Chris
Fortran has two kinds of array layouts. If your array is Fortran 77
compatible, then the layout corresponds essentially to a C array.
However, if you are using Fortan 90 features (allocatable arrays
etc.), then it will have a compiler-specific descriptor; to access it,
you will need to write some Fortran glue code to access the array
itself.
Your problem might also be that you are using one "Ptr" too many. The
type "Ptr{Ptr{Float64}}" looks suspicious; it should instead be
"Ptr{Float64}". You could try declaring your variable type as
"Float64" instead of "Ptr{Float}". That is, you're telling Julia only
about the first array element, and later use your knowledge that the
array is contiguous in memory to access the other array elements via
the pointer you get.
-erik
On Sat, Jan 16, 2016 at 10:32 AM, Chris <[email protected]> wrote:
> The Fortran code I'm working with assigns results to a number of global
> variables. One of those results is a 3x1 real array - let's call it v1.
>
> I'm trying to understand how to access this. Here's what I have:
>
> v1 = cglobal((:__libkl_mod_MOD_v1,"libkl.so"),Ptr{Float64})
>
> This gives me a Ptr{Ptr{Float64}}. I'm not sure what to do from here --
> using pointer_to_array just gives
>
> julia> pointer_to_array(v1,3)
> 3-element Array{Ptr{Float64},1}:
> Ptr{Float64} @0x0000000000000000
> Ptr{Float64} @0x0000000000000000
> Ptr{Float64} @0x0000000000000000
>
> And then doing an unsafe_load on any of those elements gives me a segfault.
>
> Am I taking the right approach here? The Fortran code is not my own, so it's
> possible this is due to an error in that code, but I'm trying to rule out
> Julia interface issues first.
>
> Thanks in advance,
> Chris
--
Erik Schnetter <[email protected]>
http://www.perimeterinstitute.ca/personal/eschnetter/