Changeset 711


Ignore:
Timestamp:
09/27/12 16:31:38 (12 years ago)
Author:
sdipsl
Message:
  • check existence of already copied files by and IGCM_sys_Put_Out IGCM_sys_PutBuffer_Out. #68
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libIGCM/libIGCM_sys/libIGCM_sys_curie.ksh

    r709 r711  
    12121212  fi 
    12131213 
    1214   typeset NB_ESSAI DELAI RET i 
     1214  typeset NB_ESSAI DELAI status i exist skip 
    12151215 
    12161216  # number of tentative 
     
    12501250    # 
    12511251 
    1252     (( i = 0 )) 
    1253     while [ $i -lt $NB_ESSAI ] ; do 
    1254     # USUAL WAY 
    1255       \cp $1 $2 > out_rsync 2>&1 
    1256       RET=$? 
    1257       if [ ${RET} -gt 0 ]; then 
    1258         IGCM_debug_Print 2 "IGCM_sys_Put_Out : cp failed ${i}/${NB_ESSAI}" 
    1259         IGCM_debug_Print 2 "IGCM_sys_Put_Out : sleep ${DELAI} seconds and try again." 
    1260         sleep $DELAI 
     1252    exist=false 
     1253    skip=false 
     1254    if [ -f $2 ] ; then 
     1255      IGCM_debug_Print 1 "$2 already exist" 
     1256      #dmget $2 
     1257      ccc_hsm get $2 
     1258      exist=true 
     1259      if [ "X$( diff $1 $2 )" = X ] ; then 
     1260        IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy" 
     1261        skip=true 
    12611262      else 
    1262         break 
     1263        IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy" 
     1264        skip=false 
    12631265      fi 
    1264       (( i = i + 1 )) 
    1265     done 
     1266    fi 
     1267    # 
     1268    if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then 
     1269      IGCM_sys_Chmod u+w $2 
     1270    fi 
     1271 
     1272    if [ X${skip} = Xfalse ] ; then 
     1273      (( i = 0 )) 
     1274      while [ $i -lt $NB_ESSAI ] ; do 
     1275        # USUAL WAY 
     1276        \cp $1 $2 > out_rsync 2>&1 
     1277        status=$? 
     1278        if [ ${status} -gt 0 ]; then 
     1279          IGCM_debug_Print 2 "IGCM_sys_Put_Out : cp failed ${i}/${NB_ESSAI}" 
     1280          IGCM_debug_Print 2 "IGCM_sys_Put_Out : sleep ${DELAI} seconds and try again." 
     1281          sleep $DELAI 
     1282        else 
     1283          break 
     1284        fi 
     1285        (( i = i + 1 )) 
     1286      done 
     1287    fi 
    12661288 
    12671289#       #RSYNC WITH NETWORK SSH CALL 
     
    12731295#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1 
    12741296 
    1275 #       RET=$? 
    1276 #       IGCM_sys_Rsync_out $RET 
     1297#       status=$? 
     1298#       IGCM_sys_Rsync_out $status 
    12771299 
    12781300#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync 
    1279 #       (( RET=RET+$? )) 
    1280  
    1281     if [ ${RET} -gt 0 ] ; then 
     1301#       (( status=status+$? )) 
     1302 
     1303    if [ ${status} -gt 0 ] ; then 
    12821304      echo "IGCM_sys_Put_Out : error." 
    12831305      cat out_rsync 
     
    13031325    echo "IGCM_sys_PutBuffer_Out :" $@ 
    13041326  fi 
     1327 
     1328  typeset NB_ESSAI DELAI status i exist skip  
     1329 
     1330  # number of tentative 
     1331  NB_ESSAI=3 
     1332  # time delay between tentative 
     1333  DELAI=2 
     1334 
    13051335  if [ $DRYRUN = 0 ]; then 
    13061336    if [ ! -f ${1} ] ; then 
     
    13121342    IGCM_sys_Mkdir $( dirname $2 ) 
    13131343    # 
    1314     typeset RET 
    13151344 
    13161345    if [ X${JobType} = XRUN ] ; then 
     
    13191348      fi 
    13201349    fi 
     1350 
     1351    exist=false 
     1352    skip=false 
     1353    if [ -f $2 ] ; then 
     1354      IGCM_debug_Print 1 "$2 already exist" 
     1355      exist=true 
     1356      if [ "X$( diff $1 $2 )" = X ] ; then 
     1357        IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy" 
     1358        skip=true 
     1359      else 
     1360        IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy" 
     1361        skip=false 
     1362      fi 
     1363    fi 
    13211364    # 
    1322     # USUAL WAY 
    1323     \cp $1 $2 > out_rsync 2>&1 
    1324     RET=$? 
    1325  
    1326     if [ ${RET} -gt 0 ] ; then 
     1365    if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then 
     1366      IGCM_sys_Chmod u+w $2 
     1367    fi 
     1368 
     1369    if [ X${skip} = Xfalse ] ; then 
     1370      i=0 
     1371      while [ $i -lt $NB_ESSAI ] ; do 
     1372        # USUAL WAY 
     1373        \cp $1 $2 > out_rsync 2>&1 
     1374        status=$? 
     1375        if [ ${status} -gt 0 ]; then 
     1376          IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : cp failed ${i}/${NB_ESSAI}" 
     1377          IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : sleep ${DELAI} seconds and try again." 
     1378          sleep $DELAI 
     1379        else 
     1380          break 
     1381        fi 
     1382        (( i = i + 1 )) 
     1383      done 
     1384    fi 
     1385 
     1386    if [ ${status} -gt 0 ] ; then 
    13271387      echo "IGCM_sys_PutBuffer_Out : error." 
    13281388      cat out_rsync 
     
    16371697    echo "IGCM_sys_Put_Dods :" $@ 
    16381698  fi 
    1639   set -vx 
     1699  #set -vx 
    16401700  typeset RET 
    16411701  if [ $DRYRUN = 0 ]; then 
Note: See TracChangeset for help on using the changeset viewer.