- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Not much different than with declarations:
allocate( fred(0:10) )
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page