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

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

  ViewVC Help
Powered by ViewVC 1.1.22