Index: trunk/libIGCM/libIGCM_config/libIGCM_config.ksh
===================================================================
--- trunk/libIGCM/libIGCM_config/libIGCM_config.ksh	(revision 455)
+++ trunk/libIGCM/libIGCM_config/libIGCM_config.ksh	(revision 457)
@@ -19,6 +19,5 @@
     # Debug Print :
     echo
-    IGCM_debug_Print 1 "IGCM_config_Initialize :"
-    echo
+    IGCM_debug_Print 1 "IGCM_config_Initialize"
 
     if [ ! -r ${SUBMIT_DIR}/run.card ]; then 
@@ -65,5 +64,5 @@
         IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card UserChoices ${option}
     done
-
+    echo
     IGCM_debug_Print 1 "DefineArrayFromOption  : config_UserChoices"
     # Name Space of this experience 
@@ -93,5 +92,4 @@
     IGCM_debug_Print 1 "DefineArrayFromSection : ListOfComponents"
     IGCM_debug_Print 3 ${config_ListOfComponents[*]}
-    echo
 
     NbComponents=${#config_ListOfComponents[*]}
@@ -105,5 +103,5 @@
     #==================================
     # Define Outputs Name
-    IGCM_debug_Print 1 "Define Script_Output_Prefix and Exe_Output"
+    IGCM_debug_Print 2 "Define Script_Output_Prefix and Exe_Output"
     eval Script_Output_Prefix=${config_UserChoices_Script_Output_Prefix:='Script_Output'}
     IGCM_debug_Print 3 "Script_Output_Prefix = ${Script_Output_Prefix}"
@@ -160,6 +158,5 @@
     # and PeriodNb through config.card
     R_INIT=${config_UserChoices_R_INIT:=${R_IN}/INIT}
-    echo
-    IGCM_debug_Print 1 "(Re)Define R_INIT, R_BC and PeriodNb"
+    IGCM_debug_Print 2 "(Re)Define R_INIT, R_BC and PeriodNb"
     IGCM_debug_Print 3 "R_INIT=${R_INIT}"
     R_BC=${config_UserChoices_R_BC:=${R_IN}/BC}
@@ -188,16 +185,17 @@
 	IGCM_sys_MkdirArchive ${R_SAVE}
     else
+	IGCM_sys_TestDirArchive ${R_SAVE}
+	[ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive"
 	#Test state of run in run.card
 	IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState
+	
 	if ( [ ${run_Configuration_PeriodState} != "Start" ] && [ ${run_Configuration_PeriodState} != "Running" ] && [ ${run_Configuration_PeriodState} != "OnQueue" ] && [ ${run_Configuration_PeriodState} != "Continue" ] ) ; then
 	    echo 
-	    IGCM_debug_Print 1 "!!!! IGCM_config_Initialize Error PeriodState : " ${run_Configuration_PeriodState} "!!!!!!!!!!"
-	    echo 
-	    IGCM_debug_Exit "IGCM_config_Initialize Error PeriodState : " ${run_Configuration_PeriodState}
+	    IGCM_debug_Print 1 "!! Error in run.card with PeriodState : " ${run_Configuration_PeriodState} "!!"
+	    IGCM_debug_Print 1 "Try running ${libIGCM}/clean_month.job to fix this"
+	    IGCM_debug_Exit
 	    IGCM_debug_Verif_Exit
 	fi
     fi
-    IGCM_sys_TestDirArchive ${R_SAVE}
-    [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive"
 
     #==================================
@@ -278,5 +276,5 @@
 	*Y|*y)
 	    PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | sed -e 's/[yY]//' ) 
-	    IGCM_debug_Print 1 "Number of years for PeriodLength : ${PeriodLengthInYears}"
+	    IGCM_debug_Print 2 "Number of years for PeriodLength : ${PeriodLengthInYears}"
 	    PeriodLengthInDays=0
 	    i=0
@@ -288,5 +286,5 @@
 	*M|*m)
 	    PeriodLengthInMonths=$( echo ${config_UserChoices_PeriodLength} | sed -e 's/[mM]//' ) 
-	    IGCM_debug_Print 1 "Number of months for PeriodLength : ${PeriodLengthInMonths}"
+	    IGCM_debug_Print 2 "Number of months for PeriodLength : ${PeriodLengthInMonths}"
 	    PeriodLengthInDays=0
 	    i=0
@@ -321,5 +319,5 @@
 
     echo
-    IGCM_debug_Print 1 "IGCM_config_Check :"
+    IGCM_debug_Print 1 "IGCM_config_Check"
     echo
 
@@ -331,9 +329,9 @@
 	echo
 	# modulo (RebuildFrequency and PeriodLength/TimeSeriesFrequency/SeasonalFrequency) must be zero
-	IGCM_debug_Print 1 "Coherence between RebuildFrequency and PeriodLength:"
+	IGCM_debug_Print 1 "Check coherence between RebuildFrequency and PeriodLength"
 	IGCM_post_CheckModuloFrequency config_Post_RebuildFrequency config_UserChoices_PeriodLength
-	IGCM_debug_Print 1 "Coherence between TimeSeriesFrequency and RebuildFrequency:"
+	IGCM_debug_Print 1 "Check coherence between TimeSeriesFrequency and RebuildFrequency"
 	IGCM_post_CheckModuloFrequency config_Post_TimeSeriesFrequency config_Post_RebuildFrequency
-	IGCM_debug_Print 1 "Coherence between SeasonalFrequency and RebuildFrequency:"
+	IGCM_debug_Print 1 "Check coherence between SeasonalFrequency and RebuildFrequency"
 	IGCM_post_CheckModuloFrequency config_Post_SeasonalFrequency config_Post_RebuildFrequency
     else
@@ -343,7 +341,7 @@
 	echo
 	#modulo (TimeSeriesFrequency/SeasonalFrequency and PeriodLenght) must be zero
-	IGCM_debug_Print 1 "Coherence between TimeSeriesFrequency and PeriodLength:"
+	IGCM_debug_Print 1 "Check coherence between TimeSeriesFrequency and PeriodLength"
 	IGCM_post_CheckModuloFrequency config_Post_TimeSeriesFrequency config_UserChoices_PeriodLength
-	IGCM_debug_Print 1 "Coherence between SeasonalFrequency and PeriodLength:"
+	IGCM_debug_Print 1 "Check coherence between SeasonalFrequency and PeriodLength"
 	IGCM_post_CheckModuloFrequency config_Post_SeasonalFrequency   config_UserChoices_PeriodLength
     fi
@@ -354,9 +352,9 @@
     until [ $i -ge $NbJob ]; do
 	value=${CHUNCK2D_SIZE[${i}]}
-	IGCM_debug_Print 1 "Coherence between All Chunck2D frequency and TimeSeriesFrequency:"
+	IGCM_debug_Print 1 "Check coherence between All Chunck2D frequency and TimeSeriesFrequency"
 	IGCM_post_CheckModuloFrequency value config_Post_TimeSeriesFrequency
 	case ${value} in  
 	    *Y|*y) ;; 
-	    *)  IGCM_debug_Print 3 "All ChunckJob2D frequency must be expressed in year *Y|*y in comp.card"
+	    *)  IGCM_debug_Print 1 "All ChunckJob2D frequency must be expressed in year *Y|*y in comp.card"
 		IGCM_debug_Exit "This will stop the job" ;;
 	esac
@@ -369,9 +367,9 @@
     until [ $i -ge $NbJob ]; do
 	value=${CHUNCK3D_SIZE[${i}]}
-	IGCM_debug_Print 1 "Coherence between All Chunck3D frequency and TimeSeriesFrequency:"
+	IGCM_debug_Print 1 "Check coherence between All Chunck3D frequency and TimeSeriesFrequency"
 	IGCM_post_CheckModuloFrequency value config_Post_TimeSeriesFrequency
 	case ${value} in  
 	    *Y|*y) ;; 
-	    *)  IGCM_debug_Print 3 "All ChunckJob3D frequency must be expressed in year *Y|*y in comp.card"
+	    *)  IGCM_debug_Print 1 "All ChunckJob3D frequency must be expressed in year *Y|*y in comp.card"
 		IGCM_debug_Exit "This will stop the job" ;;
 	esac
@@ -388,5 +386,5 @@
 
     echo
-    IGCM_debug_Print 1 "IGCM_config_PeriodStart :"
+    IGCM_debug_Print 1 "IGCM_config_PeriodStart"
     echo
 
@@ -426,7 +424,8 @@
 	if ( [ ${run_Configuration_PeriodState} != "Running" ] && [ ${run_Configuration_PeriodState} != "OnQueue" ] && [ ${run_Configuration_PeriodState} != "Continue" ] ) ; then
 	    echo 
-	    IGCM_debug_Print 1 "!!!!!! IGCM_config_PeriodStart Error PeriodState : " ${run_Configuration_PeriodState} "!!!!!!!!!!"
-	    echo 
-	    IGCM_debug_Exit "IGCM_config_PeriodStart Error PeriodState : " ${run_Configuration_PeriodState}
+	    IGCM_debug_Print 1 "!! Error in run.card with PeriodState : " ${run_Configuration_PeriodState} "!!"
+	    IGCM_debug_Print 1 "Try running ${libIGCM}/clean_month.job to fix this"
+	    echo
+	    IGCM_debug_Exit
 	    IGCM_debug_Verif_Exit
 	fi
@@ -454,5 +453,5 @@
  	    #eval ls -l ${SUBMIT_DIR}/${Last_Script_Output_Name}
  	    #eval IGCM_sys_Put_Out ${SUBMIT_DIR}/${Last_Script_Output_Name} ${R_OUT_KSH}/${Last_Script_Output_Name} > /dev/null 2>&1
-	    IGCM_debug_Print 1 "Try to save previous ksh job output"
+	    IGCM_debug_Print 2 "Try to save previous ksh job output"
 	    IGCM_sys_Cd ${SUBMIT_DIR}/
 	    IGCM_sys_Put_Out ${Last_Script_Output_Name} ${R_OUT_KSH}/${Last_Script_Output_Name}.$$ rw
@@ -483,11 +482,11 @@
     # Debug Print :
     IGCM_debug_Print 1 "IGCM_config_PeriodStart : Before Execution"
-    IGCM_debug_Print 3 "Year of simulation      : ${year}"
-    IGCM_debug_Print 3 "Month of simulation     : ${month}"
-    IGCM_debug_Print 3 "PeriodLengthInDays      : ${PeriodLengthInDays}"
-    IGCM_debug_Print 3 "PeriodDateBegin         : ${PeriodDateBegin}"
-    IGCM_debug_Print 3 "PeriodDateEnd           : ${PeriodDateEnd}"
-    IGCM_debug_Print 3 "SimulationLengthInDays  : ${SimulationLengthInDays}"
-    IGCM_debug_Print 3 "ExperienceLengthInDays  : ${ExperienceLengthInDays}"
+    IGCM_debug_Print 1 "Year of simulation      : ${year}"
+    IGCM_debug_Print 1 "Month of simulation     : ${month}"
+    IGCM_debug_Print 1 "PeriodLengthInDays      : ${PeriodLengthInDays}"
+    IGCM_debug_Print 1 "PeriodDateBegin         : ${PeriodDateBegin}"
+    IGCM_debug_Print 1 "PeriodDateEnd           : ${PeriodDateEnd}"
+    IGCM_debug_Print 1 "SimulationLengthInDays  : ${SimulationLengthInDays}"
+    IGCM_debug_Print 1 "ExperienceLengthInDays  : ${ExperienceLengthInDays}"
 
     #================================================================#
@@ -518,5 +517,5 @@
     else
 	if ( IGCM_sys_TestFileArchive ${R_OUT_KSH}/${PREFIX}_${Exe_Output} ) ; then
-	    IGCM_debug_Print 1 "IGCM_config_PeriodStart" "RErun an old job. DEBUG of DEV mode."
+	    IGCM_debug_Print 1 "IGCM_config_PeriodStart" "RErun an old job. Allowed in DEBUG or DEV mode."
 	fi
     fi
@@ -531,5 +530,5 @@
 
     echo
-    IGCM_debug_Print 1 "IGCM_config_PeriodEnd :"
+    IGCM_debug_Print 1 "IGCM_config_PeriodEnd"
     echo
 
@@ -539,8 +538,9 @@
     IGCM_sys_Put_Out ${Exe_Output} ${R_OUT_KSH}/${PREFIX}_${Exe_Output}
     eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${Exe_Output}"
-
     IGCM_sys_Put_Out ${SUBMIT_DIR}/run.card ${R_OUT_KSH}/run.card rw
-    
-    typeset LS_comp LS_bin ExeDate ExeCpuLog ExeSize NextExeSize LastCompExeSize
+
+    IGCM_debug_Print 1 "Check components binary : size and creation date"
+
+    typeset LS_comp LS_bin ExeDate ExeCpuLog NextExeSize LastCompExeSize
     typeset comp i    
     typeset ExeNameIn ExeNameOut 
@@ -550,15 +550,13 @@
     #==================================#
 
-    if [ ${DRYRUN} -le 1 ] ; then
-	(( i=0 ))
-	if ( ${FirstInitialize} ) ; then
-	    run_Log_LastExeSize=""
-	    for comp in ${config_ListOfComponents[*]} ; do
-		run_Log_LastExeSize[$i]=0
-		(( i=i+1 ))
-	    done
-	else
-	    IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/run.card Log LastExeSize
-	fi
+    (( i=0 ))
+    if ( ${FirstInitialize} ) ; then
+	run_Log_LastExeSize=""
+	for comp in ${config_ListOfComponents[*]} ; do
+	    run_Log_LastExeSize[$i]=0
+	    (( i=i+1 ))
+	done
+    else
+	IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/run.card Log LastExeSize
     fi
     #==================================#
@@ -575,5 +573,5 @@
     for comp in ${config_ListOfComponents[*]} ; do
 
-	IGCM_debug_Print 1 ${comp}
+	IGCM_debug_Print 3 ${comp}
 
 	eval ExeNameIn=\${config_Executable_${comp}[0]}
@@ -606,16 +604,18 @@
 	(( i=i+1 ))
 
-	if [ ${DRYRUN} -le 1 ] ; then
-	    if [ ${ExeSize} -ne ${LastCompExeSize} ] ; then
-		if ( ${FirstInitialize} ) ; then
-		    IGCM_debug_Print 1 "Put first ${ExeNameIn} in ${R_OUT_EXE} !"
-		else
-		    IGCM_debug_Print 1 "${ExeNameIn} has changed in ${R_EXE} !"
-		    eval FileToBeDeleted[${#FileToBeDeleted[@]}]=${ExeNameOut}
-		fi
-		eval IGCM_sys_Put_Out ${ExeNameOut} ${R_OUT_EXE}/${PREFIX}_${ExeNameIn} rw
+	if [ ${ExeSize} -ne ${LastCompExeSize} ] ; then
+	    if ( ${FirstInitialize} ) ; then
+		IGCM_debug_Print 1 "Save first ${ExeNameIn} in ${R_OUT_EXE} !"
+	    else
+		IGCM_debug_Print 1 "${ExeNameIn} has changed in ${R_EXE} !"
+		IGCM_debug_Print 1 "Save latest ${ExeNameIn} in ${R_OUT_EXE} !"
+		eval FileToBeDeleted[${#FileToBeDeleted[@]}]=${ExeNameOut}
 	    fi
+	    eval IGCM_sys_Put_Out ${ExeNameOut} ${R_OUT_EXE}/${PREFIX}_${ExeNameIn} rw
 	fi
     done
+
+    NextExeSize=${NextExeSize}" )"
+    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Log LastExeSize "${NextExeSize}"
 
     if [ ${DRYRUN} -le 1 ] ; then
@@ -632,11 +632,9 @@
     fi
 
-    NextExeSize=${NextExeSize}" )"
-    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Log LastExeSize "${NextExeSize}"
-
     # All was right ? no ? then we stop.
     IGCM_debug_Verif_Exit
 
     # If all was OK, we can delete all files not necessary for next Job
+    echo
     IGCM_debug_Print 1 "Files that will be deleted before next period-run : "
 
@@ -652,5 +650,5 @@
 
     # To use this function, one must copy libIGCM.card from ${libIGCM} directory
-    # and put it in ${SUBMIT_DIR} directory. Ater modifications of ${SUBMIT_DIR}/libIGCM.card,
+    # and put it in ${SUBMIT_DIR} directory. After modifications of ${SUBMIT_DIR}/libIGCM.card,
     # variables define inside [UserChanges] will be modified for next Period of libIGCM main loop. 
     if [ -f ${SUBMIT_DIR}/libIGCM.card ] ; then
@@ -676,5 +674,5 @@
 	    case ${option} in
 		config_UserChoices_DateEnd)
-		    IGCM_debug_PrintVariables 3 config_UserChoices_DateEnd
+		    IGCM_debug_PrintVariables 1 config_UserChoices_DateEnd
 		    DateEnd=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} )
 
@@ -688,18 +686,19 @@
 		    ;;
 		config_UserChoices_PeriodLength)
+		    IGCM_debug_Print 1  "Change config_UserChoices_PeriodLength=${config_UserChoices_PeriodLength}"
 		    ;;
 		PeriodNb)
-		    IGCM_debug_Print 3  "Loop in main Job with ${PeriodNb} period(s)"
+		    IGCM_debug_Print 1  "Loop in main Job with ${PeriodNb} period(s)"
 		    ;;
 		config_Post_RebuildFrequency)
-		    IGCM_debug_Print 3  "Change config_Post_RebuildFrequency=${config_Post_RebuildFrequency} : IGCM_post_Configure"
+		    IGCM_debug_Print 1  "Change config_Post_RebuildFrequency=${config_Post_RebuildFrequency} : IGCM_post_Configure"
 		    IGCM_post_Configure
 		    ;;
 		config_Post_TimeSeriesFrequency)
-		    IGCM_debug_Print 3  "Change config_Post_TimeSeriesFrequency = ${config_Post_TimeSeriesFrequency} : IGCM_post_Initialize"
+		    IGCM_debug_Print 1  "Change config_Post_TimeSeriesFrequency = ${config_Post_TimeSeriesFrequency} : IGCM_post_Initialize"
 		    IGCM_post_Configure
 		    ;;
 		config_Post_SeasonalFrequency)
-		    IGCM_debug_Print 3  "Change config_Post_SeasonalFrequency = ${config_Post_SeasonalFrequency} : IGCM_post_Initialize"
+		    IGCM_debug_Print 1  "Change config_Post_SeasonalFrequency = ${config_Post_SeasonalFrequency} : IGCM_post_Initialize"
 		    IGCM_post_Configure
 		    ;;
@@ -726,7 +725,7 @@
     echo
     IGCM_debug_Print 1 "IGCM_config_PeriodEnd : Preparing Next Execution"
-    IGCM_debug_Print 3 "PeriodDateBegin       : ${PeriodDateBegin}"
-    IGCM_debug_Print 3 "PeriodDateEnd         : ${PeriodDateEnd}"
-    IGCM_debug_Print 3 "PeriodLengthInDays    : ${PeriodLengthInDays}"
+    IGCM_debug_Print 1 "PeriodDateBegin       : ${PeriodDateBegin}"
+    IGCM_debug_Print 1 "PeriodDateEnd         : ${PeriodDateEnd}"
+    IGCM_debug_Print 1 "PeriodLengthInDays    : ${PeriodLengthInDays}"
 
     PeriodDateBegin=$( IGCM_date_ConvertFormatToHuman ${PeriodDateBegin} )
@@ -764,5 +763,5 @@
 
     echo
-    IGCM_debug_Print 1 "IGCM_config_Finalize :"
+    IGCM_debug_Print 1 "IGCM_config_Finalize"
     echo
 
