Changeset 1752


Ignore:
Timestamp:
06/06/12 18:01:10 (12 years ago)
Author:
aclsce
Message:

Adapted enlarge tool to work with tar lists and cp lists.

Location:
TOOLS/PACK_IPSL
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • TOOLS/PACK_IPSL/enlarge_my_files.sh

    r1727 r1752  
    11#!/bin/bash 
    2  
    32#------------------------------------------------------ 
    43switchtotar=0 
    54maxtries=3 
    6  
    75#--------------------------------------------- 
    86while [ $# -ne 0 ] 
     
    2018                echo 
    2119                echo "Description:" 
    22                 echo "   Pass a ncrcat command on files from prepared sets of files." 
    23                 echo "   2 shots will be done at each try". 
     20                echo "   Pass a ncrcat, tar or cp command on files from prepared sets of files." 
     21                echo "   For ncrcat command 2 shots will be done at each try". 
    2422                echo   
    25                 echo "   A status file and a log file will be created in enlarge_my_files/with_ncrcat directory." 
    26                 echo "   Copy a set to enlarge_my_files/with_tar directory for later processing after N tries." 
     23                echo "   A status file and a log file will be created in output_ncrcat directory." 
     24                echo "   Copy a set to output_tar directory for later processing after N tries." 
    2725                echo 
    2826                echo "Arguments:" 
     
    3331                echo "       enlarge_my_files" 
    3432                echo "                       |-- with_ncrcat" 
    35                 echo "                       |   |-- set_000001.txt" 
    36                 echo "                       |   |-- set_000002.txt" 
    37                 echo "                       |   |-- set_000003.txt" 
    38                 echo "                       |   |-- set_000004.txt" 
    39                 echo "                       |   \`-- set_000005.txt" 
     33                echo "                       |   |-- set_000001.list" 
     34                echo "                       |   |-- set_000002.list" 
     35                echo "                       |   |-- set_000003.list" 
     36                echo "                       |   |-- set_000004.list" 
     37                echo "                       |   \`-- set_000005.list" 
    4038                echo "                       \`-- with_tar" 
    4139                echo 
     
    6462fi 
    6563 
    66 if [[ ! -d $PATH_SIMU/with_ncrcat || ! -d $PATH_SIMU/with_tar ]] ; then 
     64if [[ ! -d $PATH_SIMU/output_ncrcat || ! -d $PATH_SIMU/output_tar ]] ; then 
    6765        `dirname $0`/enlarge_my_files.sh -h 
    6866        exit 
     
    7270dirin=$1 
    7371dirout=$2 
     72dirout_work=$3 
    7473 
    7574#------------------------------------------------------ 
     
    9190 
    9291#------------------------------------------------------ 
    93 for set in $PATH_SIMU/with_ncrcat/*list ; do 
     92for set in $( ls $PATH_SIMU/output_ncrcat/*list ) ; do 
    9493 
    9594        #----------------------------------- 
     
    159158        # Try 2 times before fire "FAILED" 
    160159        ncrcatcmd=ncrcat 
    161         #ncrcatoptions="--md5_digest" 
    162         ncrcatoptions="" 
     160        ncrcatoptions="--md5_digest" 
     161#       ncrcatoptions="" 
    163162 
    164163        cat $set | $ncrcatcmd $ncrcatoptions -O -x -v $varstoexclude -o $outputfile > $logfile 2>&1 
     
    188187        fi 
    189188         
    190         #----------------------------------- 
    191          
    192189done     
    193190 
    194191#------------------------------------------------------ 
    195192 
    196 #------------------------------------------------------ 
    197 for set in $PATH_SIMU/with_tar/*list ; do 
     193for set in $( ls $PATH_SIMU/output_tar/*list ) ; do 
    198194 
    199195        #----------------------------------- 
     
    227223        # Set output file name from list name 
    228224        filefirst=`head -n 1 $set` 
    229         dirin1=$( dirname $filefirst ) 
    230         fileout1=$( basename $set ) 
    231         fileout=${fileout1%.list} 
     225        dirinputfile=`dirname $filefirst` 
    232226        diroutputfile=`dirname $filefirst | sed -e "s%$dirin%$dirout%"` 
    233 #       outputfile=$diroutputfile/ncrcat_${fileoutpart1}_${fileoutpart2} 
    234         outputfile=$diroutputfile/${fileout}.tar 
    235         echo $outputfile 
     227        mkdir -p $diroutputfile 
     228#           echo "Output file to write: $outputfile" 
     229        fileout1=$( basename $set ) 
     230        outputfile=${fileout1%.list}.tar 
     231        echo "Output file to write: $outputfile" 
     232 
     233        #----------------------------------- 
     234        # Try 1 time before fire "FAILED" 
     235        # Waiting for CCRT command 
     236        tarcmd=tar 
     237        taroptions="--format=posix -W -cf" 
     238         
     239        cd $dirinputfile 
     240 
     241        set_local=$set".local" 
     242        for file in $( cat $set) ; do 
     243            basename $file >> $set".local"  
     244        done 
     245             
     246#       #----------------------------------- 
     247 
     248        $tarcmd $taroptions $diroutputfile/$outputfile --dereference --files-from $set.local > $logfile 2>&1 
     249        if [ $? -eq 0 ] ; then 
     250            datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"` 
     251            echo "DONE ; $datestr1 ; $datestr2 ; $tarcmd $taroptions $outputfile $(cat $set); $logfile" >> $statusfile 
     252            echo "====> COMPLETED at try #$nbtries (at 1st shot on 1)" 
     253            echo "COMPLETED at try #$nbtries (at 1st shot on 1)" >> $statusfile 
     254        else 
     255            datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"` 
     256            echo "====> FAILED at try #$nbtries"  
     257            echo "FAILED ; $datestr1 ; $datestr2 ; $tarcmd $taroptions $outputfile $(cat $set) ; $logfile" >> $statusfile 
     258 
     259        fi 
     260        rm -f $set".local"  
     261        #----------------------------------- 
     262         
     263done     
     264 
     265 
     266#------------------------------------------------------ 
     267 
     268for set in $( ls $PATH_SIMU/restart_tar/*list ) ; do 
     269 
     270        #----------------------------------- 
     271        echo "#-------------------" 
     272        echo "Set: $set" 
     273        datestr=`LC_ALL=C date +"%Y%m%dT%H%M%S"` 
     274        datestr1=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"` 
     275        statusfile=${set%%.list}.status 
     276        logfile=${set%%.list}_${datestr}.log 
     277 
     278        #----------------------------------- 
     279        # Create status file if not exists 
     280        if [ ! -e $statusfile ] ; then 
     281                echo "# Status ; DateStart ; DateEnd ; Command ; TarFileExists" > $statusfile 
     282        fi 
     283 
     284        #----------------------------------- 
     285        # Skip the set if last line of the status file is "COMPLETED" or "DELEGATE" 
     286        if tail -1 $statusfile | grep -q -E '(COMPLETED|DELEGATE)' ; then 
     287                printf "====> " 
     288                tail -1 $statusfile 
     289                continue 
     290        fi 
     291 
     292        #----------------------------------- 
     293        # nbtries = number of lines from status file (first comment line gives 1 for the first try) 
     294        # nbtries=`wc -l $statusfile | cut -d' ' -f1`            
     295        # echo "Nb of tries: $nbtries" 
     296 
     297        #----------------------------------- 
     298        # Set output file name from list name 
     299        dirin1=$PATH_SIMU/RESTART 
     300        dirin2=${dirin1##${IGCM_DEM}} 
     301        dirin3=${dirin2##/$( basename ${INPUT_DMF_DATA} )} 
     302        diroutputfile=${OUTPUT_STORE}${dirin3} 
     303        fileout1=$( basename $set ) 
     304        fileout=${fileout1%.list}.tar 
     305        outputfile=$diroutputfile/${fileout} 
    236306        mkdir -p $diroutputfile 
    237307        echo "Output file to write: $outputfile" 
    238308 
    239 #       #----------------------------------- 
    240 #       # Find variables to exclude to have homogeneous files (always exclude 't_inst_.*') 
    241 #       extratar=0 
    242 #       find_varstoexclude $set 
    243 #       if [ $nbvars -eq 0 ] ; then 
    244 #               varstoexclude="t_inst_.*" 
    245 #       else 
    246 #               # There are others variables than 't_inst_.*' so an extra tar file will be created 
    247 #               varstoexclude="t_inst_.*,$varstoexcludefiltered" 
    248 #               extratar=1 
    249 #               # Copy to with_tar directory  
    250 #               cp $set $PATH_SIMU/with_tar 
    251 #       fi 
    252  
    253309        #----------------------------------- 
    254310        # Try 1 time before fire "FAILED" 
    255311        # Waiting for CCRT command 
    256         tarcmd=echo 
    257         taroptions="-cvf" 
    258          
    259 #       cd $dirin1 
     312        tarcmd=tar 
     313        taroptions="--format=posix -W -cf" 
     314         
     315        cd $dirin1 
    260316#       ls 
    261317         
    262         $tarcmd "$taroptions $outputfile $(cat $set)" > $logfile 2>&1 
     318        $tarcmd $taroptions $outputfile --dereference --files-from $set > $logfile 2>&1 
    263319        if [ $? -eq 0 ] ; then 
    264320            datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"` 
    265             echo "DONE ; $datestr1 ; $datestr2 ; $tarcmd $taroptions $outputfile $(cat $set); $logfile ; $extratar" >> $statusfile 
    266             echo "====> COMPLETED at try #$nbtries (at 1st shot on 2)" 
     321            echo "DONE ; $datestr1 ; $datestr2 ; $tarcmd $taroptions $outputfile $(cat $set); $logfile" >> $statusfile 
     322            echo "====> COMPLETED at try #$nbtries (at 1st shot on 1)" 
    267323            echo "COMPLETED at try #$nbtries (at 1st shot on 1)" >> $statusfile 
    268324        else 
    269325            datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"` 
    270326            echo "====> FAILED at try #$nbtries"  
    271             echo "FAILED ; $datestr1 ; $datestr2 ; $tarcmd $taroptions $outputfile $(cat $set) ; $logfile ; $extratar" >> $statusfile 
     327            echo "FAILED ; $datestr1 ; $datestr2 ; $tarcmd $taroptions $outputfile $(cat $set) ; $logfile" >> $statusfile 
    272328 
    273329        fi 
     
    277333done     
    278334 
    279  
    280  
     335#------------------------------------------------------ 
     336for set in $( ls $PATH_SIMU/debug_tar/*list ) ; do 
     337 
     338        #----------------------------------- 
     339        echo "#-------------------" 
     340        echo "Set: $set" 
     341        datestr=`LC_ALL=C date +"%Y%m%dT%H%M%S"` 
     342        datestr1=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"` 
     343        statusfile=${set%%.list}.status 
     344        logfile=${set%%.list}_${datestr}.log 
     345 
     346        #----------------------------------- 
     347        # Create status file if not exists 
     348        if [ ! -e $statusfile ] ; then 
     349                echo "# Status ; DateStart ; DateEnd ; Command ; TarFileExists" > $statusfile 
     350        fi 
     351 
     352        #----------------------------------- 
     353        # Skip the set if last line of the status file is "COMPLETED" or "DELEGATE" 
     354        if tail -1 $statusfile | grep -q -E '(COMPLETED|DELEGATE)' ; then 
     355                printf "====> " 
     356                tail -1 $statusfile 
     357                continue 
     358        fi 
     359 
     360        #----------------------------------- 
     361        # nbtries = number of lines from status file (first comment line gives 1 for the first try) 
     362        # nbtries=`wc -l $statusfile | cut -d' ' -f1`            
     363        # echo "Nb of tries: $nbtries" 
     364 
     365        #----------------------------------- 
     366        # Set output file name from list name 
     367        dirin1=$PATH_SIMU/DEBUG 
     368        dirin2=${dirin1##${IGCM_DEM}} 
     369        dirin3=${dirin2##/$( basename ${INPUT_DMF_DATA} )} 
     370        diroutputfile=${OUTPUT_STORE}${dirin3} 
     371        fileout1=$( basename $set ) 
     372        fileout=${fileout1%.list}.tar 
     373        outputfile=$diroutputfile/${fileout} 
     374        mkdir -p $diroutputfile 
     375        echo "Output file to write: $outputfile" 
     376 
     377        #----------------------------------- 
     378        # Try 1 time before fire "FAILED" 
     379        # Waiting for CCRT command 
     380        tarcmd=tar 
     381        taroptions="--format=posix -W -cf" 
     382         
     383        cd $dirin1 
     384#       ls 
     385         
     386        $tarcmd $taroptions $outputfile --dereference --files-from $set > $logfile 2>&1 
     387        if [ $? -eq 0 ] ; then 
     388            datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"` 
     389            echo "DONE ; $datestr1 ; $datestr2 ; $tarcmd $taroptions $outputfile $(cat $set); $logfile" >> $statusfile 
     390            echo "====> COMPLETED at try #$nbtries (at 1st shot on 1)" 
     391            echo "COMPLETED at try #$nbtries (at 1st shot on 1)" >> $statusfile 
     392        else 
     393            datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"` 
     394            echo "====> FAILED at try #$nbtries"  
     395            echo "FAILED ; $datestr1 ; $datestr2 ; $tarcmd $taroptions $outputfile $(cat $set) ; $logfile" >> $statusfile 
     396 
     397        fi 
     398         
     399        #----------------------------------- 
     400         
     401done     
     402 
     403#------------------------------------------------------ 
     404for set in $( ls $PATH_SIMU/store_cp/*list ) ; do 
     405 
     406        #----------------------------------- 
     407        echo "#-------------------" 
     408        echo "Set: $set" 
     409        datestr=`LC_ALL=C date +"%Y%m%dT%H%M%S"` 
     410        datestr1=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"` 
     411        statusfile=${set%%.list}.status 
     412        logfile=${set%%.list}_${datestr}.log 
     413 
     414        #----------------------------------- 
     415        # Create status file if not exists 
     416        if [ ! -e $statusfile ] ; then 
     417                echo "# Status ; DateStart ; DateEnd ; Command ; TarFileExists" > $statusfile 
     418        fi 
     419 
     420        #----------------------------------- 
     421        # Skip the set if last line of the status file is "COMPLETED" or "DELEGATE" 
     422        if tail -1 $statusfile | grep -q -E '(COMPLETED|DELEGATE)' ; then 
     423                printf "====> " 
     424                tail -1 $statusfile 
     425                continue 
     426        fi 
     427 
     428        #----------------------------------- 
     429        # nbtries = number of lines from status file (first comment line gives 1 for the first try) 
     430        # nbtries=`wc -l $statusfile | cut -d' ' -f1`            
     431        # echo "Nb of tries: $nbtries" 
     432 
     433        #----------------------------------- 
     434        # Set output file name from first and last files from the current set 
     435        for file in $( cat $set) ; do 
     436          
     437            diroutputfile=`dirname $file | sed -e "s%$dirin%$dirout%"` 
     438            mkdir -p $diroutputfile 
     439            echo "Output file to write: $diroutputfile/$( basename $file )" 
     440             
     441        #----------------------------------- 
     442        # Try 1 time before fire "FAILED" 
     443        # Waiting for CCRT command 
     444            cpcmd="cp " 
     445            cpoptions="-rf" 
     446            $cpcmd $cpoptions $file $diroutputfile > $logfile 2>&1 
     447        done 
     448 
     449        if [ $? -eq 0 ] ; then 
     450            datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"` 
     451            echo "DONE ; $datestr1 ; $datestr2 ; $cpcmd $cpoptions $file $diroutputfile ; $logfile" >> $statusfile 
     452            echo "====> COMPLETED at try #$nbtries (at 1st shot on 1)" 
     453            echo "COMPLETED at try #$nbtries (at 1st shot on 1)" >> $statusfile 
     454        else 
     455            datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"` 
     456            echo "====> FAILED at try #$nbtries"  
     457            echo "FAILED ; $datestr1 ; $datestr2 ; $cpcmd $cpoptions $file $diroutputfile ; $logfile" >> $statusfile 
     458 
     459        fi 
     460         
     461        #----------------------------------- 
     462         
     463done     
     464 
     465#------------------------------------------------------ 
     466for set in $( ls $PATH_SIMU/work_cp/*list ) ; do 
     467 
     468        #----------------------------------- 
     469        echo "#-------------------" 
     470        echo "Set: $set" 
     471        datestr=`LC_ALL=C date +"%Y%m%dT%H%M%S"` 
     472        datestr1=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"` 
     473        statusfile=${set%%.list}.status 
     474        logfile=${set%%.list}_${datestr}.log 
     475 
     476        #----------------------------------- 
     477        # Create status file if not exists 
     478        if [ ! -e $statusfile ] ; then 
     479                echo "# Status ; DateStart ; DateEnd ; Command ; TarFileExists" > $statusfile 
     480        fi 
     481 
     482        #----------------------------------- 
     483        # Skip the set if last line of the status file is "COMPLETED" or "DELEGATE" 
     484        if tail -1 $statusfile | grep -q -E '(COMPLETED|DELEGATE)' ; then 
     485                printf "====> " 
     486                tail -1 $statusfile 
     487                continue 
     488        fi 
     489 
     490        #----------------------------------- 
     491        # nbtries = number of lines from status file (first comment line gives 1 for the first try) 
     492        # nbtries=`wc -l $statusfile | cut -d' ' -f1`            
     493        # echo "Nb of tries: $nbtries" 
     494 
     495        #----------------------------------- 
     496        # Set output file name from first and last files from the current set 
     497        for file in $( cat $set) ; do 
     498          
     499            diroutputfile=`dirname $file | sed -e "s%$dirin%$dirout_work%"` 
     500            mkdir -p $diroutputfile 
     501            echo "Output file to write: $diroutputfile/$( basename $file )" 
     502             
     503        #----------------------------------- 
     504        # Try 1 time before fire "FAILED" 
     505        # Waiting for CCRT command 
     506            cpcmd="cp " 
     507            cpoptions="-rf" 
     508            $cpcmd $cpoptions $file $diroutputfile > $logfile 2>&1 
     509        done 
     510 
     511        if [ $? -eq 0 ] ; then 
     512            datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"` 
     513            echo "DONE ; $datestr1 ; $datestr2 ; $cpcmd $cpoptions $file $diroutputfile ; $logfile" >> $statusfile 
     514            echo "====> COMPLETED at try #$nbtries (at 1st shot on 1)" 
     515            echo "COMPLETED at try #$nbtries (at 1st shot on 1)" >> $statusfile 
     516        else 
     517            datestr2=`LC_ALL=C date +"%Y-%m-%dT%H:%M:%S"` 
     518            echo "====> FAILED at try #$nbtries"  
     519            echo "FAILED ; $datestr1 ; $datestr2 ; $cpcmd $cpoptions $file $diroutputfile ; $logfile" >> $statusfile 
     520 
     521        fi 
     522         
     523        #----------------------------------- 
     524         
     525done     
  • TOOLS/PACK_IPSL/launch_ipsl_enlarge.sh

    r1727 r1752  
    1515export EXE_DIR=${JOB_DIR} 
    1616 
    17 INPUT_DMF_DATA=${SCRATCHDIR}/PSEUDO_DMNFS 
    18 OUTPUT_STORE=${SCRATCHDIR}/PSEUDO_DMNFS_STORE 
     17export INPUT_DMF_DATA=${SCRATCHDIR}/PSEUDO_DMNFS 
     18export OUTPUT_STORE=${SCRATCHDIR}/PSEUDO_DMNFS_STORE 
     19export OUTPUT_WORK=${SCRATCHDIR}/PSEUDO_DMNFS_WORK 
    1920 
    2021SCRIPT_NAME=$(basename ${0} ) 
     
    3839    DEM_write_state ${IGCM_DEM}/config_card.liste ${CONFIG} PackRunning 
    3940    export PATH_SIMU=$( dirname $CONFIG ) 
    40     ${EXE_DIR}/enlarge_my_files.sh ${INPUT_DMF_DATA} ${OUTPUT_STORE}  
     41    ${EXE_DIR}/enlarge_my_files.sh ${INPUT_DMF_DATA} ${OUTPUT_STORE} ${OUTPUT_WORK} 
    4142     
    4243    DEM_write_state ${IGCM_DEM}/config_card.liste ${CONFIG} PackDone 
Note: See TracChangeset for help on using the changeset viewer.