2012-03-27 23:13:14 +00:00
|
|
|
program foo
|
|
|
|
integer :: i, j, k
|
|
|
|
integer :: a(10), c(10)
|
|
|
|
k = 2
|
|
|
|
a(:) = 0
|
|
|
|
call test1
|
|
|
|
call test2
|
|
|
|
do i = 1, 10
|
2018-12-28 15:30:48 +00:00
|
|
|
if (a(i) .ne. 10 * i) STOP 1
|
2012-03-27 23:13:14 +00:00
|
|
|
end do
|
|
|
|
!$omp parallel do reduction (+:c)
|
|
|
|
do i = 1, 10
|
|
|
|
c = c + a
|
|
|
|
end do
|
|
|
|
do i = 1, 10
|
2018-12-28 15:30:48 +00:00
|
|
|
if (c(i) .ne. 10 * a(i)) STOP 2
|
2012-03-27 23:13:14 +00:00
|
|
|
end do
|
|
|
|
!$omp parallel do lastprivate (j)
|
|
|
|
do j = 1, 10, k
|
|
|
|
end do
|
2018-12-28 15:30:48 +00:00
|
|
|
if (j .ne. 11) STOP 3
|
2012-03-27 23:13:14 +00:00
|
|
|
contains
|
|
|
|
subroutine test1
|
|
|
|
integer :: i
|
|
|
|
integer :: b(10)
|
|
|
|
do i = 1, 10
|
|
|
|
b(i) = i
|
|
|
|
end do
|
|
|
|
c(:) = 0
|
|
|
|
!$omp parallel do reduction (+:a)
|
|
|
|
do i = 1, 10
|
|
|
|
a = a + b
|
|
|
|
end do
|
|
|
|
end subroutine test1
|
|
|
|
subroutine test2
|
|
|
|
!$omp parallel do lastprivate (j)
|
|
|
|
do j = 1, 10, k
|
|
|
|
end do
|
2018-12-28 15:30:48 +00:00
|
|
|
if (j .ne. 11) STOP 4
|
2012-03-27 23:13:14 +00:00
|
|
|
end subroutine test2
|
|
|
|
end program foo
|