/[MITgcm]/MITgcm/verification/testreport
ViewVC logotype

Diff of /MITgcm/verification/testreport

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

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

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

  ViewVC Help
Powered by ViewVC 1.1.22