Index: trunk/libIGCM/libIGCM_sys/libIGCM_sys_titane.ksh
===================================================================
--- trunk/libIGCM/libIGCM_sys/libIGCM_sys_titane.ksh	(revision 717)
+++ trunk/libIGCM/libIGCM_sys/libIGCM_sys_titane.ksh	(revision 719)
@@ -42,15 +42,15 @@
 # YOU MUST COMPILE YOUR EXE FILES FOR DRYRUN MODE !
 # -------------------------------------------------------------------------------------
-# | DRYRUN=  |	Date computations, | sys_Get	|  Exe    | sys_Put_Out; sys_Put_Rest |
-# |          |	Cp/Exe param files |		|  Chmod  |                           |
-# |          |      Qsub           |		|         |                           |
+# | DRYRUN=  |  Date computations, | sys_Get    |  Exe    | sys_Put_Out; sys_Put_Rest |
+# |          |  Cp/Exe param files |            |  Chmod  |                           |
+# |          |      Qsub           |            |         |                           |
 # -------------------------------------------------------------------------------------
-# |    0     |       yes           |	yes	|  yes    |      yes                  |
+# |    0     |       yes           |    yes     |  yes    |      yes                  |
 # -------------------------------------------------------------------------------------
-# |    1     |       yes           |	yes	|  yes    |      no                   |
+# |    1     |       yes           |    yes     |  yes    |      no                   |
 # -------------------------------------------------------------------------------------
-# |    2     |       yes           |	yes	|  no     |      no                   |
+# |    2     |       yes           |    yes     |  no     |      no                   |
 # -------------------------------------------------------------------------------------
-# |    3     |       yes           |	no	|  no     |      no                   |
+# |    3     |       yes           |    no      |  no     |      no                   |
 # -------------------------------------------------------------------------------------
 
@@ -346,5 +346,5 @@
   fi
 
-    cat  << END_MAIL > job_end.mail
+  cat  << END_MAIL > job_end.mail
 Dear ${LOGIN},
 
@@ -738,11 +738,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 : "
@@ -792,9 +792,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 "
@@ -833,5 +833,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
@@ -1302,5 +1302,5 @@
 
     if [ X${skip} = Xfalse ] ; then
-      (( i = 0 ))
+      i=0
       while [ $i -lt $NB_ESSAI ] ; do
         # USUAL WAY
@@ -1437,5 +1437,5 @@
   IGCM_debug_PushStack "IGCM_sys_Get" $@
 
-  typeset DEST RET dm_liste ifile target file_work
+  typeset DEST dm_liste ifile target file_work
   typeset NB_ESSAI DELAI status i
 
@@ -1503,10 +1503,22 @@
     #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
+    #   (( status=status+$? ))
+
     #USUAL WAY
     if [ X${1} = X'/l' ] ; then
-      (( RET=0 ))
       for target in ${dm_liste[*]} ; do
         local_file=$( basename ${target} )
-        (( i = 0 ))
         # test if the target file is present before the loop
         IGCM_sys_TestFileArchive ${target}
@@ -1516,4 +1528,5 @@
           IGCM_debug_Exit "IGCM_sys_Get"
         else
+          i=0
           while [ $i -lt $NB_ESSAI ] ; do
             \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1
@@ -1528,33 +1541,36 @@
             (( i = i + 1 ))
           done
-          (( RET = RET + status ))
+          if [ ${status} -gt 0 ] ; then
+            echo "IGCM_sys_Get : error"
+            cat out_rsync
+            \rm out_rsync
+            IGCM_debug_Exit "IGCM_sys_Get"
+          else
+            \rm out_rsync
+          fi
         fi
       done
     else
-      \cp ${dm_liste} ${DEST} >> out_rsync 2>&1
-      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 : error"
-      cat out_rsync
-      \rm out_rsync
-      IGCM_debug_Exit "IGCM_sys_Get"
-    else
-      \rm out_rsync
+      i=0
+      while [ $i -lt $NB_ESSAI ] ; do
+        \cp ${dm_liste} ${DEST} >> 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
+      if [ ${status} -gt 0 ] ; then
+        echo "IGCM_sys_Get : error"
+        cat out_rsync
+        \rm out_rsync
+        IGCM_debug_Exit "IGCM_sys_Get"
+      else
+        \rm out_rsync
+      fi
     fi
   else
@@ -1572,9 +1588,16 @@
   IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@
 
-  typeset DEST RET status buf_liste ifile target file_work
+  typeset DEST buf_liste ifile target file_work
+  typeset NB_ESSAI DELAI status i
 
   if ( $DEBUG_sys ) ; then
     echo "IGCM_sys_GetBuffer :" $@
   fi
+
+  # number of tentative
+  NB_ESSAI=3
+  # time delay between tentative
+  DELAI=2
+
   if [ $DRYRUN -le 2 ]; then
     if [ X${1} = X'/l' ] ; then
@@ -1588,22 +1611,50 @@
     #USUAL WAY
     if [ X${1} = X'/l' ] ; then
-      (( RET=0 ))
       for target in ${buf_liste[*]} ; do
         local_file=$( basename ${target} )
-        \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1
-        (( RET = RET + $? ))
+        i=0
+        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_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}"
+            IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again."
+            sleep $DELAI
+          else
+            break
+          fi
+          (( i = i + 1 ))
+        done
+        if [ ${status} -gt 0 ] ; then
+          echo "IGCM_sys_Get : error"
+          cat out_rsync
+          \rm out_rsync
+          IGCM_debug_Exit "IGCM_sys_GetBuffer"
+        else
+          \rm out_rsync
+        fi
       done
     else
-      \cp ${buf_liste} ${DEST} >> out_rsync 2>&1
-      status=$?
-    fi
-
-    if [ ${RET} -gt 0 ] ; then
-      echo "IGCM_sys_GetBuffer : error"
-      cat out_rsync
-      \rm out_rsync
-      IGCM_debug_Exit "IGCM_sys_GetBuffer"
-    else
-      \rm out_rsync
+      i=0
+      while [ $i -lt $NB_ESSAI ] ; do
+        \cp ${buf_liste} ${DEST} >> out_rsync 2>&1
+        status=$?
+        if [ ${status} -gt 0 ]; then
+          IGCM_debug_Print 2 "IGCM_sys_GetBuffer : cp failed error code ${status} ${i}/${NB_ESSAI}"
+          IGCM_debug_Print 2 "IGCM_sys_GetBuffer : sleep ${DELAI} seconds and try again."
+          sleep $DELAI
+        else
+          break
+        fi
+        (( i = i + 1 ))
+      done
+      if [ ${status} -gt 0 ] ; then
+        echo "IGCM_sys_Get : error"
+        cat out_rsync
+        \rm out_rsync
+        IGCM_debug_Exit "IGCM_sys_GetBuffer"
+      else
+        \rm out_rsync
+      fi
     fi
   else
