Skip to content

Commit 0f4e635

Browse files
committed
add loop labels
1 parent f486148 commit 0f4e635

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/stdlib_selection.fypp

+10-10
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ contains
9090
error stop "select must have 1 <= k <= size(a), and 1 <= left <= right <= size(a)";
9191
end if
9292

93-
do
93+
searchk: do
9494
mid = l + ((r-l)/2_ip) ! Avoid (l+r)/2 which can cause overflow
9595

9696
call medianOf3(a, l, mid, r)
@@ -105,7 +105,7 @@ contains
105105
kth_smallest = a(k)
106106
return
107107
end if
108-
end do
108+
end do searchk
109109

110110
contains
111111
pure subroutine swap(a, b)
@@ -136,10 +136,10 @@ contains
136136
do while (array(hi) > pivot)
137137
hi=hi-1_ip
138138
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
141141
lo=lo+1_ip
142-
end do
142+
end do inner_lohi
143143
if (lo <= hi) then
144144
call swap(array(lo),array(hi))
145145
lo=lo+1_ip
@@ -206,7 +206,7 @@ contains
206206
error stop "arg_select must have 1 <= k <= size(a), and 1 <= left <= right <= size(a)";
207207
end if
208208

209-
do
209+
searchk: do
210210
mid = l + ((r-l)/2_ip) ! Avoid (l+r)/2 which can cause overflow
211211

212212
call arg_medianOf3(a, indx, l, mid, r)
@@ -221,7 +221,7 @@ contains
221221
kth_smallest = indx(k)
222222
return
223223
end if
224-
end do
224+
end do searchk
225225

226226
contains
227227
pure subroutine swap(a, b)
@@ -254,10 +254,10 @@ contains
254254
do while (array(indx(hi)) > pivot)
255255
hi=hi-1_ip
256256
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
259259
lo=lo+1_ip
260-
end do
260+
end do inner_lohi
261261
if (lo <= hi) then
262262
call swap(indx(lo),indx(hi))
263263
lo=lo+1_ip

0 commit comments

Comments
 (0)