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

DFT in Fortran Subroutine

ajacobo
Beginner
531 Views
I've the following fortran code:

PROGRAM test
Use MKL_DFTI

IMPLICIT NONE
INTEGER, PARAMETER :: ngp=512
COMPLEX(16) A(ngp)
INTEGER i

DO i=1, ngp
A(i)=i
ENDDO

DO i=1,100
CALL transform(A,ngp)
ENDDO

END

!=============================================================================

SUBROUTINE transform(A, ngp)
Use MKL_DFTI
IMPLICIT NONE

INTEGER :: ngp
COMPLEX*16 A(ngp)
type(DFTI_DESCRIPTOR), POINTER :: punt
INTEGER status
status=DftiCreateDescriptor(punt,DFTI_DOUBLE,DFTI_COMPLEX,1,ngp)
status=DftiCommitDescriptor(punt)

status=DftiComputeForward(punt,A)
status=DftiComputeBackward(punt,A)
A=A/ngp
status = DftiFreeDescriptor(punt)
END

If instead of doing this I create and commit the descriptor in the main program, and then I pass the pointer "punt" to the subroutine I get a Segmentation Fault. Is there any way to create the descriptor just once in the program and use it every time I call the subroutine? or is this the only way to do it?
0 Kudos
0 Replies
Reply