/[MITgcm]/mitgcm.org/scripts/check_outp
ViewVC logotype

Annotation of /mitgcm.org/scripts/check_outp

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.15 - (hide annotations) (download)
Tue Jul 7 23:32:02 2009 UTC (15 years, 11 months ago) by jmc
Branch: MAIN
Changes since 1.14: +6 -6 lines
similar to make_summary changes

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

  ViewVC Help
Powered by ViewVC 1.1.22