--- MITgcm/verification/testscript 2001/08/03 20:18:40 1.8 +++ MITgcm/verification/testscript 2001/08/14 18:29:43 1.13 @@ -1,52 +1,11 @@ #!/bin/sh -similar() -{ -# similar digits a b -# -# compare the floating point number a and b and successively reduced -# truncation until a match is found - for digits in 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 - do - a=`printf '%22.'$digits'e\n' $1` - b=`printf '%22.'$digits'e\n' $2` - if [ $a = $b ]; then - if [ $verbose -gt 1 ]; then - echo $1 $2 $a 1>&2 - fi - break - fi - done - return $digits -} - compare_lines() { -# compare_lines digits < file -# -# read each line of file and test the 2nd and 3rd column values for -# similarity based on the function similar() - worst_so_far=$1 - while read linenum a b - do - if [ $debug -gt 0 ]; then - echo compare_lines: similar a=$a b=$b 1>&2 - fi - similar $a $b - digits=$? - if [ $digits -lt $worst_so_far ]; then - worst_so_far=$digits - fi - done - if [ $debug -gt 0 ]; then - echo compare_lines: worst_so_far=$worst_so_far 1>&2 - fi - return $worst_so_far -} - -compare_lines2() -{ # use codelet to compare lines + if [ $verbose -gt 1 ]; then + cat tmp3.txt 1>&2 + fi return `./a.out < tmp3.txt` } @@ -77,8 +36,7 @@ if [ $debug -gt 0 ]; then echo testoutput_for_prop: compare_lines 1>&2 fi - #compare_lines 99 < tmp3.txt - compare_lines2 + compare_lines digits_of_similarity=$? if [ $digits_of_similarity -eq 99 ]; then if [ $verbose -gt 0 ]; then @@ -124,7 +82,7 @@ echo testoutput: cg2dres=$cg2dres 1>&2 fi -if [ $testmore -gt 0 ]; then +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=$? @@ -164,10 +122,14 @@ ( cd $1; if [ $quick -eq 0 -o ! -r Makefile ]; then printf 'genmake ... ' 1>&2 - ../../../tools/genmake -mods=../code > make.log 2>&1 + if [ $ieee -eq 0 ]; then + ../../../tools/genmake -mods=../code > make.log 2>&1 + else + ../../../tools/genmake -ieee -mods=../code > make.log 2>&1 + fi if [ $? -ne 0 ]; then tail make.log - echo makemodel: genmake failed 1>&2 + echo genmakemodel: genmake failed 1>&2 return 1 else echo succesful 1>&2 @@ -176,6 +138,24 @@ ) } +makeclean() +{ +# makedependmodel directory + ( cd $1; + if [ $clean -gt 0 ]; then + 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 + return 1 + else + echo succesful 1>&2 + fi + fi + ) +} + makedependmodel() { # makedependmodel directory @@ -247,18 +227,16 @@ best=-16 99 read(*,*,end=70,err=60) linnum,a,b diff=0.5*(abs(a)+abs(b)) - if (diff.gt.0.) then +c print *,a,b,diff,abs(a-b)/diff + if (diff.gt.1.e-12) then diff=abs(a-b)/diff if (diff.gt.0.) then c print *,int(log10(diff)),diff linnum=int(log10(diff)) best=max(best,linnum) -c else -c print *,-16 endif -c else -c diff=0. -c print *,-16 + else + if (best.eq.-16.and.diff.ne.0.) best=-22 endif goto 99 60 stop 'cmpnum: An error occured reading a,b' @@ -305,12 +283,27 @@ -quick Skip "genmake" and "make depend" if the Makefile exists -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. Normal usage: $0 * Configure, compile, run and analyze in all experiment directories EOF } +scandirs() +{ +if [ $# -eq 0 ]; then + for arg in * + do + test -d $arg/input && echo $arg + done +else + echo $* +fi +} + ############################################################################### # Main function @@ -319,7 +312,9 @@ debug=0 verbose=1 quick=0 -testmore=0 +clean=0 +ieee=0 +longtest=0 expts='' # Process arguments @@ -329,24 +324,28 @@ -quick) quick=1;; -verbose) verbose=2;; -debug) debug=1;; - -testmore) testmore=1;; + -clean) clean=1;; + -ieee) ieee=1;; + -longtest) longtest=1;; -quiet) verbose=0;; -help) show_help; exit 0;; + -*) echo Unrecognized option:$arg; exit 9;; *) test -d $arg && expts=`echo $expts $arg`;; esac done -if [ ${#expts} -eq 0 ]; then - echo Scanning all directories - for arg in * - do - test -d $arg && expts=`echo $expts $arg` - done -fi +#if [ ${#expts} -eq 0 ]; then +# echo Scanning all directories +# for arg in * +# do +# test -d $arg && expts=`echo $expts $arg` +# done +#fi +expts=`scandirs $expts` createcodelet -if [ $testmore -eq 0 ]; then +if [ $longtest -gt 0 ]; then cat << EOF > summary.txt T S U V C D M c m s m s m s m s @@ -375,9 +374,13 @@ echo Experiment: $dir echo unset genmake makedepend make run - results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --' - results='-- -- -- -- -- -- -- -- --' + if [ $longtest -gt 0 ]; then + results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --' + 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 \