Index: trunk/libIGCM/AA_SE_Checker
===================================================================
--- trunk/libIGCM/AA_SE_Checker	(revision 553)
+++ trunk/libIGCM/AA_SE_Checker	(revision 554)
@@ -18,8 +18,11 @@
 # all TS to last PeriodDateEnd value, give by run.card->Configuration->OldPrefix string.
 
-# Chemin vers libIGCM
+#D- Path to libIGCM
+#D- Default : value from AA_job if any
+# WARNING For StandAlone use : To run this script on some machine (ulam and cesium)
+# WARNING you must check MirrorlibIGCM variable in sys library.
+# WARNING If this variable is true, you must use libIGCM_POST path instead
+# WARNING of your running libIGCM directory.
 libIGCM=${libIGCM:=::modipsl::/libIGCM}
-# Attention : Ã  changer si la machine de post-traitement n'est pas la frontale du serveur de calcul !
-#             voir prÃ©cence de la variable MirrorlibIGCM dans votre couche systÃšme.
 
 # Expericence class of the run
Index: trunk/libIGCM/AA_SaveSourceModifications
===================================================================
--- trunk/libIGCM/AA_SaveSourceModifications	(revision 553)
+++ trunk/libIGCM/AA_SaveSourceModifications	(revision 554)
@@ -86,11 +86,11 @@
 MODIPSL=::modipsl::
 
-#D- Low level debug : to bypass lib test checks and stack construction
+#D- Path to libIGCM
 #D- Default : value from AA_job if any
+# WARNING For StandAlone use : To run this script on some machine (ulam and cesium)
+# WARNING you must check MirrorlibIGCM variable in sys library.
+# WARNING If this variable is true, you must use libIGCM_POST path instead
+# WARNING of your running libIGCM directory.
 libIGCM=${libIGCM:=::modipsl::/libIGCM}
-# WARNING for StandAlone used : To run this script on some machine,
-# you must check MirrorlibIGCM variable in sys library.
-# If this variable is true, you must use libIGCM_POST path instead
-# of your running libIGCM directory.
 
 . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
Index: trunk/libIGCM/AA_TimeSeries_Checker
===================================================================
--- trunk/libIGCM/AA_TimeSeries_Checker	(revision 553)
+++ trunk/libIGCM/AA_TimeSeries_Checker	(revision 554)
@@ -18,8 +18,11 @@
 # all TS to last PeriodDateEnd value, give by run.card->Configuration->OldPrefix string.
 
-# Chemin vers libIGCM
+#D- Path to libIGCM
+#D- Default : value from AA_job if any
+# WARNING For StandAlone use : To run this script on some machine (ulam and cesium)
+# WARNING you must check MirrorlibIGCM variable in sys library.
+# WARNING If this variable is true, you must use libIGCM_POST path instead
+# WARNING of your running libIGCM directory.
 libIGCM=${libIGCM:=::modipsl::/libIGCM}
-# Attention : Ã  changer si la machine de post-traitement n'est pas la frontale du serveur de calcul !
-#             voir prÃ©cence de la variable MirrorlibIGCM dans votre couche systÃšme.
 
 # Expericence class of the run
Index: trunk/libIGCM/AA_create_multi_se
===================================================================
--- trunk/libIGCM/AA_create_multi_se	(revision 553)
+++ trunk/libIGCM/AA_create_multi_se	(revision 554)
@@ -136,11 +136,11 @@
 StandAlone=${StandAlone:=true}
 
-#D- Low level debug : to bypass lib test checks and stack construction
+#D- Path to libIGCM
 #D- Default : value from AA_job if any
+# WARNING For StandAlone use : To run this script on some machine (ulam and cesium)
+# WARNING you must check MirrorlibIGCM variable in sys library.
+# WARNING If this variable is true, you must use libIGCM_POST path instead
+# WARNING of your running libIGCM directory.
 libIGCM=${libIGCM:=::modipsl::/libIGCM}
-# WARNING for StandAlone used : To run this script on some machine,
-# you must check MirrorlibIGCM variable in sys library.
-# If this variable is true, you must use libIGCM_POST path instead
-# of your running libIGCM directory.
 
 #D- Flag to determine atlas job's output directory
Index: trunk/libIGCM/AA_create_se
===================================================================
--- trunk/libIGCM/AA_create_se	(revision 553)
+++ trunk/libIGCM/AA_create_se	(revision 554)
@@ -136,11 +136,11 @@
 StandAlone=${StandAlone:=true}
 
-#D- Low level debug : to bypass lib test checks and stack construction
+#D- Path to libIGCM
 #D- Default : value from AA_job if any
+# WARNING For StandAlone use : To run this script on some machine (ulam and cesium)
+# WARNING you must check MirrorlibIGCM variable in sys library.
+# WARNING If this variable is true, you must use libIGCM_POST path instead
+# WARNING of your running libIGCM directory.
 libIGCM=${libIGCM:=::modipsl::/libIGCM}
-# WARNING for StandAlone used : To run this script on some machine,
-# you must check MirrorlibIGCM variable in sys library.
-# If this variable is true, you must use libIGCM_POST path instead
-# of your running libIGCM directory.
 
 #D- Flag to determine if rebuild process has been performed asynchronously
Index: trunk/libIGCM/AA_create_ts
===================================================================
--- trunk/libIGCM/AA_create_ts	(revision 553)
+++ trunk/libIGCM/AA_create_ts	(revision 554)
@@ -136,11 +136,11 @@
 StandAlone=${StandAlone:=true}
 
-#D- Low level debug : to bypass lib test checks and stack construction
+#D- Path to libIGCM
 #D- Default : value from AA_job if any
+# WARNING For StandAlone use : To run this script on some machine (ulam and cesium)
+# WARNING you must check MirrorlibIGCM variable in sys library.
+# WARNING If this variable is true, you must use libIGCM_POST path instead
+# WARNING of your running libIGCM directory.
 libIGCM=${libIGCM:=::modipsl::/libIGCM}
-# WARNING for StandAlone used : To run this script on some machine,
-# you must check MirrorlibIGCM variable in sys library.
-# If this variable is true, you must use libIGCM_POST path instead
-# of your running libIGCM directory.
 
 #D- Flag to determine allready produced time series. Empty if you start from the beginning
@@ -462,115 +462,4 @@
 ########################################################################
 #
-#                          DEFINE DATE FUNCTIONS
-#
-########################################################################
-
-# Give the end of the next $1 period from $2 date
-function create_ts_next_date {
-    IGCM_debug_PushStack "create_ts_next_date" $@
-    typeset Length
-    case ${config_UserChoices_PeriodLength} in
-	*Y|*y) 
-	    PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' )
-	    IGCM_date_GetYearMonth ${1} year month
-	    year=$( IGCM_date_SupressZeros ${year} )
-	    (( Length=0 ))
-	    (( i=0 ))
-	    until [ $i -ge $PeriodLengthInYears ] ; do
-		(( Length = Length + $( IGCM_date_DaysInYear $(( year + i + 1 )) ) )) 
-	        (( i=i+1 ))
-	    done
-	    ;;
-	*M|*m) 
-	    PeriodLengthInMonths=$( echo ${config_UserChoices_PeriodLength} | awk -F '[mM]' '{print $1}' )
-	    IGCM_date_GetYearMonth ${1} year month
-	    year=$( IGCM_date_SupressZeros ${year} )
-	    (( year0 = year ))
-	    if [ $(( month + 1 )) -lt 13 ] ; then
-		month0=$(( month + 1 ))
-	    else
-		month0=$(( month + 1 - 12 ))
-		(( year = year0 + 1 ))
-	    fi
-	    (( Length=0 ))
-	    (( i=0 ))
-	    until [ $i -ge $PeriodLengthInMonths ] ; do
-		if [ $(( month0 + i )) -lt 13 ] ; then
-		    (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month0 + i )) ) ))
-		else
-		    (( year = year0 + 1 ))
-		    (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month0 + i - 12 )) ) ))
-		fi
-	        (( i=i+1 ))
-	    done
-	    ;;
-	*D|*d)
-	    Length=$( echo ${config_UserChoices_PeriodLength} | sed -e "s/[dD]//" ) ;;
-	*)
-	    IGCM_debug_Exit "create_ts " ${config_UserChoices_PeriodLength} " invalid PeriodLength : choose in *Y, *M, *D."
-	    IGCM_debug_Verif_Exit_Post ;;
-    esac
-    echo ${Length}
-
-    IGCM_debug_PopStack "create_ts_next_date"
-}
-
-# Give the end of the actual $1 period from $2 date
-function create_ts_begin_date {
-    IGCM_debug_PushStack "create_ts_begin_date" $@
-    typeset Length
-    case ${config_UserChoices_PeriodLength} in
-	*Y|*y) 
-	    PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' )
-	    IGCM_date_GetYearMonth ${1} year month
-	    year=$( IGCM_date_SupressZeros ${year} )
-	    if [ X${2} = Xend ] ; then
-		(( year = year - PeriodLengthInYears + 1))
-	    fi
-	    (( Length=0 ))
-	    (( i=0 ))
-	    until [ $i -ge $PeriodLengthInYears ] ; do
-		(( Length = Length + $( IGCM_date_DaysInYear $(( year + i )) ) )) 
-	        (( i=i+1 ))
-	    done
-	    ;;
-	*M|*m) 
-	    PeriodLengthInMonths=$( echo ${config_UserChoices_PeriodLength} | awk -F '[mM]' '{print $1}' )
-	    IGCM_date_GetYearMonth ${1} year month
-	    year=$( IGCM_date_SupressZeros ${year} )
-	    if [ X${2} = Xend ] ; then
-		(( month = month - PeriodLengthInMonths + 1 ))
-	    fi	    
-	    (( year0 = year ))
-	    if [ $month -le 0 ] ; then
-		(( month = month + 12 ))
-		year=$( printf "%04i\n" $(( year - 1 )) )
-	    fi
-	    month=$( printf "%02i\n" ${month} )
-	    (( Length=0 ))
-	    (( i=0 ))
-	    until [ $i -ge $PeriodLengthInMonths ] ; do
-		if [ $(( month + i )) -lt 13 ] ; then
-		    (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month + i )) ) ))
-		else
-		    (( year = year0 + 1 ))
-		    (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month + i - 12 )) ) ))
-		fi
-	        (( i=i+1 ))
-	    done
-	    ;;
-	*D|*d)
-	    Length=$( echo ${config_UserChoices_PeriodLength} | sed -e "s/[dD]//" ) ;;
-	*)
-	    IGCM_debug_Exit "create_ts " ${config_UserChoices_PeriodLength} " invalid PeriodLength : choose in *Y, *M, *D."
-	    IGCM_debug_Verif_Exit_Post ;;
-    esac
-    echo ${Length}
-
-    IGCM_debug_PopStack "create_ts_begin_date"
-}
-
-########################################################################
-#
 #               IS THERE SOME ALLREADY PRODUCED TIME SERIES ?
 #                 IF SO BRING THEM IN THE WORKING DIRECTORY
@@ -615,5 +504,5 @@
     # First Time Series Submission
     FIRST_PASS=TRUE
-    Length=$( create_ts_begin_date ${DateBegin} begin)
+    Length=$( IGCM_date_DaysInPreviousPeriod ${DateBegin} ${config_UserChoices_PeriodLength} begin)
     DATE_FIN_JOB_B=$( IGCM_date_AddDaysToGregorianDate ${DateBegin} $(( Length - 1 )) )
 else
@@ -685,5 +574,5 @@
     while [ ${DATE_COUNT} -lt ${PeriodDateEnd} ] ; do
 	(( NBRE_FILE_TOT = NBRE_FILE_TOT + 1 ))
-	Length=$( create_ts_next_date ${DATE_COUNT} )
+	Length=$( IGCM_date_DaysInNextPeriod ${DATE_COUNT} ${config_UserChoices_PeriodLength} )
 	DATE_COUNT=$( IGCM_date_AddDaysToGregorianDate ${DATE_COUNT} ${Length} )
     done
@@ -716,5 +605,5 @@
 	    DATE_COURANTE=${DATE_FIN_JOB_B_LOOP}
 	else
-	    Length=$( create_ts_next_date ${DATE_FIN_JOB_B_LOOP} )
+	    Length=$( IGCM_date_DaysInNextPeriod ${DATE_FIN_JOB_B_LOOP} ${config_UserChoices_PeriodLength} )
 	    DATE_COURANTE=$( IGCM_date_AddDaysToGregorianDate ${DATE_FIN_JOB_B_LOOP} ${Length} )
 	fi
@@ -733,10 +622,10 @@
 
         if [ ! ${FIRST_PASS} = TRUE ] && [ ${CURRENT_LOOP} -eq 1 ] ; then
-	    Length=$( create_ts_next_date ${DATE_FIN_JOB_B_LOOP} )
+	    Length=$( IGCM_date_DaysInNextPeriod ${DATE_FIN_JOB_B_LOOP} ${config_UserChoices_PeriodLength} )
 	    DATE_COURANTE=$( IGCM_date_AddDaysToGregorianDate ${DATE_FIN_JOB_B_LOOP} ${Length} )
 	elif [ -z "${DATE_COURANTE}" ] ; then
 	    DATE_COURANTE=${DATE_FIN_JOB_B}
 	else
-	    Length=$( create_ts_next_date ${DATE_FIN} )
+	    Length=$( IGCM_date_DaysInNextPeriod ${DATE_FIN} ${config_UserChoices_PeriodLength} )
 	    DATE_COURANTE=$( IGCM_date_AddDaysToGregorianDate ${DATE_FIN} ${Length} )
 	fi
@@ -748,5 +637,5 @@
 	while [ ${COMPTEUR} -lt ${NBRE_FILE_LOOP} ] ; do
 	    #
-	    Length=$( create_ts_next_date ${DATE_LOOP} )
+	    Length=$( IGCM_date_DaysInNextPeriod ${DATE_LOOP} ${config_UserChoices_PeriodLength} )
 	    DATE_LOOP=$( IGCM_date_AddDaysToGregorianDate ${DATE_LOOP} ${Length} )
 	    (( TotLength = TotLength + Length ))
@@ -765,5 +654,5 @@
 	[ ${NBRE_FILE_LOOP} -eq 0 ] && NBRE_FILE_LOOP=${UNIX_MAX_LIMIT}
 
-	Length=$( create_ts_next_date ${DATE_FIN} )
+	Length=$( IGCM_date_DaysInNextPeriod ${DATE_FIN} ${config_UserChoices_PeriodLength} )
 	DATE_COURANTE=$(IGCM_date_AddDaysToGregorianDate ${DATE_FIN} ${Length} )
 	DATE_FIN=${PeriodDateEnd}
@@ -816,8 +705,8 @@
 	    while [ ${COMPTEUR} -le ${NBRE_FILE_LOOP} ] ; do
 		#
-		Length1=$( create_ts_begin_date ${DATE_LOOP} end)
+		Length1=$( IGCM_date_DaysInPreviousPeriod ${DATE_LOOP} ${config_UserChoices_PeriodLength} end)
 	        DATE_TAB=$(  IGCM_date_AddDaysToGregorianDate ${DATE_LOOP} $(( 1 - Length1 )) )_${DATE_LOOP}
 
-		Length2=$( create_ts_next_date ${DATE_LOOP} end)
+		Length2=$( IGCM_date_DaysInNextPeriod ${DATE_LOOP} ${config_UserChoices_PeriodLength} )
 		DATE_LOOP=$( IGCM_date_AddDaysToGregorianDate ${DATE_LOOP} ${Length2} )
 
@@ -849,5 +738,5 @@
 	    # WE CAN CONCATENATE FILES AT THIS POINT
 	    [ "${FLAG_B}" = "TRUE" ] && DATE_BUILD_B=${DateBegin}_${DATE_FIN_JOB_B_LOOP_PREC}
-	    Length=$( create_ts_begin_date ${DATE_COURANTE} end)
+	    Length=$( IGCM_date_DaysInPreviousPeriod ${DATE_COURANTE} ${config_UserChoices_PeriodLength} end)
 	    DATE_BUILD1=$( IGCM_date_AddDaysToGregorianDate ${DATE_COURANTE} -$(( Length - 1 )) )
 	    DATE_BUILD=${DATE_BUILD1}_${DATE_FIN}
Index: trunk/libIGCM/AA_monitoring
===================================================================
--- trunk/libIGCM/AA_monitoring	(revision 553)
+++ trunk/libIGCM/AA_monitoring	(revision 554)
@@ -136,11 +136,11 @@
 StandAlone=${StandAlone:=true}
 
-#D- Low level debug : to bypass lib test checks and stack construction
-#D- Default : value from AA_job if any
+#D- Path to libIGCM
+#D- Default : value from AA_job if any
+# WARNING For StandAlone use : To run this script on some machine (ulam and cesium)
+# WARNING you must check MirrorlibIGCM variable in sys library.
+# WARNING If this variable is true, you must use libIGCM_POST path instead
+# WARNING of your running libIGCM directory.
 libIGCM=${libIGCM:=::modipsl::/libIGCM}
-# WARNING for StandAlone used : To run this script on some machine,
-# you must check MirrorlibIGCM variable in sys library.
-# If this variable is true, you must use libIGCM_POST path instead
-# of your running libIGCM directory.
 
 #D- Increased verbosity (1, 2, 3)
Index: trunk/libIGCM/AA_move-and-rename
===================================================================
--- trunk/libIGCM/AA_move-and-rename	(revision 553)
+++ trunk/libIGCM/AA_move-and-rename	(revision 554)
@@ -33,12 +33,14 @@
 ########################################################################
 
-# Chemin vers MODIPSL
+# Path to modipsl
 MODIPSL=${MODIPSL:=::modipsl::}
 
-# Chemin vers libIGCM
-libIGCM=${libIGCM:=${MODIPSL}/libIGCM}
-# Attention : Ã  changer si la machine de post-traitement n'est pas la frontale du serveur de calcul !
-#             voir prÃ©cence de la variable MirrorlibIGCM dans votre couche systÃšme.
-
+#D- Path to libIGCM
+#D- Default : value from AA_job if any
+# WARNING For StandAlone use : To run this script on some machine (ulam and cesium)
+# WARNING you must check MirrorlibIGCM variable in sys library.
+# WARNING If this variable is true, you must use libIGCM_POST path instead
+# WARNING of your running libIGCM directory.
+libIGCM=${libIGCM:=::modipsl::/libIGCM}
 
 DEBUG_sys=false
Index: trunk/libIGCM/AA_pack_debug
===================================================================
--- trunk/libIGCM/AA_pack_debug	(revision 553)
+++ trunk/libIGCM/AA_pack_debug	(revision 554)
@@ -33,5 +33,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 ; $DateBegin ; $PeriodDateBegin ; $PeriodDateEnd ; $StandAlone ; $MASTER
+#-Q- sx8brodie # @ environment  = $DEBUG_debug ; $MODIPSL ; $libIGCM ; $libIGCM_SX ; $SUBMIT_DIR ; $DateBegin ; $DateEnd ; $PeriodPack ; $StandAlone ; $MASTER
 #-Q- sx8brodie # @ queue
 #-Q- aix6 #!/bin/ksh
@@ -49,5 +49,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 ; $DateBegin ; $PeriodDateBegin ; $PeriodDateEnd ; $StandAlone ; $MASTER
+#-Q- aix6 # @ environment  = $DEBUG_debug ; $MODIPSL ; $libIGCM ; $libIGCM_SX ; $SUBMIT_DIR ; $DateBegin ; $DateEnd ; $PeriodPack ; $StandAlone ; $MASTER
 #-Q- aix6 # @ queue
 #-Q- ulam #!/bin/ksh
@@ -65,5 +65,5 @@
 #-Q- ulam # pour recevoir un mail en cas de depassement du temps Elapsed (ou autre pb.)
 #-Q- ulam # @ notification = error
-#-Q- ulam # @ environment  = $DEBUG_debug ; $MODIPSL ; $libIGCM ; $libIGCM_SX ; $SUBMIT_DIR ; $DateBegin ; $PeriodDateBegin ; $PeriodDateEnd ; $StandAlone ; $MASTER
+#-Q- ulam # @ environment  = $DEBUG_debug ; $MODIPSL ; $libIGCM ; $libIGCM_SX ; $SUBMIT_DIR ; $DateBegin ; $DateEnd ; $PeriodPack ; $StandAlone ; $MASTER
 #-Q- ulam # @ queue
 #-Q- sx8mercure #!/bin/ksh
@@ -132,39 +132,41 @@
 StandAlone=${StandAlone:=true}
 
-#D- Flag to determine begin date for restart pack
-#D- Default : value from AA_job if any
-DateBegin=20000101
-
-#D- Flag to determine end date for restart pack
-#D- Default : value from AA_job if any
-DateEnd=20691231
-
-#D- Flag to determine pack period
-#D- Default : value from AA_job if any
-period_pack=${period_pack:=10Y}
-
-SUBMIT_DIR=${PWD}
-
-RUN_DIR_PATH=/scratch/cont003/p86denv/Pack_Test
+#D- Path to libIGCM
+#D- Default : value from AA_job if any
+# WARNING For StandAlone use : To run this script on some machine (ulam and cesium)
+# WARNING you must check MirrorlibIGCM variable in sys library.
+# WARNING If this variable is true, you must use libIGCM_POST path instead
+# WARNING of your running libIGCM directory.
+libIGCM=${libIGCM:=::modipsl::/libIGCM}
 
 #-D- $hostname of the MASTER job when SUBMIT_DIR is not visible on postprocessing computer.
 MASTER=${MASTER:=mercure|titane|brodie|vargas}
 
+#D- Flag to determine begin date for restart pack
+#D- Default : value from AA_job if any
+DateBegin=${DateBegin:=20000101)
+
+#D- Flag to determine end date for restart pack
+#D- Default : value from AA_job if any
+DateEnd=${DateEnd:=20691231}
+
+#D- Flag to determine pack period
+#D- Default : value from AA_job if any
+PeriodPack=${PeriodPack:=10Y}
+
+#D- Uncomment to run interactively
+#D- For testing purpose, will be remove
+#SUBMIT_DIR=${PWD}
+#RUN_DIR_PATH=${SCRATCHDIR}/Pack_Test
+
+#D- Increased verbosity (1, 2, 3)
+#D- Default : value from AA_job if any
+Verbosity=${Verbosity:=3}
+
 #D- Low level debug : to bypass lib test checks and stack construction
 #D- Default : value from AA_job if any
-libIGCM=${libIGCM:=/work/cont003/p86denv/PARA_XEON_CM5_IPSLCM5A.16122011_39L/modipsl/libIGCM}
-
-# WARNING for StandAlone use : To run this script on some machine,
-# you must check MirrorlibIGCM variable in sys library.
-# If this variable is true, you must use libIGCM_POST path instead
-# of your running libIGCM directory.
-
-#D- Increased verbosity (1, 2, 3)
-#D- Default : value from AA_job if any
-Verbosity=${Verbosity:=3}
-
-#D- Low level debug : to bypass lib test checks and stack construction
-#D- Default : value from AA_job if any
 DEBUG_debug=${DEBUG_debug:=false}
+
+#D- Keep following comments for now. Will be remove.
 
 #on veut archiver les fichiers restart
@@ -187,5 +189,5 @@
 # $1= PATH/config_card d'une simulation avec 
 # TagName/JobName/ExperimentName/SpaceName/DateBegin/DateEnd/PATH_SIMUL
-# $2=period_pack en M/m ou Y/y
+# $2=PeriodPack en M/m ou Y/y
 
 ########################################################################
@@ -264,17 +266,12 @@
 #### Preparation de l'environnement
 # repertoire dans lequel seront crees les archives
-#STORE_DEBUG=${R_SAVE}/DEBUG
-#IGCM_sys_MkdirArchive ${STORE_DEBUG}
-
-STORE_DEBUG=/scratch/cont003/p86denv/Pack_Test/DEBUG
-mkdir -p ${STORE_DEBUG}
-
-#### 0- lecture de config.card 
-#### on veut les renseignements suivants : 
-#### JobName, PATH_SIMUL, DateBegin et DateEnd
-
+STORE_DEBUG=${R_SAVE}/DEBUG
+IGCM_sys_MkdirArchive ${STORE_DEBUG}
+
+#STORE_DEBUG=/scratch/cont003/p86denv/Pack_Test/DEBUG
+#mkdir -p ${STORE_DEBUG}
+
+# Switch to script variables meaning (try to be compatible with ipsl_pack TGCC moving procedure)
 JobName=${config_UserChoices_JobName}
-#DateBegin=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateBegin} )
-#DateEnd=$(   IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd}   )
 PATH_SIMUL=${R_BUFR}
 echo $JobName $PATH_SIMUL $DateBegin $DateEnd
@@ -295,5 +292,5 @@
 ###cat  ${RUN_DIR}/liste_debug_files.txt | xargs dmget 
 
-# Rename debug files we will work with
+# Rename debug files we will work with using symlinks
 #gawk -F/ '{dest_name=$(NF-2)("_") $(NF); system("cp --preserve " $0 " "dest_name)}' ${RUN_DIR}/liste_debug_files.txt
 gawk -F/ '{dest_name=$(NF-2)("_") $(NF); system("ln -s " $0 " "dest_name)}' ${RUN_DIR}/liste_debug_files.txt
@@ -303,8 +300,8 @@
 
 ### 2- creer les listes de fichiers par periode ####
-###Â 2.1- dechiffrer period_pack et le separer en year et month ###
-case ${period_pack} in
+###Â 2.1- dechiffrer PeriodPack et le separer en year et month ###
+case ${PeriodPack} in
 *Y|*y) 
-  periodpackinyear=$( echo ${period_pack} | sed -e 's/[yY]//' ) 
+  periodpackinyear=$( echo ${PeriodPack} | sed -e 's/[yY]//' ) 
   periodpackinmonth=0
   ;;
@@ -312,9 +309,9 @@
 *M|*m) 
   periodpackinyear=0
-  periodpackinmonth=$( echo ${period_pack} | sed -e 's/[mM]//' ) 
+  periodpackinmonth=$( echo ${PeriodPack} | sed -e 's/[mM]//' ) 
   ;;
 
 *)
-  echo "period_pack doit etre en mois ou annees"
+  echo "PeriodPack doit etre en mois ou annees"
   IGCM_debug_Exit "period pack unit"
   ;;
@@ -366,4 +363,5 @@
     if [ ${date_file} -lt ${date_end_pack} ] && [ ${date_file} -ge ${date_begin_pack} ] ; then 
         echo $( basename ${file} ) >> ${RUN_DIR}/liste_pack_${number_pack}.txt
+#    Will not work. Need to find a better ordering.
 #    elif [ ${date_file} -ge ${date_end_pack} ] ; then
 #      break
@@ -375,5 +373,6 @@
   date_begin_pack=${year_begin_pack}$( printf "%02i\n" ${month_begin_pack} )01
 
-  tar -cvf ${STORE_DEBUG}/debug_pack_${number_pack}.tar --dereference --files-from ${RUN_DIR}/liste_pack_${number_pack}.txt
+  # Here we create tar files directly in $STORE. Avoid to create then to copy.
+  tar -cvf ${STORE_DEBUG}/${JobName}_${year_begin_pack}_${year_end_pack}_debug.tar --dereference --files-from ${RUN_DIR}/liste_pack_${number_pack}.txt
   cat  ${RUN_DIR}/liste_pack_${number_pack}.txt | xargs rm 
   mv ${RUN_DIR}/liste_pack_${number_pack}.txt ${STORE_DEBUG}
Index: trunk/libIGCM/AA_pack_restart
===================================================================
--- trunk/libIGCM/AA_pack_restart	(revision 553)
+++ trunk/libIGCM/AA_pack_restart	(revision 554)
@@ -33,5 +33,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 ; $DateBegin ; $PeriodDateBegin ; $PeriodDateEnd ; $StandAlone ; $MASTER
+#-Q- sx8brodie # @ environment  = $DEBUG_debug ; $MODIPSL ; $libIGCM ; $libIGCM_SX ; $SUBMIT_DIR ; $DateBegin ; $DateEnd ; $PeriodPack ; $StandAlone ; $MASTER
 #-Q- sx8brodie # @ queue
 #-Q- aix6 #!/bin/ksh
@@ -49,5 +49,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 ; $DateBegin ; $PeriodDateBegin ; $PeriodDateEnd ; $StandAlone ; $MASTER
+#-Q- aix6 # @ environment  = $DEBUG_debug ; $MODIPSL ; $libIGCM ; $libIGCM_SX ; $SUBMIT_DIR ; $DateBegin ; $DateEnd ; $PeriodPack ; $StandAlone ; $MASTER
 #-Q- aix6 # @ queue
 #-Q- ulam #!/bin/ksh
@@ -65,5 +65,5 @@
 #-Q- ulam # pour recevoir un mail en cas de depassement du temps Elapsed (ou autre pb.)
 #-Q- ulam # @ notification = error
-#-Q- ulam # @ environment  = $DEBUG_debug ; $MODIPSL ; $libIGCM ; $libIGCM_SX ; $SUBMIT_DIR ; $DateBegin ; $PeriodDateBegin ; $PeriodDateEnd ; $StandAlone ; $MASTER
+#-Q- ulam # @ environment  = $DEBUG_debug ; $MODIPSL ; $libIGCM ; $libIGCM_SX ; $SUBMIT_DIR ; $DateBegin ; $DateEnd ; $PeriodPack ; $StandAlone ; $MASTER
 #-Q- ulam # @ queue
 #-Q- sx8mercure #!/bin/ksh
@@ -132,39 +132,41 @@
 StandAlone=${StandAlone:=true}
 
-#D- Flag to determine begin date for restart pack
-#D- Default : value from AA_job if any
-DateBegin=20000101
-
-#D- Flag to determine end date for restart pack
-#D- Default : value from AA_job if any
-DateEnd=20691231
-
-#D- Flag to determine pack period
-#D- Default : value from AA_job if any
-period_pack=${period_pack:=10Y}
-
-SUBMIT_DIR=${PWD}
-
-RUN_DIR_PATH=/scratch/cont003/p86denv/Pack_Test
+#D- Path to libIGCM
+#D- Default : value from AA_job if any
+# WARNING For StandAlone use : To run this script on some machine (ulam and cesium)
+# WARNING you must check MirrorlibIGCM variable in sys library.
+# WARNING If this variable is true, you must use libIGCM_POST path instead
+# WARNING of your running libIGCM directory.
+libIGCM=${libIGCM:=::modipsl::/libIGCM}
 
 #-D- $hostname of the MASTER job when SUBMIT_DIR is not visible on postprocessing computer.
 MASTER=${MASTER:=mercure|titane|brodie|vargas}
 
+#D- Flag to determine begin date for restart pack
+#D- Default : value from AA_job if any
+DateBegin=${DateBegin:=20000101)
+
+#D- Flag to determine end date for restart pack
+#D- Default : value from AA_job if any
+DateEnd=${DateEnd:=20691231}
+
+#D- Flag to determine pack period
+#D- Default : value from AA_job if any
+PeriodPack=${PeriodPack:=10Y}
+
+#D- Uncomment to run interactively
+#D- For testing purpose, will be remove
+#SUBMIT_DIR=${PWD}
+#RUN_DIR_PATH=${SCRATCHDIR}/Pack_Test
+
+#D- Increased verbosity (1, 2, 3)
+#D- Default : value from AA_job if any
+Verbosity=${Verbosity:=3}
+
 #D- Low level debug : to bypass lib test checks and stack construction
 #D- Default : value from AA_job if any
-libIGCM=${libIGCM:=/work/cont003/p86denv/PARA_XEON_CM5_IPSLCM5A.16122011_39L/modipsl/libIGCM}
-
-# WARNING for StandAlone use : To run this script on some machine,
-# you must check MirrorlibIGCM variable in sys library.
-# If this variable is true, you must use libIGCM_POST path instead
-# of your running libIGCM directory.
-
-#D- Increased verbosity (1, 2, 3)
-#D- Default : value from AA_job if any
-Verbosity=${Verbosity:=3}
-
-#D- Low level debug : to bypass lib test checks and stack construction
-#D- Default : value from AA_job if any
 DEBUG_debug=${DEBUG_debug:=false}
+
+#D- Keep following comments for now. Will be remove.
 
 #on veut archiver les fichiers restart
@@ -187,5 +189,5 @@
 # $1= PATH/config_card d'une simulation avec 
 # TagName/JobName/ExperimentName/SpaceName/DateBegin/DateEnd/PATH_SIMUL
-# $2=period_pack en M/m ou Y/y
+# $2=PeriodPack en M/m ou Y/y
 
 ########################################################################
@@ -264,17 +266,12 @@
 #### Preparation de l'environnement
 # repertoire dans lequel seront crees les archives
-#STORE_RESTART=${R_SAVE}/RESTART
-#IGCM_sys_MkdirArchive ${STORE_RESTART}
-
-STORE_RESTART=/scratch/cont003/p86denv/Pack_Test/RESTART
-mkdir -p ${STORE_RESTART}
-
-#### 0- lecture de config.card 
-#### on veut les renseignements suivants : 
-#### JobName, PATH_SIMUL, DateBegin et DateEnd
-
+STORE_RESTART=${R_SAVE}/RESTART
+IGCM_sys_MkdirArchive ${STORE_RESTART}
+
+#STORE_RESTART=/scratch/cont003/p86denv/Pack_Test/RESTART
+#mkdir -p ${STORE_RESTART}
+
+# Switch to script variables meaning (try to be compatible with ipsl_pack TGCC moving procedure)
 JobName=${config_UserChoices_JobName}
-#DateBegin=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateBegin} )
-#DateEnd=$(   IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd}   )
 PATH_SIMUL=${R_BUFR}
 echo $JobName $PATH_SIMUL $DateBegin $DateEnd
@@ -305,8 +302,8 @@
 
 ### 2- creer les listes de fichiers par periode ####
-###Â 2.1- dechiffrer period_pack et le separer en year et month ###
-case ${period_pack} in
+###Â 2.1- dechiffrer PeriodPack et le separer en year et month ###
+case ${PeriodPack} in
 *Y|*y) 
-  periodpackinyear=$( echo ${period_pack} | sed -e 's/[yY]//' ) 
+  periodpackinyear=$( echo ${PeriodPack} | sed -e 's/[yY]//' ) 
   periodpackinmonth=0
   ;;
@@ -314,9 +311,9 @@
 *M|*m) 
   periodpackinyear=0
-  periodpackinmonth=$( echo ${period_pack} | sed -e 's/[mM]//' ) 
+  periodpackinmonth=$( echo ${PeriodPack} | sed -e 's/[mM]//' ) 
   ;;
 
 *)
-  echo "period_pack doit etre en mois ou annees"
+  echo "PeriodPack doit etre en mois ou annees"
   IGCM_debug_Exit "period pack unit"
   ;;
@@ -368,4 +365,5 @@
     if [ ${date_file} -lt ${date_end_pack} ] && [ ${date_file} -ge ${date_begin_pack} ] ; then 
         echo $( basename ${file} ) >> ${RUN_DIR}/liste_pack_${number_pack}.txt
+#    Will not work. Need to find a better ordering.
 #    elif [ ${date_file} -ge ${date_end_pack} ] ; then
 #      break
@@ -377,5 +375,6 @@
   date_begin_pack=${year_begin_pack}$( printf "%02i\n" ${month_begin_pack} )01
 
-  tar -cvf ${STORE_RESTART}/restart_pack_${number_pack}.tar --dereference --files-from ${RUN_DIR}/liste_pack_${number_pack}.txt
+  # Here we create tar files directly in $STORE. Avoid to create then to copy.
+  tar -cvf ${STORE_RESTART}/${JobName}_${year_begin_pack}_${year_end_pack}_restart.tar --dereference --files-from ${RUN_DIR}/liste_pack_${number_pack}.txt
   cat  ${RUN_DIR}/liste_pack_${number_pack}.txt | xargs rm 
   mv ${RUN_DIR}/liste_pack_${number_pack}.txt ${STORE_RESTART}
Index: trunk/libIGCM/AA_rebuild_fromArchive
===================================================================
--- trunk/libIGCM/AA_rebuild_fromArchive	(revision 553)
+++ trunk/libIGCM/AA_rebuild_fromArchive	(revision 554)
@@ -136,11 +136,11 @@
 StandAlone=${StandAlone:=true}
 
-#D- Low level debug : to bypass lib test checks and stack construction
-#D- Default : value from AA_job if any
+#D- Path to libIGCM
+#D- Default : value from AA_job if any
+# WARNING For StandAlone use : To run this script on some machine (ulam and cesium)
+# WARNING you must check MirrorlibIGCM variable in sys library.
+# WARNING If this variable is true, you must use libIGCM_POST path instead
+# WARNING of your running libIGCM directory.
 libIGCM=${libIGCM:=::modipsl::/libIGCM}
-# WARNING for StandAlone used : To run this script on some machine,
-# you must check MirrorlibIGCM variable in sys library.
-# If this variable is true, you must use libIGCM_POST path instead
-# of your running libIGCM directory.
 
 #-D- $hostname of the MASTER job when SUBMIT_DIR is not visible on postprocessing computer.
Index: trunk/libIGCM/AA_rebuild_fromWorkdir
===================================================================
--- trunk/libIGCM/AA_rebuild_fromWorkdir	(revision 553)
+++ trunk/libIGCM/AA_rebuild_fromWorkdir	(revision 554)
@@ -136,11 +136,11 @@
 StandAlone=${StandAlone:=true}
 
-#D- Low level debug : to bypass lib test checks and stack construction
-#D- Default : value from AA_job if any
+#D- Path to libIGCM
+#D- Default : value from AA_job if any
+# WARNING For StandAlone use : To run this script on some machine (ulam and cesium)
+# WARNING you must check MirrorlibIGCM variable in sys library.
+# WARNING If this variable is true, you must use libIGCM_POST path instead
+# WARNING of your running libIGCM directory.
 libIGCM=${libIGCM:=::modipsl::/libIGCM}
-# WARNING for StandAlone used : To run this script on some machine,
-# you must check MirrorlibIGCM variable in sys library.
-# If this variable is true, you must use libIGCM_POST path instead
-# of your running libIGCM directory.
 
 #-D- $hostname of the MASTER job when SUBMIT_DIR is not visible on postprocessing computer.
Index: trunk/libIGCM/libIGCM_config/libIGCM_config.ksh
===================================================================
--- trunk/libIGCM/libIGCM_config/libIGCM_config.ksh	(revision 553)
+++ trunk/libIGCM/libIGCM_config/libIGCM_config.ksh	(revision 554)
@@ -211,5 +211,5 @@
 
   #==================================
-  # Post : 
+  # Read Post section: 
   IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card Post
 
@@ -222,4 +222,8 @@
     IGCM_debug_Print 3 "${option} : ${auxprint}"
   done
+
+  #==================================
+  # Define default value to keep compatibility with previous card: means before changes due to TGCC 
+  [ X${config_Post_PackFrequency} = X ] && config_Post_PackFrequency=${config_Post_RebuildFrequency}
 
   #====================================================
@@ -341,4 +345,5 @@
   typeset i
 
+  # Check RebuildFrequency against key frequencies : PeriodLength ; PackFrequency ; TimeSeriesFrequency ; SeasonalFrequency
   if ( [ ! X${config_Post_RebuildFrequency} = X${NULL_STR} ] && [ ! X${config_Post_RebuildFrequency} = XNONE ] ) ; then
     AsynchronousRebuild=true
@@ -348,4 +353,6 @@
     IGCM_debug_Print 1 "Check coherence between RebuildFrequency and PeriodLength"
     IGCM_post_CheckModuloFrequency config_Post_RebuildFrequency config_UserChoices_PeriodLength
+    IGCM_debug_Print 1 "Check coherence between PackFrequency and RebuildFrequency"
+    IGCM_post_CheckModuloFrequency config_Post_PackFrequency config_Post_RebuildFrequency
     IGCM_debug_Print 1 "Check coherence between TimeSeriesFrequency and RebuildFrequency"
     IGCM_post_CheckModuloFrequency config_Post_TimeSeriesFrequency config_Post_RebuildFrequency
@@ -357,9 +364,24 @@
     IGCM_debug_Print 1 "Proceed with standard post-treatment pathway"
     echo
-    #modulo (TimeSeriesFrequency/SeasonalFrequency and PeriodLenght) must be zero
+    #modulo (PeriodLength and TimeSeriesFrequency/SeasonalFrequency) must be zero
     IGCM_debug_Print 1 "Check coherence between TimeSeriesFrequency and PeriodLength"
     IGCM_post_CheckModuloFrequency config_Post_TimeSeriesFrequency config_UserChoices_PeriodLength
     IGCM_debug_Print 1 "Check coherence between SeasonalFrequency and PeriodLength"
     IGCM_post_CheckModuloFrequency config_Post_SeasonalFrequency   config_UserChoices_PeriodLength
+  fi
+
+  # Check PackFrequency against other key frequencies 
+  # Modulo (PackFrequency and TimeSeriesFrequency/SeasonalFrequency and PeriodLenght) must be zero
+  if ( [ ! X${config_Post_PackFrequency} = X${NULL_STR} ] && [ ! X${config_Post_PackFrequency} = XNONE ] ) ; then
+    Pack=true
+    #
+    IGCM_debug_Print 1 "Check coherence between PackFrequency and PeriodLength"
+    IGCM_post_CheckModuloFrequency config_Post_PackFrequency config_UserChoices_PeriodLength
+    IGCM_debug_Print 1 "Check coherence between TimeSeriesFrequency and PackFrequency"
+    IGCM_post_CheckModuloFrequency config_Post_TimeSeriesFrequency config_Post_PackFrequency
+    IGCM_debug_Print 1 "Check coherence between SeasonalFrequency and PackFrequency"
+    IGCM_post_CheckModuloFrequency config_Post_SeasonalFrequency config_Post_PackFrequency
+  else
+    Pack=false
   fi
 
Index: trunk/libIGCM/libIGCM_date/libIGCM_date.ksh
===================================================================
--- trunk/libIGCM/libIGCM_date/libIGCM_date.ksh	(revision 553)
+++ trunk/libIGCM/libIGCM_date/libIGCM_date.ksh	(revision 554)
@@ -825,4 +825,125 @@
 
 #D-#==================================================================
+#D-function IGCM_date_DaysInPreviousPeriod ()
+#D-* Purpose: Give the numbers of days during the previous prd1 period from grg1 date # OLD create_ts_begin_date
+#D-* Usage: IGCM_date_DaysInPreviousPeriod grg1 prd1 [end]
+#D-         where grg1 gregorian date is in the form yyyymmdd
+#D-         where prd1 period is in the form N[Yy], N[Mm], N[Dd]. N integer
+#D-         where [end] is an optionnal keyword to specify grg1 is the end of prd1
+#D-
+function IGCM_date_DaysInPreviousPeriod {
+  IGCM_debug_PushStack "IGCM_date_DaysInPreviousPeriod" $@
+  typeset Length Period
+  Period=${2}
+  case ${Period} in
+  *Y|*y)
+    PeriodLengthInYears=$( echo ${Period} | awk -F '[yY]' '{print $1}' )
+    IGCM_date_GetYearMonth ${1} year month
+    year=$( IGCM_date_SupressZeros ${year} )
+    if [ X${2} = Xend ] ; then
+      (( year = year - PeriodLengthInYears + 1))
+    fi
+    (( Length=0 ))
+    (( i=0 ))
+    until [ $i -ge $PeriodLengthInYears ] ; do
+      (( Length = Length + $( IGCM_date_DaysInYear $(( year + i )) ) )) 
+      (( i=i+1 ))
+    done
+    ;;
+  *M|*m)
+    PeriodLengthInMonths=$( echo ${Period} | awk -F '[mM]' '{print $1}' )
+    IGCM_date_GetYearMonth ${1} year month
+    year=$( IGCM_date_SupressZeros ${year} )
+    if [ X${2} = Xend ] ; then
+      (( month = month - PeriodLengthInMonths + 1 ))
+    fi	    
+    (( year0 = year ))
+    if [ $month -le 0 ] ; then
+      (( month = month + 12 ))
+      year=$( printf "%04i\n" $(( year - 1 )) )
+    fi
+    month=$( printf "%02i\n" ${month} )
+    (( Length=0 ))
+    (( i=0 ))
+    until [ $i -ge $PeriodLengthInMonths ] ; do
+      if [ $(( month + i )) -lt 13 ] ; then
+	(( Length = Length + $( IGCM_date_DaysInMonth $year $(( month + i )) ) ))
+      else
+	(( year = year0 + 1 ))
+	(( Length = Length + $( IGCM_date_DaysInMonth $year $(( month + i - 12 )) ) ))
+      fi
+      (( i=i+1 ))
+    done
+    ;;
+  *D|*d)
+    Length=$( echo ${Period} | sed -e "s/[dD]//" ) ;;
+  *)
+    IGCM_debug_Exit "IGCM_date_DaysInPreviousPeriod " ${Period} " invalid PeriodLength : choose in *Y, *M, *D."
+    IGCM_debug_Verif_Exit_Post ;;
+  esac
+  echo ${Length}
+
+  IGCM_debug_PopStack "IGCM_date_DaysInPreviousPeriod"
+}
+
+#D-#==================================================================
+#D-function IGCM_date_DaysInNextPeriod ()
+#D-* Purpose: Give the numbers of days during the next prd1 period from grg1 date # OLD create_ts_next_date
+#D-* Usage: IGCM_date_DaysInNextPeriod grg1 prd1
+#D-         where grg1 gregorian date is in the form yyyymmdd
+#D-         where prd1 period is in the form N[Yy], N[Mm], N[Dd]. N integer
+#D-
+function IGCM_date_DaysInNextPeriod {
+  IGCM_debug_PushStack "IGCM_date_DaysInNextPeriod" $@
+  typeset Length Period
+  Period=${2}
+  case ${Period} in
+  *Y|*y) 
+    PeriodLengthInYears=$( echo ${Period} | awk -F '[yY]' '{print $1}' )
+    IGCM_date_GetYearMonth ${1} year month
+    year=$( IGCM_date_SupressZeros ${year} )
+    (( Length=0 ))
+    (( i=0 ))
+    until [ $i -ge $PeriodLengthInYears ] ; do
+      (( Length = Length + $( IGCM_date_DaysInYear $(( year + i + 1 )) ) )) 
+      (( i=i+1 ))
+    done
+    ;;
+  *M|*m) 
+    PeriodLengthInMonths=$( echo ${Period} | awk -F '[mM]' '{print $1}' )
+    IGCM_date_GetYearMonth ${1} year month
+    year=$( IGCM_date_SupressZeros ${year} )
+    (( year0 = year ))
+    if [ $(( month + 1 )) -lt 13 ] ; then
+      month0=$(( month + 1 ))
+    else
+      month0=$(( month + 1 - 12 ))
+      (( year = year0 + 1 ))
+    fi
+    (( Length=0 ))
+    (( i=0 ))
+    until [ $i -ge $PeriodLengthInMonths ] ; do
+      if [ $(( month0 + i )) -lt 13 ] ; then
+	(( Length = Length + $( IGCM_date_DaysInMonth $year $(( month0 + i )) ) ))
+      else
+	(( year = year0 + 1 ))
+	(( Length = Length + $( IGCM_date_DaysInMonth $year $(( month0 + i - 12 )) ) ))
+      fi
+      (( i=i+1 ))
+    done
+    ;;
+  *D|*d)
+    Length=$( echo ${Period} | sed -e "s/[dD]//" ) ;;
+  *)
+    IGCM_debug_Exit "IGCM_date_DaysInNextPeriod " ${Period} " invalid PeriodLength : choose in *Y, *M, *D."
+    IGCM_debug_Verif_Exit_Post ;;
+  esac
+  echo ${Length}
+
+  IGCM_debug_PopStack "IGCM_date_DaysInNextPeriod"
+}
+
+
+#D-#==================================================================
 #D-function IGCM_date_Check
 #D- * Purpose: Check the present file by comparison with a reference file
Index: trunk/libIGCM/libIGCM_post/libIGCM_post.ksh
===================================================================
--- trunk/libIGCM/libIGCM_post/libIGCM_post.ksh	(revision 553)
+++ trunk/libIGCM/libIGCM_post/libIGCM_post.ksh	(revision 554)
@@ -26,6 +26,8 @@
   POST=false
   RebuildFrequency=false
+  PackFrequency=false
   TimeSeriesFrequency=false
   SeasonalFrequency=false
+  unset list_post
   #
   # ONLY IF SOMETHING NEEDS TO BE DONE (EATHER TIME SERIES OR SEASONAL) COMPUTE THE MODULOS
@@ -33,4 +35,8 @@
   if [ X${AsynchronousRebuild} = Xtrue ] ; then
     list_post="RebuildFrequency"
+  fi
+  #
+  if [ X${Pack} = Xtrue ] ; then
+    list_post="${list_post} PackFrequency"
   fi
   #
@@ -102,5 +108,5 @@
   fi
 
-  #============ TIME SERIES POST-TREATMENT ===========#
+  #============ TIME SERIES POST-PROCESSING ===========#
   if [ ${TimeSeriesFrequency} = true ] ; then
 
@@ -329,8 +335,8 @@
   fi
 
-  #=============  SEASONAL POST-TREATMENT ============#
+  #=============  SEASONAL POST-PROCESSING ============#
   if [ ${SeasonalFrequency} = true ] ; then
     #
-    IGCM_debug_Print 1 "SEASONNAL POST-TREATMENT"
+    IGCM_debug_Print 1 "SEASONNAL POST-PROCESSING"
     echo
     #
@@ -406,5 +412,5 @@
   fi
 
-  #============== REBUILD POST-TREATMENT =============#
+  #============== REBUILD POST-PROCESSING =============#
   if [ X${AsynchronousRebuild} = Xtrue ] ; then
     # -----------------------------------------------------------------------------------
@@ -424,10 +430,10 @@
   if [ ${RebuildFrequency} = true ] ; then
     if ( [ ${config_Post_RebuildFromArchive} = true ] ) ; then
-      IGCM_debug_Print 1 "REBUILD POST-TREATMENT FROM ARCHIVE"
+      IGCM_debug_Print 1 "REBUILD POST-PROCESSING FROM ARCHIVE"
       echo
       #
       script=rebuild_fromArchive
     else
-      IGCM_debug_Print 1 "REBUILD POST-TREATMENT FROM WORKDIR"
+      IGCM_debug_Print 1 "REBUILD POST-PROCESSING FROM WORKDIR"
       echo
       #
@@ -468,4 +474,44 @@
 EOF
   fi
+
+  #============== PACK PROCESSING FOR RESTART AND DEBUG FILES =============#
+  if [ ${PackFrequency} = true ] ; then
+    IGCM_debug_Print 1 "PACK POST-PROCESSING"
+    echo
+    ## Need to Remember This One
+    SavedDateBegin=${DateBegin}
+    ## Need to Remember This One
+    SavedDateEnd=${DateEnd}
+    #
+    PackDateBegin=$( IGCM_date_AddDaysToGregorianDate ${PeriodDateEnd} -$( IGCM_date_DaysInPreviousPeriod ${PeriodDateEnd} end ) )
+    #
+    script=pack_debug
+    #
+    Script_Post_Output=${script}.${PeriodDateEnd}
+    #
+    listVarEnv="DEBUG_debug,MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,MASTER,DateBegin,DateEnd,PeriodPack,StandAlone"
+    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 MASTER=${MASTER}
+    export DateBegin=${PackDateBegin}
+    export DateEnd=${PeriodDateEnd}
+    export PeriodPack=${config_UserChoices_PackFrequency}
+    export StandAlone=false
+    export listVarEnv=${listVarEnv}
+    export Script_Post_Output=${Script_Post_Output}
+    . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
+    . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
+    IGCM_sys_MkdirWork ${POST_DIR}
+    IGCM_debug_Verif_Exit_Post
+#    IGCM_sys_QsubPost ${script}
+EOF
+  fi
+
+  export DateBegin=${SavedDateBegin}
+  export DateEnd=${SavedDateEnd}
 
   IGCM_debug_PopStack "IGCM_post_Submit"
