/[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.2 by edhill, Mon Sep 1 16:50:27 2003 UTC revision 1.25 by edhill, Thu Dec 4 16:36:18 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 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 "  (-a|-addr)STRING         list of email recipients"      echo "  (-ieee|-noieee)          if possible, use IEEE compiler flags"
16      echo "  (-t|-tdir)STRING         list of \"test\" dirs"      echo "                             (DEF=\"noieee\")"
17        echo "  (-optfile=|-of=)STRING   list of optfiles to use"
18        echo "  (-a|-addr) STRING        list of email recipients"
19        echo "                             (DEF=\"edhill@mitgcm.org\")"
20        echo "  (-t|-tdir) STRING        list of test dirs to use"
21        echo "                             (DEF=\"\" which builds all)"
22        echo "  (-b|-bash) STRING        preferred location of a \"bash\" or"
23        echo "                             Bourne-compatible \"sh\" shell"
24        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\")"
28        echo "  (-m|-make) STRING        command to use for \"make\""
29        echo "                             (DEF=\"make\")"
30        echo "  (-clean)                 *ONLY* run \"make CLEAN\""
31        echo "  (-quick|-q)              same as \"-nogenmake -noclean -nodepend\""
32        echo "  (-nogenmake|-ng)         skip the genmake stage"
33        echo "  (-noclean|-nc)           skip the \"make clean\" stage"
34        echo "  (-nodepend|-nd)          skip the \"make depend\" stage"
35        echo
36        echo "and where STRING follows a whitespace-delimited format"
37        echo "such as:"
38        echo "  -t 'exp0 exp2 exp3' "
39        echo "  -addr='abc@123.com testing@home.org'"
40      echo      echo
41      exit 1      exit 1
42  }  }
# Line 23  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          ( cd $MPACKDIR && ./configure && $MAKE ) > tr_build_mpack.out 2>&1
59          RETVAL=$?          RETVAL=$?
60          if test "x$RETVAL" != x0 ; then          if test "x$RETVAL" != x0 ; then
61              echo              echo
62              echo "Error building the mpack tools at: $MPACK_DIR"              echo "Error building the mpack tools at: $MPACK_DIR"
63              exit 1              echo
64                HAVE_MPACK=f
65            else
66                rm -f tr_build_mpack.out
67                HAVE_MPACK=t
68          fi          fi
69        else
70            HAVE_MPACK=t
71      fi      fi
72      echo "OK"      echo "OK"
73  }  }
74    
 compare_lines()  
 {  
     # use codelet to compare lines  
     if [ $verbose -gt 1 ]; then  
         cat tmp3.txt 1>&2  
     fi  
     return `./a.out < tmp3.txt`  
 }  
   
75  testoutput_for_prop()  testoutput_for_prop()
76  {  {
77      # testoutput_for_prop dir s1 label subdir      # testoutput_for_prop dir s1 label subdir
# Line 60  testoutput_for_prop() Line 83  testoutput_for_prop()
83          echo testoutput_for_prop: grep "$2" $1/$4/output.txt 1>&2          echo testoutput_for_prop: grep "$2" $1/$4/output.txt 1>&2
84      fi      fi
85      if [ -r $1/$4/output.txt ]; then      if [ -r $1/$4/output.txt ]; then
86          grep "$2" $1/$4/output.txt | sed 's/.*=//' | nl > tmp1.txt          grep "$2" $1/$4/output.txt | sed 's/.*=//' | cat -n > tmp1.txt
87          lncnt=`wc -l tmp1.txt | awk '{print $1}' `          lncnt=`wc -l tmp1.txt | awk '{print $1}' `
88          if [ $lncnt -lt 3 ]; then          if [ $lncnt -lt 3 ]; then
89              if [ $verbose -gt 0 ]; then              if [ $verbose -gt 0 ]; then
# Line 75  testoutput_for_prop() Line 98  testoutput_for_prop()
98      if [ $debug -gt 0 ]; then      if [ $debug -gt 0 ]; then
99          echo testoutput_for_prop: grep "$2" $1/results/output.txt 1>&2          echo testoutput_for_prop: grep "$2" $1/results/output.txt 1>&2
100      fi      fi
101      grep "$2" $1/results/output.txt | sed 's/.*=//' | nl > tmp2.txt      grep "$2" $1/results/output.txt | sed 's/.*=//' | cat -n > tmp2.txt
102      lncnt=`wc -l tmp2.txt | awk '{print $1}' `      lncnt=`wc -l tmp2.txt | awk '{print $1}' `
103      if [ $lncnt -lt 3 ]; then      if [ $lncnt -lt 3 ]; then
104          if [ $verbose -gt 0 ]; then          if [ $verbose -gt 0 ]; then
# Line 90  testoutput_for_prop() Line 113  testoutput_for_prop()
113      if [ $debug -gt 0 ]; then      if [ $debug -gt 0 ]; then
114          echo testoutput_for_prop: compare_lines 1>&2          echo testoutput_for_prop: compare_lines 1>&2
115      fi      fi
116      compare_lines      if [ $verbose -gt 1 ]; then
117      digits_of_similarity=$?          cat tmp3.txt 1>&2
118        fi
119        echo "-1" >> tmp3.txt
120        # On the SGI O3K (*not* the O2K), "cat -n" inserts a ":" after the line number
121        cat tmp3.txt | sed -e 's|:||g' > tmp4.txt
122        digits_of_similarity=`./tmp_cmpnum < tmp4.txt`
123      if [ $digits_of_similarity -eq 99 ]; then      if [ $digits_of_similarity -eq 99 ]; then
124          if [ $verbose -gt 0 ]; then          if [ $verbose -gt 0 ]; then
125              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 102  testoutput_for_prop() Line 130  testoutput_for_prop()
130              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
131          fi          fi
132      fi      fi
133      rm tmp1.txt tmp2.txt tmp3.txt      rm -f tmp1.txt tmp2.txt tmp3.txt tmp4.txt
134            
135      return $digits_of_similarity      return $digits_of_similarity
136  }  }
# Line 122  dashnum() Line 150  dashnum()
150      done      done
151  }  }
152    
153    testoutput_ad()
154    {
155        grep $3 $1/results_ad/output.txt_adm | awk '{print NR " " $5}' > t05.txt
156        grep $3 $1/$2/output.txt_adm | awk '{print NR " " $5}' > t15.txt
157        grep $3 $1/results_ad/output.txt_adm | awk '{print NR " " $6}' > t06.txt
158        grep $3 $1/$2/output.txt_adm | awk '{print NR " " $6}' > t16.txt
159        join t05.txt t15.txt > t5.txt
160        join t06.txt t16.txt > t6.txt
161        echo "-1" >> t5.txt
162        echo "-1" >> t6.txt
163        digits_5=`./tmp_cmpnum < t5.txt`
164        digits_6=`./tmp_cmpnum < t6.txt`
165        dashnum $digits_5 $digits_6
166        rm -f t[01][56].txt t[56].txt
167    }
168    
169  testoutput()  testoutput()
170  {  {
171      # testoutput diretory subdir      # testoutput directory subdir
172      #      #
173      #  test output in "directory"      #  test output in "directory"
174        if test "x$ADM" = x ; then
175      if [ $debug -gt 0 ]; then          if [ $debug -gt 0 ]; then
176          echo testoutput: testoutput_for_prop $1 cg2d_init_res 1>&2              echo testoutput: testoutput_for_prop $1 cg2d_init_res 1>&2
177      fi          fi
178      testoutput_for_prop $1 "cg2d_init_res" "cg2d init. residual" $2; cg2dres=$?          testoutput_for_prop $1 "cg2d_init_res" "cg2d init. residual" $2; cg2dres=$?
179      if [ $debug -gt 0 ]; then          if [ $debug -gt 0 ]; then
180          echo testoutput: cg2dres=$cg2dres 1>&2              echo testoutput: cg2dres=$cg2dres 1>&2
181            fi
182            testoutput_for_prop $1 "dynstat_theta_min" "theta minimum" $2; tmin=$?
183            testoutput_for_prop $1 "dynstat_theta_max" "theta maximum" $2; tmax=$?
184            testoutput_for_prop $1 "dynstat_theta_mean" "theta mean" $2; tmean=$?
185            testoutput_for_prop $1 "dynstat_theta_sd" "theta s.d." $2; tsd=$?
186            testoutput_for_prop $1 "dynstat_salt_min" "salt minimum" $2; smin=$?
187            testoutput_for_prop $1 "dynstat_salt_max" "salt maximum" $2; smax=$?
188            testoutput_for_prop $1 "dynstat_salt_mean" "salt mean" $2; smean=$?
189            testoutput_for_prop $1 "dynstat_salt_sd" "salt s.d." $2; ssd=$?
190            testoutput_for_prop $1 "dynstat_uvel_min" "U minimum" $2; umin=$?
191            testoutput_for_prop $1 "dynstat_uvel_max" "U maximum" $2; umax=$?
192            testoutput_for_prop $1 "dynstat_uvel_mean" "U mean" $2; umean=$?
193            testoutput_for_prop $1 "dynstat_uvel_sd" "U s.d." $2; usd=$?
194            testoutput_for_prop $1 "dynstat_vvel_min" "V minimum" $2; vmin=$?
195            testoutput_for_prop $1 "dynstat_vvel_max" "V maximum" $2; vmax=$?
196            testoutput_for_prop $1 "dynstat_vvel_mean" "V mean" $2; vmean=$?
197            testoutput_for_prop $1 "dynstat_vvel_sd" "V s.d." $2; vsd=$?
198            dashnum $cg2dres $tmin $tmax $tmean $tsd $smin $smax $smean $ssd \
199                $umin $umax $umean $usd $vmin $vmax $vmean $vsd
200        else
201            testoutput_ad $1 $2 "precision_grdchk_result"
202      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  
203  }  }
204    
205  genmakemodel()  genmakemodel()
206  {  {
207      # genmakemodel directory      # genmakemodel directory
208      GENMAKE2="../../../tools/genmake2"      if test "x$NOGENMAKE" = xt ; then
209      (          echo "genmake skipped!"
210          cd $1;      else
211          printf 'genmake ... ' 1>&2          GENMAKE2="$BASH ../../../tools/genmake2"
212          # ../../../tools/genmake -ieee -mods=../code > make.log 2>&1          (
213          $GENMAKE2  -ds --mods=../code "--optfile="$OPTFILE > make.log 2>&1              cd $1;
214          RETVAL=$?              command="$GENMAKE2  -ds -m $MAKE"
215          for i in gm_state gm_optfile gm_local Makefile ; do              if test "x$ADM" = x ; then
216              if test -r $i ; then                  command="$command --mods=../code"
217                  cp $i $CDIR              else
218                    command="$command --mods=../code_ad"
219                    command="$command -adof=../../../tools/adjoint_options/adjoint_staf"
220              fi              fi
221          done              if test "x$OPTFILE" != xNONE ; then
222          if test "x$RETVAL" != x0 ; then                  command="$command --optfile=$OPTFILE"
223              tail make.log              fi
224              echo "genmakemodel: genmake failed" 1>&2              if test "x$IEEE" != x ; then
225              cp make.log $CDIR                  command="$command -ieee"
226              return 1              fi
227          else              printf 'genmake ... ' 1>&2
228              echo "succesful" 1>&2              $command > make.log 2>&1
229          fi              RETVAL=$?
230      )              cp Makefile $CDIR
231                if test "x$RETVAL" != x0 ; then
232                    tail make.log
233                    echo "genmakemodel: genmake failed" 1>&2
234                    cp genmake_* make.log $CDIR
235                    return 1
236                else
237                    echo "successful" 1>&2
238                fi
239            )
240        fi
241  }  }
242    
243  makeclean()  makeclean()
244  {  {
245      # makeclean directory      # makeclean directory
246      (      if test "x$NOCLEAN" = xt ; then
247          cd $1;          echo "make CLEAN skipped!"
248          rm -f output.txt      else
249          printf 'make CLEAN ... ' 2>&1          (
250          if test -r Makefile ; then              cd $1;
251              make CLEAN >> make.log 2>&1              if test -e output.txt ; then
252              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  
253              fi              fi
254          fi              printf 'make CLEAN ... ' 2>&1
255          echo succesful 1>&2              if test -r Makefile ; then
256          exit 0                  $MAKE CLEAN >> make.log 2>&1
257      )                  RETVAL=$?
258                    if test "x$RETVAL" != x0 ; then
259                        tail make.log
260                        echo "makeclean: \"make CLEAN\" failed" 1>&2
261                        cp make.log $CDIR"/make.log"
262                        return 1
263                    fi
264                fi
265                echo successful 1>&2
266                exit 0
267            )
268        fi
269  }  }
270    
271  makedependmodel()  makedependmodel()
272  {  {
273      # makedependmodel directory      # makedependmodel directory
274      (      if test "x$NODEPEND" = xt ; then
275          cd $1;          echo "make depend skipped!"
276          printf 'make depend ... ' 1>&2      else
277          make depend >> make.log 2>&1          (
278          RETVAL=$?              cd $1;
279          if test "x$RETVAL" != x0 ; then              printf 'make depend ... ' 1>&2
280              tail make.log              $MAKE depend >> make.log 2>&1
281              echo "makedependmodel: make depend failed" 1>&2              RETVAL=$?
282              cp make.log $CDIR"/make.log"              if test "x$RETVAL" != x0 ; then
283              return 1                  tail make.log
284          else                  echo "makedependmodel: make depend failed" 1>&2
285              echo succesful 1>&2                  cp make.log $CDIR"/make.log"
286          fi                  return 1
287      )              else
288                    echo successful 1>&2
289                fi
290            )
291        fi
292  }  }
293    
294  makemodel()  makemodel()
# Line 231  makemodel() Line 298  makemodel()
298          cd $1;          cd $1;
299          if test -r Makefile ; then          if test -r Makefile ; then
300              printf 'make ... ' 1>&2              printf 'make ... ' 1>&2
301              make >> make.log 2>&1              if test "x$ADM" = x ; then
302                    $MAKE >> make.log 2>&1
303                else
304                    $MAKE adall >> make.log 2>&1
305                fi
306              RETVAL=$?              RETVAL=$?
307              if test "x$RETVAL" != x0 ; then              if test "x$RETVAL" != x0 ; then
308                  tail make.log                  tail make.log
# Line 239  makemodel() Line 310  makemodel()
310                  cp make.log $CDIR"/make.log"                  cp make.log $CDIR"/make.log"
311                  return 1                  return 1
312              else              else
313                  echo succesful 1>&2                  echo successful 1>&2
314              fi              fi
315          fi          fi
316      )      )
# Line 250  linkdata() Line 321  linkdata()
321      # linkdata flag      # linkdata flag
322      #      #
323      # symbolically link data files to run directory      # symbolically link data files to run directory
324      if [ $1 -ne 0 ]; then      if test "x$1" = x1 ; then
325          ( cd $2 ;  ln -sf ../input/* . )          (
326                cd $2
327                if test "x$ADM" = x ; then
328                    files=`( cd ../input ; ls -1 | grep -v CVS )`
329                    for i in $files ; do
330                        if test ! -d "../input/"$i ; then
331                            ln -sf "../input/"$i $i
332                        fi
333                    done
334                else
335                    files=`( cd ../input ; ls -1 *.bin | grep -v CVS )`
336                    for i in $files ; do
337                        if test ! -d "../input/"$i ; then
338                            ln -sf "../input/"$i $i
339                        fi
340                    done
341                    files=`( cd ../input_ad ; ls -1 | grep -v CVS )`
342                    for i in $files ; do
343                        if test ! -d "../input_ad/"$i ; then
344                            ln -sf "../input_ad/"$i $i
345                        fi
346                    done
347                fi
348            )
349      fi      fi
350  }  }
351    
352  runmodel()  runmodel()
353  {  {
354      # runmodel directory exe      # runmodel directory
355      #      #
356      #  runs the model "exe" in "directory" (exe is relative to directory)      #  runs "$COMMAND in "directory"
357        #  (where "$COMMAND" is relative to "directory")
358      (      (
359          cd $1          cd $1
360          if [ -x $2 ]; then          printf 'runmodel ... ' 1>&2
361              if [ $quick -eq 0 ]; then          # make output.txt
362                  rm -f output.txt          $COMMAND >> run.log 2>&1
363              fi          RETVAL=$?
364              printf 'runmodel: ' 1>&2          if test "x$RETVAL" = x0 ; then
365              make output.txt              echo successful 1>&2
366              RETVAL=$?              if test "x$ADM" = x ; then
             if test "x$RETVAL" = x0 ; then  
367                  cp output.txt $CDIR"/output.txt"                  cp output.txt $CDIR"/output.txt"
                 return 0  
368              else              else
369                  return 1                  cp output.txt_adm $CDIR"/output.txt_adm"
370              fi              fi
371                return 0
372            else
373                tail run.log
374                echo failed 1>&2
375                cp run.log $CDIR"/run.log"
376                return 1
377          fi          fi
378      )      )
379  }  }
# Line 284  createcodelet() Line 383  createcodelet()
383      # create codelet for comparing model output      # create codelet for comparing model output
384    
385      echo -n "creating the comparison code...  "      echo -n "creating the comparison code...  "
386      cat > tmp_cmpnum.f <<EOFA      cat > tmp_cmpnum.c <<EOF
387        program cmpnum  #include <stdio.h>
388        implicit none  #include <math.h>
389        real*8 a,b,diff  int main( int argc, char** argv )  {
390        integer linnum,best    int linnum,best;
391        best=-16    double a,b,diff;
392    99  read(*,*,end=70,err=60) linnum,a,b    best = -16;
393        diff=0.5*(abs(a)+abs(b))    while( 1 )  {
394  c     print *,a,b,diff,abs(a-b)/diff      scanf("%d", &linnum);
395        if (diff.gt.1.e-12) then      if (linnum == -1)  break;
396          diff=abs(a-b)/diff      scanf("%lf", &a);  scanf("%lf", &b);
397          if (diff.gt.0.) then      diff = 0.5*(fabs(a)+fabs(b));
398  c         print *,int(log10(diff)),diff      if (diff > 1.e-12) {
399            linnum=int(log10(diff))        diff=fabs(a-b)/diff;
400            best=max(best,linnum)        if (diff > 0.0) {
401          endif          linnum = (int)log10(diff);
402        else          best = (best > linnum) ? best : linnum;
403          if (best.eq.-16.and.diff.ne.0.) best=-22        }
404        endif        else {
405        goto 99          if (best == -16 && diff != 0)  best = -22;
406    60  stop 'cmpnum: An error occured reading a,b'        }
407    70  print *,-best      }
408        end    }
409  EOFA    printf("%d\n", -best);
410      return 0;
411    }
412    EOF
413        cc -o tmp_cmpnum tmp_cmpnum.c -lm
414    
415      f77 tmp_cmpnum.f      if [ -x ./tmp_cmpnum ]; then
     if [ -x ./a.out ]; then  
416          echo "OK"          echo "OK"
417          return 0          return 0
418      else      else
419          echo          echo
420          echo "createcodelet: failed to compile codelet" | tee          echo "ERROR: failed to compile comparison code"
421          exit 1          exit 1
422      fi      fi
423  }  }
# Line 347  show_help() Line 449  show_help()
449  {  {
450      cat - << EOF      cat - << EOF
451  $0 [-help] [-quick] [-verbose] dir1 [dir2] [...]  $0 [-help] [-quick] [-verbose] dir1 [dir2] [...]
452   -help      Show this help message  
453   -quick     Skip "genmake" and "make depend" if the Makefile exists   -help|-h      Show this help message
454   -quiet     Reduce the amount of output   -quiet     Reduce the amount of output
455   -verbose   Produce copious amounts of output   -verbose   Produce copious amounts of output
456   -debug     Produce even more output which will mean nothing to most   -debug     Produce even more output which will mean nothing to most
457   -force     Do "make CLEAN" before compiling. This forces a complete rebuild.   -force     Do "make CLEAN" before compiling. This forces a complete rebuild.
458   -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.  
459   -cleanup   Aggresively removes all model output, executables and object files   -cleanup   Aggresively removes all model output, executables and object files
460              and then exits. Use with care.              and then exits. Use with care.
461    
# Line 376  scandirs() Line 477  scandirs()
477    
478    
479  ###############################################################################  ###############################################################################
 ###############################################################################  
 ###############################################################################  
480    
481    
482  #  Default properties  #  Default properties
483  debug=0  debug=0
484  verbose=1  verbose=1
 quick=0  
485  clean=0  clean=0
 ieee=1  
486  expts=''  expts=''
487    # ieee=1
488    
489    IEEE=
490    if test "x$MITGCM_IEEE" != x ; then
491        IEEE=$MITGCM_IEEE
492    fi
493    
494  OPTFILES=  
495  ADDRESSES=edhill@mitgcm.org  CLEANUP=f
496    QUICK=f
497    NOGENMAKE=f
498    NOCLEAN=f
499    NODEPEND=f
500    
501    BASH=
502    OPTFILE=NONE
503    ADDRESSES=
504  TESTDIRS=  TESTDIRS=
505  MPACKDIR="../tools/mpack-1.6"  MPACKDIR="../tools/mpack-1.6"
506    HAVE_MPACK=
507  MPACK="$MPACKDIR/mpack"  MPACK="$MPACKDIR/mpack"
508    COMMAND=
509    MAKE=make
510    MPI=f
511    
512    ADM=
513    
514  echo -n "parsing options...  "  echo -n "parsing options...  "
515    
# Line 414  for ac_option ; do Line 531  for ac_option ; do
531              usage ;;              usage ;;
532                    
533          -optfile | --optfile | -of | --of)          -optfile | --optfile | -of | --of)
534              ac_prev=OPTFILES ;;              ac_prev=OPTFILE ;;
535          -optfile=* | --optfile=* | -of=* | --of=*)          -optfile=* | --optfile=* | -of=* | --of=*)
536              OPTFILES=$ac_optarg ;;              OPTFILE=$ac_optarg ;;
537                    
538          -addr | --addr | -a | --a)          -addr | --addr | -a | --a)
539              ac_prev=ADDRESSES ;;              ac_prev=ADDRESSES ;;
# Line 428  for ac_option ; do Line 545  for ac_option ; do
545          -tdir=* | --tdir=*)          -tdir=* | --tdir=*)
546              TESTDIRS=$ac_optarg ;;              TESTDIRS=$ac_optarg ;;
547    
548          -quick) quick=1 ;;          -bash | --bash | -b | --b)
549                ac_prev=BASH ;;
550            -bash=* | --bash=*)
551                BASH=$ac_optarg ;;
552    
553            -command | --command | -c | --c)
554                ac_prev=COMMAND ;;
555            -command=* | --command=*)
556                COMMAND=$ac_optarg ;;
557    
558            -make | --make | -m | --m)
559                ac_prev=MAKE ;;
560            -make=* | --make=*)
561                MAKE=$ac_optarg ;;
562    
563            -clean | --clean)
564                CLEANUP=t ;;
565    
566            -quick | --quick | -q | --q)
567                QUICK=t ;;
568            -nogenmake | --nogenmake | -ng | --ng)
569                NOGENMAKE=t ;;
570            -noclean | --noclean | -nc | --nc)
571                NOCLEAN=t ;;
572            -nodepend | --nodepend | -nd | --nd)
573                NODEPEND=t ;;
574    
575            -mpi) MPI=t ;;
576    
577            -adm | -ad) ADM=t ;;
578    
579            -ieee) IEEE=true ;;
580            -noieee) IEEE= ;;
581    
582          -verbose) verbose=2 ;;          -verbose) verbose=2 ;;
583          -debug) debug=1 ;;          -debug) debug=1 ;;
         -clean) clean=1 ;;  
         -noieee) ieee=0 ;;  
584          -quiet) verbose=0 ;;          -quiet) verbose=0 ;;
585    
586          -*)          -*)
# Line 449  for ac_option ; do Line 597  for ac_option ; do
597            
598  done  done
599    
600    if test "x$QUICK" = xt ; then
601        NOGENMAKE=t
602        NOCLEAN=t
603        NODEPEND=t
604    fi
605    
606  if test "x$TESTDIRS" = x ; then  if test "x$TESTDIRS" = x ; then
607      TESTDIRS=`scandirs`      TESTDIRS=`scandirs`
608  fi  fi
609    
610    if test "x$OPTFILE" = xNONE -a "x$MITGCM_OF" != x ; then
611        OPTFILE=$MITGCM_OF
612    fi
613    
614    if test "x$ADM" = xt -a "x$COMMAND" = x ; then
615        COMMAND="./mitgcmuv_ad > output.txt_adm 2>&1"
616    fi
617    
618    if test "x$COMMAND" = x ; then
619        COMMAND="make output.txt"
620    fi
621    
622  echo "OK"  echo "OK"
623    
624  #  create the FORTRAN comparison code  #  create the FORTRAN comparison code
# Line 465  build_mpack Line 631  build_mpack
631  MACH=`hostname`  MACH=`hostname`
632  UNAMEA=`uname -a`  UNAMEA=`uname -a`
633  DATE=`date +%Y%m%d`  DATE=`date +%Y%m%d`
634  BASE=$MACH"_"$DATE"_"  BASE="tr_"$MACH"_"$DATE"_"
635  DNUM=0  DNUM=0
636  DRESULTS="$BASE$DNUM"  DRESULTS="$BASE$DNUM"
637  while test -e $DRESULTS ; do  while test -e $DRESULTS ; do
# Line 475  done Line 641  done
641  mkdir $DRESULTS  mkdir $DRESULTS
642  RETVAL=$?  RETVAL=$?
643  if test "x$RETVAL" != x0 ; then  if test "x$RETVAL" != x0 ; then
644      echo "Error: can't create results directory \"./$DRESULTS\""      echo "ERROR: Can't create results directory \"./$DRESULTS\""
645      exit 1      exit 1
646  fi  fi
647  SUMMARY="$DRESULTS/summary.txt"  SUMMARY="$DRESULTS/summary.txt"
648  date > $SUMMARY  echo -n "Start time:  " >> $SUMMARY
649  cat << EOF >> $SUMMARY  start_date=`date`
650    echo $start_date > $SUMMARY
651    
652    of_path=
653    if test "x$OPTFILE" != xNONE ; then
654        if test -r $OPTFILE ; then
655            # get the path
656            path=${OPTFILE%/*}
657            if test "x$path" = x ; then
658                of_path=`pwd`
659            else
660                of_path=`( cd $path > /dev/null 2>&1 ; pwd )`
661            fi
662            file=${OPTFILE##*/}
663            OPTFILE=$of_path/$file
664            cp $OPTFILE $DRESULTS
665            echo >> $SUMMARY
666            echo "  OPTFILE=$OPTFILE" >> $SUMMARY
667        else
668            echo | tee $SUMMARY
669            echo "ERROR: can't read OPTFILE=\"$OPTFILE\"" | tee $SUMMARY
670            exit 1
671        fi
672    else
673        echo >> $SUMMARY
674        echo "No \"OPTFILE\" was explicitly specified by testreport," >> $SUMMARY
675        echo "   so the genmake default will be used." >> $SUMMARY
676    fi
677    echo
678    echo >> $SUMMARY
679    if test "x$ADM" = x ; then
680        cat << EOF | tee -a $SUMMARY
681                  T           S           U           V                  T           S           U           V
682  G D M    c        m  s        m  s        m  s        m  s  G D M    c        m  s        m  s        m  s        m  s
683  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 488  N n k u  2  i  a  a  d  i  a  a  d  i  a Line 685  N n k u  2  i  a  a  d  i  a  a  d  i  a
685  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  .
686    
687  EOF  EOF
688    else
689        echo "ADJOINT=true" >> $SUMMARY
690        echo >> $SUMMARY
691        cat << EOF | tee -a $SUMMARY
692    G D M    C  G
693    E p a R  o  r
694    N n k u  s  a
695    2 d e n  t  d
696    
697  NDIR=0  EOF
698    fi
 #  For each optfile...  
 for OPTFILE in $OPTFILES ; do  
699    
700      OPTFILE=`pwd`"/$OPTFILE"  #  ...and each test directory...
701      if test ! -r $OPTFILE ; then  for dir in $TESTDIRS ; do
         echo "Error: can't read optfile \"$OPTFILE\""  
         exit 1  
     fi  
     echo  
     echo "OPTFILE=$OPTFILE" >> $SUMMARY  
     echo >> $SUMMARY  
702            
703      #  ...and each test directory...      #  Cleanup only!
704      for dir in $TESTDIRS ; do      if test "x$CLEANUP" = xt ; then
705                    if test -r $dir/build/Makefile ; then
706          #  Create an output dir for each OPTFILE/tdir combination              ( cd $dir/build ; make CLEAN )
707          CDIR=$DRESULTS"/"$DRESULTS"_"$NDIR          fi
708          mkdir $CDIR          if test -r $dir/input/Makefile ; then
709          CDIR=`pwd`"/$CDIR"              ( cd $dir/input ; make CLEAN )
710            fi
711            continue
712        fi
713    
714        #  Verify that the testdir exists and contains previous
715        #  results in the correct location--or skip this directory!
716        fout=
717        if test "x$ADM" = x ; then
718            fout=$dir"/results/output.txt"
719        else
720            fout=$dir"/results_ad/output.txt_adm"
721        fi
722        if test ! -r $fout ; then
723            echo "can't read \"$fout\" -- skipping $dir"
724            continue
725        fi
726    
727          #  ...configue, make, run, and compare the output.      echo "-------------------------------------------------------------------------------"
728          echo "-------------------------------------------------------------------------------"      echo
729          echo      echo "Experiment:  $dir"
730          echo "Experiment:  $dir"      echo
731          echo      unset genmake makedepend make run
732          unset genmake makedepend make run      results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --'
         results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --'  
         ( cd $dir/input; rm -f *.{o,f,c,F} *.[f,F]90 work* output.txt Make* make.log; )  
         if [ -r $dir/build ]; then  
             seperatebuilddir=1  
             builddir=build  
             rundir=build  
             ( cd $dir/build; ln -sf ../input/* . )  
         else  
             seperatebuilddir=0  
             builddir=input  
             rundir=input  
         fi  
733    
734          #  Verify that the testdir exists and contains previous      builddir="input"
735          #  results in the correct location--or skip this directory!      rundir="input"
736          if test ! -r $dir"/results/output.txt" ; then      use_seperate_build=0
737              echo | tee $SUMMARY      if test -d $dir/build -a -r $dir/build ; then
738              echo "can't read \"$dir/results/output.txt\" -- skipping $dir" \          builddir="build"
739                  | tee $SUMMARY          rundir="build"
740              continue          use_seperate_build=1
741            linkdata $use_seperate_build $dir/$rundir
742        fi
743        
744        if test "x$ADM" = x ; then
745            CODE_DIR=$dir/code
746        else
747            CODE_DIR=$dir/code_ad
748        fi
749        BUILD_DIR=$dir/$builddir
750        MPI_FILES="CPP_EEOPTIONS.h_mpi SIZE.h_mpi"
751        NOMPI_FILES="CPP_EEOPTIONS.h_nompi SIZE.h_nompi"
752    
753        #  Is this an MPI run?
754        if test "x$MPI" = xt ; then
755            FILES=$MPI_FILES
756            endings="_mpi"
757        else
758            FILES=$NOMPI_FILES
759            endings="_nompi"
760        fi
761        
762        #  Check to see that we have the files
763        have_files=t
764        for i in $FILES ; do
765            if test ! -r $CODE_DIR/$i ; then
766                echo "Warning: can't read file $CODE_DIR/$i"
767                have_files=f
768          fi          fi
769        done
770        if test "x$have_files" != xt -a "x$MPI" = xt ; then
771            echo "Skipping $dir due to lack of input files (see above warning)"
772            continue
773        fi
774        
775        #  If we have the $FILES and they differ, copy the $FILES to $BUILD_DIR
776        if test "x$have_files" = xt ; then
777            for i in $FILES ; do
778                sstr="s|$endings||"
779                name=`echo $i | sed -e $sstr `
780                cmp $CODE_DIR/$i $BUILD_DIR/$name > /dev/null 2>&1
781                RETVAL=$?
782                if test "x$RETVAL" != x0 ; then
783                    cp $CODE_DIR/$i $BUILD_DIR/$name
784                fi
785            done
786        fi
787        
788        #  Create an output dir for each OPTFILE/tdir combination
789        rel_CDIR=$DRESULTS"/"$dir
790        mkdir $rel_CDIR
791        CDIR=`pwd`"/$rel_CDIR"
792        
793        if test "x$CLEANUP" = xt ; then
794            makeclean $dir/$builddir
795        else
796          genmakemodel $dir/$builddir && genmake=Y \          genmakemodel $dir/$builddir && genmake=Y \
797              && makeclean $dir/$builddir \              && makeclean $dir/$builddir \
798              && makedependmodel $dir/$builddir && makedepend=Y \              && makedependmodel $dir/$builddir && makedepend=Y \
799              && makemodel $dir/$builddir && make=Y \              && makemodel $dir/$builddir && make=Y \
800              && linkdata $seperatebuilddir $dir/$rundir \              && linkdata $use_seperate_build $dir/$rundir \
801              && runmodel $dir/$builddir mitgcmuv && run=Y \              && runmodel $dir/$rundir && run=Y \
802              && results=`testoutput $dir $rundir`              && results=`testoutput $dir $rundir`
803          echo      fi
804          formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \      
805              ${run:-N} $results      echo
806          echo      if test "x$ADM" = x ; then
807          formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \          fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results`
808              ${run:-N} $results >> $SUMMARY      else
809          echo "fresults='" > $CDIR"/summary.txt"          fres=`printf '%s %s %s %s' ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N}`
810          formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \          fres=$fres"$results   $dir"
811              ${run:-N} $results >> $CDIR"/summary.txt"      fi
812          echo "'" >> $CDIR"/summary.txt"      echo
813          echo "MACH='$MACH'" >> $CDIR"/summary.txt"      echo "$fres" >> $SUMMARY
814          echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"      echo "fresults='$fres'" > $CDIR"/summary.txt"
815          echo "DATE='$DATE'" >> $CDIR"/summary.txt"      echo "MACH='$MACH'" >> $CDIR"/summary.txt"
816          echo "tdir='$dir'" >> $CDIR"/summary.txt"      echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"
817        echo "DATE='$DATE'" >> $CDIR"/summary.txt"
818          (      echo "tdir='$dir'" >> $CDIR"/summary.txt"
819              cd $DRESULTS      
820              tar -cf $NDIR".tar" $DRESULTS"_"$NDIR > /dev/null 2>&1      echo "-------------------------------------------------------------------------------"
821              gzip $NDIR".tar"      
822          )  done
823    
824          $MPACK -s MITgcm-test -m 1000000 $DRESULTS"/"$NDIR".tar.gz" $ADDRESSES  echo -n "Start time:  " >> $SUMMARY
825    echo $start_date >> $SUMMARY
826    echo -n "End time:    " >> $SUMMARY
827    date >> $SUMMARY
828    
829    #  If addresses were supplied and mpack built successfully, then try
830    #  to send email using mpack.
831    if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then
832        echo "No results email was sent."
833    else
834        if test "x$HAVE_MPACK" = xt ; then
835            tar -cf $DRESULTS".tar" $DRESULTS > /dev/null 2>&1 \
836                && gzip $DRESULTS".tar" \
837                && $MPACK -s MITgcm-test -m 1500000 $DRESULTS".tar.gz" $ADDRESSES
838          RETVAL=$?          RETVAL=$?
839          if test "x$RETVAL" != x0 ; then          if test "x$RETVAL" != x0 ; then
840              echo "Warning: \"$MPACK\" failed -- please contact <edhill@mitgcm.org>"              echo
841                echo "Warning: The tar, gzip, & mpack step failed.  Please send email"
842                echo "  to <MITgcm-support@mitgcm.org> for help.  You may copy the "
843                echo "  summary of results from the directory \"$DRESULTS\"."
844                echo
845          else          else
846              rm -f $DRESULTS"/"$NDIR".tar*"              echo
847                echo "An email containing results was sent to the following addresses:"
848                echo "  \"$ADDRESSES\""
849                echo
850          fi          fi
851            test -f $DRESULTS".tar"  &&  rm -f $DRESULTS".tar"
852            test -f $DRESULTS".tar.gz"  &&  rm -f $DRESULTS".tar.gz"
853        fi
854    fi
855    
856          NDIR=$(( $NDIR + 1 ))  # rm -f tmp_cmpnum.f a.out
857            rm -f tmp_cmpnum.c tmp_cmpnum
     done  
 done  
   
 rm tmp_cmpnum.f a.out  
858    
859  cat $SUMMARY  if test "x$CLEANUP" != xt ; then
860        cat $SUMMARY
861        if test -e tr_out.txt ; then
862            mv tr_out.txt tr_out.txt.old
863        fi
864        cat $SUMMARY > tr_out.txt
865    fi
866    

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

  ViewVC Help
Powered by ViewVC 1.1.22