/[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.49 - (show annotations) (download)
Tue Nov 23 21:25:24 2004 UTC (19 years, 4 months ago) by edhill
Branch: MAIN
Changes since 1.48: +75 -11 lines
 o add PTRACERS (PTR0[1-5]) to testreport output

1 #! /usr/bin/env bash
2 #
3 # $Header: /u/gcmpack/MITgcm/verification/testreport,v 1.48 2004/11/17 21:38:35 jmc Exp $
4 # $Name: $
5 #
6
7 usage()
8 {
9 echo
10 echo "Usage: $0 [OPTIONS]"
11 echo
12 echo "where possible OPTIONS are:"
13 echo " (-help|-h) print usage"
14 echo " (-mpi) use MPI input files"
15 echo " (-ieee|-noieee) if possible, use IEEE compiler flags"
16 echo " (DEF=\"-ieee\")"
17 echo " (-optfile=|-of=)STRING list of optfiles to use"
18 echo " (-a|-addr) STRING list of email recipients"
19 echo " (DEF=\"edhill@mitgcm.org\")"
20 echo " (-t|-tdir) STRING list of test dirs to use"
21 echo " (DEF=\"\" which builds all)"
22 echo " (-b|-bash) STRING preferred location of a \"bash\" or"
23 echo " Bourne-compatible \"sh\" shell"
24 echo " (DEF=\"\" for \"bash\")"
25 echo " (-adm|-ad) perform an adjoint run"
26 echo " (-command) STRING command to run"
27 echo " (DEF=\"make output.txt\")"
28 echo " (-m|-make) STRING command to use for \"make\""
29 echo " (DEF=\"make\")"
30 echo " (-j) JOBS use \"make -j JOBS\" for parallel builds"
31 echo " (-clean) *ONLY* run \"make CLEAN\""
32 echo " (-quick|-q) same as \"-nogenmake -noclean -nodepend\""
33 echo " (-nogenmake|-ng) skip the genmake stage"
34 echo " (-noclean|-nc) skip the \"make clean\" stage"
35 echo " (-nodepend|-nd) skip the \"make depend\" stage"
36 echo " (-deldir|-dd) on success, delete the output directory"
37 echo
38 echo "and where STRING follows a whitespace-delimited format"
39 echo "such as:"
40 echo " -t 'exp0 exp2 exp3' "
41 echo " -addr='abc@123.com testing@home.org'"
42 echo
43 exit 1
44 }
45
46 # build the mpack utility
47 build_mpack()
48 {
49 printf "building the mpack utility... "
50 if test ! -x "$MPACKDIR/mpack" ; then
51 if test ! -d $MPACKDIR ; then
52 echo
53 echo "Error: can't find \"$MPACKDIR\""
54 echo " are you sure this program is being run in the correct "
55 echo " (that is, \"MITGCM_ROOT\verification\") directory?"
56 echo
57 HAVE_MPACK=f
58 fi
59 printf "building mpack... "
60 if test "x$CC" = x ; then
61 export CC=cc
62 fi
63 ( cd $MPACKDIR && ./configure && $MAKE ) > tr_build_mpack.out 2>&1
64 RETVAL=$?
65 if test "x$RETVAL" != x0 ; then
66 echo
67 echo "Error building the mpack tools at: $MPACK_DIR"
68 echo
69 HAVE_MPACK=f
70 else
71 rm -f tr_build_mpack.out
72 HAVE_MPACK=t
73 fi
74 else
75 HAVE_MPACK=t
76 fi
77 echo "OK"
78 }
79
80 testoutput_for_prop()
81 {
82 # testoutput_for_prop dir s1 label subdir extension
83 #
84 # compares files in $dir/$subdir/output.txt and $dir/results/output.txt
85 # using search strings s1 and text label
86
87 if [ $debug -gt 0 ]; then
88 echo testoutput_for_prop: grep "$2" $1/$4/output.txt 1>&2
89 fi
90 if [ -r $1/$4/output.txt ]; then
91 grep "$2" $1/$4/output.txt | sed 's/.*=//' | cat -n > tmp1.txt
92 lncnt=`wc -l tmp1.txt | awk '{print $1}' `
93 if [ $lncnt -lt 3 ]; then
94 if [ $verbose -gt 0 ]; then
95 echo Not enough lines of output when searching for "$2" 1>&2
96 fi
97 return 99
98 fi
99 else
100 echo testoutput_for_prop: output.txt from model run was not readable 1>&2
101 return 99
102 fi
103 if [ $debug -gt 0 ]; then
104 echo testoutput_for_prop: grep "$2" $1/results/output.txt$5 1>&2
105 fi
106 grep "$2" $1/results/output.txt$5 | sed 's/.*=//' | cat -n > tmp2.txt
107 lncnt=`wc -l tmp2.txt | awk '{print $1}' `
108 if [ $lncnt -lt 3 ]; then
109 if [ $verbose -gt 0 ]; then
110 echo Not enough lines of output when searching for "$2" 1>&2
111 fi
112 return 99
113 fi
114 if [ $debug -gt 0 ]; then
115 echo testoutput_for_prop: join tmp1.txt tmp2.txt 1>&2
116 fi
117 join tmp1.txt tmp2.txt | awk '{print $1 " " $2 " " $3}' > tmp3.txt
118 if [ $debug -gt 0 ]; then
119 echo testoutput_for_prop: compare_lines 1>&2
120 fi
121 if [ $verbose -gt 1 ]; then
122 cat tmp3.txt 1>&2
123 fi
124 echo "-1" >> tmp3.txt
125 # On the SGI O3K (*not* the O2K), "cat -n" inserts a ":" after the line number
126 cat tmp3.txt | sed -e 's|:||g' > tmp4.txt
127 digits_of_similarity=`./tmp_cmpnum < tmp4.txt`
128 if [ $digits_of_similarity -eq 99 ]; then
129 if [ $verbose -gt 0 ]; then
130 echo testoutput_for_prop: No comparison was available for \"$2\" 1>&2
131 fi
132 digits_of_similarity=99
133 else
134 if [ $verbose -gt 0 ]; then
135 echo There were $digits_of_similarity decimal places of similarity for \"$2\" 1>&2
136 fi
137 fi
138 rm -f tmp1.txt tmp2.txt tmp3.txt tmp4.txt
139
140 return $digits_of_similarity
141 }
142
143 dashnum()
144 {
145 # dashnum n1 n2 n3 ...
146 #
147 # print numbers using %3i format or "--" if number = 99
148
149 for num in $@ ; do
150 if [ $num = 99 ]; then
151 printf ' --'
152 else
153 printf '%3i' $num
154 fi
155 done
156 }
157
158 testoutput_ad()
159 {
160 grep $3 $1/results_ad/output.txt_adm | awk '{print NR " " $5}' > t05.txt
161 grep $3 $1/$2/output.txt_adm | awk '{print NR " " $5}' > t15.txt
162 grep $3 $1/results_ad/output.txt_adm | awk '{print NR " " $6}' > t06.txt
163 grep $3 $1/$2/output.txt_adm | awk '{print NR " " $6}' > t16.txt
164 join t05.txt t15.txt > t5.txt
165 join t06.txt t16.txt > t6.txt
166 echo "-1" >> t5.txt
167 echo "-1" >> t6.txt
168 digits_5=`./tmp_cmpnum < t5.txt`
169 digits_6=`./tmp_cmpnum < t6.txt`
170 dashnum $digits_5 $digits_6
171 rm -f t[01][56].txt t[56].txt
172 }
173
174 check_for_add_mon_output()
175 {
176 # Check for additional types of monitor output
177 if test "x$1" = x ; then
178 return
179 fi
180
181 ptr_add="trcstat_ptracerXX_min trcstat_ptracerXX_max"
182 ptr_add="$ptr_add trcstat_ptracerXX_mean trcstat_ptracerXX_sd"
183 for ii in 1 2 3 4 5 ; do
184 for jj in $ptr_add ; do
185 name=`eval "echo $jj | sed -e 's|XX|0"$ii"|g'"`
186 tst=`grep $name $1 | wc -l | awk '{print $1}'`
187 if test ! "x$tst" = x0 ; then
188 eval "HAVE_PTR0"$ii"=t"
189 fi
190 done
191 # eval 'echo "HAVE_PTR0'$ii' = $HAVE_PTR0'$ii'"'
192 done
193 }
194
195 testoutput()
196 {
197 # testoutput directory subdir extension
198 #
199 # test output in "directory"
200 if test "x$ADM" = x ; then
201 if [ $debug -gt 0 ]; then
202 echo testoutput: testoutput_for_prop $1 cg2d_init_res 1>&2
203 fi
204 testoutput_for_prop $1 "cg2d_init_res" "cg2d init. residual" $2 $3; cg2dres=$?
205 if [ $debug -gt 0 ]; then
206 echo testoutput: cg2dres=$cg2dres 1>&2
207 fi
208 testoutput_for_prop $1 "dynstat_theta_min" "theta minimum" $2 $3; tmin=$?
209 testoutput_for_prop $1 "dynstat_theta_max" "theta maximum" $2 $3; tmax=$?
210 testoutput_for_prop $1 "dynstat_theta_mean" "theta mean" $2 $3; tmean=$?
211 testoutput_for_prop $1 "dynstat_theta_sd" "theta s.d." $2 $3; tsd=$?
212 testoutput_for_prop $1 "dynstat_salt_min" "salt minimum" $2 $3; smin=$?
213 testoutput_for_prop $1 "dynstat_salt_max" "salt maximum" $2 $3; smax=$?
214 testoutput_for_prop $1 "dynstat_salt_mean" "salt mean" $2 $3; smean=$?
215 testoutput_for_prop $1 "dynstat_salt_sd" "salt s.d." $2 $3; ssd=$?
216 testoutput_for_prop $1 "dynstat_uvel_min" "U minimum" $2 $3; umin=$?
217 testoutput_for_prop $1 "dynstat_uvel_max" "U maximum" $2 $3; umax=$?
218 testoutput_for_prop $1 "dynstat_uvel_mean" "U mean" $2 $3; umean=$?
219 testoutput_for_prop $1 "dynstat_uvel_sd" "U s.d." $2 $3; usd=$?
220 testoutput_for_prop $1 "dynstat_vvel_min" "V minimum" $2 $3; vmin=$?
221 testoutput_for_prop $1 "dynstat_vvel_max" "V maximum" $2 $3; vmax=$?
222 testoutput_for_prop $1 "dynstat_vvel_mean" "V mean" $2 $3; vmean=$?
223 testoutput_for_prop $1 "dynstat_vvel_sd" "V s.d." $2 $3; vsd=$?
224
225 for ii in 1 2 3 4 5 ; do
226 testoutput_for_prop $1 "trcstat_ptracer0"$ii"_min" "p0"$ii"_min" $2 $3
227 RETVAL=$? ; eval `echo "p0"$ii"_min="$RETVAL`
228 testoutput_for_prop $1 "trcstat_ptracer0"$ii"_max" "p0"$ii"_max" $2 $3
229 RETVAL=$? ; eval `echo "p0"$ii"_max="$RETVAL`
230 testoutput_for_prop $1 "trcstat_ptracer0"$ii"_mean" "p0"$ii"_mean" $2 $3
231 RETVAL=$? ; eval `echo "p0"$ii"_mean="$RETVAL`
232 testoutput_for_prop $1 "trcstat_ptracer0"$ii"_sd" "p0"$ii"_sd" $2 $3
233 RETVAL=$? ; eval `echo "p0"$ii"_sd="$RETVAL`
234 done
235
236 allargs="$cg2dres $tmin $tmax $tmean $tsd $smin $smax $smean $ssd"
237 allargs="$allargs $umin $umax $umean $usd $vmin $vmax $vmean $vsd"
238 allargs="$allargs $p01_min $p01_max $p01_mean $p01_sd"
239 allargs="$allargs $p02_min $p02_max $p02_mean $p02_sd"
240 allargs="$allargs $p03_min $p03_max $p03_mean $p03_sd"
241 allargs="$allargs $p04_min $p04_max $p04_mean $p04_sd"
242 allargs="$allargs $p05_min $p05_max $p05_mean $p05_sd"
243
244 eval "dashnum $allargs"
245
246 else
247 testoutput_ad $1 $2 "precision_grdchk_result"
248 fi
249 }
250
251 genmakemodel()
252 {
253 # genmakemodel directory
254 if test "x$NOGENMAKE" = xt ; then
255 echo "genmake skipped!"
256 else
257 if test "x$BASH" = x ; then
258 GENMAKE2="../../../tools/genmake2"
259 else
260 GENMAKE2="$BASH ../../../tools/genmake2 -bash $BASH"
261 fi
262 (
263 cd $1;
264 command="$GENMAKE2 -ds -m $MAKE"
265 if test "x$ADM" = x ; then
266 command="$command --mods=../code"
267 else
268 command="$command --mods=../code_ad"
269 command="$command -adof=../../../tools/adjoint_options/adjoint_staf"
270 fi
271 if test "x$OPTFILE" != xNONE ; then
272 command="$command --optfile=$OPTFILE"
273 fi
274 if test "x$IEEE" != x ; then
275 command="$command -ieee"
276 fi
277 printf 'genmake ... ' 1>&2
278 $command > make.log 2>&1
279 RETVAL=$?
280 # Reduce the size of the testing emails!
281 head -100 Makefile > $CDIR/Makefile_head
282 if test "x$RETVAL" != x0 ; then
283 tail make.log
284 echo "genmakemodel: genmake failed" 1>&2
285 cp genmake_* make.log $CDIR
286 return 1
287 else
288 echo "successful" 1>&2
289 fi
290 )
291 fi
292 }
293
294 makeclean()
295 {
296 # makeclean directory
297 if test "x$NOCLEAN" = xt ; then
298 echo "make CLEAN skipped!"
299 else
300 (
301 cd $1;
302 if test -e output.txt ; then
303 rm -f output.txt
304 fi
305 printf 'make CLEAN ... ' 2>&1
306 if test -r Makefile ; then
307 $MAKE CLEAN >> make.log 2>&1
308 RETVAL=$?
309 if test "x$RETVAL" != x0 ; then
310 tail make.log
311 echo "makeclean: \"make CLEAN\" failed" 1>&2
312 cp make.log $CDIR"/make.log"
313 return 1
314 fi
315 fi
316 echo successful 1>&2
317 exit 0
318 )
319 fi
320 }
321
322 makedependmodel()
323 {
324 # makedependmodel directory
325 if test "x$NODEPEND" = xt ; then
326 echo "make depend skipped!"
327 else
328 (
329 cd $1;
330 printf 'make depend ... ' 1>&2
331 $MAKE depend >> make.log 2>&1
332 RETVAL=$?
333 if test "x$RETVAL" != x0 ; then
334 tail make.log
335 echo "makedependmodel: make depend failed" 1>&2
336 cp make.log $CDIR"/make.log"
337 return 1
338 else
339 echo successful 1>&2
340 fi
341 )
342 fi
343 }
344
345 makemodel()
346 {
347 # makemodel directory
348 (
349 cd $1;
350 if test -r Makefile ; then
351 printf 'make ... ' 1>&2
352 if test "x$ADM" = x ; then
353 if test "x$JOBS" = x ; then
354 $MAKE >> make.log 2>&1
355 else
356 $MAKE -j $JOBS >> make.log 2>&1
357 fi
358 else
359 $MAKE adall >> make.log 2>&1
360 fi
361 RETVAL=$?
362 if test "x$RETVAL" != x0 ; then
363 tail make.log
364 echo failed 1>&2
365 cp make.log $CDIR"/make.log"
366 return 1
367 else
368 echo successful 1>&2
369 fi
370 fi
371 )
372 }
373
374 symlink_mpifiles()
375 {
376 # Put special links so that MPI specific files are used
377 # This MUST be invoked between makeclean and makelinks because
378 # the Makefile will link to non-mpi files by default
379
380 dir=$1
381 code_dir=$2
382 BUILD_DIR=$dir/$3
383 CODE_DIR=$dir/$code_dir
384
385 # These are files that should replace their counter-part when using -mpi
386 MPI_FILES=`(cd $CODE_DIR; find . -name "*_mpi")`
387
388 # Is this an MPI run?
389 if test "x$MPI" = xt ; then
390 # YES: We symbolically link these files to the build
391 # dir so long as there is no real file in place
392 for ii in $MPI_FILES ; do
393 i=`echo $ii | sed 's:^\./::'`
394 name=`echo $i | sed 's:_mpi::' `
395 cmp $CODE_DIR/$i $BUILD_DIR/$name > /dev/null 2>&1
396 RETVAL=$?
397 if test "x$RETVAL" != x0 ; then
398 if ! test -f $BUILD_DIR/$i ; then
399 #echo Linking $name to $i
400 (cd $BUILD_DIR; ln -sf ../$code_dir/$i $name)
401 fi
402 fi
403 done
404 else
405 # NO: We undo any _mpi symbolically linked files
406 for ii in $MPI_FILES ; do
407 i=`echo $ii | sed 's:^\./::'`
408 name=`echo $i | sed 's:_mpi::' `
409 if test -L $BUILD_DIR/$name ; then
410 cmp $BUILD_DIR/$name "../$code_dir/$name"_mpi > /dev/null 2>&1
411 RETVAL=$?
412 if test "x$RETVAL" = x0 ; then
413 #echo Un-linking $name from $linktarg
414 rm -f $BUILD_DIR/$name
415 fi
416 fi
417 done
418 fi
419
420 }
421
422 linkdata()
423 {
424 # linkdata flag
425 #
426 # symbolically link data files to run directory
427 if test "x$1" = x1 ; then
428 (
429 cd $2
430 if test "x$ADM" = x ; then
431 files=`( cd ../input ; ls -1 | grep -v CVS )`
432 for i in $files ; do
433 if test ! -d "../input/"$i ; then
434 ln -sf "../input/"$i $i
435 fi
436 done
437 else
438 files=`( cd ../input ; ls -1 *.bin | grep -v CVS )`
439 for i in $files ; do
440 if test ! -d "../input/"$i ; then
441 ln -sf "../input/"$i $i
442 fi
443 done
444 files=`( cd ../input_ad ; ls -1 | grep -v CVS )`
445 for i in $files ; do
446 if test ! -d "../input_ad/"$i ; then
447 ln -sf "../input_ad/"$i $i
448 fi
449 done
450 fi
451 )
452 fi
453 }
454
455 runmodel()
456 {
457 # runmodel directory
458 #
459 # runs "$COMMAND in "directory"
460 # (where "$COMMAND" is relative to "directory")
461 (
462 cd $1
463 printf 'runmodel ... ' 1>&2
464 # make output.txt
465 echo
466 rm -f run.log
467 # echo "COMMAND='$COMMAND'"
468 # echo "pwd='"`pwd`"'"
469 ( eval $COMMAND ) > run.log 2>&1
470 RETVAL=$?
471 if test "x$RETVAL" = x0 ; then
472 tail run.log
473 echo successful 1>&2
474 # === Reduce the size of the testing emails!
475 # if test "x$ADM" = x ; then
476 # cp output.txt $CDIR"/output.txt"
477 # else
478 # cp output.txt_adm $CDIR"/output.txt_adm"
479 # fi
480 if test -s STDERR.0000 ; then cp STDERR.0000 $CDIR"/STDERR.0000" ; fi
481 return 0
482 else
483 tail run.log
484 echo failed 1>&2
485 cp run.log $CDIR"/run.log"
486 if test -s STDERR.0000 ; then cp STDERR.0000 $CDIR"/STDERR.0000" ; fi
487 return 1
488 fi
489 )
490 }
491
492 createcodelet()
493 {
494 # create codelet for comparing model output
495
496 printf "creating the comparison code... "
497 cat > tmp_cmpnum.c <<EOF
498 #include <stdio.h>
499 #include <math.h>
500 int main( int argc, char** argv ) {
501 int linnum,best,lncnt;
502 double a,b,diff;
503 best = -16;
504 lncnt = 0;
505 while( 1 & (lncnt+=1) < 999 ) {
506 scanf("%d", &linnum);
507 if (linnum == -1) break;
508 scanf("%lf", &a); scanf("%lf", &b);
509 diff = 0.5*(fabs(a)+fabs(b));
510 if (diff > 1.e-12) {
511 diff=fabs(a-b)/diff;
512 if (diff > 0.0) {
513 linnum = (int)log10(diff);
514 best = (best > linnum) ? best : linnum;
515 }
516 else {
517 if (best == -16 && diff != 0) best = -22;
518 }
519 }
520 }
521 if (lncnt == 999) best=-29;
522 printf("%d\n", -best);
523 return 0;
524 }
525 EOF
526 cc -o tmp_cmpnum tmp_cmpnum.c -lm
527
528 if [ -x ./tmp_cmpnum ]; then
529 echo "OK"
530 return 0
531 else
532 echo
533 echo "ERROR: failed to compile comparison code"
534 exit 1
535 fi
536 }
537
538 formatresults()
539 {
540 # formatresults expt genmake depend make run results*
541
542 nm=$1
543 printf '%s %s %s %s' $2 $3 $4 $5
544 shift; shift; shift; shift; shift;
545 printf '%3s' $@
546
547 if [ $1 = '--' ]; then
548 printf ' N/O '
549 else
550 if [ $1 -gt 12 ]; then
551 printf ' pass'
552 else
553 printf ' FAIL'
554 fi
555 fi
556 printf ' %s' $nm
557 printf '\n'
558
559 }
560
561 show_help()
562 {
563 cat - << EOF
564 $0 [-help] [-quick] [-verbose] dir1 [dir2] [...]
565
566 -help|-h Show this help message
567 -quiet Reduce the amount of output
568 -verbose Produce copious amounts of output
569 -debug Produce even more output which will mean nothing to most
570 -force Do "make CLEAN" before compiling. This forces a complete rebuild.
571 -clean Do "make CLEAN" after compiling and testing.
572 -cleanup Aggresively removes all model output, executables and object files
573 and then exits. Use with care.
574
575 Normal usage:
576 $0 * Configure, compile, run and analyze in all experiment directories
577 EOF
578 }
579
580 scandirs()
581 {
582 if [ $# -eq 0 ]; then
583 for arg in * ; do
584 test -d $arg/input && echo $arg
585 done
586 else
587 echo $*
588 fi
589 }
590
591
592 ###############################################################################
593
594
595 # Default properties
596 debug=0
597 verbose=1
598 clean=0
599 expts=''
600 # ieee=1
601
602 IEEE=true
603 if test "x$MITGCM_IEEE" != x ; then
604 IEEE=$MITGCM_IEEE
605 fi
606
607
608 CLEANUP=f
609 QUICK=f
610 NOGENMAKE=f
611 NOCLEAN=f
612 NODEPEND=f
613
614 BASH=
615 OPTFILE=NONE
616 ADDRESSES=
617 TESTDIRS=
618 MPACKDIR="../tools/mpack-1.6"
619 HAVE_MPACK=
620 MPACK="$MPACKDIR/mpack"
621 COMMAND=
622 MAKE=make
623 JOBS=
624 MPI=f
625 DELDIR=
626
627 ADM=
628
629 # Additional monitor types
630 # HAVE_PTR01=
631 # HAVE_PTR02=
632 # HAVE_PTR03=
633 # HAVE_PTR04=
634 # HAVE_PTR05=
635
636 printf "parsing options... "
637
638 ac_prev=
639 for ac_option ; do
640
641 # If the previous option needs an argument, assign it.
642 if test -n "$ac_prev"; then
643 eval "$ac_prev=\$ac_option"
644 ac_prev=
645 continue
646 fi
647
648 ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
649
650 case $ac_option in
651
652 -help | --help | -h | --h)
653 usage ;;
654
655 -optfile | --optfile | -of | --of)
656 ac_prev=OPTFILE ;;
657 -optfile=* | --optfile=* | -of=* | --of=*)
658 OPTFILE=$ac_optarg ;;
659
660 -addr | --addr | -a | --a)
661 ac_prev=ADDRESSES ;;
662 -addr=* | --addr=*)
663 ADDRESSES=$ac_optarg ;;
664
665 -tdir | --tdir | -t | --t)
666 ac_prev=TESTDIRS ;;
667 -tdir=* | --tdir=*)
668 TESTDIRS=$ac_optarg ;;
669
670 -bash | --bash | -b | --b)
671 ac_prev=BASH ;;
672 -bash=* | --bash=*)
673 BASH=$ac_optarg ;;
674
675 -command | --command | -c | --c)
676 ac_prev=COMMAND ;;
677 -command=* | --command=*)
678 COMMAND=$ac_optarg ;;
679
680 -make | --make | -m | --m)
681 ac_prev=MAKE ;;
682 -make=* | --make=*)
683 MAKE=$ac_optarg ;;
684
685 -j) ac_prev=JOBS ;;
686 -j=*) JOBS=$ac_optarg ;;
687
688 -clean | --clean)
689 CLEANUP=t ;;
690
691 -quick | --quick | -q | --q)
692 QUICK=t ;;
693 -nogenmake | --nogenmake | -ng | --ng)
694 NOGENMAKE=t ;;
695 -noclean | --noclean | -nc | --nc)
696 NOCLEAN=t ;;
697 -nodepend | --nodepend | -nd | --nd)
698 NODEPEND=t ;;
699
700 -mpi) MPI=t ;;
701
702 -adm | -ad) ADM=t ;;
703
704 -ieee) IEEE=true ;;
705 -noieee) IEEE= ;;
706
707 -verbose) verbose=2 ;;
708 -debug) debug=1 ;;
709 -quiet) verbose=0 ;;
710
711 -deldir | -dd) DELDIR=t ;;
712
713 -*)
714 echo "Error: unrecognized option: "$ac_option
715 usage
716 ;;
717
718 *)
719 echo "Error: unrecognized argument: "$ac_option
720 usage
721 ;;
722
723 esac
724
725 done
726
727 if test "x$QUICK" = xt ; then
728 NOGENMAKE=t
729 NOCLEAN=t
730 NODEPEND=t
731 fi
732
733 if test "x$TESTDIRS" = x ; then
734 TESTDIRS=`scandirs`
735 fi
736
737 if test "x$OPTFILE" = xNONE -a "x$MITGCM_OF" != x ; then
738 OPTFILE=$MITGCM_OF
739 fi
740
741 if test "x$ADM" = xt -a "x$COMMAND" = x ; then
742 COMMAND="./mitgcmuv_ad > output.txt_adm 2>&1"
743 fi
744
745 if test "x$COMMAND" = x ; then
746 COMMAND="$MAKE output.txt"
747 fi
748
749 echo "OK"
750
751 # create the FORTRAN comparison code
752 createcodelet
753
754 # build the mpack utility
755 if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then
756 echo "skipping mpack build"
757 else
758 build_mpack
759 fi
760
761 # Create a uniquely named directory to store results
762 MACH=`hostname`
763 UNAMEA=`uname -a`
764 DATE=`date +%Y%m%d`
765 BASE="tr_"$MACH"_"$DATE"_"
766 DNUM=0
767 DRESULTS="$BASE$DNUM"
768 while test -e $DRESULTS ; do
769 DNUM=$(( $DNUM + 1 ))
770 DRESULTS="$BASE$DNUM"
771 done
772 mkdir $DRESULTS
773 RETVAL=$?
774 if test "x$RETVAL" != x0 ; then
775 echo "ERROR: Can't create results directory \"./$DRESULTS\""
776 exit 1
777 fi
778 SUMMARY="$DRESULTS/summary.txt"
779 printf "Start time: " >> $SUMMARY
780 start_date=`date`
781 echo $start_date > $SUMMARY
782
783 of_path=
784 if test "x$OPTFILE" != xNONE ; then
785 if test -r $OPTFILE ; then
786 # get the path
787 path=${OPTFILE%/*}
788 if test "x$path" = x ; then
789 of_path=`pwd`
790 else
791 of_path=`( cd $path > /dev/null 2>&1 ; pwd )`
792 fi
793 file=${OPTFILE##*/}
794 OPTFILE=$of_path/$file
795 cp $OPTFILE $DRESULTS
796 echo >> $SUMMARY
797 echo " OPTFILE=$OPTFILE" >> $SUMMARY
798 else
799 echo | tee $SUMMARY
800 echo "ERROR: can't read OPTFILE=\"$OPTFILE\"" | tee $SUMMARY
801 exit 1
802 fi
803 else
804 echo >> $SUMMARY
805 echo "No \"OPTFILE\" was explicitly specified by testreport," >> $SUMMARY
806 echo " so the genmake default will be used." >> $SUMMARY
807 fi
808 echo
809 echo >> $SUMMARY
810 if test "x$ADM" = x ; then
811 line_0=" ----T----- ----S----- ----U----- ----V-----"
812 line_1="G D M c m s m s m s m s"
813 line_2="E p a R g m m e . m m e . m m e . m m e ."
814 line_3="N n k u 2 i a a d i a a d i a a d i a a d"
815 line_4="2 d e n d n x n . n x n . n x n . n x n ."
816 for ii in 1 2 3 4 5 ; do
817 # tst=`eval 'echo $HAVE_PTR0'$ii`
818 # if test "x$tst" = xt ; then
819 line_0="$line_0 --PTR 0"$ii"--"
820 line_1="$line_1 m s"
821 line_2="$line_2 m m e ."
822 line_3="$line_3 i a a d"
823 line_4="$line_4 n x n ."
824 # fi
825 done
826 echo "$line_0" | tee -a $SUMMARY
827 echo "$line_1" | tee -a $SUMMARY
828 echo "$line_2" | tee -a $SUMMARY
829 echo "$line_3" | tee -a $SUMMARY
830 echo "$line_4" | tee -a $SUMMARY
831 echo " " | tee -a $SUMMARY
832 else
833 echo "ADJOINT=true" >> $SUMMARY
834 echo >> $SUMMARY
835 cat << EOF | tee -a $SUMMARY
836 G D M C G
837 E p a R o r
838 N n k u s a
839 2 d e n t d
840
841 EOF
842 fi
843
844 # ...and each test directory...
845 for dir in $TESTDIRS ; do
846
847 # Cleanup only!
848 if test "x$CLEANUP" = xt ; then
849 if test -r $dir/build/Makefile ; then
850 ( cd $dir/build ; make CLEAN )
851 fi
852 if test -r $dir/input/Makefile ; then
853 ( cd $dir/input ; make CLEAN )
854 fi
855 continue
856 fi
857
858 # Verify that the testdir exists and contains previous
859 # results in the correct location--or skip this directory!
860 fout=
861 if test "x$ADM" = x ; then
862 fout=$dir"/results/output.txt"
863 else
864 fout=$dir"/results_ad/output.txt_adm"
865 fi
866 if test ! -r $fout ; then
867 echo "can't read \"$fout\" -- skipping $dir"
868 continue
869 fi
870
871 # Check for additional types of monitor output
872 check_for_add_mon_output $fout
873
874 builddir="input"
875 rundir="input"
876 use_seperate_build=0
877 if test -d $dir/build -a -r $dir/build ; then
878 builddir="build"
879 rundir="build"
880 use_seperate_build=1
881 linkdata $use_seperate_build $dir/$rundir
882 fi
883
884 # Check whether there are "extra runs" for this testdir
885 extra_runs=
886 if test "x$ADM" = x -a "x$use_seperate_build" = x1 ; then
887 ex_run_dirs=`( cd $dir ; echo input.* )`
888 echo "ex_run_dirs='$ex_run_dirs'"
889 for exd in $ex_run_dirs ; do
890 name=`echo $exd | sed -e 's/input.//g'`
891 outf="$dir/results/output.txt.$name"
892 if test -f $outf -a -r $outf ; then
893 extra_runs="$extra_runs $name"
894 fi
895 done
896 fi
897
898 if test "x$ADM" = x ; then
899 code_dir=code
900 CODE_DIR=$dir/code
901 else
902 code_dir=code_ad
903 CODE_DIR=$dir/code_ad
904 fi
905 BUILD_DIR=$dir/$builddir
906
907 if test ! -r $CODE_DIR"/SIZE.h_mpi" -a "x$MPI" = "xt" ; then
908 echo "can't find \"$CODE_DIR/SIZE.h_mpi\" -- skipping $dir"
909 continue
910 fi
911
912 echo "-------------------------------------------------------------------------------"
913 echo
914 echo "Experiment: $dir"
915 echo
916 unset genmake makedepend make run
917 results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --'
918
919 # Create an output dir for each OPTFILE/tdir combination
920 rel_CDIR=$DRESULTS"/"$dir
921 mkdir $rel_CDIR
922 CDIR=`pwd`"/$rel_CDIR"
923
924 if test "x$CLEANUP" = xt ; then
925 makeclean $dir/$builddir
926 else
927 genmakemodel $dir/$builddir && genmake=Y \
928 && makeclean $dir/$builddir \
929 && symlink_mpifiles $dir $code_dir $builddir \
930 && makedependmodel $dir/$builddir && makedepend=Y \
931 && makemodel $dir/$builddir && make=Y \
932 && linkdata $use_seperate_build $dir/$rundir \
933 && runmodel $dir/$rundir && run=Y \
934 && results=`testoutput $dir $rundir`
935 fi
936
937 echo
938 if test "x$ADM" = x ; then
939 fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results`
940 echo
941 echo "$fres" >> $SUMMARY
942 echo "fresults='$fres'" > $CDIR"/summary.txt"
943 echo "MACH='$MACH'" >> $CDIR"/summary.txt"
944 echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"
945 echo "DATE='$DATE'" >> $CDIR"/summary.txt"
946 echo "tdir='$dir'" >> $CDIR"/summary.txt"
947
948 OLD_COMMAND=$COMMAND
949 COMMAND="./mitgcmuv > output.txt"
950 for ex in $extra_runs ; do
951 test -e "$dir/tr_run.$ex" && rm -rf "$dir/tr_run.$ex"
952 mkdir "$dir/tr_run.$ex"
953 links=`( cd "$dir/input" > /dev/null 2>&1 ; ls -1 | grep -v CVS )`
954 (
955 cd "$dir/tr_run.$ex"
956 for i in $links; do
957 ln -s ../input/$i $i
958 done
959 )
960 links=`( cd "$dir/input.$ex" > /dev/null 2>&1 ; ls -1 | grep -v CVS )`
961 (
962 cd "$dir/tr_run.$ex"
963 for i in $links; do
964 test -e $i && rm -f $i
965 ln -s ../input.$ex/$i $i
966 done
967 ln -s ../$builddir/mitgcmuv mitgcmuv
968 )
969 runmodel $dir/tr_run.$ex && run=Y \
970 && results=`testoutput $dir tr_run.$ex "."$ex`
971 fres=`printf '%s %s %s %s' ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N}`
972 fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results`
973 fres="$fres.$ex"
974 echo
975 echo "$fres" >> $SUMMARY
976 echo "fresults='$fres'" > $CDIR"/summary.txt"
977 echo "MACH='$MACH'" >> $CDIR"/summary.txt"
978 echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"
979 echo "DATE='$DATE'" >> $CDIR"/summary.txt"
980 echo "tdir='$dir'" >> $CDIR"/summary.txt"
981 done
982 COMMAND=$OLD_COMMAND
983 else
984 fres=`printf '%s %s %s %s' ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N}`
985 fres=$fres"$results $dir"
986 echo
987 echo "$fres" >> $SUMMARY
988 echo "fresults='$fres'" > $CDIR"/summary.txt"
989 echo "MACH='$MACH'" >> $CDIR"/summary.txt"
990 echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"
991 echo "DATE='$DATE'" >> $CDIR"/summary.txt"
992 echo "tdir='$dir'" >> $CDIR"/summary.txt"
993 fi
994
995 echo "-------------------------------------------------------------------------------"
996
997 done
998
999 printf "Start time: " >> $SUMMARY
1000 echo $start_date >> $SUMMARY
1001 printf "End time: " >> $SUMMARY
1002 date >> $SUMMARY
1003
1004 # If addresses were supplied and mpack built successfully, then try
1005 # to send email using mpack.
1006 if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then
1007 echo "No results email was sent."
1008 else
1009 if test "x$HAVE_MPACK" = xt ; then
1010 tar -cf $DRESULTS".tar" $DRESULTS > /dev/null 2>&1 \
1011 && gzip $DRESULTS".tar" \
1012 && $MPACK -s MITgcm-test -m 3555000 $DRESULTS".tar.gz" $ADDRESSES
1013 RETVAL=$?
1014 if test "x$RETVAL" != x0 ; then
1015 echo
1016 echo "Warning: The tar, gzip, & mpack step failed. Please send email"
1017 echo " to <MITgcm-support@mitgcm.org> for help. You may copy the "
1018 echo " summary of results from the directory \"$DRESULTS\"."
1019 echo
1020 else
1021 echo
1022 echo "An email containing results was sent to the following addresses:"
1023 echo " \"$ADDRESSES\""
1024 echo
1025 fi
1026 test -f $DRESULTS".tar" && rm -f $DRESULTS".tar"
1027 test -f $DRESULTS".tar.gz" && rm -f $DRESULTS".tar.gz"
1028 fi
1029 fi
1030
1031 # rm -f tmp_cmpnum.f a.out
1032 rm -f tmp_cmpnum.c tmp_cmpnum
1033
1034 if test "x$CLEANUP" != xt ; then
1035 cat $SUMMARY
1036 if test -e tr_out.txt ; then
1037 mv tr_out.txt tr_out.txt.old
1038 fi
1039 cat $SUMMARY > tr_out.txt
1040 fi
1041
1042 if test "x$DELDIR" = xt ; then
1043 rm -rf $DRESULTS
1044 fi

  ViewVC Help
Powered by ViewVC 1.1.22