/[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.77 by jmc, Mon Mar 20 21:50:36 2006 UTC revision 1.164 by jmc, Mon Jun 27 18:45:16 2011 UTC
# Line 11  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 "  (-mpi)                   use MPI input files"      echo "  (-mth)                   run multi-threaded (using eedata.mth)"
15      echo "  (-ieee|-noieee)          if possible, use IEEE compiler flags"      echo "  (-mpi)                   use MPI to compile and run on 2 processors"
16      echo "                             (DEF=\"-ieee\")"      echo "  (-MPI)  NUMBER           use MPI to compile and run on max NUMBER procs"
17      echo "  (-optfile=|-of=)STRING   list of optfiles to use"      echo "  (-mfile|-mf) STRING      MPI: file with list of possible machines to run on"
18      echo "  (-a|-addr) STRING        list of email recipients"      echo "  (-fast)                  use optfile default for compiler flags (no '-ieee')"
19      echo "                             (DEF=\"edhill@mitgcm.org\")"      echo "                            DEF=off => use IEEE numerics option (if available)"
20      echo "  (-t|-tdir) STRING        list of test dirs to use"      echo "  (-devel)                 use optfile developement flags (if available)"
21      echo "                             (DEF=\"\" which builds all)"      echo "  (-gsl)                   compile with \"-gsl\" flag"
22      echo "  (-b|-bash) STRING        preferred location of a \"bash\" or"      echo "  (-use_r4|-ur4)           if allowed, use real*4 type for '_RS' variable"
23        echo "  (-optfile|-of) STRING    list of optfiles to use"
24        echo "  (-addr|-a) STRING        list of email recipients"
25        echo "                             (DEF=\"\" no email is sent)"
26        echo "  (-mpackdir|-mpd) DIR     location of the mpack utility"
27        echo "                             (DEF=\"../tools/mpack-1.6\")"
28        echo "  (-tdir|-t) STRING        list of group and/or exp. dirs to test"
29        echo "                             (recognized groups: basic, tutorials)"
30        echo "                             (DEF=\"\" which test all)"
31        echo "                             (if list= 'start_from THIS_EXP' then"
32        echo "                              test THIS_EXP + all the following)"
33        echo "  (-skipdir|-skd) STRING   list of exp. dirs to skip"
34        echo "                             (DEF=\"\" which test all)"
35        echo "  (-bash|-b) STRING        preferred location of a \"bash\" or"
36      echo "                             Bourne-compatible \"sh\" shell"      echo "                             Bourne-compatible \"sh\" shell"
37      echo "                             (DEF=\"\" for \"bash\")"      echo "                             (DEF=\"\" for \"bash\")"
38      echo "  (-adm|-ad)               perform an adjoint run"      echo "  (-adm|-ad)               perform an adjoint run"
39      echo "  (-command) STRING        command to run"      echo "  (-oad)                   perform an OpenAD adjoint run"
40      echo "                             (DEF=\"make output.txt\")"      echo "  (-command|-c) STRING     command to run"
41      echo "  (-m|-make) STRING        command to use for \"make\""      echo "  (-makedepend|-md) STRING command to use for \"makedepend\""
42        echo "  (-make|-m) STRING        command to use for \"make\""
43      echo "                             (DEF=\"make\")"      echo "                             (DEF=\"make\")"
44      echo "  (-odir) STRING           used to build output directory name"      echo "  (-odir) STRING           used to build output directory name"
45      echo "                             (DEF=\"hostname\")"      echo "                             (DEF=\"hostname\")"
46      echo "  (-ptracers|-ptr) STRING  specify which ptracers to test"  #   echo "  (-ptracers|-ptr) STRING  specify which ptracers to test"
47      echo "                             (DEF=\"1 2 3 4 5\")"  #   echo "                             (DEF=\"1 2 3 4 5\")"
48        echo "  (-match) NUMBER          Matching Criteria (number of digits)"
49        echo "                             (DEF=\"$MATCH_CRIT\")"
50      echo "  (-j) JOBS                use \"make -j JOBS\" for parallel builds"      echo "  (-j) JOBS                use \"make -j JOBS\" for parallel builds"
51      echo "  (-clean)                 *ONLY* run \"make CLEAN\""      echo "  (-clean)                 *ONLY* run \"make CLEAN\" & clean run-dir"
52        echo "  (-norun|-nr)             skip the \"runmodel\" stage (stop after make)"
53        echo "  (-runonly|-ro)           *ONLY* run stage (=\"-quick\" without make)"
54      echo "  (-quick|-q)              same as \"-nogenmake -noclean -nodepend\""      echo "  (-quick|-q)              same as \"-nogenmake -noclean -nodepend\""
55      echo "  (-nogenmake|-ng)         skip the genmake stage"      echo "  (-nogenmake|-ng)         skip the genmake stage"
56      echo "  (-noclean|-nc)           skip the \"make clean\" stage"      echo "  (-noclean|-nc)           skip the \"make clean\" stage"
57      echo "  (-nodepend|-nd)          skip the \"make depend\" stage"      echo "  (-nodepend|-nd)          skip the \"make depend\" stage"
58        echo "  (-postclean|-pc)         after each exp. test, clean build-dir & run-dir"
59        echo "  (-deloutp|-do)           delete output files after successful run"
60      echo "  (-deldir|-dd)            on success, delete the output directory"      echo "  (-deldir|-dd)            on success, delete the output directory"
61        echo "  (-ts)                    provide timing information per timestep"
62        echo "  (-papis)                 provide MFlop/s per timestep using PAPI"
63        echo "  (-pcls)                  provide MFlop/s per timestep using PCL"
64      echo      echo
65      echo "and where STRING can be a whitespace-delimited list"      echo "and where STRING can be a whitespace-delimited list"
66      echo "such as:"      echo "such as:"
# Line 55  usage() Line 78  usage()
78  build_mpack()  build_mpack()
79  {  {
80      printf "building the mpack utility...  "      printf "building the mpack utility...  "
81      if test ! -x "$MPACKDIR/mpack" ; then      MPACK="$MPACKDIR/mpack"
82        if test ! -x $MPACK ; then
83          if test ! -d $MPACKDIR ; then          if test ! -d $MPACKDIR ; then
84              echo              echo
85              echo "Error: can't find \"$MPACKDIR\""              echo "Error: can't find \"$MPACKDIR\""
# Line 64  build_mpack() Line 88  build_mpack()
88              echo              echo
89              HAVE_MPACK=f              HAVE_MPACK=f
90          fi          fi
         printf "building mpack...  "  
91          if test "x$CC" = x ; then          if test "x$CC" = x ; then
92              export CC=cc              export CC=cc
93          fi          fi
94            printf "building mpack (using CC=$CC)...  "
95          ( cd $MPACKDIR && ./configure && $MAKE ) > tr_build_mpack.out 2>&1          ( cd $MPACKDIR && ./configure && $MAKE ) > tr_build_mpack.out 2>&1
96          RETVAL=$?          RETVAL=$?
97          if test "x$RETVAL" != x0 ; then          if test "x$RETVAL" != x0 ; then
# Line 78  build_mpack() Line 102  build_mpack()
102          else          else
103              rm -f tr_build_mpack.out              rm -f tr_build_mpack.out
104              HAVE_MPACK=t              HAVE_MPACK=t
105                echo "done"
106          fi          fi
107      else      else
108          HAVE_MPACK=t          HAVE_MPACK=t
109            echo "already exist"
110      fi      fi
     echo "OK"  
111  }  }
112    
113  testoutput_for_prop()  testoutput_var()
114  {  {
115      # testoutput_for_prop dir s1 label subdir extension      # testoutput_var dir s1 label subdir reference_output
116      #      #
117      #  compares files in $dir/$subdir/output.txt and $dir/results/output.txt      #  compares 1 variable output selected from file $dir/$subdir/$OUTPUTFILE
118      #  using search strings s1 and text label      #     with same output from reference file $dir/results/$reference_output
119        #  using search strings s1 and text label
120    
121      if [ $debug -gt 0 ]; then      if [ $debug -gt 0 ]; then
122          echo testoutput_for_prop: grep "$2" $1/$4/output.txt 1>&2          echo testoutput_var: grep "$2" $1/$4/$OUTPUTFILE 1>&2
123      fi      fi
124      if [ -r $1/$4/output.txt ]; then      if [ -r $1/$4/$OUTPUTFILE ]; then
125          grep "$2" $1/$4/output.txt | sed 's/.*=//' | cat -n > tmp1.txt          grep "$2" $1/$4/$OUTPUTFILE | sed 's/.*=//' | cat -n > tmp1.txt
126          lncntA=`wc -l tmp1.txt | awk '{print $1}' `          lncntA=`wc -l tmp1.txt | awk '{print $1}' `
127          if [ $lncntA -lt 3 ]; then          if [ $lncntA -lt 2 ]; then
128              if [ $verbose -gt 0 ]; then              if [ $verbose -gt 0 ]; then
129                  echo Not enough lines of output when searching for "$2" 1>&2                  echo Not enough lines of output when searching for "$2" 1>&2
130              fi              fi
131              return 99              return 99
132          fi          fi
133      else      else
134          echo testoutput_for_prop: output.txt from model run was not readable 1>&2          echo testoutput_var: $OUTPUTFILE from model run was not readable 1>&2
135          return 99          return 99
136      fi      fi
137      if [ $debug -gt 0 ]; then      if [ $debug -gt 0 ]; then
138          echo testoutput_for_prop: grep "$2" $1/results/output.txt$5 1>&2          echo testoutput_var: grep "$2" $1/results/$5 1>&2
139      fi      fi
140      grep "$2" $1/results/output.txt$5 | sed 's/.*=//' | cat -n > tmp2.txt      grep "$2" $1/results/$5 | sed 's/.*=//' | cat -n > tmp2.txt
141      lncntB=`wc -l tmp2.txt | awk '{print $1}' `      lncntB=`wc -l tmp2.txt | awk '{print $1}' `
142      if [ $lncntB -lt 3 ]; then      if [ $lncntB -lt 2 ]; then
143          if [ $verbose -gt 0 ]; then          if [ $verbose -gt 0 ]; then
144              echo Not enough lines of output when searching for "$2" 1>&2              echo Not enough lines of output when searching for "$2" 1>&2
145          fi          fi
# Line 127  testoutput_for_prop() Line 153  testoutput_for_prop()
153      fi      fi
154      has_nan=`cat tmp1.txt | grep -i nan | wc -l`      has_nan=`cat tmp1.txt | grep -i nan | wc -l`
155      if [ $has_nan -gt 0  ] ; then      if [ $has_nan -gt 0  ] ; then
156          echo testoutput_for_prop: output.txt contains $has_nan NaN values  1>&2          echo testoutput_var: $OUTPUTFILE contains $has_nan NaN values  1>&2
157          return 99          return 99
158      fi      fi
159      has_inf=`cat tmp1.txt | grep -i inf | wc -l`      has_inf=`cat tmp1.txt | grep -i inf | wc -l`
160      if [ $has_inf -gt 0  ] ; then      if [ $has_inf -gt 0  ] ; then
161          echo testoutput_for_prop: output.txt contains $has_inf Inf values  1>&2          echo testoutput_var: $OUTPUTFILE contains $has_inf Inf values  1>&2
162          return 99          return 99
163      fi      fi
164      if [ $debug -gt 0 ]; then      if [ $debug -gt 0 ]; then
165          echo testoutput_for_prop: join tmp1.txt tmp2.txt 1>&2          echo testoutput_var: join tmp1.txt tmp2.txt 1>&2
166      fi      fi
167      join tmp1.txt tmp2.txt | awk '{print $1 " " $2 " " $3}' > tmp3.txt      join tmp1.txt tmp2.txt | awk '{print $1 " " $2 " " $3}' > tmp3.txt
168      if [ $debug -gt 0 ]; then      if [ $debug -gt 0 ]; then
169          echo testoutput_for_prop: compare_lines 1>&2          echo testoutput_var: compare_lines 1>&2
170      fi      fi
171      if [ $verbose -gt 1 ]; then      if [ $verbose -gt 1 ]; then
172          cat tmp3.txt 1>&2          cat tmp3.txt 1>&2
# Line 148  testoutput_for_prop() Line 174  testoutput_for_prop()
174      echo "-1" >> tmp3.txt      echo "-1" >> tmp3.txt
175      # On the SGI O3K (*not* the O2K), "cat -n" inserts a ":" after the line number      # On the SGI O3K (*not* the O2K), "cat -n" inserts a ":" after the line number
176      cat tmp3.txt | sed -e 's|:||g' > tmp4.txt      cat tmp3.txt | sed -e 's|:||g' > tmp4.txt
177      digits_of_similarity=`./tmp_cmpnum < tmp4.txt`      digits_of_similarity=`./tr_cmpnum < tmp4.txt`
178      if [ $digits_of_similarity -eq 99 ]; then      if [ $digits_of_similarity -eq 99 ]; then
179          if [ $verbose -gt 0 ]; then          if [ $verbose -gt 0 ]; then
180              echo testoutput_for_prop: No comparison was available for \"$2\" 1>&2              echo testoutput_var: No comparison was available for \"$3\" 1>&2
181          fi          fi
182          digits_of_similarity=99          digits_of_similarity=99
183      else      else
184          if [ $verbose -gt 0 ]; then          if [ $verbose -gt 0 ]; then
185              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 \"$3\" 1>&2
186          fi          fi
187      fi      fi
188      rm -f tmp1.txt tmp2.txt tmp3.txt tmp4.txt      rm -f tmp1.txt tmp2.txt tmp3.txt tmp4.txt
       
     return $digits_of_similarity  
 }  
   
 dashnum()  
 {  
     # dashnum n1 n2 n3 ...  
     #  
     #  print numbers using %3i format or "--" if number = 99  
189    
190      for num in $@ ; do      return $digits_of_similarity
         if [ $num = 99 ]; then  
             printf ' --'  
         else  
             printf '%3i' $num  
         fi  
     done  
 }  
   
 testoutput_ad()  
 {  
     grep $3 $1/results_ad/output.txt_adm | awk '{print NR " " $5}' > t05.txt  
     grep $3 $1/$2/output.txt_adm | awk '{print NR " " $5}' > t15.txt  
     grep $3 $1/results_ad/output.txt_adm | awk '{print NR " " $6}' > t06.txt  
     grep $3 $1/$2/output.txt_adm | awk '{print NR " " $6}' > t16.txt  
     join t05.txt t15.txt > t5.txt  
     join t06.txt t16.txt > t6.txt  
     echo "-1" >> t5.txt  
     echo "-1" >> t6.txt  
     digits_5=`./tmp_cmpnum < t5.txt`  
     digits_6=`./tmp_cmpnum < t6.txt`  
     dashnum $digits_5 $digits_6  
     rm -f t[01][56].txt t[56].txt  
 }  
   
 check_for_add_mon_output()  
 {  
     # Check for additional types of monitor output  
     if test "x$1" = x ; then  
         return  
     fi  
   
     for ii in $PTRACERS_NUM ; do  
         eval "HAVE_PTR0"$ii"=f"  
     done  
   
     ptr_add="trcstat_ptracerXX_min trcstat_ptracerXX_max"  
     ptr_add="$ptr_add trcstat_ptracerXX_mean trcstat_ptracerXX_sd"  
     for ii in $PTRACERS_NUM ; do  
         for jj in $ptr_add ; do  
             name=`eval "echo $jj | sed -e 's|XX|0"$ii"|g'"`  
             tst=`grep $name $1 | wc -l | awk '{print $1}'`  
             if test ! "x$tst" = x0 ; then  
                 eval "HAVE_PTR0"$ii"=t"  
             fi  
         done  
         #  eval 'echo "HAVE_PTR0'$ii' = $HAVE_PTR0'$ii'"'  
     done  
191  }  }
192    
193  testoutput()  testoutput_run()
194  {  {
195      # testoutput directory subdir extension      # testoutput_run directory subdir reference_output
196      #      #
197      #  test output in "directory"      #  test output from 1 run in "directory"
198      if test "x$ADM" = x ; then  # --> same processing for adjoint & forward test
199          if [ $debug -gt 0 ]; then          # default list of output variables to be checked:
200              echo testoutput: testoutput_for_prop $1 cg2d_init_res 1>&2          #  1rst : main variable used to decide if it pass or FAIL
201          fi          #  others : number of matching digits to be printed in summary.txt
202          testoutput_for_prop $1 "cg2d_init_res" "cg2d init. residual" $2 $3; cg2dres=$?          listChk=$DEF_CHECK_LIST
203          if [ $debug -gt 0 ]; then          #  load experiment-specific list from file "tr_checklist" (if it exist)
204              echo testoutput: cg2dres=$cg2dres 1>&2          if test -r $1/$2/tr_checklist ; then listChk=`cat $1/$2/tr_checklist` ; fi
205          fi          sVar=`echo $listChk | awk '{print $1}'`
206          testoutput_for_prop $1 "dynstat_theta_min" "theta minimum" $2 $3; tmin=$?          # remove 1rst var and expand the list: + => min max mean s.d
207          testoutput_for_prop $1 "dynstat_theta_max" "theta maximum" $2 $3; tmax=$?          listVar=`echo $listChk | sed 's/ [a-zA-Z0-9]*+/&mn &mx &av &sd/g' \
208          testoutput_for_prop $1 "dynstat_theta_mean" "theta mean" $2 $3; tmean=$?                                 | sed 's/+//g' | sed "s/^$sVar//"`
209          testoutput_for_prop $1 "dynstat_theta_sd" "theta s.d." $2 $3; tsd=$?          if [ $debug -gt 0 ]; then echo "testoutput_run: listVar(I)='$listVar'" 1>&2 ; fi
210          testoutput_for_prop $1 "dynstat_salt_min" "salt minimum" $2 $3; smin=$?          # check for ptracer output in reference_output file :
211          testoutput_for_prop $1 "dynstat_salt_max" "salt maximum" $2 $3; smax=$?          outpref=$1/results/$3
212          testoutput_for_prop $1 "dynstat_salt_mean" "salt mean" $2 $3; smean=$?          ptr_mon="trcstat_ptracerXX_min trcstat_ptracerXX_max"
213          testoutput_for_prop $1 "dynstat_salt_sd" "salt s.d." $2 $3; ssd=$?          ptr_mon="$ptr_mon trcstat_ptracerXX_mean trcstat_ptracerXX_sd"
         testoutput_for_prop $1 "dynstat_uvel_min" "U minimum" $2 $3; umin=$?  
         testoutput_for_prop $1 "dynstat_uvel_max" "U maximum" $2 $3; umax=$?  
         testoutput_for_prop $1 "dynstat_uvel_mean" "U mean" $2 $3; umean=$?  
         testoutput_for_prop $1 "dynstat_uvel_sd" "U s.d." $2 $3; usd=$?  
         testoutput_for_prop $1 "dynstat_vvel_min" "V minimum" $2 $3; vmin=$?  
         testoutput_for_prop $1 "dynstat_vvel_max" "V maximum" $2 $3; vmax=$?  
         testoutput_for_prop $1 "dynstat_vvel_mean" "V mean" $2 $3; vmean=$?  
         testoutput_for_prop $1 "dynstat_vvel_sd" "V s.d." $2 $3; vsd=$?  
   
         #  This is for PTRACERS  
214          for ii in $PTRACERS_NUM ; do          for ii in $PTRACERS_NUM ; do
215              eval `echo "p0"$ii"_min=99"`              ptrfound=0
216              eval `echo "p0"$ii"_max=99"`              for jj in $ptr_mon ; do
217              eval `echo "p0"$ii"_mean=99"`                  name=`eval "echo $jj | sed -e 's|XX|0"$ii"|g'"`
218              eval `echo "p0"$ii"_sd=99"`                  tst=`grep $name $outpref | wc -l | awk '{print $1}'`
219              tst=`eval 'echo "$HAVE_PTR0'$ii'"'`                  if test ! "x$tst" = x0 ; then ptrfound=1 ; fi
220              #echo 'tst = '$tst              done
221              if test "x$tst" = xt ; then              if test $ptrfound = '1' ; then
222                  a="trcstat_ptracer0"                  eval "HAVE_PTR0"$ii"=t"
223                  testoutput_for_prop $1 "$a"$ii"_min"  "p0"$ii"_min"  $2 $3              else
224                  RETVAL=$? ; eval `echo "p0"$ii"_min="$RETVAL`                  eval "HAVE_PTR0"$ii"=f"
225                  testoutput_for_prop $1 "$a"$ii"_max"  "p0"$ii"_max"  $2 $3                if test "x$ADM" = x -a "x$OADM" = x; then
226                  RETVAL=$? ; eval `echo "p0"$ii"_max="$RETVAL`                # remove this ptr from the list of output variable to check
227                  testoutput_for_prop $1 "$a"$ii"_mean" "p0"$ii"_mean" $2 $3                # echo "-- ptr test=" $tst "number of var=" `echo $listVar | awk '{print NF}'` 1>&2
228                  RETVAL=$? ; eval `echo "p0"$ii"_mean="$RETVAL`                  listVar=`echo "$listVar" | sed "s/ pt$ii..//g"`
229                  testoutput_for_prop $1 "$a"$ii"_sd"   "p0"$ii"_sd"   $2 $3                fi
                 RETVAL=$? ; eval `echo "p0"$ii"_sd="$RETVAL`  
230              fi              fi
231            #   eval 'echo "HAVE_PTR0'$ii' = $HAVE_PTR0'$ii'"' 1>&2
232          done          done
233            tst=`echo $sVar $listVar | awk '{ for(i=2;i<=NF;i++){if($i==$1)t+=1}; print t }'`
234          allargs="$cg2dres $tmin $tmax $tmean $tsd $smin $smax $smean $ssd"          if test $tst != 1 ; then
235          allargs="$allargs $umin $umax $umean $usd $vmin $vmax $vmean $vsd"            if test $tst = 0 ; then echo "==> WARNING: selected var >$sVar< not found" 1>&2
236          allargs="$allargs $p01_min $p01_max $p01_mean $p01_sd"                   else echo "==> WARNING: found selected var >$sVar< $tst times" 1>&2 ; fi
237          allargs="$allargs $p02_min $p02_max $p02_mean $p02_sd"            echo "==> WARNING: in checked list:" $listVar 1>&2
238          allargs="$allargs $p03_min $p03_max $p03_mean $p03_sd"          #- put it back once:
239          allargs="$allargs $p04_min $p04_max $p04_mean $p04_sd"            listVar=" $sVar "`echo "$listVar " | sed "s/ $sVar / /g"`
240          allargs="$allargs $p05_min $p05_max $p05_mean $p05_sd"          fi
241            if [ $debug -gt 0 ]; then echo "testoutput_run: listVar(M)='$listVar'" 1>&2 ; fi
242          eval "dashnum $allargs"          echo "listVar='$listVar'" >> $locDIR"/summary.txt"
243            #---
244      else          allargs=""
245          testoutput_ad $1 $2 "precision_grdchk_result"          for xx in $listVar
246      fi          do
247              case $xx in
248               'PS')  if [ $debug -gt 0 ]
249                      then echo testoutput_run: testoutput_var $1 cg2d_init_res 1>&2 ; fi
250                      testoutput_var $1 "cg2d_init_res" "Press. Solver (cg2d)" $2 $3; yy=$?
251                      if [ $debug -gt 0 ] ; then echo testoutput_run: cg2dres=$yy 1>&2 ; fi ;;
252              'Cost') testoutput_var $1 "ADM  precision_derivative_cost" "ADM Cost" $2 $3; yy=$? ;;
253              'Grad') testoutput_var $1 "ADM  precision_derivative_grad" "ADM Grad" $2 $3; yy=$? ;;
254               'Tmn') testoutput_var $1 "dynstat_theta_min"  "Theta minimum"  $2 $3; yy=$? ;;
255               'Tmx') testoutput_var $1 "dynstat_theta_max"  "Theta maximum"  $2 $3; yy=$? ;;
256               'Tav') testoutput_var $1 "dynstat_theta_mean" "Theta mean"     $2 $3; yy=$? ;;
257               'Tsd') testoutput_var $1 "dynstat_theta_sd"   "Theta Std.Dev"  $2 $3; yy=$? ;;
258               'Smn') testoutput_var $1 "dynstat_salt_min"  "Salt minimum"    $2 $3; yy=$? ;;
259               'Smx') testoutput_var $1 "dynstat_salt_max"  "Salt maximum"    $2 $3; yy=$? ;;
260               'Sav') testoutput_var $1 "dynstat_salt_mean" "Salt mean"       $2 $3; yy=$? ;;
261               'Ssd') testoutput_var $1 "dynstat_salt_sd"   "Salt Std.Dev"    $2 $3; yy=$? ;;
262               'Umn') testoutput_var $1 "dynstat_uvel_min"  "U minimum"       $2 $3; yy=$? ;;
263               'Umx') testoutput_var $1 "dynstat_uvel_max"  "U maximum"       $2 $3; yy=$? ;;
264               'Uav') testoutput_var $1 "dynstat_uvel_mean" "U mean"          $2 $3; yy=$? ;;
265               'Usd') testoutput_var $1 "dynstat_uvel_sd"   "U Std.Dev"       $2 $3; yy=$? ;;
266               'Vmn') testoutput_var $1 "dynstat_vvel_min"  "V minimum"       $2 $3; yy=$? ;;
267               'Vmx') testoutput_var $1 "dynstat_vvel_max"  "V maximum"       $2 $3; yy=$? ;;
268               'Vav') testoutput_var $1 "dynstat_vvel_mean" "V mean"          $2 $3; yy=$? ;;
269               'Vsd') testoutput_var $1 "dynstat_vvel_sd"   "V Std.Dev"       $2 $3; yy=$? ;;
270            'pt1mn'|'pt2mn'|'pt3mn'|'pt4mn'|'pt5mn') ii=`echo $xx | sed 's/pt//' | sed 's/..$//'`
271               testoutput_var $1 "trcstat_ptracer0"$ii"_min"  "p0"$ii"_min"   $2 $3; yy=$? ;;
272            'pt1mx'|'pt2mx'|'pt3mx'|'pt4mx'|'pt5mx') ii=`echo $xx | sed 's/pt//' | sed 's/..$//'`
273               testoutput_var $1 "trcstat_ptracer0"$ii"_max"  "p0"$ii"_max"   $2 $3; yy=$? ;;
274            'pt1av'|'pt2av'|'pt3av'|'pt4av'|'pt5av') ii=`echo $xx | sed 's/pt//' | sed 's/..$//'`
275               testoutput_var $1 "trcstat_ptracer0"$ii"_mean" "p0"$ii"_mean" $2 $3; yy=$? ;;
276            'pt1sd'|'pt2sd'|'pt3sd'|'pt4sd'|'pt5sd') ii=`echo $xx | sed 's/pt//' | sed 's/..$//'`
277               testoutput_var $1 "trcstat_ptracer0"$ii"_sd"   "p0"$ii"_StDv"  $2 $3; yy=$? ;;
278             'Qntmn') testoutput_var $1 "forcing_qnet_min" "Qnet minimum"  $2 $3; yy=$? ;;
279             'Qntmx') testoutput_var $1 "forcing_qnet_max" "Qnet maximum"  $2 $3; yy=$? ;;
280             'Qntav') testoutput_var $1 "forcing_qnet_mean" "Qnet mean"       $2 $3; yy=$? ;;
281             'Qntsd') testoutput_var $1 "forcing_qnet_sd"  "Qnet Std.Dev"  $2 $3; yy=$? ;;
282             'aSImn') testoutput_var $1 "seaice_area_min"   "SIce Area min"   $2 $3; yy=$? ;;
283             'aSImx') testoutput_var $1 "seaice_area_max"   "SIce Area max"   $2 $3; yy=$? ;;
284             'aSIav') testoutput_var $1 "seaice_area_mean"  "SIce Area mean"  $2 $3; yy=$? ;;
285             'aSIsd') testoutput_var $1 "seaice_area_sd"    "SIce Area StDv"  $2 $3; yy=$? ;;
286             'hSImn') testoutput_var $1 "seaice_heff_min"   "SIce Heff min"   $2 $3; yy=$? ;;
287             'hSImx') testoutput_var $1 "seaice_heff_max"   "SIce Heff max"   $2 $3; yy=$? ;;
288             'hSIav') testoutput_var $1 "seaice_heff_mean"  "SIce Heff mean"  $2 $3; yy=$? ;;
289             'hSIsd') testoutput_var $1 "seaice_heff_sd"    "SIce Heff StDv"  $2 $3; yy=$? ;;
290            'AthSiG') testoutput_var $1 "thSI_Ice_Area_G" "thSIc Area Global" $2 $3; yy=$? ;;
291            'AthSiS') testoutput_var $1 "thSI_Ice_Area_S" "thSIc Area South"  $2 $3; yy=$? ;;
292            'AthSiN') testoutput_var $1 "thSI_Ice_Area_N" "thSIc Area North"  $2 $3; yy=$? ;;
293            'HthSiG') testoutput_var $1 "thSI_IceH_ave_G" "thSIc H Global"    $2 $3; yy=$? ;;
294            'HthSiS') testoutput_var $1 "thSI_IceH_ave_S" "thSIc H South"     $2 $3; yy=$? ;;
295            'HthSiN') testoutput_var $1 "thSI_IceH_ave_N" "thSIc H North"     $2 $3; yy=$? ;;
296                  *) yy=99; echo "WARNING: asking for var=$xx : not recognized !" 1>&2 ;;
297              esac
298              if test $xx = $sVar
299              then allargs="$allargs > $yy <"
300              else allargs="$allargs $yy"
301              fi
302            done
303    
304            nbVar=`echo $listVar | awk '{print NF}'`
305            if [ $nbVar -lt $LEN_CHECK_LIST ] ; then
306            #-- fill line (up to standard length) with dot:
307              adNul=`expr $LEN_CHECK_LIST - $nbVar | awk '{for(i=1;i<=$1;i++){print "."}}'`
308              echo $allargs $adNul
309            else
310              echo $allargs
311            fi
312    # <-- same processing for adjoint & forward test
313  }  }
314    
315  genmakemodel()  genmakemodel()
# Line 300  genmakemodel() Line 326  genmakemodel()
326          (          (
327              cd $1;              cd $1;
328              command="$GENMAKE2  -ds -m $MAKE"              command="$GENMAKE2  -ds -m $MAKE"
329              if test "x$ADM" = x ; then              if test "x$MKDEPEND" != x ; then
330                  command="$command --mods=../code"                  command="$command -makedepend=$MKDEPEND"
331              else              fi
332                if test "x$ADM" = xt ; then
333                  command="$command --mods=../code_ad"                  command="$command --mods=../code_ad"
334                  command="$command -adof=../../../tools/adjoint_options/adjoint_staf"              elif test "x$OADM" = xt ; then
335                    command="$command -adof ../../../tools/adjoint_options/adjoint_oad -mods '../code_oad ../../OpenAD/code_oad_all'"
336                else
337                    command="$command -mods=../code"
338              fi              fi
339              if test "x$OPTFILE" != xNONE ; then              if test "x$OPTFILE" != xNONE ; then
340                  command="$command --optfile=$OPTFILE"                  command="$command -optfile=$OPTFILE"
341              fi              fi
342              if test "x$IEEE" != x ; then              if test $OptLev = 1 ; then
343                  command="$command -ieee"                  command="$command -ieee"
344                fi
345                if test $OptLev = 0 ; then
346                    command="$command -devel"
347              fi              fi
348              if test "x$MPI" = xt ; then              if test "x$GSL" = xt ; then
349                    command="$command -gsl"
350                fi
351                if test "x$MPI" != x0 ; then
352                  command="$command -mpi"                  command="$command -mpi"
353              fi              fi
354              printf 'genmake ... ' 1>&2              if test "x$MULTI_THREAD" = xt ; then
355              $command > make.log 2>&1              #- run multi-threaded using OpenMP:
356                    command="$command -omp"
357                fi
358                if test "x$USE_R4" = xt ; then
359                    command="$command -use_r4"
360                fi
361                if test "x$TS" = xt ; then
362                    command="$command -ts"
363                fi
364                if test "x$PAPIS" = xt ; then
365                    command="$command -papis"
366                else
367                if test "x$PCLS" = xt ; then
368                    command="$command -pcls"
369                fi
370                fi
371                printf 'genmake ... '
372                eval $command > genmake.tr_log 2>&1
373              RETVAL=$?              RETVAL=$?
374              #  Reduce the size of the testing emails!              #  Reduce the size of the testing emails!
375              head -100 Makefile > $CDIR/Makefile_head              head -100 Makefile > $CDIR/Makefile_head
376              if test "x$RETVAL" != x0 ; then              if test "x$RETVAL" != x0 ; then
377                  tail make.log                  tail genmake.tr_log
378                  echo "genmakemodel: genmake failed" 1>&2                  echo "genmakemodel: genmake failed"
379                  cp genmake_* make.log $CDIR                  cp genmake.log genmake_* genmake.tr_log $CDIR
380                  return 1                  return 1
381              else              else
382                  echo "successful" 1>&2                  echo "successful"
383              fi              fi
384          )          )
385      fi      fi
# Line 335  genmakemodel() Line 388  genmakemodel()
388  makeclean()  makeclean()
389  {  {
390      # makeclean directory      # makeclean directory
391        if test "x$NODEPEND" = xf ; then rm -f $1/make.tr_log ; fi
392      if test "x$NOCLEAN" = xt ; then      if test "x$NOCLEAN" = xt ; then
393          echo "make CLEAN skipped!"          echo "make Clean skipped!"
394      else      else
395          (          (
396              cd $1;              cd $1;
397              if test -e output.txt ; then              #if test -e $OUTPUTFILE ; then rm -f $OUTPUTFILE ; fi
                 rm -f output.txt  
             fi  
             printf 'make CLEAN ... ' 2>&1  
398              if test -r Makefile ; then              if test -r Makefile ; then
399                  $MAKE CLEAN >> make.log 2>&1                  printf 'clean build-dir: make Clean ... '
400                    $MAKE Clean >> make.tr_log 2>&1
401                  RETVAL=$?                  RETVAL=$?
402                  if test "x$RETVAL" != x0 ; then                  if test "x$RETVAL" != x0 ; then
403                      tail make.log                      tail make.tr_log
404                      echo "makeclean: \"make CLEAN\" failed" 1>&2                      echo "makeclean: \"make Clean\" failed"
405                      cp make.log $CDIR"/make.log"                      cp make.tr_log genmake.log genmake.tr_log $CDIR
406                      return 1                      return 1
407                  fi                  fi
408                    echo successful
409                else
410                    echo ''
411              fi              fi
             echo successful 1>&2  
412              exit 0              exit 0
413          )          )
414      fi      fi
415  }  }
416    
417  postclean()  run_clean()
418  {  {
419      # postclean directory      # run_clean directory
420      if test "x$POSTCLEAN" = xt ; then      if test "x$NOCLEAN" = xt ; then
421            echo "run_clean skipped!"
422        else
423          (          (
424              cd $1;              cd $1;
425              if test -r Makefile ; then              printf 'clean run-dir ... '
426                  $MAKE CLEAN >> /dev/null 2>&1              # part of what is done after "make clean" when doing "make CLEAN"
427              fi              find . -name "*.meta" -exec rm {} \;
428                find . -name "*.data" -exec rm {} \;
429                find . -name "fort.*" -exec rm {} \;
430                find . -type l -exec rm {} \;
431                #- should remove executable only if sym-link (alredy done above)
432                rm -f $RUNLOG *.txt STD* *diagnostics.log datetime
433                rm -rf mnc_test_*
434                rm -f *_MIT_CE_000.opt0000 costfunction*0000
435                echo successful
436              exit 0              exit 0
437          )          )
438      fi      fi
# Line 382  makedependmodel() Line 446  makedependmodel()
446      else      else
447          (          (
448              cd $1;              cd $1;
449              printf 'make depend ... ' 1>&2              printf 'make depend ... '
450              $MAKE depend >> make.log 2>&1              $MAKE depend >> make.tr_log 2>&1
451              RETVAL=$?              RETVAL=$?
452              if test "x$RETVAL" != x0 ; then              if test "x$RETVAL" != x0 ; then
453                  tail make.log                  tail make.tr_log
454                  echo "makedependmodel: make depend failed" 1>&2                  echo "makedependmodel: make depend failed"
455                  cp make.log $CDIR"/make.log"                  cp make.tr_log genmake.log genmake.tr_log $CDIR
456                  return 1                  return 1
457              else              else
458                  echo successful 1>&2                  echo successful
459              fi              fi
460          )          )
461      fi      fi
# Line 401  makemodel() Line 465  makemodel()
465  {  {
466      # makemodel directory      # makemodel directory
467      (      (
468        mk_fail=0
469        if test "x$NOMAKE" = xt ; then
470            cd $1;
471            if test -x $EXECUTABLE ; then
472                echo "make skipped!"
473            else
474                echo "no executable!"
475                mk_fail=3
476            fi
477        else
478          cd $1;          cd $1;
479          if test -r Makefile ; then          if test -r Makefile ; then
480              printf 'make ... ' 1>&2              printf 'make ... '
481              if test "x$ADM" = x ; then              if test "x$ADM" = xt ; then
482                    $MAKE adall >> make.tr_log 2>&1
483                elif test "x$OADM" = xt ; then
484                    $MAKE adAll >> make.tr_log 2>&1
485                else
486                  if test "x$JOBS" = x ; then                  if test "x$JOBS" = x ; then
487                      $MAKE >> make.log 2>&1                      $MAKE >> make.tr_log 2>&1
488                  else                  else
489                      $MAKE -j $JOBS >> make.log 2>&1                      $MAKE -j $JOBS >> make.tr_log 2>&1
490                  fi                  fi
             else  
                 $MAKE adall >> make.log 2>&1  
491              fi              fi
492              RETVAL=$?              RETVAL=$?
493              if test "x$RETVAL" != x0 ; then              if test "x$RETVAL" != x0 ; then
494                  tail make.log                  tail make.tr_log
495                  echo failed 1>&2                  echo failed
496                  cp make.log $CDIR"/make.log"                  cp genmake.log genmake.tr_log $CDIR
497                  return 1                  tail -$NBLINES_MKLOG make.tr_log > $CDIR"/make.tr_log_tail"
498                    rm -f $EXECUTABLE
499                    mk_fail=1
500              else              else
501                  echo successful 1>&2                  echo successful
502              fi              fi
503            else
504                echo "no Makefile !"
505                mk_fail=2
506          fi          fi
507        fi
508        if test "x$ADM" = xt -a -f taf_ad.log ; then
509                head -1 taf_ad.log >> $CDIR"/summary.txt"
510                nerr=`grep -c 'TAF *.* ERROR ' taf_ad.log`
511                nwar=`grep -c 'TAF RECOMPUTATION *.* WARNING ' taf_ad.log`
512                echo " TAF reports $nerr Errors and $nwar Recomputation Warnings" \
513                                    >> $CDIR"/summary.txt"
514        fi
515        if test $mk_fail != 0 ; then return $mk_fail ; fi
516      )      )
517  }  }
518    
519    mk_mpi_size()
520    {
521        # mk_mpi_size input_file output_file proc_Nb prefer_to_split_X
522        #
523        # make new SIZE.h (=output_file) from SIZE.h_mpi (=input_file)
524        #     for an MPI build with no more than proc_Nb processors ;
525        # return the effective number of processors.
526    
527        inp=$1
528        out=$2
529        np=$3
530        dirX=$4
531        tmp=TTT.$$
532    
533        px=`grep "^     & *nPx *=" $inp | sed "s/^     & *nPx *= *//" | sed 's/, *$//'`
534        py=`grep "^     & *nPy *=" $inp | sed "s/^     & *nPy *= *//" | sed 's/, *$//'`
535        sx=`grep "^     & *nSx *=" $inp | sed "s/^     & *nSx *= *//" | sed 's/, *$//'`
536        sy=`grep "^     & *nSy *=" $inp | sed "s/^     & *nSy *= *//" | sed 's/, *$//'`
537    
538        #- find the largest divisor of input_file proc Nb, but not larger than $np
539        pp=0
540        i=1
541        while [ $i -le $px ] ; do
542          if [ `expr $px % $i` -eq 0 ] ; then
543            j=1
544            while [ $j -le $py ] ; do
545              if [ `expr $py % $j` -eq 0 ] ; then
546                ij=`expr $i \* $j`
547                if [ $ij -gt $pp ] ; then
548                    flag=1
549                elif [ $ij -eq $pp ] ; then
550                    flag=$dirX
551                else
552                    flag=0
553                fi
554                if test $flag = 1 ; then
555                  if [ $ij -le $np ] ; then
556                    ix=$i ; jy=$j ; pp=$ij
557                    #echo "  ix,jy= $ix,$jy"
558                  fi
559                fi
560              fi
561              j=`expr $j + 1`
562            done
563          fi
564          i=`expr $i + 1`
565        done
566    
567        #- create new SIZE.h type file:
568        sx=`expr $sx \* $px / $ix`
569        sy=`expr $sy \* $py / $jy`
570        if [ $verbose -gt 1 ]; then
571            echo " px,py,np= $px,$py,$np : New MPI size: px,py= $ix,$jy : sx,sy= $sx,$sy"
572        fi
573        sed "/^     \& *nPx *=/s/[0-9]*,/$ix,/" $inp > $tmp
574        sed "/^     \& *nPy *=/s/[0-9]*,/$jy,/" $tmp > $out
575        sed "/^     \& *nSx *=/s/[0-9]*,/$sx,/" $out > $tmp
576        sed "/^     \& *nSy *=/s/[0-9]*,/$sy,/" $tmp > $out
577        rm -f $tmp
578        return $pp
579    }
580    
581  symlink_mpifiles()  symlink_mpifiles()
582  {  {
583      # Put special links so that MPI specific files are used      # Put special links so that MPI specific files are used
# Line 434  symlink_mpifiles() Line 586  symlink_mpifiles()
586    
587      dir=$1      dir=$1
588      code_dir=$2      code_dir=$2
589      BUILD_DIR=$dir/$3      build_dir=$dir/$3
590      CODE_DIR=$dir/$code_dir  
       
591      # These are files that should replace their counter-part when using -mpi      # These are files that should replace their counter-part when using -mpi
592      MPI_FILES=`(cd $CODE_DIR; find . -name "*_mpi")`      MPI_FILES=`(cd $dir/$code_dir; find . -name "*_mpi" -print)`
593    
594      #  Is this an MPI run?      for ii in $MPI_FILES ; do
595      if test "x$MPI" = xt ; then          i=`echo $ii | sed 's:^\./::'`
596          # YES: We symbolically link these files to the build          name=`echo $i | sed 's:_mpi::'`
597          # dir so long as there is no real file in place          file="../$code_dir/$i"
598          for ii in $MPI_FILES ; do          if test $name = 'SIZE.h' ; then file="SIZE.h.mpi" ; fi
599              i=`echo $ii | sed 's:^\./::'`  
600              name=`echo $i | sed 's:_mpi::' `          #  Is this an MPI run?
601              cmp $CODE_DIR/$i $BUILD_DIR/$name > /dev/null 2>&1          if test "x$MPI" = x0 ; then
602              RETVAL=$?              # NO: We undo any _mpi symbolically linked files
603              if test "x$RETVAL" != x0 ; then              if test -L $build_dir/$name ; then
604                  if ! test -f $BUILD_DIR/$i ; then                  ( cd $build_dir ; cmp $name $file > /dev/null 2>&1 )
                     #echo Linking $name to $i  
                     (cd $BUILD_DIR; ln -sf ../$code_dir/$i $name)  
                 fi  
             fi  
         done  
     else  
         # NO: We undo any _mpi symbolically linked files  
         for ii in $MPI_FILES ; do  
             i=`echo $ii | sed 's:^\./::'`  
             name=`echo $i | sed 's:_mpi::' `  
             if test -L $BUILD_DIR/$name ; then  
                 cmp $BUILD_DIR/$name "../$code_dir/$name"_mpi > /dev/null 2>&1  
605                  RETVAL=$?                  RETVAL=$?
606                  if test "x$RETVAL" = x0 ; then                  if test "x$RETVAL" = x0 ; then
607                      #echo Un-linking $name from $linktarg                      if [ $verbose -gt 1 ]; then
608                      rm -f $BUILD_DIR/$name                          echo "  Un-linking $name from ../$code_dir" ; fi
609                        rm -f $build_dir/$name
610                  fi                  fi
611              fi              fi
612          done          else
613      fi              # YES: We symbolically link these files to the build
614                    # dir so long as there is no real file in place
615                ( cd $build_dir ; cmp $name $file > /dev/null 2>&1 )
616                RETVAL=$?
617                if [ $verbose -gt 1 ]; then echo "  cmp $name $file returns: $RETVAL" ; fi
618                if test "x$RETVAL" != x0 ; then
619                    if test -h $build_dir/$name ; then rm -f $build_dir/$name ; fi
620                    if test ! -r $build_dir/$name ; then
621                        if [ $verbose -gt 1 ]; then echo "  Linking $name to $file" ; fi
622                        (cd $build_dir; ln -sf $file $name)
623                    fi
624                fi
625            fi
626        done
627  }  }
628    
629  linkdata()  linkdata()
630  {  {
631      # linkdata flag      # linkdata run_dir input_dir_1 input_dir_2 ...
632      #      #
633      # symbolically link data files to run directory      # symbolically link data files to run directory
634      if test "x$1" = x1 ; then      if test -d $1 ; then
635          (          (
636              cd $2              cd $1 ; shift
637              if test "x$ADM" = x ; then              echo 'linkdata from dirs:' $*
638                  files=`( cd ../input ; ls -1 | grep -v CVS )`              inpMPI=`(cd ../$1 ; find . -name "*.mpi" -print | sed 's:^\./::')`
639                  for i in $files ; do              for xx in $inpMPI ; do
640                      if test ! -d "../input/"$i -a ! -f $i ; then                if test -r "../"$1"/"$xx ; then
641                          ln -sf "../input/"$i $i                  # found 1 _mpi sfx file in 1rst input dir and it is readable
642                      fi                  yy=`echo $xx | sed 's:\.mpi$::'`
643                  done                  if test "x$MPI" = "x0" ; then
644              else                      # not mpi test: remove symbolic link
645                  files=`( cd ../input ; ls -1 *.bin | grep -v CVS )`                      if test -h $yy ; then rm -f $yy ; fi
646                  for i in $files ; do                  else
647                      if test ! -d "../input/"$i ; then                      # mpi test: remove symbolic link & link .mpi sfx file
648                          ln -sf "../input/"$i $i                      if test -h $yy ; then rm -f $yy ; fi
649                        if test ! -r $yy ; then
650                            ln -sf "../"$1"/"$xx $yy ;
651                            printf " $xx" 1>&2
652                      fi                      fi
653                  done                  fi
654                  files=`( cd ../input_ad ; ls -1 | grep -v CVS )`                fi
655                  for i in $files ; do              done
656                      if test ! -d "../input_ad/"$i ; then              if test -r "../"$1"/eedata.mth" ; then
657                          ln -sf "../input_ad/"$i $i              # found eedata.mth in 1rst input dir and it is readable
658                    if test "x$MULTI_THREAD" = "xt" ; then
659                    # multi-threaded test: remove symbolic link & link eedata.mth
660                        if test -h eedata ; then rm -f eedata ; fi
661                        if test ! -r eedata ; then
662                            ln -sf "../"$1"/eedata.mth" eedata ;
663                            printf ' eedata.mth' 1>&2
664                      fi                      fi
665                  done                  else
666                    # not multi-threaded test: remove eedata symbolic link
667                        if test -h eedata ; then rm -f eedata ; fi
668                    fi
669              fi              fi
670                prevDir='NONE'
671                for ldir in $* ; do
672                    if test -d "../"$ldir -a $ldir != $prevDir ; then
673                        printf " ldir=${ldir}:" 1>&2
674                        files=`( cd "../"$ldir ; ls -1 | grep -v CVS )`
675                        for i in $files ; do
676                            if test ! -d "../"$ldir/$i ; then
677                                if test ! -r $i  ; then
678                                    printf ' '$i 1>&2
679                                    ln -sf "../"$ldir"/"$i $i
680                                fi
681                            fi
682                        done
683                        printf ' ;' 1>&2
684                        if test -x "../"$ldir"/"prepare_run ; then
685                            "../"$ldir"/"prepare_run 1>&2
686                        else
687                            echo '' 1>&2
688                        fi
689                    fi
690                    prevDir=$ldir
691                done
692          )          )
693      fi      fi
694  }  }
# Line 511  runmodel() Line 697  runmodel()
697  {  {
698      # runmodel directory      # runmodel directory
699      #      #
700      #  runs "$COMMAND in "directory"      #  runs $COMMAND in "directory"
701      #  (where "$COMMAND" is relative to "directory")      #  (where "$COMMAND" is relative to "directory")
702      (      (
703          cd $1          cd $1
704          printf 'runmodel in %s ...' $1 1>&2          printf 'runmodel in %s ... ' $1
705          # make output.txt          if test "x$MPI" != x0 ; then
706          echo              #- adjust the MPI run command with the right number of Procs
707          rm -f run.log              #echo '' ; echo "  COMMAND='$COMMAND'"
708          if test $OUTPUTFILE -ot $EXECUTABLE ; then              COMMAND=`echo $COMMAND | sed "s/ TR_NPROC / $LOC_NPROC /"`
709             ( eval $COMMAND ) > run.log 2>&1              if test "x$MPI_MFILE" != x ; then
710             RETVAL=$?                COMMAND=`echo $COMMAND | sed "s/ TR_MFILE / ..\/..\/$LOC_MFILE /"`
711                fi
712                #echo "  COMMAND='$COMMAND'"
713            fi
714            if test -L $EXECUTABLE ; then
715              if test -x "../"$builddir"/"$EXECUTABLE ; then
716                cmp $EXECUTABLE "../"$builddir"/"$EXECUTABLE > /dev/null 2>&1
717                outD=$? ; if test "x$outD" != x0 ; then rm -f $EXECUTABLE ; fi
718              else rm -f $EXECUTABLE
719              fi
720            fi
721            if test ! -x $EXECUTABLE -a -x "../"$builddir"/"$EXECUTABLE ; then
722                echo " link" $EXECUTABLE "from dir ../"$builddir > run.log_tmp
723                ln -sf "../"$builddir"/"$EXECUTABLE .
724            fi
725            if test ! -x $EXECUTABLE ; then
726                rm -f $RUNLOG ; touch $RUNLOG
727                if test -f run.log_tmp ; then cat run.log_tmp >> $RUNLOG ; fi
728                echo " no executable:" $EXECUTABLE >> $RUNLOG
729                RETVAL=8
730                ENDVAL=-1
731          else          else
732             echo " $OUTPUTFILE is up to date " > run.log 2>&1            if test ! -f $OUTPUTFILE -o $OUTPUTFILE -ot $EXECUTABLE ; then
733             RETVAL=0              # output do not exist or is older than executable:
734                rm -f $OUTPUTFILE $RUNLOG ; touch $RUNLOG
735                if test -f run.log_tmp ; then cat run.log_tmp >> $RUNLOG ; fi
736                ( eval $COMMAND ) >> $RUNLOG 2>&1
737                RETVAL=$?
738                ENDVAL=`tail $OUTPUTFILE | grep -c 'PROGRAM MAIN: Execution ended Normally'`
739                if [ $POSTCLEAN -eq 1 -a $ENDVAL -gt 0 ] ; then
740                    find . -name "*.meta" -exec rm {} \;
741                    find . -name "*.data" -exec rm {} \;
742                    rm -rf mnc_test_*
743                fi
744              else
745                RETVAL=0
746                ENDVAL=`tail $OUTPUTFILE | grep -c 'PROGRAM MAIN: Execution ended Normally'`
747                touch $RUNLOG
748                if test -f run.log_tmp ; then cat run.log_tmp >> $RUNLOG ; fi
749                echo "---------->> $OUTPUTFILE is up to date " >> $RUNLOG 2>&1
750              fi
751          fi          fi
752          # echo "COMMAND='$COMMAND'"          rm -f run.log_tmp
753          # echo "pwd='"`pwd`"'"          #- in all cases where OutputFile exists, report SIZE (and AD time)
754          if test "x$RETVAL" = x0 ; then          if test -f $OUTPUTFILE ; then
755              tail run.log            grep '(PID\.TID 0000\.0001)      n.. =' $OUTPUTFILE \
756              echo successful 1>&2                  | sed 's/(PID.TID 0000.0001)     //' >> $CDIR"/summary.txt"
757              # === Reduce the size of the testing emails!            if test "x$ADM" = xt ; then
758              # if test "x$ADM" = x ; then              grep -A3 'Seconds in section "ALL' $OUTPUTFILE >> $CDIR"/summary.txt"
759              #   cp output.txt $CDIR"/output.txt"            fi
760              # else          fi
761              #   cp output.txt_adm $CDIR"/output.txt_adm"          if test -s STDERR.0000 ; then cp STDERR.0000 $CDIR"/STDERR.0000" ; fi
762              # fi          if [ $RETVAL -eq 0 -a $ENDVAL -gt 0 ] ; then
763              if test -s STDERR.0000 ; then cp STDERR.0000 $CDIR"/STDERR.0000" ; fi              echo successful
764                printf '=> output from running in %s :\n' $1 1>&2
765                tail $RUNLOG | sed 's/^.*/> &/g' 1>&2
766                return 0
767            elif [ $RETVAL -ne 0 -a $ENDVAL -gt 0 ] ; then
768                #-- for some weird cases (run is finihed but with error code)
769                echo 'finished with error (run:' $RETVAL ' end:' $ENDVAL ')'
770                printf '=> output from running in %s :\n' $1 1>&2
771                tail $RUNLOG | sed 's/^.*/> &/g' 1>&2
772              return 0              return 0
773          else          else
774              tail run.log              echo 'failed (run:' $RETVAL ' end:' $ENDVAL ')'
775              echo failed 1>&2              printf '=> output from running in %s :\n' $1 1>&2
776              cp run.log $CDIR"/run.log"              tail $RUNLOG | sed 's/^.*/> &/g' 1>&2
777              if test -s STDERR.0000 ; then cp STDERR.0000 $CDIR"/STDERR.0000" ; fi              cp $RUNLOG $CDIR"/"$RUNLOG
778              return 1              return 1
779          fi          fi
780      )      )
# Line 553  createcodelet() Line 784  createcodelet()
784  {  {
785      # create codelet for comparing model output      # create codelet for comparing model output
786    
787      printf "creating the comparison code...  "      printf "creating the comparison code (using CC=$CC)...  "
788      cat > tmp_cmpnum.c <<EOF      cat > tr_cmpnum.c <<EOF
789  #include <stdio.h>  #include <stdio.h>
790  #include <math.h>  #include <math.h>
791  int main( int argc, char** argv )  {  int main( int argc, char** argv )  {
792    int linnum,best,lncnt;    int linnum,cmplin,best,lncnt;
793    double a,b,abave,relerr;    double a,b,abave,relerr;
794    best = -22;    best = -22;
795    lncnt = 0;    lncnt = 0;
796    while( 1 & (lncnt+=1) < 999 )  {    while( 1 & ( (lncnt+=1) < 999 ) )  {
797      scanf("%d", &linnum);      scanf("%d", &linnum);
798      if (linnum == -1)  break;      if (linnum == -1)  break;
799      scanf("%lf", &a);  scanf("%lf", &b);      scanf("%lf", &a);  scanf("%lf", &b);
800      abave = 0.5*(fabs(a)+fabs(b));      abave = 0.5*(fabs(a)+fabs(b));
801      if (abave > 0.0) {      if ( abave == abave ) {
802        relerr=fabs(a-b)/abave;        if (abave > 0.0) {
803        if (relerr > 0.0) { linnum = (int)rint(log10(relerr)); }          relerr=fabs(a-b)/abave;
804        else { linnum = -16 ; }          if (relerr > 0.0) { cmplin = (int)rint(log10(relerr)); }
805        best = (best > linnum) ? best : linnum;          else { cmplin = -16 ; }
806      }          best = (best > cmplin) ? best : cmplin; }
807          else { cmplin = -22 ; }
808       /* printf("%d ; %lf ; %lf\n",cmplin,a,b); */
809          }
810       else {
811       /* printf("%lf ; %lf ; %lf\n",abave,a,b); */
812          break; }
813    }    }
814    if (lncnt == 999) best=-29;    if (lncnt == 999) best=-29;
815      if (linnum != -1) best=-99;
816    printf("%d\n", -best);    printf("%d\n", -best);
817    return 0;    return 0;
818  }  }
819  EOF  EOF
820      $CC -o tmp_cmpnum tmp_cmpnum.c -lm      $CC -o tr_cmpnum tr_cmpnum.c -lm
821    
822      if [ -x ./tmp_cmpnum ]; then      if [ -x ./tr_cmpnum ]; then
823          echo "OK"          echo "OK"
824          return 0          return 0
825      else      else
826          echo          echo
827          echo "ERROR: failed to compile comparison code -- please specify"          echo "ERROR: failed to compile comparison code -- please specify"
828          echo "  a C compiler using the CC environment variable."          echo "  a C compiler using the CC environment variable."
829          exit 1          exit 1
830      fi      fi
# Line 599  formatresults() Line 837  formatresults()
837      nm=$1      nm=$1
838      printf '%s %s %s %s' $2 $3 $4 $5      printf '%s %s %s %s' $2 $3 $4 $5
839      shift; shift; shift; shift; shift;      shift; shift; shift; shift; shift;
840      printf '%3s' $@      listPrt=$@
841            listRes=`echo $listPrt | sed 's/>//' | sed 's/<//'`
842      if [ $1 = '--' ]; then      xx=`echo $listPrt | sed 's/.*>//' | sed 's/<.*//' | awk '{print $1}'`
843        printf '%3s' $listPrt
844    #   line below does not work on hp-ux_ia64 : do those substitutions later on
845    #   printf '%3s' $listPrt | sed 's/ 99/ --/g' | sed 's/  > />/' | sed 's/  < /</'
846    
847        if [ $xx = '..' ]; then
848            printf ' N/O '
849        elif [ $xx = '--' ]; then
850            printf ' N/O '
851        elif [ $xx = 99 ]; then
852          printf ' N/O '          printf ' N/O '
853      else      else
854          if [ $1 -gt 12 ]; then          if [ $xx -ge $MATCH_CRIT ]; then
855              printf ' pass'              printf ' pass'
856          else          else
857              printf ' FAIL'              printf ' FAIL'
# Line 612  formatresults() Line 859  formatresults()
859      fi      fi
860      printf '  %s' $nm      printf '  %s' $nm
861      printf '\n'      printf '\n'
       
 }  
   
 show_help()  
 {  
     cat - << EOF  
 $0 [-help] [-quick] [-verbose] dir1 [dir2] [...]  
862    
  -help|-h      Show this help message  
  -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.  
  -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  
863  }  }
864    
865  scandirs()  scandirs()
866  {  {
867      if [ $# -eq 0 ]; then      if [ $# -eq 1 ]; then
868          for arg in * ; do          for arg in * ; do
869              test -d $arg/input && echo $arg              test -f $arg/$1 && echo $arg
870          done          done
871      else      else
872          echo $*          echo $*
873      fi      fi
874  }  }
875    
876    
877    check_eedata()
878    {
879        # check_eedata eedata size.h
880        if [ $# -eq 2 ] ; then
881         if test -f $1 -a -f $2 ; then
882          nx=`grep "^ *nTx *=" $1 | tail -1 | sed 's/^ *nTx *= *//' | sed "s/, *$//"`
883          sx=`grep "^     & *nSx *=" $2 | sed "s/^     & *nSx *=//" | sed 's/, *$//'`
884          if test "x$nx" = x ; then
885            rx=10
886          else
887            rx=`expr $sx % $nx`
888          fi
889          ny=`grep "^ *nTy *=" $1 | tail -1 | sed 's/^ *nTy *= *//' | sed "s/, *$//"`
890          sy=`grep "^     & *nSy *=" $2 | sed "s/^     & *nSy *=//" | sed 's/, *$//'`
891          if test "x$ny" = x ; then
892            ry=20
893          else
894            ry=`expr $sy % $ny`
895          fi
896          echo `expr $rx + $ry`
897         else
898          echo '-1'
899         fi
900        elif [ $# -eq 1 ] ; then
901         if test -f $1 ; then
902          nx=`grep "^ *nTx *=" $1 | tail -1 | sed 's/^ *nTx *= *//' | sed "s/, *$//"`
903          if test "x$nx" = x ; then nx=1 ; fi
904          ny=`grep "^ *nTy *=" $1 | tail -1 | sed 's/^ *nTy *= *//' | sed "s/, *$//"`
905          if test "x$ny" = x ; then ny=1 ; fi
906         #echo $nx $ny
907          echo $nx
908         else
909          echo '-1'
910         fi
911        else
912          echo '-2'
913        fi
914    
915    }
916    
917  ###############################################################################  ###############################################################################
918    
919    
920  #  Default properties  #  Default properties
921  debug=0  debug=0
922  verbose=1  verbose=1
923  clean=0  NBLINES_MKLOG=16000
 expts=''  
 # ieee=1  
924    
925  IEEE=true  IEEE=true
926  if test "x$MITGCM_IEEE" != x ; then  if test "x$MITGCM_IEEE" != x ; then
927      IEEE=$MITGCM_IEEE      IEEE=$MITGCM_IEEE
928  fi  fi
929    OptLev=1
930    GSL=f
931    
932  CLEANUP=f  CLEANUP=f
933    NORUN=f
934  QUICK=f  QUICK=f
935    NOMAKE=f
936  NOGENMAKE=f  NOGENMAKE=f
937  NOCLEAN=f  NOCLEAN=f
938  NODEPEND=f  NODEPEND=f
939  POSTCLEAN=f  POSTCLEAN=0
940    
941  BASH=  BASH=
942  OPTFILE=NONE  OPTFILE=NONE
943  ADDRESSES=  ADDRESSES=
944  TESTDIRS=  TESTDIRS=
945    SKIPDIRS=
946  MPACKDIR="../tools/mpack-1.6"  MPACKDIR="../tools/mpack-1.6"
947  HAVE_MPACK=  HAVE_MPACK=
948  MPACK="$MPACKDIR/mpack"  MPACK=
949  COMMAND=  COMMAND=
950    MKDEPEND=
951  if test "x$MAKE" = x ; then  if test "x$MAKE" = x ; then
952      MAKE=make      MAKE=make
953  fi  fi
# Line 684  if test "x$CC" = x ; then Line 955  if test "x$CC" = x ; then
955      CC=cc      CC=cc
956  fi  fi
957  JOBS=  JOBS=
958  MPI=f  MPI=0
959    MPI_MFILE=
960    MULTI_THREAD=f
961  OUTDIR=  OUTDIR=
962  DELDIR=  DELDIR=
963    USE_R4=
964    
965  ADM=  ADM=
966    OADM=
967    
968  # Additional monitor types  # list of pTracers to check for monitor output
969  PTRACERS_NUM="1 2 3 4 5"  PTRACERS_NUM="1 2 3 4 5"
970    
971    MATCH_CRIT=10
972    
973  printf "parsing options...  "  printf "parsing options...  "
974    
975  ac_prev=  ac_prev=
# Line 706  for ac_option ; do Line 983  for ac_option ; do
983      fi      fi
984    
985      ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`      ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
986        
987      case $ac_option in      case $ac_option in
988                    
989          -help | --help | -h | --h)          -help | --help | -h | --h) usage ;;
990              usage ;;  
991                    -optfile | --optfile | -of | --of) ac_prev=OPTFILE ;;
992          -optfile | --optfile | -of | --of)          -optfile=* | --optfile=* | -of=* | --of=*) OPTFILE=$ac_optarg ;;
993              ac_prev=OPTFILE ;;  
994          -optfile=* | --optfile=* | -of=* | --of=*)          -addr | --addr | -a | --a) ac_prev=ADDRESSES ;;
995              OPTFILE=$ac_optarg ;;          -addr=* | --addr=* | -a=* | --a=*) ADDRESSES=$ac_optarg ;;
996                    -mpackdir | --mpackdir | -mpd | --mpd) ac_prev=MPACKDIR ;;
997          -addr | --addr | -a | --a)          -mpackdir=* | --mpackdir=* | -mpd=* | --mpd=*) MPACKDIR=$ac_optarg ;;
998              ac_prev=ADDRESSES ;;  
999          -addr=* | --addr=*)          -tdir | --tdir | -t | --t) ac_prev=TESTDIRS ;;
1000              ADDRESSES=$ac_optarg ;;          -tdir=* | --tdir=* | -t=* | --t=*) TESTDIRS=$ac_optarg ;;
1001            -skipdir | --skipdir | -skd | --skd) ac_prev=SKIPDIRS ;;
1002          -tdir | --tdir | -t | --t)          -skipdir=* | --skipdir=* | -skd=* | --skd=*) SKIPDIRS=$ac_optarg ;;
1003              ac_prev=TESTDIRS ;;  
1004          -tdir=* | --tdir=*)          -bash | --bash | -b | --b) ac_prev=BASH ;;
1005              TESTDIRS=$ac_optarg ;;          -bash=* | --bash=* | -b=* | --b=*) BASH=$ac_optarg ;;
1006    
1007          -bash | --bash | -b | --b)          -command | --command | -c | --c) ac_prev=COMMAND ;;
1008              ac_prev=BASH ;;          -command=* | --command=* | -c=* | --c=*) COMMAND=$ac_optarg ;;
1009          -bash=* | --bash=*)  
1010              BASH=$ac_optarg ;;          -makedepend | --makedepend | -md | --md) ac_prev=MKDEPEND ;;
1011            -makedepend=* | --makedepend=* | -md=* | --md=*) MKDEPEND=$ac_optarg ;;
1012          -command | --command | -c | --c)  
1013              ac_prev=COMMAND ;;          -make | --make | -m | --m) ac_prev=MAKE ;;
1014          -command=* | --command=*)          -make=* | --make=* | -m=* | --m=*) MAKE=$ac_optarg ;;
1015              COMMAND=$ac_optarg ;;  
1016            -odir | --odir) ac_prev=OUTDIR ;;
1017          -make | --make | -m | --m)          -odir=* | --odir=*) OUTDIR=$ac_optarg ;;
1018              ac_prev=MAKE ;;  
1019          -make=* | --make=*)          -ptracers | --ptracers | -ptr | --ptr) ac_prev=PTRACERS_NUM ;;
1020              MAKE=$ac_optarg ;;          -ptracers=* | --ptracers=* | -ptr=* | --ptr=*) PTRACERS_NUM=$ac_optarg ;;
1021    
1022          -odir | --odir)          -match | --match ) ac_prev=MATCH_CRIT ;;
1023              ac_prev=OUTDIR ;;          -match=* | --match=* ) MATCH_CRIT=$ac_optarg ;;
1024          -odir=* | --odir=*)  
1025              OUTDIR=$ac_optarg ;;          -j | --j) ac_prev=JOBS ;;
1026            -j=* | --j=*) JOBS=$ac_optarg ;;
1027          -ptracers | --ptracers | -ptr | --ptr)  
1028              ac_prev=PTRACERS_NUM ;;          -clean | --clean) CLEANUP=t ; DELDIR=t ;;
1029          -ptracers=* | --ptracers=* | -ptr=* | --ptr=*)  
1030              PTRACERS_NUM=$ac_optarg ;;          -norun | --norun | -nr | --nr) NORUN=t ;;
1031            -runonly | --runonly | -ro | --ro) QUICK=t ; NOMAKE=t ;;
1032          -j) ac_prev=JOBS ;;          -quick | --quick | -q | --q) QUICK=t ;;
1033          -j=*) JOBS=$ac_optarg ;;          -nogenmake | --nogenmake | -ng | --ng) NOGENMAKE=t ;;
1034            -noclean | --noclean | -nc | --nc) NOCLEAN=t ;;
1035          -clean | --clean)          -nodepend | --nodepend | -nd | --nd) NODEPEND=t ;;
1036              CLEANUP=t ; DELDIR=t ;;  
1037            -postclean | --postclean | -pc | --pc) POSTCLEAN=2 ;;
1038          -quick | --quick | -q | --q)          -deloutp | --deloutp | -do | --do) POSTCLEAN=1 ;;
             QUICK=t ;;  
         -nogenmake | --nogenmake | -ng | --ng)  
             NOGENMAKE=t ;;  
         -noclean | --noclean | -nc | --nc)  
             NOCLEAN=t ;;  
         -nodepend | --nodepend | -nd | --nd)  
             NODEPEND=t ;;  
1039    
1040          -postclean | --postclean | -pc | --pc)          -mpi | --mpi) MPI=2 ;;
1041              POSTCLEAN=t ;;          -MPI | --MPI) ac_prev=MPI ;;
1042            -MPI=* | --MPI=*) MPI=$ac_optarg ;;
1043    
1044          -mpi) MPI=t ;;          -mfile | --mfile | -mf | --mf) ac_prev=MPI_MFILE ;;
1045            -mfile=* | --mfile=* | -mf=* | --mf=*) MPI_MFILE=$ac_optarg ;;
1046    
1047            -mth) MULTI_THREAD=t ;;
1048    
1049          -adm | -ad) ADM=t ;;          -adm | -ad) ADM=t ;;
1050            -oad) OADM=t; NODEPEND=t ;;
1051    
1052          -ieee) IEEE=true ;;          -ieee)   echo "Warning: ignore option '-ieee' (already the default)"
1053          -noieee) IEEE= ;;                   printf " ... " ;;
1054            -noieee) echo "Warning: will use option '-fast' instead of '-noieee' (obsolete)"
1055                     printf " ... " ; OptLev=`expr $OptLev \* 2` ;;
1056            -fast)  OptLev=`expr $OptLev \* 2` ;;
1057            -devel) OptLev=0 ;;
1058            -gsl) GSL=t ;;
1059    
1060          -verbose) verbose=2 ;;          -verbose) verbose=2 ;;
1061          -debug) debug=1 ;;          -debug) debug=1 ;;
# Line 783  for ac_option ; do Line 1063  for ac_option ; do
1063    
1064          -deldir | -dd) DELDIR=t ;;          -deldir | -dd) DELDIR=t ;;
1065    
1066          -*)          -use_r4|-ur4) USE_R4=t ;;
1067              echo "Error: unrecognized option: "$ac_option  
1068              usage          -ts) TS=t;;
1069              ;;          -papis) PAPIS=t;;
1070                    -pcls) PCL=t;;
1071          *)  
1072              echo "Error: unrecognized argument: "$ac_option          -*) echo "Error: unrecognized option: "$ac_option
1073              usage              usage ;;
1074              ;;          *)  echo "Error: unrecognized argument: "$ac_option
1075                        usage ;;
1076    
1077       esac       esac
1078        
1079  done  done
1080    
1081  if test "x$QUICK" = xt ; then  if test "x$QUICK" = xt ; then
# Line 803  if test "x$QUICK" = xt ; then Line 1084  if test "x$QUICK" = xt ; then
1084      NODEPEND=t      NODEPEND=t
1085  fi  fi
1086    
1087  if test "x$TESTDIRS" = x ; then  #- check length of MPI machine file:
1088      TESTDIRS=`scandirs`  if test "x$MPI" != x0 -a "x$MPI_MFILE" != x ; then
1089  fi      if test -r $MPI_MFILE ; then
1090            nl=`wc -l $MPI_MFILE | awk '{print $1}'`
1091  if test "x$OPTFILE" = xNONE -a "x$MITGCM_OF" != x ; then          if [ $nl -lt $MPI ] ; then
1092      OPTFILE=$MITGCM_OF            echo "Error: need at least $MPI nodes (currently only $nl) in MPI_MFILE=$MPI_FILE"
1093              usage
1094            fi
1095            if [ $verbose -gt 1 ]; then
1096                echo " MPI_MFILE=$MPI_MFILE : $nl procs for MPI=$MPI run"
1097            fi
1098        else
1099              echo "Error: cannot access MPI_MFILE=$MPI_FILE"
1100              usage
1101        fi
1102  fi  fi
1103    
1104    #- setting for forward or ADM testing
1105  if test "x$ADM" = xt ; then  if test "x$ADM" = xt ; then
1106        code_dir=code_ad
1107        inputdir=input_ad
1108        ref_outp="output_adm.txt"
1109        EXECUTABLE="mitgcmuv_ad"
1110    elif test "x$OADM" = xt ; then
1111        code_dir=code_oad
1112        inputdir=input_oad
1113        ref_outp="output_oadm.txt"
1114      EXECUTABLE="mitgcmuv_ad"      EXECUTABLE="mitgcmuv_ad"
     OUTPUTFILE="output.txt_adm"  
1115  else  else
1116        code_dir=code
1117        inputdir=input
1118        ref_outp="output.txt"
1119      EXECUTABLE="mitgcmuv"      EXECUTABLE="mitgcmuv"
     OUTPUTFILE="output.txt"  
1120  fi  fi
1121    
1122  if test "x$ADM" = xt -a "x$COMMAND" = x ; then  xx=`echo $TESTDIRS | awk '{print $1}'`
1123      COMMAND="./$EXECUTABLE > $OUTPUTFILE"  if test "x$TESTDIRS" = x ; then
1124        LIST=`scandirs results/$ref_outp`
1125    elif test $xx = 'start_from' ; then
1126        xx=`echo $TESTDIRS | awk '{print $2}'`
1127        LIST=`scandirs results/$ref_outp | sed -n "/$xx/,$ p"`
1128    else
1129        #- expand group of experiments:
1130        LIST=" "
1131        for xx in $TESTDIRS
1132        do
1133          case $xx in
1134            'basic') LIST=${LIST}" aim.5l_cs hs94.128x64x5 ideal_2D_oce"
1135                     LIST=${LIST}" lab_sea tutorial_baroclinic_gyre"
1136                     LIST=${LIST}" tutorial_global_oce_latlon tutorial_plume_on_slope"
1137                    ;;
1138            'tutorials')
1139                     LIST=${LIST}" "`ls | grep 'tutorial_'` ;;
1140            *)       LIST=${LIST}" "$xx ;;
1141          esac
1142        done
1143    fi
1144    #echo 'LIST='${LIST}'<'
1145    #- skip dirs, remove duplicate and non-directory:
1146    TESTDIRS=" "
1147    count=0
1148    for xx in $LIST
1149    do
1150        yy=`echo $SKIPDIRS | grep -c $xx`
1151        if test $yy = 0 ; then
1152            if test -d $xx ; then
1153                yy=`echo $TESTDIRS | grep -c $xx`
1154                if test $yy = 0 ; then TESTDIRS=${TESTDIRS}" "$xx ; fi
1155            else count=1 ;
1156                echo ""; echo -n " -- skip \"$xx\" (not a directory !)"
1157            fi
1158        else
1159            if test $count = 1 ; then echo -n ", \"$xx\""
1160            else count=1 ; echo "" ;  echo -n " skip: \"$xx\""
1161            fi
1162        fi
1163    done
1164    if test $count = 1 ; then echo "" ; echo -n " ... " ; fi
1165    #echo 'TESTDIRS='${TESTDIRS}'<'
1166    
1167    if test "x$OPTFILE" = xNONE -a "x$MITGCM_OF" != x ; then
1168        OPTFILE=$MITGCM_OF
1169  fi  fi
1170    
1171    LOC_MFILE='tr_mpi_mfile'
1172    RUNLOG="run.tr_log"
1173    OUTPUTFILE=$ref_outp
1174  if test "x$COMMAND" = x ; then  if test "x$COMMAND" = x ; then
1175      COMMAND="./$EXECUTABLE > $OUTPUTFILE"      COMMAND="./$EXECUTABLE > $OUTPUTFILE"
1176  fi  fi
1177    if test "x$MPI" != x0 ; then
1178        OUTPUTFILE="STDOUT.0000"
1179    fi
1180    
 #echo "OK"  
1181  echo "OK (COMMAND= $COMMAND )"  echo "OK (COMMAND= $COMMAND )"
1182    
1183    # set the Default List of output variables to be checked:
1184    #  (use default or load experiment-specific list from file "tr_checklist")
1185    # content : 1rst = main variable used to decide if it pass or FAIL
1186    #         others = number of matching digits to be printed in summary.txt
1187    if test "x$ADM" = x -a "x$OADM" = x; then
1188        DEF_CHECK_LIST='PS PS T+ S+ U+ V+ pt1+ pt2+ pt3+ pt4+ pt5+'
1189        EMPTY_RESULTS='.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..'
1190        LEN_CHECK_LIST=`echo $DEF_CHECK_LIST | sed 's/ [a-zA-Z0-9]*+/&mn &mx &av &sd/g' | awk '{print NF-1}'`
1191        ii=`echo $EMPTY_RESULTS | awk '{print NF}'`
1192        EMPTY_RESULTS=$EMPTY_RESULTS`expr $LEN_CHECK_LIST - $ii | awk 'BEGIN{FS=":"}{for(i=1;i<=$1;i++){printf "  ."}}'`
1193    else
1194        DEF_CHECK_LIST='Grad Cost Grad'
1195        EMPTY_RESULTS='.. ..'
1196        LEN_CHECK_LIST=`echo $DEF_CHECK_LIST | sed 's/ [a-zA-Z0-9]*+/&mn &mx &av &sd/g' | awk '{print NF-1}'`
1197    fi
1198    
1199  #  create the FORTRAN comparison code  #  create the FORTRAN comparison code
1200  createcodelet  if test -x tr_cmpnum ; then
1201        echo "skipping comparison code build"
1202    else
1203        createcodelet
1204    fi
1205    
1206  #  build the mpack utility  #  build the mpack utility (if ADDRESSES = NONE, do it to test the build)
1207  if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then  if test "x$ADDRESSES" = x ; then
1208      echo "skipping mpack build"      echo "skipping mpack build"
1209  else  else
1210      build_mpack      build_mpack
1211  fi  fi
1212    
1213  #  Create a uniquely named directory to store results  #  Create a uniquely named directory to store results
1214    CMDLINE=$0
1215    for xx in "$@" ; do nw=`echo $xx | wc -w`
1216        if test $nw = '1' ; then CMDLINE="$CMDLINE $xx"
1217                            else CMDLINE="$CMDLINE '$xx'" ; fi
1218    done
1219    #for xx in "$@" ; do CMDLINE="$CMDLINE '$xx'" ; done
1220  MACH=`hostname`  MACH=`hostname`
1221  UNAMEA=`uname -a`  UNAMEA=`uname -a`
1222  DATE=`date +%Y%m%d`  DATE=`date +%Y%m%d`
1223  BASE="tr_"$MACH"_"$DATE"_"  BASE="tr_"$MACH"_"$DATE"_"
1224  if test "x$OUTDIR" != x ; then  if test "x$OUTDIR" != x ; then
1225      BASE="tr_"$OUTDIR"_"$DATE"_"      BASE="tr_"$OUTDIR"_"$DATE"_"
1226    else
1227        short_name=`hostname | sed 's/\..*$//'`
1228        BASE="tr_"$short_name"_"$DATE"_"
1229  fi  fi
1230  DNUM=0  DNUM=0
1231  DRESULTS="$BASE$DNUM"  DRESULTS="$BASE$DNUM"
# Line 861  if test "x$RETVAL" != x0 ; then Line 1240  if test "x$RETVAL" != x0 ; then
1240      exit 1      exit 1
1241  fi  fi
1242  SUMMARY="$DRESULTS/summary.txt"  SUMMARY="$DRESULTS/summary.txt"
 printf "Start time:  " >> $SUMMARY  
1243  start_date=`date`  start_date=`date`
1244  echo $start_date > $SUMMARY  echo $start_date > $SUMMARY
1245    echo 'run:' $CMDLINE >> $SUMMARY
1246    echo 'on :' $UNAMEA  >> $SUMMARY
1247    
1248  of_path=  of_path=
1249  if test "x$OPTFILE" != xNONE ; then  if test "x$OPTFILE" != xNONE ; then
# Line 887  if test "x$OPTFILE" != xNONE ; then Line 1267  if test "x$OPTFILE" != xNONE ; then
1267      fi      fi
1268  else  else
1269      echo >> $SUMMARY      echo >> $SUMMARY
1270      echo "No \"OPTFILE\" was explicitly specified by testreport," >> $SUMMARY      echo "No \"OPTFILE\" was specified ; genmake2 found and uses:" >> $SUMMARY
1271      echo "   so the genmake default will be used." >> $SUMMARY      #-note: to be filled later after 1rst run
1272  fi  fi
1273  echo  echo
1274  echo >> $SUMMARY  echo >> $SUMMARY
1275  if test "x$ADM" = x ; then  if test "x$ADM" = x -a "x$OADM" = x; then
1276      line_0="            ----T-----  ----S-----  ----U-----  ----V-----"      if [ $MATCH_CRIT -lt 10 ] ;
1277        then line_0="default  "$MATCH_CRIT ;
1278        else line_0="default "$MATCH_CRIT ; fi
1279           line_0="$line_0  ----T-----  ----S-----  ----U-----  ----V-----"
1280      line_1="G D M    c        m  s        m  s        m  s        m  s"      line_1="G D M    c        m  s        m  s        m  s        m  s"
1281      line_2="E p a R  g  m  m  e  .  m  m  e  .  m  m  e  .  m  m  e  ."      line_2="E p a R  g  m  m  e  .  m  m  e  .  m  m  e  .  m  m  e  ."
1282      line_3="N n k u  2  i  a  a  d  i  a  a  d  i  a  a  d  i  a  a  d"      line_3="N n k u  2  i  a  a  d  i  a  a  d  i  a  a  d  i  a  a  d"
1283      line_4="2 d e n  d  n  x  n  .  n  x  n  .  n  x  n  .  n  x  n  ."      line_4="2 d e n  d  n  x  n  .  n  x  n  .  n  x  n  .  n  x  n  ."
1284      for ii in $PTRACERS_NUM ; do      for ii in $PTRACERS_NUM ; do
         #  tst=`eval 'echo $HAVE_PTR0'$ii`  
         #  if test "x$tst" = xt ; then  
1285          line_0="$line_0  --PTR 0"$ii"--"          line_0="$line_0  --PTR 0"$ii"--"
1286          line_1="$line_1        m  s"          line_1="$line_1        m  s"
1287          line_2="$line_2  m  m  e  ."          line_2="$line_2  m  m  e  ."
1288          line_3="$line_3  i  a  a  d"          line_3="$line_3  i  a  a  d"
1289          line_4="$line_4  n  x  n  ."          line_4="$line_4  n  x  n  ."
         #  fi  
1290      done      done
1291      echo "$line_0" | tee -a $SUMMARY      echo "$line_0" | tee -a $SUMMARY
1292      echo "$line_1" | tee -a $SUMMARY      echo "$line_1" | tee -a $SUMMARY
# Line 917  if test "x$ADM" = x ; then Line 1297  if test "x$ADM" = x ; then
1297  else  else
1298      echo "ADJOINT=true" >> $SUMMARY      echo "ADJOINT=true" >> $SUMMARY
1299      echo >> $SUMMARY      echo >> $SUMMARY
1300        if [ $MATCH_CRIT -lt 10 ] ;
1301        then line_0="default     "$MATCH_CRIT ;
1302        else line_0="default    "$MATCH_CRIT ; fi
1303        echo "$line_0" | tee -a $SUMMARY
1304      cat << EOF | tee -a $SUMMARY      cat << EOF | tee -a $SUMMARY
1305  G D M    C  G  G D M    C  G
1306  E p a R  o  r  E p a R  o  r
# Line 925  N n k u  s  a Line 1309  N n k u  s  a
1309    
1310  EOF  EOF
1311  fi  fi
1312    echo "-------------------------------------------------------------------------------"
1313    
1314  #  ...and each test directory...  #  ...and each test directory...
1315  for dir in $TESTDIRS ; do  for dir in $TESTDIRS ; do
1316        
1317        # set builddir & rundir:
1318        builddir="build"
1319        if test ! -d $dir/$builddir ; then mkdir $dir/$builddir ; fi
1320        rundir="run"
1321        pfxdir="tr_$rundir"
1322        if test ! -d $dir/$rundir ; then
1323            rundir=$builddir
1324        fi
1325        CODE_DIR=$dir/$code_dir
1326        BUILD_DIR=$dir/$builddir
1327    
1328      #  Cleanup only!      #  Cleanup only!
1329      if test "x$CLEANUP" = xt ; then      if test "x$CLEANUP" = xt ; then
1330          if test -r $dir/build/Makefile ; then          echo -n '  --- dir:' $BUILD_DIR ': '
1331              ( cd $dir/build ; make CLEAN )          makeclean $BUILD_DIR
1332            (   cd $BUILD_DIR
1333                rm -f $EXECUTABLE *.bak
1334                rm -f genmake_state genmake_*optfile genmake.log
1335                rm -f SIZE.h.mpi genmake.tr_log make.tr_log
1336            )
1337            if test -d $dir/$rundir/CVS ; then
1338                echo -n '  --- dir:' $dir/$rundir ': '
1339                run_clean $dir/$rundir
1340          fi          fi
1341          if test -r $dir/input/Makefile ; then          trdir=`( cd $dir ; find . -type d -name "$pfxdir.*" -print | sed 's/^.\///')`
1342              ( cd $dir/input ; make CLEAN )          ttd=`echo $trdir | wc -w`
1343            if test $ttd != 0 ; then
1344                echo '  --- rm dir:' $trdir
1345                ( cd $dir ; rm -rf $trdir )
1346          fi          fi
         (  
             cd $dir  
             rm -rf tr_run.*  
         )  
1347          continue          continue
1348      fi      fi
1349    
1350      #  Verify that the testdir exists and contains previous      #  Verify that the testdir exists and contains previous
1351      #  results in the correct location--or skip this directory!      #  results in the correct location--or skip this directory!
1352      fout=      fout=$dir"/results/"$ref_outp
     if test "x$ADM" = x ; then  
         fout=$dir"/results/output.txt"  
     else  
         fout=$dir"/results_ad/output.txt_adm"  
     fi  
1353      if test ! -r $fout ; then      if test ! -r $fout ; then
1354          echo "can't read \"$fout\" -- skipping $dir"          echo "can't read \"$fout\" -- skipping $dir"
1355          continue          continue
1356      fi      fi
     if test "x$ADM" = x ; then  
         check_for_add_mon_output  $fout  
     fi  
1357    
1358      # Check for additional types of monitor output      # Check for specific files for particular type of run
1359    
1360      builddir="input"      if test ! -r $CODE_DIR"/SIZE.h_mpi"  -a "x$MPI" != "x0" ; then
1361      rundir="input"          echo "can't find \"$CODE_DIR/SIZE.h_mpi\" -- skipping $dir"
1362      use_seperate_build=0          continue
     if test -d $dir/build -a -r $dir/build ; then  
         builddir="build"  
         rundir="build"  
         use_seperate_build=1  
         linkdata $use_seperate_build $dir/$rundir  
1363      fi      fi
1364            if test ! -r $dir"/input/eedata.mth" -a "x$MULTI_THREAD" = "xt" ; then
1365      #  Check whether there are "extra runs" for this testdir          echo "can't find \"$dir/input/eedata.mth\" -- skipping $dir"
1366      extra_runs=          continue
     if test "x$ADM" = x -a "x$use_seperate_build" = x1 ; then  
         ex_run_dirs=`( cd $dir ; echo input.* )`  
         echo "ex_run_dirs='$ex_run_dirs'"  
         for exd in $ex_run_dirs ; do  
             name=`echo $exd | sed -e 's/input.//g'`  
             outf="$dir/results/output.txt.$name"  
             if test -f $outf -a -r $outf ; then  
                 extra_runs="$extra_runs $name"  
             fi  
         done  
1367      fi      fi
1368    
1369      if test "x$ADM" = x ; then      if test "x$MPI" != "x0" ; then
1370          code_dir=code          prefer_X=0
1371          CODE_DIR=$dir/code          if test "x$MULTI_THREAD" = "xt" ; then
1372      else              retv=`check_eedata $dir"/input/eedata.mth"`
1373          code_dir=code_ad              if test $retv = 1 ; then prefer_X=1 ; fi
1374          CODE_DIR=$dir/code_ad          fi
1375            #- create new SIZE.h with no more than '$MPI' Procs
1376            mk_mpi_size $CODE_DIR"/SIZE.h_mpi" $BUILD_DIR"/tr_size.mpi" $MPI $prefer_X
1377            LOC_NPROC=$?
1378            (   cd $BUILD_DIR
1379                if test -r SIZE.h.mpi ; then
1380                    cmp tr_size.mpi SIZE.h.mpi > /dev/null 2>&1 ; RETVAL=$?
1381                else RETVAL=1
1382                fi
1383                if test "x$RETVAL" = x0 ; then
1384                    rm -f tr_size.mpi
1385                else
1386                    rm -f SIZE.h.mpi ; mv tr_size.mpi SIZE.h.mpi
1387                fi
1388            )
1389            if test "x$MPI_MFILE" != x ; then
1390                #- create new MPI machine-file with the right number of Procs
1391                rm -f $LOC_MFILE
1392                cat $MPI_MFILE | sort | uniq | head -$LOC_NPROC > $LOC_MFILE
1393                nl=`wc -l $LOC_MFILE | awk '{print $1}'`
1394                if [ $nl -lt $LOC_NPROC ] ; then
1395                    rm -f $LOC_MFILE
1396                    cat $MPI_MFILE | head -$LOC_NPROC > $LOC_MFILE
1397                    #sed -n "1,$LOC_NPROC p" $MPI_MFILE > $LOC_MFILE
1398                fi
1399                if [ $verbose -gt 1 ]; then
1400                    nl=`wc -l $LOC_MFILE | awk '{print $1}'`
1401                    echo " new LOC_MFILE=$LOC_MFILE : $nl procs for LOC_NPROC=$LOC_NPROC"
1402                fi
1403            fi
1404            if test "x$MULTI_THREAD" = "xt" ; then
1405                retv=`check_eedata $dir"/input/eedata.mth" $BUILD_DIR"/SIZE.h.mpi"`
1406                if test $retv != 0 ; then
1407                    echo "input/eedata.mth tiling misfit -- skipping $dir"
1408                    continue
1409                fi
1410            fi
1411      fi      fi
     BUILD_DIR=$dir/$builddir  
1412    
1413      if test ! -r $CODE_DIR"/SIZE.h_mpi" -a "x$MPI" = "xt" ; then      #  Check whether there are "extra runs" for this testdir
1414          echo "can't find \"$CODE_DIR/SIZE.h_mpi\" -- skipping $dir"      extra_runs=
1415          continue      if test "x$NORUN" = xf ; then
1416            ex_run_dirs=`( cd $dir ; echo $inputdir.* )`
1417      fi      fi
1418        #echo "ex_run_dirs='$ex_run_dirs'"
1419        for exd in $ex_run_dirs ; do
1420            name=`echo $exd | sed -e "s/$inputdir\.//"`
1421            refExOut=`echo $ref_outp | sed "s/\./.${name}./"`
1422            outf="$dir/results/$refExOut"
1423            if test -f $outf -a -r $outf ; then
1424              if test "x$MULTI_THREAD" = "xt" ; then
1425                if test -r $dir"/"$exd"/eedata.mth" ; then
1426                  if test "x$MPI" = "x0" ; then
1427                    extra_runs="$extra_runs $name"
1428                  else
1429                    retv=`check_eedata $dir"/"$exd"/eedata.mth" $BUILD_DIR"/SIZE.h.mpi"`
1430                    if test $retv = 0 ; then
1431                        extra_runs="$extra_runs $name"
1432                    else
1433                        echo $exd"/eedata.mth tiling misfit -- skipping $dir"
1434                    fi
1435                  fi
1436                #else echo $dir"/"$exd"/eedata.mth: not found"
1437                fi
1438              else
1439                extra_runs="$extra_runs $name"
1440              fi
1441            fi
1442        done
1443    
     echo "-------------------------------------------------------------------------------"  
1444      echo      echo
1445      echo "Experiment:  $dir"      if test "x$extra_runs" = "x" ; then
1446           echo "Experiment:  $dir"
1447        else
1448           echo "Experiment:  $dir ; extra_runs=$extra_runs"
1449        fi
1450      echo      echo
1451      unset genmake makedepend make run      unset genmake makedepend make run
1452      results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --'      results=$EMPTY_RESULTS
1453    
1454      #  Create an output dir for each OPTFILE/tdir combination      #  Create an output dir & summary.txt file for each tested experiment (tdir)
1455      rel_CDIR=$DRESULTS"/"$dir      locDIR=$DRESULTS"/"$dir
1456      mkdir $rel_CDIR      mkdir $locDIR
1457      CDIR=`pwd`"/$rel_CDIR"      #- report to this experiment local summary file ---
1458            echo "DATE='$DATE' ; tdir='$dir'" > $locDIR"/summary.txt"
1459      if test "x$CLEANUP" = xt ; then      echo "MACH='$MACH'" >> $locDIR"/summary.txt"
1460          makeclean $dir/$builddir      echo "UNAMEA='$UNAMEA'" >> $locDIR"/summary.txt"
1461        CDIR=`pwd`"/$locDIR"
1462    
1463        if test "x$NORUN" = xt ; then
1464                run=N
1465            genmakemodel $dir/$builddir && genmake=Y \
1466                && makeclean $dir/$builddir \
1467                && symlink_mpifiles $dir $code_dir $builddir \
1468                && makedependmodel $dir/$builddir && makedepend=Y \
1469                && makemodel $dir/$builddir && make=Y
1470      else      else
1471          genmakemodel $dir/$builddir && genmake=Y \          genmakemodel $dir/$builddir && genmake=Y \
1472              && makeclean $dir/$builddir \              && makeclean $dir/$builddir \
1473              && symlink_mpifiles $dir $code_dir $builddir \              && symlink_mpifiles $dir $code_dir $builddir \
1474              && makedependmodel $dir/$builddir && makedepend=Y \              && makedependmodel $dir/$builddir && makedepend=Y \
1475              && makemodel $dir/$builddir && make=Y \              && makemodel $dir/$builddir && make=Y \
1476              && linkdata $use_seperate_build $dir/$rundir \              && run_clean $dir/$rundir \
1477                && linkdata $dir/$rundir $inputdir \
1478              && runmodel $dir/$rundir && run=Y \              && runmodel $dir/$rundir && run=Y \
1479              && results=`testoutput $dir $rundir`              && results=`testoutput_run $dir $rundir $ref_outp`
1480      fi      fi
1481            #echo "results='$results'"
1482      echo  
     if test "x$ADM" = x ; then  
1483          fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results`          fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results`
1484          echo          echo 1>&2
1485          echo "$fres" >> $SUMMARY          echo "$fres" | sed 's/ 99/ --/g' | sed 's/  > />/' | sed 's/  < /</' >> $SUMMARY
1486          echo "fresults='$fres'" > $CDIR"/summary.txt"          echo "fresults='$fres'" | sed 's/ 99/ --/g' >> $locDIR"/summary.txt"
         echo "MACH='$MACH'" >> $CDIR"/summary.txt"  
         echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"  
         echo "DATE='$DATE'" >> $CDIR"/summary.txt"  
         echo "tdir='$dir'" >> $CDIR"/summary.txt"  
1487    
1488          for ex in $extra_runs ; do          for ex in $extra_runs ; do
1489              unset run              unset run
1490              results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --'              results=$EMPTY_RESULTS
1491              #  Create an output dir for each OPTFILE/tdir.ex combination              #  reference output file
1492              rel_CDIR=$DRESULTS"/"$dir"."$ex              refExOut=`echo $ref_outp | sed "s/\./.${ex}./g"`
1493              mkdir $rel_CDIR              #  Create an output dir & summary.txt file for each extra run (tdir.ex)
1494              CDIR=`pwd`"/$rel_CDIR"              locDIR=$DRESULTS"/"$dir"."$ex
1495              test ! -e "$dir/tr_run.$ex" && mkdir "$dir/tr_run.$ex"              mkdir $locDIR
1496              for ldir in input.$ex input ; do              #- report to this experiment local summary file ---
1497                  (              echo "DATE='$DATE' ; tdir='$dir.$ex'" > $locDIR"/summary.txt"
1498                      cd "$dir/$ldir" > /dev/null 2>&1              #echo "MACH='$MACH'" >> $locDIR"/summary.txt"
1499                      ls -1 2>/dev/null \              #echo "UNAMEA='$UNAMEA'" >> $locDIR"/summary.txt"
1500                          | sed -e 's|^CVS$||g' | sed -e 's|^output.txt$||g'              CDIR=`pwd`"/$locDIR"
1501                  ) > tr_exrun_links              test ! -e "$dir/$pfxdir.$ex" && mkdir "$dir/$pfxdir.$ex"
1502                  (              run_clean $dir/$pfxdir.$ex
1503                      cd "$dir/tr_run.$ex"              linkdata $dir/$pfxdir.$ex $inputdir.$ex $inputdir
1504                      cat ../../tr_exrun_links | while read i ; do              runmodel $dir/$pfxdir.$ex && run=Y \
1505                          if test ! "x$i" = x ; then              && results=`testoutput_run $dir $pfxdir.$ex $refExOut`
                             test ! -r $i  &&  ln -s "../"$ldir"/"$i $i  
                         fi  
                     done  
                 )  
                 test -e tr_exrun_links  &&  rm -f tr_exrun_links  
             done  
             ldir=build  
             (  
                 cd $dir/tr_run.$ex  
                 test ! -e mitgcmuv  &&  ln -s "../"$ldir"/"mitgcmuv .  
             )  
             runmodel $dir/tr_run.$ex && run=Y \  
                 && results=`testoutput $dir tr_run.$ex "."$ex`  
             fres=`printf '%s %s %s %s' ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N}`  
1506              fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results`              fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results`
1507              fres="$fres.$ex"              fres="$fres.$ex"
1508              echo              echo 1>&2
1509              echo "$fres" >> $SUMMARY              echo "$fres" | sed 's/ 99/ --/g' | sed 's/  > />/' | sed 's/  < /</' >> $SUMMARY
1510              echo "fresults='$fres'" > $CDIR"/summary.txt"              echo "fresults='$fres'" | sed 's/ 99/ --/g' >> $locDIR"/summary.txt"
1511              echo "MACH='$MACH'" >> $CDIR"/summary.txt"              if test "x$POSTCLEAN" = x2 ; then
1512              echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"                  run_clean $dir/$pfxdir.$ex
1513              echo "DATE='$DATE'" >> $CDIR"/summary.txt"              fi
             echo "tdir='$dir.$ex'" >> $CDIR"/summary.txt"  
1514          done          done
1515      else  
1516          fres=`printf '%s %s %s %s' ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N}`      if test -f $DRESULTS"/"genmake_state ; then : ; else
1517          fres=$fres"$results   $dir"          if test -f $dir/$builddir/Makefile ; then
1518          echo              mkOpt=`grep '^# OPTFILE=' $dir/$builddir/Makefile 2>/dev/null | head -1 | sed 's/^# //'`
1519          echo "$fres" >> $SUMMARY              echo "from '$dir/$builddir/Makefile', extract:" > $DRESULTS/genmake_state
1520          echo "fresults='$fres'" > $CDIR"/summary.txt"              sed -n '/^# executed by:/,+1 p' $dir/$builddir/Makefile >> $DRESULTS/genmake_state
1521          echo "MACH='$MACH'" >> $CDIR"/summary.txt"              echo " $mkOpt" >> $DRESULTS/genmake_state
1522          echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"              if test "x$OPTFILE" = xNONE ; then
1523          echo "DATE='$DATE'" >> $CDIR"/summary.txt"                  eval $mkOpt
1524          echo "tdir='$dir'" >> $CDIR"/summary.txt"                  sed "/^No \"OPTFILE\" was specified ; genmake2/a\  OPTFILE=${OPTFILE}"\
1525          grep -A3 'Seconds in section "ALL' $dir/$rundir/$OUTPUTFILE \                          $SUMMARY > tr_0.tmp_log
1526                             >> $CDIR"/summary.txt"                  RETVAL=$?
1527                    if test "x$RETVAL" = x0 ; then rm -f $SUMMARY
1528                            cp tr_0.tmp_log $SUMMARY
1529                    else rm -f tr_0.tmp_log
1530                    fi
1531                fi
1532                gmkLog=$dir/$builddir/genmake.log
1533                grep '^Get compiler version using:' $gmkLog > /dev/null 2>&1
1534                RETVAL=$?
1535                if test "x$RETVAL" = x0 ; then
1536                    echo "from '$gmkLog', extract compiler version:" >> $DRESULTS/genmake_state
1537                    sed -n '/Get compiler version/,/<-- compiler version/p' $gmkLog \
1538                           | grep -v '^... compiler version ' > tr_1.tmp_log
1539                    sed -n '1,/^$/p' tr_1.tmp_log | sed '/^$/d' | sed 's/^./ &/' \
1540                            >> $DRESULTS/genmake_state
1541                    rm -f tr_1.tmp_log
1542                fi
1543            fi
1544        fi
1545        #postclean $dir/$builddir
1546        if test "x$POSTCLEAN" = x2 ; then
1547            makeclean $dir/$builddir \
1548                && run_clean $dir/$rundir
1549      fi      fi
1550        if test "x$MPI" != x0 -a "x$MPI_MFILE" != x ; then rm -f $LOC_MFILE ; fi
1551    
     postclean $dir/$builddir  
       
1552      echo "-------------------------------------------------------------------------------"      echo "-------------------------------------------------------------------------------"
1553        
1554  done  done
1555    
1556  printf "Start time:  " >> $SUMMARY  printf "Start time:  " >> $SUMMARY
1557  echo $start_date >> $SUMMARY  echo "$start_date" >> $SUMMARY
1558  printf "End time:    " >> $SUMMARY  printf "End time:    " >> $SUMMARY
1559  date >> $SUMMARY  date >> $SUMMARY
1560    
# Line 1124  else Line 1579  else
1579              echo "An email containing results was sent to the following addresses:"              echo "An email containing results was sent to the following addresses:"
1580              echo "  \"$ADDRESSES\""              echo "  \"$ADDRESSES\""
1581              echo              echo
1582                test -f $DRESULTS".tar"  &&  rm -f $DRESULTS".tar"
1583                test -f $DRESULTS".tar.gz"  &&  rm -f $DRESULTS".tar.gz"
1584          fi          fi
         test -f $DRESULTS".tar"  &&  rm -f $DRESULTS".tar"  
         test -f $DRESULTS".tar.gz"  &&  rm -f $DRESULTS".tar.gz"  
1585      fi      fi
1586  fi  fi
1587    
1588  # rm -f tmp_cmpnum.f a.out  if test "x$QUICK" = xf -a "x$NORUN" = xf ; then
1589  rm -f tmp_cmpnum.c tmp_cmpnum      rm -f tr_cmpnum.c tr_cmpnum
1590    fi
1591    
1592  if test "x$CLEANUP" != xt ; then  if test "x$CLEANUP" != xt ; then
1593      cat $SUMMARY | sed 's/ -- -- -- --//g'      cat $SUMMARY | sed 's/ \.  \.  \.  \.  \.  \.  \.  \.  \.  \.  \.  \. //'
1594      if test -e tr_out.txt ; then      if test -e tr_out.txt ; then
1595          mv tr_out.txt tr_out.txt.old          mv tr_out.txt tr_out.txt.old
1596      fi      fi
1597      cat $SUMMARY | sed 's/ -- -- -- --//g' > tr_out.txt      cat $SUMMARY | sed '/^[YN] [YN] [YN] [YN]/ s/ \. //g' > tr_out.txt
1598  fi  fi
1599    
1600  if test "x$DELDIR" = xt ; then  if test "x$DELDIR" = xt ; then

Legend:
Removed from v.1.77  
changed lines
  Added in v.1.164

  ViewVC Help
Powered by ViewVC 1.1.22