/[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.47 - (show annotations) (download)
Tue Aug 3 02:48:57 2004 UTC (19 years, 7 months ago) by edhill
Branch: MAIN
CVS Tags: checkpoint55c_post, checkpoint54e_post, checkpoint55d_pre, checkpoint55j_post, checkpoint55h_post, checkpoint55b_post, checkpoint55, checkpoint54f_post, checkpoint55g_post, checkpoint55f_post, checkpoint55i_post, checkpoint56, checkpoint55e_post, checkpoint55a_post, checkpoint55d_post
Changes since 1.46: +2 -2 lines
 o add partial ("head -100") Makefile information
   - keeps the email size manageable
   - tells us the optfile name and much of the config info

1 #! /usr/bin/env bash
2 #
3 # $Header: /u/gcmpack/MITgcm/verification/testreport,v 1.46 2004/07/18 21:27:42 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 testoutput()
175 {
176 # testoutput directory subdir extension
177 #
178 # test output in "directory"
179 if test "x$ADM" = x ; then
180 if [ $debug -gt 0 ]; then
181 echo testoutput: testoutput_for_prop $1 cg2d_init_res 1>&2
182 fi
183 testoutput_for_prop $1 "cg2d_init_res" "cg2d init. residual" $2 $3; cg2dres=$?
184 if [ $debug -gt 0 ]; then
185 echo testoutput: cg2dres=$cg2dres 1>&2
186 fi
187 testoutput_for_prop $1 "dynstat_theta_min" "theta minimum" $2 $3; tmin=$?
188 testoutput_for_prop $1 "dynstat_theta_max" "theta maximum" $2 $3; tmax=$?
189 testoutput_for_prop $1 "dynstat_theta_mean" "theta mean" $2 $3; tmean=$?
190 testoutput_for_prop $1 "dynstat_theta_sd" "theta s.d." $2 $3; tsd=$?
191 testoutput_for_prop $1 "dynstat_salt_min" "salt minimum" $2 $3; smin=$?
192 testoutput_for_prop $1 "dynstat_salt_max" "salt maximum" $2 $3; smax=$?
193 testoutput_for_prop $1 "dynstat_salt_mean" "salt mean" $2 $3; smean=$?
194 testoutput_for_prop $1 "dynstat_salt_sd" "salt s.d." $2 $3; ssd=$?
195 testoutput_for_prop $1 "dynstat_uvel_min" "U minimum" $2 $3; umin=$?
196 testoutput_for_prop $1 "dynstat_uvel_max" "U maximum" $2 $3; umax=$?
197 testoutput_for_prop $1 "dynstat_uvel_mean" "U mean" $2 $3; umean=$?
198 testoutput_for_prop $1 "dynstat_uvel_sd" "U s.d." $2 $3; usd=$?
199 testoutput_for_prop $1 "dynstat_vvel_min" "V minimum" $2 $3; vmin=$?
200 testoutput_for_prop $1 "dynstat_vvel_max" "V maximum" $2 $3; vmax=$?
201 testoutput_for_prop $1 "dynstat_vvel_mean" "V mean" $2 $3; vmean=$?
202 testoutput_for_prop $1 "dynstat_vvel_sd" "V s.d." $2 $3; vsd=$?
203 dashnum $cg2dres $tmin $tmax $tmean $tsd $smin $smax $smean $ssd \
204 $umin $umax $umean $usd $vmin $vmax $vmean $vsd
205 else
206 testoutput_ad $1 $2 "precision_grdchk_result"
207 fi
208 }
209
210 genmakemodel()
211 {
212 # genmakemodel directory
213 if test "x$NOGENMAKE" = xt ; then
214 echo "genmake skipped!"
215 else
216 if test "x$BASH" = x ; then
217 GENMAKE2="../../../tools/genmake2"
218 else
219 GENMAKE2="$BASH ../../../tools/genmake2 -bash $BASH"
220 fi
221 (
222 cd $1;
223 command="$GENMAKE2 -ds -m $MAKE"
224 if test "x$ADM" = x ; then
225 command="$command --mods=../code"
226 else
227 command="$command --mods=../code_ad"
228 command="$command -adof=../../../tools/adjoint_options/adjoint_staf"
229 fi
230 if test "x$OPTFILE" != xNONE ; then
231 command="$command --optfile=$OPTFILE"
232 fi
233 if test "x$IEEE" != x ; then
234 command="$command -ieee"
235 fi
236 printf 'genmake ... ' 1>&2
237 $command > make.log 2>&1
238 RETVAL=$?
239 # Reduce the size of the testing emails!
240 head -100 Makefile > $CDIR/Makefile_head
241 if test "x$RETVAL" != x0 ; then
242 tail make.log
243 echo "genmakemodel: genmake failed" 1>&2
244 cp genmake_* make.log $CDIR
245 return 1
246 else
247 echo "successful" 1>&2
248 fi
249 )
250 fi
251 }
252
253 makeclean()
254 {
255 # makeclean directory
256 if test "x$NOCLEAN" = xt ; then
257 echo "make CLEAN skipped!"
258 else
259 (
260 cd $1;
261 if test -e output.txt ; then
262 rm -f output.txt
263 fi
264 printf 'make CLEAN ... ' 2>&1
265 if test -r Makefile ; then
266 $MAKE CLEAN >> make.log 2>&1
267 RETVAL=$?
268 if test "x$RETVAL" != x0 ; then
269 tail make.log
270 echo "makeclean: \"make CLEAN\" failed" 1>&2
271 cp make.log $CDIR"/make.log"
272 return 1
273 fi
274 fi
275 echo successful 1>&2
276 exit 0
277 )
278 fi
279 }
280
281 makedependmodel()
282 {
283 # makedependmodel directory
284 if test "x$NODEPEND" = xt ; then
285 echo "make depend skipped!"
286 else
287 (
288 cd $1;
289 printf 'make depend ... ' 1>&2
290 $MAKE depend >> make.log 2>&1
291 RETVAL=$?
292 if test "x$RETVAL" != x0 ; then
293 tail make.log
294 echo "makedependmodel: make depend failed" 1>&2
295 cp make.log $CDIR"/make.log"
296 return 1
297 else
298 echo successful 1>&2
299 fi
300 )
301 fi
302 }
303
304 makemodel()
305 {
306 # makemodel directory
307 (
308 cd $1;
309 if test -r Makefile ; then
310 printf 'make ... ' 1>&2
311 if test "x$ADM" = x ; then
312 if test "x$JOBS" = x ; then
313 $MAKE >> make.log 2>&1
314 else
315 $MAKE -j $JOBS >> make.log 2>&1
316 fi
317 else
318 $MAKE adall >> make.log 2>&1
319 fi
320 RETVAL=$?
321 if test "x$RETVAL" != x0 ; then
322 tail make.log
323 echo failed 1>&2
324 cp make.log $CDIR"/make.log"
325 return 1
326 else
327 echo successful 1>&2
328 fi
329 fi
330 )
331 }
332
333 symlink_mpifiles()
334 {
335 # Put special links so that MPI specific files are used
336 # This MUST be invoked between makeclean and makelinks because
337 # the Makefile will link to non-mpi files by default
338
339 dir=$1
340 code_dir=$2
341 BUILD_DIR=$dir/$3
342 CODE_DIR=$dir/$code_dir
343
344 # These are files that should replace their counter-part when using -mpi
345 MPI_FILES=`(cd $CODE_DIR; find . -name "*_mpi")`
346
347 # Is this an MPI run?
348 if test "x$MPI" = xt ; then
349 # YES: We symbolically link these files to the build
350 # dir so long as there is no real file in place
351 for ii in $MPI_FILES ; do
352 i=`echo $ii | sed 's:^\./::'`
353 name=`echo $i | sed 's:_mpi::' `
354 cmp $CODE_DIR/$i $BUILD_DIR/$name > /dev/null 2>&1
355 RETVAL=$?
356 if test "x$RETVAL" != x0 ; then
357 if ! test -f $BUILD_DIR/$i ; then
358 #echo Linking $name to $i
359 (cd $BUILD_DIR; ln -sf ../$code_dir/$i $name)
360 fi
361 fi
362 done
363 else
364 # NO: We undo any _mpi symbolically linked files
365 for ii in $MPI_FILES ; do
366 i=`echo $ii | sed 's:^\./::'`
367 name=`echo $i | sed 's:_mpi::' `
368 if test -L $BUILD_DIR/$name ; then
369 cmp $BUILD_DIR/$name "../$code_dir/$name"_mpi > /dev/null 2>&1
370 RETVAL=$?
371 if test "x$RETVAL" = x0 ; then
372 #echo Un-linking $name from $linktarg
373 rm -f $BUILD_DIR/$name
374 fi
375 fi
376 done
377 fi
378
379 }
380
381 linkdata()
382 {
383 # linkdata flag
384 #
385 # symbolically link data files to run directory
386 if test "x$1" = x1 ; then
387 (
388 cd $2
389 if test "x$ADM" = x ; then
390 files=`( cd ../input ; ls -1 | grep -v CVS )`
391 for i in $files ; do
392 if test ! -d "../input/"$i ; then
393 ln -sf "../input/"$i $i
394 fi
395 done
396 else
397 files=`( cd ../input ; ls -1 *.bin | grep -v CVS )`
398 for i in $files ; do
399 if test ! -d "../input/"$i ; then
400 ln -sf "../input/"$i $i
401 fi
402 done
403 files=`( cd ../input_ad ; ls -1 | grep -v CVS )`
404 for i in $files ; do
405 if test ! -d "../input_ad/"$i ; then
406 ln -sf "../input_ad/"$i $i
407 fi
408 done
409 fi
410 )
411 fi
412 }
413
414 runmodel()
415 {
416 # runmodel directory
417 #
418 # runs "$COMMAND in "directory"
419 # (where "$COMMAND" is relative to "directory")
420 (
421 cd $1
422 printf 'runmodel ... ' 1>&2
423 # make output.txt
424 echo
425 rm -f run.log
426 # echo "COMMAND='$COMMAND'"
427 # echo "pwd='"`pwd`"'"
428 ( eval $COMMAND ) > run.log 2>&1
429 RETVAL=$?
430 if test "x$RETVAL" = x0 ; then
431 tail run.log
432 echo successful 1>&2
433 # === Reduce the size of the testing emails!
434 # if test "x$ADM" = x ; then
435 # cp output.txt $CDIR"/output.txt"
436 # else
437 # cp output.txt_adm $CDIR"/output.txt_adm"
438 # fi
439 return 0
440 else
441 tail run.log
442 echo failed 1>&2
443 cp run.log $CDIR"/run.log"
444 return 1
445 fi
446 )
447 }
448
449 createcodelet()
450 {
451 # create codelet for comparing model output
452
453 printf "creating the comparison code... "
454 cat > tmp_cmpnum.c <<EOF
455 #include <stdio.h>
456 #include <math.h>
457 int main( int argc, char** argv ) {
458 int linnum,best,lncnt;
459 double a,b,diff;
460 best = -16;
461 lncnt = 0;
462 while( 1 & (lncnt+=1) < 999 ) {
463 scanf("%d", &linnum);
464 if (linnum == -1) break;
465 scanf("%lf", &a); scanf("%lf", &b);
466 diff = 0.5*(fabs(a)+fabs(b));
467 if (diff > 1.e-12) {
468 diff=fabs(a-b)/diff;
469 if (diff > 0.0) {
470 linnum = (int)log10(diff);
471 best = (best > linnum) ? best : linnum;
472 }
473 else {
474 if (best == -16 && diff != 0) best = -22;
475 }
476 }
477 }
478 if (lncnt == 999) best=-29;
479 printf("%d\n", -best);
480 return 0;
481 }
482 EOF
483 cc -o tmp_cmpnum tmp_cmpnum.c -lm
484
485 if [ -x ./tmp_cmpnum ]; then
486 echo "OK"
487 return 0
488 else
489 echo
490 echo "ERROR: failed to compile comparison code"
491 exit 1
492 fi
493 }
494
495 formatresults()
496 {
497 # formatresults expt genmake depend make run results*
498
499 nm=$1
500 printf '%s %s %s %s' $2 $3 $4 $5
501 shift; shift; shift; shift; shift;
502 printf '%3s' $@
503
504 if [ $1 = '--' ]; then
505 printf ' N/O '
506 else
507 if [ $1 -gt 12 ]; then
508 printf ' pass'
509 else
510 printf ' FAIL'
511 fi
512 fi
513 printf ' %s' $nm
514 printf '\n'
515
516 }
517
518 show_help()
519 {
520 cat - << EOF
521 $0 [-help] [-quick] [-verbose] dir1 [dir2] [...]
522
523 -help|-h Show this help message
524 -quiet Reduce the amount of output
525 -verbose Produce copious amounts of output
526 -debug Produce even more output which will mean nothing to most
527 -force Do "make CLEAN" before compiling. This forces a complete rebuild.
528 -clean Do "make CLEAN" after compiling and testing.
529 -cleanup Aggresively removes all model output, executables and object files
530 and then exits. Use with care.
531
532 Normal usage:
533 $0 * Configure, compile, run and analyze in all experiment directories
534 EOF
535 }
536
537 scandirs()
538 {
539 if [ $# -eq 0 ]; then
540 for arg in * ; do
541 test -d $arg/input && echo $arg
542 done
543 else
544 echo $*
545 fi
546 }
547
548
549 ###############################################################################
550
551
552 # Default properties
553 debug=0
554 verbose=1
555 clean=0
556 expts=''
557 # ieee=1
558
559 IEEE=true
560 if test "x$MITGCM_IEEE" != x ; then
561 IEEE=$MITGCM_IEEE
562 fi
563
564
565 CLEANUP=f
566 QUICK=f
567 NOGENMAKE=f
568 NOCLEAN=f
569 NODEPEND=f
570
571 BASH=
572 OPTFILE=NONE
573 ADDRESSES=
574 TESTDIRS=
575 MPACKDIR="../tools/mpack-1.6"
576 HAVE_MPACK=
577 MPACK="$MPACKDIR/mpack"
578 COMMAND=
579 MAKE=make
580 JOBS=
581 MPI=f
582 DELDIR=
583
584 ADM=
585
586 printf "parsing options... "
587
588 ac_prev=
589 for ac_option ; do
590
591 # If the previous option needs an argument, assign it.
592 if test -n "$ac_prev"; then
593 eval "$ac_prev=\$ac_option"
594 ac_prev=
595 continue
596 fi
597
598 ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
599
600 case $ac_option in
601
602 -help | --help | -h | --h)
603 usage ;;
604
605 -optfile | --optfile | -of | --of)
606 ac_prev=OPTFILE ;;
607 -optfile=* | --optfile=* | -of=* | --of=*)
608 OPTFILE=$ac_optarg ;;
609
610 -addr | --addr | -a | --a)
611 ac_prev=ADDRESSES ;;
612 -addr=* | --addr=*)
613 ADDRESSES=$ac_optarg ;;
614
615 -tdir | --tdir | -t | --t)
616 ac_prev=TESTDIRS ;;
617 -tdir=* | --tdir=*)
618 TESTDIRS=$ac_optarg ;;
619
620 -bash | --bash | -b | --b)
621 ac_prev=BASH ;;
622 -bash=* | --bash=*)
623 BASH=$ac_optarg ;;
624
625 -command | --command | -c | --c)
626 ac_prev=COMMAND ;;
627 -command=* | --command=*)
628 COMMAND=$ac_optarg ;;
629
630 -make | --make | -m | --m)
631 ac_prev=MAKE ;;
632 -make=* | --make=*)
633 MAKE=$ac_optarg ;;
634
635 -j) ac_prev=JOBS ;;
636 -j=*) JOBS=$ac_optarg ;;
637
638 -clean | --clean)
639 CLEANUP=t ;;
640
641 -quick | --quick | -q | --q)
642 QUICK=t ;;
643 -nogenmake | --nogenmake | -ng | --ng)
644 NOGENMAKE=t ;;
645 -noclean | --noclean | -nc | --nc)
646 NOCLEAN=t ;;
647 -nodepend | --nodepend | -nd | --nd)
648 NODEPEND=t ;;
649
650 -mpi) MPI=t ;;
651
652 -adm | -ad) ADM=t ;;
653
654 -ieee) IEEE=true ;;
655 -noieee) IEEE= ;;
656
657 -verbose) verbose=2 ;;
658 -debug) debug=1 ;;
659 -quiet) verbose=0 ;;
660
661 -deldir | -dd) DELDIR=t ;;
662
663 -*)
664 echo "Error: unrecognized option: "$ac_option
665 usage
666 ;;
667
668 *)
669 echo "Error: unrecognized argument: "$ac_option
670 usage
671 ;;
672
673 esac
674
675 done
676
677 if test "x$QUICK" = xt ; then
678 NOGENMAKE=t
679 NOCLEAN=t
680 NODEPEND=t
681 fi
682
683 if test "x$TESTDIRS" = x ; then
684 TESTDIRS=`scandirs`
685 fi
686
687 if test "x$OPTFILE" = xNONE -a "x$MITGCM_OF" != x ; then
688 OPTFILE=$MITGCM_OF
689 fi
690
691 if test "x$ADM" = xt -a "x$COMMAND" = x ; then
692 COMMAND="./mitgcmuv_ad > output.txt_adm 2>&1"
693 fi
694
695 if test "x$COMMAND" = x ; then
696 COMMAND="$MAKE output.txt"
697 fi
698
699 echo "OK"
700
701 # create the FORTRAN comparison code
702 createcodelet
703
704 # build the mpack utility
705 if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then
706 echo "skipping mpack build"
707 else
708 build_mpack
709 fi
710
711 # Create a uniquely named directory to store results
712 MACH=`hostname`
713 UNAMEA=`uname -a`
714 DATE=`date +%Y%m%d`
715 BASE="tr_"$MACH"_"$DATE"_"
716 DNUM=0
717 DRESULTS="$BASE$DNUM"
718 while test -e $DRESULTS ; do
719 DNUM=$(( $DNUM + 1 ))
720 DRESULTS="$BASE$DNUM"
721 done
722 mkdir $DRESULTS
723 RETVAL=$?
724 if test "x$RETVAL" != x0 ; then
725 echo "ERROR: Can't create results directory \"./$DRESULTS\""
726 exit 1
727 fi
728 SUMMARY="$DRESULTS/summary.txt"
729 printf "Start time: " >> $SUMMARY
730 start_date=`date`
731 echo $start_date > $SUMMARY
732
733 of_path=
734 if test "x$OPTFILE" != xNONE ; then
735 if test -r $OPTFILE ; then
736 # get the path
737 path=${OPTFILE%/*}
738 if test "x$path" = x ; then
739 of_path=`pwd`
740 else
741 of_path=`( cd $path > /dev/null 2>&1 ; pwd )`
742 fi
743 file=${OPTFILE##*/}
744 OPTFILE=$of_path/$file
745 cp $OPTFILE $DRESULTS
746 echo >> $SUMMARY
747 echo " OPTFILE=$OPTFILE" >> $SUMMARY
748 else
749 echo | tee $SUMMARY
750 echo "ERROR: can't read OPTFILE=\"$OPTFILE\"" | tee $SUMMARY
751 exit 1
752 fi
753 else
754 echo >> $SUMMARY
755 echo "No \"OPTFILE\" was explicitly specified by testreport," >> $SUMMARY
756 echo " so the genmake default will be used." >> $SUMMARY
757 fi
758 echo
759 echo >> $SUMMARY
760 if test "x$ADM" = x ; then
761 cat << EOF | tee -a $SUMMARY
762 T S U V
763 G D M c m s m s m s m s
764 E p a R g m m e . m m e . m m e . m m e .
765 N n k u 2 i a a d i a a d i a a d i a a d
766 2 d e n d n x n . n x n . n x n . n x n .
767
768 EOF
769 else
770 echo "ADJOINT=true" >> $SUMMARY
771 echo >> $SUMMARY
772 cat << EOF | tee -a $SUMMARY
773 G D M C G
774 E p a R o r
775 N n k u s a
776 2 d e n t d
777
778 EOF
779 fi
780
781 # ...and each test directory...
782 for dir in $TESTDIRS ; do
783
784 # Cleanup only!
785 if test "x$CLEANUP" = xt ; then
786 if test -r $dir/build/Makefile ; then
787 ( cd $dir/build ; make CLEAN )
788 fi
789 if test -r $dir/input/Makefile ; then
790 ( cd $dir/input ; make CLEAN )
791 fi
792 continue
793 fi
794
795 # Verify that the testdir exists and contains previous
796 # results in the correct location--or skip this directory!
797 fout=
798 if test "x$ADM" = x ; then
799 fout=$dir"/results/output.txt"
800 else
801 fout=$dir"/results_ad/output.txt_adm"
802 fi
803 if test ! -r $fout ; then
804 echo "can't read \"$fout\" -- skipping $dir"
805 continue
806 fi
807
808 builddir="input"
809 rundir="input"
810 use_seperate_build=0
811 if test -d $dir/build -a -r $dir/build ; then
812 builddir="build"
813 rundir="build"
814 use_seperate_build=1
815 linkdata $use_seperate_build $dir/$rundir
816 fi
817
818 # Check whether there are "extra runs" for this testdir
819 extra_runs=
820 if test "x$ADM" = x -a "x$use_seperate_build" = x1 ; then
821 ex_run_dirs=`( cd $dir ; echo input.* )`
822 echo "ex_run_dirs='$ex_run_dirs'"
823 for exd in $ex_run_dirs ; do
824 name=`echo $exd | sed -e 's/input.//g'`
825 outf="$dir/results/output.txt.$name"
826 if test -f $outf -a -r $outf ; then
827 extra_runs="$extra_runs $name"
828 fi
829 done
830 fi
831
832 if test "x$ADM" = x ; then
833 code_dir=code
834 CODE_DIR=$dir/code
835 else
836 code_dir=code_ad
837 CODE_DIR=$dir/code_ad
838 fi
839 BUILD_DIR=$dir/$builddir
840
841 if test ! -r $CODE_DIR"/SIZE.h_mpi" -a "x$MPI" = "xt" ; then
842 echo "can't find \"$CODE_DIR/SIZE.h_mpi\" -- skipping $dir"
843 continue
844 fi
845
846 echo "-------------------------------------------------------------------------------"
847 echo
848 echo "Experiment: $dir"
849 echo
850 unset genmake makedepend make run
851 results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --'
852
853 # Create an output dir for each OPTFILE/tdir combination
854 rel_CDIR=$DRESULTS"/"$dir
855 mkdir $rel_CDIR
856 CDIR=`pwd`"/$rel_CDIR"
857
858 if test "x$CLEANUP" = xt ; then
859 makeclean $dir/$builddir
860 else
861 genmakemodel $dir/$builddir && genmake=Y \
862 && makeclean $dir/$builddir \
863 && symlink_mpifiles $dir $code_dir $builddir \
864 && makedependmodel $dir/$builddir && makedepend=Y \
865 && makemodel $dir/$builddir && make=Y \
866 && linkdata $use_seperate_build $dir/$rundir \
867 && runmodel $dir/$rundir && run=Y \
868 && results=`testoutput $dir $rundir`
869 fi
870
871 echo
872 if test "x$ADM" = x ; then
873 fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results`
874 echo
875 echo "$fres" >> $SUMMARY
876 echo "fresults='$fres'" > $CDIR"/summary.txt"
877 echo "MACH='$MACH'" >> $CDIR"/summary.txt"
878 echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"
879 echo "DATE='$DATE'" >> $CDIR"/summary.txt"
880 echo "tdir='$dir'" >> $CDIR"/summary.txt"
881
882 OLD_COMMAND=$COMMAND
883 COMMAND="./mitgcmuv > output.txt"
884 for ex in $extra_runs ; do
885 test -e "$dir/tr_run.$ex" && rm -rf "$dir/tr_run.$ex"
886 mkdir "$dir/tr_run.$ex"
887 links=`( cd "$dir/input" > /dev/null 2>&1 ; ls -1 | grep -v CVS )`
888 (
889 cd "$dir/tr_run.$ex"
890 for i in $links; do
891 ln -s ../input/$i $i
892 done
893 )
894 links=`( cd "$dir/input.$ex" > /dev/null 2>&1 ; ls -1 | grep -v CVS )`
895 (
896 cd "$dir/tr_run.$ex"
897 for i in $links; do
898 test -e $i && rm -f $i
899 ln -s ../input.$ex/$i $i
900 done
901 ln -s ../$builddir/mitgcmuv mitgcmuv
902 )
903 runmodel $dir/tr_run.$ex && run=Y \
904 && results=`testoutput $dir tr_run.$ex "."$ex`
905 fres=`printf '%s %s %s %s' ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N}`
906 fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results`
907 fres="$fres.$ex"
908 echo
909 echo "$fres" >> $SUMMARY
910 echo "fresults='$fres'" > $CDIR"/summary.txt"
911 echo "MACH='$MACH'" >> $CDIR"/summary.txt"
912 echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"
913 echo "DATE='$DATE'" >> $CDIR"/summary.txt"
914 echo "tdir='$dir'" >> $CDIR"/summary.txt"
915 done
916 COMMAND=$OLD_COMMAND
917 else
918 fres=`printf '%s %s %s %s' ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N}`
919 fres=$fres"$results $dir"
920 echo
921 echo "$fres" >> $SUMMARY
922 echo "fresults='$fres'" > $CDIR"/summary.txt"
923 echo "MACH='$MACH'" >> $CDIR"/summary.txt"
924 echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"
925 echo "DATE='$DATE'" >> $CDIR"/summary.txt"
926 echo "tdir='$dir'" >> $CDIR"/summary.txt"
927 fi
928
929 echo "-------------------------------------------------------------------------------"
930
931 done
932
933 printf "Start time: " >> $SUMMARY
934 echo $start_date >> $SUMMARY
935 printf "End time: " >> $SUMMARY
936 date >> $SUMMARY
937
938 # If addresses were supplied and mpack built successfully, then try
939 # to send email using mpack.
940 if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then
941 echo "No results email was sent."
942 else
943 if test "x$HAVE_MPACK" = xt ; then
944 tar -cf $DRESULTS".tar" $DRESULTS > /dev/null 2>&1 \
945 && gzip $DRESULTS".tar" \
946 && $MPACK -s MITgcm-test -m 3555000 $DRESULTS".tar.gz" $ADDRESSES
947 RETVAL=$?
948 if test "x$RETVAL" != x0 ; then
949 echo
950 echo "Warning: The tar, gzip, & mpack step failed. Please send email"
951 echo " to <MITgcm-support@mitgcm.org> for help. You may copy the "
952 echo " summary of results from the directory \"$DRESULTS\"."
953 echo
954 else
955 echo
956 echo "An email containing results was sent to the following addresses:"
957 echo " \"$ADDRESSES\""
958 echo
959 fi
960 test -f $DRESULTS".tar" && rm -f $DRESULTS".tar"
961 test -f $DRESULTS".tar.gz" && rm -f $DRESULTS".tar.gz"
962 fi
963 fi
964
965 # rm -f tmp_cmpnum.f a.out
966 rm -f tmp_cmpnum.c tmp_cmpnum
967
968 if test "x$CLEANUP" != xt ; then
969 cat $SUMMARY
970 if test -e tr_out.txt ; then
971 mv tr_out.txt tr_out.txt.old
972 fi
973 cat $SUMMARY > tr_out.txt
974 fi
975
976 if test "x$DELDIR" = xt ; then
977 rm -rf $DRESULTS
978 fi

  ViewVC Help
Powered by ViewVC 1.1.22