/[MITgcm]/MITgcm/verification/testreport
ViewVC logotype

Annotation of /MITgcm/verification/testreport

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.37 - (hide annotations) (download)
Fri Mar 12 18:51:05 2004 UTC (20 years ago) by edhill
Branch: MAIN
Changes since 1.36: +2 -2 lines
 o another change for JMC to test

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

  ViewVC Help
Powered by ViewVC 1.1.22