/[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.14 by edhill, Fri Nov 7 21:32:19 2003 UTC revision 1.22 by edhill, Sat Nov 29 00:58:43 2003 UTC
# Line 1  Line 1 
1  #!/bin/bash  #! /usr/bin/env bash
2  #  #
3  #  $Header$  #  $Header$
4  #  $Name$  #  $Name$
# Line 13  usage() Line 13  usage()
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"      echo "  (-ieee|-noieee)          if possible, use IEEE compiler flags"
16        echo "                             (DEF=\"noieee\")"
17      echo "  (-optfile=|-of=)STRING   list of optfiles to use"      echo "  (-optfile=|-of=)STRING   list of optfiles to use"
18      echo "  (-a|-addr)STRING         list of email recipients"      echo "  (-a|-addr) STRING        list of email recipients"
19      echo "                             (DEF=\"edhill@mitgcm.org\")"      echo "                             (DEF=\"edhill@mitgcm.org\")"
20      echo "  (-t|-tdir)STRING         list of test dirs to use"      echo "  (-t|-tdir) STRING        list of test dirs to use"
21      echo "                             (DEF=\"\" which builds all)"      echo "                             (DEF=\"\" which builds all)"
22      echo "  (-b|-bash)STRING         location of \"bash\" executable"      echo "  (-b|-bash) STRING        preferred location of a \"bash\" or"
23      echo "                             (DEF=\"\" for \"/bin/bash\")"      echo "                             Bourne-compatible \"sh\" shell"
24      echo "  (-command)STRING         command to run"      echo "                             (DEF=\"\" for \"bash\")"
25        echo "  (-command) STRING        command to run"
26      echo "                             (DEF=\"make output.txt\")"      echo "                             (DEF=\"make output.txt\")"
27      echo "  (-m|-make)STRING         command to use for \"make\""      echo "  (-m|-make) STRING        command to use for \"make\""
28      echo "                             (DEF=\"make\")"      echo "                             (DEF=\"make\")"
29      echo "  (-clean)                 *ONLY* run \"make CLEAN\""      echo "  (-clean)                 *ONLY* run \"make CLEAN\""
30      echo "  (-quick|-q)              same as \"-nogenmake -noclean -nodepend\""      echo "  (-quick|-q)              same as \"-nogenmake -noclean -nodepend\""
# Line 44  build_mpack() Line 46  build_mpack()
46      echo -n "building the mpack utility...  "      echo -n "building the mpack utility...  "
47      if test ! -x "$MPACKDIR/mpack" ; then      if test ! -x "$MPACKDIR/mpack" ; then
48          if test ! -d $MPACKDIR ; then          if test ! -d $MPACKDIR ; then
49                echo
50              echo "Error: can't find \"$MPACKDIR\""              echo "Error: can't find \"$MPACKDIR\""
51              echo "  are you sure this program is being run in the correct "              echo "  are you sure this program is being run in the correct "
52              echo "  (that is, \"MITGCM_ROOT\verification\") directory?"              echo "  (that is, \"MITGCM_ROOT\verification\") directory?"
53              exit 1              echo
54                HAVE_MPACK=f
55          fi          fi
56          echo -n "building mpack...  "          echo -n "building mpack...  "
57          ( cd $MPACKDIR && ./configure && $MAKE ) > build_mpack.out 2>&1          ( cd $MPACKDIR && ./configure && $MAKE ) > build_mpack.out 2>&1
# Line 55  build_mpack() Line 59  build_mpack()
59          if test "x$RETVAL" != x0 ; then          if test "x$RETVAL" != x0 ; then
60              echo              echo
61              echo "Error building the mpack tools at: $MPACK_DIR"              echo "Error building the mpack tools at: $MPACK_DIR"
62              exit 1              echo
63                HAVE_MPACK=f
64            else
65                HAVE_MPACK=t
66          fi          fi
67        else
68            HAVE_MPACK=t
69      fi      fi
70      echo "OK"      echo "OK"
71  }  }
# Line 81  testoutput_for_prop() Line 90  testoutput_for_prop()
90          echo testoutput_for_prop: grep "$2" $1/$4/output.txt 1>&2          echo testoutput_for_prop: grep "$2" $1/$4/output.txt 1>&2
91      fi      fi
92      if [ -r $1/$4/output.txt ]; then      if [ -r $1/$4/output.txt ]; then
93          grep "$2" $1/$4/output.txt | sed 's/.*=//' | nl > tmp1.txt          grep "$2" $1/$4/output.txt | sed 's/.*=//' | cat -n > tmp1.txt
94          lncnt=`wc -l tmp1.txt | awk '{print $1}' `          lncnt=`wc -l tmp1.txt | awk '{print $1}' `
95          if [ $lncnt -lt 3 ]; then          if [ $lncnt -lt 3 ]; then
96              if [ $verbose -gt 0 ]; then              if [ $verbose -gt 0 ]; then
# Line 96  testoutput_for_prop() Line 105  testoutput_for_prop()
105      if [ $debug -gt 0 ]; then      if [ $debug -gt 0 ]; then
106          echo testoutput_for_prop: grep "$2" $1/results/output.txt 1>&2          echo testoutput_for_prop: grep "$2" $1/results/output.txt 1>&2
107      fi      fi
108      grep "$2" $1/results/output.txt | sed 's/.*=//' | nl > tmp2.txt      grep "$2" $1/results/output.txt | sed 's/.*=//' | cat -n > tmp2.txt
109      lncnt=`wc -l tmp2.txt | awk '{print $1}' `      lncnt=`wc -l tmp2.txt | awk '{print $1}' `
110      if [ $lncnt -lt 3 ]; then      if [ $lncnt -lt 3 ]; then
111          if [ $verbose -gt 0 ]; then          if [ $verbose -gt 0 ]; then
# Line 111  testoutput_for_prop() Line 120  testoutput_for_prop()
120      if [ $debug -gt 0 ]; then      if [ $debug -gt 0 ]; then
121          echo testoutput_for_prop: compare_lines 1>&2          echo testoutput_for_prop: compare_lines 1>&2
122      fi      fi
123      compare_lines      if [ $verbose -gt 1 ]; then
124      digits_of_similarity=$?          cat tmp3.txt 1>&2
125        fi
126        echo "-1" >> tmp3.txt
127        digits_of_similarity=`./tmp_cmpnum < tmp3.txt`
128      if [ $digits_of_similarity -eq 99 ]; then      if [ $digits_of_similarity -eq 99 ]; then
129          if [ $verbose -gt 0 ]; then          if [ $verbose -gt 0 ]; then
130              echo testoutput_for_prop: No comparison was available for \"$2\" 1>&2              echo testoutput_for_prop: No comparison was available for \"$2\" 1>&2
# Line 189  genmakemodel() Line 201  genmakemodel()
201              command="$GENMAKE2  -ds -m $MAKE --mods=../code"              command="$GENMAKE2  -ds -m $MAKE --mods=../code"
202              if test "x$OPTFILE" != xNONE ; then              if test "x$OPTFILE" != xNONE ; then
203                  command="$command --optfile=$OPTFILE"                  command="$command --optfile=$OPTFILE"
                 # echo "  command=\"$command\""  
204              fi              fi
205              if test "x$IEEE" != x ; then              if test "x$IEEE" != x ; then
206                  command="$command -ieee"                  command="$command -ieee"
207              fi              fi
             # echo "command: \"$command\""  
208              printf 'genmake ... ' 1>&2              printf 'genmake ... ' 1>&2
209              $command > make.log 2>&1              $command > make.log 2>&1
210              RETVAL=$?              RETVAL=$?
211              for i in genmake_state genmake_optfile genmake_local Makefile ; do              cp Makefile $CDIR
                 if test -r $i ; then  
                     cp $i $CDIR  
                 fi  
             done  
212              if test "x$RETVAL" != x0 ; then              if test "x$RETVAL" != x0 ; then
213                  tail make.log                  tail make.log
214                  echo "genmakemodel: genmake failed" 1>&2                  echo "genmakemodel: genmake failed" 1>&2
215                  cp make.log $CDIR                  cp genmake_* make.log $CDIR
216                  return 1                  return 1
217              else              else
218                  echo "succesful" 1>&2                  echo "successful" 1>&2
219              fi              fi
220          )          )
221      fi      fi
# Line 237  makeclean() Line 243  makeclean()
243                      return 1                      return 1
244                  fi                  fi
245              fi              fi
246              echo succesful 1>&2              echo successful 1>&2
247              exit 0              exit 0
248          )          )
249      fi      fi
# Line 260  makedependmodel() Line 266  makedependmodel()
266                  cp make.log $CDIR"/make.log"                  cp make.log $CDIR"/make.log"
267                  return 1                  return 1
268              else              else
269                  echo succesful 1>&2                  echo successful 1>&2
270              fi              fi
271          )          )
272      fi      fi
# Line 281  makemodel() Line 287  makemodel()
287                  cp make.log $CDIR"/make.log"                  cp make.log $CDIR"/make.log"
288                  return 1                  return 1
289              else              else
290                  echo succesful 1>&2                  echo successful 1>&2
291              fi              fi
292          fi          fi
293      )      )
# Line 313  runmodel() Line 319  runmodel()
319      #  (where "$COMMAND" is relative to "directory")      #  (where "$COMMAND" is relative to "directory")
320      (      (
321          cd $1          cd $1
322          printf 'runmodel: ' 1>&2          printf 'runmodel ... ' 1>&2
323          # make output.txt          # make output.txt
324          $COMMAND          $COMMAND >> run.log 2>&1
325          RETVAL=$?          RETVAL=$?
326          if test "x$RETVAL" = x0 ; then          if test "x$RETVAL" = x0 ; then
327                echo successful 1>&2
328              cp output.txt $CDIR"/output.txt"              cp output.txt $CDIR"/output.txt"
329              return 0              return 0
330          else          else
331                tail run.log
332                echo failed 1>&2
333                cp run.log $CDIR"/run.log"
334              return 1              return 1
335          fi          fi
336      )      )
# Line 331  createcodelet() Line 341  createcodelet()
341      # create codelet for comparing model output      # create codelet for comparing model output
342    
343      echo -n "creating the comparison code...  "      echo -n "creating the comparison code...  "
344      cat > tmp_cmpnum.f <<EOFA      cat > tmp_cmpnum.c <<EOF
345        program cmpnum  #include <stdio.h>
346        implicit none  #include <math.h>
347        real*8 a,b,diff  int main( int argc, char** argv )  {
348        integer linnum,best    int linnum,best;
349        best=-16    double a,b,diff;
350    99  read(*,*,end=70,err=60) linnum,a,b    best = -16;
351        diff=0.5*(abs(a)+abs(b))    while( 1 )  {
352  c     print *,a,b,diff,abs(a-b)/diff      scanf("%d", &linnum);
353        if (diff.gt.1.e-12) then      if (linnum == -1)  break;
354          diff=abs(a-b)/diff      scanf("%lf", &a);  scanf("%lf", &b);
355          if (diff.gt.0.) then      diff = 0.5*(fabs(a)+fabs(b));
356  c         print *,int(log10(diff)),diff      if (diff > 1.e-12) {
357            linnum=int(log10(diff))        diff=fabs(a-b)/diff;
358            best=max(best,linnum)        if (diff > 0.0) {
359          endif          linnum = (int)log10(diff);
360        else          best = (best > linnum) ? best : linnum;
361          if (best.eq.-16.and.diff.ne.0.) best=-22        }
362        endif        else {
363        goto 99          if (best == -16 && diff != 0)  best = -22;
364    60  stop 'cmpnum: An error occured reading a,b'        }
365    70  print *,-best      }
366        end    }
367  EOFA    printf("%d\n", -best);
368      return 0;
369    }
370    EOF
371        cc -o tmp_cmpnum tmp_cmpnum.c -lm
372    
373      f77 tmp_cmpnum.f      if [ -x ./tmp_cmpnum ]; then
     if [ -x ./a.out ]; then  
374          echo "OK"          echo "OK"
375          return 0          return 0
376      else      else
377          echo          echo
378          echo "createcodelet: failed to compile codelet"          echo "ERROR: failed to compile comparison code"
379          exit 1          exit 1
380      fi      fi
381  }  }
# Line 422  scandirs() Line 435  scandirs()
435    
436    
437  ###############################################################################  ###############################################################################
 ###############################################################################  
 ###############################################################################  
438    
439    
440  #  Default properties  #  Default properties
# Line 450  OPTFILE=NONE Line 461  OPTFILE=NONE
461  ADDRESSES=  ADDRESSES=
462  TESTDIRS=  TESTDIRS=
463  MPACKDIR="../tools/mpack-1.6"  MPACKDIR="../tools/mpack-1.6"
464    HAVE_MPACK=
465  MPACK="$MPACKDIR/mpack"  MPACK="$MPACKDIR/mpack"
466  COMMAND="make output.txt"  COMMAND="make output.txt"
467  MAKE=make  MAKE=make
# Line 516  for ac_option ; do Line 528  for ac_option ; do
528          -nodepend | --nodepend | -nd | --nd)          -nodepend | --nodepend | -nd | --nd)
529              NODEPEND=t ;;              NODEPEND=t ;;
530    
531          -mpi) MPI=true ;;          -mpi) MPI=t ;;
532    
533          -ieee) IEEE=true ;;          -ieee) IEEE=true ;;
534          -noieee) IEEE= ;;          -noieee) IEEE= ;;
# Line 575  done Line 587  done
587  mkdir $DRESULTS  mkdir $DRESULTS
588  RETVAL=$?  RETVAL=$?
589  if test "x$RETVAL" != x0 ; then  if test "x$RETVAL" != x0 ; then
590      echo "Error: can't create results directory \"./$DRESULTS\""      echo "ERROR: Can't create results directory \"./$DRESULTS\""
591      exit 1      exit 1
592  fi  fi
593  SUMMARY="$DRESULTS/summary.txt"  SUMMARY="$DRESULTS/summary.txt"
594  echo -n "Start time:  " >> $SUMMARY  echo -n "Start time:  " >> $SUMMARY
595  date > $SUMMARY  start_date=`date`
596  date > dfile  echo $start_date > $SUMMARY
 cat << EOF >> $SUMMARY  
                 T           S           U           V  
 G D M    c        m  s        m  s        m  s        m  s  
 E p a R  g  m  m  e  .  m  m  e  .  m  m  e  .  m  m  e  .  
 N n k u  2  i  a  a  d  i  a  a  d  i  a  a  d  i  a  a  d  
 2 d e n  d  n  x  n  .  n  x  n  .  n  x  n  .  n  x  n  .  
   
 EOF  
   
 NDIR=0  
597    
598  of_path=  of_path=
599  if test "x$OPTFILE" != xNONE ; then  if test "x$OPTFILE" != xNONE ; then
# Line 605  if test "x$OPTFILE" != xNONE ; then Line 607  if test "x$OPTFILE" != xNONE ; then
607          fi          fi
608          file=${OPTFILE##*/}          file=${OPTFILE##*/}
609          OPTFILE=$of_path/$file          OPTFILE=$of_path/$file
610            cp $OPTFILE $DRESULTS
611            echo >> $SUMMARY
612            echo "  OPTFILE=$OPTFILE" >> $SUMMARY
613      else      else
614          echo          echo | tee $SUMMARY
615          echo "WARNING: can't read OPTFILE=\"$OPTFILE\" but will try to use it..."          echo "ERROR: can't read OPTFILE=\"$OPTFILE\"" | tee $SUMMARY
616            exit 1
617      fi      fi
618    else
619        echo >> $SUMMARY
620        echo "No \"OPTFILE\" was explicitly specified by testreport," >> $SUMMARY
621        echo "   so the genmake default will be used." >> $SUMMARY
622  fi  fi
623  echo  echo
 echo "OPTFILE=$OPTFILE" >> $SUMMARY  
624  echo >> $SUMMARY  echo >> $SUMMARY
625    cat << EOF | tee -a $SUMMARY
626                    T           S           U           V
627    G D M    c        m  s        m  s        m  s        m  s
628    E p a R  g  m  m  e  .  m  m  e  .  m  m  e  .  m  m  e  .
629    N n k u  2  i  a  a  d  i  a  a  d  i  a  a  d  i  a  a  d
630    2 d e n  d  n  x  n  .  n  x  n  .  n  x  n  .  n  x  n  .
631    
632    EOF
633    
634  #  ...and each test directory...  #  ...and each test directory...
635  for dir in $TESTDIRS ; do  for dir in $TESTDIRS ; do
# Line 693  for dir in $TESTDIRS ; do Line 710  for dir in $TESTDIRS ; do
710      fi      fi
711            
712      #  Create an output dir for each OPTFILE/tdir combination      #  Create an output dir for each OPTFILE/tdir combination
713      CDIR=$DRESULTS"/"$DRESULTS"_"$NDIR      rel_CDIR=$DRESULTS"/"$dir
714      mkdir $CDIR      mkdir $rel_CDIR
715      CDIR=`pwd`"/$CDIR"      CDIR=`pwd`"/$rel_CDIR"
716            
717      if test "x$CLEANUP" = xt ; then      if test "x$CLEANUP" = xt ; then
718          makeclean $dir/$builddir          makeclean $dir/$builddir
# Line 710  for dir in $TESTDIRS ; do Line 727  for dir in $TESTDIRS ; do
727      fi      fi
728            
729      echo      echo
730      formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \      fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results`
         ${run:-N} $results  
731      echo      echo
732      formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \      echo "$fres" >> $SUMMARY
733          ${run:-N} $results >> $SUMMARY      echo "fresults='$fres'" > $CDIR"/summary.txt"
     echo "fresults='" > $CDIR"/summary.txt"  
     formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \  
         ${run:-N} $results >> $CDIR"/summary.txt"  
     echo "'" >> $CDIR"/summary.txt"  
734      echo "MACH='$MACH'" >> $CDIR"/summary.txt"      echo "MACH='$MACH'" >> $CDIR"/summary.txt"
735      echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"      echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"
736      echo "DATE='$DATE'" >> $CDIR"/summary.txt"      echo "DATE='$DATE'" >> $CDIR"/summary.txt"
737      echo "tdir='$dir'" >> $CDIR"/summary.txt"      echo "tdir='$dir'" >> $CDIR"/summary.txt"
738            
     (  
         cd $DRESULTS  
         tar -cf $NDIR".tar" $DRESULTS"_"$NDIR > /dev/null 2>&1  
         gzip $NDIR".tar"  
     )  
       
     if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then  
         echo "No mail sent"  
     else  
         $MPACK -s MITgcm-test -m 1000000 $DRESULTS"/"$NDIR".tar.gz" $ADDRESSES  
         RETVAL=$?  
         if test "x$RETVAL" != x0 ; then  
             echo "Warning: \"$MPACK\" failed -- please contact <edhill@mitgcm.org>"  
         else  
             rm -f $DRESULTS"/"$NDIR".tar*"  
         fi  
     fi  
   
739      echo "-------------------------------------------------------------------------------"      echo "-------------------------------------------------------------------------------"
740            
     NDIR=$(( $NDIR + 1 ))  
       
741  done  done
742    
743  echo -n "Start time:  " >> $SUMMARY  echo -n "Start time:  " >> $SUMMARY
744  date -r dfile >> $SUMMARY  echo $start_date >> $SUMMARY
745  echo -n "End time:    " >> $SUMMARY  echo -n "End time:    " >> $SUMMARY
746  date >> $SUMMARY  date >> $SUMMARY
747    
748  rm tmp_cmpnum.f a.out dfile  #  If addresses were supplied and mpack built successfully, then try
749    #  to send email using mpack.
750    if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then
751        echo "No results email was sent."
752    else
753        if test "x$HAVE_MPACK" = xt ; then
754            tar -cf $DRESULTS".tar" $DRESULTS > /dev/null 2>&1 \
755                && gzip $DRESULTS".tar" \
756                && $MPACK -s MITgcm-test -m 1500000 $DRESULTS".tar.gz" $ADDRESSES
757            RETVAL=$?
758            if test "x$RETVAL" != x0 ; then
759                echo
760                echo "Warning: The tar, gzip, & mpack step failed.  Please send email"
761                echo "  to <MITgcm-support@mitgcm.org> for help.  You may copy the "
762                echo "  summary of results from the directory \"$DRESULTS\"."
763                echo
764            else
765                echo
766                echo "An email containing results was sent to the following addresses:"
767                echo "  \"$ADDRESSES\""
768                echo
769            fi
770            test -f $DRESULTS".tar"  &&  rm -f $DRESULTS".tar"
771            test -f $DRESULTS".tar.gz"  &&  rm -f $DRESULTS".tar.gz"
772        fi
773    fi
774    
775    # rm -f tmp_cmpnum.f a.out
776    rm -f tmp_cmpnum.c tmp_cmpnum
777    
778  if test "x$CLEANUP" != xt ; then  if test "x$CLEANUP" != xt ; then
779      cat $SUMMARY      cat $SUMMARY

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.22

  ViewVC Help
Powered by ViewVC 1.1.22