source: BOL/LMDZ_Setup_amaury/lmdz_env.sh @ 5010

Last change on this file since 5010 was 5006, checked in by abarral, 2 months ago

load env in era2gcm_tuto.sh
fix jeanzay detection
minor bugfix

File size: 5.0 KB
Line 
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
10function 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
20function 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      MPICMD="mpirun -np"  # on spirit, we can't run MPI using srun from within sbatch
67      RUNBASHCMD="bash"
68      SUBMITCMD="sbatch"
69      ;;
70    adast)
71      module purge
72      module load PrgEnv-gnu
73      module load gcc/13.2.0  # required, see https://dci.dci-gitlab.cines.fr/webextranet/user_support/index.html#prgenv-and-compilers
74
75      function cdo {  # cdo is available as a spack cmd which requires a specific, incompatible env
76        unset cdo
77        module purge
78        module load GCC-CPU-3.1.0
79        /opt/software/gaia-external/CPU/cdo-2.4.0/__spack_path_placeholder__/__spack_path_placeholder__/__spack_path_placeholder__/__spa/cdo-2.4.0-gcc-12.1-b3qr/bin/cdo "$@"
80        set_env
81      }
82
83      function ferret {
84        unset ferret
85        module purge
86        module load GCC-CPU-3.1.0
87        module load ferret
88        ferret "$@"
89        set_env
90      }
91
92      account=$(/usr/sbin/my_project.py -l 2>&1 | head -1 | cut -d " " -f 3- | cut -c 5-)
93      root_dir="$WORKDIR/LMDZ_Setup";
94      ARCH="X64_ADASTRA-GNU"
95      SIMRUNBASEDIR="$SCRATCHDIR/"
96      LMDZD="$root_dir/LMDZD"
97      LMDZ_INIT="$root_dir/LMDZ_Init"
98      NB_MPI_MAX=1  # TODO 2000 in JZ
99      NB_OMP_MAX=1  # TODO 20 in JZ
100      MPICMD="srun -n"
101      RUNBASHCMD="srun --label --account=$account --constraint=GENOA --ntasks-per-node=1 -n 1 --time=00:10:00 -c"
102      SUBMITCMD="sbatch --constraint=GENOA --account=$account"
103      ;;
104    *) echo "WARNING: RUNNING THIS SCRIPT ON A LOCAL COMPUTER IS DISCOURAGED (lackluster cpus and memory)"
105      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
106      ARCH="local-gfortran-parallel"  # The arch file to use
107      SIMRUNBASEDIR="/tmp/SCRATCH/"  # Where the simulations will be executed ($SIMRUNBASEDIR/LMDZ_Setup/...)
108      LMDZD="$root_dir/LMDZD"  # Where the sources will be downloaded and compiled
109      LMDZ_INIT="$root_dir/LMDZ_Init"  # Where to store shared files used for initialisation
110      NB_MPI_MAX=2  # Max number of MPI cores (only for running simulations)
111      NB_OMP_MAX=1  # Max number of OMP threads (only for running simulations)
112      MPICMD="mpirun -np" # command to run an mpi executable, as $MPICMD <nprocs> <script>
113      RUNBASHCMD="bash" # command to run a bash job, as $runbashcmd (nthreads) <script> [nthreads only supplied if =/="bash"]
114      SUBMITCMD="."  # command to sumbit a job, as $submitcmd <script>
115      ;;
116  esac
117}
118
119get_hostname
120echo "Setting up lmdz_env on $hostname"
121set_env
122
123if [[ ! (-d $root_dir && -f $root_dir/lmdz_env.sh) ]]; then
124  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
125fi
Note: See TracBrowser for help on using the repository browser.