[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 | #--------------------------------------------------------------------- |
---|
| 501 | # NB: Si on change de traceur.def (entre spla et nospla), il faut refaire l'etape "initialisation" (ce0l)? |
---|
| 502 | # Normalement les traceurs absents de start* files sont initialises=0 dans le code ; verifier pour spla ! |
---|
| 503 | if [ $aerosols = spla ] ; then |
---|
| 504 | # ancien traceur pour l instant |
---|
| 505 | cp DEF/traceur.def_spla DEF/traceur.def |
---|
| 506 | elif [ $isotopes = n ] ; then |
---|
| 507 | # nouveau traceur |
---|
| 508 | # déjà copié si 'y' |
---|
| 509 | cp DEF/tracer.def_nospla DEF/tracer.def |
---|
| 510 | fi |
---|
| 511 | |
---|
| 512 | # TEMPORAIREMENT pour spla on force l'utilisation de gcm.def_zNAfrica_BiJe (avec resolution 128x88x79) |
---|
| 513 | #---------------------------------------------------------------------- |
---|
| 514 | if [ $aerosols = spla ] ; then cp DEF/gcm.def_zNAfrica_BiJe DEF/gcm.def ; fi |
---|
| 515 | |
---|
| 516 | # Inscription du choix ok_guide dans DEF/guide.def |
---|
| 517 | #--------------------------------------------------------------------- |
---|
| 518 | sed -i -e 's/ok_guide=.*.$/ok_guide='$ok_guide'/' DEF/guide.def |
---|
| 519 | |
---|
| 520 | # Inscription du type de calendrier (qui est fonction de $climato) dans DEF/run.def |
---|
| 521 | #--------------------------------------------------------------------- |
---|
| 522 | # NB Contrairement a ce qui est ecrit dans les fichiers run.def standard, |
---|
| 523 | # dans ce tutorial le choix earth_365d n'est pas disponible, et earth_366d s'appelle gregorian |
---|
| 524 | if [ $climato = 0 ] ; then calend=gregorian ; else calend=earth_360d ; fi |
---|
| 525 | sed -i -e 's/calend=.*.$/calend='$calend'/' DEF/run.def |
---|
| 526 | |
---|
| 527 | # Changements dans config.def (pre-choisi, et regle pour output si utilisation avec IOIPSL) |
---|
| 528 | # cf options veget, aerosols, cosp, xios |
---|
| 529 | #--------------------------------------------------------------------- |
---|
| 530 | if [ $veget = NONE ] ; then VEGET=n ; else VEGET=y ; fi |
---|
| 531 | sed -i -e 's/VEGET=.*.$/VEGET='$VEGET'/' DEF/config.def |
---|
| 532 | |
---|
| 533 | if [ $aerosols = n ] ; then |
---|
| 534 | # set flag_aerosols=0 and flags ok_ade&co=n |
---|
| 535 | 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 |
---|
| 536 | fi |
---|
| 537 | |
---|
| 538 | # COSP : ok_cosp desactive COSP si on a compile avec; il ne l'active pas si on a compile sans |
---|
| 539 | sed -i -e 's/ok_cosp.*.$/ok_cosp='$cosp'/' DEF/config.def |
---|
| 540 | if [ $cosp = y ] ; then \cp -f $MODEL/DefLists/cosp*.txt $local/DEF/ ; fi |
---|
| 541 | |
---|
| 542 | # Sorties LMDZ en fonction de l'option "xios" |
---|
| 543 | sed -i'' -e 's/ok_all_xml=.*.$/ok_all_xml='$xios'/' DEF/config.def |
---|
| 544 | |
---|
| 545 | # Ajuster physiq.def en fonction de radiative code (default: values for rad=rrtm) |
---|
| 546 | # Pour isotopes=y , mettre iflag_ice_thermo=0 au lieu de 1 |
---|
| 547 | #--------------------------------------------------------------------- |
---|
| 548 | sed -i'' -e 's/iflag_rrtm=.*.$/iflag_rrtm='$iflag_rrtm'/' -e 's/NSW=.*.$/NSW='$NSW'/' DEF/physiq.def |
---|
| 549 | pwd |
---|
| 550 | sed -i'' -e 's:directory_name.*$:directory_name="'$local'/ecrad_data",:' DEF/namelist_ecrad |
---|
| 551 | |
---|
| 552 | if [ $isotopes = y ] ; then iflag_ice_thermo=0 ; else iflag_ice_thermo=1 ; fi |
---|
| 553 | sed -i -e 's/iflag_ice_thermo=.*.$/iflag_ice_thermo='$iflag_ice_thermo'/' DEF/physiq.def |
---|
| 554 | |
---|
| 555 | # Choix de orchidee.def en fonction de orchidee_rev ; modification pour xios |
---|
| 556 | # NOTE separate orchidee_pft.def file for ORCHIDEE trunk post-CMIP6 |
---|
| 557 | #--------------------------------------------------------------------- |
---|
| 558 | orchidee_def=orchidee.def_6.1 |
---|
| 559 | orchidee_pft_def="" |
---|
| 560 | if [ $veget = "7983" ] ; then |
---|
| 561 | orchidee_def=orchidee.def_6.2work |
---|
| 562 | elif [ $veget = "7994" ] ; then |
---|
| 563 | orchidee_def=orchidee.def_6.4work |
---|
| 564 | orchidee_pft_def=orchidee_pft.def_6.4work |
---|
| 565 | if [ ! grep "INCLUDEDEF=orchidee_pft.def" DEF/run.def ] ; then |
---|
| 566 | sed -i'' -e 's/INCLUDEDEF=orchidee.def/INCLUDEDEF=orchidee.def\nINCLUDEDEF=orchidee_pft.def/' DEF/run.def ; fi |
---|
| 567 | fi |
---|
| 568 | \cp -f DEF/$orchidee_def DEF/orchidee.def |
---|
| 569 | if [ "$orchidee_pft_def" != "" ] ; then \cp -f DEF/$orchidee_pft_def DEF/orchidee_pft.def ; fi |
---|
| 570 | |
---|
| 571 | # Only for veget=CMIP6 it is still possible to use IOIPSL ; newer versions of orchidee.def have XIOS_ORCHIDEE_OK = y |
---|
| 572 | sed -i'' -e 's/XIOS_ORCHIDEE_OK =.*.$/XIOS_ORCHIDEE_OK = '$xios'/' DEF/orchidee.def |
---|
| 573 | |
---|
| 574 | |
---|
| 575 | ###################################################################### |
---|
| 576 | # Si on tourne avec XIOS, mise a jour des fichiers context et field* dans XMLfilesLMDZ |
---|
| 577 | # (ils vont se repercuter dans les repertoires de simulation $local/$SIM et de run $WRK) |
---|
| 578 | ###################################################################### |
---|
| 579 | if [ $xios = y ] ; then |
---|
| 580 | \cp -f $MODEL/DefLists/context_lmdz.xml $local/DEF/XMLfilesLMDZ/. |
---|
| 581 | \cp -f $MODEL/DefLists/field_def_lmdz.xml $local/DEF/XMLfilesLMDZ/. |
---|
| 582 | if [ $cosp = y ] ; then \cp -f $MODEL/DefLists/field_def_cosp1.xml $local/DEF/XMLfilesLMDZ/. ; fi |
---|
| 583 | fi |
---|
| 584 | |
---|
| 585 | |
---|
| 586 | ###################################################################### |
---|
| 587 | # Verification de l'existance de l'etat initial et compilation eventuelle |
---|
| 588 | # pour sa creation |
---|
| 589 | ###################################################################### |
---|
| 590 | if [ ! -d $INIT ] ; then |
---|
| 591 | if [ $init = 0 ] ; then |
---|
| 592 | echo Recuperer les repertoires $INIT ou lancer avec option -init ; exit |
---|
| 593 | else |
---|
| 594 | ce0l=$MODEL/bin/ce0l${suffix}.e |
---|
| 595 | echo $ce0l |
---|
| 596 | |
---|
| 597 | # Test if $ce0l exists (it may be the case if you use a model configuration already installed and compiled) |
---|
| 598 | if [ ! -f $ce0l ] ; then |
---|
| 599 | echo L executable $ce0l n existe pas |
---|
| 600 | echo il va se compiler automatiquement sur $MODEL |
---|
| 601 | sleep 10 |
---|
| 602 | |
---|
| 603 | $local/compile.sh ce0l |
---|
| 604 | fi |
---|
| 605 | |
---|
| 606 | if [ ! -f $ce0l ] ; then echo la compilation de $ce0l a echoue ; exit ; fi |
---|
| 607 | |
---|
| 608 | cd $local |
---|
| 609 | fi |
---|
| 610 | elif [ $init = 1 ] ; then |
---|
| 611 | echo Vous essayez d initialiser le modele mais $INIT existe deja |
---|
| 612 | exit |
---|
| 613 | fi |
---|
| 614 | |
---|
| 615 | MAINDIR=`basename \`pwd\`` |
---|
| 616 | |
---|
| 617 | # EXIT after (install and) compilation if we are on jean-zay-pp instead of jean-zay ! |
---|
| 618 | hostname=`hostname` |
---|
| 619 | if [ ${hostname:0:11} = "jean-zay-pp" ] ; then |
---|
| 620 | echo "You are on jean-zay-pp, here you only can install and compile the model, not run it" |
---|
| 621 | echo "If you want to run a simulation, log in to jean-zay and launch main.sh again, without install" |
---|
| 622 | echo `date` |
---|
| 623 | exit |
---|
| 624 | fi |
---|
| 625 | |
---|
| 626 | ###################################################################### |
---|
| 627 | # On cree sur le SCRATCHD un repertoire de travail avec le meme |
---|
| 628 | # nom que le repertoire local |
---|
| 629 | ###################################################################### |
---|
| 630 | . ./lmdz_env.sh |
---|
| 631 | WRK=$SCRATCHD/$MAINDIR |
---|
| 632 | mkdir -p $WRK |
---|
| 633 | cd $WRK |
---|
| 634 | echo La simulation s executera sur $SCRATCHD/$MAINDIR |
---|
| 635 | |
---|
| 636 | ##################################################################### |
---|
| 637 | # Creation du repertoire $SIM s'il n'existe pas deja |
---|
| 638 | ##################################################################### |
---|
| 639 | |
---|
| 640 | if [ ! -d $local/$SIM ] ; then |
---|
| 641 | mkdir $local/$SIM |
---|
| 642 | cd $local |
---|
[4719] | 643 | 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] | 644 | cp lmdz_env.sh $local/$SIM/ |
---|
| 645 | mkdir $local/$SIM/DEF ; cp DEF/*def DEF/namelis* $local/$SIM/DEF/ |
---|
| 646 | #Pour XIOS, respectivement COSP, copier aussi les fichiers *xml / *txt |
---|
| 647 | if [ $cosp = y ] ; then cp DEF/cosp*txt $local/$SIM/DEF/ ; fi |
---|
| 648 | if [ $xios = y ] ; then |
---|
| 649 | cp DEF/XMLfilesLMDZ/*xml $local/$SIM/DEF/ |
---|
| 650 | if [ $veget != 'NONE' ] ; then cp DEF/XMLfilesOR$veget/*xml $local/$SIM/DEF/ ; fi |
---|
| 651 | fi |
---|
| 652 | chmod u+w $local/$SIM/DEF/* |
---|
| 653 | |
---|
| 654 | # Gestion du calendrier |
---|
| 655 | ####################### |
---|
| 656 | sed -e 's/anneeref=.*.$/anneeref='$yearini'/' \ |
---|
| 657 | DEF/run.def >| $local/$SIM/DEF/run.def |
---|
| 658 | cd $SIM |
---|
| 659 | if [ "$freq" = "yr" ] ; then date=$yearini ; else date=$mthini ; fi |
---|
| 660 | echo $date a faire >| etat |
---|
| 661 | |
---|
| 662 | # Recuperation des fichiers : executable initiaux et forcages |
---|
| 663 | ############################################################# |
---|
| 664 | echo $date |
---|
| 665 | 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 |
---|
| 666 | for f in sechiba stomate ; do if [ -f ../$INIT/start_$f.$date.nc ] ; then ln -sf ../$INIT/start_$f.$date.nc . ; fi ; done |
---|
| 667 | cp $gcm gcm.e |
---|
| 668 | fi # fin de " if [ ! -d $local/$SIM ]" |
---|
| 669 | cd $local/.. |
---|
| 670 | |
---|
| 671 | # Choix du "time limit" pour le job |
---|
| 672 | ################################### |
---|
| 673 | if [ "$freq" = "yr" ] ; then cput=04:00:00 ; else cput=01:00:00 ; fi |
---|
| 674 | |
---|
| 675 | ##################################################################### |
---|
| 676 | echo Modification du script de lancement |
---|
| 677 | ###################################################################/$S |
---|
[4719] | 678 | 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] | 679 | |
---|
| 680 | if [ "$testmode" = "y" ] ; then |
---|
| 681 | 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 |
---|
| 682 | fi |
---|
| 683 | |
---|
| 684 | if [ $climato = 0 ] ; then |
---|
| 685 | # calend est choisi plus haut dans "Changements dans les fichiers DEF/*def" et ecrit dans $MAINDIR/DEF/run.def |
---|
| 686 | yrini=`echo $mthini | cut -c-4` |
---|
| 687 | yrend=`echo $mthend | cut -c-4` |
---|
| 688 | yrs="" ; yr=$yrini ; while [ $yr -le $yrend ] ; do yrs="$yrs $yr" ; (( yr = $yr + 1 )) ; done |
---|
| 689 | suf=360x180_ |
---|
| 690 | else |
---|
| 691 | yrs=2000 |
---|
| 692 | suf=1x1_clim |
---|
| 693 | fi |
---|
| 694 | |
---|
| 695 | |
---|
| 696 | ##################################################################### |
---|
| 697 | echo Recuperation eventuelle de certains fichiers sur LMDZ_Init |
---|
| 698 | ##################################################################### |
---|
| 699 | |
---|
| 700 | if [ ! -d $LMDZ_Init ] ; then mkdir $LMDZ_Init ; fi |
---|
| 701 | |
---|
| 702 | #------------------------------------------------------------------- |
---|
| 703 | # Fichiers ORCHIDEE |
---|
| 704 | #------------------------------------------------------------------- |
---|
| 705 | get="myget 3DInputData/Orchidee/" |
---|
| 706 | liste_get="PFTmap_IPCC_2000.nc cartepente2d_15min.nc " |
---|
| 707 | liste_get+="routing.nc routing_simple.nc lai2D.nc soils_param.nc " |
---|
| 708 | liste_get+="woodharvest_2000.nc PFTmap_15PFT.v1_2000.nc" |
---|
| 709 | for file in $liste_get ; do |
---|
| 710 | if [ ! -f $LMDZ_Init/$file ] ; then cd $LMDZ_Init ; ${get}$file ; cd - ; fi |
---|
| 711 | done |
---|
| 712 | # Additionnal files needed for ORCHIDEE trunk post-CMIP6 |
---|
| 713 | if [ $veget = 7994 -a ! -f $LMDZ_Init/soil_bulk_and_ph.nc ] ; then |
---|
| 714 | cd $LMDZ_Init |
---|
| 715 | ${get}soil_bulk_and_ph.nc ; ${get}NITROGEN_for_ORtrunk.tar |
---|
| 716 | tar -xvf NITROGEN_for_ORtrunk.tar ; cd - |
---|
| 717 | fi |
---|
| 718 | #------------------------------------------------------------------- |
---|
| 719 | # Fichiers aerosols/chimie |
---|
| 720 | #------------------------------------------------------------------- |
---|
| 721 | if [ $aerosols = clim ] ; then |
---|
| 722 | get="myget 3DInputData/AerChem/" |
---|
| 723 | #liste_get="aerosols1850_from_inca.nc aerosols2000_from_inca.nc" |
---|
| 724 | #aerosols9999_from_inca.nc est un lien vers aerosols1995_2014_ensavg_from_inca.nc |
---|
| 725 | liste_get="aerosols1850_from_inca.nc aerosols9999_from_inca.nc" |
---|
| 726 | for file in $liste_get ; do |
---|
| 727 | if [ ! -f $LMDZ_Init/$file ] ; then cd $LMDZ_Init ; ${get}$file ; cd - ; fi |
---|
| 728 | done |
---|
| 729 | fi |
---|
| 730 | |
---|
| 731 | # For SPLA |
---|
| 732 | #------------------- |
---|
| 733 | # Dans ${LMDZ_Init} on cree folder SPLA_Init et dedans le INITIAL |
---|
| 734 | # Pour l'instant on copie là-dedans de chez Binta les fichiers a la res zoomNaf; |
---|
| 735 | # plus tard on y recupererea des fichiers a haute resolution reguliere depuis http:/LMDZ, |
---|
| 736 | # a regrider ensuite par un script interp_fichiers_spla.sh (comme pour aerosols="clim") |
---|
| 737 | # Les fichiers (regrides, sauf SOILSPEC.data utilise tel quel) seront mis dans $MAINDIR/INPUT_SPLA (equivalent de INPUT_DUST) |
---|
| 738 | if [ $aerosols = spla ] ; then |
---|
| 739 | if [ ! -d ${LMDZ_Init}/SPLA_Init ] ; then mkdir ${LMDZ_Init}/SPLA_Init ; mkdir $LMDZ_Init/SPLA_Init/INITIAL ; fi |
---|
| 740 | get="cp -p /gpfsstore/rech/gzi/rgzi027/ergon/BIBIAERO/INPUTS_DUST/INITIAL/" |
---|
| 741 | liste_get="wth.dat cly.dat donnees_lisa.nc SOILSPEC.data \ |
---|
| 742 | carbon_emissions.nc sulphur_emissions_antro.nc \ |
---|
| 743 | sulphur_emissions_nat.nc sulphur_emissions_volc.nc" |
---|
| 744 | |
---|
| 745 | for file in $liste_get ; do |
---|
| 746 | if [ ! -f $LMDZ_Init/SPLA_Init/INITIAL/$file ] ; then cd $LMDZ_Init/SPLA_Init/INITIAL ; ${get}$file . ; cd - ; fi |
---|
| 747 | done |
---|
| 748 | ### |
---|
| 749 | #Cas particulier des fichiers mensuels dust.nc :A DECIDER : |
---|
| 750 | #C'est entre le cas des aerosols.clim= 1 seul fichier, annuel, |
---|
| 751 | # et le cas des vents guidage, pré-interpolés avec era2gcm pour toute la periode, dans MAINDIR/GUIDE. |
---|
| 752 | # 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. |
---|
| 753 | # 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 |
---|
| 754 | #ICI pour l'instant je copie les fichiers de chez Binta (repositoire==http...) dans LMDZ_Init/SPLA_Init, avec test sur mois 01 |
---|
| 755 | |
---|
| 756 | if [ ! -d ${LMDZ_Init}/SPLA_Init/PERIOD0001 ] ; then cp -pr /gpfsstore/rech/gzi/rgzi027/ergon/BIBIAERO/INPUTS_DUST/PERIOD* $LMDZ_Init/SPLA_Init/. ; fi |
---|
| 757 | |
---|
| 758 | #A la fin on doit avoir dans SPLA_Init les fichiers initiaux dans INITIAL plus les repertoires PERIOD00MM contenant dust.nc |
---|
| 759 | #Cela doit se retrouver dans script_SIMU qui les copie dans le repertoire de run sur $SCRATCH |
---|
| 760 | |
---|
| 761 | fi #$aerosols = spla |
---|
| 762 | |
---|
| 763 | |
---|
| 764 | #------------------------------------------------------------------- |
---|
| 765 | # Fichiers Init |
---|
| 766 | #------------------------------------------------------------------- |
---|
| 767 | get="myget 3DInputData/Init/" |
---|
| 768 | liste_get="alb_bg_modisopt_2D_ESA_v2.nc reftemp.nc" |
---|
| 769 | for file in $liste_get ; do |
---|
| 770 | if [ ! -f $LMDZ_Init/$file ] ; then cd $LMDZ_Init ; ${get}$file ; cd - ; fi |
---|
| 771 | done |
---|
| 772 | |
---|
| 773 | cd $local |
---|
| 774 | |
---|
| 775 | |
---|
| 776 | |
---|
| 777 | if [ $init = 1 ] ; then |
---|
| 778 | ##################################################################### |
---|
| 779 | echo Creation de l etat initial |
---|
| 780 | ##################################################################### |
---|
| 781 | |
---|
| 782 | # Creation du repertoire INIT et mise en place de liens logiques vers les starts |
---|
| 783 | # en anticipation de leur création : |
---|
| 784 | mkdir $local/$INIT ; cd $local/$INIT |
---|
| 785 | for an in $mthini $yearini ; do for f in start startphy ; do ln -s $f.nc $f.$an.nc ; done ; done |
---|
| 786 | |
---|
| 787 | # Creation du repertoire INIT temporaire et rapatriement des fichiers necessaires |
---|
| 788 | if [ -d $WRK/$INIT ] ; then mv $WRK/$INIT $WRK/$INIT$$ ; fi |
---|
| 789 | mkdir $WRK/$INIT ; cp -r $local/DEF $WRK/$INIT/ |
---|
| 790 | cd $WRK/$INIT ; cp DEF/*.def . ; cp $local/lmdz_env.sh . |
---|
| 791 | if [ $xios = y ] ; then |
---|
| 792 | cp DEF/XMLfilesLMDZ/*xml . |
---|
| 793 | if [ $veget != 'NONE' ] ; then cp DEF/XMLfilesOR$veget/*xml . ; fi |
---|
| 794 | fi |
---|
| 795 | sed -e 's/anneeref=.*.$/anneeref='$yearini'/' DEF/run.def >| run.def |
---|
| 796 | |
---|
| 797 | #------------------------------------------------------------------- |
---|
| 798 | # Fichiers Limit |
---|
| 799 | #------------------------------------------------------------------- |
---|
| 800 | get="myget 3DInputData/Limit/" |
---|
| 801 | liste_get="Albedo.nc Relief.nc Rugos.nc landiceref.nc" |
---|
| 802 | for yr in $yrs ; do |
---|
| 803 | if [ $climato = 0 ] ; then sufyr=$suf$yr ; else sufyr=$suf ; fi |
---|
| 804 | liste_get="$liste_get amipbc_sic_$sufyr.nc amipbc_sst_$sufyr.nc" |
---|
| 805 | done |
---|
| 806 | echo LISTEGET $liste_get |
---|
| 807 | for file in $liste_get ; do |
---|
| 808 | if [ ! -f $LMDZ_Init/$file ] ; then cd $LMDZ_Init ; ${get}$file ; cd - ; fi |
---|
| 809 | ln -s $LMDZ_Init/$file |
---|
| 810 | done |
---|
| 811 | #------------------------------------------------------------------- |
---|
| 812 | # ECDYN |
---|
| 813 | #------------------------------------------------------------------- |
---|
| 814 | get="myget 3DInputData/Init/" |
---|
| 815 | if [ ! -f $LMDZ_Init/ECDYN.nc ] ; then cd $LMDZ_Init ; ${get}ECDYN.nc ; cd - ; fi |
---|
| 816 | ln -s $LMDZ_Init/ECDYN.nc |
---|
| 817 | ln -sf ECDYN.nc ECPHY.nc |
---|
| 818 | |
---|
| 819 | |
---|
| 820 | # Creation du script d'initialisation |
---|
| 821 | cat <<...eod>| tmp |
---|
| 822 | #!/bin/bash |
---|
| 823 | |
---|
| 824 | #SBATCH --job-name=Init # nom du job |
---|
| 825 | #SBATCH -A "$groupe"@cpu |
---|
| 826 | #SBATCH --ntasks=1 # Nombre de processus MPI |
---|
| 827 | #SBATCH --cpus-per-task=16 # nombre de threads OpenMP |
---|
| 828 | # /!\ Attention, la ligne suivante est trompeuse mais dans le vocabulaire |
---|
| 829 | # de Slurm "multithread" fait bien référence à l'hyperthreading. |
---|
| 830 | #SBATCH --hint=nomultithread # 1 thread par coeur physique (pas d'hyperthreading) |
---|
| 831 | #SBATCH --time=00:10:00 # Temps d’exécution maximum demandé (HH:MM:SS) |
---|
| 832 | #SBATCH --output=Init%j.out # Nom du fichier de sortie |
---|
| 833 | #SBATCH --error=Init%j.out # Nom du fichier d'erreur (ici commun avec la sortie) |
---|
| 834 | # To submit to dev queue ; "time" (above) must be max 2h |
---|
| 835 | # #SBATCH --qos=qos_cpu-dev |
---|
| 836 | |
---|
| 837 | # ANCIEN MULTI STEP case \${LOADL_STEP_NAME} in |
---|
| 838 | |
---|
| 839 | # ANCIEN MULTI STEP init ) |
---|
| 840 | |
---|
| 841 | if [ ! -f lmdz_env.sh ] ; then echo manque fichier lmdz_env.sh ; ls ; exit ; fi |
---|
| 842 | . lmdz_env.sh |
---|
| 843 | ulimit -s unlimited |
---|
| 844 | export OMP_STACKSIZE=800M |
---|
| 845 | export OMP_NUM_THREADS=1 |
---|
| 846 | cd $WRK/$INIT |
---|
| 847 | echo Executable : $ce0l |
---|
| 848 | for yr in $yrs ; do |
---|
| 849 | if [ $climato = 0 ] ; then sufyr=$suf\$yr ; else sufyr=$suf ; fi |
---|
| 850 | ln -sf amipbc_sic_\$sufyr.nc amipbc_sic_1x1.nc |
---|
| 851 | ln -sf amipbc_sst_\$sufyr.nc amipbc_sst_1x1.nc |
---|
| 852 | sed -e 's/anneeref=.*.$/anneeref='\$yr'/' DEF/run.def >| run.def |
---|
| 853 | echo Starting initialisation |
---|
| 854 | $run 1 $ce0l |
---|
| 855 | if [ $climato = 0 ] ; then mv limit.nc limit.\$yr.nc ; fi |
---|
| 856 | done |
---|
| 857 | # ANCIEN MULTI STEP ;; |
---|
| 858 | |
---|
| 859 | # ANCIEN MULTI STEP interp ) |
---|
| 860 | if [ $aerosols = clim ] ; then |
---|
| 861 | cp $local/interp_aerosols.sh . ; chmod +x interp_aerosols.sh |
---|
| 862 | # Les aerosols de l'annee 2000 ont ete remplaces par "9999" qui pointe vers un fichier moyen sur 1995-2014 |
---|
| 863 | #for year in 2000 1850 ; do ./interp_aerosols.sh \$year ; done |
---|
| 864 | #mv aerosols.2000.nc aerosols.clim.nc ; mv aerosols.1850.nc aerosols.nat.nc |
---|
| 865 | for year in 9999 1850 ; do ./interp_aerosols.sh \$year ; done |
---|
| 866 | mv aerosols.9999.nc aerosols.clim.nc ; mv aerosols.1850.nc aerosols.nat.nc |
---|
| 867 | fi |
---|
| 868 | |
---|
| 869 | # AS : S'il etait possible d'automatiser l'interpolation de l'input SPLA, ce serait a lancer ici |
---|
| 870 | #en attendant, on passe au paragraphe suivant où on copie les fichiers à la res ZoomNaf depuis $LMDZ_Init/SPLA_Init |
---|
| 871 | #if [ $aerosols = spla ] ; then |
---|
| 872 | #cp $local/futur script interp_aerosols_SPLA.sh . ; chmod +x interp_aerosols_SPLA.sh |
---|
| 873 | #for file in... ; do ./interp_aerosols_SPLA.sh \$year ; done |
---|
| 874 | #etc etc etc ... |
---|
| 875 | #fi |
---|
| 876 | |
---|
| 877 | # Copy initial and forcing files in $local/$INIT and $local/$LIMIT; also in $local/INPUT_SPLA if $aerosols=spla |
---|
| 878 | for f in sta* limit.nc gri*nc ; do cp \$f $local/$INIT/\$f ; done |
---|
| 879 | mkdir -p $local/$LIMIT |
---|
| 880 | for f in limit*.nc ; do cp \$f $local/$LIMIT/\$f ; done |
---|
| 881 | if [ $aerosols = clim ] ; then for f in aerosols[.0-9]*nc ; do cp \$f $local/$LIMIT/\$f ; done ; fi |
---|
| 882 | # |
---|
| 883 | if [ $aerosols = spla ] ; then |
---|
| 884 | #mkdir -p $local/INPUT_SPLA ; pour l'instant on copie $LMDZ_Init/SPLA_Init en block |
---|
[4718] | 885 | if [ ! -d $local/INPUT_SPLA ] ; then cp -pr $LMDZ_Init/SPLA_Init $local/INPUT_SPLA ; fi |
---|
[4615] | 886 | fi |
---|
| 887 | cd $WRK |
---|
| 888 | ...eod |
---|
| 889 | if [ $ok_guide != y ] ; then # Running first simulation automatically except for nudging |
---|
| 890 | cat <<...eod>> tmp |
---|
| 891 | $submit tmp_$SIM |
---|
| 892 | ...eod |
---|
| 893 | fi |
---|
| 894 | cat <<...eod>> tmp |
---|
| 895 | # ANCIEN MULTI STEP esac |
---|
| 896 | ...eod |
---|
| 897 | |
---|
| 898 | echo '###############################################################################' |
---|
| 899 | echo Submitting initialisation job |
---|
| 900 | pwd |
---|
| 901 | $submit tmp |
---|
| 902 | echo '###############################################################################' |
---|
| 903 | |
---|
| 904 | else |
---|
| 905 | #case [ $init != 1 ] |
---|
| 906 | |
---|
| 907 | cd $WRK |
---|
| 908 | echo '###############################################################################' |
---|
| 909 | echo Submitting job tmp_$SIM |
---|
| 910 | echo $submit tmp_$SIM |
---|
| 911 | $submit tmp_$SIM |
---|
| 912 | echo '###############################################################################' |
---|
| 913 | fi |
---|
| 914 | |
---|
| 915 | |
---|
| 916 | if [ $ok_guide = y -a $init = 1 ] ; then |
---|
| 917 | echo Once initialisation is finished, you have to create nudging files |
---|
| 918 | echo Edit era2gcm.sh and set the desired parameters in section "User choices" |
---|
| 919 | echo Make sure you have acces to the chosen ERA files, and the required modules are load |
---|
| 920 | echo Then run : ./era2gcm.sh |
---|
| 921 | if [ "$aerosols" = "spla" ] ; then |
---|
| 922 | echo Your aerosol choice is "spla", so you need ERA 10m-winds interpolated on LMDZ grid |
---|
| 923 | echo Use script era2gcm_uv10m.sh |
---|
| 924 | fi |
---|
| 925 | else |
---|
| 926 | echo Si tout se passe bien, vous avez initialise et lance automatiquement |
---|
| 927 | echo la simulation. |
---|
| 928 | echo Si vous voulez modifier les caracteristiques du job, comme le temps |
---|
| 929 | echo max ou le nombre de proc, il se trouve sur |
---|
| 930 | echo $SCRATCHD/$MAINDIR/tmp_$SIM |
---|
| 931 | fi |
---|
| 932 | |
---|
| 933 | ############################################################################### |
---|
| 934 | # At the end, print on screen the compilation command, and also in a "compile.sh" script |
---|
| 935 | |
---|
| 936 | echo "To recompile the model :" |
---|
| 937 | echo "run the compile${sufiso}.sh script created in the present folder: ./compile${sufiso}.sh gcm " |
---|