aboutsummaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.fortran/scope-2.f90
blob: f2e1593403ead34d8417f1de26ae7f231e4ca6db (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
56
57
program main
  implicit none
  integer a(0:63)
  integer r, r2, i, n
  a = 0
  r = 0
  r2 = 0
  n = 64
  !$omp parallel
    !$omp scope
     !$omp scope firstprivate (n)
      !$omp do
      do i = 0, 63
       a(i) = a(i) + 1
      end do
     !$omp end scope nowait
    !$omp end scope nowait

    !$omp scope reduction(+: r) firstprivate (n)
      !$omp do
      do i = 0, 63
        r = r + i
        if (a(i) /= 1) &
          error stop
      end do
      !$omp end do nowait
      !$omp barrier
      if (n /= 64) then
        error stop
      else
        n = 128
      end if
    !$omp end scope nowait

    !$omp barrier
    if (r /= 64 * 63 / 2) &
      error stop
    !$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) &
      error stop
    !$omp do
    do i = 0, 63
      if (a(i) /= i + 1) &
        error stop
    end do
    !$omp end do nowait
  !$omp end parallel
end program