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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
|
! { dg-do run { xfail spu-*-* } }
! FAILs on SPU because of wrong compile-time rounding mode
! { dg-options "" }
! { dg-options "-ffloat-store" { target { { i?86-*-* x86_64-*-* } && ilp32 } } }
!
!
module mod_check
implicit none
interface check
module procedure check_i8
module procedure check_i4
module procedure check_r8
module procedure check_r4
module procedure check_c8
module procedure check_c4
end interface check
interface acheck
module procedure acheck_c8
module procedure acheck_c4
end interface acheck
contains
subroutine check_i8 (a, b)
integer(kind=8), intent(in) :: a, b
if (a /= b) call abort()
end subroutine check_i8
subroutine check_i4 (a, b)
integer(kind=4), intent(in) :: a, b
if (a /= b) call abort()
end subroutine check_i4
subroutine check_r8 (a, b)
real(kind=8), intent(in) :: a, b
if (a /= b) call abort()
end subroutine check_r8
subroutine check_r4 (a, b)
real(kind=4), intent(in) :: a, b
if (a /= b) call abort()
end subroutine check_r4
subroutine check_c8 (a, b)
complex(kind=8), intent(in) :: a, b
if (a /= b) call abort()
end subroutine check_c8
subroutine check_c4 (a, b)
complex(kind=4), intent(in) :: a, b
if (a /= b) call abort()
end subroutine check_c4
subroutine acheck_c8 (a, b)
complex(kind=8), intent(in) :: a, b
if (abs(a-b) > 1.d-9 * min(abs(a),abs(b))) call abort()
end subroutine acheck_c8
subroutine acheck_c4 (a, b)
complex(kind=4), intent(in) :: a, b
if (abs(a-b) > 1.e-5 * min(abs(a),abs(b))) call abort()
end subroutine acheck_c4
end module mod_check
program test
use mod_check
implicit none
integer(kind=4) :: i4
integer(kind=8) :: i8
real(kind=4) :: r4
real(kind=8) :: r8
complex(kind=4) :: c4
complex(kind=8) :: c8
#define TEST(base,exp,var) var = base; call check((var)**(exp),(base)**(exp))
#define ATEST(base,exp,var) var = base; call acheck((var)**(exp),(base)**(exp))
!!!!! INTEGER BASE !!!!!
TEST(0,0,i4)
TEST(0_8,0_8,i8)
TEST(1,0,i4)
TEST(1_8,0_8,i8)
TEST(-1,0,i4)
TEST(-1_8,0_8,i8)
TEST(huge(0_4),0,i4)
TEST(huge(0_8),0_8,i8)
TEST(-huge(0_4)-1,0,i4)
TEST(-huge(0_8)-1_8,0_8,i8)
TEST(1,1,i4)
TEST(1_8,1_8,i8)
TEST(1,2,i4)
TEST(1_8,2_8,i8)
TEST(1,-1,i4)
TEST(1_8,-1_8,i8)
TEST(1,-2,i4)
TEST(1_8,-2_8,i8)
TEST(1,huge(0),i4)
TEST(1_8,huge(0_8),i8)
TEST(1,-huge(0)-1,i4)
TEST(1_8,-huge(0_8)-1_8,i8)
TEST(-1,1,i4)
TEST(-1_8,1_8,i8)
TEST(-1,2,i4)
TEST(-1_8,2_8,i8)
TEST(-1,-1,i4)
TEST(-1_8,-1_8,i8)
TEST(-1,-2,i4)
TEST(-1_8,-2_8,i8)
TEST(-1,huge(0),i4)
TEST(-1_8,huge(0_8),i8)
TEST(-1,-huge(0)-1,i4)
TEST(-1_8,-huge(0_8)-1_8,i8)
TEST(2,9,i4)
TEST(2_8,9_8,i8)
TEST(-2,9,i4)
TEST(-2_8,9_8,i8)
TEST(2,-9,i4)
TEST(2_8,-9_8,i8)
TEST(-2,-9,i4)
TEST(-2_8,-9_8,i8)
!!!!! REAL BASE !!!!!
TEST(0.0,0,r4)
TEST(0.0,1,r4)
TEST(0.0,huge(0),r4)
TEST(0.0,0_8,r4)
TEST(0.0,1_8,r4)
TEST(0.0,huge(0_8),r4)
TEST(1.0,0,r4)
TEST(1.0,1,r4)
TEST(1.0,-1,r4)
TEST(1.0,huge(0),r4)
TEST(1.0,-huge(0)-1,r4)
TEST(1.0,0_8,r4)
TEST(1.0,1_8,r4)
TEST(1.0,-1_8,r4)
TEST(1.0,huge(0_8),r4)
TEST(1.0,-huge(0_8)-1_8,r4)
TEST(-1.0,0,r4)
TEST(-1.0,1,r4)
TEST(-1.0,-1,r4)
TEST(-1.0,huge(0),r4)
TEST(-1.0,-huge(0)-1,r4)
TEST(-1.0,0_8,r4)
TEST(-1.0,1_8,r4)
TEST(-1.0,-1_8,r4)
TEST(-1.0,huge(0_8),r4)
TEST(-1.0,-huge(0_8)-1_8,r4)
TEST(2.0,0,r4)
TEST(2.0,1,r4)
TEST(2.0,-1,r4)
TEST(2.0,3,r4)
TEST(2.0,-3,r4)
TEST(2.0,0_8,r4)
TEST(2.0,1_8,r4)
TEST(2.0,-1_8,r4)
TEST(2.0,3_8,r4)
TEST(2.0,-3_8,r4)
TEST(nearest(1.0,-1.0),0,r4)
TEST(nearest(1.0,-1.0),huge(0_4),r4) ! { dg-warning "Arithmetic underflow" }
TEST(nearest(1.0,-1.0),0_8,r4)
TEST(nearest(1.0_8,-1.0),huge(0_8),r8) ! { dg-warning "Arithmetic underflow" }
TEST(nearest(1.0,-1.0),107,r4)
TEST(nearest(1.0,1.0),107,r4)
!!!!! COMPLEX BASE !!!!!
TEST((1.0,0.2),0,c4)
TEST((1.0,0.2),1,c4)
TEST((1.0,0.2),2,c4)
ATEST((1.0,0.2),9,c4)
ATEST((1.0,0.2),-1,c4)
ATEST((1.0,0.2),-2,c4)
ATEST((1.0,0.2),-9,c4)
TEST((0.0,0.2),0,c4)
TEST((0.0,0.2),1,c4)
TEST((0.0,0.2),2,c4)
ATEST((0.0,0.2),9,c4)
ATEST((0.0,0.2),-1,c4)
ATEST((0.0,0.2),-2,c4)
ATEST((0.0,0.2),-9,c4)
TEST((1.0,0.),0,c4)
TEST((1.0,0.),1,c4)
TEST((1.0,0.),2,c4)
TEST((1.0,0.),9,c4)
ATEST((1.0,0.),-1,c4)
ATEST((1.0,0.),-2,c4)
ATEST((1.0,0.),-9,c4)
end program test
! { dg-final { cleanup-modules "mod_check" } }
|