Hi Van, thank you for your answer.
>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.
Exactly...it happens just what you say.
>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.
I'm using Compaq Visual Fortran 6, and it supports fortran 90/95 (at least
I suppose)...
If I remove the external statement I receive this error in the building:
Linking...
funct.obj : error LNK2001: unresolved external symbol _QDAG@16
Debug/cele.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
cele.exe - 2 error(s), 0 warning(s)
I don't understand...
thank you.
celevic
Here is the program:
MODULE shared
implicit none
real :: x_copy
!external h
contains
FUNCTION f(x)
real, intent(in):: x
real :: f
real :: lower=1.,upper=10.
real :: res
!external h
x_copy=x
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
|