/[MITgcm]/MITgcm/verification/testreport
ViewVC logotype

Contents of /MITgcm/verification/testreport

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.85 - (show annotations) (download)
Fri Jul 14 22:00:51 2006 UTC (17 years, 8 months ago) by jmc
Branch: MAIN
Changes since 1.84: +6 -6 lines
change multi-test output file name (from output.txt.{name} to output.{name}.txt)

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

  ViewVC Help
Powered by ViewVC 1.1.22