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