/[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.11 by edhill, Fri Oct 10 03:29:44 2003 UTC revision 1.194 by jmc, Thu Aug 22 19:34:15 2013 UTC
# Line 1  Line 1 
1  #!/bin/bash  #! /usr/bin/env bash
2  #  #
3  #  $Header$  #  $Header$
4  #  $Name$  #  $Name$
# 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"
16      echo "  (-optfile=|-of=)STRING   list of optfiles to use"      echo "  (-adm|-ad)               perform an adjoint run"
17      echo "  (-a|-addr)STRING         list of email recipients"      echo "  (-oad)                   perform an OpenAD adjoint run"
18      echo "                             (DEF=\"edhill@mitgcm.org\")"      echo "  (-mth)                   run multi-threaded (using eedata.mth)"
19      echo "  (-t|-tdir)STRING         list of test dirs to use"      echo "  (-mpi)                   use MPI to compile and run on 2 processors"
20      echo "                             (DEF=\"\" which builds all)"      echo "  (-MPI)  NUMBER           use MPI to compile and run on max NUMBER procs"
21      echo "  (-b|-bash)STRING         location of \"bash\" executable"      echo "  (-mfile|-mf) STRING      MPI: file with list of possible machines to run on"
22      echo "                             (DEF=\"\" for \"/bin/bash\")"      echo "  (-command|-c) STRING     command to run (needed for MPI run)"
23      echo "  (-command)STRING         command to run"      echo " ---- testing options : ----"
24      echo "                             (DEF=\"make output.txt\")"      echo "  (-optfile|-of) STRING    list of optfiles to use"
25      echo "  (-m|-make)STRING         command to use for \"make\""      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 "  (-clean)                 *ONLY* run \"make CLEAN\""      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"
52        echo "                             (DEF=\"hostname\")"
53        echo "  (-addr|-a) STRING        list of email recipients"
54        echo "                             (DEF=\"\" no email is sent)"
55        echo "  (-send)       STRING     sending command (instead of using mpack)"
56        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"
71      echo      echo
72      echo "and where STRING follows a whitespace-delimited format"      echo "and where STRING can be a whitespace-delimited list"
73      echo "such as:"      echo "such as:"
74        echo
75      echo "  -t 'exp0 exp2 exp3' "      echo "  -t 'exp0 exp2 exp3' "
76      echo "  -addr='abc@123.com testing@home.org'"      echo "  -addr='abc@123.com testing@home.org'"
77      echo      echo
78        echo "provided that the expression is properly quoted within the current"
79        echo "shell (note the use of single quotes to protect white space)."
80        echo
81      exit 1      exit 1
82  }  }
83    
84  #  build the mpack utility  #  build the mpack utility
85  build_mpack()  build_mpack()
86  {  {
87      echo -n "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
92              echo "Error: can't find \"$MPACKDIR\""              echo "Error: can't find \"$MPACKDIR\""
93              echo "  are you sure this program is being run in the correct "              echo "  are you sure this program is being run in the correct "
94              echo "  (that is, \"MITGCM_ROOT\verification\") directory?"              echo "  (that is, \"MITGCM_ROOT\verification\") directory?"
95              exit 1              echo
96                HAVE_MPACK=f
97            fi
98            if test "x$CC" = x ; then
99                export CC=cc
100          fi          fi
101          echo -n "building mpack...  "          printf "building mpack (using CC=$CC)...  "
102          ( cd $MPACKDIR && ./configure && $MAKE ) > 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
105              echo              echo
106              echo "Error building the mpack tools at: $MPACK_DIR"              echo "Error building the mpack tools at: $MPACK_DIR"
107              exit 1              echo
108                HAVE_MPACK=f
109            else
110                rm -f tr_build_mpack.out
111                HAVE_MPACK=t
112                echo "done"
113          fi          fi
114        else
115            HAVE_MPACK=t
116            echo "already exist"
117      fi      fi
     echo "OK"  
 }  
   
 compare_lines()  
 {  
     # use codelet to compare lines  
     if [ $verbose -gt 1 ]; then  
         cat tmp3.txt 1>&2  
     fi  
     return `./a.out < tmp3.txt`  
118  }  }
119    
120  testoutput_for_prop()  testoutput_var()
121  {  {
122      # testoutput_for_prop dir s1 label subdir      # 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/.*=//' | nl > tmp1.txt          grep "$2" $1/$4/$OUTPUTFILE | sed 's/.*=//' | cat -n > ${TMP}a.txt
133          lncnt=`wc -l tmp1.txt | awk '{print $1}' `          lncntA=`wc -l ${TMP}a.txt | awk '{print $1}' `
134          if [ $lncnt -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 1>&2          echo testoutput_var: grep "$2" $1/$5 1>&2
146      fi      fi
147      grep "$2" $1/results/output.txt | sed 's/.*=//' | nl > tmp2.txt      grep "$2" $1/$5 | sed 's/.*=//' | cat -n > ${TMP}b.txt
148      lncnt=`wc -l tmp2.txt | awk '{print $1}' `      lncntB=`wc -l ${TMP}b.txt | awk '{print $1}' `
149      if [ $lncnt -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
155        if [ $lncntA -ne $lncntB ]; then
156            if [ $verbose -gt 0 ]; then
157                echo Not same Nb of lines when searching for "$2" ":" $lncntA $lncntB 1>&2
158            fi
159            rm -f ${TMP}a.txt ${TMP}b.txt ; return 99
160        fi
161        has_nan=`cat ${TMP}a.txt | grep -i nan | wc -l`
162        if [ $has_nan -gt 0  ] ; then
163            echo testoutput_var: $OUTPUTFILE contains $has_nan NaN values  1>&2
164            rm -f ${TMP}a.txt ${TMP}b.txt ; return 99
165        fi
166        has_inf=`cat ${TMP}a.txt | grep -i inf | wc -l`
167        if [ $has_inf -gt 0  ] ; then
168            echo testoutput_var: $OUTPUTFILE contains $has_inf Inf values  1>&2
169            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      compare_lines      if [ $verbose -gt 1 ]; then
180      digits_of_similarity=$?          cat ${TMP}c.txt 1>&2
181        fi
182        echo "-1" >> ${TMP}c.txt
183        digits_of_similarity=`./tr_cmpnum < ${TMP}c.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 tmp1.txt tmp2.txt tmp3.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()            ptr_mon="$ptr_mon trcstat_ptracerXX_mean trcstat_ptracerXX_sd"
238  {            for ii in $PTRACERS_NUM ; do
239      # testoutput diretory subdir              ptrfound=0
240      #              for jj in $ptr_mon ; do
241      #  test output in "directory"                  name=`eval "echo $jj | sed -e 's|XX|0"$ii"|g'"`
242                    tst=`grep $name $1/$refoutp | wc -l | awk '{print $1}'`
243                    if test ! "x$tst" = x0 ; then ptrfound=1 ; fi
244                done
245                if test $ptrfound = '1' ; then
246                    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
253              # eval 'echo "HAVE_PTR0'$ii' = $HAVE_PTR0'$ii'"' 1>&2
254              done
255            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              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              echo "==> WARNING: in checked list:" $listVar 1>&2
261            #- put it back once:
262              listVar=" $sVar "`echo "$listVar " | sed "s/ $sVar / /g"`
263            fi
264            if [ $debug -gt 0 ]; then echo "testoutput_run: listVar(M)='$listVar'" 1>&2 ; fi
265            echo "listVar='$listVar'" >> $locDIR"/summary.txt"
266            #---
267            allargs=""
268            for xx in $listVar
269            do
270              case $xx in
271               'PS')  if [ $debug -gt 0 ]
272                      then echo testoutput_run: testoutput_var $1 cg2d_init_res 1>&2 ; fi
273                      testoutput_var $1 "cg2d_init_res" "Press. Solver (cg2d)" $2 $refoutp ; yy=$?
274                      if [ $debug -gt 0 ] ; then echo testoutput_run: cg2dres=$yy 1>&2 ; fi ;;
275              'Cost') testoutput_var $1 "ADM  ref_cost_function" "ADM CostFct" $2 $refoutp ; yy=$? ;;
276             'AdGrd') testoutput_var $1 "ADM  adjoint_gradient"  "ADM Ad Grad" $2 $refoutp ; yy=$? ;;
277             'FDGrd') testoutput_var $1 "ADM  finite-diff_grad"  "ADM FD Grad" $2 $refoutp ; yy=$? ;;
278            'tlmCst') testoutput_var $1 "TLM  ref_cost_function" "TLM CostFct" $2 $refoutp ; yy=$? ;;
279            'tlmGrd') testoutput_var $1 "TLM  tangent-lin_grad"  "TLM TL Grad" $2 $refoutp ; yy=$? ;;
280            'fwdGrd') testoutput_var $1 "TLM  finite-diff_grad"  "TLM FD Grad" $2 $refoutp ; yy=$? ;;
281               'Tmn') testoutput_var $1 "dynstat_theta_min"  "Theta minimum"  $2 $refoutp ; yy=$? ;;
282               'Tmx') testoutput_var $1 "dynstat_theta_max"  "Theta maximum"  $2 $refoutp ; yy=$? ;;
283               'Tav') testoutput_var $1 "dynstat_theta_mean" "Theta mean"     $2 $refoutp ; yy=$? ;;
284               'Tsd') testoutput_var $1 "dynstat_theta_sd"   "Theta Std.Dev"  $2 $refoutp ; yy=$? ;;
285               'Smn') testoutput_var $1 "dynstat_salt_min"  "Salt minimum"    $2 $refoutp ; yy=$? ;;
286               '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               'Ssd') testoutput_var $1 "dynstat_salt_sd"   "Salt Std.Dev"    $2 $refoutp ; yy=$? ;;
289               'Umn') testoutput_var $1 "dynstat_uvel_min"  "U minimum"       $2 $refoutp ; yy=$? ;;
290               'Umx') testoutput_var $1 "dynstat_uvel_max"  "U maximum"       $2 $refoutp ; yy=$? ;;
291               'Uav') testoutput_var $1 "dynstat_uvel_mean" "U mean"          $2 $refoutp ; yy=$? ;;
292               'Usd') testoutput_var $1 "dynstat_uvel_sd"   "U Std.Dev"       $2 $refoutp ; yy=$? ;;
293               'Vmn') testoutput_var $1 "dynstat_vvel_min"  "V minimum"       $2 $refoutp ; yy=$? ;;
294               'Vmx') testoutput_var $1 "dynstat_vvel_max"  "V maximum"       $2 $refoutp ; yy=$? ;;
295               'Vav') testoutput_var $1 "dynstat_vvel_mean" "V mean"          $2 $refoutp ; yy=$? ;;
296               'Vsd') testoutput_var $1 "dynstat_vvel_sd"   "V Std.Dev"       $2 $refoutp ; yy=$? ;;
297            'pt1mn'|'pt2mn'|'pt3mn'|'pt4mn'|'pt5mn') ii=`echo $xx | sed 's/pt//' | sed 's/..$//'`
298               testoutput_var $1 "trcstat_ptracer0"$ii"_min"  "p0"$ii"_min"   $2 $refoutp ; yy=$? ;;
299            'pt1mx'|'pt2mx'|'pt3mx'|'pt4mx'|'pt5mx') ii=`echo $xx | sed 's/pt//' | sed 's/..$//'`
300               testoutput_var $1 "trcstat_ptracer0"$ii"_max"  "p0"$ii"_max"   $2 $refoutp ; yy=$? ;;
301            'pt1av'|'pt2av'|'pt3av'|'pt4av'|'pt5av') ii=`echo $xx | sed 's/pt//' | sed 's/..$//'`
302               testoutput_var $1 "trcstat_ptracer0"$ii"_mean" "p0"$ii"_mean" $2 $refoutp ; yy=$? ;;
303            'pt1sd'|'pt2sd'|'pt3sd'|'pt4sd'|'pt5sd') ii=`echo $xx | sed 's/pt//' | sed 's/..$//'`
304               testoutput_var $1 "trcstat_ptracer0"$ii"_sd"   "p0"$ii"_StDv"  $2 $refoutp ; yy=$? ;;
305             'Qntmn') testoutput_var $1 "forcing_qnet_min" "Qnet minimum"  $2 $refoutp ; yy=$? ;;
306             '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
341    
342      if [ $debug -gt 0 ]; then          nbVar=`echo $listVar | awk '{print NF}'`
343          echo testoutput: testoutput_for_prop $1 cg2d_init_res 1>&2          if [ $nbVar -lt $LEN_CHECK_LIST ] ; then
344      fi          #-- fill line (up to standard length) with dot:
345      testoutput_for_prop $1 "cg2d_init_res" "cg2d init. residual" $2; cg2dres=$?            adNul=`expr $LEN_CHECK_LIST - $nbVar | awk '{for(i=1;i<=$1;i++){print "."}}'`
346      if [ $debug -gt 0 ]; then            echo $allargs $adNul
347          echo testoutput: cg2dres=$cg2dres 1>&2          else
348      fi            echo $allargs
349                fi
350      testoutput_for_prop $1 "dynstat_theta_min" "theta minimum" $2; tmin=$?  # <-- same processing for adjoint & forward test
     testoutput_for_prop $1 "dynstat_theta_max" "theta maximum" $2; tmax=$?  
     testoutput_for_prop $1 "dynstat_theta_mean" "theta mean" $2; tmean=$?  
     testoutput_for_prop $1 "dynstat_theta_sd" "theta s.d." $2; tsd=$?  
     testoutput_for_prop $1 "dynstat_salt_min" "salt minimum" $2; smin=$?  
     testoutput_for_prop $1 "dynstat_salt_max" "salt maximum" $2; smax=$?  
     testoutput_for_prop $1 "dynstat_salt_mean" "salt mean" $2; smean=$?  
     testoutput_for_prop $1 "dynstat_salt_sd" "salt s.d." $2; ssd=$?  
     testoutput_for_prop $1 "dynstat_uvel_min" "U minimum" $2; umin=$?  
     testoutput_for_prop $1 "dynstat_uvel_max" "U maximum" $2; umax=$?  
     testoutput_for_prop $1 "dynstat_uvel_mean" "U mean" $2; umean=$?  
     testoutput_for_prop $1 "dynstat_uvel_sd" "U s.d." $2; usd=$?  
     testoutput_for_prop $1 "dynstat_vvel_min" "V minimum" $2; vmin=$?  
     testoutput_for_prop $1 "dynstat_vvel_max" "V maximum" $2; vmax=$?  
     testoutput_for_prop $1 "dynstat_vvel_mean" "V mean" $2; vmean=$?  
     testoutput_for_prop $1 "dynstat_vvel_sd" "V s.d." $2; vsd=$?  
       
     dashnum $cg2dres $tmin $tmax $tmean $tsd $smin $smax $smean $ssd \  
         $umin $umax $umean $usd $vmin $vmax $vmean $vsd  
351  }  }
352    
353  genmakemodel()  genmakemodel()
# Line 184  genmakemodel() Line 356  genmakemodel()
356      if test "x$NOGENMAKE" = xt ; then      if test "x$NOGENMAKE" = xt ; then
357          echo "genmake skipped!"          echo "genmake skipped!"
358      else      else
359          GENMAKE2="$BASH ../../../tools/genmake2"          if test "x$BASH" = x ; then
360                GENMAKE2="../../../tools/genmake2"
361            else
362                GENMAKE2="$BASH ../../../tools/genmake2 -bash $BASH"
363            fi
364          (          (
365              cd $1;              cd $1;
366              command="$GENMAKE2  -ds -m $MAKE --mods=../code"              command="$GENMAKE2  -ds -m $MAKE"
367                if test "x$MKDEPEND" != x ; then
368                    command="$command -makedepend=$MKDEPEND"
369                fi
370                if test $KIND = 1 -o $KIND = 2 ; then
371                    command="$command --mods=../code_ad"
372                elif test $KIND = 4 ; then
373                    command="$command -adof ../../../tools/adjoint_options/adjoint_oad -mods ../code_oad"
374                else
375                    command="$command -mods=../code"
376                fi
377              if test "x$OPTFILE" != xNONE ; then              if test "x$OPTFILE" != xNONE ; then
378                  command="$command --optfile=$OPTFILE"                  command="$command -optfile=$OPTFILE"
                 # echo "  command=\"$command\""  
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              # echo "command: \"$command\""              if test $OptLev = 0 ; then
384              printf 'genmake ... ' 1>&2                  command="$command -devel"
385              $command > make.log 2>&1              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"
391                fi
392                if test "x$MULTI_THREAD" = xt ; then
393                #- 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              for i in genmake_state genmake_optfile genmake_local Makefile ; do              #  Reduce the size of the testing emails!
416                  if test -r $i ; then              head -100 Makefile > $CDIR/Makefile_head
                     cp $i $CDIR  
                 fi  
             done  
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 make.log $CDIR                  cp genmake.log genmake_* genmake.tr_log $CDIR
421                  return 1                  return 1
422              else              else
423                  echo "succesful" 1>&2                  echo "successful"
424              fi              fi
425          )          )
426      fi      fi
# Line 219  genmakemodel() Line 429  genmakemodel()
429  makeclean()  makeclean()
430  {  {
431      # makeclean directory      # makeclean directory
432        if test "x$NOGENMAKE" = 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 succesful 1>&2  
453              exit 0              exit 0
454          )          )
455      fi      fi
456  }  }
457    
458    run_clean()
459    {
460        # run_clean directory
461        if test "x$NOCLEAN" = xt ; then
462            echo "run_clean skipped!"
463        else
464          (
465            cd $1;
466            printf 'clean run-dir ... '
467            # 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
482    }
483    
484  makedependmodel()  makedependmodel()
485  {  {
486      # makedependmodel directory      # makedependmodel directory
# Line 252  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 succesful 1>&2                  echo successful
502              fi              fi
503          )          )
504      fi      fi
# Line 271  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              $MAKE >> make.log 2>&1              if test "x$REPLMAKE" = x ; then
525                    $MAKE $TARG >> make.tr_log 2>&1
526                else
527                    $REPLMAKE $TARG >> make.tr_log 2>&1
528                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 succesful 1>&2                  echo successful
539              fi              fi
540            else
541                echo "no Makefile !"
542                mk_fail=2
543          fi          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
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()
650    {
651        # Put special links so that MPI specific files are used
652        # This MUST be invoked between makeclean and makelinks because
653        # the Makefile will link to non-mpi files by default
654    
655        dir=$1
656        code_dir=$2
657        build_dir=$dir/$3
658    
659        # These are files that should replace their counter-part when using -mpi
660        MPI_FILES=`(cd $dir/$code_dir; find . -name "*_mpi" -print)`
661    
662        for ii in $MPI_FILES ; do
663            i=`echo $ii | sed 's:^\./::'`
664            name=`echo $i | sed 's:_mpi::'`
665            file="../$code_dir/$i"
666            if test $name = 'SIZE.h' ; then file="SIZE.h.mpi" ; fi
667    
668            #  Is this an MPI run?
669            if test "x$MPI" = x0 ; then
670                # NO: We undo any _mpi symbolically linked files
671                if test -L $build_dir/$name ; then
672                    ( cd $build_dir ; cmp $name $file > /dev/null 2>&1 )
673                    RETVAL=$?
674                    if test "x$RETVAL" = x0 ; then
675                        if [ $verbose -gt 1 ]; then
676                            echo "  Un-linking $name from ../$code_dir" ; fi
677                        rm -f $build_dir/$name
678                    fi
679                fi
680            else
681                # 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 [ $1 -ne 0 ]; then      if test -d $1 ; then
703          ( cd $2 ;  ln -sf ../input/* . )          (
704                cd $1 ; shift
705                echo 'linkdata from dirs:' $*
706                inpMPI=`(cd ../$1 ; find . -name "*.mpi" -print | sed 's:^\./::')`
707                for xx in $inpMPI ; do
708                  if test -r "../"$1"/"$xx ; then
709                    # found 1 _mpi sfx file in 1rst input dir and it is readable
710                    yy=`echo $xx | sed 's:\.mpi$::'`
711                    if test "x$MPI" = "x0" ; then
712                        # not mpi test: remove symbolic link
713                        if test -h $yy ; then rm -f $yy ; fi
714                    else
715                        # mpi test: remove symbolic link & link .mpi sfx file
716                        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
721                    fi
722                  fi
723                done
724                if test -r "../"$1"/eedata.mth" ; then
725                # 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
733                    else
734                    # not multi-threaded test: remove eedata symbolic link
735                        if test -h eedata ; then rm -f eedata ; fi
736                    fi
737                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  }  }
763    
# Line 302  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: ' 1>&2          printf 'runmodel in %s ... ' $1
773          # make output.txt          if test "x$MPI" != x0 ; then
774          $COMMAND              #- adjust the MPI run command with the right number of Procs
775          RETVAL=$?              #echo '' ; echo "  COMMAND='$COMMAND'"
776          if test "x$RETVAL" = x0 ; then              COMMAND=`echo $COMMAND | sed "s/ TR_NPROC / $LOC_NPROC /"`
777              cp output.txt $CDIR"/output.txt"              if test "x$MPI_MFILE" != x ; then
778                  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
800              if test ! -f $OUTPUTFILE -o $OUTPUTFILE -ot $EXECUTABLE ; then
801                # 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
845            if test -s STDERR.0000 ; then cp STDERR.0000 $CDIR"/STDERR.0000" ; fi
846            if [ $RETVAL -eq 0 -a $ENDVAL -gt 0 ] ; then
847                echo successful
848                printf '=> output from running in %s :\n' $1 1>&2
849                tail $RUNLOG | sed 's/^.*/> &/g' 1>&2
850                return 0
851            elif [ $RETVAL -ne 0 -a $ENDVAL -gt 0 ] ; then
852                #-- for some weird cases (run is finihed but with error code)
853                echo 'finished with error (run:' $RETVAL ' end:' $ENDVAL ')'
854                printf '=> output from running in %s :\n' $1 1>&2
855                tail $RUNLOG | sed 's/^.*/> &/g' 1>&2
856              return 0              return 0
857          else          else
858                echo 'failed (run:' $RETVAL ' end:' $ENDVAL ')'
859                printf '=> output from running in %s :\n' $1 1>&2
860                tail $RUNLOG | sed 's/^.*/> &/g' 1>&2
861                cp $RUNLOG $CDIR"/"$RUNLOG
862              return 1              return 1
863          fi          fi
864      )      )
# Line 323  createcodelet() Line 868  createcodelet()
868  {  {
869      # create codelet for comparing model output      # create codelet for comparing model output
870    
871      echo -n "creating the comparison code...  "      printf "creating the comparison code (using CC=$CC)...  "
872      cat > tmp_cmpnum.f <<EOFA      cat > tr_cmpnum.c <<EOF
873        program cmpnum  #include <stdio.h>
874        implicit none  #include <math.h>
875        real*8 a,b,diff  int main( int argc, char** argv )  {
876        integer linnum,best    int linnum,cmplin,best,lncnt;
877        best=-16    double a,b,abave,relerr;
878    99  read(*,*,end=70,err=60) linnum,a,b    best = -22;
879        diff=0.5*(abs(a)+abs(b))    lncnt = 0;
880  c     print *,a,b,diff,abs(a-b)/diff    while( 1 & ( (lncnt+=1) < 999 ) )  {
881        if (diff.gt.1.e-12) then      scanf("%d", &linnum);
882          diff=abs(a-b)/diff      if (linnum == -1)  break;
883          if (diff.gt.0.) then      scanf("%lf", &a);  scanf("%lf", &b);
884  c         print *,int(log10(diff)),diff      abave = 0.5*(fabs(a)+fabs(b));
885            linnum=int(log10(diff))      if ( abave == abave ) {
886            best=max(best,linnum)        if (abave > 0.0) {
887          endif          relerr=fabs(a-b)/abave;
888        else          if (relerr > 0.0) { cmplin = (int)rint(log10(relerr)); }
889          if (best.eq.-16.and.diff.ne.0.) best=-22          else { cmplin = -16 ; }
890        endif          best = (best > cmplin) ? best : cmplin; }
891        goto 99        else { cmplin = -22 ; }
892    60  stop 'cmpnum: An error occured reading a,b'     /* printf("%d ; %lf ; %lf\n",cmplin,a,b); */
893    70  print *,-best        }
894        end     else {
895  EOFA     /* printf("%lf ; %lf ; %lf\n",abave,a,b); */
896          break; }
897      }
898      if (lncnt == 999) best=-29;
899      if (linnum != -1) best=-99;
900      printf("%d\n", -best);
901      return 0;
902    }
903    EOF
904        $CC -o tr_cmpnum tr_cmpnum.c -lm
905    
906      f77 tmp_cmpnum.f      if [ -x ./tr_cmpnum ]; then
     if [ -x ./a.out ]; then  
907          echo "OK"          echo "OK"
908          return 0          return 0
909      else      else
910          echo          echo
911          echo "createcodelet: failed to compile codelet"          echo "ERROR: failed to compile comparison code -- please specify"
912            echo "  a C compiler using the CC environment variable."
913          exit 1          exit 1
914      fi      fi
915  }  }
# Line 367  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=  
 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=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  MPACK="$MPACKDIR/mpack"  HAVE_MPACK=
1036  COMMAND="make output.txt"  MPACK=
1037  MAKE=make  SENDCMD=
1038  MPI=f  SAVDIR='.'
1039    COMMAND=
1040    MKDEPEND=
1041    if test "x$MAKE" = x ; then
1042        MAKE=make
1043    fi
1044    REPLMAKE=
1045    if test "x$CC" = x ; then
1046        CC=cc
1047    fi
1048    JOBS=
1049    TARG=
1050    MPI=0
1051    MPI_MFILE=
1052    MULTI_THREAD=f
1053    OUTDIR=
1054    DELDIR=
1055    USE_R4=
1056    EXTRFLG=
1057    
1058    #- 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    # list of pTracers to check for monitor output
1064    PTRACERS_NUM="1 2 3 4 5"
1065    
1066    MATCH_CRIT=10
1067    
1068  echo -n "parsing options...  "  printf "parsing options...  "
1069    
1070  ac_prev=  ac_prev=
1071  for ac_option ; do  for ac_option ; do
# Line 461  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 ;;  
   
         -clean | --clean)  
             CLEANUP=t ;;  
   
         -quick | --quick | -q | --q)  
             QUICK=t ;;  
         -nogenmake | --nogenmake | -ng | --ng)  
             NOGENMAKE=t ;;  
         -noclean | --noclean | -nc | --nc)  
             NOCLEAN=t ;;  
         -nodepend | --nodepend | -nd | --nd)  
             NODEPEND=t ;;  
1085    
1086          -mpi) MPI=true ;;          -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 ;;
1176          -quiet) verbose=0 ;;          -quiet) verbose=0 ;;
1177    
1178          -*)          -deldir | -dd) DELDIR=t ;;
1179              echo "Error: unrecognized option: "$ac_option  
1180              usage          -use_r4|-ur4) USE_R4=t ;;
1181              ;;  
1182                    -ts) TS=t;;
1183          *)          -papis) PAPIS=t;;
1184              echo "Error: unrecognized argument: "$ac_option          -pcls) PCL=t;;
1185              usage  
1186              ;;          -*) echo "Error: unrecognized option: "$ac_option
1187                        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 538  if test "x$QUICK" = xt ; then Line 1198  if test "x$QUICK" = xt ; then
1198      NODEPEND=t      NODEPEND=t
1199  fi  fi
1200    
1201    #- check length of MPI machine file:
1202    if test "x$MPI" != x0 -a "x$MPI_MFILE" != x ; then
1203        if test -r $MPI_MFILE ; then
1204            nl=`wc -l $MPI_MFILE | awk '{print $1}'`
1205            if [ $nl -lt $MPI ] ; then
1206              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
1217    
1218    #- 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"
1237    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"
1243    fi
1244    
1245    xx=`echo $TESTDIRS | awk '{print $1}'`
1246  if test "x$TESTDIRS" = x ; then  if test "x$TESTDIRS" = x ; then
1247      TESTDIRS=`scandirs`      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  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  if test "x$OPTFILE" = xNONE -a "x$MITGCM_OF" != x ; then
1291      OPTFILE=$MITGCM_OF      OPTFILE=$MITGCM_OF
1292  fi  fi
1293    
1294  echo "OK"  LOC_MFILE='tr_mpi_mfile'
1295    RUNLOG="run.tr_log"
1296    OUTPUTFILE=$ref_outp
1297    if test "x$COMMAND" = x ; then
1298        COMMAND="./$EXECUTABLE > $OUTPUTFILE"
1299    fi
1300    if test "x$MPI" != x0 ; then
1301        OUTPUTFILE="STDOUT.0000"
1302    fi
1303    
1304    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  build_mpack  if test "x$ADDRESSES" = x -o "x$SENDCMD" != x ; then
1347        echo "skipping mpack build"
1348    else
1349        build_mpack
1350        if test "x$HAVE_MPACK" = xt ; then SENDCMD=$MPACK ; fi
1351    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=$MACH"_"$DATE"_"  BASE="tr_"$MACH"_"$DATE"_"
1368    if test "x$OUTDIR" != x ; then
1369        BASE="tr_"$OUTDIR"_"$DATE"_"
1370    else
1371        short_name=`hostname | sed 's/\..*$//'`
1372        BASE="tr_"$short_name"_"$DATE"_"
1373    fi
1374  DNUM=0  DNUM=0
1375  DRESULTS="$BASE$DNUM"  DRESULTS="$BASE$DNUM"
1376  while test -e $DRESULTS ; do  while test -e $DRESULTS ; do
# Line 568  done Line 1380  done
1380  mkdir $DRESULTS  mkdir $DRESULTS
1381  RETVAL=$?  RETVAL=$?
1382  if test "x$RETVAL" != x0 ; then  if test "x$RETVAL" != x0 ; then
1383      echo "Error: can't create results directory \"./$DRESULTS\""      echo "ERROR: Can't create results directory \"./$DRESULTS\""
1384      exit 1      exit 1
1385  fi  fi
1386  SUMMARY="$DRESULTS/summary.txt"  SUMMARY="$DRESULTS/summary.txt"
1387  date > $SUMMARY  start_date=`date`
1388  cat << EOF >> $SUMMARY  echo $start_date > $SUMMARY
1389                  T           S           U           V  echo 'run:' $CMDLINE >> $SUMMARY
1390  G D M    c        m  s        m  s        m  s        m  s  echo 'on :' $UNAMEA  >> $SUMMARY
 E p a R  g  m  m  e  .  m  m  e  .  m  m  e  .  m  m  e  .  
 N n k u  2  i  a  a  d  i  a  a  d  i  a  a  d  i  a  a  d  
 2 d e n  d  n  x  n  .  n  x  n  .  n  x  n  .  n  x  n  .  
   
 EOF  
   
 NDIR=0  
1391    
1392  of_path=  of_path=
1393  if test "x$OPTFILE" != xNONE ; then  if test "x$OPTFILE" != xNONE ; then
# Line 596  if test "x$OPTFILE" != xNONE ; then Line 1401  if test "x$OPTFILE" != xNONE ; then
1401          fi          fi
1402          file=${OPTFILE##*/}          file=${OPTFILE##*/}
1403          OPTFILE=$of_path/$file          OPTFILE=$of_path/$file
1404            cp $OPTFILE $DRESULTS
1405            echo >> $SUMMARY
1406            echo "  OPTFILE=$OPTFILE" >> $SUMMARY
1407      else      else
1408          echo          echo | tee -a $SUMMARY
1409          echo "WARNING: can't read OPTFILE=\"$OPTFILE\" but will try to use it..."          echo "ERROR: can't read OPTFILE=\"$OPTFILE\"" | tee -a $SUMMARY
1410            exit 1
1411      fi      fi
1412    else
1413        echo >> $SUMMARY
1414        echo "No \"OPTFILE\" was specified ; genmake2 found and uses:" >> $SUMMARY
1415        #-note: to be filled later after 1rst run
1416  fi  fi
1417  echo  echo
 echo "OPTFILE=$OPTFILE" >> $SUMMARY  
1418  echo >> $SUMMARY  echo >> $SUMMARY
1419    if test $KIND = 0 ; then
1420        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"
1423        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"
1425        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
1427            line_0="$line_0  --PTR 0"$ii"--"
1428            line_1="$line_1        m  s"
1429            line_2="$line_2  m  m  e  ."
1430            line_3="$line_3  i  a  a  d"
1431            line_4="$line_4  n  x  n  ."
1432        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
1459        echo "$line_1" | tee -a $SUMMARY
1460        echo "$line_2" | tee -a $SUMMARY
1461        echo "$line_3" | tee -a $SUMMARY
1462        echo "$line_4" | tee -a $SUMMARY
1463        echo ""        | tee -a $SUMMARY
1464    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
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      if test ! -r $dir"/results/output.txt" ; then      fout=$dir"/results/"$ref_outp
1507          echo "can't read \"$dir/results/output.txt\" -- skipping $dir"     #if test ! -r $fout ; then
1508        if test ! -r $fout -a ! -r ${fout}.gz ; then
1509            echo "can't read \"$fout\" -- skipping $dir"
1510          continue          continue
1511      fi      fi
1512    
1513      echo "-------------------------------------------------------------------------------"      # Check for specific files for particular type of run
     echo  
     echo "Experiment:  $dir"  
     echo  
     unset genmake makedepend make run  
     results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --'  
1514    
1515      if [ -r $dir/build ]; then      if test ! -r $CODE_DIR"/SIZE.h_mpi"  -a "x$MPI" != "x0" ; then
1516          seperatebuilddir=1          echo "can't find \"$CODE_DIR/SIZE.h_mpi\" -- skipping $dir"
1517          builddir=build          continue
1518          rundir=build      fi
1519          ( cd $dir/build; ln -sf ../input/* . )      if test ! -r $dir"/input/eedata.mth" -a "x$MULTI_THREAD" = "xt" ; then
1520      else          echo "can't find \"$dir/input/eedata.mth\" -- skipping $dir"
1521          seperatebuilddir=0          continue
         builddir=input  
         rundir=input  
1522      fi      fi
       
     CODE_DIR=$dir/code  
     BUILD_DIR=$dir/$builddir  
     MPI_FILES="CPP_EEOPTIONS.h_mpi SIZE.h_mpi"  
     NOMPI_FILES="CPP_EEOPTIONS.h_nompi SIZE.h_nompi"  
1523    
1524      #  Is this an MPI run?      if test "x$MPI" != "x0" ; then
1525      if test "x$MPI" = xt ; then          ntx=1 ; nty=1
1526          FILES=$MPI_FILES          if test "x$MULTI_THREAD" = "xt" ; then
1527          endings="_mpi"            ff=$dir"/input/eedata.mth"
1528      else            ntx=`grep "^ *nTx *=" $ff | tail -1 | sed 's/^ *nTx *= *//' | sed "s/, *$//"`
1529          FILES=$NOMPI_FILES            nty=`grep "^ *nTy *=" $ff | tail -1 | sed 's/^ *nTy *= *//' | sed "s/, *$//"`
1530          endings="_nompi"            if test "x$ntx" = x ; then ntx=1 ; fi
1531      fi            if test "x$nty" = x ; then nty=1 ; fi
1532                fi
1533      #  Check to see that we have the files          #- create new SIZE.h with no more than '$MPI' Procs
1534      have_files=t          mk_mpi_size $CODE_DIR"/SIZE.h_mpi" $BUILD_DIR"/tr_size.mpi" $MPI $ntx $nty
1535      for i in $FILES ; do          LOC_NPROC=$?
1536          if test ! -r $CODE_DIR/$i ; then          (   cd $BUILD_DIR
1537              echo "Warning: can't read file $CODE_DIR/$i"              if test -r SIZE.h.mpi ; then
1538              have_files=f                  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          fi
     done  
     if test "x$have_files" != xt -a "x$MPI" = xt ; then  
         echo "Skipping $dir due to lack of input files (see above warning)"  
         continue  
1569      fi      fi
1570        
1571      #  If we have the $FILES and they differ, copy the $FILES to $BUILD_DIR      #  Check whether there are "extra runs" for this testdir
1572      if test "x$have_files" = xt ; then      extra_runs=
1573          for i in $FILES ; do      if test "x$NORUN" = xf ; then
1574              sstr="s|$endings||"          ex_run_dirs=`( cd $dir ; ls -d $inputdir.* 2> /dev/null )`
1575              name=`echo $i | sed -e $sstr `      fi
1576              cmp $CODE_DIR/$i $BUILD_DIR/$name > /dev/null 2>&1      #echo "ex_run_dirs='$ex_run_dirs'"
1577              RETVAL=$?      for exd in $ex_run_dirs ; do
1578              if test "x$RETVAL" != x0 ; then          name=`echo $exd | sed -e "s/$inputdir\.//"`
1579                  cp $CODE_DIR/$i $BUILD_DIR/$name          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              fi
1596          done            else
1597                extra_runs="$extra_runs $name"
1598              fi
1599            fi
1600        done
1601    
1602        echo
1603        if test "x$extra_runs" = "x" ; then
1604            echo "Experiment:  $dir"
1605        else
1606            echo "Experiment:  $dir ; extra_runs=$extra_runs"
1607      fi      fi
1608            echo
1609      #  Create an output dir for each OPTFILE/tdir combination      unset genmake makedepend make run
1610      CDIR=$DRESULTS"/"$DRESULTS"_"$NDIR      results=$EMPTY_RESULTS
1611      mkdir $CDIR  
1612      CDIR=`pwd`"/$CDIR"      #  Create an output dir & summary.txt file for each tested experiment (tdir)
1613            locDIR=$DRESULTS"/"$dir
1614      if test "x$CLEANUP" = xt ; then      mkdir $locDIR
1615          makeclean $dir/$builddir      #- report to this experiment local summary file ---
1616        echo "DATE='$DATE' ; tdir='$dir'" > $locDIR"/summary.txt"
1617        echo "MACH='$MACH'" >> $locDIR"/summary.txt"
1618        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 \
1632              && makedependmodel $dir/$builddir && makedepend=Y \              && makedependmodel $dir/$builddir && makedepend=Y \
1633              && makemodel $dir/$builddir && make=Y \              && makemodel $dir/$builddir && make=Y \
1634              && linkdata $seperatebuilddir $dir/$rundir \              && run_clean $dir/$rundir \
1635              && runmodel $dir/$builddir && run=Y \              && linkdata $dir/$rundir $inputdir \
1636              && results=`testoutput $dir $rundir`              && runmodel $dir/$rundir && run=Y \
1637                && results=`testoutput_run $dir $rundir $ref_outp`
1638        fi
1639        #echo "results='$results'"
1640    
1641            fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results`
1642            echo 1>&2
1643            echo "$fres" | sed 's/ 99/ --/g' | sed 's/  > />/' | sed 's/  < /</' >> $SUMMARY
1644            echo "fresults='$fres'" | sed 's/ 99/ --/g' >> $locDIR"/summary.txt"
1645    
1646            for ex in $extra_runs ; do
1647                unset run
1648                results=$EMPTY_RESULTS
1649                #  reference output file
1650                refExOut=`echo $ref_outp | sed "s/\./.${ex}./g"`
1651                #  Create an output dir & summary.txt file for each extra run (tdir.ex)
1652                locDIR=$DRESULTS"/"$dir"."$ex
1653                mkdir $locDIR
1654                #- report to this experiment local summary file ---
1655                echo "DATE='$DATE' ; tdir='$dir.$ex'" > $locDIR"/summary.txt"
1656                #echo "MACH='$MACH'" >> $locDIR"/summary.txt"
1657                #echo "UNAMEA='$UNAMEA'" >> $locDIR"/summary.txt"
1658                CDIR=`pwd`"/$locDIR"
1659                test ! -e "$dir/$pfxdir.$ex" && mkdir "$dir/$pfxdir.$ex"
1660                run_clean $dir/$pfxdir.$ex
1661                linkdata $dir/$pfxdir.$ex $inputdir.$ex $inputdir
1662                runmodel $dir/$pfxdir.$ex && run=Y \
1663                && results=`testoutput_run $dir $pfxdir.$ex $refExOut`
1664                fres=`formatresults $dir.$ex ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results`
1665                echo 1>&2
1666                echo "$fres" | sed 's/ 99/ --/g' | sed 's/  > />/' | sed 's/  < /</' >> $SUMMARY
1667                echo "fresults='$fres'" | sed 's/ 99/ --/g' >> $locDIR"/summary.txt"
1668                if test "x$POSTCLEAN" = x2 ; then
1669                    run_clean $dir/$pfxdir.$ex
1670                fi
1671            done
1672    
1673        if test ! -f $DRESULTS"/"genmake_state ; then
1674            if test -f $dir/$builddir/Makefile ; then
1675                mkOpt=`grep '^# OPTFILE=' $dir/$builddir/Makefile 2>/dev/null | head -1 | sed 's/^# //'`
1676                echo "from '$dir/$builddir/Makefile', extract:" > $DRESULTS/genmake_state
1677                sed -n '/^# executed by:/,+1 p' $dir/$builddir/Makefile >> $DRESULTS/genmake_state
1678                echo " $mkOpt" >> $DRESULTS/genmake_state
1679                if test "x$OPTFILE" = xNONE ; then
1680                    eval $mkOpt
1681                    sed "/^No \"OPTFILE\" was specified ; genmake2/a\  OPTFILE=${OPTFILE}"\
1682                            $SUMMARY > tmp.tr_log
1683                    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      fi
1710            #postclean $dir/$builddir
1711      echo      if test "x$POSTCLEAN" = x2 ; then
1712      formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \          makeclean $dir/$builddir \
1713          ${run:-N} $results              && run_clean $dir/$rundir
1714      echo      fi
1715      formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \      if test "x$MPI" != x0 -a "x$MPI_MFILE" != x ; then rm -f $LOC_MFILE ; fi
1716          ${run:-N} $results >> $SUMMARY  
1717      echo "fresults='" > $CDIR"/summary.txt"      echo "-------------------------------------------------------------------------------"
1718      formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \  
1719          ${run:-N} $results >> $CDIR"/summary.txt"  done
1720      echo "'" >> $CDIR"/summary.txt"  
1721      echo "MACH='$MACH'" >> $CDIR"/summary.txt"  printf "Start time:  " >> $SUMMARY
1722      echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"  echo "$start_date" >> $SUMMARY
1723      echo "DATE='$DATE'" >> $CDIR"/summary.txt"  printf "End time:    " >> $SUMMARY
1724      echo "tdir='$dir'" >> $CDIR"/summary.txt"  date >> $SUMMARY
1725        
1726      (  #  If addresses were supplied and mpack built successfully, then try
1727          cd $DRESULTS  #  to send email using mpack.
1728          tar -cf $NDIR".tar" $DRESULTS"_"$NDIR > /dev/null 2>&1  if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then
1729          gzip $NDIR".tar"      echo "No results email was sent."
1730      )  else
1731            if test "x$SENDCMD" != x ; then
1732      if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then          if [ $verbose -gt 1 ]; then
1733          echo "No mail sent"             echo " run: $SENDCMD -s MITgcm-test -m 3555000 ${SAVDIR}/${DRESULTS}".tar.gz" $ADDRESSES"
1734      else          fi
1735          $MPACK -s MITgcm-test -m 1000000 $DRESULTS"/"$NDIR".tar.gz" $ADDRESSES          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 "Warning: \"$MPACK\" failed -- please contact <edhill@mitgcm.org>"              echo
1741                echo "Warning: The tar, gzip, & mpack step failed.  Please send email"
1742                echo "  to <MITgcm-support@mitgcm.org> for help.  You may copy the "
1743                echo "  summary of results from the directory \"$DRESULTS\"."
1744                echo
1745          else          else
1746              rm -f $DRESULTS"/"$NDIR".tar*"              echo
1747                echo "An email containing results was sent to the following addresses:"
1748                echo "  \"$ADDRESSES\""
1749                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
1753      fi      fi
1754    fi
1755    
1756      echo "-------------------------------------------------------------------------------"  if test "x$QUICK" = xf -a "x$NORUN" = xf ; then
1757            rm -f tr_cmpnum.c tr_cmpnum
1758      NDIR=$(( $NDIR + 1 ))  fi
       
 done  
   
 rm tmp_cmpnum.f a.out  
1759    
1760  cat $SUMMARY  if test "x$CLEANUP" != xt ; then
1761        cat $SUMMARY | sed 's/ \.  \.  \.  \.  \.  \.  \.  \.  \.  \.  \.  \. //'
1762        if test -e tr_out.txt ; then
1763            mv tr_out.txt tr_out.txt.old
1764        fi
1765        cat $SUMMARY | sed '/^[YN] [YN] [YN] [YN]/ s/ \. //g' > tr_out.txt
1766    fi
1767    
1768    if test "x$DELDIR" = xt ; then
1769        rm -rf $DRESULTS
1770    fi
1771    echo "======== End of testreport execution ========"

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.194

  ViewVC Help
Powered by ViewVC 1.1.22