1 |
#!/bin/bash |
2 |
# |
3 |
# $Header: /u/u3/gcmpack/MITgcm/verification/testreport,v 1.14 2003/11/07 21:32:19 edhill 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 " (-mpi) use MPI input files" |
15 |
echo " (-ieee|-noieee) if possible, use IEEE compiler flags" |
16 |
echo " (-optfile=|-of=)STRING list of optfiles to use" |
17 |
echo " (-a|-addr)STRING list of email recipients" |
18 |
echo " (DEF=\"edhill@mitgcm.org\")" |
19 |
echo " (-t|-tdir)STRING list of test dirs to use" |
20 |
echo " (DEF=\"\" which builds all)" |
21 |
echo " (-b|-bash)STRING location of \"bash\" executable" |
22 |
echo " (DEF=\"\" for \"/bin/bash\")" |
23 |
echo " (-command)STRING command to run" |
24 |
echo " (DEF=\"make output.txt\")" |
25 |
echo " (-m|-make)STRING command to use for \"make\"" |
26 |
echo " (DEF=\"make\")" |
27 |
echo " (-clean) *ONLY* run \"make CLEAN\"" |
28 |
echo " (-quick|-q) same as \"-nogenmake -noclean -nodepend\"" |
29 |
echo " (-nogenmake|-ng) skip the genmake stage" |
30 |
echo " (-noclean|-nc) skip the \"make clean\" stage" |
31 |
echo " (-nodepend|-nd) skip the \"make depend\" stage" |
32 |
echo |
33 |
echo "and where STRING follows a whitespace-delimited format" |
34 |
echo "such as:" |
35 |
echo " -t 'exp0 exp2 exp3' " |
36 |
echo " -addr='abc@123.com testing@home.org'" |
37 |
echo |
38 |
exit 1 |
39 |
} |
40 |
|
41 |
# build the mpack utility |
42 |
build_mpack() |
43 |
{ |
44 |
echo -n "building the mpack utility... " |
45 |
if test ! -x "$MPACKDIR/mpack" ; then |
46 |
if test ! -d $MPACKDIR ; then |
47 |
echo "Error: can't find \"$MPACKDIR\"" |
48 |
echo " are you sure this program is being run in the correct " |
49 |
echo " (that is, \"MITGCM_ROOT\verification\") directory?" |
50 |
exit 1 |
51 |
fi |
52 |
echo -n "building mpack... " |
53 |
( cd $MPACKDIR && ./configure && $MAKE ) > build_mpack.out 2>&1 |
54 |
RETVAL=$? |
55 |
if test "x$RETVAL" != x0 ; then |
56 |
echo |
57 |
echo "Error building the mpack tools at: $MPACK_DIR" |
58 |
exit 1 |
59 |
fi |
60 |
fi |
61 |
echo "OK" |
62 |
} |
63 |
|
64 |
compare_lines() |
65 |
{ |
66 |
# use codelet to compare lines |
67 |
if [ $verbose -gt 1 ]; then |
68 |
cat tmp3.txt 1>&2 |
69 |
fi |
70 |
return `./a.out < tmp3.txt` |
71 |
} |
72 |
|
73 |
testoutput_for_prop() |
74 |
{ |
75 |
# testoutput_for_prop dir s1 label subdir |
76 |
# |
77 |
# compares files in $dir/$subdir/output.txt and $dir/results/output.txt |
78 |
# using search strings s1 and text label |
79 |
|
80 |
if [ $debug -gt 0 ]; then |
81 |
echo testoutput_for_prop: grep "$2" $1/$4/output.txt 1>&2 |
82 |
fi |
83 |
if [ -r $1/$4/output.txt ]; then |
84 |
grep "$2" $1/$4/output.txt | sed 's/.*=//' | cat -n > tmp1.txt |
85 |
lncnt=`wc -l tmp1.txt | awk '{print $1}' ` |
86 |
if [ $lncnt -lt 3 ]; then |
87 |
if [ $verbose -gt 0 ]; then |
88 |
echo Not enough lines of output when searching for "$2" 1>&2 |
89 |
fi |
90 |
return 99 |
91 |
fi |
92 |
else |
93 |
echo testoutput_for_prop: output.txt from model run was not readable 1>&2 |
94 |
return 99 |
95 |
fi |
96 |
if [ $debug -gt 0 ]; then |
97 |
echo testoutput_for_prop: grep "$2" $1/results/output.txt 1>&2 |
98 |
fi |
99 |
grep "$2" $1/results/output.txt | sed 's/.*=//' | cat -n > tmp2.txt |
100 |
lncnt=`wc -l tmp2.txt | awk '{print $1}' ` |
101 |
if [ $lncnt -lt 3 ]; then |
102 |
if [ $verbose -gt 0 ]; then |
103 |
echo Not enough lines of output when searching for "$2" 1>&2 |
104 |
fi |
105 |
return 99 |
106 |
fi |
107 |
if [ $debug -gt 0 ]; then |
108 |
echo testoutput_for_prop: join tmp1.txt tmp2.txt 1>&2 |
109 |
fi |
110 |
join tmp1.txt tmp2.txt | awk '{print $1 " " $2 " " $3}' > tmp3.txt |
111 |
if [ $debug -gt 0 ]; then |
112 |
echo testoutput_for_prop: compare_lines 1>&2 |
113 |
fi |
114 |
compare_lines |
115 |
digits_of_similarity=$? |
116 |
if [ $digits_of_similarity -eq 99 ]; then |
117 |
if [ $verbose -gt 0 ]; then |
118 |
echo testoutput_for_prop: No comparison was available for \"$2\" 1>&2 |
119 |
fi |
120 |
digits_of_similarity=99 |
121 |
else |
122 |
if [ $verbose -gt 0 ]; then |
123 |
echo There were $digits_of_similarity decimal places of similarity for \"$2\" 1>&2 |
124 |
fi |
125 |
fi |
126 |
rm tmp1.txt tmp2.txt tmp3.txt |
127 |
|
128 |
return $digits_of_similarity |
129 |
} |
130 |
|
131 |
dashnum() |
132 |
{ |
133 |
# dashnum n1 n2 n3 ... |
134 |
# |
135 |
# print numbers using %3i format or "--" if number = 99 |
136 |
|
137 |
for num in $@ ; do |
138 |
if [ $num = 99 ]; then |
139 |
printf ' --' |
140 |
else |
141 |
printf '%3i' $num |
142 |
fi |
143 |
done |
144 |
} |
145 |
|
146 |
testoutput() |
147 |
{ |
148 |
# testoutput diretory subdir |
149 |
# |
150 |
# test output in "directory" |
151 |
|
152 |
if [ $debug -gt 0 ]; then |
153 |
echo testoutput: testoutput_for_prop $1 cg2d_init_res 1>&2 |
154 |
fi |
155 |
testoutput_for_prop $1 "cg2d_init_res" "cg2d init. residual" $2; cg2dres=$? |
156 |
if [ $debug -gt 0 ]; then |
157 |
echo testoutput: cg2dres=$cg2dres 1>&2 |
158 |
fi |
159 |
testoutput_for_prop $1 "dynstat_theta_min" "theta minimum" $2; tmin=$? |
160 |
testoutput_for_prop $1 "dynstat_theta_max" "theta maximum" $2; tmax=$? |
161 |
testoutput_for_prop $1 "dynstat_theta_mean" "theta mean" $2; tmean=$? |
162 |
testoutput_for_prop $1 "dynstat_theta_sd" "theta s.d." $2; tsd=$? |
163 |
testoutput_for_prop $1 "dynstat_salt_min" "salt minimum" $2; smin=$? |
164 |
testoutput_for_prop $1 "dynstat_salt_max" "salt maximum" $2; smax=$? |
165 |
testoutput_for_prop $1 "dynstat_salt_mean" "salt mean" $2; smean=$? |
166 |
testoutput_for_prop $1 "dynstat_salt_sd" "salt s.d." $2; ssd=$? |
167 |
testoutput_for_prop $1 "dynstat_uvel_min" "U minimum" $2; umin=$? |
168 |
testoutput_for_prop $1 "dynstat_uvel_max" "U maximum" $2; umax=$? |
169 |
testoutput_for_prop $1 "dynstat_uvel_mean" "U mean" $2; umean=$? |
170 |
testoutput_for_prop $1 "dynstat_uvel_sd" "U s.d." $2; usd=$? |
171 |
testoutput_for_prop $1 "dynstat_vvel_min" "V minimum" $2; vmin=$? |
172 |
testoutput_for_prop $1 "dynstat_vvel_max" "V maximum" $2; vmax=$? |
173 |
testoutput_for_prop $1 "dynstat_vvel_mean" "V mean" $2; vmean=$? |
174 |
testoutput_for_prop $1 "dynstat_vvel_sd" "V s.d." $2; vsd=$? |
175 |
|
176 |
dashnum $cg2dres $tmin $tmax $tmean $tsd $smin $smax $smean $ssd \ |
177 |
$umin $umax $umean $usd $vmin $vmax $vmean $vsd |
178 |
} |
179 |
|
180 |
genmakemodel() |
181 |
{ |
182 |
# genmakemodel directory |
183 |
if test "x$NOGENMAKE" = xt ; then |
184 |
echo "genmake skipped!" |
185 |
else |
186 |
GENMAKE2="$BASH ../../../tools/genmake2" |
187 |
( |
188 |
cd $1; |
189 |
command="$GENMAKE2 -ds -m $MAKE --mods=../code" |
190 |
if test "x$OPTFILE" != xNONE ; then |
191 |
command="$command --optfile=$OPTFILE" |
192 |
# echo " command=\"$command\"" |
193 |
fi |
194 |
if test "x$IEEE" != x ; then |
195 |
command="$command -ieee" |
196 |
fi |
197 |
# echo "command: \"$command\"" |
198 |
printf 'genmake ... ' 1>&2 |
199 |
$command > make.log 2>&1 |
200 |
RETVAL=$? |
201 |
for i in genmake_state genmake_optfile genmake_local Makefile ; do |
202 |
if test -r $i ; then |
203 |
cp $i $CDIR |
204 |
fi |
205 |
done |
206 |
if test "x$RETVAL" != x0 ; then |
207 |
tail make.log |
208 |
echo "genmakemodel: genmake failed" 1>&2 |
209 |
cp make.log $CDIR |
210 |
return 1 |
211 |
else |
212 |
echo "succesful" 1>&2 |
213 |
fi |
214 |
) |
215 |
fi |
216 |
} |
217 |
|
218 |
makeclean() |
219 |
{ |
220 |
# makeclean directory |
221 |
if test "x$NOCLEAN" = xt ; then |
222 |
echo "make CLEAN skipped!" |
223 |
else |
224 |
( |
225 |
cd $1; |
226 |
if test -e output.txt ; then |
227 |
rm -f output.txt |
228 |
fi |
229 |
printf 'make CLEAN ... ' 2>&1 |
230 |
if test -r Makefile ; then |
231 |
$MAKE CLEAN >> make.log 2>&1 |
232 |
RETVAL=$? |
233 |
if test "x$RETVAL" != x0 ; then |
234 |
tail make.log |
235 |
echo "makeclean: \"make CLEAN\" failed" 1>&2 |
236 |
cp make.log $CDIR"/make.log" |
237 |
return 1 |
238 |
fi |
239 |
fi |
240 |
echo succesful 1>&2 |
241 |
exit 0 |
242 |
) |
243 |
fi |
244 |
} |
245 |
|
246 |
makedependmodel() |
247 |
{ |
248 |
# makedependmodel directory |
249 |
if test "x$NODEPEND" = xt ; then |
250 |
echo "make depend skipped!" |
251 |
else |
252 |
( |
253 |
cd $1; |
254 |
printf 'make depend ... ' 1>&2 |
255 |
$MAKE depend >> make.log 2>&1 |
256 |
RETVAL=$? |
257 |
if test "x$RETVAL" != x0 ; then |
258 |
tail make.log |
259 |
echo "makedependmodel: make depend failed" 1>&2 |
260 |
cp make.log $CDIR"/make.log" |
261 |
return 1 |
262 |
else |
263 |
echo succesful 1>&2 |
264 |
fi |
265 |
) |
266 |
fi |
267 |
} |
268 |
|
269 |
makemodel() |
270 |
{ |
271 |
# makemodel directory |
272 |
( |
273 |
cd $1; |
274 |
if test -r Makefile ; then |
275 |
printf 'make ... ' 1>&2 |
276 |
$MAKE >> make.log 2>&1 |
277 |
RETVAL=$? |
278 |
if test "x$RETVAL" != x0 ; then |
279 |
tail make.log |
280 |
echo failed 1>&2 |
281 |
cp make.log $CDIR"/make.log" |
282 |
return 1 |
283 |
else |
284 |
echo succesful 1>&2 |
285 |
fi |
286 |
fi |
287 |
) |
288 |
} |
289 |
|
290 |
linkdata() |
291 |
{ |
292 |
# linkdata flag |
293 |
# |
294 |
# symbolically link data files to run directory |
295 |
if test "x$1" = x1 ; then |
296 |
( |
297 |
cd $2 |
298 |
files=`( cd ../input ; ls -1 | grep -v CVS )` |
299 |
for i in $files ; do |
300 |
if test ! -d "../input/"$i ; then |
301 |
ln -sf "../input/"$i $i |
302 |
fi |
303 |
done |
304 |
) |
305 |
fi |
306 |
} |
307 |
|
308 |
runmodel() |
309 |
{ |
310 |
# runmodel directory |
311 |
# |
312 |
# runs "$COMMAND" in "directory" |
313 |
# (where "$COMMAND" is relative to "directory") |
314 |
( |
315 |
cd $1 |
316 |
printf 'runmodel: ' 1>&2 |
317 |
# make output.txt |
318 |
$COMMAND |
319 |
RETVAL=$? |
320 |
if test "x$RETVAL" = x0 ; then |
321 |
cp output.txt $CDIR"/output.txt" |
322 |
return 0 |
323 |
else |
324 |
return 1 |
325 |
fi |
326 |
) |
327 |
} |
328 |
|
329 |
createcodelet() |
330 |
{ |
331 |
# create codelet for comparing model output |
332 |
|
333 |
echo -n "creating the comparison code... " |
334 |
cat > tmp_cmpnum.f <<EOFA |
335 |
program cmpnum |
336 |
implicit none |
337 |
real*8 a,b,diff |
338 |
integer linnum,best |
339 |
best=-16 |
340 |
99 read(*,*,end=70,err=60) linnum,a,b |
341 |
diff=0.5*(abs(a)+abs(b)) |
342 |
c print *,a,b,diff,abs(a-b)/diff |
343 |
if (diff.gt.1.e-12) then |
344 |
diff=abs(a-b)/diff |
345 |
if (diff.gt.0.) then |
346 |
c print *,int(log10(diff)),diff |
347 |
linnum=int(log10(diff)) |
348 |
best=max(best,linnum) |
349 |
endif |
350 |
else |
351 |
if (best.eq.-16.and.diff.ne.0.) best=-22 |
352 |
endif |
353 |
goto 99 |
354 |
60 stop 'cmpnum: An error occured reading a,b' |
355 |
70 print *,-best |
356 |
end |
357 |
EOFA |
358 |
|
359 |
f77 tmp_cmpnum.f |
360 |
if [ -x ./a.out ]; then |
361 |
echo "OK" |
362 |
return 0 |
363 |
else |
364 |
echo |
365 |
echo "createcodelet: failed to compile codelet" |
366 |
exit 1 |
367 |
fi |
368 |
} |
369 |
|
370 |
formatresults() |
371 |
{ |
372 |
# formatresults expt genmake depend make run results* |
373 |
|
374 |
nm=$1 |
375 |
printf '%s %s %s %s' $2 $3 $4 $5 |
376 |
shift; shift; shift; shift; shift; |
377 |
printf '%3s' $@ |
378 |
|
379 |
if [ $1 = '--' ]; then |
380 |
printf ' N/O ' |
381 |
else |
382 |
if [ $1 -gt 12 ]; then |
383 |
printf ' pass' |
384 |
else |
385 |
printf ' FAIL' |
386 |
fi |
387 |
fi |
388 |
printf ' %s' $nm |
389 |
printf '\n' |
390 |
|
391 |
} |
392 |
|
393 |
show_help() |
394 |
{ |
395 |
cat - << EOF |
396 |
$0 [-help] [-quick] [-verbose] dir1 [dir2] [...] |
397 |
|
398 |
-help|-h Show this help message |
399 |
-quiet Reduce the amount of output |
400 |
-verbose Produce copious amounts of output |
401 |
-debug Produce even more output which will mean nothing to most |
402 |
-force Do "make CLEAN" before compiling. This forces a complete rebuild. |
403 |
-clean Do "make CLEAN" after compiling and testing. |
404 |
-cleanup Aggresively removes all model output, executables and object files |
405 |
and then exits. Use with care. |
406 |
|
407 |
Normal usage: |
408 |
$0 * Configure, compile, run and analyze in all experiment directories |
409 |
EOF |
410 |
} |
411 |
|
412 |
scandirs() |
413 |
{ |
414 |
if [ $# -eq 0 ]; then |
415 |
for arg in * ; do |
416 |
test -d $arg/input && echo $arg |
417 |
done |
418 |
else |
419 |
echo $* |
420 |
fi |
421 |
} |
422 |
|
423 |
|
424 |
############################################################################### |
425 |
############################################################################### |
426 |
############################################################################### |
427 |
|
428 |
|
429 |
# Default properties |
430 |
debug=0 |
431 |
verbose=1 |
432 |
clean=0 |
433 |
expts='' |
434 |
# ieee=1 |
435 |
|
436 |
IEEE= |
437 |
if test "x$MITGCM_IEEE" != x ; then |
438 |
IEEE=$MITGCM_IEEE |
439 |
fi |
440 |
|
441 |
|
442 |
CLEANUP=f |
443 |
QUICK=f |
444 |
NOGENMAKE=f |
445 |
NOCLEAN=f |
446 |
NODEPEND=f |
447 |
|
448 |
BASH= |
449 |
OPTFILE=NONE |
450 |
ADDRESSES= |
451 |
TESTDIRS= |
452 |
MPACKDIR="../tools/mpack-1.6" |
453 |
MPACK="$MPACKDIR/mpack" |
454 |
COMMAND="make output.txt" |
455 |
MAKE=make |
456 |
MPI=f |
457 |
|
458 |
echo -n "parsing options... " |
459 |
|
460 |
ac_prev= |
461 |
for ac_option ; do |
462 |
|
463 |
# If the previous option needs an argument, assign it. |
464 |
if test -n "$ac_prev"; then |
465 |
eval "$ac_prev=\$ac_option" |
466 |
ac_prev= |
467 |
continue |
468 |
fi |
469 |
|
470 |
ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` |
471 |
|
472 |
case $ac_option in |
473 |
|
474 |
-help | --help | -h | --h) |
475 |
usage ;; |
476 |
|
477 |
-optfile | --optfile | -of | --of) |
478 |
ac_prev=OPTFILE ;; |
479 |
-optfile=* | --optfile=* | -of=* | --of=*) |
480 |
OPTFILE=$ac_optarg ;; |
481 |
|
482 |
-addr | --addr | -a | --a) |
483 |
ac_prev=ADDRESSES ;; |
484 |
-addr=* | --addr=*) |
485 |
ADDRESSES=$ac_optarg ;; |
486 |
|
487 |
-tdir | --tdir | -t | --t) |
488 |
ac_prev=TESTDIRS ;; |
489 |
-tdir=* | --tdir=*) |
490 |
TESTDIRS=$ac_optarg ;; |
491 |
|
492 |
-bash | --bash | -b | --b) |
493 |
ac_prev=BASH ;; |
494 |
-bash=* | --bash=*) |
495 |
BASH=$ac_optarg ;; |
496 |
|
497 |
-command | --command | -c | --c) |
498 |
ac_prev=COMMAND ;; |
499 |
-command=* | --command=*) |
500 |
COMMAND=$ac_optarg ;; |
501 |
|
502 |
-make | --make | -m | --m) |
503 |
ac_prev=MAKE ;; |
504 |
-make=* | --make=*) |
505 |
MAKE=$ac_optarg ;; |
506 |
|
507 |
-clean | --clean) |
508 |
CLEANUP=t ;; |
509 |
|
510 |
-quick | --quick | -q | --q) |
511 |
QUICK=t ;; |
512 |
-nogenmake | --nogenmake | -ng | --ng) |
513 |
NOGENMAKE=t ;; |
514 |
-noclean | --noclean | -nc | --nc) |
515 |
NOCLEAN=t ;; |
516 |
-nodepend | --nodepend | -nd | --nd) |
517 |
NODEPEND=t ;; |
518 |
|
519 |
-mpi) MPI=true ;; |
520 |
|
521 |
-ieee) IEEE=true ;; |
522 |
-noieee) IEEE= ;; |
523 |
|
524 |
-verbose) verbose=2 ;; |
525 |
-debug) debug=1 ;; |
526 |
-quiet) verbose=0 ;; |
527 |
|
528 |
-*) |
529 |
echo "Error: unrecognized option: "$ac_option |
530 |
usage |
531 |
;; |
532 |
|
533 |
*) |
534 |
echo "Error: unrecognized argument: "$ac_option |
535 |
usage |
536 |
;; |
537 |
|
538 |
esac |
539 |
|
540 |
done |
541 |
|
542 |
if test "x$QUICK" = xt ; then |
543 |
NOGENMAKE=t |
544 |
NOCLEAN=t |
545 |
NODEPEND=t |
546 |
fi |
547 |
|
548 |
if test "x$TESTDIRS" = x ; then |
549 |
TESTDIRS=`scandirs` |
550 |
fi |
551 |
|
552 |
if test "x$OPTFILE" = xNONE -a "x$MITGCM_OF" != x ; then |
553 |
OPTFILE=$MITGCM_OF |
554 |
fi |
555 |
|
556 |
echo "OK" |
557 |
|
558 |
# create the FORTRAN comparison code |
559 |
createcodelet |
560 |
|
561 |
# build the mpack utility |
562 |
build_mpack |
563 |
|
564 |
# Create a uniquely named directory to store results |
565 |
MACH=`hostname` |
566 |
UNAMEA=`uname -a` |
567 |
DATE=`date +%Y%m%d` |
568 |
BASE=$MACH"_"$DATE"_" |
569 |
DNUM=0 |
570 |
DRESULTS="$BASE$DNUM" |
571 |
while test -e $DRESULTS ; do |
572 |
DNUM=$(( $DNUM + 1 )) |
573 |
DRESULTS="$BASE$DNUM" |
574 |
done |
575 |
mkdir $DRESULTS |
576 |
RETVAL=$? |
577 |
if test "x$RETVAL" != x0 ; then |
578 |
echo "Error: can't create results directory \"./$DRESULTS\"" |
579 |
exit 1 |
580 |
fi |
581 |
SUMMARY="$DRESULTS/summary.txt" |
582 |
echo -n "Start time: " >> $SUMMARY |
583 |
date > $SUMMARY |
584 |
date > dfile |
585 |
cat << EOF >> $SUMMARY |
586 |
T S U V |
587 |
G D M c m s m s m s m s |
588 |
E p a R g m m e . m m e . m m e . m m e . |
589 |
N n k u 2 i a a d i a a d i a a d i a a d |
590 |
2 d e n d n x n . n x n . n x n . n x n . |
591 |
|
592 |
EOF |
593 |
|
594 |
NDIR=0 |
595 |
|
596 |
of_path= |
597 |
if test "x$OPTFILE" != xNONE ; then |
598 |
if test -r $OPTFILE ; then |
599 |
# get the path |
600 |
path=${OPTFILE%/*} |
601 |
if test "x$path" = x ; then |
602 |
of_path=`pwd` |
603 |
else |
604 |
of_path=`( cd $path > /dev/null 2>&1 ; pwd )` |
605 |
fi |
606 |
file=${OPTFILE##*/} |
607 |
OPTFILE=$of_path/$file |
608 |
else |
609 |
echo |
610 |
echo "WARNING: can't read OPTFILE=\"$OPTFILE\" but will try to use it..." |
611 |
fi |
612 |
fi |
613 |
echo |
614 |
echo "OPTFILE=$OPTFILE" >> $SUMMARY |
615 |
echo >> $SUMMARY |
616 |
|
617 |
# ...and each test directory... |
618 |
for dir in $TESTDIRS ; do |
619 |
|
620 |
# Cleanup only! |
621 |
if test "x$CLEANUP" = xt ; then |
622 |
if test -r $dir/build/Makefile ; then |
623 |
( cd $dir/build ; make CLEAN ) |
624 |
fi |
625 |
if test -r $dir/input/Makefile ; then |
626 |
( cd $dir/input ; make CLEAN ) |
627 |
fi |
628 |
continue |
629 |
fi |
630 |
|
631 |
# Verify that the testdir exists and contains previous |
632 |
# results in the correct location--or skip this directory! |
633 |
if test ! -r $dir"/results/output.txt" ; then |
634 |
echo "can't read \"$dir/results/output.txt\" -- skipping $dir" |
635 |
continue |
636 |
fi |
637 |
|
638 |
echo "-------------------------------------------------------------------------------" |
639 |
echo |
640 |
echo "Experiment: $dir" |
641 |
echo |
642 |
unset genmake makedepend make run |
643 |
results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --' |
644 |
|
645 |
builddir="input" |
646 |
rundir="input" |
647 |
use_seperate_build=0 |
648 |
if test -d $dir/build -a -r $dir/build ; then |
649 |
builddir="build" |
650 |
rundir="build" |
651 |
use_seperate_build=1 |
652 |
linkdata $use_seperate_build $dir/$rundir |
653 |
fi |
654 |
|
655 |
CODE_DIR=$dir/code |
656 |
BUILD_DIR=$dir/$builddir |
657 |
MPI_FILES="CPP_EEOPTIONS.h_mpi SIZE.h_mpi" |
658 |
NOMPI_FILES="CPP_EEOPTIONS.h_nompi SIZE.h_nompi" |
659 |
|
660 |
# Is this an MPI run? |
661 |
if test "x$MPI" = xt ; then |
662 |
FILES=$MPI_FILES |
663 |
endings="_mpi" |
664 |
else |
665 |
FILES=$NOMPI_FILES |
666 |
endings="_nompi" |
667 |
fi |
668 |
|
669 |
# Check to see that we have the files |
670 |
have_files=t |
671 |
for i in $FILES ; do |
672 |
if test ! -r $CODE_DIR/$i ; then |
673 |
echo "Warning: can't read file $CODE_DIR/$i" |
674 |
have_files=f |
675 |
fi |
676 |
done |
677 |
if test "x$have_files" != xt -a "x$MPI" = xt ; then |
678 |
echo "Skipping $dir due to lack of input files (see above warning)" |
679 |
continue |
680 |
fi |
681 |
|
682 |
# If we have the $FILES and they differ, copy the $FILES to $BUILD_DIR |
683 |
if test "x$have_files" = xt ; then |
684 |
for i in $FILES ; do |
685 |
sstr="s|$endings||" |
686 |
name=`echo $i | sed -e $sstr ` |
687 |
cmp $CODE_DIR/$i $BUILD_DIR/$name > /dev/null 2>&1 |
688 |
RETVAL=$? |
689 |
if test "x$RETVAL" != x0 ; then |
690 |
cp $CODE_DIR/$i $BUILD_DIR/$name |
691 |
fi |
692 |
done |
693 |
fi |
694 |
|
695 |
# Create an output dir for each OPTFILE/tdir combination |
696 |
CDIR=$DRESULTS"/"$DRESULTS"_"$NDIR |
697 |
mkdir $CDIR |
698 |
CDIR=`pwd`"/$CDIR" |
699 |
|
700 |
if test "x$CLEANUP" = xt ; then |
701 |
makeclean $dir/$builddir |
702 |
else |
703 |
genmakemodel $dir/$builddir && genmake=Y \ |
704 |
&& makeclean $dir/$builddir \ |
705 |
&& makedependmodel $dir/$builddir && makedepend=Y \ |
706 |
&& makemodel $dir/$builddir && make=Y \ |
707 |
&& linkdata $use_seperate_build $dir/$rundir \ |
708 |
&& runmodel $dir/$rundir && run=Y \ |
709 |
&& results=`testoutput $dir $rundir` |
710 |
fi |
711 |
|
712 |
echo |
713 |
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
714 |
${run:-N} $results |
715 |
echo |
716 |
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
717 |
${run:-N} $results >> $SUMMARY |
718 |
echo "fresults='" > $CDIR"/summary.txt" |
719 |
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
720 |
${run:-N} $results >> $CDIR"/summary.txt" |
721 |
echo "'" >> $CDIR"/summary.txt" |
722 |
echo "MACH='$MACH'" >> $CDIR"/summary.txt" |
723 |
echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt" |
724 |
echo "DATE='$DATE'" >> $CDIR"/summary.txt" |
725 |
echo "tdir='$dir'" >> $CDIR"/summary.txt" |
726 |
|
727 |
( |
728 |
cd $DRESULTS |
729 |
tar -cf $NDIR".tar" $DRESULTS"_"$NDIR > /dev/null 2>&1 |
730 |
gzip $NDIR".tar" |
731 |
) |
732 |
|
733 |
if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then |
734 |
echo "No mail sent" |
735 |
else |
736 |
$MPACK -s MITgcm-test -m 1000000 $DRESULTS"/"$NDIR".tar.gz" $ADDRESSES |
737 |
RETVAL=$? |
738 |
if test "x$RETVAL" != x0 ; then |
739 |
echo "Warning: \"$MPACK\" failed -- please contact <edhill@mitgcm.org>" |
740 |
else |
741 |
rm -f $DRESULTS"/"$NDIR".tar*" |
742 |
fi |
743 |
fi |
744 |
|
745 |
echo "-------------------------------------------------------------------------------" |
746 |
|
747 |
NDIR=$(( $NDIR + 1 )) |
748 |
|
749 |
done |
750 |
|
751 |
echo -n "Start time: " >> $SUMMARY |
752 |
date -r dfile >> $SUMMARY |
753 |
echo -n "End time: " >> $SUMMARY |
754 |
date >> $SUMMARY |
755 |
|
756 |
rm tmp_cmpnum.f a.out dfile |
757 |
|
758 |
if test "x$CLEANUP" != xt ; then |
759 |
cat $SUMMARY |
760 |
if test -e tr.out ; then |
761 |
mv tr.out tr.out.old |
762 |
fi |
763 |
cat $SUMMARY > tr.out |
764 |
fi |