Discretized Fourier Transform of Arbitrary Signal Using FFTW3 Datapath
The plan here is to write a Fortran 2003 program that utilizes the FFTW3 library to generate a
Discretized Fast Fourier Transforms of arbitrary waveforms. To test the code we start with a
function whose DFFT is easily identifiable by inspection. SciLAB is used to generate the
the time domain function, time domain and frequency domain plots and discretized time domain data.
The Fortran 2003 code is then run on the discretized time domain data and the results plotted
with GNUPlot. A comparison is made to check the veracity of the Fortran 2003 code output.
Since the output of SciLAB is a comma separated value (CSV) file, a method is needed that will process
that file into another file, where the commas are removed and each data element is on a separate line.
This is most easily done using a Python script, with its powerful object-oriented file techniques and
its included CSV library. Additionaly, each data element is reformatted so that it is in fixed floating-point
format, with a decimal precision of 20 places. This is done so that the Fortran DFFT code can process
the data error-free. The Python script is shown below:
Processing of CSV file by Python script to strip commas and produce one data element per line
Python script that removes commas and produced one data element per line
Run by typing: ./convert_csv.py infile.csv outfile.dat
where infile.csv is the data file in CSV format, and outfile.dat is the processed file
Obtain the line count of the processed file by typing: wc -l outfile.dat
After the CSV file is processed into a suitable format, the following Fortran 2003 code is executed on it.
The Fortran 2003 code reads in the processed data and outputs the DFFT magnitude and phase, using the FFTW3
Fortran 2003 Code
Fortran 2003 Code to Perform Discretized Fast Fourier Transform on Processed File
Fortran 2003 code that takes in parameters and performs DFFT to generate output file
Compile by typing: gfortran -o a.out data_file_FFTW.F03 -lfftw3
Run by typing: ./a.out outfile.dat DFFT_mag_file.dat DFFT_phase_file.dat
where outfile.dat is the output of the Python script, DFFT_mag_file.dat is the DFFT magnitude
DFFT_phase_file.dat is the DFFT phase (if applicable)
The line count can be obtained by typing: wc -l outfile.dat