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

Contents of /MITgcm/verification/testreport

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


Revision 1.159 - (show annotations) (download)
Tue Mar 29 02:20:22 2011 UTC (9 years, 1 month ago) by jmc
Branch: MAIN
Changes since 1.158: +8 -3 lines
improve error report at make stage.

1 #! /usr/bin/env bash
2 #
3 # $Header: /u/gcmpack/MITgcm/verification/testreport,v 1.158 2011/01/27 18:20:38 jmc Exp $
4 # $Name: $
5 #
6
7 usage()
8 {
9 echo
10 echo "Usage: $0 [OPTIONS]"
11 echo
12 echo "where possible OPTIONS are:"
13 echo " (-help|-h) print usage"
14 echo " (-mth) run multi-threaded (using eedata.mth)"
15 echo " (-mpi) use MPI to compile and run on 2 processors"
16 echo " (-MPI) NUMBER use MPI to compile and run on max NUMBER procs"
17 echo " (-mfile|-mf) STRING MPI: file with list of possible machines to run on"
18 echo " (-ieee/-noieee) if possible, use IEEE compiler flags"
19 echo " (DEF=\"-ieee\")"
20 echo " (-gsl) compile with \"-gsl\" flag"
21 echo " (-use_r4|-ur4) if allowed, use real*4 type for '_RS' variable"
22 echo " (-optfile|-of) STRING list of optfiles to use"
23 echo " (-addr|-a) STRING list of email recipients"
24 echo " (DEF=\"\" no email is sent)"
25 echo " (-mpackdir|-mpd) DIR location of the mpack utility"
26 echo " (DEF=\"../tools/mpack-1.6\")"
27 echo " (-tdir|-t) STRING list of group and/or exp. dirs to test"
28 echo " (recognized groups: basic, tutorials)"
29 echo " (DEF=\"\" which test all)"
30 echo " (if list= 'start_from THIS_EXP' then"
31 echo " test THIS_EXP + all the following)"
32 echo " (-skipdir|-skd) STRING list of exp. dirs to skip"
33 echo " (DEF=\"\" which test all)"
34 echo " (-bash|-b) STRING preferred location of a \"bash\" or"
35 echo " Bourne-compatible \"sh\" shell"
36 echo " (DEF=\"\" for \"bash\")"
37 echo " (-adm|-ad) perform an adjoint run"
38 echo " (-oad) perform an OpenAD adjoint run"
39 echo " (-command|-c) STRING command to run"
40 echo " (-makedepend|-md) STRING command to use for \"makedepend\""
41 echo " (-make|-m) STRING command to use for \"make\""
42 echo " (DEF=\"make\")"
43 echo " (-odir) STRING used to build output directory name"
44 echo " (DEF=\"hostname\")"
45 # echo " (-ptracers|-ptr) STRING specify which ptracers to test"
46 # echo " (DEF=\"1 2 3 4 5\")"
47 echo " (-match) NUMBER Matching Criteria (number of digits)"
48 echo " (DEF=\"$MATCH_CRIT\")"
49 echo " (-j) JOBS use \"make -j JOBS\" for parallel builds"
50 echo " (-clean) *ONLY* run \"make CLEAN\" & clean run-dir"
51 echo " (-norun|-nr) skip the \"runmodel\" stage (stop after make)"
52 echo " (-runonly|-ro) *ONLY* run stage (=\"-quick\" without make)"
53 echo " (-quick|-q) same as \"-nogenmake -noclean -nodepend\""
54 echo " (-nogenmake|-ng) skip the genmake stage"
55 echo " (-noclean|-nc) skip the \"make clean\" stage"
56 echo " (-nodepend|-nd) skip the \"make depend\" stage"
57 echo " (-postclean|-pc) after each exp. test, clean build-dir & run-dir"
58 echo " (-deloutp|-do) delete output files after successful run"
59 echo " (-deldir|-dd) on success, delete the output directory"
60 echo " (-ts) provide timing information per timestep"
61 echo " (-papis) provide MFlop/s per timestep using PAPI"
62 echo " (-pcls) provide MFlop/s per timestep using PCL"
63 echo
64 echo "and where STRING can be a whitespace-delimited list"
65 echo "such as:"
66 echo
67 echo " -t 'exp0 exp2 exp3' "
68 echo " -addr='abc@123.com testing@home.org'"
69 echo
70 echo "provided that the expression is properly quoted within the current"
71 echo "shell (note the use of single quotes to protect white space)."
72 echo
73 exit 1
74 }
75
76 # build the mpack utility
77 build_mpack()
78 {
79 printf "building the mpack utility... "
80 MPACK="$MPACKDIR/mpack"
81 if test ! -x $MPACK ; then
82 if test ! -d $MPACKDIR ; then
83 echo
84 echo "Error: can't find \"$MPACKDIR\""
85 echo " are you sure this program is being run in the correct "
86 echo " (that is, \"MITGCM_ROOT\verification\") directory?"
87 echo
88 HAVE_MPACK=f
89 fi
90 if test "x$CC" = x ; then
91 export CC=cc
92 fi
93 printf "building mpack (using CC=$CC)... "
94 ( cd $MPACKDIR && ./configure && $MAKE ) > tr_build_mpack.out 2>&1
95 RETVAL=$?
96 if test "x$RETVAL" != x0 ; then
97 echo
98 echo "Error building the mpack tools at: $MPACK_DIR"
99 echo
100 HAVE_MPACK=f
101 else
102 rm -f tr_build_mpack.out
103 HAVE_MPACK=t
104 echo "done"
105 fi
106 else
107 HAVE_MPACK=t
108 echo "already exist"
109 fi
110 }
111
112 testoutput_var()
113 {
114 # testoutput_var dir s1 label subdir reference_output
115 #
116 # compares 1 variable output selected from file $dir/$subdir/$OUTPUTFILE
117 # with same output from reference file $dir/results/$reference_output
118 # using search strings s1 and text label
119
120 if [ $debug -gt 0 ]; then
121 echo testoutput_var: grep "$2" $1/$4/$OUTPUTFILE 1>&2
122 fi
123 if [ -r $1/$4/$OUTPUTFILE ]; then
124 grep "$2" $1/$4/$OUTPUTFILE | sed 's/.*=//' | cat -n > tmp1.txt
125 lncntA=`wc -l tmp1.txt | awk '{print $1}' `
126 if [ $lncntA -lt 2 ]; then
127 if [ $verbose -gt 0 ]; then
128 echo Not enough lines of output when searching for "$2" 1>&2
129 fi
130 return 99
131 fi
132 else
133 echo testoutput_var: $OUTPUTFILE from model run was not readable 1>&2
134 return 99
135 fi
136 if [ $debug -gt 0 ]; then
137 echo testoutput_var: grep "$2" $1/results/$5 1>&2
138 fi
139 grep "$2" $1/results/$5 | sed 's/.*=//' | cat -n > tmp2.txt
140 lncntB=`wc -l tmp2.txt | awk '{print $1}' `
141 if [ $lncntB -lt 2 ]; then
142 if [ $verbose -gt 0 ]; then
143 echo Not enough lines of output when searching for "$2" 1>&2
144 fi
145 return 99
146 fi
147 if [ $lncntA -ne $lncntB ]; then
148 if [ $verbose -gt 0 ]; then
149 echo Not same Nb of lines when searching for "$2" ":" $lncntA $lncntB 1>&2
150 fi
151 return 99
152 fi
153 has_nan=`cat tmp1.txt | grep -i nan | wc -l`
154 if [ $has_nan -gt 0 ] ; then
155 echo testoutput_var: $OUTPUTFILE contains $has_nan NaN values 1>&2
156 return 99
157 fi
158 has_inf=`cat tmp1.txt | grep -i inf | wc -l`
159 if [ $has_inf -gt 0 ] ; then
160 echo testoutput_var: $OUTPUTFILE contains $has_inf Inf values 1>&2
161 return 99
162 fi
163 if [ $debug -gt 0 ]; then
164 echo testoutput_var: join tmp1.txt tmp2.txt 1>&2
165 fi
166 join tmp1.txt tmp2.txt | awk '{print $1 " " $2 " " $3}' > tmp3.txt
167 if [ $debug -gt 0 ]; then
168 echo testoutput_var: compare_lines 1>&2
169 fi
170 if [ $verbose -gt 1 ]; then
171 cat tmp3.txt 1>&2
172 fi
173 echo "-1" >> tmp3.txt
174 # On the SGI O3K (*not* the O2K), "cat -n" inserts a ":" after the line number
175 cat tmp3.txt | sed -e 's|:||g' > tmp4.txt
176 digits_of_similarity=`./tr_cmpnum < tmp4.txt`
177 if [ $digits_of_similarity -eq 99 ]; then
178 if [ $verbose -gt 0 ]; then
179 echo testoutput_var: No comparison was available for \"$3\" 1>&2
180 fi
181 digits_of_similarity=99
182 else
183 if [ $verbose -gt 0 ]; then
184 echo There were $digits_of_similarity decimal places of similarity for \"$3\" 1>&2
185 fi
186 fi
187 rm -f tmp1.txt tmp2.txt tmp3.txt tmp4.txt
188
189 return $digits_of_similarity
190 }
191
192 testoutput_run()
193 {
194 # testoutput_run directory subdir reference_output
195 #
196 # test output from 1 run in "directory"
197 # --> same processing for adjoint & forward test
198 # default list of output variables to be checked:
199 # 1rst : main variable used to decide if it pass or FAIL
200 # others : number of matching digits to be printed in summary.txt
201 listChk=$DEF_CHECK_LIST
202 # load experiment-specific list from file "tr_checklist" (if it exist)
203 if test -r $1/$2/tr_checklist ; then listChk=`cat $1/$2/tr_checklist` ; fi
204 sVar=`echo $listChk | awk '{print $1}'`
205 # remove 1rst var and expand the list: + => min max mean s.d
206 listVar=`echo $listChk | sed 's/ [a-zA-Z0-9]*+/&mn &mx &av &sd/g' \
207 | sed 's/+//g' | sed "s/^$sVar//"`
208 if [ $debug -gt 0 ]; then echo "testoutput_run: listVar(I)='$listVar'" 1>&2 ; fi
209 # check for ptracer output in reference_output file :
210 outpref=$1/results/$3
211 ptr_mon="trcstat_ptracerXX_min trcstat_ptracerXX_max"
212 ptr_mon="$ptr_mon trcstat_ptracerXX_mean trcstat_ptracerXX_sd"
213 for ii in $PTRACERS_NUM ; do
214 ptrfound=0
215 for jj in $ptr_mon ; do
216 name=`eval "echo $jj | sed -e 's|XX|0"$ii"|g'"`
217 tst=`grep $name $outpref | wc -l | awk '{print $1}'`
218 if test ! "x$tst" = x0 ; then ptrfound=1 ; fi
219 done
220 if test $ptrfound = '1' ; then
221 eval "HAVE_PTR0"$ii"=t"
222 else
223 eval "HAVE_PTR0"$ii"=f"
224 if test "x$ADM" = x -a "x$OADM" = x; then
225 # remove this ptr from the list of output variable to check
226 # echo "-- ptr test=" $tst "number of var=" `echo $listVar | awk '{print NF}'` 1>&2
227 listVar=`echo "$listVar" | sed "s/ pt$ii..//g"`
228 fi
229 fi
230 # eval 'echo "HAVE_PTR0'$ii' = $HAVE_PTR0'$ii'"' 1>&2
231 done
232 tst=`echo $sVar $listVar | awk '{ for(i=2;i<=NF;i++){if($i==$1)t+=1}; print t }'`
233 if test $tst != 1 ; then
234 if test $tst = 0 ; then echo "==> WARNING: selected var >$sVar< not found" 1>&2
235 else echo "==> WARNING: found selected var >$sVar< $tst times" 1>&2 ; fi
236 echo "==> WARNING: in checked list:" $listVar 1>&2
237 #- put it back once:
238 listVar=" $sVar "`echo "$listVar " | sed "s/ $sVar / /g"`
239 fi
240 if [ $debug -gt 0 ]; then echo "testoutput_run: listVar(M)='$listVar'" 1>&2 ; fi
241 echo "listVar='$listVar'" >> $locDIR"/summary.txt"
242 #---
243 allargs=""
244 for xx in $listVar
245 do
246 case $xx in
247 'PS') if [ $debug -gt 0 ]
248 then echo testoutput_run: testoutput_var $1 cg2d_init_res 1>&2 ; fi
249 testoutput_var $1 "cg2d_init_res" "Press. Solver (cg2d)" $2 $3; yy=$?
250 if [ $debug -gt 0 ] ; then echo testoutput_run: cg2dres=$yy 1>&2 ; fi ;;
251 'Cost') testoutput_var $1 "ADM precision_derivative_cost" "ADM Cost" $2 $3; yy=$? ;;
252 'Grad') testoutput_var $1 "ADM precision_derivative_grad" "ADM Grad" $2 $3; yy=$? ;;
253 'Tmn') testoutput_var $1 "dynstat_theta_min" "Theta minimum" $2 $3; yy=$? ;;
254 'Tmx') testoutput_var $1 "dynstat_theta_max" "Theta maximum" $2 $3; yy=$? ;;
255 'Tav') testoutput_var $1 "dynstat_theta_mean" "Theta mean" $2 $3; yy=$? ;;
256 'Tsd') testoutput_var $1 "dynstat_theta_sd" "Theta Std.Dev" $2 $3; yy=$? ;;
257 'Smn') testoutput_var $1 "dynstat_salt_min" "Salt minimum" $2 $3; yy=$? ;;
258 'Smx') testoutput_var $1 "dynstat_salt_max" "Salt maximum" $2 $3; yy=$? ;;
259 'Sav') testoutput_var $1 "dynstat_salt_mean" "Salt mean" $2 $3; yy=$? ;;
260 'Ssd') testoutput_var $1 "dynstat_salt_sd" "Salt Std.Dev" $2 $3; yy=$? ;;
261 'Umn') testoutput_var $1 "dynstat_uvel_min" "U minimum" $2 $3; yy=$? ;;
262 'Umx') testoutput_var $1 "dynstat_uvel_max" "U maximum" $2 $3; yy=$? ;;
263 'Uav') testoutput_var $1 "dynstat_uvel_mean" "U mean" $2 $3; yy=$? ;;
264 'Usd') testoutput_var $1 "dynstat_uvel_sd" "U Std.Dev" $2 $3; yy=$? ;;
265 'Vmn') testoutput_var $1 "dynstat_vvel_min" "V minimum" $2 $3; yy=$? ;;
266 'Vmx') testoutput_var $1 "dynstat_vvel_max" "V maximum" $2 $3; yy=$? ;;
267 'Vav') testoutput_var $1 "dynstat_vvel_mean" "V mean" $2 $3; yy=$? ;;
268 'Vsd') testoutput_var $1 "dynstat_vvel_sd" "V Std.Dev" $2 $3; yy=$? ;;
269 'pt1mn'|'pt2mn'|'pt3mn'|'pt4mn'|'pt5mn') ii=`echo $xx | sed 's/pt//' | sed 's/..$//'`
270 testoutput_var $1 "trcstat_ptracer0"$ii"_min" "p0"$ii"_min" $2 $3; yy=$? ;;
271 'pt1mx'|'pt2mx'|'pt3mx'|'pt4mx'|'pt5mx') ii=`echo $xx | sed 's/pt//' | sed 's/..$//'`
272 testoutput_var $1 "trcstat_ptracer0"$ii"_max" "p0"$ii"_max" $2 $3; yy=$? ;;
273 'pt1av'|'pt2av'|'pt3av'|'pt4av'|'pt5av') ii=`echo $xx | sed 's/pt//' | sed 's/..$//'`
274 testoutput_var $1 "trcstat_ptracer0"$ii"_mean" "p0"$ii"_mean" $2 $3; yy=$? ;;
275 'pt1sd'|'pt2sd'|'pt3sd'|'pt4sd'|'pt5sd') ii=`echo $xx | sed 's/pt//' | sed 's/..$//'`
276 testoutput_var $1 "trcstat_ptracer0"$ii"_sd" "p0"$ii"_StDv" $2 $3; yy=$? ;;
277 'Qntmn') testoutput_var $1 "forcing_qnet_min" "Qnet minimum" $2 $3; yy=$? ;;
278 'Qntmx') testoutput_var $1 "forcing_qnet_max" "Qnet maximum" $2 $3; yy=$? ;;
279 'Qntav') testoutput_var $1 "forcing_qnet_mean" "Qnet mean" $2 $3; yy=$? ;;
280 'Qntsd') testoutput_var $1 "forcing_qnet_sd" "Qnet Std.Dev" $2 $3; yy=$? ;;
281 'aSImn') testoutput_var $1 "seaice_area_min" "SIce Area min" $2 $3; yy=$? ;;
282 'aSImx') testoutput_var $1 "seaice_area_max" "SIce Area max" $2 $3; yy=$? ;;
283 'aSIav') testoutput_var $1 "seaice_area_mean" "SIce Area mean" $2 $3; yy=$? ;;
284 'aSIsd') testoutput_var $1 "seaice_area_sd" "SIce Area StDv" $2 $3; yy=$? ;;
285 'hSImn') testoutput_var $1 "seaice_heff_min" "SIce Heff min" $2 $3; yy=$? ;;
286 'hSImx') testoutput_var $1 "seaice_heff_max" "SIce Heff max" $2 $3; yy=$? ;;
287 'hSIav') testoutput_var $1 "seaice_heff_mean" "SIce Heff mean" $2 $3; yy=$? ;;
288 'hSIsd') testoutput_var $1 "seaice_heff_sd" "SIce Heff StDv" $2 $3; yy=$? ;;
289 'AthSiG') testoutput_var $1 "thSI_Ice_Area_G" "thSIc Area Global" $2 $3; yy=$? ;;
290 'AthSiS') testoutput_var $1 "thSI_Ice_Area_S" "thSIc Area South" $2 $3; yy=$? ;;
291 'AthSiN') testoutput_var $1 "thSI_Ice_Area_N" "thSIc Area North" $2 $3; yy=$? ;;
292 'HthSiG') testoutput_var $1 "thSI_IceH_ave_G" "thSIc H Global" $2 $3; yy=$? ;;
293 'HthSiS') testoutput_var $1 "thSI_IceH_ave_S" "thSIc H South" $2 $3; yy=$? ;;
294 'HthSiN') testoutput_var $1 "thSI_IceH_ave_N" "thSIc H North" $2 $3; yy=$? ;;
295 *) yy=99; echo "WARNING: asking for var=$xx : not recognized !" 1>&2 ;;
296 esac
297 if test $xx = $sVar
298 then allargs="$allargs > $yy <"
299 else allargs="$allargs $yy"
300 fi
301 done
302
303 nbVar=`echo $listVar | awk '{print NF}'`
304 if [ $nbVar -lt $LEN_CHECK_LIST ] ; then
305 #-- fill line (up to standard length) with dot:
306 adNul=`expr $LEN_CHECK_LIST - $nbVar | awk '{for(i=1;i<=$1;i++){print "."}}'`
307 echo $allargs $adNul
308 else
309 echo $allargs
310 fi
311 # <-- same processing for adjoint & forward test
312 }
313
314 genmakemodel()
315 {
316 # genmakemodel directory
317 if test "x$NOGENMAKE" = xt ; then
318 echo "genmake skipped!"
319 else
320 if test "x$BASH" = x ; then
321 GENMAKE2="../../../tools/genmake2"
322 else
323 GENMAKE2="$BASH ../../../tools/genmake2 -bash $BASH"
324 fi
325 (
326 cd $1;
327 command="$GENMAKE2 -ds -m $MAKE"
328 if test "x$MKDEPEND" != x ; then
329 command="$command -makedepend=$MKDEPEND"
330 fi
331 if test "x$ADM" = xt ; then
332 command="$command --mods=../code_ad"
333 elif test "x$OADM" = xt ; then
334 command="$command -adof ../../../tools/adjoint_options/adjoint_oad -mods '../code_oad ../../OpenAD/code_oad_all'"
335 else
336 command="$command -mods=../code"
337 fi
338 if test "x$OPTFILE" != xNONE ; then
339 command="$command -optfile=$OPTFILE"
340 fi
341 if test "x$IEEE" != x ; then
342 command="$command -ieee"
343 fi
344 if test "x$GSL" = xt ; then
345 command="$command -gsl"
346 fi
347 if test "x$MPI" != x0 ; then
348 command="$command -mpi"
349 fi
350 if test "x$MULTI_THREAD" = xt ; then
351 #- run multi-threaded using OpenMP:
352 command="$command -omp"
353 fi
354 if test "x$USE_R4" = xt ; then
355 command="$command -use_r4"
356 fi
357 if test "x$TS" = xt ; then
358 command="$command -ts"
359 fi
360 if test "x$PAPIS" = xt ; then
361 command="$command -papis"
362 else
363 if test "x$PCLS" = xt ; then
364 command="$command -pcls"
365 fi
366 fi
367 printf 'genmake ... '
368 eval $command > genmake.tr_log 2>&1
369 RETVAL=$?
370 # Reduce the size of the testing emails!
371 head -100 Makefile > $CDIR/Makefile_head
372 if test "x$RETVAL" != x0 ; then
373 tail genmake.tr_log
374 echo "genmakemodel: genmake failed"
375 cp genmake.log genmake_* genmake.tr_log $CDIR
376 return 1
377 else
378 echo "successful"
379 fi
380 )
381 fi
382 }
383
384 makeclean()
385 {
386 # makeclean directory
387 if test "x$NODEPEND" = xf ; then rm -f $1/make.tr_log ; fi
388 if test "x$NOCLEAN" = xt ; then
389 echo "make Clean skipped!"
390 else
391 (
392 cd $1;
393 #if test -e $OUTPUTFILE ; then rm -f $OUTPUTFILE ; fi
394 if test -r Makefile ; then
395 printf 'clean build-dir: make Clean ... '
396 $MAKE Clean >> make.tr_log 2>&1
397 RETVAL=$?
398 if test "x$RETVAL" != x0 ; then
399 tail make.tr_log
400 echo "makeclean: \"make Clean\" failed"
401 cp make.tr_log genmake.log genmake.tr_log $CDIR
402 return 1
403 fi
404 echo successful
405 else
406 echo ''
407 fi
408 exit 0
409 )
410 fi
411 }
412
413 run_clean()
414 {
415 # run_clean directory
416 if test "x$NOCLEAN" = xt ; then
417 echo "run_clean skipped!"
418 else
419 (
420 cd $1;
421 printf 'clean run-dir ... '
422 # part of what is done after "make clean" when doing "make CLEAN"
423 find . -name "*.meta" -exec rm {} \;
424 find . -name "*.data" -exec rm {} \;
425 find . -name "fort.*" -exec rm {} \;
426 find . -type l -exec rm {} \;
427 rm -f $EXECUTABLE $RUNLOG *.txt STD* *diagnostics.log datetime
428 rm -rf mnc_test_*
429 rm -f *_MIT_CE_000.opt0000 costfunction*0000
430 echo successful
431 exit 0
432 )
433 fi
434 }
435
436 makedependmodel()
437 {
438 # makedependmodel directory
439 if test "x$NODEPEND" = xt ; then
440 echo "make depend skipped!"
441 else
442 (
443 cd $1;
444 printf 'make depend ... '
445 $MAKE depend >> make.tr_log 2>&1
446 RETVAL=$?
447 if test "x$RETVAL" != x0 ; then
448 tail make.tr_log
449 echo "makedependmodel: make depend failed"
450 cp make.tr_log genmake.log genmake.tr_log $CDIR
451 return 1
452 else
453 echo successful
454 fi
455 )
456 fi
457 }
458
459 makemodel()
460 {
461 # makemodel directory
462 (
463 mk_fail=0
464 if test "x$NOMAKE" = xt ; then
465 cd $1;
466 if test -x $EXECUTABLE ; then
467 echo "make skipped!"
468 else
469 echo "no executable!"
470 mk_fail=3
471 fi
472 else
473 cd $1;
474 if test -r Makefile ; then
475 printf 'make ... '
476 if test "x$ADM" = xt ; then
477 $MAKE adall >> make.tr_log 2>&1
478 elif test "x$OADM" = xt ; then
479 $MAKE adAll >> make.tr_log 2>&1
480 else
481 if test "x$JOBS" = x ; then
482 $MAKE >> make.tr_log 2>&1
483 else
484 $MAKE -j $JOBS >> make.tr_log 2>&1
485 fi
486 fi
487 RETVAL=$?
488 if test "x$RETVAL" != x0 ; then
489 tail make.tr_log
490 echo failed
491 cp make.tr_log genmake.log genmake.tr_log $CDIR
492 rm -f $EXECUTABLE
493 mk_fail=1
494 else
495 echo successful
496 fi
497 else
498 echo "no Makefile !"
499 mk_fail=2
500 fi
501 fi
502 if test "x$ADM" = xt -a -f taf_ad.log ; then
503 head -1 taf_ad.log >> $CDIR"/summary.txt"
504 nerr=`grep -c 'TAF *.* ERROR ' taf_ad.log`
505 nwar=`grep -c 'TAF RECOMPUTATION *.* WARNING ' taf_ad.log`
506 echo " TAF reports $nerr Errors and $nwar Recomputation Warnings" \
507 >> $CDIR"/summary.txt"
508 fi
509 if test $mk_fail != 0 ; then return $mk_fail ; fi
510 )
511 }
512
513 mk_mpi_size()
514 {
515 # mk_mpi_size input_file output_file proc_Nb
516 #
517 # make new SIZE.h (=output_file) from SIZE.h_mpi (=input_file)
518 # for an MPI build with no more than proc_Nb processors ;
519 # return the effective number of processors.
520
521 inp=$1
522 out=$2
523 np=$3
524 tmp=TTT.$$
525
526 px=`grep "^ & *nPx *=" $inp | sed "s/^ & *nPx *= *//" | sed 's/, *$//'`
527 py=`grep "^ & *nPy *=" $inp | sed "s/^ & *nPy *= *//" | sed 's/, *$//'`
528 sx=`grep "^ & *nSx *=" $inp | sed "s/^ & *nSx *= *//" | sed 's/, *$//'`
529 sy=`grep "^ & *nSy *=" $inp | sed "s/^ & *nSy *= *//" | sed 's/, *$//'`
530
531 #- find the largest divisor of input_file proc Nb, but not larger than $np
532 pp=0
533 i=1
534 while [ $i -le $px ] ; do
535 if [ `expr $px % $i` -eq 0 ] ; then
536 j=1
537 while [ $j -le $py ] ; do
538 if [ `expr $py % $j` -eq 0 ] ; then
539 ij=`expr $i \* $j`
540 if [ $ij -gt $pp ] ; then
541 if [ $ij -le $np ] ; then
542 ix=$i ; jy=$j ; pp=$ij
543 #echo " ix,jy= $ix,$jy"
544 fi
545 fi
546 fi
547 j=`expr $j + 1`
548 done
549 fi
550 i=`expr $i + 1`
551 done
552
553 #- create new SIZE.h type file:
554 sx=`expr $sx \* $px / $ix`
555 sy=`expr $sy \* $py / $jy`
556 if [ $verbose -gt 1 ]; then
557 echo " px,py,np= $px,$py,$np : New MPI size: px,py= $ix,$jy : sx,sy= $sx,$sy"
558 fi
559 sed "/^ \& *nPx *=/s/[0-9]*,/$ix,/" $inp > $tmp
560 sed "/^ \& *nPy *=/s/[0-9]*,/$jy,/" $tmp > $out
561 sed "/^ \& *nSx *=/s/[0-9]*,/$sx,/" $out > $tmp
562 sed "/^ \& *nSy *=/s/[0-9]*,/$sy,/" $tmp > $out
563 rm -f $tmp
564 return $pp
565 }
566
567 symlink_mpifiles()
568 {
569 # Put special links so that MPI specific files are used
570 # This MUST be invoked between makeclean and makelinks because
571 # the Makefile will link to non-mpi files by default
572
573 dir=$1
574 code_dir=$2
575 build_dir=$dir/$3
576
577 # These are files that should replace their counter-part when using -mpi
578 MPI_FILES=`(cd $dir/$code_dir; find . -name "*_mpi" -print)`
579
580 for ii in $MPI_FILES ; do
581 i=`echo $ii | sed 's:^\./::'`
582 name=`echo $i | sed 's:_mpi::'`
583 file="../$code_dir/$i"
584 if test $name = 'SIZE.h' ; then file="SIZE.h.mpi" ; fi
585
586 # Is this an MPI run?
587 if test "x$MPI" = x0 ; then
588 # NO: We undo any _mpi symbolically linked files
589 if test -L $build_dir/$name ; then
590 ( cd $build_dir ; cmp $name $file > /dev/null 2>&1 )
591 RETVAL=$?
592 if test "x$RETVAL" = x0 ; then
593 if [ $verbose -gt 1 ]; then
594 echo " Un-linking $name from ../$code_dir" ; fi
595 rm -f $build_dir/$name
596 fi
597 fi
598 else
599 # YES: We symbolically link these files to the build
600 # dir so long as there is no real file in place
601 ( cd $build_dir ; cmp $name $file > /dev/null 2>&1 )
602 RETVAL=$?
603 if [ $verbose -gt 1 ]; then echo " cmp $name $file returns: $RETVAL" ; fi
604 if test "x$RETVAL" != x0 ; then
605 if test -h $build_dir/$name ; then rm -f $build_dir/$name ; fi
606 if test ! -r $build_dir/$name ; then
607 if [ $verbose -gt 1 ]; then echo " Linking $name to $file" ; fi
608 (cd $build_dir; ln -sf $file $name)
609 fi
610 fi
611 fi
612 done
613 }
614
615 linkdata()
616 {
617 # linkdata run_dir input_dir_1 input_dir_2 ...
618 #
619 # symbolically link data files to run directory
620 if test -d $1 ; then
621 (
622 cd $1 ; shift
623 echo 'linkdata from dirs:' $*
624 inpMPI=`(cd ../$1 ; find . -name "*.mpi" -print | sed 's:^\./::')`
625 for xx in $inpMPI ; do
626 if test -r "../"$1"/"$xx ; then
627 # found 1 _mpi sfx file in 1rst input dir and it is readable
628 yy=`echo $xx | sed 's:\.mpi$::'`
629 if test "x$MPI" = "x0" ; then
630 # not mpi test: remove symbolic link
631 if test -h $yy ; then rm -f $yy ; fi
632 else
633 # mpi test: remove symbolic link & link .mpi sfx file
634 if test -h $yy ; then rm -f $yy ; fi
635 if test ! -r $yy ; then
636 ln -sf "../"$1"/"$xx $yy ;
637 printf " $xx" 1>&2
638 fi
639 fi
640 fi
641 done
642 if test -r "../"$1"/eedata.mth" ; then
643 # found eedata.mth in 1rst input dir and it is readable
644 if test "x$MULTI_THREAD" = "xt" ; then
645 # multi-threaded test: remove symbolic link & link eedata.mth
646 if test -h eedata ; then rm -f eedata ; fi
647 if test ! -r eedata ; then
648 ln -sf "../"$1"/eedata.mth" eedata ;
649 printf ' eedata.mth' 1>&2
650 fi
651 else
652 # not multi-threaded test: remove eedata symbolic link
653 if test -h eedata ; then rm -f eedata ; fi
654 fi
655 fi
656 prevDir='NONE'
657 for ldir in $* ; do
658 if test -d "../"$ldir -a $ldir != $prevDir ; then
659 printf " ldir=${ldir}:" 1>&2
660 files=`( cd "../"$ldir ; ls -1 | grep -v CVS )`
661 for i in $files ; do
662 if test ! -d "../"$ldir/$i ; then
663 if test ! -r $i ; then
664 printf ' '$i 1>&2
665 ln -sf "../"$ldir"/"$i $i
666 fi
667 fi
668 done
669 printf ' ;' 1>&2
670 if test -x "../"$ldir"/"prepare_run ; then
671 "../"$ldir"/"prepare_run 1>&2
672 else
673 echo '' 1>&2
674 fi
675 fi
676 prevDir=$ldir
677 done
678 )
679 fi
680 }
681
682 runmodel()
683 {
684 # runmodel directory
685 #
686 # runs $COMMAND in "directory"
687 # (where "$COMMAND" is relative to "directory")
688 (
689 cd $1
690 printf 'runmodel in %s ... ' $1
691 if test "x$MPI" != x0 ; then
692 #- adjust the MPI run command with the right number of Procs
693 #echo '' ; echo " COMMAND='$COMMAND'"
694 COMMAND=`echo $COMMAND | sed "s/ TR_NPROC / $LOC_NPROC /"`
695 if test "x$MPI_MFILE" != x ; then
696 COMMAND=`echo $COMMAND | sed "s/ TR_MFILE / ..\/..\/$LOC_MFILE /"`
697 fi
698 #echo " COMMAND='$COMMAND'"
699 fi
700 if test -L $EXECUTABLE ; then
701 if test -x "../"$builddir"/"$EXECUTABLE ; then
702 cmp $EXECUTABLE "../"$builddir"/"$EXECUTABLE > /dev/null 2>&1
703 outD=$? ; if test "x$outD" != x0 ; then rm -f $EXECUTABLE ; fi
704 else rm -f $EXECUTABLE
705 fi
706 fi
707 if test ! -x $EXECUTABLE -a -x "../"$builddir"/"$EXECUTABLE ; then
708 echo " link" $EXECUTABLE "from dir ../"$builddir > run.log_tmp
709 ln -sf "../"$builddir"/"$EXECUTABLE .
710 fi
711 if test ! -x $EXECUTABLE ; then
712 rm -f $RUNLOG ; touch $RUNLOG
713 if test -f run.log_tmp ; then cat run.log_tmp >> $RUNLOG ; fi
714 echo " no executable:" $EXECUTABLE >> $RUNLOG
715 RETVAL=8
716 ENDVAL=-1
717 else
718 if test ! -f $OUTPUTFILE -o $OUTPUTFILE -ot $EXECUTABLE ; then
719 # output do not exist or is older than executable:
720 rm -f $RUNLOG ; touch $RUNLOG
721 if test -f run.log_tmp ; then cat run.log_tmp >> $RUNLOG ; fi
722 ( eval $COMMAND ) >> $RUNLOG 2>&1
723 RETVAL=$?
724 ENDVAL=`tail $OUTPUTFILE | grep -c 'PROGRAM MAIN: Execution ended Normally'`
725 if [ $POSTCLEAN -eq 1 -a $ENDVAL -gt 0 ] ; then
726 find . -name "*.meta" -exec rm {} \;
727 find . -name "*.data" -exec rm {} \;
728 rm -rf mnc_test_*
729 fi
730 else
731 RETVAL=0
732 ENDVAL=`tail $OUTPUTFILE | grep -c 'PROGRAM MAIN: Execution ended Normally'`
733 touch $RUNLOG
734 if test -f run.log_tmp ; then cat run.log_tmp >> $RUNLOG ; fi
735 echo "---------->> $OUTPUTFILE is up to date " >> $RUNLOG 2>&1
736 fi
737 fi
738 rm -f run.log_tmp
739 #- in all cases where OutputFile exists, report SIZE (and AD time)
740 if test -f $OUTPUTFILE ; then
741 grep '(PID\.TID 0000\.0001) n.. =' $OUTPUTFILE \
742 | sed 's/(PID.TID 0000.0001) //' >> $CDIR"/summary.txt"
743 if test "x$ADM" = xt ; then
744 grep -A3 'Seconds in section "ALL' $OUTPUTFILE >> $CDIR"/summary.txt"
745 fi
746 fi
747 if test -s STDERR.0000 ; then cp STDERR.0000 $CDIR"/STDERR.0000" ; fi
748 if [ $RETVAL -eq 0 -a $ENDVAL -gt 0 ] ; then
749 echo successful
750 printf '=> output from running in %s :\n' $1 1>&2
751 tail $RUNLOG | sed 's/^.*/> &/g' 1>&2
752 return 0
753 elif [ $RETVAL -ne 0 -a $ENDVAL -gt 0 ] ; then
754 #-- for some weird cases (run is finihed but with error code)
755 echo 'finished with error (run:' $RETVAL ' end:' $ENDVAL ')'
756 printf '=> output from running in %s :\n' $1 1>&2
757 tail $RUNLOG | sed 's/^.*/> &/g' 1>&2
758 return 0
759 else
760 echo 'failed (run:' $RETVAL ' end:' $ENDVAL ')'
761 printf '=> output from running in %s :\n' $1 1>&2
762 tail $RUNLOG | sed 's/^.*/> &/g' 1>&2
763 cp $RUNLOG $CDIR"/"$RUNLOG
764 return 1
765 fi
766 )
767 }
768
769 createcodelet()
770 {
771 # create codelet for comparing model output
772
773 printf "creating the comparison code (using CC=$CC)... "
774 cat > tr_cmpnum.c <<EOF
775 #include <stdio.h>
776 #include <math.h>
777 int main( int argc, char** argv ) {
778 int linnum,cmplin,best,lncnt;
779 double a,b,abave,relerr;
780 best = -22;
781 lncnt = 0;
782 while( 1 & ( (lncnt+=1) < 999 ) ) {
783 scanf("%d", &linnum);
784 if (linnum == -1) break;
785 scanf("%lf", &a); scanf("%lf", &b);
786 abave = 0.5*(fabs(a)+fabs(b));
787 if ( abave == abave ) {
788 if (abave > 0.0) {
789 relerr=fabs(a-b)/abave;
790 if (relerr > 0.0) { cmplin = (int)rint(log10(relerr)); }
791 else { cmplin = -16 ; }
792 best = (best > cmplin) ? best : cmplin; }
793 else { cmplin = -22 ; }
794 /* printf("%d ; %lf ; %lf\n",cmplin,a,b); */
795 }
796 else {
797 /* printf("%lf ; %lf ; %lf\n",abave,a,b); */
798 break; }
799 }
800 if (lncnt == 999) best=-29;
801 if (linnum != -1) best=-99;
802 printf("%d\n", -best);
803 return 0;
804 }
805 EOF
806 $CC -o tr_cmpnum tr_cmpnum.c -lm
807
808 if [ -x ./tr_cmpnum ]; then
809 echo "OK"
810 return 0
811 else
812 echo
813 echo "ERROR: failed to compile comparison code -- please specify"
814 echo " a C compiler using the CC environment variable."
815 exit 1
816 fi
817 }
818
819 formatresults()
820 {
821 # formatresults expt genmake depend make run results*
822
823 nm=$1
824 printf '%s %s %s %s' $2 $3 $4 $5
825 shift; shift; shift; shift; shift;
826 listPrt=$@
827 listRes=`echo $listPrt | sed 's/>//' | sed 's/<//'`
828 xx=`echo $listPrt | sed 's/.*>//' | sed 's/<.*//' | awk '{print $1}'`
829 printf '%3s' $listPrt
830 # line below does not work on hp-ux_ia64 : do those substitutions later on
831 # printf '%3s' $listPrt | sed 's/ 99/ --/g' | sed 's/ > />/' | sed 's/ < /</'
832
833 if [ $xx = '..' ]; then
834 printf ' N/O '
835 elif [ $xx = '--' ]; then
836 printf ' N/O '
837 elif [ $xx = 99 ]; then
838 printf ' N/O '
839 else
840 if [ $xx -ge $MATCH_CRIT ]; then
841 printf ' pass'
842 else
843 printf ' FAIL'
844 fi
845 fi
846 printf ' %s' $nm
847 printf '\n'
848
849 }
850
851 scandirs()
852 {
853 if [ $# -eq 1 ]; then
854 for arg in * ; do
855 test -f $arg/$1 && echo $arg
856 done
857 else
858 echo $*
859 fi
860 }
861
862
863 check_eedata()
864 {
865 # check_eedata size.h eedata
866 if [ $# -eq 2 ] ; then
867 if test -f $1 -a -f $2 ; then
868 sx=`grep "^ & *nSx *=" $1 | sed "s/^ & *nSx *=//" | sed 's/, *$//'`
869 nx=`grep "^ *nTx *=" $2 | tail -1 | sed 's/^ *nTx *= *//' | sed "s/, *$//"`
870 if test "x$nx" = x ; then
871 rx=10
872 else
873 rx=`expr $sx % $nx`
874 fi
875 sy=`grep "^ & *nSy *=" $1 | sed "s/^ & *nSy *=//" | sed 's/, *$//'`
876 ny=`grep "^ *nTy *=" $2 | tail -1 | sed 's/^ *nTy *= *//' | sed "s/, *$//"`
877 if test "x$ny" = x ; then
878 ry=20
879 else
880 ry=`expr $sy % $ny`
881 fi
882 echo `expr $rx + $ry`
883 else
884 echo '-1'
885 fi
886 else
887 echo '-2'
888 fi
889
890 }
891
892 ###############################################################################
893
894
895 # Default properties
896 debug=0
897 verbose=1
898
899 IEEE=true
900 if test "x$MITGCM_IEEE" != x ; then
901 IEEE=$MITGCM_IEEE
902 fi
903 GSL=f
904
905 CLEANUP=f
906 NORUN=f
907 QUICK=f
908 NOMAKE=f
909 NOGENMAKE=f
910 NOCLEAN=f
911 NODEPEND=f
912 POSTCLEAN=0
913
914 BASH=
915 OPTFILE=NONE
916 ADDRESSES=
917 TESTDIRS=
918 SKIPDIRS=
919 MPACKDIR="../tools/mpack-1.6"
920 HAVE_MPACK=
921 MPACK=
922 COMMAND=
923 MKDEPEND=
924 if test "x$MAKE" = x ; then
925 MAKE=make
926 fi
927 if test "x$CC" = x ; then
928 CC=cc
929 fi
930 JOBS=
931 MPI=0
932 MPI_MFILE=
933 MULTI_THREAD=f
934 OUTDIR=
935 DELDIR=
936 USE_R4=
937
938 ADM=
939 OADM=
940
941 # list of pTracers to check for monitor output
942 PTRACERS_NUM="1 2 3 4 5"
943
944 MATCH_CRIT=10
945
946 printf "parsing options... "
947
948 ac_prev=
949 for ac_option ; do
950
951 # If the previous option needs an argument, assign it.
952 if test -n "$ac_prev"; then
953 eval "$ac_prev=\$ac_option"
954 ac_prev=
955 continue
956 fi
957
958 ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
959
960 case $ac_option in
961
962 -help | --help | -h | --h) usage ;;
963
964 -optfile | --optfile | -of | --of) ac_prev=OPTFILE ;;
965 -optfile=* | --optfile=* | -of=* | --of=*) OPTFILE=$ac_optarg ;;
966
967 -addr | --addr | -a | --a) ac_prev=ADDRESSES ;;
968 -addr=* | --addr=* | -a=* | --a=*) ADDRESSES=$ac_optarg ;;
969 -mpackdir | --mpackdir | -mpd | --mpd) ac_prev=MPACKDIR ;;
970 -mpackdir=* | --mpackdir=* | -mpd=* | --mpd=*) MPACKDIR=$ac_optarg ;;
971
972 -tdir | --tdir | -t | --t) ac_prev=TESTDIRS ;;
973 -tdir=* | --tdir=* | -t=* | --t=*) TESTDIRS=$ac_optarg ;;
974 -skipdir | --skipdir | -skd | --skd) ac_prev=SKIPDIRS ;;
975 -skipdir=* | --skipdir=* | -skd=* | --skd=*) SKIPDIRS=$ac_optarg ;;
976
977 -bash | --bash | -b | --b) ac_prev=BASH ;;
978 -bash=* | --bash=* | -b=* | --b=*) BASH=$ac_optarg ;;
979
980 -command | --command | -c | --c) ac_prev=COMMAND ;;
981 -command=* | --command=* | -c=* | --c=*) COMMAND=$ac_optarg ;;
982
983 -makedepend | --makedepend | -md | --md) ac_prev=MKDEPEND ;;
984 -makedepend=* | --makedepend=* | -md=* | --md=*) MKDEPEND=$ac_optarg ;;
985
986 -make | --make | -m | --m) ac_prev=MAKE ;;
987 -make=* | --make=* | -m=* | --m=*) MAKE=$ac_optarg ;;
988
989 -odir | --odir) ac_prev=OUTDIR ;;
990 -odir=* | --odir=*) OUTDIR=$ac_optarg ;;
991
992 -ptracers | --ptracers | -ptr | --ptr) ac_prev=PTRACERS_NUM ;;
993 -ptracers=* | --ptracers=* | -ptr=* | --ptr=*) PTRACERS_NUM=$ac_optarg ;;
994
995 -match | --match ) ac_prev=MATCH_CRIT ;;
996 -match=* | --match=* ) MATCH_CRIT=$ac_optarg ;;
997
998 -j | --j) ac_prev=JOBS ;;
999 -j=* | --j=*) JOBS=$ac_optarg ;;
1000
1001 -clean | --clean) CLEANUP=t ; DELDIR=t ;;
1002
1003 -norun | --norun | -nr | --nr) NORUN=t ;;
1004 -runonly | --runonly | -ro | --ro) QUICK=t ; NOMAKE=t ;;
1005 -quick | --quick | -q | --q) QUICK=t ;;
1006 -nogenmake | --nogenmake | -ng | --ng) NOGENMAKE=t ;;
1007 -noclean | --noclean | -nc | --nc) NOCLEAN=t ;;
1008 -nodepend | --nodepend | -nd | --nd) NODEPEND=t ;;
1009
1010 -postclean | --postclean | -pc | --pc) POSTCLEAN=2 ;;
1011 -deloutp | --deloutp | -do | --do) POSTCLEAN=1 ;;
1012
1013 -mpi | --mpi) MPI=2 ;;
1014 -MPI | --MPI) ac_prev=MPI ;;
1015 -MPI=* | --MPI=*) MPI=$ac_optarg ;;
1016
1017 -mfile | --mfile | -mf | --mf) ac_prev=MPI_MFILE ;;
1018 -mfile=* | --mfile=* | -mf=* | --mf=*) MPI_MFILE=$ac_optarg ;;
1019
1020 -mth) MULTI_THREAD=t ;;
1021
1022 -adm | -ad) ADM=t ;;
1023 -oad) OADM=t; NODEPEND=t ;;
1024
1025 -ieee) IEEE=true ;;
1026 -noieee) IEEE= ;;
1027 -gsl) GSL=t ;;
1028
1029 -verbose) verbose=2 ;;
1030 -debug) debug=1 ;;
1031 -quiet) verbose=0 ;;
1032
1033 -deldir | -dd) DELDIR=t ;;
1034
1035 -use_r4|-ur4) USE_R4=t ;;
1036
1037 -ts) TS=t;;
1038 -papis) PAPIS=t;;
1039 -pcls) PCL=t;;
1040
1041 -*) echo "Error: unrecognized option: "$ac_option
1042 usage ;;
1043 *) echo "Error: unrecognized argument: "$ac_option
1044 usage ;;
1045
1046 esac
1047
1048 done
1049
1050 if test "x$QUICK" = xt ; then
1051 NOGENMAKE=t
1052 NOCLEAN=t
1053 NODEPEND=t
1054 fi
1055
1056 #- check length of MPI machine file:
1057 if test "x$MPI" != x0 -a "x$MPI_MFILE" != x ; then
1058 if test -r $MPI_MFILE ; then
1059 nl=`wc -l $MPI_MFILE | awk '{print $1}'`
1060 if [ $nl -lt $MPI ] ; then
1061 echo "Error: need at least $MPI nodes (currently only $nl) in MPI_MFILE=$MPI_FILE"
1062 usage
1063 fi
1064 if [ $verbose -gt 1 ]; then
1065 echo " MPI_MFILE=$MPI_MFILE : $nl procs for MPI=$MPI run"
1066 fi
1067 else
1068 echo "Error: cannot access MPI_MFILE=$MPI_FILE"
1069 usage
1070 fi
1071 fi
1072
1073 #- setting for forward or ADM testing
1074 if test "x$ADM" = xt ; then
1075 code_dir=code_ad
1076 inputdir=input_ad
1077 ref_outp="output_adm.txt"
1078 EXECUTABLE="mitgcmuv_ad"
1079 elif test "x$OADM" = xt ; then
1080 code_dir=code_oad
1081 inputdir=input_oad
1082 ref_outp="output_oadm.txt"
1083 EXECUTABLE="mitgcmuv_ad"
1084 else
1085 code_dir=code
1086 inputdir=input
1087 ref_outp="output.txt"
1088 EXECUTABLE="mitgcmuv"
1089 fi
1090
1091 xx=`echo $TESTDIRS | awk '{print $1}'`
1092 if test "x$TESTDIRS" = x ; then
1093 LIST=`scandirs results/$ref_outp`
1094 elif test $xx = 'start_from' ; then
1095 xx=`echo $TESTDIRS | awk '{print $2}'`
1096 LIST=`scandirs results/$ref_outp | sed -n "/$xx/,$ p"`
1097 else
1098 #- expand group of experiments:
1099 LIST=" "
1100 for xx in $TESTDIRS
1101 do
1102 case $xx in
1103 'basic') LIST=${LIST}" aim.5l_cs hs94.128x64x5 ideal_2D_oce"
1104 LIST=${LIST}" lab_sea tutorial_baroclinic_gyre"
1105 LIST=${LIST}" tutorial_global_oce_latlon tutorial_plume_on_slope"
1106 ;;
1107 'tutorials')
1108 LIST=${LIST}" "`ls | grep 'tutorial_'` ;;
1109 *) LIST=${LIST}" "$xx ;;
1110 esac
1111 done
1112 fi
1113 #echo 'LIST='${LIST}'<'
1114 #- skip dirs, remove duplicate and non-directory:
1115 TESTDIRS=" "
1116 count=0
1117 for xx in $LIST
1118 do
1119 yy=`echo $SKIPDIRS | grep -c $xx`
1120 if test $yy = 0 ; then
1121 if test -d $xx ; then
1122 yy=`echo $TESTDIRS | grep -c $xx`
1123 if test $yy = 0 ; then TESTDIRS=${TESTDIRS}" "$xx ; fi
1124 else count=1 ;
1125 echo ""; echo -n " -- skip \"$xx\" (not a directory !)"
1126 fi
1127 else
1128 if test $count = 1 ; then echo -n ", \"$xx\""
1129 else count=1 ; echo "" ; echo -n " skip: \"$xx\""
1130 fi
1131 fi
1132 done
1133 if test $count = 1 ; then echo "" ; echo -n " ... " ; fi
1134 #echo 'TESTDIRS='${TESTDIRS}'<'
1135
1136 if test "x$OPTFILE" = xNONE -a "x$MITGCM_OF" != x ; then
1137 OPTFILE=$MITGCM_OF
1138 fi
1139
1140 LOC_MFILE='tr_mpi_mfile'
1141 RUNLOG="run.tr_log"
1142 OUTPUTFILE=$ref_outp
1143 if test "x$COMMAND" = x ; then
1144 COMMAND="./$EXECUTABLE > $OUTPUTFILE"
1145 fi
1146 if test "x$MPI" != x0 ; then
1147 OUTPUTFILE="STDOUT.0000"
1148 fi
1149
1150 echo "OK (COMMAND= $COMMAND )"
1151
1152 # set the Default List of output variables to be checked:
1153 # (use default or load experiment-specific list from file "tr_checklist")
1154 # content : 1rst = main variable used to decide if it pass or FAIL
1155 # others = number of matching digits to be printed in summary.txt
1156 if test "x$ADM" = x -a "x$OADM" = x; then
1157 DEF_CHECK_LIST='PS PS T+ S+ U+ V+ pt1+ pt2+ pt3+ pt4+ pt5+'
1158 EMPTY_RESULTS='.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..'
1159 LEN_CHECK_LIST=`echo $DEF_CHECK_LIST | sed 's/ [a-zA-Z0-9]*+/&mn &mx &av &sd/g' | awk '{print NF-1}'`
1160 ii=`echo $EMPTY_RESULTS | awk '{print NF}'`
1161 EMPTY_RESULTS=$EMPTY_RESULTS`expr $LEN_CHECK_LIST - $ii | awk 'BEGIN{FS=":"}{for(i=1;i<=$1;i++){printf " ."}}'`
1162 else
1163 DEF_CHECK_LIST='Grad Cost Grad'
1164 EMPTY_RESULTS='.. ..'
1165 LEN_CHECK_LIST=`echo $DEF_CHECK_LIST | sed 's/ [a-zA-Z0-9]*+/&mn &mx &av &sd/g' | awk '{print NF-1}'`
1166 fi
1167
1168 # create the FORTRAN comparison code
1169 if test -x tr_cmpnum ; then
1170 echo "skipping comparison code build"
1171 else
1172 createcodelet
1173 fi
1174
1175 # build the mpack utility (if ADDRESSES = NONE, do it to test the build)
1176 if test "x$ADDRESSES" = x ; then
1177 echo "skipping mpack build"
1178 else
1179 build_mpack
1180 fi
1181
1182 # Create a uniquely named directory to store results
1183 CMDLINE=$0
1184 for xx in "$@" ; do nw=`echo $xx | wc -w`
1185 if test $nw = '1' ; then CMDLINE="$CMDLINE $xx"
1186 else CMDLINE="$CMDLINE '$xx'" ; fi
1187 done
1188 #for xx in "$@" ; do CMDLINE="$CMDLINE '$xx'" ; done
1189 MACH=`hostname`
1190 UNAMEA=`uname -a`
1191 DATE=`date +%Y%m%d`
1192 BASE="tr_"$MACH"_"$DATE"_"
1193 if test "x$OUTDIR" != x ; then
1194 BASE="tr_"$OUTDIR"_"$DATE"_"
1195 else
1196 short_name=`hostname | sed 's/\..*$//'`
1197 BASE="tr_"$short_name"_"$DATE"_"
1198 fi
1199 DNUM=0
1200 DRESULTS="$BASE$DNUM"
1201 while test -e $DRESULTS ; do
1202 DNUM=$(( $DNUM + 1 ))
1203 DRESULTS="$BASE$DNUM"
1204 done
1205 mkdir $DRESULTS
1206 RETVAL=$?
1207 if test "x$RETVAL" != x0 ; then
1208 echo "ERROR: Can't create results directory \"./$DRESULTS\""
1209 exit 1
1210 fi
1211 SUMMARY="$DRESULTS/summary.txt"
1212 start_date=`date`
1213 echo $start_date > $SUMMARY
1214 echo 'run:' $CMDLINE >> $SUMMARY
1215 echo 'on :' $UNAMEA >> $SUMMARY
1216
1217 of_path=
1218 if test "x$OPTFILE" != xNONE ; then
1219 if test -r $OPTFILE ; then
1220 # get the path
1221 path=${OPTFILE%/*}
1222 if test "x$path" = x ; then
1223 of_path=`pwd`
1224 else
1225 of_path=`( cd $path > /dev/null 2>&1 ; pwd )`
1226 fi
1227 file=${OPTFILE##*/}
1228 OPTFILE=$of_path/$file
1229 cp $OPTFILE $DRESULTS
1230 echo >> $SUMMARY
1231 echo " OPTFILE=$OPTFILE" >> $SUMMARY
1232 else
1233 echo | tee $SUMMARY
1234 echo "ERROR: can't read OPTFILE=\"$OPTFILE\"" | tee $SUMMARY
1235 exit 1
1236 fi
1237 else
1238 echo >> $SUMMARY
1239 echo "No \"OPTFILE\" was specified ; genmake2 found and uses:" >> $SUMMARY
1240 #-note: to be filled later after 1rst run
1241 fi
1242 echo
1243 echo >> $SUMMARY
1244 if test "x$ADM" = x -a "x$OADM" = x; then
1245 if [ $MATCH_CRIT -lt 10 ] ;
1246 then line_0="default "$MATCH_CRIT ;
1247 else line_0="default "$MATCH_CRIT ; fi
1248 line_0="$line_0 ----T----- ----S----- ----U----- ----V-----"
1249 line_1="G D M c m s m s m s m s"
1250 line_2="E p a R g m m e . m m e . m m e . m m e ."
1251 line_3="N n k u 2 i a a d i a a d i a a d i a a d"
1252 line_4="2 d e n d n x n . n x n . n x n . n x n ."
1253 for ii in $PTRACERS_NUM ; do
1254 line_0="$line_0 --PTR 0"$ii"--"
1255 line_1="$line_1 m s"
1256 line_2="$line_2 m m e ."
1257 line_3="$line_3 i a a d"
1258 line_4="$line_4 n x n ."
1259 done
1260 echo "$line_0" | tee -a $SUMMARY
1261 echo "$line_1" | tee -a $SUMMARY
1262 echo "$line_2" | tee -a $SUMMARY
1263 echo "$line_3" | tee -a $SUMMARY
1264 echo "$line_4" | tee -a $SUMMARY
1265 echo " " | tee -a $SUMMARY
1266 else
1267 echo "ADJOINT=true" >> $SUMMARY
1268 echo >> $SUMMARY
1269 if [ $MATCH_CRIT -lt 10 ] ;
1270 then line_0="default "$MATCH_CRIT ;
1271 else line_0="default "$MATCH_CRIT ; fi
1272 echo "$line_0" | tee -a $SUMMARY
1273 cat << EOF | tee -a $SUMMARY
1274 G D M C G
1275 E p a R o r
1276 N n k u s a
1277 2 d e n t d
1278
1279 EOF
1280 fi
1281 echo "-------------------------------------------------------------------------------"
1282
1283 # ...and each test directory...
1284 for dir in $TESTDIRS ; do
1285
1286 # set builddir & rundir:
1287 builddir="build"
1288 if test ! -d $dir/$builddir ; then mkdir $dir/$builddir ; fi
1289 rundir="run"
1290 pfxdir="tr_$rundir"
1291 if test ! -d $dir/$rundir ; then
1292 rundir=$builddir
1293 fi
1294 CODE_DIR=$dir/$code_dir
1295 BUILD_DIR=$dir/$builddir
1296
1297 # Cleanup only!
1298 if test "x$CLEANUP" = xt ; then
1299 echo -n ' --- dir:' $BUILD_DIR ': '
1300 makeclean $BUILD_DIR
1301 ( cd $BUILD_DIR
1302 rm -f $EXECUTABLE *.bak
1303 rm -f genmake_state genmake_*optfile genmake.log
1304 rm -f SIZE.h.mpi genmake.tr_log make.tr_log
1305 )
1306 if test -d $dir/$rundir/CVS ; then
1307 echo -n ' --- dir:' $dir/$rundir ': '
1308 run_clean $dir/$rundir
1309 fi
1310 trdir=`( cd $dir ; find . -type d -name "$pfxdir.*" -print | sed 's/^.\///')`
1311 ttd=`echo $trdir | wc -w`
1312 if test $ttd != 0 ; then
1313 echo ' --- rm dir:' $trdir
1314 ( cd $dir ; rm -rf $trdir )
1315 fi
1316 continue
1317 fi
1318
1319 # Verify that the testdir exists and contains previous
1320 # results in the correct location--or skip this directory!
1321 fout=$dir"/results/"$ref_outp
1322 if test ! -r $fout ; then
1323 echo "can't read \"$fout\" -- skipping $dir"
1324 continue
1325 fi
1326
1327 # Check for specific files for particular type of run
1328
1329 if test "x$MPI" != "x0" ; then
1330 if test -r $CODE_DIR"/SIZE.h_mpi" ; then
1331 #- create new SIZE.h with no more than '$MPI' Procs
1332 mk_mpi_size $CODE_DIR"/SIZE.h_mpi" $BUILD_DIR"/tr_size.mpi" $MPI
1333 LOC_NPROC=$?
1334 ( cd $BUILD_DIR
1335 if test -r SIZE.h.mpi ; then
1336 cmp tr_size.mpi SIZE.h.mpi > /dev/null 2>&1 ; RETVAL=$?
1337 else RETVAL=1
1338 fi
1339 if test "x$RETVAL" = x0 ; then
1340 rm -f tr_size.mpi
1341 else
1342 rm -f SIZE.h.mpi ; mv tr_size.mpi SIZE.h.mpi
1343 fi
1344 )
1345 else
1346 echo "can't find \"$CODE_DIR/SIZE.h_mpi\" -- skipping $dir"
1347 continue
1348 fi
1349 if test "x$MPI_MFILE" != x ; then
1350 #- create new MPI machine-file with the right number of Procs
1351 rm -f $LOC_MFILE
1352 cat $MPI_MFILE | sort | uniq | head -$LOC_NPROC > $LOC_MFILE
1353 nl=`wc -l $LOC_MFILE | awk '{print $1}'`
1354 if [ $nl -lt $LOC_NPROC ] ; then
1355 rm -f $LOC_MFILE
1356 cat $MPI_MFILE | head -$LOC_NPROC > $LOC_MFILE
1357 #sed -n "1,$LOC_NPROC p" $MPI_MFILE > $LOC_MFILE
1358 fi
1359 if [ $verbose -gt 1 ]; then
1360 nl=`wc -l $LOC_MFILE | awk '{print $1}'`
1361 echo " new LOC_MFILE=$LOC_MFILE : $nl procs for LOC_NPROC=$LOC_NPROC"
1362 fi
1363 fi
1364 fi
1365 if test ! -r $dir"/input/eedata.mth" -a "x$MULTI_THREAD" = "xt" ; then
1366 echo "can't find \"$dir/input/eedata.mth\" -- skipping $dir"
1367 continue
1368 fi
1369 if test "x$MPI" != "x0" -a "x$MULTI_THREAD" = "xt" ; then
1370 retv=`check_eedata $BUILD_DIR"/SIZE.h.mpi" $dir"/input/eedata.mth"`
1371 if test $retv != 0 ; then
1372 echo "input/eedata.mth tiling misfit -- skipping $dir"
1373 continue
1374 fi
1375 fi
1376
1377 # Check whether there are "extra runs" for this testdir
1378 extra_runs=
1379 if test "x$NORUN" = xf ; then
1380 ex_run_dirs=`( cd $dir ; echo $inputdir.* )`
1381 fi
1382 #echo "ex_run_dirs='$ex_run_dirs'"
1383 for exd in $ex_run_dirs ; do
1384 name=`echo $exd | sed -e "s/$inputdir\.//"`
1385 refExOut=`echo $ref_outp | sed "s/\./.${name}./"`
1386 outf="$dir/results/$refExOut"
1387 if test -f $outf -a -r $outf ; then
1388 if test "x$MULTI_THREAD" = "xt" ; then
1389 if test -r $dir"/"$exd"/eedata.mth" ; then
1390 if test "x$MPI" = "x0" ; then
1391 extra_runs="$extra_runs $name"
1392 else
1393 retv=`check_eedata $BUILD_DIR"/SIZE.h.mpi" $dir"/"$exd"/eedata.mth"`
1394 if test $retv = 0 ; then
1395 extra_runs="$extra_runs $name"
1396 else
1397 echo $exd"/eedata.mth tiling misfit -- skipping $dir"
1398 fi
1399 fi
1400 #else echo $dir"/"$exd"/eedata.mth: not found"
1401 fi
1402 else
1403 extra_runs="$extra_runs $name"
1404 fi
1405 fi
1406 done
1407
1408 echo
1409 if test "x$extra_runs" = "x" ; then
1410 echo "Experiment: $dir"
1411 else
1412 echo "Experiment: $dir ; extra_runs=$extra_runs"
1413 fi
1414 echo
1415 unset genmake makedepend make run
1416 results=$EMPTY_RESULTS
1417
1418 # Create an output dir & summary.txt file for each tested experiment (tdir)
1419 locDIR=$DRESULTS"/"$dir
1420 mkdir $locDIR
1421 #- report to this experiment local summary file ---
1422 echo "DATE='$DATE' ; tdir='$dir'" > $locDIR"/summary.txt"
1423 echo "MACH='$MACH'" >> $locDIR"/summary.txt"
1424 echo "UNAMEA='$UNAMEA'" >> $locDIR"/summary.txt"
1425 CDIR=`pwd`"/$locDIR"
1426
1427 if test "x$NORUN" = xt ; then
1428 run=N
1429 genmakemodel $dir/$builddir && genmake=Y \
1430 && makeclean $dir/$builddir \
1431 && symlink_mpifiles $dir $code_dir $builddir \
1432 && makedependmodel $dir/$builddir && makedepend=Y \
1433 && makemodel $dir/$builddir && make=Y
1434 else
1435 genmakemodel $dir/$builddir && genmake=Y \
1436 && makeclean $dir/$builddir \
1437 && symlink_mpifiles $dir $code_dir $builddir \
1438 && makedependmodel $dir/$builddir && makedepend=Y \
1439 && makemodel $dir/$builddir && make=Y \
1440 && run_clean $dir/$rundir \
1441 && linkdata $dir/$rundir $inputdir \
1442 && runmodel $dir/$rundir && run=Y \
1443 && results=`testoutput_run $dir $rundir $ref_outp`
1444 fi
1445 #echo "results='$results'"
1446
1447 fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results`
1448 echo 1>&2
1449 echo "$fres" | sed 's/ 99/ --/g' | sed 's/ > />/' | sed 's/ < /</' >> $SUMMARY
1450 echo "fresults='$fres'" | sed 's/ 99/ --/g' >> $locDIR"/summary.txt"
1451
1452 for ex in $extra_runs ; do
1453 unset run
1454 results=$EMPTY_RESULTS
1455 # reference output file
1456 refExOut=`echo $ref_outp | sed "s/\./.${ex}./g"`
1457 # Create an output dir & summary.txt file for each extra run (tdir.ex)
1458 locDIR=$DRESULTS"/"$dir"."$ex
1459 mkdir $locDIR
1460 #- report to this experiment local summary file ---
1461 echo "DATE='$DATE' ; tdir='$dir.$ex'" > $locDIR"/summary.txt"
1462 #echo "MACH='$MACH'" >> $locDIR"/summary.txt"
1463 #echo "UNAMEA='$UNAMEA'" >> $locDIR"/summary.txt"
1464 CDIR=`pwd`"/$locDIR"
1465 test ! -e "$dir/$pfxdir.$ex" && mkdir "$dir/$pfxdir.$ex"
1466 run_clean $dir/$pfxdir.$ex
1467 linkdata $dir/$pfxdir.$ex $inputdir.$ex $inputdir
1468 runmodel $dir/$pfxdir.$ex && run=Y \
1469 && results=`testoutput_run $dir $pfxdir.$ex $refExOut`
1470 fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results`
1471 fres="$fres.$ex"
1472 echo 1>&2
1473 echo "$fres" | sed 's/ 99/ --/g' | sed 's/ > />/' | sed 's/ < /</' >> $SUMMARY
1474 echo "fresults='$fres'" | sed 's/ 99/ --/g' >> $locDIR"/summary.txt"
1475 if test "x$POSTCLEAN" = x2 ; then
1476 run_clean $dir/$pfxdir.$ex
1477 fi
1478 done
1479
1480 if test -f $DRESULTS"/"genmake_state ; then : ; else
1481 if test -f $dir/$builddir/Makefile ; then
1482 mkOpt=`grep '^# OPTFILE=' $dir/$builddir/Makefile 2>/dev/null | head -1 | sed 's/^# //'`
1483 echo "from '$dir/$builddir/Makefile', extract:" > $DRESULTS/genmake_state
1484 sed -n '/^# executed by:/,+1 p' $dir/$builddir/Makefile >> $DRESULTS/genmake_state
1485 echo " $mkOpt" >> $DRESULTS/genmake_state
1486 if test "x$OPTFILE" = xNONE ; then
1487 eval $mkOpt
1488 sed "/^No \"OPTFILE\" was specified ; genmake2/a\ OPTFILE=${OPTFILE}"\
1489 $SUMMARY > tr_0.tmp_log
1490 RETVAL=$?
1491 if test "x$RETVAL" = x0 ; then rm -f $SUMMARY
1492 cp tr_0.tmp_log $SUMMARY
1493 else rm -f tr_0.tmp_log
1494 fi
1495 fi
1496 gmkLog=$dir/$builddir/genmake.log
1497 grep '^Get compiler version using:' $gmkLog > /dev/null 2>&1
1498 RETVAL=$?
1499 if test "x$RETVAL" = x0 ; then
1500 echo "from '$gmkLog', extract compiler version:" >> $DRESULTS/genmake_state
1501 sed -n '/Get compiler version/,/<-- compiler version/p' $gmkLog \
1502 | grep -v '^... compiler version ' > tr_1.tmp_log
1503 sed -n '1,/^$/p' tr_1.tmp_log | sed '/^$/d' | sed 's/^./ &/' \
1504 >> $DRESULTS/genmake_state
1505 rm -f tr_1.tmp_log
1506 fi
1507 fi
1508 fi
1509 #postclean $dir/$builddir
1510 if test "x$POSTCLEAN" = x2 ; then
1511 makeclean $dir/$builddir \
1512 && run_clean $dir/$rundir
1513 fi
1514 if test "x$MPI" != x0 -a "x$MPI_MFILE" != x ; then rm -f $LOC_MFILE ; fi
1515
1516 echo "-------------------------------------------------------------------------------"
1517
1518 done
1519
1520 printf "Start time: " >> $SUMMARY
1521 echo "$start_date" >> $SUMMARY
1522 printf "End time: " >> $SUMMARY
1523 date >> $SUMMARY
1524
1525 # If addresses were supplied and mpack built successfully, then try
1526 # to send email using mpack.
1527 if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then
1528 echo "No results email was sent."
1529 else
1530 if test "x$HAVE_MPACK" = xt ; then
1531 tar -cf $DRESULTS".tar" $DRESULTS > /dev/null 2>&1 \
1532 && gzip $DRESULTS".tar" \
1533 && $MPACK -s MITgcm-test -m 3555000 $DRESULTS".tar.gz" $ADDRESSES
1534 RETVAL=$?
1535 if test "x$RETVAL" != x0 ; then
1536 echo
1537 echo "Warning: The tar, gzip, & mpack step failed. Please send email"
1538 echo " to <MITgcm-support@mitgcm.org> for help. You may copy the "
1539 echo " summary of results from the directory \"$DRESULTS\"."
1540 echo
1541 else
1542 echo
1543 echo "An email containing results was sent to the following addresses:"
1544 echo " \"$ADDRESSES\""
1545 echo
1546 test -f $DRESULTS".tar" && rm -f $DRESULTS".tar"
1547 test -f $DRESULTS".tar.gz" && rm -f $DRESULTS".tar.gz"
1548 fi
1549 fi
1550 fi
1551
1552 if test "x$QUICK" = xf -a "x$NORUN" = xf ; then
1553 rm -f tr_cmpnum.c tr_cmpnum
1554 fi
1555
1556 if test "x$CLEANUP" != xt ; then
1557 cat $SUMMARY | sed 's/ \. \. \. \. \. \. \. \. \. \. \. \. //'
1558 if test -e tr_out.txt ; then
1559 mv tr_out.txt tr_out.txt.old
1560 fi
1561 cat $SUMMARY | sed '/^[YN] [YN] [YN] [YN]/ s/ \. //g' > tr_out.txt
1562 fi
1563
1564 if test "x$DELDIR" = xt ; then
1565 rm -rf $DRESULTS
1566 fi

  ViewVC Help
Powered by ViewVC 1.1.22