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