/[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.8 - (show annotations) (download)
Thu Apr 16 14:45:53 2009 UTC (16 years, 2 months ago) by jmc
Branch: MAIN
Changes since 1.7: +8 -2 lines
add sufix "+mth" to optfile name when running testreport with -mth option

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

  ViewVC Help
Powered by ViewVC 1.1.22