aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: 6e8932b3e59baaabb9ef0645ecdfdb51ecb56181 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#Task solution - fast Fourier transform in fortran (using fftw3)#
This repository contains the realization of the [second task](http://home.agh.edu.pl/~macwozni/fort/zadanie2.pdf) of the fortran programming language course at AGH in Cracov.  

##Directory structure##

    Makefile
    README.md
    make_results.sh
    template.gnuplot
    src/
        fourier.F90
        f1_dft.gnuplot
        f1_original.gnuplot
        f2_dft.gnuplot
        f2_filtered.gnuplot 
        f2_original.gnuplot
    res/
        f1_dft.txt
        f1_original.txt
        f2_dft.txt
        f2_filtered.txt
        f2_original.txt
        f1_dft.png
        f1_original.png
        f2_dft.png
        f2_filtered.png
        f2_original.png

###Makefile###
This file contains recipes for building the fortran program and using to generate plots.   

###src/###
This directory contains the fortran source of the project, namely `fourier.f90` and gnuplot scripts for generating png plots.   

###res/###
This directory contains relevant plots of signals and frequency spectrums as required for the task.   

##Building##
As a prerequisite, fftw3, make and a fortran compiler, either gfortran or ifort, are required (didn't want to support proprietary compiler :c but had to). It is assumed, that include files for fftw3 are installed under `/usr/include`.   
Run:   

    $ make
to build the program executable `fourier`.   
The makefile checks which one of the 2 compilers is present and uses it. Alternatively, one can specify fortran compiler explicitly, e.g.:   

    $ make FC=gfortran
or:   

    $ make FC=ifort

##Running##
The executable is `fourier`. It's mandatory first argument is name of the function to work with - 'f1' or 'f2'. If there're no other arguments - program prints datapoints for plotting the original function. If second argument is 'dft' - program prints datapoints of function's frequency spectrum as obtained from discrete fourier transform. If second argument is 'filtered' - program prints datapoints of filtered function (with frequency components of low values removed).   

     $ ./fourier f2 filtered
     0.0000000000000000         0.99737967443382569
     1.5259021896696422E-005    0.99737363952277114
     3.0518043793392844E-005    0.99736759544407216
     4.5777065690089265E-005    0.99736154219778428
     ⋮
     0.99996948195620661         0.99739772416056849
     0.99998474097810330         0.99739171675277982
     1.0000000000000000         0.99738570017718042

Text files and plots in `res/` can be regenerated by issuing

    $ make pngs

from the main project directory.