Index: branches/ORCHIDEE_EXT/ORCHIDEE_OL/SPINUP/COMP/spinup.driver
===================================================================
--- branches/ORCHIDEE_EXT/ORCHIDEE_OL/SPINUP/COMP/spinup.driver	(revision 382)
+++ branches/ORCHIDEE_EXT/ORCHIDEE_OL/SPINUP/COMP/spinup.driver	(revision 408)
@@ -299,13 +299,13 @@
 
     IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/sechiba.card UserChoices sechiba_LEVEL ${spinup_UserChoices_sechiba_LEVEL}
-    spinup_SubJobPost_sechiba_TimeSeriesVars0=${spinup_SubJobPost_sechiba_TimeSeriesVars2D[0]} > /dev/null 2>&1
+    spinup_SubJobPost_sechiba_TimeSeriesVars0=${spinup_SubJobPost_sechiba_TimeSeriesVars2D[0]}
     if [ X${spinup_SubJobPost_sechiba_TimeSeriesVars0} != X${NULL_STR} ] ; then
-	IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/sechiba.card Post_1M_sechiba_history TimeSeriesVars2D "("$( echo ${spinup_SubJobPost_sechiba_TimeSeriesVars[@]} | sed -e "s/ /,/g" )")"
+	IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/sechiba.card Post_1M_sechiba_history TimeSeriesVars2D "("$( echo ${spinup_SubJobPost_sechiba_TimeSeriesVars2D[@]} | sed -e "s/ /,/g" )")"
     else
 	IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/sechiba.card Post_1M_sechiba_history TimeSeriesVars2D "()"
     fi
-    spinup_SubJobPost_sechiba_TimeSeriesVars0=${spinup_SubJobPost_sechiba_TimeSeriesVars3D[0]} > /dev/null 2>&1
+    spinup_SubJobPost_sechiba_TimeSeriesVars0=${spinup_SubJobPost_sechiba_TimeSeriesVars3D[0]}
     if [ X${spinup_SubJobPost_sechiba_TimeSeriesVars0} != X${NULL_STR} ] ; then
-	IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/sechiba.card Post_1M_sechiba_history TimeSeriesVars3D "("$( echo ${spinup_SubJobPost_sechiba_TimeSeriesVars[@]} | sed -e "s/ /,/g" )")"
+	IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/sechiba.card Post_1M_sechiba_history TimeSeriesVars3D "("$( echo ${spinup_SubJobPost_sechiba_TimeSeriesVars3D[@]} | sed -e "s/ /,/g" )")"
     else
 	IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/sechiba.card Post_1M_sechiba_history TimeSeriesVars3D "()"
@@ -646,6 +646,5 @@
 
 	    # We Get the forcing file from the previous run of ORCHIDEE
-	    ORCHIDEE_JobName=${LastJobName}
-	    sed -e "s&(\${config_SBG_RestartPath}/\${config_SBG_RestartJobName}/SBG/Restart/\${config_SBG_RestartJobName}_\${Date_Restarts}_stomate_forcing.nc, stomate_forcing.nc)&(${config_SBG_RestartPath}/${ORCHIDEE_JobName}/SBG/Restart/${ORCHIDEE_JobName}_${output_PreviousStage_LastRestartDate}_stomate_forcing.nc, stomate_forcing.nc)&" ${New_SUBMIT_DIR}/COMP/sechiba.card > sechiba.card.tmp
+	    sed -e "s&(\${config_SBG_RestartPath}/\${config_SBG_RestartJobName}/SBG/Restart/\${config_SBG_RestartJobName}_\${Date_Restarts}_stomate_forcing.nc, stomate_forcing.nc)&(${config_SBG_RestartPath}/${LastJobName}/SBG/Restart/${LastJobName}_${output_PreviousStage_LastRestartDate}_stomate_forcing.nc, stomate_forcing.nc)&" ${New_SUBMIT_DIR}/COMP/sechiba.card > sechiba.card.tmp
 	    IGCM_sys_Mv sechiba.card.tmp ${New_SUBMIT_DIR}/COMP/sechiba.card
 
@@ -661,4 +660,5 @@
 		fi
 	    done
+	    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card Post RebuildFrequency ${config_SubJob_PeriodLength}
 	    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card Post TimeSeriesFrequency ${config_SubJob_PeriodLength}
 
@@ -769,6 +769,5 @@
 
 	    # We Get the forcing file from the previous run of ORCHIDEE
-	    ORCHIDEE_JobName=${config_UserChoices_JobName}ORC_${iter}
-	    sed -e "s&(\${config_SBG_RestartPath}/\${config_SBG_RestartJobName}/SBG/Restart/\${config_SBG_RestartJobName}_\${Date_Restarts}_stomate_forcing.nc, stomate_forcing.nc)&(${config_SBG_RestartPath}/${ORCHIDEE_JobName}/SBG/Restart/${ORCHIDEE_JobName}_${output_PreviousStage_LastRestartDate}_stomate_forcing.nc, stomate_forcing.nc)&" ${New_SUBMIT_DIR}/COMP/sechiba.card > sechiba.card.tmp
+	    sed -e "s&(\${config_SBG_RestartPath}/\${config_SBG_RestartJobName}/SBG/Restart/\${config_SBG_RestartJobName}_\${Date_Restarts}_stomate_forcing.nc, stomate_forcing.nc)&(${config_SBG_RestartPath}/${LastJobName}/SBG/Restart/${LastJobName}_${output_PreviousStage_LastRestartDate}_stomate_forcing.nc, stomate_forcing.nc)&" ${New_SUBMIT_DIR}/COMP/sechiba.card > sechiba.card.tmp
 	    IGCM_sys_Mv sechiba.card.tmp ${New_SUBMIT_DIR}/COMP/sechiba.card
 
@@ -784,4 +783,5 @@
 		fi
 	    done
+	    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card Post RebuildFrequency ${config_SubJob_PeriodLength}
 	    eval IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card Post TimeSeriesFrequency ${config_SubJob_PeriodLength}
 
@@ -812,13 +812,8 @@
 
 	    # We Get the forcing file from the previous run of ORCHIDEE
-	    ORCHIDEE_JobName=${config_UserChoices_JobName}${output_PreviousStage_LastExtName}
 	    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/output.card PreviousStage LastRestartDate
-	    if ( [ X${spinup_UserChoices_DEBUG_SPIN} = Xn ] ) ; then  
-		last_Cforcing=${config_SBG_RestartPath}/${config_UserChoices_JobName}/SPIN/Output/${ORCHIDEE_JobName}/SBG/Restart/${ORCHIDEE_JobName}_${output_PreviousStage_LastRestartDate}_stomate_Cforcing.nc
-	    else
-		last_Cforcing=${config_SBG_RestartPath}/${ORCHIDEE_JobName}/SBG/Restart/${ORCHIDEE_JobName}_${output_PreviousStage_LastRestartDate}_stomate_Cforcing.nc
-	    fi
-	    ls -lrt ${last_Cforcing}
-	    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/stomate.card BoundaryFiles ListNonDel "(${last_Cforcing}, stomate_Cforcing.nc), \\"
+
+	    IGCM_card_WriteOption ${New_SUBMIT_DIR}/COMP/stomate.card BoundaryFiles ListNonDel \
+                    "(${config_SBG_RestartPath}/${LastJobName}/SBG/Restart/${LastJobName}_${output_PreviousStage_LastRestartDate}_stomate_Cforcing.nc, stomate_Cforcing.nc), \\"
 
 	    # Nb years for forcing FORCESOIL
@@ -959,9 +954,15 @@
     echo "SECHIBA WriteFrequency : " ${config_SRF_WriteFrequency}
     if ( [ X${StageName} != X"TSTOINI" ] && [ X${StageName} != X"TSTO" ] && [ X${StageName} != X"FORC" ] ) ; then
-    IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF WriteFrequency "${config_SRF_WriteFrequency}"
+	IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SRF WriteFrequency "${config_SRF_WriteFrequency}"
     fi
     if [ X"${spinup_UserChoices_ok_stomate}" = "Xy" ] ; then
 	echo "STOMATE WriteFrequency : " ${config_SBG_WriteFrequency}
-	IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG WriteFrequency "${config_SBG_WriteFrequency}"
+	case $StageName in
+	    "TSTOINI"|"TSTO")
+		IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG WriteFrequency "1Y"
+		;;
+	    *)
+		IGCM_card_WriteOption ${New_SUBMIT_DIR}/config.card SBG WriteFrequency "${config_SBG_WriteFrequency}"
+	esac
     fi
 
@@ -1005,5 +1006,5 @@
     # Did it finish ?
     if [ X${run_Configuration_PeriodState} != X"Completed" ] ; then
-	IGCM_debug_Exit "SPIN_update Error Run SubJob : " ${SubJobName}
+	IGCM_debug_Exit "SPIN_update Error Run SubJob : " ${SubJobName} ${run_Configuration_PeriodState}
     fi
     IGCM_debug_Verif_Exit
@@ -1023,11 +1024,8 @@
     if [ X${StageName} = X"FORC" ] ; then
         # This must be done on the ARCHIVE HOST.
-	if ( [ X${spinup_UserChoices_DEBUG_SPIN} = Xn ] ) ; then  
-	    last_restart=${config_SBG_RestartPath}/${config_UserChoices_JobName}/SPIN/Output/${ORCHIDEE_JobName}/SRF/Restart/${ORCHIDEE_JobName}_${output_PreviousStage_LastRestartDate}_sechiba_rest.nc
-	else
-	    last_restart=${config_SBG_RestartPath}/${ORCHIDEE_JobName}/SRF/Restart/${ORCHIDEE_JobName}_${output_PreviousStage_LastRestartDate}_sechiba_rest.nc
-	fi
 	IGCM_sys_MkdirArchive ${config_SBG_RestartPath}/${SubJobName}/SRF/Restart
-	IGCM_sys_RshArchive "cp -fp ${last_restart} ${config_SBG_RestartPath}/${SubJobName}/SRF/Restart/${SubJobName}_${This_Job_DateEnd}_sechiba_rest.nc"
+	IGCM_sys_RshArchive \
+	    "cp -fp ${config_SBG_RestartPath}/${LastJobName}/SRF/Restart/${LastJobName}_${output_PreviousStage_LastRestartDate}_sechiba_rest.nc"\
+                  " ${config_SBG_RestartPath}/${SubJobName}/SRF/Restart/${SubJobName}_${This_Job_DateEnd}_sechiba_rest.nc"
     fi
 
@@ -1047,5 +1045,6 @@
 	fi
 
-	IGCM_sys_RshArchive "mv -f ${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName}${output_PreviousStage_LastExtName} ${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName}/SPIN/Output/"
+	IGCM_sys_RshArchive "mv -f ${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName}${output_PreviousStage_LastExtName}"\
+                                 " ${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName}/SPIN/Output/"
     fi
 
