The implementation of this method in Fortran algorithms when a Fortran 90 compiler is available is facilitated by the fact that the intrinsic functions and operators can be redefined and overloaded. The implementation has been mostly automated with the help of a script and a module and the procedure is as follows:
python complexify1.3.py *.f.
python complexify1.3.py *.f.
c_
added to the beginning of each file name.complexify.f90
to your makefile and change the original Fortran file names by adding c_
to the beginning of each name.x = cmplx(x, h)
dfdx = aimag(f) / h
Note for SGI compilers: unlike most Fortran 90 compilers the SGI compiler does not allow the re-definition of the .eq.
and .ge.
operators and the complexify.f90
module will not compile.
I am currently trying to convince SGI to change their compilers as I see not good reason for this restriction.
When a Fortran 90 compiler is not available, and since Fortran 77 does not support intrinsic operator or function redefinition, there is no automatic way of implementing the method.
It is, however, still possible to implement the method by writing the new function definitions under different names and changing the function calls to those names.
For example, you would write a function called complex_abs()
and substitute all the calls to abs()
with this one. You also need to change the comparison operations to compare only the real parts of the arguments. The correct function definitions can be found in the complexify.f90 module.