Skip to content

Commit 9343432

Browse files
committed
Cleaning up unused variables.
1 parent ef852d3 commit 9343432

File tree

2 files changed

+24
-462
lines changed

2 files changed

+24
-462
lines changed

test/test_fftpack_original.f90

Lines changed: 24 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,21 @@ subroutine test_dfft(error)
2727
type(error_type), allocatable, intent(out) :: error
2828
real(rk) :: x(200), y(200), xh(200), w(2000)
2929
integer :: i, j, k, n, np1, nm1, ns2, nz, modn
30-
real(rk) :: fn, tfn, dt, sum1, sum2, arg, arg1
30+
real(rk) :: dt, sum1, sum2, arg, arg1
3131
real(rk) :: mismatch, cf
3232

3333
do nz = 1, size(nd)
3434
!> Create multisine signal.
3535
n = nd(nz)
3636
modn = mod(n, 2)
37-
fn = real(n, kind=rk)
38-
tfn = 2*fn
3937
np1 = n + 1; nm1 = n - 1
40-
do j = 1, np1
38+
do concurrent(j=1:np1)
4139
x(j) = sin(j*sqrt(2.0_rk))
42-
y(j) = x(j)
43-
xh(j) = x(j)
4440
end do
41+
y = x; xh = x
4542

4643
!> Discrete Fourier Transform.
47-
dt = 2*pi/fn
44+
dt = 2*pi/n
4845
ns2 = (n + 1)/2
4946
if (ns2 >= 2) then
5047
do k = 2, ns2
@@ -59,11 +56,8 @@ subroutine test_dfft(error)
5956
y(2*k - 1) = -sum2
6057
end do
6158
end if
62-
sum1 = 0.0_rk; sum2 = 0.0_rk
63-
do i = 1, nm1, 2
64-
sum1 = sum1 + x(i)
65-
sum2 = sum2 + x(i + 1)
66-
end do
59+
sum1 = sum(x(1:nm1:2))
60+
sum2 = sum(x(2:nm1 + 1:2))
6761
if (modn == 1) sum1 = sum1 + x(n)
6862
y(1) = sum1 + sum2
6963
if (modn == 0) y(n) = sum1 - sum2
@@ -73,7 +67,7 @@ subroutine test_dfft(error)
7367
call dfftf(n, x, w)
7468

7569
!> Check error.
76-
mismatch = maxval(abs(x(:n) - y(:n)))/fn
70+
mismatch = maxval(abs(x(:n) - y(:n)))/n
7771
call check(error, mismatch < rtol)
7872
if (allocated(error)) return
7973

@@ -106,7 +100,7 @@ subroutine test_dfft(error)
106100
call dfftf(n, y, w)
107101

108102
!> Check error.
109-
cf = 1.0_rk/fn
103+
cf = 1.0_rk/n
110104
mismatch = maxval(abs(cf*y(:n) - x(:n)))
111105
call check(error, mismatch < rtol)
112106
if (allocated(error)) return
@@ -122,7 +116,7 @@ subroutine test_zfft(error)
122116
do nz = 1, size(nd)
123117
!> Create signal.
124118
n = nd(nz)
125-
do i = 1, n
119+
do concurrent(i=1:n)
126120
cx(i) = cmplx(cos(sqrt(2.0_rk)*i), sin(sqrt(2.0_rk)*i**2), kind=rk)
127121
end do
128122

@@ -181,26 +175,21 @@ end subroutine test_zfft
181175
subroutine test_sint(error)
182176
type(error_type), allocatable, intent(out) :: error
183177
real(rk) :: x(200), y(200), xh(200), w(2000)
184-
integer :: i, j, k, n, np1, nm1, ns2, nz, modn
178+
integer :: i, j, k, n, np1, nm1, ns2, nz
185179
real(rk) :: dt, sum1, sum2, arg, arg1
186180
real(rk) :: mismatch, cf
187181

188182
do nz = 1, size(nd)
189183
!> Create multisine signal.
190184
n = nd(nz)
191-
modn = mod(n, 2)
192185
np1 = n + 1; nm1 = n - 1
193-
do j = 1, np1
186+
do concurrent(j=1:np1)
194187
x(j) = sin(j*sqrt(2.0_rk))
195-
y(j) = x(j)
196-
xh(j) = x(j)
197188
end do
189+
y = x; xh = x
198190

199191
!> Discrete sine transform.
200192
dt = pi/n
201-
do i = 1, nm1
202-
x(i) = xh(i)
203-
end do
204193

205194
do i = 1, nm1
206195
y(i) = 0.0_rk
@@ -236,26 +225,21 @@ end subroutine test_sint
236225
subroutine test_cost(error)
237226
type(error_type), allocatable, intent(out) :: error
238227
real(rk) :: x(200), y(200), xh(200), w(2000)
239-
integer :: i, j, k, n, np1, nm1, ns2, nz, modn
228+
integer :: i, j, k, n, np1, nm1, ns2, nz
240229
real(rk) :: dt, sum1, sum2, arg, arg1
241230
real(rk) :: mismatch, cf
242231

243232
do nz = 1, size(nd)
244233
!> Create multisine signal.
245234
n = nd(nz)
246-
modn = mod(n, 2)
247235
np1 = n + 1; nm1 = n - 1
248-
do j = 1, np1
236+
do concurrent(j=1:np1)
249237
x(j) = sin(j*sqrt(2.0_rk))
250-
y(j) = x(j)
251-
xh(j) = x(j)
252238
end do
239+
y = x; xh = x
253240

254241
!> Discrete sine transform.
255242
dt = pi/n
256-
do i = 1, np1
257-
x(i) = xh(i)
258-
end do
259243

260244
do i = 1, np1
261245
y(i) = 0.5_rk*(x(1) + (-1)**(i + 1)*x(n + 1))
@@ -291,24 +275,21 @@ end subroutine test_cost
291275
subroutine test_cosqt(error)
292276
type(error_type), allocatable, intent(out) :: error
293277
real(rk) :: x(200), y(200), xh(200), w(2000)
294-
integer :: i, j, k, n, np1, nm1, ns2, nz, modn
278+
integer :: i, j, k, n, np1, nm1, ns2, nz
295279
real(rk) :: dt, sum1, sum2, arg, arg1
296280
real(rk) :: mismatch, cf
297281

298282
do nz = 1, size(nd)
299283
!> Create multisine signal.
300284
n = nd(nz)
301-
modn = mod(n, 2)
302285
np1 = n + 1; nm1 = n - 1
303-
do j = 1, np1
286+
do concurrent(j=1:np1)
304287
x(j) = sin(j*sqrt(2.0_rk))
305-
y(j) = x(j)
306-
xh(j) = x(j)
307288
end do
289+
y = x; xh = x
308290

309291
!> Discrete quater-cos transform.
310292
dt = pi/(2*n)
311-
y(:n) = xh(:n)
312293

313294
do i = 1, n
314295
x(i) = 0.0_rk
@@ -345,7 +326,6 @@ subroutine test_cosqt(error)
345326

346327
!> Check error.
347328
mismatch = maxval(abs(y(:n) - x(:n)))*cf
348-
print *, "Mismatch :", mismatch, rtol
349329
call check(error, mismatch < rtol)
350330
if (allocated(error)) return
351331

@@ -368,24 +348,21 @@ subroutine test_dzfft(error)
368348
real(rk) :: a(100), b(100), ah(100), bh(100)
369349
real(rk) :: azero, azeroh
370350
integer :: i, j, k, n, np1, nm1, ns2, ns2m, nz, modn
371-
real(rk) :: fn, tfn, dt, sum1, sum2, arg, arg1, arg2
351+
real(rk) :: dt, sum1, sum2, arg, arg1, arg2
372352
real(rk) :: mismatch, cf
373353

374354
do nz = 1, size(nd)
375355
!> Create multisine signal.
376356
n = nd(nz)
377357
modn = mod(n, 2)
378-
fn = real(n, kind=rk)
379-
tfn = 2*fn
380358
np1 = n + 1; nm1 = n - 1
381-
do j = 1, np1
359+
do concurrent(j=1:np1)
382360
x(j) = sin(j*sqrt(2.0_rk))
383-
y(j) = x(j)
384-
xh(j) = x(j)
385361
end do
362+
y = x; xh = x
386363

387364
!> Discrete Fourier Transform.
388-
dt = 2*pi/fn
365+
dt = 2*pi/n
389366
ns2 = (n + 1)/2
390367
ns2m = ns2 - 1
391368
cf = 2.0_rk/n
@@ -403,12 +380,8 @@ subroutine test_dzfft(error)
403380
end do
404381
end if
405382
nm1 = n - 1
406-
sum1 = 0.0_rk
407-
sum2 = 0.0_rk
408-
do i = 1, nm1, 2
409-
sum1 = sum1 + x(i)
410-
sum2 = sum2 + x(i + 1)
411-
end do
383+
sum1 = sum(x(1:nm1:2))
384+
sum2 = sum(x(2:nm1 + 1:2))
412385
if (modn == 1) sum1 = sum1 + x(n)
413386
azero = 0.5_rk*cf*(sum1 + sum2)
414387
if (modn == 0) a(ns2) = 0.5_rk*cf*(sum1 - sum2)

0 commit comments

Comments
 (0)