Two valuable hints from @pmk (priv.comm.), plus some my additions:
- A pointer dummy argument with
INTENT(IN)
can be associated with a non-pointer actual argument (see 15.5.2.7) as if it were a pointer assignment statement. For arrays, the bounds are “preserved” only if the target is a whole array (i.e. array component or array name without further qualification, see 3.156, 9.5.2), otherwise lbounds are set to 1. - One can combine the power and flexibility of assumed-shaped array dummy args with the idea of explicit-shape/adjustable-array to get original bounds in the procedure, w/o using
allocatable/pointer
dummy args
real :: tab(0:9,0:19)
real, allocatable :: atab(:,:)
allocate(atab(-1:5,-2:8))
call foo(tab, lbound(tab)) ! prints 0 0
call foo(atab, lbound(atab)) ! prints -1 -2
...
contains
subroutine foo(arr, lbs)
integer, intent(in) :: lbs(2)
real, intent(in out) :: arr(lbs(1):,lbs(2):) ! assumed-shape with forced lbounds
print *, lbound(arr)
...
end