OpenMP compile error

I’m trying to compile the following OpenMP Fortran program using the -mp compiler option.

program omp
use omp_lib
implicit none
integer:: k,sz=1000
integer::c1,c2
integer,dimension(:),allocatable,save :: tr
integer:: on
!$omp threadprivate(tr,on)

call system_clock( count=c1 )

!$omp parallel num_threads(4) private(k) shared(sz) default(none)
call allo() !allocate mutiple instances of tr
on=0
!$omp DO
do k=1,sz
call finder(k)
end do
!$omp end do
!$omp end parallel
call system_clock( count=c2 )
!write(*,"(8ES14.7E2)"),z
print *,"----------------------"

print *,“time:”, (c2-c1)/10

contains
subroutine finder(k)
integer, intent(in)::k
tr(on)=k
on=on+1
!xt=xt+tr
!print *, tr
end subroutine finder

subroutine allo()
allocate(tr(1000))
tr=0
end subroutine allo

end program omp

However, I get the following error:

!:GPU-Test: pgf90 -mp testprivate.f90
/tmp/pgf90AMHboze-RgCn.o: In function finder': /home/hainesc/workspace/omp/src/./testprivate.f90:38: undefined reference to TPptr_p_’
/tmp/pgf90AMHboze-RgCn.o: In function allo': /home/hainesc/workspace/omp/src/./testprivate.f90:45: undefined reference to TPptr_p_’
/home/hainesc/workspace/omp/src/./testprivate.f90:45: undefined reference to TPptr_p_' /home/hainesc/workspace/omp/src/./testprivate.f90:46: undefined reference to TPptr_p_’

If I make a separate module out of the subroutines, this logic works. Is this a possible compiler error?

Thanks.

Hi Tsalem,

This looks like a compiler problem with accessing a thread private array from a contained subroutine. I’ve opened a technical problem report (TPR#17220) and sent it to our engineers for further investigation.

The work around would be either move ‘tr’ from a threadprivate to the parallel region’s private clause or not use ‘tr’ from a contained subroutine.

Thanks,
Mat

Thanks, Mat. I thought it might be a compiler issue. I already have a workaround - I just incorporated the subroutines into a separate module. That compiled OK, and works as it should.

Tsalem,

TPR 17220 is fixed in the 11.0 PGI release, available now.

Thanks for your report.

regards,
dave