Hi, Alexey Cherkaev <alexey.cherk...@gmail.com> writes: > To cut long story short, I have a problem of passing floating-point numbers > from > Julia to Fortran subroutine. Documentation suggests, that each parameter to > Fortran's program needs "Ref{T}" wrapper as they are passed by reference (I've > seen that older code also uses Ptr{T} with "&" at variable names). It works > fine > for integers (I even can see the difference if "FInt" alias is changed between > "Int32" and "Int64" and if "-fdefault-integer-8" in compiling option is > present > or omitted). But I don't see a single floating point value passed correctly > (including floating-point arrays). I've also tried, as an extreme measure, to > pass a floating point parameter as a vector (of size 1) and have a > corresponding > type in ccall to be "Ptr{Float64}"
Perhaps in Fortran you have 32bits floats? I just tried with this, and I have no problem passing floats to Fortran: ,---- | testdp(ar) = ccall((:__tests_MOD_testdp, "./testmodgfort"),Float64, (Ptr{Float64},), &ar) | println("Result of function call to Fortran ", testdp(5.0)) `---- ,---- | DOUBLE PRECISION FUNCTION testdp (a) | DOUBLE PRECISION :: a | testdp = 5.0*a | END FUNCTION testdp `---- ,---- | julia> include("julia-fortran.jl") | Result of function call to Fortran 25.0 `---- -- Ángel de Vicente http://www.iac.es/galeria/angelv/