/[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.70 - (show annotations) (download)
Thu Jul 28 21:12:15 2005 UTC (18 years, 8 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint57o_post, checkpoint57n_post, checkpoint57p_post
Changes since 1.69: +12 -1 lines
add "-odir STRING" option to replace 'hostname' in output dir name.

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

  ViewVC Help
Powered by ViewVC 1.1.22