From 5f5c8dc9635873d051bfa2d9f06df41f9015580c Mon Sep 17 00:00:00 2001
From: Tobias Meisel <tobias.meisel@ufz.de>
Date: Thu, 24 Mar 2022 12:56:17 +0100
Subject: [PATCH] [env] Added module setup script for TAURUS (not tested in CI)

---
 scripts/env/taurus/build_ogs.sh   | 19 +++++++++++++++++++
 scripts/env/taurus/build_petsc.sh | 22 ++++++++++++++++++++++
 scripts/env/taurus/cli.sh         |  8 ++++++++
 scripts/env/taurus/petsc.sh       | 19 +++++++++++++++++++
 scripts/env/taurus/user.sh        |  5 +++++
 5 files changed, 73 insertions(+)
 create mode 100644 scripts/env/taurus/build_ogs.sh
 create mode 100644 scripts/env/taurus/build_petsc.sh
 create mode 100644 scripts/env/taurus/cli.sh
 create mode 100644 scripts/env/taurus/petsc.sh
 create mode 100644 scripts/env/taurus/user.sh

diff --git a/scripts/env/taurus/build_ogs.sh b/scripts/env/taurus/build_ogs.sh
new file mode 100644
index 00000000000..0c88258b346
--- /dev/null
+++ b/scripts/env/taurus/build_ogs.sh
@@ -0,0 +1,19 @@
+# Alternative: OGS_DIR=$HOME/o/
+OGS_DIR=$( realpath ../../../.. )
+BIN_DIR=rp
+ENV=taurus
+source $OGS_DIR/s/scripts/env/$ENV/petsc.sh
+
+echo "Folder with all PETSC binaries for selected Partition: $PETSC_DIR"
+
+BUILD_DIR=$OGS_DIR/build/$PARTITION_NAME/$BIN_DIR/
+
+mkdir -p $OGS_DIR/build/cpm_cache
+mkdir -p $BUILD_DIR
+cd $BUILD_DIR
+
+export CPM_SOURCE_DIR=$OGS_DIR/build/cpm_cache
+
+CC=`which mpicc` CXX=`which mpic++` cmake $OGS_DIR/s -G Ninja -DCMAKE_BUILD_TYPE=Release -DOGS_EIGEN_DYNAMIC_SHAPE_MATRICES=Off -DOGS_USE_PCH=Off -DOGS_USE_PETSC=On -DOGS_BUILD_PROCESSES="HT" -DPETSC_DIR=$PETSC_DIR -DPETSC_ARCH=arch-linux-c-opt
+
+ninja -j 8
\ No newline at end of file
diff --git a/scripts/env/taurus/build_petsc.sh b/scripts/env/taurus/build_petsc.sh
new file mode 100644
index 00000000000..a4952e5e360
--- /dev/null
+++ b/scripts/env/taurus/build_petsc.sh
@@ -0,0 +1,22 @@
+if [ -n "$ZSH_VERSION" ]; then
+    DIR=$( cd $(dirname "${(%):-%x}") ; pwd -P )
+
+else
+    DIR=$( cd $(dirname "${BASH_SOURCE[0]}") ; pwd -P )
+fi
+
+source $DIR/petsc.sh
+
+PETSC_INSTALL=$ALL_PETSC_DIR/$PARTITION_NAME/
+mkdir -p $PETSC_INSTALL
+
+cd $ALL_PETSC_DIR
+echo "Clone or checkout PETSC (Version: $PETSC_VERSION) to $PETSC_DIR."
+git clone --depth 1 --branch $PETSC_VERSION --single-branch https://gitlab.com/petsc/petsc.git $PETSC_DIR || (cd $PETSC_DIR ; git pull)
+mkdir -p petsc_$PETSC_VERSION
+cd $PETSC_DIR
+echo "Build PETSC in $PETSC_DIR started."
+./configure --with-cc=gcc --with-cxx=g++ --with-fc=0 --prefix=PETSC_INSTALL --with-debugging=0
+make
+make PETSC_DIR=$PETSC_DIR PETSC_ARCH=arch-linux-c-opt install
+echo "Build PETSC in $PETSC_DIR done."
diff --git a/scripts/env/taurus/cli.sh b/scripts/env/taurus/cli.sh
new file mode 100644
index 00000000000..195ca0e4d9a
--- /dev/null
+++ b/scripts/env/taurus/cli.sh
@@ -0,0 +1,8 @@
+module purge
+module load foss/2021b
+# foss/2021b loads GCCcore/11.2.0, OpenMPI/4.4.1-GCC-11.2.0, ScaLAPACK/2.1.0-gompi-2021b-fb
+
+module load Ninja/1.10.2
+module load CMake/3.21.1
+module load git-lfs/2.7.2
+module load git/2.33.1-GCCcore-11.2.0-nodocs
diff --git a/scripts/env/taurus/petsc.sh b/scripts/env/taurus/petsc.sh
new file mode 100644
index 00000000000..bcdd782a7b9
--- /dev/null
+++ b/scripts/env/taurus/petsc.sh
@@ -0,0 +1,19 @@
+if [ -n "$ZSH_VERSION" ]; then
+    DIR=$( cd $(dirname "${(%):-%x}") ; pwd -P )
+else
+    DIR=$( cd $(dirname "${BASH_SOURCE[0]}") ; pwd -P )
+fi
+
+source $DIR/cli.sh
+source $DIR/user.sh
+
+module load HDF5/1.12.1
+module load Python/3.9.6
+module load Boost/1.77
+
+# VTK will be built by CPM, because no VTK build with GCCCore/11.2.0 in foss/2021b available
+
+# PETSC needs custom build!
+PETSC_VERSION=v3.16.4
+LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ALL_PETSC_DIR/$PARTITION_NAME/lib
+PETSC_DIR=$ALL_PETSC_DIR/$PARTITION_NAME/petsc_$PETSC_VERSION
\ No newline at end of file
diff --git a/scripts/env/taurus/user.sh b/scripts/env/taurus/user.sh
new file mode 100644
index 00000000000..558417cd849
--- /dev/null
+++ b/scripts/env/taurus/user.sh
@@ -0,0 +1,5 @@
+# Location of all petsc builds are specified by user 
+ALL_PETSC_DIR=$HOME/petsc/
+# Cluster partition names are based https://doc.zih.tu-dresden.de/jobs_and_resources/hardware_overview/
+# alpha, romeo, julia, ml, haswell, broadwell, gpu2, smp2
+PARTITION_NAME=haswell
-- 
GitLab