1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
! { 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
|