/[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.57 - (show annotations) (download)
Thu Dec 9 16:52:08 2004 UTC (19 years, 4 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint57a_post, checkpoint57a_pre, checkpoint57
Changes since 1.56: +5 -9 lines
try to fix tmp_cmpnum.c (return 22 only when all numbers are zero)

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

  ViewVC Help
Powered by ViewVC 1.1.22