1! { dg-do run }
2!
3! CO_SUM/CO_MIN/CO_MAX
4!
5program test
6  implicit none
7  intrinsic co_max
8  intrinsic co_min
9  intrinsic co_sum
10  call test_min
11  call test_max
12  call test_sum
13contains
14  subroutine test_max
15    integer :: val
16    val = this_image ()
17    call co_max (val, result_image=1)
18    if (this_image() == 1) then
19      !write(*,*) "Maximal value", val
20      if (val /= num_images()) STOP 1
21    end if
22  end subroutine test_max
23
24  subroutine test_min
25    integer :: val
26    val = this_image ()
27    call co_min (val, result_image=1)
28    if (this_image() == 1) then
29      !write(*,*) "Minimal value", val
30      if (val /= 1) STOP 2
31    end if
32  end subroutine test_min
33
34  subroutine test_sum
35    integer :: val, n
36    val = this_image ()
37    call co_sum (val, result_image=1)
38    if (this_image() == 1) then
39      !write(*,*) "The sum is ", val
40      n = num_images()
41      if (val /= (n**2 + n)/2) STOP 3
42    end if
43  end subroutine test_sum
44end program test
45