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

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.169

  ViewVC Help
Powered by ViewVC 1.1.22