Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
24 Views

Allocatable array with 0 base?

Is it possible to allocate an array, but have 0 as its base?

I know non-allocatable is easy with integer :: fred(0:10)

But I'm not sure how to do it with an allocatable array

0 Kudos
4 Replies
Highlighted
Valued Contributor II
24 Views

Not much different than with declarations:

allocate( fred(0:10) )

 

 

 

0 Kudos
Highlighted
Beginner
24 Views

Arjen Markus wrote:

Not much different than with declarations:

allocate( fred(0:10) )

oh dear, I'm sure I tried that a few months ago and it didn't work.  anyway works fine now thanks

0 Kudos
Highlighted
24 Views

Make sure you didn't try something like this:

real, allocatable :: fred(0:)
...
allocate (fred(0:10))

The declaration of fred has to be with (:) - no lower bound. If you have a lower bound, then it can't be allocatable (could be a dummy argument.)

Retired 12/31/2016
0 Kudos
Highlighted
Beginner
24 Views

Steve Lionel (Intel) wrote:

Make sure you didn't try something like this:

real, allocatable :: fred(0:)
...
allocate (fred(0:10))

The declaration of fred has to be with (:) - no lower bound. If you have a lower bound, then it can't be allocatable (could be a dummy argument.)

I may well have done that.  Thanks for the heads up.

0 Kudos