Intel fortran-80 manual Refining The Problem Definition

Models: fortran-80

1 130
Download 130 pages 742 b
Page 86
Image 86
7.1.3 Refining The Problem Definition

Programming Guidelines

FORTRAN-80

As the development of a program becomes more detailed, the documentation should become correspondingly detailed. The ultimate documentation is, of course, the final program code, which should include numerous useful comments, have mean- ingful mnemonic names for symbols, and make good use of blanks in statement lines to improve program readability. If the program is not severely limited by pro- cessor memory size, each program unit could be prefaced with a comment block. These comments could include more than a description of the program unit's func- tion; for example, it might say who coded this unit originally and who made the latest changes.

7.1.3 Refining The Problem Definition

Once the problem is defined in detail, a series of refinements is begun, with each level in the series being increasingly detailed.

For the sake of example, let's assume the payroll statistics printout task has been defined as follows:

The input will be a formatted file on diskette containing a record for each employee. This record contains all information related to hours worked, pay rates, deductions, etc.

The program is to print out (on the line printer) only the employee's name (EMP field), the hours worked (HRS), the gross pay (GRPA Y), and net pay (NET- PAY).

After the last record has been printed, the program is to print a summary showing the total number of employees, the total hours worked, and the total (gross) pay disbursed.

The first two levels of program development might look like:

Level One

Print out payroll statistics on line printer.

Level Two

Initialize variables.

Open files.

Read input record.

If (last record) then

Print totals

Close files

Else

Print individual statistics

Update totals

Go to 'read record' statement

Note in level two that we are still using essentially English sentences with a few words here and there that begin to look like FORTRAN. The program structure is beginning to take shape, but at this point we're more concerned with logic than FORTRAN.code.

7-2

Page 86
Image 86
Intel fortran-80 manual Refining The Problem Definition