/[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.150 by jmc, Tue Dec 14 18:45:52 2010 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)                   compile and run using MPI"
16        echo "  (-ieee/-noieee)          if possible, use IEEE compiler flags"
17      echo "                             (DEF=\"-ieee\")"      echo "                             (DEF=\"-ieee\")"
18      echo "  (-optfile=|-of=)STRING   list of optfiles to use"      echo "  (-gsl)                   compile with \"-gsl\" flag"
19      echo "  (-a|-addr) STRING        list of email recipients"      echo "  (-use_r4|-ur4)           if allowed, use real*4 type for '_RS' variable"
20      echo "                             (DEF=\"edhill@mitgcm.org\")"      echo "  (-optfile|-of) STRING    list of optfiles to use"
21      echo "  (-t|-tdir) STRING        list of test dirs to use"      echo "  (-addr|-a) STRING        list of email recipients"
22      echo "                             (DEF=\"\" which builds all)"      echo "                             (DEF=\"\" no email is sent)"
23      echo "  (-b|-bash) STRING        preferred location of a \"bash\" or"      echo "  (-mpackdir|-mpd) DIR     location of the mpack utility"
24        echo "                             (DEF=\"../tools/mpack-1.6\")"
25        echo "  (-tdir|-t) STRING        list of group and/or exp. dirs to test"
26        echo "                             (recognized groups: basic, tutorials)"
27        echo "                             (DEF=\"\" which test all)"
28        echo "                             (if list= 'start_from THIS_EXP' then"
29        echo "                              test THIS_EXP + all the following)"
30        echo "  (-skipdir|-skd) STRING   list of exp. dirs to skip"
31        echo "                             (DEF=\"\" which test all)"
32        echo "  (-bash|-b) STRING        preferred location of a \"bash\" or"
33      echo "                             Bourne-compatible \"sh\" shell"      echo "                             Bourne-compatible \"sh\" shell"
34      echo "                             (DEF=\"\" for \"bash\")"      echo "                             (DEF=\"\" for \"bash\")"
35      echo "  (-adm|-ad)               perform an adjoint run"      echo "  (-adm|-ad)               perform an adjoint run"
36      echo "  (-command) STRING        command to run"      echo "  (-oad)                   perform an OpenAD adjoint run"
37      echo "                             (DEF=\"make output.txt\")"      echo "  (-command|-c) STRING     command to run"
38      echo "  (-m|-make) STRING        command to use for \"make\""      echo "  (-makedepend|-md) STRING command to use for \"makedepend\""
39        echo "  (-make|-m) STRING        command to use for \"make\""
40      echo "                             (DEF=\"make\")"      echo "                             (DEF=\"make\")"
41      echo "  (-odir) STRING           used to build output directory name"      echo "  (-odir) STRING           used to build output directory name"
42      echo "                             (DEF=\"hostname\")"      echo "                             (DEF=\"hostname\")"
43      echo "  (-ptracers|-ptr) STRING  specify which ptracers to test"      echo "  (-ptracers|-ptr) STRING  specify which ptracers to test"
44      echo "                             (DEF=\"1 2 3 4 5\")"      echo "                             (DEF=\"1 2 3 4 5\")"
45        echo "  (-match) NUMBER          Matching Criteria (number of digits)"
46        echo "                             (DEF=\"$MATCH_CRIT\")"
47      echo "  (-j) JOBS                use \"make -j JOBS\" for parallel builds"      echo "  (-j) JOBS                use \"make -j JOBS\" for parallel builds"
48      echo "  (-clean)                 *ONLY* run \"make CLEAN\""      echo "  (-clean)                 *ONLY* run \"make CLEAN\""
49        echo "  (-norun|-nr)             skip the \"runmodel\" stage (stop after make)"
50        echo "  (-runonly|-ro)           *ONLY* run stage (=\"-quick\" without make)"
51      echo "  (-quick|-q)              same as \"-nogenmake -noclean -nodepend\""      echo "  (-quick|-q)              same as \"-nogenmake -noclean -nodepend\""
52      echo "  (-nogenmake|-ng)         skip the genmake stage"      echo "  (-nogenmake|-ng)         skip the genmake stage"
53      echo "  (-noclean|-nc)           skip the \"make clean\" stage"      echo "  (-noclean|-nc)           skip the \"make clean\" stage"
54      echo "  (-nodepend|-nd)          skip the \"make depend\" stage"      echo "  (-nodepend|-nd)          skip the \"make depend\" stage"
55      echo "  (-deldir|-dd)            on success, delete the output directory"      echo "  (-deldir|-dd)            on success, delete the output directory"
56        echo "  (-ts)                    provide timing information per timestep"
57        echo "  (-papis)                 provide MFlop/s per timestep using PAPI"
58        echo "  (-pcls)                  provide MFlop/s per timestep using PCL"
59      echo      echo
60      echo "and where STRING can be a whitespace-delimited list"      echo "and where STRING can be a whitespace-delimited list"
61      echo "such as:"      echo "such as:"
# Line 55  usage() Line 73  usage()
73  build_mpack()  build_mpack()
74  {  {
75      printf "building the mpack utility...  "      printf "building the mpack utility...  "
76      if test ! -x "$MPACKDIR/mpack" ; then      MPACK="$MPACKDIR/mpack"
77        if test ! -x $MPACK ; then
78          if test ! -d $MPACKDIR ; then          if test ! -d $MPACKDIR ; then
79              echo              echo
80              echo "Error: can't find \"$MPACKDIR\""              echo "Error: can't find \"$MPACKDIR\""
# Line 64  build_mpack() Line 83  build_mpack()
83              echo              echo
84              HAVE_MPACK=f              HAVE_MPACK=f
85          fi          fi
         printf "building mpack...  "  
86          if test "x$CC" = x ; then          if test "x$CC" = x ; then
87              export CC=cc              export CC=cc
88          fi          fi
89            printf "building mpack (using CC=$CC)...  "
90          ( cd $MPACKDIR && ./configure && $MAKE ) > tr_build_mpack.out 2>&1          ( cd $MPACKDIR && ./configure && $MAKE ) > tr_build_mpack.out 2>&1
91          RETVAL=$?          RETVAL=$?
92          if test "x$RETVAL" != x0 ; then          if test "x$RETVAL" != x0 ; then
# Line 78  build_mpack() Line 97  build_mpack()
97          else          else
98              rm -f tr_build_mpack.out              rm -f tr_build_mpack.out
99              HAVE_MPACK=t              HAVE_MPACK=t
100                echo "done"
101          fi          fi
102      else      else
103          HAVE_MPACK=t          HAVE_MPACK=t
104            echo "already exist"
105      fi      fi
     echo "OK"  
106  }  }
107    
108  testoutput_for_prop()  testoutput_var()
109  {  {
110      # testoutput_for_prop dir s1 label subdir extension      # testoutput_var dir s1 label subdir reference_output
111      #      #
112      #  compares files in $dir/$subdir/output.txt and $dir/results/output.txt      #  compares 1 variable output selected from file $dir/$subdir/$OUTPUTFILE
113      #  using search strings s1 and text label      #     with same output from reference file $dir/results/$reference_output
114        #  using search strings s1 and text label
115    
116      if [ $debug -gt 0 ]; then      if [ $debug -gt 0 ]; then
117          echo testoutput_for_prop: grep "$2" $1/$4/output.txt 1>&2          echo testoutput_var: grep "$2" $1/$4/$OUTPUTFILE 1>&2
118      fi      fi
119      if [ -r $1/$4/output.txt ]; then      if [ -r $1/$4/$OUTPUTFILE ]; then
120          grep "$2" $1/$4/output.txt | sed 's/.*=//' | cat -n > tmp1.txt          grep "$2" $1/$4/$OUTPUTFILE | sed 's/.*=//' | cat -n > tmp1.txt
121          lncntA=`wc -l tmp1.txt | awk '{print $1}' `          lncntA=`wc -l tmp1.txt | awk '{print $1}' `
122          if [ $lncntA -lt 3 ]; then          if [ $lncntA -lt 2 ]; then
123              if [ $verbose -gt 0 ]; then              if [ $verbose -gt 0 ]; then
124                  echo Not enough lines of output when searching for "$2" 1>&2                  echo Not enough lines of output when searching for "$2" 1>&2
125              fi              fi
126              return 99              return 99
127          fi          fi
128      else      else
129          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
130          return 99          return 99
131      fi      fi
132      if [ $debug -gt 0 ]; then      if [ $debug -gt 0 ]; then
133          echo testoutput_for_prop: grep "$2" $1/results/output.txt$5 1>&2          echo testoutput_var: grep "$2" $1/results/$5 1>&2
134      fi      fi
135      grep "$2" $1/results/output.txt$5 | sed 's/.*=//' | cat -n > tmp2.txt      grep "$2" $1/results/$5 | sed 's/.*=//' | cat -n > tmp2.txt
136      lncntB=`wc -l tmp2.txt | awk '{print $1}' `      lncntB=`wc -l tmp2.txt | awk '{print $1}' `
137      if [ $lncntB -lt 3 ]; then      if [ $lncntB -lt 2 ]; then
138          if [ $verbose -gt 0 ]; then          if [ $verbose -gt 0 ]; then
139              echo Not enough lines of output when searching for "$2" 1>&2              echo Not enough lines of output when searching for "$2" 1>&2
140          fi          fi
# Line 127  testoutput_for_prop() Line 148  testoutput_for_prop()
148      fi      fi
149      has_nan=`cat tmp1.txt | grep -i nan | wc -l`      has_nan=`cat tmp1.txt | grep -i nan | wc -l`
150      if [ $has_nan -gt 0  ] ; then      if [ $has_nan -gt 0  ] ; then
151          echo testoutput_for_prop: output.txt contains $has_nan NaN values  1>&2          echo testoutput_var: $OUTPUTFILE contains $has_nan NaN values  1>&2
152          return 99          return 99
153      fi      fi
154      has_inf=`cat tmp1.txt | grep -i inf | wc -l`      has_inf=`cat tmp1.txt | grep -i inf | wc -l`
155      if [ $has_inf -gt 0  ] ; then      if [ $has_inf -gt 0  ] ; then
156          echo testoutput_for_prop: output.txt contains $has_inf Inf values  1>&2          echo testoutput_var: $OUTPUTFILE contains $has_inf Inf values  1>&2
157          return 99          return 99
158      fi      fi
159      if [ $debug -gt 0 ]; then      if [ $debug -gt 0 ]; then
160          echo testoutput_for_prop: join tmp1.txt tmp2.txt 1>&2          echo testoutput_var: join tmp1.txt tmp2.txt 1>&2
161      fi      fi
162      join tmp1.txt tmp2.txt | awk '{print $1 " " $2 " " $3}' > tmp3.txt      join tmp1.txt tmp2.txt | awk '{print $1 " " $2 " " $3}' > tmp3.txt
163      if [ $debug -gt 0 ]; then      if [ $debug -gt 0 ]; then
164          echo testoutput_for_prop: compare_lines 1>&2          echo testoutput_var: compare_lines 1>&2
165      fi      fi
166      if [ $verbose -gt 1 ]; then      if [ $verbose -gt 1 ]; then
167          cat tmp3.txt 1>&2          cat tmp3.txt 1>&2
# Line 148  testoutput_for_prop() Line 169  testoutput_for_prop()
169      echo "-1" >> tmp3.txt      echo "-1" >> tmp3.txt
170      # 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
171      cat tmp3.txt | sed -e 's|:||g' > tmp4.txt      cat tmp3.txt | sed -e 's|:||g' > tmp4.txt
172      digits_of_similarity=`./tmp_cmpnum < tmp4.txt`      digits_of_similarity=`./tr_cmpnum < tmp4.txt`
173      if [ $digits_of_similarity -eq 99 ]; then      if [ $digits_of_similarity -eq 99 ]; then
174          if [ $verbose -gt 0 ]; then          if [ $verbose -gt 0 ]; then
175              echo testoutput_for_prop: No comparison was available for \"$2\" 1>&2              echo testoutput_var: No comparison was available for \"$3\" 1>&2
176          fi          fi
177          digits_of_similarity=99          digits_of_similarity=99
178      else      else
179          if [ $verbose -gt 0 ]; then          if [ $verbose -gt 0 ]; then
180              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
181          fi          fi
182      fi      fi
183      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  
   
     for num in $@ ; do  
         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  
 }  
184    
185  check_for_add_mon_output()      return $digits_of_similarity
 {  
     # 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  
186  }  }
187    
188  testoutput()  testoutput_run()
189  {  {
190      # testoutput directory subdir extension      # testoutput_run directory subdir reference_output
191      #      #
192      #  test output in "directory"      #  test output from 1 run in "directory"
193      if test "x$ADM" = x ; then  # --> same processing for adjoint & forward test
194          if [ $debug -gt 0 ]; then          # default list of output variables to be checked:
195              echo testoutput: testoutput_for_prop $1 cg2d_init_res 1>&2          #  1rst : main variable used to decide if it pass or FAIL
196          fi          #  others : number of matching digits to be printed in summary.txt
197          testoutput_for_prop $1 "cg2d_init_res" "cg2d init. residual" $2 $3; cg2dres=$?          listChk=$DEF_CHECK_LIST
198          if [ $debug -gt 0 ]; then          #  load experiment-specific list from file "tr_checklist" (if it exist)
199              echo testoutput: cg2dres=$cg2dres 1>&2          if test -r $1/$2/tr_checklist ; then listChk=`cat $1/$2/tr_checklist` ; fi
200          fi          sVar=`echo $listChk | awk '{print $1}'`
201          testoutput_for_prop $1 "dynstat_theta_min" "theta minimum" $2 $3; tmin=$?          # remove 1rst var and expand the list: + => min max mean s.d
202          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' \
203          testoutput_for_prop $1 "dynstat_theta_mean" "theta mean" $2 $3; tmean=$?                                 | sed 's/+//g' | sed "s/^$sVar//"`
204          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
205          testoutput_for_prop $1 "dynstat_salt_min" "salt minimum" $2 $3; smin=$?          # check for ptracer output in reference_output file :
206          testoutput_for_prop $1 "dynstat_salt_max" "salt maximum" $2 $3; smax=$?          outpref=$1/results/$3
207          testoutput_for_prop $1 "dynstat_salt_mean" "salt mean" $2 $3; smean=$?          ptr_mon="trcstat_ptracerXX_min trcstat_ptracerXX_max"
208          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  
209          for ii in $PTRACERS_NUM ; do          for ii in $PTRACERS_NUM ; do
210              eval `echo "p0"$ii"_min=99"`              ptrfound=0
211              eval `echo "p0"$ii"_max=99"`              for jj in $ptr_mon ; do
212              eval `echo "p0"$ii"_mean=99"`                  name=`eval "echo $jj | sed -e 's|XX|0"$ii"|g'"`
213              eval `echo "p0"$ii"_sd=99"`                  tst=`grep $name $outpref | wc -l | awk '{print $1}'`
214              tst=`eval 'echo "$HAVE_PTR0'$ii'"'`                  if test ! "x$tst" = x0 ; then ptrfound=1 ; fi
215              #echo 'tst = '$tst              done
216              if test "x$tst" = xt ; then              if test $ptrfound = '1' ; then
217                  a="trcstat_ptracer0"                  eval "HAVE_PTR0"$ii"=t"
218                  testoutput_for_prop $1 "$a"$ii"_min"  "p0"$ii"_min"  $2 $3              else
219                  RETVAL=$? ; eval `echo "p0"$ii"_min="$RETVAL`                  eval "HAVE_PTR0"$ii"=f"
220                  testoutput_for_prop $1 "$a"$ii"_max"  "p0"$ii"_max"  $2 $3                if test "x$ADM" = x -a "x$OADM" = x; then
221                  RETVAL=$? ; eval `echo "p0"$ii"_max="$RETVAL`                # remove this ptr from the list of output variable to check
222                  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
223                  RETVAL=$? ; eval `echo "p0"$ii"_mean="$RETVAL`                  listVar=`echo "$listVar" | sed "s/ pt$ii..//g"`
224                  testoutput_for_prop $1 "$a"$ii"_sd"   "p0"$ii"_sd"   $2 $3                fi
                 RETVAL=$? ; eval `echo "p0"$ii"_sd="$RETVAL`  
225              fi              fi
226            #   eval 'echo "HAVE_PTR0'$ii' = $HAVE_PTR0'$ii'"' 1>&2
227          done          done
228            tst=`echo $sVar $listVar | awk '{ for(i=2;i<=NF;i++){if($i==$1)t+=1}; print t }'`
229          allargs="$cg2dres $tmin $tmax $tmean $tsd $smin $smax $smean $ssd"          if test $tst != 1 ; then
230          allargs="$allargs $umin $umax $umean $usd $vmin $vmax $vmean $vsd"            if test $tst = 0 ; then echo "==> WARNING: selected var >$sVar< not found" 1>&2
231          allargs="$allargs $p01_min $p01_max $p01_mean $p01_sd"                   else echo "==> WARNING: found selected var >$sVar< $tst times" 1>&2 ; fi
232          allargs="$allargs $p02_min $p02_max $p02_mean $p02_sd"            echo "==> WARNING: in checked list:" $listVar 1>&2
233          allargs="$allargs $p03_min $p03_max $p03_mean $p03_sd"          #- put it back once:
234          allargs="$allargs $p04_min $p04_max $p04_mean $p04_sd"            listVar=" $sVar "`echo "$listVar " | sed "s/ $sVar / /g"`
235          allargs="$allargs $p05_min $p05_max $p05_mean $p05_sd"          fi
236            if [ $debug -gt 0 ]; then echo "testoutput_run: listVar(M)='$listVar'" 1>&2 ; fi
237          eval "dashnum $allargs"          echo "listVar='$listVar'" > $locDIR"/summary.txt"
238            allargs=""
239      else          for xx in $listVar
240          testoutput_ad $1 $2 "precision_grdchk_result"          do
241      fi            case $xx in
242               'PS')  if [ $debug -gt 0 ]
243                      then echo testoutput_run: testoutput_var $1 cg2d_init_res 1>&2 ; fi
244                      testoutput_var $1 "cg2d_init_res" "Press. Solver (cg2d)" $2 $3; yy=$?
245                      if [ $debug -gt 0 ] ; then echo testoutput_run: cg2dres=$yy 1>&2 ; fi ;;
246              'Cost') testoutput_var $1 "ADM  precision_derivative_cost" "ADM Cost" $2 $3; yy=$? ;;
247              'Grad') testoutput_var $1 "ADM  precision_derivative_grad" "ADM Grad" $2 $3; yy=$? ;;
248               'Tmn') testoutput_var $1 "dynstat_theta_min"  "Theta minimum"  $2 $3; yy=$? ;;
249               'Tmx') testoutput_var $1 "dynstat_theta_max"  "Theta maximum"  $2 $3; yy=$? ;;
250               'Tav') testoutput_var $1 "dynstat_theta_mean" "Theta mean"     $2 $3; yy=$? ;;
251               'Tsd') testoutput_var $1 "dynstat_theta_sd"   "Theta Std.Dev"  $2 $3; yy=$? ;;
252               'Smn') testoutput_var $1 "dynstat_salt_min"  "Salt minimum"    $2 $3; yy=$? ;;
253               'Smx') testoutput_var $1 "dynstat_salt_max"  "Salt maximum"    $2 $3; yy=$? ;;
254               'Sav') testoutput_var $1 "dynstat_salt_mean" "Salt mean"       $2 $3; yy=$? ;;
255               'Ssd') testoutput_var $1 "dynstat_salt_sd"   "Salt Std.Dev"    $2 $3; yy=$? ;;
256               'Umn') testoutput_var $1 "dynstat_uvel_min"  "U minimum"       $2 $3; yy=$? ;;
257               'Umx') testoutput_var $1 "dynstat_uvel_max"  "U maximum"       $2 $3; yy=$? ;;
258               'Uav') testoutput_var $1 "dynstat_uvel_mean" "U mean"          $2 $3; yy=$? ;;
259               'Usd') testoutput_var $1 "dynstat_uvel_sd"   "U Std.Dev"       $2 $3; yy=$? ;;
260               'Vmn') testoutput_var $1 "dynstat_vvel_min"  "V minimum"       $2 $3; yy=$? ;;
261               'Vmx') testoutput_var $1 "dynstat_vvel_max"  "V maximum"       $2 $3; yy=$? ;;
262               'Vav') testoutput_var $1 "dynstat_vvel_mean" "V mean"          $2 $3; yy=$? ;;
263               'Vsd') testoutput_var $1 "dynstat_vvel_sd"   "V Std.Dev"       $2 $3; yy=$? ;;
264            'pt1mn'|'pt2mn'|'pt3mn'|'pt4mn'|'pt5mn') ii=`echo $xx | sed 's/pt//' | sed 's/..$//'`
265               testoutput_var $1 "trcstat_ptracer0"$ii"_min"  "p0"$ii"_min"   $2 $3; yy=$? ;;
266            'pt1mx'|'pt2mx'|'pt3mx'|'pt4mx'|'pt5mx') ii=`echo $xx | sed 's/pt//' | sed 's/..$//'`
267               testoutput_var $1 "trcstat_ptracer0"$ii"_max"  "p0"$ii"_max"   $2 $3; yy=$? ;;
268            'pt1av'|'pt2av'|'pt3av'|'pt4av'|'pt5av') ii=`echo $xx | sed 's/pt//' | sed 's/..$//'`
269               testoutput_var $1 "trcstat_ptracer0"$ii"_mean" "p0"$ii"_mean" $2 $3; yy=$? ;;
270            'pt1sd'|'pt2sd'|'pt3sd'|'pt4sd'|'pt5sd') ii=`echo $xx | sed 's/pt//' | sed 's/..$//'`
271               testoutput_var $1 "trcstat_ptracer0"$ii"_sd"   "p0"$ii"_StDv"  $2 $3; yy=$? ;;
272             'Qntmn') testoutput_var $1 "forcing_qnet_min" "Qnet minimum"  $2 $3; yy=$? ;;
273             'Qntmx') testoutput_var $1 "forcing_qnet_max" "Qnet maximum"  $2 $3; yy=$? ;;
274             'Qntav') testoutput_var $1 "forcing_qnet_mean" "Qnet mean"       $2 $3; yy=$? ;;
275             'Qntsd') testoutput_var $1 "forcing_qnet_sd"  "Qnet Std.Dev"  $2 $3; yy=$? ;;
276             'aSImn') testoutput_var $1 "seaice_area_min"   "SIce Area min"   $2 $3; yy=$? ;;
277             'aSImx') testoutput_var $1 "seaice_area_max"   "SIce Area max"   $2 $3; yy=$? ;;
278             'aSIav') testoutput_var $1 "seaice_area_mean"  "SIce Area mean"  $2 $3; yy=$? ;;
279             'aSIsd') testoutput_var $1 "seaice_area_sd"    "SIce Area StDv"  $2 $3; yy=$? ;;
280             'hSImn') testoutput_var $1 "seaice_heff_min"   "SIce Heff min"   $2 $3; yy=$? ;;
281             'hSImx') testoutput_var $1 "seaice_heff_max"   "SIce Heff max"   $2 $3; yy=$? ;;
282             'hSIav') testoutput_var $1 "seaice_heff_mean"  "SIce Heff mean"  $2 $3; yy=$? ;;
283             'hSIsd') testoutput_var $1 "seaice_heff_sd"    "SIce Heff StDv"  $2 $3; yy=$? ;;
284            'AthSiG') testoutput_var $1 "thSI_Ice_Area_G" "thSIc Area Global" $2 $3; yy=$? ;;
285            'AthSiS') testoutput_var $1 "thSI_Ice_Area_S" "thSIc Area South"  $2 $3; yy=$? ;;
286            'AthSiN') testoutput_var $1 "thSI_Ice_Area_N" "thSIc Area North"  $2 $3; yy=$? ;;
287            'HthSiG') testoutput_var $1 "thSI_IceH_ave_G" "thSIc H Global"    $2 $3; yy=$? ;;
288            'HthSiS') testoutput_var $1 "thSI_IceH_ave_S" "thSIc H South"     $2 $3; yy=$? ;;
289            'HthSiN') testoutput_var $1 "thSI_IceH_ave_N" "thSIc H North"     $2 $3; yy=$? ;;
290                  *) yy=99; echo "WARNING: asking for var=$xx : not recognized !" 1>&2 ;;
291              esac
292              if test $xx = $sVar
293              then allargs="$allargs > $yy <"
294              else allargs="$allargs $yy"
295              fi
296            done
297    
298            nbVar=`echo $listVar | awk '{print NF}'`
299            if [ $nbVar -lt $LEN_CHECK_LIST ] ; then
300            #-- fill line (up to standard length) with dot:
301              adNul=`expr $LEN_CHECK_LIST - $nbVar | awk '{for(i=1;i<=$1;i++){print "."}}'`
302              echo $allargs $adNul
303            else
304              echo $allargs
305            fi
306    # <-- same processing for adjoint & forward test
307  }  }
308    
309  genmakemodel()  genmakemodel()
# Line 300  genmakemodel() Line 320  genmakemodel()
320          (          (
321              cd $1;              cd $1;
322              command="$GENMAKE2  -ds -m $MAKE"              command="$GENMAKE2  -ds -m $MAKE"
323              if test "x$ADM" = x ; then              if test "x$MKDEPEND" != x ; then
324                  command="$command --mods=../code"                  command="$command -makedepend=$MKDEPEND"
325              else              fi
326                if test "x$ADM" = xt ; then
327                  command="$command --mods=../code_ad"                  command="$command --mods=../code_ad"
328                  command="$command -adof=../../../tools/adjoint_options/adjoint_staf"              elif test "x$OADM" = xt ; then
329                    command="$command -adof ../../../tools/adjoint_options/adjoint_oad -mods '../code_oad ../../OpenAD/code_oad_all'"
330                else
331                    command="$command -mods=../code"
332              fi              fi
333              if test "x$OPTFILE" != xNONE ; then              if test "x$OPTFILE" != xNONE ; then
334                  command="$command --optfile=$OPTFILE"                  command="$command -optfile=$OPTFILE"
335              fi              fi
336              if test "x$IEEE" != x ; then              if test "x$IEEE" != x ; then
337                  command="$command -ieee"                  command="$command -ieee"
338              fi              fi
339                if test "x$GSL" = xt ; then
340                    command="$command -gsl"
341                fi
342              if test "x$MPI" = xt ; then              if test "x$MPI" = xt ; then
343                  command="$command -mpi"                  command="$command -mpi"
344              fi              fi
345              printf 'genmake ... ' 1>&2              if test "x$MULTI_THREAD" = xt ; then
346              $command > make.log 2>&1              #- run multi-threaded using OpenMP:
347                    command="$command -omp"
348                fi
349                if test "x$USE_R4" = xt ; then
350                    command="$command -use_r4"
351                fi
352                if test "x$TS" = xt ; then
353                    command="$command -ts"
354                fi
355                if test "x$PAPIS" = xt ; then
356                    command="$command -papis"
357                else
358                if test "x$PCLS" = xt ; then
359                    command="$command -pcls"
360                fi
361                fi
362                printf 'genmake ... '
363                eval $command > genmake.tr_log 2>&1
364              RETVAL=$?              RETVAL=$?
365              #  Reduce the size of the testing emails!              #  Reduce the size of the testing emails!
366              head -100 Makefile > $CDIR/Makefile_head              head -100 Makefile > $CDIR/Makefile_head
367              if test "x$RETVAL" != x0 ; then              if test "x$RETVAL" != x0 ; then
368                  tail make.log                  tail genmake.tr_log
369                  echo "genmakemodel: genmake failed" 1>&2                  echo "genmakemodel: genmake failed"
370                  cp genmake_* make.log $CDIR                  cp genmake.log genmake_* genmake.tr_log $CDIR
371                  return 1                  return 1
372              else              else
373                  echo "successful" 1>&2                  echo "successful"
374              fi              fi
375          )          )
376      fi      fi
# Line 335  genmakemodel() Line 379  genmakemodel()
379  makeclean()  makeclean()
380  {  {
381      # makeclean directory      # makeclean directory
382        if test "x$NODEPEND" = xf ; then rm -f $1/make.tr_log ; fi
383      if test "x$NOCLEAN" = xt ; then      if test "x$NOCLEAN" = xt ; then
384          echo "make CLEAN skipped!"          echo "make Clean skipped!"
385      else      else
386          (          (
387              cd $1;              cd $1;
388              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  
389              if test -r Makefile ; then              if test -r Makefile ; then
390                  $MAKE CLEAN >> make.log 2>&1                  printf 'clean build-dir: make Clean ... '
391                    rm -f Makefile.old
392                    $MAKE Clean >> make.tr_log 2>&1
393                  RETVAL=$?                  RETVAL=$?
394                  if test "x$RETVAL" != x0 ; then                  if test "x$RETVAL" != x0 ; then
395                      tail make.log                      tail make.tr_log
396                      echo "makeclean: \"make CLEAN\" failed" 1>&2                      echo "makeclean: \"make Clean\" failed"
397                      cp make.log $CDIR"/make.log"                      cp make.tr_log genmake.log genmake.tr_log $CDIR
398                      return 1                      return 1
399                  fi                  fi
400                    echo successful
401                else
402                    echo ''
403              fi              fi
             echo successful 1>&2  
404              exit 0              exit 0
405          )          )
406      fi      fi
407  }  }
408    
409  postclean()  run_clean()
410  {  {
411      # postclean directory      # run_clean directory
412      if test "x$POSTCLEAN" = xt ; then      if test "x$NOCLEAN" = xt ; then
413            echo "run_clean skipped!"
414        else
415          (          (
416              cd $1;              cd $1;
417              if test -r Makefile ; then              printf 'clean run-dir ... '
418                  $MAKE CLEAN >> /dev/null 2>&1              # part of what is done after "make clean" when doing "make CLEAN"
419              fi              find . -name "*.meta" -exec rm {} \;
420                find . -name "*.data" -exec rm {} \;
421                find . -name "fort.*" -exec rm {} \;
422                find . -type l -exec rm {} \;
423                rm -f $EXECUTABLE $RUNLOG *.txt STD* *diagnostics.log datetime
424                rm -rf mnc_test_*
425                rm -f *_MIT_CE_000.opt0000 costfunction*0000
426                echo successful
427              exit 0              exit 0
428          )          )
429      fi      fi
# Line 382  makedependmodel() Line 437  makedependmodel()
437      else      else
438          (          (
439              cd $1;              cd $1;
440              printf 'make depend ... ' 1>&2              printf 'make depend ... '
441              $MAKE depend >> make.log 2>&1              $MAKE depend >> make.tr_log 2>&1
442              RETVAL=$?              RETVAL=$?
443              if test "x$RETVAL" != x0 ; then              if test "x$RETVAL" != x0 ; then
444                  tail make.log                  tail make.tr_log
445                  echo "makedependmodel: make depend failed" 1>&2                  echo "makedependmodel: make depend failed"
446                  cp make.log $CDIR"/make.log"                  cp make.tr_log genmake.log genmake.tr_log $CDIR
447                  return 1                  return 1
448              else              else
449                  echo successful 1>&2                  echo successful
450              fi              fi
451          )          )
452      fi      fi
# Line 401  makemodel() Line 456  makemodel()
456  {  {
457      # makemodel directory      # makemodel directory
458      (      (
459        if test "x$NOMAKE" = xt ; then
460            cd $1;
461            if test -x $EXECUTABLE ; then
462                echo "make skipped!"
463            else
464                echo "no executable!"
465                return 2
466            fi
467        else
468          cd $1;          cd $1;
469          if test -r Makefile ; then          if test -r Makefile ; then
470              printf 'make ... ' 1>&2              printf 'make ... '
471              if test "x$ADM" = x ; then              if test "x$ADM" = xt ; then
472                    $MAKE adall >> make.tr_log 2>&1
473                elif test "x$OADM" = xt ; then
474                    $MAKE adAll >> make.tr_log 2>&1
475                else
476                  if test "x$JOBS" = x ; then                  if test "x$JOBS" = x ; then
477                      $MAKE >> make.log 2>&1                      $MAKE >> make.tr_log 2>&1
478                  else                  else
479                      $MAKE -j $JOBS >> make.log 2>&1                      $MAKE -j $JOBS >> make.tr_log 2>&1
480                  fi                  fi
             else  
                 $MAKE adall >> make.log 2>&1  
481              fi              fi
482              RETVAL=$?              RETVAL=$?
483              if test "x$RETVAL" != x0 ; then              if test "x$RETVAL" != x0 ; then
484                  tail make.log                  tail make.tr_log
485                  echo failed 1>&2                  echo failed
486                  cp make.log $CDIR"/make.log"                  cp make.tr_log genmake.log genmake.tr_log $CDIR
487                    rm -f $EXECUTABLE
488                  return 1                  return 1
489              else              else
490                  echo successful 1>&2                  echo successful
491              fi              fi
492          fi          fi
493        fi
494      )      )
495  }  }
496    
# Line 436  symlink_mpifiles() Line 504  symlink_mpifiles()
504      code_dir=$2      code_dir=$2
505      BUILD_DIR=$dir/$3      BUILD_DIR=$dir/$3
506      CODE_DIR=$dir/$code_dir      CODE_DIR=$dir/$code_dir
507        
508      # These are files that should replace their counter-part when using -mpi      # These are files that should replace their counter-part when using -mpi
509      MPI_FILES=`(cd $CODE_DIR; find . -name "*_mpi")`      MPI_FILES=`(cd $CODE_DIR; find . -name "*_mpi" -print)`
510    
511      #  Is this an MPI run?      #  Is this an MPI run?
512      if test "x$MPI" = xt ; then      if test "x$MPI" = xt ; then
# Line 471  symlink_mpifiles() Line 539  symlink_mpifiles()
539              fi              fi
540          done          done
541      fi      fi
542        
543  }  }
544    
545  linkdata()  linkdata()
546  {  {
547      # linkdata flag      # linkdata run_dir input_dir_1 input_dir_2 ...
548      #      #
549      # symbolically link data files to run directory      # symbolically link data files to run directory
550      if test "x$1" = x1 ; then      if test -d $1 ; then
551          (          (
552              cd $2              cd $1 ; shift
553              if test "x$ADM" = x ; then              echo 'linkdata from dirs:' $*
554                  files=`( cd ../input ; ls -1 | grep -v CVS )`              inpMPI=`(cd ../$1 ; find . -name "*.mpi" -print | sed 's:^\./::')`
555                  for i in $files ; do              for xx in $inpMPI ; do
556                      if test ! -d "../input/"$i -a ! -f $i ; then                if test -r "../"$1"/"$xx ; then
557                          ln -sf "../input/"$i $i                  # found 1 _mpi sfx file in 1rst input dir and it is readable
558                      fi                  yy=`echo $xx | sed 's:\.mpi$::'`
559                  done                  if test "x$MPI" = "xt" ; then
560              else                  # mpi test: remove symbolic link & link _mpi sfx file
561                  files=`( cd ../input ; ls -1 *.bin | grep -v CVS )`                      if test -h $yy ; then rm -f $yy ; fi
562                  for i in $files ; do                      if test ! -r $yy ; then
563                      if test ! -d "../input/"$i ; then                          ln -sf "../"$1"/"$xx $yy ;
564                          ln -sf "../input/"$i $i                          printf " $xx" 1>&2
565                      fi                      fi
566                  done                  else
567                  files=`( cd ../input_ad ; ls -1 | grep -v CVS )`                  # not mpi test: remove symbolic link
568                  for i in $files ; do                      if test -h $yy ; then rm -f $yy ; fi
569                      if test ! -d "../input_ad/"$i ; then                  fi
570                          ln -sf "../input_ad/"$i $i                fi
571                done
572                if test -r "../"$1"/eedata.mth" ; then
573                # found eedata.mth in 1rst input dir and it is readable
574                    if test "x$MULTI_THREAD" = "xt" ; then
575                    # multi-threaded test: remove symbolic link & link eedata.mth
576                        if test -h eedata ; then rm -f eedata ; fi
577                        if test ! -r eedata ; then
578                            ln -sf "../"$1"/eedata.mth" eedata ;
579                            printf ' eedata.mth' 1>&2
580                      fi                      fi
581                  done                  else
582                    # not multi-threaded test: remove eedata symbolic link
583                        if test -h eedata ; then rm -f eedata ; fi
584                    fi
585              fi              fi
586                prevDir='NONE'
587                for ldir in $* ; do
588                    if test -d "../"$ldir -a $ldir != $prevDir ; then
589                        printf " ldir=${ldir}:" 1>&2
590                        files=`( cd "../"$ldir ; ls -1 | grep -v CVS )`
591                        for i in $files ; do
592                            if test ! -d "../"$ldir/$i ; then
593                                if test ! -r $i  ; then
594                                    printf ' '$i 1>&2
595                                    ln -sf "../"$ldir"/"$i $i
596                                fi
597                            fi
598                        done
599                        printf ' ;' 1>&2
600                        if test -x "../"$ldir"/"prepare_run ; then
601                            "../"$ldir"/"prepare_run 1>&2
602                        else
603                            echo '' 1>&2
604                        fi
605                    fi
606                    prevDir=$ldir
607                done
608          )          )
609      fi      fi
610  }  }
# Line 511  runmodel() Line 613  runmodel()
613  {  {
614      # runmodel directory      # runmodel directory
615      #      #
616      #  runs "$COMMAND in "directory"      #  runs "$COMMAND in "directory"
617      #  (where "$COMMAND" is relative to "directory")      #  (where "$COMMAND" is relative to "directory")
618      (      (
619          cd $1          cd $1
620          printf 'runmodel in %s ...' $1 1>&2          printf 'runmodel in %s ... ' $1
621          # make output.txt          if test -L $EXECUTABLE ; then
622          echo            if test -x "../"$builddir"/"$EXECUTABLE ; then
623          rm -f run.log              diff -q $EXECUTABLE "../"$builddir"/"$EXECUTABLE > /dev/null 2>&1
624          if test $OUTPUTFILE -ot $EXECUTABLE ; then              outD=$? ; if test $outD != 0 ; then rm -f $EXECUTABLE ; fi
625             ( eval $COMMAND ) > run.log 2>&1            else rm -f $EXECUTABLE
626             RETVAL=$?            fi
627            fi
628            if test ! -x $EXECUTABLE -a -x "../"$builddir"/"$EXECUTABLE ; then
629                echo " link" $EXECUTABLE "from dir ../"$builddir > run.log_tmp
630                ln -sf "../"$builddir"/"$EXECUTABLE .
631            fi
632            if test ! -x $EXECUTABLE ; then
633                    rm -f $RUNLOG ; touch $RUNLOG
634                    if test -f run.log_tmp ; then cat run.log_tmp >> $RUNLOG ; fi
635                    echo " no executable:" $EXECUTABLE >> $RUNLOG
636                    RETVAL=8
637                    ENDVAL=-1
638          else          else
639             echo " $OUTPUTFILE is up to date " > run.log 2>&1              if test ! -f $OUTPUTFILE -o $OUTPUTFILE -ot $EXECUTABLE ; then
640             RETVAL=0                # output do not exist or is older than executable:
641                    rm -f $RUNLOG ; touch $RUNLOG
642                    if test -f run.log_tmp ; then cat run.log_tmp >> $RUNLOG ; fi
643                    ( eval $COMMAND ) >> $RUNLOG 2>&1
644                    RETVAL=$?
645                else
646                    RETVAL=0
647                    if test -f $RUNLOG ; then
648                        if test -f run.log_tmp ; then cat run.log_tmp >> $RUNLOG ; fi
649                        echo "---------->> $OUTPUTFILE is up to date " >> $RUNLOG 2>&1
650                    else
651                        touch $RUNLOG
652                        if test -f run.log_tmp ; then cat run.log_tmp >> $RUNLOG ; fi
653                        echo "---------->> $OUTPUTFILE is up to date " >> $RUNLOG 2>&1
654                        echo " no previous $RUNLOG: assume NORMAL END" >> $RUNLOG 2>&1
655                    fi
656                fi
657                ENDVAL=`cat $RUNLOG | grep -v 'ABNORMAL END' | grep -c 'NORMAL END'`
658          fi          fi
659          # echo "COMMAND='$COMMAND'"          rm -f run.log_tmp
660          # echo "pwd='"`pwd`"'"          if [ $RETVAL -eq 0 -a $ENDVAL -gt 0 ] ; then
661          if test "x$RETVAL" = x0 ; then              echo successful
662              tail run.log              printf '=> output from running in %s :\n' $1 1>&2
663              echo successful 1>&2              tail $RUNLOG | sed 's/^.*/> &/g' 1>&2
664              # === Reduce the size of the testing emails!              # === Reduce the size of the testing emails!
665              # if test "x$ADM" = x ; then              #cp $OUTPUTFILE $CDIR"/"$OUTPUTFILE
             #   cp output.txt $CDIR"/output.txt"  
             # else  
             #   cp output.txt_adm $CDIR"/output.txt_adm"  
             # fi  
666              if test -s STDERR.0000 ; then cp STDERR.0000 $CDIR"/STDERR.0000" ; fi              if test -s STDERR.0000 ; then cp STDERR.0000 $CDIR"/STDERR.0000" ; fi
667              return 0              return 0
668            elif [ $RETVAL -ne 0 -a $ENDVAL -gt 0 ] ; then
669                #-- for some weird cases (run is finihed but with error code)
670                echo 'finished with error (run:' $RETVAL ' end:' $ENDVAL ')'
671                printf '=> output from running in %s :\n' $1 1>&2
672                tail $RUNLOG | sed 's/^.*/> &/g' 1>&2
673                return 0
674          else          else
675              tail run.log              echo 'failed (run:' $RETVAL ' end:' $ENDVAL ')'
676              echo failed 1>&2              printf '=> output from running in %s :\n' $1 1>&2
677              cp run.log $CDIR"/run.log"              tail $RUNLOG | sed 's/^.*/> &/g' 1>&2
678                cp $RUNLOG $CDIR"/"$RUNLOG
679              if test -s STDERR.0000 ; then cp STDERR.0000 $CDIR"/STDERR.0000" ; fi              if test -s STDERR.0000 ; then cp STDERR.0000 $CDIR"/STDERR.0000" ; fi
680              return 1              return 1
681          fi          fi
# Line 553  createcodelet() Line 686  createcodelet()
686  {  {
687      # create codelet for comparing model output      # create codelet for comparing model output
688    
689      printf "creating the comparison code...  "      printf "creating the comparison code (using CC=$CC)...  "
690      cat > tmp_cmpnum.c <<EOF      cat > tr_cmpnum.c <<EOF
691  #include <stdio.h>  #include <stdio.h>
692  #include <math.h>  #include <math.h>
693  int main( int argc, char** argv )  {  int main( int argc, char** argv )  {
694    int linnum,best,lncnt;    int linnum,cmplin,best,lncnt;
695    double a,b,abave,relerr;    double a,b,abave,relerr;
696    best = -22;    best = -22;
697    lncnt = 0;    lncnt = 0;
698    while( 1 & (lncnt+=1) < 999 )  {    while( 1 & ( (lncnt+=1) < 999 ) )  {
699      scanf("%d", &linnum);      scanf("%d", &linnum);
700      if (linnum == -1)  break;      if (linnum == -1)  break;
701      scanf("%lf", &a);  scanf("%lf", &b);      scanf("%lf", &a);  scanf("%lf", &b);
702      abave = 0.5*(fabs(a)+fabs(b));      abave = 0.5*(fabs(a)+fabs(b));
703      if (abave > 0.0) {      if ( abave == abave ) {
704        relerr=fabs(a-b)/abave;        if (abave > 0.0) {
705        if (relerr > 0.0) { linnum = (int)rint(log10(relerr)); }          relerr=fabs(a-b)/abave;
706        else { linnum = -16 ; }          if (relerr > 0.0) { cmplin = (int)rint(log10(relerr)); }
707        best = (best > linnum) ? best : linnum;          else { cmplin = -16 ; }
708      }          best = (best > cmplin) ? best : cmplin; }
709          else { cmplin = -22 ; }
710       /* printf("%d ; %lf ; %lf\n",cmplin,a,b); */
711          }
712       else {
713       /* printf("%lf ; %lf ; %lf\n",abave,a,b); */
714          break; }
715    }    }
716    if (lncnt == 999) best=-29;    if (lncnt == 999) best=-29;
717      if (linnum != -1) best=-99;
718    printf("%d\n", -best);    printf("%d\n", -best);
719    return 0;    return 0;
720  }  }
721  EOF  EOF
722      $CC -o tmp_cmpnum tmp_cmpnum.c -lm      $CC -o tr_cmpnum tr_cmpnum.c -lm
723    
724      if [ -x ./tmp_cmpnum ]; then      if [ -x ./tr_cmpnum ]; then
725          echo "OK"          echo "OK"
726          return 0          return 0
727      else      else
728          echo          echo
729          echo "ERROR: failed to compile comparison code -- please specify"          echo "ERROR: failed to compile comparison code -- please specify"
730          echo "  a C compiler using the CC environment variable."          echo "  a C compiler using the CC environment variable."
731          exit 1          exit 1
732      fi      fi
# Line 599  formatresults() Line 739  formatresults()
739      nm=$1      nm=$1
740      printf '%s %s %s %s' $2 $3 $4 $5      printf '%s %s %s %s' $2 $3 $4 $5
741      shift; shift; shift; shift; shift;      shift; shift; shift; shift; shift;
742      printf '%3s' $@      listPrt=$@
743            listRes=`echo $listPrt | sed 's/>//' | sed 's/<//'`
744      if [ $1 = '--' ]; then      xx=`echo $listPrt | sed 's/.*>//' | sed 's/<.*//' | awk '{print $1}'`
745        printf '%3s' $listPrt
746    #   line below does not work on hp-ux_ia64 : do those substitutions later on
747    #   printf '%3s' $listPrt | sed 's/ 99/ --/g' | sed 's/  > />/' | sed 's/  < /</'
748    
749        if [ $xx = '..' ]; then
750            printf ' N/O '
751        elif [ $xx = '--' ]; then
752            printf ' N/O '
753        elif [ $xx = 99 ]; then
754          printf ' N/O '          printf ' N/O '
755      else      else
756          if [ $1 -gt 12 ]; then          if [ $xx -ge $MATCH_CRIT ]; then
757              printf ' pass'              printf ' pass'
758          else          else
759              printf ' FAIL'              printf ' FAIL'
# Line 612  formatresults() Line 761  formatresults()
761      fi      fi
762      printf '  %s' $nm      printf '  %s' $nm
763      printf '\n'      printf '\n'
       
 }  
   
 show_help()  
 {  
     cat - << EOF  
 $0 [-help] [-quick] [-verbose] dir1 [dir2] [...]  
764    
  -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  
765  }  }
766    
767  scandirs()  scandirs()
768  {  {
769      if [ $# -eq 0 ]; then      if [ $# -eq 1 ]; then
770          for arg in * ; do          for arg in * ; do
771              test -d $arg/input && echo $arg              test -f $arg/$1 && echo $arg
772          done          done
773      else      else
774          echo $*          echo $*
775      fi      fi
776  }  }
777    
778    
779    check_eedata()
780    {
781        # check_eedata size.h eedata
782        if [ $# -eq 2 ] ; then
783          if test -f $1 -a -f $2 ; then
784          sx=`grep "^     & *nSx *=" $1 | sed "s/^     & *nSx *=//" | sed 's/, *$//'`
785          nx=`grep "^ *nTx *=" $2 | tail -1 | sed 's/^ *nTx *= *//' | sed "s/, *$//"`
786          if test "x$nx" = x ; then
787            rx=10
788          else
789            rx=`expr $sx % $nx`
790          fi
791          sy=`grep "^     & *nSy *=" $1 | sed "s/^     & *nSy *=//" | sed 's/, *$//'`
792          ny=`grep "^ *nTy *=" $2 | tail -1 | sed 's/^ *nTy *= *//' | sed "s/, *$//"`
793          if test "x$ny" = x ; then
794            ry=20
795          else
796            ry=`expr $sy % $ny`
797          fi
798          echo `expr $rx + $ry`
799        else
800          echo '-1'
801          fi
802        else
803          echo '-2'
804        fi
805    
806    }
807    
808  ###############################################################################  ###############################################################################
809    
810    
# Line 653  scandirs() Line 812  scandirs()
812  debug=0  debug=0
813  verbose=1  verbose=1
814  clean=0  clean=0
 expts=''  
 # ieee=1  
815    
816  IEEE=true  IEEE=true
817  if test "x$MITGCM_IEEE" != x ; then  if test "x$MITGCM_IEEE" != x ; then
818      IEEE=$MITGCM_IEEE      IEEE=$MITGCM_IEEE
819  fi  fi
820    GSL=f
821    
822  CLEANUP=f  CLEANUP=f
823    NORUN=f
824  QUICK=f  QUICK=f
825    NOMAKE=f
826  NOGENMAKE=f  NOGENMAKE=f
827  NOCLEAN=f  NOCLEAN=f
828  NODEPEND=f  NODEPEND=f
# Line 673  BASH= Line 832  BASH=
832  OPTFILE=NONE  OPTFILE=NONE
833  ADDRESSES=  ADDRESSES=
834  TESTDIRS=  TESTDIRS=
835    SKIPDIRS=
836  MPACKDIR="../tools/mpack-1.6"  MPACKDIR="../tools/mpack-1.6"
837  HAVE_MPACK=  HAVE_MPACK=
838  MPACK="$MPACKDIR/mpack"  MPACK=
839  COMMAND=  COMMAND=
840    MKDEPEND=
841  if test "x$MAKE" = x ; then  if test "x$MAKE" = x ; then
842      MAKE=make      MAKE=make
843  fi  fi
# Line 685  if test "x$CC" = x ; then Line 846  if test "x$CC" = x ; then
846  fi  fi
847  JOBS=  JOBS=
848  MPI=f  MPI=f
849    MULTI_THREAD=f
850  OUTDIR=  OUTDIR=
851  DELDIR=  DELDIR=
852    USE_R4=
853    
854  ADM=  ADM=
855    OADM=
856    
857  # Additional monitor types  # list of pTracers to check for monitor output
858  PTRACERS_NUM="1 2 3 4 5"  PTRACERS_NUM="1 2 3 4 5"
859    
860    MATCH_CRIT=10
861    
862  printf "parsing options...  "  printf "parsing options...  "
863    
864  ac_prev=  ac_prev=
# Line 706  for ac_option ; do Line 872  for ac_option ; do
872      fi      fi
873    
874      ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`      ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
875        
876      case $ac_option in      case $ac_option in
877                    
878          -help | --help | -h | --h)          -help | --help | -h | --h)
# Line 719  for ac_option ; do Line 885  for ac_option ; do
885                    
886          -addr | --addr | -a | --a)          -addr | --addr | -a | --a)
887              ac_prev=ADDRESSES ;;              ac_prev=ADDRESSES ;;
888          -addr=* | --addr=*)          -addr=* | --addr=* | -a=* | --a=*)
889              ADDRESSES=$ac_optarg ;;              ADDRESSES=$ac_optarg ;;
890            -mpackdir | --mpackdir | -mpd | --mpd)
891                ac_prev=MPACKDIR ;;
892            -mpackdir=* | --mpackdir=* | -mpd=* | --mpd=*)
893                MPACKDIR=$ac_optarg ;;
894    
895          -tdir | --tdir | -t | --t)          -tdir | --tdir | -t | --t)
896              ac_prev=TESTDIRS ;;              ac_prev=TESTDIRS ;;
897          -tdir=* | --tdir=*)          -tdir=* | --tdir=* | -t=* | --t=*)
898              TESTDIRS=$ac_optarg ;;              TESTDIRS=$ac_optarg ;;
899    
900            -skipdir | --skipdir | -skd | --skd)
901                ac_prev=SKIPDIRS ;;
902            -skipdir=* | --skipdir=* | -skd=* | --skd=*)
903                SKIPDIRS=$ac_optarg ;;
904    
905          -bash | --bash | -b | --b)          -bash | --bash | -b | --b)
906              ac_prev=BASH ;;              ac_prev=BASH ;;
907          -bash=* | --bash=*)          -bash=* | --bash=* | -b=* | --b=*)
908              BASH=$ac_optarg ;;              BASH=$ac_optarg ;;
909    
910          -command | --command | -c | --c)          -command | --command | -c | --c)
911              ac_prev=COMMAND ;;              ac_prev=COMMAND ;;
912          -command=* | --command=*)          -command=* | --command=* | -c=* | --c=*)
913              COMMAND=$ac_optarg ;;              COMMAND=$ac_optarg ;;
914    
915            -makedepend | --makedepend | -md | --md)
916                ac_prev=MKDEPEND ;;
917            -makedepend=* | --makedepend=* | -md=* | --md=*)
918                MKDEPEND=$ac_optarg ;;
919    
920          -make | --make | -m | --m)          -make | --make | -m | --m)
921              ac_prev=MAKE ;;              ac_prev=MAKE ;;
922          -make=* | --make=*)          -make=* | --make=* | -m=* | --m=*)
923              MAKE=$ac_optarg ;;              MAKE=$ac_optarg ;;
924    
925          -odir | --odir)          -odir | --odir)
# Line 752  for ac_option ; do Line 932  for ac_option ; do
932          -ptracers=* | --ptracers=* | -ptr=* | --ptr=*)          -ptracers=* | --ptracers=* | -ptr=* | --ptr=*)
933              PTRACERS_NUM=$ac_optarg ;;              PTRACERS_NUM=$ac_optarg ;;
934    
935          -j) ac_prev=JOBS ;;          -match | --match ) ac_prev=MATCH_CRIT ;;
936          -j=*) JOBS=$ac_optarg ;;          -match=* | --match=* ) MATCH_CRIT=$ac_optarg ;;
937    
938            -j | --j) ac_prev=JOBS ;;
939            -j=* | --j=*) JOBS=$ac_optarg ;;
940    
941          -clean | --clean)          -clean | --clean)
942              CLEANUP=t ; DELDIR=t ;;              CLEANUP=t ; DELDIR=t ;;
943    
944            -norun | --norun | -nr | --nr)
945                NORUN=t ;;
946            -runonly | --runonly | -ro | --ro)
947                QUICK=t ; NOMAKE=t ;;
948          -quick | --quick | -q | --q)          -quick | --quick | -q | --q)
949              QUICK=t ;;              QUICK=t ;;
950          -nogenmake | --nogenmake | -ng | --ng)          -nogenmake | --nogenmake | -ng | --ng)
# Line 772  for ac_option ; do Line 959  for ac_option ; do
959    
960          -mpi) MPI=t ;;          -mpi) MPI=t ;;
961    
962            -mth) MULTI_THREAD=t ;;
963    
964          -adm | -ad) ADM=t ;;          -adm | -ad) ADM=t ;;
965    
966            -oad) OADM=t; NODEPEND=t ;;
967    
968          -ieee) IEEE=true ;;          -ieee) IEEE=true ;;
969          -noieee) IEEE= ;;          -noieee) IEEE= ;;
970            -gsl) GSL=t ;;
971    
972          -verbose) verbose=2 ;;          -verbose) verbose=2 ;;
973          -debug) debug=1 ;;          -debug) debug=1 ;;
# Line 783  for ac_option ; do Line 975  for ac_option ; do
975    
976          -deldir | -dd) DELDIR=t ;;          -deldir | -dd) DELDIR=t ;;
977    
978            -use_r4|-ur4) USE_R4=t ;;
979    
980            -ts) TS=t;;
981            -papis) PAPIS=t;;
982            -pcls) PCL=t;;
983    
984          -*)          -*)
985              echo "Error: unrecognized option: "$ac_option              echo "Error: unrecognized option: "$ac_option
986              usage              usage
987              ;;              ;;
988            
989          *)          *)
990              echo "Error: unrecognized argument: "$ac_option              echo "Error: unrecognized argument: "$ac_option
991              usage              usage
992              ;;              ;;
993            
994       esac       esac
995        
996  done  done
997    
998  if test "x$QUICK" = xt ; then  if test "x$QUICK" = xt ; then
# Line 803  if test "x$QUICK" = xt ; then Line 1001  if test "x$QUICK" = xt ; then
1001      NODEPEND=t      NODEPEND=t
1002  fi  fi
1003    
1004  if test "x$TESTDIRS" = x ; then  #- setting for forward or ADM testing
     TESTDIRS=`scandirs`  
 fi  
   
 if test "x$OPTFILE" = xNONE -a "x$MITGCM_OF" != x ; then  
     OPTFILE=$MITGCM_OF  
 fi  
   
1005  if test "x$ADM" = xt ; then  if test "x$ADM" = xt ; then
1006        code_dir=code_ad
1007        inputdir=input_ad
1008        ref_outp="output_adm.txt"
1009        EXECUTABLE="mitgcmuv_ad"
1010    elif test "x$OADM" = xt ; then
1011        code_dir=code_oad
1012        inputdir=input_oad
1013        ref_outp="output_oadm.txt"
1014      EXECUTABLE="mitgcmuv_ad"      EXECUTABLE="mitgcmuv_ad"
     OUTPUTFILE="output.txt_adm"  
1015  else  else
1016        code_dir=code
1017        inputdir=input
1018        ref_outp="output.txt"
1019      EXECUTABLE="mitgcmuv"      EXECUTABLE="mitgcmuv"
     OUTPUTFILE="output.txt"  
1020  fi  fi
1021    
1022  if test "x$ADM" = xt -a "x$COMMAND" = x ; then  xx=`echo $TESTDIRS | awk '{print $1}'`
1023      COMMAND="./$EXECUTABLE > $OUTPUTFILE"  if test "x$TESTDIRS" = x ; then
1024        LIST=`scandirs results/$ref_outp`
1025    elif test $xx = 'start_from' ; then
1026        xx=`echo $TESTDIRS | awk '{print $2}'`
1027        LIST=`scandirs results/$ref_outp | sed -n "/$xx/,$ p"`
1028    else
1029        #- expand group of experiments:
1030        LIST=" "
1031        for xx in $TESTDIRS
1032        do
1033          case $xx in
1034            'basic') LIST=${LIST}" aim.5l_cs hs94.128x64x5 ideal_2D_oce"
1035                     LIST=${LIST}" lab_sea tutorial_baroclinic_gyre"
1036                     LIST=${LIST}" tutorial_global_oce_latlon tutorial_plume_on_slope"
1037                    ;;
1038            'tutorials')
1039                     LIST=${LIST}" "`ls | grep 'tutorial_'` ;;
1040            *)       LIST=${LIST}" "$xx ;;
1041          esac
1042        done
1043    fi
1044    #echo 'LIST='${LIST}'<'
1045    #- skip dirs, remove duplicate and non-directory:
1046    TESTDIRS=" "
1047    count=0
1048    for xx in $LIST
1049    do
1050        yy=`echo $SKIPDIRS | grep -c $xx`
1051        if test $yy = 0 ; then
1052            if test -d $xx ; then
1053                yy=`echo $TESTDIRS | grep -c $xx`
1054                if test $yy = 0 ; then TESTDIRS=${TESTDIRS}" "$xx ; fi
1055            else count=1 ;
1056                echo ""; echo -n " -- skip \"$xx\" (not a directory !)"
1057            fi
1058        else
1059            if test $count = 1 ; then echo -n ", \"$xx\""
1060            else count=1 ; echo "" ;  echo -n " skip: \"$xx\""
1061            fi
1062        fi
1063    done
1064    if test $count = 1 ; then echo "" ; echo -n " ... " ; fi
1065    #echo 'TESTDIRS='${TESTDIRS}'<'
1066    
1067    if test "x$OPTFILE" = xNONE -a "x$MITGCM_OF" != x ; then
1068        OPTFILE=$MITGCM_OF
1069  fi  fi
1070    
1071    RUNLOG="run.tr_log"
1072    OUTPUTFILE=$ref_outp
1073  if test "x$COMMAND" = x ; then  if test "x$COMMAND" = x ; then
1074      COMMAND="./$EXECUTABLE > $OUTPUTFILE"      COMMAND="./$EXECUTABLE > $OUTPUTFILE"
1075  fi  fi
1076    if test "x$MPI" = xt ; then
1077        OUTPUTFILE="STDOUT.0000"
1078    fi
1079    
 #echo "OK"  
1080  echo "OK (COMMAND= $COMMAND )"  echo "OK (COMMAND= $COMMAND )"
1081    
1082    # set the Default List of output variables to be checked:
1083    #  (use default or load experiment-specific list from file "tr_checklist")
1084    # content : 1rst = main variable used to decide if it pass or FAIL
1085    #         others = number of matching digits to be printed in summary.txt
1086    if test "x$ADM" = x -a "x$OADM" = x; then
1087        DEF_CHECK_LIST='PS PS T+ S+ U+ V+ pt1+ pt2+ pt3+ pt4+ pt5+'
1088        EMPTY_RESULTS='.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..'
1089        LEN_CHECK_LIST=`echo $DEF_CHECK_LIST | sed 's/ [a-zA-Z0-9]*+/&mn &mx &av &sd/g' | awk '{print NF-1}'`
1090        ii=`echo $EMPTY_RESULTS | awk '{print NF}'`
1091        EMPTY_RESULTS=$EMPTY_RESULTS`expr $LEN_CHECK_LIST - $ii | awk 'BEGIN{FS=":"}{for(i=1;i<=$1;i++){printf "  ."}}'`
1092    else
1093        DEF_CHECK_LIST='Grad Cost Grad'
1094        EMPTY_RESULTS='.. ..'
1095        LEN_CHECK_LIST=`echo $DEF_CHECK_LIST | sed 's/ [a-zA-Z0-9]*+/&mn &mx &av &sd/g' | awk '{print NF-1}'`
1096    fi
1097    
1098  #  create the FORTRAN comparison code  #  create the FORTRAN comparison code
1099  createcodelet  if test -x tr_cmpnum ; then
1100        echo "skipping comparison code build"
1101    else
1102        createcodelet
1103    fi
1104    
1105  #  build the mpack utility  #  build the mpack utility (if ADDRESSES = NONE, do it to test the build)
1106  if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then  if test "x$ADDRESSES" = x ; then
1107      echo "skipping mpack build"      echo "skipping mpack build"
1108  else  else
1109      build_mpack      build_mpack
1110  fi  fi
1111    
1112  #  Create a uniquely named directory to store results  #  Create a uniquely named directory to store results
1113    CMDLINE=$0
1114    for xx in "$@" ; do nw=`echo $xx | wc -w`
1115        if test $nw = '1' ; then CMDLINE="$CMDLINE $xx"
1116                            else CMDLINE="$CMDLINE '$xx'" ; fi
1117    done
1118    #for xx in "$@" ; do CMDLINE="$CMDLINE '$xx'" ; done
1119  MACH=`hostname`  MACH=`hostname`
1120  UNAMEA=`uname -a`  UNAMEA=`uname -a`
1121  DATE=`date +%Y%m%d`  DATE=`date +%Y%m%d`
1122  BASE="tr_"$MACH"_"$DATE"_"  BASE="tr_"$MACH"_"$DATE"_"
1123  if test "x$OUTDIR" != x ; then  if test "x$OUTDIR" != x ; then
1124      BASE="tr_"$OUTDIR"_"$DATE"_"      BASE="tr_"$OUTDIR"_"$DATE"_"
1125    else
1126        short_name=`hostname | sed 's/\..*$//'`
1127        BASE="tr_"$short_name"_"$DATE"_"
1128  fi  fi
1129  DNUM=0  DNUM=0
1130  DRESULTS="$BASE$DNUM"  DRESULTS="$BASE$DNUM"
# Line 861  if test "x$RETVAL" != x0 ; then Line 1139  if test "x$RETVAL" != x0 ; then
1139      exit 1      exit 1
1140  fi  fi
1141  SUMMARY="$DRESULTS/summary.txt"  SUMMARY="$DRESULTS/summary.txt"
 printf "Start time:  " >> $SUMMARY  
1142  start_date=`date`  start_date=`date`
1143  echo $start_date > $SUMMARY  echo $start_date > $SUMMARY
1144    echo 'run:' $CMDLINE >> $SUMMARY
1145    echo 'on :' $UNAMEA  >> $SUMMARY
1146    
1147  of_path=  of_path=
1148  if test "x$OPTFILE" != xNONE ; then  if test "x$OPTFILE" != xNONE ; then
# Line 892  else Line 1171  else
1171  fi  fi
1172  echo  echo
1173  echo >> $SUMMARY  echo >> $SUMMARY
1174  if test "x$ADM" = x ; then  if test "x$ADM" = x -a "x$OADM" = x; then
1175      line_0="            ----T-----  ----S-----  ----U-----  ----V-----"      if [ $MATCH_CRIT -lt 10 ] ;
1176        then line_0="default  "$MATCH_CRIT ;
1177        else line_0="default "$MATCH_CRIT ; fi
1178           line_0="$line_0  ----T-----  ----S-----  ----U-----  ----V-----"
1179      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"
1180      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  ."
1181      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"
1182      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  ."
1183      for ii in $PTRACERS_NUM ; do      for ii in $PTRACERS_NUM ; do
         #  tst=`eval 'echo $HAVE_PTR0'$ii`  
         #  if test "x$tst" = xt ; then  
1184          line_0="$line_0  --PTR 0"$ii"--"          line_0="$line_0  --PTR 0"$ii"--"
1185          line_1="$line_1        m  s"          line_1="$line_1        m  s"
1186          line_2="$line_2  m  m  e  ."          line_2="$line_2  m  m  e  ."
1187          line_3="$line_3  i  a  a  d"          line_3="$line_3  i  a  a  d"
1188          line_4="$line_4  n  x  n  ."          line_4="$line_4  n  x  n  ."
         #  fi  
1189      done      done
1190      echo "$line_0" | tee -a $SUMMARY      echo "$line_0" | tee -a $SUMMARY
1191      echo "$line_1" | tee -a $SUMMARY      echo "$line_1" | tee -a $SUMMARY
# Line 917  if test "x$ADM" = x ; then Line 1196  if test "x$ADM" = x ; then
1196  else  else
1197      echo "ADJOINT=true" >> $SUMMARY      echo "ADJOINT=true" >> $SUMMARY
1198      echo >> $SUMMARY      echo >> $SUMMARY
1199        if [ $MATCH_CRIT -lt 10 ] ;
1200        then line_0="default     "$MATCH_CRIT ;
1201        else line_0="default    "$MATCH_CRIT ; fi
1202        echo "$line_0" | tee -a $SUMMARY
1203      cat << EOF | tee -a $SUMMARY      cat << EOF | tee -a $SUMMARY
1204  G D M    C  G  G D M    C  G
1205  E p a R  o  r  E p a R  o  r
# Line 925  N n k u  s  a Line 1208  N n k u  s  a
1208    
1209  EOF  EOF
1210  fi  fi
1211    echo "-------------------------------------------------------------------------------"
1212    
1213  #  ...and each test directory...  #  ...and each test directory...
1214  for dir in $TESTDIRS ; do  for dir in $TESTDIRS ; do
1215        
1216        # set builddir & rundir:
1217        builddir="build"
1218        if test ! -d $dir/$builddir ; then mkdir $dir/$builddir ; fi
1219        rundir="run"
1220        pfxdir="tr_$rundir"
1221        if test ! -d $dir/$rundir ; then
1222            rundir=$builddir
1223        fi
1224        CODE_DIR=$dir/$code_dir
1225        BUILD_DIR=$dir/$builddir
1226    
1227      #  Cleanup only!      #  Cleanup only!
1228      if test "x$CLEANUP" = xt ; then      if test "x$CLEANUP" = xt ; then
1229          if test -r $dir/build/Makefile ; then          echo -n '  --- dir:' $BUILD_DIR ': '
1230              ( cd $dir/build ; make CLEAN )          makeclean $BUILD_DIR
1231            (   cd $BUILD_DIR
1232                rm -f $EXECUTABLE *.bak
1233                rm -f genmake_state genmake_*optfile genmake.log
1234                rm -f genmake.tr_log make.tr_log
1235            )
1236            if test -d $dir/$rundir/CVS ; then
1237                echo -n '  --- dir:' $dir/$rundir ': '
1238                run_clean $dir/$rundir
1239          fi          fi
1240          if test -r $dir/input/Makefile ; then          trdir=`( cd $dir ; find . -type d -name "$pfxdir.*" -print | sed 's/^.\///')`
1241              ( cd $dir/input ; make CLEAN )          ttd=`echo $trdir | wc -w`
1242            if test $ttd != 0 ; then
1243                echo '  --- rm dir:' $trdir
1244                ( cd $dir ; rm -rf $trdir )
1245          fi          fi
         (  
             cd $dir  
             rm -rf tr_run.*  
         )  
1246          continue          continue
1247      fi      fi
1248    
1249      #  Verify that the testdir exists and contains previous      #  Verify that the testdir exists and contains previous
1250      #  results in the correct location--or skip this directory!      #  results in the correct location--or skip this directory!
1251      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  
1252      if test ! -r $fout ; then      if test ! -r $fout ; then
1253          echo "can't read \"$fout\" -- skipping $dir"          echo "can't read \"$fout\" -- skipping $dir"
1254          continue          continue
1255      fi      fi
     if test "x$ADM" = x ; then  
         check_for_add_mon_output  $fout  
     fi  
1256    
1257      # Check for additional types of monitor output      # Check for specific files for particular type of run
1258    
1259      builddir="input"      if test ! -r $CODE_DIR"/SIZE.h_mpi" -a "x$MPI" = "xt" ; then
1260      rundir="input"          echo "can't find \"$CODE_DIR/SIZE.h_mpi\" -- skipping $dir"
1261      use_seperate_build=0          continue
1262      if test -d $dir/build -a -r $dir/build ; then      fi
1263          builddir="build"      if test ! -r $dir"/input/eedata.mth" -a "x$MULTI_THREAD" = "xt" ; then
1264          rundir="build"          echo "can't find \"$dir/input/eedata.mth\" -- skipping $dir"
1265          use_seperate_build=1          continue
         linkdata $use_seperate_build $dir/$rundir  
1266      fi      fi
1267            if test "x$MPI" = "xt" -a "x$MULTI_THREAD" = "xt" ; then
1268          retv=`check_eedata $CODE_DIR"/SIZE.h_mpi" $dir"/input/eedata.mth"`
1269          if test $retv != 0 ; then
1270            echo "input/eedata.mth tiling misfit -- skipping $dir"
1271            continue
1272          fi
1273        fi
1274    
1275      #  Check whether there are "extra runs" for this testdir      #  Check whether there are "extra runs" for this testdir
1276      extra_runs=      extra_runs=
1277      if test "x$ADM" = x -a "x$use_seperate_build" = x1 ; then      if test "x$NORUN" = xf ; then
1278          ex_run_dirs=`( cd $dir ; echo input.* )`          ex_run_dirs=`( cd $dir ; echo $inputdir.* )`
1279          echo "ex_run_dirs='$ex_run_dirs'"      fi
1280          for exd in $ex_run_dirs ; do      #echo "ex_run_dirs='$ex_run_dirs'"
1281              name=`echo $exd | sed -e 's/input.//g'`      for exd in $ex_run_dirs ; do
1282              outf="$dir/results/output.txt.$name"          name=`echo $exd | sed -e "s/$inputdir\.//"`
1283              if test -f $outf -a -r $outf ; then          refExOut=`echo $ref_outp | sed "s/\./.${name}./"`
1284            outf="$dir/results/$refExOut"
1285            if test -f $outf -a -r $outf ; then
1286              if test "x$MULTI_THREAD" = "xt" ; then
1287                if test -r $dir"/"$exd"/eedata.mth" ; then
1288                  if test "x$MPI" = "xt" ; then
1289                    retv=`check_eedata $CODE_DIR"/SIZE.h_mpi" $dir"/"$exd"/eedata.mth"`
1290                    if test $retv = 0 ; then
1291                        extra_runs="$extra_runs $name"
1292                    else
1293                        echo $exd"/eedata.mth tiling misfit -- skipping $dir"
1294                    fi
1295                  else
1296                  extra_runs="$extra_runs $name"                  extra_runs="$extra_runs $name"
1297                  fi
1298                #else echo $dir"/"$exd"/eedata.mth: not found"
1299              fi              fi
1300          done            else
1301      fi              extra_runs="$extra_runs $name"
1302              fi
1303            fi
1304        done
1305    
1306      if test "x$ADM" = x ; then      echo
1307          code_dir=code      if test "x$extra_runs" = "x" ; then
1308          CODE_DIR=$dir/code         echo "Experiment:  $dir"
1309      else      else
1310          code_dir=code_ad         echo "Experiment:  $dir ; extra_runs=$extra_runs"
         CODE_DIR=$dir/code_ad  
1311      fi      fi
     BUILD_DIR=$dir/$builddir  
   
     if test ! -r $CODE_DIR"/SIZE.h_mpi" -a "x$MPI" = "xt" ; then  
         echo "can't find \"$CODE_DIR/SIZE.h_mpi\" -- skipping $dir"  
         continue  
     fi  
   
     echo "-------------------------------------------------------------------------------"  
     echo  
     echo "Experiment:  $dir"  
1312      echo      echo
1313      unset genmake makedepend make run      unset genmake makedepend make run
1314      results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --'      results=$EMPTY_RESULTS
1315    
1316      #  Create an output dir for each OPTFILE/tdir combination      #  Create an output dir for each OPTFILE/tdir combination
1317      rel_CDIR=$DRESULTS"/"$dir      locDIR=$DRESULTS"/"$dir
1318      mkdir $rel_CDIR      mkdir $locDIR
1319      CDIR=`pwd`"/$rel_CDIR"      CDIR=`pwd`"/$locDIR"
1320        
1321      if test "x$CLEANUP" = xt ; then      if test "x$NORUN" = xt ; then
1322          makeclean $dir/$builddir              run=N
1323            genmakemodel $dir/$builddir && genmake=Y \
1324                && makeclean $dir/$builddir \
1325                && symlink_mpifiles $dir $code_dir $builddir \
1326                && makedependmodel $dir/$builddir && makedepend=Y \
1327                && makemodel $dir/$builddir && make=Y
1328      else      else
1329          genmakemodel $dir/$builddir && genmake=Y \          genmakemodel $dir/$builddir && genmake=Y \
1330              && makeclean $dir/$builddir \              && makeclean $dir/$builddir \
1331              && symlink_mpifiles $dir $code_dir $builddir \              && symlink_mpifiles $dir $code_dir $builddir \
1332              && makedependmodel $dir/$builddir && makedepend=Y \              && makedependmodel $dir/$builddir && makedepend=Y \
1333              && makemodel $dir/$builddir && make=Y \              && makemodel $dir/$builddir && make=Y \
1334              && linkdata $use_seperate_build $dir/$rundir \              && run_clean $dir/$rundir \
1335                && linkdata $dir/$rundir $inputdir \
1336              && runmodel $dir/$rundir && run=Y \              && runmodel $dir/$rundir && run=Y \
1337              && results=`testoutput $dir $rundir`              && results=`testoutput_run $dir $rundir $ref_outp`
1338      fi      fi
1339            #echo "results='$results'"
1340      echo  
     if test "x$ADM" = x ; then  
1341          fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results`          fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results`
1342          echo          echo 1>&2
1343          echo "$fres" >> $SUMMARY          echo "$fres" | sed 's/ 99/ --/g' | sed 's/  > />/' | sed 's/  < /</' >> $SUMMARY
1344          echo "fresults='$fres'" > $CDIR"/summary.txt"          touch $locDIR"/summary.txt"
1345          echo "MACH='$MACH'" >> $CDIR"/summary.txt"          echo "fresults='$fres'" | sed 's/ 99/ --/g' >> $locDIR"/summary.txt"
1346          echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"          echo "MACH='$MACH'" >> $locDIR"/summary.txt"
1347          echo "DATE='$DATE'" >> $CDIR"/summary.txt"          echo "UNAMEA='$UNAMEA'" >> $locDIR"/summary.txt"
1348          echo "tdir='$dir'" >> $CDIR"/summary.txt"          echo "DATE='$DATE'" >> $locDIR"/summary.txt"
1349            echo "tdir='$dir'" >> $locDIR"/summary.txt"
1350            if test "x$ADM" = xt ; then
1351                head -1 $dir/$builddir/taf_ad.log >> $locDIR"/summary.txt"
1352                grep -A3 'Seconds in section "ALL' $dir/$rundir/$OUTPUTFILE \
1353                                    >> $locDIR"/summary.txt"
1354            fi
1355    
1356          for ex in $extra_runs ; do          for ex in $extra_runs ; do
1357              unset run              unset run
1358              results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --'              results=$EMPTY_RESULTS
1359                #  reference output file
1360                refExOut=`echo $ref_outp | sed "s/\./.${ex}./g"`
1361              #  Create an output dir for each OPTFILE/tdir.ex combination              #  Create an output dir for each OPTFILE/tdir.ex combination
1362              rel_CDIR=$DRESULTS"/"$dir"."$ex              locDIR=$DRESULTS"/"$dir"."$ex
1363              mkdir $rel_CDIR              mkdir $locDIR
1364              CDIR=`pwd`"/$rel_CDIR"              CDIR=`pwd`"/$locDIR"
1365              test ! -e "$dir/tr_run.$ex" && mkdir "$dir/tr_run.$ex"              test ! -e "$dir/$pfxdir.$ex" && mkdir "$dir/$pfxdir.$ex"
1366              for ldir in input.$ex input ; do              run_clean $dir/$pfxdir.$ex
1367                  (              linkdata $dir/$pfxdir.$ex $inputdir.$ex $inputdir
1368                      cd "$dir/$ldir" > /dev/null 2>&1              runmodel $dir/$pfxdir.$ex && run=Y \
1369                      ls -1 2>/dev/null \              && results=`testoutput_run $dir $pfxdir.$ex $refExOut`
                         | sed -e 's|^CVS$||g' | sed -e 's|^output.txt$||g'  
                 ) > tr_exrun_links  
                 (  
                     cd "$dir/tr_run.$ex"  
                     cat ../../tr_exrun_links | while read i ; do  
                         if test ! "x$i" = x ; then  
                             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}`  
1370              fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results`              fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results`
1371              fres="$fres.$ex"              fres="$fres.$ex"
1372              echo              echo 1>&2
1373              echo "$fres" >> $SUMMARY              echo "$fres" | sed 's/ 99/ --/g' | sed 's/  > />/' | sed 's/  < /</' >> $SUMMARY
1374              echo "fresults='$fres'" > $CDIR"/summary.txt"              touch $locDIR"/summary.txt"
1375              echo "MACH='$MACH'" >> $CDIR"/summary.txt"              echo "fresults='$fres'" | sed 's/ 99/ --/g' >> $locDIR"/summary.txt"
1376              echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"              echo "MACH='$MACH'" >> $locDIR"/summary.txt"
1377              echo "DATE='$DATE'" >> $CDIR"/summary.txt"              echo "UNAMEA='$UNAMEA'" >> $locDIR"/summary.txt"
1378              echo "tdir='$dir.$ex'" >> $CDIR"/summary.txt"              echo "DATE='$DATE'" >> $locDIR"/summary.txt"
1379                echo "tdir='$dir.$ex'" >> $locDIR"/summary.txt"
1380                if test "x$ADM" = xt ; then
1381                    head -1 $dir/$builddir/taf_ad.log >> $locDIR"/summary.txt"
1382                    grep -A3 'Seconds in section "ALL' $dir/$pfxdir.$ex/$OUTPUTFILE \
1383                                       >> $locDIR"/summary.txt"
1384                fi
1385                if test "x$POSTCLEAN" = xt ; then
1386                    run_clean $dir/$pfxdir.$ex
1387                fi
1388          done          done
1389      else  
1390          fres=`printf '%s %s %s %s' ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N}`      if test -f $DRESULTS"/"genmake_state ; then : ; else
1391          fres=$fres"$results   $dir"          if test -f $dir/$builddir/Makefile ; then
1392          echo              mkOpt=`grep '^# OPTFILE=' $dir/$builddir/Makefile 2>/dev/null | head -1 | sed 's/^# //'`
1393          echo "$fres" >> $SUMMARY              echo "from '$dir/$builddir/Makefile', extract:" > $DRESULTS/genmake_state
1394          echo "fresults='$fres'" > $CDIR"/summary.txt"              sed -n '/^# executed by:/,+1 p' $dir/$builddir/Makefile >> $DRESULTS/genmake_state
1395          echo "MACH='$MACH'" >> $CDIR"/summary.txt"              echo $mkOpt >> $DRESULTS/genmake_state
1396          echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"              gmkLog=$dir/$builddir/genmake.log
1397          echo "DATE='$DATE'" >> $CDIR"/summary.txt"              grep '^Get compiler version using:' $gmkLog > /dev/null 2>&1
1398          echo "tdir='$dir'" >> $CDIR"/summary.txt"              RETVAL=$?
1399          grep -A3 'Seconds in section "ALL' $dir/$rundir/$OUTPUTFILE \              if test "x$RETVAL" = x0 ; then
1400                             >> $CDIR"/summary.txt"                  echo "from '$gmkLog', extract compiler version:" >> $DRESULTS/genmake_state
1401                    sed -n '/Get compiler version/,/--- compiler version/p' $gmkLog | \
1402                           grep -v '^... compiler version ' > tr_vers.tmp_log
1403                    grep -i 'version ' tr_vers.tmp_log >> $DRESULTS/genmake_state
1404                    RETVAL=$?
1405                    if test "x$RETVAL" != x0 ; then
1406                       cat tr_vers.tmp_log >> $DRESULTS/genmake_state
1407                    fi
1408                    rm -f tr_vers.tmp_log
1409                fi
1410            fi
1411        fi
1412        #postclean $dir/$builddir
1413        if test "x$POSTCLEAN" = xt ; then
1414            makeclean $dir/$builddir \
1415                && run_clean $dir/$rundir
1416      fi      fi
1417    
     postclean $dir/$builddir  
       
1418      echo "-------------------------------------------------------------------------------"      echo "-------------------------------------------------------------------------------"
1419        
1420  done  done
1421    
1422  printf "Start time:  " >> $SUMMARY  printf "Start time:  " >> $SUMMARY
1423  echo $start_date >> $SUMMARY  echo "$start_date" >> $SUMMARY
1424  printf "End time:    " >> $SUMMARY  printf "End time:    " >> $SUMMARY
1425  date >> $SUMMARY  date >> $SUMMARY
1426    
# Line 1124  else Line 1445  else
1445              echo "An email containing results was sent to the following addresses:"              echo "An email containing results was sent to the following addresses:"
1446              echo "  \"$ADDRESSES\""              echo "  \"$ADDRESSES\""
1447              echo              echo
1448                test -f $DRESULTS".tar"  &&  rm -f $DRESULTS".tar"
1449                test -f $DRESULTS".tar.gz"  &&  rm -f $DRESULTS".tar.gz"
1450          fi          fi
         test -f $DRESULTS".tar"  &&  rm -f $DRESULTS".tar"  
         test -f $DRESULTS".tar.gz"  &&  rm -f $DRESULTS".tar.gz"  
1451      fi      fi
1452  fi  fi
1453    
1454  # rm -f tmp_cmpnum.f a.out  if test "x$QUICK" = xf -a "x$NORUN" = xf ; then
1455  rm -f tmp_cmpnum.c tmp_cmpnum      rm -f tr_cmpnum.c tr_cmpnum
1456    fi
1457    
1458  if test "x$CLEANUP" != xt ; then  if test "x$CLEANUP" != xt ; then
1459      cat $SUMMARY | sed 's/ -- -- -- --//g'      cat $SUMMARY | sed 's/ \.  \.  \.  \.  \.  \.  \.  \.  \.  \.  \.  \. //'
1460      if test -e tr_out.txt ; then      if test -e tr_out.txt ; then
1461          mv tr_out.txt tr_out.txt.old          mv tr_out.txt tr_out.txt.old
1462      fi      fi
1463      cat $SUMMARY | sed 's/ -- -- -- --//g' > tr_out.txt      cat $SUMMARY | sed '/^[YN] [YN] [YN] [YN]/ s/ \. //g' > tr_out.txt
1464  fi  fi
1465    
1466  if test "x$DELDIR" = xt ; then  if test "x$DELDIR" = xt ; then

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

  ViewVC Help
Powered by ViewVC 1.1.22