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