Reopening after 10 months, but here is something I just learned: the bounds of an allocatable array intent(in) or intent(in out) dummy argument are the same as those of the actual argument in the caller. Here is a short code showing what the bounds are for an
(1) assumed-shape dummy argument, declared as (:) – lbound = 1
(2) assumed-shape dummy argument, declared as (0:) – lbound = 0
(3) allocatable, intent(in) or intent(in out) argument – lbound = lbound of actual argument in caller
(4) assumed-shape dummy argument, declared as (lb:), where lb is an argument – lbound = lb
module m
implicit none
character (len=*), parameter :: fmt = "(a35,*(1x,i4))"
contains
!
subroutine print_bounds(x1,x2,x3,x4,lb)
integer, intent(in) :: lb
real , intent(in) :: x1(:)
real , intent(in) :: x2(0:)
real , intent(in), allocatable :: x3(:)
real , intent(in) :: x4(lb:)
print "(a)","entered print_bounds"
print fmt,"x1 bounds =",lbound(x1),ubound(x1)
print fmt,"x2 bounds =",lbound(x2),ubound(x2)
print fmt,"x3 bounds =",lbound(x3),ubound(x3)
print fmt,"x4 bounds =",lbound(x4),ubound(x4)
end subroutine print_bounds
end module m
!
program test_bounds
use m
real, allocatable :: x(:)
allocate (x(-2:3))
print fmt,"x bounds =",lbound(x),ubound(x)
call print_bounds(x,x,x,x,8)
end program test_bounds
! output:
! x bounds = -2 3
! entered print_bounds
! x1 bounds = 1 6
! x2 bounds = 0 5
! x3 bounds = -2 3
! x4 bounds = 8 13