Strange data clause behaviors with OpenACC

Hi,

I am new to OpenACC and need some help with the data clauses.

I have a program that copies in some variables and modifies their values on the accelerator, but need not copy them back to the host. The code segment is something like below:

program main

!$acc data copyin(var1)
call sub1
!$acc end data

end program

subroutine sub1
!$acc kernels loop present(var1)
var1 = xxxxx
!$acc end kernels
end subroutine

Now I got some strange results and want to check the intermediate value of var1. I have no debugger that supports accelerator, so I thought of copying the intermediate values to the host and print out there. I tried to replace “!$acc kernel loop present(var1)” with the following:
!$acc kernels loop copyout(var1)
!$acc kernels loop present_or_copyout(var1)
then I printed out var1 at end of sub1, I always got the initial value of var1. It seems that the changed var1 was never copied back to the host.

Any suggestions?

Thanks

HI appleluo,

try “!$acc update host(var1)” at the end of sub1

Best,
Paul

Thanks.