Index: /trunk/libIGCM/libIGCM_ensemble/libIGCM_ensemble.ksh
===================================================================
--- /trunk/libIGCM/libIGCM_ensemble/libIGCM_ensemble.ksh	(revision 1006)
+++ /trunk/libIGCM/libIGCM_ensemble/libIGCM_ensemble.ksh	(revision 1007)
@@ -17,13 +17,13 @@
   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_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
+
   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"
 }
@@ -33,5 +33,5 @@
 {
   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
@@ -54,5 +54,8 @@
       IGCM_sys_Cp ${SUBMIT_DIR}/Qsub.*        ${RUN_DIR}
   fi
-  
+  if [ -f ${SUBMIT_DIR}/Qclean.* ]; then
+      IGCM_sys_Cp ${SUBMIT_DIR}/Qclean.*      ${RUN_DIR}
+  fi
+
   # Useful?
   #if [ -f  ${SUBMIT_DIR}/CreatedDir.txt ] ; then
@@ -60,19 +63,18 @@
   #fi
   # Useful?
-  #if [ -f  ${SUBMIT_DIR}/Qsub.txt ] ; then
-  #  IGCM_sys_Cp ${SUBMIT_DIR}/Qsub.txt ${RUN_DIR}
+  #if [ -f  ${SUBMIT_DIR}/Qsub.sh ] ; then
+  #  IGCM_sys_Cp ${SUBMIT_DIR}/Qsub.sh ${RUN_DIR}
   #fi
-
-  IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB NAME
-  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 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 ${F_CFG_ENS} Ens_PERTURB NAME
+  IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_PERTURB BEGIN_INIT
+  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_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 PERTURB_BIN
+  IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_PERTURB INITFROM
+  IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_PERTURB INITPATH
   IGCM_card_DefineVariableFromOption config.card UserChoices JobName
   IGCM_card_DefineVariableFromOption config.card UserChoices TagName
@@ -98,5 +100,5 @@
   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]}
@@ -110,7 +112,7 @@
   IGCM_debug_Print 1 "PerturbVar  = ${PerturbVar}"
   IGCM_debug_Print 1 "PerturbAmp  = ${PerturbAmp}"
-  
+
   IGCM_ensemble_SetAlpha ${ensemble_Ens_PERTURB_MEMBER}
-  
+
   # A few checks Period case:
 
@@ -252,19 +254,27 @@
 
         # 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
+        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.month.${StartDir}.sh
+        echo "${libIGCM}/clean_month.job ; cd -"     >> ${RUN_DIR}/Qclean.month.${StartDir}.sh
+
+        echo "cd ${StartDir}/${MemberDir}/ ;"  >> ${RUN_DIR}/Qclean.year.${StartDir}.sh
+        echo "${libIGCM}/clean_year.job ; cd -"     >> ${RUN_DIR}/Qclean.year.${StartDir}.sh
+
+        # * Update files : config.card, Job_, COMP/comp.card
+        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}.txt ${SUBMIT_DIR}
+    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}
 
   # - Next DateBegin
@@ -362,23 +372,31 @@
 
         # 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
+        echo "cd ${StartDir}/${MemberDir}/ ;"  >> Qsub.${StartDir}.sh
+        echo "${SUBMIT} ${JobName} ; cd -"     >> Qsub.${StartDir}.sh
+
+        echo "cd ${StartDir}/${MemberDir}/ ;"  >> ${RUN_DIR}/Qclean.month.${StartDir}.sh
+        echo "${libIGCM}/clean_month.job ; cd -"     >> ${RUN_DIR}/Qclean.month.${StartDir}.sh
+
+        echo "cd ${StartDir}/${MemberDir}/ ;"  >> ${RUN_DIR}/Qclean.year.${StartDir}.sh
+        echo "${libIGCM}/clean_year.job ; cd -"     >> ${RUN_DIR}/Qclean.year.${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
+        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}.txt ${SUBMIT_DIR}
+    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}
 
     (( DateNum = DateNum + 1 ))
@@ -637,5 +655,5 @@
   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"
 }
@@ -655,17 +673,21 @@
         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
+  if [ -f ${SUBMIT_DIR}/Qclean.* ]; then
+        IGCM_sys_Cp ${SUBMIT_DIR}/Qclean.*      ${RUN_DIR}
+  fi
+
+  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 PERIODICITY
+  IGCM_card_DefineArrayFromOption    ${F_CFG_ENS} Ens_DATE NONPERIODIC
+  IGCM_card_DefineArrayFromOption    ${F_CFG_ENS} Ens_DATE RESTART_NONPERIODIC
+  IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_DATE LENGTH
+  IGCM_card_DefineArrayFromOption    ${F_CFG_ENS} Ens_DATE LENGTH_NONPERIODIC
+  IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_DATE INITFROM
+  IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_DATE INITFROM_NONPERIODIC
+  IGCM_card_DefineVariableFromOption ${F_CFG_ENS} Ens_DATE INITPATH
   IGCM_card_DefineVariableFromOption config.card UserChoices JobName
   IGCM_card_DefineVariableFromOption config.card UserChoices TagName
@@ -675,29 +697,30 @@
   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[*]}"
+  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 "INITFROM_NONPERIODIC = ${ensemble_Ens_DATE_INITFROM_NONPERIODIC[*]}"
+  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
@@ -716,9 +739,9 @@
   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 ))
@@ -731,29 +754,29 @@
   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 ;;
+          *[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
+          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
+          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:
@@ -763,16 +786,26 @@
       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
-      
+
+      # 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"
-	  DateNum=0
-	  while [ $DateNum -lt ${#ensemble_Ens_DATE_NONPERIODIC[*]} ] ; do
-	      ensemble_Ens_DATE_LENGTH_NONPERIODIC[DateNum]=${ensemble_Ens_DATE_LENGTH}
-	      (( DateNum = DateNum + 1 ))
-	  done
+          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
+
+      # Use INITFROM if no NONPERIODIC_INITFROM given
+      if [[ ${#ensemble_Ens_DATE_INITFROM_NONPERIODIC[*]} < ${#ensemble_Ens_DATE_NONPERIODIC[*]} ]] ; then
+          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
+              ensemble_Ens_DATE_INITFROM_NONPERIODIC[DateNum]=${ensemble_Ens_DATE_INITFROM}
+              (( DateNum = DateNum + 1 ))
+          done
       fi
   else
@@ -780,30 +813,30 @@
       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 ))
+          # - 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"
 }
@@ -823,5 +856,5 @@
   # - Build directory name
   StartDir="${ensemble_Ens_DATE_NAME}"
-  
+
   # - Create directory for current DateBegin
   if [ ! -d  ${StartDir} ] ; then
@@ -832,18 +865,19 @@
       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 ))
@@ -851,15 +885,15 @@
   # - 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]}"
+      MemberDir="${ensemble_Ens_DATE_NAME}${DateNum}${Alpha[$i]}_per"
       echo
       IGCM_debug_Print 3 "${MemberDir}"
-      
+
       JobName="Job_${MemberDir}"
 
@@ -875,13 +909,19 @@
         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}
+        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.month.${StartDir}.sh
+        echo "${libIGCM}/clean_month.job ; cd -"     >> ${RUN_DIR}/Qclean.month.${StartDir}.sh
+
+        echo "cd ${StartDir}/${MemberDir}/ ;"  >> ${RUN_DIR}/Qclean.year.${StartDir}.sh
+        echo "${libIGCM}/clean_year.job ; cd -"     >> ${RUN_DIR}/Qclean.year.${StartDir}.sh
+
+        # * Update files : config.card, Job_, COMP/comp.card
+        IGCM_ensemble_DateFilesUpdate ${DateBegin} ${DateEnd} ${RestartDate}
       fi
-      
+
       (( i = i + 1 ))
     done
@@ -896,9 +936,12 @@
     esac
 
+    (( DateNum = DateNum + 1 )) # increment number of restart date
   done
 
   # Done. Save ${StartDir} submission text file
-  IGCM_sys_Cp ${RUN_DIR}/Qsub.${StartDir}.txt ${SUBMIT_DIR}
-  
+  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_DatePeriodicStarts"
 }
@@ -930,5 +973,5 @@
       IGCM_sys_Cd ${RUN_DIR}
   fi
-  
+
   DateNum=0
   # ... Loop over ensemble_Ens_DATE_NONPERIODIC ...
@@ -937,5 +980,6 @@
     Duree=${ensemble_Ens_DATE_LENGTH_NONPERIODIC[$DateNum]}
     RestartDate=${ensemble_Ens_DATE_RESTART_NONPERIODIC[$DateNum]}
-    
+    InitFrom=${ensemble_Ens_DATE_INITFROM_NONPERIODIC[$DateNum]}
+
   # - Determine number of day(s) in LENGTH_NONPERIODIC
     IGCM_date_GetYearMonth ${DateBegin} year month
@@ -944,16 +988,16 @@
   # - Determine DateEnd
     (( DateEnd = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${DureeLengthInDays} ) ))
-    
+
     IGCM_debug_Print 2 "${DateBegin} => ${DateEnd} : ${StartDir}"
-    echo "${DateBegin} ${DateEnd} ${StartDir}" >> ${RUN_DIR}/CreatedDir.txt  
-    
+    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]}"
+      MemberDir="${ensemble_Ens_DATE_NAME}${DateNum}${Alpha[$i]}"
       IGCM_debug_Print 3 "${MemberDir}"
-      
+
       JobName="Job_${MemberDir}"
 
@@ -971,16 +1015,24 @@
 
         # 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}
+        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.month.${StartDir}.sh
+        echo "${libIGCM}/clean_month.job ; cd -"     >> ${RUN_DIR}/Qclean.month.${StartDir}.sh
+
+        echo "cd ${StartDir}/${MemberDir}/ ;"  >> ${RUN_DIR}/Qclean.year.${StartDir}.sh
+        echo "${libIGCM}/clean_year.job ; cd -"     >> ${RUN_DIR}/Qclean.year.${StartDir}.sh
+
+        # * Update files : config.card, Job_, COMP/comp.card
+        IGCM_ensemble_DateFilesUpdate ${DateBegin} ${DateEnd} ${RestartDate} ${InitFrom}
       fi
-      
+
       (( i = i + 1 ))
     done
 
     # Done. Save ${StartDir} submission text file
-    IGCM_sys_Cp ${RUN_DIR}/Qsub.${StartDir}.txt ${SUBMIT_DIR}
+    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}
 
     (( DateNum = DateNum + 1 ))
@@ -988,6 +1040,8 @@
 
   # Done. Save ${StartDir} submission text file
-  IGCM_sys_Cp ${RUN_DIR}/Qsub.${StartDir}.txt ${SUBMIT_DIR}
-  
+  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"
 }
@@ -1004,4 +1058,10 @@
   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
+
   # ==> config.card
   # [ENSEMBLE]
@@ -1010,14 +1070,14 @@
   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 RestartJobName ${initFrom}
   IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Restarts RestartPath ${ensemble_Ens_DATE_INITPATH}
 
@@ -1026,5 +1086,6 @@
     IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${comp} Restart "n"
   done
-  
+  unset initFrom
+
   # ==> Job
   sed -e "s/\(#.*\)${config_UserChoices_JobName}\( *#.*\)/\1${MemberDir} \2/"            \
