What is the best practice for communicating a struct to Fortran that contains a large array object? (In practice, the struct s_t
that I define below will also contain other elements).
I was doing something like
using StaticArrays
struct s_t
fmat::SMatrix{n,m,Cchar,n*m}
end
where n
and m
are constants.
I then call interface with Fortran using
function test()
sref = Ref{s_t}()
ccall((:C_MyRoutine, /path/to/lib.so), Cvoid, (Ref{s_t},), sref)
return sref[]
end
This is great when n
and m
are “small”, but as StaticArrays does not work well with large dimensions, this becomes painfully slow in my application.
What is the best way to communicate a struct to Fortran in this case? I can, of course, pass each argument of s_t
to a Fortran wrapper individually (where I am now using a regular matrix rather than SMatrix), and reconstruct the derived type in Fortran by copying, but I am wondering what the “best practice” would be in these settings. Thanks.