Changeset 4935


Ignore:
Timestamp:
May 6, 2024, 1:20:09 PM (13 days ago)
Author:
abarral
Message:

mildly refactor main.sh
change README* to .md
(WIP) start refactor setup.sh with sourced install_lmdz

Location:
BOL/LMDZ_Setup_amaury
Files:
2 edited
2 moved

Legend:

Unmodified
Added
Removed
  • BOL/LMDZ_Setup_amaury/README0_HowTo.md

    r4934 r4935  
     1
     2
    13Last update : 2023-07-05
    2 ===================================================================
    34
    45Complementary information and FAQ (in French) :
    56https://docs.google.com/document/d/1OLZG6e-86NiXuv5-aALxKIh-QPkp4BdCwWtiBFot-6c
    67
    7 ===================================================================
    88I. What this working environment does and does not
    9 ===================================================================
     9==================================================
    1010
    11 This tutorial can only be used on jean-zay computer at idris so far.
     11This setup can only be used on jean-zay computer at idris so far.
    1212    However, extension to ciclad or irene will be done soon.
    1313
     
    2323   a calendar with 360 days.
    2424
    25 Optionally : the configuration includes the ability to use interannually
     25Optionally: the configuration includes the ability to use interannually
    2626   varying SST and to activate "nudgning" by reanalysis.
    2727   In both cases, the calendar is then a real one.
     
    4444A configuration with isotopes is also available since 2023-04.
    4545   
    46 ===================================================================
    4746II. Files and scripts
    4847===================================================================
     
    5150CAREFUL: these scripts MUST be run from $STORE !!!!!
    5251
    53   untar the tutorial_prod.tar file in your $STORE 
     52  untar the tutorial_prod.tar file in your $STORE;
    5453  rename the TEST_PROD directory if you want to;
    5554  then run everything from this newly created directory
     
    10099     DEF/guide.def : nudging parameters
    101100
    102 ============================================================
    103101III. Known problems
    104 ============================================================
     102===================
    105103
    106104Running zoomed or coarse grid simulations
     
    116114       choose the corresponding version of DEF/orchidee_6.*.def
    117115
    118 ============================================================
    119116IV. Updates (reverse chronological order)
    120 ============================================================
     117=========================================
     118
    1211192023-07 (AS-FH-LF) : mise sous svn du repertoire TEST_PROD, renommé en "LMDZ_config"
    122120
     
    13713524/03/2020 (FH): corrections for use with AMIP SSTs and monthly freq
    138136
    139 ============================================================
    140137V. TBD
    141 ============================================================
     138======
    142139See documentation (link of the shared google doc in the beginning of this Readme)
    143140
  • BOL/LMDZ_Setup_amaury/README1_TestMode.md

    r4934 r4935  
    22
    33For development/debug purposes :
    4 List of changes in tutorial_prod scripts, in order to obtain a light&fast version : 
    5 =============================================
     4
     5### List of changes in tutorial_prod scripts, in order to obtain a light&fast version : 
     6
    67
    78-> low horizontal resolution : 48x36x39, or 32x32x39
  • BOL/LMDZ_Setup_amaury/main.sh

    r4852 r4935  
    11#!/bin/bash
     2
     3set -eu
    24
    35#####################################################################
     
    2527#       modify STORED variable accordingly
    2628#    The model will be installed in $LMDZD directory defined in lmdz_env.sh
    27 #      Default : LMDZD=$WORK ; can be changed in LMDZD=$WORK/Your_directory
     29#      Default : LMDZD=$WORK; can be changed in LMDZD=$WORK/Your_directory
    2830#    To use a model already installed (and compiled), by you or someone else (check the acces!):
    2931#       set LMDZD=path_to_model_to_use
     
    3739# Version of the tar file on https://lmdz.lmd.jussieu.fr/pub/src
    3840# Last "testing" version, thoroughly checked by the LMDZ team : contains LMDZ rev 4729 (2023-10-22)
     41# TODO move to expert-level settings
    3942version="20240308.trunk" #!! DON'T CHANGE IT WITHOUT CHECKING WITH LMDZ TEAM !!
    4043svn=""                   #!! DON'T CHANGE IT WITHOUT CHECKING WITH LMDZ TEAM !!
     
    4346        #       Mattermost: https://mattermost.lmd.ipsl.fr/lmdz/channels/installation-et-tutoriels
    4447
    45 #-----------------------------------------------------------
    4648# Grid number of points IMxJMxLM
    47 #-----------------------------------------------------------
    48 resol=144x142x79
     49resol="144x142x79"
    4950
    50 #-----------------------------------------------------------
    51 # To install the model :  -install
    52 #-----------------------------------------------------------
    53 install=""
    54 install=-install
     51# Whether to install the model: "-install" to install the model, else ""
     52install="-install"
    5553
    56 #-----------------------------------------------------------
    57 # Using XIOS for IOs
    58 #-----------------------------------------------------------
    59 xios="-xios"
     54# Using XIOS for IOs: "-xios" for enabled, else ""
    6055xios=""
    6156
    62 #-----------------------------------------------------------
    63 # Using or not the Cosp simulator 
    64 #-----------------------------------------------------------
    65 #cosp="-cosp"
     57# Using or not the Cosp simulator: "-cosp" for enabled, else ""
    6658cosp=""
    67 echo $xios $cosp
    6859
    69 #-----------------------------------------------------------
    7060# Choice of physics (default : "lmd" for "phylmd" )
    7161#   Examples : lmd_phys="new" to compile with phynew instead of phylmd,
    7262#              lmd_phys="lmdiso" to run with Isotopes
    73 #-----------------------------------------------------------
    7463lmd_phys="lmd"
    7564
     
    7867#===========================================================
    7968
    80 #-----------------------------------------------------------
    8169# Initial state and Boundary conditions
    82 #-----------------------------------------------------------
     70# init=   1: to create a new start in INIT
     71#         0: to read start files in INIT
     72#       SIM: to read start files from previous simulation SIM0, /!\ SIM0 must be in the same folder as the new SIM
     73# (limit.nc and aerosols forcing are put in ./LIMIT)
     74init=1
    8375
    84 # init=   1: to create a new start in INT
    85 #         0: to read start files in INIT
    86 #       SIM: to read start files from previous simulation SIM0
    87 # limit.nc and aerosols forcing are put in ./LIMIT
    88 init=1
    89 #init=SIM0 # SIM0 must be in the same folder as the new SIM
    90 
    91 #-----------------------------------------------------------
    92 # climato=1 : Climatological SSTs with 360-day calendar
     76# climato=1 : Climatological SSTs with 360-day calendar
    9377#        =0 : interannual SSTs with true (ie gregorian) calendar
    94 #-----------------------------------------------------------
    9578climato=1
    9679
    97 #-----------------------------------------------------------
    9880# Nudging: Can only be activated with climato=0 and freq=mo
    99 #-----------------------------------------------------------
    100 nudging="-nudging"
     81# ="-nudging" for enabled, else ""
    10182nudging=""
    10283#If using nudging, then check DEF/guide.def :
     
    10485#  - You may want to check/customize the nudging parameters
    10586
    106 #-----------------------------------------------------------
    10787# Length of elementary simulations yr (year) or mo (month)
    108 #-----------------------------------------------------------
    109 freq=yr
     88freq="yr"
    11089
    111 #-----------------------------------------------------------
    11290# Initial/final month for simulation
    113 #-----------------------------------------------------------
    11491# If $init=1, the INIT file will be called start.200001.nc,
    11592# but the data correspond in fact to another day.
     
    12198# Output files, frequencies, levels
    12299#   If you use IOIPSL (option xios=""), you may want to choose and customize DEF/config.def.
    123 #     A few versions are available as DEF/config.def_* ; config.def is a copy of config.def_default
     100#     A few versions are available as DEF/config.def_*; config.def is a copy of config.def_default
    124101#     See phys_out_filekeys, phys_out_filelevels, phys_out_filetimesteps, and supplementary variables
    125102#   If you use XIOS (option xios="-xios"), check/modify DEF/XMLfiles*/file*xml
     
    128105# Grid characteristics (regular, zoomed)
    129106#   You may want to choose and customize DEF/gcm.def
    130 #   A few versions are available as DEF/gcm.def_* ;
     107#   A few versions are available as DEF/gcm.def_*;
    131108#      The default, for regular grid 144x142x79, corresponds to _iperiod7
    132109#      (Expert : TEMPORARILY : setup.sh forces use of gcm.def_zNAfrica_BiJe for aerosols=spla)
     
    140117# NOTE : automatically choosing DEF/PHYS/physiq.def_NPiso for isotopes
    141118physics="NPv6.3"
    142 if [ $lmd_phys = "lmdiso" ] ; then physics="NPiso" ; fi
     119if [[ $lmd_phys = "lmdiso" ]]; then physics="NPiso"; fi
    143120
    144 for phys in $physics ; do
    145   deffile=DEF/PHYS/physiq.def_${phys}
    146   if [ -f $deffile ] ; then
     121if [[ $(echo "$physics" |wc -w) -gt 1 && $init = 1 ]]; then echo "!=!=! TO LOOP OVER MULTIPLE physics [$physics], YOU NEED init =/= 1 AND start* + limit* files ALREADY AVAILABLE IN THIS FOLDER !=!=!"; exit 1; fi
     122
     123for phys in $physics; do
     124  deffile="DEF/PHYS/physiq.def_$phys"
     125  if [[ -f $deffile ]]; then
    147126     cp -p $deffile DEF/physiq.def
    148127
    149128    # name of simulation : can be changed to user's convenience
    150     # (Default : name=$phys to loop on different physics)
    151     name=${phys}     
     129    # (Default: name=$phys to loop on different physics)
     130    name="$phys"
    152131
    153132    # launching setup.sh with the options defined in this main.sh.
    154     # Remember : some other options are only available in lmdz_env.sh and setup.sh.
    155     ./setup.sh -v "$version" $svn -d $resol $install $cosp $xios -init $init -climato $climato $nudging -f $freq -mthini $mthini -mthend $mthend -p $lmd_phys -name $name
    156 
    157     nphys=`echo "$physics" |wc -w` ; if [ $nphys -gt 1 -a $init = 1 ] ; then echo "!=!=! TO LOOP OVER MULTIPLE "physics", YOU NEED init /= 1 AND start* + limit* files ALREADY AVAILABLE IN THIS FOLDER !=!=!" ; exit ; fi
    158 
    159 else  # wrong "{phys}" name in "physics" list
    160  echo File $deffile inexistent
    161  exit
    162 fi
    163 
     133    # Remember: some other options are only available in lmdz_env.sh and setup.sh.
     134    # TODO clarifier la diff entre $phys et $lmd_phys ?
     135    ./setup.sh -v "$version" "$svn" -d "$resol" "$install" "$cosp" "$xios" -init "$init" -climato "$climato" "$nudging" -f "$freq" -mthini "$mthini" -mthend "$mthend" -p "$lmd_phys" -name "$name"
     136  else
     137    echo "File $deffile inexistent"; exit 1
     138  fi
    164139done
    165140
  • BOL/LMDZ_Setup_amaury/setup.sh

    r4796 r4935  
    11#!/bin/bash
    2 
    3 #set -vx
    4 
    5 #####################################################################
    6 # This script sets up and launches a (series of) simulation(s).
    7 #
     2# This script sets up and launches a (series of) simulation(s).
    83# RECOMMENDATION: use main.sh to drive it (do not run it directly)
    9 #
    10 #####################################################################
    11 #
     4
     5set -eu
     6
    127# 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
    48 # - number: orchidee version number : only rev 7983 on branch _2_2, and 7994 on trunk, are available
    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
     8####################################################################
     9function define_expert_options {
     10  #NOTE : $optim  is part of $LMDZname (see definition of LMDZname below),
     11  #   so that running with "-debug" needs to (re)install the model (install=-install in main.sh)
     12  #   If you have already installed the model, and only want to recompile the gcm in debug mode,
     13  #   add "-debug" to the compilation options in the compile.sh script created in the present folder, and run it (./compile.sh gcm)
     14  #   ALTERNATIVELY : you can remove $optim in the definition of "LMDZname" below
     15  optim=""
     16  #optim="-debug"
     17  # TODO Amaury: quelle diff avec l'option fcm="debug" ???
     18
     19  #NOTE : "testmode=y" is for running in test mode :
     20  # the simulation job "tmp_$SIM" (created on $SCRATCHDIR) is automatically changed for a short run,
     21  # and submitted to the Jean-Zay "test" queue :
     22  #  a/ time=00:10:00  (run time limit = 10 min; for test queue, it must be 30 min maximum)
     23  #  b/ nday=1 (this line, forcing nday to 1 day, is "hidden" in script_SIMU, by default it is commented out)
     24  #  c/ #SBATCH --qos=qos_cpu-dev (this line is in script_SIMU, by default it is commented out)
     25  #If you want to change "time", or "nday", but still run in "test" mode, modify the "if [ $debug = 1 ]...; fi" further below.
     26  testmode=n
     27
     28  # Radiative code : "oldrad" or "rrtm" or "ecrad"
     29  rad="rrtm"
     30
     31  # AEROSOLS : n (=no) / clim (=average 1995-2014) / spla (interactive dust and sea salt)
     32  # (WARNING : if you first run the scripts with aerosols=n, then you want to change to =clim ,
     33  #   you'll need to remove the INIT and LIMIT folders that have been created, then run main.sh with init=1
     34  #   in order to re-run the initialisation job, which downloads the aerosol files and interpolates them)
     35  aerosols="clim"
     36
     37  # SURFACE/VEGETATION SCHEME
     38  # It is controlled by the single variable "veget" which can have the following values
     39  # - "none": bucket scheme
     40  # - "CMIP6" or "orch2.0": orchidee version used in CMIP exercise, rev 5661
     41  # - "orch2.2": orchidee version used in IPSLCM7 configuration
     42  # - number: orchidee version number : only rev 7983 on branch _2_2, and 7994 on trunk, are available
     43  veget="CMIP6"
     44  #AS : If you have installed the model with a given "veget" option, and you want to change it :
     45  #   --> RECOMMENDED : re-install the model from scratch in a new TEST_PROD folder
     46  #   TODO Amaury: check w/ Adriana what the use case is for lmdz_setup here
     47  #   --> EXPERT : If you want to keep your previous installation, and not go through the install_lmdz.sh routine,
     48  #    you will need to (a) install the proper version of ORCHIDEE in the modipsl/modeles directory, and
     49  #                     (b) set the "veget" options (opt_veget, orchidee_rev, suforch) to their proper values
     50  #                        in the file $LMDZD/modipsl/modeles/surface_env
     51  # (NB : no need to initialise these vars here:
     52  #     surface_env is either (re)created when (re)installing the model (run with install=-install),
     53  #     or it already exists (install="").
     54
     55  # New snow scheme INLANDSIS (y/n)
     56  # (this flag activates INLANDSIS compilation;
     57  # not yet done : treatment of specific restart and def file)
     58  inlandsis="n"
     59
     60  # COMPILATION options : "", "fcm", "debug"
     61  fcm=""
     62
     63  # --->>> ALSO PAY ATTENTION TO OUTPUT files, frequency, level -------------
     64  #   With IOIPSL : Choose your config.def among the versions available in DEF,
     65  #     copy it as config.def (the copy is done automatically for "iso"),
     66  #     edit it and set up output files, frequencies and levels.
     67  #     NB : For aerosols=spla, output level minimum 4 is required to output the specific variables.
     68  #          For aerosols=n, the corresponding flags will automatically be set to "n".
     69  #   With XIOS : adjust DEF/XMLfiles*/file*xml
    10770}
    10871
    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)
     72# /!\ DO NOT EDIT BELOW UNLESS YOU KNOW WHAT YOU ARE DOING /!\
     73
     74function load_install_lib {
     75  # Fetch and source install_lmdz.sh
     76  if [[ ! -f "lib_install_lmdz.sh" ]]; then
     77    wget "http://svn.lmd.jussieu.fr/LMDZ/BOL/script_install_amaury/install_lmdz.sh" # TODO change to normal branch once ready
     78    mv install_lmdz.sh lib_install_lmdz.sh  # rename to avoid misleading users as to which script to run
     79    sed -i'' "2i# This is a library used in the installation, DO NOT RUN IT YOURSELF unless you're an expert !" lib_install_lmdz.sh
     80  fi
     81  source lib_install_lmdz.sh
     82}
     83load_install_lib  # Do not move later, as it would overwrite some functions
     84
     85function set_default_params {
     86  # Default value of script parameters
     87  SIM=$(basename "$local")CTL  # name
     88  phylmd="lmd" #option -p $phylmd for makelmdz
     89
     90  cosp="n"  # COSP
     91  xios="n"  #XIOS
     92
     93  # Nudging :
     94  ok_guide="n"
     95  # With nudging, use real calendar (climato=0) and monthly integrations
     96  climato=1
     97  freq="mo"  # frequence mensuelle mo ou annuelle yr
     98
     99  # NB : the run stops in the BEGINNING of mthend (test "next=stopsim")
     100  mthini=200001
     101  mthend=200501
     102  resol="144x142x79"
     103
     104  version="20230412.trunk"
     105  svn=""
     106
     107  install=0
     108  init=1
     109
     110  LIMIT="LIMIT"
     111}
     112
     113function read_cmdline_args {
     114  while (($# > 0)); do
     115    case $1 in
     116      "-h") cat <<........fin
     117       setup.sh can be launched/driven by main.sh; some options can only be specified in setup.sh (ex: veget, aerosols).
     118             setup.sh [-v version] [-r svn_release] [-init INIT] [-d 96x95x79] [-f mo] [-nudging]
     119             "version" like 20150828.trunk; see https://lmdz.lmd.jussieu.fr/Distrib/LISMOI.trunk (default <$version>)
     120             "svn_release"      either the svn release number or "last" (default <$svn>)
     121             -d IMxJMxLM        to run in resolution IM x JM x LM (default <$resol>)
     122             -install           pour installer et compiler le modele
     123             -f mo/yr           pour tourner en mensuel ou annuel (default <$freq>)
     124             "INIT"             1: creates INIT and LIMIT
     125                                0: reads from INIT and LIMIT
     126                                SIMU: reads from preexisting simulation SIMU and LIMIT (default <$init>)
     127             -nudging           to run with nudging. Nudging files must be created independently
     128             -p                 the physics to use (default <$phylmd>)
     129             -name              install folder name (default <$SIM>)
     130             Other options available (see "options" section in the script)
    161131........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
     132        exit;;
     133      "-v") version="$2"; shift; shift;;
     134      "-r") svn=$2; shift; shift;;
     135      "-d") resol=$2; shift; shift;;
     136      "-f") freq=$2; shift; shift;;
     137      "-p") phylmd=$2; shift; shift;;
     138      "-install") install=1; shift;;
     139      "-name") SIM=$2; shift; shift;;
     140      "-cosp") cosp=y; shift;;
     141      "-xios") xios=y; shift;;
     142      "-init") init=$2; shift; shift;;
     143      "-nudging") ok_guide=y; shift;;
     144      "-climato") climato=$2; shift; shift;;
     145      "-mthini") mthini=$2; shift; shift;;
     146      "-mthend") mthend=$2; shift; shift;;
     147      *) $0 -h; exit
     148    esac
     149  done
     150
     151  # Isotopes : Compile and run with isotopes if lmdz_phys="lmdiso" in main.sh
     152  if [[ $phylmd = "lmdiso" ]]; then isotopes="y"; else isotopes="n"; fi
     153
     154  # Initialisation
     155  if [[ $init = 1 || $init = 0 ]]; then
     156    INIT="INIT"
     157  else
     158    INIT=$init
     159  fi
     160
     161  yearini=$(echo "$mthini" | cut -c-4)
     162  if [[ $freq = yr ]]; then stopsim=$(echo "$mthend" | cut -c-4); else stopsim=$mthend; fi
     163
     164  if [[ $svn = "" ]]; then svnopt=""; else svnopt="-r $svn"; fi
     165
     166  if [[ -d $SIM ]]; then
     167     echo "La simulation $SIM existe deja. Il est conseillé d'arrêter et de vérifier."
     168     echo "Si vous êtes sûr de vous, vous pouvez la prolonger. Voulez vous la prolonger ? (y/n)"
     169     read -r ans
     170     if [[ $ans != y ]]; then exit 1; fi
     171  fi
     172
     173  if [[ $cosp = y ]]; then ins_cosp="-cosp v1"; else ins_cosp=""; fi
     174
     175  if [[ $xios = y ]]; then ins_xios="-xios"; else ins_xios=""; fi
     176}
     177
     178function ensure_correct_option_combinations {
     179  # AVOID COMBINATIONS OF OPTIONS THAT DON'T WORK in user choices
     180
     181  if [[ $ok_guide = y && $climato = 1 ]]; then
     182     echo "Running nudged simulations with climatological SSTs is not planned. Change <climato> to <0> or modify the setup (experts)"; exit 1
     183  fi
     184
     185  if [[ $climato = 0 && $freq = yr ]]; then
     186     echo "Running simulations with interannual SSTs is possible only month by month and a true calendar."
     187     echo "Change <climato> to <1> or <freq> to <mo> or modify setup.sh (experts)"; exit 1
     188  fi
     189
     190  # STOP if trying to use both ORCHIDEE and Isotopes :
     191  if [[ $isotopes = "y" && $veget != "NONE" ]]; then
     192    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 1
     193  fi
     194
     195  # STOP if trying to use both SPLA and Isotopes :
     196  if [[ $isotopes = "y" && $aerosols = "spla" ]]; then
     197    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 1
     198  fi
     199
     200  # (Temporary) STOP if trying to use Isotopes with XIOS :
     201  # TODO Amaury: check if still relevant
     202  if [[ $isotopes = "y" && $xios = "y" ]]; then
     203    echo "STOP: Isotopes cannont yet be run with XIOS; change <xios> option in main.sh"; exit 1
     204  fi
     205
     206  # (Temporary) Constraints for aerosols=spla :
     207  # --> resolution 128x88x79 and rad=rrtm
     208  if [[ $aerosols = spla && $resol != 128x88x79 ]]; then
     209    echo 'For now, <aerosols=spla> requires <resol=128x88x79>, and uses the zoomed grid from gcm.def_zNAfrica_BiJe, for which forcing & initial files are available'
     210    echo "Right now aerosols=<$aerosols>, resol=<$resol>"
     211    exit 1
     212  fi
     213
     214  if [[ $aerosols = "spla" && $rad != "rrtm" ]]; then
     215    echo "STOP: For the time being, <aerosols=spla> requires <rad=rrtm>"; exit 1
     216  fi
     217}
     218
     219# TODO Amaury: commented-out for now
     220## Set up the appropriate environment
     221##------------------------------------
     222#sed -i -e "s/hostname=.*.$/hostname=$(hostname)/" lmdz_env.sh
     223#. lmdz_env.sh
     224#module list
     225
     226# TODO Amaury: commented-out for now
     227## Pour les post-traitements
     228#sed -i'' -e "s/groupe@cpu/$groupe@cpu/" seasonal.sh  # TODO Amaury: $groupe jamais défini, à virer ?
     229local=$(pwd)
     230
     231define_expert_options
     232set_default_params
     233read_cmdline_args "$@"
     234ensure_correct_option_combinations
     235
     236exit 1
     237
     238
     239
     240
     241
     242
    258243
    259244########################################################################
     
    261246########################################################################
    262247
    263 if [ ! -d $LMDZD ] ; then mkdir -p $LMDZD ; fi
     248if [ ! -d $LMDZD ]; then mkdir -p $LMDZD; fi
    264249version_name=LMDZ`echo $version | sed -e 's/-v//g' -e 's/-unstable//' -e 's/-r/r/' -e 's/ //g'`
    265250LMDZname=${version_name}${svn}${optim}OR${veget}${ins_xios}
    266251MODEL=$LMDZD/$LMDZname/modipsl/modeles/LMDZ
    267252
    268 if [ $install = 1 ] ; then
    269    if [ -d $MODEL ] ; then
     253if [ $install = 1 ]; then
     254   if [ -d $MODEL ]; then
    270255           echo $MODEL
    271256      echo "Vous essayez d installer une version deja presente"
     
    283268      ./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
    284269      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
     270      if grep "Not Found" $LMDZname/get.log >/dev/null; then echo "version=$version is NOT A TESTING VERSION, Ask LMDZ Team"; exit; fi
    286271      cd $local
    287272   fi
    288273else
    289    if [ ! -d $MODEL ] ; then
     274   if [ ! -d $MODEL ]; then
    290275      echo Le model $MODEL n est pas installe
    291276      echo relancer avec install=1 si vous voulez l installer automatiquement
     
    299284# for which the test was introduced
    300285mysvn=`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
     286if [ "$mysvn" = "" ]; then mysvn=`grep 'Revision: [0-9]' $LMDZD/$LMDZname/Read*.md | awk ' { print $2 } ' 2>/dev/null`; fi
     287if [ "$mysvn" = "" ]; then mysvn=4190; fi
    303288echo mysvn $mysvn
    304289
     
    306291# lmdz_env.sh must be sourced again, and copied again as $MODEL/arch/arch-X64_JEANZAY.env
    307292# (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
     293if [ ${hostname:0:5} = "jean-" -a $mysvn -ge 4532 -a ! "`grep netcdf95 lmdz_env.sh`" ]; then
    309294   cp -p lmdz_env.sh lmdz_env.orig
    310295   sed -i'' -e 's/module load nco/module load netcdf95\n                module load nco/' lmdz_env.sh
     
    315300# COMPILATION OPTIONS depending on the user choices and LMDZ revision number $mysvn
    316301#-------------------------------------------------------
    317 if [ "$ARCH" = "" ] ; then arch= ; else arch="-arch $ARCH" ; fi
    318 
    319 if [ $cosp = y ] ; then opt_cosp="-cosp true" ; else opt_cosp="" ; fi
     302if [ "$ARCH" = "" ]; then arch=; else arch="-arch $ARCH"; fi
     303
     304if [ $cosp = y ]; then opt_cosp="-cosp true"; else opt_cosp=""; fi
    320305   # makelmdz* uses "opt_cosp", and for v1 (default) needs "-cosp true/false" 
    321306   # 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
     307   # (option cosp2 in makelmdz* to be ignored; it is a transitory version from v1 to v2)
     308
     309if [ $xios = y ]; then opt_xios="-io xios"; else opt_xios=""; fi
    325310
    326311case $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
     312    oldrad) iflag_rrtm=0; NSW=2; opt_rad="";;
     313    rrtm)   iflag_rrtm=1; NSW=6; if [ $mysvn -le 4185 ]; then opt_rad="-rrtm true"; else opt_rad="-rad rrtm"; fi;;
     314    ecrad)  iflag_rrtm=2; NSW=6; opt_rad="-rad ecrad";;
     315    *) echo Only oldrad rrtm ecrad for rad option; exit
    331316esac
    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
     317if [ "$rad" = "ecrad" -a ! -d ecrad_data ]; then
     318    cd $local; wget https://lmdz.lmd.jussieu.fr/pub/3DInputData/ecrad/ecrad_data.tar; tar xvf ecrad_data.tar; cd -
     319fi
     320if [ "$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
    336321
    337322
    338323# Aerosols : also define the associated suffix in gcm name
    339 if [ $aerosols = spla ] ; then
    340   opt_aer=' -dust true ' ;  sufaer='_spla'
     324if [ $aerosols = spla ]; then
     325  opt_aer=' -dust true ';  sufaer='_spla'
    341326else
    342   opt_aer=""             ;  sufaer=''
    343 fi
    344 
    345 if [ $inlandsis = y ] ; then
     327  opt_aer=""            ;  sufaer=''
     328fi
     329
     330if [ $inlandsis = y ]; then
    346331   opt_inlandsis="-inlandsis true"
    347332else
     
    350335
    351336# Isotopes : also define the associated suffix in gcm name
    352 if [ $isotopes = y ] ; then
    353   opt_isotopes="-isotopes true" ; sufiso="_iso"
     337if [ $isotopes = y ]; then
     338  opt_isotopes="-isotopes true"; sufiso="_iso"
    354339else
    355   opt_isotopes=""               ; sufiso=""
     340  opt_isotopes=""              ; sufiso=""
    356341fi
    357342
     
    381366#   You'll need to modify and run the compile.sh script created in the present folder, and run it (./compile.sh gcm)
    382367
    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
     368# compile_opt_iso is used for gcm only; ce0l cannot be compiled with isotopes yet (phylmd instead of phylmdiso is required)
     369if [ $isotopes = y ]; then
    385370    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
     371    if [ $mysvn -le 4185 ]; then
    387372      suffix_iso=_${resol}_phy${phylmd}_para_mem${suforch}${sufaer}${sufiso}
    388373    else
     
    395380compile_opt="$optim -p $phylmd $opt_cosp $opt_xios $opt_rad $arch -d $resol $opt_veget $opt_aer $opt_inlandsis -mem -parallel mpi_omp"
    396381
    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
     382if [ $mysvn -le 4185 ]; then suffix=_${resol}_phy${phylmd}_para_mem${suforch}${sufaer};
     383                         else suffix=_${resol}_phy${phylmd}_${rad}_para_mem${suforch}${sufaer}; fi
    399384
    400385# use an intermediate variable to use either suffix or suffix_iso
     
    405390echo $gcm
    406391
    407 if [ ! -f $gcm ] ; then
     392if [ ! -f $gcm ]; then
    408393   echo Le model $gcm n existe pas
    409394   echo il va se compiler automatiquement sur $MODEL
    410395   sleep 10
    411396
    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"
     397   if [ "$fcm" = "-nofcm" ]; then
     398       compile="./makelmdz $compile_opt \$1; mkdir -p bin; \mv -f \${prog}.e $gcm"
     399       compile_iso="./makelmdz $compile_opt_iso \$1; mkdir -p bin; \mv -f \${prog}.e $gcm"
    415400   else
    416401      # makelmdz_fcm directly produces executable named $gcm, depending on the compilation options
     
    422407   echo $compile${sufiso}
    423408
    424    #create compile.sh ;
     409   #create compile.sh;
    425410   # if isotopes = y , it will still be used for compiling ce0l
    426    cat <<...eod>| compile.sh
     411   cat << ...eod >| compile.sh
    427412   cd $MODEL
    428413   prog=\$1
     
    434419
    435420   #create compile_iso.sh for compiling gcm_ _iso.e
    436    if [ $isotopes = y ] ; then
    437    cat <<...eod>| compile_iso.sh
     421   if [ $isotopes = y ]; then
     422   cat << ...eod >| compile_iso.sh
    438423   cd $MODEL
    439424   prog=\$1
     
    448433   ./compile${sufiso}.sh gcm > lmdz.log 2>&1
    449434
    450    if [ ! -f $gcm ] ; then echo la compilation a echoue ; exit ; fi
     435   if [ ! -f $gcm ]; then echo la compilation a echoue; exit; fi
    451436   cd $local
    452437fi
     
    463448(( mpi = ( $jm + 1 ) / 2 ))
    464449omp=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
     450if [ $aerosols = spla ]; then omp=1; fi
     451if [ $veget = CMIP6 -a $xios = y ]; then omp=2; fi
     452if [ $mpi -gt $nb_mpi_max ]; then mpi=$nb_mpi_max; fi
     453if [ $omp -gt $nb_omp_max ]; then omp=$nb_omp_max; fi
    469454
    470455######################################################################
    471456# Utilisation des .def_iso pour LMDZ-ISOtopes
    472457######################################################################
    473 if [ $isotopes = y ] ; then
     458if [ $isotopes = y ]; then
    474459  for file_iso in $( ls DEF | grep _iso)
    475460  do
     
    481466# Choix de la grille verticale
    482467######################################################################
    483 if [ ! -d DEF ] ; then echo Recuperer un repertoire DEF ; exit ; fi
     468if [ ! -d DEF ]; then echo Recuperer un repertoire DEF; exit; fi
    484469lm=`echo $resol | cut -dx -f3`
    485 if [ ! -f DEF/L$lm.def ] ; then echo resolution verticale non prevue
     470if [ ! -f DEF/L$lm.def ]; then echo resolution verticale non prevue
    486471                                 echo creer un fichier DEF/L$lm.def
    487472   exit
     
    496481
    497482# Choix du fichier traceur.def coherent avec l'option "aerosols"
    498 #  NOTE : Le nouveau tracer.def_nospla par defaut n'inclut pas Rn-Pb ;
     483#  NOTE : Le nouveau tracer.def_nospla par defaut n'inclut pas Rn-Pb;
    499484#               si on les veut, il faut utiliser ci-dessous; a la place, tracer_RN_PB.def
    500485#---------------------------------------------------------------------
    501486# 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
     487# Normalement les traceurs absents de start* files sont initialises=0 dans le code; verifier pour spla ! 
     488if [ $aerosols = spla ]; then
    504489   # ancien traceur pour l instant
    505490   cp DEF/traceur.def_spla   DEF/traceur.def 
    506 elif [ $isotopes = n ] ; then
     491elif [ $isotopes = n ]; then
    507492   # nouveau traceur
    508493   # déjà copié si 'y'
     
    512497# TEMPORAIREMENT pour spla on force l'utilisation de gcm.def_zNAfrica_BiJe (avec resolution 128x88x79)
    513498#----------------------------------------------------------------------
    514 if [ $aerosols = spla ] ; then cp DEF/gcm.def_zNAfrica_BiJe DEF/gcm.def ; fi
     499if [ $aerosols = spla ]; then cp DEF/gcm.def_zNAfrica_BiJe DEF/gcm.def; fi
    515500
    516501# Inscription du choix ok_guide dans DEF/guide.def
     
    522507# NB Contrairement a ce qui est ecrit dans les fichiers run.def standard,
    523508# 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
     509if [ $climato = 0 ]; then calend=gregorian; else calend=earth_360d; fi
    525510sed -i -e 's/calend=.*.$/calend='$calend'/' DEF/run.def
    526511
     
    528513#   cf options veget, aerosols, cosp, xios
    529514#---------------------------------------------------------------------
    530 if [ $veget = NONE ] ; then  VEGET=n ; else VEGET=y ; fi
     515if [ $veget = NONE ]; then  VEGET=n; else VEGET=y; fi
    531516sed -i -e 's/VEGET=.*.$/VEGET='$VEGET'/' DEF/config.def
    532517
    533 if [ $aerosols = n ] ; then
     518if [ $aerosols = n ]; then
    534519  # set flag_aerosols=0 and flags ok_ade&co=n
    535520  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
     
    538523# COSP : ok_cosp desactive COSP si on a compile avec; il ne l'active pas si on a compile sans
    539524sed -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
     525if [ $cosp = y ]; then \cp -f $MODEL/DefLists/cosp*.txt $local/DEF/; fi
    541526
    542527# Sorties LMDZ en fonction de l'option "xios"
     
    550535sed -i'' -e 's:directory_name.*$:directory_name="'$local'/ecrad_data",:' DEF/namelist_ecrad
    551536
    552 if [ $isotopes = y ] ; then iflag_ice_thermo=0 ; else iflag_ice_thermo=1 ; fi
     537if [ $isotopes = y ]; then iflag_ice_thermo=0; else iflag_ice_thermo=1; fi
    553538sed -i -e 's/iflag_ice_thermo=.*.$/iflag_ice_thermo='$iflag_ice_thermo'/' DEF/physiq.def
    554539
    555 # Choix de orchidee.def en fonction de orchidee_rev ; modification pour xios
     540# Choix de orchidee.def en fonction de orchidee_rev; modification pour xios
    556541#  NOTE separate orchidee_pft.def file for ORCHIDEE trunk post-CMIP6 
    557542#---------------------------------------------------------------------
    558543orchidee_def=orchidee.def_6.1
    559544orchidee_pft_def=""
    560 if [ $veget = "7983" ] ; then
     545if [ $veget = "7983" ]; then
    561546  orchidee_def=orchidee.def_6.2work
    562 elif [ $veget = "7994" ] ; then
     547elif [ $veget = "7994" ]; then
    563548  orchidee_def=orchidee.def_6.4work
    564549  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
     550  if ! grep "INCLUDEDEF=orchidee_pft.def" DEF/run.def; then
     551    sed -i'' -e 's/INCLUDEDEF=orchidee.def/INCLUDEDEF=orchidee.def\nINCLUDEDEF=orchidee_pft.def/' DEF/run.def; fi
    567552fi
    568553\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
     554if [ "$orchidee_pft_def" != "" ]; then \cp -f DEF/$orchidee_pft_def DEF/orchidee_pft.def; fi
     555
     556# Only for veget=CMIP6 it is still possible to use IOIPSL; newer versions of orchidee.def have XIOS_ORCHIDEE_OK = y
    572557sed -i'' -e 's/XIOS_ORCHIDEE_OK =.*.$/XIOS_ORCHIDEE_OK = '$xios'/' DEF/orchidee.def
    573558
     
    577562# (ils vont se repercuter dans les repertoires de simulation $local/$SIM et de run $WRK)
    578563######################################################################
    579 if [ $xios = y ] ; then
     564if [ $xios = y ]; then
    580565  \cp -f $MODEL/DefLists/context_lmdz.xml $local/DEF/XMLfilesLMDZ/.
    581566  \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
     567  if [ $cosp = y ]; then \cp -f $MODEL/DefLists/field_def_cosp1.xml $local/DEF/XMLfilesLMDZ/.; fi
    583568fi
    584569
     
    588573# pour sa creation
    589574######################################################################
    590 if [ ! -d $INIT ] ; then
    591    if [ $init = 0 ] ; then
    592       echo  Recuperer les repertoires $INIT ou lancer avec option -init ; exit
     575if [ ! -d $INIT ]; then
     576   if [ $init = 0 ]; then
     577      echo  Recuperer les repertoires $INIT ou lancer avec option -init; exit
    593578   else
    594579      ce0l=$MODEL/bin/ce0l${suffix}.e
     
    596581
    597582      # Test if $ce0l exists (it may be the case if you use a model configuration already installed and compiled)
    598       if [ ! -f $ce0l ] ; then
     583      if [ ! -f $ce0l ]; then
    599584       echo L executable $ce0l n existe pas
    600585       echo il va se compiler automatiquement sur $MODEL
     
    604589     fi
    605590
    606      if [ ! -f $ce0l ] ; then echo la compilation de $ce0l a echoue ; exit ; fi
     591     if [ ! -f $ce0l ]; then echo la compilation de $ce0l a echoue; exit; fi
    607592
    608593      cd $local
    609594   fi
    610 elif [ $init = 1 ] ; then
     595elif [ $init = 1 ]; then
    611596   echo Vous essayez d initialiser le modele mais $INIT existe deja
    612597   exit
     
    617602# EXIT after (install and) compilation if we are on jean-zay-pp instead of jean-zay !
    618603hostname=`hostname`
    619 if [ ${hostname:0:11} = "jean-zay-pp" ] ; then
     604if [ ${hostname:0:11} = "jean-zay-pp" ]; then
    620605 echo "You are on jean-zay-pp, here you only can install and compile the model, not run it"
    621606 echo "If you want to run a simulation, log in to jean-zay and launch main.sh again, without install"
     
    638623#####################################################################
    639624
    640 if [ ! -d $local/$SIM ] ; then
     625if [ ! -d $local/$SIM ]; then
    641626mkdir $local/$SIM
    642627cd $local
    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
     628sed -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
    644629cp lmdz_env.sh $local/$SIM/
    645 mkdir $local/$SIM/DEF ; cp DEF/*def DEF/namelis* $local/$SIM/DEF/
     630mkdir $local/$SIM/DEF; cp DEF/*def DEF/namelis* $local/$SIM/DEF/
    646631#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
     632if [ $cosp = y ]; then cp DEF/cosp*txt $local/$SIM/DEF/; fi
     633if [ $xios = y ]; then
    649634   cp DEF/XMLfilesLMDZ/*xml $local/$SIM/DEF/
    650    if [ $veget != 'NONE' ] ; then cp DEF/XMLfilesOR$veget/*xml $local/$SIM/DEF/ ; fi
     635   if [ $veget != 'NONE' ]; then cp DEF/XMLfilesOR$veget/*xml $local/$SIM/DEF/; fi
    651636fi
    652637chmod u+w $local/$SIM/DEF/*
     
    657642    DEF/run.def >| $local/$SIM/DEF/run.def
    658643cd $SIM
    659 if [ "$freq" = "yr" ] ; then date=$yearini ; else date=$mthini ; fi
     644if [ "$freq" = "yr" ]; then date=$yearini; else date=$mthini; fi
    660645echo $date a faire >| etat
    661646
     
    663648#############################################################
    664649echo $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
     650for 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
     651for f in sechiba stomate; do if [ -f ../$INIT/start_$f.$date.nc ]; then ln -sf  ../$INIT/start_$f.$date.nc .; fi; done
    667652cp $gcm gcm.e
    668653fi  # fin de " if [ ! -d $local/$SIM ]"
     
    671656# Choix du "time limit" pour le job
    672657###################################
    673 if [ "$freq" = "yr" ] ; then cput=04:00:00 ; else cput=01:00:00 ; fi
     658if [ "$freq" = "yr" ]; then cput=04:00:00; else cput=01:00:00; fi
    674659
    675660#####################################################################
     
    678663sed -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
    679664
    680 if [ "$testmode" = "y" ] ; then
     665if [ "$testmode" = "y" ]; then
    681666  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
    682667fi
    683668
    684 if [ $climato = 0 ] ; then
     669if [ $climato = 0 ]; then
    685670# calend est choisi plus haut dans "Changements dans les fichiers DEF/*def" et ecrit dans $MAINDIR/DEF/run.def
    686671yrini=`echo $mthini | cut -c-4`
    687672yrend=`echo $mthend | cut -c-4`
    688 yrs="" ; yr=$yrini ; while [ $yr -le $yrend ] ; do yrs="$yrs $yr" ; (( yr = $yr + 1 )) ; done
     673yrs=""; yr=$yrini; while [ $yr -le $yrend ]; do yrs="$yrs $yr"; (( yr = $yr + 1 )); done
    689674suf=360x180_
    690675else
     
    698683#####################################################################
    699684
    700 if [ ! -d $LMDZ_Init ] ; then mkdir $LMDZ_Init ; fi
     685if [ ! -d $LMDZ_Init ]; then mkdir $LMDZ_Init; fi
    701686
    702687#-------------------------------------------------------------------
     
    707692liste_get+="routing.nc routing_simple.nc lai2D.nc soils_param.nc "
    708693liste_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
     694for file in $liste_get; do
     695  if [ ! -f $LMDZ_Init/$file ]; then cd $LMDZ_Init; ${get}$file; cd -; fi
    711696done
    712697# Additionnal files needed for ORCHIDEE trunk post-CMIP6
    713 if [ $veget = 7994 -a ! -f $LMDZ_Init/soil_bulk_and_ph.nc ] ; then
     698if [ $veget = 7994 -a ! -f $LMDZ_Init/soil_bulk_and_ph.nc ]; then
    714699  cd $LMDZ_Init
    715   ${get}soil_bulk_and_ph.nc ; ${get}NITROGEN_for_ORtrunk.tar
    716   tar -xvf NITROGEN_for_ORtrunk.tar ; cd -
     700  ${get}soil_bulk_and_ph.nc; ${get}NITROGEN_for_ORtrunk.tar
     701  tar -xvf NITROGEN_for_ORtrunk.tar; cd -
    717702fi
    718703#-------------------------------------------------------------------
    719704# Fichiers aerosols/chimie
    720705#-------------------------------------------------------------------
    721 if [ $aerosols = clim ] ; then
     706if [ $aerosols = clim ]; then
    722707  get="myget 3DInputData/AerChem/"
    723708  #liste_get="aerosols1850_from_inca.nc aerosols2000_from_inca.nc"
    724709  #aerosols9999_from_inca.nc est un lien vers aerosols1995_2014_ensavg_from_inca.nc
    725710  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
     711  for file in $liste_get; do
     712    if [ ! -f $LMDZ_Init/$file ]; then cd $LMDZ_Init; ${get}$file; cd -; fi
    728713  done
    729714fi
     
    736721# a regrider ensuite par un script interp_fichiers_spla.sh (comme pour aerosols="clim")
    737722# 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
     723if [ $aerosols = spla ]; then
     724  if [ ! -d ${LMDZ_Init}/SPLA_Init ]; then mkdir ${LMDZ_Init}/SPLA_Init; mkdir $LMDZ_Init/SPLA_Init/INITIAL; fi
    740725  get="cp -p /gpfsstore/rech/gzi/rgzi027/ergon/BIBIAERO/INPUTS_DUST/INITIAL/"
    741726  liste_get="wth.dat cly.dat donnees_lisa.nc SOILSPEC.data \
     
    743728               sulphur_emissions_nat.nc  sulphur_emissions_volc.nc"
    744729
    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
     730  for file in $liste_get; do
     731    if [ ! -f $LMDZ_Init/SPLA_Init/INITIAL/$file ]; then cd $LMDZ_Init/SPLA_Init/INITIAL; ${get}$file .; cd -; fi
    747732  done
    748733###
     
    754739  #ICI pour l'instant je copie les fichiers de chez Binta (repositoire==http...) dans LMDZ_Init/SPLA_Init, avec test sur mois 01
    755740
    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
     741  if [ ! -d ${LMDZ_Init}/SPLA_Init/PERIOD0001 ]; then cp -pr /gpfsstore/rech/gzi/rgzi027/ergon/BIBIAERO/INPUTS_DUST/PERIOD* $LMDZ_Init/SPLA_Init/.; fi
    757742
    758743 #A la fin on doit avoir dans SPLA_Init les fichiers initiaux dans INITIAL plus les repertoires PERIOD00MM contenant dust.nc
     
    767752get="myget 3DInputData/Init/"
    768753liste_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
     754for file in $liste_get; do
     755  if [ ! -f $LMDZ_Init/$file ]; then cd $LMDZ_Init; ${get}$file; cd -; fi
    771756done
    772757
     
    775760
    776761
    777 if [ $init = 1 ] ; then
     762if [ $init = 1 ]; then
    778763   #####################################################################
    779764      echo Creation de l etat initial
     
    782767   # Creation du repertoire INIT et mise en place de liens logiques vers les starts
    783768   # 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
     769   mkdir $local/$INIT; cd $local/$INIT
     770   for an in $mthini $yearini; do for f in start startphy; do ln -s $f.nc $f.$an.nc; done; done
    786771
    787772   # 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
     773   if [ -d $WRK/$INIT ]; then mv $WRK/$INIT $WRK/$INIT$$; fi
     774   mkdir $WRK/$INIT;  cp -r $local/DEF $WRK/$INIT/
     775   cd $WRK/$INIT; cp DEF/*.def .; cp $local/lmdz_env.sh .
     776   if [ $xios = y ]; then
    792777       cp DEF/XMLfilesLMDZ/*xml . 
    793        if [ $veget != 'NONE' ] ; then cp DEF/XMLfilesOR$veget/*xml . ; fi
     778       if [ $veget != 'NONE' ]; then cp DEF/XMLfilesOR$veget/*xml .; fi
    794779   fi
    795780   sed -e 's/anneeref=.*.$/anneeref='$yearini'/' DEF/run.def >| run.def
     
    800785   get="myget 3DInputData/Limit/"
    801786   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
     787   for yr in $yrs; do
     788       if [ $climato = 0 ]; then sufyr=$suf$yr; else sufyr=$suf; fi
    804789       liste_get="$liste_get  amipbc_sic_$sufyr.nc amipbc_sst_$sufyr.nc"
    805790   done
    806791   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
     792   for file in $liste_get; do
     793     if [ ! -f $LMDZ_Init/$file ]; then cd $LMDZ_Init; ${get}$file; cd -; fi
    809794     ln -s $LMDZ_Init/$file
    810795   done
     
    813798#-------------------------------------------------------------------
    814799   get="myget 3DInputData/Init/"
    815    if [ ! -f $LMDZ_Init/ECDYN.nc ] ; then cd $LMDZ_Init ; ${get}ECDYN.nc ; cd - ; fi
     800   if [ ! -f $LMDZ_Init/ECDYN.nc ]; then cd $LMDZ_Init; ${get}ECDYN.nc; cd -; fi
    816801   ln -s $LMDZ_Init/ECDYN.nc
    817802   ln -sf ECDYN.nc ECPHY.nc
     
    819804
    820805   # Creation du script d'initialisation
    821    cat <<...eod>| tmp
     806   cat << ...eod >| tmp
    822807#!/bin/bash
    823808
     
    832817#SBATCH --output=Init%j.out     # Nom du fichier de sortie
    833818#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
     819# To submit to dev queue; "time" (above) must be max 2h
    835820# #SBATCH --qos=qos_cpu-dev
    836821
     
    839824# ANCIEN MULTI STEP   init )
    840825
    841    if [ ! -f lmdz_env.sh ] ; then echo manque fichier lmdz_env.sh ; ls ; exit ; fi
     826   if [ ! -f lmdz_env.sh ]; then echo manque fichier lmdz_env.sh; ls; exit; fi
    842827   . lmdz_env.sh
    843828   ulimit -s unlimited
     
    846831   cd $WRK/$INIT
    847832   echo Executable : $ce0l
    848    for yr in $yrs ; do
    849       if [ $climato = 0 ] ; then sufyr=$suf\$yr ; else sufyr=$suf ; fi
     833   for yr in $yrs; do
     834      if [ $climato = 0 ]; then sufyr=$suf\$yr; else sufyr=$suf; fi
    850835      ln -sf amipbc_sic_\$sufyr.nc amipbc_sic_1x1.nc
    851836      ln -sf amipbc_sst_\$sufyr.nc amipbc_sst_1x1.nc
     
    853838      echo Starting initialisation
    854839      $run 1 $ce0l
    855       if [ $climato = 0 ] ; then mv limit.nc limit.\$yr.nc ; fi
     840      if [ $climato = 0 ]; then mv limit.nc limit.\$yr.nc; fi
    856841   done
    857 # ANCIEN MULTI STEP    ;;
     842# ANCIEN MULTI STEP   ;;
    858843
    859844# ANCIEN MULTI STEP   interp )
    860    if [ $aerosols = clim ] ; then
    861     cp $local/interp_aerosols.sh . ; chmod +x interp_aerosols.sh
     845   if [ $aerosols = clim ]; then
     846    cp $local/interp_aerosols.sh .; chmod +x interp_aerosols.sh
    862847    # 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
     848    #for year in 2000 1850; do  ./interp_aerosols.sh \$year; done
     849    #mv aerosols.2000.nc aerosols.clim.nc; mv aerosols.1850.nc aerosols.nat.nc
     850    for year in 9999 1850; do ./interp_aerosols.sh \$year; done
     851    mv aerosols.9999.nc aerosols.clim.nc; mv aerosols.1850.nc aerosols.nat.nc
    867852   fi
    868853
    869854   # AS : S'il etait possible d'automatiser l'interpolation de l'input SPLA, ce serait a lancer ici
    870855   #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
     856   #if [ $aerosols = spla ]; then
     857    #cp $local/futur script interp_aerosols_SPLA.sh .; chmod +x interp_aerosols_SPLA.sh
     858    #for file in...; do  ./interp_aerosols_SPLA.sh \$year; done
    874859    #etc etc etc ...
    875860   #fi
    876861
    877862# 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
     863   for f in sta* limit.nc gri*nc; do cp \$f $local/$INIT/\$f; done
    879864   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
     865   for f in limit*.nc ; do cp \$f $local/$LIMIT/\$f; done
     866   if [ $aerosols = clim ]; then  for f in aerosols[.0-9]*nc; do cp \$f $local/$LIMIT/\$f; done; fi
    882867   #
    883    if [ $aerosols = spla ] ; then
    884      #mkdir -p $local/INPUT_SPLA ; pour l'instant on copie $LMDZ_Init/SPLA_Init en block
    885      if [ ! -d $local/INPUT_SPLA ] ; then cp -pr $LMDZ_Init/SPLA_Init $local/INPUT_SPLA ; fi
     868   if [ $aerosols = spla ]; then
     869     #mkdir -p $local/INPUT_SPLA; pour l'instant on copie $LMDZ_Init/SPLA_Init en block
     870     if [ ! -d $local/INPUT_SPLA ]; then cp -pr $LMDZ_Init/SPLA_Init $local/INPUT_SPLA; fi
    886871   fi
    887872   cd $WRK
    888873...eod
    889    if [ $ok_guide != y ] ; then # Running first simulation automatically except for nudging
    890       cat <<...eod>> tmp
     874   if [ $ok_guide != y ]; then # Running first simulation automatically except for nudging
     875      cat << ...eod >> tmp
    891876         $submit tmp_$SIM
    892877...eod
    893878   fi
    894    cat <<...eod>> tmp
     879   cat << ...eod >> tmp
    895880# ANCIEN MULTI STEP   esac
    896881...eod
     
    914899
    915900
    916 if [ $ok_guide = y -a $init = 1 ] ; then
     901if [ $ok_guide = y -a $init = 1 ]; then
    917902   echo Once initialisation is finished, you have to create nudging files
    918903   echo Edit era2gcm.sh and set the desired parameters in section "User choices"
    919904   echo Make sure you have acces to the chosen ERA files, and the required modules are load
    920905   echo Then run : ./era2gcm.sh
    921    if [ "$aerosols" = "spla" ] ; then
     906   if [ "$aerosols" = "spla" ]; then
    922907     echo Your aerosol choice is "spla", so you need ERA 10m-winds interpolated on LMDZ grid
    923908     echo Use script era2gcm_uv10m.sh 
Note: See TracChangeset for help on using the changeset viewer.