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