[4991] | 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 | |
---|
[4991] | 10 | function get_hostname { |
---|
| 11 | if grep -q "Adastra" /etc/motd; then |
---|
| 12 | hostname="adastra" |
---|
| 13 | else |
---|
| 14 | hostname=$(hostname) |
---|
| 15 | fi |
---|
| 16 | } |
---|
[4615] | 17 | |
---|
[4991] | 18 | function set_env { # Platform-specific |
---|
| 19 | case ${hostname:0:5} in |
---|
| 20 | jean-) |
---|
| 21 | ARCH="X64_JEANZAY" |
---|
| 22 | module purge |
---|
| 23 | compilo=19.0.4 # available 2013.0, 2017.2 |
---|
| 24 | module load intel-compilers/$compilo |
---|
| 25 | #module load intel-mpi/$compilo |
---|
| 26 | module load intel-mkl/$compilo |
---|
| 27 | module load hdf5/1.10.5-mpi |
---|
| 28 | module load netcdf/4.7.2-mpi |
---|
| 29 | module load netcdf-fortran/4.5.2-mpi |
---|
| 30 | module load subversion/1.9.7 |
---|
| 31 | #Pour module gcc, voir : https://trac.lmd.jussieu.fr/LMDZ/wiki/PortageJeanZay |
---|
| 32 | #module load gcc/6.5.0 |
---|
| 33 | module load nco |
---|
| 34 | module load cdo |
---|
| 35 | # Imputation de la consommation sur le groupe (projet) actif par defaut, |
---|
| 36 | # idrproj indique le groupe (projet) actif par defaut |
---|
| 37 | # idrproj -d newproj redefinit "newproj" en tant que projet actif, |
---|
| 38 | # alors $STORE, $WORK etc vont designer les espaces de "newproj") |
---|
| 39 | account=$(idrproj | grep active | awk '{ print $1}') |
---|
| 40 | SUBMITCMD="sbatch -A $account@cpu " |
---|
| 41 | RUNCMD="srun --label -n" |
---|
| 42 | # Espaces suivants definis par defaut en fonction du groupe actif, |
---|
| 43 | # par exemple : SCRATCHD=$SCRATCH is /gpfsstore/rech/$groupe/$login |
---|
| 44 | # * On peut aussi ne pas installer les scripts a la racine de STORE, |
---|
| 45 | # mais dans STORED=$STORE/your_folder |
---|
| 46 | SIMRUNBASEDIR="$SCRATCH/LMDZ_Setup" |
---|
| 47 | LMDZD=$WORK |
---|
| 48 | NB_MPI_MAX=2000 |
---|
| 49 | NB_OMP_MAX=20 |
---|
| 50 | #LMDZ_Init sur le $STORE du $groupe |
---|
| 51 | LMDZ_INIT=$STORE/LMDZ_Init |
---|
| 52 | ;; |
---|
| 53 | spiri) |
---|
| 54 | module purge |
---|
| 55 | module load subversion/1.13.0 |
---|
| 56 | module load gcc/11.2.0 |
---|
| 57 | module load openmpi/4.0.7 |
---|
| 58 | module load cdo/2.3.0 |
---|
[4615] | 59 | |
---|
[4991] | 60 | root_dir=~/"LMDZ_SETUP_ROOT/LMDZ_Setup"; |
---|
| 61 | ARCH="X64_MESOIPSL-GNU" |
---|
| 62 | SIMRUNBASEDIR="$SCRATCH/" |
---|
| 63 | LMDZD="$root_dir/LMDZD" |
---|
| 64 | LMDZ_INIT="$root_dir/LMDZ_Init" |
---|
| 65 | NB_MPI_MAX=20 |
---|
| 66 | NB_OMP_MAX=1 |
---|
| 67 | RUNCMD="mpirun -n" # on spirit, we can't run MPI using srun from within sbatch |
---|
| 68 | SUBMITCMD="sbatch" |
---|
| 69 | ;; |
---|
| 70 | adast) |
---|
| 71 | module purge |
---|
[4993] | 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 |
---|
[4978] | 74 | |
---|
[4993] | 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 | |
---|
[4991] | 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" |
---|
[4993] | 98 | NB_MPI_MAX=1 # TODO 2000 in JZ |
---|
| 99 | NB_OMP_MAX=1 # TODO 20 in JZ |
---|
| 100 | RUNCMD="srun --label --account=$account --constraint=GENOA -n" |
---|
| 101 | SUBMITCMD="sbatch --constraint=GENOA --account=$account" |
---|
[4991] | 102 | ;; |
---|
| 103 | *) echo "WARNING: RUNNING THIS SCRIPT ON A LOCAL COMPUTER IS DISCOURAGED (lackluster cpus and memory)" |
---|
| 104 | 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 |
---|
| 105 | ARCH="local-gfortran-parallel" # The arch file to use |
---|
| 106 | SIMRUNBASEDIR="/tmp/SCRATCH/" # Where the simulations will be executed ($SIMRUNBASEDIR/LMDZ_Setup/...) |
---|
| 107 | LMDZD="$root_dir/LMDZD" # Where the sources will be downloaded and compiled |
---|
| 108 | LMDZ_INIT="$root_dir/LMDZ_Init" # Where to store shared files used for initialisation |
---|
| 109 | NB_MPI_MAX=2 # Max number of MPI cores (only for running simulations) |
---|
| 110 | NB_OMP_MAX=1 # Max number of OMP threads (only for running simulations) |
---|
| 111 | RUNCMD="mpirun -np" # command to run a job, as $runcmd <nprocs> <script> |
---|
| 112 | SUBMITCMD="." # command to sumbit a job, as $submitcmd <script> |
---|
| 113 | ;; |
---|
| 114 | esac |
---|
| 115 | } |
---|
[4955] | 116 | |
---|
[4991] | 117 | get_hostname |
---|
| 118 | echo "Setting up lmdz_env on $hostname" |
---|
| 119 | set_env |
---|
[4958] | 120 | |
---|
| 121 | if [[ ! (-d $root_dir && -f $root_dir/lmdz_env.sh) ]]; then |
---|
| 122 | 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 |
---|
[4978] | 123 | fi |
---|