/[MITgcm]/MITgcm_contrib/jmc_script/testreport
ViewVC logotype

Contents of /MITgcm_contrib/jmc_script/testreport

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


Revision 1.2 - (show annotations) (download)
Mon Feb 19 23:42:17 2007 UTC (17 years, 2 months ago) by jmc
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +1 -1 lines
FILE REMOVED
modifications have been added to the main script (MITgm/verification/testreport)

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

  ViewVC Help
Powered by ViewVC 1.1.22