program tests
implicit none
integer, dimension(32,32) :: B
integer, device :: B_d(32,32), B_d2(32,32)
B=1
B_d=B
B_d2(1:3,:)=B_d(2:4,:)
end program
With runtime error:
program tests
implicit none
integer, dimension(32,32,2) :: B
integer, device :: B_d(32,32,2), B_d2(32,32)
B=1
B_d=B
B_d2(:,:)=B_d(:,:,0)
end program
If it wasn’t a compiler issue, could you please help me understand why the second program doesn’t work? I think both are valid. I did the test with nvidia-hpc-sdk 24.3 and CUDA 12.2
Hi - so if I compile your runtime error code as written, I indeed get your error. However - something stands out to me as an issue there. In Fortran, the index starts at 1, not 0 - however, it appears that you’re treating it as 0 in your example. I’m pretty sure that’s your issue.
For example, if I make this change:
!B_d2(:,:)=B_d(:,:,0)
B_d2(:,:)=B_d(:,:,1)
Then the code appears to run correctly. Alternatively, if you need the 3d index to start at 0 for whatever reason, then in the declaration of B_d, I can instead declare it this way:
B_d(32,32,0:1) ![i.e. start at 0, and have 2 elements in the 3rd dimension]
Then the code also appears to run correctly.
Please let me know if this helps resolve your issue!