Reputation: 507
As the documentation says that fftw3
plan can be reused with different values if the array remains same. I'm using the following statement to create the plan p
in Fortran.
call dfftw_plan_dft_r2c_1d(plan,N,fin,fout,FFTW_ESTIMATE)
However, the above statement is used through a subroutine away from the main program and will be repeatedly called with different values of fin
with the same size. My present strategy is as follows:
subroutine fft_forward(fin,fout)
implicit none
integer(8),save :: plan
integer,save :: first=0
double precision,dimension(:) :: fin
double complex,dimension(:) :: fout
integer :: N
N = size(fin)
if (first == 0) then
call dfftw_plan_dft_r2c_1d(plan,N,fin,fout,FFTW_ESTIMATE)
first = 1
endif
call dfftw_execute_dft_r2c(plan,fin,fout)
...
...
end subroutine
Is the right way to do? I'm confused about saving the variable plan
during repeated calling of the subroutine.
Upvotes: 0
Views: 38