Print

Print


 
-------------- Original message from "Tuan, Hoang-Trong" <[log in to unmask]>: --------------


> Any one can help me,
> I define a module to contain a list of functions. These function has one
> arguments f_x which should be a function
>
> MODULE MY_UTILITIES
> IMPLICIT NONE
>
> CONTAINS
> REAL FUNCTION FooFunc1(f_x, a, b)
> ...
> FooFunc1 = f_x(a-b)
> END FUNCTION
>
> REAL FUNCTION FooFunc2 (f_x, a, b)
> ...
> FooFunc2 = FooFunc1 (f_x, a, b) ! error at this point
>
Without seeing all of the declarations, it's hard to say for sure.  But, I
believe you will need an
           EXTERNAL  f_x
statement.  That's consistent with the error message and there is nothing
obvious in FooFunc2 that indicates that the first argument is a function.

As a matter of style, I think it would be a good idea to also put an
EXTERNAL in FooFunc1.  True, the reference to f_x(a,b) marks
it as an external (because it isn't an array), but I think it's better to
explicitly declare all of the interesting attributes.

Dick Hendrickson
> END FUNCTION
> END MODULES
>
> PROGRAM MY_PROGRAM
> USE MY_UTILITIES
> EXTERNAL G_X
> REAL :: a, b
> INTEGER :: errCode
>
> ...
> errCode = FooFunc1(G_X, a,b)
> END PROGRAM MY_PROGRAM
>
> REAL FUNCTION G_X (...)
> END FUNCTION
>
> Ignoring other details of the functions. Eventhough I don't call the
> FooFunc2 function inside main program, when I compile the program, an error
> is popped up:
> error 327 - In the INTERFACE to FooFunc1, the first dummy argument
> (F_X) was of type REAL(KIND=1) FUNCTION, whereas the actual argument is of
> type REAL(KIND=1)
>
> NOTE: I use SilverFrost Plato IDE (Fortran 95 compiler).
>
> Tuan.
> George Mason Univ.