/[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.67 - (hide annotations) (download)
Sun Feb 6 16:58:08 2005 UTC (19 years, 1 month ago) by jmc
Branch: MAIN
CVS Tags: checkpoint57d_post, checkpoint57g_post, checkpoint57e_post, checkpoint57g_pre, checkpoint57f_pre, eckpoint57e_pre, checkpoint57h_done, checkpoint57f_post, checkpoint57h_pre, checkpoint57h_post
Changes since 1.66: +11 -5 lines
check for same number of lines in the output files

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

  ViewVC Help
Powered by ViewVC 1.1.22