/[MITgcm]/mitgcm.org/scripts/check_outp
ViewVC logotype

Contents of /mitgcm.org/scripts/check_outp

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.32 - (show annotations) (download)
Thu Aug 16 02:48:24 2012 UTC (11 years, 9 months ago) by jmc
Branch: MAIN
Changes since 1.31: +12 -8 lines
recognize TLM output

1 #! /usr/bin/env bash
2
3 # $Header: /u/gcmpack/mitgcm.org/scripts/check_outp,v 1.31 2011/08/23 18:14:10 jmc Exp $
4 #
5 # The purpose of this script is to compare
6 # the latest output with the previous one (from the same platform with
7 # same optfile)
8
9 usage()
10 {
11 echo
12 echo "Usage: $0 [OPTIONS]"
13 echo
14 echo "where possible OPTIONS are:"
15 echo " (-h|-help) print usage"
16 echo " (-v|-verbose) verbose mode"
17 echo " (-l |-list )MACHINES check platforms from this list"
18 echo " [def=\"$MACHINES\"]"
19 echo " (-d |-day )FIRSTDAY select output from day=\"YYYYMMDD\""
20 echo " (argument of \"date -d\" is allowed)"
21 echo " [def=\"$FIRSTDAY\"]"
22 echo " (-u |-upto )LASTDAY until last day=\"YYYYMMDD\" (=selected period)"
23 echo " [def=\"FIRSTDAY\"]"
24 echo " (-b |-before)BEFORE compare with output from before \"YYYYMMDD\""
25 echo " (=previous period) [def=\"FIRSTDAY\"]"
26 echo " (-o |-outp )OUTPFIL output file (-1 removed when exit)"
27 echo " [def=\"$OUTPFIL\"]"
28 echo " (-n |-nldf )NBLDIFF max number of diff lines to echo"
29 echo " [def=\"$NBLDIFF\"]"
30 echo " (-a |-addr )ADDRESS send summary to mail ADDRESS list"
31 echo " [def=\"$ADDRESS\"]"
32 echo
33 exit 1
34 }
35
36 # create list of results dir for one platform:
37 make_resdir_list()
38 {
39 if test $monthDir == 1 ; then
40 dir_list=`grep '.._'$mname ./dir_all`
41 else
42 dir_list=`( cd $INDIR ; ls -1 -t ../$PREV_P/??_*${mname}*/summary.txt 2> /dev/null | sed 's/\/summary.txt//' )`
43 #echo "dir_list='$dir_list'"
44 fi
45 for i in $dir_list ; do
46
47 dir=$INDIR"/"$i
48 #--- get the opfile used to run testreport
49 OPTFILE=
50 if test -r $dir/summary.txt ; then
51 comm=`grep 'OPTFILE=' $dir/summary.txt`
52 eval $comm
53 fi
54 if test "x$OPTFILE" = x -a -r "$dir/genmake_state" ; then
55 comm=`grep 'OPTFILE=' $dir/genmake_state 2>/dev/null`
56 eval $comm
57 fi
58 if test "x$OPTFILE" = x ; then
59 comm=`grep '^# OPTFILE=' $dir/*/Makefile* 2>/dev/null | head -1`
60 comm=${comm##*#}
61 eval $comm
62 fi
63 if test "x$OPTFILE" = x ; then
64 OPTFILE="not_explicitly_specified"
65 else
66 OPTFILE=${OPTFILE##*/}
67 fi
68 #--- case select test run by 1 user: get user who did run testreport
69 if test "x$sUser" != x ; then
70 tUser=
71 if test -f $dir/genmake_state ; then
72 nn=`sed -n '/^# executed by:/=' $dir/genmake_state`
73 if test "x$nn" != x ; then
74 nn=`expr $nn + 1`
75 tUser=`sed -n "$nn s/^# *// p" $dir/genmake_state | sed 's/@.*$//'`
76 fi
77 fi
78 if test "x$tUser" = "x" ; then
79 mkfile=`ls $dir/*/Makefile* 2>/dev/null | head -1`
80 if test "x$mkfile" = 'x' ; then
81 echo "no Makefile => discard test from: $i" | tee -a $OUTPFIL
82 continue
83 fi
84 nn=`sed -n '/^# executed by:/=' $mkfile`
85 if test "x$nn" != x ; then
86 nn=`expr $nn + 1`
87 tUser=`sed -n "$nn s/^# *// p" $mkfile | sed 's/@.*$//'`
88 fi
89 fi
90 if test "x$tUser" = x ; then
91 echo "no User found => discard test from: $i" | tee -a $OUTPFIL
92 continue
93 fi
94 if test $tUser != $sUser ; then
95 if test $dBug = 't' ; then
96 echo " discard test from: $i" | tee -a $OUTPFIL
97 fi
98 continue
99 fi
100 fi
101
102 ADJOINT=
103 TANGLIN=
104 RESTART=0
105 FAST=0
106 DVLP=0
107 MPI=0
108 MTH=0
109 UR4=0
110 if test -r $dir/summary.txt ; then
111 comm=`grep 'ADJOINT=true' $dir/summary.txt 2>/dev/null`
112 eval $comm
113 comm=`grep 'TANGLIN=true' $dir/summary.txt 2>/dev/null`
114 eval $comm
115 RESTART=`grep -c 'test 2+2=4 summary' $dir/summary.txt`
116 FAST=`grep -c "^run: .*testreport.* '*-fast'*" $dir/summary.txt`
117 if test "x$FAST" = x0 ; then
118 FAST=`grep -c "^run: .*testreport.* '*-noieee'*" $dir/summary.txt`
119 fi
120 DVLP=`grep -c "^run: .*testreport.* '*-devel'*" $dir/summary.txt`
121 MPI=`grep -c "^run: .*testreport.* -mpi " $dir/summary.txt`
122 if test "x$MPI" = x0 ; then
123 MPI=`grep -c "^run: .*testreport.* -MPI " $dir/summary.txt`
124 fi
125 MTH=`grep -c "^run: .*testreport.* -mth" $dir/summary.txt`
126 UR4=`grep -c "^run: .*testreport.* -use_r4 " $dir/summary.txt`
127 if test "x$UR4" = x0 ; then
128 UR4=`grep -c "^run: .*testreport.* -ur4 " $dir/summary.txt`
129 fi
130 fi
131 if test "x$ADJOINT" = xtrue ; then
132 kind="adjoint" ; order='000'
133 elif test "x$TANGLIN" = xtrue ; then
134 kind="tanglin" ; order='001'
135 elif test "x$RESTART" = x0 ; then
136 kind="forward" ; order='002'
137 else
138 kind="restart" ; order='003'
139 fi
140 if test "x$UR4" = x1 ; then
141 OPTFILE="${OPTFILE}.use_r4"
142 fi
143 if test "x$MPI" = x1 ; then
144 yy=`echo $OPTFILE | grep -c '+mpi'`
145 if test $yy = 0 ; then OPTFILE="${OPTFILE}+mpi" ; fi
146 fi
147 if test "x$MTH" = x1 ; then
148 yy=`echo $OPTFILE | grep -c '+mth$'`
149 if test $yy = 0 ; then OPTFILE="${OPTFILE}+mth" ; fi
150 fi
151 if test "x$FAST" = x1 ; then
152 OPTFILE="${OPTFILE}.fast"
153 fi
154 if test "x$DVLP" = x1 ; then
155 OPTFILE="${OPTFILE}.dvlp"
156 fi
157 day=`echo $i | sed -e 's/_[0-9]$//' | sed -e 's/_[0-9][0-9]$//'`
158 ttt=`echo $day | sed -e 's/_[0-9]$//' | sed -e 's/_[0-9][0-9]$//'`
159 day=`echo $ttt | sed -e 's|_| |g' |awk '{print $NF}'`
160
161 if [ $day -lt $BEFORE ] ; then
162 echo "$OPTFILE$order $day $OPTFILE $kind $i" >> ./plist
163 elif [ $day -ge $FIRSTDAY -a $day -le $LASTDAY ] ; then
164 echo "$OPTFILE$order $day $OPTFILE $kind $i" >> ./slist
165 else
166 if test $dBug = 't' ; then
167 echo "discard day='$day' from: $i" | tee -a $OUTPFIL
168 fi
169 fi
170
171 done
172 if test $dBug = 't' ; then
173 if test $monthDir == 1 ; then
174 echo "---- current list (n=$monthDir) :" | tee -a $OUTPFIL
175 cat ./slist | tee -a $OUTPFIL
176 fi
177 num1=`wc -l ./slist | awk '{print $1}'`
178 if test $num1 -gt 0 ; then
179 echo ".... previous list (n=$monthDir):" | tee -a $OUTPFIL
180 cat ./plist | tee -a $OUTPFIL | head -20
181 fi
182 echo "----" | tee -a $OUTPFIL
183 fi
184 }
185
186 #--------------------------------------------------------------------------
187 # here starts the sequential part of the script:
188
189 #CURR_PER=`date +%Y`"_"`date +%m`
190 CURR_DAY=`date +%Y%m%d`
191 # defaults
192 MACHINES='_All_'
193 FIRSTDAY=$CURR_DAY
194 LASTDAY="30000000"
195 BEFORE="30000000"
196 OUTPFIL=`basename $0`'.log'
197 NBLDIFF=5
198 ADDRESS='none'
199 dBug=f
200 sTime=`date`
201 #- to get case insensitive "ls" (and order of tested experiments)
202 export LC_ALL="en_US.UTF-8"
203
204 # Parse options
205 ac_prev=
206 for ac_option ; do
207
208 # If the previous option needs an argument, assign it.
209 if test -n "$ac_prev"; then
210 eval "$ac_prev=\$ac_option"
211 ac_prev=
212 continue
213 fi
214
215 ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
216
217 case $ac_option in
218
219 -help | --help | -h | --h) usage ;;
220 -verbose | --verbose | -v | --v) dBug=t ;;
221
222 -list | --list | -l | --l) ac_prev=MACHINES ;;
223 -list=* | --list=*) MACHINES=$ac_optarg ;;
224
225 -day | --day | -d | --d) ac_prev=FIRSTDAY ;;
226 -day=* | --day=*) FIRSTDAY=$ac_optarg ;;
227
228 -upto | --upto | -u | --u) ac_prev=LASTDAY ;;
229 -upto=* | --upto=*) LASTDAY=$ac_optarg ;;
230
231 -before | --before | -b | --b) ac_prev=BEFORE ;;
232 -before=* | --before=*) BEFORE=$ac_optarg ;;
233
234 -outp | --outp | -o | --o) ac_prev=OUTPFIL ;;
235 -outp=* | --outp=*) OUTPFIL=$ac_optarg ;;
236
237 -nldf | --nldf | -n | --n) ac_prev=NBLDIFF ;;
238 -nldf=* | --nldf=*) NBLDIFF=$ac_optarg ;;
239
240 -addr | --addr | -a | --a) ac_prev=ADDRESS ;;
241 -addr=* | --addr=*) ADDRESS=$ac_optarg ;;
242
243 *) echo "Error: don't understand argument \"$ac_option\""
244 usage ;;
245
246 esac
247
248 done
249 #-- test FIRSTDAY content ; interpret as "date -d" arg. if not YYYYMMDD
250 ttt=`echo "y$FIRSTDAY" | sed 's/[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]/z/'`
251 if test "x$ttt" != 'xyz' ; then
252 FIRSTDAY=`date -d "$FIRSTDAY" +%Y%m%d`
253 fi
254 ttt=`echo "y$FIRSTDAY" | sed 's/[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]/z/'`
255 if test "x$ttt" != 'xyz' ; then
256 echo "Error: FIRSTDAY='$FIRSDAY' not recognized"
257 exit 2
258 fi
259 if test $LASTDAY = "30000000" ; then LASTDAY=$FIRSTDAY ; fi
260 if test $BEFORE = "30000000" ; then BEFORE=$FIRSTDAY ; fi
261 CMDLINE=$0
262 for xx in "$@" ; do nw=`echo $xx | wc -w`
263 if test $nw = '1' ; then CMDLINE="$CMDLINE $xx"
264 else CMDLINE="$CMDLINE '$xx'" ; fi
265 done
266
267 PERIOD=`echo $LASTDAY | sed 's/[0-9][0-9]$//'`
268 PP=`expr $PERIOD - 1`
269 PM=`echo $PP | sed 's/^[0-9][0-9][0-9][0-9]//'`
270 PY=`echo $PP | sed 's/[0-9][0-9]$//'`
271 if test $PM == '00' ; then PM='12' ; PY=`expr $PY - 1` ; fi
272 PREV_P="${PY}_${PM}";
273 PERIOD=`echo $PERIOD | sed 's/^[0-9][0-9][0-9][0-9]/&_/'`
274
275 #INDIR="/net/orwell/export/export-9/mitgcm-testing/results/$PERIOD"
276 INDIR="/u/u0/httpd/html/testing/results/$PERIOD"
277 #INDIR="/export/export-7/u/u2/jmc/mitgcm/test_web/results/$PERIOD"
278
279 if test $OUTPFIL = '-1' ; then
280 OUTPFIL='TTT.'$$
281 elif test -e $OUTPFIL ; then
282 mv -f $OUTPFIL $OUTPFIL'_bak'
283 fi
284 echo "CMDLINE='$CMDLINE'" > $OUTPFIL
285 echo "PERIOD='$PERIOD' , PREV_P='$PREV_P'" >> $OUTPFIL
286 echo "INDIR='$INDIR'" >> $OUTPFIL
287 echo "Checking latest output from $FIRSTDAY until $LASTDAY" >> $OUTPFIL
288 echo " versus latest from before $BEFORE" >> $OUTPFIL
289
290 if test $dBug = 't' ; then
291 echo "PERIOD='$PERIOD' , PREV_P='$PREV_P'"
292 echo "FIRSTDAY='$FIRSTDAY' , LASTDAY='$LASTDAY' , BEFORE='$BEFORE'"
293 fi
294 if test -d $INDIR ; then
295 dirP=`echo $INDIR | sed "s/$PERIOD/$PREV_P/"`
296 if test -d $dirP ; then
297 listNum='1 2'
298 else
299 echo "$dirP is not a directory"
300 listNum='1'
301 fi
302 else
303 echo "$INDIR is not a directory"
304 exit 3
305 fi
306
307 #- a short summary of this checking :
308 OUTPSUM=`echo $LASTDAY | sed 's/^20../_/'`
309 OUTPSUM=`basename $0`"$OUTPSUM.txt"
310 if test -e $OUTPSUM ; then mv -f $OUTPSUM $OUTPSUM'_bak' ; fi
311 echo ' '$CMDLINE > $OUTPSUM
312
313 if test $FIRSTDAY = $LASTDAY ; then
314 echo -n "Checking latest output from $FIRSTDAY" | tee -a $OUTPSUM
315 else
316 echo -n "Checking latest output from $FIRSTDAY until $LASTDAY" | tee -a $OUTPSUM
317 fi
318 if test $FIRSTDAY = $BEFORE ; then
319 echo " versus latest prior to this period" | tee -a $OUTPSUM
320 else
321 echo " versus latest from before $BEFORE" | tee -a $OUTPSUM
322 fi
323 echo " Machine Tot. Nb. no Nb with Nb diff" >> $OUTPSUM
324 echo " name checked comp Diff lines" >> $OUTPSUM
325
326 ( cd $INDIR ; ls -1 -t */summary.txt | sed 's/\/summary.txt//' ) > ./dir_all
327
328 if test "x$MACHINES" = "x_All_" ; then
329 MACHINES="faulks meander aces- acesgrid baudelaire dickens danton beagle harbor"
330 MACHINES="$MACHINES pleiades iblade rays solasrv sx8"
331 MACHINES="$MACHINES trane dodongo dokdo stomp bigred"
332
333 MALL=`cat ./dir_all | sed -e 's|_| |g' | awk '{print $2}' | sort | uniq`
334 for madd in $MALL ; do
335 present=0
336 for m in $MACHINES ; do
337 mm=`echo $m | sed 's/\./ /g' | awk '{print $1}'`
338 echo $madd | grep $mm > /dev/null 2>&1
339 RETVAL=$?
340 test $RETVAL = 0 && present=1
341 continue
342 done
343 test $present = 0 && MACHINES="$MACHINES $madd"
344 done
345 fi
346 #echo "MACHINES=$MACHINES" ; exit
347
348 for pname in $MACHINES ; do
349
350 sname=`echo $pname | sed 's/-$//'`
351 mname=`echo $pname | sed 's/\./ /g' | awk '{print $1}'`
352 sUser=
353 if test $mname != $pname ; then
354 # to select results from user "sUser"
355 sUser=`echo $pname | sed 's/\./ /g' | awk '{print $2}'`
356 fi
357
358 if test $dBug = 't' ; then echo " $pname" ; fi
359 echo " name='$pname'" >> $OUTPFIL
360 ctot=0 ; cmis=0 ; cdif=0
361
362 # put results from selected period in "slist",
363 # results from previous period in "plist"
364 rm -f ./plist ./slist ; touch ./plist ./slist
365
366 #- create list of results (slist & plist) from current month directory
367 monthDir=1
368 make_resdir_list
369
370 # Do we have any data? If so, create the latest pointer.
371 num=`wc -l ./slist | awk '{print $1}'`
372 if test $num -gt 0 ; then
373
374 keys=`cat ./slist | cut -d " " -f 1 | sort | uniq`
375
376 for key in $keys ; do
377 ctot=`expr $ctot + 1`
378 sline=`grep "^$key " ./slist | head -1`
379 sdir=`echo $sline | cut -d " " -f 5`
380 type=`echo $sline | cut -d " " -f 4`
381 optf=`echo $sline | cut -d " " -f 3`
382 num=`grep -c "^$key" ./plist`
383 if test $num = 0 -a $monthDir = 1 ; then
384 #- add results from previous month directory to "plist".
385 monthDir=2
386 make_resdir_list
387 num=`grep -c "^$key" ./plist`
388 fi
389 #- discard unsafe test:
390 dd=`echo $optf | grep -c 'gfortran+mth'`
391 if test $mname = 'lagoon' -a $dd = 1 ; then num=-1 ; fi
392 if test $mname = 'harbor' -a $dd = 1 ; then num=-1 ; fi
393 #if test $mname = 'aces' -a $optf = 'linux_ia32_open64' ; then num=-1 ; fi
394 #if test $mname = 'aces' -a $optf = 'linux_ia32_g95' ; then num=-1 ; fi
395 dd=`echo $optf | grep -c 'bigred.*noieee'`
396 #if test $mname = 'bigred' -a $dd = 1 ; then num=-1 ; fi
397 if test $num -lt 0 ; then
398 echo " discard $sdir : $type , of='$optf'" | tee -a $OUTPFIL
399 cmis=`expr $cmis + 1`
400 elif test $num = '0' ; then
401 echo "no previous test for:" $key | tee -a $OUTPFIL
402 cmis=`expr $cmis + 1`
403 else
404 pline=`grep "^$key " ./plist | head -1`
405 if test $dBug = 't' ; then
406 echo "s='$sline'" | tee -a $OUTPFIL
407 echo "p='$pline'" | tee -a $OUTPFIL
408 fi
409 pdir=`echo $pline | cut -d " " -f 5`
410 outs="$INDIR/$sdir/summary.txt"
411 xx=`( echo 5 ; sed -n '/^ OPTFILE=/=' $outs ) | tail -1`
412 sed "1,$xx d" $outs | sed '/^[YN] [YN] [YN] [YN]/ s/ \. //g' \
413 | grep -v '^[A-S][a-t]* time: ' > tmpfs
414 outp="$INDIR/$pdir/summary.txt"
415 xx=`( echo 5 ; sed -n '/^ OPTFILE=/=' $outp ) | tail -1`
416 sed "1,$xx d" $outp | sed '/^[YN] [YN] [YN] [YN]/ s/ \. //g' \
417 | grep -v '^[A-S][a-t]* time: ' > tmpfp
418 #-- re-order list of exp (according to local "sort" order)
419 listD=`grep '^[YN] [YN] [YN] [YN]' tmpfs | awk '{print $NF}' | sort`
420 for xx in $listD
421 do
422 sed "/ $xx\$/d" tmpfs > tmpfn
423 sed -n "/ $xx\$/p" tmpfs >> tmpfn
424 mv tmpfn tmpfs
425 done
426 listD=`grep '^[YN] [YN] [YN] [YN]' tmpfp | awk '{print $NF}' | sort`
427 for xx in $listD
428 do
429 sed "/ $xx\$/d" tmpfp > tmpfn
430 sed -n "/ $xx\$/p" tmpfp >> tmpfn
431 mv tmpfn tmpfp
432 done
433 echo -n "=== diff $sdir $pdir :" | tee -a $OUTPFIL
434 diff tmpfs tmpfp > tmpdf
435 yy=$?
436 if test $yy != '0' ; then
437 echo " $type , of='$optf'" | tee -a $OUTPFIL
438 #grep '^run: ' $outp
439 #grep '^run: ' $outs
440 #-- score for each test:
441 grep '^[YN] [YN] [YN] [YN]' tmpfs > tmploc 2>/dev/null
442 t_tot=`cat tmploc | wc -l | sed -e 's| ||g'`
443 t_pass=`grep '^Y Y Y Y' tmploc | grep 'pass ' | wc -l | sed -e 's| ||g'`
444 score_s=`printf '%2i' $t_pass`":$t_tot"
445 grep '^[YN] [YN] [YN] [YN]' tmpfp > tmploc 2>/dev/null
446 t_tot=`cat tmploc | wc -l | sed -e 's| ||g'`
447 t_pass=`grep '^Y Y Y Y' tmploc | grep 'pass ' | wc -l | sed -e 's| ||g'`
448 score_p=`printf '%2i' $t_pass`":$t_tot"
449 rm -f tmploc
450 #-- count Nb of different lines
451 ndf=`wc -l tmpdf | awk '{print $1}'`
452 ndf=`expr $ndf / 2`
453 nn=`grep -c '^---' tmpdf`
454 ndf=`expr $ndf - $nn`
455 if [ $ndf -le $NBLDIFF ] ; then
456 cat tmpdf
457 else
458 echo " $ndf lines differ ( $score_s , $score_p )"
459 fi
460 echo "< "`head -1 $outs`" ( $score_s )" >> $OUTPFIL
461 echo "> "`head -1 $outp`" ( $score_p )" >> $OUTPFIL
462 cat tmpdf >> $OUTPFIL
463 if [ $cdif -eq 0 ] ; then
464 clin=`printf '%3i (%5s,%5s)' $ndf $score_s $score_p`
465 else
466 clin="$clin,"`printf '%3i (%5s,%5s)' $ndf $score_s $score_p`
467 fi
468 cdif=`expr $cdif + 1`
469 echo '----------------------------------------' | tee -a $OUTPFIL
470 else
471 echo " $type , of='$optf'" | tee -a $OUTPFIL
472 fi
473 rm -f tmpfs tmpfp tmpdf
474 fi
475 done
476 if [ $cmis -gt 0 ] ; then tmis='(-'$cmis')' ; else tmis='(--)' ; fi
477 printf '%11s : %3i %4s %3i ' $sname $ctot $tmis $cdif >> $OUTPSUM
478 if [ $cdif -gt 0 ] ; then
479 echo " $clin" >> $OUTPSUM
480 else echo "" >> $OUTPSUM ; fi
481 fi
482
483 done
484
485 echo "Start time: $sTime" | tee -a $OUTPFIL
486 echo "End time: "`date` | tee -a $OUTPFIL | tee -a $OUTPSUM
487
488 rm -f ./dir_all ./slist ./plist
489 if test $OUTPFIL = "TTT.$$" ; then rm -f $OUTPFIL ; fi
490 if test "x$ADDRESS" != 'xnone' ; then
491 echo ".. send $OUTPSUM to $ADDRESS"
492 mail -s $OUTPSUM $ADDRESS < $OUTPSUM
493 fi
494 echo ".. cat $OUTPSUM"
495 cat $OUTPSUM
496 exit 0

  ViewVC Help
Powered by ViewVC 1.1.22