/[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.31 - (show annotations) (download)
Tue Aug 23 18:14:10 2011 UTC (12 years, 8 months ago) by jmc
Branch: MAIN
Changes since 1.30: +8 -7 lines
more logical ordering of test listing on web-page

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

  ViewVC Help
Powered by ViewVC 1.1.22