--- MITgcm/verification/testscript 2001/08/21 15:21:10 1.17 +++ MITgcm/verification/testscript 2002/11/07 21:53:34 1.22 @@ -21,6 +21,13 @@ fi if [ -r $1/input/output.txt ]; then grep "$2" $1/input/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 @@ -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 @@ -205,7 +238,7 @@ if [ $quick -eq 0 ]; then rm -f output.txt fi - echo -n "runmodel: " 1>&2 + printf 'runmodel: ' 1>&2 make output.txt && return 0 # if [ ! -r output.txt -o $quick -eq 0 ]; then # echo runmodel: running... 1>&2 @@ -293,9 +326,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 @@ -314,6 +350,17 @@ 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' '-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 @@ -322,21 +369,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;; @@ -344,9 +394,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 @@ -396,12 +446,12 @@ results='-- -- -- -- -- -- -- -- --' fi genmakemodel $dir/input && genmake=Y \ - && makeclean $dir/input \ + && makecleancompile $dir/input \ && makedependmodel $dir/input && makedepend=Y \ && makemodel $dir/input && make=Y \ && runmodel $dir/input mitgcmuv && run=Y \ && results=`testoutput $dir` \ - && makeclean $dir/input + && makecleanupafter $dir/input echo formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results echo