2D AMRCLAW
drivesort.f
Go to the documentation of this file.
1 c
2 c -------------------------------------------------------------
3 c
4  subroutine drivesort(npts,badpts,level,index,mbuff)
5 
6  use amr_module
7  implicit double precision (a-h,o-z)
8  dimension badpts(2,npts)
9  dimension iflags(npts), ixarray(npts)
10  logical db/.false./
11 
12  iadd(i,j) = (i+mbuff) + (isize+2*mbuff)*(j+mbuff)
13 c
14 c convert using one dimensional ordering of badpts array as if
15 c it covered entire domain (xprob by yprob) on this level
16 c
17  isize = iregsz(level)
18  jsize = jregsz(level)
19 
20  do k = 1, npts
21  i = badpts(1,k)-.5 ! remember was shifted when put into array
22  j = badpts(2,k)-.5
23  intequiv = iadd(i,j)
24 c write(*,*)i,j," has equivalent integer ",intEquiv
25  iflags(k) = intequiv
26  end do
27 
28  call qsorti(ixarray, npts, iflags)
29 
30 c copy back to badpts, in sorted order, removing duplicates
31  k = 1
32  index = 0
33  do while (k .le. npts)
34  intequiv = iflags(ixarray(k))
35  index = index + 1
36  badpts(2,index) = intequiv/(isize+2*mbuff) + .5 -mbuff
37  badpts(1,index) = mod(intequiv,(isize+2*mbuff)) + .5 -mbuff
38  if (db) write(outunit,101) badpts(1,index),badpts(2,index)
39  101 format(2f6.1)
40  k = k + 1
41  do while ( k.le. npts) ! skip over duplicates
42  if (iflags(ixarray(k)) .eq. iflags(ixarray(k-1))) then
43 c write(*,*)" duplicate in sorted array loc ",ixarray(k)
44  k = k+1
45  else
46  exit ! back to outer loop
47  endif
48  end do
49  if (k .gt. npts) exit !did we stop because we ran off end or pts not equal
50  end do
51 
52  if (gprint) then
53  write(outunit,929) index
54  929 format(i5," flagged pts after removing duplicates and ",
55  & " non-nested flags")
56  endif
57 
58  return
59  end
subroutine qsorti(ORD, N, A)
Definition: quick_sort1.f:22
integer pure function iadd(ivar, i, j)
Definition: intfil.f90:293
subroutine drivesort(npts, badpts, level, index, mbuff)
Definition: drivesort.f:4