/[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.42 - (hide annotations) (download)
Thu Jul 8 15:47:19 2004 UTC (19 years, 8 months ago) by jmc
Branch: MAIN
Changes since 1.41: +7 -7 lines
multiple test-run done in a different directory

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

  ViewVC Help
Powered by ViewVC 1.1.22