Numerical Computing with Modern FortranRichard J. Hanson and Tim Hopkins |
Chapter 16: Modifying Source to Remove Obsolescent or Deleted Features
Source Code:
These are examples that illustrate a 'before' and 'after' version of a one-dimensional Newton method code for solving an equation f(x)=0. The before version, test.f, has statement labels and uses a withdrawn feature of Fortran, alternate return subprogram arguments. These implement reverse communication. This constuct provides the function and derivative values required by Newton's method.
The after version, test2.f90, uses the same logic as test.f, but has removed the alternate returns and the statement labels. In their place is a select case construct based on an additional integer flag.
Two executables may be generated using the makefile
- test uses test.f
- test2 uses test2.f90
Sample output from test
Solution and absolute error: 0.9000E+00 0.5960E-07
Sample output from test2
Solution and absolute error: 0.9000E+00 0.5960E-07