MODFLOW 6  version 6.7.0.dev0
USGS Modular Hydrologic Model
GridSorting.f90 File Reference

Go to the source code of this file.

Modules

module  gridsorting
 

Functions/Subroutines

subroutine, public gridsorting::quicksortgrid (array, arraySize, idxToGlobal)
 
subroutine init ()
 
logical(lgp) function lessthan (n, m)
 
subroutine swap (a, b)
 
subroutine rshift (left, right)
 

Function/Subroutine Documentation

◆ init()

subroutine quicksortgrid::init
private

Definition at line 23 of file GridSorting.f90.

Here is the caller graph for this function:

◆ lessthan()

logical(lgp) function quicksortgrid::lessthan ( integer(i4b), intent(in)  n,
integer(i4b), intent(in)  m 
)
private

Definition at line 28 of file GridSorting.f90.

29  integer(I4B), intent(in) :: n
30  integer(I4B), intent(in) :: m
31  logical(LGP) :: isLess
32  ! local
33  type(GlobalCellType), pointer :: gcn, gcm
34  real(DP) :: xn, yn, zn, xm, ym, zm
35  real(DP), dimension(:), pointer, contiguous :: dis_top_n, dis_bot_n, &
36  dis_top_m, dis_bot_m
37  real(DP), dimension(:), pointer, contiguous :: dis_xc_n, dis_yc_n, &
38  dis_xc_m, dis_yc_m
39  real(DP) :: xorigin_n, yorigin_n, angrot_n, &
40  xorigin_m, yorigin_m, angrot_m
41 
42  ! get coordinates
43  gcn => idxtoglobal(array(n))
44  gcm => idxtoglobal(array(m))
45 
46  ! get model data
47  ! for n:
48  dis_top_n => gcn%v_model%dis_top%get_array()
49  dis_bot_n => gcn%v_model%dis_bot%get_array()
50  dis_xc_n => gcn%v_model%dis_xc%get_array()
51  dis_yc_n => gcn%v_model%dis_yc%get_array()
52  xorigin_n = gcn%v_model%dis_xorigin%get()
53  yorigin_n = gcn%v_model%dis_yorigin%get()
54  angrot_n = gcn%v_model%dis_angrot%get()
55  ! for m:
56  dis_top_m => gcm%v_model%dis_top%get_array()
57  dis_bot_m => gcm%v_model%dis_bot%get_array()
58  dis_xc_m => gcm%v_model%dis_xc%get_array()
59  dis_yc_m => gcm%v_model%dis_yc%get_array()
60  xorigin_m = gcm%v_model%dis_xorigin%get()
61  yorigin_m = gcm%v_model%dis_yorigin%get()
62  angrot_m = gcm%v_model%dis_angrot%get()
63 
64  ! convert coordinates
65  call dis_transform_xy(dis_xc_n(gcn%index), dis_yc_n(gcn%index), &
66  xorigin_n, yorigin_n, angrot_n, &
67  xn, yn)
68  zn = dhalf * (dis_top_n(gcn%index) + &
69  dis_bot_n(gcn%index))
70 
71  call dis_transform_xy(dis_xc_m(gcm%index), dis_yc_m(gcm%index), &
72  xorigin_m, yorigin_m, angrot_m, &
73  xm, ym)
74  zm = dhalf * (dis_top_m(gcm%index) + &
75  dis_bot_m(gcm%index))
76 
77  ! compare
78  if (.not. is_close(zn, zm, 10 * epsilon(zn))) then
79  isless = zn > zm
80  else if (.not. is_close(yn, ym, 10 * epsilon(yn))) then
81  isless = yn > ym
82  else if (.not. is_close(xn, xm, 10 * epsilon(xn))) then
83  isless = xn < xm
84  else
85  isless = .false.
86  end if
87 
Here is the call graph for this function:

◆ rshift()

subroutine quicksortgrid::rshift ( integer, intent(in)  left,
integer, intent(in)  right 
)
private

Definition at line 102 of file GridSorting.f90.

103  integer, intent(in) :: left, right
104  integer :: hold
105 
106  hold = array(right)
107  array(left + 1:right) = array(left:right - 1)
108  array(left) = hold
109 

◆ swap()

subroutine quicksortgrid::swap ( integer, intent(in)  a,
integer, intent(in)  b 
)
private

Definition at line 91 of file GridSorting.f90.

92  integer, intent(in) :: a, b
93  integer :: hold
94 
95  hold = array(a)
96  array(a) = array(b)
97  array(b) = hold
98