Usage of CudaMemcpy2DArrayToArray()

I am interested in copying a 3D host array to a 3D device array in Cuda fortran. The problem is that their dimensions don’t match so I have to use CudaMemcpy2DArrayToArray(). The command I am using so far and is working fine is the following:


I would like to use the CudaMemcpy2DArrayToArray() command as a more efficient way, inside a do loop to account for the third dimension. What I am trying is the following :


but I am getting the following error during compilation

NVFORTRAN-S-0446-Argument number 1 to cudamemcpy2darraytoarray: rank mismatch (main.f90: 141)
NVFORTRAN-S-0446-Argument number 4 to cudamemcpy2darraytoarray: rank mismatch (main.f90: 141)

Could you please assist me on how to use the above command or suggest a more efficient way to copy 3D arrays with different dimensions?

Thank you in advance

cudaArrays are used for low-level programming for things like textures and surfaces. You don’t want to use that API. If they are normal Fortran arrays, you either want to use the regular cudaMemcpy functions, or just use array assignment, like this:
temp1_d(1:proc%ijks(1), 1:proc%ijks(2), 1) = val(1:proc%nxyz(1), 1:proc%nxyz(2), 1)

Thank you bleblack.