1program teams1
2  use omp_lib
3!$omp teams thread_limit (2)
4  if (omp_in_parallel ()) stop 1
5  if (omp_get_level () .ne. 0) stop 2
6  if (omp_get_ancestor_thread_num (0) .ne. 0) stop 3
7  if (omp_get_ancestor_thread_num (1) .ne. -1) stop 4
8  call omp_set_dynamic (.false.)
9  call omp_set_nested (.true.)
10!$omp parallel num_threads (2)
11  if (.not. omp_in_parallel ()) stop 5
12  if (omp_get_level () .ne. 1) stop 6
13  if (omp_get_ancestor_thread_num (0) .ne. 0) stop 7
14  if (omp_get_ancestor_thread_num (1) &
15&     .ne. omp_get_thread_num ()) stop 8
16  if (omp_get_ancestor_thread_num (2) .ne. -1) stop 9
17!$omp end parallel
18!$omp end teams
19end program
20