--- MITgcm/verification/testscript 2001/08/16 15:37:40 1.15 +++ MITgcm/verification/testscript 2003/06/23 22:13:48 1.24 @@ -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 \ @@ -138,9 +152,28 @@ ) } -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 @@ -148,7 +181,7 @@ 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 @@ -194,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/* .) + fi +} + runmodel() { # runmodel directory exe @@ -202,18 +247,12 @@ ( cd $1 if [ -x $2 ]; then - if [ ! -r output.txt -o $quick -eq 0 ]; then - echo runmodel: running... 1>&2 + if [ $quick -eq 0 ]; then rm -f output.txt - ( ./$2 > output.txt 2>&1 ) && return 0 - return 1 - else - echo runmodel: output.txt is newer than executable 1>&2 - return 0 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 ) } @@ -286,9 +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 @@ -307,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 @@ -315,21 +370,24 @@ debug=0 verbose=1 quick=0 +force=0 clean=0 ieee=1 -longtest=0 +longtest=1 expts='' # 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;; -noieee) ieee=0;; - -longtest) longtest=1;; + -shorttest) longtest=0;; -quiet) verbose=0;; -help) show_help; exit 0;; -*) echo Unrecognized option:$arg; exit 9;; @@ -337,9 +395,9 @@ esac done -if [ $clean -gt 0 -a $quick -gt 0 ]; then - echo You specified -quick and -clean together which conflict. - echo Please specify either -quick or -clean or neither but not both. +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 @@ -354,8 +412,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 . @@ -364,7 +423,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 @@ -388,12 +447,25 @@ else results='-- -- -- -- -- -- -- -- --' fi - 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` + 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 && genmake=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 echo @@ -405,4 +477,5 @@ echo ------------------------------------------------------------------------------- echo +date >> summary.txt cat summary.txt