Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
#
#########################################
#
# Script to build and maintain en environment to run
# the python code in this directory. We verify that
# all needed packages are available.
# This is based on the anaconda python system : https://www.anaconda.com/distribution/
#
# Usage : source Environment
#
#########################################
#
# Functions
#
function hasanaconda (){
condahost="camelot climserv ciclad"
h=$(hostname)
res=1
for ch in ${condahost} ; do
if [ $(echo $h | grep ${ch} | wc -c) != "0" ] ; then
res=0
fi
done
return $res
}
function checkenv (){
rm -f checkenv.py
cat <<EOF > checkenv.py
import mpi4py
import spherical_geometry
import netCDF4
import matplotlib
import mpl_toolkits
import configparser
import numba
print ("OK")
EOF
python checkenv.py > /dev/null
if [ $? -gt 0 ] ; then
echo "Environment not OK. Some packages must be missing."
echo "This was tested with the checkenv.py code."
else
rm -f checkenv.py
fi
}
#
# Main
#
if ( hasanaconda ) ; then
#
# Make sure the right version of Python
#
module unload python
module load python/3.6-anaconda50
#
# Test if the MPI environment is installed.
#
if [ ! -e ${HOME}/.conda/envs/MPI ] ; then
#
# Create the MPI environment as it does not exist.
#
conda create -y -n MPI mpi4py numba astropy netcdf4 matplotlib basemap ConfigParser
source activate MPI
conda install -y --channel astropy spherical-geometry
fi
#
# Activate the MPI environment
#
source activate MPI
fi
#
# Verify we can load all the needed modules.
#
checkenv