@@ -90,7 +90,7 @@ contains
90
90
error stop "select must have 1 <= k <= size(a), and 1 <= left <= right <= size(a)";
91
91
end if
92
92
93
- do
93
+ searchk: do
94
94
mid = l + ((r-l)/2_ip) ! Avoid (l+r)/2 which can cause overflow
95
95
96
96
call medianOf3(a, l, mid, r)
@@ -105,7 +105,7 @@ contains
105
105
kth_smallest = a(k)
106
106
return
107
107
end if
108
- end do
108
+ end do searchk
109
109
110
110
contains
111
111
pure subroutine swap(a, b)
@@ -136,10 +136,10 @@ contains
136
136
do while (array(hi) > pivot)
137
137
hi=hi-1_ip
138
138
end do
139
- do while (lo <= hi )
140
- if(array(lo) > pivot) exit
139
+ inner_lohi: do while (lo <= hi )
140
+ if(array(lo) > pivot) exit inner_lohi
141
141
lo=lo+1_ip
142
- end do
142
+ end do inner_lohi
143
143
if (lo <= hi) then
144
144
call swap(array(lo),array(hi))
145
145
lo=lo+1_ip
@@ -206,7 +206,7 @@ contains
206
206
error stop "arg_select must have 1 <= k <= size(a), and 1 <= left <= right <= size(a)";
207
207
end if
208
208
209
- do
209
+ searchk: do
210
210
mid = l + ((r-l)/2_ip) ! Avoid (l+r)/2 which can cause overflow
211
211
212
212
call arg_medianOf3(a, indx, l, mid, r)
@@ -221,7 +221,7 @@ contains
221
221
kth_smallest = indx(k)
222
222
return
223
223
end if
224
- end do
224
+ end do searchk
225
225
226
226
contains
227
227
pure subroutine swap(a, b)
@@ -254,10 +254,10 @@ contains
254
254
do while (array(indx(hi)) > pivot)
255
255
hi=hi-1_ip
256
256
end do
257
- do while (lo <= hi )
258
- if(array(indx(lo)) > pivot) exit
257
+ inner_lohi: do while (lo <= hi )
258
+ if(array(indx(lo)) > pivot) exit inner_lohi
259
259
lo=lo+1_ip
260
- end do
260
+ end do inner_lohi
261
261
if (lo <= hi) then
262
262
call swap(indx(lo),indx(hi))
263
263
lo=lo+1_ip
0 commit comments