1 |
#!/bin/bash |
#! /usr/bin/env bash |
2 |
# |
# |
3 |
# $Header$ |
# $Header$ |
4 |
|
# $Name$ |
5 |
# |
# |
6 |
|
|
7 |
usage() |
usage() |
11 |
echo |
echo |
12 |
echo "where possible OPTIONS are:" |
echo "where possible OPTIONS are:" |
13 |
echo " (-help|-h) print usage" |
echo " (-help|-h) print usage" |
14 |
echo " (-optfile=|-of=)STRING list of genmake2 \"optfiles\"" |
echo " (-mpi) use MPI input files" |
15 |
echo " (-a|-addr)STRING list of email recipients" |
echo " (-ieee|-noieee) if possible, use IEEE compiler flags" |
16 |
echo " (-t|-tdir)STRING list of \"test\" dirs" |
echo " (DEF=\"noieee\")" |
17 |
echo " (-b|-bash)STRING the \"bash\" executable" |
echo " (-optfile=|-of=)STRING list of optfiles to use" |
18 |
echo " (-m|-make)STRING the \"make\" executable" |
echo " (-a|-addr) STRING list of email recipients" |
19 |
|
echo " (DEF=\"edhill@mitgcm.org\")" |
20 |
|
echo " (-t|-tdir) STRING list of test dirs to use" |
21 |
|
echo " (DEF=\"\" which builds all)" |
22 |
|
echo " (-b|-bash) STRING preferred location of a \"bash\" or" |
23 |
|
echo " Bourne-compatible \"sh\" shell" |
24 |
|
echo " (DEF=\"\" for \"bash\")" |
25 |
|
echo " (-adm|-ad) perform an adjoint run" |
26 |
|
echo " (-command) STRING command to run" |
27 |
|
echo " (DEF=\"make output.txt\")" |
28 |
|
echo " (-m|-make) STRING command to use for \"make\"" |
29 |
|
echo " (DEF=\"make\")" |
30 |
|
echo " (-clean) *ONLY* run \"make CLEAN\"" |
31 |
|
echo " (-quick|-q) same as \"-nogenmake -noclean -nodepend\"" |
32 |
|
echo " (-nogenmake|-ng) skip the genmake stage" |
33 |
|
echo " (-noclean|-nc) skip the \"make clean\" stage" |
34 |
|
echo " (-nodepend|-nd) skip the \"make depend\" stage" |
35 |
|
echo |
36 |
|
echo "and where STRING follows a whitespace-delimited format" |
37 |
|
echo "such as:" |
38 |
|
echo " -t 'exp0 exp2 exp3' " |
39 |
|
echo " -addr='abc@123.com testing@home.org'" |
40 |
echo |
echo |
41 |
exit 1 |
exit 1 |
42 |
} |
} |
44 |
# build the mpack utility |
# build the mpack utility |
45 |
build_mpack() |
build_mpack() |
46 |
{ |
{ |
47 |
echo -n "building the mpack utility... " |
printf "building the mpack utility... " |
48 |
if test ! -x "$MPACKDIR/mpack" ; then |
if test ! -x "$MPACKDIR/mpack" ; then |
49 |
if test ! -d $MPACKDIR ; then |
if test ! -d $MPACKDIR ; then |
50 |
|
echo |
51 |
echo "Error: can't find \"$MPACKDIR\"" |
echo "Error: can't find \"$MPACKDIR\"" |
52 |
echo " are you sure this program is being run in the correct " |
echo " are you sure this program is being run in the correct " |
53 |
echo " (that is, \"MITGCM_ROOT\verification\") directory?" |
echo " (that is, \"MITGCM_ROOT\verification\") directory?" |
54 |
exit 1 |
echo |
55 |
|
HAVE_MPACK=f |
56 |
|
fi |
57 |
|
printf "building mpack... " |
58 |
|
if test "x$CC" = x ; then |
59 |
|
export CC=cc |
60 |
fi |
fi |
61 |
echo -n "building mpack... " |
( cd $MPACKDIR && ./configure && $MAKE ) > tr_build_mpack.out 2>&1 |
|
( cd $MPACKDIR && ./configure && $MAKE ) > build_mpack.out 2>&1 |
|
62 |
RETVAL=$? |
RETVAL=$? |
63 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
64 |
echo |
echo |
65 |
echo "Error building the mpack tools at: $MPACK_DIR" |
echo "Error building the mpack tools at: $MPACK_DIR" |
66 |
exit 1 |
echo |
67 |
|
HAVE_MPACK=f |
68 |
|
else |
69 |
|
rm -f tr_build_mpack.out |
70 |
|
HAVE_MPACK=t |
71 |
fi |
fi |
72 |
|
else |
73 |
|
HAVE_MPACK=t |
74 |
fi |
fi |
75 |
echo "OK" |
echo "OK" |
76 |
} |
} |
77 |
|
|
|
compare_lines() |
|
|
{ |
|
|
# use codelet to compare lines |
|
|
if [ $verbose -gt 1 ]; then |
|
|
cat tmp3.txt 1>&2 |
|
|
fi |
|
|
return `./a.out < tmp3.txt` |
|
|
} |
|
|
|
|
78 |
testoutput_for_prop() |
testoutput_for_prop() |
79 |
{ |
{ |
80 |
# testoutput_for_prop dir s1 label subdir |
# testoutput_for_prop dir s1 label subdir extension |
81 |
# |
# |
82 |
# compares files in $dir/$subdir/output.txt and $dir/results/output.txt |
# compares files in $dir/$subdir/output.txt and $dir/results/output.txt |
83 |
# using search strings s1 and text label |
# using search strings s1 and text label |
86 |
echo testoutput_for_prop: grep "$2" $1/$4/output.txt 1>&2 |
echo testoutput_for_prop: grep "$2" $1/$4/output.txt 1>&2 |
87 |
fi |
fi |
88 |
if [ -r $1/$4/output.txt ]; then |
if [ -r $1/$4/output.txt ]; then |
89 |
grep "$2" $1/$4/output.txt | sed 's/.*=//' | nl > tmp1.txt |
grep "$2" $1/$4/output.txt | sed 's/.*=//' | cat -n > tmp1.txt |
90 |
lncnt=`wc -l tmp1.txt | awk '{print $1}' ` |
lncnt=`wc -l tmp1.txt | awk '{print $1}' ` |
91 |
if [ $lncnt -lt 3 ]; then |
if [ $lncnt -lt 3 ]; then |
92 |
if [ $verbose -gt 0 ]; then |
if [ $verbose -gt 0 ]; then |
99 |
return 99 |
return 99 |
100 |
fi |
fi |
101 |
if [ $debug -gt 0 ]; then |
if [ $debug -gt 0 ]; then |
102 |
echo testoutput_for_prop: grep "$2" $1/results/output.txt 1>&2 |
echo testoutput_for_prop: grep "$2" $1/results/output.txt$5 1>&2 |
103 |
fi |
fi |
104 |
grep "$2" $1/results/output.txt | sed 's/.*=//' | nl > tmp2.txt |
grep "$2" $1/results/output.txt$5 | sed 's/.*=//' | cat -n > tmp2.txt |
105 |
lncnt=`wc -l tmp2.txt | awk '{print $1}' ` |
lncnt=`wc -l tmp2.txt | awk '{print $1}' ` |
106 |
if [ $lncnt -lt 3 ]; then |
if [ $lncnt -lt 3 ]; then |
107 |
if [ $verbose -gt 0 ]; then |
if [ $verbose -gt 0 ]; then |
116 |
if [ $debug -gt 0 ]; then |
if [ $debug -gt 0 ]; then |
117 |
echo testoutput_for_prop: compare_lines 1>&2 |
echo testoutput_for_prop: compare_lines 1>&2 |
118 |
fi |
fi |
119 |
compare_lines |
if [ $verbose -gt 1 ]; then |
120 |
digits_of_similarity=$? |
cat tmp3.txt 1>&2 |
121 |
|
fi |
122 |
|
echo "-1" >> tmp3.txt |
123 |
|
# On the SGI O3K (*not* the O2K), "cat -n" inserts a ":" after the line number |
124 |
|
cat tmp3.txt | sed -e 's|:||g' > tmp4.txt |
125 |
|
digits_of_similarity=`./tmp_cmpnum < tmp4.txt` |
126 |
if [ $digits_of_similarity -eq 99 ]; then |
if [ $digits_of_similarity -eq 99 ]; then |
127 |
if [ $verbose -gt 0 ]; then |
if [ $verbose -gt 0 ]; then |
128 |
echo testoutput_for_prop: No comparison was available for \"$2\" 1>&2 |
echo testoutput_for_prop: No comparison was available for \"$2\" 1>&2 |
133 |
echo There were $digits_of_similarity decimal places of similarity for \"$2\" 1>&2 |
echo There were $digits_of_similarity decimal places of similarity for \"$2\" 1>&2 |
134 |
fi |
fi |
135 |
fi |
fi |
136 |
rm tmp1.txt tmp2.txt tmp3.txt |
rm -f tmp1.txt tmp2.txt tmp3.txt tmp4.txt |
137 |
|
|
138 |
return $digits_of_similarity |
return $digits_of_similarity |
139 |
} |
} |
153 |
done |
done |
154 |
} |
} |
155 |
|
|
156 |
|
testoutput_ad() |
157 |
|
{ |
158 |
|
grep $3 $1/results_ad/output.txt_adm | awk '{print NR " " $5}' > t05.txt |
159 |
|
grep $3 $1/$2/output.txt_adm | awk '{print NR " " $5}' > t15.txt |
160 |
|
grep $3 $1/results_ad/output.txt_adm | awk '{print NR " " $6}' > t06.txt |
161 |
|
grep $3 $1/$2/output.txt_adm | awk '{print NR " " $6}' > t16.txt |
162 |
|
join t05.txt t15.txt > t5.txt |
163 |
|
join t06.txt t16.txt > t6.txt |
164 |
|
echo "-1" >> t5.txt |
165 |
|
echo "-1" >> t6.txt |
166 |
|
digits_5=`./tmp_cmpnum < t5.txt` |
167 |
|
digits_6=`./tmp_cmpnum < t6.txt` |
168 |
|
dashnum $digits_5 $digits_6 |
169 |
|
rm -f t[01][56].txt t[56].txt |
170 |
|
} |
171 |
|
|
172 |
testoutput() |
testoutput() |
173 |
{ |
{ |
174 |
# testoutput diretory subdir |
# testoutput directory subdir extension |
175 |
# |
# |
176 |
# test output in "directory" |
# test output in "directory" |
177 |
|
if test "x$ADM" = x ; then |
178 |
if [ $debug -gt 0 ]; then |
if [ $debug -gt 0 ]; then |
179 |
echo testoutput: testoutput_for_prop $1 cg2d_init_res 1>&2 |
echo testoutput: testoutput_for_prop $1 cg2d_init_res 1>&2 |
180 |
fi |
fi |
181 |
testoutput_for_prop $1 "cg2d_init_res" "cg2d init. residual" $2; cg2dres=$? |
testoutput_for_prop $1 "cg2d_init_res" "cg2d init. residual" $2 $3; cg2dres=$? |
182 |
if [ $debug -gt 0 ]; then |
if [ $debug -gt 0 ]; then |
183 |
echo testoutput: cg2dres=$cg2dres 1>&2 |
echo testoutput: cg2dres=$cg2dres 1>&2 |
184 |
|
fi |
185 |
|
testoutput_for_prop $1 "dynstat_theta_min" "theta minimum" $2 $3; tmin=$? |
186 |
|
testoutput_for_prop $1 "dynstat_theta_max" "theta maximum" $2 $3; tmax=$? |
187 |
|
testoutput_for_prop $1 "dynstat_theta_mean" "theta mean" $2 $3; tmean=$? |
188 |
|
testoutput_for_prop $1 "dynstat_theta_sd" "theta s.d." $2 $3; tsd=$? |
189 |
|
testoutput_for_prop $1 "dynstat_salt_min" "salt minimum" $2 $3; smin=$? |
190 |
|
testoutput_for_prop $1 "dynstat_salt_max" "salt maximum" $2 $3; smax=$? |
191 |
|
testoutput_for_prop $1 "dynstat_salt_mean" "salt mean" $2 $3; smean=$? |
192 |
|
testoutput_for_prop $1 "dynstat_salt_sd" "salt s.d." $2 $3; ssd=$? |
193 |
|
testoutput_for_prop $1 "dynstat_uvel_min" "U minimum" $2 $3; umin=$? |
194 |
|
testoutput_for_prop $1 "dynstat_uvel_max" "U maximum" $2 $3; umax=$? |
195 |
|
testoutput_for_prop $1 "dynstat_uvel_mean" "U mean" $2 $3; umean=$? |
196 |
|
testoutput_for_prop $1 "dynstat_uvel_sd" "U s.d." $2 $3; usd=$? |
197 |
|
testoutput_for_prop $1 "dynstat_vvel_min" "V minimum" $2 $3; vmin=$? |
198 |
|
testoutput_for_prop $1 "dynstat_vvel_max" "V maximum" $2 $3; vmax=$? |
199 |
|
testoutput_for_prop $1 "dynstat_vvel_mean" "V mean" $2 $3; vmean=$? |
200 |
|
testoutput_for_prop $1 "dynstat_vvel_sd" "V s.d." $2 $3; vsd=$? |
201 |
|
dashnum $cg2dres $tmin $tmax $tmean $tsd $smin $smax $smean $ssd \ |
202 |
|
$umin $umax $umean $usd $vmin $vmax $vmean $vsd |
203 |
|
else |
204 |
|
testoutput_ad $1 $2 "precision_grdchk_result" |
205 |
fi |
fi |
|
|
|
|
testoutput_for_prop $1 "dynstat_theta_min" "theta minimum" $2; tmin=$? |
|
|
testoutput_for_prop $1 "dynstat_theta_max" "theta maximum" $2; tmax=$? |
|
|
testoutput_for_prop $1 "dynstat_theta_mean" "theta mean" $2; tmean=$? |
|
|
testoutput_for_prop $1 "dynstat_theta_sd" "theta s.d." $2; tsd=$? |
|
|
testoutput_for_prop $1 "dynstat_salt_min" "salt minimum" $2; smin=$? |
|
|
testoutput_for_prop $1 "dynstat_salt_max" "salt maximum" $2; smax=$? |
|
|
testoutput_for_prop $1 "dynstat_salt_mean" "salt mean" $2; smean=$? |
|
|
testoutput_for_prop $1 "dynstat_salt_sd" "salt s.d." $2; ssd=$? |
|
|
testoutput_for_prop $1 "dynstat_uvel_min" "U minimum" $2; umin=$? |
|
|
testoutput_for_prop $1 "dynstat_uvel_max" "U maximum" $2; umax=$? |
|
|
testoutput_for_prop $1 "dynstat_uvel_mean" "U mean" $2; umean=$? |
|
|
testoutput_for_prop $1 "dynstat_uvel_sd" "U s.d." $2; usd=$? |
|
|
testoutput_for_prop $1 "dynstat_vvel_min" "V minimum" $2; vmin=$? |
|
|
testoutput_for_prop $1 "dynstat_vvel_max" "V maximum" $2; vmax=$? |
|
|
testoutput_for_prop $1 "dynstat_vvel_mean" "V mean" $2; vmean=$? |
|
|
testoutput_for_prop $1 "dynstat_vvel_sd" "V s.d." $2; vsd=$? |
|
|
|
|
|
dashnum $cg2dres $tmin $tmax $tmean $tsd $smin $smax $smean $ssd \ |
|
|
$umin $umax $umean $usd $vmin $vmax $vmean $vsd |
|
206 |
} |
} |
207 |
|
|
208 |
genmakemodel() |
genmakemodel() |
209 |
{ |
{ |
210 |
# genmakemodel directory |
# genmakemodel directory |
211 |
GENMAKE2="$BASH ../../../tools/genmake2" |
if test "x$NOGENMAKE" = xt ; then |
212 |
( |
echo "genmake skipped!" |
213 |
cd $1; |
else |
214 |
printf 'genmake ... ' 1>&2 |
if test "x$BASH" = x ; then |
215 |
# ../../../tools/genmake -ieee -mods=../code > make.log 2>&1 |
GENMAKE2="../../../tools/genmake2" |
|
$GENMAKE2 -make $MAKE -ds --mods=../code "--optfile="$OPTFILE > make.log 2>&1 |
|
|
RETVAL=$? |
|
|
for i in gm_state gm_optfile gm_local Makefile ; do |
|
|
if test -r $i ; then |
|
|
cp $i $CDIR |
|
|
fi |
|
|
done |
|
|
if test "x$RETVAL" != x0 ; then |
|
|
tail make.log |
|
|
echo "genmakemodel: genmake failed" 1>&2 |
|
|
cp make.log $CDIR |
|
|
return 1 |
|
216 |
else |
else |
217 |
echo "succesful" 1>&2 |
GENMAKE2="$BASH ../../../tools/genmake2 -bash $BASH" |
218 |
fi |
fi |
219 |
) |
( |
220 |
|
cd $1; |
221 |
|
command="$GENMAKE2 -ds -m $MAKE" |
222 |
|
if test "x$ADM" = x ; then |
223 |
|
command="$command --mods=../code" |
224 |
|
else |
225 |
|
command="$command --mods=../code_ad" |
226 |
|
command="$command -adof=../../../tools/adjoint_options/adjoint_staf" |
227 |
|
fi |
228 |
|
if test "x$OPTFILE" != xNONE ; then |
229 |
|
command="$command --optfile=$OPTFILE" |
230 |
|
fi |
231 |
|
if test "x$IEEE" != x ; then |
232 |
|
command="$command -ieee" |
233 |
|
fi |
234 |
|
printf 'genmake ... ' 1>&2 |
235 |
|
$command > make.log 2>&1 |
236 |
|
RETVAL=$? |
237 |
|
cp Makefile $CDIR |
238 |
|
if test "x$RETVAL" != x0 ; then |
239 |
|
tail make.log |
240 |
|
echo "genmakemodel: genmake failed" 1>&2 |
241 |
|
cp genmake_* make.log $CDIR |
242 |
|
return 1 |
243 |
|
else |
244 |
|
echo "successful" 1>&2 |
245 |
|
fi |
246 |
|
) |
247 |
|
fi |
248 |
} |
} |
249 |
|
|
250 |
makeclean() |
makeclean() |
251 |
{ |
{ |
252 |
# makeclean directory |
# makeclean directory |
253 |
( |
if test "x$NOCLEAN" = xt ; then |
254 |
cd $1; |
echo "make CLEAN skipped!" |
255 |
rm -f output.txt |
else |
256 |
printf 'make CLEAN ... ' 2>&1 |
( |
257 |
if test -r Makefile ; then |
cd $1; |
258 |
$MAKE CLEAN >> make.log 2>&1 |
if test -e output.txt ; then |
259 |
RETVAL=$? |
rm -f output.txt |
|
if test "x$RETVAL" != x0 ; then |
|
|
tail make.log |
|
|
echo "makeclean: \"make CLEAN\" failed" 1>&2 |
|
|
cp make.log $CDIR"/make.log" |
|
|
return 1 |
|
260 |
fi |
fi |
261 |
fi |
printf 'make CLEAN ... ' 2>&1 |
262 |
echo succesful 1>&2 |
if test -r Makefile ; then |
263 |
exit 0 |
$MAKE CLEAN >> make.log 2>&1 |
264 |
) |
RETVAL=$? |
265 |
|
if test "x$RETVAL" != x0 ; then |
266 |
|
tail make.log |
267 |
|
echo "makeclean: \"make CLEAN\" failed" 1>&2 |
268 |
|
cp make.log $CDIR"/make.log" |
269 |
|
return 1 |
270 |
|
fi |
271 |
|
fi |
272 |
|
echo successful 1>&2 |
273 |
|
exit 0 |
274 |
|
) |
275 |
|
fi |
276 |
} |
} |
277 |
|
|
278 |
makedependmodel() |
makedependmodel() |
279 |
{ |
{ |
280 |
# makedependmodel directory |
# makedependmodel directory |
281 |
( |
if test "x$NODEPEND" = xt ; then |
282 |
cd $1; |
echo "make depend skipped!" |
283 |
printf 'make depend ... ' 1>&2 |
else |
284 |
$MAKE depend >> make.log 2>&1 |
( |
285 |
RETVAL=$? |
cd $1; |
286 |
if test "x$RETVAL" != x0 ; then |
printf 'make depend ... ' 1>&2 |
287 |
tail make.log |
$MAKE depend >> make.log 2>&1 |
288 |
echo "makedependmodel: make depend failed" 1>&2 |
RETVAL=$? |
289 |
cp make.log $CDIR"/make.log" |
if test "x$RETVAL" != x0 ; then |
290 |
return 1 |
tail make.log |
291 |
else |
echo "makedependmodel: make depend failed" 1>&2 |
292 |
echo succesful 1>&2 |
cp make.log $CDIR"/make.log" |
293 |
fi |
return 1 |
294 |
) |
else |
295 |
|
echo successful 1>&2 |
296 |
|
fi |
297 |
|
) |
298 |
|
fi |
299 |
} |
} |
300 |
|
|
301 |
makemodel() |
makemodel() |
305 |
cd $1; |
cd $1; |
306 |
if test -r Makefile ; then |
if test -r Makefile ; then |
307 |
printf 'make ... ' 1>&2 |
printf 'make ... ' 1>&2 |
308 |
$MAKE >> make.log 2>&1 |
if test "x$ADM" = x ; then |
309 |
|
$MAKE >> make.log 2>&1 |
310 |
|
else |
311 |
|
$MAKE adall >> make.log 2>&1 |
312 |
|
fi |
313 |
RETVAL=$? |
RETVAL=$? |
314 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
315 |
tail make.log |
tail make.log |
317 |
cp make.log $CDIR"/make.log" |
cp make.log $CDIR"/make.log" |
318 |
return 1 |
return 1 |
319 |
else |
else |
320 |
echo succesful 1>&2 |
echo successful 1>&2 |
321 |
fi |
fi |
322 |
fi |
fi |
323 |
) |
) |
324 |
} |
} |
325 |
|
|
326 |
|
symlink_mpifiles() |
327 |
|
{ |
328 |
|
# Put special links so that MPI specific files are used |
329 |
|
# This MUST be invoked between makeclean and makelinks because |
330 |
|
# the Makefile will link to non-mpi files by default |
331 |
|
|
332 |
|
dir=$1 |
333 |
|
code_dir=$2 |
334 |
|
BUILD_DIR=$dir/$3 |
335 |
|
CODE_DIR=$dir/$code_dir |
336 |
|
|
337 |
|
# These are files that should replace their counter-part when using -mpi |
338 |
|
MPI_FILES=`(cd $CODE_DIR; find . -name "*_mpi")` |
339 |
|
|
340 |
|
# Is this an MPI run? |
341 |
|
if test "x$MPI" = xt ; then |
342 |
|
# YES: We symbolically link these files to the build |
343 |
|
# dir so long as there is no real file in place |
344 |
|
for ii in $MPI_FILES ; do |
345 |
|
i=`echo $ii | sed 's:^\./::'` |
346 |
|
name=`echo $i | sed 's:_mpi::' ` |
347 |
|
cmp $CODE_DIR/$i $BUILD_DIR/$name > /dev/null 2>&1 |
348 |
|
RETVAL=$? |
349 |
|
if test "x$RETVAL" != x0 ; then |
350 |
|
if ! test -f $BUILD_DIR/$i ; then |
351 |
|
#echo Linking $name to $i |
352 |
|
(cd $BUILD_DIR; ln -sf ../$code_dir/$i $name) |
353 |
|
fi |
354 |
|
fi |
355 |
|
done |
356 |
|
else |
357 |
|
# NO: We undo any _mpi symbolically linked files |
358 |
|
for ii in $MPI_FILES ; do |
359 |
|
i=`echo $ii | sed 's:^\./::'` |
360 |
|
name=`echo $i | sed 's:_mpi::' ` |
361 |
|
if test -L $BUILD_DIR/$name ; then |
362 |
|
linktarg=`(cd $BUILD_DIR; readlink $name)` |
363 |
|
if test $linktarg = "../$code_dir/$name"_mpi ; then |
364 |
|
#echo Un-linking $name from $linktarg |
365 |
|
rm -f $BUILD_DIR/$name |
366 |
|
fi |
367 |
|
fi |
368 |
|
done |
369 |
|
fi |
370 |
|
|
371 |
|
} |
372 |
|
|
373 |
linkdata() |
linkdata() |
374 |
{ |
{ |
375 |
# linkdata flag |
# linkdata flag |
376 |
# |
# |
377 |
# symbolically link data files to run directory |
# symbolically link data files to run directory |
378 |
if [ $1 -ne 0 ]; then |
if test "x$1" = x1 ; then |
379 |
( cd $2 ; ln -sf ../input/* . ) |
( |
380 |
|
cd $2 |
381 |
|
if test "x$ADM" = x ; then |
382 |
|
files=`( cd ../input ; ls -1 | grep -v CVS )` |
383 |
|
for i in $files ; do |
384 |
|
if test ! -d "../input/"$i ; then |
385 |
|
ln -sf "../input/"$i $i |
386 |
|
fi |
387 |
|
done |
388 |
|
else |
389 |
|
files=`( cd ../input ; ls -1 *.bin | grep -v CVS )` |
390 |
|
for i in $files ; do |
391 |
|
if test ! -d "../input/"$i ; then |
392 |
|
ln -sf "../input/"$i $i |
393 |
|
fi |
394 |
|
done |
395 |
|
files=`( cd ../input_ad ; ls -1 | grep -v CVS )` |
396 |
|
for i in $files ; do |
397 |
|
if test ! -d "../input_ad/"$i ; then |
398 |
|
ln -sf "../input_ad/"$i $i |
399 |
|
fi |
400 |
|
done |
401 |
|
fi |
402 |
|
) |
403 |
fi |
fi |
404 |
} |
} |
405 |
|
|
406 |
runmodel() |
runmodel() |
407 |
{ |
{ |
408 |
# runmodel directory exe |
# runmodel directory |
409 |
# |
# |
410 |
# runs the model "exe" in "directory" (exe is relative to directory) |
# runs "$COMMAND in "directory" |
411 |
|
# (where "$COMMAND" is relative to "directory") |
412 |
( |
( |
413 |
cd $1 |
cd $1 |
414 |
if [ -x $2 ]; then |
printf 'runmodel ... ' 1>&2 |
415 |
if [ $quick -eq 0 ]; then |
# make output.txt |
416 |
rm -f output.txt |
echo |
417 |
fi |
# echo "COMMAND='$COMMAND'" |
418 |
printf 'runmodel: ' 1>&2 |
# echo "pwd='"`pwd`"'" |
419 |
$MAKE output.txt |
( eval $COMMAND ) >> run.log 2>&1 |
420 |
RETVAL=$? |
RETVAL=$? |
421 |
if test "x$RETVAL" = x0 ; then |
if test "x$RETVAL" = x0 ; then |
422 |
|
echo successful 1>&2 |
423 |
|
if test "x$ADM" = x ; then |
424 |
cp output.txt $CDIR"/output.txt" |
cp output.txt $CDIR"/output.txt" |
|
return 0 |
|
425 |
else |
else |
426 |
return 1 |
cp output.txt_adm $CDIR"/output.txt_adm" |
427 |
fi |
fi |
428 |
|
return 0 |
429 |
|
else |
430 |
|
tail run.log |
431 |
|
echo failed 1>&2 |
432 |
|
cp run.log $CDIR"/run.log" |
433 |
|
return 1 |
434 |
fi |
fi |
435 |
) |
) |
436 |
} |
} |
439 |
{ |
{ |
440 |
# create codelet for comparing model output |
# create codelet for comparing model output |
441 |
|
|
442 |
echo -n "creating the comparison code... " |
printf "creating the comparison code... " |
443 |
cat > tmp_cmpnum.f <<EOFA |
cat > tmp_cmpnum.c <<EOF |
444 |
program cmpnum |
#include <stdio.h> |
445 |
implicit none |
#include <math.h> |
446 |
real*8 a,b,diff |
int main( int argc, char** argv ) { |
447 |
integer linnum,best |
int linnum,best,lncnt; |
448 |
best=-16 |
double a,b,diff; |
449 |
99 read(*,*,end=70,err=60) linnum,a,b |
best = -16; |
450 |
diff=0.5*(abs(a)+abs(b)) |
lncnt = 0; |
451 |
c print *,a,b,diff,abs(a-b)/diff |
while( 1 & (lncnt+=1) < 999 ) { |
452 |
if (diff.gt.1.e-12) then |
scanf("%d", &linnum); |
453 |
diff=abs(a-b)/diff |
if (linnum == -1) break; |
454 |
if (diff.gt.0.) then |
scanf("%lf", &a); scanf("%lf", &b); |
455 |
c print *,int(log10(diff)),diff |
diff = 0.5*(fabs(a)+fabs(b)); |
456 |
linnum=int(log10(diff)) |
if (diff > 1.e-12) { |
457 |
best=max(best,linnum) |
diff=fabs(a-b)/diff; |
458 |
endif |
if (diff > 0.0) { |
459 |
else |
linnum = (int)log10(diff); |
460 |
if (best.eq.-16.and.diff.ne.0.) best=-22 |
best = (best > linnum) ? best : linnum; |
461 |
endif |
} |
462 |
goto 99 |
else { |
463 |
60 stop 'cmpnum: An error occured reading a,b' |
if (best == -16 && diff != 0) best = -22; |
464 |
70 print *,-best |
} |
465 |
end |
} |
466 |
EOFA |
} |
467 |
|
if (lncnt == 999) best=-29; |
468 |
|
printf("%d\n", -best); |
469 |
|
return 0; |
470 |
|
} |
471 |
|
EOF |
472 |
|
cc -o tmp_cmpnum tmp_cmpnum.c -lm |
473 |
|
|
474 |
f77 tmp_cmpnum.f |
if [ -x ./tmp_cmpnum ]; then |
|
if [ -x ./a.out ]; then |
|
475 |
echo "OK" |
echo "OK" |
476 |
return 0 |
return 0 |
477 |
else |
else |
478 |
echo |
echo |
479 |
echo "createcodelet: failed to compile codelet" |
echo "ERROR: failed to compile comparison code" |
480 |
exit 1 |
exit 1 |
481 |
fi |
fi |
482 |
} |
} |
508 |
{ |
{ |
509 |
cat - << EOF |
cat - << EOF |
510 |
$0 [-help] [-quick] [-verbose] dir1 [dir2] [...] |
$0 [-help] [-quick] [-verbose] dir1 [dir2] [...] |
511 |
-help Show this help message |
|
512 |
-quick Skip "genmake" and "make depend" if the Makefile exists |
-help|-h Show this help message |
513 |
-quiet Reduce the amount of output |
-quiet Reduce the amount of output |
514 |
-verbose Produce copious amounts of output |
-verbose Produce copious amounts of output |
515 |
-debug Produce even more output which will mean nothing to most |
-debug Produce even more output which will mean nothing to most |
516 |
-force Do "make CLEAN" before compiling. This forces a complete rebuild. |
-force Do "make CLEAN" before compiling. This forces a complete rebuild. |
517 |
-clean Do "make CLEAN" after compiling and testing. |
-clean Do "make CLEAN" after compiling and testing. |
|
-noieee By default, $0 uses the -ieee option for genmake. This turns it off. |
|
518 |
-cleanup Aggresively removes all model output, executables and object files |
-cleanup Aggresively removes all model output, executables and object files |
519 |
and then exits. Use with care. |
and then exits. Use with care. |
520 |
|
|
536 |
|
|
537 |
|
|
538 |
############################################################################### |
############################################################################### |
|
############################################################################### |
|
|
############################################################################### |
|
539 |
|
|
540 |
|
|
541 |
# Default properties |
# Default properties |
542 |
debug=0 |
debug=0 |
543 |
verbose=1 |
verbose=1 |
|
quick=0 |
|
544 |
clean=0 |
clean=0 |
|
ieee=1 |
|
545 |
expts='' |
expts='' |
546 |
|
# ieee=1 |
547 |
|
|
548 |
|
IEEE= |
549 |
|
if test "x$MITGCM_IEEE" != x ; then |
550 |
|
IEEE=$MITGCM_IEEE |
551 |
|
fi |
552 |
|
|
553 |
|
|
554 |
|
CLEANUP=f |
555 |
|
QUICK=f |
556 |
|
NOGENMAKE=f |
557 |
|
NOCLEAN=f |
558 |
|
NODEPEND=f |
559 |
|
|
560 |
BASH= |
BASH= |
561 |
OPTFILES= |
OPTFILE=NONE |
562 |
ADDRESSES=edhill@mitgcm.org |
ADDRESSES= |
563 |
TESTDIRS= |
TESTDIRS= |
564 |
MPACKDIR="../tools/mpack-1.6" |
MPACKDIR="../tools/mpack-1.6" |
565 |
|
HAVE_MPACK= |
566 |
MPACK="$MPACKDIR/mpack" |
MPACK="$MPACKDIR/mpack" |
567 |
|
COMMAND= |
568 |
MAKE=make |
MAKE=make |
569 |
|
MPI=f |
570 |
|
|
571 |
|
ADM= |
572 |
|
|
573 |
echo -n "parsing options... " |
printf "parsing options... " |
574 |
|
|
575 |
ac_prev= |
ac_prev= |
576 |
for ac_option ; do |
for ac_option ; do |
590 |
usage ;; |
usage ;; |
591 |
|
|
592 |
-optfile | --optfile | -of | --of) |
-optfile | --optfile | -of | --of) |
593 |
ac_prev=OPTFILES ;; |
ac_prev=OPTFILE ;; |
594 |
-optfile=* | --optfile=* | -of=* | --of=*) |
-optfile=* | --optfile=* | -of=* | --of=*) |
595 |
OPTFILES=$ac_optarg ;; |
OPTFILE=$ac_optarg ;; |
596 |
|
|
597 |
-addr | --addr | -a | --a) |
-addr | --addr | -a | --a) |
598 |
ac_prev=ADDRESSES ;; |
ac_prev=ADDRESSES ;; |
609 |
-bash=* | --bash=*) |
-bash=* | --bash=*) |
610 |
BASH=$ac_optarg ;; |
BASH=$ac_optarg ;; |
611 |
|
|
612 |
|
-command | --command | -c | --c) |
613 |
|
ac_prev=COMMAND ;; |
614 |
|
-command=* | --command=*) |
615 |
|
COMMAND=$ac_optarg ;; |
616 |
|
|
617 |
-make | --make | -m | --m) |
-make | --make | -m | --m) |
618 |
ac_prev=MAKE ;; |
ac_prev=MAKE ;; |
619 |
-make=* | --make=*) |
-make=* | --make=*) |
620 |
MAKE=$ac_optarg ;; |
MAKE=$ac_optarg ;; |
621 |
|
|
622 |
|
-clean | --clean) |
623 |
|
CLEANUP=t ;; |
624 |
|
|
625 |
|
-quick | --quick | -q | --q) |
626 |
|
QUICK=t ;; |
627 |
|
-nogenmake | --nogenmake | -ng | --ng) |
628 |
|
NOGENMAKE=t ;; |
629 |
|
-noclean | --noclean | -nc | --nc) |
630 |
|
NOCLEAN=t ;; |
631 |
|
-nodepend | --nodepend | -nd | --nd) |
632 |
|
NODEPEND=t ;; |
633 |
|
|
634 |
|
-mpi) MPI=t ;; |
635 |
|
|
636 |
|
-adm | -ad) ADM=t ;; |
637 |
|
|
638 |
|
-ieee) IEEE=true ;; |
639 |
|
-noieee) IEEE= ;; |
640 |
|
|
|
-quick) quick=1 ;; |
|
641 |
-verbose) verbose=2 ;; |
-verbose) verbose=2 ;; |
642 |
-debug) debug=1 ;; |
-debug) debug=1 ;; |
|
-clean) clean=1 ;; |
|
|
-noieee) ieee=0 ;; |
|
643 |
-quiet) verbose=0 ;; |
-quiet) verbose=0 ;; |
644 |
|
|
645 |
-*) |
-*) |
656 |
|
|
657 |
done |
done |
658 |
|
|
659 |
|
if test "x$QUICK" = xt ; then |
660 |
|
NOGENMAKE=t |
661 |
|
NOCLEAN=t |
662 |
|
NODEPEND=t |
663 |
|
fi |
664 |
|
|
665 |
if test "x$TESTDIRS" = x ; then |
if test "x$TESTDIRS" = x ; then |
666 |
TESTDIRS=`scandirs` |
TESTDIRS=`scandirs` |
667 |
fi |
fi |
668 |
|
|
669 |
|
if test "x$OPTFILE" = xNONE -a "x$MITGCM_OF" != x ; then |
670 |
|
OPTFILE=$MITGCM_OF |
671 |
|
fi |
672 |
|
|
673 |
|
if test "x$ADM" = xt -a "x$COMMAND" = x ; then |
674 |
|
COMMAND="./mitgcmuv_ad > output.txt_adm 2>&1" |
675 |
|
fi |
676 |
|
|
677 |
|
if test "x$COMMAND" = x ; then |
678 |
|
COMMAND="make output.txt" |
679 |
|
fi |
680 |
|
|
681 |
echo "OK" |
echo "OK" |
682 |
|
|
683 |
# create the FORTRAN comparison code |
# create the FORTRAN comparison code |
684 |
createcodelet |
createcodelet |
685 |
|
|
686 |
# build the mpack utility |
# build the mpack utility |
687 |
build_mpack |
if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then |
688 |
|
echo "skipping mpack build" |
689 |
|
else |
690 |
|
build_mpack |
691 |
|
fi |
692 |
|
|
693 |
# Create a uniquely named directory to store results |
# Create a uniquely named directory to store results |
694 |
MACH=`hostname` |
MACH=`hostname` |
695 |
UNAMEA=`uname -a` |
UNAMEA=`uname -a` |
696 |
DATE=`date +%Y%m%d` |
DATE=`date +%Y%m%d` |
697 |
BASE=$MACH"_"$DATE"_" |
BASE="tr_"$MACH"_"$DATE"_" |
698 |
DNUM=0 |
DNUM=0 |
699 |
DRESULTS="$BASE$DNUM" |
DRESULTS="$BASE$DNUM" |
700 |
while test -e $DRESULTS ; do |
while test -e $DRESULTS ; do |
704 |
mkdir $DRESULTS |
mkdir $DRESULTS |
705 |
RETVAL=$? |
RETVAL=$? |
706 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
707 |
echo "Error: can't create results directory \"./$DRESULTS\"" |
echo "ERROR: Can't create results directory \"./$DRESULTS\"" |
708 |
exit 1 |
exit 1 |
709 |
fi |
fi |
710 |
SUMMARY="$DRESULTS/summary.txt" |
SUMMARY="$DRESULTS/summary.txt" |
711 |
date > $SUMMARY |
printf "Start time: " >> $SUMMARY |
712 |
cat << EOF >> $SUMMARY |
start_date=`date` |
713 |
|
echo $start_date > $SUMMARY |
714 |
|
|
715 |
|
of_path= |
716 |
|
if test "x$OPTFILE" != xNONE ; then |
717 |
|
if test -r $OPTFILE ; then |
718 |
|
# get the path |
719 |
|
path=${OPTFILE%/*} |
720 |
|
if test "x$path" = x ; then |
721 |
|
of_path=`pwd` |
722 |
|
else |
723 |
|
of_path=`( cd $path > /dev/null 2>&1 ; pwd )` |
724 |
|
fi |
725 |
|
file=${OPTFILE##*/} |
726 |
|
OPTFILE=$of_path/$file |
727 |
|
cp $OPTFILE $DRESULTS |
728 |
|
echo >> $SUMMARY |
729 |
|
echo " OPTFILE=$OPTFILE" >> $SUMMARY |
730 |
|
else |
731 |
|
echo | tee $SUMMARY |
732 |
|
echo "ERROR: can't read OPTFILE=\"$OPTFILE\"" | tee $SUMMARY |
733 |
|
exit 1 |
734 |
|
fi |
735 |
|
else |
736 |
|
echo >> $SUMMARY |
737 |
|
echo "No \"OPTFILE\" was explicitly specified by testreport," >> $SUMMARY |
738 |
|
echo " so the genmake default will be used." >> $SUMMARY |
739 |
|
fi |
740 |
|
echo |
741 |
|
echo >> $SUMMARY |
742 |
|
if test "x$ADM" = x ; then |
743 |
|
cat << EOF | tee -a $SUMMARY |
744 |
T S U V |
T S U V |
745 |
G D M c m s m s m s m s |
G D M c m s m s m s m s |
746 |
E p a R g m m e . m m e . m m e . m m e . |
E p a R g m m e . m m e . m m e . m m e . |
748 |
2 d e n d n x n . n x n . n x n . n x n . |
2 d e n d n x n . n x n . n x n . n x n . |
749 |
|
|
750 |
EOF |
EOF |
751 |
|
else |
752 |
|
echo "ADJOINT=true" >> $SUMMARY |
753 |
|
echo >> $SUMMARY |
754 |
|
cat << EOF | tee -a $SUMMARY |
755 |
|
G D M C G |
756 |
|
E p a R o r |
757 |
|
N n k u s a |
758 |
|
2 d e n t d |
759 |
|
|
760 |
NDIR=0 |
EOF |
761 |
|
fi |
762 |
|
|
763 |
# For each optfile... |
# ...and each test directory... |
764 |
for OPTFILE in $OPTFILES ; do |
for dir in $TESTDIRS ; do |
765 |
|
|
766 |
|
# Cleanup only! |
767 |
|
if test "x$CLEANUP" = xt ; then |
768 |
|
if test -r $dir/build/Makefile ; then |
769 |
|
( cd $dir/build ; make CLEAN ) |
770 |
|
fi |
771 |
|
if test -r $dir/input/Makefile ; then |
772 |
|
( cd $dir/input ; make CLEAN ) |
773 |
|
fi |
774 |
|
continue |
775 |
|
fi |
776 |
|
|
777 |
|
# Verify that the testdir exists and contains previous |
778 |
|
# results in the correct location--or skip this directory! |
779 |
|
fout= |
780 |
|
if test "x$ADM" = x ; then |
781 |
|
fout=$dir"/results/output.txt" |
782 |
|
else |
783 |
|
fout=$dir"/results_ad/output.txt_adm" |
784 |
|
fi |
785 |
|
if test ! -r $fout ; then |
786 |
|
echo "can't read \"$fout\" -- skipping $dir" |
787 |
|
continue |
788 |
|
fi |
789 |
|
|
790 |
OPTFILE=`pwd`"/$OPTFILE" |
builddir="input" |
791 |
if test ! -r $OPTFILE ; then |
rundir="input" |
792 |
echo "Error: can't read optfile \"$OPTFILE\"" |
use_seperate_build=0 |
793 |
exit 1 |
if test -d $dir/build -a -r $dir/build ; then |
794 |
|
builddir="build" |
795 |
|
rundir="build" |
796 |
|
use_seperate_build=1 |
797 |
|
linkdata $use_seperate_build $dir/$rundir |
798 |
fi |
fi |
|
echo |
|
|
echo "OPTFILE=$OPTFILE" >> $SUMMARY |
|
|
echo >> $SUMMARY |
|
799 |
|
|
800 |
# ...and each test directory... |
# Check whether there are "extra runs" for this testdir |
801 |
for dir in $TESTDIRS ; do |
extra_runs= |
802 |
|
if test "x$ADM" = x -a "x$use_seperate_build" = x1 ; then |
803 |
|
ex_run_dirs=`( cd $dir ; echo input.* )` |
804 |
|
echo "ex_run_dirs='$ex_run_dirs'" |
805 |
|
for exd in $ex_run_dirs ; do |
806 |
|
name=`echo $exd | sed -e 's/input.//g'` |
807 |
|
outf="$dir/results/output.txt.$name" |
808 |
|
if test -f $outf -a -r $outf ; then |
809 |
|
extra_runs="$extra_runs $name" |
810 |
|
fi |
811 |
|
done |
812 |
|
fi |
813 |
|
|
814 |
# Verify that the testdir exists and contains previous |
if test "x$ADM" = x ; then |
815 |
# results in the correct location--or skip this directory! |
code_dir=code |
816 |
if test ! -r $dir"/results/output.txt" ; then |
CODE_DIR=$dir/code |
817 |
echo | tee -a $SUMMARY |
else |
818 |
echo "can't read \"$dir/results/output.txt\" -- skipping $dir" \ |
code_dir=code_ad |
819 |
| tee -a $SUMMARY |
CODE_DIR=$dir/code_ad |
820 |
continue |
fi |
821 |
fi |
BUILD_DIR=$dir/$builddir |
|
|
|
|
# Create an output dir for each OPTFILE/tdir combination |
|
|
CDIR=$DRESULTS"/"$DRESULTS"_"$NDIR |
|
|
mkdir $CDIR |
|
|
CDIR=`pwd`"/$CDIR" |
|
822 |
|
|
823 |
# ...configue, make, run, and compare the output. |
if test ! -r $CODE_DIR"/SIZE.h_mpi" -a "x$MPI" = "xt" ; then |
824 |
echo "-------------------------------------------------------------------------------" |
echo "can't find \"$CODE_DIR/SIZE.h_mpi\" -- skipping $dir" |
825 |
echo |
continue |
826 |
echo "Experiment: $dir" |
fi |
827 |
echo |
|
828 |
unset genmake makedepend make run |
echo "-------------------------------------------------------------------------------" |
829 |
results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --' |
echo |
830 |
( cd $dir/input; rm -f *.{o,f,c,F} *.[f,F]90 work* output.txt Make* make.log; ) |
echo "Experiment: $dir" |
831 |
if [ -r $dir/build ]; then |
echo |
832 |
seperatebuilddir=1 |
unset genmake makedepend make run |
833 |
builddir=build |
results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --' |
|
rundir=build |
|
|
( cd $dir/build; ln -sf ../input/* . ) |
|
|
else |
|
|
seperatebuilddir=0 |
|
|
builddir=input |
|
|
rundir=input |
|
|
fi |
|
834 |
|
|
835 |
|
# Create an output dir for each OPTFILE/tdir combination |
836 |
|
rel_CDIR=$DRESULTS"/"$dir |
837 |
|
mkdir $rel_CDIR |
838 |
|
CDIR=`pwd`"/$rel_CDIR" |
839 |
|
|
840 |
|
if test "x$CLEANUP" = xt ; then |
841 |
|
makeclean $dir/$builddir |
842 |
|
else |
843 |
genmakemodel $dir/$builddir && genmake=Y \ |
genmakemodel $dir/$builddir && genmake=Y \ |
844 |
&& makeclean $dir/$builddir \ |
&& makeclean $dir/$builddir \ |
845 |
|
&& symlink_mpifiles $dir $code_dir $builddir \ |
846 |
&& makedependmodel $dir/$builddir && makedepend=Y \ |
&& makedependmodel $dir/$builddir && makedepend=Y \ |
847 |
&& makemodel $dir/$builddir && make=Y \ |
&& makemodel $dir/$builddir && make=Y \ |
848 |
&& linkdata $seperatebuilddir $dir/$rundir \ |
&& linkdata $use_seperate_build $dir/$rundir \ |
849 |
&& runmodel $dir/$builddir mitgcmuv && run=Y \ |
&& runmodel $dir/$rundir && run=Y \ |
850 |
&& results=`testoutput $dir $rundir` |
&& results=`testoutput $dir $rundir` |
851 |
|
fi |
852 |
|
|
853 |
|
echo |
854 |
|
if test "x$ADM" = x ; then |
855 |
|
fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results` |
856 |
echo |
echo |
857 |
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
echo "$fres" >> $SUMMARY |
858 |
${run:-N} $results |
echo "fresults='$fres'" > $CDIR"/summary.txt" |
|
echo |
|
|
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
|
|
${run:-N} $results >> $SUMMARY |
|
|
echo "fresults='" > $CDIR"/summary.txt" |
|
|
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
|
|
${run:-N} $results >> $CDIR"/summary.txt" |
|
|
echo "'" >> $CDIR"/summary.txt" |
|
859 |
echo "MACH='$MACH'" >> $CDIR"/summary.txt" |
echo "MACH='$MACH'" >> $CDIR"/summary.txt" |
860 |
echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt" |
echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt" |
861 |
echo "DATE='$DATE'" >> $CDIR"/summary.txt" |
echo "DATE='$DATE'" >> $CDIR"/summary.txt" |
862 |
echo "tdir='$dir'" >> $CDIR"/summary.txt" |
echo "tdir='$dir'" >> $CDIR"/summary.txt" |
863 |
|
|
864 |
( |
OLD_COMMAND=$COMMAND |
865 |
cd $DRESULTS |
COMMAND="./mitgcmuv > output.txt" |
866 |
tar -cf $NDIR".tar" $DRESULTS"_"$NDIR > /dev/null 2>&1 |
for ex in $extra_runs ; do |
867 |
gzip $NDIR".tar" |
test -e "$dir/tr_run" && rm -rf "$dir/tr_run" |
868 |
) |
mkdir "$dir/tr_run" |
869 |
|
links=`( cd "$dir/input" > /dev/null 2>&1 ; ls -1 | grep -v CVS )` |
870 |
|
( |
871 |
|
cd "$dir/tr_run" |
872 |
|
for i in $links; do |
873 |
|
ln -s ../input/$i $i |
874 |
|
done |
875 |
|
) |
876 |
|
links=`( cd "$dir/input.$ex" > /dev/null 2>&1 ; ls -1 | grep -v CVS )` |
877 |
|
( |
878 |
|
cd "$dir/tr_run" |
879 |
|
for i in $links; do |
880 |
|
test -e $i && rm -f $i |
881 |
|
ln -s ../input.$ex/$i $i |
882 |
|
done |
883 |
|
ln -s ../$builddir/mitgcmuv mitgcmuv |
884 |
|
) |
885 |
|
runmodel $dir/tr_run && run=Y \ |
886 |
|
&& results=`testoutput $dir tr_run "."$ex` |
887 |
|
fres=`printf '%s %s %s %s' ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N}` |
888 |
|
fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results` |
889 |
|
fres="$fres.$ex" |
890 |
|
echo |
891 |
|
echo "$fres" >> $SUMMARY |
892 |
|
echo "fresults='$fres'" > $CDIR"/summary.txt" |
893 |
|
echo "MACH='$MACH'" >> $CDIR"/summary.txt" |
894 |
|
echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt" |
895 |
|
echo "DATE='$DATE'" >> $CDIR"/summary.txt" |
896 |
|
echo "tdir='$dir'" >> $CDIR"/summary.txt" |
897 |
|
done |
898 |
|
COMMAND=$OLD_COMMAND |
899 |
|
else |
900 |
|
fres=`printf '%s %s %s %s' ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N}` |
901 |
|
fres=$fres"$results $dir" |
902 |
|
echo |
903 |
|
echo "$fres" >> $SUMMARY |
904 |
|
echo "fresults='$fres'" > $CDIR"/summary.txt" |
905 |
|
echo "MACH='$MACH'" >> $CDIR"/summary.txt" |
906 |
|
echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt" |
907 |
|
echo "DATE='$DATE'" >> $CDIR"/summary.txt" |
908 |
|
echo "tdir='$dir'" >> $CDIR"/summary.txt" |
909 |
|
fi |
910 |
|
|
911 |
|
echo "-------------------------------------------------------------------------------" |
912 |
|
|
913 |
|
done |
914 |
|
|
915 |
$MPACK -s MITgcm-test -m 1000000 $DRESULTS"/"$NDIR".tar.gz" $ADDRESSES |
printf "Start time: " >> $SUMMARY |
916 |
|
echo $start_date >> $SUMMARY |
917 |
|
printf "End time: " >> $SUMMARY |
918 |
|
date >> $SUMMARY |
919 |
|
|
920 |
|
# If addresses were supplied and mpack built successfully, then try |
921 |
|
# to send email using mpack. |
922 |
|
if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then |
923 |
|
echo "No results email was sent." |
924 |
|
else |
925 |
|
if test "x$HAVE_MPACK" = xt ; then |
926 |
|
tar -cf $DRESULTS".tar" $DRESULTS > /dev/null 2>&1 \ |
927 |
|
&& gzip $DRESULTS".tar" \ |
928 |
|
&& $MPACK -s MITgcm-test -m 1500000 $DRESULTS".tar.gz" $ADDRESSES |
929 |
RETVAL=$? |
RETVAL=$? |
930 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
931 |
echo "Warning: \"$MPACK\" failed -- please contact <edhill@mitgcm.org>" |
echo |
932 |
|
echo "Warning: The tar, gzip, & mpack step failed. Please send email" |
933 |
|
echo " to <MITgcm-support@mitgcm.org> for help. You may copy the " |
934 |
|
echo " summary of results from the directory \"$DRESULTS\"." |
935 |
|
echo |
936 |
else |
else |
937 |
rm -f $DRESULTS"/"$NDIR".tar*" |
echo |
938 |
|
echo "An email containing results was sent to the following addresses:" |
939 |
|
echo " \"$ADDRESSES\"" |
940 |
|
echo |
941 |
fi |
fi |
942 |
|
test -f $DRESULTS".tar" && rm -f $DRESULTS".tar" |
943 |
|
test -f $DRESULTS".tar.gz" && rm -f $DRESULTS".tar.gz" |
944 |
|
fi |
945 |
|
fi |
946 |
|
|
947 |
NDIR=$(( $NDIR + 1 )) |
# rm -f tmp_cmpnum.f a.out |
948 |
|
rm -f tmp_cmpnum.c tmp_cmpnum |
|
done |
|
|
done |
|
|
|
|
|
rm tmp_cmpnum.f a.out |
|
949 |
|
|
950 |
cat $SUMMARY |
if test "x$CLEANUP" != xt ; then |
951 |
|
cat $SUMMARY |
952 |
|
if test -e tr_out.txt ; then |
953 |
|
mv tr_out.txt tr_out.txt.old |
954 |
|
fi |
955 |
|
cat $SUMMARY > tr_out.txt |
956 |
|
fi |
957 |
|
|