Dear all,
Thank you very much for you help! I've been able to write a form of gcvspl
that seems to run, with calling:
ccall( (:gcvspl_, "./libgcvspl.so"), Void,
(Ptr{Float64},Ptr{Float64},Ptr{Cint},Ptr{Float64},Ptr{Float64},Ptr{Cint},Ptr{Cint},Ptr{Cint},Ptr{Cint},Ptr{Float64},Ptr{Float64},Ptr{Cint},Ptr{Float64},Ptr{Cint}),x,y,&NN,wx,wy,&M,&N,&K,&MD,VAL,c,&NC,WK,IER)
However, when I try to call the c or IER variables, the Julia kernel
dies... :s
Do you have any idea why? What am I missing?
Furthermore, dear Erik, what do you mean by using 'Ref' for one-element
arrays?
Thanks in advance!
Best,
Charles.
Le lundi 6 juin 2016 22:12:32 UTC+10, Erik Schnetter a écrit :
>
> I would use `Cint` as type, not `Int64`, as in `Ptr{Cint}`. Are you sure
> that your Fortran code uses 64-bit integers? Technically, this violates the
> Fortran standard. A Fortran integer is the same as a C int, except if you
> use special flags while building the Fortran library (which you might be
> doing).
>
> You can use `Ref` instead of one-element arrays.
>
> Your error message has nothing to do with arrays vs. pointer, but rather
> the mismatch between `Float64` and `Int64`.
>
> -erik
>
>
> On Mon, Jun 6, 2016 at 6:07 AM, Páll Haraldsson <[email protected]
> <javascript:>> wrote:
>
>> On Monday, June 6, 2016 at 3:22:47 AM UTC, Charles Ll wrote:
>>>
>>> Dear all,
>>>
>>> I am trying to call some Fortran code in Julia, but I have a hard time
>>> doing so... I have read the docs, looked at the wrapping of ARPACK and
>>> other libraries... But I did not find any way to make it work.
>>>
>>> I am trying to wrap a spline function library (gcvspl.f,
>>> https://github.com/charlesll/Spectra.jl/tree/master/Dependencies),
>>> which I want to use in my project, Spectra.jl.
>>>
>>> I already have a wrapper in Python, but this was easier to wrap with
>>> using f2py. In Julia, I understand that I have to do it properly. The
>>> function I am trying to call is:
>>>
>>
>> I think, you may already have gotten the correct answer. At first I was
>> expecting fcall, not just ccall keyword in Julia, to call Fortran.. It's
>> not strictly needed, but in fact, there is an issue somewhere still open
>> about fcall (keyword, or was if for a function?), and it may have been for
>> your situation..
>>
>>
>> [It might not be too helpful to know, you can call Python with PyCall.jl,
>> so if you've already wrapped in Python..]
>>
>> --
>> Palli.
>>
>>
>>
>
>
> --
> Erik Schnetter <[email protected] <javascript:>>
> http://www.perimeterinstitute.ca/personal/eschnetter/
>