How to install FFTW3 for FORTRAN (Windows) ?

How to install FFTW3 for FORTRAN (Windows) ?

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.

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
Best Reply

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
--------------

Thank you very much. It works very well. You are a life saver.

Quote:

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!

Leave a Comment

Please sign in to add a comment. Not a member? Join today