1 |
#!/bin/bash |
#! /usr/bin/env bash |
2 |
# |
# |
3 |
# $Header$ |
# $Header$ |
4 |
# $Name$ |
# $Name$ |
13 |
echo " (-help|-h) print usage" |
echo " (-help|-h) print usage" |
14 |
echo " (-mpi) use MPI input files" |
echo " (-mpi) use MPI input files" |
15 |
echo " (-ieee|-noieee) if possible, use IEEE compiler flags" |
echo " (-ieee|-noieee) if possible, use IEEE compiler flags" |
16 |
|
echo " (DEF=\"-ieee\")" |
17 |
echo " (-optfile=|-of=)STRING list of optfiles to use" |
echo " (-optfile=|-of=)STRING list of optfiles to use" |
18 |
echo " (-a|-addr)STRING list of email recipients" |
echo " (-a|-addr) STRING list of email recipients" |
19 |
echo " (DEF=\"edhill@mitgcm.org\")" |
echo " (DEF=\"edhill@mitgcm.org\")" |
20 |
echo " (-t|-tdir)STRING list of test dirs to use" |
echo " (-t|-tdir) STRING list of test dirs to use" |
21 |
echo " (DEF=\"\" which builds all)" |
echo " (DEF=\"\" which builds all)" |
22 |
echo " (-b|-bash)STRING location of \"bash\" executable" |
echo " (-b|-bash) STRING preferred location of a \"bash\" or" |
23 |
echo " (DEF=\"\" for \"/bin/bash\")" |
echo " Bourne-compatible \"sh\" shell" |
24 |
echo " (-command)STRING command to run" |
echo " (DEF=\"\" for \"bash\")" |
25 |
|
echo " (-adm|-ad) perform an adjoint run" |
26 |
|
echo " (-command) STRING command to run" |
27 |
echo " (DEF=\"make output.txt\")" |
echo " (DEF=\"make output.txt\")" |
28 |
echo " (-m|-make)STRING command to use for \"make\"" |
echo " (-m|-make) STRING command to use for \"make\"" |
29 |
echo " (DEF=\"make\")" |
echo " (DEF=\"make\")" |
30 |
echo " (-clean) *ONLY* run \"make CLEAN\"" |
echo " (-clean) *ONLY* run \"make CLEAN\"" |
31 |
echo " (-quick|-q) same as \"-nogenmake -noclean -nodepend\"" |
echo " (-quick|-q) same as \"-nogenmake -noclean -nodepend\"" |
32 |
echo " (-nogenmake|-ng) skip the genmake stage" |
echo " (-nogenmake|-ng) skip the genmake stage" |
33 |
echo " (-noclean|-nc) skip the \"make clean\" stage" |
echo " (-noclean|-nc) skip the \"make clean\" stage" |
34 |
echo " (-nodepend|-nd) skip the \"make depend\" stage" |
echo " (-nodepend|-nd) skip the \"make depend\" stage" |
35 |
|
echo " (-deldir|-dd) on success, delete the output directory" |
36 |
echo |
echo |
37 |
echo "and where STRING follows a whitespace-delimited format" |
echo "and where STRING follows a whitespace-delimited format" |
38 |
echo "such as:" |
echo "such as:" |
45 |
# build the mpack utility |
# build the mpack utility |
46 |
build_mpack() |
build_mpack() |
47 |
{ |
{ |
48 |
echo -n "building the mpack utility... " |
printf "building the mpack utility... " |
49 |
if test ! -x "$MPACKDIR/mpack" ; then |
if test ! -x "$MPACKDIR/mpack" ; then |
50 |
if test ! -d $MPACKDIR ; then |
if test ! -d $MPACKDIR ; then |
51 |
|
echo |
52 |
echo "Error: can't find \"$MPACKDIR\"" |
echo "Error: can't find \"$MPACKDIR\"" |
53 |
echo " are you sure this program is being run in the correct " |
echo " are you sure this program is being run in the correct " |
54 |
echo " (that is, \"MITGCM_ROOT\verification\") directory?" |
echo " (that is, \"MITGCM_ROOT\verification\") directory?" |
55 |
exit 1 |
echo |
56 |
|
HAVE_MPACK=f |
57 |
|
fi |
58 |
|
printf "building mpack... " |
59 |
|
if test "x$CC" = x ; then |
60 |
|
export CC=cc |
61 |
fi |
fi |
62 |
echo -n "building mpack... " |
( cd $MPACKDIR && ./configure && $MAKE ) > tr_build_mpack.out 2>&1 |
|
( cd $MPACKDIR && ./configure && $MAKE ) > build_mpack.out 2>&1 |
|
63 |
RETVAL=$? |
RETVAL=$? |
64 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
65 |
echo |
echo |
66 |
echo "Error building the mpack tools at: $MPACK_DIR" |
echo "Error building the mpack tools at: $MPACK_DIR" |
67 |
exit 1 |
echo |
68 |
|
HAVE_MPACK=f |
69 |
|
else |
70 |
|
rm -f tr_build_mpack.out |
71 |
|
HAVE_MPACK=t |
72 |
fi |
fi |
73 |
|
else |
74 |
|
HAVE_MPACK=t |
75 |
fi |
fi |
76 |
echo "OK" |
echo "OK" |
77 |
} |
} |
78 |
|
|
|
compare_lines() |
|
|
{ |
|
|
# use codelet to compare lines |
|
|
if [ $verbose -gt 1 ]; then |
|
|
cat tmp3.txt 1>&2 |
|
|
fi |
|
|
return `./a.out < tmp3.txt` |
|
|
} |
|
|
|
|
79 |
testoutput_for_prop() |
testoutput_for_prop() |
80 |
{ |
{ |
81 |
# testoutput_for_prop dir s1 label subdir |
# testoutput_for_prop dir s1 label subdir extension |
82 |
# |
# |
83 |
# compares files in $dir/$subdir/output.txt and $dir/results/output.txt |
# compares files in $dir/$subdir/output.txt and $dir/results/output.txt |
84 |
# using search strings s1 and text label |
# using search strings s1 and text label |
100 |
return 99 |
return 99 |
101 |
fi |
fi |
102 |
if [ $debug -gt 0 ]; then |
if [ $debug -gt 0 ]; then |
103 |
echo testoutput_for_prop: grep "$2" $1/results/output.txt 1>&2 |
echo testoutput_for_prop: grep "$2" $1/results/output.txt$5 1>&2 |
104 |
fi |
fi |
105 |
grep "$2" $1/results/output.txt | sed 's/.*=//' | cat -n > tmp2.txt |
grep "$2" $1/results/output.txt$5 | sed 's/.*=//' | cat -n > tmp2.txt |
106 |
lncnt=`wc -l tmp2.txt | awk '{print $1}' ` |
lncnt=`wc -l tmp2.txt | awk '{print $1}' ` |
107 |
if [ $lncnt -lt 3 ]; then |
if [ $lncnt -lt 3 ]; then |
108 |
if [ $verbose -gt 0 ]; then |
if [ $verbose -gt 0 ]; then |
117 |
if [ $debug -gt 0 ]; then |
if [ $debug -gt 0 ]; then |
118 |
echo testoutput_for_prop: compare_lines 1>&2 |
echo testoutput_for_prop: compare_lines 1>&2 |
119 |
fi |
fi |
120 |
compare_lines |
if [ $verbose -gt 1 ]; then |
121 |
digits_of_similarity=$? |
cat tmp3.txt 1>&2 |
122 |
|
fi |
123 |
|
echo "-1" >> tmp3.txt |
124 |
|
# On the SGI O3K (*not* the O2K), "cat -n" inserts a ":" after the line number |
125 |
|
cat tmp3.txt | sed -e 's|:||g' > tmp4.txt |
126 |
|
digits_of_similarity=`./tmp_cmpnum < tmp4.txt` |
127 |
if [ $digits_of_similarity -eq 99 ]; then |
if [ $digits_of_similarity -eq 99 ]; then |
128 |
if [ $verbose -gt 0 ]; then |
if [ $verbose -gt 0 ]; then |
129 |
echo testoutput_for_prop: No comparison was available for \"$2\" 1>&2 |
echo testoutput_for_prop: No comparison was available for \"$2\" 1>&2 |
134 |
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 |
135 |
fi |
fi |
136 |
fi |
fi |
137 |
rm tmp1.txt tmp2.txt tmp3.txt |
rm -f tmp1.txt tmp2.txt tmp3.txt tmp4.txt |
138 |
|
|
139 |
return $digits_of_similarity |
return $digits_of_similarity |
140 |
} |
} |
154 |
done |
done |
155 |
} |
} |
156 |
|
|
157 |
|
testoutput_ad() |
158 |
|
{ |
159 |
|
grep $3 $1/results_ad/output.txt_adm | awk '{print NR " " $5}' > t05.txt |
160 |
|
grep $3 $1/$2/output.txt_adm | awk '{print NR " " $5}' > t15.txt |
161 |
|
grep $3 $1/results_ad/output.txt_adm | awk '{print NR " " $6}' > t06.txt |
162 |
|
grep $3 $1/$2/output.txt_adm | awk '{print NR " " $6}' > t16.txt |
163 |
|
join t05.txt t15.txt > t5.txt |
164 |
|
join t06.txt t16.txt > t6.txt |
165 |
|
echo "-1" >> t5.txt |
166 |
|
echo "-1" >> t6.txt |
167 |
|
digits_5=`./tmp_cmpnum < t5.txt` |
168 |
|
digits_6=`./tmp_cmpnum < t6.txt` |
169 |
|
dashnum $digits_5 $digits_6 |
170 |
|
rm -f t[01][56].txt t[56].txt |
171 |
|
} |
172 |
|
|
173 |
testoutput() |
testoutput() |
174 |
{ |
{ |
175 |
# testoutput diretory subdir |
# testoutput directory subdir extension |
176 |
# |
# |
177 |
# test output in "directory" |
# test output in "directory" |
178 |
|
if test "x$ADM" = x ; then |
179 |
if [ $debug -gt 0 ]; then |
if [ $debug -gt 0 ]; then |
180 |
echo testoutput: testoutput_for_prop $1 cg2d_init_res 1>&2 |
echo testoutput: testoutput_for_prop $1 cg2d_init_res 1>&2 |
181 |
fi |
fi |
182 |
testoutput_for_prop $1 "cg2d_init_res" "cg2d init. residual" $2; cg2dres=$? |
testoutput_for_prop $1 "cg2d_init_res" "cg2d init. residual" $2 $3; cg2dres=$? |
183 |
if [ $debug -gt 0 ]; then |
if [ $debug -gt 0 ]; then |
184 |
echo testoutput: cg2dres=$cg2dres 1>&2 |
echo testoutput: cg2dres=$cg2dres 1>&2 |
185 |
|
fi |
186 |
|
testoutput_for_prop $1 "dynstat_theta_min" "theta minimum" $2 $3; tmin=$? |
187 |
|
testoutput_for_prop $1 "dynstat_theta_max" "theta maximum" $2 $3; tmax=$? |
188 |
|
testoutput_for_prop $1 "dynstat_theta_mean" "theta mean" $2 $3; tmean=$? |
189 |
|
testoutput_for_prop $1 "dynstat_theta_sd" "theta s.d." $2 $3; tsd=$? |
190 |
|
testoutput_for_prop $1 "dynstat_salt_min" "salt minimum" $2 $3; smin=$? |
191 |
|
testoutput_for_prop $1 "dynstat_salt_max" "salt maximum" $2 $3; smax=$? |
192 |
|
testoutput_for_prop $1 "dynstat_salt_mean" "salt mean" $2 $3; smean=$? |
193 |
|
testoutput_for_prop $1 "dynstat_salt_sd" "salt s.d." $2 $3; ssd=$? |
194 |
|
testoutput_for_prop $1 "dynstat_uvel_min" "U minimum" $2 $3; umin=$? |
195 |
|
testoutput_for_prop $1 "dynstat_uvel_max" "U maximum" $2 $3; umax=$? |
196 |
|
testoutput_for_prop $1 "dynstat_uvel_mean" "U mean" $2 $3; umean=$? |
197 |
|
testoutput_for_prop $1 "dynstat_uvel_sd" "U s.d." $2 $3; usd=$? |
198 |
|
testoutput_for_prop $1 "dynstat_vvel_min" "V minimum" $2 $3; vmin=$? |
199 |
|
testoutput_for_prop $1 "dynstat_vvel_max" "V maximum" $2 $3; vmax=$? |
200 |
|
testoutput_for_prop $1 "dynstat_vvel_mean" "V mean" $2 $3; vmean=$? |
201 |
|
testoutput_for_prop $1 "dynstat_vvel_sd" "V s.d." $2 $3; vsd=$? |
202 |
|
dashnum $cg2dres $tmin $tmax $tmean $tsd $smin $smax $smean $ssd \ |
203 |
|
$umin $umax $umean $usd $vmin $vmax $vmean $vsd |
204 |
|
else |
205 |
|
testoutput_ad $1 $2 "precision_grdchk_result" |
206 |
fi |
fi |
|
testoutput_for_prop $1 "dynstat_theta_min" "theta minimum" $2; tmin=$? |
|
|
testoutput_for_prop $1 "dynstat_theta_max" "theta maximum" $2; tmax=$? |
|
|
testoutput_for_prop $1 "dynstat_theta_mean" "theta mean" $2; tmean=$? |
|
|
testoutput_for_prop $1 "dynstat_theta_sd" "theta s.d." $2; tsd=$? |
|
|
testoutput_for_prop $1 "dynstat_salt_min" "salt minimum" $2; smin=$? |
|
|
testoutput_for_prop $1 "dynstat_salt_max" "salt maximum" $2; smax=$? |
|
|
testoutput_for_prop $1 "dynstat_salt_mean" "salt mean" $2; smean=$? |
|
|
testoutput_for_prop $1 "dynstat_salt_sd" "salt s.d." $2; ssd=$? |
|
|
testoutput_for_prop $1 "dynstat_uvel_min" "U minimum" $2; umin=$? |
|
|
testoutput_for_prop $1 "dynstat_uvel_max" "U maximum" $2; umax=$? |
|
|
testoutput_for_prop $1 "dynstat_uvel_mean" "U mean" $2; umean=$? |
|
|
testoutput_for_prop $1 "dynstat_uvel_sd" "U s.d." $2; usd=$? |
|
|
testoutput_for_prop $1 "dynstat_vvel_min" "V minimum" $2; vmin=$? |
|
|
testoutput_for_prop $1 "dynstat_vvel_max" "V maximum" $2; vmax=$? |
|
|
testoutput_for_prop $1 "dynstat_vvel_mean" "V mean" $2; vmean=$? |
|
|
testoutput_for_prop $1 "dynstat_vvel_sd" "V s.d." $2; vsd=$? |
|
|
|
|
|
dashnum $cg2dres $tmin $tmax $tmean $tsd $smin $smax $smean $ssd \ |
|
|
$umin $umax $umean $usd $vmin $vmax $vmean $vsd |
|
207 |
} |
} |
208 |
|
|
209 |
genmakemodel() |
genmakemodel() |
212 |
if test "x$NOGENMAKE" = xt ; then |
if test "x$NOGENMAKE" = xt ; then |
213 |
echo "genmake skipped!" |
echo "genmake skipped!" |
214 |
else |
else |
215 |
GENMAKE2="$BASH ../../../tools/genmake2" |
if test "x$BASH" = x ; then |
216 |
|
GENMAKE2="../../../tools/genmake2" |
217 |
|
else |
218 |
|
GENMAKE2="$BASH ../../../tools/genmake2 -bash $BASH" |
219 |
|
fi |
220 |
( |
( |
221 |
cd $1; |
cd $1; |
222 |
command="$GENMAKE2 -ds -m $MAKE --mods=../code" |
command="$GENMAKE2 -ds -m $MAKE" |
223 |
|
if test "x$ADM" = x ; then |
224 |
|
command="$command --mods=../code" |
225 |
|
else |
226 |
|
command="$command --mods=../code_ad" |
227 |
|
command="$command -adof=../../../tools/adjoint_options/adjoint_staf" |
228 |
|
fi |
229 |
if test "x$OPTFILE" != xNONE ; then |
if test "x$OPTFILE" != xNONE ; then |
230 |
command="$command --optfile=$OPTFILE" |
command="$command --optfile=$OPTFILE" |
|
# echo " command=\"$command\"" |
|
231 |
fi |
fi |
232 |
if test "x$IEEE" != x ; then |
if test "x$IEEE" != x ; then |
233 |
command="$command -ieee" |
command="$command -ieee" |
234 |
fi |
fi |
|
# echo "command: \"$command\"" |
|
235 |
printf 'genmake ... ' 1>&2 |
printf 'genmake ... ' 1>&2 |
236 |
$command > make.log 2>&1 |
$command > make.log 2>&1 |
237 |
RETVAL=$? |
RETVAL=$? |
238 |
for i in genmake_state genmake_optfile genmake_local Makefile ; do |
cp Makefile $CDIR |
|
if test -r $i ; then |
|
|
cp $i $CDIR |
|
|
fi |
|
|
done |
|
239 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
240 |
tail make.log |
tail make.log |
241 |
echo "genmakemodel: genmake failed" 1>&2 |
echo "genmakemodel: genmake failed" 1>&2 |
242 |
cp make.log $CDIR |
cp genmake_* make.log $CDIR |
243 |
return 1 |
return 1 |
244 |
else |
else |
245 |
echo "succesful" 1>&2 |
echo "successful" 1>&2 |
246 |
fi |
fi |
247 |
) |
) |
248 |
fi |
fi |
270 |
return 1 |
return 1 |
271 |
fi |
fi |
272 |
fi |
fi |
273 |
echo succesful 1>&2 |
echo successful 1>&2 |
274 |
exit 0 |
exit 0 |
275 |
) |
) |
276 |
fi |
fi |
293 |
cp make.log $CDIR"/make.log" |
cp make.log $CDIR"/make.log" |
294 |
return 1 |
return 1 |
295 |
else |
else |
296 |
echo succesful 1>&2 |
echo successful 1>&2 |
297 |
fi |
fi |
298 |
) |
) |
299 |
fi |
fi |
306 |
cd $1; |
cd $1; |
307 |
if test -r Makefile ; then |
if test -r Makefile ; then |
308 |
printf 'make ... ' 1>&2 |
printf 'make ... ' 1>&2 |
309 |
$MAKE >> make.log 2>&1 |
if test "x$ADM" = x ; then |
310 |
|
$MAKE >> make.log 2>&1 |
311 |
|
else |
312 |
|
$MAKE adall >> make.log 2>&1 |
313 |
|
fi |
314 |
RETVAL=$? |
RETVAL=$? |
315 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
316 |
tail make.log |
tail make.log |
318 |
cp make.log $CDIR"/make.log" |
cp make.log $CDIR"/make.log" |
319 |
return 1 |
return 1 |
320 |
else |
else |
321 |
echo succesful 1>&2 |
echo successful 1>&2 |
322 |
fi |
fi |
323 |
fi |
fi |
324 |
) |
) |
325 |
} |
} |
326 |
|
|
327 |
|
symlink_mpifiles() |
328 |
|
{ |
329 |
|
# Put special links so that MPI specific files are used |
330 |
|
# This MUST be invoked between makeclean and makelinks because |
331 |
|
# the Makefile will link to non-mpi files by default |
332 |
|
|
333 |
|
dir=$1 |
334 |
|
code_dir=$2 |
335 |
|
BUILD_DIR=$dir/$3 |
336 |
|
CODE_DIR=$dir/$code_dir |
337 |
|
|
338 |
|
# These are files that should replace their counter-part when using -mpi |
339 |
|
MPI_FILES=`(cd $CODE_DIR; find . -name "*_mpi")` |
340 |
|
|
341 |
|
# Is this an MPI run? |
342 |
|
if test "x$MPI" = xt ; then |
343 |
|
# YES: We symbolically link these files to the build |
344 |
|
# dir so long as there is no real file in place |
345 |
|
for ii in $MPI_FILES ; do |
346 |
|
i=`echo $ii | sed 's:^\./::'` |
347 |
|
name=`echo $i | sed 's:_mpi::' ` |
348 |
|
cmp $CODE_DIR/$i $BUILD_DIR/$name > /dev/null 2>&1 |
349 |
|
RETVAL=$? |
350 |
|
if test "x$RETVAL" != x0 ; then |
351 |
|
if ! test -f $BUILD_DIR/$i ; then |
352 |
|
#echo Linking $name to $i |
353 |
|
(cd $BUILD_DIR; ln -sf ../$code_dir/$i $name) |
354 |
|
fi |
355 |
|
fi |
356 |
|
done |
357 |
|
else |
358 |
|
# NO: We undo any _mpi symbolically linked files |
359 |
|
for ii in $MPI_FILES ; do |
360 |
|
i=`echo $ii | sed 's:^\./::'` |
361 |
|
name=`echo $i | sed 's:_mpi::' ` |
362 |
|
if test -L $BUILD_DIR/$name ; then |
363 |
|
linktarg=`(cd $BUILD_DIR; readlink $name)` |
364 |
|
if test $linktarg = "../$code_dir/$name"_mpi ; then |
365 |
|
#echo Un-linking $name from $linktarg |
366 |
|
rm -f $BUILD_DIR/$name |
367 |
|
fi |
368 |
|
fi |
369 |
|
done |
370 |
|
fi |
371 |
|
|
372 |
|
} |
373 |
|
|
374 |
linkdata() |
linkdata() |
375 |
{ |
{ |
376 |
# linkdata flag |
# linkdata flag |
379 |
if test "x$1" = x1 ; then |
if test "x$1" = x1 ; then |
380 |
( |
( |
381 |
cd $2 |
cd $2 |
382 |
files=`( cd ../input ; ls -1 | grep -v CVS )` |
if test "x$ADM" = x ; then |
383 |
for i in $files ; do |
files=`( cd ../input ; ls -1 | grep -v CVS )` |
384 |
if test ! -d "../input/"$i ; then |
for i in $files ; do |
385 |
ln -sf "../input/"$i $i |
if test ! -d "../input/"$i ; then |
386 |
fi |
ln -sf "../input/"$i $i |
387 |
done |
fi |
388 |
|
done |
389 |
|
else |
390 |
|
files=`( cd ../input ; ls -1 *.bin | grep -v CVS )` |
391 |
|
for i in $files ; do |
392 |
|
if test ! -d "../input/"$i ; then |
393 |
|
ln -sf "../input/"$i $i |
394 |
|
fi |
395 |
|
done |
396 |
|
files=`( cd ../input_ad ; ls -1 | grep -v CVS )` |
397 |
|
for i in $files ; do |
398 |
|
if test ! -d "../input_ad/"$i ; then |
399 |
|
ln -sf "../input_ad/"$i $i |
400 |
|
fi |
401 |
|
done |
402 |
|
fi |
403 |
) |
) |
404 |
fi |
fi |
405 |
} |
} |
408 |
{ |
{ |
409 |
# runmodel directory |
# runmodel directory |
410 |
# |
# |
411 |
# runs "$COMMAND" in "directory" |
# runs "$COMMAND in "directory" |
412 |
# (where "$COMMAND" is relative to "directory") |
# (where "$COMMAND" is relative to "directory") |
413 |
( |
( |
414 |
cd $1 |
cd $1 |
415 |
printf 'runmodel: ' 1>&2 |
printf 'runmodel ... ' 1>&2 |
416 |
# make output.txt |
# make output.txt |
417 |
$COMMAND |
echo |
418 |
|
# echo "COMMAND='$COMMAND'" |
419 |
|
# echo "pwd='"`pwd`"'" |
420 |
|
( eval $COMMAND ) >> run.log 2>&1 |
421 |
RETVAL=$? |
RETVAL=$? |
422 |
if test "x$RETVAL" = x0 ; then |
if test "x$RETVAL" = x0 ; then |
423 |
cp output.txt $CDIR"/output.txt" |
echo successful 1>&2 |
424 |
|
if test "x$ADM" = x ; then |
425 |
|
cp output.txt $CDIR"/output.txt" |
426 |
|
else |
427 |
|
cp output.txt_adm $CDIR"/output.txt_adm" |
428 |
|
fi |
429 |
return 0 |
return 0 |
430 |
else |
else |
431 |
|
tail run.log |
432 |
|
echo failed 1>&2 |
433 |
|
cp run.log $CDIR"/run.log" |
434 |
return 1 |
return 1 |
435 |
fi |
fi |
436 |
) |
) |
440 |
{ |
{ |
441 |
# create codelet for comparing model output |
# create codelet for comparing model output |
442 |
|
|
443 |
echo -n "creating the comparison code... " |
printf "creating the comparison code... " |
444 |
cat > tmp_cmpnum.f <<EOFA |
cat > tmp_cmpnum.c <<EOF |
445 |
program cmpnum |
#include <stdio.h> |
446 |
implicit none |
#include <math.h> |
447 |
real*8 a,b,diff |
int main( int argc, char** argv ) { |
448 |
integer linnum,best |
int linnum,best,lncnt; |
449 |
best=-16 |
double a,b,diff; |
450 |
99 read(*,*,end=70,err=60) linnum,a,b |
best = -16; |
451 |
diff=0.5*(abs(a)+abs(b)) |
lncnt = 0; |
452 |
c print *,a,b,diff,abs(a-b)/diff |
while( 1 & (lncnt+=1) < 999 ) { |
453 |
if (diff.gt.1.e-12) then |
scanf("%d", &linnum); |
454 |
diff=abs(a-b)/diff |
if (linnum == -1) break; |
455 |
if (diff.gt.0.) then |
scanf("%lf", &a); scanf("%lf", &b); |
456 |
c print *,int(log10(diff)),diff |
diff = 0.5*(fabs(a)+fabs(b)); |
457 |
linnum=int(log10(diff)) |
if (diff > 1.e-12) { |
458 |
best=max(best,linnum) |
diff=fabs(a-b)/diff; |
459 |
endif |
if (diff > 0.0) { |
460 |
else |
linnum = (int)log10(diff); |
461 |
if (best.eq.-16.and.diff.ne.0.) best=-22 |
best = (best > linnum) ? best : linnum; |
462 |
endif |
} |
463 |
goto 99 |
else { |
464 |
60 stop 'cmpnum: An error occured reading a,b' |
if (best == -16 && diff != 0) best = -22; |
465 |
70 print *,-best |
} |
466 |
end |
} |
467 |
EOFA |
} |
468 |
|
if (lncnt == 999) best=-29; |
469 |
|
printf("%d\n", -best); |
470 |
|
return 0; |
471 |
|
} |
472 |
|
EOF |
473 |
|
cc -o tmp_cmpnum tmp_cmpnum.c -lm |
474 |
|
|
475 |
f77 tmp_cmpnum.f |
if [ -x ./tmp_cmpnum ]; then |
|
if [ -x ./a.out ]; then |
|
476 |
echo "OK" |
echo "OK" |
477 |
return 0 |
return 0 |
478 |
else |
else |
479 |
echo |
echo |
480 |
echo "createcodelet: failed to compile codelet" |
echo "ERROR: failed to compile comparison code" |
481 |
exit 1 |
exit 1 |
482 |
fi |
fi |
483 |
} |
} |
537 |
|
|
538 |
|
|
539 |
############################################################################### |
############################################################################### |
|
############################################################################### |
|
|
############################################################################### |
|
540 |
|
|
541 |
|
|
542 |
# Default properties |
# Default properties |
546 |
expts='' |
expts='' |
547 |
# ieee=1 |
# ieee=1 |
548 |
|
|
549 |
IEEE= |
IEEE=true |
550 |
if test "x$MITGCM_IEEE" != x ; then |
if test "x$MITGCM_IEEE" != x ; then |
551 |
IEEE=$MITGCM_IEEE |
IEEE=$MITGCM_IEEE |
552 |
fi |
fi |
563 |
ADDRESSES= |
ADDRESSES= |
564 |
TESTDIRS= |
TESTDIRS= |
565 |
MPACKDIR="../tools/mpack-1.6" |
MPACKDIR="../tools/mpack-1.6" |
566 |
|
HAVE_MPACK= |
567 |
MPACK="$MPACKDIR/mpack" |
MPACK="$MPACKDIR/mpack" |
568 |
COMMAND="make output.txt" |
COMMAND= |
569 |
MAKE=make |
MAKE=make |
570 |
MPI=f |
MPI=f |
571 |
|
DELDIR= |
572 |
|
|
573 |
|
ADM= |
574 |
|
|
575 |
echo -n "parsing options... " |
printf "parsing options... " |
576 |
|
|
577 |
ac_prev= |
ac_prev= |
578 |
for ac_option ; do |
for ac_option ; do |
635 |
|
|
636 |
-mpi) MPI=t ;; |
-mpi) MPI=t ;; |
637 |
|
|
638 |
|
-adm | -ad) ADM=t ;; |
639 |
|
|
640 |
-ieee) IEEE=true ;; |
-ieee) IEEE=true ;; |
641 |
-noieee) IEEE= ;; |
-noieee) IEEE= ;; |
642 |
|
|
644 |
-debug) debug=1 ;; |
-debug) debug=1 ;; |
645 |
-quiet) verbose=0 ;; |
-quiet) verbose=0 ;; |
646 |
|
|
647 |
|
-deldir | -dd) DELDIR=t ;; |
648 |
|
|
649 |
-*) |
-*) |
650 |
echo "Error: unrecognized option: "$ac_option |
echo "Error: unrecognized option: "$ac_option |
651 |
usage |
usage |
674 |
OPTFILE=$MITGCM_OF |
OPTFILE=$MITGCM_OF |
675 |
fi |
fi |
676 |
|
|
677 |
|
if test "x$ADM" = xt -a "x$COMMAND" = x ; then |
678 |
|
COMMAND="./mitgcmuv_ad > output.txt_adm 2>&1" |
679 |
|
fi |
680 |
|
|
681 |
|
if test "x$COMMAND" = x ; then |
682 |
|
COMMAND="make output.txt" |
683 |
|
fi |
684 |
|
|
685 |
echo "OK" |
echo "OK" |
686 |
|
|
687 |
# create the FORTRAN comparison code |
# create the FORTRAN comparison code |
688 |
createcodelet |
createcodelet |
689 |
|
|
690 |
# build the mpack utility |
# build the mpack utility |
691 |
build_mpack |
if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then |
692 |
|
echo "skipping mpack build" |
693 |
|
else |
694 |
|
build_mpack |
695 |
|
fi |
696 |
|
|
697 |
# Create a uniquely named directory to store results |
# Create a uniquely named directory to store results |
698 |
MACH=`hostname` |
MACH=`hostname` |
699 |
UNAMEA=`uname -a` |
UNAMEA=`uname -a` |
700 |
DATE=`date +%Y%m%d` |
DATE=`date +%Y%m%d` |
701 |
BASE=$MACH"_"$DATE"_" |
BASE="tr_"$MACH"_"$DATE"_" |
702 |
DNUM=0 |
DNUM=0 |
703 |
DRESULTS="$BASE$DNUM" |
DRESULTS="$BASE$DNUM" |
704 |
while test -e $DRESULTS ; do |
while test -e $DRESULTS ; do |
708 |
mkdir $DRESULTS |
mkdir $DRESULTS |
709 |
RETVAL=$? |
RETVAL=$? |
710 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
711 |
echo "Error: can't create results directory \"./$DRESULTS\"" |
echo "ERROR: Can't create results directory \"./$DRESULTS\"" |
712 |
exit 1 |
exit 1 |
713 |
fi |
fi |
714 |
SUMMARY="$DRESULTS/summary.txt" |
SUMMARY="$DRESULTS/summary.txt" |
715 |
echo -n "Start time: " >> $SUMMARY |
printf "Start time: " >> $SUMMARY |
716 |
start_date=`date` |
start_date=`date` |
717 |
echo $start_date > $SUMMARY |
echo $start_date > $SUMMARY |
|
cat << EOF >> $SUMMARY |
|
|
T S U V |
|
|
G D M c m s m s m s m s |
|
|
E p a R g m m e . m m e . m m e . m m e . |
|
|
N n k u 2 i a a d i a a d i a a d i a a d |
|
|
2 d e n d n x n . n x n . n x n . n x n . |
|
|
|
|
|
EOF |
|
|
|
|
|
NDIR=0 |
|
718 |
|
|
719 |
of_path= |
of_path= |
720 |
if test "x$OPTFILE" != xNONE ; then |
if test "x$OPTFILE" != xNONE ; then |
728 |
fi |
fi |
729 |
file=${OPTFILE##*/} |
file=${OPTFILE##*/} |
730 |
OPTFILE=$of_path/$file |
OPTFILE=$of_path/$file |
731 |
|
cp $OPTFILE $DRESULTS |
732 |
|
echo >> $SUMMARY |
733 |
|
echo " OPTFILE=$OPTFILE" >> $SUMMARY |
734 |
else |
else |
735 |
echo |
echo | tee $SUMMARY |
736 |
echo "WARNING: can't read OPTFILE=\"$OPTFILE\" but will try to use it..." |
echo "ERROR: can't read OPTFILE=\"$OPTFILE\"" | tee $SUMMARY |
737 |
|
exit 1 |
738 |
fi |
fi |
739 |
|
else |
740 |
|
echo >> $SUMMARY |
741 |
|
echo "No \"OPTFILE\" was explicitly specified by testreport," >> $SUMMARY |
742 |
|
echo " so the genmake default will be used." >> $SUMMARY |
743 |
fi |
fi |
744 |
echo |
echo |
|
echo "OPTFILE=$OPTFILE" >> $SUMMARY |
|
745 |
echo >> $SUMMARY |
echo >> $SUMMARY |
746 |
|
if test "x$ADM" = x ; then |
747 |
|
cat << EOF | tee -a $SUMMARY |
748 |
|
T S U V |
749 |
|
G D M c m s m s m s m s |
750 |
|
E p a R g m m e . m m e . m m e . m m e . |
751 |
|
N n k u 2 i a a d i a a d i a a d i a a d |
752 |
|
2 d e n d n x n . n x n . n x n . n x n . |
753 |
|
|
754 |
|
EOF |
755 |
|
else |
756 |
|
echo "ADJOINT=true" >> $SUMMARY |
757 |
|
echo >> $SUMMARY |
758 |
|
cat << EOF | tee -a $SUMMARY |
759 |
|
G D M C G |
760 |
|
E p a R o r |
761 |
|
N n k u s a |
762 |
|
2 d e n t d |
763 |
|
|
764 |
|
EOF |
765 |
|
fi |
766 |
|
|
767 |
# ...and each test directory... |
# ...and each test directory... |
768 |
for dir in $TESTDIRS ; do |
for dir in $TESTDIRS ; do |
780 |
|
|
781 |
# Verify that the testdir exists and contains previous |
# Verify that the testdir exists and contains previous |
782 |
# results in the correct location--or skip this directory! |
# results in the correct location--or skip this directory! |
783 |
if test ! -r $dir"/results/output.txt" ; then |
fout= |
784 |
echo "can't read \"$dir/results/output.txt\" -- skipping $dir" |
if test "x$ADM" = x ; then |
785 |
|
fout=$dir"/results/output.txt" |
786 |
|
else |
787 |
|
fout=$dir"/results_ad/output.txt_adm" |
788 |
|
fi |
789 |
|
if test ! -r $fout ; then |
790 |
|
echo "can't read \"$fout\" -- skipping $dir" |
791 |
continue |
continue |
792 |
fi |
fi |
793 |
|
|
|
echo "-------------------------------------------------------------------------------" |
|
|
echo |
|
|
echo "Experiment: $dir" |
|
|
echo |
|
|
unset genmake makedepend make run |
|
|
results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --' |
|
|
|
|
794 |
builddir="input" |
builddir="input" |
795 |
rundir="input" |
rundir="input" |
796 |
use_seperate_build=0 |
use_seperate_build=0 |
801 |
linkdata $use_seperate_build $dir/$rundir |
linkdata $use_seperate_build $dir/$rundir |
802 |
fi |
fi |
803 |
|
|
804 |
CODE_DIR=$dir/code |
# Check whether there are "extra runs" for this testdir |
805 |
BUILD_DIR=$dir/$builddir |
extra_runs= |
806 |
MPI_FILES="CPP_EEOPTIONS.h_mpi SIZE.h_mpi" |
if test "x$ADM" = x -a "x$use_seperate_build" = x1 ; then |
807 |
NOMPI_FILES="CPP_EEOPTIONS.h_nompi SIZE.h_nompi" |
ex_run_dirs=`( cd $dir ; echo input.* )` |
808 |
|
echo "ex_run_dirs='$ex_run_dirs'" |
809 |
|
for exd in $ex_run_dirs ; do |
810 |
|
name=`echo $exd | sed -e 's/input.//g'` |
811 |
|
outf="$dir/results/output.txt.$name" |
812 |
|
if test -f $outf -a -r $outf ; then |
813 |
|
extra_runs="$extra_runs $name" |
814 |
|
fi |
815 |
|
done |
816 |
|
fi |
817 |
|
|
818 |
# Is this an MPI run? |
if test "x$ADM" = x ; then |
819 |
if test "x$MPI" = xt ; then |
code_dir=code |
820 |
FILES=$MPI_FILES |
CODE_DIR=$dir/code |
|
endings="_mpi" |
|
821 |
else |
else |
822 |
FILES=$NOMPI_FILES |
code_dir=code_ad |
823 |
endings="_nompi" |
CODE_DIR=$dir/code_ad |
824 |
fi |
fi |
825 |
|
BUILD_DIR=$dir/$builddir |
826 |
# Check to see that we have the files |
|
827 |
have_files=t |
if test ! -r $CODE_DIR"/SIZE.h_mpi" -a "x$MPI" = "xt" ; then |
828 |
for i in $FILES ; do |
echo "can't find \"$CODE_DIR/SIZE.h_mpi\" -- skipping $dir" |
|
if test ! -r $CODE_DIR/$i ; then |
|
|
echo "Warning: can't read file $CODE_DIR/$i" |
|
|
have_files=f |
|
|
fi |
|
|
done |
|
|
if test "x$have_files" != xt -a "x$MPI" = xt ; then |
|
|
echo "Skipping $dir due to lack of input files (see above warning)" |
|
829 |
continue |
continue |
830 |
fi |
fi |
831 |
|
|
832 |
# If we have the $FILES and they differ, copy the $FILES to $BUILD_DIR |
echo "-------------------------------------------------------------------------------" |
833 |
if test "x$have_files" = xt ; then |
echo |
834 |
for i in $FILES ; do |
echo "Experiment: $dir" |
835 |
sstr="s|$endings||" |
echo |
836 |
name=`echo $i | sed -e $sstr ` |
unset genmake makedepend make run |
837 |
cmp $CODE_DIR/$i $BUILD_DIR/$name > /dev/null 2>&1 |
results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --' |
838 |
RETVAL=$? |
|
|
if test "x$RETVAL" != x0 ; then |
|
|
cp $CODE_DIR/$i $BUILD_DIR/$name |
|
|
fi |
|
|
done |
|
|
fi |
|
|
|
|
839 |
# Create an output dir for each OPTFILE/tdir combination |
# Create an output dir for each OPTFILE/tdir combination |
840 |
CDIR=$DRESULTS"/"$DRESULTS"_"$NDIR |
rel_CDIR=$DRESULTS"/"$dir |
841 |
mkdir $CDIR |
mkdir $rel_CDIR |
842 |
CDIR=`pwd`"/$CDIR" |
CDIR=`pwd`"/$rel_CDIR" |
843 |
|
|
844 |
if test "x$CLEANUP" = xt ; then |
if test "x$CLEANUP" = xt ; then |
845 |
makeclean $dir/$builddir |
makeclean $dir/$builddir |
846 |
else |
else |
847 |
genmakemodel $dir/$builddir && genmake=Y \ |
genmakemodel $dir/$builddir && genmake=Y \ |
848 |
&& makeclean $dir/$builddir \ |
&& makeclean $dir/$builddir \ |
849 |
|
&& symlink_mpifiles $dir $code_dir $builddir \ |
850 |
&& makedependmodel $dir/$builddir && makedepend=Y \ |
&& makedependmodel $dir/$builddir && makedepend=Y \ |
851 |
&& makemodel $dir/$builddir && make=Y \ |
&& makemodel $dir/$builddir && make=Y \ |
852 |
&& linkdata $use_seperate_build $dir/$rundir \ |
&& linkdata $use_seperate_build $dir/$rundir \ |
855 |
fi |
fi |
856 |
|
|
857 |
echo |
echo |
858 |
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
if test "x$ADM" = x ; then |
859 |
${run:-N} $results |
fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results` |
860 |
echo |
echo |
861 |
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
echo "$fres" >> $SUMMARY |
862 |
${run:-N} $results >> $SUMMARY |
echo "fresults='$fres'" > $CDIR"/summary.txt" |
863 |
echo "fresults='" > $CDIR"/summary.txt" |
echo "MACH='$MACH'" >> $CDIR"/summary.txt" |
864 |
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt" |
865 |
${run:-N} $results >> $CDIR"/summary.txt" |
echo "DATE='$DATE'" >> $CDIR"/summary.txt" |
866 |
echo "'" >> $CDIR"/summary.txt" |
echo "tdir='$dir'" >> $CDIR"/summary.txt" |
867 |
echo "MACH='$MACH'" >> $CDIR"/summary.txt" |
|
868 |
echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt" |
OLD_COMMAND=$COMMAND |
869 |
echo "DATE='$DATE'" >> $CDIR"/summary.txt" |
COMMAND="./mitgcmuv > output.txt" |
870 |
echo "tdir='$dir'" >> $CDIR"/summary.txt" |
for ex in $extra_runs ; do |
871 |
|
test -e "$dir/tr_run.$ex" && rm -rf "$dir/tr_run.$ex" |
872 |
( |
mkdir "$dir/tr_run.$ex" |
873 |
cd $DRESULTS |
links=`( cd "$dir/input" > /dev/null 2>&1 ; ls -1 | grep -v CVS )` |
874 |
tar -cf $NDIR".tar" $DRESULTS"_"$NDIR > /dev/null 2>&1 |
( |
875 |
gzip $NDIR".tar" |
cd "$dir/tr_run.$ex" |
876 |
) |
for i in $links; do |
877 |
|
ln -s ../input/$i $i |
878 |
if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then |
done |
879 |
echo "No mail sent" |
) |
880 |
|
links=`( cd "$dir/input.$ex" > /dev/null 2>&1 ; ls -1 | grep -v CVS )` |
881 |
|
( |
882 |
|
cd "$dir/tr_run.$ex" |
883 |
|
for i in $links; do |
884 |
|
test -e $i && rm -f $i |
885 |
|
ln -s ../input.$ex/$i $i |
886 |
|
done |
887 |
|
ln -s ../$builddir/mitgcmuv mitgcmuv |
888 |
|
) |
889 |
|
runmodel $dir/tr_run.$ex && run=Y \ |
890 |
|
&& results=`testoutput $dir tr_run.$ex "."$ex` |
891 |
|
fres=`printf '%s %s %s %s' ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N}` |
892 |
|
fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results` |
893 |
|
fres="$fres.$ex" |
894 |
|
echo |
895 |
|
echo "$fres" >> $SUMMARY |
896 |
|
echo "fresults='$fres'" > $CDIR"/summary.txt" |
897 |
|
echo "MACH='$MACH'" >> $CDIR"/summary.txt" |
898 |
|
echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt" |
899 |
|
echo "DATE='$DATE'" >> $CDIR"/summary.txt" |
900 |
|
echo "tdir='$dir'" >> $CDIR"/summary.txt" |
901 |
|
done |
902 |
|
COMMAND=$OLD_COMMAND |
903 |
else |
else |
904 |
$MPACK -s MITgcm-test -m 1000000 $DRESULTS"/"$NDIR".tar.gz" $ADDRESSES |
fres=`printf '%s %s %s %s' ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N}` |
905 |
RETVAL=$? |
fres=$fres"$results $dir" |
906 |
if test "x$RETVAL" != x0 ; then |
echo |
907 |
echo "Warning: \"$MPACK\" failed -- please contact <edhill@mitgcm.org>" |
echo "$fres" >> $SUMMARY |
908 |
else |
echo "fresults='$fres'" > $CDIR"/summary.txt" |
909 |
rm -f $DRESULTS"/"$NDIR".tar*" |
echo "MACH='$MACH'" >> $CDIR"/summary.txt" |
910 |
fi |
echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt" |
911 |
|
echo "DATE='$DATE'" >> $CDIR"/summary.txt" |
912 |
|
echo "tdir='$dir'" >> $CDIR"/summary.txt" |
913 |
fi |
fi |
|
|
|
|
echo "-------------------------------------------------------------------------------" |
|
914 |
|
|
915 |
NDIR=$(( $NDIR + 1 )) |
echo "-------------------------------------------------------------------------------" |
916 |
|
|
917 |
done |
done |
918 |
|
|
919 |
echo -n "Start time: " >> $SUMMARY |
printf "Start time: " >> $SUMMARY |
920 |
echo $start_date >> $SUMMARY |
echo $start_date >> $SUMMARY |
921 |
echo -n "End time: " >> $SUMMARY |
printf "End time: " >> $SUMMARY |
922 |
date >> $SUMMARY |
date >> $SUMMARY |
923 |
|
|
924 |
rm tmp_cmpnum.f a.out |
# If addresses were supplied and mpack built successfully, then try |
925 |
|
# to send email using mpack. |
926 |
|
if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then |
927 |
|
echo "No results email was sent." |
928 |
|
else |
929 |
|
if test "x$HAVE_MPACK" = xt ; then |
930 |
|
tar -cf $DRESULTS".tar" $DRESULTS > /dev/null 2>&1 \ |
931 |
|
&& gzip $DRESULTS".tar" \ |
932 |
|
&& $MPACK -s MITgcm-test -m 1500000 $DRESULTS".tar.gz" $ADDRESSES |
933 |
|
RETVAL=$? |
934 |
|
if test "x$RETVAL" != x0 ; then |
935 |
|
echo |
936 |
|
echo "Warning: The tar, gzip, & mpack step failed. Please send email" |
937 |
|
echo " to <MITgcm-support@mitgcm.org> for help. You may copy the " |
938 |
|
echo " summary of results from the directory \"$DRESULTS\"." |
939 |
|
echo |
940 |
|
else |
941 |
|
echo |
942 |
|
echo "An email containing results was sent to the following addresses:" |
943 |
|
echo " \"$ADDRESSES\"" |
944 |
|
echo |
945 |
|
fi |
946 |
|
test -f $DRESULTS".tar" && rm -f $DRESULTS".tar" |
947 |
|
test -f $DRESULTS".tar.gz" && rm -f $DRESULTS".tar.gz" |
948 |
|
fi |
949 |
|
fi |
950 |
|
|
951 |
|
# rm -f tmp_cmpnum.f a.out |
952 |
|
rm -f tmp_cmpnum.c tmp_cmpnum |
953 |
|
|
954 |
if test "x$CLEANUP" != xt ; then |
if test "x$CLEANUP" != xt ; then |
955 |
cat $SUMMARY |
cat $SUMMARY |
956 |
if test -e tr.out ; then |
if test -e tr_out.txt ; then |
957 |
mv tr.out tr.out.old |
mv tr_out.txt tr_out.txt.old |
958 |
fi |
fi |
959 |
cat $SUMMARY > tr.out |
cat $SUMMARY > tr_out.txt |
960 |
|
fi |
961 |
|
|
962 |
|
if test "x$DELDIR" = xt ; then |
963 |
|
rm -rf $DRESULTS |
964 |
fi |
fi |
965 |
|
|