/[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.170 by mlosch, Thu Dec 22 12:55:05 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             'uSImn') testoutput_var $1 "seaice_uice_min"   "SIce Uice min"   $2 $3; yy=$? ;;
294             'uSImx') testoutput_var $1 "seaice_uice_max"   "SIce Uice max"   $2 $3; yy=$? ;;
295             'uSIav') testoutput_var $1 "seaice_uice_mean"  "SIce Uice mean"  $2 $3; yy=$? ;;
296             'uSIsd') testoutput_var $1 "seaice_uice_sd"    "SIce Uice StDv"  $2 $3; yy=$? ;;
297             'vSImn') testoutput_var $1 "seaice_vice_min"   "SIce Vice min"   $2 $3; yy=$? ;;
298             'vSImx') testoutput_var $1 "seaice_vice_max"   "SIce Vice max"   $2 $3; yy=$? ;;
299             'vSIav') testoutput_var $1 "seaice_vice_mean"  "SIce Vice mean"  $2 $3; yy=$? ;;
300             'vSIsd') testoutput_var $1 "seaice_vice_sd"    "SIce Vice StDv"  $2 $3; yy=$? ;;
301            'AthSiG') testoutput_var $1 "thSI_Ice_Area_G" "thSIc Area Global" $2 $3; yy=$? ;;
302            'AthSiS') testoutput_var $1 "thSI_Ice_Area_S" "thSIc Area South"  $2 $3; yy=$? ;;
303            'AthSiN') testoutput_var $1 "thSI_Ice_Area_N" "thSIc Area North"  $2 $3; yy=$? ;;
304            'HthSiG') testoutput_var $1 "thSI_IceH_ave_G" "thSIc H Global"    $2 $3; yy=$? ;;
305            'HthSiS') testoutput_var $1 "thSI_IceH_ave_S" "thSIc H South"     $2 $3; yy=$? ;;
306            'HthSiN') testoutput_var $1 "thSI_IceH_ave_N" "thSIc H North"     $2 $3; yy=$? ;;
307                  *) yy=99; echo "WARNING: asking for var=$xx : not recognized !" 1>&2 ;;
308              esac
309              if test $xx = $sVar
310              then allargs="$allargs > $yy <"
311              else allargs="$allargs $yy"
312              fi
313            done
314    
315            nbVar=`echo $listVar | awk '{print NF}'`
316            if [ $nbVar -lt $LEN_CHECK_LIST ] ; then
317            #-- fill line (up to standard length) with dot:
318              adNul=`expr $LEN_CHECK_LIST - $nbVar | awk '{for(i=1;i<=$1;i++){print "."}}'`
319              echo $allargs $adNul
320            else
321              echo $allargs
322            fi
323    # <-- same processing for adjoint & forward test
324  }  }
325    
326  genmakemodel()  genmakemodel()
# Line 183  genmakemodel() Line 329  genmakemodel()
329      if test "x$NOGENMAKE" = xt ; then      if test "x$NOGENMAKE" = xt ; then
330          echo "genmake skipped!"          echo "genmake skipped!"
331      else      else
332          GENMAKE2="$BASH ../../../tools/genmake2"          if test "x$BASH" = x ; then
333                GENMAKE2="../../../tools/genmake2"
334            else
335                GENMAKE2="$BASH ../../../tools/genmake2 -bash $BASH"
336            fi
337          (          (
338              cd $1;              cd $1;
339              command="$GENMAKE2  -ds -m $MAKE --mods=../code"              command="$GENMAKE2  -ds -m $MAKE"
340                if test "x$MKDEPEND" != x ; then
341                    command="$command -makedepend=$MKDEPEND"
342                fi
343                if test "x$ADM" = xt ; then
344                    command="$command --mods=../code_ad"
345                elif test "x$OADM" = xt ; then
346                    command="$command -adof ../../../tools/adjoint_options/adjoint_oad -mods '../code_oad ../../OpenAD/code_oad_all'"
347                else
348                    command="$command -mods=../code"
349                fi
350              if test "x$OPTFILE" != xNONE ; then              if test "x$OPTFILE" != xNONE ; then
351                  command="$command --optfile=$OPTFILE"                  command="$command -optfile=$OPTFILE"
352                  # echo "  command=\"$command\""              fi
353                if test $OptLev = 1 ; then
354                    command="$command -ieee"
355                fi
356                if test $OptLev = 0 ; then
357                    command="$command -devel"
358                fi
359                if test "x$GSL" = xt ; then
360                    command="$command -gsl"
361                fi
362                if test "x$MPI" != x0 ; then
363                    command="$command -mpi"
364                fi
365                if test "x$MULTI_THREAD" = xt ; then
366                #- run multi-threaded using OpenMP:
367                    command="$command -omp"
368                fi
369                if test "x$USE_R4" = xt ; then
370                    command="$command -use_r4"
371                fi
372                if test "x$EXTRFLG" != x ; then
373                    command="$command -extra_flag $EXTRFLG"
374                fi
375                if test "x$TS" = xt ; then
376                    command="$command -ts"
377                fi
378                if test "x$PAPIS" = xt ; then
379                    command="$command -papis"
380                else
381                if test "x$PCLS" = xt ; then
382                    command="$command -pcls"
383              fi              fi
             if test "x$IEEE" != x ; then  
                 command="$command -ieee"  
384              fi              fi
385              # echo "command: \"$command\""              printf 'genmake ... '
386              printf 'genmake ... ' 1>&2              eval $command > genmake.tr_log 2>&1
             $command > make.log 2>&1  
387              RETVAL=$?              RETVAL=$?
388              for i in genmake_state genmake_optfile genmake_local Makefile ; do              #  Reduce the size of the testing emails!
389                  if test -r $i ; then              head -100 Makefile > $CDIR/Makefile_head
                     cp $i $CDIR  
                 fi  
             done  
390              if test "x$RETVAL" != x0 ; then              if test "x$RETVAL" != x0 ; then
391                  tail make.log                  tail genmake.tr_log
392                  echo "genmakemodel: genmake failed" 1>&2                  echo "genmakemodel: genmake failed"
393                  cp make.log $CDIR                  cp genmake.log genmake_* genmake.tr_log $CDIR
394                  return 1                  return 1
395              else              else
396                  echo "succesful" 1>&2                  echo "successful"
397              fi              fi
398          )          )
399      fi      fi
# Line 218  genmakemodel() Line 402  genmakemodel()
402  makeclean()  makeclean()
403  {  {
404      # makeclean directory      # makeclean directory
405        if test "x$NODEPEND" = xf ; then rm -f $1/make.tr_log ; fi
406      if test "x$NOCLEAN" = xt ; then      if test "x$NOCLEAN" = xt ; then
407          echo "make CLEAN skipped!"          echo "make Clean skipped!"
408      else      else
409          (          (
410              cd $1;              cd $1;
411              if test -e output.txt ; then              #if test -e $OUTPUTFILE ; then rm -f $OUTPUTFILE ; fi
                 rm -f output.txt  
             fi  
             printf 'make CLEAN ... ' 2>&1  
412              if test -r Makefile ; then              if test -r Makefile ; then
413                  $MAKE CLEAN >> make.log 2>&1                  printf 'clean build-dir: make Clean ... '
414                    $MAKE Clean >> make.tr_log 2>&1
415                  RETVAL=$?                  RETVAL=$?
416                  if test "x$RETVAL" != x0 ; then                  if test "x$RETVAL" != x0 ; then
417                      tail make.log                      tail make.tr_log
418                      echo "makeclean: \"make CLEAN\" failed" 1>&2                      echo "makeclean: \"make Clean\" failed"
419                      cp make.log $CDIR"/make.log"                      cp make.tr_log genmake.log genmake.tr_log $CDIR
420                      return 1                      return 1
421                  fi                  fi
422                    echo successful
423                else
424                    echo ''
425              fi              fi
426              echo succesful 1>&2              exit 0
427            )
428        fi
429    }
430    
431    run_clean()
432    {
433        # run_clean directory
434        if test "x$NOCLEAN" = xt ; then
435            echo "run_clean skipped!"
436        else
437            (
438                cd $1;
439                printf 'clean run-dir ... '
440                # part of what is done after "make clean" when doing "make CLEAN"
441                find . -name "*.meta" -exec rm {} \;
442                find . -name "*.data" -exec rm {} \;
443                find . -name "fort.*" -exec rm {} \;
444                find . -type l -exec rm {} \;
445                #- should remove executable only if sym-link (alredy done above)
446                rm -f $RUNLOG *.txt STD* *diagnostics.log datetime
447                rm -rf mnc_test_*
448                rm -f *_MIT_CE_000.opt0000 costfunction*0000
449                echo successful
450              exit 0              exit 0
451          )          )
452      fi      fi
# Line 251  makedependmodel() Line 460  makedependmodel()
460      else      else
461          (          (
462              cd $1;              cd $1;
463              printf 'make depend ... ' 1>&2              printf 'make depend ... '
464              $MAKE depend >> make.log 2>&1              $MAKE depend >> make.tr_log 2>&1
465              RETVAL=$?              RETVAL=$?
466              if test "x$RETVAL" != x0 ; then              if test "x$RETVAL" != x0 ; then
467                  tail make.log                  tail make.tr_log
468                  echo "makedependmodel: make depend failed" 1>&2                  echo "makedependmodel: make depend failed"
469                  cp make.log $CDIR"/make.log"                  cp make.tr_log genmake.log genmake.tr_log $CDIR
470                  return 1                  return 1
471              else              else
472                  echo succesful 1>&2                  echo successful
473              fi              fi
474          )          )
475      fi      fi
# Line 270  makemodel() Line 479  makemodel()
479  {  {
480      # makemodel directory      # makemodel directory
481      (      (
482        mk_fail=0
483        if test "x$NOMAKE" = xt ; then
484            cd $1;
485            if test -x $EXECUTABLE ; then
486                echo "make skipped!"
487            else
488                echo "no executable!"
489                mk_fail=3
490            fi
491        else
492          cd $1;          cd $1;
493          if test -r Makefile ; then          if test -r Makefile ; then
494              printf 'make ... ' 1>&2              printf 'make ... '
495              $MAKE >> make.log 2>&1              $MAKE $TARG >> make.tr_log 2>&1
496              RETVAL=$?              RETVAL=$?
497              if test "x$RETVAL" != x0 ; then              if test "x$RETVAL" != x0 ; then
498                  tail make.log                  tail make.tr_log
499                  echo failed 1>&2                  echo failed
500                  cp make.log $CDIR"/make.log"                  cp genmake.log genmake.tr_log $CDIR
501                  return 1                  tail -$NBLINES_MKLOG make.tr_log > $CDIR"/make.tr_log_tail"
502                    rm -f $EXECUTABLE
503                    mk_fail=1
504              else              else
505                  echo succesful 1>&2                  echo successful
506              fi              fi
507            else
508                echo "no Makefile !"
509                mk_fail=2
510          fi          fi
511        fi
512        if test "x$ADM" = xt -a -f taf_ad.log ; then
513                head -1 taf_ad.log >> $CDIR"/summary.txt"
514                nerr=`grep -c 'TAF *.* ERROR ' taf_ad.log`
515                nwar=`grep -c 'TAF RECOMPUTATION *.* WARNING ' taf_ad.log`
516                echo " TAF reports $nerr Errors and $nwar Recomputation Warnings" \
517                                    >> $CDIR"/summary.txt"
518        fi
519        if test $mk_fail != 0 ; then return $mk_fail ; fi
520      )      )
521  }  }
522    
523    mk_mpi_size()
524    {
525        # mk_mpi_size input_file output_file proc_Nb prefer_to_split_X
526        #
527        # make new SIZE.h (=output_file) from SIZE.h_mpi (=input_file)
528        #     for an MPI build with no more than proc_Nb processors ;
529        # return the effective number of processors.
530    
531        inp=$1
532        out=$2
533        np=$3
534        dirX=$4
535        tmp=TTT.$$
536    
537        px=`grep "^     & *nPx *=" $inp | sed "s/^     & *nPx *= *//" | sed 's/, *$//'`
538        py=`grep "^     & *nPy *=" $inp | sed "s/^     & *nPy *= *//" | sed 's/, *$//'`
539        sx=`grep "^     & *nSx *=" $inp | sed "s/^     & *nSx *= *//" | sed 's/, *$//'`
540        sy=`grep "^     & *nSy *=" $inp | sed "s/^     & *nSy *= *//" | sed 's/, *$//'`
541    
542        #- find the largest divisor of input_file proc Nb, but not larger than $np
543        pp=0
544        i=1
545        while [ $i -le $px ] ; do
546          if [ `expr $px % $i` -eq 0 ] ; then
547            j=1
548            while [ $j -le $py ] ; do
549              if [ `expr $py % $j` -eq 0 ] ; then
550                ij=`expr $i \* $j`
551                if [ $ij -gt $pp ] ; then
552                    flag=1
553                elif [ $ij -eq $pp ] ; then
554                    flag=$dirX
555                else
556                    flag=0
557                fi
558                if test $flag = 1 ; then
559                  if [ $ij -le $np ] ; then
560                    ix=$i ; jy=$j ; pp=$ij
561                    #echo "  ix,jy= $ix,$jy"
562                  fi
563                fi
564              fi
565              j=`expr $j + 1`
566            done
567          fi
568          i=`expr $i + 1`
569        done
570    
571        #- create new SIZE.h type file:
572        sx=`expr $sx \* $px / $ix`
573        sy=`expr $sy \* $py / $jy`
574        if [ $verbose -gt 1 ]; then
575            echo " px,py,np= $px,$py,$np : New MPI size: px,py= $ix,$jy : sx,sy= $sx,$sy"
576        fi
577        sed "/^     \& *nPx *=/s/[0-9]*,/$ix,/" $inp > $tmp
578        sed "/^     \& *nPy *=/s/[0-9]*,/$jy,/" $tmp > $out
579        sed "/^     \& *nSx *=/s/[0-9]*,/$sx,/" $out > $tmp
580        sed "/^     \& *nSy *=/s/[0-9]*,/$sy,/" $tmp > $out
581        rm -f $tmp
582        return $pp
583    }
584    
585    symlink_mpifiles()
586    {
587        # Put special links so that MPI specific files are used
588        # This MUST be invoked between makeclean and makelinks because
589        # the Makefile will link to non-mpi files by default
590    
591        dir=$1
592        code_dir=$2
593        build_dir=$dir/$3
594    
595        # These are files that should replace their counter-part when using -mpi
596        MPI_FILES=`(cd $dir/$code_dir; find . -name "*_mpi" -print)`
597    
598        for ii in $MPI_FILES ; do
599            i=`echo $ii | sed 's:^\./::'`
600            name=`echo $i | sed 's:_mpi::'`
601            file="../$code_dir/$i"
602            if test $name = 'SIZE.h' ; then file="SIZE.h.mpi" ; fi
603    
604            #  Is this an MPI run?
605            if test "x$MPI" = x0 ; then
606                # NO: We undo any _mpi symbolically linked files
607                if test -L $build_dir/$name ; then
608                    ( cd $build_dir ; cmp $name $file > /dev/null 2>&1 )
609                    RETVAL=$?
610                    if test "x$RETVAL" = x0 ; then
611                        if [ $verbose -gt 1 ]; then
612                            echo "  Un-linking $name from ../$code_dir" ; fi
613                        rm -f $build_dir/$name
614                    fi
615                fi
616            else
617                # YES: We symbolically link these files to the build
618                # dir so long as there is no real file in place
619                ( cd $build_dir ; cmp $name $file > /dev/null 2>&1 )
620                RETVAL=$?
621                if [ $verbose -gt 1 ]; then echo "  cmp $name $file returns: $RETVAL" ; fi
622                if test "x$RETVAL" != x0 ; then
623                    if test -h $build_dir/$name ; then rm -f $build_dir/$name ; fi
624                    if test ! -r $build_dir/$name ; then
625                        if [ $verbose -gt 1 ]; then echo "  Linking $name to $file" ; fi
626                        (cd $build_dir; ln -sf $file $name)
627                    fi
628                fi
629            fi
630        done
631    }
632    
633  linkdata()  linkdata()
634  {  {
635      # linkdata flag      # linkdata run_dir input_dir_1 input_dir_2 ...
636      #      #
637      # symbolically link data files to run directory      # symbolically link data files to run directory
638      if test "x$1" = x1 ; then      if test -d $1 ; then
639          (          (
640              cd $2              cd $1 ; shift
641              files=`( cd ../input ; ls -1 | grep -v CVS )`              echo 'linkdata from dirs:' $*
642              for i in $files ; do              inpMPI=`(cd ../$1 ; find . -name "*.mpi" -print | sed 's:^\./::')`
643                  if test ! -d "../input/"$i ; then              for xx in $inpMPI ; do
644                      ln -sf "../input/"$i $i                if test -r "../"$1"/"$xx ; then
645                    # found 1 _mpi sfx file in 1rst input dir and it is readable
646                    yy=`echo $xx | sed 's:\.mpi$::'`
647                    if test "x$MPI" = "x0" ; then
648                        # not mpi test: remove symbolic link
649                        if test -h $yy ; then rm -f $yy ; fi
650                    else
651                        # mpi test: remove symbolic link & link .mpi sfx file
652                        if test -h $yy ; then rm -f $yy ; fi
653                        if test ! -r $yy ; then
654                            ln -sf "../"$1"/"$xx $yy ;
655                            printf " $xx" 1>&2
656                        fi
657                    fi
658                  fi
659                done
660                if test -r "../"$1"/eedata.mth" ; then
661                # found eedata.mth in 1rst input dir and it is readable
662                    if test "x$MULTI_THREAD" = "xt" ; then
663                    # multi-threaded test: remove symbolic link & link eedata.mth
664                        if test -h eedata ; then rm -f eedata ; fi
665                        if test ! -r eedata ; then
666                            ln -sf "../"$1"/eedata.mth" eedata ;
667                            printf ' eedata.mth' 1>&2
668                        fi
669                    else
670                    # not multi-threaded test: remove eedata symbolic link
671                        if test -h eedata ; then rm -f eedata ; fi
672                    fi
673                fi
674                prevDir='NONE'
675                for ldir in $* ; do
676                    if test -d "../"$ldir -a $ldir != $prevDir ; then
677                        printf " ldir=${ldir}:" 1>&2
678                        files=`( cd "../"$ldir ; ls -1 | grep -v CVS )`
679                        for i in $files ; do
680                            if test ! -d "../"$ldir/$i ; then
681                                if test ! -r $i  ; then
682                                    printf ' '$i 1>&2
683                                    ln -sf "../"$ldir"/"$i $i
684                                fi
685                            fi
686                        done
687                        printf ' ;' 1>&2
688                        if test -x "../"$ldir"/"prepare_run ; then
689                            "../"$ldir"/"prepare_run 1>&2
690                        else
691                            echo '' 1>&2
692                        fi
693                  fi                  fi
694                    prevDir=$ldir
695              done              done
696          )          )
697      fi      fi
# Line 309  runmodel() Line 701  runmodel()
701  {  {
702      # runmodel directory      # runmodel directory
703      #      #
704      #  runs "$COMMAND" in "directory"      #  runs $COMMAND in "directory"
705      #  (where "$COMMAND" is relative to "directory")      #  (where "$COMMAND" is relative to "directory")
706      (      (
707          cd $1          cd $1
708          printf 'runmodel: ' 1>&2          printf 'runmodel in %s ... ' $1
709          # make output.txt          if test "x$MPI" != x0 ; then
710          $COMMAND              #- adjust the MPI run command with the right number of Procs
711          RETVAL=$?              #echo '' ; echo "  COMMAND='$COMMAND'"
712          if test "x$RETVAL" = x0 ; then              COMMAND=`echo $COMMAND | sed "s/ TR_NPROC / $LOC_NPROC /"`
713              cp output.txt $CDIR"/output.txt"              if test "x$MPI_MFILE" != x ; then
714                  COMMAND=`echo $COMMAND | sed "s/ TR_MFILE / ..\/..\/$LOC_MFILE /"`
715                fi
716                #echo "  COMMAND='$COMMAND'"
717            fi
718            if test -L $EXECUTABLE ; then
719              if test -x "../"$builddir"/"$EXECUTABLE ; then
720                cmp $EXECUTABLE "../"$builddir"/"$EXECUTABLE > /dev/null 2>&1
721                outD=$? ; if test "x$outD" != x0 ; then rm -f $EXECUTABLE ; fi
722              else rm -f $EXECUTABLE
723              fi
724            fi
725            if test ! -x $EXECUTABLE -a -x "../"$builddir"/"$EXECUTABLE ; then
726                echo " link" $EXECUTABLE "from dir ../"$builddir > run.log_tmp
727                ln -sf "../"$builddir"/"$EXECUTABLE .
728            fi
729            if test ! -x $EXECUTABLE ; then
730                rm -f $RUNLOG ; touch $RUNLOG
731                if test -f run.log_tmp ; then cat run.log_tmp >> $RUNLOG ; fi
732                echo " no executable:" $EXECUTABLE >> $RUNLOG
733                RETVAL=8
734                ENDVAL=-1
735            else
736              if test ! -f $OUTPUTFILE -o $OUTPUTFILE -ot $EXECUTABLE ; then
737                # output do not exist or is older than executable:
738                rm -f $OUTPUTFILE $RUNLOG ; touch $RUNLOG
739                if test -f run.log_tmp ; then cat run.log_tmp >> $RUNLOG ; fi
740                ( eval $COMMAND ) >> $RUNLOG 2>&1
741                RETVAL=$?
742                ENDVAL=`tail $OUTPUTFILE | grep -c 'PROGRAM MAIN: Execution ended Normally'`
743                if [ $POSTCLEAN -eq 1 -a $ENDVAL -gt 0 ] ; then
744                    find . -name "*.meta" -exec rm {} \;
745                    find . -name "*.data" -exec rm {} \;
746                    rm -rf mnc_test_*
747                fi
748              else
749                RETVAL=0
750                ENDVAL=`tail $OUTPUTFILE | grep -c 'PROGRAM MAIN: Execution ended Normally'`
751                touch $RUNLOG
752                if test -f run.log_tmp ; then cat run.log_tmp >> $RUNLOG ; fi
753                echo "---------->> $OUTPUTFILE is up to date " >> $RUNLOG 2>&1
754              fi
755            fi
756            rm -f run.log_tmp
757            #- in all cases where OutputFile exists, report SIZE (and AD time)
758            if test -f $OUTPUTFILE ; then
759              grep '(PID\.TID 0000\.0001)      n.. =' $OUTPUTFILE \
760                    | sed 's/(PID.TID 0000.0001)     //' >> $CDIR"/summary.txt"
761              if test "x$ADM" = xt ; then
762                grep -A3 'Seconds in section "ALL' $OUTPUTFILE >> $CDIR"/summary.txt"
763              fi
764            fi
765            if test -s STDERR.0000 ; then cp STDERR.0000 $CDIR"/STDERR.0000" ; fi
766            if [ $RETVAL -eq 0 -a $ENDVAL -gt 0 ] ; then
767                echo successful
768                printf '=> output from running in %s :\n' $1 1>&2
769                tail $RUNLOG | sed 's/^.*/> &/g' 1>&2
770                return 0
771            elif [ $RETVAL -ne 0 -a $ENDVAL -gt 0 ] ; then
772                #-- for some weird cases (run is finihed but with error code)
773                echo 'finished with error (run:' $RETVAL ' end:' $ENDVAL ')'
774                printf '=> output from running in %s :\n' $1 1>&2
775                tail $RUNLOG | sed 's/^.*/> &/g' 1>&2
776              return 0              return 0
777          else          else
778                echo 'failed (run:' $RETVAL ' end:' $ENDVAL ')'
779                printf '=> output from running in %s :\n' $1 1>&2
780                tail $RUNLOG | sed 's/^.*/> &/g' 1>&2
781                cp $RUNLOG $CDIR"/"$RUNLOG
782              return 1              return 1
783          fi          fi
784      )      )
# Line 330  createcodelet() Line 788  createcodelet()
788  {  {
789      # create codelet for comparing model output      # create codelet for comparing model output
790    
791      echo -n "creating the comparison code...  "      printf "creating the comparison code (using CC=$CC)...  "
792      cat > tmp_cmpnum.f <<EOFA      cat > tr_cmpnum.c <<EOF
793        program cmpnum  #include <stdio.h>
794        implicit none  #include <math.h>
795        real*8 a,b,diff  int main( int argc, char** argv )  {
796        integer linnum,best    int linnum,cmplin,best,lncnt;
797        best=-16    double a,b,abave,relerr;
798    99  read(*,*,end=70,err=60) linnum,a,b    best = -22;
799        diff=0.5*(abs(a)+abs(b))    lncnt = 0;
800  c     print *,a,b,diff,abs(a-b)/diff    while( 1 & ( (lncnt+=1) < 999 ) )  {
801        if (diff.gt.1.e-12) then      scanf("%d", &linnum);
802          diff=abs(a-b)/diff      if (linnum == -1)  break;
803          if (diff.gt.0.) then      scanf("%lf", &a);  scanf("%lf", &b);
804  c         print *,int(log10(diff)),diff      abave = 0.5*(fabs(a)+fabs(b));
805            linnum=int(log10(diff))      if ( abave == abave ) {
806            best=max(best,linnum)        if (abave > 0.0) {
807          endif          relerr=fabs(a-b)/abave;
808        else          if (relerr > 0.0) { cmplin = (int)rint(log10(relerr)); }
809          if (best.eq.-16.and.diff.ne.0.) best=-22          else { cmplin = -16 ; }
810        endif          best = (best > cmplin) ? best : cmplin; }
811        goto 99        else { cmplin = -22 ; }
812    60  stop 'cmpnum: An error occured reading a,b'     /* printf("%d ; %lf ; %lf\n",cmplin,a,b); */
813    70  print *,-best        }
814        end     else {
815  EOFA     /* printf("%lf ; %lf ; %lf\n",abave,a,b); */
816          break; }
817      }
818      if (lncnt == 999) best=-29;
819      if (linnum != -1) best=-99;
820      printf("%d\n", -best);
821      return 0;
822    }
823    EOF
824        $CC -o tr_cmpnum tr_cmpnum.c -lm
825    
826      f77 tmp_cmpnum.f      if [ -x ./tr_cmpnum ]; then
     if [ -x ./a.out ]; then  
827          echo "OK"          echo "OK"
828          return 0          return 0
829      else      else
830          echo          echo
831          echo "createcodelet: failed to compile codelet"          echo "ERROR: failed to compile comparison code -- please specify"
832            echo "  a C compiler using the CC environment variable."
833          exit 1          exit 1
834      fi      fi
835  }  }
# Line 374  formatresults() Line 841  formatresults()
841      nm=$1      nm=$1
842      printf '%s %s %s %s' $2 $3 $4 $5      printf '%s %s %s %s' $2 $3 $4 $5
843      shift; shift; shift; shift; shift;      shift; shift; shift; shift; shift;
844      printf '%3s' $@      listPrt=$@
845            listRes=`echo $listPrt | sed 's/>//' | sed 's/<//'`
846      if [ $1 = '--' ]; then      xx=`echo $listPrt | sed 's/.*>//' | sed 's/<.*//' | awk '{print $1}'`
847        printf '%3s' $listPrt
848    #   line below does not work on hp-ux_ia64 : do those substitutions later on
849    #   printf '%3s' $listPrt | sed 's/ 99/ --/g' | sed 's/  > />/' | sed 's/  < /</'
850    
851        if [ $xx = '..' ]; then
852            printf ' N/O '
853        elif [ $xx = '--' ]; then
854            printf ' N/O '
855        elif [ $xx = 99 ]; then
856          printf ' N/O '          printf ' N/O '
857      else      else
858          if [ $1 -gt 12 ]; then          if [ $xx -ge $MATCH_CRIT ]; then
859              printf ' pass'              printf ' pass'
860          else          else
861              printf ' FAIL'              printf ' FAIL'
# Line 387  formatresults() Line 863  formatresults()
863      fi      fi
864      printf '  %s' $nm      printf '  %s' $nm
865      printf '\n'      printf '\n'
       
 }  
866    
 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  
867  }  }
868    
869  scandirs()  scandirs()
870  {  {
871      if [ $# -eq 0 ]; then      if [ $# -eq 1 ]; then
872          for arg in * ; do          for arg in * ; do
873              test -d $arg/input && echo $arg              test -f $arg/$1 && echo $arg
874          done          done
875      else      else
876          echo $*          echo $*
877      fi      fi
878  }  }
879    
880    
881  ###############################################################################  check_eedata()
882  ###############################################################################  {
883        # check_eedata eedata size.h
884        if [ $# -eq 2 ] ; then
885         if test -f $1 -a -f $2 ; then
886          nx=`grep "^ *nTx *=" $1 | tail -1 | sed 's/^ *nTx *= *//' | sed "s/, *$//"`
887          sx=`grep "^     & *nSx *=" $2 | sed "s/^     & *nSx *=//" | sed 's/, *$//'`
888          if test "x$nx" = x ; then
889            rx=10
890          else
891            rx=`expr $sx % $nx`
892          fi
893          ny=`grep "^ *nTy *=" $1 | tail -1 | sed 's/^ *nTy *= *//' | sed "s/, *$//"`
894          sy=`grep "^     & *nSy *=" $2 | sed "s/^     & *nSy *=//" | sed 's/, *$//'`
895          if test "x$ny" = x ; then
896            ry=20
897          else
898            ry=`expr $sy % $ny`
899          fi
900          echo `expr $rx + $ry`
901         else
902          echo '-1'
903         fi
904        elif [ $# -eq 1 ] ; then
905         if test -f $1 ; then
906          nx=`grep "^ *nTx *=" $1 | tail -1 | sed 's/^ *nTx *= *//' | sed "s/, *$//"`
907          if test "x$nx" = x ; then nx=1 ; fi
908          ny=`grep "^ *nTy *=" $1 | tail -1 | sed 's/^ *nTy *= *//' | sed "s/, *$//"`
909          if test "x$ny" = x ; then ny=1 ; fi
910         #echo $nx $ny
911          echo $nx
912         else
913          echo '-1'
914         fi
915        else
916          echo '-2'
917        fi
918    
919    }
920    
921  ###############################################################################  ###############################################################################
922    
923    
924  #  Default properties  #  Default properties
925  debug=0  debug=0
926  verbose=1  verbose=1
927  clean=0  NBLINES_MKLOG=16000
 expts=''  
 # ieee=1  
928    
929  IEEE=  IEEE=true
930  if test "x$MITGCM_IEEE" != x ; then  if test "x$MITGCM_IEEE" != x ; then
931      IEEE=$MITGCM_IEEE      IEEE=$MITGCM_IEEE
932  fi  fi
933    OptLev=1
934    GSL=f
935    
936  CLEANUP=f  CLEANUP=f
937    NORUN=f
938  QUICK=f  QUICK=f
939    NOMAKE=f
940  NOGENMAKE=f  NOGENMAKE=f
941  NOCLEAN=f  NOCLEAN=f
942  NODEPEND=f  NODEPEND=f
943    POSTCLEAN=0
944    
945  BASH=  BASH=
946  OPTFILE=NONE  OPTFILE=NONE
947  ADDRESSES=  ADDRESSES=
948  TESTDIRS=  TESTDIRS=
949    SKIPDIRS=
950  MPACKDIR="../tools/mpack-1.6"  MPACKDIR="../tools/mpack-1.6"
951  MPACK="$MPACKDIR/mpack"  HAVE_MPACK=
952  COMMAND="make output.txt"  MPACK=
953  MAKE=make  COMMAND=
954  MPI=f  MKDEPEND=
955    if test "x$MAKE" = x ; then
956        MAKE=make
957    fi
958    if test "x$CC" = x ; then
959        CC=cc
960    fi
961    JOBS=
962    TARG=
963    MPI=0
964    MPI_MFILE=
965    MULTI_THREAD=f
966    OUTDIR=
967    DELDIR=
968    USE_R4=
969    EXTRFLG=
970    
971    ADM=
972    OADM=
973    
974  echo -n "parsing options...  "  # list of pTracers to check for monitor output
975    PTRACERS_NUM="1 2 3 4 5"
976    
977    MATCH_CRIT=10
978    
979    printf "parsing options...  "
980    
981  ac_prev=  ac_prev=
982  for ac_option ; do  for ac_option ; do
# Line 468  for ac_option ; do Line 989  for ac_option ; do
989      fi      fi
990    
991      ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`      ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
992        
993      case $ac_option in      case $ac_option in
994                    
995          -help | --help | -h | --h)          -help | --help | -h | --h) usage ;;
996              usage ;;  
997                    -optfile | --optfile | -of | --of) ac_prev=OPTFILE ;;
998          -optfile | --optfile | -of | --of)          -optfile=* | --optfile=* | -of=* | --of=*) OPTFILE=$ac_optarg ;;
999              ac_prev=OPTFILE ;;  
1000          -optfile=* | --optfile=* | -of=* | --of=*)          -addr | --addr | -a | --a) ac_prev=ADDRESSES ;;
1001              OPTFILE=$ac_optarg ;;          -addr=* | --addr=* | -a=* | --a=*) ADDRESSES=$ac_optarg ;;
1002                    -mpackdir | --mpackdir | -mpd | --mpd) ac_prev=MPACKDIR ;;
1003          -addr | --addr | -a | --a)          -mpackdir=* | --mpackdir=* | -mpd=* | --mpd=*) MPACKDIR=$ac_optarg ;;
1004              ac_prev=ADDRESSES ;;  
1005          -addr=* | --addr=*)          -tdir | --tdir | -t | --t) ac_prev=TESTDIRS ;;
1006              ADDRESSES=$ac_optarg ;;          -tdir=* | --tdir=* | -t=* | --t=*) TESTDIRS=$ac_optarg ;;
1007            -skipdir | --skipdir | -skd | --skd) ac_prev=SKIPDIRS ;;
1008          -tdir | --tdir | -t | --t)          -skipdir=* | --skipdir=* | -skd=* | --skd=*) SKIPDIRS=$ac_optarg ;;
1009              ac_prev=TESTDIRS ;;  
1010          -tdir=* | --tdir=*)          -bash | --bash | -b | --b) ac_prev=BASH ;;
1011              TESTDIRS=$ac_optarg ;;          -bash=* | --bash=* | -b=* | --b=*) BASH=$ac_optarg ;;
1012    
1013          -bash | --bash | -b | --b)          -command | --command | -c | --c) ac_prev=COMMAND ;;
1014              ac_prev=BASH ;;          -command=* | --command=* | -c=* | --c=*) COMMAND=$ac_optarg ;;
1015          -bash=* | --bash=*)  
1016              BASH=$ac_optarg ;;          -makedepend | --makedepend | -md | --md) ac_prev=MKDEPEND ;;
1017            -makedepend=* | --makedepend=* | -md=* | --md=*) MKDEPEND=$ac_optarg ;;
1018          -command | --command | -c | --c)  
1019              ac_prev=COMMAND ;;          -make | --make | -m | --m) ac_prev=MAKE ;;
1020          -command=* | --command=*)          -make=* | --make=* | -m=* | --m=*) MAKE=$ac_optarg ;;
1021              COMMAND=$ac_optarg ;;  
1022            -odir | --odir) ac_prev=OUTDIR ;;
1023          -make | --make | -m | --m)          -odir=* | --odir=*) OUTDIR=$ac_optarg ;;
1024              ac_prev=MAKE ;;  
1025          -make=* | --make=*)          -ptracers | --ptracers | -ptr | --ptr) ac_prev=PTRACERS_NUM ;;
1026              MAKE=$ac_optarg ;;          -ptracers=* | --ptracers=* | -ptr=* | --ptr=*) PTRACERS_NUM=$ac_optarg ;;
1027    
1028          -clean | --clean)          -match | --match ) ac_prev=MATCH_CRIT ;;
1029              CLEANUP=t ;;          -match=* | --match=* ) MATCH_CRIT=$ac_optarg ;;
1030    
1031          -quick | --quick | -q | --q)          -j | --j) ac_prev=JOBS ;;
1032              QUICK=t ;;          -j=* | --j=*) JOBS=$ac_optarg ;;
1033          -nogenmake | --nogenmake | -ng | --ng)  
1034              NOGENMAKE=t ;;          -ef | --ef) ac_prev=EXTRFLG ;;
1035          -noclean | --noclean | -nc | --nc)          -ef=* | --ef=*) EXTRFLG=$ac_optarg ;;
             NOCLEAN=t ;;  
         -nodepend | --nodepend | -nd | --nd)  
             NODEPEND=t ;;  
1036    
1037          -mpi) MPI=true ;;          -clean | --clean) CLEANUP=t ; DELDIR=t ;;
1038    
1039          -ieee) IEEE=true ;;          -norun | --norun | -nr | --nr) NORUN=t ;;
1040          -noieee) IEEE= ;;          -obj | --obj ) TARG='obj' ; NORUN=t ;;
1041            -runonly | --runonly | -ro | --ro) QUICK=t ; NOMAKE=t ;;
1042            -quick | --quick | -q | --q) QUICK=t ;;
1043            -nogenmake | --nogenmake | -ng | --ng) NOGENMAKE=t ;;
1044            -noclean | --noclean | -nc | --nc) NOCLEAN=t ;;
1045            -nodepend | --nodepend | -nd | --nd) NODEPEND=t ;;
1046    
1047            -postclean | --postclean | -pc | --pc) POSTCLEAN=2 ;;
1048            -deloutp | --deloutp | -do | --do) POSTCLEAN=1 ;;
1049    
1050            -mpi | --mpi) MPI=2 ;;
1051            -MPI | --MPI) ac_prev=MPI ;;
1052            -MPI=* | --MPI=*) MPI=$ac_optarg ;;
1053    
1054            -mfile | --mfile | -mf | --mf) ac_prev=MPI_MFILE ;;
1055            -mfile=* | --mfile=* | -mf=* | --mf=*) MPI_MFILE=$ac_optarg ;;
1056    
1057            -mth) MULTI_THREAD=t ;;
1058    
1059            -adm | -ad) ADM=t ;;
1060            -oad) OADM=t; NODEPEND=t ;;
1061    
1062            -ieee)   echo "Warning: ignore option '-ieee' (already the default)"
1063                     printf " ... " ;;
1064            -noieee) echo "Warning: will use option '-fast' instead of '-noieee' (obsolete)"
1065                     printf " ... " ; OptLev=`expr $OptLev \* 2` ;;
1066            -fast)  OptLev=`expr $OptLev \* 2` ;;
1067            -devel) OptLev=0 ;;
1068            -gsl) GSL=t ;;
1069    
1070          -verbose) verbose=2 ;;          -verbose) verbose=2 ;;
1071          -debug) debug=1 ;;          -debug) debug=1 ;;
1072          -quiet) verbose=0 ;;          -quiet) verbose=0 ;;
1073    
1074          -*)          -deldir | -dd) DELDIR=t ;;
1075              echo "Error: unrecognized option: "$ac_option  
1076              usage          -use_r4|-ur4) USE_R4=t ;;
1077              ;;  
1078                    -ts) TS=t;;
1079          *)          -papis) PAPIS=t;;
1080              echo "Error: unrecognized argument: "$ac_option          -pcls) PCL=t;;
1081              usage  
1082              ;;          -*) echo "Error: unrecognized option: "$ac_option
1083                        usage ;;
1084            *)  echo "Error: unrecognized argument: "$ac_option
1085                usage ;;
1086    
1087       esac       esac
1088        
1089  done  done
1090    
1091  if test "x$QUICK" = xt ; then  if test "x$QUICK" = xt ; then
# Line 545  if test "x$QUICK" = xt ; then Line 1094  if test "x$QUICK" = xt ; then
1094      NODEPEND=t      NODEPEND=t
1095  fi  fi
1096    
1097    #- check length of MPI machine file:
1098    if test "x$MPI" != x0 -a "x$MPI_MFILE" != x ; then
1099        if test -r $MPI_MFILE ; then
1100            nl=`wc -l $MPI_MFILE | awk '{print $1}'`
1101            if [ $nl -lt $MPI ] ; then
1102              echo "Error: need at least $MPI nodes (currently only $nl) in MPI_MFILE=$MPI_FILE"
1103              usage
1104            fi
1105            if [ $verbose -gt 1 ]; then
1106                echo " MPI_MFILE=$MPI_MFILE : $nl procs for MPI=$MPI run"
1107            fi
1108        else
1109              echo "Error: cannot access MPI_MFILE=$MPI_FILE"
1110              usage
1111        fi
1112    fi
1113    
1114    #- setting for forward or ADM testing
1115    if test "x$ADM" = xt ; then
1116        if test "x$TARG" = xobj ; then TARG=adobj ; else TARG=adall ; fi
1117        code_dir=code_ad
1118        inputdir=input_ad
1119        ref_outp="output_adm.txt"
1120        EXECUTABLE="mitgcmuv_ad"
1121    elif test "x$OADM" = xt ; then
1122        TARG=adAll
1123        code_dir=code_oad
1124        inputdir=input_oad
1125        ref_outp="output_oadm.txt"
1126        EXECUTABLE="mitgcmuv_ad"
1127    else
1128        if test "x$JOBS" != x ; then TARG="-j $JOBS $TARG" ; fi
1129        code_dir=code
1130        inputdir=input
1131        ref_outp="output.txt"
1132        EXECUTABLE="mitgcmuv"
1133    fi
1134    
1135    xx=`echo $TESTDIRS | awk '{print $1}'`
1136  if test "x$TESTDIRS" = x ; then  if test "x$TESTDIRS" = x ; then
1137      TESTDIRS=`scandirs`      LIST=`scandirs results/$ref_outp`
1138    elif test $xx = 'start_from' ; then
1139        xx=`echo $TESTDIRS | awk '{print $2}'`
1140        LIST=`scandirs results/$ref_outp | sed -n "/$xx/,$ p"`
1141    else
1142        #- expand group of experiments:
1143        LIST=" "
1144        for xx in $TESTDIRS
1145        do
1146          case $xx in
1147            'basic') LIST=${LIST}" aim.5l_cs hs94.128x64x5 ideal_2D_oce"
1148                     LIST=${LIST}" lab_sea tutorial_baroclinic_gyre"
1149                     LIST=${LIST}" tutorial_global_oce_latlon tutorial_plume_on_slope"
1150                    ;;
1151            'tutorials')
1152                     LIST=${LIST}" "`ls | grep 'tutorial_'` ;;
1153            *)       LIST=${LIST}" "$xx ;;
1154          esac
1155        done
1156  fi  fi
1157    #echo 'LIST='${LIST}'<'
1158    #- skip dirs, remove duplicate and non-directory:
1159    TESTDIRS=" "
1160    count=0
1161    for xx in $LIST
1162    do
1163        yy=`echo $SKIPDIRS | grep -c $xx`
1164        if test $yy = 0 ; then
1165            if test -d $xx ; then
1166                yy=`echo $TESTDIRS | grep -c $xx`
1167                if test $yy = 0 ; then TESTDIRS=${TESTDIRS}" "$xx ; fi
1168            else count=1 ;
1169                echo ""; echo -n " -- skip \"$xx\" (not a directory !)"
1170            fi
1171        else
1172            if test $count = 1 ; then echo -n ", \"$xx\""
1173            else count=1 ; echo "" ;  echo -n " skip: \"$xx\""
1174            fi
1175        fi
1176    done
1177    if test $count = 1 ; then echo "" ; echo -n " ... " ; fi
1178    #echo 'TESTDIRS='${TESTDIRS}'<'
1179    
1180  if test "x$OPTFILE" = xNONE -a "x$MITGCM_OF" != x ; then  if test "x$OPTFILE" = xNONE -a "x$MITGCM_OF" != x ; then
1181      OPTFILE=$MITGCM_OF      OPTFILE=$MITGCM_OF
1182  fi  fi
1183    
1184  echo "OK"  LOC_MFILE='tr_mpi_mfile'
1185    RUNLOG="run.tr_log"
1186    OUTPUTFILE=$ref_outp
1187    if test "x$COMMAND" = x ; then
1188        COMMAND="./$EXECUTABLE > $OUTPUTFILE"
1189    fi
1190    if test "x$MPI" != x0 ; then
1191        OUTPUTFILE="STDOUT.0000"
1192    fi
1193    
1194    echo "OK (COMMAND= $COMMAND )"
1195    
1196    # set the Default List of output variables to be checked:
1197    #  (use default or load experiment-specific list from file "tr_checklist")
1198    # content : 1rst = main variable used to decide if it pass or FAIL
1199    #         others = number of matching digits to be printed in summary.txt
1200    if test "x$ADM" = x -a "x$OADM" = x; then
1201        DEF_CHECK_LIST='PS PS T+ S+ U+ V+ pt1+ pt2+ pt3+ pt4+ pt5+'
1202        EMPTY_RESULTS='.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..'
1203        LEN_CHECK_LIST=`echo $DEF_CHECK_LIST | sed 's/ [a-zA-Z0-9]*+/&mn &mx &av &sd/g' | awk '{print NF-1}'`
1204        ii=`echo $EMPTY_RESULTS | awk '{print NF}'`
1205        EMPTY_RESULTS=$EMPTY_RESULTS`expr $LEN_CHECK_LIST - $ii | awk 'BEGIN{FS=":"}{for(i=1;i<=$1;i++){printf "  ."}}'`
1206    else
1207        DEF_CHECK_LIST='AdGrd Cost AdGrd FDGrd'
1208        EMPTY_RESULTS='.. .. ..'
1209        LEN_CHECK_LIST=`echo $DEF_CHECK_LIST | sed 's/ [a-zA-Z0-9]*+/&mn &mx &av &sd/g' | awk '{print NF-1}'`
1210    fi
1211    
1212  #  create the FORTRAN comparison code  #  create the FORTRAN comparison code
1213  createcodelet  if test -x tr_cmpnum ; then
1214        echo "skipping comparison code build"
1215    else
1216        createcodelet
1217    fi
1218    
1219  #  build the mpack utility  #  build the mpack utility (if ADDRESSES = NONE, do it to test the build)
1220  build_mpack  if test "x$ADDRESSES" = x ; then
1221        echo "skipping mpack build"
1222    else
1223        build_mpack
1224    fi
1225    
1226  #  Create a uniquely named directory to store results  #  Create a uniquely named directory to store results
1227    CMDLINE=$0
1228    for xx in "$@" ; do nw=`echo $xx | wc -w`
1229        if test $nw = '1' ; then CMDLINE="$CMDLINE $xx"
1230                            else CMDLINE="$CMDLINE '$xx'" ; fi
1231    done
1232    #for xx in "$@" ; do CMDLINE="$CMDLINE '$xx'" ; done
1233  MACH=`hostname`  MACH=`hostname`
1234  UNAMEA=`uname -a`  UNAMEA=`uname -a`
1235  DATE=`date +%Y%m%d`  DATE=`date +%Y%m%d`
1236  BASE=$MACH"_"$DATE"_"  BASE="tr_"$MACH"_"$DATE"_"
1237    if test "x$OUTDIR" != x ; then
1238        BASE="tr_"$OUTDIR"_"$DATE"_"
1239    else
1240        short_name=`hostname | sed 's/\..*$//'`
1241        BASE="tr_"$short_name"_"$DATE"_"
1242    fi
1243  DNUM=0  DNUM=0
1244  DRESULTS="$BASE$DNUM"  DRESULTS="$BASE$DNUM"
1245  while test -e $DRESULTS ; do  while test -e $DRESULTS ; do
# Line 575  done Line 1249  done
1249  mkdir $DRESULTS  mkdir $DRESULTS
1250  RETVAL=$?  RETVAL=$?
1251  if test "x$RETVAL" != x0 ; then  if test "x$RETVAL" != x0 ; then
1252      echo "Error: can't create results directory \"./$DRESULTS\""      echo "ERROR: Can't create results directory \"./$DRESULTS\""
1253      exit 1      exit 1
1254  fi  fi
1255  SUMMARY="$DRESULTS/summary.txt"  SUMMARY="$DRESULTS/summary.txt"
1256  echo -n "Start time:  " >> $SUMMARY  start_date=`date`
1257  date > $SUMMARY  echo $start_date > $SUMMARY
1258  date > dfile  echo 'run:' $CMDLINE >> $SUMMARY
1259  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  
1260    
1261  of_path=  of_path=
1262  if test "x$OPTFILE" != xNONE ; then  if test "x$OPTFILE" != xNONE ; then
# Line 605  if test "x$OPTFILE" != xNONE ; then Line 1270  if test "x$OPTFILE" != xNONE ; then
1270          fi          fi
1271          file=${OPTFILE##*/}          file=${OPTFILE##*/}
1272          OPTFILE=$of_path/$file          OPTFILE=$of_path/$file
1273            cp $OPTFILE $DRESULTS
1274            echo >> $SUMMARY
1275            echo "  OPTFILE=$OPTFILE" >> $SUMMARY
1276      else      else
1277          echo          echo | tee $SUMMARY
1278          echo "WARNING: can't read OPTFILE=\"$OPTFILE\" but will try to use it..."          echo "ERROR: can't read OPTFILE=\"$OPTFILE\"" | tee $SUMMARY
1279            exit 1
1280      fi      fi
1281    else
1282        echo >> $SUMMARY
1283        echo "No \"OPTFILE\" was specified ; genmake2 found and uses:" >> $SUMMARY
1284        #-note: to be filled later after 1rst run
1285  fi  fi
1286  echo  echo
 echo "OPTFILE=$OPTFILE" >> $SUMMARY  
1287  echo >> $SUMMARY  echo >> $SUMMARY
1288    if test "x$ADM" = x -a "x$OADM" = x; then
1289        if [ $MATCH_CRIT -lt 10 ] ;
1290        then line_0="default  "$MATCH_CRIT ;
1291        else line_0="default "$MATCH_CRIT ; fi
1292           line_0="$line_0  ----T-----  ----S-----  ----U-----  ----V-----"
1293        line_1="G D M    c        m  s        m  s        m  s        m  s"
1294        line_2="e p a R  g  m  m  e  .  m  m  e  .  m  m  e  .  m  m  e  ."
1295        line_3="n n k u  2  i  a  a  d  i  a  a  d  i  a  a  d  i  a  a  d"
1296        line_4="2 d e n  d  n  x  n  .  n  x  n  .  n  x  n  .  n  x  n  ."
1297        for ii in $PTRACERS_NUM ; do
1298            line_0="$line_0  --PTR 0"$ii"--"
1299            line_1="$line_1        m  s"
1300            line_2="$line_2  m  m  e  ."
1301            line_3="$line_3  i  a  a  d"
1302            line_4="$line_4  n  x  n  ."
1303        done
1304        echo "$line_0" | tee -a $SUMMARY
1305        echo "$line_1" | tee -a $SUMMARY
1306        echo "$line_2" | tee -a $SUMMARY
1307        echo "$line_3" | tee -a $SUMMARY
1308        echo "$line_4" | tee -a $SUMMARY
1309        echo " "       | tee -a $SUMMARY
1310    else
1311        echo "ADJOINT=true" >> $SUMMARY
1312        echo >> $SUMMARY
1313        if [ $MATCH_CRIT -lt 10 ] ;
1314        then line_0="default     "$MATCH_CRIT ;
1315        else line_0="default    "$MATCH_CRIT ; fi
1316        echo "$line_0" | tee -a $SUMMARY
1317        cat << EOF | tee -a $SUMMARY
1318    G D M    C  A  F
1319    e p a R  o  d  D
1320    n n k u  s  G  G
1321    2 d e n  t  r  r
1322    
1323    EOF
1324    fi
1325    echo "-------------------------------------------------------------------------------"
1326    
1327  #  ...and each test directory...  #  ...and each test directory...
1328  for dir in $TESTDIRS ; do  for dir in $TESTDIRS ; do
1329        
1330        # set builddir & rundir:
1331        builddir="build"
1332        if test ! -d $dir/$builddir ; then mkdir $dir/$builddir ; fi
1333        rundir="run"
1334        pfxdir="tr_$rundir"
1335        if test ! -d $dir/$rundir ; then
1336            rundir=$builddir
1337        fi
1338        CODE_DIR=$dir/$code_dir
1339        BUILD_DIR=$dir/$builddir
1340    
1341      #  Cleanup only!      #  Cleanup only!
1342      if test "x$CLEANUP" = xt ; then      if test "x$CLEANUP" = xt ; then
1343          if test -r $dir/build/Makefile ; then          echo -n '  --- dir:' $BUILD_DIR ': '
1344              ( cd $dir/build ; make CLEAN )          makeclean $BUILD_DIR
1345            (   cd $BUILD_DIR
1346                rm -f $EXECUTABLE *.bak
1347                rm -f genmake_state genmake_*optfile genmake.log
1348                rm -f SIZE.h.mpi genmake.tr_log make.tr_log
1349            )
1350            if test -d $dir/$rundir/CVS ; then
1351                echo -n '  --- dir:' $dir/$rundir ': '
1352                run_clean $dir/$rundir
1353          fi          fi
1354          if test -r $dir/input/Makefile ; then          trdir=`( cd $dir ; find . -type d -name "$pfxdir.*" -print | sed 's/^.\///')`
1355              ( cd $dir/input ; make CLEAN )          ttd=`echo $trdir | wc -w`
1356            if test $ttd != 0 ; then
1357                echo '  --- rm dir:' $trdir
1358                ( cd $dir ; rm -rf $trdir )
1359          fi          fi
1360          continue          continue
1361      fi      fi
1362    
1363      #  Verify that the testdir exists and contains previous      #  Verify that the testdir exists and contains previous
1364      #  results in the correct location--or skip this directory!      #  results in the correct location--or skip this directory!
1365      if test ! -r $dir"/results/output.txt" ; then      fout=$dir"/results/"$ref_outp
1366          echo "can't read \"$dir/results/output.txt\" -- skipping $dir"      if test ! -r $fout ; then
1367            echo "can't read \"$fout\" -- skipping $dir"
1368          continue          continue
1369      fi      fi
1370    
1371      echo "-------------------------------------------------------------------------------"      # Check for specific files for particular type of run
     echo  
     echo "Experiment:  $dir"  
     echo  
     unset genmake makedepend make run  
     results='-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --'  
1372    
1373      builddir="input"      if test ! -r $CODE_DIR"/SIZE.h_mpi"  -a "x$MPI" != "x0" ; then
1374      rundir="input"          echo "can't find \"$CODE_DIR/SIZE.h_mpi\" -- skipping $dir"
1375      use_seperate_build=0          continue
1376      if test -d $dir/build -a -r $dir/build ; then      fi
1377          builddir="build"      if test ! -r $dir"/input/eedata.mth" -a "x$MULTI_THREAD" = "xt" ; then
1378          rundir="build"          echo "can't find \"$dir/input/eedata.mth\" -- skipping $dir"
1379          use_seperate_build=1          continue
         linkdata $use_seperate_build $dir/$rundir  
1380      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"  
1381    
1382      #  Is this an MPI run?      if test "x$MPI" != "x0" ; then
1383      if test "x$MPI" = xt ; then          prefer_X=0
1384          FILES=$MPI_FILES          if test "x$MULTI_THREAD" = "xt" ; then
1385          endings="_mpi"              retv=`check_eedata $dir"/input/eedata.mth"`
1386      else              if test $retv = 1 ; then prefer_X=1 ; fi
1387          FILES=$NOMPI_FILES          fi
1388          endings="_nompi"          #- create new SIZE.h with no more than '$MPI' Procs
1389      fi          mk_mpi_size $CODE_DIR"/SIZE.h_mpi" $BUILD_DIR"/tr_size.mpi" $MPI $prefer_X
1390                LOC_NPROC=$?
1391      #  Check to see that we have the files          (   cd $BUILD_DIR
1392      have_files=t              if test -r SIZE.h.mpi ; then
1393      for i in $FILES ; do                  cmp tr_size.mpi SIZE.h.mpi > /dev/null 2>&1 ; RETVAL=$?
1394          if test ! -r $CODE_DIR/$i ; then              else RETVAL=1
1395              echo "Warning: can't read file $CODE_DIR/$i"              fi
1396              have_files=f              if test "x$RETVAL" = x0 ; then
1397                    rm -f tr_size.mpi
1398                else
1399                    rm -f SIZE.h.mpi ; mv tr_size.mpi SIZE.h.mpi
1400                fi
1401            )
1402            if test "x$MPI_MFILE" != x ; then
1403                #- create new MPI machine-file with the right number of Procs
1404                rm -f $LOC_MFILE
1405                cat $MPI_MFILE | sort | uniq | head -$LOC_NPROC > $LOC_MFILE
1406                nl=`wc -l $LOC_MFILE | awk '{print $1}'`
1407                if [ $nl -lt $LOC_NPROC ] ; then
1408                    rm -f $LOC_MFILE
1409                    cat $MPI_MFILE | head -$LOC_NPROC > $LOC_MFILE
1410                    #sed -n "1,$LOC_NPROC p" $MPI_MFILE > $LOC_MFILE
1411                fi
1412                if [ $verbose -gt 1 ]; then
1413                    nl=`wc -l $LOC_MFILE | awk '{print $1}'`
1414                    echo " new LOC_MFILE=$LOC_MFILE : $nl procs for LOC_NPROC=$LOC_NPROC"
1415                fi
1416            fi
1417            if test "x$MULTI_THREAD" = "xt" ; then
1418                retv=`check_eedata $dir"/input/eedata.mth" $BUILD_DIR"/SIZE.h.mpi"`
1419                if test $retv != 0 ; then
1420                    echo "input/eedata.mth tiling misfit -- skipping $dir"
1421                    continue
1422                fi
1423          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  
1424      fi      fi
1425        
1426      #  If we have the $FILES and they differ, copy the $FILES to $BUILD_DIR      #  Check whether there are "extra runs" for this testdir
1427      if test "x$have_files" = xt ; then      extra_runs=
1428          for i in $FILES ; do      if test "x$NORUN" = xf ; then
1429              sstr="s|$endings||"          ex_run_dirs=`( cd $dir ; echo $inputdir.* )`
1430              name=`echo $i | sed -e $sstr `      fi
1431              cmp $CODE_DIR/$i $BUILD_DIR/$name > /dev/null 2>&1      #echo "ex_run_dirs='$ex_run_dirs'"
1432              RETVAL=$?      for exd in $ex_run_dirs ; do
1433              if test "x$RETVAL" != x0 ; then          name=`echo $exd | sed -e "s/$inputdir\.//"`
1434                  cp $CODE_DIR/$i $BUILD_DIR/$name          refExOut=`echo $ref_outp | sed "s/\./.${name}./"`
1435            outf="$dir/results/$refExOut"
1436            if test -f $outf -a -r $outf ; then
1437              if test "x$MULTI_THREAD" = "xt" ; then
1438                if test -r $dir"/"$exd"/eedata.mth" ; then
1439                  if test "x$MPI" = "x0" ; then
1440                    extra_runs="$extra_runs $name"
1441                  else
1442                    retv=`check_eedata $dir"/"$exd"/eedata.mth" $BUILD_DIR"/SIZE.h.mpi"`
1443                    if test $retv = 0 ; then
1444                        extra_runs="$extra_runs $name"
1445                    else
1446                        echo $exd"/eedata.mth tiling misfit -- skipping $dir"
1447                    fi
1448                  fi
1449                #else echo $dir"/"$exd"/eedata.mth: not found"
1450              fi              fi
1451          done            else
1452                extra_runs="$extra_runs $name"
1453              fi
1454            fi
1455        done
1456    
1457        echo
1458        if test "x$extra_runs" = "x" ; then
1459           echo "Experiment:  $dir"
1460        else
1461           echo "Experiment:  $dir ; extra_runs=$extra_runs"
1462      fi      fi
1463            echo
1464      #  Create an output dir for each OPTFILE/tdir combination      unset genmake makedepend make run
1465      CDIR=$DRESULTS"/"$DRESULTS"_"$NDIR      results=$EMPTY_RESULTS
1466      mkdir $CDIR  
1467      CDIR=`pwd`"/$CDIR"      #  Create an output dir & summary.txt file for each tested experiment (tdir)
1468            locDIR=$DRESULTS"/"$dir
1469      if test "x$CLEANUP" = xt ; then      mkdir $locDIR
1470          makeclean $dir/$builddir      #- report to this experiment local summary file ---
1471        echo "DATE='$DATE' ; tdir='$dir'" > $locDIR"/summary.txt"
1472        echo "MACH='$MACH'" >> $locDIR"/summary.txt"
1473        echo "UNAMEA='$UNAMEA'" >> $locDIR"/summary.txt"
1474        CDIR=`pwd`"/$locDIR"
1475    
1476        if test "x$NORUN" = xt ; then
1477                run=N
1478            genmakemodel $dir/$builddir && genmake=Y \
1479                && makeclean $dir/$builddir \
1480                && symlink_mpifiles $dir $code_dir $builddir \
1481                && makedependmodel $dir/$builddir && makedepend=Y \
1482                && makemodel $dir/$builddir && make=Y
1483      else      else
1484          genmakemodel $dir/$builddir && genmake=Y \          genmakemodel $dir/$builddir && genmake=Y \
1485              && makeclean $dir/$builddir \              && makeclean $dir/$builddir \
1486                && symlink_mpifiles $dir $code_dir $builddir \
1487              && makedependmodel $dir/$builddir && makedepend=Y \              && makedependmodel $dir/$builddir && makedepend=Y \
1488              && makemodel $dir/$builddir && make=Y \              && makemodel $dir/$builddir && make=Y \
1489              && linkdata $use_seperate_build $dir/$rundir \              && run_clean $dir/$rundir \
1490                && linkdata $dir/$rundir $inputdir \
1491              && runmodel $dir/$rundir && run=Y \              && runmodel $dir/$rundir && run=Y \
1492              && results=`testoutput $dir $rundir`              && results=`testoutput_run $dir $rundir $ref_outp`
1493      fi      fi
1494            #echo "results='$results'"
1495      echo  
1496      formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \          fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results`
1497          ${run:-N} $results          echo 1>&2
1498      echo          echo "$fres" | sed 's/ 99/ --/g' | sed 's/  > />/' | sed 's/  < /</' >> $SUMMARY
1499      formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \          echo "fresults='$fres'" | sed 's/ 99/ --/g' >> $locDIR"/summary.txt"
1500          ${run:-N} $results >> $SUMMARY  
1501      echo "fresults='" > $CDIR"/summary.txt"          for ex in $extra_runs ; do
1502      formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} \              unset run
1503          ${run:-N} $results >> $CDIR"/summary.txt"              results=$EMPTY_RESULTS
1504      echo "'" >> $CDIR"/summary.txt"              #  reference output file
1505      echo "MACH='$MACH'" >> $CDIR"/summary.txt"              refExOut=`echo $ref_outp | sed "s/\./.${ex}./g"`
1506      echo "UNAMEA='$UNAMEA'" >> $CDIR"/summary.txt"              #  Create an output dir & summary.txt file for each extra run (tdir.ex)
1507      echo "DATE='$DATE'" >> $CDIR"/summary.txt"              locDIR=$DRESULTS"/"$dir"."$ex
1508      echo "tdir='$dir'" >> $CDIR"/summary.txt"              mkdir $locDIR
1509                    #- report to this experiment local summary file ---
1510      (              echo "DATE='$DATE' ; tdir='$dir.$ex'" > $locDIR"/summary.txt"
1511          cd $DRESULTS              #echo "MACH='$MACH'" >> $locDIR"/summary.txt"
1512          tar -cf $NDIR".tar" $DRESULTS"_"$NDIR > /dev/null 2>&1              #echo "UNAMEA='$UNAMEA'" >> $locDIR"/summary.txt"
1513          gzip $NDIR".tar"              CDIR=`pwd`"/$locDIR"
1514      )              test ! -e "$dir/$pfxdir.$ex" && mkdir "$dir/$pfxdir.$ex"
1515                    run_clean $dir/$pfxdir.$ex
1516      if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then              linkdata $dir/$pfxdir.$ex $inputdir.$ex $inputdir
1517          echo "No mail sent"              runmodel $dir/$pfxdir.$ex && run=Y \
1518      else              && results=`testoutput_run $dir $pfxdir.$ex $refExOut`
1519          $MPACK -s MITgcm-test -m 1000000 $DRESULTS"/"$NDIR".tar.gz" $ADDRESSES              fres=`formatresults $dir ${genmake:-N} ${makedepend:-N} ${make:-N} ${run:-N} $results`
1520          RETVAL=$?              fres="$fres.$ex"
1521          if test "x$RETVAL" != x0 ; then              echo 1>&2
1522              echo "Warning: \"$MPACK\" failed -- please contact <edhill@mitgcm.org>"              echo "$fres" | sed 's/ 99/ --/g' | sed 's/  > />/' | sed 's/  < /</' >> $SUMMARY
1523          else              echo "fresults='$fres'" | sed 's/ 99/ --/g' >> $locDIR"/summary.txt"
1524              rm -f $DRESULTS"/"$NDIR".tar*"              if test "x$POSTCLEAN" = x2 ; then
1525                    run_clean $dir/$pfxdir.$ex
1526                fi
1527            done
1528    
1529        if test -f $DRESULTS"/"genmake_state ; then : ; else
1530            if test -f $dir/$builddir/Makefile ; then
1531                mkOpt=`grep '^# OPTFILE=' $dir/$builddir/Makefile 2>/dev/null | head -1 | sed 's/^# //'`
1532                echo "from '$dir/$builddir/Makefile', extract:" > $DRESULTS/genmake_state
1533                sed -n '/^# executed by:/,+1 p' $dir/$builddir/Makefile >> $DRESULTS/genmake_state
1534                echo " $mkOpt" >> $DRESULTS/genmake_state
1535                if test "x$OPTFILE" = xNONE ; then
1536                    eval $mkOpt
1537                    sed "/^No \"OPTFILE\" was specified ; genmake2/a\  OPTFILE=${OPTFILE}"\
1538                            $SUMMARY > tr_0.tmp_log
1539                    RETVAL=$?
1540                    if test "x$RETVAL" = x0 ; then rm -f $SUMMARY
1541                            cp tr_0.tmp_log $SUMMARY
1542                    else rm -f tr_0.tmp_log
1543                    fi
1544                fi
1545                gmkLog=$dir/$builddir/genmake.log
1546                grep '^Get compiler version using:' $gmkLog > /dev/null 2>&1
1547                RETVAL=$?
1548                if test "x$RETVAL" = x0 ; then
1549                    echo "from '$gmkLog', extract compiler version:" >> $DRESULTS/genmake_state
1550                    sed -n '/Get compiler version/,/<-- compiler version/p' $gmkLog \
1551                            | grep -v '^... compiler version ' > tr_1.tmp_log
1552                    sed -n '1p' tr_1.tmp_log >> $DRESULTS/genmake_state
1553                    sed -n '2,/^$/p' tr_1.tmp_log | sed '/^$/d' | sed 's/^./ &/' \
1554                            >> $DRESULTS/genmake_state
1555                    rm -f tr_1.tmp_log
1556                fi
1557          fi          fi
1558      fi      fi
1559        #postclean $dir/$builddir
1560        if test "x$POSTCLEAN" = x2 ; then
1561            makeclean $dir/$builddir \
1562                && run_clean $dir/$rundir
1563        fi
1564        if test "x$MPI" != x0 -a "x$MPI_MFILE" != x ; then rm -f $LOC_MFILE ; fi
1565    
1566      echo "-------------------------------------------------------------------------------"      echo "-------------------------------------------------------------------------------"
1567        
     NDIR=$(( $NDIR + 1 ))  
       
1568  done  done
1569    
1570  echo -n "Start time:  " >> $SUMMARY  printf "Start time:  " >> $SUMMARY
1571  date -r dfile >> $SUMMARY  echo "$start_date" >> $SUMMARY
1572  echo -n "End time:    " >> $SUMMARY  printf "End time:    " >> $SUMMARY
1573  date >> $SUMMARY  date >> $SUMMARY
1574    
1575  rm tmp_cmpnum.f a.out dfile  #  If addresses were supplied and mpack built successfully, then try
1576    #  to send email using mpack.
1577    if test "x$ADDRESSES" = xNONE -o "x$ADDRESSES" = x ; then
1578        echo "No results email was sent."
1579    else
1580        if test "x$HAVE_MPACK" = xt ; then
1581            tar -cf $DRESULTS".tar" $DRESULTS > /dev/null 2>&1 \
1582                && gzip $DRESULTS".tar" \
1583                && $MPACK -s MITgcm-test -m 3555000 $DRESULTS".tar.gz" $ADDRESSES
1584            RETVAL=$?
1585            if test "x$RETVAL" != x0 ; then
1586                echo
1587                echo "Warning: The tar, gzip, & mpack step failed.  Please send email"
1588                echo "  to <MITgcm-support@mitgcm.org> for help.  You may copy the "
1589                echo "  summary of results from the directory \"$DRESULTS\"."
1590                echo
1591            else
1592                echo
1593                echo "An email containing results was sent to the following addresses:"
1594                echo "  \"$ADDRESSES\""
1595                echo
1596                test -f $DRESULTS".tar"  &&  rm -f $DRESULTS".tar"
1597                test -f $DRESULTS".tar.gz"  &&  rm -f $DRESULTS".tar.gz"
1598            fi
1599        fi
1600    fi
1601    
1602    if test "x$QUICK" = xf -a "x$NORUN" = xf ; then
1603        rm -f tr_cmpnum.c tr_cmpnum
1604    fi
1605    
1606  if test "x$CLEANUP" != xt ; then  if test "x$CLEANUP" != xt ; then
1607      cat $SUMMARY      cat $SUMMARY | sed 's/ \.  \.  \.  \.  \.  \.  \.  \.  \.  \.  \.  \. //'
1608      if test -e tr.out ; then      if test -e tr_out.txt ; then
1609          mv tr.out tr.out.old          mv tr_out.txt tr_out.txt.old
1610      fi      fi
1611      cat $SUMMARY > tr.out      cat $SUMMARY | sed '/^[YN] [YN] [YN] [YN]/ s/ \. //g' > tr_out.txt
1612    fi
1613    
1614    if test "x$DELDIR" = xt ; then
1615        rm -rf $DRESULTS
1616  fi  fi
1617    

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

  ViewVC Help
Powered by ViewVC 1.1.22