Next: Linking
Up: Fortran in Practice
Previous: INCLUDE Statements
The main function of a Fortran compiler is to read a set of source
files and write the corresponding set of object modules to the
object file.
Most compilers have a number of switches or options which can
be set to control how the compiler works and what additional
output it produces. Some of the more useful ones, found on many
systems, are described below.
- Almost all compilers can produce a listing file: a text file
containing a copy of the source code, with the lines numbered, and
with error messages and other useful information attached. A list
of all the symbolic names and labels used in the program unit is
often provided: this should be checked for unexpected entries as
they may be the result of spelling mistakes.
- An even more useful addition to the listing is a cross-reference
table: this lists every place that each symbolic name has
been used. Good compilers indicate which names have only been
used once as these often indicate a programming mistake.
- Another widely available option is the detection of syntax
which does not conform to the Fortran Standard: this helps to
ensure program portability.
- Often it is possible to choose the optimization level. During
program development a low level of optimization should be
selected if this makes the compiler run faster; it may improve the
error detection. Highly optimised machine code may execute
faster but if the source code lines are rearranged error messages
may be less helpful.
- Many systems allow additional code to be included which
check for errors at run-time. Errors such as over-running the
bounds of an array or a character string, or arithmetic over-flow
can usually be trapped. Such errors are not uncommon, so this
assistance is very valuable. Some programming manuals suggest
that these options should only be selected during program
development and switched-off thereafter in the interests of speed.
This is rather like wearing seat-belts in the car only while you are
learning to drive and ignoring them as soon as you are allowed out
on the motorway. Run-time checks do not usually reduce the
execution speed noticeably.
Next: Linking
Up: Fortran in Practice
Previous: INCLUDE Statements
Helen Rowlands
8/27/1998