/[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.1 by edhill, Wed Aug 27 22:12:31 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 "  (-t|-tdir)STRING         list of test dirs to use"
20        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 29  build_mpack() Line 50  build_mpack()
50              exit 1              exit 1
51          fi          fi
52          echo -n "building mpack...  "          echo -n "building mpack...  "
53          ( cd $MPACKDIR && ./configure && make ) > build_mpack.out 2>&1          ( cd $MPACKDIR && ./configure && $MAKE ) > build_mpack.out 2>&1
54          RETVAL=$?          RETVAL=$?
55          if test "x$RETVAL" != x0 ; then          if test "x$RETVAL" != x0 ; then
56              echo              echo
# Line 160  testoutput() Line 181  testoutput()
181  genmakemodel()  genmakemodel()
182  {  {
183      # genmakemodel directory      # genmakemodel directory
184      GENMAKE2="../../../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  -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 231  makemodel() Line 274  makemodel()
274          cd $1;          cd $1;
275          if test -r Makefile ; then          if test -r Makefile ; then
276              printf 'make ... ' 1>&2              printf 'make ... ' 1>&2
277              make >> make.log 2>&1              $MAKE >> make.log 2>&1
278              RETVAL=$?              RETVAL=$?
279              if test "x$RETVAL" != x0 ; then              if test "x$RETVAL" != x0 ; then
280                  tail make.log                  tail make.log
# Line 257  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 315  EOFA Line 355  EOFA
355          return 0          return 0
356      else      else
357          echo          echo
358          echo "createcodelet: failed to compile codelet" | tee          echo "createcodelet: failed to compile codelet"
359          exit 1          exit 1
360      fi      fi
361  }  }
# Line 347  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 383  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  OPTFILES=  CLEANUP=f
436  ADDRESSES=edhill@mitgcm.org  QUICK=f
437    NOGENMAKE=f
438    NOCLEAN=f
439    NODEPEND=f
440    
441    BASH=
442    OPTFILE=NONE
443    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
449    MPI=f
450    
451  echo -n "parsing options...  "  echo -n "parsing options...  "
452    
# Line 413  for ac_option ; do Line 467  for ac_option ; do
467          -help | --help | -h | --h)          -help | --help | -h | --h)
468              usage ;;              usage ;;
469                    
470          -optfile | --optfile | -f | --f)          -optfile | --optfile | -of | --of)
471              ac_prev=OPTFILES ;;              ac_prev=OPTFILE ;;
472          -optfile=* | --optfile=*)          -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 428  for ac_option ; do Line 482  for ac_option ; do
482          -tdir=* | --tdir=*)          -tdir=* | --tdir=*)
483              TESTDIRS=$ac_optarg ;;              TESTDIRS=$ac_optarg ;;
484    
485          -quick) quick=1 ;;          -bash | --bash | -b | --b)
486                ac_prev=BASH ;;
487            -bash=* | --bash=*)
488                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)
496                ac_prev=MAKE ;;
497            -make=* | --make=*)
498                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    
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 449  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 463  build_mpack Line 556  build_mpack
556    
557  #  Create a uniquely named directory to store results  #  Create a uniquely named directory to store results
558  MACH=`hostname`  MACH=`hostname`
559    UNAMEA=`uname -a`
560  DATE=`date +%Y%m%d`  DATE=`date +%Y%m%d`
561  BASE=$MACH"_"$DATE"_"  BASE=$MACH"_"$DATE"_"
562  DNUM=0  DNUM=0
# Line 490  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            # get the path
591            path=${OPTFILE%/*}
592            if test "x$path" = x ; then
593                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
603    fi
604    echo
605    echo "OPTFILE=$OPTFILE" >> $SUMMARY
606    echo >> $SUMMARY
607    
608      OPTFILE=`pwd`"/$OPTFILE"  #  ...and each test directory...
609      if test ! -r $OPTFILE ; then  for dir in $TESTDIRS ; do
610          echo "Error: can't read optfile \"$OPTFILE\""      
611          exit 1      #  Cleanup only!
612        if test "x$CLEANUP" = xt ; then
613            if test -r $dir/build/Makefile ; then
614                ( cd $dir/build ; make CLEAN )
615            fi
616            if test -r $dir/input/Makefile ; then
617                ( cd $dir/input ; make CLEAN )
618            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      fi
628    
629        echo "-------------------------------------------------------------------------------"
630      echo      echo
631      echo "OPTFILE=$OPTFILE" >> $SUMMARY      echo "Experiment:  $dir"
632      echo >> $SUMMARY      echo
633            unset genmake makedepend make run
634      #  ...and each test directory...      results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --'
     for dir in $TESTDIRS ; do  
           
         #  Create an output dir for each OPTFILE/tdir combination  
         CDIR=$DRESULTS"/"$NDIR  
         mkdir $CDIR  
         CDIR=`pwd`"/$CDIR"  
635    
636          #  ...configue, make, run, and compare the output.      if [ -r $dir/build ]; then
637          echo "-------------------------------------------------------------------------------"          seperatebuilddir=1
638          echo          builddir=build
639          echo "Experiment:  $dir"          rundir=build
640          echo          ( cd $dir/build; ln -sf ../input/* . )
641          unset genmake makedepend make run      else
642          results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --'          seperatebuilddir=0
643          ( cd $dir/input; rm -f *.{o,f,c,F} *.[f,F]90 work* output.txt Make* make.log; )          builddir=input
644          if [ -r $dir/build ]; then          rundir=input
645              seperatebuilddir=1      fi
646              builddir=build      
647              rundir=build      CODE_DIR=$dir/code
648              ( cd $dir/build; ln -sf ../input/* . )      BUILD_DIR=$dir/$builddir
649          else      MPI_FILES="CPP_EEOPTIONS.h_mpi SIZE.h_mpi"
650              seperatebuilddir=0      NOMPI_FILES="CPP_EEOPTIONS.h_nompi SIZE.h_nompi"
651              builddir=input  
652              rundir=input      #  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          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} ${run:-N} $results      
704          echo      echo
705          formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results >> $SUMMARY      formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \
706            ${run:-N} $results
707          ( cd $DRESULTS"/"$NDIR ; gzip * )      echo
708        formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \
709          tar -cf $DRESULTS"/"$NDIR".tar" $DRESULTS"/"$NDIR          ${run:-N} $results >> $SUMMARY
710          $MPACK -s MITgcm-test -m 1000000 $DRESULTS"/"$NDIR".tar" $ADDRESSES      echo "fresults='" > $CDIR"/summary.txt"
711        formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \
712            ${run:-N} $results >> $CDIR"/summary.txt"
713        echo "'" >> $CDIR"/summary.txt"
714        echo "MACH='$MACH'" >> $CDIR"/summary.txt"
715        echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"
716        echo "DATE='$DATE'" >> $CDIR"/summary.txt"
717        echo "tdir='$dir'" >> $CDIR"/summary.txt"
718        
719        (
720            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
729            RETVAL=$?
730            if test "x$RETVAL" != x0 ; then
731                echo "Warning: \"$MPACK\" failed -- please contact <edhill@mitgcm.org>"
732            else
733                rm -f $DRESULTS"/"$NDIR".tar*"
734            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
744    
 echo -------------------------------------------------------------------------------  
 echo  
 echo >> $SUMMARY  
 date >> $SUMMARY  
745  cat $SUMMARY  cat $SUMMARY
746    
 # tar -cf $DRESULTS".tar" $DRESULTS  
 #  
 # $MPACK -s MITgcm-test -m 1000000 $DRESULTS".tar" $ADDRESSES  
   

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

  ViewVC Help
Powered by ViewVC 1.1.22