/[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.23 - (show annotations) (download)
Tue Apr 27 19:51:50 2010 UTC (15 years, 2 months ago) by jmc
Branch: MAIN
Changes since 1.22: +2 -2 lines
minor modif

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

  ViewVC Help
Powered by ViewVC 1.1.22