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

Annotation of /MITgcm/verification/testreport

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


Revision 1.88 - (hide annotations) (download)
Tue Aug 29 00:18:35 2006 UTC (17 years, 7 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint58r_post, checkpoint58t_post, checkpoint58q_post, checkpoint58s_post, checkpoint58p_post
Changes since 1.87: +21 -10 lines
check for "NORMAL END" in run.log

1 edhill 1.19 #! /usr/bin/env bash
2 edhill 1.1 #
3 jmc 1.88 # $Header: /u/gcmpack/MITgcm/verification/testreport,v 1.87 2006/07/31 20:48:41 jmc Exp $
4 edhill 1.12 # $Name: $
5 edhill 1.1 #
6    
7     usage()
8     {
9     echo
10     echo "Usage: $0 [OPTIONS]"
11     echo
12     echo "where possible OPTIONS are:"
13     echo " (-help|-h) print usage"
14 jmc 1.83 echo " (-mth) run multi threaded (using eedata.mth)"
15     echo " (-mpi) compile and run using MPI"
16 edhill 1.10 echo " (-ieee|-noieee) if possible, use IEEE compiler flags"
17 edhill 1.41 echo " (DEF=\"-ieee\")"
18 edhill 1.6 echo " (-optfile=|-of=)STRING list of optfiles to use"
19 edhill 1.20 echo " (-a|-addr) STRING list of email recipients"
20 edhill 1.6 echo " (DEF=\"edhill@mitgcm.org\")"
21 jmc 1.84 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 edhill 1.20 echo " (-b|-bash) STRING preferred location of a \"bash\" or"
25     echo " Bourne-compatible \"sh\" shell"
26     echo " (DEF=\"\" for \"bash\")"
27 edhill 1.24 echo " (-adm|-ad) perform an adjoint run"
28 edhill 1.20 echo " (-command) STRING command to run"
29 edhill 1.6 echo " (DEF=\"make output.txt\")"
30 edhill 1.20 echo " (-m|-make) STRING command to use for \"make\""
31 edhill 1.8 echo " (DEF=\"make\")"
32 jmc 1.70 echo " (-odir) STRING used to build output directory name"
33     echo " (DEF=\"hostname\")"
34 edhill 1.50 echo " (-ptracers|-ptr) STRING specify which ptracers to test"
35     echo " (DEF=\"1 2 3 4 5\")"
36 edhill 1.43 echo " (-j) JOBS use \"make -j JOBS\" for parallel builds"
37 edhill 1.10 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 edhill 1.40 echo " (-deldir|-dd) on success, delete the output directory"
43 edhill 1.6 echo
44 edhill 1.50 echo "and where STRING can be a whitespace-delimited list"
45 edhill 1.6 echo "such as:"
46 edhill 1.50 echo
47 edhill 1.6 echo " -t 'exp0 exp2 exp3' "
48     echo " -addr='abc@123.com testing@home.org'"
49 edhill 1.1 echo
50 edhill 1.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 edhill 1.1 exit 1
54     }
55    
56     # build the mpack utility
57     build_mpack()
58     {
59 edhill 1.34 printf "building the mpack utility... "
60 edhill 1.1 if test ! -x "$MPACKDIR/mpack" ; then
61     if test ! -d $MPACKDIR ; then
62 edhill 1.20 echo
63 edhill 1.1 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 edhill 1.20 echo
67     HAVE_MPACK=f
68 edhill 1.1 fi
69 edhill 1.34 printf "building mpack... "
70 edhill 1.26 if test "x$CC" = x ; then
71     export CC=cc
72     fi
73 edhill 1.25 ( cd $MPACKDIR && ./configure && $MAKE ) > tr_build_mpack.out 2>&1
74 edhill 1.1 RETVAL=$?
75     if test "x$RETVAL" != x0 ; then
76     echo
77     echo "Error building the mpack tools at: $MPACK_DIR"
78 edhill 1.20 echo
79     HAVE_MPACK=f
80     else
81 edhill 1.25 rm -f tr_build_mpack.out
82 edhill 1.20 HAVE_MPACK=t
83 edhill 1.1 fi
84 edhill 1.20 else
85     HAVE_MPACK=t
86 edhill 1.1 fi
87     echo "OK"
88     }
89    
90     testoutput_for_prop()
91     {
92 edhill 1.34 # testoutput_for_prop dir s1 label subdir extension
93 edhill 1.1 #
94 jmc 1.87 # compares files $dir/$subdir/$OUTPUTFILE and $dir/results/output.txt
95 edhill 1.1 # using search strings s1 and text label
96    
97     if [ $debug -gt 0 ]; then
98 jmc 1.87 echo testoutput_for_prop: grep "$2" $1/$4/$OUTPUTFILE 1>&2
99 edhill 1.1 fi
100 jmc 1.87 if [ -r $1/$4/$OUTPUTFILE ]; then
101     grep "$2" $1/$4/$OUTPUTFILE | sed 's/.*=//' | cat -n > tmp1.txt
102 jmc 1.67 lncntA=`wc -l tmp1.txt | awk '{print $1}' `
103     if [ $lncntA -lt 3 ]; then
104 edhill 1.1 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 jmc 1.87 echo testoutput_for_prop: $OUTPUTFILE from model run was not readable 1>&2
111 edhill 1.1 return 99
112     fi
113     if [ $debug -gt 0 ]; then
114 jmc 1.85 echo testoutput_for_prop: grep "$2" $1/results/output.$5 1>&2
115 edhill 1.1 fi
116 jmc 1.85 grep "$2" $1/results/output.$5 | sed 's/.*=//' | cat -n > tmp2.txt
117 jmc 1.67 lncntB=`wc -l tmp2.txt | awk '{print $1}' `
118     if [ $lncntB -lt 3 ]; then
119 edhill 1.1 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 jmc 1.67 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 edhill 1.72 has_nan=`cat tmp1.txt | grep -i nan | wc -l`
131     if [ $has_nan -gt 0 ] ; then
132 jmc 1.87 echo testoutput_for_prop: $OUTPUTFILE contains $has_nan NaN values 1>&2
133 edhill 1.72 return 99
134     fi
135     has_inf=`cat tmp1.txt | grep -i inf | wc -l`
136     if [ $has_inf -gt 0 ] ; then
137 jmc 1.87 echo testoutput_for_prop: $OUTPUTFILE contains $has_inf Inf values 1>&2
138 jmc 1.71 return 99
139     fi
140 edhill 1.1 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 edhill 1.22 if [ $verbose -gt 1 ]; then
148     cat tmp3.txt 1>&2
149     fi
150     echo "-1" >> tmp3.txt
151 edhill 1.23 # 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 edhill 1.1 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 edhill 1.23 rm -f tmp1.txt tmp2.txt tmp3.txt tmp4.txt
165 edhill 1.1
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 edhill 1.24 testoutput_ad()
185     {
186 jmc 1.78 grep $3 $1/results_ad/output_adm.txt | awk '{print NR " " $5}' > t05.txt
187 jmc 1.87 grep $3 $1/$2/$OUTPUTFILE | awk '{print NR " " $5}' > t15.txt
188 jmc 1.78 grep $3 $1/results_ad/output_adm.txt | awk '{print NR " " $6}' > t06.txt
189 jmc 1.87 grep $3 $1/$2/$OUTPUTFILE | awk '{print NR " " $6}' > t16.txt
190 edhill 1.24 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 edhill 1.49 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 edhill 1.50 for ii in $PTRACERS_NUM ; do
208     eval "HAVE_PTR0"$ii"=f"
209     done
210    
211 edhill 1.49 ptr_add="trcstat_ptracerXX_min trcstat_ptracerXX_max"
212     ptr_add="$ptr_add trcstat_ptracerXX_mean trcstat_ptracerXX_sd"
213 edhill 1.50 for ii in $PTRACERS_NUM ; do
214 edhill 1.49 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 edhill 1.1 testoutput()
226     {
227 edhill 1.34 # testoutput directory subdir extension
228 edhill 1.1 #
229     # test output in "directory"
230 edhill 1.24 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 edhill 1.34 testoutput_for_prop $1 "cg2d_init_res" "cg2d init. residual" $2 $3; cg2dres=$?
235 edhill 1.24 if [ $debug -gt 0 ]; then
236     echo testoutput: cg2dres=$cg2dres 1>&2
237     fi
238 edhill 1.34 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 edhill 1.49
255 edhill 1.50 # 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 edhill 1.49 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 edhill 1.24 else
287     testoutput_ad $1 $2 "precision_grdchk_result"
288 edhill 1.1 fi
289     }
290    
291     genmakemodel()
292     {
293     # genmakemodel directory
294 edhill 1.10 if test "x$NOGENMAKE" = xt ; then
295     echo "genmake skipped!"
296     else
297 edhill 1.34 if test "x$BASH" = x ; then
298     GENMAKE2="../../../tools/genmake2"
299     else
300     GENMAKE2="$BASH ../../../tools/genmake2 -bash $BASH"
301     fi
302 edhill 1.10 (
303     cd $1;
304 edhill 1.24 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 edhill 1.10 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 edhill 1.66 if test "x$MPI" = xt ; then
317     command="$command -mpi"
318     fi
319 edhill 1.10 printf 'genmake ... ' 1>&2
320     $command > make.log 2>&1
321     RETVAL=$?
322 edhill 1.44 # Reduce the size of the testing emails!
323 edhill 1.47 head -100 Makefile > $CDIR/Makefile_head
324 edhill 1.10 if test "x$RETVAL" != x0 ; then
325     tail make.log
326     echo "genmakemodel: genmake failed" 1>&2
327 edhill 1.21 cp genmake_* make.log $CDIR
328 edhill 1.10 return 1
329     else
330 edhill 1.20 echo "successful" 1>&2
331 edhill 1.1 fi
332 edhill 1.10 )
333     fi
334 edhill 1.1 }
335    
336     makeclean()
337     {
338     # makeclean directory
339 edhill 1.10 if test "x$NOCLEAN" = xt ; then
340 jmc 1.83 echo "make Clean skipped!"
341 edhill 1.10 else
342     (
343     cd $1;
344 jmc 1.87 #if test -e $OUTPUTFILE ; then rm -f $OUTPUTFILE ; fi
345 edhill 1.10 if test -r Makefile ; then
346 jmc 1.83 printf 'clean build-dir: make Clean ... ' 2>&1
347     $MAKE Clean >> make.log 2>&1
348 edhill 1.10 RETVAL=$?
349     if test "x$RETVAL" != x0 ; then
350     tail make.log
351 jmc 1.83 echo "makeclean: \"make Clean\" failed" 1>&2
352 edhill 1.10 cp make.log $CDIR"/make.log"
353     return 1
354     fi
355     fi
356 edhill 1.20 echo successful 1>&2
357 edhill 1.10 exit 0
358     )
359     fi
360     }
361    
362 jmc 1.83 run_clean()
363 edhill 1.68 {
364 jmc 1.83 # run_clean directory
365     if test "x$NOCLEAN" = xt ; then
366     echo "run_clean skipped!"
367     else
368 edhill 1.68 (
369     cd $1;
370 jmc 1.83 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 edhill 1.68 exit 0
380     )
381     fi
382     }
383    
384 edhill 1.10 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 edhill 1.1 RETVAL=$?
395     if test "x$RETVAL" != x0 ; then
396     tail make.log
397 edhill 1.10 echo "makedependmodel: make depend failed" 1>&2
398 edhill 1.1 cp make.log $CDIR"/make.log"
399     return 1
400 edhill 1.10 else
401 edhill 1.20 echo successful 1>&2
402 edhill 1.1 fi
403 edhill 1.10 )
404     fi
405 edhill 1.1 }
406    
407     makemodel()
408     {
409     # makemodel directory
410     (
411     cd $1;
412     if test -r Makefile ; then
413     printf 'make ... ' 1>&2
414 edhill 1.24 if test "x$ADM" = x ; then
415 edhill 1.43 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 edhill 1.24 else
421     $MAKE adall >> make.log 2>&1
422     fi
423 edhill 1.1 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 edhill 1.20 echo successful 1>&2
431 edhill 1.1 fi
432     fi
433     )
434     }
435    
436 edhill 1.27 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 edhill 1.45
447 edhill 1.27 # 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 edhill 1.45 #echo Linking $name to $i
462 edhill 1.27 (cd $BUILD_DIR; ln -sf ../$code_dir/$i $name)
463     fi
464     fi
465     done
466     else
467 edhill 1.45 # NO: We undo any _mpi symbolically linked files
468 edhill 1.27 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 edhill 1.45 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 edhill 1.27 rm -f $BUILD_DIR/$name
477     fi
478     fi
479     done
480     fi
481    
482     }
483    
484 edhill 1.1 linkdata()
485     {
486 jmc 1.83 # linkdata run_dir input_dir_1 input_dir_2 ...
487 edhill 1.1 #
488     # symbolically link data files to run directory
489 jmc 1.83 if test -d $1 ; then
490 edhill 1.12 (
491 jmc 1.83 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 edhill 1.24 fi
501 jmc 1.83 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 edhill 1.24 fi
521 jmc 1.83 printf ' ; ' 1>&2
522 jmc 1.82 fi
523 jmc 1.83 done
524 edhill 1.12 )
525 edhill 1.1 fi
526     }
527    
528     runmodel()
529     {
530 edhill 1.6 # runmodel directory
531 edhill 1.1 #
532 edhill 1.24 # runs "$COMMAND in "directory"
533 edhill 1.6 # (where "$COMMAND" is relative to "directory")
534 edhill 1.1 (
535     cd $1
536 jmc 1.75 printf 'runmodel in %s ...' $1 1>&2
537 edhill 1.6 # make output.txt
538 edhill 1.38 echo
539 jmc 1.83 if test ! -x $EXECUTABLE -a -x "../"$builddir"/"$EXECUTABLE ; then
540 jmc 1.88 echo " link" $EXECUTABLE "from dir ../"$builddir > run.log_00
541 jmc 1.83 ln -sf "../"$builddir"/"$EXECUTABLE .
542     fi
543     if test ! -x $EXECUTABLE ; then
544 jmc 1.88 rm -f run.log ; touch run.log
545     if test -f run.log_00 ; then cat run.log_00 >> run.log ; fi
546 jmc 1.83 echo " no executable:" $EXECUTABLE >> run.log
547     RETVAL=8
548 jmc 1.88 ENDVAL=-1
549 jmc 1.75 else
550 jmc 1.83 if test $OUTPUTFILE -ot $EXECUTABLE ; then
551 jmc 1.88 rm -f run.log ; touch run.log
552     if test -f run.log_00 ; then cat run.log_00 >> run.log ; fi
553 jmc 1.83 ( eval $COMMAND ) >> run.log 2>&1
554     RETVAL=$?
555     else
556     RETVAL=0
557 jmc 1.88 if test -f run.log ; then
558     if test -f run.log_00 ; then cat run.log_00 >> run.log ; fi
559     echo "---------->> $OUTPUTFILE is up to date " >> run.log 2>&1
560     else
561     touch run.log
562     if test -f run.log_00 ; then cat run.log_00 >> run.log ; fi
563     echo "---------->> $OUTPUTFILE is up to date " >> run.log 2>&1
564     echo " no previous run.log: assume NORMAL END" >> run.log 2>&1
565     fi
566 jmc 1.83 fi
567 jmc 1.88 ENDVAL=`cat run.log | grep -v 'ABNORMAL END' | grep -c 'NORMAL END'`
568 jmc 1.75 fi
569 jmc 1.88 rm -f run.log_00
570     #if test "x$RETVAL" = x0 ; then
571     if [ $RETVAL -eq 0 -a $ENDVAL -gt 0 ] ; then
572 jmc 1.46 tail run.log
573 edhill 1.20 echo successful 1>&2
574 edhill 1.44 # === Reduce the size of the testing emails!
575 jmc 1.87 #cp $OUTPUTFILE $CDIR"/"$OUTPUTFILE
576 jmc 1.48 if test -s STDERR.0000 ; then cp STDERR.0000 $CDIR"/STDERR.0000" ; fi
577 edhill 1.6 return 0
578     else
579 edhill 1.20 tail run.log
580 jmc 1.88 echo failed '(run:' $RETVAL ' end:' $ENDVAL ')' 1>&2
581 edhill 1.20 cp run.log $CDIR"/run.log"
582 jmc 1.48 if test -s STDERR.0000 ; then cp STDERR.0000 $CDIR"/STDERR.0000" ; fi
583 edhill 1.6 return 1
584 edhill 1.1 fi
585     )
586     }
587    
588     createcodelet()
589     {
590     # create codelet for comparing model output
591    
592 edhill 1.34 printf "creating the comparison code... "
593 edhill 1.22 cat > tmp_cmpnum.c <<EOF
594     #include <stdio.h>
595     #include <math.h>
596     int main( int argc, char** argv ) {
597 adcroft 1.33 int linnum,best,lncnt;
598 edhill 1.52 double a,b,abave,relerr;
599 jmc 1.57 best = -22;
600 adcroft 1.33 lncnt = 0;
601     while( 1 & (lncnt+=1) < 999 ) {
602 edhill 1.22 scanf("%d", &linnum);
603     if (linnum == -1) break;
604     scanf("%lf", &a); scanf("%lf", &b);
605 edhill 1.52 abave = 0.5*(fabs(a)+fabs(b));
606     if (abave > 0.0) {
607     relerr=fabs(a-b)/abave;
608 edhill 1.64 if (relerr > 0.0) { linnum = (int)rint(log10(relerr)); }
609 jmc 1.57 else { linnum = -16 ; }
610     best = (best > linnum) ? best : linnum;
611 edhill 1.22 }
612     }
613 adcroft 1.33 if (lncnt == 999) best=-29;
614 edhill 1.22 printf("%d\n", -best);
615     return 0;
616     }
617     EOF
618 edhill 1.58 $CC -o tmp_cmpnum tmp_cmpnum.c -lm
619 edhill 1.1
620 edhill 1.22 if [ -x ./tmp_cmpnum ]; then
621 edhill 1.1 echo "OK"
622     return 0
623     else
624     echo
625 edhill 1.58 echo "ERROR: failed to compile comparison code -- please specify"
626     echo " a C compiler using the CC environment variable."
627 edhill 1.1 exit 1
628     fi
629     }
630    
631     formatresults()
632     {
633     # formatresults expt genmake depend make run results*
634    
635     nm=$1
636     printf '%s %s %s %s' $2 $3 $4 $5
637     shift; shift; shift; shift; shift;
638     printf '%3s' $@
639    
640     if [ $1 = '--' ]; then
641     printf ' N/O '
642     else
643     if [ $1 -gt 12 ]; then
644     printf ' pass'
645     else
646     printf ' FAIL'
647     fi
648     fi
649     printf ' %s' $nm
650     printf '\n'
651    
652     }
653    
654     show_help()
655     {
656     cat - << EOF
657     $0 [-help] [-quick] [-verbose] dir1 [dir2] [...]
658 edhill 1.10
659     -help|-h Show this help message
660 edhill 1.1 -quiet Reduce the amount of output
661     -verbose Produce copious amounts of output
662     -debug Produce even more output which will mean nothing to most
663     -force Do "make CLEAN" before compiling. This forces a complete rebuild.
664     -clean Do "make CLEAN" after compiling and testing.
665     -cleanup Aggresively removes all model output, executables and object files
666     and then exits. Use with care.
667    
668     Normal usage:
669     $0 * Configure, compile, run and analyze in all experiment directories
670     EOF
671     }
672    
673     scandirs()
674     {
675 jmc 1.81 if [ $# -eq 1 ]; then
676     for arg in * ; do
677     test -d $arg/$1 && echo $arg
678     done
679 edhill 1.1 else
680 jmc 1.81 echo $*
681 edhill 1.1 fi
682     }
683    
684    
685     ###############################################################################
686    
687    
688     # Default properties
689     debug=0
690     verbose=1
691     clean=0
692     expts=''
693 edhill 1.6 # ieee=1
694 edhill 1.10
695 edhill 1.40 IEEE=true
696 edhill 1.10 if test "x$MITGCM_IEEE" != x ; then
697     IEEE=$MITGCM_IEEE
698     fi
699    
700    
701     CLEANUP=f
702     QUICK=f
703     NOGENMAKE=f
704     NOCLEAN=f
705     NODEPEND=f
706 edhill 1.68 POSTCLEAN=f
707 edhill 1.1
708 edhill 1.4 BASH=
709 edhill 1.10 OPTFILE=NONE
710     ADDRESSES=
711 edhill 1.1 TESTDIRS=
712     MPACKDIR="../tools/mpack-1.6"
713 edhill 1.20 HAVE_MPACK=
714 edhill 1.1 MPACK="$MPACKDIR/mpack"
715 edhill 1.24 COMMAND=
716 edhill 1.59 if test "x$MAKE" = x ; then
717     MAKE=make
718     fi
719     if test "x$CC" = x ; then
720     CC=cc
721     fi
722 edhill 1.43 JOBS=
723 edhill 1.7 MPI=f
724 jmc 1.83 MULTI_THREAD=f
725 jmc 1.70 OUTDIR=
726 edhill 1.40 DELDIR=
727 edhill 1.1
728 edhill 1.24 ADM=
729    
730 edhill 1.49 # Additional monitor types
731 edhill 1.50 PTRACERS_NUM="1 2 3 4 5"
732 edhill 1.49
733 edhill 1.34 printf "parsing options... "
734 edhill 1.1
735     ac_prev=
736     for ac_option ; do
737    
738     # If the previous option needs an argument, assign it.
739     if test -n "$ac_prev"; then
740     eval "$ac_prev=\$ac_option"
741     ac_prev=
742     continue
743     fi
744    
745     ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
746    
747     case $ac_option in
748    
749     -help | --help | -h | --h)
750     usage ;;
751    
752 edhill 1.2 -optfile | --optfile | -of | --of)
753 edhill 1.10 ac_prev=OPTFILE ;;
754 edhill 1.2 -optfile=* | --optfile=* | -of=* | --of=*)
755 edhill 1.10 OPTFILE=$ac_optarg ;;
756 edhill 1.1
757     -addr | --addr | -a | --a)
758     ac_prev=ADDRESSES ;;
759     -addr=* | --addr=*)
760     ADDRESSES=$ac_optarg ;;
761    
762     -tdir | --tdir | -t | --t)
763     ac_prev=TESTDIRS ;;
764     -tdir=* | --tdir=*)
765     TESTDIRS=$ac_optarg ;;
766 edhill 1.4
767     -bash | --bash | -b | --b)
768     ac_prev=BASH ;;
769     -bash=* | --bash=*)
770     BASH=$ac_optarg ;;
771 edhill 1.5
772 edhill 1.6 -command | --command | -c | --c)
773     ac_prev=COMMAND ;;
774     -command=* | --command=*)
775     COMMAND=$ac_optarg ;;
776 edhill 1.8
777     -make | --make | -m | --m)
778     ac_prev=MAKE ;;
779     -make=* | --make=*)
780     MAKE=$ac_optarg ;;
781 edhill 1.1
782 jmc 1.70 -odir | --odir)
783     ac_prev=OUTDIR ;;
784     -odir=* | --odir=*)
785     OUTDIR=$ac_optarg ;;
786    
787 edhill 1.50 -ptracers | --ptracers | -ptr | --ptr)
788     ac_prev=PTRACERS_NUM ;;
789     -ptracers=* | --ptracers=* | -ptr=* | --ptr=*)
790     PTRACERS_NUM=$ac_optarg ;;
791    
792 edhill 1.43 -j) ac_prev=JOBS ;;
793     -j=*) JOBS=$ac_optarg ;;
794    
795 edhill 1.10 -clean | --clean)
796 jmc 1.69 CLEANUP=t ; DELDIR=t ;;
797 edhill 1.10
798     -quick | --quick | -q | --q)
799     QUICK=t ;;
800     -nogenmake | --nogenmake | -ng | --ng)
801     NOGENMAKE=t ;;
802     -noclean | --noclean | -nc | --nc)
803     NOCLEAN=t ;;
804     -nodepend | --nodepend | -nd | --nd)
805     NODEPEND=t ;;
806    
807 edhill 1.68 -postclean | --postclean | -pc | --pc)
808     POSTCLEAN=t ;;
809    
810 edhill 1.18 -mpi) MPI=t ;;
811 edhill 1.10
812 jmc 1.83 -mth) MULTI_THREAD=t ;;
813    
814 edhill 1.24 -adm | -ad) ADM=t ;;
815    
816 edhill 1.10 -ieee) IEEE=true ;;
817     -noieee) IEEE= ;;
818    
819 edhill 1.1 -verbose) verbose=2 ;;
820     -debug) debug=1 ;;
821     -quiet) verbose=0 ;;
822    
823 edhill 1.40 -deldir | -dd) DELDIR=t ;;
824    
825 edhill 1.1 -*)
826     echo "Error: unrecognized option: "$ac_option
827     usage
828     ;;
829    
830     *)
831     echo "Error: unrecognized argument: "$ac_option
832     usage
833     ;;
834    
835     esac
836    
837     done
838    
839 edhill 1.10 if test "x$QUICK" = xt ; then
840     NOGENMAKE=t
841     NOCLEAN=t
842     NODEPEND=t
843     fi
844    
845 edhill 1.1 if test "x$TESTDIRS" = x ; then
846 jmc 1.81 if test "x$ADM" = xt ; then
847     TESTDIRS=`scandirs results_ad`
848     else
849     TESTDIRS=`scandirs results`
850     fi
851 jmc 1.84 else
852     #- expand group of experiments:
853     LIST=" "
854     for xx in $TESTDIRS
855     do
856     case $xx in
857 jmc 1.86 'basic') LIST=${LIST}" aim.5l_cs hs94.128x64x5 ideal_2D_oce"
858     LIST=${LIST}" lab_sea tutorial_baroclinic_gyre"
859     LIST=${LIST}" tutorial_global_oce_latlon tutorial_plume_on_slope"
860 jmc 1.84 ;;
861     'tutorials')
862     LIST=${LIST}" "`ls | grep 'tutorial_'` ;;
863     *) LIST=${LIST}" "$xx ;;
864     esac
865     done
866     #echo 'LIST='${LIST}'<'
867     #- remove duplicate and non-directory:
868     TESTDIRS=" "
869     for xx in $LIST
870     do
871     if test -d $xx ; then
872     yy=`echo $TESTDIRS | grep -c $xx`
873     if test $yy = 0 ; then TESTDIRS=${TESTDIRS}" "$xx ; fi
874     else
875     echo " -- skip \"$xx\" : not a directory !"
876     fi
877     done
878 edhill 1.1 fi
879 jmc 1.84 #echo 'TESTDIRS='${TESTDIRS}'<'
880 edhill 1.1
881 edhill 1.10 if test "x$OPTFILE" = xNONE -a "x$MITGCM_OF" != x ; then
882     OPTFILE=$MITGCM_OF
883     fi
884    
885 jmc 1.76 if test "x$ADM" = xt ; then
886     EXECUTABLE="mitgcmuv_ad"
887 jmc 1.78 OUTPUTFILE="output_adm.txt"
888 jmc 1.76 else
889     EXECUTABLE="mitgcmuv"
890     OUTPUTFILE="output.txt"
891     fi
892    
893 jmc 1.87 if test "x$COMMAND" = x ; then
894 jmc 1.77 COMMAND="./$EXECUTABLE > $OUTPUTFILE"
895 edhill 1.24 fi
896 jmc 1.87 if test "x$MPI" = xt ; then
897     OUTPUTFILE="STDOUT.0000"
898 edhill 1.24 fi
899    
900 jmc 1.76 #echo "OK"
901     echo "OK (COMMAND= $COMMAND )"
902 edhill 1.1
903     # create the FORTRAN comparison code
904     createcodelet
905    
906     # build the mpack utility
907 edhill 1.31 if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then
908 edhill 1.32 echo "skipping mpack build"
909     else
910 edhill 1.31 build_mpack
911     fi
912 edhill 1.1
913     # Create a uniquely named directory to store results
914     MACH=`hostname`
915 edhill 1.2 UNAMEA=`uname -a`
916 edhill 1.1 DATE=`date +%Y%m%d`
917 edhill 1.25 BASE="tr_"$MACH"_"$DATE"_"
918 jmc 1.70 if test "x$OUTDIR" != x ; then
919     BASE="tr_"$OUTDIR"_"$DATE"_"
920     fi
921 edhill 1.1 DNUM=0
922     DRESULTS="$BASE$DNUM"
923     while test -e $DRESULTS ; do
924     DNUM=$(( $DNUM + 1 ))
925     DRESULTS="$BASE$DNUM"
926     done
927     mkdir $DRESULTS
928     RETVAL=$?
929     if test "x$RETVAL" != x0 ; then
930 edhill 1.20 echo "ERROR: Can't create results directory \"./$DRESULTS\""
931 edhill 1.1 exit 1
932     fi
933     SUMMARY="$DRESULTS/summary.txt"
934 edhill 1.34 printf "Start time: " >> $SUMMARY
935 edhill 1.16 start_date=`date`
936 edhill 1.17 echo $start_date > $SUMMARY
937 edhill 1.1
938 edhill 1.11 of_path=
939 edhill 1.10 if test "x$OPTFILE" != xNONE ; then
940     if test -r $OPTFILE ; then
941 edhill 1.11 # get the path
942     path=${OPTFILE%/*}
943     if test "x$path" = x ; then
944     of_path=`pwd`
945     else
946     of_path=`( cd $path > /dev/null 2>&1 ; pwd )`
947     fi
948     file=${OPTFILE##*/}
949     OPTFILE=$of_path/$file
950 edhill 1.21 cp $OPTFILE $DRESULTS
951     echo >> $SUMMARY
952     echo " OPTFILE=$OPTFILE" >> $SUMMARY
953 edhill 1.11 else
954 edhill 1.21 echo | tee $SUMMARY
955     echo "ERROR: can't read OPTFILE=\"$OPTFILE\"" | tee $SUMMARY
956     exit 1
957 edhill 1.10 fi
958 edhill 1.21 else
959     echo >> $SUMMARY
960     echo "No \"OPTFILE\" was explicitly specified by testreport," >> $SUMMARY
961     echo " so the genmake default will be used." >> $SUMMARY
962 edhill 1.10 fi
963     echo
964     echo >> $SUMMARY
965 edhill 1.24 if test "x$ADM" = x ; then
966 edhill 1.49 line_0=" ----T----- ----S----- ----U----- ----V-----"
967     line_1="G D M c m s m s m s m s"
968     line_2="E p a R g m m e . m m e . m m e . m m e ."
969     line_3="N n k u 2 i a a d i a a d i a a d i a a d"
970     line_4="2 d e n d n x n . n x n . n x n . n x n ."
971 edhill 1.50 for ii in $PTRACERS_NUM ; do
972 edhill 1.49 # tst=`eval 'echo $HAVE_PTR0'$ii`
973     # if test "x$tst" = xt ; then
974     line_0="$line_0 --PTR 0"$ii"--"
975     line_1="$line_1 m s"
976     line_2="$line_2 m m e ."
977     line_3="$line_3 i a a d"
978     line_4="$line_4 n x n ."
979     # fi
980     done
981     echo "$line_0" | tee -a $SUMMARY
982     echo "$line_1" | tee -a $SUMMARY
983     echo "$line_2" | tee -a $SUMMARY
984     echo "$line_3" | tee -a $SUMMARY
985     echo "$line_4" | tee -a $SUMMARY
986     echo " " | tee -a $SUMMARY
987 edhill 1.24 else
988     echo "ADJOINT=true" >> $SUMMARY
989     echo >> $SUMMARY
990     cat << EOF | tee -a $SUMMARY
991     G D M C G
992     E p a R o r
993     N n k u s a
994     2 d e n t d
995    
996     EOF
997     fi
998 edhill 1.1
999 edhill 1.10 # ...and each test directory...
1000     for dir in $TESTDIRS ; do
1001    
1002     # Cleanup only!
1003     if test "x$CLEANUP" = xt ; then
1004     if test -r $dir/build/Makefile ; then
1005 jmc 1.83 echo ' ------ clean dir:' $dir/build
1006 edhill 1.10 ( cd $dir/build ; make CLEAN )
1007     fi
1008 jmc 1.83 if test -d $dir/run/CVS ; then
1009     echo ' ------ clean dir:' $dir/run
1010     run_clean $dir/run
1011 edhill 1.10 fi
1012 edhill 1.62 (
1013     cd $dir
1014     rm -rf tr_run.*
1015     )
1016 edhill 1.10 continue
1017 edhill 1.1 fi
1018 edhill 1.3
1019 edhill 1.10 # Verify that the testdir exists and contains previous
1020     # results in the correct location--or skip this directory!
1021 edhill 1.24 fout=
1022     if test "x$ADM" = x ; then
1023     fout=$dir"/results/output.txt"
1024     else
1025 jmc 1.78 fout=$dir"/results_ad/output_adm.txt"
1026 edhill 1.24 fi
1027     if test ! -r $fout ; then
1028     echo "can't read \"$fout\" -- skipping $dir"
1029 edhill 1.10 continue
1030     fi
1031 edhill 1.53 if test "x$ADM" = x ; then
1032     check_for_add_mon_output $fout
1033     fi
1034 edhill 1.7
1035 edhill 1.49 # Check for additional types of monitor output
1036    
1037 jmc 1.83 builddir="build"
1038     if test ! -d $dir/$builddir ; then mkdir $dir/$builddir ; fi
1039     rundir="run"
1040     #rundir=$builddir
1041     if test ! -d $dir/$rundir ; then
1042     rundir=$builddir
1043 edhill 1.10 fi
1044    
1045 edhill 1.24 if test "x$ADM" = x ; then
1046 edhill 1.27 code_dir=code
1047 edhill 1.24 CODE_DIR=$dir/code
1048 jmc 1.83 input_dirs='input'
1049 edhill 1.24 else
1050 edhill 1.27 code_dir=code_ad
1051 edhill 1.24 CODE_DIR=$dir/code_ad
1052 jmc 1.83 input_dirs='input_ad input'
1053 edhill 1.24 fi
1054 edhill 1.10 BUILD_DIR=$dir/$builddir
1055 edhill 1.28
1056 edhill 1.30 if test ! -r $CODE_DIR"/SIZE.h_mpi" -a "x$MPI" = "xt" ; then
1057 edhill 1.28 echo "can't find \"$CODE_DIR/SIZE.h_mpi\" -- skipping $dir"
1058     continue
1059     fi
1060 jmc 1.83 if test ! -r $dir"/input/eedata.mth" -a "x$MULTI_THREAD" = "xt" ; then
1061     echo "can't find \"$dir/input/eedata.mth\" -- skipping $dir"
1062     continue
1063     fi
1064    
1065     # Check whether there are "extra runs" for this testdir
1066     extra_runs=
1067     if test "x$ADM" = x ; then
1068     ex_run_dirs=`( cd $dir ; echo input.* )`
1069     #echo "ex_run_dirs='$ex_run_dirs'"
1070     for exd in $ex_run_dirs ; do
1071     name=`echo $exd | sed -e 's/input.//g'`
1072 jmc 1.85 outf="$dir/results/output.$name.txt"
1073 jmc 1.83 if test -f $outf -a -r $outf ; then
1074     if test "x$MULTI_THREAD" = "xt" ; then
1075     if test -r $dir"/"$exd"/eedata.mth" ; then
1076     extra_runs="$extra_runs $name"
1077     #else echo $dir"/"$exd"/eedata.mth: not found"
1078     fi
1079     else
1080     extra_runs="$extra_runs $name"
1081     fi
1082     fi
1083     done
1084     fi
1085 edhill 1.28
1086     echo "-------------------------------------------------------------------------------"
1087     echo
1088 jmc 1.83 if test "x$extra_runs" = "x" ; then
1089     echo "Experiment: $dir"
1090     else
1091     echo "Experiment: $dir ; extra_runs=$extra_runs"
1092     fi
1093 edhill 1.28 echo
1094     unset genmake makedepend make run
1095 jmc 1.73 results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --'
1096 edhill 1.10
1097     # Create an output dir for each OPTFILE/tdir combination
1098 edhill 1.20 rel_CDIR=$DRESULTS"/"$dir
1099     mkdir $rel_CDIR
1100     CDIR=`pwd`"/$rel_CDIR"
1101 edhill 1.10
1102     if test "x$CLEANUP" = xt ; then
1103 jmc 1.83 echo '====>>> this is to check that we never go through this part <<< ==='
1104     makeclean $dir/$builddir \
1105     && run_clean $dir/$rundir
1106 edhill 1.10 else
1107 edhill 1.1 genmakemodel $dir/$builddir && genmake=Y \
1108     && makeclean $dir/$builddir \
1109 jmc 1.83 && run_clean $dir/$rundir \
1110 edhill 1.27 && symlink_mpifiles $dir $code_dir $builddir \
1111 edhill 1.1 && makedependmodel $dir/$builddir && makedepend=Y \
1112     && makemodel $dir/$builddir && make=Y \
1113 jmc 1.83 && linkdata $dir/$rundir $input_dirs \
1114 edhill 1.12 && runmodel $dir/$rundir && run=Y \
1115 jmc 1.85 && results=`testoutput $dir $rundir "txt"`
1116 edhill 1.10 fi
1117    
1118     echo
1119 edhill 1.24 if test "x$ADM" = x ; then
1120     fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results`
1121 edhill 1.34 echo
1122     echo "$fres" >> $SUMMARY
1123     echo "fresults='$fres'" > $CDIR"/summary.txt"
1124     echo "MACH='$MACH'" >> $CDIR"/summary.txt"
1125     echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"
1126     echo "DATE='$DATE'" >> $CDIR"/summary.txt"
1127     echo "tdir='$dir'" >> $CDIR"/summary.txt"
1128    
1129     for ex in $extra_runs ; do
1130 jmc 1.73 unset run
1131     results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --'
1132     # Create an output dir for each OPTFILE/tdir.ex combination
1133     rel_CDIR=$DRESULTS"/"$dir"."$ex
1134     mkdir $rel_CDIR
1135     CDIR=`pwd`"/$rel_CDIR"
1136 edhill 1.61 test ! -e "$dir/tr_run.$ex" && mkdir "$dir/tr_run.$ex"
1137 jmc 1.83 run_clean $dir/tr_run.$ex
1138     linkdata $dir/tr_run.$ex input.$ex input
1139 jmc 1.42 runmodel $dir/tr_run.$ex && run=Y \
1140 jmc 1.85 && results=`testoutput $dir tr_run.$ex ${ex}".txt"`
1141 edhill 1.34 fres=`printf '%s %s %s %s' ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N}`
1142     fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results`
1143     fres="$fres.$ex"
1144     echo
1145     echo "$fres" >> $SUMMARY
1146     echo "fresults='$fres'" > $CDIR"/summary.txt"
1147     echo "MACH='$MACH'" >> $CDIR"/summary.txt"
1148     echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"
1149     echo "DATE='$DATE'" >> $CDIR"/summary.txt"
1150 jmc 1.73 echo "tdir='$dir.$ex'" >> $CDIR"/summary.txt"
1151 jmc 1.83 if test "x$POSTCLEAN" = xt ; then
1152     run_clean $dir/tr_run.$ex
1153     fi
1154 edhill 1.34 done
1155 edhill 1.24 else
1156     fres=`printf '%s %s %s %s' ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N}`
1157     fres=$fres"$results $dir"
1158 edhill 1.34 echo
1159     echo "$fres" >> $SUMMARY
1160     echo "fresults='$fres'" > $CDIR"/summary.txt"
1161     echo "MACH='$MACH'" >> $CDIR"/summary.txt"
1162     echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"
1163     echo "DATE='$DATE'" >> $CDIR"/summary.txt"
1164     echo "tdir='$dir'" >> $CDIR"/summary.txt"
1165 jmc 1.77 grep -A3 'Seconds in section "ALL' $dir/$rundir/$OUTPUTFILE \
1166     >> $CDIR"/summary.txt"
1167 edhill 1.24 fi
1168 edhill 1.68
1169 jmc 1.83 #postclean $dir/$builddir
1170     if test "x$POSTCLEAN" = xt ; then
1171     makeclean $dir/$builddir \
1172     && run_clean $dir/$rundir
1173     fi
1174 edhill 1.10
1175     echo "-------------------------------------------------------------------------------"
1176    
1177 edhill 1.1 done
1178    
1179 edhill 1.34 printf "Start time: " >> $SUMMARY
1180 edhill 1.16 echo $start_date >> $SUMMARY
1181 edhill 1.34 printf "End time: " >> $SUMMARY
1182 edhill 1.13 date >> $SUMMARY
1183 edhill 1.20
1184     # If addresses were supplied and mpack built successfully, then try
1185     # to send email using mpack.
1186     if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then
1187     echo "No results email was sent."
1188     else
1189     if test "x$HAVE_MPACK" = xt ; then
1190     tar -cf $DRESULTS".tar" $DRESULTS > /dev/null 2>&1 \
1191     && gzip $DRESULTS".tar" \
1192 edhill 1.44 && $MPACK -s MITgcm-test -m 3555000 $DRESULTS".tar.gz" $ADDRESSES
1193 edhill 1.20 RETVAL=$?
1194     if test "x$RETVAL" != x0 ; then
1195     echo
1196     echo "Warning: The tar, gzip, & mpack step failed. Please send email"
1197     echo " to <MITgcm-support@mitgcm.org> for help. You may copy the "
1198     echo " summary of results from the directory \"$DRESULTS\"."
1199     echo
1200     else
1201     echo
1202     echo "An email containing results was sent to the following addresses:"
1203     echo " \"$ADDRESSES\""
1204     echo
1205     fi
1206     test -f $DRESULTS".tar" && rm -f $DRESULTS".tar"
1207     test -f $DRESULTS".tar.gz" && rm -f $DRESULTS".tar.gz"
1208     fi
1209     fi
1210 edhill 1.13
1211 edhill 1.22 # rm -f tmp_cmpnum.f a.out
1212     rm -f tmp_cmpnum.c tmp_cmpnum
1213 edhill 1.1
1214 edhill 1.12 if test "x$CLEANUP" != xt ; then
1215 jmc 1.65 cat $SUMMARY | sed 's/ -- -- -- --//g'
1216 edhill 1.25 if test -e tr_out.txt ; then
1217     mv tr_out.txt tr_out.txt.old
1218 edhill 1.14 fi
1219 jmc 1.65 cat $SUMMARY | sed 's/ -- -- -- --//g' > tr_out.txt
1220 edhill 1.12 fi
1221 edhill 1.1
1222 edhill 1.40 if test "x$DELDIR" = xt ; then
1223     rm -rf $DRESULTS
1224     fi
1225    

  ViewVC Help
Powered by ViewVC 1.1.22