/[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.10 - (show annotations) (download)
Thu May 21 15:42:46 2009 UTC (16 years, 1 month ago) by jmc
Branch: MAIN
Changes since 1.9: +2 -1 lines
minor adjustment

1 #! /usr/bin/env bash
2
3 # $Header: /u/gcmpack/mitgcm.org/scripts/check_outp,v 1.9 2009/05/02 14:37:05 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 | head -20
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 $mname = 'lagoon' -a $dd = 1 ; then num=-1 ; fi
312 if test $mname = 'harbor' -a $dd = 1 ; then num=-1 ; fi
313 if test $mname = 'aces' -a $optf = 'linux_ia32_open64' ; then num=-1 ; fi
314 if test $mname = 'aces' -a $optf = 'linux_ia32_g95' ; then num=-1 ; fi
315 if test $num -gt 0 ; then
316 pline=`grep "^$key " ./plist | head -1`
317 if test $dBug = 't' ; then
318 echo "s='$sline'" | tee -a $OUTPFIL
319 echo "p='$pline'" | tee -a $OUTPFIL
320 fi
321 pdir=`echo $pline | cut -d " " -f 5`
322 outs="$INDIR/$sdir/summary.txt"
323 sed -n "5,$ p" $outs | sed '/^[YN] [YN] [YN] [YN]/ s/ \. //g' \
324 | sed 's/ OPTFILE=.*\// OPTFILE=/g' \
325 | grep -v '^[A-S][a-t]* time: ' > tmpfs
326 outp="$INDIR/$pdir/summary.txt"
327 sed -n "5,$ p" $outp | sed '/^[YN] [YN] [YN] [YN]/ s/ \. //g' \
328 | sed 's/ OPTFILE=.*\// OPTFILE=/g' \
329 | grep -v '^[A-S][a-t]* time: ' > tmpfp
330 echo -n "=== diff $sdir $pdir :" | tee -a $OUTPFIL
331 diff tmpfs tmpfp > tmpdf
332 yy=$?
333 if test $yy != '0' ; then
334 echo " $kind , of='$optf'" | tee -a $OUTPFIL
335 #grep '^run: ' $outp
336 #grep '^run: ' $outs
337 #-- score for each test:
338 grep '^[YN] [YN] [YN] [YN]' tmpfs > tmploc 2>/dev/null
339 t_tot=`cat tmploc | wc -l | sed -e 's| ||g'`
340 t_pass=`grep '^Y Y Y Y' tmploc | grep 'pass ' | wc -l | sed -e 's| ||g'`
341 score_s=`printf '%2i' $t_pass`":$t_tot"
342 grep '^[YN] [YN] [YN] [YN]' tmpfp > tmploc 2>/dev/null
343 t_tot=`cat tmploc | wc -l | sed -e 's| ||g'`
344 t_pass=`grep '^Y Y Y Y' tmploc | grep 'pass ' | wc -l | sed -e 's| ||g'`
345 score_p=`printf '%2i' $t_pass`":$t_tot"
346 rm -f tmploc
347 #-- count Nb of different lines
348 ndf=`wc -l tmpdf | awk '{print $1}'`
349 ndf=`expr $ndf / 2`
350 nn=`grep -c '^---' tmpdf`
351 ndf=`expr $ndf - $nn`
352 if [ $ndf -le $NBLDIFF ] ; then
353 cat tmpdf
354 else
355 echo " $ndf lines differ ( $score_s , $score_p )"
356 fi
357 echo "< "`head -1 $outs`" ( $score_s )" >> $OUTPFIL
358 echo "> "`head -1 $outp`" ( $score_p )" >> $OUTPFIL
359 cat tmpdf >> $OUTPFIL
360 if [ $cdif -eq 0 ] ; then
361 clin=`printf '%3i (%5s,%5s)' $ndf $score_s $score_p`
362 else
363 clin="$clin,"`printf '%3i (%5s,%5s)' $ndf $score_s $score_p`
364 fi
365 cdif=`expr $cdif + 1`
366 echo '----------------------------------------' | tee -a $OUTPFIL
367 else
368 echo "" | tee -a $OUTPFIL
369 fi
370 rm -f tmpfs tmpfp tmpdf
371 elif test $num = '0' ; then
372 echo "no previous test for:" $key | tee -a $OUTPFIL
373 cmis=`expr $cmis + 1`
374 else
375 cmis=`expr $cmis + 1`
376 fi
377 done
378 if [ $cmis -gt 0 ] ; then tmis='(-'$cmis')' ; else tmis='(--)' ; fi
379 printf '%11s : %3i %4s %3i ' $mname $ctot $tmis $cdif >> $OUTPSUM
380 if [ $cdif -gt 0 ] ; then
381 echo " $clin" >> $OUTPSUM
382 else echo "" >> $OUTPSUM ; fi
383 fi
384
385 done
386
387 echo "Start time: $sTime" | tee -a $OUTPFIL
388 echo "End time: "`date` | tee -a $OUTPFIL | tee -a $OUTPSUM
389
390 rm -f ./dir_all ./slist ./plist
391 if test $OUTPFIL = "TTT.$$" ; then rm -f $OUTPFIL ; fi
392 if test "x$ADDRESS" != 'xnone' ; then
393 echo ".. send $OUTPSUM to $ADDRESS"
394 mail -s $OUTPSUM $ADDRESS < $OUTPSUM
395 fi
396 echo ".. cat $OUTPSUM"
397 cat $OUTPSUM
398 exit 0

  ViewVC Help
Powered by ViewVC 1.1.22