It has been estimated that about 90% of the time it takes to develop commercial software is spent debugging and testing. This shows how important it is to write good code in the first place.
Still, we all discover bugs from time to time. Here are some hints for how to track them down.
Most Fortran compilers will have a set of options you can turn on if you like. The following compiler options are specific to the Sun Fortran 77 compiler, but most compilers will have similar options (although the letters may be different).
implicit none (a-z)
in the beginning of each (sub-)program.
Here are some common errors to watch out for:
If you have a bug, you have to try to locate it. Syntax errors are easy to find. The problem is when you have run-time errors. The old-fashioned way to find errors is to add write statements in your code and try to track the values of your variables. This is a bit tedious since you have to recompile your source code every time you change the program slightly. Today one can use special debuggers which is a convenient tool. You can step through a program line by line or define your own break points, you can display the values of the variables you want to monitor, and much more. Most UNIX machines will have the debuggers dbx and gdb. Unfortunately, these are difficult to learn since they have an old-fashioned line-oriented user interface. Check if there is a graphical user interface available, like, e.g., xdbx or dbxtool.
Copyright © 1995-7 by Stanford University. All rights reserved.