Note
Subroutine that transforms forward or backward a double complex array. For speed reasons FFTW will always work on the same memory area, until the plans are destroyed of course. 1 FFT distributed on several threads
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=I4), | intent(in) | :: | sens |
|
||
complex(kind=R8), | intent(in), | dimension(1:long, 1:larg) | :: | tab_in |
array to transform |
|
complex(kind=R8), | intent(out), | dimension(1:long, 1:larg) | :: | tab_ou |
transformed array |
|
integer(kind=I4), | intent(in) | :: | long |
first 2D array dimension |
||
integer(kind=I4), | intent(in) | :: | larg |
second 2D array dimension |
subroutine calc_fftw3(sens, tab_in, tab_ou, long, larg) implicit none integer(kind=I4), intent(in ) :: sens !! *```=FORWARD``` or ```=BACKWARD```* integer(kind=I4), intent(in ) :: long !! *first 2D array dimension* integer(kind=I4), intent(in ) :: larg !! *second 2D array dimension* complex(kind=R8), dimension(1:long, 1:larg), intent(in ) :: tab_in !! *array to transform* complex(kind=R8), dimension(1:long, 1:larg), intent(out) :: tab_ou !! *transformed array* if ( any( FFT_DIM(1:2) /= [long, larg] ) ) then if ( sum(FFT_DIM(1:2)) /= 0 ) call end_fftw3() call fftw_plan_with_nthreads(nthreads = omp_get_num_procs()) call init_fftw3(long = long, larg = larg) endif select case(sens) case(FORWARD) cmp_f_i(1:long, 1:larg) = tab_in(1:long, 1:larg) call fftw_execute_dft(plan_f, cmp_f_i(1:long, 1:larg), cmp_f_o(1:long, 1:larg)) tab_ou(1:long, 1:larg) = cmp_f_o(1:long, 1:larg)/sqrt(real(long*larg, kind=r8)) case(BACKWARD) cmp_f_i(1:long, 1:larg) = tab_in(1:long, 1:larg) call fftw_execute_dft(plan_b, cmp_f_i(1:long, 1:larg), cmp_f_o(1:long, 1:larg)) tab_ou(1:long, 1:larg) = cmp_f_o(1:long, 1:larg)/sqrt(real(long*larg, kind=r8)) endselect return endsubroutine calc_fftw3