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 |
echo |
54 |
echo |
echo |
55 |
HAVE_MPACK=f |
HAVE_MPACK=f |
56 |
fi |
fi |
57 |
echo -n "building mpack... " |
printf "building mpack... " |
58 |
if test "x$CC" = x ; then |
if test "x$CC" = x ; then |
59 |
export CC=cc |
export CC=cc |
60 |
fi |
fi |
77 |
|
|
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 |
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/.*=//' | cat -n > 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 |
171 |
|
|
172 |
testoutput() |
testoutput() |
173 |
{ |
{ |
174 |
# testoutput directory subdir |
# testoutput directory subdir extension |
175 |
# |
# |
176 |
# test output in "directory" |
# test output in "directory" |
177 |
if test "x$ADM" = x ; then |
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 |
fi |
185 |
testoutput_for_prop $1 "dynstat_theta_min" "theta minimum" $2; tmin=$? |
testoutput_for_prop $1 "dynstat_theta_min" "theta minimum" $2 $3; tmin=$? |
186 |
testoutput_for_prop $1 "dynstat_theta_max" "theta maximum" $2; tmax=$? |
testoutput_for_prop $1 "dynstat_theta_max" "theta maximum" $2 $3; tmax=$? |
187 |
testoutput_for_prop $1 "dynstat_theta_mean" "theta mean" $2; tmean=$? |
testoutput_for_prop $1 "dynstat_theta_mean" "theta mean" $2 $3; tmean=$? |
188 |
testoutput_for_prop $1 "dynstat_theta_sd" "theta s.d." $2; tsd=$? |
testoutput_for_prop $1 "dynstat_theta_sd" "theta s.d." $2 $3; tsd=$? |
189 |
testoutput_for_prop $1 "dynstat_salt_min" "salt minimum" $2; smin=$? |
testoutput_for_prop $1 "dynstat_salt_min" "salt minimum" $2 $3; smin=$? |
190 |
testoutput_for_prop $1 "dynstat_salt_max" "salt maximum" $2; smax=$? |
testoutput_for_prop $1 "dynstat_salt_max" "salt maximum" $2 $3; smax=$? |
191 |
testoutput_for_prop $1 "dynstat_salt_mean" "salt mean" $2; smean=$? |
testoutput_for_prop $1 "dynstat_salt_mean" "salt mean" $2 $3; smean=$? |
192 |
testoutput_for_prop $1 "dynstat_salt_sd" "salt s.d." $2; ssd=$? |
testoutput_for_prop $1 "dynstat_salt_sd" "salt s.d." $2 $3; ssd=$? |
193 |
testoutput_for_prop $1 "dynstat_uvel_min" "U minimum" $2; umin=$? |
testoutput_for_prop $1 "dynstat_uvel_min" "U minimum" $2 $3; umin=$? |
194 |
testoutput_for_prop $1 "dynstat_uvel_max" "U maximum" $2; umax=$? |
testoutput_for_prop $1 "dynstat_uvel_max" "U maximum" $2 $3; umax=$? |
195 |
testoutput_for_prop $1 "dynstat_uvel_mean" "U mean" $2; umean=$? |
testoutput_for_prop $1 "dynstat_uvel_mean" "U mean" $2 $3; umean=$? |
196 |
testoutput_for_prop $1 "dynstat_uvel_sd" "U s.d." $2; usd=$? |
testoutput_for_prop $1 "dynstat_uvel_sd" "U s.d." $2 $3; usd=$? |
197 |
testoutput_for_prop $1 "dynstat_vvel_min" "V minimum" $2; vmin=$? |
testoutput_for_prop $1 "dynstat_vvel_min" "V minimum" $2 $3; vmin=$? |
198 |
testoutput_for_prop $1 "dynstat_vvel_max" "V maximum" $2; vmax=$? |
testoutput_for_prop $1 "dynstat_vvel_max" "V maximum" $2 $3; vmax=$? |
199 |
testoutput_for_prop $1 "dynstat_vvel_mean" "V mean" $2; vmean=$? |
testoutput_for_prop $1 "dynstat_vvel_mean" "V mean" $2 $3; vmean=$? |
200 |
testoutput_for_prop $1 "dynstat_vvel_sd" "V s.d." $2; vsd=$? |
testoutput_for_prop $1 "dynstat_vvel_sd" "V s.d." $2 $3; vsd=$? |
201 |
dashnum $cg2dres $tmin $tmax $tmean $tsd $smin $smax $smean $ssd \ |
dashnum $cg2dres $tmin $tmax $tmean $tsd $smin $smax $smean $ssd \ |
202 |
$umin $umax $umean $usd $vmin $vmax $vmean $vsd |
$umin $umax $umean $usd $vmin $vmax $vmean $vsd |
203 |
else |
else |
211 |
if test "x$NOGENMAKE" = xt ; then |
if test "x$NOGENMAKE" = xt ; then |
212 |
echo "genmake skipped!" |
echo "genmake skipped!" |
213 |
else |
else |
214 |
GENMAKE2="$BASH ../../../tools/genmake2" |
if test "x$BASH" = x ; then |
215 |
|
GENMAKE2="../../../tools/genmake2" |
216 |
|
else |
217 |
|
GENMAKE2="$BASH ../../../tools/genmake2 -bash $BASH" |
218 |
|
fi |
219 |
( |
( |
220 |
cd $1; |
cd $1; |
221 |
command="$GENMAKE2 -ds -m $MAKE" |
command="$GENMAKE2 -ds -m $MAKE" |
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 |
413 |
cd $1 |
cd $1 |
414 |
printf 'runmodel ... ' 1>&2 |
printf 'runmodel ... ' 1>&2 |
415 |
# make output.txt |
# make output.txt |
416 |
$COMMAND >> run.log 2>&1 |
echo |
417 |
|
echo "COMMAND='$COMMAND'" |
418 |
|
echo "pwd='"`pwd`"'" |
419 |
|
( 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 |
echo successful 1>&2 |
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.c <<EOF |
cat > tmp_cmpnum.c <<EOF |
444 |
#include <stdio.h> |
#include <stdio.h> |
445 |
#include <math.h> |
#include <math.h> |
446 |
int main( int argc, char** argv ) { |
int main( int argc, char** argv ) { |
447 |
int linnum,best; |
int linnum,best,lncnt; |
448 |
double a,b,diff; |
double a,b,diff; |
449 |
best = -16; |
best = -16; |
450 |
while( 1 ) { |
lncnt = 0; |
451 |
|
while( 1 & (lncnt+=1) < 999 ) { |
452 |
scanf("%d", &linnum); |
scanf("%d", &linnum); |
453 |
if (linnum == -1) break; |
if (linnum == -1) break; |
454 |
scanf("%lf", &a); scanf("%lf", &b); |
scanf("%lf", &a); scanf("%lf", &b); |
464 |
} |
} |
465 |
} |
} |
466 |
} |
} |
467 |
|
if (lncnt == 999) best=-29; |
468 |
printf("%d\n", -best); |
printf("%d\n", -best); |
469 |
return 0; |
return 0; |
470 |
} |
} |
570 |
|
|
571 |
ADM= |
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 |
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` |
708 |
exit 1 |
exit 1 |
709 |
fi |
fi |
710 |
SUMMARY="$DRESULTS/summary.txt" |
SUMMARY="$DRESULTS/summary.txt" |
711 |
echo -n "Start time: " >> $SUMMARY |
printf "Start time: " >> $SUMMARY |
712 |
start_date=`date` |
start_date=`date` |
713 |
echo $start_date > $SUMMARY |
echo $start_date > $SUMMARY |
714 |
|
|
787 |
continue |
continue |
788 |
fi |
fi |
789 |
|
|
|
echo "-------------------------------------------------------------------------------" |
|
|
echo |
|
|
echo "Experiment: $dir" |
|
|
echo |
|
|
unset genmake makedepend make run |
|
|
results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --' |
|
|
|
|
790 |
builddir="input" |
builddir="input" |
791 |
rundir="input" |
rundir="input" |
792 |
use_seperate_build=0 |
use_seperate_build=0 |
797 |
linkdata $use_seperate_build $dir/$rundir |
linkdata $use_seperate_build $dir/$rundir |
798 |
fi |
fi |
799 |
|
|
800 |
|
# Check whether there are "extra runs" for this testdir |
801 |
|
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 |
if test "x$ADM" = x ; then |
if test "x$ADM" = x ; then |
815 |
|
code_dir=code |
816 |
CODE_DIR=$dir/code |
CODE_DIR=$dir/code |
817 |
else |
else |
818 |
|
code_dir=code_ad |
819 |
CODE_DIR=$dir/code_ad |
CODE_DIR=$dir/code_ad |
820 |
fi |
fi |
821 |
BUILD_DIR=$dir/$builddir |
BUILD_DIR=$dir/$builddir |
|
MPI_FILES="CPP_EEOPTIONS.h_mpi SIZE.h_mpi" |
|
|
NOMPI_FILES="CPP_EEOPTIONS.h_nompi SIZE.h_nompi" |
|
822 |
|
|
823 |
# Is this an MPI run? |
if test ! -r $CODE_DIR"/SIZE.h_mpi" -a "x$MPI" = "xt" ; then |
824 |
if test "x$MPI" = xt ; then |
echo "can't find \"$CODE_DIR/SIZE.h_mpi\" -- skipping $dir" |
|
FILES=$MPI_FILES |
|
|
endings="_mpi" |
|
|
else |
|
|
FILES=$NOMPI_FILES |
|
|
endings="_nompi" |
|
|
fi |
|
|
|
|
|
# Check to see that we have the files |
|
|
have_files=t |
|
|
for i in $FILES ; do |
|
|
if test ! -r $CODE_DIR/$i ; then |
|
|
echo "Warning: can't read file $CODE_DIR/$i" |
|
|
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)" |
|
825 |
continue |
continue |
826 |
fi |
fi |
827 |
|
|
828 |
# If we have the $FILES and they differ, copy the $FILES to $BUILD_DIR |
echo "-------------------------------------------------------------------------------" |
829 |
if test "x$have_files" = xt ; then |
echo |
830 |
for i in $FILES ; do |
echo "Experiment: $dir" |
831 |
sstr="s|$endings||" |
echo |
832 |
name=`echo $i | sed -e $sstr ` |
unset genmake makedepend make run |
833 |
cmp $CODE_DIR/$i $BUILD_DIR/$name > /dev/null 2>&1 |
results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --' |
834 |
RETVAL=$? |
|
|
if test "x$RETVAL" != x0 ; then |
|
|
cp $CODE_DIR/$i $BUILD_DIR/$name |
|
|
fi |
|
|
done |
|
|
fi |
|
|
|
|
835 |
# Create an output dir for each OPTFILE/tdir combination |
# Create an output dir for each OPTFILE/tdir combination |
836 |
rel_CDIR=$DRESULTS"/"$dir |
rel_CDIR=$DRESULTS"/"$dir |
837 |
mkdir $rel_CDIR |
mkdir $rel_CDIR |
842 |
else |
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 $use_seperate_build $dir/$rundir \ |
&& linkdata $use_seperate_build $dir/$rundir \ |
853 |
echo |
echo |
854 |
if test "x$ADM" = x ; then |
if test "x$ADM" = x ; then |
855 |
fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results` |
fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results` |
856 |
|
echo |
857 |
|
echo "$fres" >> $SUMMARY |
858 |
|
echo "fresults='$fres'" > $CDIR"/summary.txt" |
859 |
|
echo "MACH='$MACH'" >> $CDIR"/summary.txt" |
860 |
|
echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt" |
861 |
|
echo "DATE='$DATE'" >> $CDIR"/summary.txt" |
862 |
|
echo "tdir='$dir'" >> $CDIR"/summary.txt" |
863 |
|
|
864 |
|
OLD_COMMAND=$COMMAND |
865 |
|
COMMAND="./mitgcmuv > output.txt" |
866 |
|
for ex in $extra_runs ; do |
867 |
|
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 |
else |
900 |
fres=`printf '%s %s %s %s' ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N}` |
fres=`printf '%s %s %s %s' ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N}` |
901 |
fres=$fres"$results $dir" |
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 |
fi |
|
echo |
|
|
echo "$fres" >> $SUMMARY |
|
|
echo "fresults='$fres'" > $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" |
|
910 |
|
|
911 |
echo "-------------------------------------------------------------------------------" |
echo "-------------------------------------------------------------------------------" |
912 |
|
|
913 |
done |
done |
914 |
|
|
915 |
echo -n "Start time: " >> $SUMMARY |
printf "Start time: " >> $SUMMARY |
916 |
echo $start_date >> $SUMMARY |
echo $start_date >> $SUMMARY |
917 |
echo -n "End time: " >> $SUMMARY |
printf "End time: " >> $SUMMARY |
918 |
date >> $SUMMARY |
date >> $SUMMARY |
919 |
|
|
920 |
# If addresses were supplied and mpack built successfully, then try |
# If addresses were supplied and mpack built successfully, then try |