fft_obj_Final Subroutine

private impure subroutine fft_obj_Final(this)

Finalizes object and frees memory.

Type Bound

fft_obj

Arguments

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

A FFT object


Calls

proc~~fft_obj_final~~CallsGraph proc~fft_obj_final fft_obj%fft_obj_Final interface~fftw_destroy_plan fftw_destroy_plan proc~fft_obj_final->interface~fftw_destroy_plan interface~fftw_free fftw_free proc~fft_obj_final->interface~fftw_free

Source Code

    impure subroutine fft_obj_Final(this)
      !> Finalizes object and frees memory.
      implicit none
      class(fft_obj), intent(inout) :: this                                    !! A FFT object
      ! Work variables
      integer :: dir

      do dir=1,3
        if (c_associated(this%plan_f(dir))) then
          call fftw_destroy_plan(this%plan_f(dir))
          this%plan_f(dir) = C_NULL_PTR
        end if

        if (c_associated(this%plan_b(dir))) then
          call fftw_destroy_plan(this%plan_b(dir))
          this%plan_b(dir) = C_NULL_PTR
        end if

        if (c_associated(this%p_in(dir))) then
          call fftw_free(this%p_in(dir))
          this%p_in(dir) = C_NULL_PTR
        end if

        if (c_associated(this%p_out(dir))) then
          call fftw_free(this%p_out(dir))
          this%p_out(dir) = C_NULL_PTR
        end if
      end do

      ! Nullify pointers
      this%parallel => null()
      this%block    => null()
      do dir=1,3
        this%buffers(dir)%in  => null()
        this%buffers(dir)%out => null()
      end do

      if (allocated(this%s_counts)) deallocate(this%s_counts)
      if (allocated(this%s_displs)) deallocate(this%s_displs)
      if (allocated(this%s_ptr   )) deallocate(this%s_ptr   )
      if (allocated(this%r_counts)) deallocate(this%r_counts)
      if (allocated(this%r_displs)) deallocate(this%r_displs)
      if (allocated(this%r_ptr   )) deallocate(this%r_ptr   )

      ! Reset default
      this%fft_dir    = .false.
      this%contig_dir = 0

      return
    end subroutine fft_obj_Final