4 interface operator(.add
.)
5 module procedure do_add
11 elemental
function do_add(x
, y
)
12 type (dt
), intent (in
) :: x
, y
16 elemental
subroutine dp_add(x
, y
)
17 double precision, intent (inout
) :: x
18 double precision, intent (in
) :: y
21 elemental
subroutine dp_init(x
)
22 double precision, intent (out
) :: x
28 use m
, only
: operator(.add
.), dt
, dp_add
, dp_init
29 type(dt
), allocatable
:: xdt(:)
32 integer (kind
= 4), allocatable
, dimension(:) :: i4
33 integer (kind
= 8), allocatable
, dimension(:,:) :: i8
35 real (kind
= 4), allocatable
:: r4(:,:)
36 double precision, allocatable
:: dp(:)
37 !$omp declare reduction(.add.:dt:omp_out=omp_out.add.omp_in)
38 !$omp declare reduction(foo:integer(4),integer(kind=8),real (kind = 4) &
39 !$omp & :omp_out = omp_out + omp_in) initializer (omp_priv = 0)
40 !$omp declare reduction(foo:double precision:dp_add (omp_out, omp_in)) &
41 !$omp & initializer (dp_init (omp_priv))
44 allocate (xdt(4), i4 (3), i8(-5:-2,2:3), r4(2:5,1:1), dp(7))
52 !$omp parallel reduction(.add.: xdt) reduction(+: r) &
53 !$omp & reduction(foo: i4, i8, r4, dp) private(i)
55 xdt(i
) = xdt(i
).add
.one
62 call dp_add (dp(i
), 1.0d0)
65 if (any (xdt
%r
.ne
. r
)) call abort
66 if (any (i4
.ne
.r
).or
.any(i8
.ne
.r
)) call abort
67 if (any(r4
.ne
.r
).or
.any(dp
.ne
.r
)) call abort
68 deallocate (xdt
, i4
, i8
, r4
, dp
)