1 |
#!/bin/bash |
#! /usr/bin/env bash |
2 |
# |
# |
3 |
# $Header$ |
# $Header$ |
4 |
|
# $Name$ |
5 |
# |
# |
6 |
|
|
7 |
usage() |
usage() |
11 |
echo |
echo |
12 |
echo "where possible OPTIONS are:" |
echo "where possible OPTIONS are:" |
13 |
echo " (-help|-h) print usage" |
echo " (-help|-h) print usage" |
14 |
echo " (-optfile=|-of=)STRING list of genmake2 \"optfiles\"" |
echo " (-mpi) use MPI input files" |
15 |
echo " (-a|-addr)STRING list of email recipients" |
echo " (-ieee|-noieee) if possible, use IEEE compiler flags" |
16 |
echo " (-t|-tdir)STRING list of \"test\" dirs" |
echo " (DEF=\"noieee\")" |
17 |
|
echo " (-optfile=|-of=)STRING list of optfiles to use" |
18 |
|
echo " (-a|-addr) STRING list of email recipients" |
19 |
|
echo " (DEF=\"edhill@mitgcm.org\")" |
20 |
|
echo " (-t|-tdir) STRING list of test dirs to use" |
21 |
|
echo " (DEF=\"\" which builds all)" |
22 |
|
echo " (-b|-bash) STRING preferred location of a \"bash\" or" |
23 |
|
echo " Bourne-compatible \"sh\" shell" |
24 |
|
echo " (DEF=\"\" for \"bash\")" |
25 |
|
echo " (-adm|-ad) perform an adjoint run" |
26 |
|
echo " (-command) STRING command to run" |
27 |
|
echo " (DEF=\"make output.txt\")" |
28 |
|
echo " (-m|-make) STRING command to use for \"make\"" |
29 |
|
echo " (DEF=\"make\")" |
30 |
|
echo " (-clean) *ONLY* run \"make CLEAN\"" |
31 |
|
echo " (-quick|-q) same as \"-nogenmake -noclean -nodepend\"" |
32 |
|
echo " (-nogenmake|-ng) skip the genmake stage" |
33 |
|
echo " (-noclean|-nc) skip the \"make clean\" stage" |
34 |
|
echo " (-nodepend|-nd) skip the \"make depend\" stage" |
35 |
|
echo |
36 |
|
echo "and where STRING follows a whitespace-delimited format" |
37 |
|
echo "such as:" |
38 |
|
echo " -t 'exp0 exp2 exp3' " |
39 |
|
echo " -addr='abc@123.com testing@home.org'" |
40 |
echo |
echo |
41 |
exit 1 |
exit 1 |
42 |
} |
} |
47 |
echo -n "building the mpack utility... " |
echo -n "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 |
fi |
57 |
echo -n "building mpack... " |
echo -n "building mpack... " |
58 |
( cd $MPACKDIR && ./configure && make ) > build_mpack.out 2>&1 |
( cd $MPACKDIR && ./configure && $MAKE ) > build_mpack.out 2>&1 |
59 |
RETVAL=$? |
RETVAL=$? |
60 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
61 |
echo |
echo |
62 |
echo "Error building the mpack tools at: $MPACK_DIR" |
echo "Error building the mpack tools at: $MPACK_DIR" |
63 |
exit 1 |
echo |
64 |
|
HAVE_MPACK=f |
65 |
|
else |
66 |
|
HAVE_MPACK=t |
67 |
fi |
fi |
68 |
|
else |
69 |
|
HAVE_MPACK=t |
70 |
fi |
fi |
71 |
echo "OK" |
echo "OK" |
72 |
} |
} |
73 |
|
|
|
compare_lines() |
|
|
{ |
|
|
# use codelet to compare lines |
|
|
if [ $verbose -gt 1 ]; then |
|
|
cat tmp3.txt 1>&2 |
|
|
fi |
|
|
return `./a.out < tmp3.txt` |
|
|
} |
|
|
|
|
74 |
testoutput_for_prop() |
testoutput_for_prop() |
75 |
{ |
{ |
76 |
# testoutput_for_prop dir s1 label subdir |
# testoutput_for_prop dir s1 label subdir |
82 |
echo testoutput_for_prop: grep "$2" $1/$4/output.txt 1>&2 |
echo testoutput_for_prop: grep "$2" $1/$4/output.txt 1>&2 |
83 |
fi |
fi |
84 |
if [ -r $1/$4/output.txt ]; then |
if [ -r $1/$4/output.txt ]; then |
85 |
grep "$2" $1/$4/output.txt | sed 's/.*=//' | nl > tmp1.txt |
grep "$2" $1/$4/output.txt | sed 's/.*=//' | cat -n > tmp1.txt |
86 |
lncnt=`wc -l tmp1.txt | awk '{print $1}' ` |
lncnt=`wc -l tmp1.txt | awk '{print $1}' ` |
87 |
if [ $lncnt -lt 3 ]; then |
if [ $lncnt -lt 3 ]; then |
88 |
if [ $verbose -gt 0 ]; then |
if [ $verbose -gt 0 ]; then |
97 |
if [ $debug -gt 0 ]; then |
if [ $debug -gt 0 ]; then |
98 |
echo testoutput_for_prop: grep "$2" $1/results/output.txt 1>&2 |
echo testoutput_for_prop: grep "$2" $1/results/output.txt 1>&2 |
99 |
fi |
fi |
100 |
grep "$2" $1/results/output.txt | sed 's/.*=//' | nl > tmp2.txt |
grep "$2" $1/results/output.txt | sed 's/.*=//' | cat -n > tmp2.txt |
101 |
lncnt=`wc -l tmp2.txt | awk '{print $1}' ` |
lncnt=`wc -l tmp2.txt | awk '{print $1}' ` |
102 |
if [ $lncnt -lt 3 ]; then |
if [ $lncnt -lt 3 ]; then |
103 |
if [ $verbose -gt 0 ]; then |
if [ $verbose -gt 0 ]; then |
112 |
if [ $debug -gt 0 ]; then |
if [ $debug -gt 0 ]; then |
113 |
echo testoutput_for_prop: compare_lines 1>&2 |
echo testoutput_for_prop: compare_lines 1>&2 |
114 |
fi |
fi |
115 |
compare_lines |
if [ $verbose -gt 1 ]; then |
116 |
digits_of_similarity=$? |
cat tmp3.txt 1>&2 |
117 |
|
fi |
118 |
|
echo "-1" >> tmp3.txt |
119 |
|
# On the SGI O3K (*not* the O2K), "cat -n" inserts a ":" after the line number |
120 |
|
cat tmp3.txt | sed -e 's|:||g' > tmp4.txt |
121 |
|
digits_of_similarity=`./tmp_cmpnum < tmp4.txt` |
122 |
if [ $digits_of_similarity -eq 99 ]; then |
if [ $digits_of_similarity -eq 99 ]; then |
123 |
if [ $verbose -gt 0 ]; then |
if [ $verbose -gt 0 ]; then |
124 |
echo testoutput_for_prop: No comparison was available for \"$2\" 1>&2 |
echo testoutput_for_prop: No comparison was available for \"$2\" 1>&2 |
129 |
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 |
130 |
fi |
fi |
131 |
fi |
fi |
132 |
rm tmp1.txt tmp2.txt tmp3.txt |
rm -f tmp1.txt tmp2.txt tmp3.txt tmp4.txt |
133 |
|
|
134 |
return $digits_of_similarity |
return $digits_of_similarity |
135 |
} |
} |
149 |
done |
done |
150 |
} |
} |
151 |
|
|
152 |
|
testoutput_ad() |
153 |
|
{ |
154 |
|
grep $3 $1/results_ad/output.txt_adm | awk '{print NR " " $5}' > t05.txt |
155 |
|
grep $3 $1/$2/output.txt_adm | awk '{print NR " " $5}' > t15.txt |
156 |
|
grep $3 $1/results_ad/output.txt_adm | awk '{print NR " " $6}' > t06.txt |
157 |
|
grep $3 $1/$2/output.txt_adm | awk '{print NR " " $6}' > t16.txt |
158 |
|
join t05.txt t15.txt > t5.txt |
159 |
|
join t06.txt t16.txt > t6.txt |
160 |
|
echo "-1" >> t5.txt |
161 |
|
echo "-1" >> t6.txt |
162 |
|
digits_5=`./tmp_cmpnum < t5.txt` |
163 |
|
digits_6=`./tmp_cmpnum < t6.txt` |
164 |
|
dashnum $digits_5 $digits_6 |
165 |
|
rm -f t[01][56].txt t[56].txt |
166 |
|
} |
167 |
|
|
168 |
testoutput() |
testoutput() |
169 |
{ |
{ |
170 |
# testoutput diretory subdir |
# testoutput directory subdir |
171 |
# |
# |
172 |
# test output in "directory" |
# test output in "directory" |
173 |
|
if test "x$ADM" = x ; then |
174 |
if [ $debug -gt 0 ]; then |
if [ $debug -gt 0 ]; then |
175 |
echo testoutput: testoutput_for_prop $1 cg2d_init_res 1>&2 |
echo testoutput: testoutput_for_prop $1 cg2d_init_res 1>&2 |
176 |
fi |
fi |
177 |
testoutput_for_prop $1 "cg2d_init_res" "cg2d init. residual" $2; cg2dres=$? |
testoutput_for_prop $1 "cg2d_init_res" "cg2d init. residual" $2; cg2dres=$? |
178 |
if [ $debug -gt 0 ]; then |
if [ $debug -gt 0 ]; then |
179 |
echo testoutput: cg2dres=$cg2dres 1>&2 |
echo testoutput: cg2dres=$cg2dres 1>&2 |
180 |
|
fi |
181 |
|
testoutput_for_prop $1 "dynstat_theta_min" "theta minimum" $2; tmin=$? |
182 |
|
testoutput_for_prop $1 "dynstat_theta_max" "theta maximum" $2; tmax=$? |
183 |
|
testoutput_for_prop $1 "dynstat_theta_mean" "theta mean" $2; tmean=$? |
184 |
|
testoutput_for_prop $1 "dynstat_theta_sd" "theta s.d." $2; tsd=$? |
185 |
|
testoutput_for_prop $1 "dynstat_salt_min" "salt minimum" $2; smin=$? |
186 |
|
testoutput_for_prop $1 "dynstat_salt_max" "salt maximum" $2; smax=$? |
187 |
|
testoutput_for_prop $1 "dynstat_salt_mean" "salt mean" $2; smean=$? |
188 |
|
testoutput_for_prop $1 "dynstat_salt_sd" "salt s.d." $2; ssd=$? |
189 |
|
testoutput_for_prop $1 "dynstat_uvel_min" "U minimum" $2; umin=$? |
190 |
|
testoutput_for_prop $1 "dynstat_uvel_max" "U maximum" $2; umax=$? |
191 |
|
testoutput_for_prop $1 "dynstat_uvel_mean" "U mean" $2; umean=$? |
192 |
|
testoutput_for_prop $1 "dynstat_uvel_sd" "U s.d." $2; usd=$? |
193 |
|
testoutput_for_prop $1 "dynstat_vvel_min" "V minimum" $2; vmin=$? |
194 |
|
testoutput_for_prop $1 "dynstat_vvel_max" "V maximum" $2; vmax=$? |
195 |
|
testoutput_for_prop $1 "dynstat_vvel_mean" "V mean" $2; vmean=$? |
196 |
|
testoutput_for_prop $1 "dynstat_vvel_sd" "V s.d." $2; vsd=$? |
197 |
|
dashnum $cg2dres $tmin $tmax $tmean $tsd $smin $smax $smean $ssd \ |
198 |
|
$umin $umax $umean $usd $vmin $vmax $vmean $vsd |
199 |
|
else |
200 |
|
testoutput_ad $1 $2 "precision_grdchk_result" |
201 |
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 |
|
202 |
} |
} |
203 |
|
|
204 |
genmakemodel() |
genmakemodel() |
205 |
{ |
{ |
206 |
# genmakemodel directory |
# genmakemodel directory |
207 |
GENMAKE2="../../../tools/genmake2" |
if test "x$NOGENMAKE" = xt ; then |
208 |
( |
echo "genmake skipped!" |
209 |
cd $1; |
else |
210 |
printf 'genmake ... ' 1>&2 |
GENMAKE2="$BASH ../../../tools/genmake2" |
211 |
# ../../../tools/genmake -ieee -mods=../code > make.log 2>&1 |
( |
212 |
$GENMAKE2 -ds --mods=../code "--optfile="$OPTFILE > make.log 2>&1 |
cd $1; |
213 |
RETVAL=$? |
command="$GENMAKE2 -ds -m $MAKE" |
214 |
for i in gm_state gm_optfile gm_local Makefile ; do |
if test "x$ADM" = x ; then |
215 |
if test -r $i ; then |
command="$command --mods=../code" |
216 |
cp $i $CDIR |
else |
217 |
|
command="$command --mods=../code_ad" |
218 |
|
command="$command -adof=../../../tools/adjoint_options/adjoint_staf" |
219 |
fi |
fi |
220 |
done |
if test "x$OPTFILE" != xNONE ; then |
221 |
if test "x$RETVAL" != x0 ; then |
command="$command --optfile=$OPTFILE" |
222 |
tail make.log |
fi |
223 |
echo "genmakemodel: genmake failed" 1>&2 |
if test "x$IEEE" != x ; then |
224 |
cp make.log $CDIR |
command="$command -ieee" |
225 |
return 1 |
fi |
226 |
else |
printf 'genmake ... ' 1>&2 |
227 |
echo "succesful" 1>&2 |
$command > make.log 2>&1 |
228 |
fi |
RETVAL=$? |
229 |
) |
cp Makefile $CDIR |
230 |
|
if test "x$RETVAL" != x0 ; then |
231 |
|
tail make.log |
232 |
|
echo "genmakemodel: genmake failed" 1>&2 |
233 |
|
cp genmake_* make.log $CDIR |
234 |
|
return 1 |
235 |
|
else |
236 |
|
echo "successful" 1>&2 |
237 |
|
fi |
238 |
|
) |
239 |
|
fi |
240 |
} |
} |
241 |
|
|
242 |
makeclean() |
makeclean() |
243 |
{ |
{ |
244 |
# makeclean directory |
# makeclean directory |
245 |
( |
if test "x$NOCLEAN" = xt ; then |
246 |
cd $1; |
echo "make CLEAN skipped!" |
247 |
rm -f output.txt |
else |
248 |
printf 'make CLEAN ... ' 2>&1 |
( |
249 |
if test -r Makefile ; then |
cd $1; |
250 |
make CLEAN >> make.log 2>&1 |
if test -e output.txt ; then |
251 |
RETVAL=$? |
rm -f output.txt |
|
if test "x$RETVAL" != x0 ; then |
|
|
tail make.log |
|
|
echo "makeclean: \"make CLEAN\" failed" 1>&2 |
|
|
cp make.log $CDIR"/make.log" |
|
|
return 1 |
|
252 |
fi |
fi |
253 |
fi |
printf 'make CLEAN ... ' 2>&1 |
254 |
echo succesful 1>&2 |
if test -r Makefile ; then |
255 |
exit 0 |
$MAKE CLEAN >> make.log 2>&1 |
256 |
) |
RETVAL=$? |
257 |
|
if test "x$RETVAL" != x0 ; then |
258 |
|
tail make.log |
259 |
|
echo "makeclean: \"make CLEAN\" failed" 1>&2 |
260 |
|
cp make.log $CDIR"/make.log" |
261 |
|
return 1 |
262 |
|
fi |
263 |
|
fi |
264 |
|
echo successful 1>&2 |
265 |
|
exit 0 |
266 |
|
) |
267 |
|
fi |
268 |
} |
} |
269 |
|
|
270 |
makedependmodel() |
makedependmodel() |
271 |
{ |
{ |
272 |
# makedependmodel directory |
# makedependmodel directory |
273 |
( |
if test "x$NODEPEND" = xt ; then |
274 |
cd $1; |
echo "make depend skipped!" |
275 |
printf 'make depend ... ' 1>&2 |
else |
276 |
make depend >> make.log 2>&1 |
( |
277 |
RETVAL=$? |
cd $1; |
278 |
if test "x$RETVAL" != x0 ; then |
printf 'make depend ... ' 1>&2 |
279 |
tail make.log |
$MAKE depend >> make.log 2>&1 |
280 |
echo "makedependmodel: make depend failed" 1>&2 |
RETVAL=$? |
281 |
cp make.log $CDIR"/make.log" |
if test "x$RETVAL" != x0 ; then |
282 |
return 1 |
tail make.log |
283 |
else |
echo "makedependmodel: make depend failed" 1>&2 |
284 |
echo succesful 1>&2 |
cp make.log $CDIR"/make.log" |
285 |
fi |
return 1 |
286 |
) |
else |
287 |
|
echo successful 1>&2 |
288 |
|
fi |
289 |
|
) |
290 |
|
fi |
291 |
} |
} |
292 |
|
|
293 |
makemodel() |
makemodel() |
297 |
cd $1; |
cd $1; |
298 |
if test -r Makefile ; then |
if test -r Makefile ; then |
299 |
printf 'make ... ' 1>&2 |
printf 'make ... ' 1>&2 |
300 |
make >> make.log 2>&1 |
if test "x$ADM" = x ; then |
301 |
|
$MAKE >> make.log 2>&1 |
302 |
|
else |
303 |
|
$MAKE adall >> make.log 2>&1 |
304 |
|
fi |
305 |
RETVAL=$? |
RETVAL=$? |
306 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
307 |
tail make.log |
tail make.log |
309 |
cp make.log $CDIR"/make.log" |
cp make.log $CDIR"/make.log" |
310 |
return 1 |
return 1 |
311 |
else |
else |
312 |
echo succesful 1>&2 |
echo successful 1>&2 |
313 |
fi |
fi |
314 |
fi |
fi |
315 |
) |
) |
320 |
# linkdata flag |
# linkdata flag |
321 |
# |
# |
322 |
# symbolically link data files to run directory |
# symbolically link data files to run directory |
323 |
if [ $1 -ne 0 ]; then |
if test "x$1" = x1 ; then |
324 |
( cd $2 ; ln -sf ../input/* . ) |
( |
325 |
|
cd $2 |
326 |
|
if test "x$ADM" = x ; then |
327 |
|
files=`( cd ../input ; ls -1 | grep -v CVS )` |
328 |
|
for i in $files ; do |
329 |
|
if test ! -d "../input/"$i ; then |
330 |
|
ln -sf "../input/"$i $i |
331 |
|
fi |
332 |
|
done |
333 |
|
else |
334 |
|
files=`( cd ../input ; ls -1 *.bin | grep -v CVS )` |
335 |
|
for i in $files ; do |
336 |
|
if test ! -d "../input/"$i ; then |
337 |
|
ln -sf "../input/"$i $i |
338 |
|
fi |
339 |
|
done |
340 |
|
files=`( cd ../input_ad ; ls -1 | grep -v CVS )` |
341 |
|
for i in $files ; do |
342 |
|
if test ! -d "../input_ad/"$i ; then |
343 |
|
ln -sf "../input_ad/"$i $i |
344 |
|
fi |
345 |
|
done |
346 |
|
fi |
347 |
|
) |
348 |
fi |
fi |
349 |
} |
} |
350 |
|
|
351 |
runmodel() |
runmodel() |
352 |
{ |
{ |
353 |
# runmodel directory exe |
# runmodel directory |
354 |
# |
# |
355 |
# runs the model "exe" in "directory" (exe is relative to directory) |
# runs "$COMMAND in "directory" |
356 |
|
# (where "$COMMAND" is relative to "directory") |
357 |
( |
( |
358 |
cd $1 |
cd $1 |
359 |
if [ -x $2 ]; then |
printf 'runmodel ... ' 1>&2 |
360 |
if [ $quick -eq 0 ]; then |
# make output.txt |
361 |
rm -f output.txt |
$COMMAND >> run.log 2>&1 |
362 |
fi |
RETVAL=$? |
363 |
printf 'runmodel: ' 1>&2 |
if test "x$RETVAL" = x0 ; then |
364 |
make output.txt |
echo successful 1>&2 |
365 |
RETVAL=$? |
if test "x$ADM" = x ; then |
|
if test "x$RETVAL" = x0 ; then |
|
366 |
cp output.txt $CDIR"/output.txt" |
cp output.txt $CDIR"/output.txt" |
|
return 0 |
|
367 |
else |
else |
368 |
return 1 |
cp output.txt_adm $CDIR"/output.txt_adm" |
369 |
fi |
fi |
370 |
|
return 0 |
371 |
|
else |
372 |
|
tail run.log |
373 |
|
echo failed 1>&2 |
374 |
|
cp run.log $CDIR"/run.log" |
375 |
|
return 1 |
376 |
fi |
fi |
377 |
) |
) |
378 |
} |
} |
382 |
# create codelet for comparing model output |
# create codelet for comparing model output |
383 |
|
|
384 |
echo -n "creating the comparison code... " |
echo -n "creating the comparison code... " |
385 |
cat > tmp_cmpnum.f <<EOFA |
cat > tmp_cmpnum.c <<EOF |
386 |
program cmpnum |
#include <stdio.h> |
387 |
implicit none |
#include <math.h> |
388 |
real*8 a,b,diff |
int main( int argc, char** argv ) { |
389 |
integer linnum,best |
int linnum,best; |
390 |
best=-16 |
double a,b,diff; |
391 |
99 read(*,*,end=70,err=60) linnum,a,b |
best = -16; |
392 |
diff=0.5*(abs(a)+abs(b)) |
while( 1 ) { |
393 |
c print *,a,b,diff,abs(a-b)/diff |
scanf("%d", &linnum); |
394 |
if (diff.gt.1.e-12) then |
if (linnum == -1) break; |
395 |
diff=abs(a-b)/diff |
scanf("%lf", &a); scanf("%lf", &b); |
396 |
if (diff.gt.0.) then |
diff = 0.5*(fabs(a)+fabs(b)); |
397 |
c print *,int(log10(diff)),diff |
if (diff > 1.e-12) { |
398 |
linnum=int(log10(diff)) |
diff=fabs(a-b)/diff; |
399 |
best=max(best,linnum) |
if (diff > 0.0) { |
400 |
endif |
linnum = (int)log10(diff); |
401 |
else |
best = (best > linnum) ? best : linnum; |
402 |
if (best.eq.-16.and.diff.ne.0.) best=-22 |
} |
403 |
endif |
else { |
404 |
goto 99 |
if (best == -16 && diff != 0) best = -22; |
405 |
60 stop 'cmpnum: An error occured reading a,b' |
} |
406 |
70 print *,-best |
} |
407 |
end |
} |
408 |
EOFA |
printf("%d\n", -best); |
409 |
|
return 0; |
410 |
|
} |
411 |
|
EOF |
412 |
|
cc -o tmp_cmpnum tmp_cmpnum.c -lm |
413 |
|
|
414 |
f77 tmp_cmpnum.f |
if [ -x ./tmp_cmpnum ]; then |
|
if [ -x ./a.out ]; then |
|
415 |
echo "OK" |
echo "OK" |
416 |
return 0 |
return 0 |
417 |
else |
else |
418 |
echo |
echo |
419 |
echo "createcodelet: failed to compile codelet" |
echo "ERROR: failed to compile comparison code" |
420 |
exit 1 |
exit 1 |
421 |
fi |
fi |
422 |
} |
} |
448 |
{ |
{ |
449 |
cat - << EOF |
cat - << EOF |
450 |
$0 [-help] [-quick] [-verbose] dir1 [dir2] [...] |
$0 [-help] [-quick] [-verbose] dir1 [dir2] [...] |
451 |
-help Show this help message |
|
452 |
-quick Skip "genmake" and "make depend" if the Makefile exists |
-help|-h Show this help message |
453 |
-quiet Reduce the amount of output |
-quiet Reduce the amount of output |
454 |
-verbose Produce copious amounts of output |
-verbose Produce copious amounts of output |
455 |
-debug Produce even more output which will mean nothing to most |
-debug Produce even more output which will mean nothing to most |
456 |
-force Do "make CLEAN" before compiling. This forces a complete rebuild. |
-force Do "make CLEAN" before compiling. This forces a complete rebuild. |
457 |
-clean Do "make CLEAN" after compiling and testing. |
-clean Do "make CLEAN" after compiling and testing. |
|
-noieee By default, $0 uses the -ieee option for genmake. This turns it off. |
|
458 |
-cleanup Aggresively removes all model output, executables and object files |
-cleanup Aggresively removes all model output, executables and object files |
459 |
and then exits. Use with care. |
and then exits. Use with care. |
460 |
|
|
476 |
|
|
477 |
|
|
478 |
############################################################################### |
############################################################################### |
|
############################################################################### |
|
|
############################################################################### |
|
479 |
|
|
480 |
|
|
481 |
# Default properties |
# Default properties |
482 |
debug=0 |
debug=0 |
483 |
verbose=1 |
verbose=1 |
|
quick=0 |
|
484 |
clean=0 |
clean=0 |
|
ieee=1 |
|
485 |
expts='' |
expts='' |
486 |
|
# ieee=1 |
487 |
|
|
488 |
|
IEEE= |
489 |
|
if test "x$MITGCM_IEEE" != x ; then |
490 |
|
IEEE=$MITGCM_IEEE |
491 |
|
fi |
492 |
|
|
493 |
OPTFILES= |
|
494 |
ADDRESSES=edhill@mitgcm.org |
CLEANUP=f |
495 |
|
QUICK=f |
496 |
|
NOGENMAKE=f |
497 |
|
NOCLEAN=f |
498 |
|
NODEPEND=f |
499 |
|
|
500 |
|
BASH= |
501 |
|
OPTFILE=NONE |
502 |
|
ADDRESSES= |
503 |
TESTDIRS= |
TESTDIRS= |
504 |
MPACKDIR="../tools/mpack-1.6" |
MPACKDIR="../tools/mpack-1.6" |
505 |
|
HAVE_MPACK= |
506 |
MPACK="$MPACKDIR/mpack" |
MPACK="$MPACKDIR/mpack" |
507 |
|
COMMAND= |
508 |
|
MAKE=make |
509 |
|
MPI=f |
510 |
|
|
511 |
|
ADM= |
512 |
|
|
513 |
echo -n "parsing options... " |
echo -n "parsing options... " |
514 |
|
|
530 |
usage ;; |
usage ;; |
531 |
|
|
532 |
-optfile | --optfile | -of | --of) |
-optfile | --optfile | -of | --of) |
533 |
ac_prev=OPTFILES ;; |
ac_prev=OPTFILE ;; |
534 |
-optfile=* | --optfile=* | -of=* | --of=*) |
-optfile=* | --optfile=* | -of=* | --of=*) |
535 |
OPTFILES=$ac_optarg ;; |
OPTFILE=$ac_optarg ;; |
536 |
|
|
537 |
-addr | --addr | -a | --a) |
-addr | --addr | -a | --a) |
538 |
ac_prev=ADDRESSES ;; |
ac_prev=ADDRESSES ;; |
544 |
-tdir=* | --tdir=*) |
-tdir=* | --tdir=*) |
545 |
TESTDIRS=$ac_optarg ;; |
TESTDIRS=$ac_optarg ;; |
546 |
|
|
547 |
-quick) quick=1 ;; |
-bash | --bash | -b | --b) |
548 |
|
ac_prev=BASH ;; |
549 |
|
-bash=* | --bash=*) |
550 |
|
BASH=$ac_optarg ;; |
551 |
|
|
552 |
|
-command | --command | -c | --c) |
553 |
|
ac_prev=COMMAND ;; |
554 |
|
-command=* | --command=*) |
555 |
|
COMMAND=$ac_optarg ;; |
556 |
|
|
557 |
|
-make | --make | -m | --m) |
558 |
|
ac_prev=MAKE ;; |
559 |
|
-make=* | --make=*) |
560 |
|
MAKE=$ac_optarg ;; |
561 |
|
|
562 |
|
-clean | --clean) |
563 |
|
CLEANUP=t ;; |
564 |
|
|
565 |
|
-quick | --quick | -q | --q) |
566 |
|
QUICK=t ;; |
567 |
|
-nogenmake | --nogenmake | -ng | --ng) |
568 |
|
NOGENMAKE=t ;; |
569 |
|
-noclean | --noclean | -nc | --nc) |
570 |
|
NOCLEAN=t ;; |
571 |
|
-nodepend | --nodepend | -nd | --nd) |
572 |
|
NODEPEND=t ;; |
573 |
|
|
574 |
|
-mpi) MPI=t ;; |
575 |
|
|
576 |
|
-adm | -ad) ADM=t ;; |
577 |
|
|
578 |
|
-ieee) IEEE=true ;; |
579 |
|
-noieee) IEEE= ;; |
580 |
|
|
581 |
-verbose) verbose=2 ;; |
-verbose) verbose=2 ;; |
582 |
-debug) debug=1 ;; |
-debug) debug=1 ;; |
|
-clean) clean=1 ;; |
|
|
-noieee) ieee=0 ;; |
|
583 |
-quiet) verbose=0 ;; |
-quiet) verbose=0 ;; |
584 |
|
|
585 |
-*) |
-*) |
596 |
|
|
597 |
done |
done |
598 |
|
|
599 |
|
if test "x$QUICK" = xt ; then |
600 |
|
NOGENMAKE=t |
601 |
|
NOCLEAN=t |
602 |
|
NODEPEND=t |
603 |
|
fi |
604 |
|
|
605 |
if test "x$TESTDIRS" = x ; then |
if test "x$TESTDIRS" = x ; then |
606 |
TESTDIRS=`scandirs` |
TESTDIRS=`scandirs` |
607 |
fi |
fi |
608 |
|
|
609 |
|
if test "x$OPTFILE" = xNONE -a "x$MITGCM_OF" != x ; then |
610 |
|
OPTFILE=$MITGCM_OF |
611 |
|
fi |
612 |
|
|
613 |
|
if test "x$ADM" = xt -a "x$COMMAND" = x ; then |
614 |
|
COMMAND="./mitgcmuv_ad > output.txt_adm 2>&1" |
615 |
|
fi |
616 |
|
|
617 |
|
if test "x$COMMAND" = x ; then |
618 |
|
COMMAND="make output.txt" |
619 |
|
fi |
620 |
|
|
621 |
echo "OK" |
echo "OK" |
622 |
|
|
623 |
# create the FORTRAN comparison code |
# create the FORTRAN comparison code |
640 |
mkdir $DRESULTS |
mkdir $DRESULTS |
641 |
RETVAL=$? |
RETVAL=$? |
642 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
643 |
echo "Error: can't create results directory \"./$DRESULTS\"" |
echo "ERROR: Can't create results directory \"./$DRESULTS\"" |
644 |
exit 1 |
exit 1 |
645 |
fi |
fi |
646 |
SUMMARY="$DRESULTS/summary.txt" |
SUMMARY="$DRESULTS/summary.txt" |
647 |
date > $SUMMARY |
echo -n "Start time: " >> $SUMMARY |
648 |
cat << EOF >> $SUMMARY |
start_date=`date` |
649 |
|
echo $start_date > $SUMMARY |
650 |
|
|
651 |
|
of_path= |
652 |
|
if test "x$OPTFILE" != xNONE ; then |
653 |
|
if test -r $OPTFILE ; then |
654 |
|
# get the path |
655 |
|
path=${OPTFILE%/*} |
656 |
|
if test "x$path" = x ; then |
657 |
|
of_path=`pwd` |
658 |
|
else |
659 |
|
of_path=`( cd $path > /dev/null 2>&1 ; pwd )` |
660 |
|
fi |
661 |
|
file=${OPTFILE##*/} |
662 |
|
OPTFILE=$of_path/$file |
663 |
|
cp $OPTFILE $DRESULTS |
664 |
|
echo >> $SUMMARY |
665 |
|
echo " OPTFILE=$OPTFILE" >> $SUMMARY |
666 |
|
else |
667 |
|
echo | tee $SUMMARY |
668 |
|
echo "ERROR: can't read OPTFILE=\"$OPTFILE\"" | tee $SUMMARY |
669 |
|
exit 1 |
670 |
|
fi |
671 |
|
else |
672 |
|
echo >> $SUMMARY |
673 |
|
echo "No \"OPTFILE\" was explicitly specified by testreport," >> $SUMMARY |
674 |
|
echo " so the genmake default will be used." >> $SUMMARY |
675 |
|
fi |
676 |
|
echo |
677 |
|
echo >> $SUMMARY |
678 |
|
if test "x$ADM" = x ; then |
679 |
|
cat << EOF | tee -a $SUMMARY |
680 |
T S U V |
T S U V |
681 |
G D M c m s m s m s m s |
G D M c m s m s m s m s |
682 |
E p a R g m m e . m m e . m m e . m m e . |
E p a R g m m e . m m e . m m e . m m e . |
684 |
2 d e n d n x n . n x n . n x n . n x n . |
2 d e n d n x n . n x n . n x n . n x n . |
685 |
|
|
686 |
EOF |
EOF |
687 |
|
else |
688 |
|
echo "ADJOINT=true" >> $SUMMARY |
689 |
|
echo >> $SUMMARY |
690 |
|
cat << EOF | tee -a $SUMMARY |
691 |
|
G D M C G |
692 |
|
E p a R o r |
693 |
|
N n k u s a |
694 |
|
2 d e n t d |
695 |
|
|
696 |
NDIR=0 |
EOF |
697 |
|
fi |
|
# For each optfile... |
|
|
for OPTFILE in $OPTFILES ; do |
|
698 |
|
|
699 |
OPTFILE=`pwd`"/$OPTFILE" |
# ...and each test directory... |
700 |
if test ! -r $OPTFILE ; then |
for dir in $TESTDIRS ; do |
|
echo "Error: can't read optfile \"$OPTFILE\"" |
|
|
exit 1 |
|
|
fi |
|
|
echo |
|
|
echo "OPTFILE=$OPTFILE" >> $SUMMARY |
|
|
echo >> $SUMMARY |
|
701 |
|
|
702 |
# ...and each test directory... |
# Cleanup only! |
703 |
for dir in $TESTDIRS ; do |
if test "x$CLEANUP" = xt ; then |
704 |
|
if test -r $dir/build/Makefile ; then |
705 |
|
( cd $dir/build ; make CLEAN ) |
706 |
|
fi |
707 |
|
if test -r $dir/input/Makefile ; then |
708 |
|
( cd $dir/input ; make CLEAN ) |
709 |
|
fi |
710 |
|
continue |
711 |
|
fi |
712 |
|
|
713 |
|
# Verify that the testdir exists and contains previous |
714 |
|
# results in the correct location--or skip this directory! |
715 |
|
fout= |
716 |
|
if test "x$ADM" = x ; then |
717 |
|
fout=$dir"/results/output.txt" |
718 |
|
else |
719 |
|
fout=$dir"/results_ad/output.txt_adm" |
720 |
|
fi |
721 |
|
if test ! -r $fout ; then |
722 |
|
echo "can't read \"$fout\" -- skipping $dir" |
723 |
|
continue |
724 |
|
fi |
725 |
|
|
726 |
# Verify that the testdir exists and contains previous |
echo "-------------------------------------------------------------------------------" |
727 |
# results in the correct location--or skip this directory! |
echo |
728 |
if test ! -r $dir"/results/output.txt" ; then |
echo "Experiment: $dir" |
729 |
echo | tee -a $SUMMARY |
echo |
730 |
echo "can't read \"$dir/results/output.txt\" -- skipping $dir" \ |
unset genmake makedepend make run |
731 |
| tee -a $SUMMARY |
results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --' |
|
continue |
|
|
fi |
|
|
|
|
|
# Create an output dir for each OPTFILE/tdir combination |
|
|
CDIR=$DRESULTS"/"$DRESULTS"_"$NDIR |
|
|
mkdir $CDIR |
|
|
CDIR=`pwd`"/$CDIR" |
|
732 |
|
|
733 |
# ...configue, make, run, and compare the output. |
builddir="input" |
734 |
echo "-------------------------------------------------------------------------------" |
rundir="input" |
735 |
echo |
use_seperate_build=0 |
736 |
echo "Experiment: $dir" |
if test -d $dir/build -a -r $dir/build ; then |
737 |
echo |
builddir="build" |
738 |
unset genmake makedepend make run |
rundir="build" |
739 |
results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --' |
use_seperate_build=1 |
740 |
( cd $dir/input; rm -f *.{o,f,c,F} *.[f,F]90 work* output.txt Make* make.log; ) |
linkdata $use_seperate_build $dir/$rundir |
741 |
if [ -r $dir/build ]; then |
fi |
742 |
seperatebuilddir=1 |
|
743 |
builddir=build |
if test "x$ADM" = x ; then |
744 |
rundir=build |
CODE_DIR=$dir/code |
745 |
( cd $dir/build; ln -sf ../input/* . ) |
else |
746 |
else |
CODE_DIR=$dir/code_ad |
747 |
seperatebuilddir=0 |
fi |
748 |
builddir=input |
BUILD_DIR=$dir/$builddir |
749 |
rundir=input |
MPI_FILES="CPP_EEOPTIONS.h_mpi SIZE.h_mpi" |
750 |
|
NOMPI_FILES="CPP_EEOPTIONS.h_nompi SIZE.h_nompi" |
751 |
|
|
752 |
|
# Is this an MPI run? |
753 |
|
if test "x$MPI" = xt ; then |
754 |
|
FILES=$MPI_FILES |
755 |
|
endings="_mpi" |
756 |
|
else |
757 |
|
FILES=$NOMPI_FILES |
758 |
|
endings="_nompi" |
759 |
|
fi |
760 |
|
|
761 |
|
# Check to see that we have the files |
762 |
|
have_files=t |
763 |
|
for i in $FILES ; do |
764 |
|
if test ! -r $CODE_DIR/$i ; then |
765 |
|
echo "Warning: can't read file $CODE_DIR/$i" |
766 |
|
have_files=f |
767 |
fi |
fi |
768 |
|
done |
769 |
|
if test "x$have_files" != xt -a "x$MPI" = xt ; then |
770 |
|
echo "Skipping $dir due to lack of input files (see above warning)" |
771 |
|
continue |
772 |
|
fi |
773 |
|
|
774 |
|
# If we have the $FILES and they differ, copy the $FILES to $BUILD_DIR |
775 |
|
if test "x$have_files" = xt ; then |
776 |
|
for i in $FILES ; do |
777 |
|
sstr="s|$endings||" |
778 |
|
name=`echo $i | sed -e $sstr ` |
779 |
|
cmp $CODE_DIR/$i $BUILD_DIR/$name > /dev/null 2>&1 |
780 |
|
RETVAL=$? |
781 |
|
if test "x$RETVAL" != x0 ; then |
782 |
|
cp $CODE_DIR/$i $BUILD_DIR/$name |
783 |
|
fi |
784 |
|
done |
785 |
|
fi |
786 |
|
|
787 |
|
# Create an output dir for each OPTFILE/tdir combination |
788 |
|
rel_CDIR=$DRESULTS"/"$dir |
789 |
|
mkdir $rel_CDIR |
790 |
|
CDIR=`pwd`"/$rel_CDIR" |
791 |
|
|
792 |
|
if test "x$CLEANUP" = xt ; then |
793 |
|
makeclean $dir/$builddir |
794 |
|
else |
795 |
genmakemodel $dir/$builddir && genmake=Y \ |
genmakemodel $dir/$builddir && genmake=Y \ |
796 |
&& makeclean $dir/$builddir \ |
&& makeclean $dir/$builddir \ |
797 |
&& makedependmodel $dir/$builddir && makedepend=Y \ |
&& makedependmodel $dir/$builddir && makedepend=Y \ |
798 |
&& makemodel $dir/$builddir && make=Y \ |
&& makemodel $dir/$builddir && make=Y \ |
799 |
&& linkdata $seperatebuilddir $dir/$rundir \ |
&& linkdata $use_seperate_build $dir/$rundir \ |
800 |
&& runmodel $dir/$builddir mitgcmuv && run=Y \ |
&& runmodel $dir/$rundir && run=Y \ |
801 |
&& results=`testoutput $dir $rundir` |
&& results=`testoutput $dir $rundir` |
802 |
echo |
fi |
803 |
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
|
804 |
${run:-N} $results |
echo |
805 |
echo |
if test "x$ADM" = x ; then |
806 |
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results` |
807 |
${run:-N} $results >> $SUMMARY |
else |
808 |
echo "fresults='" > $CDIR"/summary.txt" |
fres=`printf '%s %s %s %s' ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N}` |
809 |
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
fres=$fres"$results $dir" |
810 |
${run:-N} $results >> $CDIR"/summary.txt" |
fi |
811 |
echo "'" >> $CDIR"/summary.txt" |
echo |
812 |
echo "MACH='$MACH'" >> $CDIR"/summary.txt" |
echo "$fres" >> $SUMMARY |
813 |
echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt" |
echo "fresults='$fres'" > $CDIR"/summary.txt" |
814 |
echo "DATE='$DATE'" >> $CDIR"/summary.txt" |
echo "MACH='$MACH'" >> $CDIR"/summary.txt" |
815 |
echo "tdir='$dir'" >> $CDIR"/summary.txt" |
echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt" |
816 |
|
echo "DATE='$DATE'" >> $CDIR"/summary.txt" |
817 |
( |
echo "tdir='$dir'" >> $CDIR"/summary.txt" |
818 |
cd $DRESULTS |
|
819 |
tar -cf $NDIR".tar" $DRESULTS"_"$NDIR > /dev/null 2>&1 |
echo "-------------------------------------------------------------------------------" |
820 |
gzip $NDIR".tar" |
|
821 |
) |
done |
822 |
|
|
823 |
$MPACK -s MITgcm-test -m 1000000 $DRESULTS"/"$NDIR".tar.gz" $ADDRESSES |
echo -n "Start time: " >> $SUMMARY |
824 |
|
echo $start_date >> $SUMMARY |
825 |
|
echo -n "End time: " >> $SUMMARY |
826 |
|
date >> $SUMMARY |
827 |
|
|
828 |
|
# If addresses were supplied and mpack built successfully, then try |
829 |
|
# to send email using mpack. |
830 |
|
if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then |
831 |
|
echo "No results email was sent." |
832 |
|
else |
833 |
|
if test "x$HAVE_MPACK" = xt ; then |
834 |
|
tar -cf $DRESULTS".tar" $DRESULTS > /dev/null 2>&1 \ |
835 |
|
&& gzip $DRESULTS".tar" \ |
836 |
|
&& $MPACK -s MITgcm-test -m 1500000 $DRESULTS".tar.gz" $ADDRESSES |
837 |
RETVAL=$? |
RETVAL=$? |
838 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
839 |
echo "Warning: \"$MPACK\" failed -- please contact <edhill@mitgcm.org>" |
echo |
840 |
|
echo "Warning: The tar, gzip, & mpack step failed. Please send email" |
841 |
|
echo " to <MITgcm-support@mitgcm.org> for help. You may copy the " |
842 |
|
echo " summary of results from the directory \"$DRESULTS\"." |
843 |
|
echo |
844 |
else |
else |
845 |
rm -f $DRESULTS"/"$NDIR".tar*" |
echo |
846 |
|
echo "An email containing results was sent to the following addresses:" |
847 |
|
echo " \"$ADDRESSES\"" |
848 |
|
echo |
849 |
fi |
fi |
850 |
|
test -f $DRESULTS".tar" && rm -f $DRESULTS".tar" |
851 |
|
test -f $DRESULTS".tar.gz" && rm -f $DRESULTS".tar.gz" |
852 |
|
fi |
853 |
|
fi |
854 |
|
|
855 |
NDIR=$(( $NDIR + 1 )) |
# rm -f tmp_cmpnum.f a.out |
856 |
|
rm -f tmp_cmpnum.c tmp_cmpnum |
|
done |
|
|
done |
|
|
|
|
|
rm tmp_cmpnum.f a.out |
|
857 |
|
|
858 |
cat $SUMMARY |
if test "x$CLEANUP" != xt ; then |
859 |
|
cat $SUMMARY |
860 |
|
if test -e tr.out ; then |
861 |
|
mv tr.out tr.out.old |
862 |
|
fi |
863 |
|
cat $SUMMARY > tr.out |
864 |
|
fi |
865 |
|
|