Chris This array does not use Fortran 90 features; you're fine. Note that the array indices will be different in Julia -- -n:n will be 1:(2*n+1) instead.
What is "n" in your setup? You should declare the array size as 3*(2*n+1) in Julia, or as 2d-array via 3, 2*n+1. -erik On Mon, Jan 18, 2016 at 12:05 PM, Chris <[email protected]> wrote: > Erik, > > The array declaration line in the Fortran code is something like > > integer,parameter:: fp_kind = kind(0.d0) > real(fp_kind) :: v1(3,-n:n) > > Does this appear to use any Fortran 90-specific features? > > I also tried declaring the type as Float64, then doing > pointer_to_array(v1,3) gives me a 3x1 array of zeros. This is not the > expected result of the code, but again, it might be an issue within the > Fortran code itself. > > > Adrian, > > Thank you for the link, there's a lot of useful information in there, > although, unfortunately, nothing that I saw relating to my specific problem. > In any case, do you know if the example is waiting in a PR somewhere to get > into the docs? I agree that it would be very useful. > > Thanks, > Chris > > On Saturday, January 16, 2016 at 10:59:44 AM UTC-5, Adrian Cuthbertson > wrote: >> >> I happened to make a note of a post some time ago about getting fortran >> and julia working together. Searching for that again returned this link: >> >> >> http://julia-programming-language.2336112.n4.nabble.com/example-for-ccall-use-and-fortran-td7737.html >> >> Hth, Adrian. >> >> >> On Sat, Jan 16, 2016 at 3:32 PM, 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/
