Computational Cluster Programs

How to Use the FFTW Library on ATS-Hosted Clusters

Installed location:

  • FFTW Version 3 is installed in: /u/local/apps/fftw3/current.
  • FFTW Version 2 is installed in: /u/local/apps/fftw2/current.

FFTW Version 2

FFTW Version 2 is a legacy FFTW API. FFTW Version 3 is a major rewrite and the API's are not compatible. FFTW 2 is installed in /u/local/apps/fftw2. If your code already uses this version of the API, you are welcome to use it. All new codes should be written to use FFTW Version 3.

How to run FFTW Version 3 from a C program

In your program include:

#include <fftw3.h>
and call the appropriate fftw3 functions. You may also #include <complex.h> to handle complex numbers.

There are three versions of the fftw3 library depending on precision. The APIs for each differ slightly because of the precision differences:

Precision Library Example Program (FFT of a sine wave)
Double fftw3 fftw3-test.c
Single fftw3f fftw3f-test.c
Long Double fftw3l fftw3l-test.c

To compile and link either enter:

icc pgm.c -I$FFTW3_HOME/include -L$FFTW3_HOME/lib -llib [-static-intel] -o pgm
or:
gcc -std=c99 pgm.c -I$FFTW3_HOME/include -L$FFTW3_HOME/lib -llib -lm [-static] -o pgm
depending upon the compiler you want to use.

Replace pgm.c with the name of the file containing your source code; pgm with the name of the executable to be created; and lib with one of the three fftw3 libraries: fftw3, fftw3f or fftw3l. If you omit -static, you will have to set the LD_LIBRARY_PATH environmen variable at run time to include FFTW_HOME/lib.

Set FFTW3_HOME to be: /u/local/apps/fftw3/current. You can either set an environment variable or replace $FFTW3_HOME in the command shown above.

How to run FFTW Version 3 from a Fortran program

In your program include:

include 'fftw3.f'
and call the appropriate fftw3 functions but note the differences in subroutine names and argument lists for Fortran.

To compile and link enter:

ifort -fr pgm.f90 -I$FFTW3_HOME/include -L$FFTW3_HOME/lib -llib [-static] -o pgm
Replace pgm.f90 with the name of the file containing your source code; pgm with the name of the executable to be created; and lib with one of the three fftw3 libraries: fftw3, fftw3f or fftw3l. If you omit -static, you will have to set the LD_LIBRARY_PATH environmen variable at run time to include FFTW_HOME/lib.

Set FFTW3_HOME to be: /u/local/apps/fftw3/current. You can either set an environment variable or replace $FFTW3_HOME in the command shown above.