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

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

  ViewVC Help
Powered by ViewVC 1.1.22