I checked with a debugger that a value of a variable(the name of the function) is computed, but then a different value is returned. I'd think this is related to type translation, but I don't see how. I have the following function.
double precision function func_energy(temp)
use func_params
implicit none
double precision energy_f_temp, temp
func_energy = energy_f_temp(temp, density) - p_invert
return
end function func_energy
func_params has been declared as the following
module func_params
double precision, save :: p_invert
double precision, save :: density
end module func_params
I checked that the initialization of func_params is correct. When I am inside func_energy I found that
energy_f_temp(temp, density) - p_invert
is equal to -42476827268725768, but then when I check at the next line the value of func_energy I get 588030290385264, and this is the value that is returned by the function. I don't understand what is going on. It looks to me that everything is double precision. What could be going wrong here?
I'm using ifort with compiler option:
-g -O0 -check bounds -warn all -traceback -align all -align rec8byte
These functions are part of a fortran library that I am calling from a C main program. I have read somewhere that when the calling convention are not right you could be corrupting the stack. Does it apply here? The point is that the error appeared suddently.
thanks