1 | #!/bin/bash |
---|
2 | ######################################################## |
---|
3 | # This file loads the required modules and sets the paths for simulations |
---|
4 | # To modify the paths: |
---|
5 | # 1) In the <set_env> function, find the section corresponding to your machine |
---|
6 | # 2) Modify the variables, which are documented in the *) section of <set_env> |
---|
7 | # See the end of <set_env> for the explanation of each |
---|
8 | ######################################################## |
---|
9 | |
---|
10 | function get_hostname { |
---|
11 | if grep -q "Adastra" /etc/motd; then |
---|
12 | hostname="adastra" |
---|
13 | elif which idrquota &> /dev/null; then |
---|
14 | hostname="jean-zay" |
---|
15 | else |
---|
16 | hostname=$(hostname) |
---|
17 | fi |
---|
18 | } |
---|
19 | |
---|
20 | function set_env { # Platform-specific |
---|
21 | case ${hostname:0:5} in |
---|
22 | jean-) |
---|
23 | module purge |
---|
24 | compilo=19.0.4 # available 2013.0, 2017.2 |
---|
25 | module load intel-compilers/$compilo |
---|
26 | #module load intel-mpi/$compilo |
---|
27 | module load intel-mkl/$compilo |
---|
28 | module load hdf5/1.10.5-mpi |
---|
29 | module load netcdf/4.7.2-mpi |
---|
30 | module load netcdf-fortran/4.5.2-mpi |
---|
31 | module load subversion/1.9.7 |
---|
32 | #Pour module gcc, voir : https://trac.lmd.jussieu.fr/LMDZ/wiki/PortageJeanZay |
---|
33 | #module load gcc/6.5.0 |
---|
34 | module load nco |
---|
35 | module load cdo |
---|
36 | # Imputation de la consommation sur le groupe (projet) actif par defaut, |
---|
37 | # idrproj indique le groupe (projet) actif par defaut |
---|
38 | # idrproj -d newproj redefinit "newproj" en tant que projet actif, |
---|
39 | # alors $STORE, $WORK etc vont designer les espaces de "newproj") |
---|
40 | account="lmd" # $(idrproj | grep active | awk '{ print $1}') doesn't work on compute nodes |
---|
41 | root_dir="$WORK/LMDZ_Setup"; |
---|
42 | ARCH="X64_JEANZAY" |
---|
43 | SIMRUNBASEDIR="$SCRATCH/" |
---|
44 | LMDZD="$root_dir/LMDZD" |
---|
45 | LMDZ_INIT="$root_dir/LMDZ_Init" |
---|
46 | NB_MPI_MAX=2000 |
---|
47 | NB_OMP_MAX=20 |
---|
48 | MPICMD="srun -n" |
---|
49 | RUNBASHCMD="srun -A $account@cpu --label -n 1 -c" |
---|
50 | SUBMITCMD="sbatch -A $account@cpu" |
---|
51 | ;; |
---|
52 | spiri) |
---|
53 | module purge |
---|
54 | module load subversion/1.13.0 |
---|
55 | module load gcc/11.2.0 |
---|
56 | module load openmpi/4.0.7 |
---|
57 | module load cdo/2.3.0 |
---|
58 | |
---|
59 | root_dir="/data/abarral/LMDZ_SETUP_ROOT/LMDZ_Setup"; |
---|
60 | ARCH="X64_MESOIPSL-GNU" |
---|
61 | SIMRUNBASEDIR="$SCRATCH/" |
---|
62 | LMDZD="$root_dir/LMDZD" |
---|
63 | LMDZ_INIT="$root_dir/LMDZ_Init" |
---|
64 | NB_MPI_MAX=5 |
---|
65 | NB_OMP_MAX=1 |
---|
66 | NB_CORE_PER_NODE_MAX=0 |
---|
67 | N_HYPERTHREADING=1 |
---|
68 | MPICMD="mpirun -np" # on spirit, we can't run MPI using srun from within sbatch |
---|
69 | RUNBASHCMD="bash" |
---|
70 | SUBMITCMD="sbatch" |
---|
71 | ;; |
---|
72 | adast) |
---|
73 | module purge |
---|
74 | module load PrgEnv-gnu # we need to load the env because lmdz links some shared libraries |
---|
75 | module load gcc/13.2.0 # required, see https://dci.dci-gitlab.cines.fr/webextranet/user_support/index.html#prgenv-and-compilers |
---|
76 | |
---|
77 | function cdo { # cdo is available as a spack cmd which requires a specific, incompatible env |
---|
78 | unset cdo |
---|
79 | module purge |
---|
80 | module load GCC-CPU-4.0.0 |
---|
81 | module load cdo/2.4.2-omp-mpi |
---|
82 | cdo "$@" |
---|
83 | set_env |
---|
84 | } |
---|
85 | |
---|
86 | function ferret { |
---|
87 | unset ferret |
---|
88 | module purge |
---|
89 | module load GCC-CPU-3.1.0 |
---|
90 | module load ferret |
---|
91 | ferret "$@" |
---|
92 | set_env |
---|
93 | } |
---|
94 | |
---|
95 | account=$(/usr/sbin/my_project.py -l 2>&1 | head -1 | cut -d " " -f 3- | cut -c 5-) |
---|
96 | root_dir="$WORKDIR/LMDZ_Setup"; |
---|
97 | ARCH="X64_ADASTRA-GNU" |
---|
98 | SIMRUNBASEDIR="$SCRATCHDIR/" |
---|
99 | LMDZD="$root_dir/LMDZD" |
---|
100 | LMDZ_INIT="$root_dir/LMDZ_Init" |
---|
101 | NB_MPI_MAX=2000 |
---|
102 | NB_OMP_MAX=200 |
---|
103 | NB_CORE_PER_NODE_MAX=192 |
---|
104 | N_HYPERTHREADING=1 # Adastra has SMT=2 enabled, but we found no actual performance improvement for the latlon model. Maybe useful for Dynamico ? |
---|
105 | MPICMD="srun -n" |
---|
106 | # RUNBASHCMD="srun --label --account=$account --constraint=GENOA --ntasks-per-node=1 -n 1 --time=00:15:00 -c" |
---|
107 | RUNBASHCMD="bash" # On Adastra the docs says we can use login nodes for compilation |
---|
108 | SUBMITCMD="env $(env | grep -E "SLURM_|SBATCH_|SRUN_" | cut -d= -f1 | awk '{print "-u " $0}' | tr '\n' ' ' ) sbatch --constraint=GENOA --account=$account" # we need to remove the existing SLURM variables otherwise they may be unexpectedly inherited by the submitted script |
---|
109 | ;; |
---|
110 | *) echo "WARNING: RUNNING THIS SCRIPT ON A LOCAL COMPUTER IS DISCOURAGED (lackluster cpus and memory)" |
---|
111 | root_dir="/home/abarral/PycharmProjects/installLMDZ/LMDZ_Setup"; # Where you have extracted LMDZ_Setup. Can't use $(pwd) since this script gets copied and ran from several locations |
---|
112 | ARCH="local-gfortran-parallel" # The arch file to use |
---|
113 | SIMRUNBASEDIR="/tmp/SCRATCH/" # Where the simulations will be executed ($SIMRUNBASEDIR/LMDZ_Setup/...) |
---|
114 | LMDZD="$root_dir/LMDZD" # Where the sources will be downloaded and compiled |
---|
115 | LMDZ_INIT="$root_dir/LMDZ_Init" # Where to store shared files used for initialisation |
---|
116 | NB_MPI_MAX=2 # Max number of MPI cores (only for running simulations) |
---|
117 | NB_OMP_MAX=2 # Max number of OMP threads (only for running simulations) |
---|
118 | NB_CORE_PER_NODE_MAX=0 # Max number of cores per node (real cores, not hyperthreading - only for running simulations, cluster-specific) |
---|
119 | N_HYPERTHREADING=1 # How many hyperthreading threads per physical core |
---|
120 | MPICMD="mpirun -np" # command to run an mpi executable, as $MPICMD <nprocs> <script> |
---|
121 | RUNBASHCMD="bash" # command to run a bash job, as $runbashcmd (nthreads) <script> [nthreads only supplied if =/="bash"] |
---|
122 | SUBMITCMD="." # command to sumbit a job, as $submitcmd <script> |
---|
123 | ;; |
---|
124 | esac |
---|
125 | } |
---|
126 | |
---|
127 | get_hostname |
---|
128 | echo "Setting up lmdz_env on $hostname" |
---|
129 | set_env |
---|
130 | |
---|
131 | if [[ ! (-d $root_dir && -f $root_dir/lmdz_env.sh) ]]; then |
---|
132 | echo "STOP: root_dir $root_dir not found, either you are running on an unsupported cluster, or you haven't edited lmdz_env.sh properly"; exit 1 |
---|
133 | fi |
---|