/[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.70 by jmc, Thu Jul 28 21:12:15 2005 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 "  (-odir) STRING           used to build output directory name"
31        echo "                             (DEF=\"hostname\")"
32        echo "  (-ptracers|-ptr) STRING  specify which ptracers to test"
33        echo "                             (DEF=\"1 2 3 4 5\")"
34        echo "  (-j) JOBS                use \"make -j JOBS\" for parallel builds"
35        echo "  (-clean)                 *ONLY* run \"make CLEAN\""
36        echo "  (-quick|-q)              same as \"-nogenmake -noclean -nodepend\""
37        echo "  (-nogenmake|-ng)         skip the genmake stage"
38        echo "  (-noclean|-nc)           skip the \"make clean\" stage"
39        echo "  (-nodepend|-nd)          skip the \"make depend\" stage"
40        echo "  (-deldir|-dd)            on success, delete the output directory"
41        echo
42        echo "and where STRING can be a whitespace-delimited list"
43        echo "such as:"
44        echo
45        echo "  -t 'exp0 exp2 exp3' "
46        echo "  -addr='abc@123.com testing@home.org'"
47        echo
48        echo "provided that the expression is properly quoted within the current"
49        echo "shell (note the use of single quotes to protect white space)."
50      echo      echo
51      exit 1      exit 1
52  }  }
# Line 20  usage() Line 54  usage()
54  #  build the mpack utility  #  build the mpack utility
55  build_mpack()  build_mpack()
56  {  {
57      echo -n "building the mpack utility...  "      printf "building the mpack utility...  "
58      if test ! -x "$MPACKDIR/mpack" ; then      if test ! -x "$MPACKDIR/mpack" ; then
59          if test ! -d $MPACKDIR ; then          if test ! -d $MPACKDIR ; then
60                echo
61              echo "Error: can't find \"$MPACKDIR\""              echo "Error: can't find \"$MPACKDIR\""
62              echo "  are you sure this program is being run in the correct "              echo "  are you sure this program is being run in the correct "
63              echo "  (that is, \"MITGCM_ROOT\verification\") directory?"              echo "  (that is, \"MITGCM_ROOT\verification\") directory?"
64              exit 1              echo
65                HAVE_MPACK=f
66            fi
67            printf "building mpack...  "
68            if test "x$CC" = x ; then
69                export CC=cc
70          fi          fi
71          echo -n "building mpack...  "          ( cd $MPACKDIR && ./configure && $MAKE ) > tr_build_mpack.out 2>&1
         ( cd $MPACKDIR && ./configure && make ) > build_mpack.out 2>&1  
72          RETVAL=$?          RETVAL=$?
73          if test "x$RETVAL" != x0 ; then          if test "x$RETVAL" != x0 ; then
74              echo              echo
75              echo "Error building the mpack tools at: $MPACK_DIR"              echo "Error building the mpack tools at: $MPACK_DIR"
76              exit 1              echo
77                HAVE_MPACK=f
78            else
79                rm -f tr_build_mpack.out
80                HAVE_MPACK=t
81          fi          fi
82        else
83            HAVE_MPACK=t
84      fi      fi
85      echo "OK"      echo "OK"
86  }  }
87    
 compare_lines()  
 {  
     # use codelet to compare lines  
     if [ $verbose -gt 1 ]; then  
         cat tmp3.txt 1>&2  
     fi  
     return `./a.out < tmp3.txt`  
 }  
   
88  testoutput_for_prop()  testoutput_for_prop()
89  {  {
90      # testoutput_for_prop dir s1 label subdir      # testoutput_for_prop dir s1 label subdir extension
91      #      #
92      #  compares files in $dir/$subdir/output.txt and $dir/results/output.txt      #  compares files in $dir/$subdir/output.txt and $dir/results/output.txt
93      #  using search strings s1 and text label      #  using search strings s1 and text label
# Line 60  testoutput_for_prop() Line 96  testoutput_for_prop()
96          echo testoutput_for_prop: grep "$2" $1/$4/output.txt 1>&2          echo testoutput_for_prop: grep "$2" $1/$4/output.txt 1>&2
97      fi      fi
98      if [ -r $1/$4/output.txt ]; then      if [ -r $1/$4/output.txt ]; then
99          grep "$2" $1/$4/output.txt | sed 's/.*=//' | nl > tmp1.txt          grep "$2" $1/$4/output.txt | sed 's/.*=//' | cat -n > tmp1.txt
100          lncnt=`wc -l tmp1.txt | awk '{print $1}' `          lncntA=`wc -l tmp1.txt | awk '{print $1}' `
101          if [ $lncnt -lt 3 ]; then          if [ $lncntA -lt 3 ]; then
102              if [ $verbose -gt 0 ]; then              if [ $verbose -gt 0 ]; then
103                  echo Not enough lines of output when searching for "$2" 1>&2                  echo Not enough lines of output when searching for "$2" 1>&2
104              fi              fi
# Line 73  testoutput_for_prop() Line 109  testoutput_for_prop()
109          return 99          return 99
110      fi      fi
111      if [ $debug -gt 0 ]; then      if [ $debug -gt 0 ]; then
112          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
113      fi      fi
114      grep "$2" $1/results/output.txt | sed 's/.*=//' | nl > tmp2.txt      grep "$2" $1/results/output.txt$5 | sed 's/.*=//' | cat -n > tmp2.txt
115      lncnt=`wc -l tmp2.txt | awk '{print $1}' `      lncntB=`wc -l tmp2.txt | awk '{print $1}' `
116      if [ $lncnt -lt 3 ]; then      if [ $lncntB -lt 3 ]; then
117          if [ $verbose -gt 0 ]; then          if [ $verbose -gt 0 ]; then
118              echo Not enough lines of output when searching for "$2" 1>&2              echo Not enough lines of output when searching for "$2" 1>&2
119          fi          fi
120          return 99          return 99
121      fi      fi
122        if [ $lncntA -ne $lncntB ]; then
123            if [ $verbose -gt 0 ]; then
124                echo Not same Nb of lines when searching for "$2" ":" $lncntA $lncntB 1>&2
125            fi
126            return 99
127        fi
128      if [ $debug -gt 0 ]; then      if [ $debug -gt 0 ]; then
129          echo testoutput_for_prop: join tmp1.txt tmp2.txt 1>&2          echo testoutput_for_prop: join tmp1.txt tmp2.txt 1>&2
130      fi      fi
# Line 90  testoutput_for_prop() Line 132  testoutput_for_prop()
132      if [ $debug -gt 0 ]; then      if [ $debug -gt 0 ]; then
133          echo testoutput_for_prop: compare_lines 1>&2          echo testoutput_for_prop: compare_lines 1>&2
134      fi      fi
135      compare_lines      if [ $verbose -gt 1 ]; then
136      digits_of_similarity=$?          cat tmp3.txt 1>&2
137        fi
138        echo "-1" >> tmp3.txt
139        # On the SGI O3K (*not* the O2K), "cat -n" inserts a ":" after the line number
140        cat tmp3.txt | sed -e 's|:||g' > tmp4.txt
141        digits_of_similarity=`./tmp_cmpnum < tmp4.txt`
142      if [ $digits_of_similarity -eq 99 ]; then      if [ $digits_of_similarity -eq 99 ]; then
143          if [ $verbose -gt 0 ]; then          if [ $verbose -gt 0 ]; then
144              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 149  testoutput_for_prop()
149              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
150          fi          fi
151      fi      fi
152      rm tmp1.txt tmp2.txt tmp3.txt      rm -f tmp1.txt tmp2.txt tmp3.txt tmp4.txt
153            
154      return $digits_of_similarity      return $digits_of_similarity
155  }  }
# Line 122  dashnum() Line 169  dashnum()
169      done      done
170  }  }
171    
172    testoutput_ad()
173    {
174        grep $3 $1/results_ad/output.txt_adm | awk '{print NR " " $5}' > t05.txt
175        grep $3 $1/$2/output.txt_adm | awk '{print NR " " $5}' > t15.txt
176        grep $3 $1/results_ad/output.txt_adm | awk '{print NR " " $6}' > t06.txt
177        grep $3 $1/$2/output.txt_adm | awk '{print NR " " $6}' > t16.txt
178        join t05.txt t15.txt > t5.txt
179        join t06.txt t16.txt > t6.txt
180        echo "-1" >> t5.txt
181        echo "-1" >> t6.txt
182        digits_5=`./tmp_cmpnum < t5.txt`
183        digits_6=`./tmp_cmpnum < t6.txt`
184        dashnum $digits_5 $digits_6
185        rm -f t[01][56].txt t[56].txt
186    }
187    
188    check_for_add_mon_output()
189    {
190        # Check for additional types of monitor output
191        if test "x$1" = x ; then
192            return
193        fi
194    
195        for ii in $PTRACERS_NUM ; do
196            eval "HAVE_PTR0"$ii"=f"
197        done
198    
199        ptr_add="trcstat_ptracerXX_min trcstat_ptracerXX_max"
200        ptr_add="$ptr_add trcstat_ptracerXX_mean trcstat_ptracerXX_sd"
201        for ii in $PTRACERS_NUM ; do
202            for jj in $ptr_add ; do
203                name=`eval "echo $jj | sed -e 's|XX|0"$ii"|g'"`
204                tst=`grep $name $1 | wc -l | awk '{print $1}'`
205                if test ! "x$tst" = x0 ; then
206                    eval "HAVE_PTR0"$ii"=t"
207                fi
208            done
209            #  eval 'echo "HAVE_PTR0'$ii' = $HAVE_PTR0'$ii'"'
210        done
211    }
212    
213  testoutput()  testoutput()
214  {  {
215      # testoutput diretory subdir      # testoutput directory subdir extension
216      #      #
217      #  test output in "directory"      #  test output in "directory"
218        if test "x$ADM" = x ; then
219            if [ $debug -gt 0 ]; then
220                echo testoutput: testoutput_for_prop $1 cg2d_init_res 1>&2
221            fi
222            testoutput_for_prop $1 "cg2d_init_res" "cg2d init. residual" $2 $3; cg2dres=$?
223            if [ $debug -gt 0 ]; then
224                echo testoutput: cg2dres=$cg2dres 1>&2
225            fi
226            testoutput_for_prop $1 "dynstat_theta_min" "theta minimum" $2 $3; tmin=$?
227            testoutput_for_prop $1 "dynstat_theta_max" "theta maximum" $2 $3; tmax=$?
228            testoutput_for_prop $1 "dynstat_theta_mean" "theta mean" $2 $3; tmean=$?
229            testoutput_for_prop $1 "dynstat_theta_sd" "theta s.d." $2 $3; tsd=$?
230            testoutput_for_prop $1 "dynstat_salt_min" "salt minimum" $2 $3; smin=$?
231            testoutput_for_prop $1 "dynstat_salt_max" "salt maximum" $2 $3; smax=$?
232            testoutput_for_prop $1 "dynstat_salt_mean" "salt mean" $2 $3; smean=$?
233            testoutput_for_prop $1 "dynstat_salt_sd" "salt s.d." $2 $3; ssd=$?
234            testoutput_for_prop $1 "dynstat_uvel_min" "U minimum" $2 $3; umin=$?
235            testoutput_for_prop $1 "dynstat_uvel_max" "U maximum" $2 $3; umax=$?
236            testoutput_for_prop $1 "dynstat_uvel_mean" "U mean" $2 $3; umean=$?
237            testoutput_for_prop $1 "dynstat_uvel_sd" "U s.d." $2 $3; usd=$?
238            testoutput_for_prop $1 "dynstat_vvel_min" "V minimum" $2 $3; vmin=$?
239            testoutput_for_prop $1 "dynstat_vvel_max" "V maximum" $2 $3; vmax=$?
240            testoutput_for_prop $1 "dynstat_vvel_mean" "V mean" $2 $3; vmean=$?
241            testoutput_for_prop $1 "dynstat_vvel_sd" "V s.d." $2 $3; vsd=$?
242    
243            #  This is for PTRACERS
244            for ii in $PTRACERS_NUM ; do
245                eval `echo "p0"$ii"_min=99"`
246                eval `echo "p0"$ii"_max=99"`
247                eval `echo "p0"$ii"_mean=99"`
248                eval `echo "p0"$ii"_sd=99"`
249                tst=`eval 'echo "$HAVE_PTR0'$ii'"'`
250                #echo 'tst = '$tst
251                if test "x$tst" = xt ; then
252                    a="trcstat_ptracer0"
253                    testoutput_for_prop $1 "$a"$ii"_min"  "p0"$ii"_min"  $2 $3
254                    RETVAL=$? ; eval `echo "p0"$ii"_min="$RETVAL`
255                    testoutput_for_prop $1 "$a"$ii"_max"  "p0"$ii"_max"  $2 $3
256                    RETVAL=$? ; eval `echo "p0"$ii"_max="$RETVAL`
257                    testoutput_for_prop $1 "$a"$ii"_mean" "p0"$ii"_mean" $2 $3
258                    RETVAL=$? ; eval `echo "p0"$ii"_mean="$RETVAL`
259                    testoutput_for_prop $1 "$a"$ii"_sd"   "p0"$ii"_sd"   $2 $3
260                    RETVAL=$? ; eval `echo "p0"$ii"_sd="$RETVAL`
261                fi
262            done
263    
264      if [ $debug -gt 0 ]; then          allargs="$cg2dres $tmin $tmax $tmean $tsd $smin $smax $smean $ssd"
265          echo testoutput: testoutput_for_prop $1 cg2d_init_res 1>&2          allargs="$allargs $umin $umax $umean $usd $vmin $vmax $vmean $vsd"
266      fi          allargs="$allargs $p01_min $p01_max $p01_mean $p01_sd"
267      testoutput_for_prop $1 "cg2d_init_res" "cg2d init. residual" $2; cg2dres=$?          allargs="$allargs $p02_min $p02_max $p02_mean $p02_sd"
268      if [ $debug -gt 0 ]; then          allargs="$allargs $p03_min $p03_max $p03_mean $p03_sd"
269          echo testoutput: cg2dres=$cg2dres 1>&2          allargs="$allargs $p04_min $p04_max $p04_mean $p04_sd"
270            allargs="$allargs $p05_min $p05_max $p05_mean $p05_sd"
271    
272            eval "dashnum $allargs"
273    
274        else
275            testoutput_ad $1 $2 "precision_grdchk_result"
276      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  
277  }  }
278    
279  genmakemodel()  genmakemodel()
280  {  {
281      # genmakemodel directory      # genmakemodel directory
282      GENMAKE2="../../../tools/genmake2"      if test "x$NOGENMAKE" = xt ; then
283      (          echo "genmake skipped!"
284          cd $1;      else
285          printf 'genmake ... ' 1>&2          if test "x$BASH" = x ; then
286          # ../../../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  
287          else          else
288              echo "succesful" 1>&2              GENMAKE2="$BASH ../../../tools/genmake2 -bash $BASH"
289          fi          fi
290      )          (
291                cd $1;
292                command="$GENMAKE2  -ds -m $MAKE"
293                if test "x$ADM" = x ; then
294                    command="$command --mods=../code"
295                else
296                    command="$command --mods=../code_ad"
297                    command="$command -adof=../../../tools/adjoint_options/adjoint_staf"
298                fi
299                if test "x$OPTFILE" != xNONE ; then
300                    command="$command --optfile=$OPTFILE"
301                fi
302                if test "x$IEEE" != x ; then
303                    command="$command -ieee"
304                fi
305                if test "x$MPI" = xt ; then
306                    command="$command -mpi"
307                fi
308                printf 'genmake ... ' 1>&2
309                $command > make.log 2>&1
310                RETVAL=$?
311                #  Reduce the size of the testing emails!
312                head -100 Makefile > $CDIR/Makefile_head
313                if test "x$RETVAL" != x0 ; then
314                    tail make.log
315                    echo "genmakemodel: genmake failed" 1>&2
316                    cp genmake_* make.log $CDIR
317                    return 1
318                else
319                    echo "successful" 1>&2
320                fi
321            )
322        fi
323  }  }
324    
325  makeclean()  makeclean()
326  {  {
327      # makeclean directory      # makeclean directory
328      (      if test "x$NOCLEAN" = xt ; then
329          cd $1;          echo "make CLEAN skipped!"
330          rm -f output.txt      else
331          printf 'make CLEAN ... ' 2>&1          (
332          if test -r Makefile ; then              cd $1;
333              make CLEAN >> make.log 2>&1              if test -e output.txt ; then
334              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  
335              fi              fi
336          fi              printf 'make CLEAN ... ' 2>&1
337          echo succesful 1>&2              if test -r Makefile ; then
338          exit 0                  $MAKE CLEAN >> make.log 2>&1
339      )                  RETVAL=$?
340                    if test "x$RETVAL" != x0 ; then
341                        tail make.log
342                        echo "makeclean: \"make CLEAN\" failed" 1>&2
343                        cp make.log $CDIR"/make.log"
344                        return 1
345                    fi
346                fi
347                echo successful 1>&2
348                exit 0
349            )
350        fi
351    }
352    
353    postclean()
354    {
355        # postclean directory
356        if test "x$POSTCLEAN" = xt ; then
357            (
358                cd $1;
359                if test -r Makefile ; then
360                    $MAKE CLEAN >> /dev/null 2>&1
361                fi
362                exit 0
363            )
364        fi
365  }  }
366    
367  makedependmodel()  makedependmodel()
368  {  {
369      # makedependmodel directory      # makedependmodel directory
370      (      if test "x$NODEPEND" = xt ; then
371          cd $1;          echo "make depend skipped!"
372          printf 'make depend ... ' 1>&2      else
373          make depend >> make.log 2>&1          (
374          RETVAL=$?              cd $1;
375          if test "x$RETVAL" != x0 ; then              printf 'make depend ... ' 1>&2
376              tail make.log              $MAKE depend >> make.log 2>&1
377              echo "makedependmodel: make depend failed" 1>&2              RETVAL=$?
378              cp make.log $CDIR"/make.log"              if test "x$RETVAL" != x0 ; then
379              return 1                  tail make.log
380          else                  echo "makedependmodel: make depend failed" 1>&2
381              echo succesful 1>&2                  cp make.log $CDIR"/make.log"
382          fi                  return 1
383      )              else
384                    echo successful 1>&2
385                fi
386            )
387        fi
388  }  }
389    
390  makemodel()  makemodel()
# Line 231  makemodel() Line 394  makemodel()
394          cd $1;          cd $1;
395          if test -r Makefile ; then          if test -r Makefile ; then
396              printf 'make ... ' 1>&2              printf 'make ... ' 1>&2
397              make >> make.log 2>&1              if test "x$ADM" = x ; then
398                    if test "x$JOBS" = x ; then
399                        $MAKE >> make.log 2>&1
400                    else
401                        $MAKE -j $JOBS >> make.log 2>&1
402                    fi
403                else
404                    $MAKE adall >> make.log 2>&1
405                fi
406              RETVAL=$?              RETVAL=$?
407              if test "x$RETVAL" != x0 ; then              if test "x$RETVAL" != x0 ; then
408                  tail make.log                  tail make.log
# Line 239  makemodel() Line 410  makemodel()
410                  cp make.log $CDIR"/make.log"                  cp make.log $CDIR"/make.log"
411                  return 1                  return 1
412              else              else
413                  echo succesful 1>&2                  echo successful 1>&2
414              fi              fi
415          fi          fi
416      )      )
417  }  }
418    
419    symlink_mpifiles()
420    {
421        # Put special links so that MPI specific files are used
422        # This MUST be invoked between makeclean and makelinks because
423        # the Makefile will link to non-mpi files by default
424    
425        dir=$1
426        code_dir=$2
427        BUILD_DIR=$dir/$3
428        CODE_DIR=$dir/$code_dir
429        
430        # These are files that should replace their counter-part when using -mpi
431        MPI_FILES=`(cd $CODE_DIR; find . -name "*_mpi")`
432    
433        #  Is this an MPI run?
434        if test "x$MPI" = xt ; then
435            # YES: We symbolically link these files to the build
436            # dir so long as there is no real file in place
437            for ii in $MPI_FILES ; do
438                i=`echo $ii | sed 's:^\./::'`
439                name=`echo $i | sed 's:_mpi::' `
440                cmp $CODE_DIR/$i $BUILD_DIR/$name > /dev/null 2>&1
441                RETVAL=$?
442                if test "x$RETVAL" != x0 ; then
443                    if ! test -f $BUILD_DIR/$i ; then
444                        #echo Linking $name to $i
445                        (cd $BUILD_DIR; ln -sf ../$code_dir/$i $name)
446                    fi
447                fi
448            done
449        else
450            # NO: We undo any _mpi symbolically linked files
451            for ii in $MPI_FILES ; do
452                i=`echo $ii | sed 's:^\./::'`
453                name=`echo $i | sed 's:_mpi::' `
454                if test -L $BUILD_DIR/$name ; then
455                    cmp $BUILD_DIR/$name "../$code_dir/$name"_mpi > /dev/null 2>&1
456                    RETVAL=$?
457                    if test "x$RETVAL" = x0 ; then
458                        #echo Un-linking $name from $linktarg
459                        rm -f $BUILD_DIR/$name
460                    fi
461                fi
462            done
463        fi
464        
465    }
466    
467  linkdata()  linkdata()
468  {  {
469      # linkdata flag      # linkdata flag
470      #      #
471      # symbolically link data files to run directory      # symbolically link data files to run directory
472      if [ $1 -ne 0 ]; then      if test "x$1" = x1 ; then
473          ( cd $2 ;  ln -sf ../input/* . )          (
474                cd $2
475                if test "x$ADM" = x ; then
476                    files=`( cd ../input ; ls -1 | grep -v CVS )`
477                    for i in $files ; do
478                        if test ! -d "../input/"$i -a ! -f $i ; then
479                            ln -sf "../input/"$i $i
480                        fi
481                    done
482                else
483                    files=`( cd ../input ; ls -1 *.bin | grep -v CVS )`
484                    for i in $files ; do
485                        if test ! -d "../input/"$i ; then
486                            ln -sf "../input/"$i $i
487                        fi
488                    done
489                    files=`( cd ../input_ad ; ls -1 | grep -v CVS )`
490                    for i in $files ; do
491                        if test ! -d "../input_ad/"$i ; then
492                            ln -sf "../input_ad/"$i $i
493                        fi
494                    done
495                fi
496            )
497      fi      fi
498  }  }
499    
500  runmodel()  runmodel()
501  {  {
502      # runmodel directory exe      # runmodel directory
503      #      #
504      #  runs the model "exe" in "directory" (exe is relative to directory)      #  runs "$COMMAND in "directory"
505        #  (where "$COMMAND" is relative to "directory")
506      (      (
507          cd $1          cd $1
508          if [ -x $2 ]; then          printf 'runmodel ... ' 1>&2
509              if [ $quick -eq 0 ]; then          # make output.txt
510                  rm -f output.txt          echo
511              fi          rm -f run.log
512              printf 'runmodel: ' 1>&2          # echo "COMMAND='$COMMAND'"
513              make output.txt          # echo "pwd='"`pwd`"'"
514              RETVAL=$?          ( eval $COMMAND ) > run.log 2>&1
515              if test "x$RETVAL" = x0 ; then          RETVAL=$?
516                  cp output.txt $CDIR"/output.txt"          if test "x$RETVAL" = x0 ; then
517                  return 0              tail run.log
518              else              echo successful 1>&2
519                  return 1              # === Reduce the size of the testing emails!
520              fi              # if test "x$ADM" = x ; then
521                #   cp output.txt $CDIR"/output.txt"
522                # else
523                #   cp output.txt_adm $CDIR"/output.txt_adm"
524                # fi
525                if test -s STDERR.0000 ; then cp STDERR.0000 $CDIR"/STDERR.0000" ; fi
526                return 0
527            else
528                tail run.log
529                echo failed 1>&2
530                cp run.log $CDIR"/run.log"
531                if test -s STDERR.0000 ; then cp STDERR.0000 $CDIR"/STDERR.0000" ; fi
532                return 1
533          fi          fi
534      )      )
535  }  }
# Line 283  createcodelet() Line 538  createcodelet()
538  {  {
539      # create codelet for comparing model output      # create codelet for comparing model output
540    
541      echo -n "creating the comparison code...  "      printf "creating the comparison code...  "
542      cat > tmp_cmpnum.f <<EOFA      cat > tmp_cmpnum.c <<EOF
543        program cmpnum  #include <stdio.h>
544        implicit none  #include <math.h>
545        real*8 a,b,diff  int main( int argc, char** argv )  {
546        integer linnum,best    int linnum,best,lncnt;
547        best=-16    double a,b,abave,relerr;
548    99  read(*,*,end=70,err=60) linnum,a,b    best = -22;
549        diff=0.5*(abs(a)+abs(b))    lncnt = 0;
550  c     print *,a,b,diff,abs(a-b)/diff    while( 1 & (lncnt+=1) < 999 )  {
551        if (diff.gt.1.e-12) then      scanf("%d", &linnum);
552          diff=abs(a-b)/diff      if (linnum == -1)  break;
553          if (diff.gt.0.) then      scanf("%lf", &a);  scanf("%lf", &b);
554  c         print *,int(log10(diff)),diff      abave = 0.5*(fabs(a)+fabs(b));
555            linnum=int(log10(diff))      if (abave > 0.0) {
556            best=max(best,linnum)        relerr=fabs(a-b)/abave;
557          endif        if (relerr > 0.0) { linnum = (int)rint(log10(relerr)); }
558        else        else { linnum = -16 ; }
559          if (best.eq.-16.and.diff.ne.0.) best=-22        best = (best > linnum) ? best : linnum;
560        endif      }
561        goto 99    }
562    60  stop 'cmpnum: An error occured reading a,b'    if (lncnt == 999) best=-29;
563    70  print *,-best    printf("%d\n", -best);
564        end    return 0;
565  EOFA  }
566    EOF
567        $CC -o tmp_cmpnum tmp_cmpnum.c -lm
568    
569      f77 tmp_cmpnum.f      if [ -x ./tmp_cmpnum ]; then
     if [ -x ./a.out ]; then  
570          echo "OK"          echo "OK"
571          return 0          return 0
572      else      else
573          echo          echo
574          echo "createcodelet: failed to compile codelet" | tee          echo "ERROR: failed to compile comparison code -- please specify"
575            echo "  a C compiler using the CC environment variable."
576          exit 1          exit 1
577      fi      fi
578  }  }
# Line 347  show_help() Line 604  show_help()
604  {  {
605      cat - << EOF      cat - << EOF
606  $0 [-help] [-quick] [-verbose] dir1 [dir2] [...]  $0 [-help] [-quick] [-verbose] dir1 [dir2] [...]
607   -help      Show this help message  
608   -quick     Skip "genmake" and "make depend" if the Makefile exists   -help|-h      Show this help message
609   -quiet     Reduce the amount of output   -quiet     Reduce the amount of output
610   -verbose   Produce copious amounts of output   -verbose   Produce copious amounts of output
611   -debug     Produce even more output which will mean nothing to most   -debug     Produce even more output which will mean nothing to most
612   -force     Do "make CLEAN" before compiling. This forces a complete rebuild.   -force     Do "make CLEAN" before compiling. This forces a complete rebuild.
613   -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.  
614   -cleanup   Aggresively removes all model output, executables and object files   -cleanup   Aggresively removes all model output, executables and object files
615              and then exits. Use with care.              and then exits. Use with care.
616    
# Line 376  scandirs() Line 632  scandirs()
632    
633    
634  ###############################################################################  ###############################################################################
 ###############################################################################  
 ###############################################################################  
635    
636    
637  #  Default properties  #  Default properties
638  debug=0  debug=0
639  verbose=1  verbose=1
 quick=0  
640  clean=0  clean=0
 ieee=1  
641  expts=''  expts=''
642    # ieee=1
643    
644  OPTFILES=  IEEE=true
645  ADDRESSES=edhill@mitgcm.org  if test "x$MITGCM_IEEE" != x ; then
646        IEEE=$MITGCM_IEEE
647    fi
648    
649    
650    CLEANUP=f
651    QUICK=f
652    NOGENMAKE=f
653    NOCLEAN=f
654    NODEPEND=f
655    POSTCLEAN=f
656    
657    BASH=
658    OPTFILE=NONE
659    ADDRESSES=
660  TESTDIRS=  TESTDIRS=
661  MPACKDIR="../tools/mpack-1.6"  MPACKDIR="../tools/mpack-1.6"
662    HAVE_MPACK=
663  MPACK="$MPACKDIR/mpack"  MPACK="$MPACKDIR/mpack"
664    COMMAND=
665    if test "x$MAKE" = x ; then
666        MAKE=make
667    fi
668    if test "x$CC" = x ; then
669        CC=cc
670    fi
671    JOBS=
672    MPI=f
673    OUTDIR=
674    DELDIR=
675    
676    ADM=
677    
678  echo -n "parsing options...  "  # Additional monitor types
679    PTRACERS_NUM="1 2 3 4 5"
680    
681    printf "parsing options...  "
682    
683  ac_prev=  ac_prev=
684  for ac_option ; do  for ac_option ; do
# Line 414  for ac_option ; do Line 698  for ac_option ; do
698              usage ;;              usage ;;
699                    
700          -optfile | --optfile | -of | --of)          -optfile | --optfile | -of | --of)
701              ac_prev=OPTFILES ;;              ac_prev=OPTFILE ;;
702          -optfile=* | --optfile=* | -of=* | --of=*)          -optfile=* | --optfile=* | -of=* | --of=*)
703              OPTFILES=$ac_optarg ;;              OPTFILE=$ac_optarg ;;
704                    
705          -addr | --addr | -a | --a)          -addr | --addr | -a | --a)
706              ac_prev=ADDRESSES ;;              ac_prev=ADDRESSES ;;
# Line 428  for ac_option ; do Line 712  for ac_option ; do
712          -tdir=* | --tdir=*)          -tdir=* | --tdir=*)
713              TESTDIRS=$ac_optarg ;;              TESTDIRS=$ac_optarg ;;
714    
715          -quick) quick=1 ;;          -bash | --bash | -b | --b)
716                ac_prev=BASH ;;
717            -bash=* | --bash=*)
718                BASH=$ac_optarg ;;
719    
720            -command | --command | -c | --c)
721                ac_prev=COMMAND ;;
722            -command=* | --command=*)
723                COMMAND=$ac_optarg ;;
724    
725            -make | --make | -m | --m)
726                ac_prev=MAKE ;;
727            -make=* | --make=*)
728                MAKE=$ac_optarg ;;
729    
730            -odir | --odir)
731                ac_prev=OUTDIR ;;
732            -odir=* | --odir=*)
733                OUTDIR=$ac_optarg ;;
734    
735            -ptracers | --ptracers | -ptr | --ptr)
736                ac_prev=PTRACERS_NUM ;;
737            -ptracers=* | --ptracers=* | -ptr=* | --ptr=*)
738                PTRACERS_NUM=$ac_optarg ;;
739    
740            -j) ac_prev=JOBS ;;
741            -j=*) JOBS=$ac_optarg ;;
742    
743            -clean | --clean)
744                CLEANUP=t ; DELDIR=t ;;
745    
746            -quick | --quick | -q | --q)
747                QUICK=t ;;
748            -nogenmake | --nogenmake | -ng | --ng)
749                NOGENMAKE=t ;;
750            -noclean | --noclean | -nc | --nc)
751                NOCLEAN=t ;;
752            -nodepend | --nodepend | -nd | --nd)
753                NODEPEND=t ;;
754    
755            -postclean | --postclean | -pc | --pc)
756                POSTCLEAN=t ;;
757    
758            -mpi) MPI=t ;;
759    
760            -adm | -ad) ADM=t ;;
761    
762            -ieee) IEEE=true ;;
763            -noieee) IEEE= ;;
764    
765          -verbose) verbose=2 ;;          -verbose) verbose=2 ;;
766          -debug) debug=1 ;;          -debug) debug=1 ;;
         -clean) clean=1 ;;  
         -noieee) ieee=0 ;;  
767          -quiet) verbose=0 ;;          -quiet) verbose=0 ;;
768    
769            -deldir | -dd) DELDIR=t ;;
770    
771          -*)          -*)
772              echo "Error: unrecognized option: "$ac_option              echo "Error: unrecognized option: "$ac_option
773              usage              usage
# Line 449  for ac_option ; do Line 782  for ac_option ; do
782            
783  done  done
784    
785    if test "x$QUICK" = xt ; then
786        NOGENMAKE=t
787        NOCLEAN=t
788        NODEPEND=t
789    fi
790    
791  if test "x$TESTDIRS" = x ; then  if test "x$TESTDIRS" = x ; then
792      TESTDIRS=`scandirs`      TESTDIRS=`scandirs`
793  fi  fi
794    
795    if test "x$OPTFILE" = xNONE -a "x$MITGCM_OF" != x ; then
796        OPTFILE=$MITGCM_OF
797    fi
798    
799    if test "x$ADM" = xt -a "x$COMMAND" = x ; then
800        COMMAND="./mitgcmuv_ad > output.txt_adm 2>&1"
801    fi
802    
803    if test "x$COMMAND" = x ; then
804        COMMAND="$MAKE output.txt"
805    fi
806    
807  echo "OK"  echo "OK"
808    
809  #  create the FORTRAN comparison code  #  create the FORTRAN comparison code
810  createcodelet  createcodelet
811    
812  #  build the mpack utility  #  build the mpack utility
813  build_mpack  if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then
814        echo "skipping mpack build"
815    else
816        build_mpack
817    fi
818    
819  #  Create a uniquely named directory to store results  #  Create a uniquely named directory to store results
820  MACH=`hostname`  MACH=`hostname`
821  UNAMEA=`uname -a`  UNAMEA=`uname -a`
822  DATE=`date +%Y%m%d`  DATE=`date +%Y%m%d`
823  BASE=$MACH"_"$DATE"_"  BASE="tr_"$MACH"_"$DATE"_"
824    if test "x$OUTDIR" != x ; then
825        BASE="tr_"$OUTDIR"_"$DATE"_"
826    fi
827  DNUM=0  DNUM=0
828  DRESULTS="$BASE$DNUM"  DRESULTS="$BASE$DNUM"
829  while test -e $DRESULTS ; do  while test -e $DRESULTS ; do
# Line 475  done Line 833  done
833  mkdir $DRESULTS  mkdir $DRESULTS
834  RETVAL=$?  RETVAL=$?
835  if test "x$RETVAL" != x0 ; then  if test "x$RETVAL" != x0 ; then
836      echo "Error: can't create results directory \"./$DRESULTS\""      echo "ERROR: Can't create results directory \"./$DRESULTS\""
837      exit 1      exit 1
838  fi  fi
839  SUMMARY="$DRESULTS/summary.txt"  SUMMARY="$DRESULTS/summary.txt"
840  date > $SUMMARY  printf "Start time:  " >> $SUMMARY
841  cat << EOF >> $SUMMARY  start_date=`date`
842                  T           S           U           V  echo $start_date > $SUMMARY
843  G D M    c        m  s        m  s        m  s        m  s  
844  E p a R  g  m  m  e  .  m  m  e  .  m  m  e  .  m  m  e  .  of_path=
845  N n k u  2  i  a  a  d  i  a  a  d  i  a  a  d  i  a  a  d  if test "x$OPTFILE" != xNONE ; then
846  2 d e n  d  n  x  n  .  n  x  n  .  n  x  n  .  n  x  n  .      if test -r $OPTFILE ; then
847            # get the path
848            path=${OPTFILE%/*}
849            if test "x$path" = x ; then
850                of_path=`pwd`
851            else
852                of_path=`( cd $path > /dev/null 2>&1 ; pwd )`
853            fi
854            file=${OPTFILE##*/}
855            OPTFILE=$of_path/$file
856            cp $OPTFILE $DRESULTS
857            echo >> $SUMMARY
858            echo "  OPTFILE=$OPTFILE" >> $SUMMARY
859        else
860            echo | tee $SUMMARY
861            echo "ERROR: can't read OPTFILE=\"$OPTFILE\"" | tee $SUMMARY
862            exit 1
863        fi
864    else
865        echo >> $SUMMARY
866        echo "No \"OPTFILE\" was explicitly specified by testreport," >> $SUMMARY
867        echo "   so the genmake default will be used." >> $SUMMARY
868    fi
869    echo
870    echo >> $SUMMARY
871    if test "x$ADM" = x ; then
872        line_0="            ----T-----  ----S-----  ----U-----  ----V-----"
873        line_1="G D M    c        m  s        m  s        m  s        m  s"
874        line_2="E p a R  g  m  m  e  .  m  m  e  .  m  m  e  .  m  m  e  ."
875        line_3="N n k u  2  i  a  a  d  i  a  a  d  i  a  a  d  i  a  a  d"
876        line_4="2 d e n  d  n  x  n  .  n  x  n  .  n  x  n  .  n  x  n  ."
877        for ii in $PTRACERS_NUM ; do
878            #  tst=`eval 'echo $HAVE_PTR0'$ii`
879            #  if test "x$tst" = xt ; then
880            line_0="$line_0  --PTR 0"$ii"--"
881            line_1="$line_1        m  s"
882            line_2="$line_2  m  m  e  ."
883            line_3="$line_3  i  a  a  d"
884            line_4="$line_4  n  x  n  ."
885            #  fi
886        done
887        echo "$line_0" | tee -a $SUMMARY
888        echo "$line_1" | tee -a $SUMMARY
889        echo "$line_2" | tee -a $SUMMARY
890        echo "$line_3" | tee -a $SUMMARY
891        echo "$line_4" | tee -a $SUMMARY
892        echo " "       | tee -a $SUMMARY
893    else
894        echo "ADJOINT=true" >> $SUMMARY
895        echo >> $SUMMARY
896        cat << EOF | tee -a $SUMMARY
897    G D M    C  G
898    E p a R  o  r
899    N n k u  s  a
900    2 d e n  t  d
901    
902  EOF  EOF
903    fi
904    
905    #  ...and each test directory...
906    for dir in $TESTDIRS ; do
907        
908        #  Cleanup only!
909        if test "x$CLEANUP" = xt ; then
910            if test -r $dir/build/Makefile ; then
911                ( cd $dir/build ; make CLEAN )
912            fi
913            if test -r $dir/input/Makefile ; then
914                ( cd $dir/input ; make CLEAN )
915            fi
916            (
917                cd $dir
918                rm -rf tr_run.*
919            )
920            continue
921        fi
922    
923  NDIR=0      #  Verify that the testdir exists and contains previous
924        #  results in the correct location--or skip this directory!
925        fout=
926        if test "x$ADM" = x ; then
927            fout=$dir"/results/output.txt"
928        else
929            fout=$dir"/results_ad/output.txt_adm"
930        fi
931        if test ! -r $fout ; then
932            echo "can't read \"$fout\" -- skipping $dir"
933            continue
934        fi
935        if test "x$ADM" = x ; then
936            check_for_add_mon_output  $fout
937        fi
938    
939  #  For each optfile...      # Check for additional types of monitor output
 for OPTFILE in $OPTFILES ; do  
940    
941      OPTFILE=`pwd`"/$OPTFILE"      builddir="input"
942      if test ! -r $OPTFILE ; then      rundir="input"
943          echo "Error: can't read optfile \"$OPTFILE\""      use_seperate_build=0
944          exit 1      if test -d $dir/build -a -r $dir/build ; then
945            builddir="build"
946            rundir="build"
947            use_seperate_build=1
948            linkdata $use_seperate_build $dir/$rundir
949      fi      fi
     echo  
     echo "OPTFILE=$OPTFILE" >> $SUMMARY  
     echo >> $SUMMARY  
950            
951      #  ...and each test directory...      #  Check whether there are "extra runs" for this testdir
952      for dir in $TESTDIRS ; do      extra_runs=
953                if test "x$ADM" = x -a "x$use_seperate_build" = x1 ; then
954          #  Create an output dir for each OPTFILE/tdir combination          ex_run_dirs=`( cd $dir ; echo input.* )`
955          CDIR=$DRESULTS"/"$DRESULTS"_"$NDIR          echo "ex_run_dirs='$ex_run_dirs'"
956          mkdir $CDIR          for exd in $ex_run_dirs ; do
957          CDIR=`pwd`"/$CDIR"              name=`echo $exd | sed -e 's/input.//g'`
958                outf="$dir/results/output.txt.$name"
959                if test -f $outf -a -r $outf ; then
960                    extra_runs="$extra_runs $name"
961                fi
962            done
963        fi
964    
965          #  ...configue, make, run, and compare the output.      if test "x$ADM" = x ; then
966          echo "-------------------------------------------------------------------------------"          code_dir=code
967          echo          CODE_DIR=$dir/code
968          echo "Experiment:  $dir"      else
969          echo          code_dir=code_ad
970          unset genmake makedepend make run          CODE_DIR=$dir/code_ad
971          results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --'      fi
972          ( 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  
973    
974          #  Verify that the testdir exists and contains previous      if test ! -r $CODE_DIR"/SIZE.h_mpi" -a "x$MPI" = "xt" ; then
975          #  results in the correct location--or skip this directory!          echo "can't find \"$CODE_DIR/SIZE.h_mpi\" -- skipping $dir"
976          if test ! -r $dir"/results/output.txt" ; then          continue
977              echo | tee $SUMMARY      fi
             echo "can't read \"$dir/results/output.txt\" -- skipping $dir" \  
                 | tee $SUMMARY  
             continue  
         fi  
978    
979        echo "-------------------------------------------------------------------------------"
980        echo
981        echo "Experiment:  $dir"
982        echo
983        unset genmake makedepend make run
984        results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --'
985    
986        #  Create an output dir for each OPTFILE/tdir combination
987        rel_CDIR=$DRESULTS"/"$dir
988        mkdir $rel_CDIR
989        CDIR=`pwd`"/$rel_CDIR"
990        
991        if test "x$CLEANUP" = xt ; then
992            makeclean $dir/$builddir
993        else
994          genmakemodel $dir/$builddir && genmake=Y \          genmakemodel $dir/$builddir && genmake=Y \
995              && makeclean $dir/$builddir \              && makeclean $dir/$builddir \
996                && symlink_mpifiles $dir $code_dir $builddir \
997              && makedependmodel $dir/$builddir && makedepend=Y \              && makedependmodel $dir/$builddir && makedepend=Y \
998              && makemodel $dir/$builddir && make=Y \              && makemodel $dir/$builddir && make=Y \
999              && linkdata $seperatebuilddir $dir/$rundir \              && linkdata $use_seperate_build $dir/$rundir \
1000              && runmodel $dir/$builddir mitgcmuv && run=Y \              && runmodel $dir/$rundir && run=Y \
1001              && results=`testoutput $dir $rundir`              && results=`testoutput $dir $rundir`
1002        fi
1003        
1004        echo
1005        if test "x$ADM" = x ; then
1006            fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results`
1007          echo          echo
1008          formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \          echo "$fres" >> $SUMMARY
1009              ${run:-N} $results          echo "fresults='$fres'" > $CDIR"/summary.txt"
1010            echo "MACH='$MACH'" >> $CDIR"/summary.txt"
1011            echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"
1012            echo "DATE='$DATE'" >> $CDIR"/summary.txt"
1013            echo "tdir='$dir'" >> $CDIR"/summary.txt"
1014    
1015            for ex in $extra_runs ; do
1016                test ! -e "$dir/tr_run.$ex" && mkdir "$dir/tr_run.$ex"
1017                for ldir in input.$ex input ; do
1018                    (
1019                        cd "$dir/$ldir" > /dev/null 2>&1
1020                        ls -1 2>/dev/null \
1021                            | sed -e 's|^CVS$||g' | sed -e 's|^output.txt$||g'
1022                    ) > tr_exrun_links
1023                    (
1024                        cd "$dir/tr_run.$ex"
1025                        cat ../../tr_exrun_links | while read i ; do
1026                            if test ! "x$i" = x ; then
1027                                test ! -r $i  &&  ln -s "../"$ldir"/"$i $i
1028                            fi
1029                        done
1030                    )
1031                    test -e tr_exrun_links  &&  rm -f tr_exrun_links
1032                done
1033                ldir=build
1034                (
1035                    cd "$dir/$ldir" > /dev/null 2>&1
1036                    ls -1 Makefile *.[fFhco] mitgcmuv  2>/dev/null \
1037                        | sed -e 's|^CVS$||g' | sed -e 's|^output.txt$||g'
1038                ) > tr_exrun_links
1039                (
1040                    cd "$dir/tr_run.$ex"
1041                        cat ../../tr_exrun_links | while read i ; do
1042                            if test ! "x$i" = x ; then
1043                                test ! -r $i  &&  ln -s "../"$ldir"/"$i $i
1044                            fi
1045                        done
1046                )
1047                test -e tr_exrun_links  &&  rm -f tr_exrun_links
1048                runmodel $dir/tr_run.$ex && run=Y \
1049                    && results=`testoutput $dir tr_run.$ex "."$ex`
1050                fres=`printf '%s %s %s %s' ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N}`
1051                fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results`
1052                fres="$fres.$ex"
1053                echo
1054                echo "$fres" >> $SUMMARY
1055                echo "fresults='$fres'" > $CDIR"/summary.txt"
1056                echo "MACH='$MACH'" >> $CDIR"/summary.txt"
1057                echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"
1058                echo "DATE='$DATE'" >> $CDIR"/summary.txt"
1059                echo "tdir='$dir'" >> $CDIR"/summary.txt"
1060            done
1061        else
1062            fres=`printf '%s %s %s %s' ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N}`
1063            fres=$fres"$results   $dir"
1064          echo          echo
1065          formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \          echo "$fres" >> $SUMMARY
1066              ${run:-N} $results >> $SUMMARY          echo "fresults='$fres'" > $CDIR"/summary.txt"
         echo "fresults='" > $CDIR"/summary.txt"  
         formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \  
             ${run:-N} $results >> $CDIR"/summary.txt"  
         echo "'" >> $CDIR"/summary.txt"  
1067          echo "MACH='$MACH'" >> $CDIR"/summary.txt"          echo "MACH='$MACH'" >> $CDIR"/summary.txt"
1068          echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"          echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"
1069          echo "DATE='$DATE'" >> $CDIR"/summary.txt"          echo "DATE='$DATE'" >> $CDIR"/summary.txt"
1070          echo "tdir='$dir'" >> $CDIR"/summary.txt"          echo "tdir='$dir'" >> $CDIR"/summary.txt"
1071        fi
1072    
1073          (      postclean $dir/$builddir
1074              cd $DRESULTS      
1075              tar -cf $NDIR".tar" $DRESULTS"_"$NDIR > /dev/null 2>&1      echo "-------------------------------------------------------------------------------"
1076              gzip $NDIR".tar"      
1077          )  done
1078    
1079          $MPACK -s MITgcm-test -m 1000000 $DRESULTS"/"$NDIR".tar.gz" $ADDRESSES  printf "Start time:  " >> $SUMMARY
1080    echo $start_date >> $SUMMARY
1081    printf "End time:    " >> $SUMMARY
1082    date >> $SUMMARY
1083    
1084    #  If addresses were supplied and mpack built successfully, then try
1085    #  to send email using mpack.
1086    if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then
1087        echo "No results email was sent."
1088    else
1089        if test "x$HAVE_MPACK" = xt ; then
1090            tar -cf $DRESULTS".tar" $DRESULTS > /dev/null 2>&1 \
1091                && gzip $DRESULTS".tar" \
1092                && $MPACK -s MITgcm-test -m 3555000 $DRESULTS".tar.gz" $ADDRESSES
1093          RETVAL=$?          RETVAL=$?
1094          if test "x$RETVAL" != x0 ; then          if test "x$RETVAL" != x0 ; then
1095              echo "Warning: \"$MPACK\" failed -- please contact <edhill@mitgcm.org>"              echo
1096                echo "Warning: The tar, gzip, & mpack step failed.  Please send email"
1097                echo "  to <MITgcm-support@mitgcm.org> for help.  You may copy the "
1098                echo "  summary of results from the directory \"$DRESULTS\"."
1099                echo
1100          else          else
1101              rm -f $DRESULTS"/"$NDIR".tar*"              echo
1102                echo "An email containing results was sent to the following addresses:"
1103                echo "  \"$ADDRESSES\""
1104                echo
1105          fi          fi
1106            test -f $DRESULTS".tar"  &&  rm -f $DRESULTS".tar"
1107            test -f $DRESULTS".tar.gz"  &&  rm -f $DRESULTS".tar.gz"
1108        fi
1109    fi
1110    
1111          NDIR=$(( $NDIR + 1 ))  # rm -f tmp_cmpnum.f a.out
1112            rm -f tmp_cmpnum.c tmp_cmpnum
     done  
 done  
1113    
1114  rm tmp_cmpnum.f a.out  if test "x$CLEANUP" != xt ; then
1115        cat $SUMMARY | sed 's/ -- -- -- --//g'
1116        if test -e tr_out.txt ; then
1117            mv tr_out.txt tr_out.txt.old
1118        fi
1119        cat $SUMMARY | sed 's/ -- -- -- --//g' > tr_out.txt
1120    fi
1121    
1122  cat $SUMMARY  if test "x$DELDIR" = xt ; then
1123        rm -rf $DRESULTS
1124    fi
1125    

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

  ViewVC Help
Powered by ViewVC 1.1.22