Reputation: 3392
For static array one can explicitly define the lower bound like this:
real, dimension(2:6) :: numbers
I understand that dynamic arrays are declared like this:
real, dimension(:), allocatable :: numbers
allocate(numbers(6))
Is it possible to declare a dynamic array with a lower bound and/or an upper bound? If yes, how? If no, is there a reason why was this not or can't be implemented?
Upvotes: 1
Views: 261
Reputation: 32406
Yes, very simply:
allocate(numbers(2:6))
The upper bound must always be specified, but the lower bound is optional (and taken to be 1
if omitted).
Upvotes: 3