source: TOOLS/PACK_IPSL/showPackProgress.sh @ 1864

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

gestion (a ameliorer) des echecs ncrcat + check automatiques et aleatoires + resolution bug sur outil visu avancement + suppr liste 'manquant' vides

  • Property svn:executable set to *
File size: 13.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|illisible|Non traite)' | 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" | wc -l `
248     if [ "x${packNottreated}" != "x0" ]
249     then
250         nbOfListsNottreated=$(( $nbOfListsNottreated + 1 ))
251     fi
252
253     echo "       $listName : $status | time : $timeTaken" >> simuPrint.txt
254     
255     timeInSecondsOK=`echo $timeTaken | grep -e '^[[:digit:].]*$' | wc -l `
256     if [ "x${timeInSecondsOK}" != "x0" ]
257     then
258         totalTime=$(awk 'BEGIN { print '$totalTime'+'$timeTaken' }')
259     fi
260
261
262
263}
264
265#################################
266####### Main script #############
267#################################
268
269########  Options du script ########################################################
270focusOnSimu=
271outputFile=
272detailed_mode=1
273while [ $# -gt 0 ]
274do
275   # echo "boucle sur les arguments du script ..."
276   # echo "@=$@"
277   case $1 in
278   -s)  echo "option -s selectionnee : afficher une simulation"
279        shift
280        focusOnSimu=$1
281        is_simu_an_option=`echo $focusOnSimu | grep -e '^-' | wc -l `
282        if [ "x${is_simu_an_option}" != "x0" ] || [ "x$focusOnSimu" == "x" ]
283        then
284           echo "L'option -s doit etre suivie d'une simulation !"
285           exit 1
286        fi
287        ;;
288   -o)  echo "option -o selectionnee : fichier d'output"
289        shift
290        outputFile=$1
291        is_output_an_option=`echo $outputFile | grep -e '^-' | wc -l `
292        if [ "x${is_output_an_option}" != "x0" ] || [ "x$outputFile" == "x" ]
293        then
294           echo "L'option -o doit etre suivie d'un fichier d'output !"
295           exit 1
296        fi
297        ;;
298   --not-detailled)  echo "option '--not-detailled' selectionnee"
299                     detailed_mode=0
300                     ;;
301   esac
302   shift
303done
304
305# echo "focusOnSimu=$focusOnSimu"
306# echo "outputFile=$outputFile"
307# echo "detailed_mode=$detailed_mode"
308######################################################################################
309# exit 0 # gpdebug : a virer
310
311
312
313> showPackProgress.log # vider le fichier de log
314
315
316# Recuperation des temps d'attente et ecoule depuis de demarrage des traitements en batch
317if [ -e $timeLaunchStartFile ]
318then
319    timeNow=$( getDateMilliSeconds )
320    # waitingTime=$( getWaitingTime $timeNow ) # supprime pour le moment : pb si +sieurs instances ==> on simplifie
321    # timeSinceExecutionStart=$( getTimeSinceExecutionStart $timeNow ) # supprime pour le moment : pb si +sieurs instances ==> on simplifie
322    timeSinceLaunchStart=$( getTimeSinceLaunchStart $timeNow ) # added
323else
324    # waitingTime="no handling time file available." # supprime pour le moment : pb si +sieurs instances ==> on simplifie
325    # timeFromExecutionStart="no handling time file available." # supprime pour le moment : pb si +sieurs instances ==> on simplifie
326    timeSinceLaunchStart="no launch time file available."
327fi
328
329
330totalNbOfList=0
331for CONFIG in $( awk '{print $1}' ${IGCM_DEM}/config_card.liste )
332do
333   PATH_SIMU=$( dirname $CONFIG )
334   nbListInConfig=`find $PATH_SIMU -name "*list" | wc -l `
335   totalNbOfList=$(( $totalNbOfList + $nbListInConfig ))
336done
337
338# echo "totalNbOfList=$totalNbOfList"
339# exit 0 # gpdebug : a virer
340
341nbOfListsPacked=0
342nbOfListsFailed=0
343nbOfListsNottreated=0
344TotalNbInodes=0
345TotalSimuTar=0
346totalTime=0
347
348
349for CONFIG in $( awk '{print $1}' ${IGCM_DEM}/config_card.liste ) ; do
350
351    DEM_state=$( DEM_read_state ${IGCM_DEM}/config_card.liste ${CONFIG} )
352   
353    # Eviter les simus autre que celle selectionnee par l'option -s
354    showCurrentSimu=`echo $CONFIG | grep "${focusOnSimu}" | wc -l `
355    if [ "x${showCurrentSimu}" == "x0" ]
356    then
357        continue
358    fi
359
360    simuName=$( getSimuName $CONFIG )
361   
362    > simuPrint.txt
363
364    export PATH_SIMU=$( dirname $CONFIG )
365    # echo "PATH_SIMU = $PATH_SIMU"
366   
367    simuOK=1
368   
369    if [ ! -e "${PATH_SIMU}/tar_full_simul.list" ]
370    then
371       
372         listOfDir="output_ncrcat output_tar restart_tar debug_tar store_cp work_cp"
373         for dir in $listOfDir
374         do
375             echo "   ${dir} :" >> simuPrint.txt
376             if [ ! -d $PATH_SIMU/${dir} ]
377             then
378                echo "      ${dir} n'existe pas pour cette simu" >> simuPrint.txt
379                simuOK=$(( $simuOK && 0 )) # marque une simu pas OK
380                continue
381             fi
382           
383             listFilesInDir=`find $PATH_SIMU/${dir} -name "*list" | wc -l `
384             if [ "x$listFilesInDir" == "x0" ]
385             then
386                echo "       -- no list --" >> simuPrint.txt
387                continue           
388             fi
389           
390             setList=$( ls $PATH_SIMU/${dir}/*list )
391
392             for set in $setList
393             do
394                  getListProgress $set
395             done
396         done
397    else         
398         getListProgress ${PATH_SIMU}/tar_full_simul.list
399         TotalSimuTar=$(( $TotalSimuTar + 1 ))
400    fi
401   
402    resSimu="OK"
403    if [ "x${simuOK}" == "x0" ]
404    then
405        resSimu="not OK"
406    fi
407   
408    if [ "x${outputFile}" == "x" ]
409    then
410        echo "***************************************************"
411        echo "simulation : $simuName  ===> $resSimu"
412        echo "***************************************************"
413        if [ "x${detailed_mode}" == "x1" ]
414        then
415            cat simuPrint.txt  $outRedirectStatement
416        fi
417    else
418        echo "***************************************************" >> ${outputFile}
419        echo "simulation : $simuName  ===> $resSimu"               >> ${outputFile}
420        echo "***************************************************" >> ${outputFile}
421        if [ "x${detailed_mode}" == "x1" ]
422        then
423            cat simuPrint.txt  $outRedirectStatement               >> ${outputFile}
424        fi     
425    fi
426    rm simuPrint.txt
427done
428
429NbInodeBefore=`cat ${IGCM_DEM}/Listing.txt |wc -l`
430# find $IGCM_DEM -printf "%y %s %p \n" >> ${IGCM_DEM}/ListingEnd.txt
431rm -f ${IGCM_DEM}/ListingEnd.txt
432 if [ -d "${OUTPUT_STORE}" ]
433 then
434     find $OUTPUT_STORE -printf "%y %s %p \n" >> ${IGCM_DEM}/ListingEnd.txt
435 fi
436 if [ -d "${OUTPUT_WORK}" ]
437 then
438     find $OUTPUT_WORK -printf "%y %s %p \n" >> ${IGCM_DEM}/ListingEnd.txt
439 fi
440NbInodeAfter=`cat ${IGCM_DEM}/ListingEnd.txt |wc -l`
441
442if [ "x${outputFile}" == "x" ]
443then
444    echo
445    echo "##################"
446    echo "#####  BILAN #####"
447    echo "##################"
448    echo "nb of Lists packed with success : ${nbOfListsPacked} / ${totalNbOfList}"
449    echo "nb of fails : $nbOfListsFailed"
450    echo "nb of not treated : ${nbOfListsNottreated}"
451    echo "nb of inodes packed : $TotalNbInodes"
452    echo "nb simul full tared : $TotalSimuTar"
453    echo "nb inode before : $NbInodeBefore"
454    echo "nb inode after : $NbInodeAfter"
455    echo "Total time for elementary operations : $totalTime" 
456    echo "Time since launch start : $timeSinceLaunchStart"
457
458else
459    echo
460    echo "##################" >> ${outputFile}
461    echo "#####  BILAN #####" >> ${outputFile}
462    echo "##################" >> ${outputFile}
463    echo "nb of Lists packed with success : ${nbOfListsPacked} / ${totalNbOfList}" >> ${outputFile}
464    echo "nb of fails : $nbOfListsFailed" >> ${outputFile}
465    echo "nb of not treated : ${nbOfListsNottreated}" >> ${outputFile}
466    echo "nb of inodes packed : $TotalNbInodes" >> ${outputFile}
467    echo "nb simul full tared : $TotalSimuTar" >> ${outputFile}
468    echo "nb inode before : $NbInodeBefore" >> ${outputFile}
469    echo "nb inode after : $NbInodeAfter" >> ${outputFile}
470    echo "Total time for elementary operations : $totalTime" >> ${outputFile}
471    echo "Time since launch start : $timeSinceLaunchStart" >> ${outputFile}
472
473fi
Note: See TracBrowser for help on using the repository browser.