The Fortran-specific part of Section 18.104.22.168 (Data-sharing Attribute Rules for Variables Referenced in a Region but not in a Construct
) of the OpenMP 3.1 spec doesn't explicitly address variables declared in a main program and accessed by host association in an internal subprogram.
1. Are such variables shared unless appearing in a threadprivate directive?
2. Assuming the answer to #1 is "yes", consider the following program:
Code: Select all
integer :: x = 0
!$omp parallel firstprivate(x)
x = x + 1
!$omp end master
!$omp end parallel
write (*,*) 'Outside of parallel region:', x
x = x + 2
write (*,*) 'In parallel region:', x
end subroutine printvar
end program host_association
The "x" within the parallel construct is private copy initialized to 0; however, I would expect the "x" in internal subroutine "printvar" to be shared, referencing the "x" declared in the main program and accessible to printvar via host association. In this case, the expected output (which I did not get with all the implementations I tested) would be:
- In parallel region: 2
Outside of parallel region: 2
Is this assessment correct?