FIXME : Add documentation DD>Reinstating after discussion with RN, if this causes anyone an issue
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real, | intent(in) | :: | phixf(:,:) | |||
complex, | intent(out) | :: | phi(:,:) | |||
integer, | intent(in) | :: | nny | |||
integer, | intent(in) | :: | nnx |
subroutine inverse2_2d (phixf, phi, nny, nnx)
use fft_work, only: FFT_TO_SPECTRAL_SPACE, delete_fft, init_rcfftw
use kt_grids, only: naky, nakx => ntheta0, aky
use job_manage, only: time_message
use fft_work, only: time_fft
implicit none
real, intent(in) :: phixf(:,:)
complex, intent(out) :: phi(:,:)
integer, intent(in) :: nnx, nny
complex, allocatable :: aphi(:,:)
real, allocatable :: phix(:,:)
real :: fac
integer :: ik, it
type (fft_type) :: xf2d
!May be inefficient to create and destroy this fft plan
!on every call to the routine. We may want to move this
!variable to module level and check its created flag.
#if FFT == _FFTW3_
call init_rcfftw (xf2d, FFT_TO_SPECTRAL_SPACE, nny, nnx, 1)
#endif
allocate (aphi (nny/2+1, nnx))
allocate (phix (nny, nnx))
phix(:,:)=0.; aphi(:,:)=cmplx(0.,0.)
phix(:,:)=transpose(phixf(:,:))
! transform
call time_message(.false., time_fft, ' FFT')
#if FFT == _FFTW3_
call FFTW_PREFIX(_execute_dft_r2c) (xf2d%plan, phix, aphi)
#endif
call time_message(.false., time_fft, ' FFT')
! scale, dealias and transpose
do it=1,nakx
do ik=1,naky
fac = 2.0
if (aky(ik) < epsilon(0.0)) fac = 1.0
phi(it,ik) = aphi(ik,it)*fac*xf2d%scale
end do
end do
deallocate (aphi, phix)
!RN> this statement causes error for lahey with DEBUG. I don't know why
!<DD>Reinstating after discussion with RN, if this causes anyone an issue
! then we can guard this line with some directives.
call delete_fft(xf2d)
end subroutine inverse2_2d