aboutsummaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.fortran/udr4.f90
blob: 5d70b6b2830a412ecb97c91f9062705567147ff1 (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
! { dg-do run }

!$omp declare reduction (foo : character(kind=1, len=*) &
!$omp & : omp_out = fn (omp_out, omp_in)) initializer (omp_priv = '')
!$omp declare reduction (bar : character(kind=1, len=:) &
!$omp & : omp_out = fn (omp_in, omp_out)) initializer (omp_priv = '')
!$omp declare reduction (baz : character(kind=1, len=1) &
!$omp & : omp_out = char (ichar (omp_out) + ichar (omp_in) &
!$omp & - ichar ('0'))) initializer (omp_priv = '0')
!$omp declare reduction (baz : character(kind=1, len=2) &
!$omp & : omp_out = char (ichar (omp_out(1:1)) + ichar (omp_in(1:1)) &
!$omp & - ichar ('0')) // char (ichar (omp_out(2:2)) + &
!$omp & ichar (omp_in(2:2)) - ichar ('0'))) initializer (omp_priv = '00')
  interface
    elemental function fn (x, y)
      character (len=64), intent (in) :: x, y
      character (len=64) :: fn
    end function
  end interface
  character(kind=1, len=64) :: c(-3:-2,1:1,7:8), d(2:3,-7:-5)
  character(kind = 1, len=1) :: e(2:4)
  character(kind = 1, len=1+1) :: f(8:10,9:10)
  integer :: i, j, k
  c = ''
  d = ''
  e = '0'
  f = '00'
!$omp parallel do reduction (foo : c) reduction (bar : d) &
!$omp & reduction (baz : e, f) private (j, k)
  do i = 1, 64
    forall (j = -3:-2, k = 7:8) &
      c(j,1,k) = trim(c(j,1,k)) // char (ichar ('0') + i)
    d = char (ichar ('0') + i) // d
    e = char (ichar (e) + mod (i, 3))
    f = char (ichar (f(:,:)(1:1)) + mod (i, 2)) &
&	// char (ichar (f(:,:)(2:2)) + mod (i, 3))
  end do
  do i = 1, 64
    if (any (index (c, char (ichar ('0') + i)) .eq. 0)) stop 1
    if (any (index (d, char (ichar ('0') + i)) .eq. 0)) stop 2
  end do
  if (any (e.ne.char (ichar ('0') + 64))) stop 3
  if (any (f(:,:)(1:1).ne.char (ichar ('0') + 32))) stop 4
  if (any (f(:,:)(2:2).ne.char (ichar ('0') + 64))) stop 5
end
elemental function fn (x, y)
  character (len=64), intent (in) :: x, y
  character (len=64) :: fn
  fn = trim(x) // y
end function