--- MITgcm/verification/testreport 2006/07/05 22:39:57 1.83 +++ MITgcm/verification/testreport 2007/01/31 21:28:34 1.90 @@ -1,6 +1,6 @@ #! /usr/bin/env bash # -# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/verification/testreport,v 1.83 2006/07/05 22:39:57 jmc Exp $ +# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/verification/testreport,v 1.90 2007/01/31 21:28:34 ce107 Exp $ # $Name: $ # @@ -15,11 +15,14 @@ echo " (-mpi) compile and run using MPI" echo " (-ieee|-noieee) if possible, use IEEE compiler flags" echo " (DEF=\"-ieee\")" - echo " (-optfile=|-of=)STRING list of optfiles to use" + echo " (-of=|-optfile=)STRING list of optfiles to use" echo " (-a|-addr) STRING list of email recipients" echo " (DEF=\"edhill@mitgcm.org\")" - echo " (-t|-tdir) STRING list of test dirs to use" - echo " (DEF=\"\" which builds all)" + echo " (-t|-tdir) STRING list of group and/or exp. dirs to test" + echo " (recognized groups: basic, tutorials)" + echo " (DEF=\"\" which test all)" + echo " (-skd|-skipdir) STRING list of exp. dirs to skip" + echo " (DEF=\"\" which test all)" echo " (-b|-bash) STRING preferred location of a \"bash\" or" echo " Bourne-compatible \"sh\" shell" echo " (DEF=\"\" for \"bash\")" @@ -30,7 +33,7 @@ echo " (DEF=\"make\")" echo " (-odir) STRING used to build output directory name" echo " (DEF=\"hostname\")" - echo " (-ptracers|-ptr) STRING specify which ptracers to test" + echo " (-ptr|-ptracers) STRING specify which ptracers to test" echo " (DEF=\"1 2 3 4 5\")" echo " (-j) JOBS use \"make -j JOBS\" for parallel builds" echo " (-clean) *ONLY* run \"make CLEAN\"" @@ -39,6 +42,9 @@ echo " (-noclean|-nc) skip the \"make clean\" stage" echo " (-nodepend|-nd) skip the \"make depend\" stage" echo " (-deldir|-dd) on success, delete the output directory" + echo " (-ts) provide timing information per timestep" + echo " (-papis) provide MFlop/s per timestep using PAPI" + echo " (-pcls) provide MFlop/s per timestep using PCL" echo echo "and where STRING can be a whitespace-delimited list" echo "such as:" @@ -90,14 +96,14 @@ { # testoutput_for_prop dir s1 label subdir extension # - # compares files in $dir/$subdir/output.txt and $dir/results/output.txt + # compares files $dir/$subdir/$OUTPUTFILE and $dir/results/output.txt # using search strings s1 and text label if [ $debug -gt 0 ]; then - echo testoutput_for_prop: grep "$2" $1/$4/output.txt 1>&2 + echo testoutput_for_prop: grep "$2" $1/$4/$OUTPUTFILE 1>&2 fi - if [ -r $1/$4/output.txt ]; then - grep "$2" $1/$4/output.txt | sed 's/.*=//' | cat -n > tmp1.txt + if [ -r $1/$4/$OUTPUTFILE ]; then + grep "$2" $1/$4/$OUTPUTFILE | sed 's/.*=//' | cat -n > tmp1.txt lncntA=`wc -l tmp1.txt | awk '{print $1}' ` if [ $lncntA -lt 3 ]; then if [ $verbose -gt 0 ]; then @@ -106,13 +112,13 @@ return 99 fi else - echo testoutput_for_prop: output.txt from model run was not readable 1>&2 + echo testoutput_for_prop: $OUTPUTFILE from model run was not readable 1>&2 return 99 fi if [ $debug -gt 0 ]; then - echo testoutput_for_prop: grep "$2" $1/results/output.txt$5 1>&2 + echo testoutput_for_prop: grep "$2" $1/results/output.$5 1>&2 fi - grep "$2" $1/results/output.txt$5 | sed 's/.*=//' | cat -n > tmp2.txt + grep "$2" $1/results/output.$5 | sed 's/.*=//' | cat -n > tmp2.txt lncntB=`wc -l tmp2.txt | awk '{print $1}' ` if [ $lncntB -lt 3 ]; then if [ $verbose -gt 0 ]; then @@ -128,12 +134,12 @@ fi has_nan=`cat tmp1.txt | grep -i nan | wc -l` if [ $has_nan -gt 0 ] ; then - echo testoutput_for_prop: output.txt contains $has_nan NaN values 1>&2 + echo testoutput_for_prop: $OUTPUTFILE contains $has_nan NaN values 1>&2 return 99 fi has_inf=`cat tmp1.txt | grep -i inf | wc -l` if [ $has_inf -gt 0 ] ; then - echo testoutput_for_prop: output.txt contains $has_inf Inf values 1>&2 + echo testoutput_for_prop: $OUTPUTFILE contains $has_inf Inf values 1>&2 return 99 fi if [ $debug -gt 0 ]; then @@ -183,9 +189,9 @@ testoutput_ad() { grep $3 $1/results_ad/output_adm.txt | awk '{print NR " " $5}' > t05.txt - grep $3 $1/$2/output_adm.txt | awk '{print NR " " $5}' > t15.txt + grep $3 $1/$2/$OUTPUTFILE | awk '{print NR " " $5}' > t15.txt grep $3 $1/results_ad/output_adm.txt | awk '{print NR " " $6}' > t06.txt - grep $3 $1/$2/output_adm.txt | awk '{print NR " " $6}' > t16.txt + grep $3 $1/$2/$OUTPUTFILE | awk '{print NR " " $6}' > t16.txt join t05.txt t15.txt > t5.txt join t06.txt t16.txt > t6.txt echo "-1" >> t5.txt @@ -315,6 +321,16 @@ if test "x$MPI" = xt ; then command="$command -mpi" fi + if test "x$TS" = xt ; then + command="$command -ts" + fi + if test "x$PAPIS" = xt ; then + command="$command -papis" + else + if test "x$PCLS" = xt ; then + command="$command -pcls" + fi + fi printf 'genmake ... ' 1>&2 $command > make.log 2>&1 RETVAL=$? @@ -340,7 +356,7 @@ else ( cd $1; - #if test -e output.txt ; then rm -f output.txt ; fi + #if test -e $OUTPUTFILE ; then rm -f $OUTPUTFILE ; fi if test -r Makefile ; then printf 'clean build-dir: make Clean ... ' 2>&1 $MAKE Clean >> make.log 2>&1 @@ -535,41 +551,48 @@ printf 'runmodel in %s ...' $1 1>&2 # make output.txt echo - rm -f run.log if test ! -x $EXECUTABLE -a -x "../"$builddir"/"$EXECUTABLE ; then - echo " link" $EXECUTABLE "from dir ../"$builddir > run.log + echo " link" $EXECUTABLE "from dir ../"$builddir > run.log_00 ln -sf "../"$builddir"/"$EXECUTABLE . - else - touch run.log fi if test ! -x $EXECUTABLE ; then + rm -f run.log ; touch run.log + if test -f run.log_00 ; then cat run.log_00 >> run.log ; fi echo " no executable:" $EXECUTABLE >> run.log RETVAL=8 + ENDVAL=-1 else if test $OUTPUTFILE -ot $EXECUTABLE ; then + rm -f run.log ; touch run.log + if test -f run.log_00 ; then cat run.log_00 >> run.log ; fi ( eval $COMMAND ) >> run.log 2>&1 RETVAL=$? else - echo " $OUTPUTFILE is up to date " >> run.log 2>&1 RETVAL=0 + if test -f run.log ; then + if test -f run.log_00 ; then cat run.log_00 >> run.log ; fi + echo "---------->> $OUTPUTFILE is up to date " >> run.log 2>&1 + else + touch run.log + if test -f run.log_00 ; then cat run.log_00 >> run.log ; fi + echo "---------->> $OUTPUTFILE is up to date " >> run.log 2>&1 + echo " no previous run.log: assume NORMAL END" >> run.log 2>&1 + fi fi + ENDVAL=`cat run.log | grep -v 'ABNORMAL END' | grep -c 'NORMAL END'` fi - # echo "COMMAND='$COMMAND'" - # echo "pwd='"`pwd`"'" - if test "x$RETVAL" = x0 ; then + rm -f run.log_00 + #if test "x$RETVAL" = x0 ; then + if [ $RETVAL -eq 0 -a $ENDVAL -gt 0 ] ; then tail run.log echo successful 1>&2 # === Reduce the size of the testing emails! - # if test "x$ADM" = x ; then - # cp output.txt $CDIR"/output.txt" - # else - # cp output_adm.txt $CDIR"/output_adm.txt" - # fi + #cp $OUTPUTFILE $CDIR"/"$OUTPUTFILE if test -s STDERR.0000 ; then cp STDERR.0000 $CDIR"/STDERR.0000" ; fi return 0 else tail run.log - echo failed 1>&2 + echo failed '(run:' $RETVAL ' end:' $ENDVAL ')' 1>&2 cp run.log $CDIR"/run.log" if test -s STDERR.0000 ; then cp STDERR.0000 $CDIR"/STDERR.0000" ; fi return 1 @@ -643,25 +666,6 @@ } -show_help() -{ - cat - << EOF -$0 [-help] [-quick] [-verbose] dir1 [dir2] [...] - - -help|-h Show this help message - -quiet Reduce the amount of output - -verbose Produce copious amounts of output - -debug Produce even more output which will mean nothing to most - -force Do "make CLEAN" before compiling. This forces a complete rebuild. - -clean Do "make CLEAN" after compiling and testing. - -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 -EOF -} - scandirs() { if [ $# -eq 1 ]; then @@ -701,6 +705,7 @@ OPTFILE=NONE ADDRESSES= TESTDIRS= +SKIPDIRS= MPACKDIR="../tools/mpack-1.6" HAVE_MPACK= MPACK="$MPACKDIR/mpack" @@ -756,6 +761,11 @@ -tdir=* | --tdir=*) TESTDIRS=$ac_optarg ;; + -skipdir | --skipdir | -skd | --skd) + ac_prev=SKIPDIRS ;; + -skipdir=* | --skipdir=*) + SKIPDIRS=$ac_optarg ;; + -bash | --bash | -b | --b) ac_prev=BASH ;; -bash=* | --bash=*) @@ -814,6 +824,12 @@ -deldir | -dd) DELDIR=t ;; + -ts) TS=t;; + + -papis) PAPIS=t;; + + -pcls) PCL=t;; + -*) echo "Error: unrecognized option: "$ac_option usage @@ -836,11 +852,48 @@ if test "x$TESTDIRS" = x ; then if test "x$ADM" = xt ; then - TESTDIRS=`scandirs results_ad` + LIST=`scandirs results_ad` else - TESTDIRS=`scandirs results` + LIST=`scandirs results` fi +else + #- expand group of experiments: + LIST=" " + for xx in $TESTDIRS + do + case $xx in + 'basic') LIST=${LIST}" aim.5l_cs hs94.128x64x5 ideal_2D_oce" + LIST=${LIST}" lab_sea tutorial_baroclinic_gyre" + LIST=${LIST}" tutorial_global_oce_latlon tutorial_plume_on_slope" + ;; + 'tutorials') + LIST=${LIST}" "`ls | grep 'tutorial_'` ;; + *) LIST=${LIST}" "$xx ;; + esac + done fi +#echo 'LIST='${LIST}'<' +#- skip dirs, remove duplicate and non-directory: +TESTDIRS=" " +count=0 +for xx in $LIST +do + yy=`echo $SKIPDIRS | grep -c $xx` + if test $yy = 0 ; then + if test -d $xx ; then + yy=`echo $TESTDIRS | grep -c $xx` + if test $yy = 0 ; then TESTDIRS=${TESTDIRS}" "$xx ; fi + else count=1 ; + echo ""; echo -n " -- skip \"$xx\" (not a directory !)" + fi + else + if test $count = 1 ; then echo -n ", \"$xx\"" + else count=1 ; echo "" ; echo -n " skip: \"$xx\"" + fi + fi +done +if test $count = 1 ; then echo "" ; echo -n " ... " ; fi +#echo 'TESTDIRS='${TESTDIRS}'<' if test "x$OPTFILE" = xNONE -a "x$MITGCM_OF" != x ; then OPTFILE=$MITGCM_OF @@ -854,13 +907,12 @@ OUTPUTFILE="output.txt" fi -if test "x$ADM" = xt -a "x$COMMAND" = x ; then - COMMAND="./$EXECUTABLE > $OUTPUTFILE" -fi - if test "x$COMMAND" = x ; then COMMAND="./$EXECUTABLE > $OUTPUTFILE" fi +if test "x$MPI" = xt ; then + OUTPUTFILE="STDOUT.0000" +fi #echo "OK" echo "OK (COMMAND= $COMMAND )" @@ -1034,7 +1086,7 @@ #echo "ex_run_dirs='$ex_run_dirs'" for exd in $ex_run_dirs ; do name=`echo $exd | sed -e 's/input.//g'` - outf="$dir/results/output.txt.$name" + outf="$dir/results/output.$name.txt" if test -f $outf -a -r $outf ; then if test "x$MULTI_THREAD" = "xt" ; then if test -r $dir"/"$exd"/eedata.mth" ; then @@ -1077,7 +1129,7 @@ && makemodel $dir/$builddir && make=Y \ && linkdata $dir/$rundir $input_dirs \ && runmodel $dir/$rundir && run=Y \ - && results=`testoutput $dir $rundir` + && results=`testoutput $dir $rundir "txt"` fi echo @@ -1102,7 +1154,7 @@ run_clean $dir/tr_run.$ex linkdata $dir/tr_run.$ex input.$ex input runmodel $dir/tr_run.$ex && run=Y \ - && results=`testoutput $dir tr_run.$ex "."$ex` + && results=`testoutput $dir tr_run.$ex ${ex}".txt"` fres=`printf '%s %s %s %s' ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N}` fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results` fres="$fres.$ex"