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\")" |
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\")" |
22 |
echo " (-b|-bash) STRING preferred location of a \"bash\" or" |
echo " (-b|-bash) STRING preferred location of a \"bash\" or" |
23 |
echo " Bourne-compatible \"sh\" shell" |
echo " Bourne-compatible \"sh\" shell" |
24 |
echo " (DEF=\"\" for \"bash\")" |
echo " (DEF=\"\" for \"bash\")" |
25 |
|
echo " (-adm|-ad) perform an adjoint run" |
26 |
echo " (-command) STRING command to run" |
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 " (-j) JOBS use \"make -j JOBS\" for parallel builds" |
31 |
echo " (-clean) *ONLY* run \"make CLEAN\"" |
echo " (-clean) *ONLY* run \"make CLEAN\"" |
32 |
echo " (-quick|-q) same as \"-nogenmake -noclean -nodepend\"" |
echo " (-quick|-q) same as \"-nogenmake -noclean -nodepend\"" |
33 |
echo " (-nogenmake|-ng) skip the genmake stage" |
echo " (-nogenmake|-ng) skip the genmake stage" |
34 |
echo " (-noclean|-nc) skip the \"make clean\" stage" |
echo " (-noclean|-nc) skip the \"make clean\" stage" |
35 |
echo " (-nodepend|-nd) skip the \"make depend\" stage" |
echo " (-nodepend|-nd) skip the \"make depend\" stage" |
36 |
|
echo " (-deldir|-dd) on success, delete the output directory" |
37 |
echo |
echo |
38 |
echo "and where STRING follows a whitespace-delimited format" |
echo "and where STRING follows a whitespace-delimited format" |
39 |
echo "such as:" |
echo "such as:" |
46 |
# build the mpack utility |
# build the mpack utility |
47 |
build_mpack() |
build_mpack() |
48 |
{ |
{ |
49 |
echo -n "building the mpack utility... " |
printf "building the mpack utility... " |
50 |
if test ! -x "$MPACKDIR/mpack" ; then |
if test ! -x "$MPACKDIR/mpack" ; then |
51 |
if test ! -d $MPACKDIR ; then |
if test ! -d $MPACKDIR ; then |
52 |
echo |
echo |
56 |
echo |
echo |
57 |
HAVE_MPACK=f |
HAVE_MPACK=f |
58 |
fi |
fi |
59 |
echo -n "building mpack... " |
printf "building mpack... " |
60 |
( cd $MPACKDIR && ./configure && $MAKE ) > build_mpack.out 2>&1 |
if test "x$CC" = x ; then |
61 |
|
export CC=cc |
62 |
|
fi |
63 |
|
( cd $MPACKDIR && ./configure && $MAKE ) > tr_build_mpack.out 2>&1 |
64 |
RETVAL=$? |
RETVAL=$? |
65 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
66 |
echo |
echo |
68 |
echo |
echo |
69 |
HAVE_MPACK=f |
HAVE_MPACK=f |
70 |
else |
else |
71 |
|
rm -f tr_build_mpack.out |
72 |
HAVE_MPACK=t |
HAVE_MPACK=t |
73 |
fi |
fi |
74 |
else |
else |
77 |
echo "OK" |
echo "OK" |
78 |
} |
} |
79 |
|
|
|
compare_lines() |
|
|
{ |
|
|
# use codelet to compare lines |
|
|
if [ $verbose -gt 1 ]; then |
|
|
cat tmp3.txt 1>&2 |
|
|
fi |
|
|
return `./a.out < tmp3.txt` |
|
|
} |
|
|
|
|
80 |
testoutput_for_prop() |
testoutput_for_prop() |
81 |
{ |
{ |
82 |
# testoutput_for_prop dir s1 label subdir |
# testoutput_for_prop dir s1 label subdir extension |
83 |
# |
# |
84 |
# compares files in $dir/$subdir/output.txt and $dir/results/output.txt |
# compares files in $dir/$subdir/output.txt and $dir/results/output.txt |
85 |
# using search strings s1 and text label |
# using search strings s1 and text label |
101 |
return 99 |
return 99 |
102 |
fi |
fi |
103 |
if [ $debug -gt 0 ]; then |
if [ $debug -gt 0 ]; then |
104 |
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 |
105 |
fi |
fi |
106 |
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 |
107 |
lncnt=`wc -l tmp2.txt | awk '{print $1}' ` |
lncnt=`wc -l tmp2.txt | awk '{print $1}' ` |
108 |
if [ $lncnt -lt 3 ]; then |
if [ $lncnt -lt 3 ]; then |
109 |
if [ $verbose -gt 0 ]; then |
if [ $verbose -gt 0 ]; then |
118 |
if [ $debug -gt 0 ]; then |
if [ $debug -gt 0 ]; then |
119 |
echo testoutput_for_prop: compare_lines 1>&2 |
echo testoutput_for_prop: compare_lines 1>&2 |
120 |
fi |
fi |
121 |
compare_lines |
if [ $verbose -gt 1 ]; then |
122 |
digits_of_similarity=$? |
cat tmp3.txt 1>&2 |
123 |
|
fi |
124 |
|
echo "-1" >> tmp3.txt |
125 |
|
# On the SGI O3K (*not* the O2K), "cat -n" inserts a ":" after the line number |
126 |
|
cat tmp3.txt | sed -e 's|:||g' > tmp4.txt |
127 |
|
digits_of_similarity=`./tmp_cmpnum < tmp4.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 |
135 |
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 |
136 |
fi |
fi |
137 |
fi |
fi |
138 |
rm tmp1.txt tmp2.txt tmp3.txt |
rm -f tmp1.txt tmp2.txt tmp3.txt tmp4.txt |
139 |
|
|
140 |
return $digits_of_similarity |
return $digits_of_similarity |
141 |
} |
} |
155 |
done |
done |
156 |
} |
} |
157 |
|
|
158 |
|
testoutput_ad() |
159 |
|
{ |
160 |
|
grep $3 $1/results_ad/output.txt_adm | awk '{print NR " " $5}' > t05.txt |
161 |
|
grep $3 $1/$2/output.txt_adm | awk '{print NR " " $5}' > t15.txt |
162 |
|
grep $3 $1/results_ad/output.txt_adm | awk '{print NR " " $6}' > t06.txt |
163 |
|
grep $3 $1/$2/output.txt_adm | awk '{print NR " " $6}' > t16.txt |
164 |
|
join t05.txt t15.txt > t5.txt |
165 |
|
join t06.txt t16.txt > t6.txt |
166 |
|
echo "-1" >> t5.txt |
167 |
|
echo "-1" >> t6.txt |
168 |
|
digits_5=`./tmp_cmpnum < t5.txt` |
169 |
|
digits_6=`./tmp_cmpnum < t6.txt` |
170 |
|
dashnum $digits_5 $digits_6 |
171 |
|
rm -f t[01][56].txt t[56].txt |
172 |
|
} |
173 |
|
|
174 |
testoutput() |
testoutput() |
175 |
{ |
{ |
176 |
# testoutput diretory subdir |
# testoutput directory subdir extension |
177 |
# |
# |
178 |
# test output in "directory" |
# test output in "directory" |
179 |
|
if test "x$ADM" = x ; then |
180 |
if [ $debug -gt 0 ]; then |
if [ $debug -gt 0 ]; then |
181 |
echo testoutput: testoutput_for_prop $1 cg2d_init_res 1>&2 |
echo testoutput: testoutput_for_prop $1 cg2d_init_res 1>&2 |
182 |
fi |
fi |
183 |
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=$? |
184 |
if [ $debug -gt 0 ]; then |
if [ $debug -gt 0 ]; then |
185 |
echo testoutput: cg2dres=$cg2dres 1>&2 |
echo testoutput: cg2dres=$cg2dres 1>&2 |
186 |
|
fi |
187 |
|
testoutput_for_prop $1 "dynstat_theta_min" "theta minimum" $2 $3; tmin=$? |
188 |
|
testoutput_for_prop $1 "dynstat_theta_max" "theta maximum" $2 $3; tmax=$? |
189 |
|
testoutput_for_prop $1 "dynstat_theta_mean" "theta mean" $2 $3; tmean=$? |
190 |
|
testoutput_for_prop $1 "dynstat_theta_sd" "theta s.d." $2 $3; tsd=$? |
191 |
|
testoutput_for_prop $1 "dynstat_salt_min" "salt minimum" $2 $3; smin=$? |
192 |
|
testoutput_for_prop $1 "dynstat_salt_max" "salt maximum" $2 $3; smax=$? |
193 |
|
testoutput_for_prop $1 "dynstat_salt_mean" "salt mean" $2 $3; smean=$? |
194 |
|
testoutput_for_prop $1 "dynstat_salt_sd" "salt s.d." $2 $3; ssd=$? |
195 |
|
testoutput_for_prop $1 "dynstat_uvel_min" "U minimum" $2 $3; umin=$? |
196 |
|
testoutput_for_prop $1 "dynstat_uvel_max" "U maximum" $2 $3; umax=$? |
197 |
|
testoutput_for_prop $1 "dynstat_uvel_mean" "U mean" $2 $3; umean=$? |
198 |
|
testoutput_for_prop $1 "dynstat_uvel_sd" "U s.d." $2 $3; usd=$? |
199 |
|
testoutput_for_prop $1 "dynstat_vvel_min" "V minimum" $2 $3; vmin=$? |
200 |
|
testoutput_for_prop $1 "dynstat_vvel_max" "V maximum" $2 $3; vmax=$? |
201 |
|
testoutput_for_prop $1 "dynstat_vvel_mean" "V mean" $2 $3; vmean=$? |
202 |
|
testoutput_for_prop $1 "dynstat_vvel_sd" "V s.d." $2 $3; vsd=$? |
203 |
|
dashnum $cg2dres $tmin $tmax $tmean $tsd $smin $smax $smean $ssd \ |
204 |
|
$umin $umax $umean $usd $vmin $vmax $vmean $vsd |
205 |
|
else |
206 |
|
testoutput_ad $1 $2 "precision_grdchk_result" |
207 |
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 |
|
208 |
} |
} |
209 |
|
|
210 |
genmakemodel() |
genmakemodel() |
213 |
if test "x$NOGENMAKE" = xt ; then |
if test "x$NOGENMAKE" = xt ; then |
214 |
echo "genmake skipped!" |
echo "genmake skipped!" |
215 |
else |
else |
216 |
GENMAKE2="$BASH ../../../tools/genmake2" |
if test "x$BASH" = x ; then |
217 |
|
GENMAKE2="../../../tools/genmake2" |
218 |
|
else |
219 |
|
GENMAKE2="$BASH ../../../tools/genmake2 -bash $BASH" |
220 |
|
fi |
221 |
( |
( |
222 |
cd $1; |
cd $1; |
223 |
command="$GENMAKE2 -ds -m $MAKE --mods=../code" |
command="$GENMAKE2 -ds -m $MAKE" |
224 |
|
if test "x$ADM" = x ; then |
225 |
|
command="$command --mods=../code" |
226 |
|
else |
227 |
|
command="$command --mods=../code_ad" |
228 |
|
command="$command -adof=../../../tools/adjoint_options/adjoint_staf" |
229 |
|
fi |
230 |
if test "x$OPTFILE" != xNONE ; then |
if test "x$OPTFILE" != xNONE ; then |
231 |
command="$command --optfile=$OPTFILE" |
command="$command --optfile=$OPTFILE" |
|
# echo " command=\"$command\"" |
|
232 |
fi |
fi |
233 |
if test "x$IEEE" != x ; then |
if test "x$IEEE" != x ; then |
234 |
command="$command -ieee" |
command="$command -ieee" |
235 |
fi |
fi |
|
# echo "command: \"$command\"" |
|
236 |
printf 'genmake ... ' 1>&2 |
printf 'genmake ... ' 1>&2 |
237 |
$command > make.log 2>&1 |
$command > make.log 2>&1 |
238 |
RETVAL=$? |
RETVAL=$? |
239 |
for i in genmake_state genmake_optfile genmake_local Makefile ; do |
# Reduce the size of the testing emails! |
240 |
if test -r $i ; then |
head -100 Makefile > $CDIR/Makefile_head |
|
cp $i $CDIR |
|
|
fi |
|
|
done |
|
241 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
242 |
tail make.log |
tail make.log |
243 |
echo "genmakemodel: genmake failed" 1>&2 |
echo "genmakemodel: genmake failed" 1>&2 |
244 |
cp make.log $CDIR |
cp genmake_* make.log $CDIR |
245 |
return 1 |
return 1 |
246 |
else |
else |
247 |
echo "successful" 1>&2 |
echo "successful" 1>&2 |
308 |
cd $1; |
cd $1; |
309 |
if test -r Makefile ; then |
if test -r Makefile ; then |
310 |
printf 'make ... ' 1>&2 |
printf 'make ... ' 1>&2 |
311 |
$MAKE >> make.log 2>&1 |
if test "x$ADM" = x ; then |
312 |
|
if test "x$JOBS" = x ; then |
313 |
|
$MAKE >> make.log 2>&1 |
314 |
|
else |
315 |
|
$MAKE -j $JOBS >> make.log 2>&1 |
316 |
|
fi |
317 |
|
else |
318 |
|
$MAKE adall >> make.log 2>&1 |
319 |
|
fi |
320 |
RETVAL=$? |
RETVAL=$? |
321 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
322 |
tail make.log |
tail make.log |
330 |
) |
) |
331 |
} |
} |
332 |
|
|
333 |
|
symlink_mpifiles() |
334 |
|
{ |
335 |
|
# Put special links so that MPI specific files are used |
336 |
|
# This MUST be invoked between makeclean and makelinks because |
337 |
|
# the Makefile will link to non-mpi files by default |
338 |
|
|
339 |
|
dir=$1 |
340 |
|
code_dir=$2 |
341 |
|
BUILD_DIR=$dir/$3 |
342 |
|
CODE_DIR=$dir/$code_dir |
343 |
|
|
344 |
|
# These are files that should replace their counter-part when using -mpi |
345 |
|
MPI_FILES=`(cd $CODE_DIR; find . -name "*_mpi")` |
346 |
|
|
347 |
|
# Is this an MPI run? |
348 |
|
if test "x$MPI" = xt ; then |
349 |
|
# YES: We symbolically link these files to the build |
350 |
|
# dir so long as there is no real file in place |
351 |
|
for ii in $MPI_FILES ; do |
352 |
|
i=`echo $ii | sed 's:^\./::'` |
353 |
|
name=`echo $i | sed 's:_mpi::' ` |
354 |
|
cmp $CODE_DIR/$i $BUILD_DIR/$name > /dev/null 2>&1 |
355 |
|
RETVAL=$? |
356 |
|
if test "x$RETVAL" != x0 ; then |
357 |
|
if ! test -f $BUILD_DIR/$i ; then |
358 |
|
#echo Linking $name to $i |
359 |
|
(cd $BUILD_DIR; ln -sf ../$code_dir/$i $name) |
360 |
|
fi |
361 |
|
fi |
362 |
|
done |
363 |
|
else |
364 |
|
# NO: We undo any _mpi symbolically linked files |
365 |
|
for ii in $MPI_FILES ; do |
366 |
|
i=`echo $ii | sed 's:^\./::'` |
367 |
|
name=`echo $i | sed 's:_mpi::' ` |
368 |
|
if test -L $BUILD_DIR/$name ; then |
369 |
|
cmp $BUILD_DIR/$name "../$code_dir/$name"_mpi > /dev/null 2>&1 |
370 |
|
RETVAL=$? |
371 |
|
if test "x$RETVAL" = x0 ; then |
372 |
|
#echo Un-linking $name from $linktarg |
373 |
|
rm -f $BUILD_DIR/$name |
374 |
|
fi |
375 |
|
fi |
376 |
|
done |
377 |
|
fi |
378 |
|
|
379 |
|
} |
380 |
|
|
381 |
linkdata() |
linkdata() |
382 |
{ |
{ |
383 |
# linkdata flag |
# linkdata flag |
386 |
if test "x$1" = x1 ; then |
if test "x$1" = x1 ; then |
387 |
( |
( |
388 |
cd $2 |
cd $2 |
389 |
files=`( cd ../input ; ls -1 | grep -v CVS )` |
if test "x$ADM" = x ; then |
390 |
for i in $files ; do |
files=`( cd ../input ; ls -1 | grep -v CVS )` |
391 |
if test ! -d "../input/"$i ; then |
for i in $files ; do |
392 |
ln -sf "../input/"$i $i |
if test ! -d "../input/"$i ; then |
393 |
fi |
ln -sf "../input/"$i $i |
394 |
done |
fi |
395 |
|
done |
396 |
|
else |
397 |
|
files=`( cd ../input ; ls -1 *.bin | grep -v CVS )` |
398 |
|
for i in $files ; do |
399 |
|
if test ! -d "../input/"$i ; then |
400 |
|
ln -sf "../input/"$i $i |
401 |
|
fi |
402 |
|
done |
403 |
|
files=`( cd ../input_ad ; ls -1 | grep -v CVS )` |
404 |
|
for i in $files ; do |
405 |
|
if test ! -d "../input_ad/"$i ; then |
406 |
|
ln -sf "../input_ad/"$i $i |
407 |
|
fi |
408 |
|
done |
409 |
|
fi |
410 |
) |
) |
411 |
fi |
fi |
412 |
} |
} |
415 |
{ |
{ |
416 |
# runmodel directory |
# runmodel directory |
417 |
# |
# |
418 |
# runs "$COMMAND" in "directory" |
# runs "$COMMAND in "directory" |
419 |
# (where "$COMMAND" is relative to "directory") |
# (where "$COMMAND" is relative to "directory") |
420 |
( |
( |
421 |
cd $1 |
cd $1 |
422 |
printf 'runmodel ... ' 1>&2 |
printf 'runmodel ... ' 1>&2 |
423 |
# make output.txt |
# make output.txt |
424 |
$COMMAND >> run.log 2>&1 |
echo |
425 |
|
rm -f run.log |
426 |
|
# echo "COMMAND='$COMMAND'" |
427 |
|
# echo "pwd='"`pwd`"'" |
428 |
|
( eval $COMMAND ) > run.log 2>&1 |
429 |
RETVAL=$? |
RETVAL=$? |
430 |
if test "x$RETVAL" = x0 ; then |
if test "x$RETVAL" = x0 ; then |
431 |
|
tail run.log |
432 |
echo successful 1>&2 |
echo successful 1>&2 |
433 |
cp output.txt $CDIR"/output.txt" |
# === Reduce the size of the testing emails! |
434 |
|
# if test "x$ADM" = x ; then |
435 |
|
# cp output.txt $CDIR"/output.txt" |
436 |
|
# else |
437 |
|
# cp output.txt_adm $CDIR"/output.txt_adm" |
438 |
|
# fi |
439 |
|
if test -s STDERR.0000 ; then cp STDERR.0000 $CDIR"/STDERR.0000" ; fi |
440 |
return 0 |
return 0 |
441 |
else |
else |
442 |
tail run.log |
tail run.log |
443 |
echo failed 1>&2 |
echo failed 1>&2 |
444 |
cp run.log $CDIR"/run.log" |
cp run.log $CDIR"/run.log" |
445 |
|
if test -s STDERR.0000 ; then cp STDERR.0000 $CDIR"/STDERR.0000" ; fi |
446 |
return 1 |
return 1 |
447 |
fi |
fi |
448 |
) |
) |
452 |
{ |
{ |
453 |
# create codelet for comparing model output |
# create codelet for comparing model output |
454 |
|
|
455 |
echo -n "creating the comparison code... " |
printf "creating the comparison code... " |
456 |
cat > tmp_cmpnum.f <<EOFA |
cat > tmp_cmpnum.c <<EOF |
457 |
program cmpnum |
#include <stdio.h> |
458 |
implicit none |
#include <math.h> |
459 |
real*8 a,b,diff |
int main( int argc, char** argv ) { |
460 |
integer linnum,best |
int linnum,best,lncnt; |
461 |
best=-16 |
double a,b,diff; |
462 |
99 read(*,*,end=70,err=60) linnum,a,b |
best = -16; |
463 |
diff=0.5*(abs(a)+abs(b)) |
lncnt = 0; |
464 |
c print *,a,b,diff,abs(a-b)/diff |
while( 1 & (lncnt+=1) < 999 ) { |
465 |
if (diff.gt.1.e-12) then |
scanf("%d", &linnum); |
466 |
diff=abs(a-b)/diff |
if (linnum == -1) break; |
467 |
if (diff.gt.0.) then |
scanf("%lf", &a); scanf("%lf", &b); |
468 |
c print *,int(log10(diff)),diff |
diff = 0.5*(fabs(a)+fabs(b)); |
469 |
linnum=int(log10(diff)) |
if (diff > 1.e-12) { |
470 |
best=max(best,linnum) |
diff=fabs(a-b)/diff; |
471 |
endif |
if (diff > 0.0) { |
472 |
else |
linnum = (int)log10(diff); |
473 |
if (best.eq.-16.and.diff.ne.0.) best=-22 |
best = (best > linnum) ? best : linnum; |
474 |
endif |
} |
475 |
goto 99 |
else { |
476 |
60 stop 'cmpnum: An error occured reading a,b' |
if (best == -16 && diff != 0) best = -22; |
477 |
70 print *,-best |
} |
478 |
end |
} |
479 |
EOFA |
} |
480 |
|
if (lncnt == 999) best=-29; |
481 |
|
printf("%d\n", -best); |
482 |
|
return 0; |
483 |
|
} |
484 |
|
EOF |
485 |
|
cc -o tmp_cmpnum tmp_cmpnum.c -lm |
486 |
|
|
487 |
f77 tmp_cmpnum.f |
if [ -x ./tmp_cmpnum ]; then |
|
if [ -x ./a.out ]; then |
|
488 |
echo "OK" |
echo "OK" |
489 |
return 0 |
return 0 |
490 |
else |
else |
491 |
echo |
echo |
492 |
echo "createcodelet: failed to compile codelet" |
echo "ERROR: failed to compile comparison code" |
493 |
exit 1 |
exit 1 |
494 |
fi |
fi |
495 |
} |
} |
549 |
|
|
550 |
|
|
551 |
############################################################################### |
############################################################################### |
|
############################################################################### |
|
|
############################################################################### |
|
552 |
|
|
553 |
|
|
554 |
# Default properties |
# Default properties |
558 |
expts='' |
expts='' |
559 |
# ieee=1 |
# ieee=1 |
560 |
|
|
561 |
IEEE= |
IEEE=true |
562 |
if test "x$MITGCM_IEEE" != x ; then |
if test "x$MITGCM_IEEE" != x ; then |
563 |
IEEE=$MITGCM_IEEE |
IEEE=$MITGCM_IEEE |
564 |
fi |
fi |
577 |
MPACKDIR="../tools/mpack-1.6" |
MPACKDIR="../tools/mpack-1.6" |
578 |
HAVE_MPACK= |
HAVE_MPACK= |
579 |
MPACK="$MPACKDIR/mpack" |
MPACK="$MPACKDIR/mpack" |
580 |
COMMAND="make output.txt" |
COMMAND= |
581 |
MAKE=make |
MAKE=make |
582 |
|
JOBS= |
583 |
MPI=f |
MPI=f |
584 |
|
DELDIR= |
585 |
|
|
586 |
echo -n "parsing options... " |
ADM= |
587 |
|
|
588 |
|
printf "parsing options... " |
589 |
|
|
590 |
ac_prev= |
ac_prev= |
591 |
for ac_option ; do |
for ac_option ; do |
634 |
-make=* | --make=*) |
-make=* | --make=*) |
635 |
MAKE=$ac_optarg ;; |
MAKE=$ac_optarg ;; |
636 |
|
|
637 |
|
-j) ac_prev=JOBS ;; |
638 |
|
-j=*) JOBS=$ac_optarg ;; |
639 |
|
|
640 |
-clean | --clean) |
-clean | --clean) |
641 |
CLEANUP=t ;; |
CLEANUP=t ;; |
642 |
|
|
651 |
|
|
652 |
-mpi) MPI=t ;; |
-mpi) MPI=t ;; |
653 |
|
|
654 |
|
-adm | -ad) ADM=t ;; |
655 |
|
|
656 |
-ieee) IEEE=true ;; |
-ieee) IEEE=true ;; |
657 |
-noieee) IEEE= ;; |
-noieee) IEEE= ;; |
658 |
|
|
660 |
-debug) debug=1 ;; |
-debug) debug=1 ;; |
661 |
-quiet) verbose=0 ;; |
-quiet) verbose=0 ;; |
662 |
|
|
663 |
|
-deldir | -dd) DELDIR=t ;; |
664 |
|
|
665 |
-*) |
-*) |
666 |
echo "Error: unrecognized option: "$ac_option |
echo "Error: unrecognized option: "$ac_option |
667 |
usage |
usage |
690 |
OPTFILE=$MITGCM_OF |
OPTFILE=$MITGCM_OF |
691 |
fi |
fi |
692 |
|
|
693 |
|
if test "x$ADM" = xt -a "x$COMMAND" = x ; then |
694 |
|
COMMAND="./mitgcmuv_ad > output.txt_adm 2>&1" |
695 |
|
fi |
696 |
|
|
697 |
|
if test "x$COMMAND" = x ; then |
698 |
|
COMMAND="$MAKE output.txt" |
699 |
|
fi |
700 |
|
|
701 |
echo "OK" |
echo "OK" |
702 |
|
|
703 |
# create the FORTRAN comparison code |
# create the FORTRAN comparison code |
704 |
createcodelet |
createcodelet |
705 |
|
|
706 |
# build the mpack utility |
# build the mpack utility |
707 |
build_mpack |
if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then |
708 |
|
echo "skipping mpack build" |
709 |
|
else |
710 |
|
build_mpack |
711 |
|
fi |
712 |
|
|
713 |
# Create a uniquely named directory to store results |
# Create a uniquely named directory to store results |
714 |
MACH=`hostname` |
MACH=`hostname` |
715 |
UNAMEA=`uname -a` |
UNAMEA=`uname -a` |
716 |
DATE=`date +%Y%m%d` |
DATE=`date +%Y%m%d` |
717 |
BASE=$MACH"_"$DATE"_" |
BASE="tr_"$MACH"_"$DATE"_" |
718 |
DNUM=0 |
DNUM=0 |
719 |
DRESULTS="$BASE$DNUM" |
DRESULTS="$BASE$DNUM" |
720 |
while test -e $DRESULTS ; do |
while test -e $DRESULTS ; do |
728 |
exit 1 |
exit 1 |
729 |
fi |
fi |
730 |
SUMMARY="$DRESULTS/summary.txt" |
SUMMARY="$DRESULTS/summary.txt" |
731 |
echo -n "Start time: " >> $SUMMARY |
printf "Start time: " >> $SUMMARY |
732 |
start_date=`date` |
start_date=`date` |
733 |
echo $start_date > $SUMMARY |
echo $start_date > $SUMMARY |
|
cat << EOF | tee -a $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 |
|
734 |
|
|
735 |
of_path= |
of_path= |
736 |
if test "x$OPTFILE" != xNONE ; then |
if test "x$OPTFILE" != xNONE ; then |
744 |
fi |
fi |
745 |
file=${OPTFILE##*/} |
file=${OPTFILE##*/} |
746 |
OPTFILE=$of_path/$file |
OPTFILE=$of_path/$file |
747 |
|
cp $OPTFILE $DRESULTS |
748 |
|
echo >> $SUMMARY |
749 |
|
echo " OPTFILE=$OPTFILE" >> $SUMMARY |
750 |
else |
else |
751 |
echo |
echo | tee $SUMMARY |
752 |
echo "WARNING: can't read OPTFILE=\"$OPTFILE\" but will try to use it..." |
echo "ERROR: can't read OPTFILE=\"$OPTFILE\"" | tee $SUMMARY |
753 |
|
exit 1 |
754 |
fi |
fi |
755 |
|
else |
756 |
|
echo >> $SUMMARY |
757 |
|
echo "No \"OPTFILE\" was explicitly specified by testreport," >> $SUMMARY |
758 |
|
echo " so the genmake default will be used." >> $SUMMARY |
759 |
fi |
fi |
760 |
echo |
echo |
|
echo "OPTFILE=$OPTFILE" >> $SUMMARY |
|
761 |
echo >> $SUMMARY |
echo >> $SUMMARY |
762 |
|
if test "x$ADM" = x ; then |
763 |
|
cat << EOF | tee -a $SUMMARY |
764 |
|
T S U V |
765 |
|
G D M c m s m s m s m s |
766 |
|
E p a R g m m e . m m e . m m e . m m e . |
767 |
|
N n k u 2 i a a d i a a d i a a d i a a d |
768 |
|
2 d e n d n x n . n x n . n x n . n x n . |
769 |
|
|
770 |
|
EOF |
771 |
|
else |
772 |
|
echo "ADJOINT=true" >> $SUMMARY |
773 |
|
echo >> $SUMMARY |
774 |
|
cat << EOF | tee -a $SUMMARY |
775 |
|
G D M C G |
776 |
|
E p a R o r |
777 |
|
N n k u s a |
778 |
|
2 d e n t d |
779 |
|
|
780 |
|
EOF |
781 |
|
fi |
782 |
|
|
783 |
# ...and each test directory... |
# ...and each test directory... |
784 |
for dir in $TESTDIRS ; do |
for dir in $TESTDIRS ; do |
796 |
|
|
797 |
# Verify that the testdir exists and contains previous |
# Verify that the testdir exists and contains previous |
798 |
# results in the correct location--or skip this directory! |
# results in the correct location--or skip this directory! |
799 |
if test ! -r $dir"/results/output.txt" ; then |
fout= |
800 |
echo "can't read \"$dir/results/output.txt\" -- skipping $dir" |
if test "x$ADM" = x ; then |
801 |
|
fout=$dir"/results/output.txt" |
802 |
|
else |
803 |
|
fout=$dir"/results_ad/output.txt_adm" |
804 |
|
fi |
805 |
|
if test ! -r $fout ; then |
806 |
|
echo "can't read \"$fout\" -- skipping $dir" |
807 |
continue |
continue |
808 |
fi |
fi |
809 |
|
|
|
echo "-------------------------------------------------------------------------------" |
|
|
echo |
|
|
echo "Experiment: $dir" |
|
|
echo |
|
|
unset genmake makedepend make run |
|
|
results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --' |
|
|
|
|
810 |
builddir="input" |
builddir="input" |
811 |
rundir="input" |
rundir="input" |
812 |
use_seperate_build=0 |
use_seperate_build=0 |
817 |
linkdata $use_seperate_build $dir/$rundir |
linkdata $use_seperate_build $dir/$rundir |
818 |
fi |
fi |
819 |
|
|
820 |
CODE_DIR=$dir/code |
# Check whether there are "extra runs" for this testdir |
821 |
BUILD_DIR=$dir/$builddir |
extra_runs= |
822 |
MPI_FILES="CPP_EEOPTIONS.h_mpi SIZE.h_mpi" |
if test "x$ADM" = x -a "x$use_seperate_build" = x1 ; then |
823 |
NOMPI_FILES="CPP_EEOPTIONS.h_nompi SIZE.h_nompi" |
ex_run_dirs=`( cd $dir ; echo input.* )` |
824 |
|
echo "ex_run_dirs='$ex_run_dirs'" |
825 |
|
for exd in $ex_run_dirs ; do |
826 |
|
name=`echo $exd | sed -e 's/input.//g'` |
827 |
|
outf="$dir/results/output.txt.$name" |
828 |
|
if test -f $outf -a -r $outf ; then |
829 |
|
extra_runs="$extra_runs $name" |
830 |
|
fi |
831 |
|
done |
832 |
|
fi |
833 |
|
|
834 |
# Is this an MPI run? |
if test "x$ADM" = x ; then |
835 |
if test "x$MPI" = xt ; then |
code_dir=code |
836 |
FILES=$MPI_FILES |
CODE_DIR=$dir/code |
|
endings="_mpi" |
|
837 |
else |
else |
838 |
FILES=$NOMPI_FILES |
code_dir=code_ad |
839 |
endings="_nompi" |
CODE_DIR=$dir/code_ad |
840 |
fi |
fi |
841 |
|
BUILD_DIR=$dir/$builddir |
842 |
# Check to see that we have the files |
|
843 |
have_files=t |
if test ! -r $CODE_DIR"/SIZE.h_mpi" -a "x$MPI" = "xt" ; then |
844 |
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)" |
|
845 |
continue |
continue |
846 |
fi |
fi |
847 |
|
|
848 |
# If we have the $FILES and they differ, copy the $FILES to $BUILD_DIR |
echo "-------------------------------------------------------------------------------" |
849 |
if test "x$have_files" = xt ; then |
echo |
850 |
for i in $FILES ; do |
echo "Experiment: $dir" |
851 |
sstr="s|$endings||" |
echo |
852 |
name=`echo $i | sed -e $sstr ` |
unset genmake makedepend make run |
853 |
cmp $CODE_DIR/$i $BUILD_DIR/$name > /dev/null 2>&1 |
results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --' |
854 |
RETVAL=$? |
|
|
if test "x$RETVAL" != x0 ; then |
|
|
cp $CODE_DIR/$i $BUILD_DIR/$name |
|
|
fi |
|
|
done |
|
|
fi |
|
|
|
|
855 |
# Create an output dir for each OPTFILE/tdir combination |
# Create an output dir for each OPTFILE/tdir combination |
856 |
rel_CDIR=$DRESULTS"/"$dir |
rel_CDIR=$DRESULTS"/"$dir |
857 |
mkdir $rel_CDIR |
mkdir $rel_CDIR |
862 |
else |
else |
863 |
genmakemodel $dir/$builddir && genmake=Y \ |
genmakemodel $dir/$builddir && genmake=Y \ |
864 |
&& makeclean $dir/$builddir \ |
&& makeclean $dir/$builddir \ |
865 |
|
&& symlink_mpifiles $dir $code_dir $builddir \ |
866 |
&& makedependmodel $dir/$builddir && makedepend=Y \ |
&& makedependmodel $dir/$builddir && makedepend=Y \ |
867 |
&& makemodel $dir/$builddir && make=Y \ |
&& makemodel $dir/$builddir && make=Y \ |
868 |
&& linkdata $use_seperate_build $dir/$rundir \ |
&& linkdata $use_seperate_build $dir/$rundir \ |
871 |
fi |
fi |
872 |
|
|
873 |
echo |
echo |
874 |
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
if test "x$ADM" = x ; then |
875 |
${run:-N} $results |
fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results` |
876 |
echo |
echo |
877 |
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
echo "$fres" >> $SUMMARY |
878 |
${run:-N} $results >> $SUMMARY |
echo "fresults='$fres'" > $CDIR"/summary.txt" |
879 |
echo "fresults='" > $CDIR"/summary.txt" |
echo "MACH='$MACH'" >> $CDIR"/summary.txt" |
880 |
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt" |
881 |
${run:-N} $results >> $CDIR"/summary.txt" |
echo "DATE='$DATE'" >> $CDIR"/summary.txt" |
882 |
echo "'" >> $CDIR"/summary.txt" |
echo "tdir='$dir'" >> $CDIR"/summary.txt" |
883 |
echo "MACH='$MACH'" >> $CDIR"/summary.txt" |
|
884 |
echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt" |
OLD_COMMAND=$COMMAND |
885 |
echo "DATE='$DATE'" >> $CDIR"/summary.txt" |
COMMAND="./mitgcmuv > output.txt" |
886 |
echo "tdir='$dir'" >> $CDIR"/summary.txt" |
for ex in $extra_runs ; do |
887 |
|
test -e "$dir/tr_run.$ex" && rm -rf "$dir/tr_run.$ex" |
888 |
|
mkdir "$dir/tr_run.$ex" |
889 |
|
links=`( cd "$dir/input" > /dev/null 2>&1 ; ls -1 | grep -v CVS )` |
890 |
|
( |
891 |
|
cd "$dir/tr_run.$ex" |
892 |
|
for i in $links; do |
893 |
|
ln -s ../input/$i $i |
894 |
|
done |
895 |
|
) |
896 |
|
links=`( cd "$dir/input.$ex" > /dev/null 2>&1 ; ls -1 | grep -v CVS )` |
897 |
|
( |
898 |
|
cd "$dir/tr_run.$ex" |
899 |
|
for i in $links; do |
900 |
|
test -e $i && rm -f $i |
901 |
|
ln -s ../input.$ex/$i $i |
902 |
|
done |
903 |
|
ln -s ../$builddir/mitgcmuv mitgcmuv |
904 |
|
) |
905 |
|
runmodel $dir/tr_run.$ex && run=Y \ |
906 |
|
&& results=`testoutput $dir tr_run.$ex "."$ex` |
907 |
|
fres=`printf '%s %s %s %s' ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N}` |
908 |
|
fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results` |
909 |
|
fres="$fres.$ex" |
910 |
|
echo |
911 |
|
echo "$fres" >> $SUMMARY |
912 |
|
echo "fresults='$fres'" > $CDIR"/summary.txt" |
913 |
|
echo "MACH='$MACH'" >> $CDIR"/summary.txt" |
914 |
|
echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt" |
915 |
|
echo "DATE='$DATE'" >> $CDIR"/summary.txt" |
916 |
|
echo "tdir='$dir'" >> $CDIR"/summary.txt" |
917 |
|
done |
918 |
|
COMMAND=$OLD_COMMAND |
919 |
|
else |
920 |
|
fres=`printf '%s %s %s %s' ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N}` |
921 |
|
fres=$fres"$results $dir" |
922 |
|
echo |
923 |
|
echo "$fres" >> $SUMMARY |
924 |
|
echo "fresults='$fres'" > $CDIR"/summary.txt" |
925 |
|
echo "MACH='$MACH'" >> $CDIR"/summary.txt" |
926 |
|
echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt" |
927 |
|
echo "DATE='$DATE'" >> $CDIR"/summary.txt" |
928 |
|
echo "tdir='$dir'" >> $CDIR"/summary.txt" |
929 |
|
fi |
930 |
|
|
931 |
echo "-------------------------------------------------------------------------------" |
echo "-------------------------------------------------------------------------------" |
932 |
|
|
|
NDIR=$(( $NDIR + 1 )) |
|
|
|
|
933 |
done |
done |
934 |
|
|
935 |
echo -n "Start time: " >> $SUMMARY |
printf "Start time: " >> $SUMMARY |
936 |
echo $start_date >> $SUMMARY |
echo $start_date >> $SUMMARY |
937 |
echo -n "End time: " >> $SUMMARY |
printf "End time: " >> $SUMMARY |
938 |
date >> $SUMMARY |
date >> $SUMMARY |
939 |
|
|
940 |
# If addresses were supplied and mpack built successfully, then try |
# If addresses were supplied and mpack built successfully, then try |
945 |
if test "x$HAVE_MPACK" = xt ; then |
if test "x$HAVE_MPACK" = xt ; then |
946 |
tar -cf $DRESULTS".tar" $DRESULTS > /dev/null 2>&1 \ |
tar -cf $DRESULTS".tar" $DRESULTS > /dev/null 2>&1 \ |
947 |
&& gzip $DRESULTS".tar" \ |
&& gzip $DRESULTS".tar" \ |
948 |
&& $MPACK -s MITgcm-test -m 1500000 $DRESULTS".tar.gz" $ADDRESSES |
&& $MPACK -s MITgcm-test -m 3555000 $DRESULTS".tar.gz" $ADDRESSES |
949 |
RETVAL=$? |
RETVAL=$? |
950 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
951 |
echo |
echo |
964 |
fi |
fi |
965 |
fi |
fi |
966 |
|
|
967 |
rm tmp_cmpnum.f a.out |
# rm -f tmp_cmpnum.f a.out |
968 |
|
rm -f tmp_cmpnum.c tmp_cmpnum |
969 |
|
|
970 |
if test "x$CLEANUP" != xt ; then |
if test "x$CLEANUP" != xt ; then |
971 |
cat $SUMMARY |
cat $SUMMARY |
972 |
if test -e tr.out ; then |
if test -e tr_out.txt ; then |
973 |
mv tr.out tr.out.old |
mv tr_out.txt tr_out.txt.old |
974 |
fi |
fi |
975 |
cat $SUMMARY > tr.out |
cat $SUMMARY > tr_out.txt |
976 |
|
fi |
977 |
|
|
978 |
|
if test "x$DELDIR" = xt ; then |
979 |
|
rm -rf $DRESULTS |
980 |
fi |
fi |
981 |
|
|