Index: /trunk/libIGCM/AA_RunChecker
===================================================================
--- /trunk/libIGCM/AA_RunChecker	(revision 752)
+++ /trunk/libIGCM/AA_RunChecker	(revision 752)
@@ -0,0 +1,420 @@
+#!/bin/ksh
+
+# Created by: S. Labetoulle
+# Date:       May 19th 2010
+#**************************************************************
+# Author: Sonia Labetoulle
+# Contact: sonia.labetoulle__at__ipsl.jussieu.fr
+# $Revision::                                          $ Revision of last commit
+# $Author::                                            $ Author of last commit
+# $Date::                                              $ Date of last commit
+# IPSL (2012)
+#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
+#
+#**************************************************************
+
+#======================================================================#
+
+# Display a report on how a simulation is faring.
+
+
+function SearchCatalog {
+
+  typeset num
+  unset SUBMIT_DIR
+
+  NbOcc=$( awk -v JobName=${JobName} \
+	   'BEGIN {x=0}  $1 ~ JobName {++x} END {print x}' ${SimuCatalog} )
+
+  if [ ${NbOcc} -eq 0 ] ; then
+    if [ X${fg_new} == X.true. ] ; then
+      echo "${JobName} not in Catalog, we'll try to find it in ${WORK_DIR}"
+      
+      set -A FileList
+      FileList=$( find ${WORK_DIR}/ -name "Job_${JobName}" )
+      echo $FileList
+      (( NbOcc = ${#FileList[@]} ))
+    else
+      echo "${JobName} not in Catalog."
+      echo "Use option -n / --new to look for it and add it to the catalog."
+      exit
+    fi
+  fi
+
+
+  if [ ${NbOcc} -eq 0 ] ; then
+    echo "${JobName} not found."
+    exit
+  else
+    if [ ${NbOcc} -eq 1 ] ; then
+
+      if ( [ ${UserName} == $( awk -v JobName=${JobName} '$1 ~ JobName {print $2}' ${SimuCatalog} ) ] && [ ${HostName} == $( awk -v JobName=${JobName} '$1 ~ JobName {print $3}' ${SimuCatalog} ) ] ) ; then
+        JobName=$( awk -v JobName=${JobName} '$1 ~ JobName {print $1}' ${SimuCatalog} )
+        UserName=$( awk -v JobName=${JobName} '$1 ~ JobName {print $2}' ${SimuCatalog} )
+        HostName=$( awk -v JobName=${JobName} '$1 ~ JobName {print $3}' ${SimuCatalog} )
+        SUBMIT_DIR=$( awk -v JobName=${JobName} '$1 ~ JobName {print $4}' ${SimuCatalog} )
+      else
+        echo "${JobName} not in Catalog."
+        exit
+      fi
+    fi
+  fi
+
+}
+
+
+function AffichResult {
+
+  fg_first=".false."
+  fg_last=".false."
+
+  while [ $# -ne 0 ] ; do
+    case ${1} in
+      -f|--first)
+	fg_first=".true."
+	shift 1 ;;
+      -l|--last)
+	fg_last=".true."
+	shift 1 ;;
+      -*)
+	echo "usage: ${0}"
+	echo "       options = -f; -l"
+	exit ;;
+      *)
+	break ;;
+    esac
+  done
+
+
+  # Define colors
+  ColEsc="\033["
+  ColNon="${ColEsc}0m"       # Return to normal
+  ColExp="${ColEsc}1m"       # Blanc - gras
+  ColFat="${ColEsc}1;31m"    # Fatal
+  ColCpl="${ColEsc}1;32m"    # Completed
+  ColAtt="${ColEsc}1;30m"    # Waiting
+  ColDef="${ColEsc}1;34m"    # Default
+  ColRbl="${ColEsc}31m"      # Rebuild
+
+
+  
+  if [ X${fg_first} == X.true. ] ; then
+    Dum=""
+    (( len = 67 - ${#JobName} ))
+    echo "|===========================================================================================================|"
+    printf "| JobName = ${ColExp}%-${#JobName}s${ColNon}" ${JobName}
+    printf "%-${len}s" ${Dum} 
+    printf "run.card : ${ColExp}%-17s${ColNon}|\n" "${LastWrite} "
+    echo "|-------------------------|-------------|-------------------------|-------------|-----:----------:----------|"
+    echo "|                         |             |                         |             |     Pending Rebuilds      |"
+    echo "| Date Begin - DateEnd    | PeriodState | Current Period          | CumulPeriod | Nb  : from     : to       |"
+    echo "|-------------------------|-------------|-------------------------|-------------|-----:----------:----------|"
+    return
+  fi
+
+  if [ X${fg_last} == X.true. ] ; then
+    printf "|===========================================================================================================|\n"
+    date +"${DateFormat}"
+    return
+  fi
+
+  printf "| %-10s - %-10s | " \
+	 $DateBegin $DateEnd 
+
+  case $PeriodState in
+    Fatal)
+      Color=${ColFat}
+      break ;;
+    Completed)
+      Color=${ColCpl}
+      break ;;
+    Waiting|OnQueue)
+      Color=${ColAtt}
+      break ;;
+    *)
+      Color=${ColDef}
+      break ;;
+  esac
+  printf "${Color}%-11s${ColNon} | " $PeriodState
+
+  printf "%-10s - %-10s | %11s | " \
+	 $PeriodDateBegin $PeriodDateEnd $CumulPeriod
+
+  if ( [ X${NbRebuild} != X. ] && [ X${NbRebuild} != X0 ] ) ; then
+    printf "${ColRbl}%3s : %-8s : %-8s${ColNon} |\n" \
+	   $NbRebuild $FirstRebuild $LastRebuild
+  else
+    printf "%3s : %-8s : %-8s |\n" \
+	   $NbRebuild $FirstRebuild $LastRebuild
+  fi
+
+  printf "|-----------------------------------------------------------------------------------------------------------|\n"
+  printf "|                                                      Last                                                 |\n"
+  printf "|     Rebuild      |   Pack_Output    |   Pack_Restart   |    Pack_Debug    |  Monitoring  |     Atlas      |\n"
+  printf "|------------------|------------------|------------------|------------------|--------------|----------------|\n"
+
+  if [ X${Result[1]} == XOK  ] ; then
+    Color=${ColCpl}
+  else
+    Color=${ColFat}
+  fi
+  printf "|     ${Color}%-8s${ColNon}     |" ${LastDate[1]}
+
+  if [ X${Result[2]} == XOK  ] ; then
+    Color=${ColCpl}
+  else
+    Color=${ColFat}
+  fi
+  printf "     ${Color}%-8s${ColNon}     |" ${LastDate[2]}
+
+  if [ X${Result[3]} == XOK  ] ; then
+    Color=${ColCpl}
+  else
+    Color=${ColFat}
+  fi
+  printf "     ${Color}%-8s${ColNon}     |" ${LastDate[3]}
+
+  if [ X${Result[4]} == XOK  ] ; then
+    Color=${ColCpl}
+  else
+    Color=${ColFat}
+  fi
+  printf "     ${Color}%-8s${ColNon}     |" ${LastDate[4]}
+
+  Color=${ColExp}
+  printf "     ${Color}%-4s${ColNon}     |  ${Color}%-12s${ColNon}  |\n" \
+	 ${LastDate[5]} ${LastDate[6]}
+}
+
+#======================================================================#
+
+#D- Task type (computing or post-processing)
+TaskType=post-processing
+
+libIGCM=${libIGCM:=::modipsl::/libIGCM}
+
+. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
+     ( ${DEBUG_debug} ) && IGCM_debug_Check
+. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
+     ( ${DEBUG_debug} ) && IGCM_card_Check
+. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
+     ( ${DEBUG_debug} ) && IGCM_date_Check
+#-------
+. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
+
+if ( [ $# -eq 0 ] ) ; then
+  $0 -h
+  exit
+fi
+
+# Default argument values
+UserName=$( whoami )
+HostName=$( hostname | sed -e "s/[0-9].*//" )
+
+fg_color=".true."
+fg_new=".false."
+fg_quiet=".false."
+
+# Get arguments from command line
+while [ $# -ne 0 ] ; do
+  case $1 in
+    -h|--help|-help)
+      echo "usage: $0 [-u UserName] JobName"
+      exit ;;
+    -b|--nocolor)
+      fg_color=".false."
+      shift 1 ;;
+    -n|--new)
+      fg_new=".true."
+      shift 1 ;;
+    -q|--quiet)
+      fg_quiet=".true."
+      shift 1 ;;
+    -p|--config-path)
+      ConfigPath="$2"
+      shift 2 ;;
+    -u|--user)
+      UserName="$2"
+      shift 2 ;;
+    -*)
+      $0 -h
+      exit ;;
+    *)
+      break ;;
+  esac
+done
+
+JobName=$1
+
+echo "UserName = ${UserName}"
+echo "HostName = ${HostName}"
+
+# Define useful directories
+SCRAT_DIR=$( ccc_home -s -u ${UserName} )
+STORE_DIR=$( ccc_home -A -u ${UserName} )
+CWORK_DIR=$( ccc_home -W -u ${UserName} )
+WORK_DIR=$( ccc_home -w -u ${UserName} )
+
+
+# Define the catalog in which the known simulations are stored
+SimuCatalog="$( ccc_home )/.simucatalog.dat"
+if [ ! -s ${SimuCatalog} ] ; then
+  touch ${SimuCatalog}
+fi
+
+# Date format
+DateFormat="%d/%m/%y %R:%S"
+
+# Find SUBMIT_DIR from catalog
+
+SearchCatalog
+
+# Go to SUBMIT_DIR 
+if [ ! X${SUBMIT_DIR} == X ] ; then
+
+  echo "Submit:  >${SUBMIT_DIR}<"
+  cd $SUBMIT_DIR
+
+
+# Extract usefull information from run.card and config.card
+
+  RunFile="${SUBMIT_DIR}/run.card"
+  ConfFile="${SUBMIT_DIR}/config.card"
+
+  if [ -s ${RunFile} ] ; then
+    IGCM_card_DefineVariableFromOption ${RunFile} Configuration PeriodState
+    PeriodState=${run_Configuration_PeriodState}
+  else
+    PeriodState="Waiting"
+  fi
+
+  if ( [ X${PeriodState} == XRunning ] || [ X${PeriodState} == XOnQueue ] ) ; then
+    NbRun=$( ccc_mstat -f | grep -c ${JobName} )
+
+    if [ ${NbRun} -eq 0 ] ; then
+      PeriodState="Fatal"
+    fi
+  fi
+
+  IGCM_card_DefineVariableFromOption ${ConfFile} UserChoices DateBegin
+  IGCM_card_DefineVariableFromOption ${ConfFile} UserChoices DateEnd
+  IGCM_card_DefineVariableFromOption ${ConfFile} UserChoices TagName
+  IGCM_card_DefineVariableFromOption ${ConfFile} UserChoices ExperimentName
+  IGCM_card_DefineVariableFromOption ${ConfFile} UserChoices SpaceName
+  DateBegin=${config_UserChoices_DateBegin}
+  DateEnd=${config_UserChoices_DateEnd}
+  TagName=${config_UserChoices_TagName}
+  ExperimentName=${config_UserChoices_ExperimentName}
+  SpaceName=${config_UserChoices_SpaceName}
+
+  IGCM_card_DefineVariableFromOption ${RunFile} Configuration CumulPeriod
+  CumulPeriod=${run_Configuration_CumulPeriod}
+
+  if ( [ ! X${PeriodState} == XWaiting ] && [ ! X${PeriodState} == XCompleted ] ) ; then
+    IGCM_card_DefineVariableFromOption ${RunFile} Configuration PeriodDateBegin
+    IGCM_card_DefineVariableFromOption ${RunFile} Configuration PeriodDateEnd
+    PeriodDateBegin=${run_Configuration_PeriodDateBegin}
+    PeriodDateEnd=${run_Configuration_PeriodDateEnd}
+  else
+    PeriodDateBegin="."
+    PeriodDateEnd="."
+  fi
+
+  if [ ! X${ExperimentName} == X ] ; then
+    EXP_DIR=IGCM_OUT/${TagName}/${SpaceName}/${ExperimentName}/${JobName}
+  else
+    EXP_DIR=IGCM_OUT/${TagName}/${JobName}
+  fi
+
+  DATA_DIR=${STORE_DIR}/${EXP_DIR}
+  POST_DIR=${SCRAT_DIR}/${EXP_DIR}/Out
+  CWORK_DIR=${CWORK_DIR}/${EXP_DIR}
+  REBUILD_DIR=${SCRAT_DIR}/REBUILD/${TagName}/${JobName}
+  echo "Data:    >${DATA_DIR}<"
+  echo "Rebuild: >${REBUILD_DIR}<"
+  echo "Post:    >${POST_DIR}<"
+  echo "Work:    >${CWORK_DIR}<"
+
+
+  if [ $PeriodState != "Waiting" ] ; then
+
+    # Check missing rebuilds
+
+    set -A RebuildList $( find ${REBUILD_DIR}/ -name "REBUILD_*" | sort )
+    if [ ${#RebuildList[*]} -gt 0 ] ; then
+      NbRebuild=$( IGCM_sys_CountFileArchive ${REBUILD_DIR} )
+
+      FirstRebuild=$( basename ${RebuildList[0]} | cut -f2 -d\_ )
+      LastRebuild=$( basename ${RebuildList[ (( NbRebuild=${NbRebuild}-1 )) ]} | cut -f2 -d\_ )
+    else
+      NbRebuild="."
+
+      FirstRebuild="."
+      LastRebuild="."
+    fi
+  else
+    NbRebuild="."
+
+    FirstRebuild="."
+    LastRebuild="."
+  fi
+
+  typeset -A LastDate Result
+
+  # Check last REBUILD
+  FileType=rebuild_*
+  (( num = 1 ))
+  LastDate[$num]=$( ls ${POST_DIR}/${FileType}.*.out | tail -n 1 | awk -F"." '{ print $2 }' )
+
+  dum=$( basename $( grep ^IGCM_sys_PutBuffer_Out ${POST_DIR}/${FileType}.${LastDate[$num]}.out | tail -1 | awk '{ print $4 }' ) | awk -F"_" '{ print $3 }' )
+
+  if [[ ${dum} == ${LastDate[$num]} ]] ; then
+    Result[$num]=OK
+  else
+    Result[$num]=KO
+  fi
+
+  # Check last PACK jobs
+  for FileType in pack_output pack_restart pack_debug ; do
+    (( num = num + 1 ))
+
+    LastDate[$num]=$( ls ${POST_DIR}/${FileType}.*.out | tail -n 1 | awk -F"." '{ print $2 }' )
+
+    dum=$( basename $( grep ^IGCM_sys_Put_Out ${POST_DIR}/${FileType}.${LastDate[$num]}.out | tail -1 | awk '{ print $3 }' ) | awk -F"_" '{ print $3 }' )
+
+    if [[ ${dum} == ${LastDate[$num]} ]] ; then
+      Result[$num]=OK
+    else
+      Result[$num]=KO
+    fi
+  done
+
+
+  # Check last MONITORING jobs
+
+  #set -vx
+
+  FileType=monitoring
+  (( num = num + 1 ))
+
+  LastDate[$num]=$( cdo showyear ${CWORK_DIR}/MONITORING/files/ATM_bils_global_ave.nc 2> /dev/null | awk '{ print $NF }' )
+
+  # Check last ATLAS jobs
+
+  FileType=atlas
+  (( num = num + 1 ))
+
+  LastDate[$num]=$( ls ${CWORK_DIR}/ATLAS | tail -1 )
+
+
+  # Time of last write on run.card
+  LastWrite=$( ls -l --time-style=+"${DateFormat}" ${SUBMIT_DIR}/run.card | awk '{print $6 " " $7}' )
+    
+
+  # Print results
+  AffichResult -f
+  AffichResult
+  AffichResult -l
+
+fi
+
Index: unk/libIGCM/RunChecker.job
===================================================================
--- /trunk/libIGCM/RunChecker.job	(revision 751)
+++ 	(revision )
@@ -1,420 +1,0 @@
-#!/bin/ksh
-
-# Created by: S. Labetoulle
-# Date:       May 19th 2010
-#**************************************************************
-# Author: Sonia Labetoulle
-# Contact: sonia.labetoulle__at__ipsl.jussieu.fr
-# $Revision::                                          $ Revision of last commit
-# $Author::                                            $ Author of last commit
-# $Date::                                              $ Date of last commit
-# IPSL (2012)
-#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
-#
-#**************************************************************
-
-#======================================================================#
-
-# Display a report on how a simulation is faring.
-
-
-function SearchCatalog {
-
-  typeset num
-  unset SUBMIT_DIR
-
-  NbOcc=$( awk -v JobName=${JobName} \
-	   'BEGIN {x=0}  $1 ~ JobName {++x} END {print x}' ${SimuCatalog} )
-
-  if [ ${NbOcc} -eq 0 ] ; then
-    if [ X${fg_new} == X.true. ] ; then
-      echo "${JobName} not in Catalog, we'll try to find it in ${WORK_DIR}"
-      
-      set -A FileList
-      FileList=$( find ${WORK_DIR}/ -name "Job_${JobName}" )
-      echo $FileList
-      (( NbOcc = ${#FileList[@]} ))
-    else
-      echo "${JobName} not in Catalog."
-      echo "Use option -n / --new to look for it and add it to the catalog."
-      exit
-    fi
-  fi
-
-
-  if [ ${NbOcc} -eq 0 ] ; then
-    echo "${JobName} not found."
-    exit
-  else
-    if [ ${NbOcc} -eq 1 ] ; then
-
-      if ( [ ${UserName} == $( awk -v JobName=${JobName} '$1 ~ JobName {print $2}' ${SimuCatalog} ) ] && [ ${HostName} == $( awk -v JobName=${JobName} '$1 ~ JobName {print $3}' ${SimuCatalog} ) ] ) ; then
-        JobName=$( awk -v JobName=${JobName} '$1 ~ JobName {print $1}' ${SimuCatalog} )
-        UserName=$( awk -v JobName=${JobName} '$1 ~ JobName {print $2}' ${SimuCatalog} )
-        HostName=$( awk -v JobName=${JobName} '$1 ~ JobName {print $3}' ${SimuCatalog} )
-        SUBMIT_DIR=$( awk -v JobName=${JobName} '$1 ~ JobName {print $4}' ${SimuCatalog} )
-      else
-        echo "${JobName} not in Catalog."
-        exit
-      fi
-    fi
-  fi
-
-}
-
-
-function AffichResult {
-
-  fg_first=".false."
-  fg_last=".false."
-
-  while [ $# -ne 0 ] ; do
-    case ${1} in
-      -f|--first)
-	fg_first=".true."
-	shift 1 ;;
-      -l|--last)
-	fg_last=".true."
-	shift 1 ;;
-      -*)
-	echo "usage: ${0}"
-	echo "       options = -f; -l"
-	exit ;;
-      *)
-	break ;;
-    esac
-  done
-
-
-  # Define colors
-  ColEsc="\033["
-  ColNon="${ColEsc}0m"       # Return to normal
-  ColExp="${ColEsc}1m"       # Blanc - gras
-  ColFat="${ColEsc}1;31m"    # Fatal
-  ColCpl="${ColEsc}1;32m"    # Completed
-  ColAtt="${ColEsc}1;30m"    # Waiting
-  ColDef="${ColEsc}1;34m"    # Default
-  ColRbl="${ColEsc}31m"      # Rebuild
-
-
-  
-  if [ X${fg_first} == X.true. ] ; then
-    Dum=""
-    (( len = 67 - ${#JobName} ))
-    echo "|===========================================================================================================|"
-    printf "| JobName = ${ColExp}%-${#JobName}s${ColNon}" ${JobName}
-    printf "%-${len}s" ${Dum} 
-    printf "run.card : ${ColExp}%-17s${ColNon}|\n" "${LastWrite} "
-    echo "|-------------------------|-------------|-------------------------|-------------|-----:----------:----------|"
-    echo "|                         |             |                         |             |     Pending Rebuilds      |"
-    echo "| Date Begin - DateEnd    | PeriodState | Current Period          | CumulPeriod | Nb  : from     : to       |"
-    echo "|-------------------------|-------------|-------------------------|-------------|-----:----------:----------|"
-    return
-  fi
-
-  if [ X${fg_last} == X.true. ] ; then
-    printf "|===========================================================================================================|\n"
-    date +"${DateFormat}"
-    return
-  fi
-
-  printf "| %-10s - %-10s | " \
-	 $DateBegin $DateEnd 
-
-  case $PeriodState in
-    Fatal)
-      Color=${ColFat}
-      break ;;
-    Completed)
-      Color=${ColCpl}
-      break ;;
-    Waiting|OnQueue)
-      Color=${ColAtt}
-      break ;;
-    *)
-      Color=${ColDef}
-      break ;;
-  esac
-  printf "${Color}%-11s${ColNon} | " $PeriodState
-
-  printf "%-10s - %-10s | %11s | " \
-	 $PeriodDateBegin $PeriodDateEnd $CumulPeriod
-
-  if ( [ X${NbRebuild} != X. ] && [ X${NbRebuild} != X0 ] ) ; then
-    printf "${ColRbl}%3s : %-8s : %-8s${ColNon} |\n" \
-	   $NbRebuild $FirstRebuild $LastRebuild
-  else
-    printf "%3s : %-8s : %-8s |\n" \
-	   $NbRebuild $FirstRebuild $LastRebuild
-  fi
-
-  printf "|-----------------------------------------------------------------------------------------------------------|\n"
-  printf "|                                                      Last                                                 |\n"
-  printf "|     Rebuild      |   Pack_Output    |   Pack_Restart   |    Pack_Debug    |  Monitoring  |     Atlas      |\n"
-  printf "|------------------|------------------|------------------|------------------|--------------|----------------|\n"
-
-  if [ X${Result[1]} == XOK  ] ; then
-    Color=${ColCpl}
-  else
-    Color=${ColFat}
-  fi
-  printf "|     ${Color}%-8s${ColNon}     |" ${LastDate[1]}
-
-  if [ X${Result[2]} == XOK  ] ; then
-    Color=${ColCpl}
-  else
-    Color=${ColFat}
-  fi
-  printf "     ${Color}%-8s${ColNon}     |" ${LastDate[2]}
-
-  if [ X${Result[3]} == XOK  ] ; then
-    Color=${ColCpl}
-  else
-    Color=${ColFat}
-  fi
-  printf "     ${Color}%-8s${ColNon}     |" ${LastDate[3]}
-
-  if [ X${Result[4]} == XOK  ] ; then
-    Color=${ColCpl}
-  else
-    Color=${ColFat}
-  fi
-  printf "     ${Color}%-8s${ColNon}     |" ${LastDate[4]}
-
-  Color=${ColExp}
-  printf "     ${Color}%-4s${ColNon}     |  ${Color}%-12s${ColNon}  |\n" \
-	 ${LastDate[5]} ${LastDate[6]}
-}
-
-#======================================================================#
-
-#D- Task type (computing or post-processing)
-TaskType=post-processing
-
-libIGCM=${libIGCM:=::modipsl::/libIGCM}
-
-. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
-     ( ${DEBUG_debug} ) && IGCM_debug_Check
-. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
-     ( ${DEBUG_debug} ) && IGCM_card_Check
-. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
-     ( ${DEBUG_debug} ) && IGCM_date_Check
-#-------
-. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
-
-if ( [ $# -eq 0 ] ) ; then
-  $0 -h
-  exit
-fi
-
-# Default argument values
-UserName=$( whoami )
-HostName=$( hostname | sed -e "s/[0-9].*//" )
-
-fg_color=".true."
-fg_new=".false."
-fg_quiet=".false."
-
-# Get arguments from command line
-while [ $# -ne 0 ] ; do
-  case $1 in
-    -h|--help|-help)
-      echo "usage: $0 [-u UserName] JobName"
-      exit ;;
-    -b|--nocolor)
-      fg_color=".false."
-      shift 1 ;;
-    -n|--new)
-      fg_new=".true."
-      shift 1 ;;
-    -q|--quiet)
-      fg_quiet=".true."
-      shift 1 ;;
-    -p|--config-path)
-      ConfigPath="$2"
-      shift 2 ;;
-    -u|--user)
-      UserName="$2"
-      shift 2 ;;
-    -*)
-      $0 -h
-      exit ;;
-    *)
-      break ;;
-  esac
-done
-
-JobName=$1
-
-echo "UserName = ${UserName}"
-echo "HostName = ${HostName}"
-
-# Define useful directories
-SCRAT_DIR=$( ccc_home -s -u ${UserName} )
-STORE_DIR=$( ccc_home -A -u ${UserName} )
-CWORK_DIR=$( ccc_home -W -u ${UserName} )
-WORK_DIR=$( ccc_home -w -u ${UserName} )
-
-
-# Define the catalog in which the known simulations are stored
-SimuCatalog="$( ccc_home )/.simucatalog.dat"
-if [ ! -s ${SimuCatalog} ] ; then
-  touch ${SimuCatalog}
-fi
-
-# Date format
-DateFormat="%d/%m/%y %R:%S"
-
-# Find SUBMIT_DIR from catalog
-
-SearchCatalog
-
-# Go to SUBMIT_DIR 
-if [ ! X${SUBMIT_DIR} == X ] ; then
-
-  echo "Submit:  >${SUBMIT_DIR}<"
-  cd $SUBMIT_DIR
-
-
-# Extract usefull information from run.card and config.card
-
-  RunFile="${SUBMIT_DIR}/run.card"
-  ConfFile="${SUBMIT_DIR}/config.card"
-
-  if [ -s ${RunFile} ] ; then
-    IGCM_card_DefineVariableFromOption ${RunFile} Configuration PeriodState
-    PeriodState=${run_Configuration_PeriodState}
-  else
-    PeriodState="Waiting"
-  fi
-
-  if ( [ X${PeriodState} == XRunning ] || [ X${PeriodState} == XOnQueue ] ) ; then
-    NbRun=$( ccc_mstat -f | grep -c ${JobName} )
-
-    if [ ${NbRun} -eq 0 ] ; then
-      PeriodState="Fatal"
-    fi
-  fi
-
-  IGCM_card_DefineVariableFromOption ${ConfFile} UserChoices DateBegin
-  IGCM_card_DefineVariableFromOption ${ConfFile} UserChoices DateEnd
-  IGCM_card_DefineVariableFromOption ${ConfFile} UserChoices TagName
-  IGCM_card_DefineVariableFromOption ${ConfFile} UserChoices ExperimentName
-  IGCM_card_DefineVariableFromOption ${ConfFile} UserChoices SpaceName
-  DateBegin=${config_UserChoices_DateBegin}
-  DateEnd=${config_UserChoices_DateEnd}
-  TagName=${config_UserChoices_TagName}
-  ExperimentName=${config_UserChoices_ExperimentName}
-  SpaceName=${config_UserChoices_SpaceName}
-
-  IGCM_card_DefineVariableFromOption ${RunFile} Configuration CumulPeriod
-  CumulPeriod=${run_Configuration_CumulPeriod}
-
-  if ( [ ! X${PeriodState} == XWaiting ] && [ ! X${PeriodState} == XCompleted ] ) ; then
-    IGCM_card_DefineVariableFromOption ${RunFile} Configuration PeriodDateBegin
-    IGCM_card_DefineVariableFromOption ${RunFile} Configuration PeriodDateEnd
-    PeriodDateBegin=${run_Configuration_PeriodDateBegin}
-    PeriodDateEnd=${run_Configuration_PeriodDateEnd}
-  else
-    PeriodDateBegin="."
-    PeriodDateEnd="."
-  fi
-
-  if [ ! X${ExperimentName} == X ] ; then
-    EXP_DIR=IGCM_OUT/${TagName}/${SpaceName}/${ExperimentName}/${JobName}
-  else
-    EXP_DIR=IGCM_OUT/${TagName}/${JobName}
-  fi
-
-  DATA_DIR=${STORE_DIR}/${EXP_DIR}
-  POST_DIR=${SCRAT_DIR}/${EXP_DIR}/Out
-  CWORK_DIR=${CWORK_DIR}/${EXP_DIR}
-  REBUILD_DIR=${SCRAT_DIR}/REBUILD/${TagName}/${JobName}
-  echo "Data:    >${DATA_DIR}<"
-  echo "Rebuild: >${REBUILD_DIR}<"
-  echo "Post:    >${POST_DIR}<"
-  echo "Work:    >${CWORK_DIR}<"
-
-
-  if [ $PeriodState != "Waiting" ] ; then
-
-    # Check missing rebuilds
-
-    set -A RebuildList $( find ${REBUILD_DIR}/ -name "REBUILD_*" | sort )
-    if [ ${#RebuildList[*]} -gt 0 ] ; then
-      NbRebuild=$( IGCM_sys_CountFileArchive ${REBUILD_DIR} )
-
-      FirstRebuild=$( basename ${RebuildList[0]} | cut -f2 -d\_ )
-      LastRebuild=$( basename ${RebuildList[ (( NbRebuild=${NbRebuild}-1 )) ]} | cut -f2 -d\_ )
-    else
-      NbRebuild="."
-
-      FirstRebuild="."
-      LastRebuild="."
-    fi
-  else
-    NbRebuild="."
-
-    FirstRebuild="."
-    LastRebuild="."
-  fi
-
-  typeset -A LastDate Result
-
-  # Check last REBUILD
-  FileType=rebuild_*
-  (( num = 1 ))
-  LastDate[$num]=$( ls ${POST_DIR}/${FileType}.*.out | tail -n 1 | awk -F"." '{ print $2 }' )
-
-  dum=$( basename $( grep ^IGCM_sys_PutBuffer_Out ${POST_DIR}/${FileType}.${LastDate[$num]}.out | tail -1 | awk '{ print $4 }' ) | awk -F"_" '{ print $3 }' )
-
-  if [[ ${dum} == ${LastDate[$num]} ]] ; then
-    Result[$num]=OK
-  else
-    Result[$num]=KO
-  fi
-
-  # Check last PACK jobs
-  for FileType in pack_output pack_restart pack_debug ; do
-    (( num = num + 1 ))
-
-    LastDate[$num]=$( ls ${POST_DIR}/${FileType}.*.out | tail -n 1 | awk -F"." '{ print $2 }' )
-
-    dum=$( basename $( grep ^IGCM_sys_Put_Out ${POST_DIR}/${FileType}.${LastDate[$num]}.out | tail -1 | awk '{ print $3 }' ) | awk -F"_" '{ print $3 }' )
-
-    if [[ ${dum} == ${LastDate[$num]} ]] ; then
-      Result[$num]=OK
-    else
-      Result[$num]=KO
-    fi
-  done
-
-
-  # Check last MONITORING jobs
-
-  #set -vx
-
-  FileType=monitoring
-  (( num = num + 1 ))
-
-  LastDate[$num]=$( cdo showyear ${CWORK_DIR}/MONITORING/files/ATM_bils_global_ave.nc 2> /dev/null | awk '{ print $NF }' )
-
-  # Check last ATLAS jobs
-
-  FileType=atlas
-  (( num = num + 1 ))
-
-  LastDate[$num]=$( ls ${CWORK_DIR}/ATLAS | tail -1 )
-
-
-  # Time of last write on run.card
-  LastWrite=$( ls -l --time-style=+"${DateFormat}" ${SUBMIT_DIR}/run.card | awk '{print $6 " " $7}' )
-    
-
-  # Print results
-  AffichResult -f
-  AffichResult
-  AffichResult -l
-
-fi
-
