Index: /trunk/libIGCM/libIGCM_sys/libIGCM_sys_default.ksh
===================================================================
--- /trunk/libIGCM/libIGCM_sys/libIGCM_sys_default.ksh	(revision 716)
+++ /trunk/libIGCM/libIGCM_sys/libIGCM_sys_default.ksh	(revision 717)
@@ -522,5 +522,4 @@
     IGCM_debug_Exit "IGCM_sys_Tar"
   fi
-
   IGCM_debug_PopStack "IGCM_sys_Tar"
 }
@@ -711,15 +710,14 @@
   fi
 
-  typeset RET
-
-  echo cp --preserve=timestamps $@ > out_rsync 2>&1
-  \cp --preserve=timestamps $@ >> out_rsync 2>&1
-  RET=$?
-
-  if [ ${RET} -gt 0 ] ; then
-    echo ""
-#       echo "IGCM_sys_Cp : error."
-#       cat out_rsync
-#       IGCM_debug_Exit "IGCM_sys_Cp"
+  typeset status
+
+  echo cp $@ > out_rsync 2>&1
+  \cp $@ >> out_rsync 2>&1
+  status=$?
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_Cp : error code ${status}"
+    cat out_rsync
+    IGCM_debug_Exit "IGCM_sys_Cp"
   else
     \rm out_rsync
@@ -739,12 +737,12 @@
   fi
 
-  typeset RET
+  typeset status
 
   echo rm $@ > out_rsync 2>&1
   \rm $@ >> out_rsync 2>&1
-  RET=$?
-
-  if [ ${RET} -gt 0 ] ; then
-    echo "IGCM_sys_Rm : error."
+  status=$?
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_Rm : error code ${status}"
     cat out_rsync
     IGCM_debug_Exit "IGCM_sys_Rm"
@@ -784,12 +782,12 @@
   if [ $DRYRUN = 0 ]; then
 
-    typeset RET
+    typeset status
 
     echo mv $@ > out_rsync 2>&1
     \mv $@ >> out_rsync 2>&1
-    RET=$?
-
-    if [ ${RET} -gt 0 ] ; then
-      echo "IGCM_sys_Mv : error in mv."
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_Mv : error code ${status}"
       cat out_rsync
       IGCM_debug_Exit "IGCM_sys_Mv"
@@ -821,15 +819,15 @@
     fi
 
-    typeset RET
-
-        # Only if we use rsync
-        #IGCM_sys_TestDirArchive $( dirname $2 )
-        #
-        #USUAL WAY
-    \cp -R $1 $2 > out_rsync 2>&1
-    RET=$?
-
-    if [ ${RET} -gt 0 ] ; then
-      echo "IGCM_sys_Put_Dir : error."
+    typeset status
+
+    # Only if we use rsync
+    #IGCM_sys_TestDirArchive $( dirname $2 )
+    #
+    #USUAL WAY
+    \cp -r $1 $2 > out_rsync 2>&1
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_Put_Dir : error code ${status}"
       cat out_rsync
       IGCM_debug_Exit "IGCM_sys_Put_Dir"
@@ -845,5 +843,5 @@
 #D-#==================================================
 #D-function IGCM_sys_Get_Dir
-#D-* Purpose: Copy a complete directory from $(ARCHIVE)
+#D-* Purpose: Copy a complete directory from ${ARCHIVE}
 #D-* Examples:
 #D-
@@ -917,5 +915,5 @@
 #D-#==================================================
 #D-function IGCM_sys_Put_Rest
-#D-* Purpose: Put computied restarts on $(ARCHIVE).
+#D-* Purpose: Put computied restarts on ${ARCHIVE}.
 #D-           File and target directory must exist.
 #D-* Examples:
@@ -927,27 +925,36 @@
   fi
   if [ $DRYRUN = 0 ]; then
-
-    IGCM_sys_TestDirArchive $( dirname $2 )
-
     if [ ! -f ${1} ] ; then
       echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ."
       IGCM_debug_Exit "IGCM_sys_Put_Rest"
     fi
+
+    typeset status
+    #
     if [ X${JobType} = XRUN ] ; then
       IGCM_sys_Chmod 444 ${1}
     fi
 
-    typeset RET
-
-    echo ${RSYNC} ${RSYNC_opt} $1 $2 > out_rsync 2>&1
-    ${RSYNC} ${RSYNC_opt} $1 $2 >> out_rsync 2>&1
-    RET=$?
-    IGCM_sys_Rsync_out $RET
-
-    ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
-    (( RET=RET+$? ))
-
-    if [ ${RET} -gt 0 ] ; then
-      echo "IGCM_sys_Put_Rest : error."
+    #
+    # USUAL WAY
+    \cp $1 $2 > out_rsync 2>&1
+    status=$?
+
+#       #RSYNC WITH NETWORK SSH CALL
+#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1
+#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1
+
+#       #RSYNC WITH NFS USE
+#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
+#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
+
+#       status=$?
+#       IGCM_sys_Rsync_out $status
+
+#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
+#       (( status=status+$? ))
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_Put_Rest : cp failed error code ${status}"
       cat out_rsync
       IGCM_debug_Exit "IGCM_sys_Put_Rest"
@@ -978,5 +985,5 @@
     fi
 
-    typeset RET
+    typeset status
     #
     if [ X${JobType} = XRUN ] ; then
@@ -987,8 +994,8 @@
     # USUAL WAY
     \cp $1 $2 > out_rsync 2>&1
-    RET=$?
-
-    if [ ${RET} -gt 0 ] ; then
-      echo "IGCM_sys_PutBuffer_Rest : error."
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_PutBuffer_Rest : error code ${status}"
       cat out_rsync
       IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest"
@@ -1004,5 +1011,5 @@
 #D-#==================================================
 #D-function IGCM_sys_Put_Out
-#D-* Purpose: Copy a file on $(ARCHIVE) after have chmod it in readonly
+#D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly
 #D-* Examples:
 #D-
@@ -1114,5 +1121,5 @@
   if [ $DRYRUN -le 2 ]; then
     if [ X${1} = X'/l' ] ; then
-            # test if the first file is present in the old computation :
+      # test if the first file is present in the old computation :
       eval set +A dm_liste \${${2}}
     else
@@ -1145,6 +1152,7 @@
 
     if [ ${RET} -gt 0 ] ; then
-      echo "IGCM_sys_Get : copy error."
+      echo "IGCM_sys_Get : error"
       cat out_rsync
+      \rm out_rsync
       IGCM_debug_Exit "IGCM_sys_Get"
     else
@@ -1165,5 +1173,5 @@
   IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@
 
-  typeset DEST RET buf_liste ifile target file_work
+  typeset DEST RET status buf_liste ifile target file_work
 
   if ( $DEBUG_sys ) ; then
@@ -1189,10 +1197,11 @@
     else
       \cp ${buf_liste} ${DEST} >> out_rsync 2>&1
-      RET=$?
+      status=$?
     fi
 
     if [ ${RET} -gt 0 ] ; then
-      echo "IGCM_sys_GetBuffer : copy error."
+      echo "IGCM_sys_GetBuffer : error"
       cat out_rsync
+      \rm out_rsync
       IGCM_debug_Exit "IGCM_sys_GetBuffer"
     else
@@ -1242,5 +1251,5 @@
 #D-#==================================================
 #D-function IGCM_sys_Dods_Rm
-#D-* Purpose: Suppress files in /tmp/DODS for simulation of internet protocole.
+#D-* Purpose: DO NOTHING ! Put ${ARCHIVE} files on DODS internet protocole.
 #D-* Examples:
 #D-
@@ -1298,5 +1307,5 @@
   rebuild -f -o $@
   if [ $? -gt 0 ] ; then
-    echo "IGCM_sys_rebuild : erreur ${@}."
+    echo "IGCM_sys_rebuild : rebuild error"
     IGCM_debug_Exit "rebuild"
   fi
@@ -1700,5 +1709,4 @@
 # NCO OPERATOR
 
-
 function IGCM_sys_ncap2 {
   IGCM_debug_PushStack "IGCM_sys_ncap2" -- $@
Index: /trunk/libIGCM/libIGCM_sys/libIGCM_sys_mercure.ksh
===================================================================
--- /trunk/libIGCM/libIGCM_sys/libIGCM_sys_mercure.ksh	(revision 716)
+++ /trunk/libIGCM/libIGCM_sys/libIGCM_sys_mercure.ksh	(revision 717)
@@ -111,5 +111,5 @@
 #- IN
 typeset -r R_IN=${R_IN:=/ccc/work/cont003/dsm/p86ipsl/IGCM}
-typeset -r R_IN_ECMWF=${R_IN_ECMWF:=/dmnfs/cont003/p24data}
+typeset -r R_IN_ECMWF=${R_IN_ECMWF:=/ccc/work/cont003/dsm/p24data}
 
 #====================================================
@@ -674,12 +674,12 @@
   fi
 
-  typeset RET
+  typeset status
 
   echo cp $@ > out_rsync 2>&1
   \cp $@ >> out_rsync 2>&1
-  RET=$?
-
-  if [ ${RET} -gt 0 ] ; then
-    echo "IGCM_sys_Cp : error."
+  status=$?
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_Cp : error code ${status}"
     cat out_rsync
     IGCM_debug_Exit "IGCM_sys_Cp"
@@ -701,12 +701,12 @@
   fi
 
-  typeset RET
+  typeset status
 
   echo rm $@ > out_rsync 2>&1
   \rm $@ >> out_rsync 2>&1
-  RET=$?
-
-  if [ ${RET} -gt 0 ] ; then
-    echo "IGCM_sys_Rm : error."
+  status=$?
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_Rm : error code ${status}"
     cat out_rsync
     IGCM_debug_Exit "IGCM_sys_Rm"
@@ -746,12 +746,12 @@
   if [ $DRYRUN = 0 ]; then
 
-    typeset RET
+    typeset status
 
     echo mv $@ > out_rsync 2>&1
     \mv $@ >> out_rsync 2>&1
-    RET=$?
-
-    if [ ${RET} -gt 0 ] ; then
-      echo "IGCM_sys_Mv : error in mv."
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_Mv : error code ${status}"
       cat out_rsync
       IGCM_debug_Exit "IGCM_sys_Mv"
@@ -783,5 +783,5 @@
     fi
 
-    typeset RET
+    typeset status
 
     # Only if we use rsync
@@ -790,8 +790,8 @@
     #USUAL WAY
     \cp -r $1 $2 > out_rsync 2>&1
-    RET=$?
-
-    if [ ${RET} -gt 0 ] ; then
-      echo "IGCM_sys_Put_Dir : error."
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_Put_Dir : error code ${status}"
       cat out_rsync
       IGCM_debug_Exit "IGCM_sys_Put_Dir"
@@ -822,17 +822,32 @@
 #    fi
 
-    typeset RET
+    typeset NB_ESSAI DELAI status i
+    # number of tentative
+    NB_ESSAI=3
+    # time delay between tentative
+    DELAI=2
 
     # Only if we use rsync
     #IGCM_sys_TestDirArchive $( dirname $2 )
     #
-    #USUAL WAY
-    # add dmget (to demigrate all offline files) to reduce time of this command :
-    #dmget $1/*
+    # USUAL WAY
+    # add 'ccc_hsm get' (to demigrate all offline files) to reduce time of this command :
     ccc_hsm get -r $1
-    \cp -r $1 $2 > out_rsync 2>&1
-    RET=$?
-
-    if [ ${RET} -gt 0 ] ; then
+
+    i=0
+    while [ $i -lt $NB_ESSAI ] ; do
+      \cp -ur $1 $2 >> out_rsync 2>&1
+      status=$?
+      if [ ${status} -gt 0 ]; then
+        IGCM_debug_Print 2 "IGCM_sys_Get_Dir : cp failed error code ${status} ${i}/${NB_ESSAI}"
+        IGCM_debug_Print 2 "IGCM_sys_Get_Dir : sleep ${DELAI} seconds and try again."
+        sleep $DELAI
+      else
+        break
+      fi
+      (( i = i + 1 ))
+    done
+
+    if [ ${status} -gt 0 ] ; then
       echo "IGCM_sys_Get_Dir : error."
       cat out_rsync
@@ -864,11 +879,25 @@
     fi
 
-    typeset RET
-
-    #USUAL WAY
-    \cp -rL $1 $2 > out_rsync 2>&1
-    RET=$?
-
-    if [ ${RET} -gt 0 ] ; then
+    typeset NB_ESSAI DELAI status i
+    # number of tentative
+    NB_ESSAI=3
+    # time delay between tentative
+    DELAI=2
+
+    i=0
+    while [ $i -lt $NB_ESSAI ] ; do
+      \cp -urL $1 $2 > out_rsync 2>&1
+      status=$?
+      if [ ${status} -gt 0 ]; then
+        IGCM_debug_Print 2 "IGCM_sys_Get_Master : cp failed error code ${status} ${i}/${NB_ESSAI}"
+        IGCM_debug_Print 2 "IGCM_sys_Get_Master : sleep ${DELAI} seconds and try again."
+        sleep $DELAI
+      else
+        break
+      fi
+      (( i = i + 1 ))
+    done
+
+    if [ ${status} -gt 0 ] ; then
       echo "IGCM_sys_Get_Master : error."
       cat out_rsync
@@ -900,5 +929,5 @@
     fi
 
-    typeset RET
+    typeset status
     #
     if [ X${JobType} = XRUN ] ; then
@@ -909,5 +938,5 @@
     # USUAL WAY
     \cp $1 $2 > out_rsync 2>&1
-    RET=$?
+    status=$?
 
 #       #RSYNC WITH NETWORK SSH CALL
@@ -919,12 +948,12 @@
 #       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
 
-#       RET=$?
-#       IGCM_sys_Rsync_out $RET
+#       status=$?
+#       IGCM_sys_Rsync_out $status
 
 #       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
-#       (( RET=RET+$? ))
-
-    if [ ${RET} -gt 0 ] ; then
-      echo "IGCM_sys_Put_Rest : error."
+#       (( status=status+$? ))
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_Put_Rest : cp failed error code ${status}"
       cat out_rsync
       IGCM_debug_Exit "IGCM_sys_Put_Rest"
@@ -955,5 +984,5 @@
     fi
 
-    typeset RET
+    typeset status
     #
     if [ X${JobType} = XRUN ] ; then
@@ -964,8 +993,8 @@
     # USUAL WAY
     \cp $1 $2 > out_rsync 2>&1
-    RET=$?
-
-    if [ ${RET} -gt 0 ] ; then
-      echo "IGCM_sys_PutBuffer_Rest : error."
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_PutBuffer_Rest : error code ${status}"
       cat out_rsync
       IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest"
@@ -1055,5 +1084,5 @@
         status=$?
         if [ ${status} -gt 0 ]; then
-          IGCM_debug_Print 2 "IGCM_sys_Put_Out : cp failed ${i}/${NB_ESSAI}"
+          IGCM_debug_Print 2 "IGCM_sys_Put_Out : cp failed error code ${status} ${i}/${NB_ESSAI}"
           IGCM_debug_Print 2 "IGCM_sys_Put_Out : sleep ${DELAI} seconds and try again."
           sleep $DELAI
@@ -1153,5 +1182,5 @@
         status=$?
         if [ ${status} -gt 0 ]; then
-          IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : cp failed ${i}/${NB_ESSAI}"
+          IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : cp failed error code ${status} ${i}/${NB_ESSAI}"
           IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : sleep ${DELAI} seconds and try again."
           sleep $DELAI
@@ -1223,12 +1252,12 @@
 
     ccc_hsm get ${dm_liste[*]} > out_rsync 2>&1
-    RET=$?
-    if [ ${RET} -gt 0 ] ; then
-      echo "WARNING IGCM_sys_Get : demigration error."
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      echo "WARNING IGCM_sys_Get : error code ${status}"
       cat out_rsync
       echo "WARNING IGCM_sys_Get : will stop later if the cp fails."
     fi
 
-    #if [ ${RET} -gt 0 ] ; then
+    #if [ ${status} -gt 0 ] ; then
     #    if [ ! "X$( grep "Lost dmusrcmd connection" out_rsync )" = "X" ] ; then
     #	cat out_rsync
@@ -1238,6 +1267,6 @@
     ##	dmget ${dm_liste[*]} > out_rsync 2>&1
     #   ccc_hsm get ${dm_liste[*]} > out_rsync 2>&1
-    #	RET=$?
-    #	if [ ${RET} -gt 0 ] ; then
+    #	status=$?
+    #	if [ ${status} -gt 0 ] ; then
     #       echo "ERROR IGCM_sys_Get : again demigration error :"
     #       cat out_rsync
@@ -1259,6 +1288,6 @@
         # test if the target file is present before the loop
         IGCM_sys_TestFileArchive ${target}
-        RET=$?
-        if [ ${RET} -gt 0 ] ; then
+        status=$?
+        if [ ${status} -gt 0 ] ; then
           echo "IGCM_sys_Get, ERROR : regular file ${target} DOES NOT EXIST ."
           IGCM_debug_Exit "IGCM_sys_Get"
@@ -1268,5 +1297,5 @@
             status=$?
             if [ ${status} -gt 0 ]; then
-              IGCM_debug_Print 2 "IGCM_sys_Get : cp failed ${i}/${NB_ESSAI}"
+              IGCM_debug_Print 2 "IGCM_sys_Get : cp failed error code ${status} ${i}/${NB_ESSAI}"
               IGCM_debug_Print 2 "IGCM_sys_Get : sleep ${DELAI} seconds and try again."
               sleep $DELAI
@@ -1281,5 +1310,5 @@
     else
       \cp ${dm_liste} ${DEST} >> out_rsync 2>&1
-      RET=$?
+      status=$?
     fi
 
@@ -1292,6 +1321,6 @@
 #       ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> out_rsync 2>&1
 
-#       RET=$?
-#       IGCM_sys_Rsync_out $RET
+#       status=$?
+#       IGCM_sys_Rsync_out $status
 
 #       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
@@ -1299,5 +1328,5 @@
 
     if [ ${RET} -gt 0 ] ; then
-      echo "IGCM_sys_Get : copy error."
+      echo "IGCM_sys_Get : error"
       cat out_rsync
 #      IGCM_debug_Exit "IGCM_sys_Get"
@@ -1319,5 +1348,5 @@
   IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@
 
-  typeset DEST RET buf_liste ifile target file_work
+  typeset DEST RET status buf_liste ifile target file_work
 
   if ( $DEBUG_sys ) ; then
@@ -1343,10 +1372,11 @@
     else
       \cp ${buf_liste} ${DEST} >> out_rsync 2>&1
-      RET=$?
+      status=$?
     fi
 
     if [ ${RET} -gt 0 ] ; then
-      echo "IGCM_sys_GetBuffer : copy error."
-      cat out_rsync
+      echo "IGCM_sys_GetBuffer : error"
+      cat out_rsync
+      \rm out_rsync
       IGCM_debug_Exit "IGCM_sys_GetBuffer"
     else
@@ -1395,6 +1425,5 @@
     echo "IGCM_sys_Dods_Rm :" $@
   fi
-  typeset RET
-  RET=0
+  typeset status
   if [ $DRYRUN = 0 ]; then
 
@@ -1406,7 +1435,7 @@
 
     /ccc/cont003/home/dsm/p86ipsl/bin/dods_rm public/${LOGIN}/${R_DODS}/${1} # > out_dods_rm 2>&1
-    RET=$?
-
-#	if [ ${RET} -gt 0 ] ; then
+    status=$?
+
+#	if [ ${status} -gt 0 ] ; then
 #           echo "IGCM_sys_Dods_Rm : error."
 #           cat out_dods_rm
@@ -1419,5 +1448,5 @@
     ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
   fi
-  return $RET
+  return $status
 }
 
@@ -1431,6 +1460,5 @@
     echo "IGCM_sys_Dods_Cp :" $@
   fi
-  typeset RET
-  RET=0
+  typeset status
   if [ $DRYRUN = 0 ]; then
 
@@ -1442,7 +1470,7 @@
 
     /ccc/cont003/home/dsm/p86ipsl/bin/dods_cp ${1} public/${LOGIN}/${R_DODS} # > out_dods_cp 2>&1
-    RET=$?
-
-#       if [ ${RET} -gt 0 ] ; then
+    status=$?
+
+#       if [ ${status} -gt 0 ] ; then
 #           echo "IGCM_sys_Dods_Cp : error."
 #           cat out_dods_cp
@@ -1455,5 +1483,5 @@
     ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
   fi
-  return $RET
+  return $status
 }
 
@@ -1468,5 +1496,6 @@
     echo "IGCM_sys_Put_Dods :" $@
   fi
-  typeset RET
+  #set -vx
+  typeset status
   if [ $DRYRUN = 0 ]; then
     if ( [ ! -d ${R_SAVE}/${1} ] && [ ! -d ${R_FIGR}/${1} ] ) ; then
@@ -1494,7 +1523,7 @@
     IGCM_sys_Dods_Rm ${1}
     IGCM_sys_Dods_Cp ${1}
-    RET=0
-
-    if [ ${RET} -gt 0 ] ; then
+    status=0
+
+    if [ ${status} -gt 0 ] ; then
       echo "IGCM_sys_Put_Dods : error."
       IGCM_debug_Exit "IGCM_sys_Put_Dods"
@@ -1514,7 +1543,29 @@
     echo "IGCM_sys_rebuild :" $@
   fi
-  /home/cont003/p86ipsl/X86_64/bin/rebuild -f -o $@
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+      /home/cont003/p86ipsl/X86_64/bin/rebuild -f -o $@ > out_rsync 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_rebuild : error code ${status}"
+      cat out_rsync
+      \rm out_rsync
+      IGCM_debug_Print 2 "IGCM_sys_rebuild : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+    else
+      \rm out_rsync
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
   if [ $? -gt 0 ] ; then
-    echo "IGCM_sys_rebuild : erreur ${@}."
+    echo "IGCM_sys_rebuild : rebuild error"
     IGCM_debug_Exit "rebuild"
   fi
Index: /trunk/libIGCM/libIGCM_sys/libIGCM_sys_mercurex9.ksh
===================================================================
--- /trunk/libIGCM/libIGCM_sys/libIGCM_sys_mercurex9.ksh	(revision 716)
+++ /trunk/libIGCM/libIGCM_sys/libIGCM_sys_mercurex9.ksh	(revision 717)
@@ -112,9 +112,9 @@
 
 #====================================================
-#- MirrorlibIGCM uncomment for frontend
+#- MirrorlibIGCM for frontend
 typeset -r MirrorlibIGCM=${MirrorlibIGCM:=false}
 
 #====================================================
-#- libIGCM_POST uncomment for frontend
+#- libIGCM_POST for frontend
 typeset -r libIGCM_POST=${libIGCM}
 
@@ -137,5 +137,5 @@
 #- IN
 typeset -r R_IN=${R_IN:=/ccc/work/cont003/dsm/p86ipsl/IGCM}
-typeset -r R_IN_ECMWF=${R_IN_ECMWF:=/dmnfs/cont003/p24data}
+typeset -r R_IN_ECMWF=${R_IN_ECMWF:=/ccc/work/cont003/dsm/p24data}
 
 #====================================================
@@ -245,4 +245,5 @@
     IGCM_debug_Exit "IGCM_sys_RshPost"
   fi
+  # delete temporary file
   \rm tmp_IGCM_sys_RshPost_$$
 
@@ -291,6 +292,7 @@
     status=completed
   fi
+
   cat  << END_MAIL > job_end.mail
-  Dear ${LOGIN},
+Dear ${LOGIN},
 
   Simulation ${config_UserChoices_JobName} is ${status} on supercomputer `hostname`.
@@ -354,5 +356,5 @@
   fi
   #- creation de repertoire sur le serveur fichier
-  if [ ! -d ${1} ]; then 
+  if [ ! -d ${1} ]; then
     \mkdir -p $1
     if [ $? -gt 0 ] ; then
@@ -375,5 +377,5 @@
   fi
   #- creation de repertoire sur le serveur fichier
-  if [ ! -d ${1} ]; then 
+  if [ ! -d ${1} ]; then
     \mkdir -p $1
     if [ $? -gt 0 ] ; then
@@ -664,5 +666,5 @@
 
 #D-*************************
-#D- File transfer functions 
+#D- File transfer functions
 #D-*************************
 #D-
@@ -733,5 +735,5 @@
   elif [ $MYLANG = "en" ] ; then
     case $RET in
-    0)  return;;		
+    0)  return;;
     1)  echo "rsync error : Syntax or usage error "
       return;;
@@ -789,5 +791,5 @@
   fi
 
-  typeset RET DEST
+  typeset status DEST
 
   mkdir -p ${HOME}/MIRROR/${PATHlibIGCM}
@@ -795,7 +797,7 @@
   echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > out_rsync 2>&1
   ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> out_rsync 2>&1
-  RET=$?
-
-  if [ ${RET} -gt 0 ] ; then
+  status=$?
+
+  if [ ${status} -gt 0 ] ; then
     echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on cesium."
     cat out_rsync
@@ -815,12 +817,12 @@
   fi
 
-  typeset RET
+  typeset status
 
   echo cp $@ > out_rsync 2>&1
   \cp $@ >> out_rsync 2>&1
-  RET=$?
-
-  if [ ${RET} -gt 0 ] ; then
-    echo "IGCM_sys_Cp : error."
+  status=$?
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_Cp : error code ${status}"
     cat out_rsync
     IGCM_debug_Exit "IGCM_sys_Cp"
@@ -842,12 +844,12 @@
   fi
 
-  typeset RET
+  typeset status
 
   echo rm $@ > out_rsync 2>&1
   \rm $@ >> out_rsync 2>&1
-  RET=$?
-
-  if [ ${RET} -gt 0 ] ; then
-    echo "IGCM_sys_Rm : error."
+  status=$?
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_Rm : error code ${status}"
     cat out_rsync
     IGCM_debug_Exit "IGCM_sys_Rm"
@@ -871,12 +873,12 @@
   if [ $DRYRUN = 0 ]; then
 
-    typeset RET
-    
+    typeset status
+
     echo mv $@ > out_rsync 2>&1
     \mv $@ >> out_rsync 2>&1
-    RET=$?
-    
-    if [ ${RET} -gt 0 ] ; then
-      echo "IGCM_sys_Mv : error in mv."
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_Mv : error code ${status}"
       cat out_rsync
       IGCM_debug_Exit "IGCM_sys_Mv"
@@ -908,5 +910,5 @@
     fi
 
-    typeset RET
+    typeset status
 
     # Only if we use rsync
@@ -915,8 +917,8 @@
     #USUAL WAY
     \cp -r $1 $2 > out_rsync 2>&1
-    RET=$?
-
-    if [ ${RET} -gt 0 ] ; then
-      echo "IGCM_sys_Put_Dir : error."
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_Put_Dir : error code ${status}"
       cat out_rsync
       IGCM_debug_Exit "IGCM_sys_Put_Dir"
@@ -947,5 +949,9 @@
 #    fi
 
-    typeset RET
+    typeset NB_ESSAI DELAI status i
+    # number of tentative
+    NB_ESSAI=3
+    # time delay between tentative
+    DELAI=2
 
     # Only if we use rsync
@@ -953,10 +959,22 @@
     #
     # USUAL WAY
-    # add dmfind/dmget (to demigrate all offline files) :
-    #dmfind $1 -state MIG -o -state OFL -o -state PAR | dmget
-    \cp -r $1 $2 > out_rsync 2>&1
-    RET=$?
-
-    if [ ${RET} -gt 0 ] ; then
+    # add 'ccc_hsm get' (to demigrate all offline files) to reduce time of this command :
+    ccc_hsm get -r $1
+
+    i=0
+    while [ $i -lt $NB_ESSAI ] ; do
+      \cp -ur $1 $2 >> out_rsync 2>&1
+      status=$?
+      if [ ${status} -gt 0 ]; then
+        IGCM_debug_Print 2 "IGCM_sys_Get_Dir : cp failed error code ${status} ${i}/${NB_ESSAI}"
+        IGCM_debug_Print 2 "IGCM_sys_Get_Dir : sleep ${DELAI} seconds and try again."
+        sleep $DELAI
+      else
+        break
+      fi
+      (( i = i + 1 ))
+    done
+
+    if [ ${status} -gt 0 ] ; then
       echo "IGCM_sys_Get_Dir : error."
       cat out_rsync
@@ -994,5 +1012,5 @@
     fi
 
-    typeset RET
+    typeset status
     #
     if [ X${JobType} = XRUN ] ; then
@@ -1003,22 +1021,22 @@
     # USUAL WAY
     \cp $1 $2 > out_rsync 2>&1
-    RET=$?
-
-# 	#RSYNC WITH NETWORK SSH CALL
-# 	echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1
-# 	${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1
-
-#  	#RSYNC WITH NFS USE
-#  	echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
-#  	${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
-
-#  	RET=$?
-#  	IGCM_sys_Rsync_out $RET
-
-#  	${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
-#  	(( RET=RET+$? ))
-
-    if [ ${RET} -gt 0 ] ; then
-      echo "IGCM_sys_Put_Rest : error."
+    status=$?
+
+#       #RSYNC WITH NETWORK SSH CALL
+#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1
+#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1
+
+#       #RSYNC WITH NFS USE
+#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
+#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
+
+#       status=$?
+#       IGCM_sys_Rsync_out $status
+
+#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
+#       (( status=status+$? ))
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_Put_Rest : cp failed error code ${status}"
       cat out_rsync
       IGCM_debug_Exit "IGCM_sys_Put_Rest"
@@ -1049,5 +1067,5 @@
     fi
 
-    typeset RET
+    typeset status
     #
     if [ X${JobType} = XRUN ] ; then
@@ -1058,8 +1076,8 @@
     # USUAL WAY
     \cp $1 $2 > out_rsync 2>&1
-    RET=$?
-
-    if [ ${RET} -gt 0 ] ; then
-      echo "IGCM_sys_PutBuffer_Rest : error."
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_PutBuffer_Rest : error code ${status}"
       cat out_rsync
       IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest"
@@ -1083,4 +1101,12 @@
     echo "IGCM_sys_Put_Out :" $@
   fi
+
+  typeset NB_ESSAI DELAI status i exist skip
+
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
   if [ $DRYRUN = 0 ]; then
     if [ ! -f ${1} ] ; then
@@ -1092,5 +1118,4 @@
     IGCM_sys_MkdirArchive $( dirname $2 )
     #
-    typeset RET
 
     #=====================================================
@@ -1102,5 +1127,5 @@
     #    typeset WORKPATH FILEPATH
     #    WORKPATH=$( dirname $2 | sed -e "s|${R_OUT}|${R_BUF}|" )
-    #    IGCM_sys_MkdirWork ${WORKPATH} 
+    #    IGCM_sys_MkdirWork ${WORKPATH}
     #    FILEPATH=${WORKPATH}/$( basename $2 )
     #    #
@@ -1110,27 +1135,61 @@
     if [ X${JobType} = XRUN ] ; then
       if [ X${3} = X ] ; then
-	IGCM_sys_Chmod 444 ${1}
+        IGCM_sys_Chmod 444 ${1}
       fi
     fi
     #
-    # USUAL WAY
-    \cp $1 $2 > out_rsync 2>&1
-    RET=$?
-
-# 	#RSYNC WITH NETWORK SSH CALL
-# 	echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1
-# 	${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1
-
-#  	#RSYNC WITH NFS USE
-#  	echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
-#  	${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
-
-#  	RET=$?
-#  	IGCM_sys_Rsync_out $RET
-
-#  	${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
-#  	(( RET=RET+$? ))
-
-    if [ ${RET} -gt 0 ] ; then
+
+    exist=false
+    skip=false
+    if [ -f $2 ] ; then
+      IGCM_debug_Print 1 "$2 already exist"
+      #dmget $2
+      ccc_hsm get $2
+      exist=true
+      if [ "X$( diff $1 $2 )" = X ] ; then
+        IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy"
+        skip=true
+      else
+        IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy"
+        skip=false
+      fi
+    fi
+    #
+    if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then
+      IGCM_sys_Chmod u+w $2
+    fi
+
+    if [ X${skip} = Xfalse ] ; then
+      (( i = 0 ))
+      while [ $i -lt $NB_ESSAI ] ; do
+        # USUAL WAY
+        \cp $1 $2 > out_rsync 2>&1
+        status=$?
+        if [ ${status} -gt 0 ]; then
+          IGCM_debug_Print 2 "IGCM_sys_Put_Out : cp failed error code ${status} ${i}/${NB_ESSAI}"
+          IGCM_debug_Print 2 "IGCM_sys_Put_Out : sleep ${DELAI} seconds and try again."
+          sleep $DELAI
+        else
+          break
+        fi
+        (( i = i + 1 ))
+      done
+    fi
+
+#       #RSYNC WITH NETWORK SSH CALL
+#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1
+#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1
+
+#       #RSYNC WITH NFS USE
+#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
+#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
+
+#       status=$?
+#       IGCM_sys_Rsync_out $status
+
+#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
+#       (( status=status+$? ))
+
+    if [ ${status} -gt 0 ] ; then
       echo "IGCM_sys_Put_Out : error."
       cat out_rsync
@@ -1156,4 +1215,12 @@
     echo "IGCM_sys_PutBuffer_Out :" $@
   fi
+
+  typeset NB_ESSAI DELAI status i exist skip 
+
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
   if [ $DRYRUN = 0 ]; then
     if [ ! -f ${1} ] ; then
@@ -1165,17 +1232,47 @@
     IGCM_sys_Mkdir $( dirname $2 )
     #
-    typeset RET
 
     if [ X${JobType} = XRUN ] ; then
       if [ X${3} = X ] ; then
-	IGCM_sys_Chmod 444 ${1}
+        IGCM_sys_Chmod 444 ${1}
       fi
     fi
+
+    exist=false
+    skip=false
+    if [ -f $2 ] ; then
+      IGCM_debug_Print 1 "$2 already exist"
+      exist=true
+      if [ "X$( diff $1 $2 )" = X ] ; then
+        IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy"
+        skip=true
+      else
+        IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy"
+        skip=false
+      fi
+    fi
     #
-    # USUAL WAY
-    \cp $1 $2 > out_rsync 2>&1
-    RET=$?
-
-    if [ ${RET} -gt 0 ] ; then
+    if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then
+      IGCM_sys_Chmod u+w $2
+    fi
+
+    if [ X${skip} = Xfalse ] ; then
+      i=0
+      while [ $i -lt $NB_ESSAI ] ; do
+        # USUAL WAY
+        \cp $1 $2 > out_rsync 2>&1
+        status=$?
+        if [ ${status} -gt 0 ]; then
+          IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : cp failed error code ${status} ${i}/${NB_ESSAI}"
+          IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : sleep ${DELAI} seconds and try again."
+          sleep $DELAI
+        else
+          break
+        fi
+        (( i = i + 1 ))
+      done
+    fi
+
+    if [ ${status} -gt 0 ] ; then
       echo "IGCM_sys_PutBuffer_Out : error."
       cat out_rsync
@@ -1199,9 +1296,16 @@
   IGCM_debug_PushStack "IGCM_sys_Get" $@
 
-  typeset DEST RET dm_liste ifile target file_work 
+  typeset DEST RET dm_liste ifile target file_work
+  typeset NB_ESSAI DELAI status i
 
   if ( $DEBUG_sys ) ; then
     echo "IGCM_sys_Get :" $@
   fi
+
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
   if [ $DRYRUN -le 2 ]; then
     if [ X${1} = X'/l' ] ; then
@@ -1229,22 +1333,13 @@
     #fi
 
-    # test if the (first) file is present in the old computation :
-    IGCM_sys_TestFileArchive ${dm_liste[0]}
-    RET=$?
-    if [ ${RET} -gt 0 ] ; then
-      echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ."
-      IGCM_debug_Exit "IGCM_sys_Get"
-    fi
-
-    #dmget ${dm_liste[*]} > out_rsync 2>&1
     ccc_hsm get ${dm_liste[*]} > out_rsync 2>&1
-    RET=$?
-    if [ ${RET} -gt 0 ] ; then
-      echo "WARNING IGCM_sys_Get : demigration error."
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      echo "WARNING IGCM_sys_Get : error code ${status}"
       cat out_rsync
       echo "WARNING IGCM_sys_Get : will stop later if the cp fails."
     fi
 
-    #if [ ${RET} -gt 0 ] ; then
+    #if [ ${status} -gt 0 ] ; then
     #    if [ ! "X$( grep "Lost dmusrcmd connection" out_rsync )" = "X" ] ; then
     #	cat out_rsync
@@ -1254,9 +1349,9 @@
     ##	dmget ${dm_liste[*]} > out_rsync 2>&1
     #   ccc_hsm get ${dm_liste[*]} > out_rsync 2>&1
-    #	RET=$?
-    #	if [ ${RET} -gt 0 ] ; then
-    #	    echo "ERROR IGCM_sys_Get : again demigration error :"
-    #	    cat out_rsync
-    #	    IGCM_debug_Exit "IGCM_sys_Get"
+    #	status=$?
+    #	if [ ${status} -gt 0 ] ; then
+    #       echo "ERROR IGCM_sys_Get : again demigration error :"
+    #       cat out_rsync
+    #       IGCM_debug_Exit "IGCM_sys_Get"
     #	fi
     #    else
@@ -1271,30 +1366,51 @@
       (( RET=0 ))
       for target in ${dm_liste[*]} ; do
-	local_file=$( basename ${target} )
-	\cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1
-	(( RET = RET + $? ))
+        local_file=$( basename ${target} )
+        (( i = 0 ))
+        # test if the target file is present before the loop
+        IGCM_sys_TestFileArchive ${target}
+        status=$?
+        if [ ${status} -gt 0 ] ; then
+          echo "IGCM_sys_Get, ERROR : regular file ${target} DOES NOT EXIST ."
+          IGCM_debug_Exit "IGCM_sys_Get"
+        else
+          while [ $i -lt $NB_ESSAI ] ; do
+            \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1
+            status=$?
+            if [ ${status} -gt 0 ]; then
+              IGCM_debug_Print 2 "IGCM_sys_Get : cp failed error code ${status} ${i}/${NB_ESSAI}"
+              IGCM_debug_Print 2 "IGCM_sys_Get : sleep ${DELAI} seconds and try again."
+              sleep $DELAI
+            else
+              break
+            fi
+            (( i = i + 1 ))
+          done
+          (( RET = RET + status ))
+        fi
       done
     else
       \cp ${dm_liste} ${DEST} >> out_rsync 2>&1
-      RET=$?
-    fi
-
-# 	#RSYNC WITH NETWORK SSH CALL
-# 	echo ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1
-# 	${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1
-
-#  	#RSYNC WITH NFS USE
-#  	echo ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > out_rsync 2>&1
-#  	${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> out_rsync 2>&1
-
-# 	RET=$?
-#  	IGCM_sys_Rsync_out $RET
-
-#  	${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
-#  	(( RET=RET+$? ))
+      status=$?
+    fi
+
+#       #RSYNC WITH NETWORK SSH CALL
+#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1
+#       ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1
+
+#       #RSYNC WITH NFS USE
+#       echo ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > out_rsync 2>&1
+#       ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> out_rsync 2>&1
+
+#       status=$?
+#       IGCM_sys_Rsync_out $status
+
+#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
+#       (( RET=RET+$? ))
 
     if [ ${RET} -gt 0 ] ; then
-      echo "IGCM_sys_Get : copy error."
+      echo "IGCM_sys_Get : error"
       cat out_rsync
+      \rm out_rsync
       IGCM_debug_Exit "IGCM_sys_Get"
     else
@@ -1315,5 +1431,5 @@
   IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@
 
-  typeset DEST RET buf_liste ifile target file_work 
+  typeset DEST RET status buf_liste ifile target file_work
 
   if ( $DEBUG_sys ) ; then
@@ -1333,16 +1449,17 @@
       (( RET=0 ))
       for target in ${buf_liste[*]} ; do
-	local_file=$( basename ${target} )
-	\cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1
-	(( RET = RET + $? ))
+        local_file=$( basename ${target} )
+        \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1
+        (( RET = RET + $? ))
       done
     else
       \cp ${buf_liste} ${DEST} >> out_rsync 2>&1
-      RET=$?
+      status=$?
     fi
 
     if [ ${RET} -gt 0 ] ; then
-      echo "IGCM_sys_GetBuffer : copy error."
+      echo "IGCM_sys_GetBuffer : error"
       cat out_rsync
+      \rm out_rsync
       IGCM_debug_Exit "IGCM_sys_GetBuffer"
     else
@@ -1375,5 +1492,5 @@
 #D-#==================================================
 #D-function IGCM_sys_GetDate_FichArchive
-#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE 
+#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE
 #D-* Examples:
 #D-
@@ -1398,7 +1515,29 @@
     echo "IGCM_sys_rebuild :" $@
   fi
-  /home/cont003/p86ipsl/SX8/bin/rebuild -f -o $@
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+      /home/cont003/p86ipsl/SX8/bin/rebuild -f -o $@ > out_rsync 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_rebuild : error code ${status}"
+      cat out_rsync
+      \rm out_rsync
+      IGCM_debug_Print 2 "IGCM_sys_rebuild : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+    else
+      \rm out_rsync
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
   if [ $? -gt 0 ] ; then
-    echo "IGCM_sys_rebuild : erreur ${@}."
+    echo "IGCM_sys_rebuild : rebuild error"
     IGCM_debug_Exit "rebuild"
   fi
@@ -1567,5 +1706,5 @@
 ############################################################
 # Build MPI/OMP scripts
-function IGCM_sys_build_execution_scripts 
+function IGCM_sys_build_execution_scripts
 {
   IGCM_debug_PushStack "IGCM_sys_build_execution_scripts" $@
Index: /trunk/libIGCM/libIGCM_sys/libIGCM_sys_obelix.ksh
===================================================================
--- /trunk/libIGCM/libIGCM_sys/libIGCM_sys_obelix.ksh	(revision 716)
+++ /trunk/libIGCM/libIGCM_sys/libIGCM_sys_obelix.ksh	(revision 717)
@@ -64,5 +64,4 @@
 # Host and user names
 # $hostname ou hostname
-# $hostname ou hostname
 typeset  HOST=${HOST:=$( hostname )}
 # $username ou whoami
@@ -141,5 +140,5 @@
 
 #====================================================
-#- OUT
+#- R_OUT
 typeset -r R_OUT=${ARCHIVE}/IGCM_OUT
 
@@ -268,4 +267,5 @@
     status=completed
   fi
+
   cat  << END_MAIL > job_end.mail
 Dear ${LOGIN},
@@ -308,5 +308,5 @@
     fi
   fi
-    # vérification :
+  # vérification :
   if [ ! -d ${1} ] ; then
     echo "IGCM_sys_Mkdir : erreur."
@@ -326,5 +326,5 @@
     echo "IGCM_sys_MkdirArchive :" $@
   fi
-    #- creation de repertoire sur le serveur fichier
+  #- creation de repertoire sur le serveur fichier
   if [ ! -d ${1} ]; then
     \mkdir -p $1
@@ -347,5 +347,5 @@
     echo "IGCM_sys_MkdirWork :" $@
   fi
-    #- creation de repertoire sur le serveur fichier
+  #- creation de repertoire sur le serveur fichier
   if [ ! -d ${1} ]; then
     \mkdir -p $1
@@ -537,5 +537,4 @@
     IGCM_debug_Exit "IGCM_sys_Tar"
   fi
-
   IGCM_debug_PopStack "IGCM_sys_Tar"
 }
@@ -607,11 +606,11 @@
 #D-  Error values and explanations can depend on your system version.
 function IGCM_sys_Rsync_out {
-  RET=$1
-  if [ ! $RET ] ; then
+  status=$1
+  if [ ! $status ] ; then
     echo "rsync error !"
   fi
 
   if [ $MYLANG = "fr" ]; then
-    case $RET in
+    case $status in
     0)  return ;;
     1)  echo "Erreur de rsync ; RERR_SYNTAX : "
@@ -661,9 +660,9 @@
       echo "Temps d'attente écoulé dans l'envoi/réception de données"
       return;;
-    *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $RET
+    *)  echo "Erreur de rsync : code de retour de rsync inconnu :" $status
       return;;
     esac
   elif [ $MYLANG = "en" ] ; then
-    case $RET in
+    case $status in
     0)  return;;
     1)  echo "rsync error : Syntax or usage error "
@@ -702,5 +701,5 @@
     30) echo "rsync error : Timeout in data send/receive "
       return;;
-    *)  echo "rsync error : return code of rsync unknown :" $RET
+    *)  echo "rsync error : return code of rsync unknown :" $status
       return;;
     esac
@@ -722,16 +721,16 @@
   fi
 
-  typeset RET
-
-  echo cp --preserve=timestamps $@ > out_rsync 2>&1
-  \cp --preserve=timestamps $@ >> out_rsync 2>&1
-  RET=$?
-
-  if [ ${RET} -gt 0 ] ; then
-    echo "IGCM_sys_Cp : error."
+  typeset status
+
+  echo cp $@ > out_rsync 2>&1
+  \cp $@ >> out_rsync 2>&1
+  status=$?
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_Cp : error code ${status}"
     cat out_rsync
     IGCM_debug_Exit "IGCM_sys_Cp"
   else
-    rm out_rsync
+    \rm out_rsync
   fi
   IGCM_debug_PopStack "IGCM_sys_Cp"
@@ -749,16 +748,16 @@
   fi
 
-  typeset RET
+  typeset status
 
   echo rm $@ > out_rsync 2>&1
   \rm $@ >> out_rsync 2>&1
-  RET=$?
-
-  if [ ${RET} -gt 0 ] ; then
-    echo "IGCM_sys_Rm : error."
+  status=$?
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_Rm : error code ${status}"
     cat out_rsync
     IGCM_debug_Exit "IGCM_sys_Rm"
   else
-    rm out_rsync
+    \rm out_rsync
   fi
   IGCM_debug_PopStack "IGCM_sys_Rm"
@@ -777,16 +776,17 @@
   fi
 
-  typeset RET
+  typeset status
 
   echo rm $@ > out_rsync 2>&1
   \rm $@ >> out_rsync 2>&1
-  RET=$?
-
-  if [ ${RET} -gt 0 ] ; then
-    echo "IGCM_sys_RmRunDir : error."
+  status=$?
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_RmRunDir : error code ${status}"
     cat out_rsync
     IGCM_debug_Exit "IGCM_sys_RmRunDir"
-  fi
-
+  else
+    \rm out_rsync
+  fi
   IGCM_debug_PopStack "IGCM_sys_RmRunDir"
 }
@@ -805,16 +805,16 @@
   if [ $DRYRUN = 0 ]; then
 
-    typeset RET
+    typeset status
 
     echo mv $@ > out_rsync 2>&1
     \mv $@ >> out_rsync 2>&1
-    RET=$?
-
-    if [ ${RET} -gt 0 ] ; then
-      echo "IGCM_sys_Mv : error in mv."
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_Mv : error code ${status}"
       cat out_rsync
       IGCM_debug_Exit "IGCM_sys_Mv"
     else
-      rm out_rsync
+      \rm out_rsync
     fi
   else
@@ -842,19 +842,19 @@
     fi
 
-    typeset RET
-
-        # Only if we use rsync
-        #IGCM_sys_TestDirArchive $( dirname $2 )
-        #
-        #USUAL WAY
-    \cp -R $1 $2 > out_rsync 2>&1
-    RET=$?
-
-    if [ ${RET} -gt 0 ] ; then
-      echo "IGCM_sys_Put_Dir : error."
+    typeset status
+
+    # Only if we use rsync
+    #IGCM_sys_TestDirArchive $( dirname $2 )
+    #
+    #USUAL WAY
+    \cp -r $1 $2 > out_rsync 2>&1
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_Put_Dir : error code ${status}"
       cat out_rsync
       IGCM_debug_Exit "IGCM_sys_Put_Dir"
     else
-      rm out_rsync
+      \rm out_rsync
     fi
   else
@@ -866,5 +866,5 @@
 #D-#==================================================
 #D-function IGCM_sys_Get_Dir
-#D-* Purpose: Copy a complete directory from $(ARCHIVE)
+#D-* Purpose: Copy a complete directory from ${ARCHIVE}
 #D-* Examples:
 #D-
@@ -881,16 +881,16 @@
     fi
 
-    typeset RET
+    typeset status
 
         #USUAL WAY
     \cp -R $1 $2 > out_rsync 2>&1
-    RET=$?
-
-    if [ ${RET} -gt 0 ] ; then
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
       echo "IGCM_sys_Get_Dir : error."
       cat out_rsync
       IGCM_debug_Exit "IGCM_sys_Get_Dir"
     else
-      rm out_rsync
+      \rm out_rsync
     fi
   else
@@ -917,11 +917,11 @@
     fi
 
-    typeset RET
+    typeset status
 
         #USUAL WAY
     cp -RL $1 $2 > out_rsync 2>&1
-    RET=$?
-
-    if [ ${RET} -gt 0 ] ; then
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
       echo "IGCM_sys_Get_Master : error."
       cat out_rsync
@@ -938,5 +938,5 @@
 #D-#==================================================
 #D-function IGCM_sys_Put_Rest
-#D-* Purpose: Put computied restarts on $(ARCHIVE).
+#D-* Purpose: Put computied restarts on ${ARCHIVE}.
 #D-           File and target directory must exist.
 #D-* Examples:
@@ -948,31 +948,40 @@
   fi
   if [ $DRYRUN = 0 ]; then
-
-    IGCM_sys_TestDirArchive $( dirname $2 )
-
     if [ ! -f ${1} ] ; then
       echo "ERROR : IGCM_sys_Put_Rest ${1} DOES NOT EXIST ."
       IGCM_debug_Exit "IGCM_sys_Put_Rest"
     fi
+
+    typeset status
+    #
     if [ X${JobType} = XRUN ] ; then
       IGCM_sys_Chmod 444 ${1}
     fi
 
-    typeset RET
-
-    echo ${RSYNC} ${RSYNC_opt} $1 $2 > out_rsync 2>&1
-    ${RSYNC} ${RSYNC_opt} $1 $2 >> out_rsync 2>&1
-    RET=$?
-    IGCM_sys_Rsync_out $RET
-
-    ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
-    (( RET=RET+$? ))
-
-    if [ ${RET} -gt 0 ] ; then
-      echo "IGCM_sys_Put_Rest : error."
+    #
+    # USUAL WAY
+    \cp $1 $2 > out_rsync 2>&1
+    status=$?
+
+#       #RSYNC WITH NETWORK SSH CALL
+#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1
+#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1
+
+#       #RSYNC WITH NFS USE
+#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1
+#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
+
+#       status=$?
+#       IGCM_sys_Rsync_out $status
+
+#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
+#       (( status=status+$? ))
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_Put_Rest : cp failed error code ${status}"
       cat out_rsync
       IGCM_debug_Exit "IGCM_sys_Put_Rest"
     else
-      rm out_rsync
+      \rm out_rsync
     fi
   else
@@ -999,5 +1008,5 @@
     fi
 
-    typeset RET
+    typeset status
     #
     if [ X${JobType} = XRUN ] ; then
@@ -1008,8 +1017,8 @@
     # USUAL WAY
     \cp $1 $2 > out_rsync 2>&1
-    RET=$?
-
-    if [ ${RET} -gt 0 ] ; then
-      echo "IGCM_sys_PutBuffer_Rest : error."
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_PutBuffer_Rest : error code ${status}"
       cat out_rsync
       IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest"
@@ -1025,5 +1034,5 @@
 #D-#==================================================
 #D-function IGCM_sys_Put_Out
-#D-* Purpose: Copy a file on $(ARCHIVE) after have chmod it in readonly
+#D-* Purpose: Copy a file on ${ARCHIVE} after having chmod it in readonly
 #D-* Examples:
 #D-
@@ -1044,5 +1053,5 @@
     fi
 
-    typeset RET
+    typeset status
         #
     if [ X${JobType} = XRUN ] ; then
@@ -1051,20 +1060,20 @@
       fi
     fi
-        #
+    #
 
     echo ${RSYNC} ${RSYNC_opt} $1 $2 > out_rsync 2>&1
     ${RSYNC} ${RSYNC_opt} $1 $2 >> out_rsync 2>&1
-    RET=$?
-    IGCM_sys_Rsync_out $RET
+    status=$?
+    IGCM_sys_Rsync_out $status
 
     ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
-    (( RET=RET+$? ))
-
-    if [ ${RET} -gt 0 ] ; then
+    (( status=status+$? ))
+
+    if [ ${status} -gt 0 ] ; then
       echo "IGCM_sys_Put_Out : error."
       cat out_rsync
       IGCM_debug_Exit "IGCM_sys_Put_Out"
     else
-      rm out_rsync
+      \rm out_rsync
     fi
   else
@@ -1094,5 +1103,5 @@
     IGCM_sys_Mkdir $( dirname $2 )
     #
-    typeset RET
+    typeset status
 
     if [ X${JobType} = XRUN ] ; then
@@ -1104,7 +1113,7 @@
     # USUAL WAY
     \cp $1 $2 > out_rsync 2>&1
-    RET=$?
-
-    if [ ${RET} -gt 0 ] ; then
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
       echo "IGCM_sys_PutBuffer_Out : error."
       cat out_rsync
@@ -1128,5 +1137,5 @@
   IGCM_debug_PushStack "IGCM_sys_Get" $@
 
-  typeset DEST RET dm_liste ifile target
+  typeset DEST RET status dm_liste ifile target
 
   if ( $DEBUG_sys ) ; then
@@ -1135,5 +1144,5 @@
   if [ $DRYRUN -le 2 ]; then
     if [ X${1} = X'/l' ] ; then
-            # test if the first file is present in the old computation :
+      # test if the first file is present in the old computation :
       eval set +A dm_liste \${${2}}
     else
@@ -1142,8 +1151,8 @@
     eval DEST=\${${#}}
 
-        # test if the (first) file is present in the old computation :
+    # test if the (first) file is present in the old computation :
     IGCM_sys_TestFileArchive ${dm_liste[0]}
-    RET=$?
-    if [ ${RET} -gt 0 ] ; then
+    status=$?
+    if [ ${status} -gt 0 ] ; then
       echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ."
       IGCM_debug_Exit "IGCM_sys_Get"
@@ -1159,6 +1168,6 @@
 #       echo ${RSYNC} ${RSYNC_opt} $@ > out_rsync 2>&1
 #       ${RSYNC} ${RSYNC_opt} $@ >> out_rsync 2>&1
-#       RET=$?
-#       IGCM_sys_Rsync_out $RET
+#       status=$?
+#       IGCM_sys_Rsync_out $status
 
 #       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
@@ -1166,9 +1175,10 @@
 
     if [ ${RET} -gt 0 ] ; then
-      echo "IGCM_sys_Get : copy error."
+      echo "IGCM_sys_Get : error"
       cat out_rsync
+      \rm out_rsync
       IGCM_debug_Exit "IGCM_sys_Get"
     else
-      rm out_rsync
+      \rm out_rsync
     fi
   else
@@ -1186,5 +1196,5 @@
   IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@
 
-  typeset DEST RET buf_liste ifile target file_work
+  typeset DEST RET status buf_liste ifile target file_work
 
   if ( $DEBUG_sys ) ; then
@@ -1210,10 +1220,11 @@
     else
       \cp ${buf_liste} ${DEST} >> out_rsync 2>&1
-      RET=$?
+      status=$?
     fi
 
     if [ ${RET} -gt 0 ] ; then
-      echo "IGCM_sys_GetBuffer : copy error."
+      echo "IGCM_sys_GetBuffer : error"
       cat out_rsync
+      \rm out_rsync
       IGCM_debug_Exit "IGCM_sys_GetBuffer"
     else
@@ -1263,5 +1274,5 @@
 #D-#==================================================
 #D-function IGCM_sys_Dods_Rm
-#D-* Purpose: Suppress files in /tmp/DODS for simulation of internet protocole.
+#D-* Purpose: DO NOTHING ! Put ${ARCHIVE} files on DODS internet protocole.
 #D-* Examples:
 #D-
@@ -1276,5 +1287,5 @@
 #D-#==================================================
 #D-function IGCM_sys_Dods_Cp
-#D-* Purpose: Copy from $(ARCHIVE) files to /tmp/DODS for simulation of internet protocole.
+#D-* Purpose: Copy $(ARCHIVE) files on DODS internet protocole.
 #D-* Examples:
 #D-
@@ -1288,5 +1299,5 @@
 #D-#==================================================
 #D-function IGCM_sys_Put_Dods
-#D-* Purpose: Put $(ARCHIVE) files on /tmp/DODS for simulation of internet protocole.
+#D-* Purpose: Put $(ARCHIVE) files on DODS internet protocole.
 #D-* Examples:
 #D-
@@ -1296,14 +1307,4 @@
     echo "IGCM_sys_Put_Dods :" $@
   fi
-  if [ $DRYRUN = 0 ]; then
-    RET=0
-
-    if [ ${RET} -gt 0 ] ; then
-      echo "IGCM_sys_Put_Dods : error."
-      IGCM_debug_Exit "IGCM_sys_Put_Dods"
-    fi
-  else
-    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
-  fi
   IGCM_debug_PopStack "IGCM_sys_Put_Dods"
 }
@@ -1317,7 +1318,11 @@
     echo "IGCM_sys_rebuild :" $@
   fi
+
+  typeset status
+
   /home/users/igcmg/rebuild/bin/rebuild -f -o $@
-  if [ $? -gt 0 ] ; then
-    echo "IGCM_sys_rebuild : erreur ${@}."
+  status=$?
+  if [ ${status} -gt 0 ] ; then
+    IGCM_debug_Print 2 "IGCM_sys_rebuild : error code ${status}"
     IGCM_debug_Exit "rebuild"
   fi
Index: /trunk/libIGCM/libIGCM_sys/libIGCM_sys_titane.ksh
===================================================================
--- /trunk/libIGCM/libIGCM_sys/libIGCM_sys_titane.ksh	(revision 716)
+++ /trunk/libIGCM/libIGCM_sys/libIGCM_sys_titane.ksh	(revision 717)
@@ -152,5 +152,5 @@
 #- IN
 typeset -r R_IN=${R_IN:=/ccc/work/cont003/dsm/p86ipsl/IGCM}
-typeset -r R_IN_ECMWF=${R_IN_ECMWF:=/dmnfs/cont003/p24data}
+typeset -r R_IN_ECMWF=${R_IN_ECMWF:=/ccc/work/cont003/dsm/p24data}
 
 #====================================================
@@ -853,5 +853,5 @@
   fi
 
-  typeset RET DEST
+  typeset status DEST
 
   mkdir -p ${HOME}/MIRROR/${PATHlibIGCM}
@@ -859,7 +859,7 @@
   echo ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} > out_rsync 2>&1
   ${RSYNC} ${RSYNC_opt} ${libIGCM} ${HOME}/MIRROR/${PATHlibIGCM} >> out_rsync 2>&1
-  RET=$?
-
-  if [ ${RET} -gt 0 ] ; then
+  status=$?
+
+  if [ ${status} -gt 0 ] ; then
     echo "IGCM_sys_Mirror_libIGCM Warning : no libIGCM on cesium."
     cat out_rsync
@@ -879,12 +879,12 @@
   fi
 
-  typeset RET
+  typeset status
 
   echo cp $@ > out_rsync 2>&1
   \cp $@ >> out_rsync 2>&1
-  RET=$?
-
-  if [ ${RET} -gt 0 ] ; then
-    echo "IGCM_sys_Cp : error."
+  status=$?
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_Cp : error code ${status}"
     cat out_rsync
     IGCM_debug_Exit "IGCM_sys_Cp"
@@ -906,12 +906,12 @@
   fi
 
-  typeset RET
+  typeset status
 
   echo rm $@ > out_rsync 2>&1
   \rm $@ >> out_rsync 2>&1
-  RET=$?
-
-  if [ ${RET} -gt 0 ] ; then
-    echo "IGCM_sys_Rm : error."
+  status=$?
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_Rm : error code ${status}"
     cat out_rsync
     IGCM_debug_Exit "IGCM_sys_Rm"
@@ -934,12 +934,12 @@
   fi
 
-  typeset RET
+  typeset status
 
   echo rm $@ > out_rsync 2>&1
   \rm $@ >> out_rsync 2>&1
-  RET=$?
-
-  if [ ${RET} -gt 0 ] ; then
-    echo "IGCM_sys_RmRunDir : error."
+  status=$?
+
+  if [ ${status} -gt 0 ] ; then
+    echo "IGCM_sys_RmRunDir : error code ${status}"
     cat out_rsync
     IGCM_debug_Exit "IGCM_sys_RmRunDir"
@@ -963,12 +963,12 @@
   if [ $DRYRUN = 0 ]; then
 
-    typeset RET
+    typeset status
 
     echo mv $@ > out_rsync 2>&1
     \mv $@ >> out_rsync 2>&1
-    RET=$?
-
-    if [ ${RET} -gt 0 ] ; then
-      echo "IGCM_sys_Mv : error in mv."
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_Mv : error code ${status}"
       cat out_rsync
       IGCM_debug_Exit "IGCM_sys_Mv"
@@ -1000,5 +1000,5 @@
     fi
 
-    typeset RET
+    typeset status
 
     # Only if we use rsync
@@ -1007,8 +1007,8 @@
     #USUAL WAY
     \cp -r $1 $2 > out_rsync 2>&1
-    RET=$?
-
-    if [ ${RET} -gt 0 ] ; then
-      echo "IGCM_sys_Put_Dir : error."
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_Put_Dir : error code ${status}"
       cat out_rsync
       IGCM_debug_Exit "IGCM_sys_Put_Dir"
@@ -1039,5 +1039,9 @@
 #    fi
 
-    typeset RET
+    typeset NB_ESSAI DELAI status i
+    # number of tentative
+    NB_ESSAI=3
+    # time delay between tentative
+    DELAI=2
 
     # Only if we use rsync
@@ -1048,8 +1052,20 @@
     #dmfind $1 -state MIG -o -state OFL -o -state PAR | dmget
     ccc_hsm get -r $1
-    \cp -r $1 $2 > out_rsync 2>&1
-    RET=$?
-
-    if [ ${RET} -gt 0 ] ; then
+
+    i=0
+    while [ $i -lt $NB_ESSAI ] ; do
+      \cp -ur $1 $2 >> out_rsync 2>&1
+      status=$?
+      if [ ${status} -gt 0 ]; then
+        IGCM_debug_Print 2 "IGCM_sys_Get_Dir : cp failed error code ${status} ${i}/${NB_ESSAI}"
+        IGCM_debug_Print 2 "IGCM_sys_Get_Dir : sleep ${DELAI} seconds and try again."
+        sleep $DELAI
+      else
+        break
+      fi
+      (( i = i + 1 ))
+    done
+
+    if [ ${status} -gt 0 ] ; then
       echo "IGCM_sys_Get_Dir : error."
       cat out_rsync
@@ -1081,11 +1097,25 @@
     fi
 
-    typeset RET
-
-    #USUAL WAY
-    \cp -rL $1 $2 > out_rsync 2>&1
-    RET=$?
-
-    if [ ${RET} -gt 0 ] ; then
+    typeset NB_ESSAI DELAI status i
+    # number of tentative
+    NB_ESSAI=3
+    # time delay between tentative
+    DELAI=2
+
+    i=0
+    while [ $i -lt $NB_ESSAI ] ; do
+      \cp -urL $1 $2 > out_rsync 2>&1
+      status=$?
+      if [ ${status} -gt 0 ]; then
+        IGCM_debug_Print 2 "IGCM_sys_Get_Master : cp failed error code ${status} ${i}/${NB_ESSAI}"
+        IGCM_debug_Print 2 "IGCM_sys_Get_Master : sleep ${DELAI} seconds and try again."
+        sleep $DELAI
+      else
+        break
+      fi
+      (( i = i + 1 ))
+    done
+
+    if [ ${status} -gt 0 ] ; then
       echo "IGCM_sys_Get_Master : error."
       cat out_rsync
@@ -1123,5 +1153,5 @@
     fi
 
-    typeset RET
+    typeset status
     #
     if [ X${JobType} = XRUN ] ; then
@@ -1132,5 +1162,5 @@
     # USUAL WAY
     \cp $1 $2 > out_rsync 2>&1
-    RET=$?
+    status=$?
 
 #       #RSYNC WITH NETWORK SSH CALL
@@ -1142,12 +1172,12 @@
 #       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
 
-#       RET=$?
-#       IGCM_sys_Rsync_out $RET
+#       status=$?
+#       IGCM_sys_Rsync_out $status
 
 #       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
-#       (( RET=RET+$? ))
-
-    if [ ${RET} -gt 0 ] ; then
-      echo "IGCM_sys_Put_Rest : error."
+#       (( status=status+$? ))
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_Put_Rest : cp failed error code ${status}"
       cat out_rsync
       IGCM_debug_Exit "IGCM_sys_Put_Rest"
@@ -1178,5 +1208,5 @@
     fi
 
-    typeset RET
+    typeset status
     #
     if [ X${JobType} = XRUN ] ; then
@@ -1187,8 +1217,8 @@
     # USUAL WAY
     \cp $1 $2 > out_rsync 2>&1
-    RET=$?
-
-    if [ ${RET} -gt 0 ] ; then
-      echo "IGCM_sys_PutBuffer_Rest : error."
+    status=$?
+
+    if [ ${status} -gt 0 ] ; then
+      echo "IGCM_sys_PutBuffer_Rest : error code ${status}"
       cat out_rsync
       IGCM_debug_Exit "IGCM_sys_PutBuffer_Rest"
@@ -1213,5 +1243,5 @@
   fi
 
-  typeset NB_ESSAI DELAI RET i
+  typeset NB_ESSAI DELAI status i exist skip
 
   # number of tentative
@@ -1251,18 +1281,40 @@
     #
 
-    (( i = 0 ))
-    while [ $i -lt $NB_ESSAI ] ; do
-    # USUAL WAY
-      \cp $1 $2 > out_rsync 2>&1
-      RET=$?
-      if [ ${RET} -gt 0 ]; then
-	IGCM_debug_Print 2 "IGCM_sys_Put_Out : cp failed ${i}/${NB_ESSAI}"
-	IGCM_debug_Print 2 "IGCM_sys_Put_Out : sleep ${DELAI} seconds and try again."
-	sleep $DELAI
+    exist=false
+    skip=false
+    if [ -f $2 ] ; then
+      IGCM_debug_Print 1 "$2 already exist"
+      #dmget $2
+      ccc_hsm get $2
+      exist=true
+      if [ "X$( diff $1 $2 )" = X ] ; then
+        IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy"
+        skip=true
       else
-	break
+        IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy"
+        skip=false
       fi
-      (( i = i + 1 ))
-    done
+    fi
+    #
+    if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then
+      IGCM_sys_Chmod u+w $2
+    fi
+
+    if [ X${skip} = Xfalse ] ; then
+      (( i = 0 ))
+      while [ $i -lt $NB_ESSAI ] ; do
+        # USUAL WAY
+        \cp $1 $2 > out_rsync 2>&1
+        status=$?
+        if [ ${status} -gt 0 ]; then
+          IGCM_debug_Print 2 "IGCM_sys_Put_Out : cp failed error code ${status} ${i}/${NB_ESSAI}"
+          IGCM_debug_Print 2 "IGCM_sys_Put_Out : sleep ${DELAI} seconds and try again."
+          sleep $DELAI
+        else
+          break
+        fi
+        (( i = i + 1 ))
+      done
+    fi
 
 #       #RSYNC WITH NETWORK SSH CALL
@@ -1274,11 +1326,11 @@
 #       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1
 
-#       RET=$?
-#       IGCM_sys_Rsync_out $RET
+#       status=$?
+#       IGCM_sys_Rsync_out $status
 
 #       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
-#       (( RET=RET+$? ))
-
-    if [ ${RET} -gt 0 ] ; then
+#       (( status=status+$? ))
+
+    if [ ${status} -gt 0 ] ; then
       echo "IGCM_sys_Put_Out : error."
       cat out_rsync
@@ -1304,4 +1356,12 @@
     echo "IGCM_sys_PutBuffer_Out :" $@
   fi
+
+  typeset NB_ESSAI DELAI status i exist skip 
+
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
   if [ $DRYRUN = 0 ]; then
     if [ ! -f ${1} ] ; then
@@ -1313,5 +1373,4 @@
     IGCM_sys_Mkdir $( dirname $2 )
     #
-    typeset RET
 
     if [ X${JobType} = XRUN ] ; then
@@ -1320,10 +1379,41 @@
       fi
     fi
+
+    exist=false
+    skip=false
+    if [ -f $2 ] ; then
+      IGCM_debug_Print 1 "$2 already exist"
+      exist=true
+      if [ "X$( diff $1 $2 )" = X ] ; then
+        IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy"
+        skip=true
+      else
+        IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy"
+        skip=false
+      fi
+    fi
     #
-    # USUAL WAY
-    \cp $1 $2 > out_rsync 2>&1
-    RET=$?
-
-    if [ ${RET} -gt 0 ] ; then
+    if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then
+      IGCM_sys_Chmod u+w $2
+    fi
+
+    if [ X${skip} = Xfalse ] ; then
+      i=0
+      while [ $i -lt $NB_ESSAI ] ; do
+        # USUAL WAY
+        \cp $1 $2 > out_rsync 2>&1
+        status=$?
+        if [ ${status} -gt 0 ]; then
+          IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : cp failed error code ${status} ${i}/${NB_ESSAI}"
+          IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : sleep ${DELAI} seconds and try again."
+          sleep $DELAI
+        else
+          break
+        fi
+        (( i = i + 1 ))
+      done
+    fi
+
+    if [ ${status} -gt 0 ] ; then
       echo "IGCM_sys_PutBuffer_Out : error."
       cat out_rsync
@@ -1385,12 +1475,12 @@
 
     ccc_hsm get ${dm_liste[*]} > out_rsync 2>&1
-    RET=$?
-    if [ ${RET} -gt 0 ] ; then
-      echo "WARNING IGCM_sys_Get : demigration error."
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      echo "WARNING IGCM_sys_Get : error code ${status}"
       cat out_rsync
       echo "WARNING IGCM_sys_Get : will stop later if the cp fails."
     fi
 
-    #if [ ${RET} -gt 0 ] ; then
+    #if [ ${status} -gt 0 ] ; then
     #    if [ ! "X$( grep "Lost dmusrcmd connection" out_rsync )" = "X" ] ; then
     #	cat out_rsync
@@ -1400,6 +1490,6 @@
     ##	dmget ${dm_liste[*]} > out_rsync 2>&1
     #   ccc_hsm get ${dm_liste[*]} > out_rsync 2>&1
-    #	RET=$?
-    #	if [ ${RET} -gt 0 ] ; then
+    #	status=$?
+    #	if [ ${status} -gt 0 ] ; then
     #       echo "ERROR IGCM_sys_Get : again demigration error :"
     #       cat out_rsync
@@ -1421,6 +1511,6 @@
         # test if the target file is present before the loop
         IGCM_sys_TestFileArchive ${target}
-        RET=$?
-        if [ ${RET} -gt 0 ] ; then
+        status=$?
+        if [ ${status} -gt 0 ] ; then
           echo "IGCM_sys_Get, ERROR : regular file ${target} DOES NOT EXIST ."
           IGCM_debug_Exit "IGCM_sys_Get"
@@ -1430,9 +1520,9 @@
             status=$?
             if [ ${status} -gt 0 ]; then
-	      IGCM_debug_Print 2 "IGCM_sys_Get : cp failed ${i}/${NB_ESSAI}"
-	      IGCM_debug_Print 2 "IGCM_sys_Get : sleep ${DELAI} seconds and try again."
-	      sleep $DELAI
+              IGCM_debug_Print 2 "IGCM_sys_Get : cp failed error code ${status} ${i}/${NB_ESSAI}"
+              IGCM_debug_Print 2 "IGCM_sys_Get : sleep ${DELAI} seconds and try again."
+              sleep $DELAI
             else
-	      break
+              break
             fi
             (( i = i + 1 ))
@@ -1443,5 +1533,5 @@
     else
       \cp ${dm_liste} ${DEST} >> out_rsync 2>&1
-      RET=$?
+      status=$?
     fi
 
@@ -1454,6 +1544,6 @@
 #       ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> out_rsync 2>&1
 
-#       RET=$?
-#       IGCM_sys_Rsync_out $RET
+#       status=$?
+#       IGCM_sys_Rsync_out $status
 
 #       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync
@@ -1461,6 +1551,7 @@
 
     if [ ${RET} -gt 0 ] ; then
-      echo "IGCM_sys_Get : copy error."
+      echo "IGCM_sys_Get : error"
       cat out_rsync
+      \rm out_rsync
       IGCM_debug_Exit "IGCM_sys_Get"
     else
@@ -1481,5 +1572,5 @@
   IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@
 
-  typeset DEST RET buf_liste ifile target file_work
+  typeset DEST RET status buf_liste ifile target file_work
 
   if ( $DEBUG_sys ) ; then
@@ -1505,10 +1596,11 @@
     else
       \cp ${buf_liste} ${DEST} >> out_rsync 2>&1
-      RET=$?
+      status=$?
     fi
 
     if [ ${RET} -gt 0 ] ; then
-      echo "IGCM_sys_GetBuffer : copy error."
+      echo "IGCM_sys_GetBuffer : error"
       cat out_rsync
+      \rm out_rsync
       IGCM_debug_Exit "IGCM_sys_GetBuffer"
     else
@@ -1565,6 +1657,5 @@
     echo "IGCM_sys_Dods_Rm :" $@
   fi
-  typeset RET
-  RET=0
+  typeset status
   if [ $DRYRUN = 0 ]; then
 
@@ -1576,7 +1667,7 @@
 
     /ccc/cont003/home/dsm/p86ipsl/bin/dods_rm public/${LOGIN}/${R_DODS}/${1} # > out_dods_rm 2>&1
-    RET=$?
-
-#	if [ ${RET} -gt 0 ] ; then
+    status=$?
+
+#	if [ ${status} -gt 0 ] ; then
 #           echo "IGCM_sys_Dods_Rm : error."
 #           cat out_dods_rm
@@ -1589,5 +1680,5 @@
     ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
   fi
-  return $RET
+  return $status
 }
 
@@ -1601,6 +1692,5 @@
     echo "IGCM_sys_Dods_Cp :" $@
   fi
-  typeset RET
-  RET=0
+  typeset status
   if [ $DRYRUN = 0 ]; then
 
@@ -1612,7 +1702,7 @@
 
     /ccc/cont003/home/dsm/p86ipsl/bin/dods_cp ${1} public/${LOGIN}/${R_DODS} # > out_dods_cp 2>&1
-    RET=$?
-
-#       if [ ${RET} -gt 0 ] ; then
+    status=$?
+
+#       if [ ${status} -gt 0 ] ; then
 #           echo "IGCM_sys_Dods_Cp : error."
 #           cat out_dods_cp
@@ -1625,5 +1715,5 @@
     ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack
   fi
-  return $RET
+  return $status
 }
 
@@ -1638,6 +1728,6 @@
     echo "IGCM_sys_Put_Dods :" $@
   fi
-  set -vx
-  typeset RET
+  #set -vx
+  typeset status
   if [ $DRYRUN = 0 ]; then
     if ( [ ! -d ${R_SAVE}/${1} ] && [ ! -d ${R_FIGR}/${1} ] ) ; then
@@ -1665,7 +1755,7 @@
     IGCM_sys_Dods_Rm ${1}
     IGCM_sys_Dods_Cp ${1}
-    RET=0
-
-    if [ ${RET} -gt 0 ] ; then
+    status=0
+
+    if [ ${status} -gt 0 ] ; then
       echo "IGCM_sys_Put_Dods : error."
       IGCM_debug_Exit "IGCM_sys_Put_Dods"
@@ -1685,7 +1775,29 @@
     echo "IGCM_sys_rebuild :" $@
   fi
-  /home/cont003/p86ipsl/X64/bin/rebuild -f -o $@
+
+  typeset NB_ESSAI DELAI status i
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
+  i=0
+  while [ $i -lt $NB_ESSAI ] ; do
+      /home/cont003/p86ipsl/X64/bin/rebuild -f -o $@ > out_rsync 2>&1
+    status=$?
+    if [ ${status} -gt 0 ] ; then
+      IGCM_debug_Print 2 "IGCM_sys_rebuild : error code ${status}"
+      cat out_rsync
+      \rm out_rsync
+      IGCM_debug_Print 2 "IGCM_sys_rebuild : ${i}/${NB_ESSAI} sleep ${DELAI} seconds and try again."
+    else
+      \rm out_rsync
+      break
+    fi
+    (( i = i + 1 ))
+  done
+
   if [ $? -gt 0 ] ; then
-    echo "IGCM_sys_rebuild : erreur ${@}."
+    echo "IGCM_sys_rebuild : rebuild error"
     IGCM_debug_Exit "rebuild"
   fi
