Re: ALLOCATE and contiguous memory
From: James Giles (jamesgiles_at_worldnet.att.net)
Date: Tue, 12 Oct 2004 18:36:03 GMT
Richard E Maine wrote:
> But for the kind of architecture where one can ask simply about
> contiguity without needing to first write a thesis explaining
> what the term implies, then yes, regular arrays are stored in
> contiguous memory, and allocatables just the same.
All true (including the parts I elided), but beware! If the array
is a dummy argument, especially if declared as an assumed shape
array, and the corresponding actual argument is an array slice,
then the array will possibly (even probably) not be contiguous,
even though it doesn't have the pointer attribute.
I didn't see it mentioned whether the array in question actually
has the ALLOCATABLE attribute in the context where the call
to the C routine is made, or whether it was merely allocated
elsewhere and passed into the context where the C routine is
called. Hence the possible relevance of this issue.
Note also that if your compiler "thinks" the C routine is a Fortran
routine and your call uses array slice syntax, the compiler may be
passing a descriptor that C won't understand. Probably more details
about the OP's code and what symptoms are observed would be
-- J. Giles "I conclude that there are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies and the other way is to make it so complicated that there are no obvious deficiencies." -- C. A. R. Hoare