C/Fortran FFI memory error

Assumed shape arrays in Fortran (e.g. real :: x(:)) are not interoperable with flat C arrays. The arrays would need to be assumed size to be interoperable (real :: x(*)). And the function should also probably be marked as bind(C) so that it has portable linkage.

Fortran 2018 adds ISO_Fortran_binding.h (for example, GCC's implementation) which makes assumed shape arrays interopable with C, but it requires filling out a descriptor struct. You'd need to find a way to import ISO_Fortran_binding.h for your target Fortran compiler into Rust using bindgen.

2 Likes