SUEWS API Site
Documentation of SUEWS source code
Functions/Subroutines
qsort_c_module Module Reference

Functions/Subroutines

recursive subroutine, public qsortc (A)
 
subroutine, private partition (A, marker)
 

Function/Subroutine Documentation

◆ partition()

subroutine, private qsort_c_module::partition ( real, dimension(:), intent(inout)  A,
integer, intent(out)  marker 
)
private

Definition at line 29 of file suews_util_qsort.f95.

Referenced by qsortc().

29  REAL, INTENT(in out), DIMENSION(:) :: a
30  INTEGER, INTENT(out) :: marker
31  INTEGER :: i, j
32  REAL :: temp
33  REAL :: x ! pivot point
34  x = a(1)
35  i = 0
36  j = SIZE(a) + 1
37 
38  DO
39  j = j - 1
40  DO
41  IF (a(j) <= x) EXIT
42  j = j - 1
43  END DO
44  i = i + 1
45  DO
46  IF (a(i) >= x) EXIT
47  i = i + 1
48  END DO
49  IF (i < j) THEN
50  ! exchange A(i) and A(j)
51  temp = a(i)
52  a(i) = a(j)
53  a(j) = temp
54  ELSEIF (i == j) THEN
55  marker = i + 1
56  RETURN
57  ELSE
58  marker = i
59  RETURN
60  ENDIF
61  END DO
62 
Here is the caller graph for this function:

◆ qsortc()

recursive subroutine, public qsort_c_module::qsortc ( real, dimension(:), intent(inout)  A)

Definition at line 18 of file suews_util_qsort.f95.

References partition().

18  REAL, INTENT(in out), DIMENSION(:) :: a
19  INTEGER :: iq
20 
21  IF (SIZE(a) > 1) THEN
22  CALL partition(a, iq)
23  CALL qsortc(a(:iq - 1))
24  CALL qsortc(a(iq:))
25  ENDIF
Here is the call graph for this function: