[Fortran] syntaxhighlighter_viewsource syntaxhighlighter_copycode
    program TEST_FFTwithMatlab
    USE MKL_DFTI
    IMPLICIT NONE
    INTEGER*4::X_in_Len = 7
    COMPLEX*8::X_in(7)
    INTEGER*4::Dim=1,X_Len,Status,i
    REAL*8,DIMENSION(7)::a,b
    COMPLEX*8,DIMENSION(:),ALLOCATABLE::X_inout
    Type(DFTI_DESCRIPTOR), POINTER :: Desc_handle
    !------1
    X_Len = 7
    if(allocated(X_inout)) deallocate(X_inout)
    Allocate(X_inout(X_Len))
    a = (/0.34907d0,0.54890d0,0.74776d0,0.94459d0,1.13850d0,1.32850d0,1.51370d0/)
    b = 0d0
    X_inout = CMPLX(a,b)
    !------2
    !------fft 
    X_in(1)=(0.34907D0,0D0)
    X_in(2)=(0.54890D0,0D0)
    X_in(3)=(0.74776D0,0D0)
    X_in(4)=(0.94459D0,0D0)
    X_in(5)=(1.13850D0,0D0)
    X_in(6)=(1.32850D0,0D0)
    X_in(7)=(1.51370D0,0D0)
    do i=1,7
        print*, X_in(i)
    end do
    Status = DftiCreateDescriptor (Desc_handle, DFTI_DOUBLE, DFTI_COMPLEX, Dim, X_Len)
    !Status = DftiGetValue(Desc_handle, DFTI_placement)
    !Status = DftiGetValue(Desc_handle, DFTI_Forward_Scale)
    Status = DftiSetValue(Desc_handle, DFTI_placement, dfti_inplace)
    Status = DftiCommitDescriptor (Desc_handle)
    Status = DftiComputeForward(Desc_handle, X_in)
    Status = DftiFreeDescriptor(Desc_handle)
    if (Status .ne. 0) then
        if (.not. DftiErrorClass(status,DFTI_NO_ERROR)) then
            print *, 'Error: ', Status, DftiErrorMessage(Status)
        endif
    endif
    !------ifft   
    PRINT *,X_in
    X_in(1)=(0.34907D0,0D0)
    X_in(2)=(0.54890D0,0D0)
    X_in(3)=(0.74776D0,0D0)
    X_in(4)=(0.94459D0,0D0)
    X_in(5)=(1.13850D0,0D0)
    X_in(6)=(1.32850D0,0D0)
    X_in(7)=(1.51370D0,0D0)
    do i=1,7
        print*, X_in(i)
    end do 
    Status = DftiCreateDescriptor(Desc_handle, DFTI_DOUBLE, DFTI_COMPLEX, Dim, X_Len)
    Status = DftiSetValue(Desc_handle, DFTI_BACKWARD_SCALE, 1.0d0/X_Len)
    Status = DftiSetValue(Desc_handle, DFTI_placement, dfti_inplace)
    Status = DftiCommitDescriptor (Desc_handle)
    Status = DftiComputeBackward(Desc_handle, X_in)  !720,1
    Status = DftiFreeDescriptor(Desc_handle)
    if (Status .ne. 0) then
        if (.not. DftiErrorClass(status,DFTI_NO_ERROR)) then
            print *, 'Error: ', Status, DftiErrorMessage(Status)
        endif
    endif
    PRINT *,X_in/X_Len
    END PROGRAM