MODFLOW 6 version 6.9.0.dev0
USGS Modular Hydrologic Model
Loading...
Searching...
No Matches
sortmodule::unique_values Interface Reference
Collaboration diagram for sortmodule::unique_values:
Collaboration graph

Public Member Functions

subroutine unique_values_int1d (a, b)
subroutine unique_values_dbl1d (a, b)

Detailed Description

Definition at line 15 of file sort.f90.

Member Function/Subroutine Documentation

◆ unique_values_dbl1d()

subroutine sortmodule::unique_values::unique_values_dbl1d ( real(dp), dimension(:), intent(in), allocatable a,
real(dp), dimension(:), intent(inout), allocatable b )

Definition at line 329 of file sort.f90.

330 ! - dummy arguments
331 real(DP), dimension(:), allocatable, intent(in) :: a
332 real(DP), dimension(:), allocatable, intent(inout) :: b
333 ! -- local variables
334 integer(I4B) :: count
335 integer(I4B) :: n
336 integer(I4B), dimension(:), allocatable :: indxarr
337 real(DP), dimension(:), allocatable :: tarr
338 ! -- functions
339 ! -- code
340 !
341 ! -- allocate tarr and create idxarr
342 allocate (tarr(size(a)))
343 allocate (indxarr(size(a)))
344 !
345 ! -- fill tarr with a and create index
346 do n = 1, size(a)
347 tarr(n) = a(n)
348 indxarr(n) = n
349 end do
350 !
351 ! -- sort a in increasing order
352 call qsort(indxarr, tarr, reverse=.true.)
353 !
354 ! -- determine the number of unique values
355 count = 1
356 do n = 2, size(tarr)
357 if (tarr(n) > tarr(n - 1)) count = count + 1
358 end do
359 !
360 ! -- allocate b for unique values
361 if (allocated(b)) then
362 deallocate (b)
363 end if
364 allocate (b(count))
365 !
366 ! -- fill b with unique values
367 b(1) = tarr(1)
368 count = 1
369 do n = 2, size(a)
370 if (tarr(n) > b(count)) then
371 count = count + 1
372 b(count) = tarr(n)
373 end if
374 end do
375 !
376 ! -- allocate tarr and create idxarr
377 deallocate (tarr)
378 deallocate (indxarr)

◆ unique_values_int1d()

subroutine sortmodule::unique_values::unique_values_int1d ( integer(i4b), dimension(:), intent(in), allocatable a,
integer(i4b), dimension(:), intent(inout), allocatable b )

Definition at line 277 of file sort.f90.

278 ! - dummy arguments
279 integer(I4B), dimension(:), allocatable, intent(in) :: a
280 integer(I4B), dimension(:), allocatable, intent(inout) :: b
281 ! -- local variables
282 integer(I4B) :: count
283 integer(I4B) :: n
284 integer(I4B), dimension(:), allocatable :: indxarr
285 integer(I4B), dimension(:), allocatable :: tarr
286 ! -- functions
287 ! -- code
288 !
289 ! -- allocate tarr and create idxarr
290 allocate (tarr(size(a)))
291 allocate (indxarr(size(a)))
292 !
293 ! -- fill tarr with a and create index
294 do n = 1, size(a)
295 tarr(n) = a(n)
296 indxarr(n) = n
297 end do
298 !
299 ! -- sort a in increasing order
300 call qsort(indxarr, tarr, reverse=.true.)
301 !
302 ! -- determine the number of unique values
303 count = 1
304 do n = 2, size(tarr)
305 if (tarr(n) > tarr(n - 1)) count = count + 1
306 end do
307 !
308 ! -- allocate b for unique values
309 if (allocated(b)) then
310 deallocate (b)
311 end if
312 allocate (b(count))
313 !
314 ! -- fill b with unique values
315 b(1) = tarr(1)
316 count = 1
317 do n = 2, size(a)
318 if (tarr(n) > b(count)) then
319 count = count + 1
320 b(count) = tarr(n)
321 end if
322 end do
323 !
324 ! -- allocate tarr and create idxarr
325 deallocate (tarr)
326 deallocate (indxarr)

The documentation for this interface was generated from the following file:
  • /home/runner/work/modflow6/modflow6/src/Utilities/sort.f90