! { dg-do compile }
      SUBROUTINE A12( X, XOLD, N, TOL )
      REAL X(*), XOLD(*), TOL
      INTEGER N
      INTEGER C, I, TOOBIG
      REAL ERROR, Y, AVERAGE
      EXTERNAL AVERAGE
      C=0
      TOOBIG = 1
!$OMP PARALLEL
        DO WHILE( TOOBIG > 0 )
!$OMP DO PRIVATE(I)
            DO I = 2, N-1
               XOLD(I) = X(I)
            ENDDO
!$OMP SINGLE
            TOOBIG = 0
!$OMP END SINGLE
!$OMP DO PRIVATE(I,Y,ERROR), REDUCTION(+:TOOBIG)
            DO I = 2, N-1
               Y = X(I)
               X(I) = AVERAGE( XOLD(I-1), X(I), XOLD(I+1) )
               ERROR = Y-X(I)
               IF( ERROR > TOL .OR. ERROR < -TOL ) TOOBIG = TOOBIG+1
            ENDDO
!$OMP MASTER
            C=C+1
            PRINT *, "Iteration ", C, " TOOBIG=", TOOBIG
!$OMP END MASTER
        ENDDO
!$OMP END PARALLEL
      END SUBROUTINE A12
