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

Legend:
Removed from v.1.25  
changed lines
  Added in v.1.208

  ViewVC Help
Powered by ViewVC 1.1.22