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