/[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.3 by edhill, Tue Sep 2 21:06:21 2003 UTC revision 1.30 by edhill, Fri Dec 5 17:46:32 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          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 60  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 75  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 90  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 102  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 122  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()
209  {  {
210      # genmakemodel directory      # genmakemodel directory
211      GENMAKE2="../../../tools/genmake2"      if test "x$NOGENMAKE" = xt ; then
212      (          echo "genmake skipped!"
213          cd $1;      else
214          printf 'genmake ... ' 1>&2          GENMAKE2="$BASH ../../../tools/genmake2"
215          # ../../../tools/genmake -ieee -mods=../code > make.log 2>&1          (
216          $GENMAKE2  -ds --mods=../code "--optfile="$OPTFILE > make.log 2>&1              cd $1;
217          RETVAL=$?              command="$GENMAKE2  -ds -m $MAKE"
218          for i in gm_state gm_optfile gm_local Makefile ; do              if test "x$ADM" = x ; then
219              if test -r $i ; then                  command="$command --mods=../code"
220                  cp $i $CDIR              else
221                    command="$command --mods=../code_ad"
222                    command="$command -adof=../../../tools/adjoint_options/adjoint_staf"
223              fi              fi
224          done              if test "x$OPTFILE" != xNONE ; then
225          if test "x$RETVAL" != x0 ; then                  command="$command --optfile=$OPTFILE"
226              tail make.log              fi
227              echo "genmakemodel: genmake failed" 1>&2              if test "x$IEEE" != x ; then
228              cp make.log $CDIR                  command="$command -ieee"
229              return 1              fi
230          else              printf 'genmake ... ' 1>&2
231              echo "succesful" 1>&2              $command > make.log 2>&1
232          fi              RETVAL=$?
233      )              cp Makefile $CDIR
234                if test "x$RETVAL" != x0 ; then
235                    tail make.log
236                    echo "genmakemodel: genmake failed" 1>&2
237                    cp genmake_* make.log $CDIR
238                    return 1
239                else
240                    echo "successful" 1>&2
241                fi
242            )
243        fi
244  }  }
245    
246  makeclean()  makeclean()
247  {  {
248      # makeclean directory      # makeclean directory
249      (      if test "x$NOCLEAN" = xt ; then
250          cd $1;          echo "make CLEAN skipped!"
251          rm -f output.txt      else
252          printf 'make CLEAN ... ' 2>&1          (
253          if test -r Makefile ; then              cd $1;
254              make CLEAN >> make.log 2>&1              if test -e output.txt ; then
255              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  
256              fi              fi
257          fi              printf 'make CLEAN ... ' 2>&1
258          echo succesful 1>&2              if test -r Makefile ; then
259          exit 0                  $MAKE CLEAN >> make.log 2>&1
260      )                  RETVAL=$?
261                    if test "x$RETVAL" != x0 ; then
262                        tail make.log
263                        echo "makeclean: \"make CLEAN\" failed" 1>&2
264                        cp make.log $CDIR"/make.log"
265                        return 1
266                    fi
267                fi
268                echo successful 1>&2
269                exit 0
270            )
271        fi
272  }  }
273    
274  makedependmodel()  makedependmodel()
275  {  {
276      # makedependmodel directory      # makedependmodel directory
277      (      if test "x$NODEPEND" = xt ; then
278          cd $1;          echo "make depend skipped!"
279          printf 'make depend ... ' 1>&2      else
280          make depend >> make.log 2>&1          (
281          RETVAL=$?              cd $1;
282          if test "x$RETVAL" != x0 ; then              printf 'make depend ... ' 1>&2
283              tail make.log              $MAKE depend >> make.log 2>&1
284              echo "makedependmodel: make depend failed" 1>&2              RETVAL=$?
285              cp make.log $CDIR"/make.log"              if test "x$RETVAL" != x0 ; then
286              return 1                  tail make.log
287          else                  echo "makedependmodel: make depend failed" 1>&2
288              echo succesful 1>&2                  cp make.log $CDIR"/make.log"
289          fi                  return 1
290      )              else
291                    echo successful 1>&2
292                fi
293            )
294        fi
295  }  }
296    
297  makemodel()  makemodel()
# Line 231  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 239  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      )      )
320  }  }
321    
322    symlink_mpifiles()
323    {
324        # Put special links so that MPI specific files are used
325        # This MUST be invoked between makeclean and makelinks because
326        # the Makefile will link to non-mpi files by default
327    
328        dir=$1
329        code_dir=$2
330        BUILD_DIR=$dir/$3
331        CODE_DIR=$dir/$code_dir
332    
333        # These are files that should replace their counter-part when using -mpi
334        MPI_FILES=`(cd $CODE_DIR; find . -name "*_mpi")`
335    
336        #  Is this an MPI run?
337        if test "x$MPI" = xt ; then
338            # YES: We symbolically link these files to the build
339            # dir so long as there is no real file in place
340            for ii in $MPI_FILES ; do
341                i=`echo $ii | sed 's:^\./::'`
342                name=`echo $i | sed 's:_mpi::' `
343                cmp $CODE_DIR/$i $BUILD_DIR/$name > /dev/null 2>&1
344                RETVAL=$?
345                if test "x$RETVAL" != x0 ; then
346                    if ! test -f $BUILD_DIR/$i ; then
347                    #echo Linking $name to $i
348                        (cd $BUILD_DIR; ln -sf ../$code_dir/$i $name)
349                    fi
350                fi
351            done
352        else
353        # NO: We undo any _mpi symbolically linked files
354            for ii in $MPI_FILES ; do
355                i=`echo $ii | sed 's:^\./::'`
356                name=`echo $i | sed 's:_mpi::' `
357                if test -L $BUILD_DIR/$name ; then
358                    linktarg=`(cd $BUILD_DIR; readlink $name)`
359                    if test $linktarg = "../$code_dir/$name"_mpi ; then
360                    #echo Un-linking $name from $linktarg
361                        rm -f $BUILD_DIR/$name
362                    fi
363                fi
364            done
365        fi
366        
367    }
368    
369  linkdata()  linkdata()
370  {  {
371      # linkdata flag      # linkdata flag
372      #      #
373      # symbolically link data files to run directory      # symbolically link data files to run directory
374      if [ $1 -ne 0 ]; then      if test "x$1" = x1 ; then
375          ( cd $2 ;  ln -sf ../input/* . )          (
376                cd $2
377                if test "x$ADM" = x ; then
378                    files=`( cd ../input ; ls -1 | grep -v CVS )`
379                    for i in $files ; do
380                        if test ! -d "../input/"$i ; then
381                            ln -sf "../input/"$i $i
382                        fi
383                    done
384                else
385                    files=`( cd ../input ; ls -1 *.bin | grep -v CVS )`
386                    for i in $files ; do
387                        if test ! -d "../input/"$i ; then
388                            ln -sf "../input/"$i $i
389                        fi
390                    done
391                    files=`( cd ../input_ad ; ls -1 | grep -v CVS )`
392                    for i in $files ; do
393                        if test ! -d "../input_ad/"$i ; then
394                            ln -sf "../input_ad/"$i $i
395                        fi
396                    done
397                fi
398            )
399      fi      fi
400  }  }
401    
402  runmodel()  runmodel()
403  {  {
404      # runmodel directory exe      # runmodel directory
405      #      #
406      #  runs the model "exe" in "directory" (exe is relative to directory)      #  runs "$COMMAND in "directory"
407        #  (where "$COMMAND" is relative to "directory")
408      (      (
409          cd $1          cd $1
410          if [ -x $2 ]; then          printf 'runmodel ... ' 1>&2
411              if [ $quick -eq 0 ]; then          # make output.txt
412                  rm -f output.txt          $COMMAND >> run.log 2>&1
413              fi          RETVAL=$?
414              printf 'runmodel: ' 1>&2          if test "x$RETVAL" = x0 ; then
415              make output.txt              echo successful 1>&2
416              RETVAL=$?              if test "x$ADM" = x ; then
             if test "x$RETVAL" = x0 ; then  
417                  cp output.txt $CDIR"/output.txt"                  cp output.txt $CDIR"/output.txt"
                 return 0  
418              else              else
419                  return 1                  cp output.txt_adm $CDIR"/output.txt_adm"
420              fi              fi
421                return 0
422            else
423                tail run.log
424                echo failed 1>&2
425                cp run.log $CDIR"/run.log"
426                return 1
427          fi          fi
428      )      )
429  }  }
# Line 284  createcodelet() Line 433  createcodelet()
433      # create codelet for comparing model output      # create codelet for comparing model output
434    
435      echo -n "creating the comparison code...  "      echo -n "creating the comparison code...  "
436      cat > tmp_cmpnum.f <<EOFA      cat > tmp_cmpnum.c <<EOF
437        program cmpnum  #include <stdio.h>
438        implicit none  #include <math.h>
439        real*8 a,b,diff  int main( int argc, char** argv )  {
440        integer linnum,best    int linnum,best;
441        best=-16    double a,b,diff;
442    99  read(*,*,end=70,err=60) linnum,a,b    best = -16;
443        diff=0.5*(abs(a)+abs(b))    while( 1 )  {
444  c     print *,a,b,diff,abs(a-b)/diff      scanf("%d", &linnum);
445        if (diff.gt.1.e-12) then      if (linnum == -1)  break;
446          diff=abs(a-b)/diff      scanf("%lf", &a);  scanf("%lf", &b);
447          if (diff.gt.0.) then      diff = 0.5*(fabs(a)+fabs(b));
448  c         print *,int(log10(diff)),diff      if (diff > 1.e-12) {
449            linnum=int(log10(diff))        diff=fabs(a-b)/diff;
450            best=max(best,linnum)        if (diff > 0.0) {
451          endif          linnum = (int)log10(diff);
452        else          best = (best > linnum) ? best : linnum;
453          if (best.eq.-16.and.diff.ne.0.) best=-22        }
454        endif        else {
455        goto 99          if (best == -16 && diff != 0)  best = -22;
456    60  stop 'cmpnum: An error occured reading a,b'        }
457    70  print *,-best      }
458        end    }
459  EOFA    printf("%d\n", -best);
460      return 0;
461    }
462    EOF
463        cc -o tmp_cmpnum tmp_cmpnum.c -lm
464    
465      f77 tmp_cmpnum.f      if [ -x ./tmp_cmpnum ]; then
     if [ -x ./a.out ]; then  
466          echo "OK"          echo "OK"
467          return 0          return 0
468      else      else
469          echo          echo
470          echo "createcodelet: failed to compile codelet"          echo "ERROR: failed to compile comparison code"
471          exit 1          exit 1
472      fi      fi
473  }  }
# Line 347  show_help() Line 499  show_help()
499  {  {
500      cat - << EOF      cat - << EOF
501  $0 [-help] [-quick] [-verbose] dir1 [dir2] [...]  $0 [-help] [-quick] [-verbose] dir1 [dir2] [...]
502   -help      Show this help message  
503   -quick     Skip "genmake" and "make depend" if the Makefile exists   -help|-h      Show this help message
504   -quiet     Reduce the amount of output   -quiet     Reduce the amount of output
505   -verbose   Produce copious amounts of output   -verbose   Produce copious amounts of output
506   -debug     Produce even more output which will mean nothing to most   -debug     Produce even more output which will mean nothing to most
507   -force     Do "make CLEAN" before compiling. This forces a complete rebuild.   -force     Do "make CLEAN" before compiling. This forces a complete rebuild.
508   -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.  
509   -cleanup   Aggresively removes all model output, executables and object files   -cleanup   Aggresively removes all model output, executables and object files
510              and then exits. Use with care.              and then exits. Use with care.
511    
# Line 376  scandirs() Line 527  scandirs()
527    
528    
529  ###############################################################################  ###############################################################################
 ###############################################################################  
 ###############################################################################  
530    
531    
532  #  Default properties  #  Default properties
533  debug=0  debug=0
534  verbose=1  verbose=1
 quick=0  
535  clean=0  clean=0
 ieee=1  
536  expts=''  expts=''
537    # ieee=1
538    
539    IEEE=
540    if test "x$MITGCM_IEEE" != x ; then
541        IEEE=$MITGCM_IEEE
542    fi
543    
544    
545  OPTFILES=  CLEANUP=f
546  ADDRESSES=edhill@mitgcm.org  QUICK=f
547    NOGENMAKE=f
548    NOCLEAN=f
549    NODEPEND=f
550    
551    BASH=
552    OPTFILE=NONE
553    ADDRESSES=
554  TESTDIRS=  TESTDIRS=
555  MPACKDIR="../tools/mpack-1.6"  MPACKDIR="../tools/mpack-1.6"
556    HAVE_MPACK=
557  MPACK="$MPACKDIR/mpack"  MPACK="$MPACKDIR/mpack"
558    COMMAND=
559    MAKE=make
560    MPI=f
561    
562    ADM=
563    
564  echo -n "parsing options...  "  echo -n "parsing options...  "
565    
# Line 414  for ac_option ; do Line 581  for ac_option ; do
581              usage ;;              usage ;;
582                    
583          -optfile | --optfile | -of | --of)          -optfile | --optfile | -of | --of)
584              ac_prev=OPTFILES ;;              ac_prev=OPTFILE ;;
585          -optfile=* | --optfile=* | -of=* | --of=*)          -optfile=* | --optfile=* | -of=* | --of=*)
586              OPTFILES=$ac_optarg ;;              OPTFILE=$ac_optarg ;;
587                    
588          -addr | --addr | -a | --a)          -addr | --addr | -a | --a)
589              ac_prev=ADDRESSES ;;              ac_prev=ADDRESSES ;;
# Line 428  for ac_option ; do Line 595  for ac_option ; do
595          -tdir=* | --tdir=*)          -tdir=* | --tdir=*)
596              TESTDIRS=$ac_optarg ;;              TESTDIRS=$ac_optarg ;;
597    
598          -quick) quick=1 ;;          -bash | --bash | -b | --b)
599                ac_prev=BASH ;;
600            -bash=* | --bash=*)
601                BASH=$ac_optarg ;;
602    
603            -command | --command | -c | --c)
604                ac_prev=COMMAND ;;
605            -command=* | --command=*)
606                COMMAND=$ac_optarg ;;
607    
608            -make | --make | -m | --m)
609                ac_prev=MAKE ;;
610            -make=* | --make=*)
611                MAKE=$ac_optarg ;;
612    
613            -clean | --clean)
614                CLEANUP=t ;;
615    
616            -quick | --quick | -q | --q)
617                QUICK=t ;;
618            -nogenmake | --nogenmake | -ng | --ng)
619                NOGENMAKE=t ;;
620            -noclean | --noclean | -nc | --nc)
621                NOCLEAN=t ;;
622            -nodepend | --nodepend | -nd | --nd)
623                NODEPEND=t ;;
624    
625            -mpi) MPI=t ;;
626    
627            -adm | -ad) ADM=t ;;
628    
629            -ieee) IEEE=true ;;
630            -noieee) IEEE= ;;
631    
632          -verbose) verbose=2 ;;          -verbose) verbose=2 ;;
633          -debug) debug=1 ;;          -debug) debug=1 ;;
         -clean) clean=1 ;;  
         -noieee) ieee=0 ;;  
634          -quiet) verbose=0 ;;          -quiet) verbose=0 ;;
635    
636          -*)          -*)
# Line 449  for ac_option ; do Line 647  for ac_option ; do
647            
648  done  done
649    
650    if test "x$QUICK" = xt ; then
651        NOGENMAKE=t
652        NOCLEAN=t
653        NODEPEND=t
654    fi
655    
656  if test "x$TESTDIRS" = x ; then  if test "x$TESTDIRS" = x ; then
657      TESTDIRS=`scandirs`      TESTDIRS=`scandirs`
658  fi  fi
659    
660    if test "x$OPTFILE" = xNONE -a "x$MITGCM_OF" != x ; then
661        OPTFILE=$MITGCM_OF
662    fi
663    
664    if test "x$ADM" = xt -a "x$COMMAND" = x ; then
665        COMMAND="./mitgcmuv_ad > output.txt_adm 2>&1"
666    fi
667    
668    if test "x$COMMAND" = x ; then
669        COMMAND="make output.txt"
670    fi
671    
672  echo "OK"  echo "OK"
673    
674  #  create the FORTRAN comparison code  #  create the FORTRAN comparison code
# Line 465  build_mpack Line 681  build_mpack
681  MACH=`hostname`  MACH=`hostname`
682  UNAMEA=`uname -a`  UNAMEA=`uname -a`
683  DATE=`date +%Y%m%d`  DATE=`date +%Y%m%d`
684  BASE=$MACH"_"$DATE"_"  BASE="tr_"$MACH"_"$DATE"_"
685  DNUM=0  DNUM=0
686  DRESULTS="$BASE$DNUM"  DRESULTS="$BASE$DNUM"
687  while test -e $DRESULTS ; do  while test -e $DRESULTS ; do
# Line 475  done Line 691  done
691  mkdir $DRESULTS  mkdir $DRESULTS
692  RETVAL=$?  RETVAL=$?
693  if test "x$RETVAL" != x0 ; then  if test "x$RETVAL" != x0 ; then
694      echo "Error: can't create results directory \"./$DRESULTS\""      echo "ERROR: Can't create results directory \"./$DRESULTS\""
695      exit 1      exit 1
696  fi  fi
697  SUMMARY="$DRESULTS/summary.txt"  SUMMARY="$DRESULTS/summary.txt"
698  date > $SUMMARY  echo -n "Start time:  " >> $SUMMARY
699  cat << EOF >> $SUMMARY  start_date=`date`
700    echo $start_date > $SUMMARY
701    
702    of_path=
703    if test "x$OPTFILE" != xNONE ; then
704        if test -r $OPTFILE ; then
705            # get the path
706            path=${OPTFILE%/*}
707            if test "x$path" = x ; then
708                of_path=`pwd`
709            else
710                of_path=`( cd $path > /dev/null 2>&1 ; pwd )`
711            fi
712            file=${OPTFILE##*/}
713            OPTFILE=$of_path/$file
714            cp $OPTFILE $DRESULTS
715            echo >> $SUMMARY
716            echo "  OPTFILE=$OPTFILE" >> $SUMMARY
717        else
718            echo | tee $SUMMARY
719            echo "ERROR: can't read OPTFILE=\"$OPTFILE\"" | tee $SUMMARY
720            exit 1
721        fi
722    else
723        echo >> $SUMMARY
724        echo "No \"OPTFILE\" was explicitly specified by testreport," >> $SUMMARY
725        echo "   so the genmake default will be used." >> $SUMMARY
726    fi
727    echo
728    echo >> $SUMMARY
729    if test "x$ADM" = x ; then
730        cat << EOF | tee -a $SUMMARY
731                  T           S           U           V                  T           S           U           V
732  G D M    c        m  s        m  s        m  s        m  s  G D M    c        m  s        m  s        m  s        m  s
733  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 735  N n k u  2  i  a  a  d  i  a  a  d  i  a
735  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  .
736    
737  EOF  EOF
738    else
739        echo "ADJOINT=true" >> $SUMMARY
740        echo >> $SUMMARY
741        cat << EOF | tee -a $SUMMARY
742    G D M    C  G
743    E p a R  o  r
744    N n k u  s  a
745    2 d e n  t  d
746    
747  NDIR=0  EOF
748    fi
749    
750  #  For each optfile...  #  ...and each test directory...
751  for OPTFILE in $OPTFILES ; do  for dir in $TESTDIRS ; do
752        
753        #  Cleanup only!
754        if test "x$CLEANUP" = xt ; then
755            if test -r $dir/build/Makefile ; then
756                ( cd $dir/build ; make CLEAN )
757            fi
758            if test -r $dir/input/Makefile ; then
759                ( cd $dir/input ; make CLEAN )
760            fi
761            continue
762        fi
763    
764        #  Verify that the testdir exists and contains previous
765        #  results in the correct location--or skip this directory!
766        fout=
767        if test "x$ADM" = x ; then
768            fout=$dir"/results/output.txt"
769        else
770            fout=$dir"/results_ad/output.txt_adm"
771        fi
772        if test ! -r $fout ; then
773            echo "can't read \"$fout\" -- skipping $dir"
774            continue
775        fi
776    
777      OPTFILE=`pwd`"/$OPTFILE"      builddir="input"
778      if test ! -r $OPTFILE ; then      rundir="input"
779          echo "Error: can't read optfile \"$OPTFILE\""      use_seperate_build=0
780          exit 1      if test -d $dir/build -a -r $dir/build ; then
781            builddir="build"
782            rundir="build"
783            use_seperate_build=1
784            linkdata $use_seperate_build $dir/$rundir
785      fi      fi
     echo  
     echo "OPTFILE=$OPTFILE" >> $SUMMARY  
     echo >> $SUMMARY  
786            
787      #  ...and each test directory...      if test "x$ADM" = x ; then
788      for dir in $TESTDIRS ; do          code_dir=code
789            CODE_DIR=$dir/code
790        else
791            code_dir=code_ad
792            CODE_DIR=$dir/code_ad
793        fi
794        BUILD_DIR=$dir/$builddir
795    
796          #  Verify that the testdir exists and contains previous      if test ! -r $CODE_DIR"/SIZE.h_mpi" -a "x$MPI" = "xt" ; then
797          #  results in the correct location--or skip this directory!          echo "can't find \"$CODE_DIR/SIZE.h_mpi\" -- skipping $dir"
798          if test ! -r $dir"/results/output.txt" ; then          continue
799              echo | tee -a $SUMMARY      fi
             echo "can't read \"$dir/results/output.txt\" -- skipping $dir" \  
                 | tee -a $SUMMARY  
             continue  
         fi  
           
         #  Create an output dir for each OPTFILE/tdir combination  
         CDIR=$DRESULTS"/"$DRESULTS"_"$NDIR  
         mkdir $CDIR  
         CDIR=`pwd`"/$CDIR"  
800    
801          #  ...configue, make, run, and compare the output.      echo "-------------------------------------------------------------------------------"
802          echo "-------------------------------------------------------------------------------"      echo
803          echo      echo "Experiment:  $dir"
804          echo "Experiment:  $dir"      echo
805          echo      unset genmake makedepend make run
806          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  
807    
808        #  Create an output dir for each OPTFILE/tdir combination
809        rel_CDIR=$DRESULTS"/"$dir
810        mkdir $rel_CDIR
811        CDIR=`pwd`"/$rel_CDIR"
812        
813        if test "x$CLEANUP" = xt ; then
814            makeclean $dir/$builddir
815        else
816          genmakemodel $dir/$builddir && genmake=Y \          genmakemodel $dir/$builddir && genmake=Y \
817              && makeclean $dir/$builddir \              && makeclean $dir/$builddir \
818                && symlink_mpifiles $dir $code_dir $builddir \
819              && makedependmodel $dir/$builddir && makedepend=Y \              && makedependmodel $dir/$builddir && makedepend=Y \
820              && makemodel $dir/$builddir && make=Y \              && makemodel $dir/$builddir && make=Y \
821              && linkdata $seperatebuilddir $dir/$rundir \              && linkdata $use_seperate_build $dir/$rundir \
822              && runmodel $dir/$builddir mitgcmuv && run=Y \              && runmodel $dir/$rundir && run=Y \
823              && results=`testoutput $dir $rundir`              && results=`testoutput $dir $rundir`
824          echo      fi
825          formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \      
826              ${run:-N} $results      echo
827          echo      if test "x$ADM" = x ; then
828          formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \          fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results`
829              ${run:-N} $results >> $SUMMARY      else
830          echo "fresults='" > $CDIR"/summary.txt"          fres=`printf '%s %s %s %s' ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N}`
831          formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \          fres=$fres"$results   $dir"
832              ${run:-N} $results >> $CDIR"/summary.txt"      fi
833          echo "'" >> $CDIR"/summary.txt"      echo
834          echo "MACH='$MACH'" >> $CDIR"/summary.txt"      echo "$fres" >> $SUMMARY
835          echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"      echo "fresults='$fres'" > $CDIR"/summary.txt"
836          echo "DATE='$DATE'" >> $CDIR"/summary.txt"      echo "MACH='$MACH'" >> $CDIR"/summary.txt"
837          echo "tdir='$dir'" >> $CDIR"/summary.txt"      echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"
838        echo "DATE='$DATE'" >> $CDIR"/summary.txt"
839          (      echo "tdir='$dir'" >> $CDIR"/summary.txt"
840              cd $DRESULTS      
841              tar -cf $NDIR".tar" $DRESULTS"_"$NDIR > /dev/null 2>&1      echo "-------------------------------------------------------------------------------"
842              gzip $NDIR".tar"      
843          )  done
844    
845          $MPACK -s MITgcm-test -m 1000000 $DRESULTS"/"$NDIR".tar.gz" $ADDRESSES  echo -n "Start time:  " >> $SUMMARY
846    echo $start_date >> $SUMMARY
847    echo -n "End time:    " >> $SUMMARY
848    date >> $SUMMARY
849    
850    #  If addresses were supplied and mpack built successfully, then try
851    #  to send email using mpack.
852    if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then
853        echo "No results email was sent."
854    else
855        if test "x$HAVE_MPACK" = xt ; then
856            tar -cf $DRESULTS".tar" $DRESULTS > /dev/null 2>&1 \
857                && gzip $DRESULTS".tar" \
858                && $MPACK -s MITgcm-test -m 1500000 $DRESULTS".tar.gz" $ADDRESSES
859          RETVAL=$?          RETVAL=$?
860          if test "x$RETVAL" != x0 ; then          if test "x$RETVAL" != x0 ; then
861              echo "Warning: \"$MPACK\" failed -- please contact <edhill@mitgcm.org>"              echo
862                echo "Warning: The tar, gzip, & mpack step failed.  Please send email"
863                echo "  to <MITgcm-support@mitgcm.org> for help.  You may copy the "
864                echo "  summary of results from the directory \"$DRESULTS\"."
865                echo
866          else          else
867              rm -f $DRESULTS"/"$NDIR".tar*"              echo
868                echo "An email containing results was sent to the following addresses:"
869                echo "  \"$ADDRESSES\""
870                echo
871          fi          fi
872            test -f $DRESULTS".tar"  &&  rm -f $DRESULTS".tar"
873            test -f $DRESULTS".tar.gz"  &&  rm -f $DRESULTS".tar.gz"
874        fi
875    fi
876    
877          NDIR=$(( $NDIR + 1 ))  # rm -f tmp_cmpnum.f a.out
878            rm -f tmp_cmpnum.c tmp_cmpnum
     done  
 done  
   
 rm tmp_cmpnum.f a.out  
879    
880  cat $SUMMARY  if test "x$CLEANUP" != xt ; then
881        cat $SUMMARY
882        if test -e tr_out.txt ; then
883            mv tr_out.txt tr_out.txt.old
884        fi
885        cat $SUMMARY > tr_out.txt
886    fi
887    

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.30

  ViewVC Help
Powered by ViewVC 1.1.22