1 |
#!/bin/bash |
#! /usr/bin/env 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" |
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 |
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; |
|
printf 'genmake ... ' 1>&2 |
|
189 |
command="$GENMAKE2 -ds -m $MAKE --mods=../code" |
command="$GENMAKE2 -ds -m $MAKE --mods=../code" |
190 |
if test "x$OPTFILE" != xNONE ; then |
if test "x$OPTFILE" != xNONE ; then |
191 |
command="$command --optfile=$OPTFILE" |
command="$command --optfile=$OPTFILE" |
192 |
# echo " command=\"$command\"" |
# echo " command=\"$command\"" |
193 |
fi |
fi |
194 |
|
if test "x$IEEE" != x ; then |
195 |
|
command="$command -ieee" |
196 |
|
fi |
197 |
|
# echo "command: \"$command\"" |
198 |
|
printf 'genmake ... ' 1>&2 |
199 |
$command > make.log 2>&1 |
$command > 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 |
517 |
NODEPEND=t ;; |
NODEPEND=t ;; |
518 |
|
|
519 |
-mpi) MPI=t ;; |
-mpi) MPI=t ;; |
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 |
-*) |
-*) |
579 |
exit 1 |
exit 1 |
580 |
fi |
fi |
581 |
SUMMARY="$DRESULTS/summary.txt" |
SUMMARY="$DRESULTS/summary.txt" |
582 |
date > $SUMMARY |
echo -n "Start time: " >> $SUMMARY |
583 |
|
start_date=`date` |
584 |
|
echo $start_date > $SUMMARY |
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 |
|
of_path= |
597 |
if test "x$OPTFILE" != xNONE ; then |
if test "x$OPTFILE" != xNONE ; then |
598 |
if test -r $OPTFILE ; then |
if test -r $OPTFILE ; then |
599 |
OPTFILE=`pwd`"/$OPTFILE" |
# get the path |
600 |
|
path=${OPTFILE%/*} |
601 |
|
if test "x$path" = x ; then |
602 |
|
of_path=`pwd` |
603 |
|
else |
604 |
|
of_path=`( cd $path > /dev/null 2>&1 ; pwd )` |
605 |
|
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 |
fi |
612 |
fi |
fi |
613 |
echo |
echo |
631 |
# Verify that the testdir exists and contains previous |
# Verify that the testdir exists and contains previous |
632 |
# results in the correct location--or skip this directory! |
# results in the correct location--or skip this directory! |
633 |
if test ! -r $dir"/results/output.txt" ; then |
if test ! -r $dir"/results/output.txt" ; then |
|
echo |
|
634 |
echo "can't read \"$dir/results/output.txt\" -- skipping $dir" |
echo "can't read \"$dir/results/output.txt\" -- skipping $dir" |
|
echo |
|
635 |
continue |
continue |
636 |
fi |
fi |
637 |
|
|
642 |
unset genmake makedepend make run |
unset genmake makedepend make run |
643 |
results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --' |
results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --' |
644 |
|
|
645 |
if [ -r $dir/build ]; then |
builddir="input" |
646 |
seperatebuilddir=1 |
rundir="input" |
647 |
builddir=build |
use_seperate_build=0 |
648 |
rundir=build |
if test -d $dir/build -a -r $dir/build ; then |
649 |
( cd $dir/build; ln -sf ../input/* . ) |
builddir="build" |
650 |
else |
rundir="build" |
651 |
seperatebuilddir=0 |
use_seperate_build=1 |
652 |
builddir=input |
linkdata $use_seperate_build $dir/$rundir |
|
rundir=input |
|
653 |
fi |
fi |
654 |
|
|
655 |
CODE_DIR=$dir/code |
CODE_DIR=$dir/code |
660 |
# Is this an MPI run? |
# Is this an MPI run? |
661 |
if test "x$MPI" = xt ; then |
if test "x$MPI" = xt ; then |
662 |
FILES=$MPI_FILES |
FILES=$MPI_FILES |
663 |
|
endings="_mpi" |
664 |
else |
else |
665 |
FILES=$NOMPI_FILES |
FILES=$NOMPI_FILES |
666 |
|
endings="_nompi" |
667 |
fi |
fi |
668 |
|
|
669 |
# Check to see that we have the files |
# Check to see that we have the files |
682 |
# If we have the $FILES and they differ, copy the $FILES to $BUILD_DIR |
# If we have the $FILES and they differ, copy the $FILES to $BUILD_DIR |
683 |
if test "x$have_files" = xt ; then |
if test "x$have_files" = xt ; then |
684 |
for i in $FILES ; do |
for i in $FILES ; do |
685 |
cmp $CODE_DIR/$i $BUILD_DIR/$i > /dev/null 2>&1 |
sstr="s|$endings||" |
686 |
|
name=`echo $i | sed -e $sstr ` |
687 |
|
cmp $CODE_DIR/$i $BUILD_DIR/$name > /dev/null 2>&1 |
688 |
RETVAL=$? |
RETVAL=$? |
689 |
if test "x$RETVAL" != x0 ; then |
if test "x$RETVAL" != x0 ; then |
690 |
cp $CODE_DIR/$i $BUILD_DIR/$i |
cp $CODE_DIR/$i $BUILD_DIR/$name |
691 |
fi |
fi |
692 |
done |
done |
693 |
fi |
fi |
704 |
&& makeclean $dir/$builddir \ |
&& makeclean $dir/$builddir \ |
705 |
&& makedependmodel $dir/$builddir && makedepend=Y \ |
&& makedependmodel $dir/$builddir && makedepend=Y \ |
706 |
&& makemodel $dir/$builddir && make=Y \ |
&& makemodel $dir/$builddir && make=Y \ |
707 |
&& linkdata $seperatebuilddir $dir/$rundir \ |
&& linkdata $use_seperate_build $dir/$rundir \ |
708 |
&& runmodel $dir/$builddir && run=Y \ |
&& runmodel $dir/$rundir && run=Y \ |
709 |
&& results=`testoutput $dir $rundir` |
&& results=`testoutput $dir $rundir` |
710 |
fi |
fi |
711 |
|
|
748 |
|
|
749 |
done |
done |
750 |
|
|
751 |
|
echo -n "Start time: " >> $SUMMARY |
752 |
|
echo $start_date >> $SUMMARY |
753 |
|
echo -n "End time: " >> $SUMMARY |
754 |
|
date >> $SUMMARY |
755 |
|
|
756 |
rm tmp_cmpnum.f a.out |
rm tmp_cmpnum.f a.out |
757 |
|
|
758 |
cat $SUMMARY |
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 |
|
|