2D AMRCLAW
smartbis.f
Go to the documentation of this file.
1 c
2 c ---------------------------------------------------------
3 c
4  subroutine smartbis(badpts,npts,cutoff,numptc,nclust,
5  1 lbase,intcorn,idim,jdim)
6 c 1 lbase,intcorn,iscr,jscr,idim,jdim)
7 c
8 c iscr, jscr now stackbased, no need for use of alloc
9 c
10  use amr_module
11  implicit double precision (a-h,o-z)
12 
13  dimension badpts(2,npts),intcorn(nsize,maxcl)
14 c
15 c iscr, jscr now stackbased, no need for use of alloc
16  dimension iscr(idim), jscr(jdim)
17  integer nclust, numptc(maxcl)
18  parameter(usemin=.4)
19 c
20 c :::::::::::::::::::::::::::: SMARTBIS :::::::::::::::::::::::::;
21 c smart bisect rectangles until cutoff reached for each.
22 c replaced old bisection routine that cut all grids in half.
23 c now look for good place to do the cut, based on holes or signatures.
24 c
25 c :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::;
26 c
27 c ## initially all points in 1 cluster
28  nclust = 1
29  numptc(1) = npts
30 
31  if (gprint) write(outunit,100) nclust
32  100 format(' starting smart bisection with ',i5,' clusters')
33 c
34  icl = 1
35  ist = 1
36  iend = numptc(icl)
37 c
38  10 call moment(intcorn(1,icl),badpts(1,ist),numptc(icl),usenew)
39  if (gprint) write(outunit,101) icl,numptc(icl),usenew
40  101 format(' testing cluster ',i8,' with ',i9,' pts. use ',e12.4)
41 c
42  if (usenew .lt. cutoff) go to 20
43 c
44 c this cluster ok - on to next
45 c
46  if (.not. gprint) go to 15
47  write(outunit,102) icl,numptc(icl),usenew
48  102 format(' accepting smart bisected cluster',i4,' with ',i5,
49  1 ' pts. use = ',e10.3)
50  15 icl = icl + 1
51  if (icl .gt. nclust) go to 200
52  ist = iend + 1
53  iend = ist + numptc(icl) - 1
54  go to 10
55 c
56 c smart bisect rectangle (and its cluster) in best location
57 c
58  20 if (nclust .lt. maxcl) go to 25
59  write(outunit,900) maxcl
60  write(* ,900) maxcl
61  900 format(' too many clusters: > ',i5)
62  stop
63  25 continue
64 c
65 c smart bisection computes signatures, finds best cut and splits there
66 c
67  call signs(badpts,npts,iscr,jscr,idim,jdim,
68  & ist,iend,ilo,ihi,jlo,jhi)
69  call findcut(icl,iscr,jscr,idim,jdim,index,iside,
70  & ilo,ihi,jlo,jhi)
71  if (index .eq. 0) then
72 
73 c if (usenew .gt. usemin) then
74 c icl = icl + 1
75 c if (icl .gt. nclust) go to 200
76 c ist = iend + 1
77 c iend = ist + numptc(icl) - 1
78 c go to 10
79 c else
80 c c bisect in long direction
81 c if (ihi-ilo .gt. jhi-jlo) then
82 c iside = horizontal
83 c index = (ilo + ihi)/2
84 c else
85 c iside = vertical
86 c index = (jlo + jhi)/2
87 c endif
88 c endif
89 
90 c 2/28/02 : 3d version uses this branch only; no 'if' statement.
91  icl = icl + 1
92  if (icl .gt. nclust) go to 200
93  ist = iend + 1
94  iend = ist + numptc(icl) - 1
95  go to 10
96  endif
97 c
98  if (iside .eq. vertical) then
99 c fmid = (index-.5)*hy
100  fmid = (index-.5)
101  idir = 2
102  else
103  fmid = (index-.5)
104  idir = 1
105  endif
106 c
107  itop = ist - 1
108  ibot = iend + 1
109  i = ist
110  50 if (badpts(idir,i) .lt. fmid) go to 60
111 c
112 c point in top half. let it stay, increment counter
113 c
114  itop = itop + 1
115  if (itop+1 .ge. ibot) go to 80
116  i = i + 1
117  go to 50
118 c
119 c point in bottom half. switch with a bottom point that's not yet
120 c checked, and increment bot. pointer
121 c
122  60 ibot = ibot - 1
123  temp = badpts(1,ibot)
124  badpts(1,ibot) = badpts(1,i)
125  badpts(1,i) = temp
126  temp = badpts(2,ibot)
127  badpts(2,ibot) = badpts(2,i)
128  badpts(2,i) = temp
129  if (itop+1 .lt. ibot) go to 50
130 c
131 c done smartbisecting icl'th clusters. adjust counts, repeat bisect stage .
132 c
133  80 numptc(icl) = itop - ist + 1
134  ibump = icl + 1
135 c
136 c bump down remaining clusters to make room for the new half of one.
137 c
138  if (ibump .gt. nclust) go to 120
139  do 90 ico = ibump, nclust
140  nmove = nclust - ico + ibump
141  90 numptc(nmove + 1) = numptc(nmove)
142 
143  120 numptc(ibump) = iend - ibot + 1
144  nclust = nclust + 1
145  iend = itop
146 c
147 c other half of the cluster has been inserted into cluster list.
148 c icl remains the same - need to redo it.
149  go to 10
150 c
151 c done: there are nclust clusters.
152 c
153  200 continue
154 c
155  return
156  end
subroutine signs(badpts, npts, iscr, jscr, idim, jdim, ist, iend, ilo, ihi, jlo, jhi)
Definition: signs.f:4
subroutine moment(intrect, badpts, npt, usage)
Definition: moment.f:4
subroutine smartbis(badpts, npts, cutoff, numptc, nclust, lbase, intcorn, idim, jdim)
Definition: smartbis.f:4
subroutine findcut(icl, iscr, jscr, idim, jdim, index, iside, ilo, ihi, jlo, jhi)
Definition: findcut.f:4