Re: Interface Question
- From: "A" <born.2be.wyld@xxxxxxxxx>
- Date: 28 Jun 2006 20:55:31 -0700
Thanks. That helps
Richard Maine wrote:
Arjen Markus <arjen.markus@xxxxxxxxxx> wrote:
A schreef:
Inside of A.f90 looks something like this
INTERFACE
SUBROUTINE C
...................
...................
END SUBROUTINE C
END INTERFACE
Can someone explain what this INTERFACE block is meant for. I know
INTERFACE could be used to achieve "overloading" of operators or
defining generic routines. But I don't understand what's going on here.
The INTERFACE block defines how subroutine C is supposed to be used. The
compiler can then check if the code has a syntactically correct call to
the subroutine, that is: correct number of arguments, correct types,
kinds, dimensions, correct order.
Also, the interface information is necessary for some features to work
correctly; that's more than just checking. For example, if the
subroutine has an assumed shape dummy array, the compiler needs to know
that in order to pass the necessary shape information.
I might also add, in a small attempt to help clear up one confusion,
that interface blocks have two completely separate purposes. I
personally wish that they had been given different names instead of
calling them both versions of the same thing.
1. There are the interface blocks that define generics (overloads) like
the OP is thinking about. I'd have preferred that these be called
something more like generic (and they wouldn't have needed a block form;
a simple statement would do).
2. There are interface blocks that define specific interfaces. That's
like the example here. It has nothing to do with generic overloads. It
just happens to also be called aninterface block.
As best as I can tell, the two forms were mangled together so that you
could do both things at once in cases where both were needed. I think
that the minor convenience of doing both things together is inadquate
payoff for the confuson of the concepts involved, but it is too late to
do much about that.
--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
.
- References:
- Interface Question
- From: A
- Re: Interface Question
- From: Arjen Markus
- Re: Interface Question
- From: Richard Maine
- Interface Question
- Prev by Date: Re: heap allocation of arrays
- Next by Date: Re: recl on g95 and gfortran
- Previous by thread: Re: Interface Question
- Next by thread: Array size?
- Index(es):
Relevant Pages
|