/[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.10 by adcroft, Fri Aug 10 16:49:51 2001 UTC revision 1.25 by edhill, Thu Oct 9 04:19:20 2003 UTC
# Line 11  compare_lines() Line 11  compare_lines()
11    
12  testoutput_for_prop()  testoutput_for_prop()
13  {  {
14  # testoutput_for_prop dir s1 label  # testoutput_for_prop dir s1 label subdir
15  #  #
16  #  compares files in $dir/input/output.txt and $dir/results.output.txt  #  compares files in $dir/$subdir/output.txt and $dir/results/output.txt
17  #  using search strings s1 and text label  #  using search strings s1 and text label
18    
19   if [ $debug -gt 0 ]; then   if [ $debug -gt 0 ]; then
20    echo testoutput_for_prop: grep "$2" $1/input/output.txt 1>&2    echo testoutput_for_prop: grep "$2" $1/$4/output.txt 1>&2
21   fi   fi
22   if [ -r $1/input/output.txt ]; then   if [ -r $1/$4/output.txt ]; then
23    grep "$2" $1/input/output.txt | sed 's/.*=//' | nl > tmp1.txt    grep "$2" $1/$4/output.txt | sed 's/.*=//' | nl > tmp1.txt
24      lncnt=`wc -l tmp1.txt | awk '{print $1}' `
25      if [ $lncnt -lt 3 ]; then
26       if [ $verbose -gt 0 ]; then
27        echo Not enough lines of output when searching for "$2" 1>&2
28       fi
29       return 99
30      fi
31   else   else
32    echo testoutput_for_prop: output.txt from model run was not readable 1>&2    echo testoutput_for_prop: output.txt from model run was not readable 1>&2
33    return 99    return 99
# Line 29  testoutput_for_prop() Line 36  testoutput_for_prop()
36    echo testoutput_for_prop: grep "$2" $1/results/output.txt 1>&2    echo testoutput_for_prop: grep "$2" $1/results/output.txt 1>&2
37   fi   fi
38   grep "$2" $1/results/output.txt | sed 's/.*=//' | nl > tmp2.txt   grep "$2" $1/results/output.txt | sed 's/.*=//' | nl > tmp2.txt
39      lncnt=`wc -l tmp2.txt | awk '{print $1}' `
40      if [ $lncnt -lt 3 ]; then
41       if [ $verbose -gt 0 ]; then
42        echo Not enough lines of output when searching for "$2" 1>&2
43       fi
44       return 99
45      fi
46   if [ $debug -gt 0 ]; then   if [ $debug -gt 0 ]; then
47    echo testoutput_for_prop: join tmp1.txt tmp2.txt 1>&2    echo testoutput_for_prop: join tmp1.txt tmp2.txt 1>&2
48   fi   fi
# Line 70  done Line 84  done
84    
85  testoutput()  testoutput()
86  {  {
87  # testoutput diretory  # testoutput diretory subdir
88  #  #
89  #  test output in "directory"  #  test output in "directory"
90    
91  if [ $debug -gt 0 ]; then  if [ $debug -gt 0 ]; then
92   echo testoutput: testoutput_for_prop $1 cg2d_init_res 1>&2   echo testoutput: testoutput_for_prop $1 cg2d_init_res 1>&2
93  fi  fi
94  testoutput_for_prop $1 "cg2d_init_res" "cg2d init. residual"; cg2dres=$?  testoutput_for_prop $1 "cg2d_init_res" "cg2d init. residual" $2; cg2dres=$?
95  if [ $debug -gt 0 ]; then  if [ $debug -gt 0 ]; then
96   echo testoutput: cg2dres=$cg2dres 1>&2   echo testoutput: cg2dres=$cg2dres 1>&2
97  fi  fi
98    
99  if [ $longtest -gt 0 ]; then  if [ $longtest -gt 0 ]; then
100  testoutput_for_prop $1 "dynstat_theta_min" "theta minimum"; tmin=$?  testoutput_for_prop $1 "dynstat_theta_min" "theta minimum" $2; tmin=$?
101  testoutput_for_prop $1 "dynstat_theta_max" "theta maximum"; tmax=$?  testoutput_for_prop $1 "dynstat_theta_max" "theta maximum" $2; tmax=$?
102  testoutput_for_prop $1 "dynstat_theta_mean" "theta mean"; tmean=$?  testoutput_for_prop $1 "dynstat_theta_mean" "theta mean" $2; tmean=$?
103  testoutput_for_prop $1 "dynstat_theta_sd" "theta s.d."; tsd=$?  testoutput_for_prop $1 "dynstat_theta_sd" "theta s.d." $2; tsd=$?
104  testoutput_for_prop $1 "dynstat_salt_min" "salt minimum"; smin=$?  testoutput_for_prop $1 "dynstat_salt_min" "salt minimum" $2; smin=$?
105  testoutput_for_prop $1 "dynstat_salt_max" "salt maximum"; smax=$?  testoutput_for_prop $1 "dynstat_salt_max" "salt maximum" $2; smax=$?
106  testoutput_for_prop $1 "dynstat_salt_mean" "salt mean"; smean=$?  testoutput_for_prop $1 "dynstat_salt_mean" "salt mean" $2; smean=$?
107  testoutput_for_prop $1 "dynstat_salt_sd" "salt s.d."; ssd=$?  testoutput_for_prop $1 "dynstat_salt_sd" "salt s.d." $2; ssd=$?
108  testoutput_for_prop $1 "dynstat_uvel_min" "U minimum"; umin=$?  testoutput_for_prop $1 "dynstat_uvel_min" "U minimum" $2; umin=$?
109  testoutput_for_prop $1 "dynstat_uvel_max" "U maximum"; umax=$?  testoutput_for_prop $1 "dynstat_uvel_max" "U maximum" $2; umax=$?
110  testoutput_for_prop $1 "dynstat_uvel_mean" "U mean"; umean=$?  testoutput_for_prop $1 "dynstat_uvel_mean" "U mean" $2; umean=$?
111  testoutput_for_prop $1 "dynstat_uvel_sd" "U s.d."; usd=$?  testoutput_for_prop $1 "dynstat_uvel_sd" "U s.d." $2; usd=$?
112  testoutput_for_prop $1 "dynstat_vvel_min" "V minimum"; vmin=$?  testoutput_for_prop $1 "dynstat_vvel_min" "V minimum" $2; vmin=$?
113  testoutput_for_prop $1 "dynstat_vvel_max" "V maximum"; vmax=$?  testoutput_for_prop $1 "dynstat_vvel_max" "V maximum" $2; vmax=$?
114  testoutput_for_prop $1 "dynstat_vvel_mean" "V mean"; vmean=$?  testoutput_for_prop $1 "dynstat_vvel_mean" "V mean" $2; vmean=$?
115  testoutput_for_prop $1 "dynstat_vvel_sd" "V s.d."; vsd=$?  testoutput_for_prop $1 "dynstat_vvel_sd" "V s.d." $2; vsd=$?
116  else  else
117  testoutput_for_prop $1 "dynstat_theta_min" "theta minimum"; tmin=$?  testoutput_for_prop $1 "dynstat_theta_min" "theta minimum" $2; tmin=$?
118  testoutput_for_prop $1 "dynstat_theta_max" "theta maximum"; tmax=$?  testoutput_for_prop $1 "dynstat_theta_max" "theta maximum" $2; tmax=$?
119  testoutput_for_prop $1 "dynstat_salt_min" "salt minimum"; smin=$?  testoutput_for_prop $1 "dynstat_salt_min" "salt minimum" $2; smin=$?
120  testoutput_for_prop $1 "dynstat_salt_max" "salt maximum"; smax=$?  testoutput_for_prop $1 "dynstat_salt_max" "salt maximum" $2; smax=$?
121  testoutput_for_prop $1 "dynstat_uvel_min" "U minimum"; umin=$?  testoutput_for_prop $1 "dynstat_uvel_min" "U minimum" $2; umin=$?
122  testoutput_for_prop $1 "dynstat_uvel_max" "U maximum"; umax=$?  testoutput_for_prop $1 "dynstat_uvel_max" "U maximum" $2; umax=$?
123  testoutput_for_prop $1 "dynstat_vvel_min" "V minimum"; vmin=$?  testoutput_for_prop $1 "dynstat_vvel_min" "V minimum" $2; vmin=$?
124  testoutput_for_prop $1 "dynstat_vvel_max" "V maximum"; vmax=$?  testoutput_for_prop $1 "dynstat_vvel_max" "V maximum" $2; vmax=$?
125  fi  fi
126    
127  dashnum $cg2dres $tmin $tmax $tmean $tsd $smin $smax $smean $ssd \  dashnum $cg2dres $tmin $tmax $tmean $tsd $smin $smax $smean $ssd \
# Line 122  genmakemodel() Line 136  genmakemodel()
136   ( cd $1;   ( cd $1;
137     if [ $quick -eq 0 -o ! -r Makefile ]; then     if [ $quick -eq 0 -o ! -r Makefile ]; then
138      printf 'genmake ... ' 1>&2      printf 'genmake ... ' 1>&2
139      ../../../tools/genmake -ieee -mods=../code > make.log 2>&1      if [ $ieee -eq 0 ]; then
140         ../../../tools/$genmake -mods=../code > make.log 2>&1
141        else
142         ../../../tools/$genmake -ieee -mods=../code > make.log 2>&1
143        fi
144      if [ $? -ne 0 ]; then      if [ $? -ne 0 ]; then
145       tail make.log       tail make.log
146       echo genmakemodel: genmake failed 1>&2       echo genmakemodel: $genmake failed 1>&2
147       return 1       return 1
148      else      else
149        echo succesful 1>&2        echo succesful 1>&2
# Line 134  genmakemodel() Line 152  genmakemodel()
152   )   )
153  }  }
154    
155  makeclean()  makecleancompile()
156  {  {
157  # makedependmodel directory  # makecleancompile directory
158     ( cd $1;
159       if [ $force -gt 0 ]; then
160        rm -f output.txt
161        printf 'make clean ... ' 2>&1
162        make CLEAN >> make.log 2>&1
163        if [ $? -ne 0 ]; then
164          tail make.log
165          echo makecleancompile: make clean failed 1>&2
166          return 1
167        else
168          echo succesful 1>&2
169        fi
170       fi
171     )
172    }
173    
174    makecleanupafter()
175    {
176    # makeupafter directory
177   ( cd $1;   ( cd $1;
178     if [ $clean -gt 0 ]; then     if [ $clean -gt 0 ]; then
179        rm -f output.txt
180      printf 'make clean ... ' 2>&1      printf 'make clean ... ' 2>&1
181      make CLEAN >> make.log 2>&1      make CLEAN >> make.log 2>&1
182      if [ $? -ne 0 ]; then      if [ $? -ne 0 ]; then
183        tail make.log        tail make.log
184        echo makeclean: make clean failed 1>&2        echo makeupafter: make clean failed 1>&2
185        return 1        return 1
186      else      else
187        echo succesful 1>&2        echo succesful 1>&2
# Line 189  makemodel() Line 227  makemodel()
227   )   )
228  }  }
229    
230    linkdata()
231    {
232    # linkdata flag
233    # symbolically link data files to run directory
234     if [ $1 -ne 0 ]; then
235    # if [ ! -r $2 ]; then
236    #  mkdir $2
237    # fi
238      ( cd $2; ln -sf ../input/* .)
239     fi
240    }
241    
242  runmodel()  runmodel()
243  {  {
244  # runmodel directory exe  # runmodel directory exe
# Line 197  runmodel() Line 247  runmodel()
247    
248   ( cd $1   ( cd $1
249     if [ -x $2 ]; then     if [ -x $2 ]; then
250      if [ ! -r output.txt -o $quick -eq 0 ]; then      if [ $quick -eq 0 ]; then
251       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  
252      fi      fi
253     else      printf 'runmodel: ' 1>&2
254      echo runmodel: executable \"$1/$2\" is missing 1>&2       make output.txt && return 0
255      return 1       return 1
256     fi     fi
257   )   )
258  }  }
# Line 280  $0 [-help] [-quick] [-verbose] dir1 [dir Line 325  $0 [-help] [-quick] [-verbose] dir1 [dir
325   -quiet     Reduce the amount of output   -quiet     Reduce the amount of output
326   -verbose   Produce copious amounts of output   -verbose   Produce copious amounts of output
327   -debug     Produce even more output which will mean nothing to most   -debug     Produce even more output which will mean nothing to most
328   -clean     Do "make CLEAN" before compiling. This forces a complete rebuild.   -force     Do "make CLEAN" before compiling. This forces a complete rebuild.
329   -longtest  Compare numeric output for mean and s.d. of variables.   -clean     Do "make CLEAN" after compiling and testing.
330     -shorttest Don't compare numeric output for mean and s.d. of variables.
331     -noieee    By default, $0 uses the -ieee option for genmake. This turns it off.
332     -cleanup   Aggresively removes all model output, executables and object files
333                and then exits. Use with care.
334     -2        Use genmake2 rather than genmake
335    
336  Normal usage:  Normal usage:
337   $0 *       Configure, compile, run and analyze in all experiment directories   $0 *       Configure, compile, run and analyze in all experiment directories
338  EOF  EOF
339  }  }
340    
341    scandirs()
342    {
343    if [ $# -eq 0 ]; then
344     for arg in *
345      do
346       test -d $arg/input && echo $arg
347     done
348    else
349     echo $*
350    fi
351    }
352    
353    clean_up()
354    {
355    # Find all executables, object files, CPP'd source and model output
356    # and DELETE it.
357    for opt in '-name "mitgcmuv*"' '-name "*.o"' '-name "*.f"' '-name "*.c"' '-name "fort.*"' '-name "make.log"' '-path *results -prune -o -name "*.meta"' '-path *results -prune -o -name "*.data"' '-type l'
358     do
359       echo Cleaning: find . $opt -exec rm {} \;
360       find . $opt -exec rm {} \;
361    done
362    }
363    
364    ###############################################################################
365    ###############################################################################
366  ###############################################################################  ###############################################################################
367    
368  # Main function  # Main function
# Line 296  EOF Line 371  EOF
371  debug=0  debug=0
372  verbose=1  verbose=1
373  quick=0  quick=0
374    force=0
375  clean=0  clean=0
376  longtest=0  ieee=1
377    longtest=1
378  expts=''  expts=''
379    genmake=genmake
380    
381  # Process arguments  # Process arguments
382  for arg in $@  for arg in $@
383  do  do
384   case $arg in   case $arg in
385       -cleanup) clean_up; exit 0;;
386     -quick) quick=1;;     -quick) quick=1;;
387     -verbose) verbose=2;;     -verbose) verbose=2;;
388     -debug) debug=1;;     -debug) debug=1;;
389       -force) force=1;;
390     -clean) clean=1;;     -clean) clean=1;;
391     -longtest) longtest=1;;     -2) genmake=genmake2;;
392       -noieee) ieee=0;;
393       -shorttest) longtest=0;;
394     -quiet) verbose=0;;     -quiet) verbose=0;;
395     -help) show_help; exit 0;;     -help) show_help; exit 0;;
396       -*) echo Unrecognized option:$arg; exit 9;;
397     *) test -d $arg && expts=`echo $expts $arg`;;     *) test -d $arg && expts=`echo $expts $arg`;;
398   esac   esac
399  done  done
400    
401  if [ ${#expts} -eq 0 ]; then  if [ $force -gt 0 -a $quick -gt 0 ]; then
402   echo Scanning all directories   echo You specified -quick and -force together which conflict.
403   for arg in *   echo Please specify either -quick or -force or neither but not both.
404    do   exit 1
    test -d $arg && expts=`echo $expts $arg`  
  done  
405  fi  fi
406    
407    #if [ ${#expts} -eq 0 ]; then
408    # echo Scanning all directories
409    # for arg in *
410    #  do
411    #   test -d $arg && expts=`echo $expts $arg`
412    # done
413    #fi
414    expts=`scandirs $expts`
415    
416  createcodelet  createcodelet
417    
418    date > summary.txt
419  if [ $longtest -gt 0 ]; then  if [ $longtest -gt 0 ]; then
420  cat << EOF > summary.txt  cat << EOF >> summary.txt
421                  T           S           U           V                  T           S           U           V
422  C D M    c        m  s        m  s        m  s        m  s  C D M    c        m  s        m  s        m  s        m  s
423  n p a R  g  m  m  e  .  m  m  e  .  m  m  e  .  m  m  e  .  n p a R  g  m  m  e  .  m  m  e  .  m  m  e  .  m  m  e  .
# Line 335  g d e n  d  n  x  n  .  n  x  n  .  n  x Line 426  g d e n  d  n  x  n  .  n  x  n  .  n  x
426    
427  EOF  EOF
428  else  else
429  cat << EOF > summary.txt  cat << EOF >> summary.txt
430                T     S     U     V                T     S     U     V
431  C D M    c                          C D M    c                        
432  n p a R  g  m  m  m  m  m  m  m  m  n p a R  g  m  m  m  m  m  m  m  m
# Line 353  do Line 444  do
444   echo   echo
445   echo Experiment: $dir   echo Experiment: $dir
446   echo   echo
447   unset genmake makedepend make run   unset genmakepass makedepend make run
448   results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --'   if [ $longtest -gt 0 ]; then
449   results='-- -- -- -- -- -- -- -- --'    results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --'
450   genmakemodel $dir/input && genmake=Y \   else
451   && makeclean $dir/input \    results='-- -- -- -- -- -- -- -- --'
452   && makedependmodel $dir/input && makedepend=Y \   fi
453   && makemodel $dir/input && make=Y \   if [ -r $dir/build ]; then
454   && runmodel $dir/input mitgcmuv && run=Y \    seperatebuilddir=1
455   && results=`testoutput $dir`    builddir=build
456      rundir=build
457      (cd $dir/input; rm -f *.{o,f,c,F} work* output.txt Make* make.log; )
458      (cd $dir/build; ln -sf ../input/* .)
459     else
460      seperatebuilddir=0
461      builddir=input
462      rundir=input
463     fi
464     genmakemodel $dir/$builddir && genmakepass=Y \
465     && makecleancompile $dir/$builddir \
466     && makedependmodel $dir/$builddir && makedepend=Y \
467     && makemodel $dir/$builddir && make=Y \
468     && linkdata $seperatebuilddir $dir/$rundir \
469     && runmodel $dir/$builddir mitgcmuv && run=Y \
470     && results=`testoutput $dir $rundir` \
471     && makecleanupafter $dir/$builddir
472   echo   echo
473   formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results   formatresults $dir ${genmakepass:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results
474   echo   echo
475   formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results >> summary.txt   formatresults $dir ${genmakepass:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results >> summary.txt
476   fi   fi
477  done  done
478    
# Line 373  rm tmp_cmpnum.f a.out Line 480  rm tmp_cmpnum.f a.out
480    
481  echo -------------------------------------------------------------------------------  echo -------------------------------------------------------------------------------
482  echo  echo
483    date >> summary.txt
484  cat summary.txt  cat summary.txt

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.25

  ViewVC Help
Powered by ViewVC 1.1.22