Index: /trunk/libIGCM/AA_create_se
===================================================================
--- /trunk/libIGCM/AA_create_se	(revision 148)
+++ /trunk/libIGCM/AA_create_se	(revision 149)
@@ -22,5 +22,5 @@
 #-Q- sx8brodie # pour recevoir un mail en cas de depassement du temps Elapsed (ou autre pb.)
 #-Q- sx8brodie # @ notification = error
-#-Q- sx8brodie # @ environment  = $DEBUG_debug ; $MODIPSL ; $libIGCM ; $libIGCM_SX ; $SUBMIT_DIR ; $REBUILD_DIR ; $RebuildFromArchive ; $POST_DIR ; $DateBegin ; $PeriodDateBegin ; $PeriodDateEnd ; $NbRebuildDir ; $StandAlone ; $RESOL_ATM ; $RESOL_OCE ; $RESOL_ICE ; $RESOL_SRF ; $MASTER
+#-Q- sx8brodie # @ environment  = $DEBUG_debug ; $MODIPSL ; $libIGCM ; $libIGCM_SX ; $SUBMIT_DIR ; $REBUILD_DIR ; $RebuildFromArchive ; $POST_DIR ; $MASTER ; $DateBegin ; $PeriodDateBegin ; $PeriodDateEnd ; $NbRebuildDir ; $StandAlone ; $RESOL_ATM ; $RESOL_OCE ; $RESOL_ICE ; $RESOL_SRF ; $MASTER
 #-Q- sx8brodie # @ queue
 #-Q- aix6 #!/bin/ksh
@@ -38,5 +38,5 @@
 #-Q- aix6 # pour recevoir un mail en cas de depassement du temps Elapsed (ou autre pb.)
 #-Q- aix6 # @ notification = error
-#-Q- aix6 # @ environment  = $DEBUG_debug ; $MODIPSL ; $libIGCM ; $libIGCM_SX ; $SUBMIT_DIR ; $REBUILD_DIR ; $RebuildFromArchive ; $POST_DIR ; $DateBegin ; $PeriodDateBegin ; $PeriodDateEnd ; $NbRebuildDir ; $StandAlone ; $RESOL_ATM ; $RESOL_OCE ; $RESOL_ICE ; $RESOL_SRF ; $MASTER
+#-Q- aix6 # @ environment  = $DEBUG_debug ; $MODIPSL ; $libIGCM ; $libIGCM_SX ; $SUBMIT_DIR ; $REBUILD_DIR ; $RebuildFromArchive ; $POST_DIR ; $MASTER ; $DateBegin ; $PeriodDateBegin ; $PeriodDateEnd ; $NbRebuildDir ; $StandAlone ; $RESOL_ATM ; $RESOL_OCE ; $RESOL_ICE ; $RESOL_SRF ; $MASTER
 #-Q- aix6 # @ queue
 #-Q- sx8mercure #!/bin/ksh
@@ -171,5 +171,5 @@
 freq=$( echo ${config_Post_SeasonalFrequency} |  sed -e "s/[yY]//" )
 #
-an_fin=$( expr $( IGCM_date_ConvertGregorianDateToJulian $PeriodDateEnd ) / 1000 )
+an_fin=$(( $( IGCM_date_ConvertGregorianDateToJulian ${PeriodDateEnd} ) / 1000 ))
 an_deb=$( IGCM_date_YearDigit $(( an_fin - freq + 1 )) )
 an_fin=$( IGCM_date_YearDigit ${an_fin} )
@@ -448,15 +448,4 @@
 YEARS=${an_deb}_${an_fin}
 
-# clean environment variables and export usefull one :
-if [ X$( hostname -s ) = Xrhodes ] ; then
-    LISTE_ENV=$( env | grep -iv MYLANG | grep -iv HOST | grep -iv LOGIN | grep -iv config_ | grep -iv R_ | grep -iv libIGCM | grep -iv PERIOD \
-	| grep -iv DMFDIR | grep -iv AN_| grep -iv YEARS | grep -iv ex | grep -iv RESOL_ | grep -iv PATH | grep -iv WORKDIR | grep -iv USER   \
-	| grep -iv LOGNAME | grep -iv PROFILE | grep -iv ENV | grep -iv TMPDIR | grep -iv POST_DIR | grep -iv DB |awk -F= '{print $1}' )
-    
-    for variables in ${LISTE_ENV} ; do
-	unset ${variables}
-    done
-fi
-
 export POST_DIR; export SUBMIT_DIR; export libIGCM; export R_INIT; export R_BC; export StandAlone
 export RESOL_ATM; export RESOL_OCE ; export RESOL_ICE ; export RESOL_SRF
Index: /trunk/libIGCM/AA_create_ts
===================================================================
--- /trunk/libIGCM/AA_create_ts	(revision 148)
+++ /trunk/libIGCM/AA_create_ts	(revision 149)
@@ -7,5 +7,5 @@
 #-Q- platine #BSUB -n 1                      # reservation des processeurs pour le job
 #-Q- platine #BSUB -W 1:00                   # Limite temps
-#-Q- platine #BSUB -q post              # Passage en queue post
+#-Q- platine #BSUB -q post                   # Passage en queue post
 #-Q- sx8brodie #!/bin/ksh
 #-Q- sx8brodie #######################
@@ -22,5 +22,5 @@
 #-Q- sx8brodie # pour recevoir un mail en cas de depassement du temps Elapsed (ou autre pb.)
 #-Q- sx8brodie # @ notification = error
-#-Q- sx8brodie # @ environment  = $DEBUG_debug ; $MODIPSL ; $libIGCM ; $libIGCM_SX ; $SUBMIT_DIR ; $REBUILD_DIR ; $RebuildFromArchive ; $POST_DIR ; $DateBegin ; $PeriodDateBegin ; $PeriodDateEnd ; $NbRebuildDir ; $StandAlone ; $RESOL_ATM ; $RESOL_OCE ; $RESOL_ICE ; $RESOL_SRF ; $MASTER
+#-Q- sx8brodie # @ environment  = $DEBUG_debug ; $MODIPSL ; $libIGCM ; $libIGCM_SX ; $SUBMIT_DIR ; $REBUILD_DIR ; $RebuildFromArchive ; $POST_DIR ; $MASTER ; $RebuildFrequency ; $PeriodDateBegin ; $PeriodDateEnd ; $NbRebuildDir ; $StandAlone ; $CompletedFlag ; $TsTask ; $CompToRead ; $FlagToRead ; $RESOL_ATM ; $RESOL_OCE ; $RESOL_ICE ; $RESOL_SRF ; $MASTER
 #-Q- aix6 #!/bin/ksh
 #-Q- aix6 #######################
@@ -37,5 +37,5 @@
 #-Q- aix6 # pour recevoir un mail en cas de depassement du temps Elapsed (ou autre pb.)
 #-Q- aix6 # @ notification = error
-#-Q- aix6 # @ environment  = $DEBUG_debug ; $MODIPSL ; $libIGCM ; $libIGCM_SX ; $SUBMIT_DIR ; $REBUILD_DIR ; $RebuildFromArchive ; $POST_DIR ; $DateBegin ; $PeriodDateBegin ; $PeriodDateEnd ; $NbRebuildDir ; $StandAlone ; $RESOL_ATM ; $RESOL_OCE ; $RESOL_ICE ; $RESOL_SRF ; $MASTER
+#-Q- aix6 # @ environment  = $DEBUG_debug ; $MODIPSL ; $libIGCM ; $libIGCM_SX ; $SUBMIT_DIR ; $REBUILD_DIR ; $RebuildFromArchive ; $POST_DIR ; $MASTER ; $RebuildFrequency ; $DateBegin ; $PeriodDateBegin ; $PeriodDateEnd ; $NbRebuildDir ; $StandAlone ; $CompletedFlag ; $TsTask ; $CompToRead ; $FlagToRead ; $RESOL_ATM ; $RESOL_OCE ; $RESOL_ICE ; $RESOL_SRF ; $MASTER
 #-Q- aix6 # @ queue
 #-Q- sx8brodie # @ queue
@@ -97,5 +97,5 @@
 #D- TEMPORARY Flag to determine atmospheric resolution
 #D- Default : value from atmospheric driver if any
-RESOL_ATM=${RESOL_ATM:=ALL}
+RESOL_ATM=ALL
 
 #D- TEMPORARY Flag to determine ocean resolution
@@ -109,5 +109,5 @@
 #D- Flag to determine surface resolution
 #D- Default : value from surface driver if any
-RESOL_SRF=${RESOL_SRF:=ALL}
+RESOL_SRF=ALL
 
 ########################################################################
@@ -133,6 +133,4 @@
 
 ########################################################################
-
-#set -vx
 
 if [ ${DEBUG_debug} = true ] ; then
@@ -170,14 +168,25 @@
 
 #==================================
-
 R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName}
 #
-IGCM_card_DefineArrayFromSection       ${CARD_DIR}/config.card ListOfComponents
-#
-# Determine period for time series. Default : value from AA_job if any
+# Determine component to take care of depending on kind of task create_ts will perform
+#
+( [ X${TsTask} = XChunck2D ] || [ X${TsTask} = XChunck3D ] ) && set -A config_ListOfComponents ${CompToRead} || IGCM_card_DefineArrayFromSection ${CARD_DIR}/config.card ListOfComponents
+#
+# Determine period for time series. Default : value from AA_job or from launch_TS if any
 #
 DateBegin=${DateBegin:=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateBegin} )}
 #
 PeriodDateEnd=${PeriodDateEnd:=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} )}
+#
+# Determine Dimension of the produced time series : 2D or 3D
+if (   [ X${TsTask} = XChunck2D ] || [ X${TsTask} = X2D ] ) ; then
+    Dimension=2D
+elif ( [ X${TsTask} = XChunck3D ] || [ X${TsTask} = X3D ] ) ; then
+    Dimension=3D
+else
+    Dimension=""
+fi
+
 
 ########################################################################
@@ -203,4 +212,5 @@
     #
     card=${CARD_DIR}/COMP/${compname}.card
+
     IGCM_card_DefineArrayFromOption ${card} OutputFiles List
     #
@@ -214,12 +224,16 @@
 	# INITIALISATION
 	#
-	eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1
-	typeset i=0
-	#
-	until [ $i -eq $NbFiles ]; do
+	typeset i
+	if ( [ X${TsTask} = XChunck2D ] || [ X${TsTask} = XChunck3D ] ) ; then
+	    ((NbFiles=${FlagToRead}))
+	    ((i=${NbFiles}-2))
+	else
+	    eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1
+	    i=0
+	fi
+	#
+	until [ $i -ge $NbFiles ]; do
 	    #
-	    eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1
-	    eval file_in=${file_in_}
-	    let $(( i_ = i+2 ))
+	    (( i_ = i+2 ))
 	    eval flag_post_=\${${ListFilesName}[$i_]} > /dev/null 2>&1
 	    eval flag_post=${flag_post_}
@@ -227,88 +241,94 @@
 	    if [ X${flag_post} != XNONE ] ; then
 		#
-	        # Initialize ${flag_post}_${compname}_${post_freq}
-		#
-		eval export ${flag_post}_${compname}_TimeSeriesFrequency=true
+	        # For each comp and each file who needs post-processing
+	        # determine which variables need time series.
+	        #
+		FILE=$( echo ${flag_post} | awk "-FPost_" '{print $2}' )
+		IGCM_card_DefineArrayFromOption ${card} Post_${FILE} TimeSeriesVars${Dimension}
+	        #
+		if [ $( eval echo \${${compname}_Post_${FILE}_TimeSeriesVars${Dimension}} ) = ${NULL_STR} ] ; then
+	            #
+		    IGCM_debug_Print 3 "Nothing to do for ${FILE} according to ${card}"
+		    (( i=i+3 ))
+		    continue
+	            #
+		fi
+		#
+	        # If we are not a Chunck type task, skip files/variables handled  by chunck task
+	        #
+		if [ ! X${TsTask} = XChunck${Dimension} ] ; then
+		    IGCM_card_DefineVariableFromOption ${card} Post_${FILE} ChunckJob${Dimension}
+		    if [ ! $( eval echo \${${compname}_Post_${FILE}_ChunckJob${Dimension}} ) = NONE ] ; then
+			IGCM_debug_Print 3 "Nothing to do for ${FILE} TimeSeriesVars${Dimension} according to ${card}"
+			IGCM_debug_Print 3 "Let another chunck task do the job $( eval echo \${${compname}_Post_${FILE}_ChunckJob${Dimension}} )"
+			(( i=i+3 ))
+			continue
+		    fi
+		fi
+		#
+	        #  We need coordinates axis to properly fill produced time series
+	        #
+		IGCM_card_DefineArrayFromOption ${card} Post_${FILE} GatherWithInternal
+	        #
+		if [ $( eval echo \${${compname}_Post_${FILE}_GatherWithInternal} ) = ${NULL_STR} ] ; then
+	            #
+		    IGCM_debug_Print 1 "ERROR !! We miss coordinate axis for ${FILE} according to ${card}"
+		    IGCM_debug_Print 1 "So no time series will be produced for ${FILE} !!"
+		    (( i=i+3 ))
+		    continue
+	            #
+		fi
+	        #
+	        # We need LIST of variables not allready produced (useful for standalone mode)
+	        #
+		FlagDir=$( echo ${FILE} | awk -F "_" '{print $1}' )
+		case ${FlagDir} in
+		    *Y)  TS_Dir=TS_YE  ;;
+		    *M)  TS_Dir=TS_MO  ;;
+		    *D)  TS_Dir=TS_DA  ;;
+		    HF)  TS_Dir=TS_HF  ;;
+		    INS) TS_Dir=TS_INS ;;
+		esac
+		#
+		count=0
+		for var in $( eval echo \${${compname}_Post_${FILE}_TimeSeriesVars${Dimension}[*]} ) ; do
+	            #
+		    DIRECTORY=${R_SAVE}/${comp}/Analyse/${TS_Dir}
+		    TestedFile=${config_UserChoices_JobName}_${DateBegin}_${PeriodDateEnd}_${FlagDir}_${var}.nc
+	            #
+		    IGCM_sys_TestFileArchive ${DIRECTORY}/${TestedFile}
+		    if [ ! $? = 0 ] ; then
+			eval set +A LISTE_VARS_${FILE} \${LISTE_VARS_${FILE}[*]} ${var}
+			ActiveComp=true
+			(( count = count + 1 ))
+		    fi
+		done
+		#
+		if [ ${count} -gt 0 ] ; then
+	            #
+		    eval set +A LISTE_FILE_${comp} \${LISTE_FILE_${comp}[*]} ${FILE}
+		    eval set +A LISTE_AXIS_${FILE} \${${compname}_Post_${FILE}_GatherWithInternal[*]}
+		    #
+		    if [ ! ${RebuildFrequency} = true ] ; then
+			IGCM_card_DefineArrayFromOption ${card} Post_${FILE} Patches
+			eval set +A LISTE_PATCHES_${FILE} \${${compname}_Post_${FILE}_Patches[*]}
+			if [ X$( eval echo \${LISTE_PATCHES_${FILE}[0]} ) !=  X${NULL_STR} ]; then
+			    for Patch in $( eval echo \${LISTE_PATCHES_${FILE}[*]} ); do
+				if [ Xload${Patch} != X ] ; then
+				    . ${libIGCM}/libIGCM_post/IGCM_${Patch}.ksh
+				    eval load${Patch}=loaded
+				fi
+			    done
+			fi
+		    fi
+		fi
 	    fi
-	    let $(( i=i+3 ))
+	    (( i=i+3 ))
 	done
     fi
-
-    for element in $( env | grep Post_ | grep ${compname}_TimeSeriesFrequency | grep -i "=true" ) ; do
-	#
-	FILE=$( echo ${element} | awk -F "_${compname}_TimeSeriesFrequency" '{print $1}' | awk "-FPost_" '{print $2}' )
-	#
-	# For each comp and each file who needs post-processing
-	# determine which variables need time series.
-	#
-	IGCM_card_DefineArrayFromOption ${card} Post_${FILE} TimeSeriesVars
-	#
-	if [ $( eval echo \$\{${compname}_Post_${FILE}_TimeSeriesVars} ) = ${NULL_STR} ] ; then
-	    #
-	    IGCM_debug_Print 3 "Nothing to do for ${FILE} according to ${card}"
-	    continue
-	    #
-	fi
-	#
-	IGCM_card_DefineArrayFromOption ${card} Post_${FILE} Patches
-	#
-	# So we need coordinates axis to properly fill produced time series
-	#
-	IGCM_card_DefineArrayFromOption ${card} Post_${FILE} GatherWithInternal
-	#
-	if [ $( eval echo \$\{${compname}_Post_${FILE}_GatherWithInternal} ) = ${NULL_STR} ] ; then
-	    #
-	    IGCM_debug_Print 1 "ERROR !! We miss coordinate axis for ${FILE} according to ${card}"
-	    IGCM_debug_Print 1 "So no time series will be produced for ${FILE} !!"
-	    continue
-	    #
-	fi
-	#
-	# CREATE LIST
-	#
-	FlagDir=$( echo ${FILE} | awk -F "_" '{print $1}' )
-	case ${FlagDir} in
-	    *Y)  TS_Dir=TS_YE  ;; 
-	    *M)  TS_Dir=TS_MO  ;; 
-	    *D)  TS_Dir=TS_DA  ;; 
-	    HF)  TS_Dir=TS_HF  ;;
-	    INS) TS_Dir=TS_INS ;;
-	esac
-
-	count=0
-	for var in $( eval echo \$\{${compname}_Post_${FILE}_TimeSeriesVars[*]} ) ; do
-	    #
-	    DIRECTORY=${R_SAVE}/${comp}/Analyse/${TS_Dir}
-	    TestedFile=${config_UserChoices_JobName}_${DateBegin}_${PeriodDateEnd}_${FlagDir}_${var}.nc
-	    #
-	    IGCM_sys_TestFileArchive ${DIRECTORY}/${TestedFile}
-	    if [ ! $? = 0 ] ; then
-		eval set +A LISTE_VARS_${FILE} \$\{LISTE_VARS_${FILE}[*]} ${var}
-		ActiveComp=true
-		(( count = count + 1 ))
-	    fi
-	done
-
-	if [ ${count} -gt 0 ] ; then
-	    #
-	    eval set +A LISTE_FILE_${comp} \$\{LISTE_FILE_${comp}[*]} ${FILE}
-	    eval set +A LISTE_AXIS_${FILE} \$\{${compname}_Post_${FILE}_GatherWithInternal[*]}
-	    eval set +A LISTE_PATCHES_${FILE} \$\{${compname}_Post_${FILE}_Patches[*]}
-	    if [ X$( eval echo \${LISTE_PATCHES_${FILE}[0]} ) !=  X${NULL_STR} ]; then
-		for Patch in $( eval echo \${LISTE_PATCHES_${FILE}[*]} ); do
-		    if [ Xload${Patch} != X ] ; then
-			. ${libIGCM}/libIGCM_post/IGCM_${Patch}.ksh
-			eval load${Patch}=loaded
-		    fi
-		done
-	    fi
-	    #
-	fi
-    done
-
+    #
     if [ ${ActiveComp} = true ] ; then
 	set +A ActiveListOfComponents ${ActiveListOfComponents[*]} ${comp}
     fi
-
 done
 
@@ -440,19 +460,29 @@
        echo \${run_PostProcessing_TimeSeriesRunning}" )
 
-    if [ X${Running_Flag} = Xy ] ; then
-        # Time Series Job allready running
-	IGCM_debug_Print 1 "Time Series Job allready running exit"
-	exit
-    fi
+    #if [ X${Running_Flag} = Xy ] ; then
+    #    # Time Series Job allready running
+    #	IGCM_debug_Print 1 "Time Series Job allready running exit"
+    #	exit
+    #fi
     # Now run.card know we are running
+
+
+
+
     IGCM_sys_RshMaster IGCM_card_WriteOption ${SUBMIT_DIR}/run.card PostProcessing TimeSeriesRunning "y"
+
+
+
+
+
     # Get information from last execution
-    CompletedFlag=$( IGCM_sys_RshMaster \
-	"IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card PostProcessing TimeSeriesCompleted ;\
-        echo \${run_PostProcessing_TimeSeriesCompleted}" )
+    #CompletedFlag=$( IGCM_sys_RshMaster \
+    #	"IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card PostProcessing TimeSeriesCompleted ;\
+    #        echo \${run_PostProcessing_TimeSeriesCompleted}" )
 fi
 
 # Is it the first submission or not ?
-if [ X${CompletedFlag} = X ] ; then
+
+if ( [ X${CompletedFlag} = X ] || [ X${CompletedFlag} = X$( IGCM_date_AddDaysToGregorianDate ${DateBegin} -1 ) ] ) ; then
     # First Time Series Submission
     FIRST_PASS=TRUE
@@ -600,5 +630,5 @@
     else
 	# - LEVEL 3 : WE ARE IN THE LAST LOOP
-	NBRE_FILE_LOOP=$( expr ${NBRE_FILE_TOT} % $(( UNIX_MAX_LIMIT * $(( CURRENT_LOOP - 1 )) )) )
+	NBRE_FILE_LOOP=$(( ${NBRE_FILE_TOT} % ( ${UNIX_MAX_LIMIT} * ( ${CURRENT_LOOP} - 1 ) ) ))
 	[ ${NBRE_FILE_LOOP} -eq 0 ] && NBRE_FILE_LOOP=${UNIX_MAX_LIMIT}
 
@@ -674,10 +704,12 @@
 
 	    # Apply IGCM_Patch if needed
-	    if [ X$( eval echo \${LISTE_PATCHES_${file}[0]} ) !=  X${NULL_STR} ]; then
-		for file_t in $( eval echo ${liste_file_tmp[*]} ); do		
-		    for Patch in $( eval echo \${LISTE_PATCHES_${file}[*]} ); do
-			IGCM_${Patch} ${file_t}
+	    if [ ! ${RebuildFrequency} = true ] ; then
+		if [ X$( eval echo \${LISTE_PATCHES_${file}[0]} ) !=  X${NULL_STR} ]; then
+		    for file_t in $( eval echo ${liste_file_tmp[*]} ); do		
+			for Patch in $( eval echo \${LISTE_PATCHES_${file}[*]} ); do
+			    IGCM_${Patch} ${file_t}
+			done
 		    done
-		done
+		fi
 	    fi
 
@@ -749,15 +781,4 @@
 done
 
-# clean environment variables and export usefull one :
-if [ X$( hostname -s ) = Xrhodes ] ; then
-    LISTE_ENV=$( env | grep -iv MYLANG | grep -iv HOST | grep -iv LOGIN | grep -iv config_ | grep -iv R_ | grep -iv libIGCM | grep -iv PERIOD \
-	| grep -iv DMFDIR | grep -iv AN_| grep -iv YEARS | grep -iv ex | grep -iv RESOL_ | grep -iv PATH | grep -iv WORKDIR | grep -iv USER   \
-	| grep -iv LOGNAME | grep -iv PROFILE | grep -iv ENV | grep -iv TMPDIR | grep -iv POST_DIR | grep -iv StandAlone | grep -iv DB | awk -F= '{print $1}' )
- 
-    for variables in ${LISTE_ENV} ; do
-	unset ${variables}
-    done
-fi
-
 export POST_DIR; export SUBMIT_DIR; export libIGCM; export R_INIT; export R_BC; export StandAlone
 export RESOL_ATM; export RESOL_OCE ; export RESOL_ICE ; export RESOL_SRF
@@ -774,5 +795,5 @@
 #D- Submit MONITORING
 # --------------------------------------------------------------------
-IGCM_sys_QsubPost monitoring
+[ X${TsTask} = X2D ] && IGCM_sys_QsubPost monitoring
 
 #D-
Index: /trunk/libIGCM/libIGCM_comp/libIGCM_comp.ksh
===================================================================
--- /trunk/libIGCM/libIGCM_comp/libIGCM_comp.ksh	(revision 148)
+++ /trunk/libIGCM/libIGCM_comp/libIGCM_comp.ksh	(revision 149)
@@ -80,7 +80,6 @@
 	eval R_OUT_${comp}_O_Y=\${R_OUT_${comp}_O}/YE
 
-
 	# Read UserChoices section of component card
-	IGCM_debug_Print 1 "DefineArrayFromOption  : ${compname}_UserChoices ${card}"
+	IGCM_debug_Print 1 "DefineArrayFromSection : ${compname}_UserChoices ${card}"
 	IGCM_card_DefineArrayFromSection ${card} UserChoices
 	eval first_option=\${${compname}_UserChoices[0]} > /dev/null 2>&1
@@ -98,4 +97,72 @@
 	fi
 
+	# Read and Build Output File stuff
+	IGCM_debug_Print 1 "DefineArrayFromOption  : ${compname}_OutputFiles ${card}"
+	IGCM_card_DefineArrayFromOption ${card} OutputFiles List
+	ListFilesName=${compname}_OutputFiles_List
+	eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1
+	#
+	if [ X${FileName0} != X${NULL_STR} ] ; then
+            #
+	    #IGCM_debug_Print 1 "Component      : ${compname}"
+	    #
+	    # INITIALISATION
+	    #
+	    eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1
+	    typeset i=2
+	    #
+	    #set -vx
+	    until [ $i -ge $NbFiles ]; do
+	        #
+		eval flag_post=\${${ListFilesName}[$i]} > /dev/null 2>&1
+		#
+		if [ X${flag_post} != XNONE ] ; then
+		    # A mettre demain (11/08/2009) : dÃ©pendance Dimension 2D:3D
+		    # Dimension = vide si vieille card.
+		    IGCM_card_DefineArrayFromOption ${card} ${flag_post} TimeSeriesVars
+		    IGCM_card_DefineArrayFromOption ${card} ${flag_post} Patches
+		    if [ "$( eval echo \${${compname}_${flag_post}_TimeSeriesVars[*]} )" = "Option not found ${flag_post}" ] ; then
+			# New TimeSeriesVar description, with 2D, 3D and associate ChunckJob.
+			ListDimension="2D 3D"
+			TimeSeries=false
+			for Dimension in ${ListDimension} ; do
+			    IGCM_card_DefineArrayFromOption ${card} ${flag_post} TimeSeriesVars${Dimension}
+			    IGCM_card_DefineVariableFromOption ${card} ${flag_post} ChunckJob${Dimension}
+		            #
+	                    # Time series WITHOUT chunk
+	                    #
+			    if [ ! $( eval echo \${${compname}_${flag_post}_TimeSeriesVars${Dimension}} ) = ${NULL_STR} ] ; then
+				if [ $( eval echo \${${compname}_${flag_post}_ChunckJob${Dimension}} ) = NONE ] ; then
+				    IGCM_debug_Print 3 "${Dimension} time series activated for ${flag_post} according to ${card}"
+				    eval TimeSeries${Dimension}=true
+				fi
+			    fi
+                            #
+	                    # Time series WITH chunk
+		            #
+			    if [ ! $( eval echo \${${compname}_${flag_post}_TimeSeriesVars${Dimension}} ) = ${NULL_STR} ] ; then
+				chunck_size=$( eval echo \${${compname}_${flag_post}_ChunckJob${Dimension}} )
+				if [ ! ${chunck_size} = NONE ] ; then
+				    IGCM_debug_Print 3 "${Dimension} time series activated with chunck for ${flag_post} according to ${card}"
+				    eval TimeSeriesChunck${Dimension}=true
+				    eval set +A CHUNCK${Dimension}_COMP \${CHUNCK${Dimension}_COMP[*]} ${comp}
+				    eval set +A CHUNCK${Dimension}_FLAG \${CHUNCK${Dimension}_FLAG[*]} ${i}
+				    eval set +A CHUNCK${Dimension}_SIZE \${CHUNCK${Dimension}_SIZE[*]} ${chunck_size}
+				fi
+			    fi
+			done
+		    else
+			ListDimension=""
+			TimeSeries=true
+			TimeSeries2D=false
+			TimeSeries3D=false
+			TimeSeriesChunck2D=false
+			TimeSeriesChunck3D=false
+		    fi
+		fi
+		(( i=i+3 ))
+	    done
+	    #set +vx
+	fi
 	# Debug Print
 	IGCM_debug_Print 3 "Initialize ${compname} with driver."
@@ -105,5 +172,4 @@
     done
     echo "-----"
-
     echo
     IGCM_debug_Print 1 "DefineArrayFromOption  : ListOfComponents"
@@ -640,4 +706,6 @@
 		eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1
 		eval file_out=${file_out_}
+		(( i_ = i+2 ))
+		eval flag_post=\${${ListFilesName}[$i_]} > /dev/null 2>&1
 		#
 		generic_file_name=$( basename ${file_in} .nc )
@@ -656,18 +724,32 @@
 			[ ! -d ${RUN_DIR}/REBUILD_${PeriodDateBegin} ] && IGCM_sys_Mkdir ${RUN_DIR}/REBUILD_${PeriodDateBegin}
 			IGCM_sys_Mv ${generic_file_name}_????.nc ${RUN_DIR}/REBUILD_${PeriodDateBegin}
+			# Attention au quota si on tourne dans un RUN_DIR_PATH maison
+			for DelFile in $( ls REBUILD_${PeriodDateBegin}/* | grep "${generic_file_name}[_0-9]*.nc" ) ; do
+			    eval FileToBeDeleted[${#FileToBeDeleted[@]}]=${DelFile} > /dev/null 2>&1
+			done
+
 			# Prepare headers for the shell dedicated to offline rebuild
 			if [ ! -f ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh ] ; then
-			    echo \#!/bin/ksh                               > ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-			    echo function IGCM_FlushRebuild               >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-			    echo {                                        >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-			    echo IGCM_debug_PushStack "IGCM_FlushRebuild" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-			    echo echo                                     >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-			    echo IGCM_debug_Print 1 "IGCM_FlushRebuild"   >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-			    echo echo                                     >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+			    echo \#!/bin/ksh                                           > ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+			    echo function IGCM_FlushRebuild                           >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+			    echo {                                                    >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+			    echo IGCM_debug_PushStack "IGCM_FlushRebuild"             >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+			    echo echo                                                 >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+			    echo IGCM_debug_Print 1 "IGCM_FlushRebuild"               >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+			    echo echo                                                 >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
 			fi
 			# Prepare the shell dedicated to offline rebuild
-			echo IGCM_sys_rebuild ${file_in} ${generic_file_name}_*.nc >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-			echo IGCM_sys_Put_Out ${file_in} ${file_out}               >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-			echo IGCM_sys_Rm ${generic_file_name}_*.nc                 >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+			echo IGCM_sys_rebuild ${file_in} ${generic_file_name}_*.nc    >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+			#
+			# Load Patch we need to apply and apply
+			if [ X$( eval echo \${${compname}_${flag_post}_Patches[0]} ) !=  X${NULL_STR} ]; then
+			    for Patch in $( eval echo \${${compname}_${flag_post}_Patches[*]} ); do
+				echo . ${libIGCM_POST}/libIGCM_post/IGCM_${Patch}.ksh >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+				echo IGCM_${Patch} ${file_in}                         >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+			    done
+			fi
+			#
+			echo IGCM_sys_Put_Out ${file_in} ${file_out}                  >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+			echo IGCM_sys_Rm ${generic_file_name}_*.nc                    >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
 			SaveOnArchive=false
 		    fi
@@ -675,10 +757,28 @@
 		#
 		if [ ${SaveOnArchive} = true ] ; then
-		    IGCM_sys_Put_Out ${file_in} ${file_out}
-		    [ $? -eq 0 ] && eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${file_in}" > /dev/null 2>&1
-		    if [ ${nb_rebuild_file} -gt 1 ] ; then
-			for DelFile in $( ls | grep "${generic_file_name}[_0-9]*.nc" ) ; do
-			    eval FileToBeDeleted[${#FileToBeDeleted[@]}]=${DelFile} > /dev/null 2>&1
-			done
+		    #
+		    # If we need to apply a patch we use TMP DIRECTORY before ARCHIVING if asynchronous rebuild is on
+		    #
+		    if ( [ X$( eval echo \${${compname}_${flag_post}_Patches[0]} ) !=  X${NULL_STR} ] && [ ! X${config_Post_RebuildFrequency} = X${NULL_STR} ] && [ ! X${config_Post_RebuildFrequency} = XNONE ] ) ; then
+			if [ -f ${file_in} ] ; then
+			    IGCM_sys_Mv ${file_in} ${RUN_DIR}/REBUILD_${PeriodDateBegin}
+			    eval FileToBeDeleted[${#FileToBeDeleted[@]}]=REBUILD_${PeriodDateBegin}/${file_in} > /dev/null 2>&1
+			    #
+			    for Patch in $( eval echo \${${compname}_${flag_post}_Patches[*]} ); do
+				echo . ${libIGCM_POST}/libIGCM_post/IGCM_${Patch}.ksh     >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+				echo IGCM_${Patch} ${file_in}                             >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+			    done
+			    #
+			    echo IGCM_sys_Put_Out ${file_in} ${file_out}                  >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+		            #
+			fi
+		    else
+			IGCM_sys_Put_Out ${file_in} ${file_out}
+			[ $? -eq 0 ] && eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${file_in}" > /dev/null 2>&1
+			if [ ${nb_rebuild_file} -gt 1 ] ; then
+			    for DelFile in $( ls | grep "${generic_file_name}[_0-9]*.nc" ) ; do
+				eval FileToBeDeleted[${#FileToBeDeleted[@]}]=${DelFile} > /dev/null 2>&1
+			    done
+			fi
 		    fi
 		fi
Index: /trunk/libIGCM/libIGCM_post/libIGCM_post.ksh
===================================================================
--- /trunk/libIGCM/libIGCM_post/libIGCM_post.ksh	(revision 148)
+++ /trunk/libIGCM/libIGCM_post/libIGCM_post.ksh	(revision 149)
@@ -384,30 +384,212 @@
     if [ ${TimeSeriesFrequency} = true ] ; then
 
-        IGCM_debug_Print 2 "TIME SERIES POST-TREATMENT :"
+	set -vx
+        IGCM_debug_Print 2 "TIME SERIES POST-PROCESSING ACTIVATED :"
         echo
-        #
+
+
+
+	# Get information from last execution
+	IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card PostProcessing TimeSeriesCompleted
+	CompletedFlag=${run_PostProcessing_TimeSeriesCompleted}
+        #
+
+
+
         typeset listVarEnv
-        listVarEnv="DEBUG_debug,MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,POST_DIR,DateBegin,PeriodDateEnd,StandAlone,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_SRF"
+        listVarEnv="DEBUG_debug,MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,POST_DIR,MASTER,RebuildFrequency,DateBegin,PeriodDateEnd,StandAlone,CompletedFlag,TsTask,CompToRead,FlagToRead,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_SRF"
+	#
+	for Dimension in ${ListDimension} ; do
+	    #
+	    if [ X$( eval echo \${TimeSeries${Dimension}} ) = Xtrue ] ; then
+		#
+		IGCM_debug_Print 2 "TIME SERIES POST-PROCESSING ${Dimension} ACTIVATED :"
+		echo
+                #
+		TsTask=${Dimension}
+	        #
+		if [ ${RebuildFrequency} = true ] ; then
+	            #
+		    echo export DEBUG_debug=${DEBUG_debug}            >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+		    echo export MODIPSL=${MODIPSL}                    >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+		    echo export libIGCM_SX=${libIGCM}                 >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+		    echo export libIGCM=${libIGCM_POST}               >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+		    echo export SUBMIT_DIR=${SUBMIT_DIR}              >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+		    echo export POST_DIR=${POST_DIR}                  >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+		    echo export MASTER=${MASTER}                      >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+		    echo export RebuildFrequency=${RebuildFrequency}  >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+		    echo export DateBegin=${DateBegin}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+		    echo export PeriodDateEnd=${PeriodDateEnd}        >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+		    echo export StandAlone=false                      >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+		    echo export CompletedFlag=${CompletedFlag}        >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+		    echo export TsTask=${TsTask}                      >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+		    echo export RESOL_ATM=${RESOL_ATM}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+		    echo export RESOL_OCE=${RESOL_OCE}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+		    echo export RESOL_ICE=${RESOL_ICE}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+		    echo export RESOL_SRF=${RESOL_SRF}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+		    echo export listVarEnv=${listVarEnv}              >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+		    echo IGCM_sys_MkdirWork ${POST_DIR}               >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+		    echo IGCM_debug_Verif_Exit                        >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+		    echo IGCM_sys_QsubPost create_ts                  >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+	            #
+		else
+	            #
+		    IGCM_sys_RshPost <<-EOF
+                    export DEBUG_debug=${DEBUG_debug}
+                    export MODIPSL=${MODIPSL}
+                    export libIGCM_SX=${libIGCM}
+                    export libIGCM=${libIGCM_POST}
+                    export SUBMIT_DIR=${SUBMIT_DIR}
+                    export POST_DIR=${POST_DIR}
+                    export MASTER=${MASTER}
+                    export RebuildFrequency=${RebuildFrequency}
+                    export DateBegin=${DateBegin}
+                    export PeriodDateEnd=${PeriodDateEnd}
+                    export StandAlone=false
+                    export CompletedFlag=${CompletedFlag}
+                    export TsTask=${TsTask}
+                    export RESOL_ATM=${RESOL_ATM}
+                    export RESOL_OCE=${RESOL_OCE}
+                    export RESOL_ICE=${RESOL_ICE}
+                    export RESOL_SRF=${RESOL_SRF}
+                    export listVarEnv=${listVarEnv}
+                    . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
+                    . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
+                    IGCM_sys_MkdirWork ${POST_DIR}
+                    IGCM_debug_Verif_Exit
+                    IGCM_sys_QsubPost create_ts
+EOF
+		fi
+	    fi
+	    #
+	    if [ X$( eval echo \${TimeSeriesChunck${Dimension}} ) = Xtrue ] ; then
+		#
+		IGCM_debug_Print 2 "TIME SERIES POST-PROCESSING ${Dimension} WITH CHUNCK ACTIVATED :"
+		echo
+		# Need to Remember This One
+		SavedDateBegin=${DateBegin}
+		# Kind of task create_ts will perform
+		TsTask=Chunck${Dimension}
+	        # Number of chunck jobs to configure and submit
+		eval NbJob=\${#CHUNCK${Dimension}_COMP[@]}
+		i=0
+		until [ $i -ge $NbJob ]; do
+		    CompToRead=$( eval echo \${CHUNCK${Dimension}_COMP[\${i}]} )
+		    FlagToRead=$( eval echo \${CHUNCK${Dimension}_FLAG[\${i}]} )
+		    ChunckSize=$( eval echo \${CHUNCK${Dimension}_SIZE[\${i}]} )
+		    # Chunck Length (mandatory in Year)
+		    YearsChunckLength=$( echo ${ChunckSize} | sed -e "s/[yY]//" )
+		    #
+		    IGCM_date_GetYearMonth ${DateBegin}     YearBegin MonthBegin
+		    #
+		    IGCM_date_GetYearMonth ${PeriodDateEnd} YearEnd   MonthEnd
+		    # How many chunck in total since simulation began
+		    NbYearsChunckLoop=$(( ( ${YearEnd} - ${YearBegin} + 1 ) / ${YearsChunckLength} ))
+		    #  Tweak special case
+		    [ $(( ( ${YearEnd} - ${YearBegin} + 1 ) % ${YearsChunckLength} )) = 0 ] && NbYearsChunckLoop=$(( ${NbYearsChunckLoop} - 1 ))
+		    # Starting Year of the current chunck
+		    ChunckTsYearBegin=$(( ${NbYearsChunckLoop} *  ${YearsChunckLength} + ${YearBegin} ))
+		    # Starting date of the current chunck
+		    ChunckTsDateBegin=${ChunckTsYearBegin}${MonthBegin}01
+		    #
+		    if [ ${RebuildFrequency} = true ] ; then
+	                #
+			echo export DEBUG_debug=${DEBUG_debug}            >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+			echo export MODIPSL=${MODIPSL}                    >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+			echo export libIGCM_SX=${libIGCM}                 >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+			echo export libIGCM=${libIGCM_POST}               >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+			echo export SUBMIT_DIR=${SUBMIT_DIR}              >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+			echo export POST_DIR=${POST_DIR}                  >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+			echo export MASTER=${MASTER}                      >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+			echo export RebuildFrequency=${RebuildFrequency}  >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+			echo export DateBegin=${ChunckTsDateBegin}        >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+			echo export PeriodDateEnd=${PeriodDateEnd}        >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+			echo export StandAlone=false                      >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+			echo export CompletedFlag=${CompletedFlag}        >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+			echo export TsTask=${TsTask}                      >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+			echo export CompToRead=${CompToRead}              >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+			echo export FlagToRead=${FlagToRead}              >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+			echo export RESOL_ATM=${RESOL_ATM}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+			echo export RESOL_OCE=${RESOL_OCE}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+			echo export RESOL_ICE=${RESOL_ICE}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+			echo export RESOL_SRF=${RESOL_SRF}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+			echo export listVarEnv=${listVarEnv}              >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+			echo IGCM_sys_MkdirWork ${POST_DIR}               >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+			echo IGCM_debug_Verif_Exit                        >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+			echo IGCM_sys_QsubPost create_ts                  >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+	                #
+		    else
+	                #
+			IGCM_sys_RshPost <<-EOF
+                        export DEBUG_debug=${DEBUG_debug}
+                        export MODIPSL=${MODIPSL}
+                        export libIGCM_SX=${libIGCM}
+                        export libIGCM=${libIGCM_POST}
+                        export SUBMIT_DIR=${SUBMIT_DIR}
+                        export POST_DIR=${POST_DIR}
+                        export MASTER=${MASTER}
+                        export RebuildFrequency=${RebuildFrequency}
+                        export DateBegin=${ChunckTsDateBegin}
+                        export PeriodDateEnd=${PeriodDateEnd}
+                        export StandAlone=false
+                        export CompletedFlag=${CompletedFlag}
+                        export TsTask=${TsTask}
+                        export CompToRead=${CompToRead}
+                        export FlagToRead=${FlagToRead}
+                        export RESOL_ATM=${RESOL_ATM}
+                        export RESOL_OCE=${RESOL_OCE}
+                        export RESOL_ICE=${RESOL_ICE}
+                        export RESOL_SRF=${RESOL_SRF}
+                        export listVarEnv=${listVarEnv}
+                        . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
+                        . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
+                        IGCM_sys_MkdirWork ${POST_DIR}
+                        IGCM_debug_Verif_Exit
+                        IGCM_sys_QsubPost create_ts
+EOF
+	                #
+		    fi
+		    #
+		    export DateBegin=${SavedDateBegin}
+		    #
+		    (( i=i+1 ))
+		    #
+		done
+	    fi
+	done
+    fi
+
+    set +vx
+
+    #=============  SEASONAL POST-TREATMENT ============#
+    if [ ${SeasonalFrequency} = true ] ; then
+        #
+        IGCM_debug_Print 2 "SEASONNAL POST-TREATMENT :"
+        echo
+        #
+        typeset listVarEnv
+	listVarEnv="DEBUG_debug,MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,POST_DIR,MASTER,RebuildFrequency,DateBegin,PeriodDateEnd,StandAlone,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_SRF"
 
 	if [ ${RebuildFrequency} = true ] ; then
 	    #
-	    echo export DEBUG_debug=${DEBUG_debug}     >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-	    echo export MODIPSL=${MODIPSL}             >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-	    echo export libIGCM_SX=${libIGCM}          >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-            echo export libIGCM=${libIGCM_POST}        >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-            echo export SUBMIT_DIR=${SUBMIT_DIR}       >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-            echo export POST_DIR=${POST_DIR}           >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-	    echo export MASTER=${MASTER}               >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-            echo export DateBegin=${DateBegin}         >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-            echo export PeriodDateEnd=${PeriodDateEnd} >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-            echo export StandAlone=false               >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-            echo export RESOL_ATM=${RESOL_ATM}         >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-            echo export RESOL_OCE=${RESOL_OCE}         >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-            echo export RESOL_ICE=${RESOL_ICE}         >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-            echo export RESOL_SRF=${RESOL_SRF}         >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-	    echo export listVarEnv=${listVarEnv}       >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-	    echo IGCM_sys_MkdirWork ${POST_DIR}        >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-            echo IGCM_debug_Verif_Exit                 >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-            echo IGCM_sys_QsubPost create_ts           >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+	    echo export DEBUG_debug=${DEBUG_debug}            >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+	    echo export MODIPSL=${MODIPSL}                    >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+	    echo export libIGCM_SX=${libIGCM}                 >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+            echo export libIGCM=${libIGCM_POST}               >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+            echo export SUBMIT_DIR=${SUBMIT_DIR}              >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+            echo export POST_DIR=${POST_DIR}                  >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+            echo export MASTER=${MASTER}                      >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+	    echo export RebuildFrequency=${RebuildFrequency}  >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+            echo export DateBegin=${DateBegin}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+            echo export PeriodDateEnd=${PeriodDateEnd}        >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+            echo export StandAlone=false                      >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+            echo export RESOL_ATM=${RESOL_ATM}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+            echo export RESOL_OCE=${RESOL_OCE}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+            echo export RESOL_ICE=${RESOL_ICE}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+            echo export RESOL_SRF=${RESOL_SRF}                >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+            echo export listVarEnv=${listVarEnv}              >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+	    echo IGCM_sys_MkdirWork ${POST_DIR}               >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+            echo IGCM_debug_Verif_Exit                        >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+            echo IGCM_sys_QsubPost create_se                  >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
 	    #
 	else
@@ -421,62 +603,5 @@
             export POST_DIR=${POST_DIR}
             export MASTER=${MASTER}
-            export DateBegin=${DateBegin}
-            export PeriodDateEnd=${PeriodDateEnd}
-            export StandAlone=false
-            export RESOL_ATM=${RESOL_ATM}
-            export RESOL_OCE=${RESOL_OCE}
-            export RESOL_ICE=${RESOL_ICE}
-            export RESOL_SRF=${RESOL_SRF}
-            export listVarEnv=${listVarEnv}
-            . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
-            . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
-            IGCM_sys_MkdirWork ${POST_DIR}
-            IGCM_debug_Verif_Exit
-            IGCM_sys_QsubPost create_ts
-EOF
-	    #
-	fi
-    fi
-
-    #=============  SEASONAL POST-TREATMENT ============#
-    if [ ${SeasonalFrequency} = true ] ; then
-        #
-        IGCM_debug_Print 2 "SEASONNAL POST-TREATMENT :"
-        echo
-        #
-        typeset listVarEnv
-	listVarEnv="DEBUG_debug,MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,POST_DIR,DateBegin,PeriodDateEnd,StandAlone,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_SRF"
-
-	if [ ${RebuildFrequency} = true ] ; then
-	    #
-	    echo export DEBUG_debug=${DEBUG_debug}     >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-	    echo export MODIPSL=${MODIPSL}             >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-	    echo export libIGCM_SX=${libIGCM}          >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-            echo export libIGCM=${libIGCM_POST}        >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-            echo export SUBMIT_DIR=${SUBMIT_DIR}       >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-            echo export POST_DIR=${POST_DIR}           >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-            echo export MASTER=${MASTER}               >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-            echo export DateBegin=${DateBegin}         >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-            echo export PeriodDateEnd=${PeriodDateEnd} >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-            echo export StandAlone=false               >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-            echo export RESOL_ATM=${RESOL_ATM}         >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-            echo export RESOL_OCE=${RESOL_OCE}         >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-            echo export RESOL_ICE=${RESOL_ICE}         >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-            echo export RESOL_SRF=${RESOL_SRF}         >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-            echo export listVarEnv=${listVarEnv}       >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-	    echo IGCM_sys_MkdirWork ${POST_DIR}        >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-            echo IGCM_debug_Verif_Exit                 >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-            echo IGCM_sys_QsubPost create_se           >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
-	    #
-	else
-	    #
-            IGCM_sys_RshPost <<-EOF
-            export DEBUG_debug=${DEBUG_debug}
-            export MODIPSL=${MODIPSL}
-	    export libIGCM_SX=${libIGCM}
-            export libIGCM=${libIGCM_POST}
-            export SUBMIT_DIR=${SUBMIT_DIR}
-            export POST_DIR=${POST_DIR}
-            export MASTER=${MASTER}
+            export RebuildFrequency=${RebuildFrequency}
             export DateBegin=${DateBegin}
             export PeriodDateEnd=${PeriodDateEnd}
@@ -521,5 +646,4 @@
         export REBUILD_DIR=${REBUILD_DIR}
         export POST_DIR=${POST_DIR}
-        export MASTER=${MASTER}
         export DateBegin=${DateBegin}
         export PeriodDateBegin=${PeriodDateBegin}
@@ -552,5 +676,5 @@
 
 #        typeset listVarEnv
-#        listVarEnv="DEBUG_debug,MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,REBUILD_DIR,RebuildFromArchive,POST_DIR,MASTER,DateBegin,PeriodDateBegin,PeriodDateEnd,NbRebuildDir,StandAlone,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_SRF"
+#        listVarEnv="DEBUG_debug,MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,REBUILD_DIR,RebuildFromArchive,POST_DIR,DateBegin,PeriodDateBegin,PeriodDateEnd,NbRebuildDir,StandAlone,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_SRF"
 #        export DEBUG_debug=${DEBUG_debug}
 #        export MODIPSL=${MODIPSL}
