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