Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

How to install FFTW3 for FORTRAN (Windows) ?

sawado
Beginner
2,664 Views
Hi everybody,

I have some trouble with the installation of FFTW3 on Windows. I did what they said (http://www.fftw.org/install/windows.html) but it not working. Where should I put the DLLs or Lib files? How can I call the subroutines in Fortran? How can I link those subroutines to my Fortran program(on command line with ifort 9.1 or in Visual Studio 2005) ? Please, help me. I have been trying for few days.
0 Kudos
1 Solution
mecej4
Honored Contributor III
2,664 Views
FFTW3 is written in C and is most easily called from C. It is designed to be callable from Fortran, but the details depend on the Fortran compiler used, and they expect the user to know how to call C-libraries from Fortran.

Intel Fortran 11.1 (the current version) comes with the MKL and FFTW libraries, along with examples. Here is how to compile one of the examples and link with the DLLs from the FFTW site, without using MKL:

1) As prescribed by FFTW3, build the import libraries using the .def files provided.

2) Copy the example source files to a working directory. I used real_1d_double_ex2.f mkl_fftw_examples_support.f from the Intel MKL distribution. I used the include file fftw3.f (renamed to fftw3.fi).

3) Build the example:

ifort /Qfpp /Qlowercase /us real_1d_double_ex2.f mkl_fftw_examples_support.f libfftw3-3.lib

The options used are (i) /Qfpp, to use the preprocessor, (ii) /Qlowercase /us to be compatible with the conventions used by FFTW3

4) Run the example:

real_1d_double_ex2

--------------
Initialize data array
Create FFTW plan for 1D real to complex transform
Compute 1D real to complex transform
Destroy FFTW plan
Create FFTW plan for 1D complex to real transform
Compute 1D complex to real transform
Destroy FFTW plan
Scale result by 1/N
Check results
Accuracy= 3.330669073875470E-016
TEST PASSED
END OF TEST
--------------

View solution in original post

0 Kudos
3 Replies
mecej4
Honored Contributor III
2,665 Views
FFTW3 is written in C and is most easily called from C. It is designed to be callable from Fortran, but the details depend on the Fortran compiler used, and they expect the user to know how to call C-libraries from Fortran.

Intel Fortran 11.1 (the current version) comes with the MKL and FFTW libraries, along with examples. Here is how to compile one of the examples and link with the DLLs from the FFTW site, without using MKL:

1) As prescribed by FFTW3, build the import libraries using the .def files provided.

2) Copy the example source files to a working directory. I used real_1d_double_ex2.f mkl_fftw_examples_support.f from the Intel MKL distribution. I used the include file fftw3.f (renamed to fftw3.fi).

3) Build the example:

ifort /Qfpp /Qlowercase /us real_1d_double_ex2.f mkl_fftw_examples_support.f libfftw3-3.lib

The options used are (i) /Qfpp, to use the preprocessor, (ii) /Qlowercase /us to be compatible with the conventions used by FFTW3

4) Run the example:

real_1d_double_ex2

--------------
Initialize data array
Create FFTW plan for 1D real to complex transform
Compute 1D real to complex transform
Destroy FFTW plan
Create FFTW plan for 1D complex to real transform
Compute 1D complex to real transform
Destroy FFTW plan
Scale result by 1/N
Check results
Accuracy= 3.330669073875470E-016
TEST PASSED
END OF TEST
--------------
0 Kudos
sawado
Beginner
2,664 Views
Thank you very much. It works very well. You are a life saver.
0 Kudos
Baofeng_c_
Beginner
2,664 Views

mecej4 wrote:

FFTW3 is written in C and is most easily called from C. It is designed to be callable from Fortran, but the details depend on the Fortran compiler used, and they expect the user to know how to call C-libraries from Fortran.

Intel Fortran 11.1 (the current version) comes with the MKL and FFTW libraries, along with examples. Here is how to compile one of the examples and link with the DLLs from the FFTW site, without using MKL:

1) As prescribed by FFTW3, build the import libraries using the .def files provided.

2) Copy the example source files to a working directory. I used real_1d_double_ex2.f mkl_fftw_examples_support.f from the Intel MKL distribution. I used the include file fftw3.f (renamed to fftw3.fi).

3) Build the example:

ifort /Qfpp /Qlowercase /us real_1d_double_ex2.f mkl_fftw_examples_support.f libfftw3-3.lib

The options used are (i) /Qfpp, to use the preprocessor, (ii) /Qlowercase /us to be compatible with the conventions used by FFTW3

4) Run the example:

real_1d_double_ex2

--------------
Initialize data array
Create FFTW plan for 1D real to complex transform
Compute 1D real to complex transform
Destroy FFTW plan
Create FFTW plan for 1D complex to real transform
Compute 1D complex to real transform
Destroy FFTW plan
Scale result by 1/N
Check results
Accuracy= 3.330669073875470E-016
TEST PASSED
END OF TEST
--------------

Hi mecej4,

I just had the same problem when I'm trying to use FFTW library in my Fortran (visual studio 2008, intel fortran), I got unresolved error too. Fortunately, I followed your instruction and solved my problem. However, I'm wondering is there any equivalent method to run it through visual studio rather than build and run in command line? When I try to build this example in visual studio, I still got that "unsolved" error. It seems like it didn't link libfftw3-3.lib properly, but I don't know how to fix this. What I did is like this:

the path of my lib in Additional Include Directories under Fortran General
the path of my lib in AdditionalLibrary DirectoriesunderLinker General
the name libfftw3-3.lib in Additional Dependencies in Linker Input

Any sugesstions?Thanks!

0 Kudos
Reply