Index: trunk/libIGCM/libIGCM_sys/libIGCM_sys_obelix.ksh
===================================================================
--- trunk/libIGCM/libIGCM_sys/libIGCM_sys_obelix.ksh	(revision 782)
+++ trunk/libIGCM/libIGCM_sys/libIGCM_sys_obelix.ksh	(revision 800)
@@ -64,7 +64,7 @@
 # Host and user names
 # $hostname ou hostname
-typeset HOST=${HOST:=$( hostname )}
+typeset  HOST=${HOST:=$( hostname )}
 # $username ou whoami
-typeset LOGIN=${LOGIN:=$( whoami )}
+typeset  LOGIN=${LOGIN:=$( whoami )}
 # $hostname of the MASTER job
 typeset MASTER=${MASTER:=$( hostname )}
@@ -111,16 +111,4 @@
 
 #====================================================
-#- SCRATCHDIR (=> ${R_DONNEES})
-if [ X${PBS_O_WORKDIR} != X ] ; then
-  typeset -r SCRATCHDIR=/scratch/$PBS_O_LOGNAME.$PBS_JOBID
-#==${WORKDIR}
-# cf /usr/Local/Env sur obelix
-else
-  typeset -r SCRATCHDIR=/tmp
-fi
-#FOR DEBUG RUN :
-#typeset -r SCRATCHDIR=/home/scratch01/${LOGIN}
-
-#====================================================
 #- SUBMIT_DIR : submission dir
 if [ X${PBS_O_WORKDIR} != X ] ; then
@@ -136,38 +124,33 @@
 #====================================================
 #- ARCHIVE (dedicated to large files)
-typeset -r ARCHIVE=${ARCHIVE:=/home/scratch01/${LOGIN}}
+typeset ARCHIVE=${ARCHIVE:=/home/scratch01/${LOGIN}}
 
 #====================================================
 #- STORAGE (dedicated to small/medium files)
-typeset -r STORAGE=${ARCHIVE}
+typeset STORAGE=${ARCHIVE}
 
 #====================================================
 #- R_OUT
-typeset -r R_OUT=${ARCHIVE}/IGCM_OUT
+typeset R_OUT=${ARCHIVE}/IGCM_OUT
 
 #====================================================
 #- R_FIG (hosting figures : monitoring and atlas, and/or small files)
-typeset -r R_FIG=${STORAGE}/IGCM_OUT
+typeset R_FIG=${STORAGE}/IGCM_OUT
 
 #====================================================
 #- R_BUF (ONLY FOR double copy an scratch)
-typeset -r R_BUF=/home/scratch01/${LOGIN}/IGCM_OUT
+typeset -r R_BUF=${STORAGE}/IGCM_OUT
 
 #====================================================
 #- BIG_DIR : BIG_DIR to store files waiting for rebuild
-typeset -r BIG_DIR=${BIG_DIR:=${SCRATCHDIR}/REBUILD}
+typeset -r BIG_DIR=${BIG_DIR:=${STORAGE}/REBUILD}
 
 #====================================================
 #- RUN_DIR_PATH : Temporary working directory (=> TMP)
-typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=${SCRATCHDIR}/tmp$$}
+typeset -r RUN_DIR_PATH=${RUN_DIR_PATH:=/scratch/$PBS_O_LOGNAME.$PBS_JOBID}
 
 #====================================================
 #- HOST_MPIRUN_COMMAND
 typeset -r HOST_MPIRUN_COMMAND=${HOST_MPIRUN_COMMAND:="time mpirun"}
-
-#=========================================================
-#- Add "time" before mpirun command
-MPIRUN_COMMAND="time "${MPIRUN_COMMAND}
-echo ${MPIRUN_COMMAND}
 
 #====================================================
@@ -201,9 +184,5 @@
 #D-#==================================================
 #D-function IGCM_sys_RshMaster
-#D-* Purpose: Just a fake command to wrapp
-#D-           IGCM_card call in post-treatment
-#D-           Ulam do not see brodie filesystem
-#D-           Cesium do not see all mercure filesystem
-#D-           That's why we need this hack.
+#D-* Purpose: Connection to frontend machine.
 #D-* Examples:
 #D-
@@ -246,5 +225,4 @@
 #D-* Examples:
 #D-
-(( RshPNum = 0 ))
 function IGCM_sys_RshPost {
   IGCM_debug_PushStack "IGCM_sys_RshPost" $@
@@ -252,10 +230,19 @@
     echo "IGCM_sys_RshPost :" $@
   fi
-  ssh obelix3 exec /bin/ksh $@ > out_RshPost.${RshPNum}
+
+  #echo cat tmp_IGCM_sys_RshPost_$$ INITIAL
+  #cat tmp_IGCM_sys_RshPost_$$
+  # keep standard input (stdin) for the loop onto temporary file
+  cat >tmp_IGCM_sys_RshPost_$$
+
+# ============ FRONTEND START ============ #
+
+    ssh obelix3 exec /bin/ksh <tmp_IGCM_sys_RshPost_$$
   if [ $? -gt 0 ] ; then
     echo "IGCM_sys_RshPost : erreur."
     IGCM_debug_Exit "IGCM_sys_RshPost"
   fi
-  (( RshPNum = RshPNum + 1 ))
+  # delete temporary file
+  \rm tmp_IGCM_sys_RshPost_$$
   IGCM_debug_PopStack "IGCM_sys_RshPost"
 }
@@ -285,4 +272,6 @@
   Job ended   : ${DateEnd}
   Output files are available in ${R_SAVE}
+  Files to be rebuild are temporarily available in ${REBUILD_DIR}
+  Pre-packed files are temporarily available in ${R_BUFR}
   Script files, Script Outputs and Debug files (if necessary) are available in ${SUBMIT_DIR}
 END_MAIL
@@ -461,4 +450,22 @@
 
 #D-#==================================================
+#D-function IGCM_sys_IsFileArchived
+#D-* Purpose: Test file that must NOT EXISTS on Archive
+#D-* Examples:
+#D-
+function IGCM_sys_IsFileArchived {
+  IGCM_debug_PushStack "IGCM_sys_IsFileArchived" $@
+  if ( $DEBUG_sys ) ; then
+    echo "IGCM_sys_IsFileArchived :" $@
+  fi
+  typeset IsArchivedFlag
+  # Never archived for this system
+  IsArchivedFlag=1
+  IGCM_debug_PopStack "IGCM_sys_IsFileArchived"
+
+  return ${IsArchivedFlag}
+}
+
+#D-#==================================================
 #D-function IGCM_sys_TestFileArchive
 #D-* Purpose: Test file that must NOT EXISTS on Archive
@@ -578,5 +585,4 @@
     echo "IGCM_sys_Qsub :" $@
   fi
-#    /usr/local/bin/qsub -q short -o ${Script_Output} -N ${config_UserChoices_JobName}.${CumulPeriod} < $1
   /usr/local/bin/qsub -q medium -o ${Script_Output} -N ${config_UserChoices_JobName}.${CumulPeriod} < $1
   if [ $? -gt 0 ] ; then
@@ -1263,5 +1269,5 @@
   eval ${2}=${dateF[5]}
 
-    # donne la date filesys d'un fichier sur la machine work
+  # donne la date filesys d'un fichier sur la machine work
   IGCM_debug_PopStack "IGCM_sys_FichWork"
 }
@@ -1350,5 +1356,5 @@
   list_opt=$@
 
-  # Invert Axis : t,x -> x,t 
+  # Invert Axis : t,x -> x,t
   #               t,pres,x -> x,t,pres
   # So that we can concatenate along x
@@ -1413,5 +1419,5 @@
 #      j3=${proc_stn[${iStation}]}
       # Extract station
-      # Invert Axis : t,x -> x,t 
+      # Invert Axis : t,x -> x,t
       #               t,pres,x -> x,t,pres
       # So that we can concatenate along x
@@ -1456,5 +1462,5 @@
 
 ############################################################
-# Build run file
+# Build MPI/OMP scripts run file (dummy function)
 
 function IGCM_sys_build_run_file {
@@ -1737,5 +1743,4 @@
 # NCO OPERATOR
 
-
 function IGCM_sys_ncap2 {
   IGCM_debug_PushStack "IGCM_sys_ncap2" -- $@
@@ -1759,4 +1764,5 @@
       \rm out_rsync
       IGCM_debug_Print 2 "IGCM_sys_ncap2 : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
     else
       \rm out_rsync
@@ -1795,4 +1801,5 @@
       \rm out_rsync
       IGCM_debug_Print 2 "IGCM_sys_ncatted : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
     else
       \rm out_rsync
@@ -1831,4 +1838,5 @@
       \rm out_rsync
       IGCM_debug_Print 2 "IGCM_sys_ncbo : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
     else
       \rm out_rsync
@@ -1867,4 +1875,5 @@
       \rm out_rsync
       IGCM_debug_Print 2 "IGCM_sys_ncdiff : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
     else
       \rm out_rsync
@@ -1903,4 +1912,5 @@
       \rm out_rsync
       IGCM_debug_Print 2 "IGCM_sys_ncea : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
     else
       \rm out_rsync
@@ -1939,4 +1949,5 @@
       \rm out_rsync
       IGCM_debug_Print 2 "IGCM_sys_ncecat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
     else
       \rm out_rsync
@@ -1975,4 +1986,5 @@
       \rm out_rsync
       IGCM_debug_Print 2 "IGCM_sys_ncflint : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
     else
       \rm out_rsync
@@ -2011,4 +2023,5 @@
       \rm out_rsync
       IGCM_debug_Print 2 "IGCM_sys_ncks : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
     else
       \rm out_rsync
@@ -2047,4 +2060,5 @@
       \rm out_rsync
       IGCM_debug_Print 2 "IGCM_sys_ncpdq : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
     else
       \rm out_rsync
@@ -2083,4 +2097,5 @@
       \rm out_rsync
       IGCM_debug_Print 2 "IGCM_sys_ncra : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
     else
       \rm out_rsync
@@ -2119,4 +2134,5 @@
       \rm out_rsync
       IGCM_debug_Print 2 "IGCM_sys_ncrcat : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
     else
       \rm out_rsync
@@ -2155,4 +2171,5 @@
       \rm out_rsync
       IGCM_debug_Print 2 "IGCM_sys_ncrename : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
     else
       \rm out_rsync
@@ -2191,4 +2208,5 @@
       \rm out_rsync
       IGCM_debug_Print 2 "IGCM_sys_ncwa : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+      sleep $DELAI
     else
       \rm out_rsync
