020. Loop variable after completion#
topic: Loops
The loop variable equals the upper bound plus the stride after normal completion of a loop.
integer :: i
do i = 1, 3
if (i > 1) exit
end do
print *, i ! 2
do i = 1, 3 ! stride of 1
continue ! placeholder
end do
print *, i ! 4
do i = 1, 3, 2 ! stride of 2
continue
end do
print *, i ! 5
end
2
4
5
The loop variable equals the upper bound plus the stride
— FortranTip (@fortrantip) December 19, 2021
after normal completion of a loop
integer :: i
do i=1,3
if (i > 1) exit
end do
print*,i ! 2
do i=1,3 ! stride of 1
continue ! placeholder
end do
print*,i ! 4
do i=1,3,2 ! stride of 2
continue
end do
print*,i ! 5
end
- 1
Compiled using
GNU Fortran (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
with no flags