fft_obj_SetFFTDirections Subroutine

private impure subroutine fft_obj_SetFFTDirections(this, dir_flag)

Sets the FFT directions.

Type Bound

fft_obj

Arguments

Type IntentOptional Attributes Name
class(fft_obj), intent(inout) :: this

A FFT object

logical, intent(in) :: dir_flag(3)

FFT directions


Calls

proc~~fft_obj_setfftdirections~~CallsGraph proc~fft_obj_setfftdirections fft_obj%fft_obj_SetFFTDirections interface~fftw_alloc_real fftw_alloc_real proc~fft_obj_setfftdirections->interface~fftw_alloc_real interface~fftw_plan_r2r_1d fftw_plan_r2r_1d proc~fft_obj_setfftdirections->interface~fftw_plan_r2r_1d

Source Code

    impure subroutine fft_obj_SetFFTDirections(this,dir_flag)
      !> Sets the FFT directions.
      implicit none
      class(fft_obj), intent(inout) :: this                                    !! A FFT object
      logical,        intent(in)    :: dir_flag(3)                             !! FFT directions
      ! Work variables
      integer :: dir

      this%fft_dir = dir_flag

      ! Now check that these directions are in fact periodic
      do dir=1,3
        if (this%fft_dir(dir).and. (.not.this%block%periods(dir))) &
            call this%parallel%Stop('FFT in requested directions requires these directions to be periodic')
      end do

      ! Ensure that fft directions have even number of grid points
      associate (lo=>this%block%lo, hi =>this%block%hi, Ng => this%Ng)
        do dir=1,3
          if (this%fft_dir(dir).and. mod(Ng(dir),2).ne. 0) &
            call this%parallel%Stop('FFT requires an even number of grid points in the FFT directions')
        end do
      end associate

      ! Allocate buffers and define plans
      do dir=1,3
        if (this%fft_dir(dir)) then
          this%p_in(dir)  = fftw_alloc_real(int(this%Ng(dir),C_SIZE_T))
          this%p_out(dir) = fftw_alloc_real(int(this%Ng(dir),C_SIZE_T))
          call c_f_pointer(this%p_in(dir),  this%buffers(dir)%in,  [this%Ng(dir)])
          call c_f_pointer(this%p_out(dir), this%buffers(dir)%out, [this%Ng(dir)])

          this%plan_f(dir) = fftw_plan_r2r_1d(this%Ng(dir), this%buffers(dir)%in, this%buffers(dir)%out, FFTW_R2HC, FFTW_MEASURE)
          this%plan_b(dir) = fftw_plan_r2r_1d(this%Ng(dir), this%buffers(dir)%in, this%buffers(dir)%out, FFTW_HC2R, FFTW_MEASURE)
        end if
      end do

      return
    end subroutine fft_obj_SetFFTDirections