You cannot portably call Fortran procedure requiring character(*)
from C. It is not possible, because the procedure takes typically another argument defining the string length. You may try to guess it's format, probably it is additional int
as a last argument.
I would make another Fortran wrapper, that would take an int
with length and an array of chars of length length
preferably without the trailing \0
.
logical function f_wrap(handle, name, length) bind(C,name="f_wrap")
use iso_c_binding
integer(c_int),value :: handle
integer(c_int),value :: length
character(1,kind=c_char),intent(in) :: name(length)
character(length) :: tmp
tmp = name
f_wrap = f_fn(int(handle), tmp)
end function
The tmp
may be unnecessary, because the binary representation is the same, just try it.