module allocate_data_cuda !! Controls allocation of CUDA data interface function allocate_managed_memory_double(n) bind(c, name='allocate_managed_memory_double') use iso_c_binding type(c_ptr) :: allocate_managed_memory_double integer :: n end function allocate_managed_memory_double end interface interface function allocate_managed_memory_int(n) bind(c, name='allocate_managed_memory_int') use iso_c_binding type(c_ptr) :: allocate_managed_memory_int integer :: n end function allocate_managed_memory_int end interface !interface allocate_memory ! module procedure allocate_memory_double !end interface allocate_memory contains subroutine allocate_memory_double(a,is1,ie1) use iso_c_binding double precision, dimension(:), pointer, intent(inout) :: a !< Input array integer, intent(in) :: is1,ie1 !< Starting and ending indices integer ndata ndata=(ie1-is1+1) !#if CUDA call c_f_pointer(allocate_managed_memory_double(ndata), a, & [(ie1-is1+1)]) a(is1:) => a ! call cudamemset_double(a,(ie1-is1+1)) !allocate(a(is1:ie1,is2:ie2)) !#else ! allocate(a(is1:ie1)) ! a = 0.0d0 !#endif end subroutine allocate_memory_double subroutine allocate_memory_int(a,is1,ie1) use iso_c_binding integer, dimension(:), pointer, intent(inout) :: a !< Input array integer, intent(in) :: is1,ie1 !< Starting and ending indices integer ndata ndata=(ie1-is1+1) !#if CUDA call c_f_pointer(allocate_managed_memory_int(ndata), a, & [(ie1-is1+1)]) a(is1:) => a ! call cudamemset_int(a,(ie1-is1+1)) ! !allocate(a(is1:ie1,is2:ie2)) !#else ! allocate(a(is1:ie1)) ! a = 0.0d0 !#endif end subroutine allocate_memory_int end module