The content of this document may be incorrect or out dated.
Debugging your fortran program
- Declare all variables.
- Write well documented programs.
- Use only standard procedures and calls.
- Use print statements throughout the program to detect errors.
- Use a subroutine to perform specific functions which are repeated.
- Keep subroutines shorter than 100 lines.
- Keep array sizes small during debugging to prevent slower response time.
- Use simple test data before running actual data.
- Use dbx for hard-to-find bugs.
Compilation ErrorsThese errors are usually syntax errors and undefined statement numbers. Please note that compilation does not check your program logic, it only checks syntax. During compilation, error messages are displayed on the terminal. The error messages also specify the line numbers where the problem occurred. A printed copy of these messages can be obtained. Normally, the file has to be recompiled after the errors have been corrected.
Using the -C option will compile code to check that subscripts are within the declared array bounds. This helps catch some causes of the dreaded segmentation fault.
Link ErrorsSometimes the computer is unable to find a library or function referenced by the main program. Error messages such as "undefined:_subr_" will be displayed. Usually this is due to a subroutine name that has been misspelled, a subroutine that was not included, or because the library was not specified by the "f77" command.
Execution ErrorsErrors in compilation cause no execute permission:
If a non-fatal error occurs while you are compiling your program, the executable version of the program ('a.out') is created without execute permission. If you attempt to run this program, you will get the error message:
a.out: Permission deniedYou need to fix the errors in your source code and compile it again before attempting to execute the program.
An effective method used to troubleshoot a program for execution errors is to strategically place write statements within the source code. This makes it easier to watch a program as it executes and to focus on problem areas.
A Symbolic Debugger - dbxA powerful method of troubleshooting execution errors is provided through dbx. dbx is a source level debugging tool which is run after errors have been encountered. It is a symbolic debugger which examines Fortran files and provides a controlled environment for program execution. For more information type:
Last modified: 2007/05/31 13:36:37.023000 GMT-4 by
Created: 2007/05/31 13:36:37.023000 GMT-4 by brian.r.brinegar.1.
Type in a few keywords describing what information you are looking for in the text box below.