2D AMRCLAW
findcut.f
Go to the documentation of this file.
1 c
2 c -----------------------------------------------------------
3 c
4  subroutine findcut(icl,iscr,jscr,idim,jdim,index,iside,
5  1 ilo,ihi,jlo,jhi)
6 c
7 c ::::::::::::::::::::: FINDCUT ::::::::::::::::::::::::::::;
8 c find best place to split the 2D array of flagged points
9 c either split at a hole, or use signatures to find
10 c zero crossing of laplacian.
11 c ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::;
12 c
13  use amr_module
14  implicit double precision (a-h,o-z)
15 
16 
17  dimension iscr(idim), jscr(jdim)
18 
19 c Modified 6/02:
20 c Include call.i to get def's of horizontal/vertical.
21 c integer horizontal, vertical
22 c parameter(horizontal = 1)
23 c parameter(vertical = 2)
24 
25  parameter(ithres = 2)
26  parameter(minoff = 2)
27 c
28 c look for holes first in horizontal then vertical direction
29 c
30  do 10 i = ilo, ihi
31  if (iscr(i) .eq. 0) then
32  index = i
33  iside = horizontal
34  return
35  endif
36  10 continue
37 
38  do 20 j = jlo, jhi
39  if (jscr(j) .eq. 0) then
40  index = j
41  iside = vertical
42  return
43  endif
44  20 continue
45 
46 c
47 c no holes - find 2nd derivative of signatures for best cut.
48 c overwrite signature arrays. don't make cuts less than minoff
49 c from boundary
50 c
51  ipre = iscr(ilo)
52  do 50 i = ilo+1, ihi-1
53  icur = iscr(i)
54  iscr(i) = iscr(i+1)-2*icur+ipre
55  ipre = icur
56  50 continue
57 
58  locmaxi = 0
59  indexi = 0
60  imid = (ilo + ihi) / 2
61  do 60 i = ilo+minoff, ihi-minoff+1
62  itemp1 = iscr(i-1)
63  itemp2 = iscr(i)
64  locdif = iabs(itemp1-itemp2)
65  if (itemp1*itemp2.lt.0) then
66  if (locdif .gt. locmaxi) then
67  locmaxi = locdif
68  indexi = i
69  else if (locdif .eq. locmaxi) then
70  if (iabs(i-imid).lt.iabs(indexi-imid)) indexi = i
71  endif
72  endif
73  60 continue
74 
75 
76  jpre = jscr(jlo)
77  do 130 j = jlo+1, jhi-1
78  jcur = jscr(j)
79  jscr(j) = jscr(j+1)-2*jcur+jpre
80  jpre = jcur
81  130 continue
82 
83  locmaxj = 0
84  indexj = 0
85  jmid = (jlo + jhi) / 2
86  do 160 j = jlo+minoff, jhi-minoff+1
87  jtemp1 = jscr(j-1)
88  jtemp2 = jscr(j)
89  locdif = iabs(jtemp1-jtemp2)
90  if (jtemp1*jtemp2.lt.0) then
91  if (locdif .gt. locmaxj) then
92  locmaxj = locdif
93  indexj = j
94  else if (locdif .eq. locmaxj) then
95  if (iabs(j-jmid).lt.iabs(indexj-jmid)) indexj = j
96  endif
97  endif
98  160 continue
99 c
100 c ::::: choose max dif for splitting
101 c
102  220 if (locmaxi .gt. locmaxj) then
103  index = indexi
104  iside = horizontal
105  locmax = locmaxi
106  else if (locmaxi .lt. locmaxj) then
107  index = indexj
108  iside = vertical
109  locmax = locmaxj
110  else if (iabs(indexi-imid).lt.iabs(indexj-jmid)) then
111  index = indexi
112  iside = horizontal
113  locmax = locmaxi
114  else
115  index = indexj
116  iside = vertical
117  locmax = locmaxj
118  endif
119 
120 c ::::: if inflection pt. not over the threshold, signal
121 c ::::: with index 0 (out of range)
122  if (locmax .lt. ithres) index = 0
123 
124  return
125  end
subroutine findcut(icl, iscr, jscr, idim, jdim, index, iside, ilo, ihi, jlo, jhi)
Definition: findcut.f:4