Use iso_c_binding
.
!DEC$ ATTRIBUTES DLLEXPORT::testpointer
subroutine testpointer(arrayout) bind(c)
use iso_c_binding
implicit none
real(c_float), dimension(1:50), target :: arrayin
real(c_float), dimension(:), pointer :: arrayout
integer :: i
DO i=1,50
arrayin(i)=i
end do
arrayout => arrayin
end subroutine
With bind(c)
you also don't need to mangle the procedure name either:
static extern void testpointer([Out] float[] array);//Out keyword makes no difference
You will also have to be careful with passing the array. I'd use a c_ptr
:
!DEC$ ATTRIBUTES DLLEXPORT::testpointer
subroutine testpointer(arrayout_) bind(c)
use iso_c_binding
implicit none
type(c_ptr),value::arrayout_
real(c_float), dimension(:), pointer :: arrayout
call c_f_pointer(arrayout_, arrayout, [50])