-
Notifications
You must be signed in to change notification settings - Fork 4
/
job_C-ESM-EP.sh
executable file
·140 lines (115 loc) · 4.45 KB
/
job_C-ESM-EP.sh
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/bin/bash
set -x
# -------------------------------------------------------- >
# --
# -- Script to run a CliMAF atlas on Ciclad, TGCC, CNRM, Spirit....
# -- - sets up the environment, except batch system specific ones which are
# assumed to be set on the submit command
# -- - specify the parameter file and the season
# -- - sets the CliMAF cache for special cases
# -- - and run the atlas
# --
# --
# -- Author: Jerome Servonnat
# -- Contact: jerome.servonnat__at__lsce.ipsl.fr
# --
# --
# -------------------------------------------------------- >
date
# -> # -- On doit pouvoir le soumettre en batch, ou le soumettre en interactif
# dans le repertoire de la composante
# -- Specify the atlas script
# -------------------------------------------------------- >
atlas_file='main_C-ESM-EP.py'
env_script='setenv_C-ESM-EP.sh'
# -- Cas interactif depuis le repertoire de la comparaison
if [[ $1 != '' ]]; then
component=${1%/}
comparison=$(basename $PWD)
#comparison=$(basename $(dirname $0) | sed 's=/==g')
env=$(cd ../; pwd)/${env_script}
main=$(cd ../; pwd)/${atlas_file}
#datasets_setup_file=datasets_setup.py
# -- Name of the parameter file
#param_file=${component}/params_${component}.py
else
# -- comparison, component, WD ... sont les variables passees avec qsub -v
component=${component%/}
echo '$comparison=' $comparison
echo '$component=' $component
echo '$WD=' $WD
echo '$cesmep_frontpage=' $cesmep_frontpage
if [[ -n ${WD} ]]; then
cd $WD
fi
env=$(cd ../..; pwd)/${env_script}
main=$(cd ../..; pwd)/${atlas_file}
fi
# -- Setup the environment...
# -------------------------------------------------------- >
echo 'CESMEP_CLIMAF_CACHE=' $CESMEP_CLIMAF_CACHE
source ${env}
echo 'CLIMAF_CACHE=' $CLIMAF_CACHE
# Need to import from comparison directory :
my_append -bp PYTHONPATH $(cd ..; pwd)
# -- Set CliMAF cache in some special cases (default is to inherit it)
# ------------------------------------------------------------------- >
if [[ -d "/data/scratch/globc" ]] ; then
CLIMAF_CACHE=/data/scratch/globc/dcom/CMIP6_TOOLS/C-ESM-EP/climafcache_${component}
fi
export CLIMAF_CACHE
echo ">>> CC= "$CLIMAF_CACHE
# -- Run the atlas...
# -------------------------------------------------------- >
echo "Running ${atlas_file} for season ${season} with parameter file ${param_file}"
#echo "Using CliMAF cache = ${CLIMAF_CACHE}"
run_main="python ${main} --comparison ${comparison} --component ${component} --cesmep_frontpage $cesmep_frontpage"
if [ -n "$docker_container" ] ; then
# this implies we are at TGCC) -> using pcocc for running a container
irene_tools=/ccc/cont003/home/igcmg/igcmg/Tools/irene
# Syntax using pcocc, which is for now buggy
#env="-e re(CCC.*DIR) -e re(CLIMAF.*) -e PYTHONPATH "
#env+="-e TMPDIR=${CLIMAF_CACHE} -e LOGNAME "
#pcocc run -s $env -I $docker_container --cwd $(pwd) <<-EOF
# Syntax using pcocc-rs
env="--env re(CCC.*DIR) --env re(CLIMAF.*) --env PYTHONPATH "
env+="--env TMPDIR=${CLIMAF_CACHE} --env LOGNAME "
pcocc-rs run $env $docker_container <<-EOF
set -x
umask 0022
export PATH=\$PATH:$irene_tools # For thredds_cp
export PYTHONPATH=/src/climaf:$PYTHONPATH
$run_main
EOF
elif [ -n "$singularity_container" ] ; then
# We are probably at IDRIS, and will use singularity
module load singularity
# File systems bindings
binds=$HOME:$HOME,$SCRATCH:$SCRATCH
# Must bind /gpfswork/rech and /gpfsstore/rech to access data in psl/common
# and of other projects
binds+=,/gpfsstore/rech:/gpfsstore/rech,/gpfswork/rech:/gpfswork/rech
# Must bind /gpfsdswork/projects to mimic a system symbolic link for $WORK
binds+=,/gpfswork:/gpfsdswork/projects
# Must bind /gpfslocalsup/bin for accessing mfthredds and thredds_cp commands
binds+=,/gpfslocalsup/bin:/gpfslocalsup/bin
# Must bind /gpfsdsmnt/ipsl/dods/pub for executing thredds_cp
binds+=,/gpfsdsmnt/ipsl/dods/pub:/gpfsdsmnt/ipsl/dods/pub
#
env="TMPDIR=${CLIMAF_CACHE},CLIMAF_CACHE=${CLIMAF_CACHE}"
env+=",LOGNAME=$LOGNAME"
#
set -x
srun --mpi=pmix_v2 singularity shell --bind $binds --env $env \
$SINGULARITY_ALLOWED_DIR/$singularity_container <<-EOG
set -x
export PATH=/gpfslocalsup/bin:\$PATH
# CliMAF location may be tuned below. Container default is /src/climaf
export CLIMAF=/src/climaf
export PYTHONPATH=\$CLIMAF:$PYTHONPATH
$run_main
EOG
else
export TMPDIR=${CLIMAF_CACHE}
$run_main
fi