/[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.3 - (hide annotations) (download)
Tue Sep 9 18:09:37 2008 UTC (16 years, 9 months ago) by jmc
Branch: MAIN
Changes since 1.2: +3 -3 lines
minor changes

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

  ViewVC Help
Powered by ViewVC 1.1.22