/[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.53 - (hide annotations) (download)
Tue Dec 7 22:14:35 2004 UTC (19 years, 3 months ago) by edhill
Branch: MAIN
Changes since 1.52: +4 -2 lines
 o various fixes to the CVS repository due to the disk crash on 20041206

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

  ViewVC Help
Powered by ViewVC 1.1.22