Index: /tags/libIGCM_v2.2/AA_RunChecker
===================================================================
--- /tags/libIGCM_v2.2/AA_RunChecker	(revision 998)
+++ /tags/libIGCM_v2.2/AA_RunChecker	(revision 998)
@@ -0,0 +1,277 @@
+#!/bin/ksh
+
+#**************************************************************
+# Author: Sonia Labetoulle
+# Contact: sonia.labetoulle__at__ipsl.jussieu.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2012)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#======================================================================#
+# Display a report on how a simulation is faring.
+
+
+#======================================================================#
+
+#D- Task type (computing, post-processing or checking)
+TaskType=checking
+typeset -i Verbosity=0
+
+CurrentUsr=$( whoami )
+
+if ( [ $# -eq 0 ] ) ; then
+  $0 -h
+  exit
+fi
+
+# Arguments
+# =========
+# Default argument values
+#Â -----------------------
+TargetUsr=${CurrentUsr}
+HostName=$( hostname | sed -e "s/[0-9].*//" )
+
+fg_color=true
+fg_search=false
+fg_quiet=false
+fg_running=false
+fg_path=false
+NbHisto=20
+
+# Get arguments from command line
+# -------------------------------
+while getopts :hj:p:qsu:r Opt ; do
+  case $Opt in
+    h)
+      echo "usage: $0 [-u user] [-q] [-j n] [-s] job_name [job_name2 ...]"
+      echo "       $0 [-u user] [-q] [-j n] -p config.card_path"
+      echo "       $0 [-u user] [-q] [-j n] -r [job_name job_name2 ...]"
+      echo ""
+      echo "options :"
+      echo "  -h : print this help and exit"
+      echo "  -u : owner of the job"
+      echo "  -q : quiet"
+      echo "  -j : print n post-processing jobs (default is 20)"
+      echo "  -s : search for a new job in \$WORKDIR and fill in "
+      echo "       the catalog before printing information"
+      echo "  -p : give the directory (absolute path) containing "
+      echo "       the config.card instead of the job name."
+      echo "  -r : check all running simulations."
+      exit 0 ;;
+    j)
+      NbHisto=${OPTARG}
+      ;;
+    p)
+      fg_path=true
+      ConfigPath=${OPTARG}
+      ;;
+    q)
+      fg_quiet=true
+      ;;
+    s)
+      fg_search=true
+      ;;
+    u)
+      TargetUsr=${OPTARG}
+      ;;
+    r)
+      fg_running=true
+      ;;
+    :)
+      echo "$0: -"${OPTARG}" option: missing value"
+      exit 1
+      ;;
+    \?)
+      echo "$0: -"${OPTARG}" option: not supported"
+      exit 1
+      ;;
+  esac
+done
+shift $(($OPTIND-1))
+
+# If no config.card path is given, and we're not looking for running simulations, 
+# at least one JobName must be given.
+if ( ( ! ${fg_path} ) && ( ! ${fg_running} ) && [ $# -lt 1 ] ) ; then
+  $0 -h
+  exit
+fi
+
+if ( ( ${fg_path} ) && ( ${fg_search} ) ) ; then
+  echo "You cannot use -s and -p at the same time"
+  exit
+fi
+
+if ( ( ${fg_path} ) && ( ${fg_running} ) ) ; then
+  echo "You cannot use -r and -p at the same time"
+  exit
+fi
+
+
+# Load libIGCM library
+# ====================
+libIGCM=${libIGCM:=::modipsl::/libIGCM}
+
+DEBUG_debug=false
+DEBUG_sys=false
+
+. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
+. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
+. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
+#-------
+. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
+. ${libIGCM}/libIGCM_check/libIGCM_check.ksh
+. ${libIGCM}/libIGCM_config/libIGCM_config.ksh
+#-------
+( ${DEBUG_debug} ) && IGCM_debug_Check
+( ${DEBUG_debug} ) && IGCM_card_Check
+( ${DEBUG_debug} ) && IGCM_date_Check
+
+
+if ( ${fg_running} ) ; then
+  # Look for running simu
+  IGCM_sys_ListJobInQueue ${TargetUsr} JobNameList
+fi
+
+if [ $# -ge 1 ] ; then
+  set -A JobNameList ${JobNameList[*]} ${*}
+elif ( ${fg_path} ) ; then
+  set -A JobNameList "Unknown"
+fi
+
+if [ ${#JobNameList[*]} -lt 1 ] ; then
+  echo "No running simulation found."
+  exit 0
+fi
+
+
+if ( ${fg_quiet} ) ; then
+  NbHisto=1
+fi
+
+# Define the catalog in which the known simulations are stored
+# ============================================================
+SimuCatalog="${HOME}/.simucatalog.dat"
+if [ ! -s ${SimuCatalog} ] ; then
+  touch ${SimuCatalog}
+fi
+
+
+for JobName in ${JobNameList[*]} ; do
+
+  # Find SUBMIT_DIR in catalog
+  # ==========================
+  IGCM_check_SearchCatalog
+  Status=$?
+
+  if [ $Status -eq 0 ] ; then
+
+    IGCM_sys_Cd $SUBMIT_DIR
+
+
+    # Extract usefull information from run.card and config.card
+    # =========================================================
+
+    RunFile="${SUBMIT_DIR}/run.card"
+    ConfFile="${SUBMIT_DIR}/config.card"
+
+    IGCM_config_CommonConfiguration ${SUBMIT_DIR}/config.card
+    IGCM_check_CommonDef
+
+
+    if [ -s ${RunFile} ] ; then
+      IGCM_card_DefineVariableFromOption ${RunFile} Configuration PeriodState
+      PeriodState=${run_Configuration_PeriodState}
+    else
+      PeriodState="Waiting"
+    fi
+
+    JobID="."
+    if ( [ X${PeriodState} == XRunning ] || [ X${PeriodState} == XOnQueue ] ) ; then
+      IGCM_sys_GetJobID ${JobName} ${TargetUsr} JobID
+
+      if [ "${JobID}" == "." ] || [ "${JobID}" == "" ] ; then
+        PeriodState="Fatal"
+        JobID="."
+      fi
+    fi
+
+    DateBegin=${config_UserChoices_DateBegin}
+    DateEnd=${config_UserChoices_DateEnd}
+    TagName=${config_UserChoices_TagName}
+    ExperimentName=${config_UserChoices_ExperimentName}
+    SpaceName=${config_UserChoices_SpaceName}
+
+
+    if ( [ ! X${PeriodState} == XWaiting ] && [ ! X${PeriodState} == XCompleted ] ) ; then
+      IGCM_card_DefineVariableFromOption ${RunFile} Configuration PeriodDateBegin
+      IGCM_card_DefineVariableFromOption ${RunFile} Configuration PeriodDateEnd
+      IGCM_card_DefineVariableFromOption ${RunFile} Configuration CumulPeriod
+      PeriodDateBegin=${run_Configuration_PeriodDateBegin}
+      PeriodDateEnd=${run_Configuration_PeriodDateEnd}
+      CumulPeriod=${run_Configuration_CumulPeriod}
+    else
+      PeriodDateBegin="."
+      PeriodDateEnd="."
+      CumulPeriod="."
+    fi
+
+    DATA_DIR=${R_SAVE}
+    POST_DIR=${R_BUFR}/Out
+    CWORK_DIR=${R_FIGR}
+
+    if [ ${TargetUsr} != ${CurrentUsr} ] ; then
+      DATA_DIR=$( IGCM_check_ChangeUsr ${DATA_DIR} )
+      POST_DIR=$( IGCM_check_ChangeUsr ${POST_DIR} )
+      CWORK_DIR=$( IGCM_check_ChangeUsr ${CWORK_DIR} )
+      REBUILD_DIR=$( IGCM_check_ChangeUsr ${REBUILD_DIR} )
+    fi
+
+    if [ $PeriodState != "Waiting" ] ; then
+      # Check pending REBUILDS
+      # ======================
+      IGCM_check_CheckPendingRebuild
+
+      # Check last REBUILD and PACK* jobs
+      # =================================
+      IGCM_check_CheckRebPackJobs
+
+      # Check last MONITORING jobs
+      # ==========================
+      IGCM_check_CheckMonitoring
+
+      # Check last ATLAS jobs
+      # =====================
+      IGCM_check_CheckAtlas
+
+      # Time of last write on run.card
+      # ==============================
+      IGCM_sys_GetDate_FichWork ${SUBMIT_DIR}/run.card LastWrite "SplitFields" "${DateFormat}"
+
+    else
+
+      NbRebuild="."
+      FirstRebuild="."
+      LastRebuild="."
+
+      NbLines=0
+
+    fi
+
+
+    # Print results
+    # =============
+    IGCM_check_PrintHeader
+    ind=0
+    while [ $ind -lt $NbLines ] ; do
+      IGCM_check_PrintJob
+      (( ind = ind + 1 ))
+    done
+    IGCM_check_PrintFooter
+
+  fi
+
+done
Index: /tags/libIGCM_v2.2/AA_SE_Checker
===================================================================
--- /tags/libIGCM_v2.2/AA_SE_Checker	(revision 998)
+++ /tags/libIGCM_v2.2/AA_SE_Checker	(revision 998)
@@ -0,0 +1,227 @@
+#!/bin/ksh
+
+#**************************************************************
+# Author: Sebastien Denvil
+# Contact: Sebastien.Denvil__at__ipsl.jussieu.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#D- Task type (computing or post-processing)
+TaskType=post-processing
+
+# Check that everything went well during seasonal average production
+# Display a short report
+# Launch what's missing
+# For use during a run (not on the end : PeriodState=Completed), it will complete
+# all TS to last PeriodDateEnd value, give by run.card->Configuration->OldPrefix string.
+
+#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}
+
+# Expericence class of the run
+ExperimentName=${ExperimentName:=historical}
+
+# Name of this job
+JobName=${JobName:=v2.historical1}
+
+# rÃ©pertoire courrant
+CURRENT_DIR=$( pwd )
+
+# Emplacement des cartes
+CARD_DIR=${CARD_DIR:=${CURRENT_DIR}/${ExperimentName}/${JobName}}
+
+# rÃ©pertoire de stockage des sorties des create_ts
+POST_DIR=${POST_DIR:=${CARD_DIR}/OutScript}
+
+if [ ! -d ${CARD_DIR} ]; then
+  echo "No ${CARD_DIR}, we stop here"
+  exit
+fi
+
+########################################################################
+
+. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
+. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
+. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
+#-------
+. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
+. ${libIGCM}/libIGCM_config/libIGCM_config.ksh
+#-------
+( ${DEBUG_debug} ) && IGCM_debug_Check
+( ${DEBUG_debug} ) && IGCM_card_Check
+( ${DEBUG_debug} ) && IGCM_date_Check
+
+########################################################################
+
+#set -vx
+
+#==================================
+# First of all
+#
+# Read libIGCM compatibility version in config.card
+# Read UserChoices section
+# Read Ensemble section
+# Read Post section
+# Define all netcdf output directories
+#==================================
+IGCM_config_CommonConfiguration ${CARD_DIR}/config.card
+
+#==================================
+# Read ListOfComponents section:
+IGCM_card_DefineArrayFromSection ${CARD_DIR}/config.card ListOfComponents
+
+#==================================
+# Read SeasonalFrequency:
+IGCM_card_DefineVariableFromOption ${CARD_DIR}/config.card Post SeasonalFrequency
+
+#
+DateBegin=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateBegin} )
+DateEnd=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} )
+
+#
+if ( [ X${config_Post_SeasonalFrequencyOffset} = X${NULL_STR} ] || [ X${config_Post_SeasonalFrequencyOffset} = XNONE ] || [ X${config_Post_SeasonalFrequencyOffset} = X ] ) ; then
+  PeriodOffset=0
+else
+  PeriodOffset=${config_Post_SeasonalFrequencyOffset}
+fi
+
+IGCM_debug_Print 1 "DateBegin for SE_Checker : "${DateBegin}
+IGCM_debug_Print 1 "DateEnd   for SE_Checker : "${DateEnd}
+IGCM_debug_Print 1 "Offset    for SE_Checker : "${PeriodOffset}
+echo
+#
+[ X${config_Post_SeasonalFrequency} = X"NONE" ] && exit
+
+freq=$( echo ${config_Post_SeasonalFrequency} |  sed -e "s/[yY]//" )
+
+an_deb=$( IGCM_date_YearDigit $(( DateBegin / 10000 + PeriodOffset )) )
+an_fin=$( IGCM_date_YearDigit $(( an_deb + freq - 1 )) )
+an_fin_all=$( IGCM_date_YearDigit $(( DateEnd / 10000 )) )
+
+#
+while [ ${an_fin} -le ${an_fin_all} ] ; do
+
+  countTotal=0
+  countGood=0
+  countBad=0
+
+  IGCM_debug_Print 1 " DateBegin/End for SE :  ${an_deb}_${an_fin} "
+
+  for comp in ${config_ListOfComponents[*]} ; do
+    localcountBad=0
+    # Debug Print
+    IGCM_debug_Print 1 ${comp}
+    # Define component
+    IGCM_card_DefineArrayFromOption ${CARD_DIR}/config.card ListOfComponents ${comp}
+    eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1
+
+    # Read libIGCM compatibility version in ${compname}.card
+    card=${CARD_DIR}/COMP/${compname}.card
+
+    # 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
+      #
+      # INITIALISATION
+      #
+      eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1
+      typeset i=2
+      #
+      until [ $i -gt $NbFiles ]; do
+        #
+        eval flag_post=\${${ListFilesName}[$i]} > /dev/null 2>&1
+        #
+        if [ X${flag_post} != XNONE ] ; then
+          #
+          # Check if seasonal is required for this file
+          #
+          IGCM_card_DefineArrayFromSection ${card} ${flag_post}
+          #
+          # Seasonal case : If option Seasonal is not found (old cards) put SEASONAL ON by default
+          #
+          # variable option allready typeset above
+          for option in $( eval echo \${${compname}_${flag_post}[*]} ) ; do
+            if [ ${option} = Seasonal ] ; then
+              FoundSeasonal=true
+              IGCM_card_DefineVariableFromOption ${card} ${flag_post} Seasonal
+            fi
+          done
+          #
+          if [ ! X${FoundSeasonal} = Xtrue ] ; then
+            eval ${compname}_${flag_post}_Seasonal=ON
+          fi
+          #
+          if [ ! X$( eval echo \${${compname}_${flag_post}_Seasonal} ) = XON ] ; then
+            (( i=i+3 ))
+            continue
+          fi
+          #
+          # CREATE LIST
+          #
+          FILE=$( echo ${flag_post} | awk "-FPost_" '{print $2}' )
+          #
+          DIRECTORY=${R_SAVE}/${comp}/Analyse/SE
+          #
+          TestedFile=${config_UserChoices_JobName}_SE_${an_deb}_${an_fin}_${FILE}.nc
+          #
+          (( countTotal = countTotal + 1 ))
+          IGCM_sys_TestFileArchive ${DIRECTORY}/${TestedFile} >/dev/null 2>&1
+          if [ ! $? = 0 ] ; then
+            eval set +A LISTE_FILE_${comp}_${an_deb} \$\{LISTE_FILE_${comp}_${an_deb}[*]} ${TestedFile}
+            (( countBad = countBad + 1 ))
+            (( localcountBad = localcountBad + 1 ))
+          else
+            (( countGood = countGood + 1 ))
+          fi
+        fi
+        (( i=i+3 )) # to explore file list
+      done            # until [ $i -eq $NbFiles ]
+    fi                  # [ X${FileName0} != X${NULL_STR} ]
+
+    [ $localcountBad = 0 ] || IGCM_debug_Print 1 "$localcountBad file(s) missing for ${comp} : " $( eval echo \${LISTE_FILE_${comp}_${an_deb}[*]} )
+  done
+
+  # create_se submit if files don't exist
+  if [ $countGood != $countTotal ] ; then
+    IGCM_debug_Print 2 -e "\033[1;31mSubmit create_se \033[m for period ${an_deb}-${an_fin}"
+
+    listVarEnv="libIGCM,SUBMIT_DIR,POST_DIR,DateBegin,PeriodDateEnd,RebuildFrequency,RESOL_ATM,RESOL_SRF,RESOL_SBG,RESOL_OCE,RESOL_ICE,RESOL_MBG"
+    export libIGCM=${libIGCM}
+    export SUBMIT_DIR=${CARD_DIR}
+    export POST_DIR=${POST_DIR}
+    export DateBegin=${an_deb}
+    export PeriodDateEnd=${an_fin}1231
+    export RebuildFrequency=${RebuildFrequency}
+    export RESOL_ATM=${RESOL_ATM}
+    export RESOL_SRF=${RESOL_SRF}
+    export RESOL_SBG=${RESOL_SBG}
+    export RESOL_OCE=${RESOL_OCE}
+    export RESOL_ICE=${RESOL_ICE}
+    export RESOL_MBG=${RESOL_MBG}
+    export listVarEnv=${listVarEnv}
+    IGCM_sys_MkdirWork ${POST_DIR}
+    IGCM_debug_Verif_Exit_Post
+    Script_Post_Output=create_se.${PeriodDateEnd}
+    IGCM_sys_QsubPost create_se
+
+    echo
+  fi
+
+  (( an_deb = an_deb + freq ))
+  (( an_fin = an_fin + freq ))
+
+done # while
Index: /tags/libIGCM_v2.2/AA_SaveSourceModifications
===================================================================
--- /tags/libIGCM_v2.2/AA_SaveSourceModifications	(revision 998)
+++ /tags/libIGCM_v2.2/AA_SaveSourceModifications	(revision 998)
@@ -0,0 +1,130 @@
+#-Q- curie ######################
+#-Q- curie ## CURIE   TGCC/CEA ##
+#-Q- curie ######################
+#-Q- curie #MSUB -r SaveSource   # Nom du job
+#-Q- curie #MSUB -eo
+#-Q- curie #MSUB -n 1            # Reservation du processus
+#-Q- curie #MSUB -T 7200         # Limite de temps elapsed du job
+#-Q- curie #MSUB -q xlarge
+#-Q- curie #MSUB -Q normal
+#-Q- curie #MSUB -A ::default_project::
+#-Q- curie set +x
+#-Q- ada #!/bin/ksh
+#-Q- ada #######################
+#-Q- ada # #  ADA       IDRIS ##
+#-Q- ada #######################
+#-Q- ada # @ job_type = serial
+#-Q- ada # @ requirements = (Feature == "prepost")
+#-Q- ada # Temps Elapsed max. d'une requete hh:mm:ss
+#-Q- ada # @ wall_clock_limit = 1:00:00
+#-Q- ada # Nom du travail LoadLeveler
+#-Q- ada # @ job_name   = SaveSource
+#-Q- ada # Fichier de sortie standard du travail
+#-Q- ada # @ output     = $(job_name).$(jobid)
+#-Q- ada # Fichier de sortie d'erreur du travail
+#-Q- ada # @ error      =  $(job_name).$(jobid)
+#-Q- ada # pour recevoir un mail en cas de depassement du temps Elapsed (ou autre pb.)
+#-Q- ada # @ notification = error
+#-Q- ada # @ environment  = $POST_DIR ; $SUBMIT_DIR ; $libIGCM ; $StandAlone ; $MASTER
+#-Q- ada # @ queue
+#-Q- lxiv8 ######################
+#-Q- lxiv8 ## OBELIX      LSCE ##
+#-Q- lxiv8 ######################
+#-Q- lxiv8 #PBS -N SaveSource
+#-Q- lxiv8 #PBS -m a
+#-Q- lxiv8 #PBS -j oe
+#-Q- lxiv8 #PBS -q test
+#-Q- lxiv8 #PBS -o SaveSource.$$
+#-Q- lxiv8 #PBS -S /bin/ksh
+#-Q- default #!/bin/ksh
+#-Q- default ##################
+#-Q- default ## DEFAULT HOST ##
+#-Q- default ##################
+
+#**************************************************************
+# Author: Martial Mancip
+# Contact: Martial.Mancip__at__ipsl.jussieu.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#set -eu
+#set -vx
+
+date
+
+#-Q- ada export OMP_NUM_THREADS=1
+
+#D- Task type (computing or post-processing)
+TaskType=post-processing
+
+MODIPSL=::modipsl::
+
+#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}
+
+. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
+#-------
+. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
+. ${libIGCM}/libIGCM_config/libIGCM_config.ksh
+#-------
+( ${DEBUG_debug} ) && IGCM_debug_Check
+
+IGCM_sys_MkdirWork ${RUN_DIR_PATH}
+IGCM_sys_Cd ${RUN_DIR_PATH}
+
+ExeOutDateMax=${ExeOutDateMax:=$1}
+R_OUT_EXE=${R_OUT_EXE:=$2}
+PREFIX=${PREFIX:=$3}
+SUBMIT_DIR=${SUBMIT_DIR:=$4}
+
+cd ${MODIPSL};
+${MODIPSL}/util/script_diff_model ${SUBMIT_DIR} > ${RUN_DIR_PATH}/out_script_diff_model 2>&1
+echo "script_diff_model return" $? >> ${RUN_DIR_PATH}/out_script_diff_model 2>&1
+cd ${RUN_DIR_PATH}
+
+ERR_script_diff_model=$( cat out_script_diff_model | grep "script_diff_model return [0-9]*" | sed -e "s&script_diff_model return *\([0-9]*\)&\1&" )
+
+if [ ! X${ERR_script_diff_model} = X0 ] ; then
+    echo 'Error in script_diff_model :' ${ERR_script_diff_model}
+    exit ${ERR_script_diff_model}
+fi
+
+MODIPSL_SAVE_NAME=$( cat out_script_diff_model | grep "SAVE directory in" | sed -e "s&SAVE directory in  &&" )
+MODIPSL_SAVE=${MODIPSL}/tmp/${MODIPSL_SAVE_NAME}
+if ( [ X${MODIPSL_SAVE_NAME} = X ] || [ ! -d ${MODIPSL_SAVE} ] ) ; then
+    echo 'Error in SaveSourceModifications: no MODIPSL_SAVE_NAME avaible. We STOP'
+    exit 1
+fi
+
+MaxModifiedDate=$( tail -1 ${MODIPSL_SAVE}/Last_log )
+
+cd ${MODIPSL}/tmp
+IGCM_sys_Tar ${RUN_DIR_PATH}/${MODIPSL_SAVE_NAME}.tar ${MODIPSL_SAVE_NAME}
+cd -
+if ( ! ${DEBUG_debug} ) ; then
+    IGCM_sys_Rm -rf ${MODIPSL_SAVE}
+fi
+
+if [ ${MaxModifiedDate} -lt ${ExeOutDateMax} ] ; then
+    IGCM_sys_Put_Out ${MODIPSL_SAVE_NAME}.tar ${R_OUT_EXE}/${PREFIX}_${MODIPSL_SAVE_NAME}_certified.tar
+else
+    IGCM_sys_Put_Out ${MODIPSL_SAVE_NAME}.tar ${R_OUT_EXE}/${PREFIX}_${MODIPSL_SAVE_NAME}_NOTcertified.tar
+fi
+if ( ! ${DEBUG_debug} ) ; then
+    IGCM_sys_Rm ${MODIPSL_SAVE_NAME}.tar
+fi
+
+# Clean RUN_DIR_PATH (necessary for cesium and titane only)
+if ( ! ${DEBUG_debug} ) ; then
+    IGCM_sys_RmRunDir -Rf ${RUN_DIR_PATH}
+fi
Index: /tags/libIGCM_v2.2/AA_TimeSeries_Checker
===================================================================
--- /tags/libIGCM_v2.2/AA_TimeSeries_Checker	(revision 998)
+++ /tags/libIGCM_v2.2/AA_TimeSeries_Checker	(revision 998)
@@ -0,0 +1,502 @@
+#!/bin/ksh
+
+#**************************************************************
+# Author: Sebastien Denvil
+# Contact: Sebastien.Denvil__at__ipsl.jussieu.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#D- Task type (computing or post-processing)
+TaskType=post-processing
+
+# Check that everything went well during time series production
+# Display a short report
+# Launch what's missing
+# For use during a run (not on the end : PeriodState=Completed), it will complete
+# all TS to last PeriodDateEnd value, give by run.card->Configuration->OldPrefix string.
+
+#D- Path to libIGCM
+#D- Default : value from AA_job if any
+libIGCM=${libIGCM:=::modipsl::/libIGCM}
+
+# Expericence class of the run
+ExperimentName=${ExperimentName:=historical}
+
+# Name of this job
+JobName=${JobName:=v2.historical1}
+
+# rÃ©pertoire courrant
+CURRENT_DIR=$( pwd )
+
+# Emplacement des cartes
+CARD_DIR=${CARD_DIR:=${CURRENT_DIR}/${ExperimentName}/${JobName}}
+
+# rÃ©pertoire de stockage des sorties des create_ts
+POST_DIR=${POST_DIR:=${CARD_DIR}/OutScript}
+
+if [ ! -d ${CARD_DIR} ]; then
+  echo "No ${CARD_DIR}, we stop here"
+  exit
+fi
+
+########################################################################
+
+. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
+. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
+. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
+#-------
+. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
+. ${libIGCM}/libIGCM_config/libIGCM_config.ksh
+#-------
+( ${DEBUG_debug} ) && IGCM_debug_Check
+( ${DEBUG_debug} ) && IGCM_card_Check
+( ${DEBUG_debug} ) && IGCM_date_Check
+
+########################################################################
+
+#set -vx
+
+echo "Hi I'm here to help you complete the time series production you planned according to your *.card."
+echo "This action can potentially submit numbers of jobs (up to 50)"
+echo "This action can potentially remove unnecessary files but I will ALWAYS ask permission to do so"
+echo -e "\033[1;31mDo you want me to run in dryrun mode just telling what I would submit?\033[m"
+echo -e "\033[1;31mOr do you want me to submit job for real? Answer yes in this case.\033[m"
+echo -n " Run for real (y/n) :"
+read ActionAnswer
+
+case ${ActionAnswer} in
+oui|OUI|o|y|yes|YES)
+  echo "OK. I will submit jobs but ask permissions before removing files"
+  action=true
+  ;;
+non|NON|n|no|NO)
+  echo "OK. I won't submit jobs and only print out files I could remove"
+  action=false
+  ;;
+*)
+  echo "I did not recognize your answer. I will stop here."
+  echo "Please respond: oui|OUI|o|y|yes|YES"
+  echo "Or please respond: non|NON|n|no|NO"
+  exit
+  ;;
+esac
+
+#==================================
+# First of all
+#
+# Read libIGCM compatibility version in config.card
+# Read UserChoices section
+# Read Ensemble section
+# Read Post section
+# Define all netcdf output directories
+#==================================
+IGCM_config_CommonConfiguration ${CARD_DIR}/config.card
+
+#==================================
+# Read ListOfComponents section:
+IGCM_card_DefineArrayFromSection ${CARD_DIR}/config.card ListOfComponents
+
+if [ -f ${CARD_DIR}/run.card ] ; then
+  IGCM_card_DefineVariableFromOption ${CARD_DIR}/run.card Configuration OldPrefix
+  IGCM_card_DefineVariableFromOption ${CARD_DIR}/run.card Configuration PeriodState
+  IGCM_card_DefineVariableFromOption ${CARD_DIR}/run.card PostProcessing TimeSeriesCompleted
+  IGCM_debug_Print 1 "DefineVariableFromOption  : run_Configuration"
+  IGCM_debug_PrintVariables 3 run_Configuration_OldPrefix
+  IGCM_debug_PrintVariables 3 run_Configuration_PeriodState
+  IGCM_debug_Print 1 "DefineVariableFromOption  : run_PostProcessing"
+  IGCM_debug_PrintVariables 3 run_PostProcessing_TimeSeriesCompleted
+  if [ X${run_Configuration_PeriodState} != X"Completed" ] ; then
+    DateEnd=$( IGCM_date_ConvertFormatToGregorian $( echo ${run_Configuration_OldPrefix} | awk -F'_' '{print $2}' ) )
+  else
+    DateEnd=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} )
+  fi
+  CompletedFlag=${run_PostProcessing_TimeSeriesCompleted}
+else
+  DateEnd=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} )
+  CompletedFlag=""
+fi
+SavedCompletedFlag=${CompletedFlag}
+DateBegin=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateBegin} )
+
+IGCM_date_GetYearMonth ${DateBegin} YearBegin MonthBegin
+IGCM_date_GetYearMonth ${DateEnd}   YearEnd   MonthEnd
+
+echo
+IGCM_debug_Print 1 "DateBegin for TimeSeries_Checker : "${DateBegin}
+IGCM_debug_Print 1 "DateEnd   for TimeSeries_Checker : "${DateEnd}
+IGCM_debug_Print 1 "CompletedFlag = "${CompletedFlag}
+echo
+
+for comp in ${config_ListOfComponents[*]} ; do
+  # Debug Print
+  IGCM_debug_Print 1 ${comp}
+  # Define component
+  IGCM_card_DefineArrayFromOption ${CARD_DIR}/config.card ListOfComponents ${comp}
+  eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1
+  eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1
+
+  # Read libIGCM compatibility version in ${compname}.card
+  card=${CARD_DIR}/COMP/${compname}.card
+
+  # 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
+    i=2
+    #
+    until [ $i -ge $NbFiles ]; do
+      #
+      eval flag_post=\${${ListFilesName}[$i]} > /dev/null 2>&1
+      #
+      if [ X${flag_post} != XNONE ] ; then
+        #
+        # First of all
+        #
+        IGCM_card_DefineArrayFromSection ${card} ${flag_post}
+        #
+        IGCM_card_DefineArrayFromOption ${card} ${flag_post} TimeSeriesVars
+        IGCM_card_DefineArrayFromOption ${card} ${flag_post} Patches
+        if [ X"$( eval echo \${${compname}_${flag_post}_TimeSeriesVars[*]} )" = X"Option not" ] ; then
+          # New TimeSeriesVar description, with 2D, 3D and associate ChunckJob.
+          unset ListDimension
+          ListDimension[0]=2D
+          ListDimension[1]=3D
+          TimeSeries=false
+          TimeSeries2D=false
+          TimeSeries3D=false
+          chunck=false
+          iLoop=${#ListDimension[*]}
+          j=0
+          until [ $j -ge ${iLoop} ]; do
+            Dimension=${ListDimension[${j}]}
+            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 2 "${Dimension} time series activated for ${flag_post}"
+                eval TimeSeries${Dimension}=true
+                chunck=false
+              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 ] &&  [ ! ${chunck_size} = OFF ] ; then
+                IGCM_debug_Print 2 "${Dimension} time series activated with ${chunck_size} chunck for ${flag_post}"
+                eval TimeSeriesChunck${Dimension}=true
+                chunck=true
+              fi
+            fi
+            (( j=j+1 ))
+            #
+            # If TimeSeriesVars list is empty or OFF we skip
+            #
+            if ( [ $( eval echo \${${compname}_${flag_post}_TimeSeriesVars${Dimension}} ) = ${NULL_STR} ] || \
+              [ ${chunck_size} = OFF ] ) ; then
+              #IGCM_debug_Print 2 "Empty TS : ${compname}_Post_${FILE}_TimeSeriesVars${Dimension}"
+              #(( i=i+3 ))
+              continue
+            fi
+            #
+            #  ICI ON TESTE QUE LES FICHIERS TS SONT LA!
+            #
+            FILE=$( echo ${flag_post} | awk "-FPost_" '{print $2}' )
+            IGCM_card_DefineArrayFromOption ${card}    Post_${FILE} TimeSeriesVars${Dimension}
+            IGCM_card_DefineVariableFromOption ${card} Post_${FILE} ChunckJob${Dimension}
+            #
+            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  ;;
+            3H|HF)  TS_Dir=TS_HF  ;;
+            INS) TS_Dir=TS_INS ;;
+            esac
+            #
+            # We need LIST of variables not allready produced (useful for standalone mode)
+            #
+            DateBegin=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateBegin} )
+            IGCM_date_GetYearMonth ${DateBegin} YearBegin MonthBegin
+
+            # Si on n'a pas de chunck, dans ce cas chunck_size=la durÃ©e de la simulation en annÃ©es
+            YearsChunckLength=$( echo ${chunck_size} | sed -e "s/[yY]//" )
+            [ ${chunck} = false ] && YearsChunckLength=$(( YearEnd - YearBegin + 1 ))
+
+            NbYearsChunckLoop=$(( ( YearEnd - YearBegin + 1 ) / YearsChunckLength ))
+            Reste=$(( ( YearEnd - YearBegin + 1 ) % YearsChunckLength ))
+
+            if [ ${Reste} -ne 0 ] ; then
+              NbYearsChunckLoop=$(( NbYearsChunckLoop + 1 ))
+            fi
+
+            if [ ${NbYearsChunckLoop} -eq 1 ] ; then
+              PeriodDateEnd=${DateEnd}
+            else
+              Length=$( IGCM_date_DaysInCurrentPeriod ${DateBegin} ${YearsChunckLength}Y )
+              PeriodDateEnd=$( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${Length}-1 )
+            fi
+            #
+            DIRECTORY=${R_SAVE}/${comp}/Analyse/${TS_Dir}
+            YearsChunckLoop=1
+            ChunckDebut=${DateBegin}
+            ChunckFin=${PeriodDateEnd}
+            while [ ${YearsChunckLoop} -le ${NbYearsChunckLoop} ] ; do
+              countTotal=0
+              countGood=0
+              countBad=0
+              unset RemoveList
+              unset PotentialCompletedFlag
+              for var in $( eval echo \${${compname}_Post_${FILE}_TimeSeriesVars${Dimension}[*]} ) ; do
+                TestedFile=${config_UserChoices_JobName}_${ChunckDebut}_${ChunckFin}_${FlagDir}_${var}.nc
+                #
+                DEBUG_sys=false IGCM_sys_TestDirArchive ${DIRECTORY}
+                if [ $? = 0 ] ; then
+                  Candidat=$( IGCM_sys_RshArchive "find ${DIRECTORY} -name "${config_UserChoices_JobName}_${ChunckDebut}_*_${FlagDir}_${var}.nc"" )
+                else
+                  Candidat=""
+                fi
+                #
+                BestCandidat=${ChunckDebut}
+                #
+                FoundCandidat=false
+                if [ ! "X${Candidat}" = "X" ] ; then
+                  for candid in ${Candidat} ; do
+                    #IGCM_debug_Print 1 -e "\033[1;32m[CompletedFlag CANDIDAT MATCH FOUND]\033[m $( basename ${candid} )"
+                    CandidatEnd=$( echo ${candid}   | awk -F${config_UserChoices_JobName} '{print $3}' | awk -F_ '{print $3}' )
+                    if [ ${CandidatEnd} -gt ${ChunckFin} ] ; then
+                      #IGCM_debug_Print 3 -e "File $( basename ${candid} ) should be suppress"
+                      set +A RemoveList ${RemoveList[*]} ${candid}
+                    elif [ ${CandidatEnd} -lt ${ChunckFin} ] ; then
+                      #IGCM_debug_Print 3 -e "File $( basename ${candid} ) should be suppress or used as a CompletedFlag baseline"
+                      # We keep the best candidat and remove the others
+                      if [ ${BestCandidat} -lt ${CandidatEnd} ] ; then
+                        if [ ${FoundCandidat} = true ] ; then
+                          set +A RemoveList ${RemoveList[*]} ${DIRECTORY}/${config_UserChoices_JobName}_${ChunckDebut}_${BestCandidat}_${FlagDir}_${var}.nc
+                        else
+                          FoundCandidat=true
+                        fi
+                        BestCandidat=${CandidatEnd}
+                      else
+                        set +A RemoveList ${RemoveList[*]} ${candid}
+                      fi
+                    fi
+                  done
+                else
+                  # No CompletedFlag candidat found
+                  CandidatCompletedFlag=""
+                fi
+                #
+                if [ ! -f ${DIRECTORY}/${TestedFile} ] ; then
+                  (( countBad = countBad + 1 ))
+                  [ ${countBad} = 1 ] && IGCM_debug_Print 3 "Missing time series from ${FILE} :"
+                  IGCM_debug_Print 3 ${DIRECTORY}/${TestedFile}
+                  # Then we keep a track of the Best Candidat
+                  if [ ${FoundCandidat} = true ] ; then
+                    if [ ${chunck} = true ] ; then
+                      set +A PotentialCompletedFlag ${PotentialCompletedFlag[*]} ${BestCandidat}
+                    else
+                      eval set +A PotentialCompletedFlag${Dimension} \${PotentialCompletedFlag${Dimension}[*]} \${BestCandidat}
+                    fi
+                  fi
+                else
+                  (( countGood = countGood + 1 ))
+                  # Then we do not need the best candidat if any
+                  [ ${FoundCandidat} = true ] && set +A RemoveList ${RemoveList[*]} ${DIRECTORY}/${config_UserChoices_JobName}_${ChunckDebut}_${BestCandidat}_${FlagDir}_${var}.nc
+                fi
+                (( countTotal = countTotal + 1 ))
+              done
+
+              SuccessRate=$(( countGood * 100 / countTotal ))
+              if [ ${SuccessRate} -ne 100 ] ; then
+                IGCM_debug_Print 2 -e "\033[1;31m${SuccessRate}% files OK.\033[m for period ${ChunckDebut}-${ChunckFin}"
+              else
+                IGCM_debug_Print 2 -e "\033[1;32m${SuccessRate}% files OK.\033[m for period ${ChunckDebut}-${ChunckFin}"
+              fi
+              echo
+
+              # Remove what's in the RemoveList
+              if [ ${RemoveList} ] ; then
+                IGCM_debug_Print 2 "File(s) that will be removed ${RemoveList[*]}"
+                if [ ${action} = true ] ; then
+                  echo -e "\033[1;32mDo you want to remove them?\033[m"
+                  echo -n " Your answer (y/n) : "
+                  read RemoveAnswer
+                  case ${RemoveAnswer} in
+                  oui|OUI|o|y|yes|YES)
+                    echo "OK. I will erase them"
+                    IGCM_sys_Rm -f ${RemoveList[*]}
+                    ;;
+                  non|NON|n|no|NO)
+                    echo "OK. I won't erase them"
+                    ;;
+                  *)
+                    echo "I did not recognize your answer."
+                    echo "Please respond: oui|OUI|o|y|yes|YES"
+                    echo "Or please respond: non|NON|n|no|NO"
+                    exit
+                    ;;
+                  esac
+                fi
+              fi
+              #[ ${FoundCandidat} = true ] && IGCM_debug_Print 2 "Potentials CompletedFlag: ${PotentialCompletedFlag[*]}"
+              #
+              # TO REWRITE BEGIN
+              #
+              if ( [ ${chunck} = true ] && [ ${SuccessRate} -ne 100 ] ) ; then
+                NbCandidats=${#PotentialCompletedFlag[@]}
+                countCandid=1
+                if [ ${NbCandidats} -eq 0 ] ; then
+                  ChunckCompletedFlag=""
+                  IGCM_debug_Print 2 -e "\033[1;31mNO CompletedFlag\033[m"
+                elif [ ${NbCandidats} -eq 1 ] ; then
+                  ChunckCompletedFlag=${PotentialCompletedFlag[0]}
+                  IGCM_debug_Print 2 -e "\033[1;32mCompletedFlag=${ChunckCompletedFlag}\033[m"
+                elif [ ${NbCandidats} -gt 1 ] ; then
+                  k=1
+                  until [ $k -ge ${NbCandidats} ]; do
+                    ((k_m1=k-1))
+                    if [ ${PotentialCompletedFlag[${k_m1}]} = ${PotentialCompletedFlag[${k}]} ] ; then
+                      ((countCandid=countCandid+1))
+                    fi
+                    ((k=k+1))
+                  done
+                  if [ ${NbCandidats} -eq ${countCandid} ] ; then
+                    ChunckCompletedFlag=${PotentialCompletedFlag[0]}
+                    IGCM_debug_Print 2 -e "\033[1;32mCompletedFlag=${ChunckCompletedFlag}\033[m"
+                  else
+                    ChunckCompletedFlag=${PotentialCompletedFlag[0]}
+                    IGCM_debug_Print 2 -e "\033[1;31mToo Many Potential CompletedFlag\033[m Let start with first CompletedPeriod"
+                    IGCM_debug_Print 2 -e "\033[1;31mYou will have to redo TimeSeries_Checker\033[m for other period."
+                  fi
+                fi
+                #
+                # TO REWRITE END
+                #
+                if [ ${action} = true ] ; then
+                  IGCM_debug_Print 2 -e "\033[1;31mSubmit ${FILE} chunck ${Dimension}\033[m period ${ChunckDebut}-${ChunckFin} and CompletedFlag=${ChunckCompletedFlag}"
+                  listVarEnv="libIGCM,SUBMIT_DIR,POST_DIR,DateBegin,PeriodDateEnd,CompletedFlag,TsTask,CompToRead,FlagToRead"
+                  export libIGCM=${libIGCM}
+                  export SUBMIT_DIR=${CARD_DIR}
+                  export POST_DIR=${POST_DIR}
+                  export DateBegin=${ChunckDebut}
+                  export PeriodDateEnd=${ChunckFin}
+                  export CompletedFlag=${ChunckCompletedFlag}
+                  export TsTask=Chunck${Dimension}
+                  export CompToRead=${comp}
+                  export FlagToRead=${i}
+                  export NameToRead=${flag_post}
+                  export listVarEnv=${listVarEnv}
+                  IGCM_sys_MkdirWork ${POST_DIR}
+                  IGCM_debug_Verif_Exit_Post
+                  Script_Post_Output=create_ts.${PeriodDateEnd}.${TsTask}.${CompToRead}.${NameToRead}
+                  IGCM_sys_QsubPost create_ts
+                  echo
+                else
+                  IGCM_debug_Print 2 -e "\033[1;31mI should NOW submit ${FILE} chunck ${Dimension}\033[m period ${ChunckDebut}-${ChunckFin} and CompletedFlag=${ChunckCompletedFlag}"
+                fi
+              fi
+
+              if ( [ ${chunck} = false ] && [ ${SuccessRate} -ne 100 ] ) ; then
+                eval Launch${Dimension}=true
+              fi
+
+              # Date update
+              ChunckDebut=$( IGCM_date_AddDaysToGregorianDate ${ChunckFin} 1 )
+
+              (( YearsChunckLoop = YearsChunckLoop + 1 ))
+
+              if [ ${YearsChunckLoop} -eq ${NbYearsChunckLoop} ] ; then
+                ChunckFin=${DateEnd}
+              else
+                Length=$( IGCM_date_DaysInCurrentPeriod ${ChunckDebut} ${YearsChunckLength}Y )
+                ChunckFin=$( IGCM_date_AddDaysToGregorianDate ${ChunckDebut} ${Length}-1 )
+              fi
+            done
+          done
+        else
+          ListDimension[0]=""
+          TimeSeries=true
+          TimeSeries2D=false
+          TimeSeries3D=false
+          TimeSeriesChunck2D=false
+          TimeSeriesChunck3D=false
+        fi
+      fi
+      (( i=i+3 ))
+    done
+  fi
+done # comp loop
+
+echo
+
+DateBegin=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateBegin} )
+IGCM_date_GetYearMonth ${DateBegin} YearBegin MonthBegin
+CompletedFlag=${SavedCompletedFlag}
+
+unset CompToRead
+unset FlagToRead
+
+if [ X${Launch2D} = Xtrue ] ; then
+  if [ ${action} = true ] ; then
+    #IGCM_debug_Print 2 "Potentials CompletedFlag: ${PotentialCompletedFlag2D[*]}"
+    IGCM_debug_Print 2 -e "\033[1;31mSubmit 2D\033[m without chunck period ${DateBegin}-${DateEnd}"
+    listVarEnv="libIGCM,SUBMIT_DIR,POST_DIR,DateBegin,PeriodDateEnd,CompletedFlag,TsTask"
+    export libIGCM=${libIGCM}
+    export SUBMIT_DIR=${CARD_DIR}
+    export POST_DIR=${POST_DIR}
+    export DateBegin=${DateBegin}
+    export PeriodDateEnd=${DateEnd}
+    export CompletedFlag=${CompletedFlag}
+    export TsTask=2D
+    export listVarEnv=${listVarEnv}
+    IGCM_sys_MkdirWork ${POST_DIR}
+    IGCM_debug_Verif_Exit_Post
+    Script_Post_Output=create_ts.${PeriodDateEnd}.${TsTask}
+    IGCM_sys_QsubPost create_ts
+    echo
+  else
+    IGCM_debug_Print 2 -e "\033[1;31mI should NOW submit 2D without chunck\033[m period ${DateBegin}-${DateEnd}"
+  fi
+fi
+
+if [ X${Launch3D} = Xtrue ] ; then
+  if [ ${action} = true ] ; then
+    #IGCM_debug_Print 2 "Potentials CompletedFlag: ${PotentialCompletedFlag3D[*]}"
+    IGCM_debug_Print 2 -e "\033[1;31mSubmit 3D\033[m without chunck period ${DateBegin}-${DateEnd}"
+    listVarEnv="libIGCM,SUBMIT_DIR,POST_DIR,DateBegin,PeriodDateEnd,CompletedFlag,TsTask"
+    export libIGCM=${libIGCM}
+    export SUBMIT_DIR=${CARD_DIR}
+    export POST_DIR=${POST_DIR}
+    export DateBegin=${DateBegin}
+    export PeriodDateEnd=${DateEnd}
+    export CompletedFlag=${CompletedFlag}
+    export TsTask=3D
+    export listVarEnv=${listVarEnv}
+    IGCM_sys_MkdirWork ${POST_DIR}
+    IGCM_debug_Verif_Exit_Post
+    Script_Post_Output=create_ts.${PeriodDateEnd}.${TsTask}
+    IGCM_sys_QsubPost create_ts
+    echo
+  else
+    IGCM_debug_Print 2 -e "\033[1;31mI should NOW submit 3D without chunck\033[m  period ${DateBegin}-${DateEnd}"
+  fi
+fi
Index: /tags/libIGCM_v2.2/AA_additionnal
===================================================================
--- /tags/libIGCM_v2.2/AA_additionnal	(revision 998)
+++ /tags/libIGCM_v2.2/AA_additionnal	(revision 998)
@@ -0,0 +1,126 @@
+#-Q- curie ######################
+#-Q- curie ## CURIE   TGCC/CEA ##
+#-Q- curie ######################
+#-Q- curie #MSUB -r ATL_ADD        # Nom du job
+#-Q- curie #MSUB -eo
+#-Q- curie #MSUB -n 1              # Reservation du processus
+#-Q- curie #MSUB -T 7200          # Limite de temps elapsed du job
+#-Q- curie #MSUB -q xlarge
+#-Q- curie #MSUB -Q normal
+#-Q- curie #MSUB -A ::default_project::
+#-Q- curie set +x
+#-Q- ada #!/bin/ksh
+#-Q- ada #######################
+#-Q- ada ## ADA         IDRIS ##
+#-Q- ada #######################
+#-Q- ada # @ job_type = serial
+#-Q- ada # @ requirements = (Feature == "prepost")
+#-Q- ada # Temps Elapsed max. d'une requete hh:mm:ss
+#-Q- ada # @ wall_clock_limit = 1:00:00
+#-Q- ada # Nom du travail LoadLeveler
+#-Q- ada # @ job_name   = ATL_ADD
+#-Q- ada # Fichier de sortie standard du travail
+#-Q- ada # @ output     = $(job_name).$(jobid)
+#-Q- ada # Fichier de sortie d'erreur du travail
+#-Q- ada # @ error      =  $(job_name).$(jobid)
+#-Q- ada # pour recevoir un mail en cas de depassement du temps Elapsed (ou autre pb.)
+#-Q- ada # @ notification = error
+#-Q- ada # @ environment  = $POST_DIR ; $SUBMIT_DIR ; $libIGCM ; $R_INIT ; $R_BC ; $StandAlone ; $RESOL_ATM ; $RESOL_OCE ; $RESOL_ICE ; $RESOL_MBG ; $RESOL_SRF ; $R_SAVE ; $config_UserChoices_JobName ; $config_UserChoices_TagName ; $YEARS ; $MASTER
+#-Q- ada # @ queue
+#-Q- lxiv8 ######################
+#-Q- lxiv8 ## OBELIX      LSCE ##
+#-Q- lxiv8 ######################
+#-Q- lxiv8 #PBS -N ATL_ADD
+#-Q- lxiv8 #PBS -m a
+#-Q- lxiv8 #PBS -j oe
+#-Q- lxiv8 #PBS -q test
+#-Q- lxiv8 #PBS -o ATL_ADD.$$
+#-Q- lxiv8 #PBS -S /bin/ksh
+#-Q- default #!/bin/ksh
+#-Q- default ##################
+#-Q- default ## DEFAULT HOST ##
+#-Q- default ##################
+
+#**************************************************************
+# Author: Sebastien Denvil
+# Contact: Sebastien.Denvil__at__ipsl.jussieu.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#set -eu
+#set -vx
+
+date
+
+#-Q- ada export OMP_NUM_THREADS=1
+
+#D- Task type (computing or post-processing)
+TaskType=post-processing
+
+#########################################################################
+
+. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
+. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
+. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
+#-------
+. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
+. ${libIGCM}/libIGCM_config/libIGCM_config.ksh
+#-------
+( ${DEBUG_debug} ) && IGCM_debug_Check
+( ${DEBUG_debug} ) && IGCM_card_Check
+( ${DEBUG_debug} ) && IGCM_date_Check
+
+#######################################################################
+
+#set -vx
+
+#===========================================
+R_ATLAS=ATLAS/SE_${YEARS}
+R_OUT_OCE=${R_SAVE}/OCE
+
+RUN_DIR=${RUN_DIR_PATH}/ATLAS_ADD_${YEARS}
+IGCM_sys_MkdirWork ${RUN_DIR}
+IGCM_sys_Cd ${RUN_DIR}
+
+# ------------------------------------------------------------------
+# Test if all was right before proceeding further
+# ------------------------------------------------------------------
+IGCM_debug_Verif_Exit_Post
+
+# --------------------------------------------
+# Insert your commands between III...III lines
+# and precise produced directories to save
+# IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
+
+IGCM_sys_Get ${R_OUT_OCE}/Analyse/SE/${config_UserChoices_JobName}_SE_${YEARS}_1M_grid_T.nc ${RUN_DIR}/SE_grid_T.nc
+IGCM_sys_Get ${R_OUT_OCE}/Analyse/SE/${config_UserChoices_JobName}_SE_${YEARS}_1M_grid_U.nc ${RUN_DIR}/SE_grid_U.nc
+IGCM_sys_Get ${R_OUT_OCE}/Analyse/SE/${config_UserChoices_JobName}_SE_${YEARS}_1M_grid_V.nc ${RUN_DIR}/SE_grid_V.nc
+IGCM_sys_Get ${R_OUT_OCE}/Analyse/SE/${config_UserChoices_JobName}_SE_${YEARS}_1M_grid_W.nc ${RUN_DIR}/SE_grid_W.nc
+
+atlas -o ${RUN_DIR}/${R_ATLAS}/ADD -p landscape=true,angle=-90,nup=1x1 ${FER_ATLAS}/atlas_p_ORCA2_add_*.cfg ${config_UserChoices_JobName}
+
+# IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
+
+# Put ferret journal files together
+for file in $( ls ${R_ATLAS}/ADD/*/*jnl ) ; do
+    echo -e "\n\n################################" ;
+    echo -e "$file\n" ; cat $file ;
+done  > ${R_ATLAS}/ADD/allferretscript.txt
+
+# Clear some files
+find . \( -name "*.stdout" -o -name "*.jnl" \) -print -exec rm -f {} \;
+
+# Save files
+IGCM_sys_Put_Dir ATLAS ${R_SAVE}
+
+IGCM_sys_Rm -Rf ATLAS
+IGCM_sys_Rm -f SE_grid_?.nc
+
+# DODS copy
+IGCM_sys_TestDirArchive ${R_SAVE}/${R_ATLAS}
+[ $? = 0 ] && IGCM_sys_Put_Dods ${R_ATLAS}
Index: /tags/libIGCM_v2.2/AA_atlas_LMDZ
===================================================================
--- /tags/libIGCM_v2.2/AA_atlas_LMDZ	(revision 998)
+++ /tags/libIGCM_v2.2/AA_atlas_LMDZ	(revision 998)
@@ -0,0 +1,157 @@
+#-Q- curie ######################
+#-Q- curie ## CURIE   TGCC/CEA ##
+#-Q- curie ######################
+#-Q- curie #MSUB -r ATL_LMDZ       # Nom du job
+#-Q- curie #MSUB -eo
+#-Q- curie #MSUB -n 1              # Reservation du processus
+#-Q- curie #MSUB -T 7200          # Limite de temps elapsed du job
+#-Q- curie #MSUB -q xlarge
+#-Q- curie #MSUB -Q normal
+#-Q- curie #MSUB -A ::default_project::
+#-Q- curie set +x
+#-Q- ada #!/bin/ksh
+#-Q- ada #######################
+#-Q- ada ## ADA         IDRIS ##
+#-Q- ada #######################
+#-Q- ada # @ job_type = serial
+#-Q- ada # @ requirements = (Feature == "prepost")
+#-Q- ada # Temps Elapsed max. d'une requete hh:mm:ss
+#-Q- ada # @ wall_clock_limit = 1:00:00
+#-Q- ada # Nom du travail LoadLeveler
+#-Q- ada # @ job_name   = ATL_LMDZ
+#-Q- ada # Fichier de sortie standard du travail
+#-Q- ada # @ output     = $(job_name).$(jobid)
+#-Q- ada # Fichier de sortie d'erreur du travail
+#-Q- ada # @ error      =  $(job_name).$(jobid)
+#-Q- ada # pour recevoir un mail en cas de depassement du temps Elapsed (ou autre pb.)
+#-Q- ada # @ notification = error
+#-Q- ada # @ environment  = $POST_DIR ; $SUBMIT_DIR ; $libIGCM ; $R_INIT ; $R_BC ; $StandAlone ; $RESOL_ATM ; $RESOL_OCE ; $RESOL_ICE ; $RESOL_SRF ; $R_SAVE ; $config_UserChoices_JobName ; $config_UserChoices_TagName ; $YEARS ; $DIR_OUT ; $MASTER ; $libIGCM_SX
+#-Q- ada # @ queue
+#-Q- lxiv8 ######################
+#-Q- lxiv8 ## OBELIX      LSCE ##
+#-Q- lxiv8 ######################
+#-Q- lxiv8 #PBS -N ATL_LMDZ
+#-Q- lxiv8 #PBS -m a
+#-Q- lxiv8 #PBS -j oe
+#-Q- lxiv8 #PBS -q test
+#-Q- lxiv8 #PBS -o ATL_LMDZ.$$
+#-Q- lxiv8 #PBS -S /bin/ksh
+#-Q- default #!/bin/ksh
+#-Q- default ##################
+#-Q- default ## DEFAULT HOST ##
+#-Q- default ##################
+
+#**************************************************************
+# Author: Sebastien Denvil
+# Contact: Sebastien.Denvil__at__ipsl.jussieu.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#set -eu
+#set -vx
+
+date
+
+#-Q- ada export OMP_NUM_THREADS=1
+
+#D- Task type (computing or post-processing)
+TaskType=post-processing
+
+######################################################################
+
+. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
+. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
+. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
+#-------
+. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
+. ${libIGCM}/libIGCM_config/libIGCM_config.ksh
+#-------
+( ${DEBUG_debug} ) && IGCM_debug_Check
+( ${DEBUG_debug} ) && IGCM_card_Check
+( ${DEBUG_debug} ) && IGCM_date_Check
+
+######################################################################
+
+#set -vx
+
+IGCM_sys_MkdirWork ${RUN_DIR_PATH}
+IGCM_sys_Cd ${RUN_DIR_PATH}
+
+# ------------------------------------------------------------------
+# Test if all was right before proceeding further
+# ------------------------------------------------------------------
+IGCM_debug_Verif_Exit_Post
+
+if [ ${StandAlone} = true ] ; then
+    CARD_DIR=${SUBMIT_DIR}
+else
+    CARD_DIR=${RUN_DIR_PATH}
+    IGCM_sys_Get_Master ${SUBMIT_DIR}/config.card ${RUN_DIR_PATH}
+    IGCM_sys_Get_Master ${SUBMIT_DIR}/run.card    ${RUN_DIR_PATH}
+    IGCM_sys_Get_Master ${SUBMIT_DIR}/COMP        ${RUN_DIR_PATH}
+    IGCM_sys_Get_Master ${SUBMIT_DIR}/POST        ${RUN_DIR_PATH}
+fi
+
+#==================================
+# First of all
+#
+# Read libIGCM compatibility version in config.card
+# Read UserChoices section
+# Read Ensemble section
+# Read Post section
+# Define all netcdf output directories
+#==================================
+IGCM_config_CommonConfiguration ${CARD_DIR}/config.card
+#
+IGCM_sys_MkdirArchive ${R_FIGR}
+
+R_ATLAS=ATLAS/SE_${YEARS}
+R_OUT_ATM=${R_SAVE}/ATM
+DIR_OUT=${DIR_OUT:=SE}
+
+RUN_DIR=${RUN_DIR_PATH}/ATLAS_LMDZ_${YEARS}
+IGCM_sys_MkdirWork ${RUN_DIR}
+IGCM_sys_Cd ${RUN_DIR}
+
+# --------------------------------------------
+# Insert your commands between III...III lines
+# and precise produced directories to save
+# IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
+
+IGCM_sys_Get ${R_OUT_ATM}/Analyse/${DIR_OUT}/${config_UserChoices_JobName}_SE_${YEARS}_1M_histmth.nc ${RUN_DIR}
+
+# Only LMDZ4 output have Alt variables
+DetectLev=$( ncdump -h ${config_UserChoices_JobName}_SE_${YEARS}_1M_histmth.nc | grep "Alt(Alt)" | wc -l )
+#
+[ ${DetectLev} = 1 ] && LMDZ=LMDZ4 || LMDZ=LMDZ3.3
+#
+atlas -o ${RUN_DIR}/${R_ATLAS}/ATM -l ${FER_ATLAS}/atlas_p_${LMDZ}_diag1_*.cfg ${RUN_DIR}/${config_UserChoices_JobName}_SE_${YEARS}_1M_histmth.nc
+
+# IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
+
+# Put ferret journal files together
+for file in $( ls ${R_ATLAS}/ATM/*/*jnl ) ; do
+    echo -e "\n\n################################" ;
+    echo -e "$file\n" ; cat $file ;
+done  > ${R_ATLAS}/ATM/allferretscript.txt
+
+# Clear some files
+find . \( -name "*.stdout" -o -name "*.jnl" \) -print -exec rm -f {} \;
+
+# Save files
+IGCM_sys_Put_Dir ATLAS ${R_FIGR}
+IGCM_sys_Rm -Rf ATLAS
+IGCM_sys_Rm ${config_UserChoices_JobName}_SE_${YEARS}_1M_histmth.nc
+
+# DODS copy
+if [ X${config_Post_DodsCopy} = XTRUE ]  ; then
+  IGCM_sys_TestDirArchive ${R_FIGR}/${R_ATLAS}
+  [ $? = 0 ] && IGCM_sys_Put_Dods ${R_ATLAS}
+fi
+# Clean RUN_DIR_PATH (necessary for cesium and titane only)
+IGCM_sys_RmRunDir -Rf ${RUN_DIR_PATH}
Index: /tags/libIGCM_v2.2/AA_atlas_ORCA_LIM
===================================================================
--- /tags/libIGCM_v2.2/AA_atlas_ORCA_LIM	(revision 998)
+++ /tags/libIGCM_v2.2/AA_atlas_ORCA_LIM	(revision 998)
@@ -0,0 +1,201 @@
+#-Q- curie ######################
+#-Q- curie ## CURIE   TGCC/CEA ##
+#-Q- curie ######################
+#-Q- curie #MSUB -r ATL_OPA        # Nom du job
+#-Q- curie #MSUB -eo
+#-Q- curie #MSUB -n 1              # Reservation du processus
+#-Q- curie #MSUB -T 7200          # Limite de temps elapsed du job
+#-Q- curie #MSUB -q xlarge
+#-Q- curie #MSUB -Q normal
+#-Q- curie #MSUB -A ::default_project::
+#-Q- curie set +x
+#-Q- ada #!/bin/ksh
+#-Q- ada #######################
+#-Q- ada ## ADA         IDRIS ##
+#-Q- ada #######################
+#-Q- ada # @ job_type = serial
+#-Q- ada # @ requirements = (Feature == "prepost")
+#-Q- ada # Temps Elapsed max. d'une requete hh:mm:ss
+#-Q- ada # @ wall_clock_limit = 2:00:00
+#-Q- ada # Nom du travail LoadLeveler
+#-Q- ada # @ job_name   = ATL_OPA
+#-Q- ada # Fichier de sortie standard du travail
+#-Q- ada # @ output     = $(job_name).$(jobid)
+#-Q- ada # Fichier de sortie d'erreur du travail
+#-Q- ada # @ error      =  $(job_name).$(jobid)
+#-Q- ada # pour recevoir un mail en cas de depassement du temps Elapsed (ou autre pb.)
+#-Q- ada # @ notification = error
+#-Q- ada # @ environment  = $POST_DIR ; $SUBMIT_DIR ; $libIGCM ; $R_INIT ; $R_BC ; $StandAlone ; $RESOL_ATM ; $RESOL_OCE ; $RESOL_ICE ; $RESOL_MBG ; $RESOL_SRF ; $R_SAVE ; $config_UserChoices_JobName ; $config_UserChoices_TagName ; $YEARS ; $DIR_OUT ; $MASTER ; $libIGCM_SX
+#-Q- ada # @ queue
+#-Q- lxiv8 ######################
+#-Q- lxiv8 ## OBELIX      LSCE ##
+#-Q- lxiv8 ######################
+#-Q- lxiv8 #PBS -N ATL_OPA
+#-Q- lxiv8 #PBS -m a
+#-Q- lxiv8 #PBS -j oe
+#-Q- lxiv8 #PBS -q test
+#-Q- lxiv8 #PBS -o ATL_OPA.$$
+#-Q- lxiv8 #PBS -S /bin/ksh
+#-Q- default #!/bin/ksh
+#-Q- default ##################
+#-Q- default ## DEFAULT HOST ##
+#-Q- default ##################
+
+#**************************************************************
+# Author: Sebastien Denvil
+# Contact: Sebastien.Denvil__at__ipsl.jussieu.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#set -eu
+#set -vx
+
+date
+
+#-Q- ada export OMP_NUM_THREADS=1
+
+#D- Task type (computing or post-processing)
+TaskType=post-processing
+
+########################################################################
+
+. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
+. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
+. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
+#-------
+. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
+. ${libIGCM}/libIGCM_config/libIGCM_config.ksh
+#-------
+( ${DEBUG_debug} ) && IGCM_debug_Check
+( ${DEBUG_debug} ) && IGCM_card_Check
+( ${DEBUG_debug} ) && IGCM_date_Check
+
+########################################################################
+
+#set -vx
+
+IGCM_sys_MkdirWork ${RUN_DIR_PATH}
+IGCM_sys_Cd ${RUN_DIR_PATH}
+
+# ------------------------------------------------------------------
+# Test if all was right before proceeding further
+# ------------------------------------------------------------------
+IGCM_debug_Verif_Exit_Post
+
+if [ ${StandAlone} = true ] ; then
+    CARD_DIR=${SUBMIT_DIR}
+else
+    CARD_DIR=${RUN_DIR_PATH}
+    IGCM_sys_Get_Master ${SUBMIT_DIR}/config.card ${RUN_DIR_PATH}
+    IGCM_sys_Get_Master ${SUBMIT_DIR}/run.card    ${RUN_DIR_PATH}
+    IGCM_sys_Get_Master ${SUBMIT_DIR}/COMP        ${RUN_DIR_PATH}
+    IGCM_sys_Get_Master ${SUBMIT_DIR}/POST        ${RUN_DIR_PATH}
+
+fi
+
+#==================================
+# First of all
+#
+# Read libIGCM compatibility version in config.card
+# Read UserChoices section
+# Read Ensemble section
+# Read Post section
+# Define all netcdf output directories
+#==================================
+IGCM_config_CommonConfiguration ${CARD_DIR}/config.card
+
+#
+IGCM_sys_MkdirArchive ${R_FIGR}
+
+R_ATLAS=ATLAS/SE_${YEARS}
+R_OUT_OCE=${R_SAVE}/OCE
+R_OUT_ICE=${R_SAVE}/ICE
+DIR_OUT=${DIR_OUT:=SE}
+
+RUN_DIR=${RUN_DIR_PATH}/ATLAS_ORCALIM_${YEARS}
+IGCM_sys_MkdirWork ${RUN_DIR}
+IGCM_sys_Cd ${RUN_DIR}
+
+# --------------------------------------------
+# Insert your commands between III...III lines
+# and precise produced directories to save
+# IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
+
+IGCM_sys_Get ${R_OUT_OCE}/Analyse/${DIR_OUT}/${config_UserChoices_JobName}_SE_${YEARS}_1M_grid_T.nc  ${RUN_DIR}
+IGCM_sys_Get ${R_OUT_OCE}/Analyse/${DIR_OUT}/${config_UserChoices_JobName}_SE_${YEARS}_1M_grid_U.nc  ${RUN_DIR}
+IGCM_sys_Get ${R_OUT_OCE}/Analyse/${DIR_OUT}/${config_UserChoices_JobName}_SE_${YEARS}_1M_grid_V.nc  ${RUN_DIR}
+IGCM_sys_Get ${R_OUT_OCE}/Analyse/${DIR_OUT}/${config_UserChoices_JobName}_SE_${YEARS}_1M_grid_W.nc  ${RUN_DIR}
+IGCM_sys_Get ${R_OUT_ICE}/Analyse/${DIR_OUT}/${config_UserChoices_JobName}_SE_${YEARS}_1M_icemod.nc  ${RUN_DIR}
+
+atlas -o ${RUN_DIR}/${R_ATLAS}/OCE_T -l ${FER_ATLAS}/atlas_p_${RESOL_OCE}_diag1_[abc].cfg     ${RUN_DIR}/${config_UserChoices_JobName}_SE_${YEARS}_1M_grid_T.nc
+atlas -o ${RUN_DIR}/${R_ATLAS}/OCE_U -l ${FER_ATLAS}/atlas_p_${RESOL_OCE}_diag0_U.cfg         ${RUN_DIR}/${config_UserChoices_JobName}_SE_${YEARS}_1M_grid_U.nc
+atlas -o ${RUN_DIR}/${R_ATLAS}/OCE_V -l ${FER_ATLAS}/atlas_p_${RESOL_OCE}_diag0_V.cfg         ${RUN_DIR}/${config_UserChoices_JobName}_SE_${YEARS}_1M_grid_V.nc
+#atlas -o ${RUN_DIR}/${R_ATLAS}/OCE_W -l ${FER_ATLAS}/atlas_p_${RESOL_OCE}_diag0_W.cfg         ${RUN_DIR}/${config_UserChoices_JobName}_SE_${YEARS}_1M_grid_W.nc
+atlas -o ${RUN_DIR}/${R_ATLAS}/OCE   -l ${FER_ATLAS}/atlas_p_${RESOL_OCE}_diag0_[defg].cfg     ${RUN_DIR}/${config_UserChoices_JobName}_SE_${YEARS}_1M_grid_T.nc
+atlas -o ${RUN_DIR}/${R_ATLAS}/ICE   -l ${FER_ATLAS}/atlas_p_${RESOL_OCE}LIM_diag0_[abc].cfg  ${RUN_DIR}/${config_UserChoices_JobName}_SE_${YEARS}_1M_icemod.nc
+
+# IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
+
+# Put ferret journal files together
+for file in $( ls ${R_ATLAS}/OCE_T/*/*jnl ) ; do
+  echo -e "\n\n################################" ;
+  echo -e "$file\n" ; cat $file ;
+done  > ${R_ATLAS}/OCE_T/allferretscript.txt
+
+for file in $( ls ${R_ATLAS}/OCE_U/*/*jnl ) ; do
+  echo -e "\n\n################################" ;
+  echo -e "$file\n" ; cat $file ;
+done  > ${R_ATLAS}/OCE_U/allferretscript.txt
+
+for file in $( ls ${R_ATLAS}/OCE_V/*/*jnl ) ; do
+  echo -e "\n\n################################" ;
+  echo -e "$file\n" ; cat $file ;
+done  > ${R_ATLAS}/OCE_V/allferretscript.txt
+
+for file in $( ls ${R_ATLAS}/OCE/*/*jnl ) ; do
+  echo -e "\n\n################################" ;
+  echo -e "$file\n" ; cat $file ;
+done  > ${R_ATLAS}/OCE/allferretscript.txt
+
+for file in $( ls ${R_ATLAS}/ICE/*/*jnl ) ; do
+  echo -e "\n\n################################" ;
+  echo -e "$file\n" ; cat $file ;
+done  > ${R_ATLAS}/ICE/allferretscript.txt
+
+# WHILE WAITING FOR A MORE GENERIC SOLUTION
+if ( [ ${config_UserChoices_TagName} = "IPSLCM5" ] || [ ${config_UserChoices_TagName} = "IPSLCM5A" ] || [ ${config_UserChoices_TagName} = "IPSLCM5A-MR" ] || [ ${config_UserChoices_TagName} = "ORCA2_LIM2" ] || [ ${config_UserChoices_TagName} = "ORCA2_LIM2_PISCES" ] ) ; then
+  IGCM_sys_Get ${R_OUT_OCE}/Analyse/${DIR_OUT}/${config_UserChoices_JobName}_SE_${YEARS}_1M_diaptr.nc  ${RUN_DIR} ;
+  atlas -o ${RUN_DIR}/${R_ATLAS}/ZNL   -d -l ${FER_ATLAS}/atlas_l_${RESOL_OCE}_znl.cfg         ${RUN_DIR}/${config_UserChoices_JobName}_SE_${YEARS}_1M_diaptr.nc ;
+  for file in $( ls ${R_ATLAS}/ZNL/*/*jnl ) ; do
+    echo -e "\n\n################################" ;
+    echo -e "$file\n" ; cat $file ;
+  done > ${R_ATLAS}/ZNL/allferretscript.txt
+fi
+
+# Clear some files
+find . \( -name "*.stdout" -o -name "*.jnl" \) -print -exec rm -f {} \;
+
+# Save files
+IGCM_sys_Put_Dir ATLAS ${R_FIGR}
+
+IGCM_sys_Rm -Rf ATLAS
+IGCM_sys_Rm ${config_UserChoices_JobName}_SE_${YEARS}_1M_grid_[TUVW].nc
+IGCM_sys_Rm ${config_UserChoices_JobName}_SE_${YEARS}_1M_icemod.nc
+# WHILE WAITING FOR A MORE GENERIC SOLUTION
+if ( [ ${config_UserChoices_TagName} = "IPSLCM5" ] || [ ${config_UserChoices_TagName} = "IPSLCM5A" ] || [ ${config_UserChoices_TagName} = "IPSLCM5A-MR" ] || [ ${config_UserChoices_TagName} = "ORCA2_LIM2" ] || [ ${config_UserChoices_TagName} = "ORCA2_LIM2_PISCES" ] ) ; then
+  IGCM_sys_Rm ${config_UserChoices_JobName}_SE_${YEARS}_1M_diaptr.nc ;
+fi
+
+# DODS copy
+if [ X${config_Post_DodsCopy} = XTRUE ]  ; then
+  IGCM_sys_TestDirArchive ${R_FIGR}/${R_ATLAS}
+  [ $? = 0 ] && IGCM_sys_Put_Dods ${R_ATLAS}
+fi
+
+# Clean RUN_DIR_PATH (necessary for cesium and titane only)
+IGCM_sys_RmRunDir -Rf ${RUN_DIR_PATH}
Index: /tags/libIGCM_v2.2/AA_atlas_ORCHIDEE
===================================================================
--- /tags/libIGCM_v2.2/AA_atlas_ORCHIDEE	(revision 998)
+++ /tags/libIGCM_v2.2/AA_atlas_ORCHIDEE	(revision 998)
@@ -0,0 +1,156 @@
+#-Q- curie ######################
+#-Q- curie ## CURIE   TGCC/CEA ##
+#-Q- curie ######################
+#-Q- curie #MSUB -r ATL_ORCH       # Nom du job
+#-Q- curie #MSUB -eo
+#-Q- curie #MSUB -n 1              # Reservation du processus
+#-Q- curie #MSUB -T 7200          # Limite de temps elapsed du job
+#-Q- curie #MSUB -q xlarge
+#-Q- curie #MSUB -Q normal
+#-Q- curie #MSUB -A ::default_project::
+#-Q- curie set +x
+#-Q- ada #!/bin/ksh
+#-Q- ada #######################
+#-Q- ada ## ADA         IDRIS ##
+#-Q- ada #######################
+#-Q- ada # @ job_type = serial
+#-Q- ada # @ requirements = (Feature == "prepost")
+#-Q- ada # Temps Elapsed max. d'une requete hh:mm:ss
+#-Q- ada # @ wall_clock_limit = 1:00:00
+#-Q- ada # Nom du travail LoadLeveler
+#-Q- ada # @ job_name   = ATL_ORCH
+#-Q- ada # Fichier de sortie standard du travail
+#-Q- ada # @ output     = $(job_name).$(jobid)
+#-Q- ada # Fichier de sortie d'erreur du travail
+#-Q- ada # @ error      =  $(job_name).$(jobid)
+#-Q- ada # pour recevoir un mail en cas de depassement du temps Elapsed (ou autre pb.)
+#-Q- ada # @ notification = error
+#-Q- ada # @ environment  = $POST_DIR ; $SUBMIT_DIR ; $libIGCM ; $R_INIT ; $R_BC ; $StandAlone ; $RESOL_ATM ; $RESOL_OCE ; $RESOL_ICE ; $RESOL_SRF ; $R_SAVE ; $config_UserChoices_JobName ; $config_UserChoices_TagName ; $YEARS ; $DIR_OUT ; $MASTER ; $libIGCM_SX
+#-Q- ada # @ queue
+#-Q- lxiv8 ######################
+#-Q- lxiv8 ## OBELIX      LSCE ##
+#-Q- lxiv8 ######################
+#-Q- lxiv8 #PBS -N ATL_ORCH
+#-Q- lxiv8 #PBS -m a
+#-Q- lxiv8 #PBS -j oe
+#-Q- lxiv8 #PBS -q medium
+#-Q- lxiv8 #PBS -o ATL_ORCH.$$
+#-Q- lxiv8 #PBS -S /bin/ksh
+#-Q- default #!/bin/ksh
+#-Q- default ##################
+#-Q- default ## DEFAULT HOST ##
+#-Q- default ##################
+
+#**************************************************************
+# Author: Martial Mancip
+# Contact: Martial.Mancip__at__ipsl.jussieu.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#set -eu
+#set -vx
+
+date
+
+#-Q- ada export OMP_NUM_THREADS=1
+
+#D- Task type (computing or post-processing)
+TaskType=post-processing
+
+########################################################################
+
+. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
+. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
+. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
+#-------
+. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
+. ${libIGCM}/libIGCM_config/libIGCM_config.ksh
+#-------
+( ${DEBUG_debug} ) && IGCM_debug_Check
+( ${DEBUG_debug} ) && IGCM_card_Check
+( ${DEBUG_debug} ) && IGCM_date_Check
+
+########################################################################
+
+#set -vx
+
+IGCM_sys_MkdirWork ${RUN_DIR_PATH}
+IGCM_sys_Cd ${RUN_DIR_PATH}
+
+# ------------------------------------------------------------------
+# Test if all was right before proceeding further
+# ------------------------------------------------------------------
+IGCM_debug_Verif_Exit_Post
+
+if [ ${StandAlone} = true ] ; then
+    CARD_DIR=${SUBMIT_DIR}
+else
+    CARD_DIR=${RUN_DIR_PATH}
+    IGCM_sys_Get_Master ${SUBMIT_DIR}/config.card ${RUN_DIR_PATH}
+    IGCM_sys_Get_Master ${SUBMIT_DIR}/run.card    ${RUN_DIR_PATH}
+    IGCM_sys_Get_Master ${SUBMIT_DIR}/COMP        ${RUN_DIR_PATH}
+    IGCM_sys_Get_Master ${SUBMIT_DIR}/POST        ${RUN_DIR_PATH}
+fi
+
+#==================================
+# First of all
+#
+# Read libIGCM compatibility version in config.card
+# Read UserChoices section
+# Read Ensemble section
+# Read Post section
+# Define all netcdf output directories
+#==================================
+IGCM_config_CommonConfiguration ${CARD_DIR}/config.card
+
+#
+IGCM_sys_MkdirArchive ${R_FIGR}
+
+R_ATLAS=ATLAS/SE_${YEARS}
+R_OUT_SRF=${R_SAVE}/SRF
+DIR_OUT=${DIR_OUT:=SE}
+
+RUN_DIR=${RUN_DIR_PATH}/ATLAS_ORCHIDEE_${YEARS}
+IGCM_sys_MkdirWork ${RUN_DIR}
+IGCM_sys_Cd ${RUN_DIR}
+
+# --------------------------------------------
+# Insert your commands between III...III lines
+# and precise produced directories to save
+# IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
+
+IGCM_sys_Get ${R_OUT_SRF}/Analyse/${DIR_OUT}/${config_UserChoices_JobName}_SE_${YEARS}_1M_sechiba_history.nc ${RUN_DIR}
+
+atlas -o ${RUN_DIR}/${R_ATLAS}/SRF -l ${FER_ATLAS}/atlas_p_ORCHIDEE_diag1_*.cfg \
+                                       ${FER_ATLAS}/atlas_p_SECHIBA_diag1_*.cfg \
+                                       ${FER_ATLAS}/atlas_p_ORCHIDEE_diag2_a.cfg  ${RUN_DIR}/${config_UserChoices_JobName}_SE_${YEARS}_1M_sechiba_history.nc
+
+# IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
+
+# Put ferret journal files together
+for file in $( ls ${R_ATLAS}/SRF/*/*jnl ) ; do
+    echo -e "\n\n################################" ;
+    echo -e "$file\n" ; cat $file ;
+done  > ${R_ATLAS}/SRF/allferretscript.txt
+
+# Clear some files
+find . \( -name "*.stdout" -o -name "*.jnl" \) -print -exec rm -f {} \;
+
+# Save files
+IGCM_sys_Put_Dir ATLAS ${R_FIGR}
+IGCM_sys_Rm -Rf ATLAS
+IGCM_sys_Rm ${config_UserChoices_JobName}_SE_${YEARS}_1M_sechiba_history.nc
+
+# DODS copy
+if [ X${config_Post_DodsCopy} = XTRUE ]  ; then
+  IGCM_sys_TestDirArchive ${R_FIGR}/${R_ATLAS}
+  [ $? = 0 ] && IGCM_sys_Put_Dods ${R_ATLAS}
+fi
+
+# Clean RUN_DIR_PATH (necessary for cesium and titane only)
+IGCM_sys_RmRunDir -Rf ${RUN_DIR_PATH}
Index: /tags/libIGCM_v2.2/AA_atlas_PISCES
===================================================================
--- /tags/libIGCM_v2.2/AA_atlas_PISCES	(revision 998)
+++ /tags/libIGCM_v2.2/AA_atlas_PISCES	(revision 998)
@@ -0,0 +1,163 @@
+#-Q- curie ######################
+#-Q- curie ## CURIE   TGCC/CEA ##
+#-Q- curie ######################
+#-Q- curie #MSUB -r ATL_PIS        # Nom du job
+#-Q- curie #MSUB -eo
+#-Q- curie #MSUB -n 1              # Reservation du processus
+#-Q- curie #MSUB -T 7200          # Limite de temps elapsed du job
+#-Q- curie #MSUB -q xlarge
+#-Q- curie #MSUB -Q normal
+#-Q- curie #MSUB -A ::default_project::
+#-Q- curie set +x
+#-Q- ada #!/bin/ksh
+#-Q- ada #######################
+#-Q- ada ## ADA         IDRIS ##
+#-Q- ada #######################
+#-Q- ada # @ job_type = serial
+#-Q- ada # @ requirements = (Feature == "prepost")
+#-Q- ada # Temps Elapsed max. d'une requete hh:mm:ss
+#-Q- ada # @ wall_clock_limit = 1:00:00
+#-Q- ada # Nom du travail LoadLeveler
+#-Q- ada # @ job_name   = ATL_PIS
+#-Q- ada # Fichier de sortie standard du travail
+#-Q- ada # @ output     = $(job_name).$(jobid)
+#-Q- ada # Fichier de sortie d'erreur du travail
+#-Q- ada # @ error      =  $(job_name).$(jobid)
+#-Q- ada # pour recevoir un mail en cas de depassement du temps Elapsed (ou autre pb.)
+#-Q- ada # @ notification = error
+#-Q- ada # @ environment  = $POST_DIR ; $SUBMIT_DIR ; $libIGCM ; $R_INIT ; $R_BC ; $StandAlone ; $RESOL_ATM ; $RESOL_OCE ; $RESOL_ICE ; $RESOL_MBG ; $RESOL_SRF ; $R_SAVE ; $config_UserChoices_JobName ; $config_UserChoices_TagName ; $YEARS ; $DIR_OUT ; $MASTER ; $libIGCM_SX
+#-Q- ada # @ queue
+#-Q- lxiv8 ######################
+#-Q- lxiv8 ## OBELIX      LSCE ##
+#-Q- lxiv8 ######################
+#-Q- lxiv8 #PBS -N ATL_PIS
+#-Q- lxiv8 #PBS -m a
+#-Q- lxiv8 #PBS -j oe
+#-Q- lxiv8 #PBS -q test
+#-Q- lxiv8 #PBS -o ATL_PIS.$$
+#-Q- lxiv8 #PBS -S /bin/ksh
+#-Q- default #!/bin/ksh
+#-Q- default ##################
+#-Q- default ## DEFAULT HOST ##
+#-Q- default ##################
+
+#**************************************************************
+# Author: Christian Ethe
+# Contact: Christian.Ethe__at__ipsl.jussieu.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#set -eu
+#set -vx
+
+date
+
+#-Q- ada export OMP_NUM_THREADS=1
+
+#D- Task type (computing or post-processing)
+TaskType=post-processing
+
+########################################################################
+
+. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
+. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
+. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
+#-------
+. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
+. ${libIGCM}/libIGCM_config/libIGCM_config.ksh
+#-------
+( ${DEBUG_debug} ) && IGCM_debug_Check
+( ${DEBUG_debug} ) && IGCM_card_Check
+( ${DEBUG_debug} ) && IGCM_date_Check
+
+########################################################################
+
+#set -vx
+
+IGCM_sys_MkdirWork ${RUN_DIR_PATH}
+IGCM_sys_Cd ${RUN_DIR_PATH}
+
+# ------------------------------------------------------------------
+# Test if all was right before proceeding further
+# ------------------------------------------------------------------
+IGCM_debug_Verif_Exit_Post
+
+if [ ${StandAlone} = true ] ; then
+    CARD_DIR=${SUBMIT_DIR}
+else
+    CARD_DIR=${RUN_DIR_PATH}
+    IGCM_sys_Get_Master ${SUBMIT_DIR}/config.card ${RUN_DIR_PATH}
+    IGCM_sys_Get_Master ${SUBMIT_DIR}/run.card    ${RUN_DIR_PATH}
+    IGCM_sys_Get_Master ${SUBMIT_DIR}/COMP        ${RUN_DIR_PATH}
+    IGCM_sys_Get_Master ${SUBMIT_DIR}/POST        ${RUN_DIR_PATH}
+fi
+
+#==================================
+# First of all
+#
+# Read libIGCM compatibility version in config.card
+# Read UserChoices section
+# Read Ensemble section
+# Read Post section
+# Define all netcdf output directories
+#==================================
+IGCM_config_CommonConfiguration ${CARD_DIR}/config.card
+
+IGCM_sys_MkdirArchive ${R_FIGR}
+
+R_ATLAS=ATLAS/SE_${YEARS}
+R_OUT_MBG=${R_SAVE}/MBG
+DIR_OUT=${DIR_OUT:=SE}
+
+RUN_DIR=${RUN_DIR_PATH}/ATLAS_PISCES_${YEARS}
+IGCM_sys_MkdirWork ${RUN_DIR}
+IGCM_sys_Cd ${RUN_DIR}
+
+# --------------------------------------------
+# Insert your commands between III...III lines
+# and precise produced directories to save
+# IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
+
+IGCM_sys_Get ${R_OUT_MBG}/Analyse/${DIR_OUT}/${config_UserChoices_JobName}_SE_${YEARS}_1M_ptrc_T.nc  ${RUN_DIR}
+IGCM_sys_Get ${R_OUT_MBG}/Analyse/${DIR_OUT}/${config_UserChoices_JobName}_SE_${YEARS}_1M_diad_T.nc  ${RUN_DIR}
+
+atlas -o ${RUN_DIR}/${R_ATLAS}/MBG_T -l ${FER_ATLAS}/atlas_p_PISCES_diag1_*.cfg  \
+                                        ${FER_ATLAS}/atlas_p_PISCES_diag0_a.cfg  ${RUN_DIR}/${config_UserChoices_JobName}_SE_${YEARS}_1M_ptrc_T.nc
+atlas -o ${RUN_DIR}/${R_ATLAS}/MBG_F -l ${FER_ATLAS}/atlas_p_PISCES_diag2_a.cfg  \
+                                        ${FER_ATLAS}/atlas_p_PISCES_diag0_b.cfg  ${RUN_DIR}/${config_UserChoices_JobName}_SE_${YEARS}_1M_diad_T.nc
+
+# IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
+
+# Put ferret journal files together
+for file in $( ls ${R_ATLAS}/MBG_T/*/*jnl ) ; do
+    echo -e "\n\n################################" ;
+    echo -e "$file\n" ; cat $file ;
+done  > ${R_ATLAS}/MBG_T/allferretscript.txt
+
+for file in $( ls ${R_ATLAS}/MBG_F/*/*jnl ) ; do
+    echo -e "\n\n################################" ;
+    echo -e "$file\n" ; cat $file ;
+done  > ${R_ATLAS}/MBG_F/allferretscript.txt
+# Clear some files
+find . \( -name "*.stdout" -o -name "*.jnl" \) -print -exec rm -f {} \;
+
+# Save files
+IGCM_sys_Put_Dir ATLAS ${R_FIGR}
+
+IGCM_sys_Rm -Rf ATLAS
+IGCM_sys_Rm ${config_UserChoices_JobName}_SE_${YEARS}_1M_ptrc_T.nc
+IGCM_sys_Rm ${config_UserChoices_JobName}_SE_${YEARS}_1M_diad_T.nc
+
+# DODS copy
+if [ X${config_Post_DodsCopy} = XTRUE ]  ; then
+  IGCM_sys_TestDirArchive ${R_FIGR}/${R_ATLAS}
+  [ $? = 0 ] && IGCM_sys_Put_Dods ${R_ATLAS}
+fi
+
+# Clean RUN_DIR_PATH (necessary for cesium and titane only)
+IGCM_sys_RmRunDir -Rf ${RUN_DIR_PATH}
Index: /tags/libIGCM_v2.2/AA_clean_month
===================================================================
--- /tags/libIGCM_v2.2/AA_clean_month	(revision 998)
+++ /tags/libIGCM_v2.2/AA_clean_month	(revision 998)
@@ -0,0 +1,215 @@
+#!/bin/ksh
+#**************************************************************
+# Author: Martial Mancip
+# Contact: Martial.Mancip__at__ipsl.jussieu.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#set -eu
+#set -vx
+
+libIGCM=::modipsl::/libIGCM
+
+#D- Task type (computing or post-processing)
+TaskType=post-processing
+
+#D--------------------------------------------------------------------==
+#D-                   -1. User modification place
+#D--------------------------------------------------------------------==
+
+#D- Increased verbosity (1, 2, 3)
+Verbosity=3
+
+#D- Low level debug : to bypass lib test checks and stack construction
+#D- Default=true
+DEBUG_debug=false
+
+#D--------------------------------------------------------------------==
+
+echo "clean month script :"
+echo "Script used to clean a month on SAVE directory !"
+echo "This script will erase some files !!! Be careful and read all informations !"
+echo "----"
+echo "It must be called in Experience directory (so-called SUBMIT_DIR)."
+echo "----"
+
+#D--------------------------------------------------------------------==
+
+. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
+. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
+. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
+#-------
+SUBMIT_DIR=$( pwd )
+. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
+. ${libIGCM}/libIGCM_config/libIGCM_config.ksh
+#-------
+( ${DEBUG_debug} ) && IGCM_debug_Check
+( ${DEBUG_debug} ) && IGCM_card_Check
+( ${DEBUG_debug} ) && IGCM_date_Check
+
+#==================================
+# First of all
+#
+# Read libIGCM compatibility version in config.card
+# Read UserChoices section
+# Read Ensemble section
+# Read Post section
+# Define all netcdf output directories
+#==================================
+IGCM_config_CommonConfiguration ${SUBMIT_DIR}/config.card
+
+#==================================
+# Define default value to keep compatibility with previous card: means before changes due to TGCC
+if [ X${PackDefault} = Xtrue ] ; then
+  [ X${config_Post_PackFrequency} = X ] && config_Post_PackFrequency=${config_Post_RebuildFrequency}
+else
+  config_Post_PackFrequency=NONE
+fi
+
+#==================================
+# Is the pack active
+if ( [ ! X${config_Post_PackFrequency} = X${NULL_STR} ] && [ ! X${config_Post_PackFrequency} = XNONE ] ) ; then
+  Pack=true
+fi
+
+IGCM_sys_TestDirArchive ${R_SAVE}
+[ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive"
+
+if [ ! -f ${SUBMIT_DIR}/run.card ]; then
+  echo "You seem NOT to have a run.card in this directory !!"
+  echo "This script will fail because it doesn't know what to do without run.card available."
+  exit 1
+else
+  #===================================#
+  #        Read updated run.card      #
+  #===================================#
+  IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState
+  IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration OldPrefix
+  IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin
+  IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd
+  IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod
+
+  PeriodDateEnd=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateEnd} )
+  echo "Search files with ${PeriodDateEnd} in ${R_SAVE}"
+  set +A ListFiles -- $( IGCM_sys_RshArchive "find ${R_SAVE} -name \"*${PeriodDateEnd}*\" " )
+  CountListFiles=${#ListFiles[@]}
+
+  if [ X${Pack} = Xtrue ] ; then
+    echo "Search files with ${PeriodDateEnd} in ${R_BUFR}"
+    set +A ListFilesBuf -- $( IGCM_sys_RshMaster "find ${R_BUFR} -name \"*${PeriodDateEnd}*\" " )
+    CountListFilesBuf=${#ListFilesBuf[@]}
+  else
+    CountListFilesBuf=0
+  fi
+
+  # If exist, erase REBUILD DIR
+  PeriodDateBegin=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateBegin} )
+  CountRebuildDir=0
+  if [ X${config_Post_RebuildFrequency} != X ] ; then
+    if [ X${config_Post_RebuildFromArchive} = Xtrue ] ; then
+      set +A RebuildDir -- $( IGCM_sys_RshArchive "find ${REBUILD_DIR} -type d -name \"*${PeriodDateBegin}*\" " )
+    else
+      set +A RebuildDir -- $( find ${REBUILD_DIR} -type d -name "*${PeriodDateBegin}*" )
+    fi
+    CountRebuildDir=${#RebuildDir[@]}
+  fi
+
+  IGCM_debug_Print 1 "Number of files to be erased : ${CountListFiles}."
+  if ( [ ${CountListFiles} -gt 0 ] || [ ${CountListFilesBuf} -gt 0 ] ) ; then
+    for file in ${ListFiles[@]} ; do
+      IGCM_debug_Print 2 -e "\033[1;31m ${file}\033[m"
+    done
+    if [ X${Pack} = Xtrue ] ; then
+      for file in ${ListFilesBuf[@]} ; do
+        IGCM_debug_Print 2 -e "\033[1;31m ${file}\033[m"
+      done
+    fi
+    echo -e "\033[1;32mDo you REALLY want to erase all those files ?"
+    echo -n -e " Your answer (y/n) : \033[m"
+    read reponse
+    case ${reponse} in
+
+      oui|OUI|o|y|yes|YES)
+        echo "OK. It will be erased."
+        IGCM_sys_RshArchive "find ${R_SAVE} -name \"*${PeriodDateEnd}*\" -exec rm -f '{}' \;"
+        if [ X${Pack} = Xtrue ] ; then
+          IGCM_sys_RshMaster  "find ${R_BUFR} -name \"*${PeriodDateEnd}*\" -exec rm -f '{}' \;"
+        fi
+        echo "done."
+        ;;
+      non|NON|n|no|NO)
+        echo "Nothing to do !"
+        ;;
+    esac
+  fi
+
+  if [ ${CountRebuildDir} -gt 0 ] ; then
+    IGCM_debug_Print 1 "Number of REBUILD Dirs to be erased : ${CountRebuildDir}."
+    for Dir in ${RebuildDir[@]} ; do
+      IGCM_debug_Print 2 -e "\033[1;31m ${Dir}\033[m"
+    done
+
+    echo -e "\033[1;32mDo you REALLY want to erase all those Directories ?"
+    echo -n -e " Your answer (y/n) : \033[m"
+    read reponse
+    case ${reponse} in
+
+      oui|OUI|o|y|yes|YES)
+        echo "OK. It will be erased."
+        if [ X${config_Post_RebuildFromArchive} = Xtrue ] ; then
+          IGCM_sys_RshArchive "find ${REBUILD_DIR} -type d -name \"*${PeriodDateBegin}*\" -exec rm -Rf '{}' \;"
+        else
+          find ${REBUILD_DIR} -type d -name "*${PeriodDateBegin}*" -exec rm -Rf '{}' \;
+        fi
+        echo "done."
+        ;;
+      non|NON|n|no|NO)
+        echo "Nothing to do !"
+        ;;
+    esac
+  fi
+
+  IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState
+  if ( [ ${run_Configuration_PeriodState} != "Running" ] && [ ${run_Configuration_PeriodState} != "OnQueue" ] && [ ${run_Configuration_PeriodState} != "Continue" ] ) ; then
+
+    echo -e "\033[1;32mNOW do you want to continue the simulation (Set PeriodState=OnQueue into run.card) ?"
+    echo -n -e " Your answer (y/n) : \033[m"
+    read reponse
+    case ${reponse} in
+
+      oui|OUI|o|y|yes|YES)
+        echo "OK. Now you can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}."
+        IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "OnQueue"
+        ;;
+      non|NON|n|no|NO)
+        echo "Nothing to do !"
+        ;;
+    esac
+  else
+    echo "You can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}."
+  fi
+
+  if ( [ X${run_Configuration_CumulPeriod} = X ] || [ X${run_Configuration_CumulPeriod} = X1 ] ); then
+
+    echo -e "\033[1;32mCumulPeriod=1 so we want to erase run.card to start properly. Do you want that too?"
+    echo -n -e " Your answer (y/n) : \033[m"
+    read reponse
+    case ${reponse} in
+
+      oui|OUI|o|y|yes|YES)
+        echo "OK. Now you can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}."
+        IGCM_sys_Rm ${SUBMIT_DIR}/run.card
+        ;;
+      non|NON|n|no|NO)
+        echo "Nothing to do !"
+        ;;
+    esac
+
+  fi
+fi
+exit 0
Index: /tags/libIGCM_v2.2/AA_clean_year
===================================================================
--- /tags/libIGCM_v2.2/AA_clean_year	(revision 998)
+++ /tags/libIGCM_v2.2/AA_clean_year	(revision 998)
@@ -0,0 +1,311 @@
+#!/bin/ksh
+#**************************************************************
+# Author: Martial Mancip
+# Contact: Martial.Mancip__at__ipsl.jussieu.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#set -eu
+#set -vx
+
+libIGCM=::modipsl::/libIGCM
+
+#D- Task type (computing or post-processing)
+TaskType=post-processing
+
+#D--------------------------------------------------------------------==
+#D-                   -1. User modification place
+#D--------------------------------------------------------------------==
+
+#D- Increased verbosity (1, 2, 3)
+Verbosity=3
+
+#D- Low level debug : to bypass lib test checks and stack construction
+#D- Default=true
+DEBUG_debug=false
+
+#D--------------------------------------------------------------------==
+
+echo "clean year script :"
+echo "Script used to clean a year on SAVE directory !"
+echo "This script will erase some files !!! Be careful and read all informations !"
+echo "----"
+echo "It must be called in Experience directory (so-called SUBMIT_DIR)."
+echo "----"
+
+#D--------------------------------------------------------------------==
+
+. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
+. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
+. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
+#-------
+SUBMIT_DIR=$( pwd )
+. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
+. ${libIGCM}/libIGCM_config/libIGCM_config.ksh
+#-------
+( ${DEBUG_debug} ) && IGCM_debug_Check
+( ${DEBUG_debug} ) && IGCM_card_Check
+( ${DEBUG_debug} ) && IGCM_date_Check
+
+#==================================
+# First of all
+#
+# Read libIGCM compatibility version in config.card
+# Read UserChoices section
+# Read Ensemble section
+# Read Post section
+# Define all netcdf output directories
+#==================================
+IGCM_config_CommonConfiguration ${SUBMIT_DIR}/config.card
+
+#==================================
+# Define default value to keep compatibility with previous card: means before changes due to TGCC
+if [ X${PackDefault} = Xtrue ] ; then
+  [ X${config_Post_PackFrequency} = X ] && config_Post_PackFrequency=${config_Post_RebuildFrequency}
+else
+  config_Post_PackFrequency=NONE
+fi
+
+#==================================
+# Is the pack active
+if ( [ ! X${config_Post_PackFrequency} = X${NULL_STR} ] && \
+     [ ! X${config_Post_PackFrequency} = XNONE ] ) ; then
+  Pack=true
+fi
+
+IGCM_sys_TestDirArchive ${R_SAVE}
+[ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive"
+
+if [ ! -f ${SUBMIT_DIR}/run.card ]; then
+    echo "You seem NOT to have a run.card in this directory !!"
+    echo "This script will fail because it doesn't know what to do without run.card available."
+    exit 1
+fi
+
+#===================================#
+#        Read updated run.card      #
+#===================================#
+IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState
+IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration OldPrefix
+IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin
+IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd
+IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod
+if [ X${run_Configuration_CumulPeriod} == X ] ; then
+  ${run_Configuration_CumulPeriod} = 0
+fi
+
+
+PreviousPeriodDateEnd=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateEnd} )
+PreviousPeriodDateBegin=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateBegin} )
+
+IGCM_date_GetYearMonth ${PreviousPeriodDateEnd} PreviousPeriodYear PreviousPeriodMonth
+
+if [ $# == 1 ] ; then
+  if [ ${#1} != 4 ] ; then
+    echo "You must give a year (SSAA) as argument."
+    exit 1
+  fi
+  ReferenceYear=$1
+else
+  ReferenceYear=${PreviousPeriodYear}
+fi
+RemovedPeriods=0
+
+# Colors
+Red="\033[1;31m"
+Green="\033[1;32m"
+NoColor="\033[0m"
+
+while [ ${PreviousPeriodYear} -ge ${ReferenceYear} ] ; do
+
+  PeriodDateEnd=${PreviousPeriodDateEnd}
+  PeriodDateBegin=${PreviousPeriodDateBegin}
+  PeriodYear=${PreviousPeriodYear}
+  PeriodMonth=${PreviousPeriodMonth}
+
+  echo "Search files with ${PeriodDateEnd} in ${R_SAVE}"
+  unset ListFiles
+  set +A ListFiles -- $( IGCM_sys_RshArchive "find ${R_SAVE} -name \"*${PeriodDateEnd}*\" " )
+  CountListFiles=${#ListFiles[@]}
+
+  if [ X${Pack} = Xtrue ] ; then
+    echo "Search files with ${PeriodDateEnd} in ${R_BUFR}"
+    unset ListFilesBuf
+    set +A ListFilesBuf -- $( IGCM_sys_RshMaster "find ${R_BUFR} -name \"*${PeriodDateEnd}*\" " )
+    CountListFilesBuf=${#ListFilesBuf[@]}
+  else
+    CountListFilesBuf=0
+  fi
+
+  # If exist, erase REBUILD DIR
+  CountRebuildDir=0
+  if [ X${config_Post_RebuildFrequency} != X ] ; then
+    echo "Search directories with ${PeriodDateBegin} in REBUILD_DIR"
+    unset RebuildDir
+    if [ X${config_Post_RebuildFromArchive} == Xtrue ] ; then
+      set +A RebuildDir -- $( IGCM_sys_RshArchive "find ${REBUILD_DIR} -type d -name \"*${PeriodDateBegin}*\" " )
+    else
+      set +A RebuildDir -- $( find ${REBUILD_DIR} -type d -name  "*${PeriodDateBegin}*" )
+    fi
+    CountRebuildDir=${#RebuildDir[@]}
+  fi
+
+
+  if ( [ ${CountListFiles} -gt 0 ] || [ ${CountListFilesBuf} -gt 0 ] ) ; then
+    IGCM_debug_Print 1 "Number of files to be erased from ${R_SAVE} : ${CountListFiles}."
+    for file in ${ListFiles[@]} ; do
+      IGCM_debug_Print 2 -e "${Red} ${file}${NoColor}"
+    done
+    if [ X${Pack} = Xtrue ] ; then
+      IGCM_debug_Print 1 "Number of files to be erased from ${R_BUFR} : ${CountListFilesBuf}."
+      for file in ${ListFilesBuf[@]} ; do
+        IGCM_debug_Print 2 -e "${Red} ${file}${NoColor}"
+      done
+    fi
+
+    echo -e "${Green}Do you REALLY want to erase all those files ?"
+    echo -n -e " Your answer (y/n) : ${NoColor}"
+
+    read reponse
+    case ${reponse} in
+      oui|OUI|o|y|yes|YES)
+        echo "OK. It will be erased."
+        IGCM_sys_RshArchive "find ${R_SAVE} -name \"*${PeriodDateEnd}*\" -exec rm -f '{}' \;"
+        if [ X${Pack} = Xtrue ] ; then
+          IGCM_sys_RshMaster  "find ${R_BUFR} -name \"*${PeriodDateEnd}*\" -exec rm -f '{}' \;"
+        fi
+        echo "done."
+        ;;
+      non|NON|n|no|NO)
+        echo "Nothing to do !"
+        ;;
+    esac
+  fi
+
+  if [ ${CountRebuildDir} -gt 0 ] ; then
+    IGCM_debug_Print 1 "Number of REBUILD Dirs to be erased : ${CountRebuildDir}."
+    for Dir in ${RebuildDir[@]} ; do
+      IGCM_debug_Print 2 -e "${Red} ${Dir}${NoColor}"
+    done
+
+    echo -e "${Green}Do you REALLY want to erase all those Directories ?"
+    echo -n -e " Your answer (y/n) : ${NoColor}"
+
+    read reponse
+    case ${reponse} in
+
+      oui|OUI|o|y|yes|YES)
+        echo "OK. It will be erased."
+        if [ X${config_Post_RebuildFromArchive} = Xtrue ] ; then
+          IGCM_sys_RshArchive "find ${REBUILD_DIR} -type d -name \"*${PeriodDateBegin}*\" -exec rm -Rf '{}' \;"
+        else
+          find ${REBUILD_DIR} -type d -name "*${PeriodDateBegin}*" -exec rm -Rf '{}' \;
+        fi
+        echo "done."
+        ;;
+      non|NON|n|no|NO)
+        echo "Nothing to do !"
+        ;;
+    esac
+  fi
+
+  (( RemovedPeriods = ${RemovedPeriods} + 1 ))
+
+  # Get previous period begin and end dates
+  PreviousPeriodDateEnd=$( IGCM_date_AddDaysToGregorianDate ${PeriodDateEnd} \
+                               -$( IGCM_date_DaysInMonth ${PeriodYear} ${PeriodMonth} ) )
+  IGCM_date_GetYearMonth ${PreviousPeriodDateEnd} PreviousPeriodYear PreviousPeriodMonth
+
+  PreviousPeriodDateBegin=$( IGCM_date_AddDaysToGregorianDate ${PeriodDateBegin} \
+                         -$( IGCM_date_DaysInMonth ${PreviousPeriodYear} ${PreviousPeriodMonth} ) )
+done
+
+if [ ${RemovedPeriods} == 0 ] ; then
+  echo "Nothing done, exit"
+  exit 0
+fi
+
+IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState
+if ( [ ${run_Configuration_PeriodState} != "Running" ] && \
+     [ ${run_Configuration_PeriodState} != "Continue" ] ) ; then
+
+  (( NewCumulPeriod = ${run_Configuration_CumulPeriod} - ${RemovedPeriods} + 1 ))
+
+  if [ ${NewCumulPeriod} -le 1 ] ; then
+    RemoveRunCard=true
+  else
+    RemoveRunCard=false
+  fi
+
+  Suffix=$( printf '%06i' ${NewCumulPeriod} )
+
+  printf "${Green}Your run.card and Job_${config_UserChoices_JobName} will now be updated\n"
+  printf " - PeriodState = OnQueue ;\n"
+  printf " - PeriodDateBegin, PeriodDateEnd, CumulPeriod and OldPrefix ;\n"
+  printf "   %-10s       %-10s          %6i     %s\n" \
+         $( IGCM_date_HumanDigit ${PeriodDateBegin} ) \
+         $( IGCM_date_HumanDigit ${PeriodDateEnd} ) \
+         ${NewCumulPeriod} \
+         ${config_UserChoices_JobName}_${PreviousPeriodDateEnd}
+  printf " - ScriptOutput = %s" \
+         "Script_Output_${config_UserChoices_JobName}.${Suffix}"
+  printf " Are you OK ? (y/n) ${NoColor}"
+
+  read reponse
+  case ${reponse} in
+    oui|OUI|o|y|yes|YES)
+      if ( ${RemoveRunCard} ) ; then
+        echo "CumulPeriod=1 so we erase run.card to start properly."
+        IGCM_sys_Rm ${SUBMIT_DIR}/run.card
+      else
+        #Â Update run.card
+        cp ${SUBMIT_DIR}/run.card ${SUBMIT_DIR}/run.card.old
+        IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "OnQueue"
+        IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod ${NewCumulPeriod}
+        IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin \
+                              $( IGCM_date_HumanDigit ${PeriodDateBegin} )
+        IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd \
+                              $( IGCM_date_HumanDigit ${PeriodDateEnd} )
+        IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration OldPrefix \
+                              ${config_UserChoices_JobName}_${PreviousPeriodDateEnd}
+        #Â Update job
+        cp Job_${config_UserChoices_JobName} Job_${config_UserChoices_JobName}.old
+        sed -e "s/\(#.*Script_Output_${config_UserChoices_JobName}\.\)\([0-9]*\)\(.*\)/\1${Suffix}\3/" \
+            Job_${config_UserChoices_JobName} > Job_${config_UserChoices_JobName}.tmp
+        mv Job_${config_UserChoices_JobName}.tmp Job_${config_UserChoices_JobName}
+      fi
+      echo "OK. Now you can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}."
+      ;;
+    non|NON|n|no|NO)
+      echo "Nothing to do !"
+      ;;
+  esac
+
+  IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card PostProcessing TimeSeriesCompleted
+  if [ ! X${run_PostProcessing_TimeSeriesCompleted} = X ] ; then
+
+    printf "${Green}TimeSeriesCompleted in run.card : ${run_PostProcessing_TimeSeriesCompleted}. Do we need to change it? (AAAAMMDD) ${NoColor}"
+
+    read reponse
+    case ${reponse} in
+      0*|1*|2*|3*|4*|5*|6*|7*|8*|9*)
+        #Update run.card 
+        cp ${SUBMIT_DIR}/run.card ${SUBMIT_DIR}/run.card.old
+        IGCM_card_WriteOption ${SUBMIT_DIR}/run.card PostProcessing TimeSeriesCompleted "${reponse}"
+        ;;
+      *)
+        echo "Nothing to do !"
+        ;;
+    esac
+  fi
+
+else
+  echo "You can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}."
+fi
+
+exit 0
Index: /tags/libIGCM_v2.2/AA_create_multi_se
===================================================================
--- /tags/libIGCM_v2.2/AA_create_multi_se	(revision 998)
+++ /tags/libIGCM_v2.2/AA_create_multi_se	(revision 998)
@@ -0,0 +1,458 @@
+#-Q- curie ######################
+#-Q- curie ## CURIE   TGCC/CEA ##
+#-Q- curie ######################
+#-Q- curie #MSUB -r MULTISE        # Nom du job
+#-Q- curie #MSUB -eo
+#-Q- curie #MSUB -n 1              # Reservation du processus
+#-Q- curie #MSUB -T 36000          # Limite de temps elapsed du job
+#-Q- curie #MSUB -q xlarge
+#-Q- curie #MSUB -Q normal
+#-Q- curie #MSUB -A ::default_project::
+#-Q- curie set +x
+#-Q- ada #!/bin/ksh
+#-Q- ada #######################
+#-Q- ada ## ADA         IDRIS ##
+#-Q- ada #######################
+#-Q- ada # @ job_type = serial
+#-Q- ada # @ requirements = (Feature == "prepost")
+#-Q- ada # Temps Elapsed max. d'une requete hh:mm:ss
+#-Q- ada # @ wall_clock_limit = 1:00:00
+#-Q- ada # Nom du travail LoadLeveler
+#-Q- ada # @ job_name   = MULTISE
+#-Q- ada # Fichier de sortie standard du travail
+#-Q- ada # @ output     = $(job_name).$(jobid)
+#-Q- ada # Fichier de sortie d'erreur du travail
+#-Q- ada # @ error      =  $(job_name).$(jobid)
+#-Q- ada # pour recevoir un mail en cas de depassement du temps Elapsed (ou autre pb.)
+#-Q- ada # @ notification = error
+#-Q- ada # @ 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_MBG ; $RESOL_SRF ; $RESOL_SBG ; $MASTER
+#-Q- ada # @ queue
+#-Q- lxiv8 ######################
+#-Q- lxiv8 ## OBELIX      LSCE ##
+#-Q- lxiv8 ######################
+#-Q- lxiv8 #PBS -N MULTISE
+#-Q- lxiv8 #PBS -m a
+#-Q- lxiv8 #PBS -j oe
+#-Q- lxiv8 #PBS -q medium
+#-Q- lxiv8 #PBS -o MULTISE.$$
+#-Q- lxiv8 #PBS -S /bin/ksh
+#-Q- default #!/bin/ksh
+#-Q- default ##################
+#-Q- default ## DEFAULT HOST ##
+#-Q- default ##################
+
+#**************************************************************
+# Author: Marie-Alice Foujols
+# Contact: Marie-Alice.Foujols__at__ipsl.jussieu.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#set -eu
+#set -vx
+
+date
+
+#-Q- ada export OMP_NUM_THREADS=1
+
+#D- Task type (computing or post-processing)
+TaskType=post-processing
+
+########################################################################
+
+#D- Flag to determine if this job in a standalone mode
+#D- Default : value from AA_job if any
+StandAlone=${StandAlone:=true}
+
+#D- Path to libIGCM
+#D- Default : value from AA_job if any
+libIGCM=${libIGCM:=::modipsl::/libIGCM}
+
+#D- Flag to determine atlas job's output directory
+#D- Default : value from libIGCM_post.ksh if any
+POST_DIR=${POST_DIR:=${PBS_O_WORKDIR:=$(pwd)}}
+
+#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- TEMPORARY Flag to determine atmospheric resolution
+#D- Default : value from atmospheric driver if any
+RESOL_ATM=${RESOL_ATM:=ALL}
+
+#D- Flag to determine surface resolution
+#D- Default : value from surface driver if any
+RESOL_SRF=ALL
+
+#D- Flag to determine surface resolution
+#D- Default : value from surface driver if any
+RESOL_SBG=ALL
+
+#D- TEMPORARY Flag to determine ocean resolution
+#D- Default : value from ocean driver if any
+RESOL_OCE=${RESOL_OCE:=ORCA2}
+
+#D- TEMPORARY Flag to determine ice resolution
+#D- Default : value from ice driver if any
+RESOL_ICE=${RESOL_ICE:=ORCA2}
+
+#D- TEMPORARY Flag to determine marine biogeochemistry resolution
+#D- Default : value from ice driver if any
+RESOL_MBG=${RESOL_MBG:=ORCA2}
+
+########################################################################
+
+. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
+. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
+. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
+#-------
+. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
+. ${libIGCM}/libIGCM_config/libIGCM_config.ksh
+#-------
+( ${DEBUG_debug} ) && IGCM_debug_Check
+( ${DEBUG_debug} ) && IGCM_card_Check
+( ${DEBUG_debug} ) && IGCM_date_Check
+
+########################################################################
+
+#set -vx
+
+IGCM_sys_MkdirWork ${RUN_DIR_PATH}
+IGCM_sys_Cd ${RUN_DIR_PATH}
+
+# ------------------------------------------------------------------
+# Test if all was right before proceeding further
+# ------------------------------------------------------------------
+IGCM_debug_Verif_Exit_Post
+
+if [ ${StandAlone} = true ] ; then
+  CARD_DIR=${SUBMIT_DIR}
+else
+  CARD_DIR=${RUN_DIR_PATH}
+  IGCM_sys_Get_Master ${SUBMIT_DIR}/config.card ${RUN_DIR_PATH}
+  IGCM_sys_Get_Master ${SUBMIT_DIR}/run.card    ${RUN_DIR_PATH}
+  IGCM_sys_Get_Master ${SUBMIT_DIR}/COMP        ${RUN_DIR_PATH}
+  IGCM_sys_Get_Master ${SUBMIT_DIR}/POST        ${RUN_DIR_PATH}
+fi
+
+#==================================
+# First of all
+#
+# Read libIGCM compatibility version in config.card
+# Read UserChoices section
+# Read Ensemble section
+# Read Post section
+# Define all netcdf output directories
+#==================================
+IGCM_config_CommonConfiguration ${CARD_DIR}/config.card
+
+#==================================
+# Read ListOfComponents section:
+IGCM_card_DefineArrayFromSection   ${CARD_DIR}/config.card ListOfComponents
+
+#==================================
+# Read SeasonalFrequency:
+IGCM_card_DefineArrayFromSection   ${CARD_DIR}/config.card Post
+
+#
+# If option MultiSeasonalFrequency is not found (optionnal) put MultiSeasonalFrequency=50Y
+#
+FoundMultiSeasonal=false
+for option in ${config_Post[*]} ; do
+  if [ ${option} = MultiSeasonalFrequency ] ; then
+    FoundMultiSeasonal=true
+    IGCM_card_DefineVariableFromOption ${CARD_DIR}/config.card Post MultiSeasonalFrequency
+  fi
+done
+if [ ! X${FoundMultiSeasonal} = Xtrue ] ; then
+  config_Post_MultiSeasonalFrequency=50Y
+fi
+#
+IGCM_card_DefineVariableFromOption ${CARD_DIR}/config.card Post SeasonalFrequency
+#
+# Determine period for seasonnal average. Default : value from AA_job if any
+#
+DateBegin=${DateBegin:=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateBegin} )}
+#
+PeriodDateEnd=${PeriodDateEnd:=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} )}
+#
+IGCM_debug_Print 1 "DefineVariableFromOption : Post "
+IGCM_debug_PrintVariables 3 config_Post_SeasonalFrequency
+IGCM_debug_PrintVariables 3 config_Post_MultiSeasonalFrequency
+echo
+
+#
+freq=$( echo ${config_Post_SeasonalFrequency} |  sed -e "s/[yY]//" )
+#
+multifreq=$( echo ${config_Post_MultiSeasonalFrequency} |  sed -e "s/[yY]//" )
+#
+DIR_OUT=SE_${multifreq}Y
+#
+an_multi_fin=$(( $( IGCM_date_ConvertGregorianDateToJulian ${PeriodDateEnd} ) / 1000 ))
+an_multi_deb=$( IGCM_date_YearDigit $(( an_multi_fin - multifreq + 1 )) )
+an_multi_fin=$( IGCM_date_YearDigit ${an_multi_fin} )
+#
+# For each component selected determine which files need post-processing
+#
+for comp in ${config_ListOfComponents[*]} ; do
+  #
+  IGCM_card_DefineArrayFromOption ${CARD_DIR}/config.card ListOfComponents ${comp}
+  eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1
+  #
+  card=${CARD_DIR}/COMP/${compname}.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
+    #
+    # INITIALISATION
+    #
+    eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1
+    typeset i=2
+    #
+    until [ $i -gt $NbFiles ]; do
+      #
+      eval flag_post=\${${ListFilesName}[$i]} > /dev/null 2>&1
+      #
+      if [ X${flag_post} != XNONE ] ; then
+        #
+        # Check if seasonal is required for this file
+        #
+        IGCM_card_DefineArrayFromSection ${card} ${flag_post}
+        #
+        # Seasonal case : If option Seasonal is not found (old cards) put SEASONAL ON by default
+        #
+        # variable option allready typeset above
+        for option in $( eval echo \${${compname}_${flag_post}[*]} ) ; do
+          if [ ${option} = Seasonal ] ; then
+            FoundSeasonal=true
+            IGCM_card_DefineVariableFromOption ${card} ${flag_post} Seasonal
+          fi
+        done
+        #
+        if [ ! X${FoundSeasonal} = Xtrue ] ; then
+          eval ${compname}_${flag_post}_Seasonal=ON
+        fi
+        #
+        if [ ! X$( eval echo \${${compname}_${flag_post}_Seasonal} ) = XON ] ; then
+          (( i=i+3 ))
+          continue
+        fi
+        #
+        # CREATE LIST
+        #
+        FILE=$( echo ${flag_post} | awk "-FPost_" '{print $2}' )
+        #
+        DIRECTORY=${R_SAVE}/${comp}/Analyse/SE
+        #
+        MULTI_DIRECTORY=${R_SAVE}/${comp}/Analyse/${DIR_OUT}
+        #
+        TestedFile=${config_UserChoices_JobName}_SE_${an_multi_deb}_${an_multi_fin}_${FILE}.nc
+        #
+        IGCM_sys_TestFileArchive ${MULTI_DIRECTORY}/${TestedFile}
+        if [ ! $? = 0 ] ; then
+          eval set +A LISTE_FILE_${comp} \$\{LISTE_FILE_${comp}[*]} ${FILE}
+        fi
+      fi
+      (( i=i+3 ))
+    done # until [ $i -eq $NbFiles ]
+  fi
+done         # for comp
+
+for comp in ${config_ListOfComponents[*]} ; do
+  #
+  eval R_OUT_${comp}=${R_SAVE}/${comp}
+  #
+  i=0
+  for file in $( eval echo \${LISTE_FILE_${comp}[*]} ); do
+    #
+    RESULT_MULTI_SE=${config_UserChoices_JobName}_SE_${an_multi_deb}_${an_multi_fin}_${file}.nc
+    # Do not redo an existing SE
+    IGCM_sys_TestFileArchive ${R_SAVE}/${comp}/Analyse/${DIR_OUT}/${RESULT_MULTI_SE}
+    if [ $? = 0 ] ; then
+      continue
+    fi
+    #
+    eval file_path=\${R_OUT_${comp}}/Analyse/SE/
+    #
+    (( an = an_multi_deb ))
+    # Initialize array
+    unset liste_file_se
+    unset liste_file_se_tmp
+    while [ ${an} -le ${an_multi_fin} ] ; do
+      #
+      an_deb=$(printf "%04i\n" ${an} )
+      #
+      (( an_fin = an_deb + freq - 1 ))
+      date=${an_deb}_${an_fin}
+      #
+      liste_file_se[${#liste_file_se[*]}]=${file_path}${config_UserChoices_JobName}_SE_${date}_${file}.nc
+      liste_file_se_tmp[${#liste_file_se_tmp[*]}]=${config_UserChoices_JobName}_SE_${date}_${file}.nc
+      (( an = an + freq ))
+    done
+    #
+    IGCM_sys_Get /l liste_file_se[*] ${RUN_DIR_PATH}
+    IGCM_debug_Verif_Exit_Post
+    # Search of common list of variables to be treated
+    nbfile=0
+    for file_common_var in ${liste_file_se_tmp[*]} ; do
+      ncdump -h ${file_common_var} | grep -E 'float|double' | cut -f 1 -d '(' | cut -f 2 -d ' ' >> tmpfile_ncra
+      (( nbfile = nbfile + 1 ))
+    done
+    list_var_final_ncra=`cat tmpfile_ncra | sort | uniq -c | awk -v nbfile=$nbfile '{if ($1 == nbfile) {print $2}}' | paste -s -d ','`
+    IGCM_sys_Rm tmpfile_ncra
+
+    # detect time counter : time or time_counter ie unlimited variable
+    var_unlim=$(ncdump -h ${liste_file_se_tmp[1]}|grep UNLIMITED|awk '{print $1}')
+
+    for mois in  01 02 03 04 05 06 07 08 09 10 11 12 ; do
+      #
+      (( nb = ${mois} - 1 ))
+      #
+      OUT_SE[${nb}]=${config_UserChoices_JobName}_SE${mois}_${an_deb}_${an_fin}_${file}.nc
+      IGCM_sys_ncra -O -v ${list_var_final_ncra} -d ${var_unlim},${nb},,12 ${liste_file_se_tmp[*]} ${OUT_SE[${nb}]}
+    done
+    IGCM_sys_Rm ${liste_file_se_tmp[*]}
+    #
+
+    # Search of common list of variables to be treated
+    nbfile=0
+    for file_common_var in ${OUT_SE[*]} ; do
+      ncdump -h ${file_common_var} | grep -E 'float|double' | cut -f 1 -d '(' | cut -f 2 -d ' ' >> tmpfile_ncrcat
+      (( nbfile = nbfile + 1 ))
+    done
+    list_var_final_ncrcat=`cat tmpfile_ncrcat | sort | uniq -c | awk -v nbfile=$nbfile '{if ($1 == nbfile) {print $2}}' | paste -s -d ','`
+    IGCM_sys_Rm tmpfile_ncrcat
+
+    IGCM_sys_ncrcat -O -v ${list_var_final_ncrcat} ${OUT_SE[*]} ${RESULT_MULTI_SE}
+    #
+    IGCM_sys_Rm ${OUT_SE[*]}
+
+    # Put correct climatological axis following calendar
+    case ${config_UserChoices_CalendarType} in
+      360d|360_day)
+      # 360 days
+        ncap2cmd="'defdim(\"tbnds\",2) ; ${var_unlim}[${var_unlim}]={15, 45, 75, 105, 135, 165, 195, 225, 255, 285, 315, 345.} ; ${var_unlim}_bnds[${var_unlim},tbnds]={0, 30, 30, 60, 60, 90, 90, 120, 120, 150, 150, 180, 180, 210, 210, 240, 240, 270, 270, 300, 300, 330, 330, 360.} ; ${var_unlim}@units=\"days since 0000-01-01 00:00:00\" ; ${var_unlim}@time_origin=\"01-JAN-0000 00:00:00\" ; ${var_unlim}@calendar=\"360_day\" ; ${var_unlim}@bounds=\"${var_unlim}_bnds\"'"
+        ;;
+      noleap|365_day)
+      # 365 days
+        ncap2cmd="'defdim(\"tbnds\",2) ; ${var_unlim}[${var_unlim}]={15.5, 45, 74.5, 105, 135.5, 166, 196.5, 227.5, 258, 288.5, 319, 349.5} ; ${var_unlim}_bnds[${var_unlim},tbnds]={0, 31, 31, 59, 59, 90, 90, 120, 120, 151, 151, 181, 181, 212, 212, 243, 243, 273, 273, 304, 304, 334, 334, 365.} ; ${var_unlim}@units=\"days since 0000-01-01 00:00:00\" ; ${var_unlim}@time_origin=\"01-JAN-0000 00:00:00\" ; ${var_unlim}@calendar=\"365_day\" ; ${var_unlim}@bounds=\"${var_unlim}_bnds\"'"
+        ;;
+      all_leap|366_day)
+      # 366 days
+        ncap2cmd="'defdim(\"tbnds\",2) ; ${var_unlim}[${var_unlim}]={15.5, 45.5, 75.5, 106, 136.5, 167, 197.5, 228.5, 259, 289.5, 320, 350.5} ; ${var_unlim}_bnds[${var_unlim},tbnds]={0, 31, 31, 60, 60, 91, 91, 121, 121, 152, 152, 182, 182, 213, 213, 244, 244, 274, 274, 305, 305, 335, 335, 366.} ; ${var_unlim}@units=\"days since 0000-01-01 00:00:00\" ; ${var_unlim}@time_origin=\"01-JAN-0000 00:00:00\" ; ${var_unlim}@calendar=\"366_day\" ; ${var_unlim}@bounds=\"${var_unlim}_bnds\"'"
+        ;;
+      leap|gregorian|standard)
+      # 365.2425 days
+        ncap2cmd="'defdim(\"tbnds\",2) ; ${var_unlim}[${var_unlim}]={15.5, 45.12125, 74.7425, 105.2425, 135.7425, 166.2425, 196.7425, 227.7425, 258.2425, 288.7425, 319.2425, 349.7425} ; ${var_unlim}_bnds[${var_unlim},tbnds]={0, 31, 31, 59.2425, 59.2425, 90.2425, 90.2425, 120.2425, 120.2425, 151.2425, 151.2425, 181.2425, 181.2425, 212.2425, 212.2425, 243.2425, 243.2425, 273.2425, 273.2425, 304.2425, 304.2425, 334.2425, 334.2425, 365.2425} ; ${var_unlim}@units=\"days since 0000-01-01 00:00:00\" ; ${var_unlim}@time_origin=\"01-JAN-0000 00:00:00\" ; ${var_unlim}@calendar=\"gregorian\" ; ${var_unlim}@bounds=\"${var_unlim}_bnds\"'"
+        ;;
+    esac
+    eval IGCM_sys_ncap2 -Oh -s $ncap2cmd ${RESULT_MULTI_SE} tmp.nc
+    IGCM_sys_Rm ${RESULT_MULTI_SE}
+    IGCM_sys_Mv tmp.nc ${RESULT_MULTI_SE}
+    #
+    eval IGCM_sys_Put_Out ${RESULT_MULTI_SE} \${R_OUT_${comp}}/Analyse/${DIR_OUT}/${RESULT_MULTI_SE}
+    IGCM_sys_Rm ${RESULT_MULTI_SE}
+    #
+  done
+done
+
+# DODS copy
+if [ X${config_Post_DodsCopy} = XTRUE ]  ; then
+  for comp in ${config_ListOfComponents[*]} ; do
+    IGCM_sys_TestDirArchive ${R_SAVE}/${comp}/Analyse/${DIR_OUT}
+    [ $? = 0 ] && IGCM_sys_Put_Dods ${comp}/Analyse/${DIR_OUT}
+  done
+fi
+
+# Temporal coverage id for atlas
+YEARS=${an_multi_deb}_${an_multi_fin}
+
+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_MBG ; export RESOL_SRF ; export RESOL_SBG
+export R_SAVE; export config_UserChoices_JobName; export config_UserChoices_TagName; export YEARS; export DIR_OUT
+listVarEnv="POST_DIR,SUBMIT_DIR,libIGCM,R_INIT,R_BC,StandAlone,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_MBG,RESOL_SRF,RESOL_SBG,R_SAVE,config_UserChoices_JobName,config_UserChoices_TagName,YEARS,DIR_OUT"
+export listVarEnv;
+
+#D-
+# --------------------------------------------------------------------
+#D- Test if all was right before ATLAS
+# --------------------------------------------------------------------
+IGCM_debug_Verif_Exit_Post
+
+if [ ${config_UserChoices_TagName} = "IPSLCM4_v1_OASIS3" ] || \
+   [ ${config_UserChoices_TagName} = "IPSLCM4_v2" ]        || \
+   [ ${config_UserChoices_TagName} = "IPSL_ESM_V1" ] ; then
+  #
+  Script_Post_Output=atlas_ORCHIDEE.${PeriodDateEnd} ;
+  IGCM_sys_QsubPost atlas_ORCHIDEE                   ;
+  Script_Post_Output=atlas_LDMZ.${PeriodDateEnd}     ;
+  IGCM_sys_QsubPost atlas_LMDZ                       ;
+  Script_Post_Output=atlas_ORCA_LIM.${PeriodDateEnd} ;
+  IGCM_sys_QsubPost atlas_ORCA_LIM                   ;
+  Script_Post_Output=additionnal.${PeriodDateEnd}    ;
+  IGCM_sys_QsubPost additionnal                      ;
+  #
+elif [ ${config_UserChoices_TagName} = "IPSLCM5" ]  || \
+     [ ${config_UserChoices_TagName} = "IPSLCM5A" ] || \
+     [ ${config_UserChoices_TagName} = "IPSLCM5B" ] || \
+     [ ${config_UserChoices_TagName} = "IPSLCM5A-MR" ] ; then
+  Script_Post_Output=atlas_ORCHIDEE.${PeriodDateEnd} ;
+  IGCM_sys_QsubPost atlas_ORCHIDEE                   ;
+  Script_Post_Output=atlas_LDMZ.${PeriodDateEnd}     ;
+  IGCM_sys_QsubPost atlas_LMDZ                       ;
+  Script_Post_Output=atlas_ORCA_LIM.${PeriodDateEnd} ;
+  IGCM_sys_QsubPost atlas_ORCA_LIM                   ;
+  Script_Post_Output=atlas_PISCES.${PeriodDateEnd}   ;
+  IGCM_sys_QsubPost atlas_PISCES                     ;
+  #
+elif [ ${config_UserChoices_TagName} = "LMDZ4OR" ]  || \
+     [ ${config_UserChoices_TagName} = "LMDZOR" ]   || \
+     [ ${config_UserChoices_TagName} = "LMDZ4OR_v2" ] ; then
+  #
+  Script_Post_Output=atlas_LDMZ.${PeriodDateEnd}     ;
+  IGCM_sys_QsubPost atlas_LMDZ                       ;
+  Script_Post_Output=atlas_ORCHIDEE.${PeriodDateEnd} ;
+  IGCM_sys_QsubPost atlas_ORCHIDEE                   ;
+  #
+elif [ ${config_UserChoices_TagName} = "LMDZ" ] ; then
+  #
+  Script_Post_Output=atlas_LDMZ.${PeriodDateEnd}     ;
+  IGCM_sys_QsubPost atlas_LMDZ                       ;
+  #
+elif [ ${config_UserChoices_TagName} = "OL" ]      || \
+     [ ${config_UserChoices_TagName} = "OL2" ] ; then
+  #
+  Script_Post_Output=atlas_ORCHIDEE.${PeriodDateEnd} ;
+  IGCM_sys_QsubPost atlas_ORCHIDEE                   ;
+  #
+elif [ ${config_UserChoices_TagName} = "ORCA2_LIM" ]       ||
+     [ ${config_UserChoices_TagName} = "ORCA2_LIM2" ] ; then
+  #
+  Script_Post_Output=atlas_ORCA_LIM.${PeriodDateEnd} ;
+  IGCM_sys_QsubPost atlas_ORCA_LIM                   ;
+elif [ ${config_UserChoices_TagName} = "ORCA2_LIM2_PISCES" ]  ; then
+  #
+  Script_Post_Output=atlas_ORCA_LIM.${PeriodDateEnd} ;
+  IGCM_sys_QsubPost atlas_ORCA_LIM                   ;
+  Script_Post_Output=atlas_PISCES.${PeriodDateEnd}   ;
+  IGCM_sys_QsubPost atlas_PISCES                     ;
+elif [ ${config_UserChoices_TagName} = "ORCA2_OFF_PISCES" ]  ; then
+  #
+  Script_Post_Output=atlas_PISCES.${PeriodDateEnd}   ;
+  IGCM_sys_QsubPost atlas_PISCES                     ;
+  #
+fi
+
+# Clean RUN_DIR_PATH (necessary for cesium and titane only)
+IGCM_sys_RmRunDir -Rf ${RUN_DIR_PATH}
Index: /tags/libIGCM_v2.2/AA_create_se
===================================================================
--- /tags/libIGCM_v2.2/AA_create_se	(revision 998)
+++ /tags/libIGCM_v2.2/AA_create_se	(revision 998)
@@ -0,0 +1,619 @@
+#-Q- curie ######################
+#-Q- curie ## CURIE   TGCC/CEA ##
+#-Q- curie ######################
+#-Q- curie #MSUB -r SE             # Nom du job
+#-Q- curie #MSUB -eo
+#-Q- curie #MSUB -n 1              # Reservation du processus
+#-Q- curie #MSUB -T 36000          # Limite de temps elapsed du job
+#-Q- curie #MSUB -q xlarge
+#-Q- curie #MSUB -Q normal
+#-Q- curie #MSUB -A ::default_project::
+#-Q- curie set +x
+#-Q- ada #!/bin/ksh
+#-Q- ada #######################
+#-Q- ada ## ADA         IDRIS ##
+#-Q- ada #######################
+#-Q- ada # @ job_type = serial
+#-Q- ada # @ requirements = (Feature == "prepost")
+#-Q- ada # Temps Elapsed max. d'une requete hh:mm:ss
+#-Q- ada # @ wall_clock_limit = 10:00:00
+#-Q- ada # Nom du travail LoadLeveler
+#-Q- ada # @ job_name   = SE
+#-Q- ada # Fichier de sortie standard du travail
+#-Q- ada # @ output     = $(job_name).$(jobid)
+#-Q- ada # Fichier de sortie d'erreur du travail
+#-Q- ada # @ error      =  $(job_name).$(jobid)
+#-Q- ada # pour recevoir un mail en cas de depassement du temps Elapsed (ou autre pb.)
+#-Q- ada # @ notification = error
+#-Q- ada # @ 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_MBG ; $RESOL_SRF ; $RESOL_SBG ; $MASTER
+#-Q- ada # @ queue
+#-Q- lxiv8 ######################
+#-Q- lxiv8 ## OBELIX      LSCE ##
+#-Q- lxiv8 ######################
+#-Q- lxiv8 #PBS -N SE
+#-Q- lxiv8 #PBS -m a
+#-Q- lxiv8 #PBS -j oe
+#-Q- lxiv8 #PBS -q medium
+#-Q- lxiv8 #PBS -o SE.$$
+#-Q- lxiv8 #PBS -S /bin/ksh
+#-Q- default #!/bin/ksh
+#-Q- default ##################
+#-Q- default ## DEFAULT HOST ##
+#-Q- default ##################
+
+#**************************************************************
+# Author: Sebastien Denvil
+# Contact: Sebastien.Denvil__at__ipsl.jussieu.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#set -eu
+#set -vx
+
+date
+
+#-Q- ada export OMP_NUM_THREADS=1
+
+#D- Task type (computing or post-processing)
+TaskType=post-processing
+
+########################################################################
+
+#D- Flag to determine if this job in a standalone mode
+#D- Default : value from AA_job if any
+StandAlone=${StandAlone:=true}
+
+#D- Path to libIGCM
+#D- Default : value from AA_job if any
+libIGCM=${libIGCM:=::modipsl::/libIGCM}
+
+#D- Flag to determine if rebuild process has been performed asynchronously
+#D- Possible value true or false.
+#D- If true raw files has allready been patched by rebuild job
+#D- If false create_ts will patch the raw files
+#D- Default : Value from AA_job if any. Usefull in StandAlone case.
+RebuildFrequency=${RebuildFrequency:=true}
+
+#D- Flag to determine atlas job's output directory
+#D- Default : value from libIGCM_post.ksh if any
+POST_DIR=${POST_DIR:=${PBS_O_WORKDIR:=$(pwd)}}
+
+#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- TEMPORARY Flag to determine atmospheric resolution
+#D- Default : value from atmospheric driver if any
+RESOL_ATM=${RESOL_ATM:=ALL}
+
+#D- Flag to determine surface resolution
+#D- Default : value from surface driver if any
+RESOL_SRF=ALL
+
+#D- Flag to determine surface resolution
+#D- Default : value from surface driver if any
+RESOL_SBG=ALL
+
+#D- TEMPORARY Flag to determine ocean resolution
+#D- Default : value from ocean driver if any
+RESOL_OCE=${RESOL_OCE:=ORCA2}
+
+#D- TEMPORARY Flag to determine ice resolution
+#D- Default : value from ice driver if any
+RESOL_ICE=${RESOL_ICE:=ORCA2}
+
+#D- TEMPORARY Flag to determine marine biogeochemistry resolution
+#D- Default : value from ice driver if any
+RESOL_MBG=${RESOL_MBG:=ORCA2}
+
+########################################################################
+
+. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
+. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
+. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
+#-------
+. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
+. ${libIGCM}/libIGCM_config/libIGCM_config.ksh
+#-------
+( ${DEBUG_debug} ) && IGCM_debug_Check
+( ${DEBUG_debug} ) && IGCM_card_Check
+( ${DEBUG_debug} ) && IGCM_date_Check
+
+########################################################################
+
+#set -vx
+
+IGCM_sys_MkdirWork ${RUN_DIR_PATH}
+IGCM_sys_Cd ${RUN_DIR_PATH}
+
+# ------------------------------------------------------------------
+# Test if all was right before proceeding further
+# ------------------------------------------------------------------
+IGCM_debug_Verif_Exit_Post
+
+if [ ${StandAlone} = true ] ; then
+    CARD_DIR=${SUBMIT_DIR}
+else
+    CARD_DIR=${RUN_DIR_PATH}
+    IGCM_sys_Get_Master ${SUBMIT_DIR}/config.card ${RUN_DIR_PATH}
+    IGCM_sys_Get_Master ${SUBMIT_DIR}/run.card    ${RUN_DIR_PATH}
+    IGCM_sys_Get_Master ${SUBMIT_DIR}/COMP        ${RUN_DIR_PATH}
+    IGCM_sys_Get_Master ${SUBMIT_DIR}/POST        ${RUN_DIR_PATH}
+fi
+
+#==================================
+# First of all
+#
+# Read libIGCM compatibility version in config.card
+# Read UserChoices section
+# Read Ensemble section
+# Read Post section
+# Define all netcdf output directories
+#==================================
+IGCM_config_CommonConfiguration ${CARD_DIR}/config.card
+
+#==================================
+# Define default value to keep compatibility with previous card: means before changes due to TGCC
+if [ X${PackDefault} = Xtrue ] ; then
+  [ X${config_Post_PackFrequency} = X ] && config_Post_PackFrequency=${config_Post_RebuildFrequency}
+else
+  config_Post_PackFrequency=NONE
+fi
+
+#==================================
+# If pack is active then PackFrequency overule the config_UserChoices_PeriodLength
+if ( [ ! X${config_Post_PackFrequency} = X${NULL_STR} ] && [ ! X${config_Post_PackFrequency} = XNONE ] ) ; then
+  config_UserChoices_PeriodLength=${config_Post_PackFrequency}
+fi
+
+#==================================
+# Read ListOfComponents section:
+IGCM_card_DefineArrayFromSection   ${CARD_DIR}/config.card ListOfComponents
+
+#==================================
+# Read SeasonalFrequency:
+IGCM_card_DefineVariableFromOption ${CARD_DIR}/config.card Post SeasonalFrequency
+
+#
+# Determine period for seasonnal average. Default : value from AA_job if any
+#
+DateBegin=${DateBegin:=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateBegin} )}
+#
+PeriodDateEnd=${PeriodDateEnd:=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} )}
+#
+freq=$( echo ${config_Post_SeasonalFrequency} |  sed -e "s/[yY]//" )
+#
+an_fin=$(( $( IGCM_date_ConvertGregorianDateToJulian ${PeriodDateEnd} ) / 1000 ))
+an_deb=$( IGCM_date_YearDigit $(( an_fin - freq + 1 )) )
+an_fin=$( IGCM_date_YearDigit ${an_fin} )
+#
+# For each component selected determine which files need post-processing
+#
+for comp in ${config_ListOfComponents[*]} ; do
+  #
+  IGCM_card_DefineArrayFromOption ${CARD_DIR}/config.card ListOfComponents ${comp}
+  eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1
+  #
+  card=${CARD_DIR}/COMP/${compname}.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
+    #
+    # INITIALISATION
+    #
+    eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1
+    typeset i=2
+    #
+    until [ $i -gt $NbFiles ]; do
+      #
+      eval flag_post=\${${ListFilesName}[$i]} > /dev/null 2>&1
+      #
+      if [ X${flag_post} != XNONE ] ; then
+        #
+        # Check if seasonal is required for this file
+        #
+        IGCM_card_DefineArrayFromSection ${card} ${flag_post}
+        #
+        # Seasonal case : If option Seasonal is not found (old cards) put SEASONAL ON by default
+        #
+        # variable option allready typeset above
+        for option in $( eval echo \${${compname}_${flag_post}[*]} ) ; do
+          if [ ${option} = Seasonal ] ; then
+            FoundSeasonal=true
+            IGCM_card_DefineVariableFromOption ${card} ${flag_post} Seasonal
+          fi
+        done
+        #
+        if [ ! X${FoundSeasonal} = Xtrue ] ; then
+            eval ${compname}_${flag_post}_Seasonal=ON
+        fi
+        #
+        if [ ! X$( eval echo \${${compname}_${flag_post}_Seasonal} ) = XON ] ; then
+          (( i=i+3 ))
+          continue
+        fi
+        #
+        # CREATE LIST
+        #
+        FILE=$( echo ${flag_post} | awk "-FPost_" '{print $2}' )
+        #
+        DIRECTORY=${R_SAVE}/${comp}/Analyse/SE
+        #
+        TestedFile=${config_UserChoices_JobName}_SE_${an_deb}_${an_fin}_${FILE}.nc
+        #
+        IGCM_sys_TestFileArchive ${DIRECTORY}/${TestedFile}
+        if [ ! $? = 0 ] ; then
+          eval set +A LISTE_FILE_${comp} \$\{LISTE_FILE_${comp}[*]} ${FILE}
+          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
+      (( i=i+3 ))
+    done # until [ $i -eq $NbFiles ]
+  fi
+done         # for comp
+
+for comp in ${config_ListOfComponents[*]} ; do
+  #
+  eval R_OUT_${comp}=${R_SAVE}/${comp}
+  #
+  i=0
+  for file in $( eval echo \${LISTE_FILE_${comp}[*]} ); do
+    #
+    # Determine in which output can we find file
+    # IE : Output/MO or Output/DA or ...
+    #
+    FlagDir=$( echo ${file} | awk -F "_" '{print $1}' )
+    case ${FlagDir} in
+      1Y)    FreqDir=YE  ;;
+      1M)    FreqDir=MO  ;;
+      5D|1D) FreqDir=DA  ;;
+      HF)    FreqDir=HF  ;;
+      3H)    FreqDir=HF  ;;
+      INS)   FreqDir=INS ;;
+    esac
+    #
+    RESULT_SE=${config_UserChoices_JobName}_SE_${an_deb}_${an_fin}_${file}.nc
+    # Do not redoo an existing SE
+    IGCM_sys_TestFileArchive ${R_SAVE}/${comp}/Analyse/SE/${RESULT_SE}
+    if [ $? = 0 ] ; then
+      continue
+    fi
+    #
+    eval file_path=\${R_OUT_${comp}}/Output/${FreqDir}/
+    #
+    case ${config_UserChoices_PeriodLength} in
+      # For Yearly simulation :
+      *Y|*y)
+        PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | sed -e 's/[yY]//' )
+        (( an = an_deb ))
+        # Initialize array
+        unset liste_file_se
+        unset liste_file_se_tmp
+        while [ ${an} -le ${an_fin} ] ; do
+          #
+          an4=$(printf "%04i\n" ${an} )
+          #
+          diy=$( IGCM_date_DaysInCurrentPeriod ${an4}0101 ${config_UserChoices_PeriodLength} )
+          afin=$( IGCM_date_AddDaysToGregorianDate ${an4}0101 $(( diy - 1 )) )
+          #
+          date=${an4}0101_${afin}
+          #
+          liste_file_se[${#liste_file_se[*]}]=${file_path}${config_UserChoices_JobName}_${date}_${file}.nc
+          liste_file_se_tmp[${#liste_file_se_tmp[*]}]=${config_UserChoices_JobName}_${date}_${file}.nc
+          (( an = an + ${PeriodLengthInYears} ))
+        done
+        #
+        IGCM_sys_Get /l liste_file_se[*] ${RUN_DIR_PATH}
+        IGCM_debug_Verif_Exit_Post
+
+        # Apply IGCM_Patch if needed
+        if [ ! ${RebuildFrequency} = true ] ; then
+          if [ X$( eval echo \${LISTE_PATCHES_${file}[0]} ) !=  X${NULL_STR} ]; then
+            for file_t in $( eval echo ${liste_file_se_tmp[*]} ); do
+              for Patch in $( eval echo \${LISTE_PATCHES_${file}[*]} ); do
+                IGCM_${Patch} ${file_t}
+              done
+            done
+          fi
+        fi
+
+        # Search of common list of variables to be treated
+        nbfile=0
+        for file_common_var in ${liste_file_se_tmp[*]} ; do
+          ncdump -h ${file_common_var} | grep -E 'float|double' | cut -f 1 -d '(' | cut -f 2 -d ' ' >> tmpfile_ncra
+          (( nbfile = nbfile + 1 ))
+        done
+        list_var_final_ncra=`cat tmpfile_ncra | sort | uniq -c | awk -v nbfile=$nbfile '{if ($1 == nbfile) {print $2}}' | paste -s -d ','`
+        IGCM_sys_Rm tmpfile_ncra
+
+        # detect time counter : time or time_counter ie unlimited variable
+        var_unlim=$(ncdump -h ${liste_file_se_tmp[0]}|grep UNLIMITED|awk '{print $1}')
+
+        for mois in  01 02 03 04 05 06 07 08 09 10 11 12 ; do
+          #
+          (( nb = ${mois} - 1 ))
+          #
+          OUT_SE[${nb}]=${config_UserChoices_JobName}_SE${mois}_${an_deb}_${an_fin}_${file}.nc
+          IGCM_sys_ncra -O -v ${list_var_final_ncra} -d ${var_unlim},${nb},,12 ${liste_file_se_tmp[*]} ${OUT_SE[${nb}]}
+        done
+        IGCM_sys_Rm ${liste_file_se_tmp[*]}
+        ;;
+      # For Monthly simulation :
+      1M|1m)
+        for mois in 01 02 03 04 05 06 07 08 09 10 11 12 ; do
+          #
+          (( nb = ${mois} - 1 ))
+          #
+          OUT_SE[${nb}]=${config_UserChoices_JobName}_SE${mois}_${an_deb}_${an_fin}_${file}.nc
+          #
+          (( an = an_deb ))
+          # Initialize array
+          unset liste_file_se
+          unset liste_file_se_tmp
+          while [ ${an} -le ${an_fin} ] ; do
+            moisL=$( IGCM_date_DaysInMonth ${an} ${mois} )
+            #
+            an4=$(printf "%04i\n" ${an} )
+            #
+            date=${an4}${mois}01_${an4}${mois}${moisL}
+            #
+            liste_file_se[${#liste_file_se[*]}]=${file_path}${config_UserChoices_JobName}_${date}_${file}.nc
+            liste_file_se_tmp[${#liste_file_se_tmp[*]}]=${config_UserChoices_JobName}_${date}_${file}.nc
+
+            (( an = an + 1 ))
+          done
+          #
+          IGCM_sys_Get /l liste_file_se[*] ${RUN_DIR_PATH}
+          IGCM_debug_Verif_Exit_Post
+
+          # Apply IGCM_Patch if needed
+          if [ ! ${RebuildFrequency} = true ] ; then
+            if [ X$( eval echo \${LISTE_PATCHES_${file}[0]} ) !=  X${NULL_STR} ]; then
+              for file_t in $( eval echo ${liste_file_se_tmp[*]} ); do
+                for Patch in $( eval echo \${LISTE_PATCHES_${file}[*]} ); do
+                  IGCM_${Patch} ${file_t}
+                done
+              done
+            fi
+          fi
+
+          # Search of common list of variables to be treated
+          nbfile=0
+          for file_common_var in ${liste_file_se_tmp[*]} ; do
+            ncdump -h ${file_common_var} | grep -E 'float|double' | cut -f 1 -d '(' | cut -f 2 -d ' ' >> tmpfile_ncra
+            (( nbfile = nbfile + 1 ))
+          done
+            list_var_final_ncra=`cat tmpfile_ncra | sort | uniq -c | awk -v nbfile=$nbfile '{if ($1 == nbfile) {print $2}}' | paste -s -d ','`
+          IGCM_sys_Rm tmpfile_ncra
+
+          IGCM_sys_ncra -O -v ${list_var_final_ncra} ${liste_file_se_tmp[*]} ${OUT_SE[${nb}]}
+
+          IGCM_sys_Rm ${liste_file_se_tmp[*]}
+        done
+        ;;
+      *D|*d)
+        for mois in 01 02 03 04 05 06 07 08 09 10 11 12 ; do
+          #
+          (( nb = ${mois} - 1 ))
+          #
+          OUT_SE[${nb}]=${config_UserChoices_JobName}_SE${mois}_${an_deb}_${an_fin}_${file}.nc
+          #
+          (( an = an_deb ))
+          # Initialize array
+          unset liste_file_se
+          unset liste_file_se_tmp
+          while [ ${an} -le ${an_fin} ] ; do
+            moisL=$( IGCM_date_DaysInMonth ${an} ${mois} )
+            #
+            an4=$(printf "%04i\n" ${an} )
+              #
+            length_d=$(( ${config_UserChoices_PeriodLength} - 1 ))
+            # for one day
+            if [ ${length_d} -eq 1 ] ; then
+              (( length_d = 0 ))
+            fi
+            (( day  = 1 ))
+            while [ ${day} -le ${moisL} ] ; do
+              day2=$(printf "%02i\n" ${day} )
+              day_beg=${an4}${mois}${day2}
+              day_end=$( IGCM_date_AddDaysToGregorianDate ${day_beg} ${length_d} )
+              date=${an4}${mois}${day_beg}_${an4}${mois}${day_end}
+              #
+              liste_file_se[${#liste_file_se[*]}]=${file_path}${config_UserChoices_JobName}_${date}_${file}.nc
+              liste_file_se_tmp[${#liste_file_se_tmp[*]}]=${config_UserChoices_JobName}_${date}_${file}.nc
+              (( day = day + 1 ))
+            done
+            (( an = an + 1 ))
+          done
+          #
+          IGCM_sys_Get /l liste_file_se[*] ${RUN_DIR_PATH}
+          IGCM_debug_Verif_Exit_Post
+
+          # Apply IGCM_Patch if needed
+          if [ ! ${RebuildFrequency} = true ] ; then
+            if [ X$( eval echo \${LISTE_PATCHES_${file}[0]} ) !=  X${NULL_STR} ]; then
+              for file_t in $( eval echo ${liste_file_se_tmp[*]} ); do
+                for Patch in $( eval echo \${LISTE_PATCHES_${file}[*]} ); do
+                  IGCM_${Patch} ${file_t}
+                done
+              done
+            fi
+          fi
+
+          # Search of common list of variables to be treated
+          nbfile=0
+          for file_common_var in ${liste_file_se_tmp[*]} ; do
+            ncdump -h ${file_common_var} | grep -E 'float|double' | cut -f 1 -d '(' | cut -f 2 -d ' ' >> tmpfile_ncra
+            (( nbfile = nbfile + 1 ))
+          done
+            list_var_final_ncra=`cat tmpfile_ncra | sort | uniq -c | awk -v nbfile=$nbfile '{if ($1 == nbfile) {print $2}}' | paste -s -d ','`
+          IGCM_sys_Rm tmpfile_ncra
+
+          IGCM_sys_ncra -O -v ${list_var_final_ncra} ${liste_file_se_tmp[*]} ${OUT_SE[${nb}]}
+          IGCM_sys_Rm ${liste_file_se_tmp[*]}
+        done
+        ;;
+      esac
+      #
+
+      # Search of common list of variables to be treated
+      nbfile=0
+      for file_common_var in ${OUT_SE[*]} ; do
+        ncdump -h ${file_common_var} | grep -E 'float|double' | cut -f 1 -d '(' | cut -f 2 -d ' ' >> tmpfile_ncrcat
+        (( nbfile = nbfile + 1 ))
+      done
+      list_var_final_ncrcat=`cat tmpfile_ncrcat | sort | uniq -c | awk -v nbfile=$nbfile '{if ($1 == nbfile) {print $2}}' | paste -s -d ','`
+      IGCM_sys_Rm tmpfile_ncrcat
+
+    IGCM_sys_ncrcat -O -v ${list_var_final_ncrcat} ${OUT_SE[*]} ${RESULT_SE}
+    #
+    IGCM_sys_Rm ${OUT_SE[*]}
+    #
+    # detect time counter : time or time_counter ie unlimited variable
+    var_unlim=$(ncdump -h ${RESULT_SE}|grep UNLIMITED| cut -d ' ' -f 1)
+
+    # Put correct climatological axis following calendar
+    case ${config_UserChoices_CalendarType} in
+      360d|360_day)
+      # 360 days
+        ncap2cmd="'defdim(\"tbnds\",2) ; ${var_unlim}[${var_unlim}]={15, 45, 75, 105, 135, 165, 195, 225, 255, 285, 315, 345.} ; ${var_unlim}_bnds[${var_unlim},tbnds]={0, 30, 30, 60, 60, 90, 90, 120, 120, 150, 150, 180, 180, 210, 210, 240, 240, 270, 270, 300, 300, 330, 330, 360.} ; ${var_unlim}@units=\"days since 0000-01-01 00:00:00\" ; ${var_unlim}@time_origin=\"01-JAN-0000 00:00:00\" ; ${var_unlim}@calendar=\"360_day\" ; ${var_unlim}@bounds=\"${var_unlim}_bnds\"'"
+        ;;
+      noleap|365_day)
+      # 365 days
+        ncap2cmd="'defdim(\"tbnds\",2) ; ${var_unlim}[${var_unlim}]={15.5, 45, 74.5, 105, 135.5, 166, 196.5, 227.5, 258, 288.5, 319, 349.5} ; ${var_unlim}_bnds[${var_unlim},tbnds]={0, 31, 31, 59, 59, 90, 90, 120, 120, 151, 151, 181, 181, 212, 212, 243, 243, 273, 273, 304, 304, 334, 334, 365.} ; ${var_unlim}@units=\"days since 0000-01-01 00:00:00\" ; ${var_unlim}@time_origin=\"01-JAN-0000 00:00:00\" ; ${var_unlim}@calendar=\"365_day\" ; ${var_unlim}@bounds=\"${var_unlim}_bnds\"'"
+        ;;
+      all_leap|366_day)
+      # 366 days
+        ncap2cmd="'defdim(\"tbnds\",2) ; ${var_unlim}[${var_unlim}]={15.5, 45.5, 75.5, 106, 136.5, 167, 197.5, 228.5, 259, 289.5, 320, 350.5} ; ${var_unlim}_bnds[${var_unlim},tbnds]={0, 31, 31, 60, 60, 91, 91, 121, 121, 152, 152, 182, 182, 213, 213, 244, 244, 274, 274, 305, 305, 335, 335, 366.} ; ${var_unlim}@units=\"days since 0000-01-01 00:00:00\" ; ${var_unlim}@time_origin=\"01-JAN-0000 00:00:00\" ; ${var_unlim}@calendar=\"366_day\" ; ${var_unlim}@bounds=\"${var_unlim}_bnds\"'"
+        ;;
+      leap|gregorian|standard)
+      # 365.2425 days
+        ncap2cmd="'defdim(\"tbnds\",2) ; ${var_unlim}[${var_unlim}]={15.5, 45.12125, 74.7425, 105.2425, 135.7425, 166.2425, 196.7425, 227.7425, 258.2425, 288.7425, 319.2425, 349.7425} ; ${var_unlim}_bnds[${var_unlim},tbnds]={0, 31, 31, 59.2425, 59.2425, 90.2425, 90.2425, 120.2425, 120.2425, 151.2425, 151.2425, 181.2425, 181.2425, 212.2425, 212.2425, 243.2425, 243.2425, 273.2425, 273.2425, 304.2425, 304.2425, 334.2425, 334.2425, 365.2425} ; ${var_unlim}@units=\"days since 0000-01-01 00:00:00\" ; ${var_unlim}@time_origin=\"01-JAN-0000 00:00:00\" ; ${var_unlim}@calendar=\"gregorian\" ; ${var_unlim}@bounds=\"${var_unlim}_bnds\"'"
+        ;;
+    esac
+    eval IGCM_sys_ncap2 -Oh -s $ncap2cmd ${RESULT_SE} tmp.nc
+    IGCM_sys_Rm ${RESULT_SE}
+    IGCM_sys_Mv tmp.nc ${RESULT_SE}
+    #
+    eval IGCM_sys_Put_Out ${RESULT_SE} \${R_OUT_${comp}}/Analyse/SE/${RESULT_SE}
+    IGCM_sys_Rm ${RESULT_SE}
+    #
+  done
+done
+
+# DODS copy
+if [ X${config_Post_DodsCopy} = XTRUE ]  ; then
+  for comp in ${config_ListOfComponents[*]} ; do
+    IGCM_sys_TestDirArchive ${R_SAVE}/${comp}/Analyse/SE
+    [ $? = 0 ] && IGCM_sys_Put_Dods ${comp}/Analyse/SE
+  done
+fi
+
+# Temporal coverage id for atlas
+YEARS=${an_deb}_${an_fin}
+DIR_OUT=SE
+
+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_MBG ; export RESOL_SRF ; export RESOL_SBG
+export R_SAVE; export config_UserChoices_JobName; export config_UserChoices_TagName; export YEARS; export DIR_OUT
+listVarEnv="POST_DIR,SUBMIT_DIR,libIGCM,R_INIT,R_BC,StandAlone,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_MBG,RESOL_SRF,RESOL_SBG,R_SAVE,config_UserChoices_JobName,config_UserChoices_TagName,YEARS,DIR_OUT"
+export listVarEnv;
+
+#D-
+# --------------------------------------------------------------------
+#D- Test if all was right before ATLAS
+# --------------------------------------------------------------------
+IGCM_debug_Verif_Exit_Post
+
+if [ ${config_UserChoices_TagName} = "IPSLCM4_v1_OASIS3" ] || \
+   [ ${config_UserChoices_TagName} = "IPSLCM4_v2" ]        || \
+   [ ${config_UserChoices_TagName} = "IPSL_ESM_V1" ] ; then
+  #
+  Script_Post_Output=atlas_ORCHIDEE.${PeriodDateEnd} ;
+  IGCM_sys_QsubPost atlas_ORCHIDEE                   ;
+  Script_Post_Output=atlas_LMDZ.${PeriodDateEnd}     ;
+  IGCM_sys_QsubPost atlas_LMDZ                       ;
+  Script_Post_Output=atlas_ORCA_LIM.${PeriodDateEnd} ;
+  IGCM_sys_QsubPost atlas_ORCA_LIM                   ;
+  Script_Post_Output=additionnal.${PeriodDateEnd}    ;
+  IGCM_sys_QsubPost additionnal                      ;
+  #
+elif [ ${config_UserChoices_TagName} = "IPSLCM5" ]  || \
+     [ ${config_UserChoices_TagName} = "IPSLCM5A" ] || \
+     [ ${config_UserChoices_TagName} = "IPSLCM5B" ] || \
+     [ ${config_UserChoices_TagName} = "IPSLCM5A-MR" ] || \
+     [ ${config_UserChoices_TagName} = "IPSLCM6" ] ; then
+  Script_Post_Output=atlas_ORCHIDEE.${PeriodDateEnd} ;
+  IGCM_sys_QsubPost atlas_ORCHIDEE                   ;
+  Script_Post_Output=atlas_LMDZ.${PeriodDateEnd}     ;
+  IGCM_sys_QsubPost atlas_LMDZ                       ;
+  Script_Post_Output=atlas_ORCA_LIM.${PeriodDateEnd} ;
+  IGCM_sys_QsubPost atlas_ORCA_LIM                   ;
+  Script_Post_Output=atlas_PISCES.${PeriodDateEnd}   ;
+  IGCM_sys_QsubPost atlas_PISCES                     ;
+  #
+elif [ ${config_UserChoices_TagName} = "LMDZ4OR" ]  || \
+     [ ${config_UserChoices_TagName} = "LMDZOR" ]   || \
+     [ ${config_UserChoices_TagName} = "LMDZ4OR_v2" ] ; then
+  #
+  Script_Post_Output=atlas_LMDZ.${PeriodDateEnd}     ;
+  IGCM_sys_QsubPost atlas_LMDZ                       ;
+  Script_Post_Output=atlas_ORCHIDEE.${PeriodDateEnd} ;
+  IGCM_sys_QsubPost atlas_ORCHIDEE                   ;
+  #
+elif [ ${config_UserChoices_TagName} = "LMDZ" ] ; then
+  #
+  Script_Post_Output=atlas_LMDZ.${PeriodDateEnd}     ;
+  IGCM_sys_QsubPost atlas_LMDZ                       ;
+  #
+elif [ ${config_UserChoices_TagName} = "OL" ]      || \
+     [ ${config_UserChoices_TagName} = "OL2" ] ; then
+  #
+  Script_Post_Output=atlas_ORCHIDEE.${PeriodDateEnd} ;
+  IGCM_sys_QsubPost atlas_ORCHIDEE                   ;
+  #
+elif [ ${config_UserChoices_TagName} = "ORCA2_LIM" ]  || \
+     [ ${config_UserChoices_TagName} = "ORCA2_LIM2" ] || \
+     [ ${config_UserChoices_TagName} = "ORCA2_LIM3" ] ; then
+  #
+  Script_Post_Output=atlas_ORCA_LIM.${PeriodDateEnd} ;
+  IGCM_sys_QsubPost atlas_ORCA_LIM                   ;
+elif [ ${config_UserChoices_TagName} = "ORCA2_LIM2_PISCES" ] || \
+     [ ${config_UserChoices_TagName} = "ORCA2_LIM3_PISCES" ] ; then
+  #
+  Script_Post_Output=atlas_ORCA_LIM.${PeriodDateEnd} ;
+  IGCM_sys_QsubPost atlas_ORCA_LIM                   ;
+  Script_Post_Output=atlas_PISCES.${PeriodDateEnd}   ;
+  IGCM_sys_QsubPost atlas_PISCES                     ;
+elif [ ${config_UserChoices_TagName} = "ORCA2_OFF_PISCES" ]  ; then
+  #
+  Script_Post_Output=atlas_PISCES.${PeriodDateEnd}   ;
+  IGCM_sys_QsubPost atlas_PISCES                     ;
+  #
+fi
+
+# Clean RUN_DIR_PATH (necessary for cesium and titane only)
+IGCM_sys_RmRunDir -Rf ${RUN_DIR_PATH}
Index: /tags/libIGCM_v2.2/AA_create_ts
===================================================================
--- /tags/libIGCM_v2.2/AA_create_ts	(revision 998)
+++ /tags/libIGCM_v2.2/AA_create_ts	(revision 998)
@@ -0,0 +1,802 @@
+#-Q- curie ######################
+#-Q- curie ## CURIE   TGCC/CEA ##
+#-Q- curie ######################
+#-Q- curie #MSUB -r TS             # Nom du job
+#-Q- curie #MSUB -eo
+#-Q- curie #MSUB -n 1              # Reservation du processus
+#-Q- curie #MSUB -T 80000          # Limite de temps elapsed du job
+#-Q- curie #MSUB -q xlarge
+#-Q- curie #MSUB -Q normal
+#-Q- curie #MSUB -A ::default_project::
+#-Q- curie set +x
+#-Q- ada #!/bin/ksh
+#-Q- ada #######################
+#-Q- ada ## ADA         IDRIS ##
+#-Q- ada #######################
+#-Q- ada # @ job_type = serial
+#-Q- ada # @ requirements = (Feature == "prepost")
+#-Q- ada # Temps Elapsed max. d'une requete hh:mm:ss
+#-Q- ada # @ wall_clock_limit = 20:00:00
+#-Q- ada # Nom du travail LoadLeveler
+#-Q- ada # @ job_name   = TS
+#-Q- ada # Fichier de sortie standard du travail
+#-Q- ada # @ output     = $(job_name).$(jobid)
+#-Q- ada # Fichier de sortie d'erreur du travail
+#-Q- ada # @ error      =  $(job_name).$(jobid)
+#-Q- ada # pour recevoir un mail en cas de depassement du temps Elapsed (ou autre pb.)
+#-Q- ada # @ notification = error
+#-Q- ada # @ 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_MBG ; $RESOL_SRF ; $RESOL_SBG ; $MASTER
+#-Q- ada # @ queue
+#-Q- lxiv8 ######################
+#-Q- lxiv8 ## OBELIX      LSCE ##
+#-Q- lxiv8 ######################
+#-Q- lxiv8 #PBS -N TS
+#-Q- lxiv8 #PBS -m a
+#-Q- lxiv8 #PBS -j oe
+#-Q- lxiv8 #PBS -q medium
+#-Q- lxiv8 #PBS -o TS.$$
+#-Q- lxiv8 #PBS -S /bin/ksh
+#-Q- default #!/bin/ksh
+#-Q- default ##################
+#-Q- default ## DEFAULT HOST ##
+#-Q- default ##################
+
+#**************************************************************
+# Author: Sebastien Denvil
+# Contact: Sebastien.Denvil__at__ipsl.jussieu.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#set -eu
+#set -vx
+
+date
+
+#-Q- ada export OMP_NUM_THREADS=1
+
+#D- Task type (computing or post-processing)
+TaskType=post-processing
+
+########################################################################
+
+#D- Flag to determine if this job in a standalone mode
+#D- Default : value from AA_job if any
+StandAlone=${StandAlone:=true}
+
+#D- Path to libIGCM
+#D- Default : value from AA_job if any
+libIGCM=${libIGCM:=::modipsl::/libIGCM}
+
+#D- Flag to determine allready produced time series. Empty if you start from the beginning
+#D- Default : Value from AA_job if any. Usefull in StandAlone case if you want to continue a time series
+CompletedFlag=${CompletedFlag:=}
+
+#D- Flag to determine task type this script will perform.
+#D- Possible Value : 2D, 3D, Chunck2D, Chunck3D
+#D- Default : Value from AA_job if any. Usefull in StandAlone case.
+TsTask=${TsTask:=2D}
+if [ X${TsTask} = Xempty ] ; then
+  TsTask=""
+fi
+
+#D- Flag to determine if rebuild process has been performed asynchronously
+#D- Possible value true or false.
+#D- If true raw files has allready been patched by rebuild job
+#D- If false create_ts will patch the raw files
+#D- Default : Value from AA_job if any. Usefull in StandAlone case.
+RebuildFrequency=${RebuildFrequency:=true}
+
+#D- Flag to determine job's output directory
+#D- Default : value from libIGCM_post.ksh if any
+POST_DIR=${POST_DIR:=${PBS_O_WORKDIR:=$(pwd)}}
+
+#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- TEMPORARY Flag to determine atmospheric resolution
+#D- Default : value from atmospheric driver if any
+RESOL_ATM=ALL
+
+#D- Flag to determine surface resolution
+#D- Default : value from surface driver if any
+RESOL_SRF=ALL
+
+#D- Flag to determine surface resolution
+#D- Default : value from surface driver if any
+RESOL_SBG=ALL
+
+#D- TEMPORARY Flag to determine ocean resolution
+#D- Default : value from ocean driver if any
+RESOL_OCE=${RESOL_OCE:=ORCA2}
+
+#D- TEMPORARY Flag to determine ice resolution
+#D- Default : value from ice driver if any
+RESOL_ICE=${RESOL_ICE:=ORCA2}
+
+#D- TEMPORARY Flag to determine marine biogeochemistry resolution
+#D- Default : value from ice driver if any
+RESOL_MBG=${RESOL_MBG:=ORCA2}
+
+########################################################################
+
+. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
+. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
+. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
+#-------
+. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
+. ${libIGCM}/libIGCM_config/libIGCM_config.ksh
+#-------
+( ${DEBUG_debug} ) && IGCM_debug_Check
+( ${DEBUG_debug} ) && IGCM_card_Check
+( ${DEBUG_debug} ) && IGCM_date_Check
+
+########################################################################
+
+#set -vx
+
+# Useful cleaning function
+MENAGE ()
+{
+  [ -f $3 ] && ( IGCM_sys_RshArchive rm -f $1/$2 ;)
+}
+
+########################################################################
+
+IGCM_sys_MkdirWork ${RUN_DIR_PATH}
+IGCM_sys_Cd ${RUN_DIR_PATH}
+
+# ------------------------------------------------------------------
+# Test if all was right before proceeding further
+# ------------------------------------------------------------------
+IGCM_debug_Verif_Exit_Post
+
+if [ ${StandAlone} = true ] ; then
+  CARD_DIR=${SUBMIT_DIR}
+else
+  CARD_DIR=${RUN_DIR_PATH}
+
+  IGCM_sys_Get_Master ${SUBMIT_DIR}/config.card ${RUN_DIR_PATH}
+
+  IGCM_sys_Get_Master ${SUBMIT_DIR}/run.card    ${RUN_DIR_PATH}
+
+  IGCM_sys_Get_Master ${SUBMIT_DIR}/COMP        ${RUN_DIR_PATH}
+
+  IGCM_sys_Get_Master ${SUBMIT_DIR}/POST        ${RUN_DIR_PATH}
+fi
+
+#==================================
+# First of all
+#
+# Read libIGCM compatibility version in config.card
+# Read UserChoices section
+# Read Ensemble section
+# Read Post section
+# Define all netcdf output directories
+#==================================
+IGCM_config_CommonConfiguration ${CARD_DIR}/config.card
+
+#==================================
+# Define default value to keep compatibility with previous card: means before changes due to TGCC
+if [ X${PackDefault} = Xtrue ] ; then
+  [ X${config_Post_PackFrequency} = X ] && config_Post_PackFrequency=${config_Post_RebuildFrequency}
+else
+  config_Post_PackFrequency=NONE
+fi
+
+#==================================
+# If pack is active then PackFrequency overule the config_UserChoices_PeriodLength
+if ( [ ! X${config_Post_PackFrequency} = X${NULL_STR} ] && [ ! X${config_Post_PackFrequency} = XNONE ] ) ; then
+  config_UserChoices_PeriodLength=${config_Post_PackFrequency}
+fi
+
+#
+# Determine component to take care of depending on kind of task create_ts will perform
+#
+[ ${CompToRead} ] && 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
+#
+[ X${CompletedFlag} = X ] || CompletedFlag=$( IGCM_date_ConvertFormatToGregorian ${CompletedFlag} )
+
+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
+
+# ------------------------------------------------------------------
+#D- Test if all was right before entering the loop
+# ------------------------------------------------------------------
+IGCM_debug_Verif_Exit_Post
+
+########################################################################
+#      Depending on requested time series fill following variables :
+#
+#                           - LISTE_FILE_${comp}[*]
+#                           - LISTE_VARS_${file}[*]
+#                           - LISTE_AXIS_${file}[*]
+#                           - LISTE_PATCH_${file}[*]
+########################################################################
+
+#
+# For each selected component determine which files need post-processing
+#
+DoJob=false
+for comp in ${config_ListOfComponents[*]} ; do
+  #
+  ActiveComp=false
+  #
+  IGCM_card_DefineArrayFromOption ${CARD_DIR}/config.card ListOfComponents ${comp}
+  eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1
+  #
+  card=${CARD_DIR}/COMP/${compname}.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
+    #
+    typeset i
+    if [ ${FlagToRead} ] ; then
+      ((NbFiles=${FlagToRead}))
+      ((i=${NbFiles}))
+    else
+      eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1
+      i=2
+    fi
+    #
+    until [ $i -gt $NbFiles ]; do
+      #
+      eval flag_post=\${${ListFilesName}[$i]} > /dev/null 2>&1
+      #
+      if [ X${flag_post} != XNONE ] ; then
+        #
+        # 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}
+        IGCM_card_DefineVariableFromOption ${card} Post_${FILE} ChunckJob${Dimension}
+        #
+        # If TimeSeriesVars list is empty we skip
+        #
+        if [ $( eval echo \${${compname}_Post_${FILE}_TimeSeriesVars${Dimension}} ) = ${NULL_STR} ] ; then
+          #
+          IGCM_debug_Print 3 "Nothing to do for ${FILE} according to ${card}"
+          IGCM_debug_Print 3 "TimeSeriesVars${Dimension} for ${FILE} is empty"
+          (( i=i+3 ))
+          continue
+          #
+        fi
+        #
+        # If files/variables has been switch off by ChunckJob${Dimension}=0 we skip
+        #
+        if [ X$( eval echo \${${compname}_Post_${FILE}_ChunckJob${Dimension}} ) = XOFF ] ; then
+          IGCM_debug_Print 3 "Nothing to do for ${FILE} according to ${card}"
+          IGCM_debug_Print 3 "ChunckJob${Dimension}=OFF for ${FILE} so it has been switched off"
+          (( i=i+3 ))
+          continue
+        fi
+        #
+          # If we are not a Chunck type task, we skip files/variables handled by chunck task
+          #
+        if ( [ ! X${TsTask} = XChunck${Dimension} ] && [ ! X${TsTask} = X ] && [ ! XChunck${Dimension} = XChunck ] ) ; then
+          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
+        #
+        # Now on we know we have things to do
+        #
+
+        #
+        #  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  ;;
+          3H)  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 [ ! X${RebuildFrequency} = Xtrue ] ; 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
+      (( i=i+3 ))
+    done
+  fi
+  #
+  if [ ${ActiveComp} = true ] ; then
+    set +A ActiveListOfComponents ${ActiveListOfComponents[*]} ${comp}
+  fi
+done
+
+set -A config_ListOfComponents ${ActiveListOfComponents[*]}
+[ ! -z "${ActiveListOfComponents}" ] && DoJob=true
+
+########################################################################
+#
+#               IS THERE SOME ALLREADY PRODUCED TIME SERIES ?
+#                 IF SO BRING THEM IN THE WORKING DIRECTORY
+#
+# PS : Keep in mind that IGCM_sys_Get here is a weak link :
+#      - especially for IDRiS
+#      - no special protection against "command too long" !
+#      - libIGCM_sys should handle that or modify following code part
+#
+########################################################################
+
+if [ ${StandAlone} != true ] ; then
+  Running_Flag=$( IGCM_sys_RshMaster "IGCM_card_DefineVariableFromOption \
+  ${SUBMIT_DIR}/run.card PostProcessing TimeSeriesRunning ; \
+  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
+  # 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}" )
+fi
+
+# Is it the first submission or not ?
+
+if ( [ X${CompletedFlag} = X ] || [ X${CompletedFlag} = X$( IGCM_date_AddDaysToGregorianDate ${DateBegin} -1 ) ] ) ; then
+  # First Time Series Submission
+  FIRST_PASS=TRUE
+  Length=$( IGCM_date_DaysInPreviousPeriod ${DateBegin} ${config_UserChoices_PeriodLength} begin)
+  DATE_FIN_JOB_B=$( IGCM_date_AddDaysToGregorianDate ${DateBegin} $(( Length - 1 )) )
+else
+  # Last Completed Time Series
+  FIRST_PASS=FALSE
+  DATE_FIN_JOB_B=${CompletedFlag}
+  date=${DateBegin}_${DATE_FIN_JOB_B}
+  for comp in ${config_ListOfComponents[*]} ; do
+    #
+    IGCM_sys_Mkdir ${RUN_DIR_PATH}/${comp}
+    #
+    IGCM_sys_Cd ${RUN_DIR_PATH}/${comp}
+    #
+    unset liste_file
+    #
+    file_path=${R_SAVE}/${comp}/Analyse
+    #
+    i=0
+    file=${NULL_STR}
+    #
+    for file in $( eval echo \${LISTE_FILE_${comp}[*]} ); do
+      #
+      # Determine in which output can we find file
+      # IE : Analyse/TS or Analyse/DA2TS or ...
+      #
+      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  ;;
+        3H)  TS_Dir=TS_HF  ;;
+        INS) TS_Dir=TS_INS ;;
+      esac
+      for var in $( eval echo \${LISTE_VARS_${file}[*]} ) ; do
+        #
+        liste_file[${#liste_file[*]}]=${file_path}/${TS_Dir}/${config_UserChoices_JobName}_${date}_${FlagDir}_${var}.nc
+        #
+      done
+    done
+    if [ X${file} != X${NULL_STR} ] ; then
+      IGCM_sys_Get /l liste_file[*] ${RUN_DIR_PATH}/${comp}
+
+      # Even if some files are missing we tried to continue
+      # Either ListVar in compname.card are asked but not present in original history file
+      # Either a previous TS task failed
+      ExitFlag=false
+      IGCM_debug_Verif_Exit_Post
+    fi
+  done
+  #
+  LEVEL=0
+  #
+fi
+
+########################################################################
+#
+#                          DEFINE LOOP PARAMETERS
+#
+########################################################################
+
+DATE_COUNT=${DATE_FIN_JOB_B}
+DATE_FIN_JOB_B_LOOP=${DATE_FIN_JOB_B}
+
+( [ -n "${LEVEL}" ] && [ ${LEVEL} -eq 0 ] ) && NBRE_FILE_TOT=0 || NBRE_FILE_TOT=1
+
+if [ ${DoJob} = true ] ; then
+  while [ ${DATE_COUNT} -lt ${PeriodDateEnd} ] ; do
+    (( NBRE_FILE_TOT = NBRE_FILE_TOT + 1 ))
+    Length=$( IGCM_date_DaysInNextPeriod ${DATE_COUNT} ${config_UserChoices_PeriodLength} )
+    DATE_COUNT=$( IGCM_date_AddDaysToGregorianDate ${DATE_COUNT} ${Length} )
+  done
+else
+  NBRE_FILE_TOT=0
+fi
+
+if [ ${NBRE_FILE_TOT} -le ${UNIX_MAX_LIMIT} ] ; then
+  NBRE_TOUR=1
+elif [ ${NBRE_FILE_TOT}%${UNIX_MAX_LIMIT} -eq 0 ] ; then
+  let NBRE_TOUR=${NBRE_FILE_TOT}/${UNIX_MAX_LIMIT}
+else
+  let NBRE_TOUR=${NBRE_FILE_TOT}/${UNIX_MAX_LIMIT}+1
+fi
+
+CURRENT_LOOP=1
+# THIS LOOP GIVES PARAMETERS FOR THE DATE'S LOOP ie : DATE_COURANTE, DATE_FIN.
+# WE HAVE 3 LEVELS
+#    - LEVEL 1 : JUST ONE LOOP TO COMPLETE
+#    - LEVEL 2 : WE ARE IN THE "DEEP" LOOP
+#    - LEVEL 3 : WE ARE IN THE LAST LOOP
+
+while [ ${CURRENT_LOOP} -le  ${NBRE_TOUR} ] ; do
+
+  if [ ${NBRE_FILE_TOT} -le ${UNIX_MAX_LIMIT} ] ; then
+    # - LEVEL 1 : JUST ONE LOOP TO COMPLETE
+    NBRE_FILE_LOOP=${NBRE_FILE_TOT}
+
+    if [ ${FIRST_PASS} = TRUE ] ; then
+      DATE_COURANTE=${DATE_FIN_JOB_B_LOOP}
+    else
+      Length=$( IGCM_date_DaysInNextPeriod ${DATE_FIN_JOB_B_LOOP} ${config_UserChoices_PeriodLength} )
+      DATE_COURANTE=$( IGCM_date_AddDaysToGregorianDate ${DATE_FIN_JOB_B_LOOP} ${Length} )
+    fi
+
+    DATE_FIN=${PeriodDateEnd}
+    DATE_FIN_JOB_B_LOOP_PREC=${DATE_FIN_JOB_B_LOOP}
+
+    [ -n "${DATE_LOOP}" ] && DATE_FIN_JOB_B_LOOP=${DATE_LOOP}
+    [ -n "${LEVEL}" ] && FLAG_B="TRUE" || FLAG_B="FALSE"
+
+    LEVEL=1
+    DEPOT="TRUE"
+  elif [ ${CURRENT_LOOP} -ne  ${NBRE_TOUR} ] ; then
+    # - LEVEL 2 : WE ARE IN THE "DEEP" LOOP
+    NBRE_FILE_LOOP=${UNIX_MAX_LIMIT}
+
+    if [ ! ${FIRST_PASS} = TRUE ] && [ ${CURRENT_LOOP} -eq 1 ] ; then
+      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=$( IGCM_date_DaysInNextPeriod ${DATE_FIN} ${config_UserChoices_PeriodLength} )
+      DATE_COURANTE=$( IGCM_date_AddDaysToGregorianDate ${DATE_FIN} ${Length} )
+    fi
+
+    (( TotLength = 0 ))
+    COMPTEUR=1
+    DATE_LOOP=${DATE_COURANTE}
+
+    while [ ${COMPTEUR} -lt ${NBRE_FILE_LOOP} ] ; do
+      #
+      Length=$( IGCM_date_DaysInNextPeriod ${DATE_LOOP} ${config_UserChoices_PeriodLength} )
+      DATE_LOOP=$( IGCM_date_AddDaysToGregorianDate ${DATE_LOOP} ${Length} )
+      (( TotLength = TotLength + Length ))
+      (( COMPTEUR = COMPTEUR + 1 ))
+      #
+    done # while [ ${COMPTEUR} -le ${NBRE_FILE_LOOP} ] done
+    DATE_FIN=$( IGCM_date_AddDaysToGregorianDate ${DATE_COURANTE} ${TotLength} )
+
+    [ -n "${DATE_LOOP}" ] && DATE_FIN_JOB_B_LOOP_PREC=${DATE_FIN_JOB_B_LOOP} ; DATE_FIN_JOB_B_LOOP=${DATE_LOOP}
+    [ -n "${LEVEL}" ] && [ ${LEVEL} -eq 0 ] && FLAG_B="TRUE" || [ ${CURRENT_LOOP} -gt 1 ] && FLAG_B="TRUE" || FLAG_B="FALSE"
+    DEPOT="FALSE"
+    LEVEL=2
+  else
+    # - LEVEL 3 : WE ARE IN THE LAST LOOP
+    NBRE_FILE_LOOP=$(( ${NBRE_FILE_TOT} % ( ${UNIX_MAX_LIMIT} * ( ${CURRENT_LOOP} - 1 ) ) ))
+    [ ${NBRE_FILE_LOOP} -eq 0 ] && NBRE_FILE_LOOP=${UNIX_MAX_LIMIT}
+
+    Length=$( IGCM_date_DaysInNextPeriod ${DATE_FIN} ${config_UserChoices_PeriodLength} )
+    DATE_COURANTE=$(IGCM_date_AddDaysToGregorianDate ${DATE_FIN} ${Length} )
+    DATE_FIN=${PeriodDateEnd}
+    [ -n "${DATE_LOOP}" ] && DATE_FIN_JOB_B_LOOP_PREC=${DATE_FIN_JOB_B_LOOP} ; DATE_FIN_JOB_B_LOOP=${DATE_LOOP}
+
+    LEVEL=3
+    DEPOT="TRUE"
+    FLAG_B="TRUE"
+  fi
+
+  # THEN FOR EACH FILE TYPE WE LOOP BETWEEN DATE_COURANTE AND DATE_FIN.
+  for comp in ${config_ListOfComponents[*]} ; do
+    #
+    IGCM_sys_Mkdir ${RUN_DIR_PATH}/${comp}
+      #
+    IGCM_sys_Cd ${RUN_DIR_PATH}/${comp}
+    #
+    eval R_OUT_${comp}=${R_SAVE}/${comp}
+    #
+    i=0
+    #
+    for file in $( eval echo \${LISTE_FILE_${comp}[*]} ); do
+      #
+      # Determine in which output we can find file
+      # IE : Output/MO or Output/DA or ...
+      #
+      FlagDir=$( echo ${file} | awk -F "_" '{print $1}' )
+      case ${FlagDir} in
+        *Y)    TS_Dir=TS_YE  ; FreqDir=YE  ;;
+        *M)    TS_Dir=TS_MO  ; FreqDir=MO  ;;
+        *D)    TS_Dir=TS_DA  ; FreqDir=DA  ;;
+        HF)    TS_Dir=TS_HF  ; FreqDir=HF  ;;
+        3H)    TS_Dir=TS_HF  ; FreqDir=HF  ;;
+        INS)   TS_Dir=TS_INS ; FreqDir=INS ;;
+        *)     IGCM_debug_Print 1 "Error in FlagDir=${FlagDir} for file ${file}."
+               IGCM_sys_Exit "Job create_ts" ;;
+      esac
+
+      # Initialize array
+      unset liste_file
+      unset liste_file_tmp
+      eval file_path=\${R_OUT_${comp}}/Output/${FreqDir}/
+
+      COMPTEUR=1
+      MissingFile=FALSE
+      DATE_LOOP=${DATE_COURANTE}
+
+      while [ ${COMPTEUR} -le ${NBRE_FILE_LOOP} ] ; do
+        #
+        Length1=$( IGCM_date_DaysInPreviousPeriod ${DATE_LOOP} ${config_UserChoices_PeriodLength} end)
+        DATE_TAB=$(  IGCM_date_AddDaysToGregorianDate ${DATE_LOOP} $(( 1 - Length1 )) )_${DATE_LOOP}
+
+        Length2=$( IGCM_date_DaysInNextPeriod ${DATE_LOOP} ${config_UserChoices_PeriodLength} )
+        DATE_LOOP=$( IGCM_date_AddDaysToGregorianDate ${DATE_LOOP} ${Length2} )
+
+        IGCM_sys_TestFileArchive ${file_path}${config_UserChoices_JobName}_${DATE_TAB}_${file}.nc
+        if [ $? = 0 ] ; then
+          liste_file[${#liste_file[*]}]=${file_path}${config_UserChoices_JobName}_${DATE_TAB}_${file}.nc
+          liste_file_tmp[${#liste_file_tmp[*]}]=${config_UserChoices_JobName}_${DATE_TAB}_${file}.nc
+        else
+          IGCM_debug_Print 1 "WARNING ${file_path}${config_UserChoices_JobName}_${DATE_TAB}_${file}.nc dont exist"
+          MissingFile=TRUE
+        fi
+        (( COMPTEUR = COMPTEUR + 1 ))
+        #
+      done # while [ ${COMPTEUR} -le ${NBRE_FILE_LOOP} ] done
+
+      # We skip this file type if one of them is missing.
+      if [ "${MissingFile}" = "TRUE" ] ; then
+        IGCM_debug_Print 1 "WARNING We skip ${file} type processing"
+        continue
+      fi
+
+      DATE_LOOP=$( IGCM_date_AddDaysToGregorianDate ${DATE_LOOP} -${Length2} )
+
+      # Get selected files
+      IGCM_sys_Get /l liste_file[*] ${RUN_DIR_PATH}/${comp}
+      IGCM_debug_Verif_Exit_Post
+
+      # Apply IGCM_Patch if needed
+      if [ ! X${RebuildFrequency} = Xtrue ] ; 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}
+              IGCM_debug_Verif_Exit_Post
+            done
+          done
+        fi
+      fi
+
+      # WE CAN CONCATENATE FILES AT THIS POINT
+      [ "${FLAG_B}" = "TRUE" ] && DATE_BUILD_B=${DateBegin}_${DATE_FIN_JOB_B_LOOP_PREC}
+      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}
+      DATE_BUILD_END=${DateBegin}_${DATE_FIN}
+
+      liste_coord=" "
+      for axis in $( eval echo \${LISTE_AXIS_${file}[*]} ); do
+        liste_coord=${liste_coord}${axis}","
+      done
+
+      # Time axis must be the last dimension
+      time_axis=${axis}
+
+      # SWITCH BETWEEN MODEL TO FIT PARTICULAR CASE
+      for var in $( eval echo \${LISTE_VARS_${file}[*]} ) ; do
+        #
+        if [ "${FLAG_B}" = "TRUE" ] ; then
+          # WE CONCATENATE WITH EXISTING FILES
+          file1=${config_UserChoices_JobName}_${DATE_BUILD_B}_${FlagDir}_${var}.nc
+          file_out=${config_UserChoices_JobName}_${DATE_BUILD_END}_${FlagDir}_${var}.nc
+          IGCM_sys_ncrcat --hst -v ${liste_coord}${var} ${file1} ${liste_file_tmp[*]} ${file_out}
+          #
+          IGCM_sys_Rm ${file1}
+          if [ ! "${DEPOT}" = "TRUE" ] ; then
+            eval IGCM_sys_Put_Out ${file_out} \${R_OUT_${comp}}/Analyse/${TS_Dir}/${file_out}
+            # "${file1} = file_before ?
+            [ ! "${file1}" = "${config_UserChoices_JobName}_${DateBegin}_${DATE_FIN_JOB_B}_${FlagDir}_${var}.nc" ] && eval MENAGE \${R_OUT_${comp}}/Analyse/${TS_Dir} ${file1} ${file_out}
+          fi
+
+          ExitFlag=false
+        else
+          # OR NOT
+          IGCM_sys_ncrcat --hst -v ${liste_coord}${var} ${liste_file_tmp[*]} ${config_UserChoices_JobName}_${DATE_BUILD}_${FlagDir}_${var}.nc
+        fi
+
+        #
+        if [ "${DEPOT}" = "TRUE" ] ; then
+          # WE PUT FINAL FILE ON FILE SYSTEM
+          [ "${FLAG_B}" = "FALSE" ] && file_out=${config_UserChoices_JobName}_${DATE_BUILD}_${FlagDir}_${var}.nc
+          file_before=${config_UserChoices_JobName}_${DateBegin}_${DATE_FIN_JOB_B}_${FlagDir}_${var}.nc
+          #
+          eval IGCM_sys_Put_Out ${file_out} \${R_OUT_${comp}}/Analyse/${TS_Dir}/${file_out}
+          [ "${FLAG_B}" = "TRUE" ] && eval MENAGE \${R_OUT_${comp}}/Analyse/${TS_Dir} ${file_before} ${file_out}
+          if [ ! "X${file1}" = "X" ] ; then
+            [ ! "${file1}" = "${config_UserChoices_JobName}_${DateBegin}_${DATE_FIN_JOB_B}_${FlagDir}_${var}.nc" ] && eval MENAGE \${R_OUT_${comp}}/Analyse/${TS_Dir} ${file1} ${file_out}
+          fi
+          #
+          if ( [ ${FlagDir} = "1M" ] && [ -f ${file_out} ] ) ; then
+            file_before_YE=${config_UserChoices_JobName}_${DateBegin}_${DATE_FIN_JOB_B}_1Y_${var}.nc
+            file_out_YE=${config_UserChoices_JobName}_${DATE_BUILD_END}_1Y_${var}.nc
+            #
+            # Compute yearly average considering calendar
+            # and set date of the mid year to 01/07 at 00:00
+            IGCM_sys_cdo -settime,00:00 -setday,1 -setmon,7 -settunits,days -divdpy -yearsum -muldpm -selvar,${var} ${file_out} ${file_out_YE}
+            # Extract all ancillary variables except $var, they will be appended after the cdo command
+            # Needed because cdo applies calculs on all variables
+            IGCM_sys_ncks -Oh -x -v ${var} ${file_out} ${file_out_YE%%.nc}_tmp1.nc
+            # This will remove the time axis because cdo rewrites severely with only considered useful variables
+            IGCM_sys_cdo -mulc,1 ${file_out_YE%%.nc}_tmp1.nc ${file_out_YE%%.nc}_tmp2.nc 2>/dev/null
+            if [ $? -eq 0 ] ; then
+              # Now append all ancillary variables if previous cdo operator ok
+              IGCM_sys_ncks -h -A ${file_out_YE%%.nc}_tmp2.nc ${file_out_YE}
+            fi
+
+            # Put global history attribut
+            IGCM_sys_ncatted -Oh -a history,global,o,c,"build by libIGCM/create_ts" ${file_out_YE}
+            #
+            eval IGCM_sys_Put_Out ${file_out_YE} \${R_OUT_${comp}}/Analyse/TS_MO_YE/${file_out_YE}
+            [ "${FLAG_B}" = "TRUE" ] && eval MENAGE \${R_OUT_${comp}}/Analyse/TS_MO_YE/ ${file_before_YE} ${file_out_YE}
+            IGCM_sys_Rm ${file_out_YE%%.nc}_tmp*.nc
+          fi
+          #
+          IGCM_sys_Rm ${file_out}
+          ExitFlag=false
+          #
+        fi
+        #
+      done     # for var in ${liste_var} ; do
+      IGCM_sys_Rm ${liste_file_tmp[*]}
+    done         # for file in ${liste_file_brut} do
+  done             # for comp in ${config_ListOfComponents[*]} ; do
+  # GO AHEAD IN DEEPEST LOOP
+  (( CURRENT_LOOP = CURRENT_LOOP + 1 ))
+done                 # while [ ${CURRENT_LOOP} -le  ${NBRE_TOUR} ] do
+# FINISH
+
+# DODS copy
+for comp in ${config_ListOfComponents[*]} ; do
+  for TS_Dir in TS_YE TS_MO TS_MO_YE TS_DA TS_HF TS_INS ; do
+    IGCM_sys_TestDirArchive ${R_SAVE}/${comp}/Analyse/${TS_Dir}
+    [ $? = 0 ] && IGCM_sys_Put_Dods ${comp}/Analyse/${TS_Dir}
+  done
+done
+
+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_MBG ; export RESOL_SRF ; export RESOL_SBG
+
+listVarEnv="POST_DIR,SUBMIT_DIR,libIGCM,R_INIT,R_BC,StandAlone,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_MBG,RESOL_SRF,RESOL_SBG"
+export listVarEnv
+
+#D-
+# --------------------------------------------------------------------
+#D- Test if all was right
+# --------------------------------------------------------------------
+IGCM_debug_Verif_Exit_Post
+# --------------------------------------------------------------------
+#D- Submit MONITORING
+# --------------------------------------------------------------------
+if ( [ X${TsTask} = X2D ] || [ X${TsTask} = X3D ] || [ X${TsTask} = X ] ) ; then
+  Script_Post_Output=monitoring.${PeriodDateEnd}
+  IGCM_sys_QsubPost monitoring
+fi
+
+#D-
+# --------------------------------------------------------------------
+#D- Update the run.card
+# --------------------------------------------------------------------
+if [ ${StandAlone} != true ] ; then
+  # Put in run.card end period of time series
+  [ X"${DATE_FIN}" = X ] || IGCM_sys_RshMaster IGCM_card_WriteOption ${SUBMIT_DIR}/run.card PostProcessing TimeSeriesCompleted "${DATE_FIN}"
+  # We have finish the job !
+  IGCM_sys_RshMaster IGCM_card_WriteOption ${SUBMIT_DIR}/run.card PostProcessing TimeSeriesRunning "n"
+fi
+
+# Clean RUN_DIR_PATH (necessary for cesium and titane only)
+IGCM_sys_RmRunDir -Rf ${RUN_DIR_PATH}
+
+date
Index: /tags/libIGCM_v2.2/AA_job
===================================================================
--- /tags/libIGCM_v2.2/AA_job	(revision 998)
+++ /tags/libIGCM_v2.2/AA_job	(revision 998)
@@ -0,0 +1,498 @@
+#-Q- curie #!/bin/ksh
+#-Q- curie ######################
+#-Q- curie ## CURIE   TGCC/CEA ##
+#-Q- curie ######################
+#-Q- curie #MSUB -r ::Jobname::       # nom de la requete
+#-Q- curie #MSUB -o Script_Output_::Jobname::.000001    # nom du fichier de sortie
+#-Q- curie #MSUB -e Script_Output_::Jobname::.000001    # nom du fichier de sortie
+#-Q- curie #MSUB -eo
+#-Q- curie #MSUB -n ::JobNumProcTot:: # reservation des processeurs pour le job
+#-Q- curie #MSUB -T 86400             # Limite temps (en secondes)
+#-Q- curie #MSUB -q standard
+#-Q- curie #MSUB -A ::default_project::
+#-Q- curie BATCH_NUM_PROC_TOT=$BRIDGE_MSUB_NPROC
+#-Q- curie set +x
+#-Q- ada #!/bin/ksh
+#-Q- ada # ######################
+#-Q- ada # ##  ADA       IDRIS ##
+#-Q- ada # ######################
+#-Q- ada # Nom de la requete
+#-Q- ada # @ job_name = ::Jobname::
+#-Q- ada # Type de travail
+#-Q- ada # @ job_type = parallel
+#-Q- ada # Fichier de sortie standard
+#-Q- ada # @ output = Script_Output_::Jobname::.000001
+#-Q- ada # Fichier de sortie erreur (le meme)
+#-Q- ada # @ error = Script_Output_::Jobname::.000001
+#-Q- ada # Nombre de processus demandes
+#-Q- ada # @ total_tasks = ::JobNumProcTot::
+#-Q- ada # @ environment = "BATCH_NUM_PROC_TOT=::JobNumProcTot::"
+#-Q- ada # Temps CPU max. par processus MPI hh:mm:ss
+#-Q- ada # @ wall_clock_limit = 1:00:00
+#-Q- ada # Nombre de taches OpenMP/pthreads par processus MPI
+#-Q- ada ### @ parallel_threads = 4
+#-Q- ada # Fin de l entete
+#-Q- ada # @ queue
+#-Q- lxiv8 ######################
+#-Q- lxiv8 ## OBELIX      LSCE ##
+#-Q- lxiv8 ######################
+#-Q- lxiv8 #PBS -N ::Jobname::
+#-Q- lxiv8 #PBS -m a
+#-Q- lxiv8 #PBS -j oe
+#-Q- lxiv8 #PBS -q medium
+#-Q- lxiv8 #PBS -o Script_Output_::Jobname::.000001
+#-Q- lxiv8 #PBS -S /bin/ksh
+#-Q- lxiv8 #PBS -v BATCH_NUM_PROC_TOT=::JobNumProcTot::
+#-Q- lxiv8 #PBS -l nodes=1:ppn=::JobNumProcTot::
+#-Q- default #!/bin/ksh
+#-Q- default ##################
+#-Q- default ## DEFAULT HOST ##
+#-Q- default ##################
+#-Q- default #For MPI use, uncomment next line :
+#-Q- default #BATCH_NUM_PROC_TOT=::JobNumProcTot::
+
+#**************************************************************
+# Author: Sebastien Denvil
+# Contact: Sebastien.Denvil__at__ipsl.jussieu.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#set -eu
+#set -vx
+
+date
+echo
+echo "#######################################"
+echo "#       ANOTHER GREAT SIMULATION      #"
+echo "#######################################"
+echo
+
+#D--------------------------------------------------------------------==
+#D-
+#D-                      Job to launch IGCM models
+#D-
+#D--------------------------------------------------------------------==
+#D-
+
+MODIPSL=::modipsl::
+libIGCM=${MODIPSL}/libIGCM
+
+#D--------------------------------------------------------------------==
+#D- -1. PLACE FOR USER MODIFICATION
+#D-     - Job Verbosity
+#D-     - PeriodNb
+#D-     - Experience type : DEB(ug), DEV(elopment), RUN
+#D--------------------------------------------------------------------==
+
+#D- Task type (computing or post-processing)
+TaskType=computing
+#D- Increased verbosity (1, 2, 3)
+Verbosity=3
+#D- Experience type : DEB(ug), DEV(elopment), RUN (default)
+JobType=RUN
+#D- Number of execution in one job
+PeriodNb=1
+#-Q- sx9mercure PeriodNb=60
+
+#D-
+#D- --------------------------------------------------------------------------------------------------#
+#D-                          ! OPTIONNAL FEATURES /!\ USE WITH CARE !                                 #
+#D- --------------------------------------------------------------------------------------------------#
+
+
+#D- Low level debug : to bypass lib test checks and stack construction
+#D- Default=true
+#D-
+DEBUG_debug=false
+
+#D- Messaging : all activities and call stacks will be sent to ipsl servers
+#D- If true will imply DEBUG_debug=true
+#D- Default=false
+#D-
+BigBrother=false
+
+#D- Set DEBUG_sys to false to disable output calls of function
+#D- true when JobType=DEB # means DEB(ug)
+#D-
+#DEBUG_sys=false
+
+#D- Define running directory
+#D- Default=${TMPDIR} ie temporary batch directory
+#D-
+#RUN_DIR_PATH=/workdir/or/scratchdir/of/this/machine
+
+#D- Define submit directory
+#D- Default= where you launch qsub (variable from scheduler)
+#D-
+#SUBMIT_DIR=$( pwd )
+
+#D- Define input file root directory
+#D- Default=/IGCMG/common/account/of/this/machine
+#D-
+#R_IN=/u/rech/por/rpor111/DATA
+
+#D- Turn in dry run mode ? (0,1,2,3)
+#D- Default=0
+#D-
+#DRYRUN=3
+#D-# YOU HAVE TO COMPILE YOUR EXE FILES to USE DRYRUN MODE !
+#D-# -------------------------------------------------------------------------------------
+#D-# | DRYRUN=  |  Date computations, | sys_Get    |  Exe    | sys_Put_Out; sys_Put_Rest |
+#D-# |          |  Cp/Exe/param/files |            |         |                           |
+#D-# |          |  Chmod Qsub         |            |         |                           |
+#D-# -------------------------------------------------------------------------------------
+#D-# |    0     |       yes           |    yes     |  yes    |      yes                  |
+#D-# -------------------------------------------------------------------------------------
+#D-# |    1     |       yes           |    yes     |  yes    |      no                   |
+#D-# -------------------------------------------------------------------------------------
+#D-# |    2     |       yes           |    yes     |  no     |      no                   |
+#D-# -------------------------------------------------------------------------------------
+#D-# |    3     |       yes           |    no      |  no     |      no                   |
+#D-# -------------------------------------------------------------------------------------
+
+#D-
+# --------------------------------------------------------------------------------------------------#
+#D- ! END OF OPTIONNAL FEATURES /!\ DO NOT MODIFY ANYTHING BELOW UNLESS YOU KNOW WHAT YOU ARE DOING #
+# --------------------------------------------------------------------------------------------------#
+
+#D-
+#D--------------------------------------------------------------------==
+#D- 0. SYSTEM ENVIRONMENT
+#D-    - Define variables for Number of processors
+#D-    - Define MPI variables
+#D-    - Define batch scheduler variables
+#D-    - Source IGCM Library
+#D-    - Get RESOLution in .resol file (temporary)
+#D--------------------------------------------------------------------==
+
+#---------------------------------------------------------------------==
+
+. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
+. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
+. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
+#-------
+. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
+. ${libIGCM}/libIGCM_config/libIGCM_config.ksh
+. ${libIGCM}/libIGCM_comp/libIGCM_comp.ksh
+. ${libIGCM}/libIGCM_post/libIGCM_post.ksh
+#-------
+( ${DEBUG_debug} ) && IGCM_debug_Check
+( ${DEBUG_debug} ) && IGCM_card_Check
+( ${DEBUG_debug} ) && IGCM_date_Check
+
+#--------------------------------------------------------------------==
+
+#-- Resolution FLAG for oasis input
+#RESOL="ORCA2xLMD9671"
+[ -f ${SUBMIT_DIR}/../.resol ] && RESOL=$(head -1 ${SUBMIT_DIR}/../.resol)
+#-- Chemistrie FLAG to ease chemistries configurations management
+#CHEM="AER"
+[ -f ${SUBMIT_DIR}/../.chimie ] && eval $(grep CHEM ${SUBMIT_DIR}/../.chimie)
+
+#D-
+#D--------------------------------------------------------------------==
+#D- 1. INITIALIZE CONFIGURATION
+#D-    - Simulation configuration
+#D-    - Simulation parameters
+#D-    - Execution parameter
+#D-    - Define input files directory
+#D-    - Read or initialize CumulPeriod
+#D-    - run.card
+#D---------------------------------------------------------------------==
+IGCM_config_Initialize
+
+# --------------------------------------------------------------------==
+# Define, create and cd RUN_DIR
+# --------------------------------------------------------------------==
+RUN_DIR=${RUN_DIR_PATH}/${config_UserChoices_JobName}.${$}
+IGCM_sys_MkdirWork ${RUN_DIR}
+IGCM_sys_Cd ${RUN_DIR}
+
+# ------------------------------------------------------------------
+# Test if all was right before proceeding further
+# ------------------------------------------------------------------
+IGCM_debug_Verif_Exit
+
+#D-
+#D---------------------------------------------------------------------==
+#D- 2. INITIALIZE ALL COMPONENT OF THE CONFIGURATION
+#D-    - Define component executable
+#D-    - Define Write Frequency by component "1M" "1D" ...
+#D-    - Source ${comp}.driver
+#D-    - Define Storage Places by component
+#D-    - ${comp}_Initialize :
+#D-    - Patterns to sed
+#D-    - Variables from namelist
+#D---------------------------------------------------------------------==
+IGCM_comp_Initialize
+
+#D-
+#D---------------------------------------------------------------------==
+#D- 3. PERFORM GENERAL VERIFICATION
+#D-    - Verify compatibility of period length, write frequencies, ...
+#D-    - Verify compatibility of rebuild choices and post-process choices
+#D-    - Will stop here if something is wrong
+#D---------------------------------------------------------------------==
+IGCM_config_Check
+
+# ------------------------------------------------------------------
+# Test if all was right before entering the period loop
+# ------------------------------------------------------------------
+IGCM_debug_Verif_Exit
+
+# ------------------------------------------------------------------
+# Activate BigBrother so as to supervise this simulation
+# ------------------------------------------------------------------
+IGCM_debug_ActivateBigBro
+
+#D-
+#D---------------------------------------------------------------------==
+#D- 4. ENTER THE DEEP EXECUTION LOOP
+#D-    ! FASTEN YOUR SEAT BELTS PLEASE. !
+#D-    !   WE WILL CROSS TURBULENCES.   !
+#D---------------------------------------------------------------------==
+
+Period=1
+
+PeriodContinue=false
+if [ ${Period} -le ${PeriodNb} ]; then
+  PeriodContinue=true
+fi
+while ( ${PeriodContinue} ) ; do
+
+  echo
+  echo "Starting iteration ${Period} / ${PeriodNb}"
+
+  #D-
+  # ------------------------------------------------------------------
+  #D-   4.1 COMPUTE AND DEFINE DATE INFORMATION.
+  #D-       - ${PeriodDateBegin}
+  #D-       - ${PeriodDateEnd}
+  #D-       - ${CumulPeriod}
+  #D-       - ${DatesPeriod}=${PeriodDateBegin}_${PeriodDateEnd}
+  #D-       - ${PeriodLength} => JOURS=31 , 28, 29, 30 ; MOIS=0 ; ANS=0
+  #D-       - update run.card value
+  # ------------------------------------------------------------------
+  IGCM_config_PeriodStart
+
+  #D-
+  # ------------------------------------------------------------------
+  #D-   4.2 BEGIN COMPUTATION ONLY IF NEEDED
+  # ------------------------------------------------------------------
+  if [ ${SimulationLengthInDays} -gt ${ExperienceLengthInDays} ] ; then
+    IGCM_debug_Print 1 "break because '${SimulationLengthInDays} -gt ${ExperienceLengthInDays}' : ${SimulationLengthInDays} -gt ${ExperienceLengthInDays}"
+    break ;
+  fi
+
+  #D-
+  # ------------------------------------------------------------------
+  #D-   4.3 CALL OPTIONNAL FUNCTION WITHIN DRIVER
+  #D-       - to set special variables used in lists (Param, Init or Bc).
+  # ------------------------------------------------------------------
+  IGCM_comp_PeriodStart
+
+  #D-
+  # ------------------------------------------------------------------
+  #D-   4.4 GET PARAMETERS TEXT FILES UPDATED BY JOB
+  #D-       - (.def, namelist ...)
+  #D-       - READ AND USE BY GCM AT EACH EXECUTION.
+  # ------------------------------------------------------------------
+  IGCM_comp_GetInputParametersFiles
+
+  #D-
+  # ------------------------------------------------------------------
+  #D-   4.5 GET INITIAL STATE
+  #D-       - (Etat0, carteveg,relief...)
+  #D-       - NECESSARY ONLY IF CumulPeriod= (=> NUMERO) == 1
+  #D-       - AND ???_Restart=NO
+  #D-       - READ AND USE BY GCM FOR ONLY ONE EXECUTION.
+  # ------------------------------------------------------------------
+  IGCM_comp_GetInputInitialStateFiles
+
+  #D-
+  # ------------------------------------------------------------------
+  #D-   4.6 GET BOUNDARIES CONDITIONS
+  #D-       - (SST, WIND[X,Y,Z], LAI ...)
+  #D-       - READ AND USE BY GCM AT EACH EXECUTION.
+  # ------------------------------------------------------------------
+  IGCM_comp_GetInputBoundaryFiles
+
+  #D-
+  # ------------------------------------------------------------------
+  #D-   4.7 GET SmoothFiles CONDITIONS
+  #D-       - (SST, WIND[X,Y,Z], LAI ...)
+  #D-       - READ AND USE BY GCM AT EACH EXECUTION
+  #D-       - Do not change at each ${Period}
+  # ------------------------------------------------------------------
+  IGCM_comp_GetInputSmoothFiles
+
+  #D-
+  # ------------------------------------------------------------------
+  #D-   4.8 GET RESTART FILES
+  #D-       - (restartphy.nc, orca_restart.nc ...)
+  #D-       - READ AND USE BY GCM AT EACH EXECUTION.
+  #D-
+  #D-       - IF A COMPONENT DO NOT RESTART FROM PREVIOULSY COMPUTED RESTART
+  #D-       - ONLY IF CumulPeriod= (=> NUMERO) == 1
+  #D-       - MUST EXECUTE CREATE ETAT0_LIMIT (TYPICALLY LMDZ AND ./create_etat0_limit.e)
+  #D-
+  #D-       - IF CumulPeriod == 1
+  #D-       - AND A COMPONENT RESTART FROM PREVIOULSY COMPUTED RESTART
+  #D-       - MUST BRING THIS RESTART IN ${RUN_DIR_PATH}
+  #D-
+  #D-       - ELSE BRING RESTART FROM ${JobName} IN ${RUN_DIR_PATH}
+  # ------------------------------------------------------------------
+  IGCM_comp_GetInputRestartFiles
+
+  # ------------------------------------------------------------------
+  # Test if all was right before Update
+  # ------------------------------------------------------------------
+  IGCM_debug_Verif_Exit
+
+  #D-
+  # ------------------------------------------------------------------
+  #D-   4.9 ACTIVATE RUNNING ENVIRONNEMENT VARIABLES
+  # ------------------------------------------------------------------
+  IGCM_sys_activ_variables
+
+  #D-
+  # ------------------------------------------------------------------
+  #D-   4.10 UPDATE ParametersFiles
+  #D-        - (.def, namelist ...)
+  #D-        - with current value of (ORCA_NIT00, ORCA_LRSTAR, RAZ_DATE, ...)
+  # ------------------------------------------------------------------
+  IGCM_comp_Update
+
+  # ------------------------------------------------------------------
+  # Test if all was right before execution
+  # ------------------------------------------------------------------
+  IGCM_debug_Verif_Exit
+
+  #D-
+  #D---------------------------------------------------------------------==
+  #D- 5. EXECUTION
+  #D---------------------------------------------------------------------==
+
+  echo
+  echo "#######################################"
+  echo "#      DIR BEFORE RUN EXECUTION       #"
+  echo "#######################################"
+  echo
+  ls -lrt
+
+  echo "========================================================================"
+  if [ ${DRYRUN} -le 1 ] ; then
+    REAL_DATE_INIT=$( date )
+    echo                                                                                   > ${Exe_Output}
+    echo "#######################################"                                        >> ${Exe_Output}
+    echo "EXECUTION of : ${EXECUTION}"
+    echo "EXECUTION of : ${EXECUTION}"                                                    >> ${Exe_Output}
+    echo                                                                                  >> ${Exe_Output}
+    typeset RET
+    RUN_DATE_BEGIN=$( date '+%Y-%m-%dT%H:%M:%S' )
+    ${EXECUTION}  >> ${Exe_Output} 2>&1
+    RET=$?
+    RUN_DATE_END=$( date '+%Y-%m-%dT%H:%M:%S' )
+    if [ ${RET} -gt 0 ] ; then
+      echo "Return code of executable :" ${RET}
+      IGCM_debug_Exit "EXECUTABLE"
+      IGCM_sys_Mkdir ${SUBMIT_DIR}/Debug
+      IGCM_sys_Cp ${Exe_Output} ${SUBMIT_DIR}/Debug/${PREFIX}_${Exe_Output}_error
+      ExecutionFail=true
+    fi
+    echo                                            >> ${Exe_Output}
+    echo "#######################################"  >> ${Exe_Output}
+    echo "libIGCM RunDateBegin=${RUN_DATE_BEGIN}"   >> ${Exe_Output}
+    echo "libIGCM RunDateEnd=${RUN_DATE_END}"       >> ${Exe_Output}
+    echo                                            >> ${Exe_Output}
+  else
+    echo "EXECUTION of : ${EXECUTION} simulated for DRYRUN = " $DRYRUN
+    echo "EXECUTION of : ${EXECUTION} simulated for DRYRUN = " $DRYRUN > ${Exe_Output}
+    if ( $DEBUG_debug ) ; then
+      echo "FOR EXECUTION DRYRUN mode = " $DRYRUN >> stack
+    fi
+  fi
+  echo "========================================================================"
+
+  echo
+  echo "#######################################"
+  echo "#       DIR AFTER RUN EXECUTION       #"
+  echo "#######################################"
+  echo
+  ls -lrt
+
+  #D-
+  #D---------------------------------------------------------------------==
+  #D- 6. POST EXECUTION OPERATIONS
+  #D---------------------------------------------------------------------==
+
+  #D-
+  # ------------------------------------------------------------------
+  #D-   6.1. DESACTIVATE RUNNING ENVIRONNEMENT VARIABLES
+  # ------------------------------------------------------------------
+  IGCM_sys_desactiv_variables
+
+  #D-
+  # ------------------------------------------------------------------
+  #D-   6.2. SAVE OUTPUTS
+  #D-        - On archive/storage machine
+  #D-        - netcdf outputs, restarts and text files of models
+  # ------------------------------------------------------------------
+  IGCM_comp_Finalize
+
+  # ------------------------------------------------------------------
+  # Test if all was right after Finalize
+  # ------------------------------------------------------------------
+  IGCM_debug_Verif_Exit
+
+  #D-
+  # ------------------------------------------------------------------
+  #D-   6.3. CONFIGURE POST-PROCESSING
+  #D-        - asynchronous post-treatment (Level 0) when necessary (rebuild/pack)
+  #D-        - classic post-treatment      (Level 1) when necessary (TimeSeries/Seasonal)
+  # ------------------------------------------------------------------
+  IGCM_post_Configure
+
+  #D-
+  # ------------------------------------------------------------------
+  #D-   6.4. SUBMIT POST-PROCESSING
+  #D-        - remote rebuild or/and post-treatment process if necessary
+  # ------------------------------------------------------------------
+  IGCM_post_Submit
+
+  #D-
+  # ------------------------------------------------------------------
+  #D-   6.5. FINALYZE CURRENT LOOP AND PREPARE NEXT ONE
+  #D-        - Manage executable size to save only different binary
+  #D-        - Write in run.card user, system and elapse time
+  #D-        - Check that everything went well ! No ? then we stop.
+  #D-        - Determine next computed period
+  # ------------------------------------------------------------------
+  IGCM_config_PeriodEnd
+
+  echo "Ending iteration ${Period}"
+  (( Period = Period + 1 ))
+
+  # End loop if date end is reached
+  if [ ${SimulationLengthInDays} -ge ${ExperienceLengthInDays} ] ; then
+    break ;
+  fi
+
+  PeriodContinue=false
+  if [ ${Period} -le ${PeriodNb} ]; then
+    PeriodContinue=true
+  fi
+done
+
+#D-
+#D---------------------------------------------------------------------==
+#D- 7. SUBMIT NEXT JOB OR SEND MAIL IF SIMULATION IS OVER.
+#D---------------------------------------------------------------------==
+IGCM_config_Finalize
+
+date
Index: /tags/libIGCM_v2.2/AA_monitoring
===================================================================
--- /tags/libIGCM_v2.2/AA_monitoring	(revision 998)
+++ /tags/libIGCM_v2.2/AA_monitoring	(revision 998)
@@ -0,0 +1,236 @@
+#-Q- curie ######################
+#-Q- curie ## CURIE   TGCC/CEA ##
+#-Q- curie ######################
+#-Q- curie #MSUB -r MONITORING     # Nom du job
+#-Q- curie #MSUB -eo
+#-Q- curie #MSUB -n 1              # Reservation du processus
+#-Q- curie #MSUB -T 14400          # Limite de temps elapsed du job
+#-Q- curie #MSUB -q xlarge
+#-Q- curie #MSUB -Q normal
+#-Q- curie #MSUB -A ::default_project::
+#-Q- curie set +x
+#-Q- ada #!/bin/ksh
+#-Q- ada #######################
+#-Q- ada ## ADA         IDRIS ##
+#-Q- ada #######################
+#-Q- ada # @ job_type = serial
+#-Q- ada # @ requirements = (Feature == "prepost")
+#-Q- ada # Temps Elapsed max. d'une requete hh:mm:ss
+#-Q- ada # @ wall_clock_limit = 4:00:00
+#-Q- ada # Nom du travail LoadLeveler
+#-Q- ada # @ job_name   = MONITORING
+#-Q- ada # Fichier de sortie standard du travail
+#-Q- ada # @ output     = $(job_name).$(jobid)
+#-Q- ada # Fichier de sortie d'erreur du travail
+#-Q- ada # @ error      =  $(job_name).$(jobid)
+#-Q- ada # pour recevoir un mail en cas de depassement du temps Elapsed (ou autre pb.)
+#-Q- ada # @ notification = error
+#-Q- ada # @ environment  = $POST_DIR ; $SUBMIT_DIR ; $libIGCM ; $libIGCM_SX ; $R_INIT ; $R_BC ; $StandAlone ; $RESOL_ATM ; $RESOL_OCE ; $RESOL_ICE ; $RESOL_MBG ; $RESOL_SRF ; $R_SAVE ; $config_UserChoices_JobName ; $config_UserChoices_TagName ; $YEARS ; $MASTER
+#-Q- ada # @ queue
+#-Q- lxiv8 ######################
+#-Q- lxiv8 ## OBELIX      LSCE ##
+#-Q- lxiv8 ######################
+#-Q- lxiv8 #PBS -N MONITORING
+#-Q- lxiv8 #PBS -m a
+#-Q- lxiv8 #PBS -j oe
+#-Q- lxiv8 #PBS -q medium
+#-Q- lxiv8 #PBS -o MONITORING.$$
+#-Q- lxiv8 #PBS -S /bin/ksh
+#-Q- default #!/bin/ksh
+#-Q- default ##################
+#-Q- default ## DEFAULT HOST ##
+#-Q- default ##################
+
+#**************************************************************
+# Author: Sebastien Denvil
+# Contact: Sebastien.Denvil__at__ipsl.jussieu.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#set -eu
+#set -vx
+
+date
+
+#-Q- ada export OMP_NUM_THREADS=1
+
+#D- Task type (computing or post-processing)
+TaskType=post-processing
+
+########################################################################
+
+#D- Flag to determine if this job in a standalone mode
+#D- Default : value from AA_job if any
+StandAlone=${StandAlone:=true}
+
+#D- Path to libIGCM
+#D- Default : value from AA_job if any
+# WARNING For StandAlone use : To run this script on some machine (ada 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- 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- TEMPORARY Flag to determine atmospheric resolution
+#D- Default : value from atmospheric driver if any
+RESOL_ATM=${RESOL_ATM:=ALL}
+
+#D- Flag to determine surface resolution
+#D- Default : value from surface driver if any
+RESOL_SRF=${RESOL_SRF:=ALL}
+
+#D- Flag to determine surface resolution
+#D- Default : value from surface driver if any
+RESOL_SBG=${RESOL_SBG:=ALL}
+
+#D- TEMPORARY Flag to determine ocean resolution
+#D- Default : value from ocean driver if any
+RESOL_OCE=${RESOL_OCE:=ORCA2}
+
+#D- TEMPORARY Flag to determine ice resolution
+#D- Default : value from ice driver if any
+RESOL_ICE=${RESOL_ICE:=ORCA2}
+
+#D- TEMPORARY Flag to determine marine biogeochemistry resolution
+#D- Default : value from ice driver if any
+RESOL_MBG=${RESOL_MBG:=ORCA2}
+
+######################################################################
+
+. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
+. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
+. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
+#-------
+. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
+. ${libIGCM}/libIGCM_config/libIGCM_config.ksh
+#-------
+( ${DEBUG_debug} ) && IGCM_debug_Check
+( ${DEBUG_debug} ) && IGCM_card_Check
+( ${DEBUG_debug} ) && IGCM_date_Check
+
+######################################################################
+
+#set -vx
+
+#===========================================
+RUN_DIR=${RUN_DIR_PATH}
+IGCM_sys_MkdirWork ${RUN_DIR}
+IGCM_sys_Cd ${RUN_DIR}
+
+# ------------------------------------------------------------------
+# Test if all was right before proceeding further
+# ------------------------------------------------------------------
+IGCM_debug_Verif_Exit_Post
+
+if [ ${StandAlone} = true ] ; then
+  CARD_DIR=${SUBMIT_DIR}
+else
+  CARD_DIR=${RUN_DIR}
+  IGCM_sys_Get_Master ${SUBMIT_DIR}/config.card ${RUN_DIR_PATH}
+  IGCM_sys_Get_Master ${SUBMIT_DIR}/run.card    ${RUN_DIR_PATH}
+  IGCM_sys_Get_Master ${SUBMIT_DIR}/COMP        ${RUN_DIR_PATH}
+  IGCM_sys_Get_Master ${SUBMIT_DIR}/POST        ${RUN_DIR_PATH}
+fi
+
+#==================================
+# First of all
+#
+# Read libIGCM compatibility version in config.card
+# Read UserChoices section
+# Read Ensemble section
+# Read Post section
+# Define all netcdf output directories
+#==================================
+IGCM_config_CommonConfiguration ${CARD_DIR}/config.card
+
+#==================================
+# Read ListOfComponents section:
+IGCM_card_DefineArrayFromSection ${CARD_DIR}/config.card ListOfComponents
+
+# Create R_FIGR that has been defined by IGCM_config_CommonConfiguration
+IGCM_sys_MkdirArchive ${R_FIGR}
+#
+IGCM_sys_TestDirArchive ${R_FIGR}/MONITORING
+if [ $? = 0 ] ; then
+  IGCM_debug_Print 1 "Get MONITORING directory from archive"
+  IGCM_sys_Get_Dir ${R_FIGR}/MONITORING ${RUN_DIR}
+else
+  IGCM_debug_Print 1 "MONITORING first pass. Nothing has been done before"
+fi
+# --------------------------------------------
+# Insert your commands between III...III lines
+# and precise produced directories to save
+# IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
+
+for comp in ${config_ListOfComponents[*]} ; do
+  IGCM_debug_Print 1 "################## Component: ${comp} ######################"
+  liste_file_monitoring=""
+  IGCM_card_DefineArrayFromOption ${CARD_DIR}/config.card ListOfComponents ${comp}
+  eval compname=\${config_ListOfComponents_${comp}[0]}                > /dev/null 2>&1
+
+  PATH_monitoring_file=""
+  eval monitoring_file=monitoring01_${compname}_\${RESOL_${comp}}.cfg > /dev/null 2>&1
+  if [[ -d ${CARD_DIR}/POST && -f ${CARD_DIR}/POST/monitoring01_${compname}.cfg ]] ; then
+    PATH_monitoring_file=${CARD_DIR}/POST/monitoring01_${compname}.cfg
+  elif [ -f ${FER_ATLAS}/${monitoring_file} ] ; then
+    PATH_monitoring_file=${FER_ATLAS}/${monitoring_file}
+  else
+    IGCM_debug_Print 1 "No monitoring file found for this component. Was expecting ${monitoring_file}"
+    IGCM_debug_Print 1 "Step to next component"
+    continue
+  fi
+  #
+  if [ X${PATH_monitoring_file} != X"" ] ; then
+    IGCM_debug_Print 1 "Monitoring file used : ${PATH_monitoring_file}"
+    IGCM_debug_Print 1 "Determine which frequency of time series to be used."
+
+    FreqTS=$( grep FreqTS ${PATH_monitoring_file} | grep -v \# | awk -F "=" '{print $2}' )
+    if [ X${FreqTS} = X ] ; then
+      # Default frequency is MO
+      FreqTS=MO
+    fi
+
+    IGCM_debug_Print 1 "Times series frequency to be used is ${FreqTS}"
+    IGCM_debug_Print 1 "Determine which files we need."
+    . monitoring01 -l2 --listcommand 'IGCM_sys_RshArchive_NoError ls' ${PATH_monitoring_file} ${R_SAVE}/${comp}/Analyse/TS_${FreqTS}
+    liste_file_monitoring=$( . monitoring01 -q -l2 --listcommand 'IGCM_sys_RshArchive_NoError ls' ${PATH_monitoring_file} ${R_SAVE}/${comp}/Analyse/TS_${FreqTS} )
+  fi
+  #
+  if [ ! "X${liste_file_monitoring}" = X ] ; then
+    IGCM_sys_Get /l liste_file_monitoring ${RUN_DIR}
+    IGCM_debug_Print 1 "monitoring01 -c ${CARD_DIR} -p ${comp} --time -t \"${config_UserChoices_JobName} monitoring\" -o ${RUN_DIR}/MONITORING ${PATH_monitoring_file} ."
+    IGCM_debug_Print 1 "monitoring01 starts ................................................."
+    monitoring01 -c ${CARD_DIR} -p ${comp} --time -t "${config_UserChoices_JobName} monitoring" -o ${RUN_DIR}/MONITORING ${PATH_monitoring_file} .
+  else
+    IGCM_debug_Print 1 "No time series detected by this command :"
+    IGCM_debug_Print 1 "monitoring01 -l2 --listcommand 'IGCM_sys_RshArchive_NoError ls' ${PATH_monitoring_file} ${R_SAVE}/${comp}/Analyse/TS_${FreqTS}"
+    . monitoring01 -l2 --listcommand 'IGCM_sys_RshArchive_NoError ls' ${PATH_monitoring_file} ${R_SAVE}/${comp}/Analyse/TS_${FreqTS}
+  fi
+  #
+done
+
+# IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
+
+# Save files
+IGCM_sys_Put_Dir MONITORING ${R_FIGR}
+
+# Dods copy
+if [ X${config_Post_DodsCopy} = XTRUE ]  ; then
+  IGCM_sys_Put_Dods MONITORING
+fi
+
+# Clean RUN_DIR_PATH (necessary for cesium and titane only)
+IGCM_sys_RmRunDir -Rf ${RUN_DIR_PATH}
Index: /tags/libIGCM_v2.2/AA_move-and-rename
===================================================================
--- /tags/libIGCM_v2.2/AA_move-and-rename	(revision 998)
+++ /tags/libIGCM_v2.2/AA_move-and-rename	(revision 998)
@@ -0,0 +1,539 @@
+#!/bin/ksh
+
+#**************************************************************
+# Author: Martial Mancip
+# Contact: Martial.Mancip__at__ipsl.jussieu.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#D- Task type (computing or post-processing)
+TaskType=post-processing
+
+# Change SpaceName/ExperimentName/JobName names and path for a simulation during the run.
+# !! Be careful that the job is suspended before using this script !!
+# You may call this script with those four variables already defined, or modify directly
+# default values under here :
+
+# New Name Space of this experience
+NEW_SpaceName=${NEW_SpaceName:=DEVT}
+
+# New Expericence class of the run
+NEW_ExperimentName=${NEW_ExperimentName:=NEWExperimentName}
+
+# New JobName of the run
+NEW_JobName=${NEW_JobName:=NEWJobName}
+
+SUBMIT_DIR=${SUBMIT_DIR:=my_path_to_my_SUBMIT_DIR}
+
+# verbosity
+Verbosity=3
+
+########################################################################
+
+# Path to modipsl
+MODIPSL=${MODIPSL:=::modipsl::}
+
+#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
+DEBUG_debug=false
+
+########################################################################
+
+. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
+. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
+. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
+#-------
+. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
+. ${libIGCM}/libIGCM_config/libIGCM_config.ksh
+#-------
+( ${DEBUG_debug} ) && IGCM_debug_Check
+( ${DEBUG_debug} ) && IGCM_card_Check
+( ${DEBUG_debug} ) && IGCM_date_Check
+
+########################################################################
+# define local functions
+
+# Function to replace OLD JobName in file
+
+function REPLACE_sed
+{
+  IGCM_debug_PushStack "REPLACE_sed"
+  typeset RET
+
+  FILEIN=${1}
+  FILEOUT=$( basename ${FILEIN} )
+
+  sed -e "s&${R_SAVE}&${NEW_R_SAVE}&g" -e "s/${config_UserChoices_JobName}/${NEW_JobName}/g" \
+  ${1} > ${RUN_DIR_PATH}/${FILEOUT}
+  RET=$?
+
+  touch --reference=${1} ${RUN_DIR_PATH}/${FILEOUT}
+  IGCM_sys_Mv ${RUN_DIR_PATH}/${FILEOUT} ${2}
+  chmod --reference=${1} ${2}/${FILEOUT}
+
+  IGCM_sys_Rm -f ${1}
+
+  IGCM_debug_Print 3 "REPLACE_sed : ${1} ${2}"
+
+  IGCM_debug_PopStack "REPLACE_sed"
+  return $RET
+}
+
+function MOVE_and_RENAME_files
+{
+  IGCM_debug_PushStack "MOVE_and_RENAME_files"
+
+  typeset VAR_files FILE_OUT file i RET
+
+  VAR_files=${1}
+  eval VAR1=\${${VAR_files[0]}}
+
+  if [ X$( echo ${NEW_R_SAVE} | grep ${config_UserChoices_JobName} ) != X ]; then
+    set +A FILE_OUT -- $( eval echo \${${VAR_files}[*]} | sed -e "s&${R_SAVE}&${NEW_R_SAVE}&g" )
+    ((i=0))
+    for file in ${FILE_OUT[@]} ; do
+      FILE_OUT[$i]=$( dirname $file )/$( echo $( basename $file ) | sed -e "s/${config_UserChoices_JobName}/${NEW_JobName}/g" )
+      (( i = i + 1 ))
+    done
+  else
+    set +A FILE_OUT -- $( eval echo \${${VAR_files}[*]} | sed -e "s&${R_SAVE}&${NEW_R_SAVE}&g" -e "s/${config_UserChoices_JobName}/${NEW_JobName}/g" )
+  fi
+  IGCM_debug_Print 3 "MOVE_and_RENAME_files all : ${VAR1}"
+  IGCM_debug_Print 3 "    to     ${FILE_OUT}."
+
+  (( ifile = 0 ))
+  for file_o in ${FILE_OUT[@]} ; do
+    eval IGCM_sys_Mv \${${VAR_files}[${ifile}]} ${file_o}
+    RET=$?
+    (( ifile = ifile + 1 ))
+  done
+
+  IGCM_debug_PopStack "MOVE_and_RENAME_files"
+  return $RET
+}
+
+function MY_DODS_Cp
+{
+  IGCM_debug_PushStack "MY_DODS_Cp"
+
+  typeset old_JobName old_R_DODS
+  IGCM_sys_Cd ${NEW_R_SAVE}
+  old_JobName=${config_UserChoices_JobName}
+  old_R_DODS=${R_DODS}
+  old_R_SAVE=${R_SAVE}
+
+  config_UserChoices_JobName=${NEW_JobName}
+  R_DODS=${NEW_R_DODS}
+  R_SAVE=${NEW_R_SAVE}
+
+  IGCM_sys_Dods_Cp ${1}
+  IGCM_debug_Print 3 "MY_DODS_Cp : ${config_UserChoices_JobName}/${1}"
+  IGCM_sys_Cd ${RUN_DIR_PATH}
+
+  config_UserChoices_JobName=${old_JobName}
+  R_DODS=${old_R_DODS}
+  R_SAVE=${old_R_SAVE}
+
+  IGCM_debug_PopStack "MY_DODS_Cp"
+}
+
+function MY_DODS_Rm
+{
+  IGCM_debug_PushStack "MY_DODS_Rm"
+  DEBUG_debug=false
+
+  IGCM_sys_Cd ${R_SAVE}
+  IGCM_sys_Dods_Rm ${1}
+  IGCM_debug_Print 3 "MY_DODS_Rm : ${config_UserChoices_JobName}/${1}"
+  IGCM_sys_Cd ${RUN_DIR_PATH}
+
+  IGCM_debug_PopStack "MY_DODS_Rm"
+}
+########################################################################
+
+if [ ! -d ${SUBMIT_DIR} ]; then
+  IGCM_debug_Print 1 "No ${SUBMIT_DIR}, we stop here"
+  exit 1
+fi
+
+# We temporary change ${run_Configuration_PeriodState} to
+if [ -f ${SUBMIT_DIR}/run.card ] ; then
+  IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState
+  if ( [ ${run_Configuration_PeriodState} != "Start" ] && [ ${run_Configuration_PeriodState} != "Running" ] && [ ${run_Configuration_PeriodState} != "OnQueue" ] && [ ${run_Configuration_PeriodState} != "Continue" ] ) ; then
+    old_run_Configuration_PeriodState=${run_Configuration_PeriodState}
+    IGCM_debug_PrintVariables 2 old_run_Configuration_PeriodState
+    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "OnQueue"
+  fi
+fi
+
+IGCM_config_Initialize
+
+if [ -f ${SUBMIT_DIR}/run.card ] ; then
+  IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration OldPrefix
+  IGCM_debug_PrintVariables 2 run_Configuration_OldPrefix
+  if [ X${old_run_Configuration_PeriodState} != X"Completed" ] ; then
+    DateEnd=$( IGCM_date_ConvertFormatToGregorian $( echo ${run_Configuration_OldPrefix} | awk -F'_' '{print $2}' ) )
+  else
+    DateEnd=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} )
+  fi
+else
+  DateEnd=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} )
+fi
+
+IGCM_debug_Print 1 ""
+IGCM_debug_Print 1 "DateEnd for MoveJob_Checker : " ${DateEnd}
+IGCM_date_GetYearMonth ${DateEnd}   YearEnd   MonthEnd
+IGCM_debug_Print 1 "YearEnd MonthEnd for TimeSeries_Checker : " ${YearEnd} ${MonthEnd}
+IGCM_debug_Print 1 ""
+
+#set -vx
+
+#====================================================
+#DEFINE NEW_R_SAVE
+if [ X${config_UserChoices_SpaceName} != X ] ; then
+  NEW_SAVE=${config_UserChoices_TagName}/${NEW_SpaceName}
+else
+  NEW_SAVE=${config_UserChoices_TagName}
+fi
+if [ X${config_UserChoices_ExperimentName} != X ] ; then
+  NEW_SAVE=${NEW_SAVE}/${NEW_ExperimentName}
+fi
+
+NEW_R_SAVE=${R_OUT}/${NEW_SAVE}/${NEW_JobName}
+
+IGCM_debug_Print 1 "Move ${R_SAVE} to ${NEW_R_SAVE}"
+if [ -d ${NEW_R_SAVE} ] ; then
+  IGCM_debug_Print 1 "ERROR : ${NEW_R_SAVE} directory already exist !"
+  IGCM_debug_Print 1 "We won't try to  We stop here."
+  exit 1
+fi
+IGCM_sys_MkdirArchive ${NEW_R_SAVE}
+
+# ------------------------------------------------------------------
+# Test if all was right before proceeding further
+# ------------------------------------------------------------------
+IGCM_debug_Verif_Exit_Post
+
+#DEFINE NEW_R_DODS
+NEW_R_DODS=${NEW_SAVE}/${NEW_JobName}
+
+# Define NEW_REBUILD_DIR
+if [ -d ${REBUILD_DIR} ] ; then
+  if [ X${config_Post_RebuildFromArchive} = Xtrue ] ; then
+    NEW_REBUILD_DIR=${NEW_R_SAVE}/TMP
+    IGCM_sys_MkdirArchive ${NEW_REBUILD_DIR}
+  else
+    NEW_REBUILD_DIR=${BIG_DIR}/${config_UserChoices_TagName}/${NEW_JobName}
+    IGCM_sys_MkdirWork ${NEW_REBUILD_DIR}
+  fi
+fi
+
+#====================================================
+# SAVE LOCAL WORKING DIR
+IGCM_sys_Cd ${RUN_DIR_PATH}
+
+#====================================================
+#Exe
+IGCM_debug_Print 1 "Move Exe"
+set +A listfiles -- $( find ${R_SAVE}/Exe -type f )
+
+IGCM_sys_MkdirArchive ${NEW_R_SAVE}/Exe
+MOVE_and_RENAME_files "listfiles"
+
+#====================================================
+#Out
+IGCM_debug_Print 1 "Move Out"
+OutinDir=${R_SAVE}/Out
+OutNEWDir=${NEW_R_SAVE}/Out
+IGCM_sys_MkdirArchive ${OutNEWDir}
+
+# Change JobName and copy run.card
+if [ -f ${OutinDir}/run.card ] ; then
+  sed -e "s/OldPrefix=\ *${config_UserChoices_JobName}/OldPrefix= ${NEW_JobName}/g" \
+    ${OutinDir}/run.card > ${RUN_DIR_PATH}/run.card
+  RET=$?
+  if [ ${RET} = 0 ] ; then
+    IGCM_sys_Mv -f ${RUN_DIR_PATH}/run.card ${OutNEWDir}
+    IGCM_sys_Rm -f ${OutinDir}/run.card
+  fi
+fi
+
+# Just copy historical run.card
+unset listfiles
+set +A listfiles -- $( find ${OutinDir} -type f -name "run.card\.[0-9]*\.[0-9]*" )
+if [ ${#listfiles[*]} -gt 0 ] ; then
+  IGCM_sys_Cp ${listfiles[*]} ${OutNEWDir}
+  RET=$?
+  if [ ${RET} = 0 ] ; then
+    IGCM_sys_Rm -f ${listfiles[*]}
+  fi
+fi
+
+# Move and Rename OLD Script_Output
+unset listfiles
+set +A listfiles -- $( find ${OutinDir} -type f -name "Script_Output_*\.[0-9]*\.[0-9]*" )
+MOVE_and_RENAME_files "listfiles"
+
+# Move and Rename OLD Executable Output
+unset listfiles
+set +A listfiles -- $( find ${OutinDir} -type f -name "*_out_execution" )
+MOVE_and_RENAME_files "listfiles"
+
+#====================================================
+IGCM_debug_Print 1 "For components"
+IGCM_debug_Print 1 "=============="
+
+#====================================================
+#Output
+# loop over components and frequencies
+IGCM_debug_Print 1 "Move Output"
+for comp in ${config_ListOfComponents[*]} ; do
+  IGCM_debug_Print 2 "------------------"
+  IGCM_debug_Print 2 "for component ${comp}"
+
+  unset FREQDIR
+  set +A FREQDIR -- $( find ${R_SAVE}/${comp}/Output -type d -not -name "*Output" )
+
+  IGCM_debug_Print 3 "List of WriteFrequencies : ${FREQDIR[*]}"
+
+  for ThisfreqDir in ${FREQDIR[*]} ; do
+    freq=$( basename ${ThisfreqDir} )
+    IGCM_debug_Print 2 "${freq}."
+
+    NEW_freqDir=${NEW_R_SAVE}/${comp}/Output/${freq}
+    IGCM_sys_MkdirArchive ${NEW_freqDir}
+
+    unset listfiles
+    set +A listfiles -- $( find ${ThisfreqDir} -type f )
+
+    MOVE_and_RENAME_files "listfiles"
+  done
+
+  unset COMPFILES
+  set +A COMPFILES -- $( find ${R_SAVE}/${comp}/Output -type f )
+
+  if [ ${#COMPFILES[*]} -gt 0 ] ; then
+    IGCM_debug_Print 2 "simple Output FILES : ${COMPFILES[*]}."
+
+    MOVE_and_RENAME_files "COMPFILES"
+  fi
+done
+
+#====================================================
+#Restart
+# loop over components
+IGCM_debug_Print 1 "Move Restart"
+for comp in ${config_ListOfComponents[*]} ; do
+  IGCM_debug_Print 2 "------------------"
+  IGCM_debug_Print 2 "for component ${comp}"
+
+  ThisRestDir=${R_SAVE}/${comp}/Restart
+  NEW_RestDir=${NEW_R_SAVE}/${comp}/Restart
+  IGCM_sys_MkdirArchive ${NEW_RestDir}
+
+  unset listfiles
+  set +A listfiles -- $( find ${ThisRestDir} -type f )
+
+  MOVE_and_RENAME_files "listfiles"
+done
+
+#====================================================
+#DEBUG
+# Move and Rename OLD Executable Output
+# loop over components
+IGCM_debug_Print 1 "Move Debug"
+for comp in ${config_ListOfComponents[*]} ; do
+  IGCM_debug_Print 2 "------------------"
+  IGCM_debug_Print 2 "for component ${comp}"
+
+  ThisDebugDir=${R_SAVE}/${comp}/Debug
+  NEW_DebugDir=${NEW_R_SAVE}/${comp}/Debug
+  IGCM_sys_MkdirArchive ${NEW_DebugDir}
+
+  unset listfiles
+  set +A listfiles -- $( find ${ThisDebugDir} -type f )
+
+  MOVE_and_RENAME_files "listfiles"
+done
+
+#====================================================
+#POST
+# loop over components and frequencies
+IGCM_debug_Print 1 "Move Analyse"
+for comp in ${config_ListOfComponents[*]} ; do
+  IGCM_debug_Print 2 "------------------"
+  IGCM_debug_Print 2 "for component ${comp}"
+
+  if [ -d ${R_SAVE}/${comp}/Analyse ] ; then
+    unset TSDIR
+    set +A TSDIR -- $( find ${R_SAVE}/${comp}/Analyse -name "TS_*" -type d )
+
+    for ThisTSDir in ${TSDIR[*]} ; do
+      TS_Dir=$( basename ${ThisTSDir} )
+      IGCM_debug_Print 2 "${TS_Dir}."
+
+      NEW_TSDir=${NEW_R_SAVE}/${comp}/Analyse/${TS_Dir}
+      IGCM_sys_MkdirArchive ${NEW_TSDir}
+
+      MY_DODS_Rm ${comp}/Analyse/${TS_Dir}
+
+      unset listfiles
+      set +A listfiles -- $( find ${ThisTSDir} -type f )
+
+      MOVE_and_RENAME_files "listfiles"
+
+      MY_DODS_Cp ${comp}/Analyse/${TS_Dir}
+    done
+
+    ThisSEDir=${R_SAVE}/${comp}/Analyse/SE
+    IGCM_sys_TestDirArchive ${ThisSEDir}
+    if [ $? = 0 ] ; then
+      IGCM_debug_Print 2 "SE."
+      NEW_SEDir=${NEW_R_SAVE}/${comp}/Analyse/SE
+      IGCM_sys_MkdirArchive ${NEW_SEDir}
+
+      MY_DODS_Rm ${comp}/Analyse/SE
+
+      unset listfiles
+      set +A listfiles -- $( find ${ThisSEDir} -type f )
+
+      MOVE_and_RENAME_files "listfiles"
+
+      MY_DODS_Cp ${comp}/Analyse/SE
+    fi
+
+    MY_DODS_Rm ${comp}/Analyse
+    MY_DODS_Rm ${comp}
+  else
+    IGCM_debug_Print 2 "nothing to do without Analyse."
+  fi
+
+done
+
+#====================================================
+#GRAPHS
+IGCM_debug_Print 1 "Move ATLAS"
+R_ATLAS=ATLAS
+IGCM_sys_TestDirArchive ${R_SAVE}/${R_ATLAS}
+if [ $? = 0 ] ; then
+  # REPLACE_sed ${NEW_R_SAVE}/${R_ATLAS}/*/*/index.html ${NEW_R_SAVE}/${R_ATLAS}
+
+  MY_DODS_Rm ${R_ATLAS}
+
+  IGCM_sys_Mv ${R_SAVE}/${R_ATLAS} ${NEW_R_SAVE}/${R_ATLAS}
+
+  MY_DODS_Cp ${R_ATLAS}
+fi
+
+IGCM_debug_Print 1 "Move MONITORING"
+R_MONITORING=MONITORING
+IGCM_sys_TestDirArchive ${R_SAVE}/${R_MONITORING}
+if [ $? = 0 ] ; then
+  IGCM_sys_MkdirArchive ${NEW_R_SAVE}/${R_MONITORING}
+  REPLACE_sed ${R_SAVE}/${R_MONITORING}/index.html ${NEW_R_SAVE}/${R_MONITORING}
+  sed -e "s/OldPrefix=\ *${config_UserChoices_JobName}/OldPrefix= ${NEW_JobName}/g" \
+  ${R_SAVE}/${R_MONITORING}/run.card > ${RUN_DIR_PATH}/run.card
+  IGCM_sys_Mv -f ${RUN_DIR_PATH}/run.card ${NEW_R_SAVE}/${R_MONITORING}
+  RET=$?
+  if [ ${RET} = 0 ] ; then
+    IGCM_sys_Rm -f ${R_SAVE}/${R_MONITORING}/run.card
+  fi
+  REPLACE_sed ${R_SAVE}/${R_MONITORING}/config.card ${NEW_R_SAVE}/${R_MONITORING}
+  IGCM_sys_Cp -rp ${R_SAVE}/${R_MONITORING} ${NEW_R_SAVE}
+
+  MY_DODS_Rm ${R_MONITORING}
+  IGCM_sys_Rm -rf ${R_SAVE}/${R_MONITORING}
+
+  MY_DODS_Cp ${R_MONITORING}
+fi
+
+
+#====================================================
+#REBUILD
+
+if [ -d ${REBUILD_DIR} ] ; then
+
+  IGCM_debug_Print 1 "Move REBUILD"
+  set +A LISTREBUILDS -- $( find ${REBUILD_DIR} -type d  -not -name "*${config_UserChoices_JobName}" -a -not -name "*TMP" )
+
+  for ThisREBDir in ${LISTREBUILDS[*]} ; do
+    rebdir=$( basename ${ThisREBDir} )
+    IGCM_debug_Print 2 "${rebdir}."
+    if [ X${config_Post_RebuildFromArchive} = Xtrue ] ; then
+      IGCM_sys_MkdirArchive ${NEW_REBUILD_DIR}/${rebdir}
+    else
+      IGCM_sys_MkdirWork ${NEW_REBUILD_DIR}/${rebdir}
+    fi
+    REPLACE_sed ${REBUILD_DIR}/${rebdir}/rebuild.ksh ${NEW_REBUILD_DIR}/${rebdir}
+    IGCM_sys_Mv -f ${REBUILD_DIR}/${rebdir}/* ${NEW_REBUILD_DIR}/${rebdir}/
+  done
+fi
+
+#====================================================
+#List OLD R_SAVE and Ask for erase it !
+
+IGCM_debug_Print 1 "ls of SAVE DIR :"
+ls --color -lR ${R_SAVE}
+
+echo "\033[1;31mPlease verify that ALL OLD DIRECTORY LISTED IS COMPLETLY EMPTY !"
+echo "\033[1;32mIf It is NOT EMPTY, you can TRY AGAIN this script."
+echo "\033[1;31mDo you REALLY want to erase all this directory ?"
+echo -n " Your answer (y/n) : \033[m"
+if [ X${reponse} = X ] ; then
+  read reponse
+fi
+case ${reponse} in
+
+  oui|OUI|o|y|yes|YES)
+    echo "OK. It will be erased."
+    IGCM_sys_Rm -Rf ${R_SAVE}
+    echo "done."
+    ;;
+  non|NON|n|no|NO)
+    echo "Nothing to do !"
+    ;;
+esac
+
+
+#############################################################################################################
+# Edit config.card, run.card and Job_${NewJobName}
+
+IGCM_debug_Print 1 "edit config.card"
+if [ X${config_UserChoices_SpaceName} != X ] ; then
+  IGCM_card_WriteOption ${SUBMIT_DIR}/config.card UserChoices SpaceName ${NEW_SpaceName}
+fi
+if [ X${config_UserChoices_ExperimentName} != X ] ; then
+  IGCM_card_WriteOption ${SUBMIT_DIR}/config.card UserChoices ExperimentName ${NEW_ExperimentName}
+fi
+IGCM_card_WriteOption ${SUBMIT_DIR}/config.card UserChoices JobName ${NEW_JobName}
+
+if [ -f ${SUBMIT_DIR}/run.card ] ; then
+  IGCM_debug_Print 1 "edit run.card"
+  sed -e "s/OldPrefix=\ *${config_UserChoices_JobName}/OldPrefix= ${NEW_JobName}/g" \
+  ${SUBMIT_DIR}/run.card > ${RUN_DIR_PATH}/run.card
+  IGCM_sys_Mv -f ${RUN_DIR_PATH}/run.card ${SUBMIT_DIR}/run.card
+
+  if [ X${old_run_Configuration_PeriodState} != X ] ; then
+    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState ${old_run_Configuration_PeriodState}
+  fi
+fi
+
+if [ -f ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} ] ; then
+  IGCM_debug_Print 1 "edit Job_${NEW_JobName}"
+  sed -e "s&${R_SAVE}&${NEW_R_SAVE}&g" -e "s/${config_UserChoices_JobName}/${NEW_JobName}/g" \
+  ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} > ${SUBMIT_DIR}/Job_${NEW_JobName}
+  chmod --reference=${SUBMIT_DIR}/Job_${config_UserChoices_JobName} ${SUBMIT_DIR}/Job_${NEW_JobName}
+  ls -la ${SUBMIT_DIR}/Job_${NEW_JobName}
+fi
Index: /tags/libIGCM_v2.2/AA_pack_debug
===================================================================
--- /tags/libIGCM_v2.2/AA_pack_debug	(revision 998)
+++ /tags/libIGCM_v2.2/AA_pack_debug	(revision 998)
@@ -0,0 +1,274 @@
+#-Q- curie ######################
+#-Q- curie ## CURIE   TGCC/CEA ##
+#-Q- curie ######################
+#-Q- curie #MSUB -r PACKDEBUG      # Nom du job
+#-Q- curie #MSUB -eo
+#-Q- curie #MSUB -n 1              # Reservation du processus
+#-Q- curie #MSUB -T 3600          # Limite de temps elapsed du job
+#-Q- curie #MSUB -q xlarge
+#-Q- curie #MSUB -Q normal
+#-Q- curie #MSUB -A ::default_project::
+#-Q- curie set +x
+#-Q- ada #!/bin/ksh
+#-Q- ada #######################
+#-Q- ada ## ADA         IDRIS ##
+#-Q- ada #######################
+#-Q- ada # @ job_type = serial
+#-Q- ada # @ requirements = (Feature == "prepost")
+#-Q- ada # Temps Elapsed max. d'une requete hh:mm:ss
+#-Q- ada # @ wall_clock_limit = 10:00:00
+#-Q- ada # Nom du travail LoadLeveler
+#-Q- ada # @ job_name   = PACKDEBUG
+#-Q- ada # Fichier de sortie standard du travail
+#-Q- ada # @ output     = $(job_name).$(jobid)
+#-Q- ada # Fichier de sortie d'erreur du travail
+#-Q- ada # @ error      =  $(job_name).$(jobid)
+#-Q- ada # pour recevoir un mail en cas de depassement du temps Elapsed (ou autre pb.)
+#-Q- ada # @ notification = error
+#-Q- ada # @ environment  = $DEBUG_debug ; $MODIPSL ; $libIGCM ; $libIGCM_SX ; $SUBMIT_DIR ; $DateBegin ; $DateEnd ; $PeriodPack ; $StandAlone ; $MASTER
+#-Q- ada # @ queue
+#-Q- lxiv8 ######################
+#-Q- lxiv8 ## OBELIX      LSCE ##
+#-Q- lxiv8 ######################
+#-Q- lxiv8 #PBS -N PACKDEBUG
+#-Q- lxiv8 #PBS -m a
+#-Q- lxiv8 #PBS -j oe
+#-Q- lxiv8 #PBS -q medium
+#-Q- lxiv8 #PBS -o PACKDEBUG.$$
+#-Q- lxiv8 #PBS -S /bin/ksh
+#-Q- default #!/bin/ksh
+#-Q- default ##################
+#-Q- default ## DEFAULT HOST ##
+#-Q- default ##################
+
+#**************************************************************
+# Author: Sebastien Denvil
+# Contact: Sebastien.Denvil__at__ipsl.jussieu.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#set -eu
+#set -vx
+
+date
+
+#D- Task type (computing or post-processing)
+TaskType=post-processing
+
+########################################################################
+
+#D- Flag to determine if this job in a standalone mode
+#D- Default : value from AA_job if any
+StandAlone=${StandAlone:=true}
+
+#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:=ada|curie}
+
+#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
+DEBUG_debug=${DEBUG_debug:=false}
+
+#D- Keep following comments for now. Will be remove.
+
+#on veut archiver les fichiers restart
+#Dans le cadre du demenagement ils seront renommes
+#ATM/Restart/****.nc
+#OCE/Restart/****.nc
+#...
+#sous la forme
+#RESTART/ATM_****.nc
+#RESTART/OCE_****.nc
+#Attention de bien conserver les dates d'origines
+#
+#Dans le cadre de la production nouvelle chaine
+#ils auront directement le bon nom
+#
+#On veut egalement que l'archive soit par periode de temps
+# cette periode est definie par la taille du pack donc connue
+# en entree du script (1M, 1Y, 5Y, 10Y etc...)
+#
+# $1= PATH/config_card d'une simulation avec
+# TagName/JobName/ExperimentName/SpaceName/DateBegin/DateEnd
+# $2=PeriodPack en M/m ou Y/y
+
+########################################################################
+
+. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
+. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
+. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
+#-------
+. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
+. ${libIGCM}/libIGCM_config/libIGCM_config.ksh
+. ${libIGCM}/libIGCM_post/libIGCM_post.ksh
+#-------
+( ${DEBUG_debug} ) && IGCM_debug_Check
+( ${DEBUG_debug} ) && IGCM_card_Check
+( ${DEBUG_debug} ) && IGCM_date_Check
+
+########################################################################
+
+#set -vx
+
+RUN_DIR=${RUN_DIR_PATH}
+IGCM_sys_MkdirWork ${RUN_DIR}
+IGCM_sys_Cd ${RUN_DIR}
+
+# ------------------------------------------------------------------
+# Test if all was right before proceeding further
+# ------------------------------------------------------------------
+IGCM_debug_Verif_Exit_Post
+
+if [ ${StandAlone} = true ] ; then
+    CARD_DIR=${SUBMIT_DIR}
+else
+    CARD_DIR=${RUN_DIR_PATH}
+    IGCM_sys_Get_Master ${SUBMIT_DIR}/config.card ${RUN_DIR_PATH}
+    IGCM_sys_Get_Master ${SUBMIT_DIR}/run.card    ${RUN_DIR_PATH}
+    IGCM_sys_Get_Master ${SUBMIT_DIR}/COMP        ${RUN_DIR_PATH}
+    IGCM_sys_Get_Master ${SUBMIT_DIR}/POST        ${RUN_DIR_PATH}
+fi
+
+#==================================
+# First of all
+#
+# Read libIGCM compatibility version in config.card
+# Read UserChoices section
+# Read Ensemble section
+# Read Post section
+# Define all netcdf output directories
+#==================================
+IGCM_config_CommonConfiguration ${CARD_DIR}/config.card
+
+IGCM_sys_TestDirArchive ${R_SAVE}
+[ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive"
+
+#STORE_DEBUG=/ccc/store/cont003/dsm/p86denv/.../DEBUG
+STORE_DEBUG=${R_SAVE}/DEBUG
+IGCM_sys_MkdirArchive ${STORE_DEBUG}
+
+#cd ${STORE_DEBUG}
+#rm -f *
+
+# Switch to script variables meaning (try to be compatible with ipsl_pack TGCC moving procedure)
+JobName=${config_UserChoices_JobName}
+echo $JobName $DateBegin $DateEnd
+
+# Clear txt file lists
+rm -f ${RUN_DIR}/liste_debug_files.txt
+rm -f ${RUN_DIR}/liste_out_files.txt
+rm -f ${RUN_DIR}/new_liste_debug_files.txt
+rm -f ${RUN_DIR}/liste_pack_*.txt
+
+# Create sorted debug list to work with
+find ${R_BUFR}/*/Debug -type f | sort >> ${RUN_DIR}/liste_debug_files.txt
+
+# Rename debug files we will work with using symlinks. use ???_ prefix ie NF-2
+#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
+
+# Add out_ : output of execution files
+find ${R_BUFR}/Out -type f -name '*out_*' | sort >> ${RUN_DIR}/liste_out_files.txt
+
+# Rename out files we will work with using symlinks. use Out_ prefix ie NF-1
+gawk -F/ '{dest_name=$(NF-1)("_") $(NF); system("ln -s " $0 " "dest_name)}' ${RUN_DIR}/liste_out_files.txt
+
+# List renamed debug files. Exclude Job_xxx files.
+find ${RUN_DIR} -maxdepth 1 -mindepth 1 -name "???_*${JobName}*" -ls | sort -k 11 > ${RUN_DIR}/new_liste_debug_files.txt
+
+# ------------------------------------------------------------------
+# Test if all was right before proceeding further
+# ------------------------------------------------------------------
+IGCM_debug_Verif_Exit_Post
+
+# Init loop
+date_begin_pack=${DateBegin}
+date_end_simulation=${DateEnd}
+number_pack=1
+
+IGCM_debug_PrintVariables 3 date_begin_pack
+IGCM_debug_PrintVariables 3 date_end_simulation
+
+while [ ${date_begin_pack} -le ${date_end_simulation} ] ; do
+
+  IGCM_debug_PrintVariables 3 number_pack
+
+  DaysTemp=$( IGCM_date_DaysInCurrentPeriod ${date_begin_pack} ${PeriodPack} )
+  date_end_pack=$( IGCM_date_AddDaysToGregorianDate ${date_begin_pack} $(( ${DaysTemp} - 1 )) )
+
+  for file in $( gawk '{print $11}' ${RUN_DIR}/new_liste_debug_files.txt ); do
+    extract_date_file=$( echo ${file}  | sed -e "s/.*${JobName}_[0-9]*_//" )
+    date_file=$( echo ${extract_date_file} | sed 's/\([0-9]\{8\}\)_.*$/\1/g' )
+#   echo pack nÂ°${number_pack}  ${date_file} ${date_begin_pack} ${date_end_pack}
+    if [ ${date_file} -le ${date_end_pack} ] && [ ${date_file} -ge ${date_begin_pack} ] ; then
+        echo $( basename ${file} ) >> ${RUN_DIR}/liste_pack_${date_begin_pack}_${date_end_pack}.txt
+        echo $( readlink ${file} ) >> ${RUN_DIR}/liste_remove_pack_${date_begin_pack}_${date_end_pack}.txt
+#    Will not work. Need to find a better ordering.
+#    elif [ ${date_file} -ge ${date_end_pack} ] ; then
+#      break
+    fi
+  done
+
+  # Create tar files
+  IGCM_debug_Print 1 "Tar ongoing"
+  tar -cvf ${JobName}_${date_begin_pack}_${date_end_pack}_debug.tar --dereference --files-from ${RUN_DIR}/liste_pack_${date_begin_pack}_${date_end_pack}.txt
+  # Save it
+  IGCM_sys_Put_Out ${JobName}_${date_begin_pack}_${date_end_pack}_debug.tar ${STORE_DEBUG}
+  # Clean it
+  IGCM_sys_Rm ${JobName}_${date_begin_pack}_${date_end_pack}_debug.tar
+  # ------------------------------------------------------------------
+  # Test if all was right before proceeding cleaning
+  # ------------------------------------------------------------------
+  IGCM_debug_Verif_Exit_Post
+  # Clean links
+  cat ${RUN_DIR}/liste_pack_${date_begin_pack}_${date_end_pack}.txt | xargs rm
+  # Clean files links pointed to
+  cat ${RUN_DIR}/liste_remove_pack_${date_begin_pack}_${date_end_pack}.txt | xargs rm
+  # Save the list of files that has been pack (tar)
+  #mv ${RUN_DIR}/liste_pack_${date_begin_pack}_${date_end_pack}.txt ${STORE_DEBUG}
+  IGCM_debug_Print 1 "Tar and cleaning done"
+
+  (( number_pack = number_pack + 1 ))
+
+  # Add 1 day to date_end_pack to have the new date_begin_pack
+  date_begin_pack=$( IGCM_date_AddDaysToGregorianDate ${date_end_pack} 1 )
+
+done
+
+# Clean RUN_DIR_PATH (necessary for cesium and titane only)
+IGCM_sys_RmRunDir -Rf ${RUN_DIR_PATH}
+
+date
Index: /tags/libIGCM_v2.2/AA_pack_output
===================================================================
--- /tags/libIGCM_v2.2/AA_pack_output	(revision 998)
+++ /tags/libIGCM_v2.2/AA_pack_output	(revision 998)
@@ -0,0 +1,282 @@
+#-Q- curie ######################
+#-Q- curie ## CURIE   TGCC/CEA ##
+#-Q- curie ######################
+#-Q- curie #MSUB -r PACKOUTPUT     # Nom du job
+#-Q- curie #MSUB -eo
+#-Q- curie #MSUB -n 1              # Reservation du processus
+#-Q- curie #MSUB -T 36000          # Limite de temps elapsed du job
+#-Q- curie #MSUB -q xlarge
+#-Q- curie #MSUB -Q normal
+#-Q- curie #MSUB -A ::default_project::
+#-Q- curie set +x
+#-Q- ada #!/bin/ksh
+#-Q- ada #######################
+#-Q- ada ## ADA         IDRIS ##
+#-Q- ada #######################
+#-Q- ada # @ job_type = serial
+#-Q- ada # @ requirements = (Feature == "prepost")
+#-Q- ada # Temps Elapsed max. d'une requete hh:mm:ss
+#-Q- ada # @ wall_clock_limit = 10:00:00
+#-Q- ada # Nom du travail LoadLeveler
+#-Q- ada # @ job_name   = PACKOUTPUT
+#-Q- ada # Fichier de sortie standard du travail
+#-Q- ada # @ output     = $(job_name).$(jobid)
+#-Q- ada # Fichier de sortie d'erreur du travail
+#-Q- ada # @ error      =  $(job_name).$(jobid)
+#-Q- ada # pour recevoir un mail en cas de depassement du temps Elapsed (ou autre pb.)
+#-Q- ada # @ notification = error
+#-Q- ada # @ environment  = $DEBUG_debug ; $MODIPSL ; $libIGCM ; $libIGCM_SX ; $SUBMIT_DIR ; $DateBegin ; $DateEnd ; $PeriodPack ; $StandAlone ; $MASTER
+#-Q- ada # @ queue
+#-Q- lxiv8 ######################
+#-Q- lxiv8 ## OBELIX      LSCE ##
+#-Q- lxiv8 ######################
+#-Q- lxiv8 #PBS -N PACKOUTPUT
+#-Q- lxiv8 #PBS -m a
+#-Q- lxiv8 #PBS -j oe
+#-Q- lxiv8 #PBS -q medium
+#-Q- lxiv8 #PBS -o PACKOUTPUT.$$
+#-Q- lxiv8 #PBS -S /bin/ksh
+#-Q- default #!/bin/ksh
+#-Q- default ##################
+#-Q- default ## DEFAULT HOST ##
+#-Q- default ##################
+
+#**************************************************************
+# Author: Sebastien Denvil
+# Contact: Sebastien.Denvil__at__ipsl.jussieu.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#set -eu
+#set -vx
+
+date
+
+#D- Task type (computing or post-processing)
+TaskType=post-processing
+
+########################################################################
+
+#D- Flag to determine if this job in a standalone mode
+#D- Default : value from AA_job if any
+StandAlone=${StandAlone:=true}
+
+#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:=ada|curie}
+
+#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
+DEBUG_debug=${DEBUG_debug:=false}
+
+########################################################################
+
+. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
+. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
+. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
+#-------
+. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
+. ${libIGCM}/libIGCM_config/libIGCM_config.ksh
+. ${libIGCM}/libIGCM_post/libIGCM_post.ksh
+#-------
+( ${DEBUG_debug} ) && IGCM_debug_Check
+( ${DEBUG_debug} ) && IGCM_card_Check
+( ${DEBUG_debug} ) && IGCM_date_Check
+
+########################################################################
+
+#set -vx
+
+RUN_DIR=${RUN_DIR_PATH}
+IGCM_sys_MkdirWork ${RUN_DIR}
+IGCM_sys_Cd ${RUN_DIR}
+
+# ------------------------------------------------------------------
+# Test if all was right before proceeding further
+# ------------------------------------------------------------------
+IGCM_debug_Verif_Exit_Post
+
+if [ ${StandAlone} = true ] ; then
+    CARD_DIR=${SUBMIT_DIR}
+else
+    CARD_DIR=${RUN_DIR_PATH}
+    IGCM_sys_Get_Master ${SUBMIT_DIR}/config.card ${RUN_DIR_PATH}
+    IGCM_sys_Get_Master ${SUBMIT_DIR}/run.card    ${RUN_DIR_PATH}
+    IGCM_sys_Get_Master ${SUBMIT_DIR}/COMP        ${RUN_DIR_PATH}
+    IGCM_sys_Get_Master ${SUBMIT_DIR}/POST        ${RUN_DIR_PATH}
+fi
+
+#==================================
+# First of all
+#
+# Read libIGCM compatibility version in config.card
+# Read UserChoices section
+# Read Ensemble section
+# Read Post section
+# Define all netcdf output directories
+#==================================
+IGCM_config_CommonConfiguration ${CARD_DIR}/config.card
+
+#==================================
+# Read ListOfComponents section
+# to drive the loop over find
+IGCM_card_DefineArrayFromSection ${CARD_DIR}/config.card ListOfComponents
+#
+IGCM_sys_TestDirArchive ${R_SAVE}
+[ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive"
+
+# Where to store used file list /!\ TEMPORARY /!\
+STORE_DEBUG=${R_SAVE}/DEBUG
+
+# Switch to script variables meaning (try to be compatible with ipsl_pack TGCC moving procedure)
+JobName=${config_UserChoices_JobName}
+echo $JobName $DateBegin $DateEnd
+
+# ------------------------------------------------------------------
+# Test if all was right before proceeding further
+# ------------------------------------------------------------------
+IGCM_debug_Verif_Exit_Post
+
+IGCM_debug_Print 1 "Check coherence between PackFrequency and PeriodLength"
+IGCM_post_CheckModuloFrequency PeriodPack config_UserChoices_PeriodLength NbPeriodPerFrequency
+# ------------------------------------------------------------------
+# Test if all was right before proceeding further
+# ------------------------------------------------------------------
+IGCM_debug_Verif_Exit_Post
+
+IGCM_debug_Print 1 "We must process ${NbPeriodPerFrequency} files for each pack"
+
+# Init loop
+date_begin_pack=${DateBegin}
+date_end_simulation=${DateEnd}
+number_pack=1
+
+IGCM_debug_PrintVariables 3 date_begin_pack
+IGCM_debug_PrintVariables 3 date_end_simulation
+
+while [ ${date_begin_pack} -le ${date_end_simulation} ] ; do
+
+  IGCM_debug_PrintVariables 3 number_pack
+  DaysTemp=$( IGCM_date_DaysInCurrentPeriod ${date_begin_pack} ${PeriodPack} )
+  date_end_pack=$( IGCM_date_AddDaysToGregorianDate ${date_begin_pack} $(( ${DaysTemp} - 1 )) )
+
+  for comp in ${config_ListOfComponents[*]} ; do
+    dirList=$( find ${R_BUFR}/${comp}/Output -maxdepth 1 -mindepth 1 -type d )
+    for dir in ${dirList} ; do
+      # dirID is like ATM.Output.MO
+      dirID=$( echo $dir | sed "s:${R_BUFR}/::" | sed "s:/:.:g" )
+      # Sort what's in the directory
+      find ${dir} -type f -name "${JobName}*.nc" -ls | sort -k 11 > liste_files.${dirID}.txt
+      # How much file type. Example : 1M_histmthCOSP.nc, 1M_histmth.nc, 1M_histmthNMC.nc, 1M_paramLMDZ_phy.nc
+      # /!\ fileType include the .nc extension /!\
+      fileType=$( gawk '{print $11}' liste_files.${dirID}.txt | gawk -F$dir/ '{print $2}' | sed "s:${JobName}_[0-9]\{8,9\}_[0-9]\{8,9\}_::g" | sort | uniq )
+      # Loop over the file type and pack them when in between date_begin_pack and date_end_pack
+      for myType in ${fileType} ; do
+        grep ${myType} liste_files.${dirID}.txt > liste_files.${dirID}.${myType}.txt
+        nbfile=0
+        for file in $( gawk '{print $11}' liste_files.${dirID}.${myType}.txt ); do
+          extract_date_file=$( echo ${file}  | sed -e "s/.*${JobName}_[0-9]*_//" )
+          date_file=$( echo ${extract_date_file} | sed 's/\([0-9]\{8\}\)_.*$/\1/g' )
+          # echo pack nÂ°${number_pack}  ${date_file} ${date_begin_pack} ${date_end_pack}
+          if [ ${date_file} -le ${date_end_pack} ] && [ ${date_file} -ge ${date_begin_pack} ] ; then
+            echo ${file} >> liste_pack_${myType}_${date_begin_pack}_${date_end_pack}.txt
+            ncdump -h ${file} | grep -E 'float|double' | cut -f 1 -d '(' | cut -f 2 -d ' ' >> liste_variables_${myType}_${date_begin_pack}_${date_end_pack}.txt
+            (( nbfile = nbfile + 1 ))
+          fi
+        done
+
+        if [ ${nbfile} = 0 ] ; then
+          IGCM_debug_Print 1 "We found no file to process"
+          IGCM_debug_Print 1 "We should have found ${NbPeriodPerFrequency} files"
+          IGCM_debug_Print 1 "As some files can be produced only for some selected period we consider we can move to the next file type"
+          continue
+        fi
+
+        # Select list of variables to work with
+        list_var=$( cat liste_variables_${myType}_${date_begin_pack}_${date_end_pack}.txt | sort | uniq -c | awk -v nbfile=$nbfile '{if ($1 != nbfile) {print $2}}' | paste -s -d ',' )
+        liste_file_tmp=$( for i in $( cat liste_pack_${myType}_${date_begin_pack}_${date_end_pack}.txt ) ; do basename $i ; done )
+        # Create packed files
+        IGCM_debug_Print 1 "Ncrcat ongoing for ${dir} and ${myType}"
+        if [ ! ${nbfile} = ${NbPeriodPerFrequency} ] ; then
+          IGCM_debug_Print 1 "Number of files to process is not equal to what it should be"
+          IGCM_debug_Print 1 "We found ${nbfile} files and it should have been ${NbPeriodPerFrequency} files"
+          IGCM_debug_Exit "ERROR in number of files to process. STOP HERE INCLUDING THE COMPUTING JOB"
+          IGCM_debug_Verif_Exit
+        fi
+        output=${JobName}_${date_begin_pack}_${date_end_pack}_${myType}
+        #cat liste_pack_${myType}_${date_begin_pack}_${date_end_pack}.txt | xargs ncrcat -v ${list_var} -o ${output}
+        if [ X${list_var} = X ] ; then
+          IGCM_sys_ncrcat -p ${dir} ${liste_file_tmp} --output ${output}
+        else
+          IGCM_sys_ncrcat -x -v ${list_var} -p ${dir} ${liste_file_tmp} --output ${output}
+        fi
+        # ------------------------------------------------------------------
+        # Test if all was right before proceeding further
+        # ------------------------------------------------------------------
+        IGCM_debug_Verif_Exit_Post
+        # Save it
+        IGCM_sys_Put_Out ${output} ${R_SAVE}/$( echo $dir | sed "s:${R_BUFR}/::" )/${output}
+        # Clean file produced by ncrcat
+        IGCM_sys_Rm ${output}
+        # ------------------------------------------------------------------
+        # Test if all was right before proceeding further
+        # ------------------------------------------------------------------
+        IGCM_debug_Verif_Exit_Post
+        # Clean files used by ncrcat
+        cat liste_pack_${myType}_${date_begin_pack}_${date_end_pack}.txt | xargs rm
+        # Save the list of files that has been pack (ncrcat)
+        #mv liste_pack_${myType}_${date_begin_pack}_${date_end_pack}.txt ${STORE_DEBUG}
+        IGCM_debug_Print 1 "Ncrcat and cleaning done for ${dir} and ${myType}"
+        echo
+      done
+    done
+  done
+  (( number_pack = number_pack + 1 ))
+  # Add 1 day to date_end_pack to have the new date_begin_pack
+  date_begin_pack=$( IGCM_date_AddDaysToGregorianDate ${date_end_pack} 1 )
+done
+
+# Flush post-processing submission
+if [ -f ${R_BUFR}/FlushPost_${DateEnd}.ksh ] ; then
+  . ${R_BUFR}/FlushPost_${DateEnd}.ksh
+  IGCM_FlushPost
+  #IGCM_sys_Rm -f ${R_BUFR}/FlushPost_${DateEnd}.ksh
+fi
+
+# Clean RUN_DIR_PATH (necessary for cesium and titane only)
+IGCM_sys_RmRunDir -Rf ${RUN_DIR_PATH}
+
+date
Index: /tags/libIGCM_v2.2/AA_pack_restart
===================================================================
--- /tags/libIGCM_v2.2/AA_pack_restart	(revision 998)
+++ /tags/libIGCM_v2.2/AA_pack_restart	(revision 998)
@@ -0,0 +1,271 @@
+#-Q- curie ######################
+#-Q- curie ## CURIE   TGCC/CEA ##
+#-Q- curie ######################
+#-Q- curie #MSUB -r PACKRESTART    # Nom du job
+#-Q- curie #MSUB -eo
+#-Q- curie #MSUB -n 1              # Reservation du processus
+#-Q- curie #MSUB -T 7200          # Limite de temps elapsed du job
+#-Q- curie #MSUB -q xlarge
+#-Q- curie #MSUB -Q normal
+#-Q- curie #MSUB -A ::default_project::
+#-Q- curie set +x
+#-Q- ada #!/bin/ksh
+#-Q- ada #######################
+#-Q- ada ## ADA         IDRIS ##
+#-Q- ada #######################
+#-Q- ada # @ job_type = serial
+#-Q- ada # @ requirements = (Feature == "prepost")
+#-Q- ada # Temps Elapsed max. d'une requete hh:mm:ss
+#-Q- ada # @ wall_clock_limit = 10:00:00
+#-Q- ada # Nom du travail LoadLeveler
+#-Q- ada # @ job_name   = PACKRESTART
+#-Q- ada # Fichier de sortie standard du travail
+#-Q- ada # @ output     = $(job_name).$(jobid)
+#-Q- ada # Fichier de sortie d'erreur du travail
+#-Q- ada # @ error      =  $(job_name).$(jobid)
+#-Q- ada # pour recevoir un mail en cas de depassement du temps Elapsed (ou autre pb.)
+#-Q- ada # @ notification = error
+#-Q- ada # @ environment  = $DEBUG_debug ; $MODIPSL ; $libIGCM ; $libIGCM_SX ; $SUBMIT_DIR ; $DateBegin ; $DateEnd ; $PeriodPack ; $StandAlone ; $MASTER
+#-Q- ada # @ queue
+#-Q- lxiv8 ######################
+#-Q- lxiv8 ## OBELIX      LSCE ##
+#-Q- lxiv8 ######################
+#-Q- lxiv8 #PBS -N PACKRESTART
+#-Q- lxiv8 #PBS -m a
+#-Q- lxiv8 #PBS -j oe
+#-Q- lxiv8 #PBS -q medium
+#-Q- lxiv8 #PBS -o PACKRESTART.$$
+#-Q- lxiv8 #PBS -S /bin/ksh
+#-Q- default #!/bin/ksh
+#-Q- default ##################
+#-Q- default ## DEFAULT HOST ##
+#-Q- default ##################
+
+#**************************************************************
+# Author: Sebastien Denvil
+# Contact: Sebastien.Denvil__at__ipsl.jussieu.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#set -eu
+#set -vx
+
+date
+
+#D- Task type (computing or post-processing)
+TaskType=post-processing
+
+########################################################################
+
+#D- Flag to determine if this job in a standalone mode
+#D- Default : value from AA_job if any
+StandAlone=${StandAlone:=true}
+
+#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:=ada|curie}
+
+#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
+DEBUG_debug=${DEBUG_debug:=false}
+
+#D- Keep following comments for now. Will be remove.
+
+#on veut archiver les fichiers restart
+#Dans le cadre du demenagement ils seront renommes
+#ATM/Restart/****.nc
+#OCE/Restart/****.nc
+#...
+#sous la forme
+#RESTART/ATM_****.nc
+#RESTART/OCE_****.nc
+#Attention de bien conserver les dates d'origines
+#
+#Dans le cadre de la production nouvelle chaine
+#ils auront directement le bon nom
+#
+#On veut egalement que l'archive soit par periode de temps
+# cette periode est definie par la taille du pack donc connue
+# en entree du script (1M, 1Y, 5Y, 10Y etc...)
+#
+# $1= PATH/config_card d'une simulation avec
+# TagName/JobName/ExperimentName/SpaceName/DateBegin/DateEnd
+# $2=PeriodPack en M/m ou Y/y
+
+########################################################################
+
+. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
+. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
+. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
+#-------
+. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
+. ${libIGCM}/libIGCM_config/libIGCM_config.ksh
+. ${libIGCM}/libIGCM_post/libIGCM_post.ksh
+#-------
+( ${DEBUG_debug} ) && IGCM_debug_Check
+( ${DEBUG_debug} ) && IGCM_card_Check
+( ${DEBUG_debug} ) && IGCM_date_Check
+
+########################################################################
+
+#set -vx
+
+RUN_DIR=${RUN_DIR_PATH}
+IGCM_sys_MkdirWork ${RUN_DIR}
+IGCM_sys_Cd ${RUN_DIR}
+
+# ------------------------------------------------------------------
+# Test if all was right before proceeding further
+# ------------------------------------------------------------------
+IGCM_debug_Verif_Exit_Post
+
+if [ ${StandAlone} = true ] ; then
+    CARD_DIR=${SUBMIT_DIR}
+else
+    CARD_DIR=${RUN_DIR_PATH}
+    IGCM_sys_Get_Master ${SUBMIT_DIR}/config.card ${RUN_DIR_PATH}
+    IGCM_sys_Get_Master ${SUBMIT_DIR}/run.card    ${RUN_DIR_PATH}
+    IGCM_sys_Get_Master ${SUBMIT_DIR}/COMP        ${RUN_DIR_PATH}
+    IGCM_sys_Get_Master ${SUBMIT_DIR}/POST        ${RUN_DIR_PATH}
+fi
+
+#==================================
+# First of all
+#
+# Read libIGCM compatibility version in config.card
+# Read UserChoices section
+# Read Ensemble section
+# Read Post section
+# Define all netcdf output directories
+#==================================
+IGCM_config_CommonConfiguration ${CARD_DIR}/config.card
+#
+IGCM_sys_TestDirArchive ${R_SAVE}
+[ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive"
+
+#STORE_RESTART=/ccc/store/cont003/dsm/p86denv/.../RESTART
+STORE_RESTART=${R_SAVE}/RESTART
+IGCM_sys_MkdirArchive ${STORE_RESTART}
+
+#cd ${STORE_RESTART}
+#rm -f *
+
+# Switch to script variables meaning (try to be compatible with ipsl_pack TGCC moving procedure)
+JobName=${config_UserChoices_JobName}
+echo $JobName $R_BUFR $DateBegin $DateEnd
+
+# Clear txt file lists
+rm -f ${RUN_DIR}/liste_restart_files.txt
+rm -f ${RUN_DIR}/new_liste_restart_files.txt
+rm -f ${RUN_DIR}/liste_pack_*.txt
+
+# Create sorted restart list to work with
+find ${R_BUFR}/*/Restart -name "*.*" | sort >> ${RUN_DIR}/liste_restart_files.txt
+
+# Rename restart files we will work with using symlinks
+#gawk -F/ '{dest_name=$(NF-2)("_") $(NF); system("cp --preserve " $0 " "dest_name)}' ${RUN_DIR}/liste_restart_files.txt
+gawk -F/ '{dest_name=$(NF-2)("_") $(NF); system("ln -s " $0 " "dest_name)}' ${RUN_DIR}/liste_restart_files.txt
+
+# List renamed restart files
+find ${RUN_DIR} -maxdepth 1 -mindepth 1 -name "???_*${JobName}*" -ls | sort -k 11 > ${RUN_DIR}/new_liste_restart_files.txt
+
+# ------------------------------------------------------------------
+# Test if all was right before proceeding further
+# ------------------------------------------------------------------
+IGCM_debug_Verif_Exit_Post
+
+# Init loop
+date_begin_pack=${DateBegin}
+date_end_simulation=${DateEnd}
+number_pack=1
+
+IGCM_debug_PrintVariables 3 date_begin_pack
+IGCM_debug_PrintVariables 3 date_end_simulation
+
+# last restart of the previous period : to be deleted
+typeset date_end_previous
+date_end_previous=$( IGCM_date_AddDaysToGregorianDate ${date_begin_pack} -1 )
+
+while [ ${date_begin_pack} -le ${date_end_simulation} ] ; do
+
+  IGCM_debug_PrintVariables 3 number_pack
+
+  DaysTemp=$( IGCM_date_DaysInCurrentPeriod ${date_begin_pack} ${PeriodPack} )
+  date_end_pack=$( IGCM_date_AddDaysToGregorianDate ${date_begin_pack} $(( ${DaysTemp} - 1 )) )
+
+  for file in $( gawk '{print $11}' ${RUN_DIR}/new_liste_restart_files.txt ); do
+    extract_date_file=$( echo ${file}  | sed -e "s/.*${JobName}_//" )
+    date_file=$( echo ${extract_date_file} | sed 's/\([0-9]\{8\}\)_.*$/\1/g' )
+    # warning demenagement. delete last restart of the previous pack
+    [  ${date_file} -eq ${date_end_previous} ] && echo $( readlink ${file} ) >> ${RUN_DIR}/liste_remove_pack_${date_begin_pack}_${date_end_pack}.txt
+    # echo pack number ${number_pack}  ${date_file} ${date_begin_pack} ${date_end_pack}
+    if [ ${date_file} -le ${date_end_pack} ] && [ ${date_file} -ge ${date_begin_pack} ] ; then
+      echo $( basename ${file} ) >> ${RUN_DIR}/liste_pack_${date_begin_pack}_${date_end_pack}.txt
+      # warning demenagement. do not delete last restart of this pack
+      [ ${date_file} -eq ${date_end_pack} ] || echo $( readlink ${file} ) >> ${RUN_DIR}/liste_remove_pack_${date_begin_pack}_${date_end_pack}.txt
+    fi
+  done
+
+  # Create tar files
+  IGCM_debug_Print 1 "Tar ongoing"
+  tar -cvf ${JobName}_${date_begin_pack}_${date_end_pack}_restart.tar --dereference --files-from ${RUN_DIR}/liste_pack_${date_begin_pack}_${date_end_pack}.txt
+  # Save it
+  IGCM_sys_Put_Out ${JobName}_${date_begin_pack}_${date_end_pack}_restart.tar ${STORE_RESTART}
+  # Clean it
+  IGCM_sys_Rm ${JobName}_${date_begin_pack}_${date_end_pack}_restart.tar
+  # ------------------------------------------------------------------
+  # Test if all was right before proceeding cleaning
+  # ------------------------------------------------------------------
+  IGCM_debug_Verif_Exit_Post
+  # Clean links
+  cat ${RUN_DIR}/liste_pack_${date_begin_pack}_${date_end_pack}.txt | xargs rm
+  # Clean files links pointed to
+  cat ${RUN_DIR}/liste_remove_pack_${date_begin_pack}_${date_end_pack}.txt | xargs rm
+  # Save the list of files that has been pack (tar)
+  #mv ${RUN_DIR}/liste_pack_${date_begin_pack}_${date_end_pack}.txt ${STORE_RESTART}
+  IGCM_debug_Print 1 "Tar and cleaning done"
+
+  (( number_pack = number_pack + 1 ))
+
+  # Add 1 day to date_end_pack to have the new date_begin_pack
+  date_begin_pack=$( IGCM_date_AddDaysToGregorianDate ${date_end_pack} 1 )
+
+done
+
+# Clean RUN_DIR_PATH (necessary for cesium and titane only)
+IGCM_sys_RmRunDir -Rf ${RUN_DIR_PATH}
+
+date
Index: /tags/libIGCM_v2.2/AA_rebuild_fromWorkdir
===================================================================
--- /tags/libIGCM_v2.2/AA_rebuild_fromWorkdir	(revision 998)
+++ /tags/libIGCM_v2.2/AA_rebuild_fromWorkdir	(revision 998)
@@ -0,0 +1,207 @@
+#-Q- curie ######################
+#-Q- curie ## CURIE   TGCC/CEA ##
+#-Q- curie ######################
+#-Q- curie #MSUB -r REBUILDWRK     # Nom du job
+#-Q- curie #MSUB -eo
+#-Q- curie #MSUB -n 1              # Reservation du processus
+#-Q- curie #MSUB -T 36000          # Limite de temps elapsed du job
+#-Q- curie #MSUB -q xlarge
+#-Q- curie #MSUB -Q normal
+#-Q- curie #MSUB -A ::default_project::
+#-Q- curie set +x
+#-Q- ada #!/bin/ksh
+#-Q- ada #######################
+#-Q- ada ## ADA         IDRIS ##
+#-Q- ada #######################
+#-Q- ada # @ job_type = serial
+#-Q- ada # @ requirements = (Feature == "prepost")
+#-Q- ada # Temps Elapsed max. d'une requete hh:mm:ss
+#-Q- ada # @ wall_clock_limit = 10:00:00
+#-Q- ada # Nom du travail LoadLeveler
+#-Q- ada # @ job_name   = REBUILDWRK
+#-Q- ada # Fichier de sortie standard du travail
+#-Q- ada # @ output     = $(job_name).$(jobid)
+#-Q- ada # Fichier de sortie d'erreur du travail
+#-Q- ada # @ error      =  $(job_name).$(jobid)
+#-Q- ada # pour recevoir un mail en cas de depassement du temps Elapsed (ou autre pb.)
+#-Q- ada # @ notification = error
+#-Q- ada # @ 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_MBG ; $RESOL_SRF ; $RESOL_SBG ; $MASTER
+#-Q- ada # @ queue
+#-Q- lxiv8 ######################
+#-Q- lxiv8 ## OBELIX      LSCE ##
+#-Q- lxiv8 ######################
+#-Q- lxiv8 #PBS -N REBUILDWRK
+#-Q- lxiv8 #PBS -m a
+#-Q- lxiv8 #PBS -j oe
+#-Q- lxiv8 #PBS -q medium
+#-Q- lxiv8 #PBS -o REBUILDWRK.$$
+#-Q- lxiv8 #PBS -S /bin/ksh
+#-Q- default #!/bin/ksh
+#-Q- default ##################
+#-Q- default ## DEFAULT HOST ##
+#-Q- default ##################
+
+#**************************************************************
+# Author: Sebastien Denvil
+# Contact: Sebastien.Denvil__at__ipsl.jussieu.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#set -eu
+#set -vx
+
+date
+
+#-Q- ada export OMP_NUM_THREADS=1
+
+#D- Task type (computing or post-processing)
+TaskType=post-processing
+
+########################################################################
+
+#D- Flag to determine if this job in a standalone mode
+#D- Default : value from AA_job if any
+StandAlone=${StandAlone:=true}
+
+#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:=ada|curie}
+
+#D- Do we rebuild parallel output from archive or from ${BIGDIR}
+#D- Default : value from AA_job if any
+RebuildFromArchive=${RebuildFromArchive:=false}
+
+#D- Directory where files we need to rebuild are store
+#D- Default : value from AA_job if any
+#D- if RebuildFromArchive=true REBUILD_DIR=${DMFDIR}/IGCM_OUT/.../JobName/TMP
+#D- example : /dmnfs09/cont003/p86denv/IGCM_OUT/IPSLCM5/CM5PIRC7/TMP
+#D- if RebuildFromArchive=false REBUILD_DIR=${BIGDIR}/REBUILD/TagName/JobName/
+#D- example : /scratch/cont003/p86denv/REBUILD/IPSLCM5/SCAL-NEW
+REBUILD_DIR=${REBUILD_DIR:=/path/to/your/TMP/REBUILD/FILES}
+
+#D- How many directory to rebuild we have to consider
+#D- Default : value from AA_job if any
+NbRebuildDir=${NbRebuildDir:=1000}
+
+#D- Suffix date we will use to determine which directory to rebuild
+#D- We will rebuild NbRebuildDir before and including PeriodDateBegin
+#D- Default : value from AA_job if any
+LastPeriodForRebuild=${LastPeriodForRebuild:=${PeriodDateBegin:=18901201}}
+
+#D- Flag to determine atlas job's output directory
+#D- Default : value from libIGCM_post.ksh if any
+POST_DIR=${POST_DIR:=${PBS_O_WORKDIR}}
+
+#-D- libIGCM_SX contains libIGCM on Master computer. Required on some center. Always OK.
+libIGCM_SX=${libIGCM_SX:=::modipsl::/libIGCM}
+
+#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- TEMPORARY Flag to determine atmospheric resolution
+#D- Default : value from atmospheric driver if any
+RESOL_ATM=${RESOL_ATM:=ALL}
+
+#D- TEMPORARY Flag to determine ocean resolution
+#D- Default : value from ocean driver if any
+RESOL_OCE=${RESOL_OCE:=ORCA2}
+
+#D- TEMPORARY Flag to determine ice resolution
+#D- Default : value from ice driver if any
+RESOL_ICE=${RESOL_ICE:=ORCA2}
+
+#D- TEMPORARY Flag to determine biogeochemistry resolution
+#D- Default : value from ice driver if any
+RESOL_MBG=${RESOL_MBG:=ORCA2}
+
+#D- Flag to determine surface resolution
+#D- Default : value from surface driver if any
+RESOL_SRF=ALL
+
+#D- Flag to determine surface resolution
+#D- Default : value from surface driver if any
+RESOL_SBG=ALL
+
+########################################################################
+
+. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
+. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
+. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
+#-------
+. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
+. ${libIGCM}/libIGCM_post/libIGCM_post.ksh
+#-------
+( ${DEBUG_debug} ) && IGCM_debug_Check
+( ${DEBUG_debug} ) && IGCM_card_Check
+( ${DEBUG_debug} ) && IGCM_date_Check
+
+########################################################################
+
+#set -vx
+
+RUN_DIR=${RUN_DIR_PATH}
+IGCM_sys_MkdirWork ${RUN_DIR}
+IGCM_sys_Cd ${RUN_DIR}
+
+# ------------------------------------------------------------------
+# Test if all was right before proceeding further
+# ------------------------------------------------------------------
+IGCM_debug_Verif_Exit_Post
+
+#
+if [ ${RebuildFromArchive} = true ] ; then
+  ListAllRebuildDir=$( IGCM_sys_RshArchive ls -d ${REBUILD_DIR}/REBUILD_* | grep -B $(( ${NbRebuildDir} -1 )) ${LastPeriodForRebuild} )
+else
+  ListAllRebuildDir=$( IGCM_sys_RshMaster ls -d ${REBUILD_DIR}/REBUILD_* | grep -B $(( ${NbRebuildDir} -1 )) ${LastPeriodForRebuild} )
+fi
+#
+
+for directory in ${ListAllRebuildDir} ; do
+  #
+  if [ ${RebuildFromArchive} = true ] ; then
+    IGCM_sys_Get_Dir ${directory} ${RUN_DIR}
+  else
+    IGCM_sys_Get_Master ${directory} ${RUN_DIR}
+  fi
+  #
+  IGCM_sys_Cd ${RUN_DIR}/$( basename ${directory} )
+
+  # --------------------------------------------------------------------
+  # Source function include in the REBUILD ksh and rebuild
+  # --------------------------------------------------------------------
+  . ${RUN_DIR}/$( basename ${directory} )/rebuild.ksh
+  IGCM_FlushRebuild
+  #
+  IGCM_sys_Cd ${RUN_DIR}
+  # Clean Up
+  # local clean up
+  IGCM_sys_Rm -rf $( basename ${directory} )
+  # remote clean up
+  if [ ${RebuildFromArchive} = true ] ; then
+    IGCM_sys_RshArchive rm -rf ${directory}
+  else
+    IGCM_sys_RshMaster rm -rf ${directory}
+  fi
+done
+
+# Clean RUN_DIR_PATH (necessary for cesium and titane only)
+IGCM_sys_RmRunDir -Rf ${RUN_DIR_PATH}
+
+date
Index: /tags/libIGCM_v2.2/libIGCM.card
===================================================================
--- /tags/libIGCM_v2.2/libIGCM.card	(revision 998)
+++ /tags/libIGCM_v2.2/libIGCM.card	(revision 998)
@@ -0,0 +1,25 @@
+#**************************************************************
+# Author: Martial Mancip
+# Contact: Martial.Mancip__at__ipsl.jussieu.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#D- You MUST change cards (and first config.card) parameters too be compatible
+#D- with your modifications here.
+[UserChanges]
+PeriodNb=2
+#config_UserChoices_DateEnd=1900-02-03
+#config_UserChoices_PeriodLength= 1D
+#config_Post_TimeSeriesFrequency= 1D
+#config_Post_SeasonalFrequency= 1Y
+#config_SRF_WriteFrequency= 1800s
+
+#D- Increased verbosity (1, 2, 3)
+#Verbosity=1
+#D- Path must exist before change it !
+#RUN_DIR=${RUN_DIR_PATH}/${config_UserChoices_TagName}/${config_UserChoices_JobName}
Index: /tags/libIGCM_v2.2/libIGCM_CeCILL.LIC
===================================================================
--- /tags/libIGCM_v2.2/libIGCM_CeCILL.LIC	(revision 998)
+++ /tags/libIGCM_v2.2/libIGCM_CeCILL.LIC	(revision 998)
@@ -0,0 +1,40 @@
+The following licence information concerns ONLY the libIGCM tools
+==================================================================
+
+Copyright © Centre National de la Recherche Scientifique CNRS  
+            Commissariat à l'Énergie Atomique CEA
+
+libIGCM : Library for Portable Models Computation of IGCM Group.
+
+IGCM Group is the french IPSL Global Climate Model Group.
+
+This library is a set of shell scripts and functions whose purpose is
+the management of the initialization, the launch, the transfer of
+output files, the post-processing and the monitoring of datas produce
+by any numerical program on any plateforme.
+
+This software is governed by the CeCILL  license under French law and
+abiding by the rules of distribution of free software.  You can  use, 
+modify and/ or redistribute the software under the terms of the CeCILL
+license as circulated by CEA, CNRS and INRIA at the following URL
+"http://www.cecill.info". 
+
+As a counterpart to the access to the source code and  rights to copy,
+modify and redistribute granted by the license, users are provided only
+with a limited warranty  and the software's author,  the holder of the
+economic rights,  and the successive licensors  have only  limited
+liability. 
+
+In this respect, the user's attention is drawn to the risks associated
+with loading,  using,  modifying and/or developing or reproducing the
+software by the user in light of its specific status of free software,
+that may mean  that it is complicated to manipulate,  and  that  also
+therefore means  that it is reserved for developers  and  experienced
+professionals having in-depth computer knowledge. Users are therefore
+encouraged to load and test the software's suitability as regards their
+requirements in conditions enabling the security of their systems and/or 
+data to be ensured and,  more generally, to use and operate it in the 
+same conditions as regards security. 
+
+The fact that you are presently reading this means that you have had
+knowledge of the CeCILL license and that you accept its terms.
Index: /tags/libIGCM_v2.2/libIGCM_card/IGCM_card_PrintOption.awk
===================================================================
--- /tags/libIGCM_v2.2/libIGCM_card/IGCM_card_PrintOption.awk	(revision 998)
+++ /tags/libIGCM_v2.2/libIGCM_card/IGCM_card_PrintOption.awk	(revision 998)
@@ -0,0 +1,137 @@
+#**************************************************************
+# Author: Patrick Brockmann
+# Contact: Patrick.Brockmann__at__cea.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#==========================
+function myprint(str) {
+	if (debug) {
+		print str
+	}
+}
+
+#==========================
+BEGIN {
+
+nbarg=ARGC
+if (ARGV[1] == "-d") {
+        debug=1
+        file=ARGV[2]
+        section=ARGV[3]
+        option=ARGV[4]
+        delete ARGV[1] ; delete ARGV[3] ; delete ARGV[4]
+	nbarg--
+} else {
+        debug=0
+        file=ARGV[1]
+        section=ARGV[2]
+        option=ARGV[3]
+        delete ARGV[2] ; delete ARGV[3]
+}
+
+# When exit statement, 'END' rule is always executed, so defined a exit_value to manage this
+exit_value=0
+if (nbarg != 4) {
+	print "Usage: IGCM_card_PrintOption [-d] file section option" 
+	print 
+	print "Args:"
+	print "      file = file at CARD format" 
+	print "      section = section to find" 
+	print "      option = option to find" 
+	print 
+	print "Options:" 
+	print "       -d = debug mode" 
+	print 
+	exit_value=1
+	exit
+}
+
+section_found=0
+option_found=0
+
+}
+
+#==========================
+{
+
+myprint($0) 
+
+# Do not consider commented lines (#...)
+if (! match($0,/^#/)) {
+
+# Find section with delimiters '[' and ']'
+if (match($0, "\\[" section "\\]")) {
+
+	myprint("---->section found")
+	section_found=1
+
+} else if (section_found == 1 && (match($0, "^[ ]*" option "[ ]*="))) {
+
+	myprint("---->option found")
+	option_found=1
+	
+	# Extract string after '='
+	option_value=substr($0, index($0, "=")+1)
+
+	# Remove space after '='
+	gsub(/^[ ]*/, "", option_value)
+
+	# If continuation character '\' get next lines
+	if (match($0,/\\$/)) {
+		tmp=$0
+		tmp=substr(tmp, 1, length(tmp)-1)
+		gsub(/[ \t]*/, "", tmp)
+		option_value=tmp
+		getline tmp
+		while (match(tmp,/\\$/)) {
+			tmp=substr(tmp, 1, length(tmp)-1)
+			gsub(/[ \t]*/, "", tmp)
+			option_value=option_value " " tmp
+			getline tmp 
+			}
+		gsub(/[ \t]*/, "", tmp)
+		option_value=option_value " " tmp
+	}
+
+	exit
+
+} else if (section_found == 1 && match($0, /^[\[*\]]/)) {
+
+	myprint("---->end section")
+	exit
+
+}
+
+}
+
+}
+
+#==========================
+END {
+
+if (! exit_value ) {
+
+myprint("###############################")
+myprint("section      ====> " section)
+myprint("option       ====> " option)
+myprint("value        ====> " option_value)
+
+if (section_found == 0) {
+	print "Error: Section not found"
+} else if (option_found == 0) {
+	print "Error: Option not found"
+} else {
+	print option_value
+}
+
+}
+
+}
+ 
+#==========================
Index: /tags/libIGCM_v2.2/libIGCM_card/IGCM_card_PrintSection.awk
===================================================================
--- /tags/libIGCM_v2.2/libIGCM_card/IGCM_card_PrintSection.awk	(revision 998)
+++ /tags/libIGCM_v2.2/libIGCM_card/IGCM_card_PrintSection.awk	(revision 998)
@@ -0,0 +1,120 @@
+#**************************************************************
+# Author: Patrick Brockmann
+# Contact: Patrick.Brockmann__at__cea.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#==========================
+function myprint(str) {
+	if (debug) {
+		print str
+	}
+}
+
+#==========================
+BEGIN {
+
+nbarg=ARGC
+if (ARGV[1] == "-d") {
+        debug=1
+        file=ARGV[2]
+        section=ARGV[3]
+        delete ARGV[1] ; delete ARGV[3]
+	nbarg--
+} else {
+        debug=0
+        file=ARGV[1]
+        section=ARGV[2]
+        delete ARGV[2]
+}
+
+# When exit statement, 'END' rule is always executed, so defined a exit_value to manage this
+exit_value=0
+if (nbarg != 3) {
+	print "Usage: IGCM_card_PrintSection [-d] file section" 
+	print 
+	print "Args:"
+	print "      file = file at CARD format" 
+	print "      section = section to find" 
+	print 
+	print "Options:" 
+	print "       -d = debug mode" 
+	print 
+	exit_value=1
+	exit
+}
+
+section_found=0
+option_list="null"
+
+}
+
+#==========================
+{
+
+myprint($0) 
+
+# Do not consider commented lines (#...)
+if (! match($0,/^#/)) {
+
+# Find section with delimiters '[' and ']'
+if (match($0, "\\[" section "\\]")) {
+
+	myprint("---->section found")
+	section_found=1
+
+} else if (section_found == 1 && (match($0, "[.]*="))) {
+
+	myprint("---->option found")
+
+	# Extract string after '='
+	option_value=substr($0, 1, index($0, "=")-1)
+
+	# Remove space before '='
+	gsub(/[ ]*/, "", option_value)
+
+	# Add options
+	# If 1st option
+	if (match(option_list,"null")) {
+		option_list=option_value
+	} else {
+		option_list=option_list " " option_value
+	}
+
+} else if (section_found == 1 && match($0, /^[\[*\]]/)) {
+
+	myprint("---->end section")
+	exit
+
+}
+
+}
+
+}
+
+#==========================
+END {
+
+if (! exit_value ) {
+
+myprint("###############################")
+myprint("section      ====> " section)
+
+if (section_found == 0) {
+	print "Error: Section not found"
+} else if (match(option_list,"null")) {
+	print "Error: Option not found"
+} else {
+	print option_list
+}
+
+}
+
+}
+ 
+#==========================
Index: /tags/libIGCM_v2.2/libIGCM_card/IGCM_card_Test.ksh
===================================================================
--- /tags/libIGCM_v2.2/libIGCM_card/IGCM_card_Test.ksh	(revision 998)
+++ /tags/libIGCM_v2.2/libIGCM_card/IGCM_card_Test.ksh	(revision 998)
@@ -0,0 +1,86 @@
+#!/bin/ksh
+
+#**************************************************************
+# Author: Patrick Brockmann
+# Contact: Patrick.Brockmann__at__cea.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+# This script is used to generate a reference file with command :
+# IGCM_card_Test.ksh > IGCM_card_Test.ref 2>&1
+# The reference file produced is used by the function IGCM_card_Check
+# to verify that the libIGCM_card produce the same results
+
+#=================================================
+cd /tmp
+
+libIGCM=`dirname $0`/..
+typeset DEBUG_sys=false
+typeset TaskType=checking
+. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
+. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
+. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
+
+#=================================================
+cat ${libIGCM}/libIGCM_card/TestFile.card
+
+#=================================================
+# function IGCM_card_PrintOption
+
+IGCM_card_PrintOption ${libIGCM}/libIGCM_card/TestFile.card Messages Option1
+IGCM_card_PrintOption ${libIGCM}/libIGCM_card/TestFile.card Messages Option2
+IGCM_card_PrintOption ${libIGCM}/libIGCM_card/TestFile.card ColorValues Red
+IGCM_card_PrintOption ${libIGCM}/libIGCM_card/TestFile.card ColorValues Blue
+IGCM_card_PrintOption ${libIGCM}/libIGCM_card/TestFile.card ColorValues Green
+
+#=================================================
+# function IGCM_card_PrintSection
+
+IGCM_card_PrintSection ${libIGCM}/libIGCM_card/TestFile.card Recipes
+IGCM_card_PrintSection ${libIGCM}/libIGCM_card/TestFile.card Couples
+
+#==================================================
+# function IGCM_card_DefineVariableFromOption
+
+IGCM_card_DefineVariableFromOption ${libIGCM}/libIGCM_card/TestFile.card Messages Option2
+echo ${TestFile_Messages_Option2}
+IGCM_card_DefineVariableFromOption ${libIGCM}/libIGCM_card/TestFile.card ColorValues Red
+echo ${TestFile_ColorValues_Red}
+
+#==================================================
+# function IGCM_card_DefineArrayFromOption
+
+IGCM_card_DefineArrayFromOption ${libIGCM}/libIGCM_card/TestFile.card Couples List1
+echo ${TestFile_Couples_List1[*]}
+IGCM_card_DefineArrayFromOption ${libIGCM}/libIGCM_card/TestFile.card Couples List2
+echo ${TestFile_Couples_List2[*]}
+
+#=================================================
+# function IGCM_card_DefineArrayFromSection
+
+IGCM_card_DefineArrayFromSection ${libIGCM}/libIGCM_card/TestFile.card ColorValues
+echo ${TestFile_ColorValues[*]}
+
+#==================================================
+# function IGCM_card_WriteOption
+
+cp ${libIGCM}/libIGCM_card/TestFile.card /tmp/NewTestFile.$$.card
+IGCM_card_WriteOption /tmp/NewTestFile.$$.card Messages Option2 '"Hello Mercure"'
+
+IGCM_card_WriteOption /tmp/NewTestFile.$$.card Messages ListVal1 '( 1, 2, 3 )'
+listname="(Sebastien, Martial, Patrick)"
+IGCM_card_WriteOption /tmp/NewTestFile.$$.card Messages ListVal2 "${listname}"
+
+set -A tableau one, two, three, four
+echo ${tableau[*]}
+IGCM_card_WriteOption /tmp/NewTestFile.$$.card Messages ListVal3 "( ${tableau[*]} )"
+
+IGCM_card_WriteOption /tmp/NewTestFile.$$.card ColorValues Red 888
+
+diff ${libIGCM}/libIGCM_card/TestFile.card /tmp/NewTestFile.$$.card
+rm -f /tmp/NewTestFile.$$.card /tmp/NewTestFile.$$.card.bak
Index: /tags/libIGCM_v2.2/libIGCM_card/IGCM_card_Test.ref
===================================================================
--- /tags/libIGCM_v2.2/libIGCM_card/IGCM_card_Test.ref	(revision 998)
+++ /tags/libIGCM_v2.2/libIGCM_card/IGCM_card_Test.ref	(revision 998)
@@ -0,0 +1,53 @@
+
+[Messages]
+Option1= "Hello Earth"
+Option2= "Hello Mars"
+ListVal1= ()
+ListVal2= ()
+ListVal3= ()
+
+# My comments
+[Recipes]
+Cake= "file1.doc"
+Starter= "file2.doc"
+
+[ColorValues]
+Red= 120
+Blue= 230
+Green= 178
+AnotherRed= 234
+
+[Couples]
+List1=   (up, down), \
+         (humid, dry), \
+         (hot, cold), \
+         (far, close)
+List2=   (ice, fire, air, water)
+
+"Hello Earth"
+"Hello Mars"
+120
+230
+178
+Cake Starter
+List1 List2
+Hello Mars
+120
+up down humid dry hot cold far close
+ice fire air water
+Red Blue Green AnotherRed
+one, two, three, four
+4,7c4,7
+< Option2= "Hello Mars"
+< ListVal1= ()
+< ListVal2= ()
+< ListVal3= ()
+---
+> Option2= "Hello Mercure"
+> ListVal1= ( 1, 2, 3 )
+> ListVal2= (Sebastien, Martial, Patrick)
+> ListVal3= ( one, two, three, four )
+15c15
+< Red= 120
+---
+> Red= 888
Index: /tags/libIGCM_v2.2/libIGCM_card/IGCM_card_WriteOption.awk
===================================================================
--- /tags/libIGCM_v2.2/libIGCM_card/IGCM_card_WriteOption.awk	(revision 998)
+++ /tags/libIGCM_v2.2/libIGCM_card/IGCM_card_WriteOption.awk	(revision 998)
@@ -0,0 +1,121 @@
+#**************************************************************
+# Author: Patrick Brockmann
+# Contact: Patrick.Brockmann__at__cea.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#==========================
+function myprint(str) {
+	if (debug) {
+		print str
+	}
+}
+
+#==========================
+BEGIN {
+
+nbarg=ARGC
+if (ARGV[1] == "-d") {
+        debug=1
+        file=ARGV[2]
+        section=ARGV[3]
+        option=ARGV[4]
+        value=ARGV[5]
+        delete ARGV[1] ; delete ARGV[3] ; delete ARGV[4] ; delete ARGV[5]
+	nbarg--
+} else {
+        debug=0
+        file=ARGV[1]
+        section=ARGV[2]
+        option=ARGV[3]
+        value=ARGV[4]
+        delete ARGV[2] ; delete ARGV[3] ; delete ARGV[4]
+}
+
+
+# When exit statement, 'END' rule is always executed, so defined a exit_value to manage this
+exit_value=0
+if (nbarg != 5) {
+	print "Usage: IGCM_card_WriteOption [-d] file section option value"
+	print 
+	print "Args:"
+	print "      file = file at CARD format" 
+	print "      section = section to find" 
+	print "      option = option to find" 
+	print "      value = value option to write" 
+	print 
+	print "Options:" 
+	print "       -d = debug mode" 
+	print
+	exit_value=1
+        exit
+}
+
+section_found=0
+section_inside=0
+option_found=0
+}
+
+#==========================
+{
+
+myprint($0) 
+
+# Find section with delimiters '[' and ']'
+if (match($0, "\\[" section "\\]")) {
+
+	myprint("---->section found")
+	section_found=1
+	section_inside=1
+	print $0
+
+} else if (section_inside == 1 && (match($0, "^[ ]*" option "[ ]*="))) {
+
+	myprint("---->option found")
+	option_found=1
+
+	print option "= " value
+	myprint("---->new value ")
+
+} else if (section_inside == 1 && match($0, /^[\[*\]]/)) {
+
+	myprint("---->end section")
+	section_inside=0
+	print $0
+
+} else {
+	print $0
+}
+
+}
+
+#==========================
+END {
+
+    if (! exit_value ) {
+
+	myprint("###############################")
+	myprint("section      ====> " section)
+	myprint("option       ====> " option)
+	myprint("value        ====> " value)
+	
+	if (section_found == 0) {
+	    print "Error: Section not found"
+	} else if (option_found == 0) {
+	    print "Error: Option not found"
+	}	
+	
+    } else {
+
+	print "Error in with IGCM_WriteOption : ", section, option
+
+    }
+
+}
+ 
+#==========================
Index: /tags/libIGCM_v2.2/libIGCM_card/TestFile.card
===================================================================
--- /tags/libIGCM_v2.2/libIGCM_card/TestFile.card	(revision 998)
+++ /tags/libIGCM_v2.2/libIGCM_card/TestFile.card	(revision 998)
@@ -0,0 +1,26 @@
+
+[Messages]
+Option1= "Hello Earth"
+Option2= "Hello Mars"
+ListVal1= ()
+ListVal2= ()
+ListVal3= ()
+
+# My comments
+[Recipes]
+Cake= "file1.doc"
+Starter= "file2.doc"
+
+[ColorValues]
+Red= 120
+Blue= 230
+Green= 178
+AnotherRed= 234
+
+[Couples]
+List1=   (up, down), \
+         (humid, dry), \
+         (hot, cold), \
+         (far, close)
+List2=   (ice, fire, air, water)
+
Index: /tags/libIGCM_v2.2/libIGCM_card/libIGCM_card.ksh
===================================================================
--- /tags/libIGCM_v2.2/libIGCM_card/libIGCM_card.ksh	(revision 998)
+++ /tags/libIGCM_v2.2/libIGCM_card/libIGCM_card.ksh	(revision 998)
@@ -0,0 +1,332 @@
+#!/bin/ksh
+
+#**************************************************************
+# Author: Patrick Brockmann
+# Contact: Patrick.Brockmann__at__cea.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#==================================================
+# The documentation of this file can be automatically generated
+# if you use the prefix #D- for comments to be extracted. 
+# Extract with command: cat lib* | grep "^#D-" | cut -c "4-"
+#==================================================
+ 
+#D-#==================================================================
+#D-libIGCM_card
+#D-This ksh library handles extraction of information from configuration file
+#D-called "card" file (en français fichier "carte").
+#D-All function described bellow must be prefixed by IGCM_card.
+#D-A card file is organized as follows :
+#D- ---------------------
+#D-[Messages]
+#D-Option1= "Hello Earth"
+#D-Option2= "Hello Mars"
+#D-
+#D-# My comments 
+#D-[Recipes]
+#D-Cake= "file1.doc" 
+#D-Starter= "file2.doc" 
+#D-
+#D-[ColorValues]
+#D-Red= 120
+#D-Blue= 230 
+#D-Green= 178 
+#D-
+#D-[Couples]
+#D-List1=   (up, down), \
+#D-         (humid, dry), \
+#D-         (hot, cold), \
+#D-         (far, close)
+#D-List2=   (ice, fire, air, water)
+#D- ---------------------
+#D-
+
+#D-#==================================================================
+#D-function IGCM_card_PrintOption
+#D-* Purpose: Print an option from a given file.card and section
+#D-* Usage: IGCM_card_PrintOption file.card section option
+#D-* Only used by IGCM_card_Test.ksh
+#D-
+function IGCM_card_PrintOption
+{
+    IGCM_debug_PushStack "IGCM_card_PrintOption" $@
+    if ( [ -r "$1" ] && [ -f "$1" ] ) ; then
+      gawk -f ${libIGCM}/libIGCM_card/IGCM_card_PrintOption.awk "$@"
+    else
+      echo
+      IGCM_debug_Print 1 "--Error--> IGCM_card_PrintOption $@"
+      IGCM_debug_Print 1 "           $1 is not readable"
+      IGCM_debug_Exit "IGCM_card_PrintOption"
+    fi
+    IGCM_debug_PopStack "IGCM_card_PrintOption"
+}
+
+#D-#==================================================================
+#D-function IGCM_card_PrintSection
+#D-* Purpose: Print all options from a given file.card and section
+#D-* Usage: IGCM_card_PrintSection file.card section
+#D-* Only used by IGCM_card_Test.ksh
+#D-
+function IGCM_card_PrintSection
+{
+    IGCM_debug_PushStack "IGCM_card_PrintSection" $@
+    if ( [ -r "$1" ] && [ -f "$1" ] ) ; then
+      gawk -f ${libIGCM}/libIGCM_card/IGCM_card_PrintSection.awk -- "$@"
+    else
+      IGCM_debug_Print 1 "--Error--> IGCM_card_PrintSection $@"
+      IGCM_debug_Print 1 "           $1 is not readable"
+      IGCM_debug_Exit "IGCM_card_PrintSection"
+    fi
+    IGCM_debug_PopStack "IGCM_card_PrintSection"
+}
+
+#D-#==================================================================
+#D-function IGCM_card_DefineVariableFromOption
+#D-* Purpose: Define a variable from a given file.card, section and option
+#D-*          Variable name is automatically defined as file_section_option
+#D-* Usage: IGCM_card_DefineVariableFromOption file.card section option
+#D-
+function IGCM_card_DefineVariableFromOption
+{
+    IGCM_debug_PushStack "IGCM_card_DefineVariableFromOption" $@
+    if ( [ -r "$1" ] && [ -f "$1" ] ) ; then
+      # Get basename of card file ($1)
+      typeset name1=${1##*/}
+      # Build name of variable as $1_$2_$3 (cardname_Section_Option)
+      typeset name=${name1%%.*}_${2}_${3}
+      typeset value=$( gawk -f ${libIGCM}/libIGCM_card/IGCM_card_PrintOption.awk -- "$@" )
+
+      # Only if a section is missing we exit the job.
+      # We must allow missing option to keep backward compatibilty.
+      if [ "${value}" = "Error: Section not found" ] ; then
+        echo
+        IGCM_debug_Print 1 "Error with readding of ${name} variable in ${1}."
+        IGCM_debug_Print 1 "Error: Section ${2} not found"
+        IGCM_debug_Exit
+        IGCM_debug_Verif_Exit
+      fi
+      eval ${name}=${value}
+    else
+      echo
+      IGCM_debug_Print 1 "--Error--> IGCM_card_DefineVariableFromOption"
+      IGCM_debug_Print 1 "--Error--> $1 is not readable"
+      IGCM_debug_Exit "IGCM_card_DefineVariableFromOption"
+      IGCM_debug_Verif_Exit
+    fi
+    IGCM_debug_PopStack "IGCM_card_DefineVariableFromOption"
+}
+
+#D-#==================================================================
+#D-function IGCM_card_DefineArrayFromOption
+#D-* Purpose: Define an array variable from a given file.card, section and option
+#D-*          Array variable is automatically defined as file_section_option
+#D-* Usage: IGCM_card_DefineArrayFromOption file.card section option
+#D-
+function IGCM_card_DefineArrayFromOption
+{
+    IGCM_debug_PushStack "IGCM_card_DefineArrayFromOption" $@
+    if ( [ -r "$1" ] && [ -f "$1" ] ) ; then
+      # Get basename of card file ($1)
+      typeset name1=${1##*/}
+      # Build name of array as $1_$2_$3 (cardname_Section_Option)
+      typeset name=${name1%%.*}_${2}_${3}
+      eval unset ${name}
+      eval ${name}[0]=${NULL_STR}
+      set +A ${name} -- $( gawk -f ${libIGCM}/libIGCM_card/IGCM_card_PrintOption.awk -- "$@" | gawk -- 'BEGIN {FS="[() ,]+"} {for (i=2; i <= NF-1; i++) printf("%s ",$i)}' )
+    else
+      echo
+      IGCM_debug_Print 1 "--Error--> IGCM_card_DefineArrayFromOption $@"
+      IGCM_debug_Print 1 "           $1 is not readable"
+      IGCM_debug_Exit "IGCM_card_DefineArrayFromOption"
+    fi
+    IGCM_debug_PopStack "IGCM_card_DefineArrayFromOption"
+}
+
+#D-#==================================================================
+#D-function IGCM_card_DefineArrayFromSection
+#D-* Purpose: Define an array variable from a given file.card and section
+#D-*          Array variable is automatically defined as file_section
+#D-* Usage: IGCM_card_DefineArrayFromSection file.card section
+#D-
+function IGCM_card_DefineArrayFromSection
+{
+    IGCM_debug_PushStack "IGCM_card_DefineArrayFromSection" $@
+    if ( [ -r "$1" ] && [ -f "$1" ] ) ; then
+      # Get basename of card file ($1)
+      typeset name1=${1##*/}
+      # Build name of array as $1_$2 (cardname_Section)
+      typeset name=${name1%%.*}_${2}
+      eval unset ${name}
+      eval ${name}[0]=${NULL_STR}
+      set +A ${name} -- $( gawk -f ${libIGCM}/libIGCM_card/IGCM_card_PrintSection.awk -- "$@" )
+      #if [ "$( eval echo \${${name}[@]} )" = "Error: Section not found" ] ; then
+      #    echo
+      #    IGCM_debug_Print 1 "Error with readding of ${name} variable in ${1}."
+      #    IGCM_debug_Print 1 "Error: Section ${2} not found"
+      #    IGCM_debug_Exit
+      #    IGCM_debug_Verif_Exit
+      #fi
+      if [ "$( eval echo \${${name}[@]} )" = "Error: Section not found" ] ; then
+        echo
+        IGCM_debug_Print 1 "Warning with readding of ${name} variable in ${1}."
+        IGCM_debug_Print 1 "Warning: Section ${2} not found"
+        eval unset ${name}
+      fi
+    else
+      IGCM_debug_Print 1 "--Error--> IGCM_card_DefineArrayFromSection $@"
+      IGCM_debug_Print 1 "           $1 is not readable"
+      IGCM_debug_Exit "IGCM_card_DefineArrayFromSection"
+    fi
+    IGCM_debug_PopStack "IGCM_card_DefineArrayFromSection"
+}
+
+#D-#==================================================================
+#D-function IGCM_card_WriteOption
+#D-* Purpose: Write an option in a given file.card and section
+#D-* Usage: IGCM_card_WriteOption file.card section newvalue
+#D-* Examples: IGCM_card_WriteOption file.card Recipes Red 150
+#D-            IGCM_card_WriteOption file.card Messages Option2 '"Hello Mercure"'
+#D-            IGCM_card_WriteOption file.card Messages ListVal1 '( 1, 2, 3 )'
+#D-            listname="(Sebastien, Martial, Patrick)"
+#D-            IGCM_card_WriteOption NewTestFile.card Messages ListVal2 "${listname}"
+#D-
+function IGCM_card_WriteOption
+{
+    IGCM_debug_PushStack "IGCM_card_WriteOption" $@
+    if ( [ -r "$1" ] && [ -w "$1" ]  && [ -f "$1" ] ) ; then
+      typeset tmpfile=tmpfile_$$
+      ( IGCM_card_PrintOption "$1" "$2" "$3" | grep "not found" ) > ${tmpfile}
+      if [ $( cat ${tmpfile} | wc -l ) -gt 0 ] ; then
+        IGCM_debug_Print 1 "!!! Issue with IGCM_card_WriteOption !!!"
+        IGCM_debug_Print 1 "We tried to write : $@"
+        IGCM_debug_Exit "Must check that option $3 in section $2 exist in this file $1"
+        IGCM_debug_Verif_Exit
+      fi
+      \rm ${tmpfile}
+
+      # The tmpfile uses now the real path of the card to be modified, 
+      # not just a local tmpfile with PID.
+      tmpfile=$1_mutex_$$
+
+      IGCM_card_CheckConflict $1
+
+      # Do the job
+      ( gawk -f ${libIGCM}/libIGCM_card/IGCM_card_WriteOption.awk -- "$@" 2> /dev/null ) > ${tmpfile}
+
+      cp $1 $1.bak
+      mv ${tmpfile} $1
+
+    else
+      echo
+      IGCM_debug_Print 1 "--Error--> IGCM_card_WriteOption $@"
+      IGCM_debug_Print 1 "           $1 is not readable or not writable"
+      IGCM_debug_Exit "IGCM_card_WriteOption"
+    fi
+    IGCM_debug_PopStack "IGCM_card_WriteOption"
+}
+
+function IGCM_card_CheckConflict
+{
+    IGCM_debug_PushStack "IGCM_card_CheckConflict" $@
+
+    typeset isleep tmpfiles
+
+    # Watch for possible conflics : Check for other tmpfiles.
+    set +A tmpfiles -- $( ls $1_mutex_[0-9]* 2>/dev/null )
+    ((isleep=0))
+    while [ ${#tmpfiles[@]} -gt 0 ] ; do 
+      echo "Conflict between two processes working on " $1 "!!!" ${tmpfiles[@]}
+      sleep 1
+      ((isleep=isleep+1))
+      if [ ${isleep} -gt 20 ] ; then
+        echo "Too many loops waiting for other process working on " $1 ". We continue."
+        echo "You should see if one process of your run or post-treatment may have terminated suddenly."
+        echo "Afer, you should erase this(those) file(s) : " ${tmpfiles[@]}
+# Send a mail to USER ??
+        break ;
+      fi
+      unset tmpfiles
+      set +A tmpfiles -- $( ls $1_mutex_[0-9]* 2>/dev/null )
+    done
+
+    IGCM_debug_PopStack "IGCM_card_CheckConflict"
+}
+
+#D-#==================================================================
+#D-function IGCM_card_WriteArrayOption
+#D-* Purpose: Write an array option a given file.card and section
+#D-* Usage: IGCM_card_WriteArrayOption file.card section option newarray
+#D-* Examples: set -A MyArray -- 1 2 3
+#D-            IGCM_card_WriteArrayOption file.card Recipes List MyArray
+#D-
+function IGCM_card_WriteArrayOption
+{
+    IGCM_debug_PushStack "IGCM_card_WriteArrayOption" $@
+
+    if ( [ -r "$1" ] && [ -w "$1" ]  && [ -f "$1" ] ) ; then
+      typeset tmpfile=tmpfile_$$
+      if [ X"${4}" != X"" ]; then
+        tab=$4
+        IGCM_card_WriteOption $1 $2 $3 '('$( eval echo \${${tab}[@]} | sed -e 's/ /,/g' )')'
+      else
+        IGCM_card_WriteOption $1 $2 $3 '()'
+      fi
+    else
+      echo
+      IGCM_debug_Print 1 "--Error--> IGCM_card_WriteArrayOption $@"
+      IGCM_debug_Print 1 "           $1 is not readable or not writable"
+      IGCM_debug_Exit "IGCM_card_WriteArrayOption"
+    fi
+    IGCM_debug_PopStack "IGCM_card_WriteArrayOption"
+}
+
+#D-#==================================================================
+#D-function IGCM_card_Check
+#D-* Purpose: Check the present file by comparison with a reference file
+#D-* Usage: IGCM_card_Check
+#D-
+function IGCM_card_Check
+{
+    IGCM_debug_PushStack "IGCM_card_Check" 
+#---------------------
+    if [ ! -n "${libIGCM}" ] ; then
+      echo "Check libIGCM_card ...........................................[ FAILED ]"
+      echo "--Error--> libIGCM variable is not defined"
+      IGCM_debug_Exit "IGCM_card_Check"
+    fi
+
+#---------------------
+    whence -v gawk > /dev/null 2>&1
+    if [ ! $? -eq 0 ] ; then
+      echo "Check libIGCM_card ...........................................[ FAILED ]"
+      echo "--Error--> gawk command is not defined"
+      IGCM_debug_Exit "IGCM_card_Check"
+    fi
+
+#---------------------
+    ${libIGCM}/libIGCM_card/IGCM_card_Test.ksh > /tmp/IGCM_card_Test.$$.ref.failed 2>&1
+    sleep 2
+
+    if diff /tmp/IGCM_card_Test.$$.ref.failed ${libIGCM}/libIGCM_card/IGCM_card_Test.ref > /dev/null 2>&1 ; then 
+      echo "Check libIGCM_card ...............................................[ OK ]"
+      rm -f /tmp/IGCM_card_Test.$$.ref.failed
+    else 
+      echo "Check libIGCM_card ...........................................[ FAILED ]"
+      echo "--Error--> Execution of ${libIGCM}/libIGCM_card/IGCM_card_Test.ksh"
+      echo "           has produced the file IGCM_card_Test.ref.failed"
+      echo "           Please analyse differences with the reference file by typing:"
+      echo "           diff IGCM_card_Test.ref.failed ${libIGCM}/libIGCM_card/IGCM_card_Test.ref"
+      echo "           Report errors to the author: Patrick.Brockmann@cea.fr"
+      cat /tmp/IGCM_card_Test.$$.ref.failed
+      IGCM_debug_Exit "IGCM_card_Check"
+    fi
+
+#---------------------
+    IGCM_debug_PopStack "IGCM_card_Check" 
+}
Index: /tags/libIGCM_v2.2/libIGCM_check/libIGCM_check.ksh
===================================================================
--- /tags/libIGCM_v2.2/libIGCM_check/libIGCM_check.ksh	(revision 998)
+++ /tags/libIGCM_v2.2/libIGCM_check/libIGCM_check.ksh	(revision 998)
@@ -0,0 +1,484 @@
+#!/bin/ksh
+
+#**************************************************************
+# Author: Sebastien Denvil, Martial Mancip
+# Contact: Sebastien.Denvil__at__ipsl.jussieu.fr Martial.Mancip__at__ipsl.jussieu.fr
+# $Revision:: 939                                      $ Revision of last commit
+# $Author:: sdipsl                                     $ Author of last commit
+# $Date:: 2013-08-23 11:38:24 +0200 (Fri, 23 Aug 2013) $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#===================================
+function IGCM_check_CommonDef
+{
+
+  IGCM_debug_PushStack "IGCM_check_CommonDef" $@
+
+  # Define colors
+  # -------------
+  ColEsc="\033["
+  ColNon="${ColEsc}0m"       # Return to normal
+  ColExp="${ColEsc}1m"       # Blanc - gras
+  ColFat="${ColEsc}1;31m"    # Fatal
+  ColCpl="${ColEsc}1;32m"    # Completed
+  ColAtt="${ColEsc}1;30m"    # Waiting
+  ColDef="${ColEsc}1;34m"    # Default
+  ColRbl="${ColEsc}31m"      # Rebuild
+
+  # Define date format
+  # ------------------
+  DateFormat="%d/%m/%y %R:%S"
+
+
+  # What kind of rebuild ?
+  # ----------------------
+  if [ X${config_Post_RebuildFromArchive} = Xtrue ] ; then
+    RebuildJob="rebuild_fromArchive"
+    IGCM_sys_TestDirArchive ${REBUILD_DIR}
+    RebuildExists=$?
+  else
+    RebuildJob="rebuild_fromWorkdir"
+    IGCM_sys_TestDir ${REBUILD_DIR}
+    RebuildExists=$?
+  fi
+
+  # Are packs activated or not ?
+  # ----------------------------
+  if ( [ ! X${config_Post_PackFrequency} = X${NULL_STR} ] && \
+       [ ! X${config_Post_PackFrequency} = XNONE ] ) ; then
+    Pack=true
+  else
+    Pack=false
+  fi
+
+
+  # Define input parameters
+  # -----------------------
+  set -A JobType_list "${RebuildJob}" "pack_output" "pack_restart" "pack_debug"
+
+  for JobType in ${JobType_list[*]} ; do 
+    typeset    name1="${JobType}_String"
+    typeset    name2="${JobType}_Field"
+    typeset    name3="${JobType}_Activ"
+    if [ X${JobType} == X${RebuildJob} ] ; then
+      if ( ${Pack} ) ; then
+        eval ${name1}=IGCM_sys_PutBuffer_Out
+      else
+        eval ${name1}=IGCM_sys_Put_Out
+      fi
+      eval ${name2}=4
+      eval ${name3}=true
+    else
+      eval ${name1}=IGCM_sys_Put_Out
+      eval ${name2}=3
+      if ( ${Pack} ) ; then
+        eval ${name3}=true
+      else
+        eval ${name3}=false
+      fi
+    fi
+  done
+
+  IGCM_debug_PopStack "IGCM_check_CommonDef"
+
+}
+
+#===================================
+function IGCM_check_ChangeUsr
+{
+
+  IGCM_debug_PushStack "IGCM_check_ChangeUsr" $@
+
+  CurrentGrp=$( groups $CurrentUsr | gawk '{print $3}' )
+  TargetGrp=$( groups $TargetUsr | gawk '{print $3}' )
+
+  echo $1 | sed -e "s/${CurrentUsr}/${TargetUsr}/" \
+                -e "s/${CurrentGrp}/${TargetGrp}/"
+
+  IGCM_debug_PopStack "IGCM_check_ChangeUsr"
+
+}
+
+
+
+#===================================
+function IGCM_check_SearchCatalog
+{
+
+  IGCM_debug_PushStack "IGCM_check_SearchCatalog" $@
+
+  typeset num
+  unset SUBMIT_DIR
+
+  fg_new=false
+
+  if [ ! X${JobName} == X ] ; then
+    NbOcc=$( gawk -v JobName=${JobName} \
+             'BEGIN {x=0}  $1 ~ JobName {++x} END {print x}' ${SimuCatalog} )
+  else
+    NbOcc=0
+  fi
+
+  if ( [ ${NbOcc} -eq 0 ] && ( ${fg_path} ) ) ; then
+
+    if [ ! "$( echo ${ConfigPath} | cut -c 1 )" == "/" ] ; then
+      ConfigPath="${PWD}/${ConfigPath}"
+    fi
+
+    set -A FileList $( ls ${ConfigPath}/Job_* )
+    if [ X$FileList == X ] ; then
+      NbOcc=0
+    else
+      NbOcc=${#FileList[@]}
+      fg_new=true
+    fi
+  fi
+
+  if ( [ ${NbOcc} -eq 0 ] && ( ${fg_search} ) ) ; then
+    SEARCH_DIR=${WORKDIR}
+    if [ ${TargetUsr} != ${CurrentUsr} ] ; then
+      SEARCH_DIR=$( IGCM_check_ChangeUsr ${SEARCH_DIR} )
+    fi
+    echo "${JobName} not in Catalog, we'll try to find it in ${SEARCH_DIR}"
+
+    set -A FileList $( find ${SEARCH_DIR}/ \
+                            -path ${SEARCH_DIR}/IGCM_OUT -prune -o \
+                            -name Job_${JobName} -print )
+    if [ X$FileList == X ] ; then
+      NbOcc=0
+    else
+      NbOcc=${#FileList[@]}
+      fg_new=true
+    fi
+  fi
+
+  if [ ${NbOcc} -gt 1 ] ; then
+    echo "More than one job"
+    ind=0
+    while [ ${ind} -lt ${NbOcc} ] ; do
+      printf '%2i) %-30s\n' ${ind} ${FileList[${ind}]}
+      (( ind = ind + 1 ))
+    done
+    echo "Give your choice number or 'q' to quit : "
+    read Choice
+    if [ X${Choice} == Xq ] ; then
+      return 1
+    else
+      fg_new=true
+      FileList=${FileList[${Choice}]}
+      NbOcc=1
+    fi
+  fi
+
+  case ${NbOcc} in
+    0)
+      if ( ${fg_search} ) ; then
+        echo "${JobName} not found, neither in catalog nor in \$WORKDIR."
+      else
+        echo "${JobName} not found in catalog."
+      fi
+      echo "You can try : *) '-s' option to automatically search your \$WORKDIR ; "
+      echo "              *) '-p' option to provide the directory (absolute path) "
+      echo "                      containing the config.card ; "
+      echo "              *)  manually editing your ${SimuCatalog}."
+      return 1 ;;
+    1)
+      if ( ${fg_new} ) ; then
+#        JobName=${JobName:=$( basename ${FileList} | gawk -F"_" '{ print $2 }' )}
+        JobName=$( basename ${FileList} | gawk -F"_" '{ print $2 }' )
+        SUBMIT_DIR=$( dirname ${FileList} )
+        echo "${JobName} ${TargetUsr} ${HostName} ${SUBMIT_DIR}"
+        echo "${JobName} ${TargetUsr} ${HostName} ${SUBMIT_DIR}" >> ${SimuCatalog}
+        sort -u ${SimuCatalog} > ${SimuCatalog}.tmp
+        mv ${SimuCatalog}.tmp ${SimuCatalog}
+      elif ( [ ${TargetUsr} == $( gawk -v JobName=${JobName} \
+                                      '$1 ~ JobName {print $2}' \
+                                      ${SimuCatalog} ) ] \
+          && [ ${HostName}  == $( gawk -v JobName=${JobName} \
+                                      '$1 ~ JobName {print $3}' \
+                                      ${SimuCatalog} ) ] ) ; then
+        JobName=$( gawk -v JobName=${JobName} '$1 ~ JobName {print $1}' ${SimuCatalog} )
+        SUBMIT_DIR=$( gawk -v JobName=${JobName} '$1 ~ JobName {print $4}' ${SimuCatalog} )
+      else
+        echo "${JobName} not in Catalog."
+        return 1
+      fi
+      ;;
+    *)
+      break ;;
+  esac
+
+  IGCM_debug_PopStack "IGCM_check_SearchCatalog"
+
+}
+
+#===================================
+function IGCM_check_PrintHeader
+{
+
+  IGCM_debug_PushStack "IGCM_check_PrintHeader" $@
+
+  echo "|===========================================================================================================|"
+  printf "| JobName = ${ColExp}%-26.26s${ColNon} JobID = ${ColExp}%-36.36s${ColNon}date : ${ColExp}%-18s${ColNon}|\n" \
+         ${JobName} ${JobID} "$( date +"${DateFormat}" )"
+
+  printf "| User    = ${ColExp}%-56.56s${ColNon}last run.card write : ${ColExp}%-18s${ColNon}|\n" \
+         ${TargetUsr} "${LastWrite}"
+
+  printf "|-----------------------------------------------------------------------------------------------------------|\n"
+
+  printf "| Submit  | ${ColExp}%-95.95s${ColNon} |\n" ${SUBMIT_DIR}
+  printf "| Data    | ${ColExp}%-95.95s${ColNon} |\n" ${DATA_DIR}
+  printf "| Rebuild | ${ColExp}%-95.95s${ColNon} |\n" ${REBUILD_DIR}
+  printf "| Post    | ${ColExp}%-95.95s${ColNon} |\n" ${POST_DIR}
+  printf "| Work    | ${ColExp}%-95.95s${ColNon} |\n" ${CWORK_DIR}
+
+  echo "|-------------------------|-------------|-------------------------|-------------|-----:----------:----------|"
+  echo "|                         |             |                         |             |     Pending Rebuilds      |"
+  echo "| Date Begin - DateEnd    | PeriodState | Current Period          | CumulPeriod | Nb  : from     : to       |"
+  echo "|-------------------------|-------------|-------------------------|-------------|-----:----------:----------|"
+
+  printf "| %-10s - %-10s | " \
+         $DateBegin $DateEnd
+
+  case $PeriodState in
+    Fatal)
+      Color=${ColFat}
+      ;;
+    Completed)
+      Color=${ColCpl}
+      ;;
+    Waiting|OnQueue)
+      Color=${ColAtt}
+      ;;
+    *)
+      Color=${ColDef}
+      ;;
+  esac
+  printf "${Color}%-11s${ColNon} | " $PeriodState
+
+  printf "%-10s - %-10s | %11s | " \
+         $PeriodDateBegin $PeriodDateEnd $CumulPeriod
+
+  if ( [ X${NbRebuild} != X. ] && [ X${NbRebuild} != X0 ] ) ; then
+    printf "${ColRbl}%3s : %-8s : %-8s${ColNon} |\n" \
+           $NbRebuild $FirstRebuild $LastRebuild
+  else
+    printf "%3s : %-8s : %-8s |\n" \
+           $NbRebuild $FirstRebuild $LastRebuild
+  fi
+
+  if [ ${NbLines} -gt 0 ] ; then
+    printf "|-----------------------------------------------------------------------------------------------------------|\n"
+    printf "|                                                      Last                                                 |\n"
+    printf "|     Rebuild      |   Pack_Output    |   Pack_Restart   |    Pack_Debug    |  Monitoring  |     Atlas      |\n"
+    printf "|------------------|------------------|------------------|------------------|--------------|----------------|\n"
+  fi
+
+  IGCM_debug_PopStack "IGCM_check_PrintHeader"
+
+}
+
+#===================================
+function IGCM_check_PrintJob
+{
+
+  IGCM_debug_PushStack "IGCM_check_PrintJob" $@
+
+  printf "|"
+
+  #Â Print rebuild and pack jobs
+  #Â ---------------------------
+  for JobType in ${JobType_list[*]} ; do 
+    eval Date=\${${JobType}_Date[${ind}]}
+    eval Status=\${${JobType}_Status[${ind}]}
+    eval Nb=\${${JobType}_Nb[${ind}]}
+
+    if [ X${Status} == XOK  ] ; then
+      Color=${ColCpl}
+    else
+      Color=${ColFat}
+    fi
+    printf "  ${Color}%-8s${ColNon} : %3s  |" ${Date} ${Nb}
+  done
+
+  Color=${ColExp}
+
+  #Â Print monitoring jobs
+  #Â ---------------------
+  JobType=monitoring
+  if [ $ind -eq 0 ] ; then
+    eval Date=\${${JobType}_Date}
+  else
+    Date=""
+  fi
+  printf "     ${Color}%-4s${ColNon}     |" ${Date}
+
+  #Â Print atlas jobs
+  #Â ----------------
+  JobType=atlas
+  eval Date=\${${JobType}_Date[${ind}]}
+  printf "  ${Color}%-12s${ColNon}  |" ${Date}
+
+  printf "\n"
+
+  IGCM_debug_PopStack "IGCM_check_PrintJob"
+
+}
+
+#===================================
+function IGCM_check_PrintFooter
+{
+
+  IGCM_debug_PushStack "IGCM_check_PrintFooter" $@
+
+  printf "|===========================================================================================================|\n"
+  #date +"${DateFormat}"
+
+  IGCM_debug_PopStack "IGCM_check_PrintFooter"
+
+}
+
+#===================================
+function IGCM_check_CheckPendingRebuild
+{
+
+  IGCM_debug_PushStack "IGCM_check_PendingRebuild" $@
+
+  NbRebuild="."
+  FirstRebuild="."
+  LastRebuild="."
+
+  if [ ${RebuildExists} == 0 ] ; then
+    set -A RebuildList $( find ${REBUILD_DIR}/ -name "REBUILD_*" | sort )
+    if [ ${#RebuildList[*]} -gt 0 ] ; then
+      NbRebuild=$( IGCM_sys_CountFileArchive ${REBUILD_DIR} )
+
+      FirstRebuild=$( basename ${RebuildList[0]} | cut -f2 -d\_ )
+      LastRebuild=$( basename ${RebuildList[ (( NbRebuild=${NbRebuild}-1 )) ]} | cut -f2 -d\_ )
+    fi
+  fi
+
+  IGCM_debug_PopStack "IGCM_check_PendingRebuild"
+
+}
+
+#===================================
+function IGCM_check_CheckRebPackJobs
+{
+
+  IGCM_debug_PushStack "IGCM_check_CheckRebPackJobs" $@
+
+  NbLines=0
+  for JobType in ${JobType_list[*]} ; do
+    eval String=\${${JobType}_String}
+    eval Field=\${${JobType}_Field}
+    eval Activ=\${${JobType}_Activ}
+
+    if ( ${Activ} ) ; then
+
+      set -A FileList $( ls ${POST_DIR}/${JobType}.*.out | tail -n ${NbHisto} )
+
+      if [ ${#FileList[*]} -gt ${NbLines} ] ; then
+        NbLines=${#FileList[*]}
+      fi
+
+      (( ind = 0 ))
+      for FileName in ${FileList[*]} ; do
+        LastDate=""
+        LastDate=$( basename ${FileName} | gawk -F"." '{ print $(NF-1) }' )
+
+        set -- $( gawk -v String=${String} \
+                       'BEGIN { nb_ok = 0 ; nb_ko = 0 } \
+                       ($1 ~ String) { \
+                         if ($3 !~ /error./) { \
+                           nb_ok = nb_ok + 1 \
+                         } else { \
+                           nb_ko = nb_ko + 1 \
+                         } \
+                       } \
+                       END { print nb_ok " " nb_ko }' \
+                       ${POST_DIR}/${JobType}.${LastDate}.out )
+        Match=$1
+        Error=$2
+
+        (( Nb = ${Match} - ${Error} ))
+
+        if ( [ ${Error} -eq 0 ] && [ ${Nb} -gt 0 ] ) ; then
+          Status=OK
+        else
+          Status=KO
+        fi
+
+        eval ${JobType}_Date[$ind]=${LastDate}
+        eval ${JobType}_Status[$ind]=${Status}
+        eval ${JobType}_Nb[$ind]=${Nb}
+
+        (( ind = ind + 1 ))
+      done
+
+    else
+
+        eval ${JobType}_Date[0]=""
+        eval ${JobType}_Status[0]=""
+        eval ${JobType}_Nb[0]=""
+
+    fi
+
+  done
+
+  IGCM_debug_PopStack "IGCM_check_CheckRebPackJobs"
+
+}
+
+#===================================
+function IGCM_check_CheckMonitoring
+{
+
+  IGCM_debug_PushStack "IGCM_check_CheckMonitoring" $@
+
+    LastDate=""
+    JobType=monitoring
+    IGCM_sys_TestDirArchive ${CWORK_DIR}/MONITORING
+    RC=$?
+    if [ $RC == 0 ] ; then
+      FileTmp=$( IGCM_sys_RshArchive "ls ${CWORK_DIR}/MONITORING/files/*.nc | head -n 1" )
+      IGCM_sys_GetDate_Monitoring ${FileTmp} LastDate
+      eval ${JobType}_Date=${LastDate}
+    fi
+
+  IGCM_debug_PopStack "IGCM_check_CheckMonitoring"
+
+}
+
+#===================================
+function IGCM_check_CheckAtlas
+{
+
+  IGCM_debug_PushStack "IGCM_check_CheckAtlas" $@
+
+  JobType=atlas
+  IGCM_sys_TestDirArchive ${CWORK_DIR}/ATLAS
+  RC=$?
+  if [ $RC == 0 ] ; then
+    set -A FileList $( IGCM_sys_RshArchive "ls ${CWORK_DIR}/ATLAS | tail -n ${NbHisto}" )
+
+    if [ ${#FileList[*]} -gt ${NbLines} ] ; then
+      NbLines=${#FileList[*]}
+    fi
+
+    (( ind = 0 ))
+    for FileName in ${FileList[*]} ; do
+      eval ${JobType}_Date[$ind]=${FileName}
+      (( ind = ind + 1 ))
+    done
+  fi
+
+  IGCM_debug_PopStack "IGCM_check_CheckAtlas"
+
+}
+
+#===================================
Index: /tags/libIGCM_v2.2/libIGCM_comp/libIGCM_comp.ksh
===================================================================
--- /tags/libIGCM_v2.2/libIGCM_comp/libIGCM_comp.ksh	(revision 998)
+++ /tags/libIGCM_v2.2/libIGCM_comp/libIGCM_comp.ksh	(revision 998)
@@ -0,0 +1,1338 @@
+#!/bin/ksh
+
+#**************************************************************
+# Author: Sebastien Denvil, Martial Mancip
+# Contact: Sebastien.Denvil__at__ipsl.jussieu.fr Martial.Mancip__at__ipsl.jussieu.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#========================================================================
+function IGCM_comp_Initialize
+{
+  IGCM_debug_PushStack "IGCM_comp_Initialize"
+
+  # Debug Print :
+  echo
+  IGCM_debug_Print 1 "IGCM_comp_Initialize"
+  echo
+
+  typeset comp compname comptagname CompatibilityTag auxprint card_UserChoices first_option option i j
+  for comp in ${config_ListOfComponents[*]} ; do
+
+    # Define component
+    IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/config.card ListOfComponents ${comp}
+    eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1
+    eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1
+
+    # Debug Print
+    IGCM_debug_Print 1 "Initialize ${comp} : ${compname} component."
+
+    # Read libIGCM compatibility version in ${compname}.card
+    card=${SUBMIT_DIR}/COMP/${compname}.card
+    IGCM_card_DefineVariableFromOption ${card} Compatibility libIGCM
+
+    eval CompatibilityTag=\${${compname}_Compatibility_libIGCM} > /dev/null 2>&1
+    if [ ! "${CompatibilityTag}" = "${libIGCM_CurrentTag}" ] ; then
+      IGCM_debug_Exit "${compname}.card is not compatible with libIGCM version ${libIGCM_CurrentTag} see libIGCM FAQ http://wiki.ipsl.jussieu.fr/wiki_ipsl/IGCMG/libIGCM/DocUtilisateur/FAQ ."
+    fi
+
+    # Manage component executable
+    IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/config.card Executable ${comp}
+
+    # Define all options in section [comp]
+    IGCM_debug_Print 3 " DefineArrayFromSection : ${comp}"
+    IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card ${comp}
+    eval config_comp=\${config_${comp}[*]} > /dev/null 2>&1
+    for option in ${config_comp[*]} ; do
+        IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ${comp} ${option}
+    done
+    IGCM_debug_Print 3 " Found in section config_${comp} :  ${config_comp[*]} "
+
+    # Debug Print :
+    eval auxprint=\${config_${comp}_WriteFrequency}
+    IGCM_debug_Print 1 "Write frequency for ${compname} : ${auxprint} "
+    #2> /dev/null
+
+    # Debug Print :
+    IGCM_debug_Print 2 "Initialize following component library"
+
+    # Source drivers in directory DRIVER if it exist
+    # else source them from directory COMP
+    if [ -d ${SUBMIT_DIR}/DRIVER ] ; then
+      IGCM_debug_Print 2 ${SUBMIT_DIR}/DRIVER/${compname}.driver
+      # Source component library
+      . ${SUBMIT_DIR}/DRIVER/${compname}.driver
+    else
+      IGCM_debug_Print 2 ${SUBMIT_DIR}/COMP/${compname}.driver
+      # Source component library
+      . ${SUBMIT_DIR}/COMP/${compname}.driver
+    fi
+    IGCM_debug_Print 3 "With tag : ${comptagname}"
+
+    # Debug Print
+    IGCM_debug_Print 3 "Initialize ${comp} output directory."
+
+    # Define ARCHIVED Dirs
+    eval R_OUT_${comp}=${R_SAVE}/${comp}
+    eval IGCM_sys_MkdirArchive \${R_OUT_${comp}}
+
+    eval R_OUT_${comp}_O=\${R_OUT_${comp}}/Output
+    eval IGCM_sys_MkdirArchive \${R_OUT_${comp}_O}
+
+    eval R_OUT_${comp}_R=\${R_OUT_${comp}}/Restart
+    [ ${config_Post_PackFrequency} = NONE ] && eval IGCM_sys_MkdirArchive \${R_OUT_${comp}_R}
+
+    eval R_OUT_${comp}_D=\${R_OUT_${comp}}/Debug
+    [ ${config_Post_PackFrequency} = NONE ] && eval IGCM_sys_MkdirArchive \${R_OUT_${comp}_D}
+
+    eval R_OUT_${comp}_O_I=\${R_OUT_${comp}_O}/INS
+    eval R_OUT_${comp}_O_H=\${R_OUT_${comp}_O}/HF
+    eval R_OUT_${comp}_O_D=\${R_OUT_${comp}_O}/DA
+    eval R_OUT_${comp}_O_M=\${R_OUT_${comp}_O}/MO
+    eval R_OUT_${comp}_O_Y=\${R_OUT_${comp}_O}/YE
+
+    # Define BUFFERED Dirs
+    if [ ! ${config_Post_PackFrequency} = NONE ] ; then
+      eval R_BUF_${comp}=${R_BUFR}/${comp}
+      eval IGCM_sys_Mkdir \${R_BUF_${comp}}
+
+      eval R_BUF_${comp}_O=\${R_BUF_${comp}}/Output
+      eval IGCM_sys_Mkdir \${R_BUF_${comp}_O}
+
+      eval R_BUF_${comp}_R=\${R_BUF_${comp}}/Restart
+      eval IGCM_sys_Mkdir \${R_BUF_${comp}_R}
+
+      eval R_BUF_${comp}_D=\${R_BUF_${comp}}/Debug
+      eval IGCM_sys_Mkdir \${R_BUF_${comp}_D}
+
+      eval R_BUF_${comp}_O_I=\${R_BUF_${comp}_O}/INS
+      eval R_BUF_${comp}_O_H=\${R_BUF_${comp}_O}/HF
+      eval R_BUF_${comp}_O_D=\${R_BUF_${comp}_O}/DA
+      eval R_BUF_${comp}_O_M=\${R_BUF_${comp}_O}/MO
+      eval R_BUF_${comp}_O_Y=\${R_BUF_${comp}_O}/YE
+    fi
+
+    # Read UserChoices section of component card
+    IGCM_debug_Print 2 "DefineArrayFromSection : ${compname}_UserChoices ${card}"
+    IGCM_card_DefineArrayFromSection ${card} UserChoices
+    eval first_option=\${${compname}_UserChoices[0]} > /dev/null 2>&1
+
+    # If section is not empty we define corresponding variables
+    if [ X${first_option} != X"Error:" ] ; then
+      if [ X${card_UserChoices[0]} != X ] ; then
+        unset card_UserChoices
+      fi
+      eval set +A card_UserChoices -- \${${compname}_UserChoices[*]} > /dev/null 2>&1
+      IGCM_debug_Print 3 "${compname}_UserChoices_values:"
+      for option in ${card_UserChoices[*]} ; do
+        IGCM_card_DefineVariableFromOption ${card} UserChoices ${option}
+        eval IGCM_debug_Print 3 "${option}=\${${compname}_UserChoices_${option}}"
+      done
+    fi
+
+    # Read and Build Output File stuff
+    IGCM_debug_Print 2 "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
+      #
+      i=2
+      #
+      until [ $i -ge $NbFiles ]; do
+        #
+        eval flag_post=\${${ListFilesName}[$i]} > /dev/null 2>&1
+        #
+        if [ X${flag_post} != XNONE ] ; then
+          #
+          # First of all
+          #
+          IGCM_card_DefineArrayFromSection ${card} ${flag_post}
+          #
+          # Seasonal case : If option Seasonal is not found (old cards) put SEASONAL ON by default
+          #
+          # variable option allready typeset above
+          for option in $( eval echo \${${compname}_${flag_post}[*]} ) ; do
+            if [ ${option} = Seasonal ] ; then
+              FoundSeasonal=true
+              IGCM_card_DefineVariableFromOption ${card} ${flag_post} Seasonal
+            fi
+          done
+          #
+          if [ ! X${FoundSeasonal} = Xtrue ] ; then
+            eval ${compname}_${flag_post}_Seasonal=ON
+          fi
+          #
+          if [ $( eval echo \${${compname}_${flag_post}_Seasonal} ) = ON ] ; then
+            Seasonal=true
+          fi
+
+          # Dimension = vide si vieille card.
+          IGCM_card_DefineArrayFromOption ${card} ${flag_post} TimeSeriesVars
+          IGCM_card_DefineArrayFromOption ${card} ${flag_post} Patches
+          if [ X"$( eval echo \${${compname}_${flag_post}_TimeSeriesVars[*]} )" = X"Option not" ] ; then
+            # New TimeSeriesVar description, with 2D, 3D and associate ChunckJob.
+            ListDimension[0]=2D
+            ListDimension[1]=3D
+            TimeSeries=false
+            iLoop=${#ListDimension[*]}
+            j=0
+            until [ $j -ge ${iLoop} ]; do
+              Dimension=${ListDimension[${j}]}
+              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}"
+                  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 ] &&  [ ! ${chunck_size} = OFF ] ; then
+                  IGCM_debug_Print 3 "${Dimension} time series activated with chunck for ${flag_post}"
+                  eval TimeSeriesChunck${Dimension}=true
+                  eval CHUNCK${Dimension}_COMP[\${#CHUNCK${Dimension}_COMP[*]}]=${comp}
+                  eval CHUNCK${Dimension}_FLAG[\${#CHUNCK${Dimension}_FLAG[*]}]=${i}
+                  eval CHUNCK${Dimension}_NAME[\${#CHUNCK${Dimension}_NAME[*]}]=${flag_post}
+                  eval CHUNCK${Dimension}_SIZE[\${#CHUNCK${Dimension}_SIZE[*]}]=${chunck_size}
+                fi
+              fi
+              (( j=j+1 ))
+            done
+          else
+            ListDimension[0]=""
+            TimeSeries=true
+            TimeSeries2D=false
+            TimeSeries3D=false
+            TimeSeriesChunck2D=false
+            TimeSeriesChunck3D=false
+          fi
+        fi
+        (( i=i+3 ))
+      done
+    fi
+    # Debug Print
+    IGCM_debug_Print 3 "Initialize ${compname} with driver."
+    # INIT component
+    ${comp}_Initialize
+    echo
+  done
+
+  IGCM_debug_PopStack "IGCM_comp_Initialize"
+}
+
+#=======================================================================
+function IGCM_comp_PrepareDeletedFiles
+{
+  IGCM_debug_PushStack "IGCM_comp_PrepareDeletedFiles" $@
+
+  if [ X${2} != X. ] ; then
+    eval FileToBeDeleted[${#FileToBeDeleted[@]}]=$( basename ${2} ) > /dev/null 2>&1
+  else
+    eval FileToBeDeleted[${#FileToBeDeleted[@]}]=$( basename ${1} ) > /dev/null 2>&1
+  fi
+
+  IGCM_debug_PopStack "IGCM_comp_PrepareDeletedFiles"
+}
+
+#=======================================================================
+function IGCM_comp_GetInputInitialStateFiles
+{
+  IGCM_debug_PushStack "IGCM_comp_GetInputInitialStateFiles"
+
+  # Debug Print :
+  echo
+  IGCM_debug_Print 1 "IGCM_comp_GetInputInitialStateFiles"
+  echo
+
+  # Only the first time step need InitialStateFiles
+  # otherwise it's BoundaryConditions
+  if ( ${FirstInitialize} ) ; then
+    typeset comp compname comptagname card ListFilesName FileName0 NbFiles i i_
+    typeset file_in_ file_in file_out_ file_out do_init
+    for comp in ${config_ListOfComponents[*]} ; do
+      # Initialize
+      do_init="y"
+      # Do we need to bring initial state file for this component
+      if [ "${config_Restarts_OverRule}" = "y" ] ; then
+        eval do_init="n"
+      else
+        # Read component Restarts parameters
+        IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ${comp} Restart
+        eval do_start=\${config_${comp}_Restart} > /dev/null 2>&1
+        if [ "${do_start}" = "y" ] ; then
+          do_init="n"
+        else
+          do_init="y"
+        fi
+      fi
+
+      if [ "${do_init}" = "y" ] ; then
+        # Define component
+        eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1
+        eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1
+
+        # Debug Print :
+        IGCM_debug_Print 3 "Initialisation files ${compname}"
+
+        card=${SUBMIT_DIR}/COMP/${compname}.card
+
+        IGCM_card_DefineArrayFromOption ${card} InitialStateFiles List
+        ListFilesName=${compname}_InitialStateFiles_List
+
+        eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1
+        if [ X${FileName0} != X${NULL_STR} ] ; then
+          eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1
+          (( i=0 ))
+          until [ $i -ge $NbFiles ]; do
+            eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1
+            eval file_in=${file_in_}
+            (( i_ = i+1 ))
+            eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1
+            eval file_out=${file_out_}
+
+            IGCM_sys_IsFileArchived ${file_in}
+            if [ $? = 0 ] ; then
+              IGCM_sys_Get ${file_in} ${file_out}
+              #IGCM_comp_PrepareDeletedFiles ${file_in} ${file_out}
+            else
+              IGCM_sys_Cp ${file_in} ${file_out}
+            fi
+            (( i=i+2 ))
+          done
+        fi
+      fi
+    done
+  fi
+  IGCM_debug_PopStack "IGCM_comp_GetInputInitialStateFiles"
+}
+
+#=======================================================================
+# Definition of Smooth modulo function
+# usage :
+# IGCM_SmoothModulo StringModulo value
+#
+# StringModulo : A string of min max and modulo like definition of Scilab vectors.
+# [min]:[modulo:][max]
+# where :
+# [] value are optionnals;
+# empty min equal 1
+# empty max equal infinity
+# modulo not given or empty equal 1
+# empty string or just ':' equal always.
+#
+# value : the value to test with the definition
+#
+# return : true(1)/false(0)
+function IGCM_SmoothModulo
+{
+  IGCM_debug_PushStack "IGCM_SmoothModulo"
+  typeset defVector ModValue
+
+  eval set +A defVector -- $( echo "${1}" | \
+    gawk -F ':' '{print ($1 == "" ? 1 : $1) " " (NF==3 ? ($2 == "" ? 1 : $2) : 1) " " (NF==3 ? ($3 == "" ? -1 : $3) : ($2 == "" ? -1 : $2))}' )
+
+  # Save Smooth Min and Max. Needed to call IGCM_sys_Get when appropriate
+  arr[1]=${defVector[0]}
+  arr[2]=${defVector[2]}
+
+  # Test limits :
+  # ${defVector[0]} <= ${2} <= ${defVector[2]}
+  #          or ${defVector[2]} == -1
+  if ( [ ${2} -ge ${defVector[0]} ] && ( [ ${2} -le ${defVector[2]} ] || [ ${defVector[2]} -lt 0 ] ) ) ; then
+    # Test modulo
+    ModValue=$( expr \( ${2} - ${defVector[0]} \) % ${defVector[1]} )
+    if [ ${ModValue} -eq 0 ] ;  then
+      arr[3]=true
+      echo ${arr[@]}
+      IGCM_debug_PopStack "IGCM_SmoothModulo"
+      return 1
+    else
+      arr[3]=false
+      echo ${arr[@]}
+      IGCM_debug_PopStack "IGCM_SmoothModulo"
+      return 0
+    fi
+  else
+    arr[3]=false
+    echo ${arr[@]}
+    IGCM_debug_PopStack "IGCM_SmoothModulo"
+    return 0
+  fi
+}
+
+#=======================================================================
+function IGCM_comp_GetInputSmoothFiles
+{
+  IGCM_debug_PushStack "IGCM_comp_GetInputSmoothFiles"
+
+  # Debug Print :
+  echo
+  IGCM_debug_Print 1 "IGCM_comp_GetInputSmoothFiles"
+  echo
+
+  typeset comp compname comptagname card ListFilesName FileName0 NbFiles j i i_ i__
+  typeset file_in_ file_in file_out_ file_out ret SmoothDef aux val
+
+  for comp in ${config_ListOfComponents[*]} ; do
+    # Define component
+    eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1
+    eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1
+
+    # Debug Print :
+    IGCM_debug_Print 3 "Smooth files ${compname}"
+
+    card=${SUBMIT_DIR}/COMP/${compname}.card
+
+    IGCM_card_DefineArrayFromOption ${card} SmoothFiles List
+    ListFilesName=${compname}_SmoothFiles_List
+    eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1
+
+    if ( [ X${FileName0} != X${NULL_STR} ] && [ X${FileName0} != X"Section" ] ) ; then
+      eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1
+
+      (( i=0 ))
+      until [ $i -ge $NbFiles ]; do
+        eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1
+        eval file_in=${file_in_}
+        (( i_ = i+1 ))
+        eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1
+        eval file_out=${file_out_}
+
+        # define CumulPeriod definition for this file
+        (( i__ = i+2 ))
+        eval SmoothDef=\${${ListFilesName}[$i__]}
+        IGCM_debug_Print 3 "  ${file_in} ${SmoothDef}"
+        aux=$( IGCM_SmoothModulo ${SmoothDef} ${CumulPeriod} )
+        j=1
+        for val in ${aux} ; do
+          [ ${j} -eq 1 ] && SmoothMin=${val}
+          [ ${j} -eq 2 ] && SmoothMax=${val}
+          [ ${j} -eq 3 ] && ret=${val}
+          (( j=j+1 ))
+        done
+        [ ${SmoothMax} -eq -1 ] && SmoothMax=${CumulPeriod}
+        if ( [ X${ret} = Xtrue ] || ( [ ${Period} -eq 1 ] && [ ${CumulPeriod} -ge ${SmoothMin} ] && [ ${CumulPeriod} -le ${SmoothMax} ] ) ) ; then
+
+          IGCM_sys_IsFileArchived ${file_in}
+          if [ $? = 0 ] ; then
+            IGCM_sys_Get ${file_in} ${file_out}
+            #IGCM_comp_PrepareDeletedFiles ${file_in} ${file_out}
+          else
+            IGCM_sys_Cp ${file_in} ${file_out}
+          fi
+        fi
+        (( i=i+3 ))
+      done
+    fi
+  done
+
+  IGCM_debug_PopStack "IGCM_comp_GetInputSmoothFiles"
+}
+
+#=======================================================================
+function IGCM_comp_GetInputBoundaryFiles
+{
+  IGCM_debug_PushStack "IGCM_comp_GetInputBoundaryFiles"
+
+  # Debug Print :
+  echo
+  IGCM_debug_Print 1 "IGCM_comp_GetInputBoundaryFiles"
+  echo
+
+  typeset comp compname comptagname card ListFilesName FileName0 NbFiles i i_
+  typeset file_in_ file_in file_out_ file_out
+
+  if [ ${Period} = 1 ]; then
+    ListFixBoundary=" "
+  fi
+
+  for comp in ${config_ListOfComponents[*]} ; do
+
+    # Define component
+    eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1
+    eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1
+
+    # Debug Print :
+    IGCM_debug_Print 3 "Boundary files ${compname}"
+
+    card=${SUBMIT_DIR}/COMP/${compname}.card
+
+    IGCM_card_DefineArrayFromOption ${card} BoundaryFiles List
+    ListFilesName=${compname}_BoundaryFiles_List
+    eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1
+
+    if [ X${FileName0} != X${NULL_STR} ] ; then
+      eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1
+
+      (( i=0 ))
+      until [ $i -ge $NbFiles ]; do
+        eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1
+        eval file_in=${file_in_}
+        (( i_ = i+1 ))
+        eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1
+        eval file_out=${file_out_}
+
+        IGCM_sys_IsFileArchived ${file_in}
+        if [ $? = 0 ] ; then
+          IGCM_sys_Get ${file_in} ${file_out}
+          IGCM_comp_PrepareDeletedFiles ${file_in} ${file_out}
+        else
+          IGCM_sys_Cp ${file_in} ${file_out}
+        fi
+
+        (( i=i+2 ))
+      done
+    fi
+
+    # Get non deleted files
+    if [ ${Period} = 1 ]; then
+
+      IGCM_card_DefineArrayFromOption ${card} BoundaryFiles ListNonDel
+      ListFilesName=${compname}_BoundaryFiles_ListNonDel
+      eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1
+
+      if [ X${FileName0} != X${NULL_STR} ] ; then
+        eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1
+
+        (( i=0 ))
+        until [ $i -ge $NbFiles ]; do
+          eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1
+          eval file_in=${file_in_}
+          (( i_ = i+1 ))
+          eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1
+          eval file_out=${file_out_}
+
+          IGCM_sys_IsFileArchived ${file_in}
+          if [ $? = 0 ] ; then
+            IGCM_sys_Get ${file_in} ${file_out}
+            #IGCM_comp_PrepareDeletedFiles ${file_in} ${file_out}
+          else
+            IGCM_sys_Cp ${file_in} ${file_out}
+          fi
+
+          if [ X${file_out} != X. ] ; then
+            ListFixBoundary=${ListFixBoundary}" "${file_out}
+          else
+            ListFixBoundary=${ListFixBoundary}" "$( basename ${file_in} )
+          fi
+
+          (( i=i+2 ))
+        done
+      fi
+    fi
+  done
+
+  IGCM_debug_PopStack "IGCM_comp_GetInputBoundaryFiles"
+}
+
+#=======================================================================
+function IGCM_comp_DelFixeBoundaryFiles
+{
+  IGCM_debug_PushStack "IGCM_comp_DelFixeBoundaryFiles"
+
+  # Debug Print :
+  echo
+  IGCM_debug_Print 1 "IGCM_comp_DelFixeBoundaryFiles"
+  echo
+
+  ls -l ${ListFixBoundary}
+  rm -f ${ListFixBoundary}
+
+  IGCM_debug_PopStack "IGCM_comp_DelFixeBoundaryFiles"
+}
+
+#=======================================================================
+function IGCM_comp_GetInputParametersFiles
+{
+  IGCM_debug_PushStack "IGCM_comp_GetInputParametersFiles"
+
+  # Debug Print :
+  echo
+  IGCM_debug_Print 1 "IGCM_comp_GetInputParametersFiles"
+  echo
+
+  typeset comp compname comptagname card ListFilesName FileName0 NbFiles i i_ file_in file_out
+  for comp in ${config_ListOfComponents[*]} ; do
+    # Define component
+    eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1
+    eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1
+
+    # Debug Print :
+    IGCM_debug_Print 3 "Parameters ${compname}"
+
+    card=${SUBMIT_DIR}/COMP/${compname}.card
+
+    IGCM_card_DefineArrayFromOption ${card} ParametersFiles List
+    ListFilesName=${compname}_ParametersFiles_List
+    eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1
+
+    if [ X${FileName0} != X${NULL_STR} ] ; then
+      eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1
+
+      (( i=0 ))
+      until [ $i -ge $NbFiles ]; do
+        eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1
+        eval file_in=${file_in_}
+        (( i_ = i+1 ))
+        eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1
+        eval file_out=${file_out_}
+
+        IGCM_sys_Cp ${file_in} ${file_out}
+        IGCM_comp_PrepareDeletedFiles ${file_in} ${file_out}
+
+        (( i=i+2 ))
+      done
+    fi
+  done
+
+  IGCM_debug_PopStack "IGCM_comp_GetInputParametersFiles"
+}
+
+#=======================================================================
+function IGCM_comp_GetInputRestartFiles
+{
+  IGCM_debug_PushStack "IGCM_comp_GetInputRestartFiles"
+
+  # Debug Print :
+  echo
+  IGCM_debug_Print 1 "IGCM_comp_GetInputRestartFiles"
+  echo
+
+  typeset Date_tmp Date_r Path_r do_start CompOldName Path_OUT Path_BUF
+  typeset Buffered Archived Tared PotentialTarFile IsMatching TarFileFound
+  typeset comp compname comptagname card ListFilesName FileName0 NbFiles i i_
+  typeset file_in file_out file_in_ file_out_ file_in_Name
+  typeset -Z4 j4
+  #BASH declare j4
+
+  IsMatching=""
+
+  for comp in ${config_ListOfComponents[*]} ; do
+    # Define component
+    eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1
+    eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1
+    #
+    card=${SUBMIT_DIR}/COMP/${compname}.card
+    #
+    IGCM_card_DefineArrayFromOption ${card} RestartFiles List
+    ListFilesName=${compname}_RestartFiles_List
+    eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1
+
+    # Debug Print :
+    IGCM_debug_Print 3 "restart ${compname}"
+
+    if ( ${FirstInitialize} ) ; then
+
+      if [ "${config_Restarts_OverRule}" = "y" ] ; then
+        eval config_${comp}_Restart="y"
+        eval config_${comp}_RestartDate=${config_Restarts_RestartDate}
+        eval config_${comp}_RestartJobName=${config_Restarts_RestartJobName}
+        eval config_${comp}_RestartPath=${config_Restarts_RestartPath}
+        eval do_start=\${config_${comp}_Restart} > /dev/null 2>&1
+        eval CompOldName=${comp}
+      else
+        # Read component Restarts parameters
+        IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ${comp} Restart
+        eval do_start=\${config_${comp}_Restart} > /dev/null 2>&1
+
+        if [ "${do_start}" = "y" ] ; then
+          IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ${comp} RestartDate
+          IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ${comp} RestartJobName
+          IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card ${comp} RestartPath
+        else
+          eval config_${comp}_RestartDate=-1
+          eval config_${comp}_RestartJobName=${NULL_STR}
+          eval config_${comp}_RestartPath=${NULL_STR}
+        fi
+
+        eval CompOldName=\${config_${comp}_OldName}
+        if [ X${CompOldName} = X ] ; then
+          eval CompOldName=${comp}
+        fi
+
+        # Reinitialize IsMatching to allow searching for a different tar file for each component.
+        IsMatching=""
+        TarFileFound=""
+      fi
+
+      if [ "${do_start}" = "y" ] ; then
+
+        # Restore Restarts files
+        #-----------------------
+        if ( [ X${FileName0} != X${NULL_STR} ] && [ X${FileName0} != XNONE ] ) ; then
+          eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1
+
+          (( i=1 ))
+          until [ $i -gt $NbFiles ]; do
+            eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1
+            eval file_in=${file_in_}
+            (( i_ = i+1 ))
+            eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1
+            eval file_out=${file_out_}
+
+            eval Date_tmp=\${config_${comp}_RestartDate}
+            Date_r=$( IGCM_date_ConvertFormatToGregorian ${Date_tmp} )
+            # will be re-use
+            eval RestartPath=\${config_${comp}_RestartPath}
+            eval RestartJobName=\${config_${comp}_RestartJobName}
+            #
+            Path_r=${RestartPath}/${RestartJobName}/${CompOldName}/Restart
+            file_in_Name=${RestartJobName}_${Date_r}_${file_in}
+
+            extension_in=$( echo ${file_in_Name##*.} )
+            extension_out=$( echo ${file_out##*.} )
+
+            generic_restart_file_name_in=$( basename ${file_in_Name} .${extension_in} )
+            generic_restart_file_name_out=$( basename ${file_out} .${extension_out} )
+
+            Path_OUT=${Path_r}/${generic_restart_file_name_in}
+
+            if [ $( IGCM_sys_TestFileBuffer ${Path_OUT}*.${extension_in} ; echo $? ) = 0 ] ; then
+              IGCM_debug_Print 3 "Buffered restart ${Path_OUT}*.${extension_in} "
+              Buffered=true
+              Archived=false
+              Tared=false
+              nb_restart_file=$(IGCM_sys_CountFileBuffer ${Path_OUT}_????.${extension_in})
+            elif [ $( IGCM_sys_TestFileArchive ${Path_OUT}*.${extension_in} ; echo $? ) = 0 ] ; then
+              IGCM_debug_Print 3 "Archived restart ${Path_OUT}*.${extension_in}"
+              Buffered=false
+              Archived=true
+              Tared=false
+              nb_restart_file=$(IGCM_sys_CountFileArchive ${Path_OUT}_????.${extension_in})
+            else
+              IGCM_debug_Print 3 "No restart file in the buffer nor in the archive directory"
+              IGCM_debug_Print 3 "${Path_OUT}*.${extension_in} do not exist"
+              IGCM_debug_Print 3 "Restart files will now be searched for in : ${RestartPath}/${RestartJobName}/RESTART"
+              Buffered=false
+              Archived=false
+              Tared=true
+              # Look after the tar file we want if we did not found it already
+              if [ X${IsMatching} = X ] ; then
+                IGCM_sys_TestDirArchive ${RestartPath}/${RestartJobName}/RESTART
+                if [ $? ] ; then
+                  for PotentialTarFile in $( IGCM_sys_RshArchive "find ${RestartPath}/${RestartJobName}/RESTART -name "${RestartJobName}_*restart*.tar" -print" ) ; do
+                    IsMatching=$( echo ${PotentialTarFile##*/} | \
+                      sed "s:_restart::" | \
+                      sed "s:^${RestartJobName}_::" | \
+                      sed "s:\.tar$::" | \
+                      gawk -F_ -v restartdate=${Date_r} \
+                      '{if (($1 <= restartdate) && ($2 >= restartdate)) {print $1"_"$2}}' )
+                    if [ ! X${IsMatching} = X ] ; then
+                      TarFileFound=${PotentialTarFile}
+                      break
+                    fi
+                  done
+                else
+                  IGCM_debug_Print 3 "Restart files were not found!"
+                  IGCM_debug_Print 3 "Restart files have been searched for in buffer and archive directory."
+                  IGCM_debug_Print 3 "They have been searched for in packed and unpacked format."
+                  IGCM_debug_Exit "Please double check restart settings in config.card"
+                  IGCM_debug_Verif_Exit
+                fi
+              fi
+              IGCM_sys_PrepareTaredRestart ${TarFileFound}
+              TarFileLocation=$( basename ${TarFileFound} )
+              IGCM_debug_Print 1 "tar xvf ${TarFileLocation} ${comp}_${generic_restart_file_name_in}*.${extension_in}"
+              tar xvf ${TarFileLocation} ${comp}_${generic_restart_file_name_in}*.${extension_in}
+              nb_restart_file=$( IGCM_sys_CountFileBuffer ${comp}_${generic_restart_file_name_in}_????.${extension_in} )
+            fi
+
+            if [ ${nb_restart_file} -gt 1 ] ; then
+              j=0                                      # BASH LINE NOT NEEDED
+              # BASH for j4 in in $( eval echo {0000..$(( nb_restart_file - 1 ))} ) ; do
+              until [ $j -ge ${nb_restart_file} ]; do  # BASH LINE NOT NEEDED
+                j4=${j}                                # BASH LINE NOT NEEDED
+                if [ X${Buffered} = Xtrue ] ; then
+                  IGCM_sys_GetBuffer ${Path_OUT}_${j4}.${extension_in} ${generic_restart_file_name_out}_${j4}.${extension_out}
+                elif [ X${Archived} = Xtrue ] ; then
+                  IGCM_sys_Get ${Path_OUT}_${j4}.${extension_in} ${generic_restart_file_name_out}_${j4}.${extension_out}
+                elif [ X${Tared} = Xtrue ] ; then
+                  IGCM_sys_Mv ${comp}_${generic_restart_file_name_in}_${j4}.${extension_in} ${generic_restart_file_name_out}_${j4}.${extension_out}
+                fi
+                (( j=j+1 ))                            #BASH LINE NOT NEEDED
+              done
+
+              if [ X${NUM_PROC_OCE} != X ] ; then
+                if [ ${NUM_PROC_OCE} -ne ${nb_restart_file} ] ; then
+                  IGCM_sys_rebuild ${generic_restart_file_name_out}.${extension_out} ${generic_restart_file_name_out}_????.${extension_out}
+                  IGCM_sys_Rm ${generic_restart_file_name_out}_????.${extension_out}
+                fi
+              fi
+            else
+              if [ X${Buffered} = Xtrue ] ; then
+                IGCM_sys_GetBuffer ${Path_r}/${file_in_Name} ${file_out}
+              elif [ X${Archived} = Xtrue ] ; then
+                IGCM_sys_Get ${Path_r}/${file_in_Name} ${file_out}
+              elif [ X${Tared} = Xtrue ] ; then
+                IGCM_sys_Mv ${comp}_${file_in_Name} ${file_out}
+              fi
+            fi
+            (( i=i+3 ))
+          done
+        else
+          if [ X${FileName0} != XNONE ] ; then
+            IGCM_debug_Exit "IGCM_comp_GetInputRestartFiles : No file in list for ${compname}."
+          else
+            IGCM_debug_Print 1 "IGCM_comp_GetInputRestartFiles : NONE specified in Restart List ${compname}."
+          fi
+        fi
+      fi
+    elif ( [ ${Period} -eq 1 ] && [ ${DRYRUN} -eq 0 ] ) ; then
+      # if not FirstInitialize and first loop of this job
+
+      # Restore Restarts files
+      #-----------------------
+      if ( [ X${FileName0} != X${NULL_STR} ] && [ X${FileName0} != XNONE ] ) ; then
+        eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1
+
+        (( i=1 ))
+        until [ $i -gt $NbFiles ]; do
+          eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1
+          eval file_in=${file_in_}
+          (( i_ = i+1 ))
+          eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1
+          eval file_out=${file_out_}
+
+          file_in_Name=${run_Configuration_OldPrefix}_${file_in}
+
+          extension_in=$( echo ${file_in_Name##*.} )
+          extension_out=$( echo ${file_out##*.} )
+
+          generic_restart_file_name_in=$( basename ${file_in_Name} .${extension_in} )
+          generic_restart_file_name_out=$( basename ${file_out} .${extension_out} )
+
+          eval Path_BUF=\${R_BUF_${comp}_R}/${generic_restart_file_name_in}
+          eval Path_OUT=\${R_OUT_${comp}_R}/${generic_restart_file_name_in}
+
+          if [ $( IGCM_sys_TestFileBuffer ${Path_BUF}*.${extension_in} ; echo $? ) = 0 ] ; then
+            IGCM_debug_Print 3 "Buffered restart ${Path_BUF}*.${extension_in}"
+            Buffered=true
+            Archived=false
+            Tared=false
+            nb_restart_file=$(IGCM_sys_CountFileBuffer ${Path_BUF}_????.${extension_in})
+          elif [ $( IGCM_sys_TestFileArchive ${Path_OUT}*.${extension_in} ; echo $? ) = 0 ] ; then
+            IGCM_debug_Print 3 "Archived restart ${Path_OUT}*.${extension_in}"
+            Buffered=false
+            Archived=true
+            Tared=false
+            nb_restart_file=$(IGCM_sys_CountFileArchive ${Path_OUT}_????.${extension_in})
+          else
+            IGCM_debug_Print 3 "No restart file in the buffer nor in the archive directory"
+            IGCM_debug_Print 3 "Restart files will now be searched for in : ${R_SAVE}/RESTART"
+            Buffered=false
+            Archived=false
+            Tared=true
+            # Look after the tar file we want if we did not found it already
+            if [ X${IsMatching} = X ] ; then
+              for PotentialTarFile in $( IGCM_sys_RshArchive "find ${R_SAVE}/RESTART -name "${config_UserChoices_JobName}_*_restart.tar" -print" ) ; do
+                IsMatching=$( echo ${PotentialTarFile##*/} | sed "s:^${config_UserChoices_JobName}_::" | sed "s:\.restart\.tar$::" | gawk -F_ -v restartdate=${LastPeriodDateEnd} '{if (($1 < restartdate) && ($2 >= restartdate)) {print $1"_"$2}}' )
+                if [ ! X${IsMatching} = X ] ; then
+                  TarFileFound=${PotentialTarFile}
+                  break
+                fi
+              done
+            fi
+            IGCM_sys_PrepareTaredRestart ${TarFileFound}
+            TarFileLocation=$( basename ${TarFileFound} )
+            IGCM_debug_Print 1 "tar xvf ${TarFileLocation} ${comp}_${generic_restart_file_name_in}*.${extension_in}"
+            tar xvf ${TarFileLocation} ${comp}_${generic_restart_file_name_in}*.${extension_in}
+            nb_restart_file=$( IGCM_sys_CountFileBuffer ${comp}_${generic_restart_file_name_in}_????.${extension_in} )
+          fi
+
+          if [ ${nb_restart_file} -gt 1 ] ; then
+            j=0                                     # BASH LINE NOT NEEDED
+            #BASH for j4 in in $( eval echo {0000..$(( nb_restart_file - 1 ))} ) ; do
+            until [ $j -ge ${nb_restart_file} ]; do # BASH LINE NOT NEEDED
+              j4=${j}                               # BASH LINE NOT NEEDED
+              if [ X${Buffered} = Xtrue ] ; then
+                IGCM_sys_GetBuffer ${Path_BUF}_${j4}.${extension_in} ${generic_restart_file_name_out}_${j4}.${extension_out}
+              elif [ X${Archived} = Xtrue ] ; then
+                IGCM_sys_Get ${Path_OUT}_${j4}.${extension_in} ${generic_restart_file_name_out}_${j4}.${extension_out}
+              elif [ X${Tared} = Xtrue ] ; then
+                IGCM_sys_Mv ${comp}_${generic_restart_file_name_in}_${j4}.${extension_in} ${generic_restart_file_name_out}_${j4}.${extension_out}
+              fi
+              (( j=j+1 ))                           # BASH LINE NOT NEEDED
+            done
+          else
+            if [ X${Buffered} = Xtrue ] ; then
+              eval IGCM_sys_GetBuffer \${R_BUF_${comp}_R}/${file_in_Name} ${file_out}
+            elif [ X${Archived} = Xtrue ] ; then
+              eval IGCM_sys_Get \${R_OUT_${comp}_R}/${file_in_Name} ${file_out}
+            elif [ X${Tared} = Xtrue ] ; then
+              IGCM_sys_Mv ${comp}_${file_in_Name} ${file_out}
+            fi
+          fi
+          (( i=i+3 ))
+        done
+      else
+        if [ X${FileName0} != XNONE ] ; then
+          IGCM_debug_Exit "IGCM_comp_GetInputRestartFiles : No file in list for ${compname}."
+        else
+          IGCM_debug_Print 1 "IGCM_comp_GetInputRestartFiles : NONE specified in Restart List ${compname}."
+        fi
+      fi
+    fi
+  done
+
+  NbFiles=$( ls * 2> /dev/null | wc -l )
+  if [ ${NbFiles} -gt 0 ] ; then
+    IGCM_sys_Chmod u+rw *
+  fi
+
+  IGCM_debug_PopStack "IGCM_comp_GetInputRestartFiles"
+}
+
+#=======================================================================
+function IGCM_comp_PeriodStart
+{
+  IGCM_debug_PushStack "IGCM_comp_PeriodStart"
+
+  # Debug Print :
+  echo
+  IGCM_debug_Print 1 "IGCM_comp_PeriodStart"
+  echo
+
+  typeset ExeNameIn ExeNameOut
+  typeset comp compname comptagname
+  for comp in ${config_ListOfComponents[*]} ; do
+    # Define component
+    eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1
+    eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1
+
+    # Copy executable for this component
+    eval ExeNameIn=\${config_Executable_${comp}[0]}
+    eval ExeNameOut=\${config_Executable_${comp}[1]}
+
+    # Debug Print
+    IGCM_debug_Print 3 "PeriodStart ${compname} Driver Function (if any)."
+    # UPDATE component
+    ${comp}_PeriodStart 2> /dev/null
+
+  done
+
+  IGCM_debug_PopStack "IGCM_comp_PeriodStart"
+}
+
+#=======================================================================
+function IGCM_comp_Update
+{
+  IGCM_debug_PushStack "IGCM_comp_Update"
+
+    # Debug Print :
+  echo
+  IGCM_debug_Print 1 "IGCM_comp_Update"
+  echo
+
+  typeset ExeNameIn ExeNameOut
+  typeset comp compname comptagname
+  for comp in ${config_ListOfComponents[*]} ; do
+    # Define component
+    eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1
+    eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1
+
+    # Copy executable for this component
+    eval ExeNameIn=\${config_Executable_${comp}[0]}
+    eval ExeNameOut=\${config_Executable_${comp}[1]}
+
+    # If missing executable and DRYRUN is set to 0 or 1  then stop!
+    if [ ${DRYRUN} -le 1 ] && [ X${ExeNameIn} != X\"\" ] &&  [ ! -f ${R_EXE}/${ExeNameIn} ] ; then
+      IGCM_debug_Exit "IGCM_comp_Update missing executable ${ExeNameIn}"
+    fi
+
+    if [ ${Period} -eq 1 ] && [ -f ${R_EXE}/${ExeNameIn} ] ; then
+      eval IGCM_sys_Cp ${R_EXE}/${ExeNameIn} ${ExeNameOut}
+      if [ -f ${RUN_DIR}/${ExeNameOut} ] ; then
+        eval IGCM_sys_Chmod +rx ${RUN_DIR}/${ExeNameOut}
+      fi
+    elif [ -f ${R_EXE}/${ExeNameIn} ] && [ ! -f ${RUN_DIR}/${ExeNameOut} ] ; then
+      eval IGCM_sys_Cp ${R_EXE}/${ExeNameIn} ${ExeNameOut}
+      if [ -f ${RUN_DIR}/${ExeNameOut} ] ; then
+        eval IGCM_sys_Chmod +rx ${RUN_DIR}/${ExeNameOut}
+      fi
+    fi
+
+    # Debug Print
+    IGCM_debug_Print 1 "Update ${compname} Parameter Files."
+    # UPDATE component
+    ${comp}_Update
+
+  done
+
+  IGCM_debug_PopStack "IGCM_comp_Update"
+}
+
+#=======================================================================
+function IGCM_comp_Finalize
+{
+  IGCM_debug_PushStack "IGCM_comp_Finalize"
+
+  # Debug Print :
+  echo
+  IGCM_debug_Print 1 "IGCM_comp_Finalize"
+  echo
+
+  typeset ListTextName TextName0
+  typeset comp compname comptagname card ListFilesName FileName0 NbFiles SaveOnArchive
+  typeset i i_ file_in file_in_ file_out file_out_ file_outin file_outin_ generic_file_name nb_rebuild_file
+  typeset -Z4 j4
+  #BASH declare j4
+  typeset list_file nlist_file
+  typeset compactoutputs
+
+  compactoutputs=false
+  if [ X${JobType} != XRUN ] ; then
+    compactoutputs=true
+  elif [ X${config_UserChoices_CompactText} != Xn ] ; then
+    compactoutputs=true
+  fi
+
+  for comp in ${config_ListOfComponents[*]} ; do
+    # Define component
+    eval compname=\${config_ListOfComponents_${comp}[0]} > /dev/null 2>&1
+    eval comptagname=\${config_ListOfComponents_${comp}[1]} > /dev/null 2>&1
+
+    # Debug Print
+    IGCM_debug_Print 1 "Finalize ${comp} : ${compname} component."
+    # FINALIZE component
+    ${comp}_Finalize
+
+    card=${SUBMIT_DIR}/COMP/${compname}.card
+
+    # Save Output Text files of models
+    #---------------------------------
+    IGCM_debug_Print 2 "Save Output Text files for ${comp} : ${compname} component."
+    IGCM_card_DefineArrayFromOption ${card} OutputText List
+    ListTextName=${compname}_OutputText_List
+
+    eval TextName0=\${${ListTextName}[0]} > /dev/null 2>&1
+    if [ X${TextName0} != X${NULL_STR} ] ; then
+      eval NbFiles=\${#${ListTextName}[@]} > /dev/null 2>&1
+
+      (( i=0 ))
+      until [ $i -eq $NbFiles ]; do
+        eval file_in=\${${ListTextName}[$i]} > /dev/null 2>&1
+        eval file_out=${PREFIX}_${file_in}
+
+        (( i=i+1 ))
+
+        unset list_file
+        #set +A list_file -- $( ls ${file_in}* | sort 2>/dev/null )
+        # result for a a1 a10 a2 with file_in=a a a1 a2 a10
+        set +A list_file -- $( [ -f ${file_in} ] && ls ${file_in} ; for i in $(ls ${file_in}* 2>/dev/null | sed "s/${file_in}//" | sort -n) ; do ls ${file_in}$i ; done )
+        nlist_file=${#list_file[@]}
+        if [ ${nlist_file} -gt 1 ] ; then
+          if ( ${compactoutputs} ) ; then
+            IGCM_debug_Print 2 "Parallelism of Text Output with ${nlist_file} files."
+            IGCM_debug_Print 2 "Compact files in ${file_out} : " ${list_file[*]}
+            echo ${list_file[*]} > ${file_out}
+            echo "
+" >> ${file_out}
+
+            (( i_ = 0 ))
+            for file in ${list_file[@]}
+            do
+              echo "_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ " >> ${file_out}
+              echo "| " ${i_} " " ${file} >> ${file_out}
+              echo "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - " >> ${file_out}
+              cat ${file} | sed "s/\(.*\)/${i_}\1/" ${file} >> ${file_out}
+              echo "
+" >> ${file_out}
+              eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${file}" > /dev/null 2>&1
+                  (( i_ = i_ + 1 ))
+            done
+            if [ X${Pack} = Xtrue ] ; then
+              eval IGCM_sys_PutBuffer_Out ${file_out} \${R_BUF_${comp}_D}/${file_out}
+            else
+              eval IGCM_sys_Put_Out ${file_out} \${R_OUT_${comp}_D}/${file_out}
+            fi
+            eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${file_out}" > /dev/null 2>&1
+
+            if ( ${ExecutionFail} ) ; then
+              IGCM_sys_Cp ${file_out} ${SUBMIT_DIR}/Debug
+            fi
+          else
+            for file in ${list_file[@]}
+            do
+              if [ X${Pack} = Xtrue ] ; then
+                eval IGCM_sys_PutBuffer_Out ${file} \${R_BUF_${comp}_D}/${PREFIX}_${file}
+              else
+                eval IGCM_sys_Put_Out ${file} \${R_OUT_${comp}_D}/${PREFIX}_${file}
+              fi
+              eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${file}" > /dev/null 2>&1
+
+              if ( ${ExecutionFail} ) ; then
+                IGCM_sys_Cp ${file} ${SUBMIT_DIR}/Debug/${PREFIX}_${file}
+              fi
+            done
+          fi
+        else
+          if ( [ -f ${file_in}_0000 ] || [ -f ${file_in}0 ] ) ; then
+            eval IGCM_sys_Mv ${file_in}* ${file_in}
+          fi
+          if [ X${Pack} = Xtrue ] ; then
+            eval IGCM_sys_PutBuffer_Out ${file_in} \${R_BUF_${comp}_D}/${file_out}
+          else
+            eval IGCM_sys_Put_Out ${file_in} \${R_OUT_${comp}_D}/${file_out}
+          fi
+          eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${file_in}" > /dev/null 2>&1
+
+          if ( ${ExecutionFail} ) ; then
+            IGCM_sys_Cp ${file_in} ${SUBMIT_DIR}/Debug/${file_out}
+          fi
+        fi
+      done
+    fi
+
+    # Save Restarts files
+    #--------------------
+    IGCM_debug_Print 2 "Save Restart files for ${comp} : ${compname} component."
+    IGCM_card_DefineArrayFromOption ${card} RestartFiles List
+    ListFilesName=${compname}_RestartFiles_List
+    eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1
+
+    if ( [ X${FileName0} != X${NULL_STR} ] && [ X${FileName0} != XNONE ] ) ; then
+      eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1
+
+      (( i=0 ))
+      until [ $i -ge $NbFiles ]; do
+        eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1
+        eval file_in=${file_in_}
+
+        (( i_ = i+1 ))
+        eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1
+        eval file_out=${file_out_}
+
+        (( i_ = i+2 ))
+        eval file_outin_=\${${ListFilesName}[$i_]} > /dev/null 2>&1
+        eval file_outin=${file_outin_}
+
+        generic_restart_file_name_in=$(    basename ${file_in} .nc )
+        generic_restart_file_name_out=$(   basename ${config_UserChoices_JobName}_${PeriodDateEnd}_${file_out} .nc )
+        generic_restart_file_name_outin=$( basename ${file_outin} .nc )
+
+        nb_restart_file=$( ls ${generic_restart_file_name_in}_????.nc 2>/dev/null | wc -l )
+        if [ ${nb_restart_file} -gt 1 ] ; then
+          j=0                                     # BASH LINE NOT NEEDED
+          # BASH for j4 in in $( eval echo {0000..$(( nb_restart_file - 1 ))} ) ; do
+          until [ $j -ge ${nb_restart_file} ]; do # BASH LINE NOT NEEDED
+            j4=${j}                               # BASH LINE NOT NEEDED
+            if [ X${Pack} = Xtrue ] ; then
+              eval IGCM_sys_PutBuffer_Rest ${generic_restart_file_name_in}_${j4}.nc \${R_BUF_${comp}_R}/${generic_restart_file_name_out}_${j4}.nc
+            else
+              eval IGCM_sys_Put_Rest ${generic_restart_file_name_in}_${j4}.nc \${R_OUT_${comp}_R}/${generic_restart_file_name_out}_${j4}.nc
+            fi
+            if [ ! ${file_in} = ${file_outin} ] ; then
+              if ( ${ExitFlag} ) ; then
+                echo "IGCM_sys_Mv ${generic_restart_file_name_in}_${j4}.nc ${generic_restart_file_name_outin}_${j4}.nc not executed."
+              else
+                IGCM_sys_Mv ${generic_restart_file_name_in}_${j4}.nc ${generic_restart_file_name_outin}_${j4}.nc
+              fi
+            fi
+            (( j=j+1 ))                           # BASH LINE NOT NEEDED
+          done
+        else
+          if [ X${Pack} = Xtrue ] ; then
+            eval IGCM_sys_PutBuffer_Rest ${file_in} \${R_BUF_${comp}_R}/${config_UserChoices_JobName}_${PeriodDateEnd}_${file_out}
+          else
+            eval IGCM_sys_Put_Rest ${file_in} \${R_OUT_${comp}_R}/${config_UserChoices_JobName}_${PeriodDateEnd}_${file_out}
+          fi
+          if [ ! ${file_in} = ${file_outin} ] ; then
+            if ( ${ExitFlag} ) ; then
+              echo "IGCM_sys_Mv ${file_in} ${file_outin} not executed."
+            else
+              IGCM_sys_Mv ${file_in} ${file_outin}
+            fi
+          fi
+        fi
+
+        (( i=i+3 ))
+      done
+    else
+      if [ X${FileName0} != XNONE ] ; then
+        IGCM_debug_Exit "IGCM_comp_Finalize : No file in restart list for ${compname}."
+      else
+        IGCM_debug_Print 1 "IGCM_comp_Finalize : NONE specified in Restart List ${compname}."
+      fi
+    fi
+
+    # Save Output files
+    #------------------
+    IGCM_debug_Print 2 "Save Output files for ${comp} : ${compname} component."
+    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
+      eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1
+
+      (( i=0 ))
+      until [ $i -ge $NbFiles ]; do
+        SaveOnArchive=true
+        eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1
+        eval file_in=${file_in_}
+        (( i_ = i+1 ))
+        eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1
+        eval file_out=${file_out_}
+        #
+        # Override file_out path remplacing R_SAVE by R_BUFR
+        #
+        if [ X${Pack} = Xtrue ] ; then
+          file_out=$( echo $file_out | sed "s:^$R_SAVE:$R_BUFR:" )
+        fi
+        #
+        # Not necessarily the best option. /!\ Potential side effects /!\
+        #
+        (( i_ = i+2 ))
+        eval flag_post=\${${ListFilesName}[$i_]} > /dev/null 2>&1
+        #
+        generic_file_name=$( basename ${file_in} .nc )
+        nb_rebuild_file=$( ls | grep "^${generic_file_name}_[0-9]*.nc" | wc -l )
+        #
+        if ( [ ${nb_rebuild_file} -eq 1 ] && [ -f ${generic_file_name}_0000.nc ] ) ; then
+          IGCM_debug_Print 2 "Parallelism with 1 file. Rebuilding ${file_in} not needed"
+          IGCM_sys_Mv ${generic_file_name}_0000.nc ${file_in}
+        elif [ ${nb_rebuild_file} -gt 1 ] ; then
+          IGCM_debug_Print 2 "Parallelism detected and rebuilding ${file_in} is needed"
+          if [ X${AsynchronousRebuild} = Xfalse ] ; then
+            IGCM_debug_Print 2 "Rebuilding ${file_in} online"
+            IGCM_sys_rebuild ${file_in} ${generic_file_name}_[0-9]*.nc
+          else
+            IGCM_debug_Print 2 "Preparing offline rebuild for ${file_in}"
+            [ ! -d ${RUN_DIR}/REBUILD_${PeriodDateBegin} ] && IGCM_sys_Mkdir ${RUN_DIR}/REBUILD_${PeriodDateBegin}
+            IGCM_sys_Mv ${generic_file_name}_[0-9]*.nc ${RUN_DIR}/REBUILD_${PeriodDateBegin}
+
+            # Prepare headers for the shell dedicated to offline rebuild
+            if [ ! -f ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh ] ; then
+              if [ $DRYRUN -le 1 ]; 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 "export R_SAVE=${R_SAVE}                           " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+                echo "export R_BUFR=${R_BUFR}                           " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+                echo "export R_OUT_KSH=${R_OUT_KSH}                     " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+                echo "export R_BUF_KSH=${R_BUF_KSH}                     " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+                echo "export config_UserChoices_JobName=${config_UserChoices_JobName}     " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+                echo "export config_UserChoices_SpaceName=${config_UserChoices_SpaceName} " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+              fi
+            fi
+            # Prepare the shell dedicated to offline rebuild
+            if [ $DRYRUN -le 1 ]; then
+              if [ ${file_in} = histstn.nc ] ; then
+                echo "IGCM_sys_rebuild_station ${file_in} ${generic_file_name}_*.nc" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+              else
+                echo "IGCM_sys_rebuild ${file_in} ${generic_file_name}_[0-9]*.nc" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+              fi
+              echo "IGCM_debug_Verif_Exit_Post" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+            fi
+            #
+            # Load Patch we need to apply and apply
+            if [ $DRYRUN -le 1 ]; then
+              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
+                  echo "IGCM_debug_Verif_Exit_Post                      " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+                done
+              fi
+            fi
+            #
+            if [ $DRYRUN -le 1 ]; then
+              if [ X${Pack} = Xtrue ] ; then
+                echo "IGCM_sys_PutBuffer_Out ${file_in} ${file_out}     " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+              else
+                echo "IGCM_sys_Put_Out ${file_in} ${file_out}           " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+              fi
+              echo "IGCM_debug_Verif_Exit_Post                          " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+              echo "IGCM_sys_Rm ${generic_file_name}_[0-9]*.nc          " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+            fi
+            SaveOnArchive=false
+          fi
+        fi
+        #
+        if [ ${SaveOnArchive} = true ] ; then
+          #
+          # Rebuild has been done online or it was not needed
+          #
+          # If we need to apply a patch we use TMP DIRECTORY before ARCHIVING if asynchronous rebuild is on
+          #
+          thereisapatch=$( eval echo \${${compname}_${flag_post}_Patches[0]} )
+          if ( [ ! X${thereisapatch} = X${NULL_STR} ] && [ X${AsynchronousRebuild} = Xtrue ] && [ -f ${file_in} ] ) ; then
+            [ ! -d ${RUN_DIR}/REBUILD_${PeriodDateBegin} ] && IGCM_sys_Mkdir ${RUN_DIR}/REBUILD_${PeriodDateBegin}
+            IGCM_sys_Mv ${file_in} ${RUN_DIR}/REBUILD_${PeriodDateBegin}
+            eval FileToBeDeleted[${#FileToBeDeleted[@]}]=REBUILD_${PeriodDateBegin}/${file_in} > /dev/null 2>&1
+            #
+            if [ $DRYRUN -le 1 ]; then
+              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 "export R_SAVE=${R_SAVE}                         " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+                echo "export config_UserChoices_JobName=${config_UserChoices_JobName} " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+              fi
+              #
+              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
+                echo "IGCM_debug_Verif_Exit_Post                      " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+              done
+              #
+              if [ X${Pack} = Xtrue ] ; then
+                echo "IGCM_sys_PutBuffer_Out ${file_in} ${file_out}   " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+              else
+                echo "IGCM_sys_Put_Out ${file_in} ${file_out}         " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+              fi
+              echo "IGCM_debug_Verif_Exit_Post                        " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+              #
+            fi
+          else
+            #
+            # No Patch, No Asynchronous rebuild, online rebuild has been done or was not needed
+            #
+            if [ X${Pack} = Xtrue ] ; then
+              IGCM_sys_PutBuffer_Out ${file_in} ${file_out}
+            else
+              IGCM_sys_Put_Out ${file_in} ${file_out}
+            fi
+            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
+        (( i=i+3 ))
+      done
+    fi
+    echo
+  done
+  IGCM_debug_PopStack "IGCM_comp_Finalize"
+}
Index: /tags/libIGCM_v2.2/libIGCM_config/libIGCM_config.ksh
===================================================================
--- /tags/libIGCM_v2.2/libIGCM_config/libIGCM_config.ksh	(revision 998)
+++ /tags/libIGCM_v2.2/libIGCM_config/libIGCM_config.ksh	(revision 998)
@@ -0,0 +1,1327 @@
+#!/bin/ksh
+
+#**************************************************************
+# Author: Sebastien Denvil, Martial Mancip
+# Contact: Sebastien.Denvil__at__ipsl.jussieu.fr Martial.Mancip__at__ipsl.jussieu.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#===================================
+function IGCM_config_CommonConfiguration
+{
+  IGCM_debug_PushStack "IGCM_config_CommonConfiguration" $@
+
+  # Debug Print :
+  [ ${Verbosity} -gt 0 ] && echo
+  IGCM_debug_Print 1 "IGCM_config_CommonConfiguration" $@
+
+  # config.card path
+  configPath=$1
+
+  #==================================
+  typeset option auxprint CompatibilityTag
+
+  #==================================
+  # Read libIGCM compatibility version in config.card
+  IGCM_card_DefineVariableFromOption ${configPath} Compatibility libIGCM
+  CompatibilityTag=${config_Compatibility_libIGCM}
+
+  if [ ! "${CompatibilityTag}" = "${libIGCM_CurrentTag}" ] ; then
+    IGCM_debug_Exit "config.card is not compatible with libIGCM version ${libIGCM_CurrentTag} see libIGCM FAQ http://wiki.ipsl.jussieu.fr/wiki_ipsl/IGCMG/libIGCM/DocUtilisateur/FAQ ."
+  fi
+
+  #==================================
+  # Read UserChoices section:
+  [ ${Verbosity} -gt 0 ] && echo
+  IGCM_debug_Print 1 "DefineArrayFromOption  : config_UserChoices"
+
+  IGCM_card_DefineArrayFromSection ${configPath} UserChoices
+  for option in ${config_UserChoices[*]} ; do
+    IGCM_card_DefineVariableFromOption ${configPath} UserChoices ${option}
+    eval auxprint=\${config_UserChoices_${option}}
+    IGCM_debug_Print 3 "${option} : ${auxprint}"
+  done
+
+  #==================================
+  # Read Ensemble section:
+  [ ${Verbosity} -gt 0 ] && echo
+  IGCM_debug_Print 1 "DefineArrayFromOption  : config_Ensemble"
+
+  IGCM_card_DefineArrayFromSection ${configPath} Ensemble
+  for option in ${config_Ensemble[*]} ; do
+    IGCM_card_DefineVariableFromOption ${configPath} Ensemble ${option}
+    eval auxprint=\${config_Ensemble_${option}}
+    IGCM_debug_Print 3 "${option} : ${auxprint}"
+  done
+
+  #==================================
+  # Read Post section:
+  [ ${Verbosity} -gt 0 ] && echo
+  IGCM_debug_Print 1 "DefineArrayFromOption : config_Post"
+
+  IGCM_card_DefineArrayFromSection ${configPath} Post
+  for option in ${config_Post[*]} ; do
+    IGCM_card_DefineVariableFromOption ${configPath} Post ${option}
+    eval auxprint=\${config_Post_${option}}
+    IGCM_debug_Print 3 "${option} : ${auxprint}"
+  done
+  [ ${Verbosity} -gt 0 ] && echo
+
+  #==================================
+  # Define default value to keep compatibility with previous card: means before changes due to TGCC
+  # Apply some overrules to ensure proper usage of computing centres resources
+  #
+  if [ X${PackDefault} = Xtrue ] ; then
+    # If we DO apply pack in this computing center
+    IGCM_debug_Print 1 "Due to inodes policy OVERRULE RebuildFromArchive value to NONE"
+    config_Post_RebuildFromArchive=NONE
+    if [ X${config_UserChoices_SpaceName} = XTEST ]; then
+      # TEST simulations will not be packed and will stay on SCRATCHDIR filesystem
+      IGCM_debug_Print 1 "SpaceName=TEST. OVERRULE PackFrequency to NONE"
+      IGCM_debug_Print 1 "SpaceName=TEST. OVERRULE destination path directories"
+      config_Post_PackFrequency=NONE
+      IGCM_sys_ChangeArchive
+    else
+      # Default to RebuildFrequency if nothing has been set up related to PackFrequency
+      [ X${config_Post_PackFrequency} = X ] && config_Post_PackFrequency=${config_Post_RebuildFrequency}
+    fi
+  else
+    # If we DO NOT apply pack in this computing center
+    config_Post_PackFrequency=NONE
+  fi
+
+  #====================================================
+  # R_SAVE : Job output directory
+  # R_BUFR : Job output buffered directory
+
+  if ( [ ! X${config_UserChoices_SpaceName} = X ] && [ ! X${config_UserChoices_ExperimentName} = X ] ) ; then
+    FreeName=$( echo ${config_UserChoices_JobName} | sed 's/.*_//' )
+    if ( [ ! X${config_Ensemble_EnsembleName} = X ] && [ ! X${config_Ensemble_EnsembleDate} = X ] ) ; then
+      R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${config_Ensemble_EnsembleName}/${config_Ensemble_EnsembleDate}/${FreeName}
+      R_FIGR=${R_FIG}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${config_Ensemble_EnsembleName}/${config_Ensemble_EnsembleDate}/${FreeName}
+      R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${config_Ensemble_EnsembleName}/${config_Ensemble_EnsembleDate}/${FreeName}
+      R_DODS=${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${config_Ensemble_EnsembleName}/${config_Ensemble_EnsembleDate}/${FreeName}
+    else
+      R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName}
+      R_FIGR=${R_FIG}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName}
+      R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName}
+      R_DODS=${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName}
+    fi
+  else
+    if ( [ ! X${config_Ensemble_EnsembleName} = X ] && [ ! X${config_Ensemble_EnsembleDate} = X ] ) ; then
+      R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_Ensemble_EnsembleName}/${config_Ensemble_EnsembleDate}/${config_UserChoices_JobName}
+      R_FIGR=${R_FIG}/${config_UserChoices_TagName}/${config_Ensemble_EnsembleName}/${config_Ensemble_EnsembleDate}/${config_UserChoices_JobName}
+      R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_Ensemble_EnsembleName}/${config_Ensemble_EnsembleDate}/${config_UserChoices_JobName}
+      R_DODS=${config_UserChoices_TagName}/${config_Ensemble_EnsembleName}/${config_Ensemble_EnsembleDate}/${config_UserChoices_JobName}
+    else
+      R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName}
+      R_FIGR=${R_FIG}/${config_UserChoices_TagName}/${config_UserChoices_JobName}
+      R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_JobName}
+      R_DODS=${config_UserChoices_TagName}/${config_UserChoices_JobName}
+    fi
+  fi
+
+  #====================================================
+  # Define REBUILD_DIR : where we store files needing rebuild process
+  if [ X${config_Post_RebuildFromArchive} = Xtrue ] ; then
+    REBUILD_DIR=${R_SAVE}/REBUILD
+    if [ ! X${TaskType} = Xchecking ] ; then
+      IGCM_sys_MkdirArchive ${REBUILD_DIR}
+    fi
+  else
+    REBUILD_DIR=${R_BUFR}/REBUILD
+    if [ ! X${TaskType} = Xchecking ] ; then
+      IGCM_sys_MkdirWork ${REBUILD_DIR}
+    fi
+  fi
+
+  #====================================================
+  # DodsCopy : apply default value if not defined
+  if ( [ X${config_Post_DodsCopy} = X${NULL_STR} ] || [ X${config_Post_DodsCopy} = X ] ) ; then
+    config_Post_DodsCopy=TRUE
+  fi
+
+  IGCM_debug_PopStack "IGCM_config_CommonConfiguration"
+}
+
+#===================================
+function IGCM_config_Initialize
+{
+  IGCM_debug_PushStack "IGCM_config_Initialize"
+
+  # Debug Print :
+  echo
+  IGCM_debug_Print 1 "IGCM_config_Initialize"
+
+  if [ ! -r ${SUBMIT_DIR}/run.card ] ; then
+    #================================================#
+    #         The file run.card doesn't exist        #
+    #================================================#
+    FirstInitialize=true
+    #copy initial run.card
+    IGCM_sys_Cp ${SUBMIT_DIR}/run.card.init ${SUBMIT_DIR}/run.card
+    IGCM_debug_Print 2 "run.card copied from run.card.init"
+  else
+    FirstInitialize=false
+    IGCM_debug_Print 2 "run.card exists"
+  fi
+
+  # Test modipsl tree existence.
+  IGCM_sys_TestDir ${MODIPSL}
+  [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDir"
+  IGCM_sys_TestDir ${libIGCM}
+  [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDir"
+  IGCM_sys_TestDir ${R_EXE}
+  [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDir"
+  IGCM_sys_TestDir ${SUBMIT_DIR}
+  [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDir"
+
+  if ( $DEBUG_debug ) ; then
+    echo "Keep trace of inital SUBMIT_DIR : "
+    ls -lta ${SUBMIT_DIR}
+  fi
+
+  #==================================
+  # Read libIGCM compatibility version in config.card
+  # Read UserChoices section
+  # Read Ensemble section
+  # Read Post section
+  # Define all netcdf output directories
+  #==================================
+  IGCM_config_CommonConfiguration ${SUBMIT_DIR}/config.card
+
+  #==================================
+  # Read ListOfComponents section:
+  echo
+  IGCM_debug_Print 1 "DefineArrayFromSection : ListOfComponents"
+
+  IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card ListOfComponents
+  for comp in ${config_ListOfComponents[*]} ; do
+    IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/config.card ListOfComponents ${comp}
+  done
+  IGCM_debug_Print 3 ${config_ListOfComponents[*]}
+
+  #==================================
+  # Read Executable section:
+  IGCM_card_DefineArrayFromSection   ${SUBMIT_DIR}/config.card Executable
+
+  #==================================
+  # Read Restarts section:
+  # Restarts : Gerneral rule or local for each component.
+  echo
+  IGCM_debug_Print 1 "DefineArrayFromOption : config_Restarts"
+
+  IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card Restarts
+  for option in ${config_Restarts[*]} ; do
+    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card Restarts ${option}
+    eval auxprint=\${config_Restarts_${option}}
+    IGCM_debug_Print 3 "${option} : ${auxprint}"
+  done
+
+  #==================================
+  # Define Job Outputs Name
+  echo
+  IGCM_debug_Print 2 "Define Script_Output_Prefix and Exe_Output"
+  Script_Output_Prefix=${config_UserChoices_Script_Output_Prefix:='Script_Output'}
+  IGCM_debug_Print 3 "Script_Output_Prefix = ${Script_Output_Prefix}"
+  Exe_Output=out_execution
+  IGCM_debug_Print 3 "Exe_Output           = ${Exe_Output}"
+
+  #===================================================================#
+  # Prepare variables available for ${COMP}.card and ${COMP}.driver   #
+  #             But available to any son functions                    #
+  #===================================================================#
+
+  # Convert yyyy-mm-dd date to gregorian yyyymmdd
+  DateBegin=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateBegin} )
+  DateEnd=$(   IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd}   )
+
+  # Period Length In Days between DateBegin and DateEnd
+  (( ExperienceLengthInDays=$( IGCM_date_DaysBetweenGregorianDate ${DateEnd} ${DateBegin} )  + 1 ))
+  if [ ${ExperienceLengthInDays} -lt 0 ] ; then
+    IGCM_debug_Print 1 "Problem with dates in config.card : ${DateEnd} < ${DateBegin} ! You must check that."
+    IGCM_debug_Exit "IGCM_config_Initialize" " Wrong Dates."
+    IGCM_debug_Verif_Exit
+  fi
+
+  # Day and Year of Initial State (Given in julian format)
+  InitDay=$(( $( IGCM_date_ConvertGregorianDateToJulian $DateBegin ) % 1000 ))
+  InitYear=$(( $( IGCM_date_ConvertGregorianDateToJulian $DateBegin ) / 1000 ))
+
+  #================================================================#
+  #                  Test and Prepare directories                  #
+  #================================================================#
+
+  # ==> 4 kinds of input files :
+  #     1) R_INIT  : Initial State Files   (Etat0, carteveg)
+  #     2) R_BC    : Boundary Conditions   (Forcages, lai)
+  #     3) Parameters files (allready define through ${SUBMIT_DIR})
+  #     4) Restarts files   (allready define in IGCM_config_Initialize)
+
+  # Here we offer the possibility to redefine R_INIT, R_BC
+  # and PeriodNb through config.card
+  R_INIT=${config_UserChoices_R_INIT:=${R_IN}/INIT}
+  echo
+  IGCM_debug_Print 2 "(Re)Define R_INIT, R_BC and PeriodNb"
+  IGCM_debug_Print 3 "R_INIT=${R_INIT}"
+  R_BC=${config_UserChoices_R_BC:=${R_IN}/BC}
+  IGCM_debug_Print 3  "R_BC=${R_BC}"
+  PeriodNb=${config_UserChoices_PeriodNb:=${PeriodNb}}
+  IGCM_debug_Print 3  "Loop in main Job with ${PeriodNb} period(s)"
+
+  # Test Archive input/output.
+  echo
+  IGCM_sys_TestDirArchive ${ARCHIVE}
+  [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive"
+
+  # SD ADA SPECIFIC #
+  #      TO FIX     #
+  #IGCM_sys_TestDirArchive ${R_IN}
+  #[ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive"
+
+  if ( ${FirstInitialize} ) ; then
+    IGCM_sys_MkdirArchive   ${R_SAVE}
+    [ ! ${config_Post_PackFrequency} = NONE ] && IGCM_sys_Mkdir ${R_BUFR}
+  else
+    IGCM_sys_TestDirArchive ${R_SAVE}
+    [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive ${R_SAVE}"
+
+    if [ ! ${config_Post_PackFrequency} = NONE ] ; then
+      IGCM_sys_TestDir ${R_BUFR}
+      [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDir ${R_BUFR}"
+    fi
+
+    #Test state of run in run.card
+    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState
+
+    if ( [ ${run_Configuration_PeriodState} != "Start" ] && [ ${run_Configuration_PeriodState} != "Running" ] && [ ${run_Configuration_PeriodState} != "OnQueue" ] && [ ${run_Configuration_PeriodState} != "Continue" ] ) ; then
+      echo
+      IGCM_debug_Print 1 "!! Error in run.card with PeriodState : " ${run_Configuration_PeriodState} "!!"
+      IGCM_debug_Print 1 "Check post-processing jobs carefully by running ${libIGCM}/RunChecker.job -p ${SUBMIT_DIR}"
+      IGCM_debug_Print 1 "Then try running ${libIGCM}/clean_month.job to rerun one period"
+      IGCM_debug_Print 1 "Then try running ${libIGCM}/clean_year.job to rerun more."
+      IGCM_debug_Exit
+      IGCM_debug_Verif_Exit
+    fi
+  fi
+
+  #====================================================
+  # Experience type : DEB(ug), DEV(elopment), RUN
+  if [ X${JobType} != XRUN ] ; then
+    echo
+    echo "===================================================="
+    echo "libIGCM JOB is NOT in RUN type mode."
+    echo "!! OUTPUT files will NOT be PROTECTED !!"
+    echo "Be carefull : you can ERASE the result of this job !"
+
+    case ${JobType} in
+    DEB)
+      echo "DEBUG mode : activation of 'set -vx' mode."
+      echo "DEBUG mode : no protection for output files."
+      echo "DEBUG mode : if active force asynchronous rebuild frequency to PeriodLength frequency."
+      ;;
+    DEV)
+      echo "DEVelopment mode : no protection for output files."
+      echo "DEVelopment mode : if active force asynchronous rebuild frequency to PeriodLength frequency."
+      ;;
+    esac
+
+    if ( [ X${config_Post_RebuildFrequency} != XNONE ] && [ ${DRYRUN} -eq 0 ] ) ; then
+      if [ X${config_Post_RebuildFrequency} != X${config_UserChoices_PeriodLength} ] ; then
+        echo "------------"
+        echo "WARNING : Job is NOT in RUN mode then we will force REBUILD Frequency"
+        echo "          to PeriodLength : ${config_UserChoices_PeriodLength}"
+        echo "------------"
+        config_Post_RebuildFrequency=${config_UserChoices_PeriodLength}
+      fi
+    fi
+    echo "===================================================="
+    echo
+  fi
+
+  #====================================================
+  #R_OUT_KSH : Storage place for job output
+  #R_OUT_EXE : Storage place for binary used during simulation
+  R_OUT_KSH=${R_SAVE}/Out
+  R_OUT_EXE=${R_SAVE}/Exe
+
+  #====================================================
+  #R_BUF_KSH : Buffer place for job output
+  #R_BUF_EXE : Buffer place for binary used during simulation
+  R_BUF_KSH=${R_BUFR}/Out
+  R_BUF_EXE=${R_BUFR}/Exe
+
+  IGCM_debug_PopStack "IGCM_config_Initialize"
+}
+
+#===================================
+function IGCM_config_DaysInPeriodLength
+{
+  IGCM_debug_PushStack "IGCM_config_DaysInPeriodLength"
+
+  typeset i
+
+  # Determine number of day(s) in PeriodLength :
+  case ${config_UserChoices_PeriodLength} in
+  *Y|*y)
+    PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | sed -e 's/[yY]//' )
+    echo
+    IGCM_debug_Print 2 "Number of years for PeriodLength : ${PeriodLengthInYears}"
+    PeriodLengthInDays=0
+    i=0
+    until [ $i -ge $PeriodLengthInYears ] ; do
+      (( PeriodLengthInDays = PeriodLengthInDays + $( IGCM_date_DaysInYear $(( year + i )) ) ))
+      (( i=i+1 ))
+    done
+    ;;
+  *M|*m)
+    PeriodLengthInMonths=$( echo ${config_UserChoices_PeriodLength} | sed -e 's/[mM]//' )
+    echo
+    IGCM_debug_Print 2 "Number of months for PeriodLength : ${PeriodLengthInMonths}"
+    PeriodLengthInDays=0
+    i=0
+    until [ $i -ge $PeriodLengthInMonths ] ; do
+      if [ $(( 10#${month} + ${i} )) -lt 13 ] ; then
+        (( PeriodLengthInDays  = PeriodLengthInDays + $( IGCM_date_DaysInMonth $year $(( 10#${month} + ${i} )) ) ))
+      else
+        (( PeriodLengthInDays  = PeriodLengthInDays + $( IGCM_date_DaysInMonth $year $(( 10#${month} + ${i} - 12 )) ) ))
+      fi
+      (( i=i+1 ))
+    done
+    ;;
+  *D|*d)
+    PeriodLengthInMonths=0
+    PeriodLengthInDays=$( echo ${config_UserChoices_PeriodLength} | sed -e 's/[dD]//' )
+    echo
+    IGCM_debug_Print 2 "Number of days for PeriodLength : ${PeriodLengthInDays}";;
+  *)
+    IGCM_debug_Exit "IGCM_config_DaysInPeriodLength " ${config_UserChoices_PeriodLength} " invalid period length : choose in *Y, *M, *D."
+    IGCM_debug_Verif_Exit ;;
+  esac
+
+  IGCM_debug_PopStack "IGCM_config_DaysInPeriodLength"
+}
+
+#===================================
+function IGCM_config_DateCoherency
+{
+  IGCM_debug_PushStack "IGCM_config_DateCoherency"
+
+  echo
+  IGCM_debug_Print 1 "IGCM_config_DateCoherency"
+  echo
+
+  typeset Length VerifiedPeriodDateBegin VerifiedPeriodDateEnd
+
+  # check coherency between (PeriodDateBegin, PeriodDateEnd) and (DateBegin, CumulPeriod, PeriodLength)
+  # DateBegin + CumulPeriod*PeriodLength = PeriodDateBegin
+  echo
+
+  case ${config_UserChoices_PeriodLength} in
+  *Y|*y)
+    Length=$( IGCM_date_DaysInCurrentPeriod ${DateBegin} $(( ${CumulPeriod} * ${PeriodLengthInYears} ))Y )
+    ;;
+  *M|*m)
+    Length=$( IGCM_date_DaysInCurrentPeriod ${DateBegin} $(( ${CumulPeriod} * ${PeriodLengthInMonths} ))M )
+    ;;
+  *D|*d)
+    Length=$( IGCM_date_DaysInCurrentPeriod ${DateBegin} $(( ${CumulPeriod} * ${PeriodLengthInDays} ))D )
+    ;;
+  esac
+  VerifiedPeriodDateEnd=$( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${Length}-1 )
+
+  if [ ${VerifiedPeriodDateEnd} != ${PeriodDateEnd} ] ; then
+    IGCM_debug_Print 1 "From run.card PeriodDateEnd is not consistent with DateBegin and CumulPeriod."
+    IGCM_debug_Print 1 "We have DateBegin = ${DateBegin}"
+    IGCM_debug_Print 1 "We have CumulPeriod = ${CumulPeriod}"
+    IGCM_debug_Print 1 "We have PeriodDateEnd = ${PeriodDateEnd}"
+    IGCM_debug_Print 1 "We have VerifiedPeriodDateEnd = ${VerifiedPeriodDateEnd}"
+    IGCM_debug_Print 1 "You must have change run.card in an inconsistent way."
+
+    IGCM_debug_Exit "STOP here to avoid further issues."
+  fi
+
+  # PeriodDateBegin + PeriodLength = PeriodDateEnd
+  VerifiedPeriodDateBegin=$( IGCM_date_AddDaysToGregorianDate ${VerifiedPeriodDateEnd} $(( ${PeriodLengthInDays} * -1 )) )
+
+  IGCM_debug_PopStack "IGCM_config_DateCoherency"
+}
+
+
+#===================================
+function IGCM_config_Check
+{
+  IGCM_debug_PushStack "IGCM_config_Check"
+
+  # If one of the following modulo is not zero :
+  # we will issue an error then explain and exit in
+  # AA_job IGCM_debug_Verif_Exit call before binary submission
+
+  echo
+  IGCM_debug_Print 1 "IGCM_config_Check"
+  echo
+
+  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
+    IGCM_debug_Print 1 "Asynchronous rebuild has been activated."
+    echo
+    # modulo (RebuildFrequency and PeriodLength/TimeSeriesFrequency/SeasonalFrequency) must be zero
+    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
+    IGCM_debug_Print 1 "Check coherence between SeasonalFrequency and RebuildFrequency"
+    IGCM_post_CheckModuloFrequency config_Post_SeasonalFrequency config_Post_RebuildFrequency
+  else
+    AsynchronousRebuild=false
+    IGCM_debug_Print 1 "Asynchronous rebuild has not been activated"
+    IGCM_debug_Print 1 "Proceed with standard post-treatment pathway"
+    echo
+    #modulo (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
+
+  # modulo (TimeSeriesFrequency and all Chunck2D) must be zero
+  NbJob=${#CHUNCK2D_SIZE[@]}
+  i=0
+  until [ $i -ge $NbJob ]; do
+    value=${CHUNCK2D_SIZE[${i}]}
+    IGCM_debug_Print 1 "Check coherence between All Chunck2D frequency and TimeSeriesFrequency"
+    IGCM_post_CheckModuloFrequency value config_Post_TimeSeriesFrequency
+    case ${value} in
+    *Y|*y) ;;
+    *)
+      IGCM_debug_Print 1 "All ChunckJob2D frequency must be expressed in year *Y|*y in comp.card"
+      IGCM_debug_Exit "This will stop the job" ;;
+    esac
+    (( i=i+1 ))
+  done
+
+  # modulo (TimeSeriesFrequency and all Chunck3D) must be zero
+  NbJob=${#CHUNCK3D_SIZE[@]}
+  i=0
+  until [ $i -ge $NbJob ]; do
+    value=${CHUNCK3D_SIZE[${i}]}
+    IGCM_debug_Print 1 "Check coherence between All Chunck3D frequency and TimeSeriesFrequency"
+    IGCM_post_CheckModuloFrequency value config_Post_TimeSeriesFrequency
+    case ${value} in
+    *Y|*y) ;;
+    *)
+      IGCM_debug_Print 1 "All ChunckJob3D frequency must be expressed in year *Y|*y in comp.card"
+      IGCM_debug_Exit "This will stop the job" ;;
+    esac
+    (( i=i+1 ))
+  done
+
+  # check to be sure there is enough space on temporary filesystems to run
+  echo
+  IGCM_debug_Print 1 "Check if there is enough space on temporary filesystem"
+  IGCM_sys_check_quota
+
+  # check to be sure that RUN_DIR_PATH, that will be removed is not pointing to an important directory
+  echo
+  IGCM_debug_Print 1 "Check where RUN_DIR_PATH variable is pointing to"
+  IGCM_sys_check_path
+
+
+  IGCM_debug_PopStack "IGCM_config_Check"
+}
+
+#===================================
+function IGCM_config_PeriodStart
+{
+  IGCM_debug_PushStack "IGCM_config_PeriodStart"
+
+  echo
+  IGCM_debug_Print 1 "IGCM_config_PeriodStart"
+  echo
+
+  if ( ${FirstInitialize} ) ; then
+    #================================================#
+    #         Initialize date/period information     #
+    #================================================#
+
+    IGCM_date_GetYearMonthDay ${DateBegin} year month day
+    IGCM_config_DaysInPeriodLength
+
+    PeriodDateBegin=${DateBegin}
+    PeriodDateEnd=$( IGCM_date_AddDaysToGregorianDate ${DateBegin} $(( ${PeriodLengthInDays} - 1 )) )
+    CumulPeriod=1
+
+    #=================================================#
+    #              Write updated run.card             #
+    #=================================================#
+
+    #Correct run.card Configuration for this period
+    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin ${PeriodDateBegin}
+    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd ${PeriodDateEnd}
+    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod ${CumulPeriod}
+    if [ X$( grep "SubmitPath" ${SUBMIT_DIR}/run.card ) != X ] ; then
+      IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration SubmitPath ${SUBMIT_DIR}
+    fi
+
+    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Running"
+
+  else
+    #================================================#
+    #         The file run.card allready exist       #
+    #================================================#
+
+    #Test state of run in run.card
+    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState
+    if ( [ ${run_Configuration_PeriodState} != "Running" ] && [ ${run_Configuration_PeriodState} != "OnQueue" ] && [ ${run_Configuration_PeriodState} != "Continue" ] ) ; then
+      echo
+      IGCM_debug_Print 1 "!! Error in run.card with PeriodState : " ${run_Configuration_PeriodState} "!!"
+      IGCM_debug_Print 1 "Try running ${libIGCM}/clean_month.job to fix this"
+      echo
+      IGCM_debug_Exit
+      IGCM_debug_Verif_Exit
+    fi
+
+    #===================================#
+    #        Read updated run.card      #
+    #===================================#
+
+    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration OldPrefix
+    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin
+    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd
+    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod
+
+    PeriodDateBegin=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateBegin} )
+    PeriodDateEnd=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateEnd} )
+    CumulPeriod=${run_Configuration_CumulPeriod}
+
+    LastPeriodDateEnd=$( echo ${run_Configuration_OldPrefix} | sed -e "s/${config_UserChoices_JobName}_//" )
+
+    if [ ${Period} = 1 ]; then
+      # save last Job output and current run.card
+      typeset Potential
+      IGCM_sys_Cd ${SUBMIT_DIR}
+      #
+      IGCM_debug_Print 2 "Save previous ksh job output"
+      for Potential in $( ls ${Script_Output_Prefix}_${config_UserChoices_JobName}.[0-9][0-9][0-9][0-9][0-9][0-9] ) ; do
+        if [ X${Pack} = Xtrue ] ; then
+          ( IGCM_sys_TestFileBuffer  ${R_BUF_KSH}/${Potential} ) || IGCM_sys_PutBuffer_Out ${Potential} ${R_BUF_KSH}/${Potential}.$$ rw
+        else
+          ( IGCM_sys_TestFileArchive ${R_OUT_KSH}/${Potential} ) || IGCM_sys_Put_Out ${Potential} ${R_OUT_KSH}/${Potential}.$$ rw
+        fi
+      done
+      #
+      IGCM_debug_Print 2 "Save current run.card"
+      IGCM_card_CheckConflict run.card
+      if [ X${Pack} = Xtrue ] ; then
+        IGCM_sys_PutBuffer_Out ${SUBMIT_DIR}/run.card ${R_BUF_KSH}/run.card rw
+      else
+        IGCM_sys_Put_Out ${SUBMIT_DIR}/run.card ${R_OUT_KSH}/run.card rw
+      fi
+      #
+      IGCM_sys_Cd ${RUN_DIR}
+    else
+      unset FileToBeDeleted
+    fi
+
+    # Determine number of day(s) in PeriodLength
+    IGCM_date_GetYearMonthDay $PeriodDateBegin year month day
+    IGCM_config_DaysInPeriodLength
+
+    # Check coherency between (PeriodDateBegin, PeriodDateEnd) and (DateBegin, CumulPeriod, PeriodLength)
+    IGCM_config_DateCoherency
+    # And EXIT if not OK
+    IGCM_debug_Verif_Exit
+
+    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Running"
+  fi
+
+  # Save for futur use
+  OldPrefix=${config_UserChoices_JobName}_${PeriodDateEnd}
+
+  # BEGIN: SHOULD GO IN A FUNCTION FROM libIGCM_date.ksh
+  # Compute year_m1 and year_p1 (year minus 1Y and year plus 1Y)
+  year_m1=$(( year - 1 ))
+  year_p1=$(( year + 1 ))
+  # Compute month_m1 (month minus 1M)
+  # Compute yyyymm_m1 (yyyymm minus 1M)
+  month_m1=$(( 10#${month} - 1 ))
+  if [ ${month_m1} = 0 ]; then
+    month_m1=12
+    yyyymm_m1=${year_m1}12
+  elif [ ${month_m1} -le 9 ]; then
+    month_m1=0${month_m1}
+    yyyymm_m1=${year}${month_m1}
+  else
+    yyyymm_m1=${year}${month_m1}
+  fi
+  # Compute month_p1 (month plus 1M)
+  # Compute yyyymm_p1 (yyyymm plus 1M)
+  month_p1=$(( 10#${month} + 1 ))
+  if [ ${month_p1} = 13 ]; then
+    month_p1=01
+    yyyymm_p1=${year_p1}01
+  elif [ ${month_p1} -le 9 ]; then
+    month_p1=0${month_p1}
+    yyyymm_p1=${year}${month_p1}
+  else
+    yyyymm_p1=${year}${month_p1}
+  fi
+  #IGCM_debug_Print 1 "jg 1 month_m1 = ${month_m1} month_p1 = ${month_p1} "
+  #IGCM_debug_Print 1 "jg 1 calculate yyyymm_m1 = ${yyyymm_m1} "
+  #IGCM_debug_Print 1 "jg 1 calculate yyyymm_p1 = ${yyyymm_p1} "
+
+  #===================================================================#
+  # Calculate CyclicYear to be used for looping over a given forcing  #
+  # period. Add CyclicBegin and CyclicEnd in config.card UserChoices. #
+  #===================================================================#
+
+  # To use the variable CyclicYear, one must add in config.card CyclicBegin and CyclicEnd.
+  # CyclicBegin is the first year in the cycle. CyclicEnd is the last year included in the cycle.
+  if ( [ ! X${config_UserChoices_CyclicBegin} = X ] && [ ! X${config_UserChoices_CyclicEnd} = X ] ) ; then
+    CycleNb=$(( ${config_UserChoices_CyclicEnd} - ${config_UserChoices_CyclicBegin} + 1 ))
+    CyclicYear_p1=NOTDEFINED
+
+    # For current year
+    yeartmp=$year
+    diffy=$(( $yeartmp - ${config_UserChoices_CyclicBegin} ))
+    while [ $diffy -lt 0 ] ; do
+      yeartmp=$(( ${yeartmp} + ${CycleNb} ))
+      diffy=$(( $yeartmp - ${config_UserChoices_CyclicBegin} ))
+    done
+    CyclicYear=$(( ( ${diffy} % ${CycleNb} ) + ${config_UserChoices_CyclicBegin} ))
+
+    # For next coming year
+    yeartmp=$(( $year + 1 ))
+    diffy=$(( $yeartmp - ${config_UserChoices_CyclicBegin} ))
+    while [ $diffy -lt 0 ] ; do
+      yeartmp=$(( ${yeartmp} + ${CycleNb} ))
+      diffy=$(( $yeartmp - ${config_UserChoices_CyclicBegin} ))
+    done
+    CyclicYear_p1=$(( ( ${diffy} % ${CycleNb} ) + ${config_UserChoices_CyclicBegin} ))
+
+    IGCM_debug_Print 1 "CyclicYear   = ${CyclicYear}, CyclicYear_p1 = ${CyclicYear_p1}, current year=$year"
+  else
+    CyclicYear="ERROR_CyclicYear_Variable_Not_Defined"
+    CyclicYear_p1="ERROR_CyclicYear_p1_Variable_Not_Defined"
+    IGCM_debug_Print 1 "CyclicYear wont be use without adding CyclicBegin and CyclicEnd in config.card"
+  fi
+
+  # END: SHOULD GO IN A FUNCTION FROM libIGCM_date.ksh
+
+  #===================================================================#
+  # Prepare variables available for ${COMP}.card and ${COMP}.driver   #
+  #             But available to any son functions                    #
+  #===================================================================#
+
+  # Period Length In Days between DateBegin and DateCurrent (at end of period == PeriodDateEnd !)
+  (( SimulationLengthInDays = $( IGCM_date_DaysBetweenGregorianDate ${PeriodDateEnd} ${DateBegin} ) + 1 ))
+
+  # Debug Print :
+  echo
+  IGCM_debug_Print 1 "IGCM_config_PeriodStart : Before Execution"
+  IGCM_debug_Print 1 "Year of simulation      : ${year}"
+  IGCM_debug_Print 1 "Month of simulation     : ${month}"
+  IGCM_debug_Print 1 "PeriodLengthInDays      : ${PeriodLengthInDays}"
+  IGCM_debug_Print 1 "PeriodDateBegin         : ${PeriodDateBegin}"
+  IGCM_debug_Print 1 "PeriodDateEnd           : ${PeriodDateEnd}"
+  IGCM_debug_Print 1 "SimulationLengthInDays  : ${SimulationLengthInDays}"
+  IGCM_debug_Print 1 "ExperienceLengthInDays  : ${ExperienceLengthInDays}"
+
+  #================================================================#
+  #         Prepare variables available for comp_finalyze          #
+  #================================================================#
+
+  # Period for save files
+  DatesPeriod=${PeriodDateBegin}_${PeriodDateEnd}
+
+  # Prefix for save files of this period
+  PREFIX=${config_UserChoices_JobName}_${DatesPeriod}
+
+  # List of files that will be deleted in RUN_DIR after run
+  [ -f stack ] && FileToBeDeleted[0]="stack"
+
+  # Test if the same run as already been saved :
+  if [ X${JobType} = XRUN ] ; then
+    if [ ${DRYRUN} -le 0 ] ; then
+      if ( IGCM_sys_TestFileBuffer ${R_BUF_KSH}/${PREFIX}_${Exe_Output} ) ; then
+        IGCM_debug_Exit "IGCM_config_PeriodStart" "You are currently RErunning an old job."
+        IGCM_debug_Print 1 "Because of readonly permissions, you can't RErun a job when saved files"
+        IGCM_debug_Print 1 " are still in the ARCHIVE directory. You must deleted those files, or "
+        IGCM_debug_Print 1 " the whole ${R_SAVE} tree. See clean_month.job in ${libIGCM} directory."
+        IGCM_debug_Print 1 " This exit has been initiated because at least ${R_BUF_KSH}/${PREFIX}_${Exe_Output} exists."
+        IGCM_debug_Verif_Exit
+      fi
+    fi
+  else
+    if ( IGCM_sys_TestFileBuffer ${R_BUF_KSH}/${PREFIX}_${Exe_Output} ) ; then
+      IGCM_debug_Print 1 "IGCM_config_PeriodStart" "RErun an old job. Allowed in DEBUG or DEV mode."
+    fi
+  fi
+
+  #================================================================#
+  #       Prepare variables available for binary execution         #
+  #================================================================#
+
+  typeset ExeNameIn ExeNameFirst CompNameFirst comp i j
+  typeset tempvar tempvarMPI tempvarNOD NbElts NbExec
+
+  PROCESSUS_NUMBER=0
+  NbExec=0
+  i=0
+
+  OK_PARA_MPI=false
+  OK_PARA_OMP=false
+  OK_PARA_NOD=false
+  OK_PARA_MPMD=false
+
+  for comp in ${config_ListOfComponents[*]} ; do
+
+    IGCM_debug_Print 1 ${comp}
+
+    eval ExeNameIn=\${config_Executable_${comp}[0]}
+
+    # NO order in config.card for parallelized values !
+    # just use suffix : MPI , OMP and NOD (for number of NODes.)
+
+    # NOD is the number of NODes allocated
+    eval ${comp}_PROC_NOD=0
+
+    # MPI is the number of MPI processus per nodes
+    eval ${comp}_PROC_MPI=0
+
+    # OMP is the number of OpenMP threads per MPI processus
+    eval ${comp}_PROC_OMP=0
+
+    # Only if we really have an executable for the component :
+    if ( [ "X${ExeNameIn}" != X\"\" ] && [ "X${ExeNameIn}" != "Xinca.dat" ] ) ; then
+
+      # Keep the first executable found and the first CompName
+      ExeNameFirst=${ExeNameIn}
+      CompNameFirst=${comp}
+
+      # Are we a second executable?
+      (( NbExec = NbExec + 1 ))
+
+      # set 1 MPI task, 1 OpenMP thread and 1 node as default
+      eval ${comp}_PROC_MPI=1
+      eval ${comp}_PROC_OMP=1
+      eval ${comp}_PROC_NOD=1
+
+      eval NbElts=\${#config_Executable_${comp}[@]}
+
+      if [ ${NbElts} -ge 2 ] ; then
+        (( j = 2 ))
+        while [ $j -lt ${NbElts} ] ; do
+          eval tempvar=\${config_Executable_${comp}[${j}]}
+          IGCM_debug_Print 2 ${tempvar}
+
+          if [ X${tempvar} = X ] ; then
+            IGCM_debug_Print 2 "Error reading MPI/OMP parameters !!!"
+            IGCM_debug_Exit "Check your config.card. Exit now"
+            IGCM_debug_Verif_Exit
+          fi
+
+          case ${tempvar} in
+          *[mM][pP][iI]*)
+            # Read MPI parameter for composante
+            eval ${comp}_PROC_MPI=$( echo ${tempvar} | tr '[a-z]' '[A-Z]' | sed -e "s/MPI//" )
+            OK_PARA_MPI=true;;
+          *[oO][mM][pP]*)
+            # Read OMP parameter for composante
+            eval ${comp}_PROC_OMP=$( echo ${tempvar} | tr '[a-z]' '[A-Z]' | sed -e "s/OMP//" )
+            OK_PARA_OMP=true;;
+          *[nN][oO][dD]*)
+            # Read NOD (NumBer of Nodes) parameter for composante
+            eval ${comp}_PROC_NOD=$( echo ${tempvar} | tr '[a-z]' '[A-Z]' | sed -e "s/NOD//" )
+            OK_PARA_NOD=true
+            OK_PARA_MPI=true;;
+          esac
+          (( j = j + 1 ))
+        done
+      fi
+      eval tempvarMPI=\${${comp}_PROC_MPI}
+      eval tempvarNOD=\${${comp}_PROC_NOD}
+      eval tempvarOMP=\${${comp}_PROC_OMP}
+
+      (( PROCESSUS_NUMBER = PROCESSUS_NUMBER + tempvarMPI * tempvarNOD * tempvarOMP ))
+    fi
+    (( i=i+1 ))
+  done
+
+  # set MPMD mode if more than 2 executable names.
+  [ ${NbExec} -ge 2 ] && OK_PARA_MPMD=true
+
+  # Verification of BATCH_NUM_PROC_TOT total number of processors set in job header.
+  if [ X${BATCH_NUM_PROC_TOT} != X ] ; then
+    # BATCH_NUM_PROC_TOT is set
+    if ( ${OK_PARA_MPI} ) ; then
+      IGCM_debug_Print 1 "MPI/OMP/NOD found into config.card and BATCH_NUM_PROC_TOT = ${BATCH_NUM_PROC_TOT} "
+    else
+      # with previous method.
+      if [ ${BATCH_NUM_PROC_TOT} -gt 1 ] ; then
+        # with more than 1 proc
+        if ( ${OK_PARA_MPMD} ) ; then
+          # with MPMD ie CPL/oasis method
+          IGCM_debug_Print 2 "Use default number of MPI tasks for this machine : "
+          IGCM_debug_Print 2 "${DEFAULT_NUM_PROC_OCE} for OCE"
+          IGCM_debug_Print 2 "${DEFAULT_NUM_PROC_CPL} for CPL"
+          IGCM_debug_Print 2 "${DEFAULT_NUM_PROC_ATM} for ATM"
+          OK_PARA_MPI=true
+          CPL_PROC_MPI=${DEFAULT_NUM_PROC_CPL}
+          OCE_PROC_MPI=${DEFAULT_NUM_PROC_OCE}
+          ATM_PROC_MPI=${DEFAULT_NUM_PROC_ATM}
+          PROCESSUS_NUMBER=${DEFAULT_NUM_PROC_TOTAL}
+        else
+          # with have only one executable
+          IGCM_debug_Print 2 "Use ${BATCH_NUM_PROC_TOT} MPI tasks for ${CompNameFirst} : ${ExeNameFirst} "
+          OK_PARA_MPI=true
+          eval ${CompNameFirst}_PROC_MPI=${BATCH_NUM_PROC_TOT}
+          PROCESSUS_NUMBER=${BATCH_NUM_PROC_TOT}
+        fi
+      else
+        PROCESSUS_NUMBER=1
+      fi
+    fi
+    # Verification with PBS parameter
+    if [ ${BATCH_NUM_PROC_TOT} -ne ${PROCESSUS_NUMBER} ] ; then
+      IGCM_debug_Exit "ERROR with parallelization parameters !"
+      IGCM_debug_Print 2 "Job header variable BATCH_NUM_PROC_TOT = ${BATCH_NUM_PROC_TOT} "
+      IGCM_debug_Print 2 "is the total number of _processors_ reserved."
+      IGCM_debug_Print 2 "It is not equal to the sum of _processus_  = ${PROCESSUS_NUMBER}."
+      IGCM_debug_Verif_Exit
+    fi
+    NUM_PROC_CPL=${CPL_PROC_MPI} # for backward compatibility
+    NUM_PROC_OCE=${OCE_PROC_MPI} # for backward compatibility
+    NUM_PROC_ATM=${ATM_PROC_MPI} # for backward compatibility
+  else # BATCH_NUM_PROC_TOT=""
+    if ( ${OK_PARA_MPI} ) ; then
+      IGCM_debug_Exit "ERROR : missing value for ${BATCH_NUM_PROC_TOT} processors,"
+      IGCM_debug_Print 2 "You have parallel parameters in config->Executable->list."
+      IGCM_debug_Print 2 "Please add BATCH_NUM_PROC_TOT variable in job header as well."
+      IGCM_debug_Exit "Exit now."
+      IGCM_debug_Verif_Exit
+    else
+      # sequential case !
+      if [ ${PROCESSUS_NUMBER} -eq 0 ] ; then
+        (( PROCESSUS_NUMBER = 1 ))
+        IGCM_debug_Print 2 "PROCESSUS_NUMBER is all 0 (sequential use of old definition in config->Executable->list)."
+        IGCM_debug_Print 2 "We set it to 1."
+      fi
+    fi
+  fi
+
+  IGCM_debug_Print 1 "MPI/OMP treatment PROCESSUS_NUMBER = ${PROCESSUS_NUMBER}"
+
+  IGCM_sys_build_execution_scripts
+
+  ExecutionFail=false
+
+  IGCM_debug_PopStack "IGCM_config_PeriodStart"
+}
+
+#===================================
+function IGCM_config_SaveSourceModifications
+{
+  IGCM_debug_PushStack "IGCM_config_SaveSourceModifications"
+
+  typeset ExeOutDateMax listVarEnv
+  ExeOutDateMax=$1
+
+  listVarEnv="ExeOutDateMax,R_OUT_EXE,PREFIX,SUBMIT_DIR"
+  IGCM_sys_RshMaster "\
+    . ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh; \
+    export ExeOutDateMax=${ExeOutDateMax};\
+    export R_OUT_EXE=${R_OUT_EXE};\
+    export PREFIX=${PREFIX};\
+    export SUBMIT_DIR=${SUBMIT_DIR};\
+    export listVarEnv=${listVarEnv};\
+    Script_Output=out_SaveSourceModifications;\
+    IGCM_sys_Qsub ${libIGCM}/SaveSourceModifications.job ${ExeOutDateMax} ${R_OUT_EXE} ${PREFIX} ${SUBMIT_DIR}"
+
+  IGCM_debug_PopStack "IGCM_config_SaveSourceModifications"
+}
+
+#===================================
+function IGCM_config_PeriodEnd
+{
+  IGCM_debug_PushStack "IGCM_config_PeriodEnd"
+
+  echo
+  IGCM_debug_Print 1 "IGCM_config_PeriodEnd"
+  echo
+
+  #==================================#
+  #         Save Job output          #
+  #==================================#
+  if [ X${Pack} = Xtrue ] ; then
+    IGCM_sys_PutBuffer_Out ${Exe_Output} ${R_BUF_KSH}/${PREFIX}_${Exe_Output}
+  else
+    IGCM_sys_Put_Out ${Exe_Output} ${R_OUT_KSH}/${PREFIX}_${Exe_Output}
+  fi
+  FileToBeDeleted[${#FileToBeDeleted[@]}]=${Exe_Output}
+
+  if [ ${DRYRUN} -le 1 ] ; then
+
+    IGCM_debug_Print 1 "Check components binary : size and creation date"
+
+    typeset LS_comp LS_bin ExeDate ExeCpuLog NextExeSize LastCompExeSize
+    typeset comp i
+    typeset ExeNameIn ExeNameOut UpdateExe ExeSecDateMax
+
+    #==================================#
+    #        Get last Exe Size         #
+    #==================================#
+
+    (( i=0 ))
+    if ( ${FirstInitialize} ) ; then
+      run_Log_LastExeSize=""
+      for comp in ${config_ListOfComponents[*]} ; do
+        run_Log_LastExeSize[$i]=0
+        (( i=i+1 ))
+      done
+    else
+      IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/run.card Log LastExeSize
+    fi
+    #==================================#
+    #         And Build ExeDate        #
+    #==================================#
+
+    # ExeDate = ATM_Jun_12_09:34-SRF_Jun_12_09:34-OCE_Jun_12_09:34-ICE_Jun_12_09:34-CPL_Jun_12_09:33
+    # Would be nice to have next line but no way to format ls output (need to ls -l --time-style "+%Y-%m-%dT%H:%M")
+    # ExeDate = ATM_2009-06-12T09:34+SRF_2009-06-12T09:34+OCE_2009-06-12T09:34+ICE_2009-06-12T09:34+CPL_2009-06-12T09:34
+    ExeDate=""
+    NextExeSize="( "
+    (( i=0 ))
+    UpdateExe=false
+    (( ExeSecDateMax = 0 ))
+    for comp in ${config_ListOfComponents[*]} ; do
+
+      IGCM_debug_Print 3 ${comp}
+
+      eval ExeNameIn=\${config_Executable_${comp}[0]}
+      eval ExeNameOut=\${config_Executable_${comp}[1]}
+      # Only if we really have an executable for the component :
+      if [ X${ExeNameIn} = X\"\" ] ; then
+        # If there is no exe file for this component
+        (( ExeSize=0 ))
+      else
+        LS_bin=${R_EXE}/${ExeNameIn}
+        IGCM_sys_FileSize ${LS_bin} ExeSize
+
+        set +A LS_comp -- $( LC_TIME=en_US ls -l ${LS_bin} )
+        if [ X${ExeDate} = X ] ; then
+          # First component exe date
+          ExeDate=${comp}_${LS_comp[5]}_${LS_comp[6]}
+        else
+          ExeDate=${ExeDate}-${comp}_${LS_comp[5]}_${LS_comp[6]}
+        fi
+        ExeDate=${ExeDate}_${LS_comp[7]}
+      fi
+
+      if [ ${i} -eq 0 ] ; then
+        # First component
+        NextExeSize="( "${ExeSize}
+      else
+        NextExeSize=${NextExeSize}", "${ExeSize}
+      fi
+      LastCompExeSize=${run_Log_LastExeSize[$i]}
+      (( i=i+1 ))
+
+      if [ ${ExeSize} -ne ${LastCompExeSize} ] ; then
+        if ( ${FirstInitialize} ) ; then
+          IGCM_debug_Print 1 "Save first ${ExeNameIn} in ${R_OUT_EXE} !"
+        else
+          IGCM_debug_Print 1 "${ExeNameIn} has changed in ${R_EXE} !"
+          IGCM_debug_Print 1 "Save latest ${ExeNameIn} in ${R_OUT_EXE} !"
+          FileToBeDeleted[${#FileToBeDeleted[@]}]=${ExeNameOut}
+        fi
+        IGCM_sys_Put_Out ${ExeNameOut} ${R_OUT_EXE}/${PREFIX}_${ExeNameIn} rw
+        UpdateExe=true
+
+        # SD : switch off for now
+        #IGCM_sys_GetDate_FichWork ${LS_bin} ExeSecDate
+        #if [ $ExeSecDateMax -lt $ExeSecDate ] ; then
+        #  ExeSecDateMax=$ExeSecDate
+        #fi
+      fi
+    done
+
+    # SD : switch off for now
+    #if ( ${UpdateExe} ) ; then
+    #  echo "Launch SaveSourceModifications."
+    #  IGCM_config_SaveSourceModifications ${ExeSecDateMax}
+    #fi
+
+    NextExeSize=${NextExeSize}" )"
+    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Log LastExeSize "${NextExeSize}"
+
+    if [ ${DRYRUN} -le 1 ] ; then
+      tail -1500 ${Exe_Output} > ${Exe_Output}_tail.txt
+      ExeCpuLog=$( gawk -f ${libIGCM}/libIGCM_sys/IGCM_add_out.awk ${Exe_Output}_tail.txt )
+      RET=$?
+      if [ $RET -eq 0 ] ; then
+        # ExeCpuLog variable contents 5 fields
+        echo "${CumulPeriod} ${PeriodDateBegin} ${PeriodDateEnd} ${ExeCpuLog} ${ExeDate}" |   \
+          gawk '{printf("# %11d | %15s | %15s | %19s | %19s | %15.5f | %15.5f | %15.5f | %s\n", \
+            $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/run.card
+      fi
+      FileToBeDeleted[${#FileToBeDeleted[@]}]=${Exe_Output}_tail.txt
+    fi
+
+  fi
+
+  # All was right ? no ? then we stop.
+  IGCM_debug_Verif_Exit
+
+  # If all was OK, we can delete all files not necessary for next Job
+  echo
+  IGCM_debug_Print 1 "Files that will be deleted before next period-run : "
+
+  if [ ${DRYRUN} -le 2 ] ; then
+    for f in ${FileToBeDeleted[@]} ; do [ -f ${f} ] && ls -la $f ; [ -f ${f} ] && rm -f $f ; done
+  else
+    echo ${FileToBeDeleted[@]}
+  fi
+
+  # Send some accounting element to the user if CumulPeriod=3
+  if [ ${CumulPeriod} -eq 3 ] ; then
+    echo
+    IGCM_debug_Print 1 "Send email containing some accounting information : "
+
+    RealCpuTime=$( echo ${ExeCpuLog} | gawk '{print $3}' )
+
+    consumeHoursPerPeriod=$( echo "scale=6;${RealCpuTime}*${PROCESSUS_NUMBER}/3600" | bc )
+
+    consumeHoursPerWholeSimulation=$( echo "scale=6;${consumeHoursPerPeriod}/${PeriodLengthInDays}*${ExperienceLengthInDays}" | bc )
+
+    recommendedPeriodNb=$( echo "scale=6;24/${consumeHoursPerPeriod}*${PROCESSUS_NUMBER}" | bc )
+
+    IGCM_sys_SendMail Accounting
+  fi
+
+  #=================================================#
+  #         Modification of libIGCM behaviour       #
+  #=================================================#
+
+  # To use this function, one must copy libIGCM.card from ${libIGCM} directory
+  # and put it in ${SUBMIT_DIR} directory. After modifications of ${SUBMIT_DIR}/libIGCM.card,
+  # variables define inside [UserChanges] will be modified for next Period of libIGCM main loop.
+  if [ -f ${SUBMIT_DIR}/libIGCM.card ] ; then
+    echo
+    echo "########################################################################"
+    echo "!!!                 Modification of libIGCM behaviour                !!!"
+    echo
+
+    IGCM_debug_Print 1 "DefineArrayFromOption  : libIGCM_UserChanges in libIGCM.card"
+    IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/libIGCM.card UserChanges
+    IGCM_debug_Print 2 "libIGCM_UserChanges" ${libIGCM_UserChanges[*]}
+
+    # Special treatments for libIGCM internals
+    for option in ${libIGCM_UserChanges[*]} ; do
+      IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/libIGCM.card UserChanges ${option}
+
+      echo "We will change : ${option}."
+      eval echo "Previous value : " \${${option}}
+      eval echo "Change to : " \${libIGCM_UserChanges_${option}}
+
+      eval ${option}=\${libIGCM_UserChanges_${option}}
+
+      case ${option} in
+      config_UserChoices_DateEnd)
+        IGCM_debug_PrintVariables 1 config_UserChoices_DateEnd
+        DateEnd=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} )
+
+        # Period Length In Days between DateBegin and DateEnd
+        (( ExperienceLengthInDays=$( IGCM_date_DaysBetweenGregorianDate ${DateEnd} ${DateBegin} )  + 1 ))
+        if [ ${ExperienceLengthInDays} -lt 0 ] ; then
+          IGCM_debug_Print 1 "Problem with dates in libIGCM.card : ${DateEnd} < ${DateBegin} ! You must check that."
+          IGCM_debug_Exit "IGCM_PeriodEnd have wrong dates."
+          IGCM_debug_Verif_Exit
+        fi
+        ;;
+      config_UserChoices_PeriodLength)
+        IGCM_debug_Print 1  "Change config_UserChoices_PeriodLength=${config_UserChoices_PeriodLength}"
+        ;;
+      PeriodNb)
+        IGCM_debug_Print 1  "Loop in main Job with ${PeriodNb} period(s)"
+        ;;
+      config_Post_RebuildFrequency)
+        IGCM_debug_Print 1  "Change config_Post_RebuildFrequency=${config_Post_RebuildFrequency} : IGCM_post_Configure"
+        IGCM_post_Configure
+        ;;
+      config_Post_TimeSeriesFrequency)
+        IGCM_debug_Print 1  "Change config_Post_TimeSeriesFrequency = ${config_Post_TimeSeriesFrequency} : IGCM_post_Configure"
+        IGCM_post_Configure
+        ;;
+      config_Post_SeasonalFrequency)
+        IGCM_debug_Print 1  "Change config_Post_SeasonalFrequency = ${config_Post_SeasonalFrequency} : IGCM_post_Configure"
+        IGCM_post_Configure
+        ;;
+      esac
+    done
+
+    echo
+    echo "########################################################################"
+    echo
+  fi
+
+  #=================================================#
+  #         Determine next computed period          #
+  #=================================================#
+
+  PeriodDateBegin=$( IGCM_date_AddDaysToGregorianDate ${PeriodDateEnd} 1 )
+  IGCM_date_GetYearMonthDay $PeriodDateBegin year month day
+  year_m1=$(( year - 1 ))
+  year_p1=$(( year + 1 ))
+  IGCM_config_DaysInPeriodLength
+  PeriodDateEnd=$( IGCM_date_AddDaysToGregorianDate ${PeriodDateBegin} $(( ${PeriodLengthInDays} - 1 )) )
+
+  # Debug Print :
+  echo
+  IGCM_debug_Print 1 "IGCM_config_PeriodEnd : Preparing Next Execution"
+  IGCM_debug_Print 1 "PeriodDateBegin       : ${PeriodDateBegin}"
+  IGCM_debug_Print 1 "PeriodDateEnd         : ${PeriodDateEnd}"
+  IGCM_debug_Print 1 "PeriodLengthInDays    : ${PeriodLengthInDays}"
+
+  PeriodDateBegin=$( IGCM_date_ConvertFormatToHuman ${PeriodDateBegin} )
+  PeriodDateEnd=$( IGCM_date_ConvertFormatToHuman ${PeriodDateEnd} )
+
+  (( CumulPeriod = CumulPeriod + 1 ))
+
+  # Debug Print :
+  echo
+  IGCM_debug_Print 3 "PeriodDateBegin Human : ${PeriodDateBegin}"
+  IGCM_debug_Print 3 "PeriodDateEnd Human   : ${PeriodDateEnd}"
+  IGCM_debug_Print 3 "CumulPeriod           : ${CumulPeriod}"
+
+  #=================================================#
+  #             Write updated run.card              #
+  #=================================================#
+
+  IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration OldPrefix ${OldPrefix}
+  IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin ${PeriodDateBegin}
+  IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd ${PeriodDateEnd}
+  IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod ${CumulPeriod}
+
+  if ( ${FirstInitialize} ) ; then
+    # It's no more the first time
+    FirstInitialize=false
+  fi
+
+  IGCM_debug_PopStack "IGCM_config_PeriodEnd"
+}
+
+#===================================
+function IGCM_config_Finalize
+{
+  IGCM_debug_PushStack "IGCM_config_Finalize"
+
+  echo
+  IGCM_debug_Print 1 "IGCM_config_Finalize"
+  echo
+
+  if ( $DEBUG_debug ) ; then
+    # Inform the rabbitMQ queue
+    if [ X${ActivateBigBro} = Xtrue ] ; then
+      # RabbitMQ message code
+      code=1100
+      # RabbitMQ message body
+      Body=$( echo "{\"code\":\"${code}\",\"simuid\":\"${simuid}\",\"jobid\":\"${jobid}\",\"status\":\"OK\",\"timestamp\":\"$( date +"%Y-%m-%d-%T" )\"}" )
+      # Fill the rabbitMQ queue
+      IGCM_debug_sendAMQP
+    fi
+  fi
+
+  if [ ${SimulationLengthInDays} -ge ${ExperienceLengthInDays} ] ; then
+    #==========================#
+    # End of entire simulation #
+    #==========================#
+
+    # Mail notification
+    IGCM_sys_SendMail
+    #
+    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Completed"
+    #
+    IGCM_debug_Print 1 "Normal End of computation."
+
+    if ( $DEBUG_debug ) ; then
+      if [ X${ActivateBigBro} = Xtrue ] ; then
+        # RabbitMQ message code
+        code=0100
+        # RabbitMQ message body
+        Body=$( echo "{\"code\":\"${code}\",\"simuid\":\"${simuid}\",\"jobid\":\"${jobid}\",\"status\":\"OK\",\"timestamp\":\"$( date +"%Y-%m-%d-%T" )\"}" )
+        # Fill the rabbitMQ queue
+        IGCM_debug_sendAMQP
+      fi
+      echo
+      IGCM_debug_Print 1 "Your files on ${R_SAVE} :"
+      IGCM_sys_Tree ${R_SAVE}
+
+      IGCM_debug_Print 1 "Your files on ${R_BUFR} :"
+      IGCM_sys_Tree ${R_BUFR}
+    fi
+  else
+    #=================#
+    # Submit next job #
+    #=================#
+
+    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "OnQueue"
+
+    # Name of next Ksh Script output :
+    Script_Output=${Script_Output_Prefix}_${config_UserChoices_JobName}.$( printf "%06d" ${CumulPeriod} )
+
+    IGCM_debug_Print 1 "Submit next job"
+    # SUBMIT NEXT JOB from SUBMIT_DIR and come back in RUN_DIR
+    IGCM_sys_Cd ${SUBMIT_DIR}
+    # Keep only the 5 latest ${Script_Output_Prefix}_${config_UserChoices_JobName}
+    ScriptTot=$( ls ${Script_Output_Prefix}_${config_UserChoices_JobName}.?????? 2>/dev/null | wc -l )
+    [ ${ScriptTot} -gt 5 ] && rm -f $( ls ${Script_Output_Prefix}_${config_UserChoices_JobName}.?????? | head -$(( ${ScriptTot} - 5 )) )
+    # Submit next job and come back
+    IGCM_sys_Qsub ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}
+    IGCM_sys_Cd -
+  fi
+
+  # Supress Non Deleted Boundary files
+  #if [ ${DRYRUN} -le 2 ] ; then
+  #  IGCM_comp_DelFixeBoundaryFiles
+  #  ls -la
+  #fi
+
+  # Clean ${RUN_DIR}=${RUN_DIR_PATH}/${config_UserChoices_JobName}.${$}
+  # Only for production run (No clean up in DEV or DEB mode)
+  # and command sent from .. directory.
+  IGCM_sys_Cd ..
+  [ X${JobType} = XRUN ] && IGCM_sys_RmRunDir -rf ${RUN_DIR_PATH}
+
+  # To be sure we flush message buffer before exiting the job
+  FlushAMQP=TRUE
+
+  IGCM_debug_PopStack "IGCM_config_Finalize"
+}
+
+#===================================
Index: /tags/libIGCM_v2.2/libIGCM_date/IGCM_date_Test.ksh
===================================================================
--- /tags/libIGCM_v2.2/libIGCM_date/IGCM_date_Test.ksh	(revision 998)
+++ /tags/libIGCM_v2.2/libIGCM_date/IGCM_date_Test.ksh	(revision 998)
@@ -0,0 +1,145 @@
+#!/bin/ksh
+
+#**************************************************************
+# Author: Sebastien Denvil
+# Contact: Sebastien.Denvil__at__ipsl.jussieu.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+# This script is used to generate a reference file with command :
+# IGCM_date_Test.ksh > IGCM_date_Test.ref 2>&1
+# The reference file produced is used by the function IGCM_date_Check
+# to verify that the libIGCM_date produce the same results
+
+#=================================================
+cd /tmp
+
+libIGCM=`dirname $0`/..
+typeset TaskType=checking
+. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
+. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
+
+if [ X${config_UserChoices_CalendarType} = X ] ; then
+    config_UserChoices_CalendarType="leap"
+fi
+
+echo "#=================================#"
+echo "IGCM_date_DaysInYear test"
+echo "#=================================#"
+
+echo ""
+echo "#"
+echo "IGCM_date_DaysInYears 1998"
+echo "#"
+IGCM_date_DaysInYear 1998
+
+echo ""
+echo "#"
+echo "IGCM_date_DaysInYears 2000"
+echo "#"
+IGCM_date_DaysInYear 2000
+
+echo "#=================================#"
+echo "IGCM_date_DaysInMonth test"
+echo "#=================================#"
+
+echo ""
+echo "#"
+echo "IGCM_date_DaysInMonth 1998 02"
+echo "#"
+IGCM_date_DaysInMonth 1998 02
+
+echo ""
+echo "#"
+echo "IGCM_date_DaysInMonth 20000206"
+echo "#"
+IGCM_date_DaysInMonth 20000206
+
+echo "#==========================================#"
+echo "IGCM_date_ConvertGregorianDateToJulian test"
+echo "#==========================================#"
+
+echo ""
+echo "#"
+echo "IGCM_date_ConvertGregorianDateToJulian 19980312"
+echo "#"
+IGCM_date_ConvertGregorianDateToJulian 19980312
+
+echo ""
+echo "#"
+echo "IGCM_date_ConvertGregorianDateToJulian 19980830"
+echo "#"
+IGCM_date_ConvertGregorianDateToJulian 19980830
+
+echo "#==========================================#"
+echo "IGCM_date_ConvertJulianDateToGregorian test"
+echo "#==========================================#"
+
+echo ""
+echo "#"
+echo "IGCM_date_ConvertJulianDateToGregorian 1998326"
+echo "#"
+IGCM_date_ConvertJulianDateToGregorian 1998326
+
+echo ""
+echo "#"
+echo "IGCM_date_ConvertJulianDateToGregorian 2000298"
+echo "#"
+IGCM_date_ConvertJulianDateToGregorian 2000298
+
+echo "#==================================#"
+echo "IGCM_date_AddDaysToJulianDate test"
+echo "#==================================#"
+
+echo ""
+echo "#"
+echo "IGCM_date_AddDaysToJulianDate 1998312 14"
+echo "#"
+IGCM_date_AddDaysToJulianDate 1998312 14
+
+echo ""
+echo "#"
+echo "IGCM_date_AddDaysToJulianDate 2000312 -14"
+echo "#"
+IGCM_date_AddDaysToJulianDate 2000312 -14
+
+echo "#====================================#"
+echo "IGCM_date_AddDaysToGregorianDate test"
+echo "#====================================#"
+
+echo ""
+echo "#"
+echo "IGCM_date_AddDaysToGregorianDate 19980312 44"
+echo "#"
+IGCM_date_AddDaysToGregorianDate 19980312 44
+
+echo ""
+echo "#"
+echo "IGCM_date_AddDaysToGregorianDate 20000228 -44"
+echo "#"
+IGCM_date_AddDaysToGregorianDate 20000228 -44
+
+echo "#====================================#"
+echo "IGCM_date_DaysBetweenJulianDate test"
+echo "#====================================#"
+
+echo ""
+echo "#"
+echo "IGCM_date_DaysBetweenJulianDate 1860001 1865365"
+echo "#"
+IGCM_date_DaysBetweenJulianDate 1860001 1865365
+
+echo "#======================================#"
+echo "IGCM_date_DaysBetweenGregorianDate test"
+echo "#======================================#"
+
+echo ""
+echo "#"
+echo "IGCM_date_DaysBetweenGregorianDate 18801231 18750101"
+echo "#"
+IGCM_date_DaysBetweenGregorianDate 18801231 18750101
Index: /tags/libIGCM_v2.2/libIGCM_date/IGCM_date_Test4.ref
===================================================================
--- /tags/libIGCM_v2.2/libIGCM_date/IGCM_date_Test4.ref	(revision 998)
+++ /tags/libIGCM_v2.2/libIGCM_date/IGCM_date_Test4.ref	(revision 998)
@@ -0,0 +1,94 @@
+#=================================#
+IGCM_date_DaysInYear test
+#=================================#
+
+#
+IGCM_date_DaysInYears 1998
+#
+365
+
+#
+IGCM_date_DaysInYears 2000
+#
+366
+#=================================#
+IGCM_date_DaysInMonth test
+#=================================#
+
+#
+IGCM_date_DaysInMonth 1998 02
+#
+28
+
+#
+IGCM_date_DaysInMonth 20000206
+#
+29
+#==========================================#
+IGCM_date_ConvertGregorianDateToJulian test
+#==========================================#
+
+#
+IGCM_date_ConvertGregorianDateToJulian 19980312
+#
+1998071
+
+#
+IGCM_date_ConvertGregorianDateToJulian 19980830
+#
+1998242
+#==========================================#
+IGCM_date_ConvertJulianDateToGregorian test
+#==========================================#
+
+#
+IGCM_date_ConvertJulianDateToGregorian 1998326
+#
+19981122
+
+#
+IGCM_date_ConvertJulianDateToGregorian 2000298
+#
+20001024
+#==================================#
+IGCM_date_AddDaysToJulianDate test
+#==================================#
+
+#
+IGCM_date_AddDaysToJulianDate 1998312 14
+#
+1998326
+
+#
+IGCM_date_AddDaysToJulianDate 2000312 -14
+#
+2000298
+#====================================#
+IGCM_date_AddDaysToGregorianDate test
+#====================================#
+
+#
+IGCM_date_AddDaysToGregorianDate 19980312 44
+#
+19980425
+
+#
+IGCM_date_AddDaysToGregorianDate 20000228 -44
+#
+20000115
+#====================================#
+IGCM_date_DaysBetweenJulianDate test
+#====================================#
+
+#
+IGCM_date_DaysBetweenJulianDate 1860001 1865365
+#
+-2191
+#======================================#
+IGCM_date_DaysBetweenGregorianDate test
+#======================================#
+
+#
+IGCM_date_DaysBetweenGregorianDate 18801231 18750101
+#
+2191
Index: /tags/libIGCM_v2.2/libIGCM_date/IGCM_date_Test5.ref
===================================================================
--- /tags/libIGCM_v2.2/libIGCM_date/IGCM_date_Test5.ref	(revision 998)
+++ /tags/libIGCM_v2.2/libIGCM_date/IGCM_date_Test5.ref	(revision 998)
@@ -0,0 +1,94 @@
+#=================================#
+IGCM_date_DaysInYear test
+#=================================#
+
+#
+IGCM_date_DaysInYears 1998
+#
+365
+
+#
+IGCM_date_DaysInYears 2000
+#
+366
+#=================================#
+IGCM_date_DaysInMonth test
+#=================================#
+
+#
+IGCM_date_DaysInMonth 1998 02
+#
+28
+
+#
+IGCM_date_DaysInMonth 20000206
+#
+29
+#==========================================#
+IGCM_date_ConvertGregorianDateToJulian test
+#==========================================#
+
+#
+IGCM_date_ConvertGregorianDateToJulian 19980312
+#
+1998071
+
+#
+IGCM_date_ConvertGregorianDateToJulian 19980830
+#
+1998242
+#==========================================#
+IGCM_date_ConvertJulianDateToGregorian test
+#==========================================#
+
+#
+IGCM_date_ConvertJulianDateToGregorian 1998326
+#
+019981122
+
+#
+IGCM_date_ConvertJulianDateToGregorian 2000298
+#
+020001024
+#==================================#
+IGCM_date_AddDaysToJulianDate test
+#==================================#
+
+#
+IGCM_date_AddDaysToJulianDate 1998312 14
+#
+1998326
+
+#
+IGCM_date_AddDaysToJulianDate 2000312 -14
+#
+2000298
+#====================================#
+IGCM_date_AddDaysToGregorianDate test
+#====================================#
+
+#
+IGCM_date_AddDaysToGregorianDate 19980312 44
+#
+019980425
+
+#
+IGCM_date_AddDaysToGregorianDate 20000228 -44
+#
+020000115
+#====================================#
+IGCM_date_DaysBetweenJulianDate test
+#====================================#
+
+#
+IGCM_date_DaysBetweenJulianDate 1860001 1865365
+#
+-2191
+#======================================#
+IGCM_date_DaysBetweenGregorianDate test
+#======================================#
+
+#
+IGCM_date_DaysBetweenGregorianDate 18801231 18750101
+#
+2191
Index: /tags/libIGCM_v2.2/libIGCM_date/libIGCM_date.ksh
===================================================================
--- /tags/libIGCM_v2.2/libIGCM_date/libIGCM_date.ksh	(revision 998)
+++ /tags/libIGCM_v2.2/libIGCM_date/libIGCM_date.ksh	(revision 998)
@@ -0,0 +1,1058 @@
+#!/bin/ksh
+
+#**************************************************************
+# Author: Sebastien Denvil
+# Contact: Sebastien.Denvil__at__ipsl.jussieu.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#==================================================
+# The documentation of this file can be automatically generated
+# if you use the prefix #D- for comments to be extracted.
+# Extract with command: cat lib* | grep "^#D-" | cut -c "4-"
+#==================================================
+
+#D-#==================================================================
+#D-libIGCM_date
+#D-This ksh library handles date calculs and convertions in different calendars.
+#D-  types of calendars are possible :
+#D-
+#D-  - leap|gregorian|standard (other name leap) :
+#D-      The normal calendar. The time origin for the
+#D-      julian day in this case is 24 Nov -4713.
+#D-  - noleap|365_day :
+#D-      A 365 day year without leap years.
+#D-  - all_leap|366_day :
+#D-      A 366 day year with only leap years.
+#D-  - 360d|360_day :
+#D-      Year of 360 days with month of equal length.
+
+# Number of digit in the year
+typeset -r dY=${dY:=4}
+#typeset -r MaxpY=$( echo "10^"$((dY+1)) | bc -l )
+# Number of digit in non-human date representation
+typeset -r pY=$(( dY+4 ))
+
+#==================================================================
+function IGCM_date_YearDigit
+{
+  IGCM_debug_PushStack "IGCM_date_YearDigit" $@
+
+  typeset NUM
+
+  NUM=$(( 10#${1} ))
+  echo $( gawk "BEGIN { printf \"%0${dY}d\",${NUM} }" )
+
+  IGCM_debug_PopStack "IGCM_date_YearDigit"
+}
+
+#==================================================================
+function IGCM_date_GregorianDigit
+{
+  IGCM_debug_PushStack "IGCM_date_GregorianDigit" $@
+
+  typeset NUM
+
+  NUM=$(( 10#${1} ))
+
+  echo $( gawk "BEGIN { printf \"%0${pY}d\",${NUM} }" )
+
+  IGCM_debug_PopStack "IGCM_date_GregorianDigit"
+}
+
+#==================================================================
+function IGCM_date_HumanDigit
+{
+  IGCM_debug_PushStack "IGCM_date_HumanDigit" $@
+
+  echo $( IGCM_date_GregorianDigit $( print ${1} | sed 's/-//g' ) ) \
+    | sed -e "s/\([0-9]\{${dY}\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)/\1-\2-\3/"
+
+  IGCM_debug_PopStack "IGCM_date_HumanDigit"
+}
+
+#==================================================================
+function IGCM_date_SupressZeros
+{
+  IGCM_debug_PushStack "IGCM_date_SupressZeros" $@
+  echo $( print ${1} | sed -e "s/0*//" )
+  IGCM_debug_PopStack "IGCM_date_SupressZeros"
+}
+
+#==================================================================
+function IGCM_date_ConvertFormatToGregorian
+{
+  IGCM_debug_PushStack "IGCM_date_ConvertFormatToGregorian" $@
+
+  # from a yyyy-mm-dd date format return
+  # a yyymmdd date format
+  # usage IGCM_date_ConvertFormat yyyy-mm-dd
+
+  # if there is no argument on the command line,
+  # then assume that a y-m-d formated date is being
+  # piped in
+  typeset ymd
+  if [ $# = 0 ]
+  then
+    read ymd
+  else
+    ymd=$1
+  fi
+
+  IGCM_date_GregorianDigit $( print ${ymd} | sed 's/-//g' )
+
+  IGCM_debug_PopStack "IGCM_date_ConvertFormatToGregorian"
+}
+
+#==================================================================
+function IGCM_date_ConvertFormatToHuman
+{
+  IGCM_debug_PushStack "IGCM_date_ConvertFormatToHuman" $@
+
+  # from a yyyymmdd date format return
+  # a yyyy-mm-dd date format
+  # usage IGCM_date_ConvertFormat yyyymmdd
+
+  # if there is no argument on the command line,
+  # then assume that a yyyymmdd formated date is being
+  # piped in
+  typeset dt
+  if [ $# = 0 ]
+  then
+    read dt
+  else
+    dt=$1
+  fi
+
+  # break the yyyymmdd into separate parts for year, month and day
+  echo $( IGCM_date_GregorianDigit ${dt} ) | sed -e "s/\([0-9]\{${dY}\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)/\1-\2-\3/"
+
+  IGCM_debug_PopStack "IGCM_date_ConvertFormatToHuman"
+}
+
+#==================================================================
+function IGCM_date_GetYearMonth
+{
+  IGCM_debug_PushStack "IGCM_date_GetYearMonth" $@
+
+  # from a yyyymmdd date format return
+  # a yyyy year and mm month
+  # usage IGCM_date_GetYearMonth yyyymmdd year_var month_var
+
+  # if there is no argument on the command line,
+  # then assume that a yyyymmdd formated date is being
+  # piped in
+  typeset dt
+  if [ $# = 0 ]
+  then
+    read dt
+  else
+    dt=$1
+  fi
+
+  # break the yyyymmdd into separate parts for year, month and day
+  eval $2=$( IGCM_date_GregorianDigit ${dt} | sed -e "s/\([0-9]\{${dY}\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)/\1/" )
+  eval $3=$( IGCM_date_GregorianDigit ${dt} | sed -e "s/\([0-9]\{${dY}\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)/\2/" )
+
+  IGCM_debug_PopStack "IGCM_date_GetYearMonth"
+}
+
+#==================================================================
+function IGCM_date_GetYearMonthDay
+{
+  IGCM_debug_PushStack "IGCM_date_GetYearMonthDay" $@
+
+  # from a yyyymmdd date format return
+  # a yyyy year, mm month and dd day
+  # usage IGCM_date_GetYearMonthDay yyyymmdd year_var month_var day_var
+
+  # if there is no argument on the command line,
+  # then assume that a yyyymmdd formated date is being
+  # piped in
+  typeset dt
+  if [ $# = 0 ]
+  then
+    read dt
+  else
+    dt=$1
+  fi
+
+  # break the yyyymmdd into separate parts for year, month and day
+  eval $2=$( IGCM_date_GregorianDigit ${dt} | sed -e "s/\([0-9]\{${dY}\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)/\1/" )
+  eval $3=$( IGCM_date_GregorianDigit ${dt} | sed -e "s/\([0-9]\{${dY}\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)/\2/" )
+  eval $4=$( IGCM_date_GregorianDigit ${dt} | sed -e "s/\([0-9]\{${dY}\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)/\3/" )
+
+  IGCM_debug_PopStack "IGCM_date_GetYearMonthDay"
+}
+
+#D-#==================================================================
+#D-function IGCM_date_DaysInYear
+#D-* Purpose: Return the number of days in a year
+#D-* Usage: IGCM_date_DaysInYear yyyy
+#D-         if there is no argument on the command line,
+#D-         then assume that a yyyy is being piped in
+#D-
+function IGCM_date_DaysInYear
+{
+#    IGCM_debug_PushStack "IGCM_date_DaysInYear" $@
+  # return the number of days in a year
+  # usage IGCM_date_DaysInYear yyyy
+
+  # What is the calendar :
+  case ${config_UserChoices_CalendarType} in
+  360d|360_day)
+    if [ X$2 = X ] ; then
+      echo 360
+    else
+      eval $2=360 > /dev/null 2>&1
+    fi
+#    IGCM_debug_PopStack "IGCM_date_DaysInYear"
+    return;;
+  noleap|365_day)
+    if [ X$2 = X ] ; then
+      echo 365
+    else
+      eval $2=365 > /dev/null 2>&1
+    fi
+
+#    IGCM_debug_PopStack "IGCM_date_DaysInYear"
+    return;;
+  all_leap|366_day)
+    if [ X$2 = X ] ; then
+      echo 366
+    else
+      eval $2=366 > /dev/null 2>&1
+    fi
+
+#    IGCM_debug_PopStack "IGCM_date_DaysInYear"
+    return;;
+  esac
+
+  typeset y a
+
+  # if there is no argument on the command line,
+  # then assume that a yyyy is being piped in
+  if [ $# = 0 ]
+  then
+    read y
+  else
+    y=$(( 10#${1} ))
+  fi
+
+  # a year is a leap year if it is even divisible by 4
+  # but not evenly divisible by 100
+  # unless it is evenly divisible by 400
+
+  # if it is evenly divisible by 400 it must be a leap year
+  a=$(( $y % 400 ))
+  if [ $a = 0 ]
+  then
+    if [ X$2 = X ] ; then
+      echo 366
+    else
+      eval $2=366 > /dev/null 2>&1
+    fi
+
+#    IGCM_debug_PopStack "IGCM_date_DaysInYear"
+    return
+  fi
+
+  # if it is evenly divisible by 100 it must not be a leap year
+  a=$(( $y % 100 ))
+  if [ $a = 0 ]
+  then
+    if [ X$2 = X ] ; then
+      echo 365
+    else
+      eval $2=365 > /dev/null 2>&1
+    fi
+
+#    IGCM_debug_PopStack "IGCM_date_DaysInYear"
+    return
+  fi
+
+  # if it is evenly divisible by 4 it must be a leap year
+  a=$(( $y % 4 ))
+  if [ $a = 0 ]
+  then
+    if [ X$2 = X ] ; then
+      echo 366
+    else
+      eval $2=366 > /dev/null 2>&1
+    fi
+
+#    IGCM_debug_PopStack "IGCM_date_DaysInYear"
+    return
+  fi
+
+  # otherwise it is not a leap year
+  if [ X$2 = X ] ; then
+    echo 365
+  else
+    eval $2=365 > /dev/null 2>&1
+  fi
+
+#    IGCM_debug_PopStack "IGCM_date_DaysInYear"
+}
+
+#D-#==================================================================
+#D-function IGCM_date_DaysInMonth
+#D-* Purpose: Calculate the number of days in a month
+#D-* Usage: IGCM_date_DaysInMonth yyyy mm
+#D-         or IGCM_date_DaysInMonth yyyymmdd
+#D-         if there are no command line arguments then
+#D-         assume that a yyyymmdd is being piped in and read the value.
+#D-         if there is only one argument assume it is a yyyymmdd on the command line
+#D-         other wise it is a yyyy and mm on the command line
+function IGCM_date_DaysInMonth
+{
+#    IGCM_debug_PushStack "IGCM_date_DaysInMonth" $@
+
+  # calculates the number of days in a month
+  # usage IGCM_date_DaysInMonth yyyy mm
+  # or IGCM_date_DaysInMonth yyyymmdd
+
+  # What is the calendar :
+  if ( [ "${config_UserChoices_CalendarType}" = "360d" ] || [ "${config_UserChoices_CalendarType}" = "360_day" ] ) ; then
+    if [ X$3 = X ] ; then
+      echo 30
+    else
+      eval $3=30 > /dev/null 2>&1
+    fi
+
+#   IGCM_debug_PopStack "IGCM_date_DaysInMonth"
+    return
+  fi
+
+  typeset ymd y m
+
+  # if there are no command line arguments then assume that a yyyymmdd is being
+  # piped in and read the value.
+  # if there is only one argument assume it is a yyyymmdd on the command line
+  # other wise it is a yyyy and mm on the command line
+  if [ $# = 0 ]
+  then
+    read ymd
+  elif [ $# = 1 ]
+  then
+    ymd=$1
+  else
+    ymd=$(( ( $1 * 10000 ) + ( $2 * 100 ) + 1 ))
+  fi
+
+  # extract the year and the month
+  y=$(( $ymd / 10000 )) ;
+  m=$(( ( $ymd % 10000 ) / 100 )) ;
+
+  # 30 days hath september etc.
+  case $m in
+  1|3|5|7|8|10|12)
+    if [ X$3 = X ] ; then
+      echo 31
+    else
+      eval $3=31 > /dev/null 2>&1
+    fi
+
+#           IGCM_debug_PopStack "IGCM_date_DaysInMonth"
+    return ;;
+  4|6|9|11)
+    if [ X$3 = X ] ; then
+      echo 30
+    else
+      eval $3=30 > /dev/null 2>&1
+    fi
+
+#           IGCM_debug_PopStack "IGCM_date_DaysInMonth"
+    return ;;
+  *) ;;
+  esac
+
+  # except for month 2 which depends on whether the year is a leap year
+  # Use IGCM_date_DaysInYear to get the number of days in the year and return a value
+  # accordingly.
+
+  IGCM_date_DaysInYear $y diy
+  case $diy in
+  365)
+    if [ X$3 = X ] ; then
+      echo 28
+    else
+      eval $3=28 > /dev/null 2>&1
+    fi
+
+#    IGCM_debug_PopStack "IGCM_date_DaysInMonth"
+    return ;;
+  366)
+    if [ X$3 = X ] ; then
+      echo 29
+    else
+      eval $3=29 > /dev/null 2>&1
+    fi
+
+#    IGCM_debug_PopStack "IGCM_date_DaysInMonth"
+    return ;;
+  esac
+
+#    IGCM_debug_PopStack "IGCM_date_DaysInMonth"
+}
+
+#D-#==================================================================
+#D-function IGCM_date_ConvertGregorianDateToJulian
+#D-* Purpose: Convert yyyymmdd to yyyyddd
+#D-* Usage: IGCM_date_ConvertGregorianDateToJulian 19980429
+#D-         if there is no command line argument, then assume that the date
+#D-         is coming in on a pipe and use read to collect it
+#D-
+function IGCM_date_ConvertGregorianDateToJulian
+{
+  IGCM_debug_PushStack "IGCM_date_ConvertGregorianDateToJulian" $@
+
+  # IGCM_date_ConvertGregorianDateToJulian converts yyyymmdd to yyyyddd
+  # usage IGCM_date_ConvertGregorianDateToJulian 19980429
+
+  typeset dt y m d x jul
+
+  # if there is no command line argument, then assume that the date
+  # is coming in on a pipe and use read to collect it
+  if [ $# = 0 ]
+  then
+    read dt
+  else
+    dt=$( IGCM_date_SupressZeros $1 )
+  fi
+
+  # break the yyyymmdd into separate parts for year, month and day
+  y=$(( $dt / 10000 ))
+  m=$(( ( $dt % 10000 ) / 100 ))
+  d=$(( ( $dt % 100 ) ))
+
+  # add the days in each month up to (but not including the month itself)
+  # into the days. For example if the date is 19980203 then extract the
+  # number of days in January and add it to 03. If the date is June 14, 1998
+  # then extract the number of days in January, February, March, April and May
+  # and add them to 14.
+  x=1
+  while [ $x -lt $m ]
+  do
+    IGCM_date_DaysInMonth $y $x md
+    d=$(( $d + $md ))
+    x=$(( $x + 1 ))
+  done
+
+  # combine the year and day back together again and you have the julian date.
+  jul=$(( ( $y * 1000 ) + $d ))
+  echo $jul
+
+  IGCM_debug_PopStack "IGCM_date_ConvertGregorianDateToJulian"
+}
+
+#D-#==================================================================
+#D-function IGCM_date_ConvertJulianDateToGregorian()
+#D-* Purpose: Convert yyyyddd to yyyymmdd
+#D-* Usage: IGCM_date_ConvertJulianDateToGregorian 1998213
+#D-         if there is no command line argument, assume one is being
+#D-         piped in and read it
+#D-
+function IGCM_date_ConvertJulianDateToGregorian
+{
+  IGCM_debug_PushStack "IGCM_date_ConvertJulianDateToGregorian" $@
+
+  # IGCM_date_ConvertJulianDateToGregorian converts yyyyddd to yyyymmdd
+  # usage IGCM_date_ConvertJulianDateToGregorian 1998213
+
+  typeset dt y m d grg
+
+  # if there is no command line argument, assume one is being
+  # piped in and read it
+  if [ X$1 = X ]
+  then
+    read dt
+  else
+    dt=$1
+  fi
+
+  # break apart the year and the days
+  y=$(( $dt / 1000 ))
+  d=$(( $dt % 1000 ))
+
+  # subtract the number of days in each month starting from 1
+  # from the days in the date. When the day goes below 1, you
+  # have the current month. Add back the number of days in the
+  # month to get the correct day of the month
+  m=1
+  while [ $d -gt 0 ]
+  do
+    IGCM_date_DaysInMonth $y $m md
+    d=$(( $d - $md ))
+    m=$(( $m + 1 ))
+  done
+
+  d=$(( $d + $md ))
+
+  # the loop steps one past the correct month, so back up the month
+  m=$(( $m - 1 ))
+
+  # assemble the results into a gregorian date
+  grg=$(( ( $y * 10000 ) + ( $m * 100 ) + $d ))
+  echo $( IGCM_date_GregorianDigit $grg )
+
+  IGCM_debug_PopStack "IGCM_date_ConvertJulianDateToGregorian"
+}
+
+#D-#==================================================================
+#D-function IGCM_date_AddDaysToJulianDate
+#D-* Purpose: Add days to a yyyyddd formatted date
+#D-* Usage: IGCM_date_AddDaysToJulianDate 1998312 { ,-}14
+#D-         Read the difference from the command lines
+#D-         and the date from the command line, or standard input
+#D-
+function IGCM_date_AddDaysToJulianDate
+{
+  IGCM_debug_PushStack "IGCM_date_AddDaysToJulianDate" $@
+
+  # IGCM_date_AddDaysToJulianDate adds days to a yyyyddd formatted date
+  # usage IGCM_date_AddDaysToJulianDate 1998312 { ,-}14
+
+  typeset dif yd d y
+
+  # Read the difference from the command lines
+  # and the date from the command line, or standard input
+  if [ X$2 = X ]
+  then
+    dif=$1
+    read yd
+  else
+    yd=$1
+    dif=$2
+  fi
+
+  # Break it into pieces
+  d=$(( $yd % 1000 ))
+  y=$(( $yd / 1000 ))
+
+  # Add the number of days (if days is negative this results is
+  # a subtraction)
+  d=$(( $d + $dif ))
+
+  # Extract the days in the year
+  IGCM_date_DaysInYear $y diy
+
+  # If the calculated day exceeds the days in the year,
+  # add one year to the year and subtract the days in the year from the
+  # calculated days. Extract the days in the new year and repeat
+  # test until you end up with a day number that falls within the
+  # days of the year
+  while [ $d -gt $diy ]
+  do
+    d=$(( $d - $diy ))
+    y=$(( $y + 1 ))
+    IGCM_date_DaysInYear $y diy
+  done
+
+  # This is the reverse process. If the calculated number of days
+  # is less than 1, move back one year. Extract
+  # the days in this year and add the days in the year
+  # loop on this test until you end up with a number that
+  # falls within the days of the year
+  while [ $d -lt 1 ]
+  do
+    y=$(( $y - 1 ))
+    IGCM_date_DaysInYear $y diy
+    d=$(( $d + $diy ))
+  done
+
+  # put the year and day back together and echo the result
+  yd=$(( ( $y * 1000 ) + $d ))
+
+  echo $yd
+
+  IGCM_debug_PopStack "IGCM_date_AddDaysToJulianDate"
+}
+
+#D-#==================================================================
+#D-function IGCM_date_AddDaysToGregorianDate
+#D-* Purpose: Add days to a yyyymmdd formatted date
+#D-* Usage: IGCM_date_AddDaysToGregorianDate 19980312 { ,-}14
+#D-         Read the difference from the command lines
+#D-         and the date from the command line, or standard input
+#D-
+function IGCM_date_AddDaysToGregorianDate
+{
+  IGCM_debug_PushStack "IGCM_date_AddDaysToGregorianDate" $@
+
+  # IGCM_date_AddDaysToGregorianDate adds days to a yyyymmdd formatted date
+  # usage IGCM_date_AddDaysToGregorianDate 19980312 { ,-}14
+
+  # Read the difference from the command lines
+  # and the date from the command line, or standard input
+  typeset dif yd tmp res
+  if [ X$2 = X ]
+  then
+    dif=$1
+    read yd
+  else
+    yd=$1
+    dif=$2
+  fi
+
+  tmp=$( IGCM_date_ConvertGregorianDateToJulian $yd )
+  tmp=$( IGCM_date_AddDaysToJulianDate $tmp $dif )
+  res=$( IGCM_date_ConvertJulianDateToGregorian $tmp )
+
+  echo $res
+
+  IGCM_debug_PopStack "IGCM_date_AddDaysToGregorianDate"
+}
+
+#D-#==================================================================
+#D-function IGCM_date_DaysBetweenJulianDate
+#D-* Purpose: Calculate the days difference between two dates and reports
+#D-           the number days as jul1 - jul2
+#D-* Usage: IGCM_date_DaysBetweenJulianDate jul1 jul2
+#D-         where julian date is in the form yyyyddd
+#D-
+function IGCM_date_DaysBetweenJulianDate
+{
+  IGCM_debug_PushStack "IGCM_date_DaysBetweenJulianDate" $@
+
+  # calculates the days difference between two dates and reports
+  # the number days as jul1 - jul2
+  # usage IGCM_date_DaysBetweenJulianDate jul1 jul2
+  # where julian date is in the form yyyyddd
+
+  usage () {
+    echo "Usage:"
+    echo " IGCM_date_DaysBetweenJulianDate jul1 jul2"
+    echo ""
+    echo " Calculates the day difference between"
+    echo " two julian dates (jul1 -jul2)"
+    echo " where a julian date is in the form of yyyyddd."
+  }
+
+  if [ $# -lt 2 ]; then
+    usage
+    IGCM_debug_Exit "IGCM_date_DaysBetweenJulianDate"
+  fi
+
+  typeset jul1 jul2 yyyy1 yyyy2 ddd1 ddd2 res
+
+  # This process subtracts arg2 from arg1. If arg2 is larger
+  # then reverse the arguments. The calculations are done, and
+  # then the sign is reversed
+  if [ $1 -lt $2 ]
+  then
+    jul1=$2
+    jul2=$1
+  elif [ $1 -gt $2 ]
+  then
+    jul1=$1
+    jul2=$2
+  else
+    echo 0
+    IGCM_debug_PopStack "IGCM_date_DaysBetweenJulianDate"
+    return
+  fi
+
+  # Break the dates in to year and day portions
+  yyyy1=$(( $jul1 / 1000 ))
+  yyyy2=$(( $jul2 / 1000 ))
+  ddd1=$(( $jul1 % 1000 ))
+  ddd2=$(( $jul2 % 1000 ))
+
+  # Subtract days
+  res=$(( $ddd1 - $ddd2 ))
+
+  # Then add days in year until year2 matches year1
+  case ${config_UserChoices_CalendarType} in
+  360d|360_day)
+    res=$(( ( ( $yyyy1 - $yyyy2 ) * 360 ) + $res )) ;;
+  noleap|365_day)
+    res=$(( ( ( $yyyy1 - $yyyy2 ) * 365 ) + $res )) ;;
+  all_leap|366_day)
+    res=$(( ( ( $yyyy1 - $yyyy2 ) * 366 ) + $res )) ;;
+  leap|gregorian|standard)
+    while [ $yyyy2 -lt $yyyy1 ]
+    do
+      IGCM_date_DaysInYear $yyyy2 diy
+      res=$(( $res + $diy ))
+      yyyy2=$(( $yyyy2 + 1 ))
+    done
+    ;;
+  esac
+
+  # if argument 2 was larger than argument 1 then
+  # the arguments were reversed before calculating
+  # adjust by reversing the sign
+  if [ $1 -lt $2 ]
+  then
+    res=$(( $res * -1 ))
+  fi
+
+  # and output the results
+  echo $res
+
+  IGCM_debug_PopStack "IGCM_date_DaysBetweenJulianDate"
+}
+
+#D-#==================================================================
+#D-function IGCM_date_DaysBetweenGregorianDate ()
+#D-* Purpose: Calculate the days difference between two dates and reports
+#D-           the number days as grg1 - grg2
+#D-* Usage: IGCM_date_DaysBetweenGregorianDate grg1 grg2
+#D-         where gregorian date is in the form yyyymmdd
+#D-
+function IGCM_date_DaysBetweenGregorianDate
+{
+  IGCM_debug_PushStack "IGCM_date_DaysBetweenGregorianDate" $@
+
+  # calculates the days difference between two dates and reports
+  # the number days as grg1 - grg2
+  # usage IGCM_date_DaysBetweenGregorianDate grg1 grg2
+  # where gregorian date is in the form yyyymmdd
+
+  usage () {
+    echo "Usage:"
+    echo " IGCM_date_DaysBetweenGregorianDate grg1 grg2"
+    echo ""
+    echo " Calculate day difference between"
+    echo " two gregorian dates (grg1 - grg2)"
+    echo " where a gregorian date is in the form of yyyymmdd."
+  }
+
+  if [ $# -lt 2 ]; then
+    usage
+    IGCM_debug_Exit "IGCM_date_DaysBetweenGregorianDate"
+  fi
+
+  typeset grg1 grg2 jul1 jul2 res
+
+  # convert each date to julian
+  grg1=$1
+  grg2=$2
+
+  jul1=$( IGCM_date_ConvertGregorianDateToJulian $grg1 )
+  jul2=$( IGCM_date_ConvertGregorianDateToJulian $grg2 )
+
+  if [ $jul1 -ne $jul2 ]; then
+    # calculate the answer using IGCM_date_DaysBetweenJulianDate
+    res=$( IGCM_date_DaysBetweenJulianDate $jul1 $jul2 )
+    # and output the results
+    echo $res
+  else
+    echo 0
+  fi
+
+  IGCM_debug_PopStack "IGCM_date_DaysBetweenGregorianDate"
+}
+
+#D-#==================================================================
+#D-function IGCM_date_DaysSinceJC ()
+#D-* Purpose: Calculate the days difference between a date and 00010101
+#D-* Usage: IGCM_date_DaysSinceJC grg1
+#D-         where gregorian date is in the form yyyymmdd
+#D-
+function IGCM_date_DaysSinceJC
+{
+  IGCM_debug_PushStack "IGCM_date_DaysSinceJC" $@
+
+  # calculates the days difference between a date and 00010101
+  # usage IGCM_date_DaysSinceJC grg1
+  # where gregorian date is in the form yyyymmdd
+
+  usage () {
+    echo "Usage:"
+    echo " IGCM_date_DaysSinceJC grg1"
+    echo ""
+    echo " Calculate day difference between"
+    echo " a gregorian date and 00010101"
+    echo " where a gregorian date is in the form of yyyymmdd."
+  }
+
+  if [ $# -lt 1 ]; then
+    usage
+    IGCM_debug_Exit "IGCM_date_DaysSinceJC"
+  fi
+
+  typeset aux num
+
+  if   [ ${1} -lt  5000000 ]; then
+    case ${config_UserChoices_CalendarType} in
+    360d|360_day)
+      aux=-360;;
+    noleap|365_day)
+      aux=-365;;
+    all_leap|366_day)
+      aux=-366;;
+    leap|gregorian|standard)
+      aux=-366;;
+    esac
+    num=101
+  elif [ ${1} -lt 15000000 ]; then
+    # To save CPU type we use auxiliary value
+    # which is number of days since JC and 10000101
+    case ${config_UserChoices_CalendarType} in
+    360d|360_day)
+      aux=359640;;
+    noleap|365_day)
+      aux=364635;;
+    all_leap|366_day)
+      aux=365634;;
+    leap|gregorian|standard)
+      aux=364877;;
+    esac
+    num=10000101
+  else
+    # To save CPU type we use auxiliary value
+    # which is number of days since JC and 19000101
+    case ${config_UserChoices_CalendarType} in
+    360d|360_day)
+      aux=683640;;
+    noleap|365_day)
+      aux=693135;;
+    all_leap|366_day)
+      aux=695034;;
+    leap|gregorian|standard)
+      aux=693595;;
+    esac
+    num=19000101
+  fi
+  echo $(( $( IGCM_date_DaysBetweenGregorianDate $1 ${num} ) + $aux ))
+
+  IGCM_debug_PopStack "IGCM_date_DaysSinceJC"
+}
+
+#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 treatedYear PeriodLengthInYears PeriodLengthInMonths year0 i
+
+  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${3} = 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${3} = 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} )
+    treatedYear=0
+    Length=0
+    i=0
+    for ((i = 0; i < ${PeriodLengthInMonths}; i += 1)) ; do
+
+      (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month + i - 12 * treatedYear )) ) ))
+
+      if [ $(( month + i )) -ge $(( 12 * (treatedYear + 1) )) ] ; then
+        (( year = year0 + 1 ))
+        (( treatedYear = treatedYear + 1 ))
+      fi
+    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 treatedYear PeriodLengthInYears PeriodLengthInMonths year0 month0 i
+
+  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
+    treatedYear=0
+    Length=0
+    i=0
+    for ((i = 0; i < ${PeriodLengthInMonths}; i += 1)) ; do
+
+      (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month0 + i - 12 * treatedYear )) ) ))
+
+      if [ $(( month0 + i )) -ge $(( 12 * (treatedYear + 1) )) ] ; then
+        (( year = year0 + 1 ))
+        (( treatedYear = treatedYear + 1 ))
+      fi
+    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_DaysInCurrentPeriod ()
+#D-* Purpose: Give the numbers of days during the Current prd1 period from grg1 date
+#D-* Usage: IGCM_date_DaysInCurrentPeriod 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_DaysInCurrentPeriod {
+  IGCM_debug_PushStack "IGCM_date_DaysInCurrentPeriod" $@
+
+  typeset Length Period treatedYear PeriodLengthInYears PeriodLengthInMonths year0 i
+
+  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} )
+    month=$( IGCM_date_SupressZeros ${month} )
+    Length=0
+    # if starting after february and using leap calendar
+    # we need to add the number of days of the next year (potentially a leap year)
+    if [ ${month} -gt 2 ] ; then
+      (( year = year + 1 ))
+    fi
+    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} )
+    year0=year
+    treatedYear=0
+    Length=0
+    i=0
+    for ((i = 0; i < ${PeriodLengthInMonths}; i += 1)) ; do
+
+      (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month + i - 12 * treatedYear )) ) ))
+
+      if [ $(( month + i )) -ge $(( 12 * (treatedYear + 1) )) ] ; then
+        (( year = year0 + 1 ))
+        (( treatedYear = treatedYear + 1 ))
+      fi
+    done
+    ;;
+  *D|*d)
+    Length=$( echo ${Period} | sed -e "s/[dD]//" ) ;;
+  *)
+    IGCM_debug_Exit "IGCM_date_DaysInCurrentPeriod " ${Period} " invalid PeriodLength : choose in *Y, *M, *D."
+    IGCM_debug_Verif_Exit_Post ;;
+  esac
+  echo ${Length}
+
+  IGCM_debug_PopStack "IGCM_date_DaysInCurrentPeriod"
+}
+
+#D-#==================================================================
+#D-function IGCM_date_Check
+#D- * Purpose: Check the present file by comparison with a reference file
+function IGCM_date_Check
+{
+  IGCM_debug_PushStack "IGCM_date_Check"
+
+#---------------------
+  if [ ! -n "${libIGCM}" ] ; then
+    echo "Check libIGCM_date ...........................................[ FAILED ]"
+    echo "--Error--> libIGCM variable is not defined"
+    IGCM_debug_Exit "IGCM_date_Check"
+  fi
+
+#---------------------
+  whence -v gawk > /dev/null 2>&1
+  if [ ! $? -eq 0 ] ; then
+    echo "Check libIGCM_date ...........................................[ FAILED ]"
+    echo "--Error--> gawk command is not defined"
+    IGCM_debug_Exit "IGCM_date_Check"
+  fi
+
+#---------------------
+  ${libIGCM}/libIGCM_date/IGCM_date_Test.ksh > /tmp/IGCM_date_Test.$$.ref.failed 2>&1
+
+  if diff /tmp/IGCM_date_Test.$$.ref.failed ${libIGCM}/libIGCM_date/IGCM_date_Test${dY}.ref > /dev/null 2>&1 ; then
+    echo "Check libIGCM_date ...............................................[ OK ]"
+    rm -f /tmp/IGCM_date_Test.$$.ref.failed
+  else
+    echo "Check libIGCM_date ...........................................[ FAILED ]"
+    echo "--Error--> Execution of ${libIGCM}/libIGCM_date/IGCM_date_Test.ksh"
+    echo "           has produced the file IGCM_date_Test.ref.failed"
+    echo "           Please analyse differences with the reference file by typing:"
+    echo "           diff IGCM_date_Test.ref.failed ${libIGCM}/libIGCM_date/IGCM_date_Test${dY}.ref"
+    echo "           Report errors to the author: Sebastien.Denvil@ipsl.jussieu.fr"
+    cat /tmp/IGCM_date_Test.$$.ref.failed
+    IGCM_debug_Exit "IGCM_date_Check"
+  fi
+
+#---------------------
+  IGCM_debug_PopStack "IGCM_date_Check"
+}
+
+#==================================================================
Index: /tags/libIGCM_v2.2/libIGCM_debug/IGCM_debug_Test.ksh
===================================================================
--- /tags/libIGCM_v2.2/libIGCM_debug/IGCM_debug_Test.ksh	(revision 998)
+++ /tags/libIGCM_v2.2/libIGCM_debug/IGCM_debug_Test.ksh	(revision 998)
@@ -0,0 +1,51 @@
+#!/bin/ksh
+
+#**************************************************************
+# Author: Patrick Brockmann
+# Contact: Patrick.Brockmann__at__cea.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+# This script is used to generate a reference file with command :
+# IGCM_debug_Test.ksh > IGCM_debug_Test.ref 2>&1
+# The reference file produced is used by the function IGCM_debug_Check
+# to verify that the libIGCM_debug produce the same results
+
+#=================================================
+cd /tmp
+
+libIGCM=`dirname $0`/..
+typeset TaskType=checking
+. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
+
+#=================================================
+Verbosity=3
+
+Option1="Hello Earth"
+Option2="Hello Mars"
+
+List="${R_ENTREE}/flux_iceberg . ${R_ENTREE}/Albedo.nc ."
+
+#=================================================
+# function IGCM_debug_Print
+
+IGCM_debug_Print 1 ${Option1}
+IGCM_debug_Print 1 ${Option2}
+
+IGCM_debug_Print 2 "A comment at level 2"
+IGCM_debug_Print 3 "A comment at level 3" "Another comment at level 3"
+IGCM_debug_Print 1 "A comment at level 1"
+IGCM_debug_Print 3 "Another comment at level 3"
+IGCM_debug_Print 2 "Another comment at level 2"
+
+IGCM_debug_Print 1 ${List}
+
+#=================================================
+# function IGCM_debug_PrintVariables
+
+IGCM_debug_PrintVariables 1 Option
Index: /tags/libIGCM_v2.2/libIGCM_debug/IGCM_debug_Test.ref
===================================================================
--- /tags/libIGCM_v2.2/libIGCM_debug/IGCM_debug_Test.ref	(revision 998)
+++ /tags/libIGCM_v2.2/libIGCM_debug/IGCM_debug_Test.ref	(revision 998)
@@ -0,0 +1,18 @@
+--Debug1--> Hello
+--Debug1--> Earth
+--Debug1--> Hello
+--Debug1--> Mars
+--------Debug2--> A comment at level 2
+--------------Debug3--> A comment at level 3
+--------------Debug3--> Another comment at level 3
+--Debug1--> A comment at level 1
+--------------Debug3--> Another comment at level 3
+--------Debug2--> Another comment at level 2
+--Debug1--> /flux_iceberg
+--Debug1--> .
+--Debug1--> /Albedo.nc
+--Debug1--> .
+--Debug1--> Option1=Hello
+--Debug1--> Earth
+--Debug1--> Option2=Hello
+--Debug1--> Mars
Index: /tags/libIGCM_v2.2/libIGCM_debug/libIGCM_debug.ksh
===================================================================
--- /tags/libIGCM_v2.2/libIGCM_debug/libIGCM_debug.ksh	(revision 998)
+++ /tags/libIGCM_v2.2/libIGCM_debug/libIGCM_debug.ksh	(revision 998)
@@ -0,0 +1,794 @@
+#!/bin/ksh
+
+#**************************************************************
+# Author: Patrick Brockmann, Martial Mancip
+# Contact: Patrick.Brockmann__at__cea.fr Martial.Mancip__at__ipsl.jussieu.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#==================================================
+# The documentation of this file can be automatically generated
+# if you use the prefix #D- for comments to be extracted.
+# Extract with command: cat lib* | grep "^#D-" | cut -c "4-"
+#==================================================
+
+#==================================================
+# Add high level verbosity
+typeset -i Verbosity=${Verbosity:=3}
+
+#==================================================
+# DEBUG_debug
+# Add low level verbosity
+typeset DEBUG_debug=${DEBUG_debug:=false}
+
+#==================================================
+# GENERATE RANDOM ERROR ; only apply if ( ${DEBUG_debug} )
+typeset RandomError=false
+
+# Stack file containing call tree will be stored there.
+if ( $DEBUG_debug ) ; then
+  if [ X${TaskType} = Xcomputing ]; then
+    typeset StackFileLocation=${StackFileLocation:=${PWD}}
+    typeset StackFileName=computing.stack.$$
+  elif [ X${TaskType} = Xpost-processing ]; then
+    typeset StackFileLocation=${POST_DIR:=${StackFileLocation}}
+    typeset StackFileName=post-processing.stack.$$
+  elif [ X${TaskType} = Xchecking ]; then
+    typeset StackFileLocation=${POST_DIR:=${PWD}}
+    typeset StackFileName=checking.stack.$$
+  else
+    typeset StackFileLocation=${POST_DIR:=${PWD}}
+    typeset StackFileName=checking.stack.$$
+  fi
+
+  if [ -f ${StackFileLocation}/${StackFileName} ] ;
+  then
+    echo "Stack of an libIGCM job :" >> ${StackFileLocation}/${StackFileName}
+  else
+    echo "Stack of an libIGCM job :" >  ${StackFileLocation}/${StackFileName}
+  fi
+fi
+
+#==================================================
+# NULL_STR
+# Default null string
+typeset -r NULL_STR="_0_"
+
+#==================================================
+# libIGCM_CurrentTag
+# Current libIGCM tag, check compatibilty with *.card
+typeset -r libIGCM_CurrentTag="1.0"
+
+#==================================================
+# Exit Flag (internal debug)
+# When true, end the master loop AFTER SAVES FILES
+ExitFlag=false
+
+#==================================================
+# Declare a stack of functions calls
+unset IGCM_debug_Stack
+unset IGCM_debug_StackArgs
+unset IGCM_debug_StackTiming
+IGCM_debug_Stack[0]=${NULL_STR}
+IGCM_debug_StackArgs[0]=${NULL_STR}
+IGCM_debug_StackTiming[0]=${NULL_STR}
+IGCM_debug_LenStack=0
+
+#D-#==================================================================
+#D-function IGCM_debug_getDate_ms
+#D- * Purpose: Give number of milliseconds since 01-jan-1970
+function IGCM_debug_getDate_ms
+{
+  typeset nanosecs ms
+  # nano secondes since 01-jan-1970
+  nanosecs=$( date +%s%N )
+
+  # truncate the last 6 digits to get milliseconds since 01-jan-1970
+  ms=${nanosecs:0:${#nanosecs}-6}
+
+  echo "$ms"
+}
+
+#D-#==================================================================
+#D-function IGCM_debug_sizeOfTabContent
+#D- * Purpose: Give sumed size of a list of files
+#D- * Usage: IGCM_debug_sizeOfTabContent entityList destination
+#D- *        where entityList is a list of files or directory
+#D- *        where dest is either a directory or a file name
+function IGCM_debug_sizeOfTabContent
+{
+  typeset entityListe destination iEntity sizeKo sumSizeKo sumSizeMo
+
+  eval set +A entityListe \${${1}}
+  destination=${2}
+  sumSizeKo=0
+
+  # Here we will try to compute size (file or directory size) from local path and not from archive.
+  for ((i = 0; i < ${#entityListe[*]}; i += 1)) ; do
+    if [ -f ${entityListe[$i]} ] ; then
+      # One file or a bunch of files has been copied without renaming from a visible filesystem
+      iEntity=${entityListe[$i]}
+    elif [ -f ${entityListe[$i]##/*/} ] ; then
+      # One file or a bunch of files has been copied without renaming from an non visible filesystem
+      # remove path /home/login/../ from entityListe elements
+      iEntity=${entityListe[$i]##/*/}
+    elif [ -f ${destination} ] ; then
+      # a file has been copied and renamed
+      iEntity=${destination}
+    elif [ -f ${destination}/${entityListe[$i]##/*/} ] ; then
+      # a copy in a directory but not in ${PWD}
+      iEntity=${destination}/${entityListe[$i]##/*/}
+    elif [ -d ${entityListe[$i]} ] ; then
+      # a directory has been copied from a non remote place
+      iEntity=${entityListe[$i]}
+    elif [ -d ${destination}/${entityListe[$i]##/*/} ] ; then
+      # a directory has been copied from a remote archive and not renamed
+      iEntity=${destination}/${entityListe[$i]##/*/}
+    elif [ -d ${destination} ] ; then
+      # a directory has been copied from a remote archive and renamed
+      iEntity=${destination}
+    fi
+    sizeKo=$( du --apparent-size -sk ${iEntity} | gawk '{print $1}' )
+    sumSizeKo=$(( $sumSizeKo + $sizeKo ))
+  done
+  sumSizeMo=$( echo "scale=6;${sumSizeKo}/1024" | bc )
+  echo "${sumSizeKo}|${sumSizeMo}"
+}
+
+#D-#==================================================================
+#D-function IGCM_debug_send_AMQP_msg__MAILTUNNEL
+#D- * Purpose: Take over AMQP C client using mail as a message recipient
+#D- * One argument : base64 encoded message
+function IGCM_debug_send_AMQP_msg__MAILTUNNEL {
+
+  typeset b64_encoded_msg mail_recipient
+  typeset buffer send_messages mail_frequency 
+  typeset last_mail_date__file
+
+  b64_encoded_msg=$1
+
+  buffer=/tmp/buffer.$$
+  mail_recipient="sebastien.denvil@ipsl.jussieu.fr"
+  send_messages=0
+  mail_frequency=3600 # in seconds
+  # use to keep track when was last mail sent (maybe to be replaced with global variable)
+  last_mail_date__file=/tmp/stamp.$$ 
+
+  # init
+  if [ ! -f "${buffer}" ]; then
+    touch "${buffer}"
+  fi
+
+  # retrieve pending messages number
+  messages_count=$( wc -l ${buffer} | gawk {'print $1'} )
+
+  if [ ! -f "${last_mail_date__file}" ]; then
+    # if we are here, it means no mail has been sent yet
+    # send the first mail
+    [ ${messages_count} -gt 0 ] && send_messages=1
+  else
+     # compute last time the file was changed (in seconds)
+    seconds_since_last_mail=$(( $(date +%s) - $(stat -c %Y ${last_mail_date__file}) ))
+    # send message when exceeding threshold
+    [ ${seconds_since_last_mail} -gt ${mail_frequency} ] && send_messages=1
+  fi
+
+  # queue messages in the buffer
+  echo ${b64_encoded_msg} >> ${buffer}
+
+  # send mail
+  if ( [ ${send_messages} -eq 1 ] || [ X${FlushAMQP} = XTRUE ] ) ; then
+    mail -s "[TEMPORARY AMQP CHANNEL]" ${mail_recipient}  < ${buffer} # send buffer
+    rm -f $buffer ; touch ${buffer}                                   # clear buffer
+    touch ${last_mail_date__file}                                     # memorize last mail date
+  fi
+
+  # Allways all good for now.
+  return 0
+}
+
+#D-#==================================================================
+#D-function IGCM_debug_SendAMQP
+#D- * Purpose: Send body; encoded body and config.card to rabbitMQ
+function IGCM_debug_sendAMQP
+{
+  typeset decal first additionnalOption encodedBody
+
+  # Encode message Body
+  encodedBody=$( echo "${Body}" | base64 -w 0 )
+
+  # Send config.card ?
+  if [ X${1} = Xactivate ] ; then
+    # Encode config.card
+    cat ${SUBMIT_DIR}/config.card | base64 -w 0 > ${SUBMIT_DIR}/config.card.base64
+    # Prepare additionnal option
+    additionnalOption="-f ${SUBMIT_DIR}/config.card.base64"
+  else
+    additionnalOption=
+  fi
+
+  # Only cosmetics : stack file
+  decal=0
+  while [ ${decal} -lt ${IGCM_debug_LenStack} ]; do
+    printf ' ' >> ${StackFileLocation}/${StackFileName}
+    (( decal = decal + 1 ))
+  done
+  # Log to stack file using human readable format
+  echo sendAMQPMsg -h localhost -p 5672 ${additionnalOption} -b "${Body}"      >> ${StackFileLocation}/${StackFileName}
+
+  # Log separately encoded AMQP message command for reuse in a mock up
+  echo sendAMQPMsg -h localhost -p 5672 ${additionnalOption} -b ${encodedBody} >> /tmp/send.AMQP.${jobid}.history.txt
+
+  # Send the message
+  if [ X${BigBrotherChannel} = XMAIL ] ; then
+    IGCM_debug_send_AMQP_msg__MAILTUNNEL "${encodedBody}"
+    status=$?
+  else
+    sendAMQPMsg -h localhost -p 5672 ${additionnalOption} -b ${encodedBody}
+    status=$?
+  fi
+
+  status=$?
+  if [ ${status} -gt 0 ] ; then
+    IGCM_debug_Print 2 "IGCM_debug_Push/PopStack/ActivateBigBro : command sendAMQPMsg failed error code ${status}"
+    echo  sendAMQPMsg -h localhost -p 5672 -b "${Body}"
+    exit
+  fi
+}
+
+#D-#==================================================================
+#D-function IGCM_debug_CallStack
+#D-* Purpose: Print the call stack tree from the oldest to the youngest (opposite of the display standard)
+#D-
+function IGCM_debug_CallStack {
+  if ( $DEBUG_debug ) ; then
+    # Cosmetics
+    typeset i decal
+    i=0
+    until [ $i -eq ${IGCM_debug_LenStack} ]; do
+      decal=0
+      until [ $decal -eq ${i} ]; do
+        printf -- ' '
+        (( decal = decal + 1 ))
+      done
+      echo "$i - ${IGCM_debug_Stack[$(( $IGCM_debug_LenStack-$i-1 ))]}" "(${IGCM_debug_StackArgs[$(( $IGCM_debug_LenStack-$i-1 ))]})"
+      ((i = i + 1))
+    done
+  fi
+}
+
+#D-#==================================================================
+#D-function IGCM_debug_PushStack
+#D-* Purpose: Push a function name in the stack
+#D-
+function IGCM_debug_PushStack {
+  if ( $DEBUG_debug ) ; then
+    typeset decal inputs startTime_ms
+
+    # Only cosmetics : stack file
+    echo >> ${StackFileLocation}/${StackFileName}
+    decal=0
+    while [ ${decal} -lt ${IGCM_debug_LenStack} ]; do
+      printf ' ' >> ${StackFileLocation}/${StackFileName}
+      (( decal = decal + 1 ))
+    done
+
+    # Fill the stack file
+    echo "> ${IGCM_debug_LenStack} : ${@}" >> ${StackFileLocation}/${StackFileName}
+
+    # Save input list in an indexed array
+    INPUTS=( $@ )
+
+    # Get timing information
+    startTime_ms=$( IGCM_debug_getDate_ms )
+
+    # We add function call name on beginning of the stack
+    set +A IGCM_debug_Stack -- ${1} ${IGCM_debug_Stack[*]}
+
+    # Save timing in milliseconds in an indexed array
+    set +A IGCM_debug_StackTiming -- ${startTime_ms} ${IGCM_debug_StackTiming[*]}
+
+    # We include the "null" Args in the beginning of the StackArgs
+    set +A IGCM_debug_StackArgs ${NULL_STR} ${IGCM_debug_StackArgs[*]}
+
+    # Then, we shift StackArgs tabular
+    if [ $# -gt 1 ]; then
+      IGCM_debug_StackArgs[0]=$(echo ${INPUTS[*]:1} | sed -e "s/\ /,/g" )
+    fi
+
+    if [ X${ActivateBigBro} = Xtrue ] ; then
+      # RabbitMQ message code
+      code=2000
+      # RabbitMQ message body
+      Body=$( echo "{\"code\":\"${code}\",\"simuid\":\"${simuid}\",\"jobid\":\"${jobid}\",\"nesting\":\"${IGCM_debug_LenStack}\",\"command\":\"${INPUTS[*]}\",\"timestamp\":\"$( date +"%Y-%m-%d-%T" )\"}" )
+      # Fill the rabbitMQ queue
+      IGCM_debug_sendAMQP
+    fi
+
+    # Increment LenStack
+    (( IGCM_debug_LenStack = IGCM_debug_LenStack + 1 ))
+
+    #IGCM_debug_CallStack
+  fi
+}
+
+#D-#==================================================================
+#D-function IGCM_debug_PopStack
+#D-* Purpose: Pop a function name in the stack
+#D-
+function IGCM_debug_PopStack {
+  if ( $DEBUG_debug ) ; then
+    typeset i decal command arguments startTime_ms endTime_ms
+    typeset instrumentation dest prefix
+    # they are not typeset because they are send "by adress" to son functions
+    # we unset them to avoid "memory effect"
+    unset fileList source
+
+    # INTRODUCE SIMPLE ERROR GENERATOR TO TEST SUPERVISOR
+    # PROBABILITY ERROR IS 0.0001 PER COMMAND OR FUNCTION CALL
+    # THERE ARE ~500 COMMAND OR FUNCTION CALL PER PERIOD
+    if ( ${RandomError} ) ; then
+      if [ $((RANDOM%10000)) -le 10 ] ; then
+        IGCM_debug_Print 1 "Random error has been triggered"
+        echo "RANDOM ERROR" >> ${StackFileLocation}/${StackFileName}
+        ExitFlag=true
+      fi
+    fi
+
+    if [ "${IGCM_debug_Stack[0]}" = "${1}" ]; then
+      # Everything is cool
+
+      # Get timing information
+      endTime_ms=$( IGCM_debug_getDate_ms )
+
+      # Save Stack information before poping the stack
+      command=${IGCM_debug_Stack[0]}
+
+      # Go from comma separated (list) to space separated in an array
+      set -A arguments $( echo ${IGCM_debug_StackArgs[0]} | sed -e "s/,/\ /g" )
+
+      # Save Stack information before poping the stack
+      startTime_ms=${IGCM_debug_StackTiming[0]}
+
+      # Pop the stack
+      (( IGCM_debug_LenStack = IGCM_debug_LenStack - 1 ))
+      set -A IGCM_debug_Stack -- ${IGCM_debug_Stack[*]:1}
+      set -A IGCM_debug_StackArgs -- ${IGCM_debug_StackArgs[*]:1}
+      set -A IGCM_debug_StackTiming -- ${IGCM_debug_StackTiming[*]:1}
+    else
+      echo 'IGCM_debug_Exit : stack is corrupted ! LenStack =' ${IGCM_debug_LenStack}
+      IGCM_debug_Exit $@
+    fi
+
+    # Special actions depending on command to prepare IGCM_debug_PrintInfosActions call
+    # We are interested in:
+    #  0. Which command performs the work
+    #  1. Size of entity we are working with
+    #  2. Where are we reading
+    #  3. Where are we writing
+    #  4. How long it took
+
+    instrumentation=false
+
+    case ${command} in
+    # Classical copy (only files are given to IGCM_sys_Cp as options)
+    IGCM_sys_Cp)
+      instrumentation=true
+      # All but the latest
+      fileList=${arguments[*]:0:${#arguments[*]}-1}
+      # just need the first file to get the directory
+      source=${arguments[0]}
+      # Nothing but the latest
+      dest=${arguments[${#arguments[*]}-1]}
+      # Size of file whose name are stored in a list
+      entitySize=$( IGCM_debug_sizeOfTabContent fileList ${dest} )
+      ;;
+
+    # Copy from archive machine or from buffer
+    IGCM_sys_Get|IGCM_sys_GetBuffer)
+      instrumentation=true
+      if [ ${#arguments[*]} -eq 2 ] ; then
+        source=${arguments[0]}
+        dest=${arguments[1]}
+        # Size of file whose name are stored in a variable
+        entitySize=$( IGCM_debug_sizeOfTabContent source ${dest} )
+      elif ( [ ${#arguments[*]} -eq 3 ] && [ ${arguments[0]} = '/l' ] ) ; then
+        # IGCM_sys_Get /l liste_file[*] /ccc/scratch/cont003/dsm/p86denv/RUN_DIR/985998_14754/
+        # Keep the array name hosting the all list
+        eval set +A fileList \${${arguments[1]}}
+        # just need the first file to get the directory
+        source=${fileList[0]}
+        dest=${arguments[2]}
+        # Size of file whose name are stored in a list
+        entitySize=$( IGCM_debug_sizeOfTabContent fileList[*] ${dest} )
+      elif [ [ ${#arguments[*]} -ge 3 ] ; then
+       # All but the latest
+        fileList=${arguments[*]:0:${#arguments[*]}-1}
+        # just need the first file to get the directory
+        source=${arguments[0]}
+        # Nothing but the latest
+        dest=${arguments[${#arguments[*]}-1]}
+        # Size of file whose name are stored in a list
+        entitySize=$( IGCM_debug_sizeOfTabContent fileList ${dest} )
+      fi
+      ;;
+
+    # Copy from compute node or copy to archive/buffer
+    IGCM_sys_Get_Master|IGCM_sys_Get_Dir|IGCM_sys_Put_Out|IGCM_sys_PutBuffer_Out)
+      instrumentation=true
+      source=${arguments[0]}
+      dest=${arguments[1]}
+      # Size of file whose name are stored in a variable
+      entitySize=$( IGCM_debug_sizeOfTabContent source ${dest} )
+      ;;
+
+    # Rebuild command
+    IGCM_sys_rebuild|IGCM_sys_rebuild_station)
+      instrumentation=true
+      # All but the first
+      fileList=${arguments[*]:1:${#arguments[*]}-1}
+      # just need a file to get the directory
+      source=${arguments[1]}
+      # Nothing but the first
+      dest=${arguments[0]}
+      # Size of file whose name are stored in a list
+      entitySize=$( IGCM_debug_sizeOfTabContent fileList ${dest} )
+      ;;
+
+    # NCO commands
+    IGCM_sys_ncrcat|IGCM_sys_ncecat|IGCM_sys_ncra|IGCM_sys_ncks|IGCM_sys_cdo)
+      # Example of what we want to catch : only filenames in those command lines
+      # IGCM_sys_ncrcat -O -v ${list_var_final_ncrcat} ${OUT_SE[*]} ${RESULT_SE}
+      # IGCM_sys_ncrcat --hst -v ${liste_coord}${var} ${file1} ${liste_file_tmp[*]} ${file_out}
+      # IGCM_sys_ncrcat -p ${dir} ${liste_file_tmp} --output ${output}
+      # IGCM_sys_ncrcat -x -v ${list_var} -p ${dir} ${liste_file_tmp} --output ${output}
+      instrumentation=true
+      keepGoing=true
+      prefix=.
+      i=0
+      while ( ${keepGoing} ) ; do
+        # the last one is not interesting
+        if [ ${i} -eq ${#arguments[*]}-1 ] ; then
+          keepGoing=false
+        # look after "-p" option. Path prefix is the following arguments
+        elif [ ${arguments[${i}]} = "-p" ] ; then
+          ((i = i + 1))
+          prefix=${arguments[${i}]}
+          ((i = i + 1))
+        elif [ ${i} -eq ${#arguments[*]}-1 ] ; then
+          keepGoing=false
+        # looking for files
+        elif [ -f ${prefix}/${arguments[${i}]} ] ; then
+          fileList="${fileList} ${prefix}/${arguments[${i}]}"
+          ((i = i + 1))
+        # other options are not interesting
+        else
+          ((i = i + 1))
+        fi
+      done
+
+      # i value is at least 1
+      # just need one file to get the directory
+      source=$( echo ${fileList} | gawk '{print $1}' )
+      # Nothing but the latest
+      dest=${arguments[${#arguments[*]}-1]}
+      # Size of file whose name are stored in a list
+      entitySize=$( IGCM_debug_sizeOfTabContent fileList ${dest} )
+      ;;
+    esac
+
+    # Print information related to instrumentation
+    ( ${instrumentation} ) && IGCM_debug_PrintInfosActions ${command} ${entitySize} ${startTime_ms} ${endTime_ms} ${dest} ${source}
+
+    # Only cosmetics : stack file
+    decal=0
+    while [ ${decal} -lt ${IGCM_debug_LenStack} ]; do
+      printf ' ' >> ${StackFileLocation}/${StackFileName}
+      (( decal = decal + 1 ))
+    done
+
+    if ( ${ExitFlag} ) ; then
+      # Inform the stack file
+      echo '!!! ExitFlag has been activated !!!' >> ${StackFileLocation}/${StackFileName}
+
+      if [ X${ActivateBigBro} = Xtrue ] ; then
+        # RabbitMQ message code
+        code=9000
+        # RabbitMQ message body
+        Body=$( echo "{\"code\":\"${code}\",\"simuid\":\"${simuid}\",\"jobid\":\"${jobid}\",\"status\":\"NOK\",\"out\":\"true\",\"nesting\":\"${IGCM_debug_LenStack}\",\"command\":\"${INPUTS[*]}\",\"timestamp\":\"$( date +"%Y-%m-%d-%T" )\"}" )
+        # Fill the rabbitMQ queue
+        IGCM_debug_sendAMQP
+      fi
+    else
+      # Inform the stack file
+      echo "< ${IGCM_debug_LenStack} : ${@}" >> ${StackFileLocation}/${StackFileName}
+      if [ X${ActivateBigBro} = Xtrue ] ; then
+        # RabbitMQ message code
+        code=3000
+        # RabbitMQ message body
+        Body=$( echo "{\"code\":\"${code}\",\"simuid\":\"${simuid}\",\"jobid\":\"${jobid}\",\"status\":\"OK\",\"out\":\"true\",\"nesting\":\"${IGCM_debug_LenStack}\",\"command\":\"${INPUTS[*]}\",\"timestamp\":\"$( date +"%Y-%m-%d-%T" )\"}" )
+        # Fill the rabbitMQ queue
+        IGCM_debug_sendAMQP
+      fi
+    fi
+
+    # Reset array if necessary
+    if [ ${IGCM_debug_LenStack} = 0 ]; then
+      #echo
+      #IGCM_debug_Print 3 "Clean stack array"
+      #echo
+      unset IGCM_debug_Stack
+      unset IGCM_debug_StackArgs
+      unset IGCM_debug_StackTiming
+      IGCM_debug_Stack[0]=${NULL_STR}
+      IGCM_debug_StackArgs[0]=${NULL_STR}
+      IGCM_debug_StackTiming[0]=${NULL_STR}
+    fi
+  fi
+  #IGCM_debug_CallStack
+}
+
+#D-#==================================================================
+#D-function IGCM_debug_ActivateBigBro
+#D-* Purpose: switch rabbitMQ on
+#D-
+function IGCM_debug_ActivateBigBro {
+  IGCM_debug_PushStack "IGCM_debug_ActivateBigBro"
+
+  if [ X${BigBrother} = Xtrue ] ; then
+    # ID to identify a simulation
+    simuid=${config_UserChoices_JobName}.${config_UserChoices_ExperimentName}.${config_UserChoices_SpaceName}.${config_UserChoices_TagName}.${LOGIN}.${CENTER}.${MASTER}
+
+    # ID to identify a job. Several Jobs are needed to complete a simulation
+    jobid=${config_UserChoices_JobName}.${config_UserChoices_ExperimentName}.${config_UserChoices_SpaceName}.${config_UserChoices_TagName}.${LOGIN}.${CENTER}.${MASTER}.${CumulPeriod}
+
+    # RabbitMQ message code
+    if ( ${FirstInitialize} ) ; then
+      code=0000
+    else
+      code=1000
+    fi
+    # RabbitMQ message body
+    Body=$( echo "{\"code\":\"${code}\",\"simuid\":\"${simuid}\",\"jobid\":\"${jobid}\",\"status\":\"OK\",\"out\":\"false\",\"nesting\":\"${IGCM_debug_LenStack}\",\"timestamp\":\"$( date +"%Y-%m-%d-%T" )\"}" )
+    # Fill the rabbitMQ queue (specifying config.card must be send)
+    IGCM_debug_sendAMQP activate
+
+    # Turn the flag on
+    ActivateBigBro=true
+  fi
+  IGCM_debug_PopStack "IGCM_debug_ActivateBigBro"
+}
+
+#D-#==================================================================
+#D-function IGCM_debug_Exit
+#D-* Purpose: Print Call Stack and set ExitFlag to true
+#D-
+function IGCM_debug_Exit {
+  IGCM_debug_PushStack "IGCM_debug_Exit"
+  echo "IGCM_debug_Exit : " "${@}"
+  echo
+  echo "!!!!!!!!!!!!!!!!!!!!!!!!!!"
+  echo "!!   ERROR TRIGGERED    !!"
+  echo "!!   EXIT FLAG SET      !!"
+  echo "!------------------------!"
+  echo
+  IGCM_debug_CallStack
+  ExitFlag=true
+  IGCM_debug_PopStack "IGCM_debug_Exit"
+}
+
+#D-#==================================================
+#D-function IGCM_debug_Verif_Exit
+#D-* Purpose: exit with number 1 if ExitFlag is true
+#D-
+function IGCM_debug_Verif_Exit {
+  if ( ${ExitFlag} ) ; then
+    # Plan to send an email here with IGCM_sys_SendMail
+    if [ X${TaskType} != Xchecking ] ; then
+      IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Fatal"
+      echo "IGCM_debug_Verif_Exit : Something wrong happened previously."
+      echo "IGCM_debug_Verif_Exit : ERROR and EXIT keyword will help find out where."
+      echo "                        EXIT THE JOB."
+      echo
+      IGCM_debug_CallStack
+    fi
+
+    if [ X${ActivateBigBro} = Xtrue ] ; then
+      # RabbitMQ message code
+      code=9999
+      # RabbitMQ message body
+      Body=$( echo "{\"code\":\"${code}\",\"simuid\":\"${simuid}\",\"jobid\":\"${jobid}\",\"status\":\"FATAL\",\"timestamp\":\"$( date +"%Y-%m-%d-%T" )\"}" )
+      # Fill the rabbitMQ queue
+      IGCM_debug_sendAMQP
+    fi
+
+    # Not sure about that one ...
+    if ( $DEBUG_debug ) ; then
+      echo "Your files on ${R_OUT} :"
+      IGCM_sys_Tree ${R_SAVE}
+      echo
+    fi
+
+    # Mail notification
+    IGCM_sys_SendMail
+
+    # And Good Bye
+    date
+    exit 1
+  fi
+}
+
+#D-#==================================================
+#D-function IGCM_debug_Verif_Exit_Post
+#D-* Purpose: exit with number 1 if ExitFlag is true for Post-treatment
+#D-
+function IGCM_debug_Verif_Exit_Post {
+  if ( ${ExitFlag} ) ; then
+    echo "IGCM_debug_Verif_Exit_Post : Something wrong happened."
+    # If SpaceName is PROD then we stop if post_processing fails
+    # Plan to send an email here with IGCM_sys_SendMail
+    if [ X${config_UserChoices_SpaceName} = XPROD ] ; then
+      echo "                        EXIT THE JOB."
+      echo
+      # Mail notification
+      #IGCM_sys_SendMailPost
+      # And Good Bye
+      date
+      exit 1
+    else
+      echo "Either inside config.card the variable SpaceName is not in PROD"
+      echo "or inside the main Job the variable JobType is not in RUN mode"
+      echo "              SO WE DO NOT EXIT THE JOB."
+      echo
+      date
+    fi
+  fi
+}
+
+#D-#==================================================================
+#D-function IGCM_debug_Print
+#D-* Purpose: Print arguments according to a level of verbosity.
+#D-
+function IGCM_debug_Print
+{
+  typeset level=$1
+  shift
+
+  if [ X"${1}" = X"-e" ]; then
+    typeset cmd_echo="echo -e"
+    shift
+  else
+    typeset cmd_echo="echo"
+  fi
+
+  if [ ${level} -le ${Verbosity} ] ; then
+    typeset i
+    case "${level}" in
+    1) for i in "$@" ; do
+      ${cmd_echo} $(date +"%Y-%m-%d %T") "--Debug1-->" ${i}
+      done ;;
+    2) for i in "$@" ; do
+      ${cmd_echo} $(date +"%Y-%m-%d %T") "--------Debug2-->" ${i}
+      done ;;
+    3) for i in "$@" ; do
+      ${cmd_echo} $(date +"%Y-%m-%d %T") "--------------Debug3-->" ${i}
+      done ;;
+    esac
+  fi
+}
+
+#D-#==================================================================
+#D-function IGCM_debug_PrintVariables
+#D-* Purpose: Print arguments when match a pattern
+#D-           according to a level of verbosity.
+function IGCM_debug_PrintVariables
+{
+  typeset level=$1
+  shift
+
+  list=$( set | grep ^$1 | sed -e "s/'//g" )
+
+  if [ "X${list}" != X ]  ; then
+    IGCM_debug_Print ${level} ${list}
+  fi
+}
+
+#D-#==================================================================
+#D-function IGCM_debug_PrintInfosActions
+#D-* Purpose: Print information related to instrumentation
+function IGCM_debug_PrintInfosActions
+{
+  typeset actionType=$1
+  typeset entitySize=$2
+  typeset start_ms=$3
+  typeset end_ms=$4
+
+  typeset dest=$5
+  typeset source=$6
+
+  typeset diff_ms entitySizeKo entitySizeMo flux_Ko_ms flux_Ko_s flux_Mo_s
+  typeset name dirOut dirSource
+
+  name="doNotKnow"
+
+  diff_ms=$(( $end_ms - $start_ms ))
+  # echo "diff_ms=$diff_ms"
+
+  entitySizeKo=$( echo ${entitySize} | gawk -F"|" '{print $1}' )
+  # echo "entitySizeKo=$entitySizeKo"
+  entitySizeMo=$( echo ${entitySize} | gawk -F"|" '{print $2}' )
+
+  # flux en Ko / ms
+  flux_Ko_ms=$( echo "scale=6;${entitySizeKo}/${diff_ms}" | bc )
+  # echo "flux_Ko_ms=$flux_Ko_ms"
+
+  # flux en Ko / s
+  flux_Ko_s=$(( $flux_Ko_ms * 1000 ))
+  # echo "flux_Ko_s=$flux_Ko_s"
+
+  # flux en Mo / s
+  flux_Mo_s=$( echo "scale=6;${flux_Ko_s}/1024" | bc )
+  # echo "flux_Mo_s=$flux_Mo_s"
+
+  if [ -d $dest ] ; then
+    dirOut=$( readlink -f ${dest} )
+  else
+    dirOut=$( readlink -f $( dirname ${dest} ) )
+  fi
+
+  if [ -d $source ] ; then
+    dirSource=$( readlink -f ${source} )
+  else
+    dirSource=$( readlink -f $( dirname ${source} ) )
+  fi
+
+  echo "==>act:${actionType}|sz:${entitySizeMo}|ms:${diff_ms}|fx(ko):${flux_Ko_s}|fx(mo):${flux_Mo_s}|nm:${name}|dirSource:${dirSource}|dirOut:${dirOut}"
+}
+
+#D-#==================================================================
+#D-function IGCM_debug_Check
+#D- * Purpose: Check the present file by comparison with a reference file
+function IGCM_debug_Check
+{
+  #---------------------
+  if [ ! -n "${libIGCM}" ] ; then
+    echo "Check libIGCM_debug ..........................................[ FAILED ]"
+    echo "--Error--> libIGCM variable is not defined"
+    exit 2
+  fi
+
+  #---------------------
+  if [ ! -n "${Verbosity}" ] ; then
+    echo "Check libIGCM_debug ..........................................[ FAILED ]"
+    echo "--Error--> Verbosity variable is not defined"
+    exit 3
+  fi
+
+  #---------------------
+  ${libIGCM}/libIGCM_debug/IGCM_debug_Test.ksh > /tmp/IGCM_debug_Test.$$.ref.failed 2>&1
+  sleep 2
+
+  # Remove date stamp.
+  sed -e "s:[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]\:[0-9][0-9]\:[0-9][0-9] ::g" /tmp/IGCM_debug_Test.$$.ref.failed > /tmp/IGCM_debug_Test.$$.ref.failed.nodate
+  mv /tmp/IGCM_debug_Test.$$.ref.failed.nodate /tmp/IGCM_debug_Test.$$.ref.failed
+
+  if diff /tmp/IGCM_debug_Test.$$.ref.failed ${libIGCM}/libIGCM_debug/IGCM_debug_Test.ref > /dev/null 2>&1 ; then
+    echo "Check libIGCM_debug ..............................................[ OK ]"
+    rm -f /tmp/IGCM_debug_Test.$$.ref.failed
+  else
+    echo "Check libIGCM_debug ..........................................[ FAILED ]"
+    echo "--Error--> Execution of ${libIGCM}/libIGCM_debug/IGCM_debug_Test.ksh"
+    echo "           has produced the file IGCM_debug_Test.ref.failed"
+    echo "           Please analyse differences with the reference file by typing:"
+    echo "           diff IGCM_debug_Test.ref.failed ${libIGCM}/libIGCM_debug/IGCM_debug_Test.ref"
+    echo "           Report errors to the author: Patrick.Brockmann@cea.fr"
+    cat /tmp/IGCM_debug_Test.$$.ref.failed
+    exit 4
+  fi
+  #---------------------
+}
Index: /tags/libIGCM_v2.2/libIGCM_ensemble/libIGCM_ensemble.ksh
===================================================================
--- /tags/libIGCM_v2.2/libIGCM_ensemble/libIGCM_ensemble.ksh	(revision 998)
+++ /tags/libIGCM_v2.2/libIGCM_ensemble/libIGCM_ensemble.ksh	(revision 998)
@@ -0,0 +1,605 @@
+#!/bin/ksh
+
+#**************************************************************
+# Author: Sonia Labetoulle
+# Contact: Sonia.Labetoulle__at__locean-ipsl.upmc.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2012)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+function IGCM_ensemble_CastInit
+{
+  IGCM_debug_PushStack "IGCM_ensemble_CastInit"
+
+  set -A Alpha      A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
+  set -A AlphaMonth a b c d e f g h i j k l
+
+  IGCM_sys_Mkdir ${RUN_DIR}
+
+  IGCM_sys_Cp ${SUBMIT_DIR}/config.card   ${RUN_DIR}
+  IGCM_sys_Cp ${SUBMIT_DIR}/ensemble.card ${RUN_DIR}
+  IGCM_sys_Cp ${SUBMIT_DIR}/Job_*         ${RUN_DIR}
+  IGCM_sys_Cp ${SUBMIT_DIR}/run.card.init ${RUN_DIR}
+
+  # Useful?
+  #if [ -f  ${SUBMIT_DIR}/CreatedDir.txt ] ; then
+  #  IGCM_sys_Cp ${SUBMIT_DIR}/CreatedDir.txt ${RUN_DIR}
+  #fi
+  # Useful?
+  #if [ -f  ${SUBMIT_DIR}/Qsub.txt ] ; then
+  #  IGCM_sys_Cp ${SUBMIT_DIR}/Qsub.txt ${RUN_DIR}
+  #fi
+
+  IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB actif
+  IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB NAME
+  IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB DEBUT_INIT
+  IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB FIN_INIT
+  IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB PERIODICITE
+  IGCM_card_DefineArrayFromOption    ${FileName} Ens_PERTURB NONPERIODIC
+  IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB DUREE
+  IGCM_card_DefineArrayFromOption    ${FileName} Ens_PERTURB DUREE_NONPERIODIC
+  IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB MEMBER
+  IGCM_card_DefineArrayFromOption    ${FileName} Ens_PERTURB PERTURB_BIN
+  IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB INITFROM
+  IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB INITPATH
+  IGCM_card_DefineVariableFromOption config.card UserChoices TagName
+  IGCM_card_DefineVariableFromOption config.card UserChoices CalendarType
+  IGCM_card_DefineArrayFromSection   config.card ListOfComponents
+
+  echo
+  IGCM_debug_Print 1 "ACTIVE            = ${ensemble_Ens_PERTURB_actif}"
+  IGCM_debug_Print 1 "NAME              = ${ensemble_Ens_PERTURB_NAME}"
+  IGCM_debug_Print 1 "DEBUT_INIT        = ${ensemble_Ens_PERTURB_DEBUT_INIT}"
+  IGCM_debug_Print 1 "FIN_INIT          = ${ensemble_Ens_PERTURB_FIN_INIT}"
+  IGCM_debug_Print 1 "PERIODICITE       = ${ensemble_Ens_PERTURB_PERIODICITE}"
+  IGCM_debug_Print 1 "NONPERIODIC       = ${ensemble_Ens_PERTURB_NONPERIODIC[*]}"
+  IGCM_debug_Print 1 "DUREE             = ${ensemble_Ens_PERTURB_DUREE}"
+  IGCM_debug_Print 1 "DUREE_NONPERIODIC = ${ensemble_Ens_PERTURB_DUREE_NONPERIODIC[*]}"
+  IGCM_debug_Print 1 "MEMBER            = ${ensemble_Ens_PERTURB_MEMBER}"
+  IGCM_debug_Print 1 "PERTURB_BIN       = ${ensemble_Ens_PERTURB_PERTURB_BIN[*]}"
+  IGCM_debug_Print 1 "INITFROM          = ${ensemble_Ens_PERTURB_INITFROM}"
+  IGCM_debug_Print 1 "INITPATH          = ${ensemble_Ens_PERTURB_INITPATH}"
+  IGCM_debug_Print 1 "TagName           = ${config_UserChoices_TagName}"
+  IGCM_debug_Print 1 "CalendarType      = ${config_UserChoices_CalendarType}"
+  IGCM_debug_Print 1 "ListOfComponents  = ${config_ListOfComponents[*]}"
+
+  PerturbExe=${ensemble_Ens_PERTURB_PERTURB_BIN[0]}
+  PerturbComp=${ensemble_Ens_PERTURB_PERTURB_BIN[1]}
+  PerturbFile=${ensemble_Ens_PERTURB_PERTURB_BIN[2]}
+  PerturbVar=${ensemble_Ens_PERTURB_PERTURB_BIN[3]}
+  PerturbAmp=${ensemble_Ens_PERTURB_PERTURB_BIN[4]}
+
+  IGCM_debug_Print 1 "PerturbExe  = ${PerturbExe}"
+  IGCM_debug_Print 1 "PerturbFile = ${PerturbFile}"
+  IGCM_debug_Print 1 "PerturbComp = ${PerturbComp}"
+  IGCM_debug_Print 1 "PerturbVar  = ${PerturbVar}"
+  IGCM_debug_Print 1 "PerturbAmp  = ${PerturbAmp}"
+
+  # A few checks Period case:
+
+  # ... Check PERIODICITE ...
+  case ${ensemble_Ens_PERTURB_PERIODICITE} in
+  _0_)
+    IGCM_debug_Print 1 "periodic start not active"
+    CastPeriodicStart=false
+    ;;
+  *[Yy]|*[Mm])
+    CastPeriodicStart=true
+    IGCM_debug_Print 1 "Periodic length : ${ensemble_Ens_PERTURB_PERIODICITE}" ;;
+  *)
+    IGCM_debug_Exit "IGCM_ensemble_CastInit ${ensemble_Ens_PERTURB_PERIODICITE} : invalid PERIODICITE"
+    IGCM_debug_Exit "Choose a value in *Y or *M"
+    IGCM_debug_Verif_Exit ;;
+  esac
+# ... Check DUREE ...
+  case ${ensemble_Ens_PERTURB_DUREE} in
+  *[Yy]|*[Mm])
+    IGCM_debug_Print 1 "Periodic duration : ${ensemble_Ens_PERTURB_DUREE}" ;;
+  *)
+    IGCM_debug_Exit "IGCM_ensemble_CastInit ${ensemble_Ens_PERTURB_DUREE} invalid DUREE"
+    IGCM_debug_Exit "Choose a value in choose in *Y or *M"
+    IGCM_debug_Verif_Exit ;;
+  esac
+
+  # A few checks for the Non-Periodic case:
+  DateNum=0
+  while [ $DateNum -lt ${#ensemble_Ens_PERTURB_NONPERIODIC[*]} ] ; do
+
+    # - Check DUREE_NONPERIODIC
+    case ${ensemble_Ens_PERTURB_DUREE_NONPERIODIC[$DateNum]} in
+    _0_)
+      IGCM_debug_Print 1 "non-periodic start not active"
+      CastNonPeriodicStart=false
+      ;;
+    *[Yy]|*[Mm])
+      IGCM_debug_Print 1 "Non-periodic duration : ${ensemble_Ens_PERTURB_DUREE_NONPERIODIC[$DateNum]}"
+      CastNonPeriodicStart=true
+      ;;
+    *)
+      IGCM_debug_Exit "IGCM_ensemble_CastInit ${ensemble_Ens_PERTURB_DUREE_NONPERIODIC[$DateNum]} : invalid DUREE"
+      IGCM_debug_Exit "choose in *Y or *M"
+      IGCM_debug_Verif_Exit ;;
+    esac
+    (( DateNum = DateNum + 1 ))
+  done
+
+  # Need to know all the restart filename of the component we will apply the noise to
+  IGCM_card_DefineArrayFromOption config.card ListOfComponents ${PerturbComp}
+  eval compname=\${config_ListOfComponents_${PerturbComp}[0]} > /dev/null 2>&1
+
+  # Target the component's card we apply the noise to
+  card=${SUBMIT_DIR}/COMP/${compname}.card
+
+  # Read the restart file list. To be used later
+  IGCM_card_DefineArrayFromOption ${card} RestartFiles List
+  ListFilesName=${compname}_RestartFiles_List
+  eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1
+  eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1
+
+  # Check
+  IGCM_debug_Print 1 "Nb Restart Files  = ${NbFiles}"
+
+  IGCM_debug_PopStack "IGCM_ensemble_CastInit"
+}
+
+function IGCM_ensemble_CastPeriodicStarts
+{
+  IGCM_debug_PushStack "IGCM_ensemble_CastPeriodicStarts"
+
+  [ ${CastPeriodicStart} = false ] && return
+
+  echo
+  IGCM_debug_Print 1 "Manage periodic starts"
+
+#.. Manage periodic starts ..
+#   ======================
+
+# ... Loop over DateBegin ...
+  eval DateBegin=\${ensemble_Ens_PERTURB_DEBUT_INIT}
+
+  while [ ${DateBegin} -le ${ensemble_Ens_PERTURB_FIN_INIT} ] ; do
+    IGCM_date_GetYearMonth ${DateBegin} year month
+
+  # - Determine number of day(s) in PERIODICITE
+    PeriodLengthInDays=$( IGCM_date_DaysInCurrentPeriod ${DateBegin} ${ensemble_Ens_PERTURB_PERIODICITE} )
+
+  # - Determine number of day(s) in DUREE
+    DureeLengthInDays=$(( $( IGCM_date_DaysInCurrentPeriod ${DateBegin} ${ensemble_Ens_PERTURB_DUREE} ) - 1 ))
+
+  # - Determine DateEnd
+    (( DateEnd = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${DureeLengthInDays} ) ))
+
+  # - Build directory name
+    IGCM_ensemble_CastDirectoryName ${ensemble_Ens_PERTURB_NAME} ${ensemble_Ens_PERTURB_PERIODICITE} $year $month $StartDir
+
+  # - Determine RestartDate
+    (( Offset = -1 ))
+    (( RestartDate = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${Offset} ) ))
+
+    IGCM_debug_Print 2 "${DateBegin} => ${DateEnd} : ${StartDir}"
+    echo "${DateBegin} ${DateEnd} ${StartDir}" >> ${RUN_DIR}/CreatedDir.txt
+
+  # - Create directory for current DateBegin
+    if [ ! -d  ${StartDir} ] ; then
+      IGCM_sys_Mkdir ${SUBMIT_DIR}/${StartDir}
+      IGCM_sys_Cd ${SUBMIT_DIR}/${StartDir}
+      ln -s ../../.resol .
+      ln -s ../../.libmpi .
+      IGCM_sys_Cd ${RUN_DIR}
+    fi
+
+  # - Create directory to store modified restart files
+    RestartDir=${STORAGE}/IGCM_IN/${config_UserChoices_TagName}/${StartDir}
+    IGCM_sys_MkdirArchive ${RestartDir}
+
+  # - Loop over members
+    i=0
+    while [ $i -lt ${ensemble_Ens_PERTURB_MEMBER} ] ; do
+      MemberDir="${StartDir}${Alpha[$i]}"
+      echo
+      IGCM_debug_Print 3 "${MemberDir}"
+
+      JobName="Job_${MemberDir}"
+
+    # * Create directory if it doesn't exist and copy/link files
+      if [ ! -d  ${SUBMIT_DIR}/${StartDir}/${MemberDir} ] ; then
+        IGCM_sys_Mkdir ${SUBMIT_DIR}/${StartDir}/${MemberDir}
+        #IGCM_sys_Cp -r COMP/ PARAM/ ${StartDir}/${MemberDir}
+        IGCM_sys_Cd ${SUBMIT_DIR}/${StartDir}/${MemberDir}
+        ln -s ../../COMP
+        ln -s ../../PARAM
+        ln -s ../../POST
+        IGCM_sys_Cd ${RUN_DIR}
+        IGCM_sys_Cp config.card run.card.init ${SUBMIT_DIR}/${StartDir}/${MemberDir}
+        IGCM_sys_Cp Job_${ensemble_Ens_PERTURB_NAME} ${SUBMIT_DIR}/${StartDir}/${MemberDir}/${JobName}
+
+        # Dump command to be lauched
+        echo "cd ${StartDir}/${MemberDir}/ ;"  >> ${RUN_DIR}/Qsub.${StartDir}.txt
+        echo "${SUBMIT} ${JobName} ; cd -"     >> ${RUN_DIR}/Qsub.${StartDir}.txt
+      fi
+
+    # * Update files : config.card, Job_, COMP/comp.card
+      IGCM_ensemble_CastFilesUpdate ${DateBegin} ${DateEnd} ${RestartDate}
+
+    # * Apply noise on restart file
+      IGCM_ensemble_CastPerturbFile
+
+      (( i = i + 1 ))
+    done
+
+    # Done. Save ${StartDir} submission text file
+    IGCM_sys_Cp ${RUN_DIR}/Qsub.${StartDir}.txt ${SUBMIT_DIR}
+
+  # - Next DateBegin
+    echo "$DateBegin  $PeriodLengthInDays"
+    case ${ensemble_Ens_PERTURB_PERIODICITE} in
+    *[Yy]|*[Mm])
+      (( DateBegin = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${PeriodLengthInDays} ) ))
+      ;;
+    esac
+    echo "New DateBegin = $DateBegin"
+    echo "========================================================================"
+  done
+  IGCM_debug_PopStack "IGCM_ensemble_CastPeriodicStarts"
+}
+
+function IGCM_ensemble_CastNonPeriodicStarts
+{
+  IGCM_debug_PushStack "IGCM_ensemble_CastNonPeriodicStarts"
+
+  #.. Manage non periodic starts => Loop over DateBegin ..
+  #   ==========================
+
+  [ ${CastNonPeriodicStart} = false ] && return
+
+  echo
+  IGCM_debug_Print 1 "Manage non periodic starts"
+
+  DateNum=0
+# ... Loop over ensemble_Ens_PERTURB_NONPERIODIC ...
+  echo ">${DateNum}<"
+  echo ">${#ensemble_Ens_PERTURB_NONPERIODIC[*]}<"
+  while [ $DateNum -lt ${#ensemble_Ens_PERTURB_NONPERIODIC[*]} ] ; do
+    DateBegin=${ensemble_Ens_PERTURB_NONPERIODIC[$DateNum]}
+    Duree=${ensemble_Ens_PERTURB_DUREE_NONPERIODIC[$DateNum]}
+    echo ">${DateBegin}<"
+    echo ">${Duree}<"
+
+  # - Determine number of day(s) in DUREE_NONPERIODIC
+    IGCM_date_GetYearMonth ${DateBegin} year month
+    DureeLengthInDays=$(( $( IGCM_date_DaysInCurrentPeriod ${DateBegin} ${Duree} ) - 1 ))
+
+  # - Build directory name
+    echo "========================================================================"
+    echo "ensemble_Ens_PERTURB_NAME = ${ensemble_Ens_PERTURB_NAME}"
+    IGCM_ensemble_CastDirectoryName ${ensemble_Ens_PERTURB_NAME} ${Duree} $year $month $StartDir
+
+  # - Determine DateEnd
+    (( DateEnd = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${DureeLengthInDays} ) ))
+    echo ">${DateEnd}<"
+    echo "tout va bien 1"
+
+  # - Determine RestartDate
+    (( Offset = -1 ))
+    (( RestartDate = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${Offset} ) ))
+
+    IGCM_debug_Print 2 "${DateBegin} => ${DateEnd} : ${StartDir}"
+
+  # -  Does $StartDir already exist ?
+    #echo "tout va bien 2" ${StartDir}
+    if [ ! -d ${SUBMIT_DIR}/${StartDir} ] ; then
+      echo "create dir"
+      IGCM_sys_Mkdir ${SUBMIT_DIR}/${StartDir}
+      IGCM_sys_Cd ${SUBMIT_DIR}/${StartDir}
+      ln -s ../../.resol .
+      ln -s ../../.libmpi .
+      IGCM_sys_Cd ${RUN_DIR}
+      echo "${DateBegin} ${DateEnd} ${StartDir}" >> ${RUN_DIR}/CreatedDir.txt
+    fi
+    PeriodDateEnd=$( grep -m1 ${StartDir} ${RUN_DIR}/CreatedDir.txt | cut -f2 -d\  )
+
+  # - Create directory in which to store new restart files if it does'nt already exist
+    RestartDir=${STORAGE}/IGCM_IN/${config_UserChoices_TagName}/${StartDir}
+    IGCM_sys_MkdirArchive ${RestartDir}
+
+  # - Loop over members
+    i=0
+    while [ $i -lt ${ensemble_Ens_PERTURB_MEMBER} ] ; do
+      MemberDir="${StartDir}${Alpha[$i]}"
+      IGCM_debug_Print 3 "${MemberDir}"
+
+      JobName="Job_${MemberDir}"
+
+    # * Create directory if it doesn't exist and copy files
+      if [ ! -d  ${SUBMIT_DIR}/${StartDir}/${MemberDir} ] ; then
+        IGCM_sys_Mkdir ${SUBMIT_DIR}/${StartDir}/${MemberDir}
+        #IGCM_sys_Cp -r COMP/ PARAM/ ${StartDir}/${MemberDir}
+        IGCM_sys_Cd ${SUBMIT_DIR}/${StartDir}/${MemberDir}
+        ln -s ../../COMP
+        ln -s ../../PARAM
+        ln -s ../../POST
+        IGCM_sys_Cd ${RUN_DIR}
+        IGCM_sys_Cp config.card run.card.init ${SUBMIT_DIR}/${StartDir}/${MemberDir}
+        IGCM_sys_Cp Job_${ensemble_Ens_PERTURB_NAME} ${SUBMIT_DIR}/${StartDir}/${MemberDir}/Job_${MemberDir}
+
+        # Dump command to be lauched
+        echo "cd ${StartDir}/${MemberDir}/ ;"  >> Qsub.${StartDir}.txt
+        echo "${SUBMIT} ${JobName} ; cd -"     >> Qsub.${StartDir}.txt
+      fi
+
+    # * Update files : config.card, Job_, COMP/comp.card
+      echo "${PeriodDateEnd} ? ${DateEnd}"
+      if [ ${PeriodDateEnd} -gt ${DateEnd} ] ; then
+        DateEnd=${PeriodDateEnd}
+      fi
+      IGCM_ensemble_CastFilesUpdate ${DateBegin} ${DateEnd} ${RestartDate}
+
+    # * Apply noise on restart file
+      IGCM_ensemble_CastPerturbFile
+      (( i = i + 1 ))
+    done
+
+    # Done. Save ${StartDir} submission text file
+    IGCM_sys_Cp ${RUN_DIR}/Qsub.${StartDir}.txt ${SUBMIT_DIR}
+
+    (( DateNum = DateNum + 1 ))
+  done
+  IGCM_debug_PopStack "IGCM_ensemble_CastNonPeriodicStarts"
+}
+
+function IGCM_ensemble_CastFilesUpdate
+{
+  IGCM_debug_PushStack "IGCM_ensemble_CastFilesUpdate"
+
+  # Debug Print :
+  echo
+  IGCM_debug_Print 1 "IGCM_ensemble_CastFilesUpdate :"
+
+  HumanDateBegin=$(   IGCM_date_ConvertFormatToHuman ${1} )
+  HumanDateEnd=$(     IGCM_date_ConvertFormatToHuman ${2} )
+  HumanRestartDate=$( IGCM_date_ConvertFormatToHuman ${3} )
+  # ==> config.card
+  IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Ensemble EnsembleRun 'y'
+  IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Ensemble EnsembleName ${ensemble_Ens_PERTURB_NAME}
+  IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Ensemble EnsembleDate ${StartDir}
+
+  IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card UserChoices JobName   ${MemberDir}
+  IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card UserChoices DateBegin ${HumanDateBegin}
+  IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card UserChoices DateEnd   ${HumanDateEnd}
+  IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Restarts OverRule "n"
+
+  for comp in ${config_ListOfComponents[*]} ; do
+    IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${comp} Restart "y"
+    IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${comp} RestartDate ${HumanRestartDate}
+    IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${comp} RestartJobName ${ensemble_Ens_PERTURB_INITFROM}
+    IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${comp} RestartPath ${ensemble_Ens_PERTURB_INITPATH}
+  done
+
+  # ==> Job
+  sed -e "s/\(#.*\)${ensemble_Ens_PERTURB_NAME}\( *#.*\)/\1${MemberDir} \2/"            \
+      -e "s/\(#.*Script_Output_\)${ensemble_Ens_PERTURB_NAME}\(\.*\)/\1${MemberDir}\2/" \
+      -e "s/^PeriodNb=.*/PeriodNb=60/"                                                  \
+      ${SUBMIT_DIR}/${StartDir}/${MemberDir}/Job_${MemberDir} > Job_${MemberDir}.tmp
+  IGCM_sys_Mv Job_${MemberDir}.tmp ${SUBMIT_DIR}/${StartDir}/${MemberDir}/Job_${MemberDir}
+
+  IGCM_debug_PopStack "IGCM_ensemble_CastFilesUpdate"
+}
+
+function IGCM_ensemble_CastDirectoryName
+{
+  IGCM_debug_PushStack "IGCM_ensemble_CastDirectoryName"
+
+  #.. Debug Print ..
+  echo
+  IGCM_debug_Print 1 "IGCM_ensemble_CastDirectoryName :"
+  echo
+
+  Name=$1
+  Duree=$2
+  year=$3
+  month=$4
+
+  # - Build directory name
+  case ${Duree} in
+    *Y|*y)
+      siecle="$( echo $year | cut -c1-2 )"
+      siecle=$( (( $siecle - 18 )) )
+      StartYear="${siecle}$( echo $year | cut -c3-4 )"
+      StartDir="${Name}${StartYear}"
+      ;;
+    *M|*m)
+      echo $month
+      siecle="$( echo $year | cut -c1-2 )"
+      siecle=$( (( $siecle - 18 )) )
+      StartYear="${siecle}$( echo $year | cut -c3-4 )"
+      StartMonth="${AlphaMonth[ (( 10#${month} - 1 )) ]}"
+      StartDir="${Name}${StartYear}${StartMonth}"
+      ;;
+  esac
+
+  IGCM_debug_PopStack "IGCM_ensemble_CastDirectoryName"
+}
+
+function IGCM_ensemble_CastPerturbFile
+{
+  IGCM_debug_PushStack "IGCM_ensemble_CastPerturbFile"
+
+  typeset i i_ j j4 file_out file_out_
+
+  #.. Debug Print ..
+  echo
+  IGCM_debug_Print 1 "IGCM_ensemble_CastPerturbFile :"
+
+  #.. FileIn ? => RestartDate ..
+  DirIn="${ensemble_Ens_PERTURB_INITPATH}/${ensemble_Ens_PERTURB_INITFROM}/${PerturbComp}/Restart"
+  DirInTar="${ensemble_Ens_PERTURB_INITPATH}/${ensemble_Ens_PERTURB_INITFROM}/RESTART"
+  FileIn="${ensemble_Ens_PERTURB_INITFROM}_${RestartDate}_${PerturbFile}"
+  DirOut="${RestartDir}/${MemberDir}/${PerturbComp}/Restart"
+
+  # * Create member restart directory
+  IGCM_sys_TestDirArchive ${DirOut}
+  RET=$?
+  if [ $RET -gt 0 ] ; then
+    IGCM_sys_MkdirArchive ${DirOut}
+  fi
+
+  FileOut="${MemberDir}_${RestartDate}_${PerturbFile}"
+  IGCM_debug_Print 1 "FileIn  = ${DirIn}/${FileIn}"
+  IGCM_debug_Print 1 "FileOut = ${DirOut}/${FileOut}.nc"
+
+  IGCM_sys_TestFileArchive ${DirOut}/${FileOut}.nc
+  RET=$?
+  if [ $RET -gt 0 ] ; then
+
+    # * Look for the restart file we apply the noise to
+
+    # restart file list pertaining to the component we apply the noise to
+    # but not being the precise restart file we will apply the noise to
+    unset OtherFileInList
+    # generic restart filename list (like flxat, sstoc, restart, ...)
+    unset OtherGenericList
+
+    if ( [ X${FileName0} != X${NULL_STR} ] && [ X${FileName0} != XNONE ] ) ; then
+      (( i=0 ))
+      until [ $i -ge ${NbFiles} ]; do
+
+        (( i_ = i+1 ))
+        eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1
+        eval file_out=${file_out_}
+
+        generic_restart_file_name_out=$( basename ${file_out} .nc )
+
+        if [ ! ${generic_restart_file_name_out} = ${PerturbFile} ] ; then
+          set +A OtherFileInList ${OtherFileInList[*]} ${PerturbComp}_${ensemble_Ens_PERTURB_INITFROM}_${RestartDate}_${generic_restart_file_name_out}\*.nc
+          set +A OtherGenericList ${OtherGenericList[*]} ${generic_restart_file_name_out}
+        fi
+
+        (( i=i+3 ))
+      done
+    fi
+    # How many restart files other than the one we will apply the noise to
+    NbOtherFiles=${#OtherGenericList[*]}
+
+    ##########################
+    # TO BE A FUNCTION BEGIN #
+    ##########################
+
+    if [ $( IGCM_sys_TestFileBuffer ${DirIn}/${FileIn}*.nc ; echo $? ) = 0 ] ; then
+      IGCM_debug_Print 3 "Buffered restart"
+      Buffered=true
+      Archived=false
+      Tared=false
+      nb_restart_file=$(IGCM_sys_CountFileBuffer ${DirIn}/${FileIn}_????.nc)
+    elif [ $( IGCM_sys_TestFileArchive ${DirIn}/${FileIn}*.nc ; echo $? ) = 0 ] ; then
+      IGCM_debug_Print 3 "Archived restart"
+      Buffered=false
+      Archived=true
+      Tared=false
+      nb_restart_file=$(IGCM_sys_CountFileArchive ${DirIn}/${FileIn}_????.nc)
+    else
+      IGCM_debug_Print 3 "Tared restart"
+      Buffered=false
+      Archived=false
+      Tared=true
+
+      # Look for the tar file we want if we did not found it already
+      for PotentialTarFile in $( find ${ensemble_Ens_PERTURB_INITPATH}/${ensemble_Ens_PERTURB_INITFROM}/RESTART -name "${ensemble_Ens_PERTURB_INITFROM}_*restart*.tar" -print ) ; do
+        IsMatching=$( echo ${PotentialTarFile##*/} | sed "s:_restart::" | sed "s:^${ensemble_Ens_PERTURB_INITFROM}_::" | sed "s:\.tar$::" | gawk -F_ -v restartdate=${RestartDate} '{if (($1 <= restartdate) && ($2 >= restartdate)) {print $1"_"$2}}' )
+        if [ ! X${IsMatching} = X ] ; then
+          TarFileFound=${PotentialTarFile}
+          break
+        fi
+      done
+
+      # Extract relevant restart files
+      IGCM_debug_Print 1 "tar xvf ${TarFileFound} ${PerturbComp}_${FileIn}*.nc ${OtherFileInList[*]}"
+      tar xvf ${TarFileFound} ${PerturbComp}_${FileIn}*.nc ${OtherFileInList[*]}
+      nb_restart_file=$( IGCM_sys_CountFileBuffer ${PerturbComp}_${FileIn}_????.nc )
+    fi
+
+    # Move around and perturb restart files so as to be able to start hindcast/forecast simulation members
+    if [ ${nb_restart_file} -gt 1 ] ; then
+      j=0
+      until [ $j -ge ${nb_restart_file} ]; do
+        j4=${j}
+        if [ X${Buffered} = Xtrue ] ; then
+          IGCM_sys_GetBuffer ${DirIn}/${FileIn}_${j4}.nc ${RUN_DIR}/${FileOut}_${j4}.nc
+
+          cd ${DirOut}
+          for generic in ${OtherGenericList[*]} ; do
+            ln -s ${DirIn}/${ensemble_Ens_PERTURB_INITFROM}_${RestartDate}_${generic}.nc ${MemberDir}_${RestartDate}_${generic}_${j4}.nc
+          done
+          cd -
+
+        elif [ X${Archived} = Xtrue ] ; then
+          IGCM_sys_Get ${DirIn}/${FileIn}_${j4}.nc ${RUN_DIR}/${FileOut}_${j4}.nc
+
+          for generic in ${OtherGenericList[*]} ; do
+            IGCM_sys_RshArchive "cd ${DirOut} ; ln -s ${DirIn}/${ensemble_Ens_PERTURB_INITFROM}_${RestartDate}_${generic}.nc ${MemberDir}_${RestartDate}_${generic}_${j4}.nc"
+          done
+
+        elif [ X${Tared} = Xtrue ] ; then
+          IGCM_sys_Mv ${PerturbComp}_${FileIn}_${j4}.nc ${RUN_DIR}/${FileOut}_${j4}.nc
+
+          for generic in ${OtherGenericList[*]} ; do
+            IGCM_sys_Mv ${PerturbComp}_${ensemble_Ens_PERTURB_INITFROM}_${RestartDate}_${generic}.nc ${DirOut}/${MemberDir}_${RestartDate}_${generic}_${j4}.nc
+          done
+
+        fi
+        (( j=j+1 ))
+      done
+    else
+      if [ X${Buffered} = Xtrue ] ; then
+        IGCM_sys_GetBuffer ${DirIn}/${FileIn}.nc ${RUN_DIR}/${FileOut}.nc
+
+        cd ${DirOut}
+        for generic in ${OtherGenericList[*]} ; do
+          ln -s ${DirIn}/${ensemble_Ens_PERTURB_INITFROM}_${RestartDate}_${generic}.nc ${MemberDir}_${RestartDate}_${generic}.nc
+        done
+        cd -
+
+      elif [ X${Archived} = Xtrue ] ; then
+        IGCM_sys_Get ${DirIn}/${FileIn}.nc ${RUN_DIR}/${FileOut}.nc
+
+        for generic in ${OtherGenericList[*]} ; do
+          IGCM_sys_RshArchive "cd ${DirOut} ; ln -s ${DirIn}/${ensemble_Ens_PERTURB_INITFROM}_${RestartDate}_${generic}.nc ${MemberDir}_${RestartDate}_${generic}.nc"
+        done
+
+      elif [ X${Tared} = Xtrue ] ; then
+        IGCM_sys_Mv ${PerturbComp}_${FileIn}.nc ${RUN_DIR}/${FileOut}.nc
+
+        for generic in ${OtherGenericList[*]} ; do
+          IGCM_sys_Mv ${PerturbComp}_${ensemble_Ens_PERTURB_INITFROM}_${RestartDate}_${generic}.nc ${DirOut}/${MemberDir}_${RestartDate}_${generic}.nc
+        done
+
+      fi
+    fi
+
+    ########################
+    # TO BE A FUNCTION END #
+    ########################
+
+    IGCM_sys_Chmod 644 ${RUN_DIR}/${FileOut}.nc
+    IGCM_debug_Print 1 "${PerturbExe} ${RUN_DIR}/${FileOut}.nc ${PerturbVar} ${PerturbAmp}"
+    echo
+    ${PerturbExe} ${RUN_DIR}/${FileOut}.nc ${PerturbVar} ${PerturbAmp} > /dev/null 2>&1
+
+    if [ $? -ne 0 ] ; then
+      IGCM_debug_Exit "Abend $( basename ${PerturbExe} )"
+      IGCM_debug_Verif_Exit
+    fi
+    IGCM_sys_Put_Out ${RUN_DIR}/${FileOut}.nc ${DirOut}/ 644
+  fi
+
+  #.. Update config.card..
+  IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${PerturbComp} Restart "y"
+  IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${PerturbComp} RestartDate    ${HumanRestartDate}
+  IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${PerturbComp} RestartJobName ${MemberDir}
+  IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${PerturbComp} RestartPath    ${RestartDir}/
+
+  IGCM_debug_PopStack "IGCM_ensemble_CastPerturbFile"
+}
Index: /tags/libIGCM_v2.2/libIGCM_post/IGCM_Patch_20070220_histcom_time_axis.ksh
===================================================================
--- /tags/libIGCM_v2.2/libIGCM_post/IGCM_Patch_20070220_histcom_time_axis.ksh	(revision 998)
+++ /tags/libIGCM_v2.2/libIGCM_post/IGCM_Patch_20070220_histcom_time_axis.ksh	(revision 998)
@@ -0,0 +1,71 @@
+#!/bin/ksh
+
+#**************************************************************
+# Author: Martial Mancip
+# Contact: Martial.Mancip__at__ipsl.jussieu.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+# We keep only first time axis as time_counter !!!!
+#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+function IGCM_Patch_20070220_histcom_time_axis {
+    IGCM_debug_PushStack "IGCM_Patch_histcom_time_axis" $@
+
+    typeset file AXISt AXISt_i VARName var ATTN ATTNV VAR_AXISt VAR_AXISt_i
+
+    ncdump -h ${1} > ${1}_ncdump-h
+    set +A AXISt $(cat ${1}_ncdump-h | grep 't_ave_.*(time_counter)' | sed -e 's/[[:space:]]float t_ave_\([0-9]*\).*/\1/')
+    # liste => tous les axes de temps vont s'appeler time_counter !!
+    if [ $? -eq 0 ] ; then
+
+	file=t_$1
+	IGCM_sys_Mv ${1} ${file}
+	IGCM_sys_Chmod 644 ${file}
+
+	if [ ${#AXISt[*]} -gt 1 ] ; then
+	    echo "WARNING : for file ${1} we have more than one time axis !"
+	    echo "We choose first one ! = t_ave_${AXISt[0]}."
+	fi
+        #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+        # We keep only first time axis as time_counter !!!!
+        #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+	AXISt_i=${AXISt[0]}
+	# Rename time_counter variable
+	IGCM_sys_ncrename -O --hst -v t_ave_${AXISt_i},time_counter ${file}
+	ncdump -h ${file} > ${file}_ncdump-h
+
+	# We have also to rename variables indexed by this time value
+        # liste => pb avec deux variables indéxées par deux valeurs de temps différentes => même nom au final!
+	set +A VAR_AXISt $( cat ${file}_ncdump-h | grep "[[:space:]]*[a-z]* [a-zA-Z_]*${AXISt_i}(.*) ;" | sed -e "s/[[:space:]]*[a-z]* \([a-zA-Z_]*\)_${AXISt_i}(.*) ;/\1/" )
+	for VAR_AXISt_i in ${VAR_AXISt[*]} ; do
+	    IGCM_sys_ncrename -O --hst -v ${VAR_AXISt_i}_${AXISt_i},${VAR_AXISt_i} ${file}
+	done
+
+        # A-t-on besoin de renommer les attributs des autres variables ??
+	# Rename relative associate string in other variables
+
+	set +A VARName $( cat ${file}_ncdump-h | grep "[0-9a-zA-Z_]*.*:associate.*" | grep "t_ave_${AXISt_i}" | sed -e "s/[[:space:]]*\(.*\):associate.*/\1/" )
+	for var in ${VARName[*]} ; do 
+	    # Old attribute value
+	    ATTN=$( cat ${file}_ncdump-h | grep "${var}:associate.*" | grep "t_ave_${AXISt_i}" | sed -e "s/.*:associate = \"\(.*\)\" ;/\1/" )
+	    # New attribute value
+	    ATTNV=$( echo ${ATTN} | sed -e "s/t_ave_${AXISt_i}/time_counter/" ) #| sed -e 's/[[:space:]]/\\ /g')
+	    # change it !
+	    IGCM_sys_ncatted -O --hst -a associate,${var},m,c,"${ATTNV}" ${file}
+	done
+	IGCM_debug_Verif_Exit_Post
+	IGCM_sys_Mv ${file} ${1}
+	IGCM_sys_Rm ${file}_ncdump-h
+    fi
+    IGCM_sys_Rm ${1}_ncdump-h
+    
+    IGCM_debug_PopStack "IGCM_Patch_histcom_time_axis"
+}
Index: /tags/libIGCM_v2.2/libIGCM_post/IGCM_Patch_20090317_histcom__Fillvalue.ksh
===================================================================
--- /tags/libIGCM_v2.2/libIGCM_post/IGCM_Patch_20090317_histcom__Fillvalue.ksh	(revision 998)
+++ /tags/libIGCM_v2.2/libIGCM_post/IGCM_Patch_20090317_histcom__Fillvalue.ksh	(revision 998)
@@ -0,0 +1,36 @@
+#!/bin/ksh
+
+#**************************************************************
+# Author: Martial Mancip
+# Contact: Martial.Mancip__at__ipsl.jussieu.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+# We change _Fillvalue to old missing_value    !!!!
+#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+function IGCM_Patch_20090317_histcom__Fillvalue {
+    IGCM_debug_PushStack "IGCM_Patch_histcom__Fillvalue" $@
+ 
+    typeset file
+
+    file=t_$1
+    IGCM_sys_Mv ${1} ${file}
+    IGCM_sys_Chmod 644 ${file}
+
+    #IGCM_sys_ncrename -O --hst -a _Fillvalue,missing_value ${file}
+
+    miss=$( ncdump -h ${file} | grep _Fillvalue | head -1 | awk "-F=" '{print $2}' |  awk "-Ff" '{print $1}' )
+
+    [ ! X${miss} = X ] && IGCM_sys_ncatted -a missing_value,,c,f,${miss} ${file} 
+
+    IGCM_sys_Mv ${file} ${1}
+    
+    IGCM_debug_PopStack "IGCM_Patch_histcom__Fillvalue"
+}
Index: /tags/libIGCM_v2.2/libIGCM_post/IGCM_Patch_20090407_histcom_time_axis.ksh
===================================================================
--- /tags/libIGCM_v2.2/libIGCM_post/IGCM_Patch_20090407_histcom_time_axis.ksh	(revision 998)
+++ /tags/libIGCM_v2.2/libIGCM_post/IGCM_Patch_20090407_histcom_time_axis.ksh	(revision 998)
@@ -0,0 +1,71 @@
+#!/bin/ksh
+
+#**************************************************************
+# Author: Martial Mancip
+# Contact: Martial.Mancip__at__ipsl.jussieu.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+# We keep only first time axis as time_counter !!!!
+#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+function IGCM_Patch_20090407_histcom_time_axis {
+    IGCM_debug_PushStack "IGCM_Patch_histcom_time_axis" $@
+
+    typeset file AXISt AXISt_i VARName var ATTN ATTNV VAR_AXISt VAR_AXISt_i
+
+    ncdump -h ${1} > ${1}_ncdump-h
+    set +A AXISt $(cat ${1}_ncdump-h | grep 't_ave_.*(time_counter)' | sed -e 's/[[:space:]][fd][lo][ou][ab][tl][ e] *t_ave_\([0-9]*\).*/\1/')
+    # liste => tous les axes de temps vont s'appeler time_counter !!
+    if [ $? -eq 0 ] ; then
+
+	file=t_$1
+	IGCM_sys_Mv ${1} ${file}
+	IGCM_sys_Chmod 644 ${file}
+
+	if [ ${#AXISt[*]} -gt 1 ] ; then
+	    echo "WARNING : for file ${1} we have more than one time axis !"
+	    echo "We choose first one ! = t_ave_${AXISt[0]}."
+	fi
+        #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+        # We keep only first time axis as time_counter !!!!
+        #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+	AXISt_i=${AXISt[0]}
+	# Rename time_counter variable
+	IGCM_sys_ncrename -O --hst -v t_ave_${AXISt_i},time_counter ${file}
+	ncdump -h ${file} > ${file}_ncdump-h
+
+	# We have also to rename variables indexed by this time value
+        # liste => pb avec deux variables indéxées par deux valeurs de temps différentes => même nom au final!
+	set +A VAR_AXISt $( cat ${file}_ncdump-h | grep "[[:space:]]*[a-z]* [a-zA-Z_]*${AXISt_i}(.*) ;" | sed -e "s/[[:space:]]*[a-z]* \([a-zA-Z_]*\)_${AXISt_i}(.*) ;/\1/" )
+	for VAR_AXISt_i in ${VAR_AXISt[*]} ; do
+	    IGCM_sys_ncrename -O --hst -v ${VAR_AXISt_i}_${AXISt_i},${VAR_AXISt_i} ${file}
+	done
+
+        # A-t-on besoin de renommer les attributs des autres variables ??
+	# Rename relative associate string in other variables
+
+	set +A VARName $( cat ${file}_ncdump-h | grep "[0-9a-zA-Z_]*.*:associate.*" | grep "t_ave_${AXISt_i}" | sed -e "s/[[:space:]]*\(.*\):associate.*/\1/" )
+	for var in ${VARName[*]} ; do 
+	    # Old attribute value
+	    ATTN=$( cat ${file}_ncdump-h | grep "${var}:associate.*" | grep "t_ave_${AXISt_i}" | sed -e "s/.*:associate = \"\(.*\)\" ;/\1/" )
+	    # New attribute value
+	    ATTNV=$( echo ${ATTN} | sed -e "s/t_ave_${AXISt_i}/time_counter/" ) #| sed -e 's/[[:space:]]/\\ /g')
+	    # change it !
+	    IGCM_sys_ncatted -O --hst -a associate,${var},m,c,"${ATTNV}" ${file}
+	done
+	IGCM_debug_Verif_Exit_Post
+	IGCM_sys_Mv ${file} ${1}
+	IGCM_sys_Rm ${file}_ncdump-h
+    fi
+    IGCM_sys_Rm ${1}_ncdump-h
+    
+    IGCM_debug_PopStack "IGCM_Patch_histcom_time_axis"
+}
Index: /tags/libIGCM_v2.2/libIGCM_post/IGCM_Patch_20091030_histcom_time_axis.ksh
===================================================================
--- /tags/libIGCM_v2.2/libIGCM_post/IGCM_Patch_20091030_histcom_time_axis.ksh	(revision 998)
+++ /tags/libIGCM_v2.2/libIGCM_post/IGCM_Patch_20091030_histcom_time_axis.ksh	(revision 998)
@@ -0,0 +1,87 @@
+#!/bin/ksh
+
+#**************************************************************
+# Author: Martial Mancip
+# Contact: Martial.Mancip__at__ipsl.jussieu.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+# We keep only first time axis as time_counter !!!!
+#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+function IGCM_Patch_20091030_histcom_time_axis {
+    IGCM_debug_PushStack "IGCM_Patch_histcom_time_axis" $@
+
+    typeset file AXISt AXISt_i VARName var ATTN ATTNV VAR_AXISt VAR_AXISt_i
+
+    ncdump -h ${1} > ${1}_ncdump-h
+    set +A AXISt $(cat ${1}_ncdump-h | grep 't_ave_.*(time_counter)' | sed -e 's/[[:space:]][fd][lo][ou][ab][tl][ e] *t_ave_\([0-9a-zA-Z]*\).*/\1/')
+    # liste => tous les axes de temps vont s'appeler time_counter !!
+    if [ $? -eq 0 ] ; then
+      if [ ${#AXISt[*]} -ge 1 ] ; then
+
+	file=t_$1
+	IGCM_sys_Mv ${1} ${file}
+	IGCM_sys_Chmod 644 ${file}
+
+	if [ ${#AXISt[*]} -gt 1 ] ; then
+	    echo "WARNING : for file ${1} we have more than one time axis !"
+	    echo "We choose first one ! = t_ave_${AXISt[0]}."
+	fi
+        #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+        # We keep only first time axis as time_counter !!!!
+        #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+	AXISt_i=${AXISt[0]}
+	# Rename time_counter variable
+	IGCM_sys_ncrename -O --hst -v t_ave_${AXISt_i},time_counter ${file}
+	ncdump -h ${file} > ${file}_ncdump-h
+
+	# We have also to rename variables indexed by this time value
+        # liste => pb avec deux variables indéxées par deux valeurs de temps différentes => même nom au final!
+	set +A VAR_AXISt $( cat ${file}_ncdump-h | grep "[[:space:]]*[a-z]* [a-zA-Z_]*${AXISt_i}(.*) ;" | sed -e "s/[[:space:]]*[a-z]* \([a-zA-Z_]*\)_${AXISt_i}(.*) ;/\1/" )
+	for VAR_AXISt_i in ${VAR_AXISt[*]} ; do
+	    IGCM_sys_ncrename -O --hst -v ${VAR_AXISt_i}_${AXISt_i},${VAR_AXISt_i} ${file}
+	done
+
+        # A-t-on besoin de renommer les attributs des autres variables ??
+	# Rename relative associate string in other variables
+
+	set +A VARName $( cat ${file}_ncdump-h | grep "[0-9a-zA-Z_]*.*:associate.*" | grep "t_ave_${AXISt_i}" | sed -e "s/[[:space:]]*\(.*\):associate.*/\1/" )
+	for var in ${VARName[*]} ; do 
+	    # Old attribute value
+	    ATTN=$( cat ${file}_ncdump-h | grep "${var}:associate.*" | grep "t_ave_${AXISt_i}" | sed -e "s/.*:associate = \"\(.*\)\" ;/\1/" )
+	    # New attribute value
+	    ATTNV=$( echo ${ATTN} | sed -e "s/t_ave_${AXISt_i}/time_counter/" ) #| sed -e 's/[[:space:]]/\\ /g')
+	    # change it !
+	    IGCM_sys_ncatted -O --hst -a associate,${var},m,c,"${ATTNV}" ${file}
+	done
+
+        # Rename coordinates attribut from t_ave_xxxx to time_counter
+
+        set +A VARName $( cat ${file}_ncdump-h | grep "[0-9a-zA-Z_]*.*:coordinates.*" | grep "t_ave_${AXISt_i}" | sed -e "s/[[:space:]]*\(.*\):coordinates.*/\1/" )
+        for var in ${VARName[*]} ; do
+            # Old attribute value
+            ATTN=$( cat ${file}_ncdump-h | grep "${var}:coordinates.*" | grep "t_ave_${AXISt_i}" | sed -e "s/.*:coordinates = \"\(.*\)\" ;/\1/" )
+            # New attribute value
+            ATTNV=$( echo ${ATTN} | sed -e "s/t_ave_${AXISt_i}/time_counter/" ) #| sed -e 's/[[:space:]]/\\ /g')
+            # change it ! 
+	    IGCM_sys_ncatted -O --hst -a coordinates,${var},m,c,"${ATTNV}" ${file}
+        done
+
+
+	IGCM_debug_Verif_Exit_Post
+	IGCM_sys_Mv ${file} ${1}
+	IGCM_sys_Rm ${file}_ncdump-h
+      fi
+    fi
+    IGCM_sys_Rm ${1}_ncdump-h
+    
+    IGCM_debug_PopStack "IGCM_Patch_histcom_time_axis"
+}
Index: /tags/libIGCM_v2.2/libIGCM_post/IGCM_Patch_20091116_ncks_ncra.ksh
===================================================================
--- /tags/libIGCM_v2.2/libIGCM_post/IGCM_Patch_20091116_ncks_ncra.ksh	(revision 998)
+++ /tags/libIGCM_v2.2/libIGCM_post/IGCM_Patch_20091116_ncks_ncra.ksh	(revision 998)
@@ -0,0 +1,56 @@
+#!/bin/ksh
+
+#**************************************************************
+# Author: Marie-Alice Foujols
+# Contact: Marie-Alice.Foujols__at__ipsl.jussieu.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2009)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#------------------------------------------------------------
+# ncks CPL files for 1D frequency, ncra for 1M averaged files
+#------------------------------------------------------------
+
+function IGCM_Patch_20091116_ncks_ncra {
+    IGCM_debug_PushStack "IGCM_Patch_ncks_ncra" $@
+
+    CPL_OkDay=y
+    CPL_OkMonth=y
+
+    PREFIX=TEMPO
+    if [ -f FIRST_TIME_CPL ] ; then
+       echo FIRST_TIME_CPL exists
+    else
+       # create FIRST_TIME_CPL file
+       date > FIRST_TIME_CPL
+
+       #ls -l S*_out.*.nc C*_out.*.nc
+
+       rm -f ${PREFIX}_*_cpl_*.nc 
+
+       for file in S*_out.*.nc C*_out.*.nc
+       do
+           [[ ${CPL_OkDay}   = "y" ]] && IGCM_sys_ncks -A ${file} ${PREFIX}_1D_cpl_atm.nc  > /dev/null 2>&1
+           [[ ${CPL_OkMonth} = "y" ]] && IGCM_sys_ncra -A ${file} ${PREFIX}_1M_cpl_atm.nc  > /dev/null 2>&1
+       done
+       rm -f S*_out.*.nc C*_out.*.nc
+
+       #ls -l O*_out.*.nc
+
+       for file in O*_out.*.nc
+       do
+           [[ ${CPL_OkDay}   = "y" ]] && IGCM_sys_ncks -A ${file} ${PREFIX}_1D_cpl_oce.nc   > /dev/null 2>&1
+           [[ ${CPL_OkMonth} = "y" ]] && IGCM_sys_ncra -A ${file} ${PREFIX}_1M_cpl_oce.nc   > /dev/null 2>&1
+       done
+       rm -f O*_out.*.nc
+
+       #ls -s ${PREFIX}_*_cpl_*.nc 
+
+     fi
+    
+    IGCM_debug_PopStack "IGCM_Patch_ncks_ncra"
+}
Index: /tags/libIGCM_v2.2/libIGCM_post/IGCM_Patch_20091118_mask.ksh
===================================================================
--- /tags/libIGCM_v2.2/libIGCM_post/IGCM_Patch_20091118_mask.ksh	(revision 998)
+++ /tags/libIGCM_v2.2/libIGCM_post/IGCM_Patch_20091118_mask.ksh	(revision 998)
@@ -0,0 +1,147 @@
+#!/bin/ksh
+
+#**************************************************************
+# Author: Arnaud Caubel
+# Contact: Arnaud.Caubel__at__lsce.ipsl.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2009)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#------------------------------------------------------------
+# Add mask from meshmask file to oceanic variables
+#------------------------------------------------------------
+
+function IGCM_Patch_20091118_mask {
+
+    IGCM_debug_PushStack "IGCM_Patch_mask" $@
+
+    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}
+
+    chaineT=${filename%%'grid_T'*}
+    chaineU=${filename%%'grid_U'*}
+    chaineV=${filename%%'grid_V'*}
+    chaineW=${filename%%'grid_W'*}
+    chaineIce=${filename%%'icemod'*}
+    chaineTrc=${filename%%'ptrc_T'*}
+    chaineDia=${filename%%'diad_T'*}
+    chaineBio=${filename%%'dbio_T'*}
+
+    if [ ${filename} != ${chaineT} ]; then
+	mask='tmask' ; depth='deptht'
+    elif [ ${filename} != ${chaineU} ]; then
+	mask='umask' ; depth='depthu'
+    elif [ ${filename} != ${chaineV} ]; then
+	mask='vmask' ; depth='depthv'
+    elif [ ${filename} != ${chaineW} ]; then
+	mask='tmask' ; depth='depthw'
+    elif [ ${filename} != ${chaineIce} ]; then
+	mask='tmask' ; depth='deptht'
+    elif [ ${filename} != ${chaineTrc} ]; then
+	mask='tmask' ; depth='deptht'
+    elif [ ${filename} != ${chaineDia} ]; then
+	mask='tmask' ; depth='deptht'
+    elif [ ${filename} != ${chaineBio} ]; then
+	mask='tmask' ; depth='deptht'
+    fi
+
+    #============================================
+    # Remove nav_lon, nav_lat file
+    IGCM_sys_ncks -Oh -x -v nav_lon,nav_lat ${filename} file1.nc
+
+    #============================================
+    # Extract mask variable
+    IGCM_sys_ncks -Oh -v ${mask} ${config_UserChoices_JobName}_mesh_mask.nc mask3D.nc
+
+    #============================================
+    # Rename deptht dimension
+    IGCM_sys_ncrename -Oh -d z,${depth} mask3D.nc
+
+    #============================================
+    # Remove single dimension t
+    IGCM_sys_ncwa -Oh -a t mask3D.nc mask3D.nc
+
+    #============================================
+    # Create mask2D 
+    IGCM_sys_ncks -Oh -d ${depth},0,0 mask3D.nc mask2D.nc
+    IGCM_sys_ncwa -Oh -a ${depth} mask2D.nc mask2D.nc
+    IGCM_sys_ncrename -h -v ${mask},mask2D mask2D.nc
+
+    #============================================
+    # Append mask (2D) to file1.nc
+    IGCM_sys_ncks -Ah -c -v mask2D mask2D.nc file1.nc
+
+    if [ ${filename} = ${chaineIce} ]; then
+
+        #============================================
+        # Append mask (3D) only for oceanic files
+	IGCM_sys_ncks -Ah -v ${mask} mask3D.nc file1.nc
+	IGCM_sys_ncrename -h -v ${mask},mask3D file1.nc
+
+        #============================================
+        # Add record dimension only for oceanic files
+	IGCM_sys_ncecat -Oh file1.nc file1.nc
+
+        #============================================
+        # Apply mask 3D only for oceanic files
+	IGCM_sys_ncwa -Oh -a record -B 'mask3D==1' file1.nc file2.nc
+	IGCM_sys_Rm file1.nc
+	IGCM_sys_Mv file2.nc file1.nc
+
+
+    fi
+
+    #============================================
+    # Add record dimension
+    IGCM_sys_ncecat -Oh file1.nc file1.nc
+
+    #============================================
+    # Apply mask 2D
+    IGCM_sys_ncwa -Oh -b -a record -B 'mask2D==1' file1.nc file1.nc
+
+    #============================================
+    # Permute record dimension in time_counter dimension
+    IGCM_sys_ncpdq -Oh -a time_counter,record file1.nc file1.nc
+    IGCM_sys_ncwa -Oh -a record file1.nc file1.nc
+
+    #============================================
+    # Remove mask 2D and 3D for oceanic files, and mask 2D only for ice files
+    
+    if [ ${filename} = ${chaineIce} ]; then
+        #============================================
+        # Remove mask 2D and mask 3D for oceanic files
+        IGCM_sys_ncks -Oh -x -v mask2D,mask3D file1.nc file_mask.nc
+    else
+        #============================================
+        # Remove mask 2D for ice files
+        IGCM_sys_ncks -Oh -x -v mask2D file1.nc file_mask.nc
+    fi
+
+    #============================================
+    # Add nav_lon nav_lat
+    IGCM_sys_ncks -Ah -v nav_lon,nav_lat ${filename} file_mask.nc
+
+    #============================================
+    # Cleaning
+    IGCM_debug_Verif_Exit_Post
+    IGCM_sys_Mv file_mask.nc ${filename}
+    IGCM_sys_Rm mask3D.nc mask2D.nc file1.nc
+    
+    IGCM_debug_PopStack "IGCM_Patch_mask"
+}
Index: /tags/libIGCM_v2.2/libIGCM_post/IGCM_Patch_20091119_put_out.ksh
===================================================================
--- /tags/libIGCM_v2.2/libIGCM_post/IGCM_Patch_20091119_put_out.ksh	(revision 998)
+++ /tags/libIGCM_v2.2/libIGCM_post/IGCM_Patch_20091119_put_out.ksh	(revision 998)
@@ -0,0 +1,23 @@
+#!/bin/ksh
+
+#**************************************************************
+#**************************************************************
+# Author: Marie-Alice Foujols
+# Contact: Marie-Alice.Foujols__at__ipsl.jussieu.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2009)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#------------------------------------------------------------
+# to put_out the result of IGCM_Patch_20091116_ncks_ncra.ksh
+#------------------------------------------------------------
+
+function IGCM_Patch_20091119_put_out {
+    IGCM_debug_PushStack "IGCM_Patch_put_out" $@
+
+    IGCM_debug_PopStack "IGCM_Patch_put_out"
+}
Index: /tags/libIGCM_v2.2/libIGCM_post/IGCM_Patch_20101208_nudge_interp.ksh
===================================================================
--- /tags/libIGCM_v2.2/libIGCM_post/IGCM_Patch_20101208_nudge_interp.ksh	(revision 998)
+++ /tags/libIGCM_v2.2/libIGCM_post/IGCM_Patch_20101208_nudge_interp.ksh	(revision 998)
@@ -0,0 +1,160 @@
+#!/bin/ksh
+
+#**************************************************************
+# Author: Josefine Ghattas
+# Contact: Josefine.Ghattas__at__ipsl.jussieu.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+#
+# Interpolation of monthly input ERAI files to the actual model grid.
+#
+# The patch should be applied once for each variable to interpolate. The file start.nc must be present in lmdz.car OutputFiles.
+# In lmdz.card all monthly ERAI files for the actual year to be interpolated must be present at format var_month_year.nc, where var=[u,v], 
+# month=[1,13]. The file var_13_year.nc correspond to january the following year.
+# Partial year can be interpolated.
+# 
+#
+function IGCM_Patch_20101208_nudge_interp {
+    IGCM_debug_PushStack "IGCM_Patch_nudge_interp" $@
+
+###################################################################################################
+# 1 - Define variables
+# Filein is the first month to interpolate for a variable.
+# Filein name should be at format X_Y_ZZZZ.nc, where X=varaiable name [u,v,ta], Y=[1,13] and ZZZZ=year.
+# To do one year complete for one variable X, 13 month must be present.
+###################################################################################################
+    filein=${1}
+
+# Define startfile containg the destination grid. This file must exist in the OutputFiles list in lmdz.card. 
+    startfile=start.nc
+
+# Determine which variable and year concerned by this patch
+    var=$( echo ${filein} | awk '-F_' '{print $1}' )
+    year=$( echo ${filein} | awk '-F_' '{print $3}' | awk '-F.nc' '{print $1}' )
+    echo var=$var year=$year
+
+###################################################################################################
+# 2 - Interpolate all files for the actual varaiable.
+#     Original files will be overritten.
+###################################################################################################
+    filelist=${var}_*.nc
+    echo 'filelist 1 = ' ${filelist}
+    for file in ${filelist}; do
+	month=$( echo ${file} | awk '-F_' '{print $2}' | awk '-F_' '{print $1}' )
+	echo 'era2gcm for file = ' ${file} 
+	IGCM_era2gcm ${file} tmp_${file} ${var} ${year}
+	IGCM_sys_Mv tmp_${file} ${file}
+    done
+
+###################################################################################################
+# 3 - Add a final time step in each file, coming from the first time step in following month
+###################################################################################################
+    filelist=${var}_*.nc
+    echo 'filelist 2 = ' ${filelist}
+    for file in ${filelist}; do
+	month=$( echo ${file} | awk '-F_' '{print $2}' | awk '-F_' '{print $1}' )
+	month_next=`expr $month + 1`
+	file_next=${var}_${month_next}_${year}.nc
+	if [ -f ${file_next} ] ; then
+	    echo First time step from file ${file_next} will be added last in file ${file}
+	    ncks -O -d THOUR,0,0 ${file_next} tmp.nc
+	    ncrcat -O $file tmp.nc tmptot.nc
+	    IGCM_sys_Mv tmptot.nc $file
+	else
+	    echo Next file ${file_next} does not exist. Nothing will be done for ${file}
+	fi
+    done
+
+###################################################################################################
+# 4 - Remove 13'th month
+###################################################################################################
+    if [ -f ${var}_13_${year}.nc ] ; then
+	echo Remove file ${var}_13_${year}.nc
+	IGCM_sys_Rm ${var}_13_${year}.nc
+    fi
+
+    IGCM_debug_PopStack "IGCM_Patch_nudge_interp"
+}
+
+
+function IGCM_era2gcm {
+#set -xv
+# Function that does a linear interpolation of the variable in 
+# filein towards the destionation grid in gridfile. Results in are 
+# stored in fileout.
+    IGCM_debug_PushStack "IGCM_era2gcm" $@
+
+###################################################################
+# 1 - Define variables
+###################################################################
+    filein=$1
+    fileout=$2
+    varin=$3
+    year=$4
+
+# Define file with destination grid
+    gridfile=start.nc
+    
+# Find time boundaries
+    tmin=1
+    tmax=`ncdump -h ${filein} | grep time | head -1 | awk ' { print $6 } '`
+    tmax=$( echo ${tmax} | awk '-F(' '{print $2}' )
+    
+# Choose grid and output variable name 
+    if [ ${varin} = 'u' ] ; then 
+	varout=uwnd
+	grille='grille_u'
+    elif [ ${varin} = 'v' ] ; then 
+	varout=vwnd
+	grille='grille_v'
+    elif [ ${varin} = 'ta' ] ; then 
+	varout=air
+	grille='grille_t'
+    elif [ ${varin} = 'r' ] ; then 
+	varout=rh
+	grille='grille_t'
+    elif [ ${varin} = 'msl' ] ; then 
+	varout=sp
+	grille='grille_t'
+    else 
+	echo Error : ${varin} unknown!!!!
+	exit
+    fi 
+
+###################################################################
+# 2 - Create ferret script for interpolation
+###################################################################
+    cat << eod >  ${varin}.jnl
+set memory/size=50
+
+use ${gridfile}
+use ${filein}
+let ${varout}=${varin}
+
+define axis/t=01-JAN-${year}:31-DEC-${year}:6/units=hours thour
+
+define grid/like=${varout}[d=2]/x=cu[d=1]/y=cu[d=1] grille_u
+define grid/like=${varout}[d=2]/x=cv[d=1]/y=cv[d=1] grille_v
+define grid/like=${varout}[d=2]/x=cv[d=1]/y=cu[d=1] grille_t
+
+save/clobber/file=${fileout} ${varout}[d=2,g=${grille},l=1,gt=thour@asn]
+repeat/l=1:${tmax} save/file="${fileout}"/append ${varout}[d=2,g=${grille},gt=thour@asn]
+
+exit
+eod
+    
+###################################################################
+# 3 - Launch interpolation with ferret
+###################################################################
+    ferret -nojnl <<eod >  /dev/null
+go ${varin}.jnl
+quit
+eod
+
+    IGCM_debug_PopStack "IGCM_era2gcm"    
+}
Index: /tags/libIGCM_v2.2/libIGCM_post/IGCM_Patch_20140206_ncks_ncra.ksh
===================================================================
--- /tags/libIGCM_v2.2/libIGCM_post/IGCM_Patch_20140206_ncks_ncra.ksh	(revision 998)
+++ /tags/libIGCM_v2.2/libIGCM_post/IGCM_Patch_20140206_ncks_ncra.ksh	(revision 998)
@@ -0,0 +1,50 @@
+#!/bin/ksh
+
+#**************************************************************
+# Author: Marie-Alice Foujols
+# Contact: Marie-Alice.Foujols__at__ipsl.jussieu.fr
+# $Revision:: 397                                      $ Revision of last commit
+# $Author:: sdipsl                                     $ Author of last commit
+# $Date:: 2010-12-08 14:38:46 +0100 (Wed, 08 Dec 2010) $ Date of last commit
+# IPSL (2009)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#------------------------------------------------------------
+# ncks CPL files for 1D frequency, ncra for 1M averaged files
+#------------------------------------------------------------
+
+function IGCM_Patch_20140206_ncks_ncra {
+    IGCM_debug_PushStack "IGCM_Patch_ncks_ncra" $@
+
+    CPL_OkDay=y
+    CPL_OkMonth=y
+
+    PREFIX=TEMPO
+    if [ -f FIRST_TIME_CPL ] ; then
+       echo FIRST_TIME_CPL exists
+    else
+       # create FIRST_TIME_CPL file
+       date > FIRST_TIME_CPL
+
+       rm -f ${PREFIX}_*_cpl_*.nc 
+
+       for file in S*lmdz.x*.nc C*lmdz.x*.nc
+       do
+           [[ ${CPL_OkDay}   = "y" ]] && IGCM_sys_ncks -A ${file} ${PREFIX}_1D_cpl_atm.nc  > /dev/null 2>&1
+           [[ ${CPL_OkMonth} = "y" ]] && IGCM_sys_ncra -A ${file} ${PREFIX}_1M_cpl_atm.nc  > /dev/null 2>&1
+       done
+       rm -f S*lmdz.x*.nc C*lmdz.x*.nc
+
+       for file in O*oceanx*.nc
+       do
+           [[ ${CPL_OkDay}   = "y" ]] && IGCM_sys_ncks -A ${file} ${PREFIX}_1D_cpl_oce.nc   > /dev/null 2>&1
+           [[ ${CPL_OkMonth} = "y" ]] && IGCM_sys_ncra -A ${file} ${PREFIX}_1M_cpl_oce.nc   > /dev/null 2>&1
+       done
+       rm -f O*oceanx*.nc
+
+     fi
+    
+    IGCM_debug_PopStack "IGCM_Patch_ncks_ncra"
+}
Index: /tags/libIGCM_v2.2/libIGCM_post/check_expe_files_size.sh
===================================================================
--- /tags/libIGCM_v2.2/libIGCM_post/check_expe_files_size.sh	(revision 998)
+++ /tags/libIGCM_v2.2/libIGCM_post/check_expe_files_size.sh	(revision 998)
@@ -0,0 +1,320 @@
+#!/bin/sh
+##set -xv
+# stephane.senesi 'at' meteo.fr, CNRM-GAME/GMGEC, mars-avril 2010
+doc="\nScript d'analyse des fichiers d'un repertoire pour y trouver des formes \n\
+de nom de fichier avec dates, les dates, et des sequences de dates. \n\
+On synthetise la
+\n\n\t Syntaxe : $(basename $0) [-d] [-v/q] [-R] [-Z] dir [-S subdir] [-I maxyear]\n\n\
+L'option -R permet d'inclure les sous-repertoires\n\
+L'option -Z permet de verifier que les tailles des fichiers mensuels sont identiques par mois\n\
+dir permet de decrire le repertoire selectionne : . par defaut \n\
+-S subdir permet de decrire les sous-repertoires selectionnes : \*/Output par exemple\n\
+-I maxyear ne traite que les dates inferieures ou egales a maxyear. Toutes les dates par defaut\n\
+Les formes de dates identifiables sont illustrees dans l'exemple obtenu par \n\
+    \t$(basename $0) -exemple\n\
+la valeur retournee est le nombre de formes de noms de fichier qui presentent des trous\n
+Si l option -Z est precisee, le code retour y ajoute le nombre de mois avec tailles differentes.\n
+-q pour n avoir aucun message / -v pour avoir les patterns et erreurs  a  l ecran \n
+-d pour activer l echo des commandes \n
+Exemples :\n
+check_expe_files_size.sh SRF/Output/MO # verification des noms du repertoire SRF/Output/MO\n
+check_expe_files_size.sh -Z SRF/Output/MO # verification des noms et des tailles des fichiers du repertoire\n
+check_expe_files_size.sh -R -S \"*/Output\" # verification des noms des fichiers pour toute une simulation IPSL\n
+check_expe_files_size.sh -Z -R -S \"*/Output\" # verification des noms et des tailles des fichiers pour toute une simulation IPSL\n
+check_expe_files_size.sh -I 1949 -R -S \"*/Output\" # verification jusuque a l annee 1949 incluse des noms des fichiers pour une simulation IPSL\n
+"
+#La presence d'une annee+mois impose la presence de l'annee entiere
+[ $# -eq 0  ]  && echo -e $doc && exit -1
+
+debugflag=0
+quiet=0
+exemple=0
+recursion=0
+examsize=0
+dir=.
+subdir=
+maxyear=9999
+maxyearp1=9999
+
+#---------------------------------------------
+while [ $# -ne 0 ]
+do
+  case $1 in
+  -h|--help|-help)
+    echo -e $doc
+    exit -1 ;;
+  -e|-exemple)
+    exemple=1
+# exemple de formes de dates reconnues par ce script. La liste ci-dessous est aussi
+# utilisee lors des tests du script
+    cat<<-EOF > /tmp/$$.ldir
+MONEXP_20000101_20000131_1M_histmth.nc
+MONEXP_20000101_20000131_1M_histmthNMC.nc
+MONEXP_20000201_20000228_1M_histmth.nc
+MONEXP_20000201_20000228_1M_histmthNMC.nc
+MONEXP_20000301_20000331_1M_histmth.nc
+MONEXP_20000301_20000331_1M_histmthNMC.nc
+MONEXP_20000401_20000430_1M_histmth.nc
+MONEXP_20000401_20000430_1M_histmthNMC.nc
+MONEXP_20000501_20000531_1M_histmth.nc
+MONEXP_20000501_20000531_1M_histmthNMC.nc
+MONEXP_20000601_20000630_1M_histmth.nc
+MONEXP_20000601_20000630_1M_histmthNMC.nc
+MONEXP_20000701_20000731_1M_histmth.nc
+MONEXP_20000701_20000731_1M_histmthNMC.nc
+MONEXP_20000801_20000831_1M_histmth.nc
+MONEXP_20000801_20000831_1M_histmthNMC.nc
+MONEXP_20000901_20000930_1M_histmth.nc
+MONEXP_20000901_20000930_1M_histmthNMC.nc
+MONEXP_20001001_20001031_1M_histmth.nc
+MONEXP_20001001_20001031_1M_histmthNMC.nc
+MONEXP_20001101_20001130_1M_histmthNMC.nc
+MONEXP_20001201_20001231_1M_histmth.nc
+MONEXP_20001201_20001231_1M_histmthNMC.nc
+
+EOF
+    echo -e "\nExample : with this directory content\n"
+    cat  /tmp/$$.ldir
+    echo -e "\n\nYou would get :\n\n"
+    break;;
+  -d|--debug)
+    set -x
+    debugflag=1
+    shift ;;
+  -q|--quiet)
+    quiet=1
+    shift ;;
+  -v|--verbose)
+    quiet=0
+    shift ;;
+  -R|-r|--r)
+    recursion=1
+    shift ;;
+  -Z|-z|--z)
+    examsize=1
+    shift ;;
+  -S|-s|--s)
+    subdir=$2
+    shift 2 ;;
+  -I|-i|--i)
+    maxyear=$2
+    (( maxyearp1 = maxyear + 1 ))
+    shift 2 ;;
+  *)
+    dir=$1
+    break ;;
+  esac
+done
+
+[ $quiet = 0 ] && echo quiet : $quiet recursion : $recursion - examsize : $examsize - dir - $dir -- subdir $subdir-- maxyearp1 : $maxyearp1
+if [ $exemple = 0 ] ; then
+  [ ! -d $dir ] && echo "verif_expe_files : missing directory $dir "&& exit
+  ( cd $dir
+    if [ $recursion = O ] ; then ls > /tmp/$$.ldir ; [ $examsize = 1 ] && ls -l > /tmp/$$.size # Cas "normal" : on liste les entrees du repertoire et ls long
+    else find ./$subdir  -type f > /tmp/$$.ldir ; [ $examsize = 1 ] && find ./$subdir -type f -exec ls -l {} \; >/tmp/$$.size # Cas de listage recursif des fichiers
+    fi
+  )
+fi
+###head /tmp/$$.ldir ; head /tmp/$$.size ; rm /tmp/$$*
+# For debugging purpose ...
+#head -n 2 /tmp/$$.ldir > /tmp/$$.aa ; mv /tmp/$$.aa /tmp/$$.ldir
+#set -x
+# On remplace les / en ~ dans la liste des fichiers
+cat /tmp/$$.ldir | tr "/" "~" > /tmp/$$.aa ; mv /tmp/$$.aa /tmp/$$.ldir
+[ -f /tmp/$$.size ] && cat /tmp/$$.size | tr "/" "~" > /tmp/$$.aa && mv /tmp/$$.aa /tmp/$$.size
+# On deduit de la liste des fichiers des patterns de annee+mois, annee, intervalles de date ...
+sed -r \
+  -e 's/[0-5][0-9]{3}[01][0-9]/YYMM/g' \
+  -e 's/YYMM01_YYMM(28|29|30|31)/YYmmdd_YYmmdd/g' \
+  /tmp/$$.ldir | sort -u > /tmp/$$.lpat
+# Ci-dessus, il faudrait compter les nb d'occ de chqaue pattern pour signaler et
+# ne pas retenir ceux qui n'apparaissent qu'une fois (sauf les decennaux ?)
+# On ote les patterns sans date du tout
+sed -i -e '/YY/!d' /tmp/$$.lpat
+# On rend compte des patterns identifies
+#echo "Formes de fichier identifiees: " ; awk '{printf "\t%s\n",$1}' /tmp/$$.lpat
+# Une fonction pour associer un nom de fichier a chaque pattern : on remplace les / par des ~
+tmpfic (){
+  echo -n "/tmp/$$." ; echo $1 | tr "/" "_"
+}
+# Pour chaque pattern, on liste les dates pertinentes: annees de debut et fin pour les
+# intervalles d'annees, ou annee ou annee+mois pour les autres
+cat /dev/null > /tmp/$$.dates
+#set -x
+while read pattern ; do
+  if [ $(echo $pattern | grep "YYmmdd_YYmmdd") ] ; then
+        # On transforme le pattern pour mettre une sequences
+        # de capture des annees de debut et fin d'intervalle
+    p2=$(echo $pattern | sed -e 's/YYmmdd_YYmmdd/([0-5][0-9]{3}[01][0-9])01_[0-5][0-9]{3}[01][0-9](28|29|30|31)/g' )
+
+       # On balaye le repertoire avec le(s) pattern(s) transforme(s) pour capturer les annees
+    grep -E $p2 /tmp/$$.ldir | sed -r -e "s/$p2/\1/g"  >> /tmp/$$.$pattern.tmp
+  fi
+  sort -n -u /tmp/$$.$pattern.tmp > /tmp/$$.$pattern.list
+    # Si la liste des date (annees ou annes+mois) pour le pattern est
+    # de taille > 1, on l'integre a la liste generale des dates
+    # en supprimant au prealable les dates isolees
+    # ... ca reste a faire
+  cat /tmp/$$.$pattern.list | cut -c 1-4 >> /tmp/$$.dates
+done < /tmp/$$.lpat
+# Fonction pour completer et rendre sequentielle une liste d'annees (une par ligne)
+force_sequence (){
+  awk '{
+        if (NR==1) {avant=$1; print $1}
+        else { for (i=avant+1 ; i<=$1 ; i++) printf "%04i\n", i}}'
+}
+sort -u /tmp/$$.dates > /tmp/$$.toutes_dates
+# On enleve les trous dans la liste des dates
+force_sequence < /tmp/$$.toutes_dates > /tmp/$$.tmp ; sort -u /tmp/$$.tmp > /tmp/$$.toutes_dates
+# Fonction d'analyse de sequences de nombres (annees, ou annees+mois
+# On transforme les series continues a a+1 a+2....b (a raison d'un par
+# ligne) en : "a-b"
+sequence (){
+  awk -v pas=${1:-1} '{
+        if (NR==1) {avant=$1;nb=1; printf "%s",$1}
+        else {
+          suivant=avant+pas
+          # Pour les nombres sur 6 chiffres, on suppose que c est du YYYMM
+          # et on gere le passage de decembre a janvier
+          if ((length(avant)==6) && (substr(avant,5,2)=="12"))
+            { avant4=substr(avant,1,4) ; suivant=sprintf("%4d01",avant4+1)}
+          if ($1 > suivant) {
+            if (nb>1) printf "-%s",avant
+            nb=1 ; printf ", %s",$1}
+          else { nb=nb+1 }
+          avant=$1  }}
+      END { if (nb >1) printf "-%s\n",avant ; else print ""} '
+}
+[ $quiet = 0 ] && echo $(wc -l /tmp/$$.ldir | cut -d \  -f 1) files proceeded.
+[ $quiet = 0 ] && echo -n "Years occurring : " && sequence 1 < /tmp/$$.toutes_dates
+# on ne garde que les annees inferieures a maxyear
+sed "/$maxyearp1/"',$d' </tmp/$$.toutes_dates >/tmp/$$.toutes_dates_maxyear
+[ $quiet = 0 ] && echo -n "Years tested : " && sequence 1 < /tmp/$$.toutes_dates_maxyear
+mv /tmp/$$.toutes_dates_maxyear /tmp/$$.toutes_dates
+# On liste tous les mois qui doivent etre presents (au motif qu'une annee est presente)
+> /tmp/$$.toutes_dates_et_mois
+while read an ; do
+  i=1
+  while [ $i -le 12 ] ; do
+    printf "%s%02d\n" ${an} $i  >> /tmp/$$.toutes_dates_et_mois
+    i=$(( i + 1 ))
+  done
+done < /tmp/$$.toutes_dates
+# Pour chaque pattern, on analyse si toutes les dates sont presentes en bon nombre (decennie, an, an+mois)
+touch /tmp/$$.synthese
+[ $quiet = 0 ] && echo "File name patterns and holes (if any) :"
+#set -x
+while read pattern ; do
+  [ `echo $pattern | grep -E "(YYmmdd_YYmmdd)"` ]  && pas=1 && \
+    join -v 1 /tmp/$$.toutes_dates_et_mois  /tmp/$$.$pattern.list > /tmp/$$.$pattern.manques
+  sequence $pas < /tmp/$$.$pattern.manques > /tmp/$$.$pattern.synthese
+  truepattern=$(echo $pattern | tr "~" "/")
+  [ $quiet = 0 ] && printf "%80s : " $truepattern  && cat /tmp/$$.$pattern.synthese
+  cat /tmp/$$.$pattern.synthese >> /tmp/$$.synthese
+done < /tmp/$$.lpat
+
+rep=$(wc -w /tmp/$$.synthese | tail -1 | cut -d \  -f 1)
+if [ $examsize = 0 ] ; then rm /tmp/$$* ; exit $rep ; fi
+
+# taille des fichiers
+cat /dev/null > /tmp/$$.dates
+#set -x
+while read pattern ; do
+  i=1
+  while [ $i -le 12 ] ; do
+    mois=$(printf "%02d\n"  $i)
+    if [ $(echo $pattern | grep "YYmmdd_YYmmdd") ] ; then
+           # On transforme le pattern pour mettre une sequences
+           # avec le mois courant
+      px=$(echo $pattern | sed -e "s/YYmmdd_YYmmdd/([0-5][0-9]{3})${mois}01_[0-5][0-9]{3}${mois}(28|29|30|31)/g" )
+
+           # On balaye le repertoire avec le(s) pattern(s) transforme(s) pour capturer les tailles des fichiers de ce mois
+      grep -E $px /tmp/$$.size | awk '{print $5}' | sort -u >/tmp/$$.$pattern.size_${mois}
+           # On garde les infos s il n y a pas une taille unique
+      for size in $(cat /tmp/$$.$pattern.size_${mois})  ; do
+        grep -E $px /tmp/$$.size | grep " "${size}" " | tr "~" "/" >>/tmp/$$.$pattern.files_${mois}.${size}
+      done
+    fi
+    i=$(( i + 1 ))
+  done
+done < /tmp/$$.lpat
+
+[ $quiet = 0 ] && echo
+[ $quiet = 0 ] && echo  "Size verification per month (if different) :"
+# Pour chaque pattern, on liste la taille des fichiers de chaque mois
+touch /tmp/$$.synthese_size
+while read pattern ; do
+  truepattern=$(echo $pattern | tr "~" "/")
+  [ $quiet = 0 ] && printf "%80s : " $truepattern
+  if [ `echo $pattern | grep -E "(YYmmdd_YYmmdd)"` ]  ; then
+    RESULT=""
+    for i in 1 2 3 4 5 6 7 8 9 10 11 12 ; do
+      mois=$(printf "%02d\n"  $i)
+      if [ $(wc -l /tmp/$$.$pattern.size_${mois} |  cut -d " " -f 1) = 1 ] ; then
+        RESULT="$RESULT "
+      else
+                # special case for february , we accept 2 different sizes for february for leap year
+        if [[ $i == 2 && $(wc -l /tmp/$$.$pattern.size_${mois} |  cut -d " " -f 1) = 2 ]] ; then
+                   # est ce qu il y a des mois de 29 jours? si non souci reel
+          if [ $( grep 0229 /tmp/$$.$pattern.files_02.* 1>/dev/null 2>&1 ) ] ; then
+            RESULT="$RESULT \033[1;31m[$mois]\033[m"
+            cat  /tmp/$$.$pattern.size_${mois} >> /tmp/$$.synthese_size
+          else
+            RESULT="$RESULT "
+          fi
+        else
+          RESULT="$RESULT \033[1;31m[$mois]\033[m"
+          cat  /tmp/$$.$pattern.size_${mois} >> /tmp/$$.synthese_size
+        fi
+      fi
+    done
+    [ $quiet = 0 ] && echo -e $RESULT
+  fi
+done < /tmp/$$.lpat
+
+# affichage des details
+while read pattern ; do
+  first=0
+  i=1
+  truepattern=$(echo $pattern | tr "~" "/")
+  while [ $i -le 12 ] ; do
+    mois=$(printf "%02d\n"  $i)
+    if [ $(echo $pattern | grep "YYmmdd_YYmmdd") ] ; then
+           # si on a plus de 2 tailles de fichiers pour ce mois, on liste le nombre de fichiers par taille et les 3 premiers
+           # cas special pour fevrier qui accepte 2 tailles differentes si 1 pour les 28 et l autre pour les 29
+      if [ $(wc -l /tmp/$$.$pattern.size_${mois} | cut -d " " -f 1) != 1 ] ; then
+        if  [[ $i == 2 && $(wc -l /tmp/$$.$pattern.size_${mois} |  cut -d " " -f 1) == 2 ]] ; then
+                   # est ce qu il y a des mois de 29 jours? sinon souci reel
+          if [ $( grep 0229 /tmp/$$.$pattern.files_02* 1>/dev/null 2>&1 ) ] ; then
+            if [[ ${first} == 0 ]] ; then printf "Details %73s : \n" $truepattern ; first=1 ; fi
+            echo mois : ${mois}
+            for size in $( cat /tmp/$$.$pattern.size_${mois} ) ; do
+              head -1 /tmp/$$.$pattern.files_${mois}.${size}
+            done
+          fi
+        else
+          if [[ ${first} == 0 ]] ; then printf "Details %73s : \n" $truepattern ; first=1 ; fi
+          echo mois : ${mois}
+          for size in $( cat /tmp/$$.$pattern.size_${mois} ) ; do
+            head -1 /tmp/$$.$pattern.files_${mois}.${size}
+          done
+        fi
+      fi
+    fi
+    i=$(( i + 1 ))
+  done
+done < /tmp/$$.lpat
+
+
+rep=$(wc -w /tmp/$$.synthese /tmp/$$.synthese_size | tail -1 | sed -e 's/total//' -e 's/ //g' )
+
+# reste  a analyser par annee en sus de par pattern, pour presenter le plus clair
+# Penser a forunir l'option d'imposer des patterns et des annees en entree
+[ $debugflag = 0 ] && rm -f /tmp/$$.* /tmp/$$.ldir
+exit $rep
+# Changes
+# - 20 april 2010 : add handling of pattern year1-year2, which is a generalization of decades
+# - janvier 2011 : suppression des caracteres accentues
+#                  mise en place pour prefix de type libIGCM / IPSL
+#                  ajout de la verification des tailles des fichiers mensuels
+#                  ajout des options -d -q/-v -R -S subdir -I maxyear
Index: /tags/libIGCM_v2.2/libIGCM_post/libIGCM_post.ksh
===================================================================
--- /tags/libIGCM_v2.2/libIGCM_post/libIGCM_post.ksh	(revision 998)
+++ /tags/libIGCM_v2.2/libIGCM_post/libIGCM_post.ksh	(revision 998)
@@ -0,0 +1,874 @@
+#!/bin/ksh
+
+#**************************************************************
+# Author: Sebastien Denvil
+# Contact: Sebastien.Denvil__at__ipsl.jussieu.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#=======================================================================
+
+function IGCM_post_Configure
+{
+  IGCM_debug_PushStack "IGCM_post_Configure"
+
+  # Debug Print :
+  echo
+  IGCM_debug_Print 1 "IGCM_post_Configure"
+  #
+  # Initialize
+  #
+  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
+  #
+  if [ X${AsynchronousRebuild} = Xtrue ] ; then
+    list_post="RebuildFrequency"
+  fi
+  #
+  if [ X${Pack} = Xtrue ] ; then
+    list_post="${list_post} PackFrequency"
+  fi
+  #
+  if ( [ X${TimeSeries} = Xtrue ] || [ X${TimeSeries2D} = Xtrue ] || [ X${TimeSeries3D} = Xtrue ] || [ X${TimeSeriesChunck2D} = Xtrue ] || [ X${TimeSeriesChunck3D} = Xtrue ] ) ; then
+    list_post="${list_post} TimeSeriesFrequency"
+  fi
+  #
+  if [ X${Seasonal} = Xtrue ] ; then
+    list_post="${list_post} SeasonalFrequency"
+  fi
+
+  # Overrule special cases
+  if ( [ ! X${config_Post_TimeSeriesFrequency} = X${NULL_STR} ] && \
+    [ ! X${config_Post_TimeSeriesFrequency} = XNONE ]           && \
+    [ ${SimulationLengthInDays} -ge ${ExperienceLengthInDays} ] ) ; then
+    TimeSeriesFrequency=true
+    POST=true
+  fi
+  #
+  if ( [ X${AsynchronousRebuild} = Xtrue ] && [ ${SimulationLengthInDays} -ge ${ExperienceLengthInDays} ] ) ; then
+    RebuildFrequency=true
+    POST=true
+  fi
+
+  # READ REBUILD OR TIME SERIES OR SEASONAL FREQUENCY
+  # AND TURN ON THE SUBMISSION FLAG WHEN MODULO IS ZERO
+  for post_freq in ${list_post} ; do
+    # Extract frequency from previously defined variable
+    config_Post_post_freq=$( eval echo \${config_Post_${post_freq}} )
+    # Offset for Seasonal Average starting period
+    if [ ${post_freq} = SeasonalFrequency ] ; then
+      if ( [ X${config_Post_SeasonalFrequencyOffset} = X${NULL_STR} ] || [ X${config_Post_SeasonalFrequencyOffset} = XNONE ] || [ X${config_Post_SeasonalFrequencyOffset} = X ] ) ; then
+        PeriodOffset=0
+      else
+        PeriodOffset=${config_Post_SeasonalFrequencyOffset}
+      fi
+    else
+      PeriodOffset=0
+    fi
+    # Compute Modulo between frequencys (/!\second argument will be multiplied by CumuPeriod/!\)
+    # RebuildFrequency needs additionnal information
+    if [ ${post_freq} = RebuildFrequency ] ; then
+      IGCM_post_ModuloRuntimeFrequency config_Post_post_freq config_UserChoices_PeriodLength NbPeriodPerFrequency
+      NbRebuildDir=${NbPeriodPerFrequency}
+    else
+      IGCM_post_ModuloRuntimeFrequency config_Post_post_freq config_UserChoices_PeriodLength
+    fi
+    #
+    eval IGCM_debug_Print 1 \" "${post_freq} flag value : \${${post_freq}}" \"
+  done
+  #
+  IGCM_debug_Print 2 "POST-TREATEMENT flag value : ${POST}"
+  #
+  # Prepare headers for the shell dedicated to post-processing
+  if ( [ ${PackFrequency} = true ] && ( [ ${TimeSeriesFrequency} = true ] || [ ${SeasonalFrequency} = true ] ) ) ; then
+    if [ $DRYRUN -le 1 ]; then
+      echo "#!/bin/ksh                                     " >  ${R_BUFR}/FlushPost_${PeriodDateEnd}.ksh
+      echo "function IGCM_FlushPost                        " >> ${R_BUFR}/FlushPost_${PeriodDateEnd}.ksh
+      echo "{                                              " >> ${R_BUFR}/FlushPost_${PeriodDateEnd}.ksh
+      echo "IGCM_debug_PushStack \"IGCM_FlushPost\"        " >> ${R_BUFR}/FlushPost_${PeriodDateEnd}.ksh
+      echo "echo                                           " >> ${R_BUFR}/FlushPost_${PeriodDateEnd}.ksh
+      echo "IGCM_debug_Print 1 \"IGCM_FlushPost\"          " >> ${R_BUFR}/FlushPost_${PeriodDateEnd}.ksh
+      echo "echo                                           " >> ${R_BUFR}/FlushPost_${PeriodDateEnd}.ksh
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_post_Configure"
+}
+
+function IGCM_post_Submit
+{
+  IGCM_debug_PushStack "IGCM_post_Submit"
+
+  typeset listVarEnv DaysTemp
+
+  POST_DIR=${R_BUF_KSH}
+
+  if [ ${POST} = true ]; then
+    echo
+    IGCM_debug_Print 1 "IGCM_post_Submit"
+    echo
+    IGCM_debug_Print 2 "POST_DIR = ${POST_DIR}"
+  fi
+
+  #============ TIME SERIES POST-PROCESSING ===========#
+  if [ ${TimeSeriesFrequency} = true ] ; then
+
+    IGCM_debug_Print 1 "TIME SERIES POST-PROCESSING ACTIVATED"
+    echo
+
+
+
+    # Get information from last execution
+    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card PostProcessing TimeSeriesCompleted
+    CompletedFlag=${run_PostProcessing_TimeSeriesCompleted}
+    #
+
+
+
+    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_MBG,RESOL_SRF,RESOL_SBG"
+    #
+    jLoop=${#ListDimension[*]}
+    j=0
+    until [ $j -ge ${jLoop} ]; do
+      Dimension=${ListDimension[${j}]}
+      #
+      if [ X$( eval echo \${TimeSeries${Dimension}} ) = Xtrue ] ; then
+      #
+        IGCM_debug_Print 1 "TIME SERIES POST-PROCESSING ${Dimension} ACTIVATED"
+        echo
+        #
+        if [ X${Dimension} = X ] ; then
+          TsTask="empty"
+          Script_Post_Output=create_ts.${PeriodDateEnd}
+        else
+          TsTask=${Dimension}
+          Script_Post_Output=create_ts.${PeriodDateEnd}.${TsTask}
+        fi
+        #
+        if [ ${RebuildFrequency} = true ] ; then
+          #
+          if [ ${PackFrequency} = true ] ; then
+            FunctionPath=${R_BUFR}/FlushPost_${PeriodDateEnd}.ksh
+          else
+            FunctionPath=${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+          fi
+          #
+          if [ -f ${FunctionPath} ] ; then
+#           if [ X${MASTER} = Xtitane ] ; then
+#             echo "IGCM_sys_RshPost <<-EOF"                       >> ${FunctionPath}
+#           fi
+            echo "export DEBUG_debug=${DEBUG_debug}              " >> ${FunctionPath}
+            echo "export MODIPSL=${MODIPSL}                      " >> ${FunctionPath}
+            echo "export libIGCM_SX=${libIGCM}                   " >> ${FunctionPath}
+            echo "export libIGCM=${libIGCM_POST}                 " >> ${FunctionPath}
+            echo "export SUBMIT_DIR=${SUBMIT_DIR}                " >> ${FunctionPath}
+            echo "export POST_DIR=${POST_DIR}                    " >> ${FunctionPath}
+            echo "export MASTER=${MASTER}                        " >> ${FunctionPath}
+            echo "export RebuildFrequency=${RebuildFrequency}    " >> ${FunctionPath}
+            echo "export DateBegin=${DateBegin}                  " >> ${FunctionPath}
+            echo "export PeriodDateEnd=${PeriodDateEnd}          " >> ${FunctionPath}
+            echo "export StandAlone=false                        " >> ${FunctionPath}
+            echo "export CompletedFlag=${CompletedFlag}          " >> ${FunctionPath}
+            echo "export TsTask=${TsTask}                        " >> ${FunctionPath}
+            echo "unset  CompToRead                              " >> ${FunctionPath}
+            echo "unset  FlagToRead                              " >> ${FunctionPath}
+            echo "export RESOL_ATM=${RESOL_ATM}                  " >> ${FunctionPath}
+            echo "export RESOL_OCE=${RESOL_OCE}                  " >> ${FunctionPath}
+            echo "export RESOL_ICE=${RESOL_ICE}                  " >> ${FunctionPath}
+            echo "export RESOL_MBG=${RESOL_MBG}                  " >> ${FunctionPath}
+            echo "export RESOL_SRF=${RESOL_SRF}                  " >> ${FunctionPath}
+            echo "export RESOL_SBG=${RESOL_SBG}                  " >> ${FunctionPath}
+            echo "export listVarEnv=${listVarEnv}                " >> ${FunctionPath}
+            echo "export Script_Post_Output=${Script_Post_Output}" >> ${FunctionPath}
+#           if [ X${MASTER} = Xtitane ] ; then
+#             echo ". ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh" >> ${FunctionPath}
+#             echo ". ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh"     >> ${FunctionPath}
+#           fi
+            echo "IGCM_sys_MkdirWork ${POST_DIR}                 " >> ${FunctionPath}
+            echo "IGCM_debug_Verif_Exit_Post                     " >> ${FunctionPath}
+            echo "IGCM_sys_QsubPost create_ts                    " >> ${FunctionPath}
+#           if [ X${MASTER} = Xtitane ] ; then
+#             echo "EOF"                                           >> ${FunctionPath}
+#           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 RebuildFrequency=${RebuildFrequency}
+                    export DateBegin=${DateBegin}
+                    export PeriodDateEnd=${PeriodDateEnd}
+                    export StandAlone=false
+                    export CompletedFlag=${CompletedFlag}
+                    export TsTask=${TsTask}
+                    unset  CompToRead
+                    unset  FlagToRead
+                    export RESOL_ATM=${RESOL_ATM}
+                    export RESOL_OCE=${RESOL_OCE}
+                    export RESOL_ICE=${RESOL_ICE}
+                    export RESOL_MBG=${RESOL_MBG}
+                    export RESOL_SRF=${RESOL_SRF}
+                    export RESOL_SBG=${RESOL_SBG}
+                    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 create_ts
+EOF
+        fi
+      fi
+      #
+      if [ X$( eval echo \${TimeSeriesChunck${Dimension}} ) = Xtrue ] ; then
+        #
+        IGCM_debug_Print 1 "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[@]}
+        typeset i
+        i=0
+        until [ $i -ge $NbJob ]; do
+          CompToRead=$( eval echo \${CHUNCK${Dimension}_COMP[\${i}]} )
+          FlagToRead=$( eval echo \${CHUNCK${Dimension}_FLAG[\${i}]} )
+          NameToRead=$( eval echo \${CHUNCK${Dimension}_NAME[\${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
+          #
+          Script_Post_Output=create_ts.${PeriodDateEnd}.${TsTask}.${CompToRead}.${NameToRead}
+          #
+          if [ ${RebuildFrequency} = true ] ; then
+            #
+            if [ ${PackFrequency} = true ] ; then
+              FunctionPath=${R_BUFR}/FlushPost_${PeriodDateEnd}.ksh
+            else
+              FunctionPath=${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+            fi
+            #
+            if [ -f ${FunctionPath} ] ; then
+#             if [ X${MASTER} = Xtitane ] ; then
+#               echo "IGCM_sys_RshPost <<-EOF"                       >> ${FunctionPath}
+#             fi
+              echo "export DEBUG_debug=${DEBUG_debug}              " >> ${FunctionPath}
+              echo "export MODIPSL=${MODIPSL}                      " >> ${FunctionPath}
+              echo "export libIGCM_SX=${libIGCM}                   " >> ${FunctionPath}
+              echo "export libIGCM=${libIGCM_POST}                 " >> ${FunctionPath}
+              echo "export SUBMIT_DIR=${SUBMIT_DIR}                " >> ${FunctionPath}
+              echo "export POST_DIR=${POST_DIR}                    " >> ${FunctionPath}
+              echo "export MASTER=${MASTER}                        " >> ${FunctionPath}
+              echo "export RebuildFrequency=${RebuildFrequency}    " >> ${FunctionPath}
+              echo "export DateBegin=${ChunckTsDateBegin}          " >> ${FunctionPath}
+              echo "export PeriodDateEnd=${PeriodDateEnd}          " >> ${FunctionPath}
+              echo "export StandAlone=false                        " >> ${FunctionPath}
+              echo "export CompletedFlag=${CompletedFlag}          " >> ${FunctionPath}
+              echo "export TsTask=${TsTask}                        " >> ${FunctionPath}
+              echo "export CompToRead=${CompToRead}                " >> ${FunctionPath}
+              echo "export FlagToRead=${FlagToRead}                " >> ${FunctionPath}
+              echo "export RESOL_ATM=${RESOL_ATM}                  " >> ${FunctionPath}
+              echo "export RESOL_OCE=${RESOL_OCE}                  " >> ${FunctionPath}
+              echo "export RESOL_ICE=${RESOL_ICE}                  " >> ${FunctionPath}
+              echo "export RESOL_MBG=${RESOL_MBG}                  " >> ${FunctionPath}
+              echo "export RESOL_SRF=${RESOL_SRF}                  " >> ${FunctionPath}
+              echo "export RESOL_SBG=${RESOL_SBG}                  " >> ${FunctionPath}
+              echo "export listVarEnv=${listVarEnv}                " >> ${FunctionPath}
+              echo "export Script_Post_Output=${Script_Post_Output}" >> ${FunctionPath}
+#             if [ X${MASTER} = Xtitane ] ; then
+#               echo ". ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh" >> ${FunctionPath}
+#               echo ". ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh"     >> ${FunctionPath}
+#             fi
+              echo "IGCM_sys_MkdirWork ${POST_DIR}                 " >> ${FunctionPath}
+              echo "IGCM_debug_Verif_Exit_Post                     " >> ${FunctionPath}
+              echo "IGCM_sys_QsubPost create_ts                    " >> ${FunctionPath}
+#             if [ X${MASTER} = Xtitane ] ; then
+#               echo "EOF"                                           >> ${FunctionPath}
+#             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 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_MBG=${RESOL_MBG}
+                        export RESOL_SRF=${RESOL_SRF}
+                        export RESOL_SBG=${RESOL_SBG}
+                        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 create_ts
+EOF
+            #
+          fi
+          #
+          export DateBegin=${SavedDateBegin}
+          #
+          (( i=i+1 ))
+          #
+        done
+      fi
+      (( j=j+1 ))
+    done
+  fi
+
+  #=============  SEASONAL POST-PROCESSING ============#
+  if [ ${SeasonalFrequency} = true ] ; then
+    #
+    IGCM_debug_Print 1 "SEASONNAL POST-PROCESSING"
+    echo
+    #
+    Script_Post_Output=create_se.${PeriodDateEnd}
+    #
+    listVarEnv="DEBUG_debug,MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,POST_DIR,MASTER,RebuildFrequency,DateBegin,PeriodDateEnd,StandAlone,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_MBG,RESOL_SRF,RESOL_SBG"
+
+    if [ ${RebuildFrequency} = true ] ; then
+      #
+      if [ ${PackFrequency} = true ] ; then
+        FunctionPath=${R_BUFR}/FlushPost_${PeriodDateEnd}.ksh
+      else
+        FunctionPath=${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+      fi
+      #
+      if [ -f ${FunctionPath} ] ; then
+      #
+#     if [ X${MASTER} = Xtitane ] ; then
+#       echo "IGCM_sys_RshPost <<-EOF"                     >> ${FunctionPath}
+#     fi
+      echo "export DEBUG_debug=${DEBUG_debug}              " >> ${FunctionPath}
+      echo "export MODIPSL=${MODIPSL}                      " >> ${FunctionPath}
+      echo "export libIGCM_SX=${libIGCM}                   " >> ${FunctionPath}
+      echo "export libIGCM=${libIGCM_POST}                 " >> ${FunctionPath}
+      echo "export SUBMIT_DIR=${SUBMIT_DIR}                " >> ${FunctionPath}
+      echo "export POST_DIR=${POST_DIR}                    " >> ${FunctionPath}
+      echo "export MASTER=${MASTER}                        " >> ${FunctionPath}
+      echo "export RebuildFrequency=${RebuildFrequency}    " >> ${FunctionPath}
+      echo "export DateBegin=${DateBegin}                  " >> ${FunctionPath}
+      echo "export PeriodDateEnd=${PeriodDateEnd}          " >> ${FunctionPath}
+      echo "export StandAlone=false                        " >> ${FunctionPath}
+      echo "export RESOL_ATM=${RESOL_ATM}                  " >> ${FunctionPath}
+      echo "export RESOL_OCE=${RESOL_OCE}                  " >> ${FunctionPath}
+      echo "export RESOL_ICE=${RESOL_ICE}                  " >> ${FunctionPath}
+      echo "export RESOL_MBG=${RESOL_MBG}                  " >> ${FunctionPath}
+      echo "export RESOL_SRF=${RESOL_SRF}                  " >> ${FunctionPath}
+      echo "export RESOL_SBG=${RESOL_SBG}                  " >> ${FunctionPath}
+      echo "export listVarEnv=${listVarEnv}                " >> ${FunctionPath}
+      echo "export Script_Post_Output=${Script_Post_Output}" >> ${FunctionPath}
+#     if [ X${MASTER} = Xtitane ] ; then
+#       echo ". ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh" >> ${FunctionPath}
+#       echo ". ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh"     >> ${FunctionPath}
+#     fi
+      echo "IGCM_sys_MkdirWork ${POST_DIR}                 " >> ${FunctionPath}
+      echo "IGCM_debug_Verif_Exit_Post                     " >> ${FunctionPath}
+      echo "IGCM_sys_QsubPost create_se                    " >> ${FunctionPath}
+#     if [ X${MASTER} = Xtitane ] ; then
+#       echo "EOF"                                         >> ${FunctionPath}
+#     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 RebuildFrequency=${RebuildFrequency}
+            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_MBG=${RESOL_MBG}
+            export RESOL_SRF=${RESOL_SRF}
+            export RESOL_SBG=${RESOL_SBG}
+            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 create_se
+EOF
+    fi
+  fi
+
+  #============== PACK PROCESSING FOR RESTART, DEBUG AND OUTPUT FILES =============#
+  if [ ${PackFrequency} = true ] ; then
+    IGCM_debug_Print 1 "PACK POST-PROCESSING"
+    # -----------------------------------------------------------------------------------
+    # Function IGCM_FlushPost called by pack_output.job has not been closed yet. Do it now
+    # Will submit Time Series OR Seasonal Average if needed 
+    # -----------------------------------------------------------------------------------
+    if [ -f ${R_BUFR}/FlushPost_${PeriodDateEnd}.ksh ] ; then
+      echo "IGCM_debug_PopStack \"IGCM_FlushPost\" " >> ${R_BUFR}/FlushPost_${PeriodDateEnd}.ksh
+      echo "}                                      " >> ${R_BUFR}/FlushPost_${PeriodDateEnd}.ksh
+    fi
+    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_card/libIGCM_card.ksh
+    . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
+    IGCM_sys_MkdirWork ${POST_DIR}
+    IGCM_debug_Verif_Exit_Post
+    IGCM_sys_QsubPost ${script}
+    IGCM_debug_Verif_Exit
+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_card/libIGCM_card.ksh
+      . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
+      IGCM_sys_MkdirWork ${POST_DIR}
+      IGCM_debug_Verif_Exit_Post
+      IGCM_sys_QsubPost ${script}
+      IGCM_debug_Verif_Exit
+EOF
+    #
+    script=pack_output
+    #
+    Script_Post_Output=${script}.${PeriodDateEnd}
+    #
+    if ( [ ${RebuildFrequency} = true ] && [ -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
+      echo "IGCM_debug_Verif_Exit                          " >> ${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 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_card/libIGCM_card.ksh
+        . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
+        IGCM_sys_MkdirWork ${POST_DIR}
+        IGCM_debug_Verif_Exit_Post
+        IGCM_sys_QsubPost ${script}
+        IGCM_debug_Verif_Exit
+EOF
+      export DateBegin=${SavedDateBegin}
+      export DateEnd=${SavedDateEnd}
+    fi
+  fi
+
+  #============== REBUILD POST-PROCESSING =============#
+  if ( [ X${AsynchronousRebuild} = Xtrue ] && [ -f ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh ] ) ; then
+    # -----------------------------------------------------------------------------------
+    # Function IGCM_FlushRebuild define in rebuild.ksh has not been closed yet. Do it now
+    # -----------------------------------------------------------------------------------
+    if [ ${DRYRUN} -le 1 ] ; then
+      echo "IGCM_debug_PopStack \"IGCM_FlushRebuild\" " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+      echo "}                                         " >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh
+    fi
+    if [ X${config_Post_RebuildFromArchive} = Xtrue ] ; then
+      IGCM_sys_Put_Dir REBUILD_${PeriodDateBegin} ${REBUILD_DIR}
+    else
+      IGCM_sys_Mv      REBUILD_${PeriodDateBegin} ${REBUILD_DIR}
+    fi
+  fi
+  #
+  if [ ${RebuildFrequency} = true ] ; then
+    if ( [ X${config_Post_RebuildFromArchive} = Xtrue ] ) ; then
+      IGCM_debug_Print 1 "REBUILD POST-PROCESSING FROM ARCHIVE"
+      echo
+    else
+      IGCM_debug_Print 1 "REBUILD POST-PROCESSING FROM WORKDIR"
+      echo
+    fi
+    script=rebuild_fromWorkdir
+    #
+    Script_Post_Output=${script}.${PeriodDateEnd}
+    #
+    listVarEnv="DEBUG_debug,MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,REBUILD_DIR,POST_DIR,MASTER,RebuildFromArchive,DateBegin,PeriodDateBegin,PeriodDateEnd,NbRebuildDir,StandAlone,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_MBG,RESOL_SRF,RESOL_SBG"
+    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 REBUILD_DIR=${REBUILD_DIR}
+      export POST_DIR=${POST_DIR}
+      export MASTER=${MASTER}
+      export RebuildFromArchive=${config_Post_RebuildFromArchive}
+      export DateBegin=${DateBegin}
+      export PeriodDateBegin=${PeriodDateBegin}
+      export PeriodDateEnd=${PeriodDateEnd}
+      export NbRebuildDir=${NbRebuildDir}
+      export StandAlone=false
+      export RESOL_ATM=${RESOL_ATM}
+      export RESOL_OCE=${RESOL_OCE}
+      export RESOL_ICE=${RESOL_ICE}
+      export RESOL_MBG=${RESOL_MBG}
+      export RESOL_SRF=${RESOL_SRF}
+      export RESOL_SBG=${RESOL_SBG}
+      export listVarEnv=${listVarEnv}
+      export Script_Post_Output=${Script_Post_Output}
+      . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh
+      . ${libIGCM_POST}/libIGCM_card/libIGCM_card.ksh
+      . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh
+      IGCM_sys_MkdirWork ${POST_DIR}
+      IGCM_debug_Verif_Exit_Post
+      IGCM_sys_QsubPost ${script}
+      IGCM_debug_Verif_Exit
+EOF
+  fi
+  IGCM_debug_PopStack "IGCM_post_Submit"
+}
+
+#===================================
+function IGCM_post_CheckModuloFrequency
+{
+  IGCM_debug_PushStack "IGCM_post_CheckModuloFrequency" $*
+
+  # Used by IGCM_config_Check
+  # from 2 libIGCM compatible frequency (*Y, *M, *D, *y, *m, *d)
+  # Issue an exit instruction IGCM_debug_Exit if there modulo is not zero
+  # Input parameter are the name of the variable, not the frequency value itself
+  # example
+  # IGCM_post_ModuloFrequency config_Post_RebuildFrequency config_UserChoices_PeriodLength
+
+  typeset MasterName SlaveName MasterFrequency SlaveFrequency PeriodMasterYear PeriodMasterMonth PeriodMasterDay PeriodSlaveYear PeriodSlaveMonth PeriodSlaveDay
+
+  # Get the name of the variable
+  MasterName=$1
+  SlaveName=$2
+  # Get the value the above name points to
+  MasterFrequency=$( eval echo \${${1}} )
+  SlaveFrequency=$( eval echo \${${2}} )
+
+  IGCM_debug_Print 2 "IGCM_post_CheckModuloFrequency : Master=${MasterFrequency} Slave=${SlaveFrequency}"
+
+  case ${MasterFrequency} in
+  *y|*Y)
+    PeriodMasterYear=$( echo ${MasterFrequency} | sed -e "s/[yY]//" )
+    case ${SlaveFrequency} in
+    *Y|*y)
+      PeriodSlaveYear=$( echo ${SlaveFrequency} | sed -e "s/[yY]//" )
+      if ( [ ${PeriodSlaveYear} -gt ${PeriodMasterYear} ] || \
+      [ $(( ${PeriodMasterYear} % ${PeriodSlaveYear} )) -ne 0 ] );  then
+        IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
+        IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}"
+        IGCM_debug_Exit "Check your frequency"
+      else
+        [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterYear} / ${PeriodSlaveYear} ))
+      fi ;;
+    *M|*m)
+      PeriodSlaveMonth=$( echo ${SlaveFrequency} | sed -e "s/[mM]//" )
+      if ( [ ${PeriodSlaveMonth} -gt $(( ${PeriodMasterYear} * 12 )) ] || \
+        [ $(( ( ${PeriodMasterYear} * 12 ) % ${PeriodSlaveMonth} )) -ne 0 ] ) ; then
+        IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
+        IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}"
+        IGCM_debug_Exit "Check your frequency"
+      else
+        [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ( 12 * ${PeriodMasterYear} ) / ${PeriodSlaveMonth} ))
+      fi ;;
+    *D|*d)
+      PeriodSlaveDay=$( echo ${SlaveFrequency} | sed -e "s/[dD]//" )
+      NbDays=$( IGCM_date_DaysInYear ${year} )
+      if [ ${config_UserChoices_CalendarType} = 360d ] || [ ${config_UserChoices_CalendarType} = noleap ] ; then
+        if ( [ ${PeriodSlaveDay} -gt $(( ${PeriodMasterYear} * ${NbDays} )) ] || \
+          [ $(( ( ${PeriodMasterYear} * ${NbDays} ) % ${PeriodSlaveDay} )) -ne 0 ] ; ) then
+          IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
+          IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}"
+          IGCM_debug_Exit "Check your frequency"
+        fi
+      else
+        IGCM_debug_Print 1 "For ${MasterName} with leap calendar:"
+        IGCM_debug_Print 1 "We have a daily ${SlaveName} frequency and ${MasterName}=${MasterFrequency}"
+        IGCM_debug_Print 1 "No post-treatment. Case not properly handle at this moment by libIGCM. Sorry"
+        IGCM_debug_Exit    "Check your frequency ${MasterName} and choose a daily frequency for this one too."
+      fi ;;
+    esac ;;
+  *M|*m)
+    PeriodMasterMonth=$( echo ${MasterFrequency} | sed -e "s/[mM]//" )
+    case ${SlaveFrequency} in
+    *Y|*y)
+      PeriodSlaveYear=$( echo ${SlaveFrequency} | sed -e "s/[yY]//" )
+      if ( [ ${PeriodMasterMonth} -gt $(( ${PeriodSlaveYear} * 12 )) ] || \
+        [ $(( ${PeriodMasterMonth} % ( ${PeriodSlaveYear} * 12 ) )) -ne 0 ] ) ; then
+        IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
+        IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}"
+        IGCM_debug_Exit "Check your frequency"
+      else
+        [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterMonth} / ( 12 * ${PeriodSlaveYear} ) ))
+      fi ;;
+    *M|*m)
+      PeriodSlaveMonth=$( echo ${SlaveFrequency} | sed -e "s/[mM]//" )
+      if ( [ ${PeriodSlaveMonth} -gt ${PeriodMasterMonth} ] || \
+        [ $(( ${PeriodMasterMonth} % ${PeriodSlaveMonth} )) -ne 0 ] ) ;  then         
+        IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
+        IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}"
+        IGCM_debug_Exit "Check your frequency"
+      else
+        [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterMonth} / ${PeriodSlaveMonth} ))
+      fi ;;
+    *D|*d)
+      IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
+      IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}"
+      IGCM_debug_Exit "Check your frequency" ;;
+    esac ;;
+  *D|*d)
+    PeriodMasterDay=$( echo ${MasterFrequency} | sed -e "s/[dD]//" )
+    case ${SlaveFrequency} in
+    *Y|*y)
+      IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
+      IGCM_debug_Print 1 "${MasterName} frequency ${MasterFrequency}"
+      IGCM_debug_Exit "Check your frequency" ;;
+    *M|*m)
+      IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
+      IGCM_debug_Print 1 "${MasterName} frequency ${MasterFrequency}"
+      IGCM_debug_Exit "Check your frequency" ;;
+    *D|*d)
+      PeriodSlaveDay=$( echo ${SlaveFrequency} | sed -e "s/[dD]//" )
+      if ( [ ${PeriodSlaveDay} -gt ${PeriodMasterDay} ] || \
+        [ $(( ${PeriodMasterDay} % ${PeriodSlaveDay} )) -ne 0 ] ) ;  then
+        IGCM_debug_Print 1 "${SlaveName} frequency ${SlaveFrequency} not compatbile with"
+        IGCM_debug_Print 1 "${MasterName} frequency : ${MasterFrequency}"
+        IGCM_debug_Exit "Check your frequency"
+      else
+        [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterDay} / ${PeriodSlaveDay} ))
+      fi ;;
+    esac ;;
+  NONE|none)
+    ;;
+  *)
+    IGCM_debug_Print 1 "KeyWord ${MasterFrequency} not allowed for ${MasterName} in config.card"
+    IGCM_debug_Exit "Check your ${MasterName} in config.card" ;;
+  esac
+
+  IGCM_debug_PopStack "IGCM_post_CheckModuloFrequency"
+}
+
+#===================================
+function IGCM_post_ModuloRuntimeFrequency
+{
+  IGCM_debug_PushStack "IGCM_post_ModuloRuntimeFrequency" $*
+
+  # Used by IGCM_post_Configure
+  # - from libIGCM (config_UserChoices_PeriodLength frequency * CumulPeriod) and 
+  # - post-processing compatible frequency (*Y, *M, *D, *y, *m, *d)
+  # --> turn on post-processing submission when their modulo is zero
+  # Input parameter are the name of the variable, not the frequency value itself
+  # example
+  # IGCM_post_ModuloRuntimeFrequency config_Post_SeasonalFrequency config_UserChoices_PeriodLength
+
+  typeset MasterName SlaveName MasterFrequency SlaveFrequency PeriodMasterYear PeriodMasterMonth PeriodMasterDay PeriodSlaveYear PeriodSlaveMonth PeriodSlaveDay
+
+  # Get the name of the variable
+  MasterName=$1
+  SlaveName=$2
+  # Get the value the above name points to
+  eval MasterFrequency=\${${1}}
+  eval SlaveFrequency=\${${2}}
+
+  echo
+  IGCM_debug_Print 2 "IGCM_post_ModuloRuntimeFrequency : Master=${MasterFrequency} Slave=${SlaveFrequency} CumulPeriod=${CumulPeriod}"
+
+  case ${MasterFrequency} in
+  *y|*Y)
+    PeriodMasterYear=$( echo ${MasterFrequency} | sed -e "s/[yY]//" )
+    case ${SlaveFrequency} in
+    *Y|*y)
+      PeriodSlaveYear=$( echo ${SlaveFrequency} | sed -e "s/[yY]//" )
+      if [ $(( ( ${CumulPeriod} * ${PeriodSlaveYear} - ${PeriodOffset} ) % ${PeriodMasterYear} )) -eq 0 ] ;  then
+        if [ $(( ${CumulPeriod} * ${PeriodSlaveYear} - ${PeriodOffset} )) -ne 0 ] ; then
+          eval ${post_freq}=true ; POST=true
+          [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterYear} / ${PeriodSlaveYear} ))
+        fi
+      fi;;
+    *M|*m)
+      PeriodSlaveMonth=$( echo ${SlaveFrequency} | sed -e "s/[mM]//" )
+      if [ $(( ( ${CumulPeriod} * ${PeriodSlaveMonth} - ${PeriodOffset} * 12 ) % ( ${PeriodMasterYear} * 12 ) )) -eq 0 ] ; then
+        if [ $(( ${CumulPeriod} * ${PeriodSlaveMonth} - ${PeriodOffset} * 12 )) -ne 0 ] ; then
+          eval ${post_freq}=true ; POST=true
+          [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ( 12 * ${PeriodMasterYear} ) / ${PeriodSlaveMonth} ))
+        fi
+      fi;;
+    *D|*d)
+      PeriodSlaveDay=$( echo ${SlaveFrequency} | sed -e "s/[dD]//" )
+      NbDays=$( IGCM_date_DaysInYear ${year} )
+      if [ $(( ( ${CumulPeriod} - ( ${PeriodOffset} * ${NbDays} / ${PeriodSlaveDay} ) ) % ( ${NbDays} * ${PeriodMasterYear} / ${PeriodSlaveDay} ) )) -eq 0 ] ; then
+        if [ $(( ${CumulPeriod} - ( ${PeriodOffset} * ${NbDays} / ${PeriodSlaveDay} ) )) -ne 0 ] ; then
+          eval ${post_freq}=true ; POST=true
+          [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ( ${NbDays} * ${PeriodMasterYear} ) / ${PeriodSlaveDay} ))
+        fi
+      fi;;
+    esac ;;
+  *M|*m)
+    PeriodMasterMonth=$( echo ${MasterFrequency} | sed -e "s/[mM]//" )
+    case ${SlaveFrequency} in
+    *Y|*y)
+      PeriodSlaveYear=$( echo ${SlaveFrequency} | sed -e "s/[yY]//" )
+      if [ $(( ( ${CumulPeriod} * ${PeriodSlaveYear} * 12 - ${PeriodOffset} ) % ( ${PeriodMasterMonth} ) )) -eq 0 ] ; then
+        if [ $(( ${CumulPeriod} * ${PeriodSlaveYear} * 12 - ${PeriodOffset} )) -ne 0 ] ; then
+          eval ${post_freq}=true ; POST=true
+          [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterMonth} / ( 12 * ${PeriodSlaveYear} ) ))
+        fi
+      fi;;
+    *M|*m)
+      PeriodSlaveMonth=$( echo ${SlaveFrequency} | sed -e "s/[mM]//" )
+      if [ $(( ( ${CumulPeriod} * ${PeriodSlaveMonth} - ${PeriodOffset} ) % ${PeriodMasterMonth} )) -eq 0 ] ;  then
+        if [ $(( ${CumulPeriod} * ${PeriodSlaveMonth} -  ${PeriodOffset} )) -ne 0 ] ; then 
+          eval ${post_freq}=true ; POST=true
+          [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterMonth} / ${PeriodSlaveMonth} ))
+        fi
+      fi;;
+    *D|*d)
+      IGCM_debug_Print 1 "PeriodLength frequency ${SlaveFrequency} not compatbile with"
+      IGCM_debug_Print 1 "${flag_post} frequency : ${MasterFrequency} " ;;
+    esac ;;
+  *D|*d)
+    PeriodMasterDay=$( echo ${MasterFrequency} | sed -e "s/[dD]//" )
+    case ${SlaveFrequency} in
+    *Y|*y)
+      IGCM_debug_Print 1 "PeriodLength frequency ${SlaveFrequency} not compatbile with"
+      IGCM_debug_Print 1 "${flag_post} frequency : ${MasterFrequency} " ;;
+    *M|*m)
+      IGCM_debug_Print 1 "PeriodLength frequency ${SlaveFrequency} not compatbile with"
+      IGCM_debug_Print 1 "${flag_post} frequency : ${MasterFrequency} " ;;
+    *D|*d)
+      PeriodSlaveDay=$( echo ${SlaveFrequency} | sed -e "s/[dD]//" )
+      if [ $(( ( ${CumulPeriod} * ${PeriodSlaveDay} - ${PeriodOffset} ) % ${PeriodMasterDay} )) -eq 0 ] ;  then
+        if [ $(( ${CumulPeriod} * ${PeriodSlaveDay} - ${PeriodOffset} )) -ne 0 ] ; then
+          eval ${post_freq}=true ; POST=true
+          [ X${3} = XNbPeriodPerFrequency ] && NbPeriodPerFrequency=$(( ${PeriodMasterDay} / ${PeriodSlaveDay} ))
+        fi
+      fi;;
+    esac ;;
+  NONE|none)
+    ;;
+  *)
+    IGCM_debug_Print 1 "KeyWord not allowed for ${post_freq} in config.card"
+    ;;
+  esac
+
+  IGCM_debug_PopStack "IGCM_post_ModuloRuntimeFrequency"
+}
Index: /tags/libIGCM_v2.2/libIGCM_sys/IGCM_add_out.awk
===================================================================
--- /tags/libIGCM_v2.2/libIGCM_sys/IGCM_add_out.awk	(revision 998)
+++ /tags/libIGCM_v2.2/libIGCM_sys/IGCM_add_out.awk	(revision 998)
@@ -0,0 +1,460 @@
+# IGCM_add_out - filter of output of the job :
+# command :
+# IGCM_add_out.awk job_output.out REALTIME USERTIME SYSTIME
+
+#**************************************************************
+# Author: Martial.Mancip
+# Contact: Martial.Mancip__at__ipsl.jussieu.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+# Modification: Patrick.Brockmann@cea.fr
+#
+#**************************************************************
+
+#==========================
+function myprint(str) {
+  if (debug) {
+     print str
+  }
+}
+
+
+#==========================
+BEGIN {
+#  print "traitement de " ARGV[1]
+
+  nbarg=ARGC
+  if (ARGV[1] == "-d") {
+    debug=1
+    file=ARGV[2]
+    delete ARGV[1] 
+    nbarg--
+  } else {
+    debug=0
+    file=ARGV[1]
+  }
+
+# When exit statement, 'END' rule is always executed, so defined a exit_value to manage this
+  exit_value=0
+  if (nbarg != 2) {
+    print "Usage: IGCM_add_out.awk [-d] file.output" 
+    print 
+    print "Args:"
+    print "      file.output = output file of at Job to be parsed" 
+    print 
+    print "Options:" 
+    print "       -d = debug mode" 
+    print 
+    exit_value=1
+    exit
+  }
+
+  Information_found=0
+  Information_ksh_SX_found=0
+
+  RealTime=0.
+  UserTime=-1.
+  SysTime=0.
+  VectorTime=0.
+  InstCount=0.
+  VInstCount=0.
+  VElementCount=0.
+  FLOPCount=0.
+  MOPS=0.
+  MFLOPS=0.
+  AVLength=0.
+  VOpRatio=0.
+  MemorySize=0.
+  MIPS=0.
+  ICache=0.
+  OCache=0.
+  Bank=0.
+
+  counter=0
+
+  RunDateBegin="2000-01-01T00:00:00"
+  RunDateEnd="2000-01-01T00:00:00"
+
+}
+
+#==========================
+{
+  myprint($0) 
+
+# Get information with MPI Program Information output on NEC
+  if (match($0, "     \\*\\*\\*\\*\\*\\*  Program Information  \\*\\*\\*\\*\\*\\*")) 
+  {
+    Information_found=1
+    counter=counter+1
+#   print $0      
+#    print counter
+    next
+  }
+  else if (Information_found == 1 && (match($0, ".*:.*"))) 
+  {
+    where=(match($0,"[a-zA-Z]"))
+    Length=(match($0, " *:"))-where
+    whereDot=(match($0, ":"))
+    info=substr($0,where,Length)
+    whereNum=(match($0, "[0-9]"))
+    Res=substr($0,whereNum)
+#    print where "," Length "," whereDot "," whereNum " '" info "' :" Res 
+
+    if( info=="Real Time (sec)" ) {
+#      print "|" Res "|"
+#      printf("RealTime = %10.5f\n",0.037600)
+#      printf("RealTime = %10.5f\n",Res)
+      if ( Res > RealTime ) {
+        myprint( "NEC Real Time updated" )
+	    RealTime=Res
+      }
+      next
+    }
+    	  
+    if( info=="User Time (sec)" ) {
+      myprint( "NEC User Time " )
+      UserTime=UserTime+Res
+      next
+    }
+
+    if( info=="Sys  Time (sec)" ) {
+      SysTime=SysTime+Res
+      next
+    }
+
+    if( info=="Vector Time (sec)" ) {
+      VectorTime=VectorTime+Res
+      next  
+    }
+
+    if( info=="Inst. Count" ) {
+      InstCount=InstCount+Res
+      next
+    }
+
+    if( info=="V. Element Count" ) {
+      VInstCount=VInstCount+Res
+      next  
+    }
+
+    if( info=="V. Element Count" ) {
+      VElementCount=VElementCount+Res
+      next
+    }
+
+    if( info=="FLOP Count" ) {
+      FLOPCount=FLOPCount+Res
+      next  
+    }
+
+    if( info=="MOPS" ) {
+      MOPS=MOPS+Res
+      next
+    }
+
+    if( info=="MFLOPS" ) {
+      MFLOPS=MFLOPS+Res
+      next  
+    }
+
+    if( info=="A.V. Length" ) {
+      AVLength=AVLength+Res
+      next
+    }
+
+    if( info=="V. Op. Ratio (%)" ) {
+      VOpRatio=VOpRatio+Res
+      next  
+    }
+
+    if( info=="Memory Size (MB)" ) {
+      MemorySize=MemorySize+Res
+      next
+    }
+
+    if( info=="MIPS" ) {
+      MIPS=MIPS+Res
+      next  
+    }
+
+    if( info=="I-Cache (sec)" ) {
+      ICache=ICache+Res
+      next
+    }
+
+    if( info=="O-Cache (sec)" ) {
+      OCache=OCache+Res
+      next  
+    }
+
+    if( info=="Bank (sec)" ) {
+      Bank=Bank+Res
+      next
+    }
+
+  }
+# Get information with time output on other hosts
+# ksh time
+  else if (match($0, ".*s real .*s user .*s system"))
+  {
+    myprint( "ksh" )
+    counter=counter+1
+
+    RealTime=(substr($1,1,match($1, "s")-1))
+    UserTime=(substr($3,1,match($3, "s")-1))
+    SysTime=(substr($5,1,match($5, "s")-1))
+
+  }
+
+# csh time
+# 0.000+u 0.000+s 0:00.00 0.0%      0+0k 0+0io 0pf+0w
+  else if (match($0, "[0-9.]+u [0-9.]+s .+"))
+  {
+    myprint( "csh" )
+    counter=counter+1
+
+    UserTime=(substr($1,1,match($1, "u")-1))
+    SysTime=(substr($2,1,match($2, "s")-1))
+    # si hours ?
+    RealTime=(substr($3,1,match($3, ":")-1)*60. + substr($3,match($3, ":")+1))
+
+  }
+# linux system time
+### example :
+### 2.02user 6.60system 12:41.62elapsed 1%CPU (0avgtext+0avgdata 25520maxresident)k
+### 1.31user 5.33system 2:47:39elapsed 0%CPU (0avgtext+0avgdata 30400maxresident)k
+  else if (match($0, ".*user .*system .*elapsed .*CPU .*"))
+  {
+    myprint( "linux" )
+    counter=counter+1
+
+    UserTime=(substr($1,1,match($1, "user")-1))
+    SysTime=(substr($2,1,match($2, "system")-1))
+    ### RealTime=(substr($3,1,match($3, ":")-1)*60.+substr($3, match($3, ":")+1, match($3, "elapsed"))) what for hours????
+
+    RealTime=0
+    if (match($3, "[0-9]*:[0-9]*:[0-9]*elapsed"))
+    {
+      #### $3=2:47:39elapsed
+      myprint( "linux elapsed in hours " )
+      sub1=(match($3, ":")-1)
+      sub2=sub1+2
+      min=(substr($3,sub2))
+      sub3=(match(min, ":")-1)
+      sub4=sub3+2
+      fin=(substr(min,sub4))
+      sub5=(match(fin, "elapsed")-1)
+      RealTime=((substr($3,1,sub1))*60+substr(min,1,sub3))*60+(substr(min,sub4,sub5))
+      myprint( " real time seconds " RealTime )
+    }
+    else if (match($3, "[0-9]*:[0-9]*\\.[0-9]*elapsed"))
+    {
+      #### $3=12:41.62elapsed
+      myprint( "linux elapsed in minutes " )
+      sub1=(match($3, ":")-1)
+      sub2=sub1+2
+      fin=(substr($3,sub2))
+      sub3=(match(fin, "elapsed")-1)
+      RealTime=(substr($3,1,sub1))*60+(substr($3,sub2,sub3))
+      myprint( " real time seconds " RealTime )
+    }
+    else if (match($3, "[0-9]*\\.[0-9]*elapsed"))
+    {
+      #### $3=41.62elapsed
+      myprint( "linux elapsed in second " )
+      RealTime=(substr($3,1,match($3, "elapsed")-1))
+      myprint( " real time seconds " RealTime )
+    }
+    next
+  }
+# curie system time (if not linux) or vargas
+### curie (with tab)
+### real    9m38.96s
+### user    0m4.45s
+### sys     0m6.41s
+### vargas (with space)
+### real   2891.80
+### user   0.28
+### sys    0.45
+
+  else if (match($1, "real"))
+  {
+    myprint( "curie ou vargas ?" )
+
+    # real    9m38.96s or real   2891.80
+    if (match($2, ".*s.*"))
+    {
+      myprint( "curie" )
+      counter=counter+1
+      ### real    9m38.96s
+      ### real  5h9m38.96s
+      RealTime=((substr($2,1,match($2, "h")-1)*60.)+substr($2,match($2, "h")+1,match($2, "m")-1))*60.+substr($2,match($2, "m")+1,match($2, "s"))
+      next
+    }
+    else
+    {
+      myprint( "vargas" )
+      counter=counter+1
+   
+      ### real 2891.80
+      RealTime=$2
+    next
+    }
+  }
+  else if (match($1, "user"))
+  {
+    # user(tab)0m4.45s or user   0.28
+    if (match($2, ".*s.*"))
+    {
+       myprint( "curie user" )
+       UserTime=((substr($2,1,match($2, "h")-1)*60.)+substr($2,match($2, "h")+1,match($2, "m")-1))*60.+substr($2,match($2, "m")+1,match($2, "s"))
+       next
+    }
+    else
+    {
+      myprint( "vargas user" )
+      UserTime=$2
+      next
+    }
+  }
+  else if (match($1, "sys"))
+  {
+    # 0m6.41s or 0.45
+    if (match($2, ".*s.*"))
+    {
+      myprint( "curie sys" )
+      SysTime=((substr($2,1,match($2, "h")-1)*60.)+substr($2,match($2, "h")+1,match($2, "m")-1))*60.+substr($2,match($2, "m")+1,match($2, "s"))
+      next
+    }
+    else
+    {
+      myprint( "vargas sys" )
+      SysTime=$2
+      next
+    }
+  }
+
+# Get information with time output on SX hosts
+# ksh time
+  else if (match($0, "real *[0-9:.]*"))
+  {
+    myprint("ksh SX")
+    Information_ksh_SX_found=1
+    counter=counter+1
+
+    RealTime=0
+    if (match($2, "[0-9]*:[0-9]*:[0-9]*\\.[0-9]*"))
+    {
+	sub1=(match($2, ":")-1)
+	sub2=sub1+2
+	fin=(substr($2,sub2))
+	sub3=(match(fin, ":")-1)+sub2
+	RealTime=(substr($2,1,sub1))*60+(substr($2,sub2,sub3))
+    }
+    else if (match($2, "[0-9]*:[0-9]*\\.[0-9]*"))
+    {
+	RealTime=(substr($2,1,match($2, ":")-1))
+    }
+  }
+  else if (Information_ksh_SX_found == 1 && match($0, "user *[0-9:.]*"))
+  {
+    myprint("ksh SX ")
+
+    UserTime=0
+    if (match($2, "[0-9]*:[0-9]*:[0-9]*\\.[0-9]*"))
+    {
+	sub1=(match($2, ":")-1)
+	sub2=sub1+2
+	fin=(substr($2,sub2))
+	sub3=(match(fin, ":")-1)+sub2
+	UserTime=(substr($2,1,sub1))*60+(substr($2,sub2,sub3))
+    }
+    else if (match($2, "[0-9]*:[0-9]*\\.[0-9]*"))
+    {
+	UserTime=(substr($2,1,match($2, ":")-1))
+    }
+  }
+  else if (Information_ksh_SX_found == 1 && match($0, "sys *[0-9:.]*"))
+  {
+    myprint("ksh SX ")
+
+    SysTime=0
+    if (match($2, "[0-9]*:[0-9]*:[0-9]*\\.[0-9]*"))
+    {
+	sub1=(match($2, ":")-1)
+	sub2=sub1+2
+	fin=(substr($2,sub2))
+	sub3=(match(fin, ":")-1)+sub2
+	SysTime=(substr($2,1,sub1))*60+(substr($2,sub2,sub3))
+    }
+    else if (match($2, "[0-9]*:[0-9]*\\.[0-9]*"))
+    {
+	SysTime=(substr($2,1,match($2, ":")-1))
+    }
+  }
+
+# RUN_DATE_BEGIN
+if ($0 ~ /RunDateBegin.*=/) {
+    myprint( "start date" )
+    split($0,a,"=")
+    RunDateBegin=a[2]
+}
+
+# RUN_DATE_END
+if ($0 ~ /RunDateEnd.*=/) {
+    myprint( "end date" )
+    split($0,a,"=")
+    RunDateEnd=a[2]
+  }
+
+}
+
+#==========================
+END {
+
+    myprint("exit_value : " exit_value)
+    myprint("counter    : " counter)
+
+  if (! exit_value ) {
+    if (counter > 0) { 
+      myprint("=============================================")
+      myprint("Additionnal results on Program Informations for " ARGV[1])
+      myprint("Real Time (sec)        :" RealTime)
+      myprint("User Time (sec)        :" UserTime)
+      myprint("Sys  Time (sec)        :" SysTime)
+      myprint("Vector Time (sec)      :" VectorTime)
+      myprint("Inst. Count            :" InstCount)
+      myprint("V. Inst. Count         :" VInstCount)
+      myprint("V. Element Count       :" VElementCount)
+      myprint("FLOP Count             :" FLOPCount)
+      myprint("MOPS                   :" MOPS)
+      myprint("MFLOPS                 :" MFLOPS)
+      myprint("A.V. Length            :" AVLength)
+      myprint("V. Op. Ratio (%)       :" VOpRatio)
+      myprint("Memory Size (MB)       :" MemorySize)
+      myprint("MIPS                   :" MIPS)
+      myprint("I-Cache (sec)          :" ICache)
+      myprint("O-Cache (sec)          :" OCache)
+      myprint("Bank (sec)             :" Bank)
+
+      myprint("Date of executables :")
+      myprint("Start Time             :" RunDateBegin)
+      myprint("End   Time             :" RunDateEnd)
+
+      printf("%s %s %.5f %.5f %.5f", RunDateBegin, RunDateEnd, RealTime, UserTime, SysTime) 
+      exit(0)
+    }
+    else
+    { 
+      exit(1)
+    }
+  }
+  else
+  { 
+    exit(2)
+  }
+  
+}
Index: /tags/libIGCM_v2.2/libIGCM_sys/IGCM_analyse_rsync_out.awk
===================================================================
--- /tags/libIGCM_v2.2/libIGCM_sys/IGCM_analyse_rsync_out.awk	(revision 998)
+++ /tags/libIGCM_v2.2/libIGCM_sys/IGCM_analyse_rsync_out.awk	(revision 998)
@@ -0,0 +1,120 @@
+#!/usr/bin/awk -f 
+# IGCM_analyse_rsync_out - filter rsync output in a job output :
+# command :
+# IGCM_analyse_rsync_out.awk [-d] job_output.out
+
+#**************************************************************
+# Author: Martial.Mancip
+# Contact: Martial.Mancip__at__ipsl.jussieu.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#==========================
+function myprint(str) {
+  if (debug) {
+     print str
+  }
+}
+
+
+#==========================
+BEGIN {
+#  print "traitement de " ARGV[1]
+
+  nbarg=ARGC
+
+  if (ARGV[1] == "-d") {
+    debug=1
+    file=ARGV[2]
+    delete ARGV[1] 
+    nbarg--
+  } else {
+    debug=0
+    file=ARGV[1]
+  }
+
+  exit_value=0
+  if (nbarg != 2) {
+        print "Usage: analyse_rsync_out.awk [-d] file"
+        exit_value=-1
+        exit
+  }
+    
+  rsync_found=0
+  speedup_found=0
+  counter=0
+  thisfile[1]=""
+  errcounter=0
+  errorfile[1]=""
+}
+
+#==========================
+{
+
+  myprint($0) 
+
+  if (rsync_found == 0 && match($0, ".*/rsync .*")) {
+    speedup_found = 0
+    rsync_found=1
+    counter=counter+1
+
+    nb=split($0,felts, " ")
+    myprint("nb  :" nb)
+    for (elt in felts) {
+	myprint(elt "- elt  :" felts[elt])
+    }
+    myprint("elts_split  :" felts[4])
+
+    thisfile[counter]=felts[4]
+  }
+  else if (rsync_found == 1 && match($0, ".* speedup is .*")) {
+    myprint("speedup_found = 1")
+    speedup_found = 1
+  }
+  else if (speedup_found == 1 && match($0, "rsync error:.*")) {
+    errcounter=errcounter+1
+    errorfile[errcounter]=thisfile[counter]
+    myprint("=============================================")
+    myprint("WARNING : Rsync ERROR for " ARGV[1])
+    myprint("counter  :" counter)
+    myprint("file  :" thisfile[counter])
+    thisfile[counter]=""
+    counter=counter-1
+  } 
+  else {
+    if ( speedup_found == 1 ) {
+      rsync_found=0
+      speedup_found=0
+    }
+  }
+}
+
+#==========================
+END {
+  if ( exit_value != -1 ) {
+
+    myprint("=============================================")
+    myprint("Rsync for " ARGV[1])
+    myprint("counter  :" counter)
+    for (i=1; i<=counter; i++) {  
+      myprint("file  :" thisfile[i])
+    }
+    if (errcounter > 0) {
+      debug=1
+      myprint("Error counter  :" errcounter)
+      for (i=1; i<=errcounter; i++) {  
+        myprint("Error file  :" errorfile[i])
+      }
+      exit_value=errcounter
+      print exit_value
+      exit exit_value
+    } 
+    exit_value=0
+    exit 0
+  }
+}
Index: /tags/libIGCM_v2.2/libIGCM_sys/jobAccounting.mail
===================================================================
--- /tags/libIGCM_v2.2/libIGCM_sys/jobAccounting.mail	(revision 998)
+++ /tags/libIGCM_v2.2/libIGCM_sys/jobAccounting.mail	(revision 998)
@@ -0,0 +1,11 @@
+Dear ${LOGIN},
+
+this mail will be sent once for the simulation ${config_UserChoices_JobName} you recently submitted
+
+The whole simulation will consume around ${consumeHoursPerWholeSimulation} hours. To be compared with your project allocation.
+
+The recommended PeriodNb for a 24 hours job seems to be around ${recommendedPeriodNb}. To be compare with the current setting \(Job_${config_UserChoices_JobName} parameter\) : PeriodNb=${PeriodNb}
+
+Greetings!
+
+Check this out for more information : https://forge.ipsl.jussieu.fr/igcmg/wiki/platform/en/documentation
Index: /tags/libIGCM_v2.2/libIGCM_sys/jobEnd.mail
===================================================================
--- /tags/libIGCM_v2.2/libIGCM_sys/jobEnd.mail	(revision 998)
+++ /tags/libIGCM_v2.2/libIGCM_sys/jobEnd.mail	(revision 998)
@@ -0,0 +1,17 @@
+Dear ${LOGIN},
+
+Simulation ${config_UserChoices_JobName} ${status} on supercomputer $( hostname )
+Simulation started : ${DateBegin}
+Simulation ended   : ${DateEnd}
+
+Output files are available in ${R_SAVE}
+
+Files to be rebuild are temporarily available in ${REBUILD_DIR}
+
+Pre-packed files are temporarily available in ${R_BUFR}
+
+Script files, Script Outputs and Debug files \(if necessary\) are available in ${SUBMIT_DIR}
+
+Greetings!
+
+Check this out for more information : https://forge.ipsl.jussieu.fr/igcmg/wiki/platform/en/documentation
Index: /tags/libIGCM_v2.2/libIGCM_sys/libIGCM_sys.ksh
===================================================================
--- /tags/libIGCM_v2.2/libIGCM_sys/libIGCM_sys.ksh	(revision 998)
+++ /tags/libIGCM_v2.2/libIGCM_sys/libIGCM_sys.ksh	(revision 998)
@@ -0,0 +1,79 @@
+#!/bin/ksh
+
+#**************************************************************
+# Author: Martial Mancip
+# Contact: Martial.Mancip__at__ipsl.jussieu.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+# bypass specific internationalization (for gawk)
+export LC_ALL="C"
+
+# By default, all libIGCM_sys save functions will protect output datas (RUN execution mode)
+# other values : DEB(ug), DEV(elopment).
+JobType=${JobType:=RUN}
+
+#====================================================
+# set PackDefault false by default
+PackDefault=false
+
+#====================================================
+# set BigBrother false by default
+BigBrother=${BigBrother:=false}
+
+#====================================================
+# set BigBrother channel (AMQP or MAIL)
+# only MAIL working at present due to firewall constraint
+BigBrotherChannel=MAIL
+
+# variable that must have lower case value.
+typeset -l config_Post_RebuildFromArchive
+
+# no need to be so verbose in checking mode
+if [ ! X${TaskType} = Xchecking ] ; then
+  echo
+  echo "===================================================="
+  echo "Where do we run ?" $( hostname )
+  uname -a
+  echo "===================================================="
+  echo
+fi
+
+if [ X${JobType} = XDEB ] ; then
+    echo "DEBUG mode : activation of 'set -vx' mode."
+    set -vx
+    DEBUG_debug=true
+    DEBUG_sys=true
+fi
+
+#====================================================
+case $( hostname -s ) in
+    ada*)
+        [ ! X${TaskType} = Xchecking ] && echo "sys source ada Intel X-64 lib."
+        CENTER=IDRIS
+        . ${libIGCM}/libIGCM_sys/libIGCM_sys_ada.ksh;;
+    curie*)
+        [ ! X${TaskType} = Xchecking ] && echo "sys source curie Intel X-64 lib."
+        CENTER=TGCC
+        . ${libIGCM}/libIGCM_sys/libIGCM_sys_curie.ksh;;
+    asterix*|obelix*)
+        [ ! X${TaskType} = Xchecking ] && echo "sys source obelix or asterix lib."
+        CENTER=LSCE
+        . ${libIGCM}/libIGCM_sys/libIGCM_sys_obelix.ksh;;
+    iitm*)
+        [ ! X${TaskType} = Xchecking ] && echo "sys source iitm lib."
+        CENTER=IITM
+        . ${libIGCM}/libIGCM_sys/libIGCM_sys_iitm.ksh;;
+    *)
+        [ ! X${TaskType} = Xchecking ] && echo "sys source default lib."
+        CENTER=DEFAULT
+        . ${libIGCM}/libIGCM_sys/libIGCM_sys_default.ksh;;
+esac
+
+# Set default umask (umask is 0027 on some machines : CCRT machine at least)
+umask 0022
Index: /tags/libIGCM_v2.2/libIGCM_sys/libIGCM_sys_ada.ksh
===================================================================
--- /tags/libIGCM_v2.2/libIGCM_sys/libIGCM_sys_ada.ksh	(revision 998)
+++ /tags/libIGCM_v2.2/libIGCM_sys/libIGCM_sys_ada.ksh	(revision 998)
@@ -0,0 +1,2670 @@
+#!/bin/ksh
+
+#**************************************************************
+# Author: Sébastien Denvil
+# Contact: Sebastien.Denvil__at__ipsl.jussieu.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#=========================================================
+# The documentation of this file can be automatically generated
+# if you use the prefix #D- for comments to be extracted.
+# Extract with command: cat lib* | grep "^#D-" | cut -c "4-"
+#=========================================================
+
+#D-#==================================================
+#D-LibIGCM_sys for Ada
+#D-#==================================================
+#D-
+#D- This ksh library if a layer under some usefull
+#D-environment variables and shell commands.
+#D-All those definitions depend on host particularities.
+#D-It manages a stack mechanism and test validity of operations.
+#D-All function described bellow must be prefixed by IGCM_sys.
+
+#====================================================
+# libIGCM_sys PARAMETERS
+#====================================================
+
+#====================================================
+# set DEBUG_sys to true to output calls of function
+typeset -r DEBUG_sys=${DEBUG_sys:=true}
+
+#====================================================
+# Turn in dry run mode ? (sys_Put_Rest, sys_Put_Out, sys_Get)
+typeset -r DRYRUN=${DRYRUN:=0}
+
+# YOU MUST COMPILE YOUR EXE FILES FOR DRYRUN MODE !
+# -------------------------------------------------------------------------------------
+# | DRYRUN=  |  Date computations, | sys_Get    |  Exe    | sys_Put_Out; sys_Put_Rest |
+# |          |  Cp/Exe/param/files |            |         |                           |
+# |          |  Chmod Qsub         |            |         |                           |
+# -------------------------------------------------------------------------------------
+# |    0     |       yes           |    yes     |  yes    |      yes                  |
+# -------------------------------------------------------------------------------------
+# |    1     |       yes           |    yes     |  yes    |      no                   |
+# -------------------------------------------------------------------------------------
+# |    2     |       yes           |    yes     |  no     |      no                   |
+# -------------------------------------------------------------------------------------
+# |    3     |       yes           |    no      |  no     |      no                   |
+# -------------------------------------------------------------------------------------
+
+#=====================================================
+# Global Variables :
+#=====================================================
+# Language : "fr" or "en"
+typeset -r MYLANG="fr"
+
+#=====================================================
+# Host and user names
+# $hostname ou hostname
+typeset  HOST=${HOST:=$( hostname )}
+# $username ou whoami
+typeset  LOGIN=${LOGIN:=$( whoami )}
+# $hostname of the MASTER job
+typeset MASTER=ada
+
+#D-
+#D-#==================================================
+#D-Program used in libIGCM
+#D-#==================================================
+
+# Submit command
+typeset SUBMIT=${SUBMIT:=llsubmit}
+# rsync with path
+typeset -r RSYNC=/usr/bin/rsync
+# RSYNC_opt args to rsync
+typeset -r RSYNC_opt="-va"
+# ie storage filesystem
+typeset -r STOREHOST=gaya
+typeset -r REMOTE_RSYNC=/u/rech/ces/rces452/RSYNC/bin/rsync
+
+#====================================================
+# Source default environment
+#====================================================
+##. /etc/profile
+
+#====================================================
+# Set environment tools (ferret, nco, cdo)
+#====================================================
+source /smplocal/pub/Modules/default/init/ksh
+. /smphome/rech/psl/rpsl035/.atlas_env_ada_bash > /dev/null 2>&1
+export PATH=${PATH}:/smphome/rech/psl/rpsl035/AddNoise/src_X64_ADA/bin
+
+#====================================================
+# Host specific DIRECTORIES
+#====================================================
+
+#====================================================
+#- MirrorlibIGCM for frontend
+typeset -r MirrorlibIGCM=${MirrorlibIGCM:=false}
+
+#====================================================
+#- libIGCM_POST for frontend
+typeset -r libIGCM_POST=${libIGCM}
+
+#====================================================
+#- R_EXE   (==> BIN_DIR = ${MODIPSL}/bin )
+typeset -r R_EXE="${MODIPSL}/bin"
+
+#====================================================
+#- SUBMIT_DIR : submission dir
+typeset SUBMIT_DIR=${SUBMIT_DIR:=${LOADL_STEP_INITDIR}}
+
+#====================================================
+#- IN
+typeset -r R_IN=${R_IN:=/workgpfs/rech/psl/rpsl035/IGCM}
+typeset -r R_IN_ECMWF=${R_IN_ECMWF:=/u/rech/psl/rpsl376}
+
+#====================================================
+#- ARCHIVE (dedicated to large files)
+typeset ARCHIVE=$(echo ${HOME} | sed -e "s,/.*home/,/u/,")
+
+#====================================================
+#- STORAGE (dedicated to small/medium files)
+typeset STORAGE=${WORKDIR}
+
+#====================================================
+#- R_OUT
+typeset R_OUT=${ARCHIVE}/IGCM_OUT
+
+#====================================================
+#- R_FIG (hosting figures : monitoring and atlas, and/or small files)
+typeset R_FIG=${ARCHIVE}/IGCM_OUT
+
+#====================================================
+#- R_BUF (ONLY FOR double copy an scratch)
+typeset -r R_BUF=${WORKDIR}/IGCM_OUT
+
+#====================================================
+#- RUN_DIR_PATH : Temporary working directory (=> TMP)
+typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=${TMPDIR}}
+
+#====================================================
+#- HOST_MPIRUN_COMMAND
+typeset -r HOST_MPIRUN_COMMAND=${HOST_MPIRUN_COMMAND:="/usr/bin/time poe"}
+
+#====================================================
+#- Max number of arguments passed to nco operator or demigration command
+UNIX_MAX_LIMIT=360
+
+#====================================================
+#- set PackDefault true on curie
+PackDefault=true
+
+#====================================================
+#- Number of core per node (max number of OpenMP task)
+NUM_COREPERNODE=8
+
+#====================================================
+#- Default number of MPI task for IPSL coupled model
+#- required for backward compatibility
+#-
+DEFAULT_NUM_PROC_OCE=5
+DEFAULT_NUM_PROC_CPL=1
+(( DEFAULT_NUM_PROC_ATM = BATCH_NUM_PROC_TOT - DEFAULT_NUM_PROC_OCE - DEFAULT_NUM_PROC_CPL ))
+DEFAULT_NUM_PROC_TOTAL=${BATCH_NUM_PROC_TOT}
+
+#D-#==================================================
+#D-function IGCM_sys_ChangeArchive
+#D-* Purpose: if SpaceName=TEST everything is stored on SCRATCHDIR
+#D-* Examples:
+#D-
+function IGCM_sys_ChangeArchive {
+  IGCM_debug_PushStack "IGCM_sys_ChangeArchive"
+
+  R_OUT=${WORKDIR}/IGCM_OUT
+  R_FIG=${WORKDIR}/IGCM_OUT
+
+  IGCM_debug_Print 1 "R_OUT   has been redefined = ${R_OUT}"
+  IGCM_debug_Print 1 "R_FIG   has been redefined = ${R_FIG}"
+
+  IGCM_debug_PopStack "IGCM_sys_ChangeArchive"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_RshMaster
+#D-* Purpose: Connection to frontend machine.
+#D-* Examples:
+#D-
+function IGCM_sys_RshMaster {
+  IGCM_debug_PushStack "IGCM_sys_RshMaster" $@
+  /bin/ksh <<-EOF
+    export libIGCM=${libIGCM}
+    export DEBUG_debug=${DEBUG_debug}
+    . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
+    . ${libIGCM}/libIGCM_card/libIGCM_card.ksh
+    ${@}
+EOF
+  if [ $? -gt 0 ] ; then
+    echo "IGCM_sys_RshMaster : erreur."
+    IGCM_debug_Exit "IGCM_sys_RshMaster"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_RshMaster"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_RshArchive
+#D-* Purpose: Archive rsh command
+#D-* Examples:
+#D-
+function IGCM_sys_RshArchive {
+  IGCM_debug_PushStack "IGCM_sys_RshArchive" $@
+  DEBUG_sys=false IGCM_sys_IsFileArchived "$@"
+  if [ $? = 0 ] ; then
+    rsh ${STOREHOST} exec /bin/ksh <<-EOF
+    ${@}
+EOF
+    status=$?
+  else
+    /bin/ksh <<-EOF
+    ${@}
+EOF
+    status=$?
+  fi
+  if [ ${status} -gt 0 ] ; then
+    IGCM_debug_Print 2 "IGCM_sys_RshArchive : rsh or command failed error code ${status}"
+    IGCM_debug_Exit "IGCM_sys_RshArchive"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_RshArchive"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_RshArchive_NoError
+#D-* Purpose: Archive rsh command, without error
+#D-*          used only in monitoring.job
+#D-* Examples:
+#D-
+function IGCM_sys_RshArchive_NoError {
+  IGCM_debug_PushStack "IGCM_sys_RshArchive_NoError" $@
+  DEBUG_sys=false IGCM_sys_IsFileArchived "$@"
+  if [ $? = 0 ] ; then
+    rsh ${STOREHOST} exec /bin/ksh <<-EOF
+    ${@} 2> /dev/null
+EOF
+  else
+    /bin/ksh <<-EOF
+    ${@} 2> /dev/null
+EOF
+  fi
+  IGCM_debug_PopStack "IGCM_sys_RshArchive_NoError"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_RshPost
+#D-* Purpose: Post-process rsh command
+#D-* Examples:
+#D-
+function IGCM_sys_RshPost {
+  IGCM_debug_PushStack "IGCM_sys_RshPost" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_RshPost :" $@
+  fi
+  # keep standard input (stdin) for the loop onto temporary file
+  cat >/tmp/tmp_IGCM_sys_RshPost_$$_${LOGNAME}
+
+  /bin/ksh </tmp/tmp_IGCM_sys_RshPost_$$_${LOGNAME}
+  if [ $? -gt 0 ] ; then
+    echo "IGCM_sys_RshPost : erreur."
+    IGCM_debug_Exit "IGCM_sys_RshPost"
+  fi
+  # delete temporary file
+  \rm /tmp/tmp_IGCM_sys_RshPost_$$_${LOGNAME}
+
+  IGCM_debug_PopStack "IGCM_sys_RshPost"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_SendMail
+#D-* Purpose: Send mail when simulation is over
+#D-* Examples:
+#D-
+function IGCM_sys_SendMail {
+  IGCM_debug_PushStack "IGCM_sys_SendMail" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_SendMail :" $@
+  fi
+
+  if [ X${1} = XAccounting ] ; then
+    status=Accounting
+    mailText=jobAccounting.mail
+  elif ( ${ExitFlag} ) ; then
+    status=failed
+    mailText=jobEnd.mail
+  else
+    status=completed
+    mailText=jobEnd.mail
+  fi
+
+  # Update selected mail template
+  while read -r line; do
+    eval echo $line >> mail.txt ;
+  done < ${libIGCM}/libIGCM_sys/${mailText}
+
+  if [ ! -z ${config_UserChoices_MailName} ] ; then
+    mail -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} <  mail.txt
+  elif [ -f ~/.forward ] ; then
+    mail -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < mail.txt
+  else
+    mail -s "${config_UserChoices_JobName} ${status}" ${USER} < mail.txt
+  fi
+
+  sleep 10
+  rm -f mail.txt
+
+  IGCM_debug_PopStack "IGCM_sys_SendMail"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Mkdir
+#D-* Purpose: Master locale mkdir command
+#D-* Examples:
+#D-
+function IGCM_sys_Mkdir {
+  IGCM_debug_PushStack "IGCM_sys_Mkdir" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Mkdir :" $@
+  fi
+  if [ ! -d ${1} ]; then
+    \mkdir -p $1
+    if [ $? -gt 0 ] ; then
+      echo "IGCM_sys_Mkdir : erreur."
+      IGCM_debug_Exit "IGCM_sys_Mkdir"
+    fi
+  fi
+  # vérification :
+  if [ ! -d ${1} ] ; then
+    echo "IGCM_sys_Mkdir : erreur."
+    IGCM_debug_Exit "IGCM_sys_Mkdir"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Mkdir"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_MkdirArchive
+#D-* Purpose: Mkdir on Archive
+#D-* Examples:
+#D-
+function IGCM_sys_MkdirArchive {
+  IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_MkdirArchive :" $@
+  fi
+  #- creation de repertoire sur le serveur fichier
+  DEBUG_sys=false IGCM_sys_IsFileArchived $1
+  if [ $? = 0 ] ; then
+    rsh ${STOREHOST} -n mkdir -p $1
+    status=$?
+  else
+    mkdir -p $1
+    status=$?
+  fi
+
+  if [ ${status} -gt 0 ] ; then
+    IGCM_debug_Print 2 "IGCM_sys_MkdirArchive : rsh or mkdir failed error code ${status}"
+    IGCM_debug_Exit "IGCM_sys_MkdirArchive"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_MkdirArchive"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_MkdirWork
+#D-* Purpose: Mkdir on Work
+#D-* Examples:
+#D-
+function IGCM_sys_MkdirWork {
+  IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_MkdirWork :" $@
+  fi
+  #- creation de repertoire sur le serveur fichier
+  if [ ! -d ${1} ]; then
+    \mkdir -p $1
+    if [ $? -gt 0 ] ; then
+      echo "IGCM_sys_MkdirWork : erreur."
+      IGCM_debug_Exit "IGCM_sys_MkdirWork"
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_MkdirWork"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Cd
+#D-* Purpose: master cd command
+#D-* Examples:
+#D-
+function IGCM_sys_Cd {
+  IGCM_debug_PushStack "IGCM_sys_Cd" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Cd :" $@
+  fi
+  \cd $1
+  if [ $? -gt 0 ] ; then
+    echo "IGCM_sys_Cd : erreur."
+    IGCM_debug_Exit "IGCM_sys_Cd"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Cd"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Chmod
+#D-* Purpose: Chmod
+#D-* Examples:
+#D-
+function IGCM_sys_Chmod {
+  IGCM_debug_PushStack "IGCM_sys_Chmod" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Chmod :" $@
+  fi
+  \chmod $@
+  if [ $? -gt 0 ] ; then
+    echo "IGCM_sys_Chmod : erreur."
+    IGCM_debug_Exit "IGCM_sys_Chmod"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Chmod"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_FileSize
+#D-* Purpose: Filesize
+#D-* Examples:
+#D-
+function IGCM_sys_FileSize {
+  IGCM_debug_PushStack "IGCM_sys_FileSize" $@
+
+  typeset sizeF
+  set +A sizeF -- $( ls -la ${1} )
+  if [ $? -gt 0 ] ; then
+    IGCM_debug_Exit "IGCM_sys_FileSize"
+  fi
+  eval ${2}=${sizeF[4]}
+
+  IGCM_debug_PopStack "IGCM_sys_FileSize"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_TestDir
+#D-* Purpose: Test Directory that must exists
+#D-* Examples:
+#D-
+function IGCM_sys_TestDir {
+  IGCM_debug_PushStack "IGCM_sys_TestDir" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_TestDir :" $@
+  fi
+  typeset ExistFlag
+  ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
+  IGCM_debug_PopStack "IGCM_sys_TestDir"
+
+  return ${ExistFlag}
+}
+
+#D-#==================================================
+#D-function IGCM_sys_TestDirArchive
+#D-* Purpose: Test Directory that must exists on Archive
+#D-* Examples:
+#D-
+function IGCM_sys_TestDirArchive {
+  IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_TestDirArchive :" $@
+  fi
+  typeset ExistFlag
+  #Command depends on targeted file system
+  DEBUG_sys=false IGCM_sys_IsFileArchived $1
+  if [ $? = 0 ] ; then
+    ExistFlag=$( IGCM_sys_RshArchive "[ -d $1 ] && echo 0 || echo 1" )
+  else
+    ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
+  fi
+  IGCM_debug_PopStack "IGCM_sys_TestDirArchive"
+  return ${ExistFlag}
+}
+
+#D-#==================================================
+#D-function IGCM_sys_IsFileArchived
+#D-* Purpose: Test file that must NOT EXISTS on Archive
+#D-* Examples:
+#D-
+function IGCM_sys_IsFileArchived {
+  IGCM_debug_PushStack "IGCM_sys_IsFileArchived" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_IsFileArchived :" $@
+  fi
+  typeset IsArchivedFlag
+  IsArchivedFlag=$( [ "X$( echo $@ | grep \/u\/rech )" != "X" ] && echo 0 || echo 1 )
+  IGCM_debug_PopStack "IGCM_sys_IsFileArchived"
+
+  return ${IsArchivedFlag}
+}
+
+#D-#==================================================
+#D-function IGCM_sys_TestFileArchive
+#D-* Purpose: Test file that must NOT EXISTS on Archive
+#D-* Examples:
+#D-
+function IGCM_sys_TestFileArchive {
+  IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@
+  typeset ExistFlag
+  #Command depends on targeted file system
+  #We want it quiet
+  DEBUG_sys=false IGCM_sys_IsFileArchived $1
+  if [ $? = 0 ] ; then
+    ExistFlag=$( IGCM_sys_RshArchive "[ -f $1 ] && echo 0 || echo 1" )
+  else
+    ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 )
+  fi
+  IGCM_debug_PopStack "IGCM_sys_TestFileArchive"
+
+  return ${ExistFlag}
+}
+
+#D-#==================================================
+#D-function IGCM_sys_TestFileBuffer
+#D-* Purpose: Test file that must NOT EXISTS on Buffer
+#D-* Examples:
+#D-
+function IGCM_sys_TestFileBuffer {
+  IGCM_debug_PushStack "IGCM_sys_TestFileBuffer" $@
+  typeset ExistFlag
+  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 )
+  IGCM_debug_PopStack "IGCM_sys_TestFileBuffer"
+
+  return ${ExistFlag}
+}
+
+#D-#==================================================
+#D-function IGCM_sys_CountFileArchive
+#D-* Purpose: Count files on Archive filesystem
+#D-* Examples:
+#D-
+function IGCM_sys_CountFileArchive {
+  IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@
+  #Command depends on targeted file system
+  DEBUG_sys=false IGCM_sys_IsFileArchived $1
+  if [ $? = 0 ] ; then
+    IGCM_sys_RshArchive "ls ${@} 2>/dev/null | wc -l"
+    status=$?
+  else
+    ls ${@} 2>/dev/null | wc -l
+    status=$?
+  fi
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_CountFileArchive : erreur."
+  fi
+  IGCM_debug_PopStack "IGCM_sys_CountFileArchive"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_CountFileBuffer
+#D-* Purpose: Count files on Scratch filesystem
+#D-* Examples:
+#D-
+function IGCM_sys_CountFileBuffer {
+  IGCM_debug_PushStack "IGCM_sys_CountFileBuffer" $@
+  ls ${@} 2>/dev/null | wc -l
+  if [ $? -gt 0 ] ; then
+    echo "IGCM_sys_CountFileBuffer : erreur."
+  fi
+  IGCM_debug_PopStack "IGCM_sys_CountFileBuffer"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Tree
+#D-* Purpose: Tree directories with files on ${ARCHIVE}
+#D-* Examples: IGCM_sys_Tree ${R_IN} ${R_OUT}
+#D-
+function IGCM_sys_Tree {
+  IGCM_debug_PushStack "IGCM_sys_Tree" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Tree :" $@
+  fi
+
+  \mfls -r $@
+
+  IGCM_debug_PopStack "IGCM_sys_Tree"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Tar
+#D-* Purpose: master tar command
+#D-* Examples:
+#D-
+function IGCM_sys_Tar {
+  IGCM_debug_PushStack "IGCM_sys_Tar" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Tar :" $@
+  fi
+  \tar cf $@
+  if [ $? -gt 0 ] ; then
+    echo "IGCM_sys_Tar : erreur."
+    IGCM_debug_Exit "IGCM_sys_Tar"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Tar"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_UnTar
+#D-* Purpose: master un-tar command
+#D-* Examples:
+#D-
+function IGCM_sys_UnTar {
+  IGCM_debug_PushStack "IGCM_sys_UnTar" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_UnTar :" $@
+  fi
+  \tar xvf $1
+  if [ $? -gt 0 ] ; then
+    echo "IGCM_sys_UnTar : erreur."
+    IGCM_debug_Exit "IGCM_sys_UnTar"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_UnTar"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Qsub
+#D-* Purpose: Qsub new job
+#D-* Examples:
+#D-
+function IGCM_sys_Qsub {
+  IGCM_debug_PushStack "IGCM_sys_Qsub" $@
+
+  typeset status
+
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Qsub :" $@
+  fi
+  # We have to change output/error file
+  [ ${#@} = 1 ] &&  REP_FOR_JOB=${SUBMIT_DIR}
+  [ ${#@} = 2 ] &&  REP_FOR_JOB=${2}
+  sed -e "s:\# \@ output *= .*:\# \@ output = ${Script_Output}:" \
+      -e "s:\# \@ error *= .*:\# \@ error = ${Script_Output}:"   \
+      $1 > ${REP_FOR_JOB}/JOB_FOR_IGCM
+  cd $REP_FOR_JOB ; /usr/bin/llsubmit JOB_FOR_IGCM > /tmp/out_command.$$ 2>&1 ; status=$? ; cd - ;
+
+  cat /tmp/out_command.$$
+  if [ ${status} -gt 0 ] ; then
+    IGCM_debug_Print 2 "IGCM_sys_Qsub $1 : error code ${status}"
+    IGCM_debug_Exit "IGCM_sys_Qsub"
+  else
+    JobID=$( gawk {'print $4'} /tmp/out_command.$$ | tail -1 | sed -e s/\"//g )
+    IGCM_sys_Rm ${REP_FOR_JOB}/JOB_FOR_IGCM
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Qsub"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_QsubPost
+#D-* Purpose: Qsub new job on scalaire
+#D-* Examples:
+#D-
+function IGCM_sys_QsubPost {
+  IGCM_debug_PushStack "IGCM_sys_QsubPost" $@
+
+  typeset status
+
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_QsubPost :" $@
+  fi
+  # We have to change output/error file
+  [ ${#@} = 1 ] &&  REP_FOR_JOB=${POST_DIR}
+  [ ${#@} = 2 ] &&  REP_FOR_JOB=${2}
+
+  sed -e "s:\# \@ output *= .*:\# \@ output = ${Script_Post_Output}.out:" \
+      -e "s:\# \@ error *= .*:\# \@ error = ${Script_Post_Output}.out:"   \
+      ${libIGCM_POST}/$1.job > ${REP_FOR_JOB}/JOB_FOR_IGCM_$$
+
+  cd $REP_FOR_JOB ; /usr/bin/llsubmit JOB_FOR_IGCM_$$ > /tmp/out_command.$$ 2>&1 ; status=$? ; cd - ;
+
+  cat /tmp/out_command.$$
+  if [ ${status} -gt 0 ] ; then
+    IGCM_debug_Print 2 "IGCM_sys_QsubPost $1 : error code ${status}"
+    IGCM_debug_Exit "IGCM_sys_QsubPost"
+  else
+    JobID=$( gawk {'print $4'} /tmp/out_command.$$ | tail -1 | sed -e s/\"//g )
+    IGCM_sys_Rm ${REP_FOR_JOB}/JOB_FOR_IGCM_$$
+  fi
+  IGCM_debug_PopStack "IGCM_sys_QsubPost"
+}
+
+#D-*************************
+#D- File transfer functions
+#D-*************************
+#D-
+
+#D-#==================================================
+#D-function IGCM_sys_Rsync_out
+#D-* Purpose: treat return val of rsync
+#D-* Examples: IGCM_sys_Rsync_out out_RET_rsync
+#D-  Error values and explanations can depend on your system version.
+function IGCM_sys_Rsync_out {
+  status=$1
+  if [ ! $status ] ; then
+    echo "rsync error !"
+  fi
+
+  if [ $MYLANG = "fr" ]; then
+    case $status in
+    0)  return ;;
+    1)  echo "Erreur de rsync ; RERR_SYNTAX : "
+      echo "Erreur de syntaxe ou d'utilisation."
+      return;;
+    2)  echo "Erreur de rsync ; RERR_PROTOCOL : "
+      echo "Incompatibilité de protocole."
+      return;;
+    3)  echo "Erreur de rsync ; RERR_FILESELECT 3"
+      echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et"
+      echo "répertoires"
+      return;;
+    4)  echo "Erreur de rsync ; RERR_UNSUPPORTED"
+      echo "Action demandée non supportée : une tentative de manipulation de"
+      echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a"
+      echo "été faite ; ou une option qui est supportée par le  client  mais"
+      echo "pas par le serveur a été spécifiée."
+      return;;
+    10) echo "Erreur de rsync ; RERR_SOCKETIO"
+      echo "Erreur dans le socket d'entrée sortie"
+      return;;
+    11) echo "Erreur de rsync ; RERR_FILEIO"
+      echo "Erreur d'entrée sortie fichier"
+      return;;
+    12) echo "Erreur de rsync ; RERR_STREAMIO"
+      echo "Erreur dans flux de donnée du protocole rsync"
+      return;;
+    13) echo "Erreur de rsync ; RERR_MESSAGEIO"
+      echo "Erreur avec les diagnostics du programme"
+      return;;
+    14) echo "Erreur de rsync ; RERR_IPC"
+      echo "Erreur dans le code IPC"
+      return;;
+    20) echo "Erreur de rsync ; RERR_SIGNAL"
+      echo "SIGUSR1 ou SIGINT reçu"
+      return;;
+    21) echo "Erreur de rsync ; RERR_WAITCHILD"
+      echo "Une erreur retournée par waitpid()"
+      return;;
+    22) echo "Erreur de rsync ; RERR_MALLOC"
+      echo "Erreur lors de l'allocation des tampons de mémoire de coeur"
+      return;;
+    23) echo ""
+      echo "Erreur fichier inexistant"
+      return;;
+    30) echo "Erreur de rsync ; RERR_TIMEOUT"
+      echo "Temps d'attente écoulé dans l'envoi/réception de données"
+      return;;
+    *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $status
+      return;;
+    esac
+  elif [ $MYLANG = "en" ] ; then
+    case $status in
+    0)  return;;
+    1)  echo "rsync error : Syntax or usage error "
+      return;;
+    2)  echo "rsync error : Protocol incompatibility "
+      return;;
+    3)  echo "rsync error : Errors selecting input/output files, dirs"
+      return;;
+    4)  echo "rsync error : Requested action not supported: an attempt"
+      echo "was made to manipulate 64-bit files on a platform that cannot support"
+      echo "them; or an option was specified that is supported by the client and"
+      echo "not by the server."
+      return;;
+    5)  echo "rsync error : Error starting client-server protocol"
+      return;;
+    10) echo "rsync error : Error in socket I/O "
+      return;;
+    11) echo "rsync error : Error in file I/O "
+      return;;
+    12) echo "rsync error : Error in rsync protocol data stream "
+      return;;
+    13) echo "rsync error : Errors with program diagnostics "
+      return;;
+    14) echo "rsync error : Error in IPC code "
+      return;;
+    20) echo "rsync error : Received SIGUSR1 or SIGINT "
+      return;;
+    21) echo "rsync error : Some error returned by waitpid() "
+      return;;
+    22) echo "rsync error : Error allocating core memory buffers "
+      return;;
+    23) echo "rsync error : Partial transfer due to error"
+      return;;
+    24) echo "rsync error : Partial transfer due to vanished source files"
+      return;;
+    30) echo "rsync error : Timeout in data send/receive "
+      return;;
+    *)  echo "rsync error : return code of rsync unknown :" $status
+      return;;
+    esac
+  else
+    echo "unknown language $MYLANG."
+    return
+  fi
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Miror_libIGCM
+#D-* Purpose: Mirror libIGCM PATH and lib to frontend
+#D-* Examples:
+#D-
+function IGCM_sys_Mirror_libIGCM {
+  IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM"
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Mirror_libIGCM"
+  fi
+
+  typeset status
+
+  mkdir -p ${HOME}/MIRROR/${PATHlibIGCM}
+
+  echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > /tmp/out_command.$$ 2>&1
+  ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> /tmp/out_command.$$ 2>&1
+  status=$?
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on frontend."
+    cat /tmp/out_command.$$
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Cp
+#D-* Purpose: generic cp
+#D-* Examples:
+#D-
+function IGCM_sys_Cp {
+  IGCM_debug_PushStack "IGCM_sys_Cp" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Cp :" $@
+  fi
+
+  typeset status
+
+  echo cp $@ > /tmp/out_command.$$ 2>&1
+  \cp $@ >> /tmp/out_command.$$ 2>&1
+  status=$?
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_Cp : error code ${status}"
+    cat /tmp/out_command.$$
+    IGCM_debug_Exit "IGCM_sys_Cp"
+  else
+    \rm /tmp/out_command.$$
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Cp"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Rm
+#D-* Purpose: generic rm
+#D-* Examples:
+#D-
+function IGCM_sys_Rm {
+  IGCM_debug_PushStack "IGCM_sys_Rm" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Rm :" $@
+  fi
+
+  typeset status
+
+  echo rm $@ > /tmp/out_command.$$ 2>&1
+  \rm $@ >> /tmp/out_command.$$ 2>&1
+  status=$?
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_Rm : error code ${status}"
+    cat /tmp/out_command.$$
+    IGCM_debug_Exit "IGCM_sys_Rm"
+  else
+    \rm /tmp/out_command.$$
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Rm"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_RmRunDir
+#D-* Purpose: rm tmpdir (dummy function most of the time batch
+#D-                      scheduler will do the job)
+#D-* Examples:
+#D-
+function IGCM_sys_RmRunDir {
+  IGCM_debug_PushStack "IGCM_sys_RmRunDir" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_RmRunDir :" $@
+    echo "Dummy call, let the scheduler do that."
+  fi
+  IGCM_debug_PopStack "IGCM_sys_RmRunDir"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Mv
+#D-* Purpose: generic move
+#D-* Examples:
+#D-
+function IGCM_sys_Mv {
+  IGCM_debug_PushStack "IGCM_sys_Mv" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Mv :" $@
+  fi
+
+  if [ $DRYRUN = 0 ]; then
+
+    typeset status
+
+    echo mv $@ > /tmp/out_command.$$ 2>&1
+    \mv $@ >> /tmp/out_command.$$ 2>&1
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_Mv : error code ${status}"
+      cat /tmp/out_command.$$
+      IGCM_debug_Exit "IGCM_sys_Mv"
+    else
+      \rm /tmp/out_command.$$
+    fi
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_Mv"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Put_Dir
+#D-* Purpose: Copy a complete directory on $(ARCHIVE)
+#D-* Examples:
+#D-
+function IGCM_sys_Put_Dir {
+  IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Put_Dir :" $@
+  fi
+  if [ $DRYRUN = 0 ]; then
+    if [ ! -d ${1} ] ; then
+      echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ."
+      IGCM_debug_PopStack "IGCM_sys_Put_Dir"
+      return
+    fi
+
+    typeset status
+
+    # Only if we use rsync
+    #IGCM_sys_TestDirArchive $( dirname $2 )
+    #
+    #Command depends on targeted file system
+    DEBUG_sys=false IGCM_sys_IsFileArchived $2
+    if [ $? = 0 ] ; then
+      \rcp -r $1 ${STOREHOST}:$2 > /tmp/out_command.$$ 2>&1
+      status=$?
+    else
+      \cp -r $1 $2 > /tmp/out_command.$$ 2>&1
+      status=$?
+    fi
+
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_Put_Dir : rcp or cp failed error code ${status}"
+      cat /tmp/out_command.$$
+      IGCM_debug_Exit "IGCM_sys_Put_Dir"
+    else
+      \rm /tmp/out_command.$$
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Put_Dir"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Get_Dir
+#D-* Purpose: Copy a complete directory from ${ARCHIVE}
+#D-* Examples:
+#D-
+function IGCM_sys_Get_Dir {
+  IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Get_Dir :" $@
+  fi
+  if [ $DRYRUN = 0 ]; then
+#    if [ ! -d ${1} ] ; then
+#      echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ."
+#      IGCM_debug_PopStack "IGCM_sys_Get_Dir"
+#      return
+#    fi
+
+    typeset NB_ESSAI DELAI status i
+    # number of tentative
+    NB_ESSAI=3
+    # time delay between tentative
+    DELAI=2
+
+    # Only if we use rsync
+    #IGCM_sys_TestDirArchive $( dirname $2 )
+    #
+    # Command depends on targeted filesystem
+    DEBUG_sys=false IGCM_sys_IsFileArchived $1
+    if [ $? = 0 ] ; then
+      # add dmget (to demigrate all offline files) to reduce time of this command :
+      IGCM_sys_RshArchive "dmfind $1 -state MIG -o -state OFL -o -state PAR | dmget -q -n"
+      i=0
+      while [ $i -lt $NB_ESSAI ] ; do
+        \rcp -rp ${STOREHOST}:$1 $2 > /tmp/out_command.$$ 2>&1
+        status=$?
+        if [ ${status} -gt 0 ]; then
+          IGCM_debug_Print 2 "IGCM_sys_Get_Dir : rcp failed error code ${status} ${i}/${NB_ESSAI}"
+          IGCM_debug_Print 2 "IGCM_sys_Get_Dir : sleep ${DELAI} seconds and try again."
+          sleep $DELAI
+        else
+          break
+        fi
+        (( i = i + 1 ))
+      done
+    else
+      \cp -rp $1 $2 > /tmp/out_command.$$ 2>&1
+      status=$?
+      if [ ${status} -gt 0 ] ; then
+        IGCM_debug_Print 2 "IGCM_sys_Get_Dir : cp failed error code ${status}"
+        cat /tmp/out_command.$$
+        IGCM_debug_Exit "IGCM_sys_Get_Dir"
+      else
+        \rm /tmp/out_command.$$
+      fi
+    fi
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_Get_Dir : error."
+      cat /tmp/out_command.$$
+      IGCM_debug_Exit "IGCM_sys_Get_Dir"
+    else
+      \rm /tmp/out_command.$$
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Get_Dir"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Get_Master
+#D-* Purpose: Copy a complete directory from MASTER filesystem
+#D-* Examples:
+#D-
+function IGCM_sys_Get_Master {
+  IGCM_debug_PushStack "IGCM_sys_Get_Master" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Get_Master :" $@
+  fi
+  if [ $DRYRUN = 0 ]; then
+    if ( [ ! -d ${1} ] && [ ! -f ${1} ] ) ; then
+      echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ."
+      IGCM_debug_PopStack "IGCM_sys_Get_Master"
+      return
+    fi
+
+    typeset NB_ESSAI DELAI status i
+    # number of tentative
+    NB_ESSAI=3
+    # time delay between tentative
+    DELAI=2
+
+    i=0
+    while [ $i -lt $NB_ESSAI ] ; do
+      \cp -urL $1 $2 > /tmp/out_command.$$ 2>&1
+      status=$?
+      if [ ${status} -gt 0 ]; then
+        IGCM_debug_Print 2 "IGCM_sys_Get_Master : cp failed error code ${status} ${i}/${NB_ESSAI}"
+        IGCM_debug_Print 2 "IGCM_sys_Get_Master : sleep ${DELAI} seconds and try again."
+        sleep $DELAI
+      else
+        break
+      fi
+      (( i = i + 1 ))
+    done
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_Get_Master : error."
+      cat /tmp/out_command.$$
+      IGCM_debug_Exit "IGCM_sys_Get_Master"
+    else
+      \rm /tmp/out_command.$$
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Get_Master"
+}
+
+#====================================================
+#- Call IGCM_sys_Mirror_libIGCM now !
+if ( $MirrorlibIGCM ) ; then
+  IGCM_sys_Mirror_libIGCM
+fi
+
+#D-#==================================================
+#D-function IGCM_sys_Put_Rest
+#D-* Purpose: Put computied restarts on ${ARCHIVE}.
+#D-           File and target directory must exist.
+#D-* Examples:
+#D-
+function IGCM_sys_Put_Rest {
+  IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Put_Rest :" $@
+  fi
+  if [ $DRYRUN = 0 ]; then
+    if [ ! -f ${1} ] ; then
+      echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ."
+      IGCM_debug_Exit "IGCM_sys_Put_Rest"
+    fi
+
+    typeset status
+    #
+    if [ X${JobType} = XRUN ] ; then
+      IGCM_sys_Chmod 444 ${1}
+    fi
+    #
+    #
+    #Command depends on targeted file system
+    DEBUG_sys=false IGCM_sys_IsFileArchived $2
+    if [ $? = 0 ] ; then
+      mfput $1 $2 > /tmp/out_command.$$ 2>&1
+      status=$?
+    else
+      IGCM_sys_MkdirArchive $( dirname $2 )
+      \cp $1 $2 > /tmp/out_command.$$ 2>&1
+      status=$?
+    fi
+
+#       #RSYNC WITH NETWORK RSH CALL
+#       IGCM_sys_MkdirArchive $( dirname $2 )
+#       echo ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${STOREHOST}:${2} > /tmp/out_command.$$ 2>&1
+#       ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> /tmp/out_command.$$ 2>&1
+
+#       #RSYNC WITH NFS USE
+#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > /tmp/out_command.$$ 2>&1
+#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> /tmp/out_command.$$ 2>&1
+
+#       status=$?
+#       IGCM_sys_Rsync_out $status
+
+#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk /tmp/out_command.$$
+#       (( status=status+$? ))
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_Put_Rest : mfput or cp failed error code ${status}"
+      cat /tmp/out_command.$$
+      IGCM_debug_Exit "IGCM_sys_Put_Rest"
+    else
+      \rm /tmp/out_command.$$
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Put_Rest"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_PutBuffer_Rest
+#D-* Purpose: Put computied restarts on ${SCRATCHDIR}.
+#D-           File and target directory must exist.
+#D-* Examples:
+#D-
+function IGCM_sys_PutBuffer_Rest {
+  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Rest" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_PutBuffer_Rest :" $@
+  fi
+  if [ $DRYRUN = 0 ]; then
+    if [ ! -f ${1} ] ; then
+      echo "ERROR : IGCM_sys_PutBuffer_Rest ${1} DOES NOT EXIST ."
+      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest"
+    fi
+
+    typeset status
+    #
+    if [ X${JobType} = XRUN ] ; then
+      IGCM_sys_Chmod 444 ${1}
+    fi
+
+    #
+    # USUAL WAY
+    \cp $1 $2 > /tmp/out_command.$$ 2>&1
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_PutBuffer_Rest : error code ${status}"
+      [ -f ${2} ] && ls -l ${2}
+      [ -f ${2}/${1} ] && ls -l ${2}/${1}
+      cat /tmp/out_command.$$
+      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest"
+    else
+      \rm /tmp/out_command.$$
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Rest"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_PrepareTaredRestart
+#D-* Purpose: Prepare tared restart to be access by computing job.
+#D-* Examples:
+#D-
+function IGCM_sys_PrepareTaredRestart {
+  IGCM_debug_PushStack "IGCM_sys_PrepareTaredRestart" $@
+  if [ $DRYRUN = 0 ]; then
+    [ ! -f $( basename $1 ) ] && IGCM_sys_Get $1 .
+  fi
+  IGCM_debug_PopStack "IGCM_sys_PrepareTaredRestart"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Put_Out
+#D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly
+#D-* Examples:
+#D-
+function IGCM_sys_Put_Out {
+  IGCM_debug_PushStack "IGCM_sys_Put_Out" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Put_Out :" $@
+  fi
+
+  typeset status
+
+  if [ $DRYRUN = 0 ]; then
+    if [ ! -f ${1} ] ; then
+      echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ."
+      IGCM_debug_PopStack "IGCM_sys_Put_Out"
+      return 1
+    fi
+
+    #
+    if [ X${JobType} = XRUN ] ; then
+      if [ X${3} = X ] ; then
+        IGCM_sys_Chmod 444 ${1}
+      fi
+    fi
+    #
+    #
+    #Command depends on targeted file system
+    DEBUG_sys=false IGCM_sys_IsFileArchived $2
+    if [ $? = 0 ] ; then
+      mfput $1 $2 > /tmp/out_command.$$ 2>&1
+      status=$?
+    else
+      IGCM_sys_MkdirArchive $( dirname $2 )
+      \cp $1 $2 > /tmp/out_command.$$ 2>&1
+      status=$?
+    fi
+
+#       #RSYNC WITH NETWORK RSH CALL
+#       IGCM_sys_MkdirArchive $( dirname $2 )
+#       echo ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${STOREHOST}:${2} > /tmp/out_command.$$ 2>&1
+#       ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> /tmp/out_command.$$ 2>&1
+
+#       #RSYNC WITH NFS USE
+#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > /tmp/out_command.$$ 2>&1
+#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> /tmp/out_command.$$ 2>&1
+
+#       status=$?
+#       IGCM_sys_Rsync_out $status
+
+#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk /tmp/out_command.$$
+#       (( status=status+$? ))
+
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_Put_Out : mfput or cp failed error code ${status}"
+      cat /tmp/out_command.$$
+      IGCM_debug_Exit "IGCM_sys_Put_Out"
+    else
+      \rm /tmp/out_command.$$
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Put_Out"
+  return 0
+}
+
+#D-#==================================================
+#D-function IGCM_sys_PutBuffer_Out
+#D-* Purpose: Copy a file on ${WORKDIR} after having chmod it in readonly
+#D-* Examples:
+#D-
+function IGCM_sys_PutBuffer_Out {
+  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Out" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_PutBuffer_Out :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i exist skip
+
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  if [ $DRYRUN = 0 ]; then
+    if [ ! -f ${1} ] ; then
+      echo "WARNING : IGCM_sys_PutBuffer_Out ${1} DOES NOT EXIST ."
+      IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out"
+      return 1
+    fi
+    #
+    IGCM_sys_Mkdir $( dirname $2 )
+    #
+
+    exist=false
+    skip=false
+    if [ -f $2 ] ; then
+      IGCM_debug_Print 1 "$2 already exist"
+      exist=true
+      if [ "X$( diff $1 $2 )" = X ] ; then
+        IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy"
+        status=0
+        skip=true
+      else
+        IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy"
+        skip=false
+      fi
+    fi
+    #
+    if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then
+      IGCM_sys_Chmod u+w $2
+    fi
+
+    if [ X${skip} = Xfalse ] ; then
+      i=0
+      while [ $i -lt $NB_ESSAI ] ; do
+        # USUAL WAY
+        \cp $1 $2 > /tmp/out_command.$$ 2>&1
+        status=$?
+        if [ ${status} -gt 0 ]; then
+          IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : cp failed error code ${status} ${i}/${NB_ESSAI}"
+          IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : sleep ${DELAI} seconds and try again."
+          [ -f ${2} ] && ls -l ${2}
+          [ -f ${2}/${1} ] && ls -l ${2}/${1}
+          sleep $DELAI
+        else
+          break
+        fi
+        (( i = i + 1 ))
+      done
+    fi
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_PutBuffer_Out : error."
+      [ -f ${2} ] && ls -l ${2}
+      [ -f ${2}/${1} ] && ls -l ${2}/${1}
+      cat /tmp/out_command.$$
+      IGCM_debug_Exit "IGCM_sys_PutBuffer_Out"
+    else
+
+      if [ X${JobType} = XRUN ] ; then
+        if [ X${3} = X ] ; then
+          [ -f ${2} ] && IGCM_sys_Chmod 444 ${2}
+          [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1}
+        fi
+      fi
+
+      \rm /tmp/out_command.$$
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out"
+  return 0
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Get
+#D-* Purpose: Get a file from ${ARCHIVE}
+#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
+#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
+function IGCM_sys_Get {
+  IGCM_debug_PushStack "IGCM_sys_Get" $@
+
+  typeset DEST status dm_liste
+
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Get :" $@
+  fi
+  if [ $DRYRUN -le 2 ]; then
+    if [ X${1} = X'/l' ] ; then
+      eval set +A dm_liste \${${2}}
+    else
+      dm_liste=${1}
+    fi
+    eval DEST=\${${#}}
+
+    # test if the (first) file is present in the old computation :
+    DEBUG_sys=false IGCM_sys_IsFileArchived ${dm_liste[0]}
+    if [ $? = 0 ] ; then
+      IGCM_sys_TestFileArchive ${dm_liste[0]}
+      status=$?
+    else
+      IGCM_sys_TestFileBuffer ${dm_liste[0]}
+      status=$?
+    fi
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ."
+      IGCM_debug_Exit "IGCM_sys_Get"
+      return
+    fi
+
+    #Command depends on targeted file system
+    DEBUG_sys=false IGCM_sys_IsFileArchived ${dm_liste[0]}
+    if [ $? = 0 ] ; then
+      mfget ${dm_liste[*]} ${DEST} > /tmp/out_command.$$ 2>&1
+      status=$?
+    else
+      \cp ${dm_liste[*]} ${DEST} > /tmp/out_command.$$ 2>&1
+      status=$?
+    fi
+
+#       #RSYNC WITH NETWORK RSH CALL
+#       echo ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} > /tmp/out_command.$$ 2>&1
+#       ${RSYNC} ${RSYNC_opt} --rsync-path=${REMOTE_RSYNC} -e rsh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} >> /tmp/out_command.$$ 2>&1
+
+#       #RSYNC WITH NFS USE
+#       echo ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > /tmp/out_command.$$ 2>&1
+#       ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> /tmp/out_command.$$ 2>&1
+
+#       status=$?
+#       IGCM_sys_Rsync_out $status
+
+#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk /tmp/out_command.$$
+#       (( status=status+$? ))
+
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_Get : mfget or cp failed error code ${status}"
+      cat /tmp/out_command.$$
+      IGCM_debug_Exit "IGCM_sys_Get"
+    else
+      \rm /tmp/out_command.$$
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Get"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_GetBuffer
+#D-* Purpose: Get a file from ${SCRATCHDIR}
+#D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX
+#D-            IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/
+function IGCM_sys_GetBuffer {
+  IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@
+
+  typeset DEST buf_liste target file_work
+  typeset NB_ESSAI DELAI status i
+
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_GetBuffer :" $@
+  fi
+
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  if [ $DRYRUN -le 2 ]; then
+    if [ X${1} = X'/l' ] ; then
+      eval set +A buf_liste \${${2}}
+    else
+      eval set +A buf_liste ${1}
+    fi
+    eval DEST=\${${#}}
+
+    #USUAL WAY
+    if [ X${1} = X'/l' ] ; then
+      for target in ${buf_liste[*]} ; do
+        local_file=$( basename ${target} )
+        i=0
+        while [ $i -lt $NB_ESSAI ] ; do
+          \cp ${target} ${DEST}/${local_file} >> /tmp/out_command.$$ 2>&1
+          status=$?
+          if [ ${status} -gt 0 ]; then
+            IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}"
+            IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again."
+            sleep $DELAI
+          else
+            break
+          fi
+          (( i = i + 1 ))
+        done
+        if [ ${status} -gt 0 ] ; then
+          echo "IGCM_sys_Get : error"
+          cat /tmp/out_command.$$
+          \rm /tmp/out_command.$$
+          IGCM_debug_Exit "IGCM_sys_GetBuffer"
+        else
+          \rm /tmp/out_command.$$
+        fi
+      done
+    else
+      i=0
+      while [ $i -lt $NB_ESSAI ] ; do
+        \cp ${buf_liste} ${DEST} >> /tmp/out_command.$$ 2>&1
+        status=$?
+        if [ ${status} -gt 0 ]; then
+          IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}"
+          IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again."
+          sleep $DELAI
+        else
+          break
+        fi
+        (( i = i + 1 ))
+      done
+      if [ ${status} -gt 0 ] ; then
+        echo "IGCM_sys_Get : error"
+        cat /tmp/out_command.$$
+        \rm /tmp/out_command.$$
+        IGCM_debug_Exit "IGCM_sys_GetBuffer"
+      else
+        \rm /tmp/out_command.$$
+      fi
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_GetBuffer"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_GetDate_FichWork
+#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK
+#D-* Examples:
+#D-
+function IGCM_sys_GetDate_FichWork {
+  IGCM_debug_PushStack "IGCM_sys_FichWork" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_GetDate_FichWork :" $@
+  fi
+
+  if [ $# -ge 3 ] ; then
+    mode=$3
+    TimeStyle=$4
+  else
+    mode="default"
+    TimeStyle="%Y%m%d%H%M%S"
+  fi
+
+  typeset dateF
+  set +A dateF -- $( ls -l --full-time --time-style=+"${TimeStyle}" ${1} )
+
+  case $mode in
+    "default")
+      eval ${2}=${dateF[5]}
+      ;;
+    "SplitFields")
+      eval ${2}="${dateF[5]}\ ${dateF[6]}"
+      ;;
+  esac
+
+
+  # donne la date filesys d'un fichier sur la machine work
+  IGCM_debug_PopStack "IGCM_sys_FichWork"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_GetDate_FichArchive
+#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE
+#D-* Examples:
+#D-
+function IGCM_sys_GetDate_FichArchive {
+  IGCM_debug_PushStack "IGCM_sys_FichArchive" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_GetDate_FichArchive :" $@
+  fi
+  typeset dateF
+  set +A dateF -- $( rsh ${STOREHOST} -n ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} )
+  eval ${2}=${dateF[5]}
+
+  IGCM_debug_PopStack "IGCM_sys_FichArchive"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_GetDate_Monitoring
+#D-* Purpose: get the last year for which the monitoring has been computed
+#D-* Examples:
+#D-
+function IGCM_sys_GetDate_Monitoring {
+  IGCM_debug_PushStack "IGCM_sys_GetDate_Monitoring" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_GetDate_Monitoring :" $@
+  fi
+
+  IGCM_sys_Cd /tmp
+  IGCM_sys_Get ${1} .
+  eval ${2}=$( cdo showyear $( basename ${1} ) 2> /dev/null | gawk '{ print $NF }' )
+  IGCM_sys_Cd -
+
+  IGCM_debug_PopStack "IGCM_sys_GetDate_Monitoring"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Put_Dods
+#D-* Purpose: Put $(ARCHIVE) files on DODS internet protocole.
+#D-* Examples:
+#D-
+function IGCM_sys_Put_Dods {
+  IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Put_Dods :" $@
+  fi
+  if [ $DRYRUN = 0 ]; then
+    # We take our time on that
+    sleep 10
+    IGCM_sys_TestDirArchive ${R_SAVE}/${1}
+    if [ $? != 0 ] ; then
+      echo "WARNING : IGCM_sys_Put_Dods ${R_SAVE}/${1} DOES NOT EXIST ."
+      IGCM_debug_PopStack "IGCM_sys_Put_Dods"
+      return
+    fi
+
+    typeset status
+    #
+    rsh gaya exec /bin/ksh <<EOF
+          cd ${R_SAVE}
+          /usr/local/bin/dods_rm DODS/pub/${LOGIN}/${R_DODS}/${1} > /dev/null 2>&1
+          /bin/chmod -R u+w ${R_SAVE}/${1}
+          /usr/local/bin/dods_cp ${1} DODS/pub/${LOGIN}/${R_DODS} > /dev/null 2>&1
+          /bin/chmod -R +rX ${R_SAVE}/${1}
+          /bin/chmod -R u+w ${R_SAVE}/${1}
+EOF
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_Put_Dods : error."
+      IGCM_debug_Exit "IGCM_sys_Put_Dods"
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Put_Dods"
+}
+
+##############################################################
+# REBUILD OPERATOR
+
+#D-#==================================================
+#D-function IGCM_sys_rebuild
+#D-* Purpose: rebuild parallel files
+#D-* Examples:
+#D-
+function IGCM_sys_rebuild {
+  IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_rebuild :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i firstArg
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    /smphome/rech/psl/rpsl035/bin/rebuild -f -o $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_rebuild : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_rebuild : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      firstArg=${1}
+      \rm ${firstArg}
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_rebuild : rebuild error code is ${status}"
+    IGCM_debug_Exit "rebuild"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_rebuild"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_rebuild_station
+#D-* Purpose: rebuild parallel files describing station
+#D-* Examples:
+#D-
+function IGCM_sys_rebuild_station {
+  IGCM_debug_PushStack "IGCM_sys_rebuild_station" -- $@
+  typeset i list_opt file_in file_out prefix_invert list_invert
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_rebuild_station :" $@
+  fi
+  list_opt=$@
+
+  # Invert Axis : t,x -> x,t
+  #               t,pres,x -> x,t,pres
+  # So that we can concatenate along x
+  i=0
+  for file_in in ${list_opt} ; do
+    (( i = i + 1))
+    [ ${i} = 1 ] && file_out=${file_in} && continue
+    prefix_invert=$( basename ${file_in} .nc )
+    IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs ${file_in} ${prefix_invert}_xt.nc
+    list_invert[${#list_invert[*]}]=${prefix_invert}_xt.nc
+  done
+
+  # Concatenate
+  IGCM_sys_ncrcat ${list_invert[*]} histstn_xt.nc
+
+  # Re-ivert file
+  IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x histstn_xt.nc ${file_out}
+
+  # Station re-ordering is too expansive to be run within libIGCM
+  # This is due to (ncpdq - nrcat - ncpdq) I/O sequence.
+  # This re-ordering must be done "in memory" by the cmorization process
+  # Anyway this is the best sequence using (ncpdq - nrcat - ncpdq)
+  # BEGIN reordering
+
+  # Only LMDZ text output contains the exact ordering of the station.
+  # We isolate this in the code below:
+  #  0  38  -157.5000000000000  70.98591549295774
+  #  0  54  27.49999999999999   67.18309859154928
+  #  0  56  -62.50000000000001  82.39436619718309
+  #  0  79  12.49999999999999   78.59154929577466
+  #  0  116 -165.0000000000000  76.05633802816901
+  #  0  117 130.0000000000000   70.98591549295774
+  #  0  118 110.0000000000000   87.46478873239437
+  #  1  40  4.999999999999995   51.97183098591550
+#  typeset iStation iProc list_opt file_in file_out prefix_invert
+#  typeset -Z4 j4
+#  typeset -Z3 j3
+
+#  unset list_opt
+#  set +A list_opt $@
+
+  # Filename after rebuild
+#  file_out=${list_opt[0]}
+  # Prefix of output files
+#  prefix_invert=$( basename ${file_out} .nc )
+  # Number of procs
+#  num_proc=$( grep -i mpi_size ${PREFIX}_${Exe_Output} | wc -l )
+
+#  iProc=0
+#  while [ ${iProc} -lt ${num_proc} ] ; do
+    # Array containing Station as a number
+#    unset proc_stn
+#    set +A proc_stn $( grep "iophy_mpi rank ip lon lat  $iProc" ${PREFIX}_${Exe_Output} | sed -e "s/iophy_mpi rank ip lon lat //g" | gawk ' {print $2}' )
+    # Number of stations produced by processor proc
+#    stationLast=${#proc_stn[*]}
+    # Proc number on 4 digits
+#    j4=${iProc}
+    # Init
+#    iStation=0
+#    while [ ${iStation} -lt ${stationLast} ] ; do
+      # Station number on 3 digits
+#      j3=${proc_stn[${iStation}]}
+      # Extract station
+      # Invert Axis : t,x -> x,t
+      #               t,pres,x -> x,t,pres
+      # So that we can concatenate along x
+#      IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs -d x,$iStation,$iStation ${prefix_invert}_${j4}.nc ${prefix_invert}_stn_${j3}.nc
+#      (( iStation = iStation + 1 ))
+#    done
+#    (( iProc = iProc + 1 ))
+#  done
+
+  # Concatenate all station along x
+#  IGCM_sys_ncrcat ${prefix_invert}_stn_???.nc ${prefix_invert}_xt.nc
+
+  # Re-invert file
+#  IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x ${prefix_invert}_xt.nc ${file_out}
+
+  # END reordering
+
+  IGCM_debug_PopStack "IGCM_sys_rebuild_station"
+}
+
+############################################################
+# Activate Running Environnment Variables
+
+#D-#==================================================
+#D-function IGCM_sys_desactiv_variables
+#D-* Purpose: set environement variables prior to execution
+#D-* Examples:
+#D-
+function IGCM_sys_activ_variables {
+  IGCM_debug_PushStack "IGCM_sys_activ_variables"
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_activ_variables"
+  fi
+
+# --------------------------------------------------------------------
+#D- MPI specifications
+# --------------------------------------------------------------------
+
+# --------------------------------------------------------------------
+#D- Other specifications
+# --------------------------------------------------------------------
+
+  ulimit -s unlimited
+
+## to be done only one time
+## export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/smplocal/pub/NetCDF/4.1.3/lib:/smplocal/pub/HDF5/1.8.9/seq/lib
+  echo ${LD_LIBRARY_PATH} | grep -i netcdf >/dev/null 2>&1 || export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/smplocal/pub/NetCDF/4.1.3/lib:/smplocal/pub/HDF5/1.8.9/seq/lib
+  IGCM_debug_Print 1 "set LD_LIBRARY_PATH=${LD_LIBRARY_PATH}"
+
+  export MP_STDOUTMODE=combined
+  IGCM_debug_Print 1 "set MP_STDOUTMODE=${MP_STDOUTMODE}"
+
+  IGCM_debug_PopStack "IGCM_sys_activ_variables"
+}
+
+############################################################
+# Desactivate Running Environnment Variables
+
+#D-#==================================================
+#D-function IGCM_sys_desactiv_variables
+#D-* Purpose: unset environement variables after execution
+#D-* Examples:
+#D-
+function IGCM_sys_desactiv_variables {
+  IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_desactiv_variables"
+  fi
+# --------------------------------------------------------------------
+#D- MPI specifications
+# --------------------------------------------------------------------
+
+# --------------------------------------------------------------------
+#D- Other specifications
+# --------------------------------------------------------------------
+
+  IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
+}
+
+############################################################
+# Build MPI/OMP scripts run file (dummy function)
+
+#D-#==================================================
+#D-function IGCM_sys_build_run_file
+#D-* Purpose: build run file (deprecated)
+#D-* Examples:
+#D-
+function IGCM_sys_build_run_file {
+
+  IGCM_debug_Print 3 " dummy function : IGCM_sys_build_run_file "
+
+}
+
+############################################################
+# Build MPI/OMP scripts
+
+#D-#==================================================
+#D-function IGCM_sys_build_execution_scripts
+#D-* Purpose: build execution scripts to be launch by ${HOST_MPIRUN_COMMAND}
+#D-* Examples:
+#D-
+function IGCM_sys_build_execution_scripts
+{
+  IGCM_debug_PushStack "IGCM_sys_build_execution_scripts" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_build_execution_scripts " $@
+  fi
+
+  EXECUTION=${HOST_MPIRUN_COMMAND}
+
+  if ( ${OK_PARA_MPMD} ) ; then
+
+    if [ -f run_file ] ; then
+      IGCM_sys_Rm -f run_file
+    fi
+    touch run_file
+
+# run_file construction
+
+# Then first loop on the components for the coupler ie oasis
+
+### the coupler ie oasis must be the first one
+    for comp in ${config_ListOfComponents[*]} ; do
+
+      eval ExeNameIn=\${config_Executable_${comp}[0]}
+      eval ExeNameOut=\${config_Executable_${comp}[1]}
+
+      # for CPL component only
+      if [ "X${comp}" = "XCPL" ] ; then
+
+        eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
+        eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
+
+        if ( ${OK_PARA_MPI} ) ; then
+          (( mpi_count = 1 ))
+          until [ ${mpi_count} -gt ${comp_proc_mpi_loc} ] ; do
+            echo "./${ExeNameOut}" >> run_file
+            (( mpi_count = mpi_count + 1 ))
+          done
+        else
+          echo "./${ExeNameOut} " >> run_file
+        fi
+      fi
+    done
+
+# Then second loop on the components
+
+    for comp in ${config_ListOfComponents[*]} ; do
+
+      eval ExeNameIn=\${config_Executable_${comp}[0]}
+      eval ExeNameOut=\${config_Executable_${comp}[1]}
+
+      # Only if we really have an executable for the component and not the coupler ie oasis:
+      if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${comp}" != "XCPL" ] ) ; then
+
+        eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
+        eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
+
+        if ( ${OK_PARA_MPI} ) ; then
+          (( mpi_count = 1 ))
+          until [ ${mpi_count} -gt ${comp_proc_mpi_loc} ] ; do
+            echo "./${ExeNameOut}" >> run_file
+            (( mpi_count = mpi_count + 1 ))
+          done
+        else
+            echo "./${ExeNameOut} " >> run_file
+        fi
+      fi
+    done
+
+    EXECUTION="${HOST_MPIRUN_COMMAND} -pgmmodel mpmd -cmdfile ./run_file"
+
+    IGCM_sys_Chmod u+x run_file
+    if ( $DEBUG_sys ) ; then
+      echo "run_file contains : "
+      cat run_file
+    fi
+
+  else # Only one executable. launch it.
+
+    for comp in ${config_ListOfComponents[*]} ; do
+
+      # Only if we really have an executable for the component :
+      eval ExeNameOut=\${config_Executable_${comp}[1]}
+      if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${ExeNameOut}" != "Xinca.dat" ] ) ; then
+
+        if ( ${OK_PARA_OMP} ) ; then
+          eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
+          export KMP_STACKSIZE=200m
+          #export KMP_LIBRARY=turnaround
+          #echo "export KMP_STACKSIZE=3g"  >> script_${ExeNameOut}.ksh
+          #echo "export KMP_LIBRARY=turnaround"  >> script_${ExeNameOut}.ksh
+          #echo "export MKL_SERIAL=YES"  >> script_${ExeNameOut}.ksh
+        fi
+
+        EXECUTION="${HOST_MPIRUN_COMMAND} ./${ExeNameOut}"
+      fi
+
+    done
+
+  fi
+
+  IGCM_debug_Print 1 "sys ada : execution command is "
+  IGCM_debug_Print 1 "$EXECUTION"
+
+  IGCM_debug_PopStack "IGCM_sys_build_execution_scripts"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_check_path
+#D-* Purpose: check that RUN_DIR_PATH that will be removed on some machine
+#D-* do not point to an important use directory. Stop immediately in that case.
+#D-* Examples:
+#D-
+function IGCM_sys_check_path {
+  IGCM_debug_PushStack "IGCM_sys_check_path"
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_check_path"
+  fi
+
+  if ( [ X${RUN_DIR_PATH} = X${HOME} ] || [ X${RUN_DIR_PATH} = X${WORKDIR} ] || [ X${RUN_DIR_PATH} = X${HOMEGAYA} ] ) ; then
+    IGCM_debug_Print 1 "Variable RUN_DIR_PATH is pointing to an important directory : ${RUN_DIR_PATH}"
+    IGCM_debug_Print 1 "Please check the RUN_DIR_PATH definition in your Job : Job_${config_UserChoices_JobName}"
+    IGCM_debug_Exit "This will stop the job"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_check_path"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_check_quota
+#D-* Purpose: check user quota. Stop the simulation if quota above 90%
+#D-* Examples:
+#D-
+function IGCM_sys_check_quota {
+  IGCM_debug_PushStack "IGCM_sys_check_quota"
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_check_quota"
+  fi
+  # Limit of quota (in %)
+  limit_quota=90
+
+  # Check of the volume
+  volume_quota=$(quota_u -w 2>/dev/null| grep 'Quota soft' | gawk '{print $5}')
+  if [ ! X${volume_quota} = X ] ; then
+    quota_volume=${volume_quota%%\%}
+#    echo $quota_volume
+    if [ $(echo "${quota_volume} > ${limit_quota}" | bc) -eq 1 ] ; then
+      IGCM_debug_Print 1 "Please, check your quota of volume on workgpfs"
+      IGCM_debug_Print 1 "${quota_volume}% of your quota is used"
+      IGCM_debug_Print 1 "Use the quota_u -w command to check"
+      IGCM_debug_Print 1 "You must have more than 10% available to run"
+      IGCM_debug_Exit "Not enough space to run ! STOP HERE"
+      IGCM_debug_Verif_Exit
+    fi
+
+  fi
+  IGCM_debug_PopStack "IGCM_sys_check_quota"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_GetJobID
+#D-* Purpose: Check if job_name is currently
+#D-  running or in queue
+#D-* Examples: IGCM_sys_GetJobID ${JobName} NbRun
+#D-
+function IGCM_sys_GetJobID {
+  IGCM_debug_PushStack "IGCM_sys_GetJobID"
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_GetJobID"
+  fi
+
+  # Print only the full (-W) JobID (%id) and JobName (%jn)
+  ID=$( llq -u $2 -W -f %id %jn | \
+        gawk -v JobName=$1 '( $NF ~ JobName ) { print $1 }' )
+
+  eval ${3}=${ID}
+
+  IGCM_debug_PopStack "IGCM_sys_GetJobID"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_CountJobInQueue
+#D-* Purpose: Check if job_name is currently
+#D-  running or in queue
+#D-* Examples: IGCM_sys_CountJobInQueue ${JobName} NbRun
+#D-
+function IGCM_sys_CountJobInQueue {
+  IGCM_debug_PushStack "IGCM_sys_CountJobInQueue"
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_CountJobInQueue"
+  fi
+
+  # Print only the full (-W) JobName (%jn)
+  NbRun=$( llq -W -f %jn | grep -c "$1" )
+
+  eval ${2}=${NbRun}
+
+  IGCM_debug_PopStack "IGCM_sys_CountJobInQueue"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ListJobInQueue
+#D-* Purpose: Check if job_name is currently
+#D-  running or in queue
+#D-* Examples: IGCM_sys_ListJobInQueue ${User} JobNameList
+#D-
+function IGCM_sys_ListJobInQueue {
+  IGCM_debug_PushStack "IGCM_sys_ListJobInQueue"
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ListJobInQueue"
+  fi
+
+  # With -W option, column width is as large as necessary
+  set -A JobList $( llq -u $1 -W -f %jn | head -n -2 | tail -n +3 | \
+                    gawk '( $1 != /TS/      && \
+                            $1 !~ /PACK/    && \
+                            $1 !~ /REBUILD/ && \
+                            $1 !~ /pack/ )     \
+                          { print $1 }' | sed -e "s/\(.*\)\.[0-9]*/\1/" )
+
+  eval set -A ${2} ${JobList[*]}
+
+  IGCM_debug_PopStack "IGCM_sys_ListJobInQueue"
+}
+
+##############################################################
+# NCO OPERATOR
+
+#D-#==================================================
+#D-function IGCM_sys_ncap2
+#D-* Purpose: encapsulate ncap2 call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncap2 {
+  IGCM_debug_PushStack "IGCM_sys_ncap2" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncap2 :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncap2 "$@" > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncap2 : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncap2 : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncap2 : ncap2 error"
+    IGCM_debug_Exit "ncap2"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncap2"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncatted
+#D-* Purpose: encapsulate ncatted call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncatted {
+  IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncatted :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncatted "$@" > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncatted : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncatted : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncatted : ncatted error"
+    IGCM_debug_Exit "ncatted"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncatted"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncbo
+#D-* Purpose: encapsulate ncbo call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncbo {
+  IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncbo :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncbo $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncbo : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncbo : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncbo : ncbo error"
+    IGCM_debug_Exit "ncbo"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncbo"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncdif
+#D-* Purpose: encapsulate ncdiff call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncdiff {
+  IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncdiff :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncdiff $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncdiff : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncdiff : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncdiff : ncdiff error"
+    IGCM_debug_Exit "ncdiff"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncdiff"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncea
+#D-* Purpose: encapsulate ncea call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncea {
+  IGCM_debug_PushStack "IGCM_sys_ncea" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncea :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncea $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncea : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncea : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncea : ncea error"
+    IGCM_debug_Exit "ncea"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncea"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncecat
+#D-* Purpose: encapsulate ncecat call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncecat {
+  IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncecat :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncecat $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncecat : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncecat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncecat : ncecat error"
+    IGCM_debug_Exit "ncecat"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncecat"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncflint
+#D-* Purpose: encapsulate ncflint call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncflint {
+  IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncflint :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncflint $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncflint : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncflint : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncflint : ncflint error"
+    IGCM_debug_Exit "ncflint"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncflint"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncks
+#D-* Purpose: encapsulate ncks call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncks {
+  IGCM_debug_PushStack "IGCM_sys_ncks" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncks :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncks $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncks : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncks : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncks : ncks error"
+    IGCM_debug_Exit "ncks"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncks"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncpdq
+#D-* Purpose: encapsulate ncpdq call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncpdq {
+  IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncpdq :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncpdq $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncpdq : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncpdq : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncpdq : ncpdq error"
+    IGCM_debug_Exit "ncpdq"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncpdq"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncra
+#D-* Purpose: encapsulate ncra call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncra {
+  IGCM_debug_PushStack "IGCM_sys_ncra" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncra :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncra $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncra : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncra : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncra : ncra error"
+    IGCM_debug_Exit "ncra"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncra"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncrcat
+#D-* Purpose: encapsulate ncrcat call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncrcat {
+  IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncrcat :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i lastArg
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncrcat $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncrcat : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    elif [ ! "X$( grep "WARNING Intra-file non-monotonicity" /tmp/out_command.$$ )" = "X" ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncrcat : WARNING Intra-file non-monotonicity"
+      cat /tmp/out_command.$$
+      # remove files having corrupted time axis
+      eval lastArg=\${$#}
+      IGCM_debug_Print 2 "IGCM_sys_ncrcat : Delete ${lastArg}"
+      \rm ${lastArg}
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncrcat : ncrcat error"
+    #IGCM_debug_Exit "ncrcat"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncrcat"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncrename
+#D-* Purpose: encapsulate ncrename call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncrename {
+  IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncrename :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncrename $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncrename : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncrename : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncrename : ncrename error"
+    IGCM_debug_Exit "ncrename"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncrename"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncwa
+#D-* Purpose: encapsulate ncwa call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncwa {
+  IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncwa :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncwa $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncwa : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncwa : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncwa : ncwa error"
+    IGCM_debug_Exit "ncwa"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncwa"
+}
+
+##############################################################
+# CDO OPERATOR
+
+#D-#==================================================
+#D-function IGCM_sys_cdo
+#D-* Purpose: encapsulate cdo call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_cdo {
+  IGCM_debug_PushStack "IGCM_sys_cdo" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_cdo :" $@
+  fi
+
+  typeset status
+
+  \cdo $@ > /tmp/out_command.$$ 2>&1
+  status=$?
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_cdo : error code ${status}"
+    cat /tmp/out_command.$$
+    \rm /tmp/out_command.$$
+    IGCM_debug_PopStack "IGCM_sys_cdo"
+    return 1
+  else
+    IGCM_debug_PopStack "IGCM_sys_cdo"
+    return 0
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_cdo"
+}
Index: /tags/libIGCM_v2.2/libIGCM_sys/libIGCM_sys_curie.ksh
===================================================================
--- /tags/libIGCM_v2.2/libIGCM_sys/libIGCM_sys_curie.ksh	(revision 998)
+++ /tags/libIGCM_v2.2/libIGCM_sys/libIGCM_sys_curie.ksh	(revision 998)
@@ -0,0 +1,3003 @@
+#!/bin/ksh
+
+#**************************************************************
+# Author: Sebastien Denvil, Martial Mancip, Arnaud Caubel
+# Contact: Arnaud.Caubel__at__lsce.ipsl.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#=========================================================
+# The documentation of this file can be automatically generated
+# if you use the prefix #D- for comments to be extracted.
+# Extract with command: cat lib* | grep "^#D-" | cut -c "4-"
+#=========================================================
+
+#D-#==================================================
+#D-LibIGCM_sys for Curie
+#D-#==================================================
+#D-
+#D- This ksh library if a layer under some usefull
+#D-environment variables and shell commands.
+#D-All those definitions depend on host particularities.
+#D-It manages a stack mechanism and test validity of operations.
+#D-All function described bellow must be prefixed by IGCM_sys.
+
+#====================================================
+# libIGCM_sys PARAMETERS
+#====================================================
+
+#====================================================
+# set DEBUG_sys to true to output calls of function
+typeset -r DEBUG_sys=${DEBUG_sys:=true}
+
+#====================================================
+# Turn in dry run mode ? (sys_Put_Rest, sys_Put_Out, sys_Get)
+typeset -r DRYRUN=${DRYRUN:=0}
+
+# YOU MUST COMPILE YOUR EXE FILES FOR DRYRUN MODE !
+# -------------------------------------------------------------------------------------
+# | DRYRUN=  |  Date computations, | sys_Get    |  Exe    | sys_Put_Out; sys_Put_Rest |
+# |          |  Cp/Exe/param/files |            |         |                           |
+# |          |  Chmod Qsub         |            |         |                           |
+# -------------------------------------------------------------------------------------
+# |    0     |       yes           |    yes     |  yes    |      yes                  |
+# -------------------------------------------------------------------------------------
+# |    1     |       yes           |    yes     |  yes    |      no                   |
+# -------------------------------------------------------------------------------------
+# |    2     |       yes           |    yes     |  no     |      no                   |
+# -------------------------------------------------------------------------------------
+# |    3     |       yes           |    no      |  no     |      no                   |
+# -------------------------------------------------------------------------------------
+
+#=====================================================
+# Global Variables :
+#=====================================================
+# Language : "fr" or "en"
+typeset -r MYLANG="fr"
+
+#=====================================================
+# Host and user names
+# $hostname ou hostname
+typeset  HOST=${HOST:=$( hostname )}
+# $username ou whoami
+typeset  LOGIN=${LOGIN:=$( whoami )}
+# $hostname of the MASTER job
+typeset MASTER=curie
+# add default project on curie
+typeset DEFAULT_PROJECT=gen0826
+
+#D-
+#D-#==================================================
+#D-Program used in libIGCM
+#D-#==================================================
+
+# Submit command
+typeset SUBMIT=${SUBMIT:=ccc_msub}
+# rsync with path
+typeset -r RSYNC=/usr/bin/rsync
+# RSYNC_opt args to rsync
+typeset -r RSYNC_opt="-va"
+# ie storage filesystem
+typeset -r STOREHOST=${MASTER}
+
+#====================================================
+# Source default environment
+#====================================================
+##. /etc/profile
+
+#====================================================
+# Set environment tools (ferret, nco, cdo)
+#====================================================
+if [ X${TaskType} = Xcomputing ] ; then
+  . /ccc/cont003/home/dsm/p86ipsl/.atlas_env_netcdf4_curie_ksh > /dev/null 2>&1
+# to run with netcdf 3.6.3 ie compilation done before 17/2/2014
+# uncomment 2 lines :
+#  module unload netcdf
+#  module load netcdf/3.6.3
+  export PATH=${PATH}:/ccc/cont003/home/dsm/p86ipsl/AddNoise/src_X64_CURIE/bin
+else
+  . /ccc/cont003/home/dsm/p86ipsl/.atlas_env_netcdf4_curie_ksh > /dev/null 2>&1
+fi
+
+#====================================================
+# Specific for ocean additionnal diagnostic
+export FER_GO="$FER_GO /home/cont003/p86denv/IGCM_POST_UTIL/JNL /home/cont003/p86denv/GRAF /home/cont003/p86denv/GRAF/GO"
+export FER_PALETTE="$FER_PALETTE /home/cont003/p86denv/GRAF/PALET"
+
+#====================================================
+# Host specific DIRECTORIES
+#====================================================
+
+# ============ CESIUM START ============ #
+
+#====================================================
+#- Mirror libIGCM from titane to cesium if needed
+#ROOTSYS=$( echo ${libIGCM} | gawk -F"/" '{print $3}' )
+#if [ ! ${ROOTSYS} = "home" ] ; then
+#  typeset -r MirrorlibIGCM=${MirrorlibIGCM:=true}
+#else
+#  typeset -r MirrorlibIGCM=${MirrorlibIGCM:=false}
+#fi
+
+#====================================================
+#- libIGCM_POST
+#if ( ${MirrorlibIGCM} ) ; then
+#  PATHlibIGCM=$( echo ${libIGCM} | gawk -F"${LOGIN}/" '{print $2}' | sed -e "s&/libIGCM&&" )
+#  typeset -r libIGCM_POST=${HOME}/MIRROR/${PATHlibIGCM}/libIGCM
+#else
+#  typeset -r libIGCM_POST=${libIGCM}
+#fi
+
+# ============ CESIUM  END  ============ #
+
+#====================================================
+#- MirrorlibIGCM for frontend
+typeset -r MirrorlibIGCM=${MirrorlibIGCM:=false}
+
+#====================================================
+#- libIGCM_POST for frontend
+typeset -r libIGCM_POST=${libIGCM}
+
+#====================================================
+#- R_EXE   (==> BIN_DIR = ${MODIPSL}/bin )
+typeset -r R_EXE="${MODIPSL}/bin"
+
+#====================================================
+#- SUBMIT_DIR : submission dir
+typeset SUBMIT_DIR=${SUBMIT_DIR:=${BRIDGE_MSUB_PWD}}
+
+#====================================================
+#- IN
+typeset -r R_IN=${R_IN:=/ccc/work/cont003/dsm/p86ipsl/IGCM}
+typeset -r R_IN_ECMWF=${R_IN_ECMWF:=/ccc/work/cont003/dsm/p24data}
+
+#====================================================
+#- ARCHIVE (dedicated to large files)
+typeset ARCHIVE=${CCCSTOREDIR}
+
+#====================================================
+#- STORAGE (dedicated to small/medium files)
+typeset STORAGE=${CCCWORKDIR}
+
+#====================================================
+#- R_OUT
+typeset R_OUT=${ARCHIVE}/IGCM_OUT
+
+#====================================================
+#- R_FIG (hosting figures : monitoring and atlas, and/or small files)
+typeset R_FIG=${STORAGE}/IGCM_OUT
+
+#====================================================
+#- R_BUF (ONLY FOR double copy an scratch)
+typeset -r R_BUF=${SCRATCHDIR}/IGCM_OUT
+
+#====================================================
+#- RUN_DIR_PATH : Temporary working directory (=> TMP)
+typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=${SCRATCHDIR}/RUN_DIR/${BRIDGE_MSUB_JOBID}_${$}}
+
+#====================================================
+#- HOST_MPIRUN_COMMAND
+typeset -r HOST_MPIRUN_COMMAND=${HOST_MPIRUN_COMMAND:="/usr/bin/time ccc_mprun -E-K1"}
+
+#====================================================
+#- Max number of arguments passed to nco operator or demigration command
+UNIX_MAX_LIMIT=360
+
+#====================================================
+#- set PackDefault true on curie
+PackDefault=true
+
+#====================================================
+#- Number of core per node (max number of OpenMP task)
+NUM_COREPERNODE=8
+
+#====================================================
+#- Default number of MPI task for IPSL coupled model
+#- required for backward compatibility
+#-
+DEFAULT_NUM_PROC_OCE=5
+DEFAULT_NUM_PROC_CPL=1
+(( DEFAULT_NUM_PROC_ATM = BATCH_NUM_PROC_TOT - DEFAULT_NUM_PROC_OCE - DEFAULT_NUM_PROC_CPL ))
+DEFAULT_NUM_PROC_TOTAL=${BATCH_NUM_PROC_TOT}
+
+#D-#==================================================
+#D-function IGCM_sys_ChangeArchive
+#D-* Purpose: if SpaceName=TEST everything is stored on SCRATCHDIR
+#D-* Examples:
+#D-
+function IGCM_sys_ChangeArchive {
+  IGCM_debug_PushStack "IGCM_sys_ChangeArchive"
+
+  R_OUT=${SCRATCHDIR}/IGCM_OUT
+  R_FIG=${SCRATCHDIR}/IGCM_OUT
+
+  IGCM_debug_Print 1 "R_OUT   has been redefined = ${R_OUT}"
+  IGCM_debug_Print 1 "R_FIG   has been redefined = ${R_FIG}"
+
+  IGCM_debug_PopStack "IGCM_sys_ChangeArchive"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_RshMaster
+#D-* Purpose: Connection to frontend machine.
+#D-* Examples:
+#D-
+function IGCM_sys_RshMaster {
+  IGCM_debug_PushStack "IGCM_sys_RshMaster" $@
+  /bin/ksh <<-EOF
+    export libIGCM=${libIGCM}
+    export DEBUG_debug=${DEBUG_debug}
+    . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
+    . ${libIGCM}/libIGCM_card/libIGCM_card.ksh
+    ${@}
+EOF
+  if [ $? -gt 0 ] ; then
+    echo "IGCM_sys_RshMaster : erreur."
+    IGCM_debug_Exit "IGCM_sys_RshMaster"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_RshMaster"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_RshArchive
+#D-* Purpose: Archive rsh command
+#D-* Examples:
+#D-
+function IGCM_sys_RshArchive {
+  IGCM_debug_PushStack "IGCM_sys_RshArchive" $@
+  /bin/ksh <<-EOF
+    ${@}
+EOF
+  status=$?
+  if [ ${status} -gt 0 ] ; then
+    IGCM_debug_Print 2 "IGCM_sys_RshArchive : command failed error code ${status}"
+    IGCM_debug_Exit "IGCM_sys_RshArchive"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_RshArchive"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_RshArchive_NoError
+#D-* Purpose: Archive rsh command, without error
+#D-*          used only in monitoring.job
+#D-* Examples:
+#D-
+function IGCM_sys_RshArchive_NoError {
+  IGCM_debug_PushStack "IGCM_sys_RshArchive_NoError" $@
+  /bin/ksh <<-EOF
+    ${@} 2> \dev\null
+EOF
+  IGCM_debug_PopStack "IGCM_sys_RshArchive_NoError"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_RshPost
+#D-* Purpose: Post-process rsh command
+#D-* Examples:
+#D-
+function IGCM_sys_RshPost {
+  IGCM_debug_PushStack "IGCM_sys_RshPost" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_RshPost :" $@
+  fi
+  # keep standard input (stdin) for the loop onto temporary file
+  cat >/tmp/tmp_IGCM_sys_RshPost_$$_${LOGNAME}
+
+  /bin/ksh </tmp/tmp_IGCM_sys_RshPost_$$_${LOGNAME}
+  if [ $? -gt 0 ] ; then
+    echo "IGCM_sys_RshPost : erreur."
+    IGCM_debug_Exit "IGCM_sys_RshPost"
+  fi
+  # delete temporary file
+  \rm /tmp/tmp_IGCM_sys_RshPost_$$_${LOGNAME}
+
+# ============ FRONTEND  END  ============ #
+
+# ============ CESIUM START ============ #
+#  typeset NB_ESSAI DELAI status i
+#  if [ "X$( grep rebuild_from tmp_IGCM_sys_RshPost_$$ )" != "X" ] ; then
+#    #little hack so that rebuild submission is done on titane not an cesium
+#
+#    libIGCM_POST_sed=$( echo $libIGCM_POST | sed 's/\//\\\//g' )
+#    POST_DIR_sed=$( echo ${POST_DIR} | sed 's/\//\\\//g' )
+#    sed "s/IGCM_sys_QsubPost/IGCM_sys_Qsub/g" tmp_IGCM_sys_RshPost_$$ > tmp.txt
+#    sed "s/ rebuild_fromWorkdir/ ${libIGCM_POST_sed}\/rebuild_fromWorkdir.job/g" tmp.txt > tmp_IGCM_sys_RshPost_$$
+#    sed "s/ rebuild_fromArchive/ ${libIGCM_POST_sed}\/rebuild_fromArchive.job/g" tmp_IGCM_sys_RshPost_$$ > tmp.txt
+#    sed "s/Script_Post_Output=/Script_Output=${POST_DIR_sed}\//g" tmp.txt > tmp_IGCM_sys_RshPost_$$
+#    \mv tmp.txt tmp_IGCM_sys_RshPost_$$
+#
+#    echo cat tmp_IGCM_sys_RshPost_$$ AFTER
+#    cat tmp_IGCM_sys_RshPost_$$
+#
+#    /bin/ksh <tmp_IGCM_sys_RshPost_$$
+#    if [ $? -gt 0 ] ; then
+#      echo "IGCM_sys_RshPost : erreur."
+#      IGCM_debug_Exit "IGCM_sys_RshPost"
+#    fi
+#    # delete temporary file
+#    \rm tmp_IGCM_sys_RshPost_$$
+#
+#  else
+#    # number of tentative
+#    NB_ESSAI=10
+#    # time delay between tentative
+#    DELAI=10
+#    i=0
+#    while [ $i -ne $NB_ESSAI ] ; do
+#      ssh -t titane996 ssh cesium /bin/ksh <tmp_IGCM_sys_RshPost_$$
+#      status=$?
+#      if [ ${status} -ne 0 ];
+#      then
+#        sleep $DELAI
+#      else
+#        break
+#      fi
+#      let i=$i+1
+#    done
+#    # delete temporary file
+#    \rm tmp_IGCM_sys_RshPost_$$
+#
+#    if [ ${status} -gt 0 ] ; then
+#      echo "IGCM_sys_RshPost : erreur."
+#      IGCM_debug_Exit "IGCM_sys_RshPost"
+#    fi
+#  fi
+
+# ============ CESIUM  END  ============ #
+
+  IGCM_debug_PopStack "IGCM_sys_RshPost"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_SendMail
+#D-* Purpose: Send mail when simulation is over
+#D-* Examples:
+#D-
+function IGCM_sys_SendMail {
+  IGCM_debug_PushStack "IGCM_sys_SendMail" $@
+
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_SendMail :" $@
+  fi
+
+  if [ X${1} = XAccounting ] ; then
+    status=Accounting
+    mailText=jobAccounting.mail
+  elif ( ${ExitFlag} ) ; then
+    status=failed
+    mailText=jobEnd.mail
+  else
+    status=completed
+    mailText=jobEnd.mail
+  fi
+
+  # Update selected mail template
+  while read -r line; do
+    eval echo $line >> mail.txt ;
+  done < ${libIGCM}/libIGCM_sys/${mailText}
+
+  if [ ! -z ${config_UserChoices_MailName} ] ; then
+    mail -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} < mail.txt
+  elif [ -f ~/.forward ] ; then
+    mail -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < mail.txt
+  fi
+
+  sleep 10
+  rm -f mail.txt
+
+  IGCM_debug_PopStack "IGCM_sys_SendMail"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Mkdir
+#D-* Purpose: Master locale mkdir command
+#D-* Examples:
+#D-
+function IGCM_sys_Mkdir {
+  IGCM_debug_PushStack "IGCM_sys_Mkdir" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Mkdir :" $@
+  fi
+  if [ ! -d ${1} ]; then
+    \mkdir -p $1
+    if [ $? -gt 0 ] ; then
+      echo "IGCM_sys_Mkdir : erreur."
+      IGCM_debug_Exit "IGCM_sys_Mkdir"
+    fi
+  fi
+  # vérification :
+  if [ ! -d ${1} ] ; then
+    echo "IGCM_sys_Mkdir : erreur."
+    IGCM_debug_Exit "IGCM_sys_Mkdir"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Mkdir"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_MkdirArchive
+#D-* Purpose: Mkdir on Archive
+#D-* Examples:
+#D-
+function IGCM_sys_MkdirArchive {
+  IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_MkdirArchive :" $@
+  fi
+  #- creation de repertoire sur le serveur fichier
+  if [ ! -d ${1} ]; then
+    \mkdir -p $1
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_MkdirArchive : mkdir failed error code ${status}"
+      IGCM_debug_Exit "IGCM_sys_MkdirArchive"
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_MkdirArchive"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_MkdirWork
+#D-* Purpose: Mkdir on Work
+#D-* Examples:
+#D-
+function IGCM_sys_MkdirWork {
+  IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_MkdirWork :" $@
+  fi
+  #- creation de repertoire sur le serveur fichier
+  if [ ! -d ${1} ]; then
+    \mkdir -p $1
+    if [ $? -gt 0 ] ; then
+      echo "IGCM_sys_MkdirWork : erreur."
+      IGCM_debug_Exit "IGCM_sys_MkdirWork"
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_MkdirWork"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Cd
+#D-* Purpose: master cd command
+#D-* Examples:
+#D-
+function IGCM_sys_Cd {
+  IGCM_debug_PushStack "IGCM_sys_Cd" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Cd :" $@
+  fi
+  \cd $1
+  if [ $? -gt 0 ] ; then
+    echo "IGCM_sys_Cd : erreur."
+    IGCM_debug_Exit "IGCM_sys_Cd"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Cd"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Chmod
+#D-* Purpose: Chmod
+#D-* Examples:
+#D-
+function IGCM_sys_Chmod {
+  IGCM_debug_PushStack "IGCM_sys_Chmod" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Chmod :" $@
+  fi
+  \chmod $@
+  if [ $? -gt 0 ] ; then
+    echo "IGCM_sys_Chmod : erreur."
+    IGCM_debug_Exit "IGCM_sys_Chmod"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Chmod"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_FileSize
+#D-* Purpose: Filesize
+#D-* Examples:
+#D-
+function IGCM_sys_FileSize {
+  IGCM_debug_PushStack "IGCM_sys_FileSize" $@
+
+  typeset sizeF
+  set +A sizeF -- $( ls -la ${1} )
+  if [ $? -gt 0 ] ; then
+    IGCM_debug_Exit "IGCM_sys_FileSize"
+  fi
+  eval ${2}=${sizeF[4]}
+
+  IGCM_debug_PopStack "IGCM_sys_FileSize"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_TestDir
+#D-* Purpose: Test Directory that must exists
+#D-* Examples:
+#D-
+function IGCM_sys_TestDir {
+  IGCM_debug_PushStack "IGCM_sys_TestDir" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_TestDir :" $@
+  fi
+  typeset ExistFlag
+  ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
+  IGCM_debug_PopStack "IGCM_sys_TestDir"
+
+  return ${ExistFlag}
+}
+
+#D-#==================================================
+#D-function IGCM_sys_TestDirArchive
+#D-* Purpose: Test Directory that must exists on Archive
+#D-* Examples:
+#D-
+function IGCM_sys_TestDirArchive {
+  IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_TestDirArchive :" $@
+  fi
+  typeset ExistFlag
+  ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
+  IGCM_debug_PopStack "IGCM_sys_TestDirArchive"
+  return ${ExistFlag}
+}
+
+#D-#==================================================
+#D-function IGCM_sys_IsFileArchived
+#D-* Purpose: Test file that must NOT EXISTS on Archive
+#D-* Examples:
+#D-
+function IGCM_sys_IsFileArchived {
+  IGCM_debug_PushStack "IGCM_sys_IsFileArchived" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_IsFileArchived :" $@
+  fi
+  typeset IsArchivedFlag
+  IsArchivedFlag=$( [ X$( echo $@ | grep ^\/ccc\/store ) != X ] && echo 0 || echo 1 )
+  IGCM_debug_PopStack "IGCM_sys_IsFileArchived"
+
+  return ${IsArchivedFlag}
+}
+
+#D-#==================================================
+#D-function IGCM_sys_TestFileArchive
+#D-* Purpose: Test file that must NOT EXISTS on Archive
+#D-* Examples:
+#D-
+function IGCM_sys_TestFileArchive {
+  IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@
+  typeset ExistFlag
+  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 )
+  IGCM_debug_PopStack "IGCM_sys_TestFileArchive"
+
+  return ${ExistFlag}
+}
+
+#D-#==================================================
+#D-function IGCM_sys_TestFileBuffer
+#D-* Purpose: Test file that must NOT EXISTS on Buffer
+#D-* Examples:
+#D-
+function IGCM_sys_TestFileBuffer {
+  IGCM_debug_PushStack "IGCM_sys_TestFileBuffer" $@
+  typeset ExistFlag
+  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 )
+  IGCM_debug_PopStack "IGCM_sys_TestFileBuffer"
+
+  return ${ExistFlag}
+}
+
+#D-#==================================================
+#D-function IGCM_sys_CountFileArchive
+#D-* Purpose: Count files on Archive filesystem
+#D-* Examples:
+#D-
+function IGCM_sys_CountFileArchive {
+  IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@
+  ls ${@} 2>/dev/null | wc -l
+  if [ $? -gt 0 ] ; then
+    echo "IGCM_sys_CountFileArchive : erreur."
+  fi
+  IGCM_debug_PopStack "IGCM_sys_CountFileArchive"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_CountFileBuffer
+#D-* Purpose: Count files on Scratch filesystem
+#D-* Examples:
+#D-
+function IGCM_sys_CountFileBuffer {
+  IGCM_debug_PushStack "IGCM_sys_CountFileBuffer" $@
+  ls ${@} 2>/dev/null | wc -l
+  if [ $? -gt 0 ] ; then
+    echo "IGCM_sys_CountFileBuffer : erreur."
+  fi
+  IGCM_debug_PopStack "IGCM_sys_CountFileBuffer"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Tree
+#D-* Purpose: Tree directories with files on ${ARCHIVE}
+#D-* Examples: IGCM_sys_Tree ${R_IN} ${R_OUT}
+#D-
+function IGCM_sys_Tree {
+  IGCM_debug_PushStack "IGCM_sys_Tree" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Tree :" $@
+  fi
+
+  \ls -lR ${@}
+
+  IGCM_debug_PopStack "IGCM_sys_Tree"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Tar
+#D-* Purpose: master tar command
+#D-* Examples:
+#D-
+function IGCM_sys_Tar {
+  IGCM_debug_PushStack "IGCM_sys_Tar" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Tar :" $@
+  fi
+  \tar cf $@
+  if [ $? -gt 0 ] ; then
+    echo "IGCM_sys_Tar : erreur."
+    IGCM_debug_Exit "IGCM_sys_Tar"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Tar"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_UnTar
+#D-* Purpose: master un-tar command
+#D-* Examples:
+#D-
+function IGCM_sys_UnTar {
+  IGCM_debug_PushStack "IGCM_sys_UnTar" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_UnTar :" $@
+  fi
+  \tar xvf $1
+  if [ $? -gt 0 ] ; then
+    echo "IGCM_sys_UnTar : erreur."
+    IGCM_debug_Exit "IGCM_sys_UnTar"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_UnTar"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Qsub
+#D-* Purpose: Qsub new job
+#D-* Examples:
+#D-
+function IGCM_sys_Qsub {
+  IGCM_debug_PushStack "IGCM_sys_Qsub" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Qsub :" $@
+  fi
+  typeset options status
+  options="-o ${SUBMIT_DIR}/${Script_Output} -e ${SUBMIT_DIR}/${Script_Output}"
+
+  /usr/bin/ccc_msub ${options} $1 > /tmp/out_command.$$ 2>&1
+  status=$?
+
+  cat /tmp/out_command.$$
+  if [ ${status} -gt 0 ] ; then
+    IGCM_debug_Print 2 "IGCM_sys_Qsub ${options} $1 : error code ${status}"
+    IGCM_debug_Exit "IGCM_sys_Qsub"
+  else
+    JobID=$( gawk {'print $4'} /tmp/out_command.$$ )
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Qsub"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_QsubPost
+#D-* Purpose: Qsub new job on scalaire
+#D-* Examples:
+#D-
+function IGCM_sys_QsubPost {
+  IGCM_debug_PushStack "IGCM_sys_QsubPost" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_QsubPost :" $@
+  fi
+  typeset options status
+  MY_PROJECT=$(echo ${BRIDGE_MSUB_PROJECT:=${DEFAULT_PROJECT}} | cut -d@ -f1 )
+  options="-Q normal -A ${MY_PROJECT} -o ${POST_DIR}/${Script_Post_Output}.out -e ${POST_DIR}/${Script_Post_Output}.out"
+
+  /usr/bin/ccc_msub ${options} ${libIGCM_POST}/$1.job > /tmp/out_command.$$ 2>&1
+  status=$?
+
+  cat /tmp/out_command.$$
+  if [ ${status} -gt 0 ] ; then
+    IGCM_debug_Print 2 "IGCM_sys_QsubPost ${options} ${libIGCM_POST}/$1.job : error code ${status}"
+    IGCM_debug_Exit "IGCM_sys_QsubPost"
+  else
+    JobID=$( gawk {'print $4'} /tmp/out_command.$$ )
+  fi
+  IGCM_debug_PopStack "IGCM_sys_QsubPost"
+}
+
+#D-*************************
+#D- File transfer functions
+#D-*************************
+#D-
+
+#D-#==================================================
+#D-function IGCM_sys_Rsync_out
+#D-* Purpose: treat return val of rsync
+#D-* Examples: IGCM_sys_Rsync_out out_RET_rsync
+#D-  Error values and explanations can depend on your system version.
+function IGCM_sys_Rsync_out {
+  status=$1
+  if [ ! $status ] ; then
+    echo "rsync error !"
+  fi
+
+  if [ $MYLANG = "fr" ]; then
+    case $status in
+    0)  return ;;
+    1)  echo "Erreur de rsync ; RERR_SYNTAX : "
+      echo "Erreur de syntaxe ou d'utilisation."
+      return;;
+    2)  echo "Erreur de rsync ; RERR_PROTOCOL : "
+      echo "Incompatibilité de protocole."
+      return;;
+    3)  echo "Erreur de rsync ; RERR_FILESELECT 3"
+      echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et"
+      echo "répertoires"
+      return;;
+    4)  echo "Erreur de rsync ; RERR_UNSUPPORTED"
+      echo "Action demandée non supportée : une tentative de manipulation de"
+      echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a"
+      echo "été faite ; ou une option qui est supportée par le  client  mais"
+      echo "pas par le serveur a été spécifiée."
+      return;;
+    10) echo "Erreur de rsync ; RERR_SOCKETIO"
+      echo "Erreur dans le socket d'entrée sortie"
+      return;;
+    11) echo "Erreur de rsync ; RERR_FILEIO"
+      echo "Erreur d'entrée sortie fichier"
+      return;;
+    12) echo "Erreur de rsync ; RERR_STREAMIO"
+      echo "Erreur dans flux de donnée du protocole rsync"
+      return;;
+    13) echo "Erreur de rsync ; RERR_MESSAGEIO"
+      echo "Erreur avec les diagnostics du programme"
+      return;;
+    14) echo "Erreur de rsync ; RERR_IPC"
+      echo "Erreur dans le code IPC"
+      return;;
+    20) echo "Erreur de rsync ; RERR_SIGNAL"
+      echo "SIGUSR1 ou SIGINT reçu"
+      return;;
+    21) echo "Erreur de rsync ; RERR_WAITCHILD"
+      echo "Une erreur retournée par waitpid()"
+      return;;
+    22) echo "Erreur de rsync ; RERR_MALLOC"
+      echo "Erreur lors de l'allocation des tampons de mémoire de coeur"
+      return;;
+    23) echo ""
+      echo "Erreur fichier inexistant"
+      return;;
+    30) echo "Erreur de rsync ; RERR_TIMEOUT"
+      echo "Temps d'attente écoulé dans l'envoi/réception de données"
+      return;;
+    *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $status
+      return;;
+    esac
+  elif [ $MYLANG = "en" ] ; then
+    case $status in
+    0)  return;;
+    1)  echo "rsync error : Syntax or usage error "
+      return;;
+    2)  echo "rsync error : Protocol incompatibility "
+      return;;
+    3)  echo "rsync error : Errors selecting input/output files, dirs"
+      return;;
+    4)  echo "rsync error : Requested action not supported: an attempt"
+      echo "was made to manipulate 64-bit files on a platform that cannot support"
+      echo "them; or an option was specified that is supported by the client and"
+      echo "not by the server."
+      return;;
+    5)  echo "rsync error : Error starting client-server protocol"
+      return;;
+    10) echo "rsync error : Error in socket I/O "
+      return;;
+    11) echo "rsync error : Error in file I/O "
+      return;;
+    12) echo "rsync error : Error in rsync protocol data stream "
+      return;;
+    13) echo "rsync error : Errors with program diagnostics "
+      return;;
+    14) echo "rsync error : Error in IPC code "
+      return;;
+    20) echo "rsync error : Received SIGUSR1 or SIGINT "
+      return;;
+    21) echo "rsync error : Some error returned by waitpid() "
+      return;;
+    22) echo "rsync error : Error allocating core memory buffers "
+      return;;
+    23) echo "rsync error : Partial transfer due to error"
+      return;;
+    24) echo "rsync error : Partial transfer due to vanished source files"
+      return;;
+    30) echo "rsync error : Timeout in data send/receive "
+      return;;
+    *)  echo "rsync error : return code of rsync unknown :" $status
+      return;;
+    esac
+  else
+    echo "unknown language $MYLANG."
+    return
+  fi
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Miror_libIGCM
+#D-* Purpose: Mirror libIGCM PATH and lib to frontend
+#D-* Examples:
+#D-
+function IGCM_sys_Mirror_libIGCM {
+  IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM"
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Mirror_libIGCM"
+  fi
+
+  typeset status
+
+  mkdir -p ${HOME}/MIRROR/${PATHlibIGCM}
+
+  echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > /tmp/out_command.$$ 2>&1
+  ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> /tmp/out_command.$$ 2>&1
+  status=$?
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on frontend."
+    cat /tmp/out_command.$$
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Cp
+#D-* Purpose: generic cp
+#D-* Examples:
+#D-
+function IGCM_sys_Cp {
+  IGCM_debug_PushStack "IGCM_sys_Cp" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Cp :" $@
+  fi
+
+  typeset status
+
+  echo cp $@ > /tmp/out_command.$$ 2>&1
+  \cp $@ >> /tmp/out_command.$$ 2>&1
+  status=$?
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_Cp : error code ${status}"
+    cat /tmp/out_command.$$
+    IGCM_debug_Exit "IGCM_sys_Cp"
+  else
+    \rm /tmp/out_command.$$
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Cp"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Rm
+#D-* Purpose: generic rm
+#D-* Examples:
+#D-
+function IGCM_sys_Rm {
+  IGCM_debug_PushStack "IGCM_sys_Rm" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Rm :" $@
+  fi
+
+  typeset status
+
+  echo rm $@ > /tmp/out_command.$$ 2>&1
+  \rm $@ >> /tmp/out_command.$$ 2>&1
+  status=$?
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_Rm : error code ${status}"
+    cat /tmp/out_command.$$
+    IGCM_debug_Exit "IGCM_sys_Rm"
+  else
+    \rm /tmp/out_command.$$
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Rm"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_RmRunDir
+#D-* Purpose: rm tmpdir (dummy function most of the time batch
+#D-                      scheduler will do the job)
+#D-* Examples:
+#D-
+function IGCM_sys_RmRunDir {
+  IGCM_debug_PushStack "IGCM_sys_RmRunDir" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_RmRunDir :" $@
+  fi
+
+  typeset status
+
+  echo rm $@ > /tmp/out_command.$$ 2>&1
+  \rm $@ >> /tmp/out_command.$$ 2>&1
+  status=$?
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_RmRunDir : rm error code is ${status}."
+    cat /tmp/out_command.$$
+    IGCM_debug_Exit "IGCM_sys_RmRunDir"
+  else
+    \rm /tmp/out_command.$$
+  fi
+  IGCM_debug_PopStack "IGCM_sys_RmRunDir"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Mv
+#D-* Purpose: generic move
+#D-* Examples:
+#D-
+function IGCM_sys_Mv {
+  IGCM_debug_PushStack "IGCM_sys_Mv" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Mv :" $@
+  fi
+
+  if [ $DRYRUN = 0 ]; then
+
+    typeset status
+
+    echo mv $@ > /tmp/out_command.$$ 2>&1
+    \mv $@ >> /tmp/out_command.$$ 2>&1
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_Mv : error code ${status}"
+      cat /tmp/out_command.$$
+      IGCM_debug_Exit "IGCM_sys_Mv"
+    else
+      \rm /tmp/out_command.$$
+    fi
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_Mv"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Put_Dir
+#D-* Purpose: Copy a complete directory on $(ARCHIVE)
+#D-* Examples:
+#D-
+function IGCM_sys_Put_Dir {
+  IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Put_Dir :" $@
+  fi
+  if [ $DRYRUN = 0 ]; then
+    if [ ! -d ${1} ] ; then
+      echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ."
+      IGCM_debug_PopStack "IGCM_sys_Put_Dir"
+      return
+    fi
+
+    typeset status
+
+    # Only if we use rsync
+    #IGCM_sys_TestDirArchive $( dirname $2 )
+    #
+    #USUAL WAY
+    \cp -r $1 $2 > /tmp/out_command.$$ 2>&1
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_Put_Dir : cp failed error code ${status}"
+      cat /tmp/out_command.$$
+      IGCM_debug_Exit "IGCM_sys_Put_Dir"
+    else
+      \rm /tmp/out_command.$$
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Put_Dir"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Get_Dir
+#D-* Purpose: Copy a complete directory from ${ARCHIVE}
+#D-* Examples:
+#D-
+function IGCM_sys_Get_Dir {
+  IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Get_Dir :" $@
+  fi
+  if [ $DRYRUN = 0 ]; then
+#    if [ ! -d ${1} ] ; then
+#      echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ."
+#      IGCM_debug_PopStack "IGCM_sys_Get_Dir"
+#      return
+#    fi
+
+    typeset NB_ESSAI DELAI status i
+    # number of tentative
+    NB_ESSAI=3
+    # time delay between tentative
+    DELAI=2
+
+    # Only if we use rsync
+    #IGCM_sys_TestDirArchive $( dirname $2 )
+    #
+    # USUAL WAY
+    # add 'ccc_hsm get' (to demigrate all offline files) to reduce time of this command :
+    ccc_hsm get -r $1
+
+    i=0
+    while [ $i -lt $NB_ESSAI ] ; do
+      \cp -ur $1 $2 >> /tmp/out_command.$$ 2>&1
+      status=$?
+      if [ ${status} -gt 0 ] ; then
+        IGCM_debug_Print 2 "IGCM_sys_Get_Dir : cp failed error code ${status} ${i}/${NB_ESSAI}"
+        IGCM_debug_Print 2 "IGCM_sys_Get_Dir : sleep ${DELAI} seconds and try again."
+        sleep $DELAI
+      else
+        break
+      fi
+      (( i = i + 1 ))
+    done
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_Get_Dir : error."
+      cat /tmp/out_command.$$
+      IGCM_debug_Exit "IGCM_sys_Get_Dir"
+    else
+      \rm /tmp/out_command.$$
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Get_Dir"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Get_Master
+#D-* Purpose: Copy a complete directory from MASTER filesystem
+#D-* Examples:
+#D-
+function IGCM_sys_Get_Master {
+  IGCM_debug_PushStack "IGCM_sys_Get_Master" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Get_Master :" $@
+  fi
+  if [ $DRYRUN = 0 ]; then
+    if ( [ ! -d ${1} ] && [ ! -f ${1} ] ) ; then
+      echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ."
+      IGCM_debug_PopStack "IGCM_sys_Get_Master"
+      return
+    fi
+
+    typeset NB_ESSAI DELAI status i
+    # number of tentative
+    NB_ESSAI=3
+    # time delay between tentative
+    DELAI=2
+
+    i=0
+    while [ $i -lt $NB_ESSAI ] ; do
+      \cp -urL $1 $2 > /tmp/out_command.$$ 2>&1
+      status=$?
+      if [ ${status} -gt 0 ]; then
+        IGCM_debug_Print 2 "IGCM_sys_Get_Master : cp failed error code ${status} ${i}/${NB_ESSAI}"
+        IGCM_debug_Print 2 "IGCM_sys_Get_Master : sleep ${DELAI} seconds and try again."
+        sleep $DELAI
+      else
+        break
+      fi
+      (( i = i + 1 ))
+    done
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_Get_Master : error."
+      cat /tmp/out_command.$$
+      IGCM_debug_Exit "IGCM_sys_Get_Master"
+    else
+      \rm /tmp/out_command.$$
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Get_Master"
+}
+
+#====================================================
+#- Call IGCM_sys_Mirror_libIGCM now !
+if ( $MirrorlibIGCM ) ; then
+  IGCM_sys_Mirror_libIGCM
+fi
+
+#D-#==================================================
+#D-function IGCM_sys_Put_Rest
+#D-* Purpose: Put computied restarts on ${ARCHIVE}.
+#D-           File and target directory must exist.
+#D-* Examples:
+#D-
+function IGCM_sys_Put_Rest {
+  IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Put_Rest :" $@
+  fi
+  if [ $DRYRUN = 0 ]; then
+    if [ ! -f ${1} ] ; then
+      echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ."
+      IGCM_debug_Exit "IGCM_sys_Put_Rest"
+    fi
+
+    typeset status
+    #
+    # USUAL WAY
+    \cp $1 $2 > /tmp/out_command.$$ 2>&1
+    status=$?
+
+#       #RSYNC WITH NETWORK SSH CALL
+#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > /tmp/out_command.$$ 2>&1
+#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> /tmp/out_command.$$ 2>&1
+
+#       #RSYNC WITH NFS USE
+#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > /tmp/out_command.$$ 2>&1
+#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> /tmp/out_command.$$ 2>&1
+
+#       status=$?
+#       IGCM_sys_Rsync_out $status
+
+#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk /tmp/out_command.$$
+#       (( status=status+$? ))
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_Put_Rest : cp failed error code ${status}"
+      [ -f ${1} ] && ls -l ${1}
+      [ -f ${2} ] && ls -l ${2}
+      [ -f ${2}/${1} ] && ls -l ${2}/${1}
+      cat /tmp/out_command.$$
+      IGCM_debug_Exit "IGCM_sys_Put_Rest"
+    else
+
+      if [ X${JobType} = XRUN ] ; then
+        [ -f ${2} ] && IGCM_sys_Chmod 444 ${2}
+        [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1}
+      fi
+
+      \rm /tmp/out_command.$$
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Put_Rest"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_PutBuffer_Rest
+#D-* Purpose: Put computied restarts on ${SCRATCHDIR}.
+#D-           File and target directory must exist.
+#D-* Examples:
+#D-
+function IGCM_sys_PutBuffer_Rest {
+  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Rest" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_PutBuffer_Rest :" $@
+  fi
+  if [ $DRYRUN = 0 ]; then
+    if [ ! -f ${1} ] ; then
+      echo "ERROR : IGCM_sys_PutBuffer_Rest ${1} DOES NOT EXIST ."
+      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest"
+    fi
+
+    typeset status
+    #
+    # USUAL WAY
+    \cp $1 $2 > /tmp/out_command.$$ 2>&1
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_PutBuffer_Rest : error code ${status}"
+      [ -f ${2} ] && ls -l ${2}
+      [ -f ${2}/${1} ] && ls -l ${2}/${1}
+      cat /tmp/out_command.$$
+      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest"
+    else
+
+      if [ X${JobType} = XRUN ] ; then
+        [ -f ${2} ] && IGCM_sys_Chmod 444 ${2}
+        [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1}
+      fi
+
+      \rm /tmp/out_command.$$
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Rest"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_PrepareTaredRestart
+#D-* Purpose: Prepare tared restart to be access by computing job. Identity here.
+#D-* Examples:
+#D-
+function IGCM_sys_PrepareTaredRestart {
+  IGCM_debug_PushStack "IGCM_sys_PrepareTaredRestart" $@
+  if [ $DRYRUN = 0 ]; then
+    [ ! -f $( basename $1 ) ] && IGCM_sys_Get $1 .
+  fi
+  IGCM_debug_PopStack "IGCM_sys_PrepareTaredRestart"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Put_Out
+#D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly
+#D-* Examples:
+#D-
+function IGCM_sys_Put_Out {
+  IGCM_debug_PushStack "IGCM_sys_Put_Out" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Put_Out :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i exist skip
+
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  if [ $DRYRUN = 0 ]; then
+    if [ ! -f ${1} ] ; then
+      echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ."
+      IGCM_debug_PopStack "IGCM_sys_Put_Out"
+      return 1
+    fi
+    #
+    IGCM_sys_MkdirArchive $( dirname $2 )
+    #
+
+    #=====================================================
+    #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR
+    #=====================================================
+
+    #echo ${2} | grep "${R_OUT}" > /dev/null 2>&1
+    #if [ $? -eq 0 ] ; then
+    #    typeset WORKPATH FILEPATH
+    #    WORKPATH=$( dirname $2 | sed -e "s|${R_OUT}|${R_BUF}|" )
+    #    IGCM_sys_MkdirWork ${WORKPATH}
+    #    FILEPATH=${WORKPATH}/$( basename $2 )
+    #    #
+    #    IGCM_sys_Cp ${1} ${FILEPATH}
+    #fi
+
+    exist=false
+    skip=false
+    if [ -f $2 ] ; then
+      IGCM_debug_Print 1 "$2 already exist"
+      #dmget $2
+      ccc_hsm get $2
+      exist=true
+      if [ "X$( diff $1 $2 )" = X ] ; then
+        IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy"
+        skip=true
+      else
+        IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy"
+        skip=false
+      fi
+    fi
+    #
+    if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then
+      IGCM_sys_Chmod u+w $2
+    fi
+
+    if [ X${skip} = Xfalse ] ; then
+      i=0
+      while [ $i -lt $NB_ESSAI ] ; do
+        # USUAL WAY
+        \cp $1 $2 > /tmp/out_command.$$ 2>&1
+        status=$?
+        if [ ${status} -gt 0 ]; then
+          IGCM_debug_Print 2 "IGCM_sys_Put_Out : cp failed error code ${status} ${i}/${NB_ESSAI}"
+          IGCM_debug_Print 2 "IGCM_sys_Put_Out : sleep ${DELAI} seconds and try again."
+          [ -f ${1} ] && ls -l ${1}
+          [ -f ${2} ] && ls -l ${2}
+          [ -f ${2}/${1} ] && ls -l ${2}/${1}
+          sleep $DELAI
+        else
+          break
+        fi
+        (( i = i + 1 ))
+      done
+    fi
+
+#       #RSYNC WITH NETWORK SSH CALL
+#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > /tmp/out_command.$$ 2>&1
+#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> /tmp/out_command.$$ 2>&1
+
+#       #RSYNC WITH NFS USE
+#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > /tmp/out_command.$$ 2>&1
+#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> /tmp/out_command.$$ 2>&1
+
+#       status=$?
+#       IGCM_sys_Rsync_out $status
+
+#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk /tmp/out_command.$$
+#       (( status=status+$? ))
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_Put_Out : error."
+      [ -f ${1} ] && ls -l ${1}
+      [ -f ${2} ] && ls -l ${2}
+      [ -f ${2}/${1} ] && ls -l ${2}/${1}
+      cat /tmp/out_command.$$
+      IGCM_debug_Exit "IGCM_sys_Put_Out"
+    else
+
+      if [ X${JobType} = XRUN ] ; then
+        if [ X${3} = X ] ; then
+          [ -f ${2} ] && IGCM_sys_Chmod 444 ${2}
+          [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1}
+        fi
+      fi
+
+      \rm /tmp/out_command.$$
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Put_Out"
+  return 0
+}
+
+#D-#==================================================
+#D-function IGCM_sys_PutBuffer_Out
+#D-* Purpose: Copy a file on ${SCRATCHDIR} after having chmod it in readonly
+#D-* Examples:
+#D-
+function IGCM_sys_PutBuffer_Out {
+  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Out" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_PutBuffer_Out :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i exist skip
+
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  if [ $DRYRUN = 0 ]; then
+    if [ ! -f ${1} ] ; then
+      echo "WARNING : IGCM_sys_PutBuffer_Out ${1} DOES NOT EXIST ."
+      IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out"
+      return 1
+    fi
+    #
+    IGCM_sys_Mkdir $( dirname $2 )
+    #
+
+    exist=false
+    skip=false
+    if [ -f $2 ] ; then
+      IGCM_debug_Print 1 "$2 already exist"
+      exist=true
+      if [ "X$( diff $1 $2 )" = X ] ; then
+        IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy"
+        status=0
+        skip=true
+      else
+        IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy"
+        skip=false
+      fi
+    fi
+    #
+    if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then
+      IGCM_sys_Chmod u+w $2
+    fi
+
+    if [ X${skip} = Xfalse ] ; then
+      i=0
+      while [ $i -lt $NB_ESSAI ] ; do
+        # USUAL WAY
+        \cp $1 $2 > /tmp/out_command.$$ 2>&1
+        status=$?
+        if [ ${status} -gt 0 ]; then
+          IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : cp failed error code ${status} ${i}/${NB_ESSAI}"
+          IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : sleep ${DELAI} seconds and try again."
+          [ -f ${2} ] && ls -l ${2}
+          [ -f ${2}/${1} ] && ls -l ${2}/${1}
+          sleep $DELAI
+        else
+          break
+        fi
+        (( i = i + 1 ))
+      done
+    fi
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_PutBuffer_Out : error."
+      [ -f ${2} ] && ls -l ${2}
+      [ -f ${2}/${1} ] && ls -l ${2}/${1}
+      cat /tmp/out_command.$$
+      IGCM_debug_Exit "IGCM_sys_PutBuffer_Out"
+    else
+
+      if [ X${JobType} = XRUN ] ; then
+        if [ X${3} = X ] ; then
+          [ -f ${2} ] && IGCM_sys_Chmod 444 ${2}
+          [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1}
+        fi
+      fi
+
+      \rm /tmp/out_command.$$
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out"
+  return 0
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Get
+#D-* Purpose: Get a file from ${ARCHIVE}
+#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
+#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
+function IGCM_sys_Get {
+  IGCM_debug_PushStack "IGCM_sys_Get" $@
+
+  typeset DEST dm_liste target file_work
+  typeset NB_ESSAI DELAI status i
+
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Get :" $@
+  fi
+
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  if [ $DRYRUN -le 2 ]; then
+    if [ X${1} = X'/l' ] ; then
+      eval set +A dm_liste \${${2}}
+    else
+      eval set +A dm_liste ${1}
+    fi
+    eval DEST=\${${#}}
+
+    #=====================================================
+    #         COMMENT OUT DOUBLE COPY ON SCRATCHDIR
+    #=====================================================
+
+    # Is it an R_OUT file (not R_IN) ?
+    #echo ${dm_liste[0]} | grep "${R_OUT}" > /dev/null 2>&1
+    #if [ $? -eq 0 ] ; then
+    #  # Yes  ? then we try to get it in SCRATCHDIR
+    #  set +A file_work $( echo ${dm_liste[*]} | sed -e "s|${R_OUT}|${R_BUF}|g" )
+    #  if [ -f ${file_work[0]} ] ; then
+    #    IGCM_sys_Cp ${file_work[*]} ${DEST}
+    #    IGCM_debug_PopStack "IGCM_sys_Get"
+    #    return
+    #  fi
+    #fi
+
+    ccc_hsm get ${dm_liste[*]} > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      echo "WARNING IGCM_sys_Get : error code ${status}"
+      cat /tmp/out_command.$$
+      echo "WARNING IGCM_sys_Get : will stop later if the cp fails."
+    fi
+
+    #if [ ${status} -gt 0 ] ; then
+    #  if [ ! "X$( grep "Lost dmusrcmd connection" /tmp/out_command.$$ )" = "X" ] ; then
+    #    cat /tmp/out_command.$$
+    #    echo "WARNING IGCM_sys_Get : Lost dmusrcmd connection : "
+    #    sleep 30
+    #    echo "We try another time"
+    ##    dmget ${dm_liste[*]} > /tmp/out_command.$$ 2>&1
+    #    ccc_hsm get ${dm_liste[*]} > /tmp/out_command.$$ 2>&1
+    #    status=$?
+    #    if [ ${status} -gt 0 ] ; then
+    #      echo "ERROR IGCM_sys_Get : again demigration error :"
+    #      cat /tmp/out_command.$$
+    #      IGCM_debug_Exit "IGCM_sys_Get"
+    #    fi
+    #  else
+    #    echo "ERROR IGCM_sys_Get : demigration error :"
+    #    cat /tmp/out_command.$$
+    #    IGCM_debug_Exit "IGCM_sys_Get"
+    #  fi
+    #fi
+
+    #   #RSYNC WITH NETWORK SSH CALL
+    #   echo ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} > /tmp/out_command.$$ 2>&1
+    #   ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} >> /tmp/out_command.$$ 2>&1
+
+    #   #RSYNC WITH NFS USE
+    #   echo ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > /tmp/out_command.$$ 2>&1
+    #   ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> /tmp/out_command.$$ 2>&1
+
+    #   status=$?
+    #   IGCM_sys_Rsync_out $status
+
+    #   ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk /tmp/out_command.$$
+    #   (( status=status+$? ))
+
+    #USUAL WAY
+    if [ X${1} = X'/l' ] ; then
+      for target in ${dm_liste[*]} ; do
+        local_file=$( basename ${target} )
+        # test if the target file is present before the loop
+        IGCM_sys_TestFileArchive ${target}
+        status=$?
+        if [ ${status} -gt 0 ] ; then
+          echo "IGCM_sys_Get, ERROR : regular file ${target} DOES NOT EXIST ."
+          IGCM_debug_Exit "IGCM_sys_Get"
+        else
+          i=0
+          while [ $i -lt $NB_ESSAI ] ; do
+            \cp ${target} ${DEST}/${local_file} >> /tmp/out_command.$$ 2>&1
+            status=$?
+            if [ ${status} -gt 0 ]; then
+              IGCM_debug_Print 2 "IGCM_sys_Get : cp failed error code ${status} ${i}/${NB_ESSAI}"
+              IGCM_debug_Print 2 "IGCM_sys_Get : sleep ${DELAI} seconds and try again."
+              sleep $DELAI
+            else
+              break
+            fi
+            (( i = i + 1 ))
+          done
+          if [ ${status} -gt 0 ] ; then
+            echo "IGCM_sys_Get : error"
+            cat /tmp/out_command.$$
+            \rm /tmp/out_command.$$
+            IGCM_debug_Exit "IGCM_sys_Get"
+          else
+            \rm /tmp/out_command.$$
+          fi
+        fi
+      done
+    else
+      i=0
+      while [ $i -lt $NB_ESSAI ] ; do
+        \cp ${dm_liste} ${DEST} >> /tmp/out_command.$$ 2>&1
+        status=$?
+        if [ ${status} -gt 0 ]; then
+          IGCM_debug_Print 2 "IGCM_sys_Get : cp failed error code ${status} ${i}/${NB_ESSAI}"
+          IGCM_debug_Print 2 "IGCM_sys_Get : sleep ${DELAI} seconds and try again."
+          sleep $DELAI
+        else
+          break
+        fi
+        (( i = i + 1 ))
+      done
+      if [ ${status} -gt 0 ] ; then
+        echo "IGCM_sys_Get : error"
+        cat /tmp/out_command.$$
+        \rm /tmp/out_command.$$
+        IGCM_debug_Exit "IGCM_sys_Get"
+      else
+        \rm /tmp/out_command.$$
+      fi
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Get"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_GetBuffer
+#D-* Purpose: Get a file from ${SCRATCHDIR}
+#D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX
+#D-            IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/
+function IGCM_sys_GetBuffer {
+  IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@
+
+  typeset DEST buf_liste target file_work
+  typeset NB_ESSAI DELAI status i
+
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_GetBuffer :" $@
+  fi
+
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  if [ $DRYRUN -le 2 ]; then
+    if [ X${1} = X'/l' ] ; then
+      eval set +A buf_liste \${${2}}
+    else
+      eval set +A buf_liste ${1}
+    fi
+    eval DEST=\${${#}}
+
+    #USUAL WAY
+    if [ X${1} = X'/l' ] ; then
+      for target in ${buf_liste[*]} ; do
+        local_file=$( basename ${target} )
+        i=0
+        while [ $i -lt $NB_ESSAI ] ; do
+          \cp ${target} ${DEST}/${local_file} >> /tmp/out_command.$$ 2>&1
+          status=$?
+          if [ ${status} -gt 0 ]; then
+            IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}"
+            IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again."
+            sleep $DELAI
+          else
+            break
+          fi
+          (( i = i + 1 ))
+        done
+        if [ ${status} -gt 0 ] ; then
+          echo "IGCM_sys_Get : error"
+          cat /tmp/out_command.$$
+          \rm /tmp/out_command.$$
+          IGCM_debug_Exit "IGCM_sys_GetBuffer"
+        else
+          \rm /tmp/out_command.$$
+        fi
+      done
+    else
+      i=0
+      while [ $i -lt $NB_ESSAI ] ; do
+        \cp ${buf_liste} ${DEST} >> /tmp/out_command.$$ 2>&1
+        status=$?
+        if [ ${status} -gt 0 ]; then
+          IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}"
+          IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again."
+          sleep $DELAI
+        else
+          break
+        fi
+        (( i = i + 1 ))
+      done
+      if [ ${status} -gt 0 ] ; then
+        echo "IGCM_sys_Get : error"
+        cat /tmp/out_command.$$
+        \rm /tmp/out_command.$$
+        IGCM_debug_Exit "IGCM_sys_GetBuffer"
+      else
+        \rm /tmp/out_command.$$
+      fi
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_GetBuffer"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_GetDate_FichWork
+#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK
+#D-* Examples:
+#D-
+function IGCM_sys_GetDate_FichWork {
+  IGCM_debug_PushStack "IGCM_sys_FichWork" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_GetDate_FichWork :" $@
+  fi
+
+  if [ $# -ge 3 ] ; then
+    mode=$3
+    TimeStyle=$4
+  else
+    mode="default"
+    TimeStyle="%Y%m%d%H%M%S"
+  fi
+
+  typeset dateF
+  set +A dateF -- $( ls -l --full-time --time-style=+"${TimeStyle}" ${1} )
+
+  case $mode in
+    "default")
+      eval ${2}=${dateF[5]}
+      ;;
+    "SplitFields")
+      eval ${2}="${dateF[5]}\ ${dateF[6]}"
+      ;;
+  esac
+
+
+  # donne la date filesys d'un fichier sur la machine work
+  IGCM_debug_PopStack "IGCM_sys_FichWork"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_GetDate_FichArchive
+#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE
+#D-* Examples:
+#D-
+function IGCM_sys_GetDate_FichArchive {
+  IGCM_debug_PushStack "IGCM_sys_FichArchive" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_GetDate_FichArchive :" $@
+  fi
+  typeset dateF
+  set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} )
+  eval ${2}=${dateF[5]}
+
+  IGCM_debug_PopStack "IGCM_sys_FichArchive"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_GetDate_Monitoring
+#D-* Purpose: get the last year for which the monitoring has been computed
+#D-* Examples:
+#D-
+function IGCM_sys_GetDate_Monitoring {
+  IGCM_debug_PushStack "IGCM_sys_GetDate_Monitoring" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_GetDate_Monitoring :" $@
+  fi
+
+  eval ${2}=$( cdo showyear ${1} 2> /dev/null | gawk '{ print $NF }' )
+
+  IGCM_debug_PopStack "IGCM_sys_GetDate_Monitoring"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Dods_Rm
+#D-* Purpose: DO NOTHING ! Put ${ARCHIVE} files on DODS internet protocole.
+#D-* Examples:
+#D-
+function IGCM_sys_Dods_Rm {
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Dods_Rm :" $@
+  fi
+  typeset status
+  if [ $DRYRUN = 0 ]; then
+
+#    if [ ! -d /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} ] ; then
+#      echo "WARNING : IGCM_sys_Dods_Rm /dmnfs/cont003/dods/public/${LOGIN}/${R_DODS}/${1} DOES NOT EXIST ."
+#      echo "Nothing has been done."
+#      return
+#    fi
+
+    /ccc/cont003/home/dsm/p86ipsl/bin/dods_rm public/${LOGIN}/${R_DODS}/${1} # > out_dods_rm 2>&1
+    status=$?
+
+#    if [ ${status} -gt 0 ] ; then
+#      echo "IGCM_sys_Dods_Rm : error."
+#      cat out_dods_rm
+#      IGCM_debug_Exit "IGCM_sys_Dods_Rm"
+#    else
+#      rm out_dods_rm
+#    fi
+
+  fi
+  return $status
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Dods_Cp
+#D-* Purpose: Copy $(ARCHIVE) files on DODS internet protocole.
+#D-* Examples:
+#D-
+function IGCM_sys_Dods_Cp {
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Dods_Cp :" $@
+  fi
+  typeset status
+  if [ $DRYRUN = 0 ]; then
+
+#    if [ ! -d ${R_SAVE}/${1} ] ; then
+#      echo "WARNING : IGCM_sys_Dods_Cp ${R_SAVE}/${1} DOES NOT EXIST ."
+#      echo "Nothing has been done."
+#      return
+#    fi
+
+    /ccc/cont003/home/dsm/p86ipsl/bin/dods_cp ${1} public/${LOGIN}/${R_DODS} # > out_dods_cp 2>&1
+    status=$?
+
+#       if [ ${status} -gt 0 ] ; then
+#           echo "IGCM_sys_Dods_Cp : error."
+#           cat out_dods_cp
+#           IGCM_debug_Exit "IGCM_sys_Dods_Cp"
+#       else
+#           rm out_dods_cp
+#       fi
+
+  fi
+  return $status
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Put_Dods
+#D-* Purpose: Put $(ARCHIVE) files on DODS internet protocole.
+#D-* Examples:
+#D-
+function IGCM_sys_Put_Dods {
+  IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Put_Dods :" $@
+  fi
+  #set -vx
+  typeset status
+  if [ $DRYRUN = 0 ]; then
+    if ( [ ! -d ${R_SAVE}/${1} ] && [ ! -d ${R_FIGR}/${1} ] ) ; then
+      echo "WARNING IGCM_sys_Put_Dods : None of the following directories exist. Exactly one should."
+      echo "WARNING IGCM_sys_Put_Dods : ${R_SAVE}/${1} DOES NOT EXIST."
+      echo "WARNING IGCM_sys_Put_Dods : ${R_FIGR}/${1} DOES NOT EXIST."
+      IGCM_debug_PopStack "IGCM_sys_Put_Dods"
+      return
+    fi
+
+    if ( [ -d ${R_SAVE}/${1} ] && [ -d ${R_FIGR}/${1} ] ) ; then
+      echo "WARNING IGCM_sys_Put_Dods : Both of the following directories exist. Exactly one should."
+      echo "WARNING IGCM_sys_Put_Dods : ${R_SAVE}/${1} EXISTS."
+      echo "WARNING IGCM_sys_Put_Dods : ${R_FIGR}/${1} EXISTS."
+      IGCM_debug_PopStack "IGCM_sys_Put_Dods"
+      return
+    fi
+    #
+    if [ -d ${R_SAVE}/${1} ] ; then
+      cd ${R_SAVE}
+    elif [ -d ${R_FIGR}/${1} ] ; then
+      cd ${R_FIGR}
+    fi
+
+    IGCM_sys_Dods_Rm ${1}
+    IGCM_sys_Dods_Cp ${1}
+    status=0
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_Put_Dods : error."
+      IGCM_debug_Exit "IGCM_sys_Put_Dods"
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Put_Dods"
+}
+
+##############################################################
+# REBUILD OPERATOR
+
+#D-#==================================================
+#D-function IGCM_sys_rebuild
+#D-* Purpose: rebuild parallel files
+#D-* Examples:
+#D-
+function IGCM_sys_rebuild {
+  IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_rebuild :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i firstArg
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ~p86ipsl/rebuild/src_X64_CURIE/modipsl_v2_2_2_netcdf4.2/bin/rebuild -f -o $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_rebuild : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_rebuild : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      firstArg=${1}
+      \rm ${firstArg}
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_rebuild : rebuild error code is ${status}"
+    IGCM_debug_Exit "rebuild"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_rebuild"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_rebuild_station
+#D-* Purpose: rebuild parallel files describing station
+#D-* Examples:
+#D-
+function IGCM_sys_rebuild_station {
+  IGCM_debug_PushStack "IGCM_sys_rebuild_station" -- $@
+  typeset i list_opt file_in file_out prefix_invert list_invert
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_rebuild_station :" $@
+  fi
+  list_opt=$@
+
+  # Invert Axis : t,x -> x,t
+  #               t,pres,x -> x,t,pres
+  # So that we can concatenate along x
+  i=0
+  for file_in in ${list_opt} ; do
+    (( i = i + 1))
+    [ ${i} = 1 ] && file_out=${file_in} && continue
+    prefix_invert=$( basename ${file_in} .nc )
+    IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs ${file_in} ${prefix_invert}_xt.nc
+    list_invert[${#list_invert[*]}]=${prefix_invert}_xt.nc
+  done
+
+  # Concatenate
+  IGCM_sys_ncrcat ${list_invert[*]} histstn_xt.nc
+
+  # Re-ivert file
+  IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x histstn_xt.nc ${file_out}
+
+  # Station re-ordering is too expansive to be run within libIGCM
+  # This is due to (ncpdq - nrcat - ncpdq) I/O sequence.
+  # This re-ordering must be done "in memory" by the cmorization process
+  # Anyway this is the best sequence using (ncpdq - nrcat - ncpdq)
+  # BEGIN reordering
+
+  # Only LMDZ text output contains the exact ordering of the station.
+  # We isolate this in the code below:
+  #  0  38  -157.5000000000000  70.98591549295774
+  #  0  54  27.49999999999999   67.18309859154928
+  #  0  56  -62.50000000000001  82.39436619718309
+  #  0  79  12.49999999999999   78.59154929577466
+  #  0  116 -165.0000000000000  76.05633802816901
+  #  0  117 130.0000000000000   70.98591549295774
+  #  0  118 110.0000000000000   87.46478873239437
+  #  1  40  4.999999999999995   51.97183098591550
+#  typeset iStation iProc list_opt file_in file_out prefix_invert
+#  typeset -Z4 j4
+#  typeset -Z3 j3
+
+#  unset list_opt
+#  set +A list_opt $@
+
+  # Filename after rebuild
+#  file_out=${list_opt[0]}
+  # Prefix of output files
+#  prefix_invert=$( basename ${file_out} .nc )
+  # Number of procs
+#  num_proc=$( grep -i mpi_size ${PREFIX}_${Exe_Output} | wc -l )
+
+#  iProc=0
+#  while [ ${iProc} -lt ${num_proc} ] ; do
+    # Array containing Station as a number
+#    unset proc_stn
+#    set +A proc_stn $( grep "iophy_mpi rank ip lon lat  $iProc" ${PREFIX}_${Exe_Output} | sed -e "s/iophy_mpi rank ip lon lat //g" | gawk ' {print $2}' )
+    # Number of stations produced by processor proc
+#    stationLast=${#proc_stn[*]}
+    # Proc number on 4 digits
+#    j4=${iProc}
+    # Init
+#    iStation=0
+#    while [ ${iStation} -lt ${stationLast} ] ; do
+      # Station number on 3 digits
+#      j3=${proc_stn[${iStation}]}
+      # Extract station
+      # Invert Axis : t,x -> x,t
+      #               t,pres,x -> x,t,pres
+      # So that we can concatenate along x
+#      IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs -d x,$iStation,$iStation ${prefix_invert}_${j4}.nc ${prefix_invert}_stn_${j3}.nc
+#      (( iStation = iStation + 1 ))
+#    done
+#    (( iProc = iProc + 1 ))
+#  done
+
+  # Concatenate all station along x
+#  IGCM_sys_ncrcat ${prefix_invert}_stn_???.nc ${prefix_invert}_xt.nc
+
+  # Re-invert file
+#  IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x ${prefix_invert}_xt.nc ${file_out}
+
+  # END reordering
+
+  IGCM_debug_PopStack "IGCM_sys_rebuild_station"
+}
+
+############################################################
+# Activate Running Environnment Variables
+
+#D-#==================================================
+#D-function IGCM_sys_desactiv_variables
+#D-* Purpose: set environement variables prior to execution
+#D-* Examples:
+#D-
+function IGCM_sys_activ_variables {
+  IGCM_debug_PushStack "IGCM_sys_activ_variables"
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_activ_variables"
+  fi
+
+# --------------------------------------------------------------------
+#D- MPI specifications
+# --------------------------------------------------------------------
+
+# --------------------------------------------------------------------
+#D- Other specifications
+# --------------------------------------------------------------------
+
+  ulimit -s unlimited
+
+  IGCM_debug_PopStack "IGCM_sys_activ_variables"
+}
+
+############################################################
+# Desactivate Running Environnment Variables
+
+#D-#==================================================
+#D-function IGCM_sys_desactiv_variables
+#D-* Purpose: unset environement variables after execution
+#D-* Examples:
+#D-
+function IGCM_sys_desactiv_variables {
+  IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_desactiv_variables"
+  fi
+# --------------------------------------------------------------------
+#D- MPI specifications
+# --------------------------------------------------------------------
+
+# --------------------------------------------------------------------
+#D- Other specifications
+# --------------------------------------------------------------------
+
+  IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
+}
+
+############################################################
+# Build MPI/OMP scripts run file (dummy function)
+
+#D-#==================================================
+#D-function IGCM_sys_build_run_file
+#D-* Purpose: build run file (deprecated)
+#D-* Examples:
+#D-
+function IGCM_sys_build_run_file {
+
+  IGCM_debug_Print 3 " dummy function : IGCM_sys_build_run_file "
+
+}
+
+############################################################
+# Build MPI/OMP scripts
+
+#D-#==================================================
+#D-function IGCM_sys_build_execution_scripts
+#D-* Purpose: build execution scripts to be launch by ${HOST_MPIRUN_COMMAND}
+#D-* Examples:
+#D-
+function IGCM_sys_build_execution_scripts
+{
+  IGCM_debug_PushStack "IGCM_sys_build_execution_scripts" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_build_execution_scripts " $@
+  fi
+
+  EXECUTION=${HOST_MPIRUN_COMMAND}
+
+  if ( ${OK_PARA_MPMD} ) ; then
+
+    if [ -f run_file ] ; then
+      IGCM_sys_Rm -f run_file
+    fi
+    touch run_file
+
+# run_file construction
+
+# Then first loop on the components for the coupler ie oasis
+
+## the coupler ie oasis must be the first one
+    for comp in ${config_ListOfComponents[*]} ; do
+
+      eval ExeNameIn=\${config_Executable_${comp}[0]}
+      eval ExeNameOut=\${config_Executable_${comp}[1]}
+
+      # for CPL component only
+      if [ "X${comp}" = "XCPL" ] && [ "X${ExeNameOut}" != X\"\" ] ; then
+
+        eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
+        eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
+        echo "${comp_proc_mpi_loc} ./${ExeNameOut}" >> run_file
+      fi
+    done
+
+# Then second loop on the components
+
+    for comp in ${config_ListOfComponents[*]} ; do
+
+      eval ExeNameIn=\${config_Executable_${comp}[0]}
+      eval ExeNameOut=\${config_Executable_${comp}[1]}
+
+      # Only if we really have an executable for the component and not the coupler ie oasis:
+      if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${comp}" != "XCPL" ] ) ; then
+
+        eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
+        eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
+        echo "${comp_proc_mpi_loc} ./${ExeNameOut}" >> run_file
+      fi
+    done
+
+    EXECUTION="${HOST_MPIRUN_COMMAND} -f ./run_file"
+
+    IGCM_sys_Chmod u+x run_file
+    if ( $DEBUG_sys ) ; then
+      echo "run_file contains : "
+      cat run_file
+    fi
+
+  else # Only one executable. launch it.
+
+    for comp in ${config_ListOfComponents[*]} ; do
+
+      # Only if we really have an executable for the component :
+      eval ExeNameOut=\${config_Executable_${comp}[1]}
+      if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${ExeNameOut}" != "Xinca.dat" ] ) ; then
+
+        echo "#!/bin/ksh" > script_${ExeNameOut}.ksh
+        echo ""  >> script_${ExeNameOut}.ksh
+        IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh
+
+        if ( ${OK_PARA_OMP} ) ; then
+          eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
+          echo ""  >> script_${ExeNameOut}.ksh
+          echo "export KMP_STACKSIZE=3g"  >> script_${ExeNameOut}.ksh
+          echo "export KMP_LIBRARY=turnaround"  >> script_${ExeNameOut}.ksh
+          echo "export MKL_SERIAL=YES"  >> script_${ExeNameOut}.ksh
+          echo "OMP_NUM_THREADS=${comp_proc_omp_loc}" >> script_${ExeNameOut}.ksh
+        fi
+
+        if  ( ${OK_PARA_MPI} ) ; then
+          eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
+          # Default : ccc_mprun used if nb_proc gt 1
+          # to have out/err per process on different files
+          # echo "./${ExeNameOut} > out_${ExeNameOut}.out.\${SLURM_PROCID} 2>out_${ExeNameOut}.err.\${SLURM_PROCID}"  >> script_${ExeNameOut}.ksh
+          echo "./${ExeNameOut}" >> script_${ExeNameOut}.ksh
+          EXECUTION="${HOST_MPIRUN_COMMAND} -n ${comp_proc_mpi_loc} ./script_${ExeNameOut}.ksh"
+        else
+          # Default : ccc_mprun is NOT used if nb_proc eq 1
+          # to have out/err per process on different files
+          # echo "./${ExeNameOut} > out_${ExeNameOut}.out 2>out_${ExeNameOut}.err" >> script_${ExeNameOut}.ksh
+          echo "./${ExeNameOut}" >> script_${ExeNameOut}.ksh
+          EXECUTION="/usr/bin/time ./script_${ExeNameOut}.ksh"
+        fi
+
+        IGCM_debug_Print 1 "sys Curie : script_${ExeNameOut}.ksh contains"
+        cat script_${ExeNameOut}.ksh
+
+      fi
+
+    done
+
+  fi
+
+  IGCM_debug_Print 1 "sys Curie : execution command is "
+  IGCM_debug_Print 1 "$EXECUTION"
+
+  IGCM_debug_PopStack "IGCM_sys_build_execution_scripts"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_check_path
+#D-* Purpose: check that RUN_DIR_PATH that will be removed on some machine
+#D-* do not point to an important use directory. Stop immediately in that case.
+#D-* Examples:
+#D-
+function IGCM_sys_check_path {
+  IGCM_debug_PushStack "IGCM_sys_check_path"
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_check_path"
+  fi
+
+  if ( [ X${RUN_DIR_PATH} = X${HOME} ] || [ X${RUN_DIR_PATH} = X${WORKDIR} ] || [ X${RUN_DIR_PATH} = X${SCRATCHDIR} ] || [ X${RUN_DIR_PATH} = X${CCCWORKDIR} ] || [ X${RUN_DIR_PATH} = X${CCCSTOREDIR} ] ) ; then
+    IGCM_debug_Print 1 "Variable RUN_DIR_PATH is pointing to an important directory : ${RUN_DIR_PATH}"
+    IGCM_debug_Print 1 "Please check the RUN_DIR_PATH definition in your Job : Job_${config_UserChoices_JobName}"
+    IGCM_debug_Exit "This will stop the job"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_check_path"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_check_quota
+#D-* Purpose: check user quota. Stop the simulation if quota above 90%
+#D-* Examples:
+#D-
+function IGCM_sys_check_quota {
+  IGCM_debug_PushStack "IGCM_sys_check_quota"
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_check_quota"
+  fi
+  # Limit of quota (in %)
+  limit_quota=90
+
+  # Check of the volume
+  volume_quota=$(ccc_quota | grep ' scratch' | gawk '{print $2}')
+  volume_avail=$(ccc_quota | grep ' scratch' | gawk '{print $3}')
+
+  if ( [ ! X${volume_quota} = X ] && [ ! ${volume_quota} = "-" ] ) ; then
+
+    unit_avail=${volume_avail: -1}
+    unit_quota=${volume_quota: -1}
+
+    if [ "${unit_quota}" = "*" ] ; then
+      IGCM_debug_Print 1 "Please, check your quota of volume on scratch"
+      IGCM_debug_Print 1 "More than 100% of your quota is used"
+      IGCM_debug_Print 1 "Use the ccc_quota command to check"
+      IGCM_debug_Print 1 "You must have more than 10% available to run"
+      IGCM_debug_Exit "Not enough space to run ! STOP HERE"
+      IGCM_debug_Verif_Exit
+    fi
+
+    temp_avail=${volume_avail%%${volume_avail: -1}*}
+    temp_quota=${volume_quota%%${volume_quota: -1}*}
+
+    if [ ! ${unit_avail} = ${unit_quota} ] ; then
+
+    # Convertion
+      if [ ${volume_avail: -1} = "T" ] ; then
+        (( temp_avail = temp_avail * 1000000000000 ))
+      elif [ ${volume_avail: -1} = "G" ] ; then
+        (( temp_avail = temp_avail * 1000000000 ))
+      elif [ ${volume_avail: -1} = "M" ] ; then
+        (( temp_avail = temp_avail * 1000000 ))
+      elif [ ${volume_avail: -1} = "k" ] ; then
+        (( temp_avail = temp_avail * 1000 ))
+      else
+        (( temp_avail = volume_avail ))
+      fi
+      if [ ${volume_quota: -1} = "T" ] ; then
+        (( temp_quota = temp_quota * 1000000000000 ))
+      elif [ ${volume_quota: -1} = "G" ] ; then
+        (( temp_quota = temp_quota * 1000000000 ))
+      elif [ ${volume_quota: -1} = "M" ] ; then
+        (( temp_quota = temp_quota * 1000000 ))
+      elif [ ${volume_quota: -1} = "k" ] ; then
+        (( temp_quota = temp_quota * 1000 ))
+      else
+        (( temp_quota = volume_quota ))
+      fi
+    fi
+
+    quota_volume=$(echo "scale=2 ; $temp_quota/$temp_avail*100" | bc)
+#    echo "volume ratio is " $quota_volume
+
+    if [ ${quota_volume} -ge ${limit_quota} ] ; then
+      IGCM_debug_Print 1 "Please, check your quota of volume on scratch"
+      IGCM_debug_Print 1 "${quota_volume}% of your quota is used"
+      IGCM_debug_Print 1 "Use the ccc_quota command to check"
+      IGCM_debug_Print 1 "You must have more than 10% available to run"
+      IGCM_debug_Exit "Not enough space to run ! STOP HERE"
+      IGCM_debug_Verif_Exit
+    fi
+
+  fi
+
+# Check of the number of inodes
+
+  inode_quota=$(ccc_quota | grep ' scratch' | gawk '{print $6}')
+  inode_avail=$(ccc_quota | grep ' scratch' | gawk '{print $7}')
+
+  if ( [ ! X${inode_quota} = X ] && [ ! ${inode_quota} = "-" ] ) ; then
+
+    unit_avail=${inode_avail: -1}
+    unit_quota=${inode_quota: -1}
+
+    if [ "${unit_quota}" = "*" ] ; then
+      IGCM_debug_Print 1 "Please, check your quota of inode on scratch"
+      IGCM_debug_Print 1 "More than 100% of your quota is used"
+      IGCM_debug_Print 1 "Use the ccc_quota command to check"
+      IGCM_debug_Print 1 "You must have more than 10% available to run"
+      IGCM_debug_Exit "Not enough space to run ! STOP HERE"
+      IGCM_debug_Verif_Exit
+    fi
+
+    temp_avail=${inode_avail%%${inode_avail: -1}*}
+    temp_quota=${inode_quota%%${inode_quota: -1}*}
+
+    if [ ! ${unit_avail} = ${unit_quota} ] ; then
+
+    # Convertion
+      if [ ${inode_avail: -1} = "T" ] ; then
+        (( temp_avail = temp_avail * 1000000000000 ))
+      elif [ ${inode_avail: -1} = "G" ] ; then
+        (( temp_avail = temp_avail * 1000000000 ))
+      elif [ ${inode_avail: -1} = "M" ] ; then
+        (( temp_avail = temp_avail * 1000000 ))
+      elif [ ${inode_avail: -1} = "k" ] ; then
+        (( temp_avail = temp_avail * 1000 ))
+      else
+        (( temp_avail = inode_avail ))
+      fi
+
+      if [ ${inode_quota: -1} = "T" ] ; then
+        (( temp_quota = temp_quota * 1000000000000 ))
+      elif [ ${inode_quota: -1} = "G" ] ; then
+        (( temp_quota = temp_quota * 1000000000 ))
+      elif [ ${inode_quota: -1} = "M" ] ; then
+        (( temp_quota = temp_quota * 1000000 ))
+      elif [ ${inode_quota: -1} = "k" ] ; then
+        (( temp_quota = temp_quota * 1000 ))
+      else
+        (( temp_quota = inode_quota ))
+      fi
+    fi
+    quota_inode=$(echo "scale=2 ; $temp_quota/$temp_avail*100" | bc)
+#    echo "inode ratio is " $quota_inode
+
+    if [ ${quota_inode} -ge ${limit_quota} ] ; then
+      IGCM_debug_Print 1 "Please, check your quota of inode on scratch"
+      IGCM_debug_Print 1 "${quota_inode}% of your quota is used"
+      IGCM_debug_Print 1 "Use the ccc_quota command to check"
+      IGCM_debug_Print 1 "You must have more than 10% available to run"
+      IGCM_debug_Exit "Not enough space to run ! STOP HERE"
+      IGCM_debug_Verif_Exit
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_check_quota"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_GetJobID
+#D-* Purpose: Check if job_name is currently
+#D-  running or in queue
+#D-* Examples: IGCM_sys_GetJobID ${JobName} ${TargetUsr} JobID
+#D-
+function IGCM_sys_GetJobID {
+  IGCM_debug_PushStack "IGCM_sys_GetJobID"
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_GetJobID"
+  fi
+
+  # With -f option, the full job name is given in the last column
+  ID=$( ccc_mstat -f -u $2 | \
+        gawk -v JobName=$1 '( $NF ~ JobName ) { print $1 }' )
+
+  eval ${3}=${ID}
+
+  IGCM_debug_PopStack "IGCM_sys_GetJobID"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_CountJobInQueue
+#D-* Purpose: Check if job_name is currently
+#D-  running or in queue
+#D-* Examples: IGCM_sys_CountJobInQueue ${JobName} NbRun
+#D-
+function IGCM_sys_CountJobInQueue {
+  IGCM_debug_PushStack "IGCM_sys_CountJobInQueue"
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_CountJobInQueue"
+  fi
+
+  #NbRun=$( ccc_mstat -f | grep -c ${JobName} )
+
+  # With -f option, the full job name is given in the last column
+  NbRun=$( ccc_mstat -f | gawk -v JobName=$1 'BEGIN { x=0 } ( $NF ~ JobName ) { x=x+1 } END { print x }' )
+
+  eval ${2}=${NbRun}
+
+  IGCM_debug_PopStack "IGCM_sys_CountJobInQueue"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ListJobInQueue
+#D-* Purpose: Check if job_name is currently
+#D-  running or in queue
+#D-* Examples: IGCM_sys_ListJobInQueue ${User} JobNameList
+#D-
+function IGCM_sys_ListJobInQueue {
+  IGCM_debug_PushStack "IGCM_sys_ListJobInQueue"
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ListJobInQueue"
+  fi
+
+  # With -f option, the full job name is given in the last column
+  set -A JobList $( ccc_mstat -f | gawk -v User=$1             \
+                                        '( $2  == User      && \
+                                           $NF != /TS/      && \
+                                           $NF !~ /PACK/    && \
+                                           $NF !~ /REBUILD/ && \
+                                           $NF !~ /pack/ )     \
+                                         { print $NF }' | sed -e "s/\(.*\)\.[0-9]*/\1/" )
+
+  eval set -A ${2} ${JobList[*]}
+
+  IGCM_debug_PopStack "IGCM_sys_ListJobInQueue"
+}
+
+##############################################################
+# NCO OPERATOR
+
+#D-#==================================================
+#D-function IGCM_sys_ncap2
+#D-* Purpose: encapsulate ncap2 call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncap2 {
+  IGCM_debug_PushStack "IGCM_sys_ncap2" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncap2 :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncap2 "$@" > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncap2 : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncap2 : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncap2 : ncap2 error"
+    IGCM_debug_Exit "ncap2"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncap2"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncatted
+#D-* Purpose: encapsulate ncatted call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncatted {
+  IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncatted :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncatted "$@" > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncatted : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncatted : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncatted : ncatted error"
+    IGCM_debug_Exit "ncatted"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncatted"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncbo
+#D-* Purpose: encapsulate ncbo call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncbo {
+  IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncbo :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncbo $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncbo : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncbo : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncbo : ncbo error"
+    IGCM_debug_Exit "ncbo"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncbo"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncdif
+#D-* Purpose: encapsulate ncdiff call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncdiff {
+  IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncdiff :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncdiff $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncdiff : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncdiff : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncdiff : ncdiff error"
+    IGCM_debug_Exit "ncdiff"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncdiff"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncea
+#D-* Purpose: encapsulate ncea call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncea {
+  IGCM_debug_PushStack "IGCM_sys_ncea" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncea :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncea $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncea : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncea : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncea : ncea error"
+    IGCM_debug_Exit "ncea"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncea"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncecat
+#D-* Purpose: encapsulate ncecat call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncecat {
+  IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncecat :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncecat $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncecat : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncecat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncecat : ncecat error"
+    IGCM_debug_Exit "ncecat"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncecat"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncflint
+#D-* Purpose: encapsulate ncflint call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncflint {
+  IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncflint :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncflint $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncflint : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncflint : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncflint : ncflint error"
+    IGCM_debug_Exit "ncflint"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncflint"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncks
+#D-* Purpose: encapsulate ncks call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncks {
+  IGCM_debug_PushStack "IGCM_sys_ncks" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncks :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncks $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncks : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncks : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncks : ncks error"
+    IGCM_debug_Exit "ncks"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncks"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncpdq
+#D-* Purpose: encapsulate ncpdq call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncpdq {
+  IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncpdq :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncpdq $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncpdq : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncpdq : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncpdq : ncpdq error"
+    IGCM_debug_Exit "ncpdq"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncpdq"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncra
+#D-* Purpose: encapsulate ncra call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncra {
+  IGCM_debug_PushStack "IGCM_sys_ncra" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncra :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncra $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncra : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncra : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncra : ncra error"
+    IGCM_debug_Exit "ncra"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncra"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncrcat
+#D-* Purpose: encapsulate ncrcat call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncrcat {
+  IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncrcat :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i lastArg
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncrcat $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncrcat : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    elif [ ! "X$( grep "WARNING Intra-file non-monotonicity" /tmp/out_command.$$ )" = "X" ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncrcat : WARNING Intra-file non-monotonicity"
+      cat /tmp/out_command.$$
+      # remove files having corrupted time axis
+      eval lastArg=\${$#}
+      IGCM_debug_Print 2 "IGCM_sys_ncrcat : Delete ${lastArg}"
+      \rm ${lastArg}
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncrcat : ncrcat error"
+    #IGCM_debug_Exit "ncrcat"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncrcat"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncrename
+#D-* Purpose: encapsulate ncrename call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncrename {
+  IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncrename :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncrename $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncrename : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncrename : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncrename : ncrename error"
+    IGCM_debug_Exit "ncrename"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncrename"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncwa
+#D-* Purpose: encapsulate ncwa call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncwa {
+  IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncwa :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncwa $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncwa : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncwa : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncwa : ncwa error"
+    IGCM_debug_Exit "ncwa"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncwa"
+}
+
+##############################################################
+# CDO OPERATOR
+
+#D-#==================================================
+#D-function IGCM_sys_cdo
+#D-* Purpose: encapsulate cdo call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_cdo {
+  IGCM_debug_PushStack "IGCM_sys_cdo" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_cdo :" $@
+  fi
+
+  typeset status
+
+  \cdo $@ > /tmp/out_command.$$ 2>&1
+  status=$?
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_cdo : error code ${status}"
+    cat /tmp/out_command.$$
+    \rm /tmp/out_command.$$
+    IGCM_debug_PopStack "IGCM_sys_cdo"
+    return 1
+  else
+    IGCM_debug_PopStack "IGCM_sys_cdo"
+    return 0
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_cdo"
+}
Index: /tags/libIGCM_v2.2/libIGCM_sys/libIGCM_sys_default.ksh
===================================================================
--- /tags/libIGCM_v2.2/libIGCM_sys/libIGCM_sys_default.ksh	(revision 998)
+++ /tags/libIGCM_v2.2/libIGCM_sys/libIGCM_sys_default.ksh	(revision 998)
@@ -0,0 +1,2509 @@
+#!/bin/ksh
+
+#**************************************************************
+# Author: Sebastien Denvil, Martial Mancip
+# Contact: Martial.Mancip__at__ipsl.jussieu.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#=========================================================
+# The documentation of this file can be automatically generated
+# if you use the prefix #D- for comments to be extracted.
+# Extract with command: cat lib* | grep "^#D-" | cut -c "4-"
+#=========================================================
+
+#D-#==================================================
+#D-LibIGCM_sys Default host
+#D-#==================================================
+#D-
+#D- This ksh library if a layer under some usefull
+#D-environment variables and shell commands.
+#D-All those definitions depend on host particularities.
+#D-It manages a stack mechanism and test validity of operations.
+#D-All function described bellow must be prefixed by IGCM_sys.
+
+#====================================================
+# libIGCM_sys PARAMETERS
+#====================================================
+
+#====================================================
+# set DEBUG_sys to true to output calls of function
+typeset -r DEBUG_sys=${DEBUG_sys:=true}
+
+#====================================================
+# Turn in dry run mode ? (sys_Put_Rest, sys_Put_Out, sys_Get)
+typeset -r DRYRUN=${DRYRUN:=0}
+
+# YOU MUST COMPILE YOUR EXE FILES FOR DRYRUN MODE !
+# -------------------------------------------------------------------------------------
+# | DRYRUN=  |  Date computations, | sys_Get    |  Exe    | sys_Put_Out; sys_Put_Rest |
+# |          |  Cp/Exe/param/files |            |         |                           |
+# |          |  Chmod Qsub         |            |         |                           |
+# -------------------------------------------------------------------------------------
+# |    0     |       yes           |    yes     |  yes    |      yes                  |
+# -------------------------------------------------------------------------------------
+# |    1     |       yes           |    yes     |  yes    |      no                   |
+# -------------------------------------------------------------------------------------
+# |    2     |       yes           |    yes     |  no     |      no                   |
+# -------------------------------------------------------------------------------------
+# |    3     |       yes           |    no      |  no     |      no                   |
+# -------------------------------------------------------------------------------------
+
+#=====================================================
+# Global Variables :
+#=====================================================
+# Language : "fr" or "en"
+typeset -r MYLANG="fr"
+
+#=====================================================
+# Host and user names
+# $hostname ou hostname
+typeset  HOST=${HOST:=$( hostname )}
+# $username ou whoami
+typeset  LOGIN=${LOGIN:=$( whoami )}
+# $hostname of the MASTER job
+typeset -r MASTER=${HOST}
+
+#D-
+#D-#==================================================
+#D-Program used in libIGCM
+#D-#==================================================
+
+# Submit command
+typeset SUBMIT=${SUBMIT:=qsub}
+# rsync with path
+typeset -r RSYNC=/usr/bin/rsync
+# RSYNC_opt args to rsync
+typeset -r RSYNC_opt="-va"
+# ie storage filesystem
+typeset -r STOREHOST=${MASTER}
+
+#====================================================
+# Set environment tools (ferret, nco, cdo)
+#====================================================
+#. /home/${LOGIN}/.atlas_env_${HOST}_ksh
+
+export PATH=${PATH}:/home/jripsl/snapshot/Monitoring/CNClient/
+
+#====================================================
+# Host specific DIRECTORIES
+#====================================================
+
+#====================================================
+#- MirrorlibIGCM for frontend
+typeset -r MirrorlibIGCM=${MirrorlibIGCM:=false}
+
+#====================================================
+#- libIGCM_POST for frontend
+typeset -r libIGCM_POST=${libIGCM}
+
+#====================================================
+#- R_EXE   (==> BIN_DIR = ${MODIPSL}/bin )
+typeset -r R_EXE="${MODIPSL}/bin"
+
+#====================================================
+#- SUBMIT_DIR : submission dir
+typeset SUBMIT_DIR=${SUBMIT_DIR:=${PWD}}
+
+#====================================================
+#- IN
+typeset -r R_IN=${R_IN:=/home/${LOGIN}/IGCM}
+typeset -r R_IN_ECMWF=${R_IN_ECMWF:=/home/${LOGIN}/IGCM}
+
+#====================================================
+#- ARCHIVE
+typeset ARCHIVE=${ARCHIVE:=/home/${LOGIN}}
+
+#====================================================
+#- STORAGE (dedicated to small/medium files)
+typeset STORAGE=${ARCHIVE}
+
+#====================================================
+#- R_OUT
+typeset R_OUT=${ARCHIVE}/IGCM_OUT
+
+#====================================================
+#- R_FIG (hosting figures : monitoring and atlas, and/or small files)
+typeset R_FIG=${STORAGE}/IGCM_OUT
+
+#====================================================
+#- R_BUF (ONLY FOR double copy an scratch)
+typeset -r R_BUF=${STORAGE}/IGCM_OUT
+
+#====================================================
+#- RUN_DIR_PATH : Temporary working directory (=> TMP)
+typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=${STORAGE}/RUN_DIR/tmp$$}
+
+#====================================================
+#- HOST_MPIRUN_COMMAND
+typeset -r HOST_MPIRUN_COMMAND=${HOST_MPIRUN_COMMAND:="time mpirun"}
+
+#====================================================
+#- Max number of arguments passed to nco operator or demigration command
+UNIX_MAX_LIMIT=360
+
+#====================================================
+#- Number of core per node (max number of OpenMP task)
+NUM_COREPERNODE=1
+
+#====================================================
+#- Default number of MPI task for IPSL coupled model
+#- required for backward compatibility
+#-
+DEFAULT_NUM_PROC_OCE=1
+DEFAULT_NUM_PROC_CPL=1
+(( DEFAULT_NUM_PROC_ATM = BATCH_NUM_PROC_TOT - DEFAULT_NUM_PROC_OCE - DEFAULT_NUM_PROC_CPL ))
+DEFAULT_NUM_PROC_TOTAL=${BATCH_NUM_PROC_TOT}
+
+#D-#==================================================
+#D-function IGCM_sys_ChangeArchive
+#D-* Purpose: Just a dummy call on this machine
+#D-* Examples:
+#D-
+function IGCM_sys_ChangeArchive {
+  IGCM_debug_Print 1 " dummy function : IGCM_sys_ChangeArchive "
+}
+
+#D-#==================================================
+#D-function IGCM_sys_RshMaster
+#D-* Purpose: Connection to frontend machine.
+#D-* Examples:
+#D-
+function IGCM_sys_RshMaster {
+  IGCM_debug_PushStack "IGCM_sys_RshMaster" $@
+  /bin/ksh <<-EOF
+    export libIGCM=${libIGCM}
+    export DEBUG_debug=${DEBUG_debug}
+    . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
+    . ${libIGCM}/libIGCM_card/libIGCM_card.ksh
+    ${@}
+EOF
+  if [ $? -gt 0 ] ; then
+    echo "IGCM_sys_RshMaster : erreur."
+    IGCM_debug_Exit "IGCM_sys_RshMaster"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_RshMaster"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_RshArchive
+#D-* Purpose: Archive rsh command
+#D-* Examples:
+#D-
+function IGCM_sys_RshArchive {
+  IGCM_debug_PushStack "IGCM_sys_RshArchive" $@
+  /bin/ksh <<-EOF
+    ${@}
+EOF
+  status=$?
+  if [ ${status} -gt 0 ] ; then
+    IGCM_debug_Print 2 "IGCM_sys_RshArchive : command failed error code ${status}"
+    IGCM_debug_Exit "IGCM_sys_RshArchive"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_RshArchive"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_RshPost
+#D-* Purpose: Post-process rsh command
+#D-* Examples:
+#D-
+function IGCM_sys_RshPost {
+  IGCM_debug_PushStack "IGCM_sys_RshPost" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_RshPost :" $@
+  fi
+
+  # keep standard input (stdin) for the loop onto temporary file
+  cat >tmp_IGCM_sys_RshPost_$$
+
+  /bin/ksh <tmp_IGCM_sys_RshPost_$$
+  if [ $? -gt 0 ] ; then
+    echo "IGCM_sys_RshPost : erreur."
+    IGCM_debug_Exit "IGCM_sys_RshPost"
+  fi
+  # delete temporary file
+  \rm tmp_IGCM_sys_RshPost_$$
+  IGCM_debug_PopStack "IGCM_sys_RshPost"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_SendMail
+#D-* Purpose: Send mail when simulation is over
+#D-* Examples:
+#D-
+function IGCM_sys_SendMail {
+  IGCM_debug_PushStack "IGCM_sys_SendMail" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_SendMail :" $@
+  fi
+
+  if [ X${1} = XAccounting ] ; then
+    status=Accounting
+    mailText=jobAccounting.mail
+  elif ( ${ExitFlag} ) ; then
+    status=failed
+    mailText=jobEnd.mail
+  else
+    status=completed
+    mailText=jobEnd.mail
+  fi
+
+  # Update selected mail template
+  while read -r line; do
+    eval echo $line >> mail.txt ;
+  done < ${libIGCM}/libIGCM_sys/${mailText}
+
+  if [ ! -z ${config_UserChoices_MailName} ] ; then
+    mailx -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} <  mail.txt
+  elif [ -f ~/.forward ] ; then
+    mailx -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < mail.txt
+  fi
+
+  sleep 10
+  rm -f mail.txt
+
+  IGCM_debug_PopStack "IGCM_sys_SendMail"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Mkdir
+#D-* Purpose: Master locale mkdir command
+#D-* Examples:
+#D-
+function IGCM_sys_Mkdir {
+  IGCM_debug_PushStack "IGCM_sys_Mkdir" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Mkdir :" $@
+  fi
+  if [ ! -d ${1} ]; then
+    \mkdir -p $1
+    if [ $? -gt 0 ] ; then
+      echo "IGCM_sys_Mkdir : erreur."
+      IGCM_debug_Exit "IGCM_sys_Mkdir"
+    fi
+  fi
+  # vérification :
+  if [ ! -d ${1} ] ; then
+    echo "IGCM_sys_Mkdir : erreur."
+    IGCM_debug_Exit "IGCM_sys_Mkdir"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Mkdir"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_MkdirArchive
+#D-* Purpose: Mkdir on Archive
+#D-* Examples:
+#D-
+function IGCM_sys_MkdirArchive {
+  IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_MkdirArchive :" $@
+  fi
+  #- creation de repertoire sur le serveur fichier
+  mkdir -p $1
+  status=$?
+
+  if [ ${status} -gt 0 ] ; then
+    IGCM_debug_Print 2 "IGCM_sys_MkdirArchive : mkdir failed error code ${status}"
+    IGCM_debug_Exit "IGCM_sys_MkdirArchive"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_MkdirArchive"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_MkdirWork
+#D-* Purpose: Mkdir on Work
+#D-* Examples:
+#D-
+function IGCM_sys_MkdirWork {
+  IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_MkdirWork :" $@
+  fi
+  #- creation de repertoire sur le serveur fichier
+  if [ ! -d ${1} ]; then
+    \mkdir -p $1
+    if [ $? -gt 0 ] ; then
+      echo "IGCM_sys_MkdirWork : erreur."
+      IGCM_debug_Exit "IGCM_sys_MkdirWork"
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_MkdirWork"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Cd
+#D-* Purpose: master cd command
+#D-* Examples:
+#D-
+function IGCM_sys_Cd {
+  IGCM_debug_PushStack "IGCM_sys_Cd" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Cd :" $@
+  fi
+  \cd $1
+  if [ $? -gt 0 ] ; then
+    echo "IGCM_sys_Cd : erreur."
+    IGCM_debug_Exit "IGCM_sys_Cd"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Cd"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Chmod
+#D-* Purpose: Chmod
+#D-* Examples:
+#D-
+function IGCM_sys_Chmod {
+  IGCM_debug_PushStack "IGCM_sys_Chmod" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Chmod :" $@
+  fi
+  \chmod $@
+  if [ $? -gt 0 ] ; then
+    echo "IGCM_sys_Chmod : erreur."
+    IGCM_debug_Exit "IGCM_sys_Chmod"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Chmod"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_FileSize
+#D-* Purpose: Filesize
+#D-* Examples:
+#D-
+function IGCM_sys_FileSize {
+  IGCM_debug_PushStack "IGCM_sys_FileSize" $@
+
+  typeset sizeF
+  set +A sizeF -- $( ls -la ${1} )
+  if [ $? -gt 0 ] ; then
+    IGCM_debug_Exit "IGCM_sys_FileSize"
+  fi
+  eval ${2}=${sizeF[4]}
+
+  IGCM_debug_PopStack "IGCM_sys_FileSize"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_TestDir
+#D-* Purpose: Test Directory that must exists
+#D-* Examples:
+#D-
+function IGCM_sys_TestDir {
+  IGCM_debug_PushStack "IGCM_sys_TestDir" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_TestDir :" $@
+  fi
+  typeset ExistFlag
+  ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
+  IGCM_debug_PopStack "IGCM_sys_TestDir"
+
+  return ${ExistFlag}
+}
+
+#D-#==================================================
+#D-function IGCM_sys_TestDirArchive
+#D-* Purpose: Test Directory that must exists on Archive
+#D-* Examples:
+#D-
+function IGCM_sys_TestDirArchive {
+  IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_TestDirArchive :" $@
+  fi
+  typeset ExistFlag
+  ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
+  IGCM_debug_PopStack "IGCM_sys_TestDirArchive"
+  return ${ExistFlag}
+}
+
+#D-#==================================================
+#D-function IGCM_sys_IsFileArchived
+#D-* Purpose: Test file that must NOT EXISTS on Archive
+#D-* Examples:
+#D-
+function IGCM_sys_IsFileArchived {
+  IGCM_debug_PushStack "IGCM_sys_IsFileArchived" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_IsFileArchived :" $@
+  fi
+  typeset IsArchivedFlag
+  # Never archived for this system
+  IsArchivedFlag=1
+  IGCM_debug_PopStack "IGCM_sys_IsFileArchived"
+
+  return ${IsArchivedFlag}
+}
+
+#D-#==================================================
+#D-function IGCM_sys_TestFileArchive
+#D-* Purpose: Test file that must NOT EXISTS on Archive
+#D-* Examples:
+#D-
+function IGCM_sys_TestFileArchive {
+  IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@
+  typeset ExistFlag
+  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 )
+  IGCM_debug_PopStack "IGCM_sys_TestFileArchive"
+
+  return ${ExistFlag}
+}
+
+#D-#==================================================
+#D-function IGCM_sys_TestFileBuffer
+#D-* Purpose: Test file that must NOT EXISTS on Buffer
+#D-* Examples:
+#D-
+function IGCM_sys_TestFileBuffer {
+  IGCM_debug_PushStack "IGCM_sys_TestFileBuffer" $@
+  typeset ExistFlag
+  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 )
+  IGCM_debug_PopStack "IGCM_sys_TestFileBuffer"
+
+  return ${ExistFlag}
+}
+
+#D-#==================================================
+#D-function IGCM_sys_CountFileArchive
+#D-* Purpose: Count files on Archive filesystem
+#D-* Examples:
+#D-
+function IGCM_sys_CountFileArchive {
+  IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@
+  ls ${@} 2>/dev/null | wc -l
+  if [ $? -gt 0 ] ; then
+    echo "IGCM_sys_CountFileArchive : erreur."
+  fi
+  IGCM_debug_PopStack "IGCM_sys_CountFileArchive"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_CountFileBuffer
+#D-* Purpose: Count files on Scratch filesystem
+#D-* Examples:
+#D-
+function IGCM_sys_CountFileBuffer {
+  IGCM_debug_PushStack "IGCM_sys_CountFileBuffer" $@
+  ls ${@} 2>/dev/null | wc -l
+  if [ $? -gt 0 ] ; then
+    echo "IGCM_sys_CountFileBuffer : erreur."
+  fi
+  IGCM_debug_PopStack "IGCM_sys_CountFileBuffer"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Tree
+#D-* Purpose: Tree directories with files on ${ARCHIVE}
+#D-* Examples: IGCM_sys_Tree ${R_IN} ${R_OUT}
+#D-
+function IGCM_sys_Tree {
+  IGCM_debug_PushStack "IGCM_sys_Tree" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Tree :" $@
+  fi
+
+  \tree -f $@
+
+  IGCM_debug_PopStack "IGCM_sys_Tree"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Tar
+#D-* Purpose: master tar command
+#D-* Examples:
+#D-
+function IGCM_sys_Tar {
+  IGCM_debug_PushStack "IGCM_sys_Tar" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Tar :" $@
+  fi
+  \tar cf $@
+  if [ $? -gt 0 ] ; then
+    echo "IGCM_sys_Tar : erreur."
+    IGCM_debug_Exit "IGCM_sys_Tar"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Tar"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_UnTar
+#D-* Purpose: master un-tar command
+#D-* Examples:
+#D-
+function IGCM_sys_UnTar {
+  IGCM_debug_PushStack "IGCM_sys_UnTar" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_UnTar :" $@
+  fi
+  \tar xvf $1
+  if [ $? -gt 0 ] ; then
+    echo "IGCM_sys_UnTar : erreur."
+    IGCM_debug_Exit "IGCM_sys_UnTar"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_UnTar"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Qsub
+#D-* Purpose: Qsub new job
+#D-* Examples:
+#D-
+function IGCM_sys_Qsub {
+  IGCM_debug_PushStack "IGCM_sys_Qsub" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Qsub :" $@
+  fi
+  echo "${@} > ${SUBMIT_DIR}/${Script_Output} 2>&1 &"
+  ${@} > ${SUBMIT_DIR}/${Script_Output} 2>&1 &
+  if [ $? -gt 0 ] ; then
+    echo "IGCM_sys_Qsub : erreur ${options} $1"
+    IGCM_debug_Exit "IGCM_sys_Qsub"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Qsub"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_QsubPost
+#D-* Purpose: Qsub new job on scalaire
+#D-* Examples:
+#D-
+function IGCM_sys_QsubPost {
+  IGCM_debug_PushStack "IGCM_sys_QsubPost" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_QsubPost :" $@
+  fi
+  echo "${libIGCM_POST}/$1.job > ${POST_DIR}/$1.${PeriodDateEnd}.out 2>&1 &"
+  ${libIGCM_POST}/$1.job > ${POST_DIR}/${Script_Post_Output}.out 2>&1 &
+  if [ $? -gt 0 ] ; then
+    echo "IGCM_sys_QsubPost : erreur " $@
+    IGCM_debug_Exit "IGCM_sys_QsubPost"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_QsubPost"
+}
+
+#D-*************************
+#D- File transfer functions
+#D-*************************
+#D-
+
+#D-#==================================================
+#D-function IGCM_sys_Rsync_out
+#D-* Purpose: treat return val of rsync
+#D-* Examples: IGCM_sys_Rsync_out out_RET_rsync
+#D-  Error values and explanations can depend on your system version.
+function IGCM_sys_Rsync_out {
+  status=$1
+  if [ ! $status ] ; then
+    echo "rsync error !"
+  fi
+
+  if [ $MYLANG = "fr" ]; then
+    case $status in
+    0)  return ;;
+    1)  echo "Erreur de rsync ; RERR_SYNTAX : "
+      echo "Erreur de syntaxe ou d'utilisation."
+      return;;
+    2)  echo "Erreur de rsync ; RERR_PROTOCOL : "
+      echo "Incompatibilité de protocole."
+      return;;
+    3)  echo "Erreur de rsync ; RERR_FILESELECT 3"
+      echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et"
+      echo "répertoires"
+      return;;
+    4)  echo "Erreur de rsync ; RERR_UNSUPPORTED"
+      echo "Action demandée non supportée : une tentative de manipulation de"
+      echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a"
+      echo "été faite ; ou une option qui est supportée par le  client  mais"
+      echo "pas par le serveur a été spécifiée."
+      return;;
+    10) echo "Erreur de rsync ; RERR_SOCKETIO"
+      echo "Erreur dans le socket d'entrée sortie"
+      return;;
+    11) echo "Erreur de rsync ; RERR_FILEIO"
+      echo "Erreur d'entrée sortie fichier"
+      return;;
+    12) echo "Erreur de rsync ; RERR_STREAMIO"
+      echo "Erreur dans flux de donnée du protocole rsync"
+      return;;
+    13) echo "Erreur de rsync ; RERR_MESSAGEIO"
+      echo "Erreur avec les diagnostics du programme"
+      return;;
+    14) echo "Erreur de rsync ; RERR_IPC"
+      echo "Erreur dans le code IPC"
+      return;;
+    20) echo "Erreur de rsync ; RERR_SIGNAL"
+      echo "SIGUSR1 ou SIGINT reçu"
+      return;;
+    21) echo "Erreur de rsync ; RERR_WAITCHILD"
+      echo "Une erreur retournée par waitpid()"
+      return;;
+    22) echo "Erreur de rsync ; RERR_MALLOC"
+      echo "Erreur lors de l'allocation des tampons de mémoire de coeur"
+      return;;
+    23) echo ""
+      echo "Erreur fichier inexistant"
+      return;;
+    30) echo "Erreur de rsync ; RERR_TIMEOUT"
+      echo "Temps d'attente écoulé dans l'envoi/réception de données"
+      return;;
+    *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $status
+      return;;
+    esac
+  elif [ $MYLANG = "en" ] ; then
+    case $status in
+    0)  return;;
+    1)  echo "rsync error : Syntax or usage error "
+      return;;
+    2)  echo "rsync error : Protocol incompatibility "
+      return;;
+    3)  echo "rsync error : Errors selecting input/output files, dirs"
+      return;;
+    4)  echo "rsync error : Requested action not supported: an attempt"
+      echo "was made to manipulate 64-bit files on a platform that cannot support"
+      echo "them; or an option was specified that is supported by the client and"
+      echo "not by the server."
+      return;;
+    5)  echo "rsync error : Error starting client-server protocol"
+      return;;
+    10) echo "rsync error : Error in socket I/O "
+      return;;
+    11) echo "rsync error : Error in file I/O "
+      return;;
+    12) echo "rsync error : Error in rsync protocol data stream "
+      return;;
+    13) echo "rsync error : Errors with program diagnostics "
+      return;;
+    14) echo "rsync error : Error in IPC code "
+      return;;
+    20) echo "rsync error : Received SIGUSR1 or SIGINT "
+      return;;
+    21) echo "rsync error : Some error returned by waitpid() "
+      return;;
+    22) echo "rsync error : Error allocating core memory buffers "
+      return;;
+    23) echo "rsync error : Partial transfer due to error"
+      return;;
+    24) echo "rsync error : Partial transfer due to vanished source files"
+      return;;
+    30) echo "rsync error : Timeout in data send/receive "
+      return;;
+    *)  echo "rsync error : return code of rsync unknown :" $status
+      return;;
+    esac
+  else
+    echo "unknown language $MYLANG."
+    return
+  fi
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Miror_libIGCM
+#D-* Purpose: Mirror libIGCM PATH and lib to frontend
+#D-* Examples:
+#D-
+function IGCM_sys_Mirror_libIGCM {
+  IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM"
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Mirror_libIGCM"
+  fi
+
+  typeset status
+
+  mkdir -p ${HOME}/MIRROR/${PATHlibIGCM}
+
+  echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > /tmp/out_command.$$ 2>&1
+  ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> /tmp/out_command.$$ 2>&1
+  status=$?
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on frontend."
+    cat /tmp/out_command.$$
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Cp
+#D-* Purpose: generic cp
+#D-* Examples:
+#D-
+function IGCM_sys_Cp {
+  IGCM_debug_PushStack "IGCM_sys_Cp" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Cp :" $@
+  fi
+
+  typeset status
+
+  echo cp $@ > /tmp/out_command.$$ 2>&1
+  \cp $@ >> /tmp/out_command.$$ 2>&1
+  status=$?
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_Cp : error code ${status}"
+    cat /tmp/out_command.$$
+    IGCM_debug_Exit "IGCM_sys_Cp"
+  else
+    \rm /tmp/out_command.$$
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Cp"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Rm
+#D-* Purpose: generic rm
+#D-* Examples:
+#D-
+function IGCM_sys_Rm {
+  IGCM_debug_PushStack "IGCM_sys_Rm" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Rm :" $@
+  fi
+
+  typeset status
+
+  echo rm $@ > /tmp/out_command.$$ 2>&1
+  \rm $@ >> /tmp/out_command.$$ 2>&1
+  status=$?
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_Rm : error code ${status}"
+    cat /tmp/out_command.$$
+    IGCM_debug_Exit "IGCM_sys_Rm"
+  else
+    \rm /tmp/out_command.$$
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Rm"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_RmRunDir
+#D-* Purpose: rm tmpdir (dummy function most of the time batch
+#D-                      scheduler will do the job)
+#D-* Examples:
+#D-
+function IGCM_sys_RmRunDir {
+  IGCM_debug_PushStack "IGCM_sys_RmRunDir" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_RmRunDir :" $@
+    echo "Dummy call, let the user do that."
+#    IGCM_sys_Rm -rf ${RUN_DIR}
+  fi
+  IGCM_debug_PopStack "IGCM_sys_RmRunDir"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Mv
+#D-* Purpose: generic move
+#D-* Examples:
+#D-
+function IGCM_sys_Mv {
+  IGCM_debug_PushStack "IGCM_sys_Mv" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Mv :" $@
+  fi
+
+  if [ $DRYRUN = 0 ]; then
+
+    typeset status
+
+    echo mv $@ > /tmp/out_command.$$ 2>&1
+    \mv $@ >> /tmp/out_command.$$ 2>&1
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_Mv : error code ${status}"
+      cat /tmp/out_command.$$
+      IGCM_debug_Exit "IGCM_sys_Mv"
+    else
+      \rm /tmp/out_command.$$
+    fi
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_Mv"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Put_Dir
+#D-* Purpose: Copy a complete directory on $(ARCHIVE)
+#D-* Examples:
+#D-
+function IGCM_sys_Put_Dir {
+  IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Put_Dir :" $@
+  fi
+  if [ $DRYRUN = 0 ]; then
+    if [ ! -d ${1} ] ; then
+      echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ."
+      IGCM_debug_PopStack "IGCM_sys_Put_Dir"
+      return
+    fi
+
+    typeset status
+
+    # Only if we use rsync
+    #IGCM_sys_TestDirArchive $( dirname $2 )
+    #
+    #USUAL WAY
+    \cp -r $1 $2 > /tmp/out_command.$$ 2>&1
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_Put_Dir : cp failed error code ${status}"
+      cat /tmp/out_command.$$
+      IGCM_debug_Exit "IGCM_sys_Put_Dir"
+    else
+      \rm /tmp/out_command.$$
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Put_Dir"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Get_Dir
+#D-* Purpose: Copy a complete directory from ${ARCHIVE}
+#D-* Examples:
+#D-
+function IGCM_sys_Get_Dir {
+  IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Get_Dir :" $@
+  fi
+  if [ $DRYRUN = 0 ]; then
+    if [ ! -d ${1} ] ; then
+      echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ."
+      IGCM_debug_PopStack "IGCM_sys_Get_Dir"
+      return
+    fi
+
+    typeset status
+
+    #USUAL WAY
+    \cp -ur $1 $2 > /tmp/out_command.$$ 2>&1
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_Get_Dir : cp failed error code ${status}"
+      cat /tmp/out_command.$$
+      IGCM_debug_Exit "IGCM_sys_Get_Dir"
+    else
+      \rm /tmp/out_command.$$
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Get_Dir"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Get_Master
+#D-* Purpose: Copy a complete directory from MASTER filesystem
+#D-* Examples:
+#D-
+function IGCM_sys_Get_Master {
+  IGCM_debug_PushStack "IGCM_sys_Get_Master" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Get_Master :" $@
+  fi
+  if [ $DRYRUN = 0 ]; then
+    if ( [ ! -d ${1} ] && [ ! -f ${1} ] ) ; then
+      echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ."
+      IGCM_debug_PopStack "IGCM_sys_Get_Master"
+      return
+    fi
+
+    typeset NB_ESSAI DELAI status i
+    # number of tentative
+    NB_ESSAI=3
+    # time delay between tentative
+    DELAI=2
+
+    i=0
+    while [ $i -lt $NB_ESSAI ] ; do
+      \cp -urL $1 $2 > /tmp/out_command.$$ 2>&1
+      status=$?
+      if [ ${status} -gt 0 ]; then
+        IGCM_debug_Print 2 "IGCM_sys_Get_Master : cp failed error code ${status} ${i}/${NB_ESSAI}"
+        IGCM_debug_Print 2 "IGCM_sys_Get_Master : sleep ${DELAI} seconds and try again."
+        sleep $DELAI
+      else
+        break
+      fi
+      (( i = i + 1 ))
+    done
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_Get_Master : error."
+      cat /tmp/out_command.$$
+      IGCM_debug_Exit "IGCM_sys_Get_Master"
+    else
+      \rm /tmp/out_command.$$
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Get_Master"
+}
+
+#====================================================
+#- Call IGCM_sys_Mirror_libIGCM now !
+if ( $MirrorlibIGCM ) ; then
+  IGCM_sys_Mirror_libIGCM
+fi
+
+#D-#==================================================
+#D-function IGCM_sys_Put_Rest
+#D-* Purpose: Put computied restarts on ${ARCHIVE}.
+#D-           File and target directory must exist.
+#D-* Examples:
+#D-
+function IGCM_sys_Put_Rest {
+  IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Put_Rest :" $@
+  fi
+  if [ $DRYRUN = 0 ]; then
+    if [ ! -f ${1} ] ; then
+      echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ."
+      IGCM_debug_Exit "IGCM_sys_Put_Rest"
+    fi
+
+    typeset status
+    #
+    if [ X${JobType} = XRUN ] ; then
+      IGCM_sys_Chmod 444 ${1}
+    fi
+    #
+    # Only if we use rsync
+    #IGCM_sys_MkdirArchive $( dirname $2 )
+    #
+    #USUAL WAY
+    \cp $1 $2 > /tmp/out_command.$$ 2>&1
+    status=$?
+
+#       #RSYNC WITH NETWORK SSH CALL
+#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > /tmp/out_command.$$ 2>&1
+#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> /tmp/out_command.$$ 2>&1
+
+#       #RSYNC WITH NFS USE
+#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > /tmp/out_command.$$ 2>&1
+#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> /tmp/out_command.$$ 2>&1
+
+#       status=$?
+#       IGCM_sys_Rsync_out $status
+
+#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk /tmp/out_command.$$
+#       (( status=status+$? ))
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_Put_Rest : cp failed error code ${status}"
+      cat /tmp/out_command.$$
+      IGCM_debug_Exit "IGCM_sys_Put_Rest"
+    else
+      \rm /tmp/out_command.$$
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Put_Rest"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_PutBuffer_Rest
+#D-* Purpose: Put computied restarts on ${SCRATCHDIR}.
+#D-           File and target directory must exist.
+#D-* Examples:
+#D-
+function IGCM_sys_PutBuffer_Rest {
+  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Rest" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_PutBuffer_Rest :" $@
+  fi
+  if [ $DRYRUN = 0 ]; then
+    if [ ! -f ${1} ] ; then
+      echo "ERROR : IGCM_sys_PutBuffer_Rest ${1} DOES NOT EXIST ."
+      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest"
+    fi
+
+    typeset status
+    #
+    if [ X${JobType} = XRUN ] ; then
+      IGCM_sys_Chmod 444 ${1}
+    fi
+
+    #
+    # USUAL WAY
+    \cp $1 $2 > /tmp/out_command.$$ 2>&1
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_PutBuffer_Rest : error code ${status}"
+      [ -f ${2} ] && ls -l ${2}
+      [ -f ${2}/${1} ] && ls -l ${2}/${1}
+      cat /tmp/out_command.$$
+      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest"
+    else
+      \rm /tmp/out_command.$$
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Rest"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_PrepareTaredRestart
+#D-* Purpose: Prepare tared restart to be access by computing job. Identity here.
+#D-* Examples:
+#D-
+function IGCM_sys_PrepareTaredRestart {
+  IGCM_debug_PushStack "IGCM_sys_PrepareTaredRestart" $@
+
+  IGCM_debug_PopStack "IGCM_sys_PrepareTaredRestart"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Put_Out
+#D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly
+#D-* Examples:
+#D-
+function IGCM_sys_Put_Out {
+  IGCM_debug_PushStack "IGCM_sys_Put_Out" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Put_Out :" $@
+  fi
+
+  typeset status
+
+  if [ $DRYRUN = 0 ]; then
+    if [ ! -f ${1} ] ; then
+      echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ."
+      IGCM_debug_PopStack "IGCM_sys_Put_Out"
+      return 1
+    fi
+    #
+    IGCM_sys_MkdirArchive $( dirname $2 )
+    #
+    if [ X${JobType} = XRUN ] ; then
+      if [ X${3} = X ] ; then
+        IGCM_sys_Chmod 444 ${1}
+      fi
+    fi
+    #
+
+    echo ${RSYNC} ${RSYNC_opt} $1 $2 > /tmp/out_command.$$ 2>&1
+    ${RSYNC} ${RSYNC_opt} $1 $2 >> /tmp/out_command.$$ 2>&1
+    status=$?
+    IGCM_sys_Rsync_out $status
+
+    ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk /tmp/out_command.$$
+    (( status=status+$? ))
+
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_Put_Out : rsync failed error code ${status}"
+      cat /tmp/out_command.$$
+      IGCM_debug_Exit "IGCM_sys_Put_Out"
+    else
+      \rm /tmp/out_command.$$
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Put_Out"
+  return 0
+}
+
+#D-#==================================================
+#D-function IGCM_sys_PutBuffer_Out
+#D-* Purpose: Copy a file on ${SCRATCHDIR} after having chmod it in readonly
+#D-* Examples:
+#D-
+function IGCM_sys_PutBuffer_Out {
+  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Out" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_PutBuffer_Out :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i exist skip
+
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  if [ $DRYRUN = 0 ]; then
+    if [ ! -f ${1} ] ; then
+      echo "WARNING : IGCM_sys_PutBuffer_Out ${1} DOES NOT EXIST ."
+      IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out"
+      return 1
+    fi
+    #
+    IGCM_sys_Mkdir $( dirname $2 )
+    #
+
+    exist=false
+    skip=false
+    if [ -f $2 ] ; then
+      IGCM_debug_Print 1 "$2 already exist"
+      exist=true
+      if [ "X$( diff $1 $2 )" = X ] ; then
+        IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy"
+        status=0
+        skip=true
+      else
+        IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy"
+        skip=false
+      fi
+    fi
+    #
+    if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then
+      IGCM_sys_Chmod u+w $2
+    fi
+
+    if [ X${skip} = Xfalse ] ; then
+      i=0
+      while [ $i -lt $NB_ESSAI ] ; do
+        # USUAL WAY
+        \cp $1 $2 > /tmp/out_command.$$ 2>&1
+        status=$?
+        if [ ${status} -gt 0 ]; then
+          IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : cp failed error code ${status} ${i}/${NB_ESSAI}"
+          IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : sleep ${DELAI} seconds and try again."
+          [ -f ${2} ] && ls -l ${2}
+          [ -f ${2}/${1} ] && ls -l ${2}/${1}
+          sleep $DELAI
+        else
+          break
+        fi
+        (( i = i + 1 ))
+      done
+    fi
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_PutBuffer_Out : error."
+      [ -f ${2} ] && ls -l ${2}
+      [ -f ${2}/${1} ] && ls -l ${2}/${1}
+      cat /tmp/out_command.$$
+      IGCM_debug_Exit "IGCM_sys_PutBuffer_Out"
+    else
+
+      if [ X${JobType} = XRUN ] ; then
+        if [ X${3} = X ] ; then
+          [ -f ${2} ] && IGCM_sys_Chmod 444 ${2}
+          [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1}
+        fi
+      fi
+
+      \rm /tmp/out_command.$$
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out"
+  return 0
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Get
+#D-* Purpose: Get a file from ${ARCHIVE}
+#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
+#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
+function IGCM_sys_Get {
+  IGCM_debug_PushStack "IGCM_sys_Get" $@
+
+  typeset DEST status dm_liste
+
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Get :" $@
+  fi
+  if [ $DRYRUN -le 2 ]; then
+    if [ X${1} = X'/l' ] ; then
+      eval set +A dm_liste \${${2}}
+    else
+      dm_liste=${1}
+    fi
+    eval DEST=\${${#}}
+
+    # test if the (first) file is present in the old computation :
+    IGCM_sys_TestFileArchive ${dm_liste[0]}
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ."
+      IGCM_debug_Exit "IGCM_sys_Get"
+      return
+    fi
+
+    #USUAL WAY
+    \cp ${dm_liste[*]} ${DEST} > /tmp/out_command.$$ 2>&1
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_Get : cp failed error code ${status}"
+      cat /tmp/out_command.$$
+      IGCM_debug_Exit "IGCM_sys_Get"
+    else
+      \rm /tmp/out_command.$$
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Get"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_GetBuffer
+#D-* Purpose: Get a file from ${SCRATCHDIR}
+#D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX
+#D-            IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/
+function IGCM_sys_GetBuffer {
+  IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@
+
+  typeset DEST buf_liste target file_work
+  typeset NB_ESSAI DELAI status i
+
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_GetBuffer :" $@
+  fi
+
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  if [ $DRYRUN -le 2 ]; then
+    if [ X${1} = X'/l' ] ; then
+      eval set +A buf_liste \${${2}}
+    else
+      eval set +A buf_liste ${1}
+    fi
+    eval DEST=\${${#}}
+
+    #USUAL WAY
+    if [ X${1} = X'/l' ] ; then
+      for target in ${buf_liste[*]} ; do
+        local_file=$( basename ${target} )
+        i=0
+        while [ $i -lt $NB_ESSAI ] ; do
+          \cp ${target} ${DEST}/${local_file} >> /tmp/out_command.$$ 2>&1
+          status=$?
+          if [ ${status} -gt 0 ]; then
+            IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}"
+            IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again."
+            sleep $DELAI
+          else
+            break
+          fi
+          (( i = i + 1 ))
+        done
+        if [ ${status} -gt 0 ] ; then
+          echo "IGCM_sys_Get : error"
+          cat /tmp/out_command.$$
+          \rm /tmp/out_command.$$
+          IGCM_debug_Exit "IGCM_sys_GetBuffer"
+        else
+          \rm /tmp/out_command.$$
+        fi
+      done
+    else
+      i=0
+      while [ $i -lt $NB_ESSAI ] ; do
+        \cp ${buf_liste} ${DEST} >> /tmp/out_command.$$ 2>&1
+        status=$?
+        if [ ${status} -gt 0 ]; then
+          IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}"
+          IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again."
+          sleep $DELAI
+        else
+          break
+        fi
+        (( i = i + 1 ))
+      done
+      if [ ${status} -gt 0 ] ; then
+        echo "IGCM_sys_Get : error"
+        cat /tmp/out_command.$$
+        \rm /tmp/out_command.$$
+        IGCM_debug_Exit "IGCM_sys_GetBuffer"
+      else
+        \rm /tmp/out_command.$$
+      fi
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_GetBuffer"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_GetDate_FichWork
+#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK
+#D-* Examples:
+#D-
+function IGCM_sys_GetDate_FichWork {
+  IGCM_debug_PushStack "IGCM_sys_FichWork" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_GetDate_FichWork :" $@
+  fi
+  typeset dateF
+  set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} )
+  eval ${2}=${dateF[5]}
+
+  # donne la date filesys d'un fichier sur la machine work
+  IGCM_debug_PopStack "IGCM_sys_FichWork"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_GetDate_FichArchive
+#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE
+#D-* Examples:
+#D-
+function IGCM_sys_GetDate_FichArchive {
+  IGCM_debug_PushStack "IGCM_sys_FichArchive" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_GetDate_FichArchive :" $@
+  fi
+  typeset dateF
+  set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} )
+  eval ${2}=${dateF[5]}
+
+  IGCM_debug_PopStack "IGCM_sys_FichArchive"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Dods_Rm
+#D-* Purpose: DO NOTHING ! Put ${ARCHIVE} files on DODS internet protocole.
+#D-* Examples:
+#D-
+function IGCM_sys_Dods_Rm {
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Dods_Rm :" $@
+  fi
+  return 0
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Dods_Cp
+#D-* Purpose: Copy $(ARCHIVE) files on DODS internet protocole.
+#D-* Examples:
+#D-
+function IGCM_sys_Dods_Cp {
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Dods_Cp :" $@
+  fi
+  return 0
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Put_Dods
+#D-* Purpose: Put ${ARCHIVE} files on DODS internet protocole. Dummy function here
+#D-* Examples:
+#D-
+function IGCM_sys_Put_Dods {
+  IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Put_Dods :" $@
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Put_Dods"
+}
+
+##############################################################
+# REBUILD OPERATOR
+
+#D-#==================================================
+#D-function IGCM_sys_rebuild
+#D-* Purpose: rebuild parallel files
+#D-* Examples:
+#D-
+function IGCM_sys_rebuild {
+  IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_rebuild :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i firstArg
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    rebuild -f -o $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_rebuild : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_rebuild : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      firstArg=${1}
+      \rm ${firstArg}
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_rebuild : rebuild error code is ${status}"
+    IGCM_debug_Exit "rebuild"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_rebuild"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_rebuild_station
+#D-* Purpose: rebuild parallel files describing station
+#D-* Examples:
+#D-
+function IGCM_sys_rebuild_station {
+  IGCM_debug_PushStack "IGCM_sys_rebuild_station" -- $@
+  typeset i list_opt file_in file_out prefix_invert list_invert
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_rebuild_station :" $@
+  fi
+  list_opt=$@
+
+  # Invert Axis : t,x -> x,t
+  #               t,pres,x -> x,t,pres
+  # So that we can concatenate along x
+  i=0
+  for file_in in ${list_opt} ; do
+    (( i = i + 1))
+    [ ${i} = 1 ] && file_out=${file_in} && continue
+    prefix_invert=$( basename ${file_in} .nc )
+    IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs ${file_in} ${prefix_invert}_xt.nc
+    list_invert[${#list_invert[*]}]=${prefix_invert}_xt.nc
+  done
+
+  # Concatenate
+  IGCM_sys_ncrcat ${list_invert[*]} histstn_xt.nc
+
+  # Re-ivert file
+  IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x histstn_xt.nc ${file_out}
+
+  # Station re-ordering is too expansive to be run within libIGCM
+  # This is due to (ncpdq - nrcat - ncpdq) I/O sequence.
+  # This re-ordering must be done "in memory" by the cmorization process
+  # Anyway this is the best sequence using (ncpdq - nrcat - ncpdq)
+  # BEGIN reordering
+
+  # Only LMDZ text output contains the exact ordering of the station.
+  # We isolate this in the code below:
+  #  0  38  -157.5000000000000  70.98591549295774
+  #  0  54  27.49999999999999   67.18309859154928
+  #  0  56  -62.50000000000001  82.39436619718309
+  #  0  79  12.49999999999999   78.59154929577466
+  #  0  116 -165.0000000000000  76.05633802816901
+  #  0  117 130.0000000000000   70.98591549295774
+  #  0  118 110.0000000000000   87.46478873239437
+  #  1  40  4.999999999999995   51.97183098591550
+#  typeset iStation iProc list_opt file_in file_out prefix_invert
+#  typeset -Z4 j4
+#  typeset -Z3 j3
+
+#  unset list_opt
+#  set +A list_opt $@
+
+  # Filename after rebuild
+#  file_out=${list_opt[0]}
+  # Prefix of output files
+#  prefix_invert=$( basename ${file_out} .nc )
+  # Number of procs
+#  num_proc=$( grep -i mpi_size ${PREFIX}_${Exe_Output} | wc -l )
+
+#  iProc=0
+#  while [ ${iProc} -lt ${num_proc} ] ; do
+    # Array containing Station as a number
+#    unset proc_stn
+#    set +A proc_stn $( grep "iophy_mpi rank ip lon lat  $iProc" ${PREFIX}_${Exe_Output} | sed -e "s/iophy_mpi rank ip lon lat //g" | gawk ' {print $2}' )
+    # Number of stations produced by processor proc
+#    stationLast=${#proc_stn[*]}
+    # Proc number on 4 digits
+#    j4=${iProc}
+    # Init
+#    iStation=0
+#    while [ ${iStation} -lt ${stationLast} ] ; do
+      # Station number on 3 digits
+#      j3=${proc_stn[${iStation}]}
+      # Extract station
+      # Invert Axis : t,x -> x,t
+      #               t,pres,x -> x,t,pres
+      # So that we can concatenate along x
+#      IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs -d x,$iStation,$iStation ${prefix_invert}_${j4}.nc ${prefix_invert}_stn_${j3}.nc
+#      (( iStation = iStation + 1 ))
+#    done
+#    (( iProc = iProc + 1 ))
+#  done
+
+  # Concatenate all station along x
+#  IGCM_sys_ncrcat ${prefix_invert}_stn_???.nc ${prefix_invert}_xt.nc
+
+  # Re-invert file
+#  IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x ${prefix_invert}_xt.nc ${file_out}
+
+  # END reordering
+
+  IGCM_debug_PopStack "IGCM_sys_rebuild_station"
+}
+
+############################################################
+# Activate Running Environnment Variables
+
+#D-#==================================================
+#D-function IGCM_sys_desactiv_variables
+#D-* Purpose: set environement variables prior to execution
+#D-* Examples:
+#D-
+function IGCM_sys_activ_variables {
+  IGCM_debug_PushStack "IGCM_sys_activ_variables"
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_activ_variables"
+  fi
+
+# --------------------------------------------------------------------
+#D- MPI specifications
+# --------------------------------------------------------------------
+
+# --------------------------------------------------------------------
+#D- Other specifications
+# --------------------------------------------------------------------
+
+  IGCM_debug_PopStack "IGCM_sys_activ_variables"
+}
+
+############################################################
+# Desactivate Running Environnment Variables
+
+#D-#==================================================
+#D-function IGCM_sys_desactiv_variables
+#D-* Purpose: unset environement variables after execution
+#D-* Examples:
+#D-
+function IGCM_sys_desactiv_variables {
+  IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_desactiv_variables"
+  fi
+# --------------------------------------------------------------------
+#D- MPI specifications
+# --------------------------------------------------------------------
+
+# --------------------------------------------------------------------
+#D- Other specifications
+# --------------------------------------------------------------------
+
+  IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
+}
+
+############################################################
+# Build MPI/OMP scripts run file (dummy function)
+
+#D-#==================================================
+#D-function IGCM_sys_build_run_file
+#D-* Purpose: build run file (deprecated)
+#D-* Examples:
+#D-
+function IGCM_sys_build_run_file {
+
+  IGCM_debug_Print 3 " dummy function : IGCM_sys_build_run_file "
+
+}
+
+############################################################
+# Build MPI/OMP scripts
+
+#D-#==================================================
+#D-function IGCM_sys_build_execution_scripts
+#D-* Purpose: build execution scripts to be launch by ${HOST_MPIRUN_COMMAND}
+#D-* Examples:
+#D-
+function IGCM_sys_build_execution_scripts
+{
+  IGCM_debug_PushStack "IGCM_sys_build_execution_scripts" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_build_execution_scripts " $@
+  fi
+  typeset nodes listnodes init_node start_num init_exec comp ExeNameIn ExeNameOut
+  typeset node_num_current node_current comp_proc_mpi_loc comp_proc_omp_loc
+  typeset num_corempi nombre_restant_node nombre_restant_comp
+
+  if [ ! -f ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} ]  ; then
+    IGCM_debug_Exit "IGCM_sys_default build_execution_scripts : Job_${config_UserChoices_JobName} don't exist in SUBMIT_DIR : ${SUBMIT_DIR} "
+  fi
+
+  if ( ${OK_PARA_MPMD} ) ; then
+
+    if [ -f run_file ] ; then
+      IGCM_sys_Rm -f run_file
+    fi
+    touch run_file
+
+    if ( ${OK_PARA_OMP} ) ; then
+
+      #  Hosts treatment
+
+      ${HOST_MPIRUN_COMMAND} hostname | sort | uniq > hosts.tmp
+
+      i=0
+      rm -f hosts
+      IGCM_debug_Print 1 "sys $( hostname ), Hosts avaible :"
+      for nodes in `cat hosts.tmp` ; do
+        host[$i]=$nodes
+        echo "${host[$i]} slots=1 max_slots=1" >> hosts
+        IGCM_debug_Print 1 ${host[$i]}
+        i=$((i+1))
+      done
+      rm -f hosts.tmp
+
+      listnodes=${host[*]}
+
+      EXECUTION="${HOST_MPIRUN_COMMAND} -hostfile hosts"
+
+      # Initialisation
+
+      init_node=y
+      node_num_current=0
+      start_num=0
+      init_exec=n
+
+      # Test : if oasis is there, we put it at the first position
+
+      for comp in ${config_ListOfComponents[*]} ; do
+
+        if [ "X${comp}" = "XCPL" ]  ; then
+
+          eval ExeNameIn=\${config_Executable_${comp}[0]}
+          eval ExeNameOut=\${config_Executable_${comp}[1]}
+
+          echo "#!/bin/ksh" > script_${ExeNameOut}.ksh
+          echo ""  >> script_${ExeNameOut}.ksh
+          #echo "export KMP_STACKSIZE=3g"  >> script_${ExeNameOut}.ksh
+          #echo "export KMP_LIBRARY=turnaround"  >> script_${ExeNameOut}.ksh
+          #echo "export MKL_SERIAL=YES"  >> script_${ExeNameOut}.ksh
+          echo "./${ExeNameOut} > out_${ExeNameOut}.out 2>out_${ExeNameOut}.err"  >> script_${ExeNameOut}.ksh
+          IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh
+
+          init_node=n
+
+          (( nombre_restant_node = NUM_COREPERNODE - 1 ))
+          node_num_current=0
+          node_current=${host[${node_num_current}]}
+
+          EXECUTION="${EXECUTION} -H ${node_current} -np 1 ./script_${ExeNameOut}.ksh"
+
+          init_exec=y
+          start_num=1
+
+        fi
+
+      done
+
+      # Then loop on the components (except for oasis)
+
+      for comp in ${config_ListOfComponents[*]} ; do
+
+        eval ExeNameIn=\${config_Executable_${comp}[0]}
+        eval ExeNameOut=\${config_Executable_${comp}[1]}
+
+        # Only if we really have an executable for the component :
+        if ( [ "X${ExeNameOut}" != X\"\" ] &&  [ "X${comp}" != "XCPL" ] ) ; then
+
+          eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
+          eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
+
+          echo "#!/bin/ksh" > script_${ExeNameOut}.ksh
+          # echo "set -vx" >> script_${ExeNameOut}.ksh
+          echo ""  >> script_${ExeNameOut}.ksh
+          #echo "export KMP_STACKSIZE=3g"  >> script_${ExeNameOut}.ksh
+          #echo "export KMP_LIBRARY=turnaround"  >> script_${ExeNameOut}.ksh
+          #echo "export MKL_SERIAL=YES"  >> script_${ExeNameOut}.ksh
+          echo "OMP_NUM_THREADS=${comp_proc_omp_loc}" >> script_${ExeNameOut}.ksh
+          echo "(( MYMPIRANK = OMPI_COMM_WORLD_RANK - ${start_num})) " >>  script_${ExeNameOut}.ksh
+          echo "./${ExeNameOut} > out_${ExeNameOut}.out.\${MYMPIRANK} 2>out_${ExeNameOut}.err.\${MYMPIRANK}"  >> script_${ExeNameOut}.ksh
+          IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh
+
+          node_num=0
+
+          # We define the number of MPI process to be assigned for the component
+
+          nombre_restant_comp=${comp_proc_mpi_loc}
+
+          # Loop on the allocated nodes
+
+          for node in ${listnodes} ; do
+
+            # We go to the current node
+            if [ ${node_num} = ${node_num_current} ] ; then
+
+              node_current=${host[${node_num_current}]}
+
+              # If first time on the node : initialisation
+
+              if [ ${init_node} = y ] ; then
+                nombre_restant_node=${NUM_COREPERNODE}
+              fi
+
+              # Test on the number of OMP threads
+
+              if [ ${comp_proc_omp_loc} -gt ${nombre_restant_node} ] ; then
+                (( node_num = node_num + 1 ))
+                node_num_current=${node_num}
+                init_node=y
+                continue
+              fi
+
+              # Number of MPI process to assign
+
+              (( num_corempi = nombre_restant_node / comp_proc_omp_loc ))
+
+              if [ ${num_corempi} -gt ${nombre_restant_comp} ] ; then
+                num_corempi=${nombre_restant_comp}
+              fi
+
+              (( nombre_restant_node = nombre_restant_node - num_corempi * comp_proc_omp_loc ))
+              (( nombre_restant_comp = nombre_restant_comp - num_corempi ))
+
+              if [ ${init_exec} = y ] ; then
+                EXECUTION="${EXECUTION} : -H ${node_current} -np ${num_corempi} ./script_${ExeNameOut}.ksh"
+              else
+                EXECUTION="${EXECUTION} -H ${node_current} -np ${num_corempi} ./script_${ExeNameOut}.ksh"
+                init_exec=y
+              fi
+
+              ((  start_num = num_corempi + start_num ))
+
+            else
+
+              (( node_num = node_num + 1 ))
+              continue
+            fi
+
+            # Test on the number of core/process remaining on the node/component
+
+            if [ ${nombre_restant_node} = 0 ] ; then
+              (( node_num = node_num + 1 ))
+              node_num_current=${node_num}
+              init_node=y
+
+              if [ ${nombre_restant_comp} = 0 ] ; then
+                break 1
+              fi
+            else
+
+              node_num_current=${node_num}
+              init_node=n
+
+              if [ ${nombre_restant_comp} = 0 ] ; then
+                break 1
+              fi
+            fi
+          done
+        fi
+      done
+
+    else
+
+      # Then first loop on the components for the coupler ie oasis
+
+      ## the coupler ie oasis must be the first one
+      for comp in ${config_ListOfComponents[*]} ; do
+
+        eval ExeNameOut=\${config_Executable_${comp}[1]}
+
+        # for CPL component only
+        if [ "X${comp}" = "XCPL" ] ; then
+          eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
+          echo "-np ${comp_proc_mpi_loc} ./${ExeNameOut} " >> run_file
+        fi
+      done
+
+      # Then second loop on the components
+
+      for comp in ${config_ListOfComponents[*]} ; do
+
+        eval ExeNameOut=\${config_Executable_${comp}[1]}
+
+        # Only if we really have an executable for the component and not the coupler ie oasis:
+        if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${comp}" != "XCPL" ] ) ; then
+          eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
+          echo "-np ${comp_proc_mpi_loc} ./${ExeNameOut}" >> run_file
+        fi
+      done
+      IGCM_sys_Chmod u+x run_file
+
+      EXECUTION="${HOST_MPIRUN_COMMAND} --app ./run_file"
+
+    fi
+
+  else # Only one executable. launch it.
+
+    for comp in ${config_ListOfComponents[*]} ; do
+
+      # Only if we really have an executable for the component :
+      eval ExeNameOut=\${config_Executable_${comp}[1]}
+      if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${ExeNameOut}" != "Xinca.dat" ] ) ; then
+
+        echo "#!/bin/ksh" > script_${ExeNameOut}.ksh
+        echo ""  >> script_${ExeNameOut}.ksh
+        if ( ${OK_PARA_OMP} ) ; then
+          eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
+          echo "OMP_NUM_THREADS=${comp_proc_omp_loc}" >> script_${ExeNameOut}.ksh
+        fi
+        if  ( ${OK_PARA_MPI} ) ; then
+          # Default : mpirun used if nb_proc gt 1
+          # pour sortie out/err par process
+          # echo "./${ExeNameOut} > out_${ExeNameOut}.out.\${OMPI_COMM_WORLD_RANK} 2>out_${ExeNameOut}.err.\${OMPI_COMM_WORLD_RANK}"  >> script_${ExeNameOut}.ksh
+          echo "./${ExeNameOut}" >> script_${ExeNameOut}.ksh
+          IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh
+          EXECUTION="${HOST_MPIRUN_COMMAND} ./script_${ExeNameOut}.ksh"
+        else
+          # Default : mpirun is NOT used if nb_proc eq 1
+          # pour sortie out/err par process
+          # echo "./${ExeNameOut} > out_${ExeNameOut}.out 2>out_${ExeNameOut}.err" >> script_${ExeNameOut}.ksh
+          echo "./${ExeNameOut}" >> script_${ExeNameOut}.ksh
+          IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh
+          EXECUTION="time ./script_${ExeNameOut}.ksh"
+        fi
+      fi
+    done
+
+  fi
+
+  IGCM_debug_Print 1 "sys $( hostname ) : execution command is"
+  IGCM_debug_Print 1 "$EXECUTION"
+
+  IGCM_debug_PopStack "IGCM_sys_build_execution_scripts"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_check_path
+#D-* Purpose: check that RUN_DIR_PATH that will be removed on some machine
+#D-* do not point to an important use directory. Stop immediately in that case.
+#D-* Examples:
+#D-
+function IGCM_sys_check_path {
+  IGCM_debug_PushStack "IGCM_sys_check_path"
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_check_path"
+  fi
+
+  if ( [ X${RUN_DIR_PATH} = X${HOME} ] || [ X${RUN_DIR_PATH} = X${ARCHIVE} ] ) ; then
+    IGCM_debug_Print 1 "Variable RUN_DIR_PATH is pointing to an important directory : ${RUN_DIR_PATH}"
+    IGCM_debug_Print 1 "Please check the RUN_DIR_PATH definition in your Job : Job_${config_UserChoices_JobName}"
+    IGCM_debug_Exit "This will stop the job"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_check_path"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_check_quota. Dummy call here
+#D-* Purpose: check user quota. Stop the simulation if quota above 90%
+#D-* Examples:
+#D-
+function IGCM_sys_check_quota {
+  IGCM_debug_PushStack "IGCM_sys_check_quota"
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_check_quota"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_check_quota"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_CountJobInQueue
+#D-* Purpose: Check if job_name is currently
+#D-  running or in queue
+#D-* Examples: IGCM_sys_CountJobInQueue ${JobName} NbRun
+#D-
+function IGCM_sys_CountJobInQueue {
+  IGCM_debug_PushStack "IGCM_sys_CountJobInQueue"
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_CountJobInQueue"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_CountJobInQueue"
+}
+
+##############################################################
+# NCO OPERATOR
+
+#D-#==================================================
+#D-function IGCM_sys_ncap2
+#D-* Purpose: encapsulate ncap2 call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncap2 {
+  IGCM_debug_PushStack "IGCM_sys_ncap2" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncap2 :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncap2 "$@" > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncap2 : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncap2 : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncap2 : ncap2 error"
+    IGCM_debug_Exit "ncap2"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncap2"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncatted
+#D-* Purpose: encapsulate ncatted call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncatted {
+  IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncatted :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncatted "$@" > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncatted : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncatted : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncatted : ncatted error"
+    IGCM_debug_Exit "ncatted"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncatted"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncbo
+#D-* Purpose: encapsulate ncbo call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncbo {
+  IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncbo :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncbo $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncbo : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncbo : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncbo : ncbo error"
+    IGCM_debug_Exit "ncbo"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncbo"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncdif
+#D-* Purpose: encapsulate ncdiff call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncdiff {
+  IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncdiff :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncdiff $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncdiff : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncdiff : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncdiff : ncdiff error"
+    IGCM_debug_Exit "ncdiff"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncdiff"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncea
+#D-* Purpose: encapsulate ncea call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncea {
+  IGCM_debug_PushStack "IGCM_sys_ncea" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncea :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncea $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncea : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncea : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncea : ncea error"
+    IGCM_debug_Exit "ncea"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncea"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncecat
+#D-* Purpose: encapsulate ncecat call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncecat {
+  IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncecat :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncecat $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncecat : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncecat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncecat : ncecat error"
+    IGCM_debug_Exit "ncecat"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncecat"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncflint
+#D-* Purpose: encapsulate ncflint call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncflint {
+  IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncflint :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncflint $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncflint : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncflint : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncflint : ncflint error"
+    IGCM_debug_Exit "ncflint"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncflint"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncks
+#D-* Purpose: encapsulate ncks call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncks {
+  IGCM_debug_PushStack "IGCM_sys_ncks" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncks :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncks $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncks : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncks : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncks : ncks error"
+    IGCM_debug_Exit "ncks"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncks"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncpdq
+#D-* Purpose: encapsulate ncpdq call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncpdq {
+  IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncpdq :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncpdq $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncpdq : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncpdq : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncpdq : ncpdq error"
+    IGCM_debug_Exit "ncpdq"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncpdq"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncra
+#D-* Purpose: encapsulate ncra call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncra {
+  IGCM_debug_PushStack "IGCM_sys_ncra" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncra :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncra $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncra : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncra : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncra : ncra error"
+    IGCM_debug_Exit "ncra"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncra"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncrcat
+#D-* Purpose: encapsulate ncrcat call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncrcat {
+  IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncrcat :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i lastArg
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncrcat $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncrcat : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    elif [ ! "X$( grep "WARNING Intra-file non-monotonicity" /tmp/out_command.$$ )" = "X" ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncrcat : WARNING Intra-file non-monotonicity"
+      cat /tmp/out_command.$$
+      # remove files having corrupted time axis
+      eval lastArg=\${$#}
+      IGCM_debug_Print 2 "IGCM_sys_ncrcat : Delete ${lastArg}"
+      \rm ${lastArg}
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncrcat : ncrcat error"
+    #IGCM_debug_Exit "ncrcat"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncrcat"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncrename
+#D-* Purpose: encapsulate ncrename call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncrename {
+  IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncrename :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncrename $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncrename : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncrename : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncrename : ncrename error"
+    IGCM_debug_Exit "ncrename"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncrename"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncwa
+#D-* Purpose: encapsulate ncwa call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncwa {
+  IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncwa :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncwa $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncwa : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncwa : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncwa : ncwa error"
+    IGCM_debug_Exit "ncwa"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncwa"
+}
+
+##############################################################
+# CDO OPERATOR
+
+#D-#==================================================
+#D-function IGCM_sys_cdo
+#D-* Purpose: encapsulate cdo call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_cdo {
+  IGCM_debug_PushStack "IGCM_sys_cdo" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_cdo :" $@
+  fi
+
+  typeset status
+
+  \cdo $@ > /tmp/out_command.$$ 2>&1
+  status=$?
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_cdo : error code ${status}"
+    cat /tmp/out_command.$$
+    \rm /tmp/out_command.$$
+    IGCM_debug_PopStack "IGCM_sys_cdo"
+    return 1
+  else
+    IGCM_debug_PopStack "IGCM_sys_cdo"
+    return 0
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_cdo"
+}
Index: /tags/libIGCM_v2.2/libIGCM_sys/libIGCM_sys_iitm.ksh
===================================================================
--- /tags/libIGCM_v2.2/libIGCM_sys/libIGCM_sys_iitm.ksh	(revision 998)
+++ /tags/libIGCM_v2.2/libIGCM_sys/libIGCM_sys_iitm.ksh	(revision 998)
@@ -0,0 +1,2457 @@
+#!/bin/ksh
+
+#**************************************************************
+# Author: Sébastien Denvil
+# Contact: Sebastien.Denvil__at__ipsl.jussieu.fr
+# $Revision:: 423                                      $ Revision of last commit
+# $Author:: sdipsl                                     $ Author of last commit
+# $Date:: 2011-02-18 16:49:14 +0100 (ven. 18 fÃ©vr. 20#$ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#=========================================================
+# The documentation of this file can be automatically generated
+# if you use the prefix #D- for comments to be extracted.
+# Extract with command: cat lib* | grep "^#D-" | cut -c "4-"
+#=========================================================
+
+#D-#==================================================
+#D-LibIGCM_sys for IITM IBM machine
+#D-#==================================================
+#D-
+#D- This ksh library if a layer under some usefull
+#D-environment variables and shell commands.
+#D-All those definitions depend on host particularities.
+#D-It manages a stack mechanism and test validity of operations.
+#D-All function described bellow must be prefixed by IGCM_sys.
+
+#====================================================
+# libIGCM_sys PARAMETERS
+#====================================================
+
+#====================================================
+# set DEBUG_sys to true to output calls of function
+typeset -r DEBUG_sys=${DEBUG_sys:=true}
+
+#====================================================
+# Turn in dry run mode ? (sys_Put_Rest, sys_Put_Out, sys_Get)
+typeset -r DRYRUN=${DRYRUN:=0}
+
+# YOU MUST COMPILE YOUR EXE FILES FOR DRYRUN MODE !
+# -------------------------------------------------------------------------------------
+# | DRYRUN=  |  Date computations, | sys_Get    |  Exe    | sys_Put_Out; sys_Put_Rest |
+# |          |  Cp/Exe/param/files |            |         |                           |
+# |          |  Chmod Qsub         |            |         |                           |
+# -------------------------------------------------------------------------------------
+# |    0     |       yes           |    yes     |  yes    |      yes                  |
+# -------------------------------------------------------------------------------------
+# |    1     |       yes           |    yes     |  yes    |      no                   |
+# -------------------------------------------------------------------------------------
+# |    2     |       yes           |    yes     |  no     |      no                   |
+# -------------------------------------------------------------------------------------
+# |    3     |       yes           |    no      |  no     |      no                   |
+# -------------------------------------------------------------------------------------
+
+#=====================================================
+# Global Variables :
+#=====================================================
+# Language : "fr" or "en"
+typeset -r MYLANG="fr"
+
+#=====================================================
+# Host and user names
+# $hostname ou hostname
+typeset  HOST=${HOST:=$( hostname )}
+# $username ou whoami
+typeset  LOGIN=${LOGIN:=$( whoami )}
+# $hostname of the MASTER job
+ntypeset -r MASTER=iitm01
+
+#D-
+#D-#==================================================
+#D-Program used in libIGCM
+#D-#==================================================
+
+# Submit command
+typeset SUBMIT=${SUBMIT:=/usr/lpp/LoadL/full/bin/llsubmit}
+# rsync with path
+typeset -r RSYNC=/usr/bin/rsync
+# RSYNC_opt args to rsync
+typeset -r RSYNC_opt="-va"
+# ie storage filesystem
+typeset -r STOREHOST=iitm01
+typeset -r REMOTE_RSYNC=/usr/bin/rsync
+
+#====================================================
+# Source default environment
+#====================================================
+##. /etc/profile
+
+#====================================================
+# Set environment tools (ferret, nco, cdo)
+#====================================================
+# Not applicable here
+
+#====================================================
+# Host specific DIRECTORIES
+#====================================================
+
+#====================================================
+#- Mirror libIGCM from iitm to a post-processing machine
+typeset -r MirrorlibIGCM=${MirrorlibIGCM:=false}
+
+#====================================================
+#- libIGCM_POST for frontend
+typeset -r libIGCM_POST=${libIGCM}
+
+#====================================================
+#- R_EXE   (==> BIN_DIR = ${MODIPSL}/bin )
+typeset -r R_EXE="${MODIPSL}/bin"
+
+#====================================================
+#- SUBMIT_DIR : submission dir
+typeset SUBMIT_DIR=${SUBMIT_DIR:=${LOADL_STEP_INITDIR}}
+
+#====================================================
+#- IN
+typeset -r R_IN=${R_IN:=/gpfs1/home/sabin}
+typeset -r R_IN_ECMWF=${R_IN_ECMWF:=/gpfs1/home/sabin}
+
+#====================================================
+#- ARCHIVE
+typeset ARCHIVE=$( echo ${HOME} | sed -e "s/gpfs1/gpfs3/" )
+
+#====================================================
+#- STORAGE (dedicated to small/medium files)
+typeset STORAGE=${ARCHIVE}
+
+#====================================================
+#- R_OUT
+typeset R_OUT=${ARCHIVE}/IGCM_OUT
+
+#====================================================
+#- R_FIG (hosting figures : monitoring and atlas, and/or small files)
+typeset R_FIG=${WORKDIR}/IGCM_OUT
+
+#====================================================
+#- R_BUF (ONLY FOR double copy an scratch)
+typeset -r R_BUF=${WORKDIR}/IGCM_OUT
+
+#====================================================
+#- RUN_DIR_PATH : Temporary working directory (=> TMP)
+typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=${ARCHIVE}/RUN/${LOADL_STEP_ID}}
+
+#====================================================
+#- HOST_MPIRUN_COMMAND
+typeset -r HOST_MPIRUN_COMMAND=${HOST_MPIRUN_COMMAND:="/usr/bin/time poe"}
+
+#====================================================
+#- Max number of arguments passed to nco operator or demigration command
+UNIX_MAX_LIMIT=360
+
+#====================================================
+#- set PackDefault true on curie
+PackDefault=false
+
+#====================================================
+#- Number of core per node (max number of OpenMP task)
+NUM_COREPERNODE=2
+
+#====================================================
+#- Default number of MPI task for IPSL coupled model
+#- required for backward compatibility
+#-
+DEFAULT_NUM_PROC_OCE=5
+DEFAULT_NUM_PROC_CPL=1
+(( DEFAULT_NUM_PROC_ATM = BATCH_NUM_PROC_TOT - DEFAULT_NUM_PROC_OCE - DEFAULT_NUM_PROC_CPL ))
+DEFAULT_NUM_PROC_TOTAL=${BATCH_NUM_PROC_TOT}
+
+#D-#==================================================
+#D-function IGCM_sys_ChangeArchive
+#D-* Purpose: Just a dummy call on this machine
+#D-* Examples:
+#D-
+function IGCM_sys_ChangeArchive {
+  IGCM_debug_Print 1 " dummy function : IGCM_sys_ChangeArchive "
+}
+
+#D-#==================================================
+#D-function IGCM_sys_RshMaster
+#D-* Purpose: Just a fake command to wrapp
+#D-           IGCM_card call in post-treatment
+#D-           Ulam do not see brodie filesystem
+#D-           Cesium do not see all mercure filesystem
+#D-           That's why we need this hack.
+#D-* Examples:
+#D-
+function IGCM_sys_RshMaster {
+  IGCM_debug_PushStack "IGCM_sys_RshMaster" $@
+  /bin/ksh <<-EOF
+    export libIGCM=${libIGCM}
+    export DEBUG_debug=${DEBUG_debug}
+    . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
+    . ${libIGCM}/libIGCM_card/libIGCM_card.ksh
+    ${@}
+EOF
+  if [ $? -gt 0 ] ; then
+    echo "IGCM_sys_RshMaster : erreur."
+    IGCM_debug_Exit "IGCM_sys_RshMaster"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_RshMaster"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_RshArchive
+#D-* Purpose: Archive rsh command
+#D-* Examples:
+#D-
+function IGCM_sys_RshArchive {
+  IGCM_debug_PushStack "IGCM_sys_RshArchive" $@
+  /bin/ksh <<-EOF
+    ${@}
+EOF
+  status=$?
+  if [ ${status} -gt 0 ] ; then
+    IGCM_debug_Print 2 "IGCM_sys_RshArchive : command failed error code ${status}"
+    IGCM_debug_Exit "IGCM_sys_RshArchive"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_RshArchive"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_RshPost
+#D-* Purpose: Post-process rsh command
+#D-* Examples:
+#D-
+function IGCM_sys_RshPost {
+  IGCM_debug_PushStack "IGCM_sys_RshPost" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_RshPost :" $@
+  fi
+
+  # keep standard input to keep it for postpone if ulam don't answer
+  cat >/tmp/tmp_IGCM_sys_RshPost_$$_${LOGNAME}
+
+  /bin/ksh </tmp/tmp_IGCM_sys_RshPost_$$_${LOGNAME}
+  if [ $? -gt 0 ] ; then
+    echo "IGCM_sys_RshPost : erreur."
+    IGCM_debug_Exit "IGCM_sys_RshPost"
+  fi
+  # delete temporary file
+  \rm /tmp/tmp_IGCM_sys_RshPost_$$_${LOGNAME}
+
+  IGCM_debug_PopStack "IGCM_sys_RshPost"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_SendMail
+#D-* Purpose: Send mail when simulation is over
+#D-* Examples:
+#D-
+function IGCM_sys_SendMail {
+  IGCM_debug_PushStack "IGCM_sys_SendMail" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_SendMail :" $@
+  fi
+
+  if [ X${1} = XAccounting ] ; then
+    status=Accounting
+    mailText=jobAccounting.mail
+  elif ( ${ExitFlag} ) ; then
+    status=failed
+    mailText=jobEnd.mail
+  else
+    status=completed
+    mailText=jobEnd.mail
+  fi
+
+  # Update selected mail template
+  while read -r line; do
+    eval echo $line >> mail.txt ;
+  done < ${libIGCM}/libIGCM_sys/${mailText}
+
+  if [ ! -z ${config_UserChoices_MailName} ] ; then
+    mailx -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} < mail.txt
+  elif [ -f ~/.forward ] ; then
+    mailx -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < mail.txt
+  else
+    mailx -s "${config_UserChoices_JobName} ${status}" ${USER} < mail.txt
+  fi
+
+  sleep 10
+  rm -f mail.txt
+
+  IGCM_debug_PopStack "IGCM_sys_SendMail"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Mkdir
+#D-* Purpose: Master locale mkdir command
+#D-* Examples:
+#D-
+function IGCM_sys_Mkdir {
+  IGCM_debug_PushStack "IGCM_sys_Mkdir" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Mkdir :" $@
+  fi
+  if [ ! -d ${1} ]; then
+    \mkdir -p $1
+    if [ $? -gt 0 ] ; then
+      echo "IGCM_sys_Mkdir : erreur."
+      IGCM_debug_Exit "IGCM_sys_Mkdir"
+    fi
+  fi
+  # vérification :
+  if [ ! -d ${1} ] ; then
+    echo "IGCM_sys_Mkdir : erreur."
+    IGCM_debug_Exit "IGCM_sys_Mkdir"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Mkdir"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_MkdirArchive
+#D-* Purpose: Mkdir on Archive
+#D-* Examples:
+#D-
+function IGCM_sys_MkdirArchive {
+  IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_MkdirArchive :" $@
+  fi
+  #- creation de repertoire sur le serveur fichier
+  mkdir -p $1
+  status=$?
+
+  if [ ${status} -gt 0 ] ; then
+    IGCM_debug_Print 2 "IGCM_sys_MkdirArchive : mkdir failed error code ${status}"
+    IGCM_debug_Exit "IGCM_sys_MkdirArchive"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_MkdirArchive"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_MkdirWork
+#D-* Purpose: Mkdir on Work
+#D-* Examples:
+#D-
+function IGCM_sys_MkdirWork {
+  IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_MkdirWork :" $@
+  fi
+  #- creation de repertoire sur le serveur fichier
+  if [ ! -d ${1} ]; then
+    \mkdir -p $1
+    if [ $? -gt 0 ] ; then
+      echo "IGCM_sys_MkdirWork : erreur."
+      IGCM_debug_Exit "IGCM_sys_MkdirWork"
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_MkdirWork"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Cd
+#D-* Purpose: master cd command
+#D-* Examples:
+#D-
+function IGCM_sys_Cd {
+  IGCM_debug_PushStack "IGCM_sys_Cd" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Cd :" $@
+  fi
+  \cd $1
+  if [ $? -gt 0 ] ; then
+    echo "IGCM_sys_Cd : erreur."
+    IGCM_debug_Exit "IGCM_sys_Cd"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Cd"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Chmod
+#D-* Purpose: Chmod
+#D-* Examples:
+#D-
+function IGCM_sys_Chmod {
+  IGCM_debug_PushStack "IGCM_sys_Chmod" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Chmod :" $@
+  fi
+  \chmod $@
+  if [ $? -gt 0 ] ; then
+    echo "IGCM_sys_Chmod : erreur."
+    IGCM_debug_Exit "IGCM_sys_Chmod"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Chmod"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_FileSize
+#D-* Purpose: Filesize
+#D-* Examples:
+#D-
+function IGCM_sys_FileSize {
+  IGCM_debug_PushStack "IGCM_sys_FileSize" $@
+
+  typeset sizeF
+  set +A sizeF -- $( ls -la ${1} )
+  if [ $? -gt 0 ] ; then
+    IGCM_debug_Exit "IGCM_sys_FileSize"
+  fi
+  eval ${2}=${sizeF[4]}
+
+  IGCM_debug_PopStack "IGCM_sys_FileSize"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_TestDir
+#D-* Purpose: Test Directory that must exists
+#D-* Examples:
+#D-
+function IGCM_sys_TestDir {
+  IGCM_debug_PushStack "IGCM_sys_TestDir" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_TestDir :" $@
+  fi
+  typeset ExistFlag
+  ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
+  IGCM_debug_PopStack "IGCM_sys_TestDir"
+
+  return ${ExistFlag}
+}
+
+#D-#==================================================
+#D-function IGCM_sys_TestDirArchive
+#D-* Purpose: Test Directory that must exists on Archive
+#D-* Examples:
+#D-
+function IGCM_sys_TestDirArchive {
+  IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_TestDirArchive :" $@
+  fi
+  typeset ExistFlag
+  ExistFlag=$( IGCM_sys_RshArchive "[ -d $1 ] && echo 0 || echo 1" )
+  IGCM_debug_PopStack "IGCM_sys_TestDirArchive"
+  return ${ExistFlag}
+}
+
+#D-#==================================================
+#D-function IGCM_sys_IsFileArchived
+#D-* Purpose: Test file that must NOT EXISTS on Archive
+#D-* Examples:
+#D-
+function IGCM_sys_IsFileArchived {
+  IGCM_debug_PushStack "IGCM_sys_IsFileArchived" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_IsFileArchived :" $@
+  fi
+  typeset IsArchivedFlag
+  IsArchivedFlag=$( [ "X$( echo $@ | grep \/gpfs3 )" != "X" ] && echo 0 || echo 1 )
+  IGCM_debug_PopStack "IGCM_sys_IsFileArchived"
+
+  return ${IsArchivedFlag}
+}
+
+#D-#==================================================
+#D-function IGCM_sys_TestFileArchive
+#D-* Purpose: Test file that must NOT EXISTS on Archive
+#D-* Examples:
+#D-
+function IGCM_sys_TestFileArchive {
+  IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@
+  typeset ExistFlag
+  ExistFlag=$( IGCM_sys_RshArchive "[ -f $1 ] && echo 0 || echo 1" )
+  IGCM_debug_PopStack "IGCM_sys_TestFileArchive"
+
+  return ${ExistFlag}
+}
+
+#D-#==================================================
+#D-function IGCM_sys_TestFileBuffer
+#D-* Purpose: Test file that must NOT EXISTS on Buffer
+#D-* Examples:
+#D-
+function IGCM_sys_TestFileBuffer {
+  IGCM_debug_PushStack "IGCM_sys_TestFileBuffer" $@
+  typeset ExistFlag
+  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 )
+  IGCM_debug_PopStack "IGCM_sys_TestFileBuffer"
+
+  return ${ExistFlag}
+}
+
+#D-#==================================================
+#D-function IGCM_sys_CountFileArchive
+#D-* Purpose: Count files on Archive filesystem
+#D-* Examples:
+#D-
+function IGCM_sys_CountFileArchive {
+  IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@
+  #Command depends on targeted file system
+  DEBUG_sys=false IGCM_sys_IsFileArchived $1
+  if [ $? = 0 ] ; then
+    IGCM_sys_RshArchive "ls ${@} 2>/dev/null | wc -l"
+    status=$?
+  else
+    ls ${@} 2>/dev/null | wc -l
+    status=$?
+  fi
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_CountFileArchive : erreur."
+  fi
+  IGCM_debug_PopStack "IGCM_sys_CountFileArchive"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_CountFileBuffer
+#D-* Purpose: Count files on Scratch filesystem
+#D-* Examples:
+#D-
+function IGCM_sys_CountFileBuffer {
+  IGCM_debug_PushStack "IGCM_sys_CountFileBuffer" $@
+  ls ${@} 2>/dev/null | wc -l
+  if [ $? -gt 0 ] ; then
+    echo "IGCM_sys_CountFileBuffer : erreur."
+  fi
+  IGCM_debug_PopStack "IGCM_sys_CountFileBuffer"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Tree
+#D-* Purpose: Tree directories with files on ${ARCHIVE}
+#D-* Examples: IGCM_sys_Tree ${R_IN} ${R_OUT}
+#D-
+function IGCM_sys_Tree {
+  IGCM_debug_PushStack "IGCM_sys_Tree" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Tree :" $@
+  fi
+
+  \tree -f $@
+
+  IGCM_debug_PopStack "IGCM_sys_Tree"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Tar
+#D-* Purpose: master tar command
+#D-* Examples:
+#D-
+function IGCM_sys_Tar {
+  IGCM_debug_PushStack "IGCM_sys_Tar" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Tar :" $@
+  fi
+  \tar cf $@
+  if [ $? -gt 0 ] ; then
+    echo "IGCM_sys_Tar : erreur."
+    IGCM_debug_Exit "IGCM_sys_Tar"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Tar"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_UnTar
+#D-* Purpose: master un-tar command
+#D-* Examples:
+#D-
+function IGCM_sys_UnTar {
+  IGCM_debug_PushStack "IGCM_sys_UnTar" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_UnTar :" $@
+  fi
+  \tar xvf $1
+  if [ $? -gt 0 ] ; then
+    echo "IGCM_sys_UnTar : erreur."
+    IGCM_debug_Exit "IGCM_sys_UnTar"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_UnTar"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Qsub
+#D-* Purpose: Qsub new job
+#D-* Examples:
+#D-
+function IGCM_sys_Qsub {
+  IGCM_debug_PushStack "IGCM_sys_Qsub" $@
+
+  typeset status
+
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Qsub :" $@
+  fi
+  # We have to change output/error file
+  [ ${#@} = 1 ] &&  REP_FOR_JOB=${SUBMIT_DIR}
+  [ ${#@} = 2 ] &&  REP_FOR_JOB=${2}
+  sed -e "s:\# \@ output *= .*:\# \@ output = ${Script_Output}:" \
+    -e "s:\# \@ error *= .*:\# \@ error = ${Script_Output}:"   \
+    $1 > ${REP_FOR_JOB}/JOB_FOR_IGCM
+  cd $REP_FOR_JOB ; /usr/lpp/LoadL/full/bin/llsubmit JOB_FOR_IGCM > /tmp/out_command.$$ 2>&1 ; status=$? ; cd - ;
+
+  cat /tmp/out_command.$$
+  if [ ${status} -gt 0 ] ; then
+    IGCM_debug_Print 2 "IGCM_sys_Qsub $1 : error code ${status}"
+    IGCM_debug_Exit "IGCM_sys_Qsub"
+  else
+    JobID=$( gawk {'print $4'} /tmp/out_command.$$ | tail -1 | sed -e s/\"//g )
+    IGCM_sys_Rm ${REP_FOR_JOB}/JOB_FOR_IGCM
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Qsub"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_QsubPost
+#D-* Purpose: Qsub new job on scalaire
+#D-* Examples:
+#D-
+function IGCM_sys_QsubPost {
+  IGCM_debug_PushStack "IGCM_sys_QsubPost" $@
+
+  typeset status
+
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_QsubPost :" $@
+  fi
+  # We have to change output/error file
+  [ ${#@} = 1 ] &&  REP_FOR_JOB=${POST_DIR}
+  [ ${#@} = 2 ] &&  REP_FOR_JOB=${2}
+
+  sed -e "s:\# \@ output *= .*:\# \@ output = ${Script_Post_Output}.out:" \
+    -e "s:\# \@ error *= .*:\# \@ error = ${Script_Post_Output}.out:"   \
+    ${libIGCM_POST}/$1.job > ${REP_FOR_JOB}/JOB_FOR_IGCM
+
+  cd $REP_FOR_JOB ; /usr/lpp/LoadL/full/bin/llsubmit JOB_FOR_IGCM > /tmp/out_command.$$ 2>&1 ; status=$? ; cd - ;
+
+  cat /tmp/out_command.$$
+  if [ ${status} -gt 0 ] ; then
+    IGCM_debug_Print 2 "IGCM_sys_QsubPost $1 : error code ${status}"
+    IGCM_debug_Exit "IGCM_sys_QsubPost"
+  else
+    JobID=$( gawk {'print $4'} /tmp/out_command.$$ | tail -1 | sed -e s/\"//g )
+    IGCM_sys_Rm ${REP_FOR_JOB}/JOB_FOR_IGCM
+  fi
+  IGCM_debug_PopStack "IGCM_sys_QsubPost"
+}
+
+#D-*************************
+#D- File transfer functions
+#D-*************************
+#D-
+
+#D-#==================================================
+#D-function IGCM_sys_Rsync_out
+#D-* Purpose: treat return val of rsync
+#D-* Examples: IGCM_sys_Rsync_out out_RET_rsync
+#D-  Error values and explanations can depend on your system version.
+function IGCM_sys_Rsync_out {
+  status=$1
+  if [ ! $status ] ; then
+    echo "rsync error !"
+  fi
+
+  if [ $MYLANG = "fr" ]; then
+    case $status in
+    0)  return ;;
+    1)  echo "Erreur de rsync ; RERR_SYNTAX : "
+      echo "Erreur de syntaxe ou d'utilisation."
+      return;;
+    2)  echo "Erreur de rsync ; RERR_PROTOCOL : "
+      echo "Incompatibilité de protocole."
+      return;;
+    3)  echo "Erreur de rsync ; RERR_FILESELECT 3"
+      echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et"
+      echo "répertoires"
+      return;;
+    4)  echo "Erreur de rsync ; RERR_UNSUPPORTED"
+      echo "Action demandée non supportée : une tentative de manipulation de"
+      echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a"
+      echo "été faite ; ou une option qui est supportée par le  client  mais"
+      echo "pas par le serveur a été spécifiée."
+      return;;
+    10) echo "Erreur de rsync ; RERR_SOCKETIO"
+      echo "Erreur dans le socket d'entrée sortie"
+      return;;
+    11) echo "Erreur de rsync ; RERR_FILEIO"
+      echo "Erreur d'entrée sortie fichier"
+      return;;
+    12) echo "Erreur de rsync ; RERR_STREAMIO"
+      echo "Erreur dans flux de donnée du protocole rsync"
+      return;;
+    13) echo "Erreur de rsync ; RERR_MESSAGEIO"
+      echo "Erreur avec les diagnostics du programme"
+      return;;
+    14) echo "Erreur de rsync ; RERR_IPC"
+      echo "Erreur dans le code IPC"
+      return;;
+    20) echo "Erreur de rsync ; RERR_SIGNAL"
+      echo "SIGUSR1 ou SIGINT reçu"
+      return;;
+    21) echo "Erreur de rsync ; RERR_WAITCHILD"
+      echo "Une erreur retournée par waitpid()"
+      return;;
+    22) echo "Erreur de rsync ; RERR_MALLOC"
+      echo "Erreur lors de l'allocation des tampons de mémoire de coeur"
+      return;;
+    23) echo ""
+      echo "Erreur fichier inexistant"
+      return;;
+    30) echo "Erreur de rsync ; RERR_TIMEOUT"
+      echo "Temps d'attente écoulé dans l'envoi/réception de données"
+      return;;
+    *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $status
+      return;;
+    esac
+  elif [ $MYLANG = "en" ] ; then
+    case $status in
+    0)  return;;
+    1)  echo "rsync error : Syntax or usage error "
+      return;;
+    2)  echo "rsync error : Protocol incompatibility "
+      return;;
+    3)  echo "rsync error : Errors selecting input/output files, dirs"
+      return;;
+    4)  echo "rsync error : Requested action not supported: an attempt"
+      echo "was made to manipulate 64-bit files on a platform that cannot support"
+      echo "them; or an option was specified that is supported by the client and"
+      echo "not by the server."
+      return;;
+    5)  echo "rsync error : Error starting client-server protocol"
+      return;;
+    10) echo "rsync error : Error in socket I/O "
+      return;;
+    11) echo "rsync error : Error in file I/O "
+      return;;
+    12) echo "rsync error : Error in rsync protocol data stream "
+      return;;
+    13) echo "rsync error : Errors with program diagnostics "
+      return;;
+    14) echo "rsync error : Error in IPC code "
+      return;;
+    20) echo "rsync error : Received SIGUSR1 or SIGINT "
+      return;;
+    21) echo "rsync error : Some error returned by waitpid() "
+      return;;
+    22) echo "rsync error : Error allocating core memory buffers "
+      return;;
+    23) echo "rsync error : Partial transfer due to error"
+      return;;
+    24) echo "rsync error : Partial transfer due to vanished source files"
+      return;;
+    30) echo "rsync error : Timeout in data send/receive "
+      return;;
+    *)  echo "rsync error : return code of rsync unknown :" $status
+      return;;
+    esac
+  else
+    echo "unknown language $MYLANG."
+    return
+  fi
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Miror_libIGCM
+#D-* Purpose: Mirror libIGCM PATH and lib to frontend
+#D-* Examples:
+#D-
+function IGCM_sys_Mirror_libIGCM {
+  IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM"
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Mirror_libIGCM"
+  fi
+
+  typeset status
+
+  mkdir -p ${HOME}/MIRROR/${PATHlibIGCM}
+
+  echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > /tmp/out_command.$$ 2>&1
+  ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> /tmp/out_command.$$ 2>&1
+  status=$?
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on frontend."
+    cat /tmp/out_command.$$
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Cp
+#D-* Purpose: generic cp
+#D-* Examples:
+#D-
+function IGCM_sys_Cp {
+  IGCM_debug_PushStack "IGCM_sys_Cp" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Cp :" $@
+  fi
+
+  typeset status
+
+  echo cp $@ > /tmp/out_command.$$ 2>&1
+  \cp $@ >> /tmp/out_command.$$ 2>&1
+  status=$?
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_Cp : error code ${status}"
+    cat /tmp/out_command.$$
+    IGCM_debug_Exit "IGCM_sys_Cp"
+  else
+    \rm /tmp/out_command.$$
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Cp"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Rm
+#D-* Purpose: generic rm
+#D-* Examples:
+#D-
+function IGCM_sys_Rm {
+  IGCM_debug_PushStack "IGCM_sys_Rm" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Rm :" $@
+  fi
+
+  typeset status
+
+  echo rm $@ > /tmp/out_command.$$ 2>&1
+  \rm $@ >> /tmp/out_command.$$ 2>&1
+  status=$?
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_Rm : error code ${status}"
+    cat /tmp/out_command.$$
+    IGCM_debug_Exit "IGCM_sys_Rm"
+  else
+    \rm /tmp/out_command.$$
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Rm"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_RmRunDir
+#D-* Purpose: rm tmpdir (dummy function most of the time batch
+#D-                      scheduler will do the job)
+#D-* Examples:
+#D-
+function IGCM_sys_RmRunDir {
+  IGCM_debug_PushStack "IGCM_sys_RmRunDir" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_RmRunDir :" $@
+  fi
+
+  typeset status
+
+  echo rm $@ > /tmp/out_command.$$ 2>&1
+  \rm $@ >> /tmp/out_command.$$ 2>&1
+  status=$?
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_RmRunDir : rm error code is ${status}."
+    cat /tmp/out_command.$$
+    IGCM_debug_Exit "IGCM_sys_RmRunDir"
+  else
+    \rm /tmp/out_command.$$
+  fi
+  IGCM_debug_PopStack "IGCM_sys_RmRunDir"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Mv
+#D-* Purpose: generic move
+#D-* Examples:
+#D-
+function IGCM_sys_Mv {
+  IGCM_debug_PushStack "IGCM_sys_Mv" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Mv :" $@
+  fi
+
+  if [ $DRYRUN = 0 ]; then
+
+    typeset status
+
+    echo mv $@ > /tmp/out_command.$$ 2>&1
+    \mv $@ >> /tmp/out_command.$$ 2>&1
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_Mv : error code ${status}"
+      cat /tmp/out_command.$$
+      IGCM_debug_Exit "IGCM_sys_Mv"
+    else
+      \rm /tmp/out_command.$$
+    fi
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_Mv"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Put_Dir
+#D-* Purpose: Copy a complete directory on $(ARCHIVE)
+#D-* Examples:
+#D-
+function IGCM_sys_Put_Dir {
+  IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Put_Dir :" $@
+  fi
+  if [ $DRYRUN = 0 ]; then
+    if [ ! -d ${1} ] ; then
+      echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ."
+      IGCM_debug_PopStack "IGCM_sys_Put_Dir"
+      return
+    fi
+
+    typeset status
+
+    # Only if we use rsync
+    #IGCM_sys_TestDirArchive $( dirname $2 )
+    #
+    #USUAL WAY
+    \cp -r $1 $2 > /tmp/out_command.$$ 2>&1
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_Put_Dir : cp failed error code ${status}"
+      cat /tmp/out_command.$$
+      IGCM_debug_Exit "IGCM_sys_Put_Dir"
+    else
+      \rm /tmp/out_command.$$
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Put_Dir"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Get_Dir
+#D-* Purpose: Copy a complete directory from ${ARCHIVE}
+#D-* Examples:
+#D-
+function IGCM_sys_Get_Dir {
+  IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Get_Dir :" $@
+  fi
+  if [ $DRYRUN = 0 ]; then
+    if [ ! -d ${1} ] ; then
+      echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ."
+      IGCM_debug_PopStack "IGCM_sys_Get_Dir"
+      return
+    fi
+
+    typeset status
+
+    #USUAL WAY
+    \cp -ur $1 $2 > /tmp/out_command.$$ 2>&1
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_Get_Dir : cp failed error code ${status}"
+      cat /tmp/out_command.$$
+      IGCM_debug_Exit "IGCM_sys_Get_Dir"
+    else
+      \rm /tmp/out_command.$$
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Get_Dir"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Get_Master
+#D-* Purpose: Copy a complete directory from MASTER filesystem
+#D-* Examples:
+#D-
+function IGCM_sys_Get_Master {
+  IGCM_debug_PushStack "IGCM_sys_Get_Master" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Get_Master :" $@
+  fi
+  if [ $DRYRUN = 0 ]; then
+    if ( [ ! -d ${1} ] && [ ! -f ${1} ] ) ; then
+      echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ."
+      IGCM_debug_PopStack "IGCM_sys_Get_Master"
+      return
+    fi
+
+    typeset NB_ESSAI DELAI status i
+    # number of tentative
+    NB_ESSAI=3
+    # time delay between tentative
+    DELAI=2
+
+    i=0
+    while [ $i -lt $NB_ESSAI ] ; do
+      \cp -urL $1 $2 > /tmp/out_command.$$ 2>&1
+      status=$?
+      if [ ${status} -gt 0 ]; then
+        IGCM_debug_Print 2 "IGCM_sys_Get_Master : cp failed error code ${status} ${i}/${NB_ESSAI}"
+        IGCM_debug_Print 2 "IGCM_sys_Get_Master : sleep ${DELAI} seconds and try again."
+        sleep $DELAI
+      else
+        break
+      fi
+      (( i = i + 1 ))
+    done
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_Get_Master : error."
+      cat /tmp/out_command.$$
+      IGCM_debug_Exit "IGCM_sys_Get_Master"
+    else
+      \rm /tmp/out_command.$$
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Get_Master"
+}
+
+#====================================================
+#- Call IGCM_sys_Mirror_libIGCM now !
+if ( $MirrorlibIGCM ) ; then
+  IGCM_sys_Mirror_libIGCM
+fi
+
+#D-#==================================================
+#D-function IGCM_sys_Put_Rest
+#D-* Purpose: Put computied restarts on ${ARCHIVE}.
+#D-           File and target directory must exist.
+#D-* Examples:
+#D-
+function IGCM_sys_Put_Rest {
+  IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Put_Rest :" $@
+  fi
+  if [ $DRYRUN = 0 ]; then
+    if [ ! -f ${1} ] ; then
+      echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ."
+      IGCM_debug_Exit "IGCM_sys_Put_Rest"
+    fi
+
+    typeset status
+    #
+    if [ X${JobType} = XRUN ] ; then
+      IGCM_sys_Chmod 444 ${1}
+    fi
+    #
+    # Only if we use rsync
+    #IGCM_sys_MkdirArchive $( dirname $2 )
+    #
+    #USUAL WAY
+    \cp $1 $2 > /tmp/out_command.$$ 2>&1
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_Put_Rest : cp failed error code ${status}"
+      cat /tmp/out_command.$$
+      IGCM_debug_Exit "IGCM_sys_Put_Rest"
+    else
+      \rm /tmp/out_command.$$
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Put_Rest"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_PutBuffer_Rest
+#D-* Purpose: Put computied restarts on ${SCRATCHDIR}.
+#D-           File and target directory must exist.
+#D-* Examples:
+#D-
+function IGCM_sys_PutBuffer_Rest {
+  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Rest" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_PutBuffer_Rest :" $@
+  fi
+  if [ $DRYRUN = 0 ]; then
+    if [ ! -f ${1} ] ; then
+      echo "ERROR : IGCM_sys_PutBuffer_Rest ${1} DOES NOT EXIST ."
+      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest"
+    fi
+
+    typeset status
+    #
+    if [ X${JobType} = XRUN ] ; then
+      IGCM_sys_Chmod 444 ${1}
+    fi
+
+    #
+    # USUAL WAY
+    \cp $1 $2 > /tmp/out_command.$$ 2>&1
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_PutBuffer_Rest : error code ${status}"
+      [ -f ${2} ] && ls -l ${2}
+      [ -f ${2}/${1} ] && ls -l ${2}/${1}
+      cat /tmp/out_command.$$
+      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest"
+    else
+      \rm /tmp/out_command.$$
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Rest"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_PrepareTaredRestart
+#D-* Purpose: Prepare tared restart to be access by computing job. Identity here.
+#D-* Examples:
+#D-
+function IGCM_sys_PrepareTaredRestart {
+  IGCM_debug_PushStack "IGCM_sys_PrepareTaredRestart" $@
+
+  IGCM_debug_PopStack "IGCM_sys_PrepareTaredRestart"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Put_Out
+#D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly
+#D-* Examples:
+#D-
+function IGCM_sys_Put_Out {
+  IGCM_debug_PushStack "IGCM_sys_Put_Out" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Put_Out :" $@
+  fi
+
+  typeset status
+
+  if [ $DRYRUN = 0 ]; then
+    if [ ! -f ${1} ] ; then
+      echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ."
+      IGCM_debug_PopStack "IGCM_sys_Put_Out"
+      return 1
+    fi
+    #
+    IGCM_sys_MkdirArchive $( dirname $2 )
+    #
+    if [ X${JobType} = XRUN ] ; then
+      if [ X${3} = X ] ; then
+        IGCM_sys_Chmod 444 ${1}
+      fi
+    fi
+    #
+    #USUAL WAY
+    \cp $1 $2 > /tmp/out_command.$$ 2>&1
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_Put_Out : cp failed error code ${status}"
+      cat /tmp/out_command.$$
+      IGCM_debug_Exit "IGCM_sys_Put_Out"
+    else
+      \rm /tmp/out_command.$$
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Put_Out"
+  return 0
+}
+
+#D-#==================================================
+#D-function IGCM_sys_PutBuffer_Out
+#D-* Purpose: Copy a file on ${WORKDIR} after having chmod it in readonly
+#D-* Examples:
+#D-
+function IGCM_sys_PutBuffer_Out {
+  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Out" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_PutBuffer_Out :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i exist skip
+
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  if [ $DRYRUN = 0 ]; then
+    if [ ! -f ${1} ] ; then
+      echo "WARNING : IGCM_sys_PutBuffer_Out ${1} DOES NOT EXIST ."
+      IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out"
+      return 1
+    fi
+    #
+    IGCM_sys_Mkdir $( dirname $2 )
+    #
+
+    exist=false
+    skip=false
+    if [ -f $2 ] ; then
+      IGCM_debug_Print 1 "$2 already exist"
+      exist=true
+      if [ "X$( diff $1 $2 )" = X ] ; then
+        IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy"
+        status=0
+        skip=true
+      else
+        IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy"
+        skip=false
+      fi
+    fi
+    #
+    if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then
+      IGCM_sys_Chmod u+w $2
+    fi
+
+    if [ X${skip} = Xfalse ] ; then
+      i=0
+      while [ $i -lt $NB_ESSAI ] ; do
+        # USUAL WAY
+        \cp $1 $2 > /tmp/out_command.$$ 2>&1
+        status=$?
+        if [ ${status} -gt 0 ]; then
+          IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : cp failed error code ${status} ${i}/${NB_ESSAI}"
+          IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : sleep ${DELAI} seconds and try again."
+          [ -f ${2} ] && ls -l ${2}
+          [ -f ${2}/${1} ] && ls -l ${2}/${1}
+          sleep $DELAI
+        else
+          break
+        fi
+        (( i = i + 1 ))
+      done
+    fi
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_PutBuffer_Out : error."
+      [ -f ${2} ] && ls -l ${2}
+      [ -f ${2}/${1} ] && ls -l ${2}/${1}
+      cat /tmp/out_command.$$
+      IGCM_debug_Exit "IGCM_sys_PutBuffer_Out"
+    else
+
+      if [ X${JobType} = XRUN ] ; then
+        if [ X${3} = X ] ; then
+          [ -f ${2} ] && IGCM_sys_Chmod 444 ${2}
+          [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1}
+        fi
+      fi
+
+      \rm /tmp/out_command.$$
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out"
+  return 0
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Get
+#D-* Purpose: Get a file from ${ARCHIVE}
+#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
+#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
+function IGCM_sys_Get {
+  IGCM_debug_PushStack "IGCM_sys_Get" $@
+
+  typeset DEST status dm_liste
+
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Get :" $@
+  fi
+  if [ $DRYRUN -le 2 ]; then
+    if [ X${1} = X'/l' ] ; then
+      eval set +A dm_liste \${${2}}
+    else
+      dm_liste=${1}
+    fi
+    eval DEST=\${${#}}
+
+    # test if the (first) file is present in the old computation :
+    DEBUG_sys=false IGCM_sys_IsFileArchived ${dm_liste[0]}
+    if [ $? = 0 ] ; then
+      IGCM_sys_TestFileArchive ${dm_liste[0]}
+      status=$?
+    else
+      IGCM_sys_TestFileBuffer ${dm_liste[0]}
+      status=$?
+    fi
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ."
+      IGCM_debug_Exit "IGCM_sys_Get"
+      return
+    fi
+
+    #USUAL WAY
+    \cp ${dm_liste[*]} ${DEST} > /tmp/out_command.$$ 2>&1
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_Get : cp failed error code ${status}"
+      cat /tmp/out_command.$$
+      IGCM_debug_Exit "IGCM_sys_Get"
+    else
+      \rm /tmp/out_command.$$
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Get"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_GetBuffer
+#D-* Purpose: Get a file from ${SCRATCHDIR}
+#D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX
+#D-            IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/
+function IGCM_sys_GetBuffer {
+  IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@
+
+  typeset DEST buf_liste target file_work
+  typeset NB_ESSAI DELAI status i
+
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_GetBuffer :" $@
+  fi
+
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  if [ $DRYRUN -le 2 ]; then
+    if [ X${1} = X'/l' ] ; then
+      eval set +A buf_liste \${${2}}
+    else
+      eval set +A buf_liste ${1}
+    fi
+    eval DEST=\${${#}}
+
+    #USUAL WAY
+    if [ X${1} = X'/l' ] ; then
+      for target in ${buf_liste[*]} ; do
+        local_file=$( basename ${target} )
+        i=0
+        while [ $i -lt $NB_ESSAI ] ; do
+          \cp ${target} ${DEST}/${local_file} >> /tmp/out_command.$$ 2>&1
+          status=$?
+          if [ ${status} -gt 0 ]; then
+            IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}"
+            IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again."
+            sleep $DELAI
+          else
+            break
+          fi
+          (( i = i + 1 ))
+        done
+        if [ ${status} -gt 0 ] ; then
+          echo "IGCM_sys_Get : error"
+          cat /tmp/out_command.$$
+          \rm /tmp/out_command.$$
+          IGCM_debug_Exit "IGCM_sys_GetBuffer"
+        else
+          \rm /tmp/out_command.$$
+        fi
+      done
+    else
+      i=0
+      while [ $i -lt $NB_ESSAI ] ; do
+        \cp ${buf_liste} ${DEST} >> /tmp/out_command.$$ 2>&1
+        status=$?
+        if [ ${status} -gt 0 ]; then
+          IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}"
+          IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again."
+          sleep $DELAI
+        else
+          break
+        fi
+        (( i = i + 1 ))
+      done
+      if [ ${status} -gt 0 ] ; then
+        echo "IGCM_sys_Get : error"
+        cat /tmp/out_command.$$
+        \rm /tmp/out_command.$$
+        IGCM_debug_Exit "IGCM_sys_GetBuffer"
+      else
+        \rm /tmp/out_command.$$
+      fi
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_GetBuffer"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_GetDate_FichWork
+#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK
+#D-* Examples:
+#D-
+function IGCM_sys_GetDate_FichWork {
+  IGCM_debug_PushStack "IGCM_sys_FichWork" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_GetDate_FichWork :" $@
+  fi
+  # donne la date filesys d'un fichier sur la machine work
+  IGCM_debug_PopStack "IGCM_sys_FichWork"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_GetDate_FichArchive
+#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE
+#D-* Examples:
+#D-
+function IGCM_sys_GetDate_FichArchive {
+  IGCM_debug_PushStack "IGCM_sys_FichArchive" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_GetDate_FichArchive :" $@
+  fi
+  IGCM_debug_PopStack "IGCM_sys_FichArchive"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Dods_Rm
+#D-* Purpose: DO NOTHING ! Put ${ARCHIVE} files on DODS internet protocole.
+#D-* Examples:
+#D-
+function IGCM_sys_Dods_Rm {
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Dods_Rm :" $@
+  fi
+  return 0
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Dods_Cp
+#D-* Purpose: Copy $(ARCHIVE) files on DODS internet protocole.
+#D-* Examples:
+#D-
+function IGCM_sys_Dods_Cp {
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Dods_Cp :" $@
+  fi
+  return 0
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Put_Dods
+#D-* Purpose: Put ${ARCHIVE} files on DODS internet protocole. Dummy function here
+#D-* Examples:
+#D-
+function IGCM_sys_Put_Dods {
+  IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Put_Dods :" $@
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Put_Dods"
+}
+
+##############################################################
+# REBUILD OPERATOR
+
+#D-#==================================================
+#D-function IGCM_sys_rebuild
+#D-* Purpose: rebuild parallel files
+#D-* Examples:
+#D-
+function IGCM_sys_rebuild {
+  IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_rebuild :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i firstArg
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    /gpfs1/home/sebastien/REBUILD/rebuild -f -o $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_rebuild : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_rebuild : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      firstArg=${1}
+      \rm ${firstArg}
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_rebuild : rebuild error code is ${status}"
+    IGCM_debug_Exit "rebuild"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_rebuild"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_rebuild_station
+#D-* Purpose: rebuild parallel files describing station
+#D-* Examples:
+#D-
+function IGCM_sys_rebuild_station {
+  IGCM_debug_PushStack "IGCM_sys_rebuild_station" -- $@
+  typeset i list_opt file_in file_out prefix_invert list_invert
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_rebuild_station :" $@
+  fi
+  list_opt=$@
+
+  # Invert Axis : t,x -> x,t
+  #               t,pres,x -> x,t,pres
+  # So that we can concatenate along x
+  i=0
+  for file_in in ${list_opt} ; do
+    (( i = i + 1))
+    [ ${i} = 1 ] && file_out=${file_in} && continue
+    prefix_invert=$( basename ${file_in} .nc )
+    IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs ${file_in} ${prefix_invert}_xt.nc
+    list_invert[${#list_invert[*]}]=${prefix_invert}_xt.nc
+  done
+
+  # Concatenate
+  IGCM_sys_ncrcat ${list_invert[*]} histstn_xt.nc
+
+  # Re-ivert file
+  IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x histstn_xt.nc ${file_out}
+
+  # Station re-ordering is too expansive to be run within libIGCM
+  # This is due to (ncpdq - nrcat - ncpdq) I/O sequence.
+  # This re-ordering must be done "in memory" by the cmorization process
+  # Anyway this is the best sequence using (ncpdq - nrcat - ncpdq)
+  # BEGIN reordering
+
+  # Only LMDZ text output contains the exact ordering of the station.
+  # We isolate this in the code below:
+  #  0  38  -157.5000000000000  70.98591549295774
+  #  0  54  27.49999999999999   67.18309859154928
+  #  0  56  -62.50000000000001  82.39436619718309
+  #  0  79  12.49999999999999   78.59154929577466
+  #  0  116 -165.0000000000000  76.05633802816901
+  #  0  117 130.0000000000000   70.98591549295774
+  #  0  118 110.0000000000000   87.46478873239437
+  #  1  40  4.999999999999995   51.97183098591550
+#  typeset iStation iProc list_opt file_in file_out prefix_invert
+#  typeset -Z4 j4
+#  typeset -Z3 j3
+
+#  unset list_opt
+#  set +A list_opt $@
+
+  # Filename after rebuild
+#  file_out=${list_opt[0]}
+  # Prefix of output files
+#  prefix_invert=$( basename ${file_out} .nc )
+  # Number of procs
+#  num_proc=$( grep -i mpi_size ${PREFIX}_${Exe_Output} | wc -l )
+
+#  iProc=0
+#  while [ ${iProc} -lt ${num_proc} ] ; do
+    # Array containing Station as a number
+#    unset proc_stn
+#    set +A proc_stn $( grep "iophy_mpi rank ip lon lat  $iProc" ${PREFIX}_${Exe_Output} | sed -e "s/iophy_mpi rank ip lon lat //g" | gawk ' {print $2}' )
+    # Number of stations produced by processor proc
+#    stationLast=${#proc_stn[*]}
+    # Proc number on 4 digits
+#    j4=${iProc}
+    # Init
+#    iStation=0
+#    while [ ${iStation} -lt ${stationLast} ] ; do
+      # Station number on 3 digits
+#      j3=${proc_stn[${iStation}]}
+      # Extract station
+      # Invert Axis : t,x -> x,t
+      #               t,pres,x -> x,t,pres
+      # So that we can concatenate along x
+#      IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs -d x,$iStation,$iStation ${prefix_invert}_${j4}.nc ${prefix_invert}_stn_${j3}.nc
+#      (( iStation = iStation + 1 ))
+#    done
+#    (( iProc = iProc + 1 ))
+#  done
+
+  # Concatenate all station along x
+#  IGCM_sys_ncrcat ${prefix_invert}_stn_???.nc ${prefix_invert}_xt.nc
+
+  # Re-invert file
+#  IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x ${prefix_invert}_xt.nc ${file_out}
+
+  # END reordering
+
+  IGCM_debug_PopStack "IGCM_sys_rebuild_station"
+}
+
+############################################################
+# Activate Running Environnment Variables
+
+#D-#==================================================
+#D-function IGCM_sys_desactiv_variables
+#D-* Purpose: set environement variables prior to execution
+#D-* Examples:
+#D-
+function IGCM_sys_activ_variables {
+  IGCM_debug_PushStack "IGCM_sys_activ_variables"
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_activ_variables"
+  fi
+
+# --------------------------------------------------------------------
+#D- MPI specifications
+# --------------------------------------------------------------------
+
+# --------------------------------------------------------------------
+#D- Other specifications
+# --------------------------------------------------------------------
+
+  IGCM_debug_PopStack "IGCM_sys_activ_variables"
+}
+
+############################################################
+# Desactivate Running Environnment Variables
+
+#D-#==================================================
+#D-function IGCM_sys_desactiv_variables
+#D-* Purpose: unset environement variables after execution
+#D-* Examples:
+#D-
+function IGCM_sys_desactiv_variables {
+  IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_desactiv_variables"
+  fi
+# --------------------------------------------------------------------
+#D- MPI specifications
+# --------------------------------------------------------------------
+
+# --------------------------------------------------------------------
+#D- Other specifications
+# --------------------------------------------------------------------
+
+  IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
+}
+
+############################################################
+# Build MPI/OMP scripts run file (dummy function)
+
+#D-#==================================================
+#D-function IGCM_sys_build_run_file
+#D-* Purpose: build run file (deprecated)
+#D-* Examples:
+#D-
+function IGCM_sys_build_run_file {
+
+  IGCM_debug_Print 3 " dummy function : IGCM_sys_build_run_file "
+
+}
+
+############################################################
+# Build MPI/OMP scripts
+
+#D-#==================================================
+#D-function IGCM_sys_build_execution_scripts
+#D-* Purpose: build execution scripts to be launch by ${HOST_MPIRUN_COMMAND}
+#D-* Examples:
+#D-
+function IGCM_sys_build_execution_scripts
+{
+  IGCM_debug_PushStack "IGCM_sys_build_execution_scripts" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_build_execution_scripts " $@
+  fi
+
+  typeset NbNodes_Job NbProc_Job comp_proc_mpi_loc comp_proc_omp_loc mpi_count
+
+  if [ ! -f ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} ]  ; then
+    IGCM_debug_Exit "IGCM_sys_iitm build_execution_scripts : Job_${config_UserChoices_JobName} don't exist in SUBMIT_DIR : ${SUBMIT_DIR} "
+  fi
+
+  if ( ${OK_PARA_MPMD} ) ; then
+
+    if [ -f run_file ] ; then
+      IGCM_sys_Rm -f run_file
+    fi
+    touch run_file
+
+    if ( ${OK_PARA_OMP} ) ; then
+# NEW : 2 Noeuds
+# @ task_geometry={(0)(1,2,3)}
+# Nombre de processus demandes
+      echo "Job_${config_UserChoices_JobName} includes task_geometry = \c"
+      cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "task_geometry" | sed -e "s/[^(]*([^(]*/(/g"
+      echo "Job_${config_UserChoices_JobName} includes task_geometry  with NbNodes = \c"
+      cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "task_geometry" | sed -e "s/[^(]*([^(]*/(/g" | wc -c
+      NbNodes_Job=$(( $( cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "task_geometry" | sed -e "s/[^(]*([^(]*/(/g" | wc -c ) - 1 ))
+
+      if [ ${NbNodes_Job} -eq 0 ] ; then
+        IGCM_debug_Print 2 "Error in Job_${config_UserChoices_JobName} ressources : no task_geometry defined with OpenMP run."
+        exit 1
+      fi
+    else
+
+# OLD :
+# @ total_tasks = 3
+# @ environment = "BATCH_NUM_PROC_TOT=3"
+# Pas d OpenMP
+# @ resources = ConsumableCpus(1)
+
+      echo "Job_${config_UserChoices_JobName} includes total_tasks = \c"
+      cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "total_tasks" | sed -e "s/.*total_tasks = //"
+      NbProc_Job=$( cat ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} | grep "total_tasks" | sed -e "s/.*total_tasks = //" )
+      NbProc_Job=${NbProc_Job:=0}
+      if [ ${NbProc_Job} -eq 0 ] ; then
+        IGCM_debug_Print 2 "Error in Job_${config_UserChoices_JobName} ressources : no total_tasks defined with MPI only run."
+        exit 1
+      fi
+      if ( $( egrep '^# *@ *resources *= *ConsumableCpus\(1\)' ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} >/dev/null 2>&1 ) ) ; then
+        IGCM_debug_Print 2 "ressources =  ConsumableCpus(1) line found into Job_${config_UserChoices_JobName}"
+      else
+        IGCM_debug_Print 2 "Error in Job_${config_UserChoices_JobName} ressources = line not found. Job should include resources = ConsumableCpus(1) "
+        exit 1
+      fi
+    fi
+
+# run_file construction
+
+# Then first loop on the components for the coupler ie oasis
+
+### the coupler ie oasis must be the first one
+    for comp in ${config_ListOfComponents[*]} ; do
+
+      eval ExeNameIn=\${config_Executable_${comp}[0]}
+      eval ExeNameOut=\${config_Executable_${comp}[1]}
+
+      # for CPL component only
+      if [ "X${comp}" = "XCPL" ] ; then
+
+        eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
+        eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
+
+        if ( ${OK_PARA_MPI} ) ; then
+
+          (( mpi_count = 1 ))
+          until [ ${mpi_count} -gt ${comp_proc_mpi_loc} ] ; do
+            if ( ${OK_PARA_OMP} ) ; then
+              echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> run_file
+            else
+              echo "./${ExeNameOut}" >> run_file
+            fi
+            (( mpi_count = mpi_count + 1 ))
+          done
+        else
+          if ( ${OK_PARA_OMP} ) ; then
+            echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> run_file
+          else
+            echo "./${ExeNameOut} " >> run_file
+          fi
+        fi
+      fi
+    done
+
+# Then second loop on the components
+
+    for comp in ${config_ListOfComponents[*]} ; do
+
+      eval ExeNameIn=\${config_Executable_${comp}[0]}
+      eval ExeNameOut=\${config_Executable_${comp}[1]}
+
+      # Only if we really have an executable for the component and not the coupler ie oasis:
+      if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${comp}" != "XCPL" ] ) ; then
+
+        eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
+        eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
+
+        if ( ${OK_PARA_MPI} ) ; then
+
+          (( mpi_count = 1 ))
+          until [ ${mpi_count} -gt ${comp_proc_mpi_loc} ] ; do
+            if ( ${OK_PARA_OMP} ) ; then
+              echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> run_file
+            else
+              echo "./${ExeNameOut}" >> run_file
+            fi
+            (( mpi_count = mpi_count + 1 ))
+          done
+        else
+          if ( ${OK_PARA_OMP} ) ; then
+            echo "env OMP_NUM_THREADS=${comp_proc_omp_loc} ./${ExeNameOut} " >> run_file
+          else
+                    # to be tested : no MPI only OpenMP into MPMD mode
+            echo "./${ExeNameOut} " >> run_file
+          fi
+        fi
+      fi
+    done
+
+    EXECUTION="${HOST_MPIRUN_COMMAND} -pgmmodel mpmd -cmdfile ./run_file"
+
+    IGCM_sys_Chmod u+x run_file
+    if ( $DEBUG_sys ) ; then
+      echo "run_file contains : "
+      cat run_file
+    fi
+
+  else # Only one executable. launch it.
+
+    for comp in ${config_ListOfComponents[*]} ; do
+
+      # Only if we really have an executable for the component :
+      eval ExeNameOut=\${config_Executable_${comp}[1]}
+      if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${ExeNameOut}" != "Xinca.dat" ] ) ; then
+        EXECUTION="${HOST_MPIRUN_COMMAND} ./${ExeNameOut}"
+      fi
+
+    done
+
+  fi
+
+  IGCM_debug_Print 1 "sys iitm : execution command is"
+  IGCM_debug_Print 1 "$EXECUTION"
+
+  IGCM_debug_PopStack "IGCM_sys_build_execution_scripts"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_check_path
+#D-* Purpose: check that RUN_DIR_PATH that will be removed on some machine
+#D-* do not point to an important use directory. Stop immediately in that case.
+#D-* Examples:
+#D-
+function IGCM_sys_check_path {
+  IGCM_debug_PushStack "IGCM_sys_check_path"
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_check_path"
+  fi
+
+  if ( [ X${RUN_DIR_PATH} = X${HOME} ] || [ X${RUN_DIR_PATH} = X${WORKDIR} ] || [ X${RUN_DIR_PATH} = X${ARCHIVE} ] ) ; then
+    IGCM_debug_Print 1 "Variable RUN_DIR_PATH is pointing to an important directory : ${RUN_DIR_PATH}"
+    IGCM_debug_Print 1 "Please check the RUN_DIR_PATH definition in your Job : Job_${config_UserChoices_JobName}"
+    IGCM_debug_Exit "This will stop the job"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_check_path"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_check_quota. Dummy call here
+#D-* Purpose: check user quota. Stop the simulation if quota above 90%
+#D-* Examples:
+#D-
+function IGCM_sys_check_quota {
+  IGCM_debug_PushStack "IGCM_sys_check_quota"
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_check_quota"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_check_quota"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_CountJobInQueue
+#D-* Purpose: Check if job_name is currently
+#D-  running or in queue
+#D-* Examples: IGCM_sys_CountJobInQueue ${JobName} NbRun
+#D-
+function IGCM_sys_CountJobInQueue {
+  IGCM_debug_PushStack "IGCM_sys_CountJobInQueue"
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_CountJobInQueue"
+  fi
+
+  # Print only the full (-W) JobName (%jn)
+  NbRun=$( llq -W -f %jn | grep -c "$1" )
+
+  eval ${2}=${NbRun}
+
+  IGCM_debug_PopStack "IGCM_sys_CountJobInQueue"
+}
+
+##############################################################
+# NCO OPERATOR
+
+#D-#==================================================
+#D-function IGCM_sys_ncap2
+#D-* Purpose: encapsulate ncap2 call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncap2 {
+  IGCM_debug_PushStack "IGCM_sys_ncap2" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncap2 :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncap2 "$@" > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncap2 : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncap2 : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncap2 : ncap2 error"
+    IGCM_debug_Exit "ncap2"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncap2"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncatted
+#D-* Purpose: encapsulate ncatted call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncatted {
+  IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncatted :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncatted "$@" > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncatted : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncatted : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncatted : ncatted error"
+    IGCM_debug_Exit "ncatted"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncatted"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncbo
+#D-* Purpose: encapsulate ncbo call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncbo {
+  IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncbo :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncbo $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncbo : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncbo : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncbo : ncbo error"
+    IGCM_debug_Exit "ncbo"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncbo"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncdif
+#D-* Purpose: encapsulate ncdiff call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncdiff {
+  IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncdiff :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncdiff $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncdiff : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncdiff : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncdiff : ncdiff error"
+    IGCM_debug_Exit "ncdiff"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncdiff"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncea
+#D-* Purpose: encapsulate ncea call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncea {
+  IGCM_debug_PushStack "IGCM_sys_ncea" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncea :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncea $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncea : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncea : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncea : ncea error"
+    IGCM_debug_Exit "ncea"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncea"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncecat
+#D-* Purpose: encapsulate ncecat call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncecat {
+  IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncecat :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncecat $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncecat : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncecat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncecat : ncecat error"
+    IGCM_debug_Exit "ncecat"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncecat"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncflint
+#D-* Purpose: encapsulate ncflint call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncflint {
+  IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncflint :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncflint $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncflint : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncflint : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncflint : ncflint error"
+    IGCM_debug_Exit "ncflint"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncflint"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncks
+#D-* Purpose: encapsulate ncks call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncks {
+  IGCM_debug_PushStack "IGCM_sys_ncks" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncks :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncks $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncks : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncks : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncks : ncks error"
+    IGCM_debug_Exit "ncks"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncks"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncpdq
+#D-* Purpose: encapsulate ncpdq call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncpdq {
+  IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncpdq :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncpdq $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncpdq : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncpdq : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncpdq : ncpdq error"
+    IGCM_debug_Exit "ncpdq"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncpdq"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncra
+#D-* Purpose: encapsulate ncra call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncra {
+  IGCM_debug_PushStack "IGCM_sys_ncra" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncra :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncra $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncra : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncra : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncra : ncra error"
+    IGCM_debug_Exit "ncra"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncra"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncrcat
+#D-* Purpose: encapsulate ncrcat call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncrcat {
+  IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncrcat :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i lastArg
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncrcat $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncrcat : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    elif [ ! "X$( grep "WARNING Intra-file non-monotonicity" /tmp/out_command.$$ )" = "X" ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncrcat : WARNING Intra-file non-monotonicity"
+      cat /tmp/out_command.$$
+      # remove files having corrupted time axis
+      eval lastArg=\${$#}
+      IGCM_debug_Print 2 "IGCM_sys_ncrcat : Delete ${lastArg}"
+      \rm ${lastArg}
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncrcat : ncrcat error"
+      #IGCM_debug_Exit "ncrcat"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncrcat"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncrename
+#D-* Purpose: encapsulate ncrename call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncrename {
+  IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncrename :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncrename $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncrename : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncrename : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncrename : ncrename error"
+    IGCM_debug_Exit "ncrename"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncrename"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncwa
+#D-* Purpose: encapsulate ncwa call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncwa {
+  IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncwa :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncwa $@ > /tmp/out_command.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncwa : error code ${status}"
+      cat /tmp/out_command.$$
+      \rm /tmp/out_command.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncwa : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncwa : ncwa error"
+    IGCM_debug_Exit "ncwa"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncwa"
+}
+
+##############################################################
+# CDO OPERATOR
+
+#D-#==================================================
+#D-function IGCM_sys_cdo
+#D-* Purpose: encapsulate cdo call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_cdo {
+  IGCM_debug_PushStack "IGCM_sys_cdo" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_cdo :" $@
+  fi
+
+  typeset status
+
+  \cdo $@ > /tmp/out_command.$$ 2>&1
+  status=$?
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_cdo : error code ${status}"
+    cat /tmp/out_command.$$
+    \rm /tmp/out_command.$$
+    IGCM_debug_PopStack "IGCM_sys_cdo"
+    return 1
+  else
+    IGCM_debug_PopStack "IGCM_sys_cdo"
+    return 0
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_cdo"
+}
Index: /tags/libIGCM_v2.2/libIGCM_sys/libIGCM_sys_obelix.ksh
===================================================================
--- /tags/libIGCM_v2.2/libIGCM_sys/libIGCM_sys_obelix.ksh	(revision 998)
+++ /tags/libIGCM_v2.2/libIGCM_sys/libIGCM_sys_obelix.ksh	(revision 998)
@@ -0,0 +1,2533 @@
+#!/bin/ksh
+
+#**************************************************************
+# Author: Sebastien Denvil, Martial Mancip, Christian Laguerre
+# Contact: Martial.Mancip__at__ipsl.jussieu.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#=========================================================
+# The documentation of this file can be automatically generated
+# if you use the prefix #D- for comments to be extracted.
+# Extract with command: cat lib* | grep "^#D-" | cut -c "4-"
+#=========================================================
+
+#D-#==================================================
+#D-LibIGCM_sys for obelix
+#D-#==================================================
+#D-
+#D- This ksh library if a layer under some usefull
+#D-environment variables and shell commands.
+#D-All those definitions depend on host particularities.
+#D-It manages a stack mechanism and test validity of operations.
+#D-All function described bellow must be prefixed by IGCM_sys.
+
+#====================================================
+# libIGCM_sys PARAMETERS
+#====================================================
+
+#====================================================
+# set DEBUG_sys to true to output calls of function
+typeset -r DEBUG_sys=${DEBUG_sys:=true}
+
+#====================================================
+# Turn in dry run mode ? (sys_Put_Rest, sys_Put_Out, sys_Get)
+typeset -r DRYRUN=${DRYRUN:=0}
+
+# YOU MUST COMPILE YOUR EXE FILES FOR DRYRUN MODE !
+# -------------------------------------------------------------------------------------
+# | DRYRUN=  |  Date computations, | sys_Get    |  Exe    | sys_Put_Out; sys_Put_Rest |
+# |          |  Cp/Exe/param/files |            |         |                           |
+# |          |  Chmod Qsub         |            |         |                           |
+# -------------------------------------------------------------------------------------
+# |    0     |       yes           |    yes     |  yes    |      yes                  |
+# -------------------------------------------------------------------------------------
+# |    1     |       yes           |    yes     |  yes    |      no                   |
+# -------------------------------------------------------------------------------------
+# |    2     |       yes           |    yes     |  no     |      no                   |
+# -------------------------------------------------------------------------------------
+# |    3     |       yes           |    no      |  no     |      no                   |
+# -------------------------------------------------------------------------------------
+
+#=====================================================
+# Global Variables :
+#=====================================================
+# Language : "fr" or "en"
+typeset -r MYLANG="fr"
+
+#=====================================================
+# Host and user names
+# $hostname ou hostname
+typeset  HOST=${HOST:=$( hostname )}
+# $username ou whoami
+typeset  LOGIN=${LOGIN:=$( whoami )}
+# $hostname of the MASTER job
+typeset MASTER=${MASTER:=$( hostname )}
+
+#D-
+#D-#==================================================
+#D-Program used in libIGCM
+#D-#==================================================
+
+# Submit command
+typeset SUBMIT=${SUBMIT:=qsub}
+# rsync with path
+typeset -r RSYNC=/usr/bin/rsync
+# RSYNC_opt args to rsync
+typeset -r RSYNC_opt="-va"
+# ie storage filesystem
+typeset -r STOREHOST=${MASTER}
+
+#====================================================
+# Set environment tools (ferret, nco, cdo)
+#====================================================
+. /home/users/brock/.atlas_env_asterix_ksh
+
+#====================================================
+# Set lf95 environment
+#====================================================
+. /usr/local/install/lf6481/bash_laheyfort_setup
+
+#====================================================
+# Host specific DIRECTORIES
+#====================================================
+
+#====================================================
+#- MirrorlibIGCM for frontend
+typeset -r MirrorlibIGCM=${MirrorlibIGCM:=false}
+
+#====================================================
+#- libIGCM_POST for frontend
+typeset -r libIGCM_POST=${libIGCM}
+
+#====================================================
+#- R_EXE   (==> BIN_DIR = ${MODIPSL}/bin )
+typeset -r R_EXE="${MODIPSL}/bin"
+
+#====================================================
+#- SUBMIT_DIR : submission dir
+if [ X${PBS_O_WORKDIR} != X ] ; then
+  typeset SUBMIT_DIR=${SUBMIT_DIR:=${PBS_O_WORKDIR}}
+else
+  typeset SUBMIT_DIR=${SUBMIT_DIR:=${PWD}}
+fi
+
+#====================================================
+#- IN
+typeset -r R_IN=${R_IN:=/home/orchideeshare/igcmg/IGCM}
+
+#====================================================
+#- ARCHIVE
+typeset ARCHIVE=${ARCHIVE:=/home/scratch01/${LOGIN}}
+
+#====================================================
+#- STORAGE (dedicated to small/medium files)
+typeset STORAGE=${ARCHIVE}
+
+#====================================================
+#- R_OUT
+typeset R_OUT=${ARCHIVE}/IGCM_OUT
+
+#====================================================
+#- R_FIG (hosting figures : monitoring and atlas, and/or small files)
+typeset R_FIG=${STORAGE}/IGCM_OUT
+
+#====================================================
+#- R_BUF (ONLY FOR double copy an scratch)
+typeset -r R_BUF=${STORAGE}/IGCM_OUT
+
+#====================================================
+#- RUN_DIR_PATH : Temporary working directory (=> TMP)
+if [ X${PBS_JOBID} != X ] ; then
+  typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=/scratch/$PBS_O_LOGNAME.$PBS_JOBID}
+else
+  typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=/tmp/tmp$$}
+fi
+
+#====================================================
+#- HOST_MPIRUN_COMMAND
+typeset -r HOST_MPIRUN_COMMAND=${HOST_MPIRUN_COMMAND:="time mpirun"}
+
+#====================================================
+#- Max number of arguments passed to nco operator or demigration command
+UNIX_MAX_LIMIT=360
+
+#====================================================
+#- Number of core per node (max number of OpenMP task)
+NUM_COREPERNODE=1
+
+#====================================================
+#- Default number of MPI task for IPSL coupled model
+#- required for backward compatibility
+#-
+DEFAULT_NUM_PROC_OCE=1
+DEFAULT_NUM_PROC_CPL=1
+(( DEFAULT_NUM_PROC_ATM = BATCH_NUM_PROC_TOT - DEFAULT_NUM_PROC_OCE - DEFAULT_NUM_PROC_CPL ))
+DEFAULT_NUM_PROC_TOTAL=${BATCH_NUM_PROC_TOT}
+
+#D-#==================================================
+#D-function IGCM_sys_ChangeArchive
+#D-* Purpose: Just a dummy call on this machine
+#D-* Examples:
+#D-
+function IGCM_sys_ChangeArchive {
+  IGCM_debug_Print 1 " dummy function : IGCM_sys_ChangeArchive "
+}
+
+#D-#==================================================
+#D-function IGCM_sys_RshMaster
+#D-* Purpose: Connection to frontend machine.
+#D-* Examples:
+#D-
+function IGCM_sys_RshMaster {
+  IGCM_debug_PushStack "IGCM_sys_RshMaster" $@
+  /bin/ksh  <<-EOF
+    export libIGCM=${libIGCM}
+    export DEBUG_debug=${DEBUG_debug}
+    . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
+    . ${libIGCM}/libIGCM_card/libIGCM_card.ksh
+    ${@}
+EOF
+  if [ $? -gt 0 ] ; then
+    echo "IGCM_sys_RshMaster : erreur."
+    IGCM_debug_Exit "IGCM_sys_RshMaster"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_RshMaster"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_RshArchive
+#D-* Purpose: Archive rsh command
+#D-* Examples:
+#D-
+function IGCM_sys_RshArchive {
+  IGCM_debug_PushStack "IGCM_sys_RshArchive" $@
+  /bin/ksh <<-EOF
+    ${@}
+EOF
+  status=$?
+  if [ ${status} -gt 0 ] ; then
+    IGCM_debug_Print 2 "IGCM_sys_RshArchive : command failed error code ${status}"
+    IGCM_debug_Exit "IGCM_sys_RshArchive"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_RshArchive"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_RshPost
+#D-* Purpose: Post-process rsh command
+#D-* Examples:
+#D-
+function IGCM_sys_RshPost {
+  IGCM_debug_PushStack "IGCM_sys_RshPost" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_RshPost :" $@
+  fi
+
+  # keep standard input (stdin) for the loop onto temporary file
+  cat >tmp_IGCM_sys_RshPost_$$
+
+# ============ FRONTEND START ============ #
+
+  /bin/ksh <tmp_IGCM_sys_RshPost_$$
+  if [ $? -gt 0 ] ; then
+    echo "IGCM_sys_RshPost : erreur."
+    IGCM_debug_Exit "IGCM_sys_RshPost"
+  fi
+  # delete temporary file
+  \rm tmp_IGCM_sys_RshPost_$$
+  IGCM_debug_PopStack "IGCM_sys_RshPost"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_SendMail
+#D-* Purpose: Send mail when simulation is over
+#D-* Examples:
+#D-
+function IGCM_sys_SendMail {
+  IGCM_debug_PushStack "IGCM_sys_SendMail" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_SendMail :" $@
+  fi
+
+  if [ X${1} = XAccounting ] ; then
+    status=Accounting
+    mailText=jobAccounting.mail
+  elif ( ${ExitFlag} ) ; then
+    status=failed
+    mailText=jobEnd.mail
+  else
+    status=completed
+    mailText=jobEnd.mail
+  fi
+
+  # Update selected mail template
+  while read -r line; do
+    eval echo $line >> mail.txt ;
+  done < ${libIGCM}/libIGCM_sys/${mailText}
+
+  if [ ! -z ${config_UserChoices_MailName} ] ; then
+    mailx -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} < mail.txt
+  elif [ -f ~/.forward ] ; then
+    mailx -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < mail.txt
+  fi
+
+  sleep 10
+  rm -f mail.txt
+
+  IGCM_debug_PopStack "IGCM_sys_SendMail"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Mkdir
+#D-* Purpose: Master locale mkdir command
+#D-* Examples:
+#D-
+function IGCM_sys_Mkdir {
+  IGCM_debug_PushStack "IGCM_sys_Mkdir" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Mkdir :" $@
+  fi
+  if [ ! -d ${1} ]; then
+    \mkdir -p $1
+    if [ $? -gt 0 ] ; then
+      echo "IGCM_sys_Mkdir : erreur."
+      IGCM_debug_Exit "IGCM_sys_Mkdir"
+    fi
+  fi
+  # vérification :
+  if [ ! -d ${1} ] ; then
+    echo "IGCM_sys_Mkdir : erreur."
+    IGCM_debug_Exit "IGCM_sys_Mkdir"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Mkdir"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_MkdirArchive
+#D-* Purpose: Mkdir on Archive
+#D-* Examples:
+#D-
+function IGCM_sys_MkdirArchive {
+  IGCM_debug_PushStack "IGCM_sys_MkdirArchive" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_MkdirArchive :" $@
+  fi
+  #- creation de repertoire sur le serveur fichier
+  if [ ! -d ${1} ]; then
+    mkdir -p $1
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_MkdirArchive : mkdir failed error code ${status}"
+      IGCM_debug_Exit "IGCM_sys_MkdirArchive"
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_MkdirArchive"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_MkdirWork
+#D-* Purpose: Mkdir on Work
+#D-* Examples:
+#D-
+function IGCM_sys_MkdirWork {
+  IGCM_debug_PushStack "IGCM_sys_MkdirWork" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_MkdirWork :" $@
+  fi
+  #- creation de repertoire sur le serveur fichier
+  if [ ! -d ${1} ]; then
+    \mkdir -p $1
+    if [ $? -gt 0 ] ; then
+      echo "IGCM_sys_MkdirWork : erreur."
+      IGCM_debug_Exit "IGCM_sys_MkdirWork"
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_MkdirWork"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Cd
+#D-* Purpose: master cd command
+#D-* Examples:
+#D-
+function IGCM_sys_Cd {
+  IGCM_debug_PushStack "IGCM_sys_Cd" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Cd :" $@
+  fi
+  \cd $1
+  if [ $? -gt 0 ] ; then
+    echo "IGCM_sys_Cd : erreur."
+    IGCM_debug_Exit "IGCM_sys_Cd"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Cd"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Chmod
+#D-* Purpose: Chmod
+#D-* Examples:
+#D-
+function IGCM_sys_Chmod {
+  IGCM_debug_PushStack "IGCM_sys_Chmod" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Chmod :" $@
+  fi
+  \chmod $@
+  if [ $? -gt 0 ] ; then
+    echo "IGCM_sys_Chmod : erreur."
+    IGCM_debug_Exit "IGCM_sys_Chmod"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Chmod"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_FileSize
+#D-* Purpose: Filesize
+#D-* Examples:
+#D-
+function IGCM_sys_FileSize {
+  IGCM_debug_PushStack "IGCM_sys_FileSize" $@
+
+  typeset sizeF
+  set +A sizeF -- $( ls -la ${1} )
+  if [ $? -gt 0 ] ; then
+    IGCM_debug_Exit "IGCM_sys_FileSize"
+  fi
+  eval ${2}=${sizeF[4]}
+
+  IGCM_debug_PopStack "IGCM_sys_FileSize"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_TestDir
+#D-* Purpose: Test Directory that must exists
+#D-* Examples:
+#D-
+function IGCM_sys_TestDir {
+  IGCM_debug_PushStack "IGCM_sys_TestDir" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_TestDir :" $@
+  fi
+  typeset ExistFlag
+  ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
+  IGCM_debug_PopStack "IGCM_sys_TestDir"
+
+  return ${ExistFlag}
+}
+
+#D-#==================================================
+#D-function IGCM_sys_TestDirArchive
+#D-* Purpose: Test Directory that must exists on Archive
+#D-* Examples:
+#D-
+function IGCM_sys_TestDirArchive {
+  IGCM_debug_PushStack "IGCM_sys_TestDirArchive" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_TestDirArchive :" $@
+  fi
+  typeset ExistFlag
+  ExistFlag=$( [ -d $1 ] && echo 0 || echo 1 )
+  IGCM_debug_PopStack "IGCM_sys_TestDirArchive"
+  return ${ExistFlag}
+}
+
+#D-#==================================================
+#D-function IGCM_sys_IsFileArchived
+#D-* Purpose: Test file that must NOT EXISTS on Archive
+#D-* Examples:
+#D-
+function IGCM_sys_IsFileArchived {
+  IGCM_debug_PushStack "IGCM_sys_IsFileArchived" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_IsFileArchived :" $@
+  fi
+  typeset IsArchivedFlag
+  # Never archived for this system
+  IsArchivedFlag=1
+  IGCM_debug_PopStack "IGCM_sys_IsFileArchived"
+
+  return ${IsArchivedFlag}
+}
+
+#D-#==================================================
+#D-function IGCM_sys_TestFileArchive
+#D-* Purpose: Test file that must NOT EXISTS on Archive
+#D-* Examples:
+#D-
+function IGCM_sys_TestFileArchive {
+  IGCM_debug_PushStack "IGCM_sys_TestFileArchive" $@
+  typeset ExistFlag
+  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 )
+  IGCM_debug_PopStack "IGCM_sys_TestFileArchive"
+
+  return ${ExistFlag}
+}
+
+#D-#==================================================
+#D-function IGCM_sys_TestFileBuffer
+#D-* Purpose: Test file that must NOT EXISTS on Buffer
+#D-* Examples:
+#D-
+function IGCM_sys_TestFileBuffer {
+  IGCM_debug_PushStack "IGCM_sys_TestFileBuffer" $@
+  typeset ExistFlag
+  ExistFlag=$( [ -f $1 ] && echo 0 || echo 1 )
+  IGCM_debug_PopStack "IGCM_sys_TestFileBuffer"
+
+  return ${ExistFlag}
+}
+
+#D-#==================================================
+#D-function IGCM_sys_CountFileArchive
+#D-* Purpose: Count files on Archive filesystem
+#D-* Examples:
+#D-
+function IGCM_sys_CountFileArchive {
+  IGCM_debug_PushStack "IGCM_sys_CountFileArchive" $@
+  ls ${@} 2>/dev/null | wc -l
+  if [ $? -gt 0 ] ; then
+    echo "IGCM_sys_CountFileArchive : erreur."
+  fi
+  IGCM_debug_PopStack "IGCM_sys_CountFileArchive"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_CountFileBuffer
+#D-* Purpose: Count files on Scratch filesystem
+#D-* Examples:
+#D-
+function IGCM_sys_CountFileBuffer {
+  IGCM_debug_PushStack "IGCM_sys_CountFileBuffer" $@
+  ls ${@} 2>/dev/null | wc -l
+  if [ $? -gt 0 ] ; then
+    echo "IGCM_sys_CountFileBuffer : erreur."
+  fi
+  IGCM_debug_PopStack "IGCM_sys_CountFileBuffer"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Tree
+#D-* Purpose: Tree directories with files on ${ARCHIVE}
+#D-* Examples: IGCM_sys_Tree ${R_IN} ${R_OUT}
+#D-
+function IGCM_sys_Tree {
+  IGCM_debug_PushStack "IGCM_sys_Tree" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Tree :" $@
+  fi
+
+  \tree -f $@
+
+  IGCM_debug_PopStack "IGCM_sys_Tree"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Tar
+#D-* Purpose: master tar command
+#D-* Examples:
+#D-
+function IGCM_sys_Tar {
+  IGCM_debug_PushStack "IGCM_sys_Tar" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Tar :" $@
+  fi
+  \tar cf $@
+  if [ $? -gt 0 ] ; then
+    echo "IGCM_sys_Tar : erreur."
+    IGCM_debug_Exit "IGCM_sys_Tar"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Tar"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_UnTar
+#D-* Purpose: master un-tar command
+#D-* Examples:
+#D-
+function IGCM_sys_UnTar {
+  IGCM_debug_PushStack "IGCM_sys_UnTar" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_UnTar :" $@
+  fi
+  \tar xvf $1
+  if [ $? -gt 0 ] ; then
+    echo "IGCM_sys_UnTar : erreur."
+    IGCM_debug_Exit "IGCM_sys_UnTar"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_UnTar"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Qsub
+#D-* Purpose: Qsub new job
+#D-* Examples:
+#D-
+function IGCM_sys_Qsub {
+  IGCM_debug_PushStack "IGCM_sys_Qsub" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Qsub :" $@
+  fi
+  typeset options status
+  options="-o ${SUBMIT_DIR}/${Script_Output}"
+  /usr/local/bin/qsub ${options} $1 > /tmp/out_command_${LOGIN}.$$ 2>&1
+  status=$?
+
+  cat /tmp/out_command_${LOGIN}.$$
+  if [ ${status} -gt 0 ] ; then
+    IGCM_debug_Print 2 "IGCM_sys_Qsub $1 : error code ${status}"
+    IGCM_debug_Exit "IGCM_sys_Qsub"
+  else
+    JobID=$( gawk {'print $1'} /tmp/out_command_${LOGIN}.$$ )
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Qsub"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_QsubPost
+#D-* Purpose: Qsub new job on scalaire
+#D-* Examples:
+#D-
+function IGCM_sys_QsubPost {
+  IGCM_debug_PushStack "IGCM_sys_QsubPost" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_QsubPost :" $@
+  fi
+  typeset options status
+  options="-o ${POST_DIR}/${Script_Post_Output}.out -v ${listVarEnv}"
+  /usr/local/bin/qsub ${options} ${libIGCM_POST}/$1.job > /tmp/out_command_${LOGIN}.$$ 2>&1
+  status=$?
+
+  cat /tmp/out_command_${LOGIN}.$$
+  if [ ${status} -gt 0 ] ; then
+    IGCM_debug_Print 2 "IGCM_sys_QsubPost ${options} ${libIGCM_POST}/$1.job : error code ${status}"
+    IGCM_debug_Exit "IGCM_sys_QsubPost"
+  else
+    JobID=$( gawk {'print $1'} /tmp/out_command_${LOGIN}.$$ )
+  fi
+  IGCM_debug_PopStack "IGCM_sys_QsubPost"
+}
+
+#D-*************************
+#D- File transfer functions
+#D-*************************
+#D-
+
+#D-#==================================================
+#D-function IGCM_sys_Rsync_out
+#D-* Purpose: treat return val of rsync
+#D-* Examples: IGCM_sys_Rsync_out out_RET_rsync
+#D-  Error values and explanations can depend on your system version.
+function IGCM_sys_Rsync_out {
+  status=$1
+  if [ ! $status ] ; then
+    echo "rsync error !"
+  fi
+
+  if [ $MYLANG = "fr" ]; then
+    case $status in
+    0)  return ;;
+    1)  echo "Erreur de rsync ; RERR_SYNTAX : "
+      echo "Erreur de syntaxe ou d'utilisation."
+      return;;
+    2)  echo "Erreur de rsync ; RERR_PROTOCOL : "
+      echo "Incompatibilité de protocole."
+      return;;
+    3)  echo "Erreur de rsync ; RERR_FILESELECT 3"
+      echo "Erreurs  lors  de  la  sélection des fichiers d'entrée sortie et"
+      echo "répertoires"
+      return;;
+    4)  echo "Erreur de rsync ; RERR_UNSUPPORTED"
+      echo "Action demandée non supportée : une tentative de manipulation de"
+      echo "fichiers  64-bits  sur une plate-forme qui ne les supporte pas a"
+      echo "été faite ; ou une option qui est supportée par le  client  mais"
+      echo "pas par le serveur a été spécifiée."
+      return;;
+    10) echo "Erreur de rsync ; RERR_SOCKETIO"
+      echo "Erreur dans le socket d'entrée sortie"
+      return;;
+    11) echo "Erreur de rsync ; RERR_FILEIO"
+      echo "Erreur d'entrée sortie fichier"
+      return;;
+    12) echo "Erreur de rsync ; RERR_STREAMIO"
+      echo "Erreur dans flux de donnée du protocole rsync"
+      return;;
+    13) echo "Erreur de rsync ; RERR_MESSAGEIO"
+      echo "Erreur avec les diagnostics du programme"
+      return;;
+    14) echo "Erreur de rsync ; RERR_IPC"
+      echo "Erreur dans le code IPC"
+      return;;
+    20) echo "Erreur de rsync ; RERR_SIGNAL"
+      echo "SIGUSR1 ou SIGINT reçu"
+      return;;
+    21) echo "Erreur de rsync ; RERR_WAITCHILD"
+      echo "Une erreur retournée par waitpid()"
+      return;;
+    22) echo "Erreur de rsync ; RERR_MALLOC"
+      echo "Erreur lors de l'allocation des tampons de mémoire de coeur"
+      return;;
+    23) echo ""
+      echo "Erreur fichier inexistant"
+      return;;
+    30) echo "Erreur de rsync ; RERR_TIMEOUT"
+      echo "Temps d'attente écoulé dans l'envoi/réception de données"
+      return;;
+    *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $status
+      return;;
+    esac
+  elif [ $MYLANG = "en" ] ; then
+    case $status in
+    0)  return;;
+    1)  echo "rsync error : Syntax or usage error "
+      return;;
+    2)  echo "rsync error : Protocol incompatibility "
+      return;;
+    3)  echo "rsync error : Errors selecting input/output files, dirs"
+      return;;
+    4)  echo "rsync error : Requested action not supported: an attempt"
+      echo "was made to manipulate 64-bit files on a platform that cannot support"
+      echo "them; or an option was specified that is supported by the client and"
+      echo "not by the server."
+      return;;
+    5)  echo "rsync error : Error starting client-server protocol"
+      return;;
+    10) echo "rsync error : Error in socket I/O "
+      return;;
+    11) echo "rsync error : Error in file I/O "
+      return;;
+    12) echo "rsync error : Error in rsync protocol data stream "
+      return;;
+    13) echo "rsync error : Errors with program diagnostics "
+      return;;
+    14) echo "rsync error : Error in IPC code "
+      return;;
+    20) echo "rsync error : Received SIGUSR1 or SIGINT "
+      return;;
+    21) echo "rsync error : Some error returned by waitpid() "
+      return;;
+    22) echo "rsync error : Error allocating core memory buffers "
+      return;;
+    23) echo "rsync error : Partial transfer due to error"
+      return;;
+    24) echo "rsync error : Partial transfer due to vanished source files"
+      return;;
+    30) echo "rsync error : Timeout in data send/receive "
+      return;;
+    *)  echo "rsync error : return code of rsync unknown :" $status
+      return;;
+    esac
+  else
+    echo "unknown language $MYLANG."
+    return
+  fi
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Miror_libIGCM
+#D-* Purpose: Mirror libIGCM PATH and lib to frontend
+#D-* Examples:
+#D-
+function IGCM_sys_Mirror_libIGCM {
+  IGCM_debug_PushStack "IGCM_sys_Mirror_libIGCM"
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Mirror_libIGCM"
+  fi
+
+  typeset status
+
+  mkdir -p ${HOME}/MIRROR/${PATHlibIGCM}
+
+  echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > /tmp/out_command_${LOGIN}.$$ 2>&1
+  ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> /tmp/out_command_${LOGIN}.$$ 2>&1
+  status=$?
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on frontend."
+    cat /tmp/out_command_${LOGIN}.$$
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Mirror_libIGCM"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Cp
+#D-* Purpose: generic cp
+#D-* Examples:
+#D-
+function IGCM_sys_Cp {
+  IGCM_debug_PushStack "IGCM_sys_Cp" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Cp :" $@
+  fi
+
+  typeset status
+
+  echo cp $@ > /tmp/out_command_${LOGIN}.$$ 2>&1
+  \cp $@ >> /tmp/out_command_${LOGIN}.$$ 2>&1
+  status=$?
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_Cp : error code ${status}"
+    cat /tmp/out_command_${LOGIN}.$$
+    IGCM_debug_Exit "IGCM_sys_Cp"
+  else
+    \rm /tmp/out_command_${LOGIN}.$$
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Cp"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Rm
+#D-* Purpose: generic rm
+#D-* Examples:
+#D-
+function IGCM_sys_Rm {
+  IGCM_debug_PushStack "IGCM_sys_Rm" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Rm :" $@
+  fi
+
+  typeset status
+
+  echo rm $@ > /tmp/out_command_${LOGIN}.$$ 2>&1
+  \rm $@ >> /tmp/out_command_${LOGIN}.$$ 2>&1
+  status=$?
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_Rm : error code ${status}"
+    cat /tmp/out_command_${LOGIN}.$$
+    IGCM_debug_Exit "IGCM_sys_Rm"
+  else
+    \rm /tmp/out_command_${LOGIN}.$$
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Rm"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_RmRunDir
+#D-* Purpose: rm tmpdir (dummy function most of the time batch
+#D-                      scheduler will do the job)
+#D-* Examples:
+#D-
+function IGCM_sys_RmRunDir {
+  IGCM_debug_PushStack "IGCM_sys_RmRunDir" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_RmRunDir :" $@
+    echo "Dummy call, let the scheduler do that."
+  fi
+  IGCM_debug_PopStack "IGCM_sys_RmRunDir"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Mv
+#D-* Purpose: generic move
+#D-* Examples:
+#D-
+function IGCM_sys_Mv {
+  IGCM_debug_PushStack "IGCM_sys_Mv" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Mv :" $@
+  fi
+
+  if [ $DRYRUN = 0 ]; then
+
+    typeset status
+
+    echo mv $@ > /tmp/out_command_${LOGIN}.$$ 2>&1
+    \mv $@ >> /tmp/out_command_${LOGIN}.$$ 2>&1
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_Mv : error code ${status}"
+      cat /tmp/out_command_${LOGIN}.$$
+      IGCM_debug_Exit "IGCM_sys_Mv"
+    else
+      \rm /tmp/out_command_${LOGIN}.$$
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Mv"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Put_Dir
+#D-* Purpose: Copy a complete directory on $(ARCHIVE)
+#D-* Examples:
+#D-
+function IGCM_sys_Put_Dir {
+  IGCM_debug_PushStack "IGCM_sys_Put_Dir" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Put_Dir :" $@
+  fi
+  if [ $DRYRUN = 0 ]; then
+    if [ ! -d ${1} ] ; then
+      echo "WARNING : IGCM_sys_Put_Dir ${1} DOES NOT EXIST ."
+      IGCM_debug_PopStack "IGCM_sys_Put_Dir"
+      return
+    fi
+
+    typeset status
+
+    # Only if we use rsync
+    #IGCM_sys_TestDirArchive $( dirname $2 )
+    #
+    #USUAL WAY
+    \cp -r $1 $2 > /tmp/out_command_${LOGIN}.$$ 2>&1
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_Put_Dir : cp failed error code ${status}"
+      cat /tmp/out_command_${LOGIN}.$$
+      IGCM_debug_Exit "IGCM_sys_Put_Dir"
+    else
+      \rm /tmp/out_command_${LOGIN}.$$
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Put_Dir"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Get_Dir
+#D-* Purpose: Copy a complete directory from ${ARCHIVE}
+#D-* Examples:
+#D-
+function IGCM_sys_Get_Dir {
+  IGCM_debug_PushStack "IGCM_sys_Get_Dir" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Get_Dir :" $@
+  fi
+  if [ $DRYRUN = 0 ]; then
+    if [ ! -d ${1} ] ; then
+      echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ."
+      IGCM_debug_PopStack "IGCM_sys_Get_Dir"
+      return
+    fi
+
+    typeset status
+
+    #USUAL WAY
+    \cp -ur $1 $2 > /tmp/out_command_${LOGIN}.$$ 2>&1
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_Get_Dir : cp failed error code ${status}"
+      cat /tmp/out_command_${LOGIN}.$$
+      IGCM_debug_Exit "IGCM_sys_Get_Dir"
+    else
+      \rm /tmp/out_command_${LOGIN}.$$
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Get_Dir"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Get_Master
+#D-* Purpose: Copy a complete directory from MASTER filesystem
+#D-* Examples:
+#D-
+function IGCM_sys_Get_Master {
+  IGCM_debug_PushStack "IGCM_sys_Get_Master" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Get_Master :" $@
+  fi
+  if [ $DRYRUN = 0 ]; then
+    if ( [ ! -d ${1} ] && [ ! -f ${1} ] ) ; then
+      echo "WARNING : IGCM_sys_Get_Master ${1} DOES NOT EXIST ."
+      IGCM_debug_PopStack "IGCM_sys_Get_Master"
+      return
+    fi
+
+    typeset NB_ESSAI DELAI status i
+    # number of tentative
+    NB_ESSAI=3
+    # time delay between tentative
+    DELAI=2
+
+    i=0
+    while [ $i -lt $NB_ESSAI ] ; do
+      \cp -urL $1 $2 > /tmp/out_command_${LOGIN}.$$ 2>&1
+      status=$?
+      if [ ${status} -gt 0 ]; then
+        IGCM_debug_Print 2 "IGCM_sys_Get_Master : cp failed error code ${status} ${i}/${NB_ESSAI}"
+        IGCM_debug_Print 2 "IGCM_sys_Get_Master : sleep ${DELAI} seconds and try again."
+        sleep $DELAI
+      else
+        break
+      fi
+      (( i = i + 1 ))
+    done
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_Get_Master : error."
+      cat /tmp/out_command_${LOGIN}.$$
+      IGCM_debug_Exit "IGCM_sys_Get_Master"
+    else
+      \rm /tmp/out_command_${LOGIN}.$$
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Get_Master"
+}
+
+#====================================================
+#- Call IGCM_sys_Mirror_libIGCM now !
+if ( $MirrorlibIGCM ) ; then
+  IGCM_sys_Mirror_libIGCM
+fi
+
+#D-#==================================================
+#D-function IGCM_sys_Put_Rest
+#D-* Purpose: Put computied restarts on ${ARCHIVE}.
+#D-           File and target directory must exist.
+#D-* Examples:
+#D-
+function IGCM_sys_Put_Rest {
+  IGCM_debug_PushStack "IGCM_sys_Put_Rest" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Put_Rest :" $@
+  fi
+  if [ $DRYRUN = 0 ]; then
+    if [ ! -f ${1} ] ; then
+      echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ."
+      IGCM_debug_Exit "IGCM_sys_Put_Rest"
+    fi
+
+    typeset status
+    #
+    if [ X${JobType} = XRUN ] ; then
+      IGCM_sys_Chmod 444 ${1}
+    fi
+    #
+    # Only if we use rsync
+    #IGCM_sys_MkdirArchive $( dirname $2 )
+    #
+    #USUAL WAY
+    \cp $1 $2 > /tmp/out_command_${LOGIN}.$$ 2>&1
+    status=$?
+
+#       #RSYNC WITH NETWORK SSH CALL
+#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > /tmp/out_command_${LOGIN}.$$ 2>&1
+#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> /tmp/out_command_${LOGIN}.$$ 2>&1
+
+#       #RSYNC WITH NFS USE
+#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > /tmp/out_command_${LOGIN}.$$ 2>&1
+#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> /tmp/out_command_${LOGIN}.$$ 2>&1
+
+#       status=$?
+#       IGCM_sys_Rsync_out $status
+
+#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk /tmp/out_command_${LOGIN}.$$
+#       (( status=status+$? ))
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_Put_Rest : cp failed error code ${status}"
+      cat /tmp/out_command_${LOGIN}.$$
+      IGCM_debug_Exit "IGCM_sys_Put_Rest"
+    else
+      \rm /tmp/out_command_${LOGIN}.$$
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Put_Rest"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_PutBuffer_Rest
+#D-* Purpose: Put computied restarts on ${SCRATCHDIR}.
+#D-           File and target directory must exist.
+#D-* Examples:
+#D-
+function IGCM_sys_PutBuffer_Rest {
+  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Rest" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_PutBuffer_Rest :" $@
+  fi
+  if [ $DRYRUN = 0 ]; then
+    if [ ! -f ${1} ] ; then
+      echo "ERROR : IGCM_sys_PutBuffer_Rest ${1} DOES NOT EXIST ."
+      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest"
+    fi
+
+    typeset status
+    #
+    if [ X${JobType} = XRUN ] ; then
+      IGCM_sys_Chmod 444 ${1}
+    fi
+
+    #
+    # USUAL WAY
+    \cp $1 $2 > /tmp/out_command_${LOGIN}.$$ 2>&1
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_PutBuffer_Rest : error code ${status}"
+      [ -f ${2} ] && ls -l ${2}
+      [ -f ${2}/${1} ] && ls -l ${2}/${1}
+      cat /tmp/out_command_${LOGIN}.$$
+      IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest"
+    else
+      \rm /tmp/out_command_${LOGIN}.$$
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Rest"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_PrepareTaredRestart
+#D-* Purpose: Prepare tared restart to be access by computing job. Identity here.
+#D-* Examples:
+#D-
+function IGCM_sys_PrepareTaredRestart {
+  IGCM_debug_PushStack "IGCM_sys_PrepareTaredRestart" $@
+
+  IGCM_debug_PopStack "IGCM_sys_PrepareTaredRestart"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Put_Out
+#D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly
+#D-* Examples:
+#D-
+function IGCM_sys_Put_Out {
+  IGCM_debug_PushStack "IGCM_sys_Put_Out" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Put_Out :" $@
+  fi
+
+  typeset status
+
+  if [ $DRYRUN = 0 ]; then
+    if [ ! -f ${1} ] ; then
+      echo "WARNING : IGCM_sys_Put_Out ${1} DOES NOT EXIST ."
+      IGCM_debug_PopStack "IGCM_sys_Put_Out"
+      return 1
+    fi
+    #
+    IGCM_sys_MkdirArchive $( dirname $2 )
+    #
+    if [ X${JobType} = XRUN ] ; then
+      if [ X${3} = X ] ; then
+        IGCM_sys_Chmod 444 ${1}
+      fi
+    fi
+    #
+
+    echo ${RSYNC} ${RSYNC_opt} $1 $2 > /tmp/out_command_${LOGIN}.$$ 2>&1
+    ${RSYNC} ${RSYNC_opt} $1 $2 >> /tmp/out_command_${LOGIN}.$$ 2>&1
+    status=$?
+    IGCM_sys_Rsync_out $status
+
+    ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk /tmp/out_command_${LOGIN}.$$
+    (( status=status+$? ))
+
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_Put_Out : rsync failed error code ${status}"
+      cat /tmp/out_command_${LOGIN}.$$
+      IGCM_debug_Exit "IGCM_sys_Put_Out"
+    else
+      \rm /tmp/out_command_${LOGIN}.$$
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Put_Out"
+  return 0
+}
+
+#D-#==================================================
+#D-function IGCM_sys_PutBuffer_Out
+#D-* Purpose: Copy a file on ${SCRATCHDIR} after having chmod it in readonly
+#D-* Examples:
+#D-
+function IGCM_sys_PutBuffer_Out {
+  IGCM_debug_PushStack "IGCM_sys_PutBuffer_Out" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_PutBuffer_Out :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i exist skip
+
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  if [ $DRYRUN = 0 ]; then
+    if [ ! -f ${1} ] ; then
+      echo "WARNING : IGCM_sys_PutBuffer_Out ${1} DOES NOT EXIST ."
+      IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out"
+      return 1
+    fi
+    #
+    IGCM_sys_Mkdir $( dirname $2 )
+    #
+
+    exist=false
+    skip=false
+    if [ -f $2 ] ; then
+      IGCM_debug_Print 1 "$2 already exist"
+      exist=true
+      if [ "X$( diff $1 $2 )" = X ] ; then
+        IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy"
+        status=0
+        skip=true
+      else
+        IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy"
+        skip=false
+      fi
+    fi
+    #
+    if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then
+      IGCM_sys_Chmod u+w $2
+    fi
+
+    if [ X${skip} = Xfalse ] ; then
+      i=0
+      while [ $i -lt $NB_ESSAI ] ; do
+        # USUAL WAY
+        \cp $1 $2 > /tmp/out_command_${LOGIN}.$$ 2>&1
+        status=$?
+        if [ ${status} -gt 0 ]; then
+          IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : cp failed error code ${status} ${i}/${NB_ESSAI}"
+          IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : sleep ${DELAI} seconds and try again."
+          [ -f ${2} ] && ls -l ${2}
+          [ -f ${2}/${1} ] && ls -l ${2}/${1}
+          sleep $DELAI
+        else
+          break
+        fi
+        (( i = i + 1 ))
+      done
+    fi
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_PutBuffer_Out : error."
+      [ -f ${2} ] && ls -l ${2}
+      [ -f ${2}/${1} ] && ls -l ${2}/${1}
+      cat /tmp/out_command_${LOGIN}.$$
+      IGCM_debug_Exit "IGCM_sys_PutBuffer_Out"
+    else
+
+      if [ X${JobType} = XRUN ] ; then
+        if [ X${3} = X ] ; then
+          [ -f ${2} ] && IGCM_sys_Chmod 444 ${2}
+          [ -f ${2}/${1} ] && IGCM_sys_Chmod 444 ${2}/${1}
+        fi
+      fi
+
+      \rm /tmp/out_command_${LOGIN}.$$
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_PutBuffer_Out"
+  return 0
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Get
+#D-* Purpose: Get a file from ${ARCHIVE}
+#D-* Examples: IGCM_sys_Get myfile /destpath/myfile_with_PREFIX
+#D-            IGCM_sys_Get /l Array_contain_myfiles /destpath/
+function IGCM_sys_Get {
+  IGCM_debug_PushStack "IGCM_sys_Get" $@
+
+  typeset DEST status dm_liste
+
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Get :" $@
+  fi
+  if [ $DRYRUN -le 2 ]; then
+    if [ X${1} = X'/l' ] ; then
+      eval set +A dm_liste \${${2}}
+    else
+      dm_liste=${1}
+    fi
+    eval DEST=\${${#}}
+
+    # test if the (first) file is present in the old computation :
+    IGCM_sys_TestFileArchive ${dm_liste[0]}
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ."
+      IGCM_debug_Exit "IGCM_sys_Get"
+      return
+    fi
+
+    #USUAL WAY
+    \cp ${dm_liste[*]} ${DEST} > /tmp/out_command_${LOGIN}.$$ 2>&1
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_Get : cp failed error code ${status}"
+      cat /tmp/out_command_${LOGIN}.$$
+      IGCM_debug_Exit "IGCM_sys_Get"
+    else
+      \rm /tmp/out_command_${LOGIN}.$$
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Get"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_GetBuffer
+#D-* Purpose: Get a file from ${SCRATCHDIR}
+#D-* Examples: IGCM_sys_GetBuffer myfile /destpath/myfile_with_PREFIX
+#D-            IGCM_sys_GetBuffer /l Array_contain_myfiles /destpath/
+function IGCM_sys_GetBuffer {
+  IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@
+
+  typeset DEST buf_liste target file_work
+  typeset NB_ESSAI DELAI status i
+
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_GetBuffer :" $@
+  fi
+
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  if [ $DRYRUN -le 2 ]; then
+    if [ X${1} = X'/l' ] ; then
+      eval set +A buf_liste \${${2}}
+    else
+      eval set +A buf_liste ${1}
+    fi
+    eval DEST=\${${#}}
+
+    #USUAL WAY
+    if [ X${1} = X'/l' ] ; then
+      for target in ${buf_liste[*]} ; do
+        local_file=$( basename ${target} )
+        i=0
+        while [ $i -lt $NB_ESSAI ] ; do
+          \cp ${target} ${DEST}/${local_file} >> /tmp/out_command_${LOGIN}.$$ 2>&1
+          status=$?
+          if [ ${status} -gt 0 ]; then
+            IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}"
+            IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again."
+            sleep $DELAI
+          else
+            break
+          fi
+          (( i = i + 1 ))
+        done
+        if [ ${status} -gt 0 ] ; then
+          echo "IGCM_sys_Get : error"
+          cat /tmp/out_command_${LOGIN}.$$
+          \rm /tmp/out_command_${LOGIN}.$$
+          IGCM_debug_Exit "IGCM_sys_GetBuffer"
+        else
+          \rm /tmp/out_command_${LOGIN}.$$
+        fi
+      done
+    else
+      i=0
+      while [ $i -lt $NB_ESSAI ] ; do
+        \cp ${buf_liste} ${DEST} >> /tmp/out_command_${LOGIN}.$$ 2>&1
+        status=$?
+        if [ ${status} -gt 0 ]; then
+          IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}"
+          IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again."
+          sleep $DELAI
+        else
+          break
+        fi
+        (( i = i + 1 ))
+      done
+      if [ ${status} -gt 0 ] ; then
+        echo "IGCM_sys_Get : error"
+        cat /tmp/out_command_${LOGIN}.$$
+        \rm /tmp/out_command_${LOGIN}.$$
+        IGCM_debug_Exit "IGCM_sys_GetBuffer"
+      else
+        \rm /tmp/out_command_${LOGIN}.$$
+      fi
+    fi
+  fi
+  IGCM_debug_PopStack "IGCM_sys_GetBuffer"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_GetDate_FichWork
+#D-* Purpose: donne la date filesys d'un fichier sur le filesystem WORK
+#D-* Examples:
+#D-
+function IGCM_sys_GetDate_FichWork {
+  IGCM_debug_PushStack "IGCM_sys_FichWork" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_GetDate_FichWork :" $@
+  fi
+  typeset dateF
+  set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} )
+  eval ${2}=${dateF[5]}
+
+  # donne la date filesys d'un fichier sur la machine work
+  IGCM_debug_PopStack "IGCM_sys_FichWork"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_GetDate_FichArchive
+#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE
+#D-* Examples:
+#D-
+function IGCM_sys_GetDate_FichArchive {
+  IGCM_debug_PushStack "IGCM_sys_FichArchive" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_GetDate_FichArchive :" $@
+  fi
+  typeset dateF
+  set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} )
+  eval ${2}=${dateF[5]}
+
+  IGCM_debug_PopStack "IGCM_sys_FichArchive"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Dods_Rm
+#D-* Purpose: DO NOTHING ! Put ${ARCHIVE} files on DODS internet protocole.
+#D-* Examples:
+#D-
+function IGCM_sys_Dods_Rm {
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Dods_Rm :" $@
+  fi
+  return 0
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Dods_Cp
+#D-* Purpose: Copy $(ARCHIVE) files on DODS internet protocole.
+#D-* Examples:
+#D-
+function IGCM_sys_Dods_Cp {
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Dods_Cp :" $@
+  fi
+  return 0
+}
+
+#D-#==================================================
+#D-function IGCM_sys_Put_Dods
+#D-* Purpose: Put ${ARCHIVE} files on DODS internet protocole. Dummy function here
+#D-* Examples:
+#D-
+function IGCM_sys_Put_Dods {
+  IGCM_debug_PushStack "IGCM_sys_Put_Dods" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_Put_Dods :" $@
+  fi
+  IGCM_debug_PopStack "IGCM_sys_Put_Dods"
+}
+
+##############################################################
+# REBUILD OPERATOR
+
+#D-#==================================================
+#D-function IGCM_sys_rebuild
+#D-* Purpose: rebuild parallel files
+#D-* Examples:
+#D-
+function IGCM_sys_rebuild {
+  IGCM_debug_PushStack "IGCM_sys_rebuild" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_rebuild :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i firstArg
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    /home/users/igcmg/rebuild/bin/rebuild -f -o $@ > /tmp/out_command_${LOGIN}.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_rebuild : error code ${status}"
+      cat /tmp/out_command_${LOGIN}.$$
+      \rm /tmp/out_command_${LOGIN}.$$
+      IGCM_debug_Print 2 "IGCM_sys_rebuild : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      firstArg=${1}
+      \rm ${firstArg}
+      sleep $DELAI
+    else
+      \rm /tmp/out_command_${LOGIN}.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_rebuild : rebuild error code is ${status}"
+    IGCM_debug_Exit "rebuild"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_rebuild"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_rebuild_station
+#D-* Purpose: rebuild parallel files describing station
+#D-* Examples:
+#D-
+function IGCM_sys_rebuild_station {
+  IGCM_debug_PushStack "IGCM_sys_rebuild_station" -- $@
+  typeset i list_opt file_in file_out prefix_invert list_invert
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_rebuild_station :" $@
+  fi
+  list_opt=$@
+
+  # Invert Axis : t,x -> x,t
+  #               t,pres,x -> x,t,pres
+  # So that we can concatenate along x
+  i=0
+  for file_in in ${list_opt} ; do
+    (( i = i + 1))
+    [ ${i} = 1 ] && file_out=${file_in} && continue
+    prefix_invert=$( basename ${file_in} .nc )
+    IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs ${file_in} ${prefix_invert}_xt.nc
+    list_invert[${#list_invert[*]}]=${prefix_invert}_xt.nc
+  done
+
+  # Concatenate
+  IGCM_sys_ncrcat ${list_invert[*]} histstn_xt.nc
+
+  # Re-ivert file
+  IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x histstn_xt.nc ${file_out}
+
+  # Station re-ordering is too expansive to be run within libIGCM
+  # This is due to (ncpdq - nrcat - ncpdq) I/O sequence.
+  # This re-ordering must be done "in memory" by the cmorization process
+  # Anyway this is the best sequence using (ncpdq - nrcat - ncpdq)
+  # BEGIN reordering
+
+  # Only LMDZ text output contains the exact ordering of the station.
+  # We isolate this in the code below:
+  #  0  38  -157.5000000000000  70.98591549295774
+  #  0  54  27.49999999999999   67.18309859154928
+  #  0  56  -62.50000000000001  82.39436619718309
+  #  0  79  12.49999999999999   78.59154929577466
+  #  0  116 -165.0000000000000  76.05633802816901
+  #  0  117 130.0000000000000   70.98591549295774
+  #  0  118 110.0000000000000   87.46478873239437
+  #  1  40  4.999999999999995   51.97183098591550
+#  typeset iStation iProc list_opt file_in file_out prefix_invert
+#  typeset -Z4 j4
+#  typeset -Z3 j3
+
+#  unset list_opt
+#  set +A list_opt $@
+
+  # Filename after rebuild
+#  file_out=${list_opt[0]}
+  # Prefix of output files
+#  prefix_invert=$( basename ${file_out} .nc )
+  # Number of procs
+#  num_proc=$( grep -i mpi_size ${PREFIX}_${Exe_Output} | wc -l )
+
+#  iProc=0
+#  while [ ${iProc} -lt ${num_proc} ] ; do
+    # Array containing Station as a number
+#    unset proc_stn
+#    set +A proc_stn $( grep "iophy_mpi rank ip lon lat  $iProc" ${PREFIX}_${Exe_Output} | sed -e "s/iophy_mpi rank ip lon lat //g" | gawk ' {print $2}' )
+    # Number of stations produced by processor proc
+#    stationLast=${#proc_stn[*]}
+    # Proc number on 4 digits
+#    j4=${iProc}
+    # Init
+#    iStation=0
+#    while [ ${iStation} -lt ${stationLast} ] ; do
+      # Station number on 3 digits
+#      j3=${proc_stn[${iStation}]}
+      # Extract station
+      # Invert Axis : t,x -> x,t
+      #               t,pres,x -> x,t,pres
+      # So that we can concatenate along x
+#      IGCM_sys_ncpdq -a x,time_counter -a x,time_counter,presnivs -d x,$iStation,$iStation ${prefix_invert}_${j4}.nc ${prefix_invert}_stn_${j3}.nc
+#      (( iStation = iStation + 1 ))
+#    done
+#    (( iProc = iProc + 1 ))
+#  done
+
+  # Concatenate all station along x
+#  IGCM_sys_ncrcat ${prefix_invert}_stn_???.nc ${prefix_invert}_xt.nc
+
+  # Re-invert file
+#  IGCM_sys_ncpdq -a time_counter,x -a time_counter,presnivs,x ${prefix_invert}_xt.nc ${file_out}
+
+  # END reordering
+
+  IGCM_debug_PopStack "IGCM_sys_rebuild_station"
+}
+
+############################################################
+# Activate Running Environnment Variables
+
+#D-#==================================================
+#D-function IGCM_sys_desactiv_variables
+#D-* Purpose: set environement variables prior to execution
+#D-* Examples:
+#D-
+function IGCM_sys_activ_variables {
+  IGCM_debug_PushStack "IGCM_sys_activ_variables"
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_activ_variables"
+  fi
+
+# --------------------------------------------------------------------
+#D- MPI specifications
+# --------------------------------------------------------------------
+
+# --------------------------------------------------------------------
+#D- Other specifications
+# --------------------------------------------------------------------
+
+  IGCM_debug_PopStack "IGCM_sys_activ_variables"
+}
+
+############################################################
+# Desactivate Running Environnment Variables
+
+#D-#==================================================
+#D-function IGCM_sys_desactiv_variables
+#D-* Purpose: unset environement variables after execution
+#D-* Examples:
+#D-
+function IGCM_sys_desactiv_variables {
+  IGCM_debug_PushStack "IGCM_sys_desactiv_variables"
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_desactiv_variables"
+  fi
+# --------------------------------------------------------------------
+#D- MPI specifications
+# --------------------------------------------------------------------
+
+# --------------------------------------------------------------------
+#D- Other specifications
+# --------------------------------------------------------------------
+
+  IGCM_debug_PopStack "IGCM_sys_desactiv_variables"
+}
+
+############################################################
+# Build MPI/OMP scripts run file (dummy function)
+
+#D-#==================================================
+#D-function IGCM_sys_build_run_file
+#D-* Purpose: build run file (deprecated)
+#D-* Examples:
+#D-
+function IGCM_sys_build_run_file {
+
+  IGCM_debug_Print 3 " dummy function : IGCM_sys_build_run_file "
+
+}
+
+############################################################
+# Build MPI/OMP scripts
+
+#D-#==================================================
+#D-function IGCM_sys_build_execution_scripts
+#D-* Purpose: build execution scripts to be launch by ${HOST_MPIRUN_COMMAND}
+#D-* Examples:
+#D-
+function IGCM_sys_build_execution_scripts
+{
+  IGCM_debug_PushStack "IGCM_sys_build_execution_scripts" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_build_execution_scripts " $@
+  fi
+  typeset nodes listnodes init_node start_num init_exec comp ExeNameIn ExeNameOut
+  typeset node_num_current node_current comp_proc_mpi_loc comp_proc_omp_loc
+  typeset num_corempi nombre_restant_node nombre_restant_comp
+
+  if [ ! -f ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} ]  ; then
+    IGCM_debug_Exit "IGCM_sys_obelix build_execution_scripts : Job_${config_UserChoices_JobName} don't exist in SUBMIT_DIR : ${SUBMIT_DIR} "
+  fi
+
+  if ( ${OK_PARA_MPMD} ) ; then
+
+    if [ -f run_file ] ; then
+      IGCM_sys_Rm -f run_file
+    fi
+    touch run_file
+
+    if ( ${OK_PARA_OMP} ) ; then
+
+      #  Hosts treatment
+
+      ${HOST_MPIRUN_COMMAND} hostname | sort | uniq > hosts.tmp
+
+      i=0
+      rm -f hosts
+      IGCM_debug_Print 1 "sys Obelix, Hosts avaible :"
+      for nodes in `cat hosts.tmp` ; do
+        host[$i]=$nodes
+        echo "${host[$i]} slots=1 max_slots=1" >> hosts
+        IGCM_debug_Print 1 ${host[$i]}
+        i=$((i+1))
+      done
+      rm -f hosts.tmp
+
+      listnodes=${host[*]}
+
+      EXECUTION="${HOST_MPIRUN_COMMAND} -hostfile hosts"
+
+      # Initialisation
+
+      init_node=y
+      node_num_current=0
+      start_num=0
+      init_exec=n
+
+      # Test : if oasis is there, we put it at the first position
+
+      for comp in ${config_ListOfComponents[*]} ; do
+
+        if [ "X${comp}" = "XCPL" ]  ; then
+
+          eval ExeNameIn=\${config_Executable_${comp}[0]}
+          eval ExeNameOut=\${config_Executable_${comp}[1]}
+
+          echo "#!/bin/ksh" > script_${ExeNameOut}.ksh
+          echo ""  >> script_${ExeNameOut}.ksh
+          #echo "export KMP_STACKSIZE=3g"  >> script_${ExeNameOut}.ksh
+          #echo "export KMP_LIBRARY=turnaround"  >> script_${ExeNameOut}.ksh
+          #echo "export MKL_SERIAL=YES"  >> script_${ExeNameOut}.ksh
+          echo "./${ExeNameOut} > out_${ExeNameOut}.out 2>out_${ExeNameOut}.err"  >> script_${ExeNameOut}.ksh
+          IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh
+
+          init_node=n
+
+          (( nombre_restant_node = NUM_COREPERNODE - 1 ))
+          node_num_current=0
+          node_current=${host[${node_num_current}]}
+
+          EXECUTION="${EXECUTION} -H ${node_current} -np 1 ./script_${ExeNameOut}.ksh"
+
+          init_exec=y
+          start_num=1
+
+        fi
+
+      done
+
+      # Then loop on the components (except for oasis)
+
+      for comp in ${config_ListOfComponents[*]} ; do
+
+        eval ExeNameIn=\${config_Executable_${comp}[0]}
+        eval ExeNameOut=\${config_Executable_${comp}[1]}
+
+        # Only if we really have an executable for the component :
+        if ( [ "X${ExeNameOut}" != X\"\" ] &&  [ "X${comp}" != "XCPL" ] ) ; then
+
+          eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
+          eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
+
+          echo "#!/bin/ksh" > script_${ExeNameOut}.ksh
+          # echo "set -vx" >> script_${ExeNameOut}.ksh
+          echo ""  >> script_${ExeNameOut}.ksh
+          #echo "export KMP_STACKSIZE=3g"  >> script_${ExeNameOut}.ksh
+          #echo "export KMP_LIBRARY=turnaround"  >> script_${ExeNameOut}.ksh
+          #echo "export MKL_SERIAL=YES"  >> script_${ExeNameOut}.ksh
+          echo "OMP_NUM_THREADS=${comp_proc_omp_loc}" >> script_${ExeNameOut}.ksh
+          echo "(( MYMPIRANK = OMPI_COMM_WORLD_RANK - ${start_num})) " >>  script_${ExeNameOut}.ksh
+          echo "./${ExeNameOut} > out_${ExeNameOut}.out.\${MYMPIRANK} 2>out_${ExeNameOut}.err.\${MYMPIRANK}"  >> script_${ExeNameOut}.ksh
+          IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh
+
+          node_num=0
+
+          # We define the number of MPI process to be assigned for the component
+
+          nombre_restant_comp=${comp_proc_mpi_loc}
+
+          # Loop on the allocated nodes
+
+          for node in ${listnodes} ; do
+
+            # We go to the current node
+            if [ ${node_num} = ${node_num_current} ] ; then
+
+              node_current=${host[${node_num_current}]}
+
+              # If first time on the node : initialisation
+
+              if [ ${init_node} = y ] ; then
+                nombre_restant_node=${NUM_COREPERNODE}
+              fi
+
+              # Test on the number of OMP threads
+
+              if [ ${comp_proc_omp_loc} -gt ${nombre_restant_node} ] ; then
+                (( node_num = node_num + 1 ))
+                node_num_current=${node_num}
+                init_node=y
+                continue
+              fi
+
+              # Number of MPI process to assign
+
+              (( num_corempi = nombre_restant_node / comp_proc_omp_loc ))
+
+              if [ ${num_corempi} -gt ${nombre_restant_comp} ] ; then
+                num_corempi=${nombre_restant_comp}
+              fi
+
+              (( nombre_restant_node = nombre_restant_node - num_corempi * comp_proc_omp_loc ))
+              (( nombre_restant_comp = nombre_restant_comp - num_corempi ))
+
+              if [ ${init_exec} = y ] ; then
+                EXECUTION="${EXECUTION} : -H ${node_current} -np ${num_corempi} ./script_${ExeNameOut}.ksh"
+              else
+                EXECUTION="${EXECUTION} -H ${node_current} -np ${num_corempi} ./script_${ExeNameOut}.ksh"
+                init_exec=y
+              fi
+
+              ((  start_num = num_corempi + start_num ))
+
+            else
+
+              (( node_num = node_num + 1 ))
+              continue
+            fi
+
+            # Test on the number of core/process remaining on the node/component
+
+            if [ ${nombre_restant_node} = 0 ] ; then
+              (( node_num = node_num + 1 ))
+              node_num_current=${node_num}
+              init_node=y
+
+              if [ ${nombre_restant_comp} = 0 ] ; then
+                break 1
+              fi
+            else
+
+              node_num_current=${node_num}
+              init_node=n
+
+              if [ ${nombre_restant_comp} = 0 ] ; then
+                break 1
+              fi
+            fi
+          done
+        fi
+      done
+
+    else
+
+      # Then first loop on the components for the coupler ie oasis
+
+      ## the coupler ie oasis must be the first one
+      for comp in ${config_ListOfComponents[*]} ; do
+
+        eval ExeNameOut=\${config_Executable_${comp}[1]}
+
+        # for CPL component only
+        if [ "X${comp}" = "XCPL" ] ; then
+          eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
+          echo "-np ${comp_proc_mpi_loc} ./${ExeNameOut} " >> run_file
+        fi
+      done
+
+      # Then second loop on the components
+
+      for comp in ${config_ListOfComponents[*]} ; do
+
+        eval ExeNameOut=\${config_Executable_${comp}[1]}
+
+        # Only if we really have an executable for the component and not the coupler ie oasis:
+        if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${comp}" != "XCPL" ] ) ; then
+          eval comp_proc_mpi_loc=\${${comp}_PROC_MPI}
+          echo "-np ${comp_proc_mpi_loc} ./${ExeNameOut}" >> run_file
+        fi
+      done
+      IGCM_sys_Chmod u+x run_file
+
+      EXECUTION="${HOST_MPIRUN_COMMAND} --app ./run_file"
+
+    fi
+
+  else # Only one executable. launch it.
+
+    for comp in ${config_ListOfComponents[*]} ; do
+
+      # Only if we really have an executable for the component :
+      eval ExeNameOut=\${config_Executable_${comp}[1]}
+      if ( [ "X${ExeNameOut}" != X\"\" ] && [ "X${ExeNameOut}" != "Xinca.dat" ] ) ; then
+
+        echo "#!/bin/ksh" > script_${ExeNameOut}.ksh
+        echo ""  >> script_${ExeNameOut}.ksh
+        if ( ${OK_PARA_OMP} ) ; then
+          eval comp_proc_omp_loc=\${${comp}_PROC_OMP}
+          echo "OMP_NUM_THREADS=${comp_proc_omp_loc}" >> script_${ExeNameOut}.ksh
+        fi
+        if  ( ${OK_PARA_MPI} ) ; then
+          # Default : mpirun used if nb_proc gt 1
+          # pour sortie out/err par process
+          # echo "./${ExeNameOut} > out_${ExeNameOut}.out.\${OMPI_COMM_WORLD_RANK} 2>out_${ExeNameOut}.err.\${OMPI_COMM_WORLD_RANK}"  >> script_${ExeNameOut}.ksh
+          echo "./${ExeNameOut}" >> script_${ExeNameOut}.ksh
+          IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh
+          EXECUTION="${HOST_MPIRUN_COMMAND} ./script_${ExeNameOut}.ksh"
+        else
+          # Default : mpirun is NOT used if nb_proc eq 1
+          # pour sortie out/err par process
+          # echo "./${ExeNameOut} > out_${ExeNameOut}.out 2>out_${ExeNameOut}.err" >> script_${ExeNameOut}.ksh
+          echo "./${ExeNameOut}" >> script_${ExeNameOut}.ksh
+          IGCM_sys_Chmod u+x script_${ExeNameOut}.ksh
+          EXECUTION="time ./script_${ExeNameOut}.ksh"
+        fi
+      fi
+    done
+
+  fi
+
+  IGCM_debug_Print 1 "sys Obelix : execution command is"
+  IGCM_debug_Print 1 "$EXECUTION"
+
+  IGCM_debug_PopStack "IGCM_sys_build_execution_scripts"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_check_path
+#D-* Purpose: check that RUN_DIR_PATH that will be removed on some machine
+#D-* do not point to an important use directory. Stop immediately in that case.
+#D-* Examples:
+#D-
+function IGCM_sys_check_path {
+  IGCM_debug_PushStack "IGCM_sys_check_path"
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_check_path"
+  fi
+
+  if ( [ X${RUN_DIR_PATH} = X${HOME} ] || [ X${RUN_DIR_PATH} = X${ARCHIVE} ] ) ; then
+    IGCM_debug_Print 1 "Variable RUN_DIR_PATH is pointing to an important directory : ${RUN_DIR_PATH}"
+    IGCM_debug_Print 1 "Please check the RUN_DIR_PATH definition in your Job : Job_${config_UserChoices_JobName}"
+    IGCM_debug_Exit "This will stop the job"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_check_path"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_check_quota. Dummy call here
+#D-* Purpose: check user quota. Stop the simulation if quota above 90%
+#D-* Examples:
+#D-
+function IGCM_sys_check_quota {
+  IGCM_debug_PushStack "IGCM_sys_check_quota"
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_check_quota"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_check_quota"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_CountJobInQueue
+#D-* Purpose: Check if job_name is currently
+#D-  running or in queue
+#D-* Examples: IGCM_sys_CountJobInQueue ${JobName} NbRun
+#D-
+function IGCM_sys_CountJobInQueue {
+  IGCM_debug_PushStack "IGCM_sys_CountJobInQueue"
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_CountJobInQueue"
+  fi
+  IGCM_debug_PopStack "IGCM_sys_CountJobInQueue"
+}
+
+##############################################################
+# NCO OPERATOR
+
+#D-#==================================================
+#D-function IGCM_sys_ncap2
+#D-* Purpose: encapsulate ncap2 call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncap2 {
+  IGCM_debug_PushStack "IGCM_sys_ncap2" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncap2 :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncap2 "$@" > /tmp/out_command_${LOGIN}.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncap2 : error code ${status}"
+      cat /tmp/out_command_${LOGIN}.$$
+      \rm /tmp/out_command_${LOGIN}.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncap2 : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command_${LOGIN}.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncap2 : ncap2 error"
+    IGCM_debug_Exit "ncap2"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncap2"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncatted
+#D-* Purpose: encapsulate ncatted call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncatted {
+  IGCM_debug_PushStack "IGCM_sys_ncatted" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncatted :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncatted "$@" > /tmp/out_command_${LOGIN}.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncatted : error code ${status}"
+      cat /tmp/out_command_${LOGIN}.$$
+      \rm /tmp/out_command_${LOGIN}.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncatted : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command_${LOGIN}.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncatted : ncatted error"
+    IGCM_debug_Exit "ncatted"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncatted"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncbo
+#D-* Purpose: encapsulate ncbo call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncbo {
+  IGCM_debug_PushStack "IGCM_sys_ncbo" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncbo :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncbo $@ > /tmp/out_command_${LOGIN}.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncbo : error code ${status}"
+      cat /tmp/out_command_${LOGIN}.$$
+      \rm /tmp/out_command_${LOGIN}.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncbo : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command_${LOGIN}.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncbo : ncbo error"
+    IGCM_debug_Exit "ncbo"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncbo"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncdif
+#D-* Purpose: encapsulate ncdiff call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncdiff {
+  IGCM_debug_PushStack "IGCM_sys_ncdiff" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncdiff :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncdiff $@ > /tmp/out_command_${LOGIN}.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncdiff : error code ${status}"
+      cat /tmp/out_command_${LOGIN}.$$
+      \rm /tmp/out_command_${LOGIN}.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncdiff : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command_${LOGIN}.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncdiff : ncdiff error"
+    IGCM_debug_Exit "ncdiff"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncdiff"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncea
+#D-* Purpose: encapsulate ncea call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncea {
+  IGCM_debug_PushStack "IGCM_sys_ncea" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncea :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncea $@ > /tmp/out_command_${LOGIN}.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncea : error code ${status}"
+      cat /tmp/out_command_${LOGIN}.$$
+      \rm /tmp/out_command_${LOGIN}.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncea : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command_${LOGIN}.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncea : ncea error"
+    IGCM_debug_Exit "ncea"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncea"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncecat
+#D-* Purpose: encapsulate ncecat call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncecat {
+  IGCM_debug_PushStack "IGCM_sys_ncecat" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncecat :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncecat $@ > /tmp/out_command_${LOGIN}.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncecat : error code ${status}"
+      cat /tmp/out_command_${LOGIN}.$$
+      \rm /tmp/out_command_${LOGIN}.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncecat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command_${LOGIN}.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncecat : ncecat error"
+    IGCM_debug_Exit "ncecat"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncecat"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncflint
+#D-* Purpose: encapsulate ncflint call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncflint {
+  IGCM_debug_PushStack "IGCM_sys_ncflint" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncflint :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncflint $@ > /tmp/out_command_${LOGIN}.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncflint : error code ${status}"
+      cat /tmp/out_command_${LOGIN}.$$
+      \rm /tmp/out_command_${LOGIN}.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncflint : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command_${LOGIN}.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncflint : ncflint error"
+    IGCM_debug_Exit "ncflint"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncflint"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncks
+#D-* Purpose: encapsulate ncks call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncks {
+  IGCM_debug_PushStack "IGCM_sys_ncks" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncks :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncks $@ > /tmp/out_command_${LOGIN}.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncks : error code ${status}"
+      cat /tmp/out_command_${LOGIN}.$$
+      \rm /tmp/out_command_${LOGIN}.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncks : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command_${LOGIN}.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncks : ncks error"
+    IGCM_debug_Exit "ncks"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncks"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncpdq
+#D-* Purpose: encapsulate ncpdq call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncpdq {
+  IGCM_debug_PushStack "IGCM_sys_ncpdq" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncpdq :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncpdq $@ > /tmp/out_command_${LOGIN}.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncpdq : error code ${status}"
+      cat /tmp/out_command_${LOGIN}.$$
+      \rm /tmp/out_command_${LOGIN}.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncpdq : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command_${LOGIN}.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncpdq : ncpdq error"
+    IGCM_debug_Exit "ncpdq"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncpdq"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncra
+#D-* Purpose: encapsulate ncra call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncra {
+  IGCM_debug_PushStack "IGCM_sys_ncra" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncra :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncra $@ > /tmp/out_command_${LOGIN}.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncra : error code ${status}"
+      cat /tmp/out_command_${LOGIN}.$$
+      \rm /tmp/out_command_${LOGIN}.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncra : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command_${LOGIN}.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncra : ncra error"
+    IGCM_debug_Exit "ncra"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncra"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncrcat
+#D-* Purpose: encapsulate ncrcat call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncrcat {
+  IGCM_debug_PushStack "IGCM_sys_ncrcat" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncrcat :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i lastArg
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncrcat $@ > /tmp/out_command_${LOGIN}.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncrcat : error code ${status}"
+      cat /tmp/out_command_${LOGIN}.$$
+      \rm /tmp/out_command_${LOGIN}.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    elif [ ! "X$( grep "WARNING Intra-file non-monotonicity" /tmp/out_command_${LOGIN}.$$ )" = "X" ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncrcat : WARNING Intra-file non-monotonicity"
+      cat /tmp/out_command_${LOGIN}.$$
+      # remove files having corrupted time axis
+      eval lastArg=\${$#}
+      IGCM_debug_Print 2 "IGCM_sys_ncrcat : Delete ${lastArg}"
+      \rm ${lastArg}
+      \rm /tmp/out_command_${LOGIN}.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command_${LOGIN}.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncrcat : ncrcat error"
+    #IGCM_debug_Exit "ncrcat"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncrcat"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncrename
+#D-* Purpose: encapsulate ncrename call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncrename {
+  IGCM_debug_PushStack "IGCM_sys_ncrename" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncrename :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncrename $@ > /tmp/out_command_${LOGIN}.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncrename : error code ${status}"
+      cat /tmp/out_command_${LOGIN}.$$
+      \rm /tmp/out_command_${LOGIN}.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncrename : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command_${LOGIN}.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncrename : ncrename error"
+    IGCM_debug_Exit "ncrename"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncrename"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ncwa
+#D-* Purpose: encapsulate ncwa call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_ncwa {
+  IGCM_debug_PushStack "IGCM_sys_ncwa" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ncwa :" $@
+  fi
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+    ncwa $@ > /tmp/out_command_${LOGIN}.$$ 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_ncwa : error code ${status}"
+      cat /tmp/out_command_${LOGIN}.$$
+      \rm /tmp/out_command_${LOGIN}.$$
+      IGCM_debug_Print 2 "IGCM_sys_ncwa : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
+    else
+      \rm /tmp/out_command_${LOGIN}.$$
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_ncwa : ncwa error"
+    IGCM_debug_Exit "ncwa"
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_ncwa"
+}
+
+##############################################################
+# CDO OPERATOR
+
+#D-#==================================================
+#D-function IGCM_sys_cdo
+#D-* Purpose: encapsulate cdo call so as to manage error code and retry
+#D-* Examples:
+#D-
+function IGCM_sys_cdo {
+  IGCM_debug_PushStack "IGCM_sys_cdo" -- $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_cdo :" $@
+  fi
+
+  typeset status
+
+  \cdo $@ > /tmp/out_command_${LOGIN}.$$ 2>&1
+  status=$?
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_cdo : error code ${status}"
+    cat /tmp/out_command_${LOGIN}.$$
+    \rm /tmp/out_command_${LOGIN}.$$
+    IGCM_debug_PopStack "IGCM_sys_cdo"
+    return 1
+  else
+    IGCM_debug_PopStack "IGCM_sys_cdo"
+    return 0
+  fi
+
+  IGCM_debug_PopStack "IGCM_sys_cdo"
+}
Index: /tags/libIGCM_v2.2/run.card.init
===================================================================
--- /tags/libIGCM_v2.2/run.card.init	(revision 998)
+++ /tags/libIGCM_v2.2/run.card.init	(revision 998)
@@ -0,0 +1,37 @@
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2006)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+
+#========================================================================
+[Configuration]
+#last PREFIX
+OldPrefix=
+#Compute date of loop
+PeriodDateBegin=
+PeriodDateEnd=
+CumulPeriod=
+# State of Job "Start", "Running", "OnQueue", "Completed"
+PeriodState="Start"
+
+SubmitPath=
+
+#========================================================================
+[PostProcessing]
+
+#RebuildRunning=y/n
+#RebuildToComplete=number of dir to rebuild
+#RebuildDateID=PeriodDateEnd correspondant au dernier flag de RebuildFrequency=true
+
+TimeSeriesRunning=n
+TimeSeriesCompleted=
+
+#========================================================================
+[Log]
+# Executables Size
+LastExeSize=()
+
+#------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+# CumulPeriod | PeriodDateBegin |   PeriodDateEnd |        RunDateBegin |          RunDateEnd |     RealCpuTime |     UserCpuTime |      SysCpuTime | ExeDate
+#------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
