aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: 6ae881a5574044811744876563f0c306fea5141e (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
#Task solution - numerical integration in fortran#
This repository contains the realization of the [third task](http://home.agh.edu.pl/~macwozni/fort/zadanie3.pdf) of the fortran programming language course at AGH in Cracov.  

##Directory structure##

    Makefile
    README.md
    run.sh
    measure_times.sh
    src/
        functions.f90
        quadratures.f90
        main.f90
    res/
        1image_results
        5images_results
        times

###Makefile###
This file contains recipes for building the fortran program and using it to generate files in `res/`.   

###run.sh###
This scripts is called from `Makefile` to compute numerical integrals of some example functions using different quadratures and numbers of integration subintervals. The script uses `./integral`'s output to create `res/1image_results` and `res/5images_results`.   

###measure_times.sh###
Another script, used in `Makefile` to measure computation speed with different numbers of images and write the results to `res/times`.   

###src/###
This directory contains the fortran sources of the project.   

###res/###
This directory contains result data files with running times of the program and computed integrals with their errors.   

##Building##
As a prerequisite, make, gfortran and opencoarrays are required (I already have my grade, so I didn't do ifort 🙃).   
Run   

    $ make
to build the program executables `integrator` and `integrator_single` (compiled with -fcoarray=single instead of lib).   

##Running##
The executables are `integrator` and `integrator_single`. The first expected argument is '_analytical_' for analytically computed integral or quadrature type ('_newton-cotes_' or '_gauss_') for numerical integral. Second argument is function to be integrated  - '_exp_', '_sin_' or '_poly_' (which is some 10 degree polynomial I made up). Third and fourth arguments are start and end of integration interval. Fifth arg is polynomial order (explained later in this README) and and sixth is the number of subintervals. Arguments 5 and 6 are only needed for numerical integrals.   
To run a multi-image version:   

     $ cafrun -np IMAGES_NUMBER ./integrator ARGUMENTS
For a single image execution:   

     $ ./integrator_single ARGUMENTS
Examples:   

     $ ./integrator_single analytical exp 0 1 
     1.7182818284590451
     $ cafrun -np 3 ./integrator gauss exp 0 1 2 1000000
     1.71828182845905E+00  2.22044604925031E-16
The small second number of the output is the absolute difference between numerically and analytically computed integrals (numerical error).   

Data in `res/` can be regenerated by issuing   

    $ make results

from the main project directory.   

##Numerical integration##
TODO