/[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.33 - (show annotations) (download)
Tue Sep 4 20:34:31 2012 UTC (12 years, 9 months ago) by jmc
Branch: MAIN
Changes since 1.32: +23 -13 lines
import modifs from front_content/make_summary:
distinguish when output contains selected number of experiments (-t/-tdir)

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

  ViewVC Help
Powered by ViewVC 1.1.22