Program layout
The following general rules apply to the layout:
- In the case of nesting, indent by three positions.
- Separate the sub program units by brief comments lines.
- Insert a extra space before and after every comment block.
- Never use tabs, as this causes problems with transport to other machines.
The standard layout of a program or subroutine is described below.
- Program unit statement (PROGRAM, SUBROUTINE, FUNCTION, MODULE).
- Comment block consisting of:
- Programmer's name.
- Version number followed by the date and machine on which it was developed
- Version numbers of the modifications including dates, followed by a brief description of the
modification and the reason for modifying.
- Any applicable copyright, preferably GNU Public License (see http://www.gnu.org).
- Description of the subroutine function, if necessary with reference to a detailed design.
The version number consists of several digits separated by a decimal point, and has a start value of
1.0. Major modifications result in an increase by a value 1 of digit 1, and in the decimal being set at 0.
The modified digits are filled in on the next line to retain the previous information, and the
modification is briefly described in brackets. Minor modifications result in the decimal being increased
by a value 1 and, if required, a brief description of the modification.
Routines which are clearly sensitive to machine accuracy contain a warning in the comments.
- Declaration of input and output variables, followed by a comment block with a description of these
variables marked with i (input) and/or o (output).
Use the lexicographic order, and always use the INTENT attribute.
- Local variables:
- Declaration of variables.
- Any SAVE attributes, parameter and data statements.
- A comment block with a description of all local variables. Use the lexicographical order.
- Comment block consisting of:
- I/O description including unit numbers and files used.
- Description of all subroutines used.
- Description of all subroutines which call the current subroutine.
- Error messages.
- Description of the module as a pseudo code (see Chapter 8).
- Program text.
Format statements are given at the end of the program unit.
A template format of a subroutine is given in Chapter 13. No layout must be used for SWAN other than the layout
of that example.
The SWAN team 2022-08-10