James Abeles <[log in to unmask]> wrote on Fri, 28 Feb 2003 13:02 PST:
> We have a code that passes pointers. I think the standard requires that
> you define an explicit interface for the called routine. Here is a code
> fragment. Should the compiler flag an error if an interface is not
> declared?
A procedure needs to have explicit interface if a dummy argument has the
pointer attribute. If a dummy argument doesn't have the pointer attribute
and the actual argument does, this does not force one to have an explicit
interface. In this case, the pointer has to be associated with a target
when the call is executed, and the target of the pointer becomes associated
with the dummy argument.
Nearly every reason to have an explicit interface depends upon
characteristics of the procedure declaration, not upon references to it.
Those that depend upon references to it include using keywords instead of
positions to indicate which actual argument is which, and anything having
to do with genericity, including defined operations or defined assignment.
> Complex, Pointer, Dimension(:,:) :: pufn
> Complex, Pointer, Dimension(:,:) :: pvfn
> complex, dimension(idim,2*jj+2,2), target :: w2
>
> pufn =>w2(1:idim, 1: jj ,1)
> pvfn =>w2(1:idim, jj+1: 2*jj ,1)
>
> call abc(idim,pufn,pvfn)
>
> Here is abc which is compiled seperately:
>
> subroutine abc(idim,pu,pv)
> #include xyz <<jj defined here
> complex pu(idim,jj),pv(idim,jj)
>
>
> Second question, can the interface be declared :
>
> interface
> subroutine abc(idim,pu,pv)
> integer idim
> complex pu(:,:),pv(:,:)
> end interface
Sure, but it's probably easier to make the procedure a module procedure.
> Jim Abeles
> IBM Scientific and Technical Computing
> 301 879-3283 - work
> [log in to unmask]
--
Van Snyder | What fraction of Americans believe
[log in to unmask] | Wrestling is real and NASA is fake?
Any alleged opinions are my own and have not been approved or disapproved
by JPL, CalTech, NASA, Sean O'Keefe, George Bush, the Pope, or anybody else.
|