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

'mkl_dfti.f90' module error

Erik_T_1
Novice
2,867 Views

I am trying to use intel mkl dft routines under windows/visual studio.
Running intel mkl DGEMM routine presents no problem (hence automatic linking via seems to work). My problem is when I include 'mkl_dfti.f90', in order to "use mkl_dfti" . That produces the error:

..\mkl_dfti.f90(27): error #6218: This statement is positioned incorrectly and/or has syntax errors.

and that points to the first line with code in mkl_dfti.f90

MODULE MKL_DFT_TYPE

Here is my full code:

  module mymodule
  use iso_c_binding
  INCLUDE 'mkl_dfti.f90'
  Use MKL_DFTI
  implicit none
  type(DFTI_DESCRIPTOR),POINTER :: My_Desc_Handle

  contains

  subroutine prepareMKLfft(nfft)
  integer(C_INT),intent(in)                 ::  nfft
  integer,parameter                         ::  fftdimension = 1
  Integer                                   :: Status
  Status = DftiCreateDescriptor( My_Desc_Handle, DFTI_DOUBLE, DFTI_COMPLEX, fftdimension, nfft )
  Status = DftiSetValue( My_Desc_Handle, DFTI_PLACEMENT, DFTI_NOT_INPLACE)
  Status = DftiCommitDescriptor( My_Desc_Handle )
  end subroutine prepareMKLfft

  subroutine finishMKLfft()
  Integer                                   :: Status
  Status = DftiFreeDescriptor(My_Desc1_Handle)
  end subroutine finishMKLfft

  subroutine fft(X_in,X_out,nfft)
  ! From: https://software.intel.com/en-us/mkl-developer-reference-fortran-fft-code-examples
  integer(C_INT),intent(in)                 ::  nfft
  complex(C_DOUBLE_COMPLEX),intent(in)      ::  X_in(:)
  complex(C_DOUBLE_COMPLEX),intent(out)     ::  X_out(:)
  Integer                                   :: Status
  Status = DftiComputeForward( My_Desc1_Handle, X_in, X_out )
  end subroutine fft

  subroutine ifft(X_in,X_out,nfft)
  integer(C_INT),intent(in)                 ::  nfft
  complex(C_DOUBLE_COMPLEX),intent(in)      ::  X_in(:)
  complex(C_DOUBLE_COMPLEX),intent(out)     ::  X_out(:)
  Integer                                   :: Status
  Status = DftiComputeBackward( My_Desc1_Handle, X_in, X_out )
  end subroutine fft

  end module mymodule

 

Does anyone know the answer to this? Help is very much appreciated.

(windows 7, visual studio 2013, intel parallel studio xe 2016 cluster edition update 3)

0 Kudos
1 Solution
Ying_H_Intel
Employee
2,867 Views

Right, please keep the mkl_dfti.f90 was compiles separately.  For example,  the quick-and-dirty solution may to remove the INCLUDE 'mkl_dfti.f90' line from your source code,  to copy the mkl_dfti.f90 file to the source directory and add it in the your current Project.

Best Regards,
Ying

 

View solution in original post

0 Kudos
3 Replies
mecej4
Honored Contributor III
2,867 Views

The file mkl_dfti.f90 starts with "MODULE.." as the first non-comment line and ends with "END Module". It contains the source code of one or more modules, and is to be compiled before, and separately from, any other source file that USEs it. It is not suitable for INCLUDE inside any other program unit. 

In other words, compile mkl_dfti.f90 separately, and remove the INCLUDE 'mkl_dfti.f90' line from your source code.

0 Kudos
Ying_H_Intel
Employee
2,868 Views

Right, please keep the mkl_dfti.f90 was compiles separately.  For example,  the quick-and-dirty solution may to remove the INCLUDE 'mkl_dfti.f90' line from your source code,  to copy the mkl_dfti.f90 file to the source directory and add it in the your current Project.

Best Regards,
Ying

 

0 Kudos
Erik_T_1
Novice
2,867 Views

Thank you very much Ying! That did it.

0 Kudos
Reply