Python/Fortran interoperability
sturlamolden
sturlamolden at yahoo.no
Sun Aug 23 20:06:43 EDT 2009
On 24 Aug, 01:59, sturlamolden <sturlamol... at yahoo.no> wrote:
> subroutine foobar(cstr) bind(c, name='foobar')
> use, intrinsic :: iso_c_binding
> type(c_ptr) :: cstr
> character(*), pointer :: fstr
> call c_f_pointer(cptr, fptr)
>
Which means that you can write a wrapper in Fortran callable from C,
that calls a Fortran routine you want to expose:
subroutine wrap_foobar(cstr) bind(c, name='foobar')
use, intrinsic :: iso_c_binding
type(c_ptr) :: cstr
character(*), pointer :: fstr
call c_f_pointer(cptr, fptr)
call foobar(fstr)
end subroutine
subroutine foobar(fstr)
character(*) :: fstr
! whatever
end subroutine
This by the way is how wrap exposes Fortran functions to Cython.
More information about the Python-list
mailing list