1 |
#!/bin/bash |
#!/bin/bash |
2 |
# |
# |
3 |
# $Header$ |
# $Header$ |
4 |
|
# $Name$ |
5 |
# |
# |
6 |
|
|
7 |
usage() |
usage() |
12 |
echo "where possible OPTIONS are:" |
echo "where possible OPTIONS are:" |
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" |
16 |
echo " (-optfile=|-of=)STRING list of optfiles to use" |
echo " (-optfile=|-of=)STRING list of optfiles to use" |
17 |
echo " (-a|-addr)STRING list of email recipients" |
echo " (-a|-addr)STRING list of email recipients" |
18 |
echo " (DEF=\"edhill@mitgcm.org\")" |
echo " (DEF=\"edhill@mitgcm.org\")" |
20 |
echo " (DEF=\"\" which builds all)" |
echo " (DEF=\"\" which builds all)" |
21 |
echo " (-b|-bash)STRING location of \"bash\" executable" |
echo " (-b|-bash)STRING location of \"bash\" executable" |
22 |
echo " (DEF=\"\" for \"/bin/bash\")" |
echo " (DEF=\"\" for \"/bin/bash\")" |
23 |
echo " (-c|-command)STRING command to run" |
echo " (-command)STRING command to run" |
24 |
echo " (DEF=\"make output.txt\")" |
echo " (DEF=\"make output.txt\")" |
25 |
echo " (-m|-make)STRING command to use for \"make\"" |
echo " (-m|-make)STRING command to use for \"make\"" |
26 |
echo " (DEF=\"make\")" |
echo " (DEF=\"make\")" |
27 |
|
echo " (-clean) *ONLY* run \"make CLEAN\"" |
28 |
echo " (-quick|-q) same as \"-nogenmake -noclean -nodepend\"" |
echo " (-quick|-q) same as \"-nogenmake -noclean -nodepend\"" |
29 |
echo " (-nogenmake|-ng) skip the genmake stage" |
echo " (-nogenmake|-ng) skip the genmake stage" |
30 |
echo " (-noclean|-nc) skip the \"make clean\" stage" |
echo " (-noclean|-nc) skip the \"make clean\" stage" |
156 |
if [ $debug -gt 0 ]; then |
if [ $debug -gt 0 ]; then |
157 |
echo testoutput: cg2dres=$cg2dres 1>&2 |
echo testoutput: cg2dres=$cg2dres 1>&2 |
158 |
fi |
fi |
|
|
|
159 |
testoutput_for_prop $1 "dynstat_theta_min" "theta minimum" $2; tmin=$? |
testoutput_for_prop $1 "dynstat_theta_min" "theta minimum" $2; tmin=$? |
160 |
testoutput_for_prop $1 "dynstat_theta_max" "theta maximum" $2; tmax=$? |
testoutput_for_prop $1 "dynstat_theta_max" "theta maximum" $2; tmax=$? |
161 |
testoutput_for_prop $1 "dynstat_theta_mean" "theta mean" $2; tmean=$? |
testoutput_for_prop $1 "dynstat_theta_mean" "theta mean" $2; tmean=$? |
186 |
GENMAKE2="$BASH ../../../tools/genmake2" |
GENMAKE2="$BASH ../../../tools/genmake2" |
187 |
( |
( |
188 |
cd $1; |
cd $1; |
189 |
|
command="$GENMAKE2 -ds -m $MAKE --mods=../code" |
190 |
|
if test "x$OPTFILE" != xNONE ; then |
191 |
|
command="$command --optfile=$OPTFILE" |
192 |
|
# echo " command=\"$command\"" |
193 |
|
fi |
194 |
|
if test "x$IEEE" != x ; then |
195 |
|
command="$command -ieee" |
196 |
|
fi |
197 |
|
# echo "command: \"$command\"" |
198 |
printf 'genmake ... ' 1>&2 |
printf 'genmake ... ' 1>&2 |
199 |
# ../../../tools/genmake -ieee -mods=../code > make.log 2>&1 |
$command > make.log 2>&1 |
|
$GENMAKE2 -ds -m $MAKE --mods=../code "--optfile="$OPTFILE > make.log 2>&1 |
|
200 |
RETVAL=$? |
RETVAL=$? |
201 |
for i in gm_state gm_optfile gm_local Makefile ; do |
for i in genmake_state genmake_optfile genmake_local Makefile ; do |
202 |
if test -r $i ; then |
if test -r $i ; then |
203 |
cp $i $CDIR |
cp $i $CDIR |
204 |
fi |
fi |
292 |
# linkdata flag |
# linkdata flag |
293 |
# |
# |
294 |
# symbolically link data files to run directory |
# symbolically link data files to run directory |
295 |
if [ $1 -ne 0 ]; then |
if test "x$1" = x1 ; then |
296 |
( cd $2 ; ln -sf ../input/* . ) |
( |
297 |
|
cd $2 |
298 |
|
files=`( cd ../input ; ls -1 | grep -v CVS )` |
299 |
|
for i in $files ; do |
300 |
|
if test ! -d "../input/"$i ; then |
301 |
|
ln -sf "../input/"$i $i |
302 |
|
fi |
303 |
|
done |
304 |
|
) |
305 |
fi |
fi |
306 |
} |
} |
307 |
|
|
401 |
-debug Produce even more output which will mean nothing to most |
-debug Produce even more output which will mean nothing to most |
402 |
-force Do "make CLEAN" before compiling. This forces a complete rebuild. |
-force Do "make CLEAN" before compiling. This forces a complete rebuild. |
403 |
-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. |
|
404 |
-cleanup Aggresively removes all model output, executables and object files |
-cleanup Aggresively removes all model output, executables and object files |
405 |
and then exits. Use with care. |
and then exits. Use with care. |
406 |
|
|
433 |
expts='' |
expts='' |
434 |
# ieee=1 |
# ieee=1 |
435 |
|
|
436 |
|
IEEE= |
437 |
|
if test "x$MITGCM_IEEE" != x ; then |
438 |
|
IEEE=$MITGCM_IEEE |
439 |
|
fi |
440 |
|
|
441 |
|
|
442 |
CLEANUP=f |
CLEANUP=f |
443 |
QUICK=f |
QUICK=f |
444 |
NOGENMAKE=f |
NOGENMAKE=f |
446 |
NODEPEND=f |
NODEPEND=f |
447 |
|
|
448 |
BASH= |
BASH= |
449 |
OPTFILES= |
OPTFILE=NONE |
450 |
ADDRESSES= |
ADDRESSES= |
451 |
TESTDIRS= |
TESTDIRS= |
452 |
MPACKDIR="../tools/mpack-1.6" |
MPACKDIR="../tools/mpack-1.6" |
475 |
usage ;; |
usage ;; |
476 |
|
|
477 |
-optfile | --optfile | -of | --of) |
-optfile | --optfile | -of | --of) |
478 |
ac_prev=OPTFILES ;; |
ac_prev=OPTFILE ;; |
479 |
-optfile=* | --optfile=* | -of=* | --of=*) |
-optfile=* | --optfile=* | -of=* | --of=*) |
480 |
OPTFILES=$ac_optarg ;; |
OPTFILE=$ac_optarg ;; |
481 |
|
|
482 |
-addr | --addr | -a | --a) |
-addr | --addr | -a | --a) |
483 |
ac_prev=ADDRESSES ;; |
ac_prev=ADDRESSES ;; |
516 |
-nodepend | --nodepend | -nd | --nd) |
-nodepend | --nodepend | -nd | --nd) |
517 |
NODEPEND=t ;; |
NODEPEND=t ;; |
518 |
|
|
519 |
-mpi) MPI=t ;; |
-mpi) MPI=true ;; |
520 |
|
|
521 |
|
-ieee) IEEE=true ;; |
522 |
|
-noieee) IEEE= ;; |
523 |
|
|
524 |
-verbose) verbose=2 ;; |
-verbose) verbose=2 ;; |
525 |
-debug) debug=1 ;; |
-debug) debug=1 ;; |
|
-clean) clean=1 ;; |
|
526 |
-quiet) verbose=0 ;; |
-quiet) verbose=0 ;; |
527 |
|
|
528 |
-*) |
-*) |
549 |
TESTDIRS=`scandirs` |
TESTDIRS=`scandirs` |
550 |
fi |
fi |
551 |
|
|
552 |
if test "x$OPTFILES" = x ; then |
if test "x$OPTFILE" = xNONE -a "x$MITGCM_OF" != x ; then |
553 |
OPTFILES=$MITGCM_OF |
OPTFILE=$MITGCM_OF |
|
fi |
|
|
if test "x$OPTFILES" = x ; then |
|
|
echo "Error: please specify an optfile using either the command-line or" |
|
|
echo " the MITGCM_OF environment variable. Also, examples are located " |
|
|
echo " in \$ROOTDIR/tools/build_options" |
|
|
exit 1 |
|
554 |
fi |
fi |
555 |
|
|
556 |
echo "OK" |
echo "OK" |
579 |
exit 1 |
exit 1 |
580 |
fi |
fi |
581 |
SUMMARY="$DRESULTS/summary.txt" |
SUMMARY="$DRESULTS/summary.txt" |
582 |
|
echo -n "Start time: " >> $SUMMARY |
583 |
date > $SUMMARY |
date > $SUMMARY |
584 |
|
date > dfile |
585 |
cat << EOF >> $SUMMARY |
cat << EOF >> $SUMMARY |
586 |
T S U V |
T S U V |
587 |
G D M c m s m s m s m s |
G D M c m s m s m s m s |
593 |
|
|
594 |
NDIR=0 |
NDIR=0 |
595 |
|
|
596 |
# For each optfile... |
of_path= |
597 |
for OPTFILE in $OPTFILES ; do |
if test "x$OPTFILE" != xNONE ; then |
598 |
|
if test -r $OPTFILE ; then |
599 |
OPTFILE=`pwd`"/$OPTFILE" |
# get the path |
600 |
if test ! -r $OPTFILE ; then |
path=${OPTFILE%/*} |
601 |
echo "Error: can't read optfile \"$OPTFILE\"" |
if test "x$path" = x ; then |
602 |
exit 1 |
of_path=`pwd` |
|
fi |
|
|
echo |
|
|
echo "OPTFILE=$OPTFILE" >> $SUMMARY |
|
|
echo >> $SUMMARY |
|
|
|
|
|
# ...and each test directory... |
|
|
for dir in $TESTDIRS ; do |
|
|
|
|
|
# Cleanup only! |
|
|
if test "x$CLEANUP" = xt ; then |
|
|
if test -r $dir/build/Makefile ; then |
|
|
( cd $dir/build ; make CLEAN ) |
|
|
fi |
|
|
if test -r $dir/input/Makefile ; then |
|
|
( cd $dir/input ; make CLEAN ) |
|
|
fi |
|
|
continue |
|
|
fi |
|
|
|
|
|
# Verify that the testdir exists and contains previous |
|
|
# results in the correct location--or skip this directory! |
|
|
if test ! -r $dir"/results/output.txt" ; then |
|
|
echo |
|
|
echo "can't read \"$dir/results/output.txt\" -- skipping $dir" |
|
|
echo |
|
|
continue |
|
|
fi |
|
|
|
|
|
echo "-------------------------------------------------------------------------------" |
|
|
echo |
|
|
echo "Experiment: $dir" |
|
|
echo |
|
|
unset genmake makedepend make run |
|
|
results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --' |
|
|
|
|
|
if [ -r $dir/build ]; then |
|
|
seperatebuilddir=1 |
|
|
builddir=build |
|
|
rundir=build |
|
|
( cd $dir/build; ln -sf ../input/* . ) |
|
603 |
else |
else |
604 |
seperatebuilddir=0 |
of_path=`( cd $path > /dev/null 2>&1 ; pwd )` |
|
builddir=input |
|
|
rundir=input |
|
605 |
fi |
fi |
606 |
|
file=${OPTFILE##*/} |
607 |
|
OPTFILE=$of_path/$file |
608 |
|
else |
609 |
|
echo |
610 |
|
echo "WARNING: can't read OPTFILE=\"$OPTFILE\" but will try to use it..." |
611 |
|
fi |
612 |
|
fi |
613 |
|
echo |
614 |
|
echo "OPTFILE=$OPTFILE" >> $SUMMARY |
615 |
|
echo >> $SUMMARY |
616 |
|
|
617 |
CODE_DIR=$dir/code |
# ...and each test directory... |
618 |
BUILD_DIR=$dir/$builddir |
for dir in $TESTDIRS ; do |
619 |
MPI_FILES="CPP_EEOPTIONS.h_mpi SIZE.h_mpi" |
|
620 |
NOMPI_FILES="CPP_EEOPTIONS.h_nompi SIZE.h_nompi" |
# Cleanup only! |
621 |
# Is this an MPI run? |
if test "x$CLEANUP" = xt ; then |
622 |
if test "x$MPI" = xt ; then |
if test -r $dir/build/Makefile ; then |
623 |
FILES=$MPI_FILES |
( cd $dir/build ; make CLEAN ) |
|
else |
|
|
FILES=$NOMPI_FILES |
|
624 |
fi |
fi |
625 |
|
if test -r $dir/input/Makefile ; then |
626 |
# Check to see that we have the files |
( cd $dir/input ; make CLEAN ) |
|
have_files=t |
|
|
for i in $FILES ; do |
|
|
if test ! -r $CODE_DIR/$i ; then |
|
|
echo "Warning: can't read file $CODE_DIR/$i" | tee -a $SUMMARY |
|
|
have_files=f |
|
|
fi |
|
|
done |
|
|
if test "x$have_files" != xt -a "x$MPI" = xt ; then |
|
|
echo "Skipping $dir due to lack of input files (see above warning)" \ |
|
|
| tee -a $SUMMARY |
|
|
continue |
|
627 |
fi |
fi |
628 |
|
continue |
629 |
|
fi |
630 |
|
|
631 |
# If we have the $FILES and they differ, copy the $FILES to $BUILD_DIR |
# Verify that the testdir exists and contains previous |
632 |
if "x$have_files" = xt ; then |
# results in the correct location--or skip this directory! |
633 |
for i in $FILES ; do |
if test ! -r $dir"/results/output.txt" ; then |
634 |
cmp $CODE_DIR/$i $BUILD_DIR/$i > /dev/null 2>&1 |
echo "can't read \"$dir/results/output.txt\" -- skipping $dir" |
635 |
RETVAL=$? |
continue |
636 |
if test "x$RETVAL" != x0 ; then |
fi |
|
cp $CODE_DIR/$i $BUILD_DIR/$i |
|
|
fi |
|
|
done |
|
|
fi |
|
637 |
|
|
638 |
# Create an output dir for each OPTFILE/tdir combination |
echo "-------------------------------------------------------------------------------" |
639 |
CDIR=$DRESULTS"/"$DRESULTS"_"$NDIR |
echo |
640 |
mkdir $CDIR |
echo "Experiment: $dir" |
641 |
CDIR=`pwd`"/$CDIR" |
echo |
642 |
|
unset genmake makedepend make run |
643 |
|
results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --' |
644 |
|
|
645 |
if test "x$CLEANUP" = xt ; then |
builddir="input" |
646 |
makeclean $dir/$builddir |
rundir="input" |
647 |
else |
use_seperate_build=0 |
648 |
genmakemodel $dir/$builddir && genmake=Y \ |
if test -d $dir/build -a -r $dir/build ; then |
649 |
&& makeclean $dir/$builddir \ |
builddir="build" |
650 |
&& makedependmodel $dir/$builddir && makedepend=Y \ |
rundir="build" |
651 |
&& makemodel $dir/$builddir && make=Y \ |
use_seperate_build=1 |
652 |
&& linkdata $seperatebuilddir $dir/$rundir \ |
linkdata $use_seperate_build $dir/$rundir |
653 |
&& runmodel $dir/$builddir && run=Y \ |
fi |
654 |
&& results=`testoutput $dir $rundir` |
|
655 |
|
CODE_DIR=$dir/code |
656 |
|
BUILD_DIR=$dir/$builddir |
657 |
|
MPI_FILES="CPP_EEOPTIONS.h_mpi SIZE.h_mpi" |
658 |
|
NOMPI_FILES="CPP_EEOPTIONS.h_nompi SIZE.h_nompi" |
659 |
|
|
660 |
|
# Is this an MPI run? |
661 |
|
if test "x$MPI" = xt ; then |
662 |
|
FILES=$MPI_FILES |
663 |
|
endings="_mpi" |
664 |
|
else |
665 |
|
FILES=$NOMPI_FILES |
666 |
|
endings="_nompi" |
667 |
|
fi |
668 |
|
|
669 |
|
# Check to see that we have the files |
670 |
|
have_files=t |
671 |
|
for i in $FILES ; do |
672 |
|
if test ! -r $CODE_DIR/$i ; then |
673 |
|
echo "Warning: can't read file $CODE_DIR/$i" |
674 |
|
have_files=f |
675 |
fi |
fi |
676 |
|
done |
677 |
echo |
if test "x$have_files" != xt -a "x$MPI" = xt ; then |
678 |
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
echo "Skipping $dir due to lack of input files (see above warning)" |
679 |
${run:-N} $results |
continue |
680 |
echo |
fi |
681 |
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
|
682 |
${run:-N} $results >> $SUMMARY |
# If we have the $FILES and they differ, copy the $FILES to $BUILD_DIR |
683 |
echo "fresults='" > $CDIR"/summary.txt" |
if test "x$have_files" = xt ; then |
684 |
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
for i in $FILES ; do |
685 |
${run:-N} $results >> $CDIR"/summary.txt" |
sstr="s|$endings||" |
686 |
echo "'" >> $CDIR"/summary.txt" |
name=`echo $i | sed -e $sstr ` |
687 |
echo "MACH='$MACH'" >> $CDIR"/summary.txt" |
cmp $CODE_DIR/$i $BUILD_DIR/$name > /dev/null 2>&1 |
|
echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt" |
|
|
echo "DATE='$DATE'" >> $CDIR"/summary.txt" |
|
|
echo "tdir='$dir'" >> $CDIR"/summary.txt" |
|
|
|
|
|
( |
|
|
cd $DRESULTS |
|
|
tar -cf $NDIR".tar" $DRESULTS"_"$NDIR > /dev/null 2>&1 |
|
|
gzip $NDIR".tar" |
|
|
) |
|
|
|
|
|
if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then |
|
|
echo "No mail sent" |
|
|
else |
|
|
$MPACK -s MITgcm-test -m 1000000 $DRESULTS"/"$NDIR".tar.gz" $ADDRESSES |
|
688 |
RETVAL=$? |
RETVAL=$? |
689 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
690 |
echo "Warning: \"$MPACK\" failed -- please contact <edhill@mitgcm.org>" |
cp $CODE_DIR/$i $BUILD_DIR/$name |
|
else |
|
|
rm -f $DRESULTS"/"$NDIR".tar*" |
|
691 |
fi |
fi |
692 |
|
done |
693 |
|
fi |
694 |
|
|
695 |
|
# Create an output dir for each OPTFILE/tdir combination |
696 |
|
CDIR=$DRESULTS"/"$DRESULTS"_"$NDIR |
697 |
|
mkdir $CDIR |
698 |
|
CDIR=`pwd`"/$CDIR" |
699 |
|
|
700 |
|
if test "x$CLEANUP" = xt ; then |
701 |
|
makeclean $dir/$builddir |
702 |
|
else |
703 |
|
genmakemodel $dir/$builddir && genmake=Y \ |
704 |
|
&& makeclean $dir/$builddir \ |
705 |
|
&& makedependmodel $dir/$builddir && makedepend=Y \ |
706 |
|
&& makemodel $dir/$builddir && make=Y \ |
707 |
|
&& linkdata $use_seperate_build $dir/$rundir \ |
708 |
|
&& runmodel $dir/$rundir && run=Y \ |
709 |
|
&& results=`testoutput $dir $rundir` |
710 |
|
fi |
711 |
|
|
712 |
|
echo |
713 |
|
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
714 |
|
${run:-N} $results |
715 |
|
echo |
716 |
|
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
717 |
|
${run:-N} $results >> $SUMMARY |
718 |
|
echo "fresults='" > $CDIR"/summary.txt" |
719 |
|
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
720 |
|
${run:-N} $results >> $CDIR"/summary.txt" |
721 |
|
echo "'" >> $CDIR"/summary.txt" |
722 |
|
echo "MACH='$MACH'" >> $CDIR"/summary.txt" |
723 |
|
echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt" |
724 |
|
echo "DATE='$DATE'" >> $CDIR"/summary.txt" |
725 |
|
echo "tdir='$dir'" >> $CDIR"/summary.txt" |
726 |
|
|
727 |
|
( |
728 |
|
cd $DRESULTS |
729 |
|
tar -cf $NDIR".tar" $DRESULTS"_"$NDIR > /dev/null 2>&1 |
730 |
|
gzip $NDIR".tar" |
731 |
|
) |
732 |
|
|
733 |
|
if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then |
734 |
|
echo "No mail sent" |
735 |
|
else |
736 |
|
$MPACK -s MITgcm-test -m 1000000 $DRESULTS"/"$NDIR".tar.gz" $ADDRESSES |
737 |
|
RETVAL=$? |
738 |
|
if test "x$RETVAL" != x0 ; then |
739 |
|
echo "Warning: \"$MPACK\" failed -- please contact <edhill@mitgcm.org>" |
740 |
|
else |
741 |
|
rm -f $DRESULTS"/"$NDIR".tar*" |
742 |
fi |
fi |
743 |
|
fi |
744 |
|
|
745 |
NDIR=$(( $NDIR + 1 )) |
echo "-------------------------------------------------------------------------------" |
746 |
|
|
747 |
done |
NDIR=$(( $NDIR + 1 )) |
748 |
|
|
749 |
done |
done |
750 |
|
|
751 |
rm tmp_cmpnum.f a.out |
echo -n "Start time: " >> $SUMMARY |
752 |
|
date -r dfile >> $SUMMARY |
753 |
cat $SUMMARY |
echo -n "End time: " >> $SUMMARY |
754 |
|
date >> $SUMMARY |
755 |
|
|
756 |
|
rm tmp_cmpnum.f a.out dfile |
757 |
|
|
758 |
|
if test "x$CLEANUP" != xt ; then |
759 |
|
cat $SUMMARY |
760 |
|
if test -e tr.out ; then |
761 |
|
mv tr.out tr.out.old |
762 |
|
fi |
763 |
|
cat $SUMMARY > tr.out |
764 |
|
fi |
765 |
|
|