Index: trunk/libIGCM/libIGCM_ensemble/libIGCM_ensemble.ksh
===================================================================
--- trunk/libIGCM/libIGCM_ensemble/libIGCM_ensemble.ksh	(revision 895)
+++ trunk/libIGCM/libIGCM_ensemble/libIGCM_ensemble.ksh	(revision 1001)
@@ -2,6 +2,6 @@
 
 #**************************************************************
-# Author: Sonia Labetoulle
-# Contact: Sonia.Labetoulle__at__locean-ipsl.upmc.fr
+# Author: Sebastien Denvil, Sonia Labetoulle, Nicolas Lebas
+# Contact: Nicolas.Lebas__at__locean-ipsl.upmc.fr
 # $Revision::                                          $ Revision of last commit
 # $Author::                                            $ Author of last commit
@@ -12,10 +12,36 @@
 #**************************************************************
 
-function IGCM_ensemble_CastInit
-{
-  IGCM_debug_PushStack "IGCM_ensemble_CastInit"
-
+# Read which ensemble type are active
+function IGCM_ensemble_Init
+{
+  IGCM_debug_PushStack "IGCM_ensemble_Init"
+
+  IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB active
+  IGCM_card_DefineVariableFromOption ${FileName} Ens_DATE active
+  IGCM_card_DefineVariableFromOption ${FileName} Ens_PARAMETRIC active
+  
+  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 ""
+  
+  IGCM_debug_PopStack "IGCM_ensemble_Init"
+}
+
+# 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"
 
   IGCM_sys_Mkdir ${RUN_DIR}
@@ -25,5 +51,8 @@
   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
+  
   # Useful?
   #if [ -f  ${SUBMIT_DIR}/CreatedDir.txt ] ; then
@@ -35,16 +64,16 @@
   #fi
 
-  IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB actif
   IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB NAME
-  IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB DEBUT_INIT
-  IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB FIN_INIT
-  IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB PERIODICITE
+  IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB BEGIN_INIT
+  IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB END_INIT
+  IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB PERIODICITY
   IGCM_card_DefineArrayFromOption    ${FileName} Ens_PERTURB NONPERIODIC
-  IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB DUREE
-  IGCM_card_DefineArrayFromOption    ${FileName} Ens_PERTURB DUREE_NONPERIODIC
+  IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB LENGTH
+  IGCM_card_DefineArrayFromOption    ${FileName} Ens_PERTURB LENGTH_NONPERIODIC
   IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB MEMBER
   IGCM_card_DefineArrayFromOption    ${FileName} Ens_PERTURB PERTURB_BIN
   IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB INITFROM
   IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB INITPATH
+  IGCM_card_DefineVariableFromOption config.card UserChoices JobName
   IGCM_card_DefineVariableFromOption config.card UserChoices TagName
   IGCM_card_DefineVariableFromOption config.card UserChoices CalendarType
@@ -52,20 +81,22 @@
 
   echo
-  IGCM_debug_Print 1 "ACTIVE            = ${ensemble_Ens_PERTURB_actif}"
+  IGCM_debug_Print 1 "[Ens_PERTURB]"
+  IGCM_debug_Print 1 "ACTIVE            = ${ensemble_Ens_PERTURB_active}"
   IGCM_debug_Print 1 "NAME              = ${ensemble_Ens_PERTURB_NAME}"
-  IGCM_debug_Print 1 "DEBUT_INIT        = ${ensemble_Ens_PERTURB_DEBUT_INIT}"
-  IGCM_debug_Print 1 "FIN_INIT          = ${ensemble_Ens_PERTURB_FIN_INIT}"
-  IGCM_debug_Print 1 "PERIODICITE       = ${ensemble_Ens_PERTURB_PERIODICITE}"
+  IGCM_debug_Print 1 "BEGIN_INIT        = ${ensemble_Ens_PERTURB_BEGIN_INIT}"
+  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 "DUREE             = ${ensemble_Ens_PERTURB_DUREE}"
-  IGCM_debug_Print 1 "DUREE_NONPERIODIC = ${ensemble_Ens_PERTURB_DUREE_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 "PERTURB_BIN       = ${ensemble_Ens_PERTURB_PERTURB_BIN[*]}"
   IGCM_debug_Print 1 "INITFROM          = ${ensemble_Ens_PERTURB_INITFROM}"
   IGCM_debug_Print 1 "INITPATH          = ${ensemble_Ens_PERTURB_INITPATH}"
+  IGCM_debug_Print 1 "JobName           = ${config_UserChoices_JobName}"
   IGCM_debug_Print 1 "TagName           = ${config_UserChoices_TagName}"
   IGCM_debug_Print 1 "CalendarType      = ${config_UserChoices_CalendarType}"
   IGCM_debug_Print 1 "ListOfComponents  = ${config_ListOfComponents[*]}"
-
+  
   PerturbExe=${ensemble_Ens_PERTURB_PERTURB_BIN[0]}
   PerturbComp=${ensemble_Ens_PERTURB_PERTURB_BIN[1]}
@@ -79,9 +110,11 @@
   IGCM_debug_Print 1 "PerturbVar  = ${PerturbVar}"
   IGCM_debug_Print 1 "PerturbAmp  = ${PerturbAmp}"
-
+  
+  IGCM_ensemble_SetAlpha ${ensemble_Ens_PERTURB_MEMBER}
+  
   # A few checks Period case:
 
-  # ... Check PERIODICITE ...
-  case ${ensemble_Ens_PERTURB_PERIODICITE} in
+  # ... Check PERIODICITY ...
+  case ${ensemble_Ens_PERTURB_PERIODICITY} in
   _0_)
     IGCM_debug_Print 1 "periodic start not active"
@@ -90,16 +123,16 @@
   *[Yy]|*[Mm])
     CastPeriodicStart=true
-    IGCM_debug_Print 1 "Periodic length : ${ensemble_Ens_PERTURB_PERIODICITE}" ;;
+    IGCM_debug_Print 1 "Periodic length : ${ensemble_Ens_PERTURB_PERIODICITY}" ;;
   *)
-    IGCM_debug_Exit "IGCM_ensemble_CastInit ${ensemble_Ens_PERTURB_PERIODICITE} : invalid PERIODICITE"
+    IGCM_debug_Exit "IGCM_ensemble_CastInit ${ensemble_Ens_PERTURB_PERIODICITY} : invalid PERIODICITY"
     IGCM_debug_Exit "Choose a value in *Y or *M"
     IGCM_debug_Verif_Exit ;;
   esac
-# ... Check DUREE ...
-  case ${ensemble_Ens_PERTURB_DUREE} in
+# ... Check LENGTH ...
+  case ${ensemble_Ens_PERTURB_LENGTH} in
   *[Yy]|*[Mm])
-    IGCM_debug_Print 1 "Periodic duration : ${ensemble_Ens_PERTURB_DUREE}" ;;
+    IGCM_debug_Print 1 "Periodic duration : ${ensemble_Ens_PERTURB_LENGTH}" ;;
   *)
-    IGCM_debug_Exit "IGCM_ensemble_CastInit ${ensemble_Ens_PERTURB_DUREE} invalid DUREE"
+    IGCM_debug_Exit "IGCM_ensemble_CastInit ${ensemble_Ens_PERTURB_LENGTH} invalid LENGTH"
     IGCM_debug_Exit "Choose a value in choose in *Y or *M"
     IGCM_debug_Verif_Exit ;;
@@ -110,6 +143,6 @@
   while [ $DateNum -lt ${#ensemble_Ens_PERTURB_NONPERIODIC[*]} ] ; do
 
-    # - Check DUREE_NONPERIODIC
-    case ${ensemble_Ens_PERTURB_DUREE_NONPERIODIC[$DateNum]} in
+    # - Check LENGTH_NONPERIODIC
+    case ${ensemble_Ens_PERTURB_LENGTH_NONPERIODIC[$DateNum]} in
     _0_)
       IGCM_debug_Print 1 "non-periodic start not active"
@@ -117,9 +150,9 @@
       ;;
     *[Yy]|*[Mm])
-      IGCM_debug_Print 1 "Non-periodic duration : ${ensemble_Ens_PERTURB_DUREE_NONPERIODIC[$DateNum]}"
+      IGCM_debug_Print 1 "Non-periodic duration : ${ensemble_Ens_PERTURB_LENGTH_NONPERIODIC[$DateNum]}"
       CastNonPeriodicStart=true
       ;;
     *)
-      IGCM_debug_Exit "IGCM_ensemble_CastInit ${ensemble_Ens_PERTURB_DUREE_NONPERIODIC[$DateNum]} : invalid DUREE"
+      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 ;;
@@ -160,14 +193,14 @@
 
 # ... Loop over DateBegin ...
-  eval DateBegin=\${ensemble_Ens_PERTURB_DEBUT_INIT}
-
-  while [ ${DateBegin} -le ${ensemble_Ens_PERTURB_FIN_INIT} ] ; do
+  eval DateBegin=\${ensemble_Ens_PERTURB_BEGIN_INIT}
+
+  while [ ${DateBegin} -le ${ensemble_Ens_PERTURB_END_INIT} ] ; do
     IGCM_date_GetYearMonth ${DateBegin} year month
 
-  # - Determine number of day(s) in PERIODICITE
-    PeriodLengthInDays=$( IGCM_date_DaysInCurrentPeriod ${DateBegin} ${ensemble_Ens_PERTURB_PERIODICITE} )
-
-  # - Determine number of day(s) in DUREE
-    DureeLengthInDays=$(( $( IGCM_date_DaysInCurrentPeriod ${DateBegin} ${ensemble_Ens_PERTURB_DUREE} ) - 1 ))
+  # - Determine number of day(s) in PERIODICITY
+    PeriodLengthInDays=$( IGCM_date_DaysInCurrentPeriod ${DateBegin} ${ensemble_Ens_PERTURB_PERIODICITY} )
+
+  # - Determine number of day(s) in LENGTH
+    DureeLengthInDays=$(( $( IGCM_date_DaysInCurrentPeriod ${DateBegin} ${ensemble_Ens_PERTURB_LENGTH} ) - 1 ))
 
   # - Determine DateEnd
@@ -175,5 +208,5 @@
 
   # - Build directory name
-    IGCM_ensemble_CastDirectoryName ${ensemble_Ens_PERTURB_NAME} ${ensemble_Ens_PERTURB_PERIODICITE} $year $month $StartDir
+    IGCM_ensemble_CastDirectoryName ${ensemble_Ens_PERTURB_NAME} ${ensemble_Ens_PERTURB_PERIODICITY} $year $month $StartDir
 
   # - Determine RestartDate
@@ -209,24 +242,24 @@
       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_${ensemble_Ens_PERTURB_NAME} ${SUBMIT_DIR}/${StartDir}/${MemberDir}/${JobName}
+        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}.txt
         echo "${SUBMIT} ${JobName} ; cd -"     >> ${RUN_DIR}/Qsub.${StartDir}.txt
+
+	# * Update files : config.card, Job_, COMP/comp.card
+	IGCM_ensemble_CastFilesUpdate ${DateBegin} ${DateEnd} ${RestartDate}
+	
+	# * Apply noise on restart file
+	IGCM_ensemble_CastPerturbFile
       fi
-
-    # * Update files : config.card, Job_, COMP/comp.card
-      IGCM_ensemble_CastFilesUpdate ${DateBegin} ${DateEnd} ${RestartDate}
-
-    # * Apply noise on restart file
-      IGCM_ensemble_CastPerturbFile
-
+      
       (( i = i + 1 ))
     done
@@ -237,5 +270,5 @@
   # - Next DateBegin
     echo "$DateBegin  $PeriodLengthInDays"
-    case ${ensemble_Ens_PERTURB_PERIODICITE} in
+    case ${ensemble_Ens_PERTURB_PERIODICITY} in
     *[Yy]|*[Mm])
       (( DateBegin = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${PeriodLengthInDays} ) ))
@@ -266,9 +299,9 @@
   while [ $DateNum -lt ${#ensemble_Ens_PERTURB_NONPERIODIC[*]} ] ; do
     DateBegin=${ensemble_Ens_PERTURB_NONPERIODIC[$DateNum]}
-    Duree=${ensemble_Ens_PERTURB_DUREE_NONPERIODIC[$DateNum]}
+    Duree=${ensemble_Ens_PERTURB_LENGTH_NONPERIODIC[$DateNum]}
     echo ">${DateBegin}<"
     echo ">${Duree}<"
 
-  # - Determine number of day(s) in DUREE_NONPERIODIC
+  # - Determine number of day(s) in LENGTH_NONPERIODIC
     IGCM_date_GetYearMonth ${DateBegin} year month
     DureeLengthInDays=$(( $( IGCM_date_DaysInCurrentPeriod ${DateBegin} ${Duree} ) - 1 ))
@@ -323,22 +356,24 @@
         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_${ensemble_Ens_PERTURB_NAME} ${SUBMIT_DIR}/${StartDir}/${MemberDir}/Job_${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}.txt
         echo "${SUBMIT} ${JobName} ; cd -"     >> Qsub.${StartDir}.txt
+
+	# * 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
-
-    # * 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
+      
       (( i = i + 1 ))
     done
@@ -381,6 +416,6 @@
 
   # ==> Job
-  sed -e "s/\(#.*\)${ensemble_Ens_PERTURB_NAME}\( *#.*\)/\1${MemberDir} \2/"            \
-      -e "s/\(#.*Script_Output_\)${ensemble_Ens_PERTURB_NAME}\(\.*\)/\1${MemberDir}\2/" \
+  sed -e "s/\(#.*\)${config_UserChoices_JobName}\( *#.*\)/\1${MemberDir} \2/"            \
+      -e "s/\(#.*Script_Output_\)${config_UserChoices_JobName}\(\.*\)/\1${MemberDir}\2/" \
       -e "s/^PeriodNb=.*/PeriodNb=60/"                                                  \
       ${SUBMIT_DIR}/${StartDir}/${MemberDir}/Job_${MemberDir} > Job_${MemberDir}.tmp
@@ -601,5 +636,404 @@
   IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${PerturbComp} RestartJobName ${MemberDir}
   IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${PerturbComp} RestartPath    ${RestartDir}/
-
+  IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Ensemble EnsembleType "Ens_PERTURB"
+  
   IGCM_debug_PopStack "IGCM_ensemble_CastPerturbFile"
 }
+
+############### Date ENSEMBLE #################
+function IGCM_ensemble_DateInit
+{
+  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
+  
+  IGCM_card_DefineVariableFromOption ${FileName} Ens_DATE active
+  IGCM_card_DefineVariableFromOption ${FileName} Ens_DATE NAME
+  IGCM_card_DefineVariableFromOption ${FileName} Ens_DATE BEGIN_INIT
+  IGCM_card_DefineVariableFromOption ${FileName} Ens_DATE BEGIN_RESTART
+  IGCM_card_DefineVariableFromOption ${FileName} Ens_DATE END_INIT
+  IGCM_card_DefineVariableFromOption ${FileName} Ens_DATE PERIODICITY
+  IGCM_card_DefineArrayFromOption    ${FileName} Ens_DATE NONPERIODIC
+  IGCM_card_DefineArrayFromOption    ${FileName} Ens_DATE RESTART_NONPERIODIC
+  IGCM_card_DefineVariableFromOption ${FileName} Ens_DATE LENGTH
+  IGCM_card_DefineArrayFromOption    ${FileName} Ens_DATE LENGTH_NONPERIODIC
+  IGCM_card_DefineVariableFromOption ${FileName} Ens_DATE INITFROM
+  IGCM_card_DefineVariableFromOption ${FileName} Ens_DATE INITPATH
+  IGCM_card_DefineVariableFromOption config.card UserChoices JobName
+  IGCM_card_DefineVariableFromOption config.card UserChoices TagName
+  IGCM_card_DefineVariableFromOption config.card UserChoices CalendarType
+  IGCM_card_DefineArrayFromSection   config.card ListOfComponents
+
+  echo
+  IGCM_debug_Print 1 "[Ens_DATE]"
+  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 "PERIODICITY        = ${ensemble_Ens_DATE_PERIODICITY}"
+  IGCM_debug_Print 1 "BEGIN_RESTART      = ${ensemble_Ens_DATE_BEGIN_RESTART}"
+  IGCM_debug_Print 1 "NONPERIODIC        = ${ensemble_Ens_DATE_NONPERIODIC[*]}"
+  IGCM_debug_Print 1 "RESTART_NONPERIODIC= ${ensemble_Ens_DATE_RESTART_NONPERIODIC[*]}"
+  IGCM_debug_Print 1 "LENGTH             = ${ensemble_Ens_DATE_LENGTH}"
+  IGCM_debug_Print 1 "LENGTH_NONPERIODIC = ${ensemble_Ens_DATE_LENGTH_NONPERIODIC[*]}"
+  IGCM_debug_Print 1 "INITFROM           = ${ensemble_Ens_DATE_INITFROM}"
+  IGCM_debug_Print 1 "INITPATH           = ${ensemble_Ens_DATE_INITPATH}"
+  IGCM_debug_Print 1 "JobName            = ${config_UserChoices_JobName}"
+  IGCM_debug_Print 1 "TagName            = ${config_UserChoices_TagName}"
+  IGCM_debug_Print 1 "CalendarType       = ${config_UserChoices_CalendarType}"
+  IGCM_debug_Print 1 "ListOfComponents   = ${config_ListOfComponents[*]}"
+  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
+  
+  # ... Check LENGTH ...
+  case ${ensemble_Ens_DATE_LENGTH} in
+  *[Yy]|*[Mm])
+    IGCM_debug_Print 1 "Default simulation duration : ${ensemble_Ens_DATE_LENGTH}" ;;
+  *)
+    IGCM_debug_Exit "IGCM_ensemble_DateInit ${ensemble_Ens_DATE_LENGTH} invalid LENGTH"
+    IGCM_debug_Exit "Choose a value in choose in *Y or *M"
+    IGCM_debug_Verif_Exit ;;
+  esac
+
+  # ***************************************
+  # 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 ${FileName} 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
+  
+  # Use LENGTH if no NONPERIODIC_LENGTH given
+  if [[ ${#ensemble_Ens_DATE_NONPERIODIC[*]} > 0 ]] && [[ ${ensemble_Ens_DATE_NONPERIODIC[*]} != _0_ ]]; then
+      DateNonPeriodicStart=true
+      
+      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"
+	  DateNum=0
+	  while [ $DateNum -lt ${#ensemble_Ens_DATE_NONPERIODIC[*]} ] ; do
+	      ensemble_Ens_DATE_LENGTH_NONPERIODIC[DateNum]=${ensemble_Ens_DATE_LENGTH}
+	      (( DateNum = DateNum + 1 ))
+	  done
+      fi
+  else
+      IGCM_debug_Print 1 "Non-Periodic start NOT ACTIVE"
+      DateNonPeriodicStart=false
+  fi
+  
+  if [[ ${DateNonPeriodicStart} = true ]]; then
+      DateNum=0
+      while [ $DateNum -lt ${#ensemble_Ens_DATE_NONPERIODIC[*]} ] ; do
+	  # - Check LENGTH_NONPERIODIC
+	  case ${ensemble_Ens_DATE_LENGTH_NONPERIODIC[$DateNum]} in
+	      *[Yy]|*[Mm])
+		  IGCM_debug_Print 1 "Non-periodic duration $DateNum: ${ensemble_Ens_DATE_LENGTH_NONPERIODIC[$DateNum]}"
+		  ;;
+	      *)
+		  IGCM_debug_Exit "IGCM_ensemble_DateInit ${ensemble_Ens_DATE_LENGTH_NONPERIODIC[$DateNum]} : invalid NON PERIODIC LENGTH"
+		  IGCM_debug_Exit "choose in *Y or *M"
+		  IGCM_debug_Verif_Exit ;;
+	  esac
+
+	  # - Check RESTART_NONPERIODIC
+	  case ${ensemble_Ens_DATE_RESTART_NONPERIODIC[$DateNum]} in
+	      _0_)
+		  IGCM_debug_Exit "IGCM_ensemble_DateInit ${ensemble_Ens_DATE_RESTART_NONPERIODIC[$DateNum]} : invalid NON PERIODIC RESTART"
+		  IGCM_debug_Verif_Exit ;;
+	  esac
+	  
+	  (( DateNum = DateNum + 1 ))
+      done
+  fi # DateNonPeriodicStart = true
+  
+  IGCM_debug_PopStack "IGCM_ensemble_DateInit"
+}
+
+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}
+
+  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_INITFROM}${RestartDate}${Alpha[$i]}"
+      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}.txt
+        echo "${SUBMIT} ${JobName} ; cd -"     >> ${RUN_DIR}/Qsub.${StartDir}.txt
+      
+	# * 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
+
+  done
+
+  # Done. Save ${StartDir} submission text file
+  IGCM_sys_Cp ${RUN_DIR}/Qsub.${StartDir}.txt ${SUBMIT_DIR}
+  
+  IGCM_debug_PopStack "IGCM_ensemble_DatePeriodicStarts"
+}
+
+function IGCM_ensemble_DateNonPeriodicStarts
+{
+  IGCM_debug_PushStack "IGCM_ensemble_DateNonPeriodicStarts"
+
+  #.. Manage non periodic starts => Loop over DateBegin ..
+  #   ==========================
+
+  [ ${DateNonPeriodicStart} = false ] && return
+
+  echo
+  IGCM_debug_Print 1 ">>>  MANAGE NON PERIODIC STARTS  <<<"
+
+  # - Build directory name
+  echo ""
+  echo "========================================================================"
+  echo "ensemble_Ens_DATE_NAME = ${ensemble_Ens_DATE_NAME}"
+  StartDir="${ensemble_Ens_DATE_NAME}"
+
+  # -  Does $StartDir already exist ?
+  if [ ! -d ${SUBMIT_DIR}/${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
+  
+  DateNum=0
+  # ... Loop over ensemble_Ens_DATE_NONPERIODIC ...
+  while [ $DateNum -lt ${#ensemble_Ens_DATE_NONPERIODIC[*]} ] ; do
+    DateBegin=${ensemble_Ens_DATE_NONPERIODIC[$DateNum]}
+    Duree=${ensemble_Ens_DATE_LENGTH_NONPERIODIC[$DateNum]}
+    RestartDate=${ensemble_Ens_DATE_RESTART_NONPERIODIC[$DateNum]}
+    
+  # - Determine number of day(s) in LENGTH_NONPERIODIC
+    IGCM_date_GetYearMonth ${DateBegin} year month
+    DureeLengthInDays=$(( $( IGCM_date_DaysInCurrentPeriod ${DateBegin} ${Duree} ) - 1 ))
+
+  # - Determine DateEnd
+    (( DateEnd = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${DureeLengthInDays} ) ))
+    
+    IGCM_debug_Print 2 "${DateBegin} => ${DateEnd} : ${StartDir}"
+    echo "${DateBegin} ${DateEnd} ${StartDir}" >> ${RUN_DIR}/CreatedDir.txt  
+    
+    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_INITFROM}${RestartDate}${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_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}.txt
+        echo "${SUBMIT} ${JobName} ; cd -"     >> ${RUN_DIR}/Qsub.${StartDir}.txt
+
+	# * Update files : config.card, Job_, COMP/comp.card
+	IGCM_ensemble_DateFilesUpdate ${DateBegin} ${DateEnd} ${RestartDate}
+      fi
+      
+      (( i = i + 1 ))
+    done
+
+    # Done. Save ${StartDir} submission text file
+    IGCM_sys_Cp ${RUN_DIR}/Qsub.${StartDir}.txt ${SUBMIT_DIR}
+
+    (( DateNum = DateNum + 1 ))
+  done
+
+  # Done. Save ${StartDir} submission text file
+  IGCM_sys_Cp ${RUN_DIR}/Qsub.${StartDir}.txt ${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} )
+  # ==> 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 ${ensemble_Ens_DATE_INITFROM}
+  IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Restarts RestartPath ${ensemble_Ens_DATE_INITPATH}
+
+    # [ATM/OCE/...]
+  for comp in ${config_ListOfComponents[*]} ; do
+    IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${comp} Restart "n"
+  done
+  
+  # ==> Job
+  sed -e "s/\(#.*\)${config_UserChoices_JobName}\( *#.*\)/\1${MemberDir} \2/"            \
+      -e "s/\(#.*Script_Output_\)${config_UserChoices_JobName}\(\.*\)/\1${MemberDir}\2/" \
+      -e "s/^PeriodNb=.*/PeriodNb=60/"                                                  \
+      ${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 #################
