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