Index: trunk/libIGCM/ins_job
===================================================================
--- trunk/libIGCM/ins_job	(revision 1488)
+++ trunk/libIGCM/ins_job	(revision 1489)
@@ -359,5 +359,6 @@
       echo "Directory ${j}/${JobName} exists already. It will not be overwritten."
       echo "Remove the existing directory or change JobName before relaunching ins_job."
-      continue
+      #continue
+      exit  
     fi
     echo "=> Submit directory ${JobName} will be created with cards from EXPERIMENTS/${config_UserChoices_ExpType}"
@@ -370,5 +371,5 @@
     fi
     rm -f ${j}/${F_CFG}
-    rm -f ${j}/${F_CFG_ENS}
+    # rm -f ${j}/${F_CFG_ENS}
     rm -f ${j}/${F_CFG}.bak
     j=${j}/${JobName}
@@ -452,4 +453,13 @@
 # Limited to hindcast/forecast and date restart Ensemble for the time being
 if [ ${x_e} = 'true' ] ; then
+    if [ ! -f ${F_CFG_ENS} ] ; then
+       echo ""
+       echo "################## WARNING ##################"
+       echo "No ensemble.card available in current directory"
+       echo ""
+       exit
+      #  continue
+   fi
+
   #.. Read input data from ensemble.card ..
   SUBMIT_DIR=${SUBMIT_DIR_ENS}
@@ -460,8 +470,4 @@
   IGCM_ensemble_Init
 
-  if [[ ${ensemble_Ens_PARAMETRIC_active} = 'y' ]] ; then
-    echo "WARNING: Parametric Ensemble is not implemented yet..."
-  fi
-
   if [[ ${ensemble_Ens_DATE_active} = 'y' ]] ; then
     IGCM_sys_Cd ${SUBMIT_DIR}
@@ -469,10 +475,5 @@
     # As it says
     IGCM_sys_Cd ${SUBMIT_DIR}
-    IGCM_ensemble_DatePeriodicStarts
-    # As it says
-    IGCM_sys_Cd ${SUBMIT_DIR}
     IGCM_ensemble_DateNonPeriodicStarts
-    # Clean
-    IGCM_sys_Rm -rf ${RUN_DIR}
   fi
 
@@ -484,15 +485,12 @@
     IGCM_ensemble_CastPeriodicStarts
     # As it says
-    IGCM_sys_Cd ${SUBMIT_DIR}
-    IGCM_ensemble_CastNonPeriodicStarts
-    # As it says
-    IGCM_sys_Cd ${SUBMIT_DIR}
-    IGCM_ensemble_CastMemberList
-    # Done
-    #IGCM_sys_Cp ${RUN_DIR}/CreatedDir.txt ${SUBMIT_DIR}
-    IGCM_sys_Cd ${SUBMIT_DIR}
-    # Clean
-    IGCM_sys_Rm -rf ${RUN_DIR}
-  fi
+    #IGCM_sys_Cd ${SUBMIT_DIR}
+    #IGCM_ensemble_CastMemberList
+  fi
+  # Done
+  IGCM_sys_Cd ${SUBMIT_DIR}
+  # Clean
+  IGCM_sys_Rm -rf ${RUN_DIR}
+  
 fi
 #-
Index: trunk/libIGCM/libIGCM_ensemble/libIGCM_ensemble.ksh
===================================================================
--- trunk/libIGCM/libIGCM_ensemble/libIGCM_ensemble.ksh	(revision 1488)
+++ trunk/libIGCM/libIGCM_ensemble/libIGCM_ensemble.ksh	(revision 1489)
@@ -21,4 +21,15 @@
 # IPSL (2014)
 #
+# >>> Uniform DATE and PERTURB ensemble (remove old, useless), ADD some functions <<<
+# add : IGCM_ensemble_InitRunDir, IGCM_ensemble_FilesUpdate (unique function)
+# DATE           ensemble : removed periodic case
+#                         : all dates are NON-periodic
+# CAST PERTURBED ensemble : removed NON-periodic case
+#                         : all casts are periodic (*Y or *M)
+#                         : removed Ens_PERTURB_PERTU_MAP_LIST case
+# 
+# Author: Simona Flavoni & Nicola Lebas
+# Contact: Simona.Flavoni__at__locean-ipsl.upmc.fr
+# IPSL (2019)
 #**************************************************************
 
@@ -30,9 +41,9 @@
   IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_PERTURB active
   IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_DATE active
-  IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_PARAMETRIC active
+ 
+  Job_Period=10 # PARAMETER USED in function IGCM_ensemble_FilesUpdate
 
   IGCM_debug_Print 1 "Ens_PERTURB ACTIVE     = ${ensemble_Ens_PERTURB_active}"
   IGCM_debug_Print 1 "Ens_DATE ACTIVE        = ${ensemble_Ens_DATE_active}"
-  IGCM_debug_Print 1 "Ens_PARAMETRIC ACTIVE  = ${ensemble_Ens_PARAMETRIC_active}"
   echo ""
 
@@ -48,20 +59,13 @@
 }
 
-# Set Alphanumerical variables ajust to member nb
-function IGCM_ensemble_SetAlpha
-{
-  IGCM_debug_PushStack "IGCM_ensemble_SetAlpha"
-
-  set -A Alpha      A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
-  set -A AlphaMonth a b c d e f g h i j k l
-
-  IGCM_debug_PopStack "IGCM_ensemble_SetAlpha"
-}
-
-############### Perturb ENSEMBLE #################
-function IGCM_ensemble_CastInit
-{
-  IGCM_debug_PushStack "IGCM_ensemble_CastInit"
-
+
+############### ENSEMBLE #################
+function IGCM_ensemble_InitRunDir
+{
+
+  if [ -d ${SUBMIT_DIR}/${JobName} ] ; then
+    IGCM_debug_Print 3 "STOP directory ${SUBMIT_DIR}/${JobName} already exists."
+    exit # SF: stop at this point because in ENSEMBLE case need to be stopped 
+  fi
   IGCM_sys_Mkdir ${RUN_DIR}
 
@@ -76,20 +80,116 @@
     IGCM_sys_Cp ${SUBMIT_DIR}/Qclean.*      ${RUN_DIR}
   fi
+
+}
+
+############### Create Member Directory ENSEMBLE ################# 
+function IGCM_ensemble_CreateMemberDir
+{
+
+ #  if [ ! -d  ${SUBMIT_DIR}/${StartDir}/${MemberDir} ] ; then
+     IGCM_sys_Mkdir ${SUBMIT_DIR}/${StartDir}/${MemberDir}
+     IGCM_sys_Cd ${SUBMIT_DIR}/${StartDir}/${MemberDir}
+     ln -s ../../COMP
+     ln -s ../../PARAM
+     ln -s ../../POST
+     ln -s ../../DRIVER
+     IGCM_sys_Cd ${RUN_DIR}
+     IGCM_sys_Cp config.card run.card.init ${SUBMIT_DIR}/${StartDir}/${MemberDir}
+     IGCM_sys_Cp Job_${config_UserChoices_JobName} ${SUBMIT_DIR}/${StartDir}/${MemberDir}/${JobName}
+
+     # Dump command to be lauched
+     echo "cd ${StartDir}/${MemberDir}/ ;"    >> ${RUN_DIR}/Qsub.${StartDir}.sh
+     echo "${SUBMIT} ${JobName} ; cd -"       >> ${RUN_DIR}/Qsub.${StartDir}.sh
+
+     echo "cd ${StartDir}/${MemberDir}/ ;"    >> ${RUN_DIR}/Qclean.latestPackperiod.${StartDir}.sh
+     echo "${libIGCM}/clean_latestPackperiod.job ; cd -"  >> ${RUN_DIR}/Qclean.latestPackperiod.${StartDir}.sh
+
+     echo "cd ${StartDir}/${MemberDir}/ ;"    >> ${RUN_DIR}/Qclean.PeriodLength.${StartDir}.sh
+     echo "${libIGCM}/clean_PeriodLength.job ; cd -"  >> ${RUN_DIR}/Qclean.PeriodLength.${StartDir}.sh
+
+}
+
+
+############### FilesUpdate ENSEMBLE #################
+function IGCM_ensemble_FilesUpdate
+{
+  IGCM_debug_PushStack "IGCM_ensemble_FilesUpdate"
+
+  # Debug Print :
+  echo 
+  IGCM_debug_Print 1 "IGCM_ensemble_FilesUpdate :"
+
+  EnsembleType=${1}
+  MemberNb=${2}
+  HumanDateBegin=$(   IGCM_date_ConvertFormatToHuman ${3} )
+  HumanDateEnd=$(     IGCM_date_ConvertFormatToHuman ${4} )
+  HumanRestartDate=$( IGCM_date_ConvertFormatToHuman ${5} )
+  if [[ X${6} != "X" ]]; then 
+    initFrom=${6} # non periodic config (INITFROM could be different between members)
+  else 
+    initFrom=$(eval echo $\ensemble_Ens_${EnsembleType}_INITFROM) # periodic (same INITFROM value)
+  fi
+
+  if [[ X${7} != "X" ]]; then 
+    initPath=${7} # non periodic config (INITPATH could be different between members)
+  else 
+    initPath=$(eval echo $\ensemble_Ens_${EnsembleType}_INITPATH) # periodic (same INITPATH value)
+  fi
   
-  ## Init some variables
-  CastPeriodicStart=false
-  CastNonPeriodicStart=false
-  CastRestartNonPer=false
-  CastLengthNonPer=false
+  # ==> 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}"
   
-  # Useful?
-  #if [ -f  ${SUBMIT_DIR}/CreatedDir.txt ] ; then
-  #  IGCM_sys_Cp ${SUBMIT_DIR}/CreatedDir.txt ${RUN_DIR}
-  #fi
-  # Useful?
-  #if [ -f  ${SUBMIT_DIR}/Qsub.sh ] ; then
-  #  IGCM_sys_Cp ${SUBMIT_DIR}/Qsub.sh ${RUN_DIR}
-  #fi
-  echo ${PWD}
+  # [UserChoices]
+  IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card UserChoices JobName   ${MemberDir}
+  IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card UserChoices DateBegin ${HumanDateBegin}
+  IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card UserChoices DateEnd   ${HumanDateEnd}
+  # Adhoc exceptioN for CMIP6 : update realisation number in member field.
+  if ( [ X"$( echo ${config_UserChoices_ExpType} | grep CMIP6 )" != "X" ] ) ; then
+      IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card UserChoices Member "r${MemberNb}i1p1f1"
+  fi
+
+  # [Restarts]
+  IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Restarts OverRule "n"
+  # [ATM/OCE/...]
+  for comp in ${config_ListOfComponents[*]} ; do
+    IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${comp} Restart "y"
+    IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${comp} RestartDate ${HumanRestartDate}
+    IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${comp} RestartJobName ${initFrom}
+    IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${comp} RestartPath ${initPath}
+
+    # Adhoc exception for CMIP6 : exclude XIOS from the restart overrule mechanism.
+    if ( [ X${comp} = XIOS ] && [ X"$( echo ${config_UserChoices_ExpType} | grep CMIP6 )" != "X" ] ) ; then
+    IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${comp} Restart "n"
+    fi
+  done
+
+  unset initFrom
+
+  # ==> Job
+  sed -e "s/\(#.*Script_Output_\)${config_UserChoices_JobName}\(\.*\)/\1${MemberDir}\2/" \
+      -e "s/\(#.*\)${config_UserChoices_JobName}\(\.*\)/\1${MemberDir} \2/"              \
+      -e "s/^PeriodNb=.*/PeriodNb=${Job_Period}/"                                        \
+      ${SUBMIT_DIR}/${StartDir}/${MemberDir}/Job_${MemberDir} > Job_${MemberDir}.tmp
+  IGCM_sys_Mv Job_${MemberDir}.tmp ${SUBMIT_DIR}/${StartDir}/${MemberDir}/Job_${MemberDir}
+
+  IGCM_debug_PopStack "IGCM_ensemble_FilesUpdate"
+}
+
+
+############### Perturb ENSEMBLE #################
+function IGCM_ensemble_CastInit
+{
+  IGCM_debug_PushStack "IGCM_ensemble_CastInit"
+
+  IGCM_ensemble_InitRunDir
+  
+  ## Init some variables (only periodic case)
+  CastPeriodicStart=true
+  
+  echo " pwd id : ${PWD}"
 
   IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_PERTURB active
@@ -98,10 +198,6 @@
   IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_PERTURB END_INIT
   IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_PERTURB PERIODICITY
-  IGCM_card_DefineArrayFromOption    ${F_CFG_ENS} Ens_PERTURB NONPERIODIC
-  IGCM_card_DefineArrayFromOption    ${F_CFG_ENS} Ens_PERTURB RESTART_NONPERIODIC
   IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_PERTURB LENGTH
-  IGCM_card_DefineArrayFromOption    ${F_CFG_ENS} Ens_PERTURB LENGTH_NONPERIODIC
   IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_PERTURB MEMBER
-  IGCM_card_DefineArrayFromOption    ${F_CFG_ENS} Ens_PERTURB PERTU_MAP_LIST
   IGCM_card_DefineArrayFromOption    ${F_CFG_ENS} Ens_PERTURB MEMBER_NAMESLIST
   IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_PERTURB MEMBER_INITFROM
@@ -122,10 +218,6 @@
   IGCM_debug_Print 1 "END_INIT          = ${ensemble_Ens_PERTURB_END_INIT}"
   IGCM_debug_Print 1 "PERIODICITY       = ${ensemble_Ens_PERTURB_PERIODICITY}"
-  IGCM_debug_Print 1 "NONPERIODIC       = ${ensemble_Ens_PERTURB_NONPERIODIC[*]}"
-  IGCM_debug_Print 1 "RESTART_NONPERIODIC=${ensemble_Ens_PERTURB_RESTART_NONPERIODIC[*]}"
   IGCM_debug_Print 1 "LENGTH            = ${ensemble_Ens_PERTURB_LENGTH}"
-  IGCM_debug_Print 1 "LENGTH_NONPERIODIC= ${ensemble_Ens_PERTURB_LENGTH_NONPERIODIC[*]}"
   IGCM_debug_Print 1 "MEMBER            = ${ensemble_Ens_PERTURB_MEMBER}"
-  IGCM_debug_Print 1 "PERTU_MAP_LIST    = ${ensemble_Ens_PERTURB_PERTU_MAP_LIST[*]}"
   IGCM_debug_Print 1 "MEMBER_NAMESLIST  = ${ensemble_Ens_PERTURB_MEMBER_NAMESLIST[*]}"
   IGCM_debug_Print 1 "MEMBER_INITFROM   = ${ensemble_Ens_PERTURB_MEMBER_INITFROM}"
@@ -139,43 +231,8 @@
   IGCM_debug_Print 1 "ListOfComponents  = ${config_ListOfComponents[*]}"
 
-  ### Retro compatibility with former param name ###
-  if [ X"${ensemble_Ens_PERTURB_MEMBER_LIST[0]}" != "XOption" ];
-  then
-      if [ X"${ensemble_Ens_PERTURB_PERTU_MAP_LIST[0]}" = "XOption" ];
-      then
-	  ensemble_Ens_PERTURB_PERTU_MAP_LIST=${ensemble_Ens_PERTURB_MEMBER_LIST}
-	  IGCM_debug_Print 1 "WARNING: PERTU_MAP_LIST is deprecacated, please use PERTURB_PERTU_MAP_LIST instead."
-      else
-	  IGCM_debug_Print 1 "WARNING: both PERTURB_PERTU_MAP_LIST and PERTU_MAP_LIST are specified!"
-	  IGCM_debug_Print 1 "Ignore PERTU_MAP_LIST which is deprecated."
-      fi
-  fi
-  ####### End of retro compatibility code #######
 
   ### Check unset variables and set them to empty
   # Following var are set because they could be unset in some 
   # use case (ex: non periodic if periodic is active...)
-  if [[ X"${ensemble_Ens_PERTURB_RESTART_NONPERIODIC[0]}" = "XOption" || X"${ensemble_Ens_PERTURB_RESTART_NONPERIODIC[0]}" = "X" ]];
-  then 
-      ensemble_Ens_PERTURB_RESTART_NONPERIODIC[0]=_0_
-      CastRestartNonPer=false
-  else
-      CastRestartNonPer=true
-  fi
-  if [[ X"${ensemble_Ens_PERTURB_PERTU_MAP_LIST[0]}" = "XOption" || X"${ensemble_Ens_PERTURB_PERTU_MAP_LIST[0]}" = "X" ]];
-  then 
-      ensemble_Ens_PERTURB_PERTU_MAP_LIST[0]=_0_
-  fi
-  if [[ X"${ensemble_Ens_PERTURB_LENGTH_NONPERIODIC[0]}" = "XOption" || X"${ensemble_Ens_PERTURB_LENGTH_NONPERIODIC[0]}" = "X" ]];
-  then 
-      CastLengthNonPer=false
-      ensemble_Ens_PERTURB_LENGTH_NONPERIODIC[0]=_0_
-  else
-      CastLengthNonPer=true
-  fi
-  if [ X"${ensemble_Ens_PERTURB_NONPERIODIC[0]}" = "XOption" ];
-  then 
-      ensemble_Ens_PERTURB_NONPERIODIC[0]=_0_
-  fi
   if [[ "${ensemble_Ens_PERTURB_PERIODICITY}" = _0_ || "${ensemble_Ens_PERTURB_PERIODICITY}" = '' ]];
   then 
@@ -223,5 +280,4 @@
     ;;
   esac
-  IGCM_ensemble_SetAlpha ${ensemble_Ens_PERTURB_MEMBER}
 
   # A few checks Period case:
@@ -251,111 +307,4 @@
   esac
 
-################################
-  if [[ ${#ensemble_Ens_PERTURB_NONPERIODIC[*]} != ${#ensemble_Ens_PERTURB_RESTART_NONPERIODIC[*]} && CastRestartNonPer = "true" ]] ; then
-    IGCM_debug_Exit "IGCM_ensemble_CastInit: NONPERIODIC and RESTART_NONPERIODIC lists have different sizes"
-    IGCM_debug_Verif_Exit
-  fi
-  if [[ ${#ensemble_Ens_PERTURB_NONPERIODIC[*]} > 0 ]] && [[ ${ensemble_Ens_PERTURB_NONPERIODIC[0]} != _0_ ]]; then
-    DateNonPeriodicStart=true
-    
-    # Use LENGTH if no NONPERIODIC_LENGTH given
-    if [[ ${#ensemble_Ens_PERTURB_LENGTH_NONPERIODIC[*]} < ${#ensemble_Ens_PERTURB_NONPERIODIC[*]} || ${ensemble_Ens_PERTURB_LENGTH_NONPERIODIC[0]} = _0_ ]] ; then
-      IGCM_debug_Print 1 "WARNING: LENGTH_NONPERIODIC is not fill (or not correctly). Use LENGTH value '${ensemble_Ens_PERTURB_LENGTH}' for all NONPERIODIC runs"
-      echo "WARNING: LENGTH_NONPERIODIC is not fill (or not correctly). Use LENGTH value '${ensemble_Ens_PERTURB_LENGTH}' for all NONPERIODIC runs"
-      DateNum=0
-      while [ ${DateNum} -lt ${#ensemble_Ens_PERTURB_NONPERIODIC[*]} ] ; do
-        ensemble_Ens_PERTURB_LENGTH_NONPERIODIC[${DateNum}]=${ensemble_Ens_PERTURB_LENGTH}
-        (( DateNum = DateNum + 1 ))
-      done
-    fi
-    # Check lengths
-    DateNum=0
-    while [ ${DateNum} -lt ${#ensemble_Ens_PERTURB_NONPERIODIC[*]} ] ; do
-	# - Check LENGTH_NONPERIODIC
-	case ${ensemble_Ens_PERTURB_LENGTH_NONPERIODIC[${DateNum}]} in
-	    _0_)
-		IGCM_debug_Print 1 "non-periodic start not active"
-		CastNonPeriodicStart=false
-		break
-		;;
-	    *[Yy]|*[Mm])
-		IGCM_debug_Print 1 "Non-periodic duration : ${ensemble_Ens_PERTURB_LENGTH_NONPERIODIC[${DateNum}]}"
-		CastNonPeriodicStart=true
-		;;
-	    *)
-		IGCM_debug_Exit "IGCM_ensemble_CastInit ${ensemble_Ens_PERTURB_LENGTH_NONPERIODIC[${DateNum}]} : invalid LENGTH"
-		IGCM_debug_Exit "choose in *Y or *M"
-		IGCM_debug_Verif_Exit ;;
-	esac
-	(( DateNum = DateNum + 1 ))
-	
-	# - Check RESTART_NONPERIODIC
-	if [[ DateNonPeriodicStart ]]; then
-	    case ${ensemble_Ens_PERTURB_RESTART_NONPERIODIC[${DateNum}]} in
-		_0_)
-		    IGCM_debug_Exit "IGCM_ensemble_CastInit ${ensemble_Ens_PERTURB_RESTART_NONPERIODIC[${DateNum}]} : invalid NON PERIODIC RESTART"
-		    IGCM_debug_Verif_Exit ;;
-	    esac
-	fi
-    done
-    
-    # Use INITFROM if no INITFROM_NONPERIODIC given
-    if [ ${#ensemble_Ens_PERTURB_INITFROM_NONPERIODIC[*]} -lt ${#ensemble_Ens_PERTURB_NONPERIODIC[*]} ] ; then
-      IGCM_debug_Print 1 "WARNING: INITFROM_NONPERIODIC is not fill (or not correctly). Use INITFROM value '${ensemble_Ens_PERTURB_INITFROM}' for all NONPERIODIC runs"
-      DateNum=0
-      while [ ${DateNum} -lt ${#ensemble_Ens_PERTURB_NONPERIODIC[*]} ] ; do
-        ensemble_Ens_PERTURB_INITFROM_NONPERIODIC[${DateNum}]=${ensemble_Ens_PERTURB_INITFROM}
-        (( DateNum = DateNum + 1 ))
-      done
-    fi
-    
-    # Use INITPATH if no INITPATH_NONPERIODIC given
-    if [ ${#ensemble_Ens_PERTURB_INITPATH_NONPERIODIC[*]} -lt ${#ensemble_Ens_PERTURB_NONPERIODIC[*]} ] ; then
-      IGCM_debug_Print 1 "WARNING: INITPATH_NONPERIODIC is not fill (or not correctly). Use INITPATH value '${ensemble_Ens_PERTURB_INITPATH}' for all NONPERIODIC runs"
-      DateNum=0
-      while [ ${DateNum} -lt ${#ensemble_Ens_PERTURB_NONPERIODIC[*]} ] ; do
-        ensemble_Ens_PERTURB_INITPATH_NONPERIODIC[${DateNum}]=${ensemble_Ens_PERTURB_INITPATH}
-        (( DateNum = DateNum + 1 ))
-      done
-    fi
-  else
-    IGCM_debug_Print 1 "Non-Periodic start NOT ACTIVE"
-    DateNonPeriodicStart=false
-  fi
-################################
-
-  # A few checks for the Non-Periodic case:
-  
-  # A few checks for the PERTU_MAP_LIST case:
-  case ${ensemble_Ens_PERTURB_PERTU_MAP_LIST[0]} in
-  _0_)
-    IGCM_debug_Print 1 "list of perturbation maps not active"
-    CastMemberList=false
-    ;;
-  *)
-    if [ ${CastPeriodicStart} = "true" ] ; then
-      IGCM_debug_Exit "list of perturbation maps for periodic start not implemented, will stop execution"
-      IGCM_debug_Verif_Exit
-    elif [ ${CastNonPeriodicStart} = "true" ] ; then
-      IGCM_debug_Exit "list of perturbation maps for non periodic start not implemented, will stop execution"
-      IGCM_debug_Verif_Exit
-    fi
-
-    # test that MEMBER_NAMESLIST and PERTU_MAP_LIST have the same size
-
-    if [ ${#ensemble_Ens_PERTURB_PERTU_MAP_LIST[*]} -ne ${#ensemble_Ens_PERTURB_MEMBER_NAMESLIST[*]} ] ; then
-      IGCM_debug_Exit "number of elements in PERTU_MAP_LIST and MEMBER_NAMESLIST differ"
-      IGCM_debug_Verif_Exit
-    fi
-
-    IGCM_debug_Print 1 "list of perturbation maps : ${ensemble_Ens_PERTURB_PERTU_MAP_LIST[*]}"
-    IGCM_debug_Print 1 "list of members names : ${ensemble_Ens_PERTURB_MEMBER_NAMESLIST[*]}"
-    CastMemberList=true
-    ;;
-  esac
-
-#  IGCM_debug_Exit "fin du test PERTU_MAP_LIST"
-#  IGCM_debug_Verif_Exit
-
   # Need to know all the restart filename of the component we will apply the noise to
   IGCM_card_DefineArrayFromOption config.card ListOfComponents ${PerturbComp}
@@ -399,11 +348,13 @@
 
   # - Determine number of day(s) in LENGTH
-    DureeLengthInDays=$(( $( IGCM_date_DaysInCurrentPeriod ${DateBegin} ${ensemble_Ens_PERTURB_LENGTH} ) - 1 ))
+    DurationLengthInDays=$(( $( IGCM_date_DaysInCurrentPeriod ${DateBegin} ${ensemble_Ens_PERTURB_LENGTH} ) - 1 ))
 
   # - Determine DateEnd
-    (( DateEnd = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${DureeLengthInDays} ) ))
+    (( DateEnd = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${DurationLengthInDays} ) ))
 
   # - Build directory name
-    IGCM_ensemble_CastDirectoryName ${ensemble_Ens_PERTURB_NAME} ${ensemble_Ens_PERTURB_PERIODICITY} $year $month $StartDir
+    #SF IGCM_ensemble_CastDirectoryName ${ensemble_Ens_PERTURB_NAME} ${ensemble_Ens_PERTURB_PERIODICITY} ${year} ${month} ${StartDir}
+    IGCM_ensemble_CastDirectoryName ${ensemble_Ens_PERTURB_NAME} ${ensemble_Ens_PERTURB_PERIODICITY} ${year} ${month}
+    # StartDir="${ensemble_Ens_PERTURB_NAME}"
 
   # - Determine RestartDate
@@ -428,7 +379,11 @@
 
   # - Loop over members
-    i=0
-    while [ $i -lt ${ensemble_Ens_PERTURB_MEMBER} ] ; do
-      MemberDir="${StartDir}${Alpha[$i]}"
+    i=1
+    while [ $i -le ${ensemble_Ens_PERTURB_MEMBER} ] ; do
+      if [ $((i)) -le 9 ] ; then
+        MemberDir="${StartDir}"-0"$((i))"
+      else 
+        MemberDir="${StartDir}-$((i))"
+      fi
       echo
       IGCM_debug_Print 3 "${MemberDir}"
@@ -438,23 +393,13 @@
     # * Create directory if it doesn't exist and copy/link files
       if [ ! -d  ${SUBMIT_DIR}/${StartDir}/${MemberDir} ] ; then
-        IGCM_sys_Mkdir ${SUBMIT_DIR}/${StartDir}/${MemberDir}
-        IGCM_sys_Cd ${SUBMIT_DIR}/${StartDir}/${MemberDir}
-        ln -s ../../COMP
-        ln -s ../../PARAM
-        ln -s ../../POST
-        ln -s ../../DRIVER
-        IGCM_sys_Cd ${RUN_DIR}
-        IGCM_sys_Cp config.card run.card.init ${SUBMIT_DIR}/${StartDir}/${MemberDir}
-        IGCM_sys_Cp Job_${config_UserChoices_JobName} ${SUBMIT_DIR}/${StartDir}/${MemberDir}/${JobName}
-
-        # Dump command to be lauched
-        echo "cd ${StartDir}/${MemberDir}/ ;"    >> ${RUN_DIR}/Qsub.${StartDir}.sh
-        echo "${SUBMIT} ${JobName} ; cd -"       >> ${RUN_DIR}/Qsub.${StartDir}.sh
-
-        echo "cd ${StartDir}/${MemberDir}/ ;"    >> ${RUN_DIR}/Qclean.PeriodLength.${StartDir}.sh
-        echo "${libIGCM}/clean_PeriodLength.job ; cd -"  >> ${RUN_DIR}/Qclean.PeriodLength.${StartDir}.sh
+     
+        # * Create ${SUBMIT_DIR}/${StartDir}/${MemberDir} directories
+        #   link COMP PARAM POST and DRIVER
+        #   cp config.card, run.card.init, Job_
+        #   and Dump command to be launched 
+        IGCM_ensemble_CreateMemberDir
 
         # * Update files : config.card, Job_, COMP/comp.card
-        IGCM_ensemble_CastFilesUpdate ${DateBegin} ${DateEnd} ${RestartDate}
+        IGCM_ensemble_FilesUpdate "PERTURB" ${i} ${DateBegin} ${DateEnd} ${RestartDate} 
 
         # * Apply noise on restart file
@@ -468,4 +413,5 @@
     IGCM_sys_Cp ${RUN_DIR}/Qsub.${StartDir}.sh ${SUBMIT_DIR}
     IGCM_sys_Cp ${RUN_DIR}/Qclean.PeriodLength.${StartDir}.sh ${SUBMIT_DIR}
+    IGCM_sys_Cp ${RUN_DIR}/Qclean.latestPackperiod.${StartDir}.sh ${SUBMIT_DIR}
 
   # - Next DateBegin
@@ -482,119 +428,4 @@
 }
 
-function IGCM_ensemble_CastNonPeriodicStarts
-{
-  IGCM_debug_PushStack "IGCM_ensemble_CastNonPeriodicStarts"
-
-  #.. Manage non periodic starts => Loop over DateBegin ..
-  #   ==========================
-
-  [ ${CastNonPeriodicStart} = false ] && return
-
-  echo
-  IGCM_debug_Print 1 "Manage non periodic starts"
-
-  DateNum=0
-# ... Loop over ensemble_Ens_PERTURB_NONPERIODIC ...
-  echo ">${DateNum}<"
-  echo ">${#ensemble_Ens_PERTURB_NONPERIODIC[*]}<"
-  while [ ${DateNum} -lt ${#ensemble_Ens_PERTURB_NONPERIODIC[*]} ] ; do
-    DateBegin=${ensemble_Ens_PERTURB_NONPERIODIC[${DateNum}]}
-    Duree=${ensemble_Ens_PERTURB_LENGTH_NONPERIODIC[${DateNum}]}
-    echo ">${DateBegin}<"
-    echo ">${Duree}<"
-
-  # - Determine number of day(s) in LENGTH_NONPERIODIC
-    IGCM_date_GetYearMonth ${DateBegin} year month
-    DureeLengthInDays=$(( $( IGCM_date_DaysInCurrentPeriod ${DateBegin} ${Duree} ) - 1 ))
-
-  # - Build directory name
-    echo "========================================================================"
-    echo "ensemble_Ens_PERTURB_NAME = ${ensemble_Ens_PERTURB_NAME}"
-    IGCM_ensemble_CastDirectoryName ${ensemble_Ens_PERTURB_NAME} ${Duree} $year $month $StartDir
-
-  # - Determine DateEnd
-    (( DateEnd = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${DureeLengthInDays} ) ))
-    echo ">${DateEnd}<"
-    echo "tout va bien 1"
-
-  # - Determine RestartDate
-    if [[ ${CastRestartNonPer} == "true" ]]; then
-        RestartDate=${ensemble_Ens_PERTURB_RESTART_NONPERIODIC[${DateNum}]}
-    else
-        (( Offset = -1 ))
-        (( RestartDate = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${Offset} ) ))
-    fi
-    
-    IGCM_debug_Print 2 "${DateBegin} => ${DateEnd} : ${StartDir}"
-
-  # -  Does $StartDir already exist ?
-    #echo "tout va bien 2" ${StartDir}
-    if [ ! -d ${SUBMIT_DIR}/${StartDir} ] ; then
-      echo "create dir"
-      IGCM_sys_Mkdir ${SUBMIT_DIR}/${StartDir}
-      IGCM_sys_Cd ${SUBMIT_DIR}/${StartDir}
-      ln -s ../../.resol .
-      ln -s ../../.libmpi .
-      IGCM_sys_Cd ${RUN_DIR}
-      echo "${DateBegin} ${DateEnd} ${StartDir}" >> ${RUN_DIR}/CreatedDir.txt
-    fi
-    PeriodDateEnd=$( grep -m1 ${StartDir} ${RUN_DIR}/CreatedDir.txt | cut -f2 -d\  )
-
-  # - Create directory in which to store new restart files if it does'nt already exist
-    RestartDir=${STORAGE}/IGCM_IN/${config_UserChoices_TagName}/${StartDir}
-    IGCM_sys_MkdirArchive ${RestartDir}
-
-  # - Loop over members
-    i=0
-    while [ $i -lt ${ensemble_Ens_PERTURB_MEMBER} ] ; do
-      MemberDir="${StartDir}${Alpha[$i]}"
-      IGCM_debug_Print 3 "${MemberDir}"
-
-      JobName="Job_${MemberDir}"
-
-    # * Create directory if it doesn't exist and copy files
-      if [ ! -d  ${SUBMIT_DIR}/${StartDir}/${MemberDir} ] ; then
-        IGCM_sys_Mkdir ${SUBMIT_DIR}/${StartDir}/${MemberDir}
-        #IGCM_sys_Cp -r COMP/ PARAM/ ${StartDir}/${MemberDir}
-        IGCM_sys_Cd ${SUBMIT_DIR}/${StartDir}/${MemberDir}
-        ln -s ../../COMP
-        ln -s ../../PARAM
-        ln -s ../../POST
-        ln -s ../../DRIVER
-        IGCM_sys_Cd ${RUN_DIR}
-        IGCM_sys_Cp config.card run.card.init ${SUBMIT_DIR}/${StartDir}/${MemberDir}
-        IGCM_sys_Cp Job_${config_UserChoices_JobName} ${SUBMIT_DIR}/${StartDir}/${MemberDir}/Job_${MemberDir}
-
-        # Dump command to be lauched
-        echo "cd ${StartDir}/${MemberDir}/ ;"    >> Qsub.${StartDir}.sh
-        echo "${SUBMIT} ${JobName} ; cd -"       >> Qsub.${StartDir}.sh
-
-        echo "cd ${StartDir}/${MemberDir}/ ;"    >> ${RUN_DIR}/Qclean.PeriodLength.${StartDir}.sh
-        echo "${libIGCM}/clean_PeriodLength.job ; cd -"  >> ${RUN_DIR}/Qclean.PeriodLength.${StartDir}.sh
-
-        # * Update files : config.card, Job_, COMP/comp.card
-        echo "${PeriodDateEnd} ? ${DateEnd}"
-        if [ ${PeriodDateEnd} -gt ${DateEnd} ] ; then
-          DateEnd=${PeriodDateEnd}
-        fi
-	
-        IGCM_ensemble_CastFilesUpdate ${DateBegin} ${DateEnd} ${RestartDate}
-
-        # * Apply noise on restart file
-        IGCM_ensemble_CastPerturbFile
-      fi
-
-      (( i = i + 1 ))
-    done
-
-    # Done. Save ${StartDir} submission text file
-    IGCM_sys_Cp ${RUN_DIR}/Qsub.${StartDir}.sh ${SUBMIT_DIR}
-    IGCM_sys_Cp ${RUN_DIR}/Qclean.PeriodLength.${StartDir}.sh ${SUBMIT_DIR}
-
-    (( DateNum = DateNum + 1 ))
-  done
-  IGCM_debug_PopStack "IGCM_ensemble_CastNonPeriodicStarts"
-}
-
 function IGCM_ensemble_CastMemberList
 {
@@ -615,15 +446,16 @@
   eval DateBegin=\${ensemble_Ens_PERTURB_BEGIN_INIT}
 
-  IGCM_date_GetYearMonth ${DateBegin} year month
+  IGCM_date_GetYearMonth ${DateBegin} ${year} ${month}
 
   # - Determine number of day(s) in LENGTH
-  DureeLengthInDays=$(( $( IGCM_date_DaysInCurrentPeriod ${DateBegin} ${ensemble_Ens_PERTURB_LENGTH} ) - 1 ))
+  DurationLengthInDays=$(( $( IGCM_date_DaysInCurrentPeriod ${DateBegin} ${ensemble_Ens_PERTURB_LENGTH} ) - 1 ))
 
   # - Determine DateEnd
-  DateEnd=$( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${DureeLengthInDays} )
+  DateEnd=$( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${DurationLengthInDays} )
 
   # bad hack enforce yearly for parent directory name
   # - Build directory name
-  IGCM_ensemble_CastDirectoryName ${ensemble_Ens_PERTURB_NAME} 1Y $year $month $StartDir
+  IGCM_ensemble_CastDirectoryName ${ensemble_Ens_PERTURB_NAME} 1Y ${year} ${month}
+  #SF IGCM_ensemble_CastDirectoryName ${ensemble_Ens_PERTURB_NAME} 1Y ${year} ${month} ${StartDir}
 
   # - Determine RestartDate
@@ -648,9 +480,12 @@
 
   # - Loop over members
-  i=0
-  nbmember=${#ensemble_Ens_PERTURB_PERTU_MAP_LIST[*]}
+  i=1
+  nbmember=${ensemble_Ens_PERTURB_MEMBER}
   while [ $i -lt $nbmember ] ; do
-    MemberDir=${ensemble_Ens_PERTURB_MEMBER_NAMESLIST[${i}]}
-    MemberVec=${ensemble_Ens_PERTURB_PERTU_MAP_LIST[${i}]}
+    MemberVec=${ensemble_PERTURB_MEMBER_[${i}]}
+    MemberDir=${config_UserChoices_Member}
+    echo 
+    IGCM_debug_Print 3 "print nbmember: ${nbmember}"
+    IGCM_debug_Print 3 "print MemberVec: ${ensemble_PERTURB_MEMBER[${i}]}"
 
     JobName="Job_${MemberDir}"
@@ -660,23 +495,13 @@
     # * Create directory if it doesn't exist and copy/link files
     if [ ! -d  ${SUBMIT_DIR}/${StartDir}/${MemberDir} ] ; then
-      IGCM_sys_Mkdir ${SUBMIT_DIR}/${StartDir}/${MemberDir}
-      IGCM_sys_Cd ${SUBMIT_DIR}/${StartDir}/${MemberDir}
-      ln -s ../../COMP
-      ln -s ../../PARAM
-      ln -s ../../POST
-      ln -s ../../DRIVER
-      IGCM_sys_Cd ${RUN_DIR}
-      IGCM_sys_Cp config.card run.card.init ${SUBMIT_DIR}/${StartDir}/${MemberDir}
-      IGCM_sys_Cp Job_${config_UserChoices_JobName} ${SUBMIT_DIR}/${StartDir}/${MemberDir}/${JobName}
-
-      # Dump command to be lauched
-      echo "cd ${StartDir}/${MemberDir}/ ;"     >> ${RUN_DIR}/Qsub.${StartDir}.sh
-      echo "${SUBMIT} ${JobName} ; cd -"        >> ${RUN_DIR}/Qsub.${StartDir}.sh
-
-      echo "cd ${StartDir}/${MemberDir}/ ;"     >> ${RUN_DIR}/Qclean.PeriodLength.${StartDir}.sh
-      echo "${libIGCM}/clean_PeriodLength.job ; cd -"   >> ${RUN_DIR}/Qclean.PeriodLength.${StartDir}.sh
+
+      # * Create ${SUBMIT_DIR}/${StartDir}/${MemberDir} directories
+      #   link COMP PARAM POST and DRIVER
+      #   cp config.card, run.card.init, Job_
+      #   and Dump command to be launched 
+      IGCM_ensemble_CreateMemberDir
 
       # * Update files : config.card, Job_, COMP/comp.card
-      IGCM_ensemble_CastFilesUpdate ${DateBegin} ${DateEnd} ${RestartDate}
+      IGCM_ensemble_FilesUpdate "PERTURB" ${i} ${DateBegin} ${DateEnd} ${RestartDate} ${InitFrom} ${InitPath}
 
       # * Apply noise on restart file
@@ -692,47 +517,4 @@
 
   IGCM_debug_PopStack "IGCM_ensemble_CastMemberList"
-}
-
-function IGCM_ensemble_CastFilesUpdate
-{
-  IGCM_debug_PushStack "IGCM_ensemble_CastFilesUpdate"
-
-  # Debug Print :
-  echo
-  IGCM_debug_Print 1 "IGCM_ensemble_CastFilesUpdate :"
-
-  HumanDateBegin=$(   IGCM_date_ConvertFormatToHuman ${1} )
-  HumanDateEnd=$(     IGCM_date_ConvertFormatToHuman ${2} )
-  HumanRestartDate=$( IGCM_date_ConvertFormatToHuman ${3} )
-  # ==> config.card
-  IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Ensemble EnsembleRun 'y'
-  IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Ensemble EnsembleName ${ensemble_Ens_PERTURB_NAME}
-  IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Ensemble EnsembleDate ${StartDir}
-  IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Ensemble EnsembleType "Ens_PERTURB"
-
-  IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card UserChoices JobName   ${MemberDir}
-  IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card UserChoices DateBegin ${HumanDateBegin}
-  IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card UserChoices DateEnd   ${HumanDateEnd}
-  IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Restarts OverRule "n"
-
-  for comp in ${config_ListOfComponents[*]} ; do
-    IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${comp} Restart "y"
-    IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${comp} RestartDate ${HumanRestartDate}
-    IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${comp} RestartJobName ${ensemble_Ens_PERTURB_INITFROM}
-    IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${comp} RestartPath ${ensemble_Ens_PERTURB_INITPATH}
-  done
-  # Adhoc exception for CMIP6 : exclude XIOS from the restart overrule mechanism.
-  if ( [ X${comp} = XIOS ] && [ X"$( echo ${config_UserChoices_ExpType} | grep CMIP6 )" != "X" ] ) ; then
-      IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${comp} Restart "n"
-  fi
-
-  # ==> Job
-  sed -e "s/\(#.*Script_Output_\)${config_UserChoices_JobName}\(\.*\)/\1${MemberDir}\2/" \
-      -e "s/\(#.*\)${config_UserChoices_JobName}\(\.*\)/\1${MemberDir} \2/"            \
-      -e "s/^PeriodNb=.*/PeriodNb=5/"                                                   \
-      ${SUBMIT_DIR}/${StartDir}/${MemberDir}/Job_${MemberDir} > Job_${MemberDir}.tmp
-  IGCM_sys_Mv Job_${MemberDir}.tmp ${SUBMIT_DIR}/${StartDir}/${MemberDir}/Job_${MemberDir}
-
-  IGCM_debug_PopStack "IGCM_ensemble_CastFilesUpdate"
 }
 
@@ -747,23 +529,12 @@
 
   Name=$1
-  Duree=$2
-  year=$3
-  month=$4
+  PeriodLen=$2
+  Year=$3
+  Month=$4
 
   # - Build directory name
-  case ${Duree} in
+  case ${PeriodLen} in
   *Y|*y)
-    siecle="$( echo $year | cut -c1-2 )"
-    siecle=$( (( $siecle - 18 )) )
-    StartYear="${siecle}$( echo $year | cut -c3-4 )"
-    StartDir="${Name}${StartYear}"
-    ;;
-  *M|*m)
-    echo $month
-    siecle="$( echo $year | cut -c1-2 )"
-    siecle=$( (( $siecle - 18 )) )
-    StartYear="${siecle}$( echo $year | cut -c3-4 )"
-    StartMonth="${AlphaMonth[ (( 10#${month} - 1 )) ]}"
-    StartDir="${Name}${StartYear}${StartMonth}"
+    StartDir="${Name}${year}"
     ;;
   esac
@@ -998,16 +769,5 @@
   IGCM_debug_PushStack "IGCM_ensemble_DateInit"
 
-  IGCM_sys_Mkdir ${RUN_DIR}
-
-  IGCM_sys_Cp ${SUBMIT_DIR}/config.card   ${RUN_DIR}
-  IGCM_sys_Cp ${SUBMIT_DIR}/ensemble.card ${RUN_DIR}
-  IGCM_sys_Cp ${SUBMIT_DIR}/Job_*         ${RUN_DIR}
-  IGCM_sys_Cp ${SUBMIT_DIR}/run.card.init ${RUN_DIR}
-  if [ -f ${SUBMIT_DIR}/Qsub.* ]; then
-    IGCM_sys_Cp ${SUBMIT_DIR}/Qsub.*        ${RUN_DIR}
-  fi
-  if [ -f ${SUBMIT_DIR}/Qclean.* ]; then
-    IGCM_sys_Cp ${SUBMIT_DIR}/Qclean.*      ${RUN_DIR}
-  fi
+  IGCM_ensemble_InitRunDir
 
   IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_DATE active
@@ -1016,5 +776,5 @@
   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 PERIODICITY
+  IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_DATE STARTDATE
   IGCM_card_DefineArrayFromOption    ${F_CFG_ENS} Ens_DATE NONPERIODIC
   IGCM_card_DefineArrayFromOption    ${F_CFG_ENS} Ens_DATE RESTART_NONPERIODIC
@@ -1036,6 +796,6 @@
   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 "PERIODICITY          = ${ensemble_Ens_DATE_PERIODICITY}"
   IGCM_debug_Print 1 "BEGIN_RESTART        = ${ensemble_Ens_DATE_BEGIN_RESTART}"
+  IGCM_debug_Print 1 "STARTDATE            = ${ensemble_Ens_DATE_STARTDATE}"
   IGCM_debug_Print 1 "NONPERIODIC          = ${ensemble_Ens_DATE_NONPERIODIC[*]}"
   IGCM_debug_Print 1 "RESTART_NONPERIODIC  = ${ensemble_Ens_DATE_RESTART_NONPERIODIC[*]}"
@@ -1052,10 +812,6 @@
   echo ""
 
-  ensemble_Ens_DATE_MEMBER=1 # actually use only 1 member
-  IGCM_ensemble_SetAlpha ${ensemble_Ens_DATE_MEMBER}
-
   IGCM_debug_Print 1 "Check args..."
-  DatePeriodicStart=false
-  DateNonPeriodicStart=false
+  DateNonPeriodicStart=true
 
   # ... Check LENGTH ...
@@ -1070,63 +826,19 @@
 
   # ***************************************
-  # A few checks Period case:
-  # ***************************************
-  # if all Periodic params are not filled: desactivate Periodic mode
-  totalPeriodArgs=4
-  periodFillArgs=0
-
-  if [[ X${ensemble_Ens_DATE_BEGIN_RESTART} != "X" ]]; then
-    (( periodFillArgs = periodFillArgs + 1 ))
-  fi
-
-  if [[ X${ensemble_Ens_DATE_BEGIN_INIT} != "X" ]]; then
-    (( periodFillArgs = periodFillArgs + 1 ))
-  fi
-
-  if [[ X${ensemble_Ens_DATE_END_INIT} != "X" ]]; then
-    (( periodFillArgs = periodFillArgs + 1 ))
-  fi
-
-  if [[ X${ensemble_Ens_DATE_PERIODICITY} != "X" ]]; then
-    (( periodFillArgs = periodFillArgs + 1 ))
-
-    # ... Check PERIODICITY ...
-    case ${ensemble_Ens_DATE_PERIODICITY} in
-    *[Yy]|*[Mm])
-      IGCM_debug_Print 1 "Periodic length : ${ensemble_Ens_DATE_PERIODICITY}" ;;
-    *)
-      IGCM_debug_Exit "IGCM_ensemble_DateInit ${ensemble_Ens_DATE_PERIODICITY} : invalid PERIODICITY"
-      IGCM_debug_Exit "Choose a value in *Y or *M"
-      IGCM_debug_Verif_Exit ;;
-    esac
-  fi # if periodicity
-
-  if [[ ${periodFillArgs} = ${totalPeriodArgs} ]]; then
-    DatePeriodicStart=true
-  else
-    if [[ ${periodFillArgs} = 0 ]]; then
-      IGCM_debug_Print 1 "Periodic start NOT ACTIVE"
-      DatePeriodicStart=false
-    else
-      IGCM_debug_Exit "IGCM_ensemble_DateInit missing arguments for Periodic mode!"
-      IGCM_debug_Exit "Get only ${periodFillArgs} on ${totalPeriodArgs} args. Check ${F_CFG_ENS} file."
-      IGCM_debug_Verif_Exit
-    fi
-  fi
-
-  # ***************************************
   # 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_NONPERIODIC[*]} > 0 ]] && [[ ${ensemble_Ens_DATE_NONPERIODIC[*]} != _0_ ]]; then
+#  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
     DateNonPeriodicStart=true
 
     # Use LENGTH if no NONPERIODIC_LENGTH given
-    if [[ ${#ensemble_Ens_DATE_LENGTH_NONPERIODIC[*]} < ${#ensemble_Ens_DATE_NONPERIODIC[*]} ]] ; then
-      IGCM_debug_Print 1 "WARNING: LENGTH_NONPERIODIC is not fill (or not correctly). Use LENGTH value '${ensemble_Ens_DATE_LENGTH}' for all NONPERIODIC runs"
+    if [[ ${#ensemble_Ens_DATE_LENGTH_NONPERIODIC[*]} < ${#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
@@ -1135,5 +847,17 @@
       done
     fi
-
+    
+    # Use STARTDATE if no NONPERIODIC start date given
+    if [[ ${#ensemble_Ens_DATE_NONPERIODIC[*]} < ${#ensemble_Ens_DATE_RESTART_NONPERIODIC[*]} ]] ||
+	   [[ X"${ensemble_Ens_DATE_NONPERIODIC[0]}" = "XOption" ]] ; then
+	IGCM_debug_Print 1 "WARNING: NONPERIODIC start date not fill (or not correctly)."
+	IGCM_debug_Print 1 "Use STARTDATE value '${ensemble_Ens_DATE_STARTDATE}' for all NONPERIODIC runs"
+      DateNum=0
+      while [ ${DateNum} -lt ${#ensemble_Ens_DATE_RESTART_NONPERIODIC[*]} ] ; do
+        ensemble_Ens_DATE_NONPERIODIC[${DateNum}]=${ensemble_Ens_DATE_STARTDATE}
+        (( DateNum = DateNum + 1 ))
+      done
+    fi
+	
     # Use INITFROM if no INITFROM_NONPERIODIC given
     if [ ${#ensemble_Ens_DATE_INITFROM_NONPERIODIC[*]} -lt ${#ensemble_Ens_DATE_NONPERIODIC[*]} ] ; then
@@ -1188,105 +912,4 @@
 }
 
-function IGCM_ensemble_DatePeriodicStarts
-{
-  IGCM_debug_PushStack "IGCM_ensemble_DatePeriodicStarts"
-
-  [ ${DatePeriodicStart} = false ] && return
-
-  echo
-  IGCM_debug_Print 1 ">>>  MANAGE PERIODIC STARTS  <<<"
-
-#.. Manage periodic starts ..
-#   ======================
-
-  # - Build directory name
-  StartDir="${ensemble_Ens_DATE_NAME}"
-
-  # - Create directory for current DateBegin
-  if [ ! -d  ${StartDir} ] ; then
-    IGCM_sys_Mkdir ${SUBMIT_DIR}/${StartDir}
-    IGCM_sys_Cd ${SUBMIT_DIR}/${StartDir}
-    ln -s ../../.resol .
-    ln -s ../../.libmpi .
-    IGCM_sys_Cd ${RUN_DIR}
-  fi
-
-  # ... Loop over DateBegin ...
-  eval DateBegin=\${ensemble_Ens_DATE_BEGIN_INIT}
-  eval RestartDate=\${ensemble_Ens_DATE_BEGIN_RESTART}
-
-  DateNum=0
-  while [ ${DateBegin} -le ${ensemble_Ens_DATE_END_INIT} ] ; do
-    IGCM_date_GetYearMonth ${DateBegin} year month
-
-    echo "========================================================================"
-    echo "New DateBegin = $DateBegin"
-
-  # - Determine number of day(s) in PERIODICITY
-    PeriodLengthInDays=$( IGCM_date_DaysInCurrentPeriod ${DateBegin} ${ensemble_Ens_DATE_PERIODICITY} )
-
-  # - Determine number of day(s) in LENGTH
-    DureeLengthInDays=$(( $( IGCM_date_DaysInCurrentPeriod ${DateBegin} ${ensemble_Ens_DATE_LENGTH} ) - 1 ))
-
-  # - Determine DateEnd
-    (( DateEnd = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${DureeLengthInDays} ) ))
-
-    IGCM_debug_Print 2 "${DateBegin} => ${DateEnd} : ${StartDir}"
-    echo "${DateBegin} ${DateEnd} ${StartDir}" >> ${RUN_DIR}/CreatedDir.txt
-
-  # - Loop over members (default =1 no member)
-    i=0
-    while [ $i -lt ${ensemble_Ens_DATE_MEMBER} ] ; do
-      MemberDir="${ensemble_Ens_DATE_NAME}${DateNum}${Alpha[$i]}_per"
-      echo
-      IGCM_debug_Print 3 "${MemberDir}"
-
-      JobName="Job_${MemberDir}"
-
-    # * Create directory if it doesn't exist and copy/link files
-      if [ ! -d  ${SUBMIT_DIR}/${StartDir}/${MemberDir} ] ; then
-        IGCM_sys_Mkdir ${SUBMIT_DIR}/${StartDir}/${MemberDir}
-        IGCM_sys_Cd ${SUBMIT_DIR}/${StartDir}/${MemberDir}
-        ln -s ../../COMP
-        ln -s ../../PARAM
-        ln -s ../../POST
-        ln -s ../../DRIVER
-        IGCM_sys_Cd ${RUN_DIR}
-        IGCM_sys_Cp config.card run.card.init ${SUBMIT_DIR}/${StartDir}/${MemberDir}
-        IGCM_sys_Cp Job_${config_UserChoices_JobName} ${SUBMIT_DIR}/${StartDir}/${MemberDir}/${JobName}
-
-        # Dump command to be lauched
-        echo "cd ${StartDir}/${MemberDir}/ ;"    >> ${RUN_DIR}/Qsub.${StartDir}.sh
-        echo "${SUBMIT} ${JobName} ; cd -"       >> ${RUN_DIR}/Qsub.${StartDir}.sh
-
-        echo "cd ${StartDir}/${MemberDir}/ ;"    >> ${RUN_DIR}/Qclean.PeriodLength.${StartDir}.sh
-        echo "${libIGCM}/clean_PeriodLength.job ; cd -"  >> ${RUN_DIR}/Qclean.PeriodLength.${StartDir}.sh
-
-        # * Update files : config.card, Job_, COMP/comp.card
-        IGCM_ensemble_DateFilesUpdate ${DateBegin} ${DateEnd} ${RestartDate}
-      fi
-
-      (( i = i + 1 ))
-    done
-
-  # - Next DateBegin & RestartDate
-    echo "$DateBegin  $PeriodLengthInDays"
-    case ${ensemble_Ens_DATE_PERIODICITY} in
-    *[Yy]|*[Mm])
-      (( DateBegin =   $( IGCM_date_AddDaysToGregorianDate ${DateBegin}   ${PeriodLengthInDays} ) ))
-      (( RestartDate = $( IGCM_date_AddDaysToGregorianDate ${RestartDate} ${PeriodLengthInDays} ) ))
-      ;;
-    esac
-
-    (( DateNum = DateNum + 1 )) # increment number of restart date
-  done
-
-  # Done. Save ${StartDir} submission text file
-  IGCM_sys_Cp ${RUN_DIR}/Qsub.${StartDir}.sh ${SUBMIT_DIR}
-  IGCM_sys_Cp ${RUN_DIR}/Qclean.PeriodLength.${StartDir}.sh ${SUBMIT_DIR}
-
-  IGCM_debug_PopStack "IGCM_ensemble_DatePeriodicStarts"
-}
-
 function IGCM_ensemble_DateNonPeriodicStarts
 {
@@ -1324,5 +947,10 @@
     InitFrom=${ensemble_Ens_DATE_INITFROM_NONPERIODIC[${DateNum}]}
     InitPath=${ensemble_Ens_DATE_INITPATH_NONPERIODIC[${DateNum}]}
-
+    (( ii=DateNum + 1 ))
+    
+    MemberDir="${ensemble_Ens_DATE_NAME}${ii}"
+    IGCM_debug_Print 3 "${MemberDir}"
+    echo "Create: ${MemberDir}"
+    
   # - Determine number of day(s) in LENGTH_NONPERIODIC
     IGCM_date_GetYearMonth ${DateBegin} year month
@@ -1337,109 +965,28 @@
     PeriodDateEnd=$( grep -m1 ${StartDir} ${RUN_DIR}/CreatedDir.txt | cut -f2 -d\  )
 
-  # - Loop over members
-    i=0
-    while [ $i -lt ${ensemble_Ens_DATE_MEMBER} ] ; do
-      MemberDir="${ensemble_Ens_DATE_NAME}${DateNum}${Alpha[$i]}"
-      IGCM_debug_Print 3 "${MemberDir}"
-
-      JobName="Job_${MemberDir}"
-
+    JobName="Job_${MemberDir}"
+    
     # * Create directory if it doesn't exist and copy files
-      if [ ! -d  ${SUBMIT_DIR}/${StartDir}/${MemberDir} ] ; then
-        IGCM_sys_Mkdir ${SUBMIT_DIR}/${StartDir}/${MemberDir}
-        IGCM_sys_Cd ${SUBMIT_DIR}/${StartDir}/${MemberDir}
-        ln -s ../../COMP
-        ln -s ../../PARAM
-        ln -s ../../POST
-        ln -s ../../DRIVER
-        IGCM_sys_Cd ${RUN_DIR}
-        IGCM_sys_Cp config.card run.card.init ${SUBMIT_DIR}/${StartDir}/${MemberDir}
-        IGCM_sys_Cp Job_${config_UserChoices_JobName} ${SUBMIT_DIR}/${StartDir}/${MemberDir}/Job_${MemberDir}
-
-        # Dump command to be lauched
-        echo "cd ${StartDir}/${MemberDir}/ ;"     >> ${RUN_DIR}/Qsub.${StartDir}.sh
-        echo "${SUBMIT} ${JobName} ; cd -"        >> ${RUN_DIR}/Qsub.${StartDir}.sh
-
-        echo "cd ${StartDir}/${MemberDir}/ ;"     >> ${RUN_DIR}/Qclean.PeriodLength.${StartDir}.sh
-        echo "${libIGCM}/clean_PeriodLength.job ; cd -"   >> ${RUN_DIR}/Qclean.PeriodLength.${StartDir}.sh
-
+    if [ ! -d  ${SUBMIT_DIR}/${StartDir}/${MemberDir} ] ; then
+
+        # * Create ${SUBMIT_DIR}/${StartDir}/${MemberDir} directories
+        #   link COMP PARAM POST and DRIVER
+        #   cp config.card, run.card.init, Job_
+        #   and Dump command to be launched 
+        IGCM_ensemble_CreateMemberDir
+	
         # * Update files : config.card, Job_, COMP/comp.card
-        IGCM_ensemble_DateFilesUpdate ${DateBegin} ${DateEnd} ${RestartDate} ${InitFrom} ${InitPath}
-      fi
-
-      (( i = i + 1 ))
-    done
-
+        IGCM_ensemble_FilesUpdate "DATE" ${ii} ${DateBegin} ${DateEnd} ${RestartDate} ${InitFrom} ${InitPath}
+    fi
+    
     # Done. Save ${StartDir} submission text file
     IGCM_sys_Cp ${RUN_DIR}/Qsub.${StartDir}.sh ${SUBMIT_DIR}
     IGCM_sys_Cp ${RUN_DIR}/Qclean.PeriodLength.${StartDir}.sh ${SUBMIT_DIR}
+    IGCM_sys_Cp ${RUN_DIR}/Qclean.latestPackperiod.${StartDir}.sh ${SUBMIT_DIR}
 
     (( DateNum = DateNum + 1 ))
   done
 
-  # Done. Save ${StartDir} submission text file
-  IGCM_sys_Cp ${RUN_DIR}/Qsub.${StartDir}.sh ${SUBMIT_DIR}
-  IGCM_sys_Cp ${RUN_DIR}/Qclean.month.${StartDir}.sh ${SUBMIT_DIR}
-  IGCM_sys_Cp ${RUN_DIR}/Qclean.year.${StartDir}.sh ${SUBMIT_DIR}
-
   IGCM_debug_PopStack "IGCM_ensemble_DateNonPeriodicStarts"
 }
 
-function IGCM_ensemble_DateFilesUpdate
-{
-  IGCM_debug_PushStack "IGCM_ensemble_DateFilesUpdate"
-
-  # Debug Print :
-  echo
-  IGCM_debug_Print 1 "IGCM_ensemble_DateFilesUpdate :"
-
-  HumanDateBegin=$(   IGCM_date_ConvertFormatToHuman ${1} )
-  HumanDateEnd=$(     IGCM_date_ConvertFormatToHuman ${2} )
-  HumanRestartDate=$( IGCM_date_ConvertFormatToHuman ${3} )
-  if [[ X${4} != "X" ]]; then
-    initFrom=${4} # non periodic config (INITFROM could be different between members)
-  else
-    initFrom=${ensemble_Ens_DATE_INITFROM} # periodic (same INITFROM value)
-  fi
-
-  if [[ X${5} != "X" ]]; then
-    initPath=${5} # non periodic config (INITPATH could be different between members)
-  else
-    initPath=${ensemble_Ens_DATE_INITPATH} # periodic (same INITPATH value)
-  fi
-  
-  # ==> 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 ${ensemble_Ens_DATE_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_DATE"
-
-  # [UserChoices]
-  IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card UserChoices JobName   ${MemberDir}
-  IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card UserChoices DateBegin ${HumanDateBegin}
-  IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card UserChoices DateEnd   ${HumanDateEnd}
-
-  # [Restarts]
-  IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Restarts OverRule "y"
-  IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Restarts RestartDate ${HumanRestartDate}
-  IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Restarts RestartJobName ${initFrom}
-  IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Restarts RestartPath ${initPath}
-
-    # [ATM/OCE/...]
-  for comp in ${config_ListOfComponents[*]} ; do
-    IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${comp} Restart "n"
-  done
-  unset initFrom
-
-  # ==> Job
-  sed -e "s/\(#.*Script_Output_\)${config_UserChoices_JobName}\(\.*\)/\1${MemberDir}\2/" \
-      -e "s/\(#.*\)${config_UserChoices_JobName}\(\.*\)/\1${MemberDir} \2/"            \
-      -e "s/^PeriodNb=.*/PeriodNb=5/"                                                   \
-      ${SUBMIT_DIR}/${StartDir}/${MemberDir}/Job_${MemberDir} > Job_${MemberDir}.tmp
-  IGCM_sys_Mv Job_${MemberDir}.tmp ${SUBMIT_DIR}/${StartDir}/${MemberDir}/Job_${MemberDir}
-
-  IGCM_debug_PopStack "IGCM_ensemble_DateFilesUpdate"
-}
-
-############### Parametric ENSEMBLE #################
