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