I am trying to write two simple functions, one which contains the definition of a real function and the other one uses the previous function to find its derivative. However i keep getting the undefined reference error.
my module:
module module_name
contains
function f(x)
implicit none
real(8) :: x
real(8) :: f
f= 2.71**x
endfunction
function f_p_def(x)
implicit none
real(8) :: x, dx, f
real(8) :: f_p_def
dx= 0.1
f_p_def= (f(x+dx)-f(x))/dx
endfunction
endmodule
then in my main program I have this:
program test
use module_name
real(8) :: f1, x
x=0
f1= f_p_def(x)
write(*,*) f1
endprogram
and this is the error:
.\principal.o:principal.f95:(.text+0x27): undefined reference to `__module_name_MOD_f_p_def' collect2.exe: error: ld returned 1 exit status