Definition at line 11 of file sort.f90.
◆ qsort_dbl1d()
subroutine sortmodule::qsort::qsort_dbl1d |
( |
integer(i4b), dimension(:), intent(inout) |
indx, |
|
|
real(dp), dimension(:), intent(inout) |
v, |
|
|
logical, intent(in), optional |
reverse |
|
) |
| |
|
private |
Definition at line 151 of file sort.f90.
153 integer(I4B),
dimension(:),
intent(inout) :: indx
154 real(DP),
dimension(:),
intent(inout) :: v
155 logical,
intent(in),
optional :: reverse
158 integer(I4B),
parameter :: nn = 15
159 integer(I4B),
parameter :: nstack = 50
160 integer(I4B) :: nsize
164 integer(I4B) :: jstack
165 integer(I4B) :: ileft
166 integer(I4B) :: iright
167 integer(I4B),
dimension(nstack) :: istack
175 if (
present(reverse))
then
189 if (iright - ileft < nn)
then
190 do j = (ileft + 1), iright
193 do i = (j - 1), ileft, -1
196 indx(i + 1) = indx(i)
201 if (jstack == 0)
return
202 iright = istack(jstack)
203 ileft = istack(jstack - 1)
206 k = (ileft + iright) / 2
207 call rswap(v(k), v(ileft + 1))
208 call iswap(indx(k), indx(ileft + 1))
209 if (v(ileft) > v(iright))
then
210 call rswap(v(ileft), v(iright))
211 call iswap(indx(ileft), indx(iright))
213 if (v(ileft + 1) > v(iright))
then
214 call rswap(v(ileft + 1), v(iright))
215 call iswap(indx(ileft + 1), indx(iright))
217 if (v(ileft) > v(ileft + 1))
then
218 call rswap(v(ileft), v(ileft + 1))
219 call iswap(indx(ileft), indx(ileft + 1))
241 call rswap(v(i), v(j))
242 call iswap(indx(i), indx(j))
245 indx(ileft + 1) = indx(j)
249 if (jstack > nstack)
then
250 write (errmsg,
'(a,3(1x,a))') &
251 'JSTACK > NSTACK IN SortModule::qsort'
252 call store_error(errmsg, terminate=.true.)
254 if ((iright - i + 1) >= (j - 1))
then
255 istack(jstack) = iright
256 istack(jstack - 1) = i
259 istack(jstack) = j - 1
260 istack(jstack - 1) = ileft
270 call rswap(v(i), v(j))
271 call iswap(indx(i), indx(j))
◆ qsort_int1d()
subroutine sortmodule::qsort::qsort_int1d |
( |
integer(i4b), dimension(:), intent(inout) |
indx, |
|
|
integer(i4b), dimension(:), intent(inout) |
v, |
|
|
logical, intent(in), optional |
reverse |
|
) |
| |
|
private |
Definition at line 23 of file sort.f90.
25 integer(I4B),
dimension(:),
intent(inout) :: indx
26 integer(I4B),
dimension(:),
intent(inout) :: v
27 logical,
intent(in),
optional :: reverse
30 integer(I4B),
parameter :: nn = 15
31 integer(I4B),
parameter :: nstack = 50
36 integer(I4B) :: jstack
38 integer(I4B) :: iright
39 integer(I4B),
dimension(nstack) :: istack
47 if (
present(reverse))
then
61 if (iright - ileft < nn)
then
62 do j = (ileft + 1), iright
65 do i = (j - 1), ileft, -1
73 if (jstack == 0)
return
74 iright = istack(jstack)
75 ileft = istack(jstack - 1)
78 k = (ileft + iright) / 2
79 call iswap(v(k), v(ileft + 1))
80 call iswap(indx(k), indx(ileft + 1))
81 if (v(ileft) > v(iright))
then
82 call iswap(v(ileft), v(iright))
83 call iswap(indx(ileft), indx(iright))
85 if (v(ileft + 1) > v(iright))
then
86 call iswap(v(ileft + 1), v(iright))
87 call iswap(indx(ileft + 1), indx(iright))
89 if (v(ileft) > v(ileft + 1))
then
90 call iswap(v(ileft), v(ileft + 1))
91 call iswap(indx(ileft), indx(ileft + 1))
113 call iswap(v(i), v(j))
114 call iswap(indx(i), indx(j))
117 indx(ileft + 1) = indx(j)
121 if (jstack > nstack)
then
122 write (errmsg,
'(a,3(1x,a))') &
123 'JSTACK > NSTACK IN SortModule::qsort'
124 call store_error(errmsg, terminate=.true.)
126 if ((iright - i + 1) >= (j - 1))
then
127 istack(jstack) = iright
128 istack(jstack - 1) = i
131 istack(jstack) = j - 1
132 istack(jstack - 1) = ileft
142 call iswap(v(i), v(j))
143 call iswap(indx(i), indx(j))
The documentation for this interface was generated from the following file:
- /home/runner/work/modflow6/modflow6/src/Utilities/sort.f90