/[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.26 - (show annotations) (download)
Wed Nov 24 16:22:08 2010 UTC (14 years, 7 months ago) by jmc
Branch: MAIN
Changes since 1.25: +3 -3 lines
update list of "known" tested platforms

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

  ViewVC Help
Powered by ViewVC 1.1.22