/[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.5 by edhill, Sat Sep 6 02:45:07 2003 UTC revision 1.11 by edhill, Fri Oct 10 03:29:44 2003 UTC
# Line 1  Line 1 
1  #!/bin/bash  #!/bin/bash
2  #  #
3  #  $Header$  #  $Header$
4    #  $Name$
5  #  #
6    
7  usage()  usage()
# Line 10  usage() Line 11  usage()
11      echo      echo
12      echo "where possible OPTIONS are:"      echo "where possible OPTIONS are:"
13      echo "  (-help|-h)               print usage"      echo "  (-help|-h)               print usage"
14      echo "  (-optfile=|-of=)STRING   list of genmake2 \"optfiles\""      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"
17      echo "  (-a|-addr)STRING         list of email recipients"      echo "  (-a|-addr)STRING         list of email recipients"
18      echo "  (-t|-tdir)STRING         list of \"test\" dirs"      echo "                             (DEF=\"edhill@mitgcm.org\")"
19      echo "  (-b|-bash)STRING         the \"bash\" executable"      echo "  (-t|-tdir)STRING         list of test dirs to use"
20      echo "  (-m|-make)STRING         the \"make\" executable"      echo "                             (DEF=\"\" which builds all)"
21        echo "  (-b|-bash)STRING         location of \"bash\" executable"
22        echo "                             (DEF=\"\" for \"/bin/bash\")"
23        echo "  (-command)STRING         command to run"
24        echo "                             (DEF=\"make output.txt\")"
25        echo "  (-m|-make)STRING         command to use for \"make\""
26        echo "                             (DEF=\"make\")"
27        echo "  (-clean)                 *ONLY* run \"make CLEAN\""
28        echo "  (-quick|-q)              same as \"-nogenmake -noclean -nodepend\""
29        echo "  (-nogenmake|-ng)         skip the genmake stage"
30        echo "  (-noclean|-nc)           skip the \"make clean\" stage"
31        echo "  (-nodepend|-nd)          skip the \"make depend\" stage"
32        echo
33        echo "and where STRING follows a whitespace-delimited format"
34        echo "such as:"
35        echo "  -t 'exp0 exp2 exp3' "
36        echo "  -addr='abc@123.com testing@home.org'"
37      echo      echo
38      exit 1      exit 1
39  }  }
# Line 162  testoutput() Line 181  testoutput()
181  genmakemodel()  genmakemodel()
182  {  {
183      # genmakemodel directory      # genmakemodel directory
184      GENMAKE2="$BASH ../../../tools/genmake2"      if test "x$NOGENMAKE" = xt ; then
185      (          echo "genmake skipped!"
186          cd $1;      else
187          printf 'genmake ... ' 1>&2          GENMAKE2="$BASH ../../../tools/genmake2"
188          # ../../../tools/genmake -ieee -mods=../code > make.log 2>&1          (
189          $GENMAKE2 -make $MAKE -ds --mods=../code "--optfile="$OPTFILE > make.log 2>&1              cd $1;
190          RETVAL=$?              command="$GENMAKE2  -ds -m $MAKE --mods=../code"
191          for i in gm_state gm_optfile gm_local Makefile ; do              if test "x$OPTFILE" != xNONE ; then
192              if test -r $i ; then                  command="$command --optfile=$OPTFILE"
193                  cp $i $CDIR                  # echo "  command=\"$command\""
194              fi              fi
195          done              if test "x$IEEE" != x ; then
196          if test "x$RETVAL" != x0 ; then                  command="$command -ieee"
197              tail make.log              fi
198              echo "genmakemodel: genmake failed" 1>&2              # echo "command: \"$command\""
199              cp make.log $CDIR              printf 'genmake ... ' 1>&2
200              return 1              $command > make.log 2>&1
201          else              RETVAL=$?
202              echo "succesful" 1>&2              for i in genmake_state genmake_optfile genmake_local Makefile ; do
203          fi                  if test -r $i ; then
204      )                      cp $i $CDIR
205                    fi
206                done
207                if test "x$RETVAL" != x0 ; then
208                    tail make.log
209                    echo "genmakemodel: genmake failed" 1>&2
210                    cp make.log $CDIR
211                    return 1
212                else
213                    echo "succesful" 1>&2
214                fi
215            )
216        fi
217  }  }
218    
219  makeclean()  makeclean()
220  {  {
221      # makeclean directory      # makeclean directory
222      (      if test "x$NOCLEAN" = xt ; then
223          cd $1;          echo "make CLEAN skipped!"
224          rm -f output.txt      else
225          printf 'make CLEAN ... ' 2>&1          (
226          if test -r Makefile ; then              cd $1;
227              $MAKE CLEAN >> make.log 2>&1              if test -e output.txt ; then
228              RETVAL=$?                  rm -f output.txt
             if test "x$RETVAL" != x0 ; then  
                 tail make.log  
                 echo "makeclean: \"make CLEAN\" failed" 1>&2  
                 cp make.log $CDIR"/make.log"  
                 return 1  
229              fi              fi
230          fi              printf 'make CLEAN ... ' 2>&1
231          echo succesful 1>&2              if test -r Makefile ; then
232          exit 0                  $MAKE CLEAN >> make.log 2>&1
233      )                  RETVAL=$?
234                    if test "x$RETVAL" != x0 ; then
235                        tail make.log
236                        echo "makeclean: \"make CLEAN\" failed" 1>&2
237                        cp make.log $CDIR"/make.log"
238                        return 1
239                    fi
240                fi
241                echo succesful 1>&2
242                exit 0
243            )
244        fi
245  }  }
246    
247  makedependmodel()  makedependmodel()
248  {  {
249      # makedependmodel directory      # makedependmodel directory
250      (      if test "x$NODEPEND" = xt ; then
251          cd $1;          echo "make depend skipped!"
252          printf 'make depend ... ' 1>&2      else
253          $MAKE depend >> make.log 2>&1          (
254          RETVAL=$?              cd $1;
255          if test "x$RETVAL" != x0 ; then              printf 'make depend ... ' 1>&2
256              tail make.log              $MAKE depend >> make.log 2>&1
257              echo "makedependmodel: make depend failed" 1>&2              RETVAL=$?
258              cp make.log $CDIR"/make.log"              if test "x$RETVAL" != x0 ; then
259              return 1                  tail make.log
260          else                  echo "makedependmodel: make depend failed" 1>&2
261              echo succesful 1>&2                  cp make.log $CDIR"/make.log"
262          fi                  return 1
263      )              else
264                    echo succesful 1>&2
265                fi
266            )
267        fi
268  }  }
269    
270  makemodel()  makemodel()
# Line 259  linkdata() Line 300  linkdata()
300    
301  runmodel()  runmodel()
302  {  {
303      # runmodel directory exe      # runmodel directory
304      #      #
305      #  runs the model "exe" in "directory" (exe is relative to directory)      #  runs "$COMMAND" in "directory"
306        #  (where "$COMMAND" is relative to "directory")
307      (      (
308          cd $1          cd $1
309          if [ -x $2 ]; then          printf 'runmodel: ' 1>&2
310              if [ $quick -eq 0 ]; then          # make output.txt
311                  rm -f output.txt          $COMMAND
312              fi          RETVAL=$?
313              printf 'runmodel: ' 1>&2          if test "x$RETVAL" = x0 ; then
314              $MAKE output.txt              cp output.txt $CDIR"/output.txt"
315              RETVAL=$?              return 0
316              if test "x$RETVAL" = x0 ; then          else
317                  cp output.txt $CDIR"/output.txt"              return 1
                 return 0  
             else  
                 return 1  
             fi  
318          fi          fi
319      )      )
320  }  }
# Line 349  show_help() Line 387  show_help()
387  {  {
388      cat - << EOF      cat - << EOF
389  $0 [-help] [-quick] [-verbose] dir1 [dir2] [...]  $0 [-help] [-quick] [-verbose] dir1 [dir2] [...]
390   -help      Show this help message  
391   -quick     Skip "genmake" and "make depend" if the Makefile exists   -help|-h      Show this help message
392   -quiet     Reduce the amount of output   -quiet     Reduce the amount of output
393   -verbose   Produce copious amounts of output   -verbose   Produce copious amounts of output
394   -debug     Produce even more output which will mean nothing to most   -debug     Produce even more output which will mean nothing to most
395   -force     Do "make CLEAN" before compiling. This forces a complete rebuild.   -force     Do "make CLEAN" before compiling. This forces a complete rebuild.
396   -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.  
397   -cleanup   Aggresively removes all model output, executables and object files   -cleanup   Aggresively removes all model output, executables and object files
398              and then exits. Use with care.              and then exits. Use with care.
399    
# Line 385  scandirs() Line 422  scandirs()
422  #  Default properties  #  Default properties
423  debug=0  debug=0
424  verbose=1  verbose=1
 quick=0  
425  clean=0  clean=0
 ieee=1  
426  expts=''  expts=''
427    # ieee=1
428    
429    IEEE=
430    if test "x$MITGCM_IEEE" != x ; then
431        IEEE=$MITGCM_IEEE
432    fi
433    
434    
435    CLEANUP=f
436    QUICK=f
437    NOGENMAKE=f
438    NOCLEAN=f
439    NODEPEND=f
440    
441  BASH=  BASH=
442  OPTFILES=  OPTFILE=NONE
443  ADDRESSES=edhill@mitgcm.org  ADDRESSES=
444  TESTDIRS=  TESTDIRS=
445  MPACKDIR="../tools/mpack-1.6"  MPACKDIR="../tools/mpack-1.6"
446  MPACK="$MPACKDIR/mpack"  MPACK="$MPACKDIR/mpack"
447    COMMAND="make output.txt"
448  MAKE=make  MAKE=make
449    MPI=f
450    
451  echo -n "parsing options...  "  echo -n "parsing options...  "
452    
# Line 418  for ac_option ; do Line 468  for ac_option ; do
468              usage ;;              usage ;;
469                    
470          -optfile | --optfile | -of | --of)          -optfile | --optfile | -of | --of)
471              ac_prev=OPTFILES ;;              ac_prev=OPTFILE ;;
472          -optfile=* | --optfile=* | -of=* | --of=*)          -optfile=* | --optfile=* | -of=* | --of=*)
473              OPTFILES=$ac_optarg ;;              OPTFILE=$ac_optarg ;;
474                    
475          -addr | --addr | -a | --a)          -addr | --addr | -a | --a)
476              ac_prev=ADDRESSES ;;              ac_prev=ADDRESSES ;;
# Line 437  for ac_option ; do Line 487  for ac_option ; do
487          -bash=* | --bash=*)          -bash=* | --bash=*)
488              BASH=$ac_optarg ;;              BASH=$ac_optarg ;;
489    
490            -command | --command | -c | --c)
491                ac_prev=COMMAND ;;
492            -command=* | --command=*)
493                COMMAND=$ac_optarg ;;
494    
495          -make | --make | -m | --m)          -make | --make | -m | --m)
496              ac_prev=MAKE ;;              ac_prev=MAKE ;;
497          -make=* | --make=*)          -make=* | --make=*)
498              MAKE=$ac_optarg ;;              MAKE=$ac_optarg ;;
499    
500            -clean | --clean)
501                CLEANUP=t ;;
502    
503            -quick | --quick | -q | --q)
504                QUICK=t ;;
505            -nogenmake | --nogenmake | -ng | --ng)
506                NOGENMAKE=t ;;
507            -noclean | --noclean | -nc | --nc)
508                NOCLEAN=t ;;
509            -nodepend | --nodepend | -nd | --nd)
510                NODEPEND=t ;;
511    
512            -mpi) MPI=true ;;
513    
514            -ieee) IEEE=true ;;
515            -noieee) IEEE= ;;
516    
         -quick) quick=1 ;;  
517          -verbose) verbose=2 ;;          -verbose) verbose=2 ;;
518          -debug) debug=1 ;;          -debug) debug=1 ;;
         -clean) clean=1 ;;  
         -noieee) ieee=0 ;;  
519          -quiet) verbose=0 ;;          -quiet) verbose=0 ;;
520    
521          -*)          -*)
# Line 463  for ac_option ; do Line 532  for ac_option ; do
532            
533  done  done
534    
535    if test "x$QUICK" = xt ; then
536        NOGENMAKE=t
537        NOCLEAN=t
538        NODEPEND=t
539    fi
540    
541  if test "x$TESTDIRS" = x ; then  if test "x$TESTDIRS" = x ; then
542      TESTDIRS=`scandirs`      TESTDIRS=`scandirs`
543  fi  fi
544    
545    if test "x$OPTFILE" = xNONE -a "x$MITGCM_OF" != x ; then
546        OPTFILE=$MITGCM_OF
547    fi
548    
549  echo "OK"  echo "OK"
550    
551  #  create the FORTRAN comparison code  #  create the FORTRAN comparison code
# Line 505  EOF Line 584  EOF
584    
585  NDIR=0  NDIR=0
586    
587  #  For each optfile...  of_path=
588  for OPTFILE in $OPTFILES ; do  if test "x$OPTFILE" != xNONE ; then
589        if test -r $OPTFILE ; then
590      OPTFILE=`pwd`"/$OPTFILE"          # get the path
591      if test ! -r $OPTFILE ; then          path=${OPTFILE%/*}
592          echo "Error: can't read optfile \"$OPTFILE\""          if test "x$path" = x ; then
593          exit 1              of_path=`pwd`
594            else
595                of_path=`( cd $path > /dev/null 2>&1 ; pwd )`
596            fi
597            file=${OPTFILE##*/}
598            OPTFILE=$of_path/$file
599        else
600            echo
601            echo "WARNING: can't read OPTFILE=\"$OPTFILE\" but will try to use it..."
602      fi      fi
603      echo  fi
604      echo "OPTFILE=$OPTFILE" >> $SUMMARY  echo
605      echo >> $SUMMARY  echo "OPTFILE=$OPTFILE" >> $SUMMARY
606        echo >> $SUMMARY
     #  ...and each test directory...  
     for dir in $TESTDIRS ; do  
607    
608          #  Verify that the testdir exists and contains previous  #  ...and each test directory...
609          #  results in the correct location--or skip this directory!  for dir in $TESTDIRS ; do
610          if test ! -r $dir"/results/output.txt" ; then      
611              echo | tee -a $SUMMARY      #  Cleanup only!
612              echo "can't read \"$dir/results/output.txt\" -- skipping $dir" \      if test "x$CLEANUP" = xt ; then
613                  | tee -a $SUMMARY          if test -r $dir/build/Makefile ; then
614              continue              ( cd $dir/build ; make CLEAN )
615          fi          fi
616                    if test -r $dir/input/Makefile ; then
617          #  Create an output dir for each OPTFILE/tdir combination              ( cd $dir/input ; make CLEAN )
         CDIR=$DRESULTS"/"$DRESULTS"_"$NDIR  
         mkdir $CDIR  
         CDIR=`pwd`"/$CDIR"  
   
         #  ...configue, make, run, and compare the output.  
         echo "-------------------------------------------------------------------------------"  
         echo  
         echo "Experiment:  $dir"  
         echo  
         unset genmake makedepend make run  
         results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --'  
         ( cd $dir/input; rm -f *.{o,f,c,F} *.[f,F]90 work* output.txt Make* make.log; )  
         if [ -r $dir/build ]; then  
             seperatebuilddir=1  
             builddir=build  
             rundir=build  
             ( cd $dir/build; ln -sf ../input/* . )  
         else  
             seperatebuilddir=0  
             builddir=input  
             rundir=input  
618          fi          fi
619            continue
620        fi
621    
622        #  Verify that the testdir exists and contains previous
623        #  results in the correct location--or skip this directory!
624        if test ! -r $dir"/results/output.txt" ; then
625            echo "can't read \"$dir/results/output.txt\" -- skipping $dir"
626            continue
627        fi
628    
629        echo "-------------------------------------------------------------------------------"
630        echo
631        echo "Experiment:  $dir"
632        echo
633        unset genmake makedepend make run
634        results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --'
635    
636        if [ -r $dir/build ]; then
637            seperatebuilddir=1
638            builddir=build
639            rundir=build
640            ( cd $dir/build; ln -sf ../input/* . )
641        else
642            seperatebuilddir=0
643            builddir=input
644            rundir=input
645        fi
646        
647        CODE_DIR=$dir/code
648        BUILD_DIR=$dir/$builddir
649        MPI_FILES="CPP_EEOPTIONS.h_mpi SIZE.h_mpi"
650        NOMPI_FILES="CPP_EEOPTIONS.h_nompi SIZE.h_nompi"
651    
652        #  Is this an MPI run?
653        if test "x$MPI" = xt ; then
654            FILES=$MPI_FILES
655            endings="_mpi"
656        else
657            FILES=$NOMPI_FILES
658            endings="_nompi"
659        fi
660        
661        #  Check to see that we have the files
662        have_files=t
663        for i in $FILES ; do
664            if test ! -r $CODE_DIR/$i ; then
665                echo "Warning: can't read file $CODE_DIR/$i"
666                have_files=f
667            fi
668        done
669        if test "x$have_files" != xt -a "x$MPI" = xt ; then
670            echo "Skipping $dir due to lack of input files (see above warning)"
671            continue
672        fi
673        
674        #  If we have the $FILES and they differ, copy the $FILES to $BUILD_DIR
675        if test "x$have_files" = xt ; then
676            for i in $FILES ; do
677                sstr="s|$endings||"
678                name=`echo $i | sed -e $sstr `
679                cmp $CODE_DIR/$i $BUILD_DIR/$name > /dev/null 2>&1
680                RETVAL=$?
681                if test "x$RETVAL" != x0 ; then
682                    cp $CODE_DIR/$i $BUILD_DIR/$name
683                fi
684            done
685        fi
686        
687        #  Create an output dir for each OPTFILE/tdir combination
688        CDIR=$DRESULTS"/"$DRESULTS"_"$NDIR
689        mkdir $CDIR
690        CDIR=`pwd`"/$CDIR"
691        
692        if test "x$CLEANUP" = xt ; then
693            makeclean $dir/$builddir
694        else
695          genmakemodel $dir/$builddir && genmake=Y \          genmakemodel $dir/$builddir && genmake=Y \
696              && makeclean $dir/$builddir \              && makeclean $dir/$builddir \
697              && makedependmodel $dir/$builddir && makedepend=Y \              && makedependmodel $dir/$builddir && makedepend=Y \
698              && makemodel $dir/$builddir && make=Y \              && makemodel $dir/$builddir && make=Y \
699              && linkdata $seperatebuilddir $dir/$rundir \              && linkdata $seperatebuilddir $dir/$rundir \
700              && runmodel $dir/$builddir mitgcmuv && run=Y \              && runmodel $dir/$builddir && run=Y \
701              && results=`testoutput $dir $rundir`              && results=`testoutput $dir $rundir`
702          echo      fi
703          formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \      
704              ${run:-N} $results      echo
705          echo      formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \
706          formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \          ${run:-N} $results
707              ${run:-N} $results >> $SUMMARY      echo
708          echo "fresults='" > $CDIR"/summary.txt"      formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \
709          formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \          ${run:-N} $results >> $SUMMARY
710              ${run:-N} $results >> $CDIR"/summary.txt"      echo "fresults='" > $CDIR"/summary.txt"
711          echo "'" >> $CDIR"/summary.txt"      formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \
712          echo "MACH='$MACH'" >> $CDIR"/summary.txt"          ${run:-N} $results >> $CDIR"/summary.txt"
713          echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"      echo "'" >> $CDIR"/summary.txt"
714          echo "DATE='$DATE'" >> $CDIR"/summary.txt"      echo "MACH='$MACH'" >> $CDIR"/summary.txt"
715          echo "tdir='$dir'" >> $CDIR"/summary.txt"      echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"
716        echo "DATE='$DATE'" >> $CDIR"/summary.txt"
717          (      echo "tdir='$dir'" >> $CDIR"/summary.txt"
718              cd $DRESULTS      
719              tar -cf $NDIR".tar" $DRESULTS"_"$NDIR > /dev/null 2>&1      (
720              gzip $NDIR".tar"          cd $DRESULTS
721          )          tar -cf $NDIR".tar" $DRESULTS"_"$NDIR > /dev/null 2>&1
722            gzip $NDIR".tar"
723        )
724        
725        if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then
726            echo "No mail sent"
727        else
728          $MPACK -s MITgcm-test -m 1000000 $DRESULTS"/"$NDIR".tar.gz" $ADDRESSES          $MPACK -s MITgcm-test -m 1000000 $DRESULTS"/"$NDIR".tar.gz" $ADDRESSES
729          RETVAL=$?          RETVAL=$?
730          if test "x$RETVAL" != x0 ; then          if test "x$RETVAL" != x0 ; then
# Line 588  for OPTFILE in $OPTFILES ; do Line 732  for OPTFILE in $OPTFILES ; do
732          else          else
733              rm -f $DRESULTS"/"$NDIR".tar*"              rm -f $DRESULTS"/"$NDIR".tar*"
734          fi          fi
735        fi
736    
737          NDIR=$(( $NDIR + 1 ))      echo "-------------------------------------------------------------------------------"
738                
739      done      NDIR=$(( $NDIR + 1 ))
740        
741  done  done
742    
743  rm tmp_cmpnum.f a.out  rm tmp_cmpnum.f a.out

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.11

  ViewVC Help
Powered by ViewVC 1.1.22