/[MITgcm]/MITgcm/verification/testscript
ViewVC logotype

Diff of /MITgcm/verification/testscript

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

revision 1.8 by adcroft, Fri Aug 3 20:18:40 2001 UTC revision 1.20 by adcroft, Thu Dec 6 15:26:16 2001 UTC
# Line 1  Line 1 
1  #!/bin/sh  #!/bin/sh
2    
 similar()  
 {  
 # similar digits a b  
 #  
 #  compare the floating point number a and b and successively reduced  
 #  truncation until a match is found  
  for digits in 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0  
  do  
    a=`printf '%22.'$digits'e\n' $1`  
    b=`printf '%22.'$digits'e\n' $2`  
    if [ $a = $b ]; then  
     if [ $verbose -gt 1 ]; then  
      echo $1 $2 $a 1>&2  
     fi  
     break  
    fi  
  done  
  return $digits  
 }  
   
3  compare_lines()  compare_lines()
4  {  {
 # compare_lines digits < file  
 #  
 #  read each line of file and test the 2nd and 3rd column values for  
 #  similarity based on the function similar()  
  worst_so_far=$1  
  while read linenum a b  
  do  
   if [ $debug -gt 0 ]; then  
    echo compare_lines: similar a=$a b=$b 1>&2  
   fi  
   similar $a $b  
   digits=$?  
   if [ $digits -lt $worst_so_far ]; then  
    worst_so_far=$digits  
   fi  
  done  
   if [ $debug -gt 0 ]; then  
    echo compare_lines: worst_so_far=$worst_so_far 1>&2  
   fi  
  return $worst_so_far  
 }  
   
 compare_lines2()  
 {  
5  # use codelet to compare lines  # use codelet to compare lines
6     if [ $verbose -gt 1 ]; then
7      cat tmp3.txt 1>&2
8     fi
9   return `./a.out < tmp3.txt`   return `./a.out < tmp3.txt`
10  }  }
11    
# Line 77  testoutput_for_prop() Line 36  testoutput_for_prop()
36   if [ $debug -gt 0 ]; then   if [ $debug -gt 0 ]; then
37    echo testoutput_for_prop: compare_lines 1>&2    echo testoutput_for_prop: compare_lines 1>&2
38   fi   fi
39   #compare_lines 99 < tmp3.txt   compare_lines
  compare_lines2  
40   digits_of_similarity=$?   digits_of_similarity=$?
41   if [ $digits_of_similarity -eq 99 ]; then   if [ $digits_of_similarity -eq 99 ]; then
42    if [ $verbose -gt 0 ]; then    if [ $verbose -gt 0 ]; then
# Line 124  if [ $debug -gt 0 ]; then Line 82  if [ $debug -gt 0 ]; then
82   echo testoutput: cg2dres=$cg2dres 1>&2   echo testoutput: cg2dres=$cg2dres 1>&2
83  fi  fi
84    
85  if [ $testmore -gt 0 ]; then  if [ $longtest -gt 0 ]; then
86  testoutput_for_prop $1 "dynstat_theta_min" "theta minimum"; tmin=$?  testoutput_for_prop $1 "dynstat_theta_min" "theta minimum"; tmin=$?
87  testoutput_for_prop $1 "dynstat_theta_max" "theta maximum"; tmax=$?  testoutput_for_prop $1 "dynstat_theta_max" "theta maximum"; tmax=$?
88  testoutput_for_prop $1 "dynstat_theta_mean" "theta mean"; tmean=$?  testoutput_for_prop $1 "dynstat_theta_mean" "theta mean"; tmean=$?
# Line 164  genmakemodel() Line 122  genmakemodel()
122   ( cd $1;   ( cd $1;
123     if [ $quick -eq 0 -o ! -r Makefile ]; then     if [ $quick -eq 0 -o ! -r Makefile ]; then
124      printf 'genmake ... ' 1>&2      printf 'genmake ... ' 1>&2
125      ../../../tools/genmake -mods=../code > make.log 2>&1      if [ $ieee -eq 0 ]; then
126         ../../../tools/genmake -mods=../code > make.log 2>&1
127        else
128         ../../../tools/genmake -ieee -mods=../code > make.log 2>&1
129        fi
130      if [ $? -ne 0 ]; then      if [ $? -ne 0 ]; then
131       tail make.log       tail make.log
132       echo makemodel: genmake failed 1>&2       echo genmakemodel: genmake failed 1>&2
133       return 1       return 1
134      else      else
135        echo succesful 1>&2        echo succesful 1>&2
# Line 176  genmakemodel() Line 138  genmakemodel()
138   )   )
139  }  }
140    
141    makecleancompile()
142    {
143    # makecleancompile directory
144     ( cd $1;
145       if [ $force -gt 0 ]; then
146        rm -f output.txt
147        printf 'make clean ... ' 2>&1
148        make CLEAN >> make.log 2>&1
149        if [ $? -ne 0 ]; then
150          tail make.log
151          echo makecleancompile: make clean failed 1>&2
152          return 1
153        else
154          echo succesful 1>&2
155        fi
156       fi
157     )
158    }
159    
160    makecleanupafter()
161    {
162    # makeupafter directory
163     ( cd $1;
164       if [ $clean -gt 0 ]; then
165        rm -f output.txt
166        printf 'make clean ... ' 2>&1
167        make CLEAN >> make.log 2>&1
168        if [ $? -ne 0 ]; then
169          tail make.log
170          echo makeupafter: make clean failed 1>&2
171          return 1
172        else
173          echo succesful 1>&2
174        fi
175       fi
176     )
177    }
178    
179  makedependmodel()  makedependmodel()
180  {  {
181  # makedependmodel directory  # makedependmodel directory
# Line 221  runmodel() Line 221  runmodel()
221    
222   ( cd $1   ( cd $1
223     if [ -x $2 ]; then     if [ -x $2 ]; then
224      if [ ! -r output.txt -o $quick -eq 0 ]; then      if [ $quick -eq 0 ]; then
225       echo runmodel: running... 1>&2       rm -f output.txt
      ( ./$2 > output.txt 2>&1 ) && return 0  
      return 1  
     else  
      echo runmodel: output.txt is newer than executable 1>&2  
      return 0  
226      fi      fi
227     else      printf 'runmodel: ' 1>&2
228      echo runmodel: executable \"$1/$2\" is missing 1>&2      make output.txt && return 0
229      return 1  #   if [ ! -r output.txt -o $quick -eq 0 ]; then
230    #    echo runmodel: running... 1>&2
231    #    ( ./$2 > output.txt 2>&1 ) && return 0
232    #    rm -f output.txt
233    #    ( make output.txt ) && return 0
234    #    return 1
235    #   else
236    #    echo runmodel: output.txt is newer than executable 1>&2
237    #    ( make output.txt ) && return 0
238    #    return 0
239    #   fi
240    #  else
241    #   echo runmodel: executable \"$1/$2\" is missing 1>&2
242    #   return 1
243     fi     fi
244   )   )
245  }  }
# Line 247  cat > tmp_cmpnum.f <<EOFA Line 255  cat > tmp_cmpnum.f <<EOFA
255        best=-16        best=-16
256    99  read(*,*,end=70,err=60) linnum,a,b    99  read(*,*,end=70,err=60) linnum,a,b
257        diff=0.5*(abs(a)+abs(b))        diff=0.5*(abs(a)+abs(b))
258        if (diff.gt.0.) then  c     print *,a,b,diff,abs(a-b)/diff
259          if (diff.gt.1.e-12) then
260          diff=abs(a-b)/diff          diff=abs(a-b)/diff
261          if (diff.gt.0.) then          if (diff.gt.0.) then
262  c         print *,int(log10(diff)),diff  c         print *,int(log10(diff)),diff
263            linnum=int(log10(diff))            linnum=int(log10(diff))
264            best=max(best,linnum)            best=max(best,linnum)
 c       else  
 c         print *,-16  
265          endif          endif
266  c     else        else
267  c       diff=0.          if (best.eq.-16.and.diff.ne.0.) best=-22
 c       print *,-16  
268        endif        endif
269        goto 99        goto 99
270    60  stop 'cmpnum: An error occured reading a,b'    60  stop 'cmpnum: An error occured reading a,b'
# Line 305  $0 [-help] [-quick] [-verbose] dir1 [dir Line 311  $0 [-help] [-quick] [-verbose] dir1 [dir
311   -quick     Skip "genmake" and "make depend" if the Makefile exists   -quick     Skip "genmake" and "make depend" if the Makefile exists
312   -quiet     Reduce the amount of output   -quiet     Reduce the amount of output
313   -verbose   Produce copious amounts of output   -verbose   Produce copious amounts of output
314     -debug     Produce even more output which will mean nothing to most
315     -force     Do "make CLEAN" before compiling. This forces a complete rebuild.
316     -clean     Do "make CLEAN" after compiling and testing.
317     -shorttest Don't compare numeric output for mean and s.d. of variables.
318     -noieee    By default, $0 uses the -ieee option for genmake. This turns it off.
319    
320  Normal usage:  Normal usage:
321   $0 *       Configure, compile, run and analyze in all experiment directories   $0 *       Configure, compile, run and analyze in all experiment directories
322  EOF  EOF
323  }  }
324    
325    scandirs()
326    {
327    if [ $# -eq 0 ]; then
328     for arg in *
329      do
330       test -d $arg/input && echo $arg
331     done
332    else
333     echo $*
334    fi
335    }
336    
337  ###############################################################################  ###############################################################################
338    
339  # Main function  # Main function
# Line 319  EOF Line 342  EOF
342  debug=0  debug=0
343  verbose=1  verbose=1
344  quick=0  quick=0
345  testmore=0  force=0
346    clean=0
347    ieee=1
348    longtest=1
349  expts=''  expts=''
350    
351  # Process arguments  # Process arguments
# Line 329  do Line 355  do
355     -quick) quick=1;;     -quick) quick=1;;
356     -verbose) verbose=2;;     -verbose) verbose=2;;
357     -debug) debug=1;;     -debug) debug=1;;
358     -testmore) testmore=1;;     -force) force=1;;
359       -clean) clean=1;;
360       -noieee) ieee=0;;
361       -shorttest) longtest=0;;
362     -quiet) verbose=0;;     -quiet) verbose=0;;
363     -help) show_help; exit 0;;     -help) show_help; exit 0;;
364       -*) echo Unrecognized option:$arg; exit 9;;
365     *) test -d $arg && expts=`echo $expts $arg`;;     *) test -d $arg && expts=`echo $expts $arg`;;
366   esac   esac
367  done  done
368    
369  if [ ${#expts} -eq 0 ]; then  if [ $force -gt 0 -a $quick -gt 0 ]; then
370   echo Scanning all directories   echo You specified -quick and -force together which conflict.
371   for arg in *   echo Please specify either -quick or -force or neither but not both.
372    do   exit 1
    test -d $arg && expts=`echo $expts $arg`  
  done  
373  fi  fi
374    
375    #if [ ${#expts} -eq 0 ]; then
376    # echo Scanning all directories
377    # for arg in *
378    #  do
379    #   test -d $arg && expts=`echo $expts $arg`
380    # done
381    #fi
382    expts=`scandirs $expts`
383    
384  createcodelet  createcodelet
385    
386  if [ $testmore -eq 0 ]; then  if [ $longtest -gt 0 ]; then
387  cat << EOF > summary.txt  cat << EOF > summary.txt
388                  T           S           U           V                  T           S           U           V
389  C D M    c        m  s        m  s        m  s        m  s  C D M    c        m  s        m  s        m  s        m  s
# Line 375  do Line 412  do
412   echo Experiment: $dir   echo Experiment: $dir
413   echo   echo
414   unset genmake makedepend make run   unset genmake makedepend make run
415   results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --'   if [ $longtest -gt 0 ]; then
416   results='-- -- -- -- -- -- -- -- --'    results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --'
417     else
418      results='-- -- -- -- -- -- -- -- --'
419     fi
420   genmakemodel $dir/input && genmake=Y \   genmakemodel $dir/input && genmake=Y \
421     && makecleancompile $dir/input \
422   && makedependmodel $dir/input && makedepend=Y \   && makedependmodel $dir/input && makedepend=Y \
423   && makemodel $dir/input && make=Y \   && makemodel $dir/input && make=Y \
424   && runmodel $dir/input mitgcmuv && run=Y \   && runmodel $dir/input mitgcmuv && run=Y \
425   && results=`testoutput $dir`   && results=`testoutput $dir` \
426     && makecleanupafter $dir/input
427   echo   echo
428   formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results   formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results
429   echo   echo

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.20

  ViewVC Help
Powered by ViewVC 1.1.22