Skip to content

Instantly share code, notes, and snippets.

@ScottWales
Last active October 21, 2020 05:55
Show Gist options
  • Save ScottWales/623cc0bd8a669643597b890b3f665865 to your computer and use it in GitHub Desktop.
Save ScottWales/623cc0bd8a669643597b890b3f665865 to your computer and use it in GitHub Desktop.
Install dynlib at NCI
#!/bin/bash
## Option A - use the central conda environment
# module use /g/data/hh5/public/modules
# module load conda/analysis3
## Option B - use your own conda environment
conda create -c conda-forge -n dynlib python numpy pytest liblapack pytz basemap scipy matplotlib pillow netcdf4 gfortran_impl_linux-64
conda activate dynlib
# Use conda's gfortran
mkdir bin
ln -s $(which x86_64-conda_cos6-linux-gnu-gfortran) bin/gfortran
export PATH=$PWD/bin:$PATH
# Get spherepack
wget https://www2.cisl.ucar.edu/sites/default/files/spherepack3.2.tar
tar xvf spherepack3.2.tar
cd spherepack3.2
# Setup spherepack
cat > make.inc <<EOF
LIB=../lib/libspherepack.a
F90=gfortran -fPIC
CPP=gfortran -cpp
AR=ar
EOF
# Build spherepack
make
cd ..
# Get dynlib
git clone https://git.app.uib.no/Clemens.Spensberger/dynlib
cd dynlib
# Path to the spherepack we just built
export SPHEREPATH=$PWD/../spherepack3.2/lib
# Fix lib path
patch -p1 <<EOF
diff --git a/compile b/compile
index 69894d7..415873f 100755
--- a/compile
+++ b/compile
@@ -60,7 +60,7 @@ elif [ "${host::12}" == 'nird-cyclone' ]; then
RPATH=""
elif [ "$uname" == 'Linux' ]; then
# Default Linux configuration
- LIBS='-L/usr/lib -L/usr/local/lib -lblas -llapack'
+ LIBS="-L$CONDA_PREFIX/lib -llapack -lblas"
RPATH=""
else
echo "Error: Unknown host/ operating system."
EOF
# Build and install dynlib
python setup.py install --user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment