[5535] | 1 | !/bin/bash |
---|
[5415] | 2 | # This script sets up and launches a (series of) simulation(s). |
---|
| 3 | # RECOMMENDATION: use main.sh to drive it (do not run it directly) |
---|
[4615] | 4 | |
---|
[5415] | 5 | set -eu |
---|
[4615] | 6 | |
---|
[5438] | 7 | #--------------------------------------------------------------------------- |
---|
| 8 | function define_expert_options() { # Expert-level choices |
---|
| 9 | #--------------------------------------------------------------------------- |
---|
| 10 | |
---|
| 11 | # optim: either "" or "-debug" to compile in debug mode |
---|
| 12 | # (slower but better diagnosis of segfaults) |
---|
[5415] | 13 | optim="" |
---|
[4615] | 14 | |
---|
[5438] | 15 | # "n" or "y". If testmode="y", then simulations run for a single day |
---|
| 16 | # per period. |
---|
[5415] | 17 | # NOTE: you must set mthend accordingly ! |
---|
| 18 | testmode="n" |
---|
[4615] | 19 | |
---|
[5415] | 20 | # Radiative code: "oldrad" / "rrtm" / "ecrad" |
---|
| 21 | rad="rrtm" |
---|
[4615] | 22 | |
---|
[5438] | 23 | # !!! STRONG recommendation : experiments with DIFFERENT Orchidee or |
---|
| 24 | # aerosol options should be performed in DIFFERENT LMDZ_Setup folders |
---|
[5415] | 25 | # !!! (especially as they may need different initial files) |
---|
[4615] | 26 | |
---|
[5438] | 27 | # AEROSOLS : "n" (=no)/"clim" (=average 1995-2014) / "spla" (interactive) |
---|
| 28 | # (WARNING : if you first run the scripts with aerosols=n, then you want |
---|
| 29 | # to change to =clim, you must remove the INIT and LIMIT folders and |
---|
| 30 | # rerun main.sh with init=1 in order to create aerosol files |
---|
| 31 | |
---|
[5415] | 32 | aerosols="clim" |
---|
[4615] | 33 | |
---|
[5415] | 34 | # SURFACE/VEGETATION SCHEME |
---|
[5438] | 35 | # - "none" : bucket scheme |
---|
| 36 | # CMIP6 : orchidee CMIP6 version |
---|
| 37 | # 7983/7994 : orchidee svn release 7983 (orch2.2) and 7994 (last tested) |
---|
| 38 | # If you need other orch versions, and also require XIOS, you'll need |
---|
| 39 | # to create the appropriate files in DEF/XMLfilesOR... |
---|
[5415] | 40 | veget="CMIP6" |
---|
[4615] | 41 | |
---|
[5415] | 42 | # New snow scheme INLANDSIS! "y" / "n" |
---|
[5438] | 43 | # Activates INLANDSIS compilation |
---|
| 44 | # to be done : treatment of specific restart and def file |
---|
[5415] | 45 | inlandsis="n" |
---|
[4615] | 46 | |
---|
[5415] | 47 | # netcdf: 0 (use existing library) / 1 (recompile netcdf, slow) |
---|
| 48 | netcdf=0 |
---|
[4615] | 49 | |
---|
[5438] | 50 | # --->>> ALSO PAY ATTENTION TO OUTPUT files, frequency, level ------------ |
---|
| 51 | # With IOIPSL : Choose your config.def among versions available in DEF, |
---|
[5415] | 52 | # copy it as config.def (the copy is done automatically for "iso"), |
---|
| 53 | # edit it and set up output files, frequencies and levels. |
---|
[5438] | 54 | # NB : For aerosols=spla, output level minimum 4 is required to outpu |
---|
| 55 | # the specific variables. |
---|
| 56 | # For aerosols=n, aerosol flags will automatically be set to "n". |
---|
[5415] | 57 | # With XIOS : adjust DEF/XMLfiles*/file*xml |
---|
| 58 | } |
---|
[4615] | 59 | |
---|
| 60 | |
---|
[5438] | 61 | #--------------------------------------------------------------------------- |
---|
| 62 | function enable_platform() { # Sed platform-specific headers |
---|
| 63 | #--------------------------------------------------------------------------- |
---|
[5415] | 64 | local file="$1" |
---|
| 65 | local platform |
---|
[4615] | 66 | |
---|
[5415] | 67 | case ${hostname:0:5} in |
---|
| 68 | jean-) platform="JZ";; |
---|
| 69 | spiri) platform="SP";; |
---|
| 70 | adast) platform="ADS";; |
---|
| 71 | *) echo "Warning: $hostname is not a known job platform (ignore if running locally)"; return 0;; |
---|
| 72 | esac |
---|
[4615] | 73 | |
---|
[5415] | 74 | sed -i'' -e "s/^#@$platform//" "$file" |
---|
| 75 | } |
---|
[4615] | 76 | |
---|
[5438] | 77 | #--------------------------------------------------------------------------- |
---|
| 78 | function load_install_lib() { #Fetch and source install_lmdz.sh to get myget |
---|
| 79 | #--------------------------------------------------------------------------- |
---|
[5415] | 80 | if [[ ! -f "install_lmdz.sh" ]]; then |
---|
| 81 | wget --no-cache "http://svn.lmd.jussieu.fr/LMDZ/BOL/script_install/install_lmdz.sh" |
---|
| 82 | fi |
---|
| 83 | # shellcheck disable=SC1090 |
---|
| 84 | source <(sed 's/function \(.*\) {/function installlmdz_\1 {/g' install_lmdz.sh) # source with a namespace for functions |
---|
| 85 | function myget { installlmdz_myget "$@"; } |
---|
[4615] | 86 | } |
---|
| 87 | |
---|
[5438] | 88 | #--------------------------------------------------------------------------- |
---|
| 89 | function set_default_params() { # Default value of script parameters |
---|
| 90 | #--------------------------------------------------------------------------- |
---|
| 91 | |
---|
[5464] | 92 | SIM=$(basename "$local_d")CTL # name |
---|
[5415] | 93 | phylmd="lmd" #option -p $phylmd for makelmdz |
---|
[4615] | 94 | |
---|
[5415] | 95 | cosp="n" # COSP |
---|
| 96 | xios="n" #XIOS |
---|
[4615] | 97 | |
---|
[5415] | 98 | # Nudging : |
---|
| 99 | ok_guide="n" |
---|
| 100 | # With nudging, use real calendar (climato=0) and monthly integrations |
---|
| 101 | climato=1 |
---|
| 102 | freq="mo" # frequence mensuelle mo ou annuelle yr |
---|
[4615] | 103 | |
---|
[5415] | 104 | # NB : the run stops in the BEGINNING of mthend (test "next=stopsim") |
---|
| 105 | mthini=200001 |
---|
| 106 | mthend=200501 |
---|
| 107 | resol="144x142x79" |
---|
[4615] | 108 | |
---|
[5415] | 109 | version="20230412.trunk" |
---|
| 110 | svn="" |
---|
[4615] | 111 | |
---|
[5415] | 112 | init=1 |
---|
[4615] | 113 | |
---|
[5415] | 114 | LIMIT="LIMIT" |
---|
[4615] | 115 | |
---|
[5415] | 116 | } |
---|
[4615] | 117 | |
---|
[5438] | 118 | #--------------------------------------------------------------------------- |
---|
[5415] | 119 | function read_cmdline_args() { |
---|
[5438] | 120 | #--------------------------------------------------------------------------- |
---|
[5415] | 121 | while (($# > 0)); do |
---|
| 122 | case $1 in |
---|
| 123 | "-h") cat <<........fin |
---|
[5428] | 124 | setup.sh can be launched/driven by main.sh |
---|
[5415] | 125 | setup.sh [-v version] [-r svn_release] [-init INIT] [-d 96x95x79] [-f mo] [-nudging] |
---|
| 126 | -v "version" like 20150828.trunk; see https://lmdz.lmd.jussieu.fr/Distrib/LISMOI.trunk (default <$version>) |
---|
[5428] | 127 | -r "svn_release" either the svn release number or "last" (default <$svn>) |
---|
| 128 | -d IMxJMxLM to run in resolution IM x JM x LM (default <$resol>) |
---|
| 129 | -install pour installer et compiler le modele |
---|
| 130 | -f mo/yr pour tourner en mensuel ou annuel (default <$freq>) |
---|
| 131 | -rad RAD Radiation |
---|
| 132 | -netcdf 0/1/DIR Netcdf installation |
---|
| 133 | -aerosols n/clim/spla Aerosols : none / climatological / interactive with SPLA |
---|
| 134 | -veget CMIP6 CMIP6 version of rchidee |
---|
| 135 | 7983 orch2.2 |
---|
| 136 | 7994 trunk |
---|
| 137 | "INIT" 1: creates INIT and LIMIT |
---|
| 138 | 0: reads from INIT and LIMIT |
---|
| 139 | SIMU: reads from preexisting simulation SIMU and LIMIT (default <$init>) |
---|
| 140 | -nudging to run with nudging. Nudging files must be created independently |
---|
| 141 | -p the physics to use (default <$phylmd>) |
---|
| 142 | -name install folder name (default <$SIM>) |
---|
[5415] | 143 | Other options available (see "options" section in the script) |
---|
[4615] | 144 | ........fin |
---|
[5415] | 145 | exit;; |
---|
| 146 | "-v") version="$2"; shift; shift;; |
---|
| 147 | "-r") svn=$2; shift; shift;; |
---|
| 148 | "-d") resol=$2; shift; shift;; |
---|
| 149 | "-f") freq=$2; shift; shift;; |
---|
| 150 | "-p") phylmd=$2; shift; shift;; |
---|
| 151 | "-name") SIM=$2; shift; shift;; |
---|
[5428] | 152 | "-rad") rad=$2; shift; shift;; |
---|
| 153 | "-netcdf") netcdf=$2; shift; shift;; |
---|
| 154 | "-aerosols") aerosols=$2; shift; shift;; |
---|
| 155 | "-veget") veget=$2; shift; shift;; |
---|
[5415] | 156 | "-cosp") cosp=y; shift;; |
---|
| 157 | "-xios") xios=y; shift;; |
---|
| 158 | "-init") init=$2; shift; shift;; |
---|
| 159 | "-nudging") ok_guide=y; shift;; |
---|
| 160 | "-climato") climato=$2; shift; shift;; |
---|
| 161 | "-mthini") mthini=$2; shift; shift;; |
---|
| 162 | "-mthend") mthend=$2; shift; shift;; |
---|
| 163 | *) echo "unexpected $1"; $0 -h; exit |
---|
| 164 | esac |
---|
| 165 | done |
---|
[4615] | 166 | |
---|
[5415] | 167 | # Initialisation |
---|
| 168 | if [[ $init = 1 || $init = 0 ]]; then |
---|
| 169 | INIT="INIT" |
---|
| 170 | else |
---|
| 171 | INIT=$init |
---|
| 172 | fi |
---|
[4615] | 173 | |
---|
[5428] | 174 | case $rad in |
---|
| 175 | oldrad) iflag_rrtm=0; NSW=2;; |
---|
| 176 | rrtm) iflag_rrtm=1; NSW=6;; |
---|
| 177 | ecrad) iflag_rrtm=2; NSW=6;; |
---|
| 178 | esac |
---|
| 179 | |
---|
[5432] | 180 | im=$(echo "$resol" | cut -dx -f1) |
---|
| 181 | jm=$(echo "$resol" | cut -dx -f2) |
---|
| 182 | lm=$(echo "$resol" | cut -dx -f3) |
---|
| 183 | |
---|
[5415] | 184 | yearini=$(echo "$mthini" | cut -c-4) |
---|
| 185 | if [[ $freq = yr ]]; then stopsim=$(echo "$mthend" | cut -c-4); else stopsim=$mthend; fi |
---|
[4615] | 186 | |
---|
[5415] | 187 | if [[ -d $SIM ]]; then |
---|
| 188 | echo "La simulation $SIM existe deja. Il est conseillé d'arrêter et de vérifier." |
---|
| 189 | echo "Si vous êtes sûr de vous, vous pouvez la prolonger. Voulez vous la prolonger ? (y/n)" |
---|
| 190 | read -r ans |
---|
| 191 | if [[ $ans != y ]]; then exit 1; fi |
---|
| 192 | fi |
---|
[4615] | 193 | |
---|
[5415] | 194 | ###################################################################### |
---|
| 195 | # Choix du nombre de processeurs |
---|
| 196 | # NOTES : |
---|
[5438] | 197 | # omp=8 by default (for Jean-Zay must be a divisor of 40 procs/node) |
---|
| 198 | # omp=1 : required for SPLA (omp parallelism not ready) |
---|
| 199 | # omp=2 for veget=CMIP6+XIOS beacause of a bug in ORCHIDEE/src_xml/xios_orchidee.f90 |
---|
[5415] | 200 | ###################################################################### |
---|
| 201 | (( mpi = ( jm + 1 ) / 2 )) |
---|
| 202 | omp=8 |
---|
| 203 | if [[ $aerosols = "spla" ]]; then omp=1; fi |
---|
| 204 | if [[ $veget = "CMIP6" && $xios = "y" ]]; then omp=2; fi |
---|
| 205 | if [[ $mpi -gt $NB_MPI_MAX ]]; then mpi=$NB_MPI_MAX; fi |
---|
| 206 | if [[ $omp -gt $NB_OMP_MAX ]]; then omp=$NB_OMP_MAX; fi |
---|
[4615] | 207 | |
---|
[5415] | 208 | # Compute how many mpi per node (required e.g. for Adastra) |
---|
| 209 | mpi_per_node=0 |
---|
| 210 | if [[ $NB_CORE_PER_NODE_MAX -gt 0 ]]; then |
---|
| 211 | local N_omp_mt=1 |
---|
| 212 | if [[ $omp -gt 1 ]]; then (( N_omp_mt = omp / N_HYPERTHREADING )); fi # take into account hyperthreading |
---|
| 213 | (( mpi_per_node = NB_CORE_PER_NODE_MAX / N_omp_mt )) |
---|
| 214 | if [[ mpi_per_node -gt mpi ]]; then mpi_per_node=$mpi; fi |
---|
| 215 | fi |
---|
[4615] | 216 | |
---|
[5415] | 217 | echo "Total MPI=$mpi (PER NODE=$mpi_per_node), OMP=$omp" |
---|
| 218 | } |
---|
[4615] | 219 | |
---|
[5438] | 220 | #--------------------------------------------------------------------------- |
---|
[5415] | 221 | function ensure_correct_option_combinations() { |
---|
| 222 | # AVOID COMBINATIONS OF OPTIONS THAT DON'T WORK in user choices |
---|
[5438] | 223 | #--------------------------------------------------------------------------- |
---|
[5415] | 224 | if [[ $ok_guide = y && $climato = 1 ]]; then |
---|
| 225 | echo "STOP: Running nudged simulations with climatological SSTs is not planned. Change <climato> to <0> or modify the setup (experts)"; exit 1 |
---|
| 226 | fi |
---|
[4615] | 227 | |
---|
[5415] | 228 | if [[ $climato = 0 && $freq = "yr" ]]; then |
---|
| 229 | echo "STOP: Running simulations with interannual SSTs is possible only month by month and a true calendar." |
---|
| 230 | echo "Change <climato> to <1> or <freq> to <mo> or modify setup.sh (experts)"; exit 1 |
---|
| 231 | fi |
---|
[4615] | 232 | |
---|
| 233 | |
---|
[5415] | 234 | # (Temporary) Constraints for aerosols=spla : |
---|
| 235 | # --> resolution 128x88x79 and rad=rrtm |
---|
[5438] | 236 | if [[ $aerosols = "spla" && ( ${im}x${jm} != "128x88" || $freq != mo ) ]]; then |
---|
| 237 | echo 'STOP: For now, <aerosols=spla> requires <resol=128x88x79>,' |
---|
| 238 | echo 'and uses the zoomed grid from gcm.def_zNAfrica_BiJe,' |
---|
| 239 | echo 'for which forcing & initial files are available' |
---|
[5415] | 240 | echo "Right now resol=<$resol>" |
---|
[5438] | 241 | echo 'Should be run in monthly mode' |
---|
[5415] | 242 | exit 1 |
---|
| 243 | fi |
---|
[4615] | 244 | |
---|
[5415] | 245 | if [[ $rad = "ecrad" && $phylmd != "lmd" ]]; then |
---|
| 246 | echo "<rad=ecrad> is only supported for <phy=phylmd> here" # (Amaury) I added this check because we fetch ecrad data from libf/phylmd/ecrad/data only. |
---|
| 247 | fi |
---|
| 248 | } |
---|
[4615] | 249 | |
---|
[5438] | 250 | #--------------------------------------------------------------------------- |
---|
[5415] | 251 | function install_model() { |
---|
[5438] | 252 | #--------------------------------------------------------------------------- |
---|
[5415] | 253 | mkdir -p "$LMDZD" |
---|
[4615] | 254 | |
---|
[5415] | 255 | local ins_xios ins_cosp ins_aero ins_inlandsis |
---|
| 256 | if [[ $xios = "y" ]]; then ins_xios="-xios"; else ins_xios=""; fi |
---|
| 257 | if [[ $cosp = "y" ]]; then ins_cosp="-cosp v1"; else ins_cosp=""; fi |
---|
| 258 | if [[ $aerosols = "spla" ]]; then ins_aero="-spla"; else ins_aero=""; fi |
---|
| 259 | if [[ $inlandsis = "y" ]]; then ins_inlandsis="-inlandsis"; else ins_inlandsis=""; fi |
---|
| 260 | if [[ -n $svn ]]; then svnopt="-r $svn"; else svnopt=""; fi |
---|
[4615] | 261 | |
---|
[5465] | 262 | if [[ $PARALLEL == 0 ]] ; then parallel= ; parsuf=seq ; else parallel="-parallel mpi_omp" ; parsuf= ; fi |
---|
[5415] | 263 | version_name=LMDZ$(echo "$version" | sed -e 's/-v//g' -e 's/-unstable//' -e 's/-r/r/' -e 's/ //g') |
---|
[5465] | 264 | LMDZname="${version_name}${svn}OR$veget${ins_xios}${parsuf}$( echo $optim | sed -e 's/[\ -]//g' )" |
---|
[5415] | 265 | MODEL="$LMDZD/$LMDZname/modipsl/modeles/LMDZ" |
---|
[4615] | 266 | |
---|
[5415] | 267 | if [[ -d $MODEL ]]; then echo "Found existing install at MODEL=$MODEL"; fi |
---|
| 268 | echo "Installing model" |
---|
| 269 | cd "$LMDZD" |
---|
[5464] | 270 | cp "$local_d/install_lmdz.sh" . |
---|
[5415] | 271 | chmod +x install_lmdz.sh |
---|
| 272 | local make_j=8 |
---|
| 273 | # We launch using $MPICMD, except if it's using mpirun (no srun equivalent for bash script) => if supported, the compilation runs in a cluster job |
---|
| 274 | jobcmd="\"$RUNBASHCMD $make_j\"" |
---|
| 275 | if [[ ${hostname:0:5} = "jean-" ]]; then jobcmd="\"$RUNBASHCMD $make_j --partition=compil\""; fi # On JeanZay: compile on the <compil> partition |
---|
| 276 | if [[ $(echo "$RUNBASHCMD" | cut -c -4) = "bash" ]]; then |
---|
| 277 | jobcmd="bash" |
---|
| 278 | fi |
---|
[5534] | 279 | echo "./install_lmdz.sh -noclean $optim -v $version $svnopt -d $resol -rad $rad -bench compile_only $parallel $ins_cosp $ins_xios $ins_aero $ins_inlandsis -name $LMDZname -veget $veget -netcdf $netcdf -arch $ARCH -make_j $make_j -jobcmd $jobcmd" >> install_lmdz_options.$$.sh |
---|
[5415] | 280 | chmod +x install_lmdz_options.$$.sh |
---|
| 281 | echo "Running install_lmdz_options.$$.sh" |
---|
| 282 | set -o pipefail |
---|
[5534] | 283 | ./install_lmdz_options.$$.sh |
---|
| 284 | #gcm=$MODEL/$(./install_lmdz_options.$$.sh | tee /dev/tty | tail -n 1 | sed -n "s:.* executable is \(.*\.e\).*:\1:p") |
---|
| 285 | gcm=$MODEL/bin/gcm.e |
---|
[5415] | 286 | set +o pipefail |
---|
| 287 | mv install_lmdz.sh install_lmdz.$$.sh |
---|
[5464] | 288 | cd "$local_d" |
---|
[5415] | 289 | } |
---|
[4615] | 290 | |
---|
[5438] | 291 | #--------------------------------------------------------------------------- |
---|
| 292 | function setup_def() { # modify various .def in ./DEF (+ xios xml ) |
---|
| 293 | #--------------------------------------------------------------------------- |
---|
[5464] | 294 | cd "$local_d" |
---|
[4615] | 295 | |
---|
[5415] | 296 | # Utilisation des .def_iso pour LMDZ-ISOtopes |
---|
| 297 | if [[ $phylmd = "lmdiso" ]]; then |
---|
| 298 | for file_iso in $(ls DEF | grep _iso); do |
---|
| 299 | cp DEF/"$file_iso" DEF/"${file_iso%%_iso}" |
---|
| 300 | done |
---|
| 301 | fi |
---|
[4615] | 302 | |
---|
[5415] | 303 | ###################################################################### |
---|
| 304 | # Choix de la grille verticale |
---|
| 305 | ###################################################################### |
---|
| 306 | if [ ! -f "DEF/L$lm.def" ]; then |
---|
| 307 | echo "STOP: Résolution verticale non prévue - créer un fichier DEF/L$lm.def"; exit 1 |
---|
| 308 | else |
---|
| 309 | sed -i'' -e "s/INCLUDEDEF=L.*.def/INCLUDEDEF=L$lm.def/" DEF/run.def |
---|
| 310 | fi |
---|
[4615] | 311 | |
---|
[5415] | 312 | ###################################################################### |
---|
| 313 | # Changements dans les fichiers DEF/*def |
---|
[5464] | 314 | # (ils vont se repercuter dans les repertoires de simulation $local_d/$SIM et de run $SIMRUNDIR) |
---|
[5415] | 315 | ###################################################################### |
---|
[4615] | 316 | |
---|
[5415] | 317 | # Choix du fichier tracer.def coherent avec l'option "aerosols" |
---|
| 318 | # NOTE : Le nouveau tracer.def_nospla par defaut n'inclut pas Rn-Pb; |
---|
[5439] | 319 | # si on les veut, il faut utiliser ci-dessous; a la place, tracer_RN_PB.def |
---|
[5415] | 320 | #--------------------------------------------------------------------- |
---|
| 321 | # NB : Les traceurs absents de start* files sont initialises=0 dans le code |
---|
| 322 | if [[ $aerosols = "spla" ]]; then |
---|
| 323 | # nouveau tracer.def (remplace "traceur.def") |
---|
| 324 | cp DEF/tracer.def_spla DEF/tracer.def |
---|
| 325 | elif [[ $phylmd = "lmdiso" ]]; then |
---|
| 326 | # déjà copié si 'y' |
---|
| 327 | cp DEF/tracer.def_nospla DEF/tracer.def |
---|
| 328 | fi |
---|
[4615] | 329 | |
---|
[5415] | 330 | # TEMPORAIREMENT pour spla on force l'utilisation de gcm.def_zNAfrica_BiJe (avec resolution 128x88x79) |
---|
| 331 | #---------------------------------------------------------------------- |
---|
[5438] | 332 | if [[ $aerosols = "spla" ]]; then |
---|
| 333 | cp DEF/gcm.def_zNAfrica_BiJe DEF/gcm.def; fi |
---|
[4615] | 334 | |
---|
[5415] | 335 | # Inscription du choix ok_guide dans DEF/guide.def |
---|
| 336 | #--------------------------------------------------------------------- |
---|
| 337 | sed -i'' -e 's/ok_guide=.*.$/ok_guide='$ok_guide'/' DEF/guide.def |
---|
[4615] | 338 | |
---|
[5415] | 339 | # Inscription du type de calendrier (qui est fonction de $climato) dans DEF/run.def |
---|
| 340 | #--------------------------------------------------------------------- |
---|
| 341 | # NB Contrairement a ce qui est ecrit dans les fichiers run.def standard, |
---|
| 342 | # dans ce tutorial le choix earth_365d n'est pas disponible, et earth_366d s'appelle gregorian |
---|
| 343 | if [[ $climato = 0 ]]; then calend="gregorian"; else calend="earth_360d"; fi |
---|
| 344 | sed -i'' -e 's/calend=.*.$/calend='$calend'/' DEF/run.def |
---|
[4615] | 345 | |
---|
[5415] | 346 | # Changements dans config.def (pre-choisi, et regle pour output si utilisation avec IOIPSL) |
---|
| 347 | # cf options veget, aerosols, cosp, xios |
---|
| 348 | #--------------------------------------------------------------------- |
---|
| 349 | if [[ $veget = "none" ]]; then VEGET="n"; else VEGET="y"; fi |
---|
| 350 | sed -i'' -e 's/VEGET=.*.$/VEGET='$VEGET'/' DEF/config.def |
---|
[4615] | 351 | |
---|
[5438] | 352 | ok_cdnc=y ; ok_ade=y ; ok_aie=y ; ok_alw=y |
---|
| 353 | case $aerosols in |
---|
| 354 | clim) flag_aerosol=6 ;; |
---|
| 355 | spla) flag_aerosol=1 ;; |
---|
| 356 | n) flag_aerosol=0 ; ok_cdnc=n ; ok_ade=n ; ok_aie=n ; ok_alw=n ;; |
---|
| 357 | *) echo Option aerosols=$aerosols not available ; exit 1 |
---|
| 358 | esac |
---|
| 359 | sed -i'' -e 's/^ok_cdnc=.*.$/ok_cdnc='$ok_cdnc'/' \ |
---|
| 360 | -e 's/^ok_ade=.*.$/ok_ade='$ok_ade'/' \ |
---|
| 361 | -e 's/^ok_aie=.*.$/ok_aie='$ok_aie'/' \ |
---|
| 362 | -e 's/^ok_alw=.*.$/ok_alw='$ok_alw'/' \ |
---|
| 363 | -e 's/^flag_aerosol=.*.$/flag_aerosol='$flag_aerosol'/' DEF/config.def |
---|
| 364 | pwd |
---|
[4615] | 365 | |
---|
[5415] | 366 | # COSP : ok_cosp desactive COSP si on a compile avec; il ne l'active pas si on a compile sans |
---|
| 367 | sed -i'' -e 's/ok_cosp.*.$/ok_cosp='$cosp'/' DEF/config.def |
---|
[5464] | 368 | if [[ $cosp = "y" ]]; then \cp -f "$MODEL"/DefLists/cosp*.txt "$local_d"/DEF/; fi |
---|
[4615] | 369 | |
---|
[5415] | 370 | # Sorties LMDZ en fonction de l'option "xios" |
---|
| 371 | sed -i'' -e 's/ok_all_xml=.*.$/ok_all_xml='$xios'/' DEF/config.def |
---|
[4615] | 372 | |
---|
[5415] | 373 | # Ajuster physiq.def en fonction de radiative code (default: values for rad=rrtm) |
---|
| 374 | # Pour isotopes=y , mettre iflag_ice_thermo=0 au lieu de 1 |
---|
| 375 | #--------------------------------------------------------------------- |
---|
| 376 | sed -i'' -e "s/iflag_rrtm=.*.$/iflag_rrtm=$iflag_rrtm/" -e "s/NSW=.*.$/NSW=$NSW/" DEF/physiq.def |
---|
| 377 | sed -i"" -e "s:directory_name.*$:directory_name=\"$MODEL/libf/phylmd/ecrad/data\",:" DEF/namelist_ecrad |
---|
[4615] | 378 | |
---|
[5415] | 379 | if [[ $phylmd = "lmdiso" ]]; then iflag_ice_thermo=0; else iflag_ice_thermo=1; fi |
---|
| 380 | sed -i -e 's/iflag_ice_thermo=.*.$/iflag_ice_thermo='$iflag_ice_thermo'/' DEF/physiq.def |
---|
[4615] | 381 | |
---|
[5415] | 382 | # Choix de orchidee.def en fonction de orchidee_rev; modification pour xios |
---|
| 383 | # NOTE separate orchidee_pft.def file for ORCHIDEE trunk post-CMIP6 |
---|
| 384 | #--------------------------------------------------------------------- |
---|
| 385 | orchidee_def=orchidee.def_6.1 |
---|
| 386 | orchidee_pft_def="" |
---|
| 387 | if [[ $veget = "7983" ]]; then |
---|
| 388 | orchidee_def=orchidee.def_6.2work |
---|
| 389 | elif [[ $veget = "7994" ]]; then |
---|
| 390 | orchidee_def=orchidee.def_6.4work |
---|
| 391 | orchidee_pft_def=orchidee_pft.def_6.4work |
---|
| 392 | if ! grep "INCLUDEDEF=orchidee_pft.def" DEF/run.def; then |
---|
| 393 | sed -i'' -e 's/INCLUDEDEF=orchidee.def/INCLUDEDEF=orchidee.def\nINCLUDEDEF=orchidee_pft.def/' DEF/run.def; fi |
---|
| 394 | fi |
---|
| 395 | cp -f DEF/$orchidee_def DEF/orchidee.def |
---|
| 396 | if [[ $orchidee_pft_def != "" ]]; then cp -f DEF/$orchidee_pft_def DEF/orchidee_pft.def; fi |
---|
[4615] | 397 | |
---|
[5415] | 398 | # Only for veget=CMIP6 it is still possible to use IOIPSL; newer versions of orchidee.def have XIOS_ORCHIDEE_OK = y |
---|
| 399 | sed -i'' -e 's/XIOS_ORCHIDEE_OK =.*.$/XIOS_ORCHIDEE_OK = '$xios'/' DEF/orchidee.def |
---|
[4615] | 400 | |
---|
[5415] | 401 | ###################################################################### |
---|
| 402 | # Si on tourne avec XIOS, mise a jour des fichiers context et field* dans XMLfilesLMDZ |
---|
[5464] | 403 | # (ils vont se repercuter dans les repertoires de simulation $local_d/$SIM et de run $SIMRUNDIR) |
---|
[5415] | 404 | ###################################################################### |
---|
| 405 | if [[ $xios = y ]]; then |
---|
[5464] | 406 | cp -f "$MODEL"/DefLists/context_lmdz.xml "$local_d"/DEF/XMLfilesLMDZ/. |
---|
| 407 | cp -f "$MODEL"/DefLists/field_def_lmdz.xml "$local_d"/DEF/XMLfilesLMDZ/. |
---|
| 408 | if [[ $cosp = y ]]; then cp -f "$MODEL"/DefLists/field_def_cosp1.xml "$local_d"/DEF/XMLfilesLMDZ/.; fi |
---|
[5415] | 409 | fi |
---|
| 410 | } |
---|
[4615] | 411 | |
---|
[5438] | 412 | #--------------------------------------------------------------------------- |
---|
[5415] | 413 | function setup_ce0l() { # Verification de l'existance de l'état initial, compilation eventuelle pour sa creation |
---|
[5438] | 414 | #--------------------------------------------------------------------------- |
---|
[5415] | 415 | if [[ ! -d $INIT ]]; then |
---|
| 416 | if [[ $init = 0 ]]; then |
---|
| 417 | echo "STOP: Récuperer les repertoires $INIT ou lancer avec option -init"; exit 1 |
---|
| 418 | else |
---|
| 419 | # Compile ce0l |
---|
| 420 | cd "$MODEL" |
---|
[5534] | 421 | sed -e 's/gcm/ce0l/g' compile.sh > compile_ce0l.sh; chmod +x compile_ce0l.sh |
---|
[5415] | 422 | echo "Compiling ce0l" |
---|
| 423 | if ! ./compile_ce0l.sh &> ce0l.log; then echo "STOP: ce0l compilation failed, see $MODEL/ce0l.log"; exit 1; fi |
---|
| 424 | echo "Compiled ce0l" |
---|
| 425 | ce0l=${gcm/gcm/ce0l} |
---|
[4615] | 426 | |
---|
[5464] | 427 | cd "$local_d" |
---|
[4615] | 428 | fi |
---|
[5415] | 429 | elif [[ $init = 1 ]]; then |
---|
| 430 | echo "STOP: Vous essayez d initialiser le modele mais $INIT existe deja"; exit 1 |
---|
| 431 | fi |
---|
| 432 | } |
---|
[4615] | 433 | |
---|
[5438] | 434 | #--------------------------------------------------------------------------- |
---|
[5415] | 435 | function setup_simu() { |
---|
[5438] | 436 | #--------------------------------------------------------------------------- |
---|
[5464] | 437 | #SIMRUNTOPDIR="$SIMRUNBASEDIR/$(basename "$local_d")" |
---|
[5420] | 438 | SIMRUNTOPDIR="$SIMRUNBASEDIR" |
---|
[5415] | 439 | SIMRUNDIR=$SIMRUNTOPDIR |
---|
| 440 | mkdir -p "$SIMRUNDIR" |
---|
| 441 | cd "$SIMRUNDIR" |
---|
| 442 | echo "La simulation s'exécutera sur $SIMRUNDIR" |
---|
[4615] | 443 | |
---|
[5415] | 444 | ##################################################################### |
---|
| 445 | # Creation du repertoire $SIM s'il n'existe pas deja |
---|
| 446 | ##################################################################### |
---|
[5464] | 447 | if [[ ! -d $local_d/$SIM ]]; then |
---|
| 448 | mkdir "$local_d/$SIM" |
---|
| 449 | cd "$local_d" |
---|
[4615] | 450 | |
---|
[5415] | 451 | # Edit reb.sh |
---|
[5464] | 452 | cp reb.sh "$local_d/$SIM/reb.sh"; chmod +x "$local_d/$SIM/reb.sh" |
---|
| 453 | sed -i'' -e "s:^rebuild=.*.$:rebuild=$LMDZD/$LMDZname/modipsl/bin/rebuild:" "$local_d/$SIM/reb.sh" |
---|
| 454 | enable_platform "$local_d/$SIM/reb.sh" |
---|
[4615] | 455 | |
---|
[5415] | 456 | # Copy .def |
---|
[5464] | 457 | cp lmdz_env.sh "$local_d/$SIM/" |
---|
| 458 | mkdir "$local_d/$SIM/DEF"; cp DEF/*def DEF/namelis* "$local_d/$SIM/DEF/" |
---|
[5415] | 459 | #Pour XIOS, respectivement COSP, copier aussi les fichiers *xml / *txt |
---|
[5464] | 460 | if [[ $cosp = "y" ]]; then cp DEF/cosp*txt "$local_d/$SIM/DEF/"; fi |
---|
[5415] | 461 | if [[ $xios = "y" ]]; then |
---|
[5464] | 462 | cp DEF/XMLfilesLMDZ/*xml "$local_d/$SIM/DEF/" |
---|
| 463 | if [[ $veget != 'none' ]]; then cp DEF/XMLfilesOR$veget/*xml "$local_d/$SIM/DEF/"; fi |
---|
[5415] | 464 | fi |
---|
[5464] | 465 | chmod u+w "$local_d/$SIM"/DEF/* |
---|
[4615] | 466 | |
---|
[5415] | 467 | # Gestion du calendrier |
---|
| 468 | ####################### |
---|
| 469 | cd "$SIM" |
---|
| 470 | sed -i'' -e "s/anneeref=.*.$/anneeref=$yearini/" DEF/run.def |
---|
| 471 | if [[ $freq = "yr" ]]; then date=$yearini; else date=$mthini; fi |
---|
| 472 | echo "$date a faire" >| etat |
---|
[4615] | 473 | |
---|
[5415] | 474 | # Recuperation des fichiers : executable initiaux et forcages |
---|
| 475 | ############################################################# |
---|
| 476 | echo "date: $date" |
---|
| 477 | for f in start startphy; do |
---|
| 478 | inf=../$INIT/$f.$date.nc |
---|
| 479 | if [[ -f $inf || $init = 1 ]]; then ln -s "$inf" ./; else echo "STOP: $inf missing"; exit ; fi; |
---|
| 480 | done |
---|
| 481 | for f in sechiba stomate; do |
---|
| 482 | if [[ -f ../$INIT/start_$f.$date.nc ]]; then ln -sf "../$INIT/start_$f.$date.nc" .; fi |
---|
| 483 | done |
---|
| 484 | cp "$gcm" gcm.e |
---|
| 485 | fi |
---|
[5464] | 486 | cd "$local_d"/.. |
---|
[4615] | 487 | |
---|
[5415] | 488 | ##################################################################### |
---|
| 489 | echo "Modification du script de lancement" |
---|
| 490 | ##################################################################### |
---|
| 491 | local cput |
---|
| 492 | if [[ $freq = "yr" ]]; then cput="04:00:00"; else cput="01:00:00"; fi |
---|
| 493 | local isotopes="n" |
---|
| 494 | if [[ $phylmd = "lmdiso" ]]; then isotopes="y"; fi |
---|
| 495 | sed -e "s/NOM_SIMU/$SIM/" \ |
---|
| 496 | -e "s/time=.*.$/time=$cput/" \ |
---|
| 497 | -e "s/ntasks=.*.$/ntasks=$mpi/" \ |
---|
| 498 | -e "s/ntasks-per-node=.*.$/ntasks-per-node=$mpi_per_node/" \ |
---|
| 499 | -e "s/cpus-per-task=.*.$/cpus-per-task=$omp/" \ |
---|
| 500 | -e "s/nthreads=.*./nthreads=$omp/" \ |
---|
[5464] | 501 | -e "s/MAINDIR=.*.$/MAINDIR=$(basename "$local_d")/" \ |
---|
| 502 | -e "s:STORED=.*.*:STORED=$(dirname "$local_d"):" \ |
---|
[5415] | 503 | -e "s:SCRATCHD=.*.*:SCRATCHD=$SIMRUNBASEDIR:" \ |
---|
| 504 | -e "s/stopsim=.*.$/stopsim=$stopsim/" \ |
---|
| 505 | -e "s/^veget=.*.$/veget=$veget/" \ |
---|
| 506 | -e "s/^aerosols=.*.$/aerosols=$aerosols/" \ |
---|
| 507 | -e "s/^isotopes=.*.$/isotopes=$isotopes/" \ |
---|
| 508 | -e "s/^climato=.*.$/climato=$climato/" \ |
---|
| 509 | -e "s/^ok_guide=.*.$/ok_guide=$ok_guide/" \ |
---|
[5464] | 510 | "$local_d/script_SIMU" >| "$SIMRUNDIR/tmp_$SIM" |
---|
[4615] | 511 | |
---|
[5415] | 512 | enable_platform "$SIMRUNDIR/tmp_$SIM" |
---|
[4615] | 513 | |
---|
[5415] | 514 | if [[ $testmode = "y" ]]; then |
---|
| 515 | sed -i'' -e "s/time=.*.$/time=00:10:00/" -e "s/#nday=1/nday=1/" -e "s/#@TESTQ//" "$SIMRUNTOPDIR/tmp_$SIM" |
---|
| 516 | fi |
---|
| 517 | } |
---|
[4615] | 518 | |
---|
[5429] | 519 | #---------------------------------------------------------------------- |
---|
[5439] | 520 | function list_yrmth() { |
---|
| 521 | #---------------------------------------------------------------------- |
---|
| 522 | local liste="" |
---|
| 523 | local mthini=$1 |
---|
| 524 | local mthend=$2 |
---|
| 525 | local mo_=$mthini |
---|
| 526 | while [[ $mo_ != $mthend ]] ; do |
---|
| 527 | liste="$liste $mo_" |
---|
| 528 | yr__=$( echo $mo_ | cut -c 1-4 ) |
---|
| 529 | mo__=$( echo $mo_ | cut -c 5-6 ) |
---|
| 530 | echo YM $yr__ $mo__ |
---|
| 531 | if [ $(( $mo__ +1 )) == 12 ] ; then |
---|
| 532 | yr__=$(( $yr__ + 1 )) ; mo_=$yr__$mo__ |
---|
| 533 | else |
---|
| 534 | mo_=$(( $mo_ + 1 )) |
---|
| 535 | fi |
---|
| 536 | done |
---|
| 537 | echo $liste |
---|
| 538 | |
---|
| 539 | } |
---|
| 540 | |
---|
| 541 | #---------------------------------------------------------------------- |
---|
| 542 | increment_month() { |
---|
| 543 | #---------------------------------------------------------------------- |
---|
| 544 | local year=$( echo $1 | cut -c 1-4 ) |
---|
| 545 | local month=$(( $1 - ${year}00 )) |
---|
| 546 | if [ $(( $month - 12 )) -eq 0 ]; then |
---|
| 547 | year=$((year + 1)) |
---|
| 548 | month=1 |
---|
| 549 | else |
---|
| 550 | month=$((month + 1)) |
---|
| 551 | fi |
---|
| 552 | if [[ $month -le 9 ]] ; then month=0$month ; fi |
---|
| 553 | echo $year$month |
---|
| 554 | } |
---|
| 555 | |
---|
| 556 | #---------------------------------------------------------------------- |
---|
[5415] | 557 | function fetch_simu_init_files() { |
---|
[5429] | 558 | #---------------------------------------------------------------------- |
---|
[5415] | 559 | ##################################################################### |
---|
[5426] | 560 | echo "Recuperation eventuelle de certains fichiers sur http:lmdz.lmd.jussieu.fr/pub" |
---|
[5415] | 561 | ##################################################################### |
---|
[4615] | 562 | |
---|
[5426] | 563 | # ORCHIDEE input files |
---|
[5429] | 564 | get_input_files wget_pub Orchidee |
---|
[5426] | 565 | |
---|
| 566 | # Files for aerosols and chemistry |
---|
[5438] | 567 | if [[ $aerosols = "clim" ]]; then |
---|
| 568 | get_input_files wget_pub AerChem ; fi |
---|
[5426] | 569 | |
---|
[5429] | 570 | # Files for SPLA |
---|
[5438] | 571 | if [[ $aerosols = "spla" ]]; then |
---|
| 572 | get_input_files wget_pub SPLA_WA/emissions |
---|
[5439] | 573 | mo_=$mthini |
---|
| 574 | while [[ $mo_ != $mthend ]] ; do |
---|
| 575 | # Code horrible duplique a cause de 08 (FH) |
---|
| 576 | local yr__=$( echo $mo_ | cut -c 1-4 ) |
---|
| 577 | local mo__=$(( $mo_ - ${yr__}00 )) |
---|
| 578 | if [[ $mo__ -le 9 ]] ; then mo__=0$mo__ ; fi |
---|
[5438] | 579 | for var in u10m v10m u v ; do |
---|
| 580 | echo wget_pub 3DInputData/SPLA_WA/ERA5/$yr__/$mo__ $var.nc |
---|
| 581 | wget_pub 3DInputData/SPLA_WA/ERA5/$yr__/$mo__ $var.nc |
---|
| 582 | done |
---|
[5439] | 583 | mo_=$( increment_month $mo_ ) |
---|
[5438] | 584 | done |
---|
[5464] | 585 | cd $local_d ; ln -sf $LMDZ_INIT/3DInputData/SPLA_WA/ERA5 GUIDE |
---|
[5438] | 586 | fi |
---|
[5415] | 587 | } |
---|
[4615] | 588 | |
---|
[5429] | 589 | #---------------------------------------------------------------------- |
---|
[5415] | 590 | function run_sim_or_init() { |
---|
[5429] | 591 | #---------------------------------------------------------------------- |
---|
[5464] | 592 | cd "$local_d" |
---|
[4615] | 593 | |
---|
[5415] | 594 | if [[ $init = 1 ]]; then |
---|
| 595 | ##################################################################### |
---|
| 596 | echo "Creation de l etat initial" |
---|
| 597 | ##################################################################### |
---|
[4615] | 598 | |
---|
[5415] | 599 | # Creation du repertoire INIT et mise en place de liens logiques vers les starts |
---|
| 600 | # en anticipation de leur création : |
---|
[5464] | 601 | mkdir "$local_d/$INIT"; cd "$local_d/$INIT" |
---|
[5415] | 602 | for an in $mthini $yearini; do for f in start startphy; do ln -s "$f.nc" "$f.$an.nc"; done; done |
---|
[4615] | 603 | |
---|
[5415] | 604 | # Creation du repertoire INIT temporaire et rapatriement des fichiers necessaires |
---|
| 605 | if [[ -d $SIMRUNDIR/$INIT ]]; then mv "$SIMRUNDIR/$INIT" "$SIMRUNDIR/$INIT$$"; fi |
---|
[5464] | 606 | mkdir "$SIMRUNDIR/$INIT"; cp -r "$local_d/DEF" "$SIMRUNDIR/$INIT/" |
---|
| 607 | cd "$SIMRUNDIR/$INIT"; cp DEF/*.def .; cp "$local_d/lmdz_env.sh" . |
---|
[5415] | 608 | if [[ $xios = "y" ]]; then |
---|
| 609 | cp DEF/XMLfilesLMDZ/*xml . |
---|
| 610 | if [[ $veget != 'none' ]]; then cp DEF/XMLfilesOR$veget/*xml .; fi |
---|
| 611 | fi |
---|
| 612 | sed -e "s/anneeref=.*.$/anneeref=$yearini/" DEF/run.def >| run.def |
---|
[4615] | 613 | |
---|
[5415] | 614 | #------------------------------------------------------------------- |
---|
| 615 | # Fichiers Limit |
---|
| 616 | #------------------------------------------------------------------- |
---|
| 617 | local yrs suf |
---|
| 618 | if [[ $climato = 0 ]]; then |
---|
| 619 | # calend est choisi plus haut dans "Changements dans les fichiers DEF/*def" et ecrit dans $MAINDIR/DEF/run.def |
---|
| 620 | yrini=$(echo "$mthini" | cut -c-4) |
---|
| 621 | yrend=$(echo "$mthend" | cut -c-4) |
---|
| 622 | yrs=""; yr=$yrini |
---|
| 623 | while [[ $yr -le $yrend ]]; do yrs="$yrs $yr"; (( yr = yr + 1 )); done |
---|
| 624 | suf="360x180_" |
---|
| 625 | else |
---|
| 626 | yrs=2000 |
---|
| 627 | suf="1x1_clim" |
---|
| 628 | fi |
---|
[4615] | 629 | |
---|
[5415] | 630 | liste_get="Albedo.nc Relief.nc Rugos.nc landiceref.nc" |
---|
| 631 | for yr in $yrs; do |
---|
| 632 | if [[ $climato = 0 ]]; then sufyr=$suf$yr; else sufyr=$suf; fi |
---|
| 633 | liste_get="$liste_get amipbc_sic_$sufyr.nc amipbc_sst_$sufyr.nc" |
---|
| 634 | done |
---|
| 635 | echo LISTEGET "$liste_get" |
---|
| 636 | for file in $liste_get; do |
---|
[5426] | 637 | wget_pub 3DInputData/Limit $file |
---|
| 638 | ln_from_pub 3DInputData/Limit $file |
---|
[5415] | 639 | done |
---|
| 640 | #------------------------------------------------------------------- |
---|
[5426] | 641 | # Initial state ECDYN |
---|
[5415] | 642 | #------------------------------------------------------------------- |
---|
[5426] | 643 | wget_pub 3DInputData/Init ECDYN.nc |
---|
| 644 | ln_from_pub 3DInputData/Init ECDYN.nc |
---|
[5415] | 645 | ln -sf ECDYN.nc ECPHY.nc |
---|
[4615] | 646 | |
---|
[5415] | 647 | # Creation du script d'initialisation |
---|
[5465] | 648 | if [ "$MPICMD" = "" ] ; then mpicmd='' ; else mpicmd='OMP_NUM_THREADS=1 '"$MPICMD"' 1' ; fi |
---|
[5415] | 649 | cat << ...eod >| tmp |
---|
[4615] | 650 | #!/bin/bash |
---|
[5415] | 651 | #@JZ#JeanZay |
---|
| 652 | #@JZ#SBATCH --job-name=Init # nom du job |
---|
| 653 | #@JZ#SBATCH --ntasks=1 # Nombre de processus MPI |
---|
| 654 | #@JZ#SBATCH --cpus-per-task=1 # nombre de threads OpenMP |
---|
| 655 | #@JZ# /!\ Attention, la ligne suivante est trompeuse mais dans le vocabulaire |
---|
| 656 | #@JZ# de Slurm "multithread" fait bien référence à l'hyperthreading. |
---|
| 657 | #@JZ#SBATCH --hint=nomultithread # 1 thread par coeur physique (pas d'hyperthreading) |
---|
| 658 | #@JZ#SBATCH --time=00:10:00 # Temps d'exécution maximum demandé (HH:MM:SS) |
---|
| 659 | #@JZ#SBATCH --output=Init%j.out # Nom du fichier de sortie |
---|
| 660 | #@JZ#SBATCH --error=Init%j.out # Nom du fichier d'erreur (ici commun avec la sortie) |
---|
| 661 | #@JZ# To submit to dev queue; "time" (above) must be max 2h |
---|
| 662 | #@JZ#TESTQ#SBATCH --qos=qos_cpu-dev |
---|
| 663 | #@SP#Spirit |
---|
| 664 | #@SP#SBATCH --job-name=Init |
---|
| 665 | #@SP#SBATCH --ntasks=1 |
---|
| 666 | #@SP#SBATCH --cpus-per-task=1 |
---|
| 667 | #@SP#SBATCH --hint=nomultithread |
---|
| 668 | #@SP#SBATCH --time=00:10:00 |
---|
| 669 | #@SP#SBATCH --output=Init%j.out |
---|
| 670 | #@SP#SBATCH --error=Init%j.out |
---|
| 671 | #@ADS#Adastra |
---|
| 672 | #@ADS#SBATCH --job-name=Init |
---|
| 673 | #@ADS#SBATCH --ntasks=1 |
---|
| 674 | #@ADS#SBATCH --cpus-per-task=1 |
---|
| 675 | #@ADS#SBATCH --nodes=1 |
---|
| 676 | #@ADS#SBATCH --hint=nomultithread |
---|
| 677 | #@ADS#SBATCH --time=00:10:00 |
---|
| 678 | #@ADS#SBATCH --output=Init%j.out |
---|
| 679 | #@ADS#SBATCH --error=Init%j.out |
---|
[4615] | 680 | |
---|
[5415] | 681 | set -eu |
---|
[4615] | 682 | |
---|
| 683 | # ANCIEN MULTI STEP case \${LOADL_STEP_NAME} in |
---|
| 684 | |
---|
| 685 | # ANCIEN MULTI STEP init ) |
---|
| 686 | |
---|
[5415] | 687 | if [ ! -f lmdz_env.sh ]; then echo "manque fichier lmdz_env.sh"; ls; exit 1; fi |
---|
| 688 | . lmdz_env.sh |
---|
| 689 | ulimit -s unlimited |
---|
| 690 | cd $SIMRUNDIR/$INIT |
---|
| 691 | echo "Executable : $ce0l" |
---|
| 692 | for yr in $yrs; do |
---|
| 693 | if [ $climato = 0 ]; then sufyr=$suf\$yr; else sufyr=$suf; fi |
---|
| 694 | ln -sf amipbc_sic_\$sufyr.nc amipbc_sic_1x1.nc |
---|
| 695 | ln -sf amipbc_sst_\$sufyr.nc amipbc_sst_1x1.nc |
---|
| 696 | sed -e 's/anneeref=.*.$/anneeref='\$yr'/' DEF/run.def >| run.def |
---|
| 697 | echo Starting initialisation |
---|
[5426] | 698 | # Runing ce0l.e |
---|
[5465] | 699 | $mpicmd $ce0l # ce0l requires MPI=OMP=1 |
---|
[5415] | 700 | if [ $climato = 0 ]; then mv limit.nc limit.\$yr.nc; fi |
---|
| 701 | done |
---|
| 702 | # ANCIEN MULTI STEP ;; |
---|
[4615] | 703 | |
---|
| 704 | # ANCIEN MULTI STEP interp ) |
---|
[5415] | 705 | if [[ $aerosols = clim ]]; then |
---|
[5464] | 706 | cp $local_d/interp_aerosols.sh .; chmod +x interp_aerosols.sh |
---|
[5415] | 707 | # Les aerosols de l'annee 2000 ont été remplacés par "9999" qui pointe vers un fichier moyen sur 1995-2014 |
---|
| 708 | #for year in 2000 1850; do ./interp_aerosols.sh \$year; done |
---|
| 709 | #mv aerosols.2000.nc aerosols.clim.nc; mv aerosols.1850.nc aerosols.nat.nc |
---|
| 710 | for year in 9999 1850; do ./interp_aerosols.sh \$year; done |
---|
| 711 | mv aerosols.9999.nc aerosols.clim.nc; mv aerosols.1850.nc aerosols.nat.nc |
---|
| 712 | fi |
---|
[4615] | 713 | |
---|
[5464] | 714 | for f in sta* gri*nc; do cp \$f $local_d/$INIT/\$f; done |
---|
| 715 | if [[ $climato = 1 ]]; then cp limit.nc $local_d/$INIT/limit.nc; fi |
---|
| 716 | mkdir -p $local_d/$LIMIT |
---|
| 717 | for f in limit*.nc ; do cp \$f $local_d/$LIMIT/\$f; done |
---|
| 718 | if [ $aerosols = clim ]; then for f in aerosols[.0-9]*nc; do cp \$f $local_d/$LIMIT/\$f; done; fi |
---|
[5415] | 719 | # |
---|
| 720 | cd $SIMRUNDIR |
---|
[4615] | 721 | ...eod |
---|
[5415] | 722 | if [[ $ok_guide != "y" ]]; then # Running first simulation automatically except for nudging |
---|
| 723 | cat << ...eod >> tmp |
---|
| 724 | echo "Submitting job tmp_$SIM" |
---|
[5422] | 725 | #echo "\$SUBMITCMD tmp_$SIM" |
---|
| 726 | #\$SUBMITCMD tmp_$SIM |
---|
[5424] | 727 | echo submitcmd tmp_$SIM |
---|
[5422] | 728 | submitcmd tmp_$SIM |
---|
[4615] | 729 | ...eod |
---|
[5415] | 730 | fi |
---|
| 731 | cat << ...eod >> tmp |
---|
| 732 | # ANCIEN MULTI STEP esac |
---|
[4615] | 733 | ...eod |
---|
[5415] | 734 | enable_platform tmp |
---|
[5438] | 735 | echo "#################################################################" |
---|
[5422] | 736 | #echo "Submitting initialisation job <$SUBMITCMD tmp> from $(pwd)" |
---|
| 737 | echo "Submitting initialisation job <submitcmd tmp> from $(pwd)" |
---|
[5415] | 738 | chmod +x tmp |
---|
[5422] | 739 | #$SUBMITCMD tmp |
---|
| 740 | submitcmd tmp |
---|
[5438] | 741 | echo "#################################################################" |
---|
[4615] | 742 | |
---|
[5415] | 743 | else #case [ $init != 1 ] |
---|
| 744 | cd "$SIMRUNDIR" |
---|
[5438] | 745 | echo "################################################################" |
---|
[5415] | 746 | echo "Submitting job tmp_$SIM" |
---|
[5422] | 747 | #echo "$SUBMITCMD tmp_$SIM" |
---|
| 748 | #$SUBMITCMD "tmp_$SIM" |
---|
| 749 | echo "submitcmd tmp_$SIM" |
---|
| 750 | submitcmd "tmp_$SIM" |
---|
[5438] | 751 | echo '################################################################' |
---|
[5415] | 752 | fi |
---|
| 753 | } |
---|
[4615] | 754 | |
---|
[5438] | 755 | #--------------------------------------------------------------------------- |
---|
[5415] | 756 | function message_post_submit() { |
---|
[5438] | 757 | #--------------------------------------------------------------------------- |
---|
[5415] | 758 | if [[ $ok_guide = "y" && $init = 1 ]]; then |
---|
[5464] | 759 | cd "$local_d" |
---|
[5415] | 760 | enable_platform era2gcm_tuto.sh |
---|
| 761 | echo "Once initialisation is finished, you have to create nudging files" |
---|
| 762 | echo "Edit era2gcm_tuto.sh and set the desired parameters in section <User choices>" |
---|
| 763 | echo "Make sure you have acces to the chosen ERA files, and the required modules are loaded, then run : ./era2gcm_tuto.sh" |
---|
| 764 | if [[ $aerosols = "spla" ]]; then |
---|
| 765 | echo "Your aerosol choice is <spla>, so you need ERA 10m-winds interpolated on LMDZ grid. Use script era2gcm_uv10m.sh" |
---|
| 766 | fi |
---|
| 767 | else |
---|
| 768 | echo "Si tout se passe bien, vous avez initialisé et lancé automatiquement la simulation." |
---|
| 769 | echo "Le job qui a été lancé se trouve sur $SIMRUNTOPDIR/tmp_$SIM" |
---|
| 770 | fi |
---|
| 771 | } |
---|
[4615] | 772 | |
---|
[5438] | 773 | #--------------------------------------------------------------------------- |
---|
[5415] | 774 | function setup_and_load_lmdz_env() { |
---|
[5438] | 775 | #--------------------------------------------------------------------------- |
---|
[5415] | 776 | if [[ ! -f .lmdz_setup_root_dir ]]; then echo "STOP: setup.sh is not located in the root dir ??!!"; exit 1; fi |
---|
| 777 | # sed root_dir in lmdz_env.sh |
---|
[5464] | 778 | sed -i'' "s<root_dir=.*<root_dir=$local_d<" lmdz_env.sh |
---|
[4615] | 779 | |
---|
[5415] | 780 | # Set up the appropriate environment |
---|
| 781 | source lmdz_env.sh |
---|
| 782 | } |
---|
[4615] | 783 | |
---|
[5464] | 784 | local_d=$(pwd) |
---|
[4615] | 785 | |
---|
[5415] | 786 | setup_and_load_lmdz_env |
---|
| 787 | load_install_lib |
---|
| 788 | define_expert_options |
---|
| 789 | set_default_params |
---|
| 790 | read_cmdline_args "$@" |
---|
| 791 | ensure_correct_option_combinations |
---|
| 792 | install_model |
---|
| 793 | setup_def |
---|
| 794 | setup_ce0l |
---|
| 795 | setup_simu |
---|
| 796 | fetch_simu_init_files |
---|
| 797 | run_sim_or_init |
---|
[5420] | 798 | message_post_submit |
---|