/[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.90 - (show annotations) (download)
Wed Jan 31 21:28:34 2007 UTC (14 years, 3 months ago) by ce107
Branch: MAIN
CVS Tags: checkpoint58w_post, checkpoint58x_post, checkpoint59e, checkpoint59d, checkpoint59f, checkpoint59a, checkpoint59c, checkpoint59b, checkpoint59, checkpoint58y_post, checkpoint58v_post
Changes since 1.89: +25 -6 lines
Added support for timing and performance per timestep reporting

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

  ViewVC Help
Powered by ViewVC 1.1.22