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

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

Relevant Pages

  • Re: gfortran and the family of fortran array types
    ... || only the base_addr field is passed to the C routine. ... there would be no problems at all with passing the above array to ... while in F77 one uses an assumed-size (or explicit-shape) dummy. ... compiler may mantain a dope vector internally, ...
  • Re: Idea for ECMA/C# Standard - compile time hash for performance
    ... I agree with you the chance of a compiler change is slim, ... and then delegating to the standard hash for fields accessed less frequently. ... or the array lookup which would require the ... > 64-bit architecture) for each enum value that doesn't map to anything. ...
  • Re: Windows array allocation problem
    ... array reference has to have a 64-bit index or array subscript triplet? ... to fit in one. ... That assumes, of course, that your compiler ... limits on just about anything. ...
  • Re: Q: Checking the size of a non-allocated array?
    ... an actual argument is already invalid ... First note that you don't have an unallocated array in the subroutine. ... it is comparable to disassociated or undefined pointers. ... Obviously the compiler has ...
  • Re: Is this expected behavior or not
    ... This gives you array interfaces while keeping arrays ... to know the representation in order to be able to pass it meaningfully. ... not a normal array if you are using the character interface). ... should have a tag and it's up to the compiler how to implement it. ...