I have a FORTRAN 95 code where, in the main program, these variables are declared:
integer :: i
real(8) :: dx
real(8), allocatable :: X(:), Y(:), Z(:)
The following function uses these values at some point during the program:
function Funcion_ceros(var_4)
implicit none
real(8), intent(in) :: var_4(2)
real(8) :: Funcion_ceros(2)
Funcion_ceros(1) = var_4(1) - Y(i) - dx*var_4(2)
Funcion_ceros(2) = var_4(2) - Z(i) - dx*F(X(i + 1), var_4(1), var_4(2))
end function Funcion_ceros
If I include this function in the contains section of the main program, there is no compiling issue. However, when separating it into a module, it loses access to these variables. I attempt to specify the same variabes written above in the module aswell, and get the following error:
Symbol 'i' at (1) conflicts with symbol from module 'Module_Name', use associated at (2).
How do I separate this function into a module, allowing at the same time its access to the variables it uses from the main program?