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

FFTW: how to compile and link it?

madsplinter
Beginner
4,247 Views
Hi there,

I wrote a program in fortran that uses the FFTW library but, shame on me, I don't know how to compile and link it!

That's what I've done til now:
I wrote the program, using the command

include fftw3.f

in the declaration part. I suppose I've to put at the beginning of my program something like

use fftw3

but I'm not sure, since I've found no evidence of using that.
Assuming that the program is written correctly, which argument I have to pass to ifort to compile and link it?


Thank you in advance
0 Kudos
2 Replies
TimP
Honored Contributor III
4,247 Views
fftw has specific instructions about how to use it with Fortran, including how to configure it to build the wrappers for ifort. Since fftw is built with a C compiler, the build of fftw itself would use ifort only to get the wrappers right, so it wouldn't matter which options you give there to ifort.
0 Kudos
de-wei-yin
Beginner
4,247 Views
I assume that you have compiled FFTW to include F77 wrappers and that you have read Chapter 6 "Calling FFTW from Fortran" in the FFTW manual.

If you look inside the file fftw3.f, you will see that it contains only integer parameter declarations, so it is a file to be "included"; you cannot compile fftw3.f into a module file and "use" it.

The simplest way to compile a Fortran program and statically link the FFTW library is to issue a command like this:

ifort -o test-fftw3 test-fftw3.f90 -L/usr/local/lib -lfftw3

where -L gives ifort the path that allows it to find libfftw3.a (change this if your FFTW is not installed in /usr/local/lib), and -lfftw3 tells ifort to link libfftw3.a into your program. Note that libfftw3.a is the double-precision FFTW library; if you need the single-precision FFTW library, specify -lfftw3f for libfftw3f.a . Both single- and double-precision FFTW libraries can be linked into the same program if both are needed. You can add other compiler flags; the above is the minimum.

It seems to me in your post that you might also have problems calling FFTW in your Fortran program. You will need to read and understand Chapter 6 in the FFTW manual, and if you know how to program in C, read Chapter 2 before you read Chapter 6. Post back if you have a specific question.

I have used FFTW 3.1 with ifort 9.1.040 and it does work. I haven't used FFTW 3.1.2 with ifort 9.1.040 (the latest versions for both) but I would expect it to work too.


0 Kudos
Reply