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