1! PR fortran/46874
2! { dg-do run }
3
4  interface
5    subroutine sub (a, b, c, d, n)
6      integer :: n
7      integer, allocatable :: a(:), b(:), c(:), d(:)
8    end subroutine
9  end interface
10
11  integer, allocatable :: a(:), b(:), c(:), d(:)
12  integer :: i, j
13  allocate (a(50), b(50), c(50), d(50))
14  do i = 1, 50
15    a(i) = 2 + modulo (i, 7)
16    b(i) = 179 - modulo (i, 11)
17  end do
18  c = 0
19  d = 2147483647
20  call sub (a, b, c, d, 50)
21  do i = 1, 50
22    j = 0
23    if (i .eq. 3) then
24      j = 8
25    else if (i .gt. 1 .and. i .lt. 9) then
26      j = 7
27    end if
28    if (c(i) .ne. j) call abort
29    j = 179 - modulo (i, 11)
30    if (i .gt. 1 .and. i .lt. 9) j = i
31    if (d(i) .ne. j) call abort
32  end do
33  deallocate (a, b, c, d)
34end
35
36subroutine sub (a, b, c, d, n)
37  integer :: n
38  integer, allocatable :: a(:), b(:), c(:), d(:)
39!$omp parallel do shared(a, b) reduction(+:c) reduction(min:d)
40  do i = 1, n
41    c(a(i)) = c(a(i)) + 1
42    d(i) = min(d(i), b(i))
43    d(a(i)) = min(d(a(i)), a(i))
44  end do
45end
46