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