Fortran array ubound function

Fortran-lang has an example, but I think a simpler example like this would be a useful addition:

program main ! output in comments
implicit none
real :: x(4),y(-4:3),z(5,-3:2,7)
print*,lbound(x),ubound(x)     ! 1 4
print*,lbound(y),ubound(y)     ! -4 3
print*,lbound(z)               ! 1 -3 1
print*,ubound(z)               ! 5 2 7
print*,lbound(z,2),ubound(z,2) ! -3 2
end program main
3 Likes