--- MITgcm/verification/testscript 2001/08/10 18:18:52 1.11 +++ MITgcm/verification/testscript 2003/12/03 19:43:51 1.26 @@ -11,16 +11,23 @@ testoutput_for_prop() { -# testoutput_for_prop dir s1 label +# testoutput_for_prop dir s1 label subdir # -# compares files in $dir/input/output.txt and $dir/results.output.txt +# compares files in $dir/$subdir/output.txt and $dir/results/output.txt # using search strings s1 and text label if [ $debug -gt 0 ]; then - echo testoutput_for_prop: grep "$2" $1/input/output.txt 1>&2 + echo testoutput_for_prop: grep "$2" $1/$4/output.txt 1>&2 fi - if [ -r $1/input/output.txt ]; then - grep "$2" $1/input/output.txt | sed 's/.*=//' | nl > tmp1.txt + if [ -r $1/$4/output.txt ]; then + grep "$2" $1/$4/output.txt | sed 's/.*=//' | nl > tmp1.txt + lncnt=`wc -l tmp1.txt | awk '{print $1}' ` + if [ $lncnt -lt 3 ]; then + if [ $verbose -gt 0 ]; then + echo Not enough lines of output when searching for "$2" 1>&2 + fi + return 99 + fi else echo testoutput_for_prop: output.txt from model run was not readable 1>&2 return 99 @@ -29,6 +36,13 @@ echo testoutput_for_prop: grep "$2" $1/results/output.txt 1>&2 fi grep "$2" $1/results/output.txt | sed 's/.*=//' | nl > tmp2.txt + lncnt=`wc -l tmp2.txt | awk '{print $1}' ` + if [ $lncnt -lt 3 ]; then + if [ $verbose -gt 0 ]; then + echo Not enough lines of output when searching for "$2" 1>&2 + fi + return 99 + fi if [ $debug -gt 0 ]; then echo testoutput_for_prop: join tmp1.txt tmp2.txt 1>&2 fi @@ -70,44 +84,44 @@ testoutput() { -# testoutput diretory +# testoutput diretory subdir # # test output in "directory" if [ $debug -gt 0 ]; then echo testoutput: testoutput_for_prop $1 cg2d_init_res 1>&2 fi -testoutput_for_prop $1 "cg2d_init_res" "cg2d init. residual"; cg2dres=$? +testoutput_for_prop $1 "cg2d_init_res" "cg2d init. residual" $2; cg2dres=$? if [ $debug -gt 0 ]; then echo testoutput: cg2dres=$cg2dres 1>&2 fi if [ $longtest -gt 0 ]; then -testoutput_for_prop $1 "dynstat_theta_min" "theta minimum"; tmin=$? -testoutput_for_prop $1 "dynstat_theta_max" "theta maximum"; tmax=$? -testoutput_for_prop $1 "dynstat_theta_mean" "theta mean"; tmean=$? -testoutput_for_prop $1 "dynstat_theta_sd" "theta s.d."; tsd=$? -testoutput_for_prop $1 "dynstat_salt_min" "salt minimum"; smin=$? -testoutput_for_prop $1 "dynstat_salt_max" "salt maximum"; smax=$? -testoutput_for_prop $1 "dynstat_salt_mean" "salt mean"; smean=$? -testoutput_for_prop $1 "dynstat_salt_sd" "salt s.d."; ssd=$? -testoutput_for_prop $1 "dynstat_uvel_min" "U minimum"; umin=$? -testoutput_for_prop $1 "dynstat_uvel_max" "U maximum"; umax=$? -testoutput_for_prop $1 "dynstat_uvel_mean" "U mean"; umean=$? -testoutput_for_prop $1 "dynstat_uvel_sd" "U s.d."; usd=$? -testoutput_for_prop $1 "dynstat_vvel_min" "V minimum"; vmin=$? -testoutput_for_prop $1 "dynstat_vvel_max" "V maximum"; vmax=$? -testoutput_for_prop $1 "dynstat_vvel_mean" "V mean"; vmean=$? -testoutput_for_prop $1 "dynstat_vvel_sd" "V s.d."; vsd=$? +testoutput_for_prop $1 "dynstat_theta_min" "theta minimum" $2; tmin=$? +testoutput_for_prop $1 "dynstat_theta_max" "theta maximum" $2; tmax=$? +testoutput_for_prop $1 "dynstat_theta_mean" "theta mean" $2; tmean=$? +testoutput_for_prop $1 "dynstat_theta_sd" "theta s.d." $2; tsd=$? +testoutput_for_prop $1 "dynstat_salt_min" "salt minimum" $2; smin=$? +testoutput_for_prop $1 "dynstat_salt_max" "salt maximum" $2; smax=$? +testoutput_for_prop $1 "dynstat_salt_mean" "salt mean" $2; smean=$? +testoutput_for_prop $1 "dynstat_salt_sd" "salt s.d." $2; ssd=$? +testoutput_for_prop $1 "dynstat_uvel_min" "U minimum" $2; umin=$? +testoutput_for_prop $1 "dynstat_uvel_max" "U maximum" $2; umax=$? +testoutput_for_prop $1 "dynstat_uvel_mean" "U mean" $2; umean=$? +testoutput_for_prop $1 "dynstat_uvel_sd" "U s.d." $2; usd=$? +testoutput_for_prop $1 "dynstat_vvel_min" "V minimum" $2; vmin=$? +testoutput_for_prop $1 "dynstat_vvel_max" "V maximum" $2; vmax=$? +testoutput_for_prop $1 "dynstat_vvel_mean" "V mean" $2; vmean=$? +testoutput_for_prop $1 "dynstat_vvel_sd" "V s.d." $2; vsd=$? else -testoutput_for_prop $1 "dynstat_theta_min" "theta minimum"; tmin=$? -testoutput_for_prop $1 "dynstat_theta_max" "theta maximum"; tmax=$? -testoutput_for_prop $1 "dynstat_salt_min" "salt minimum"; smin=$? -testoutput_for_prop $1 "dynstat_salt_max" "salt maximum"; smax=$? -testoutput_for_prop $1 "dynstat_uvel_min" "U minimum"; umin=$? -testoutput_for_prop $1 "dynstat_uvel_max" "U maximum"; umax=$? -testoutput_for_prop $1 "dynstat_vvel_min" "V minimum"; vmin=$? -testoutput_for_prop $1 "dynstat_vvel_max" "V maximum"; vmax=$? +testoutput_for_prop $1 "dynstat_theta_min" "theta minimum" $2; tmin=$? +testoutput_for_prop $1 "dynstat_theta_max" "theta maximum" $2; tmax=$? +testoutput_for_prop $1 "dynstat_salt_min" "salt minimum" $2; smin=$? +testoutput_for_prop $1 "dynstat_salt_max" "salt maximum" $2; smax=$? +testoutput_for_prop $1 "dynstat_uvel_min" "U minimum" $2; umin=$? +testoutput_for_prop $1 "dynstat_uvel_max" "U maximum" $2; umax=$? +testoutput_for_prop $1 "dynstat_vvel_min" "V minimum" $2; vmin=$? +testoutput_for_prop $1 "dynstat_vvel_max" "V maximum" $2; vmax=$? fi dashnum $cg2dres $tmin $tmax $tmean $tsd $smin $smax $smean $ssd \ @@ -122,10 +136,14 @@ ( cd $1; if [ $quick -eq 0 -o ! -r Makefile ]; then printf 'genmake ... ' 1>&2 - ../../../tools/genmake -ieee -mods=../code > make.log 2>&1 + if [ $ieee -eq 0 ]; then + ../../../tools/genmake2 -mods=../code > make.log 2>&1 + else + ../../../tools/genmake2 -ieee -mods=../code > make.log 2>&1 + fi if [ $? -ne 0 ]; then tail make.log - echo genmakemodel: genmake failed 1>&2 + echo genmakemodel: $genmake failed 1>&2 return 1 else echo succesful 1>&2 @@ -134,16 +152,36 @@ ) } -makeclean() +makecleancompile() { -# makedependmodel directory +# makecleancompile directory + ( cd $1; + if [ $force -gt 0 ]; then + rm -f output.txt + printf 'make clean ... ' 2>&1 + make CLEAN >> make.log 2>&1 + if [ $? -ne 0 ]; then + tail make.log + echo makecleancompile: make clean failed 1>&2 + return 1 + else + echo succesful 1>&2 + fi + fi + ) +} + +makecleanupafter() +{ +# makeupafter directory ( cd $1; if [ $clean -gt 0 ]; then + rm -f output.txt printf 'make clean ... ' 2>&1 make CLEAN >> make.log 2>&1 if [ $? -ne 0 ]; then tail make.log - echo makeclean: make clean failed 1>&2 + echo makeupafter: make clean failed 1>&2 return 1 else echo succesful 1>&2 @@ -189,6 +227,18 @@ ) } +linkdata() +{ +# linkdata flag +# symbolically link data files to run directory + if [ $1 -ne 0 ]; then +# if [ ! -r $2 ]; then +# mkdir $2 +# fi + ( cd $2; ln -sf ../input/{eedata,data*,*.bin,POLY3*,pickup*} .) + fi +} + runmodel() { # runmodel directory exe @@ -197,17 +247,12 @@ ( cd $1 if [ -x $2 ]; then - if [ ! -r output.txt -o $quick -eq 0 ]; then - echo runmodel: running... 1>&2 - ( ./$2 > output.txt 2>&1 ) && return 0 - return 1 - else - echo runmodel: output.txt is newer than executable 1>&2 - return 0 + if [ $quick -eq 0 ]; then + rm -f output.txt fi - else - echo runmodel: executable \"$1/$2\" is missing 1>&2 - return 1 + printf 'runmodel: ' 1>&2 + make output.txt && return 0 + return 1 fi ) } @@ -280,8 +325,12 @@ -quiet Reduce the amount of output -verbose Produce copious amounts of output -debug Produce even more output which will mean nothing to most - -clean Do "make CLEAN" before compiling. This forces a complete rebuild. - -longtest Compare numeric output for mean and s.d. of variables. + -force Do "make CLEAN" before compiling. This forces a complete rebuild. + -clean Do "make CLEAN" after compiling and testing. + -shorttest Don't compare numeric output for mean and s.d. of variables. + -noieee By default, $0 uses the -ieee option for genmake. This turns it off. + -cleanup Aggresively removes all model output, executables and object files + and then exits. Use with care. Normal usage: $0 * Configure, compile, run and analyze in all experiment directories @@ -300,6 +349,19 @@ fi } +clean_up() +{ +# Find all executables, object files, CPP'd source and model output +# and DELETE it. +for opt in '-name "mitgcmuv*"' '-name "*.o"' '-name "*.f"' '-name "*.c"' '-name "fort.*"' '-name "make.log"' '-path *results -prune -o -name "*.meta"' '-path *results -prune -o -name "*.data"' '-type l' + do + echo Cleaning: find . $opt -exec rm {} \; + find . $opt -exec rm {} \; +done +} + +############################################################################### +############################################################################### ############################################################################### # Main function @@ -308,25 +370,38 @@ debug=0 verbose=1 quick=0 +force=0 clean=0 -longtest=0 +ieee=1 +longtest=1 expts='' +genmake=genmake # Process arguments for arg in $@ do case $arg in + -cleanup) clean_up; exit 0;; -quick) quick=1;; -verbose) verbose=2;; -debug) debug=1;; + -force) force=1;; -clean) clean=1;; - -longtest) longtest=1;; + -noieee) ieee=0;; + -shorttest) longtest=0;; -quiet) verbose=0;; -help) show_help; exit 0;; + -*) echo Unrecognized option:$arg; exit 9;; *) test -d $arg && expts=`echo $expts $arg`;; esac done +if [ $force -gt 0 -a $quick -gt 0 ]; then + echo You specified -quick and -force together which conflict. + echo Please specify either -quick or -force or neither but not both. + exit 1 +fi + #if [ ${#expts} -eq 0 ]; then # echo Scanning all directories # for arg in * @@ -338,8 +413,9 @@ createcodelet +date > summary.txt if [ $longtest -gt 0 ]; then -cat << EOF > summary.txt +cat << EOF >> summary.txt T S U V C D M c m s m s m s m s n p a R g m m e . m m e . m m e . m m e . @@ -348,7 +424,7 @@ EOF else -cat << EOF > summary.txt +cat << EOF >> summary.txt T S U V C D M c n p a R g m m m m m m m m @@ -366,19 +442,35 @@ echo echo Experiment: $dir echo - unset genmake makedepend make run - results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --' - results='-- -- -- -- -- -- -- -- --' - genmakemodel $dir/input && genmake=Y \ - && makeclean $dir/input \ - && makedependmodel $dir/input && makedepend=Y \ - && makemodel $dir/input && make=Y \ - && runmodel $dir/input mitgcmuv && run=Y \ - && results=`testoutput $dir` + unset genmakepass makedepend make run + if [ $longtest -gt 0 ]; then + results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --' + else + results='-- -- -- -- -- -- -- -- --' + fi + if [ -r $dir/build ]; then + seperatebuilddir=1 + builddir=build + rundir=build + (cd $dir/input; rm -f *.{o,f,c,F} work* output.txt Make* make.log; ) + (cd $dir/build; ln -sf ../input/* .) + else + seperatebuilddir=0 + builddir=input + rundir=input + fi + genmakemodel $dir/$builddir && genmakepass=Y \ + && makecleancompile $dir/$builddir \ + && makedependmodel $dir/$builddir && makedepend=Y \ + && makemodel $dir/$builddir && make=Y \ + && linkdata $seperatebuilddir $dir/$rundir \ + && runmodel $dir/$builddir mitgcmuv && run=Y \ + && results=`testoutput $dir $rundir` \ + && makecleanupafter $dir/$builddir echo - formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results + formatresults $dir ${genmakepass:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results echo - formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results >> summary.txt + formatresults $dir ${genmakepass:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results >> summary.txt fi done @@ -386,4 +478,5 @@ echo ------------------------------------------------------------------------------- echo +date >> summary.txt cat summary.txt