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" |
187 |
GENMAKE2="$BASH ../../../tools/genmake2" |
GENMAKE2="$BASH ../../../tools/genmake2" |
188 |
( |
( |
189 |
cd $1; |
cd $1; |
190 |
|
command="$GENMAKE2 -ds -m $MAKE --mods=../code" |
191 |
|
if test "x$OPTFILE" != xNONE ; then |
192 |
|
command="$command --optfile=$OPTFILE" |
193 |
|
# echo " command=\"$command\"" |
194 |
|
fi |
195 |
|
if test "x$IEEE" != x ; then |
196 |
|
command="$command -ieee" |
197 |
|
fi |
198 |
|
# echo "command: \"$command\"" |
199 |
printf 'genmake ... ' 1>&2 |
printf 'genmake ... ' 1>&2 |
200 |
# ../../../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 |
|
201 |
RETVAL=$? |
RETVAL=$? |
202 |
for i in gm_state gm_optfile gm_local Makefile ; do |
for i in genmake_state genmake_optfile genmake_local Makefile ; do |
203 |
if test -r $i ; then |
if test -r $i ; then |
204 |
cp $i $CDIR |
cp $i $CDIR |
205 |
fi |
fi |
394 |
-debug Produce even more output which will mean nothing to most |
-debug Produce even more output which will mean nothing to most |
395 |
-force Do "make CLEAN" before compiling. This forces a complete rebuild. |
-force Do "make CLEAN" before compiling. This forces a complete rebuild. |
396 |
-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. |
|
397 |
-cleanup Aggresively removes all model output, executables and object files |
-cleanup Aggresively removes all model output, executables and object files |
398 |
and then exits. Use with care. |
and then exits. Use with care. |
399 |
|
|
426 |
expts='' |
expts='' |
427 |
# ieee=1 |
# ieee=1 |
428 |
|
|
429 |
|
IEEE= |
430 |
|
if test "x$MITGCM_IEEE" != x ; then |
431 |
|
IEEE=$MITGCM_IEEE |
432 |
|
fi |
433 |
|
|
434 |
|
|
435 |
CLEANUP=f |
CLEANUP=f |
436 |
QUICK=f |
QUICK=f |
437 |
NOGENMAKE=f |
NOGENMAKE=f |
439 |
NODEPEND=f |
NODEPEND=f |
440 |
|
|
441 |
BASH= |
BASH= |
442 |
OPTFILES= |
OPTFILE=NONE |
443 |
ADDRESSES= |
ADDRESSES= |
444 |
TESTDIRS= |
TESTDIRS= |
445 |
MPACKDIR="../tools/mpack-1.6" |
MPACKDIR="../tools/mpack-1.6" |
468 |
usage ;; |
usage ;; |
469 |
|
|
470 |
-optfile | --optfile | -of | --of) |
-optfile | --optfile | -of | --of) |
471 |
ac_prev=OPTFILES ;; |
ac_prev=OPTFILE ;; |
472 |
-optfile=* | --optfile=* | -of=* | --of=*) |
-optfile=* | --optfile=* | -of=* | --of=*) |
473 |
OPTFILES=$ac_optarg ;; |
OPTFILE=$ac_optarg ;; |
474 |
|
|
475 |
-addr | --addr | -a | --a) |
-addr | --addr | -a | --a) |
476 |
ac_prev=ADDRESSES ;; |
ac_prev=ADDRESSES ;; |
497 |
-make=* | --make=*) |
-make=* | --make=*) |
498 |
MAKE=$ac_optarg ;; |
MAKE=$ac_optarg ;; |
499 |
|
|
500 |
-clean | --clean | -c | --c) |
-clean | --clean) |
501 |
CLEANUP=t ;; |
CLEANUP=t ;; |
502 |
|
|
503 |
-quick | --quick | -q | --q) |
-quick | --quick | -q | --q) |
509 |
-nodepend | --nodepend | -nd | --nd) |
-nodepend | --nodepend | -nd | --nd) |
510 |
NODEPEND=t ;; |
NODEPEND=t ;; |
511 |
|
|
512 |
-mpi) MPI=t ;; |
-mpi) MPI=true ;; |
513 |
|
|
514 |
|
-ieee) IEEE=true ;; |
515 |
|
-noieee) IEEE= ;; |
516 |
|
|
517 |
-verbose) verbose=2 ;; |
-verbose) verbose=2 ;; |
518 |
-debug) debug=1 ;; |
-debug) debug=1 ;; |
|
-clean) clean=1 ;; |
|
519 |
-quiet) verbose=0 ;; |
-quiet) verbose=0 ;; |
520 |
|
|
521 |
-*) |
-*) |
542 |
TESTDIRS=`scandirs` |
TESTDIRS=`scandirs` |
543 |
fi |
fi |
544 |
|
|
545 |
if test "x$OPTFILES" = x ; then |
if test "x$OPTFILE" = xNONE -a "x$MITGCM_OF" != x ; then |
546 |
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 |
|
547 |
fi |
fi |
548 |
|
|
549 |
echo "OK" |
echo "OK" |
584 |
|
|
585 |
NDIR=0 |
NDIR=0 |
586 |
|
|
587 |
# For each optfile... |
of_path= |
588 |
for OPTFILE in $OPTFILES ; do |
if test "x$OPTFILE" != xNONE ; then |
589 |
|
if test -r $OPTFILE ; then |
590 |
OPTFILE=`pwd`"/$OPTFILE" |
# get the path |
591 |
if test ! -r $OPTFILE ; then |
path=${OPTFILE%/*} |
592 |
echo "Error: can't read optfile \"$OPTFILE\"" |
if test "x$path" = x ; then |
593 |
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 | tee -a $SUMMARY |
|
|
echo "can't read \"$dir/results/output.txt\" -- skipping $dir" \ |
|
|
| tee -a $SUMMARY |
|
|
continue |
|
|
fi |
|
|
|
|
|
# Is this an MPI run? |
|
|
if test "x$MPI" = xt ; then |
|
|
if test ! -r $dir"/code/CPP_EEOPTIONS.h_mpi" -o ! -r $dir"/code/SIZE.h_mpi" ; then |
|
|
echo | tee -a $SUMMARY |
|
|
echo "can't read \"$dir/code/CPP_EEOPTIONS.h_mpi\" or \"$dir/code/SIZE.h_mpi\"" \ |
|
|
| tee -a $SUMMARY |
|
|
continue |
|
|
else |
|
|
cmp $dir"/code/CPP_EEOPTIONS.h_mpi" $dir"/code/CPP_EEOPTIONS.h" |
|
|
RETVAL=$? |
|
|
if test "x$RETVAL" != x0 ; then |
|
|
cp $dir"/code/CPP_EEOPTIONS.h_mpi" $dir"/code/CPP_EEOPTIONS.h" |
|
|
fi |
|
|
cmp $dir"/code/SIZE.h_mpi" $dir"/code/SIZE.h" |
|
|
RETVAL=$? |
|
|
if test "x$RETVAL" != x0 ; then |
|
|
cp $dir"/code/SIZE.h_mpi" $dir"/code/SIZE.h" |
|
|
fi |
|
|
fi |
|
594 |
else |
else |
595 |
if test -r $dir"/code/CPP_EEOPTIONS.h_nompi" ; then |
of_path=`( cd $path > /dev/null 2>&1 ; pwd )` |
|
cmp $dir"/code/CPP_EEOPTIONS.h_nompi" $dir"/code/CPP_EEOPTIONS.h" |
|
|
RETVAL=$? |
|
|
if test "x$RETVAL" != x0 ; then |
|
|
cp $dir"/code/CPP_EEOPTIONS.h_nompi" $dir"/code/CPP_EEOPTIONS.h" |
|
|
fi |
|
|
fi |
|
|
if test -r $dir"/code/SIZE.h_nompi" ; then |
|
|
cmp $dir"/code/SIZE.h_nompi" $dir"/code/SIZE.h" |
|
|
RETVAL=$? |
|
|
if test "x$RETVAL" != x0 ; then |
|
|
cp $dir"/code/SIZE.h_nompi" $dir"/code/SIZE.h" |
|
|
fi |
|
|
fi |
|
596 |
fi |
fi |
597 |
|
file=${OPTFILE##*/} |
598 |
# Create an output dir for each OPTFILE/tdir combination |
OPTFILE=$of_path/$file |
599 |
CDIR=$DRESULTS"/"$DRESULTS"_"$NDIR |
else |
|
mkdir $CDIR |
|
|
CDIR=`pwd`"/$CDIR" |
|
|
|
|
|
# ...configue, make, run, and compare the output. |
|
|
echo "-------------------------------------------------------------------------------" |
|
|
echo |
|
|
echo "Experiment: $dir" |
|
600 |
echo |
echo |
601 |
unset genmake makedepend make run |
echo "WARNING: can't read OPTFILE=\"$OPTFILE\" but will try to use it..." |
602 |
results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --' |
fi |
603 |
|
fi |
604 |
|
echo |
605 |
|
echo "OPTFILE=$OPTFILE" >> $SUMMARY |
606 |
|
echo >> $SUMMARY |
607 |
|
|
608 |
if [ -r $dir/build ]; then |
# ...and each test directory... |
609 |
seperatebuilddir=1 |
for dir in $TESTDIRS ; do |
610 |
builddir=build |
|
611 |
rundir=build |
# Cleanup only! |
612 |
( cd $dir/build; ln -sf ../input/* . ) |
if test "x$CLEANUP" = xt ; then |
613 |
else |
if test -r $dir/build/Makefile ; then |
614 |
seperatebuilddir=0 |
( cd $dir/build ; make CLEAN ) |
|
builddir=input |
|
|
rundir=input |
|
615 |
fi |
fi |
616 |
|
if test -r $dir/input/Makefile ; then |
617 |
if test "x$CLEANUP" = xt ; then |
( cd $dir/input ; make CLEAN ) |
|
makeclean $dir/$builddir |
|
|
else |
|
|
genmakemodel $dir/$builddir && genmake=Y \ |
|
|
&& makeclean $dir/$builddir \ |
|
|
&& makedependmodel $dir/$builddir && makedepend=Y \ |
|
|
&& makemodel $dir/$builddir && make=Y \ |
|
|
&& linkdata $seperatebuilddir $dir/$rundir \ |
|
|
&& runmodel $dir/$builddir && run=Y \ |
|
|
&& results=`testoutput $dir $rundir` |
|
618 |
fi |
fi |
619 |
|
continue |
620 |
|
fi |
621 |
|
|
622 |
echo |
# Verify that the testdir exists and contains previous |
623 |
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
# results in the correct location--or skip this directory! |
624 |
${run:-N} $results |
if test ! -r $dir"/results/output.txt" ; then |
625 |
echo |
echo "can't read \"$dir/results/output.txt\" -- skipping $dir" |
626 |
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
continue |
627 |
${run:-N} $results >> $SUMMARY |
fi |
|
echo "fresults='" > $CDIR"/summary.txt" |
|
|
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
|
|
${run:-N} $results >> $CDIR"/summary.txt" |
|
|
echo "'" >> $CDIR"/summary.txt" |
|
|
echo "MACH='$MACH'" >> $CDIR"/summary.txt" |
|
|
echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt" |
|
|
echo "DATE='$DATE'" >> $CDIR"/summary.txt" |
|
|
echo "tdir='$dir'" >> $CDIR"/summary.txt" |
|
628 |
|
|
629 |
( |
echo "-------------------------------------------------------------------------------" |
630 |
cd $DRESULTS |
echo |
631 |
tar -cf $NDIR".tar" $DRESULTS"_"$NDIR > /dev/null 2>&1 |
echo "Experiment: $dir" |
632 |
gzip $NDIR".tar" |
echo |
633 |
) |
unset genmake makedepend make run |
634 |
|
results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --' |
635 |
|
|
636 |
if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then |
if [ -r $dir/build ]; then |
637 |
echo "No mail sent" |
seperatebuilddir=1 |
638 |
else |
builddir=build |
639 |
$MPACK -s MITgcm-test -m 1000000 $DRESULTS"/"$NDIR".tar.gz" $ADDRESSES |
rundir=build |
640 |
|
( cd $dir/build; ln -sf ../input/* . ) |
641 |
|
else |
642 |
|
seperatebuilddir=0 |
643 |
|
builddir=input |
644 |
|
rundir=input |
645 |
|
fi |
646 |
|
|
647 |
|
CODE_DIR=$dir/code |
648 |
|
BUILD_DIR=$dir/$builddir |
649 |
|
MPI_FILES="CPP_EEOPTIONS.h_mpi SIZE.h_mpi" |
650 |
|
NOMPI_FILES="CPP_EEOPTIONS.h_nompi SIZE.h_nompi" |
651 |
|
|
652 |
|
# Is this an MPI run? |
653 |
|
if test "x$MPI" = xt ; then |
654 |
|
FILES=$MPI_FILES |
655 |
|
endings="_mpi" |
656 |
|
else |
657 |
|
FILES=$NOMPI_FILES |
658 |
|
endings="_nompi" |
659 |
|
fi |
660 |
|
|
661 |
|
# Check to see that we have the files |
662 |
|
have_files=t |
663 |
|
for i in $FILES ; do |
664 |
|
if test ! -r $CODE_DIR/$i ; then |
665 |
|
echo "Warning: can't read file $CODE_DIR/$i" |
666 |
|
have_files=f |
667 |
|
fi |
668 |
|
done |
669 |
|
if test "x$have_files" != xt -a "x$MPI" = xt ; then |
670 |
|
echo "Skipping $dir due to lack of input files (see above warning)" |
671 |
|
continue |
672 |
|
fi |
673 |
|
|
674 |
|
# If we have the $FILES and they differ, copy the $FILES to $BUILD_DIR |
675 |
|
if test "x$have_files" = xt ; then |
676 |
|
for i in $FILES ; do |
677 |
|
sstr="s|$endings||" |
678 |
|
name=`echo $i | sed -e $sstr ` |
679 |
|
cmp $CODE_DIR/$i $BUILD_DIR/$name > /dev/null 2>&1 |
680 |
RETVAL=$? |
RETVAL=$? |
681 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
682 |
echo "Warning: \"$MPACK\" failed -- please contact <edhill@mitgcm.org>" |
cp $CODE_DIR/$i $BUILD_DIR/$name |
|
else |
|
|
rm -f $DRESULTS"/"$NDIR".tar*" |
|
683 |
fi |
fi |
684 |
|
done |
685 |
|
fi |
686 |
|
|
687 |
|
# Create an output dir for each OPTFILE/tdir combination |
688 |
|
CDIR=$DRESULTS"/"$DRESULTS"_"$NDIR |
689 |
|
mkdir $CDIR |
690 |
|
CDIR=`pwd`"/$CDIR" |
691 |
|
|
692 |
|
if test "x$CLEANUP" = xt ; then |
693 |
|
makeclean $dir/$builddir |
694 |
|
else |
695 |
|
genmakemodel $dir/$builddir && genmake=Y \ |
696 |
|
&& makeclean $dir/$builddir \ |
697 |
|
&& makedependmodel $dir/$builddir && makedepend=Y \ |
698 |
|
&& makemodel $dir/$builddir && make=Y \ |
699 |
|
&& linkdata $seperatebuilddir $dir/$rundir \ |
700 |
|
&& runmodel $dir/$builddir && run=Y \ |
701 |
|
&& results=`testoutput $dir $rundir` |
702 |
|
fi |
703 |
|
|
704 |
|
echo |
705 |
|
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
706 |
|
${run:-N} $results |
707 |
|
echo |
708 |
|
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
709 |
|
${run:-N} $results >> $SUMMARY |
710 |
|
echo "fresults='" > $CDIR"/summary.txt" |
711 |
|
formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \ |
712 |
|
${run:-N} $results >> $CDIR"/summary.txt" |
713 |
|
echo "'" >> $CDIR"/summary.txt" |
714 |
|
echo "MACH='$MACH'" >> $CDIR"/summary.txt" |
715 |
|
echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt" |
716 |
|
echo "DATE='$DATE'" >> $CDIR"/summary.txt" |
717 |
|
echo "tdir='$dir'" >> $CDIR"/summary.txt" |
718 |
|
|
719 |
|
( |
720 |
|
cd $DRESULTS |
721 |
|
tar -cf $NDIR".tar" $DRESULTS"_"$NDIR > /dev/null 2>&1 |
722 |
|
gzip $NDIR".tar" |
723 |
|
) |
724 |
|
|
725 |
|
if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then |
726 |
|
echo "No mail sent" |
727 |
|
else |
728 |
|
$MPACK -s MITgcm-test -m 1000000 $DRESULTS"/"$NDIR".tar.gz" $ADDRESSES |
729 |
|
RETVAL=$? |
730 |
|
if test "x$RETVAL" != x0 ; then |
731 |
|
echo "Warning: \"$MPACK\" failed -- please contact <edhill@mitgcm.org>" |
732 |
|
else |
733 |
|
rm -f $DRESULTS"/"$NDIR".tar*" |
734 |
fi |
fi |
735 |
|
fi |
736 |
|
|
737 |
NDIR=$(( $NDIR + 1 )) |
echo "-------------------------------------------------------------------------------" |
738 |
|
|
739 |
done |
NDIR=$(( $NDIR + 1 )) |
740 |
|
|
741 |
done |
done |
742 |
|
|
743 |
rm tmp_cmpnum.f a.out |
rm tmp_cmpnum.f a.out |