/[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.45 - (hide annotations) (download)
Sat Jul 17 02:08:45 2004 UTC (19 years, 8 months ago) by edhill
Branch: MAIN
CVS Tags: checkpoint54c_post
Changes since 1.44: +9 -8 lines
 o replace readlink with more portable cmp (eg. no readlink on halem!)
 o use $MAKE instead of "make"

1 edhill 1.19 #! /usr/bin/env bash
2 edhill 1.1 #
3 edhill 1.45 # $Header: /u/gcmpack/MITgcm/verification/testreport,v 1.44 2004/07/12 14:02:25 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.43 echo " (-j) JOBS use \"make -j JOBS\" for parallel builds"
31 edhill 1.10 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 edhill 1.40 echo " (-deldir|-dd) on success, delete the output directory"
37 edhill 1.6 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 edhill 1.1 echo
43     exit 1
44     }
45    
46     # build the mpack utility
47     build_mpack()
48     {
49 edhill 1.34 printf "building the mpack utility... "
50 edhill 1.1 if test ! -x "$MPACKDIR/mpack" ; then
51     if test ! -d $MPACKDIR ; then
52 edhill 1.20 echo
53 edhill 1.1 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 edhill 1.20 echo
57     HAVE_MPACK=f
58 edhill 1.1 fi
59 edhill 1.34 printf "building mpack... "
60 edhill 1.26 if test "x$CC" = x ; then
61     export CC=cc
62     fi
63 edhill 1.25 ( cd $MPACKDIR && ./configure && $MAKE ) > tr_build_mpack.out 2>&1
64 edhill 1.1 RETVAL=$?
65     if test "x$RETVAL" != x0 ; then
66     echo
67     echo "Error building the mpack tools at: $MPACK_DIR"
68 edhill 1.20 echo
69     HAVE_MPACK=f
70     else
71 edhill 1.25 rm -f tr_build_mpack.out
72 edhill 1.20 HAVE_MPACK=t
73 edhill 1.1 fi
74 edhill 1.20 else
75     HAVE_MPACK=t
76 edhill 1.1 fi
77     echo "OK"
78     }
79    
80     testoutput_for_prop()
81     {
82 edhill 1.34 # testoutput_for_prop dir s1 label subdir extension
83 edhill 1.1 #
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 edhill 1.15 grep "$2" $1/$4/output.txt | sed 's/.*=//' | cat -n > tmp1.txt
92 edhill 1.1 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 edhill 1.34 echo testoutput_for_prop: grep "$2" $1/results/output.txt$5 1>&2
105 edhill 1.1 fi
106 edhill 1.34 grep "$2" $1/results/output.txt$5 | sed 's/.*=//' | cat -n > tmp2.txt
107 edhill 1.1 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 edhill 1.22 if [ $verbose -gt 1 ]; then
122     cat tmp3.txt 1>&2
123     fi
124     echo "-1" >> tmp3.txt
125 edhill 1.23 # 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 edhill 1.1 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 edhill 1.23 rm -f tmp1.txt tmp2.txt tmp3.txt tmp4.txt
139 edhill 1.1
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 edhill 1.24 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 edhill 1.1 testoutput()
175     {
176 edhill 1.34 # testoutput directory subdir extension
177 edhill 1.1 #
178     # test output in "directory"
179 edhill 1.24 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 edhill 1.34 testoutput_for_prop $1 "cg2d_init_res" "cg2d init. residual" $2 $3; cg2dres=$?
184 edhill 1.24 if [ $debug -gt 0 ]; then
185     echo testoutput: cg2dres=$cg2dres 1>&2
186     fi
187 edhill 1.34 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 edhill 1.24 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 edhill 1.1 fi
208     }
209    
210     genmakemodel()
211     {
212     # genmakemodel directory
213 edhill 1.10 if test "x$NOGENMAKE" = xt ; then
214     echo "genmake skipped!"
215     else
216 edhill 1.34 if test "x$BASH" = x ; then
217     GENMAKE2="../../../tools/genmake2"
218     else
219     GENMAKE2="$BASH ../../../tools/genmake2 -bash $BASH"
220     fi
221 edhill 1.10 (
222     cd $1;
223 edhill 1.24 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 edhill 1.10 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 edhill 1.44 # Reduce the size of the testing emails!
240     # cp Makefile $CDIR
241 edhill 1.10 if test "x$RETVAL" != x0 ; then
242     tail make.log
243     echo "genmakemodel: genmake failed" 1>&2
244 edhill 1.21 cp genmake_* make.log $CDIR
245 edhill 1.10 return 1
246     else
247 edhill 1.20 echo "successful" 1>&2
248 edhill 1.1 fi
249 edhill 1.10 )
250     fi
251 edhill 1.1 }
252    
253     makeclean()
254     {
255     # makeclean directory
256 edhill 1.10 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 edhill 1.20 echo successful 1>&2
276 edhill 1.10 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 edhill 1.1 RETVAL=$?
292     if test "x$RETVAL" != x0 ; then
293     tail make.log
294 edhill 1.10 echo "makedependmodel: make depend failed" 1>&2
295 edhill 1.1 cp make.log $CDIR"/make.log"
296     return 1
297 edhill 1.10 else
298 edhill 1.20 echo successful 1>&2
299 edhill 1.1 fi
300 edhill 1.10 )
301     fi
302 edhill 1.1 }
303    
304     makemodel()
305     {
306     # makemodel directory
307     (
308     cd $1;
309     if test -r Makefile ; then
310     printf 'make ... ' 1>&2
311 edhill 1.24 if test "x$ADM" = x ; then
312 edhill 1.43 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 edhill 1.24 else
318     $MAKE adall >> make.log 2>&1
319     fi
320 edhill 1.1 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 edhill 1.20 echo successful 1>&2
328 edhill 1.1 fi
329     fi
330     )
331     }
332    
333 edhill 1.27 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 edhill 1.45
344 edhill 1.27 # 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 edhill 1.45 #echo Linking $name to $i
359 edhill 1.27 (cd $BUILD_DIR; ln -sf ../$code_dir/$i $name)
360     fi
361     fi
362     done
363     else
364 edhill 1.45 # NO: We undo any _mpi symbolically linked files
365 edhill 1.27 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 edhill 1.45 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 edhill 1.27 rm -f $BUILD_DIR/$name
374     fi
375     fi
376     done
377     fi
378    
379     }
380    
381 edhill 1.1 linkdata()
382     {
383     # linkdata flag
384     #
385     # symbolically link data files to run directory
386 edhill 1.12 if test "x$1" = x1 ; then
387     (
388     cd $2
389 edhill 1.24 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 edhill 1.12 )
411 edhill 1.1 fi
412     }
413    
414     runmodel()
415     {
416 edhill 1.6 # runmodel directory
417 edhill 1.1 #
418 edhill 1.24 # runs "$COMMAND in "directory"
419 edhill 1.6 # (where "$COMMAND" is relative to "directory")
420 edhill 1.1 (
421     cd $1
422 edhill 1.20 printf 'runmodel ... ' 1>&2
423 edhill 1.6 # make output.txt
424 edhill 1.38 echo
425 edhill 1.39 # echo "COMMAND='$COMMAND'"
426     # echo "pwd='"`pwd`"'"
427 edhill 1.38 ( eval $COMMAND ) >> run.log 2>&1
428 edhill 1.6 RETVAL=$?
429     if test "x$RETVAL" = x0 ; then
430 edhill 1.20 echo successful 1>&2
431 edhill 1.44 # === Reduce the size of the testing emails!
432     # if test "x$ADM" = x ; then
433     # cp output.txt $CDIR"/output.txt"
434     # else
435     # cp output.txt_adm $CDIR"/output.txt_adm"
436     # fi
437 edhill 1.6 return 0
438     else
439 edhill 1.20 tail run.log
440     echo failed 1>&2
441     cp run.log $CDIR"/run.log"
442 edhill 1.6 return 1
443 edhill 1.1 fi
444     )
445     }
446    
447     createcodelet()
448     {
449     # create codelet for comparing model output
450    
451 edhill 1.34 printf "creating the comparison code... "
452 edhill 1.22 cat > tmp_cmpnum.c <<EOF
453     #include <stdio.h>
454     #include <math.h>
455     int main( int argc, char** argv ) {
456 adcroft 1.33 int linnum,best,lncnt;
457 edhill 1.22 double a,b,diff;
458     best = -16;
459 adcroft 1.33 lncnt = 0;
460     while( 1 & (lncnt+=1) < 999 ) {
461 edhill 1.22 scanf("%d", &linnum);
462     if (linnum == -1) break;
463     scanf("%lf", &a); scanf("%lf", &b);
464     diff = 0.5*(fabs(a)+fabs(b));
465     if (diff > 1.e-12) {
466     diff=fabs(a-b)/diff;
467     if (diff > 0.0) {
468     linnum = (int)log10(diff);
469     best = (best > linnum) ? best : linnum;
470     }
471     else {
472     if (best == -16 && diff != 0) best = -22;
473     }
474     }
475     }
476 adcroft 1.33 if (lncnt == 999) best=-29;
477 edhill 1.22 printf("%d\n", -best);
478     return 0;
479     }
480     EOF
481     cc -o tmp_cmpnum tmp_cmpnum.c -lm
482 edhill 1.1
483 edhill 1.22 if [ -x ./tmp_cmpnum ]; then
484 edhill 1.1 echo "OK"
485     return 0
486     else
487     echo
488 edhill 1.21 echo "ERROR: failed to compile comparison code"
489 edhill 1.1 exit 1
490     fi
491     }
492    
493     formatresults()
494     {
495     # formatresults expt genmake depend make run results*
496    
497     nm=$1
498     printf '%s %s %s %s' $2 $3 $4 $5
499     shift; shift; shift; shift; shift;
500     printf '%3s' $@
501    
502     if [ $1 = '--' ]; then
503     printf ' N/O '
504     else
505     if [ $1 -gt 12 ]; then
506     printf ' pass'
507     else
508     printf ' FAIL'
509     fi
510     fi
511     printf ' %s' $nm
512     printf '\n'
513    
514     }
515    
516     show_help()
517     {
518     cat - << EOF
519     $0 [-help] [-quick] [-verbose] dir1 [dir2] [...]
520 edhill 1.10
521     -help|-h Show this help message
522 edhill 1.1 -quiet Reduce the amount of output
523     -verbose Produce copious amounts of output
524     -debug Produce even more output which will mean nothing to most
525     -force Do "make CLEAN" before compiling. This forces a complete rebuild.
526     -clean Do "make CLEAN" after compiling and testing.
527     -cleanup Aggresively removes all model output, executables and object files
528     and then exits. Use with care.
529    
530     Normal usage:
531     $0 * Configure, compile, run and analyze in all experiment directories
532     EOF
533     }
534    
535     scandirs()
536     {
537     if [ $# -eq 0 ]; then
538     for arg in * ; do
539     test -d $arg/input && echo $arg
540     done
541     else
542     echo $*
543     fi
544     }
545    
546    
547     ###############################################################################
548    
549    
550     # Default properties
551     debug=0
552     verbose=1
553     clean=0
554     expts=''
555 edhill 1.6 # ieee=1
556 edhill 1.10
557 edhill 1.40 IEEE=true
558 edhill 1.10 if test "x$MITGCM_IEEE" != x ; then
559     IEEE=$MITGCM_IEEE
560     fi
561    
562    
563     CLEANUP=f
564     QUICK=f
565     NOGENMAKE=f
566     NOCLEAN=f
567     NODEPEND=f
568 edhill 1.1
569 edhill 1.4 BASH=
570 edhill 1.10 OPTFILE=NONE
571     ADDRESSES=
572 edhill 1.1 TESTDIRS=
573     MPACKDIR="../tools/mpack-1.6"
574 edhill 1.20 HAVE_MPACK=
575 edhill 1.1 MPACK="$MPACKDIR/mpack"
576 edhill 1.24 COMMAND=
577 edhill 1.8 MAKE=make
578 edhill 1.43 JOBS=
579 edhill 1.7 MPI=f
580 edhill 1.40 DELDIR=
581 edhill 1.1
582 edhill 1.24 ADM=
583    
584 edhill 1.34 printf "parsing options... "
585 edhill 1.1
586     ac_prev=
587     for ac_option ; do
588    
589     # If the previous option needs an argument, assign it.
590     if test -n "$ac_prev"; then
591     eval "$ac_prev=\$ac_option"
592     ac_prev=
593     continue
594     fi
595    
596     ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
597    
598     case $ac_option in
599    
600     -help | --help | -h | --h)
601     usage ;;
602    
603 edhill 1.2 -optfile | --optfile | -of | --of)
604 edhill 1.10 ac_prev=OPTFILE ;;
605 edhill 1.2 -optfile=* | --optfile=* | -of=* | --of=*)
606 edhill 1.10 OPTFILE=$ac_optarg ;;
607 edhill 1.1
608     -addr | --addr | -a | --a)
609     ac_prev=ADDRESSES ;;
610     -addr=* | --addr=*)
611     ADDRESSES=$ac_optarg ;;
612    
613     -tdir | --tdir | -t | --t)
614     ac_prev=TESTDIRS ;;
615     -tdir=* | --tdir=*)
616     TESTDIRS=$ac_optarg ;;
617 edhill 1.4
618     -bash | --bash | -b | --b)
619     ac_prev=BASH ;;
620     -bash=* | --bash=*)
621     BASH=$ac_optarg ;;
622 edhill 1.5
623 edhill 1.6 -command | --command | -c | --c)
624     ac_prev=COMMAND ;;
625     -command=* | --command=*)
626     COMMAND=$ac_optarg ;;
627 edhill 1.8
628     -make | --make | -m | --m)
629     ac_prev=MAKE ;;
630     -make=* | --make=*)
631     MAKE=$ac_optarg ;;
632 edhill 1.1
633 edhill 1.43 -j) ac_prev=JOBS ;;
634     -j=*) JOBS=$ac_optarg ;;
635    
636 edhill 1.10 -clean | --clean)
637     CLEANUP=t ;;
638    
639     -quick | --quick | -q | --q)
640     QUICK=t ;;
641     -nogenmake | --nogenmake | -ng | --ng)
642     NOGENMAKE=t ;;
643     -noclean | --noclean | -nc | --nc)
644     NOCLEAN=t ;;
645     -nodepend | --nodepend | -nd | --nd)
646     NODEPEND=t ;;
647    
648 edhill 1.18 -mpi) MPI=t ;;
649 edhill 1.10
650 edhill 1.24 -adm | -ad) ADM=t ;;
651    
652 edhill 1.10 -ieee) IEEE=true ;;
653     -noieee) IEEE= ;;
654    
655 edhill 1.1 -verbose) verbose=2 ;;
656     -debug) debug=1 ;;
657     -quiet) verbose=0 ;;
658    
659 edhill 1.40 -deldir | -dd) DELDIR=t ;;
660    
661 edhill 1.1 -*)
662     echo "Error: unrecognized option: "$ac_option
663     usage
664     ;;
665    
666     *)
667     echo "Error: unrecognized argument: "$ac_option
668     usage
669     ;;
670    
671     esac
672    
673     done
674    
675 edhill 1.10 if test "x$QUICK" = xt ; then
676     NOGENMAKE=t
677     NOCLEAN=t
678     NODEPEND=t
679     fi
680    
681 edhill 1.1 if test "x$TESTDIRS" = x ; then
682     TESTDIRS=`scandirs`
683     fi
684    
685 edhill 1.10 if test "x$OPTFILE" = xNONE -a "x$MITGCM_OF" != x ; then
686     OPTFILE=$MITGCM_OF
687     fi
688    
689 edhill 1.24 if test "x$ADM" = xt -a "x$COMMAND" = x ; then
690     COMMAND="./mitgcmuv_ad > output.txt_adm 2>&1"
691     fi
692    
693     if test "x$COMMAND" = x ; then
694 edhill 1.45 COMMAND="$MAKE output.txt"
695 edhill 1.24 fi
696    
697 edhill 1.1 echo "OK"
698    
699     # create the FORTRAN comparison code
700     createcodelet
701    
702     # build the mpack utility
703 edhill 1.31 if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then
704 edhill 1.32 echo "skipping mpack build"
705     else
706 edhill 1.31 build_mpack
707     fi
708 edhill 1.1
709     # Create a uniquely named directory to store results
710     MACH=`hostname`
711 edhill 1.2 UNAMEA=`uname -a`
712 edhill 1.1 DATE=`date +%Y%m%d`
713 edhill 1.25 BASE="tr_"$MACH"_"$DATE"_"
714 edhill 1.1 DNUM=0
715     DRESULTS="$BASE$DNUM"
716     while test -e $DRESULTS ; do
717     DNUM=$(( $DNUM + 1 ))
718     DRESULTS="$BASE$DNUM"
719     done
720     mkdir $DRESULTS
721     RETVAL=$?
722     if test "x$RETVAL" != x0 ; then
723 edhill 1.20 echo "ERROR: Can't create results directory \"./$DRESULTS\""
724 edhill 1.1 exit 1
725     fi
726     SUMMARY="$DRESULTS/summary.txt"
727 edhill 1.34 printf "Start time: " >> $SUMMARY
728 edhill 1.16 start_date=`date`
729 edhill 1.17 echo $start_date > $SUMMARY
730 edhill 1.1
731 edhill 1.11 of_path=
732 edhill 1.10 if test "x$OPTFILE" != xNONE ; then
733     if test -r $OPTFILE ; then
734 edhill 1.11 # get the path
735     path=${OPTFILE%/*}
736     if test "x$path" = x ; then
737     of_path=`pwd`
738     else
739     of_path=`( cd $path > /dev/null 2>&1 ; pwd )`
740     fi
741     file=${OPTFILE##*/}
742     OPTFILE=$of_path/$file
743 edhill 1.21 cp $OPTFILE $DRESULTS
744     echo >> $SUMMARY
745     echo " OPTFILE=$OPTFILE" >> $SUMMARY
746 edhill 1.11 else
747 edhill 1.21 echo | tee $SUMMARY
748     echo "ERROR: can't read OPTFILE=\"$OPTFILE\"" | tee $SUMMARY
749     exit 1
750 edhill 1.10 fi
751 edhill 1.21 else
752     echo >> $SUMMARY
753     echo "No \"OPTFILE\" was explicitly specified by testreport," >> $SUMMARY
754     echo " so the genmake default will be used." >> $SUMMARY
755 edhill 1.10 fi
756     echo
757     echo >> $SUMMARY
758 edhill 1.24 if test "x$ADM" = x ; then
759     cat << EOF | tee -a $SUMMARY
760 edhill 1.21 T S U V
761     G D M c m s m s m s m s
762     E p a R g m m e . m m e . m m e . m m e .
763     N n k u 2 i a a d i a a d i a a d i a a d
764     2 d e n d n x n . n x n . n x n . n x n .
765    
766     EOF
767 edhill 1.24 else
768     echo "ADJOINT=true" >> $SUMMARY
769     echo >> $SUMMARY
770     cat << EOF | tee -a $SUMMARY
771     G D M C G
772     E p a R o r
773     N n k u s a
774     2 d e n t d
775    
776     EOF
777     fi
778 edhill 1.1
779 edhill 1.10 # ...and each test directory...
780     for dir in $TESTDIRS ; do
781    
782     # Cleanup only!
783     if test "x$CLEANUP" = xt ; then
784     if test -r $dir/build/Makefile ; then
785     ( cd $dir/build ; make CLEAN )
786     fi
787     if test -r $dir/input/Makefile ; then
788     ( cd $dir/input ; make CLEAN )
789     fi
790     continue
791 edhill 1.1 fi
792 edhill 1.3
793 edhill 1.10 # Verify that the testdir exists and contains previous
794     # results in the correct location--or skip this directory!
795 edhill 1.24 fout=
796     if test "x$ADM" = x ; then
797     fout=$dir"/results/output.txt"
798     else
799     fout=$dir"/results_ad/output.txt_adm"
800     fi
801     if test ! -r $fout ; then
802     echo "can't read \"$fout\" -- skipping $dir"
803 edhill 1.10 continue
804     fi
805 edhill 1.7
806 edhill 1.12 builddir="input"
807     rundir="input"
808     use_seperate_build=0
809     if test -d $dir/build -a -r $dir/build ; then
810     builddir="build"
811     rundir="build"
812     use_seperate_build=1
813     linkdata $use_seperate_build $dir/$rundir
814 edhill 1.10 fi
815    
816 edhill 1.34 # Check whether there are "extra runs" for this testdir
817     extra_runs=
818     if test "x$ADM" = x -a "x$use_seperate_build" = x1 ; then
819     ex_run_dirs=`( cd $dir ; echo input.* )`
820     echo "ex_run_dirs='$ex_run_dirs'"
821     for exd in $ex_run_dirs ; do
822     name=`echo $exd | sed -e 's/input.//g'`
823     outf="$dir/results/output.txt.$name"
824     if test -f $outf -a -r $outf ; then
825     extra_runs="$extra_runs $name"
826     fi
827     done
828     fi
829    
830 edhill 1.24 if test "x$ADM" = x ; then
831 edhill 1.27 code_dir=code
832 edhill 1.24 CODE_DIR=$dir/code
833     else
834 edhill 1.27 code_dir=code_ad
835 edhill 1.24 CODE_DIR=$dir/code_ad
836     fi
837 edhill 1.10 BUILD_DIR=$dir/$builddir
838 edhill 1.28
839 edhill 1.30 if test ! -r $CODE_DIR"/SIZE.h_mpi" -a "x$MPI" = "xt" ; then
840 edhill 1.28 echo "can't find \"$CODE_DIR/SIZE.h_mpi\" -- skipping $dir"
841     continue
842     fi
843    
844     echo "-------------------------------------------------------------------------------"
845     echo
846     echo "Experiment: $dir"
847     echo
848     unset genmake makedepend make run
849     results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --'
850 edhill 1.10
851     # Create an output dir for each OPTFILE/tdir combination
852 edhill 1.20 rel_CDIR=$DRESULTS"/"$dir
853     mkdir $rel_CDIR
854     CDIR=`pwd`"/$rel_CDIR"
855 edhill 1.10
856     if test "x$CLEANUP" = xt ; then
857     makeclean $dir/$builddir
858     else
859 edhill 1.1 genmakemodel $dir/$builddir && genmake=Y \
860     && makeclean $dir/$builddir \
861 edhill 1.27 && symlink_mpifiles $dir $code_dir $builddir \
862 edhill 1.1 && makedependmodel $dir/$builddir && makedepend=Y \
863     && makemodel $dir/$builddir && make=Y \
864 edhill 1.12 && linkdata $use_seperate_build $dir/$rundir \
865     && runmodel $dir/$rundir && run=Y \
866 edhill 1.1 && results=`testoutput $dir $rundir`
867 edhill 1.10 fi
868    
869     echo
870 edhill 1.24 if test "x$ADM" = x ; then
871     fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results`
872 edhill 1.34 echo
873     echo "$fres" >> $SUMMARY
874     echo "fresults='$fres'" > $CDIR"/summary.txt"
875     echo "MACH='$MACH'" >> $CDIR"/summary.txt"
876     echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"
877     echo "DATE='$DATE'" >> $CDIR"/summary.txt"
878     echo "tdir='$dir'" >> $CDIR"/summary.txt"
879    
880 edhill 1.35 OLD_COMMAND=$COMMAND
881     COMMAND="./mitgcmuv > output.txt"
882 edhill 1.34 for ex in $extra_runs ; do
883 jmc 1.42 test -e "$dir/tr_run.$ex" && rm -rf "$dir/tr_run.$ex"
884     mkdir "$dir/tr_run.$ex"
885 edhill 1.36 links=`( cd "$dir/input" > /dev/null 2>&1 ; ls -1 | grep -v CVS )`
886 edhill 1.34 (
887 jmc 1.42 cd "$dir/tr_run.$ex"
888 edhill 1.34 for i in $links; do
889     ln -s ../input/$i $i
890     done
891     )
892 edhill 1.36 links=`( cd "$dir/input.$ex" > /dev/null 2>&1 ; ls -1 | grep -v CVS )`
893 edhill 1.34 (
894 jmc 1.42 cd "$dir/tr_run.$ex"
895 edhill 1.34 for i in $links; do
896     test -e $i && rm -f $i
897     ln -s ../input.$ex/$i $i
898     done
899     ln -s ../$builddir/mitgcmuv mitgcmuv
900     )
901 jmc 1.42 runmodel $dir/tr_run.$ex && run=Y \
902     && results=`testoutput $dir tr_run.$ex "."$ex`
903 edhill 1.34 fres=`printf '%s %s %s %s' ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N}`
904     fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results`
905     fres="$fres.$ex"
906     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     done
914 edhill 1.35 COMMAND=$OLD_COMMAND
915 edhill 1.24 else
916     fres=`printf '%s %s %s %s' ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N}`
917     fres=$fres"$results $dir"
918 edhill 1.34 echo
919     echo "$fres" >> $SUMMARY
920     echo "fresults='$fres'" > $CDIR"/summary.txt"
921     echo "MACH='$MACH'" >> $CDIR"/summary.txt"
922     echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"
923     echo "DATE='$DATE'" >> $CDIR"/summary.txt"
924     echo "tdir='$dir'" >> $CDIR"/summary.txt"
925 edhill 1.24 fi
926 edhill 1.10
927     echo "-------------------------------------------------------------------------------"
928    
929 edhill 1.1 done
930    
931 edhill 1.34 printf "Start time: " >> $SUMMARY
932 edhill 1.16 echo $start_date >> $SUMMARY
933 edhill 1.34 printf "End time: " >> $SUMMARY
934 edhill 1.13 date >> $SUMMARY
935 edhill 1.20
936     # If addresses were supplied and mpack built successfully, then try
937     # to send email using mpack.
938     if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then
939     echo "No results email was sent."
940     else
941     if test "x$HAVE_MPACK" = xt ; then
942     tar -cf $DRESULTS".tar" $DRESULTS > /dev/null 2>&1 \
943     && gzip $DRESULTS".tar" \
944 edhill 1.44 && $MPACK -s MITgcm-test -m 3555000 $DRESULTS".tar.gz" $ADDRESSES
945 edhill 1.20 RETVAL=$?
946     if test "x$RETVAL" != x0 ; then
947     echo
948     echo "Warning: The tar, gzip, & mpack step failed. Please send email"
949     echo " to <MITgcm-support@mitgcm.org> for help. You may copy the "
950     echo " summary of results from the directory \"$DRESULTS\"."
951     echo
952     else
953     echo
954     echo "An email containing results was sent to the following addresses:"
955     echo " \"$ADDRESSES\""
956     echo
957     fi
958     test -f $DRESULTS".tar" && rm -f $DRESULTS".tar"
959     test -f $DRESULTS".tar.gz" && rm -f $DRESULTS".tar.gz"
960     fi
961     fi
962 edhill 1.13
963 edhill 1.22 # rm -f tmp_cmpnum.f a.out
964     rm -f tmp_cmpnum.c tmp_cmpnum
965 edhill 1.1
966 edhill 1.12 if test "x$CLEANUP" != xt ; then
967     cat $SUMMARY
968 edhill 1.25 if test -e tr_out.txt ; then
969     mv tr_out.txt tr_out.txt.old
970 edhill 1.14 fi
971 edhill 1.25 cat $SUMMARY > tr_out.txt
972 edhill 1.12 fi
973 edhill 1.1
974 edhill 1.40 if test "x$DELDIR" = xt ; then
975     rm -rf $DRESULTS
976     fi
977    

  ViewVC Help
Powered by ViewVC 1.1.22