1  common /blk/ q, e
2  integer :: q, r
3  logical :: e
4!$omp parallel
5!$omp single
6  call foo (2, 7)
7  r = bar (12, 18)
8!$omp end single
9!$omp end parallel
10  if (q .ne. 6 .or. r .ne. 17 .or. e) STOP 1
11contains
12  subroutine foo (a, b)
13    integer, intent (in) :: a, b
14    common /blk/ q, e
15    integer :: q, r, d
16    logical :: e
17!$omp taskloop lastprivate (q) nogroup
18    do d = a, b, 2
19      q = d
20      if (d < 2 .or. d > 6 .or. iand (d, 1) .ne. 0) then
21!$omp atomic write
22        e = .true.
23      end if
24    end do
25  end subroutine foo
26  function bar (a, b)
27    integer, intent (in) :: a, b
28    integer :: bar
29    common /blk/ q, e
30    integer :: q, r, d, s
31    logical :: e
32    s = 7
33!$omp taskloop lastprivate (s)
34    do d = a, b - 1
35      if (d < 12 .or. d > 17) then
36!$omp atomic write
37        e = .true.
38      end if
39      s = d
40    end do
41!$omp end taskloop
42    bar = s
43  end function bar
44end
45