/[MITgcm]/MITgcm/verification/testreport
ViewVC logotype

Diff of /MITgcm/verification/testreport

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.9.2.1 by edhill, Fri Oct 3 02:18:21 2003 UTC revision 1.16 by edhill, Tue Nov 11 16:05:11 2003 UTC
# Line 1  Line 1 
1  #!/bin/bash  #!/bin/bash
2  #  #
3  #  $Header$  #  $Header$
4    #  $Name$
5  #  #
6    
7  usage()  usage()
# Line 11  usage() Line 12  usage()
12      echo "where possible OPTIONS are:"      echo "where possible OPTIONS are:"
13      echo "  (-help|-h)               print usage"      echo "  (-help|-h)               print usage"
14      echo "  (-mpi)                   use MPI input files"      echo "  (-mpi)                   use MPI input files"
15        echo "  (-ieee|-noieee)          if possible, use IEEE compiler flags"
16      echo "  (-optfile=|-of=)STRING   list of optfiles to use"      echo "  (-optfile=|-of=)STRING   list of optfiles to use"
17      echo "  (-a|-addr)STRING         list of email recipients"      echo "  (-a|-addr)STRING         list of email recipients"
18      echo "                             (DEF=\"edhill@mitgcm.org\")"      echo "                             (DEF=\"edhill@mitgcm.org\")"
# Line 18  usage() Line 20  usage()
20      echo "                             (DEF=\"\" which builds all)"      echo "                             (DEF=\"\" which builds all)"
21      echo "  (-b|-bash)STRING         location of \"bash\" executable"      echo "  (-b|-bash)STRING         location of \"bash\" executable"
22      echo "                             (DEF=\"\" for \"/bin/bash\")"      echo "                             (DEF=\"\" for \"/bin/bash\")"
23      echo "  (-c|-command)STRING      command to run"      echo "  (-command)STRING         command to run"
24      echo "                             (DEF=\"make output.txt\")"      echo "                             (DEF=\"make output.txt\")"
25      echo "  (-m|-make)STRING         command to use for \"make\""      echo "  (-m|-make)STRING         command to use for \"make\""
26      echo "                             (DEF=\"make\")"      echo "                             (DEF=\"make\")"
27        echo "  (-clean)                 *ONLY* run \"make CLEAN\""
28      echo "  (-quick|-q)              same as \"-nogenmake -noclean -nodepend\""      echo "  (-quick|-q)              same as \"-nogenmake -noclean -nodepend\""
29      echo "  (-nogenmake|-ng)         skip the genmake stage"      echo "  (-nogenmake|-ng)         skip the genmake stage"
30      echo "  (-noclean|-nc)           skip the \"make clean\" stage"      echo "  (-noclean|-nc)           skip the \"make clean\" stage"
# Line 78  testoutput_for_prop() Line 81  testoutput_for_prop()
81          echo testoutput_for_prop: grep "$2" $1/$4/output.txt 1>&2          echo testoutput_for_prop: grep "$2" $1/$4/output.txt 1>&2
82      fi      fi
83      if [ -r $1/$4/output.txt ]; then      if [ -r $1/$4/output.txt ]; then
84          grep "$2" $1/$4/output.txt | sed 's/.*=//' | nl > tmp1.txt          grep "$2" $1/$4/output.txt | sed 's/.*=//' | cat -n > tmp1.txt
85          lncnt=`wc -l tmp1.txt | awk '{print $1}' `          lncnt=`wc -l tmp1.txt | awk '{print $1}' `
86          if [ $lncnt -lt 3 ]; then          if [ $lncnt -lt 3 ]; then
87              if [ $verbose -gt 0 ]; then              if [ $verbose -gt 0 ]; then
# Line 93  testoutput_for_prop() Line 96  testoutput_for_prop()
96      if [ $debug -gt 0 ]; then      if [ $debug -gt 0 ]; then
97          echo testoutput_for_prop: grep "$2" $1/results/output.txt 1>&2          echo testoutput_for_prop: grep "$2" $1/results/output.txt 1>&2
98      fi      fi
99      grep "$2" $1/results/output.txt | sed 's/.*=//' | nl > tmp2.txt      grep "$2" $1/results/output.txt | sed 's/.*=//' | cat -n > tmp2.txt
100      lncnt=`wc -l tmp2.txt | awk '{print $1}' `      lncnt=`wc -l tmp2.txt | awk '{print $1}' `
101      if [ $lncnt -lt 3 ]; then      if [ $lncnt -lt 3 ]; then
102          if [ $verbose -gt 0 ]; then          if [ $verbose -gt 0 ]; then
# Line 153  testoutput() Line 156  testoutput()
156      if [ $debug -gt 0 ]; then      if [ $debug -gt 0 ]; then
157          echo testoutput: cg2dres=$cg2dres 1>&2          echo testoutput: cg2dres=$cg2dres 1>&2
158      fi      fi
       
159      testoutput_for_prop $1 "dynstat_theta_min" "theta minimum" $2; tmin=$?      testoutput_for_prop $1 "dynstat_theta_min" "theta minimum" $2; tmin=$?
160      testoutput_for_prop $1 "dynstat_theta_max" "theta maximum" $2; tmax=$?      testoutput_for_prop $1 "dynstat_theta_max" "theta maximum" $2; tmax=$?
161      testoutput_for_prop $1 "dynstat_theta_mean" "theta mean" $2; tmean=$?      testoutput_for_prop $1 "dynstat_theta_mean" "theta mean" $2; tmean=$?
# Line 184  genmakemodel() Line 186  genmakemodel()
186          GENMAKE2="$BASH ../../../tools/genmake2"          GENMAKE2="$BASH ../../../tools/genmake2"
187          (          (
188              cd $1;              cd $1;
189                command="$GENMAKE2  -ds -m $MAKE --mods=../code"
190                if test "x$OPTFILE" != xNONE ; then
191                    command="$command --optfile=$OPTFILE"
192                    # echo "  command=\"$command\""
193                fi
194                if test "x$IEEE" != x ; then
195                    command="$command -ieee"
196                fi
197                # echo "command: \"$command\""
198              printf 'genmake ... ' 1>&2              printf 'genmake ... ' 1>&2
199              # ../../../tools/genmake -ieee -mods=../code > make.log 2>&1              $command > make.log 2>&1
             $GENMAKE2  -ds -m $MAKE --mods=../code "--optfile="$OPTFILE > make.log 2>&1  
200              RETVAL=$?              RETVAL=$?
201              for i in gm_state gm_optfile gm_local Makefile ; do              for i in genmake_state genmake_optfile genmake_local Makefile ; do
202                  if test -r $i ; then                  if test -r $i ; then
203                      cp $i $CDIR                      cp $i $CDIR
204                  fi                  fi
# Line 282  linkdata() Line 292  linkdata()
292      # linkdata flag      # linkdata flag
293      #      #
294      # symbolically link data files to run directory      # symbolically link data files to run directory
295      if [ $1 -ne 0 ]; then      if test "x$1" = x1 ; then
296          ( cd $2 ;  ln -sf ../input/* . )          (
297                cd $2
298                files=`( cd ../input ; ls -1 | grep -v CVS )`
299                for i in $files ; do
300                    if test ! -d "../input/"$i ; then
301                        ln -sf "../input/"$i $i
302                    fi
303                done
304            )
305      fi      fi
306  }  }
307    
# Line 383  $0 [-help] [-quick] [-verbose] dir1 [dir Line 401  $0 [-help] [-quick] [-verbose] dir1 [dir
401   -debug     Produce even more output which will mean nothing to most   -debug     Produce even more output which will mean nothing to most
402   -force     Do "make CLEAN" before compiling. This forces a complete rebuild.   -force     Do "make CLEAN" before compiling. This forces a complete rebuild.
403   -clean     Do "make CLEAN" after compiling and testing.   -clean     Do "make CLEAN" after compiling and testing.
  -noieee    By default, $0 uses the -ieee option for genmake. This turns it off.  
404   -cleanup   Aggresively removes all model output, executables and object files   -cleanup   Aggresively removes all model output, executables and object files
405              and then exits. Use with care.              and then exits. Use with care.
406    
# Line 416  clean=0 Line 433  clean=0
433  expts=''  expts=''
434  # ieee=1  # ieee=1
435    
436  QUICK=f  IEEE=
437    if test "x$MITGCM_IEEE" != x ; then
438        IEEE=$MITGCM_IEEE
439    fi
440    
441    
442  CLEANUP=f  CLEANUP=f
443    QUICK=f
444  NOGENMAKE=f  NOGENMAKE=f
445  NOCLEAN=f  NOCLEAN=f
446  NODEPEND=f  NODEPEND=f
447    
448  BASH=  BASH=
449  OPTFILES=  OPTFILE=NONE
450  ADDRESSES=  ADDRESSES=
451  TESTDIRS=  TESTDIRS=
452  MPACKDIR="../tools/mpack-1.6"  MPACKDIR="../tools/mpack-1.6"
453  MPACK="$MPACKDIR/mpack"  MPACK="$MPACKDIR/mpack"
454  COMMAND="rm -f output.txt; make output.txt"  COMMAND="make output.txt"
455  MAKE=make  MAKE=make
456  MPI=f  MPI=f
457    
# Line 452  for ac_option ; do Line 475  for ac_option ; do
475              usage ;;              usage ;;
476                    
477          -optfile | --optfile | -of | --of)          -optfile | --optfile | -of | --of)
478              ac_prev=OPTFILES ;;              ac_prev=OPTFILE ;;
479          -optfile=* | --optfile=* | -of=* | --of=*)          -optfile=* | --optfile=* | -of=* | --of=*)
480              OPTFILES=$ac_optarg ;;              OPTFILE=$ac_optarg ;;
481                    
482          -addr | --addr | -a | --a)          -addr | --addr | -a | --a)
483              ac_prev=ADDRESSES ;;              ac_prev=ADDRESSES ;;
# Line 481  for ac_option ; do Line 504  for ac_option ; do
504          -make=* | --make=*)          -make=* | --make=*)
505              MAKE=$ac_optarg ;;              MAKE=$ac_optarg ;;
506    
507            -clean | --clean)
508                CLEANUP=t ;;
509    
510          -quick | --quick | -q | --q)          -quick | --quick | -q | --q)
511              QUICK=t ;;              QUICK=t ;;
512          -nogenmake | --nogenmake | -ng | --ng)          -nogenmake | --nogenmake | -ng | --ng)
# Line 490  for ac_option ; do Line 516  for ac_option ; do
516          -nodepend | --nodepend | -nd | --nd)          -nodepend | --nodepend | -nd | --nd)
517              NODEPEND=t ;;              NODEPEND=t ;;
518    
519          -mpi) MPI=t ;;          -mpi) MPI=true ;;
520    
521            -ieee) IEEE=true ;;
522            -noieee) IEEE= ;;
523    
524          -verbose) verbose=2 ;;          -verbose) verbose=2 ;;
525          -debug) debug=1 ;;          -debug) debug=1 ;;
         -clean) clean=1 ;;  
526          -quiet) verbose=0 ;;          -quiet) verbose=0 ;;
527    
528          -*)          -*)
# Line 520  if test "x$TESTDIRS" = x ; then Line 549  if test "x$TESTDIRS" = x ; then
549      TESTDIRS=`scandirs`      TESTDIRS=`scandirs`
550  fi  fi
551    
552  if test "x$OPTFILES" = x ; then  if test "x$OPTFILE" = xNONE -a "x$MITGCM_OF" != x ; then
553      OPTFILES=$MITGCM_OF      OPTFILE=$MITGCM_OF
 fi  
 if test "x$OPTFILES" = x ; then  
     echo "Error: please specify an optfile using either the command-line or"  
     echo "  the MITGCM_OF environment variable.  Also, examples are located "  
     echo "  in \$ROOTDIR/tools/build_options"  
     exit 1  
554  fi  fi
555    
556  echo "OK"  echo "OK"
# Line 556  if test "x$RETVAL" != x0 ; then Line 579  if test "x$RETVAL" != x0 ; then
579      exit 1      exit 1
580  fi  fi
581  SUMMARY="$DRESULTS/summary.txt"  SUMMARY="$DRESULTS/summary.txt"
582    echo -n "Start time:  " >> $SUMMARY
583  date > $SUMMARY  date > $SUMMARY
584    start_date=`date`
585  cat << EOF >> $SUMMARY  cat << EOF >> $SUMMARY
586                  T           S           U           V                  T           S           U           V
587  G D M    c        m  s        m  s        m  s        m  s  G D M    c        m  s        m  s        m  s        m  s
# Line 568  EOF Line 593  EOF
593    
594  NDIR=0  NDIR=0
595    
596  #  For each optfile...  of_path=
597  for OPTFILE in $OPTFILES ; do  if test "x$OPTFILE" != xNONE ; then
598        if test -r $OPTFILE ; then
599      OPTFILE=`pwd`"/$OPTFILE"          # get the path
600      if test ! -r $OPTFILE ; then          path=${OPTFILE%/*}
601          echo "Error: can't read optfile \"$OPTFILE\""          if test "x$path" = x ; then
602          exit 1              of_path=`pwd`
     fi  
     echo  
     echo "OPTFILE=$OPTFILE" >> $SUMMARY  
     echo >> $SUMMARY  
       
     #  ...and each test directory...  
     for dir in $TESTDIRS ; do  
   
         #  Verify that the testdir exists and contains previous  
         #  results in the correct location--or skip this directory!  
         if test ! -r $dir"/results/output.txt" ; then  
             echo | tee -a $SUMMARY  
             echo "can't read \"$dir/results/output.txt\" -- skipping $dir" \  
                 | tee -a $SUMMARY  
             continue  
         fi  
   
         #  Is this an MPI run?  
         if test "x$MPI" = xt ; then  
             if test ! -r $dir"/code/CPP_EEOPTIONS.h_mpi" -o ! -r $dir"/code/SIZE.h_mpi" ; then  
                 echo | tee -a $SUMMARY  
                 echo "can't read \"$dir/code/CPP_EEOPTIONS.h_mpi\" or \"$dir/code/SIZE.h_mpi\"" \  
                     | tee -a $SUMMARY  
                 continue  
             else  
                 cp $dir"/code/CPP_EEOPTIONS.h_mpi" $dir"/code/CPP_EEOPTIONS.h"  
                 cp $dir"/code/SIZE.h_mpi" $dir"/code/SIZE.h"  
             fi  
603          else          else
604              if test -r $dir"/code/CPP_EEOPTIONS.h_nompi" ; then              of_path=`( cd $path > /dev/null 2>&1 ; pwd )`
                 cp $dir"/code/CPP_EEOPTIONS.h_nompi" $dir"/code/CPP_EEOPTIONS.h"  
             fi  
             if test -r $dir"/code/SIZE.h_nompi" ; then  
                 cp $dir"/code/SIZE.h_nompi" $dir"/code/SIZE.h"  
             fi  
605          fi          fi
606            file=${OPTFILE##*/}
607          #  Create an output dir for each OPTFILE/tdir combination          OPTFILE=$of_path/$file
608          CDIR=$DRESULTS"/"$DRESULTS"_"$NDIR      else
         mkdir $CDIR  
         CDIR=`pwd`"/$CDIR"  
   
         #  ...configue, make, run, and compare the output.  
         echo "-------------------------------------------------------------------------------"  
         echo  
         echo "Experiment:  $dir"  
609          echo          echo
610          unset genmake makedepend make run          echo "WARNING: can't read OPTFILE=\"$OPTFILE\" but will try to use it..."
611          results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --'      fi
612    fi
613    echo
614    echo "OPTFILE=$OPTFILE" >> $SUMMARY
615    echo >> $SUMMARY
616    
617          if [ -r $dir/build ]; then  #  ...and each test directory...
618              seperatebuilddir=1  for dir in $TESTDIRS ; do
619              builddir=build      
620              rundir=build      #  Cleanup only!
621              ( cd $dir/build; ln -sf ../input/* . )      if test "x$CLEANUP" = xt ; then
622          else          if test -r $dir/build/Makefile ; then
623              seperatebuilddir=0              ( cd $dir/build ; make CLEAN )
             builddir=input  
             rundir=input  
624          fi          fi
625            if test -r $dir/input/Makefile ; then
626          if test "x$CLEANUP" = xt ; then              ( cd $dir/input ; make CLEAN )
             makeclean $dir/$builddir  
         else  
             genmakemodel $dir/$builddir && genmake=Y \  
                 && makeclean $dir/$builddir \  
                 && makedependmodel $dir/$builddir && makedepend=Y \  
                 && makemodel $dir/$builddir && make=Y \  
                 && linkdata $seperatebuilddir $dir/$rundir \  
                 && runmodel $dir/$builddir && run=Y \  
                 && results=`testoutput $dir $rundir`  
627          fi          fi
628            continue
629        fi
630    
631          echo      #  Verify that the testdir exists and contains previous
632          formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \      #  results in the correct location--or skip this directory!
633              ${run:-N} $results      if test ! -r $dir"/results/output.txt" ; then
634          echo          echo "can't read \"$dir/results/output.txt\" -- skipping $dir"
635          formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \          continue
636              ${run:-N} $results >> $SUMMARY      fi
         echo "fresults='" > $CDIR"/summary.txt"  
         formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \  
             ${run:-N} $results >> $CDIR"/summary.txt"  
         echo "'" >> $CDIR"/summary.txt"  
         echo "MACH='$MACH'" >> $CDIR"/summary.txt"  
         echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"  
         echo "DATE='$DATE'" >> $CDIR"/summary.txt"  
         echo "tdir='$dir'" >> $CDIR"/summary.txt"  
637    
638          (      echo "-------------------------------------------------------------------------------"
639              cd $DRESULTS      echo
640              tar -cf $NDIR".tar" $DRESULTS"_"$NDIR > /dev/null 2>&1      echo "Experiment:  $dir"
641              gzip $NDIR".tar"      echo
642          )      unset genmake makedepend make run
643        results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --'
644    
645          if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then      builddir="input"
646              echo "No mail sent"      rundir="input"
647          else      use_seperate_build=0
648              $MPACK -s MITgcm-test -m 1000000 $DRESULTS"/"$NDIR".tar.gz" $ADDRESSES      if test -d $dir/build -a -r $dir/build ; then
649            builddir="build"
650            rundir="build"
651            use_seperate_build=1
652            linkdata $use_seperate_build $dir/$rundir
653        fi
654        
655        CODE_DIR=$dir/code
656        BUILD_DIR=$dir/$builddir
657        MPI_FILES="CPP_EEOPTIONS.h_mpi SIZE.h_mpi"
658        NOMPI_FILES="CPP_EEOPTIONS.h_nompi SIZE.h_nompi"
659    
660        #  Is this an MPI run?
661        if test "x$MPI" = xt ; then
662            FILES=$MPI_FILES
663            endings="_mpi"
664        else
665            FILES=$NOMPI_FILES
666            endings="_nompi"
667        fi
668        
669        #  Check to see that we have the files
670        have_files=t
671        for i in $FILES ; do
672            if test ! -r $CODE_DIR/$i ; then
673                echo "Warning: can't read file $CODE_DIR/$i"
674                have_files=f
675            fi
676        done
677        if test "x$have_files" != xt -a "x$MPI" = xt ; then
678            echo "Skipping $dir due to lack of input files (see above warning)"
679            continue
680        fi
681        
682        #  If we have the $FILES and they differ, copy the $FILES to $BUILD_DIR
683        if test "x$have_files" = xt ; then
684            for i in $FILES ; do
685                sstr="s|$endings||"
686                name=`echo $i | sed -e $sstr `
687                cmp $CODE_DIR/$i $BUILD_DIR/$name > /dev/null 2>&1
688              RETVAL=$?              RETVAL=$?
689              if test "x$RETVAL" != x0 ; then              if test "x$RETVAL" != x0 ; then
690                  echo "Warning: \"$MPACK\" failed -- please contact <edhill@mitgcm.org>"                  cp $CODE_DIR/$i $BUILD_DIR/$name
             else  
                 rm -f $DRESULTS"/"$NDIR".tar*"  
691              fi              fi
692            done
693        fi
694        
695        #  Create an output dir for each OPTFILE/tdir combination
696        CDIR=$DRESULTS"/"$DRESULTS"_"$NDIR
697        mkdir $CDIR
698        CDIR=`pwd`"/$CDIR"
699        
700        if test "x$CLEANUP" = xt ; then
701            makeclean $dir/$builddir
702        else
703            genmakemodel $dir/$builddir && genmake=Y \
704                && makeclean $dir/$builddir \
705                && makedependmodel $dir/$builddir && makedepend=Y \
706                && makemodel $dir/$builddir && make=Y \
707                && linkdata $use_seperate_build $dir/$rundir \
708                && runmodel $dir/$rundir && run=Y \
709                && results=`testoutput $dir $rundir`
710        fi
711        
712        echo
713        formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \
714            ${run:-N} $results
715        echo
716        formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \
717            ${run:-N} $results >> $SUMMARY
718        echo "fresults='" > $CDIR"/summary.txt"
719        formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \
720            ${run:-N} $results >> $CDIR"/summary.txt"
721        echo "'" >> $CDIR"/summary.txt"
722        echo "MACH='$MACH'" >> $CDIR"/summary.txt"
723        echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"
724        echo "DATE='$DATE'" >> $CDIR"/summary.txt"
725        echo "tdir='$dir'" >> $CDIR"/summary.txt"
726        
727        (
728            cd $DRESULTS
729            tar -cf $NDIR".tar" $DRESULTS"_"$NDIR > /dev/null 2>&1
730            gzip $NDIR".tar"
731        )
732        
733        if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then
734            echo "No mail sent"
735        else
736            $MPACK -s MITgcm-test -m 1000000 $DRESULTS"/"$NDIR".tar.gz" $ADDRESSES
737            RETVAL=$?
738            if test "x$RETVAL" != x0 ; then
739                echo "Warning: \"$MPACK\" failed -- please contact <edhill@mitgcm.org>"
740            else
741                rm -f $DRESULTS"/"$NDIR".tar*"
742          fi          fi
743        fi
744    
745          NDIR=$(( $NDIR + 1 ))      echo "-------------------------------------------------------------------------------"
746                
747      done      NDIR=$(( $NDIR + 1 ))
748        
749  done  done
750    
751  rm tmp_cmpnum.f a.out  echo -n "Start time:  " >> $SUMMARY
752    echo $start_date >> $SUMMARY
753  cat $SUMMARY  echo -n "End time:    " >> $SUMMARY
754    date >> $SUMMARY
755    
756    rm tmp_cmpnum.f a.out dfile
757    
758    if test "x$CLEANUP" != xt ; then
759        cat $SUMMARY
760        if test -e tr.out ; then
761            mv tr.out tr.out.old
762        fi
763        cat $SUMMARY > tr.out
764    fi
765    

Legend:
Removed from v.1.9.2.1  
changed lines
  Added in v.1.16

  ViewVC Help
Powered by ViewVC 1.1.22