Skip to content

Instantly share code, notes, and snippets.

@julesghub
Last active August 27, 2020 04:43
Show Gist options
  • Save julesghub/5005a10a8cc6dacd2c2c09f1622d230f to your computer and use it in GitHub Desktop.
Save julesghub/5005a10a8cc6dacd2c2c09f1622d230f to your computer and use it in GitHub Desktop.
Artemis uw-full-stack setup script
#!/bin/bash
#PBS -P BGH
#PBS -N UW_Run
#PBS -l select=1:ncpus=4:mem=3GB
#PBS -l walltime=00:20:00
#PBS -q defaultQ
source /project/RDS-FSC-BGH-RW/codes/UWGeodynamics_2.10.1.sh
cd $PBS_O_WORKDIR
OUTPUTPATH=`pwd`
MODELNAME="foobar"
SCRIPT="Tutorial_11_Coupling_with_Badlands.py"
export OPENBLAS_NUM_THREADS=1
# execution
mpiexec python3 ./$SCRIPT 1> $OUTPUTPATH/$MODELNAME.$PBS_JOBID.log 2> $OUTPUTPATH/$MODELNAME.$PBS_JOBID.err
#!/bin/bash
module purge
module load gcc/4.9.3 python/3.6.5 hdf5-gcc-mpich-3.2/1.10.1
# this is missing in the module
export HDF_DIR=/usr/local/hdf5-gcc-mpich-3.2/1.10.1
export PATH=$HDF_DIR/bin:$PATH
export GROUP=m18
export USER=
export INSTALL_NAME=UWGeodynamics_2.10
export CODES_PATH=/project/RDS-FSC-BGH-RW/codes
export UW_OPT_DIR=$CODES_PATH/opt
export INSTALL_PATH=$CODES_PATH/$INSTALL_NAME
export SWIG_VERSION=3.0.12
export SWIG_PATH=$UW_OPT_DIR/swig-$SWIG_VERSION
export PATH=$SWIG_PATH/bin:$PATH
export OMPI_MCA_io=ompio
export CDIR=$PWD
install_swig() {
tmp_dir=$(mktemp -d -t ci-XXXXXXXXXX)
cd $tmp_dir
wget http://prdownloads.sourceforge.net/swig/swig-$SWIG_VERSION.tar.gz
tar -xvzf swig-$SWIG_VERSION.tar.gz
cd swig-$SWIG_VERSION
./configure --prefix=$SWIG_PATH
make
make install
rm $tmp_dir
cd $CDIR
}
install_petsc(){
source $INSTALL_PATH/bin/activate
module load cmake
export PETSC_CONFIGURE_OPTIONS="
--with-debugging=no \
--useThreads=0 \
--with-shared-libraries \
--download-ctetgen \
--download-fblaslapack=yes \
--download-metis=yes \
--download-mumps=yes \
--download-parmetis=yes \
--download-scalapack \
--download-triangle \
--prefix=$UW_OPT_DIR/petsc-3.12.5 \
--with-hdf5-dir=/usr/local/hdf5-gcc-mpich-3.2/1.10.1 \
--with-fortran-interfaces=1 \
-I/usr/local/gcc/4.9.3/include \
-I/usr/local/gmp/5.1.3/include \
-I/usr/local/mpc/1.0.3/include \
-I/usr/local/mpfr/3.1.4/include \
-I/usr/local/mpich/3.2/include \
-I/usr/local/openssl/1.0.1s/include \
-I/usr/local/python/3.6.5/include \
-I/usr/local/zlib/1.2.8/include \
-L/usr/local/gcc/4.9.3/lib64 \
-L/usr/local/gmp/5.1.3/lib \
-L/usr/local/mpc/1.0.3/lib \
-L/usr/local/mpfr/3.1.4/lib \
-L/usr/local/mpich/3.2/lib \
-L/usr/local/openssl/1.0.1s/lib \
-L/usr/local/zlib/1.2.8/lib \
CFLAGS=-I/usr/local/python/3.6.5/include/python3.6m \
CPPFLAGS=-I/usr/local/python/3.6.5/include/python3.6m \
CXXFLAGS=-I/usr/local/openssl/1.0.1s/include \
LDFLAGS=-L/usr/local/python/3.6.5/lib"
CC=mpicc CXX=mpicxx FC=mpif90 pip install petsc==3.12.5 -vvv
}
install_python_dependencies(){
source $INSTALL_PATH/bin/activate
pip3 install --upgrade pip
pip3 install Cython numpy==1.18.4
pip3 install scons==3.1.1
pip3 install cmake lavavu==1.4.14
pip3 install mpi4py
CC="mpicc" HDF5_MPI="ON" pip3 install --no-binary=h5py h5py
}
install_underworld(){
source $INSTALL_PATH/bin/activate
export PYTHON_DIR=/usr/local/python/3.6.5/
# Artemis specific
export PETSC_DIR=$UW_OPT_DIR/petsc-3.12.5
tmp_dir=$(mktemp -d -t ci-XXXXXXXXXX)
cd $tmp_dir
# git clone https://github.com/underworldcode/underworld2.git $tmp_dir
pip3 install underworld==2.10.0b
}
install_uwgeodynamics(){
source $INSTALL_PATH/bin/activate
tmp_dir=$(mktemp -d -t ci-XXXXXXXXXX)
cd $tmp_dir
# git clone https://github.com/underworldcode/uwgeodynamics.git $tmp_dir
pip3 install UWGEOdynamics==2.10.1
rm -rf $tmp_dir
cd $CDIR
}
check_underworld_exists(){
source $INSTALL_PATH/bin/activate
return $(python3 -c "import underworld")
}
check_uwgeodynamics_exists(){
source $INSTALL_PATH/bin/activate
return $(python3 -c "import UWGeodynamics")
}
check_badlands_exists(){
source $INSTALL_PATH/bin/activate
return $(python3 -c "import badlands")
}
install_badlands(){
source $INSTALL_PATH/bin/activate
pip3 install badlands
}
install_full_stack(){
if ! command -v swig 2>/dev/null; then
install_swig
else
echo "Found swig"
fi
install_python_dependencies
if ! check_underworld_exists; then
install_underworld
fi
if ! check_uwgeodynamics_exists; then
install_uwgeodynamics
fi
if ! check_badlands_exists; then
install_badlands
fi
}
if [ ! -d "$INSTALL_PATH" ]
then
echo "Environment not found, creating a new one"
mkdir -p $INSTALL_PATH
python3 --version
python3 -m venv $INSTALL_PATH
else
echo "Found Environment"
source $INSTALL_PATH/bin/activate
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment