This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: External function passed to Interface function


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]