/[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.45 by edhill, Sat Jul 17 02:08:45 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                #  Reduce the size of the testing emails!
240                #  cp Makefile $CDIR
241                if test "x$RETVAL" != x0 ; then
242                    tail make.log
243                    echo "genmakemodel: genmake failed" 1>&2
244                    cp genmake_* make.log $CDIR
245                    return 1
246                else
247                    echo "successful" 1>&2
248                fi
249            )
250        fi
251  }  }
252    
253  makeclean()  makeclean()
254  {  {
255      # makeclean directory      # makeclean directory
256      (      if test "x$NOCLEAN" = xt ; then
257          cd $1;          echo "make CLEAN skipped!"
258          rm -f output.txt      else
259          printf 'make CLEAN ... ' 2>&1          (
260          if test -r Makefile ; then              cd $1;
261              make CLEAN >> make.log 2>&1              if test -e output.txt ; then
262              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  
263              fi              fi
264          fi              printf 'make CLEAN ... ' 2>&1
265          echo succesful 1>&2              if test -r Makefile ; then
266          exit 0                  $MAKE CLEAN >> make.log 2>&1
267      )                  RETVAL=$?
268                    if test "x$RETVAL" != x0 ; then
269                        tail make.log
270                        echo "makeclean: \"make CLEAN\" failed" 1>&2
271                        cp make.log $CDIR"/make.log"
272                        return 1
273                    fi
274                fi
275                echo successful 1>&2
276                exit 0
277            )
278        fi
279  }  }
280    
281  makedependmodel()  makedependmodel()
282  {  {
283      # makedependmodel directory      # makedependmodel directory
284      (      if test "x$NODEPEND" = xt ; then
285          cd $1;          echo "make depend skipped!"
286          printf 'make depend ... ' 1>&2      else
287          make depend >> make.log 2>&1          (
288          RETVAL=$?              cd $1;
289          if test "x$RETVAL" != x0 ; then              printf 'make depend ... ' 1>&2
290              tail make.log              $MAKE depend >> make.log 2>&1
291              echo "makedependmodel: make depend failed" 1>&2              RETVAL=$?
292              cp make.log $CDIR"/make.log"              if test "x$RETVAL" != x0 ; then
293              return 1                  tail make.log
294          else                  echo "makedependmodel: make depend failed" 1>&2
295              echo succesful 1>&2                  cp make.log $CDIR"/make.log"
296          fi                  return 1
297      )              else
298                    echo successful 1>&2
299                fi
300            )
301        fi
302  }  }
303    
304  makemodel()  makemodel()
# Line 231  makemodel() Line 308  makemodel()
308          cd $1;          cd $1;
309          if test -r Makefile ; then          if test -r Makefile ; then
310              printf 'make ... ' 1>&2              printf 'make ... ' 1>&2
311              make >> make.log 2>&1              if test "x$ADM" = x ; then
312                    if test "x$JOBS" = x ; then
313                        $MAKE >> make.log 2>&1
314                    else
315                        $MAKE -j $JOBS >> make.log 2>&1
316                    fi
317                else
318                    $MAKE adall >> make.log 2>&1
319                fi
320              RETVAL=$?              RETVAL=$?
321              if test "x$RETVAL" != x0 ; then              if test "x$RETVAL" != x0 ; then
322                  tail make.log                  tail make.log
# Line 239  makemodel() Line 324  makemodel()
324                  cp make.log $CDIR"/make.log"                  cp make.log $CDIR"/make.log"
325                  return 1                  return 1
326              else              else
327                  echo succesful 1>&2                  echo successful 1>&2
328              fi              fi
329          fi          fi
330      )      )
331  }  }
332    
333    symlink_mpifiles()
334    {
335        # Put special links so that MPI specific files are used
336        # This MUST be invoked between makeclean and makelinks because
337        # the Makefile will link to non-mpi files by default
338    
339        dir=$1
340        code_dir=$2
341        BUILD_DIR=$dir/$3
342        CODE_DIR=$dir/$code_dir
343        
344        # These are files that should replace their counter-part when using -mpi
345        MPI_FILES=`(cd $CODE_DIR; find . -name "*_mpi")`
346    
347        #  Is this an MPI run?
348        if test "x$MPI" = xt ; then
349            # YES: We symbolically link these files to the build
350            # dir so long as there is no real file in place
351            for ii in $MPI_FILES ; do
352                i=`echo $ii | sed 's:^\./::'`
353                name=`echo $i | sed 's:_mpi::' `
354                cmp $CODE_DIR/$i $BUILD_DIR/$name > /dev/null 2>&1
355                RETVAL=$?
356                if test "x$RETVAL" != x0 ; then
357                    if ! test -f $BUILD_DIR/$i ; then
358                        #echo Linking $name to $i
359                        (cd $BUILD_DIR; ln -sf ../$code_dir/$i $name)
360                    fi
361                fi
362            done
363        else
364            # NO: We undo any _mpi symbolically linked files
365            for ii in $MPI_FILES ; do
366                i=`echo $ii | sed 's:^\./::'`
367                name=`echo $i | sed 's:_mpi::' `
368                if test -L $BUILD_DIR/$name ; then
369                    cmp $BUILD_DIR/$name "../$code_dir/$name"_mpi > /dev/null 2>&1
370                    RETVAL=$?
371                    if test "x$RETVAL" = x0 ; then
372                        #echo Un-linking $name from $linktarg
373                        rm -f $BUILD_DIR/$name
374                    fi
375                fi
376            done
377        fi
378        
379    }
380    
381  linkdata()  linkdata()
382  {  {
383      # linkdata flag      # linkdata flag
384      #      #
385      # symbolically link data files to run directory      # symbolically link data files to run directory
386      if [ $1 -ne 0 ]; then      if test "x$1" = x1 ; then
387          ( cd $2 ;  ln -sf ../input/* . )          (
388                cd $2
389                if test "x$ADM" = x ; then
390                    files=`( cd ../input ; ls -1 | grep -v CVS )`
391                    for i in $files ; do
392                        if test ! -d "../input/"$i ; then
393                            ln -sf "../input/"$i $i
394                        fi
395                    done
396                else
397                    files=`( cd ../input ; ls -1 *.bin | grep -v CVS )`
398                    for i in $files ; do
399                        if test ! -d "../input/"$i ; then
400                            ln -sf "../input/"$i $i
401                        fi
402                    done
403                    files=`( cd ../input_ad ; ls -1 | grep -v CVS )`
404                    for i in $files ; do
405                        if test ! -d "../input_ad/"$i ; then
406                            ln -sf "../input_ad/"$i $i
407                        fi
408                    done
409                fi
410            )
411      fi      fi
412  }  }
413    
414  runmodel()  runmodel()
415  {  {
416      # runmodel directory exe      # runmodel directory
417      #      #
418      #  runs the model "exe" in "directory" (exe is relative to directory)      #  runs "$COMMAND in "directory"
419        #  (where "$COMMAND" is relative to "directory")
420      (      (
421          cd $1          cd $1
422          if [ -x $2 ]; then          printf 'runmodel ... ' 1>&2
423              if [ $quick -eq 0 ]; then          # make output.txt
424                  rm -f output.txt          echo
425              fi          # echo "COMMAND='$COMMAND'"
426              printf 'runmodel: ' 1>&2          # echo "pwd='"`pwd`"'"
427              make output.txt          ( eval $COMMAND ) >> run.log 2>&1
428              RETVAL=$?          RETVAL=$?
429              if test "x$RETVAL" = x0 ; then          if test "x$RETVAL" = x0 ; then
430                  cp output.txt $CDIR"/output.txt"              echo successful 1>&2
431                  return 0              # === Reduce the size of the testing emails!
432              else              # if test "x$ADM" = x ; then
433                  return 1              #   cp output.txt $CDIR"/output.txt"
434              fi              # else
435                #   cp output.txt_adm $CDIR"/output.txt_adm"
436                # fi
437                return 0
438            else
439                tail run.log
440                echo failed 1>&2
441                cp run.log $CDIR"/run.log"
442                return 1
443          fi          fi
444      )      )
445  }  }
# Line 283  createcodelet() Line 448  createcodelet()
448  {  {
449      # create codelet for comparing model output      # create codelet for comparing model output
450    
451      echo -n "creating the comparison code...  "      printf "creating the comparison code...  "
452      cat > tmp_cmpnum.f <<EOFA      cat > tmp_cmpnum.c <<EOF
453        program cmpnum  #include <stdio.h>
454        implicit none  #include <math.h>
455        real*8 a,b,diff  int main( int argc, char** argv )  {
456        integer linnum,best    int linnum,best,lncnt;
457        best=-16    double a,b,diff;
458    99  read(*,*,end=70,err=60) linnum,a,b    best = -16;
459        diff=0.5*(abs(a)+abs(b))    lncnt = 0;
460  c     print *,a,b,diff,abs(a-b)/diff    while( 1 & (lncnt+=1) < 999 )  {
461        if (diff.gt.1.e-12) then      scanf("%d", &linnum);
462          diff=abs(a-b)/diff      if (linnum == -1)  break;
463          if (diff.gt.0.) then      scanf("%lf", &a);  scanf("%lf", &b);
464  c         print *,int(log10(diff)),diff      diff = 0.5*(fabs(a)+fabs(b));
465            linnum=int(log10(diff))      if (diff > 1.e-12) {
466            best=max(best,linnum)        diff=fabs(a-b)/diff;
467          endif        if (diff > 0.0) {
468        else          linnum = (int)log10(diff);
469          if (best.eq.-16.and.diff.ne.0.) best=-22          best = (best > linnum) ? best : linnum;
470        endif        }
471        goto 99        else {
472    60  stop 'cmpnum: An error occured reading a,b'          if (best == -16 && diff != 0)  best = -22;
473    70  print *,-best        }
474        end      }
475  EOFA    }
476      if (lncnt == 999) best=-29;
477      printf("%d\n", -best);
478      return 0;
479    }
480    EOF
481        cc -o tmp_cmpnum tmp_cmpnum.c -lm
482    
483      f77 tmp_cmpnum.f      if [ -x ./tmp_cmpnum ]; then
     if [ -x ./a.out ]; then  
484          echo "OK"          echo "OK"
485          return 0          return 0
486      else      else
487          echo          echo
488          echo "createcodelet: failed to compile codelet" | tee          echo "ERROR: failed to compile comparison code"
489          exit 1          exit 1
490      fi      fi
491  }  }
# Line 347  show_help() Line 517  show_help()
517  {  {
518      cat - << EOF      cat - << EOF
519  $0 [-help] [-quick] [-verbose] dir1 [dir2] [...]  $0 [-help] [-quick] [-verbose] dir1 [dir2] [...]
520   -help      Show this help message  
521   -quick     Skip "genmake" and "make depend" if the Makefile exists   -help|-h      Show this help message
522   -quiet     Reduce the amount of output   -quiet     Reduce the amount of output
523   -verbose   Produce copious amounts of output   -verbose   Produce copious amounts of output
524   -debug     Produce even more output which will mean nothing to most   -debug     Produce even more output which will mean nothing to most
525   -force     Do "make CLEAN" before compiling. This forces a complete rebuild.   -force     Do "make CLEAN" before compiling. This forces a complete rebuild.
526   -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.  
527   -cleanup   Aggresively removes all model output, executables and object files   -cleanup   Aggresively removes all model output, executables and object files
528              and then exits. Use with care.              and then exits. Use with care.
529    
# Line 376  scandirs() Line 545  scandirs()
545    
546    
547  ###############################################################################  ###############################################################################
 ###############################################################################  
 ###############################################################################  
548    
549    
550  #  Default properties  #  Default properties
551  debug=0  debug=0
552  verbose=1  verbose=1
 quick=0  
553  clean=0  clean=0
 ieee=1  
554  expts=''  expts=''
555    # ieee=1
556    
557    IEEE=true
558    if test "x$MITGCM_IEEE" != x ; then
559        IEEE=$MITGCM_IEEE
560    fi
561    
562    
563  OPTFILES=  CLEANUP=f
564  ADDRESSES=edhill@mitgcm.org  QUICK=f
565    NOGENMAKE=f
566    NOCLEAN=f
567    NODEPEND=f
568    
569    BASH=
570    OPTFILE=NONE
571    ADDRESSES=
572  TESTDIRS=  TESTDIRS=
573  MPACKDIR="../tools/mpack-1.6"  MPACKDIR="../tools/mpack-1.6"
574    HAVE_MPACK=
575  MPACK="$MPACKDIR/mpack"  MPACK="$MPACKDIR/mpack"
576    COMMAND=
577    MAKE=make
578    JOBS=
579    MPI=f
580    DELDIR=
581    
582    ADM=
583    
584  echo -n "parsing options...  "  printf "parsing options...  "
585    
586  ac_prev=  ac_prev=
587  for ac_option ; do  for ac_option ; do
# Line 414  for ac_option ; do Line 601  for ac_option ; do
601              usage ;;              usage ;;
602                    
603          -optfile | --optfile | -of | --of)          -optfile | --optfile | -of | --of)
604              ac_prev=OPTFILES ;;              ac_prev=OPTFILE ;;
605          -optfile=* | --optfile=* | -of=* | --of=*)          -optfile=* | --optfile=* | -of=* | --of=*)
606              OPTFILES=$ac_optarg ;;              OPTFILE=$ac_optarg ;;
607                    
608          -addr | --addr | -a | --a)          -addr | --addr | -a | --a)
609              ac_prev=ADDRESSES ;;              ac_prev=ADDRESSES ;;
# Line 428  for ac_option ; do Line 615  for ac_option ; do
615          -tdir=* | --tdir=*)          -tdir=* | --tdir=*)
616              TESTDIRS=$ac_optarg ;;              TESTDIRS=$ac_optarg ;;
617    
618          -quick) quick=1 ;;          -bash | --bash | -b | --b)
619                ac_prev=BASH ;;
620            -bash=* | --bash=*)
621                BASH=$ac_optarg ;;
622    
623            -command | --command | -c | --c)
624                ac_prev=COMMAND ;;
625            -command=* | --command=*)
626                COMMAND=$ac_optarg ;;
627    
628            -make | --make | -m | --m)
629                ac_prev=MAKE ;;
630            -make=* | --make=*)
631                MAKE=$ac_optarg ;;
632    
633            -j) ac_prev=JOBS ;;
634            -j=*) JOBS=$ac_optarg ;;
635    
636            -clean | --clean)
637                CLEANUP=t ;;
638    
639            -quick | --quick | -q | --q)
640                QUICK=t ;;
641            -nogenmake | --nogenmake | -ng | --ng)
642                NOGENMAKE=t ;;
643            -noclean | --noclean | -nc | --nc)
644                NOCLEAN=t ;;
645            -nodepend | --nodepend | -nd | --nd)
646                NODEPEND=t ;;
647    
648            -mpi) MPI=t ;;
649    
650            -adm | -ad) ADM=t ;;
651    
652            -ieee) IEEE=true ;;
653            -noieee) IEEE= ;;
654    
655          -verbose) verbose=2 ;;          -verbose) verbose=2 ;;
656          -debug) debug=1 ;;          -debug) debug=1 ;;
         -clean) clean=1 ;;  
         -noieee) ieee=0 ;;  
657          -quiet) verbose=0 ;;          -quiet) verbose=0 ;;
658    
659            -deldir | -dd) DELDIR=t ;;
660    
661          -*)          -*)
662              echo "Error: unrecognized option: "$ac_option              echo "Error: unrecognized option: "$ac_option
663              usage              usage
# Line 449  for ac_option ; do Line 672  for ac_option ; do
672            
673  done  done
674    
675    if test "x$QUICK" = xt ; then
676        NOGENMAKE=t
677        NOCLEAN=t
678        NODEPEND=t
679    fi
680    
681  if test "x$TESTDIRS" = x ; then  if test "x$TESTDIRS" = x ; then
682      TESTDIRS=`scandirs`      TESTDIRS=`scandirs`
683  fi  fi
684    
685    if test "x$OPTFILE" = xNONE -a "x$MITGCM_OF" != x ; then
686        OPTFILE=$MITGCM_OF
687    fi
688    
689    if test "x$ADM" = xt -a "x$COMMAND" = x ; then
690        COMMAND="./mitgcmuv_ad > output.txt_adm 2>&1"
691    fi
692    
693    if test "x$COMMAND" = x ; then
694        COMMAND="$MAKE output.txt"
695    fi
696    
697  echo "OK"  echo "OK"
698    
699  #  create the FORTRAN comparison code  #  create the FORTRAN comparison code
700  createcodelet  createcodelet
701    
702  #  build the mpack utility  #  build the mpack utility
703  build_mpack  if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then
704        echo "skipping mpack build"
705    else
706        build_mpack
707    fi
708    
709  #  Create a uniquely named directory to store results  #  Create a uniquely named directory to store results
710  MACH=`hostname`  MACH=`hostname`
711  UNAMEA=`uname -a`  UNAMEA=`uname -a`
712  DATE=`date +%Y%m%d`  DATE=`date +%Y%m%d`
713  BASE=$MACH"_"$DATE"_"  BASE="tr_"$MACH"_"$DATE"_"
714  DNUM=0  DNUM=0
715  DRESULTS="$BASE$DNUM"  DRESULTS="$BASE$DNUM"
716  while test -e $DRESULTS ; do  while test -e $DRESULTS ; do
# Line 475  done Line 720  done
720  mkdir $DRESULTS  mkdir $DRESULTS
721  RETVAL=$?  RETVAL=$?
722  if test "x$RETVAL" != x0 ; then  if test "x$RETVAL" != x0 ; then
723      echo "Error: can't create results directory \"./$DRESULTS\""      echo "ERROR: Can't create results directory \"./$DRESULTS\""
724      exit 1      exit 1
725  fi  fi
726  SUMMARY="$DRESULTS/summary.txt"  SUMMARY="$DRESULTS/summary.txt"
727  date > $SUMMARY  printf "Start time:  " >> $SUMMARY
728  cat << EOF >> $SUMMARY  start_date=`date`
729    echo $start_date > $SUMMARY
730    
731    of_path=
732    if test "x$OPTFILE" != xNONE ; then
733        if test -r $OPTFILE ; then
734            # get the path
735            path=${OPTFILE%/*}
736            if test "x$path" = x ; then
737                of_path=`pwd`
738            else
739                of_path=`( cd $path > /dev/null 2>&1 ; pwd )`
740            fi
741            file=${OPTFILE##*/}
742            OPTFILE=$of_path/$file
743            cp $OPTFILE $DRESULTS
744            echo >> $SUMMARY
745            echo "  OPTFILE=$OPTFILE" >> $SUMMARY
746        else
747            echo | tee $SUMMARY
748            echo "ERROR: can't read OPTFILE=\"$OPTFILE\"" | tee $SUMMARY
749            exit 1
750        fi
751    else
752        echo >> $SUMMARY
753        echo "No \"OPTFILE\" was explicitly specified by testreport," >> $SUMMARY
754        echo "   so the genmake default will be used." >> $SUMMARY
755    fi
756    echo
757    echo >> $SUMMARY
758    if test "x$ADM" = x ; then
759        cat << EOF | tee -a $SUMMARY
760                  T           S           U           V                  T           S           U           V
761  G D M    c        m  s        m  s        m  s        m  s  G D M    c        m  s        m  s        m  s        m  s
762  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 764  N n k u  2  i  a  a  d  i  a  a  d  i  a
764  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  .
765    
766  EOF  EOF
767    else
768        echo "ADJOINT=true" >> $SUMMARY
769        echo >> $SUMMARY
770        cat << EOF | tee -a $SUMMARY
771    G D M    C  G
772    E p a R  o  r
773    N n k u  s  a
774    2 d e n  t  d
775    
776  NDIR=0  EOF
777    fi
778    
779  #  For each optfile...  #  ...and each test directory...
780  for OPTFILE in $OPTFILES ; do  for dir in $TESTDIRS ; do
781        
782        #  Cleanup only!
783        if test "x$CLEANUP" = xt ; then
784            if test -r $dir/build/Makefile ; then
785                ( cd $dir/build ; make CLEAN )
786            fi
787            if test -r $dir/input/Makefile ; then
788                ( cd $dir/input ; make CLEAN )
789            fi
790            continue
791        fi
792    
793        #  Verify that the testdir exists and contains previous
794        #  results in the correct location--or skip this directory!
795        fout=
796        if test "x$ADM" = x ; then
797            fout=$dir"/results/output.txt"
798        else
799            fout=$dir"/results_ad/output.txt_adm"
800        fi
801        if test ! -r $fout ; then
802            echo "can't read \"$fout\" -- skipping $dir"
803            continue
804        fi
805    
806      OPTFILE=`pwd`"/$OPTFILE"      builddir="input"
807      if test ! -r $OPTFILE ; then      rundir="input"
808          echo "Error: can't read optfile \"$OPTFILE\""      use_seperate_build=0
809          exit 1      if test -d $dir/build -a -r $dir/build ; then
810            builddir="build"
811            rundir="build"
812            use_seperate_build=1
813            linkdata $use_seperate_build $dir/$rundir
814      fi      fi
     echo  
     echo "OPTFILE=$OPTFILE" >> $SUMMARY  
     echo >> $SUMMARY  
815            
816      #  ...and each test directory...      #  Check whether there are "extra runs" for this testdir
817      for dir in $TESTDIRS ; do      extra_runs=
818                if test "x$ADM" = x -a "x$use_seperate_build" = x1 ; then
819          #  Create an output dir for each OPTFILE/tdir combination          ex_run_dirs=`( cd $dir ; echo input.* )`
820          CDIR=$DRESULTS"/"$DRESULTS"_"$NDIR          echo "ex_run_dirs='$ex_run_dirs'"
821          mkdir $CDIR          for exd in $ex_run_dirs ; do
822          CDIR=`pwd`"/$CDIR"              name=`echo $exd | sed -e 's/input.//g'`
823                outf="$dir/results/output.txt.$name"
824                if test -f $outf -a -r $outf ; then
825                    extra_runs="$extra_runs $name"
826                fi
827            done
828        fi
829    
830          #  ...configue, make, run, and compare the output.      if test "x$ADM" = x ; then
831          echo "-------------------------------------------------------------------------------"          code_dir=code
832          echo          CODE_DIR=$dir/code
833          echo "Experiment:  $dir"      else
834          echo          code_dir=code_ad
835          unset genmake makedepend make run          CODE_DIR=$dir/code_ad
836          results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --'      fi
837          ( 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  
838    
839          #  Verify that the testdir exists and contains previous      if test ! -r $CODE_DIR"/SIZE.h_mpi" -a "x$MPI" = "xt" ; then
840          #  results in the correct location--or skip this directory!          echo "can't find \"$CODE_DIR/SIZE.h_mpi\" -- skipping $dir"
841          if test ! -r $dir"/results/output.txt" ; then          continue
842              echo | tee $SUMMARY      fi
843              echo "can't read \"$dir/results/output.txt\" -- skipping $dir" \  
844                  | tee $SUMMARY      echo "-------------------------------------------------------------------------------"
845              continue      echo
846          fi      echo "Experiment:  $dir"
847        echo
848        unset genmake makedepend make run
849        results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --'
850    
851        #  Create an output dir for each OPTFILE/tdir combination
852        rel_CDIR=$DRESULTS"/"$dir
853        mkdir $rel_CDIR
854        CDIR=`pwd`"/$rel_CDIR"
855        
856        if test "x$CLEANUP" = xt ; then
857            makeclean $dir/$builddir
858        else
859          genmakemodel $dir/$builddir && genmake=Y \          genmakemodel $dir/$builddir && genmake=Y \
860              && makeclean $dir/$builddir \              && makeclean $dir/$builddir \
861                && symlink_mpifiles $dir $code_dir $builddir \
862              && makedependmodel $dir/$builddir && makedepend=Y \              && makedependmodel $dir/$builddir && makedepend=Y \
863              && makemodel $dir/$builddir && make=Y \              && makemodel $dir/$builddir && make=Y \
864              && linkdata $seperatebuilddir $dir/$rundir \              && linkdata $use_seperate_build $dir/$rundir \
865              && runmodel $dir/$builddir mitgcmuv && run=Y \              && runmodel $dir/$rundir && run=Y \
866              && results=`testoutput $dir $rundir`              && results=`testoutput $dir $rundir`
867        fi
868        
869        echo
870        if test "x$ADM" = x ; then
871            fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results`
872          echo          echo
873          formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \          echo "$fres" >> $SUMMARY
874              ${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"  
875          echo "MACH='$MACH'" >> $CDIR"/summary.txt"          echo "MACH='$MACH'" >> $CDIR"/summary.txt"
876          echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"          echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"
877          echo "DATE='$DATE'" >> $CDIR"/summary.txt"          echo "DATE='$DATE'" >> $CDIR"/summary.txt"
878          echo "tdir='$dir'" >> $CDIR"/summary.txt"          echo "tdir='$dir'" >> $CDIR"/summary.txt"
879    
880          (          OLD_COMMAND=$COMMAND
881              cd $DRESULTS          COMMAND="./mitgcmuv > output.txt"
882              tar -cf $NDIR".tar" $DRESULTS"_"$NDIR > /dev/null 2>&1          for ex in $extra_runs ; do
883              gzip $NDIR".tar"              test -e "$dir/tr_run.$ex" && rm -rf "$dir/tr_run.$ex"
884          )              mkdir "$dir/tr_run.$ex"
885                links=`( cd "$dir/input" > /dev/null 2>&1 ; ls -1 | grep -v CVS )`
886                (
887                    cd "$dir/tr_run.$ex"
888                    for i in $links; do
889                        ln -s ../input/$i $i
890                    done
891                )
892                links=`( cd "$dir/input.$ex" > /dev/null 2>&1 ; ls -1 | grep -v CVS )`
893                (
894                    cd "$dir/tr_run.$ex"
895                    for i in $links; do
896                        test -e $i  &&  rm -f $i
897                        ln -s ../input.$ex/$i $i
898                    done
899                    ln -s ../$builddir/mitgcmuv mitgcmuv
900                )
901                runmodel $dir/tr_run.$ex && run=Y \
902                    && results=`testoutput $dir tr_run.$ex "."$ex`
903                fres=`printf '%s %s %s %s' ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N}`
904                fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results`
905                fres="$fres.$ex"
906                echo
907                echo "$fres" >> $SUMMARY
908                echo "fresults='$fres'" > $CDIR"/summary.txt"
909                echo "MACH='$MACH'" >> $CDIR"/summary.txt"
910                echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"
911                echo "DATE='$DATE'" >> $CDIR"/summary.txt"
912                echo "tdir='$dir'" >> $CDIR"/summary.txt"
913            done
914            COMMAND=$OLD_COMMAND
915        else
916            fres=`printf '%s %s %s %s' ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N}`
917            fres=$fres"$results   $dir"
918            echo
919            echo "$fres" >> $SUMMARY
920            echo "fresults='$fres'" > $CDIR"/summary.txt"
921            echo "MACH='$MACH'" >> $CDIR"/summary.txt"
922            echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"
923            echo "DATE='$DATE'" >> $CDIR"/summary.txt"
924            echo "tdir='$dir'" >> $CDIR"/summary.txt"
925        fi
926        
927        echo "-------------------------------------------------------------------------------"
928        
929    done
930    
931          $MPACK -s MITgcm-test -m 1000000 $DRESULTS"/"$NDIR".tar.gz" $ADDRESSES  printf "Start time:  " >> $SUMMARY
932    echo $start_date >> $SUMMARY
933    printf "End time:    " >> $SUMMARY
934    date >> $SUMMARY
935    
936    #  If addresses were supplied and mpack built successfully, then try
937    #  to send email using mpack.
938    if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then
939        echo "No results email was sent."
940    else
941        if test "x$HAVE_MPACK" = xt ; then
942            tar -cf $DRESULTS".tar" $DRESULTS > /dev/null 2>&1 \
943                && gzip $DRESULTS".tar" \
944                && $MPACK -s MITgcm-test -m 3555000 $DRESULTS".tar.gz" $ADDRESSES
945          RETVAL=$?          RETVAL=$?
946          if test "x$RETVAL" != x0 ; then          if test "x$RETVAL" != x0 ; then
947              echo "Warning: \"$MPACK\" failed -- please contact <edhill@mitgcm.org>"              echo
948                echo "Warning: The tar, gzip, & mpack step failed.  Please send email"
949                echo "  to <MITgcm-support@mitgcm.org> for help.  You may copy the "
950                echo "  summary of results from the directory \"$DRESULTS\"."
951                echo
952          else          else
953              rm -f $DRESULTS"/"$NDIR".tar*"              echo
954                echo "An email containing results was sent to the following addresses:"
955                echo "  \"$ADDRESSES\""
956                echo
957          fi          fi
958            test -f $DRESULTS".tar"  &&  rm -f $DRESULTS".tar"
959            test -f $DRESULTS".tar.gz"  &&  rm -f $DRESULTS".tar.gz"
960        fi
961    fi
962    
963          NDIR=$(( $NDIR + 1 ))  # rm -f tmp_cmpnum.f a.out
964            rm -f tmp_cmpnum.c tmp_cmpnum
     done  
 done  
965    
966  rm tmp_cmpnum.f a.out  if test "x$CLEANUP" != xt ; then
967        cat $SUMMARY
968        if test -e tr_out.txt ; then
969            mv tr_out.txt tr_out.txt.old
970        fi
971        cat $SUMMARY > tr_out.txt
972    fi
973    
974  cat $SUMMARY  if test "x$DELDIR" = xt ; then
975        rm -rf $DRESULTS
976    fi
977    

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

  ViewVC Help
Powered by ViewVC 1.1.22