I have a Julia function that calls a FORTRAN subroutine that I have written. Everything was working fine until recently I tried to change the return type of the Julia function - an array of the FORTRAN returns instead of a tuple. i.e.
return x, y, z
→ return hcat(x, y, z)
.
Having changed this, and nothing else, the code now crashes within the FORTRAN routine from an error that would mean the input to the subroutine has somehow changed to bad values. Can someone help me make sense of this?
Edit: The function in question:
function ComputeDerivatives_Pressure( D::Array{Float64, 1}, E::Array{Float64, 1}, Ne::Array{Float64,1};
Units_Option::Bool=true )
# Initialize arrays to hold derivatives
nx :: Int64 = length( D )
dPdD :: Array{Float64, 1} = zeros( nx );
dPdT :: Array{Float64, 1} = zeros( nx );
dPdY :: Array{Float64, 1} = zeros( nx );
dPdE :: Array{Float64, 1} = zeros( nx );
dPdDe :: Array{Float64, 1} = zeros( nx );
dPdTau :: Array{Float64, 1} = zeros( nx );
# =============================================================
# This calls the FORTRAN function :computederivatives_pressure_
# FORTRAN compilation mangles the name. Cvoid is the return
# type, the next parameters are input types, followed
# by the arguements.
# =============================================================
ccall( (:computederivatives_pressure_, "./EoS_jl.so"), Cvoid,
( Ref{Float64}, Ref{Float64}, Ref{Float64}, Ref{Int64}, Ref{Float64}, Ref{Float64}, Ref{Float64}, Ref{Float64}, Ref{Float64},
Ref{Float64}, Ref{Bool} ),
D, E, Ne, nx, dPdD, dPdT, dPdY, dPdE, dPdDe, dPdTau, Units_Option )
# return dPdD, dPdT, dPdY, dPdE, dPdDe, dPdTau
return hcat( copy(dPdD), copy(dPdT), copy(dPdY), copy(dPdE), copy(dPdDe), copy(dPdTau) )
end