Index: branches/libIGCM_MPI_OpenMP/libIGCM_post/IGCM_Patch_20091118_mask.ksh
===================================================================
--- branches/libIGCM_MPI_OpenMP/libIGCM_post/IGCM_Patch_20091118_mask.ksh	(revision 571)
+++ branches/libIGCM_MPI_OpenMP/libIGCM_post/IGCM_Patch_20091118_mask.ksh	(revision 592)
@@ -20,5 +20,16 @@
     IGCM_debug_PushStack "IGCM_Patch_mask" $@
 
-    [ -f ${config_UserChoices_JobName}_mesh_mask.nc ] || IGCM_sys_Get ${R_SAVE}/OCE/Output/${config_UserChoices_JobName}_mesh_mask.nc .
+    if [ ! -f ${config_UserChoices_JobName}_mesh_mask.nc ] ; then
+      if [ -f ${R_BUFR}/OCE/Output/${config_UserChoices_JobName}_mesh_mask.nc ] ; then
+	IGCM_sys_GetBuffer ${R_BUFR}/OCE/Output/${config_UserChoices_JobName}_mesh_mask.nc .
+      elif [ -f ${R_SAVE}/OCE/Output/${config_UserChoices_JobName}_mesh_mask.nc ] ; then
+	IGCM_sys_Get ${R_SAVE}/OCE/Output/${config_UserChoices_JobName}_mesh_mask.nc .
+      else
+	IGCM_debug_Exit "mesh_mask can not be found. Stop."
+	IGCM_debug_Exit "neither here ${R_SAVE}/OCE/Output/${config_UserChoices_JobName}_mesh_mask.nc"
+	IGCM_debug_Exit "nor here ${R_BUFR}/OCE/Output/${config_UserChoices_JobName}_mesh_mask.nc"
+	IGCM_debug_Verif_Exit_Post
+      fi
+    fi
 
     filename=${1}
Index: branches/libIGCM_MPI_OpenMP/libIGCM_post/libIGCM_post.ksh
===================================================================
--- branches/libIGCM_MPI_OpenMP/libIGCM_post/libIGCM_post.ksh	(revision 571)
+++ branches/libIGCM_MPI_OpenMP/libIGCM_post/libIGCM_post.ksh	(revision 592)
@@ -248,5 +248,5 @@
 	  [ $(( ( ${YearEnd} - ${YearBegin} + 1 ) % ${YearsChunckLength} )) = 0 ] && NbYearsChunckLoop=$(( ${NbYearsChunckLoop} - 1 ))
 	  # Starting Year of the current chunck
-	  ChunckTsYearBegin=$(( ${NbYearsChunckLoop} *  ${YearsChunckLength} + ${YearBegin} ))
+	  ChunckTsYearBegin=$(( ${NbYearsChunckLoop} * ${YearsChunckLength} + ${YearBegin} ))
 	  # Starting date of the current chunck
 	  ChunckTsDateBegin=${ChunckTsYearBegin}${MonthBegin}01
@@ -415,4 +415,130 @@
   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}
+    #
+    DaysTemp=$(( $( IGCM_date_DaysInPreviousPeriod ${PeriodDateEnd} ${config_Post_PackFrequency} end ) - 1 ))
+    #
+    PackDateBegin=$( IGCM_date_AddDaysToGregorianDate ${PeriodDateEnd} -${DaysTemp} )
+    #
+    script=pack_debug
+    #
+    Script_Post_Output=${script}.${PeriodDateEnd}
+    #
+    listVarEnv="DEBUG_debug,MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,POST_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 POST_DIR=${POST_DIR}
+    export MASTER=${MASTER}
+    export DateBegin=${PackDateBegin}
+    export DateEnd=${PeriodDateEnd}
+    export PeriodPack=${config_Post_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
+    #
+    script=pack_restart
+    #
+    Script_Post_Output=${script}.${PeriodDateEnd}
+    #
+    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 DateBegin=${PackDateBegin}
+    export DateEnd=${PeriodDateEnd}
+    export PeriodPack=${config_Post_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
+    #
+    script=pack_output
+    #
+    Script_Post_Output=${script}.${PeriodDateEnd}
+    #
+    if [ ${RebuildFrequency} = true ] ; then
+      #
+      if [ -f ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh ] ; then
+	#
+#	if [ X${MASTER} = Xtitane ] ; then
+#	  echo "IGCM_sys_RshPost <<-EOF"                     >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+#	fi
+	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=${PackDateBegin}              " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+	echo "export DateEnd=${PeriodDateEnd}                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+	echo "export PeriodPack=${config_Post_PackFrequency} " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+	echo "export StandAlone=false                        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+	echo "export listVarEnv=${listVarEnv}                " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+	echo "export Script_Post_Output=${Script_Post_Output}" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+	echo "export script=${script}                        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+#	if [ X${MASTER} = Xtitane ] ; then
+#	  echo ". ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+#	  echo ". ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh"     >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+#	fi
+	echo "IGCM_sys_MkdirWork ${POST_DIR}                 " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+	echo "IGCM_debug_Verif_Exit_Post                     " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+	echo "IGCM_sys_QsubPost ${script}                    " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+#	if [ X${MASTER} = Xtitane ] ; then
+#	  echo "EOF"                                         >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+#	fi
+      fi
+    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 DateBegin=${PackDateBegin}
+    export DateEnd=${PeriodDateEnd}
+    export PeriodPack=${config_Post_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
+    export DateBegin=${SavedDateBegin}
+    export DateEnd=${SavedDateEnd}
+    fi
+  fi
+
   #============== REBUILD POST-PROCESSING =============#
   if [ X${AsynchronousRebuild} = Xtrue ] ; then
@@ -476,72 +602,4 @@
     IGCM_sys_QsubPost ${script}
 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}
-    #
-    DaysTemp=$(( $( IGCM_date_DaysInPreviousPeriod ${PeriodDateEnd} ${config_Post_PackFrequency} end ) - 1 ))
-    #
-    PackDateBegin=$( IGCM_date_AddDaysToGregorianDate ${PeriodDateEnd} -${DaysTemp} )
-    #
-    script=pack_debug
-    #
-    Script_Post_Output=${script}.${PeriodDateEnd}
-    #
-    listVarEnv="DEBUG_debug,MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,POST_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 POST_DIR=${POST_DIR}
-    export MASTER=${MASTER}
-    export DateBegin=${PackDateBegin}
-    export DateEnd=${PeriodDateEnd}
-    export PeriodPack=${config_Post_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
-    #
-    script=pack_restart
-    #
-    Script_Post_Output=${script}.${PeriodDateEnd}
-    #
-    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 DateBegin=${PackDateBegin}
-    export DateEnd=${PeriodDateEnd}
-    export PeriodPack=${config_Post_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
-
-    export DateBegin=${SavedDateBegin}
-    export DateEnd=${SavedDateEnd}
   fi
   IGCM_debug_PopStack "IGCM_post_Submit"
@@ -610,5 +668,5 @@
   *M|*m)
     PeriodMasterMonth=$( echo ${MasterFrequency} | sed -e "s/[mM]//" )
-    case ${SlaveFrequency} in		    
+    case ${SlaveFrequency} in
     *Y|*y)
       PeriodSlaveYear=$( echo ${SlaveFrequency} | sed -e "s/[yY]//" )
