The following subroutine has an orphaned OpenMP "do" directive (i.e. no
enclosing "parallel" region in the program unit) containing a reduction clause.
 gfortran reports an error involving the scope of the reduction variable and
fails to compile the code.  I believe this code is valid.  For reference, using
xlf -qsmp=omp it compiles and runs without any warnings.

[EMAIL PROTECTED] $ cat test.f 
      subroutine test(u)
      implicit none
      real u(100), peak
      integer i
      peak = 0.0
!$omp do private(i) reduction(max:peak)
      do i = 1, 100
        peak = max(peak, abs(u(i)))
      end do
      end subroutine

[EMAIL PROTECTED] $ gfortran -fopenmp -c test.f 
test.f: In function 'test':
test.f:6: error: reduction variable 'peak' is private in outer context

[EMAIL PROTECTED] $ gfortran -v
Using built-in specs.
Target: powerpc-apple-darwin8.9.0
Configured with: ../gcc-4.3-20070511/configure --enable-languages=fortran
--enable-static --disable-shared
Thread model: posix
gcc version 4.3.0 20070511 (experimental)


-- 
           Summary: Rejects valid OpenMP code due to orphaned construct with
                    reduction clause
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: spam dot brian dot taylor at gmail dot com
  GCC host triplet: powerpc-apple-darwin8.8.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32502

Reply via email to