Changeset 4940


Ignore:
Timestamp:
May 13, 2024, 10:12:59 AM (5 weeks ago)
Author:
abarral
Message:

(WIP)
move compile-relevant args to install_lmdz

Location:
BOL/LMDZ_Setup_amaury
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • BOL/LMDZ_Setup_amaury/main.sh

    r4935 r4940  
    4141# TODO move to expert-level settings
    4242version="20240308.trunk" #!! DON'T CHANGE IT WITHOUT CHECKING WITH LMDZ TEAM !!
    43 svn=""                   #!! DON'T CHANGE IT WITHOUT CHECKING WITH LMDZ TEAM !! 
    44         # CONTACT LMDZ Team : 
     43svn=""                   #!! DON'T CHANGE IT WITHOUT CHECKING WITH LMDZ TEAM !!
     44        # CONTACT LMDZ Team :
    4545        #       email: poihl@listes.lmd.ipsl.fr
    4646        #       Mattermost: https://mattermost.lmd.ipsl.fr/lmdz/channels/installation-et-tutoriels
     
    5454# Using XIOS for IOs: "-xios" for enabled, else ""
    5555xios=""
     56# TODO Amaury: je pensais que l'idée de main.sh c'était de mettre des paramètres qu'on peut changer en recompilant uniquement lmdz. Or ce n'est pas le cas d'XIOS...
    5657
    5758# Using or not the Cosp simulator: "-cosp" for enabled, else ""
  • BOL/LMDZ_Setup_amaury/setup.sh

    r4935 r4940  
    7474function load_install_lib {
    7575  # Fetch and source install_lmdz.sh
    76   if [[ ! -f "lib_install_lmdz.sh" ]]; then
     76  if [[ ! -f "install_lmdz.sh" ]]; then
    7777    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
    8078  fi
    81   source lib_install_lmdz.sh
     79  # shellcheck disable=SC1090
     80  source <(sed 's/function \(.*\) {/function installlmdz_\1 {/g' install_lmdz.sh)  # source with a namespace for functions
     81  function myget { installlmdz_myget "$@"; }
    8282}
    83 load_install_lib  # Do not move later, as it would overwrite some functions
    8483
    8584function set_default_params {
     
    149148  done
    150149
    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 
    154150  # Initialisation
    155151  if [[ $init = 1 || $init = 0 ]]; then
     
    162158  if [[ $freq = yr ]]; then stopsim=$(echo "$mthend" | cut -c-4); else stopsim=$mthend; fi
    163159
    164   if [[ $svn = "" ]]; then svnopt=""; else svnopt="-r $svn"; fi
    165 
    166160  if [[ -d $SIM ]]; then
    167161     echo "La simulation $SIM existe deja. Il est conseillé d'arrêter et de vérifier."
     
    170164     if [[ $ans != y ]]; then exit 1; fi
    171165  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
    176166}
    177167
    178168function ensure_correct_option_combinations {
    179169  # AVOID COMBINATIONS OF OPTIONS THAT DON'T WORK in user choices
    180 
    181170  if [[ $ok_guide = y && $climato = 1 ]]; then
    182171     echo "Running nudged simulations with climatological SSTs is not planned. Change <climato> to <0> or modify the setup (experts)"; exit 1
     
    187176     echo "Change <climato> to <1> or <freq> to <mo> or modify setup.sh (experts)"; exit 1
    188177  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
     178}
     179
     180function install_model {
     181  mkdir -p "$LMDZD"
     182
     183  version_name=LMDZ$(echo "$version" | sed -e 's/-v//g' -e 's/-unstable//' -e 's/-r/r/' -e 's/ //g')
     184  LMDZname="${version_name}${svn}OR$veget${ins_xios}"
     185  MODEL="$LMDZD/$LMDZname/modipsl/modeles/LMDZ"
     186
     187  if [[ $install = 1 ]]; then  # run install_lmdz to pull the required files and compile once
     188    if [[ -d $MODEL ]]; then
     189      echo "MODEL=$MODEL"
     190      echo "STOP: Vous essayez d'installer une version déja présente (option <-install>)"; exit 1
     191    else
     192      echo "Installing model"
     193      cd "$LMDZD"
     194      cp "$local/install_lmdz.sh" .
     195      chmod +x install_lmdz.sh
     196      # TODO handle arch/env here (used to be -env-file)
     197      echo "./install_lmdz.sh $fcm $optim -v $version $svnopt -d $resol -rad $rad -bench 0 -parallel mpi_omp $ins_cosp $ins_xios -name $LMDZname -veget $veget -netcdf 0 -arch $ARCH" >> install_lmdz_options.$$.sh
     198      chmod +x install_lmdz_options.$$.sh
     199      echo "Running install_lmdz_options.$$.sh"
     200      ./install_lmdz_options.$$.sh
     201      mv install_lmdz.sh install_lmdz.$$.sh
     202      cd -
     203     fi
     204  else
     205     if [[ ! -d $MODEL ]]; then
     206        echo "Le model $MODEL n'est pas installé. Vous pouvez relancez avec <-install>."; exit 1
     207     fi
    216208  fi
    217209}
    218210
    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
     211# Set up the appropriate environment
     212source lmdz_env.sh
    225213
    226214# TODO Amaury: commented-out for now
    227215## Pour les post-traitements
    228 #sed -i'' -e "s/groupe@cpu/$groupe@cpu/" seasonal.sh  # TODO Amaury: $groupe jamais défini, à virer ?
     216#sed -i'' -e "s/groupe@cpu/$groupe@cpu/" seasonal.sh
    229217local=$(pwd)
    230218
     219load_install_lib
    231220define_expert_options
    232221set_default_params
    233222read_cmdline_args "$@"
    234223ensure_correct_option_combinations
     224install_model
    235225
    236226exit 1
    237227
    238228
    239 
    240 
    241 
    242 
    243 
    244 ########################################################################
    245 # Recuperation ou compilation du GCM
    246 ########################################################################
    247 
    248 if [ ! -d $LMDZD ]; then mkdir -p $LMDZD; fi
    249 version_name=LMDZ`echo $version | sed -e 's/-v//g' -e 's/-unstable//' -e 's/-r/r/' -e 's/ //g'`
    250 LMDZname=${version_name}${svn}${optim}OR${veget}${ins_xios}
    251 MODEL=$LMDZD/$LMDZname/modipsl/modeles/LMDZ
    252 
    253 if [ $install = 1 ]; then
    254    if [ -d $MODEL ]; then
    255            echo $MODEL
    256       echo "Vous essayez d installer une version deja presente"
    257       exit
    258    else
    259       echo On installe le modele
    260       cd $LMDZD
    261       echo wget https://lmdz.lmd.jussieu.fr/pub/install_lmdz.sh
    262       \rm -f install_lmdz.sh
    263       wget --no-cache https://lmdz.lmd.jussieu.fr/pub/install_lmdz.sh
    264       # Si la ligne ci-dessus "wget https://lmdz.lmd..." ne marche pas pour "certificat expired", utiliser : 
    265       #wget https://web.lmd.jussieu.fr/~lmdz/pub/install_lmdz.sh
    266       chmod +x install_lmdz.sh
    267       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.$$
    268       ./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
    269       mv install_lmdz.sh install_lmdz.$$
    270       if grep "Not Found" $LMDZname/get.log >/dev/null; then echo "version=$version is NOT A TESTING VERSION, Ask LMDZ Team"; exit; fi
    271       cd $local
    272    fi
    273 else
    274    if [ ! -d $MODEL ]; then
    275       echo Le model $MODEL n est pas installe
    276       echo relancer avec install=1 si vous voulez l installer automatiquement
    277       exit
    278    fi
    279 fi
    280 
    281 # Determine svn revision number, which will determine compilation options, executable names etc
    282 # If svn not available, will use the svn writen in $MODEL/Readm*md
    283 # For old version it assumes that it is before 4185 (the version
    284 # for which the test was introduced
    285 mysvn=`svnversion $MODEL | egrep -o "[0-9]+" 2>/dev/null` 
    286 if [ "$mysvn" = "" ]; then mysvn=`grep 'Revision: [0-9]' $LMDZD/$LMDZname/Read*.md | awk ' { print $2 } ' 2>/dev/null`; fi
    287 if [ "$mysvn" = "" ]; then mysvn=4190; fi
    288 echo mysvn $mysvn
    289 
    290 # For mysvn >= 4532, "module load netcdf95" must be added in lmdz_env.sh for Jean-Zay if it's not there;
    291 # lmdz_env.sh must be sourced again, and copied again as $MODEL/arch/arch-X64_JEANZAY.env
    292 # (first copy is done by install_lmdz.sh launched with option "-env lmdz_env.sh" )
    293 if [ ${hostname:0:5} = "jean-" -a $mysvn -ge 4532 -a ! "`grep netcdf95 lmdz_env.sh`" ]; then
    294    cp -p lmdz_env.sh lmdz_env.orig
    295    sed -i'' -e 's/module load nco/module load netcdf95\n                module load nco/' lmdz_env.sh
    296    cp -p lmdz_env.sh $MODEL/arch/arch-X64_JEANZAY.env
    297    . lmdz_env.sh
    298 fi
     229# TODO check w/ Adriana the exact reasons why we recompile the model (or even compile it using install_lmdz in the first place)
    299230
    300231# COMPILATION OPTIONS depending on the user choices and LMDZ revision number $mysvn
    301232#-------------------------------------------------------
    302 if [ "$ARCH" = "" ]; then arch=; else arch="-arch $ARCH"; fi
    303 
    304 if [ $cosp = y ]; then opt_cosp="-cosp true"; else opt_cosp=""; fi
    305    # makelmdz* uses "opt_cosp", and for v1 (default) needs "-cosp true/false" 
    306    # When cosp v2 will be validated, we'll have opt_cosp=ins_cosp="-cosp v2"
    307    # (option cosp2 in makelmdz* to be ignored; it is a transitory version from v1 to v2)
    308 
    309 if [ $xios = y ]; then opt_xios="-io xios"; else opt_xios=""; fi
    310 
    311 case $rad in
    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
    316 esac
     233arch="-arch $ARCH"
    317234if [ "$rad" = "ecrad" -a ! -d ecrad_data ]; then
    318235    cd $local; wget https://lmdz.lmd.jussieu.fr/pub/3DInputData/ecrad/ecrad_data.tar; tar xvf ecrad_data.tar; cd -
    319236fi
    320 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
    321 
    322 
    323 # Aerosols : also define the associated suffix in gcm name
    324 if [ $aerosols = spla ]; then
    325   opt_aer=' -dust true ';  sufaer='_spla'
    326 else
    327   opt_aer=""            ;  sufaer=''
    328 fi
    329 
    330 if [ $inlandsis = y ]; then
    331    opt_inlandsis="-inlandsis true"
    332 else
    333    opt_inlandsis=""
    334 fi
    335 
    336 # Isotopes : also define the associated suffix in gcm name
    337 if [ $isotopes = y ]; then
    338   opt_isotopes="-isotopes true"; sufiso="_iso"
    339 else
    340   opt_isotopes=""              ; sufiso=""
    341 fi
     237
     238if [ "$rad" = "ecrad" -a "$aerosols" != "n" -a "$mysvn" -lt 4489 ] ; then echo "Les aerosols tropospheriques ne sont pas pris en charge par ecrad avant LMDZ rev 4489, ici rev est $mysvn"; exit 1; fi
    342239
    343240# Source the surface_env file created by install_lmdz.sh, to get the "veget"-related variables
     
    380277compile_opt="$optim -p $phylmd $opt_cosp $opt_xios $opt_rad $arch -d $resol $opt_veget $opt_aer $opt_inlandsis -mem -parallel mpi_omp"
    381278
    382 if [ $mysvn -le 4185 ]; then suffix=_${resol}_phy${phylmd}_para_mem${suforch}${sufaer};
    383                          else suffix=_${resol}_phy${phylmd}_${rad}_para_mem${suforch}${sufaer}; fi
    384279
    385280# use an intermediate variable to use either suffix or suffix_iso
     
    395290   sleep 10
    396291
    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"
    400    else
    401       # makelmdz_fcm directly produces executable named $gcm, depending on the compilation options
    402        compile="./makelmdz_fcm $compile_opt -j 2 \$1"
    403        compile_iso="./makelmdz_fcm $compile_opt_iso -j 2 \$1"
    404    fi
     292   compile="./makelmdz_fcm $compile_opt -j 2 \$1"
     293   compile_iso="./makelmdz_fcm $compile_opt_iso -j 2 \$1"
    405294
    406295   #NB on est dans $local, qui est $STORE/$MAINDIR
     
    436325   cd $local
    437326fi
     327
     328# TODO ^ qu'est-ce qui nous empêche de mettre tout ça directement dans install_lmdz ????
     329# TODO Ce qu'il faudrait faire:
     330# TODO 1) bien expliquer ce que fait l'option install (lancer install_lmdz une unique fois pour lancer tout sauf la compil LMDZ => maintenant ça ne fonctionne plus car on installe tjrs lmdz, mais en fait c'est pas grave car derrière on vérifie si le gcm.e existe ou non)
     331# TODO 2) importer les fonctions de install_lmdz nécessaires pour "recompiler" lmdz "à la carte" (ou bien juste modifier compile.sh ??)
    438332
    439333
Note: See TracChangeset for help on using the changeset viewer.