DFT in Fortran Subroutine

DFT in Fortran Subroutine

ajacobo's picture

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?

1 post / 0 new
For more complete information about compiler optimizations, see our Optimization Notice.