I have a C function that accept a pointer, which is supposed to point to data on device memory
int c_foo_func (int * arr, int size) {
....
//call kernel to process arr
}
Now, I want to call this function from Fortran. It’s trivial to declare the interface
interface
integer(c_int) function c_foo_func(arr, size) bind(c)
integer(c_int) :: arr
integer(c_int), value :: arr
end function
end interface
However, an issue arise when I try to call and pass a device pointer to the function
integer, device, dimension(:), allocatable :: arr_d
integer :: size = 100
allocate(arr_d(size))
x = c_foo_fuc(arr_d, size)
I always get the error type mismatch for the first argument of c_foo_func.
How could the issue be resolved?
Thanks,
Tuan