1! { dg-do run }
2
3module mod1
4  contains
5
6    subroutine foo (x, y)
7      integer :: x, y
8
9      !$omp taskgroup task_reduction (+: x, y)
10
11      !$omp target in_reduction (+: x, y)
12      x = x + 8
13      y = y + 16
14      !$omp end target
15
16      !$omp task in_reduction (+: x, y)
17      x = x + 2
18      y = y + 4
19      !$omp end task
20
21      !$omp end taskgroup
22    end subroutine foo
23
24    integer function bar (x)
25      integer, value :: x
26
27      !$omp taskgroup task_reduction (+: x)
28
29      !$omp target in_reduction (+: x)
30      x = x + 16
31      !$omp end target
32
33      !$omp task in_reduction (+: x)
34      x = x + 32
35      !$omp end task
36
37      !$omp end taskgroup
38
39      bar = x
40    end function bar
41  end module mod1
42
43program main
44  use mod1
45  integer :: x, y
46  real :: f;
47
48  x = 1
49  y = 1
50
51  call foo (x, y)
52
53  if (x .ne. 11) stop 1
54  if (y .ne. 21) stop 2
55
56  y = bar (8)
57  if (y .ne. 56) stop 3
58
59  x = 0
60  f = 0.0
61
62  !$omp taskgroup task_reduction (+: x, f)
63  !$omp target in_reduction (+: x, f)
64  x = x + 1
65  f = f + 2.0
66  !$omp end target
67
68  !$omp task in_reduction (+: x, f)
69  x = x + 2
70  f = f + 3.0
71  !$omp end task
72
73  !$omp end taskgroup
74
75  if (x .ne. 3) stop 4
76  if (f .ne. 5.0) stop 5
77
78end program main
79