Hi all,
the julia documentation provides quite some example on how to call C functions. However, I want to accress some fortran modules and currently I’m a bit lost. Say I have a fortran module like:
module foo
use :: iso_fortran_env
implicit none
contains
subroutine foo1(n,x,y)
integer(int64), intent(in) :: n
integer(int64), intent(in), dimension(n) :: x
integer(int64), intent(out), dimension(n) :: y
y = 2*x
end subroutine foo1
subroutine foo2(x,y)
integer(int64), intent(in), dimension(:) :: x
integer(int64), intent(out), dimension(size(x)) :: y
y = 2*x
end subroutine foo2
function bar1(n,x) result(y)
integer(int64), intent(in) :: n
integer(int64), intent(in), dimension(n) :: x
integer(int64), dimension(n) :: y
y = 2*x
end function bar1
end module foo
which I compile (on Ubuntu) with
gfortran -Wall -Wextra -fPIC -c mod_foo.F08
gfortran -shared -Wl,-soname,libfoo.so -o libfoo.so mod_foo.o
then, within julia the following works:
julia> t = ones(Int64,2); ccall((:__foo_MOD_foo1, "./libfoo.so"), Void, (Ref{Int64}, Ref{Int64}, Ptr{Int64}), 2, [3, -1], t); t
2-element Array{Int64,1}:
6
-2
but any attempt to call foo2 or bar1 has ended in segmentation faults. Can anybody tell me how to access these?
Regards,
Laurent