--- MITgcm/verification/testreport 2006/03/20 21:50:36 1.77 +++ 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.77 2006/03/20 21:50:36 jmc Exp $ +# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/verification/testreport,v 1.90 2007/01/31 21:28:34 ce107 Exp $ # $Name: $ # @@ -11,14 +11,18 @@ echo echo "where possible OPTIONS are:" echo " (-help|-h) print usage" - echo " (-mpi) use MPI input files" + echo " (-mth) run multi threaded (using eedata.mth)" + 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\")" @@ -29,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\"" @@ -38,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:" @@ -89,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 @@ -105,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 @@ -127,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 @@ -181,10 +188,10 @@ testoutput_ad() { - grep $3 $1/results_ad/output.txt_adm | awk '{print NR " " $5}' > t05.txt - grep $3 $1/$2/output.txt_adm | awk '{print NR " " $5}' > t15.txt - grep $3 $1/results_ad/output.txt_adm | awk '{print NR " " $6}' > t06.txt - grep $3 $1/$2/output.txt_adm | awk '{print NR " " $6}' > t16.txt + grep $3 $1/results_ad/output_adm.txt | awk '{print NR " " $5}' > t05.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/$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 @@ -304,7 +311,6 @@ command="$command --mods=../code" else command="$command --mods=../code_ad" - command="$command -adof=../../../tools/adjoint_options/adjoint_staf" fi if test "x$OPTFILE" != xNONE ; then command="$command --optfile=$OPTFILE" @@ -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=$? @@ -336,20 +352,18 @@ { # makeclean directory if test "x$NOCLEAN" = xt ; then - echo "make CLEAN skipped!" + echo "make Clean skipped!" else ( cd $1; - if test -e output.txt ; then - rm -f output.txt - fi - printf 'make CLEAN ... ' 2>&1 + #if test -e $OUTPUTFILE ; then rm -f $OUTPUTFILE ; fi if test -r Makefile ; then - $MAKE CLEAN >> make.log 2>&1 + printf 'clean build-dir: make Clean ... ' 2>&1 + $MAKE Clean >> make.log 2>&1 RETVAL=$? if test "x$RETVAL" != x0 ; then tail make.log - echo "makeclean: \"make CLEAN\" failed" 1>&2 + echo "makeclean: \"make Clean\" failed" 1>&2 cp make.log $CDIR"/make.log" return 1 fi @@ -360,15 +374,23 @@ fi } -postclean() +run_clean() { - # postclean directory - if test "x$POSTCLEAN" = xt ; then + # run_clean directory + if test "x$NOCLEAN" = xt ; then + echo "run_clean skipped!" + else ( cd $1; - if test -r Makefile ; then - $MAKE CLEAN >> /dev/null 2>&1 - fi + printf 'clean run-dir ... ' 2>&1 + # part of what is done after "make clean" when doing "make CLEAN" + find . -name "*.meta" -exec rm {} \; + find . -name "*.data" -exec rm {} \; + find . -name "fort.*" -exec rm {} \; + find . -type l -exec rm {} \; + rm -f $EXECUTABLE *.txt STD* *diagnostics.log datetime + rm -rf mnc_test_* + echo successful 1>&2 exit 0 ) fi @@ -476,33 +498,44 @@ linkdata() { - # linkdata flag + # linkdata run_dir input_dir_1 input_dir_2 ... # # symbolically link data files to run directory - if test "x$1" = x1 ; then + if test -d $1 ; then ( - cd $2 - if test "x$ADM" = x ; then - files=`( cd ../input ; ls -1 | grep -v CVS )` - for i in $files ; do - if test ! -d "../input/"$i -a ! -f $i ; then - ln -sf "../input/"$i $i + cd $1 ; shift + if test -r "../"$1"/eedata.mth" ; then + # found eedata.mth in 1rst input dir and it is readable + if test "x$MULTI_THREAD" = "xt" ; then + # multi-threaded test: remove symbolic link & link eedata.mth + if test -h eedata ; then rm -f eedata ; fi + if test ! -r eedata ; then + ln -sf "../"$1"/eedata.mth" eedata ; + printf 'eedata.mth ' 1>&2 fi - done - else - files=`( cd ../input ; ls -1 *.bin | grep -v CVS )` - for i in $files ; do - if test ! -d "../input/"$i ; then - ln -sf "../input/"$i $i - fi - done - files=`( cd ../input_ad ; ls -1 | grep -v CVS )` - for i in $files ; do - if test ! -d "../input_ad/"$i ; then - ln -sf "../input_ad/"$i $i - fi - done + else + # not multi-threaded test: remove eedata symbolic link + if test -h eedata ; then rm -f eedata ; fi + fi fi + for ldir in $* ; do + if test -d "../"$ldir ; then + printf 'ldir='${ldir} 1>&2 + files=`( cd "../"$ldir ; ls -1 | grep -v CVS )` + for i in $files ; do + if test ! -d "../"$ldir/$i ; then + if test ! -r $i ; then + printf ' '$i 1>&2 + ln -sf "../"$ldir"/"$i $i + fi + fi + done + if test -x "../"$ldir"/"prepare_run ; then + "../"$ldir"/"prepare_run + fi + printf ' ; ' 1>&2 + fi + done ) fi } @@ -518,30 +551,48 @@ printf 'runmodel in %s ...' $1 1>&2 # make output.txt echo - rm -f run.log - if test $OUTPUTFILE -ot $EXECUTABLE ; then - ( eval $COMMAND ) > run.log 2>&1 - RETVAL=$? + if test ! -x $EXECUTABLE -a -x "../"$builddir"/"$EXECUTABLE ; then + echo " link" $EXECUTABLE "from dir ../"$builddir > run.log_00 + ln -sf "../"$builddir"/"$EXECUTABLE . + 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 - echo " $OUTPUTFILE is up to date " > run.log 2>&1 - RETVAL=0 + 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 + 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.txt_adm $CDIR"/output.txt_adm" - # 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 @@ -615,33 +666,14 @@ } -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 0 ]; then - for arg in * ; do - test -d $arg/input && echo $arg - done + if [ $# -eq 1 ]; then + for arg in * ; do + test -d $arg/$1 && echo $arg + done else - echo $* + echo $* fi } @@ -673,6 +705,7 @@ OPTFILE=NONE ADDRESSES= TESTDIRS= +SKIPDIRS= MPACKDIR="../tools/mpack-1.6" HAVE_MPACK= MPACK="$MPACKDIR/mpack" @@ -685,6 +718,7 @@ fi JOBS= MPI=f +MULTI_THREAD=f OUTDIR= DELDIR= @@ -727,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=*) @@ -772,6 +811,8 @@ -mpi) MPI=t ;; + -mth) MULTI_THREAD=t ;; + -adm | -ad) ADM=t ;; -ieee) IEEE=true ;; @@ -783,6 +824,12 @@ -deldir | -dd) DELDIR=t ;; + -ts) TS=t;; + + -papis) PAPIS=t;; + + -pcls) PCL=t;; + -*) echo "Error: unrecognized option: "$ac_option usage @@ -804,8 +851,49 @@ fi if test "x$TESTDIRS" = x ; then - TESTDIRS=`scandirs` + if test "x$ADM" = xt ; then + LIST=`scandirs results_ad` + else + 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 @@ -813,19 +901,18 @@ if test "x$ADM" = xt ; then EXECUTABLE="mitgcmuv_ad" - OUTPUTFILE="output.txt_adm" + OUTPUTFILE="output_adm.txt" else EXECUTABLE="mitgcmuv" 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 )" @@ -932,10 +1019,12 @@ # Cleanup only! if test "x$CLEANUP" = xt ; then if test -r $dir/build/Makefile ; then + echo ' ------ clean dir:' $dir/build ( cd $dir/build ; make CLEAN ) fi - if test -r $dir/input/Makefile ; then - ( cd $dir/input ; make CLEAN ) + if test -d $dir/run/CVS ; then + echo ' ------ clean dir:' $dir/run + run_clean $dir/run fi ( cd $dir @@ -950,7 +1039,7 @@ if test "x$ADM" = x ; then fout=$dir"/results/output.txt" else - fout=$dir"/results_ad/output.txt_adm" + fout=$dir"/results_ad/output_adm.txt" fi if test ! -r $fout ; then echo "can't read \"$fout\" -- skipping $dir" @@ -962,36 +1051,22 @@ # Check for additional types of monitor output - builddir="input" - rundir="input" - use_seperate_build=0 - if test -d $dir/build -a -r $dir/build ; then - builddir="build" - rundir="build" - use_seperate_build=1 - linkdata $use_seperate_build $dir/$rundir + builddir="build" + if test ! -d $dir/$builddir ; then mkdir $dir/$builddir ; fi + rundir="run" + #rundir=$builddir + if test ! -d $dir/$rundir ; then + rundir=$builddir fi - # Check whether there are "extra runs" for this testdir - extra_runs= - if test "x$ADM" = x -a "x$use_seperate_build" = x1 ; then - ex_run_dirs=`( cd $dir ; echo input.* )` - 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" - if test -f $outf -a -r $outf ; then - extra_runs="$extra_runs $name" - fi - done - fi - if test "x$ADM" = x ; then code_dir=code CODE_DIR=$dir/code + input_dirs='input' else code_dir=code_ad CODE_DIR=$dir/code_ad + input_dirs='input_ad input' fi BUILD_DIR=$dir/$builddir @@ -999,10 +1074,39 @@ echo "can't find \"$CODE_DIR/SIZE.h_mpi\" -- skipping $dir" continue fi + if test ! -r $dir"/input/eedata.mth" -a "x$MULTI_THREAD" = "xt" ; then + echo "can't find \"$dir/input/eedata.mth\" -- skipping $dir" + continue + fi + + # Check whether there are "extra runs" for this testdir + extra_runs= + if test "x$ADM" = x ; then + ex_run_dirs=`( cd $dir ; echo input.* )` + #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.$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 + extra_runs="$extra_runs $name" + #else echo $dir"/"$exd"/eedata.mth: not found" + fi + else + extra_runs="$extra_runs $name" + fi + fi + done + fi echo "-------------------------------------------------------------------------------" echo - echo "Experiment: $dir" + if test "x$extra_runs" = "x" ; then + echo "Experiment: $dir" + else + echo "Experiment: $dir ; extra_runs=$extra_runs" + fi echo unset genmake makedepend make run results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --' @@ -1013,16 +1117,19 @@ CDIR=`pwd`"/$rel_CDIR" if test "x$CLEANUP" = xt ; then - makeclean $dir/$builddir + echo '====>>> this is to check that we never go through this part <<< ===' + makeclean $dir/$builddir \ + && run_clean $dir/$rundir else genmakemodel $dir/$builddir && genmake=Y \ && makeclean $dir/$builddir \ + && run_clean $dir/$rundir \ && symlink_mpifiles $dir $code_dir $builddir \ && makedependmodel $dir/$builddir && makedepend=Y \ && makemodel $dir/$builddir && make=Y \ - && linkdata $use_seperate_build $dir/$rundir \ + && linkdata $dir/$rundir $input_dirs \ && runmodel $dir/$rundir && run=Y \ - && results=`testoutput $dir $rundir` + && results=`testoutput $dir $rundir "txt"` fi echo @@ -1044,29 +1151,10 @@ mkdir $rel_CDIR CDIR=`pwd`"/$rel_CDIR" test ! -e "$dir/tr_run.$ex" && mkdir "$dir/tr_run.$ex" - for ldir in input.$ex input ; do - ( - cd "$dir/$ldir" > /dev/null 2>&1 - ls -1 2>/dev/null \ - | sed -e 's|^CVS$||g' | sed -e 's|^output.txt$||g' - ) > tr_exrun_links - ( - cd "$dir/tr_run.$ex" - cat ../../tr_exrun_links | while read i ; do - if test ! "x$i" = x ; then - test ! -r $i && ln -s "../"$ldir"/"$i $i - fi - done - ) - test -e tr_exrun_links && rm -f tr_exrun_links - done - ldir=build - ( - cd $dir/tr_run.$ex - test ! -e mitgcmuv && ln -s "../"$ldir"/"mitgcmuv . - ) + 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" @@ -1077,6 +1165,9 @@ echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt" echo "DATE='$DATE'" >> $CDIR"/summary.txt" echo "tdir='$dir.$ex'" >> $CDIR"/summary.txt" + if test "x$POSTCLEAN" = xt ; then + run_clean $dir/tr_run.$ex + fi done else fres=`printf '%s %s %s %s' ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N}` @@ -1092,7 +1183,11 @@ >> $CDIR"/summary.txt" fi - postclean $dir/$builddir + #postclean $dir/$builddir + if test "x$POSTCLEAN" = xt ; then + makeclean $dir/$builddir \ + && run_clean $dir/$rundir + fi echo "-------------------------------------------------------------------------------"