Print

Print


> I have a function with the following prototype.

 Prototype is called interface in Fortran :-)

>     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.
>
     subroutine integrate(f,a,b)
         implicit none
         real :: left,right
 !       declaration on f     <==== (1)
    interface
     function f(x,y)
         implicit none
         real,dimension(:) :: x
         real              :: y
         real,dimension(size(x)):: f
     end function
    end interface

     end subroutine

program xxx
! . . .
    interface
     function f(x,y)
         implicit none
         real,dimension(:) :: x
         real              :: y
         real,dimension(size(x)):: f
     end function
    end interface
! . . .
     call integrate(g,a,b)  !  <==== (2)

end program xxx

> 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) ?
>
 This the best way to, I guess.
 You need an interface if the called procedures are not in a
module, which is an alternative.

This may help you forward.

/---
Jan van Oosterwijk