Re: Interface Question
- From: "Arjen Markus" <arjen.markus@xxxxxxxxxx>
- Date: 28 Jun 2006 00:07:57 -0700
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.
Usually this can be avoided by putting the subroutine in a module: it
is safer and easier because the interface is then known automatically
and there is only one place where it is defined - where the routine
itself
is defined.
If, however, subroutine C is a dummy argument, then an explicit
interface is a very useful mechanism: you declare explicitly what
your calling routine expects from any actual subroutine that is passed.
It is also useful if you have subroutines or functions not written in
Fortran
or if you lack the source to put them in a module.
First and foremost: INTERFACE helps the compiler to do the "right"
thing.
Hope this helps.
Regards,
Arjen
.
- Follow-Ups:
- Re: Interface Question
- From: Richard Maine
- Re: Interface Question
- References:
- Interface Question
- From: A
- Interface Question
- Prev by Date: Re: recl on g95 and gfortran
- Next by Date: Re: automatic variables are not initialized correctly?
- Previous by thread: Interface Question
- Next by thread: Re: Interface Question
- Index(es):
Relevant Pages
|
|