/[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.9.2.2 by edhill, Fri Oct 3 04:04:38 2003 UTC revision 1.26 by edhill, Fri Dec 5 14:56:45 2003 UTC
# Line 1  Line 1 
1  #!/bin/bash  #! /usr/bin/env bash
2  #  #
3  #  $Header$  #  $Header$
4    #  $Name$
5  #  #
6    
7  usage()  usage()
# Line 11  usage() Line 12  usage()
12      echo "where possible OPTIONS are:"      echo "where possible OPTIONS are:"
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"
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 "  (-c|-command)STRING      command to run"      echo "                             (DEF=\"\" for \"bash\")"
25        echo "  (-adm|-ad)               perform an adjoint run"
26        echo "  (-command) STRING        command to run"
27      echo "                             (DEF=\"make output.txt\")"      echo "                             (DEF=\"make output.txt\")"
28      echo "  (-m|-make)STRING         command to use for \"make\""      echo "  (-m|-make) STRING        command to use for \"make\""
29      echo "                             (DEF=\"make\")"      echo "                             (DEF=\"make\")"
30        echo "  (-clean)                 *ONLY* run \"make CLEAN\""
31      echo "  (-quick|-q)              same as \"-nogenmake -noclean -nodepend\""      echo "  (-quick|-q)              same as \"-nogenmake -noclean -nodepend\""
32      echo "  (-nogenmake|-ng)         skip the genmake stage"      echo "  (-nogenmake|-ng)         skip the genmake stage"
33      echo "  (-noclean|-nc)           skip the \"make clean\" stage"      echo "  (-noclean|-nc)           skip the \"make clean\" stage"
# Line 41  build_mpack() Line 47  build_mpack()
47      echo -n "building the mpack utility...  "      echo -n "building the mpack utility...  "
48      if test ! -x "$MPACKDIR/mpack" ; then      if test ! -x "$MPACKDIR/mpack" ; then
49          if test ! -d $MPACKDIR ; then          if test ! -d $MPACKDIR ; then
50                echo
51              echo "Error: can't find \"$MPACKDIR\""              echo "Error: can't find \"$MPACKDIR\""
52              echo "  are you sure this program is being run in the correct "              echo "  are you sure this program is being run in the correct "
53              echo "  (that is, \"MITGCM_ROOT\verification\") directory?"              echo "  (that is, \"MITGCM_ROOT\verification\") directory?"
54              exit 1              echo
55                HAVE_MPACK=f
56          fi          fi
57          echo -n "building mpack...  "          echo -n "building mpack...  "
58          ( cd $MPACKDIR && ./configure && $MAKE ) > build_mpack.out 2>&1          if test "x$CC" = x ; then
59                export CC=cc
60            fi
61            ( cd $MPACKDIR && ./configure && $MAKE ) > tr_build_mpack.out 2>&1
62          RETVAL=$?          RETVAL=$?
63          if test "x$RETVAL" != x0 ; then          if test "x$RETVAL" != x0 ; then
64              echo              echo
65              echo "Error building the mpack tools at: $MPACK_DIR"              echo "Error building the mpack tools at: $MPACK_DIR"
66              exit 1              echo
67                HAVE_MPACK=f
68            else
69                rm -f tr_build_mpack.out
70                HAVE_MPACK=t
71          fi          fi
72        else
73            HAVE_MPACK=t
74      fi      fi
75      echo "OK"      echo "OK"
76  }  }
77    
 compare_lines()  
 {  
     # use codelet to compare lines  
     if [ $verbose -gt 1 ]; then  
         cat tmp3.txt 1>&2  
     fi  
     return `./a.out < tmp3.txt`  
 }  
   
78  testoutput_for_prop()  testoutput_for_prop()
79  {  {
80      # testoutput_for_prop dir s1 label subdir      # testoutput_for_prop dir s1 label subdir
# Line 78  testoutput_for_prop() Line 86  testoutput_for_prop()
86          echo testoutput_for_prop: grep "$2" $1/$4/output.txt 1>&2          echo testoutput_for_prop: grep "$2" $1/$4/output.txt 1>&2
87      fi      fi
88      if [ -r $1/$4/output.txt ]; then      if [ -r $1/$4/output.txt ]; then
89          grep "$2" $1/$4/output.txt | sed 's/.*=//' | nl > tmp1.txt          grep "$2" $1/$4/output.txt | sed 's/.*=//' | cat -n > tmp1.txt
90          lncnt=`wc -l tmp1.txt | awk '{print $1}' `          lncnt=`wc -l tmp1.txt | awk '{print $1}' `
91          if [ $lncnt -lt 3 ]; then          if [ $lncnt -lt 3 ]; then
92              if [ $verbose -gt 0 ]; then              if [ $verbose -gt 0 ]; then
# Line 93  testoutput_for_prop() Line 101  testoutput_for_prop()
101      if [ $debug -gt 0 ]; then      if [ $debug -gt 0 ]; then
102          echo testoutput_for_prop: grep "$2" $1/results/output.txt 1>&2          echo testoutput_for_prop: grep "$2" $1/results/output.txt 1>&2
103      fi      fi
104      grep "$2" $1/results/output.txt | sed 's/.*=//' | nl > tmp2.txt      grep "$2" $1/results/output.txt | sed 's/.*=//' | cat -n > tmp2.txt
105      lncnt=`wc -l tmp2.txt | awk '{print $1}' `      lncnt=`wc -l tmp2.txt | awk '{print $1}' `
106      if [ $lncnt -lt 3 ]; then      if [ $lncnt -lt 3 ]; then
107          if [ $verbose -gt 0 ]; then          if [ $verbose -gt 0 ]; then
# Line 108  testoutput_for_prop() Line 116  testoutput_for_prop()
116      if [ $debug -gt 0 ]; then      if [ $debug -gt 0 ]; then
117          echo testoutput_for_prop: compare_lines 1>&2          echo testoutput_for_prop: compare_lines 1>&2
118      fi      fi
119      compare_lines      if [ $verbose -gt 1 ]; then
120      digits_of_similarity=$?          cat tmp3.txt 1>&2
121        fi
122        echo "-1" >> tmp3.txt
123        # On the SGI O3K (*not* the O2K), "cat -n" inserts a ":" after the line number
124        cat tmp3.txt | sed -e 's|:||g' > tmp4.txt
125        digits_of_similarity=`./tmp_cmpnum < tmp4.txt`
126      if [ $digits_of_similarity -eq 99 ]; then      if [ $digits_of_similarity -eq 99 ]; then
127          if [ $verbose -gt 0 ]; then          if [ $verbose -gt 0 ]; then
128              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 120  testoutput_for_prop() Line 133  testoutput_for_prop()
133              echo There were $digits_of_similarity decimal places of similarity for \"$2\" 1>&2              echo There were $digits_of_similarity decimal places of similarity for \"$2\" 1>&2
134          fi          fi
135      fi      fi
136      rm tmp1.txt tmp2.txt tmp3.txt      rm -f tmp1.txt tmp2.txt tmp3.txt tmp4.txt
137            
138      return $digits_of_similarity      return $digits_of_similarity
139  }  }
# Line 140  dashnum() Line 153  dashnum()
153      done      done
154  }  }
155    
156    testoutput_ad()
157    {
158        grep $3 $1/results_ad/output.txt_adm | awk '{print NR " " $5}' > t05.txt
159        grep $3 $1/$2/output.txt_adm | awk '{print NR " " $5}' > t15.txt
160        grep $3 $1/results_ad/output.txt_adm | awk '{print NR " " $6}' > t06.txt
161        grep $3 $1/$2/output.txt_adm | awk '{print NR " " $6}' > t16.txt
162        join t05.txt t15.txt > t5.txt
163        join t06.txt t16.txt > t6.txt
164        echo "-1" >> t5.txt
165        echo "-1" >> t6.txt
166        digits_5=`./tmp_cmpnum < t5.txt`
167        digits_6=`./tmp_cmpnum < t6.txt`
168        dashnum $digits_5 $digits_6
169        rm -f t[01][56].txt t[56].txt
170    }
171    
172  testoutput()  testoutput()
173  {  {
174      # testoutput diretory subdir      # testoutput directory subdir
175      #      #
176      #  test output in "directory"      #  test output in "directory"
177        if test "x$ADM" = x ; then
178      if [ $debug -gt 0 ]; then          if [ $debug -gt 0 ]; then
179          echo testoutput: testoutput_for_prop $1 cg2d_init_res 1>&2              echo testoutput: testoutput_for_prop $1 cg2d_init_res 1>&2
180      fi          fi
181      testoutput_for_prop $1 "cg2d_init_res" "cg2d init. residual" $2; cg2dres=$?          testoutput_for_prop $1 "cg2d_init_res" "cg2d init. residual" $2; cg2dres=$?
182      if [ $debug -gt 0 ]; then          if [ $debug -gt 0 ]; then
183          echo testoutput: cg2dres=$cg2dres 1>&2              echo testoutput: cg2dres=$cg2dres 1>&2
184            fi
185            testoutput_for_prop $1 "dynstat_theta_min" "theta minimum" $2; tmin=$?
186            testoutput_for_prop $1 "dynstat_theta_max" "theta maximum" $2; tmax=$?
187            testoutput_for_prop $1 "dynstat_theta_mean" "theta mean" $2; tmean=$?
188            testoutput_for_prop $1 "dynstat_theta_sd" "theta s.d." $2; tsd=$?
189            testoutput_for_prop $1 "dynstat_salt_min" "salt minimum" $2; smin=$?
190            testoutput_for_prop $1 "dynstat_salt_max" "salt maximum" $2; smax=$?
191            testoutput_for_prop $1 "dynstat_salt_mean" "salt mean" $2; smean=$?
192            testoutput_for_prop $1 "dynstat_salt_sd" "salt s.d." $2; ssd=$?
193            testoutput_for_prop $1 "dynstat_uvel_min" "U minimum" $2; umin=$?
194            testoutput_for_prop $1 "dynstat_uvel_max" "U maximum" $2; umax=$?
195            testoutput_for_prop $1 "dynstat_uvel_mean" "U mean" $2; umean=$?
196            testoutput_for_prop $1 "dynstat_uvel_sd" "U s.d." $2; usd=$?
197            testoutput_for_prop $1 "dynstat_vvel_min" "V minimum" $2; vmin=$?
198            testoutput_for_prop $1 "dynstat_vvel_max" "V maximum" $2; vmax=$?
199            testoutput_for_prop $1 "dynstat_vvel_mean" "V mean" $2; vmean=$?
200            testoutput_for_prop $1 "dynstat_vvel_sd" "V s.d." $2; vsd=$?
201            dashnum $cg2dres $tmin $tmax $tmean $tsd $smin $smax $smean $ssd \
202                $umin $umax $umean $usd $vmin $vmax $vmean $vsd
203        else
204            testoutput_ad $1 $2 "precision_grdchk_result"
205      fi      fi
       
     testoutput_for_prop $1 "dynstat_theta_min" "theta minimum" $2; tmin=$?  
     testoutput_for_prop $1 "dynstat_theta_max" "theta maximum" $2; tmax=$?  
     testoutput_for_prop $1 "dynstat_theta_mean" "theta mean" $2; tmean=$?  
     testoutput_for_prop $1 "dynstat_theta_sd" "theta s.d." $2; tsd=$?  
     testoutput_for_prop $1 "dynstat_salt_min" "salt minimum" $2; smin=$?  
     testoutput_for_prop $1 "dynstat_salt_max" "salt maximum" $2; smax=$?  
     testoutput_for_prop $1 "dynstat_salt_mean" "salt mean" $2; smean=$?  
     testoutput_for_prop $1 "dynstat_salt_sd" "salt s.d." $2; ssd=$?  
     testoutput_for_prop $1 "dynstat_uvel_min" "U minimum" $2; umin=$?  
     testoutput_for_prop $1 "dynstat_uvel_max" "U maximum" $2; umax=$?  
     testoutput_for_prop $1 "dynstat_uvel_mean" "U mean" $2; umean=$?  
     testoutput_for_prop $1 "dynstat_uvel_sd" "U s.d." $2; usd=$?  
     testoutput_for_prop $1 "dynstat_vvel_min" "V minimum" $2; vmin=$?  
     testoutput_for_prop $1 "dynstat_vvel_max" "V maximum" $2; vmax=$?  
     testoutput_for_prop $1 "dynstat_vvel_mean" "V mean" $2; vmean=$?  
     testoutput_for_prop $1 "dynstat_vvel_sd" "V s.d." $2; vsd=$?  
       
     dashnum $cg2dres $tmin $tmax $tmean $tsd $smin $smax $smean $ssd \  
         $umin $umax $umean $usd $vmin $vmax $vmean $vsd  
206  }  }
207    
208  genmakemodel()  genmakemodel()
# Line 184  genmakemodel() Line 214  genmakemodel()
214          GENMAKE2="$BASH ../../../tools/genmake2"          GENMAKE2="$BASH ../../../tools/genmake2"
215          (          (
216              cd $1;              cd $1;
217                command="$GENMAKE2  -ds -m $MAKE"
218                if test "x$ADM" = x ; then
219                    command="$command --mods=../code"
220                else
221                    command="$command --mods=../code_ad"
222                    command="$command -adof=../../../tools/adjoint_options/adjoint_staf"
223                fi
224                if test "x$OPTFILE" != xNONE ; then
225                    command="$command --optfile=$OPTFILE"
226                fi
227                if test "x$IEEE" != x ; then
228                    command="$command -ieee"
229                fi
230              printf 'genmake ... ' 1>&2              printf 'genmake ... ' 1>&2
231              # ../../../tools/genmake -ieee -mods=../code > make.log 2>&1              $command > make.log 2>&1
             $GENMAKE2  -ds -m $MAKE --mods=../code "--optfile="$OPTFILE > make.log 2>&1  
232              RETVAL=$?              RETVAL=$?
233              for i in gm_state gm_optfile gm_local Makefile ; do              cp Makefile $CDIR
                 if test -r $i ; then  
                     cp $i $CDIR  
                 fi  
             done  
234              if test "x$RETVAL" != x0 ; then              if test "x$RETVAL" != x0 ; then
235                  tail make.log                  tail make.log
236                  echo "genmakemodel: genmake failed" 1>&2                  echo "genmakemodel: genmake failed" 1>&2
237                  cp make.log $CDIR                  cp genmake_* make.log $CDIR
238                  return 1                  return 1
239              else              else
240                  echo "succesful" 1>&2                  echo "successful" 1>&2
241              fi              fi
242          )          )
243      fi      fi
# Line 227  makeclean() Line 265  makeclean()
265                      return 1                      return 1
266                  fi                  fi
267              fi              fi
268              echo succesful 1>&2              echo successful 1>&2
269              exit 0              exit 0
270          )          )
271      fi      fi
# Line 250  makedependmodel() Line 288  makedependmodel()
288                  cp make.log $CDIR"/make.log"                  cp make.log $CDIR"/make.log"
289                  return 1                  return 1
290              else              else
291                  echo succesful 1>&2                  echo successful 1>&2
292              fi              fi
293          )          )
294      fi      fi
# Line 263  makemodel() Line 301  makemodel()
301          cd $1;          cd $1;
302          if test -r Makefile ; then          if test -r Makefile ; then
303              printf 'make ... ' 1>&2              printf 'make ... ' 1>&2
304              $MAKE >> make.log 2>&1              if test "x$ADM" = x ; then
305                    $MAKE >> make.log 2>&1
306                else
307                    $MAKE adall >> make.log 2>&1
308                fi
309              RETVAL=$?              RETVAL=$?
310              if test "x$RETVAL" != x0 ; then              if test "x$RETVAL" != x0 ; then
311                  tail make.log                  tail make.log
# Line 271  makemodel() Line 313  makemodel()
313                  cp make.log $CDIR"/make.log"                  cp make.log $CDIR"/make.log"
314                  return 1                  return 1
315              else              else
316                  echo succesful 1>&2                  echo successful 1>&2
317              fi              fi
318          fi          fi
319      )      )
# Line 282  linkdata() Line 324  linkdata()
324      # linkdata flag      # linkdata flag
325      #      #
326      # symbolically link data files to run directory      # symbolically link data files to run directory
327      if [ $1 -ne 0 ]; then      if test "x$1" = x1 ; then
328          ( cd $2 ;  ln -sf ../input/* . )          (
329                cd $2
330                if test "x$ADM" = x ; then
331                    files=`( cd ../input ; ls -1 | grep -v CVS )`
332                    for i in $files ; do
333                        if test ! -d "../input/"$i ; then
334                            ln -sf "../input/"$i $i
335                        fi
336                    done
337                else
338                    files=`( cd ../input ; ls -1 *.bin | grep -v CVS )`
339                    for i in $files ; do
340                        if test ! -d "../input/"$i ; then
341                            ln -sf "../input/"$i $i
342                        fi
343                    done
344                    files=`( cd ../input_ad ; ls -1 | grep -v CVS )`
345                    for i in $files ; do
346                        if test ! -d "../input_ad/"$i ; then
347                            ln -sf "../input_ad/"$i $i
348                        fi
349                    done
350                fi
351            )
352      fi      fi
353  }  }
354    
# Line 291  runmodel() Line 356  runmodel()
356  {  {
357      # runmodel directory      # runmodel directory
358      #      #
359      #  runs "$COMMAND" in "directory"      #  runs "$COMMAND in "directory"
360      #  (where "$COMMAND" is relative to "directory")      #  (where "$COMMAND" is relative to "directory")
361      (      (
362          cd $1          cd $1
363          printf 'runmodel: ' 1>&2          printf 'runmodel ... ' 1>&2
364          # make output.txt          # make output.txt
365          $COMMAND          $COMMAND >> run.log 2>&1
366          RETVAL=$?          RETVAL=$?
367          if test "x$RETVAL" = x0 ; then          if test "x$RETVAL" = x0 ; then
368              cp output.txt $CDIR"/output.txt"              echo successful 1>&2
369                if test "x$ADM" = x ; then
370                    cp output.txt $CDIR"/output.txt"
371                else
372                    cp output.txt_adm $CDIR"/output.txt_adm"
373                fi
374              return 0              return 0
375          else          else
376                tail run.log
377                echo failed 1>&2
378                cp run.log $CDIR"/run.log"
379              return 1              return 1
380          fi          fi
381      )      )
# Line 313  createcodelet() Line 386  createcodelet()
386      # create codelet for comparing model output      # create codelet for comparing model output
387    
388      echo -n "creating the comparison code...  "      echo -n "creating the comparison code...  "
389      cat > tmp_cmpnum.f <<EOFA      cat > tmp_cmpnum.c <<EOF
390        program cmpnum  #include <stdio.h>
391        implicit none  #include <math.h>
392        real*8 a,b,diff  int main( int argc, char** argv )  {
393        integer linnum,best    int linnum,best;
394        best=-16    double a,b,diff;
395    99  read(*,*,end=70,err=60) linnum,a,b    best = -16;
396        diff=0.5*(abs(a)+abs(b))    while( 1 )  {
397  c     print *,a,b,diff,abs(a-b)/diff      scanf("%d", &linnum);
398        if (diff.gt.1.e-12) then      if (linnum == -1)  break;
399          diff=abs(a-b)/diff      scanf("%lf", &a);  scanf("%lf", &b);
400          if (diff.gt.0.) then      diff = 0.5*(fabs(a)+fabs(b));
401  c         print *,int(log10(diff)),diff      if (diff > 1.e-12) {
402            linnum=int(log10(diff))        diff=fabs(a-b)/diff;
403            best=max(best,linnum)        if (diff > 0.0) {
404          endif          linnum = (int)log10(diff);
405        else          best = (best > linnum) ? best : linnum;
406          if (best.eq.-16.and.diff.ne.0.) best=-22        }
407        endif        else {
408        goto 99          if (best == -16 && diff != 0)  best = -22;
409    60  stop 'cmpnum: An error occured reading a,b'        }
410    70  print *,-best      }
411        end    }
412  EOFA    printf("%d\n", -best);
413      return 0;
414    }
415    EOF
416        cc -o tmp_cmpnum tmp_cmpnum.c -lm
417    
418      f77 tmp_cmpnum.f      if [ -x ./tmp_cmpnum ]; then
     if [ -x ./a.out ]; then  
419          echo "OK"          echo "OK"
420          return 0          return 0
421      else      else
422          echo          echo
423          echo "createcodelet: failed to compile codelet"          echo "ERROR: failed to compile comparison code"
424          exit 1          exit 1
425      fi      fi
426  }  }
# Line 383  $0 [-help] [-quick] [-verbose] dir1 [dir Line 459  $0 [-help] [-quick] [-verbose] dir1 [dir
459   -debug     Produce even more output which will mean nothing to most   -debug     Produce even more output which will mean nothing to most
460   -force     Do "make CLEAN" before compiling. This forces a complete rebuild.   -force     Do "make CLEAN" before compiling. This forces a complete rebuild.
461   -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.  
462   -cleanup   Aggresively removes all model output, executables and object files   -cleanup   Aggresively removes all model output, executables and object files
463              and then exits. Use with care.              and then exits. Use with care.
464    
# Line 405  scandirs() Line 480  scandirs()
480    
481    
482  ###############################################################################  ###############################################################################
 ###############################################################################  
 ###############################################################################  
483    
484    
485  #  Default properties  #  Default properties
# Line 416  clean=0 Line 489  clean=0
489  expts=''  expts=''
490  # ieee=1  # ieee=1
491    
492    IEEE=
493    if test "x$MITGCM_IEEE" != x ; then
494        IEEE=$MITGCM_IEEE
495    fi
496    
497    
498  CLEANUP=f  CLEANUP=f
499  QUICK=f  QUICK=f
500  NOGENMAKE=f  NOGENMAKE=f
# Line 423  NOCLEAN=f Line 502  NOCLEAN=f
502  NODEPEND=f  NODEPEND=f
503    
504  BASH=  BASH=
505  OPTFILES=  OPTFILE=NONE
506  ADDRESSES=  ADDRESSES=
507  TESTDIRS=  TESTDIRS=
508  MPACKDIR="../tools/mpack-1.6"  MPACKDIR="../tools/mpack-1.6"
509    HAVE_MPACK=
510  MPACK="$MPACKDIR/mpack"  MPACK="$MPACKDIR/mpack"
511  COMMAND="make output.txt"  COMMAND=
512  MAKE=make  MAKE=make
513  MPI=f  MPI=f
514    
515    ADM=
516    
517  echo -n "parsing options...  "  echo -n "parsing options...  "
518    
519  ac_prev=  ac_prev=
# Line 452  for ac_option ; do Line 534  for ac_option ; do
534              usage ;;              usage ;;
535                    
536          -optfile | --optfile | -of | --of)          -optfile | --optfile | -of | --of)
537              ac_prev=OPTFILES ;;              ac_prev=OPTFILE ;;
538          -optfile=* | --optfile=* | -of=* | --of=*)          -optfile=* | --optfile=* | -of=* | --of=*)
539              OPTFILES=$ac_optarg ;;              OPTFILE=$ac_optarg ;;
540                    
541          -addr | --addr | -a | --a)          -addr | --addr | -a | --a)
542              ac_prev=ADDRESSES ;;              ac_prev=ADDRESSES ;;
# Line 481  for ac_option ; do Line 563  for ac_option ; do
563          -make=* | --make=*)          -make=* | --make=*)
564              MAKE=$ac_optarg ;;              MAKE=$ac_optarg ;;
565    
566          -clean | --clean | -c | --c)          -clean | --clean)
567              CLEANUP=t ;;              CLEANUP=t ;;
568    
569          -quick | --quick | -q | --q)          -quick | --quick | -q | --q)
# Line 494  for ac_option ; do Line 576  for ac_option ; do
576              NODEPEND=t ;;              NODEPEND=t ;;
577    
578          -mpi) MPI=t ;;          -mpi) MPI=t ;;
579    
580            -adm | -ad) ADM=t ;;
581    
582            -ieee) IEEE=true ;;
583            -noieee) IEEE= ;;
584    
585          -verbose) verbose=2 ;;          -verbose) verbose=2 ;;
586          -debug) debug=1 ;;          -debug) debug=1 ;;
         -clean) clean=1 ;;  
587          -quiet) verbose=0 ;;          -quiet) verbose=0 ;;
588    
589          -*)          -*)
# Line 523  if test "x$TESTDIRS" = x ; then Line 610  if test "x$TESTDIRS" = x ; then
610      TESTDIRS=`scandirs`      TESTDIRS=`scandirs`
611  fi  fi
612    
613  if test "x$OPTFILES" = x ; then  if test "x$OPTFILE" = xNONE -a "x$MITGCM_OF" != x ; then
614      OPTFILES=$MITGCM_OF      OPTFILE=$MITGCM_OF
615  fi  fi
616  if test "x$OPTFILES" = x ; then  
617      echo "Error: please specify an optfile using either the command-line or"  if test "x$ADM" = xt -a "x$COMMAND" = x ; then
618      echo "  the MITGCM_OF environment variable.  Also, examples are located "      COMMAND="./mitgcmuv_ad > output.txt_adm 2>&1"
619      echo "  in \$ROOTDIR/tools/build_options"  fi
620      exit 1  
621    if test "x$COMMAND" = x ; then
622        COMMAND="make output.txt"
623  fi  fi
624    
625  echo "OK"  echo "OK"
# Line 545  build_mpack Line 634  build_mpack
634  MACH=`hostname`  MACH=`hostname`
635  UNAMEA=`uname -a`  UNAMEA=`uname -a`
636  DATE=`date +%Y%m%d`  DATE=`date +%Y%m%d`
637  BASE=$MACH"_"$DATE"_"  BASE="tr_"$MACH"_"$DATE"_"
638  DNUM=0  DNUM=0
639  DRESULTS="$BASE$DNUM"  DRESULTS="$BASE$DNUM"
640  while test -e $DRESULTS ; do  while test -e $DRESULTS ; do
# Line 555  done Line 644  done
644  mkdir $DRESULTS  mkdir $DRESULTS
645  RETVAL=$?  RETVAL=$?
646  if test "x$RETVAL" != x0 ; then  if test "x$RETVAL" != x0 ; then
647      echo "Error: can't create results directory \"./$DRESULTS\""      echo "ERROR: Can't create results directory \"./$DRESULTS\""
648      exit 1      exit 1
649  fi  fi
650  SUMMARY="$DRESULTS/summary.txt"  SUMMARY="$DRESULTS/summary.txt"
651  date > $SUMMARY  echo -n "Start time:  " >> $SUMMARY
652  cat << EOF >> $SUMMARY  start_date=`date`
653    echo $start_date > $SUMMARY
654    
655    of_path=
656    if test "x$OPTFILE" != xNONE ; then
657        if test -r $OPTFILE ; then
658            # get the path
659            path=${OPTFILE%/*}
660            if test "x$path" = x ; then
661                of_path=`pwd`
662            else
663                of_path=`( cd $path > /dev/null 2>&1 ; pwd )`
664            fi
665            file=${OPTFILE##*/}
666            OPTFILE=$of_path/$file
667            cp $OPTFILE $DRESULTS
668            echo >> $SUMMARY
669            echo "  OPTFILE=$OPTFILE" >> $SUMMARY
670        else
671            echo | tee $SUMMARY
672            echo "ERROR: can't read OPTFILE=\"$OPTFILE\"" | tee $SUMMARY
673            exit 1
674        fi
675    else
676        echo >> $SUMMARY
677        echo "No \"OPTFILE\" was explicitly specified by testreport," >> $SUMMARY
678        echo "   so the genmake default will be used." >> $SUMMARY
679    fi
680    echo
681    echo >> $SUMMARY
682    if test "x$ADM" = x ; then
683        cat << EOF | tee -a $SUMMARY
684                  T           S           U           V                  T           S           U           V
685  G D M    c        m  s        m  s        m  s        m  s  G D M    c        m  s        m  s        m  s        m  s
686  E p a R  g  m  m  e  .  m  m  e  .  m  m  e  .  m  m  e  .  E p a R  g  m  m  e  .  m  m  e  .  m  m  e  .  m  m  e  .
# Line 568  N n k u  2  i  a  a  d  i  a  a  d  i  a Line 688  N n k u  2  i  a  a  d  i  a  a  d  i  a
688  2 d e n  d  n  x  n  .  n  x  n  .  n  x  n  .  n  x  n  .  2 d e n  d  n  x  n  .  n  x  n  .  n  x  n  .  n  x  n  .
689    
690  EOF  EOF
691    else
692  NDIR=0      echo "ADJOINT=true" >> $SUMMARY
   
 #  For each optfile...  
 for OPTFILE in $OPTFILES ; do  
   
     OPTFILE=`pwd`"/$OPTFILE"  
     if test ! -r $OPTFILE ; then  
         echo "Error: can't read optfile \"$OPTFILE\""  
         exit 1  
     fi  
     echo  
     echo "OPTFILE=$OPTFILE" >> $SUMMARY  
693      echo >> $SUMMARY      echo >> $SUMMARY
694            cat << EOF | tee -a $SUMMARY
695      #  ...and each test directory...  G D M    C  G
696      for dir in $TESTDIRS ; do  E p a R  o  r
697    N n k u  s  a
698    2 d e n  t  d
699    
700          #  Cleanup only!  EOF
701          if test "x$CLEANUP" = xt ; then  fi
             if test -r $dir/build/Makefile ; then  
                 ( cd $dir/build ; make CLEAN )  
             fi  
             if test -r $dir/input/Makefile ; then  
                 ( cd $dir/input ; make CLEAN )  
             fi  
             continue  
         fi  
   
         #  Verify that the testdir exists and contains previous  
         #  results in the correct location--or skip this directory!  
         if test ! -r $dir"/results/output.txt" ; then  
             echo | tee -a $SUMMARY  
             echo "can't read \"$dir/results/output.txt\" -- skipping $dir" \  
                 | tee -a $SUMMARY  
             continue  
         fi  
   
         #  Is this an MPI run?  
         if test "x$MPI" = xt ; then  
             if test ! -r $dir"/code/CPP_EEOPTIONS.h_mpi" -o ! -r $dir"/code/SIZE.h_mpi" ; then  
                 echo | tee -a $SUMMARY  
                 echo "can't read \"$dir/code/CPP_EEOPTIONS.h_mpi\" or \"$dir/code/SIZE.h_mpi\"" \  
                     | tee -a $SUMMARY  
                 continue  
             else  
                 cmp $dir"/code/CPP_EEOPTIONS.h_mpi" $dir"/code/CPP_EEOPTIONS.h"  
                 RETVAL=$?  
                 if test "x$RETVAL" != x0 ; then  
                     cp $dir"/code/CPP_EEOPTIONS.h_mpi" $dir"/code/CPP_EEOPTIONS.h"  
                 fi  
                 cmp $dir"/code/SIZE.h_mpi" $dir"/code/SIZE.h"  
                 RETVAL=$?  
                 if test "x$RETVAL" != x0 ; then  
                     cp $dir"/code/SIZE.h_mpi" $dir"/code/SIZE.h"  
                 fi  
             fi  
         else  
             if test -r $dir"/code/CPP_EEOPTIONS.h_nompi" ; then  
                 cmp $dir"/code/CPP_EEOPTIONS.h_nompi" $dir"/code/CPP_EEOPTIONS.h"  
                 RETVAL=$?  
                 if test "x$RETVAL" != x0 ; then  
                     cp $dir"/code/CPP_EEOPTIONS.h_nompi" $dir"/code/CPP_EEOPTIONS.h"  
                 fi  
             fi  
             if test -r $dir"/code/SIZE.h_nompi" ; then  
                 cmp $dir"/code/SIZE.h_nompi" $dir"/code/SIZE.h"  
                 RETVAL=$?  
                 if test "x$RETVAL" != x0 ; then  
                     cp $dir"/code/SIZE.h_nompi" $dir"/code/SIZE.h"  
                 fi  
             fi  
         fi  
   
         #  Create an output dir for each OPTFILE/tdir combination  
         CDIR=$DRESULTS"/"$DRESULTS"_"$NDIR  
         mkdir $CDIR  
         CDIR=`pwd`"/$CDIR"  
702    
703          #  ...configue, make, run, and compare the output.  #  ...and each test directory...
704          echo "-------------------------------------------------------------------------------"  for dir in $TESTDIRS ; do
705          echo      
706          echo "Experiment:  $dir"      #  Cleanup only!
707          echo      if test "x$CLEANUP" = xt ; then
708          unset genmake makedepend make run          if test -r $dir/build/Makefile ; then
709          results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --'              ( cd $dir/build ; make CLEAN )
710            fi
711            if test -r $dir/input/Makefile ; then
712                ( cd $dir/input ; make CLEAN )
713            fi
714            continue
715        fi
716    
717        #  Verify that the testdir exists and contains previous
718        #  results in the correct location--or skip this directory!
719        fout=
720        if test "x$ADM" = x ; then
721            fout=$dir"/results/output.txt"
722        else
723            fout=$dir"/results_ad/output.txt_adm"
724        fi
725        if test ! -r $fout ; then
726            echo "can't read \"$fout\" -- skipping $dir"
727            continue
728        fi
729    
730          if [ -r $dir/build ]; then      echo "-------------------------------------------------------------------------------"
731              seperatebuilddir=1      echo
732              builddir=build      echo "Experiment:  $dir"
733              rundir=build      echo
734              ( cd $dir/build; ln -sf ../input/* . )      unset genmake makedepend make run
735          else      results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --'
             seperatebuilddir=0  
             builddir=input  
             rundir=input  
         fi  
736    
737          if test "x$CLEANUP" = xt ; then      builddir="input"
738              makeclean $dir/$builddir      rundir="input"
739          else      use_seperate_build=0
740              genmakemodel $dir/$builddir && genmake=Y \      if test -d $dir/build -a -r $dir/build ; then
741                  && makeclean $dir/$builddir \          builddir="build"
742                  && makedependmodel $dir/$builddir && makedepend=Y \          rundir="build"
743                  && makemodel $dir/$builddir && make=Y \          use_seperate_build=1
744                  && linkdata $seperatebuilddir $dir/$rundir \          linkdata $use_seperate_build $dir/$rundir
745                  && runmodel $dir/$builddir && run=Y \      fi
746                  && results=`testoutput $dir $rundir`      
747        if test "x$ADM" = x ; then
748            CODE_DIR=$dir/code
749        else
750            CODE_DIR=$dir/code_ad
751        fi
752        BUILD_DIR=$dir/$builddir
753        MPI_FILES="CPP_EEOPTIONS.h_mpi SIZE.h_mpi"
754        NOMPI_FILES="CPP_EEOPTIONS.h_nompi SIZE.h_nompi"
755    
756        #  Is this an MPI run?
757        if test "x$MPI" = xt ; then
758            FILES=$MPI_FILES
759            endings="_mpi"
760        else
761            FILES=$NOMPI_FILES
762            endings="_nompi"
763        fi
764        
765        #  Check to see that we have the files
766        have_files=t
767        for i in $FILES ; do
768            if test ! -r $CODE_DIR/$i ; then
769                echo "Warning: can't read file $CODE_DIR/$i"
770                have_files=f
771          fi          fi
772        done
773          echo      if test "x$have_files" != xt -a "x$MPI" = xt ; then
774          formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \          echo "Skipping $dir due to lack of input files (see above warning)"
775              ${run:-N} $results          continue
776          echo      fi
777          formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \      
778              ${run:-N} $results >> $SUMMARY      #  If we have the $FILES and they differ, copy the $FILES to $BUILD_DIR
779          echo "fresults='" > $CDIR"/summary.txt"      if test "x$have_files" = xt ; then
780          formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \          for i in $FILES ; do
781              ${run:-N} $results >> $CDIR"/summary.txt"              sstr="s|$endings||"
782          echo "'" >> $CDIR"/summary.txt"              name=`echo $i | sed -e $sstr `
783          echo "MACH='$MACH'" >> $CDIR"/summary.txt"              cmp $CODE_DIR/$i $BUILD_DIR/$name > /dev/null 2>&1
         echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"  
         echo "DATE='$DATE'" >> $CDIR"/summary.txt"  
         echo "tdir='$dir'" >> $CDIR"/summary.txt"  
   
         (  
             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  
784              RETVAL=$?              RETVAL=$?
785              if test "x$RETVAL" != x0 ; then              if test "x$RETVAL" != x0 ; then
786                  echo "Warning: \"$MPACK\" failed -- please contact <edhill@mitgcm.org>"                  cp $CODE_DIR/$i $BUILD_DIR/$name
             else  
                 rm -f $DRESULTS"/"$NDIR".tar*"  
787              fi              fi
788          fi          done
789        fi
790          NDIR=$(( $NDIR + 1 ))      
791                #  Create an output dir for each OPTFILE/tdir combination
792      done      rel_CDIR=$DRESULTS"/"$dir
793        mkdir $rel_CDIR
794        CDIR=`pwd`"/$rel_CDIR"
795        
796        if test "x$CLEANUP" = xt ; then
797            makeclean $dir/$builddir
798        else
799            genmakemodel $dir/$builddir && genmake=Y \
800                && makeclean $dir/$builddir \
801                && makedependmodel $dir/$builddir && makedepend=Y \
802                && makemodel $dir/$builddir && make=Y \
803                && linkdata $use_seperate_build $dir/$rundir \
804                && runmodel $dir/$rundir && run=Y \
805                && results=`testoutput $dir $rundir`
806        fi
807        
808        echo
809        if test "x$ADM" = x ; then
810            fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results`
811        else
812            fres=`printf '%s %s %s %s' ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N}`
813            fres=$fres"$results   $dir"
814        fi
815        echo
816        echo "$fres" >> $SUMMARY
817        echo "fresults='$fres'" > $CDIR"/summary.txt"
818        echo "MACH='$MACH'" >> $CDIR"/summary.txt"
819        echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"
820        echo "DATE='$DATE'" >> $CDIR"/summary.txt"
821        echo "tdir='$dir'" >> $CDIR"/summary.txt"
822        
823        echo "-------------------------------------------------------------------------------"
824        
825  done  done
826    
827  rm tmp_cmpnum.f a.out  echo -n "Start time:  " >> $SUMMARY
828    echo $start_date >> $SUMMARY
829    echo -n "End time:    " >> $SUMMARY
830    date >> $SUMMARY
831    
832    #  If addresses were supplied and mpack built successfully, then try
833    #  to send email using mpack.
834    if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then
835        echo "No results email was sent."
836    else
837        if test "x$HAVE_MPACK" = xt ; then
838            tar -cf $DRESULTS".tar" $DRESULTS > /dev/null 2>&1 \
839                && gzip $DRESULTS".tar" \
840                && $MPACK -s MITgcm-test -m 1500000 $DRESULTS".tar.gz" $ADDRESSES
841            RETVAL=$?
842            if test "x$RETVAL" != x0 ; then
843                echo
844                echo "Warning: The tar, gzip, & mpack step failed.  Please send email"
845                echo "  to <MITgcm-support@mitgcm.org> for help.  You may copy the "
846                echo "  summary of results from the directory \"$DRESULTS\"."
847                echo
848            else
849                echo
850                echo "An email containing results was sent to the following addresses:"
851                echo "  \"$ADDRESSES\""
852                echo
853            fi
854            test -f $DRESULTS".tar"  &&  rm -f $DRESULTS".tar"
855            test -f $DRESULTS".tar.gz"  &&  rm -f $DRESULTS".tar.gz"
856        fi
857    fi
858    
859    # rm -f tmp_cmpnum.f a.out
860    rm -f tmp_cmpnum.c tmp_cmpnum
861    
862  cat $SUMMARY  if test "x$CLEANUP" != xt ; then
863        cat $SUMMARY
864        if test -e tr_out.txt ; then
865            mv tr_out.txt tr_out.txt.old
866        fi
867        cat $SUMMARY > tr_out.txt
868    fi
869    

Legend:
Removed from v.1.9.2.2  
changed lines
  Added in v.1.26

  ViewVC Help
Powered by ViewVC 1.1.22