Re: INTERFACE problem



Richard Maine wrote:

glen herrmannsfeldt <gah@xxxxxxxxxxxxxxxx> writes:

From C.9.4 it seems that
without an INTERFACE Fortran 77 array passing rules still apply.

I don't think we are communicating very well.

I assumed that you understood how it wworks, but I begin to suspect
that the reason your posts on it might be misleading is perhaps
that you don't actually understand it fully.

Those same rules also apply *WITH* an interface, provided that the
interface describes what I might call f77-like arrays (explicit shape
or assumed size). Having an explicit interface makes *NO* difference at
all. What matters is what the dummy arrays are like. If the dummy
arrays look like f77 ones, then you will get f77-style passing no matter
whether you have an explicit interface or not.

I think I understood that, but the reference to Fortran 77 rules was meant to include passing an array element to an array dummy, and passing arrays with different rank than the dummy, both of which are somewhat unusual. (Well, you can pass to different rank in C, and pass the address of an array element, too.) Those pretty much just happen if you pass arrays and array elements by address only.


Also, the statement above "without an INTERFACE ..." was not meant to exclude the case with an INTERFACE, but just to be sure that all the old rules still apply in the no INTERFACE case. I didn't find the two cases mentioned, one way or the other, in the Sept. 2002 draft, but they are in the 77 standard, and the draft seems to indicate that Fortran 77 rules apply without an INTERFACE. (As you say, maybe not exclusively.)

I won't argue that those methods should be used, only that it seems that they are legal. Well, in addition to the discussion here there is a discussion on comp.arch.arithmetic on the ability to do bounds checking in different languages, and with different calling conventions. C and Fortran came up in the discussion because some of these are legal, yet could confuse the ability to do bounds checking.

-- glen

.



Relevant Pages

  • Re: couple c and fortran 95
    ... I would always put middleware layer at either side of the interface not just ... Fortran by Reference. ... arrays or by passing a pointer from the C side of the interface. ... C strings are null terminated arrays of character; ...
    (comp.lang.fortran)
  • Re: INTERFACE problem
    ... > without an INTERFACE Fortran 77 array passing rules still apply. ... Having an explicit interface makes *NO* difference at ... What matters is what the dummy arrays are like. ...
    (comp.lang.fortran)
  • Re: How to pass class as parameter?
    ... >> Brett wrote: ... >>> I have several classes that create arrays of data and have certain ... >>> MainClass makes use of third party objects to do this. ... across all the classes that will be implementing the interface. ...
    (microsoft.public.dotnet.languages.vb)
  • Copy-in/Copy-out
    ... I'm trying to understand Fortran's Copy-in/Copy-out of arrays, ... declared as a target or pointer, it should be safe to assign a pointer ... End Interface ... End Subroutine SubNormal ...
    (comp.lang.fortran)
  • Re: gfortran & adjustable array: most values remain zero
    ... Indeed I expected that adjustable arrays would work in 2D the same ... adjustable arrays of more than one dimension should be generally avoided ... the actual and dummy arrays don't ...
    (comp.lang.fortran)