source: TOOLS/PACK_IPSL/showPackProgress.sh @ 1878

Last change on this file since 1878 was 1876, checked in by gpincka, 12 years ago

correction pour simu type 'tar full'

  • Property svn:executable set to *
File size: 15.2 KB
Line 
1#!/bin/bash
2
3export JOB_DIR=${LS_SUBCWD:-${PWD}}
4export EXE_DIR=${JOB_DIR}
5
6# On renseigne les variables d'environnement
7. load_ipslPack_env.sh
8
9SCRIPT_NAME=$(basename ${0} )
10
11export IGCM_TMP="${IGCM_DEM}/tmp"  # gpdebug : added
12
13export config_card=${IGCM_DEM}/config_card.liste
14
15source ${EXE_DIR}/DEM_utilities.sh
16
17export timeHandlingFile="${USER_OUTPUT_PROGRESS}/timeHandlingFile.txt"
18export timeLaunchStartFile="${USER_OUTPUT_PROGRESS}/timeLaunchStartFile.txt"
19export timeEndFile="${USER_OUTPUT_PROGRESS}/timeEndFile.txt"
20
21
22function getSimuName
23{   
24   config_card=$1
25   
26   dirSimu=$( dirname $config_card )
27   simuName=`echo ${dirSimu} | sed "s;${IGCM_DEM}/;;" `
28   echo $simuName
29
30}
31
32function getTimeTaken
33{
34   statFile=$1
35   if [ ! -e $statFile ]
36   then
37      echo "inconnu : pas de fichier status"
38      return
39   fi
40   
41   timeLine=`sed -n '1p' $statFile `
42   goodFormat=`echo $timeLine | grep -e '^meantime:[[:digit:]]*\.[[:digit:]]\{1,3\}$' | wc -l `
43   if [ "x$goodFormat" == "x0" ]
44   then
45       echo "inconnu : mauvais format du temps"
46       return
47   fi
48   
49   timeTaken=`echo $timeLine | sed 's;^meantime:;;' `
50   echo $timeTaken
51   
52}
53
54function progressStatus
55{
56   statFile=$1
57   echo "statFile=$1" >> showPackProgress.log
58   if [ ! -e $statFile ]
59   then
60      echo "Non traitee"
61      return
62   fi
63   echo "blabla" >> showPackProgress.log
64   echo "----------------------------------------------" >> showPackProgress.log
65   # echo "progressStatus..." # gpdebug : a virer
66   
67   # ------------------------------------------------------------------------------------------------
68   listLineNumWithKey=`grep -n -E '(COMPLETED|FAILED|DELEGATE)' $statFile | awk -F":" '{print $1}' ` 
69   # echo "listLineNumWithKey=$listLineNumWithKey" # gpdebug : a virer
70   
71  if [ "x$listLineNumWithKey" == "x" ]
72  then
73     echo "Statut illisible"
74     return
75  fi
76
77   # On trouve la derniere ligne du fichier status comportant un mot cle
78   max=0
79   for lineNum in $listLineNumWithKey
80   do
81      if [ $lineNum -gt $max ]
82      then
83          max=$lineNum
84      fi
85   done
86
87   # echo "max=$max" # gpdebug : a virer
88
89   lastLineWithKey=`sed -n "${max}p" $statFile `
90   # echo "lastLineWithKey=$lastLineWithKey" # gpdebug : a virer   
91   # ------------------------------------------------------------------------------------------------
92     
93   # lastLine=`tail -1 $statFile ` # gpdebug : a virer
94   
95   completed=`echo $lastLineWithKey | grep COMPLETED | sed 's; (.*)$;;' `
96   if [ "x${completed}" != "x" ]
97   then
98      echo $completed
99      return
100   fi
101   
102  failed=`echo $lastLineWithKey | grep FAILED | cut -d";" -f1 `
103  if [ "x${failed}" != "x" ]
104  then
105     echo $failed
106     return         
107  fi
108 
109  delegate=`echo $lastLineWithKey | grep DELEGATE `
110  if [ "x${delegate}" != "x" ]
111  then
112     echo "DELEGATE"
113     return
114  fi
115 
116}
117
118
119function getWaitingTime
120{
121    timeNow_=$1
122    stillWaiting_=1
123   
124    launchTimeString=`cat $timeHandlingFile | grep -e 'launch time:[[:digit:].]*$' `
125    if [ "x${launchTimeString}" == "x" ]
126    then
127        echo "no launch time"
128        return
129    fi
130    launchTime_=`echo $launchTimeString | awk -F":" '{print $2}' `
131   
132   
133    startExecTimeString=`cat $timeHandlingFile | grep -e 'start time:[[:digit:].]*$' `
134    if [ "x${startExecTimeString}" == "x" ]
135    then
136        execTime_=${timeNow_}   
137    else
138        execTime_=`echo $startExecTimeString | awk -F":" '{print $2}' `
139        stillWaiting_=0
140    fi
141   
142    waitingTime_=$( awk 'BEGIN { print '${execTime_}'-'${launchTime_}' }' )
143    waitingTime_=$( awk 'BEGIN { print '${waitingTime_}'/'1000' }' )
144    if [ "x$stillWaiting_" == "x1" ]
145    then
146       waitingTime_="${waitingTime_}, still waiting..."
147    fi
148   
149    echo $waitingTime_
150}
151   
152   
153function getTimeSinceExecutionStart
154{ 
155   
156    timeNow_=$1
157    stillWaiting_=1   
158   
159    execTimeString=`cat $timeHandlingFile | grep -e 'start time:[[:digit:].]*$' `
160    if [ "x${execTimeString}" == "x" ]
161    then
162        echo "no start time"
163        return
164    fi
165    execTime_=`echo $execTimeString | awk -F":" '{print $2}' `
166   
167       
168    endTimeString=`cat $timeHandlingFile | grep -e 'end time:[[:digit:].]*$' `
169    if [ "x${endTimeString}" == "x" ]
170    then
171        endTime_=${timeNow_}
172    else
173        endTime_=`echo $endTimeString | awk -F":" '{print $2}' `
174        stillWaiting_=0
175    fi
176   
177    timeSinceExec_=$( awk 'BEGIN { print '${endTime_}'-'${execTime_}' }' )
178    timeSinceExec_=$( awk 'BEGIN { print '${timeSinceExec_}'/'1000' }' )
179    if [ "x$stillWaiting_" == "x1" ]
180    then
181       timeSinceExec_="${timeSinceExec_}, still executing..."
182    fi
183   
184    echo $timeSinceExec_
185}
186
187function getTimeSinceLaunchStart
188{
189    timeNow_=$1
190    stillWaiting_=1
191   
192    launchTimeString=`cat $timeLaunchStartFile | grep -e 'launch time:[[:digit:].]*$' `
193    if [ "x${launchTimeString}" == "x" ]
194    then
195        echo "no launch time"
196        return
197    fi
198    launchTime_=`echo $launchTimeString | awk -F":" '{print $2}' `
199   
200   
201    endTimeString=`cat $timeEndFile | grep -e 'end time:[[:digit:].]*$' `
202    if [ "x${endTimeString}" == "x" ]
203    then
204        endTime_=${timeNow_}
205    else
206        endTime_=`echo $endTimeString | awk -F":" '{print $2}' `
207        stillWaiting_=0
208    fi
209   
210    timeSinceLaunch_=$( awk 'BEGIN { print '${endTime_}'-'${launchTime_}' }' )
211    timeSinceLaunch_=$( awk 'BEGIN { print '${timeSinceLaunch_}'/'1000' }' )
212    if [ "x$stillWaiting_" == "x1" ]
213    then
214       timeSinceLaunch_="${timeSinceLaunch_}, still executing..."
215    fi
216   
217    echo $timeSinceLaunch_
218
219}
220
221
222function getListProgress
223{
224     set=$1     
225     
226     listName=`echo $(basename $set) | sed 's;\.list$;;' | sed 's;\.nc$;;' `
227     ListNbInode=`cat $set |wc -l`
228     TotalNbInodes=$(( $TotalNbInodes + $ListNbInode ))
229     statusfile=${set%%.list}.status
230     status=$( progressStatus $statusfile ) # gpdebug : a retablir
231     timeTaken="???"
232 
233     packFailed=`echo $status | grep -E '(DELEGATE|FAILED)' | wc -l `
234     if [ "x${packFailed}" != "x0" ]
235     then
236        nbOfListsFailed=$(( $nbOfListsFailed + 1 ))
237        simuOK=$(( $simuOK && 0 )) # marque une simu pas OK
238     fi
239 
240     packSuccess=`echo $status | grep "COMPLETED" | wc -l `
241     if [ "x${packSuccess}" != "x0" ]
242     then
243        timeTaken=$( getTimeTaken $statusfile )
244        nbOfListsPacked=$(( $nbOfListsPacked + 1 ))
245     fi
246     
247     packNottreated=`echo $status | grep -E '(Non traitee|illisible)' | wc -l `
248     if [ "x${packNottreated}" != "x0" ]
249     then
250         nbOfListsNottreated=$(( $nbOfListsNottreated + 1 ))
251         simuOK=$(( $simuOK && 0 )) # marque une simu pas OK
252         simutreated=$(( $simutreated && 0 )) # marque une simu non completement traitee
253     fi
254
255     echo "       $listName : $status | time : $timeTaken" >> simuPrint.txt
256     
257     timeInSecondsOK=`echo $timeTaken | grep -e '^[[:digit:].]*$' | wc -l `
258     if [ "x${timeInSecondsOK}" != "x0" ]
259     then
260         totalTime=$(awk 'BEGIN { print '$totalTime'+'$timeTaken' }')
261     fi
262
263
264
265}
266
267#################################
268####### Main script #############
269#################################
270
271########  Options du script ########################################################
272focusOnSimu=
273outputFile=
274detailed_mode=1
275publish_mode=1
276while [ $# -gt 0 ]
277do
278   # echo "boucle sur les arguments du script ..."
279   # echo "@=$@"
280   case $1 in
281   -s)  echo "option -s selectionnee : afficher une simulation"
282        shift
283        focusOnSimu=$1
284        is_simu_an_option=`echo $focusOnSimu | grep -e '^-' | wc -l `
285        if [ "x${is_simu_an_option}" != "x0" ] || [ "x$focusOnSimu" == "x" ]
286        then
287           echo "L'option -s doit etre suivie d'une simulation !"
288           exit 1
289        fi
290        ;;
291   -o)  echo "option -o selectionnee : fichier d'output"
292        shift
293        outputFile=$1
294        is_output_an_option=`echo $outputFile | grep -e '^-' | wc -l `
295        if [ "x${is_output_an_option}" != "x0" ] || [ "x$outputFile" == "x" ]
296        then
297           echo "L'option -o doit etre suivie d'un fichier d'output !"
298           exit 1
299        fi
300        ;;
301   --not-detailled)  echo "option '--not-detailled' selectionnee"
302                     detailed_mode=0
303                     ;;
304   -p) echo "option -p selectionnee : publication"
305       publish_mode=0     
306   esac
307   shift
308done
309
310# echo "focusOnSimu=$focusOnSimu"
311# echo "outputFile=$outputFile"
312# echo "detailed_mode=$detailed_mode"
313######################################################################################
314# exit 0 # gpdebug : a virer
315
316
317
318> showPackProgress.log # vider le fichier de log
319
320
321# Recuperation des temps d'attente et ecoule depuis de demarrage des traitements en batch
322if [ -e $timeLaunchStartFile ]
323then
324    timeNow=$( getDateMilliSeconds )
325    # waitingTime=$( getWaitingTime $timeNow ) # supprime pour le moment : pb si +sieurs instances ==> on simplifie
326    # timeSinceExecutionStart=$( getTimeSinceExecutionStart $timeNow ) # supprime pour le moment : pb si +sieurs instances ==> on simplifie
327    timeSinceLaunchStart=$( getTimeSinceLaunchStart $timeNow ) # added
328else
329    # waitingTime="no handling time file available." # supprime pour le moment : pb si +sieurs instances ==> on simplifie
330    # timeFromExecutionStart="no handling time file available." # supprime pour le moment : pb si +sieurs instances ==> on simplifie
331    timeSinceLaunchStart="no launch time file available."
332fi
333
334
335totalNbOfList=0
336for CONFIG in $( awk '{print $1}' ${IGCM_DEM}/config_card.liste )
337do
338   PATH_SIMU=$( dirname $CONFIG )
339   nbListInConfig=`find $PATH_SIMU -name "*list" | wc -l `
340   totalNbOfList=$(( $totalNbOfList + $nbListInConfig ))
341done
342
343# echo "totalNbOfList=$totalNbOfList"
344# exit 0 # gpdebug : a virer
345
346TotalNbSimu=0
347nbOfSimuPacked=0
348nbOfSimuFailed=0
349nbOfSimuNottreated=0
350nbOfListsPacked=0
351nbOfListsFailed=0
352nbOfListsNottreated=0
353TotalNbInodes=0
354TotalSimuTar=0
355totalTime=0
356
357TotalNbSimu=`cat ${IGCM_DEM}/config_card.liste |wc -l`
358
359if [ "x${outputFile}" == "x" ] && [ "x${publish_mode}" == "x0" ]
360then
361# Publication
362echo "Simulation;Status" > ${outputFile}_${USER}
363fi
364
365for CONFIG in $( awk '{print $1}' ${IGCM_DEM}/config_card.liste ) ; do
366
367    DEM_state=$( DEM_read_state ${IGCM_DEM}/config_card.liste ${CONFIG} )
368   
369    # Eviter les simus autre que celle selectionnee par l'option -s
370    showCurrentSimu=`echo $CONFIG | grep "${focusOnSimu}" | wc -l `
371    if [ "x${showCurrentSimu}" == "x0" ]
372    then
373        continue
374    fi
375
376    simuName=$( getSimuName $CONFIG )
377   
378    > simuPrint.txt
379
380    export PATH_SIMU=$( dirname $CONFIG )
381    # echo "PATH_SIMU = $PATH_SIMU"
382   
383    simuOK=1
384    simutreated=1
385 
386    if [ ! -e "${PATH_SIMU}/tar_full_simul.list" ]
387    then
388       
389         listOfDir="output_ncrcat output_tar restart_tar debug_tar store_cp work_cp"
390         for dir in $listOfDir
391         do
392             echo "   ${dir} :" >> simuPrint.txt
393             if [ ! -d $PATH_SIMU/${dir} ]
394             then
395                echo "      ${dir} n'existe pas pour cette simu" >> simuPrint.txt
396#               simuOK=$(( $simuOK && 0 )) # marque une simu pas OK
397                continue
398             fi
399           
400             listFilesInDir=`find $PATH_SIMU/${dir} -name "*list" | wc -l `
401             if [ "x$listFilesInDir" == "x0" ]
402             then
403                echo "       -- no list --" >> simuPrint.txt
404                continue           
405             fi
406           
407             setList=$( ls $PATH_SIMU/${dir}/*list )
408
409             for set in $setList
410             do
411                  getListProgress $set
412             done
413         done
414    else         
415         getListProgress ${PATH_SIMU}/tar_full_simul.list
416         TotalSimuTar=$(( $TotalSimuTar + 1 ))
417    fi
418   
419    resSimu="OK"
420    if [ "x${simuOK}" == "x0" ]
421    then
422        resSimu="not OK"
423    fi
424
425    if [ "x${simutreated}" == "x0" ]
426    then
427        resSimu="not treated"
428    fi
429
430    if [ "x${resSimu}" == "xnot OK" ]
431    then
432       nbOfSimuFailed=$(( $nbOfSimuFailed + 1 )) 
433    elif [ "x${resSimu}" == "xnot treated" ]
434    then
435       nbOfSimuNottreated=$(( $nbOfSimuNottreated + 1 ))
436    else
437        nbOfSimuPacked=$(( $nbOfSimuPacked + 1 ))
438    fi
439
440    if [ "x${outputFile}" == "x" ]
441    then
442        echo "***************************************************"
443        echo "simulation : $simuName  ===> $resSimu"
444        echo "***************************************************"
445        if [ "x${detailed_mode}" == "x1" ]
446        then
447            cat simuPrint.txt  $outRedirectStatement
448        fi
449    else
450        if [ "x${publish_mode}" == "x1" ]
451        then
452        echo "***************************************************" >> ${outputFile}
453        echo "simulation : $simuName  ===> $resSimu"               >> ${outputFile}
454        echo "***************************************************" >> ${outputFile}
455        if [ "x${detailed_mode}" == "x1" ]
456        then
457            cat simuPrint.txt  $outRedirectStatement               >> ${outputFile}
458        fi     
459        else
460# Publication
461        echo "$simuName;$resSimu" >> ${outputFile}_${USER}
462        fi
463    fi
464    rm simuPrint.txt
465done
466
467NbInodeBefore=`cat ${IGCM_DEM}/Listing.txt |wc -l`
468# find $IGCM_DEM -printf "%y %s %p \n" >> ${IGCM_DEM}/ListingEnd.txt
469rm -f ${IGCM_DEM}/ListingEnd.txt
470 if [ -d "${OUTPUT_STORE}" ]
471 then
472     find $OUTPUT_STORE -printf "%y %s %p \n" >> ${IGCM_DEM}/ListingEnd.txt
473 fi
474 if [ -d "${OUTPUT_WORK}" ]
475 then
476     find $OUTPUT_WORK -printf "%y %s %p \n" >> ${IGCM_DEM}/ListingEnd.txt
477 fi
478NbInodeAfter=`cat ${IGCM_DEM}/ListingEnd.txt |wc -l`
479
480if [ "x${outputFile}" == "x" ]
481then
482    echo
483    echo "##################"
484    echo "#####  BILAN #####"
485    echo "##################"
486    echo "nb of Simulations packed with success : ${nbOfSimuPacked} / ${TotalNbSimu}"
487    echo "nb of Simus failed : ${nbOfSimuFailed}"
488    echo "nb of Simus not treated : ${nbOfSimuNottreated}"
489    echo "nb of Lists packed with success : ${nbOfListsPacked} / ${totalNbOfList}"
490    echo "nb of fails : $nbOfListsFailed"
491    echo "nb of not treated : ${nbOfListsNottreated}"
492    echo "nb of inodes packed : $TotalNbInodes"
493    echo "nb simul full tared : $TotalSimuTar"
494    echo "nb inode before : $NbInodeBefore"
495    echo "nb inode after : $NbInodeAfter"
496    echo "Total time for elementary operations : $totalTime" 
497    echo "Time since launch start : $timeSinceLaunchStart"
498
499else
500    if [ "x${publish_mode}" == "x1" ]
501        then
502    echo
503    echo "##################" >> ${outputFile}
504    echo "#####  BILAN #####" >> ${outputFile}
505    echo "##################" >> ${outputFile}
506    echo "nb of Simulations packed with success : ${nbOfSimuPacked} / ${TotalNbSimu}" >> ${outputFile}
507    echo "nb of Simus failed : ${nbOfSimuFailed}" >> ${outputFile}
508    echo "nb of Simus not treated : ${nbOfSimuNottreated}" >> ${outputFile}
509    echo "nb of Lists packed with success : ${nbOfListsPacked} / ${totalNbOfList}" >> ${outputFile}
510    echo "nb of fails : $nbOfListsFailed" >> ${outputFile}
511    echo "nb of not treated : ${nbOfListsNottreated}" >> ${outputFile}
512    echo "nb of inodes packed : $TotalNbInodes" >> ${outputFile}
513    echo "nb simul full tared : $TotalSimuTar" >> ${outputFile}
514    echo "nb inode before : $NbInodeBefore" >> ${outputFile}
515    echo "nb inode after : $NbInodeAfter" >> ${outputFile}
516    echo "Total time for elementary operations : $totalTime" >> ${outputFile}
517    echo "Time since launch start : $timeSinceLaunchStart" >> ${outputFile}
518    else
519# Publication
520    echo "User;TotalNbSimu;NbOfSimuPacked;NbOfSimuFailed;NbOfSimuNottreated;TotalNbOfList;NbOfListsPacked;NbOfListsFailed;NbOfListsNottreated;TotalNbFiles;Nbfilestreated;Nbfilesafter;NbSimuTar" > ${outputFile}
521    echo "${USER};${TotalNbSimu};${nbOfSimuPacked};${nbOfSimuFailed};${nbOfSimuNottreated};${totalNbOfList};${nbOfListsPacked};$nbOfListsFailed;${nbOfListsNottreated};$TotalNbInodes;$NbInodeBefore;$NbInodeAfter;$TotalSimuTar" >> ${outputFile}
522    fi
523fi
Note: See TracBrowser for help on using the repository browser.