Index: trunk/libIGCM/libIGCM_ensemble/libIGCM_ensemble.ksh
===================================================================
--- trunk/libIGCM/libIGCM_ensemble/libIGCM_ensemble.ksh	(revision 741)
+++ trunk/libIGCM/libIGCM_ensemble/libIGCM_ensemble.ksh	(revision 742)
@@ -26,10 +26,12 @@
   IGCM_sys_Cp ${SUBMIT_DIR}/run.card.init ${RUN_DIR}
 
-  if [ -f  ${SUBMIT_DIR}/CreatedDir.txt ] ; then
-    IGCM_sys_Cp ${SUBMIT_DIR}/CreatedDir.txt ${RUN_DIR}
-  fi
-  if [ -f  ${SUBMIT_DIR}/Qsub.txt ] ; then
-    IGCM_sys_Cp ${SUBMIT_DIR}/Qsub.txt ${RUN_DIR}
-  fi
+  # Useful?
+  #if [ -f  ${SUBMIT_DIR}/CreatedDir.txt ] ; then
+  #  IGCM_sys_Cp ${SUBMIT_DIR}/CreatedDir.txt ${RUN_DIR}
+  #fi
+  # Useful?
+  #if [ -f  ${SUBMIT_DIR}/Qsub.txt ] ; then
+  #  IGCM_sys_Cp ${SUBMIT_DIR}/Qsub.txt ${RUN_DIR}
+  #fi
 
   IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB actif
@@ -202,18 +204,7 @@
         IGCM_sys_Cp Job_${ensemble_Ens_PERTURB_NAME} ${SUBMIT_DIR}/${StartDir}/${MemberDir}/${JobName}
 
-        ##############################
-        # TO BE A SYS FUNCTION BEGIN #
-        ##############################
-
-        # Dump command to be lauched in Qsub.txt
-        echo "cd ${StartDir}/${MemberDir}/ ;"  >> Qsub.txt
-        echo "sed -e 's/PeriodNb=.*/PeriodNb=48/' ${JobName} > ${JobName}.tmp ; " >> Qsub.txt
-        echo "mv ${JobName}.tmp ${JobName} ; " >> Qsub.txt
-        echo "ccc_msub ${JobName} ; cd -"      >> Qsub.txt
-
-        ############################
-        # TO BE A SYS FUNCTION END #
-        ############################
-
+        # Dump command to be lauched
+        echo "cd ${StartDir}/${MemberDir}/ ;"  >> Qsub.${StartDir}.txt
+        echo "${SUBMIT} ${JobName} ; cd -"     >> Qsub.${StartDir}.txt
       fi
 
@@ -226,4 +217,7 @@
       (( i = i + 1 ))
     done
+
+    # Done. Save ${StartDir} submission text file
+    IGCM_sys_Cp ${RUN_DIR}/Qsub.${StartDir}.txt ${SUBMIT_DIR}
 
   # - Next DateBegin
@@ -319,18 +313,7 @@
         IGCM_sys_Cp Job_${ensemble_Ens_PERTURB_NAME} ${SUBMIT_DIR}/${StartDir}/${MemberDir}/Job_${MemberDir}
 
-        ##############################
-        # TO BE A SYS FUNCTION BEGIN #
-        ##############################
-
-        # Dump command to be lauched in Qsub.txt
-        echo "cd ${StartDir}/${MemberDir}/ ;"  >> Qsub.txt
-        echo "sed -e 's/PeriodNb=.*/PeriodNb=48/' ${JobName} > ${JobName}.tmp ; " >> Qsub.txt
-        echo "mv ${JobName}.tmp ${JobName} ; " >> Qsub.txt
-        echo "ccc_msub ${JobName} ; cd -"      >> Qsub.txt
-
-        ############################
-        # TO BE A SYS FUNCTION END #
-        ############################
-
+        # Dump command to be lauched
+        echo "cd ${StartDir}/${MemberDir}/ ;"  >> Qsub.${StartDir}.txt
+        echo "${SUBMIT} ${JobName} ; cd -"     >> Qsub.${StartDir}.txt
       fi
 
@@ -346,4 +329,7 @@
       (( i = i + 1 ))
     done
+
+    # Done. Save ${StartDir} submission text file
+    IGCM_sys_Cp ${RUN_DIR}/Qsub.${StartDir}.txt ${SUBMIT_DIR}
 
     (( DateNum = DateNum + 1 ))
@@ -373,24 +359,17 @@
   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}
+  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
+
   # ==> Job
-  ##############################
-  # TO BE A SYS FUNCTION BEGIN #
-  ##############################
-
-  #sed -e "s/\(#MSUB -r \)[A-Za-z0-9]*\( *#.*\)/\1 ${MemberDir} \2/"           \
-  #    -e "s/\(#MSUB -o Script_Output_\)[A-Za-z0-9]*\(\.*\)/\1${MemberDir}\2/" \
-  #    -e "s/\(#MSUB -e Script_Output_\)[A-Za-z0-9]*\(\.*\)/\1${MemberDir}\2/" \
-  #    ${SUBMIT_DIR}/${StartDir}/${MemberDir}/Job_${MemberDir} > Job_${MemberDir}.tmp
-  #IGCM_sys_Mv Job_${MemberDir}.tmp ${SUBMIT_DIR}/${StartDir}/${MemberDir}/Job_${MemberDir}
-
-  ############################
-  # TO BE A SYS FUNCTION END #
-  ############################
+  sed -e "s/\(#.*\)${ensemble_Ens_PERTURB_NAME}\( *#.*\)/\1${MemberDir} \2/"            \
+      -e "s/\(#.*Script_Output_\)${ensemble_Ens_PERTURB_NAME}\(\.*\)/\1${MemberDir}\2/" \
+      -e "s/^PeriodNb=.*/PeriodNb=48/"                                                  \
+      ${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"
