Ignore:
Timestamp:
06/05/12 16:31:28 (12 years ago)
Author:
sdipsl
Message:
  • Prevent the fact that cp command is not reliable on ccrt/tgcc filesystems
  • Cosmetics
File:
1 edited

Legend:

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

    r669 r676  
    1 #!/bin/ksh  
     1#!/bin/ksh 
    22 
    33#************************************************************** 
     
    1414#========================================================= 
    1515# The documentation of this file can be automatically generated 
    16 # if you use the prefix #D- for comments to be extracted.  
     16# if you use the prefix #D- for comments to be extracted. 
    1717# Extract with command: cat lib* | grep "^#D-" | cut -c "4-" 
    1818#========================================================= 
     
    2222#D-#================================================== 
    2323#D- 
    24 #D- This ksh library if a layer under some usefull  
     24#D- This ksh library if a layer under some usefull 
    2525#D-environment variables and shell commands. 
    2626#D-All those definitions depend on host particularities. 
     
    9494 
    9595#==================================================== 
    96 # For interactive jobs on mercure  
     96# For interactive jobs on mercure 
    9797PBS_O_WORKDIR=${PBS_O_WORKDIR:=$(pwd)} 
    9898 
     
    220220    status=completed 
    221221  fi 
     222 
    222223  cat  << END_MAIL > job_end.mail 
    223224Dear ${LOGIN}, 
     
    281282  fi 
    282283  #- creation de repertoire sur le serveur fichier 
    283   if [ ! -d ${1} ]; then  
     284  if [ ! -d ${1} ]; then 
    284285    \mkdir -p $1 
    285286    if [ $? -gt 0 ] ; then 
     
    302303  fi 
    303304  #- creation de repertoire sur le serveur fichier 
    304   if [ ! -d ${1} ]; then  
     305  if [ ! -d ${1} ]; then 
    305306    \mkdir -p $1 
    306307    if [ $? -gt 0 ] ; then 
     
    548549 
    549550#D-************************* 
    550 #D- File transfer functions  
     551#D- File transfer functions 
    551552#D-************************* 
    552553#D- 
     
    617618  elif [ $MYLANG = "en" ] ; then 
    618619    case $RET in 
    619     0)  return;;                 
     620    0)  return;; 
    620621    1)  echo "rsync error : Syntax or usage error " 
    621622      return;; 
     
    746747 
    747748    typeset RET 
    748      
     749 
    749750    echo mv $@ > out_rsync 2>&1 
    750751    \mv $@ >> out_rsync 2>&1 
    751752    RET=$? 
    752      
     753 
    753754    if [ ${RET} -gt 0 ] ; then 
    754755      echo "IGCM_sys_Mv : error in mv." 
     
    806807#D-#================================================== 
    807808#D-function IGCM_sys_Get_Dir 
    808 #D-* Purpose: Copy a complete directory from $(ARCHIVE) 
     809#D-* Purpose: Copy a complete directory from ${ARCHIVE} 
    809810#D-* Examples: 
    810811#D- 
     
    815816  fi 
    816817  if [ $DRYRUN = 0 ]; then 
    817 #       if [ ! -d ${1} ] ; then 
    818 #           echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ." 
    819 #           IGCM_debug_PopStack "IGCM_sys_Get_Dir" 
    820 #           return 
    821 #       fi 
     818#    if [ ! -d ${1} ] ; then 
     819#      echo "WARNING : IGCM_sys_Get_Dir ${1} DOES NOT EXIST ." 
     820#      IGCM_debug_PopStack "IGCM_sys_Get_Dir" 
     821#      return 
     822#    fi 
    822823 
    823824    typeset RET 
     
    910911    RET=$? 
    911912 
    912 #       #RSYNC WITH NETWORK SSH CALL 
    913 #       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1 
    914 #       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1 
    915  
    916      #RSYNC WITH NFS USE 
    917      echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1 
    918      ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1 
    919  
    920      RET=$? 
    921      IGCM_sys_Rsync_out $RET 
    922  
    923      ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync 
    924      (( RET=RET+$? )) 
     913#       #RSYNC WITH NETWORK SSH CALL 
     914#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1 
     915#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1 
     916 
     917     #RSYNC WITH NFS USE 
     918     echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1 
     919     ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1 
     920 
     921     RET=$? 
     922     IGCM_sys_Rsync_out $RET 
     923 
     924     ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync 
     925     (( RET=RET+$? )) 
    925926 
    926927    if [ ${RET} -gt 0 ] ; then 
     
    988989    echo "IGCM_sys_Put_Out :" $@ 
    989990  fi 
     991 
     992  typeset NB_ESSAI DELAI RET i exist skip 
     993 
     994  # number of tentative 
     995  NB_ESSAI=3 
     996  # time delay between tentative 
     997  DELAI=2 
     998 
    990999  if [ $DRYRUN = 0 ]; then 
    9911000    if [ ! -f ${1} ] ; then 
     
    9971006    IGCM_sys_MkdirArchive $( dirname $2 ) 
    9981007    # 
    999     typeset RET exist skip 
    10001008 
    10011009    #===================================================== 
     
    10071015    #    typeset WORKPATH FILEPATH 
    10081016    #    WORKPATH=$( dirname $2 | sed -e "s|${R_OUT}|${R_BUF}|" ) 
    1009     #    IGCM_sys_MkdirWork ${WORKPATH}  
     1017    #    IGCM_sys_MkdirWork ${WORKPATH} 
    10101018    #    FILEPATH=${WORKPATH}/$( basename $2 ) 
    10111019    #    # 
     
    10151023    if [ X${JobType} = XRUN ] ; then 
    10161024      if [ X${3} = X ] ; then 
    1017         IGCM_sys_Chmod 444 ${1} 
     1025        IGCM_sys_Chmod 444 ${1} 
    10181026      fi 
    10191027    fi 
     1028    # 
    10201029 
    10211030    exist=false 
     
    10271036      exist=true 
    10281037      if [ "X$( diff $1 $2 )" = X ] ; then 
    1029         IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy" 
    1030         skip=true 
     1038        IGCM_debug_Print 2 "$1 and $2 are the same file, we skip the copy" 
     1039        skip=true 
    10311040      else 
    1032         IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy" 
    1033         skip=false 
     1041        IGCM_debug_Print 2 "$1 and $2 are not the same file, we force the copy" 
     1042        skip=false 
    10341043      fi 
    10351044    fi 
    1036     #  
     1045    # 
    10371046    if ( [ X${exist} = Xtrue ] && [ X${skip} = Xfalse ] ) ; then 
    10381047      IGCM_sys_Chmod u+w $2 
    10391048    fi 
    1040     # USUAL WAY 
     1049 
    10411050    if [ X${skip} = Xfalse ] ; then 
    1042       \cp $1 $2 > out_rsync 2>&1 
    1043       RET=$? 
    1044       if [ ${RET} -gt 0 ] ; then 
    1045         echo "IGCM_sys_Put_Out : error." 
    1046         cat out_rsync 
    1047         IGCM_debug_Exit "IGCM_sys_Put_Out" 
    1048       else 
    1049         \rm out_rsync 
    1050       fi 
    1051     fi 
    1052  
    1053 #       #RSYNC WITH NETWORK SSH CALL 
    1054 #       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1 
    1055 #       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1 
    1056  
    1057 #       #RSYNC WITH NFS USE 
    1058 #       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1 
    1059 #       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1 
    1060  
    1061 #       RET=$? 
    1062 #       IGCM_sys_Rsync_out $RET 
    1063  
    1064 #       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync 
    1065 #       (( RET=RET+$? )) 
    1066  
     1051      (( i = 0 )) 
     1052      while [ $i -lt $NB_ESSAI ] ; do 
     1053        # USUAL WAY 
     1054        \cp $1 $2 > out_rsync 2>&1 
     1055        RET=$? 
     1056        if [ ${RET} -gt 0 ]; then 
     1057          IGCM_debug_Print 2 "IGCM_sys_Put_Out : cp failed ${i}/${NB_ESSAI}" 
     1058          IGCM_debug_Print 2 "IGCM_sys_Put_Out : sleep ${DELAI} seconds and try again." 
     1059          sleep $DELAI 
     1060        else 
     1061          break 
     1062        fi 
     1063        (( i = i + 1 )) 
     1064      done 
     1065    fi 
     1066 
     1067#       #RSYNC WITH NETWORK SSH CALL 
     1068#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} > out_rsync 2>&1 
     1069#       ${RSYNC} ${RSYNC_opt} -e ssh ${RUN_DIR}/$1 ${STOREHOST}:${2} >> out_rsync 2>&1 
     1070 
     1071#       #RSYNC WITH NFS USE 
     1072#       echo ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} > out_rsync 2>&1 
     1073#       ${RSYNC} ${RSYNC_opt} ${RUN_DIR}/$1 ${2} >> out_rsync 2>&1 
     1074 
     1075#       RET=$? 
     1076#       IGCM_sys_Rsync_out $RET 
     1077 
     1078#       ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync 
     1079#       (( RET=RET+$? )) 
     1080 
     1081    if [ ${RET} -gt 0 ] ; then 
     1082      echo "IGCM_sys_Put_Out : error." 
     1083      cat out_rsync 
     1084      IGCM_debug_Exit "IGCM_sys_Put_Out" 
     1085    else 
     1086      \rm out_rsync 
     1087    fi 
    10671088  else 
    10681089    ( ${DEBUG_debug} ) && echo "DRYRUN mode = " $DRYRUN >> stack 
     
    10951116    if [ X${JobType} = XRUN ] ; then 
    10961117      if [ X${3} = X ] ; then 
    1097         IGCM_sys_Chmod 444 ${1} 
     1118        IGCM_sys_Chmod 444 ${1} 
    10981119      fi 
    10991120    fi 
     
    11251146  IGCM_debug_PushStack "IGCM_sys_Get" $@ 
    11261147 
    1127   typeset DEST RET dm_liste ifile target file_work  
     1148  typeset DEST RET dm_liste ifile target file_work 
     1149  typeset NB_ESSAI DELAI status i 
    11281150 
    11291151  if ( $DEBUG_sys ) ; then 
    11301152    echo "IGCM_sys_Get :" $@ 
    11311153  fi 
     1154 
     1155  # number of tentative 
     1156  NB_ESSAI=3 
     1157  # time delay between tentative 
     1158  DELAI=2 
     1159 
    11321160  if [ $DRYRUN -le 2 ]; then 
    11331161    if [ X${1} = X'/l' ] ; then 
     
    11551183    #fi 
    11561184 
    1157     # test if the (first) file is present in the old computation : 
    1158     IGCM_sys_TestFileArchive ${dm_liste[0]} 
    1159     RET=$? 
    1160     if [ ${RET} -gt 0 ] ; then 
    1161       echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ." 
    1162       IGCM_debug_Exit "IGCM_sys_Get" 
    1163     fi 
    1164  
    1165     #dmget ${dm_liste[*]} > out_rsync 2>&1 
    11661185    ccc_hsm get ${dm_liste[*]} > out_rsync 2>&1 
    11671186    RET=$? 
    1168  
    11691187    if [ ${RET} -gt 0 ] ; then 
    11701188      echo "WARNING IGCM_sys_Get : demigration error." 
     
    11831201    #   RET=$? 
    11841202    #   if [ ${RET} -gt 0 ] ; then 
    1185     #       echo "ERROR IGCM_sys_Get : again demigration error :" 
    1186     #       cat out_rsync 
    1187     #       IGCM_debug_Exit "IGCM_sys_Get" 
     1203    #       echo "ERROR IGCM_sys_Get : again demigration error :" 
     1204    #       cat out_rsync 
     1205    #       IGCM_debug_Exit "IGCM_sys_Get" 
    11881206    #   fi 
    11891207    #    else 
     
    11981216      (( RET=0 )) 
    11991217      for target in ${dm_liste[*]} ; do 
    1200         local_file=$( basename ${target} ) 
    1201         \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1 
    1202         (( RET = RET + $? )) 
     1218        local_file=$( basename ${target} ) 
     1219        (( i = 0 )) 
     1220        # test if the target file is present before the loop 
     1221        IGCM_sys_TestFileArchive ${target} 
     1222        RET=$? 
     1223        if [ ${RET} -gt 0 ] ; then 
     1224          echo "IGCM_sys_Get, ERROR : regular file ${dm_liste[0]} DOES NOT EXIST ." 
     1225          IGCM_debug_Exit "IGCM_sys_Get" 
     1226        else 
     1227          while [ $i -lt $NB_ESSAI ] ; do 
     1228            \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1 
     1229            status=$? 
     1230            if [ ${status} -gt 0 ]; then 
     1231              IGCM_debug_Print 2 "IGCM_sys_Get : cp failed ${i}/${NB_ESSAI}" 
     1232              IGCM_debug_Print 2 "IGCM_sys_Get : sleep ${DELAI} seconds and try again." 
     1233              sleep $DELAI 
     1234            else 
     1235              break 
     1236            fi 
     1237            (( i = i + 1 )) 
     1238          done 
     1239          (( RET = RET + status )) 
     1240        fi 
    12031241      done 
    12041242    else 
     
    12071245    fi 
    12081246 
    1209 #       #RSYNC WITH NETWORK SSH CALL 
    1210 #       echo ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1 
    1211 #       ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1 
    1212  
    1213      #RSYNC WITH NFS USE 
    1214      echo ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > out_rsync 2>&1 
    1215      ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> out_rsync 2>&1 
    1216  
    1217 #       RET=$? 
    1218      IGCM_sys_Rsync_out $RET 
    1219  
    1220      ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync 
    1221      (( RET=RET+$? )) 
     1247#       #RSYNC WITH NETWORK SSH CALL 
     1248#       echo ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} > out_rsync 2>&1 
     1249#       ${RSYNC} ${RSYNC_opt} -e ssh ${STOREHOST}:"${dm_liste}" ${STOREHOST}:${RUN_DIR}/${DEST} >> out_rsync 2>&1 
     1250 
     1251     #RSYNC WITH NFS USE 
     1252     echo ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} > out_rsync 2>&1 
     1253     ${RSYNC} ${RSYNC_opt} ${dm_liste} ${RUN_DIR}/${DEST} >> out_rsync 2>&1 
     1254 
     1255#       RET=$? 
     1256     IGCM_sys_Rsync_out $RET 
     1257 
     1258     ${libIGCM}/libIGCM_sys/IGCM_analyse_rsync_out.awk out_rsync 
     1259     (( RET=RET+$? )) 
    12221260 
    12231261    if [ ${RET} -gt 0 ] ; then 
     
    12421280  IGCM_debug_PushStack "IGCM_sys_GetBuffer" $@ 
    12431281 
    1244   typeset DEST RET buf_liste ifile target file_work  
     1282  typeset DEST RET buf_liste ifile target file_work 
    12451283 
    12461284  if ( $DEBUG_sys ) ; then 
     
    12601298      (( RET=0 )) 
    12611299      for target in ${buf_liste[*]} ; do 
    1262         local_file=$( basename ${target} ) 
    1263         \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1 
    1264         (( RET = RET + $? )) 
     1300        local_file=$( basename ${target} ) 
     1301        \cp ${target} ${DEST}/${local_file} >> out_rsync 2>&1 
     1302        (( RET = RET + $? )) 
    12651303      done 
    12661304    else 
     
    12981336#D-#================================================== 
    12991337#D-function IGCM_sys_GetDate_FichArchive 
    1300 #D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE  
     1338#D-* Purpose: donne la date filesys d'un fichier sur le filesystem ARCHIVE 
    13011339#D-* Examples: 
    13021340#D- 
     
    13111349#D-#================================================== 
    13121350#D-function IGCM_sys_Dods_Rm 
    1313 #D-* Purpose: DO NOTHING ! Put $(ARCHIVE) files on DODS internet protocole. 
     1351#D-* Purpose: DO NOTHING ! Put ${ARCHIVE} files on DODS internet protocole. 
    13141352#D-* Examples: 
    13151353#D- 
     
    13301368    /ccc/cont003/home/dsm/p86ipsl/bin/dods_rm public/${LOGIN}/${R_DODS}/${1} # > out_dods_rm 2>&1 
    13311369    RET=$? 
    1332      
     1370 
    13331371#       if [ ${RET} -gt 0 ] ; then 
    1334 #           echo "IGCM_sys_Dods_Rm : error." 
    1335 #           cat out_dods_rm 
    1336 #           IGCM_debug_Exit "IGCM_sys_Dods_Rm" 
     1372#           echo "IGCM_sys_Dods_Rm : error." 
     1373#           cat out_dods_rm 
     1374#           IGCM_debug_Exit "IGCM_sys_Dods_Rm" 
    13371375#       else 
    1338 #           rm out_dods_rm 
     1376#           rm out_dods_rm 
    13391377#       fi 
    13401378 
     
    13671405    RET=$? 
    13681406 
    1369 #       if [ ${RET} -gt 0 ] ; then 
    1370 #           echo "IGCM_sys_Dods_Cp : error." 
    1371 #           cat out_dods_cp 
    1372 #           IGCM_debug_Exit "IGCM_sys_Dods_Cp" 
    1373 #       else 
    1374 #           rm out_dods_cp 
    1375 #       fi 
     1407#       if [ ${RET} -gt 0 ] ; then 
     1408#           echo "IGCM_sys_Dods_Cp : error." 
     1409#           cat out_dods_cp 
     1410#           IGCM_debug_Exit "IGCM_sys_Dods_Cp" 
     1411#       else 
     1412#           rm out_dods_cp 
     1413#       fi 
    13761414 
    13771415  else 
     
    14181456    IGCM_sys_Dods_Cp ${1} 
    14191457    RET=0 
    1420      
     1458 
    14211459    if [ ${RET} -gt 0 ] ; then 
    14221460      echo "IGCM_sys_Put_Dods : error." 
Note: See TracChangeset for help on using the changeset viewer.