Changeset 710 for trunk


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

Legend:

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

    r705 r710  
    990990  fi 
    991991 
    992   typeset NB_ESSAI DELAI RET i exist skip 
     992  typeset NB_ESSAI DELAI status i exist skip 
    993993 
    994994  # number of tentative 
     
    10531053        # USUAL WAY 
    10541054        \cp $1 $2 > out_rsync 2>&1 
    1055         RET=$? 
    1056         if [ ${RET} -gt 0 ]; then 
     1055        status=$? 
     1056        if [ ${status} -gt 0 ]; then 
    10571057          IGCM_debug_Print 2 "IGCM_sys_Put_Out : cp failed ${i}/${NB_ESSAI}" 
    10581058          IGCM_debug_Print 2 "IGCM_sys_Put_Out : sleep ${DELAI} seconds and try again." 
     
    10731073#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1 
    10741074 
    1075 #       RET=$? 
    1076 #       IGCM_sys_Rsync_out $RET 
     1075#       status=$? 
     1076#       IGCM_sys_Rsync_out $status 
    10771077 
    10781078#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync 
    1079 #       (( RET=RET+$? )) 
    1080  
    1081     if [ ${RET} -gt 0 ] ; then 
     1079#       (( status=status+$? )) 
     1080 
     1081    if [ ${status} -gt 0 ] ; then 
    10821082      echo "IGCM_sys_Put_Out : error." 
    10831083      cat out_rsync 
     
    11031103    echo "IGCM_sys_PutBuffer_Out :" $@ 
    11041104  fi 
     1105 
     1106  typeset NB_ESSAI DELAI status i exist skip  
     1107 
     1108  # number of tentative 
     1109  NB_ESSAI=3 
     1110  # time delay between tentative 
     1111  DELAI=2 
     1112 
    11051113  if [ $DRYRUN = 0 ]; then 
    11061114    if [ ! -f ${1} ] ; then 
     
    11121120    IGCM_sys_Mkdir $( dirname $2 ) 
    11131121    # 
    1114     typeset RET 
    11151122 
    11161123    if [ X${JobType} = XRUN ] ; then 
     
    11191126      fi 
    11201127    fi 
     1128 
     1129    exist=false 
     1130    skip=false 
     1131    if [ -f $2 ] ; then 
     1132      IGCM_debug_Print 1 "$2 already exist" 
     1133      exist=true 
     1134      if [ "X$( diff $1 $2 )" = X ] ; then 
     1135        IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy" 
     1136        skip=true 
     1137      else 
     1138        IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy" 
     1139        skip=false 
     1140      fi 
     1141    fi 
    11211142    # 
    1122     # USUAL WAY 
    1123     #\cp $1 $2 > out_rsync 2>&1 
    1124     \mv $1 $2 > out_rsync 2>&1 
    1125  
    1126     RET=$? 
    1127  
    1128     if [ ${RET} -gt 0 ] ; then 
     1143    if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then 
     1144      IGCM_sys_Chmod u+w $2 
     1145    fi 
     1146 
     1147    if [ X${skip} = Xfalse ] ; then 
     1148      i=0 
     1149      while [ $i -lt $NB_ESSAI ] ; do 
     1150        # USUAL WAY 
     1151        #\cp $1 $2 > out_rsync 2>&1 
     1152        \mv $1 $2 > out_rsync 2>&1 
     1153        status=$? 
     1154        if [ ${status} -gt 0 ]; then 
     1155          IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : cp failed ${i}/${NB_ESSAI}" 
     1156          IGCM_debug_Print 2 "IGCM_sys_PutBuffer_Out : sleep ${DELAI} seconds and try again." 
     1157          sleep $DELAI 
     1158        else 
     1159          break 
     1160        fi 
     1161        (( i = i + 1 )) 
     1162      done 
     1163    fi 
     1164 
     1165    if [ ${status} -gt 0 ] ; then 
    11291166      echo "IGCM_sys_PutBuffer_Out : error." 
    11301167      cat out_rsync 
Note: See TracChangeset for help on using the changeset viewer.