Re: Calling Fortran 77 from Fortran 95



sturlamolden <sturlamolden@xxxxxxxx> wrote:

On 6 Mar, 20:51, n...@xxxxxxxxx wrote:

Just write the obvious code and it will all work.

real :: X(100,4)

X(1:10,:) ! whats the leading dimension of this? 10 or 100?

10, when passed to a procedures that uses an explicit-shape or
assumed-size argument, as LAPACK and all other Fortran 77 code
does.

So if I pass a slice like X(1:10,:) as an explicit-shape or assumed-
size array, I can depend on the compiler to make a temporary copy and
pass a contiguous array?

In practice, yes. The standard doesn't exactly say that. But it does say
that passing a slice like that to an explicit-shape or assumed-size
dummy array must work. A compiler could legally implement explicit-shape
and assumed-size arrays with things like dope vectors that accomodated
non-contiguous arrays, but none of them do... well almost none, and
anyway none you are likely to run in to.

In any case, the standard does require that the compiler do whatever is
needed to make passing such a slice work. If the compiler needs
contiguity for explicit-shape or assumed-size dummy arrays (as almost
all compilers do), then it has to do something to get such a contiguous
version. In practice, that means making a copy. I suppose one could
imagine some kind of esoteric virtual memory remapping, but it would
just be imagination.

--
Richard Maine | Good judgment comes from experience;
email: last name at domain . net | experience comes from bad judgment.
domain: summertriangle | -- Mark Twain
.