1 |
#!/bin/bash |
#! /usr/bin/env bash |
2 |
# |
# |
3 |
# $Header$ |
# $Header$ |
4 |
|
# $Name$ |
5 |
# |
# |
6 |
|
|
7 |
usage() |
usage() |
11 |
echo |
echo |
12 |
echo "where possible OPTIONS are:" |
echo "where possible OPTIONS are:" |
13 |
echo " (-help|-h) print usage" |
echo " (-help|-h) print usage" |
14 |
echo " (-optfile=|-of=)STRING list of genmake2 \"optfiles\"" |
echo " (-mpi) use MPI input files" |
15 |
echo " (-a|-addr)STRING list of email recipients" |
echo " (-ieee|-noieee) if possible, use IEEE compiler flags" |
16 |
echo " (-t|-tdir)STRING list of \"test\" dirs" |
echo " (DEF=\"noieee\")" |
17 |
|
echo " (-optfile=|-of=)STRING list of optfiles to use" |
18 |
|
echo " (-a|-addr) STRING list of email recipients" |
19 |
|
echo " (DEF=\"edhill@mitgcm.org\")" |
20 |
|
echo " (-t|-tdir) STRING list of test dirs to use" |
21 |
|
echo " (DEF=\"\" which builds all)" |
22 |
|
echo " (-b|-bash) STRING preferred location of a \"bash\" or" |
23 |
|
echo " Bourne-compatible \"sh\" shell" |
24 |
|
echo " (DEF=\"\" for \"bash\")" |
25 |
|
echo " (-command) STRING command to run" |
26 |
|
echo " (DEF=\"make output.txt\")" |
27 |
|
echo " (-m|-make) STRING command to use for \"make\"" |
28 |
|
echo " (DEF=\"make\")" |
29 |
|
echo " (-clean) *ONLY* run \"make CLEAN\"" |
30 |
|
echo " (-quick|-q) same as \"-nogenmake -noclean -nodepend\"" |
31 |
|
echo " (-nogenmake|-ng) skip the genmake stage" |
32 |
|
echo " (-noclean|-nc) skip the \"make clean\" stage" |
33 |
|
echo " (-nodepend|-nd) skip the \"make depend\" stage" |
34 |
|
echo |
35 |
|
echo "and where STRING follows a whitespace-delimited format" |
36 |
|
echo "such as:" |
37 |
|
echo " -t 'exp0 exp2 exp3' " |
38 |
|
echo " -addr='abc@123.com testing@home.org'" |
39 |
echo |
echo |
40 |
exit 1 |
exit 1 |
41 |
} |
} |
46 |
echo -n "building the mpack utility... " |
echo -n "building the mpack utility... " |
47 |
if test ! -x "$MPACKDIR/mpack" ; then |
if test ! -x "$MPACKDIR/mpack" ; then |
48 |
if test ! -d $MPACKDIR ; then |
if test ! -d $MPACKDIR ; then |
49 |
|
echo |
50 |
echo "Error: can't find \"$MPACKDIR\"" |
echo "Error: can't find \"$MPACKDIR\"" |
51 |
echo " are you sure this program is being run in the correct " |
echo " are you sure this program is being run in the correct " |
52 |
echo " (that is, \"MITGCM_ROOT\verification\") directory?" |
echo " (that is, \"MITGCM_ROOT\verification\") directory?" |
53 |
exit 1 |
echo |
54 |
|
HAVE_MPACK=f |
55 |
fi |
fi |
56 |
echo -n "building mpack... " |
echo -n "building mpack... " |
57 |
( cd $MPACKDIR && ./configure && make ) > build_mpack.out 2>&1 |
( cd $MPACKDIR && ./configure && $MAKE ) > build_mpack.out 2>&1 |
58 |
RETVAL=$? |
RETVAL=$? |
59 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
60 |
echo |
echo |
61 |
echo "Error building the mpack tools at: $MPACK_DIR" |
echo "Error building the mpack tools at: $MPACK_DIR" |
62 |
exit 1 |
echo |
63 |
|
HAVE_MPACK=f |
64 |
|
else |
65 |
|
HAVE_MPACK=t |
66 |
fi |
fi |
67 |
|
else |
68 |
|
HAVE_MPACK=t |
69 |
fi |
fi |
70 |
echo "OK" |
echo "OK" |
71 |
} |
} |
72 |
|
|
|
compare_lines() |
|
|
{ |
|
|
# use codelet to compare lines |
|
|
if [ $verbose -gt 1 ]; then |
|
|
cat tmp3.txt 1>&2 |
|
|
fi |
|
|
return `./a.out < tmp3.txt` |
|
|
} |
|
|
|
|
73 |
testoutput_for_prop() |
testoutput_for_prop() |
74 |
{ |
{ |
75 |
# testoutput_for_prop dir s1 label subdir |
# testoutput_for_prop dir s1 label subdir |
81 |
echo testoutput_for_prop: grep "$2" $1/$4/output.txt 1>&2 |
echo testoutput_for_prop: grep "$2" $1/$4/output.txt 1>&2 |
82 |
fi |
fi |
83 |
if [ -r $1/$4/output.txt ]; then |
if [ -r $1/$4/output.txt ]; then |
84 |
grep "$2" $1/$4/output.txt | sed 's/.*=//' | nl > tmp1.txt |
grep "$2" $1/$4/output.txt | sed 's/.*=//' | cat -n > tmp1.txt |
85 |
lncnt=`wc -l tmp1.txt | awk '{print $1}' ` |
lncnt=`wc -l tmp1.txt | awk '{print $1}' ` |
86 |
if [ $lncnt -lt 3 ]; then |
if [ $lncnt -lt 3 ]; then |
87 |
if [ $verbose -gt 0 ]; then |
if [ $verbose -gt 0 ]; then |
96 |
if [ $debug -gt 0 ]; then |
if [ $debug -gt 0 ]; then |
97 |
echo testoutput_for_prop: grep "$2" $1/results/output.txt 1>&2 |
echo testoutput_for_prop: grep "$2" $1/results/output.txt 1>&2 |
98 |
fi |
fi |
99 |
grep "$2" $1/results/output.txt | sed 's/.*=//' | nl > tmp2.txt |
grep "$2" $1/results/output.txt | sed 's/.*=//' | cat -n > tmp2.txt |
100 |
lncnt=`wc -l tmp2.txt | awk '{print $1}' ` |
lncnt=`wc -l tmp2.txt | awk '{print $1}' ` |
101 |
if [ $lncnt -lt 3 ]; then |
if [ $lncnt -lt 3 ]; then |
102 |
if [ $verbose -gt 0 ]; then |
if [ $verbose -gt 0 ]; then |
111 |
if [ $debug -gt 0 ]; then |
if [ $debug -gt 0 ]; then |
112 |
echo testoutput_for_prop: compare_lines 1>&2 |
echo testoutput_for_prop: compare_lines 1>&2 |
113 |
fi |
fi |
114 |
compare_lines |
if [ $verbose -gt 1 ]; then |
115 |
digits_of_similarity=$? |
cat tmp3.txt 1>&2 |
116 |
|
fi |
117 |
|
echo "-1" >> tmp3.txt |
118 |
|
# On the SGI O3K (*not* the O2K), "cat -n" inserts a ":" after the line number |
119 |
|
cat tmp3.txt | sed -e 's|:||g' > tmp4.txt |
120 |
|
digits_of_similarity=`./tmp_cmpnum < tmp4.txt` |
121 |
if [ $digits_of_similarity -eq 99 ]; then |
if [ $digits_of_similarity -eq 99 ]; then |
122 |
if [ $verbose -gt 0 ]; then |
if [ $verbose -gt 0 ]; then |
123 |
echo testoutput_for_prop: No comparison was available for \"$2\" 1>&2 |
echo testoutput_for_prop: No comparison was available for \"$2\" 1>&2 |
128 |
echo There were $digits_of_similarity decimal places of similarity for \"$2\" 1>&2 |
echo There were $digits_of_similarity decimal places of similarity for \"$2\" 1>&2 |
129 |
fi |
fi |
130 |
fi |
fi |
131 |
rm tmp1.txt tmp2.txt tmp3.txt |
rm -f tmp1.txt tmp2.txt tmp3.txt tmp4.txt |
132 |
|
|
133 |
return $digits_of_similarity |
return $digits_of_similarity |
134 |
} |
} |
161 |
if [ $debug -gt 0 ]; then |
if [ $debug -gt 0 ]; then |
162 |
echo testoutput: cg2dres=$cg2dres 1>&2 |
echo testoutput: cg2dres=$cg2dres 1>&2 |
163 |
fi |
fi |
|
|
|
164 |
testoutput_for_prop $1 "dynstat_theta_min" "theta minimum" $2; tmin=$? |
testoutput_for_prop $1 "dynstat_theta_min" "theta minimum" $2; tmin=$? |
165 |
testoutput_for_prop $1 "dynstat_theta_max" "theta maximum" $2; tmax=$? |
testoutput_for_prop $1 "dynstat_theta_max" "theta maximum" $2; tmax=$? |
166 |
testoutput_for_prop $1 "dynstat_theta_mean" "theta mean" $2; tmean=$? |
testoutput_for_prop $1 "dynstat_theta_mean" "theta mean" $2; tmean=$? |
185 |
genmakemodel() |
genmakemodel() |
186 |
{ |
{ |
187 |
# genmakemodel directory |
# genmakemodel directory |
188 |
GENMAKE2="../../../tools/genmake2" |
if test "x$NOGENMAKE" = xt ; then |
189 |
( |
echo "genmake skipped!" |
190 |
cd $1; |
else |
191 |
printf 'genmake ... ' 1>&2 |
GENMAKE2="$BASH ../../../tools/genmake2" |
192 |
# ../../../tools/genmake -ieee -mods=../code > make.log 2>&1 |
( |
193 |
$GENMAKE2 -ds --mods=../code "--optfile="$OPTFILE > make.log 2>&1 |
cd $1; |
194 |
RETVAL=$? |
command="$GENMAKE2 -ds -m $MAKE --mods=../code" |
195 |
for i in gm_state gm_optfile gm_local Makefile ; do |
if test "x$OPTFILE" != xNONE ; then |
196 |
if test -r $i ; then |
command="$command --optfile=$OPTFILE" |
|
cp $i $CDIR |
|
197 |
fi |
fi |
198 |
done |
if test "x$IEEE" != x ; then |
199 |
if test "x$RETVAL" != x0 ; then |
command="$command -ieee" |
200 |
tail make.log |
fi |
201 |
echo "genmakemodel: genmake failed" 1>&2 |
printf 'genmake ... ' 1>&2 |
202 |
cp make.log $CDIR |
$command > make.log 2>&1 |
203 |
return 1 |
RETVAL=$? |
204 |
else |
cp Makefile $CDIR |
205 |
echo "succesful" 1>&2 |
if test "x$RETVAL" != x0 ; then |
206 |
fi |
tail make.log |
207 |
) |
echo "genmakemodel: genmake failed" 1>&2 |
208 |
|
cp genmake_* make.log $CDIR |
209 |
|
return 1 |
210 |
|
else |
211 |
|
echo "successful" 1>&2 |
212 |
|
fi |
213 |
|
) |
214 |
|
fi |
215 |
} |
} |
216 |
|
|
217 |
makeclean() |
makeclean() |
218 |
{ |
{ |
219 |
# makeclean directory |
# makeclean directory |
220 |
( |
if test "x$NOCLEAN" = xt ; then |
221 |
cd $1; |
echo "make CLEAN skipped!" |
222 |
rm -f output.txt |
else |
223 |
printf 'make CLEAN ... ' 2>&1 |
( |
224 |
if test -r Makefile ; then |
cd $1; |
225 |
make CLEAN >> make.log 2>&1 |
if test -e output.txt ; then |
226 |
RETVAL=$? |
rm -f output.txt |
|
if test "x$RETVAL" != x0 ; then |
|
|
tail make.log |
|
|
echo "makeclean: \"make CLEAN\" failed" 1>&2 |
|
|
cp make.log $CDIR"/make.log" |
|
|
return 1 |
|
227 |
fi |
fi |
228 |
fi |
printf 'make CLEAN ... ' 2>&1 |
229 |
echo succesful 1>&2 |
if test -r Makefile ; then |
230 |
exit 0 |
$MAKE CLEAN >> make.log 2>&1 |
231 |
) |
RETVAL=$? |
232 |
|
if test "x$RETVAL" != x0 ; then |
233 |
|
tail make.log |
234 |
|
echo "makeclean: \"make CLEAN\" failed" 1>&2 |
235 |
|
cp make.log $CDIR"/make.log" |
236 |
|
return 1 |
237 |
|
fi |
238 |
|
fi |
239 |
|
echo successful 1>&2 |
240 |
|
exit 0 |
241 |
|
) |
242 |
|
fi |
243 |
} |
} |
244 |
|
|
245 |
makedependmodel() |
makedependmodel() |
246 |
{ |
{ |
247 |
# makedependmodel directory |
# makedependmodel directory |
248 |
( |
if test "x$NODEPEND" = xt ; then |
249 |
cd $1; |
echo "make depend skipped!" |
250 |
printf 'make depend ... ' 1>&2 |
else |
251 |
make depend >> make.log 2>&1 |
( |
252 |
RETVAL=$? |
cd $1; |
253 |
if test "x$RETVAL" != x0 ; then |
printf 'make depend ... ' 1>&2 |
254 |
tail make.log |
$MAKE depend >> make.log 2>&1 |
255 |
echo "makedependmodel: make depend failed" 1>&2 |
RETVAL=$? |
256 |
cp make.log $CDIR"/make.log" |
if test "x$RETVAL" != x0 ; then |
257 |
return 1 |
tail make.log |
258 |
else |
echo "makedependmodel: make depend failed" 1>&2 |
259 |
echo succesful 1>&2 |
cp make.log $CDIR"/make.log" |
260 |
fi |
return 1 |
261 |
) |
else |
262 |
|
echo successful 1>&2 |
263 |
|
fi |
264 |
|
) |
265 |
|
fi |
266 |
} |
} |
267 |
|
|
268 |
makemodel() |
makemodel() |
272 |
cd $1; |
cd $1; |
273 |
if test -r Makefile ; then |
if test -r Makefile ; then |
274 |
printf 'make ... ' 1>&2 |
printf 'make ... ' 1>&2 |
275 |
make >> make.log 2>&1 |
$MAKE >> make.log 2>&1 |
276 |
RETVAL=$? |
RETVAL=$? |
277 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
278 |
tail make.log |
tail make.log |
280 |
cp make.log $CDIR"/make.log" |
cp make.log $CDIR"/make.log" |
281 |
return 1 |
return 1 |
282 |
else |
else |
283 |
echo succesful 1>&2 |
echo successful 1>&2 |
284 |
fi |
fi |
285 |
fi |
fi |
286 |
) |
) |
291 |
# linkdata flag |
# linkdata flag |
292 |
# |
# |
293 |
# symbolically link data files to run directory |
# symbolically link data files to run directory |
294 |
if [ $1 -ne 0 ]; then |
if test "x$1" = x1 ; then |
295 |
( cd $2 ; ln -sf ../input/* . ) |
( |
296 |
|
cd $2 |
297 |
|
files=`( cd ../input ; ls -1 | grep -v CVS )` |
298 |
|
for i in $files ; do |
299 |
|
if test ! -d "../input/"$i ; then |
300 |
|
ln -sf "../input/"$i $i |
301 |
|
fi |
302 |
|
done |
303 |
|
) |
304 |
fi |
fi |
305 |
} |
} |
306 |
|
|
307 |
runmodel() |
runmodel() |
308 |
{ |
{ |
309 |
# runmodel directory exe |
# runmodel directory |
310 |
# |
# |
311 |
# runs the model "exe" in "directory" (exe is relative to directory) |
# runs "$COMMAND" in "directory" |
312 |
|
# (where "$COMMAND" is relative to "directory") |
313 |
( |
( |
314 |
cd $1 |
cd $1 |
315 |
if [ -x $2 ]; then |
printf 'runmodel ... ' 1>&2 |
316 |
if [ $quick -eq 0 ]; then |
# make output.txt |
317 |
rm -f output.txt |
$COMMAND >> run.log 2>&1 |
318 |
fi |
RETVAL=$? |
319 |
printf 'runmodel: ' 1>&2 |
if test "x$RETVAL" = x0 ; then |
320 |
make output.txt |
echo successful 1>&2 |
321 |
RETVAL=$? |
cp output.txt $CDIR"/output.txt" |
322 |
if test "x$RETVAL" = x0 ; then |
return 0 |
323 |
cp output.txt $CDIR"/output.txt" |
else |
324 |
return 0 |
tail run.log |
325 |
else |
echo failed 1>&2 |
326 |
return 1 |
cp run.log $CDIR"/run.log" |
327 |
fi |
return 1 |
328 |
fi |
fi |
329 |
) |
) |
330 |
} |
} |
334 |
# create codelet for comparing model output |
# create codelet for comparing model output |
335 |
|
|
336 |
echo -n "creating the comparison code... " |
echo -n "creating the comparison code... " |
337 |
cat > tmp_cmpnum.f <<EOFA |
cat > tmp_cmpnum.c <<EOF |
338 |
program cmpnum |
#include <stdio.h> |
339 |
implicit none |
#include <math.h> |
340 |
real*8 a,b,diff |
int main( int argc, char** argv ) { |
341 |
integer linnum,best |
int linnum,best; |
342 |
best=-16 |
double a,b,diff; |
343 |
99 read(*,*,end=70,err=60) linnum,a,b |
best = -16; |
344 |
diff=0.5*(abs(a)+abs(b)) |
while( 1 ) { |
345 |
c print *,a,b,diff,abs(a-b)/diff |
scanf("%d", &linnum); |
346 |
if (diff.gt.1.e-12) then |
if (linnum == -1) break; |
347 |
diff=abs(a-b)/diff |
scanf("%lf", &a); scanf("%lf", &b); |
348 |
if (diff.gt.0.) then |
diff = 0.5*(fabs(a)+fabs(b)); |
349 |
c print *,int(log10(diff)),diff |
if (diff > 1.e-12) { |
350 |
linnum=int(log10(diff)) |
diff=fabs(a-b)/diff; |
351 |
best=max(best,linnum) |
if (diff > 0.0) { |
352 |
endif |
linnum = (int)log10(diff); |
353 |
else |
best = (best > linnum) ? best : linnum; |
354 |
if (best.eq.-16.and.diff.ne.0.) best=-22 |
} |
355 |
endif |
else { |
356 |
goto 99 |
if (best == -16 && diff != 0) best = -22; |
357 |
60 stop 'cmpnum: An error occured reading a,b' |
} |
358 |
70 print *,-best |
} |
359 |
end |
} |
360 |
EOFA |
printf("%d\n", -best); |
361 |
|
return 0; |
362 |
|
} |
363 |
|
EOF |
364 |
|
cc -o tmp_cmpnum tmp_cmpnum.c -lm |
365 |
|
|
366 |
f77 tmp_cmpnum.f |
if [ -x ./tmp_cmpnum ]; then |
|
if [ -x ./a.out ]; then |
|
367 |
echo "OK" |
echo "OK" |
368 |
return 0 |
return 0 |
369 |
else |
else |
370 |
echo |
echo |
371 |
echo "createcodelet: failed to compile codelet" | tee |
echo "ERROR: failed to compile comparison code" |
372 |
exit 1 |
exit 1 |
373 |
fi |
fi |
374 |
} |
} |
400 |
{ |
{ |
401 |
cat - << EOF |
cat - << EOF |
402 |
$0 [-help] [-quick] [-verbose] dir1 [dir2] [...] |
$0 [-help] [-quick] [-verbose] dir1 [dir2] [...] |
403 |
-help Show this help message |
|
404 |
-quick Skip "genmake" and "make depend" if the Makefile exists |
-help|-h Show this help message |
405 |
-quiet Reduce the amount of output |
-quiet Reduce the amount of output |
406 |
-verbose Produce copious amounts of output |
-verbose Produce copious amounts of output |
407 |
-debug Produce even more output which will mean nothing to most |
-debug Produce even more output which will mean nothing to most |
408 |
-force Do "make CLEAN" before compiling. This forces a complete rebuild. |
-force Do "make CLEAN" before compiling. This forces a complete rebuild. |
409 |
-clean Do "make CLEAN" after compiling and testing. |
-clean Do "make CLEAN" after compiling and testing. |
|
-noieee By default, $0 uses the -ieee option for genmake. This turns it off. |
|
410 |
-cleanup Aggresively removes all model output, executables and object files |
-cleanup Aggresively removes all model output, executables and object files |
411 |
and then exits. Use with care. |
and then exits. Use with care. |
412 |
|
|
428 |
|
|
429 |
|
|
430 |
############################################################################### |
############################################################################### |
|
############################################################################### |
|
|
############################################################################### |
|
431 |
|
|
432 |
|
|
433 |
# Default properties |
# Default properties |
434 |
debug=0 |
debug=0 |
435 |
verbose=1 |
verbose=1 |
|
quick=0 |
|
436 |
clean=0 |
clean=0 |
|
ieee=1 |
|
437 |
expts='' |
expts='' |
438 |
|
# ieee=1 |
439 |
|
|
440 |
|
IEEE= |
441 |
|
if test "x$MITGCM_IEEE" != x ; then |
442 |
|
IEEE=$MITGCM_IEEE |
443 |
|
fi |
444 |
|
|
445 |
OPTFILES= |
|
446 |
ADDRESSES=edhill@mitgcm.org |
CLEANUP=f |
447 |
|
QUICK=f |
448 |
|
NOGENMAKE=f |
449 |
|
NOCLEAN=f |
450 |
|
NODEPEND=f |
451 |
|
|
452 |
|
BASH= |
453 |
|
OPTFILE=NONE |
454 |
|
ADDRESSES= |
455 |
TESTDIRS= |
TESTDIRS= |
456 |
MPACKDIR="../tools/mpack-1.6" |
MPACKDIR="../tools/mpack-1.6" |
457 |
|
HAVE_MPACK= |
458 |
MPACK="$MPACKDIR/mpack" |
MPACK="$MPACKDIR/mpack" |
459 |
|
COMMAND="make output.txt" |
460 |
|
MAKE=make |
461 |
|
MPI=f |
462 |
|
|
463 |
echo -n "parsing options... " |
echo -n "parsing options... " |
464 |
|
|
480 |
usage ;; |
usage ;; |
481 |
|
|
482 |
-optfile | --optfile | -of | --of) |
-optfile | --optfile | -of | --of) |
483 |
ac_prev=OPTFILES ;; |
ac_prev=OPTFILE ;; |
484 |
-optfile=* | --optfile=* | -of=* | --of=*) |
-optfile=* | --optfile=* | -of=* | --of=*) |
485 |
OPTFILES=$ac_optarg ;; |
OPTFILE=$ac_optarg ;; |
486 |
|
|
487 |
-addr | --addr | -a | --a) |
-addr | --addr | -a | --a) |
488 |
ac_prev=ADDRESSES ;; |
ac_prev=ADDRESSES ;; |
494 |
-tdir=* | --tdir=*) |
-tdir=* | --tdir=*) |
495 |
TESTDIRS=$ac_optarg ;; |
TESTDIRS=$ac_optarg ;; |
496 |
|
|
497 |
-quick) quick=1 ;; |
-bash | --bash | -b | --b) |
498 |
|
ac_prev=BASH ;; |
499 |
|
-bash=* | --bash=*) |
500 |
|
BASH=$ac_optarg ;; |
501 |
|
|
502 |
|
-command | --command | -c | --c) |
503 |
|
ac_prev=COMMAND ;; |
504 |
|
-command=* | --command=*) |
505 |
|
COMMAND=$ac_optarg ;; |
506 |
|
|
507 |
|
-make | --make | -m | --m) |
508 |
|
ac_prev=MAKE ;; |
509 |
|
-make=* | --make=*) |
510 |
|
MAKE=$ac_optarg ;; |
511 |
|
|
512 |
|
-clean | --clean) |
513 |
|
CLEANUP=t ;; |
514 |
|
|
515 |
|
-quick | --quick | -q | --q) |
516 |
|
QUICK=t ;; |
517 |
|
-nogenmake | --nogenmake | -ng | --ng) |
518 |
|
NOGENMAKE=t ;; |
519 |
|
-noclean | --noclean | -nc | --nc) |
520 |
|
NOCLEAN=t ;; |
521 |
|
-nodepend | --nodepend | -nd | --nd) |
522 |
|
NODEPEND=t ;; |
523 |
|
|
524 |
|
-mpi) MPI=t ;; |
525 |
|
|
526 |
|
-ieee) IEEE=true ;; |
527 |
|
-noieee) IEEE= ;; |
528 |
|
|
529 |
-verbose) verbose=2 ;; |
-verbose) verbose=2 ;; |
530 |
-debug) debug=1 ;; |
-debug) debug=1 ;; |
|
-clean) clean=1 ;; |
|
|
-noieee) ieee=0 ;; |
|
531 |
-quiet) verbose=0 ;; |
-quiet) verbose=0 ;; |
532 |
|
|
533 |
-*) |
-*) |
544 |
|
|
545 |
done |
done |
546 |
|
|
547 |
|
if test "x$QUICK" = xt ; then |
548 |
|
NOGENMAKE=t |
549 |
|
NOCLEAN=t |
550 |
|
NODEPEND=t |
551 |
|
fi |
552 |
|
|
553 |
if test "x$TESTDIRS" = x ; then |
if test "x$TESTDIRS" = x ; then |
554 |
TESTDIRS=`scandirs` |
TESTDIRS=`scandirs` |
555 |
fi |
fi |
556 |
|
|
557 |
|
if test "x$OPTFILE" = xNONE -a "x$MITGCM_OF" != x ; then |
558 |
|
OPTFILE=$MITGCM_OF |
559 |
|
fi |
560 |
|
|
561 |
echo "OK" |
echo "OK" |
562 |
|
|
563 |
# create the FORTRAN comparison code |
# create the FORTRAN comparison code |
580 |
mkdir $DRESULTS |
mkdir $DRESULTS |
581 |
RETVAL=$? |
RETVAL=$? |
582 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
583 |
echo "Error: can't create results directory \"./$DRESULTS\"" |
echo "ERROR: Can't create results directory \"./$DRESULTS\"" |
584 |
exit 1 |
exit 1 |
585 |
fi |
fi |
586 |
SUMMARY="$DRESULTS/summary.txt" |
SUMMARY="$DRESULTS/summary.txt" |
587 |
date > $SUMMARY |
echo -n "Start time: " >> $SUMMARY |
588 |
cat << EOF >> $SUMMARY |
start_date=`date` |
589 |
|
echo $start_date > $SUMMARY |
590 |
|
|
591 |
|
of_path= |
592 |
|
if test "x$OPTFILE" != xNONE ; then |
593 |
|
if test -r $OPTFILE ; then |
594 |
|
# get the path |
595 |
|
path=${OPTFILE%/*} |
596 |
|
if test "x$path" = x ; then |
597 |
|
of_path=`pwd` |
598 |
|
else |
599 |
|
of_path=`( cd $path > /dev/null 2>&1 ; pwd )` |
600 |
|
fi |
601 |
|
file=${OPTFILE##*/} |
602 |
|
OPTFILE=$of_path/$file |
603 |
|
cp $OPTFILE $DRESULTS |
604 |
|
echo >> $SUMMARY |
605 |
|
echo " OPTFILE=$OPTFILE" >> $SUMMARY |
606 |
|
else |
607 |
|
echo | tee $SUMMARY |
608 |
|
echo "ERROR: can't read OPTFILE=\"$OPTFILE\"" | tee $SUMMARY |
609 |
|
exit 1 |
610 |
|
fi |
611 |
|
else |
612 |
|
echo >> $SUMMARY |
613 |
|
echo "No \"OPTFILE\" was explicitly specified by testreport," >> $SUMMARY |
614 |
|
echo " so the genmake default will be used." >> $SUMMARY |
615 |
|
fi |
616 |
|
echo |
617 |
|
echo >> $SUMMARY |
618 |
|
cat << EOF | tee -a $SUMMARY |
619 |
T S U V |
T S U V |
620 |
G D M c m s m s m s m s |
G D M c m s m s m s m s |
621 |
E p a R g m m e . m m e . m m e . m m e . |
E p a R g m m e . m m e . m m e . m m e . |
624 |
|
|
625 |
EOF |
EOF |
626 |
|
|
627 |
NDIR=0 |
# ...and each test directory... |
628 |
|
for dir in $TESTDIRS ; do |
629 |
# For each optfile... |
|
630 |
for OPTFILE in $OPTFILES ; do |
# Cleanup only! |
631 |
|
if test "x$CLEANUP" = xt ; then |
632 |
|
if test -r $dir/build/Makefile ; then |
633 |
|
( cd $dir/build ; make CLEAN ) |
634 |
|
fi |
635 |
|
if test -r $dir/input/Makefile ; then |
636 |
|
( cd $dir/input ; make CLEAN ) |
637 |
|
fi |
638 |
|
continue |
639 |
|
fi |
640 |
|
|
641 |
OPTFILE=`pwd`"/$OPTFILE" |
# Verify that the testdir exists and contains previous |
642 |
if test ! -r $OPTFILE ; then |
# results in the correct location--or skip this directory! |
643 |
echo "Error: can't read optfile \"$OPTFILE\"" |
if test ! -r $dir"/results/output.txt" ; then |
644 |
exit 1 |
echo "can't read \"$dir/results/output.txt\" -- skipping $dir" |
645 |
|
continue |
646 |
fi |
fi |
|
echo |
|
|
echo "OPTFILE=$OPTFILE" >> $SUMMARY |
|
|
echo >> $SUMMARY |
|
|
|
|
|
# ...and each test directory... |
|
|
for dir in $TESTDIRS ; do |
|
|
|
|
|
# Create an output dir for each OPTFILE/tdir combination |
|
|
CDIR=$DRESULTS"/"$DRESULTS"_"$NDIR |
|
|
mkdir $CDIR |
|
|
CDIR=`pwd`"/$CDIR" |
|
647 |
|
|
648 |
# ...configue, make, run, and compare the output. |
echo "-------------------------------------------------------------------------------" |
649 |
echo "-------------------------------------------------------------------------------" |
echo |
650 |
echo |
echo "Experiment: $dir" |
651 |
echo "Experiment: $dir" |
echo |
652 |
echo |
unset genmake makedepend make run |
653 |
unset genmake makedepend make run |
results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --' |
|
results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --' |
|
|
( cd $dir/input; rm -f *.{o,f,c,F} *.[f,F]90 work* output.txt Make* make.log; ) |
|
|
if [ -r $dir/build ]; then |
|
|
seperatebuilddir=1 |
|
|
builddir=build |
|
|
rundir=build |
|
|
( cd $dir/build; ln -sf ../input/* . ) |
|
|
else |
|
|
seperatebuilddir=0 |
|
|
builddir=input |
|
|
rundir=input |
|
|
fi |
|
654 |
|
|
655 |
# Verify that the testdir exists and contains previous |
builddir="input" |
656 |
# results in the correct location--or skip this directory! |
rundir="input" |
657 |
if test ! -r $dir"/results/output.txt" ; then |
use_seperate_build=0 |
658 |
echo | tee $SUMMARY |
if test -d $dir/build -a -r $dir/build ; then |
659 |
echo "can't read \"$dir/results/output.txt\" -- skipping $dir" \ |
builddir="build" |
660 |
| tee $SUMMARY |
rundir="build" |
661 |
continue |
use_seperate_build=1 |
662 |
|
linkdata $use_seperate_build $dir/$rundir |
663 |
|
fi |
664 |
|
|
665 |
|
CODE_DIR=$dir/code |
666 |
|
BUILD_DIR=$dir/$builddir |
667 |
|
MPI_FILES="CPP_EEOPTIONS.h_mpi SIZE.h_mpi" |
668 |
|
NOMPI_FILES="CPP_EEOPTIONS.h_nompi SIZE.h_nompi" |
669 |
|
|
670 |
|
# Is this an MPI run? |
671 |
|
if test "x$MPI" = xt ; then |
672 |
|
FILES=$MPI_FILES |
673 |
|
endings="_mpi" |
674 |
|
else |
675 |
|
FILES=$NOMPI_FILES |
676 |
|
endings="_nompi" |
677 |
|
fi |
678 |
|
|
679 |
|
# Check to see that we have the files |
680 |
|
have_files=t |
681 |
|
for i in $FILES ; do |
682 |
|
if test ! -r $CODE_DIR/$i ; then |
683 |
|
echo "Warning: can't read file $CODE_DIR/$i" |
684 |
|
have_files=f |
685 |
fi |
fi |
686 |
|
done |
687 |
|
if test "x$have_files" != xt -a "x$MPI" = xt ; then |
688 |
|
echo "Skipping $dir due to lack of input files (see above warning)" |
689 |
|
continue |
690 |
|
fi |
691 |
|
|
692 |
|
# If we have the $FILES and they differ, copy the $FILES to $BUILD_DIR |
693 |
|
if test "x$have_files" = xt ; then |
694 |
|
for i in $FILES ; do |
695 |
|
sstr="s|$endings||" |
696 |
|
name=`echo $i | sed -e $sstr ` |
697 |
|
cmp $CODE_DIR/$i $BUILD_DIR/$name > /dev/null 2>&1 |
698 |
|
RETVAL=$? |
699 |
|
if test "x$RETVAL" != x0 ; then |
700 |
|
cp $CODE_DIR/$i $BUILD_DIR/$name |
701 |
|
fi |
702 |
|
done |
703 |
|
fi |
704 |
|
|
705 |
|
# Create an output dir for each OPTFILE/tdir combination |
706 |
|
rel_CDIR=$DRESULTS"/"$dir |
707 |
|
mkdir $rel_CDIR |
708 |
|
CDIR=`pwd`"/$rel_CDIR" |
709 |
|
|
710 |
|
if test "x$CLEANUP" = xt ; then |
711 |
|
makeclean $dir/$builddir |
712 |
|
else |
713 |
genmakemodel $dir/$builddir && genmake=Y \ |
genmakemodel $dir/$builddir && genmake=Y \ |
714 |
&& makeclean $dir/$builddir \ |
&& makeclean $dir/$builddir \ |
715 |
&& makedependmodel $dir/$builddir && makedepend=Y \ |
&& makedependmodel $dir/$builddir && makedepend=Y \ |
716 |
&& makemodel $dir/$builddir && make=Y \ |
&& makemodel $dir/$builddir && make=Y \ |
717 |
&& linkdata $seperatebuilddir $dir/$rundir \ |
&& linkdata $use_seperate_build $dir/$rundir \ |
718 |
&& runmodel $dir/$builddir mitgcmuv && run=Y \ |
&& runmodel $dir/$rundir && run=Y \ |
719 |
&& results=`testoutput $dir $rundir` |
&& results=`testoutput $dir $rundir` |
720 |
echo |
fi |
721 |
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
|
722 |
${run:-N} $results |
echo |
723 |
echo |
fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results` |
724 |
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
echo |
725 |
${run:-N} $results >> $SUMMARY |
echo "$fres" >> $SUMMARY |
726 |
echo "fresults='" > $CDIR"/summary.txt" |
echo "fresults='$fres'" > $CDIR"/summary.txt" |
727 |
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
echo "MACH='$MACH'" >> $CDIR"/summary.txt" |
728 |
${run:-N} $results >> $CDIR"/summary.txt" |
echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt" |
729 |
echo "'" >> $CDIR"/summary.txt" |
echo "DATE='$DATE'" >> $CDIR"/summary.txt" |
730 |
echo "MACH='$MACH'" >> $CDIR"/summary.txt" |
echo "tdir='$dir'" >> $CDIR"/summary.txt" |
731 |
echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt" |
|
732 |
echo "DATE='$DATE'" >> $CDIR"/summary.txt" |
echo "-------------------------------------------------------------------------------" |
733 |
echo "tdir='$dir'" >> $CDIR"/summary.txt" |
|
734 |
|
done |
|
( |
|
|
cd $DRESULTS |
|
|
tar -cf $NDIR".tar" $DRESULTS"_"$NDIR > /dev/null 2>&1 |
|
|
gzip $NDIR".tar" |
|
|
) |
|
735 |
|
|
736 |
$MPACK -s MITgcm-test -m 1000000 $DRESULTS"/"$NDIR".tar.gz" $ADDRESSES |
echo -n "Start time: " >> $SUMMARY |
737 |
|
echo $start_date >> $SUMMARY |
738 |
|
echo -n "End time: " >> $SUMMARY |
739 |
|
date >> $SUMMARY |
740 |
|
|
741 |
|
# If addresses were supplied and mpack built successfully, then try |
742 |
|
# to send email using mpack. |
743 |
|
if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then |
744 |
|
echo "No results email was sent." |
745 |
|
else |
746 |
|
if test "x$HAVE_MPACK" = xt ; then |
747 |
|
tar -cf $DRESULTS".tar" $DRESULTS > /dev/null 2>&1 \ |
748 |
|
&& gzip $DRESULTS".tar" \ |
749 |
|
&& $MPACK -s MITgcm-test -m 1500000 $DRESULTS".tar.gz" $ADDRESSES |
750 |
RETVAL=$? |
RETVAL=$? |
751 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
752 |
echo "Warning: \"$MPACK\" failed -- please contact <edhill@mitgcm.org>" |
echo |
753 |
|
echo "Warning: The tar, gzip, & mpack step failed. Please send email" |
754 |
|
echo " to <MITgcm-support@mitgcm.org> for help. You may copy the " |
755 |
|
echo " summary of results from the directory \"$DRESULTS\"." |
756 |
|
echo |
757 |
else |
else |
758 |
rm -f $DRESULTS"/"$NDIR".tar*" |
echo |
759 |
|
echo "An email containing results was sent to the following addresses:" |
760 |
|
echo " \"$ADDRESSES\"" |
761 |
|
echo |
762 |
fi |
fi |
763 |
|
test -f $DRESULTS".tar" && rm -f $DRESULTS".tar" |
764 |
|
test -f $DRESULTS".tar.gz" && rm -f $DRESULTS".tar.gz" |
765 |
|
fi |
766 |
|
fi |
767 |
|
|
768 |
NDIR=$(( $NDIR + 1 )) |
# rm -f tmp_cmpnum.f a.out |
769 |
|
rm -f tmp_cmpnum.c tmp_cmpnum |
|
done |
|
|
done |
|
|
|
|
|
rm tmp_cmpnum.f a.out |
|
770 |
|
|
771 |
cat $SUMMARY |
if test "x$CLEANUP" != xt ; then |
772 |
|
cat $SUMMARY |
773 |
|
if test -e tr.out ; then |
774 |
|
mv tr.out tr.out.old |
775 |
|
fi |
776 |
|
cat $SUMMARY > tr.out |
777 |
|
fi |
778 |
|
|