aboutsummaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.fortran/scope-1.f90
blob: 3f41e89413147f1bc047f3f0d3a465585862d32e (plain)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
program main
  implicit none (type, external)
  integer :: r, r2, i
  integer a(0:63)
  a = 0
  r = 0; r2 = 0
  !$omp parallel
    !$omp scope
      !$omp scope
        !$omp do
          do i = 0, 63
            a(i) = a(i) + 1
          end do
        !$omp end do
      !$omp end scope nowait
    !$omp end scope nowait

    !$omp scope reduction(+: r)
      !$omp do
        do i = 0, 63
          r = r + i
          if (a(i) /= 1) &
            stop 1
        end do
      !$omp end do nowait
      !$omp barrier
    !$omp end scope nowait

    !$omp barrier

    if (r /= 64 * 63 / 2) &
      stop 2

    !$omp scope private (i)
      !$omp scope reduction(+: r2)
        !$omp do
          do i = 0, 63
            r2 = r2 + 2 * i
            a(i) = a(i) + i
          end do
        !$omp end do nowait
      !$omp end scope
    !$omp end scope nowait

    if (r2 /= 64 * 63) &
      stop 3

    !$omp do
      do i = 0, 63
        if (a(i) /= i + 1) &
          stop 4
      end do
    !$omp end do nowait
  !$omp end parallel
end