INTERFACE problem
Richard E Maine
Richard.Maine@nasa.gov
Thu Mar 9 20:00:00 GMT 2006
On Mar 9, 2006, at 9:05 AM, Steve Kargl wrote:
> On Thu, Mar 09, 2006 at 09:34:22AM -0700, Michael Webb wrote:
>>
>> Module IntTest2
>>
>> IMPLICIT NONE
>>
>> CONTAINS
>>
>> SUBROUTINE mytest(myfunc,x,s)
>> INTERFACE
>> FUNCTION myfunc(x,a,b)
>> REAL(8) x,a,b
>> END FUNCTION myfunc
>> END INTERFACE
>>
>> REAL(8), INTENT(IN) :: x
>> REAL(8), INTENT(OUT) :: s
>>
>> REAL(8) a,b
>>
>> s=myfunc(x,a,b)
>>
>> END SUBROUTINE mytest
>>
>> END MODULE IntTest2
...
> With gfortran your code gives,
>
> troutmask:kargl[204] gfc -c f.f90
> In file f.f90:7
>
> SUBROUTINE mytest(myfunc,x,s)
> 1
> Error: Symbol 'myfunc' at (1) has no IMPLICIT type
Then has someone submitted a bug report? :-) Because...
> In looking at your code, you need have used "IMPLICIT NONE"
> and you don't declare the return type form myfunc. If
> you add "REAL(8) myfunc" to the interface, then gfortran
> compiles your code.
However implicit mappings are not inherited into interface bodies. See
f95 [64:5-8], where this is discussed. Note the distinction made
between different kinds of scoping units. For interface bodies, the
default mapping does *NOT* come from the host. See also the comments in
Note 5.24, which illustrates the distinction.
Therefore, the implicit none does not inherit into the interface body.
The "usual" implicit mappings apply and the code is valid. It might not
do what is intended because the implicit integer type seems odd here.
And I would not recommend the coding style. But the standard allows it.
I personally think the exception for interface bodies was a mistake,
but it was one intentionally done. Indeed, I recall the debate on the
f90 interp that did this. It was at my very first J3 meeting, before I
was a member, in 1991.
--
Richard Maine | Good judgment comes from experience;
Richard.Maine@nasa.gov | experience comes from bad judgment.
| -- Mark Twain
More information about the Fortran
mailing list