hi all!
i am new to fortran and I'm using a module that contains a subroutine, that I need to call in another main file, however I am getting some errors and the subroutine is not printing what I want her to print.
Here is my module:
module prestel
use Constants
implicit none
contains
subroutine gradient_density(rho,N,dr,gradiant_rho)
implicit none
real(kind=dp), allocatable :: rho(:)
real(kind=dp),allocatable :: gradiant_rho(:)
integer,intent(in) :: N
real(kind=dp),intent(in) :: dr
integer :: i
do i = 1,N
gradiant_rho(i) = (rho(i+1) - rho(i))/dr
end do
print *,gradiant_rho
end subroutine gradient_density
end module prestel
and this is my main file:
program pt1
use prestel
implicit NONE
integer :: Npts=100
real(kind=dp), allocatable :: gradro(:)
real(kind=dp), allocatable :: v_density(:)
real(kind=dp) :: rho_0 = 10**17
integer :: i,j
real (kind=dp) :: c = 2
allocate(gradro(N),v_density(N))
do i = 1,Npts
v_density(i) = rho_0
end do
call gradient_density(v_density,Npts,c,gradro)
deallocate(gradro,v_density)
end program tp1
When compiling my module I get this:
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
Then, I'm getting this error while compiling my main file:
Undefined symbols for architecture x86_64:
"___prestel_MOD_gradient_density", referenced from:
_MAIN__ in cc5vaf5l.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
What I have tried:
I doubled checked my subroutine but i really can't seem to find what's the problem.
Any idea how to solve this?
Thanks in advance!