Index: /BOL/script_install_amaury/install_lmdz.sh
===================================================================
--- /BOL/script_install_amaury/install_lmdz.sh	(revision 4938)
+++ /BOL/script_install_amaury/install_lmdz.sh	(revision 4939)
@@ -58,5 +58,6 @@
     veget="none"
     grid_resolution="32x32x39"
-    physiq=""
+    benchphysiq=""
+    compphysiq="lmd"
 
     parallel="none"
@@ -84,5 +85,5 @@
 
     local mpi_file
-    mpi_file=$(readlink -f "$(which mpif90)")
+    mpi_file=$(readlink -e -f "$(which mpif90)")
     path_mpi=$(dirname "$mpi_file")
     root_mpi=$(dirname "$path_mpi")
@@ -128,7 +129,13 @@
         -debug      compile everything in debug mode
 
-        -physiq     to choose which physics package to use in the bench (default <$physiq>)
+        -benchphysiq   to choose which physics.def package to use in the bench (default <$benchphysiq>)
+
+        -compilephysiq   physics to compile the model with (default <$compphysiq>)
 
         -veget      surface/vegetation scheme treatment controlled by the single variable veget which can have the following values: none: bucket scheme (default); CMIP6 | veget2.0: orchidee version used in CMIP exercise, rev 5661; veget2.2: orchidee branch 2.2, rev 8529 (bundled); number: orchidee version number (default $veget)
+
+        -spla       activate interactive aerosols
+
+        -inlandsis  activate new snow scheme
 
         -arch       name of the arch to use (default <$arch>)
@@ -165,13 +172,19 @@
             "-name") MODEL=$2; shift; shift;;
             "-netcdf") netcdf=$2; shift; shift;;
-            "-physiq") physiq=$2; shift; shift;;
+            "-benchphysiq") benchphysiq=$2; shift; shift;;
+            "-compilephysiq") compphysiq=$2; shift; shift;;
             "-xios") with_xios=1; shift;;
             "-arch") arch=$2; shift; shift;;
             "-arch_dir") arch_dir=$2; shift; shift;;
             "-veget") veget=$2; shift; shift;;
+            "-spla") aerosols=1; shift;;
+            "-inlandsis") inlandsis=1; shift;;
             "-make_j") make_j=$2; shift; shift;;
             *)  bash install_lmdz.sh -h; exit 1
         esac
     done
+
+    # Isotopes : Compile and run with isotopes if lmdz_phys="lmdiso" in main.sh
+    if [[ $compphysiq = "lmdiso" ]]; then isotopes=1; else isotopes=0; fi
 
     # Option de compilation pour Cosp
@@ -182,4 +195,48 @@
     esac
 
+    #Define veget-related suffix for gcm name
+    if [[ $veget = 'none' ]]; then
+        suff_orc=''
+    else
+        suff_orc='_orch'
+    fi
+
+
+    if [[ $parallel = "none" ]]; then
+        suff_para='_seq'
+    else
+        suff_para='_para_mem'
+    fi
+
+    if [[ $with_xios = 1 ]]; then opt_makelmdz_xios="-io xios"; fi
+
+    if [[ $aerosols = 1 ]]; then
+      opt_aer="-dust true"; suff_aer="_spla"
+    else
+      opt_aer=""; suff_aer=""
+    fi
+
+    if [[ $inlandsis = 1 ]]; then
+       opt_inlandsis="-inlandsis true"
+    else
+       opt_inlandsis=""
+    fi
+
+    if [[ $isotopes = 1 ]]; then
+      opt_isotopes="-isotopes true"; suff_iso="_iso"
+    else
+      opt_isotopes="" ; suff_iso=""
+    fi
+
+
+    # Name of the model's folder. The convention taken here is that models that requires different compilation sources should have a different names.
+    local xios_name=""
+    if [[ $with_xios = 1 ]]; then xios_name="XIOS"; fi
+    if [[ $MODEL = "" ]]; then MODEL="./LMDZ$version${svn_lmdz}OR$veget$xios_name"; fi
+
+    if [[ $arch_dir = "" ]]; then arch_dir="$MODEL/modipsl/config/IPSLCM7/ARCH/"; fi
+}
+
+function ensure_correct_option_combinations {
     # Check on veget version
     if [[ $veget != 'none' && $veget != "CMIP6" && $veget != "orch2.0" && $veget != "orch2.2" ]]; then
@@ -190,21 +247,4 @@
     fi
 
-    #Define veget-related suffix for gcm name
-    if [[ $veget = 'none' ]]; then
-        suff_orc=''
-    else
-        suff_orc='_orch'
-    fi
-
-
-    if [[ $parallel = "none" ]]; then
-        suff_exe='_seq'
-    else
-        suff_exe='_para_mem'
-    fi
-
-    #Chemin pour placer le modele
-    if [[ $MODEL = "" ]]; then MODEL="./LMDZ$version$svn_lmdz$optim_debug"; fi
-
     ## if also compiling XIOS, parallel must be mpi_omp
     if [[ $with_xios = 1 && $parallel != "mpi_omp" ]]; then
@@ -212,16 +252,35 @@
     fi
 
-    if [[ $with_xios = 1 ]]; then
-        opt_makelmdz_xios="-io xios"
-    fi
-
     if [[ $cosp = "v2" && $with_xios = 0 ]]; then
         echo "Error, Cospv2 cannot run without Xios"; exit 1
     fi
 
-    if [[ $arch_dir = "" ]]; then
-        arch_dir="$MODEL/modipsl/config/IPSLCM7/ARCH/"
-    fi
-    arch_dir=$(readlink -f "$arch_dir")  # full path
+    # STOP if trying to use both ORCHIDEE and Isotopes :
+    if [[ $isotopes = 1 && $veget != "NONE" ]]; then
+      echo "STOP: You cannot run LMDZ with ORCHIDEE and ISOtopes at the same time"; exit 1
+    fi
+
+    # STOP if trying to use both SPLA and Isotopes :
+    if [[ $isotopes = 1 && $aerosols = 1 ]]; then
+      echo "STOP: You cannot run LMDZ with Isotopes and aerosols=spla at the same time"; exit 1
+    fi
+
+    # (Temporary) STOP if trying to use Isotopes with XIOS :
+    # TODO Amaury: check if still relevant
+    if [[ $isotopes = 1 && $with_xios = 1 ]]; then
+      echo "STOP: Isotopes cannont yet be run with XIOS"; exit 1
+    fi
+
+    # (Temporary) Constraints for aerosols=spla :
+    # --> resolution 128x88x79 and rad=rrtm
+    if [[ $aerosols = 1 && $grid_resolution != "128x88x79" ]]; then
+      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'
+      echo "Right now resol=<$grid_resolution>"
+      exit 1
+    fi
+
+    if [[ $aerosols = 1 && $rad != "rrtm" ]]; then
+      echo "STOP: For the time being, <aerosols=spla> requires <rad=rrtm>"; exit 1
+    fi
 }
 
@@ -250,5 +309,5 @@
 function download_model {
     mkdir -p "$MODEL"
-    MODEL=$(readlink -f "$MODEL"); echo "$MODEL"  # absolute path
+    MODEL=$(readlink -e -f "$MODEL"); echo "$MODEL"  # absolute path
 
     rm -rf "$MODEL/modipsl"
@@ -292,8 +351,9 @@
         mv MODEL_REF "$MODEL"
     fi
-    MODEL=$(readlink -f "$MODEL"); echo "$MODEL"  # absolute path
+    MODEL=$(readlink -e -f "$MODEL"); echo "$MODEL"  # absolute path
 }
 
 function init_arch {
+    arch_dir=$(readlink -e -f "$arch_dir")  # full path. readlink must be called *after* the path is created
     if [[ ! -d $arch_dir ]]; then
         echo "Error: no arch dir $arch_dir"; exit 1
@@ -559,5 +619,5 @@
 
 function get_lmdz_version {
-    LMDZPATH=$(readlink -f "$MODEL/modipsl/modeles/LMD"*)
+    LMDZPATH=$(readlink -e -f "$MODEL/modipsl/modeles/LMD"*)
     cd "$LMDZPATH"
     lmdzlog="$(pwd)/lmdz.log"
@@ -587,5 +647,9 @@
     cd "$LMDZPATH"
 
-    exe_name="bin/gcm_${grid_resolution}_phylmd_${rad}${suff_exe}${suff_orc}.e"
+    if [[ $used_lmdz_rev -le 4185 ]]; then
+        exe_name="bin/gcm_${grid_resolution}_phy${compphysiq}_${suff_para}${suff_orc}${suff_aer}${suff_iso}.e"
+    else
+        exe_name="bin/gcm_${grid_resolution}_phy${compphysiq}_${rad}${suff_para}${suff_orc}${suff_aer}${suff_iso}.e"
+    fi
 
     local opt_rad
@@ -608,9 +672,6 @@
     local varenv="IOIPSL_LIBDIR_=\"$IOIPSL_LIBDIR_\" IOIPSL_INCDIR_=\"$IOIPSL_INCDIR_\" ORCH_INCDIR_=\"$ORCH_INCDIR_\" ORCH_LIBDIR_=\"$ORCH_LIBDIR_\" XIOS_INCDIR_=\"$XIOS_INCDIR_\" XIOS_LIBDIR_=\"$XIOS_LIBDIR_\""
     makelmdz="makelmdz_fcm $optim_debug -arch $arch -j $make_j"
-    if [[ $parallel = "none" ]]; then
-        echo "$varenv ./$makelmdz $opt_rad $opt_cosp -d ${grid_resolution} -v $fcm_veget_version gcm " > compile.sh
-    else
-        echo "$varenv ./$makelmdz $opt_rad $opt_cosp $opt_makelmdz_xios -d ${grid_resolution} -v $fcm_veget_version -mem -parallel $parallel gcm" > compile.sh
-    fi
+    local para_compile_opt="-mem -parallel $parallel"; if [[ $parallel = "none" ]]; then para_compile_opt=""; fi
+    echo "$varenv ./$makelmdz $opt_rad $opt_cosp $opt_makelmdz_xios $opt_aer $opt_inlandsis $opt_isotopes -p $compphysiq -d ${grid_resolution} -v $fcm_veget_version $para_compile_opt gcm" > compile.sh
     echo "Compiling lmdz using $(\cat compile.sh) (log: $lmdzlog) $(date)"
     chmod +x ./compile.sh
@@ -621,5 +682,4 @@
 
     # Check executable
-    # TODO $mysev -ge 4186 => other name convention ! check original install
     if [[ ! -f $exe_name ]]; then
         echo "Compilation failed, can't find the executable"; exit 1
@@ -652,9 +712,9 @@
         fi
 
-        if [[ -n "$physiq" ]]; then
+        if [[ -n "$benchphysiq" ]]; then
             cd "BENCH${grid_resolution}"
-            if [[ -f "physiq.def_${physiq}" ]]; then
-                cp "physiq.def_${physiq}" physiq.def
-                echo "using physiq.def_${physiq}"
+            if [[ -f "physiq.def_${benchphysiq}" ]]; then
+                cp "physiq.def_${benchphysiq}" benchphysiq.def
+                echo "using physiq.def_${benchphysiq}"
             else
                 echo "using standard physiq.def"
@@ -849,4 +909,5 @@
 set_default_params
 read_cmdline_args "$@"
+ensure_correct_option_combinations
 #download_model
 create_model_tar
