Debian Codegraph @

libgomp/testsuite/libgomp.fortran/metadirective-4.f90

raw
1 ! { dg-do run }
2
3 program test
4 use omp_lib
5
6 implicit none
7 integer, parameter :: N = 100
8 integer :: a(N)
9 logical :: is_parallel, is_static
10
11 ! is_static is always set if run_parallel is false.
12 call f (a, .false., .false., is_parallel, is_static)
13 if (is_parallel .or. .not. is_static) stop 1
14
15 call f (a, .false., .true., is_parallel, is_static)
16 if (is_parallel .or. .not. is_static) stop 2
17
18 call f (a, .true., .false., is_parallel, is_static)
19 if (.not. is_parallel .or. is_static) stop 3
20
21 call f (a, .true., .true., is_parallel, is_static)
22 if (.not. is_parallel .or. .not. is_static) stop 4
23 contains
24 subroutine f (a, run_parallel, run_static, is_parallel, is_static)
25 integer :: a(N)
26 logical, intent(in) :: run_parallel, run_static
27 logical, intent(out) :: is_parallel, is_static
28 integer :: i
29
30 is_parallel = .false.
31 is_static = .false.
32
33 !$omp begin metadirective when(user={condition(run_parallel)}: parallel)
34 if (omp_in_parallel ()) is_parallel = .true.
35
36 !$omp metadirective &
37 !$omp& when(construct={parallel}, user={condition(.not. run_static)}: &
38 !$omp& do schedule(guided) private(is_static)) &
39 !$omp& when(construct={parallel}: do schedule(static))
40 do i = 1, N
41 a(i) = i
42 is_static = .true.
43 end do
44 !$omp end metadirective
45 end subroutine
46 end program