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

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

  ViewVC Help
Powered by ViewVC 1.1.22