/[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.49 - (hide annotations) (download)
Tue Nov 23 21:25:24 2004 UTC (19 years, 4 months ago) by edhill
Branch: MAIN
Changes since 1.48: +75 -11 lines
 o add PTRACERS (PTR0[1-5]) to testreport output

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

  ViewVC Help
Powered by ViewVC 1.1.22