/[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.91 - (hide annotations) (download)
Wed Sep 5 00:07:25 2007 UTC (16 years, 6 months ago) by jmc
Branch: MAIN
Changes since 1.90: +22 -16 lines
change comparison code to handle NAN when used for AD testing.

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

  ViewVC Help
Powered by ViewVC 1.1.22