Hi,
I have a code where some subroutines are defined with contains from an other subroutine. Here is an example:
module computation
implicit none
CONTAINS
!---------------------------------------------
subroutine organize(nvec,nlev,a,option)
real, intent(inout) :: a(:,:)
integer, intent(in) :: nvec,nlev,option
integer :: i,k
!$acc reflected(a)
IF (option==1) THEN
call compute_1
ELSE
call compute_2
END IF
CONTAINS
subroutine compute_1
integer :: i,k
!$acc region do kernel
do i=1,nvec
do k=2,nlev
a(i,k)=a(i,k)*a(i,k-1)
end do
end do
!$acc end region
end subroutine compute_1
subroutine compute_2
integer :: i,k
!$acc region do kernel
do i=1,nvec
do k=2,nlev
a(i,k)=2*a(i,k)*a(i,k-1)
end do
end do
!$acc end region
end subroutine compute_2
end subroutine organize
!-----------------------------
end module computation
program main
USE computation
implicit none
real, allocatable :: a(:,:)
!$acc mirror(a)
integer, parameter :: n1=10000, nlev=60
integer, parameter :: option=0
allocate(a(n1,nlev))
!init a
a=0.1
!$acc update device(a)
call organize(n1,nlev,a,option)
!$acc update host(a)
print*, sum(a)
end program main
when I compile I get the following message:
compute_1:
27, Generating allocate(a(:,:))
Generating copyin(a(1:nvec,1:nlev))
...
which indicates that the compiler does not see that “a” is already on the device (as it should be from the reflected statement in organize subroutine).
What am I doing wrong here ?
Thanks,
Xavier