Index: /trunk/libIGCM/AA_RunChecker
===================================================================
--- /trunk/libIGCM/AA_RunChecker	(revision 954)
+++ /trunk/libIGCM/AA_RunChecker	(revision 955)
@@ -16,5 +16,4 @@
 
 
-
 #======================================================================#
 
@@ -40,4 +39,5 @@
 fg_search=false
 fg_quiet=false
+fg_running=false
 fg_path=false
 NbHisto=20
@@ -45,5 +45,5 @@
 # Get arguments from command line
 # -------------------------------
-while getopts :hj:p:qsu: Opt ; do
+while getopts :hj:p:qsu:r Opt ; do
   case $Opt in
     h)
@@ -61,4 +61,5 @@
       echo "  -p : give the directory (absolute path) containing "
       echo "       the config.card instead of the job name."
+      echo "  -r : check all running simulations."
       exit 0 ;;
     j)
@@ -78,4 +79,7 @@
       TargetUsr=${OPTARG}
       ;;
+    r)
+      fg_running=true
+      ;;
     :)
       echo "$0: -"${OPTARG}" option: missing value"
@@ -90,4 +94,6 @@
 shift $(($OPTIND-1))
 
+# If no config.card path is given, and we're not looking for running simulations, 
+# at least one JobName must be given.
 if ( ( ! ${fg_path} ) && ( ! ${fg_running} ) && [ $# -lt 1 ] ) ; then
   $0 -h
@@ -121,5 +127,18 @@
 
 
-JobName=$1
+if ( ${fg_running} ) ; then
+  # Look for running simu
+  IGCM_sys_ListJobInQueue ${TargetUsr} JobNameList
+fi
+
+if [ $# -ge 1 ] ; then
+  set -A JobNameList ${JobNameList[*]} ${*}
+fi
+
+if [ ${#JobNameList[*]} -lt 1 ] ; then
+  echo "No running simulation found."
+  exit 0
+fi
+
 
 if ( ${fg_quiet} ) ; then
@@ -134,111 +153,117 @@
 fi
 
-# Find SUBMIT_DIR in catalog
-# ==========================
-IGCM_check_SearchCatalog
-
-if [ ! X${SUBMIT_DIR} == X ] ; then
-
-  IGCM_sys_Cd $SUBMIT_DIR
-
-
-  # Extract usefull information from run.card and config.card
-  # =========================================================
-
-  RunFile="${SUBMIT_DIR}/run.card"
-  ConfFile="${SUBMIT_DIR}/config.card"
-
-  IGCM_config_CommonConfiguration ${SUBMIT_DIR}/config.card
-  IGCM_check_CommonDef
-
-
-  if [ -s ${RunFile} ] ; then
-    IGCM_card_DefineVariableFromOption ${RunFile} Configuration PeriodState
-    PeriodState=${run_Configuration_PeriodState}
-  else
-    PeriodState="Waiting"
+
+for JobName in ${JobNameList[*]} ; do
+
+  # Find SUBMIT_DIR in catalog
+  # ==========================
+  IGCM_check_SearchCatalog
+  Status=$?
+
+  if [ $Status -eq 0 ] ; then
+
+    IGCM_sys_Cd $SUBMIT_DIR
+
+
+    # Extract usefull information from run.card and config.card
+    # =========================================================
+
+    RunFile="${SUBMIT_DIR}/run.card"
+    ConfFile="${SUBMIT_DIR}/config.card"
+
+    IGCM_config_CommonConfiguration ${SUBMIT_DIR}/config.card
+    IGCM_check_CommonDef
+
+
+    if [ -s ${RunFile} ] ; then
+      IGCM_card_DefineVariableFromOption ${RunFile} Configuration PeriodState
+      PeriodState=${run_Configuration_PeriodState}
+    else
+      PeriodState="Waiting"
+    fi
+
+    if ( [ X${PeriodState} == XRunning ] || [ X${PeriodState} == XOnQueue ] ) ; then
+      #NbRun=$( ccc_mstat -f | grep -c ${JobName} )
+      IGCM_sys_CountJobInQueue ${JobName} NbRun
+
+      if [ ${NbRun} -eq 0 ] ; then
+        PeriodState="Fatal"
+      fi
+    fi
+
+    DateBegin=${config_UserChoices_DateBegin}
+    DateEnd=${config_UserChoices_DateEnd}
+    TagName=${config_UserChoices_TagName}
+    ExperimentName=${config_UserChoices_ExperimentName}
+    SpaceName=${config_UserChoices_SpaceName}
+
+
+    if ( [ ! X${PeriodState} == XWaiting ] && [ ! X${PeriodState} == XCompleted ] ) ; then
+      IGCM_card_DefineVariableFromOption ${RunFile} Configuration PeriodDateBegin
+      IGCM_card_DefineVariableFromOption ${RunFile} Configuration PeriodDateEnd
+      IGCM_card_DefineVariableFromOption ${RunFile} Configuration CumulPeriod
+      PeriodDateBegin=${run_Configuration_PeriodDateBegin}
+      PeriodDateEnd=${run_Configuration_PeriodDateEnd}
+      CumulPeriod=${run_Configuration_CumulPeriod}
+    else
+      PeriodDateBegin="."
+      PeriodDateEnd="."
+      CumulPeriod="."
+    fi
+
+    DATA_DIR=${R_SAVE}
+    POST_DIR=${R_BUFR}/Out
+    CWORK_DIR=${R_FIGR}
+
+    if [ ${TargetUsr} != ${CurrentUsr} ] ; then
+      DATA_DIR=$( IGCM_check_ChangeUsr ${DATA_DIR} )
+      POST_DIR=$( IGCM_check_ChangeUsr ${POST_DIR} )
+      CWORK_DIR=$( IGCM_check_ChangeUsr ${CWORK_DIR} )
+      REBUILD_DIR=$( IGCM_check_ChangeUsr ${REBUILD_DIR} )
+    fi
+
+    if [ $PeriodState != "Waiting" ] ; then
+      # Check pending REBUILDS
+      # ======================
+      IGCM_check_CheckPendingRebuild
+
+      # Check last REBUILD and PACK* jobs
+      # =================================
+      IGCM_check_CheckRebPackJobs
+
+      # Check last MONITORING jobs
+      # ==========================
+      IGCM_check_CheckMonitoring
+
+      # Check last ATLAS jobs
+      # =====================
+      IGCM_check_CheckAtlas
+
+      # Time of last write on run.card
+      # ==============================
+      IGCM_sys_GetDate_FichWork ${SUBMIT_DIR}/run.card LastWrite "SplitFields" "${DateFormat}"
+
+    else
+
+      NbRebuild="."
+      FirstRebuild="."
+      LastRebuild="."
+
+      NbLines=0
+
+    fi
+
+
+    # Print results
+    # =============
+    IGCM_check_PrintHeader
+    ind=0
+    while [ $ind -lt $NbLines ] ; do
+      IGCM_check_PrintJob
+      (( ind = ind + 1 ))
+    done
+    IGCM_check_PrintFooter
+
   fi
 
-  if ( [ X${PeriodState} == XRunning ] || [ X${PeriodState} == XOnQueue ] ) ; then
-    #NbRun=$( ccc_mstat -f | grep -c ${JobName} )
-    IGCM_sys_CountJobInQueue ${JobName} NbRun
-
-    if [ ${NbRun} -eq 0 ] ; then
-      PeriodState="Fatal"
-    fi
-  fi
-
-  DateBegin=${config_UserChoices_DateBegin}
-  DateEnd=${config_UserChoices_DateEnd}
-  TagName=${config_UserChoices_TagName}
-  ExperimentName=${config_UserChoices_ExperimentName}
-  SpaceName=${config_UserChoices_SpaceName}
-
-
-  if ( [ ! X${PeriodState} == XWaiting ] && [ ! X${PeriodState} == XCompleted ] ) ; then
-    IGCM_card_DefineVariableFromOption ${RunFile} Configuration PeriodDateBegin
-    IGCM_card_DefineVariableFromOption ${RunFile} Configuration PeriodDateEnd
-    IGCM_card_DefineVariableFromOption ${RunFile} Configuration CumulPeriod
-    PeriodDateBegin=${run_Configuration_PeriodDateBegin}
-    PeriodDateEnd=${run_Configuration_PeriodDateEnd}
-    CumulPeriod=${run_Configuration_CumulPeriod}
-  else
-    PeriodDateBegin="."
-    PeriodDateEnd="."
-    CumulPeriod="."
-  fi
-
-  DATA_DIR=${R_SAVE}
-  POST_DIR=${R_BUFR}/Out
-  CWORK_DIR=${R_FIGR}
-
-  if [ ${TargetUsr} != ${CurrentUsr} ] ; then
-    DATA_DIR=$( IGCM_check_ChangeUsr ${DATA_DIR} )
-    POST_DIR=$( IGCM_check_ChangeUsr ${POST_DIR} )
-    CWORK_DIR=$( IGCM_check_ChangeUsr ${CWORK_DIR} )
-    REBUILD_DIR=$( IGCM_check_ChangeUsr ${REBUILD_DIR} )
-  fi
-
-  if [ $PeriodState != "Waiting" ] ; then
-    # Check pending REBUILDS
-    # ======================
-    IGCM_check_CheckPendingRebuild
-
-    # Check last REBUILD and PACK* jobs
-    # =================================
-    IGCM_check_CheckRebPackJobs
-
-    # Check last MONITORING jobs
-    # ==========================
-    IGCM_check_CheckMonitoring
-
-    # Check last ATLAS jobs
-    # =====================
-    IGCM_check_CheckAtlas
-
-    # Time of last write on run.card
-    # ==============================
-    LastWrite=$( ls -l --time-style=+"${DateFormat}" ${SUBMIT_DIR}/run.card | gawk '{print $6 " " $7}' )
-
-  else
-
-    NbRebuild="."
-    FirstRebuild="."
-    LastRebuild="."
-
-    NbLines=0
-
-  fi
-
-
-  # Print results
-  # =============
-  IGCM_check_PrintHeader
-  ind=0
-  while [ $ind -lt $NbLines ] ; do
-    IGCM_check_PrintJob
-    (( ind = ind + 1 ))
-  done
-  IGCM_check_PrintFooter
-
-fi
+done
Index: /trunk/libIGCM/libIGCM_check/libIGCM_check.ksh
===================================================================
--- /trunk/libIGCM/libIGCM_check/libIGCM_check.ksh	(revision 954)
+++ /trunk/libIGCM/libIGCM_check/libIGCM_check.ksh	(revision 955)
@@ -136,7 +136,5 @@
     SEARCH_DIR=${WORKDIR}
     if [ ${TargetUsr} != ${CurrentUsr} ] ; then
-      echo $SEARCH_DIR
       SEARCH_DIR=$( IGCM_check_ChangeUsr ${SEARCH_DIR} )
-      echo $SEARCH_DIR
     fi
     echo "${JobName} not in Catalog, we'll try to find it in ${SEARCH_DIR}"
@@ -163,5 +161,5 @@
     read Choice
     if [ X${Choice} == Xq ] ; then
-      exit
+      return 1
     else
       fg_new=true
@@ -173,10 +171,14 @@
   case ${NbOcc} in
     0)
-      echo "${JobName} not found."
+      if ( ${fg_search} ) ; then
+        echo "${JobName} not found, neither in catalog nor in \$WORKDIR."
+      else
+        echo "${JobName} not found in catalog."
+      fi
       echo "You can try : *) '-s' option to automatically search your \$WORKDIR ; "
       echo "              *) '-p' option to provide the directory (absolute path) "
       echo "                      containing the config.card ; "
       echo "              *)  manually editing your ${SimuCatalog}."
-      exit ;;
+      return 1 ;;
     1)
       if ( ${fg_new} ) ; then
@@ -197,5 +199,5 @@
       else
         echo "${JobName} not in Catalog."
-        exit
+        return 1
       fi
       ;;
Index: /trunk/libIGCM/libIGCM_sys/libIGCM_sys_ada.ksh
===================================================================
--- /trunk/libIGCM/libIGCM_sys/libIGCM_sys_ada.ksh	(revision 954)
+++ /trunk/libIGCM/libIGCM_sys/libIGCM_sys_ada.ksh	(revision 955)
@@ -1535,7 +1535,25 @@
     echo "IGCM_sys_GetDate_FichWork :" $@
   fi
+
+  if [ $# -ge 3 ] ; then
+    mode=$3
+    TimeStyle=$4
+  else
+    mode="default"
+    TimeStyle="%Y%m%d%H%M%S"
+  fi
+
   typeset dateF
-  set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} )
-  eval ${2}=${dateF[5]}
+  set +A dateF -- $( ls -l --full-time --time-style=+"${TimeStyle}" ${1} )
+
+  case $mode in
+    "default")
+      eval ${2}=${dateF[5]}
+      ;;
+    "SplitFields")
+      eval ${2}="${dateF[5]}\ ${dateF[6]}"
+      ;;
+  esac
+
 
   # donne la date filesys d'un fichier sur la machine work
@@ -2018,4 +2036,28 @@
 }
 
+#D-#==================================================
+#D-function IGCM_sys_ListJobInQueue
+#D-* Purpose: Check if job_name is currently
+#D-  running or in queue
+#D-* Examples: IGCM_sys_ListJobInQueue ${User} JobNameList
+#D-
+function IGCM_sys_ListJobInQueue {
+  IGCM_debug_PushStack "IGCM_sys_ListJobInQueue"
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ListJobInQueue"
+  fi
+
+  # With -f option, the full job name is given in the last column
+  set -A JobList $( llq -u $1 -W -f %jn | gawk '( $1 != /TS/      && \
+                                                  $1 !~ /PACK/    && \
+                                                  $1 !~ /REBUILD/ && \
+                                                  $1 !~ /pack/ )     \
+                                                { print $1 }' | sed -e "s/\(.*\)\.[0-9]*/\1/" )
+
+  eval set -A ${2} ${JobList[*]}
+
+  IGCM_debug_PopStack "IGCM_sys_ListJobInQueue"
+}
+
 ##############################################################
 # NCO OPERATOR
Index: /trunk/libIGCM/libIGCM_sys/libIGCM_sys_curie.ksh
===================================================================
--- /trunk/libIGCM/libIGCM_sys/libIGCM_sys_curie.ksh	(revision 954)
+++ /trunk/libIGCM/libIGCM_sys/libIGCM_sys_curie.ksh	(revision 955)
@@ -1682,7 +1682,25 @@
     echo "IGCM_sys_GetDate_FichWork :" $@
   fi
+
+  if [ $# -ge 3 ] ; then
+    mode=$3
+    TimeStyle=$4
+  else
+    mode="default"
+    TimeStyle="%Y%m%d%H%M%S"
+  fi
+
   typeset dateF
-  set +A dateF -- $( ls -l --full-time --time-style='+%Y%m%d%H%M%S' ${1} )
-  eval ${2}=${dateF[5]}
+  set +A dateF -- $( ls -l --full-time --time-style=+"${TimeStyle}" ${1} )
+
+  case $mode in
+    "default")
+      eval ${2}=${dateF[5]}
+      ;;
+    "SplitFields")
+      eval ${2}="${dateF[5]}\ ${dateF[6]}"
+      ;;
+  esac
+
 
   # donne la date filesys d'un fichier sur la machine work
@@ -2337,8 +2355,35 @@
   # With -f option, the full job name is given in the last column
   NbRun=$( ccc_mstat -f | gawk -v JobName=$1 'BEGIN { x=0 } ( $NF ~ JobName ) { x=x+1 } END { print x }' )
+  set -A JobID=
 
   eval ${2}=${NbRun}
 
   IGCM_debug_PopStack "IGCM_sys_CountJobInQueue"
+}
+
+#D-#==================================================
+#D-function IGCM_sys_ListJobInQueue
+#D-* Purpose: Check if job_name is currently
+#D-  running or in queue
+#D-* Examples: IGCM_sys_ListJobInQueue ${User} JobNameList
+#D-
+function IGCM_sys_ListJobInQueue {
+  IGCM_debug_PushStack "IGCM_sys_ListJobInQueue"
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_ListJobInQueue"
+  fi
+
+  # With -f option, the full job name is given in the last column
+  set -A JobList $( ccc_mstat -f | gawk -v User=$1             \
+                                        '( $2  == User      && \
+                                           $NF != /TS/      && \
+                                           $NF !~ /PACK/    && \
+                                           $NF !~ /REBUILD/ && \
+                                           $NF !~ /pack/ )     \
+                                         { print $NF }' | sed -e "s/\(.*\)\.[0-9]*/\1/" )
+
+  eval set -A ${2} ${JobList[*]}
+
+  IGCM_debug_PopStack "IGCM_sys_ListJobInQueue"
 }
 
