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 | |
---|
19 | |
---|
20 | function getSimuName |
---|
21 | { |
---|
22 | config_card=$1 |
---|
23 | |
---|
24 | dirSimu=$( dirname $config_card ) |
---|
25 | simuName=`echo ${dirSimu} | sed "s;${IGCM_DEM}/;;" ` |
---|
26 | echo $simuName |
---|
27 | |
---|
28 | } |
---|
29 | |
---|
30 | function getTimeTaken |
---|
31 | { |
---|
32 | statFile=$1 |
---|
33 | if [ ! -e $statFile ] |
---|
34 | then |
---|
35 | echo "inconnu : pas de fichier status" |
---|
36 | return |
---|
37 | fi |
---|
38 | |
---|
39 | timeLine=`sed -n '1p' $statFile ` |
---|
40 | goodFormat=`echo $timeLine | grep -e '^meantime:[[:digit:]]*\.[[:digit:]]\{1,3\}$' | wc -l ` |
---|
41 | if [ "x$goodFormat" == "x0" ] |
---|
42 | then |
---|
43 | echo "inconnu : mauvais format du temps" |
---|
44 | return |
---|
45 | fi |
---|
46 | |
---|
47 | timeTaken=`echo $timeLine | sed 's;^meantime:;;' ` |
---|
48 | echo $timeTaken |
---|
49 | |
---|
50 | } |
---|
51 | |
---|
52 | function progressStatus |
---|
53 | { |
---|
54 | statFile=$1 |
---|
55 | echo "statFile=$1" >> showPackProgress.log |
---|
56 | if [ ! -e $statFile ] |
---|
57 | then |
---|
58 | echo "Non traitee" |
---|
59 | return |
---|
60 | fi |
---|
61 | echo "blabla" >> showPackProgress.log |
---|
62 | echo "----------------------------------------------" >> showPackProgress.log |
---|
63 | # echo "progressStatus..." # gpdebug : a virer |
---|
64 | |
---|
65 | # ------------------------------------------------------------------------------------------------ |
---|
66 | listLineNumWithKey=`grep -n -E '(COMPLETED|FAILED|DELEGATE)' $statFile | awk -F":" '{print $1}' ` |
---|
67 | # echo "listLineNumWithKey=$listLineNumWithKey" # gpdebug : a virer |
---|
68 | |
---|
69 | if [ "x$listLineNumWithKey" == "x" ] |
---|
70 | then |
---|
71 | echo "Statut illisible" |
---|
72 | return |
---|
73 | fi |
---|
74 | |
---|
75 | # On trouve la derniere ligne du fichier status comportant un mot cle |
---|
76 | max=0 |
---|
77 | for lineNum in $listLineNumWithKey |
---|
78 | do |
---|
79 | if [ $lineNum -gt $max ] |
---|
80 | then |
---|
81 | max=$lineNum |
---|
82 | fi |
---|
83 | done |
---|
84 | |
---|
85 | # echo "max=$max" # gpdebug : a virer |
---|
86 | |
---|
87 | lastLineWithKey=`sed -n "${max}p" $statFile ` |
---|
88 | # echo "lastLineWithKey=$lastLineWithKey" # gpdebug : a virer |
---|
89 | # ------------------------------------------------------------------------------------------------ |
---|
90 | |
---|
91 | # lastLine=`tail -1 $statFile ` # gpdebug : a virer |
---|
92 | |
---|
93 | completed=`echo $lastLineWithKey | grep COMPLETED | sed 's; (.*)$;;' ` |
---|
94 | if [ "x${completed}" != "x" ] |
---|
95 | then |
---|
96 | echo $completed |
---|
97 | return |
---|
98 | fi |
---|
99 | |
---|
100 | failed=`echo $lastLineWithKey | grep FAILED | cut -d";" -f1 ` |
---|
101 | if [ "x${failed}" != "x" ] |
---|
102 | then |
---|
103 | echo $failed |
---|
104 | return |
---|
105 | fi |
---|
106 | |
---|
107 | delegate=`echo $lastLineWithKey | grep DELEGATE ` |
---|
108 | if [ "x${delegate}" != "x" ] |
---|
109 | then |
---|
110 | echo "DELEGATE" |
---|
111 | return |
---|
112 | fi |
---|
113 | |
---|
114 | } |
---|
115 | |
---|
116 | |
---|
117 | function getWaitingTime |
---|
118 | { |
---|
119 | timeNow_=$1 |
---|
120 | stillWaiting_=1 |
---|
121 | |
---|
122 | launchTimeString=`cat $timeHandlingFile | grep -e 'launch time:[[:digit:].]*$' ` |
---|
123 | if [ "x${launchTimeString}" == "x" ] |
---|
124 | then |
---|
125 | echo "no launch time" |
---|
126 | return |
---|
127 | fi |
---|
128 | launchTime_=`echo $launchTimeString | awk -F":" '{print $2}' ` |
---|
129 | |
---|
130 | |
---|
131 | startExecTimeString=`cat $timeHandlingFile | grep -e 'start time:[[:digit:].]*$' ` |
---|
132 | if [ "x${startExecTimeString}" == "x" ] |
---|
133 | then |
---|
134 | execTime_=${timeNow_} |
---|
135 | else |
---|
136 | execTime_=`echo $startExecTimeString | awk -F":" '{print $2}' ` |
---|
137 | stillWaiting_=0 |
---|
138 | fi |
---|
139 | |
---|
140 | waitingTime_=$( awk 'BEGIN { print '${execTime_}'-'${launchTime_}' }' ) |
---|
141 | waitingTime_=$( awk 'BEGIN { print '${waitingTime_}'/'1000' }' ) |
---|
142 | if [ "x$stillWaiting_" == "x1" ] |
---|
143 | then |
---|
144 | waitingTime_="${waitingTime_}, still waiting..." |
---|
145 | fi |
---|
146 | |
---|
147 | echo $waitingTime_ |
---|
148 | } |
---|
149 | |
---|
150 | |
---|
151 | function getTimeSinceExecutionStart |
---|
152 | { |
---|
153 | |
---|
154 | timeNow_=$1 |
---|
155 | stillWaiting_=1 |
---|
156 | |
---|
157 | execTimeString=`cat $timeHandlingFile | grep -e 'start time:[[:digit:].]*$' ` |
---|
158 | if [ "x${execTimeString}" == "x" ] |
---|
159 | then |
---|
160 | echo "no start time" |
---|
161 | return |
---|
162 | fi |
---|
163 | execTime_=`echo $execTimeString | awk -F":" '{print $2}' ` |
---|
164 | |
---|
165 | |
---|
166 | endTimeString=`cat $timeHandlingFile | grep -e 'end time:[[:digit:].]*$' ` |
---|
167 | if [ "x${endTimeString}" == "x" ] |
---|
168 | then |
---|
169 | endTime_=${timeNow_} |
---|
170 | else |
---|
171 | endTime_=`echo $endTimeString | awk -F":" '{print $2}' ` |
---|
172 | stillWaiting_=0 |
---|
173 | fi |
---|
174 | |
---|
175 | timeSinceExec_=$( awk 'BEGIN { print '${endTime_}'-'${execTime_}' }' ) |
---|
176 | timeSinceExec_=$( awk 'BEGIN { print '${timeSinceExec_}'/'1000' }' ) |
---|
177 | if [ "x$stillWaiting_" == "x1" ] |
---|
178 | then |
---|
179 | timeSinceExec_="${timeSinceExec_}, still executing..." |
---|
180 | fi |
---|
181 | |
---|
182 | echo $timeSinceExec_ |
---|
183 | } |
---|
184 | |
---|
185 | |
---|
186 | |
---|
187 | function getListProgress |
---|
188 | { |
---|
189 | set=$1 |
---|
190 | |
---|
191 | listName=`echo $(basename $set) | sed 's;\.list$;;' | sed 's;\.nc$;;' ` |
---|
192 | ListNbInode=`cat $set |wc -l` |
---|
193 | TotalNbInodes=$(( $TotalNbInodes + $ListNbInode )) |
---|
194 | statusfile=${set%%.list}.status |
---|
195 | status=$( progressStatus $statusfile ) # gpdebug : a retablir |
---|
196 | timeTaken="???" |
---|
197 | |
---|
198 | packFailed=`echo $status | grep -E '(DELEGATE|FAILED|illisible)' | wc -l ` |
---|
199 | if [ "x${packFailed}" != "x0" ] |
---|
200 | then |
---|
201 | nbOfListsFailed=$(( $nbOfListsFailed + 1 )) |
---|
202 | simuOK=$(( $simuOK && 0 )) # marque une simu pas OK |
---|
203 | fi |
---|
204 | |
---|
205 | packSuccess=`echo $status | grep "COMPLETED" | wc -l ` |
---|
206 | if [ "x${packSuccess}" != "x0" ] |
---|
207 | then |
---|
208 | timeTaken=$( getTimeTaken $statusfile ) |
---|
209 | nbOfListsPacked=$(( $nbOfListsPacked + 1 )) |
---|
210 | fi |
---|
211 | |
---|
212 | echo " $listName : $status | time : $timeTaken" >> simuPrint.txt |
---|
213 | |
---|
214 | timeInSecondsOK=`echo $timeTaken | grep -e '^[[:digit:].]*$' | wc -l ` |
---|
215 | if [ "x${timeInSecondsOK}" != "x0" ] |
---|
216 | then |
---|
217 | totalTime=$(awk 'BEGIN { print '$totalTime'+'$timeTaken' }') |
---|
218 | fi |
---|
219 | |
---|
220 | |
---|
221 | |
---|
222 | } |
---|
223 | |
---|
224 | ################################# |
---|
225 | ####### Main script ############# |
---|
226 | ################################# |
---|
227 | |
---|
228 | ######## Options du script ######################################################## |
---|
229 | focusOnSimu= |
---|
230 | outputFile= |
---|
231 | detailed_mode=1 |
---|
232 | while [ $# -gt 0 ] |
---|
233 | do |
---|
234 | # echo "boucle sur les arguments du script ..." |
---|
235 | # echo "@=$@" |
---|
236 | case $1 in |
---|
237 | -s) echo "option -s selectionnee : afficher une simulation" |
---|
238 | shift |
---|
239 | focusOnSimu=$1 |
---|
240 | is_simu_an_option=`echo $focusOnSimu | grep -e '^-' | wc -l ` |
---|
241 | if [ "x${is_simu_an_option}" != "x0" ] || [ "x$focusOnSimu" == "x" ] |
---|
242 | then |
---|
243 | echo "L'option -s doit etre suivie d'une simulation !" |
---|
244 | exit 1 |
---|
245 | fi |
---|
246 | ;; |
---|
247 | -o) echo "option -o selectionnee : fichier d'output" |
---|
248 | shift |
---|
249 | outputFile=$1 |
---|
250 | is_output_an_option=`echo $outputFile | grep -e '^-' | wc -l ` |
---|
251 | if [ "x${is_output_an_option}" != "x0" ] || [ "x$outputFile" == "x" ] |
---|
252 | then |
---|
253 | echo "L'option -o doit etre suivie d'un fichier d'output !" |
---|
254 | exit 1 |
---|
255 | fi |
---|
256 | ;; |
---|
257 | --not-detailled) echo "option '--not-detailled' selectionnee" |
---|
258 | detailed_mode=0 |
---|
259 | ;; |
---|
260 | esac |
---|
261 | shift |
---|
262 | done |
---|
263 | |
---|
264 | # echo "focusOnSimu=$focusOnSimu" |
---|
265 | # echo "outputFile=$outputFile" |
---|
266 | # echo "detailed_mode=$detailed_mode" |
---|
267 | ###################################################################################### |
---|
268 | # exit 0 # gpdebug : a virer |
---|
269 | |
---|
270 | |
---|
271 | |
---|
272 | > showPackProgress.log # vider le fichier de log |
---|
273 | |
---|
274 | |
---|
275 | # Recuperation des temps d'attente et ecoule depuis de demarrage des traitements en batch |
---|
276 | if [ -e $timeHandlingFile ] |
---|
277 | then |
---|
278 | timeNow=$( getDateMilliSeconds ) |
---|
279 | waitingTime=$( getWaitingTime $timeNow ) |
---|
280 | timeSinceExecutionStart=$( getTimeSinceExecutionStart $timeNow ) |
---|
281 | else |
---|
282 | waitingTime="no handling time file available." |
---|
283 | timeFromExecutionStart="no handling time file available." |
---|
284 | fi |
---|
285 | |
---|
286 | |
---|
287 | totalNbOfList=0 |
---|
288 | for CONFIG in $( awk '{print $1}' ${IGCM_DEM}/config_card.liste ) |
---|
289 | do |
---|
290 | PATH_SIMU=$( dirname $CONFIG ) |
---|
291 | nbListInConfig=`find $PATH_SIMU -name "*list" | wc -l ` |
---|
292 | totalNbOfList=$(( $totalNbOfList + $nbListInConfig )) |
---|
293 | done |
---|
294 | |
---|
295 | # echo "totalNbOfList=$totalNbOfList" |
---|
296 | # exit 0 # gpdebug : a virer |
---|
297 | |
---|
298 | nbOfListsPacked=0 |
---|
299 | nbOfListsFailed=0 |
---|
300 | TotalNbInodes=0 |
---|
301 | TotalSimuTar=0 |
---|
302 | totalTime=0 |
---|
303 | |
---|
304 | |
---|
305 | for CONFIG in $( awk '{print $1}' ${IGCM_DEM}/config_card.liste ) ; do |
---|
306 | |
---|
307 | DEM_state=$( DEM_read_state ${IGCM_DEM}/config_card.liste ${CONFIG} ) |
---|
308 | |
---|
309 | # Eviter les simus autre que celle selectionnee par l'option -s |
---|
310 | showCurrentSimu=`echo $CONFIG | grep "${focusOnSimu}" | wc -l ` |
---|
311 | if [ "x${showCurrentSimu}" == "x0" ] |
---|
312 | then |
---|
313 | continue |
---|
314 | fi |
---|
315 | |
---|
316 | simuName=$( getSimuName $CONFIG ) |
---|
317 | |
---|
318 | > simuPrint.txt |
---|
319 | |
---|
320 | export PATH_SIMU=$( dirname $CONFIG ) |
---|
321 | # echo "PATH_SIMU = $PATH_SIMU" |
---|
322 | |
---|
323 | simuOK=1 |
---|
324 | |
---|
325 | if [ ! -e "${PATH_SIMU}/tar_full_simul.list" ] |
---|
326 | then |
---|
327 | |
---|
328 | listOfDir="output_ncrcat output_tar restart_tar debug_tar store_cp work_cp" |
---|
329 | for dir in $listOfDir |
---|
330 | do |
---|
331 | echo " ${dir} :" >> simuPrint.txt |
---|
332 | if [ ! -d $PATH_SIMU/${dir} ] |
---|
333 | then |
---|
334 | echo " ${dir} n'existe pas pour cette simu" >> simuPrint.txt |
---|
335 | simuOK=$(( $simuOK && 0 )) # marque une simu pas OK |
---|
336 | continue |
---|
337 | fi |
---|
338 | |
---|
339 | listFilesInDir=`find $PATH_SIMU/${dir} -name "*list" | wc -l ` |
---|
340 | if [ "x$listFilesInDir" == "x0" ] |
---|
341 | then |
---|
342 | echo " -- no list --" >> simuPrint.txt |
---|
343 | continue |
---|
344 | fi |
---|
345 | |
---|
346 | setList=$( ls $PATH_SIMU/${dir}/*list ) |
---|
347 | |
---|
348 | for set in $setList |
---|
349 | do |
---|
350 | getListProgress $set |
---|
351 | done |
---|
352 | done |
---|
353 | else |
---|
354 | getListProgress ${PATH_SIMU}/tar_full_simul.list |
---|
355 | TotalSimuTar=$(( $TotalSimuTar + 1 )) |
---|
356 | fi |
---|
357 | |
---|
358 | resSimu="OK" |
---|
359 | if [ "x${simuOK}" == "x0" ] |
---|
360 | then |
---|
361 | resSimu="not OK" |
---|
362 | fi |
---|
363 | |
---|
364 | if [ "x${outputFile}" == "x" ] |
---|
365 | then |
---|
366 | echo "***************************************************" |
---|
367 | echo "simulation : $simuName ===> $resSimu" |
---|
368 | echo "***************************************************" |
---|
369 | if [ "x${detailed_mode}" == "x1" ] |
---|
370 | then |
---|
371 | cat simuPrint.txt $outRedirectStatement |
---|
372 | fi |
---|
373 | else |
---|
374 | echo "***************************************************" >> ${outputFile} |
---|
375 | echo "simulation : $simuName ===> $resSimu" >> ${outputFile} |
---|
376 | echo "***************************************************" >> ${outputFile} |
---|
377 | if [ "x${detailed_mode}" == "x1" ] |
---|
378 | then |
---|
379 | cat simuPrint.txt $outRedirectStatement >> ${outputFile} |
---|
380 | fi |
---|
381 | fi |
---|
382 | rm simuPrint.txt |
---|
383 | done |
---|
384 | |
---|
385 | NbInodeBefore=`cat ${IGCM_DEM}/Listing.txt |wc -l` |
---|
386 | # find $IGCM_DEM -printf "%y %s %p \n" >> ${IGCM_DEM}/ListingEnd.txt |
---|
387 | rm -f ${IGCM_DEM}/ListingEnd.txt |
---|
388 | find $OUTPUT_STORE -printf "%y %s %p \n" >> ${IGCM_DEM}/ListingEnd.txt |
---|
389 | find $OUTPUT_WORK -printf "%y %s %p \n" >> ${IGCM_DEM}/ListingEnd.txt |
---|
390 | NbInodeAfter=`cat ${IGCM_DEM}/ListingEnd.txt |wc -l` |
---|
391 | echo |
---|
392 | echo "##################" |
---|
393 | echo "##### BILAN #####" |
---|
394 | echo "##################" |
---|
395 | echo "nb of Lists packed with success : ${nbOfListsPacked} / ${totalNbOfList}" |
---|
396 | echo "nb of fails : $nbOfListsFailed" |
---|
397 | echo "nb of inodes packed : $TotalNbInodes" |
---|
398 | echo "nb simul full tared : $TotalSimuTar" |
---|
399 | echo "nb inode before : $NbInodeBefore" |
---|
400 | echo "nb inode after : $NbInodeAfter" |
---|
401 | echo "Total time for elementary operations : $totalTime (sum of times on several proc)" |
---|
402 | echo "waiting time : $waitingTime" |
---|
403 | echo "Time since execution start : $timeSinceExecutionStart" |
---|
404 | |
---|
405 | |
---|
406 | |
---|
407 | |
---|