/[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.89 - (hide annotations) (download)
Wed Jan 10 22:50:09 2007 UTC (13 years, 4 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint58u_post
Changes since 1.88: +36 -38 lines
add option: -skd|-skipdir to skip some test (usefull since full list is
 getting long);
remove "show_help" (not used, not up-to-date, was copied from testscript ?).

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

  ViewVC Help
Powered by ViewVC 1.1.22