1 |
#!/bin/bash |
2 |
# |
3 |
# $Header: /u/u3/gcmpack/MITgcm/verification/testreport,v 1.10 2003/10/09 04:19:20 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/.*=//' | nl > 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/.*=//' | nl > 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 |
|
160 |
testoutput_for_prop $1 "dynstat_theta_min" "theta minimum" $2; tmin=$? |
161 |
testoutput_for_prop $1 "dynstat_theta_max" "theta maximum" $2; tmax=$? |
162 |
testoutput_for_prop $1 "dynstat_theta_mean" "theta mean" $2; tmean=$? |
163 |
testoutput_for_prop $1 "dynstat_theta_sd" "theta s.d." $2; tsd=$? |
164 |
testoutput_for_prop $1 "dynstat_salt_min" "salt minimum" $2; smin=$? |
165 |
testoutput_for_prop $1 "dynstat_salt_max" "salt maximum" $2; smax=$? |
166 |
testoutput_for_prop $1 "dynstat_salt_mean" "salt mean" $2; smean=$? |
167 |
testoutput_for_prop $1 "dynstat_salt_sd" "salt s.d." $2; ssd=$? |
168 |
testoutput_for_prop $1 "dynstat_uvel_min" "U minimum" $2; umin=$? |
169 |
testoutput_for_prop $1 "dynstat_uvel_max" "U maximum" $2; umax=$? |
170 |
testoutput_for_prop $1 "dynstat_uvel_mean" "U mean" $2; umean=$? |
171 |
testoutput_for_prop $1 "dynstat_uvel_sd" "U s.d." $2; usd=$? |
172 |
testoutput_for_prop $1 "dynstat_vvel_min" "V minimum" $2; vmin=$? |
173 |
testoutput_for_prop $1 "dynstat_vvel_max" "V maximum" $2; vmax=$? |
174 |
testoutput_for_prop $1 "dynstat_vvel_mean" "V mean" $2; vmean=$? |
175 |
testoutput_for_prop $1 "dynstat_vvel_sd" "V s.d." $2; vsd=$? |
176 |
|
177 |
dashnum $cg2dres $tmin $tmax $tmean $tsd $smin $smax $smean $ssd \ |
178 |
$umin $umax $umean $usd $vmin $vmax $vmean $vsd |
179 |
} |
180 |
|
181 |
genmakemodel() |
182 |
{ |
183 |
# genmakemodel directory |
184 |
if test "x$NOGENMAKE" = xt ; then |
185 |
echo "genmake skipped!" |
186 |
else |
187 |
GENMAKE2="$BASH ../../../tools/genmake2" |
188 |
( |
189 |
cd $1; |
190 |
command="$GENMAKE2 -ds -m $MAKE --mods=../code" |
191 |
if test "x$OPTFILE" != xNONE ; then |
192 |
command="$command --optfile=$OPTFILE" |
193 |
# echo " command=\"$command\"" |
194 |
fi |
195 |
if test "x$IEEE" != x ; then |
196 |
command="$command -ieee" |
197 |
fi |
198 |
# echo "command: \"$command\"" |
199 |
printf 'genmake ... ' 1>&2 |
200 |
$command > make.log 2>&1 |
201 |
RETVAL=$? |
202 |
for i in genmake_state genmake_optfile genmake_local Makefile ; do |
203 |
if test -r $i ; then |
204 |
cp $i $CDIR |
205 |
fi |
206 |
done |
207 |
if test "x$RETVAL" != x0 ; then |
208 |
tail make.log |
209 |
echo "genmakemodel: genmake failed" 1>&2 |
210 |
cp make.log $CDIR |
211 |
return 1 |
212 |
else |
213 |
echo "succesful" 1>&2 |
214 |
fi |
215 |
) |
216 |
fi |
217 |
} |
218 |
|
219 |
makeclean() |
220 |
{ |
221 |
# makeclean directory |
222 |
if test "x$NOCLEAN" = xt ; then |
223 |
echo "make CLEAN skipped!" |
224 |
else |
225 |
( |
226 |
cd $1; |
227 |
if test -e output.txt ; then |
228 |
rm -f output.txt |
229 |
fi |
230 |
printf 'make CLEAN ... ' 2>&1 |
231 |
if test -r Makefile ; then |
232 |
$MAKE CLEAN >> make.log 2>&1 |
233 |
RETVAL=$? |
234 |
if test "x$RETVAL" != x0 ; then |
235 |
tail make.log |
236 |
echo "makeclean: \"make CLEAN\" failed" 1>&2 |
237 |
cp make.log $CDIR"/make.log" |
238 |
return 1 |
239 |
fi |
240 |
fi |
241 |
echo succesful 1>&2 |
242 |
exit 0 |
243 |
) |
244 |
fi |
245 |
} |
246 |
|
247 |
makedependmodel() |
248 |
{ |
249 |
# makedependmodel directory |
250 |
if test "x$NODEPEND" = xt ; then |
251 |
echo "make depend skipped!" |
252 |
else |
253 |
( |
254 |
cd $1; |
255 |
printf 'make depend ... ' 1>&2 |
256 |
$MAKE depend >> make.log 2>&1 |
257 |
RETVAL=$? |
258 |
if test "x$RETVAL" != x0 ; then |
259 |
tail make.log |
260 |
echo "makedependmodel: make depend failed" 1>&2 |
261 |
cp make.log $CDIR"/make.log" |
262 |
return 1 |
263 |
else |
264 |
echo succesful 1>&2 |
265 |
fi |
266 |
) |
267 |
fi |
268 |
} |
269 |
|
270 |
makemodel() |
271 |
{ |
272 |
# makemodel directory |
273 |
( |
274 |
cd $1; |
275 |
if test -r Makefile ; then |
276 |
printf 'make ... ' 1>&2 |
277 |
$MAKE >> make.log 2>&1 |
278 |
RETVAL=$? |
279 |
if test "x$RETVAL" != x0 ; then |
280 |
tail make.log |
281 |
echo failed 1>&2 |
282 |
cp make.log $CDIR"/make.log" |
283 |
return 1 |
284 |
else |
285 |
echo succesful 1>&2 |
286 |
fi |
287 |
fi |
288 |
) |
289 |
} |
290 |
|
291 |
linkdata() |
292 |
{ |
293 |
# linkdata flag |
294 |
# |
295 |
# symbolically link data files to run directory |
296 |
if [ $1 -ne 0 ]; then |
297 |
( cd $2 ; ln -sf ../input/* . ) |
298 |
fi |
299 |
} |
300 |
|
301 |
runmodel() |
302 |
{ |
303 |
# runmodel directory |
304 |
# |
305 |
# runs "$COMMAND" in "directory" |
306 |
# (where "$COMMAND" is relative to "directory") |
307 |
( |
308 |
cd $1 |
309 |
printf 'runmodel: ' 1>&2 |
310 |
# make output.txt |
311 |
$COMMAND |
312 |
RETVAL=$? |
313 |
if test "x$RETVAL" = x0 ; then |
314 |
cp output.txt $CDIR"/output.txt" |
315 |
return 0 |
316 |
else |
317 |
return 1 |
318 |
fi |
319 |
) |
320 |
} |
321 |
|
322 |
createcodelet() |
323 |
{ |
324 |
# create codelet for comparing model output |
325 |
|
326 |
echo -n "creating the comparison code... " |
327 |
cat > tmp_cmpnum.f <<EOFA |
328 |
program cmpnum |
329 |
implicit none |
330 |
real*8 a,b,diff |
331 |
integer linnum,best |
332 |
best=-16 |
333 |
99 read(*,*,end=70,err=60) linnum,a,b |
334 |
diff=0.5*(abs(a)+abs(b)) |
335 |
c print *,a,b,diff,abs(a-b)/diff |
336 |
if (diff.gt.1.e-12) then |
337 |
diff=abs(a-b)/diff |
338 |
if (diff.gt.0.) then |
339 |
c print *,int(log10(diff)),diff |
340 |
linnum=int(log10(diff)) |
341 |
best=max(best,linnum) |
342 |
endif |
343 |
else |
344 |
if (best.eq.-16.and.diff.ne.0.) best=-22 |
345 |
endif |
346 |
goto 99 |
347 |
60 stop 'cmpnum: An error occured reading a,b' |
348 |
70 print *,-best |
349 |
end |
350 |
EOFA |
351 |
|
352 |
f77 tmp_cmpnum.f |
353 |
if [ -x ./a.out ]; then |
354 |
echo "OK" |
355 |
return 0 |
356 |
else |
357 |
echo |
358 |
echo "createcodelet: failed to compile codelet" |
359 |
exit 1 |
360 |
fi |
361 |
} |
362 |
|
363 |
formatresults() |
364 |
{ |
365 |
# formatresults expt genmake depend make run results* |
366 |
|
367 |
nm=$1 |
368 |
printf '%s %s %s %s' $2 $3 $4 $5 |
369 |
shift; shift; shift; shift; shift; |
370 |
printf '%3s' $@ |
371 |
|
372 |
if [ $1 = '--' ]; then |
373 |
printf ' N/O ' |
374 |
else |
375 |
if [ $1 -gt 12 ]; then |
376 |
printf ' pass' |
377 |
else |
378 |
printf ' FAIL' |
379 |
fi |
380 |
fi |
381 |
printf ' %s' $nm |
382 |
printf '\n' |
383 |
|
384 |
} |
385 |
|
386 |
show_help() |
387 |
{ |
388 |
cat - << EOF |
389 |
$0 [-help] [-quick] [-verbose] dir1 [dir2] [...] |
390 |
|
391 |
-help|-h Show this help message |
392 |
-quiet Reduce the amount of output |
393 |
-verbose Produce copious amounts of output |
394 |
-debug Produce even more output which will mean nothing to most |
395 |
-force Do "make CLEAN" before compiling. This forces a complete rebuild. |
396 |
-clean Do "make CLEAN" after compiling and testing. |
397 |
-cleanup Aggresively removes all model output, executables and object files |
398 |
and then exits. Use with care. |
399 |
|
400 |
Normal usage: |
401 |
$0 * Configure, compile, run and analyze in all experiment directories |
402 |
EOF |
403 |
} |
404 |
|
405 |
scandirs() |
406 |
{ |
407 |
if [ $# -eq 0 ]; then |
408 |
for arg in * ; do |
409 |
test -d $arg/input && echo $arg |
410 |
done |
411 |
else |
412 |
echo $* |
413 |
fi |
414 |
} |
415 |
|
416 |
|
417 |
############################################################################### |
418 |
############################################################################### |
419 |
############################################################################### |
420 |
|
421 |
|
422 |
# Default properties |
423 |
debug=0 |
424 |
verbose=1 |
425 |
clean=0 |
426 |
expts='' |
427 |
# ieee=1 |
428 |
|
429 |
IEEE= |
430 |
if test "x$MITGCM_IEEE" != x ; then |
431 |
IEEE=$MITGCM_IEEE |
432 |
fi |
433 |
|
434 |
|
435 |
CLEANUP=f |
436 |
QUICK=f |
437 |
NOGENMAKE=f |
438 |
NOCLEAN=f |
439 |
NODEPEND=f |
440 |
|
441 |
BASH= |
442 |
OPTFILE=NONE |
443 |
ADDRESSES= |
444 |
TESTDIRS= |
445 |
MPACKDIR="../tools/mpack-1.6" |
446 |
MPACK="$MPACKDIR/mpack" |
447 |
COMMAND="make output.txt" |
448 |
MAKE=make |
449 |
MPI=f |
450 |
|
451 |
echo -n "parsing options... " |
452 |
|
453 |
ac_prev= |
454 |
for ac_option ; do |
455 |
|
456 |
# If the previous option needs an argument, assign it. |
457 |
if test -n "$ac_prev"; then |
458 |
eval "$ac_prev=\$ac_option" |
459 |
ac_prev= |
460 |
continue |
461 |
fi |
462 |
|
463 |
ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` |
464 |
|
465 |
case $ac_option in |
466 |
|
467 |
-help | --help | -h | --h) |
468 |
usage ;; |
469 |
|
470 |
-optfile | --optfile | -of | --of) |
471 |
ac_prev=OPTFILE ;; |
472 |
-optfile=* | --optfile=* | -of=* | --of=*) |
473 |
OPTFILE=$ac_optarg ;; |
474 |
|
475 |
-addr | --addr | -a | --a) |
476 |
ac_prev=ADDRESSES ;; |
477 |
-addr=* | --addr=*) |
478 |
ADDRESSES=$ac_optarg ;; |
479 |
|
480 |
-tdir | --tdir | -t | --t) |
481 |
ac_prev=TESTDIRS ;; |
482 |
-tdir=* | --tdir=*) |
483 |
TESTDIRS=$ac_optarg ;; |
484 |
|
485 |
-bash | --bash | -b | --b) |
486 |
ac_prev=BASH ;; |
487 |
-bash=* | --bash=*) |
488 |
BASH=$ac_optarg ;; |
489 |
|
490 |
-command | --command | -c | --c) |
491 |
ac_prev=COMMAND ;; |
492 |
-command=* | --command=*) |
493 |
COMMAND=$ac_optarg ;; |
494 |
|
495 |
-make | --make | -m | --m) |
496 |
ac_prev=MAKE ;; |
497 |
-make=* | --make=*) |
498 |
MAKE=$ac_optarg ;; |
499 |
|
500 |
-clean | --clean) |
501 |
CLEANUP=t ;; |
502 |
|
503 |
-quick | --quick | -q | --q) |
504 |
QUICK=t ;; |
505 |
-nogenmake | --nogenmake | -ng | --ng) |
506 |
NOGENMAKE=t ;; |
507 |
-noclean | --noclean | -nc | --nc) |
508 |
NOCLEAN=t ;; |
509 |
-nodepend | --nodepend | -nd | --nd) |
510 |
NODEPEND=t ;; |
511 |
|
512 |
-mpi) MPI=true ;; |
513 |
|
514 |
-ieee) IEEE=true ;; |
515 |
-noieee) IEEE= ;; |
516 |
|
517 |
-verbose) verbose=2 ;; |
518 |
-debug) debug=1 ;; |
519 |
-quiet) verbose=0 ;; |
520 |
|
521 |
-*) |
522 |
echo "Error: unrecognized option: "$ac_option |
523 |
usage |
524 |
;; |
525 |
|
526 |
*) |
527 |
echo "Error: unrecognized argument: "$ac_option |
528 |
usage |
529 |
;; |
530 |
|
531 |
esac |
532 |
|
533 |
done |
534 |
|
535 |
if test "x$QUICK" = xt ; then |
536 |
NOGENMAKE=t |
537 |
NOCLEAN=t |
538 |
NODEPEND=t |
539 |
fi |
540 |
|
541 |
if test "x$TESTDIRS" = x ; then |
542 |
TESTDIRS=`scandirs` |
543 |
fi |
544 |
|
545 |
if test "x$OPTFILE" = xNONE -a "x$MITGCM_OF" != x ; then |
546 |
OPTFILE=$MITGCM_OF |
547 |
fi |
548 |
|
549 |
echo "OK" |
550 |
|
551 |
# create the FORTRAN comparison code |
552 |
createcodelet |
553 |
|
554 |
# build the mpack utility |
555 |
build_mpack |
556 |
|
557 |
# Create a uniquely named directory to store results |
558 |
MACH=`hostname` |
559 |
UNAMEA=`uname -a` |
560 |
DATE=`date +%Y%m%d` |
561 |
BASE=$MACH"_"$DATE"_" |
562 |
DNUM=0 |
563 |
DRESULTS="$BASE$DNUM" |
564 |
while test -e $DRESULTS ; do |
565 |
DNUM=$(( $DNUM + 1 )) |
566 |
DRESULTS="$BASE$DNUM" |
567 |
done |
568 |
mkdir $DRESULTS |
569 |
RETVAL=$? |
570 |
if test "x$RETVAL" != x0 ; then |
571 |
echo "Error: can't create results directory \"./$DRESULTS\"" |
572 |
exit 1 |
573 |
fi |
574 |
SUMMARY="$DRESULTS/summary.txt" |
575 |
date > $SUMMARY |
576 |
cat << EOF >> $SUMMARY |
577 |
T S U V |
578 |
G D M c m s m s m s m s |
579 |
E p a R g m m e . m m e . m m e . m m e . |
580 |
N n k u 2 i a a d i a a d i a a d i a a d |
581 |
2 d e n d n x n . n x n . n x n . n x n . |
582 |
|
583 |
EOF |
584 |
|
585 |
NDIR=0 |
586 |
|
587 |
of_path= |
588 |
if test "x$OPTFILE" != xNONE ; then |
589 |
if test -r $OPTFILE ; then |
590 |
# get the path |
591 |
path=${OPTFILE%/*} |
592 |
if test "x$path" = x ; then |
593 |
of_path=`pwd` |
594 |
else |
595 |
of_path=`( cd $path > /dev/null 2>&1 ; pwd )` |
596 |
fi |
597 |
file=${OPTFILE##*/} |
598 |
OPTFILE=$of_path/$file |
599 |
else |
600 |
echo |
601 |
echo "WARNING: can't read OPTFILE=\"$OPTFILE\" but will try to use it..." |
602 |
fi |
603 |
fi |
604 |
echo |
605 |
echo "OPTFILE=$OPTFILE" >> $SUMMARY |
606 |
echo >> $SUMMARY |
607 |
|
608 |
# ...and each test directory... |
609 |
for dir in $TESTDIRS ; do |
610 |
|
611 |
# Cleanup only! |
612 |
if test "x$CLEANUP" = xt ; then |
613 |
if test -r $dir/build/Makefile ; then |
614 |
( cd $dir/build ; make CLEAN ) |
615 |
fi |
616 |
if test -r $dir/input/Makefile ; then |
617 |
( cd $dir/input ; make CLEAN ) |
618 |
fi |
619 |
continue |
620 |
fi |
621 |
|
622 |
# Verify that the testdir exists and contains previous |
623 |
# results in the correct location--or skip this directory! |
624 |
if test ! -r $dir"/results/output.txt" ; then |
625 |
echo "can't read \"$dir/results/output.txt\" -- skipping $dir" |
626 |
continue |
627 |
fi |
628 |
|
629 |
echo "-------------------------------------------------------------------------------" |
630 |
echo |
631 |
echo "Experiment: $dir" |
632 |
echo |
633 |
unset genmake makedepend make run |
634 |
results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --' |
635 |
|
636 |
if [ -r $dir/build ]; then |
637 |
seperatebuilddir=1 |
638 |
builddir=build |
639 |
rundir=build |
640 |
( cd $dir/build; ln -sf ../input/* . ) |
641 |
else |
642 |
seperatebuilddir=0 |
643 |
builddir=input |
644 |
rundir=input |
645 |
fi |
646 |
|
647 |
CODE_DIR=$dir/code |
648 |
BUILD_DIR=$dir/$builddir |
649 |
MPI_FILES="CPP_EEOPTIONS.h_mpi SIZE.h_mpi" |
650 |
NOMPI_FILES="CPP_EEOPTIONS.h_nompi SIZE.h_nompi" |
651 |
|
652 |
# Is this an MPI run? |
653 |
if test "x$MPI" = xt ; then |
654 |
FILES=$MPI_FILES |
655 |
endings="_mpi" |
656 |
else |
657 |
FILES=$NOMPI_FILES |
658 |
endings="_nompi" |
659 |
fi |
660 |
|
661 |
# Check to see that we have the files |
662 |
have_files=t |
663 |
for i in $FILES ; do |
664 |
if test ! -r $CODE_DIR/$i ; then |
665 |
echo "Warning: can't read file $CODE_DIR/$i" |
666 |
have_files=f |
667 |
fi |
668 |
done |
669 |
if test "x$have_files" != xt -a "x$MPI" = xt ; then |
670 |
echo "Skipping $dir due to lack of input files (see above warning)" |
671 |
continue |
672 |
fi |
673 |
|
674 |
# If we have the $FILES and they differ, copy the $FILES to $BUILD_DIR |
675 |
if test "x$have_files" = xt ; then |
676 |
for i in $FILES ; do |
677 |
sstr="s|$endings||" |
678 |
name=`echo $i | sed -e $sstr ` |
679 |
cmp $CODE_DIR/$i $BUILD_DIR/$name > /dev/null 2>&1 |
680 |
RETVAL=$? |
681 |
if test "x$RETVAL" != x0 ; then |
682 |
cp $CODE_DIR/$i $BUILD_DIR/$name |
683 |
fi |
684 |
done |
685 |
fi |
686 |
|
687 |
# Create an output dir for each OPTFILE/tdir combination |
688 |
CDIR=$DRESULTS"/"$DRESULTS"_"$NDIR |
689 |
mkdir $CDIR |
690 |
CDIR=`pwd`"/$CDIR" |
691 |
|
692 |
if test "x$CLEANUP" = xt ; then |
693 |
makeclean $dir/$builddir |
694 |
else |
695 |
genmakemodel $dir/$builddir && genmake=Y \ |
696 |
&& makeclean $dir/$builddir \ |
697 |
&& makedependmodel $dir/$builddir && makedepend=Y \ |
698 |
&& makemodel $dir/$builddir && make=Y \ |
699 |
&& linkdata $seperatebuilddir $dir/$rundir \ |
700 |
&& runmodel $dir/$builddir && run=Y \ |
701 |
&& results=`testoutput $dir $rundir` |
702 |
fi |
703 |
|
704 |
echo |
705 |
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
706 |
${run:-N} $results |
707 |
echo |
708 |
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
709 |
${run:-N} $results >> $SUMMARY |
710 |
echo "fresults='" > $CDIR"/summary.txt" |
711 |
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
712 |
${run:-N} $results >> $CDIR"/summary.txt" |
713 |
echo "'" >> $CDIR"/summary.txt" |
714 |
echo "MACH='$MACH'" >> $CDIR"/summary.txt" |
715 |
echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt" |
716 |
echo "DATE='$DATE'" >> $CDIR"/summary.txt" |
717 |
echo "tdir='$dir'" >> $CDIR"/summary.txt" |
718 |
|
719 |
( |
720 |
cd $DRESULTS |
721 |
tar -cf $NDIR".tar" $DRESULTS"_"$NDIR > /dev/null 2>&1 |
722 |
gzip $NDIR".tar" |
723 |
) |
724 |
|
725 |
if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then |
726 |
echo "No mail sent" |
727 |
else |
728 |
$MPACK -s MITgcm-test -m 1000000 $DRESULTS"/"$NDIR".tar.gz" $ADDRESSES |
729 |
RETVAL=$? |
730 |
if test "x$RETVAL" != x0 ; then |
731 |
echo "Warning: \"$MPACK\" failed -- please contact <edhill@mitgcm.org>" |
732 |
else |
733 |
rm -f $DRESULTS"/"$NDIR".tar*" |
734 |
fi |
735 |
fi |
736 |
|
737 |
echo "-------------------------------------------------------------------------------" |
738 |
|
739 |
NDIR=$(( $NDIR + 1 )) |
740 |
|
741 |
done |
742 |
|
743 |
rm tmp_cmpnum.f a.out |
744 |
|
745 |
cat $SUMMARY |