- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear all,
I encountered a problem between interface and module in the following test program :
module functions
implicit none
contains
function square(x)
real*8 :: x,square
square=x*x
end function square
end module functions
module mod
use functions
implicit none
contains
function launch(x)
interface
function square(x)
real*8 :: x,square
end function square
end interface
real*8 :: x,launch
launch=square(x)
end function launch
end module mod
program test
use functions
use mod
real*8 :: x=2.,y
y=launch(x)
print*, y
end program test
When I compile it, it says that the module mod can not find the function square. But when I get rid off the module functions and put square directly on an independent file, it just works fine...
Can someone tells me what is going on ?
Thanks in advance.
I encountered a problem between interface and module in the following test program :
module functions
implicit none
contains
function square(x)
real*8 :: x,square
square=x*x
end function square
end module functions
module mod
use functions
implicit none
contains
function launch(x)
interface
function square(x)
real*8 :: x,square
end function square
end interface
real*8 :: x,launch
launch=square(x)
end function launch
end module mod
program test
use functions
use mod
real*8 :: x=2.,y
y=launch(x)
print*, y
end program test
When I compile it, it says that the module mod can not find the function square. But when I get rid off the module functions and put square directly on an independent file, it just works fine...
Can someone tells me what is going on ?
Thanks in advance.
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you are referencing a procedure contained in another module, you must not also define a separate interface for it. The interface comes from the USE of the module. The interface you added in module mod tells the compiler that square is an external procedure, different from the module procedure in module functions.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page