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

Legend:
Removed from v.1.32  
changed lines
  Added in v.1.164

  ViewVC Help
Powered by ViewVC 1.1.22