1function foo ()
2  integer :: foo
3  logical :: foo_seen
4  common /foo_seen/ foo_seen
5  foo_seen = .true.
6  foo = 3
7end
8function bar ()
9  integer :: bar
10  logical :: bar_seen
11  common /bar_seen/ bar_seen
12  bar_seen = .true.
13  bar = 3
14end
15  integer :: a (10), b (10), foo, bar
16  logical :: foo_seen, bar_seen
17  common /foo_seen/ foo_seen
18  common /bar_seen/ bar_seen
19
20  foo_seen = .false.
21  bar_seen = .false.
22!$omp parallel workshare if (foo () .gt. 2) num_threads (bar () + 1)
23  a = 10
24  b = 20
25  a(1:5) = max (a(1:5), b(1:5))
26!$omp end parallel workshare
27  if (any (a(1:5) .ne. 20)) STOP 1
28  if (any (a(6:10) .ne. 10)) STOP 2
29  if (.not. foo_seen .or. .not. bar_seen) STOP 3
30end
31