1! { dg-do run }
2
3  integer :: i
4  common /c/ i
5  i = -1
6!$omp parallel shared (i) num_threads (4)
7  call test1
8!$omp end parallel
9end
10subroutine test1
11  integer :: vari
12  call test2
13  call test3
14contains
15  subroutine test2
16    use omp_lib
17    integer :: i
18    common /c/ i
19!$omp single
20    i = omp_get_thread_num ()
21    call test4
22!$omp end single copyprivate (vari)
23  end subroutine test2
24  subroutine test3
25    integer :: i
26    common /c/ i
27    if (i .lt. 0 .or. i .ge. 4) STOP 1
28    if (i + 10 .ne. vari) STOP 2
29  end subroutine test3
30  subroutine test4
31    use omp_lib
32    vari = omp_get_thread_num () + 10
33  end subroutine test4
34end subroutine test1
35