11 |
|
|
12 |
testoutput_for_prop() |
testoutput_for_prop() |
13 |
{ |
{ |
14 |
# testoutput_for_prop dir s1 label |
# testoutput_for_prop dir s1 label subdir |
15 |
# |
# |
16 |
# compares files in $dir/input/output.txt and $dir/results.output.txt |
# compares files in $dir/$subdir/output.txt and $dir/results/output.txt |
17 |
# using search strings s1 and text label |
# using search strings s1 and text label |
18 |
|
|
19 |
if [ $debug -gt 0 ]; then |
if [ $debug -gt 0 ]; then |
20 |
echo testoutput_for_prop: grep "$2" $1/input/output.txt 1>&2 |
echo testoutput_for_prop: grep "$2" $1/$4/output.txt 1>&2 |
21 |
fi |
fi |
22 |
if [ -r $1/input/output.txt ]; then |
if [ -r $1/$4/output.txt ]; then |
23 |
grep "$2" $1/input/output.txt | sed 's/.*=//' | nl > tmp1.txt |
grep "$2" $1/$4/output.txt | sed 's/.*=//' | nl > tmp1.txt |
24 |
|
lncnt=`wc -l tmp1.txt | awk '{print $1}' ` |
25 |
|
if [ $lncnt -lt 3 ]; then |
26 |
|
if [ $verbose -gt 0 ]; then |
27 |
|
echo Not enough lines of output when searching for "$2" 1>&2 |
28 |
|
fi |
29 |
|
return 99 |
30 |
|
fi |
31 |
else |
else |
32 |
echo testoutput_for_prop: output.txt from model run was not readable 1>&2 |
echo testoutput_for_prop: output.txt from model run was not readable 1>&2 |
33 |
return 99 |
return 99 |
36 |
echo testoutput_for_prop: grep "$2" $1/results/output.txt 1>&2 |
echo testoutput_for_prop: grep "$2" $1/results/output.txt 1>&2 |
37 |
fi |
fi |
38 |
grep "$2" $1/results/output.txt | sed 's/.*=//' | nl > tmp2.txt |
grep "$2" $1/results/output.txt | sed 's/.*=//' | nl > tmp2.txt |
39 |
|
lncnt=`wc -l tmp2.txt | awk '{print $1}' ` |
40 |
|
if [ $lncnt -lt 3 ]; then |
41 |
|
if [ $verbose -gt 0 ]; then |
42 |
|
echo Not enough lines of output when searching for "$2" 1>&2 |
43 |
|
fi |
44 |
|
return 99 |
45 |
|
fi |
46 |
if [ $debug -gt 0 ]; then |
if [ $debug -gt 0 ]; then |
47 |
echo testoutput_for_prop: join tmp1.txt tmp2.txt 1>&2 |
echo testoutput_for_prop: join tmp1.txt tmp2.txt 1>&2 |
48 |
fi |
fi |
84 |
|
|
85 |
testoutput() |
testoutput() |
86 |
{ |
{ |
87 |
# testoutput diretory |
# testoutput diretory subdir |
88 |
# |
# |
89 |
# test output in "directory" |
# test output in "directory" |
90 |
|
|
91 |
if [ $debug -gt 0 ]; then |
if [ $debug -gt 0 ]; then |
92 |
echo testoutput: testoutput_for_prop $1 cg2d_init_res 1>&2 |
echo testoutput: testoutput_for_prop $1 cg2d_init_res 1>&2 |
93 |
fi |
fi |
94 |
testoutput_for_prop $1 "cg2d_init_res" "cg2d init. residual"; cg2dres=$? |
testoutput_for_prop $1 "cg2d_init_res" "cg2d init. residual" $2; cg2dres=$? |
95 |
if [ $debug -gt 0 ]; then |
if [ $debug -gt 0 ]; then |
96 |
echo testoutput: cg2dres=$cg2dres 1>&2 |
echo testoutput: cg2dres=$cg2dres 1>&2 |
97 |
fi |
fi |
98 |
|
|
99 |
if [ $longtest -gt 0 ]; then |
if [ $longtest -gt 0 ]; then |
100 |
testoutput_for_prop $1 "dynstat_theta_min" "theta minimum"; tmin=$? |
testoutput_for_prop $1 "dynstat_theta_min" "theta minimum" $2; tmin=$? |
101 |
testoutput_for_prop $1 "dynstat_theta_max" "theta maximum"; tmax=$? |
testoutput_for_prop $1 "dynstat_theta_max" "theta maximum" $2; tmax=$? |
102 |
testoutput_for_prop $1 "dynstat_theta_mean" "theta mean"; tmean=$? |
testoutput_for_prop $1 "dynstat_theta_mean" "theta mean" $2; tmean=$? |
103 |
testoutput_for_prop $1 "dynstat_theta_sd" "theta s.d."; tsd=$? |
testoutput_for_prop $1 "dynstat_theta_sd" "theta s.d." $2; tsd=$? |
104 |
testoutput_for_prop $1 "dynstat_salt_min" "salt minimum"; smin=$? |
testoutput_for_prop $1 "dynstat_salt_min" "salt minimum" $2; smin=$? |
105 |
testoutput_for_prop $1 "dynstat_salt_max" "salt maximum"; smax=$? |
testoutput_for_prop $1 "dynstat_salt_max" "salt maximum" $2; smax=$? |
106 |
testoutput_for_prop $1 "dynstat_salt_mean" "salt mean"; smean=$? |
testoutput_for_prop $1 "dynstat_salt_mean" "salt mean" $2; smean=$? |
107 |
testoutput_for_prop $1 "dynstat_salt_sd" "salt s.d."; ssd=$? |
testoutput_for_prop $1 "dynstat_salt_sd" "salt s.d." $2; ssd=$? |
108 |
testoutput_for_prop $1 "dynstat_uvel_min" "U minimum"; umin=$? |
testoutput_for_prop $1 "dynstat_uvel_min" "U minimum" $2; umin=$? |
109 |
testoutput_for_prop $1 "dynstat_uvel_max" "U maximum"; umax=$? |
testoutput_for_prop $1 "dynstat_uvel_max" "U maximum" $2; umax=$? |
110 |
testoutput_for_prop $1 "dynstat_uvel_mean" "U mean"; umean=$? |
testoutput_for_prop $1 "dynstat_uvel_mean" "U mean" $2; umean=$? |
111 |
testoutput_for_prop $1 "dynstat_uvel_sd" "U s.d."; usd=$? |
testoutput_for_prop $1 "dynstat_uvel_sd" "U s.d." $2; usd=$? |
112 |
testoutput_for_prop $1 "dynstat_vvel_min" "V minimum"; vmin=$? |
testoutput_for_prop $1 "dynstat_vvel_min" "V minimum" $2; vmin=$? |
113 |
testoutput_for_prop $1 "dynstat_vvel_max" "V maximum"; vmax=$? |
testoutput_for_prop $1 "dynstat_vvel_max" "V maximum" $2; vmax=$? |
114 |
testoutput_for_prop $1 "dynstat_vvel_mean" "V mean"; vmean=$? |
testoutput_for_prop $1 "dynstat_vvel_mean" "V mean" $2; vmean=$? |
115 |
testoutput_for_prop $1 "dynstat_vvel_sd" "V s.d."; vsd=$? |
testoutput_for_prop $1 "dynstat_vvel_sd" "V s.d." $2; vsd=$? |
116 |
else |
else |
117 |
testoutput_for_prop $1 "dynstat_theta_min" "theta minimum"; tmin=$? |
testoutput_for_prop $1 "dynstat_theta_min" "theta minimum" $2; tmin=$? |
118 |
testoutput_for_prop $1 "dynstat_theta_max" "theta maximum"; tmax=$? |
testoutput_for_prop $1 "dynstat_theta_max" "theta maximum" $2; tmax=$? |
119 |
testoutput_for_prop $1 "dynstat_salt_min" "salt minimum"; smin=$? |
testoutput_for_prop $1 "dynstat_salt_min" "salt minimum" $2; smin=$? |
120 |
testoutput_for_prop $1 "dynstat_salt_max" "salt maximum"; smax=$? |
testoutput_for_prop $1 "dynstat_salt_max" "salt maximum" $2; smax=$? |
121 |
testoutput_for_prop $1 "dynstat_uvel_min" "U minimum"; umin=$? |
testoutput_for_prop $1 "dynstat_uvel_min" "U minimum" $2; umin=$? |
122 |
testoutput_for_prop $1 "dynstat_uvel_max" "U maximum"; umax=$? |
testoutput_for_prop $1 "dynstat_uvel_max" "U maximum" $2; umax=$? |
123 |
testoutput_for_prop $1 "dynstat_vvel_min" "V minimum"; vmin=$? |
testoutput_for_prop $1 "dynstat_vvel_min" "V minimum" $2; vmin=$? |
124 |
testoutput_for_prop $1 "dynstat_vvel_max" "V maximum"; vmax=$? |
testoutput_for_prop $1 "dynstat_vvel_max" "V maximum" $2; vmax=$? |
125 |
fi |
fi |
126 |
|
|
127 |
dashnum $cg2dres $tmin $tmax $tmean $tsd $smin $smax $smean $ssd \ |
dashnum $cg2dres $tmin $tmax $tmean $tsd $smin $smax $smean $ssd \ |
136 |
( cd $1; |
( cd $1; |
137 |
if [ $quick -eq 0 -o ! -r Makefile ]; then |
if [ $quick -eq 0 -o ! -r Makefile ]; then |
138 |
printf 'genmake ... ' 1>&2 |
printf 'genmake ... ' 1>&2 |
139 |
|
find . -type l -exec rm {} \; |
140 |
if [ $ieee -eq 0 ]; then |
if [ $ieee -eq 0 ]; then |
141 |
../../../tools/genmake -mods=../code > make.log 2>&1 |
../../../tools/genmake2 -mods=../code > make.log 2>&1 |
142 |
else |
else |
143 |
../../../tools/genmake -ieee -mods=../code > make.log 2>&1 |
../../../tools/genmake2 -ieee -mods=../code > make.log 2>&1 |
144 |
fi |
fi |
145 |
if [ $? -ne 0 ]; then |
if [ $? -ne 0 ]; then |
146 |
tail make.log |
tail make.log |
147 |
echo genmakemodel: genmake failed 1>&2 |
echo genmakemodel: $genmake failed 1>&2 |
148 |
return 1 |
return 1 |
149 |
else |
else |
150 |
echo succesful 1>&2 |
echo succesful 1>&2 |
228 |
) |
) |
229 |
} |
} |
230 |
|
|
231 |
|
linkdata() |
232 |
|
{ |
233 |
|
# linkdata flag |
234 |
|
# |
235 |
|
# symbolically link data files to run directory |
236 |
|
if test "x$1" = x1 ; then |
237 |
|
( |
238 |
|
cd $2 |
239 |
|
if test "x$ADM" = x ; then |
240 |
|
files=`( cd ../input ; ls -1 | grep -v CVS )` |
241 |
|
for i in $files ; do |
242 |
|
if test ! -d "../input/"$i ; then |
243 |
|
ln -sf "../input/"$i $i |
244 |
|
fi |
245 |
|
done |
246 |
|
else |
247 |
|
files=`( cd ../input ; ls -1 *.bin | grep -v CVS )` |
248 |
|
for i in $files ; do |
249 |
|
if test ! -d "../input/"$i ; then |
250 |
|
ln -sf "../input/"$i $i |
251 |
|
fi |
252 |
|
done |
253 |
|
files=`( cd ../input_ad ; ls -1 | grep -v CVS )` |
254 |
|
for i in $files ; do |
255 |
|
if test ! -d "../input_ad/"$i ; then |
256 |
|
ln -sf "../input_ad/"$i $i |
257 |
|
fi |
258 |
|
done |
259 |
|
fi |
260 |
|
) |
261 |
|
fi |
262 |
|
} |
263 |
|
|
264 |
runmodel() |
runmodel() |
265 |
{ |
{ |
266 |
# runmodel directory exe |
# runmodel directory exe |
272 |
if [ $quick -eq 0 ]; then |
if [ $quick -eq 0 ]; then |
273 |
rm -f output.txt |
rm -f output.txt |
274 |
fi |
fi |
275 |
|
if [ $debug -gt 0 ]; then |
276 |
|
echo -n runmodel: pwd= 1>&2 |
277 |
|
pwd 1>&2 |
278 |
|
fi |
279 |
printf 'runmodel: ' 1>&2 |
printf 'runmodel: ' 1>&2 |
280 |
make output.txt && return 0 |
make output.txt && return 0 |
281 |
# if [ ! -r output.txt -o $quick -eq 0 ]; then |
return 1 |
282 |
# echo runmodel: running... 1>&2 |
fi |
283 |
# ( ./$2 > output.txt 2>&1 ) && return 0 |
) |
284 |
# rm -f output.txt |
} |
285 |
# ( make output.txt ) && return 0 |
|
286 |
# return 1 |
copynewresults() |
287 |
# else |
{ |
288 |
# echo runmodel: output.txt is newer than executable 1>&2 |
# copynewresults directory |
289 |
# ( make output.txt ) && return 0 |
# |
290 |
# return 0 |
# runs the model "exe" in "directory" (exe is relative to directory) |
291 |
# fi |
|
292 |
# else |
( cd $1 |
293 |
# echo runmodel: executable \"$1/$2\" is missing 1>&2 |
if [ $newresults -eq 1 ]; then |
294 |
# return 1 |
if [ -r output.txt ]; then |
295 |
|
cp -f output.txt ../results/ |
296 |
|
return 0 |
297 |
|
fi |
298 |
fi |
fi |
299 |
) |
) |
300 |
} |
} |
364 |
$0 [-help] [-quick] [-verbose] dir1 [dir2] [...] |
$0 [-help] [-quick] [-verbose] dir1 [dir2] [...] |
365 |
-help Show this help message |
-help Show this help message |
366 |
-quick Skip "genmake" and "make depend" if the Makefile exists |
-quick Skip "genmake" and "make depend" if the Makefile exists |
367 |
|
-newresults Copy the output.txt into results/ |
368 |
-quiet Reduce the amount of output |
-quiet Reduce the amount of output |
369 |
-verbose Produce copious amounts of output |
-verbose Produce copious amounts of output |
370 |
-debug Produce even more output which will mean nothing to most |
-debug Produce even more output which will mean nothing to most |
372 |
-clean Do "make CLEAN" after compiling and testing. |
-clean Do "make CLEAN" after compiling and testing. |
373 |
-shorttest Don't compare numeric output for mean and s.d. of variables. |
-shorttest Don't compare numeric output for mean and s.d. of variables. |
374 |
-noieee By default, $0 uses the -ieee option for genmake. This turns it off. |
-noieee By default, $0 uses the -ieee option for genmake. This turns it off. |
375 |
|
-cleanup Aggresively removes all model output, executables and object files |
376 |
|
and then exits. Use with care. |
377 |
|
|
378 |
Normal usage: |
Normal usage: |
379 |
$0 * Configure, compile, run and analyze in all experiment directories |
$0 * Configure, compile, run and analyze in all experiment directories |
392 |
fi |
fi |
393 |
} |
} |
394 |
|
|
395 |
|
clean_up() |
396 |
|
{ |
397 |
|
# Find all executables, object files, CPP'd source and model output |
398 |
|
# and DELETE it. |
399 |
|
for opt in '-name "mitgcmuv*"' '-name "*.o"' '-name "*.f"' '-name "*.c"' '-name "fort.*"' '-name "make.log"' '-path *results -prune -o -name "*.meta"' '-path *results -prune -o -name "*.data"' '-type l' |
400 |
|
do |
401 |
|
echo Cleaning: find . $opt -exec rm {} \; |
402 |
|
find . $opt -exec rm {} \; |
403 |
|
done |
404 |
|
} |
405 |
|
|
406 |
|
############################################################################### |
407 |
|
############################################################################### |
408 |
############################################################################### |
############################################################################### |
409 |
|
|
410 |
# Main function |
# Main function |
413 |
debug=0 |
debug=0 |
414 |
verbose=1 |
verbose=1 |
415 |
quick=0 |
quick=0 |
416 |
|
newresults=0 |
417 |
force=0 |
force=0 |
418 |
clean=0 |
clean=0 |
419 |
ieee=1 |
ieee=1 |
420 |
longtest=1 |
longtest=1 |
421 |
expts='' |
expts='' |
422 |
|
genmake=genmake |
423 |
|
|
424 |
# Process arguments |
# Process arguments |
425 |
for arg in $@ |
for arg in $@ |
426 |
do |
do |
427 |
case $arg in |
case $arg in |
428 |
|
-cleanup) clean_up; exit 0;; |
429 |
-quick) quick=1;; |
-quick) quick=1;; |
430 |
|
-newresults) newresults=1;; |
431 |
-verbose) verbose=2;; |
-verbose) verbose=2;; |
432 |
-debug) debug=1;; |
-debug) debug=1;; |
433 |
-force) force=1;; |
-force) force=1;; |
458 |
|
|
459 |
createcodelet |
createcodelet |
460 |
|
|
461 |
|
date > summary.txt |
462 |
if [ $longtest -gt 0 ]; then |
if [ $longtest -gt 0 ]; then |
463 |
cat << EOF > summary.txt |
cat << EOF >> summary.txt |
464 |
T S U V |
T S U V |
465 |
C D M c m s m s m s m s |
C D M c m s m s m s m s |
466 |
n p a R g m m e . m m e . m m e . m m e . |
n p a R g m m e . m m e . m m e . m m e . |
469 |
|
|
470 |
EOF |
EOF |
471 |
else |
else |
472 |
cat << EOF > summary.txt |
cat << EOF >> summary.txt |
473 |
T S U V |
T S U V |
474 |
C D M c |
C D M c |
475 |
n p a R g m m m m m m m m |
n p a R g m m m m m m m m |
487 |
echo |
echo |
488 |
echo Experiment: $dir |
echo Experiment: $dir |
489 |
echo |
echo |
490 |
unset genmake makedepend make run |
unset genmakepass makedepend make run |
491 |
if [ $longtest -gt 0 ]; then |
if [ $longtest -gt 0 ]; then |
492 |
results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --' |
results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --' |
493 |
else |
else |
494 |
results='-- -- -- -- -- -- -- -- --' |
results='-- -- -- -- -- -- -- -- --' |
495 |
fi |
fi |
496 |
genmakemodel $dir/input && genmake=Y \ |
if [ -r $dir/build ]; then |
497 |
&& makecleancompile $dir/input \ |
seperatebuilddir=1 |
498 |
&& makedependmodel $dir/input && makedepend=Y \ |
builddir=build |
499 |
&& makemodel $dir/input && make=Y \ |
rundir=build |
500 |
&& runmodel $dir/input mitgcmuv && run=Y \ |
(cd $dir/input; rm -f *.{o,f,c,F,h} work* output.txt Make* make.log; ) |
501 |
&& results=`testoutput $dir` \ |
else |
502 |
&& makecleanupafter $dir/input |
seperatebuilddir=0 |
503 |
|
builddir=input |
504 |
|
rundir=input |
505 |
|
fi |
506 |
|
genmakemodel $dir/$builddir && genmakepass=Y \ |
507 |
|
&& makecleancompile $dir/$builddir \ |
508 |
|
&& makedependmodel $dir/$builddir && makedepend=Y \ |
509 |
|
&& makemodel $dir/$builddir && make=Y \ |
510 |
|
&& linkdata $seperatebuilddir $dir/$rundir \ |
511 |
|
&& runmodel $dir/$builddir mitgcmuv && run=Y \ |
512 |
|
&& results=`testoutput $dir $rundir` \ |
513 |
|
&& copynewresults $dir/$rundir \ |
514 |
|
&& makecleanupafter $dir/$builddir |
515 |
echo |
echo |
516 |
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results |
formatresults $dir ${genmakepass:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results |
517 |
echo |
echo |
518 |
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results >> summary.txt |
formatresults $dir ${genmakepass:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results >> summary.txt |
519 |
fi |
fi |
520 |
done |
done |
521 |
|
|
523 |
|
|
524 |
echo ------------------------------------------------------------------------------- |
echo ------------------------------------------------------------------------------- |
525 |
echo |
echo |
526 |
|
date >> summary.txt |
527 |
cat summary.txt |
cat summary.txt |