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

Legend:
Removed from v.1.57  
changed lines
  Added in v.1.173

  ViewVC Help
Powered by ViewVC 1.1.22