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 |
} |
} |
90 |
echo testoutput_for_prop: grep "$2" $1/$4/output.txt 1>&2 |
echo testoutput_for_prop: grep "$2" $1/$4/output.txt 1>&2 |
91 |
fi |
fi |
92 |
if [ -r $1/$4/output.txt ]; then |
if [ -r $1/$4/output.txt ]; then |
93 |
grep "$2" $1/$4/output.txt | sed 's/.*=//' | nl > tmp1.txt |
grep "$2" $1/$4/output.txt | sed 's/.*=//' | cat -n > tmp1.txt |
94 |
lncnt=`wc -l tmp1.txt | awk '{print $1}' ` |
lncnt=`wc -l tmp1.txt | awk '{print $1}' ` |
95 |
if [ $lncnt -lt 3 ]; then |
if [ $lncnt -lt 3 ]; then |
96 |
if [ $verbose -gt 0 ]; then |
if [ $verbose -gt 0 ]; then |
105 |
if [ $debug -gt 0 ]; then |
if [ $debug -gt 0 ]; then |
106 |
echo testoutput_for_prop: grep "$2" $1/results/output.txt 1>&2 |
echo testoutput_for_prop: grep "$2" $1/results/output.txt 1>&2 |
107 |
fi |
fi |
108 |
grep "$2" $1/results/output.txt | sed 's/.*=//' | nl > tmp2.txt |
grep "$2" $1/results/output.txt | sed 's/.*=//' | cat -n > tmp2.txt |
109 |
lncnt=`wc -l tmp2.txt | awk '{print $1}' ` |
lncnt=`wc -l tmp2.txt | awk '{print $1}' ` |
110 |
if [ $lncnt -lt 3 ]; then |
if [ $lncnt -lt 3 ]; then |
111 |
if [ $verbose -gt 0 ]; then |
if [ $verbose -gt 0 ]; then |
120 |
if [ $debug -gt 0 ]; then |
if [ $debug -gt 0 ]; then |
121 |
echo testoutput_for_prop: compare_lines 1>&2 |
echo testoutput_for_prop: compare_lines 1>&2 |
122 |
fi |
fi |
123 |
compare_lines |
if [ $verbose -gt 1 ]; then |
124 |
digits_of_similarity=$? |
cat tmp3.txt 1>&2 |
125 |
|
fi |
126 |
|
echo "-1" >> tmp3.txt |
127 |
|
digits_of_similarity=`./tmp_cmpnum < tmp3.txt` |
128 |
if [ $digits_of_similarity -eq 99 ]; then |
if [ $digits_of_similarity -eq 99 ]; then |
129 |
if [ $verbose -gt 0 ]; then |
if [ $verbose -gt 0 ]; then |
130 |
echo testoutput_for_prop: No comparison was available for \"$2\" 1>&2 |
echo testoutput_for_prop: No comparison was available for \"$2\" 1>&2 |
168 |
if [ $debug -gt 0 ]; then |
if [ $debug -gt 0 ]; then |
169 |
echo testoutput: cg2dres=$cg2dres 1>&2 |
echo testoutput: cg2dres=$cg2dres 1>&2 |
170 |
fi |
fi |
|
|
|
171 |
testoutput_for_prop $1 "dynstat_theta_min" "theta minimum" $2; tmin=$? |
testoutput_for_prop $1 "dynstat_theta_min" "theta minimum" $2; tmin=$? |
172 |
testoutput_for_prop $1 "dynstat_theta_max" "theta maximum" $2; tmax=$? |
testoutput_for_prop $1 "dynstat_theta_max" "theta maximum" $2; tmax=$? |
173 |
testoutput_for_prop $1 "dynstat_theta_mean" "theta mean" $2; tmean=$? |
testoutput_for_prop $1 "dynstat_theta_mean" "theta mean" $2; tmean=$? |
192 |
genmakemodel() |
genmakemodel() |
193 |
{ |
{ |
194 |
# genmakemodel directory |
# genmakemodel directory |
195 |
GENMAKE2="../../../tools/genmake2" |
if test "x$NOGENMAKE" = xt ; then |
196 |
( |
echo "genmake skipped!" |
197 |
cd $1; |
else |
198 |
printf 'genmake ... ' 1>&2 |
GENMAKE2="$BASH ../../../tools/genmake2" |
199 |
# ../../../tools/genmake -ieee -mods=../code > make.log 2>&1 |
( |
200 |
$GENMAKE2 -ds --mods=../code "--optfile="$OPTFILE > make.log 2>&1 |
cd $1; |
201 |
RETVAL=$? |
command="$GENMAKE2 -ds -m $MAKE --mods=../code" |
202 |
for i in gm_state gm_optfile gm_local Makefile ; do |
if test "x$OPTFILE" != xNONE ; then |
203 |
if test -r $i ; then |
command="$command --optfile=$OPTFILE" |
|
cp $i $CDIR |
|
204 |
fi |
fi |
205 |
done |
if test "x$IEEE" != x ; then |
206 |
if test "x$RETVAL" != x0 ; then |
command="$command -ieee" |
207 |
tail make.log |
fi |
208 |
echo "genmakemodel: genmake failed" 1>&2 |
printf 'genmake ... ' 1>&2 |
209 |
cp make.log $CDIR |
$command > make.log 2>&1 |
210 |
return 1 |
RETVAL=$? |
211 |
else |
cp Makefile $CDIR |
212 |
echo "succesful" 1>&2 |
if test "x$RETVAL" != x0 ; then |
213 |
fi |
tail make.log |
214 |
) |
echo "genmakemodel: genmake failed" 1>&2 |
215 |
|
cp genmake_* make.log $CDIR |
216 |
|
return 1 |
217 |
|
else |
218 |
|
echo "successful" 1>&2 |
219 |
|
fi |
220 |
|
) |
221 |
|
fi |
222 |
} |
} |
223 |
|
|
224 |
makeclean() |
makeclean() |
225 |
{ |
{ |
226 |
# makeclean directory |
# makeclean directory |
227 |
( |
if test "x$NOCLEAN" = xt ; then |
228 |
cd $1; |
echo "make CLEAN skipped!" |
229 |
rm -f output.txt |
else |
230 |
printf 'make CLEAN ... ' 2>&1 |
( |
231 |
if test -r Makefile ; then |
cd $1; |
232 |
make CLEAN >> make.log 2>&1 |
if test -e output.txt ; then |
233 |
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 |
|
234 |
fi |
fi |
235 |
fi |
printf 'make CLEAN ... ' 2>&1 |
236 |
echo succesful 1>&2 |
if test -r Makefile ; then |
237 |
exit 0 |
$MAKE CLEAN >> make.log 2>&1 |
238 |
) |
RETVAL=$? |
239 |
|
if test "x$RETVAL" != x0 ; then |
240 |
|
tail make.log |
241 |
|
echo "makeclean: \"make CLEAN\" failed" 1>&2 |
242 |
|
cp make.log $CDIR"/make.log" |
243 |
|
return 1 |
244 |
|
fi |
245 |
|
fi |
246 |
|
echo successful 1>&2 |
247 |
|
exit 0 |
248 |
|
) |
249 |
|
fi |
250 |
} |
} |
251 |
|
|
252 |
makedependmodel() |
makedependmodel() |
253 |
{ |
{ |
254 |
# makedependmodel directory |
# makedependmodel directory |
255 |
( |
if test "x$NODEPEND" = xt ; then |
256 |
cd $1; |
echo "make depend skipped!" |
257 |
printf 'make depend ... ' 1>&2 |
else |
258 |
make depend >> make.log 2>&1 |
( |
259 |
RETVAL=$? |
cd $1; |
260 |
if test "x$RETVAL" != x0 ; then |
printf 'make depend ... ' 1>&2 |
261 |
tail make.log |
$MAKE depend >> make.log 2>&1 |
262 |
echo "makedependmodel: make depend failed" 1>&2 |
RETVAL=$? |
263 |
cp make.log $CDIR"/make.log" |
if test "x$RETVAL" != x0 ; then |
264 |
return 1 |
tail make.log |
265 |
else |
echo "makedependmodel: make depend failed" 1>&2 |
266 |
echo succesful 1>&2 |
cp make.log $CDIR"/make.log" |
267 |
fi |
return 1 |
268 |
) |
else |
269 |
|
echo successful 1>&2 |
270 |
|
fi |
271 |
|
) |
272 |
|
fi |
273 |
} |
} |
274 |
|
|
275 |
makemodel() |
makemodel() |
279 |
cd $1; |
cd $1; |
280 |
if test -r Makefile ; then |
if test -r Makefile ; then |
281 |
printf 'make ... ' 1>&2 |
printf 'make ... ' 1>&2 |
282 |
make >> make.log 2>&1 |
$MAKE >> make.log 2>&1 |
283 |
RETVAL=$? |
RETVAL=$? |
284 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
285 |
tail make.log |
tail make.log |
287 |
cp make.log $CDIR"/make.log" |
cp make.log $CDIR"/make.log" |
288 |
return 1 |
return 1 |
289 |
else |
else |
290 |
echo succesful 1>&2 |
echo successful 1>&2 |
291 |
fi |
fi |
292 |
fi |
fi |
293 |
) |
) |
298 |
# linkdata flag |
# linkdata flag |
299 |
# |
# |
300 |
# symbolically link data files to run directory |
# symbolically link data files to run directory |
301 |
if [ $1 -ne 0 ]; then |
if test "x$1" = x1 ; then |
302 |
( cd $2 ; ln -sf ../input/* . ) |
( |
303 |
|
cd $2 |
304 |
|
files=`( cd ../input ; ls -1 | grep -v CVS )` |
305 |
|
for i in $files ; do |
306 |
|
if test ! -d "../input/"$i ; then |
307 |
|
ln -sf "../input/"$i $i |
308 |
|
fi |
309 |
|
done |
310 |
|
) |
311 |
fi |
fi |
312 |
} |
} |
313 |
|
|
314 |
runmodel() |
runmodel() |
315 |
{ |
{ |
316 |
# runmodel directory exe |
# runmodel directory |
317 |
# |
# |
318 |
# runs the model "exe" in "directory" (exe is relative to directory) |
# runs "$COMMAND" in "directory" |
319 |
|
# (where "$COMMAND" is relative to "directory") |
320 |
( |
( |
321 |
cd $1 |
cd $1 |
322 |
if [ -x $2 ]; then |
printf 'runmodel ... ' 1>&2 |
323 |
if [ $quick -eq 0 ]; then |
# make output.txt |
324 |
rm -f output.txt |
$COMMAND >> run.log 2>&1 |
325 |
fi |
RETVAL=$? |
326 |
printf 'runmodel: ' 1>&2 |
if test "x$RETVAL" = x0 ; then |
327 |
make output.txt |
echo successful 1>&2 |
328 |
RETVAL=$? |
cp output.txt $CDIR"/output.txt" |
329 |
if test "x$RETVAL" = x0 ; then |
return 0 |
330 |
cp output.txt $CDIR"/output.txt" |
else |
331 |
return 0 |
tail run.log |
332 |
else |
echo failed 1>&2 |
333 |
return 1 |
cp run.log $CDIR"/run.log" |
334 |
fi |
return 1 |
335 |
fi |
fi |
336 |
) |
) |
337 |
} |
} |
341 |
# create codelet for comparing model output |
# create codelet for comparing model output |
342 |
|
|
343 |
echo -n "creating the comparison code... " |
echo -n "creating the comparison code... " |
344 |
cat > tmp_cmpnum.f <<EOFA |
cat > tmp_cmpnum.c <<EOF |
345 |
program cmpnum |
#include <stdio.h> |
346 |
implicit none |
#include <math.h> |
347 |
real*8 a,b,diff |
int main( int argc, char** argv ) { |
348 |
integer linnum,best |
int linnum,best; |
349 |
best=-16 |
double a,b,diff; |
350 |
99 read(*,*,end=70,err=60) linnum,a,b |
best = -16; |
351 |
diff=0.5*(abs(a)+abs(b)) |
while( 1 ) { |
352 |
c print *,a,b,diff,abs(a-b)/diff |
scanf("%d", &linnum); |
353 |
if (diff.gt.1.e-12) then |
if (linnum == -1) break; |
354 |
diff=abs(a-b)/diff |
scanf("%lf", &a); scanf("%lf", &b); |
355 |
if (diff.gt.0.) then |
diff = 0.5*(fabs(a)+fabs(b)); |
356 |
c print *,int(log10(diff)),diff |
if (diff > 1.e-12) { |
357 |
linnum=int(log10(diff)) |
diff=fabs(a-b)/diff; |
358 |
best=max(best,linnum) |
if (diff > 0.0) { |
359 |
endif |
linnum = (int)log10(diff); |
360 |
else |
best = (best > linnum) ? best : linnum; |
361 |
if (best.eq.-16.and.diff.ne.0.) best=-22 |
} |
362 |
endif |
else { |
363 |
goto 99 |
if (best == -16 && diff != 0) best = -22; |
364 |
60 stop 'cmpnum: An error occured reading a,b' |
} |
365 |
70 print *,-best |
} |
366 |
end |
} |
367 |
EOFA |
printf("%d\n", -best); |
368 |
|
return 0; |
369 |
|
} |
370 |
|
EOF |
371 |
|
cc -o tmp_cmpnum tmp_cmpnum.c -lm |
372 |
|
|
373 |
f77 tmp_cmpnum.f |
if [ -x ./tmp_cmpnum ]; then |
|
if [ -x ./a.out ]; then |
|
374 |
echo "OK" |
echo "OK" |
375 |
return 0 |
return 0 |
376 |
else |
else |
377 |
echo |
echo |
378 |
echo "createcodelet: failed to compile codelet" |
echo "ERROR: failed to compile comparison code" |
379 |
exit 1 |
exit 1 |
380 |
fi |
fi |
381 |
} |
} |
407 |
{ |
{ |
408 |
cat - << EOF |
cat - << EOF |
409 |
$0 [-help] [-quick] [-verbose] dir1 [dir2] [...] |
$0 [-help] [-quick] [-verbose] dir1 [dir2] [...] |
410 |
-help Show this help message |
|
411 |
-quick Skip "genmake" and "make depend" if the Makefile exists |
-help|-h Show this help message |
412 |
-quiet Reduce the amount of output |
-quiet Reduce the amount of output |
413 |
-verbose Produce copious amounts of output |
-verbose Produce copious amounts of output |
414 |
-debug Produce even more output which will mean nothing to most |
-debug Produce even more output which will mean nothing to most |
415 |
-force Do "make CLEAN" before compiling. This forces a complete rebuild. |
-force Do "make CLEAN" before compiling. This forces a complete rebuild. |
416 |
-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. |
|
417 |
-cleanup Aggresively removes all model output, executables and object files |
-cleanup Aggresively removes all model output, executables and object files |
418 |
and then exits. Use with care. |
and then exits. Use with care. |
419 |
|
|
435 |
|
|
436 |
|
|
437 |
############################################################################### |
############################################################################### |
|
############################################################################### |
|
|
############################################################################### |
|
438 |
|
|
439 |
|
|
440 |
# Default properties |
# Default properties |
441 |
debug=0 |
debug=0 |
442 |
verbose=1 |
verbose=1 |
|
quick=0 |
|
443 |
clean=0 |
clean=0 |
|
ieee=1 |
|
444 |
expts='' |
expts='' |
445 |
|
# ieee=1 |
446 |
|
|
447 |
|
IEEE= |
448 |
|
if test "x$MITGCM_IEEE" != x ; then |
449 |
|
IEEE=$MITGCM_IEEE |
450 |
|
fi |
451 |
|
|
452 |
OPTFILES= |
|
453 |
ADDRESSES=edhill@mitgcm.org |
CLEANUP=f |
454 |
|
QUICK=f |
455 |
|
NOGENMAKE=f |
456 |
|
NOCLEAN=f |
457 |
|
NODEPEND=f |
458 |
|
|
459 |
|
BASH= |
460 |
|
OPTFILE=NONE |
461 |
|
ADDRESSES= |
462 |
TESTDIRS= |
TESTDIRS= |
463 |
MPACKDIR="../tools/mpack-1.6" |
MPACKDIR="../tools/mpack-1.6" |
464 |
|
HAVE_MPACK= |
465 |
MPACK="$MPACKDIR/mpack" |
MPACK="$MPACKDIR/mpack" |
466 |
|
COMMAND="make output.txt" |
467 |
|
MAKE=make |
468 |
|
MPI=f |
469 |
|
|
470 |
echo -n "parsing options... " |
echo -n "parsing options... " |
471 |
|
|
487 |
usage ;; |
usage ;; |
488 |
|
|
489 |
-optfile | --optfile | -of | --of) |
-optfile | --optfile | -of | --of) |
490 |
ac_prev=OPTFILES ;; |
ac_prev=OPTFILE ;; |
491 |
-optfile=* | --optfile=* | -of=* | --of=*) |
-optfile=* | --optfile=* | -of=* | --of=*) |
492 |
OPTFILES=$ac_optarg ;; |
OPTFILE=$ac_optarg ;; |
493 |
|
|
494 |
-addr | --addr | -a | --a) |
-addr | --addr | -a | --a) |
495 |
ac_prev=ADDRESSES ;; |
ac_prev=ADDRESSES ;; |
501 |
-tdir=* | --tdir=*) |
-tdir=* | --tdir=*) |
502 |
TESTDIRS=$ac_optarg ;; |
TESTDIRS=$ac_optarg ;; |
503 |
|
|
504 |
-quick) quick=1 ;; |
-bash | --bash | -b | --b) |
505 |
|
ac_prev=BASH ;; |
506 |
|
-bash=* | --bash=*) |
507 |
|
BASH=$ac_optarg ;; |
508 |
|
|
509 |
|
-command | --command | -c | --c) |
510 |
|
ac_prev=COMMAND ;; |
511 |
|
-command=* | --command=*) |
512 |
|
COMMAND=$ac_optarg ;; |
513 |
|
|
514 |
|
-make | --make | -m | --m) |
515 |
|
ac_prev=MAKE ;; |
516 |
|
-make=* | --make=*) |
517 |
|
MAKE=$ac_optarg ;; |
518 |
|
|
519 |
|
-clean | --clean) |
520 |
|
CLEANUP=t ;; |
521 |
|
|
522 |
|
-quick | --quick | -q | --q) |
523 |
|
QUICK=t ;; |
524 |
|
-nogenmake | --nogenmake | -ng | --ng) |
525 |
|
NOGENMAKE=t ;; |
526 |
|
-noclean | --noclean | -nc | --nc) |
527 |
|
NOCLEAN=t ;; |
528 |
|
-nodepend | --nodepend | -nd | --nd) |
529 |
|
NODEPEND=t ;; |
530 |
|
|
531 |
|
-mpi) MPI=t ;; |
532 |
|
|
533 |
|
-ieee) IEEE=true ;; |
534 |
|
-noieee) IEEE= ;; |
535 |
|
|
536 |
-verbose) verbose=2 ;; |
-verbose) verbose=2 ;; |
537 |
-debug) debug=1 ;; |
-debug) debug=1 ;; |
|
-clean) clean=1 ;; |
|
|
-noieee) ieee=0 ;; |
|
538 |
-quiet) verbose=0 ;; |
-quiet) verbose=0 ;; |
539 |
|
|
540 |
-*) |
-*) |
551 |
|
|
552 |
done |
done |
553 |
|
|
554 |
|
if test "x$QUICK" = xt ; then |
555 |
|
NOGENMAKE=t |
556 |
|
NOCLEAN=t |
557 |
|
NODEPEND=t |
558 |
|
fi |
559 |
|
|
560 |
if test "x$TESTDIRS" = x ; then |
if test "x$TESTDIRS" = x ; then |
561 |
TESTDIRS=`scandirs` |
TESTDIRS=`scandirs` |
562 |
fi |
fi |
563 |
|
|
564 |
|
if test "x$OPTFILE" = xNONE -a "x$MITGCM_OF" != x ; then |
565 |
|
OPTFILE=$MITGCM_OF |
566 |
|
fi |
567 |
|
|
568 |
echo "OK" |
echo "OK" |
569 |
|
|
570 |
# create the FORTRAN comparison code |
# create the FORTRAN comparison code |
587 |
mkdir $DRESULTS |
mkdir $DRESULTS |
588 |
RETVAL=$? |
RETVAL=$? |
589 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
590 |
echo "Error: can't create results directory \"./$DRESULTS\"" |
echo "ERROR: Can't create results directory \"./$DRESULTS\"" |
591 |
exit 1 |
exit 1 |
592 |
fi |
fi |
593 |
SUMMARY="$DRESULTS/summary.txt" |
SUMMARY="$DRESULTS/summary.txt" |
594 |
date > $SUMMARY |
echo -n "Start time: " >> $SUMMARY |
595 |
cat << EOF >> $SUMMARY |
start_date=`date` |
596 |
|
echo $start_date > $SUMMARY |
597 |
|
|
598 |
|
of_path= |
599 |
|
if test "x$OPTFILE" != xNONE ; then |
600 |
|
if test -r $OPTFILE ; then |
601 |
|
# get the path |
602 |
|
path=${OPTFILE%/*} |
603 |
|
if test "x$path" = x ; then |
604 |
|
of_path=`pwd` |
605 |
|
else |
606 |
|
of_path=`( cd $path > /dev/null 2>&1 ; pwd )` |
607 |
|
fi |
608 |
|
file=${OPTFILE##*/} |
609 |
|
OPTFILE=$of_path/$file |
610 |
|
cp $OPTFILE $DRESULTS |
611 |
|
echo >> $SUMMARY |
612 |
|
echo " OPTFILE=$OPTFILE" >> $SUMMARY |
613 |
|
else |
614 |
|
echo | tee $SUMMARY |
615 |
|
echo "ERROR: can't read OPTFILE=\"$OPTFILE\"" | tee $SUMMARY |
616 |
|
exit 1 |
617 |
|
fi |
618 |
|
else |
619 |
|
echo >> $SUMMARY |
620 |
|
echo "No \"OPTFILE\" was explicitly specified by testreport," >> $SUMMARY |
621 |
|
echo " so the genmake default will be used." >> $SUMMARY |
622 |
|
fi |
623 |
|
echo |
624 |
|
echo >> $SUMMARY |
625 |
|
cat << EOF | tee -a $SUMMARY |
626 |
T S U V |
T S U V |
627 |
G D M c m s m s m s m s |
G D M c m s m s m s m s |
628 |
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 . |
631 |
|
|
632 |
EOF |
EOF |
633 |
|
|
634 |
NDIR=0 |
# ...and each test directory... |
635 |
|
for dir in $TESTDIRS ; do |
636 |
# For each optfile... |
|
637 |
for OPTFILE in $OPTFILES ; do |
# Cleanup only! |
638 |
|
if test "x$CLEANUP" = xt ; then |
639 |
|
if test -r $dir/build/Makefile ; then |
640 |
|
( cd $dir/build ; make CLEAN ) |
641 |
|
fi |
642 |
|
if test -r $dir/input/Makefile ; then |
643 |
|
( cd $dir/input ; make CLEAN ) |
644 |
|
fi |
645 |
|
continue |
646 |
|
fi |
647 |
|
|
648 |
OPTFILE=`pwd`"/$OPTFILE" |
# Verify that the testdir exists and contains previous |
649 |
if test ! -r $OPTFILE ; then |
# results in the correct location--or skip this directory! |
650 |
echo "Error: can't read optfile \"$OPTFILE\"" |
if test ! -r $dir"/results/output.txt" ; then |
651 |
exit 1 |
echo "can't read \"$dir/results/output.txt\" -- skipping $dir" |
652 |
|
continue |
653 |
fi |
fi |
|
echo |
|
|
echo "OPTFILE=$OPTFILE" >> $SUMMARY |
|
|
echo >> $SUMMARY |
|
|
|
|
|
# ...and each test directory... |
|
|
for dir in $TESTDIRS ; do |
|
654 |
|
|
655 |
# Verify that the testdir exists and contains previous |
echo "-------------------------------------------------------------------------------" |
656 |
# results in the correct location--or skip this directory! |
echo |
657 |
if test ! -r $dir"/results/output.txt" ; then |
echo "Experiment: $dir" |
658 |
echo | tee -a $SUMMARY |
echo |
659 |
echo "can't read \"$dir/results/output.txt\" -- skipping $dir" \ |
unset genmake makedepend make run |
660 |
| tee -a $SUMMARY |
results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --' |
|
continue |
|
|
fi |
|
|
|
|
|
# Create an output dir for each OPTFILE/tdir combination |
|
|
CDIR=$DRESULTS"/"$DRESULTS"_"$NDIR |
|
|
mkdir $CDIR |
|
|
CDIR=`pwd`"/$CDIR" |
|
661 |
|
|
662 |
# ...configue, make, run, and compare the output. |
builddir="input" |
663 |
echo "-------------------------------------------------------------------------------" |
rundir="input" |
664 |
echo |
use_seperate_build=0 |
665 |
echo "Experiment: $dir" |
if test -d $dir/build -a -r $dir/build ; then |
666 |
echo |
builddir="build" |
667 |
unset genmake makedepend make run |
rundir="build" |
668 |
results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --' |
use_seperate_build=1 |
669 |
( cd $dir/input; rm -f *.{o,f,c,F} *.[f,F]90 work* output.txt Make* make.log; ) |
linkdata $use_seperate_build $dir/$rundir |
670 |
if [ -r $dir/build ]; then |
fi |
671 |
seperatebuilddir=1 |
|
672 |
builddir=build |
CODE_DIR=$dir/code |
673 |
rundir=build |
BUILD_DIR=$dir/$builddir |
674 |
( cd $dir/build; ln -sf ../input/* . ) |
MPI_FILES="CPP_EEOPTIONS.h_mpi SIZE.h_mpi" |
675 |
else |
NOMPI_FILES="CPP_EEOPTIONS.h_nompi SIZE.h_nompi" |
676 |
seperatebuilddir=0 |
|
677 |
builddir=input |
# Is this an MPI run? |
678 |
rundir=input |
if test "x$MPI" = xt ; then |
679 |
|
FILES=$MPI_FILES |
680 |
|
endings="_mpi" |
681 |
|
else |
682 |
|
FILES=$NOMPI_FILES |
683 |
|
endings="_nompi" |
684 |
|
fi |
685 |
|
|
686 |
|
# Check to see that we have the files |
687 |
|
have_files=t |
688 |
|
for i in $FILES ; do |
689 |
|
if test ! -r $CODE_DIR/$i ; then |
690 |
|
echo "Warning: can't read file $CODE_DIR/$i" |
691 |
|
have_files=f |
692 |
fi |
fi |
693 |
|
done |
694 |
|
if test "x$have_files" != xt -a "x$MPI" = xt ; then |
695 |
|
echo "Skipping $dir due to lack of input files (see above warning)" |
696 |
|
continue |
697 |
|
fi |
698 |
|
|
699 |
|
# If we have the $FILES and they differ, copy the $FILES to $BUILD_DIR |
700 |
|
if test "x$have_files" = xt ; then |
701 |
|
for i in $FILES ; do |
702 |
|
sstr="s|$endings||" |
703 |
|
name=`echo $i | sed -e $sstr ` |
704 |
|
cmp $CODE_DIR/$i $BUILD_DIR/$name > /dev/null 2>&1 |
705 |
|
RETVAL=$? |
706 |
|
if test "x$RETVAL" != x0 ; then |
707 |
|
cp $CODE_DIR/$i $BUILD_DIR/$name |
708 |
|
fi |
709 |
|
done |
710 |
|
fi |
711 |
|
|
712 |
|
# Create an output dir for each OPTFILE/tdir combination |
713 |
|
rel_CDIR=$DRESULTS"/"$dir |
714 |
|
mkdir $rel_CDIR |
715 |
|
CDIR=`pwd`"/$rel_CDIR" |
716 |
|
|
717 |
|
if test "x$CLEANUP" = xt ; then |
718 |
|
makeclean $dir/$builddir |
719 |
|
else |
720 |
genmakemodel $dir/$builddir && genmake=Y \ |
genmakemodel $dir/$builddir && genmake=Y \ |
721 |
&& makeclean $dir/$builddir \ |
&& makeclean $dir/$builddir \ |
722 |
&& makedependmodel $dir/$builddir && makedepend=Y \ |
&& makedependmodel $dir/$builddir && makedepend=Y \ |
723 |
&& makemodel $dir/$builddir && make=Y \ |
&& makemodel $dir/$builddir && make=Y \ |
724 |
&& linkdata $seperatebuilddir $dir/$rundir \ |
&& linkdata $use_seperate_build $dir/$rundir \ |
725 |
&& runmodel $dir/$builddir mitgcmuv && run=Y \ |
&& runmodel $dir/$rundir && run=Y \ |
726 |
&& results=`testoutput $dir $rundir` |
&& results=`testoutput $dir $rundir` |
727 |
echo |
fi |
728 |
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
|
729 |
${run:-N} $results |
echo |
730 |
echo |
fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results` |
731 |
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
echo |
732 |
${run:-N} $results >> $SUMMARY |
echo "$fres" >> $SUMMARY |
733 |
echo "fresults='" > $CDIR"/summary.txt" |
echo "fresults='$fres'" > $CDIR"/summary.txt" |
734 |
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
echo "MACH='$MACH'" >> $CDIR"/summary.txt" |
735 |
${run:-N} $results >> $CDIR"/summary.txt" |
echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt" |
736 |
echo "'" >> $CDIR"/summary.txt" |
echo "DATE='$DATE'" >> $CDIR"/summary.txt" |
737 |
echo "MACH='$MACH'" >> $CDIR"/summary.txt" |
echo "tdir='$dir'" >> $CDIR"/summary.txt" |
738 |
echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt" |
|
739 |
echo "DATE='$DATE'" >> $CDIR"/summary.txt" |
echo "-------------------------------------------------------------------------------" |
740 |
echo "tdir='$dir'" >> $CDIR"/summary.txt" |
|
741 |
|
done |
|
( |
|
|
cd $DRESULTS |
|
|
tar -cf $NDIR".tar" $DRESULTS"_"$NDIR > /dev/null 2>&1 |
|
|
gzip $NDIR".tar" |
|
|
) |
|
742 |
|
|
743 |
$MPACK -s MITgcm-test -m 1000000 $DRESULTS"/"$NDIR".tar.gz" $ADDRESSES |
echo -n "Start time: " >> $SUMMARY |
744 |
|
echo $start_date >> $SUMMARY |
745 |
|
echo -n "End time: " >> $SUMMARY |
746 |
|
date >> $SUMMARY |
747 |
|
|
748 |
|
# If addresses were supplied and mpack built successfully, then try |
749 |
|
# to send email using mpack. |
750 |
|
if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then |
751 |
|
echo "No results email was sent." |
752 |
|
else |
753 |
|
if test "x$HAVE_MPACK" = xt ; then |
754 |
|
tar -cf $DRESULTS".tar" $DRESULTS > /dev/null 2>&1 \ |
755 |
|
&& gzip $DRESULTS".tar" \ |
756 |
|
&& $MPACK -s MITgcm-test -m 1500000 $DRESULTS".tar.gz" $ADDRESSES |
757 |
RETVAL=$? |
RETVAL=$? |
758 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
759 |
echo "Warning: \"$MPACK\" failed -- please contact <edhill@mitgcm.org>" |
echo |
760 |
|
echo "Warning: The tar, gzip, & mpack step failed. Please send email" |
761 |
|
echo " to <MITgcm-support@mitgcm.org> for help. You may copy the " |
762 |
|
echo " summary of results from the directory \"$DRESULTS\"." |
763 |
|
echo |
764 |
else |
else |
765 |
rm -f $DRESULTS"/"$NDIR".tar*" |
echo |
766 |
|
echo "An email containing results was sent to the following addresses:" |
767 |
|
echo " \"$ADDRESSES\"" |
768 |
|
echo |
769 |
fi |
fi |
770 |
|
test -f $DRESULTS".tar" && rm -f $DRESULTS".tar" |
771 |
|
test -f $DRESULTS".tar.gz" && rm -f $DRESULTS".tar.gz" |
772 |
|
fi |
773 |
|
fi |
774 |
|
|
775 |
NDIR=$(( $NDIR + 1 )) |
# rm -f tmp_cmpnum.f a.out |
776 |
|
rm -f tmp_cmpnum.c tmp_cmpnum |
|
done |
|
|
done |
|
|
|
|
|
rm tmp_cmpnum.f a.out |
|
777 |
|
|
778 |
cat $SUMMARY |
if test "x$CLEANUP" != xt ; then |
779 |
|
cat $SUMMARY |
780 |
|
if test -e tr.out ; then |
781 |
|
mv tr.out tr.out.old |
782 |
|
fi |
783 |
|
cat $SUMMARY > tr.out |
784 |
|
fi |
785 |
|
|