Index: /trunk/libIGCM/libIGCM_sys/libIGCM_sys_curie.ksh
===================================================================
--- /trunk/libIGCM/libIGCM_sys/libIGCM_sys_curie.ksh	(revision 710)
+++ /trunk/libIGCM/libIGCM_sys/libIGCM_sys_curie.ksh	(revision 711)
@@ -1212,5 +1212,5 @@
   fi
 
-  typeset NB_ESSAI DELAI RET i
+  typeset NB_ESSAI DELAI status i exist skip
 
   # number of tentative
@@ -1250,18 +1250,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 ${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
@@ -1273,11 +1295,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
@@ -1303,4 +1325,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
@@ -1312,5 +1342,4 @@
     IGCM_sys_Mkdir $( dirname $2 )
     #
-    typeset RET
 
     if [ X${JobType} = XRUN ] ; then
@@ -1319,10 +1348,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 ${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
@@ -1637,5 +1697,5 @@
     echo "IGCM_sys_Put_Dods :" $@
   fi
-  set -vx
+  #set -vx
   typeset RET
   if [ $DRYRUN = 0 ]; then
