blob: f0949b5530d7b7cd02b968a843109f421c32b00d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
! PR fortran/51722
module m
implicit none
contains
subroutine seltype
type :: a
integer :: p = 2
end type a
type, extends(a) :: b
integer :: cnt = 0
end type b
integer :: k, s
class(a), pointer :: x
allocate(a :: x)
s = 0
select type (y => x)
class is (a)
!$omp parallel do default(shared) private(k) reduction(+:s)
do k = 1,10
s = s + k*y%p
end do
!$omp end parallel do
end select
if (s /= 110) error stop
deallocate(x)
allocate(b :: x)
s = 0
select type (y => x)
class is (b)
!$omp parallel do default(shared) private(k) reduction(+:s)
do k = 1,10
s = s + k*y%p
!$omp atomic update
y%cnt = y%cnt + 2
end do
!$omp end parallel do
if (s /= 110) error stop
if (y%p /= 2) error stop
if (y%cnt /= 10*2) error stop
end select
deallocate(x)
end subroutine seltype
subroutine assoc
type :: b
integer :: r = 3
end type b
type :: a
integer :: p = 2
class(b), pointer :: u => null()
end type a
integer :: k, s
class(a), pointer :: x
s = 0
allocate(a :: x)
allocate(b :: x%u)
associate(f => x%u)
!$omp parallel do default(shared) private(k) reduction(+:s)
do k = 1,10
s = s + k*f%r
end do
!$omp end parallel do
end associate
deallocate(x%u)
deallocate(x)
if (s /= 165) error stop
end subroutine assoc
end module m
use m
implicit none (type, external)
call seltype
call assoc
end
|