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