1! { dg-do run } 2! { dg-require-effective-target tls_runtime } 3 4 use omp_lib 5 integer, allocatable, save :: a, b(:), c(:,:) 6 integer :: p 7!$omp threadprivate (a, b, c) 8 if (allocated (a) .or. allocated (b) .or. allocated (c)) call abort 9 10 call omp_set_dynamic (.false.) 11 call omp_set_num_threads (4) 12 13!$omp parallel num_threads (4) 14 if (allocated (a) .or. allocated (b) .or. allocated (c)) call abort 15!$omp end parallel 16 17 allocate (a, b(6:9), c(3, 8:9)) 18 a = 4 19 b = 5 20 c = 6 21 if (.not.allocated (a)) call abort 22 if (.not.allocated (b) .or. size (b) /= 4) call abort 23 if (lbound (b, 1) /= 6 .or. ubound (b, 1) /= 9) call abort 24 if (.not.allocated (c) .or. size (c) /= 6) call abort 25 if (size (c, 1) /= 3 .or. size (c, 2) /= 2) call abort 26 if (lbound (c, 1) /= 1 .or. ubound (c, 1) /= 3) call abort 27 if (lbound (c, 2) /= 8 .or. ubound (c, 2) /= 9) call abort 28 29!$omp parallel num_threads (4) copyin (a, b, c) private (p) 30 p = omp_get_thread_num () 31 if (.not.allocated (a)) call abort 32 if (.not.allocated (b) .or. size (b) /= 4) call abort 33 if (lbound (b, 1) /= 6 .or. ubound (b, 1) /= 9) call abort 34 if (.not.allocated (c) .or. size (c) /= 6) call abort 35 if (size (c, 1) /= 3 .or. size (c, 2) /= 2) call abort 36 if (lbound (c, 1) /= 1 .or. ubound (c, 1) /= 3) call abort 37 if (lbound (c, 2) /= 8 .or. ubound (c, 2) /= 9) call abort 38 if (a /= 4 .or. any (b /= 5) .or. any (c /= 6)) call abort 39 deallocate (a, b, c) 40 if (allocated (a) .or. allocated (b) .or. allocated (c)) call abort 41 allocate (a, b(p:9), c(3, p:7)) 42 a = p 43 b = p 44 c = p 45 if (.not.allocated (a)) call abort 46 if (.not.allocated (b) .or. size (b) /= (10 - p)) call abort 47 if (lbound (b, 1) /= p .or. ubound (b, 1) /= 9) call abort 48 if (.not.allocated (c) .or. size (c) /= (3 * (8 - p))) call abort 49 if (size (c, 1) /= 3 .or. size (c, 2) /= (8 - p)) call abort 50 if (lbound (c, 1) /= 1 .or. ubound (c, 1) /= 3) call abort 51 if (lbound (c, 2) /= p .or. ubound (c, 2) /= 7) call abort 52 if (a /= p .or. any (b /= p) .or. any (c /= p)) call abort 53!$omp end parallel 54 55!$omp parallel num_threads (4) copyin (a, b, c) 56 if (.not.allocated (a)) call abort 57 if (.not.allocated (b) .or. size (b) /= 10) call abort 58 if (lbound (b, 1) /= 0 .or. ubound (b, 1) /= 9) call abort 59 if (.not.allocated (c) .or. size (c) /= 24) call abort 60 if (size (c, 1) /= 3 .or. size (c, 2) /= 8) call abort 61 if (lbound (c, 1) /= 1 .or. ubound (c, 1) /= 3) call abort 62 if (lbound (c, 2) /= 0 .or. ubound (c, 2) /= 7) call abort 63 if (a /= 0 .or. any (b /= 0) .or. any (c /= 0)) call abort 64!$omp end parallel 65 66 deallocate (a, b, c) 67 if (allocated (a) .or. allocated (b) .or. allocated (c)) call abort 68 69!$omp parallel num_threads (4) copyin (a, b, c) 70 if (allocated (a) .or. allocated (b) .or. allocated (c)) call abort 71!$omp end parallel 72end 73