Index: trunk/libIGCM/libIGCM_config/libIGCM_config.ksh
===================================================================
--- trunk/libIGCM/libIGCM_config/libIGCM_config.ksh	(revision 373)
+++ trunk/libIGCM/libIGCM_config/libIGCM_config.ksh	(revision 380)
@@ -269,5 +269,4 @@
 	    IGCM_debug_Print 1 "Number of years for PeriodLength : ${PeriodLengthInYears}"
 	    PeriodLengthInDays=0
-	    typeset i
 	    i=0
 	    until [ $i -ge $PeriodLengthInYears ] ; do 
@@ -280,5 +279,4 @@
 	    IGCM_debug_Print 1 "Number of months for PeriodLength : ${PeriodLengthInMonths}"
 	    PeriodLengthInDays=0
-	    typeset i
 	    i=0
 	    until [ $i -ge $PeriodLengthInMonths ] ; do 
@@ -300,5 +298,38 @@
 
     IGCM_debug_PopStack "IGCM_config_Analyse_PeriodLength"
-
+}
+
+#===================================
+function IGCM_config_Check
+{
+    IGCM_debug_PushStack "IGCM_config_Check"
+
+    # If one of the following modulo is not zero :
+    # we will issue an error then explain and exit in
+    # AA_job IGCM_debug_Verif_Exit call before binary submission
+
+    echo
+    IGCM_debug_Print 1 "IGCM_config_Check :"
+    echo
+
+    if ( [ ! X${config_Post_RebuildFrequency} = X${NULL_STR} ] || [ ! X${config_Post_RebuildFrequency} = XNONE ] ) ; then
+	AsynchronousRebuild=true
+	IGCM_debug_Print 1 "Asynchronous rebuild has been activated."
+	echo
+	# modulo (RebuildFrequency and PeriodLength/TimeSeriesFrequency/SeasonalFrequency) must be zero
+	IGCM_post_CheckModuloFrequency config_Post_RebuildFrequency config_UserChoices_PeriodLength
+	IGCM_post_CheckModuloFrequency config_Post_TimeSeriesFrequency config_Post_RebuildFrequency
+	IGCM_post_CheckModuloFrequency config_Post_SeasonalFrequency config_Post_RebuildFrequency
+    else
+	AsynchronousRebuild=false
+	IGCM_debug_Print 1 "Asynchronous rebuild has not been activated"
+	IGCM_debug_Print 1 "Proceed with standard post-treatment pathway"
+	echo
+	#modulo (TimeSeriesFrequency/SeasonalFrequency and PeriodLenght) must be zero
+	IGCM_post_CheckModuloFrequency config_Post_TimeSeriesFrequency config_UserChoices_PeriodLength
+	IGCM_post_CheckModuloFrequency config_Post_SeasonalFrequency   config_UserChoices_PeriodLength
+    fi
+
+    IGCM_debug_PopStack "IGCM_config_Check"
 }
 
@@ -435,8 +466,9 @@
 	if [ ${DRYRUN} -le 0 ] ; then
 	    if ( IGCM_sys_TestFileArchive ${R_OUT_KSH}/${PREFIX}_${Exe_Output} ) ; then
-		IGCM_debug_Exit "IGCM_config_PeriodStart" "RErun an old job."
+		IGCM_debug_Exit "IGCM_config_PeriodStart" "You are currently RErunning an old job."
 		IGCM_debug_Print 1 "Because of readonly permissions, you can't RErun a job when saved files"
 		IGCM_debug_Print 1 " are still in the ARCHIVE directory. You must deleted those files, or "
-		IGCM_debug_Print 1 " the whole ${R_SAVE} tree."
+		IGCM_debug_Print 1 " the whole ${R_SAVE} tree. See clean_month.job in ${libIGCM} directory."
+		IGCM_debug_Print 1 " This exit has been initiated because at least ${R_OUT_KSH}/${PREFIX}_${Exe_Output} exists."
 		IGCM_debug_Verif_Exit
 	    fi
@@ -476,16 +508,16 @@
     #==================================#
 
-    typeset i
-    (( 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
-
+    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
+    fi
     #==================================#
     #         And Build ExeDate        #
@@ -532,17 +564,18 @@
 	(( i=i+1 ))
 
-	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}
+	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
 	    fi
-	    eval IGCM_sys_Put_Out ${ExeNameOut} ${R_OUT_EXE}/${PREFIX}_${ExeNameIn} rw
 	fi
     done
 
     if [ ${DRYRUN} -le 1 ] ; then
-	typeset ExeCpuLog
 	tail -1500 ${Exe_Output} > ${Exe_Output}_tail.txt
 	ExeCpuLog=$( gawk -f ${libIGCM}/libIGCM_sys/IGCM_add_out.awk ${Exe_Output}_tail.txt )
@@ -688,5 +721,4 @@
 
     if [ ${SimulationLengthInDays} -ge ${ExperienceLengthInDays} ] ; then
-
 	#==========================#
         # End of entire simulation #
@@ -704,7 +736,5 @@
 	    IGCM_sys_Tree ${R_SAVE}
 	fi
-    
     else
-
 	#=================#
         # Submit next job #
@@ -719,4 +749,8 @@
         # SUBMIT NEXT JOB from SUBMIT_DIR and come back in RUN_DIR
 	IGCM_sys_Cd ${SUBMIT_DIR}
+	# Keep only the 5 latest ${Script_Output_Prefix}_${config_UserChoices_JobName}
+	ScriptTot=$( ls ${Script_Output_Prefix}_${config_UserChoices_JobName}.?????? > /dev/null 2>&1 | wc -l )
+	[ ${ScriptTot} -gt 5 ] && rm -f $( ls ${Script_Output_Prefix}_${config_UserChoices_JobName}.?????? | head -$(( ${ScriptTot} - 5 )) )
+	# Submit next job and come back
 	IGCM_sys_Qsub ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}
         IGCM_sys_Cd -
