/[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.92 by jmc, Wed Sep 5 01:46:37 2007 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 "  (-mth)                   run multi threaded (using eedata.mth)"
15      echo "  (-a|-addr)STRING         list of email recipients"      echo "  (-mpi)                   compile and run using MPI"
16      echo "  (-t|-tdir)STRING         list of \"test\" dirs"      echo "  (-ieee|-noieee)          if possible, use IEEE compiler flags"
17        echo "                             (DEF=\"-ieee\")"
18        echo "  (-of=|-optfile=)STRING   list of optfiles to use"
19        echo "  (-a|-addr) STRING        list of email recipients"
20        echo "                             (DEF=\"edhill@mitgcm.org\")"
21        echo "  (-t|-tdir) STRING        list of group and/or exp. dirs to test"
22        echo "                             (recognized groups: basic, tutorials)"
23        echo "                             (DEF=\"\" which test all)"
24        echo "  (-skd|-skipdir) STRING   list of exp. dirs to skip"
25        echo "                             (DEF=\"\" which test all)"
26        echo "  (-b|-bash) STRING        preferred location of a \"bash\" or"
27        echo "                             Bourne-compatible \"sh\" shell"
28        echo "                             (DEF=\"\" for \"bash\")"
29        echo "  (-adm|-ad)               perform an adjoint run"
30        echo "  (-command) STRING        command to run"
31        echo "                             (DEF=\"make output.txt\")"
32        echo "  (-m|-make) STRING        command to use for \"make\""
33        echo "                             (DEF=\"make\")"
34        echo "  (-odir) STRING           used to build output directory name"
35        echo "                             (DEF=\"hostname\")"
36        echo "  (-ptr|-ptracers) STRING  specify which ptracers to test"
37        echo "                             (DEF=\"1 2 3 4 5\")"
38        echo "  (-match) NUMBER          Matching Criteria (number of digits)"
39        echo "                             (DEF=\"12\")"
40        echo "  (-j) JOBS                use \"make -j JOBS\" for parallel builds"
41        echo "  (-clean)                 *ONLY* run \"make CLEAN\""
42        echo "  (-quick|-q)              same as \"-nogenmake -noclean -nodepend\""
43        echo "  (-nogenmake|-ng)         skip the genmake stage"
44        echo "  (-noclean|-nc)           skip the \"make clean\" stage"
45        echo "  (-nodepend|-nd)          skip the \"make depend\" stage"
46        echo "  (-deldir|-dd)            on success, delete the output directory"
47        echo "  (-ts)                    provide timing information per timestep"
48        echo "  (-papis)                 provide MFlop/s per timestep using PAPI"
49        echo "  (-pcls)                  provide MFlop/s per timestep using PCL"
50        echo
51        echo "and where STRING can be a whitespace-delimited list"
52        echo "such as:"
53        echo
54        echo "  -t 'exp0 exp2 exp3' "
55        echo "  -addr='abc@123.com testing@home.org'"
56        echo
57        echo "provided that the expression is properly quoted within the current"
58        echo "shell (note the use of single quotes to protect white space)."
59      echo      echo
60      exit 1      exit 1
61  }  }
# Line 20  usage() Line 63  usage()
63  #  build the mpack utility  #  build the mpack utility
64  build_mpack()  build_mpack()
65  {  {
66      echo -n "building the mpack utility...  "      printf "building the mpack utility...  "
67      if test ! -x "$MPACKDIR/mpack" ; then      if test ! -x "$MPACKDIR/mpack" ; then
68          if test ! -d $MPACKDIR ; then          if test ! -d $MPACKDIR ; then
69                echo
70              echo "Error: can't find \"$MPACKDIR\""              echo "Error: can't find \"$MPACKDIR\""
71              echo "  are you sure this program is being run in the correct "              echo "  are you sure this program is being run in the correct "
72              echo "  (that is, \"MITGCM_ROOT\verification\") directory?"              echo "  (that is, \"MITGCM_ROOT\verification\") directory?"
73              exit 1              echo
74                HAVE_MPACK=f
75          fi          fi
76          echo -n "building mpack...  "          printf "building mpack...  "
77          ( cd $MPACKDIR && ./configure && make ) > build_mpack.out 2>&1          if test "x$CC" = x ; then
78                export CC=cc
79            fi
80            ( cd $MPACKDIR && ./configure && $MAKE ) > tr_build_mpack.out 2>&1
81          RETVAL=$?          RETVAL=$?
82          if test "x$RETVAL" != x0 ; then          if test "x$RETVAL" != x0 ; then
83              echo              echo
84              echo "Error building the mpack tools at: $MPACK_DIR"              echo "Error building the mpack tools at: $MPACK_DIR"
85              exit 1              echo
86                HAVE_MPACK=f
87            else
88                rm -f tr_build_mpack.out
89                HAVE_MPACK=t
90          fi          fi
91        else
92            HAVE_MPACK=t
93      fi      fi
94      echo "OK"      echo "OK"
95  }  }
96    
 compare_lines()  
 {  
     # use codelet to compare lines  
     if [ $verbose -gt 1 ]; then  
         cat tmp3.txt 1>&2  
     fi  
     return `./a.out < tmp3.txt`  
 }  
   
97  testoutput_for_prop()  testoutput_for_prop()
98  {  {
99      # testoutput_for_prop dir s1 label subdir      # testoutput_for_prop dir s1 label subdir extension
100      #      #
101      #  compares files in $dir/$subdir/output.txt and $dir/results/output.txt      #  compares files $dir/$subdir/$OUTPUTFILE and $dir/results/output.txt
102      #  using search strings s1 and text label      #  using search strings s1 and text label
103    
104      if [ $debug -gt 0 ]; then      if [ $debug -gt 0 ]; then
105          echo testoutput_for_prop: grep "$2" $1/$4/output.txt 1>&2          echo testoutput_for_prop: grep "$2" $1/$4/$OUTPUTFILE 1>&2
106      fi      fi
107      if [ -r $1/$4/output.txt ]; then      if [ -r $1/$4/$OUTPUTFILE ]; then
108          grep "$2" $1/$4/output.txt | sed 's/.*=//' | nl > tmp1.txt          grep "$2" $1/$4/$OUTPUTFILE | sed 's/.*=//' | cat -n > tmp1.txt
109          lncnt=`wc -l tmp1.txt | awk '{print $1}' `          lncntA=`wc -l tmp1.txt | awk '{print $1}' `
110          if [ $lncnt -lt 3 ]; then          if [ $lncntA -lt 3 ]; then
111              if [ $verbose -gt 0 ]; then              if [ $verbose -gt 0 ]; then
112                  echo Not enough lines of output when searching for "$2" 1>&2                  echo Not enough lines of output when searching for "$2" 1>&2
113              fi              fi
114              return 99              return 99
115          fi          fi
116      else      else
117          echo testoutput_for_prop: output.txt from model run was not readable 1>&2          echo testoutput_for_prop: $OUTPUTFILE from model run was not readable 1>&2
118          return 99          return 99
119      fi      fi
120      if [ $debug -gt 0 ]; then      if [ $debug -gt 0 ]; then
121          echo testoutput_for_prop: grep "$2" $1/results/output.txt 1>&2          echo testoutput_for_prop: grep "$2" $1/results/output.$5 1>&2
122      fi      fi
123      grep "$2" $1/results/output.txt | sed 's/.*=//' | nl > tmp2.txt      grep "$2" $1/results/output.$5 | sed 's/.*=//' | cat -n > tmp2.txt
124      lncnt=`wc -l tmp2.txt | awk '{print $1}' `      lncntB=`wc -l tmp2.txt | awk '{print $1}' `
125      if [ $lncnt -lt 3 ]; then      if [ $lncntB -lt 3 ]; then
126          if [ $verbose -gt 0 ]; then          if [ $verbose -gt 0 ]; then
127              echo Not enough lines of output when searching for "$2" 1>&2              echo Not enough lines of output when searching for "$2" 1>&2
128          fi          fi
129          return 99          return 99
130      fi      fi
131        if [ $lncntA -ne $lncntB ]; then
132            if [ $verbose -gt 0 ]; then
133                echo Not same Nb of lines when searching for "$2" ":" $lncntA $lncntB 1>&2
134            fi
135            return 99
136        fi
137        has_nan=`cat tmp1.txt | grep -i nan | wc -l`
138        if [ $has_nan -gt 0  ] ; then
139            echo testoutput_for_prop: $OUTPUTFILE contains $has_nan NaN values  1>&2
140            return 99
141        fi
142        has_inf=`cat tmp1.txt | grep -i inf | wc -l`
143        if [ $has_inf -gt 0  ] ; then
144            echo testoutput_for_prop: $OUTPUTFILE contains $has_inf Inf values  1>&2
145            return 99
146        fi
147      if [ $debug -gt 0 ]; then      if [ $debug -gt 0 ]; then
148          echo testoutput_for_prop: join tmp1.txt tmp2.txt 1>&2          echo testoutput_for_prop: join tmp1.txt tmp2.txt 1>&2
149      fi      fi
# Line 90  testoutput_for_prop() Line 151  testoutput_for_prop()
151      if [ $debug -gt 0 ]; then      if [ $debug -gt 0 ]; then
152          echo testoutput_for_prop: compare_lines 1>&2          echo testoutput_for_prop: compare_lines 1>&2
153      fi      fi
154      compare_lines      if [ $verbose -gt 1 ]; then
155      digits_of_similarity=$?          cat tmp3.txt 1>&2
156        fi
157        echo "-1" >> tmp3.txt
158        # On the SGI O3K (*not* the O2K), "cat -n" inserts a ":" after the line number
159        cat tmp3.txt | sed -e 's|:||g' > tmp4.txt
160        digits_of_similarity=`./tr_cmpnum < tmp4.txt`
161      if [ $digits_of_similarity -eq 99 ]; then      if [ $digits_of_similarity -eq 99 ]; then
162          if [ $verbose -gt 0 ]; then          if [ $verbose -gt 0 ]; then
163              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 168  testoutput_for_prop()
168              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
169          fi          fi
170      fi      fi
171      rm tmp1.txt tmp2.txt tmp3.txt      rm -f tmp1.txt tmp2.txt tmp3.txt tmp4.txt
172            
173      return $digits_of_similarity      return $digits_of_similarity
174  }  }
# Line 122  dashnum() Line 188  dashnum()
188      done      done
189  }  }
190    
191    testoutput_ad()
192    {
193        grep $3 $1/results_ad/output_adm.txt | awk '{print NR " " $5}' > t05.txt
194        grep $3 $1/$2/$OUTPUTFILE | awk '{print NR " " $5}' > t15.txt
195        grep $3 $1/results_ad/output_adm.txt | awk '{print NR " " $6}' > t06.txt
196        grep $3 $1/$2/$OUTPUTFILE | awk '{print NR " " $6}' > t16.txt
197        join t05.txt t15.txt > t5.txt
198        join t06.txt t16.txt > t6.txt
199        echo "-1" >> t5.txt
200        echo "-1" >> t6.txt
201        digits_5=`./tr_cmpnum < t5.txt`
202        digits_6=`./tr_cmpnum < t6.txt`
203        dashnum $digits_5 $digits_6
204        rm -f t[01][56].txt t[56].txt
205    }
206    
207    check_for_add_mon_output()
208    {
209        # Check for additional types of monitor output
210        if test "x$1" = x ; then
211            return
212        fi
213    
214        for ii in $PTRACERS_NUM ; do
215            eval "HAVE_PTR0"$ii"=f"
216        done
217    
218        ptr_add="trcstat_ptracerXX_min trcstat_ptracerXX_max"
219        ptr_add="$ptr_add trcstat_ptracerXX_mean trcstat_ptracerXX_sd"
220        for ii in $PTRACERS_NUM ; do
221            for jj in $ptr_add ; do
222                name=`eval "echo $jj | sed -e 's|XX|0"$ii"|g'"`
223                tst=`grep $name $1 | wc -l | awk '{print $1}'`
224                if test ! "x$tst" = x0 ; then
225                    eval "HAVE_PTR0"$ii"=t"
226                fi
227            done
228            #  eval 'echo "HAVE_PTR0'$ii' = $HAVE_PTR0'$ii'"'
229        done
230    }
231    
232  testoutput()  testoutput()
233  {  {
234      # testoutput diretory subdir      # testoutput directory subdir extension
235      #      #
236      #  test output in "directory"      #  test output in "directory"
237        if test "x$ADM" = x ; then
238            if [ $debug -gt 0 ]; then
239                echo testoutput: testoutput_for_prop $1 cg2d_init_res 1>&2
240            fi
241            testoutput_for_prop $1 "cg2d_init_res" "cg2d init. residual" $2 $3; cg2dres=$?
242            if [ $debug -gt 0 ]; then
243                echo testoutput: cg2dres=$cg2dres 1>&2
244            fi
245            testoutput_for_prop $1 "dynstat_theta_min" "theta minimum" $2 $3; tmin=$?
246            testoutput_for_prop $1 "dynstat_theta_max" "theta maximum" $2 $3; tmax=$?
247            testoutput_for_prop $1 "dynstat_theta_mean" "theta mean" $2 $3; tmean=$?
248            testoutput_for_prop $1 "dynstat_theta_sd" "theta s.d." $2 $3; tsd=$?
249            testoutput_for_prop $1 "dynstat_salt_min" "salt minimum" $2 $3; smin=$?
250            testoutput_for_prop $1 "dynstat_salt_max" "salt maximum" $2 $3; smax=$?
251            testoutput_for_prop $1 "dynstat_salt_mean" "salt mean" $2 $3; smean=$?
252            testoutput_for_prop $1 "dynstat_salt_sd" "salt s.d." $2 $3; ssd=$?
253            testoutput_for_prop $1 "dynstat_uvel_min" "U minimum" $2 $3; umin=$?
254            testoutput_for_prop $1 "dynstat_uvel_max" "U maximum" $2 $3; umax=$?
255            testoutput_for_prop $1 "dynstat_uvel_mean" "U mean" $2 $3; umean=$?
256            testoutput_for_prop $1 "dynstat_uvel_sd" "U s.d." $2 $3; usd=$?
257            testoutput_for_prop $1 "dynstat_vvel_min" "V minimum" $2 $3; vmin=$?
258            testoutput_for_prop $1 "dynstat_vvel_max" "V maximum" $2 $3; vmax=$?
259            testoutput_for_prop $1 "dynstat_vvel_mean" "V mean" $2 $3; vmean=$?
260            testoutput_for_prop $1 "dynstat_vvel_sd" "V s.d." $2 $3; vsd=$?
261    
262            #  This is for PTRACERS
263            for ii in $PTRACERS_NUM ; do
264                eval `echo "p0"$ii"_min=99"`
265                eval `echo "p0"$ii"_max=99"`
266                eval `echo "p0"$ii"_mean=99"`
267                eval `echo "p0"$ii"_sd=99"`
268                tst=`eval 'echo "$HAVE_PTR0'$ii'"'`
269                #echo 'tst = '$tst
270                if test "x$tst" = xt ; then
271                    a="trcstat_ptracer0"
272                    testoutput_for_prop $1 "$a"$ii"_min"  "p0"$ii"_min"  $2 $3
273                    RETVAL=$? ; eval `echo "p0"$ii"_min="$RETVAL`
274                    testoutput_for_prop $1 "$a"$ii"_max"  "p0"$ii"_max"  $2 $3
275                    RETVAL=$? ; eval `echo "p0"$ii"_max="$RETVAL`
276                    testoutput_for_prop $1 "$a"$ii"_mean" "p0"$ii"_mean" $2 $3
277                    RETVAL=$? ; eval `echo "p0"$ii"_mean="$RETVAL`
278                    testoutput_for_prop $1 "$a"$ii"_sd"   "p0"$ii"_sd"   $2 $3
279                    RETVAL=$? ; eval `echo "p0"$ii"_sd="$RETVAL`
280                fi
281            done
282    
283      if [ $debug -gt 0 ]; then          allargs="$cg2dres $tmin $tmax $tmean $tsd $smin $smax $smean $ssd"
284          echo testoutput: testoutput_for_prop $1 cg2d_init_res 1>&2          allargs="$allargs $umin $umax $umean $usd $vmin $vmax $vmean $vsd"
285      fi          allargs="$allargs $p01_min $p01_max $p01_mean $p01_sd"
286      testoutput_for_prop $1 "cg2d_init_res" "cg2d init. residual" $2; cg2dres=$?          allargs="$allargs $p02_min $p02_max $p02_mean $p02_sd"
287      if [ $debug -gt 0 ]; then          allargs="$allargs $p03_min $p03_max $p03_mean $p03_sd"
288          echo testoutput: cg2dres=$cg2dres 1>&2          allargs="$allargs $p04_min $p04_max $p04_mean $p04_sd"
289            allargs="$allargs $p05_min $p05_max $p05_mean $p05_sd"
290    
291            eval "dashnum $allargs"
292    
293        else
294            testoutput_ad $1 $2 "precision_grdchk_result"
295      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  
296  }  }
297    
298  genmakemodel()  genmakemodel()
299  {  {
300      # genmakemodel directory      # genmakemodel directory
301      GENMAKE2="../../../tools/genmake2"      if test "x$NOGENMAKE" = xt ; then
302      (          echo "genmake skipped!"
303          cd $1;      else
304          printf 'genmake ... ' 1>&2          if test "x$BASH" = x ; then
305          # ../../../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  
306          else          else
307              echo "succesful" 1>&2              GENMAKE2="$BASH ../../../tools/genmake2 -bash $BASH"
308          fi          fi
309      )          (
310                cd $1;
311                command="$GENMAKE2  -ds -m $MAKE"
312                if test "x$ADM" = x ; then
313                    command="$command --mods=../code"
314                else
315                    command="$command --mods=../code_ad"
316                fi
317                if test "x$OPTFILE" != xNONE ; then
318                    command="$command --optfile=$OPTFILE"
319                fi
320                if test "x$IEEE" != x ; then
321                    command="$command -ieee"
322                fi
323                if test "x$MPI" = xt ; then
324                    command="$command -mpi"
325                fi
326                if test "x$TS" = xt ; then
327                    command="$command -ts"
328                fi
329                if test "x$PAPIS" = xt ; then
330                    command="$command -papis"
331                else
332                if test "x$PCLS" = xt ; then
333                    command="$command -pcls"
334                fi
335                fi
336                printf 'genmake ... ' 1>&2
337                $command > make.log 2>&1
338                RETVAL=$?
339                #  Reduce the size of the testing emails!
340                head -100 Makefile > $CDIR/Makefile_head
341                if test "x$RETVAL" != x0 ; then
342                    tail make.log
343                    echo "genmakemodel: genmake failed" 1>&2
344                    cp genmake_* make.log $CDIR
345                    return 1
346                else
347                    echo "successful" 1>&2
348                fi
349            )
350        fi
351  }  }
352    
353  makeclean()  makeclean()
354  {  {
355      # makeclean directory      # makeclean directory
356      (      if test "x$NOCLEAN" = xt ; then
357          cd $1;          echo "make Clean skipped!"
358          rm -f output.txt      else
359          printf 'make CLEAN ... ' 2>&1          (
360          if test -r Makefile ; then              cd $1;
361              make CLEAN >> make.log 2>&1              #if test -e $OUTPUTFILE ; then rm -f $OUTPUTFILE ; fi
362              RETVAL=$?              if test -r Makefile ; then
363              if test "x$RETVAL" != x0 ; then                  printf 'clean build-dir: make Clean ... ' 2>&1
364                  tail make.log                  $MAKE Clean >> make.log 2>&1
365                  echo "makeclean: \"make CLEAN\" failed" 1>&2                  RETVAL=$?
366                  cp make.log $CDIR"/make.log"                  if test "x$RETVAL" != x0 ; then
367                  return 1                      tail make.log
368                        echo "makeclean: \"make Clean\" failed" 1>&2
369                        cp make.log $CDIR"/make.log"
370                        return 1
371                    fi
372              fi              fi
373          fi              echo successful 1>&2
374          echo succesful 1>&2              exit 0
375          exit 0          )
376      )      fi
377    }
378    
379    run_clean()
380    {
381        # run_clean directory
382        if test "x$NOCLEAN" = xt ; then
383            echo "run_clean skipped!"
384        else
385            (
386                cd $1;
387                printf 'clean run-dir ... ' 2>&1
388                # part of what is done after "make clean" when doing "make CLEAN"
389                find . -name "*.meta" -exec rm {} \;
390                find . -name "*.data" -exec rm {} \;
391                find . -name "fort.*" -exec rm {} \;
392                find . -type l -exec rm {} \;
393                rm -f $EXECUTABLE *.txt STD* *diagnostics.log datetime
394                rm -rf mnc_test_*
395                echo successful 1>&2
396                exit 0
397            )
398        fi
399  }  }
400    
401  makedependmodel()  makedependmodel()
402  {  {
403      # makedependmodel directory      # makedependmodel directory
404      (      if test "x$NODEPEND" = xt ; then
405          cd $1;          echo "make depend skipped!"
406          printf 'make depend ... ' 1>&2      else
407          make depend >> make.log 2>&1          (
408          RETVAL=$?              cd $1;
409          if test "x$RETVAL" != x0 ; then              printf 'make depend ... ' 1>&2
410              tail make.log              $MAKE depend >> make.log 2>&1
411              echo "makedependmodel: make depend failed" 1>&2              RETVAL=$?
412              cp make.log $CDIR"/make.log"              if test "x$RETVAL" != x0 ; then
413              return 1                  tail make.log
414          else                  echo "makedependmodel: make depend failed" 1>&2
415              echo succesful 1>&2                  cp make.log $CDIR"/make.log"
416          fi                  return 1
417      )              else
418                    echo successful 1>&2
419                fi
420            )
421        fi
422  }  }
423    
424  makemodel()  makemodel()
# Line 231  makemodel() Line 428  makemodel()
428          cd $1;          cd $1;
429          if test -r Makefile ; then          if test -r Makefile ; then
430              printf 'make ... ' 1>&2              printf 'make ... ' 1>&2
431              make >> make.log 2>&1              if test "x$ADM" = x ; then
432                    if test "x$JOBS" = x ; then
433                        $MAKE >> make.log 2>&1
434                    else
435                        $MAKE -j $JOBS >> make.log 2>&1
436                    fi
437                else
438                    $MAKE adall >> make.log 2>&1
439                fi
440              RETVAL=$?              RETVAL=$?
441              if test "x$RETVAL" != x0 ; then              if test "x$RETVAL" != x0 ; then
442                  tail make.log                  tail make.log
# Line 239  makemodel() Line 444  makemodel()
444                  cp make.log $CDIR"/make.log"                  cp make.log $CDIR"/make.log"
445                  return 1                  return 1
446              else              else
447                  echo succesful 1>&2                  echo successful 1>&2
448              fi              fi
449          fi          fi
450      )      )
451  }  }
452    
453    symlink_mpifiles()
454    {
455        # Put special links so that MPI specific files are used
456        # This MUST be invoked between makeclean and makelinks because
457        # the Makefile will link to non-mpi files by default
458    
459        dir=$1
460        code_dir=$2
461        BUILD_DIR=$dir/$3
462        CODE_DIR=$dir/$code_dir
463        
464        # These are files that should replace their counter-part when using -mpi
465        MPI_FILES=`(cd $CODE_DIR; find . -name "*_mpi")`
466    
467        #  Is this an MPI run?
468        if test "x$MPI" = xt ; then
469            # YES: We symbolically link these files to the build
470            # dir so long as there is no real file in place
471            for ii in $MPI_FILES ; do
472                i=`echo $ii | sed 's:^\./::'`
473                name=`echo $i | sed 's:_mpi::' `
474                cmp $CODE_DIR/$i $BUILD_DIR/$name > /dev/null 2>&1
475                RETVAL=$?
476                if test "x$RETVAL" != x0 ; then
477                    if ! test -f $BUILD_DIR/$i ; then
478                        #echo Linking $name to $i
479                        (cd $BUILD_DIR; ln -sf ../$code_dir/$i $name)
480                    fi
481                fi
482            done
483        else
484            # NO: We undo any _mpi symbolically linked files
485            for ii in $MPI_FILES ; do
486                i=`echo $ii | sed 's:^\./::'`
487                name=`echo $i | sed 's:_mpi::' `
488                if test -L $BUILD_DIR/$name ; then
489                    cmp $BUILD_DIR/$name "../$code_dir/$name"_mpi > /dev/null 2>&1
490                    RETVAL=$?
491                    if test "x$RETVAL" = x0 ; then
492                        #echo Un-linking $name from $linktarg
493                        rm -f $BUILD_DIR/$name
494                    fi
495                fi
496            done
497        fi
498        
499    }
500    
501  linkdata()  linkdata()
502  {  {
503      # linkdata flag      # linkdata run_dir input_dir_1 input_dir_2 ...
504      #      #
505      # symbolically link data files to run directory      # symbolically link data files to run directory
506      if [ $1 -ne 0 ]; then      if test -d $1 ; then
507          ( cd $2 ;  ln -sf ../input/* . )          (
508                cd $1 ; shift
509                if test -r "../"$1"/eedata.mth" ; then
510                # found eedata.mth in 1rst input dir and it is readable
511                    if test "x$MULTI_THREAD" = "xt" ; then
512                    # multi-threaded test: remove symbolic link & link eedata.mth
513                        if test -h eedata ; then rm -f eedata ; fi
514                        if test ! -r eedata ; then
515                            ln -sf "../"$1"/eedata.mth" eedata ;
516                            printf 'eedata.mth ' 1>&2
517                        fi
518                    else
519                    # not multi-threaded test: remove eedata symbolic link
520                        if test -h eedata ; then rm -f eedata ; fi
521                    fi
522                fi
523                for ldir in $* ; do
524                    if test -d "../"$ldir ; then
525                        printf 'ldir='${ldir} 1>&2
526                        files=`( cd "../"$ldir ; ls -1 | grep -v CVS )`
527                        for i in $files ; do
528                            if test ! -d "../"$ldir/$i ; then
529                                if test ! -r $i  ; then
530                                    printf ' '$i 1>&2
531                                    ln -sf "../"$ldir"/"$i $i
532                                fi
533                            fi
534                        done
535                        if test -x "../"$ldir"/"prepare_run ; then
536                            "../"$ldir"/"prepare_run
537                        fi
538                        printf ' ; ' 1>&2
539                    fi
540                done
541            )
542      fi      fi
543  }  }
544    
545  runmodel()  runmodel()
546  {  {
547      # runmodel directory exe      # runmodel directory
548      #      #
549      #  runs the model "exe" in "directory" (exe is relative to directory)      #  runs "$COMMAND in "directory"
550        #  (where "$COMMAND" is relative to "directory")
551      (      (
552          cd $1          cd $1
553          if [ -x $2 ]; then          printf 'runmodel in %s ...' $1 1>&2
554              if [ $quick -eq 0 ]; then          # make output.txt
555                  rm -f output.txt          echo
556              fi          if test ! -x $EXECUTABLE -a -x "../"$builddir"/"$EXECUTABLE ; then
557              printf 'runmodel: ' 1>&2              echo " link" $EXECUTABLE "from dir ../"$builddir > run.log_00
558              make output.txt              ln -sf "../"$builddir"/"$EXECUTABLE .
559              RETVAL=$?          fi
560              if test "x$RETVAL" = x0 ; then          if test ! -x $EXECUTABLE ; then
561                  cp output.txt $CDIR"/output.txt"                  rm -f run.log ; touch run.log
562                  return 0                  if test -f run.log_00 ; then cat run.log_00 >> run.log ; fi
563                    echo " no executable:" $EXECUTABLE >> run.log
564                    RETVAL=8
565                    ENDVAL=-1
566            else
567                if test $OUTPUTFILE -ot $EXECUTABLE ; then
568                    rm -f run.log ; touch run.log
569                    if test -f run.log_00 ; then cat run.log_00 >> run.log ; fi
570                    ( eval $COMMAND ) >> run.log 2>&1
571                    RETVAL=$?
572              else              else
573                  return 1                  RETVAL=0
574                    if test -f run.log ; then
575                        if test -f run.log_00 ; then cat run.log_00 >> run.log ; fi
576                        echo "---------->> $OUTPUTFILE is up to date " >> run.log 2>&1
577                    else
578                        touch run.log
579                        if test -f run.log_00 ; then cat run.log_00 >> run.log ; fi
580                        echo "---------->> $OUTPUTFILE is up to date " >> run.log 2>&1
581                        echo " no previous run.log: assume NORMAL END" >> run.log 2>&1
582                    fi
583              fi              fi
584                ENDVAL=`cat run.log | grep -v 'ABNORMAL END' | grep -c 'NORMAL END'`
585            fi
586            rm -f run.log_00
587            #if test "x$RETVAL" = x0 ; then
588            if [ $RETVAL -eq 0 -a $ENDVAL -gt 0 ] ; then
589                tail run.log
590                echo successful 1>&2
591                # === Reduce the size of the testing emails!
592                #cp $OUTPUTFILE $CDIR"/"$OUTPUTFILE
593                if test -s STDERR.0000 ; then cp STDERR.0000 $CDIR"/STDERR.0000" ; fi
594                return 0
595            else
596                tail run.log
597                echo failed '(run:' $RETVAL ' end:' $ENDVAL ')' 1>&2
598                cp run.log $CDIR"/run.log"
599                if test -s STDERR.0000 ; then cp STDERR.0000 $CDIR"/STDERR.0000" ; fi
600                return 1
601          fi          fi
602      )      )
603  }  }
# Line 283  createcodelet() Line 606  createcodelet()
606  {  {
607      # create codelet for comparing model output      # create codelet for comparing model output
608    
609      echo -n "creating the comparison code...  "      printf "creating the comparison code...  "
610      cat > tmp_cmpnum.f <<EOFA      cat > tr_cmpnum.c <<EOF
611        program cmpnum  #include <stdio.h>
612        implicit none  #include <math.h>
613        real*8 a,b,diff  int main( int argc, char** argv )  {
614        integer linnum,best    int linnum,cmplin,best,lncnt;
615        best=-16    double a,b,abave,relerr;
616    99  read(*,*,end=70,err=60) linnum,a,b    best = -22;
617        diff=0.5*(abs(a)+abs(b))    lncnt = 0;
618  c     print *,a,b,diff,abs(a-b)/diff    while( 1 & (lncnt+=1) < 999 )  {
619        if (diff.gt.1.e-12) then      scanf("%d", &linnum);
620          diff=abs(a-b)/diff      if (linnum == -1)  break;
621          if (diff.gt.0.) then      scanf("%lf", &a);  scanf("%lf", &b);
622  c         print *,int(log10(diff)),diff      abave = 0.5*(fabs(a)+fabs(b));
623            linnum=int(log10(diff))      if ( abave == abave ) {
624            best=max(best,linnum)        if (abave > 0.0) {
625          endif          relerr=fabs(a-b)/abave;
626        else          if (relerr > 0.0) { cmplin = (int)rint(log10(relerr)); }
627          if (best.eq.-16.and.diff.ne.0.) best=-22          else { cmplin = -16 ; }
628        endif          best = (best > cmplin) ? best : cmplin; }
629        goto 99        else { cmplin = -22 ; }
630    60  stop 'cmpnum: An error occured reading a,b'     /* printf("%d ; %lf ; %lf\n",cmplin,a,b); */
631    70  print *,-best        }
632        end     else {
633  EOFA     /* printf("%lf ; %lf ; %lf\n",abave,a,b); */
634          break; }
635      }
636      if (lncnt == 999) best=-29;
637      if (linnum != -1) best=-99;
638      printf("%d\n", -best);
639      return 0;
640    }
641    EOF
642        $CC -o tr_cmpnum tr_cmpnum.c -lm
643    
644      f77 tmp_cmpnum.f      if [ -x ./tr_cmpnum ]; then
     if [ -x ./a.out ]; then  
645          echo "OK"          echo "OK"
646          return 0          return 0
647      else      else
648          echo          echo
649          echo "createcodelet: failed to compile codelet" | tee          echo "ERROR: failed to compile comparison code -- please specify"
650            echo "  a C compiler using the CC environment variable."
651          exit 1          exit 1
652      fi      fi
653  }  }
# Line 332  formatresults() Line 664  formatresults()
664      if [ $1 = '--' ]; then      if [ $1 = '--' ]; then
665          printf ' N/O '          printf ' N/O '
666      else      else
667          if [ $1 -gt 12 ]; then          if [ $1 -ge $MATCH_CRIT ]; then
668              printf ' pass'              printf ' pass'
669          else          else
670              printf ' FAIL'              printf ' FAIL'
# Line 343  formatresults() Line 675  formatresults()
675            
676  }  }
677    
 show_help()  
 {  
     cat - << EOF  
 $0 [-help] [-quick] [-verbose] dir1 [dir2] [...]  
  -help      Show this help message  
  -quick     Skip "genmake" and "make depend" if the Makefile exists  
  -quiet     Reduce the amount of output  
  -verbose   Produce copious amounts of output  
  -debug     Produce even more output which will mean nothing to most  
  -force     Do "make CLEAN" before compiling. This forces a complete rebuild.  
  -clean     Do "make CLEAN" after compiling and testing.  
  -noieee    By default, $0 uses the -ieee option for genmake. This turns it off.  
  -cleanup   Aggresively removes all model output, executables and object files  
             and then exits. Use with care.  
   
 Normal usage:  
  $0 *       Configure, compile, run and analyze in all experiment directories  
 EOF  
 }  
   
678  scandirs()  scandirs()
679  {  {
680      if [ $# -eq 0 ]; then      if [ $# -eq 1 ]; then
681          for arg in * ; do          for arg in * ; do
682              test -d $arg/input && echo $arg              test -d $arg/$1 && echo $arg
683          done          done
684      else      else
685          echo $*          echo $*
686      fi      fi
687  }  }
688    
689    
690  ###############################################################################  ###############################################################################
 ###############################################################################  
 ###############################################################################  
691    
692    
693  #  Default properties  #  Default properties
694  debug=0  debug=0
695  verbose=1  verbose=1
 quick=0  
696  clean=0  clean=0
 ieee=1  
697  expts=''  expts=''
698    # ieee=1
699    
700  OPTFILES=  IEEE=true
701  ADDRESSES=edhill@mitgcm.org  if test "x$MITGCM_IEEE" != x ; then
702        IEEE=$MITGCM_IEEE
703    fi
704    
705    
706    CLEANUP=f
707    QUICK=f
708    NOGENMAKE=f
709    NOCLEAN=f
710    NODEPEND=f
711    POSTCLEAN=f
712    
713    BASH=
714    OPTFILE=NONE
715    ADDRESSES=
716  TESTDIRS=  TESTDIRS=
717    SKIPDIRS=
718  MPACKDIR="../tools/mpack-1.6"  MPACKDIR="../tools/mpack-1.6"
719    HAVE_MPACK=
720  MPACK="$MPACKDIR/mpack"  MPACK="$MPACKDIR/mpack"
721    COMMAND=
722    if test "x$MAKE" = x ; then
723        MAKE=make
724    fi
725    if test "x$CC" = x ; then
726        CC=cc
727    fi
728    JOBS=
729    MPI=f
730    MULTI_THREAD=f
731    OUTDIR=
732    DELDIR=
733    
734    ADM=
735    
736    # Additional monitor types
737    PTRACERS_NUM="1 2 3 4 5"
738    
739    MATCH_CRIT=13
740    
741  echo -n "parsing options...  "  printf "parsing options...  "
742    
743  ac_prev=  ac_prev=
744  for ac_option ; do  for ac_option ; do
# Line 414  for ac_option ; do Line 758  for ac_option ; do
758              usage ;;              usage ;;
759                    
760          -optfile | --optfile | -of | --of)          -optfile | --optfile | -of | --of)
761              ac_prev=OPTFILES ;;              ac_prev=OPTFILE ;;
762          -optfile=* | --optfile=* | -of=* | --of=*)          -optfile=* | --optfile=* | -of=* | --of=*)
763              OPTFILES=$ac_optarg ;;              OPTFILE=$ac_optarg ;;
764                    
765          -addr | --addr | -a | --a)          -addr | --addr | -a | --a)
766              ac_prev=ADDRESSES ;;              ac_prev=ADDRESSES ;;
# Line 428  for ac_option ; do Line 772  for ac_option ; do
772          -tdir=* | --tdir=*)          -tdir=* | --tdir=*)
773              TESTDIRS=$ac_optarg ;;              TESTDIRS=$ac_optarg ;;
774    
775          -quick) quick=1 ;;          -skipdir | --skipdir | -skd | --skd)
776                ac_prev=SKIPDIRS ;;
777            -skipdir=* | --skipdir=*)
778                SKIPDIRS=$ac_optarg ;;
779    
780            -bash | --bash | -b | --b)
781                ac_prev=BASH ;;
782            -bash=* | --bash=*)
783                BASH=$ac_optarg ;;
784    
785            -command | --command | -c | --c)
786                ac_prev=COMMAND ;;
787            -command=* | --command=*)
788                COMMAND=$ac_optarg ;;
789    
790            -make | --make | -m | --m)
791                ac_prev=MAKE ;;
792            -make=* | --make=*)
793                MAKE=$ac_optarg ;;
794    
795            -odir | --odir)
796                ac_prev=OUTDIR ;;
797            -odir=* | --odir=*)
798                OUTDIR=$ac_optarg ;;
799    
800            -ptracers | --ptracers | -ptr | --ptr)
801                ac_prev=PTRACERS_NUM ;;
802            -ptracers=* | --ptracers=* | -ptr=* | --ptr=*)
803                PTRACERS_NUM=$ac_optarg ;;
804    
805            -match | --match ) ac_prev=MATCH_CRIT ;;
806            -match=* | --match=* ) MATCH_CRIT=$ac_optarg ;;
807    
808            -j) ac_prev=JOBS ;;
809            -j=*) JOBS=$ac_optarg ;;
810    
811            -clean | --clean)
812                CLEANUP=t ; DELDIR=t ;;
813    
814            -quick | --quick | -q | --q)
815                QUICK=t ;;
816            -nogenmake | --nogenmake | -ng | --ng)
817                NOGENMAKE=t ;;
818            -noclean | --noclean | -nc | --nc)
819                NOCLEAN=t ;;
820            -nodepend | --nodepend | -nd | --nd)
821                NODEPEND=t ;;
822    
823            -postclean | --postclean | -pc | --pc)
824                POSTCLEAN=t ;;
825    
826            -mpi) MPI=t ;;
827    
828            -mth) MULTI_THREAD=t ;;
829    
830            -adm | -ad) ADM=t ;;
831    
832            -ieee) IEEE=true ;;
833            -noieee) IEEE= ;;
834    
835          -verbose) verbose=2 ;;          -verbose) verbose=2 ;;
836          -debug) debug=1 ;;          -debug) debug=1 ;;
         -clean) clean=1 ;;  
         -noieee) ieee=0 ;;  
837          -quiet) verbose=0 ;;          -quiet) verbose=0 ;;
838    
839            -deldir | -dd) DELDIR=t ;;
840    
841            -ts) TS=t;;
842    
843            -papis) PAPIS=t;;
844    
845            -pcls) PCL=t;;
846    
847          -*)          -*)
848              echo "Error: unrecognized option: "$ac_option              echo "Error: unrecognized option: "$ac_option
849              usage              usage
# Line 449  for ac_option ; do Line 858  for ac_option ; do
858            
859  done  done
860    
861    if test "x$QUICK" = xt ; then
862        NOGENMAKE=t
863        NOCLEAN=t
864        NODEPEND=t
865    fi
866    
867  if test "x$TESTDIRS" = x ; then  if test "x$TESTDIRS" = x ; then
868      TESTDIRS=`scandirs`      if test "x$ADM" = xt ; then
869            LIST=`scandirs results_ad`
870        else
871            LIST=`scandirs results`
872        fi
873    else
874        #- expand group of experiments:
875        LIST=" "
876        for xx in $TESTDIRS
877        do
878          case $xx in
879            'basic') LIST=${LIST}" aim.5l_cs hs94.128x64x5 ideal_2D_oce"
880                     LIST=${LIST}" lab_sea tutorial_baroclinic_gyre"
881                     LIST=${LIST}" tutorial_global_oce_latlon tutorial_plume_on_slope"
882                    ;;
883            'tutorials')
884                     LIST=${LIST}" "`ls | grep 'tutorial_'` ;;
885            *)       LIST=${LIST}" "$xx ;;
886          esac
887        done
888    fi
889    #echo 'LIST='${LIST}'<'
890    #- skip dirs, remove duplicate and non-directory:
891    TESTDIRS=" "
892    count=0
893    for xx in $LIST
894    do
895        yy=`echo $SKIPDIRS | grep -c $xx`
896        if test $yy = 0 ; then
897            if test -d $xx ; then
898                yy=`echo $TESTDIRS | grep -c $xx`
899                if test $yy = 0 ; then TESTDIRS=${TESTDIRS}" "$xx ; fi
900            else count=1 ;
901                echo ""; echo -n " -- skip \"$xx\" (not a directory !)"
902            fi
903        else
904            if test $count = 1 ; then echo -n ", \"$xx\""
905            else count=1 ; echo "" ;  echo -n " skip: \"$xx\""
906            fi
907        fi
908    done
909    if test $count = 1 ; then echo "" ; echo -n " ... " ; fi
910    #echo 'TESTDIRS='${TESTDIRS}'<'
911    
912    if test "x$OPTFILE" = xNONE -a "x$MITGCM_OF" != x ; then
913        OPTFILE=$MITGCM_OF
914    fi
915    
916    if test "x$ADM" = xt ; then
917        EXECUTABLE="mitgcmuv_ad"
918        OUTPUTFILE="output_adm.txt"
919    else
920        EXECUTABLE="mitgcmuv"
921        OUTPUTFILE="output.txt"
922    fi
923    
924    if test "x$COMMAND" = x ; then
925        COMMAND="./$EXECUTABLE > $OUTPUTFILE"
926    fi
927    if test "x$MPI" = xt ; then
928        OUTPUTFILE="STDOUT.0000"
929  fi  fi
930    
931  echo "OK"  #echo "OK"
932    echo "OK (COMMAND= $COMMAND )"
933    
934  #  create the FORTRAN comparison code  #  create the FORTRAN comparison code
935  createcodelet  createcodelet
936    
937  #  build the mpack utility  #  build the mpack utility
938  build_mpack  if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then
939        echo "skipping mpack build"
940    else
941        build_mpack
942    fi
943    
944  #  Create a uniquely named directory to store results  #  Create a uniquely named directory to store results
945  MACH=`hostname`  MACH=`hostname`
946  UNAMEA=`uname -a`  UNAMEA=`uname -a`
947  DATE=`date +%Y%m%d`  DATE=`date +%Y%m%d`
948  BASE=$MACH"_"$DATE"_"  BASE="tr_"$MACH"_"$DATE"_"
949    if test "x$OUTDIR" != x ; then
950        BASE="tr_"$OUTDIR"_"$DATE"_"
951    fi
952  DNUM=0  DNUM=0
953  DRESULTS="$BASE$DNUM"  DRESULTS="$BASE$DNUM"
954  while test -e $DRESULTS ; do  while test -e $DRESULTS ; do
# Line 475  done Line 958  done
958  mkdir $DRESULTS  mkdir $DRESULTS
959  RETVAL=$?  RETVAL=$?
960  if test "x$RETVAL" != x0 ; then  if test "x$RETVAL" != x0 ; then
961      echo "Error: can't create results directory \"./$DRESULTS\""      echo "ERROR: Can't create results directory \"./$DRESULTS\""
962      exit 1      exit 1
963  fi  fi
964  SUMMARY="$DRESULTS/summary.txt"  SUMMARY="$DRESULTS/summary.txt"
965  date > $SUMMARY  printf "Start time:  " >> $SUMMARY
966  cat << EOF >> $SUMMARY  start_date=`date`
967                  T           S           U           V  echo $start_date > $SUMMARY
968  G D M    c        m  s        m  s        m  s        m  s  
969  E p a R  g  m  m  e  .  m  m  e  .  m  m  e  .  m  m  e  .  of_path=
970  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
971  2 d e n  d  n  x  n  .  n  x  n  .  n  x  n  .  n  x  n  .      if test -r $OPTFILE ; then
972            # get the path
973            path=${OPTFILE%/*}
974            if test "x$path" = x ; then
975                of_path=`pwd`
976            else
977                of_path=`( cd $path > /dev/null 2>&1 ; pwd )`
978            fi
979            file=${OPTFILE##*/}
980            OPTFILE=$of_path/$file
981            cp $OPTFILE $DRESULTS
982            echo >> $SUMMARY
983            echo "  OPTFILE=$OPTFILE" >> $SUMMARY
984        else
985            echo | tee $SUMMARY
986            echo "ERROR: can't read OPTFILE=\"$OPTFILE\"" | tee $SUMMARY
987            exit 1
988        fi
989    else
990        echo >> $SUMMARY
991        echo "No \"OPTFILE\" was explicitly specified by testreport," >> $SUMMARY
992        echo "   so the genmake default will be used." >> $SUMMARY
993    fi
994    echo
995    echo >> $SUMMARY
996    if test "x$ADM" = x ; then
997        if [ $MATCH_CRIT -lt 10 ] ;
998        then line_0="      "$MATCH_CRIT ;
999        else line_0="     "$MATCH_CRIT ; fi
1000        line_0="   $line_0  ----T-----  ----S-----  ----U-----  ----V-----"
1001    #   line_0="            ----T-----  ----S-----  ----U-----  ----V-----"
1002        line_1="G D M    c        m  s        m  s        m  s        m  s"
1003        line_2="E p a R  g  m  m  e  .  m  m  e  .  m  m  e  .  m  m  e  ."
1004        line_3="N n k u  2  i  a  a  d  i  a  a  d  i  a  a  d  i  a  a  d"
1005        line_4="2 d e n  d  n  x  n  .  n  x  n  .  n  x  n  .  n  x  n  ."
1006        for ii in $PTRACERS_NUM ; do
1007            #  tst=`eval 'echo $HAVE_PTR0'$ii`
1008            #  if test "x$tst" = xt ; then
1009            line_0="$line_0  --PTR 0"$ii"--"
1010            line_1="$line_1        m  s"
1011            line_2="$line_2  m  m  e  ."
1012            line_3="$line_3  i  a  a  d"
1013            line_4="$line_4  n  x  n  ."
1014            #  fi
1015        done
1016        echo "$line_0" | tee -a $SUMMARY
1017        echo "$line_1" | tee -a $SUMMARY
1018        echo "$line_2" | tee -a $SUMMARY
1019        echo "$line_3" | tee -a $SUMMARY
1020        echo "$line_4" | tee -a $SUMMARY
1021        echo " "       | tee -a $SUMMARY
1022    else
1023        echo "ADJOINT=true" >> $SUMMARY
1024        echo >> $SUMMARY
1025        cat << EOF | tee -a $SUMMARY
1026    G D M    C  G
1027    E p a R  o  r
1028    N n k u  s  a
1029    2 d e n  t  d
1030    
1031  EOF  EOF
1032    fi
1033    
1034  NDIR=0  #  ...and each test directory...
1035    for dir in $TESTDIRS ; do
1036        
1037        #  Cleanup only!
1038        if test "x$CLEANUP" = xt ; then
1039            if test -r $dir/build/Makefile ; then
1040                echo '  ------  clean dir:' $dir/build
1041                ( cd $dir/build ; make CLEAN )
1042            fi
1043            if test -d $dir/run/CVS ; then
1044                echo '  ------  clean dir:' $dir/run
1045                run_clean $dir/run
1046            fi
1047            (
1048                cd $dir
1049                rm -rf tr_run.*
1050            )
1051            continue
1052        fi
1053    
1054  #  For each optfile...      #  Verify that the testdir exists and contains previous
1055  for OPTFILE in $OPTFILES ; do      #  results in the correct location--or skip this directory!
1056        fout=
1057        if test "x$ADM" = x ; then
1058            fout=$dir"/results/output.txt"
1059        else
1060            fout=$dir"/results_ad/output_adm.txt"
1061        fi
1062        if test ! -r $fout ; then
1063            echo "can't read \"$fout\" -- skipping $dir"
1064            continue
1065        fi
1066        if test "x$ADM" = x ; then
1067            check_for_add_mon_output  $fout
1068        fi
1069    
1070      OPTFILE=`pwd`"/$OPTFILE"      # Check for additional types of monitor output
1071      if test ! -r $OPTFILE ; then  
1072          echo "Error: can't read optfile \"$OPTFILE\""      builddir="build"
1073          exit 1      if test ! -d $dir/$builddir ; then mkdir $dir/$builddir ; fi
1074        rundir="run"
1075       #rundir=$builddir
1076        if test ! -d $dir/$rundir ; then
1077            rundir=$builddir
1078      fi      fi
     echo  
     echo "OPTFILE=$OPTFILE" >> $SUMMARY  
     echo >> $SUMMARY  
1079            
1080      #  ...and each test directory...      if test "x$ADM" = x ; then
1081      for dir in $TESTDIRS ; do          code_dir=code
1082                    CODE_DIR=$dir/code
1083          #  Create an output dir for each OPTFILE/tdir combination          input_dirs='input'
1084          CDIR=$DRESULTS"/"$DRESULTS"_"$NDIR      else
1085          mkdir $CDIR          code_dir=code_ad
1086          CDIR=`pwd`"/$CDIR"          CODE_DIR=$dir/code_ad
1087            input_dirs='input_ad input'
1088        fi
1089        BUILD_DIR=$dir/$builddir
1090    
1091          #  ...configue, make, run, and compare the output.      if test ! -r $CODE_DIR"/SIZE.h_mpi" -a "x$MPI" = "xt" ; then
1092          echo "-------------------------------------------------------------------------------"          echo "can't find \"$CODE_DIR/SIZE.h_mpi\" -- skipping $dir"
1093          echo          continue
1094          echo "Experiment:  $dir"      fi
1095          echo      if test ! -r $dir"/input/eedata.mth" -a "x$MULTI_THREAD" = "xt" ; then
1096          unset genmake makedepend make run          echo "can't find \"$dir/input/eedata.mth\" -- skipping $dir"
1097          results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --'          continue
1098          ( cd $dir/input; rm -f *.{o,f,c,F} *.[f,F]90 work* output.txt Make* make.log; )      fi
         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  
1099    
1100          #  Verify that the testdir exists and contains previous      #  Check whether there are "extra runs" for this testdir
1101          #  results in the correct location--or skip this directory!      extra_runs=
1102          if test ! -r $dir"/results/output.txt" ; then      if test "x$ADM" = x ; then
1103              echo | tee $SUMMARY          ex_run_dirs=`( cd $dir ; echo input.* )`
1104              echo "can't read \"$dir/results/output.txt\" -- skipping $dir" \          #echo "ex_run_dirs='$ex_run_dirs'"
1105                  | tee $SUMMARY          for exd in $ex_run_dirs ; do
1106              continue              name=`echo $exd | sed -e 's/input.//g'`
1107          fi              outf="$dir/results/output.$name.txt"
1108                if test -f $outf -a -r $outf ; then
1109                    if test "x$MULTI_THREAD" = "xt" ; then
1110                        if test -r $dir"/"$exd"/eedata.mth" ; then
1111                            extra_runs="$extra_runs $name"
1112                        #else echo $dir"/"$exd"/eedata.mth: not found"
1113                        fi
1114                    else
1115                        extra_runs="$extra_runs $name"
1116                    fi
1117                fi
1118            done
1119        fi
1120    
1121        echo "-------------------------------------------------------------------------------"
1122        echo
1123        if test "x$extra_runs" = "x" ; then
1124           echo "Experiment:  $dir"
1125        else
1126           echo "Experiment:  $dir ; extra_runs=$extra_runs"
1127        fi
1128        echo
1129        unset genmake makedepend make run
1130        results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --'
1131    
1132        #  Create an output dir for each OPTFILE/tdir combination
1133        rel_CDIR=$DRESULTS"/"$dir
1134        mkdir $rel_CDIR
1135        CDIR=`pwd`"/$rel_CDIR"
1136        
1137        if test "x$CLEANUP" = xt ; then
1138            echo '====>>> this is to check that we never go through this part <<< ==='
1139            makeclean $dir/$builddir \
1140                && run_clean $dir/$rundir
1141        else
1142          genmakemodel $dir/$builddir && genmake=Y \          genmakemodel $dir/$builddir && genmake=Y \
1143              && makeclean $dir/$builddir \              && makeclean $dir/$builddir \
1144                && run_clean $dir/$rundir \
1145                && symlink_mpifiles $dir $code_dir $builddir \
1146              && makedependmodel $dir/$builddir && makedepend=Y \              && makedependmodel $dir/$builddir && makedepend=Y \
1147              && makemodel $dir/$builddir && make=Y \              && makemodel $dir/$builddir && make=Y \
1148              && linkdata $seperatebuilddir $dir/$rundir \              && linkdata $dir/$rundir $input_dirs \
1149              && runmodel $dir/$builddir mitgcmuv && run=Y \              && runmodel $dir/$rundir && run=Y \
1150              && results=`testoutput $dir $rundir`              && results=`testoutput $dir $rundir "txt"`
1151        fi
1152        
1153        echo
1154        if test "x$ADM" = x ; then
1155            fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results`
1156          echo          echo
1157          formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \          echo "$fres" >> $SUMMARY
1158              ${run:-N} $results          echo "fresults='$fres'" > $CDIR"/summary.txt"
1159            echo "MACH='$MACH'" >> $CDIR"/summary.txt"
1160            echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"
1161            echo "DATE='$DATE'" >> $CDIR"/summary.txt"
1162            echo "tdir='$dir'" >> $CDIR"/summary.txt"
1163    
1164            for ex in $extra_runs ; do
1165                unset run
1166                results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --'
1167                #  Create an output dir for each OPTFILE/tdir.ex combination
1168                rel_CDIR=$DRESULTS"/"$dir"."$ex
1169                mkdir $rel_CDIR
1170                CDIR=`pwd`"/$rel_CDIR"
1171                test ! -e "$dir/tr_run.$ex" && mkdir "$dir/tr_run.$ex"
1172                run_clean $dir/tr_run.$ex
1173                linkdata $dir/tr_run.$ex input.$ex input
1174                runmodel $dir/tr_run.$ex && run=Y \
1175                    && results=`testoutput $dir tr_run.$ex ${ex}".txt"`
1176                fres=`printf '%s %s %s %s' ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N}`
1177                fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results`
1178                fres="$fres.$ex"
1179                echo
1180                echo "$fres" >> $SUMMARY
1181                echo "fresults='$fres'" > $CDIR"/summary.txt"
1182                echo "MACH='$MACH'" >> $CDIR"/summary.txt"
1183                echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"
1184                echo "DATE='$DATE'" >> $CDIR"/summary.txt"
1185                echo "tdir='$dir.$ex'" >> $CDIR"/summary.txt"
1186                if test "x$POSTCLEAN" = xt ; then
1187                    run_clean $dir/tr_run.$ex
1188                fi
1189            done
1190        else
1191            fres=`printf '%s %s %s %s' ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N}`
1192            fres=$fres"$results   $dir"
1193          echo          echo
1194          formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \          echo "$fres" >> $SUMMARY
1195              ${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"  
1196          echo "MACH='$MACH'" >> $CDIR"/summary.txt"          echo "MACH='$MACH'" >> $CDIR"/summary.txt"
1197          echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"          echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"
1198          echo "DATE='$DATE'" >> $CDIR"/summary.txt"          echo "DATE='$DATE'" >> $CDIR"/summary.txt"
1199          echo "tdir='$dir'" >> $CDIR"/summary.txt"          echo "tdir='$dir'" >> $CDIR"/summary.txt"
1200            grep -A3 'Seconds in section "ALL' $dir/$rundir/$OUTPUTFILE \
1201                               >> $CDIR"/summary.txt"
1202        fi
1203    
1204          (      #postclean $dir/$builddir
1205              cd $DRESULTS      if test "x$POSTCLEAN" = xt ; then
1206              tar -cf $NDIR".tar" $DRESULTS"_"$NDIR > /dev/null 2>&1          makeclean $dir/$builddir \
1207              gzip $NDIR".tar"              && run_clean $dir/$rundir
1208          )      fi
1209        
1210        echo "-------------------------------------------------------------------------------"
1211        
1212    done
1213    
1214          $MPACK -s MITgcm-test -m 1000000 $DRESULTS"/"$NDIR".tar.gz" $ADDRESSES  printf "Start time:  " >> $SUMMARY
1215    echo $start_date >> $SUMMARY
1216    printf "End time:    " >> $SUMMARY
1217    date >> $SUMMARY
1218    
1219    #  If addresses were supplied and mpack built successfully, then try
1220    #  to send email using mpack.
1221    if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then
1222        echo "No results email was sent."
1223    else
1224        if test "x$HAVE_MPACK" = xt ; then
1225            tar -cf $DRESULTS".tar" $DRESULTS > /dev/null 2>&1 \
1226                && gzip $DRESULTS".tar" \
1227                && $MPACK -s MITgcm-test -m 3555000 $DRESULTS".tar.gz" $ADDRESSES
1228          RETVAL=$?          RETVAL=$?
1229          if test "x$RETVAL" != x0 ; then          if test "x$RETVAL" != x0 ; then
1230              echo "Warning: \"$MPACK\" failed -- please contact <edhill@mitgcm.org>"              echo
1231                echo "Warning: The tar, gzip, & mpack step failed.  Please send email"
1232                echo "  to <MITgcm-support@mitgcm.org> for help.  You may copy the "
1233                echo "  summary of results from the directory \"$DRESULTS\"."
1234                echo
1235          else          else
1236              rm -f $DRESULTS"/"$NDIR".tar*"              echo
1237                echo "An email containing results was sent to the following addresses:"
1238                echo "  \"$ADDRESSES\""
1239                echo
1240          fi          fi
1241            test -f $DRESULTS".tar"  &&  rm -f $DRESULTS".tar"
1242            test -f $DRESULTS".tar.gz"  &&  rm -f $DRESULTS".tar.gz"
1243        fi
1244    fi
1245    
1246          NDIR=$(( $NDIR + 1 ))  rm -f tr_cmpnum.c tr_cmpnum
           
     done  
 done  
1247    
1248  rm tmp_cmpnum.f a.out  if test "x$CLEANUP" != xt ; then
1249        cat $SUMMARY | sed 's/ -- -- -- --//g'
1250        if test -e tr_out.txt ; then
1251            mv tr_out.txt tr_out.txt.old
1252        fi
1253        cat $SUMMARY | sed 's/ -- -- -- --//g' > tr_out.txt
1254    fi
1255    
1256  cat $SUMMARY  if test "x$DELDIR" = xt ; then
1257        rm -rf $DRESULTS
1258    fi
1259    

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

  ViewVC Help
Powered by ViewVC 1.1.22