Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

Transformed Values are not correct - MKL FFT Fortran Linux

Giri_Ajay__Adhyanth
995 Views

Hello!

I was trying to learn about the MKL's FFT Function and wrote a small 1D program to show the forward transformed values. From my understanding, the arguments for the forward function - mentioned in the comment in the program (italicised and not in bold) - should be right and it should perform fine. 

When I try to run this, I get 0 as my transformed value (the array y1). Now I am confused about why that happens and what the error in the code is for me to get this error. 

Could someone help me to understand the issue? 

I am attaching the program file(test.f90), the executable link file (link1.txt - might have to use chmod 700) and the output text file (text.txt).

Thanks!

- Adhyanth

PROGRAM test
!   IMPLICIT NONE
   USE MKL_DFTI
   REAL(KIND = DFTI_DPKP), DIMENSION(201) :: x,y,z
   COMPLEX(KIND = DFTI_DPKP), DIMENSION(201) ::x1, y1
   INTEGER :: i, status
   TYPE(DFTI_DESCRIPTOR), POINTER :: plan
   plan => null()
DO i=1,201
   x(i) = REAL(i-101)/100
   y(i)= 5*SIN(2*x(i))
END DO

OPEN(9, file='text.txt', form = 'FORMATTED')
WRITE(9,*) 'Y values'
WRITE(9,*) y
status = dfti_create_descriptor_1d(plan, DFTI_DOUBLE, DFTI_COMPLEX, 1, 200)
status = dfti_commit_descriptor_external(plan)
DO i=1,201
status = dfti_compute_forward_dz(plan, y(i), y1(i))

!Using the(desc,xreinout,ximinout) argument format
ENDDO
status = dfti_free_descriptor_external(plan)
WRITE(9,*) 'Y1 Values'
WRITE(9,*) y1
WRITE(9,*) 'Y values - After Transform'
WRITE(9,*) y

END PROGRAM test

0 Kudos
1 Solution
Khang_N_Intel
Employee
995 Views

Hi Adhyanth,

You are trying to do the R2C out-of-place transform.  However, you are not setting the right parameter values.

DftiSetValue(plan, DFTI_PLACEMENT, DFTI_NOT_INPLACE)

Also, you call the Fortran function directly

dfti_compute_forward_dz(plan, y, y1)

You should call the interface, instead.

Please look at the example basic_dp_real_dft_1d.f90 in the examples folder.

Hope this helps!

Khang

View solution in original post

0 Kudos
5 Replies
Khang_N_Intel
Employee
996 Views

Hi Adhyanth,

You are trying to do the R2C out-of-place transform.  However, you are not setting the right parameter values.

DftiSetValue(plan, DFTI_PLACEMENT, DFTI_NOT_INPLACE)

Also, you call the Fortran function directly

dfti_compute_forward_dz(plan, y, y1)

You should call the interface, instead.

Please look at the example basic_dp_real_dft_1d.f90 in the examples folder.

Hope this helps!

Khang

0 Kudos
Giri_Ajay__Adhyanth
995 Views

Hi Khang,

The code worked now. Thanks a ton!

- Adhyanth

0 Kudos
Khang_N_Intel
Employee
995 Views

Hi dhyanth,

I am glad that you find it helpful.

Khang

0 Kudos
Khang_N_Intel
Employee
995 Views

Hi Adhyanth,

I apologize for typing you name incorrectly.

Khang

0 Kudos
Giri_Ajay__Adhyanth
995 Views

Hey Khang,

No worries.

- Adhyanth

0 Kudos
Reply