Hi, I have an issue compiling the following fortran openmp code using gcc4.3 snapshot 20071910:
SUBROUTINE foo(a, b, n) DOUBLE PRECISION a, b INTEGER*8 i1, i2, i3, n DIMENSION a(n,n,n), b(n,n,n) !$OMP PARALLEL !$OMP+DEFAULT(SHARED) !$OMP+PRIVATE(I3) !$OMP DO !$OMP+LASTPRIVATE(I1,I2) DO i3 = 2, n-1, 1 DO i2 = 2, n-1, 1 DO i1 = 2, n-1, 1 a(i1, i2, i3) = b(i1, i2, i3); 600 CONTINUE ENDDO ENDDO ENDDO !$OMP END DO NOWAIT !$OMP END PARALLEL RETURN END gfortran -O2 -fopenmp foo.c -c -o foo.o fortran2.f:11: error: lastprivate variable "i2" is private in outer context fortran2.f:11: error: lastprivate variable "i1" is private in outer context I believe this code is compliant with the OPENMP 2.5 spec, since the DEFAULT(SHARED) clause should make the scope of i1, i2 shared in the enclosing parallel region. Pathscale 3.0, PGI 7.0.6 and Intel 10.0.026 compile the above code successfully. Replacing: !$OMP+DEFAULT(SHARED) with: !$OMP+SHARED(I1,I2) makes the code compile successfully with gfortran. Alternatively, keeping DEFAULT(SHARED) and fusing the OMP PARALLEL clause with the OMP DO clause (i.e. using OMP PARALLEL DO) also solves the problem. (this testcase is derived from a benchmark suite that doesn't allow source code modifications. gfortran should be able to compile this with no code changes - if this is indeed openmp-compliant code) Could this behavior be due to the following libgomp patch not getting all necessary information from the fortran front-end? http://gcc.gnu.org/ml/gcc-patches/2007-01/msg01940.html GCC4.3 snapshot 20071910 was built and bootstrapped with the following configuration on sles10-sp1: Target: x86_64-unknown-linux-gnu Configured with: /home/gcc-4.3-20071019/configure --with-gmp-lib=/usr/local/lib/ --with-gmp-include=/usr/local/include/ --with-mpfr-lib=/usr/local/lib --with-mpfr-include=/usr/local/include/ --enable-threads=posix --prefix=/opt/gcc4.3 Thread model: posix gcc version 4.3.0 20071019 (experimental) (GCC) thanks, - Vasilis