1! { dg-set-target-env-var OMP_PROC_BIND "spread,close" }
2! { dg-set-target-env-var OMP_PLACES "cores" }
3! { dg-set-target-env-var OMP_NUM_THREADS "4" }
4! { dg-set-target-env-var OMP_AFFINITY_FORMAT "hello" }
5
6  use omp_lib
7  character(len=68) :: buf, buf2
8  character(len=8) :: buf3
9  character(len=1) :: buf4
10  integer :: l1, l2
11
12  buf = 'L:%0.5L%%%n>%32H<!%.33{host}!%.6P_%i_%0.18i_%0.7{ancestor_tnum} %18A'
13  call omp_set_affinity_format (format = buf)
14  if (omp_get_affinity_format (buf4) /= 68) stop 1
15  if (buf4 /= 'L') stop 2
16  if (omp_get_affinity_format (buf2) /= 68) stop 3
17  if (buf2 /= buf) stop 4
18  if (omp_get_affinity_format (buf3) /= 68) stop 5
19  if (buf3 /= 'L:%0.5L%') stop 6
20  call omp_display_affinity ('')
21  call omp_display_affinity ('%%%0.9N')
22  l1 = omp_capture_affinity (buf4, '%0.5{nesting_level}%%|||%0.7a%3N!%N!')
23  buf = '%.5L%%|||%0.7{ancestor_tnum}%3{num_threads}!%{num_threads}!'
24  call omp_set_affinity_format (trim (buf))
25  l2 = omp_capture_affinity (buf2, '')
26  if (l1 /= l2) stop 7
27  if (l1 /= 22) stop 8
28  if (buf2 /= '    0%|||-0000011  !1!') stop 9
29  if (buf4 /= '0') stop 10
30!$omp parallel num_threads (4) proc_bind(spread)
31  call omp_display_affinity ('%0.2a!%n!%.4L!%N;%.2t;%0.2T;&
32                             &%{team_num};%{num_teams};%A')
33!$omp end parallel
34end
35