Index: BOL/script_install_amaury/install_lmdz.sh
===================================================================
--- BOL/script_install_amaury/install_lmdz.sh	(revision 4852)
+++ BOL/script_install_amaury/install_lmdz.sh	(revision 4861)
@@ -75,5 +75,5 @@
 #          or 0: do not install NetCDF and look for it in standard locations;
 #          or absolute path: look for NetCDF there
-check_linux=1
+check_software_linux=1
 ioipsl=1
 bench=1
@@ -294,7 +294,4 @@
 arch=local
 
-
-if [[ $compiler = g95 ]]; then echo g95 is not supported anymore; exit 1; fi
-
 ################################################################
 # Specificite des machines
@@ -312,11 +309,9 @@
              module purge
              module load intel-compilers/19.0.4;
-             #module load intel-mpi/19.0.4;
-             #module load intel-mkl/19.0.4;
              module load hdf5/1.10.5-mpi;
              module load netcdf/4.7.2-mpi;
              module load netcdf-fortran/4.5.2-mpi;
              module load subversion/1.9.7;
-	     module load cmake
+	           module load cmake
              export NETCDF_LIBDIR=./
              export NETCDFFORTRAN_INCDIR=./
@@ -389,51 +384,22 @@
 fi
 
-#####################################################################
-# Test for old gfortran compilers
-# If the compiler is too old (older than 4.3.x) we test if the
-# temporary gfortran44 patch is available on the computer in which
-# case the compiler is changed from gfortran to gfortran44
-# Must be aware than parallelism can not be activated in this case
-#####################################################################
-
-if [[ "$compiler" = "gfortran" ]]; then
-    gfortran=gfortran
-    gfortranv=$(gfortran --version | \
-   head -1 | awk ' { print $NF } ' | awk -F. ' { print $1 * 10 + $2 } ')
-    if [[ $gfortranv -le 43 ]]; then
-        \cat <<EOF
-ERROR : Your gfortran compiler is too old
-Please choose a new one (ifort) and change the line
-compiler=xxx
-in the install_lmdz.sh script and rerun it
-EOF
-        if [[ $(which gfortran44 | wc -w) -ne 0 ]]; then
-            gfortran=gfortran44
-        else
-            echo gfotran trop vieux; exit 1
-        fi
-    fi
-    compiler=$gfortran
-fi
-#####################################################################
-
 ## if also compiling XIOS, parallel must be mpi_omp
-if [[ "$with_xios" = "y" && "$parallel" != "mpi_omp" ]]; then
+if [[ $with_xios = "y" && $parallel != "mpi_omp" ]]; then
     echo "Error, you must set -parallel mpi_omp if you want XIOS"
     exit 1
 fi
 
-if [[ "$with_xios" = "y" ]]; then
+if [[ $with_xios = "y" ]]; then
     opt_makelmdz_xios="-io xios"
 fi
 
-if [[ "$cosp" = "v2" && "$with_xios" = "n" ]]; then
+if [[ $cosp = "v2" && $with_xios = "n" ]]; then
     echo "Error, Cospv2 cannot run without Xios"
     exit 1
 fi
 
-echo '################################################################'
-echo  Choix des options de compilation
-echo '################################################################'
+echo "################################################################"
+echo  "Choix des options de compilation"
+echo "################################################################"
 
 export FC=$compiler
@@ -445,15 +411,15 @@
 OPTPREC="$OPT_GPROF"
 ARFLAGS="rs"
-if [[ "$(lsb_release -i -s)" = "Ubuntu" ]]; then
-    if [[ "$(lsb_release -r -s | cut -d. -f1)" -ge 16 ]]; then
-            ARFLAGS="rU"
-    fi
-fi
-
-if [[ "$compiler" = "$gfortran" ]]; then
+if [[ $(lsb_release -i -s) = "Ubuntu" ]]; then
+    if [[ $(lsb_release -r -s | cut -d. -f1) -ge 16 ]]; then
+        ARFLAGS="rU"
+    fi
+fi
+
+if [[ $compiler = "gfortran" ]]; then
    OPTIM="-O3 $allow_arg_mismatch"
    OPTDEB="-g3 -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow -O0 -fstack-protector-all -fbacktrace -finit-real=snan  $allow_arg_mismatch"
    OPTDEV="-Wall -fbounds-check  $allow_arg_mismatch"
-   fmod='I '
+   fmod="I "
    OPTPREC="$OPTPREC -cpp -ffree-line-length-0"
    if [[ $real = r8 ]]; then OPTPREC="$OPTPREC -fdefault-real-8 -DNC_DOUBLE"; fi
@@ -465,9 +431,9 @@
 
 elif [[ $compiler = mpif90 ]]; then
-    OPTIM='-O3'
+    OPTIM="-O3"
     OPTDEB="-g3 -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow -O0 -fstack-protector-all"
     OPTDEV="-Wall -fbounds-check"
     BASE_LD="$BASE_LD -lblas"
-    fmod='I '
+    fmod="I "
     if [[ $real = r8 ]]; then
         OPTPREC="$OPTPREC -fdefault-real-8 -DNC_DOUBLE -fcray-pointer"
@@ -479,8 +445,8 @@
 
 elif [[ $compiler = pgf90 ]]; then
-    OPTIM='-O2 -Mipa -Munroll -Mnoframe -Mautoinline -Mcache_align'
-    OPTDEB='-g -Mdclchk -Mbounds -Mchkfpstk -Mchkptr -Minform=inform -Mstandard -Ktrap=fp -traceback'
-    OPTDEV='-g -Mbounds -Ktrap=fp -traceback'
-    fmod='module '
+    OPTIM="-O2 -Mipa -Munroll -Mnoframe -Mautoinline -Mcache_align"
+    OPTDEB="-g -Mdclchk -Mbounds -Mchkfpstk -Mchkptr -Minform=inform -Mstandard -Ktrap=fp -traceback"
+    OPTDEV="-g -Mbounds -Ktrap=fp -traceback"
+    fmod="module "
     if [[ $real = r8 ]]; then OPTPREC="$OPTPREC -r8 -DNC_DOUBLE"; fi
     export CPPFLAGS="-DpgiFortran"
@@ -520,7 +486,7 @@
 # If installing on known machines such as Jean-Zay at IDRIS,
 # don't check for available software and don't install netcdf
-if [[ ${hostname:0:5} = jean- ]]; then
+if [[ ${hostname:0:5} = "jean-" ]]; then
     netcdf=0 # no need to recompile netcdf, alreday available
-    check_linux=0
+    check_software_linux=0
     pclinux=0
     ioipsl=0 # no need to recompile ioipsl, already available
@@ -540,20 +506,8 @@
 
 
-if [[ "$check_linux" = 1 ]]; then
+if [[ $check_software_linux = 1 ]]; then
     echo "################################################################"
     echo "Check if required software is available"
     echo "################################################################"
-
-    #### Ehouarn: test if the required shell is available
-    #### Maj FH-LF-AS 2021-04 : default=bash; if bash missing, use ksh
-    use_shell="bash" # default
-    if [[ $(which bash) = "" ]]; then
-        echo "no bash; we will use ksh"
-        use_shell="ksh"
-        if [[ $(which ksh) = "" ]]; then
-            echo "bash (or ksh) needed!! Install it!"
-            exit 1
-        fi
-    fi
 
     for logiciel in wget tar gzip make $compiler gcc cmake m4 c++; do
@@ -564,16 +518,14 @@
     done
 
-    if [[ $pclinux = 1 ]]; then
-        cd "$MODEL"
-        cat <<eod > tt.f90
+    cd "$MODEL"
+    cat <<eod > tt.f90
 print*,'coucou'
 end
 eod
-        $compiler tt.f90 || a.out
-        ./a.out >| tt
-        if [[ $(< tt sed -e 's/ //g' ) != "coucou" ]]; then
-            echo "problem installing with compiler $compiler"; exit 1; fi
-        \rm tt a.out tt.f90
-    fi
+    $compiler tt.f90 || a.out
+    ./a.out >| tt
+    if [[ $(< tt sed -e 's/ //g' ) != "coucou" ]]; then
+        echo "problem installing with compiler $compiler"; exit 1; fi
+    \rm tt a.out tt.f90
 fi
 
@@ -595,5 +547,5 @@
 
 ###########################################################################
-echo Installing Netcdf
+echo "Installing Netcdf"
 ###########################################################################
 
@@ -687,9 +639,9 @@
         cp AA_make.gdef AA_make.orig
         F_C="$compiler -c "
-        if [[ $compiler = "$gfortran" || $compiler = "mpif90" ]]
+        if [[ $compiler = "gfortran" || $compiler = "mpif90" ]]
         then
             F_C="$compiler -c -cpp "
         fi
-        if [[ "$compiler" = "pgf90" ]]; then F_C="$compiler -c -Mpreprocess"; fi
+        if [[ $compiler = "pgf90" ]]; then F_C="$compiler -c -Mpreprocess"; fi
         sed -e 's/^\#.*.g95.*.\#.*.$/\#/' AA_make.gdef > tmp
         sed -e "s:F_L = g95:F_L = $compiler:" \
@@ -709,20 +661,10 @@
         fi
 
-
         # We use lines for g95 even for the other compilers to run ins_make
-        if [[ "$use_shell" = "ksh" ]]; then
-            ./ins_make "$o_ins_make"
-        else # bash
-            sed -e s:/bin/ksh:/bin/bash:g ins_make > ins_make.bash
-            if [[ $(grep jeanzay AA_make.gdef) = "" ]]; then
-                # Bidouille pour compiler sur ada des vieux modipsl.tar
-                echo 'Warning jean-zay not in AA_make.gdef'
-                echo 'Think about updating'
-                exit 1
-            fi
-
-            chmod u=rwx ins_make.bash
-            ./ins_make.bash "$o_ins_make"
-        fi # of if [[ "$use_shell" = "ksh" ]]
+        sed -e s:/bin/ksh:/bin/bash:g ins_make > ins_make.bash  # Note Amaury: the case where the default shell isn't bash should be handled directly in ins_make (via ./ and #! directives)
+
+        chmod u=rwx ins_make.bash
+        # shellcheck disable=SC2086
+        ./ins_make.bash $o_ins_make
 
         echo "install_lmdz.sh MODIPSL_OK $(date)"
@@ -735,13 +677,11 @@
         echo "log file : $ioipsllog   $(date)"
 
-        if [[ "$use_shell" = "bash" ]]; then
-            cp Makefile Makefile.ksh
-            sed -e s:/bin/ksh:/bin/bash:g Makefile.ksh > Makefile
-        fi
-        ### if [[ "$pclinux" = 1 ]]; then
+        cp Makefile Makefile.ksh
+        sed -e s:/bin/ksh:/bin/bash:g Makefile.ksh > Makefile
+
         # Build IOIPSL modules and library
         $make clean
         $make > "$ioipsllog" 2>&1
-        if [[ $compiler = "$gfortran" || $compiler = "mpif90" ]]; then
+        if [[ $compiler = "gfortran" || $compiler = "mpif90" ]]; then
             # copy module files to lib
             cp -f -- *.mod ../../../lib
@@ -752,22 +692,19 @@
         if [[ -f $MODEL/modipsl/modeles/IOIPSL/tools/rebuild ]]; then 
             rebuild_dir=$MODEL/modipsl/modeles/IOIPSL/tools
-	elif [[ -d $MODEL/modipsl/modeles/IOIPSL/rebuild ]]; then
-              rebuild_dir=$MODEL/modipsl/modeles/IOIPSL/rebuild
+	      elif [[ -d $MODEL/modipsl/modeles/IOIPSL/rebuild ]]; then
+            rebuild_dir=$MODEL/modipsl/modeles/IOIPSL/rebuild
         fi
         if [[ $rebuild_dir != "" ]]; then
-	    cd "$rebuild_dir"
+	          cd "$rebuild_dir"
             # adapt Makefile & rebuild script if in bash
-            if [[ "$use_shell" = "bash" ]]; then
-                cp Makefile Makefile.ksh
-                sed -e s:/bin/ksh:/bin/bash:g Makefile.ksh > Makefile
-                cp rebuild rebuild.ksh
-                sed -e 's:/bin/ksh:/bin/bash:g' \
-                    -e 's:print -u2:echo:g' \
-                    -e 's:print:echo:g' rebuild.ksh > rebuild
-            fi
+            cp Makefile Makefile.ksh
+            sed -e s:/bin/ksh:/bin/bash:g Makefile.ksh > Makefile
+            cp rebuild rebuild.ksh
+            sed -e 's:/bin/ksh:/bin/bash:g' \
+                -e 's:print -u2:echo:g' \
+                -e 's:print:echo:g' rebuild.ksh > rebuild
             $make clean
             $make > "$ioipsllog" 2>&1
         fi
-        ### fi # of if [[ "$pclinux" = 1 ]] which is commented out
 
     else # of if [[ $ioipsl = 1 ]]
@@ -817,10 +754,8 @@
 
     if [[ ${hostname:0:5} = jean- ]]; then
-	if [[ $mysvn -ge 4619 ]]; then 
-          svn co http://forge.ipsl.jussieu.fr/ioserver/svn/XIOS2/branches/xios-2.6 \
-            XIOS
-	else
-          svn co http://forge.ipsl.jussieu.fr/ioserver/svn/XIOS2/branches/xios-2.5 \
-            XIOS
+        if [[ $mysvn -ge 4619 ]]; then
+            svn co http://forge.ipsl.jussieu.fr/ioserver/svn/XIOS2/branches/xios-2.6 XIOS
+        else
+            svn co http://forge.ipsl.jussieu.fr/ioserver/svn/XIOS2/branches/xios-2.5 XIOS
         fi
         cd XIOS/arch
@@ -944,5 +879,5 @@
             cd "$src_d"; \rm -f -- *.mod make; $make clean
             $make > "$orchideelog" 2>&1
-            if [[ "$compiler" = "$gfortran" || "$compiler" = "mpif90" ]]; then
+            if [[ "$compiler" = "gfortran" || "$compiler" = "mpif90" ]]; then
                 cp -f -- *.mod ../../../lib
             fi
@@ -956,5 +891,5 @@
 #============================================================================
 # Ehouarn: the directory name LMDZ* depends on version/tar file...
-if [[ -d $MODEL/modipsl/modeles/LMD* ]]; then
+if find . -name "$MODEL/modipsl/modeles/LMD*"; then
     echo '###############################################################'
     echo 'Preparing LMDZ compilation : arch file, svn switch if needed...'
@@ -967,4 +902,5 @@
 fi
 
+
 ###########################################################
 # For those who want to use fcm to compile via :
@@ -1014,5 +950,5 @@
       cat <<EOF > arch-local.path
 NETCDF_LIBDIR="-L$ncdfdir/lib"
-NETCDF_LIB="-lnetcdff -lnetcdf\"
+NETCDF_LIB="-lnetcdff -lnetcdf"
 NETCDF_INCDIR=-I$ncdfdir/include
 NETCDF95_INCDIR=-I\$LMDGCM/../../include
