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