1 |
#!/bin/bash |
#! /usr/bin/env bash |
2 |
# |
# |
3 |
# $Header$ |
# $Header$ |
4 |
# $Name$ |
# $Name$ |
13 |
echo " (-help|-h) print usage" |
echo " (-help|-h) print usage" |
14 |
echo " (-mpi) use MPI input files" |
echo " (-mpi) use MPI input files" |
15 |
echo " (-ieee|-noieee) if possible, use IEEE compiler flags" |
echo " (-ieee|-noieee) if possible, use IEEE compiler flags" |
16 |
|
echo " (DEF=\"noieee\")" |
17 |
echo " (-optfile=|-of=)STRING list of optfiles to use" |
echo " (-optfile=|-of=)STRING list of optfiles to use" |
18 |
echo " (-a|-addr)STRING list of email recipients" |
echo " (-a|-addr) STRING list of email recipients" |
19 |
echo " (DEF=\"edhill@mitgcm.org\")" |
echo " (DEF=\"edhill@mitgcm.org\")" |
20 |
echo " (-t|-tdir)STRING list of test dirs to use" |
echo " (-t|-tdir) STRING list of test dirs to use" |
21 |
echo " (DEF=\"\" which builds all)" |
echo " (DEF=\"\" which builds all)" |
22 |
echo " (-b|-bash)STRING location of \"bash\" executable" |
echo " (-b|-bash) STRING preferred location of a \"bash\" or" |
23 |
echo " (DEF=\"\" for \"/bin/bash\")" |
echo " Bourne-compatible \"sh\" shell" |
24 |
echo " (-command)STRING command to run" |
echo " (DEF=\"\" for \"bash\")" |
25 |
|
echo " (-command) STRING command to run" |
26 |
echo " (DEF=\"make output.txt\")" |
echo " (DEF=\"make output.txt\")" |
27 |
echo " (-m|-make)STRING command to use for \"make\"" |
echo " (-m|-make) STRING command to use for \"make\"" |
28 |
echo " (DEF=\"make\")" |
echo " (DEF=\"make\")" |
29 |
echo " (-clean) *ONLY* run \"make CLEAN\"" |
echo " (-clean) *ONLY* run \"make CLEAN\"" |
30 |
echo " (-quick|-q) same as \"-nogenmake -noclean -nodepend\"" |
echo " (-quick|-q) same as \"-nogenmake -noclean -nodepend\"" |
46 |
echo -n "building the mpack utility... " |
echo -n "building the mpack utility... " |
47 |
if test ! -x "$MPACKDIR/mpack" ; then |
if test ! -x "$MPACKDIR/mpack" ; then |
48 |
if test ! -d $MPACKDIR ; then |
if test ! -d $MPACKDIR ; then |
49 |
|
echo |
50 |
echo "Error: can't find \"$MPACKDIR\"" |
echo "Error: can't find \"$MPACKDIR\"" |
51 |
echo " are you sure this program is being run in the correct " |
echo " are you sure this program is being run in the correct " |
52 |
echo " (that is, \"MITGCM_ROOT\verification\") directory?" |
echo " (that is, \"MITGCM_ROOT\verification\") directory?" |
53 |
exit 1 |
echo |
54 |
|
HAVE_MPACK=f |
55 |
fi |
fi |
56 |
echo -n "building mpack... " |
echo -n "building mpack... " |
57 |
( cd $MPACKDIR && ./configure && $MAKE ) > build_mpack.out 2>&1 |
( cd $MPACKDIR && ./configure && $MAKE ) > build_mpack.out 2>&1 |
59 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
60 |
echo |
echo |
61 |
echo "Error building the mpack tools at: $MPACK_DIR" |
echo "Error building the mpack tools at: $MPACK_DIR" |
62 |
exit 1 |
echo |
63 |
|
HAVE_MPACK=f |
64 |
|
else |
65 |
|
HAVE_MPACK=t |
66 |
fi |
fi |
67 |
|
else |
68 |
|
HAVE_MPACK=t |
69 |
fi |
fi |
70 |
echo "OK" |
echo "OK" |
71 |
} |
} |
72 |
|
|
|
compare_lines() |
|
|
{ |
|
|
# use codelet to compare lines |
|
|
if [ $verbose -gt 1 ]; then |
|
|
cat tmp3.txt 1>&2 |
|
|
fi |
|
|
return `./a.out < tmp3.txt` |
|
|
} |
|
|
|
|
73 |
testoutput_for_prop() |
testoutput_for_prop() |
74 |
{ |
{ |
75 |
# testoutput_for_prop dir s1 label subdir |
# testoutput_for_prop dir s1 label subdir |
81 |
echo testoutput_for_prop: grep "$2" $1/$4/output.txt 1>&2 |
echo testoutput_for_prop: grep "$2" $1/$4/output.txt 1>&2 |
82 |
fi |
fi |
83 |
if [ -r $1/$4/output.txt ]; then |
if [ -r $1/$4/output.txt ]; then |
84 |
grep "$2" $1/$4/output.txt | sed 's/.*=//' | nl > tmp1.txt |
grep "$2" $1/$4/output.txt | sed 's/.*=//' | cat -n > tmp1.txt |
85 |
lncnt=`wc -l tmp1.txt | awk '{print $1}' ` |
lncnt=`wc -l tmp1.txt | awk '{print $1}' ` |
86 |
if [ $lncnt -lt 3 ]; then |
if [ $lncnt -lt 3 ]; then |
87 |
if [ $verbose -gt 0 ]; then |
if [ $verbose -gt 0 ]; then |
96 |
if [ $debug -gt 0 ]; then |
if [ $debug -gt 0 ]; then |
97 |
echo testoutput_for_prop: grep "$2" $1/results/output.txt 1>&2 |
echo testoutput_for_prop: grep "$2" $1/results/output.txt 1>&2 |
98 |
fi |
fi |
99 |
grep "$2" $1/results/output.txt | sed 's/.*=//' | nl > tmp2.txt |
grep "$2" $1/results/output.txt | sed 's/.*=//' | cat -n > tmp2.txt |
100 |
lncnt=`wc -l tmp2.txt | awk '{print $1}' ` |
lncnt=`wc -l tmp2.txt | awk '{print $1}' ` |
101 |
if [ $lncnt -lt 3 ]; then |
if [ $lncnt -lt 3 ]; then |
102 |
if [ $verbose -gt 0 ]; then |
if [ $verbose -gt 0 ]; then |
111 |
if [ $debug -gt 0 ]; then |
if [ $debug -gt 0 ]; then |
112 |
echo testoutput_for_prop: compare_lines 1>&2 |
echo testoutput_for_prop: compare_lines 1>&2 |
113 |
fi |
fi |
114 |
compare_lines |
if [ $verbose -gt 1 ]; then |
115 |
digits_of_similarity=$? |
cat tmp3.txt 1>&2 |
116 |
|
fi |
117 |
|
echo "-1" >> tmp3.txt |
118 |
|
# On the SGI O3K (*not* the O2K), "cat -n" inserts a ":" after the line number |
119 |
|
cat tmp3.txt | sed -e 's|:||g' > tmp4.txt |
120 |
|
digits_of_similarity=`./tmp_cmpnum < tmp4.txt` |
121 |
if [ $digits_of_similarity -eq 99 ]; then |
if [ $digits_of_similarity -eq 99 ]; then |
122 |
if [ $verbose -gt 0 ]; then |
if [ $verbose -gt 0 ]; then |
123 |
echo testoutput_for_prop: No comparison was available for \"$2\" 1>&2 |
echo testoutput_for_prop: No comparison was available for \"$2\" 1>&2 |
128 |
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 |
129 |
fi |
fi |
130 |
fi |
fi |
131 |
rm tmp1.txt tmp2.txt tmp3.txt |
rm -f tmp1.txt tmp2.txt tmp3.txt tmp4.txt |
132 |
|
|
133 |
return $digits_of_similarity |
return $digits_of_similarity |
134 |
} |
} |
194 |
command="$GENMAKE2 -ds -m $MAKE --mods=../code" |
command="$GENMAKE2 -ds -m $MAKE --mods=../code" |
195 |
if test "x$OPTFILE" != xNONE ; then |
if test "x$OPTFILE" != xNONE ; then |
196 |
command="$command --optfile=$OPTFILE" |
command="$command --optfile=$OPTFILE" |
|
# echo " command=\"$command\"" |
|
197 |
fi |
fi |
198 |
if test "x$IEEE" != x ; then |
if test "x$IEEE" != x ; then |
199 |
command="$command -ieee" |
command="$command -ieee" |
200 |
fi |
fi |
|
# echo "command: \"$command\"" |
|
201 |
printf 'genmake ... ' 1>&2 |
printf 'genmake ... ' 1>&2 |
202 |
$command > make.log 2>&1 |
$command > make.log 2>&1 |
203 |
RETVAL=$? |
RETVAL=$? |
204 |
for i in genmake_state genmake_optfile genmake_local Makefile ; do |
cp Makefile $CDIR |
|
if test -r $i ; then |
|
|
cp $i $CDIR |
|
|
fi |
|
|
done |
|
205 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
206 |
tail make.log |
tail make.log |
207 |
echo "genmakemodel: genmake failed" 1>&2 |
echo "genmakemodel: genmake failed" 1>&2 |
208 |
cp make.log $CDIR |
cp genmake_* make.log $CDIR |
209 |
return 1 |
return 1 |
210 |
else |
else |
211 |
echo "succesful" 1>&2 |
echo "successful" 1>&2 |
212 |
fi |
fi |
213 |
) |
) |
214 |
fi |
fi |
236 |
return 1 |
return 1 |
237 |
fi |
fi |
238 |
fi |
fi |
239 |
echo succesful 1>&2 |
echo successful 1>&2 |
240 |
exit 0 |
exit 0 |
241 |
) |
) |
242 |
fi |
fi |
259 |
cp make.log $CDIR"/make.log" |
cp make.log $CDIR"/make.log" |
260 |
return 1 |
return 1 |
261 |
else |
else |
262 |
echo succesful 1>&2 |
echo successful 1>&2 |
263 |
fi |
fi |
264 |
) |
) |
265 |
fi |
fi |
280 |
cp make.log $CDIR"/make.log" |
cp make.log $CDIR"/make.log" |
281 |
return 1 |
return 1 |
282 |
else |
else |
283 |
echo succesful 1>&2 |
echo successful 1>&2 |
284 |
fi |
fi |
285 |
fi |
fi |
286 |
) |
) |
312 |
# (where "$COMMAND" is relative to "directory") |
# (where "$COMMAND" is relative to "directory") |
313 |
( |
( |
314 |
cd $1 |
cd $1 |
315 |
printf 'runmodel: ' 1>&2 |
printf 'runmodel ... ' 1>&2 |
316 |
# make output.txt |
# make output.txt |
317 |
$COMMAND |
$COMMAND >> run.log 2>&1 |
318 |
RETVAL=$? |
RETVAL=$? |
319 |
if test "x$RETVAL" = x0 ; then |
if test "x$RETVAL" = x0 ; then |
320 |
|
echo successful 1>&2 |
321 |
cp output.txt $CDIR"/output.txt" |
cp output.txt $CDIR"/output.txt" |
322 |
return 0 |
return 0 |
323 |
else |
else |
324 |
|
tail run.log |
325 |
|
echo failed 1>&2 |
326 |
|
cp run.log $CDIR"/run.log" |
327 |
return 1 |
return 1 |
328 |
fi |
fi |
329 |
) |
) |
334 |
# create codelet for comparing model output |
# create codelet for comparing model output |
335 |
|
|
336 |
echo -n "creating the comparison code... " |
echo -n "creating the comparison code... " |
337 |
cat > tmp_cmpnum.f <<EOFA |
cat > tmp_cmpnum.c <<EOF |
338 |
program cmpnum |
#include <stdio.h> |
339 |
implicit none |
#include <math.h> |
340 |
real*8 a,b,diff |
int main( int argc, char** argv ) { |
341 |
integer linnum,best |
int linnum,best; |
342 |
best=-16 |
double a,b,diff; |
343 |
99 read(*,*,end=70,err=60) linnum,a,b |
best = -16; |
344 |
diff=0.5*(abs(a)+abs(b)) |
while( 1 ) { |
345 |
c print *,a,b,diff,abs(a-b)/diff |
scanf("%d", &linnum); |
346 |
if (diff.gt.1.e-12) then |
if (linnum == -1) break; |
347 |
diff=abs(a-b)/diff |
scanf("%lf", &a); scanf("%lf", &b); |
348 |
if (diff.gt.0.) then |
diff = 0.5*(fabs(a)+fabs(b)); |
349 |
c print *,int(log10(diff)),diff |
if (diff > 1.e-12) { |
350 |
linnum=int(log10(diff)) |
diff=fabs(a-b)/diff; |
351 |
best=max(best,linnum) |
if (diff > 0.0) { |
352 |
endif |
linnum = (int)log10(diff); |
353 |
else |
best = (best > linnum) ? best : linnum; |
354 |
if (best.eq.-16.and.diff.ne.0.) best=-22 |
} |
355 |
endif |
else { |
356 |
goto 99 |
if (best == -16 && diff != 0) best = -22; |
357 |
60 stop 'cmpnum: An error occured reading a,b' |
} |
358 |
70 print *,-best |
} |
359 |
end |
} |
360 |
EOFA |
printf("%d\n", -best); |
361 |
|
return 0; |
362 |
|
} |
363 |
|
EOF |
364 |
|
cc -o tmp_cmpnum tmp_cmpnum.c -lm |
365 |
|
|
366 |
f77 tmp_cmpnum.f |
if [ -x ./tmp_cmpnum ]; then |
|
if [ -x ./a.out ]; then |
|
367 |
echo "OK" |
echo "OK" |
368 |
return 0 |
return 0 |
369 |
else |
else |
370 |
echo |
echo |
371 |
echo "createcodelet: failed to compile codelet" |
echo "ERROR: failed to compile comparison code" |
372 |
exit 1 |
exit 1 |
373 |
fi |
fi |
374 |
} |
} |
428 |
|
|
429 |
|
|
430 |
############################################################################### |
############################################################################### |
|
############################################################################### |
|
|
############################################################################### |
|
431 |
|
|
432 |
|
|
433 |
# Default properties |
# Default properties |
454 |
ADDRESSES= |
ADDRESSES= |
455 |
TESTDIRS= |
TESTDIRS= |
456 |
MPACKDIR="../tools/mpack-1.6" |
MPACKDIR="../tools/mpack-1.6" |
457 |
|
HAVE_MPACK= |
458 |
MPACK="$MPACKDIR/mpack" |
MPACK="$MPACKDIR/mpack" |
459 |
COMMAND="make output.txt" |
COMMAND="make output.txt" |
460 |
MAKE=make |
MAKE=make |
521 |
-nodepend | --nodepend | -nd | --nd) |
-nodepend | --nodepend | -nd | --nd) |
522 |
NODEPEND=t ;; |
NODEPEND=t ;; |
523 |
|
|
524 |
-mpi) MPI=true ;; |
-mpi) MPI=t ;; |
525 |
|
|
526 |
-ieee) IEEE=true ;; |
-ieee) IEEE=true ;; |
527 |
-noieee) IEEE= ;; |
-noieee) IEEE= ;; |
580 |
mkdir $DRESULTS |
mkdir $DRESULTS |
581 |
RETVAL=$? |
RETVAL=$? |
582 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
583 |
echo "Error: can't create results directory \"./$DRESULTS\"" |
echo "ERROR: Can't create results directory \"./$DRESULTS\"" |
584 |
exit 1 |
exit 1 |
585 |
fi |
fi |
586 |
SUMMARY="$DRESULTS/summary.txt" |
SUMMARY="$DRESULTS/summary.txt" |
587 |
date > $SUMMARY |
echo -n "Start time: " >> $SUMMARY |
588 |
cat << EOF >> $SUMMARY |
start_date=`date` |
589 |
T S U V |
echo $start_date > $SUMMARY |
|
G D M c m s m s m s m s |
|
|
E p a R g m m e . m m e . m m e . m m e . |
|
|
N n k u 2 i a a d i a a d i a a d i a a d |
|
|
2 d e n d n x n . n x n . n x n . n x n . |
|
|
|
|
|
EOF |
|
|
|
|
|
NDIR=0 |
|
590 |
|
|
591 |
of_path= |
of_path= |
592 |
if test "x$OPTFILE" != xNONE ; then |
if test "x$OPTFILE" != xNONE ; then |
600 |
fi |
fi |
601 |
file=${OPTFILE##*/} |
file=${OPTFILE##*/} |
602 |
OPTFILE=$of_path/$file |
OPTFILE=$of_path/$file |
603 |
|
cp $OPTFILE $DRESULTS |
604 |
|
echo >> $SUMMARY |
605 |
|
echo " OPTFILE=$OPTFILE" >> $SUMMARY |
606 |
else |
else |
607 |
echo |
echo | tee $SUMMARY |
608 |
echo "WARNING: can't read OPTFILE=\"$OPTFILE\" but will try to use it..." |
echo "ERROR: can't read OPTFILE=\"$OPTFILE\"" | tee $SUMMARY |
609 |
|
exit 1 |
610 |
fi |
fi |
611 |
|
else |
612 |
|
echo >> $SUMMARY |
613 |
|
echo "No \"OPTFILE\" was explicitly specified by testreport," >> $SUMMARY |
614 |
|
echo " so the genmake default will be used." >> $SUMMARY |
615 |
fi |
fi |
616 |
echo |
echo |
|
echo "OPTFILE=$OPTFILE" >> $SUMMARY |
|
617 |
echo >> $SUMMARY |
echo >> $SUMMARY |
618 |
|
cat << EOF | tee -a $SUMMARY |
619 |
|
T S U V |
620 |
|
G D M c m s m s m s m s |
621 |
|
E p a R g m m e . m m e . m m e . m m e . |
622 |
|
N n k u 2 i a a d i a a d i a a d i a a d |
623 |
|
2 d e n d n x n . n x n . n x n . n x n . |
624 |
|
|
625 |
|
EOF |
626 |
|
|
627 |
# ...and each test directory... |
# ...and each test directory... |
628 |
for dir in $TESTDIRS ; do |
for dir in $TESTDIRS ; do |
703 |
fi |
fi |
704 |
|
|
705 |
# Create an output dir for each OPTFILE/tdir combination |
# Create an output dir for each OPTFILE/tdir combination |
706 |
CDIR=$DRESULTS"/"$DRESULTS"_"$NDIR |
rel_CDIR=$DRESULTS"/"$dir |
707 |
mkdir $CDIR |
mkdir $rel_CDIR |
708 |
CDIR=`pwd`"/$CDIR" |
CDIR=`pwd`"/$rel_CDIR" |
709 |
|
|
710 |
if test "x$CLEANUP" = xt ; then |
if test "x$CLEANUP" = xt ; then |
711 |
makeclean $dir/$builddir |
makeclean $dir/$builddir |
720 |
fi |
fi |
721 |
|
|
722 |
echo |
echo |
723 |
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results` |
|
${run:-N} $results |
|
724 |
echo |
echo |
725 |
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
echo "$fres" >> $SUMMARY |
726 |
${run:-N} $results >> $SUMMARY |
echo "fresults='$fres'" > $CDIR"/summary.txt" |
|
echo "fresults='" > $CDIR"/summary.txt" |
|
|
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
|
|
${run:-N} $results >> $CDIR"/summary.txt" |
|
|
echo "'" >> $CDIR"/summary.txt" |
|
727 |
echo "MACH='$MACH'" >> $CDIR"/summary.txt" |
echo "MACH='$MACH'" >> $CDIR"/summary.txt" |
728 |
echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt" |
echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt" |
729 |
echo "DATE='$DATE'" >> $CDIR"/summary.txt" |
echo "DATE='$DATE'" >> $CDIR"/summary.txt" |
730 |
echo "tdir='$dir'" >> $CDIR"/summary.txt" |
echo "tdir='$dir'" >> $CDIR"/summary.txt" |
731 |
|
|
732 |
( |
echo "-------------------------------------------------------------------------------" |
|
cd $DRESULTS |
|
|
tar -cf $NDIR".tar" $DRESULTS"_"$NDIR > /dev/null 2>&1 |
|
|
gzip $NDIR".tar" |
|
|
) |
|
733 |
|
|
734 |
if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then |
done |
735 |
echo "No mail sent" |
|
736 |
else |
echo -n "Start time: " >> $SUMMARY |
737 |
$MPACK -s MITgcm-test -m 1000000 $DRESULTS"/"$NDIR".tar.gz" $ADDRESSES |
echo $start_date >> $SUMMARY |
738 |
|
echo -n "End time: " >> $SUMMARY |
739 |
|
date >> $SUMMARY |
740 |
|
|
741 |
|
# If addresses were supplied and mpack built successfully, then try |
742 |
|
# to send email using mpack. |
743 |
|
if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then |
744 |
|
echo "No results email was sent." |
745 |
|
else |
746 |
|
if test "x$HAVE_MPACK" = xt ; then |
747 |
|
tar -cf $DRESULTS".tar" $DRESULTS > /dev/null 2>&1 \ |
748 |
|
&& gzip $DRESULTS".tar" \ |
749 |
|
&& $MPACK -s MITgcm-test -m 1500000 $DRESULTS".tar.gz" $ADDRESSES |
750 |
RETVAL=$? |
RETVAL=$? |
751 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
752 |
echo "Warning: \"$MPACK\" failed -- please contact <edhill@mitgcm.org>" |
echo |
753 |
|
echo "Warning: The tar, gzip, & mpack step failed. Please send email" |
754 |
|
echo " to <MITgcm-support@mitgcm.org> for help. You may copy the " |
755 |
|
echo " summary of results from the directory \"$DRESULTS\"." |
756 |
|
echo |
757 |
else |
else |
758 |
rm -f $DRESULTS"/"$NDIR".tar*" |
echo |
759 |
|
echo "An email containing results was sent to the following addresses:" |
760 |
|
echo " \"$ADDRESSES\"" |
761 |
|
echo |
762 |
fi |
fi |
763 |
|
test -f $DRESULTS".tar" && rm -f $DRESULTS".tar" |
764 |
|
test -f $DRESULTS".tar.gz" && rm -f $DRESULTS".tar.gz" |
765 |
fi |
fi |
766 |
|
fi |
767 |
|
|
768 |
echo "-------------------------------------------------------------------------------" |
# rm -f tmp_cmpnum.f a.out |
769 |
|
rm -f tmp_cmpnum.c tmp_cmpnum |
|
NDIR=$(( $NDIR + 1 )) |
|
|
|
|
|
done |
|
|
|
|
|
rm tmp_cmpnum.f a.out |
|
770 |
|
|
771 |
if test "x$CLEANUP" != xt ; then |
if test "x$CLEANUP" != xt ; then |
772 |
cat $SUMMARY |
cat $SUMMARY |
773 |
|
if test -e tr.out ; then |
774 |
|
mv tr.out tr.out.old |
775 |
|
fi |
776 |
|
cat $SUMMARY > tr.out |
777 |
fi |
fi |
778 |
|
|