This is likely going to be something stupid, but I’m at my wits end here. My code doesn’t seem to be executing properly. I’ve stripped the problem down to the most simple form (obviously I’ve changed variable names and initialized the variables to silly values since the work is proprietary).
program Mat_test implicit none integer :: i, j, endn integer :: inds(260) real*8 :: A(260, 260, 89), B(260, 89), C(260, 89, 89), D(260, 260) real*8 :: test(89), test1(89), test2(89) do i = 1, 89 A(:,:,i) = i*2.5 B(:,i) = i * 3.5 do j = 1, 89 C(:,i,i) = i*j*0.01 end do end do endn = 250 !$acc kernels !$acc loop independent private(D) do i = 1, 2 do j = 1, 260 A(:,j, i) = A(:,j,i) / B(:, i) enddo do j = 1, endn D(:,j) = - A(:,j,i) * C(j,i,i) D(j,j) = D(j,j) + 1.0 enddo test(i) = D(5,5) test1(i) = - A(5,5,i) test2(i) = C(5,i,i) enddo !$acc end kernels print *, test(1), test1(1), test2(1) print *, test(2), test1(2), test2(2) print *, A(5,5,1) end program Mat_test
In my full version, D is used later on in the loop, but is unique for each iteration through i.
The problem is that the value of “test(2)” depends on “endn”. For endn = 10, it gives the correct answer, while for endn = 250 is doesn’t. In principle it should loop to 260, but it’s causing me problems.
What am I missing here?