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