FFTW is a C subroutine library for computing the discrete Fourier transform (DFT) in one or more dimensions, of arbitrary input size, and of both real and complex data (as well as of even/odd data, i.e. the discrete cosine/sine transforms).
Both FFTW Version 2 and FFTW Version 3 are available on NERSC systems but there are significant differences between these two versions, as shown below.
NOTE: Version 3 is the default on Edison and Cori.
Differences between Version 2 and Version:
- Different names for include files
- Different names for FFTW routines
- Different arguments for FFTW routines
- Different data structure methods for fftw_complex
- Different approach to plan preparation and execution
Using FFTW on Edison and Cori
Although FFTW is nominally "free" software, highly optimized versions of the libraries are provided by Cray on the NERSC XE6 system. To use:
module load fftw
To see which versions are available:
module avail fftw
A selection of sample codes using FFTW is given in a later section on this web page. Sample compile lines are given below; note that all of these commands work for all of the compiler environments available on Edison and Cori.
To compile the sample serial 1-D code with FFTW version 3 use the following (after the appropriate module load command):
module load fftw (version 3 is the default)
To compile the sample serial 1-D code with Version 2 use the following:
module load fftw/188.8.131.52 # the version number given here is an example
cc FFTW2Serial1DExample.c $FFTW_POST_LINK_OPTS -lfftw
ftn FFTW2Serial1DExample.f $FFTW_POST_LINK_OPTS -lfftw
Those commands work for the arrays declared as either "complex" or "double complex."
To compile the sample MPI 3-D code with Version 2 use:
cc FFTW2MPI3DExample.c $FFTW_POST_LINK_OPTS -ldfftw_mpi -ldfftw
ftn FFTW2MPI3DExample.f $FFTW_POST_LINK_OPTS -ldfftw_mpi -ldfftw
Note that the order of the libraries given on the above command is significant.
FFTW Example Codes
These simple examples demonstrate that (1) not all FFTW routines, which are written in C, have Fortran wrappers; and (2) the Fortran function arguments differ from the C arguments. In particular, the utility to print the plan structure does not have a Fortran wrapper, and the Fortran code example can only give the value of the pointer, not the data in the plan structure.
In addition, there are significant differences between Version 2 and Version 3 of the FFTW library. The data structures are different, the routine names are different, the arguments are different. Conversion of a code from Version 2 to Version 3 will require extensive source code changes.
FFTW2 Serial 1D Example
FFTW2 MPI 3D Example
FFTW3 Serial 1D Example
FFTW3 MPI Example
MPI is enabled only in FFTW versions 3.3+. Sample compile line: "cc $FFTW -l fftw3_mpi -lfftw3"
For the Cray systems the document to look for is the Programming Environment User's Guide. The base document number for this is S–2529. Cray documents are generally of the form S-xxxx-nnn, where nun relates to the release. The June, 2014 release of the Programming Environment User's Guide is S–2529-116. Man pages are available via man fftw and/or man libsci.
General information FFTW is available at fftw.org.
For questions about FFTW on any NERSC systems send e-mail to firstname.lastname@example.org
Availability at NERSC
|Package||Platform||Category||Version||Module||Install Date||Date Made Default|
|fftw fftw cray-fftw||cori||libraries libraries libraries/ math math math||184.108.40.206||fftw/220.127.116.11||2017-03-20|
|fftw fftw||cori||libraries libraries/ math math||18.104.22.168||fftw/22.214.171.124||2016-06-27|
|fftw fftw||cori||libraries libraries/ math math||126.96.36.199||fftw/188.8.131.52||2016-11-11||2016-11-17|
|fftw fftw||cori||libraries libraries/ math math||184.108.40.206||fftw/220.127.116.11||2016-07-13|
|fftw fftw||cori||libraries libraries/ math math||18.104.22.168||fftw/22.214.171.124||2016-06-27|
|fftw fftw||cori||libraries libraries/ math math||126.96.36.199||fftw/188.8.131.52||2016-07-22|
|fftw fftw||edison||libraries libraries/ math math||184.108.40.206||fftw/220.127.116.11||2017-07-21|
|fftw fftw||edison||libraries libraries/ math math||18.104.22.168||fftw/22.214.171.124||2017-07-21|
|fftw fftw||edison||libraries libraries/ math math||126.96.36.199||fftw/188.8.131.52||2017-07-21||2017-07-20|
|fftw fftw||edison||libraries libraries/ math math||184.108.40.206||fftw/220.127.116.11||2017-07-21|