The compiler is complaining about the EXTERNAL statement because it
is among the executable statements. If you move it up one line,
the compiler won't complain about the EXTERNAL statement, but the linker
will complain that H doesn't exist, because H is not an external
procedure: It's a module procedure. The instructions from your
library guide say to declare H to be external because it's a Fortran
77 library. In Fortran 95, module procedures are different from
external procedures. In Fortran 77 you had to declare procedures to be
external if you wanted to use them as actual arguments, because that was
the only way to distinguish them from variables. In Fortran 95, the
compiler knows that H is a module procedure -- unless you declare it to
be external, in which case the local declaration of H within F will
override the declaration of H that would otherwise be gotten from the
module in which F and H are both contained.
So just remove the EXTERNAL statement.
Van Snyder
======================================================================
> Hi Ron, thank you for your answer.
> I've done as you suggested and the program is O.K
> Now, I use the program calling the subroutine of the integration
> (QDAG,IMSL libray) to define f(x) as the integral of h(x,y) (respect to
> y); to do this the function h must be declared ad EXTERNAL.
> Adding the line - external h - before the calling there is the error:
> Error: A specification statement cannot appear in the executable section.
> external h.
> But I have to declare h external in some way (as it is also written in the
> imsl doc). How can I solve this? Thank you for your help!!!
> cheers,
> celevic
>
> Here is the program:
>
> MODULE shared
> implicit none
> real :: x_copy
> contains
>
> FUNCTION f(x)
> real, intent(in):: x
> real :: f
> real :: lower=1.,upper=10.
> real :: res
> x_copy=x
> external h <------------------- error
> call qdag(h,lower,upper,res)
> f=res
> END FUNCTION
>
> FUNCTION h(y)
> real, intent(in) :: y
> real :: h
> h=(x_copy*y)*(y**2)
> END FUNCTION
>
> end MODULE shared
>
> PROGRAM proof
> use shared
> real :: a,b
> do a=1.,5.,1.
> b=f(a)
> write(*,*) b
> enddo
> END PROGRAM
>
|