/[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.9 - (show annotations) (download)
Tue Sep 16 18:16:03 2003 UTC (20 years, 6 months ago) by edhill
Branch: MAIN
CVS Tags: checkpoint51j_post, checkpoint51f_post, branchpoint-genmake2, checkpoint51h_pre, checkpoint51g_post, checkpoint51i_pre
Branch point for: branch-genmake2
Changes since 1.8: +2 -2 lines
fix omission from previous checkin

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

  ViewVC Help
Powered by ViewVC 1.1.22