10th Feb. 2001
> Date: Fri, 9 Feb 2001 17:02:39 -0600
> From: Jaehoon <[log in to unmask]>
> I have a function with the following prototype.
>
> function f(x,y)
> implicit none
> real,dimension(:) :: x
> real :: y
> real,dimension(size(x)):: f
> .........
> end function
>
> And another function which can take f(,) as an argument.
You mean a "subroutine":
> subroutine integrate(f,a,b)
> implicit none
> real :: left,right
> declaration on f <==== (1)
>
> end subroutine
>
> call integrate(g,a,b) <==== (2)
>
> My question is what is the most effective way of declaring(specifying) f
> within the subroutine integrate() (1) so that the compiler can check if g
> has a matching prototype at the stage (2) ?
You need an interface for function f within subroutine "integrate" at (1), e.g.
interface
function f(a, b) result (r)
real, intent (in) :: a, b
real :: r
end function f
end interface
There are some examples in Chapter 11 on Numerical Methods
in my book: "Algorithms and Data Structures in F and Fortran" --
ISBN 0-9640135-4-1 which may be purchased online from the publisher
Unicomp at http://www.uni-comp.com
> Thanks.
|