NERSCPowering Scientific Discovery Since 1974

FFTW

Description

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)
cc FFTW3Serial1DExample.c
ftn FFTW3Serial1DExample.f  

To compile the sample serial 1-D code with Version 2 use the following:

module load fftw/2.1.5.9    # 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

C source code
Fortran source code

FFTW2 MPI 3D Example

C source code
Fortran source code

FFTW3 Serial 1D Example

C source code
Fortran source code

Differences between FFTW 3 and FFTW 2 source code

FFTW3 MPI Example

MPI is enabled only in FFTW versions 3.3+.   Sample compile line:  "cc  $FFTW -l fftw3_mpi -lfftw3"

C source code

Documentation

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 consult@nersc.gov

Availability at NERSC

PackagePlatformCategoryVersionModuleInstall DateDate Made Default
FFTW babbage libraries/ math 3.3.4-host fftw/3.3.4-host 2014-06-11
FFTW babbage libraries/ math 3.3.4-mic fftw/3.3.4-mic 2014-06-11 2014-06-11
fftw genepool pe_libraries/ math 3.3.3 fftw/3.3.3 2013-09-12 2013-09-12