Index: /BOL/script_install/install_lmdz.sh
===================================================================
--- /BOL/script_install/install_lmdz.sh	(revision 4080)
+++ /BOL/script_install/install_lmdz.sh	(revision 4081)
@@ -35,5 +35,4 @@
 
 echo install_lmdz.sh DEBUT `date`
-
 set -e
 
@@ -42,5 +41,7 @@
 ################################################################
 
+################################################################
 # A function to fetch files either locally or on the internet
+################################################################
 function myget { #1st and only argument should be file name
   # Path on local computer where to look for the datafile
@@ -51,5 +52,8 @@
   else
     wget -nv http://www.lmd.jussieu.fr/~lmdz/pub/$1
-    #dir=~/LMDZ/pub/`dirname $1` ; mkdir -p $dir ; cp -r `basename $1` $dir
+    save_pub_locally=0
+    if [ $save_pub_locally = 1 ] ; then # saving wget files on ~/LMDZ/pub
+       dir=~/LMDZ/pub/`dirname $1` ; mkdir -p $dir ; cp -r `basename $1` $dir
+    fi
   fi
 }
@@ -64,5 +68,6 @@
 svn=""
 #version=trunk
-version=20211102.trunk
+version=20220131.trunk
+
 getlmdzor=1
 netcdf=1   #  1 for automatic installation
@@ -223,20 +228,18 @@
 done
 
-#Option de compilation en fonction du code radiatif (-rad rrtm/ecrad)
-if [ $rad = rrtm ] ; then
-   opt_rad="-rad rrtm"
-elif [ $rad = ecrad ] ; then
-   opt_rad="-rad ecrad"
-else
-   opt_rad=""
-fi
-
-if [ $cosp = v1 ] ; then
-    opt_cosp="-cosp true"
-elif [ $cosp = v2 ] ; then
-    opt_cosp="-cospv2 true"
-else
-    opt_cosp=""
-fi
+# Option de compilation du rayonnement
+opt_rad=""
+case $rad in
+   rrtm) opt_rad="-rad rrtm" ;;
+   ecrad) opt_rad="-rad ecrad" ;;
+esac
+
+
+# Option de compilation pour Cosp
+opt_cosp=""
+case cosp in
+   v1) opt_cosp="-cosp true" ;;
+   v2) opt_cosp="-cospv2 true" ;;
+esac
   
 # Check on veget version
@@ -543,177 +546,177 @@
 
 ###########################################################################
-if [ $getlmdzor = 1 ] ; then
-echo '##########################################################'
-echo  Download a slightly modified version of  LMDZ
-echo '##########################################################'
-cd $MODEL
-myget src/modipsl_orc_cmip6.$version.tar.gz
-echo install_lmdz.sh wget_OK `date`
-gunzip modipsl_orc_cmip6.$version.tar.gz
-tar xvf modipsl_orc_cmip6.$version.tar
-\rm modipsl_orc_cmip6.$version.tar
-fi
-
-if [ $netcdf = 1 ] ; then
-cd $MODEL
-netcdflog=`pwd`/netcdf.log
-echo '##########################################################'
-echo Compiling the Netcdf library
-echo '##########################################################'
-echo log file : $netcdflog
-if [ "$with_xios" = "n" ] ; then
-  # keep it simple
-  #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/netcdf-4.0.1.tar.gz
-  myget import/netcdf-4.0.1.tar.gz
-  gunzip netcdf-4.0.1.tar.gz
-  tar xvf netcdf-4.0.1.tar
-  \rm -f netcdf-4.0.1.tar
-
-  cd netcdf-4.0.1
-
-  localdir=`pwd -P`
-  ./configure --prefix=$localdir --enable-shared --disable-cxx
-  #sed -e 's/gfortran/'$gfortran'/g' Makefile >| tmp ; mv -f tmp Makefile
-  $make check > $netcdflog 2>&1
-  $make install >> $netcdflog 2>&1
-#LF rajout d'une verrue, pour une raison non encore expliquee, la librairie est parfois rangée dans lib64
-#   et non dans lib par certains compilateurs
-  if [ ! -e lib -a -d lib64 ] ; then ln -s lib64 lib; fi
+if [ $getlmdzor = 1 -a ! -d $MODEL/modipsl ] ; then
+###########################################################################
+   echo '##########################################################'
+   echo  Download a slightly modified version of  LMDZ
+   echo '##########################################################'
+   cd $MODEL
+   myget src/modipsl_orc_cmip6.$version.tar.gz
+   echo install_lmdz.sh wget_OK `date`
+   gunzip modipsl_orc_cmip6.$version.tar.gz
+   tar xvf modipsl_orc_cmip6.$version.tar
+   \rm modipsl_orc_cmip6.$version.tar
+fi
+
+###########################################################################
+if [ $netcdf = 1 -a ! -d $MODEL/netcdf ] ; then
+###########################################################################
+   cd $MODEL
+   netcdflog=`pwd`/netcdf.log
+   echo '##########################################################'
+   echo Compiling the Netcdf library
+   echo '##########################################################'
+   echo log file : $netcdflog
+   if [ "$with_xios" = "n" ] ; then
+      # keep it simple
+      #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/netcdf-4.0.1.tar.gz
+      myget import/netcdf-4.0.1.tar.gz
+      gunzip netcdf-4.0.1.tar.gz
+      tar xvf netcdf-4.0.1.tar
+      \rm -f netcdf-4.0.1.tar
+    
+      cd netcdf-4.0.1
+    
+      localdir=`pwd -P`
+      ./configure --prefix=$localdir --enable-shared --disable-cxx
+      #sed -e 's/gfortran/'$gfortran'/g' Makefile >| tmp ; mv -f tmp Makefile
+      $make check > $netcdflog 2>&1
+      $make install >> $netcdflog 2>&1
+    #LF rajout d'une verrue, pour une raison non encore expliquee, la librairie est parfois rangée dans lib64
+    #   et non dans lib par certains compilateurs
+      if [ ! -e lib -a -d lib64 ] ; then ln -s lib64 lib; fi
+   else
+      # download and compile hdf5 and netcdf, etc. using the install_netcdf4_hdf5.bash script
+      #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/install_netcdf4_hdf5.bash
+      myget import/install_netcdf4_hdf5.bash
+      chmod u=rwx install_netcdf4_hdf5.bash
+      if [ "$compiler" = "gfortran" ] ; then
+      ./install_netcdf4_hdf5.bash -prefix $MODEL/netcdf4_hdf5 -CC gcc -FC gfortran -CXX g++ -MPI $root_mpi  > $netcdflog 2>&1
+      elif [ "$compiler" = "ifort" ] ; then
+      ./install_netcdf4_hdf5.bash -prefix $MODEL/netcdf4_hdf5 -CC icc -FC ifort -CXX icpc -MPI $root_mpi  > $netcdflog 2>&1
+      elif [ "$compiler" = "pgf90" ] ; then
+      ./install_netcdf4_hdf5.bash -prefix $MODEL/netcdf4_hdf5 -CC pgcc -FC pgf90 -CXX pgCC -MPI $root_mpi  > $netcdflog 2>&1
+      else
+        echo "unexpected compiler $compiler" ; exit
+      fi
+   fi  # of if [ "$with_xios" = "n" ]
+   echo install_lmdz.sh netcdf_OK `date`
+fi # of if [ $netcdf = 1 ]
+
+# ncdfdir contains the directory where netcdfd is installed
+if [ $netcdf = 0 -o $netcdf = 1 ] ; then
+   if [ "$with_xios" = "y" ] ; then
+      ncdfdir=$MODEL/netcdf4_hdf5
+   else
+      ncdfdir=$MODEL/netcdf-4.0.1
+   fi
 else
-  # download and compile hdf5 and netcdf, etc. using the install_netcdf4_hdf5.bash script
-  #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/install_netcdf4_hdf5.bash
-  myget import/install_netcdf4_hdf5.bash
-  chmod u=rwx install_netcdf4_hdf5.bash
-  if [ "$compiler" = "gfortran" ] ; then
-  ./install_netcdf4_hdf5.bash -prefix $MODEL/netcdf4_hdf5 -CC gcc -FC gfortran -CXX g++ -MPI $root_mpi  > $netcdflog 2>&1
-  elif [ "$compiler" = "ifort" ] ; then
-  ./install_netcdf4_hdf5.bash -prefix $MODEL/netcdf4_hdf5 -CC icc -FC ifort -CXX icpc -MPI $root_mpi  > $netcdflog 2>&1
-  elif [ "$compiler" = "pgf90" ] ; then
-  ./install_netcdf4_hdf5.bash -prefix $MODEL/netcdf4_hdf5 -CC pgcc -FC pgf90 -CXX pgCC -MPI $root_mpi  > $netcdflog 2>&1
-  else
-    echo "unexpected compiler $compiler" ; exit
-  fi
-fi  # of if [ "$with_xios" = "n" ]
-echo install_lmdz.sh netcdf_OK `date`
-fi # of if [ $netcdf = 1 ]
-
-#======================================================================================
-echo OK ioipsl=$ioipsl
-echo '##########################################################'
-echo 'Installing MODIPSL, the installation package manager for the '
-echo 'IPSL models and tools'
-echo '##########################################################'
-echo `date`
-
-if [ $netcdf = 0 -o $netcdf = 1 ] ; then
-  if [ "$with_xios" = "y" ] ; then
-  ncdfdir=$MODEL/netcdf4_hdf5
-  else
-  ncdfdir=$MODEL/netcdf-4.0.1
-  fi
-else
-  ncdfdir=$netcdf
-fi
-
+   ncdfdir=$netcdf
+fi
+
+#=========================================================================
 if [ $ioipsl = 1 ] ; then
-  cd $MODEL/modipsl
-  \rm -rf lib/*
-
-  cd util
-
-  cp AA_make.gdef AA_make.orig
-  F_C="$compiler -c " ; if [ "$compiler" = "$gfortran" -o "$compiler" = "mpif90" ] ; then F_C="$compiler -c -cpp " ; 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:" -e "s:F_C = g95 -c -cpp:F_C = $F_C": \
-  -e 's/g95.*.w_w.*.(F_D)/g95      w_w = '"$OPTIMGCM"'/' \
-  -e 's:g95.*.NCDF_INC.*.$:g95      NCDF_INC= '"$ncdfdir"'/include:' \
-  -e 's:g95.*.NCDF_LIB.*.$:g95      NCDF_LIB= -L'"$ncdfdir"'/lib -lnetcdff -lnetcdf:' \
-  -e 's:g95      L_O =:g95      L_O = -Wl,-rpath='"$ncdfdir"'/lib:' \
-  -e "s:-fmod=:-$fmod:" -e 's/-fno-second-underscore//' \
-  -e 's:#-Q- g95      M_K = gmake:#-Q- g95      M_K = make:' \
-  tmp >| AA_make.gdef
-
-  if [ $pcmac == 1 ]
-  then
-      cp AA_make.gdef tmp
-      sed -e 's/rpath=/rpath,/g' tmp > AA_make.gdef
-  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 ada AA_make.gdef`" = "" ] ; then # Bidouille pour compiler sur ada des vieux modipsl.tar
-    #    \cp -f ~rdzt401/bin/AA_make.gdef .
-    #fi
-    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
+#=========================================================================
+   echo OK ioipsl=$ioipsl
+   echo '##########################################################'
+   echo 'Installing MODIPSL, the installation package manager for the '
+   echo 'IPSL models and tools'
+   echo '##########################################################'
+   echo `date`
+   
+   cd $MODEL/modipsl
+   \rm -rf lib/*
+   cd util
+   cp AA_make.gdef AA_make.orig
+   F_C="$compiler -c " ; if [ "$compiler" = "$gfortran" -o "$compiler" = "mpif90" ] ; then F_C="$compiler -c -cpp " ; 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:" -e "s:F_C = g95 -c -cpp:F_C = $F_C": \
+   -e 's/g95.*.w_w.*.(F_D)/g95      w_w = '"$OPTIMGCM"'/' \
+   -e 's:g95.*.NCDF_INC.*.$:g95      NCDF_INC= '"$ncdfdir"'/include:' \
+   -e 's:g95.*.NCDF_LIB.*.$:g95      NCDF_LIB= -L'"$ncdfdir"'/lib -lnetcdff -lnetcdf:' \
+   -e 's:g95      L_O =:g95      L_O = -Wl,-rpath='"$ncdfdir"'/lib:' \
+   -e "s:-fmod=:-$fmod:" -e 's/-fno-second-underscore//' \
+   -e 's:#-Q- g95      M_K = gmake:#-Q- g95      M_K = make:' \
+   tmp >| AA_make.gdef
+ 
+   if [ $pcmac == 1 ]
+   then
+       cp AA_make.gdef tmp
+       sed -e 's/rpath=/rpath,/g' tmp > AA_make.gdef
+   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" ]
+ 
+   echo install_lmdz.sh MODIPSL_OK `date`
+ 
+   cd $MODEL/modipsl/modeles/IOIPSL/src
+   ioipsllog=`pwd`/ioipsl.log
+   echo '##########################################################'
+   echo 'Compiling IOIPSL, the interface library with Netcdf'
+   echo '##########################################################'
+   echo `date`
+   echo log file : $ioipsllog
+ 
+   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
+     # Build IOIPSL modules and library
+     $make clean
+     $make > $ioipsllog 2>&1
+     if [ "$compiler" = "$gfortran" -o "$compiler" = "mpif90" ] ; then # copy module files to lib
+       cp -f *.mod ../../../lib
+     fi
+     # Build IOIPSL tools (ie: "rebuild", if present)
+     if [ -f $MODEL/modipsl/modeles/IOIPSL/tools/rebuild ] ; then
+       cd $MODEL/modipsl/modeles/IOIPSL/tools
+       # 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
+       $make clean
+       $make > $ioipsllog 2>&1
+     fi
+# fi # of if [ "$pclinux" = 1 ] 
+ 
+else # of if [ $ioipsl = 1 ]
+   if [ ${hostname:0:5} = jean- ] ; then
+      cd $MODEL/modipsl
+      cd util
+        if [ "`grep jeanzay AA_make.gdef`" = "" ] ; then
+         echo 'Warning jean-zay not in AA_make.gdef'
+         echo 'Think about updating'
+         exit 1
+        fi
+        ./ins_make $o_ins_make
+# Compile IOIPSL on jean-zay
+        cd $MODEL/modipsl/modeles/IOIPSL/src
+        gmake > ioipsl.log
+        cd $MODEL/modipsl/modeles/IOIPSL/tools
+        gmake > ioipsl.log
     
-    chmod u=rwx ins_make.bash
-    ./ins_make.bash $o_ins_make
-  fi # of if [ "$use_shell" = "ksh" ]
-
-echo install_lmdz.sh MODIPSL_OK `date`
-#=======================================================================================
-  cd $MODEL/modipsl/modeles/IOIPSL/src
-  ioipsllog=`pwd`/ioipsl.log
-  echo '##########################################################'
-  echo 'Compiling IOIPSL, the interface library with Netcdf'
-  echo '##########################################################'
-  echo `date`
-  echo log file : $ioipsllog
-
-  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
-    # Build IOIPSL modules and library
-    $make clean
-    $make > $ioipsllog 2>&1
-    if [ "$compiler" = "$gfortran" -o "$compiler" = "mpif90" ] ; then # copy module files to lib
-      cp -f *.mod ../../../lib
-    fi
-    # Build IOIPSL tools (ie: "rebuild", if present)
-    if [ -f $MODEL/modipsl/modeles/IOIPSL/tools/rebuild ] ; then
-      cd $MODEL/modipsl/modeles/IOIPSL/tools
-      # 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
-      $make clean
-      $make > $ioipsllog 2>&1
-    fi
-# fi # of if [ "$pclinux" = 1 ] 
-
-else # of if [ $ioipsl = 1 ]
-  if [ ${hostname:0:5} = jean- ] ; then
-     cd $MODEL/modipsl
-     cd util
-       if [ "`grep jeanzay AA_make.gdef`" = "" ] ; then
-        echo 'Warning jean-zay not in AA_make.gdef'
-        echo 'Think about updating'
-        exit 1
-       fi
-       ./ins_make $o_ins_make
-# Compile IOIPSL on jean-zay
-       cd $MODEL/modipsl/modeles/IOIPSL/src
-       gmake > ioipsl.log
-       cd $MODEL/modipsl/modeles/IOIPSL/tools
-       gmake > ioipsl.log
-   
-  fi
-  echo install_lmdz.sh ioipsl_OK `date`
+   fi
+   echo install_lmdz.sh ioipsl_OK `date`
 fi # of if [ $ioipsl = 1 ]
 # Saving ioipsl lib for possible parallel compile
@@ -721,5 +724,5 @@
   tar cf ioipsl.tar lib/ bin/
 
-#===========================================================================
+#=========================================================================
 if [ "$with_xios" = "y" ] ; then
   echo '##########################################################'
@@ -924,5 +927,5 @@
 echo '##################################################################'
 echo "Preparing script compile.sh for LMDZ compilation" 
-echo "It will only be run automatically if bench=1" 
+echo "It will only be run automatically if bench=1/tuto" 
 echo Here bench=$bench
 echo '##################################################################'
@@ -938,5 +941,5 @@
   echo "./$makelmdz $optim $OPT_MAKELMDZ $optim $opt_rad $opt_cosp -d ${grid_resolution} -v $veget_version gcm " >> compile.sh
   chmod +x ./compile.sh
-  if [ $bench != 0 ] ; then 
+  if [ $bench = 1 ] ; then 
     echo install_lmdz.sh start_lmdz_seq_compilation `date`
     echo log file: $lmdzlog
@@ -1022,8 +1025,6 @@
   chmod +x ./compile.sh
 
-  if [ $bench != 0 ] ; then 
-    echo Compiling LMDZ in parallel mode `date`
-    echo LMDZ log file: $lmdzlog
-    ./compile.sh > $lmdzlog 2>&1
+  if [ $bench = 1 ] ; then
+     echo Compiling LMDZ in parallel mode `date`,  LMDZ log file: $lmdzlog ; ./compile.sh > $lmdzlog 2>&1
   fi
   
@@ -1042,5 +1043,5 @@
 
 if [ "$gcm" = "" ] ; then
-  if [ $bench != 0 ] ; then
+  if [ $bench = 1 ] ; then
     echo 'Compilation failed !! Cannot run the benchmark;'
     exit
@@ -1056,201 +1057,206 @@
 
 ##################################################################
-# Below, we run a benchmark test (if bench=0)
+# Below, we run a benchmark if bench=1 or tuto
 ##################################################################
 
-if [ $bench != 0 ] ; then
-
-echo '##########################################################'
-echo ' Running a test run '
-echo '##########################################################'
-
-\rm -rf BENCH${grid_resolution}
-bench=bench_lmdz_${grid_resolution}
-echo install_lmdz.sh before bench download  `date`
-#wget http://www.lmd.jussieu.fr/~lmdz/Distrib/$bench.tar.gz
-myget 3DBenchs/$bench.tar.gz
-echo install_lmdz.sh after bench download  `date`
-tar xvf $bench.tar.gz
-
-if [ "$cosp" = "v1" -o "$cosp" = "v2" ] ; then
-  cd BENCH${grid_resolution}
-# copier les fichiers namelist input et output our COSP
-  cp ../DefLists/cosp*_input_nl.txt .
-  cp ../DefLists/cosp*_output_nl.txt .
-# Activer la cles ok_cosp pour tourner avec COSP
-  sed -e 's@ok_cosp=n@ok_cosp=y@' config.def > tmp
-   \mv -f tmp config.def
-  cd ..
-fi 
-
-if [ -n "$physiq" ]; then
-  cd BENCH${grid_resolution}
-  if [ -f physiq.def_${physiq} ]; then
-    cp physiq.def_${physiq} physiq.def
-    echo using physiq.def_${physiq}
-  else
-    echo using standard physiq.def
-  fi
-  cd ..
-else
-  echo using standard physiq.def
-fi
-
-if [ "$with_xios" = "y" ] ; then
-  cd BENCH${grid_resolution}
-  cp ../DefLists/iodef.xml .
-  cp ../DefLists/context_lmdz.xml .
-  cp ../DefLists/field_def_lmdz.xml .
-# A raffiner par la suite
-  echo A FAIRE : Copier les *xml en fonction de l option cosp
-  cp ../DefLists/field_def_cosp*.xml .
-  cp ../DefLists/file_def_hist*xml .
-  # adapt iodef.xml to use attached mode
-  sed -e 's@"using_server" type="bool">true@"using_server" type="bool">false@' iodef.xml > tmp
-  \mv -f tmp iodef.xml
-
-  # and convert all the enabled="_AUTO_" (for libIGCM) to enabled=.FALSE.
-  # except for histday
-  for histfile in file_def_hist*xml
-  do
-    if [ "$histfile" = "file_def_histday_lmdz.xml" ] ; then
-    sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".TRUE."@' $histfile > tmp ; \mv -f tmp $histfile
-    sed -e 's@output_level="_AUTO_"@output_level="5"@' $histfile > tmp ; \mv -f tmp $histfile
-    sed -e 's@compression_level="2"@compression_level="0"@' $histfile > tmp ; \mv -f tmp $histfile
-    else
-    sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".FALSE."@' $histfile > tmp ; \mv -f tmp $histfile
-    fi
-  done
-  # and add option "ok_all_xml=y" in config.def
-  echo "### XIOS outputs" >> config.def
-  echo 'ok_all_xml=.true.' >> config.def
-
-  #activer les sorties pour Cosp
-  if [ "$cosp" = "v1" ] ; then 
-   histfile=file_def_histdayCOSP_lmdz.xml
-   sed -e 's@enabled=".FALSE."@enabled=".TRUE."@' $histfile > tmp ; \mv -f tmp $histfile
-   sed -e 's@output_level="_AUTO_"@output_level="5"@' $histfile > tmp ; \mv -f tmp $histfile
-   sed -e 's@compression_level="2"@compression_level="0"@' $histfile > tmp ; \mv -f tmp $histfile
-  fi
-  if [ "$cosp" = "v2" ] ; then
-   histfile=file_def_histdayCOSPv2_lmdz.xml
-   sed -e 's@compression_level="2"@compression_level="0"@' $histfile > tmp ; \mv -f tmp $histfile
-   contextfile=context_lmdz.xml
-   sed -e 's@src="./file_def_histdayCOSP_lmdz.xml"@src="./file_def_histdayCOSPv2_lmdz.xml"@' $contextfile > tmp ; \mv -f tmp $contextfile
-   sed -e 's@src="./file_def_histmthCOSP_lmdz.xml"@src="./file_def_histmthCOSPv2_lmdz.xml"@' $contextfile > tmp ; \mv -f tmp $contextfile
-   sed -e 's@src="./file_def_histhfCOSP_lmdz.xml"@src="./file_def_histhfCOSPv2_lmdz.xml"@' $contextfile > tmp ; \mv -f tmp $contextfile
-   fieldfile=field_def_lmdz.xml
-   sed -e 's@field_def_cosp1.xml@field_def_cospv2.xml@' $fieldfile > tmp ; \mv -f tmp $fieldfile
-  fi
-
-  cd ..
-fi
-
-# Cas Bensh avec ecrad
-if [ "$rad" = "ecrad" ] ; then
-  cd BENCH${grid_resolution}
-  cp  ../DefLists/namelist_ecrad .
-  cp -r ../libf/phylmd/ecrad/data .
-# Attention au cas ou ne 1
-  sed -e 's@iflag_rrtm=1@iflag_rrtm=2@' physiq.def > tmp
-   \mv -f tmp physiq.def
-  cd ..
-fi
-
-cp $gcm BENCH${grid_resolution}/gcm.e
-
-cd BENCH${grid_resolution}
-# On cree le fichier bench.sh au besoin
-# Dans le cas 48x36x39 le bench.sh existe deja en parallele
-
-if [ "$grid_resolution" = "48x36x39" ] ; then
-   echo On ne touche pas au bench.sh
-   # But we have to adapt "run_local.sh" for $mpirun
-   sed -e "s@mpirun@$mpirun@g" run_local.sh > tmp
-   mv -f tmp run_local.sh
-   chmod u=rwx run_local.sh
-elif [ "${parallel:0:3}" = "mpi" ] ; then
-   # Lancement avec deux procs mpi et 2 openMP
-   echo "export OMP_STACKSIZE=800M" > bench.sh
-   if [ "${parallel:4:3}" = "omp" ] ; then
-     echo "export OMP_NUM_THREADS=2" >> bench.sh
+if [ $bench = tuto ] ; then
+   myget Training/tutorial.tar ; tar xvf tutorial.tar ; cd TUTORIAL ; ./init.sh
+
+elif [ $bench = 1 ] ; then
+   # TOUTE CETTE SECTION DEVRAIT DISPARAITRE POUR UNE COMMANDE
+   # OU DES BENCHS PAR MOTS CLES COMME tuto
+
+   echo '##########################################################'
+   echo ' Running a test run '
+   echo '##########################################################'
+   
+   \rm -rf BENCH${grid_resolution}
+   bench=bench_lmdz_${grid_resolution}
+   echo install_lmdz.sh before bench download  `date`
+   #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/$bench.tar.gz
+   myget 3DBenchs/$bench.tar.gz
+   echo install_lmdz.sh after bench download  `date`
+   tar xvf $bench.tar.gz
+   
+   if [ "$cosp" = "v1" -o "$cosp" = "v2" ] ; then
+     cd BENCH${grid_resolution}
+   # copier les fichiers namelist input et output our COSP
+     cp ../DefLists/cosp*_input_nl.txt .
+     cp ../DefLists/cosp*_output_nl.txt .
+   # Activer la cles ok_cosp pour tourner avec COSP
+     sed -e 's@ok_cosp=n@ok_cosp=y@' config.def > tmp
+      \mv -f tmp config.def
+     cd ..
+   fi 
+   
+   if [ -n "$physiq" ]; then
+     cd BENCH${grid_resolution}
+     if [ -f physiq.def_${physiq} ]; then
+       cp physiq.def_${physiq} physiq.def
+       echo using physiq.def_${physiq}
+     else
+       echo using standard physiq.def
+     fi
+     cd ..
+   else
+     echo using standard physiq.def
    fi
-   if [ "$cosp" = "v1" -o "$cosp" = "v2" ] ; then 
-      if [ ${hostname:0:5} = jean- ] ; then    
-	chmod +x ../arch.env
-        ../arch.env	
-        echo "ulimit -s 2000000" >> bench.sh
+   
+   if [ "$with_xios" = "y" ] ; then
+     cd BENCH${grid_resolution}
+     cp ../DefLists/iodef.xml .
+     cp ../DefLists/context_lmdz.xml .
+     cp ../DefLists/field_def_lmdz.xml .
+   # A raffiner par la suite
+     echo A FAIRE : Copier les *xml en fonction de l option cosp
+     cp ../DefLists/field_def_cosp*.xml .
+     cp ../DefLists/file_def_hist*xml .
+     # adapt iodef.xml to use attached mode
+     sed -e 's@"using_server" type="bool">true@"using_server" type="bool">false@' iodef.xml > tmp
+     \mv -f tmp iodef.xml
+   
+     # and convert all the enabled="_AUTO_" (for libIGCM) to enabled=.FALSE.
+     # except for histday
+     for histfile in file_def_hist*xml
+     do
+       if [ "$histfile" = "file_def_histday_lmdz.xml" ] ; then
+       sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".TRUE."@' $histfile > tmp ; \mv -f tmp $histfile
+       sed -e 's@output_level="_AUTO_"@output_level="5"@' $histfile > tmp ; \mv -f tmp $histfile
+       sed -e 's@compression_level="2"@compression_level="0"@' $histfile > tmp ; \mv -f tmp $histfile
+       else
+       sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".FALSE."@' $histfile > tmp ; \mv -f tmp $histfile
+       fi
+     done
+     # and add option "ok_all_xml=y" in config.def
+     echo "### XIOS outputs" >> config.def
+     echo 'ok_all_xml=.true.' >> config.def
+   
+     #activer les sorties pour Cosp
+     if [ "$cosp" = "v1" ] ; then 
+      histfile=file_def_histdayCOSP_lmdz.xml
+      sed -e 's@enabled=".FALSE."@enabled=".TRUE."@' $histfile > tmp ; \mv -f tmp $histfile
+      sed -e 's@output_level="_AUTO_"@output_level="5"@' $histfile > tmp ; \mv -f tmp $histfile
+      sed -e 's@compression_level="2"@compression_level="0"@' $histfile > tmp ; \mv -f tmp $histfile
+     fi
+     if [ "$cosp" = "v2" ] ; then
+      histfile=file_def_histdayCOSPv2_lmdz.xml
+      sed -e 's@compression_level="2"@compression_level="0"@' $histfile > tmp ; \mv -f tmp $histfile
+      contextfile=context_lmdz.xml
+      sed -e 's@src="./file_def_histdayCOSP_lmdz.xml"@src="./file_def_histdayCOSPv2_lmdz.xml"@' $contextfile > tmp ; \mv -f tmp $contextfile
+      sed -e 's@src="./file_def_histmthCOSP_lmdz.xml"@src="./file_def_histmthCOSPv2_lmdz.xml"@' $contextfile > tmp ; \mv -f tmp $contextfile
+      sed -e 's@src="./file_def_histhfCOSP_lmdz.xml"@src="./file_def_histhfCOSPv2_lmdz.xml"@' $contextfile > tmp ; \mv -f tmp $contextfile
+      fieldfile=field_def_lmdz.xml
+      sed -e 's@field_def_cosp1.xml@field_def_cospv2.xml@' $fieldfile > tmp ; \mv -f tmp $fieldfile
+     fi
+   
+     cd ..
+   fi
+   
+   # Cas Bensh avec ecrad
+   if [ "$rad" = "ecrad" ] ; then
+     cd BENCH${grid_resolution}
+     cp  ../DefLists/namelist_ecrad .
+     cp -r ../libf/phylmd/ecrad/data .
+   # Attention au cas ou ne 1
+     sed -e 's@iflag_rrtm=1@iflag_rrtm=2@' physiq.def > tmp
+      \mv -f tmp physiq.def
+     cd ..
+   fi
+   
+   cp $gcm BENCH${grid_resolution}/gcm.e
+   
+   cd BENCH${grid_resolution}
+   # On cree le fichier bench.sh au besoin
+   # Dans le cas 48x36x39 le bench.sh existe deja en parallele
+   
+   if [ "$grid_resolution" = "48x36x39" ] ; then
+      echo On ne touche pas au bench.sh
+      # But we have to adapt "run_local.sh" for $mpirun
+      sed -e "s@mpirun@$mpirun@g" run_local.sh > tmp
+      mv -f tmp run_local.sh
+      chmod u=rwx run_local.sh
+   elif [ "${parallel:0:3}" = "mpi" ] ; then
+      # Lancement avec deux procs mpi et 2 openMP
+      echo "export OMP_STACKSIZE=800M" > bench.sh
+      if [ "${parallel:4:3}" = "omp" ] ; then
+        echo "export OMP_NUM_THREADS=2" >> bench.sh
+      fi
+      if [ "$cosp" = "v1" -o "$cosp" = "v2" ] ; then 
+         if [ ${hostname:0:5} = jean- ] ; then    
+   	chmod +x ../arch.env
+           ../arch.env	
+           echo "ulimit -s 2000000" >> bench.sh
+         else
+           echo "ulimit -s 200000" >> bench.sh	      
+         fi	
       else
-        echo "ulimit -s 200000" >> bench.sh	      
-      fi	
+         echo "ulimit -s unlimited" >> bench.sh
+      fi
+      if [ ${hostname:0:5} = jean- ] ; then
+        . ../arch/arch-${arch}.env  
+        echo "srun -n 2 -A $idris_acct@cpu gcm.e > listing  2>&1" >> bench.sh
+      else
+        echo "$mpirun -np 2 gcm.e > listing  2>&1" >> bench.sh
+      fi
+      # Add rebuild, using reb.sh if it is there
+      echo 'if [ -f reb.sh ] ; then' >> bench.sh
+      echo '  ./reb.sh histday ; ./reb.sh histmth ; ./reb.sh histhf ; ./reb.sh histins ; ./reb.sh stomate_history ; ./reb.sh sechiba_history ; ./reb.sh sechiba_out_2 ' >> bench.sh
+      echo 'fi' >> bench.sh
    else
-      echo "ulimit -s unlimited" >> bench.sh
+      echo "./gcm.e > listing  2>&1" > bench.sh
    fi
-   if [ ${hostname:0:5} = jean- ] ; then
-     . ../arch/arch-${arch}.env  
-     echo "srun -n 2 -A $idris_acct@cpu gcm.e > listing  2>&1" >> bench.sh
+   # Getting orchidee stuff
+   if [ $veget == 'CMIP6' ] ; then
+       #echo 'myget 3DBenchs/BENCHorch11.tar.gz'
+       #myget 3DBenchs/BENCHorch11.tar.gz
+       #tar xvzf BENCHorch11.tar.gz
+       echo 'myget 3DBenchs/BENCHCMIP6.tar.gz'
+       myget 3DBenchs/BENCHCMIP6.tar.gz
+       tar xvzf BENCHCMIP6.tar.gz
+       sed -e "s:VEGET=n:VEGET=y:" config.def > tmp
+       mv -f tmp config.def
+       if [ "$with_xios" = "y" ] ; then
+         cp ../../ORCHIDEE/src_xml/context_orchidee.xml .
+         echo '<context id="orchidee" src="./context_orchidee.xml"/>' > add.tmp
+         cp ../../ORCHIDEE/src_xml/field_def_orchidee.xml .
+         cp ../../ORCHIDEE/src_xml/file_def_orchidee.xml .
+         cp ../../ORCHIDEE/src_xml/file_def_input_orchidee.xml .
+         if [ -f ../../ORCHIDEE/src_xml/context_input_orchidee.xml ] ; then
+   	cp ../../ORCHIDEE/src_xml/context_input_orchidee.xml .
+   	echo '<context id="orchidee" src="./context_input_orchidee.xml"/>' >> add.tmp
+         fi
+         sed -e '/id="LMDZ"/r add.tmp' iodef.xml > tmp
+         mv tmp iodef.xml
+         sed -e'{/sechiba1/ s/enabled="_AUTO_"/type="one_file" enabled=".TRUE."/}' file_def_orchidee.xml > tmp ; \mv -f tmp file_def_orchidee.xml
+         sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".FALSE."@' file_def_orchidee.xml > tmp ; \mv -f tmp file_def_orchidee.xml
+         sed -e 's@output_level="_AUTO_"@output_level="1"@' file_def_orchidee.xml > tmp ; \mv -f tmp file_def_orchidee.xml
+         sed -e 's@output_freq="_AUTO_"@output_freq="1d"@' file_def_orchidee.xml > tmp ; \mv -f tmp file_def_orchidee.xml
+         sed -e 's@compression_level="4"@compression_level="0"@' file_def_orchidee.xml > tmp ; \mv -f tmp file_def_orchidee.xml
+         sed -e 's@XIOS_ORCHIDEE_OK = n@XIOS_ORCHIDEE_OK = y@' orchidee.def > tmp ; \mv -f tmp orchidee.def
+       fi
+   fi
+   echo EXECUTION DU BENCH
+   set +e
+   date ; ./bench.sh > out.bench 2>&1 ; date
+   set -e
+   tail listing
+   
+   
+   echo '##########################################################'
+   echo 'Simulation finished in' `pwd`
+      echo 'You have compiled with:'
+      cat ../compile.sh
+   if [ $parallel = "none" ] ; then
+     echo 'You may re-run it with : cd ' `pwd` ' ; gcm.e'
+     echo 'or ./bench.sh'
    else
-     echo "$mpirun -np 2 gcm.e > listing  2>&1" >> bench.sh
+     echo 'You may re-run it with : '
+     echo 'cd ' `pwd` '; ./bench.sh'
+   #  echo 'ulimit -s unlimited'
+   #  echo 'export OMP_NUM_THREADS=2'
+   #  echo 'export OMP_STACKSIZE=800M'
+   #  echo "$mpirun -np 2 gcm.e "
    fi
-   # Add rebuild, using reb.sh if it is there
-   echo 'if [ -f reb.sh ] ; then' >> bench.sh
-   echo '  ./reb.sh histday ; ./reb.sh histmth ; ./reb.sh histhf ; ./reb.sh histins ; ./reb.sh stomate_history ; ./reb.sh sechiba_history ; ./reb.sh sechiba_out_2 ' >> bench.sh
-   echo 'fi' >> bench.sh
-else
-   echo "./gcm.e > listing  2>&1" > bench.sh
-fi
-# Getting orchidee stuff
-if [ $veget == 'CMIP6' ] ; then
-    #echo 'myget 3DBenchs/BENCHorch11.tar.gz'
-    #myget 3DBenchs/BENCHorch11.tar.gz
-    #tar xvzf BENCHorch11.tar.gz
-    echo 'myget 3DBenchs/BENCHCMIP6.tar.gz'
-    myget 3DBenchs/BENCHCMIP6.tar.gz
-    tar xvzf BENCHCMIP6.tar.gz
-    sed -e "s:VEGET=n:VEGET=y:" config.def > tmp
-    mv -f tmp config.def
-    if [ "$with_xios" = "y" ] ; then
-      cp ../../ORCHIDEE/src_xml/context_orchidee.xml .
-      echo '<context id="orchidee" src="./context_orchidee.xml"/>' > add.tmp
-      cp ../../ORCHIDEE/src_xml/field_def_orchidee.xml .
-      cp ../../ORCHIDEE/src_xml/file_def_orchidee.xml .
-      cp ../../ORCHIDEE/src_xml/file_def_input_orchidee.xml .
-      if [ -f ../../ORCHIDEE/src_xml/context_input_orchidee.xml ] ; then
-	cp ../../ORCHIDEE/src_xml/context_input_orchidee.xml .
-	echo '<context id="orchidee" src="./context_input_orchidee.xml"/>' >> add.tmp
-      fi
-      sed -e '/id="LMDZ"/r add.tmp' iodef.xml > tmp
-      mv tmp iodef.xml
-      sed -e'{/sechiba1/ s/enabled="_AUTO_"/type="one_file" enabled=".TRUE."/}' file_def_orchidee.xml > tmp ; \mv -f tmp file_def_orchidee.xml
-      sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".FALSE."@' file_def_orchidee.xml > tmp ; \mv -f tmp file_def_orchidee.xml
-      sed -e 's@output_level="_AUTO_"@output_level="1"@' file_def_orchidee.xml > tmp ; \mv -f tmp file_def_orchidee.xml
-      sed -e 's@output_freq="_AUTO_"@output_freq="1d"@' file_def_orchidee.xml > tmp ; \mv -f tmp file_def_orchidee.xml
-      sed -e 's@compression_level="4"@compression_level="0"@' file_def_orchidee.xml > tmp ; \mv -f tmp file_def_orchidee.xml
-      sed -e 's@XIOS_ORCHIDEE_OK = n@XIOS_ORCHIDEE_OK = y@' orchidee.def > tmp ; \mv -f tmp orchidee.def
-    fi
-fi
-echo EXECUTION DU BENCH
-set +e
-date ; ./bench.sh > out.bench 2>&1 ; date
-set -e
-tail listing
-
-
-echo '##########################################################'
-echo 'Simulation finished in' `pwd`
-   echo 'You have compiled with:'
-   cat ../compile.sh
-if [ $parallel = "none" ] ; then
-  echo 'You may re-run it with : cd ' `pwd` ' ; gcm.e'
-  echo 'or ./bench.sh'
-else
-  echo 'You may re-run it with : '
-  echo 'cd ' `pwd` '; ./bench.sh'
-#  echo 'ulimit -s unlimited'
-#  echo 'export OMP_NUM_THREADS=2'
-#  echo 'export OMP_STACKSIZE=800M'
-#  echo "$mpirun -np 2 gcm.e "
-fi
-echo '##########################################################'
+   echo '##########################################################'
 
 fi # bench
