/[MITgcm]/MITgcm/verification/testreport
ViewVC logotype

Contents of /MITgcm/verification/testreport

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


Revision 1.2 - (show annotations) (download)
Mon Sep 1 16:50:27 2003 UTC (17 years, 9 months ago) by edhill
Branch: MAIN
Changes since 1.1: +41 -19 lines
simplify reports sent with mpack and convert "summary.txt" to bash syntax

1 #!/bin/bash
2 #
3 # $Header: /u/u3/gcmpack/MITgcm/verification/testreport,v 1.1 2003/08/27 22:12:31 edhill Exp $
4 #
5
6 usage()
7 {
8 echo
9 echo "Usage: $0 [OPTIONS]"
10 echo
11 echo "where possible OPTIONS are:"
12 echo " (-help|-h) print usage"
13 echo " (-optfile=|-of=)STRING list of genmake2 \"optfiles\""
14 echo " (-a|-addr)STRING list of email recipients"
15 echo " (-t|-tdir)STRING list of \"test\" dirs"
16 echo
17 exit 1
18 }
19
20 # build the mpack utility
21 build_mpack()
22 {
23 echo -n "building the mpack utility... "
24 if test ! -x "$MPACKDIR/mpack" ; then
25 if test ! -d $MPACKDIR ; then
26 echo "Error: can't find \"$MPACKDIR\""
27 echo " are you sure this program is being run in the correct "
28 echo " (that is, \"MITGCM_ROOT\verification\") directory?"
29 exit 1
30 fi
31 echo -n "building mpack... "
32 ( cd $MPACKDIR && ./configure && make ) > build_mpack.out 2>&1
33 RETVAL=$?
34 if test "x$RETVAL" != x0 ; then
35 echo
36 echo "Error building the mpack tools at: $MPACK_DIR"
37 exit 1
38 fi
39 fi
40 echo "OK"
41 }
42
43 compare_lines()
44 {
45 # use codelet to compare lines
46 if [ $verbose -gt 1 ]; then
47 cat tmp3.txt 1>&2
48 fi
49 return `./a.out < tmp3.txt`
50 }
51
52 testoutput_for_prop()
53 {
54 # testoutput_for_prop dir s1 label subdir
55 #
56 # compares files in $dir/$subdir/output.txt and $dir/results/output.txt
57 # using search strings s1 and text label
58
59 if [ $debug -gt 0 ]; then
60 echo testoutput_for_prop: grep "$2" $1/$4/output.txt 1>&2
61 fi
62 if [ -r $1/$4/output.txt ]; then
63 grep "$2" $1/$4/output.txt | sed 's/.*=//' | nl > tmp1.txt
64 lncnt=`wc -l tmp1.txt | awk '{print $1}' `
65 if [ $lncnt -lt 3 ]; then
66 if [ $verbose -gt 0 ]; then
67 echo Not enough lines of output when searching for "$2" 1>&2
68 fi
69 return 99
70 fi
71 else
72 echo testoutput_for_prop: output.txt from model run was not readable 1>&2
73 return 99
74 fi
75 if [ $debug -gt 0 ]; then
76 echo testoutput_for_prop: grep "$2" $1/results/output.txt 1>&2
77 fi
78 grep "$2" $1/results/output.txt | sed 's/.*=//' | nl > tmp2.txt
79 lncnt=`wc -l tmp2.txt | awk '{print $1}' `
80 if [ $lncnt -lt 3 ]; then
81 if [ $verbose -gt 0 ]; then
82 echo Not enough lines of output when searching for "$2" 1>&2
83 fi
84 return 99
85 fi
86 if [ $debug -gt 0 ]; then
87 echo testoutput_for_prop: join tmp1.txt tmp2.txt 1>&2
88 fi
89 join tmp1.txt tmp2.txt | awk '{print $1 " " $2 " " $3}' > tmp3.txt
90 if [ $debug -gt 0 ]; then
91 echo testoutput_for_prop: compare_lines 1>&2
92 fi
93 compare_lines
94 digits_of_similarity=$?
95 if [ $digits_of_similarity -eq 99 ]; then
96 if [ $verbose -gt 0 ]; then
97 echo testoutput_for_prop: No comparison was available for \"$2\" 1>&2
98 fi
99 digits_of_similarity=99
100 else
101 if [ $verbose -gt 0 ]; then
102 echo There were $digits_of_similarity decimal places of similarity for \"$2\" 1>&2
103 fi
104 fi
105 rm tmp1.txt tmp2.txt tmp3.txt
106
107 return $digits_of_similarity
108 }
109
110 dashnum()
111 {
112 # dashnum n1 n2 n3 ...
113 #
114 # print numbers using %3i format or "--" if number = 99
115
116 for num in $@ ; do
117 if [ $num = 99 ]; then
118 printf ' --'
119 else
120 printf '%3i' $num
121 fi
122 done
123 }
124
125 testoutput()
126 {
127 # testoutput diretory subdir
128 #
129 # test output in "directory"
130
131 if [ $debug -gt 0 ]; then
132 echo testoutput: testoutput_for_prop $1 cg2d_init_res 1>&2
133 fi
134 testoutput_for_prop $1 "cg2d_init_res" "cg2d init. residual" $2; cg2dres=$?
135 if [ $debug -gt 0 ]; then
136 echo testoutput: cg2dres=$cg2dres 1>&2
137 fi
138
139 testoutput_for_prop $1 "dynstat_theta_min" "theta minimum" $2; tmin=$?
140 testoutput_for_prop $1 "dynstat_theta_max" "theta maximum" $2; tmax=$?
141 testoutput_for_prop $1 "dynstat_theta_mean" "theta mean" $2; tmean=$?
142 testoutput_for_prop $1 "dynstat_theta_sd" "theta s.d." $2; tsd=$?
143 testoutput_for_prop $1 "dynstat_salt_min" "salt minimum" $2; smin=$?
144 testoutput_for_prop $1 "dynstat_salt_max" "salt maximum" $2; smax=$?
145 testoutput_for_prop $1 "dynstat_salt_mean" "salt mean" $2; smean=$?
146 testoutput_for_prop $1 "dynstat_salt_sd" "salt s.d." $2; ssd=$?
147 testoutput_for_prop $1 "dynstat_uvel_min" "U minimum" $2; umin=$?
148 testoutput_for_prop $1 "dynstat_uvel_max" "U maximum" $2; umax=$?
149 testoutput_for_prop $1 "dynstat_uvel_mean" "U mean" $2; umean=$?
150 testoutput_for_prop $1 "dynstat_uvel_sd" "U s.d." $2; usd=$?
151 testoutput_for_prop $1 "dynstat_vvel_min" "V minimum" $2; vmin=$?
152 testoutput_for_prop $1 "dynstat_vvel_max" "V maximum" $2; vmax=$?
153 testoutput_for_prop $1 "dynstat_vvel_mean" "V mean" $2; vmean=$?
154 testoutput_for_prop $1 "dynstat_vvel_sd" "V s.d." $2; vsd=$?
155
156 dashnum $cg2dres $tmin $tmax $tmean $tsd $smin $smax $smean $ssd \
157 $umin $umax $umean $usd $vmin $vmax $vmean $vsd
158 }
159
160 genmakemodel()
161 {
162 # genmakemodel directory
163 GENMAKE2="../../../tools/genmake2"
164 (
165 cd $1;
166 printf 'genmake ... ' 1>&2
167 # ../../../tools/genmake -ieee -mods=../code > make.log 2>&1
168 $GENMAKE2 -ds --mods=../code "--optfile="$OPTFILE > make.log 2>&1
169 RETVAL=$?
170 for i in gm_state gm_optfile gm_local Makefile ; do
171 if test -r $i ; then
172 cp $i $CDIR
173 fi
174 done
175 if test "x$RETVAL" != x0 ; then
176 tail make.log
177 echo "genmakemodel: genmake failed" 1>&2
178 cp make.log $CDIR
179 return 1
180 else
181 echo "succesful" 1>&2
182 fi
183 )
184 }
185
186 makeclean()
187 {
188 # makeclean directory
189 (
190 cd $1;
191 rm -f output.txt
192 printf 'make CLEAN ... ' 2>&1
193 if test -r Makefile ; then
194 make CLEAN >> make.log 2>&1
195 RETVAL=$?
196 if test "x$RETVAL" != x0 ; then
197 tail make.log
198 echo "makeclean: \"make CLEAN\" failed" 1>&2
199 cp make.log $CDIR"/make.log"
200 return 1
201 fi
202 fi
203 echo succesful 1>&2
204 exit 0
205 )
206 }
207
208 makedependmodel()
209 {
210 # makedependmodel directory
211 (
212 cd $1;
213 printf 'make depend ... ' 1>&2
214 make depend >> make.log 2>&1
215 RETVAL=$?
216 if test "x$RETVAL" != x0 ; then
217 tail make.log
218 echo "makedependmodel: make depend failed" 1>&2
219 cp make.log $CDIR"/make.log"
220 return 1
221 else
222 echo succesful 1>&2
223 fi
224 )
225 }
226
227 makemodel()
228 {
229 # makemodel directory
230 (
231 cd $1;
232 if test -r Makefile ; then
233 printf 'make ... ' 1>&2
234 make >> make.log 2>&1
235 RETVAL=$?
236 if test "x$RETVAL" != x0 ; then
237 tail make.log
238 echo failed 1>&2
239 cp make.log $CDIR"/make.log"
240 return 1
241 else
242 echo succesful 1>&2
243 fi
244 fi
245 )
246 }
247
248 linkdata()
249 {
250 # linkdata flag
251 #
252 # symbolically link data files to run directory
253 if [ $1 -ne 0 ]; then
254 ( cd $2 ; ln -sf ../input/* . )
255 fi
256 }
257
258 runmodel()
259 {
260 # runmodel directory exe
261 #
262 # runs the model "exe" in "directory" (exe is relative to directory)
263 (
264 cd $1
265 if [ -x $2 ]; then
266 if [ $quick -eq 0 ]; then
267 rm -f output.txt
268 fi
269 printf 'runmodel: ' 1>&2
270 make output.txt
271 RETVAL=$?
272 if test "x$RETVAL" = x0 ; then
273 cp output.txt $CDIR"/output.txt"
274 return 0
275 else
276 return 1
277 fi
278 fi
279 )
280 }
281
282 createcodelet()
283 {
284 # create codelet for comparing model output
285
286 echo -n "creating the comparison code... "
287 cat > tmp_cmpnum.f <<EOFA
288 program cmpnum
289 implicit none
290 real*8 a,b,diff
291 integer linnum,best
292 best=-16
293 99 read(*,*,end=70,err=60) linnum,a,b
294 diff=0.5*(abs(a)+abs(b))
295 c print *,a,b,diff,abs(a-b)/diff
296 if (diff.gt.1.e-12) then
297 diff=abs(a-b)/diff
298 if (diff.gt.0.) then
299 c print *,int(log10(diff)),diff
300 linnum=int(log10(diff))
301 best=max(best,linnum)
302 endif
303 else
304 if (best.eq.-16.and.diff.ne.0.) best=-22
305 endif
306 goto 99
307 60 stop 'cmpnum: An error occured reading a,b'
308 70 print *,-best
309 end
310 EOFA
311
312 f77 tmp_cmpnum.f
313 if [ -x ./a.out ]; then
314 echo "OK"
315 return 0
316 else
317 echo
318 echo "createcodelet: failed to compile codelet" | tee
319 exit 1
320 fi
321 }
322
323 formatresults()
324 {
325 # formatresults expt genmake depend make run results*
326
327 nm=$1
328 printf '%s %s %s %s' $2 $3 $4 $5
329 shift; shift; shift; shift; shift;
330 printf '%3s' $@
331
332 if [ $1 = '--' ]; then
333 printf ' N/O '
334 else
335 if [ $1 -gt 12 ]; then
336 printf ' pass'
337 else
338 printf ' FAIL'
339 fi
340 fi
341 printf ' %s' $nm
342 printf '\n'
343
344 }
345
346 show_help()
347 {
348 cat - << EOF
349 $0 [-help] [-quick] [-verbose] dir1 [dir2] [...]
350 -help Show this help message
351 -quick Skip "genmake" and "make depend" if the Makefile exists
352 -quiet Reduce the amount of output
353 -verbose Produce copious amounts of output
354 -debug Produce even more output which will mean nothing to most
355 -force Do "make CLEAN" before compiling. This forces a complete rebuild.
356 -clean Do "make CLEAN" after compiling and testing.
357 -noieee By default, $0 uses the -ieee option for genmake. This turns it off.
358 -cleanup Aggresively removes all model output, executables and object files
359 and then exits. Use with care.
360
361 Normal usage:
362 $0 * Configure, compile, run and analyze in all experiment directories
363 EOF
364 }
365
366 scandirs()
367 {
368 if [ $# -eq 0 ]; then
369 for arg in * ; do
370 test -d $arg/input && echo $arg
371 done
372 else
373 echo $*
374 fi
375 }
376
377
378 ###############################################################################
379 ###############################################################################
380 ###############################################################################
381
382
383 # Default properties
384 debug=0
385 verbose=1
386 quick=0
387 clean=0
388 ieee=1
389 expts=''
390
391 OPTFILES=
392 ADDRESSES=edhill@mitgcm.org
393 TESTDIRS=
394 MPACKDIR="../tools/mpack-1.6"
395 MPACK="$MPACKDIR/mpack"
396
397 echo -n "parsing options... "
398
399 ac_prev=
400 for ac_option ; do
401
402 # If the previous option needs an argument, assign it.
403 if test -n "$ac_prev"; then
404 eval "$ac_prev=\$ac_option"
405 ac_prev=
406 continue
407 fi
408
409 ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
410
411 case $ac_option in
412
413 -help | --help | -h | --h)
414 usage ;;
415
416 -optfile | --optfile | -of | --of)
417 ac_prev=OPTFILES ;;
418 -optfile=* | --optfile=* | -of=* | --of=*)
419 OPTFILES=$ac_optarg ;;
420
421 -addr | --addr | -a | --a)
422 ac_prev=ADDRESSES ;;
423 -addr=* | --addr=*)
424 ADDRESSES=$ac_optarg ;;
425
426 -tdir | --tdir | -t | --t)
427 ac_prev=TESTDIRS ;;
428 -tdir=* | --tdir=*)
429 TESTDIRS=$ac_optarg ;;
430
431 -quick) quick=1 ;;
432 -verbose) verbose=2 ;;
433 -debug) debug=1 ;;
434 -clean) clean=1 ;;
435 -noieee) ieee=0 ;;
436 -quiet) verbose=0 ;;
437
438 -*)
439 echo "Error: unrecognized option: "$ac_option
440 usage
441 ;;
442
443 *)
444 echo "Error: unrecognized argument: "$ac_option
445 usage
446 ;;
447
448 esac
449
450 done
451
452 if test "x$TESTDIRS" = x ; then
453 TESTDIRS=`scandirs`
454 fi
455
456 echo "OK"
457
458 # create the FORTRAN comparison code
459 createcodelet
460
461 # build the mpack utility
462 build_mpack
463
464 # Create a uniquely named directory to store results
465 MACH=`hostname`
466 UNAMEA=`uname -a`
467 DATE=`date +%Y%m%d`
468 BASE=$MACH"_"$DATE"_"
469 DNUM=0
470 DRESULTS="$BASE$DNUM"
471 while test -e $DRESULTS ; do
472 DNUM=$(( $DNUM + 1 ))
473 DRESULTS="$BASE$DNUM"
474 done
475 mkdir $DRESULTS
476 RETVAL=$?
477 if test "x$RETVAL" != x0 ; then
478 echo "Error: can't create results directory \"./$DRESULTS\""
479 exit 1
480 fi
481 SUMMARY="$DRESULTS/summary.txt"
482 date > $SUMMARY
483 cat << EOF >> $SUMMARY
484 T S U V
485 G D M c m s m s m s m s
486 E p a R g m m e . m m e . m m e . m m e .
487 N n k u 2 i a a d i a a d i a a d i a a d
488 2 d e n d n x n . n x n . n x n . n x n .
489
490 EOF
491
492 NDIR=0
493
494 # For each optfile...
495 for OPTFILE in $OPTFILES ; do
496
497 OPTFILE=`pwd`"/$OPTFILE"
498 if test ! -r $OPTFILE ; then
499 echo "Error: can't read optfile \"$OPTFILE\""
500 exit 1
501 fi
502 echo
503 echo "OPTFILE=$OPTFILE" >> $SUMMARY
504 echo >> $SUMMARY
505
506 # ...and each test directory...
507 for dir in $TESTDIRS ; do
508
509 # Create an output dir for each OPTFILE/tdir combination
510 CDIR=$DRESULTS"/"$DRESULTS"_"$NDIR
511 mkdir $CDIR
512 CDIR=`pwd`"/$CDIR"
513
514 # ...configue, make, run, and compare the output.
515 echo "-------------------------------------------------------------------------------"
516 echo
517 echo "Experiment: $dir"
518 echo
519 unset genmake makedepend make run
520 results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --'
521 ( cd $dir/input; rm -f *.{o,f,c,F} *.[f,F]90 work* output.txt Make* make.log; )
522 if [ -r $dir/build ]; then
523 seperatebuilddir=1
524 builddir=build
525 rundir=build
526 ( cd $dir/build; ln -sf ../input/* . )
527 else
528 seperatebuilddir=0
529 builddir=input
530 rundir=input
531 fi
532
533 # Verify that the testdir exists and contains previous
534 # results in the correct location--or skip this directory!
535 if test ! -r $dir"/results/output.txt" ; then
536 echo | tee $SUMMARY
537 echo "can't read \"$dir/results/output.txt\" -- skipping $dir" \
538 | tee $SUMMARY
539 continue
540 fi
541
542 genmakemodel $dir/$builddir && genmake=Y \
543 && makeclean $dir/$builddir \
544 && makedependmodel $dir/$builddir && makedepend=Y \
545 && makemodel $dir/$builddir && make=Y \
546 && linkdata $seperatebuilddir $dir/$rundir \
547 && runmodel $dir/$builddir mitgcmuv && run=Y \
548 && results=`testoutput $dir $rundir`
549 echo
550 formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \
551 ${run:-N} $results
552 echo
553 formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \
554 ${run:-N} $results >> $SUMMARY
555 echo "fresults='" > $CDIR"/summary.txt"
556 formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \
557 ${run:-N} $results >> $CDIR"/summary.txt"
558 echo "'" >> $CDIR"/summary.txt"
559 echo "MACH='$MACH'" >> $CDIR"/summary.txt"
560 echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"
561 echo "DATE='$DATE'" >> $CDIR"/summary.txt"
562 echo "tdir='$dir'" >> $CDIR"/summary.txt"
563
564 (
565 cd $DRESULTS
566 tar -cf $NDIR".tar" $DRESULTS"_"$NDIR > /dev/null 2>&1
567 gzip $NDIR".tar"
568 )
569
570 $MPACK -s MITgcm-test -m 1000000 $DRESULTS"/"$NDIR".tar.gz" $ADDRESSES
571 RETVAL=$?
572 if test "x$RETVAL" != x0 ; then
573 echo "Warning: \"$MPACK\" failed -- please contact <edhill@mitgcm.org>"
574 else
575 rm -f $DRESULTS"/"$NDIR".tar*"
576 fi
577
578 NDIR=$(( $NDIR + 1 ))
579
580 done
581 done
582
583 rm tmp_cmpnum.f a.out
584
585 cat $SUMMARY

  ViewVC Help
Powered by ViewVC 1.1.22