next up previous contents
Next: Appendix A - List Up: Professional Programmer's Guide to Previous: Obsolete and Deprecated Features

Common Extensions to the Fortran Standard

Almost before the official Standard (ANSI X3.9-1978) for Fortran77 had been defined, various software producers started to add their own favourite features. The US Department of Defense issued in 1988 a supplement called MIL-STD-1753 setting out a list of extensions that it required Fortran systems to support if they were to tender for DoD contracts. This requirement later spread to other areas of Federal Government procurement, so these extensions are now almost universally provided and can be used with confidence without reducing portability.

MIL-STD-1753 Extensions

IMPLICIT NONE statement

This statement says that there are no default data types in this program unit, so that all named items (variables, arrays, constants, and external functions) must have their data type specified in an explicit type statement. It must appear before all these specification statements and cannot be used together with any other IMPLICIT statement in the same program unit. Although novice programmers find it tedious to have to declare each name before using it, but the benefits are considerable in that mis-spelled names come to light much more easily, and most professional programmers find it a worth-while investment.

INCLUDE statement

The INCLUDE statement specifies the name of another file which contains some source code. It is most often used to contain a set of specification statements which are common to a number of different program units, for example COMMON blocks and their associated type statements, or a list of common constants such as tex2html_wrap_inline2929. The form of file-name is, of course, system dependent. In portable software it is prudent to choose a simple name which is likely to be acceptable to most operating systems. For example:

      INCLUDE 'trig.inc'
\end{verbatime}
where the file {\tt trig.inc} (or maybe {\tt TRIG.INC}) contains:
\begin{verbatim}
      REAL PI, TWOPI, RTOD
      PARAMETER (PI = 3.14159265, TWOPI=2.0*PI, RTOD=PI/180.0)
If such constants are defined only once, it is much easier to ensure that they are correct. Similarly the definition of a COMMON block in only one place ensures that its consistency throughout the program.

DO-loops with END DO

The Fortran77 Standard seemed deficient in pairing IF with END IF but not DO with END DO. This extension is widely available and helpful in that it avoids the need to use a different statement label on each loop. For example:

      DO J = 1,NPTS
         SUM   = SUM + X(I)
         SUMSQ = SUMSQ + X(I)**2
      END DO
It is good practice to indent the lines between the DO and END DO statements to make the repeated section obvious. The appearance of a statement label in such code usually marks the destination of a GO TO statement, and alerts the programmer to some unusual alteration to the standard sequence of operations. Where only labelled DO-loops are used, such exceptions are harder to spot.


next up previous contents
Next: Appendix A - List Up: Professional Programmer's Guide to Previous: Obsolete and Deprecated Features

Clive Page
Tue Feb 27 11:14:41 GMT 2001