Index: trunk/libIGCM/libIGCM_sys/libIGCM_sys_iitm.ksh
===================================================================
--- trunk/libIGCM/libIGCM_sys/libIGCM_sys_iitm.ksh	(revision 1179)
+++ trunk/libIGCM/libIGCM_sys/libIGCM_sys_iitm.ksh	(revision 1180)
@@ -64,9 +64,9 @@
 # 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
-ntypeset -r MASTER=iitm01
+typeset MASTER=iitm01
 
 #D-
@@ -86,12 +86,8 @@
 
 #====================================================
-# Source default environment
+# Set environment tools (ferret, nco, cdo, rebuild, ...)
 #====================================================
-##. /etc/profile
-
-#====================================================
-# Set environment tools (ferret, nco, cdo)
-#====================================================
-# Not applicable here
+# Not applicable here. Only rebuild path
+export export PATH=${PATH}:/gpfs1/home/sebastien/REBUILD/
 
 #====================================================
@@ -100,5 +96,5 @@
 
 #====================================================
-#- Mirror libIGCM from iitm to a post-processing machine
+#- MirrorlibIGCM for frontend
 typeset -r MirrorlibIGCM=${MirrorlibIGCM:=false}
 
@@ -137,5 +133,5 @@
 
 #====================================================
-#- set PackDefault true on curie
+#- set PackDefault to false on iitm
 PackDefault=false
 
@@ -210,14 +206,10 @@
 #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-
 function IGCM_sys_RshMaster {
   IGCM_debug_PushStack "IGCM_sys_RshMaster" $@
-  /bin/ksh <<-EOF
+  OUTCOMMAND_PATH=${OUTCOMMAND_PATH} /bin/ksh <<-EOF
     export libIGCM=${libIGCM}
     export DEBUG_debug=${DEBUG_debug}
@@ -252,4 +244,18 @@
 
 #D-#==================================================
+#D-function IGCM_sys_RshArchive_NoError
+#D-* Purpose: Archive rsh command, without error
+#D-*          used only in monitoring.job
+#D-* Examples:
+#D-
+function IGCM_sys_RshArchive_NoError {
+  IGCM_debug_PushStack "IGCM_sys_RshArchive_NoError" $@
+  /bin/ksh <<-EOF
+    ${@} 2> /dev/null
+EOF
+  IGCM_debug_PopStack "IGCM_sys_RshArchive_NoError"
+}
+
+#D-#==================================================
 #D-function IGCM_sys_RshPost
 #D-* Purpose: Post-process rsh command
@@ -261,9 +267,8 @@
     echo "IGCM_sys_RshPost :" $@
   fi
-
-  # keep standard input to keep it for postpone if ulam don't answer
-  cat >/tmp/tmp_IGCM_sys_RshPost_$$_${LOGNAME}
-
-  /bin/ksh </tmp/tmp_IGCM_sys_RshPost_$$_${LOGNAME}
+  # keep standard input (stdin) for the loop onto temporary file
+  cat >${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME}
+
+  OUTCOMMAND_PATH=${OUTCOMMAND_PATH} /bin/ksh <${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME}
   if [ $? -gt 0 ] ; then
     echo "IGCM_sys_RshPost : erreur."
@@ -271,5 +276,5 @@
   fi
   # delete temporary file
-  \rm /tmp/tmp_IGCM_sys_RshPost_$$_${LOGNAME}
+  \rm ${OUTCOMMAND_PATH}/tmp_IGCM_sys_RshPost_$$_${LOGNAME}
 
   IGCM_debug_PopStack "IGCM_sys_RshPost"
@@ -304,9 +309,9 @@
 
   if [ ! -z ${config_UserChoices_MailName} ] ; then
-    mailx -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} < mail.txt
+    mail -s "${config_UserChoices_JobName} ${status}" ${config_UserChoices_MailName} < mail.txt
   elif [ -f ~/.forward ] ; then
-    mailx -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < mail.txt
+    mail -s "${config_UserChoices_JobName} ${status}" $( cat ~/.forward ) < mail.txt
   else
-    mailx -s "${config_UserChoices_JobName} ${status}" ${USER} < mail.txt
+    mail -s "${config_UserChoices_JobName} ${status}" ${USER} < mail.txt
   fi
 
@@ -353,10 +358,12 @@
   fi
   #- creation de repertoire sur le serveur fichier
-  mkdir -p $1
-  status=$?
-
-  if [ ${status} -gt 0 ] ; then
-    IGCM_debug_Print 2 "IGCM_sys_MkdirArchive : mkdir failed error code ${status}"
-    IGCM_debug_Exit "IGCM_sys_MkdirArchive"
+  if [ ! -d ${1} ]; then
+    \mkdir -p $1
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_MkdirArchive : mkdir failed error code ${status}"
+      IGCM_debug_Exit "IGCM_sys_MkdirArchive"
+    fi
   fi
   IGCM_debug_PopStack "IGCM_sys_MkdirArchive"
@@ -473,5 +480,5 @@
 #D-#==================================================
 #D-function IGCM_sys_IsFileArchived
-#D-* Purpose: Test file that must NOT EXISTS on Archive
+#D-* Purpose: Test file that must NOT EXISTS on Archive based on filename only
 #D-* Examples:
 #D-
@@ -920,5 +927,4 @@
     fi
   fi
-
   IGCM_debug_PopStack "IGCM_sys_Mv"
 }
@@ -1080,5 +1086,5 @@
 
     if [ ${status} -gt 0 ] ; then
-      echo "IGCM_sys_Put_Rest : cp failed error code ${status}"
+      IGCM_debug_Print 2 "IGCM_sys_Put_Rest : cp failed error code ${status}"
       cat ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$
       IGCM_debug_Exit "IGCM_sys_Put_Rest"
@@ -1236,7 +1242,13 @@
       i=0
       while [ $i -lt $NB_ESSAI ] ; do
-        # USUAL WAY
-        \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
-        status=$?
+        if [ $( stat -c %d $1 ) -ne $( stat -c %d $( dirname $2 ) ) ] ; then
+          # USUAL WAY
+          \cp $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
+          status=$?
+        else
+          # NOT SO USUAL WAY
+          \mv $1 $2 > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
+          status=$?
+        fi
         if [ ${status} -gt 0 ]; then
           IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : cp failed error code ${status} ${i}/${NB_ESSAI}"
@@ -1507,5 +1519,5 @@
   i=0
   while [ $i -lt $NB_ESSAI ] ; do
-    /gpfs1/home/sebastien/REBUILD/rebuild -f -o $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
+    rebuild -f -o $@ > ${OUTCOMMAND_PATH}/out_command_${LOGIN}.$$ 2>&1
     status=$?
     if [ ${status} -gt 0 ] ; then
@@ -1583,4 +1595,5 @@
   #  0  118 110.0000000000000   87.46478873239437
   #  1  40  4.999999999999995   51.97183098591550
+
 #  typeset iStation iProc list_opt file_in file_out prefix_invert
 #  typeset -Z4 j4
@@ -1778,5 +1791,4 @@
 
         if ( ${OK_PARA_MPI} ) ; then
-
           (( mpi_count = 1 ))
           until [ ${mpi_count} -gt ${comp_proc_mpi_loc} ] ; do
@@ -1812,5 +1824,4 @@
 
         if ( ${OK_PARA_MPI} ) ; then
-
           (( mpi_count = 1 ))
           until [ ${mpi_count} -gt ${comp_proc_mpi_loc} ] ; do
@@ -1841,5 +1852,6 @@
     fi
 
-  else # Only one executable. launch it.
+  # Only one executable (SPMD mode).
+  else
 
     for comp in ${config_ListOfComponents[*]} ; do
@@ -2383,5 +2395,5 @@
   if [ ${status} -gt 0 ] ; then
     echo "IGCM_sys_ncrcat : ncrcat error"
-      #IGCM_debug_Exit "ncrcat"
+    #IGCM_debug_Exit "ncrcat"
   fi
 
