Skip to content

Commit 5601a66

Browse files
committed
Fix Makefile & replace dp with rk.
1 parent 976b214 commit 5601a66

File tree

9 files changed

+162
-109
lines changed

9 files changed

+162
-109
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ cd fftpack
1212
```
1313

1414
### Build with [fortran-lang/fpm](https://github.com/fortran-lang/fpm)
15-
Fortran Package Manager (fpm) is a great package manager and build system for Fortran.
15+
Fortran Package Manager (fpm) is a package manager and build system for Fortran.
1616
You can build using provided `fpm.toml`:
1717
```bash
18-
fpm build --flag "-O2"
19-
fpm test --flag "-O2" --list
20-
fpm test --flag "-O2" <test_name, see `fpm.toml` or list>
18+
fpm build
19+
fpm test --list
20+
fpm test <test_name, see `fpm.toml` or list>
2121
```
2222
To use `fftpack` within your `fpm` project, add the following to your `fpm.toml` file:
2323
```toml

example/bench1.f90

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
program bench1
22
use fftpack, only: zffti, zfftf, zfftb
3+
use fftpack_kind, only: rk
34
implicit none
4-
integer, parameter :: dp = kind(0.d0)
5-
complex(dp), allocatable :: z(:)
6-
real(dp), allocatable :: w(:), x(:)
7-
real(dp) :: err, time_init, time_forward, time_backward, t1, t2
5+
complex(rk), allocatable :: z(:)
6+
real(rk), allocatable :: w(:), x(:)
7+
real(rk) :: err, time_init, time_forward, time_backward, t1, t2
88
integer :: N
99

1010
N = 1024*1014*16
@@ -32,7 +32,7 @@ program bench1
3232
time_backward = t2-t1
3333
print *, "Done"
3434

35-
err = maxval(abs(x-real(z/N,dp)))
35+
err = maxval(abs(x-real(z/N,rk)))
3636
print *
3737
print *, "Error: ", err
3838
print *, "Init time: ", time_init

src/Makefile

Lines changed: 111 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,53 @@
11
SRCF = \
2-
zfftb.f\
3-
cfftb1.f\
4-
zfftf.f\
5-
cfftf1.f\
6-
zffti.f\
7-
cffti1.f\
8-
dcosqb.f\
9-
cosqb1.f\
10-
dcosqf.f\
11-
cosqf1.f\
12-
dcosqi.f\
13-
dcost.f\
14-
dcosti.f\
15-
ezfft1.f\
16-
dzfftb.f\
17-
dzfftf.f\
18-
dzffti.f\
19-
passb.f\
20-
passb2.f\
21-
passb3.f\
22-
passb4.f\
23-
passb5.f\
24-
passf.f\
25-
passf2.f\
26-
passf3.f\
27-
passf4.f\
28-
passf5.f\
29-
radb2.f\
30-
radb3.f\
31-
radb4.f\
32-
radb5.f\
33-
radbg.f\
34-
radf2.f\
35-
radf3.f\
36-
radf4.f\
37-
radf5.f\
38-
radfg.f\
39-
dfftb.f\
40-
rfftb1.f\
41-
dfftf.f\
42-
rfftf1.f\
43-
dffti.f\
44-
rffti1.f\
45-
dsinqb.f\
46-
dsinqf.f\
47-
dsinqi.f\
48-
dsint.f\
49-
sint1.f\
50-
dsinti.f
2+
zfftb.f90\
3+
cfftb1.f90\
4+
zfftf.f90\
5+
cfftf1.f90\
6+
zffti.f90\
7+
cffti1.f90\
8+
dcosqb.f90\
9+
cosqb1.f90\
10+
dcosqf.f90\
11+
cosqf1.f90\
12+
dcosqi.f90\
13+
dcost.f90\
14+
dcosti.f90\
15+
ezfft1.f90\
16+
dzfftb.f90\
17+
dzfftf.f90\
18+
dzffti.f90\
19+
passb.f90\
20+
passb2.f90\
21+
passb3.f90\
22+
passb4.f90\
23+
passb5.f90\
24+
passf.f90\
25+
passf2.f90\
26+
passf3.f90\
27+
passf4.f90\
28+
passf5.f90\
29+
radb2.f90\
30+
radb3.f90\
31+
radb4.f90\
32+
radb5.f90\
33+
radbg.f90\
34+
radf2.f90\
35+
radf3.f90\
36+
radf4.f90\
37+
radf5.f90\
38+
radfg.f90\
39+
dfftb.f90\
40+
rfftb1.f90\
41+
dfftf.f90\
42+
rfftf1.f90\
43+
dffti.f90\
44+
rffti1.f90\
45+
dsinqb.f90\
46+
dsinqf.f90\
47+
dsinqi.f90\
48+
dsint.f90\
49+
sint1.f90\
50+
dsinti.f90
5151

5252
SRCF90 = \
5353
fftpack.f90\
@@ -59,9 +59,10 @@ SRCF90 = \
5959
fftpack_ifftshift.f90\
6060
fftpack_qct.f90\
6161
fftpack_iqct.f90\
62-
fftpack_dct.f90
62+
fftpack_dct.f90\
63+
rk.f90
6364

64-
OBJF := $(SRCF:.f=.o)
65+
OBJF := $(SRCF:.f90=.o)
6566
OBJF90 := $(SRCF90:.f90=.o)
6667

6768
lib$(LIB).a: $(OBJF) $(OBJF90)
@@ -76,12 +77,62 @@ clean:
7677
%.o: %.f90
7778
$(FC) $(FFLAGS) -c $<
7879

79-
fftpack_fft.o: fftpack.o
80-
fftpack_ifft.o: fftpack.o
81-
fftpack_rfft.o: fftpack.o
82-
fftpack_irfft.o: fftpack.o
83-
fftpack_qct.o: fftpack.o
84-
fftpack_iqct.o: fftpack.o
85-
fftpack_dct.o: fftpack.o
86-
fftpack_fftshift.o: fftpack.o
87-
fftpack_ifftshift.o: fftpack.o
80+
fftpack_fft.o: fftpack.o rk.o
81+
fftpack_ifft.o: fftpack.o rk.o
82+
fftpack_rfft.o: fftpack.o rk.o
83+
fftpack_irfft.o: fftpack.o rk.o
84+
fftpack_qct.o: fftpack.o rk.o
85+
fftpack_iqct.o: fftpack.o rk.o
86+
fftpack_dct.o: fftpack.o rk.o
87+
fftpack_fftshift.o: fftpack.o rk.o
88+
fftpack_ifftshift.o: fftpack.o rk.o
89+
90+
zfftb.f90: rk.o
91+
cfftb1.f90: rk.o
92+
zfftf.f90: rk.o
93+
cfftf1.f90: rk.o
94+
zffti.f90: rk.o
95+
cffti1.f90: rk.o
96+
dcosqb.f90: rk.o
97+
cosqb1.f90: rk.o
98+
dcosqf.f90: rk.o
99+
cosqf1.f90: rk.o
100+
dcosqi.f90: rk.o
101+
dcost.f90: rk.o
102+
dcosti.f90: rk.o
103+
ezfft1.f90: rk.o
104+
dzfftb.f90: rk.o
105+
dzfftf.f90: rk.o
106+
dzffti.f90: rk.o
107+
passb.f90: rk.o
108+
passb2.f90: rk.o
109+
passb3.f90: rk.o
110+
passb4.f90: rk.o
111+
passb5.f90: rk.o
112+
passf.f90: rk.o
113+
passf2.f90: rk.o
114+
passf3.f90: rk.o
115+
passf4.f90: rk.o
116+
passf5.f90: rk.o
117+
radb2.f90: rk.o
118+
radb3.f90: rk.o
119+
radb4.f90: rk.o
120+
radb5.f90: rk.o
121+
radbg.f90: rk.o
122+
radf2.f90: rk.o
123+
radf3.f90: rk.o
124+
radf4.f90: rk.o
125+
radf5.f90: rk.o
126+
radfg.f90: rk.o
127+
dfftb.f90: rk.o
128+
rfftb1.f90: rk.o
129+
dfftf.f90: rk.o
130+
rfftf1.f90: rk.o
131+
dffti.f90: rk.o
132+
rffti1.f90: rk.o
133+
dsinqb.f90: rk.o
134+
dsinqf.f90: rk.o
135+
dsinqi.f90: rk.o
136+
dsint.f90: rk.o
137+
sint1.f90: rk.o
138+
dsinti.f90: rk.o

src/fftpack.f90

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ module fftpack
1818

1919
public :: dcosti, dcost
2020
public :: dct, idct
21+
22+
public :: rk
2123

2224
interface
2325

@@ -157,20 +159,20 @@ end subroutine dcosqb
157159
!>
158160
!> Initialize `dcost`. ([Specification](../page/specs/fftpack.html#dcosti))
159161
pure subroutine dcosti(n, wsave)
160-
import dp
162+
import rk
161163
integer, intent(in) :: n
162-
real(kind=dp), intent(out) :: wsave(*)
164+
real(kind=rk), intent(out) :: wsave(*)
163165
end subroutine dcosti
164166

165167
!> Version: experimental
166168
!>
167169
!> Discrete fourier cosine transform of an even sequence.
168170
!> ([Specification](../page/specs/fftpack.html#dcost))
169171
pure subroutine dcost(n, x, wsave)
170-
import dp
172+
import rk
171173
integer, intent(in) :: n
172-
real(kind=dp), intent(inout) :: x(*)
173-
real(kind=dp), intent(in) :: wsave(*)
174+
real(kind=rk), intent(inout) :: x(*)
175+
real(kind=rk), intent(in) :: wsave(*)
174176
end subroutine dcost
175177

176178
end interface
@@ -252,19 +254,19 @@ end function iqct_rk
252254
!> Discrete fourier cosine (forward) transform of an even sequence.
253255
!> ([Specification](../page/specs/fftpack.html#dct))
254256
interface dct
255-
pure module function dct_dp(x, n) result(result)
256-
real(kind=dp), intent(in) :: x(:)
257+
pure module function dct_rk(x, n) result(result)
258+
real(kind=rk), intent(in) :: x(:)
257259
integer, intent(in), optional :: n
258-
real(kind=dp), allocatable :: result(:)
259-
end function dct_dp
260+
real(kind=rk), allocatable :: result(:)
261+
end function dct_rk
260262
end interface dct
261263

262264
!> Version: experimental
263265
!>
264266
!> Discrete fourier cosine (backward) transform of an even sequence.
265267
!> ([Specification](../page/specs/fftpack.html#idct))
266268
interface idct
267-
module procedure :: dct_dp
269+
module procedure :: dct_rk
268270
end interface idct
269271

270272
!> Version: experimental

src/fftpack_dct.f90

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33
contains
44

55
!> Discrete fourier cosine transform of an even sequence.
6-
pure module function dct_dp(x, n) result(result)
7-
real(kind=dp), intent(in) :: x(:)
6+
pure module function dct_rk(x, n) result(result)
7+
real(kind=rk), intent(in) :: x(:)
88
integer, intent(in), optional :: n
9-
real(kind=dp), allocatable :: result(:)
9+
real(kind=rk), allocatable :: result(:)
1010

1111
integer :: lenseq, lensav, i
12-
real(kind=dp), allocatable :: wsave(:)
12+
real(kind=rk), allocatable :: wsave(:)
1313

1414
if (present(n)) then
1515
lenseq = n
1616
if (lenseq <= size(x)) then
1717
result = x(:lenseq)
1818
else if (lenseq > size(x)) then
19-
result = [x, (0.0_dp, i=1, lenseq - size(x))]
19+
result = [x, (0.0_rk, i=1, lenseq - size(x))]
2020
end if
2121
else
2222
lenseq = size(x)
@@ -31,6 +31,6 @@ pure module function dct_dp(x, n) result(result)
3131
!> Discrete fourier cosine transformation
3232
call dcost(lenseq, result, wsave)
3333

34-
end function dct_dp
34+
end function dct_rk
3535

3636
end submodule fftpack_dct

test/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ all: tstfft \
1313
fftpack_dct
1414

1515
# Orginal test
16-
tstfft: tstfft.o
16+
tstfft: tstfft.f
1717
$(FC) $(FFLAGS) $< -L../src -l$(LIB) -I../src -o $@.x
1818
time ./tstfft.x
1919

@@ -68,4 +68,4 @@ fftpack_ifftshift: test_fftpack_ifftshift.f90
6868
./fftpack_ifftshift.x
6969

7070
clean:
71-
rm -f -r *.o *.x
71+
rm -f -r *.o *.x

test/test_fftpack_dcosq.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ end subroutine check
1313

1414
subroutine test_fftpack_dcosq_real
1515
use fftpack, only: dcosqi, dcosqf, dcosqb
16-
use fftpack_kind
16+
use fftpack_kind
1717
real(kind=rk) :: w(3*4 + 15)
1818
real(kind=rk) :: x(4) = [1, 2, 3, 4]
1919
real(kind=rk) :: eps = 1.0e-10_rk

test/test_fftpack_dcost.f90

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ end subroutine check
1313

1414
subroutine test_fftpack_dcost_real
1515
use fftpack, only: dcosti, dcost
16-
use iso_fortran_env, only: dp => real64
17-
real(kind=dp) :: w(3*4 + 15)
18-
real(kind=dp) :: x(4) = [1, 2, 3, 4]
19-
real(kind=dp) :: eps = 1.0e-10_dp
16+
use fftpack_kind
17+
real(kind=rk) :: w(3*4 + 15)
18+
real(kind=rk) :: x(4) = [1, 2, 3, 4]
19+
real(kind=rk) :: eps = 1.0e-10_rk
2020

2121
call dcosti(4, w)
2222
call dcost(4, x, w)
23-
call check(all(x == [real(kind=dp) :: 15, -4, 0, -1.0000000000000009_dp]), msg="`dcosti` failed.")
23+
call check(all(x == [real(kind=rk) :: 15, -4, 0, -1.0000000000000009_rk]), msg="`dcosti` failed.")
2424

2525
call dcost(4, x, w)
26-
call check(all(x/(2.0_dp*(4.0_dp - 1.0_dp)) == [real(kind=dp) :: 1, 2, 3, 4]), msg="`dcost` failed.")
26+
call check(all(x/(2.0_rk*(4.0_rk - 1.0_rk)) == [real(kind=rk) :: 1, 2, 3, 4]), msg="`dcost` failed.")
2727

2828
end subroutine test_fftpack_dcost_real
2929

0 commit comments

Comments
 (0)