Index: /bench_AROME.sh
===================================================================
--- /bench_AROME.sh	(revision 85)
+++ /bench_AROME.sh	(revision 86)
@@ -1,98 +1,83 @@
 #!/bin/bash
 
-model=AROME
-case=ARMCU
-subcase=REF
-
-DATE=`date "+%Y%m%d"`
-
-MULTIMETRICS=TRUE
-./setup.sh $model BENCHMARK/$model/$DATE
-cd WORK/BENCHMARK/$model/$DATE
-
-# To be modified if namelists and binaries are not at the default location
-cat << EOF > param_AROME
-nlev=90
-timestep=50
-cycle=41t1_op1.11_MUSC
-simuREF=AROME_OPER
-namref=$REP_MUSC/namelist/AROME/namarp_41t1_AROME_HTUNE
-namsfx=$REP_MUSC/namelist/SURFEX/nam.sfx.tl127.CMIP6.v631
-MASTER=/home/honnert/pack/41t1_op1.11_MUSC/bin/MASTERODB
-PGD=/home/honnert/pack/41t1_op1.11_MUSC/bin/PGD
-PREP=/home/honnert/pack/41t1_op1.11_MUSC/bin/PREP
-EOF
-
-cat << EOF > expe_setup.R
-#############################################################################
-# Purpose : define the setup of the experiments, i.e.the case, subcase, 
-#           target variables and wave number.
-#######################################i######################################
-# available targetvar
-# theta500 : potential temperature at 500m
-# qv500    : water vapor at 500m
-# zhneb    : effective height of cloud
-# nebmax   : max nebulosity
-# nebzmin  : base of clouds (min z with neb > 5% nebmax)
-# nebzmax  : top of clouds  (max z with neb > 5% nebmax)
-#######################################i#####################################
-case_name="$case"
-subcase_name="$subcase"
-#targetvar<- c("theta500")
-#plotvar="theta" # qv ou rneb
-# Exemple for multi-target experiment :
-targetvar<- c("theta500","qv500","zhneb","nebmax")
-nmetrique=length(targetvar)
-# Wave number
-WAVEN=1
-EOF
-
-echo '###########################'
-echo 'Executing param2R.sh'
-#./param2R.sh 10 3 AROME_tuning_compa_thermique_PM09.txt > param2R.out 2> param2R.err
-./param2R.sh 30 3 AROME_tuning_compa_thermique_PM09.txt > param2R.out 2> param2R.err
-cat param2R.err
-
-echo '###########################'
-echo 'Executing serie_AROME.sh'
-./serie_AROME.sh $case $subcase > serie_AROME.out 2> serie_AROME.err
-cat serie_AROME.err
-
-echo '###########################'
-echo 'Executing htune_ncdf2Rdata.R'
-Rscript htune_ncdf2Rdata.R > htune_ncdf2Rdata.out 2> htune_ncdf2Rdata.err
-cat htune_ncdf2Rdata.err
-
-echo '###########################'
-echo 'Executing htune_EmulatingSCM_CS2.R'
-# simple metrics
-if [ $MULTIMETRICS == TRUE ];then
-Rscript htune_EmulatingSCM.R > htune_EmulatingSCM.out 2> htune_EmulatingSCM.err
-cat htune_EmulatingSCM.err
-else
-Rscript htune_EmulatingSCM_CS2.R > htune_EmulatingSCM_CS2.out 2> htune_EmulatingSCM_CS2.err
-cat htune_EmulatingSCM_CS2.err
+if [ `pwd | grep -o HighTune | wc -l` -gt 1 ]
+then
+  echo "Careful: the HighTune string appears more than once in your current directory:"
+  pwd
+  echo "This is going to be a problem! Make sure it appears only once!"
+  # some sed commands won't work otherwise; this should be improved.
+  exit
 fi
 
-if [ $MULTIMETRICS == TRUE ];then
-#pdfjam WAVE1/ARMCU/REF/Plots_LOO.pdf 1
-pdfjam WAVE1/$case/$subcase/Plots_LOO.pdf 1
-pdf2ps Plots_LOO-1-pdfjam.pdf
-ps2epsi Plots_LOO-1-pdfjam.ps
-epstopdf Plots_LOO-1-pdfjam.epsi
-pdfjam Plots_LOO-1-pdfjam.pdf InputSpace_wave1.pdf --nup 2x1 --landscape --outfile result_mm.pdf
-evince result_mm.pdf &
-else
-pdfjam Rplots.pdf 2 
-pdf2ps Rplots-2-pdfjam.pdf
-ps2epsi Rplots-2-pdfjam.ps
-epstopdf Rplots-2-pdfjam.epsi
-pdfjam Rplots-2-pdfjam.pdf InputSpace_wave1.pdf --nup 2x1 --landscape --outfile result.pdf
-evince result.pdf &
+model=LMDZ
+cas=ARMCU/REF
+param=param
+bench=2
+
+while (($# > 0)) ; do
+        case $1 in
+          -bench) bench=$2 ; shift ; shift ;;
+          -param) param=$2 ; shift ; shift ;;
+          -help) echo Usage "$0 [-bench N] [-param param_file] [model]" ; exit ;;
+          *) model=$1 ; shift ;;
+        esac
+done
+
+if [ $model == AROME ];then
+  cas=ARMCU
+  subcase=REF
+fi
+if [ $model == ECRAD ] ; then
+  cas=ARMCU/008
 fi
 
-echo '##########################################################'
-echo Next version will start heating water at tea time
-echo '##########################################################'
+WDIR=BENCH$bench$model
+./setup.sh $model $WDIR
+cd WORK/$WDIR
 
+./param2R.sh 30 3 $param
+if [ $? -eq 0 ]; then
+  sed -i "s/WAVEN=.*/WAVEN=1/g" expe_setup.R
+  if [ $model == AROME ];then
+    echo ./serie_$model.sh $cas $subcase 1	   
+    ./serie_$model.sh $cas $subcase 1
+  else
+    ./serie_$model.sh $cas 1
+  fi
+  echo bench=$bench
+  if [ $? -eq 0 ]; then
+    if [ $bench = 1 ] ; then
+       compute_metrics_csv.sh
+       Rscript htune_csv2Rdata.R
+       Rscript htune_EmulatingMultiMetric.R
+    elif [ $bench = 3 ] ; then
+       # csv bench.
+       echo 'Compute_multicas_onemetric+csv'
+       compute_multicas_onemetric.sh
+       Rscript htune_csv2Rdata_many-met.R
+       Rscript htune_EmulatingMultiMetric.R
+    elif [ $bench = 2 ] ; then
+       # old bench. To be removed
+       echo 'Emulating_CS2'
+       Rscript htune_ncdf2Rdata.R 
+       Rscript htune_EmulatingSCM_CS2.R
+    else
+       # bench with optionally multi metrics computed witing R
+       echo 'Emulating_MultiMetric'
+       Rscript htune_ncdf2Rdata.R 
+       Rscript htune_EmulatingMultiMetric.R
+    fi
 
+  
+    echo '##########################################################'
+    echo Next version will start heating water at tea time
+    echo '##########################################################'
+  
+    pdfjam Rplots.pdf 2 
+    pdf2ps Rplots-2-pdfjam.pdf
+    ps2epsi Rplots-2-pdfjam.ps
+    epstopdf Rplots-2-pdfjam.epsi
+    pdfjam Rplots-2-pdfjam.pdf InputSpace_wave1.pdf --nup 2x1 --landscape --outfile result.pdf
+    evince InputSpace_wave1.pdf &
+  fi
+fi
Index: /models/AROME/prep_config_tunning.py
===================================================================
--- /models/AROME/prep_config_tunning.py	(revision 85)
+++ /models/AROME/prep_config_tunning.py	(revision 86)
@@ -2,5 +2,5 @@
 import sys
 
-import configMUSC
+#import configMUSC
 
 nsimus = int(sys.argv[1])
@@ -11,20 +11,30 @@
 model = sys.argv[6]
 
-rep0 = configMUSC.mainrep
+config = sys.argv[7]
+cycle = sys.argv[8]
+MASTER = sys.argv[9]
+if model == 'ARPCLIMAT':
+  PGD = sys.argv[10]
+  PREP = sys.argv[11]
+  namsfx = sys.argv[12]
+  
 
-if model == 'ARPCLIMAT':
-  config = 'CMIP6'
-  cycle = 'arp631'
-  MASTER = '/Users/romainroehrig/rootpack/arp603_export.01.MPIGNU640.x/bin/MASTERODB'
-  PGD = '/Users/romainroehrig/rootpack/arp603_export.01.MPIGNU640.x/bin/PGD'
-  PREP = '/Users/romainroehrig/rootpack/arp603_export.01.MPIGNU640.x/bin/PREP'
-elif model == 'AROME':
-  config = 'AROME_OPER'
-  cycle = '41t1_op1.11_MUSC'
-  MASTER ='/home/honnert/Bureau/MUSC/pack/' + cycle + '/bin/MASTERODB'
-elif model == 'ARPEGE':
-  config = 'ARPEGE_OPER'
-  cycle = '41t1_op1.11_MUSC'
-  MASTER = '/home/honnert/Bureau/MUSC/pack/' + cycle + '/bin/MASTERODB'
+
+#rep0 = configMUSC.mainrep
+
+#if model == 'ARPCLIMAT':
+#  config = 'CMIP6'
+#  cycle = 'arp631'
+#  MASTER = '/Users/romainroehrig/rootpack/arp603_export.01.MPIGNU640.x/bin/MASTERODB'
+#  PGD = '/Users/romainroehrig/rootpack/arp603_export.01.MPIGNU640.x/bin/PGD'
+#  PREP = '/Users/romainroehrig/rootpack/arp603_export.01.MPIGNU640.x/bin/PREP'
+#elif model == 'AROME':
+#  config = 'AROME_OPER'
+#  cycle = '41t1_op1.11_MUSC'
+#  MASTER ='/home/honnert/Bureau/MUSC/pack/' + cycle + '/bin/MASTERODB'
+#elif model == 'ARPEGE':
+#  config = 'ARPEGE_OPER'
+#  cycle = '41t1_op1.11_MUSC'
+#  MASTER = '/home/honnert/Bureau/MUSC/pack/' + cycle + '/bin/MASTERODB'
 
 repnamelist = os.getcwd() + '/WAVE{0}/namelist'.format(nwave) 
@@ -33,5 +43,4 @@
   fout = 'config_{0}_{1}.{2}_{3}-{4:0>3}.py'.format(cycle,config,name,nwave,i+1)
   g = open(fout,'w')
-  print >> g, "rep0 = '{0}'\n".format(rep0)
   print >> g, "config = '{0}.{1}_{2}-{3:0>3}'".format(config,name,nwave,i+1)
   print >> g, "cycle = '{0}'".format(cycle)
@@ -42,5 +51,5 @@
   print >> g, "namATMref = '{0}/namref.{1}_{2}-{3:0>3}'".format(repnamelist,name,nwave,i+1)
   if model == 'ARPCLIMAT':
-    print >> g, "namSFXref = rep0 + '/main/namelist/SURFEX/nam.sfx.tl127.CMIP6.v631'"
+    print >> g, "namSFXref = '{0}'".format(namsfx)
   g.close()
 
Index: /models/AROME/serie_AROME.sh
===================================================================
--- /models/AROME/serie_AROME.sh	(revision 85)
+++ /models/AROME/serie_AROME.sh	(revision 86)
@@ -3,10 +3,8 @@
 #set -ex
 
-if [ $# = 0 ] || [ $# = 1 ] ; then
-cat <<eod
-Use : serie_AROME.sh CASE SUBCASE
-eod
-exit
-fi
+if [ $# -lt 2 ] ; then
+   echo Use : ./serie_AROME.sh CASE SUBCASE WAVE
+   exit 1 ; fi
+
 
 DIRMUSC=$REP_MUSC
@@ -23,7 +21,7 @@
 subcase=$2
 name='SCM'
-nwave=1
-
-PARAM=$WORKDIR/WAVE1/Par1D_Wave${nwave}.asc
+nwave=$3
+
+PARAM=$WORKDIR/WAVE${nwave}/Par1D_Wave${nwave}.asc
 
 repout=$WORKDIR/WAVE${nwave}/${case}/${subcase}
@@ -31,9 +29,10 @@
 DIRCONFIG=$WORKDIR/WAVE$nwave/config
 
-
 # A few variables in the environment to specify the simulation configuration (model component)
 # Please edit param_AROME
 
 . ./param_AROME
+# Type of cleaning : no, nc, lfa, nclfa, all
+clean='no'
 
 #Use for rerunning some simulations in case of some (random) crashes (useful on mac)
@@ -128,4 +127,17 @@
     rm -f $DIRMUSC/SURFEX/${cycle}/${simuREF}.${name}_${nwave}-$i
   fi
+  if [ $clean == 'nc' ]; then
+    rm -rf $DIRMUSC/simulations/${cycle}/${simuREF}.${name}_${nwave}-$i/L${nlev}_${timestep}s/$case/$subcase/Output/netcdf/*.nc
+  fi
+  if [ $clean == 'lfa' ]; then
+    rm -rf $DIRMUSC/simulations/${cycle}/${simuREF}.${name}_${nwave}-$i/L${nlev}_${timestep}s/$case/$subcase/Output/LFAf/*.lfa
+  fi
+  if [ $clean == 'nclfa' ]; then
+    rm -rf $DIRMUSC/simulations/${cycle}/${simuREF}.${name}_${nwave}-$i/L${nlev}_${timestep}s/$case/$subcase/Output/netcdf/*.nc
+    rm -rf $DIRMUSC/simulations/${cycle}/${simuREF}.${name}_${nwave}-$i/L${nlev}_${timestep}s/$case/$subcase/Output/LFAf/*.lfa
+  fi
+  if [ $clean == 'all' ]; then
+    rm -rf $DIRMUSC/simulations/${cycle}/${simuREF}.${name}_${nwave}-$i
+  fi
 done
 
@@ -172,5 +184,9 @@
   run_MUSC_cases.py $DIRCONFIG/config_${cycle}_${simuREF}.${name}_${nwave}-$i.py $case $subcase
 # Pour être cohérent avec le calcul fait sur les LES
-  cdo houravg $DIRMUSC/simulations/${cycle}/${simuREF}.${name}_${nwave}-$i/L${nlev}_${timestep}s/$case/$subcase/Output/netcdf/Out_klevel.nc $repout/${name}_${nwave}-$i.nc || echo $i >> $WORKDIR/$ERROUT
+  cdo houravg $DIRMUSC/simulations/${cycle}/${simuREF}.${name}_${nwave}-$i/L${nlev}_${timestep}s/$case/$subcase/Output/netcdf/Out_klevel.nc $repout/tmp_${name}_${nwave}-$i.nc || echo $i >> $WORKDIR/$ERROUT
+  #cdo houravg $DIRMUSC/simulations/${cycle}/${simuREF}.${name}_${nwave}-$i/L${nlev}_${timestep}s/$case/$subcase/Output/netcdf/Out_klevel.nc $repout/${name}_${nwave}-$i.nc || echo $i >> $WORKDIR/$ERROUT
+  cd  $repout
+  ncks -v wpvp_conv,wpthp_conv,wpthp_pbl,wpup_conv,wpup_pbl,wpqp_conv,wpqp_pbl -d levh,1,91 tmp_${name}_${nwave}-$i.nc ${name}_${nwave}-$i.nc
+
   if [ $model == 'ARPCLIMAT' ]; then
     rm -f $DIRMUSC/SURFEX/${cycle}/${simuREF}.${name}_${nwave}-$i
Index: /models/LMDZ/serie_LMDZ.sh
===================================================================
--- /models/LMDZ/serie_LMDZ.sh	(revision 85)
+++ /models/LMDZ/serie_LMDZ.sh	(revision 86)
@@ -18,5 +18,5 @@
 
 
-LMDZdir=/home/couvreux/TUNING/HighTune/../../LMDZtrunk
+LMDZdir=/home/honnert/HighTune/../../LMDZtrunk
 EXPE=`pwd`/WAVE$WAVEN
 
