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