Index: TOOLS/SURPACK_IPSL/DEM_utilities.sh
===================================================================
--- TOOLS/SURPACK_IPSL/DEM_utilities.sh	(revision 2136)
+++ TOOLS/SURPACK_IPSL/DEM_utilities.sh	(revision 2136)
@@ -0,0 +1,731 @@
+#!/bin/bash
+#
+# Fonctions utiles pour les scripts de Pack IPSL
+#
+
+function DEM_read_state {
+# Lire l'Ã©tat du pack pour une simulation
+    local L_CONFIG_FILE=${1}
+    local L_CONFIG_CARD=${2}
+
+    local L_OLD_STATE=$( grep ${L_CONFIG_CARD} ${L_CONFIG_FILE} | awk '{print $2}' )
+    
+    if [ ${?} -eq 0 ] 
+    then 
+	echo ${L_OLD_STATE}
+	return 0
+    else
+	return 1
+    fi
+    return 0
+}
+
+function DEM_write_state {
+# Mettre Ã  jour l'Ã©tat du pack pour une simulation
+    local L_CONFIG_FILE=${1}
+    local L_CONFIG_CARD=${2}
+    local L_NEW_STATE=${3}
+
+    local L_MAX_TRY=10 L_TRY=0 L_CHECK L_PP
+
+    # On essaye ${L_MAX_TRY} fois de mettre Ã  jour le fichier
+    while [ ${L_TRY} -le ${L_MAX_TRY} ]
+    do
+	if [[ ! -f ${L_CONFIG_FILE}.lock ]]
+	then 
+	    echo ${$}  >> ${L_CONFIG_FILE}.lock     ; chmod -w ${L_CONFIG_FILE}.lock
+	    L_CHECK=$( wc -l ${L_CONFIG_FILE}.lock | awk '{print $1}' )
+	    if [[ ${L_CHECK} -gt 1 ]]
+	    then
+		DEM_log -0 "Erreur. Plusieurs processus on pose un verrou sur ${L_CONFIG_FILE}"
+		for L_PP in $( awk  '{print $1}' ${L_CONFIG_FILE}.lock ) 
+		do
+		    DEM_log -0 "Erreur. Process : ${L_PP}"
+		done
+		return 1
+	    fi
+
+	    local L_OLD_LINE=$( grep ${L_CONFIG_CARD} ${L_CONFIG_FILE} )
+	    [[ ${?} -eq 0 ]] || ( return 1 ; )
+	    if [[ ${L_OLD_LINE} = "" ]]
+	    then
+		DEM_log -0 "Erreur. Dans le fichier : ${L_CONFIG_FILE}, Experience ${L_CONFIG_CARD} non trouvee"
+		return 1
+	    fi
+	    local L_OLD_STATE=$( echo ${L_OLD_LINE} | awk '{print $2}' )
+	    [[ ${?} -eq 0 ]] || ( return 1 ; )
+	    
+	    L_NEW_LINE="${L_CONFIG_CARD} ${L_NEW_STATE}"
+
+	    sed -i "s%${L_OLD_LINE}%${L_NEW_LINE}%" ${L_CONFIG_FILE}
+	    rm -f ${L_CONFIG_FILE}.lock
+	    break
+	else
+	    (( L_TRY = L_TRY + 1 ))
+	    DEM_log -3 "Fichier ${L_CONFIG_FILE} en cours de modif par un autre processus. Essai ${L_TRY}"
+	    sleep 1
+	fi
+	   
+    done
+    
+    if [[ ${L_TRY} -ge ${L_MAX_TRY} ]]
+    then 
+	DEM_log -0 "Erreur. Verrou sur le fichier : ${L_CONFIG_FILE}"
+	return 1
+    fi
+
+    return 0
+}
+
+function DEM_min {
+# Calcul du minimum d'un nombre quelconque d'entiers
+    local l_min=${1} l_xx
+
+    for l_xx in ${*:2:${#}}
+    do
+	l_xx_tmp=`echo $l_xx|sed 's/^0*//'`
+	l_min_tmp=`echo $l_min|sed 's/^0*//'`
+	[[ ${l_xx_tmp} -lt ${l_min_tmp} ]] && l_min=${l_xx}
+    done
+    echo ${l_min}
+}
+
+function DEM_max {
+# Calcul du maximum d'un nombre quelconque d'entiers
+    local l_max=${1} l_xx
+  
+    for l_xx in ${*:2:${#}}
+    do
+	l_xx_tmp=`echo $l_xx|sed 's/^0*//'`
+	l_max_tmp=`echo $l_max|sed 's/^0*//'`
+	[[ ${l_xx_tmp} -gt ${l_max_tmp} ]] && l_max=${l_xx}
+    done
+    echo ${l_max}
+}
+
+function DEM_log {
+# Affichage d'un message sur stdout et dans un fichier de log
+# DEM_log [-0|-1|-2|-3] Message
+#
+    local MESSAGE P_LINE L_NAME
+    LOG_LEV=${LOG_LEV:-3}
+    local OPTARG OPTIND L_LOG=3
+    local L_DEM_LOG=${DEM_LOG:-${TMP_MIGR_DATA}/dem_log.${$}}
+
+    while getopts 0123 L_NAME
+    do
+	case ${L_NAME} in
+            ( 0 )  L_LOG=0 ;;
+            ( 1 )  L_LOG=1 ;;
+            ( 2 )  L_LOG=2 ;;
+	    ( 3 )  L_LOG=3 ;;
+	esac
+    done
+    shift $(( ${OPTIND} - 1 ))
+
+    if [[ ${L_LOG} -le ${LOG_LEV} ]]
+    then 
+	MESSAGE=${*}
+	P_LINE="$(date) - ${MESSAGE}"
+	
+	echo ${P_LINE}
+	echo ${P_LINE} >> ${L_DEM_LOG}
+    fi
+    return
+}
+
+# gpdebug : fonctions de gestion des erreurs ########################################################
+function DEM_errorSend {
+    # Envoi d'un msg d'erreur au programme principal. 
+    # Suppression des processus du programme principal au fils emetteur de l'erreur
+    
+    echo "########## DEM_errorSend : Error detected ==> Sending an error..."
+    
+    msgToSend=${1}
+    listPIDtoKill=${2}
+    if [ "x${listPIDtoKill}" == "x" ]
+    then
+        listPIDtoKill=${listPID}
+    fi
+    # --------------------------------
+    # Verif du format de listPIDtoKill
+    # --------------------------------
+    listPIDformat='^[[:digit:]]*\([[:blank:]][[:digit:]]*\)*$'
+    isListPIDformatOK=`echo ${listPIDtoKill} | grep -e ${listPIDformat} | wc -l `
+    if [ "x$isListPIDformatOK" == "x0" ]
+    then
+       echo "	   Attention : le format de la liste de PID est incorrecte :"
+       echo "	   $listPIDtoKill"
+       kill -TERM ${listPID}
+    fi
+
+    
+    # -----------------------------------
+    # Verif du Format du ${msgToSend}
+    # -----------------------------------
+    errorFormat='^[^:]*\.sh:[[:digit:]]*:.*$'
+    isErrorFormatOK=`echo ${msgToSend} | grep -e ${errorFormat} | wc -l `
+    if [ "x$isErrorFormatOK" == "x0" ]
+    then
+       echo "      Attention : le format du message d'erreur est incorrect :"
+       echo "      $msgToSend"
+    fi
+    
+    # Envoi du msg dans le fichier d'erreur
+    # -------------------------------------
+    #    test sur la var contenant le nom du fichier d'erreur
+    if [ "x${errorMsgFile}" != "x${TMP_MIGR_DATA}/errorMsg.txt" ]
+    then
+        echo "      Le fichier d'erreur a un nom incorrect"
+    fi
+    
+    echo $msgToSend > $errorMsgFile
+    
+    echo "killing ${listPIDtoKill}"
+    kill -TERM ${listPIDtoKill}
+    
+    exit -1 # utile : sinon le script qui appelle cette fonction continue un peu l'exec --> pas propre
+}
+
+function DEM_errorReceive {
+    # Récupération et affichage du msg d'erreur emis par un processus fils 
+    
+    # Lecture du msg dans le fichier d'erreur
+    # ---------------------------------------
+    #    test sur la var contenant le nom du fichier d'erreur
+    if [ "x${errorMsgFile}" != "x${TMP_MIGR_DATA}/errorMsg.txt" ]
+    then
+       echo "      Le fichier d'erreur a un nom incorrect"
+       exit -1	
+    fi
+    
+    #    Lecture    
+    errorReceived=`cat $errorMsgFile `
+    
+    # -----------------------------------
+    # Verif du Format du ${errorReceived}
+    # -----------------------------------
+    errorFormat='^[^:]*\.sh:[[:digit:]]*:.*$'
+    isErrorFormatOK=`echo ${errorReceived} | grep -e ${errorFormat} | wc -l `
+    if [ "x$isErrorFormatOK" == "x0" ]
+    then
+       echo "      Attention : le format du message d'erreur est incorrect :"
+       echo "      $errorReceived"
+       exit -1
+    fi
+    
+    echo "########## DEM_errorReceive : $SCRIPT_NAME received an error..."
+    echo $errorReceived
+    
+    # echo "Current PID:$$"
+    # echo "FatherPID:$FatherPID"
+    # On fait un bilan de la progression seulement si c'est une erreur bloquante : lorsque le proc pere est tue.
+    # if [ "x${FatherPID}" == "x$$" ]
+    # then
+    #    ./showListsProgress.sh $FileParam
+    # fi
+       
+    exit -1 
+}
+
+# Verification de la version de nco chargee
+function check_nco_version
+{
+   # nom du présent prog (pour gestion des erreurs) 
+   PROGNAME="DEM_utilities.sh" #########
+   . /etc/profile 
+   module list >& ${JOB_DIR}/myModuleList.txt
+   
+   if [ "x$?" != "x0" ]
+   then
+       # echo "La commande module list a rencontre un pb !"
+       DEM_errorSend "${PROGNAME}:${LINENO}:La commande module list a rencontre un pb !"
+   fi
+   
+   if [ ! -e ${JOB_DIR}/myModuleList.txt ]
+   then
+       # echo "Le fichier 'myModuleList.txt'  n existe pas"
+       DEM_errorSend "${PROGNAME}:${LINENO}:Le fichier 'myModuleList.txt' n'existe pas."
+   fi   
+   
+   # Presence de la chaine "n) nco/" ou n est un nombre  
+   ncoLines=` grep -e '[[:digit:]]*) nco/' ${JOB_DIR}/myModuleList.txt `
+   # ncoLines=` grep -e '[[:digit:]]*) nco/' moduleList.txt `
+   # echo "ncoLines=${ncoLines}|"
+   # echo "----------------------------------------"
+
+   # Plus besoin du myModuleList.txt
+   rm -f ${JOB_DIR}/myModuleList.txt
+ 
+   # La chaine "nco" est remplacee par le caractere "#"
+   temp1=`echo $ncoLines | sed 's;nco;#;g' `
+   # echo "$temp1"
+   # echo "----------------------------------------"
+
+   # On supprime tout ce qui n'est pas "n) #/..." avec n un nombre et "..." une chaine sans blanc 
+   temp2=`echo $temp1 | sed 's;[[:blank:]]*[[:digit:]]*) [^#][^[:blank:]]*;;g' `
+   # echo "$temp2"
+   # echo "----------------------------------------"
+
+
+   # Recuperation du numero de version du nco au format x.y.z
+   # C'est une liste de num de version (a priori ici, il pourrait y en avoir plusieurs, 
+   # mais dans les faits, les nco s'excluent les uns les autres)
+   temp3=`echo $temp2 | sed 's;[[:blank:]]*[[:digit:]]*) #/;|;g' `
+   temp3=`echo $temp3 | sed 's;^|;;g' `
+   temp3=`echo $temp3 | sed 's;|; ;g' `
+   # echo "$temp3"
+   # echo "----------------------------------------"
+   
+   # comptage du nombre de nco
+   versionNCO=
+   count=0
+   for ver in $temp3
+   do
+     # echo "ver=$ver"
+     versionNCO=$ver
+     count=$(( $count + 1 ))
+   done
+   # echo "count=$count"
+   
+   # si aucun nco n'est charge, on sort.
+   if [ $count -eq 0 ]
+   then
+     # echo "nco pas charge"
+     DEM_errorSend "${PROGNAME}:${LINENO}:Aucun nco n'est charge"
+   fi
+   
+   # si plus d'un nco sont charges, on sort (n'arrive jamais en pratique).
+   if [ $count -gt 1 ]
+   then
+     DEM_errorSend "${PROGNAME}:${LINENO}:Au moins 2 versions de nco sont chargees"
+   fi
+   
+   # Si un seul nco est charge, on supprime les "." de son numero de version (x.y.z ==> xyz)
+   verNCOnumber=`echo $versionNCO | sed 's;[^[:digit:]];;g' `
+   # echo "versionNCO=$versionNCO"
+   
+   # On verifie que xyz est un nombre a 3 chiffres
+   verNCOnumberOK=`echo $verNCOnumber | grep -e '^[0-9]\{3\}$' | wc -l `
+   #  if ! [[ "$verNCOnumber" =~ ^[0-9]\{3\}$ ]] # gpdebug : ne marche pas sous curie si ksh. 
+   if [ "x${verNCOnumberOK}" == "x0" ]
+   then
+      # echo "verNCOnumber is not a number"
+      DEM_errorSend "${PROGNAME}:${LINENO}:La variable verNCOnumber n'est pas un nombre --> $verNCOnumber"
+   fi
+   
+   
+   # On verifie que le num de version est >= 4.1.0
+   if [ $verNCOnumber -lt 410 ]
+   then
+       # echo "version < 4.1.0 . STOP."
+       DEM_errorSend "${PROGNAME}:${LINENO}:La version de nco < 4.1.0 ==> $versionNCO"
+   fi
+   
+   echo "La version de nco chargee est : $versionNCO"
+   
+}
+
+
+# Verification de la version de nco chargee sur ulam (machine IDRIS)
+function check_nco_version_idris
+{
+   # nom du présent prog (pour gestion des erreurs) 
+   PROGNAME="DEM_utilities.sh" #########
+   . /etc/profile 
+   module list >& ${JOB_DIR}/myModuleList.txt
+   
+   if [ "x$?" != "x0" ]
+   then
+       # echo "La commande module list a rencontre un pb !"
+       DEM_errorSend "${PROGNAME}:${LINENO}:La commande module list a rencontre un pb !"
+   fi
+   
+   if [ ! -e ${JOB_DIR}/myModuleList.txt ]
+   then
+       # echo "Le fichier 'myModuleList.txt'  n existe pas"
+       DEM_errorSend "${PROGNAME}:${LINENO}:Le fichier 'myModuleList.txt' n'existe pas."
+   fi   
+   
+   # Presence de la chaine "n) nco/" ou n est un nombre  
+   ncoLines=` grep -e '[[:digit:]]*) nco/' ${JOB_DIR}/myModuleList.txt `
+   # ncoLines=` grep -e '[[:digit:]]*) nco/' moduleList.txt `
+   # echo "ncoLines=${ncoLines}|"
+   # echo "----------------------------------------"
+
+   # Plus besoin du myModuleList.txt
+   rm -f ${JOB_DIR}/myModuleList.txt
+ 
+   # La chaine "nco" est remplacee par le caractere "#"
+   temp1=`echo $ncoLines | sed 's;nco;#;g' `
+   # echo "$temp1"
+   # echo "----------------------------------------"
+
+   # On supprime tout ce qui n'est pas "n) #/..." avec n un nombre et "..." une chaine sans blanc 
+   temp2=`echo $temp1 | sed 's;[[:blank:]]*[[:digit:]]*) [^#][^[:blank:]]*;;g' `
+   # echo "$temp2"
+   # echo "----------------------------------------"
+
+
+   # Recuperation du numero de version du nco au format x.y.z
+   # C'est une liste de num de version (a priori ici, il pourrait y en avoir plusieurs, 
+   # mais dans les faits, les nco s'excluent les uns les autres)
+   temp3=`echo $temp2 | sed 's;[[:blank:]]*[[:digit:]]*) #/;|;g' `
+   temp3=`echo $temp3 | sed 's;^|;;g' `
+   temp3=`echo $temp3 | sed 's;|; ;g' `
+   # echo "$temp3"
+   # echo "----------------------------------------"
+   
+   # comptage du nombre de nco
+   versionNCO=
+   count=0
+   for ver in $temp3
+   do
+     # echo "ver=$ver"
+     versionNCO=$ver
+     count=$(( $count + 1 ))
+   done
+   # echo "count=$count"
+   
+   # si aucun nco n'est charge, on sort.
+   if [ $count -eq 0 ]
+   then
+     # echo "nco pas charge"
+     DEM_errorSend "${PROGNAME}:${LINENO}:Aucun nco n'est charge"
+   fi
+   
+   # si plus d'un nco sont charges, on sort (n'arrive jamais en pratique).
+   if [ $count -gt 1 ]
+   then
+     DEM_errorSend "${PROGNAME}:${LINENO}:Au moins 2 versions de nco sont chargees"
+   fi
+   
+   # Si un seul nco est charge, on supprime les "." de son numero de version (x.y.z ==> xyz)
+   verNCOnumber=`echo $versionNCO | sed 's;[^[:digit:]];;g' `
+   # echo "versionNCO=$versionNCO"
+   
+   # On verifie que xyz est un nombre a 3 chiffres
+   verNCOnumberOK=`echo $verNCOnumber | grep -e '^[0-9]\{3\}$' | wc -l `
+   #  if ! [[ "$verNCOnumber" =~ ^[0-9]\{3\}$ ]] # gpdebug : ne marche pas sous curie si ksh. 
+   if [ "x${verNCOnumberOK}" == "x0" ]
+   then
+      # echo "verNCOnumber is not a number"
+      DEM_errorSend "${PROGNAME}:${LINENO}:La variable verNCOnumber n'est pas un nombre --> $verNCOnumber"
+   fi
+   
+   # On verifie que le num de version est >= 4.0.5
+   if [ $verNCOnumber -lt 405 ]
+   then
+       # echo "version < 4.0.5 . STOP."
+       DEM_errorSend "${PROGNAME}:${LINENO}:La version de nco < 4.0.5 ==> $versionNCO"
+   fi
+   
+   echo "La version de nco chargee est : $versionNCO"
+   
+}
+
+function check_netcdf_idris
+{
+   # nom du présent prog (pour gestion des erreurs) 
+   PROGNAME="DEM_utilities.sh" #########
+   . /etc/profile 
+   module list >& ${JOB_DIR}/myModuleList.txt
+   
+   if [ "x$?" != "x0" ]
+   then
+       # echo "La commande module list a rencontre un pb !"
+       DEM_errorSend "${PROGNAME}:${LINENO}:La commande module list a rencontre un pb !"
+   fi
+   
+   if [ ! -e ${JOB_DIR}/myModuleList.txt ]
+   then
+       # echo "Le fichier 'myModuleList.txt'  n existe pas"
+       DEM_errorSend "${PROGNAME}:${LINENO}:Le fichier 'myModuleList.txt' n'existe pas."
+   fi   
+   
+   # Presence de la chaine "n) nco/" ou n est un nombre  
+   nb_of_libLines=` grep -e '[[:digit:]]*) netcdf/' ${JOB_DIR}/myModuleList.txt | wc -l `
+
+   if [ "x${nb_of_libLines}" == "x0" ]
+   then
+       DEM_errorSend "${PROGNAME}:${LINENO}:Aucun netCDF n'est charge"
+   fi
+
+   # Plus besoin du myModuleList.txt
+   rm -f ${JOB_DIR}/myModuleList.txt
+}
+
+function check_libccc_user
+{
+   # nom du présent prog (pour gestion des erreurs) 
+   PROGNAME="DEM_utilities.sh" #########
+   . /etc/profile 
+   module list >& ${JOB_DIR}/myModuleList.txt
+   
+   if [ "x$?" != "x0" ]
+   then
+       # echo "La commande module list a rencontre un pb !"
+       DEM_errorSend "${PROGNAME}:${LINENO}:La commande module list a rencontre un pb !"
+   fi
+   
+   if [ ! -e ${JOB_DIR}/myModuleList.txt ]
+   then
+       # echo "Le fichier 'myModuleList.txt'  n existe pas"
+       DEM_errorSend "${PROGNAME}:${LINENO}:Le fichier 'myModuleList.txt' n'existe pas."
+   fi   
+   
+   # Presence de la chaine "n) nco/" ou n est un nombre  
+   nb_of_libLines=` grep -e '[[:digit:]]*) libccc_user/' ${JOB_DIR}/myModuleList.txt | wc -l `
+
+   if [ "x${nb_of_libLines}" == "x0" ]
+   then
+       DEM_errorSend "${PROGNAME}:${LINENO}:Aucun libccc_user n'est charge"
+   fi
+
+   # Plus besoin du myModuleList.txt
+   rm -f ${JOB_DIR}/myModuleList.txt
+
+}
+
+
+function check_cdo
+{
+   # nom du présent prog (pour gestion des erreurs) 
+   PROGNAME="DEM_utilities.sh" #########
+   . /etc/profile 
+   module list >& ${JOB_DIR}/myModuleList.txt
+   
+   if [ "x$?" != "x0" ]
+   then
+       # echo "La commande module list a rencontre un pb !"
+       DEM_errorSend "${PROGNAME}:${LINENO}:La commande module list a rencontre un pb !"
+   fi
+   
+   if [ ! -e ${JOB_DIR}/myModuleList.txt ]
+   then
+       # echo "Le fichier 'myModuleList.txt'  n existe pas"
+       DEM_errorSend "${PROGNAME}:${LINENO}:Le fichier 'myModuleList.txt' n'existe pas."
+   fi   
+   
+   # Presence de la chaine "n) nco/" ou n est un nombre  
+   nb_of_libLines=` grep -e '[[:digit:]]*) cdo/' ${JOB_DIR}/myModuleList.txt | wc -l `
+
+   if [ "x${nb_of_libLines}" == "x0" ]
+   then
+       DEM_errorSend "${PROGNAME}:${LINENO}:Aucun cdo n'est charge"
+   fi
+
+   # Plus besoin du myModuleList.txt
+   rm -f ${JOB_DIR}/myModuleList.txt
+
+}
+
+
+function prepareMonitoringDir
+{
+   # nom du présent prog (pour gestion des erreurs) 
+   PROGNAME="DEM_utilities.sh" #########
+   
+   MonitoringDirDefined=`echo $MonitoringDir | grep "SuiviListes" | wc -l `
+   if [ "x${workFlowDirDefined}" == "x0" ]
+   then
+      DEM_errorSend "${PROGNAME}:${LINENO}:Le repertoire de suivi est mal defini."
+   fi
+   
+   #  Si l'option de forcage de toute les etapes est activee,
+   #  on vide le fichier
+   if [ "x${execEveryStep}" == "x1" ]
+   then
+      echo "${MonitoringDir}:destruction..."
+      rm -rf ${MonitoringDir}
+   fi
+   
+   # Si le rep de suivi n'existe pas, on le créé.
+   if [ ! -d ${MonitoringDir} ]
+   then
+      mkdir -p ${MonitoringDir}
+   fi
+
+}
+
+function generalMonitoring
+{  
+   # Si l'etape courante a ete executee (correctement), on sort du script appelant cette fonction
+   
+   # nom du présent prog (pour gestion des erreurs) 
+   PROGNAME="DEM_utilities.sh" #########
+
+   currentStep=${1}
+   stepMsg=`echo $currentStep | grep -e '^.*\.sh-->OK$' | wc -l `
+   if [ "x${stepMsg}" == "x0" ]
+   then
+      DEM_errorSend "${PROGNAME}:${LINENO}:Le nom de l'etape courante n'est pas au bon format !"
+   fi
+   
+   currentStepScriptName=`echo $currentStep | sed 's;\.sh-->OK;;' `
+   # si le fichier de suivi general n'existe pas, il n'y a pas eu de passage de script de liste avant.
+   # ==> on sort normalement
+   if [ ! -e ${generalMonitorFile} ]
+   then
+      return 0
+   fi
+   
+   currentStepPassed=`grep ${currentStep} ${generalMonitorFile} | wc -l `
+   if [ "x${currentStepPassed}" != "x0" ]
+   then
+      echo "${currentStepScriptName} a deja ete passee ..."
+      exit 0
+   fi
+
+}
+
+function createListingMonitoring_Check
+{
+   
+   # La presence de createListingOK.txt dans le sous rep (associe a un rep de param_AC.txt) du rep de suivi
+   # indique que le bon deroulement de l'action de create_listing.sh sur le repertoire de param_AC.txt
+   DIR=$(basename ${1})   
+   MonitSubDir=${MonitoringDir}/${DIR}
+   
+   createListingOK=${MonitSubDir}/createListingOK.txt
+   
+   if [ -e $createListingOK ]
+   then
+      echo "create_listing a deja ete passe pour ${DIR}..."
+      exit 0      
+   fi   
+
+}
+
+function createListingMonitoring_OK
+{
+   
+   # A partir du nom du rep courant (contenant des res de simulation), creation d'un sous rep de suivi
+   DIR=$(basename ${1})
+   MonitSubDir=${MonitoringDir}/${DIR}
+   mkdir $MonitSubDir
+   
+   # dans ce sous rep de suivi, creation d'un fichier dont la presence indique le bon deroulement
+   # de l'action de create_listing.sh sur le repertoire en argument (celui contenant des simus) 
+   createListingOK=${MonitSubDir}/createListingOK.txt  
+   touch $createListingOK  
+
+}
+
+function simuMonitoring_check
+{
+   # nom du présent prog (pour gestion des erreurs) 
+   PROGNAME="DEM_utilities.sh" #########
+   
+   currentStep=${1}
+   config=${2}
+   # echo "######### simuMonitoring_check --> config:$config"
+   # former le nom du fichier de suivi de la simu a partir de "config"
+   getSimuMonitFileName $config
+   
+   # si le fichier de suivi de simu n'existe pas, il n'y a pas eu de passage de script de liste avant.
+   # ==> on sort normalement
+   if [ ! -e ${simuMonitoringFile} ]
+   then
+      return 0
+   fi
+   
+   stepMsg=`echo $currentStep | grep -e '^.*\.sh-->OK$' | wc -l `
+   if [ "x{stepMsg}" == "x0" ]
+   then
+      DEM_errorSend "${PROGNAME}:${LINENO}:Le nom de l'etape courante n'est pas au bon format !"
+   fi
+   
+   currentStepScriptName=`echo $currentStep | sed 's;\.sh-->OK;;' `
+   
+   currentStepPassed=`grep ${currentStep} ${simuMonitoringFile} | wc -l `
+   
+   # echo "######### simuMonitoring_check --> currentStep:$currentStep"
+   # echo "######### simuMonitoring_check --> simuMonitoringFile:$simuMonitoringFile"
+   # echo "######### simuMonitoring_check --> currentStepPassed:$currentStepPassed"
+   if [ "x${currentStepPassed}" != "x0" ]
+   then
+      echo "${currentStepScriptName} a deja ete passee ..."
+      # echo "-----------------------------------------------------------------------------"
+      exit 0
+   fi
+   
+}
+
+function simuMonitoring_OK
+{
+   currentStep=${1}
+   config=${2}
+   # echo "######### simuMonitoring_OK --> config:$config"
+   # former le nom du fichier de suivi de la simu a partir de "config"
+   getSimuMonitFileName $config
+   
+   echo $currentStep >> $simuMonitoringFile
+}
+
+function getSimuMonitFileName
+{
+   # nom du présent prog (pour gestion des erreurs) 
+   PROGNAME="DEM_utilities.sh" #########
+   
+   config=${1}
+   # echo "######### getSimuMonitFileName --> config:$config"
+   configBaseName=$(basename ${config})
+      
+   # On cherche dans quel sous rep du rep de suivi on va chercher le fichier de suivi de la simu
+   listMonitSubDir=`ls -l ${MonitoringDir} | grep -e '^d' | awk '{print $NF}' `
+   
+   # echo "######### getSimuMonitFileName --> listMonitSubDir:$listMonitSubDir"
+   
+   searchedDir=
+   for dir in $listMonitSubDir
+   do
+       found=`echo $config | grep "/${dir}/" | wc -l `
+       if [ "x${found}" != "x0" ]
+       then
+          searchedDir=$dir
+	  break
+       fi
+   done
+   
+   if [ "x$searchedDir" == "x" ]
+   then
+      DEM_errorSend "${PROGNAME}:${LINENO}:Sous rep de suivi non trouve !"
+   fi
+   
+   # On forme le nom du fichier de suivi pour la simu courante
+   # ... on debarasse config du fichier de config
+   repConfig=$(dirname $config)
+   # ... on supprime du path tout ce qui est devant le nom du sous rep
+   simu=`echo $repConfig | sed "s;^.*/$searchedDir;$searchedDir;" `
+   # ... remplacement des "/" par des "_#_" (les "/" ne sont pas acceptes dans les noms de fichiers)
+   simuMonitoringFile=`echo $simu | sed 's;/;_#_;g' `
+   # ... On rajoute un ".txt" a la fin du nom de fichier
+   simuMonitoringFile="${simuMonitoringFile}.txt"
+   
+   simuMonitoringFile="${MonitoringDir}/${searchedDir}/${simuMonitoringFile}"
+}
+
+
+function getDateMilliSeconds
+{
+   test=`date +%s%N`
+   testnum=${#test}
+   millisec=${test:0:$testnum-6}
+   echo "$millisec"
+}
+
+function getTimeDiffSeconds
+{
+   startTimeMilliSec=$1
+   endTimeMilliSec=$( getDateMilliSeconds )
+   
+   diffMilliSec=$(( $endTimeMilliSec - $startTimeMilliSec ))
+   
+   diffSeconds=$(awk 'BEGIN { print '$diffMilliSec'/'1000' }')
+   echo "$diffSeconds"  
+
+}
+
+# gpdebug : fin #####################################################################################
+
Index: TOOLS/SURPACK_IPSL/Makefile
===================================================================
--- TOOLS/SURPACK_IPSL/Makefile	(revision 2136)
+++ TOOLS/SURPACK_IPSL/Makefile	(revision 2136)
@@ -0,0 +1,26 @@
+MODULE_LOADED := $(shell ./check_libccc_user.sh; echo $$?)
+ifeq ($(MODULE_LOADED),1)
+  $(error "Charger le module libccc_user")
+endif
+MPICC=mpicc
+MPICC_OPTS=-g
+# do not forget "module load libccc_user" before
+ifneq ($(CCC_LIBCCC_USER_LDFLAGS),)
+LIBS=$(CCC_LIBCCC_USER_LDFLAGS) 
+MPICC_OPTS+=-D __HAVE_LIBCCC_USER__ -I$(CCC_LIBCCC_USER_INC_DIR)
+endif
+
+.PHONY: all
+all : glost_launch
+
+%:%.c
+	$(MPICC) $(MPICC_OPTS) -o $@ $< $(LIBS)
+	
+clean:
+	$(RM) glost_launch
+
+
+
+
+
+
Index: TOOLS/SURPACK_IPSL/archive_debug.sh
===================================================================
--- TOOLS/SURPACK_IPSL/archive_debug.sh	(revision 2136)
+++ TOOLS/SURPACK_IPSL/archive_debug.sh	(revision 2136)
@@ -0,0 +1,205 @@
+#!/bin/bash
+
+#on veut archiver les fichiers Debug. 
+#Ils seront tous regroupes dans un repertoire DEBUG commun  
+# on les renommes (repertoire DEBUG) de la meme maniere que les fichiers restart
+# puis on les archive via tar par periode 
+#Creation des listes dans un repertoire debug_tar
+
+config_card=${1}
+LISTE_DMNFS=${2}
+
+
+export JOB_DIR=${JOB_DIR:-${TMP_MIGR_DATA}}
+export IGCM_DEM=${IGCM_DEM:-${SCRATCHDIR}/IGCM_DEM}
+export IGCM_TMP=${IGCM_TMP:-${IGCM_DEM}/tmp}
+mkdir -p ${IGCM_DEM}
+mkdir -p ${IGCM_TMP}
+clean_tmp=${clean_tmp:-yes}
+EXE_DIR=$(dirname ${0})
+SCRIPT_NAME=$(basename ${0} )
+
+source ${EXE_DIR}/DEM_utilities.sh
+
+# gpdebug : verif si le present script a ete execute jusqu'au bout #########
+MonitoringInfo="${SCRIPT_NAME}-->OK"
+simuMonitoring_check "$MonitoringInfo" "$config_card"
+
+DEM_log -0 "Demarrage de ${SCRIPT_NAME}"
+
+#### 0- lecture de config.card 
+#### on veut les renseignements suivants : 
+#### JobName, PATH_SIMUL, DateBegin et DateEnd
+eval $(grep JobName ${config_card}) 
+eval $(grep PATH_SIMUL_FULL ${config_card}) 
+eval $(grep DateBegin ${config_card}) 
+eval $(grep DateEnd ${config_card}) 
+eval $(grep IGCM_DEM_SIMU ${config_card})
+
+
+#### Preparation de l'environnement
+# repertoire dans lequel seront renommes les fichiers de debug
+STORE_DEBUG=$IGCM_DEM_SIMU/DEBUG
+mkdir -p ${STORE_DEBUG}
+
+# repertoire dans lequel nous stockerons les listes de debug a archiver
+DEBUG_TAR=$IGCM_DEM_SIMU/debug_tar
+mkdir -p ${DEBUG_TAR}
+STORE_CP=$IGCM_DEM_SIMU/store_cp
+mkdir -p ${STORE_CP}
+
+# lecture de periodpack dans ${IGCM_DEM_SIMU}/period_pack.txt
+period_pack=`awk '{print $0} ' ${IGCM_DEM_SIMU}/period_pack.txt`
+
+#### 1- renommer les fichiers ######
+DEM_log -1 "Renommer les fichiers de Debug"
+
+cd ${STORE_DEBUG}
+if [ "x${STORE_DEBUG}" != "x" ]
+then
+rm -rf *
+fi
+
+# On copie les fichiers de Debug sur le scratchdir en changeant le nom et conservant la date
+grep ${PATH_SIMUL_FULL}/ ${LISTE_DMNFS} | grep DEBUG | grep "f "| awk '{print $3}' |  grep -e '.*/DEBUG/.*\..*' | sort >> ${IGCM_TMP}/${$}.liste_debug_files.txt
+grep -w "tar" ${IGCM_TMP}/${$}.liste_debug_files.txt > ${IGCM_DEM_SIMU}/liste_debug_files_config.txt
+
+# On les copie sur le scratchdir en changeant le nom et conservant la date
+for archive in  `awk '{print $0}' ${IGCM_DEM_SIMU}/liste_debug_files_config.txt`; do 
+    ccc_hsm get $archive
+    tar tf $archive >> ${IGCM_TMP}/${$}.new_liste_debug_files.txt
+done
+
+# Test si il y a un repertoire Debug
+listDebugNbLines=`cat ${IGCM_TMP}/${$}.new_liste_debug_files.txt | wc -l `
+if [ "x${listDebugNbLines}" == "x0" ]
+then
+    DEM_log -0 "Pas de repertoire Debug pour cette simulation"
+else
+
+
+#creation des listes en fonction des suffixes
+   if [ "x${ON_IDRIS}" == "xno" ]
+   then
+       awk '{if (NR >1) print $9}' ${IGCM_TMP}/${$}.new_liste_debug_files.txt > ${IGCM_TMP}/${$}.new_liste_debug_files.txt_tmp
+   else
+       awk '{if (NR >1) print $8}' ${IGCM_TMP}/${$}.new_liste_debug_files.txt > ${IGCM_TMP}/${$}.new_liste_debug_files.txt_tmp       
+   fi
+sort ${IGCM_TMP}/${$}.new_liste_debug_files.txt_tmp > ${IGCM_TMP}/${$}.order_new_liste_debug_files.txt
+ref=`awk -F_ '{if (NR==1) print $1}' ${IGCM_TMP}/${$}.order_new_liste_debug_files.txt`
+
+
+
+i=1
+for new_file in `awk  '{print $0}' ${IGCM_TMP}/${$}.order_new_liste_debug_files.txt`; do 
+    new_ref=$( echo ${new_file} | sed -e "s/_.*//") 
+
+    if [ ${new_ref} == ${ref} ]; then
+	echo ${new_file} >> ${IGCM_TMP}/${$}.debug_list_${i}.txt
+    else
+	ref=${new_ref}
+	(( i = $i + 1 )) 
+	echo ${new_file} >> ${IGCM_TMP}/${$}.debug_list_${i}.txt
+    fi
+done
+
+j=1
+while [[ $j -le $i  ]]; do 
+
+
+### 2- creer les listes de fichiers par periode ####
+    DEM_log -1 "Creation des listes de fichiers par periode"
+### 2.1- extraire l'annee et le mois de DateBegin ###
+    date_begin=${DateBegin}
+    date_end=${DateEnd}
+    
+    year_begin=$(echo ${date_begin} | cut -c 1-4 )
+    month_begin=$(echo ${date_begin} | cut -c 5-6 )
+    year_end=$(echo ${date_end} | cut -c 1-4 )
+    month_end=$(echo ${date_end} | cut -c 5-6 )
+
+
+### 2.2- creation des listes ###
+    date_begin_pack=${date_begin}
+    date_end_simulation=${date_end}
+
+    month_begin_pack=${month_begin}
+    year_begin_pack=${year_begin}
+
+    number_pack=1
+
+    while [ ${date_begin_pack} -le ${date_end_simulation} ]
+    do 
+
+	DEM_log -1 "On calcule la date de fin du pack "
+	month_end_pack=${month_begin_pack}
+	year_end_pack=`expr ${year_begin_pack} + ${period_pack}`
+	
+	date_end_pack=${year_end_pack}${month_end_pack}01   
+	for file in `awk '{print $1}' ${IGCM_TMP}/${$}.debug_list_${j}.txt`; do 
+	    extract_date_file=`echo ${file}  | sed -e "s/.*\${JobName}_//"`
+	    date_file=`echo ${extract_date_file}| sed 's/\([0-9]\{8\}\)_.*$/\1/g'`
+	    if [[  "x${date_file}" != "x" && ! -n ${date_file//[0-9]/} ]]; then
+		if [  ${date_file} -lt ${date_end_pack} ]
+		then 
+		    if [ ${date_file} -ge ${date_begin_pack} ]
+		    then 
+			echo ${file} >> ${IGCM_TMP}/${$}.liste_pack_debug_${number_pack}.txt
+			grep -v ${file} ${IGCM_TMP}/${$}.debug_list_${j}.txt > ${IGCM_TMP}/${$}.debug_list_${j}.txt.tmp
+			mv ${IGCM_TMP}/${$}.debug_list_${j}.txt.tmp ${IGCM_TMP}/${$}.debug_list_${j}.txt
+			
+		    fi
+		fi 
+	    fi
+	    if [  ${date_file} -gt ${date_end_pack} ]
+	    then 
+		break
+	    fi
+	    
+	done
+	month_begin_pack=${month_end_pack}
+	year_begin_pack=${year_end_pack}
+
+	date_begin_pack=${year_begin_pack}${month_begin_pack}01
+
+	number_pack=`expr ${number_pack} + 1`
+    done
+
+    ((j = $j + 1 ))
+done
+
+compt_pack=1
+while [[ $compt_pack -le $number_pack ]]; do 
+
+#on archive les debug - le nom de l'archive contiendra ${yearbegin}${monthbegin}_${yearend}${monthend} 
+# end etant la date du dernier fichier contenu et non pas la premiere date suivant 
+DEM_log -1 "Recherche de la date de fin reel pour nommer l'archive "
+#On classe par ordre alphabetique les fichiers contenus dans liste_pack_debug 
+#la date du dernier fichier donnera la date de fin du pack
+  if [[ -f ${IGCM_TMP}/${$}.liste_pack_debug_${compt_pack}.txt ]] ; then
+   sort ${IGCM_TMP}/${$}.liste_pack_debug_${compt_pack}.txt > ${IGCM_TMP}/${$}.liste_pack_debug_${compt_pack}.txt.tmp
+
+   first_file=$(head -n 1 ${IGCM_TMP}/${$}.liste_pack_debug_${compt_pack}.txt.tmp )
+   extract_date_file=$( echo ${first_file}  | sed -e "s/.*${JobName}_//" )
+   DateBegin_Debug=$(echo ${extract_date_file}| sed 's%\([0-9]\{8\}\)_.*$%\1%g' )
+
+   last_file=$(tail -n 1 ${IGCM_TMP}/${$}.liste_pack_debug_${compt_pack}.txt.tmp )
+   extract_date_file=$( echo ${last_file}  | sed -e "s/.*${JobName}_//" )
+   DateEnd_Debug=$(   echo ${extract_date_file}| sed 's%.*\([0-9]\{8\}\)_.*$%\1%g' )
+   mv ${IGCM_TMP}/${$}.liste_pack_debug_${compt_pack}.txt.tmp ${DEBUG_TAR}/${JobName}_debug_${DateBegin_Debug}_${DateEnd_Debug}.list
+  fi
+
+
+
+DEM_log -1 "On definit le datebegin de la  prochaine periode pack"
+#on definit la periode pack suivante
+
+   compt_pack=`expr ${compt_pack} + 1`
+done
+
+fi
+
+cd ${EXE_DIR}
+
+# gpdebug : le script n a pas rencontre d'erreur. On l'inscrit dans le fichier de suivi
+simuMonitoring_OK "$MonitoringInfo" "$config_card"
Index: TOOLS/SURPACK_IPSL/archive_restart.sh
===================================================================
--- TOOLS/SURPACK_IPSL/archive_restart.sh	(revision 2136)
+++ TOOLS/SURPACK_IPSL/archive_restart.sh	(revision 2136)
@@ -0,0 +1,200 @@
+#!/bin/bash
+
+
+#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/PATH_SIMUL
+# $2=period_pack en M/m ou Y/y
+
+config_card=${1}
+LISTE_DMNFS=${2}
+
+
+export JOB_DIR=${JOB_DIR:-${TMP_MIGR_DATA}}
+export IGCM_DEM=${IGCM_DEM:-${SCRATCHDIR}/IGCM_DEM}
+export IGCM_TMP=${IGCM_TMP:-${IGCM_DEM}/tmp}
+mkdir -p ${IGCM_DEM}
+mkdir -p ${IGCM_TMP}
+clean_tmp=${clean_tmp:-yes}
+EXE_DIR=$(dirname ${0})
+SCRIPT_NAME=$(basename ${0} )
+
+source ${EXE_DIR}/DEM_utilities.sh
+
+# gpdebug : verif si le present script a ete execute jusqu'au bout #########
+MonitoringInfo="${SCRIPT_NAME}-->OK"
+simuMonitoring_check "$MonitoringInfo" "$config_card"
+
+DEM_log -0 "Demarrage de ${SCRIPT_NAME}"
+
+
+#### 0- lecture de config.card 
+#### on veut les renseignements suivants : 
+#### JobName, PATH_SIMUL, DateBegin et DateEnd
+eval $(grep JobName ${config_card}) 
+eval $(grep PATH_SIMUL_FULL ${config_card}) 
+eval $(grep DateBegin ${config_card}) 
+eval $(grep DateEnd ${config_card}) 
+eval $(grep IGCM_DEM_SIMU ${config_card})
+
+
+#### Preparation de l'environnement
+# repertoire dans lequel seront renommes les fichiers de restart
+STORE_RESTART=$IGCM_DEM_SIMU/RESTART
+mkdir -p ${STORE_RESTART}
+
+# repertoire dans lequel nous stockerons les listes de restart a archiver
+RESTART_TAR=$IGCM_DEM_SIMU/restart_tar
+mkdir -p ${RESTART_TAR}
+
+# lecture de periodpack dans ${IGCM_DEM_SIMU}/period_pack.txt
+period_pack=`awk '{print $0} ' ${IGCM_DEM_SIMU}/period_pack.txt`
+
+DEM_log -1 "Period pack = ${period_pack}" 
+#### 1- renommer les fichiers ######
+DEM_log -1 "Renommer les fichiers de Restart"
+
+cd ${STORE_RESTART}
+if [ "x${STORE_RESTART}" != "x" ]
+then
+    rm -rf *
+fi
+# On les copie sur le scratchdir en changeant le nom et conservant la date
+for archive in  `awk '{print $2}' ${IGCM_DEM_SIMU}/liste_restart_files_config.txt`; do 
+    ccc_hsm get $archive
+    tar tf $archive >> ${IGCM_TMP}/${$}.new_liste_restart_files.txt
+done
+
+### creation de liste en fonction du type de restart
+sort ${IGCM_TMP}/${$}.new_liste_restart_files.txt > ${IGCM_TMP}/${$}.order_new_liste_restart_files.txt
+ref=`awk -F_ '{if (NR==1) print $1}' ${IGCM_TMP}/${$}.order_new_liste_restart_files.txt`
+
+i=1
+for new_file in `awk  '{print $0}' ${IGCM_TMP}/${$}.order_new_liste_restart_files.txt`; do 
+    new_ref=$( echo ${new_file} | sed -e "s/_.*//") 
+
+    if [ ${new_ref} == ${ref} ]; then
+	echo ${new_file} >> ${IGCM_TMP}/${$}.restart_list_${i}.txt
+    else
+	ref=${new_ref}
+	(( i = $i + 1 )) 
+	echo ${new_file} >> ${IGCM_TMP}/${$}.restart_list_${i}.txt
+    fi
+done
+
+
+
+j=1
+while [[ $j -le $i  ]]; do 
+
+### 2- creer les listes de fichiers par periode ####
+    DEM_log -1 "Creation des listes de fichiers par periode"
+### 2.1- extraire l'annee et le mois de DateBegin ###
+    date_begin=${DateBegin}
+    date_end=${DateEnd}
+
+    year_begin=$(echo ${date_begin} | cut -c 1-4 )
+    month_begin=$(echo ${date_begin} | cut -c 5-6 )
+    year_end=$(echo ${date_end} | cut -c 1-4 )
+    month_end=$(echo ${date_end} | cut -c 5-6 )
+
+
+### 2.2- creation des listes ###
+    date_begin_pack=${date_begin}
+    date_end_simulation=${date_end}
+
+    month_begin_pack=${month_begin}
+    year_begin_pack=${year_begin}
+
+    number_pack=1
+    while [ ${date_begin_pack} -le ${date_end_simulation} ]
+    do 
+	
+	month_end_pack=${month_begin_pack}
+	year_end_pack=`expr ${year_begin_pack} + ${period_pack}`
+
+
+	date_end_pack=${year_end_pack}${month_end_pack}01   
+	
+	for file in `awk '{print $1}' ${IGCM_TMP}/${$}.restart_list_${j}.txt`; do   
+	    extract_date_file=`echo ${file}  | sed -e "s/.*\${JobName}_//"`
+	    date_file=`echo ${extract_date_file}| sed 's/\([0-9]\{8\}\)_.*$/\1/g'`
+	    
+	    if [  ${date_file} -lt ${date_end_pack} ]
+	    then
+		if [ ${date_file} -ge ${date_begin_pack} ]
+		then 
+		    echo ${file} >> ${IGCM_TMP}/${$}.liste_pack_restart_${number_pack}.txt
+		    grep -v ${file} ${IGCM_TMP}/${$}.restart_list_${j}.txt > ${IGCM_TMP}/${$}.restart_list_${j}.txt.tmp
+		    mv ${IGCM_TMP}/${$}.restart_list_${j}.txt.tmp ${IGCM_TMP}/${$}.restart_list_${j}.txt
+		fi
+		
+	    fi
+	    if [  ${date_file} -gt ${date_end_pack} ]
+	    then 
+		break
+	    fi
+	done
+
+
+
+	DEM_log -1 "On definit le datebegin de la  prochaine periode pack"
+#on definit la periode pack suivante
+	month_begin_pack=${month_end_pack}
+	year_begin_pack=${year_end_pack}
+	
+	date_begin_pack=${year_begin_pack}${month_begin_pack}01
+	
+	number_pack=`expr ${number_pack} + 1`
+
+    done
+
+    ((j = $j + 1 ))
+done
+
+compt_pack=1
+while [[ $compt_pack -le $number_pack ]]; do 
+#on archive les restart - le nom de l'archive contiendra ${yearbegin}${monthbegin}_${yearend}${monthend} 
+# end etant la date du dernier fichier contenu et non pas la premiere date suivant 
+    DEM_log -1 "Recherche de la date de fin reel pour nommer l'archive "
+#On classe par ordre alphabetique les fichiers contenus dans liste_pack_restart 
+#la date du dernier fichier donnera la date de fin du pack
+    if [[ -f ${IGCM_TMP}/${$}.liste_pack_restart_${compt_pack}.txt ]] ; then
+	sort ${IGCM_TMP}/${$}.liste_pack_restart_${compt_pack}.txt > ${IGCM_TMP}/${$}.liste_pack_restart_${compt_pack}.txt.tmp
+
+	first_file=$(head -n 1 ${IGCM_TMP}/${$}.liste_pack_restart_${compt_pack}.txt.tmp )
+	extract_date_file=$( echo ${first_file}  | sed -e "s/.*${JobName}_//" )
+	DateBegin_Restart=$(echo ${extract_date_file}| sed 's%\([0-9]\{8\}\)_.*$%\1%g' )
+	    
+	last_file=$(tail -n 1 ${IGCM_TMP}/${$}.liste_pack_restart_${compt_pack}.txt.tmp )
+	extract_date_file=$( echo ${last_file}  | sed -e "s/.*${JobName}_//" )
+	DateEnd_Restart=$(   echo ${extract_date_file}| sed 's/\([0-9]\{8\}\)_.*$/\1/g' )
+	mv ${IGCM_TMP}/${$}.liste_pack_restart_${compt_pack}.txt.tmp ${RESTART_TAR}/${JobName}_restart_${DateBegin_Restart}_${DateEnd_Restart}.list
+    fi
+
+compt_pack=`expr ${compt_pack} + 1`
+done
+
+
+cd ${EXE_DIR}
+
+# gpdebug : le script n'a pas rencontre d'erreur. On l'inscrit dans le fichier de suivi
+simuMonitoring_OK "$MonitoringInfo" "$config_card"
Index: TOOLS/SURPACK_IPSL/calcul_size_simul.sh
===================================================================
--- TOOLS/SURPACK_IPSL/calcul_size_simul.sh	(revision 2136)
+++ TOOLS/SURPACK_IPSL/calcul_size_simul.sh	(revision 2136)
@@ -0,0 +1,54 @@
+#!/bin/bash
+
+#### On veut calculer si l'ensemble des fichiers d'une simulation 
+#### est bien superieur a 1G
+
+config_card=${1}
+LISTE_DMNFS=${2}
+
+export JOB_DIR=${JOB_DIR:-${TMP_MIGR_DATA}}
+export IGCM_DEM=${IGCM_DEM:-${SCRATCHDIR}/IGCM_DEM}
+export IGCM_TMP=${IGCM_TMP:-${IGCM_DEM}/tmp}
+mkdir -p ${IGCM_DEM}
+mkdir -p ${IGCM_TMP}
+
+EXE_DIR=$(dirname ${0})
+SCRIPT_NAME=$(basename ${0} )
+source ${EXE_DIR}/DEM_utilities.sh
+
+# gpdebug : verif si le present script a ete execute jusqu'au bout #########
+MonitoringInfo="${SCRIPT_NAME}-->OK"
+simuMonitoring_check "$MonitoringInfo" "$config_card"
+
+DEM_log -0 "Demarrage de ${SCRIPT_NAME}"
+
+eval $(grep JobName ${config_card}) 
+eval $(grep PATH_SIMUL_FULL ${config_card}) 
+eval $(grep DateBegin ${config_card}) 
+eval $(grep DateEnd ${config_card}) 
+eval $(grep IGCM_DEM_SIMU ${config_card})
+
+
+
+## 1 Go
+limitmin=1000000000
+
+#cree la liste de l'ensemble des fichiers de la simulation
+#echo ${PATH_SIMUL_FULL} ${LISTE_DMNFS}
+grep ${PATH_SIMUL_FULL}/ ${LISTE_DMNFS} | grep 'f ' >> ${IGCM_TMP}/$$.info_tmp.txt 
+awk '{print $(NF-1) " " $(NF)}' ${IGCM_TMP}/$$.info_tmp.txt > ${IGCM_DEM_SIMU}/All_files_simul.txt
+
+size=`awk 'BEGIN {y = 0} {x = $1 ; y = y + x } END{print y}'  ${IGCM_DEM_SIMU}/All_files_simul.txt`
+DEM_log -3 "la taille de la simulation est  $size"
+if [  ${size} -lt ${limitmin} ]
+then
+
+    DEM_log -0  "Simulation < 1Go -  on l'archive avec tar"
+    ./write_liste_tar.sh ${config_card}
+    MonitoringInfo="${SCRIPT_NAME}-->special simu==>OK"
+    
+fi
+# gpdebug : le script n'a pas rencontre d'erreur. On l'inscrit dans le fichier de suivi
+simuMonitoring_OK "$MonitoringInfo" "$config_card"
+
+DEM_log -0 "Fin de ${SCRIPT_NAME}"
Index: TOOLS/SURPACK_IPSL/check_libccc_user.sh
===================================================================
--- TOOLS/SURPACK_IPSL/check_libccc_user.sh	(revision 2136)
+++ TOOLS/SURPACK_IPSL/check_libccc_user.sh	(revision 2136)
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+function check_cdo
+{
+   . load_ipslPack_env.sh
+   module list >& ${TMP_MIGR_DATA}/myModuleList.txt 
+   
+   # Presence de la chaine "n) nco/" ou n est un nombre  
+   nb_of_libLines=` grep -e '[[:digit:]]*) libccc_user/' ${TMP_MIGR_DATA}/myModuleList.txt | wc -l `
+
+   if [ "x${nb_of_libLines}" == "x0" ]
+   then
+       # echo "1"
+       exit 1
+   fi
+
+   # Plus besoin du myModuleList.txt
+   rm -f ${TMP_MIGR_DATA}/myModuleList.txt > /dev/null 2>&1
+   # echo "0"
+   exit 0
+
+}
+
+
+check_cdo
Index: TOOLS/SURPACK_IPSL/check_ncrcat_list.sh
===================================================================
--- TOOLS/SURPACK_IPSL/check_ncrcat_list.sh	(revision 2136)
+++ TOOLS/SURPACK_IPSL/check_ncrcat_list.sh	(revision 2136)
@@ -0,0 +1,108 @@
+#!/bin/bash
+listToProcessFile="${1}"
+# exemple de fichier liste :
+# /ccc/scratch/cont003/incka/pierreg/IGCM_DEM/dataDMNFS_FromTitane/IGCM_OUT/IPSLCM5A/REDO/historicalGHG/v3.historicalGHG1R/output_tar/v3.historicalGHG1R_20101201_20121231_1M_histmthNMC.nc.list
+
+
+# On renseigne les variables d'environnement (ici surtout pour la var OUTPUT_CHECK) 
+. load_ipslPack_env.sh
+
+
+dirin=$INPUT_DMF_DATA
+dirout=$OUTPUT_STORE
+dirout_work=$OUTPUT_WORK
+dirout_check=$OUTPUT_CHECK
+
+export JOB_DIR=${TMP_MIGR_DATA}
+export EXE_DIR=${LS_SUBCWD:-${PWD}}
+source ${EXE_DIR}/DEM_utilities.sh
+
+# Ca sert a quoi tout ca ?
+# dirPathOfListFile=$( dirname  $listToProcessFile )
+# dirnameOfListFile=$( basename $dirPathOfListFile )
+
+# rep de simu : celui contenant le rep qui contient la liste
+# PATH_SIMU=$( dirname  $dirPathOfListFile )
+
+set=$listToProcessFile
+
+
+#-----------------------------------
+# Set output file name from list name
+
+fileout1=$( basename $set )
+fileout=${fileout1%.list}
+
+filefirst=`head -n 1 $set`
+diroutputfile=`dirname $filefirst | sed -e "s%$dirin%$dirout%"`
+
+output_ncrcat_file=$diroutputfile/${fileout}
+
+#----------------------------------
+fileout_cdocat=${fileout1%.list}.cdocat
+
+dirOutput_cdocat_file=`dirname $filefirst | sed -e "s%$dirin%$dirout_check%"`
+
+output_cdocat_file=${dirOutput_cdocat_file}/${fileout_cdocat}
+
+
+#----------------------------------
+# log file 
+datestr=`LC_ALL=C date +"%Y%m%dTT%H%M%S"`
+logfile=${fileout_cdocat%%.cdocat}_${datestr}.log
+output_cdocat_logFile=${dirOutput_cdocat_file}/${logfile}
+
+
+#echo
+#echo "ncrcat file to compare cdo cat file with :"
+#echo "$output_ncrcat_file"
+#echo
+#echo "Output cdo cat file to create:"
+#echo "$output_cdocat_file"
+#echo
+#echo "Output cdo cat log file:"
+#echo "$output_cdocat_logFile"
+
+if [ ! -e $listToProcessFile ]
+then
+    echo "Le fichier en entree n'existe pas. STOP." > $output_cdocat_logFile
+    exit 1
+fi
+
+
+if [ ! -e $outputfile ]
+then
+   echo "Le fichier liste suivant n'existe pas :" >> $output_cdocat_logFile
+   echo "$outputfile" >> $output_cdocat_logFile
+   exit 1
+fi
+
+mkdir -p $dirOutput_cdocat_file
+
+listOfFilesToCdocat=`cat $listToProcessFile `
+
+
+cdo cat $listOfFilesToCdocat $output_cdocat_file > $output_cdocat_logFile 2>&1
+
+
+echo >> $output_cdocat_logFile
+
+vartoexclude="t_inst*,contfracATM,sobowlin,Contfrac,LandPoints"
+./diff.bash $output_ncrcat_file $output_cdocat_file $vartoexclude >> $output_cdocat_logFile
+
+code_sortie=$?
+
+exit $code_sortie
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: TOOLS/SURPACK_IPSL/check_tar_list.sh
===================================================================
--- TOOLS/SURPACK_IPSL/check_tar_list.sh	(revision 2136)
+++ TOOLS/SURPACK_IPSL/check_tar_list.sh	(revision 2136)
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+listToProcessFile="${1}"
+
+echo "A faire. STOP."
+exit 0
+
+
+
Index: TOOLS/SURPACK_IPSL/cmd_launch.c
===================================================================
--- TOOLS/SURPACK_IPSL/cmd_launch.c	(revision 2136)
+++ TOOLS/SURPACK_IPSL/cmd_launch.c	(revision 2136)
@@ -0,0 +1,107 @@
+#include <mpi.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define CMD_MAXLEN 4096
+#define CMD_MASTER 0
+#define TAG_AVAIL 1
+#define TAG_CMD   2
+
+void read_and_exec(char *filename);
+void read_and_send(int slaves, char *filename);
+void recv_and_exec(int rank);
+void read_next_command(FILE *fl, char *cmd);
+void exec_command(char *cmd, int rank);
+
+int main(int argc,char **argv)
+{
+	FILE *fl;
+	int rank,size;
+
+	MPI_Init(&argc,&argv);
+	MPI_Comm_rank(MPI_COMM_WORLD,&rank);
+	MPI_Comm_size(MPI_COMM_WORLD,&size);  
+	if (rank == CMD_MASTER)
+		printf("master is %d , nb slaves: %d\n",
+		       CMD_MASTER,size-1);	
+
+	if (size == 1)
+		read_and_exec(argv[1]);
+	else if(size != 1 && rank == CMD_MASTER)
+		read_and_send(size-1,argv[1]);
+	else
+		recv_and_exec(rank);
+	MPI_Finalize();
+}
+
+void read_and_exec(char *filename)
+{
+	FILE *fl;
+	char cmd[CMD_MAXLEN];
+	double t;
+
+	fl = fopen(filename,"r");
+	do {
+	  read_next_command(fl,cmd);
+		if(!strlen(cmd))
+			break;
+		exec_command(cmd,CMD_MASTER);
+	} while (strlen(cmd));
+	fclose(fl);
+}
+
+void read_and_send(int slaves,char *filename)
+{
+	int i, num;
+	MPI_Status status;
+	FILE *fl;
+	char cmd[CMD_MAXLEN];
+
+	fl = fopen(filename,"r");
+	i=0;
+	do {
+	        read_next_command(fl,cmd);
+		MPI_Recv(&num,1,MPI_INT,MPI_ANY_SOURCE,
+			 TAG_AVAIL,MPI_COMM_WORLD,&status);
+		MPI_Send(cmd,CMD_MAXLEN,MPI_CHAR,num,
+			 TAG_CMD,MPI_COMM_WORLD);
+		if (!strlen(cmd)) /* terminate command sent */
+			i++;
+	} while (i < slaves);
+	fclose(fl);
+}
+
+void recv_and_exec(int rank)
+{
+	char cmd[CMD_MAXLEN];  
+	MPI_Status status;  
+
+	do {
+		MPI_Send(&rank,1,MPI_INT,CMD_MASTER,
+			 TAG_AVAIL,MPI_COMM_WORLD); 
+		MPI_Recv(cmd,CMD_MAXLEN,MPI_CHAR,CMD_MASTER,
+			 TAG_CMD,MPI_COMM_WORLD,&status); 
+		if(!strlen(cmd)) /* terminate command */
+			break;
+		exec_command(cmd,rank);
+	} while (strlen(cmd));
+}
+
+void read_next_command(FILE *fl,char *cmd)
+{
+	if(!fgets(cmd,CMD_MAXLEN,fl)) cmd[0]='\0';
+	if(cmd[strlen(cmd)-1]=='\n') cmd[strlen(cmd)-1]='\0';
+}
+
+void exec_command(char *cmd, int rank)
+{
+	double t;
+	int r;
+
+	t = MPI_Wtime();  
+	r=system(cmd);
+	t = MPI_Wtime() - t;  
+	fprintf(stderr,"#executed by process\t%d in %gs\twith status\t%d : %s\n",
+		rank,t,r,cmd);
+}
Index: TOOLS/SURPACK_IPSL/create_config_card.sh
===================================================================
--- TOOLS/SURPACK_IPSL/create_config_card.sh	(revision 2136)
+++ TOOLS/SURPACK_IPSL/create_config_card.sh	(revision 2136)
@@ -0,0 +1,188 @@
+#!/bin/bash
+##
+## Job permettant de recreer une partie du config.card d'une simulation
+## Champs vises : JobName / DateBegin / DateEnd / Calendar 
+##
+
+# Prend en argument un fichier contenant une liste de simulations
+# cree pour chacune son config.card
+# Ex : ./create_config_card.job liste_simul_fichier_param_test1.txt liste_fichier_dmnfs
+# Ex : ./create_config_card.job liste_simul_param_SL.txt /cscratch/cont003/labetoul/FROM_CCRT_INFORMATIONS_DMNFS/information_dmnfs_2012-03-21
+
+
+LISTE_SIMUL=${1}
+LISTE_DMNFS=${2}
+
+# ----
+export JOB_DIR=${JOB_DIR:-${TMP_MIGR_DATA}}
+export IGCM_DEM=${IGCM_DEM:-${SCRATCHDIR}/IGCM_DEM}
+export IGCM_TMP=${IGCM_TMP:-${IGCM_DEM}/tmp}
+mkdir -p ${IGCM_DEM}
+mkdir -p ${IGCM_TMP}
+clean_tmp=${clean_tmp:-yes}
+EXE_DIR=$(dirname ${0})
+SCRIPT_NAME=$(basename ${0} )
+source ${EXE_DIR}/DEM_utilities.sh
+
+# gpdebug : verif si le present script a ete execute jusqu'au bout #########
+MonitoringInfo="${SCRIPT_NAME}-->OK"
+generalMonitoring "$MonitoringInfo"
+
+DEM_log -0 "Demarrage de ${SCRIPT_NAME}"
+
+# gpdebug : on augmente la liste des proc à détruire en cas d'erreur bloquante du présent proc
+export listPID="$$ ${listPID}" #########
+
+cd ${JOB_DIR}
+# ----
+
+DEM_log -0 "LISTE_SIMUL : ${LISTE_SIMUL}"
+DEM_log -0 "LISTE_DMNFS : ${LISTE_DMNFS}"
+
+[[ -f ${IGCM_DEM}/config_card.liste ]] && rm ${IGCM_DEM}/config_card.liste
+
+
+for PATH_SIMUL_FULL in `awk  '{print $0}' ${LISTE_SIMUL}` ; do 
+
+    DEM_log -3 PATH_SIMUL_FULL : ${PATH_SIMUL_FULL}
+    PATH_SIMUL_SHORT=$(echo ${PATH_SIMUL_FULL} | sed "s%${INPUT_DMF_DATA}/%%" ) # gpdebug : added
+    DEM_log -3 PATH_SIMUL_SHORT : ${PATH_SIMUL_SHORT}
+
+    IGCM_DEM_SIMU=${IGCM_DEM}/${PATH_SIMUL_SHORT}
+    mkdir -p ${IGCM_DEM_SIMU}
+    rm -rf ${IGCM_DEM_SIMU}/*
+
+### note dans cette version on ne gere pas les fichiers Analyse / Monitoring ils sont deja la ou il faut et comme il faut
+    # on recherche le nom du job
+    JobName=""
+    
+
+    # Etablir la liste des fichiers de restart
+    grep ${PATH_SIMUL_FULL}/ ${LISTE_DMNFS} | grep RESTART | awk '{print $2 " " $3}' | grep -e '.*/RESTART/.*\..*' |grep -v "jnl" | sort  >> ${IGCM_TMP}/${$}.liste_restart_files_config.txt
+
+    # Retirons de la liste les fichiers que l'on n'attends pas, en particulier si il  y a des sous-repertoires au repetoire RESTART/
+    for file in `awk  '{print $2}'  ${IGCM_TMP}/${$}.liste_restart_files_config.txt ` ; do 
+	dir=$( echo $file | sed -e "s%.*RESTART/%%") 
+	testdir=$(dirname ${dir}) 
+	if [ $testdir != "." ]; then 
+	    echo $( grep ${file} ${IGCM_TMP}/${$}.liste_restart_files_config.txt)  >> ${IGCM_TMP}/${$}.liste_no_restart_files_config.txt
+	fi
+    done
+    if [ -f ${IGCM_TMP}/${$}.liste_no_restart_files_config.txt ]; then 
+	join -t % -v 1 ${IGCM_TMP}/${$}.liste_restart_files_config.txt ${IGCM_TMP}/${$}.liste_no_restart_files_config.txt > ${IGCM_TMP}/${$}.info_tmp.txt
+	mv ${IGCM_TMP}/${$}.info_tmp.txt ${IGCM_TMP}/${$}.liste_restart_files_config.txt
+    fi
+    
+    # Etablir la liste des fichiers output
+    grep ${PATH_SIMUL_FULL}/ ${LISTE_DMNFS} | grep Output  | awk '{print $2 " "  $3}' | grep -e '.*/Output/.*\.nc$'  | sort >> ${IGCM_TMP}/${$}.liste_output_files_config.txt
+    # Retirons de la liste les fichiers que l'on n'attends pas, en particulier si il  y a des sous-repertoires aux repetoires Output/*/
+    for file in `awk  '{print $2}'  ${IGCM_TMP}/${$}.liste_output_files_config.txt ` ; do 
+	dir=$( echo $file | sed -e "s%.*Output/[^/]*/%%") 
+	testdir=$(dirname ${dir}) 
+	if [ $testdir != "." ]; then 
+	    echo $( grep ${file} ${IGCM_TMP}/${$}.liste_output_files_config.txt ) >> ${IGCM_TMP}/${$}.liste_no_output_files_config.txt
+	fi
+    done
+    if [ -f ${IGCM_TMP}/${$}.liste_no_output_files_config.txt ]; then 
+	join -t % -v 1 ${IGCM_TMP}/${$}.liste_output_files_config.txt ${IGCM_TMP}/${$}.liste_no_output_files_config.txt > ${IGCM_TMP}/${$}.info_tmp.txt
+	mv ${IGCM_TMP}/${$}.info_tmp.txt ${IGCM_TMP}/${$}.liste_output_files_config.txt
+    fi
+
+    # Lecture du nom du job
+    JobName=`awk -F/ '{if (NR==1) print $(NF-2)}'  ${IGCM_TMP}/${$}.liste_restart_files_config.txt`
+
+    DEM_log -2 JobName ${JobName}
+
+   # traitons les listes de restart pour conserver ceux qui correspondent au format $JobName_restart_date_date.tar et $JobName_date_date_restart.tar
+   # on enleve les fichiers qui ne sont pas en .tar
+   grep -w "tar" ${IGCM_TMP}/${$}.liste_restart_files_config.txt  >  ${IGCM_TMP}/${$}.info_tmp.txt; mv ${IGCM_TMP}/${$}.info_tmp.txt  ${IGCM_TMP}/${$}.liste_restart_files_config.txt 
+   # dans ces fichiers on enleve ceux qui n'ont pas la chaine "restart" (attention suivant d'ou provient la simulation (pack ou libigcm) la chaine restart n'est pas situee au meme endroite
+   grep "restart"  ${IGCM_TMP}/${$}.liste_restart_files_config.txt  >  ${IGCM_TMP}/${$}.info_tmp.txt; mv ${IGCM_TMP}/${$}.info_tmp.txt  ${IGCM_TMP}/${$}.liste_restart_files_config.txt 
+   # dans ces fichiers on enleve ceux qui n'ont pas le jobName
+   grep $JobName ${IGCM_TMP}/${$}.liste_restart_files_config.txt  >  ${IGCM_TMP}/${$}.info_tmp.txt; mv ${IGCM_TMP}/${$}.info_tmp.txt  ${IGCM_TMP}/${$}.liste_restart_files_config.txt    
+
+   mv ${IGCM_TMP}/${$}.liste_restart_files_config.txt    ${IGCM_DEM_SIMU}/liste_restart_files_config.txt
+
+# Maintenant que nous avons JobName verifions que tous les fichiers de Output sont bien du type JobName_date_*
+    sed -e "s%.*/${JobName}_\([0-9]\{8\}\)_%%" ${IGCM_TMP}/${$}.liste_output_files_config.txt  >  ${IGCM_TMP}/${$}.info_tmp.txt
+    cat ${IGCM_TMP}/${$}.info_tmp.txt |grep "/" >  ${IGCM_TMP}/${$}.info_tmp_bis.txt
+    join -t % -v 1 ${IGCM_TMP}/${$}.liste_output_files_config.txt ${IGCM_TMP}/${$}.info_tmp_bis.txt > ${IGCM_TMP}/${$}.output.tmp
+    sort -k 2 ${IGCM_TMP}/${$}.output.tmp > ${IGCM_TMP}/${$}.output_bis.tmp
+    mv ${IGCM_TMP}/${$}.output_bis.tmp ${IGCM_DEM_SIMU}/liste_output_files_config.txt
+
+
+## Recherche de DateBegin et DateEnd pour les Restarts
+    typeRestart=`awk -F_ '{if (NR==1) print $(NF)}'  ${IGCM_DEM_SIMU}/liste_restart_files_config.txt `
+    echo $typeRestart
+    if [[ "$typeRestart" == "restart.tar" ]]; then 
+	first_file=$(        head -n 1 ${IGCM_DEM_SIMU}/liste_restart_files_config.txt )
+	extract_date_file=$( echo ${first_file}  | sed -e "s/.*${JobName}_//" | sed -e 's/_restart.tar//g' )
+	DateBegin_Restart=$( echo ${extract_date_file}| sed 's/\([0-9]\{8\}\)_.*$/\1/g' )
+
+	last_file=$(         tail -n 1 ${IGCM_DEM_SIMU}/liste_restart_files_config.txt )
+	extract_date_file=$( echo ${last_file}  | sed -e "s/.*${JobName}_//" | sed -e 's/_restart.tar//g' )
+	DateEnd_Restart=$(   echo ${extract_date_file}| sed 's/.*_\([0-9]\{8\}\).*$/\1/g' )
+    else
+	first_file=$(        head -n 1 ${IGCM_DEM_SIMU}/liste_restart_files_config.txt )
+	extract_date_file=$( echo ${first_file}  | sed -e "s/.*${JobName}_restart_//" | sed -e 's/\.tar//g' )
+	DateBegin_Restart=$( echo ${extract_date_file}| sed 's/\([0-9]\{8\}\)_.*$/\1/g' )
+
+	last_file=$(         tail -n 1 ${IGCM_DEM_SIMU}/liste_restart_files_config.txt )
+	extract_date_file=$( echo ${last_file}  | sed -e "s/.*${JobName}_restart_//" | sed -e 's/\.tar//g' )
+	DateEnd_Restart=$(   echo ${extract_date_file}| sed 's/.*_\([0-9]\{8\}\).*$/\1/g' )
+	
+    fi
+
+
+# Recherche de DateBegin et DateEnd pour les Output
+    first_file=$( head -n 1 ${IGCM_DEM_SIMU}/liste_output_files_config.txt )
+    extract_date_file=$( echo ${first_file}  | sed -e "s/.*${JobName}_//" )
+    DateBegin_Output=$(  echo ${extract_date_file}| sed 's/\([0-9]\{8\}\)_.*$/\1/g' )
+    
+    last_file=$(         tail -n 1 ${IGCM_DEM_SIMU}/liste_output_files_config.txt )
+    extract_date_file=$( echo ${last_file}  | sed -e "s/.*${JobName}_//" )
+    DateEnd_Output=$(    echo ${extract_date_file}| sed 's/.*_\([0-9]\{8\}\)_.*$/\1/g' )
+    
+    DateBegin=${DateBegin_Restart}
+    DateEnd=${DateEnd_Restart}
+
+    DEM_log -2 "DateBegin DateEnd : ${DateBegin} ${DateEnd}"
+    DEM_log -2 "DateBegin_Output DateEnd_Output : ${DateBegin_Output} ${DateEnd_Output}"
+    DEM_log -2 "DateBegin_Restart DateEnd_Restart : ${DateBegin_Restart} ${DateEnd_Restart}"
+
+    DateBegin=$( DEM_min ${DateBegin_Output} ${DateBegin} ) 
+    DateEnd=$(   DEM_max ${DateEnd_Output}   ${DateEnd}   )
+    
+    DEM_log -2  "DateBegin DateEnd : ${DateBegin} ${DateEnd}"
+    
+    [[ "${clean_tmp}" = "yes" ]] && rm -f ${IGCM_TMP}/${$}.config_name ${IGCM_TMP}/${$}.liste_output_files_config.txt ${IGCM_TMP}/${$}.liste_restart_files_config.txt
+    
+    rm -f ${IGCM_DEM_SIMU}/config_card_${JobName}
+    cat<<EOD>${IGCM_DEM_SIMU}/config_card_${JobName}
+JobName=${JobName}
+DateBegin=${DateBegin}
+DateEnd=${DateEnd}
+PATH_SIMUL_FULL=${PATH_SIMUL_FULL}
+IGCM_DEM_SIMU=${IGCM_DEM_SIMU}
+EOD
+    
+    echo "${IGCM_DEM_SIMU}/config_card_${JobName} ListToBeDone" >> ${IGCM_DEM}/config_card.liste
+
+    DEM_log -1 "${IGCM_DEM_SIMU}/config_card_${JobName} ListToBeDone >> ${IGCM_DEM}/config_card.liste"
+
+#si la liste des fichiers d'output est vide on tar la simul 
+if [[ !  -s ${IGCM_DEM_SIMU}/liste_output_files_config.txt ]]; then
+DEM_log -2 "liste output vide"
+    cd ${EXE_DIR}
+    ./write_liste_tar.sh ${IGCM_DEM_SIMU}/config_card_${JobName}
+    cd ${JOB_DIR}
+fi 
+
+
+done
+
+# gpdebug : le script n'a pas rencontre d'erreur. On l'inscrit dans le fichier de suivi
+echo $MonitoringInfo >> $generalMonitorFile
+
+DEM_log -0 "Fin de ${SCRIPT_NAME}"
+
Index: TOOLS/SURPACK_IPSL/create_listing.sh
===================================================================
--- TOOLS/SURPACK_IPSL/create_listing.sh	(revision 2136)
+++ TOOLS/SURPACK_IPSL/create_listing.sh	(revision 2136)
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+#cree le listing du repertoire REPtoLISTE ($1) 
+#exemple REPtoList=/dmnfs09/cont003/p86cadul/IGCM_OUT
+
+REPtoList=$1
+
+EXE_DIR=$(dirname ${0})
+SCRIPT_NAME=$(basename ${0} )
+export IGCM_DEM=${IGCM_DEM:-${SCRATCHDIR}/IGCM_DEM}
+export IGCM_TMP=${IGCM_TMP:-${IGCM_DEM}/tmp}
+
+source ${EXE_DIR}/DEM_utilities.sh
+
+# gpdebug : verif si le present script a ete execute jusqu'au bout, sinon on sort #########
+createListingMonitoring_Check "$REPtoList"
+
+DEM_log -0 "Demarrage de ${SCRIPT_NAME}"
+
+# gpdebug : on augmente la liste des proc à détruire en cas d'erreur bloquante du présent proc
+export listPID="$$ ${listPID}" #########
+
+echo "gpdebug : REPtoList=$REPtoList" # gpdebug : a virer
+find $REPtoList -printf "%y %s %p \n" >> ${IGCM_DEM}/Listing.txt
+
+cd $EXE_DIR
+#lors de la creation de la liste on retire les repertoires SPIN qui seront traites ulterieurement par le ccrt 
+sed '/SPIN/d' ${IGCM_DEM}/Listing.txt > ${IGCM_TMP}/Listing_tmp.txt; mv ${IGCM_TMP}/Listing_tmp.txt ${IGCM_DEM}/Listing.txt
+# on retire les fichiers issus de liens : le champ de la premiere colonne est alors un l 
+awk '{if ($1!="l") print $0}' ${IGCM_DEM}/Listing.txt > ${IGCM_TMP}/Listing_tmp.txt; mv ${IGCM_TMP}/Listing_tmp.txt ${IGCM_DEM}/Listing.txt
+# on retire les fichiers run.card
+sed '/run.card/d' ${IGCM_DEM}/Listing.txt > ${IGCM_TMP}/Listing_tmp.txt; mv ${IGCM_TMP}/Listing_tmp.txt ${IGCM_DEM}/Listing.txt
+# on retire les fichiers Script_Output
+sed '/Script_Output/d' ${IGCM_DEM}/Listing.txt > ${IGCM_TMP}/Listing_tmp.txt; mv ${IGCM_TMP}/Listing_tmp.txt ${IGCM_DEM}/Listing.txt
+#possibilite de retirer d'autres types de fichiers ex: .jnl* 
+sed '/.jnl/d' ${IGCM_DEM}/Listing.txt > ${IGCM_TMP}/Listing_tmp.txt; mv ${IGCM_TMP}/Listing_tmp.txt ${IGCM_DEM}/Listing.txt
+
+
+# gpdebug : le script n'a pas rencontre d'erreur. On créé un fichier de suivi pour create_listing dans le rep de suivi ##########
+createListingMonitoring_OK "$REPtoList"
+
+DEM_log -0 "Fin de ${SCRIPT_NAME}"
+
Index: TOOLS/SURPACK_IPSL/diff.bash
===================================================================
--- TOOLS/SURPACK_IPSL/diff.bash	(revision 2136)
+++ TOOLS/SURPACK_IPSL/diff.bash	(revision 2136)
@@ -0,0 +1,43 @@
+#!/bin/bash
+#==============================================
+#
+# Usage:
+# ./diff.bash f1.nc f1.nc
+# ./diff.bash f1.nc f1_witherror.nc
+#
+# ./diff.bash fileA.nc fileB.nc 'var1,var2'
+#
+# ex: ./diff.bash file_ncrcat.nc file_cdocat.nc 'contfracATM'
+#
+#==============================================
+
+if [ $# -eq 3 ] ; then
+	delname="-delname,$3"
+fi
+
+cdo -s $delname $1 ${JOB_DIR}/out_tmp1.nc
+cdo -s $delname $2 ${JOB_DIR}/out_tmp2.nc
+
+cdo -s diff ${JOB_DIR}/out_tmp1.nc ${JOB_DIR}/out_tmp2.nc > ${JOB_DIR}/diff_$$.tmp 2>&1
+result2=`cat ${JOB_DIR}/diff_$$.tmp | grep -i "records differ" | tr -s " " | cut -f2 -d" "`
+
+if [ "$result2" = "0" ] ; then
+	# EXIT_SUCCESS
+	echo "Variables from netcdf files : "
+	echo "$1"
+	echo "$2" 
+	echo "are the same"
+	rm -f ${JOB_DIR}/diff_$$.tmp ${JOB_DIR}/out_tmp1.nc ${JOB_DIR}/out_tmp2.nc
+	exit 0
+else
+	# EXIT_FAILURE
+	echo "Variables from netcdf files : "
+	echo "$1"
+	echo "$2" 
+	echo "differ"	
+	cat ${JOB_DIR}/diff_$$.tmp | grep -i "records differ"
+	rm -f ${JOB_DIR}/diff_$$.tmp ${JOB_DIR}/out_tmp1.nc ${JOB_DIR}/out_tmp2.nc
+	echo "==============> ERROR"
+	exit 1 
+fi
+
Index: TOOLS/SURPACK_IPSL/enlarge_my_files.sh
===================================================================
--- TOOLS/SURPACK_IPSL/enlarge_my_files.sh	(revision 2136)
+++ TOOLS/SURPACK_IPSL/enlarge_my_files.sh	(revision 2136)
@@ -0,0 +1,717 @@
+#!/bin/bash
+#------------------------------------------------------
+switchtotar=0
+maxtries=3
+#---------------------------------------------
+while [ $# -ne 0 ]
+do
+        case $1 in
+       --switchtotar)
+		switchtotar=1
+		shift 1 ;;
+       --maxtries)
+		maxtries=$2
+		shift 2 ;;
+       -h|--help|-help)
+                echo "----------------------------------------------------------------------------"
+		echo "Usage: enlarge_my_files.sh [--switchtotar] [--maxtries N] dirin dirout"
+		echo
+		echo "Description:"
+                echo "   Pass a ncrcat, tar or cp command on files from prepared sets of files."
+                echo "   For ncrcat command 2 shots will be done at each try".
+                echo  
+                echo "   A status file and a log file will be created in output_ncrcat directory."
+                echo "   Copy a set to output_tar directory for later processing after N tries."
+		echo
+		echo "Arguments:"
+                echo "   dirin is the input directory where files to concatenate will be read"
+                echo "   dirout is the output directory where concatenated files will be written"
+		echo
+                echo "   The following directory must exist where the command enlarge_my_files is run:"
+		echo "       enlarge_my_files"
+		echo "                       |-- output_ncrcat"
+		echo "                       |   |-- set_000001.list"
+		echo "                       |   |-- set_000002.list"
+		echo "                       |   |-- set_000003.list"
+		echo "                       |   |-- set_000004.list"
+		echo "                       |   \`-- set_000005.list"
+		echo "                       \`-- output_tar"
+		echo
+		echo "Options:"
+                echo "   -h, --help, -help"
+                echo "       Print this manual."
+                echo "   --switchtotar"
+                echo "       Abort ncrcat operation and switch to tar command"
+                echo "   --maxtries N"
+                echo "       Maximum number of tries before switching to tar command" 
+                echo "       Default is 3"
+		echo
+		echo "----------------------------------------------------------------------------"
+		exit ;;
+        -*)
+                `dirname $0`/enlarge_my_files.sh -h
+                exit ;;
+        *)
+                break ;;
+        esac
+done
+
+if [ $# -lt 2 ] ; then
+        `dirname $0`/enlarge_my_files.sh -h
+        exit
+fi
+
+if ( \
+     [ ! -d $PATH_SIMU/output_ncrcat ] || \
+     [ ! -d $PATH_SIMU/output_tar ]    || \
+     [ ! -d $PATH_SIMU/restart_tar ]   || \
+     [ ! -d $PATH_SIMU/store_cp ]      || \
+     [ ! -d $PATH_SIMU/work_cp ]       || \
+     [ ! -d $PATH_SIMU/debug_tar ]     || \
+     [ ! -d $PATH_SIMU/other_tar ] \
+   ) \
+   && \
+   [ ! -e $PATH_SIMU/tar_full_simul.list ]
+then
+        `dirname $0`/enlarge_my_files.sh -h
+        exit
+fi
+
+#------------------------------------------------------
+dirin=$1
+dirout=$2
+dirout_work=$3
+
+#------------------------------------------------------
+function find_varstoexclude {
+nbfile=0
+for file in `cat $1` ; do
+ #   ncdump -h ${file} | gawk '{if (match($0, /(byte|char|short|int|float|double) (.*)\(/, arr)) print arr[2] }' >> tmp_$$.txt
+    ncdump -h ${file} | grep -Ew "byte|char|short|int|float|double"  | awk -F\( '{split($1,a," ") ; split($2,b,")") ; if (a[2] != b[1]) print a[2]}'  >> tmp_$$.txt
+    let nbfile=nbfile+1
+done
+
+varstoexclude=`cat tmp_$$.txt | sort | uniq -c | awk -v nbfile=$nbfile '{if ($1 != nbfile) {print $2}}' | paste -s -d','`
+varstoexcludefiltered=`cat tmp_$$.txt | sort | uniq -c | awk -v nbfile=$nbfile '{if (($1 != nbfile) && !(match($2, /t_inst_(.*)/))) {print $2}}' | paste -s -d','`
+nbvars=`echo $varstoexcludefiltered | gawk -F',' '{print NF}'`
+
+rm -f tmp_$$.txt
+
+return 0 
+}
+
+# gpdebug : pour test showPackProgress.sh *************************
+export RANDOM=$$
+
+function gives_0_or_1
+{
+   bit=-1
+   let "bit = RANDOM % 2"
+   echo $bit
+}
+
+resultCmd=
+# gpdebug : ****************************** fin ********************
+
+source ${EXE_DIR}/DEM_utilities.sh # gpdebug : pour trouver les fonctions de mesure de temps
+
+if ( \
+     [ -d $PATH_SIMU/output_ncrcat ] || \
+     [ -d $PATH_SIMU/output_tar ]    || \
+     [ -d $PATH_SIMU/restart_tar ]   || \
+     [ -d $PATH_SIMU/store_cp ]      || \
+     [ -d $PATH_SIMU/work_cp ]       || \
+     [ -d $PATH_SIMU/debug_tar ]     || \
+     [ -d $PATH_SIMU/other_tar ] \
+   )
+then
+
+    #------------------------------------------------------
+    for set in $( ls $PATH_SIMU/output_ncrcat/*list ) ; do
+
+	    #-----------------------------------
+	    echo "#-------------------"
+	    echo "Set: $set"
+            datestr=`LC_ALL=C date +"%Y%m%dT%H%M%S"`
+	    datestr1=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+	    statusfile=${set%%.list}.status
+	    logfile=${set%%.list}_${datestr}.log
+
+	    #-----------------------------------
+	    # Create status file if not exists
+	    if [ ! -e $statusfile ] ; then
+		    echo "# Status ; DateStart ; DateEnd ; Command ; TarFileExists" > $statusfile
+	    fi
+
+	    #-----------------------------------
+	    # Switch to tar command
+	    if [ $switchtotar -eq 1 ] ; then
+		    echo "====> DELEGATE to tar command with option --switchtotar"
+		    echo "DELEGATE to tar command with option --switchtotar" >> $statusfile
+		    mv $set $PATH_SIMU/output_tar
+		    continue
+	    fi
+
+	    #-----------------------------------
+	    # Skip the set if last line of the status file is "COMPLETED" or "DELEGATE"
+	    if tail -1 $statusfile | grep -q -E '(COMPLETED|DELEGATE)' ; then
+		    printf "====> "
+		    tail -1 $statusfile
+		    continue
+	    fi
+
+	    #-----------------------------------
+	    # nbtries = number of lines from status file (first comment line gives 1 for the first try)
+	    nbtries=`wc -l $statusfile | cut -d' ' -f1`		
+	    echo "Nb of tries: $nbtries"
+
+	    #-----------------------------------
+	    # Set output file name from list name
+
+ 	    fileout1=$( basename $set )
+ 	    fileout=${fileout1%.list}
+
+	    filefirst=`head -n 1 $set`
+	    diroutputfile=`dirname $filefirst | sed -e "s%$dirin%$dirout%"`
+
+	    outputfile=$diroutputfile/${fileout}
+	    mkdir -p $diroutputfile
+	    echo "Output file to write: $outputfile"
+
+	    #-----------------------------------
+	    # Find variables to exclude to have homogeneous files (always exclude 't_inst_.*')
+	    extratar=0
+	    find_varstoexclude $set
+	    if [ $nbvars -eq 0 ] ; then
+		    varstoexclude="t_inst_.*"
+	    else
+		    # There are others variables than 't_inst_.*' so an extra tar file will be created
+		    varstoexclude="t_inst_.*,$varstoexcludefiltered"
+		    extratar=1
+		    # Copy to output_tar directory 
+		    echo "====> COPY to tar command because find other variables ($varstoexcludefiltered) than t_inst_*"
+		    echo "COPY to tar command because find other variables ($varstoexcludefiltered) than t_inst_*" >> $statusfile
+		    cp $set $PATH_SIMU/output_tar
+	    fi
+
+	    #-----------------------------------
+	    # Try 2 times before fire "FAILED"
+	    ncrcatcmd=ncrcat
+	    ncrcatoptions=""
+	    if [ "x${ON_IDRIS}" == "xno" ]
+	    then
+	        ncrcatoptions="--md5_digest"	    
+	    fi
+    #	ncrcatoptions=""
+
+	    startTime=$( getDateMilliSeconds ) # gpdebug : time
+	    resCmd=0
+	    cat $set | $ncrcatcmd $ncrcatoptions -O -x -v $varstoexclude -o $outputfile > $logfile 2>&1 # gpdebug : a retablir
+	    resCmd=$?
+	    meantime=$( getTimeDiffSeconds $startTime ) # gpdebug : time
+
+	    # resultCmd=$( gives_0_or_1 )
+	    # resultCmd=1
+	    # if [ $resultCmd -eq 0 ] ; then
+	    if [ $resCmd -eq 0 ] ; then
+	            sed -i "1i\meantime:${meantime}" $statusfile # gpdebug : time
+		    datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+		    echo "DONE ; $datestr1 ; $datestr2 ; cat $set | $ncrcatcmd $ncrcatoptions -O -x -v '$varstoexclude' -o $outputfile ; $logfile ; $extratar" >> $statusfile
+		    echo "====> COMPLETED at try #$nbtries (at 1st shot on 2)"
+		    echo "COMPLETED at try #$nbtries (at 1st shot on 2)" >> $statusfile
+	    else
+		    # Add --md5_digest
+	            rm -f $outputfile*ncrcat.tmp
+		    startTime=$( getDateMilliSeconds ) # gpdebug : time
+		    resCmd=0
+		    cat $set | $ncrcatcmd $ncrcatoptions -O -x -v $varstoexclude -o $outputfile > $logfile 2>&1 # gpdebug : a retablir
+		    resCmd=$?
+		    meantime=$( getTimeDiffSeconds $startTime ) # gpdebug : time
+	            # resultCmd=$( gives_0_or_1 )
+		    # resultCmd=1
+	            # if [ $resultCmd -eq 0 ] ; then
+		    if [ $resCmd -eq 0 ] ; then
+		            sed -i "1i\meantime:${meantime}" $statusfile # gpdebug : time
+			    datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+			    echo "DONE ; $datestr1 ; $datestr2 ; cat $set | $ncrcatcmd $ncrcatoptions -O -x -v '$varstoexclude' -o $outputfile ; $logfile ; $extratar" >> $statusfile
+			    echo "====> COMPLETED at try #$nbtries (at 2nd shot on 2)"
+			    echo "COMPLETED at try #$nbtries (at 2nd shot on 2)" >> $statusfile
+		    else
+		            rm -f $outputfile*ncrcat.tmp
+			    datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+			    echo "====> FAILED at try #$nbtries" 
+			    echo "FAILED at try #$nbtries ; $datestr1 ; $datestr2 ; cat $set | $ncrcatcmd $ncrcatoptions -O -x -v '$varstoexclude' -o $outputfile ; $logfile ; $extratar" >> $statusfile
+			    if [ $nbtries -ge $maxtries ] ; then
+				    echo "====> DELEGATE to tar command after $nbtries tries (maxtries=$maxtries)"
+				    echo "DELEGATE to tar command after $nbtries tries (maxtries=$maxtries)" >> $statusfile
+			            cp $set $PATH_SIMU/output_tar # gpdebug : a retablir
+			    fi
+		    fi
+	    fi
+
+    done	
+
+    #------------------------------------------------------
+
+    for set in $( ls $PATH_SIMU/output_tar/*list ) ; do
+
+	    #-----------------------------------
+	    echo "#-------------------"
+	    echo "Set: $set"
+            datestr=`LC_ALL=C date +"%Y%m%dT%H%M%S"`
+	    datestr1=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+	    statusfile=${set%%.list}.status
+	    logfile=${set%%.list}_${datestr}.log
+
+	    #-----------------------------------
+	    # Create status file if not exists
+	    if [ ! -e $statusfile ] ; then
+		    echo "# Status ; DateStart ; DateEnd ; Command ; TarFileExists" > $statusfile
+	    fi
+
+	    #-----------------------------------
+	    # Skip the set if last line of the status file is "COMPLETED" or "DELEGATE"
+	    if tail -1 $statusfile | grep -q -E '(COMPLETED|DELEGATE)' ; then
+		    printf "====> "
+		    tail -1 $statusfile
+		    continue
+	    fi
+
+	    #-----------------------------------
+	    # nbtries = number of lines from status file (first comment line gives 1 for the first try)
+	    nbtries=`wc -l $statusfile | cut -d' ' -f1`		
+	    # echo "Nb of tries: $nbtries"
+
+	    #-----------------------------------
+	    # Set output file name from list name
+
+ 	    fileout1=$( basename $set )
+ 	    fileout=${fileout1%.list}.tar
+
+	    filefirst=`head -n 1 $set`
+	    dirinputfile=`dirname $filefirst`
+	    diroutputfile=`dirname $filefirst | sed -e "s%$dirin%$dirout%"`	
+
+	    outputfile=$diroutputfile/${fileout}
+	    mkdir -p $diroutputfile
+	    echo "Output file to write: $outputfile"
+
+	    #-----------------------------------
+	    # Try 1 time before fire "FAILED"
+	    # Waiting for CCRT command
+	    tarcmd=tar
+	    taroptions="--format=posix -W -cf"
+            #taroptions="--format=posix -cf"
+	    cd $dirinputfile
+
+	    set_local=$set".local"
+	    for file in $( cat $set) ; do
+		basename $file >> $set".local" 
+	    done
+
+    # 	#-----------------------------------
+            startTime=$( getDateMilliSeconds ) # gpdebug : time
+	    resCmd=0
+	    $tarcmd $taroptions $outputfile --dereference --files-from $set.local > $logfile 2>&1 # gpdebug : a retablir
+	    resCmd=$?
+	    meantime=$( getTimeDiffSeconds $startTime ) # gpdebug : time
+
+	    # resultCmd=$( gives_0_or_1 )
+	    # if [ $resultCmd -eq 0 ] ; then
+	    if [ $resCmd -eq 0 ] ; then
+		sed -i "1i\meantime:${meantime}" $statusfile # gpdebug : time
+		datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+		echo "DONE ; $datestr1 ; $datestr2 ; $tarcmd $taroptions $outputfile $(cat $set); $logfile" >> $statusfile
+		echo "====> COMPLETED at try #$nbtries (at 1st shot on 1)"
+		echo "COMPLETED at try #$nbtries (at 1st shot on 1)" >> $statusfile
+	    else
+		datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+		echo "====> FAILED at try #$nbtries" 
+		echo "FAILED at try #$nbtries ; $datestr1 ; $datestr2 ; $tarcmd $taroptions $outputfile $(cat $set) ; $logfile" >> $statusfile
+
+	    fi
+	    rm -f $set".local" 
+	    #-----------------------------------
+
+    done	
+
+
+    #------------------------------------------------------
+
+    for set in $( ls $PATH_SIMU/restart_tar/*list ) ; do
+	    #-----------------------------------
+	    echo "#-------------------"
+	    echo "Set: $set"
+            datestr=`LC_ALL=C date +"%Y%m%dT%H%M%S"`
+	    datestr1=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+	    statusfile=${set%%.list}.status
+	    logfile=${set%%.list}_${datestr}.log
+
+	    #-----------------------------------
+	    # Create status file if not exists
+	    if [ ! -e $statusfile ] ; then
+		    echo "# Status ; DateStart ; DateEnd ; Command ; TarFileExists" > $statusfile
+	    fi
+
+	    #-----------------------------------
+	    # Skip the set if last line of the status file is "COMPLETED" or "DELEGATE"
+	    if tail -1 $statusfile | grep -q -E '(COMPLETED|DELEGATE)' ; then
+		    printf "====> "
+		    tail -1 $statusfile
+		    continue
+	    fi
+
+	    #-----------------------------------
+	    # nbtries = number of lines from status file (first comment line gives 1 for the first try)
+	    nbtries=`wc -l $statusfile | cut -d' ' -f1`		
+	    # echo "Nb of tries: $nbtries"
+
+	    #-----------------------------------
+	    # Set output file name from list name
+	    dirin1=$PATH_SIMU/RESTART
+	    dirin2=${dirin1##${IGCM_DEM}}
+	    dirin3=${dirin2##/$( basename ${INPUT_DMF_DATA} )}
+	    diroutputfile=${OUTPUT_STORE}${dirin3}
+ 	    fileout1=$( basename $set )
+ 	    fileout=${fileout1%.list}.tar
+	    outputfile=$diroutputfile/${fileout}
+	    mkdir -p $diroutputfile
+	    echo "Output file to write: $outputfile"
+
+	    #-----------------------------------
+	    # Try 1 time before fire "FAILED"
+	    # Waiting for CCRT command
+	    tarcmd=tar
+	    taroptions="--format=posix -W -cf"
+    #	taroptions="--format=posix -cf"
+	    cd $dirin1
+    #	ls
+
+	    startTime=$( getDateMilliSeconds ) # gpdebug : time
+	    resCmd=0
+	    $tarcmd $taroptions $outputfile --dereference --files-from $set > $logfile 2>&1 # gpdebug : a retablir
+	    resCmd=$?
+	    meantime=$( getTimeDiffSeconds $startTime ) # gpdebug : time
+
+	    # resultCmd=$( gives_0_or_1 )
+	    # if [ $resultCmd -eq 0 ] ; then
+	    if [ $resCmd -eq 0 ] ; then
+		sed -i "1i\meantime:${meantime}" $statusfile # gpdebug : time
+		datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+		echo "DONE ; $datestr1 ; $datestr2 ; $tarcmd $taroptions $outputfile $(cat $set); $logfile" >> $statusfile
+		echo "====> COMPLETED at try #$nbtries (at 1st shot on 1)"
+		echo "COMPLETED at try #$nbtries (at 1st shot on 1)" >> $statusfile
+	    else
+		datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+		echo "====> FAILED at try #$nbtries" 
+		echo "FAILED at try #$nbtries ; $datestr1 ; $datestr2 ; $tarcmd $taroptions $outputfile $(cat $set) ; $logfile" >> $statusfile
+
+	    fi
+
+	    #-----------------------------------
+
+    done	
+
+    #------------------------------------------------------
+    for set in $( ls $PATH_SIMU/debug_tar/*list ) ; do
+
+	    #-----------------------------------
+	    echo "#-------------------"
+	    echo "Set: $set"
+            datestr=`LC_ALL=C date +"%Y%m%dT%H%M%S"`
+	    datestr1=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+	    statusfile=${set%%.list}.status
+	    logfile=${set%%.list}_${datestr}.log
+
+	    #-----------------------------------
+	    # Create status file if not exists
+	    if [ ! -e $statusfile ] ; then
+		    echo "# Status ; DateStart ; DateEnd ; Command ; TarFileExists" > $statusfile
+	    fi
+
+	    #-----------------------------------
+	    # Skip the set if last line of the status file is "COMPLETED" or "DELEGATE"
+	    if tail -1 $statusfile | grep -q -E '(COMPLETED|DELEGATE)' ; then
+		    printf "====> "
+		    tail -1 $statusfile
+		    continue
+	    fi
+
+	    #-----------------------------------
+	    # nbtries = number of lines from status file (first comment line gives 1 for the first try)
+	    nbtries=`wc -l $statusfile | cut -d' ' -f1`		
+	    # echo "Nb of tries: $nbtries"
+
+	    #-----------------------------------
+	    # Set output file name from list name
+	    dirin1=$PATH_SIMU/DEBUG
+	    dirin2=${dirin1##${IGCM_DEM}}
+	    dirin3=${dirin2##/$( basename ${INPUT_DMF_DATA} )}
+	    diroutputfile=${OUTPUT_STORE}${dirin3}
+ 	    fileout1=$( basename $set )
+ 	    fileout=${fileout1%.list}.tar
+	    outputfile=$diroutputfile/${fileout}
+	    mkdir -p $diroutputfile
+	    echo "Output file to write: $outputfile"
+
+	    #-----------------------------------
+	    # Try 1 time before fire "FAILED"
+	    # Waiting for CCRT command
+	    tarcmd=tar
+	    taroptions="--format=posix -W -cf"
+    #	taroptions="--format=posix -cf"
+	    cd $dirin1
+    #	ls
+
+	    startTime=$( getDateMilliSeconds ) # gpdebug : time
+	    resCmd=0
+	    $tarcmd $taroptions $outputfile --dereference --files-from $set > $logfile 2>&1 # gpdebug : a retablir
+	    resCmd=$?
+	    meantime=$( getTimeDiffSeconds $startTime ) # gpdebug : time
+
+	    # resultCmd=$( gives_0_or_1 )
+	    # if [ $resultCmd -eq 0 ] ; then
+	    if [ $resCmd -eq 0 ] ; then
+		sed -i "1i\meantime:${meantime}" $statusfile # gpdebug : time
+		datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+		echo "DONE ; $datestr1 ; $datestr2 ; $tarcmd $taroptions $outputfile $(cat $set); $logfile" >> $statusfile
+		echo "====> COMPLETED at try #$nbtries (at 1st shot on 1)"
+		echo "COMPLETED at try #$nbtries (at 1st shot on 1)" >> $statusfile
+	    else
+		datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+		echo "====> FAILED at try #$nbtries" 
+		echo "FAILED at try #$nbtries ; $datestr1 ; $datestr2 ; $tarcmd $taroptions $outputfile $(cat $set) ; $logfile" >> $statusfile
+
+	    fi
+
+	    #-----------------------------------
+
+    done	
+
+    #------------------------------------------------------
+    for set in $( ls $PATH_SIMU/store_cp/*list ) ; do
+
+	    #-----------------------------------
+	    echo "#-------------------"
+	    echo "Set: $set"
+            datestr=`LC_ALL=C date +"%Y%m%dT%H%M%S"`
+	    datestr1=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+	    statusfile=${set%%.list}.status
+	    logfile=${set%%.list}_${datestr}.log
+
+	    #-----------------------------------
+	    # Create status file if not exists
+	    if [ ! -e $statusfile ] ; then
+		    echo "# Status ; DateStart ; DateEnd ; Command ; TarFileExists" > $statusfile
+	    fi
+
+	    #-----------------------------------
+	    # Skip the set if last line of the status file is "COMPLETED" or "DELEGATE"
+	    if tail -1 $statusfile | grep -q -E '(COMPLETED|DELEGATE)' ; then
+		    printf "====> "
+		    tail -1 $statusfile
+		    continue
+	    fi
+
+	    #-----------------------------------
+	    # nbtries = number of lines from status file (first comment line gives 1 for the first try)
+	    nbtries=`wc -l $statusfile | cut -d' ' -f1`		
+	    # echo "Nb of tries: $nbtries"
+
+	    #-----------------------------------
+	    # Set output file name from first and last files from the current set
+	    for file in $( cat $set) ; do
+
+		diroutputfile=`dirname $file | sed -e "s%$dirin%$dirout%"`
+		mkdir -p $diroutputfile
+		echo "Output file to write: $diroutputfile/$( basename $file )"
+
+	    #-----------------------------------
+	    # Try 1 time before fire "FAILED"
+	    # Waiting for CCRT command
+		cpcmd="cp "
+		cpoptions="-rf"
+		startTime=$( getDateMilliSeconds ) # gpdebug : time
+		resCmd=0
+		$cpcmd $cpoptions $file $diroutputfile > $logfile 2>&1 # gpdebug : a retablir
+		resCmd=$?
+		meantime=$( getTimeDiffSeconds $startTime ) # gpdebug : time
+	    done
+
+	    # resultCmd=$( gives_0_or_1 )
+	    # if [ $resultCmd -eq 0 ] ; then
+	    if [ $resCmd -eq 0 ] ; then
+		sed -i "1i\meantime:${meantime}" $statusfile # gpdebug : time
+		datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+		echo "DONE ; $datestr1 ; $datestr2 ; $cpcmd $cpoptions $file $diroutputfile ; $logfile" >> $statusfile
+		echo "====> COMPLETED at try #$nbtries (at 1st shot on 1)"
+		echo "COMPLETED at try #$nbtries (at 1st shot on 1)" >> $statusfile
+	    else
+		datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+		echo "====> FAILED at try #$nbtries" 
+		echo "FAILED at try #$nbtries ; $datestr1 ; $datestr2 ; $cpcmd $cpoptions $file $diroutputfile ; $logfile" >> $statusfile
+
+	    fi
+
+	    #-----------------------------------
+
+    done	
+
+    #------------------------------------------------------
+    for set in $( ls $PATH_SIMU/work_cp/*list ) ; do
+
+	    #-----------------------------------
+	    echo "#-------------------"
+	    echo "Set: $set"
+            datestr=`LC_ALL=C date +"%Y%m%dT%H%M%S"`
+	    datestr1=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+	    statusfile=${set%%.list}.status
+	    logfile=${set%%.list}_${datestr}.log
+
+	    #-----------------------------------
+	    # Create status file if not exists
+	    if [ ! -e $statusfile ] ; then
+		    echo "# Status ; DateStart ; DateEnd ; Command ; TarFileExists" > $statusfile
+	    fi
+
+	    #-----------------------------------
+	    # Skip the set if last line of the status file is "COMPLETED" or "DELEGATE"
+	    if tail -1 $statusfile | grep -q -E '(COMPLETED|DELEGATE)' ; then
+		    printf "====> "
+		    tail -1 $statusfile
+		    continue
+	    fi
+
+	    #-----------------------------------
+	    # nbtries = number of lines from status file (first comment line gives 1 for the first try)
+	    nbtries=`wc -l $statusfile | cut -d' ' -f1`		
+	    # echo "Nb of tries: $nbtries"
+
+	    #-----------------------------------
+	    # Set output file name from first and last files from the current set
+	    for file in $( cat $set) ; do
+
+		diroutputfile=`dirname $file | sed -e "s%$dirin%$dirout_work%"`
+		mkdir -p $diroutputfile
+		echo "Output file to write: $diroutputfile/$( basename $file )"
+
+	    #-----------------------------------
+	    # Try 1 time before fire "FAILED"
+	    # Waiting for CCRT command
+		cpcmd="cp "
+		cpoptions="-rf"
+		startTime=$( getDateMilliSeconds ) # gpdebug : time
+		resCmd=0
+		$cpcmd $cpoptions $file $diroutputfile > $logfile 2>&1  # gpdebug : a retablir
+		resCmd=$?
+		meantime=$( getTimeDiffSeconds $startTime ) # gpdebug : timeS
+	    done
+
+	    # resultCmd=$( gives_0_or_1 )
+	    # if [ $resultCmd -eq 0 ] ; then
+	    if [ $resCmd -eq 0 ] ; then
+		sed -i "1i\meantime:${meantime}" $statusfile # gpdebug : time
+		datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+		echo "DONE ; $datestr1 ; $datestr2 ; $cpcmd $cpoptions $file $diroutputfile ; $logfile" >> $statusfile
+		echo "====> COMPLETED at try #$nbtries (at 1st shot on 1)"
+		echo "COMPLETED at try #$nbtries (at 1st shot on 1)" >> $statusfile
+	    else
+		datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+		echo "====> FAILED at try #$nbtries" 
+		echo "FAILED at try #$nbtries ; $datestr1 ; $datestr2 ; $cpcmd $cpoptions $file $diroutputfile ; $logfile" >> $statusfile
+
+	    fi
+
+	    #-----------------------------------
+
+    done
+fi
+
+for set in $( ls ${PATH_SIMU}/*.list | grep "tar_full_simul" )
+do
+	# set="${PATH_SIMU}/tar_full_simul.list" # gpdebug : foireux ?
+	#-----------------------------------
+	echo "#-------------------"
+	echo "Set: $set"
+        datestr=`LC_ALL=C date +"%Y%m%dT%H%M%S"`
+	datestr1=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+	statusfile=${set%%.list}.status
+	logfile=${set%%.list}_${datestr}.log
+
+	#-----------------------------------
+	# Create status file if not exists
+	if [ ! -e $statusfile ] ; then
+		echo "# Status ; DateStart ; DateEnd ; Command ; TarFileExists" > $statusfile
+	fi
+
+	#-----------------------------------
+	# Skip the set if last line of the status file is "COMPLETED" or "DELEGATE"
+	if tail -1 $statusfile | grep -q -E '(COMPLETED|DELEGATE)' ; then
+		printf "====> "
+		tail -1 $statusfile
+		continue
+	fi
+	
+	#-----------------------------------
+	# nbtries = number of lines from status file (first comment line gives 1 for the first try)
+	nbtries=`wc -l $statusfile | cut -d' ' -f1`	    
+	# echo "Nb of tries: $nbtries"
+	    
+	#-----------------------------------
+	# Set output file name from list name
+	# echo "PATH_SIMU=$PATH_SIMU"
+	dirOfOutputFile=`echo $PATH_SIMU | sed "s;${IGCM_DEM};${OUTPUT_STORE};" `
+	# echo "dirOfOutputFile=$dirOfOutputFile"
+	dirOfOutputFile_Up=$( dirname $dirOfOutputFile )
+	PATH_SIMU_NAME=$( basename $dirOfOutputFile )
+	fileout=${PATH_SIMU_NAME}.tar
+	# echo "dirnameOfListFile=$dirnameOfListFile"
+	outputfile=$dirOfOutputFile_Up/${fileout}
+	# echo "outputfile=$outputfile"
+	# exit 1 # gpdebug : a virer
+	mkdir -p $dirOfOutputFile_Up
+	echo "Output file to write: $outputfile  tar_full_simul"
+	
+	# exit 0 # a virer
+
+	#-----------------------------------
+	# Try 1 time before fire "FAILED"
+	# Waiting for CCRT command
+	tarcmd=tar
+	taroptions="--format=posix -W -cf"
+#	taroptions="--format=posix -cf"
+
+	filefirst=`head -n 1 $set`
+	dirinputfile=`dirname $filefirst`
+	cd $dirinputfile
+
+	set_local=${set%%.list}.local
+	> $set_local
+	for file in $( cat $set) ; do
+	    basename $file >> $set_local 
+	done
+#	ls
+	
+	startTime=$( getDateMilliSeconds ) # gpdebug : time
+	resCmd=0
+	$tarcmd $taroptions $outputfile --dereference --files-from $set_local > $logfile 2>&1 # gpdebug : a retablir
+	resCmd=$?
+	meantime=$( getTimeDiffSeconds $startTime ) # gpdebug : time
+	
+	# resultCmd=$( gives_0_or_1 )
+	# if [ $resultCmd -eq 0 ] ; then
+	if [ $resCmd -eq 0 ] ; then
+	    sed -i "1i\meantime:${meantime}" $statusfile # gpdebug : time
+	    datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+	    echo "DONE ; $datestr1 ; $datestr2 ; $tarcmd $taroptions $outputfile $(cat $set); $logfile" >> $statusfile
+	    echo "====> COMPLETED at try #$nbtries (at 1st shot on 1)"
+	    echo "COMPLETED at try #$nbtries (at 1st shot on 1)" >> $statusfile
+	else
+	    datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+	    echo "====> FAILED at try #$nbtries" 
+	    echo "FAILED at try #$nbtries ; $datestr1 ; $datestr2 ; $tarcmd $taroptions $outputfile $(cat $set) ; $logfile" >> $statusfile
+	    exit 1
+	fi
+	
+	#-----------------------------------
+done
Index: TOOLS/SURPACK_IPSL/find_directory_simul.sh
===================================================================
--- TOOLS/SURPACK_IPSL/find_directory_simul.sh	(revision 2136)
+++ TOOLS/SURPACK_IPSL/find_directory_simul.sh	(revision 2136)
@@ -0,0 +1,95 @@
+#!/bin/bash
+# set -vx # gpdebug : a virer ########
+# prend en argument le path et le nom d'un fichier param (argument de la commande
+# ccc_archive avec option ipsl_pack) 
+# ex : ./find_directory_simul.job  fichier_param_test1.txt liste_fichier_dmnfs
+# ex : find_directory_simul.job param_SL.txt /cscratch/cont003/labetoul/FROM_CCRT_INFORMATIONS_DMNFS/information_dmnfs_2012-03-21
+
+#-------------------------------
+# A modifier avant utilisation : 
+#--------------------------------
+
+LISTE_SIMUL=${1}
+LISTE_DMNFS=${2}
+echo $LISTE_SIMUL $LISTE_DMNFS
+# ----
+export JOB_DIR=${JOB_DIR:-${TMP_MIGR_DATA}}
+export IGCM_DEM=${IGCM_DEM:-${SCRATCHDIR}/IGCM_DEM}
+export IGCM_TMP=${IGCM_TMP:-${IGCM_DEM}/tmp}
+mkdir -p ${IGCM_DEM}
+mkdir -p ${IGCM_TMP}
+clean_tmp=${clean_tmp:-yes}
+EXE_DIR=$(dirname ${0})
+SCRIPT_NAME=$(basename ${0} )
+source ${EXE_DIR}/DEM_utilities.sh
+
+echo "apres sources" ${SCRIPT_NAME}
+
+# gpdebug : verif si le present script a ete execute jusqu'au bout #########
+MonitoringInfo="${SCRIPT_NAME}-->OK"
+generalMonitoring "$MonitoringInfo"
+
+DEM_log -0 "Demmarrage de ${SCRIPT_NAME}"
+
+cd ${EXE_DIR}
+# ----
+# gpdebug : Execute la function errorReceive() si reception d'un signal TERM
+trap 'DEM_errorReceive' TERM ########
+
+# gpdebug : on augmente la liste des proc à détruire en cas d'erreur bloquante du présent proc
+export listPID="$$ ${listPID}" #########
+
+LISTE_SIMUL=${1}
+LISTE_DMNFS=${2}
+
+LISTE_SIMUL_NAME=$(basename ${LISTE_SIMUL} )
+
+echo "gpdebug : ${IGCM_TMP}/${$}.liste_Restart.txt" # gpdebug : a virer  #######
+
+# Pour tous les fichiers ou repertoires contenus dans le fichier de parametres 
+for DIR in $( awk '{print $0}' ${LISTE_SIMUL} ) ; do 
+    eval DIR_FINAL=$DIR
+    DEM_log -1 ${SCRIPT_NAME} - Inspection de ${DIR}"/"
+    # trouve la liste des repertoires restart sous l'arborescence    
+        
+    # gpdebug : s'il n'y a pas de rep Restart, on saute ###############################################################################
+    listRestart=`grep ${DIR_FINAL}"/" ${LISTE_DMNFS} | grep RESTART |grep -v ".tar" | awk '{print $3}' | sed 's%/RESTART.*%%' `
+
+    if [ "x${listRestart}" == "x" ] ;
+    then
+	echo "########## Attention :"
+	echo "${SCRIPT_NAME}:${LINENO}:Pas de Repertoire RESTART ou de fichiers Restart dans ${DIR_FINAL}"
+	continue
+    fi
+    echo "${listRestart}" >> ${IGCM_TMP}/${$}.liste_Restart.txt
+    # gpdebug : fin #########################################################################################################################    
+done
+
+# Pour le cas ou aucune simu n aurait ete detectee
+if [ -e  ${IGCM_TMP}/${$}.liste_Restart.txt ]
+then
+   listRestartNbLines=`cat ${IGCM_TMP}/${$}.liste_Restart.txt | wc -l `
+   if [ "x${listRestartNbLines}" == "x0" ]
+   then
+      DEM_errorSend "${SCRIPT_NAME}:${LINENO}:Il n existe aucune simulation !" # "${$}"
+   fi
+else
+   DEM_errorSend "${SCRIPT_NAME}:${LINENO}:Il n existe aucune simulation !" # "${$}"
+fi
+
+#  il n'y a qu'un seul path par simu dans le fichier (un repertoire RESTART par simul) 
+mv ${IGCM_TMP}/${$}.liste_Restart.txt ${IGCM_DEM}/liste_simul_${LISTE_SIMUL_NAME}
+
+# gpdebug : envoi du nombre de simu dans un "nbSimu.txt" du rep de suivi
+echo `cat ${IGCM_DEM}/liste_simul_${LISTE_SIMUL_NAME} | wc -l ` > $nbSimuFile
+
+DEM_log -1 "Fichier cree : liste_simul_${LISTE_SIMUL_NAME}"
+
+
+[[ "${clean_tmp}" = "yes" ]] && rm -f ${IGCM_TMP}/${$}.path_simul.txt
+[[ "${clean_tmp}" = "yes" ]] && rm -f ${IGCM_TMP}/${$}.liste_Restart.txt
+
+# gpdebug : le script n'a pas rencontre d'erreur. On l'inscrit dans le fichier de suivi
+echo $MonitoringInfo >> $generalMonitorFile
+
+DEM_log -0 "Fin de ${SCRIPT_NAME}"
Index: TOOLS/SURPACK_IPSL/find_size_pack.sh
===================================================================
--- TOOLS/SURPACK_IPSL/find_size_pack.sh	(revision 2136)
+++ TOOLS/SURPACK_IPSL/find_size_pack.sh	(revision 2136)
@@ -0,0 +1,254 @@
+#!/bin/bash
+# But : trouver la taille ideale de pack pour une simulation donnee
+# on part sur une base de 10 ans et on augmente par 0.5 ou on divise 
+# par 2 suivant un critÃšre de taille
+# on passe en revue tous les types de fichiers d'Output et on conserve
+# la taille de pack la plus petite (hors HF) 
+
+# $1= PATH/config_card d'une simulation avec 
+# TagName/JobName/ExperimentName/SpaceName/DateBegin/DateEnd/PATH_SIMUL
+
+# pour commencer on travaille avec le fichier information_dmnfs
+#/cscratch/cont003/p86mart/FROM_CCRT_INFORMATIONS_DMNFS/information_dmnfs_2011-09-21
+
+config_card=${1}
+LISTE_DMNFS=${2}
+
+# ----
+export JOB_DIR=${JOB_DIR:-${TMP_MIGR_DATA}}
+export IGCM_DEM=${IGCM_DEM:-${SCRATCHDIR}/IGCM_DEM}
+export IGCM_TMP=${IGCM_TMP:-${IGCM_DEM}/tmp}
+mkdir -p ${IGCM_DEM}
+mkdir -p ${IGCM_TMP}
+clean_tmp=${clean_tmp:-yes}
+EXE_DIR=$(dirname ${0})
+SCRIPT_NAME=$(basename ${0} )
+source ${EXE_DIR}/DEM_utilities.sh
+
+# gpdebug : verif si le present script a ete execute jusqu'au bout #########
+MonitoringInfo="${SCRIPT_NAME}-->OK"
+simuMonitoring_check "$MonitoringInfo" "$config_card"
+
+# gpdebug : Execute la function errorReceive() si reception d'un signal TERM
+trap 'DEM_errorReceive' TERM ########
+
+# gpdebug : on augmente la liste des proc à détruire en cas d'erreur bloquante du présent proc
+export listPID="$$ ${listPID}" #########
+
+DEM_log -0 "Demmarrage de ${SCRIPT_NAME}"
+cd ${EXE_DIR}
+# ----
+
+eval $(grep JobName         ${config_card} ) 
+eval $(grep PATH_SIMUL_FULL ${config_card} ) 
+eval $(grep DateBegin       ${config_card} ) 
+eval $(grep DateEnd         ${config_card} ) 
+eval $(grep IGCM_DEM_SIMU   ${config_card} )
+
+DEM_log -0 "on travaille avec la simu ${JobName}"
+
+DEM_state=$( DEM_read_state ${IGCM_DEM}/config_card.liste ${config_card} )
+# gpdebug : si c'est une premiere exec (pas une reprise)
+if [[ "x${execEveryStep}" == "1" ]] && [[ "${DEM_state}" != "ListToBeDone" ]] ; then
+    echo "gpdebug : DEM_state=${DEM_state}"
+    DEM_errorSend "${SCRIPT_NAME}:${LINENO}:Etat incorrect dans ${IGCM_DEM}/config_card.liste"
+fi
+
+DEM_write_state ${IGCM_DEM}/config_card.liste ${config_card} FindSizePackRunning
+# Periodicite du pack (20 ans par defaut) 
+period_pack=20Y
+periodpackinyear=$( echo ${period_pack} | sed -e 's/[yY]//' ) 
+
+# Taille max et min que devra avoir un pack en octet (20Go - 70Go) 
+size_pack_max=70000000000
+size_pack_min=20000000000
+
+SIMUL=${PATH_SIMUL_FULL}/
+
+# Nettoyons les tests precedents .... 
+rm -f ${IGCM_DEM_SIMU}/info_Output.txt
+rm -f ${IGCM_DEM_SIMU}/info_name_file.txt
+
+[[ "${clean_tmp}" = "yes" ]] && rm -f   ${IGCM_TMP}/${$}.info_tmp.txt  ${IGCM_TMP}/${$}.info_tmp_2.txt
+
+# 1- Trouver la liste des noms des fichiers d'Output
+DEM_log -1 "Recherche des noms de fichiers Output"
+
+sed -e "s%.*_\([0-9]\{8\}\)_\([0-9]\{8\}\)_%%" ${IGCM_DEM_SIMU}/liste_output_files_config.txt  | awk '/.nc/{print $0}'  >  ${IGCM_TMP}/${$}.info_tmp.txt
+
+#on enleve si des fichiers ne repondent pas au critere et ont donc encore en / dans leur nom
+cat ${IGCM_TMP}/${$}.info_tmp.txt | grep -v "/" > ${IGCM_TMP}/${$}.info_tmp_bis.txt
+
+
+# On retire les doublons de la liste precedente
+awk '{if (x[$0] != "") next ; print $0 ; x[$0]=$0}' <  ${IGCM_TMP}/${$}.info_tmp_bis.txt >> ${IGCM_DEM_SIMU}/info_name_file.txt
+[[ "${clean_tmp}" = "yes" ]] && rm -f  ${IGCM_TMP}/${$}.info_tmp.txt ${IGCM_TMP}/${$}.info_tmp_bis.txt
+
+
+# On cree la liste des fichiers pour chaque type_file (type_file = histmth, histday, etc...)
+DEM_log -1 "Creation de la liste des fichiers"
+
+for type_file in `awk '{print $0}' ${IGCM_DEM_SIMU}/info_name_file.txt`
+do 
+    DEM_log -1 "Traitement type de fichier = ${type_file}"
+    grep ${type_file} ${IGCM_DEM_SIMU}/liste_output_files_config.txt >  ${IGCM_TMP}/${$}.info_${type_file}.txt
+    # cette liste comporte en premiere colonne la taille et en deuxieme le path du fichier
+    # on classe la liste par ordre alphabetique des path des fichiers
+    sort -k 2  ${IGCM_TMP}/${$}.info_${type_file}.txt >  ${IGCM_TMP}/${$}.tmp_info_${type_file}.txt.tmp
+    cp ${IGCM_TMP}/${$}.tmp_info_${type_file}.txt.tmp  ${IGCM_TMP}/${$}.info_${type_file}.txt
+    [[ "${clean_tmp}" = "yes" ]] && rm -f ${IGCM_TMP}/${$}.tmp_info_${type_file}.txt.tmp
+done
+
+
+
+# 3- Maintenant pour chaque type de fichier de sortie nous allons calculer la 
+# taille qu'aurait le pack de {periodpackinyear}ans
+DEM_log -1 "Debut recherche taille de pack"
+# Recherche des dates du premier pack
+
+year_begin=$(  echo ${DateBegin} | cut -c 1-4 )
+month_begin=$( echo ${DateBegin} | cut -c 5-6 )
+year_end=$(    echo ${DateEnd}   | cut -c 1-4 )
+month_end=$(   echo ${DateEnd}   | cut -c 5-6 )
+
+date_begin_pack=${DateBegin}
+date_end_simulation=${DateEnd}
+
+month_begin_pack=${month_begin}
+year_begin_pack=${year_begin}
+
+number_pack=1
+
+# on ne fait le calcul que pour les dix premiers pack (donc 20 * 10 =  200 ans) 
+# cela doit donner un echantillon suffisant
+date_begin_pack=`echo $date_begin_pack|sed 's/^0*//'` 
+date_end_simulation=`echo $date_end_simulation|sed 's/^0*//'` 
+
+echo "begin_pack  =  $date_begin_pack end_simu $date_end_simulation"
+while [[ ${date_begin_pack} -le ${date_end_simulation}  && ${number_pack} -le 3 ]]  ###### ANNE 10 au lieu de 3
+do 
+    
+    month_end_pack=${month_begin_pack}
+    year_end_pack=$(( 10#${year_begin_pack} + ${periodpackinyear} ))
+    date_end_pack=${year_end_pack}${month_end_pack}01 
+
+    DEM_log -0 "Entree boucle : year_begin_pack month_begin_pack year_end_pack month_end_pack : ${year_begin_pack} ${month_begin_pack} ${year_end_pack} ${month_end_pack}"
+    # on travaille pour chaque type de fichiers 
+    for type_file in `awk '{print $0}' ${IGCM_DEM_SIMU}/info_name_file.txt`
+    do
+    #for type_file in 1M_grid_T.nc ; do
+	DEM_log -3 "type file, number_pack " ${type_file} ${number_pack}
+	taille=0
+        #il faut les passer en revue et calculer par tranche de period_pack leur somme
+	for file in `awk '{print $2}'  ${IGCM_TMP}/${$}.info_${type_file}.txt` ; do 
+            #extraire la date de debut et la date de fin de la periode d'output traitee par le fichier    
+            extract_date_file=$( echo ${file}             | sed "s%.*${JobName}_%%"            )
+            date_debut=$(        echo ${extract_date_file}| sed 's%\([0-9]\{8\}\)_.*$%\1%g'    )
+            date_fin=$(          echo ${extract_date_file}| sed 's%.*_\([0-9]\{8\}\)_.*$%\1%g' )
+            if [  ${date_debut} -lt ${date_end_pack} ]
+            then 
+		if [ ${date_fin} -ge ${date_begin_pack} ]
+		then 
+		    grep ${file}  ${IGCM_TMP}/${$}.info_${type_file}.txt >>  ${IGCM_TMP}/${$}.info_${type_file}_${number_pack}.txt
+	            # on efface le fichier de la liste pour ne pas travailler dessus pour le prochain pack
+		    grep -v ${file} ${IGCM_TMP}/${$}.info_${type_file}.txt > ${IGCM_TMP}/${$}.info_${type_file}.txt.tmp
+                    cp ${IGCM_TMP}/${$}.info_${type_file}.txt.tmp ${IGCM_TMP}/${$}.info_${type_file}.txt
+		    [[ "${clean_tmp}" = "yes" ]] && rm -f ${IGCM_TMP}/${$}.info_${type_file}.txt.tmp
+		fi
+	    else 
+	    # comme la liste est classee par ordre alphabetique --> par ordre croissant des periodes de sorties
+	    # des que un fichier n'est plus dans le pack on peut sortir c'est qu'on les a tous. 
+		break
+            fi
+	    
+	done
+       # on fait la somme par periodpack et par type de fichier de la taille qu'aurait le pack
+	if [ -f ${IGCM_TMP}/${$}.info_${type_file}_${number_pack}.txt ] 
+	then
+	    awk 'BEGIN {y = 0} {x = $1 ; y = y + x } END{print y}'  ${IGCM_TMP}/${$}.info_${type_file}_${number_pack}.txt >> ${IGCM_TMP}/${$}.size_pack_${type_file}.txt
+	    [[ "${clean_tmp}" = "yes" ]] && rm -f  ${IGCM_TMP}/${$}.info_${type_file}_${number_pack}.txt
+	fi
+    done
+    
+    DEM_log -2 "Sortie boucle : year_begin_pack month_begin_pack year_end_pack month_end_pack : ${year_begin_pack} ${month_begin_pack} ${year_end_pack} ${month_end_pack}"
+
+    month_begin_pack=${month_end_pack}
+    year_begin_pack=${year_end_pack}
+    date_begin_pack=${year_begin_pack}${month_begin_pack}01
+    
+    number_pack=$(( ${number_pack} + 1 ))
+
+
+done
+
+# Pour chaque type de fichier on verifie si toutes les tailles sont dans 
+# la fourchette size_pack_min / size_pack_max 
+# Si une taille est plus petite 
+# attention il ne faut pas tenir compte du dernier pack qui peut etre
+# inferieur a periodpack
+
+new_period=999999
+newpackinyear=0
+if [[ -f ${IGCM_TMP}/${$}.size_pack_${type_file}.txt ]]; then 
+    for type_file in `awk '{print $0}' ${IGCM_DEM_SIMU}/info_name_file.txt`
+    do
+	nb_line=$(cat ${IGCM_TMP}/${$}.size_pack_${type_file}.txt | wc -l )
+	if [ ${nb_line} -gt 1 ] 
+	then 
+	    for taille in `head -n -1  ${IGCM_TMP}/${$}.size_pack_${type_file}.txt`
+	    do 
+		[[ ${taille} -lt ${size_pack_min} ]] && period_tmp=$(( ${size_pack_min} * ${periodpackinyear} / ${taille} ))
+		[[ ${taille} -gt ${size_pack_max} ]] && period_tmp=$(( ${size_pack_max} * ${periodpackinyear} / ${taille} ))
+		[[ ${taille} -ge ${size_pack_min} && ${taille} -le ${size_pack_max} ]] && period_tmp=${periodpackinyear}
+		[[ ${period_tmp} -lt ${new_period} ]] && new_period=${period_tmp}
+		echo "type_file =  ${type_file} taille = ${taille} new_period = ${new_period}"
+
+	    done
+	else
+        # Dans ce cas la il n'y avait pas assez de fichiers pour remplir une periode complete #
+        # il faut donc commencer par calculer la taille du pack que l'on a fait #
+	    newpackinyear=$((    ${year_end}  - ${year_begin}        ))
+	    newpackinyear=$(( $newpackinyear + 1 ))
+	    [[ ${newpackinyear} -lt 1 ]] && newpackinyear=1
+	    for taille in `head  ${IGCM_TMP}/${$}.size_pack_${type_file}.txt`
+	    do 
+		[[ ${taille} -lt ${size_pack_min} ]] && period_tmp=${newpackinyear}
+		[[ ${taille} -gt ${size_pack_max} ]] && period_tmp=$(( ${size_pack_max} * ${newpackinyear} / ${taille} ))
+		[[ ${taille} -ge ${size_pack_min} && ${taille} -le ${size_pack_max} ]] && period_tmp=${newpackinyear}
+		[[ ${period_tmp} -lt ${new_period} ]] && new_period=${period_tmp}
+	    done
+	fi 
+    done
+fi
+DEM_log -1 "taille=${taille}"
+DEM_log -1 "new_period=${new_period}"
+
+# on veut que la taille de pack soit de 1 2 5 10 20 50 ou 100 ans
+# sauf si newperiod = nb annee de simul auquel cas on ne tronque pas
+declare -a liste_period=( 1 2 5 10 20 50 100 )
+
+change=0
+for i in 1 2 3 4 5 6 ; do
+    if [[ ${new_period} -lt ${liste_period[i]} && ${change} -eq 0 && ${newpackinyear} -ne 0 ]]
+    then 
+	new_period=${liste_period[i-1]}
+	change=1
+    fi 
+done
+
+[[ ${new_period} -gt 100 ]] && new_period=100
+
+[[ ${new_period} -eq 0 ]] && new_period=1
+
+[[ "${clean_tmp}" = "yes" ]] && rm -f  ${IGCM_TMP}/${$}.*
+
+echo ${new_period} > ${IGCM_DEM_SIMU}/period_pack.txt
+DEM_log -0 "La nouvelle periode de pack est : ${new_period}Y"
+
+DEM_write_state ${IGCM_DEM}/config_card.liste ${config_card} FindSizePackDone
+
+# gpdebug : le script n'a pas rencontre d'erreur. On l'inscrit dans le fichier de suivi
+simuMonitoring_OK "$MonitoringInfo" "$config_card"
+DEM_log -0 "Fin de ${SCRIPT_NAME}"
+
+exit 
Index: TOOLS/SURPACK_IPSL/glost_launch.c
===================================================================
--- TOOLS/SURPACK_IPSL/glost_launch.c	(revision 2136)
+++ TOOLS/SURPACK_IPSL/glost_launch.c	(revision 2136)
@@ -0,0 +1,234 @@
+#include <mpi.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <getopt.h>
+#include <signal.h>
+
+
+#ifdef __HAVE_LIBCCC_USER__
+#include "ccc_user.h"
+#else
+static int ccc_tremain(double *tremain)
+{
+  tremain[0] = 0. ;
+  return EXIT_FAILURE;
+}
+#endif
+
+#define GLOST_MAXLEN 4096
+#define GLOST_MASTER 0
+#define TAG_AVAIL 1
+#define TAG_TSK   2
+
+static int glost_no_new_task=0;
+
+void read_options(int argc, char *argv[],double *user_tremain);
+void read_and_exec(char *filename, double user_tremain);
+void read_and_send(int slaves, char *filename, double user_tremain);
+void recv_and_exec(int rank);
+void set_sigaction();
+
+static void set_glost_no_new_task(int signum)
+{
+  fprintf(stderr,"#signal %i received: no new task will be submitted\n",signum);
+  glost_no_new_task=1;
+}
+
+static void read_next_command(FILE *fl,char *tsk, double user_tremain)
+{
+  int r;
+  double tremain;
+
+  tsk[0]='\0'; 
+
+  r = ccc_tremain(&tremain);
+  
+  fprintf(stderr,"#time remaining = %g\n", tremain);
+  fprintf(stderr,"#user_tremain = %g\n", user_tremain);
+  // fprintf(stderr,"#r=%d\n", r);
+	    	
+  r = (!r && tremain < user_tremain);
+  if (r) 
+    fprintf(stderr,"#time remaining = %g < %g : do not launch new tasks.\n",
+	    tremain,user_tremain);
+
+  if (glost_no_new_task) r = 1;   
+  if (r) return;
+
+  /* if(!fgets(tsk,GLOST_MAXLEN,fl)) tsk[0]='\0'; */
+  /* if(tsk[strlen(tsk)-1]=='\n') tsk[strlen(tsk)-1]='\0'; */
+
+  do {
+    if(!fgets(tsk,GLOST_MAXLEN,fl)){
+      tsk[0] = '\0';
+      break;
+    } 
+    r = strlen(tsk);
+  } while (r < 2);
+
+  if(tsk[r-1]=='\n') tsk[r-1]='\0';
+
+}
+
+static void exec_command(char *tsk, int rank)
+{
+  double t;
+  int r;
+
+  t = MPI_Wtime();  
+  r = system(tsk);
+  t = MPI_Wtime() - t;
+  if ( WIFEXITED(r) ) 
+    {
+      r = WEXITSTATUS(r); 
+      fprintf(stderr,"#executed by process\t%d in %gs\twith status\t%d : %s\n",
+	      rank,t,r,tsk);
+    }
+  else { 
+    if( WIFSIGNALED(r) ){
+      r = WTERMSIG(r); 
+      fprintf(stderr,"#executed by process\t%d in %gs\tkilled by signal %d: %s\n",
+	      rank,t,r,tsk);
+    }
+  }
+}
+
+
+int main(int argc,char **argv)
+{
+  FILE *fl;
+  int rank,size;
+  double user_tremain;
+
+  MPI_Init(&argc,&argv);
+  MPI_Comm_rank(MPI_COMM_WORLD,&rank);
+  MPI_Comm_size(MPI_COMM_WORLD,&size);  
+
+  set_sigaction();
+  if (rank == GLOST_MASTER){
+    printf("master is %d , nb slaves: %d\n", GLOST_MASTER,size-1);	
+    read_options(argc,argv,&user_tremain);
+  }
+
+  if (size == 1)
+    read_and_exec(argv[optind],user_tremain);
+  else if(size != 1 && rank == GLOST_MASTER)
+    read_and_send(size-1,argv[optind],user_tremain);
+  else
+    recv_and_exec(rank);
+
+  MPI_Finalize();
+}
+
+void read_options(int argc, char *argv[],double *user_tremain )
+{
+  int r;
+  int longoptind;
+  char opt[256];
+
+  user_tremain[0] = -1.;
+  static struct option longopts[]=
+    {
+      {"time_remaining",required_argument,NULL,'R'},
+      {0,0,0,0}
+    };
+
+  while (r = getopt_long(argc, argv,"R:",longopts,&longoptind))
+    {
+      if (r == -1) break; 
+      if (r == 0){ 		/* long option */
+	fprintf(stderr,"r %c\n",longopts[longoptind].val);	
+	r = longopts[longoptind].val ;
+      }
+	
+      switch(r)
+	{
+	case 'R': 
+	  *user_tremain = strtod(optarg,NULL);
+#ifndef   __HAVE_LIBCCC_USER__
+	  fprintf(stderr,"WARNING option -R %g ignored: not compiled with libccc_user\n",*user_tremain);
+#endif
+	  break;
+
+	case '?':
+	  fprintf(stderr,"WARNING option %c ignored: unknown option\n",optopt);	
+	  break;
+
+	default:
+	  abort();
+	  break;
+	}
+    }
+}
+
+void read_and_exec(char *filename, double user_tremain )
+{
+  FILE *fl;
+  char tsk[GLOST_MAXLEN];
+  double t;
+
+  fl = fopen(filename,"r");
+  do {
+    read_next_command(fl,tsk,user_tremain);
+    if(!strlen(tsk))
+      break;
+    exec_command(tsk,GLOST_MASTER);
+  } while (strlen(tsk));
+  fclose(fl);
+}
+
+void read_and_send(int slaves,char *filename, double user_tremain )
+{
+  int i, num, r;
+  MPI_Status status;
+  FILE *fl;
+  char tsk[GLOST_MAXLEN];
+
+  fl = fopen(filename,"r");
+  i=0;
+  do {
+    read_next_command(fl,tsk,user_tremain);
+    
+    MPI_Recv(&num,1,MPI_INT,MPI_ANY_SOURCE,
+	     TAG_AVAIL,MPI_COMM_WORLD,&status);
+    MPI_Send(tsk,GLOST_MAXLEN,MPI_CHAR,num,
+	     TAG_TSK,MPI_COMM_WORLD);
+    if (!strlen(tsk)) /* terminate command sent */
+      i++;
+  } while (i < slaves);
+  fclose(fl);
+}
+
+void recv_and_exec(int rank)
+{
+  char tsk[GLOST_MAXLEN];  
+  MPI_Status status;  
+
+  do {
+    MPI_Send(&rank,1,MPI_INT,GLOST_MASTER,
+	     TAG_AVAIL,MPI_COMM_WORLD); 
+    MPI_Recv(tsk,GLOST_MAXLEN,MPI_CHAR,GLOST_MASTER,
+	     TAG_TSK,MPI_COMM_WORLD,&status); 
+    if(!strlen(tsk)) /* terminate command */
+      break;
+    exec_command(tsk,rank);
+  } while (strlen(tsk));
+}
+
+
+/* signal handling */
+void set_sigaction()
+{
+  struct sigaction new_action;
+
+  new_action.sa_handler = set_glost_no_new_task ;
+  sigemptyset(&new_action.sa_mask);
+  new_action.sa_flags = SA_RESETHAND;
+
+  if (sigaction(SIGUSR1,&new_action,NULL) < 0)
+    fprintf(stderr,"#WARNING sigaction failed: no SIGQUIT support\n");
+}
+
+
+
Index: TOOLS/SURPACK_IPSL/launch_and_measureTime.sh
===================================================================
--- TOOLS/SURPACK_IPSL/launch_and_measureTime.sh	(revision 2136)
+++ TOOLS/SURPACK_IPSL/launch_and_measureTime.sh	(revision 2136)
@@ -0,0 +1,637 @@
+#!/bin/bash
+
+function update_tasks_list
+{
+   local tasksListFile=$1 # fichier contenant la nouvelle liste de cmds
+   touch $tasksListFile
+   local logFileOfPrevPack=$2 # fichier log de relatif a l'execution de la derniere liste de cmds
+   local tasksListFileOfPrevPack=$3 # fichier contenant la derniere liste de cmds
+   
+   > $tasksListFile
+   
+   old_IFS=$IFS     # sauvegarde du séparateur de champ  
+   IFS=$'\n'     # nouveau séparateur de champ, le caractère fin de ligne   
+   for cmdReport in $( cat $logFileOfPrevPack | grep -e '^#executed by process' )
+   do  
+       local resCmd=`echo $cmdReport | awk '{print $9}' `
+   # Status 50 = FAILED mais pas de ressoumission
+       if [ "x$resCmd" !=  "x0" ] && [ "x$resCmd" !=  "x50" ]
+       then
+           local cmdToPrint=`echo $cmdReport | awk '{print $NF}' `
+	   case "x$resCmd" in
+	   x5)
+	       newCmdToPrint=`echo $cmdToPrint | sed 's;output_ncrcat;output_tar;' `
+	       echo "./process_list.sh $newCmdToPrint" >> ${tasksListFile}
+	   ;;
+	   x10)
+	       echo "./process_list.sh $cmdToPrint" >> ${tasksListFile}	       
+	       newCmdToPrint=`echo $cmdToPrint | sed 's;output_ncrcat;output_tar;' `
+	       echo "./process_list.sh $newCmdToPrint" >> ${tasksListFile}
+	   ;;
+	   *)
+	       echo "./process_list.sh $cmdToPrint" >> ${tasksListFile}
+	   ;;
+	   esac
+       fi
+   done
+   IFS=$old_IFS     # rétablissement du séparateur de champ par défaut
+   
+   # Il faut aussi rajouter les cmds qui n'ont pas ete traitees du tout,
+   # par exemple en cas d'interruption du calculateur
+   # Pour cela, on boucle sur la derniere liste de cmds et on cherche dans le 
+   # fichier log associe si certaines sont absentes. On remet ces commandes (absentes)
+   # dans la nouvelle liste
+   old_IFS=$IFS     # sauvegarde du séparateur de champ  
+   IFS=$'\n'     # nouveau séparateur de champ, le caractère fin de ligne   
+   for cmd in $( cat $tasksListFileOfPrevPack )
+   do  
+       local list=`echo $cmd | awk '{print $NF}' `
+       hasListBeenTreated=`grep $list $logFileOfPrevPack | wc -l `
+       if [ "x${hasListBeenTreated}" == "x0" ]
+       then
+           echo $cmd  >> ${tasksListFile}
+       fi
+       
+ 
+   done
+   IFS=$old_IFS     # rétablissement du séparateur de champ par défaut
+   
+   # Il peut arriver que 2 listes soient identiques, on empeche ce cas
+   cat ${tasksListFile} | sort | uniq > ${JOB_DIR}/taskFile.txt
+   cat ${JOB_DIR}/taskFile.txt > ${tasksListFile}  
+
+}
+
+function getNumeroOfCurrentTry
+{
+   local num_try="1"
+   tryNumFile=${USER_OUTPUT_PROGRESS}/numero_current_try.txt
+   if [ ! -e $tryNumFile ]
+   then
+       echo "Le fichier :" >> $badFailureFile
+       echo "$tryNumFile" >> $badFailureFile
+       echo "doit etre present dans le repertoire :" >> $badFailureFile
+       echo "${USER_OUTPUT_PROGRESS}" >> $badFailureFile
+       echo "et il doit contenir un numero d'essai" >> $badFailureFile
+       exit 1
+   fi
+   num_try=`head -n 1 $tryNumFile `
+   echo $num_try
+   
+}
+
+function getNumeroOfLastInstance
+{
+    local num_instance="0"
+    local numTry=$1
+    ici=$PWD
+    local progressDirectory="${USER_OUTPUT_PROGRESS}/TRY__${numTry}"
+    if [ ! -e $progressDirectory ]
+    then
+        echo "fonction getNumeroOfLastInstance :" >> $badFailureFile
+	echo "Le repertoire :" >> $badFailureFile
+        echo "$progressDirectory" >> $badFailureFile
+        echo "devrait exister. Il n'existe pas." >> $badFailureFile
+        exit 1
+    fi    
+    cd $progressDirectory
+   
+    listFiles=`ls | grep -e "inputCmd__try__${numTry}__instance__[[:digit:]]\{1,2\}.list" `
+    for listFile in $listFiles
+    do
+       num=`echo $listFile | awk -F"__" '{print $NF}' | awk -F"." '{print $1}' `
+       if [ $num -gt $num_instance ]
+       then
+           num_instance=$num 
+       fi
+    done  
+    cd $ici
+    echo $num_instance
+
+
+}
+
+
+function check_progress
+{
+   local file1=$1
+   local file2=$2
+   local file_to_get_retCode=$3
+   if [ "x${file1}" == "x" ] || [ "x${file2}" == "x" ] || [ "x${file_to_get_retCode}" == "x" ]
+   then
+       echo "check_progress : Le nom d'au moins 1 des 3 fichiers d'entree est vide" >> $badFailureFile
+       exit 1
+   fi
+      
+   if [ ! -e $file1 ] || [ ! -e $file2 ] || [ ! -e ${file_to_get_retCode} ]
+   then
+       echo "check_progress : au moins un des 3 fichiers suivants n'existe pas :" >> $badFailureFile
+       echo "$file1" >> $badFailureFile
+       echo "$file2" >> $badFailureFile
+       echo "${file_to_get_retCode}" >> $badFailureFile
+       exit 1
+   fi
+   local nbLineFile1=`cat $file1 | wc -l `
+   local nbLineFile2=`cat $file2 | wc -l `
+   if [ $nbLineFile1 -ne $nbLineFile2 ]
+   then
+       echo 1
+       return
+   fi
+   # si l'on parvient a ce stade, c'est les 2 fichiers ont le meme
+   # nombre de lignes
+   
+   old_IFS=$IFS     # sauvegarde du séparateur de champ  
+   IFS=$'\n'     # nouveau séparateur de champ, le caractère fin de ligne   
+   for line in $( cat $file1 )
+   do
+       # echo $line
+       local isLineInFile2=`grep $line $file2 | wc -l `
+       if [ $isLineInFile2 -eq 0 ]
+       then
+           echo 1
+	   return
+       fi 
+   done
+   IFS=$old_IFS     # rétablissement du séparateur de champ par défaut
+   
+   # Les codes de retour sont-ils != 0 ?
+   nbNonZeroCodes=`cat ${file_to_get_retCode} | grep -e '^#executed by' | awk '{ if ($9 != 0) {print $9} }' | wc -l `
+   if [ $nbNonZeroCodes -gt 0 ]
+   then
+       echo 1
+       return
+   fi
+     
+   echo 0
+}
+
+
+function update_report
+{ 
+    > $reportFile # on vide le fichier rapport
+    echo "Execution of tasks :" >> $reportFile
+    echo "------------------" >> $reportFile
+    cat $inputCmd >> $reportFile
+    echo >> $reportFile
+    echo "Results of tasks :" >> $reportFile 
+    echo "----------------" >> $reportFile
+    cat $output >> $reportFile
+    echo >> $reportFile
+    echo >> $reportFile
+
+}
+
+function searchListsToDestroy
+{
+     outputToSearchIn=$1
+     listToRmvFile=$2
+     listsToProcessFile=$3
+     # On cherche les listes qui ont ete traitees correctement a la precedente etape de traitement
+     cat ${outputToSearchIn} | grep -e '^#executed by' | awk '{ if ($9 == 0) {print $12} }' >> ${listToRmvFile}
+     
+     # Cependant, il se peut (cas du basculement de listes "output_ncrcat" vers "output_tar") que des listes soient
+     # encore a traiter alors que qu'il y a eu traitement correct.
+     # Ne pas supprimer ces listes (les retirer du fichier des listes a supprimer).
+     listToRmvFile_tmp="${listToRmvFile}_tmp"
+     cp $listToRmvFile $listToRmvFile_tmp
+     
+     old_IFS=$IFS     # sauvegarde du séparateur de champ  
+     IFS=$'\n'     # nouveau séparateur de champ, le caractère fin de ligne     
+     for list in $( cat $listToRmvFile_tmp | grep "/output_ncrcat/" )
+     do
+	 list_tar=`echo $list | sed 's;output_ncrcat;output_tar;' `
+	 isInLstsToProcess=`grep $list_tar $listsToProcessFile | wc -l `
+	 if [ "x${isInLstsToProcess}" != "x0" ]
+	 then
+	     lineNbInRmvFile=`grep -n $list $listToRmvFile | awk -F":" '{print $1}' `
+	     sed -i "${lineNbInRmvFile}d" ${listToRmvFile}	 
+	 fi     
+     done
+     
+     for list in $( cat $listToRmvFile_tmp | grep "/output_tar/" )
+     do
+	 list_ncrcat=`echo $list | sed 's;output_tar;output_ncrcat;' `
+	 isInLstsToProcess=`grep $list_ncrcat $listsToProcessFile | wc -l `
+	 if [ "x${isInLstsToProcess}" != "x0" ]
+	 then
+	     lineNbInRmvFile=`grep -n $list $listToRmvFile | awk -F":" '{print $1}' `
+	     sed -i "${lineNbInRmvFile}d" ${listToRmvFile}	 
+	 fi
+
+	 # Si la liste est a detruire ET a traiter alors on l enleve de la liste a traiter	 
+	 isInLstsToProcess=`grep $list $listsToProcessFile | wc -l `
+	 if [ "x${isInLstsToProcess}" != "x0" ]
+	 then
+	     lineNbInProcessFile=`grep -n $list $listsToProcessFile | awk -F":" '{print $1}' `
+	     sed -i "${lineNbInProcessFile}d" ${listsToProcessFile}	 
+	 fi   
+     done
+            
+     IFS=$old_IFS     # retablissement du separateur de champ par defaut
+     
+     rm -f $listToRmvFile_tmp
+}
+
+function removeFilesInLists
+{
+     setOfFileLstsToRmv=$1
+     rmvedFiles=$2
+     linksToEraseFile=$3
+     realDataToEraseFile=$4
+     
+     old_IFS=$IFS     # sauvegarde du séparateur de champ  
+     IFS=$'\n'     # nouveau séparateur de champ, le caractère fin de ligne
+     
+     # Suppression des donnees autres que celles de type "debug" et "restart".
+     for lst in $( cat $setOfFileLstsToRmv | grep -v -E '(restart_tar|debug_tar)' )
+     do
+         opt=
+	 lstName=$( basename $lst )
+	 
+	 if [ "${lstName}" == "tar_full_simul.list" ] || [ "${lstName}" == "cp_files.list" ]
+	 then
+	     opt="r"
+	 fi
+
+	 sed -e "s/\(.*\)/rm -f${opt} \1/" $lst >> ${rmvedFiles} 
+	 	 
+	 # for file in $( cat $lst )
+	 # do
+	 #     echo "rm -f${opt} $file" >> ${rmvedFiles}
+	 #     if [ "x$deleteFiles" == "x1" ]
+	 #     then
+	 # 	 rm -f${opt} $file
+	 #     fi
+	 # done	  
+     done
+     
+     # Pour les listes de type "debug" et "restart", les listes ne comportent
+     # que des liens : uniquement leur nom de base, pas leur path
+     # Il faut retrouver leur path, detruire le lien et le fichier qu'il pointe.
+           
+     # Recherche de l'ensemble des fichiers a detruire : les liens + les donnees pointees par les liens 
+     for lst in $( cat $setOfFileLstsToRmv | grep -E '(restart_tar|debug_tar)' )
+     do
+         # Recuperation du repertoire contenant les fichiers de liens
+	 dir_containing_links=
+	 is_debug_tar_lst=`echo $lst | grep "debug_tar" | wc -l `
+	 if [ "x${is_debug_tar_lst}" != "x0" ]
+	 then
+	     dir_containing_links="DEBUG"
+	 else
+	     dir_containing_links="RESTART"
+	 fi
+	 
+	 tar_dir=$( dirname $lst )
+	 simu_dir=$( dirname $tar_dir )
+	 
+	 LINK_DIR="${simu_dir}/${dir_containing_links}"
+	 if [ ! -d  $LINK_DIR ]
+	 then
+	     echo "Suppression des donnees :" >> $badFailureFile
+	     echo "Le repertoire sense contenir des liens symboliques :" >> $badFailureFile
+	     echo "${LINK_DIR}" >> $badFailureFile
+	     echo "n'existe pas." >> $badFailureFile
+	     exit 1
+	 fi
+	 
+	 #
+	 # ls sur le reperoire de lien et insertion du path absolu avant chaque lien.
+	 ls -1 ${LINK_DIR} | sed "s;^;${LINK_DIR}/;" >> ${linksToEraseFile}
+	 
+	 # Recuperation des donnees reelles pointees par les liens.
+	 ls -1 -lrt ${LINK_DIR} | awk -F"->" '{print $2}' | sed 's;^ ;;' >> ${realDataToEraseFile}
+     done
+     
+     # Destruction des liens et des donnees pointees par les liens pour les listes 
+     # de type "debug" et "restart"
+     
+     # Destroy links
+
+     # for file in $( cat ${linksToEraseFile} )
+     # do
+     #     echo "rm -f $file" >> ${rmvedFiles}
+     # 	 if [ "x$deleteFiles" == "x1" ]
+     # 	 then
+     # 	     rm -f $file
+     # 	 fi
+     # done
+
+     sed -e "s/\(.*\)/rm -f \1/" ${linksToEraseFile} >> ${rmvedFiles}     
+
+     # Destroy real datas
+     # for file in $( cat ${realDataToEraseFile} )
+     # do
+     #     echo "rm -f $file" >> ${rmvedFiles}
+     # 	 if [ "x$deleteFiles" == "x1" ]
+     # 	 then
+     # 	     rm -f $file
+     # 	 fi
+     # done     
+
+     sed -e "s/\(.*\)/rm -f \1/" ${realDataToEraseFile} >> ${rmvedFiles}     
+     
+     if [ "x$deleteFiles" == "x1" ]
+     then
+	 sh ${rmvedFiles} 
+     fi
+
+     IFS=$old_IFS     # retablissement du separateur de champ par defaut
+}
+
+
+export RANDOM=$$ # random seed
+function gives_random_number
+{
+   lim=$1
+   bit=-1
+   let "bit = RANDOM % $lim"
+   bit=$(( $bit + 1 )) # nb entre 1 et $limit
+   echo $bit
+}
+
+########## batch directives : begin ##########
+#MSUB -r pack_ipsl          # Nom du job                
+### mutable directives ###
+#MSUB -o /ccc/dmfbuf/ipsl_logs/dsm/bacasable/ARNAUD/PSEUDO_DMNFS_PROGRESS/ARNAUD/IPSLCM5/R55C/detailed_pack_output/pack_ipsl_%I.o
+#MSUB -e /ccc/dmfbuf/ipsl_logs/dsm/bacasable/ARNAUD/PSEUDO_DMNFS_PROGRESS/ARNAUD/IPSLCM5/R55C/detailed_pack_output/pack_ipsl_%I.e
+#MSUB -n 16
+#MSUB -c 2
+#MSUB -x
+#MSUB -T 1500
+#MSUB -A tgcc0013
+#MSUB -q standard
+#MSUB -Q test
+########## batch directives : end ##########
+set +x
+export JOB_DIR=${TMP_MIGR_DATA}
+export EXE_DIR=${LS_SUBCWD:-${PWD}}
+source ${EXE_DIR}/DEM_utilities.sh
+
+export badFailureFile=${USER_OUTPUT_PROGRESS}/badFailure.txt
+
+export numCurrentTry=$( getNumeroOfCurrentTry )
+export progressDir="${USER_OUTPUT_PROGRESS}/TRY__${numCurrentTry}"
+if [ ! -e $progressDir ]
+then
+   echo "Le repertoire de suivi :" >> $badFailureFile
+   echo "$progressDir" >> $badFailureFile
+   echo "n'existe pas. STOP." >> $badFailureFile   
+   exit 1
+fi
+export numPrevInstance=$( getNumeroOfLastInstance $numCurrentTry )
+export numNewInstance=$(( $numPrevInstance + 1 ))
+
+export inputCmd="${progressDir}/inputCmd__try__${numCurrentTry}__instance__${numNewInstance}.list"
+export nextInputCmd="${progressDir}/nextInputCmd__try__${numCurrentTry}__instance__${numNewInstance}.list"
+export output="${progressDir}/packOutput__try__${numCurrentTry}__instance__${numNewInstance}.log"
+export reportFile="${progressDir}/report__try__${numCurrentTry}__instance__${numNewInstance}.log"
+export checkFile="${progressDir}/check__try__${numCurrentTry}__instance__${numNewInstance}.log"
+export checkFileTmp="${JOB_DIR}/checkTmp__try__${numCurrentTry}__instance__${numNewInstance}.txt"
+
+export listsOfFilesToRemove="${progressDir}/listsToRmv__try__${numCurrentTry}__instance__${numNewInstance}.txt"
+export removedFiles="${progressDir}/removedFiles__try__${numCurrentTry}__instance__${numNewInstance}.txt"
+
+# Les 2 fichiers suivants sont crees pour la destruction des liens et des donnees pointes par ces liens
+# dans le cas de listes de type "debug" ou "restart"
+export linksToDestroyFile="${progressDir}/linksToDestroy__try__${numCurrentTry}__instance__${numNewInstance}.txt"
+export realDataToDestroyFile="${progressDir}/realDataToDestroy__try__${numCurrentTry}__instance__${numNewInstance}.txt"
+
+export noInterruptFile="${progressDir}/noInterrupt__try__${numCurrentTry}__instance__${numNewInstance}.txt"
+
+
+if [ ${numCurrentTry} -le 1 ] && [ ${numNewInstance} -le 1 ]
+then
+    # C'est le tout premier essai
+    # on construit la liste des taches a effectuer en inventoriant les fichiers *.liste
+    # dans les rep contenus dans le fichier "config_card.liste"
+    > ${inputCmd}
+    for CONFIG in $( awk '{print $1}' ${IGCM_DEM}/config_card.liste ) ; do 
+    
+       PATH_SIMU=$( dirname $CONFIG )
+       # echo "PATH_SIMU=$PATH_SIMU"
+
+       setOfListFiles=`find $PATH_SIMU -type f -name "*.list" `
+       for file in $setOfListFiles
+       do
+    	    echo "./process_list.sh $file" >> ${inputCmd}
+       done      
+    done
+    
+else
+    # if try > 1 && inst == 1 ==> construction liste cmd avec fichiers try - 1, derniere instance
+    #                             dans ce dernier cas, gerer une eventuelle interruption au try - 1
+    # if try > 1 && inst > 1  ==> construction liste cmd avec fichiers try, instance precedente
+    if [ ${numNewInstance} -ge 2 ]
+    then
+        nextInputCmd_of_PrevInst="${progressDir}/nextInputCmd__try__${numCurrentTry}__instance__${numPrevInstance}.list"
+	if [ ! -e $nextInputCmd_of_PrevInst ]
+	then
+	    echo "Le fichier suivant :" >> $badFailureFile
+	    echo "$nextInputCmd_of_PrevInst" >> $badFailureFile
+	    echo "n'existe pas. Il devrait exister. STOP." >> $badFailureFile
+	    exit 1
+	fi
+	cat $nextInputCmd_of_PrevInst > ${inputCmd}
+    
+    else # numNewInstance == 1
+        numPrevTry=$(( $numCurrentTry - 1 ))
+        numLastInstInstanceInPrevTry=$( getNumeroOfLastInstance $numPrevTry )
+        noInterruptFile_prev_try="${progressDir}/noInterrupt__try__${numPrevTry}__instance__${numLastInstInstanceInPrevTry}.txt"
+        if [ ! -e ${noInterruptFile_prev_try} ]
+        then
+	    # il y a eu interruption non prevue au dernier essai, il faut recomposer la liste des cmds avec les resultats
+	    # de l'essai precedent, derniere instance
+	    prevProgressDir="${USER_OUTPUT_PROGRESS}/TRY__${numPrevTry}"
+	    nextInputCmd_of_LastInst="${prevProgressDir}/nextInputCmd__try__${numPrevTry}__instance__${numLastInstInstanceInPrevTry}.list"
+	    output_of_LastInst="${prevProgressDir}/packOutput__try__${numPrevTry}__instance__${numLastInstInstanceInPrevTry}.log"
+	    inputCmd_of_LastInst="${prevProgressDir}/inputCmd__try__${numPrevTry}__instance__${numLastInstInstanceInPrevTry}.list"
+	    if [ ! -e $output_of_LastInst ] || [ ! -e $inputCmd_of_LastInst ]
+	    then
+	        echo "Les fichiers suivants :" >> $badFailureFile
+	        echo "$output_of_LastInst" >> $badFailureFile
+		echo "$inputCmd_of_LastInst" >> $badFailureFile
+	        echo "n'existent pas. Il devrait exister. STOP." >> $badFailureFile
+	        exit 1
+	    fi
+	    
+            update_tasks_list ${nextInputCmd_of_LastInst} ${output_of_LastInst} ${inputCmd_of_LastInst}
+	    cat $nextInputCmd_of_LastInst > ${inputCmd}
+	    
+	    
+            # Il faut aussi detruire les donnees correctement traitement a l'essai precedent, derniere instance.
+	    listsOfFilesToRemoveFromPrevTry="${progressDir}/listsToRmvFromPrev__try__${numPrevTry}__instance__${numLastInstInstanceInPrevTry}.txt"
+	    removedFilesFromPrevTry="${progressDir}/removedFilesFromPrev__try__${numPrevTry}__instance__${numLastInstInstanceInPrevTry}.txt"
+	    linksToDestroyFileFromPrevTry="${progressDir}/linksToDestroyFromPrev__try__${numPrevTry}__instance__${numLastInstInstanceInPrevTry}.txt"
+	    realDataToDestroyFileFromPrevTry="${progressDir}/realDataToDestroyFromPrev__try__${numPrevTry}__instance__${numLastInstInstanceInPrevTry}.txt"
+	    	    
+	    searchListsToDestroy $output_of_LastInst $listsOfFilesToRemoveFromPrevTry ${inputCmd}
+	    removeFilesInLists $listsOfFilesToRemoveFromPrevTry $removedFilesFromPrevTry $linksToDestroyFileFromPrevTry $realDataToDestroyFileFromPrevTry
+	    
+        else
+	    nextInputCmd_of_LastInst="${progressDir}/nextInputCmd__try__${numPrevTry}__instance__${numLastInstInstanceInPrevTry}.list"
+	    if [ ! -e $nextInputCmd_of_LastInst ]
+	    then
+	        echo "Le fichier suivant :" >> $badFailureFile
+	        echo "$nextInputCmd_of_LastInst" >> $badFailureFile
+	        echo "n'existe pas. Il devrait exister. STOP." >> $badFailureFile
+	        exit 1
+	    fi
+	    cat $nextInputCmd_of_LastInst > ${inputCmd}
+        fi 
+        
+    fi
+fi
+
+# Initialisation du rapport : par defaut, les calculs ont ete interrompus
+echo "No report. Le computation must have been interrupted." > $reportFile
+
+# exit 0 # a virer
+
+# a virer #########################################
+# if [ ${numNewInstance} -ge 10 ]
+# then
+#     echo >> $badFailureFile
+#     echo "10eme instance. STOP." >> $badFailureFile
+#     exit 1
+# fi
+###################################################
+# startTime=$( getDateMilliSeconds ) # suppr
+# echo "start time:$startTime" >> $timeHandlingFile # suppr
+> $timeEndFile # added
+
+ccc_mprun  ./glost_launch -R $timeLimitBeforeEnd ${inputCmd} 2>${output}
+if [ "x$?" != "x0" ]
+then
+   echo "Temps limite atteint pour l'essai : ${numCurrentTry}; instance : ${numNewInstance}" >> $badFailureFile
+fi
+
+### ccc_mprun  ./cmd_launch.exe ${inputCmd} 2>${output}
+
+###    ./cmd_launch.exe ${inputCmd} 2>${output}
+###    ccc_mprun -p standard -n ${BRIDGE_MSUB_NPROC} ./cmd_launch.exe ${inputCmd} 2>myIO/output.log
+###    mpirun -n 4 ./cmd_launch.exe myIO/inputCmd10.list 2>myIO/output.log
+
+# meantime=$( getTimeDiffSeconds $startTime ) # suppr
+
+endExecutionTime=$( getDateMilliSeconds )
+echo "end time:$endExecutionTime" >> $timeEndFile
+
+
+
+# echo "meantime ncrcat = $meantime"
+
+# exit 0 # a virer
+
+# Gestion des reprises :
+# --------------------
+
+update_report
+
+update_tasks_list $nextInputCmd $output $inputCmd
+
+
+# Verifications sur qq listes (dont le traitement semble correct) :
+# ----------------------------------------------------------------------------------------
+if [ "x${doYouWantCheck}" == "xyes" ]
+then
+    if [ "x${nbListsToCheck}" == "x" ]
+    then
+	echo "nbre de listes a checker absent" >> $checkFile
+	echo "nbre de listes a checker absent" >> $badFailureFile
+	exit 1
+    fi
+    > $checkFileTmp
+    # ensemble des listes concatenees correctement
+    set_of_good_lists=`cat $output | grep -e '^#executed by process' | awk '{ if ($9==0){print $12} }' | grep "output_ncrcat" `
+
+    # envoi des cmds de check dans fichier tmp
+    for lst in $set_of_good_lists
+    do
+       echo "./check_ncrcat_list.sh $lst" >> $checkFileTmp
+    done
+
+    # nombre de listes concatenees correctement
+    nb_of_good_lists=`cat $checkFileTmp | wc -l `
+
+    # le nb de listes a checker ne peut exceder le nb de listes disponibles pour le check
+    if [ $nbListsToCheck -ge $nb_of_good_lists ]
+    then
+	nbListsToCheck=$nb_of_good_lists
+    fi
+    nbLstToCheck_tmp=$nbListsToCheck
+
+    while [ $nbLstToCheck_tmp -gt 0 ]
+    do
+	random_number=$( gives_random_number $nbLstToCheck_tmp ) # nb aleatoire entre 1 et $nbLstToCheck_tmp
+	checkCmd=`sed -n "${random_number}p" $checkFileTmp `
+	$checkCmd # on envoie la cmd de check
+	resCmd=$?
+	if [ "x${resCmd}" != "x0" ]
+	then
+            echo "$checkCmd ==> not OK ==> stop everything." >> $checkFile
+	    echo "$checkCmd ==> not OK ==> stop everything." >> $badFailureFile
+	    exit 1 # a retablir
+	else
+            echo "$checkCmd ==> OK" >> $checkFile
+	fi
+	sed -i "${random_number}d" $checkFileTmp # on retire la cmd qui vient d'etre effectuee du fichier tmp
+	nbLstToCheck_tmp=$(( $nbLstToCheck_tmp - 1 ))
+    done
+
+
+    rm $checkFileTmp
+fi
+# ----- Fin verif ------------------------------------------------------------------------
+
+
+# Suppression des données des fichiers de listes correctement traitees -------------------
+# Recherche des listes de fichiers de donnees a detruire :
+# Parmi celles traitees, celles qui ont ete traitees correctement
+> $listsOfFilesToRemove
+> $removedFiles
+> $linksToDestroyFile
+> $realDataToDestroyFile
+
+searchListsToDestroy $output $listsOfFilesToRemove $nextInputCmd
+
+removeFilesInLists $listsOfFilesToRemove $removedFiles $linksToDestroyFile $realDataToDestroyFile
+
+
+
+# ----- Fin suppression de donnees -------------------------------------------------------
+
+# Si le fichier dans variable "noInterruptFile" inexistant, une interruption non prevue a eu lieu
+echo "no interruption has occured" > ${noInterruptFile}
+
+# exit 0 # a virer
+
+# Tout s'est bien passe
+# ----------------------
+everythingOK=`cat $nextInputCmd | wc -l `
+if [ "x${everythingOK}" == "x0" ]
+then
+    echo "Tout s'est fini correctement" >> $badFailureFile
+    exit 0
+fi
+
+# Y a t il progression entre avant traitements et apres ?
+# ------------------------------------------------------
+# Dans la fonction 'check_progress', on a besoin de verifier le code
+# de retour du traitement des listes : en effet, si les 2 fichiers a comparer
+# contiennent les memes fichiers de liste, il faut aussi que les codes de
+# retour soient != 0. 
+file_to_get_lists_retCode=$output
+resDiff=$( check_progress $inputCmd $nextInputCmd $file_to_get_lists_retCode )
+
+# resDiff == 1 : fichiers differents
+# resDiff == 0 : fichiers identiques
+if [ "x${resDiff}" == "x0" ]
+then
+    echo "Il n'y pas plus de progression" >> $badFailureFile
+    exit 1
+fi
+
+# On enchaine avec le meme script
+ccc_msub ${TMP_MIGR_DATA}/launch_and_measureTime.sh
Index: TOOLS/SURPACK_IPSL/launch_ipsl_enlarge.sh
===================================================================
--- TOOLS/SURPACK_IPSL/launch_ipsl_enlarge.sh	(revision 2136)
+++ TOOLS/SURPACK_IPSL/launch_ipsl_enlarge.sh	(revision 2136)
@@ -0,0 +1,144 @@
+#!/bin/bash
+######################
+## TITANE   CEA ##
+######################
+#MSUB -r ipsl_pack      # Nom du job                
+#MSUB -eo
+#MSUB -n 1              # Reservation du processus
+#MSUB -T 86400          # Limite de temps elapsed du job
+#MSUB -p gen2211
+#MSUB -q mono
+
+# ex : ./launch_ipsl_enlarge.sh
+
+# Est-on sur ulam (machine de l'IDRIS) ?
+is_idris_machine=`hostname | grep "ulam" | wc -l `
+ON_IDRIS="no"
+if [ "x${is_idris_machine}" != "x0" ]
+then
+    ON_IDRIS="yes"
+fi
+export ON_IDRIS=${ON_IDRIS}
+
+# gpdebug : pour option -f
+restartExecFromZero=0
+while [ $# -gt 0 ]
+do
+   echo "boucle sur les arguments du script ..."
+   echo "@=$@"
+   case $1 in
+   -f)  restartExecFromZero=1 
+        echo "force restart from the beginning ..."
+	;;
+   esac
+   shift
+done
+export restartExecFromZero=${restartExecFromZero}
+# gpdebug : end
+
+#export JOB_DIR=${TMP_MIGR_DATA}
+#export EXE_DIR=${LS_SUBCWD:-${PWD}}
+
+# export INPUT_DMF_DATA=/ccc/dmfbuf/import_data.2/ccrt/dmnfs12/cont003/bacasable # gpdebug : suppr
+# export OUTPUT_STORE=${SCRATCHDIR}/PSEUDO_DMNFS_STORE # gpdebug : suppr
+# export OUTPUT_WORK=${SCRATCHDIR}/PSEUDO_DMNFS_WORK # gpdebug : suppr
+
+SCRIPT_NAME=$(basename ${0} )
+
+# export IGCM_DEM=${SCRATCHDIR}/IGCM_DEM # gpdebug : suppr
+# export IGCM_TMP=${SCRATCHDIR}/IGCM_DEM/tmp # gpdebug : suppr
+
+# On renseigne les variables d'environnement
+export scriptCallingLoad=$SCRIPT_NAME # sert a renseigner "load_ipslPack_env.sh" sur le script l'appelant
+. load_ipslPack_env.sh
+export IGCM_TMP="${IGCM_DEM}/tmp"  # gpdebug : added
+
+export JOB_DIR=${TMP_MIGR_DATA}
+export EXE_DIR=${LS_SUBCWD:-${PWD}}
+
+export clean_tmp=${clean_tmp:-yes}
+export DEM_LOG=${JOB_DIR}/dem_${LSB_JOBID:-${$}}.log
+export LOG_LEV=2
+
+export config_card=${IGCM_DEM}/config_card.liste
+
+
+############## gpdebug : Pour gestion des erreurs ######################################### 
+# Execute la function errorReceive() si reception d'un signal TERM
+trap 'DEM_errorReceive' TERM
+# liste des processus à détruire en cas d'erreur bloquante
+export listPID=$$
+# fichier pour la transmission des messages d'erreur d'un fils au prog principal
+export errorMsgFile="${TMP_MIGR_DATA}/errorMsg.txt"
+############## gpdebug : fin ############################################################## 
+
+source ${EXE_DIR}/DEM_utilities.sh
+
+DEM_log -0 "Demarrage de ${SCRIPT_NAME}"
+
+if [ "x${ON_IDRIS}" == "xno" ]
+then
+    check_nco_version # verification de la version de nco #######################
+else
+    check_nco_version_idris # verification de la version de nco (sur la machine ulam de l'idris)
+    check_netcdf_idris      # verification du chargement du module netCDF (pour cmd ncdump) 
+fi
+
+# gpdebug : si l'option -f est activee, on detruit tous les fichiers status
+if [ "x$restartExecFromZero" == "x1" ]
+then
+    echo "Deleting  all status files ..."
+    for CONFIG in $( awk '{print $1}' ${IGCM_DEM}/config_card.liste )
+    do
+       PATH_SIMU=$( dirname $CONFIG )
+       ListStatFileInSimu=`find $PATH_SIMU -type f -name "*status" `
+       if [ "x$ListStatFileInSimu" != "x" ]
+       then
+           for file in $ListStatFileInSimu
+           do
+              if [ -e $file ]
+	      then
+	         rm -f $file
+	      fi
+       
+           done      
+       fi   
+    done
+    echo "Deletion done."
+fi
+# gpdebug : end
+
+export timeLaunchStartFile="${USER_OUTPUT_PROGRESS}/timeLaunchStartFile.txt"
+> $timeLaunchStartFile
+startTime=$( getDateMilliSeconds )
+echo "launch time:$startTime" > $timeLaunchStartFile
+
+
+for CONFIG in $( awk '{print $1}' ${IGCM_DEM}/config_card.liste ) ; do 
+
+    DEM_state=$( DEM_read_state ${IGCM_DEM}/config_card.liste ${CONFIG} )
+
+    if [[ "${DEM_state}" != "WriteListTarDone" ]] ; then
+
+	DEM_write_state ${IGCM_DEM}/config_card.liste ${CONFIG} PackRunning
+	export PATH_SIMU=$( dirname $CONFIG )
+	${EXE_DIR}/enlarge_my_files.sh ${INPUT_DMF_DATA} ${OUTPUT_STORE} ${OUTPUT_WORK}
+    
+	DEM_write_state ${IGCM_DEM}/config_card.liste ${CONFIG} PackDone
+
+    else
+	DEM_write_state ${IGCM_DEM}/config_card.liste ${CONFIG} TarRunning
+	export PATH_SIMU=$( dirname $CONFIG )
+	# ${EXE_DIR}/tar_full_simu.sh  ${INPUT_DMF_DATA} ${OUTPUT_STORE} ${CONFIG}
+	${EXE_DIR}/enlarge_my_files.sh  ${INPUT_DMF_DATA} ${OUTPUT_STORE} ${CONFIG}
+	DEM_write_state ${IGCM_DEM}/config_card.liste ${CONFIG} TarDone
+
+
+    fi
+
+done
+
+export timeEndFile="${USER_OUTPUT_PROGRESS}/timeEndFile.txt"
+> $timeEndFile
+
+DEM_log -0 "Fin de ${SCRIPT_NAME}"
Index: TOOLS/SURPACK_IPSL/launch_ipsl_pack.sh
===================================================================
--- TOOLS/SURPACK_IPSL/launch_ipsl_pack.sh	(revision 2136)
+++ TOOLS/SURPACK_IPSL/launch_ipsl_pack.sh	(revision 2136)
@@ -0,0 +1,169 @@
+#!/bin/bash
+######################
+## TITANE   CEA ##
+######################
+#MSUB -r ipsl_pack      # Nom du job                
+#MSUB -eo
+#MSUB -n 1              # Reservation du processus
+#MSUB -T 86400          # Limite de temps elapsed du job
+#MSUB -p gen2211
+#MSUB -q mono
+
+# ex : ./launch_ipsl_pack.sh fichier_param_test1.txt
+# ex : ./launch_ipsl_pack.sh param_SL.txt
+# ex : ./launch_ipsl_pack.sh param_OM.txt
+
+# Est-on sur ulam (machine de l'IDRIS) ?
+is_idris_machine=`hostname | grep "ulam" | wc -l `
+ON_IDRIS="no"
+if [ "x${is_idris_machine}" != "x0" ]
+then
+    ON_IDRIS="yes"
+fi
+export ON_IDRIS=${ON_IDRIS}
+
+##### gpdebug : addition ##################################
+# Boucle qui gere les parametres du script (permet l'introduction d'une option -f 
+# qui force l'execution de toute les etapes du script de listes)
+execEveryStep=0
+LISTE_SIMUL_ARG=
+while [ $# -gt 0 ]
+do
+   echo "boucle sur les arguments du script ..."
+   echo "@=$@"
+   case $1 in
+   -f)  execEveryStep=1 
+        echo "force..."
+	;;
+   *)  LISTE_SIMUL_ARG=${1} 
+       echo "autres..."
+       ;;
+   esac
+   shift
+done
+export execEveryStep=${execEveryStep}
+
+SCRIPT_NAME=$(basename ${0} )
+
+# On renseigne les variables d'environnement
+export scriptCallingLoad=$SCRIPT_NAME # sert a renseigner "load_ipslPack_env.sh" sur le script l'appelant
+. load_ipslPack_env.sh
+
+if [ "x${LISTE_SIMUL_ARG}" == "x" ]
+then
+    if [ -f /ccc/work/cont003/dsm/p86ipsl/PARAM_USER_IPSL/$USER.txt ]
+    then
+	echo "The file used is /ccc/work/cont003/dsm/p86ipsl/PARAM_USER_IPSL/$USER.txt" 
+	LISTE_SIMUL="/ccc/work/cont003/dsm/p86ipsl/PARAM_USER_IPSL/$USER.txt" 
+    else	
+	echo "Vous devez passer un fichier en parametre"
+	exit 1
+    fi
+else
+    LISTE_SIMUL=${LISTE_SIMUL_ARG}
+fi
+
+LISTE_SIMUL_NAME=$(basename ${LISTE_SIMUL} )
+# fichier de progression d'execution
+ficParam=$( basename ${LISTE_SIMUL} ) # gpdebug : modif ici et ligne d'apres
+extSuiviListes=`echo ${ficParam} | sed 's;\.[[:alnum:]]*$;;' `
+
+##### gpdebug : fin #####################################
+
+export JOB_DIR=${TMP_MIGR_DATA}
+export EXE_DIR=${LS_SUBCWD:-${PWD}}
+
+export MonitoringDir="${TMP_MIGR_DATA}/SuiviListes_${extSuiviListes}"
+
+export generalMonitorFile=${MonitoringDir}/general.txt
+export nbSimuFile=${MonitoringDir}/nbSimu.txt
+
+
+if [ "x${IGCM_DEM}" == "x" ]
+then
+    echo "variable IGCM_DEM non renseignee. STOP."
+    exit 1
+fi
+if [ "x${execEveryStep}" == "x1" ]
+then
+    echo "Destruction du repertoire :"
+    echo "${IGCM_DEM}"
+    rm -rf ${IGCM_DEM}
+fi
+
+export IGCM_TMP="${IGCM_DEM}/tmp" 
+# INPUT_DMF_DATA, positionnee par le load_ipslPack_env.sh, sert pour pour PATH_SIMUL_SHORT dans create_config_card.sh
+
+export clean_tmp=${clean_tmp:-yes}
+export DEM_LOG=${JOB_DIR}/dem_${LSB_JOBID:-${$}}.log
+export LOG_LEV=0
+export FileParam=${LISTE_SIMUL} # gpdebug : pour appel (dans DEM_utilities.sh) a showListsProgress.sh
+export FatherPID=$$ # gpdebug : pour appel (dans DEM_utilities.sh) a showListsProgress.sh
+
+source ${EXE_DIR}/DEM_utilities.sh
+
+# gpdebug : prepare le fichier de suivi de la progression
+prepareMonitoringDir
+
+# gpdebug : Execute la function errorReceive() si reception d'un signal TERM
+trap 'DEM_errorReceive' TERM ########
+
+# gpdebug : liste des processus à détruire en cas d'erreur bloquante
+export listPID=$$ ########
+
+# gpdebug : fichier pour la transmission des messages d'erreur d'un fils au prog principal
+export errorMsgFile="${TMP_MIGR_DATA}/errorMsg.txt" ########
+
+DEM_log -0 "Demarrage de ${SCRIPT_NAME}"
+
+mkdir -p ${IGCM_DEM}
+mkdir -p ${IGCM_TMP}
+
+rm -rf ${IGCM_TMP}/tmp/*
+rm -f ${DEM_LOG}
+
+# 0- on cree le listing correspondant au fichier param 
+# on efface les tests precedents
+
+for DIR in $( awk '{print $0}' ${LISTE_SIMUL} ) ; do
+    eval DIR_FINAL=$DIR
+    ./create_listing.sh $DIR_FINAL
+done
+
+LISTE_DMNFS=${IGCM_DEM}/Listing.txt
+
+
+# 1- A partir de param_list - on recherche l'ensemble des simulations a packer
+# la liste creee (liste_simul_$1) est stockee dans $SCRATCHDIR/IGCM_DEM
+
+${EXE_DIR}/find_directory_simul.sh ${LISTE_SIMUL} ${LISTE_DMNFS}
+
+
+# 2- Pour chacune des simulations listees on cree un fichier config.card correspondant
+# ces fichiers seront stockes dans ${IGCM_DEM}/arborescence/
+# un fichier recapitulatif des fichiers config.card (config_card.liste) crees sera stocke dans ${IGCM_DEM}
+
+${EXE_DIR}/create_config_card.sh ${IGCM_DEM}/liste_simul_${LISTE_SIMUL_NAME}  ${LISTE_DMNFS}
+
+#3- recherche de la taille ideale de pack pour chacune des simulations - puis creation des listes
+
+for CONFIG in $( awk '{print $1}' ${IGCM_DEM}/config_card.liste ) ; do 
+    DEM_log -2 ${CONFIG}
+
+    eval $(grep IGCM_DEM_SIMU ${CONFIG})
+    ${EXE_DIR}/calcul_size_simul.sh ${CONFIG} ${LISTE_DMNFS}
+
+    DEM_state=$( DEM_read_state ${IGCM_DEM}/config_card.liste ${CONFIG} )
+    if [[ "${DEM_state}" != "WriteListTarDone" ]] ; then
+
+	DEM_log -3  "la simulation est superieur a 1Go alors on pack"
+	${EXE_DIR}/find_size_pack.sh   ${CONFIG} ${LISTE_DMNFS}
+	${EXE_DIR}/write_liste_pack.sh ${CONFIG} ${LISTE_DMNFS}
+	${EXE_DIR}/archive_restart.sh ${CONFIG} ${LISTE_DMNFS}
+	${EXE_DIR}/archive_debug.sh ${CONFIG} ${LISTE_DMNFS}
+
+    fi
+done
+####################################################################
+
+DEM_log -0 "Fin de ${SCRIPT_NAME}"
Index: TOOLS/SURPACK_IPSL/loadParameters.sh
===================================================================
--- TOOLS/SURPACK_IPSL/loadParameters.sh	(revision 2136)
+++ TOOLS/SURPACK_IPSL/loadParameters.sh	(revision 2136)
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+# nombre de listes a verifier par l'outil "check_ncrcat_list.sh"
+export nbListsToCheck=1
+
+# Voulez vous le check ?
+export doYouWantCheck="no"
+
+# Voulez vous recommencer les traitements depuis le debut ?
+# Attention : l'option -f de parallelPack.sh est prioritaire par
+#             rapport au contenu de cette variable :
+#             *  Si -f est indiquee au lancement de parallelPack.sh et que
+#                forceRestartFromBegin="no" ici, le forcage sera mis en oeuvre.
+#             *  Si forceRestartFromBegin="no" ici et que -f n'est pas indiquee
+#                au lancement de parallelPack.sh, le forcage sera mis en oeuvre.
+export forceRestartFromBegin="no"
+
+# Nombre max d essais
+export maxtry=3
Index: TOOLS/SURPACK_IPSL/load_batch_directives.sh
===================================================================
--- TOOLS/SURPACK_IPSL/load_batch_directives.sh	(revision 2136)
+++ TOOLS/SURPACK_IPSL/load_batch_directives.sh	(revision 2136)
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+# Directives Batch pour le code parallele
+export nbProcs="16"
+
+# Duree max des traitements pour une instance du script "launch_and_measureTime.sh"
+export computationTime="1500"
+
+# Si on est a "timeLimitBeforeEnd" de la fin des traitements (la duree max
+# des traitements est indique par la variable "computationTime"),
+# tout proc mpi ayant fini sa tache s'arrete.
+export timeLimitBeforeEnd="50"
+
+export projectName="tgcc0013"
+
+export queueType="standard"
+
+export QosType="test"
+
+export corePerProc="1"
Index: TOOLS/SURPACK_IPSL/load_ipslPack_env.sh
===================================================================
--- TOOLS/SURPACK_IPSL/load_ipslPack_env.sh	(revision 2136)
+++ TOOLS/SURPACK_IPSL/load_ipslPack_env.sh	(revision 2136)
@@ -0,0 +1,109 @@
+#!/bin/bash
+
+# TMP_MIGR_DATA = repertoire temporaire de travail
+export TMP_MIGR_DATA="$SCRATCHDIR/TEST_PACK" 
+# INPUT_DMF_DATA = repertoire contenant les donnees de l'utilisateur
+## ATTENTION : il ne faut pas de "/" en fin de path
+export INPUT_DMF_DATA="/ccc/store/cont003/dsm/p86caub/dmf_import/IGCM_OUT"
+# OUTPUT_STORE / OUTPUT_WORK = repertoire de stockage des donnees une fois traitees 
+export OUTPUT_STORE="$SCRATCHDIR/TEST_PACK/PSEUDO_DMNFS_STORE"
+export OUTPUT_WORK="$SCRATCHDIR/TEST_PACK/PSEUDO_DMNFS_WORK"
+
+#IGCM_DEM = espace dans lequel nous stockerons nos listes de fichiers packables
+export IGCM_DEM=${TMP_MIGR_DATA}"/IGCM_DEM"
+#OUPUT_CHECK = espace pour faire des operations de double verification durant le processus de package
+export OUTPUT_CHECK=${TMP_MIGR_DATA}"/PSEUDO_DMNFS_CHECK"
+#OUTPUT_PROGRESS = espace permettant la gestion des reprises en cas d'arret non prevu ou d'echec. 
+export OUTPUT_PROGRESS=${TMP_MIGR_DATA}"/PSEUDO_DMNFS_PROGRESS"
+
+# Variables d'environnement
+
+# Sur curie en sequentiel
+# export OUTPUT_PROGRESS="/ccc/dmfbuf/import_data.2/ccrt/dmnfs12/cont003/bacasable/GUILLAUME/PSEUDO_DMNFS_PROGRESS_SEQ"
+# export OUTPUT_STORE="/ccc/dmfbuf/import_data.2/ccrt/dmnfs12/cont003/bacasable/GUILLAUME/PSEUDO_DMNFS_STORE_SEQ"
+# export OUTPUT_WORK="/ccc/dmfbuf/import_data.2/ccrt/dmnfs12/cont003/bacasable/GUILLAUME/PSEUDO_DMNFS_WORK_SEQ"
+
+
+# Pour titane
+#export IGCM_DEM="/scratch/cont003/pierreg/IGCM_DEM"
+#export INPUT_DMF_DATA="/scratch/cont003/pierreg/datasLabo/dataDMNFS_simple1"
+#export OUTPUT_STORE="/scratch/cont003/pierreg/PSEUDO_DMNFS_STORE"
+#export OUTPUT_WORK="/scratch/cont003/pierreg/PSEUDO_DMNFS_WORK"
+#export OUTPUT_CHECK="/scratch/cont003/pierreg/PSEUDO_DMNFS_CHECK"
+#export OUTPUT_PROGRESS="/scratch/cont003/pierreg/PSEUDO_DMNFS_PROGRESS"
+
+
+
+# Determination du chemin pour le rep ${PSEUDO_DMNFS_PROGRESS}/USER (seulement pour la partie de pack)
+# ------------------------------------------------------------------
+# Le rep ${OUTPUT_PROGRESS} contiendra des sous rep USER
+# ${OUTPUT_PROGRESS}/USER contiendra, pour l'utilisateur USER :
+#    * la liste des taches a executer en parallele par le prog c/mpi
+#    * la nouvelle liste des taches qui n'ont pas ete reussies dans un premier temps
+#    * les sorties des taches executees en parallele (traitement des liste de fichiers)
+# L'idee est de regrouper ces elements dans un rep ${OUTPUT_PROGRESS}/USER
+# Pour determiner le rep USER, on parcourt ${IGCM_DEM}/config_card.liste. 
+# La chaine de caract commune a toutes les lignes de ce fichier est le rep USER, 
+# que l'on cree ensuite dans ${OUTPUT_PROGRESS}
+
+function find_intersection
+{
+    # Trouve la sous chaine commune de 2 chaines de caract
+    local string1=$1
+    local string2=$2
+
+    local lengthString1=${#string1}
+    local lengthString2=${#string2}
+
+    local longestString=
+    local smallestString=
+    if [ $lengthString1 -ge $lengthString2 ]
+    then
+       longestString=$string1
+       smallestString=$string2
+    else
+       longestString=$string2
+       smallestString=$string1  
+    fi
+
+    while [ "x`echo $longestString | grep $smallestString `" == "x" ]
+    do
+	smallestString=$( dirname $smallestString )
+    done
+    echo "$smallestString"
+}
+
+
+scriptCallingThisOne="$scriptCallingLoad"
+# echo "scriptCallingThisOne=$scriptCallingThisOne"
+
+if [ "x${scriptCallingThisOne}" != "xlaunch_ipsl_pack.sh" ]
+then
+
+    echo "specific loading for pack script."
+    
+    COMMON_STRING=`head -n 1 ${IGCM_DEM}/config_card.liste | awk '{print $1}' | xargs dirname `
+    for CONFIG in $( awk '{print $1}' ${IGCM_DEM}/config_card.liste ) ; do
+
+       PATH_SIMU=$( dirname $CONFIG )
+       INTERSECT=$( find_intersection  $PATH_SIMU $COMMON_STRING )
+       COMMON_STRING=$INTERSECT
+
+    done
+
+    # echo "COMMON_STRING=$COMMON_STRING"
+
+    PATH_TO_ADD=`echo $COMMON_STRING | sed "s;${IGCM_DEM};;" | sed 's;^/;;' `
+    # echo "PATH_TO_ADD=$PATH_TO_ADD"
+
+    USER_OUTPUT_PROGRESS="${OUTPUT_PROGRESS}/${PATH_TO_ADD}"
+    export USER_OUTPUT_PROGRESS=`echo $USER_OUTPUT_PROGRESS | sed 's;/$;;' `
+    export DETAILLED_OUTPUT="${USER_OUTPUT_PROGRESS}/detailed_pack_output"
+
+    # creation du rep ${IGCM_DEM}/PSEUDO_DMNFS_PROGRESS/USER
+    mkdir -p ${USER_OUTPUT_PROGRESS}
+
+    # creation d'un rep specifique pour les sorties detaillees des operations de pack
+    mkdir -p ${DETAILLED_OUTPUT}
+
+fi
Index: TOOLS/SURPACK_IPSL/monit_header.txt
===================================================================
--- TOOLS/SURPACK_IPSL/monit_header.txt	(revision 2136)
+++ TOOLS/SURPACK_IPSL/monit_header.txt	(revision 2136)
@@ -0,0 +1,1 @@
+User;Inode NB;Inode Processed;Inode Treatment Percentage;Inode After;Inode store;Inode percentage STORE-WORK;Simu NB;Simu OK; Simu FAILED;Simu Percentage;List NB;List OK;List FAILED;List Percentage
Index: TOOLS/SURPACK_IPSL/monitoring.sh
===================================================================
--- TOOLS/SURPACK_IPSL/monitoring.sh	(revision 2136)
+++ TOOLS/SURPACK_IPSL/monitoring.sh	(revision 2136)
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+# Variables a renseigner
+# Stockage des fichiers pour monitoring de tous les users (pour l instant sur p86caub)
+export MONIT_DIR=/ccc/work/cont003/dods/public/MONIT_DIR
+export DODS_MONIT=/ccc/work/cont003/dods/public/DODS_MONIT
+
+testr=`LC_ALL=C date +"%Y%m%dT%H%M"`
+
+####### Boucle sur les USER (on doit etre connecte comme USER)
+echo "User" $USER
+
+mkdir -p $MONIT_DIR/${USER}_SIMUS
+
+# On lance le script qui donne l etat du traitement des donnees
+./showPackProgress.sh -p
+
+if [ -e ${MONIT_DIR}/monit_all_new.txt ]
+then
+    tail -1 ${MONIT_DIR}/monit_${USER}.txt >> ${MONIT_DIR}/monit_all_new.txt
+else
+    cp monit_header.txt ${MONIT_DIR}/monit_all_new.txt
+    tail -1 ${MONIT_DIR}/monit_${USER}.txt >> ${MONIT_DIR}/monit_all_new.txt
+fi
+
+####### fin boucle sur les USER
+
+datestr=`LC_ALL=C date +"%Y%m%dT%H%M"`
+cp ${MONIT_DIR}/monit_all_new.txt ${MONIT_DIR}/monit_all_${datestr}.txt
+mv ${MONIT_DIR}/monit_all_new.txt ${MONIT_DIR}/monit_all.txt 
+
+#if [ -d ${MONIT_DIR}/${USER}_SIMUS ]
+#then
+#    rm -rf ${MONIT_DIR}/${USER}_SIMUS
+#fi
+#cp -rf ${USER}_SIMUS ${MONIT_DIR}/.
+
+#if [ "x$DODS_MONIT" != "x" ]
+#then
+#    rm -rf $DODS_MONIT
+#fi
+cp -prf $MONIT_DIR/* ${DODS_MONIT}/.
+chmod -R o+rX ${DODS_MONIT}
Index: TOOLS/SURPACK_IPSL/number_of_files.sh
===================================================================
--- TOOLS/SURPACK_IPSL/number_of_files.sh	(revision 2136)
+++ TOOLS/SURPACK_IPSL/number_of_files.sh	(revision 2136)
@@ -0,0 +1,34 @@
+#!/bin/bash
+# Script to evaluate nb of inodes which will be created on store and work
+
+NB1=0; NB2=0; SOMME=0; RESULTAT=0;
+
+# nb de listes dans output_ncrcat output_tar debug_tar restart_tar
+NB1=$( find $TMP_MIGR_DATA/IGCM_DEM -type f -name "*.list" | wc -l )
+# nb de fichiers dans les listes store_cp
+find $TMP_MIGR_DATA/IGCM_DEM -type f -name "*.list" | grep "store_cp" > tmp.$$
+for list in `cat tmp.$$` ; do
+for dir in `cat $list` ; do
+NB2=$( find $dir | wc -l )
+(( SOMME = SOMME + NB2 ))
+done
+done
+# somme des 2
+(( RESULTAT = NB1 + SOMME ))
+echo store
+echo $RESULTAT
+rm -f tmp.$$
+
+# nb de fichiers dans les listes work_cp 
+NB2=0; SOMME=0; RESULTAT=0;
+find $TMP_MIGR_DATA/IGCM_DEM -type f -name "*.list" | grep "work_cp" > tmp.$$
+for list in `cat tmp.$$` ; do
+for dir in `cat $list` ; do
+NB2=$( find $dir | wc -l )
+(( SOMME = SOMME + NB2 ))
+done
+done
+echo work
+echo $SOMME
+rm -f tmp.$$
+
Index: TOOLS/SURPACK_IPSL/parallelPack.sh
===================================================================
--- TOOLS/SURPACK_IPSL/parallelPack.sh	(revision 2136)
+++ TOOLS/SURPACK_IPSL/parallelPack.sh	(revision 2136)
@@ -0,0 +1,323 @@
+#!/bin/bash
+
+function insertDirectives
+{
+    
+    local batchFile="${TMP_MIGR_DATA}/launch_and_measureTime.sh"
+    local lineBeginMutableDrves=`grep -n "batch directives : begin" $batchFile | awk -F":" '{print $1}' `
+    local lineHeaderMutableDrves=`grep -n "mutable directives" $batchFile | awk -F":" '{print $1}' `
+    local lineEndMutableDrves=`grep -n "batch directives : end" $batchFile | awk -F":" '{print $1}' `
+    if [ "x${lineBeginMutableDrves}" == "x" ] || [ "x${lineHeaderMutableDrves}" == "x" ] || [ "x${lineEndMutableDrves}" == "x" ]
+    then
+        echo "Examen du fichier $batchFile :"
+	echo "Il manque les balises commentees 'mutable directives' et 'batch directives : end' "
+        exit 1
+    fi
+    
+    # echo "lineHeaderMutableDrves=$lineHeaderMutableDrves"
+    # echo "lineEndMutableDrves=$lineEndMutableDrves"
+    
+    if [ $lineHeaderMutableDrves -ge $lineEndMutableDrves ]
+    then
+       echo "Examen du fichier $batchFile :"
+       echo "les lignes 'mutable directives' et 'batch directives : end' n'existent pas ou ne sont"
+       echo "pas bien placees l'une par rapport a l'autre ==> STOP."
+       exit 1
+    fi
+    
+    # Suppression des anciennes directives
+    local firstLineToMove=$(( $lineHeaderMutableDrves + 1 ))
+    local lastLineToMove=$(( $lineEndMutableDrves - 1 ))
+    if [ $firstLineToMove -lt $lineEndMutableDrves ]
+    then
+        sed -i "${firstLineToMove},${lastLineToMove}d" $batchFile
+    fi
+        
+    # insertion des directives chargees a partir de "load_batch_directives.sh"
+    local lineEndMutableDrves=`grep -n "batch directives : end" $batchFile | awk -F":" '{print $1}' `
+    sed -i "${lineEndMutableDrves}i\#MSUB -Q $QosType" $batchFile
+    sed -i "${lineEndMutableDrves}i\#MSUB -q $queueType" $batchFile
+    sed -i "${lineEndMutableDrves}i\#MSUB -A $projectName" $batchFile
+    sed -i "${lineEndMutableDrves}i\#MSUB -T $computationTime" $batchFile
+    sed -i "${lineEndMutableDrves}i\#MSUB -x" $batchFile
+    sed -i "${lineEndMutableDrves}i\#MSUB -c $corePerProc" $batchFile 
+    sed -i "${lineEndMutableDrves}i\#MSUB -n $nbProcs" $batchFile
+    
+    # insertion des directives specifiant les sorties des operations de pack
+    sed -i "${lineEndMutableDrves}i\#MSUB -e ${DETAILLED_OUTPUT}/pack_ipsl_%I.e" $batchFile
+    sed -i "${lineEndMutableDrves}i\#MSUB -o ${DETAILLED_OUTPUT}/pack_ipsl_%I.o" $batchFile
+
+}
+
+function check_machine
+{
+    local host_name=`hostname `
+    local isMachineTitane=`echo $host_name | grep "titane" | wc -l `
+    local isMachineCurie=`echo $host_name | grep "curie" | wc -l `
+    
+    if [ "x${isMachineTitane}" == "x0" ] && [ "x${isMachineCurie}" == "x0" ]
+    then
+        echo "Ce programme doit etre lance a partir 'curie' ou 'titane'. STOP."
+	exit 1
+    fi
+
+}
+
+function check_glost_launch
+{
+    local file_exec='glost_launch'
+    if [ ! -e $file_exec ]
+    then
+	echo "Il n'y a pas l'executable glost_launch."
+	echo "Vous devez compiler l'outil via make. "
+	exit 1
+    fi
+}
+
+function checkParameters
+{
+    isCheckVarOK=`echo $doYouWantCheck | grep -E '^(yes|no)$' | wc -l `
+    if [ "x${isCheckVarOK}" == "x0" ]
+    then
+        echo "La variable 'doYouWantCheck' doit etre yes ou no"
+	exit 1
+    fi
+    
+    isRestartVarOK=`echo $forceRestartFromBegin | grep -E '^(yes|no)$' | wc -l `
+    if [ "x${isRestartVarOK}" == "x0" ]
+    then
+        echo "La variable 'forceRestartFromBegin' doit etre yes ou no"
+	exit 1
+    fi
+}
+
+
+function getNumeroOfPreviousTry
+{
+   local num_try="0"
+   ici=$PWD
+   cd $USER_OUTPUT_PROGRESS
+   
+   tryDirs=`ls | grep -e 'TRY__[[:digit:]]\{1,2\}$' `
+   for dir in $tryDirs
+   do
+      num=`echo $dir | awk -F"__" '{print $NF}' `
+      if [ $num -gt $num_try ]
+      then
+          num_try=$num 
+      fi
+   done  
+   cd $ici
+   echo $num_try
+   
+}
+
+# indique si l'on recommence les traitement depuis le debut ou non 
+restartExecFromZero=0
+
+# indique si l'on veut effacer les fichiers d'entrée ou non
+deleteFiles=0
+
+# On charge les variables d'environnement 
+. load_ipslPack_env.sh
+
+# On charge les directives batch
+. load_batch_directives.sh
+
+# On charge les parametres
+. loadParameters.sh
+
+checkParameters
+
+if [ "x${forceRestartFromBegin}" == "xyes" ]
+then
+     restartExecFromZero=1
+fi
+
+
+# on verifie que la machine est 'curie' ou 'titane'
+check_machine
+
+
+
+# on verifie que l outil glost a bien ete compile
+check_glost_launch
+
+
+########  pour option -f #############
+while [ $# -gt 0 ]
+do
+   echo "boucle sur les arguments du script ..."
+   echo "@=$@"
+   case $1 in
+   -f)  restartExecFromZero=1 
+        echo "force restart from the beginning ..."
+	;;
+   -d)  deleteFiles=1
+	echo "force to delete input files ..."
+	;;
+   -h|--help|-help)
+        echo "---------------------------------------------------"
+        echo "Usage: parallelPack.sh [-f]"
+	echo "Description:"
+	echo "   Launches the simultaneous treatments (ncrcat, tar, cap) of"
+	echo "   file lists contained in the IGCM_DEM directory."
+	echo "   In case of machine crash, this script handle restarts from the point"
+	echo "   the machine crashed."
+	echo
+	echo "Options:"
+	echo "   -h, --help, -help"
+	echo "        Print this manual"
+	echo "   -f"
+	echo "        Force to restart the treatments from the beginning"
+	echo "   -d"
+	echo "       force to delete input files ... "
+	echo "---------------------------------------------------"
+	exit
+        ;;
+   esac
+   shift
+done
+
+# copie du fichier launch_and_measureTime.sh sur ${TMP_MIGR_DATA}
+cp launch_and_measureTime.sh ${TMP_MIGR_DATA}/.
+
+export restartExecFromZero=${restartExecFromZero}
+export deleteFiles=${deleteFiles}
+######################################
+
+#########  On insert les directives batch en en-tete du script "launch_and_measureTime.sh"         ##########
+#########  lance plus loin. Seules les directives de nom du job et de sorties restent inchangees   ##########
+
+insertDirectives
+
+# exit 0 # gpdebug : a virer
+
+# export inputCmd="${USER_OUTPUT_PROGRESS}/inputCmd.list"
+# export nextInputCmd="${USER_OUTPUT_PROGRESS}/nextInputCmd.list"
+# export output="${USER_OUTPUT_PROGRESS}/packOutput.log"
+# export reportFile="${USER_OUTPUT_PROGRESS}/report.log"
+
+########## Si l'option -f est activee, on detruit tous les fichiers status  ##########
+if [ "x$restartExecFromZero" == "x1" ]
+then
+    echo "Deleting  all status files ..."
+    for CONFIG in $( awk '{print $1}' ${IGCM_DEM}/config_card.liste )
+    do
+       PATH_SIMU=$( dirname $CONFIG )
+       ListStatFileInSimu=`find $PATH_SIMU -type f -name "*status" `
+       if [ "x$ListStatFileInSimu" != "x" ]
+       then
+           for file in $ListStatFileInSimu
+           do
+              if [ -e $file ]
+	      then
+	         rm -f $file
+	      fi
+       
+           done      
+       fi   
+    done
+    echo "Deletion done."
+fi
+
+
+# Par ailleurs, on vide les fichiers de cmds, d'output et de rapport si option -f activee
+if [ "x${restartExecFromZero}" == "x1" ]
+then
+    rm -rf ${USER_OUTPUT_PROGRESS}/TRY__*
+fi
+
+# exit 0 # a virer
+
+#####################################################################################
+
+export JOB_DIR=${TMP_MIGR_DATA}
+export EXE_DIR=${LS_SUBCWD:-${PWD}}
+source ${EXE_DIR}/DEM_utilities.sh
+
+############## gpdebug : Pour gestion des erreurs ######################################### 
+# Execute la function errorReceive() si reception d'un signal TERM
+trap 'DEM_errorReceive' TERM
+# liste des processus à détruire en cas d'erreur bloquante
+export listPID=$$
+# fichier pour la transmission des messages d'erreur d'un fils au prog principal
+export errorMsgFile="${TMP_MIGR_DATA}/errorMsg.txt"
+############## gpdebug : fin ##############################################################
+
+check_nco_version # verification de la version de nco #######################
+check_libccc_user # verif que le module libccc_user est charge ##############
+check_cdo         # verif que le module cdo est charge ######################
+
+# exit 0 # a virer
+
+export badFailureFile=${USER_OUTPUT_PROGRESS}/badFailure.txt
+> $badFailureFile # nouvel essai, on vide le fichier d'erreur
+tryNumFile=${USER_OUTPUT_PROGRESS}/numero_current_try.txt
+numPreviousTry=$( getNumeroOfPreviousTry )
+# echo "numPreviousTry=$numPreviousTry"
+numNewTry=$(( $numPreviousTry + 1 ))
+
+
+# Pas de 4eme essai permis
+# ---------------------------- 
+if [ $numNewTry -ge $maxtry ]
+then
+    echo "Pas de $maxtry eme essai permis"
+    exit 1
+fi
+
+# echo "numNewTry=$numNewTry"
+mkdir -p ${USER_OUTPUT_PROGRESS}/TRY__${numNewTry}
+echo $numNewTry > $tryNumFile
+
+# exit 0 # a virer
+
+
+
+export timeLaunchStartFile="${USER_OUTPUT_PROGRESS}/timeLaunchStartFile.txt"
+> $timeLaunchStartFile
+startTime=$( getDateMilliSeconds )
+echo "launch time:$startTime" > $timeLaunchStartFile
+
+export timeEndFile="${USER_OUTPUT_PROGRESS}/timeEndFile.txt"
+> $timeEndFile
+
+SCRIPT_NAME=$(basename ${0} )
+
+DEM_log -0 "Demarrage de ${SCRIPT_NAME}"
+
+# ccc_msub -A tgcc0013 launch_and_measureTime.sh
+ccc_msub ${TMP_MIGR_DATA}/launch_and_measureTime.sh
+
+if [ $? -ne 0 ]
+then
+    echo "Errreur : le job batch ${TMP_MIGR_DATA}/launch_and_measureTime.sh n a pas pu etre soumis correctement !"
+    echo "Verifier les parametres batch de votre job "
+    exit 1
+fi
+
+tpsAvantRendreLaMain=15
+
+elapsedTime=0
+while [ $elapsedTime -lt $tpsAvantRendreLaMain ]
+do
+    sleep 5
+    elapsedTime=$(( $elapsedTime + 5 ))
+    isFailureFileEmpty=`cat $badFailureFile | wc -l `
+    if [ "x${isFailureFileEmpty}" != "x0" ]
+    then
+       sleep 2 # on attend que le fichier soit correctement rempli
+       cat $badFailureFile
+       exit 0
+    fi
+done
+
+if [ ${elapsedTime} -ge $tpsAvantRendreLaMain ]
+then
+    echo "Les $tpsAvantRendreLaMain sec sont ecoulees, les traitements continuent..."
+fi
+
+
+DEM_log -0 "Fin de ${SCRIPT_NAME}"
+
Index: TOOLS/SURPACK_IPSL/process_list.sh
===================================================================
--- TOOLS/SURPACK_IPSL/process_list.sh	(revision 2136)
+++ TOOLS/SURPACK_IPSL/process_list.sh	(revision 2136)
@@ -0,0 +1,703 @@
+#!/bin/bash
+
+
+listToProcessFile="${1}"
+
+
+
+switchtotar=0 # gpdebug : a modifier --> s'occuper des options du script orig enlarge.sh
+maxtries=2
+
+# On renseigne les variables d'environnement 
+. load_ipslPack_env.sh
+
+dirin=$INPUT_DMF_DATA
+dirout=$OUTPUT_STORE
+dirout_work=$OUTPUT_WORK
+
+export JOB_DIR=${TMP_MIGR_DATA}
+export EXE_DIR=${LS_SUBCWD:-${PWD}}
+
+source ${EXE_DIR}/DEM_utilities.sh
+#------------------------------------------------------
+
+baseNameOfListFile=$( basename $listToProcessFile )
+dirPathOfListFile=$( dirname  $listToProcessFile )
+dirnameOfListFile=$( basename $dirPathOfListFile )
+
+echo "dirnameOfListFile ==> $dirnameOfListFile"
+
+
+if ( \
+     [ $dirnameOfListFile != "output_ncrcat" ] && \
+     [ $dirnameOfListFile != "output_tar" ]    && \
+     [ $dirnameOfListFile != "restart_tar" ]   && \
+     [ $dirnameOfListFile != "store_cp" ]      && \
+     [ $dirnameOfListFile != "work_cp" ]       && \
+     [ $dirnameOfListFile != "debug_tar" ]     && \
+     [ $dirnameOfListFile != "other_tar" ] \
+   ) \
+   && \
+   [ $baseNameOfListFile != "tar_full_simul.list" ]
+then
+        echo "probleme : le rep du fichier liste est mauvais." # gpdebug : a modifier
+        exit 1
+fi
+
+
+function find_varstoexclude {
+nbfile=0
+for file in `cat $1` ; do
+ #   ncdump -h ${file} | gawk '{if (match($0, /(byte|char|short|int|float|double) (.*)\(/, arr)) print arr[2] }' >> tmp_$$.txt
+    ncdump -h ${file} | grep -Ew "byte|char|short|int|float|double"  | awk -F\( '{split($1,a," ") ; split($2,b,")") ; if (a[2] != b[1]) print a[2]}'  >> ${JOB_DIR}/tmp_$$.txt
+    let nbfile=nbfile+1
+done
+
+varstoexclude=`cat ${JOB_DIR}/tmp_$$.txt | sort | uniq -c | awk -v nbfile=$nbfile '{if ($1 != nbfile) {print $2}}' | paste -s -d','`
+varstoexcludefiltered=`cat ${JOB_DIR}/tmp_$$.txt | sort | uniq -c | awk -v nbfile=$nbfile '{if (($1 != nbfile) && !(match($2, /t_inst_(.*)/))) {print $2}}' | paste -s -d','`
+nbvars=`echo $varstoexcludefiltered | gawk -F',' '{print NF}'`
+
+rm -f tmp_$$.txt
+
+return 0 
+}
+
+# gpdebug : pour test showPackProgress.sh *************************
+export RANDOM=$$
+
+function gives_0_or_1
+{
+   bit=-1
+   let "bit = RANDOM % 2"
+   echo $bit
+}
+
+resultCmd=
+# gpdebug : ****************************** fin ********************
+
+
+
+
+# rep de simu : celui contenant le rep qui contient la liste
+PATH_SIMU=$( dirname  $dirPathOfListFile )
+set=$listToProcessFile
+
+
+if [ "$dirnameOfListFile" == "output_ncrcat" ]
+then
+	#-----------------------------------
+	echo "#-------------------"
+	echo "Set: $set"
+        datestr=`LC_ALL=C date +"%Y%m%dT%H%M%S"`
+	datestr1=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+	statusfile=${set%%.list}.status
+	logfile=${set%%.list}_${datestr}.log
+	
+	# echo "output_ncrcat : blabla 0"
+	
+	#-----------------------------------
+	# Create status file if not exists
+	if [ ! -e $statusfile ] ; then
+		echo "# Status ; DateStart ; DateEnd ; Command ; TarFileExists" > $statusfile
+	fi
+        
+	# Switch to tar command
+	if [ $switchtotar -eq 1 ] ; then
+		echo "====> DELEGATE to tar command with option --switchtotar"
+		echo "DELEGATE to tar command with option --switchtotar" >> $statusfile
+		mkdir -p $PATH_SIMU/output_tar
+		mv $set $PATH_SIMU/output_tar
+		exit 5
+	fi
+	
+	# # Skip the set if last line of the status file is "DELEGATE"
+	# if tail -1 $statusfile | grep -q -E 'DELEGATE' ; then
+	# 	printf "====> "
+	# 	tail -1 $statusfile
+	# 	exit 50
+	# fi
+	
+	# Skip the set if last line of the status file is "COMPLETED"
+	if tail -1 $statusfile | grep -q -E '(COMPLETED|DELEGATE)' ; then
+		printf "====> "
+		tail -1 $statusfile
+		exit 0
+	fi	
+
+	#-----------------------------------
+	# nbtries = number of lines from status file (first comment line gives 1 for the first try)
+	nbtries=`wc -l $statusfile | cut -d' ' -f1`		
+	echo "Nb of tries: $nbtries"
+
+	#-----------------------------------
+	# Set output file name from list name
+
+ 	fileout1=$( basename $set )
+ 	fileout=${fileout1%.list}
+
+	filefirst=`head -n 1 $set`
+	diroutputfile=`dirname $filefirst | sed -e "s%$dirin%$dirout%"`
+
+	outputfile=$diroutputfile/${fileout}
+	mkdir -p $diroutputfile
+	echo "Output file to write: $outputfile  output_ncrcat"
+
+	#-----------------------------------
+	# Find variables to exclude to have homogeneous files (always exclude 't_inst_.*')
+	extratar=0
+	find_varstoexclude $set
+	if [ $nbvars -eq 0 ] ; then
+		varstoexclude="t_inst_.*"
+	else
+		# There are others variables than 't_inst_.*' so an extra tar file will be created
+		varstoexclude="t_inst_.*,$varstoexcludefiltered"
+		extratar=1
+		# Copy to output_tar directory
+		echo "====> COPY to tar command because find other variables ($varstoexcludefiltered) than t_inst_*"
+#		echo "COPY to tar command because find other variables ($varstoexcludefiltered) than t_inst_*" >> $statusfile
+		mkdir -p $PATH_SIMU/output_tar
+		cp $set $PATH_SIMU/output_tar
+		
+	fi
+
+	#-----------------------------------
+	# Try 2 times before fire "FAILED"
+	ncrcatcmd=ncrcat
+	ncrcatoptions="--md5_digest"
+#	ncrcatoptions=""
+
+	startTime=$( getDateMilliSeconds ) # gpdebug : time
+	resCmd=0
+	cat $set | $ncrcatcmd $ncrcatoptions -O -x -v $varstoexclude -o $outputfile > $logfile 2>&1 # gpdebug : a retablir
+	resCmd=$?
+	meantime=$( getTimeDiffSeconds $startTime ) # gpdebug : time
+	
+	# resultCmd=$( gives_0_or_1 )
+	# resultCmd=1
+	# if [ $resultCmd -eq 0 ] ; then
+	if [ $resCmd -eq 0 ] ; then
+	        sed -i "1i\meantime:${meantime}" $statusfile # gpdebug : time
+		datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+		echo "DONE ; $datestr1 ; $datestr2 ; cat $set | $ncrcatcmd $ncrcatoptions -O -x -v '$varstoexclude' -o $outputfile ; $logfile ; $extratar" >> $statusfile
+		echo "====> COMPLETED at try #$nbtries (at 1st shot on 2)"
+		echo "COMPLETED at try #$nbtries (at 1st shot on 2)" >> $statusfile
+		# exit 10 : il faut tarer cette liste dans "output_tar" et tenter de la concatener a nouveau
+			# exit 5 : seulement la tarer dans "output_tar"
+		if [ "x${extratar}" == "x1" ]
+		then
+		    exit 5
+		fi
+	else
+		# Add --md5_digest
+		rm -f $outputfile*ncrcat.tmp
+		startTime=$( getDateMilliSeconds ) # gpdebug : time
+		resCmd=0
+		cat $set | $ncrcatcmd $ncrcatoptions -O -x -v $varstoexclude -o $outputfile > $logfile 2>&1 # gpdebug : a retablir
+		resCmd=$?
+		meantime=$( getTimeDiffSeconds $startTime ) # gpdebug : time
+	        # resultCmd=$( gives_0_or_1 )
+		# resultCmd=1
+	        # if [ $resultCmd -eq 0 ] ; then
+		if [ $resCmd -eq 0 ] ; then
+		        sed -i "1i\meantime:${meantime}" $statusfile # gpdebug : time
+			datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+			echo "DONE ; $datestr1 ; $datestr2 ; cat $set | $ncrcatcmd $ncrcatoptions -O -x -v '$varstoexclude' -o $outputfile ; $logfile ; $extratar" >> $statusfile
+			echo "====> COMPLETED at try #$nbtries (at 2nd shot on 2)"
+			echo "COMPLETED at try #$nbtries (at 2nd shot on 2)" >> $statusfile
+			if [ "x${extratar}" == "x1" ]
+			then
+			    exit 5
+			fi
+		else
+			datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+			rm -f $outputfile*ncrcat.tmp
+			echo "====> FAILED at try #$nbtries" 
+			echo "FAILED at try #$nbtries ; $datestr1 ; $datestr2 ; cat $set | $ncrcatcmd $ncrcatoptions -O -x -v '$varstoexclude' -o $outputfile ; $logfile ; $extratar" >> $statusfile
+			if [ $nbtries -ge $maxtries ] ; then
+				echo "====> DELEGATE to tar command after $nbtries tries (maxtries=$maxtries)"
+				echo "DELEGATE to tar command after $nbtries tries (maxtries=$maxtries)" >> $statusfile
+				mkdir -p $PATH_SIMU/output_tar
+				cp $set $PATH_SIMU/output_tar # gpdebug : a retablir
+				exit 5
+			fi
+			
+			# exit 10 : il faut tarer cette liste dans "output_tar" et tenter de la concatener a nouveau
+			# exit 5 : seulement la tarer dans "output_tar"
+			if [ "x${extratar}" == "x1" ]
+			then
+			    exit 10
+			else
+			    exit 1
+			fi
+		fi
+	fi
+
+
+
+fi
+
+
+#------------------------------------------------------
+if [ "$dirnameOfListFile" == "output_tar" ]
+then
+
+	#-----------------------------------
+	echo "#-------------------"
+	echo "Set: $set"
+        datestr=`LC_ALL=C date +"%Y%m%dT%H%M%S"`
+	datestr1=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+	statusfile=${set%%.list}.status
+	logfile=${set%%.list}_${datestr}.log
+
+	#-----------------------------------
+	# Create status file if not exists
+	if [ ! -e $statusfile ] ; then
+		echo "# Status ; DateStart ; DateEnd ; Command ; TarFileExists" > $statusfile
+	fi
+
+	#-----------------------------------
+	# Skip the set if last line of the status file is "COMPLETED" or "DELEGATE"
+	if tail -1 $statusfile | grep -q -E '(COMPLETED)' ; then
+		printf "====> "
+		tail -1 $statusfile	
+	fi
+
+	#-----------------------------------
+	# nbtries = number of lines from status file (first comment line gives 1 for the first try)
+	nbtries=`wc -l $statusfile | cut -d' ' -f1`		
+	# echo "Nb of tries: $nbtries"
+
+	#-----------------------------------
+	# Set output file name from list name
+
+ 	fileout1=$( basename $set )
+ 	fileout=${fileout1%.list}.tar
+	
+	filefirst=`head -n 1 $set`
+	dirinputfile=`dirname $filefirst`
+	diroutputfile=`dirname $filefirst | sed -e "s%$dirin%$dirout%"`	
+
+	outputfile=$diroutputfile/${fileout}
+	mkdir -p $diroutputfile
+	echo "Output file to write: $outputfile  output_tar"
+
+	#-----------------------------------
+	# Try 1 time before fire "FAILED"
+	# Waiting for CCRT command
+	tarcmd=tar
+	taroptions="--format=posix -W -cf"
+	
+	cd $dirinputfile
+
+	set_local=$set".local"
+	for file in $( cat $set) ; do
+	    basename $file >> $set".local" 
+	done
+	    
+# 	#-----------------------------------
+        startTime=$( getDateMilliSeconds ) # gpdebug : time
+	resCmd=0
+	$tarcmd $taroptions $outputfile --dereference --files-from $set.local > $logfile 2>&1 # gpdebug : a retablir
+	resCmd=$?
+	meantime=$( getTimeDiffSeconds $startTime ) # gpdebug : time
+	
+	# resultCmd=$( gives_0_or_1 )
+	# if [ $resultCmd -eq 0 ] ; then
+	if [ $resCmd -eq 0 ] ; then
+	    sed -i "1i\meantime:${meantime}" $statusfile # gpdebug : time
+	    datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+	    echo "DONE ; $datestr1 ; $datestr2 ; $tarcmd $taroptions $outputfile $(cat $set); $logfile" >> $statusfile
+	    echo "====> COMPLETED at try #$nbtries (at 1st shot on 1)"
+	    echo "COMPLETED at try #$nbtries (at 1st shot on 1)" >> $statusfile
+	else
+	    datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+	    echo "====> FAILED at try #$nbtries" 
+	    echo "FAILED at try #$nbtries ; $datestr1 ; $datestr2 ; $tarcmd $taroptions $outputfile $(cat $set) ; $logfile" >> $statusfile
+            exit 50
+	fi
+	rm -f $set".local" 
+	#-----------------------------------
+	
+fi
+
+
+#------------------------------------------------------
+if [ "$dirnameOfListFile" == "restart_tar" ]
+then
+	#-----------------------------------
+	echo "#-------------------"
+	echo "Set: $set"
+        datestr=`LC_ALL=C date +"%Y%m%dT%H%M%S"`
+	datestr1=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+	statusfile=${set%%.list}.status
+	logfile=${set%%.list}_${datestr}.log
+
+	#-----------------------------------
+	# Create status file if not exists
+	if [ ! -e $statusfile ] ; then
+		echo "# Status ; DateStart ; DateEnd ; Command ; TarFileExists" > $statusfile
+	fi
+
+	#-----------------------------------
+	# Skip the set if last line of the status file is "COMPLETED" or "DELEGATE"
+	if tail -1 $statusfile | grep -q -E '(COMPLETED)' ; then
+		printf "====> "
+		tail -1 $statusfile
+		exit 0
+	fi
+
+	#-----------------------------------
+	# nbtries = number of lines from status file (first comment line gives 1 for the first try)
+	nbtries=`wc -l $statusfile | cut -d' ' -f1`		
+	# echo "Nb of tries: $nbtries"
+
+	#-----------------------------------
+	# Set output file name from list name
+	dirin1=$PATH_SIMU/RESTART
+	dirin2=${dirin1##${IGCM_DEM}}
+	dirin3=${dirin2##/$( basename ${INPUT_DMF_DATA} )}
+	diroutputfile=${OUTPUT_STORE}${dirin3}
+ 	fileout1=$( basename $set )
+ 	fileout=${fileout1%.list}.tar
+	outputfile=$diroutputfile/${fileout}
+	mkdir -p $diroutputfile
+	echo "Output file to write: $outputfile  restart_tar"
+
+	#-----------------------------------
+	# Try 1 time before fire "FAILED"
+	# Waiting for CCRT command
+	tarcmd=tar
+	taroptions="--format=posix -W -cf"
+	
+	cd $dirin1
+#	ls
+	
+	startTime=$( getDateMilliSeconds ) # gpdebug : time
+	resCmd=0
+	$tarcmd $taroptions $outputfile --dereference --files-from $set > $logfile 2>&1 # gpdebug : a retablir
+	resCmd=$?
+	meantime=$( getTimeDiffSeconds $startTime ) # gpdebug : time
+	
+	# resultCmd=$( gives_0_or_1 )
+	# if [ $resultCmd -eq 0 ] ; then
+	if [ $resCmd -eq 0 ] ; then
+	    sed -i "1i\meantime:${meantime}" $statusfile # gpdebug : time
+	    datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+	    echo "DONE ; $datestr1 ; $datestr2 ; $tarcmd $taroptions $outputfile $(cat $set); $logfile" >> $statusfile
+	    echo "====> COMPLETED at try #$nbtries (at 1st shot on 1)"
+	    echo "COMPLETED at try #$nbtries (at 1st shot on 1)" >> $statusfile
+	else
+	    datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+	    echo "====> FAILED at try #$nbtries" 
+	    echo "FAILED at try #$nbtries ; $datestr1 ; $datestr2 ; $tarcmd $taroptions $outputfile $(cat $set) ; $logfile" >> $statusfile
+            exit 50
+	fi
+	
+	#-----------------------------------
+	
+fi	
+
+#------------------------------------------------------
+if [ "$dirnameOfListFile" == "debug_tar" ]
+then
+
+	#-----------------------------------
+	echo "#-------------------"
+	echo "Set: $set"
+        datestr=`LC_ALL=C date +"%Y%m%dT%H%M%S"`
+	datestr1=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+	statusfile=${set%%.list}.status
+	logfile=${set%%.list}_${datestr}.log
+
+	#-----------------------------------
+	# Create status file if not exists
+	if [ ! -e $statusfile ] ; then
+		echo "# Status ; DateStart ; DateEnd ; Command ; TarFileExists" > $statusfile
+	fi
+
+	#-----------------------------------
+	# Skip the set if last line of the status file is "COMPLETED" or "DELEGATE"
+	if tail -1 $statusfile | grep -q -E '(COMPLETED)' ; then
+		printf "====> "
+		tail -1 $statusfile
+		exit 0
+	fi
+
+	#-----------------------------------
+	# nbtries = number of lines from status file (first comment line gives 1 for the first try)
+	nbtries=`wc -l $statusfile | cut -d' ' -f1`		
+	# echo "Nb of tries: $nbtries"
+
+	#-----------------------------------
+	# Set output file name from list name
+	dirin1=$PATH_SIMU/DEBUG
+	dirin2=${dirin1##${IGCM_DEM}}
+	dirin3=${dirin2##/$( basename ${INPUT_DMF_DATA} )}
+	diroutputfile=${OUTPUT_STORE}${dirin3}
+ 	fileout1=$( basename $set )
+ 	fileout=${fileout1%.list}.tar
+	outputfile=$diroutputfile/${fileout}
+	mkdir -p $diroutputfile
+	echo "Output file to write: $outputfile  debug_tar"
+
+	#-----------------------------------
+	# Try 1 time before fire "FAILED"
+	# Waiting for CCRT command
+	tarcmd=tar
+	taroptions="--format=posix -W -cf"
+	
+	cd $dirin1
+#	ls
+        resCmd=0
+	startTime=$( getDateMilliSeconds ) # gpdebug : time
+	$tarcmd $taroptions $outputfile --dereference --files-from $set > $logfile 2>&1 # gpdebug : a retablir
+	resCmd=$?
+	meantime=$( getTimeDiffSeconds $startTime ) # gpdebug : time
+	
+	# resultCmd=$( gives_0_or_1 )
+	# if [ $resultCmd -eq 0 ] ; then
+	if [ $resCmd -eq 0 ] ; then
+	    sed -i "1i\meantime:${meantime}" $statusfile # gpdebug : time
+	    datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+	    echo "DONE ; $datestr1 ; $datestr2 ; $tarcmd $taroptions $outputfile $(cat $set); $logfile" >> $statusfile
+	    echo "====> COMPLETED at try #$nbtries (at 1st shot on 1)"
+	    echo "COMPLETED at try #$nbtries (at 1st shot on 1)" >> $statusfile
+	else
+	    datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+	    echo "====> FAILED at try #$nbtries" 
+	    echo "FAILED at try #$nbtries ; $datestr1 ; $datestr2 ; $tarcmd $taroptions $outputfile $(cat $set) ; $logfile" >> $statusfile
+            exit 50
+	fi
+	
+	#-----------------------------------
+	
+fi
+
+#------------------------------------------------------
+if [ "$dirnameOfListFile" == "store_cp" ]
+then
+	#-----------------------------------
+	echo "#-------------------"
+	echo "Set: $set"
+        datestr=`LC_ALL=C date +"%Y%m%dT%H%M%S"`
+	datestr1=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+	statusfile=${set%%.list}.status
+	logfile=${set%%.list}_${datestr}.log
+
+	#-----------------------------------
+	# Create status file if not exists
+	if [ ! -e $statusfile ] ; then
+		echo "# Status ; DateStart ; DateEnd ; Command ; TarFileExists" > $statusfile
+	fi
+
+	#-----------------------------------
+	# Skip the set if last line of the status file is "COMPLETED" or "DELEGATE"
+	if tail -1 $statusfile | grep -q -E '(COMPLETED)' ; then
+		printf "====> "
+		tail -1 $statusfile
+		exit 0
+	fi
+
+	#-----------------------------------
+	# nbtries = number of lines from status file (first comment line gives 1 for the first try)
+	nbtries=`wc -l $statusfile | cut -d' ' -f1`		
+	# echo "Nb of tries: $nbtries"
+
+	meantime=0
+	resCmd=0
+	startTime=$( getDateMilliSeconds ) # gpdebug : time
+	#-----------------------------------
+	# Set output file name from first and last files from the current set
+	for file in $( cat $set) ; do
+	 
+	    diroutputfile=`dirname $file | sed -e "s%$dirin%$dirout%"`
+	    mkdir -p $diroutputfile
+	    echo "Output file to write: $diroutputfile/$( basename $file )  store_cp"
+	    
+	#-----------------------------------
+	# Try 1 time before fire "FAILED"
+	# Waiting for CCRT command
+	    cpcmd="cp "
+	    cpoptions="-rf"
+	    $cpcmd $cpoptions $file $diroutputfile > $logfile 2>&1 # gpdebug : a retablir
+	    resCmd=$(( $resCmd || $? ))
+	done
+	meantime=$( getTimeDiffSeconds $startTime ) # gpdebug : time
+	
+	# resultCmd=$( gives_0_or_1 )
+	# if [ $resultCmd -eq 0 ] ; then
+	if [ $resCmd -eq 0 ] ; then
+	    sed -i "1i\meantime:${meantime}" $statusfile # gpdebug : time
+	    datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+	    echo "DONE ; $datestr1 ; $datestr2 ; $cpcmd $cpoptions $file $diroutputfile ; $logfile" >> $statusfile
+	    echo "====> COMPLETED at try #$nbtries (at 1st shot on 1)"
+	    echo "COMPLETED at try #$nbtries (at 1st shot on 1)" >> $statusfile
+	else
+	    datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+	    echo "====> FAILED at try #$nbtries" 
+	    echo "FAILED at try #$nbtries ; $datestr1 ; $datestr2 ; $cpcmd $cpoptions $file $diroutputfile ; $logfile" >> $statusfile
+            exit 50
+	fi
+	
+	#-----------------------------------
+	
+fi	
+
+#------------------------------------------------------
+if [ "$dirnameOfListFile" == "work_cp" ]
+then
+	#-----------------------------------
+	echo "#-------------------"
+	echo "Set: $set"
+        datestr=`LC_ALL=C date +"%Y%m%dT%H%M%S"`
+	datestr1=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+	statusfile=${set%%.list}.status
+	logfile=${set%%.list}_${datestr}.log
+
+	#-----------------------------------
+	# Create status file if not exists
+	if [ ! -e $statusfile ] ; then
+		echo "# Status ; DateStart ; DateEnd ; Command ; TarFileExists" > $statusfile
+	fi
+
+	#-----------------------------------
+	# Skip the set if last line of the status file is "COMPLETED" or "DELEGATE"
+	if tail -1 $statusfile | grep -q -E '(COMPLETED)' ; then
+		printf "====> "
+		tail -1 $statusfile
+		exit 0
+	fi
+
+	#-----------------------------------
+	# nbtries = number of lines from status file (first comment line gives 1 for the first try)
+	nbtries=`wc -l $statusfile | cut -d' ' -f1`		
+	# echo "Nb of tries: $nbtries"
+
+	meantime=0
+	resCmd=0
+	startTime=$( getDateMilliSeconds ) # gpdebug : time
+	#-----------------------------------
+	# Set output file name from first and last files from the current set
+	for file in $( cat $set) ; do
+	 
+	    diroutputfile=`dirname $file | sed -e "s%$dirin%$dirout_work%"`
+	    mkdir -p $diroutputfile
+	    echo "Output file to write: $diroutputfile/$( basename $file )  work_cp"
+	    
+	#-----------------------------------
+	# Try 1 time before fire "FAILED"
+	# Waiting for CCRT command
+	    cpcmd="cp "
+	    cpoptions="-rf"
+	    $cpcmd $cpoptions $file $diroutputfile > $logfile 2>&1  # gpdebug : a retablir
+	    resCmd=$(( $resCmd || $? ))   
+	done
+	meantime=$( getTimeDiffSeconds $startTime ) # gpdebug : timeS
+	# resultCmd=$( gives_0_or_1 )
+	# if [ $resultCmd -eq 0 ] ; then
+	if [ $resCmd -eq 0 ] ; then
+	    sed -i "1i\meantime:${meantime}" $statusfile # gpdebug : time
+	    datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+	    echo "DONE ; $datestr1 ; $datestr2 ; $cpcmd $cpoptions $file $diroutputfile ; $logfile" >> $statusfile
+	    echo "====> COMPLETED at try #$nbtries (at 1st shot on 1)"
+	    echo "COMPLETED at try #$nbtries (at 1st shot on 1)" >> $statusfile
+	else
+	    datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+	    echo "====> FAILED at try #$nbtries" 
+	    echo "FAILED at try #$nbtries ; $datestr1 ; $datestr2 ; $cpcmd $cpoptions $file $diroutputfile ; $logfile" >> $statusfile
+            exit 50
+	fi
+	
+	#-----------------------------------
+	
+fi
+
+# gpdebug : traitement des simu < 1 Go ou de type create_etat0
+#           il n'est censé n'y avoir qu'un seul fichier tar_full_simul.list par simu.
+#           d'ou le "if" et non le "for"
+# pense bete :
+#    * implication dans showPackProgress.sh (fichier status) ?
+if [ "$baseNameOfListFile" == "tar_full_simul.list" ]
+then
+	# set="${PATH_SIMU}/tar_full_simul.list" # gpdebug : foireux ?
+	#-----------------------------------
+	echo "#-------------------"
+	echo "Set: $set"
+        datestr=`LC_ALL=C date +"%Y%m%dT%H%M%S"`
+	datestr1=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+	statusfile=${set%%.list}.status
+	logfile=${set%%.list}_${datestr}.log
+
+	#-----------------------------------
+	# Create status file if not exists
+	if [ ! -e $statusfile ] ; then
+		echo "# Status ; DateStart ; DateEnd ; Command ; TarFileExists" > $statusfile
+	fi
+
+	#-----------------------------------
+	# Skip the set if last line of the status file is "COMPLETED" or "DELEGATE"
+	if tail -1 $statusfile | grep -q -E '(COMPLETED)' ; then
+		printf "====> "
+		tail -1 $statusfile
+		exit 0
+	fi
+
+	#-----------------------------------
+	# Set output file name from list name
+	# echo "PATH_SIMU=$PATH_SIMU"
+	dirOfOutputFile=`echo $PATH_SIMU | sed "s;${IGCM_DEM};${OUTPUT_STORE};" `
+	fileout=${dirnameOfListFile}.tar
+	# echo "dirnameOfListFile=$dirnameOfListFile"
+	outputfile=$dirOfOutputFile/${fileout}
+	mkdir -p $dirOfOutputFile
+	echo "Output file to write: $outputfile  tar_full_simul"
+	
+	# exit 0 # a virer
+
+	#-----------------------------------
+	# Try 1 time before fire "FAILED"
+	# Waiting for CCRT command
+	tarcmd=tar
+	taroptions="--format=posix -W -cf"
+#	taroptions="--format=posix -cf"
+
+	filefirst=`head -n 1 $set`
+	dirinputfile=`dirname $filefirst`
+	cd $dirinputfile
+
+	set_local=${set%%.list}.local
+	> $set_local
+	for file in $( cat $set) ; do
+	    basename $file >> $set_local 
+	done
+#	ls
+	
+	startTime=$( getDateMilliSeconds ) # gpdebug : time
+	resCmd=0
+	$tarcmd $taroptions $outputfile --dereference --files-from $set_local > $logfile 2>&1 # gpdebug : a retablir
+	resCmd=$?
+	meantime=$( getTimeDiffSeconds $startTime ) # gpdebug : time
+	
+	# resultCmd=$( gives_0_or_1 )
+	# if [ $resultCmd -eq 0 ] ; then
+	if [ $resCmd -eq 0 ] ; then
+	    sed -i "1i\meantime:${meantime}" $statusfile # gpdebug : time
+	    datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+	    echo "DONE ; $datestr1 ; $datestr2 ; $tarcmd $taroptions $outputfile $(cat $set); $logfile" >> $statusfile
+	    echo "====> COMPLETED at try #$nbtries (at 1st shot on 1)"
+	    echo "COMPLETED at try #$nbtries (at 1st shot on 1)" >> $statusfile
+	else
+	    datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"`
+	    echo "====> FAILED at try #$nbtries" 
+	    echo "FAILED at try #$nbtries ; $datestr1 ; $datestr2 ; $tarcmd $taroptions $outputfile $(cat $set) ; $logfile" >> $statusfile
+	    exit 50
+	fi
+	
+	#-----------------------------------
+fi
+
+if [ "$dirnameOfListFile" == "other_tar" ]
+then
+exit 50
+fi
+
Index: TOOLS/SURPACK_IPSL/showListsProgress.sh
===================================================================
--- TOOLS/SURPACK_IPSL/showListsProgress.sh	(revision 2136)
+++ TOOLS/SURPACK_IPSL/showListsProgress.sh	(revision 2136)
@@ -0,0 +1,246 @@
+#!/bin/bash
+
+
+function waitingFor
+{
+   waitedFile=$1
+   
+   # verif que la variable MonitoringDir est bien define
+   if [ "x${MonitoringDir}" == "x" ] 
+   then
+      echo "variable MonitoringDir not defined. stop."
+      exit -1
+   fi
+   
+   # Le fichier teste doit etre dans le rep de suivi
+   isWaitedFileName_In_MonitoringDir=`echo $waitedFile | grep ${MonitoringDir} | wc -l `
+   if [ "x${isWaitedFileName_In_MonitoringDir}" == "x0" ]
+   then
+      echo "The waited file name :"
+      echo "$waitedFile"
+      echo "is incorrect. The location of the file must be in the monitoring dir."
+      exit -1
+   fi
+   
+   waitedFileBasename=$(basename ${waitedFile})
+   # echo "On verifie la presence de ${waitedFileBasename}..."
+   iter=0
+   found=0
+   while [ ${iter} -lt 60 ]
+   do
+      if [ -e $waitedFile ]
+      then
+         found=1
+         break
+      fi      
+      iter=$(( $iter + 1 ))
+      echo "waiting for ${waitedFileBasename}...${iter}..."
+      sleep 1
+   done
+   
+   if [ "x${found}" == "x0"  ]
+   then
+      echo "Le fichier ${waitedFileBasename} n'a pas ete trouve. stop."
+      exit -1
+   fi
+   
+   # echo "fichier trouve !"
+
+}
+
+
+#######################
+# Main program ########
+#######################
+. load_ipslPack_env.sh
+# fichier de progression d'execution
+# Le seul arg du script doit etre un fichier param
+# paramFile=${1}
+# paramFileBasename=$(basename ${1})
+
+# if [ ! -e $paramFile ] || [ "x${paramFile}" == "x" ]
+# then
+#     echo "Le fichier en argument n existe pas"
+#     exit 0
+# fi
+
+if [ ! -e ${1} ] || [ "x${1}" == "x" ]
+then
+    echo "Le fichier en argument n existe pas"
+    exit 0
+else
+    paramFile=${1}
+    paramFileBasename=$(basename ${1})
+fi
+
+
+extSuiviListes=`echo ${paramFileBasename} | sed 's;\.[[:alnum:]]*$;;' `
+export MonitoringDir="${TMP_MIGR_DATA}/SuiviListes_${extSuiviListes}"
+# echo "MonitoringDir=$MonitoringDir"
+export generalMonitorFile=${MonitoringDir}/general.txt
+export nbSimuFile=${MonitoringDir}/nbSimu.txt
+
+declare -a tabGeneralSteps=()
+tabGeneralSteps[0]="find_directory_simul.sh-->OK"
+tabGeneralSteps[1]="create_config_card.sh-->OK"
+
+declare -a tabSimuSteps=()
+tabSimuSteps[0]="calcul_size_simul.sh-->OK"
+tabSimuSteps[1]="find_size_pack.sh-->OK"
+tabSimuSteps[2]="write_liste_pack.sh-->OK"
+tabSimuSteps[3]="archive_restart.sh-->OK"
+tabSimuSteps[4]="archive_debug.sh-->OK"
+
+echo "#################################################"
+echo "###  ETAT D'AVANCEMENT DES SCRIPTS DE lISTES  ###"
+echo "#################################################"
+echo
+
+# Si le rep de suivi n'existe pas, stop.
+if [ ! -d ${MonitoringDir} ]
+then
+   echo "${MonitoringDir} n'existe pas. stop."
+   exit -1 
+fi
+
+cd ${MonitoringDir}
+if [ "x$?" != "x0" ]
+then
+  echo "Pb avec cd ${MonitoringDir}"
+  exit -1
+fi
+
+# Etapes generales
+# ----------------
+echo "--------------------------------------------------"
+echo "---------------- Etapes generales ----------------"
+echo "--------------------------------------------------"
+waitingFor "${generalMonitorFile}"
+
+
+generalStepsDoneList=`cat ${generalMonitorFile} `
+for ((i = 0; i < ${#tabGeneralSteps[*]}; i += 1))
+do
+  isEltInDoneList=`echo $generalStepsDoneList | grep "${tabGeneralSteps[$i]}" | wc -l `
+  if [ "x$isEltInDoneList" == "x0" ]
+  then
+     stringKO=`echo ${tabGeneralSteps[$i]} | sed 's;OK;?? #####;' `
+     echo "$stringKO"
+  else
+     echo "${tabGeneralSteps[$i]}"
+  fi
+  
+done
+
+
+# Etapes createListing
+# --------------------
+echo
+echo "--------------------------------------------------" 
+echo "---------------- Etape createListing -------------"
+echo "--------------------------------------------------" 
+listSubDir=`ls -l | grep -e '^d' | awk '{print $NF}' `
+# echo "listSubDir=$listSubDir"
+if [ "x$listSubDir" == "x" ]
+then
+   echo "Aucune liste n'est prete."
+fi
+
+# echo "listSubDir=$listSubDir"
+for rep in $listSubDir
+do
+   cd $rep
+   if [ ! -e createListingOK.txt ]
+   then
+      echo "${rep}: createListing.sh-->?? #####"
+   else
+      echo "${rep}: createListing.sh-->OK"
+   fi
+   
+   cd ..
+done
+echo
+
+echo "--------------------------------------------------" 
+echo "---------------  Etape par simu ------------------"
+echo "--------------------------------------------------"
+if [ "x$listSubDir" == "x" ]
+then
+   echo "Aucune simu n'a ete traitee."
+fi
+
+nbSimuOK=0
+for rep in $listSubDir
+do
+   cd $rep
+   listSimu=`ls -1 | grep -v "createListingOK.txt" `
+   if [ ! -e createListingOK.txt ] || [ "x${listSimu}" == "x" ]
+   then
+      echo "${rep}: Pas de simu traitee"
+   fi
+   # echo "listSimu=$listSimu"
+   for simu in $listSimu
+   do
+       simuDone=1
+       simuName=`echo $simu | sed 's;_#_;/;g' | sed 's;\.txt;;' `
+       
+       # Cas des simu speciales ( < 1 Go ou de type etat0 ) #############
+       isSpecialSimuOK=`cat ${simu} | grep "special simu==>OK" | wc -l `
+       if [ "x${isSpecialSimuOK}" != "x0" ]
+       then
+           echo "$simuName : special simulation ==> OK"
+	   nbSimuOK=$(( $nbSimuOK + 1 ))
+	   continue
+       fi
+       
+       
+       # Cas des simus normales
+       echo $simuName
+       simuStepsDoneList=`cat ${simu} `
+       for ((i = 0; i < ${#tabSimuSteps[*]}; i += 1))
+       do
+           isEltInDoneList=`echo $simuStepsDoneList | grep "${tabSimuSteps[$i]}" | wc -l `
+           if [ "x$isEltInDoneList" == "x0" ]
+           then
+              stringKO=`echo ${tabSimuSteps[$i]} | sed 's;OK;?? #####;' `
+	      simuDone=$(( $simuDone && 0 ))
+              echo "    $stringKO"
+           else
+              echo "    ${tabSimuSteps[$i]}"
+           fi         
+       done
+       
+       # si toutes les operations sur la simu sont OK, on incremente le nb de simu OK
+       if [ "x$simuDone" == "x1" ]
+       then
+          nbSimuOK=$(( $nbSimuOK + 1 ))
+       fi                 
+   done   
+   cd ..
+done
+
+
+waitingFor "${nbSimuFile}"
+
+nbSimuTot=`cat ${nbSimuFile} `
+nbSimuFormatOK=`echo $nbSimuTot | grep -e '^[0-9]\{1,4\}$' | wc -l`
+if [ "x$nbSimuFormatOK" == "x0" ]
+then
+   echo "Le nombre de simulation contenues dans le fichier $nbSimuFile est incorrect."
+   exit -1
+fi
+
+echo
+echo "============================================="
+echo "nbre de simu OK : $nbSimuOK / $nbSimuTot"
+echo "============================================="
+
+
+
+
+
+
+
+
+
+
Index: TOOLS/SURPACK_IPSL/showPackProgress.sh
===================================================================
--- TOOLS/SURPACK_IPSL/showPackProgress.sh	(revision 2136)
+++ TOOLS/SURPACK_IPSL/showPackProgress.sh	(revision 2136)
@@ -0,0 +1,563 @@
+#!/bin/bash
+
+# On renseigne les variables d'environnement 
+. load_ipslPack_env.sh
+
+export JOB_DIR=${TMP_MIGR_DATA}
+export EXE_DIR=${LS_SUBCWD:-${PWD}}
+
+SCRIPT_NAME=$(basename ${0} )
+
+export IGCM_TMP="${IGCM_DEM}/tmp"  # gpdebug : added
+
+export config_card=${IGCM_DEM}/config_card.liste
+
+source ${EXE_DIR}/DEM_utilities.sh
+
+export timeHandlingFile="${USER_OUTPUT_PROGRESS}/timeHandlingFile.txt"
+export timeLaunchStartFile="${USER_OUTPUT_PROGRESS}/timeLaunchStartFile.txt"
+export timeEndFile="${USER_OUTPUT_PROGRESS}/timeEndFile.txt"
+
+
+function getSimuName
+{   
+   config_card=$1
+   
+   dirSimu=$( dirname $config_card )
+   simuName=`echo ${dirSimu} | sed "s;${IGCM_DEM}/;;" `
+   echo $simuName
+
+}
+
+function getTimeTaken
+{
+   statFile=$1
+   if [ ! -e $statFile ]
+   then
+      echo "inconnu : pas de fichier status"
+      return
+   fi
+   
+   timeLine=`sed -n '1p' $statFile `
+   goodFormat=`echo $timeLine | grep -e '^meantime:[[:digit:]]*\.[[:digit:]]\{1,3\}$' | wc -l `
+   if [ "x$goodFormat" == "x0" ]
+   then
+       echo "inconnu : mauvais format du temps"
+       return
+   fi
+   
+   timeTaken=`echo $timeLine | sed 's;^meantime:;;' `
+   echo $timeTaken
+   
+}
+
+function progressStatus
+{
+   statFile=$1
+   echo "statFile=$1" >> ${JOB_DIR}/showPackProgress.log
+   if [ ! -e $statFile ]
+   then
+      echo "Non traitee"
+      return
+   fi
+   echo "blabla" >> ${JOB_DIR}/showPackProgress.log
+   echo "----------------------------------------------" >> ${JOB_DIR}/showPackProgress.log
+   # echo "progressStatus..." # gpdebug : a virer
+   
+   # ------------------------------------------------------------------------------------------------
+   listLineNumWithKey=`grep -n -E '(COMPLETED|FAILED|DELEGATE)' $statFile | awk -F":" '{print $1}' ` 
+   # echo "listLineNumWithKey=$listLineNumWithKey" # gpdebug : a virer
+   
+  if [ "x$listLineNumWithKey" == "x" ]
+  then
+     echo "Statut illisible"
+     return
+  fi
+
+   # On trouve la derniere ligne du fichier status comportant un mot cle 
+   max=0
+   for lineNum in $listLineNumWithKey
+   do
+      if [ $lineNum -gt $max ]
+      then
+          max=$lineNum
+      fi
+   done
+
+   # echo "max=$max" # gpdebug : a virer
+
+   lastLineWithKey=`sed -n "${max}p" $statFile `
+   # echo "lastLineWithKey=$lastLineWithKey" # gpdebug : a virer   
+   # ------------------------------------------------------------------------------------------------
+     
+   # lastLine=`tail -1 $statFile ` # gpdebug : a virer
+   
+   completed=`echo $lastLineWithKey | grep COMPLETED | sed 's; (.*)$;;' `
+   if [ "x${completed}" != "x" ]
+   then 
+      echo $completed
+      return
+   fi
+   
+  failed=`echo $lastLineWithKey | grep FAILED | cut -d";" -f1 `
+  if [ "x${failed}" != "x" ]
+  then
+     echo $failed
+     return         
+  fi
+  
+  delegate=`echo $lastLineWithKey | grep DELEGATE `
+  if [ "x${delegate}" != "x" ]
+  then
+     echo "DELEGATE"
+     return
+  fi
+  
+}
+
+
+function getWaitingTime
+{
+    timeNow_=$1
+    stillWaiting_=1
+    
+    launchTimeString=`cat $timeHandlingFile | grep -e 'launch time:[[:digit:].]*$' `
+    if [ "x${launchTimeString}" == "x" ]
+    then
+        echo "no launch time"
+	return
+    fi
+    launchTime_=`echo $launchTimeString | awk -F":" '{print $2}' `
+    
+    
+    startExecTimeString=`cat $timeHandlingFile | grep -e 'start time:[[:digit:].]*$' `
+    if [ "x${startExecTimeString}" == "x" ]
+    then
+        execTime_=${timeNow_}	
+    else
+        execTime_=`echo $startExecTimeString | awk -F":" '{print $2}' `
+	stillWaiting_=0
+    fi
+    
+    waitingTime_=$( awk 'BEGIN { print '${execTime_}'-'${launchTime_}' }' )
+    waitingTime_=$( awk 'BEGIN { print '${waitingTime_}'/'1000' }' )
+    if [ "x$stillWaiting_" == "x1" ]
+    then
+       waitingTime_="${waitingTime_}, still waiting..."
+    fi
+    
+    echo $waitingTime_
+}
+    
+    
+function getTimeSinceExecutionStart
+{  
+    
+    timeNow_=$1
+    stillWaiting_=1    
+    
+    execTimeString=`cat $timeHandlingFile | grep -e 'start time:[[:digit:].]*$' `
+    if [ "x${execTimeString}" == "x" ]
+    then
+        echo "no start time"
+	return
+    fi
+    execTime_=`echo $execTimeString | awk -F":" '{print $2}' `
+    
+        
+    endTimeString=`cat $timeHandlingFile | grep -e 'end time:[[:digit:].]*$' `
+    if [ "x${endTimeString}" == "x" ]
+    then
+	endTime_=${timeNow_}
+    else
+	endTime_=`echo $endTimeString | awk -F":" '{print $2}' `
+	stillWaiting_=0
+    fi
+    
+    timeSinceExec_=$( awk 'BEGIN { print '${endTime_}'-'${execTime_}' }' )
+    timeSinceExec_=$( awk 'BEGIN { print '${timeSinceExec_}'/'1000' }' )
+    if [ "x$stillWaiting_" == "x1" ]
+    then
+       timeSinceExec_="${timeSinceExec_}, still executing..."
+    fi
+    
+    echo $timeSinceExec_
+}
+
+function getTimeSinceLaunchStart
+{
+    timeNow_=$1
+    stillWaiting_=1
+    
+    launchTimeString=`cat $timeLaunchStartFile | grep -e 'launch time:[[:digit:].]*$' `
+    if [ "x${launchTimeString}" == "x" ]
+    then
+        echo "no launch time"
+	return
+    fi
+    launchTime_=`echo $launchTimeString | awk -F":" '{print $2}' `
+    
+    
+    endTimeString=`cat $timeEndFile | grep -e 'end time:[[:digit:].]*$' `
+    if [ "x${endTimeString}" == "x" ]
+    then
+	endTime_=${timeNow_}
+    else
+	endTime_=`echo $endTimeString | awk -F":" '{print $2}' `
+	stillWaiting_=0
+    fi
+    
+    timeSinceLaunch_=$( awk 'BEGIN { print '${endTime_}'-'${launchTime_}' }' )
+    timeSinceLaunch_=$( awk 'BEGIN { print '${timeSinceLaunch_}'/'1000' }' )
+    if [ "x$stillWaiting_" == "x1" ]
+    then
+       timeSinceLaunch_="${timeSinceLaunch_}, still executing..."
+    fi
+    
+    echo $timeSinceLaunch_
+
+}
+
+
+function getListProgress
+{
+     set=$1     
+     
+     listName=`echo $(basename $set) | sed 's;\.list$;;' | sed 's;\.nc$;;' `
+
+     statusfile=${set%%.list}.status
+     status=$( progressStatus $statusfile ) # gpdebug : a retablir
+     timeTaken="???"
+
+     if [ -e ${statusfile} ]
+     then
+	 
+	 if [ -s $set ] ; then
+	     if [[ "$listName" == *"_restart_"* ]] || [[ "$listName" == *"_debug_"* ]]
+	     then
+		 purge_list=$( awk '{print $0}' $set | cut -c 5- )
+	     else
+		 purge_list=$( awk '{print $0}' $set )
+	     fi
+	     grep -v -F "$purge_list" ${IGCM_DEM}/Listing_progress.txt > ${IGCM_DEM}/Listing_progress_tmp.txt
+	     mv ${IGCM_DEM}/Listing_progress_tmp.txt ${IGCM_DEM}/Listing_progress.txt
+	 fi
+     fi
+
+     packFailed=`echo $status | grep -E '(DELEGATE|FAILED)' | wc -l `
+     if [ "x${packFailed}" != "x0" ]
+     then
+   	nbOfListsFailed=$(( $nbOfListsFailed + 1 ))
+	simuOK=$(( $simuOK && 0 )) # marque une simu pas OK
+     fi
+  
+     packSuccess=`echo $status | grep "COMPLETED" | wc -l `
+     if [ "x${packSuccess}" != "x0" ]
+     then
+   	timeTaken=$( getTimeTaken $statusfile )
+	nbOfListsPacked=$(( $nbOfListsPacked + 1 ))
+     fi
+     
+     packNottreated=`echo $status | grep -E '(Non traitee|illisible)' | wc -l `
+     if [ "x${packNottreated}" != "x0" ]
+     then
+	 nbOfListsNottreated=$(( $nbOfListsNottreated + 1 ))
+	 simuOK=$(( $simuOK && 0 )) # marque une simu pas OK
+         simutreated=$(( $simutreated && 0 )) # marque une simu non completement traitee
+     fi
+
+     echo "	  $listName : $status | time : $timeTaken" >> ${JOB_DIR}/simuPrint.txt
+     
+     timeInSecondsOK=`echo $timeTaken | grep -e '^[[:digit:].]*$' | wc -l `
+     if [ "x${timeInSecondsOK}" != "x0" ]
+     then
+   	 totalTime=$(awk 'BEGIN { print '$totalTime'+'$timeTaken' }')
+     fi
+
+
+
+}
+
+#################################
+####### Main script #############
+#################################
+
+########  Options du script ########################################################
+focusOnSimu=
+outputFile=
+outputFile_simus=
+detailed_mode=1
+publish_mode=1
+while [ $# -gt 0 ]
+do
+   # echo "boucle sur les arguments du script ..."
+   # echo "@=$@"
+   case $1 in
+   -s)  echo "option -s selectionnee : afficher une simulation"
+        shift
+	focusOnSimu=$1
+	is_simu_an_option=`echo $focusOnSimu | grep -e '^-' | wc -l `
+	if [ "x${is_simu_an_option}" != "x0" ] || [ "x$focusOnSimu" == "x" ]
+	then
+	   echo "L'option -s doit etre suivie d'une simulation !"
+	   exit 1
+	fi
+	;;
+   -o)  echo "option -o selectionnee : fichier d'output"
+        shift
+	outputFile=$1
+	is_output_an_option=`echo $outputFile | grep -e '^-' | wc -l `
+	if [ "x${is_output_an_option}" != "x0" ] || [ "x$outputFile" == "x" ]
+	then
+	   echo "L'option -o doit etre suivie d'un fichier d'output !"
+	   exit 1
+	fi
+	;;
+   --not-detailled)  echo "option '--not-detailled' selectionnee"
+                     detailed_mode=0
+                     ;;
+   -p) echo "option -p selectionnee : publication"
+       publish_mode=0
+       outputFile="${MONIT_DIR}/monit_${USER}.txt"
+       outputFile_simus="${MONIT_DIR}/${USER}_SIMUS/monit_${USER}_simus.txt"
+       if [ -d ${MONIT_DIR}/${USER}_SIMUS ]
+       then
+	   rm -f ${MONIT_DIR}/${USER}_SIMUS/*
+       else
+	   mkdir -p ${MONIT_DIR}/${USER}_SIMUS
+       fi
+       echo "Simulation;Status" > ${outputFile_simus}
+   esac
+   shift
+done
+
+# echo "focusOnSimu=$focusOnSimu"
+# echo "outputFile=$outputFile"
+# echo "detailed_mode=$detailed_mode"
+######################################################################################
+# exit 0 # gpdebug : a virer
+
+
+
+> ${JOB_DIR}/showPackProgress.log # vider le fichier de log
+
+
+# Recuperation des temps d'attente et ecoule depuis de demarrage des traitements en batch
+if [ -e $timeLaunchStartFile ]
+then
+    timeNow=$( getDateMilliSeconds )
+    # waitingTime=$( getWaitingTime $timeNow ) # supprime pour le moment : pb si +sieurs instances ==> on simplifie
+    # timeSinceExecutionStart=$( getTimeSinceExecutionStart $timeNow ) # supprime pour le moment : pb si +sieurs instances ==> on simplifie
+    timeSinceLaunchStart=$( getTimeSinceLaunchStart $timeNow ) # added
+else
+    # waitingTime="no handling time file available." # supprime pour le moment : pb si +sieurs instances ==> on simplifie
+    # timeFromExecutionStart="no handling time file available." # supprime pour le moment : pb si +sieurs instances ==> on simplifie
+    timeSinceLaunchStart="no launch time file available."
+fi
+
+
+totalNbOfList=0
+for CONFIG in $( awk '{print $1}' ${IGCM_DEM}/config_card.liste )
+do
+   PATH_SIMU=$( dirname $CONFIG )
+   nbListInConfig=`find $PATH_SIMU -name "*list" | wc -l `
+   totalNbOfList=$(( $totalNbOfList + $nbListInConfig ))
+done
+
+# echo "totalNbOfList=$totalNbOfList"
+# exit 0 # gpdebug : a virer
+
+TotalNbSimu=0
+nbOfSimuPacked=0
+nbOfSimuFailed=0
+nbOfSimuNottreated=0
+nbOfListsPacked=0
+nbOfListsFailed=0
+nbOfListsNottreated=0
+TotalNbInodes=0
+TotalSimuTar=0
+totalTime=0
+cp ${IGCM_DEM}/Listing.txt ${IGCM_DEM}/Listing_progress.txt
+TotalNbSimu=`cat ${IGCM_DEM}/config_card.liste |wc -l`
+
+if [ "x${outputFile}" == "x" ] && [ "x${publish_mode}" == "x0" ]
+then
+# Publication
+echo "Simulation;Status" > ${outputFile}_${USER}
+fi
+
+for CONFIG in $( awk '{print $1}' ${IGCM_DEM}/config_card.liste ) ; do 
+
+    DEM_state=$( DEM_read_state ${IGCM_DEM}/config_card.liste ${CONFIG} )
+    
+    # Eviter les simus autre que celle selectionnee par l'option -s
+    showCurrentSimu=`echo $CONFIG | grep "${focusOnSimu}" | wc -l `
+    if [ "x${showCurrentSimu}" == "x0" ]
+    then
+        continue
+    fi
+
+    simuName=$( getSimuName $CONFIG )
+    
+    > ${JOB_DIR}/simuPrint.txt
+
+    export PATH_SIMU=$( dirname $CONFIG )
+    # echo "PATH_SIMU = $PATH_SIMU"
+    
+    simuOK=1 
+    simutreated=1
+ 
+    if [ ! -e "${PATH_SIMU}/tar_full_simul.list" ]
+    then
+    	
+	 listOfDir="output_ncrcat output_tar restart_tar debug_tar store_cp work_cp"
+	 for dir in $listOfDir
+	 do
+	     echo "   ${dir} :" >> ${JOB_DIR}/simuPrint.txt
+	     if [ ! -d $PATH_SIMU/${dir} ]
+	     then
+	        echo "      ${dir} n'existe pas pour cette simu" >> ${JOB_DIR}/simuPrint.txt
+#		simuOK=$(( $simuOK && 0 )) # marque une simu pas OK
+	        continue
+	     fi
+	   
+	     listFilesInDir=`find $PATH_SIMU/${dir} -name "*list" | wc -l `
+	     if [ "x$listFilesInDir" == "x0" ]
+	     then
+	        echo "       -- no list --" >> ${JOB_DIR}/simuPrint.txt
+	        continue	   
+	     fi
+	   
+	     setList=$( ls $PATH_SIMU/${dir}/*list )
+
+	     for set in $setList
+	     do
+	          getListProgress $set
+	     done
+         done
+    else	 
+	 getListProgress ${PATH_SIMU}/tar_full_simul.list
+	 TotalSimuTar=$(( $TotalSimuTar + 1 ))
+    fi
+    
+    resSimu="OK"
+    if [ "x${simuOK}" == "x0" ]
+    then
+        resSimu="not OK"
+    fi
+
+    if [ "x${simutreated}" == "x0" ]
+    then
+        resSimu="not treated"
+    fi
+
+    if [ "x${resSimu}" == "xnot OK" ]
+    then
+       nbOfSimuFailed=$(( $nbOfSimuFailed + 1 )) 
+    elif [ "x${resSimu}" == "xnot treated" ]
+    then
+       nbOfSimuNottreated=$(( $nbOfSimuNottreated + 1 ))
+    else
+        nbOfSimuPacked=$(( $nbOfSimuPacked + 1 ))
+    fi
+
+    if [ "x${outputFile}" == "x" ]
+    then
+        echo "***************************************************"
+        echo "simulation : $simuName  ===> $resSimu"
+        echo "***************************************************"
+        if [ "x${detailed_mode}" == "x1" ]
+        then
+    	    cat ${JOB_DIR}/simuPrint.txt  $outRedirectStatement
+        fi
+    else
+        if [ "x${publish_mode}" == "x1" ]
+        then
+        echo "***************************************************" >> ${outputFile}
+        echo "simulation : $simuName  ===> $resSimu"               >> ${outputFile}
+        echo "***************************************************" >> ${outputFile}
+        if [ "x${detailed_mode}" == "x1" ]
+        then
+    	    cat ${JOB_DIR}/simuPrint.txt  $outRedirectStatement               >> ${outputFile}
+        fi     
+        else
+# Publication
+            echo "$simuName;$resSimu" >> ${outputFile_simus}
+	    if [ "x${resSimu}" == "xnot OK" ]
+	    then
+		simuName_modif=$( echo $simuName | sed s%"/"%"_"%g )
+		cat ${JOB_DIR}/simuPrint.txt $outRedirectStatemen > ${MONIT_DIR}/${USER}_SIMUS/${simuName_modif}".log"
+	    fi
+        fi
+    fi 
+    rm ${JOB_DIR}/simuPrint.txt
+done
+NbInodeBefore=`cat ${IGCM_DEM}/Listing.txt | grep "f " | wc -l`
+#NbInodeBefore=`cat ${IGCM_DEM}/Listing.txt  | wc -l`
+ NbInodeAfterStore=0
+ if [ -d "${OUTPUT_STORE}" ]
+ then
+     NbInodeAfterStore=$( find $OUTPUT_STORE -type f -printf "%y %s %p \n" | wc -l )
+ fi
+ NbInodeAfterWork=0
+ if [ -d "${OUTPUT_WORK}" ]
+ then
+     NbInodeAfterWork=$( find $OUTPUT_WORK -type f -printf "%y %s %p \n" | wc -l )
+ fi
+
+# NbInodeAfter=`cat ${IGCM_DEM}/ListingEnd.txt | grep "f " | wc -l`
+ NbInodeAfter=$(( $NbInodeAfterStore + $NbInodeAfterWork ))
+
+if [ -e ${IGCM_DEM}/Listing_progress.txt ]
+then
+    NbInodesprogressed=`cat ${IGCM_DEM}/Listing_progress.txt | grep "f " | wc -l`
+#    NbInodesprogressed=`cat ${IGCM_DEM}/Listing_progress.txt | wc -l`
+fi
+TotalNbInodes=$(( $NbInodeBefore - $NbInodesprogressed ))
+
+
+if [ "x${outputFile}" == "x" ]
+then
+    echo
+    echo "##################"
+    echo "#####  BILAN #####"
+    echo "##################"
+    echo "nb of Simulations packed with success : ${nbOfSimuPacked} / ${TotalNbSimu}"
+    echo "nb of Simus failed : ${nbOfSimuFailed}"
+    echo "nb of Simus not treated : ${nbOfSimuNottreated}"
+    echo "nb of Lists packed with success : ${nbOfListsPacked} / ${totalNbOfList}"
+    echo "nb of fails : $nbOfListsFailed"
+    echo "nb of not treated : ${nbOfListsNottreated}"
+    echo "nb of inodes packed : $TotalNbInodes"
+    echo "nb simul full tared : $TotalSimuTar"
+    echo "nb inode before : $NbInodeBefore"
+    echo "nb inode after WORK : $NbInodeAfterWork"
+    echo "nb inode after STORE : $NbInodeAfterStore"
+    echo "Total time for elementary operations : $totalTime" 
+    echo "Time since launch start : $timeSinceLaunchStart"
+
+else
+    if [ "x${publish_mode}" == "x1" ]
+        then
+    echo
+    echo "##################" >> ${outputFile}
+    echo "#####  BILAN #####" >> ${outputFile}
+    echo "##################" >> ${outputFile}
+    echo "nb of Simulations packed with success : ${nbOfSimuPacked} / ${TotalNbSimu}" >> ${outputFile}
+    echo "nb of Simus failed : ${nbOfSimuFailed}" >> ${outputFile}
+    echo "nb of Simus not treated : ${nbOfSimuNottreated}" >> ${outputFile}
+    echo "nb of Lists packed with success : ${nbOfListsPacked} / ${totalNbOfList}" >> ${outputFile}
+    echo "nb of fails : $nbOfListsFailed" >> ${outputFile}
+    echo "nb of not treated : ${nbOfListsNottreated}" >> ${outputFile}
+    echo "nb of inodes packed : $TotalNbInodes" >> ${outputFile}
+    echo "nb simul full tared : $TotalSimuTar" >> ${outputFile}
+    echo "nb inode before : $NbInodeBefore" >> ${outputFile}
+    echo "nb inode after : $NbInodeAfter" >> ${outputFile}
+    echo "Total time for elementary operations : $totalTime" >> ${outputFile}
+    echo "Time since launch start : $timeSinceLaunchStart" >> ${outputFile}
+    else
+# Publication
+    echo "User;Inode NB;Inode Processed;Inode Treatment Percentage;Inode After;Inode store;Inode percentage STORE-WORK;Simu NB;Simu OK; Simu FAILED;Simu Percentage;List NB;List OK;List FAILED;List Percentage" > ${outputFile}
+	echo "${USER};$NbInodeBefore;$TotalNbInodes;PIE2;$NbInodeAfter;$NbInodeAfterStore;PIE2;${TotalNbSimu};${nbOfSimuPacked};${nbOfSimuFailed};PIE3;${totalNbOfList};${nbOfListsPacked};$nbOfListsFailed;PIE3" >> ${outputFile}
+    fi
+fi
Index: TOOLS/SURPACK_IPSL/write_liste_pack.sh
===================================================================
--- TOOLS/SURPACK_IPSL/write_liste_pack.sh	(revision 2136)
+++ TOOLS/SURPACK_IPSL/write_liste_pack.sh	(revision 2136)
@@ -0,0 +1,314 @@
+#!/bin/bash
+
+# Script permettant de creer les listes de fichiers pour ncrcat
+# si un trou est detecte dans la simulation alors cette liste sera 
+# pour un tar
+
+# $1= PATH/config_card d'une simulation avec 
+# TagName/JobName/ExperimentName/SpaceName/DateBegin/DateEnd/PATH_SIMUL
+
+
+# Pour commencer on travaille avec le fichier information_dmnfs
+# /cscratch/cont003/p86mart/FROM_CCRT_INFORMATIONS_DMNFS/information_dmnfs_2011-09-21
+
+config_card=${1}
+LISTE_DMNFS=${2}
+
+# Declaration des variables
+
+# ----
+export JOB_DIR=${JOB_DIR:-${TMP_MIGR_DATA}}
+export IGCM_DEM=${IGCM_DEM:-${SCRATCHDIR}/IGCM_DEM}
+export IGCM_TMP=${IGCM_TMP:-${IGCM_DEM}/tmp}
+mkdir -p ${IGCM_DEM}
+mkdir -p ${IGCM_TMP}
+clean_tmp=${clean_tmp:-yes}
+EXE_DIR=$(dirname ${0} )
+SCRIPT_NAME=$(basename ${0} )
+source ${EXE_DIR}/DEM_utilities.sh
+
+# gpdebug : verif si le present script a ete execute jusqu'au bout #########
+MonitoringInfo="${SCRIPT_NAME}-->OK"
+simuMonitoring_check "$MonitoringInfo" "$config_card"
+
+# gpdebug : Execute la function errorReceive() si reception d'un signal TERM
+trap 'DEM_errorReceive' TERM ########
+
+# gpdebug : on augmente la liste des proc à détruire en cas d'erreur bloquante du présent proc
+export listPID="$$ ${listPID}" #########
+
+DEM_log -0 "Demmarrage de ${SCRIPT_NAME}"
+cd ${JOB_DIR}
+# ----
+
+DEM_log -0 "config_card : ${config_card}"
+DEM_log -0 "LISTE_DMNFS : ${LISTE_DMNFS}"
+
+eval $(grep JobName         ${config_card}) 
+eval $(grep PATH_SIMUL_FULL ${config_card}) 
+eval $(grep DateBegin       ${config_card}) 
+eval $(grep DateEnd         ${config_card}) 
+eval $(grep IGCM_DEM_SIMU   ${config_card})
+
+SIMUL=${PATH_SIMUL_FULL}/${JobName}
+
+
+DEM_state=$( DEM_read_state ${IGCM_DEM}/config_card.liste ${config_card} )
+# gpdebug : si c'est une premiere exec (pas une reprise)
+if [[ "x${execEveryStep}" == "1" ]] && [[ "${DEM_state}" != "FindSizePackDone" ]] ; then
+    DEM_errorSend "${SCRIPT_NAME}:${LINENO}:Etat incorrect dans ${IGCM_DEM}/config_card.liste"
+fi
+
+
+DEM_write_state ${IGCM_DEM}/config_card.liste ${config_card} WriteListPackRunning
+
+# creation des repertoires with_tar et with_ncrcat
+OUTPUT_NCRCAT=${IGCM_DEM_SIMU}/output_ncrcat
+OUTPUT_TAR=${IGCM_DEM_SIMU}/output_tar
+
+mkdir -p ${OUTPUT_NCRCAT}
+mkdir -p ${OUTPUT_TAR}
+
+# lecture de periodpack dans ${IGCM_DEM_SIMU}/period_pack.txt
+period_pack=$( awk '{print $0} ' ${IGCM_DEM_SIMU}/period_pack.txt )
+
+year_begin=$(  echo ${DateBegin} | cut -c 1-4 )
+month_begin=$( echo ${DateBegin} | cut -c 5-6 )
+year_end=$(    echo ${DateEnd}   | cut -c 1-4 )
+month_end=$(   echo ${DateEnd}   | cut -c 5-6 )
+
+awk '{print $2}' ${IGCM_DEM_SIMU}/liste_output_files_config.txt >  ${IGCM_DEM_SIMU}/info_Output_light.txt
+
+# on cree la liste des fichiers pour chaque type_file
+for type_file in $( awk '{print $0}' ${IGCM_DEM_SIMU}/info_name_file.txt ) ; do 
+   #sed -e "/${type_file}/!d" ${IGCM_DEM_SIMU}/info_Output_light.txt > ${IGCM_TMP}/${$}.info_${type_file}.txt
+    grep ${type_file} ${IGCM_DEM_SIMU}/info_Output_light.txt > ${IGCM_TMP}/${$}.info_${type_file}.txt
+    sort -u ${IGCM_TMP}/${$}.info_${type_file}.txt > ${IGCM_TMP}/${$}.tmp_info_${type_file}.txt.tmp
+    cp ${IGCM_TMP}/${$}.tmp_info_${type_file}.txt.tmp ${IGCM_TMP}/${$}.info_${type_file}.txt
+    [[ "${clean_tmp}" = "yes" ]] && rm -f ${IGCM_TMP}/${$}.tmp_info_${type_file}.txt.tmp
+done
+
+# 3- Maintenant pour chaque type de fichier de sortie nous allons creer la liste
+# des fichiers contenus dans chaque pack
+
+# Recherche des dates du premier pack
+
+date_begin_pack=${DateBegin}
+date_end_simulation=${DateEnd}
+
+month_begin_pack=${month_begin}
+year_begin_pack=${year_begin}
+
+number_pack=1
+
+#
+date_begin_pack=`echo $date_begin_pack|sed 's/^0*//'`
+date_end_simulation=`echo $date_end_simulation|sed 's/^0*//'`
+
+while [[ ${date_begin_pack} -le ${date_end_simulation}  ]]
+do 
+
+   month_end_pack=${month_begin_pack}
+   year_end_pack=$(( ${year_begin_pack} +${period_pack} ))
+   
+   date_end_pack=${year_end_pack}${month_end_pack}01   
+
+   DEM_log -2 "Entree boucle 3 : year_begin_pack month_begin_pack year_end_pack month_end_pack : ${year_begin_pack} ${month_begin_pack} ${year_end_pack} ${month_end_pack}"
+   DEM_log -2 "Entree boucle 3 : date_end_pack : ${date_end_pack}"
+   
+   for type_file in `awk '{print $0}' ${IGCM_DEM_SIMU}/info_name_file.txt`
+   do 
+       DEM_log -2 "Boucle 3 : ${type_file} ${number_pack}"
+       taille=0
+
+       # On passe en revue chaque type de fichier 
+       for file in `awk '{print $0}' ${IGCM_TMP}/${$}.info_${type_file}.txt`
+       do 
+           # Extraire la date de debut et la date de fin de la periode d'output traitee par le fichier    
+           extract_date_file=$( echo ${file}             | sed -e "s%.*${JobName}_%%" )
+           date_debut=$(        echo ${extract_date_file}| sed 's%\([0-9]\{8\}\)_.*$%\1%g' )
+           date_fin=$(          echo ${extract_date_file}| sed 's%.*_\([0-9]\{8\}\)_.*$%\1%g' )
+	   
+           if [  ${date_debut} -lt ${date_end_pack} ]
+           then 
+               if [ ${date_fin} -ge ${date_begin_pack} ]
+               then 
+		   echo ${file} >> ${OUTPUT_NCRCAT}/ncrcat_${type_file}_${date_begin_pack}_${date_end_pack}.list
+		   echo ${date_debut} | cut -c 1-6 >>  ${IGCM_TMP}/${$}.date_${type_file}.txt
+		   grep -v ${file} ${IGCM_TMP}/${$}.info_${type_file}.txt > ${IGCM_TMP}/${$}.info_${type_file}.txt.tmp
+		   cp ${IGCM_TMP}/${$}.info_${type_file}.txt.tmp ${IGCM_TMP}/${$}.info_${type_file}.txt
+		   [[ "${clean_tmp}" = "yes" ]] && rm -f ${IGCM_TMP}/${$}.info_${type_file}.txt.tmp
+               fi
+	   else 
+	       break
+           fi
+	   
+       done
+       if [[ -f ${IGCM_TMP}/${$}.date_${type_file}.txt ]] ; then
+	   sort -u ${IGCM_TMP}/${$}.date_${type_file}.txt > ${IGCM_TMP}/${$}.date_tmp.txt
+	   mv ${IGCM_TMP}/${$}.date_tmp.txt ${IGCM_TMP}/${$}.date_${type_file}.txt
+       else
+	   DEM_log -2 "Pas de fichier cree :  ${IGCM_TMP}/${$}.date_${type_file}.txt - Date_end_pack : ${date_end_pack}"
+       fi
+
+#On renomme le fichier ncrcat avec la date reelle de fin et non pas la premiere date suivant la fin 
+#on renomme egalement en fonction de la date reelle de debut pour le cas des annees < 1000 qui perdent leurs zeros en cour de route
+       if [[ -f ${OUTPUT_NCRCAT}/ncrcat_${type_file}_${date_begin_pack}_${date_end_pack}.list ]]; then 
+	   sort ${OUTPUT_NCRCAT}/ncrcat_${type_file}_${date_begin_pack}_${date_end_pack}.list > ${IGCM_TMP}/${$}.ncrcat.tmp
+
+	   first_file=$(head -n 1 ${IGCM_TMP}/${$}.ncrcat.tmp )
+	   extract_date_file=$( echo ${first_file}  | sed -e "s/.*${JobName}_//" )
+	   date_debut=$(echo ${extract_date_file}| sed 's%\([0-9]\{8\}\)_.*$%\1%g' )
+
+	   last_file=$(tail -n 1 ${IGCM_TMP}/${$}.ncrcat.tmp )
+	   extract_date_file=$( echo ${last_file}  | sed -e "s/.*${JobName}_//" )
+	   date_fin=$(echo ${extract_date_file}| sed 's%.*_\([0-9]\{8\}\)_.*$%\1%g' )
+	   mv ${OUTPUT_NCRCAT}/ncrcat_${type_file}_${date_begin_pack}_${date_end_pack}.list ${OUTPUT_NCRCAT}/${JobName}_${date_debut}_${date_fin}_${type_file}.list
+       fi
+   done
+
+   month_begin_pack=${month_end_pack}
+   year_begin_pack=${year_end_pack}
+   date_begin_pack=${year_begin_pack}${month_begin_pack}01
+   
+   number_pack=$(( ${number_pack} + 1 ))
+
+   DEM_log -2 "Sortie boucle : year_begin_pack month_begin_pack year_end_pack month_end_pack : ${year_begin_pack} ${month_begin_pack} ${year_end_pack} ${month_end_pack}"
+   DEM_log -2 "Sortie boucle : date_begin_pack : ${date_begin_pack}"
+   
+done
+
+
+## Recherche des trous eventuels dans cette simulation
+
+## Creation de la liste des annees comprisent entre DateBegin et DateEnd >>  ${IGCM_TMP}/${$}.liste_date.txt
+force_sequence (){
+    awk '{
+        if (NR==1) {avant=$1; print $1}
+        else { for (i=avant+1 ; i<=$1 ; i++) printf "%04i\n", i}}'
+}
+
+DEM_log -1 "year_begin - year_end : ${year_begin} - ${year_end}"
+
+echo ${year_begin} > ${IGCM_TMP}/${$}.liste_date.txt
+echo ${year_end}  >> ${IGCM_TMP}/${$}.liste_date.txt
+
+force_sequence < ${IGCM_TMP}/${$}.liste_date.txt > ${IGCM_TMP}/${$}.tmp ; mv ${IGCM_TMP}/${$}.tmp ${IGCM_TMP}/${$}.liste_date.txt
+
+
+## il faut savoir si les fichiers d'output sont annuels ou mensuels ? 
+file=$( head -n 1 ${IGCM_DEM_SIMU}/liste_output_files_config.txt )
+
+extract_date_file=$( echo ${file}             | sed -e "s%.*${JobName}_%%" )
+date_debut=$(        echo ${extract_date_file}| sed 's%\([0-9]\{8\}\)_.*$%\1%g')
+date_fin=$(          echo ${extract_date_file}| sed 's%.*_\([0-9]\{8\}\)_.*$%\1%g')
+month_begin=$(       echo ${date_debut}       | cut -c 5-6 )
+month_end=$(         echo ${date_fin}         | cut -c 5-6 )
+year_debut=$(       echo ${date_debut}       | cut -c 1-4 )
+year_fin=$(       echo ${date_fin}       | cut -c 1-4 )
+DEM_log -1 "Recherche de la frequence"
+if [ ${month_end} -eq ${month_begin} ] 
+then 
+    DEM_log -1 "Mensuel"
+    while read an ; do
+        for month in 1 2 3 4 5 6 7 8 9 10 11 12 ; do
+            printf "%s%02d\n" ${an} ${month}  >> ${IGCM_TMP}/${$}.toutes_dates
+	done
+    done < ${IGCM_TMP}/${$}.liste_date.txt
+    [[ "${clean_tmp}" = "yes" ]] && rm -f ${IGCM_TMP}/${$}.liste_date.txt
+else
+    freqwriteyear=0
+#la frequence peut être de plusieurs mois (<1 an) 
+#ou de plusieurs années 
+#attention une simulation ne commence pas obligatoirement au 1er janvier
+    if [[ ${year_debut} -eq ${year_fin} ]]; then 
+	freqwritemonth=$(( ${month_end} - ${month_begin} + 1 ))
+    else
+	freqwritemonth=$(( 12 + ${month_end} - ${month_begin} + 1 ))
+    fi
+    if [[ $freqwritemonth -eq 12 ]]; then
+	## frequence annuelle
+	if [[ ${year_debut} -eq ${year_fin} ]]; then 
+	    freqwriteyear=1
+	else 
+	    if [[ ${month_end} -gt {month_begin}  ]]; then 
+		freqwriteyear=$(( ${year_fin} - ${year_debut} + 1 ))
+	    else
+		freqwriteyear=$(( ${year_fin} - ${year_debut} ))
+	    fi
+	fi
+    fi 
+
+    if [[ $freqwriteyear -eq 0 ]]; then 
+	DEM_log -1 "mensuel avec sorties tous les  $freqwritemonth mois "
+	while read an ; do
+	    i=${month_begin}
+	    while [[ ${i} -le 12 ]] ; do 
+		printf "%s%02d\n" ${an} ${i}  >> ${IGCM_TMP}/${$}.toutes_dates
+		i=$(( $i + $freqwritemonth ))
+	    done
+	done < ${IGCM_TMP}/${$}.liste_date.txt    
+    else
+	DEM_log -1 "annuel avec sorties tous les  $freqwriteyear month "
+	i=${month_begin}
+	y=${year_debut}
+	while [[ $y -le ${year_end} ]]; do    # attention year_fin = annee de fin du premier fichier / year_end = annee de fin de la simulation 
+		printf "%s%02d\n" ${y} ${i}  >> ${IGCM_TMP}/${$}.toutes_dates
+		y=$(( $y + $freqwriteyear ))
+	done
+    fi 
+	
+fi 
+
+# Maintenant il faut comparer la liste des dates avec la liste des dates des fichiers 
+# et pour des dates manquantes transformer le fichier ncrcat_date correspondant en fichier 
+# tar_date
+DEM_log -1 "Recherche des dates manquantes"
+for type_file in `awk '{print $0}' ${IGCM_DEM_SIMU}/info_name_file.txt`
+do 
+    DEM_log -2 "${type_file}"
+    rm -f ${IGCM_DEM_SIMU}/${type_file}_manquant.list
+    
+    if [ -f ${IGCM_TMP}/${$}.date_${type_file}.txt ] ; then
+	join -v 1  ${IGCM_TMP}/${$}.toutes_dates ${IGCM_TMP}/${$}.date_${type_file}.txt > ${IGCM_DEM_SIMU}/${type_file}_manquant.list
+	
+        # On change le fichier ncrcat pour chaque date manquante en fichier tar
+	if [[ -f ${IGCM_DEM_SIMU}/${type_file}_manquant.list && -s ${IGCM_DEM_SIMU}/${type_file}_manquant.list ]]; then 
+	    for date in `awk '{print $0}' ${IGCM_DEM_SIMU}/${type_file}_manquant.list` ; do
+### AC : test si le fichier de list existe dans output_ncrcat (si non ca veut dire qu'il deja ete move dans output_tar) 
+		nb_files=$(ls ${OUTPUT_NCRCAT} | grep ${JobName} | grep "${type_file}.list" | wc -l )
+		if [ "x$nb_files" != "x0" ] ; then
+		    ls -l ${OUTPUT_NCRCAT}/${JobName}_*_${type_file}.list > ${IGCM_TMP}/${$}.liste_ncrcat
+		    for pack in $( awk '{print $9}' ${IGCM_TMP}/${$}.liste_ncrcat ) ; do 
+			extract_date_file=$( echo ${pack}       | sed -e "s%.*${JobName}_%%" )
+			date_debut=$( echo ${extract_date_file} | sed 's%\([0-9]\{8\}\)_.*$%\1%g'     | cut -c 1-6  )
+			date_fin=$(   echo ${extract_date_file} | sed 's%.*_\([0-9]\{8\}\)_.*$%\1%g' | cut -c 1-6  )
+			#on retire les eventuels zero pour eviter de tomber sur des dates de type 08 ou 09 
+			date=`echo $date|sed 's/^0*//'`
+			date_debut=`echo $date_debut|sed 's/^0*//'`
+			date_fin=`echo $date_fin|sed 's/^0*//'`
+			if [[ ${date} -ge ${date_debut} && ${date} -lt ${date_fin} ]]; then
+			    mv ${pack} ${OUTPUT_TAR}/.
+			    break 
+			else
+			    rm -f ${IGCM_DEM_SIMU}/${type_file}_manquant.list
+			fi
+		    done
+		fi
+		[[ "${clean_tmp}" = "yes" ]] && rm -f ${IGCM_TMP}/${$}.liste_ncrcat
+	    done
+	elif [[ -f ${IGCM_DEM_SIMU}/${type_file}_manquant.list && ! -s ${IGCM_DEM_SIMU}/${type_file}_manquant.list ]]; then
+	    rm -f ${IGCM_DEM_SIMU}/${type_file}_manquant.list
+	fi
+    fi
+    rm -f ${IGCM_DEM_SIMU}/${type_file}_manquant.list
+done
+
+DEM_write_state ${IGCM_DEM}/config_card.liste ${config_card} WriteListPackDone
+
+# gpdebug : le script n'a pas rencontre d'erreur. On l'inscrit dans le fichier de suivi
+simuMonitoring_OK "$MonitoringInfo" "$config_card"
+
+DEM_log -0 "Fin de ${SCRIPT_NAME}"
+
+exit
Index: TOOLS/SURPACK_IPSL/write_liste_tar.sh
===================================================================
--- TOOLS/SURPACK_IPSL/write_liste_tar.sh	(revision 2136)
+++ TOOLS/SURPACK_IPSL/write_liste_tar.sh	(revision 2136)
@@ -0,0 +1,56 @@
+#!/bin/bash
+
+#On decide d'archiver via tar une simulation entiere : 
+# - si elle est trop petite 
+# - si elle ne contient aucun fichier d'output correspondant a la norme etablie JobName_date 
+
+
+config_card=${1}
+
+# Declaration des variables
+
+# ----
+export JOB_DIR=${JOB_DIR:-${TMP_MIGR_DATA}}
+export IGCM_DEM=${IGCM_DEM:-${SCRATCHDIR}/IGCM_DEM}
+export IGCM_TMP=${IGCM_TMP:-${IGCM_DEM}/tmp}
+mkdir -p ${IGCM_DEM}
+mkdir -p ${IGCM_TMP}
+clean_tmp=${clean_tmp:-yes}
+EXE_DIR=$(dirname ${0} )
+SCRIPT_NAME=$(basename ${0} )
+source ${EXE_DIR}/DEM_utilities.sh
+DEM_log -0 "Demmarrage de ${SCRIPT_NAME}"
+cd ${JOB_DIR}
+# ----
+DEM_log -0 "Debut de ${SCRIPT_NAME}"
+DEM_log -0 "On va archiver via tar la simulation " ${PATH_SIMUL_FULL}
+DEM_log -0 "config_card : ${config_card}"
+
+eval $(grep JobName         ${config_card}) 
+eval $(grep PATH_SIMUL_FULL ${config_card}) 
+eval $(grep DateBegin       ${config_card}) 
+eval $(grep DateEnd         ${config_card}) 
+eval $(grep IGCM_DEM_SIMU   ${config_card})
+
+
+echo  ${PATH_SIMUL_FULL} > ${IGCM_DEM_SIMU}/tar_full_simul.list
+
+# Dans ce cas la on efface les eventuelles listes deja creees
+rm -f ${IGCM_DEM_SIMU}/tar_no_output_files.txt
+rm -f ${IGCM_DEM_SIMU}/tar_no_restart_files.txt
+
+
+# gpdebug : traitement des simu < 1 Go ou de type create_etat0 : il faut virer ces rep 
+#           (et pas slt leur contenu) pour pouvoir integrer le traitement specifique 
+#           de ces simu dans "enlarge_my_files.sh" (sequentiel) et  "process_list.sh" (parallele)
+# rm -f ${IGCM_DEM_SIMU}/work_cp/*
+# rm -f ${IGCM_DEM_SIMU}/store_cp/*
+# rm -f ${IGCM_DEM_SIMU}/other_tar/*
+
+rm -rf ${IGCM_DEM_SIMU}/work_cp
+rm -rf ${IGCM_DEM_SIMU}/store_cp
+rm -rf ${IGCM_DEM_SIMU}/other_tar
+
+DEM_write_state ${IGCM_DEM}/config_card.liste ${config_card} WriteListTarDone
+
+DEM_log -0 "Fin de ${SCRIPT_NAME}"
