OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gfortran.dg/] [sum_init_expr.f03] - Blame information for rev 716

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 694 jeremybenn
! { dg-do run }
2
! { dg-options "-fno-inline" }
3
!
4
! SUM as initialization expression.
5
!
6
! This test compares results of simplifier of SUM
7
! with the corresponding inlined or library routine(s).
8
!
9
 
10
  IMPLICIT NONE
11
 
12
  INTEGER, PARAMETER :: imatrix(2,4) = RESHAPE ([ 1, 2, 3, 4, 5, 6, 7, 8 ], [2, 4] )
13
  INTEGER, PARAMETER :: imatrix_sum = SUM (imatrix)
14
  INTEGER, PARAMETER :: imatrix_sum_d1(4) = SUM (imatrix, dim=1)
15
  INTEGER, PARAMETER :: imatrix_sum_d2(2) = SUM (imatrix, dim=2)
16
  LOGICAL, PARAMETER :: i_equal_sum = ALL ([SUM( imatrix_sum_d1 ) ==  SUM ( imatrix_sum_d2 ), &
17
                                            SUM( imatrix_sum_d1 ) == imatrix_sum])
18
  LOGICAL, PARAMETER :: i_empty_sum = SUM(imatrix, mask=.FALSE.) == 0
19
 
20
  REAL, PARAMETER :: rmatrix(2,4) = RESHAPE ([ 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8 ], [2, 4] )
21
  REAL, PARAMETER :: rmatrix_sum = SUM (rmatrix)
22
  REAL, PARAMETER :: rmatrix_sum_d1(4) = SUM (rmatrix, dim=1)
23
  REAL, PARAMETER :: rmatrix_sum_d2(2) = SUM (rmatrix, dim=2)
24
  LOGICAL, PARAMETER :: r_equal_sum = ALL ([SUM( rmatrix_sum_d1 ) ==  SUM ( rmatrix_sum_d2 ), &
25
                                            SUM( rmatrix_sum_d1 ) == rmatrix_sum])
26
  LOGICAL, PARAMETER :: r_empty_sum = SUM(rmatrix, mask=.FALSE.) == 0.0
27
 
28
  IF (.NOT. ALL ([i_equal_sum, i_empty_sum])) CALL abort()
29
  IF (.NOT. ALL ([r_equal_sum, r_empty_sum])) CALL abort()
30
 
31
  CALL ilib (imatrix, imatrix_sum)
32
  CALL ilib_with_dim (imatrix, 1, imatrix_sum_d1)
33
  CALL ilib_with_dim (imatrix, 2, imatrix_sum_d2)
34
  CALL rlib (rmatrix, rmatrix_sum)
35
  CALL rlib_with_dim (rmatrix, 1, rmatrix_sum_d1)
36
  CALL rlib_with_dim (rmatrix, 2, rmatrix_sum_d2)
37
 
38
CONTAINS
39
  SUBROUTINE ilib (array, result)
40
    INTEGER, DIMENSION(:,:), INTENT(in) :: array
41
    INTEGER, INTENT(in) :: result
42
    IF (SUM(array) /= result) CALL abort()
43
  END SUBROUTINE
44
 
45
  SUBROUTINE ilib_with_dim (array, dim, result)
46
    INTEGER, DIMENSION(:,:), INTENT(in) :: array
47
    INTEGER, INTENT(iN)                 :: dim
48
    INTEGER, DIMENSION(:), INTENT(in)   :: result
49
    IF (ANY (SUM (array, dim=dim) /= result)) CALL abort()
50
  END SUBROUTINE
51
 
52
  SUBROUTINE rlib (array, result)
53
    REAL, DIMENSION(:,:), INTENT(in) :: array
54
    REAL, INTENT(in) :: result
55
    IF (ABS(SUM(array) - result) > 4e-6) CALL abort()
56
  END SUBROUTINE
57
 
58
  SUBROUTINE rlib_with_dim (array, dim, result)
59
    REAL, DIMENSION(:,:), INTENT(in) :: array
60
    INTEGER, INTENT(iN)              :: dim
61
    REAL, DIMENSION(:), INTENT(in)   :: result
62
    IF (ANY (ABS(SUM (array, dim=dim) - result) > 4e-6)) CALL abort()
63
  END SUBROUTINE
64
END
65
 
66
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.