The program root_search.f90 finds the roots of a function by bisection.
It is composed by:
module rootfinding.f90 | It contains the subroutine bisect. Subroutines for root searching with other methods could be added here |
module functions.f90 | It contains the function f=x^2-5. Other functions could be added |
main program zero_of_f.f90 |
Read interval where the root occurs and the desired tolerance from file
root_search.inp. Calls the subroutine bisect and writes results to file root_search.out Reading the input from an external file avoids recompiling the program. It is good practice to write the input data in the output file. |
Since modules can be used by different main programs they can be stored separately and compiled together by use of makefile and the command make.