[5415] | 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 | ######################################################## |
---|
[4615] | 9 | |
---|
[5415] | 10 | # <root_dir> will be set by sed by setup.sh here |
---|
[5438] | 11 | root_dir=/home/hourdin/TMP/TestI |
---|
[5426] | 12 | pub_store=1 |
---|
[4615] | 13 | |
---|
[5415] | 14 | function get_hostname { |
---|
[5422] | 15 | if grep -q "Adastra" /etc/motd 2>/dev/null ; then |
---|
[5415] | 16 | hostname="adastra" |
---|
| 17 | elif which idrquota &> /dev/null; then |
---|
| 18 | hostname="jean-zay" |
---|
| 19 | else |
---|
| 20 | hostname=$(hostname) |
---|
| 21 | fi |
---|
| 22 | } |
---|
[4615] | 23 | |
---|
[5415] | 24 | function set_env { # Platform-specific |
---|
| 25 | case ${hostname:0:5} in |
---|
[5422] | 26 | #------------------------------------------------------------------------- |
---|
| 27 | jean-) # Jean-zay, Idris-CNRS super computer |
---|
| 28 | #------------------------------------------------------------------------- |
---|
[5415] | 29 | module purge |
---|
| 30 | compilo=19.0.4 # available 2013.0, 2017.2 |
---|
| 31 | module load intel-compilers/$compilo |
---|
| 32 | #module load intel-mpi/$compilo |
---|
| 33 | module load intel-mkl/$compilo |
---|
| 34 | module load hdf5/1.10.5-mpi |
---|
| 35 | module load netcdf/4.7.2-mpi |
---|
| 36 | module load netcdf-fortran/4.5.2-mpi |
---|
| 37 | module load subversion/1.9.7 |
---|
| 38 | #Pour module gcc, voir : https://trac.lmd.jussieu.fr/LMDZ/wiki/PortageJeanZay |
---|
| 39 | #module load gcc/6.5.0 |
---|
| 40 | module load nco |
---|
| 41 | module load cdo |
---|
| 42 | # Imputation de la consommation sur le groupe (projet) actif par defaut, |
---|
| 43 | # idrproj indique le groupe (projet) actif par defaut |
---|
| 44 | # idrproj -d newproj redefinit "newproj" en tant que projet actif, |
---|
| 45 | # alors $STORE, $WORK etc vont designer les espaces de "newproj") |
---|
| 46 | account="lmd" # $(idrproj | grep active | awk '{ print $1}') doesn't work on compute nodes |
---|
| 47 | ARCH="X64_JEANZAY_PBIOIPSL" |
---|
[5420] | 48 | SIMRUNBASEDIR="$SCRATCH/$(basename $root_dir)" |
---|
[5426] | 49 | LMDZD="$WORK/LMDZD" |
---|
| 50 | LMDZ_INIT="$WORK/LMDZ/pub" |
---|
[5415] | 51 | NB_MPI_MAX=2000 |
---|
| 52 | NB_OMP_MAX=20 |
---|
| 53 | NB_CORE_PER_NODE_MAX=0 |
---|
| 54 | MPICMD="srun -n" |
---|
| 55 | RUNBASHCMD="srun -A $account@cpu --label -n 1 -c" |
---|
[5422] | 56 | #SUBMITCMD="sbatch -A $account@cpu" |
---|
| 57 | submitcmd() { |
---|
| 58 | sbatch -A $account@cpu $1 |
---|
| 59 | } |
---|
[5415] | 60 | ;; |
---|
[5422] | 61 | #------------------------------------------------------------------------- |
---|
| 62 | spiri) # Spirit : IPSL cluster |
---|
| 63 | #------------------------------------------------------------------------- |
---|
[5415] | 64 | module purge |
---|
| 65 | module load subversion/1.13.0 |
---|
| 66 | module load gcc/11.2.0 |
---|
| 67 | module load openmpi/4.0.7 |
---|
| 68 | module load cdo/2.3.0 |
---|
[4615] | 69 | |
---|
[5415] | 70 | ARCH="X64_MESOIPSL-GNU" |
---|
[5420] | 71 | SIMRUNBASEDIR="$SCRATCH/$(basename $root_dir)" |
---|
[5415] | 72 | LMDZD="$root_dir/LMDZD" |
---|
[5426] | 73 | LMDZ_INIT="$HOME/LMDZ/pub" |
---|
[5415] | 74 | NB_MPI_MAX=5 |
---|
| 75 | NB_OMP_MAX=1 |
---|
| 76 | NB_CORE_PER_NODE_MAX=0 |
---|
| 77 | N_HYPERTHREADING=1 |
---|
| 78 | MPICMD="mpirun -np" # on spirit, we can't run MPI using srun from within sbatch |
---|
| 79 | RUNBASHCMD="bash" |
---|
[5422] | 80 | #SUBMITCMD="sbatch" |
---|
| 81 | submitcmd() { |
---|
| 82 | sbatch $1 |
---|
| 83 | } |
---|
[5415] | 84 | ;; |
---|
[5422] | 85 | #------------------------------------------------------------------------- |
---|
| 86 | adast) # Adastra, Cines computing center |
---|
| 87 | #------------------------------------------------------------------------- |
---|
[5415] | 88 | module purge |
---|
| 89 | module load PrgEnv-gnu # we need to load the env because lmdz links some shared libraries |
---|
| 90 | module load gcc/13.2.0 # required, see https://dci.dci-gitlab.cines.fr/webextranet/user_support/index.html#prgenv-and-compilers |
---|
| 91 | export CRAY_CPU_TARGET=x86-64 # to suppress warnings during Cmake netcdf95 build |
---|
| 92 | export FI_CXI_RX_MATCH_MODE=hybrid # 09/24 otherwise we get random SIGABRT e.g. "libfabric:2490616:1725895288::cxi:core:cxip_ux_onload_cb():2657<warn> c1456: RXC (0x5130:21) PtlTE 84:[Fatal] LE resources not recovered during flow control. FI_CXI_RX_MATCH_MODE=[hybrid|software] is required" |
---|
[4615] | 93 | |
---|
[5415] | 94 | function cdo { # cdo is available as a spack cmd which requires a specific, incompatible env |
---|
| 95 | unset cdo |
---|
| 96 | module purge |
---|
| 97 | module load develop GCC-CPU-4.0.0 cdo/2.4.2-omp-mpi |
---|
| 98 | cdo "$@" |
---|
| 99 | set_env |
---|
| 100 | } |
---|
[4615] | 101 | |
---|
[5415] | 102 | function ferret { |
---|
| 103 | unset ferret |
---|
| 104 | module purge |
---|
| 105 | module load GCC-CPU-3.1.0 |
---|
| 106 | module load ferret |
---|
| 107 | ferret "$@" |
---|
| 108 | set_env |
---|
| 109 | } |
---|
| 110 | |
---|
| 111 | account=$(/usr/sbin/my_project.py -l 2>&1 | head -1 | cut -d " " -f 3- | cut -c 5-) |
---|
| 112 | ARCH="X64_ADASTRA-GNU" |
---|
[5420] | 113 | SIMRUNBASEDIR="$SCRATCHDIR/$(basename $root_dir)" |
---|
[5426] | 114 | LMDZD="$WORKDIR/LMDZD" |
---|
| 115 | LMDZ_INIT="$WORKDIR/LMDZ/pub" |
---|
[5415] | 116 | NB_MPI_MAX=2000 |
---|
| 117 | NB_OMP_MAX=200 |
---|
| 118 | NB_CORE_PER_NODE_MAX=192 |
---|
| 119 | N_HYPERTHREADING=1 # Adastra has SMT=2 enabled, but we found no actual performance improvement for the latlon model. Maybe useful for Dynamico ? |
---|
| 120 | MPICMD="srun -n" |
---|
| 121 | # RUNBASHCMD="srun --label --account=$account --constraint=GENOA --ntasks-per-node=1 -n 1 --time=00:15:00 -c" |
---|
| 122 | RUNBASHCMD="bash" # On Adastra the docs says we can use login nodes for compilation |
---|
[5422] | 123 | #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 |
---|
| 124 | submitcmd() { |
---|
[5424] | 125 | env $(env | grep -E "SLURM_|SBATCH_|SRUN_" | cut -d= -f1 | awk '{print "-u " $0}' | tr '\n' ' ' ) sbatch --constraint=GENOA --account=$account $1 |
---|
[5422] | 126 | } # we need to remove the existing SLURM variables otherwise they may be unexpectedly inherited by the submitted script |
---|
[5415] | 127 | ;; |
---|
[5422] | 128 | #------------------------------------------------------------------------- |
---|
| 129 | *) # Local machine. |
---|
| 130 | #------------------------------------------------------------------------- |
---|
[5415] | 131 | ARCH="local-gfortran-parallel" # The arch file to use |
---|
[5420] | 132 | SIMRUNBASEDIR="$root_dir/SCRATCH/" # Where the simulations will be executed ($SIMRUNBASEDIR/LMDZ_Setup/...) |
---|
[5426] | 133 | LMDZD="$root_dir/../LMDZD" # Where the sources will be downloaded and compiled |
---|
| 134 | if [[ $pub_store ]] ; then LMDZ_INIT="$HOME/LMDZ/pub" ; else LMDZ_INIT="$root_dir/LMDZ/pub" ; fi |
---|
[5415] | 135 | NB_MPI_MAX=2 # Max number of MPI cores (only for running simulations) |
---|
| 136 | NB_OMP_MAX=2 # Max number of OMP threads (only for running simulations) |
---|
| 137 | NB_CORE_PER_NODE_MAX=0 # Max number of cores per node (real cores, not hyperthreading - only for running simulations, cluster-specific) |
---|
| 138 | N_HYPERTHREADING=1 # How many hyperthreading threads per physical core |
---|
| 139 | MPICMD="mpirun -np" # command to run an mpi executable, as $MPICMD <nprocs> <script> |
---|
| 140 | RUNBASHCMD="bash" # command to run a bash job, as $runbashcmd (nthreads) <script> [nthreads only supplied if =/="bash"] |
---|
[5422] | 141 | #SUBMITCMD="." # command to sumbit a job, as $submitcmd <script> |
---|
| 142 | submitcmd() { |
---|
| 143 | nohup bash $1 > out.$$ 2>err.$$ & |
---|
| 144 | } |
---|
[5415] | 145 | ;; |
---|
| 146 | esac |
---|
| 147 | } |
---|
| 148 | |
---|
[5426] | 149 | #----------------------------------------------------------------------------------------------------- |
---|
| 150 | function wget_pub() { # geting file from http:lmdz... and saving on $LMDZ_INIT |
---|
| 151 | #----------------------------------------------------------------------------------------------------- |
---|
| 152 | local dir=$1 |
---|
| 153 | local file=$2 |
---|
| 154 | local target_dir=$LMDZ_INIT/$dir |
---|
| 155 | if [ ! -f $target_dir/$file ] ; then |
---|
| 156 | mkdir -p $target_dir |
---|
| 157 | cd $target_dir |
---|
| 158 | wget --no-check-certificate -nv "http://lmdz.lmd.jussieu.fr/pub/$dir/$file" |
---|
| 159 | cd - |
---|
| 160 | fi |
---|
| 161 | } |
---|
| 162 | |
---|
| 163 | #----------------------------------------------------------------------------------------------------- |
---|
| 164 | function cp_from_pub() { # geting file from http:lmdz... and saving on $LMDZ_INIT |
---|
| 165 | #----------------------------------------------------------------------------------------------------- |
---|
| 166 | local dir=$1 |
---|
| 167 | local file=$2 |
---|
| 168 | cp -f $LMDZ_INIT/$dir/$file . |
---|
| 169 | } |
---|
| 170 | |
---|
| 171 | #----------------------------------------------------------------------------------------------------- |
---|
| 172 | function ln_from_pub() { # geting file from http:lmdz... and saving on $LMDZ_INIT |
---|
| 173 | #----------------------------------------------------------------------------------------------------- |
---|
| 174 | local dir=$1 |
---|
| 175 | local file=$2 |
---|
| 176 | ln -sf $LMDZ_INIT/$dir/$file . |
---|
| 177 | } |
---|
| 178 | |
---|
[5429] | 179 | #----------------------------------------------------------------------------------------------------- |
---|
| 180 | function get_input_files() { |
---|
| 181 | #----------------------------------------------------------------------------------------------------- |
---|
| 182 | local method=$1 |
---|
| 183 | local target=$2 |
---|
| 184 | case $target in |
---|
| 185 | |
---|
| 186 | Orchidee) local files="PFTmap_IPCC_2000.nc cartepente2d_15min.nc routing.nc routing_simple.nc lai2D.nc \ |
---|
| 187 | alb_bg_modisopt_2D_ESA_v2.nc reftemp.nc \ |
---|
| 188 | soils_param.nc woodharvest_2000.nc PFTmap_15PFT.v1_2000.nc soil_bulk_and_ph.nc \ |
---|
| 189 | ndep_nhx.nc ndep_noy.nc nfert_cropland.nc nfert_pasture.nc nmanure_cropland.nc nmanure_pasture.nc bnf.nc" ;; |
---|
| 190 | |
---|
| 191 | AerChem) local files="aerosols1850_from_inca.nc aerosols9999_from_inca.nc" ;; |
---|
| 192 | |
---|
| 193 | SPLA_WA/emissions) local files="donnees_lisa.nc SOILSPEC.data \ |
---|
[5438] | 194 | cly.dat $( for i in $(seq -w 1 12 ) ; do echo dust$i.nc ; done ) wth.dat \ |
---|
[5429] | 195 | carbon_emissions.nc sulphur_emissions_antro.nc sulphur_emissions_nat.nc \ |
---|
| 196 | sulphur_emissions_volc.nc" ;; |
---|
| 197 | |
---|
| 198 | *) echo target $target non available in get_input_files ; exit 1 ;; |
---|
| 199 | esac |
---|
| 200 | |
---|
| 201 | if [[ $method != wget_pub && $method != ln_from_pub ]] ; then |
---|
| 202 | echo method $method not available in get_input_files ; exit 1 |
---|
| 203 | fi |
---|
| 204 | for file in $files ; do $method 3DInputData/$target $file ; done |
---|
| 205 | |
---|
| 206 | } |
---|
| 207 | |
---|
[5415] | 208 | get_hostname |
---|
| 209 | echo "Setting up lmdz_env on $hostname" |
---|
| 210 | set_env |
---|
| 211 | |
---|
| 212 | if [[ ! (-d $root_dir && -f $root_dir/.lmdz_setup_root_dir && -f $root_dir/lmdz_env.sh) ]]; then |
---|
| 213 | echo "STOP: root_dir $root_dir not found, either you are running on an unsupported cluster, or the initialisation failed midway"; exit 1 |
---|
| 214 | fi |
---|