Hello,
I am trying to use both OpenMP and OpenACC for my Fortran code. I find that if I use “declare create” for the global variables in my modules, I will have a problem when compiling the code.
This is an example code
module test
use omp_lib
use openacc
implicit none
real, allocatable, dimension(:,:,:) :: a, b, c
!$acc declare create(a)
contains
subroutine run
integer :: i
real :: s
allocate(a(100000,10000,2))
!$omp parallel num_threads(1)
!$acc parallel loop
do i=1,100000
s=a(1,1,1)
enddo
!$omp end parallel
end subroutine
end module
When compiling the code, I got the following error.
$pgfortran -c -r8 -Mpreprocess -mp -acc -ta=tesla test.f90
PGF90-S-0155-Compiler failed to translate accelerator region (see -Minfo messages): Unknown variable reference (test.f90: 28)
PGF90-F-0704-Compilation aborted due to previous errors. (test.f90)
PGF90/power Linux 19.9-0: compilation aborted
This error can be eliminated by either removing omp directives, or by commenting “!$acc declare create”.
But I do need acc declare since this array will be used by other acc routines. I don’t understand why OpenMP matters here.