/[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.29 - (show annotations) (download)
Tue Aug 9 16:40:29 2011 UTC (13 years, 1 month ago) by jmc
Branch: MAIN
Changes since 1.28: +5 -4 lines
add acesgrid to the list of known machines

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

  ViewVC Help
Powered by ViewVC 1.1.22