/[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.43 by edhill, Thu Jul 8 20:58:24 2004 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=\"-ieee\")"
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 "  (-j) JOBS                use \"make -j JOBS\" for parallel builds"
31        echo "  (-clean)                 *ONLY* run \"make CLEAN\""
32        echo "  (-quick|-q)              same as \"-nogenmake -noclean -nodepend\""
33        echo "  (-nogenmake|-ng)         skip the genmake stage"
34        echo "  (-noclean|-nc)           skip the \"make clean\" stage"
35        echo "  (-nodepend|-nd)          skip the \"make depend\" stage"
36        echo "  (-deldir|-dd)            on success, delete the output directory"
37        echo
38        echo "and where STRING follows a whitespace-delimited format"
39        echo "such as:"
40        echo "  -t 'exp0 exp2 exp3' "
41        echo "  -addr='abc@123.com testing@home.org'"
42      echo      echo
43      exit 1      exit 1
44  }  }
# Line 20  usage() Line 46  usage()
46  #  build the mpack utility  #  build the mpack utility
47  build_mpack()  build_mpack()
48  {  {
49      echo -n "building the mpack utility...  "      printf "building the mpack utility...  "
50      if test ! -x "$MPACKDIR/mpack" ; then      if test ! -x "$MPACKDIR/mpack" ; then
51          if test ! -d $MPACKDIR ; then          if test ! -d $MPACKDIR ; then
52                echo
53              echo "Error: can't find \"$MPACKDIR\""              echo "Error: can't find \"$MPACKDIR\""
54              echo "  are you sure this program is being run in the correct "              echo "  are you sure this program is being run in the correct "
55              echo "  (that is, \"MITGCM_ROOT\verification\") directory?"              echo "  (that is, \"MITGCM_ROOT\verification\") directory?"
56              exit 1              echo
57                HAVE_MPACK=f
58            fi
59            printf "building mpack...  "
60            if test "x$CC" = x ; then
61                export CC=cc
62          fi          fi
63          echo -n "building mpack...  "          ( cd $MPACKDIR && ./configure && $MAKE ) > tr_build_mpack.out 2>&1
         ( cd $MPACKDIR && ./configure && make ) > build_mpack.out 2>&1  
64          RETVAL=$?          RETVAL=$?
65          if test "x$RETVAL" != x0 ; then          if test "x$RETVAL" != x0 ; then
66              echo              echo
67              echo "Error building the mpack tools at: $MPACK_DIR"              echo "Error building the mpack tools at: $MPACK_DIR"
68              exit 1              echo
69                HAVE_MPACK=f
70            else
71                rm -f tr_build_mpack.out
72                HAVE_MPACK=t
73          fi          fi
74        else
75            HAVE_MPACK=t
76      fi      fi
77      echo "OK"      echo "OK"
78  }  }
79    
 compare_lines()  
 {  
     # use codelet to compare lines  
     if [ $verbose -gt 1 ]; then  
         cat tmp3.txt 1>&2  
     fi  
     return `./a.out < tmp3.txt`  
 }  
   
80  testoutput_for_prop()  testoutput_for_prop()
81  {  {
82      # testoutput_for_prop dir s1 label subdir      # testoutput_for_prop dir s1 label subdir extension
83      #      #
84      #  compares files in $dir/$subdir/output.txt and $dir/results/output.txt      #  compares files in $dir/$subdir/output.txt and $dir/results/output.txt
85      #  using search strings s1 and text label      #  using search strings s1 and text label
# Line 60  testoutput_for_prop() Line 88  testoutput_for_prop()
88          echo testoutput_for_prop: grep "$2" $1/$4/output.txt 1>&2          echo testoutput_for_prop: grep "$2" $1/$4/output.txt 1>&2
89      fi      fi
90      if [ -r $1/$4/output.txt ]; then      if [ -r $1/$4/output.txt ]; then
91          grep "$2" $1/$4/output.txt | sed 's/.*=//' | nl > tmp1.txt          grep "$2" $1/$4/output.txt | sed 's/.*=//' | cat -n > tmp1.txt
92          lncnt=`wc -l tmp1.txt | awk '{print $1}' `          lncnt=`wc -l tmp1.txt | awk '{print $1}' `
93          if [ $lncnt -lt 3 ]; then          if [ $lncnt -lt 3 ]; then
94              if [ $verbose -gt 0 ]; then              if [ $verbose -gt 0 ]; then
# Line 73  testoutput_for_prop() Line 101  testoutput_for_prop()
101          return 99          return 99
102      fi      fi
103      if [ $debug -gt 0 ]; then      if [ $debug -gt 0 ]; then
104          echo testoutput_for_prop: grep "$2" $1/results/output.txt 1>&2          echo testoutput_for_prop: grep "$2" $1/results/output.txt$5 1>&2
105      fi      fi
106      grep "$2" $1/results/output.txt | sed 's/.*=//' | nl > tmp2.txt      grep "$2" $1/results/output.txt$5 | sed 's/.*=//' | cat -n > tmp2.txt
107      lncnt=`wc -l tmp2.txt | awk '{print $1}' `      lncnt=`wc -l tmp2.txt | awk '{print $1}' `
108      if [ $lncnt -lt 3 ]; then      if [ $lncnt -lt 3 ]; then
109          if [ $verbose -gt 0 ]; then          if [ $verbose -gt 0 ]; then
# Line 90  testoutput_for_prop() Line 118  testoutput_for_prop()
118      if [ $debug -gt 0 ]; then      if [ $debug -gt 0 ]; then
119          echo testoutput_for_prop: compare_lines 1>&2          echo testoutput_for_prop: compare_lines 1>&2
120      fi      fi
121      compare_lines      if [ $verbose -gt 1 ]; then
122      digits_of_similarity=$?          cat tmp3.txt 1>&2
123        fi
124        echo "-1" >> tmp3.txt
125        # On the SGI O3K (*not* the O2K), "cat -n" inserts a ":" after the line number
126        cat tmp3.txt | sed -e 's|:||g' > tmp4.txt
127        digits_of_similarity=`./tmp_cmpnum < tmp4.txt`
128      if [ $digits_of_similarity -eq 99 ]; then      if [ $digits_of_similarity -eq 99 ]; then
129          if [ $verbose -gt 0 ]; then          if [ $verbose -gt 0 ]; then
130              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 135  testoutput_for_prop()
135              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
136          fi          fi
137      fi      fi
138      rm tmp1.txt tmp2.txt tmp3.txt      rm -f tmp1.txt tmp2.txt tmp3.txt tmp4.txt
139            
140      return $digits_of_similarity      return $digits_of_similarity
141  }  }
# Line 122  dashnum() Line 155  dashnum()
155      done      done
156  }  }
157    
158    testoutput_ad()
159    {
160        grep $3 $1/results_ad/output.txt_adm | awk '{print NR " " $5}' > t05.txt
161        grep $3 $1/$2/output.txt_adm | awk '{print NR " " $5}' > t15.txt
162        grep $3 $1/results_ad/output.txt_adm | awk '{print NR " " $6}' > t06.txt
163        grep $3 $1/$2/output.txt_adm | awk '{print NR " " $6}' > t16.txt
164        join t05.txt t15.txt > t5.txt
165        join t06.txt t16.txt > t6.txt
166        echo "-1" >> t5.txt
167        echo "-1" >> t6.txt
168        digits_5=`./tmp_cmpnum < t5.txt`
169        digits_6=`./tmp_cmpnum < t6.txt`
170        dashnum $digits_5 $digits_6
171        rm -f t[01][56].txt t[56].txt
172    }
173    
174  testoutput()  testoutput()
175  {  {
176      # testoutput diretory subdir      # testoutput directory subdir extension
177      #      #
178      #  test output in "directory"      #  test output in "directory"
179        if test "x$ADM" = x ; then
180      if [ $debug -gt 0 ]; then          if [ $debug -gt 0 ]; then
181          echo testoutput: testoutput_for_prop $1 cg2d_init_res 1>&2              echo testoutput: testoutput_for_prop $1 cg2d_init_res 1>&2
182      fi          fi
183      testoutput_for_prop $1 "cg2d_init_res" "cg2d init. residual" $2; cg2dres=$?          testoutput_for_prop $1 "cg2d_init_res" "cg2d init. residual" $2 $3; cg2dres=$?
184      if [ $debug -gt 0 ]; then          if [ $debug -gt 0 ]; then
185          echo testoutput: cg2dres=$cg2dres 1>&2              echo testoutput: cg2dres=$cg2dres 1>&2
186            fi
187            testoutput_for_prop $1 "dynstat_theta_min" "theta minimum" $2 $3; tmin=$?
188            testoutput_for_prop $1 "dynstat_theta_max" "theta maximum" $2 $3; tmax=$?
189            testoutput_for_prop $1 "dynstat_theta_mean" "theta mean" $2 $3; tmean=$?
190            testoutput_for_prop $1 "dynstat_theta_sd" "theta s.d." $2 $3; tsd=$?
191            testoutput_for_prop $1 "dynstat_salt_min" "salt minimum" $2 $3; smin=$?
192            testoutput_for_prop $1 "dynstat_salt_max" "salt maximum" $2 $3; smax=$?
193            testoutput_for_prop $1 "dynstat_salt_mean" "salt mean" $2 $3; smean=$?
194            testoutput_for_prop $1 "dynstat_salt_sd" "salt s.d." $2 $3; ssd=$?
195            testoutput_for_prop $1 "dynstat_uvel_min" "U minimum" $2 $3; umin=$?
196            testoutput_for_prop $1 "dynstat_uvel_max" "U maximum" $2 $3; umax=$?
197            testoutput_for_prop $1 "dynstat_uvel_mean" "U mean" $2 $3; umean=$?
198            testoutput_for_prop $1 "dynstat_uvel_sd" "U s.d." $2 $3; usd=$?
199            testoutput_for_prop $1 "dynstat_vvel_min" "V minimum" $2 $3; vmin=$?
200            testoutput_for_prop $1 "dynstat_vvel_max" "V maximum" $2 $3; vmax=$?
201            testoutput_for_prop $1 "dynstat_vvel_mean" "V mean" $2 $3; vmean=$?
202            testoutput_for_prop $1 "dynstat_vvel_sd" "V s.d." $2 $3; vsd=$?
203            dashnum $cg2dres $tmin $tmax $tmean $tsd $smin $smax $smean $ssd \
204                $umin $umax $umean $usd $vmin $vmax $vmean $vsd
205        else
206            testoutput_ad $1 $2 "precision_grdchk_result"
207      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  
208  }  }
209    
210  genmakemodel()  genmakemodel()
211  {  {
212      # genmakemodel directory      # genmakemodel directory
213      GENMAKE2="../../../tools/genmake2"      if test "x$NOGENMAKE" = xt ; then
214      (          echo "genmake skipped!"
215          cd $1;      else
216          printf 'genmake ... ' 1>&2          if test "x$BASH" = x ; then
217          # ../../../tools/genmake -ieee -mods=../code > make.log 2>&1              GENMAKE2="../../../tools/genmake2"
         $GENMAKE2  -ds --mods=../code "--optfile="$OPTFILE > make.log 2>&1  
         RETVAL=$?  
         for i in gm_state gm_optfile gm_local Makefile ; do  
             if test -r $i ; then  
                 cp $i $CDIR  
             fi  
         done  
         if test "x$RETVAL" != x0 ; then  
             tail make.log  
             echo "genmakemodel: genmake failed" 1>&2  
             cp make.log $CDIR  
             return 1  
218          else          else
219              echo "succesful" 1>&2              GENMAKE2="$BASH ../../../tools/genmake2 -bash $BASH"
220          fi          fi
221      )          (
222                cd $1;
223                command="$GENMAKE2  -ds -m $MAKE"
224                if test "x$ADM" = x ; then
225                    command="$command --mods=../code"
226                else
227                    command="$command --mods=../code_ad"
228                    command="$command -adof=../../../tools/adjoint_options/adjoint_staf"
229                fi
230                if test "x$OPTFILE" != xNONE ; then
231                    command="$command --optfile=$OPTFILE"
232                fi
233                if test "x$IEEE" != x ; then
234                    command="$command -ieee"
235                fi
236                printf 'genmake ... ' 1>&2
237                $command > make.log 2>&1
238                RETVAL=$?
239                cp Makefile $CDIR
240                if test "x$RETVAL" != x0 ; then
241                    tail make.log
242                    echo "genmakemodel: genmake failed" 1>&2
243                    cp genmake_* make.log $CDIR
244                    return 1
245                else
246                    echo "successful" 1>&2
247                fi
248            )
249        fi
250  }  }
251    
252  makeclean()  makeclean()
253  {  {
254      # makeclean directory      # makeclean directory
255      (      if test "x$NOCLEAN" = xt ; then
256          cd $1;          echo "make CLEAN skipped!"
257          rm -f output.txt      else
258          printf 'make CLEAN ... ' 2>&1          (
259          if test -r Makefile ; then              cd $1;
260              make CLEAN >> make.log 2>&1              if test -e output.txt ; then
261              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  
262              fi              fi
263          fi              printf 'make CLEAN ... ' 2>&1
264          echo succesful 1>&2              if test -r Makefile ; then
265          exit 0                  $MAKE CLEAN >> make.log 2>&1
266      )                  RETVAL=$?
267                    if test "x$RETVAL" != x0 ; then
268                        tail make.log
269                        echo "makeclean: \"make CLEAN\" failed" 1>&2
270                        cp make.log $CDIR"/make.log"
271                        return 1
272                    fi
273                fi
274                echo successful 1>&2
275                exit 0
276            )
277        fi
278  }  }
279    
280  makedependmodel()  makedependmodel()
281  {  {
282      # makedependmodel directory      # makedependmodel directory
283      (      if test "x$NODEPEND" = xt ; then
284          cd $1;          echo "make depend skipped!"
285          printf 'make depend ... ' 1>&2      else
286          make depend >> make.log 2>&1          (
287          RETVAL=$?              cd $1;
288          if test "x$RETVAL" != x0 ; then              printf 'make depend ... ' 1>&2
289              tail make.log              $MAKE depend >> make.log 2>&1
290              echo "makedependmodel: make depend failed" 1>&2              RETVAL=$?
291              cp make.log $CDIR"/make.log"              if test "x$RETVAL" != x0 ; then
292              return 1                  tail make.log
293          else                  echo "makedependmodel: make depend failed" 1>&2
294              echo succesful 1>&2                  cp make.log $CDIR"/make.log"
295          fi                  return 1
296      )              else
297                    echo successful 1>&2
298                fi
299            )
300        fi
301  }  }
302    
303  makemodel()  makemodel()
# Line 231  makemodel() Line 307  makemodel()
307          cd $1;          cd $1;
308          if test -r Makefile ; then          if test -r Makefile ; then
309              printf 'make ... ' 1>&2              printf 'make ... ' 1>&2
310              make >> make.log 2>&1              if test "x$ADM" = x ; then
311                    if test "x$JOBS" = x ; then
312                        $MAKE >> make.log 2>&1
313                    else
314                        $MAKE -j $JOBS >> make.log 2>&1
315                    fi
316                else
317                    $MAKE adall >> make.log 2>&1
318                fi
319              RETVAL=$?              RETVAL=$?
320              if test "x$RETVAL" != x0 ; then              if test "x$RETVAL" != x0 ; then
321                  tail make.log                  tail make.log
# Line 239  makemodel() Line 323  makemodel()
323                  cp make.log $CDIR"/make.log"                  cp make.log $CDIR"/make.log"
324                  return 1                  return 1
325              else              else
326                  echo succesful 1>&2                  echo successful 1>&2
327              fi              fi
328          fi          fi
329      )      )
330  }  }
331    
332    symlink_mpifiles()
333    {
334        # Put special links so that MPI specific files are used
335        # This MUST be invoked between makeclean and makelinks because
336        # the Makefile will link to non-mpi files by default
337    
338        dir=$1
339        code_dir=$2
340        BUILD_DIR=$dir/$3
341        CODE_DIR=$dir/$code_dir
342    
343        # These are files that should replace their counter-part when using -mpi
344        MPI_FILES=`(cd $CODE_DIR; find . -name "*_mpi")`
345    
346        #  Is this an MPI run?
347        if test "x$MPI" = xt ; then
348            # YES: We symbolically link these files to the build
349            # dir so long as there is no real file in place
350            for ii in $MPI_FILES ; do
351                i=`echo $ii | sed 's:^\./::'`
352                name=`echo $i | sed 's:_mpi::' `
353                cmp $CODE_DIR/$i $BUILD_DIR/$name > /dev/null 2>&1
354                RETVAL=$?
355                if test "x$RETVAL" != x0 ; then
356                    if ! test -f $BUILD_DIR/$i ; then
357                    #echo Linking $name to $i
358                        (cd $BUILD_DIR; ln -sf ../$code_dir/$i $name)
359                    fi
360                fi
361            done
362        else
363        # NO: We undo any _mpi symbolically linked files
364            for ii in $MPI_FILES ; do
365                i=`echo $ii | sed 's:^\./::'`
366                name=`echo $i | sed 's:_mpi::' `
367                if test -L $BUILD_DIR/$name ; then
368                    linktarg=`(cd $BUILD_DIR; readlink $name)`
369                    if test $linktarg = "../$code_dir/$name"_mpi ; then
370                    #echo Un-linking $name from $linktarg
371                        rm -f $BUILD_DIR/$name
372                    fi
373                fi
374            done
375        fi
376        
377    }
378    
379  linkdata()  linkdata()
380  {  {
381      # linkdata flag      # linkdata flag
382      #      #
383      # symbolically link data files to run directory      # symbolically link data files to run directory
384      if [ $1 -ne 0 ]; then      if test "x$1" = x1 ; then
385          ( cd $2 ;  ln -sf ../input/* . )          (
386                cd $2
387                if test "x$ADM" = x ; then
388                    files=`( cd ../input ; ls -1 | grep -v CVS )`
389                    for i in $files ; do
390                        if test ! -d "../input/"$i ; then
391                            ln -sf "../input/"$i $i
392                        fi
393                    done
394                else
395                    files=`( cd ../input ; ls -1 *.bin | grep -v CVS )`
396                    for i in $files ; do
397                        if test ! -d "../input/"$i ; then
398                            ln -sf "../input/"$i $i
399                        fi
400                    done
401                    files=`( cd ../input_ad ; ls -1 | grep -v CVS )`
402                    for i in $files ; do
403                        if test ! -d "../input_ad/"$i ; then
404                            ln -sf "../input_ad/"$i $i
405                        fi
406                    done
407                fi
408            )
409      fi      fi
410  }  }
411    
412  runmodel()  runmodel()
413  {  {
414      # runmodel directory exe      # runmodel directory
415      #      #
416      #  runs the model "exe" in "directory" (exe is relative to directory)      #  runs "$COMMAND in "directory"
417        #  (where "$COMMAND" is relative to "directory")
418      (      (
419          cd $1          cd $1
420          if [ -x $2 ]; then          printf 'runmodel ... ' 1>&2
421              if [ $quick -eq 0 ]; then          # make output.txt
422                  rm -f output.txt          echo
423              fi          # echo "COMMAND='$COMMAND'"
424              printf 'runmodel: ' 1>&2          # echo "pwd='"`pwd`"'"
425              make output.txt          ( eval $COMMAND ) >> run.log 2>&1
426              RETVAL=$?          RETVAL=$?
427              if test "x$RETVAL" = x0 ; then          if test "x$RETVAL" = x0 ; then
428                echo successful 1>&2
429                if test "x$ADM" = x ; then
430                  cp output.txt $CDIR"/output.txt"                  cp output.txt $CDIR"/output.txt"
                 return 0  
431              else              else
432                  return 1                  cp output.txt_adm $CDIR"/output.txt_adm"
433              fi              fi
434                return 0
435            else
436                tail run.log
437                echo failed 1>&2
438                cp run.log $CDIR"/run.log"
439                return 1
440          fi          fi
441      )      )
442  }  }
# Line 283  createcodelet() Line 445  createcodelet()
445  {  {
446      # create codelet for comparing model output      # create codelet for comparing model output
447    
448      echo -n "creating the comparison code...  "      printf "creating the comparison code...  "
449      cat > tmp_cmpnum.f <<EOFA      cat > tmp_cmpnum.c <<EOF
450        program cmpnum  #include <stdio.h>
451        implicit none  #include <math.h>
452        real*8 a,b,diff  int main( int argc, char** argv )  {
453        integer linnum,best    int linnum,best,lncnt;
454        best=-16    double a,b,diff;
455    99  read(*,*,end=70,err=60) linnum,a,b    best = -16;
456        diff=0.5*(abs(a)+abs(b))    lncnt = 0;
457  c     print *,a,b,diff,abs(a-b)/diff    while( 1 & (lncnt+=1) < 999 )  {
458        if (diff.gt.1.e-12) then      scanf("%d", &linnum);
459          diff=abs(a-b)/diff      if (linnum == -1)  break;
460          if (diff.gt.0.) then      scanf("%lf", &a);  scanf("%lf", &b);
461  c         print *,int(log10(diff)),diff      diff = 0.5*(fabs(a)+fabs(b));
462            linnum=int(log10(diff))      if (diff > 1.e-12) {
463            best=max(best,linnum)        diff=fabs(a-b)/diff;
464          endif        if (diff > 0.0) {
465        else          linnum = (int)log10(diff);
466          if (best.eq.-16.and.diff.ne.0.) best=-22          best = (best > linnum) ? best : linnum;
467        endif        }
468        goto 99        else {
469    60  stop 'cmpnum: An error occured reading a,b'          if (best == -16 && diff != 0)  best = -22;
470    70  print *,-best        }
471        end      }
472  EOFA    }
473      if (lncnt == 999) best=-29;
474      printf("%d\n", -best);
475      return 0;
476    }
477    EOF
478        cc -o tmp_cmpnum tmp_cmpnum.c -lm
479    
480      f77 tmp_cmpnum.f      if [ -x ./tmp_cmpnum ]; then
     if [ -x ./a.out ]; then  
481          echo "OK"          echo "OK"
482          return 0          return 0
483      else      else
484          echo          echo
485          echo "createcodelet: failed to compile codelet" | tee          echo "ERROR: failed to compile comparison code"
486          exit 1          exit 1
487      fi      fi
488  }  }
# Line 347  show_help() Line 514  show_help()
514  {  {
515      cat - << EOF      cat - << EOF
516  $0 [-help] [-quick] [-verbose] dir1 [dir2] [...]  $0 [-help] [-quick] [-verbose] dir1 [dir2] [...]
517   -help      Show this help message  
518   -quick     Skip "genmake" and "make depend" if the Makefile exists   -help|-h      Show this help message
519   -quiet     Reduce the amount of output   -quiet     Reduce the amount of output
520   -verbose   Produce copious amounts of output   -verbose   Produce copious amounts of output
521   -debug     Produce even more output which will mean nothing to most   -debug     Produce even more output which will mean nothing to most
522   -force     Do "make CLEAN" before compiling. This forces a complete rebuild.   -force     Do "make CLEAN" before compiling. This forces a complete rebuild.
523   -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.  
524   -cleanup   Aggresively removes all model output, executables and object files   -cleanup   Aggresively removes all model output, executables and object files
525              and then exits. Use with care.              and then exits. Use with care.
526    
# Line 376  scandirs() Line 542  scandirs()
542    
543    
544  ###############################################################################  ###############################################################################
 ###############################################################################  
 ###############################################################################  
545    
546    
547  #  Default properties  #  Default properties
548  debug=0  debug=0
549  verbose=1  verbose=1
 quick=0  
550  clean=0  clean=0
 ieee=1  
551  expts=''  expts=''
552    # ieee=1
553    
554    IEEE=true
555    if test "x$MITGCM_IEEE" != x ; then
556        IEEE=$MITGCM_IEEE
557    fi
558    
559    
560  OPTFILES=  CLEANUP=f
561  ADDRESSES=edhill@mitgcm.org  QUICK=f
562    NOGENMAKE=f
563    NOCLEAN=f
564    NODEPEND=f
565    
566    BASH=
567    OPTFILE=NONE
568    ADDRESSES=
569  TESTDIRS=  TESTDIRS=
570  MPACKDIR="../tools/mpack-1.6"  MPACKDIR="../tools/mpack-1.6"
571    HAVE_MPACK=
572  MPACK="$MPACKDIR/mpack"  MPACK="$MPACKDIR/mpack"
573    COMMAND=
574    MAKE=make
575    JOBS=
576    MPI=f
577    DELDIR=
578    
579  echo -n "parsing options...  "  ADM=
580    
581    printf "parsing options...  "
582    
583  ac_prev=  ac_prev=
584  for ac_option ; do  for ac_option ; do
# Line 414  for ac_option ; do Line 598  for ac_option ; do
598              usage ;;              usage ;;
599                    
600          -optfile | --optfile | -of | --of)          -optfile | --optfile | -of | --of)
601              ac_prev=OPTFILES ;;              ac_prev=OPTFILE ;;
602          -optfile=* | --optfile=* | -of=* | --of=*)          -optfile=* | --optfile=* | -of=* | --of=*)
603              OPTFILES=$ac_optarg ;;              OPTFILE=$ac_optarg ;;
604                    
605          -addr | --addr | -a | --a)          -addr | --addr | -a | --a)
606              ac_prev=ADDRESSES ;;              ac_prev=ADDRESSES ;;
# Line 428  for ac_option ; do Line 612  for ac_option ; do
612          -tdir=* | --tdir=*)          -tdir=* | --tdir=*)
613              TESTDIRS=$ac_optarg ;;              TESTDIRS=$ac_optarg ;;
614    
615          -quick) quick=1 ;;          -bash | --bash | -b | --b)
616                ac_prev=BASH ;;
617            -bash=* | --bash=*)
618                BASH=$ac_optarg ;;
619    
620            -command | --command | -c | --c)
621                ac_prev=COMMAND ;;
622            -command=* | --command=*)
623                COMMAND=$ac_optarg ;;
624    
625            -make | --make | -m | --m)
626                ac_prev=MAKE ;;
627            -make=* | --make=*)
628                MAKE=$ac_optarg ;;
629    
630            -j) ac_prev=JOBS ;;
631            -j=*) JOBS=$ac_optarg ;;
632    
633            -clean | --clean)
634                CLEANUP=t ;;
635    
636            -quick | --quick | -q | --q)
637                QUICK=t ;;
638            -nogenmake | --nogenmake | -ng | --ng)
639                NOGENMAKE=t ;;
640            -noclean | --noclean | -nc | --nc)
641                NOCLEAN=t ;;
642            -nodepend | --nodepend | -nd | --nd)
643                NODEPEND=t ;;
644    
645            -mpi) MPI=t ;;
646    
647            -adm | -ad) ADM=t ;;
648    
649            -ieee) IEEE=true ;;
650            -noieee) IEEE= ;;
651    
652          -verbose) verbose=2 ;;          -verbose) verbose=2 ;;
653          -debug) debug=1 ;;          -debug) debug=1 ;;
         -clean) clean=1 ;;  
         -noieee) ieee=0 ;;  
654          -quiet) verbose=0 ;;          -quiet) verbose=0 ;;
655    
656            -deldir | -dd) DELDIR=t ;;
657    
658          -*)          -*)
659              echo "Error: unrecognized option: "$ac_option              echo "Error: unrecognized option: "$ac_option
660              usage              usage
# Line 449  for ac_option ; do Line 669  for ac_option ; do
669            
670  done  done
671    
672    if test "x$QUICK" = xt ; then
673        NOGENMAKE=t
674        NOCLEAN=t
675        NODEPEND=t
676    fi
677    
678  if test "x$TESTDIRS" = x ; then  if test "x$TESTDIRS" = x ; then
679      TESTDIRS=`scandirs`      TESTDIRS=`scandirs`
680  fi  fi
681    
682    if test "x$OPTFILE" = xNONE -a "x$MITGCM_OF" != x ; then
683        OPTFILE=$MITGCM_OF
684    fi
685    
686    if test "x$ADM" = xt -a "x$COMMAND" = x ; then
687        COMMAND="./mitgcmuv_ad > output.txt_adm 2>&1"
688    fi
689    
690    if test "x$COMMAND" = x ; then
691        COMMAND="make output.txt"
692    fi
693    
694  echo "OK"  echo "OK"
695    
696  #  create the FORTRAN comparison code  #  create the FORTRAN comparison code
697  createcodelet  createcodelet
698    
699  #  build the mpack utility  #  build the mpack utility
700  build_mpack  if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then
701        echo "skipping mpack build"
702    else
703        build_mpack
704    fi
705    
706  #  Create a uniquely named directory to store results  #  Create a uniquely named directory to store results
707  MACH=`hostname`  MACH=`hostname`
708  UNAMEA=`uname -a`  UNAMEA=`uname -a`
709  DATE=`date +%Y%m%d`  DATE=`date +%Y%m%d`
710  BASE=$MACH"_"$DATE"_"  BASE="tr_"$MACH"_"$DATE"_"
711  DNUM=0  DNUM=0
712  DRESULTS="$BASE$DNUM"  DRESULTS="$BASE$DNUM"
713  while test -e $DRESULTS ; do  while test -e $DRESULTS ; do
# Line 475  done Line 717  done
717  mkdir $DRESULTS  mkdir $DRESULTS
718  RETVAL=$?  RETVAL=$?
719  if test "x$RETVAL" != x0 ; then  if test "x$RETVAL" != x0 ; then
720      echo "Error: can't create results directory \"./$DRESULTS\""      echo "ERROR: Can't create results directory \"./$DRESULTS\""
721      exit 1      exit 1
722  fi  fi
723  SUMMARY="$DRESULTS/summary.txt"  SUMMARY="$DRESULTS/summary.txt"
724  date > $SUMMARY  printf "Start time:  " >> $SUMMARY
725  cat << EOF >> $SUMMARY  start_date=`date`
726    echo $start_date > $SUMMARY
727    
728    of_path=
729    if test "x$OPTFILE" != xNONE ; then
730        if test -r $OPTFILE ; then
731            # get the path
732            path=${OPTFILE%/*}
733            if test "x$path" = x ; then
734                of_path=`pwd`
735            else
736                of_path=`( cd $path > /dev/null 2>&1 ; pwd )`
737            fi
738            file=${OPTFILE##*/}
739            OPTFILE=$of_path/$file
740            cp $OPTFILE $DRESULTS
741            echo >> $SUMMARY
742            echo "  OPTFILE=$OPTFILE" >> $SUMMARY
743        else
744            echo | tee $SUMMARY
745            echo "ERROR: can't read OPTFILE=\"$OPTFILE\"" | tee $SUMMARY
746            exit 1
747        fi
748    else
749        echo >> $SUMMARY
750        echo "No \"OPTFILE\" was explicitly specified by testreport," >> $SUMMARY
751        echo "   so the genmake default will be used." >> $SUMMARY
752    fi
753    echo
754    echo >> $SUMMARY
755    if test "x$ADM" = x ; then
756        cat << EOF | tee -a $SUMMARY
757                  T           S           U           V                  T           S           U           V
758  G D M    c        m  s        m  s        m  s        m  s  G D M    c        m  s        m  s        m  s        m  s
759  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 761  N n k u  2  i  a  a  d  i  a  a  d  i  a
761  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  .
762    
763  EOF  EOF
764    else
765        echo "ADJOINT=true" >> $SUMMARY
766        echo >> $SUMMARY
767        cat << EOF | tee -a $SUMMARY
768    G D M    C  G
769    E p a R  o  r
770    N n k u  s  a
771    2 d e n  t  d
772    
773  NDIR=0  EOF
774    fi
775    
776  #  For each optfile...  #  ...and each test directory...
777  for OPTFILE in $OPTFILES ; do  for dir in $TESTDIRS ; do
778        
779        #  Cleanup only!
780        if test "x$CLEANUP" = xt ; then
781            if test -r $dir/build/Makefile ; then
782                ( cd $dir/build ; make CLEAN )
783            fi
784            if test -r $dir/input/Makefile ; then
785                ( cd $dir/input ; make CLEAN )
786            fi
787            continue
788        fi
789    
790        #  Verify that the testdir exists and contains previous
791        #  results in the correct location--or skip this directory!
792        fout=
793        if test "x$ADM" = x ; then
794            fout=$dir"/results/output.txt"
795        else
796            fout=$dir"/results_ad/output.txt_adm"
797        fi
798        if test ! -r $fout ; then
799            echo "can't read \"$fout\" -- skipping $dir"
800            continue
801        fi
802    
803      OPTFILE=`pwd`"/$OPTFILE"      builddir="input"
804      if test ! -r $OPTFILE ; then      rundir="input"
805          echo "Error: can't read optfile \"$OPTFILE\""      use_seperate_build=0
806          exit 1      if test -d $dir/build -a -r $dir/build ; then
807            builddir="build"
808            rundir="build"
809            use_seperate_build=1
810            linkdata $use_seperate_build $dir/$rundir
811      fi      fi
     echo  
     echo "OPTFILE=$OPTFILE" >> $SUMMARY  
     echo >> $SUMMARY  
812            
813      #  ...and each test directory...      #  Check whether there are "extra runs" for this testdir
814      for dir in $TESTDIRS ; do      extra_runs=
815                if test "x$ADM" = x -a "x$use_seperate_build" = x1 ; then
816          #  Create an output dir for each OPTFILE/tdir combination          ex_run_dirs=`( cd $dir ; echo input.* )`
817          CDIR=$DRESULTS"/"$DRESULTS"_"$NDIR          echo "ex_run_dirs='$ex_run_dirs'"
818          mkdir $CDIR          for exd in $ex_run_dirs ; do
819          CDIR=`pwd`"/$CDIR"              name=`echo $exd | sed -e 's/input.//g'`
820                outf="$dir/results/output.txt.$name"
821                if test -f $outf -a -r $outf ; then
822                    extra_runs="$extra_runs $name"
823                fi
824            done
825        fi
826    
827          #  ...configue, make, run, and compare the output.      if test "x$ADM" = x ; then
828          echo "-------------------------------------------------------------------------------"          code_dir=code
829          echo          CODE_DIR=$dir/code
830          echo "Experiment:  $dir"      else
831          echo          code_dir=code_ad
832          unset genmake makedepend make run          CODE_DIR=$dir/code_ad
833          results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --'      fi
834          ( cd $dir/input; rm -f *.{o,f,c,F} *.[f,F]90 work* output.txt Make* make.log; )      BUILD_DIR=$dir/$builddir
         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  
835    
836          #  Verify that the testdir exists and contains previous      if test ! -r $CODE_DIR"/SIZE.h_mpi" -a "x$MPI" = "xt" ; then
837          #  results in the correct location--or skip this directory!          echo "can't find \"$CODE_DIR/SIZE.h_mpi\" -- skipping $dir"
838          if test ! -r $dir"/results/output.txt" ; then          continue
839              echo | tee $SUMMARY      fi
840              echo "can't read \"$dir/results/output.txt\" -- skipping $dir" \  
841                  | tee $SUMMARY      echo "-------------------------------------------------------------------------------"
842              continue      echo
843          fi      echo "Experiment:  $dir"
844        echo
845        unset genmake makedepend make run
846        results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --'
847    
848        #  Create an output dir for each OPTFILE/tdir combination
849        rel_CDIR=$DRESULTS"/"$dir
850        mkdir $rel_CDIR
851        CDIR=`pwd`"/$rel_CDIR"
852        
853        if test "x$CLEANUP" = xt ; then
854            makeclean $dir/$builddir
855        else
856          genmakemodel $dir/$builddir && genmake=Y \          genmakemodel $dir/$builddir && genmake=Y \
857              && makeclean $dir/$builddir \              && makeclean $dir/$builddir \
858                && symlink_mpifiles $dir $code_dir $builddir \
859              && makedependmodel $dir/$builddir && makedepend=Y \              && makedependmodel $dir/$builddir && makedepend=Y \
860              && makemodel $dir/$builddir && make=Y \              && makemodel $dir/$builddir && make=Y \
861              && linkdata $seperatebuilddir $dir/$rundir \              && linkdata $use_seperate_build $dir/$rundir \
862              && runmodel $dir/$builddir mitgcmuv && run=Y \              && runmodel $dir/$rundir && run=Y \
863              && results=`testoutput $dir $rundir`              && results=`testoutput $dir $rundir`
864        fi
865        
866        echo
867        if test "x$ADM" = x ; then
868            fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results`
869          echo          echo
870          formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \          echo "$fres" >> $SUMMARY
871              ${run:-N} $results          echo "fresults='$fres'" > $CDIR"/summary.txt"
         echo  
         formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \  
             ${run:-N} $results >> $SUMMARY  
         echo "fresults='" > $CDIR"/summary.txt"  
         formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \  
             ${run:-N} $results >> $CDIR"/summary.txt"  
         echo "'" >> $CDIR"/summary.txt"  
872          echo "MACH='$MACH'" >> $CDIR"/summary.txt"          echo "MACH='$MACH'" >> $CDIR"/summary.txt"
873          echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"          echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"
874          echo "DATE='$DATE'" >> $CDIR"/summary.txt"          echo "DATE='$DATE'" >> $CDIR"/summary.txt"
875          echo "tdir='$dir'" >> $CDIR"/summary.txt"          echo "tdir='$dir'" >> $CDIR"/summary.txt"
876    
877          (          OLD_COMMAND=$COMMAND
878              cd $DRESULTS          COMMAND="./mitgcmuv > output.txt"
879              tar -cf $NDIR".tar" $DRESULTS"_"$NDIR > /dev/null 2>&1          for ex in $extra_runs ; do
880              gzip $NDIR".tar"              test -e "$dir/tr_run.$ex" && rm -rf "$dir/tr_run.$ex"
881          )              mkdir "$dir/tr_run.$ex"
882                links=`( cd "$dir/input" > /dev/null 2>&1 ; ls -1 | grep -v CVS )`
883                (
884                    cd "$dir/tr_run.$ex"
885                    for i in $links; do
886                        ln -s ../input/$i $i
887                    done
888                )
889                links=`( cd "$dir/input.$ex" > /dev/null 2>&1 ; ls -1 | grep -v CVS )`
890                (
891                    cd "$dir/tr_run.$ex"
892                    for i in $links; do
893                        test -e $i  &&  rm -f $i
894                        ln -s ../input.$ex/$i $i
895                    done
896                    ln -s ../$builddir/mitgcmuv mitgcmuv
897                )
898                runmodel $dir/tr_run.$ex && run=Y \
899                    && results=`testoutput $dir tr_run.$ex "."$ex`
900                fres=`printf '%s %s %s %s' ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N}`
901                fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results`
902                fres="$fres.$ex"
903                echo
904                echo "$fres" >> $SUMMARY
905                echo "fresults='$fres'" > $CDIR"/summary.txt"
906                echo "MACH='$MACH'" >> $CDIR"/summary.txt"
907                echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"
908                echo "DATE='$DATE'" >> $CDIR"/summary.txt"
909                echo "tdir='$dir'" >> $CDIR"/summary.txt"
910            done
911            COMMAND=$OLD_COMMAND
912        else
913            fres=`printf '%s %s %s %s' ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N}`
914            fres=$fres"$results   $dir"
915            echo
916            echo "$fres" >> $SUMMARY
917            echo "fresults='$fres'" > $CDIR"/summary.txt"
918            echo "MACH='$MACH'" >> $CDIR"/summary.txt"
919            echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"
920            echo "DATE='$DATE'" >> $CDIR"/summary.txt"
921            echo "tdir='$dir'" >> $CDIR"/summary.txt"
922        fi
923        
924        echo "-------------------------------------------------------------------------------"
925        
926    done
927    
928          $MPACK -s MITgcm-test -m 1000000 $DRESULTS"/"$NDIR".tar.gz" $ADDRESSES  printf "Start time:  " >> $SUMMARY
929    echo $start_date >> $SUMMARY
930    printf "End time:    " >> $SUMMARY
931    date >> $SUMMARY
932    
933    #  If addresses were supplied and mpack built successfully, then try
934    #  to send email using mpack.
935    if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then
936        echo "No results email was sent."
937    else
938        if test "x$HAVE_MPACK" = xt ; then
939            tar -cf $DRESULTS".tar" $DRESULTS > /dev/null 2>&1 \
940                && gzip $DRESULTS".tar" \
941                && $MPACK -s MITgcm-test -m 1500000 $DRESULTS".tar.gz" $ADDRESSES
942          RETVAL=$?          RETVAL=$?
943          if test "x$RETVAL" != x0 ; then          if test "x$RETVAL" != x0 ; then
944              echo "Warning: \"$MPACK\" failed -- please contact <edhill@mitgcm.org>"              echo
945                echo "Warning: The tar, gzip, & mpack step failed.  Please send email"
946                echo "  to <MITgcm-support@mitgcm.org> for help.  You may copy the "
947                echo "  summary of results from the directory \"$DRESULTS\"."
948                echo
949          else          else
950              rm -f $DRESULTS"/"$NDIR".tar*"              echo
951                echo "An email containing results was sent to the following addresses:"
952                echo "  \"$ADDRESSES\""
953                echo
954          fi          fi
955            test -f $DRESULTS".tar"  &&  rm -f $DRESULTS".tar"
956            test -f $DRESULTS".tar.gz"  &&  rm -f $DRESULTS".tar.gz"
957        fi
958    fi
959    
960          NDIR=$(( $NDIR + 1 ))  # rm -f tmp_cmpnum.f a.out
961            rm -f tmp_cmpnum.c tmp_cmpnum
     done  
 done  
962    
963  rm tmp_cmpnum.f a.out  if test "x$CLEANUP" != xt ; then
964        cat $SUMMARY
965        if test -e tr_out.txt ; then
966            mv tr_out.txt tr_out.txt.old
967        fi
968        cat $SUMMARY > tr_out.txt
969    fi
970    
971  cat $SUMMARY  if test "x$DELDIR" = xt ; then
972        rm -rf $DRESULTS
973    fi
974    

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

  ViewVC Help
Powered by ViewVC 1.1.22