-
Notifications
You must be signed in to change notification settings - Fork 5
/
adjac_fft.f95
208 lines (180 loc) · 5.29 KB
/
adjac_fft.f95
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
206
207
208
!! NOTE: this file is autogenerated from adjac_fft.f95.in: do not edit manually
module adjac_fft
use adjac
private
public fft, ifft
interface fft
module procedure fft_a, fft_d, fft_b, fft_z
end interface fft
interface ifft
module procedure ifft_a, ifft_d, ifft_b, ifft_z
end interface ifft
type(adjac_double), dimension(:), allocatable :: ch_a
double precision, dimension(:), allocatable :: wa, ch_d
integer, dimension(15) :: ifac
contains
subroutine fft_a(q)
use adjac
implicit none
external :: zffti1, zfftf1
type(adjac_double), dimension(:), contiguous, intent(inout) :: q
integer :: n
n = size(q)/2
if (n.le.1) return
if (.not.allocated(wa) .or. size(wa) .ne. 2*n) then
if (allocated(wa)) deallocate(wa)
allocate(wa(2*n))
call zffti1(n, wa, ifac)
end if
if (.not.allocated(ch_a) .or. size(ch_a) .ne. 2*n) then
if (allocated(ch_a)) deallocate(ch_a)
allocate(ch_a(2*n))
end if
call zfftf1a(n, q, ch_a, wa, ifac)
end subroutine fft_a
subroutine ifft_a(q)
use adjac
implicit none
external :: zffti1, zfftf1
type(adjac_double), dimension(:), contiguous, intent(inout) :: q
integer :: i, n
n = size(q)/2
if (n.le.1) return
if (.not.allocated(wa) .or. size(wa) .ne. 2*n) then
if (allocated(wa)) deallocate(wa)
allocate(wa(2*n))
call zffti1(n, wa, ifac)
end if
if (.not.allocated(ch_a) .or. size(ch_a) .ne. 2*n) then
if (allocated(ch_a)) deallocate(ch_a)
allocate(ch_a(2*n))
end if
call zfftb1a(n, q, ch_a, wa, ifac)
do i = 1, size(q)
q(i) = q(i) / n
end do
end subroutine ifft_a
subroutine fft_d(q)
use adjac
implicit none
external :: zffti1, zfftf1
double precision, dimension(:), contiguous, intent(inout) :: q
integer :: n
n = size(q)/2
if (n.le.1) return
if (.not.allocated(wa) .or. size(wa) .ne. 2*n) then
if (allocated(wa)) deallocate(wa)
allocate(wa(2*n))
call zffti1(n, wa, ifac)
end if
if (.not.allocated(ch_d) .or. size(ch_d) .ne. 2*n) then
if (allocated(ch_d)) deallocate(ch_d)
allocate(ch_d(2*n))
end if
call zfftf1d(n, q, ch_d, wa, ifac)
end subroutine fft_d
subroutine ifft_d(q)
use adjac
implicit none
external :: zffti1, zfftf1
double precision, dimension(:), contiguous, intent(inout) :: q
integer :: i, n
n = size(q)/2
if (n.le.1) return
if (.not.allocated(wa) .or. size(wa) .ne. 2*n) then
if (allocated(wa)) deallocate(wa)
allocate(wa(2*n))
call zffti1(n, wa, ifac)
end if
if (.not.allocated(ch_d) .or. size(ch_d) .ne. 2*n) then
if (allocated(ch_d)) deallocate(ch_d)
allocate(ch_d(2*n))
end if
call zfftb1d(n, q, ch_d, wa, ifac)
do i = 1, size(q)
q(i) = q(i) / n
end do
end subroutine ifft_d
subroutine fft_b(q)
use adjac
implicit none
external :: zffti1, zfftf1
type(adjac_complex), dimension(:), contiguous, intent(inout) :: q
integer :: n
n = size(q)
if (n.le.1) return
if (.not.allocated(wa) .or. size(wa) .ne. 2*n) then
if (allocated(wa)) deallocate(wa)
allocate(wa(2*n))
call zffti1(n, wa, ifac)
end if
if (.not.allocated(ch_a) .or. size(ch_a) .ne. 2*n) then
if (allocated(ch_a)) deallocate(ch_a)
allocate(ch_a(2*n))
end if
call zfftf1a(n, q, ch_a, wa, ifac)
end subroutine fft_b
subroutine ifft_b(q)
use adjac
implicit none
external :: zffti1, zfftf1
type(adjac_complex), dimension(:), contiguous, intent(inout) :: q
integer :: i, n
n = size(q)
if (n.le.1) return
if (.not.allocated(wa) .or. size(wa) .ne. 2*n) then
if (allocated(wa)) deallocate(wa)
allocate(wa(2*n))
call zffti1(n, wa, ifac)
end if
if (.not.allocated(ch_a) .or. size(ch_a) .ne. 2*n) then
if (allocated(ch_a)) deallocate(ch_a)
allocate(ch_a(2*n))
end if
call zfftb1a(n, q, ch_a, wa, ifac)
do i = 1, size(q)
q(i) = q(i) / n
end do
end subroutine ifft_b
subroutine fft_z(q)
use adjac
implicit none
external :: zffti1, zfftf1
complex(kind=kind(0d0)), dimension(:), contiguous, intent(inout) :: q
integer :: n
n = size(q)
if (n.le.1) return
if (.not.allocated(wa) .or. size(wa) .ne. 2*n) then
if (allocated(wa)) deallocate(wa)
allocate(wa(2*n))
call zffti1(n, wa, ifac)
end if
if (.not.allocated(ch_d) .or. size(ch_d) .ne. 2*n) then
if (allocated(ch_d)) deallocate(ch_d)
allocate(ch_d(2*n))
end if
call zfftf1d(n, q, ch_d, wa, ifac)
end subroutine fft_z
subroutine ifft_z(q)
use adjac
implicit none
external :: zffti1, zfftf1
complex(kind=kind(0d0)), dimension(:), contiguous, intent(inout) :: q
integer :: i, n
n = size(q)
if (n.le.1) return
if (.not.allocated(wa) .or. size(wa) .ne. 2*n) then
if (allocated(wa)) deallocate(wa)
allocate(wa(2*n))
call zffti1(n, wa, ifac)
end if
if (.not.allocated(ch_d) .or. size(ch_d) .ne. 2*n) then
if (allocated(ch_d)) deallocate(ch_d)
allocate(ch_d(2*n))
end if
call zfftb1d(n, q, ch_d, wa, ifac)
do i = 1, size(q)
q(i) = q(i) / n
end do
end subroutine ifft_z
end module adjac_fft