Index: trunk/libIGCM/libIGCM_config/libIGCM_config.ksh
===================================================================
--- trunk/libIGCM/libIGCM_config/libIGCM_config.ksh	(revision 1558)
+++ trunk/libIGCM/libIGCM_config/libIGCM_config.ksh	(revision 1565)
@@ -111,10 +111,53 @@
   if ( [ ! X${config_UserChoices_SpaceName} = X ] && [ ! X${config_UserChoices_ExperimentName} = X ] ) ; then
     FreeName=$( echo ${config_UserChoices_JobName} | sed 's/.*_//' )
-    if ( [ ! X${config_Ensemble_EnsembleName} = X ] && [ ! X${config_Ensemble_EnsembleDate} = X ] ) ; then
-      R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${config_Ensemble_EnsembleName}/${config_Ensemble_EnsembleDate}/${FreeName}
-      R_FIGR=${R_FIG}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${config_Ensemble_EnsembleName}/${config_Ensemble_EnsembleDate}/${FreeName}
-      R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${config_Ensemble_EnsembleName}/${config_Ensemble_EnsembleDate}/${FreeName}
-      R_DODS=${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${config_Ensemble_EnsembleName}/${config_Ensemble_EnsembleDate}/${FreeName}
-      R_CMIP=${CMIP6_BUF}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${config_Ensemble_EnsembleName}/${config_Ensemble_EnsembleDate}/${FreeName}
+
+    if ( [ X${config_Post_StorageCMIP} = XSCRATCH ] || [ X${config_Post_StorageCMIP} = Xscratch ] ) ; then
+      IGCM_debug_Print 1 "LIBIGCM CONFIG:: SCRATCH R_BUF=${R_BUF}"
+      StoreCMIP=${R_BUF}
+    elif ( [ X${config_Post_StorageCMIP} = XSTORE ] || [ X${config_Post_StorageCMIP} = Xstore ] ) ; then
+      IGCM_debug_Print 1 "LIBIGCM CONFIG:: SCRATCH R_OUT=${R_OUT}"
+      StoreCMIP=${R_OUT}
+    else
+      IGCM_debug_Print 1 "LIBIGCM CONFIG:: ELSE CMIP_BUF=${CMIP6_BUF}"
+      StoreCMIP=${CMIP6_BUF}
+    fi
+    # Ensemble cases (default all members outputs in same directory)
+    if ( [ ! X${config_Ensemble_EnsembleName} = X ] ) ; then
+      R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${config_Ensemble_EnsembleName}
+      R_FIGR=${R_FIG}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${config_Ensemble_EnsembleName}
+      R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${config_Ensemble_EnsembleName}
+      R_DODS=${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${config_Ensemble_EnsembleName}
+      R_CMIP=${StoreCMIP}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${config_Ensemble_EnsembleName}
+      IGCM_debug_Print 1 "LIBIGCM CONFIG:: ENSEMBLE R_CMIP=${R_CMIP}"
+
+      # PERTURB Ensemble Outputs
+      if ( [ X${config_Ensemble_EnsembleType} = XEns_PERTURB ] ) ; then
+	if ( [ ! X${config_Ensemble_EnsembleDate} = X ] ) ; then
+          R_SAVE=${R_SAVE}/${config_Ensemble_EnsembleDate}/${FreeName}
+	  R_FIGR=${R_FIGR}/${config_Ensemble_EnsembleDate}/${FreeName}
+	  R_BUFR=${R_BUFR}/${config_Ensemble_EnsembleDate}/${FreeName}
+	  R_DODS=${R_DODS}/${config_Ensemble_EnsembleDate}/${FreeName}
+	  R_CMIP=${R_CMIP}/${config_Ensemble_EnsembleDate}/${FreeName}
+	else
+	  R_SAVE=${R_SAVE}/${FreeName}
+	  R_FIGR=${R_FIGR}/${FreeName}
+	  R_BUFR=${R_BUFR}/${FreeName}
+	  R_DODS=${R_DODS}/${FreeName}
+	  R_CMIP=${R_CMIP}/${FreeName}
+	fi
+      # DATE Ensemble Outputs
+      elif ( [ X${config_Ensemble_EnsembleType} = XEns_DATE ] ) ; then
+	R_FIGR=${R_FIGR}/${FreeName}
+	R_BUFR=${R_BUFR}/${FreeName}
+	R_DODS=${R_DODS}/${FreeName}
+	IGCM_debug_Print 1 "LIBIGCM CONFIG:: ENSEMBLE DATE R_CMIP=${R_CMIP}"
+        if ( [ X${config_Ensemble_EnsembleMergeSave} = X ] || [ X${config_Ensemble_EnsembleMergeSave} = Xn ] || 
+	     [ X${config_Ensemble_EnsembleMergeSave} = Xno ] ) ; then
+	  # One SAVE directory per member, else common output dir for all members
+          R_SAVE=${R_SAVE}/${FreeName}
+	  R_CMIP=${R_CMIP}/${FreeName}
+	  IGCM_debug_Print 1 "LIBIGCM CONFIG:: ENSEMBLE DATE MERGE R_CMIP=${R_CMIP}"
+	fi
+      fi
     else
       R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName}
@@ -122,5 +165,5 @@
       R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName}
       R_DODS=${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName}
-      R_CMIP=${CMIP6_BUF}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName}
+      R_CMIP=${StoreCMIP}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName}
     fi
   else
@@ -137,5 +180,7 @@
     fi
   fi
-
+  
+  IGCM_debug_Print 1 "LIBIGCM CONFIG:: R_CMIP = ${R_CMIP}"
+  
   #====================================================
   # Define R_OUT_KSH : Storage place for job output
Index: trunk/libIGCM/libIGCM_ensemble/libIGCM_ensemble.ksh
===================================================================
--- trunk/libIGCM/libIGCM_ensemble/libIGCM_ensemble.ksh	(revision 1558)
+++ trunk/libIGCM/libIGCM_ensemble/libIGCM_ensemble.ksh	(revision 1565)
@@ -29,6 +29,6 @@
 #                         : removed Ens_PERTURB_PERTU_MAP_LIST case
 # 
-# Author: Simona Flavoni & Nicola Lebas
-# Contact: Simona.Flavoni__at__locean-ipsl.upmc.fr
+# Author: Simona Flavoni & Nicolas Lebas
+# Contact: Simona.Flavoni__at__locean.ipsl.fr & Nicolas.Lebas__at__locean.ipsl.fr
 # IPSL (2019)
 #**************************************************************
@@ -38,14 +38,22 @@
 {
   IGCM_debug_PushStack "IGCM_ensemble_Init"
-
+  
   IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_PERTURB active
   IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_DATE active
- 
-  Job_Period=10 # PARAMETER USED in function IGCM_ensemble_FilesUpdate
-
+  
+  Job_Period=10 # Default PARAMETER USED in function IGCM_ensemble_FilesUpdate
+  answer=""
+  print - "\nHit Enter or give PERIOD_NB for all member's Job (default is 10)"
+  read answer
+  
+  if [ "X${answer}" != "X" ] ; then
+      Job_Period=${answer}
+  fi
+  print "\nPeriodNb in ensemble Jobs is ${Job_Period}"
+  
   IGCM_debug_Print 1 "Ens_PERTURB ACTIVE     = ${ensemble_Ens_PERTURB_active}"
   IGCM_debug_Print 1 "Ens_DATE ACTIVE        = ${ensemble_Ens_DATE_active}"
   echo ""
-
+  
   #====================================================
   # Define ARCHIVE : Dedicated to large files
@@ -55,5 +63,5 @@
   # Define R_BUF   : USELESS and DEPRECATED output tree.
   IGCM_sys_defineArchives
-
+  
   IGCM_debug_PopStack "IGCM_ensemble_Init"
 }
@@ -139,8 +147,8 @@
   # ==> config.card
   # [ENSEMBLE]
-  IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Ensemble EnsembleRun 'y'
   IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Ensemble EnsembleName $(eval echo $\ensemble_Ens_${EnsembleType}_NAME)
   IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Ensemble EnsembleDate ${HumanDateBegin}
   IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Ensemble EnsembleType "Ens_${EnsembleType}"
+  IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Ensemble EnsembleMergeSave ${ensemble_Ens_DATE_MERGE_SAVE}
   
   # [UserChoices]
@@ -369,6 +377,8 @@
       IGCM_sys_Mkdir ${SUBMIT_DIR}/${StartDir}
       IGCM_sys_Cd ${SUBMIT_DIR}/${StartDir}
-      ln -s ../../.resol .
-      ln -s ../../.libmpi .
+      ln -s ../../.resol .                        # TODO: remove for future version (>6.1)
+      ln -s ../../.libmpi .                       # TODO: remove for future version (>6.1)
+      ln -s ../../SOURCES .
+      ln -s ../../ARCH .
       IGCM_sys_Cd ${RUN_DIR}
     fi
@@ -470,6 +480,8 @@
     IGCM_sys_Mkdir ${SUBMIT_DIR}/${StartDir}
     IGCM_sys_Cd ${SUBMIT_DIR}/${StartDir}
-    ln -s ../../.resol .
-    ln -s ../../.libmpi .
+    ln -s ../../.resol .                        # TODO: remove for future version (>6.1)
+    ln -s ../../.libmpi .                       # TODO: remove for future version (>6.1)
+    ln -s ../../SOURCES .
+    ln -s ../../ARCH .
     IGCM_sys_Cd ${RUN_DIR}
   fi
@@ -773,7 +785,5 @@
   IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_DATE active
   IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_DATE NAME
-  IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_DATE BEGIN_INIT
-  IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_DATE BEGIN_RESTART
-  IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_DATE END_INIT
+  IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_DATE MERGE_SAVE
   IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_DATE STARTDATE
   IGCM_card_DefineArrayFromOption    ${F_CFG_ENS} Ens_DATE NONPERIODIC
@@ -794,7 +804,5 @@
   IGCM_debug_Print 1 "ACTIVE               = ${ensemble_Ens_DATE_active}"
   IGCM_debug_Print 1 "NAME                 = ${ensemble_Ens_DATE_NAME}"
-  IGCM_debug_Print 1 "BEGIN_INIT           = ${ensemble_Ens_DATE_BEGIN_INIT}"
-  IGCM_debug_Print 1 "END_INIT             = ${ensemble_Ens_DATE_END_INIT}"
-  IGCM_debug_Print 1 "BEGIN_RESTART        = ${ensemble_Ens_DATE_BEGIN_RESTART}"
+  IGCM_debug_Print 1 "MERGE_SAVE           = ${ensemble_Ens_DATE_MERGE_SAVE}"
   IGCM_debug_Print 1 "STARTDATE            = ${ensemble_Ens_DATE_STARTDATE}"
   IGCM_debug_Print 1 "NONPERIODIC          = ${ensemble_Ens_DATE_NONPERIODIC[*]}"
@@ -828,8 +836,4 @@
   # A few checks for the Non-Periodic case:
   # ***************************************
-#  if [[ ${#ensemble_Ens_DATE_NONPERIODIC[*]} != ${#ensemble_Ens_DATE_RESTART_NONPERIODIC[*]} ]] ; then
-#    IGCM_debug_Exit "IGCM_ensemble_DateInit: NONPERIODIC and RESTART_NONPERIODIC lists have different sizes"
-#    IGCM_debug_Verif_Exit
-#  fi
 
   if [[ ${#ensemble_Ens_DATE_RESTART_NONPERIODIC[*]} > 0 ]] && [[ ${ensemble_Ens_DATE_RESTART_NONPERIODIC[*]} != _0_ ]]; then
@@ -837,13 +841,12 @@
 
     # Use LENGTH if no NONPERIODIC_LENGTH given
-    if [[ ${#ensemble_Ens_DATE_LENGTH_NONPERIODIC[*]} < ${#ensemble_Ens_DATE_NONPERIODIC[*]} ]] ||
-	   [[ X"${ensemble_Ens_DATE_LENGTH_NONPERIODIC[0]}" = "XOption" ]] ; then
+    if ( [ ${#ensemble_Ens_DATE_LENGTH_NONPERIODIC[*]} -lt ${#ensemble_Ens_DATE_NONPERIODIC[*]} ] || [[ "X${ensemble_Ens_DATE_LENGTH_NONPERIODIC[0]}" = "XOption" ]] ) ; then
 	IGCM_debug_Print 1 "WARNING: LENGTH_NONPERIODIC is not fill (or not correctly). "
 	IGCM_debug_Print 1 "Use LENGTH value '${ensemble_Ens_DATE_LENGTH}' for all NONPERIODIC runs"
-      DateNum=0
-      while [ ${DateNum} -lt ${#ensemble_Ens_DATE_NONPERIODIC[*]} ] ; do
-        ensemble_Ens_DATE_LENGTH_NONPERIODIC[${DateNum}]=${ensemble_Ens_DATE_LENGTH}
-        (( DateNum = DateNum + 1 ))
-      done
+	DateNum=0
+	while [ ${DateNum} -lt ${#ensemble_Ens_DATE_RESTART_NONPERIODIC[*]} ] ; do
+            ensemble_Ens_DATE_LENGTH_NONPERIODIC[${DateNum}]=${ensemble_Ens_DATE_LENGTH}
+            (( DateNum = DateNum + 1 ))
+	done
     fi
     
@@ -864,5 +867,5 @@
       IGCM_debug_Print 1 "WARNING: INITFROM_NONPERIODIC is not fill (or not correctly). Use INITFROM value '${ensemble_Ens_DATE_INITFROM}' for all NONPERIODIC runs"
       DateNum=0
-      while [ ${DateNum} -lt ${#ensemble_Ens_DATE_NONPERIODIC[*]} ] ; do
+      while [ ${DateNum} -lt ${#ensemble_Ens_DATE_RESTART_NONPERIODIC[*]} ] ; do
         ensemble_Ens_DATE_INITFROM_NONPERIODIC[${DateNum}]=${ensemble_Ens_DATE_INITFROM}
         (( DateNum = DateNum + 1 ))
@@ -874,5 +877,5 @@
       IGCM_debug_Print 1 "WARNING: INITPATH_NONPERIODIC is not fill (or not correctly). Use INITPATH value '${ensemble_Ens_DATE_INITPATH}' for all NONPERIODIC runs"
       DateNum=0
-      while [ ${DateNum} -lt ${#ensemble_Ens_DATE_NONPERIODIC[*]} ] ; do
+      while [ ${DateNum} -lt ${#ensemble_Ens_DATE_RESTART_NONPERIODIC[*]} ] ; do
         ensemble_Ens_DATE_INITPATH_NONPERIODIC[${DateNum}]=${ensemble_Ens_DATE_INITPATH}
         (( DateNum = DateNum + 1 ))
@@ -934,6 +937,8 @@
     IGCM_sys_Mkdir ${SUBMIT_DIR}/${StartDir}
     IGCM_sys_Cd ${SUBMIT_DIR}/${StartDir}
-    ln -s ../../.resol .
-    ln -s ../../.libmpi .
+    ln -s ../../.resol .                        # TODO: remove for future version (>6.1)
+    ln -s ../../.libmpi .                       # TODO: remove for future version (>6.1)
+    ln -s ../../SOURCES .
+    ln -s ../../ARCH .
     IGCM_sys_Cd ${RUN_DIR}
   fi
@@ -949,5 +954,10 @@
     (( ii=DateNum + 1 ))
     
-    MemberDir="${ensemble_Ens_DATE_NAME}${ii}"
+    # Member number on 2 digits (01 02 ... 10 11)
+    if (( ii < 10)) then
+	MemberDir="${ensemble_Ens_DATE_NAME}-0${ii}"
+    else
+	 MemberDir="${ensemble_Ens_DATE_NAME}-${ii}"
+    fi
     IGCM_debug_Print 3 "${MemberDir}"
     echo "Create: ${MemberDir}"
