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