This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: External function passed to Interface function
- From: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- To: Jon Hurst <jhurst at ucar dot edu>
- Cc: fortran at gcc dot gnu dot org
- Date: Tue, 24 Feb 2009 11:22:23 -0800
- Subject: Re: External function passed to Interface function
- References: <49A4443E.4060101@ucar.edu>
On Tue, Feb 24, 2009 at 12:02:22PM -0700, Jon Hurst wrote:
> Hello,
>
> The attached piece of code is giving me the following errors with
> gfortran 4.3.3 and some earlier versions (4.1.2).
>
>
> gfortran -o test2 test2.f90
> test2.f90:46.28:
>
> res = recSum( a, res, UserFunction, UserOp )
> 1
> Error: Type/rank mismatch in argument 'userfunction' at (1)
> test2.f90:25.20:
>
> rs = recSum( a, b, test1, sumInts )
> 1
> Error: Type/rank mismatch in argument 'userfunction' at (1)
>
>
>
> The code compiles and runs on pgf90 7.0-7 and gfortran 4.0.3.
If it compiled with 4.0.3, you got lucky and maybe the results
you wanted.
>
> INTEGER FUNCTION test1(a,b,opfunc)
> INTEGER :: a,b
> INTEGER, EXTERNAL :: opfunc
Replace this with an explicit interface.
> END FUNCTION test1
>
> RECURSIVE INTEGER FUNCTION recSum( a,b,UserFunction,UserOp ) RESULT( res )
>
> IMPLICIT NONE
>
> INTEGER :: a,b
> INTERFACE
> INTEGER FUNCTION UserFunction(a,b,opfunc)
> INTEGER :: a,b
> INTEGER, EXTERNAL :: opfunc
Ditto.
> END FUNCTION UserFunction
> END INTERFACE
> INTEGER, EXTERNAL :: UserOp
>
You're getting ensnared by the implicit interfaces and scoping rules.
--
Steve