1

I admit the title might be a bit obscure, so let me give an example of what I want to do and what doesn't work. I have a main program which calls a subroutine which is in a module:

Program Test_program

Use module_A
Implicit none
Integer :: i
i = 1
call subroutine_A(i)

End program Test_program

this subroutine_A is in module A, and in turns calls a function_B which is in module_B:

module module_A

use module_B
implicit none
contains

subroutine subroutine_A(i)
implicit none
integer, intent(in) :: i
double precision :: j
j = function_B(i)
end subroutine subroutine_A

end module module_A

and finally, module_B looks like this:

module module_B
Implicit none
Contains

double precision function function_B(i)
implicit none
integer,intent(in) :: i
function_B = 5.d0*i
end function function_B

end module module_B

the program and modules are in different files. Unfortunately, this does not compile, as I get an error message:

ERROR Subroutine_A: This reference to subroutine function_B is not in a CALL statement.

It seems the program believes that function_B is a subroutine, so I am not sure what to do. By the way, I am trying to use proper encapsulation of my subroutines and functions using modules as I was told to, but if this is not the proper way I am open to suggestions (I was told not to use interfaces but modules instead hence this test).

Thanks

Tibo
  • 195
  • 3
  • 8

1 Answers1

0

My apologies, I actually "solved" the mystery: instead of using the name function_B, I was using the name Compute_Error. When I changed that function name to something else, the method above worked. It seems some library I link to somewhere has a subroutine compute_error, though the the error message did not tell me which one, or if that was the issue for sure. Anyway, sorry again but I guess I can let the post since it helps to see how to link modules and procedures (I did not find many examples of that particular example on the internet). Of course of this way of using modules and procedures is not the proper way, feel free to add some useful knowledge.

Tibo
  • 195
  • 3
  • 8