Ignore:
Timestamp:
07/19/12 16:02:21 (12 years ago)
Author:
aclsce
Message:

Modifications done by Guillaume P :

  • error handling for the whole script
  • check of nco version
  • restart tool for list script
  • progress visualization for both scripts
  • "force" option -f added for both scripts
  • timing information added for pack script
File:
1 edited

Legend:

Unmodified
Added
Removed
  • TOOLS/PACK_IPSL/enlarge_my_files.sh

    r1768 r1822  
    8989} 
    9090 
     91# gpdebug : pour test showPackProgress.sh ************************* 
     92export RANDOM=$$ 
     93 
     94function gives_0_or_1 
     95{ 
     96   bit=-1 
     97   let "bit = RANDOM % 2" 
     98   echo $bit 
     99} 
     100 
     101resultCmd= 
     102# gpdebug : ****************************** fin ******************** 
     103 
     104 
     105#********** gpdebug : mesure d'intervalles de temps *************** 
     106function getDateMilliSeconds 
     107{ 
     108   test=`date +%s%N` 
     109   testnum=${#test} 
     110   millisec=${test:0:$testnum-6} 
     111   echo "$millisec" 
     112} 
     113 
     114function getTimeDiffSeconds 
     115{ 
     116   startTimeMilliSec=$1 
     117   endTimeMilliSec=$( getDateMilliSeconds ) 
     118    
     119   diffMilliSec=$(( $endTimeMilliSec - $startTimeMilliSec )) 
     120    
     121   diffSeconds=$(awk 'BEGIN { print '$diffMilliSec'/'1000' }') 
     122   echo "$diffSeconds"   
     123 
     124} 
     125# gpdebug : ****************************** fin ******************** 
    91126#------------------------------------------------------ 
    92127for set in $( ls $PATH_SIMU/output_ncrcat/*list ) ; do 
     
    158193        # Try 2 times before fire "FAILED" 
    159194        ncrcatcmd=ncrcat 
    160         ncrcatoptions="--md5_digest" 
    161 #       ncrcatoptions="" 
    162  
    163         cat $set | $ncrcatcmd $ncrcatoptions -O -x -v $varstoexclude -o $outputfile > $logfile 2>&1 
     195#       ncrcatoptions="--md5_digest" 
     196        ncrcatoptions="" 
     197 
     198        startTime=$( getDateMilliSeconds ) # gpdebug : time 
     199        cat $set | $ncrcatcmd $ncrcatoptions -O -x -v $varstoexclude -o $outputfile > $logfile 2>&1 # gpdebug : a retablir 
     200        meantime=$( getTimeDiffSeconds $startTime ) # gpdebug : time 
     201         
     202        # resultCmd=$( gives_0_or_1 ) 
     203        # resultCmd=1 
     204        # if [ $resultCmd -eq 0 ] ; then 
    164205        if [ $? -eq 0 ] ; then 
     206                sed -i "1i\meantime:${meantime}" $statusfile # gpdebug : time 
    165207                datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"` 
    166208                echo "DONE ; $datestr1 ; $datestr2 ; cat $set | $ncrcatcmd $ncrcatoptions -O -x -v '$varstoexclude' -o $outputfile ; $logfile ; $extratar" >> $statusfile 
     
    169211        else 
    170212                # Add --md5_digest 
    171                 cat $set | $ncrcatcmd $ncrcatoptions -O -x -v $varstoexclude -o $outputfile > $logfile 2>&1 
     213                startTime=$( getDateMilliSeconds ) # gpdebug : time 
     214                cat $set | $ncrcatcmd $ncrcatoptions -O -x -v $varstoexclude -o $outputfile > $logfile 2>&1 # gpdebug : a retablir 
     215                meantime=$( getTimeDiffSeconds $startTime ) # gpdebug : time 
     216                # resultCmd=$( gives_0_or_1 ) 
     217                # resultCmd=1 
     218                # if [ $resultCmd -eq 0 ] ; then 
    172219                if [ $? -eq 0 ] ; then 
     220                        sed -i "1i\meantime:${meantime}" $statusfile # gpdebug : time 
    173221                        datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"` 
    174222                        echo "DONE ; $datestr1 ; $datestr2 ; cat $set | $ncrcatcmd $ncrcatoptions -O -x -v '$varstoexclude' -o $outputfile ; $logfile ; $extratar" >> $statusfile 
     
    178226                        datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"` 
    179227                        echo "====> FAILED at try #$nbtries"  
    180                         echo "FAILED ; $datestr1 ; $datestr2 ; cat $set | $ncrcatcmd $ncrcatoptions -O -x -v '$varstoexclude' -o $outputfile ; $logfile ; $extratar" >> $statusfile 
     228                        echo "FAILED at try #$nbtries ; $datestr1 ; $datestr2 ; cat $set | $ncrcatcmd $ncrcatoptions -O -x -v '$varstoexclude' -o $outputfile ; $logfile ; $extratar" >> $statusfile 
    181229                        if [ $nbtries -ge $maxtries ] ; then 
    182230                                echo "====> DELEGATE to tar command after $nbtries tries (maxtries=$maxtries)" 
    183231                                echo "DELEGATE to tar command after $nbtries tries (maxtries=$maxtries)" >> $statusfile 
    184                                 cp $set $PATH_SIMU/output_tar 
     232                                # cp $set $PATH_SIMU/output_tar # gpdebug : a retablir 
    185233                        fi 
    186234                fi 
     
    238286        # Waiting for CCRT command 
    239287        tarcmd=tar 
    240         taroptions="--format=posix -W -cf" 
    241          
     288#       taroptions="--format=posix -W -cf" 
     289        taroptions="--format=posix -cf" 
    242290        cd $dirinputfile 
    243291 
     
    248296             
    249297#       #----------------------------------- 
    250  
    251         $tarcmd $taroptions $outputfile --dereference --files-from $set.local > $logfile 2>&1 
     298        startTime=$( getDateMilliSeconds ) # gpdebug : time 
     299        $tarcmd $taroptions $outputfile --dereference --files-from $set.local > $logfile 2>&1 # gpdebug : a retablir 
     300        meantime=$( getTimeDiffSeconds $startTime ) # gpdebug : time 
     301         
     302        # resultCmd=$( gives_0_or_1 ) 
     303        # if [ $resultCmd -eq 0 ] ; then 
    252304        if [ $? -eq 0 ] ; then 
     305            sed -i "1i\meantime:${meantime}" $statusfile # gpdebug : time 
    253306            datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"` 
    254307            echo "DONE ; $datestr1 ; $datestr2 ; $tarcmd $taroptions $outputfile $(cat $set); $logfile" >> $statusfile 
     
    258311            datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"` 
    259312            echo "====> FAILED at try #$nbtries"  
    260             echo "FAILED ; $datestr1 ; $datestr2 ; $tarcmd $taroptions $outputfile $(cat $set) ; $logfile" >> $statusfile 
     313            echo "FAILED at try #$nbtries ; $datestr1 ; $datestr2 ; $tarcmd $taroptions $outputfile $(cat $set) ; $logfile" >> $statusfile 
    261314 
    262315        fi 
     
    314367        # Waiting for CCRT command 
    315368        tarcmd=tar 
    316         taroptions="--format=posix -W -cf" 
    317          
     369#       taroptions="--format=posix -W -cf" 
     370        taroptions="--format=posix -cf" 
    318371        cd $dirin1 
    319372#       ls 
    320373         
    321         $tarcmd $taroptions $outputfile --dereference --files-from $set > $logfile 2>&1 
     374        startTime=$( getDateMilliSeconds ) # gpdebug : time 
     375        $tarcmd $taroptions $outputfile --dereference --files-from $set > $logfile 2>&1 # gpdebug : a retablir 
     376        meantime=$( getTimeDiffSeconds $startTime ) # gpdebug : time 
     377         
     378        # resultCmd=$( gives_0_or_1 ) 
     379        # if [ $resultCmd -eq 0 ] ; then 
    322380        if [ $? -eq 0 ] ; then 
     381            sed -i "1i\meantime:${meantime}" $statusfile # gpdebug : time 
    323382            datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"` 
    324383            echo "DONE ; $datestr1 ; $datestr2 ; $tarcmd $taroptions $outputfile $(cat $set); $logfile" >> $statusfile 
     
    328387            datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"` 
    329388            echo "====> FAILED at try #$nbtries"  
    330             echo "FAILED ; $datestr1 ; $datestr2 ; $tarcmd $taroptions $outputfile $(cat $set) ; $logfile" >> $statusfile 
     389            echo "FAILED at try #$nbtries ; $datestr1 ; $datestr2 ; $tarcmd $taroptions $outputfile $(cat $set) ; $logfile" >> $statusfile 
    331390 
    332391        fi 
     
    382441        # Waiting for CCRT command 
    383442        tarcmd=tar 
    384         taroptions="--format=posix -W -cf" 
    385          
     443#       taroptions="--format=posix -W -cf" 
     444        taroptions="--format=posix -cf" 
    386445        cd $dirin1 
    387446#       ls 
    388          
    389         $tarcmd $taroptions $outputfile --dereference --files-from $set > $logfile 2>&1 
     447 
     448        startTime=$( getDateMilliSeconds ) # gpdebug : time 
     449        $tarcmd $taroptions $outputfile --dereference --files-from $set > $logfile 2>&1 # gpdebug : a retablir 
     450        meantime=$( getTimeDiffSeconds $startTime ) # gpdebug : time 
     451         
     452        # resultCmd=$( gives_0_or_1 ) 
     453        # if [ $resultCmd -eq 0 ] ; then 
    390454        if [ $? -eq 0 ] ; then 
     455            sed -i "1i\meantime:${meantime}" $statusfile # gpdebug : time 
    391456            datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"` 
    392457            echo "DONE ; $datestr1 ; $datestr2 ; $tarcmd $taroptions $outputfile $(cat $set); $logfile" >> $statusfile 
     
    396461            datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"` 
    397462            echo "====> FAILED at try #$nbtries"  
    398             echo "FAILED ; $datestr1 ; $datestr2 ; $tarcmd $taroptions $outputfile $(cat $set) ; $logfile" >> $statusfile 
     463            echo "FAILED at try #$nbtries ; $datestr1 ; $datestr2 ; $tarcmd $taroptions $outputfile $(cat $set) ; $logfile" >> $statusfile 
    399464 
    400465        fi 
     
    447512            cpcmd="cp " 
    448513            cpoptions="-rf" 
    449             $cpcmd $cpoptions $file $diroutputfile > $logfile 2>&1 
     514            startTime=$( getDateMilliSeconds ) # gpdebug : time 
     515            $cpcmd $cpoptions $file $diroutputfile > $logfile 2>&1 # gpdebug : a retablir 
     516            meantime=$( getTimeDiffSeconds $startTime ) # gpdebug : time 
    450517        done 
    451  
     518         
     519        # resultCmd=$( gives_0_or_1 ) 
     520        # if [ $resultCmd -eq 0 ] ; then 
    452521        if [ $? -eq 0 ] ; then 
     522            sed -i "1i\meantime:${meantime}" $statusfile # gpdebug : time 
    453523            datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"` 
    454524            echo "DONE ; $datestr1 ; $datestr2 ; $cpcmd $cpoptions $file $diroutputfile ; $logfile" >> $statusfile 
     
    458528            datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"` 
    459529            echo "====> FAILED at try #$nbtries"  
    460             echo "FAILED ; $datestr1 ; $datestr2 ; $cpcmd $cpoptions $file $diroutputfile ; $logfile" >> $statusfile 
     530            echo "FAILED at try #$nbtries ; $datestr1 ; $datestr2 ; $cpcmd $cpoptions $file $diroutputfile ; $logfile" >> $statusfile 
    461531 
    462532        fi 
     
    509579            cpcmd="cp " 
    510580            cpoptions="-rf" 
    511             $cpcmd $cpoptions $file $diroutputfile > $logfile 2>&1 
     581            startTime=$( getDateMilliSeconds ) # gpdebug : time 
     582            $cpcmd $cpoptions $file $diroutputfile > $logfile 2>&1  # gpdebug : a retablir 
     583            meantime=$( getTimeDiffSeconds $startTime ) # gpdebug : timeS 
    512584        done 
    513  
     585         
     586        # resultCmd=$( gives_0_or_1 ) 
     587        # if [ $resultCmd -eq 0 ] ; then 
    514588        if [ $? -eq 0 ] ; then 
     589            sed -i "1i\meantime:${meantime}" $statusfile # gpdebug : time 
    515590            datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"` 
    516591            echo "DONE ; $datestr1 ; $datestr2 ; $cpcmd $cpoptions $file $diroutputfile ; $logfile" >> $statusfile 
     
    520595            datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"` 
    521596            echo "====> FAILED at try #$nbtries"  
    522             echo "FAILED ; $datestr1 ; $datestr2 ; $cpcmd $cpoptions $file $diroutputfile ; $logfile" >> $statusfile 
     597            echo "FAILED at try #$nbtries ; $datestr1 ; $datestr2 ; $cpcmd $cpoptions $file $diroutputfile ; $logfile" >> $statusfile 
    523598 
    524599        fi 
Note: See TracChangeset for help on using the changeset viewer.