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

Legend:
Removed from v.1.9.2.8  
changed lines
  Added in v.1.162

  ViewVC Help
Powered by ViewVC 1.1.22