FORTRAN-SO

Programming Guidelines

When calculating a value for use in a DO loop, be sure the value is computed before the loop is entered. Otherwise, the program could compute the value again for each iteration of the loop. Consider the following short Examples:

CEXAMPLE OF RECOMPUTED CONSTANT INTEGER*1 R

DO 25 R = 1,60

X = (2217)*(r* *2)

WRITE (4) X, R

25 CONTINUE

CSAME EXAMPLE WITH PRECOMPUTED CONSTANT INTEGER*1 R

PI = 2217

DO 25 R = 1,60 X = PI*(R**2)

WRITE (4) X, R

25 CONTINUE

In the first case, the value '22/7' would have to be computed 60 times!

7.2.5 Reminders

We've already mentioned the use of comments, good mnemonic names, and blanks to improve program readability and understandability. We've also mentioned debugging aids available in the FORTRAN language (such as the PAUSE, STOP, and WRITE or PRINT statements). In addition, the programmer should explore other debugging tools that might be available in his system environment, such as the DEBUG command in Intel's ISIS-II or Intel's in-circuit emulator family, which in- cludes ICE-80 and ICE-85 for the 8080 and 8085 microprocessors.

7.3 References

The following list suggests material for further reading. Some of the material, like the books by Ledgard and McCracken or the article by Ogdin, is essentially tutorial. Bear in mind that all of this material was written before FORTRAN 77 ~as specified and FORTRAN 'limitations' discussed in these works may no longer be a problem in the new version.

Dahl, 0.1., Dijkstra, E.W. and Hoare, C.A.R., Structured Programming, Academic Press, New York, 1972.

Dijkstra, Edgar W., 'GO TO Statement Considered Harmful,' Communications of the A CM, Vol. 15, No. 10, Oct. 1972.

Henderson, P., and Snowdon, R., 'An Experiment in Structured Programming,' BIT 12, 1972.

Hilburn, 1.L., and lulich, P.M., Microcomputers/Microprocessors: Hardware, Software, and Applications, Prentice-Hall, Inc., 1976.

Knuth, Donald E., The Art of Computer Programming, Vol. 1, Fundamental Algorithms, Addison-Wesley, Reading, Mass., 1968.

Ledgard, Henry F., Programming Pro verbs for FORTRAN Programmers, Hayden,

Rochelle Park, N.l., 1975.

.

7-5

Page 89
Image 89
Intel fortran-80 manual References, Reminders, = 2217*r* *2, Pi =