--- MITgcm/verification/testreport 2005/06/07 22:21:47 1.68 +++ MITgcm/verification/testreport 2006/07/31 20:48:41 1.87 @@ -1,6 +1,6 @@ #! /usr/bin/env bash # -# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/verification/testreport,v 1.68 2005/06/07 22:21:47 edhill Exp $ +# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/verification/testreport,v 1.87 2006/07/31 20:48:41 jmc Exp $ # $Name: $ # @@ -11,14 +11,16 @@ 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 " (-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 " (-b|-bash) STRING preferred location of a \"bash\" or" echo " Bourne-compatible \"sh\" shell" echo " (DEF=\"\" for \"bash\")" @@ -27,6 +29,8 @@ echo " (DEF=\"make output.txt\")" echo " (-m|-make) STRING command to use for \"make\"" 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 " (DEF=\"1 2 3 4 5\")" echo " (-j) JOBS use \"make -j JOBS\" for parallel builds" @@ -87,14 +91,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 @@ -103,13 +107,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 @@ -123,6 +127,16 @@ fi return 99 fi + has_nan=`cat tmp1.txt | grep -i nan | wc -l` + if [ $has_nan -gt 0 ] ; then + 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: $OUTPUTFILE contains $has_inf Inf values 1>&2 + return 99 + fi if [ $debug -gt 0 ]; then echo testoutput_for_prop: join tmp1.txt tmp2.txt 1>&2 fi @@ -169,10 +183,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 @@ -292,7 +306,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" @@ -324,20 +337,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 @@ -348,15 +359,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 @@ -464,33 +483,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 - 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 + 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 + # 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 } @@ -503,23 +533,35 @@ # (where "$COMMAND" is relative to "directory") ( cd $1 - printf 'runmodel ... ' 1>&2 + 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 + ln -sf "../"$builddir"/"$EXECUTABLE . + else + touch run.log + fi + if test ! -x $EXECUTABLE ; then + echo " no executable:" $EXECUTABLE >> run.log + RETVAL=8 + else + if test $OUTPUTFILE -ot $EXECUTABLE ; then + ( eval $COMMAND ) >> run.log 2>&1 + RETVAL=$? + else + echo " $OUTPUTFILE is up to date " >> run.log 2>&1 + RETVAL=0 + fi + fi # echo "COMMAND='$COMMAND'" # echo "pwd='"`pwd`"'" - ( eval $COMMAND ) > run.log 2>&1 - RETVAL=$? if test "x$RETVAL" = x0 ; 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 @@ -619,12 +661,12 @@ 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 } @@ -668,6 +710,8 @@ fi JOBS= MPI=f +MULTI_THREAD=f +OUTDIR= DELDIR= ADM= @@ -724,6 +768,11 @@ -make=* | --make=*) MAKE=$ac_optarg ;; + -odir | --odir) + ac_prev=OUTDIR ;; + -odir=* | --odir=*) + OUTDIR=$ac_optarg ;; + -ptracers | --ptracers | -ptr | --ptr) ac_prev=PTRACERS_NUM ;; -ptracers=* | --ptracers=* | -ptr=* | --ptr=*) @@ -733,7 +782,7 @@ -j=*) JOBS=$ac_optarg ;; -clean | --clean) - CLEANUP=t ;; + CLEANUP=t ; DELDIR=t ;; -quick | --quick | -q | --q) QUICK=t ;; @@ -749,6 +798,8 @@ -mpi) MPI=t ;; + -mth) MULTI_THREAD=t ;; + -adm | -ad) ADM=t ;; -ieee) IEEE=true ;; @@ -781,22 +832,62 @@ fi if test "x$TESTDIRS" = x ; then - TESTDIRS=`scandirs` + if test "x$ADM" = xt ; then + TESTDIRS=`scandirs results_ad` + else + TESTDIRS=`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 + #echo 'LIST='${LIST}'<' + #- remove duplicate and non-directory: + TESTDIRS=" " + for xx in $LIST + do + if test -d $xx ; then + yy=`echo $TESTDIRS | grep -c $xx` + if test $yy = 0 ; then TESTDIRS=${TESTDIRS}" "$xx ; fi + else + echo " -- skip \"$xx\" : not a directory !" + fi + done fi +#echo 'TESTDIRS='${TESTDIRS}'<' if test "x$OPTFILE" = xNONE -a "x$MITGCM_OF" != x ; then OPTFILE=$MITGCM_OF fi -if test "x$ADM" = xt -a "x$COMMAND" = x ; then - COMMAND="./mitgcmuv_ad > output.txt_adm 2>&1" +if test "x$ADM" = xt ; then + EXECUTABLE="mitgcmuv_ad" + OUTPUTFILE="output_adm.txt" +else + EXECUTABLE="mitgcmuv" + OUTPUTFILE="output.txt" fi if test "x$COMMAND" = x ; then - COMMAND="$MAKE output.txt" + COMMAND="./$EXECUTABLE > $OUTPUTFILE" +fi +if test "x$MPI" = xt ; then + OUTPUTFILE="STDOUT.0000" fi -echo "OK" +#echo "OK" +echo "OK (COMMAND= $COMMAND )" # create the FORTRAN comparison code createcodelet @@ -813,6 +904,9 @@ UNAMEA=`uname -a` DATE=`date +%Y%m%d` BASE="tr_"$MACH"_"$DATE"_" +if test "x$OUTDIR" != x ; then + BASE="tr_"$OUTDIR"_"$DATE"_" +fi DNUM=0 DRESULTS="$BASE$DNUM" while test -e $DRESULTS ; do @@ -897,10 +991,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 @@ -915,7 +1011,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" @@ -927,36 +1023,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 @@ -964,13 +1046,42 @@ 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='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --' + results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --' # Create an output dir for each OPTFILE/tdir combination rel_CDIR=$DRESULTS"/"$dir @@ -978,16 +1089,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 @@ -1002,40 +1116,17 @@ echo "tdir='$dir'" >> $CDIR"/summary.txt" for ex in $extra_runs ; do + unset run + results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --' + # Create an output dir for each OPTFILE/tdir.ex combination + rel_CDIR=$DRESULTS"/"$dir"."$ex + 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/$ldir" > /dev/null 2>&1 - ls -1 Makefile *.[fFhco] mitgcmuv 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 + 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" @@ -1045,7 +1136,10 @@ echo "MACH='$MACH'" >> $CDIR"/summary.txt" echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt" echo "DATE='$DATE'" >> $CDIR"/summary.txt" - echo "tdir='$dir'" >> $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}` @@ -1057,9 +1151,15 @@ echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt" echo "DATE='$DATE'" >> $CDIR"/summary.txt" echo "tdir='$dir'" >> $CDIR"/summary.txt" + grep -A3 'Seconds in section "ALL' $dir/$rundir/$OUTPUTFILE \ + >> $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 "-------------------------------------------------------------------------------"