Index: trunk/libIGCM/AA_RunChecker
===================================================================
--- trunk/libIGCM/AA_RunChecker	(revision 755)
+++ trunk/libIGCM/AA_RunChecker	(revision 756)
@@ -29,7 +29,11 @@
   unset SUBMIT_DIR
 
-  if ( $fg_path ) ; then
-    set -A FileList
-    FileList=$( ls ${ConfigPath}/Job_* )
+  fg_new=false
+
+  NbOcc=$( awk -v JobName=${JobName} \
+           'BEGIN {x=0}  $1 ~ JobName {++x} END {print x}' ${SimuCatalog} )
+
+  if ( [ ${NbOcc} -eq 0 ] && ( $fg_path ) ) ; then
+    set -A FileList $( ls ${ConfigPath}/Job_* )
     if [ X$FileList == X ] ; then
       NbOcc=0
@@ -38,10 +42,7 @@
       fg_new=true
     fi
-  else
-    NbOcc=$( awk -v JobName=${JobName} \
-             'BEGIN {x=0}  $1 ~ JobName {++x} END {print x}' ${SimuCatalog} )
-  fi
-
-  if ( [ ${NbOcc} -eq 0 ] && ( ${fg_new} ) ) ; then
+  fi
+
+  if ( [ ${NbOcc} -eq 0 ] && ( ${fg_search} ) ) ; then
     SEARCH_DIR=${WORKDIR}
     if [ ${TargetUsr} != ${CurrentUsr} ] ; then
@@ -50,10 +51,10 @@
     echo "${JobName} not in Catalog, we'll try to find it in ${SEARCH_DIR}"
 
-    set -A FileList
-    FileList=$( find ${SEARCH_DIR}/ -name "Job_${JobName}" )
+    set -A FileList $( find ${SEARCH_DIR}/ -name "Job_${JobName}" )
     if [ X$FileList == X ] ; then
       NbOcc=0
     else
       NbOcc=${#FileList[@]}
+      fg_new=true
     fi
   fi
@@ -62,7 +63,7 @@
     0)
       echo "${JobName} not found."
-      echo "You can try : '-n' option to automatically search your \$WORKDIR, "
-      echo "              '-p' option to provide the config.card path, "
-      echo "               manually editing your ${SimuCatalog}"
+      echo "You can try : *) '-s' option to automatically search your \$WORKDIR, "
+      echo "              *) '-p' option to provide the config.card path, "
+      echo "              *)  manually editing your ${SimuCatalog}"
       exit ;;
     1)
@@ -261,5 +262,5 @@
 
 fg_color=true
-fg_new=false
+fg_search=false
 fg_quiet=false
 fg_path=false
@@ -279,5 +280,5 @@
       echo "  -q : quiet"
       echo "  -j : print n post-processing jobs (default is 10)"
-      echo "  -n : look for a new job in \$WORKDIR and fill in "
+      echo "  -s : search for a new job in \$WORKDIR and fill in "
       echo "       the catalog before printing information"
       echo "  -p : give the config.card path to a new simulation, "
@@ -287,6 +288,6 @@
 #      fg_color=false
 #      shift 1 ;;
-    -n|-new)
-      fg_new=true
+    -s|-search)
+      fg_search=true
       shift 1 ;;
     -q|-quiet)
@@ -311,6 +312,11 @@
 done
 
-if ( [ ! $fg_path ] && [ $# -lt 1 ] ) ; then
+if ( ( ! $fg_path ) && [ $# -lt 1 ] ) ; then
   $0 -h
+  exit
+fi
+
+if ( ( ${fg_path} ) && ( ${fg_search} ) ) ; then
+  echo "You cannot use -s and -p at the same time"
   exit
 fi
@@ -473,12 +479,17 @@
   #Â Check jobs
   # ----------
+  NbLines=0
   for JobType in ${JobType_list[*]} ; do 
     eval String=\${${JobType}_String}
     eval Field=\${${JobType}_Field}
 
-    FileList=$( ls ${POST_DIR}/${JobType}.*.out | tail -n ${NbHisto} )
+    set -A FileList $( ls ${POST_DIR}/${JobType}.*.out | tail -n ${NbHisto} )
+
+    if [ ${#FileList[*]} -gt ${NbLines} ] ; then
+      NbLines=${#FileList[*]}
+    fi
 
     (( ind = 0 ))
-    for FileName in ${FileList} ; do
+    for FileName in ${FileList[*]} ; do
       LastDate=$( basename ${FileName} | awk -F"." '{ print $(NF-1) }' )
 
@@ -503,18 +514,26 @@
   # ==========================
   JobType=monitoring
-  LastDate=$( cdo showyear ${CWORK_DIR}/MONITORING/files/ATM_bils_global_ave.nc 2> /dev/null | \
-                  awk '{ print $NF }' )
-  eval ${JobType}_Date=${LastDate}
+  if [ -d ${CWORK_DIR}/MONITORING ] ; then
+    LastDate=$( cdo showyear ${CWORK_DIR}/MONITORING/files/ATM_bils_global_ave.nc 2> /dev/null | \
+                    awk '{ print $NF }' )
+    eval ${JobType}_Date=${LastDate}
+  fi
 
   # Check last ATLAS jobs
   # =====================
   JobType=atlas
-  FileList=$( ls ${CWORK_DIR}/ATLAS | tail -n ${NbHisto} )
-
-  (( ind = 0 ))
-  for FileName in ${FileList} ; do
-    eval ${JobType}_Date[$ind]=${FileName}
-    (( ind = ind + 1 ))
-  done
+  if [ -d ${CWORK_DIR}/ATLAS ] ; then
+    set -A FileList $( ls ${CWORK_DIR}/ATLAS | tail -n ${NbHisto} )
+
+    if [ ${#FileList[*]} -gt ${NbLines}=0 ] ; then
+      NbLines=${#FileList[*]}
+    fi
+
+    (( ind = 0 ))
+    for FileName in ${FileList[*]} ; do
+      eval ${JobType}_Date[$ind]=${FileName}
+      (( ind = ind + 1 ))
+    done
+  fi
 
 
@@ -528,5 +547,5 @@
   AffichResult -f
   ind=0
-  while [ $ind -lt $NbHisto ] ; do
+  while [ $ind -lt $NbLines ] ; do
     AffichResult -j
     (( ind = ind + 1 ))
