Skip to content

Commit 4ab5fcf

Browse files
gareth-nxjvdp1
andauthored
Apply suggestions from code review by jvdp1
Co-authored-by: Jeremie Vandenplas <jeremie.vandenplas@gmail.com>
1 parent 533ea51 commit 4ab5fcf

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/stdlib_selection.fypp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,21 +107,21 @@ contains
107107
end do
108108

109109
contains
110-
subroutine swap(a, b)
110+
pure subroutine swap(a, b)
111111
${arraytype}$, intent(inout) :: a, b
112112
${arraytype}$ :: tmp
113113
tmp = a; a = b; b = tmp
114114
end subroutine
115115

116-
subroutine medianOf3(a, left, mid, right)
116+
pure subroutine medianOf3(a, left, mid, right)
117117
${arraytype}$, intent(inout) :: a(:)
118118
${inttype}$, intent(in) :: left, mid, right
119119
if(a(right) < a(left)) call swap(a(right), a(left))
120120
if(a(mid) < a(left)) call swap(a(mid) , a(left))
121121
if(a(right) < a(mid) ) call swap(a(mid) , a(right))
122122
end subroutine
123123

124-
subroutine partition(array,left,right,iPivot)
124+
pure subroutine partition(array,left,right,iPivot)
125125
${arraytype}$, intent(inout) :: array(:)
126126
${inttype}$, intent(in) :: left, right
127127
${inttype}$, intent(out) :: iPivot
@@ -223,13 +223,13 @@ contains
223223
end do
224224

225225
contains
226-
subroutine swap(a, b)
226+
pure subroutine swap(a, b)
227227
${inttype}$, intent(inout) :: a, b
228228
${inttype}$ :: tmp
229229
tmp = a; a = b; b = tmp
230230
end subroutine
231231

232-
subroutine arg_medianOf3(a, indx, left, mid, right)
232+
pure subroutine arg_medianOf3(a, indx, left, mid, right)
233233
${arraytype}$, intent(in) :: a(:)
234234
${inttype}$, intent(inout) :: indx(:)
235235
${inttype}$, intent(in) :: left, mid, right
@@ -238,7 +238,7 @@ contains
238238
if(a(indx(right)) < a(indx(mid)) ) call swap(indx(mid) , indx(right))
239239
end subroutine
240240

241-
subroutine arg_partition(array, indx, left,right,iPivot)
241+
pure subroutine arg_partition(array, indx, left,right,iPivot)
242242
${arraytype}$, intent(in) :: array(:)
243243
${inttype}$, intent(inout) :: indx(:)
244244
${inttype}$, intent(in) :: left, right

0 commit comments

Comments
 (0)