1! PR fortran/27395
2! { dg-do run }
3
4program pr27395_2
5  implicit none
6  integer, parameter :: n=10,m=1001
7  integer :: i
8  call foo(n,m)
9end program pr27395_2
10
11subroutine foo(n,m)
12  use omp_lib, only : omp_get_thread_num
13  implicit none
14  integer, intent(in) :: n,m
15  integer :: i,j
16  integer, dimension(n) :: sumarray
17  sumarray(:)=0
18!$OMP PARALLEL DEFAULT(shared) NUM_THREADS(4)
19!$OMP DO PRIVATE(j,i), REDUCTION(+:sumarray)
20  do j=1,m
21    do i=1,n
22      sumarray(i)=sumarray(i)+i
23    end do
24  end do
25!$OMP END DO
26!$OMP END PARALLEL
27  do i=1,n
28    if (sumarray(i).ne.m*i) STOP 1
29  end do
30end subroutine foo
31