Calling SUBROUTINE DLL in Julia

Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Calling SUBROUTINE DLL in Julia

jijinlee
This post has NOT been accepted by the mailing list yet.
This post was updated on .
Hello, I'm trying to call subroutine dll in Julia. Below is my situation.
------------------------------------
1. Fortran dll code
! File name : DLL2.f90
SUBROUTINE HELLODLL(X,Y,Z)
!DEC$ ATTRIBUTES DLLEXPORT :: HELLODLL
REAL(8), INTENT(INOUT) :: X, Y
REAL(8), INTENT(INOUT) :: Z
PRINT *, "HELLODLLJIJIN"
Z = X + Y
PRINT *, Z
END SUBROUTINE

2. Fortran Compile (on cmd)
> ifort -shared -fPIC /dll DLL2.f90

3. Calling in Julia
julia> x=10.0
10.0

julia> y=10.0
10.0

julia> z=0.0
0.0

julia> ccall((:HELLODLL,"DLL2.dll"), Void, (Ptr{Float64},Ptr{Float64},Ptr{Float64}), &x,&y,&z)
 HELLODLLJIJIN
   20.0000000000000

julia> z
0.0
----------------------------------
The printed result was right. But the returned "z" wasn't changed(SHOULD BE z=20.0). How can I get the result "z" in those example? Many fortran libraries provide results as subroutine inputs.