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