/[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.24 - (show annotations) (download)
Sun Nov 30 01:28:51 2003 UTC (20 years, 4 months ago) by edhill
Branch: MAIN
CVS Tags: branch-netcdf
Changes since 1.23: +131 -44 lines
 o added an "-adm" option that runs an adjoint test instead of the normal
   forward tests
   - confirmed to work with global_ocean.90x40x15 in checkpoint52a_post
     since the current HEAD seems to be broken for the adjoint
   - used staf for the above test
   - produces same results for the forward tests

1 #! /usr/bin/env bash
2 #
3 # $Header: /u/u3/gcmpack/MITgcm/verification/testreport,v 1.23 2003/11/29 01:45:25 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=\"noieee\")"
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 " (-clean) *ONLY* run \"make CLEAN\""
31 echo " (-quick|-q) same as \"-nogenmake -noclean -nodepend\""
32 echo " (-nogenmake|-ng) skip the genmake stage"
33 echo " (-noclean|-nc) skip the \"make clean\" stage"
34 echo " (-nodepend|-nd) skip the \"make depend\" stage"
35 echo
36 echo "and where STRING follows a whitespace-delimited format"
37 echo "such as:"
38 echo " -t 'exp0 exp2 exp3' "
39 echo " -addr='abc@123.com testing@home.org'"
40 echo
41 exit 1
42 }
43
44 # build the mpack utility
45 build_mpack()
46 {
47 echo -n "building the mpack utility... "
48 if test ! -x "$MPACKDIR/mpack" ; then
49 if test ! -d $MPACKDIR ; then
50 echo
51 echo "Error: can't find \"$MPACKDIR\""
52 echo " are you sure this program is being run in the correct "
53 echo " (that is, \"MITGCM_ROOT\verification\") directory?"
54 echo
55 HAVE_MPACK=f
56 fi
57 echo -n "building mpack... "
58 ( cd $MPACKDIR && ./configure && $MAKE ) > build_mpack.out 2>&1
59 RETVAL=$?
60 if test "x$RETVAL" != x0 ; then
61 echo
62 echo "Error building the mpack tools at: $MPACK_DIR"
63 echo
64 HAVE_MPACK=f
65 else
66 HAVE_MPACK=t
67 fi
68 else
69 HAVE_MPACK=t
70 fi
71 echo "OK"
72 }
73
74 testoutput_for_prop()
75 {
76 # testoutput_for_prop dir s1 label subdir
77 #
78 # compares files in $dir/$subdir/output.txt and $dir/results/output.txt
79 # using search strings s1 and text label
80
81 if [ $debug -gt 0 ]; then
82 echo testoutput_for_prop: grep "$2" $1/$4/output.txt 1>&2
83 fi
84 if [ -r $1/$4/output.txt ]; then
85 grep "$2" $1/$4/output.txt | sed 's/.*=//' | cat -n > tmp1.txt
86 lncnt=`wc -l tmp1.txt | awk '{print $1}' `
87 if [ $lncnt -lt 3 ]; then
88 if [ $verbose -gt 0 ]; then
89 echo Not enough lines of output when searching for "$2" 1>&2
90 fi
91 return 99
92 fi
93 else
94 echo testoutput_for_prop: output.txt from model run was not readable 1>&2
95 return 99
96 fi
97 if [ $debug -gt 0 ]; then
98 echo testoutput_for_prop: grep "$2" $1/results/output.txt 1>&2
99 fi
100 grep "$2" $1/results/output.txt | sed 's/.*=//' | cat -n > tmp2.txt
101 lncnt=`wc -l tmp2.txt | awk '{print $1}' `
102 if [ $lncnt -lt 3 ]; then
103 if [ $verbose -gt 0 ]; then
104 echo Not enough lines of output when searching for "$2" 1>&2
105 fi
106 return 99
107 fi
108 if [ $debug -gt 0 ]; then
109 echo testoutput_for_prop: join tmp1.txt tmp2.txt 1>&2
110 fi
111 join tmp1.txt tmp2.txt | awk '{print $1 " " $2 " " $3}' > tmp3.txt
112 if [ $debug -gt 0 ]; then
113 echo testoutput_for_prop: compare_lines 1>&2
114 fi
115 if [ $verbose -gt 1 ]; then
116 cat tmp3.txt 1>&2
117 fi
118 echo "-1" >> tmp3.txt
119 # On the SGI O3K (*not* the O2K), "cat -n" inserts a ":" after the line number
120 cat tmp3.txt | sed -e 's|:||g' > tmp4.txt
121 digits_of_similarity=`./tmp_cmpnum < tmp4.txt`
122 if [ $digits_of_similarity -eq 99 ]; then
123 if [ $verbose -gt 0 ]; then
124 echo testoutput_for_prop: No comparison was available for \"$2\" 1>&2
125 fi
126 digits_of_similarity=99
127 else
128 if [ $verbose -gt 0 ]; then
129 echo There were $digits_of_similarity decimal places of similarity for \"$2\" 1>&2
130 fi
131 fi
132 rm -f tmp1.txt tmp2.txt tmp3.txt tmp4.txt
133
134 return $digits_of_similarity
135 }
136
137 dashnum()
138 {
139 # dashnum n1 n2 n3 ...
140 #
141 # print numbers using %3i format or "--" if number = 99
142
143 for num in $@ ; do
144 if [ $num = 99 ]; then
145 printf ' --'
146 else
147 printf '%3i' $num
148 fi
149 done
150 }
151
152 testoutput_ad()
153 {
154 grep $3 $1/results_ad/output.txt_adm | awk '{print NR " " $5}' > t05.txt
155 grep $3 $1/$2/output.txt_adm | awk '{print NR " " $5}' > t15.txt
156 grep $3 $1/results_ad/output.txt_adm | awk '{print NR " " $6}' > t06.txt
157 grep $3 $1/$2/output.txt_adm | awk '{print NR " " $6}' > t16.txt
158 join t05.txt t15.txt > t5.txt
159 join t06.txt t16.txt > t6.txt
160 echo "-1" >> t5.txt
161 echo "-1" >> t6.txt
162 digits_5=`./tmp_cmpnum < t5.txt`
163 digits_6=`./tmp_cmpnum < t6.txt`
164 dashnum $digits_5 $digits_6
165 rm -f t[01][56].txt t[56].txt
166 }
167
168 testoutput()
169 {
170 # testoutput directory subdir
171 #
172 # test output in "directory"
173 if test "x$ADM" = x ; then
174 if [ $debug -gt 0 ]; then
175 echo testoutput: testoutput_for_prop $1 cg2d_init_res 1>&2
176 fi
177 testoutput_for_prop $1 "cg2d_init_res" "cg2d init. residual" $2; cg2dres=$?
178 if [ $debug -gt 0 ]; then
179 echo testoutput: cg2dres=$cg2dres 1>&2
180 fi
181 testoutput_for_prop $1 "dynstat_theta_min" "theta minimum" $2; tmin=$?
182 testoutput_for_prop $1 "dynstat_theta_max" "theta maximum" $2; tmax=$?
183 testoutput_for_prop $1 "dynstat_theta_mean" "theta mean" $2; tmean=$?
184 testoutput_for_prop $1 "dynstat_theta_sd" "theta s.d." $2; tsd=$?
185 testoutput_for_prop $1 "dynstat_salt_min" "salt minimum" $2; smin=$?
186 testoutput_for_prop $1 "dynstat_salt_max" "salt maximum" $2; smax=$?
187 testoutput_for_prop $1 "dynstat_salt_mean" "salt mean" $2; smean=$?
188 testoutput_for_prop $1 "dynstat_salt_sd" "salt s.d." $2; ssd=$?
189 testoutput_for_prop $1 "dynstat_uvel_min" "U minimum" $2; umin=$?
190 testoutput_for_prop $1 "dynstat_uvel_max" "U maximum" $2; umax=$?
191 testoutput_for_prop $1 "dynstat_uvel_mean" "U mean" $2; umean=$?
192 testoutput_for_prop $1 "dynstat_uvel_sd" "U s.d." $2; usd=$?
193 testoutput_for_prop $1 "dynstat_vvel_min" "V minimum" $2; vmin=$?
194 testoutput_for_prop $1 "dynstat_vvel_max" "V maximum" $2; vmax=$?
195 testoutput_for_prop $1 "dynstat_vvel_mean" "V mean" $2; vmean=$?
196 testoutput_for_prop $1 "dynstat_vvel_sd" "V s.d." $2; vsd=$?
197 dashnum $cg2dres $tmin $tmax $tmean $tsd $smin $smax $smean $ssd \
198 $umin $umax $umean $usd $vmin $vmax $vmean $vsd
199 else
200 testoutput_ad $1 $2 "precision_grdchk_result"
201 fi
202 }
203
204 genmakemodel()
205 {
206 # genmakemodel directory
207 if test "x$NOGENMAKE" = xt ; then
208 echo "genmake skipped!"
209 else
210 GENMAKE2="$BASH ../../../tools/genmake2"
211 (
212 cd $1;
213 command="$GENMAKE2 -ds -m $MAKE"
214 if test "x$ADM" = x ; then
215 command="$command --mods=../code"
216 else
217 command="$command --mods=../code_ad"
218 command="$command -adof=../../../tools/adjoint_options/adjoint_staf"
219 fi
220 if test "x$OPTFILE" != xNONE ; then
221 command="$command --optfile=$OPTFILE"
222 fi
223 if test "x$IEEE" != x ; then
224 command="$command -ieee"
225 fi
226 printf 'genmake ... ' 1>&2
227 $command > make.log 2>&1
228 RETVAL=$?
229 cp Makefile $CDIR
230 if test "x$RETVAL" != x0 ; then
231 tail make.log
232 echo "genmakemodel: genmake failed" 1>&2
233 cp genmake_* make.log $CDIR
234 return 1
235 else
236 echo "successful" 1>&2
237 fi
238 )
239 fi
240 }
241
242 makeclean()
243 {
244 # makeclean directory
245 if test "x$NOCLEAN" = xt ; then
246 echo "make CLEAN skipped!"
247 else
248 (
249 cd $1;
250 if test -e output.txt ; then
251 rm -f output.txt
252 fi
253 printf 'make CLEAN ... ' 2>&1
254 if test -r Makefile ; then
255 $MAKE CLEAN >> make.log 2>&1
256 RETVAL=$?
257 if test "x$RETVAL" != x0 ; then
258 tail make.log
259 echo "makeclean: \"make CLEAN\" failed" 1>&2
260 cp make.log $CDIR"/make.log"
261 return 1
262 fi
263 fi
264 echo successful 1>&2
265 exit 0
266 )
267 fi
268 }
269
270 makedependmodel()
271 {
272 # makedependmodel directory
273 if test "x$NODEPEND" = xt ; then
274 echo "make depend skipped!"
275 else
276 (
277 cd $1;
278 printf 'make depend ... ' 1>&2
279 $MAKE depend >> make.log 2>&1
280 RETVAL=$?
281 if test "x$RETVAL" != x0 ; then
282 tail make.log
283 echo "makedependmodel: make depend failed" 1>&2
284 cp make.log $CDIR"/make.log"
285 return 1
286 else
287 echo successful 1>&2
288 fi
289 )
290 fi
291 }
292
293 makemodel()
294 {
295 # makemodel directory
296 (
297 cd $1;
298 if test -r Makefile ; then
299 printf 'make ... ' 1>&2
300 if test "x$ADM" = x ; then
301 $MAKE >> make.log 2>&1
302 else
303 $MAKE adall >> make.log 2>&1
304 fi
305 RETVAL=$?
306 if test "x$RETVAL" != x0 ; then
307 tail make.log
308 echo failed 1>&2
309 cp make.log $CDIR"/make.log"
310 return 1
311 else
312 echo successful 1>&2
313 fi
314 fi
315 )
316 }
317
318 linkdata()
319 {
320 # linkdata flag
321 #
322 # symbolically link data files to run directory
323 if test "x$1" = x1 ; then
324 (
325 cd $2
326 if test "x$ADM" = x ; then
327 files=`( cd ../input ; ls -1 | grep -v CVS )`
328 for i in $files ; do
329 if test ! -d "../input/"$i ; then
330 ln -sf "../input/"$i $i
331 fi
332 done
333 else
334 files=`( cd ../input ; ls -1 *.bin | grep -v CVS )`
335 for i in $files ; do
336 if test ! -d "../input/"$i ; then
337 ln -sf "../input/"$i $i
338 fi
339 done
340 files=`( cd ../input_ad ; ls -1 | grep -v CVS )`
341 for i in $files ; do
342 if test ! -d "../input_ad/"$i ; then
343 ln -sf "../input_ad/"$i $i
344 fi
345 done
346 fi
347 )
348 fi
349 }
350
351 runmodel()
352 {
353 # runmodel directory
354 #
355 # runs "$COMMAND in "directory"
356 # (where "$COMMAND" is relative to "directory")
357 (
358 cd $1
359 printf 'runmodel ... ' 1>&2
360 # make output.txt
361 $COMMAND >> run.log 2>&1
362 RETVAL=$?
363 if test "x$RETVAL" = x0 ; then
364 echo successful 1>&2
365 if test "x$ADM" = x ; then
366 cp output.txt $CDIR"/output.txt"
367 else
368 cp output.txt_adm $CDIR"/output.txt_adm"
369 fi
370 return 0
371 else
372 tail run.log
373 echo failed 1>&2
374 cp run.log $CDIR"/run.log"
375 return 1
376 fi
377 )
378 }
379
380 createcodelet()
381 {
382 # create codelet for comparing model output
383
384 echo -n "creating the comparison code... "
385 cat > tmp_cmpnum.c <<EOF
386 #include <stdio.h>
387 #include <math.h>
388 int main( int argc, char** argv ) {
389 int linnum,best;
390 double a,b,diff;
391 best = -16;
392 while( 1 ) {
393 scanf("%d", &linnum);
394 if (linnum == -1) break;
395 scanf("%lf", &a); scanf("%lf", &b);
396 diff = 0.5*(fabs(a)+fabs(b));
397 if (diff > 1.e-12) {
398 diff=fabs(a-b)/diff;
399 if (diff > 0.0) {
400 linnum = (int)log10(diff);
401 best = (best > linnum) ? best : linnum;
402 }
403 else {
404 if (best == -16 && diff != 0) best = -22;
405 }
406 }
407 }
408 printf("%d\n", -best);
409 return 0;
410 }
411 EOF
412 cc -o tmp_cmpnum tmp_cmpnum.c -lm
413
414 if [ -x ./tmp_cmpnum ]; then
415 echo "OK"
416 return 0
417 else
418 echo
419 echo "ERROR: failed to compile comparison code"
420 exit 1
421 fi
422 }
423
424 formatresults()
425 {
426 # formatresults expt genmake depend make run results*
427
428 nm=$1
429 printf '%s %s %s %s' $2 $3 $4 $5
430 shift; shift; shift; shift; shift;
431 printf '%3s' $@
432
433 if [ $1 = '--' ]; then
434 printf ' N/O '
435 else
436 if [ $1 -gt 12 ]; then
437 printf ' pass'
438 else
439 printf ' FAIL'
440 fi
441 fi
442 printf ' %s' $nm
443 printf '\n'
444
445 }
446
447 show_help()
448 {
449 cat - << EOF
450 $0 [-help] [-quick] [-verbose] dir1 [dir2] [...]
451
452 -help|-h Show this help message
453 -quiet Reduce the amount of output
454 -verbose Produce copious amounts of output
455 -debug Produce even more output which will mean nothing to most
456 -force Do "make CLEAN" before compiling. This forces a complete rebuild.
457 -clean Do "make CLEAN" after compiling and testing.
458 -cleanup Aggresively removes all model output, executables and object files
459 and then exits. Use with care.
460
461 Normal usage:
462 $0 * Configure, compile, run and analyze in all experiment directories
463 EOF
464 }
465
466 scandirs()
467 {
468 if [ $# -eq 0 ]; then
469 for arg in * ; do
470 test -d $arg/input && echo $arg
471 done
472 else
473 echo $*
474 fi
475 }
476
477
478 ###############################################################################
479
480
481 # Default properties
482 debug=0
483 verbose=1
484 clean=0
485 expts=''
486 # ieee=1
487
488 IEEE=
489 if test "x$MITGCM_IEEE" != x ; then
490 IEEE=$MITGCM_IEEE
491 fi
492
493
494 CLEANUP=f
495 QUICK=f
496 NOGENMAKE=f
497 NOCLEAN=f
498 NODEPEND=f
499
500 BASH=
501 OPTFILE=NONE
502 ADDRESSES=
503 TESTDIRS=
504 MPACKDIR="../tools/mpack-1.6"
505 HAVE_MPACK=
506 MPACK="$MPACKDIR/mpack"
507 COMMAND=
508 MAKE=make
509 MPI=f
510
511 ADM=
512
513 echo -n "parsing options... "
514
515 ac_prev=
516 for ac_option ; do
517
518 # If the previous option needs an argument, assign it.
519 if test -n "$ac_prev"; then
520 eval "$ac_prev=\$ac_option"
521 ac_prev=
522 continue
523 fi
524
525 ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
526
527 case $ac_option in
528
529 -help | --help | -h | --h)
530 usage ;;
531
532 -optfile | --optfile | -of | --of)
533 ac_prev=OPTFILE ;;
534 -optfile=* | --optfile=* | -of=* | --of=*)
535 OPTFILE=$ac_optarg ;;
536
537 -addr | --addr | -a | --a)
538 ac_prev=ADDRESSES ;;
539 -addr=* | --addr=*)
540 ADDRESSES=$ac_optarg ;;
541
542 -tdir | --tdir | -t | --t)
543 ac_prev=TESTDIRS ;;
544 -tdir=* | --tdir=*)
545 TESTDIRS=$ac_optarg ;;
546
547 -bash | --bash | -b | --b)
548 ac_prev=BASH ;;
549 -bash=* | --bash=*)
550 BASH=$ac_optarg ;;
551
552 -command | --command | -c | --c)
553 ac_prev=COMMAND ;;
554 -command=* | --command=*)
555 COMMAND=$ac_optarg ;;
556
557 -make | --make | -m | --m)
558 ac_prev=MAKE ;;
559 -make=* | --make=*)
560 MAKE=$ac_optarg ;;
561
562 -clean | --clean)
563 CLEANUP=t ;;
564
565 -quick | --quick | -q | --q)
566 QUICK=t ;;
567 -nogenmake | --nogenmake | -ng | --ng)
568 NOGENMAKE=t ;;
569 -noclean | --noclean | -nc | --nc)
570 NOCLEAN=t ;;
571 -nodepend | --nodepend | -nd | --nd)
572 NODEPEND=t ;;
573
574 -mpi) MPI=t ;;
575
576 -adm | -ad) ADM=t ;;
577
578 -ieee) IEEE=true ;;
579 -noieee) IEEE= ;;
580
581 -verbose) verbose=2 ;;
582 -debug) debug=1 ;;
583 -quiet) verbose=0 ;;
584
585 -*)
586 echo "Error: unrecognized option: "$ac_option
587 usage
588 ;;
589
590 *)
591 echo "Error: unrecognized argument: "$ac_option
592 usage
593 ;;
594
595 esac
596
597 done
598
599 if test "x$QUICK" = xt ; then
600 NOGENMAKE=t
601 NOCLEAN=t
602 NODEPEND=t
603 fi
604
605 if test "x$TESTDIRS" = x ; then
606 TESTDIRS=`scandirs`
607 fi
608
609 if test "x$OPTFILE" = xNONE -a "x$MITGCM_OF" != x ; then
610 OPTFILE=$MITGCM_OF
611 fi
612
613 if test "x$ADM" = xt -a "x$COMMAND" = x ; then
614 COMMAND="./mitgcmuv_ad > output.txt_adm 2>&1"
615 fi
616
617 if test "x$COMMAND" = x ; then
618 COMMAND="make output.txt"
619 fi
620
621 echo "OK"
622
623 # create the FORTRAN comparison code
624 createcodelet
625
626 # build the mpack utility
627 build_mpack
628
629 # Create a uniquely named directory to store results
630 MACH=`hostname`
631 UNAMEA=`uname -a`
632 DATE=`date +%Y%m%d`
633 BASE=$MACH"_"$DATE"_"
634 DNUM=0
635 DRESULTS="$BASE$DNUM"
636 while test -e $DRESULTS ; do
637 DNUM=$(( $DNUM + 1 ))
638 DRESULTS="$BASE$DNUM"
639 done
640 mkdir $DRESULTS
641 RETVAL=$?
642 if test "x$RETVAL" != x0 ; then
643 echo "ERROR: Can't create results directory \"./$DRESULTS\""
644 exit 1
645 fi
646 SUMMARY="$DRESULTS/summary.txt"
647 echo -n "Start time: " >> $SUMMARY
648 start_date=`date`
649 echo $start_date > $SUMMARY
650
651 of_path=
652 if test "x$OPTFILE" != xNONE ; then
653 if test -r $OPTFILE ; then
654 # get the path
655 path=${OPTFILE%/*}
656 if test "x$path" = x ; then
657 of_path=`pwd`
658 else
659 of_path=`( cd $path > /dev/null 2>&1 ; pwd )`
660 fi
661 file=${OPTFILE##*/}
662 OPTFILE=$of_path/$file
663 cp $OPTFILE $DRESULTS
664 echo >> $SUMMARY
665 echo " OPTFILE=$OPTFILE" >> $SUMMARY
666 else
667 echo | tee $SUMMARY
668 echo "ERROR: can't read OPTFILE=\"$OPTFILE\"" | tee $SUMMARY
669 exit 1
670 fi
671 else
672 echo >> $SUMMARY
673 echo "No \"OPTFILE\" was explicitly specified by testreport," >> $SUMMARY
674 echo " so the genmake default will be used." >> $SUMMARY
675 fi
676 echo
677 echo >> $SUMMARY
678 if test "x$ADM" = x ; then
679 cat << EOF | tee -a $SUMMARY
680 T S U V
681 G D M c m s m s m s m s
682 E p a R g m m e . m m e . m m e . m m e .
683 N n k u 2 i a a d i a a d i a a d i a a d
684 2 d e n d n x n . n x n . n x n . n x n .
685
686 EOF
687 else
688 echo "ADJOINT=true" >> $SUMMARY
689 echo >> $SUMMARY
690 cat << EOF | tee -a $SUMMARY
691 G D M C G
692 E p a R o r
693 N n k u s a
694 2 d e n t d
695
696 EOF
697 fi
698
699 # ...and each test directory...
700 for dir in $TESTDIRS ; do
701
702 # Cleanup only!
703 if test "x$CLEANUP" = xt ; then
704 if test -r $dir/build/Makefile ; then
705 ( cd $dir/build ; make CLEAN )
706 fi
707 if test -r $dir/input/Makefile ; then
708 ( cd $dir/input ; make CLEAN )
709 fi
710 continue
711 fi
712
713 # Verify that the testdir exists and contains previous
714 # results in the correct location--or skip this directory!
715 fout=
716 if test "x$ADM" = x ; then
717 fout=$dir"/results/output.txt"
718 else
719 fout=$dir"/results_ad/output.txt_adm"
720 fi
721 if test ! -r $fout ; then
722 echo "can't read \"$fout\" -- skipping $dir"
723 continue
724 fi
725
726 echo "-------------------------------------------------------------------------------"
727 echo
728 echo "Experiment: $dir"
729 echo
730 unset genmake makedepend make run
731 results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --'
732
733 builddir="input"
734 rundir="input"
735 use_seperate_build=0
736 if test -d $dir/build -a -r $dir/build ; then
737 builddir="build"
738 rundir="build"
739 use_seperate_build=1
740 linkdata $use_seperate_build $dir/$rundir
741 fi
742
743 if test "x$ADM" = x ; then
744 CODE_DIR=$dir/code
745 else
746 CODE_DIR=$dir/code_ad
747 fi
748 BUILD_DIR=$dir/$builddir
749 MPI_FILES="CPP_EEOPTIONS.h_mpi SIZE.h_mpi"
750 NOMPI_FILES="CPP_EEOPTIONS.h_nompi SIZE.h_nompi"
751
752 # Is this an MPI run?
753 if test "x$MPI" = xt ; then
754 FILES=$MPI_FILES
755 endings="_mpi"
756 else
757 FILES=$NOMPI_FILES
758 endings="_nompi"
759 fi
760
761 # Check to see that we have the files
762 have_files=t
763 for i in $FILES ; do
764 if test ! -r $CODE_DIR/$i ; then
765 echo "Warning: can't read file $CODE_DIR/$i"
766 have_files=f
767 fi
768 done
769 if test "x$have_files" != xt -a "x$MPI" = xt ; then
770 echo "Skipping $dir due to lack of input files (see above warning)"
771 continue
772 fi
773
774 # If we have the $FILES and they differ, copy the $FILES to $BUILD_DIR
775 if test "x$have_files" = xt ; then
776 for i in $FILES ; do
777 sstr="s|$endings||"
778 name=`echo $i | sed -e $sstr `
779 cmp $CODE_DIR/$i $BUILD_DIR/$name > /dev/null 2>&1
780 RETVAL=$?
781 if test "x$RETVAL" != x0 ; then
782 cp $CODE_DIR/$i $BUILD_DIR/$name
783 fi
784 done
785 fi
786
787 # Create an output dir for each OPTFILE/tdir combination
788 rel_CDIR=$DRESULTS"/"$dir
789 mkdir $rel_CDIR
790 CDIR=`pwd`"/$rel_CDIR"
791
792 if test "x$CLEANUP" = xt ; then
793 makeclean $dir/$builddir
794 else
795 genmakemodel $dir/$builddir && genmake=Y \
796 && makeclean $dir/$builddir \
797 && makedependmodel $dir/$builddir && makedepend=Y \
798 && makemodel $dir/$builddir && make=Y \
799 && linkdata $use_seperate_build $dir/$rundir \
800 && runmodel $dir/$rundir && run=Y \
801 && results=`testoutput $dir $rundir`
802 fi
803
804 echo
805 if test "x$ADM" = x ; then
806 fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results`
807 else
808 fres=`printf '%s %s %s %s' ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N}`
809 fres=$fres"$results $dir"
810 fi
811 echo
812 echo "$fres" >> $SUMMARY
813 echo "fresults='$fres'" > $CDIR"/summary.txt"
814 echo "MACH='$MACH'" >> $CDIR"/summary.txt"
815 echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"
816 echo "DATE='$DATE'" >> $CDIR"/summary.txt"
817 echo "tdir='$dir'" >> $CDIR"/summary.txt"
818
819 echo "-------------------------------------------------------------------------------"
820
821 done
822
823 echo -n "Start time: " >> $SUMMARY
824 echo $start_date >> $SUMMARY
825 echo -n "End time: " >> $SUMMARY
826 date >> $SUMMARY
827
828 # If addresses were supplied and mpack built successfully, then try
829 # to send email using mpack.
830 if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then
831 echo "No results email was sent."
832 else
833 if test "x$HAVE_MPACK" = xt ; then
834 tar -cf $DRESULTS".tar" $DRESULTS > /dev/null 2>&1 \
835 && gzip $DRESULTS".tar" \
836 && $MPACK -s MITgcm-test -m 1500000 $DRESULTS".tar.gz" $ADDRESSES
837 RETVAL=$?
838 if test "x$RETVAL" != x0 ; then
839 echo
840 echo "Warning: The tar, gzip, & mpack step failed. Please send email"
841 echo " to <MITgcm-support@mitgcm.org> for help. You may copy the "
842 echo " summary of results from the directory \"$DRESULTS\"."
843 echo
844 else
845 echo
846 echo "An email containing results was sent to the following addresses:"
847 echo " \"$ADDRESSES\""
848 echo
849 fi
850 test -f $DRESULTS".tar" && rm -f $DRESULTS".tar"
851 test -f $DRESULTS".tar.gz" && rm -f $DRESULTS".tar.gz"
852 fi
853 fi
854
855 # rm -f tmp_cmpnum.f a.out
856 rm -f tmp_cmpnum.c tmp_cmpnum
857
858 if test "x$CLEANUP" != xt ; then
859 cat $SUMMARY
860 if test -e tr.out ; then
861 mv tr.out tr.out.old
862 fi
863 cat $SUMMARY > tr.out
864 fi

  ViewVC Help
Powered by ViewVC 1.1.22