Chapter 1. Introduction

For a programming language, Fortran has existed for a long time. It was one of the first widely used high-level languages and was the first programming language to be standardized. It is still the premier language for scientific and engineering computing applications. This chapter provides compatibility information and introduces the newest additions to the Fortran language.

1.1. FORTRAN 77 Compatibility

Because of the large investment in existing software written in Fortran, the Fortran standards committee decided to include the entire previous FORTRAN 77 standard in the Fortran 90 standard. In the Fortran 95 standard, however, some features are deleted. Even though the Fortran 95 standard deleted some features, the compiler has not deleted any features. Features from older standards that are deleted are honored, but they generate an ANSI message from the compiler.

Fortran 95 restricts the behavior of some features that were processor dependent in FORTRAN 77. Therefore, a program that conforms to the FORTRAN 77 standard and uses processor-dependent features can also conform to the Fortran 95 standard and yet behave differently than with some FORTRAN 77 systems. In the following situations, the Fortran 95 interpretation is different from that of FORTRAN 77:

  • Fortran 95 contains more intrinsic functions than FORTRAN 77 did, and Fortran 95 has a few intrinsic subroutines. Therefore, a standard-conforming FORTRAN 77 program can have a different interpretation under this standard if it invokes an external procedure that has the same name as one of the new standard intrinsic procedures, unless that procedure is specified in an EXTERNAL statement as recommended for nonintrinsic functions.

  • If a named variable that was not in a common block was initialized in a DATA statement, it has the SAVE attribute in Fortran 95. In FORTRAN 77, if the value of the variable was changed or became undefined, its value on reentry into a procedure was processor dependent. The compiler treats variables initialized in DATA statements as if they had appeared in a SAVE statement. MIPSpro F77 saves the variables in DATA statements on the heap instead of the stack.

  • In FORTRAN 77, an input list could never require more characters than were present in a record during formatted input. Fortran 95 does not dictate this restriction for cases in which the PAD= specifier is YES; in these cases, the input record is padded with as many blanks as necessary to satisfy the input item and the corresponding format. For more information on this, see the MIPSpro Fortran Language Reference Manual, Volume 3.

  • FORTRAN 77 permitted a processor to supply extra precision for a real constant when it was used to initialize a DOUBLE PRECISION data object in a DATA statement. Fortran 95 does not permit this.

  • The format of a floating point zero written with a G edit descriptor is different in Fortran 95. The floating-point zero was written with an Ew. d edit descriptor in FORTRAN 77, but it is written with an Fw.d edit descriptor in the compiler. FORTRAN 77 output cannot be changed. Therefore, different compare files must be retained for FORTRAN 77 and Fortran 95 programs that use the G edit descriptor for floating-point output.

1.2. Fortran 90 Compatibility

The Fortran 90 language standard introduced new data types, new operators, and new meanings for the existing operators and assignment. It provided ways for programmers to extend Fortran. These facilities allow programmers to create abstract data types by defining new types and the operations to be performed on them. Modules were introduced into Fortran as a convenient way to package these new data types and their operations. Modules can be used by the same programmer in different applications or can be distributed to several users on the same or different projects.

The Fortran 90 standard (ISO/IEC 1539:1991) described the syntax and semantics of the Fortran programming language. The standard addressed certain aspects of the Fortran processing system, but it did not address others. When specifications were not covered by the standard, the interpretation was processor dependent; that is, the processor defined the interpretation, but the interpretation for any two processors did not need to be the same. Typically, programs that rely on processor-dependent interpretations are not portable.

The Fortran 90 standard declared several features to be obsolescent. In the Fortran 95 standard, some of Fortran 90's obsolescent features are deleted. The compiler has not deleted any features. The compiler issues an ANSI message whenever a deleted feature is used, however. For more information on deleted and obsolescent features, see the MIPSpro Fortran Language Reference Manual, Volume 3.

1.2.1. Fortran 95 language standard

Fortran 95 continues the evolutionary model introduced in Fortran 90 by deleting several of the features marked as obsolescent in Fortran 90 and identifying a few new obsolescent features. For information on these features, see the MIPSpro Fortran Language Reference Manual, Volume 3.

Fortran 95 is a relatively minor evolution of standard Fortran, with the emphasis in this revision being upon correcting defects in the Fortran 90 standard. This new standard also provides interpretation for a number of questions that have arisen concerning Fortran 90 semantics and syntax. For example, the Fortran 95 SIGN(3i) intrinsic function behaves differently from the Fortran 90 SIGN (3i) function if the second argument is negative real zero.

In addition to corrections and clarifications, Fortran 95 contains several extensions to Fortran 90. The major extensions are as follows:

  • The FORALL statement and construct.

  • PURE and ELEMENTAL procedures.

  • Pointer initialization and structure default initialization.

  • Additional intrinsic procedures. A Fortran 90 program may have a different interpretation under the Fortran 95 standard if it invokes an external procedure that has the same name as one of the new standard intrinsic procedures unless that procedure is specified in an EXTERNAL statement or an interface body.

The Fortran 95 standard specifies the following information:

  • Syntax of Fortran statements and forms for Fortran programs

  • Semantics of Fortran statements and Fortran programs

  • Specifications for correct input data

  • Appearance of standard output data

The standard does not specify the following information:

  • The way in which each Fortran compiler is written

  • Operating system facilities defining the computing system

  • Methods used to transfer data to and from peripheral storage devices and the nature of the peripheral devices

  • Behavior of vendor extensions

  • Size and complexity of a Fortran program and its data

  • Hardware or firmware used to run the program

  • The way values are represented and the way numeric values are computed

  • Physical representation of data

  • Characteristics of tapes, disks, and various storage media

1.2.2. Program Conformance

A program conforms to the standard if all the statements are syntactically correct, execution of the program causes no violations of the standard (such as dividing by zero), and all the input data is in the correct form.

Compiler extensions to the Fortran standard appear in notes throughout the text.

1.2.3. Processor Conformance

In the Fortran standard, the term processor means the combination of a Fortran compiler and the computing system that executes the code. A processor conforms to the standard if it compiles and executes programs that conform to the standard, provided that the Fortran program is not too large or complex for the computer system in question.

Options on the f90(1) command line can direct the compiler to flag nonstandard usage. For more information on the command lines, see the f90(1) man page or the MIPSpro Fortran 90 Commands and Directives Reference Manual. When the option is in effect, the compiler prints messages for extensions to the standard that are used in the program. As required by the standard, the compiler also flags the following items and provides the reason that the item is being flagged:

  • Obsolescent features

  • Deleted features

  • Kind type parameters not supported

  • Violations of any syntax rules and the accompanying constraints

  • Characters not permitted by the processor

  • Illegal source form

  • Violations of the scope rules for names, labels, operators, and assignment symbols

These conformance requirements were not present in previous Fortran standards.

The compiler includes extensions to the Fortran standard. Because the compiler processes programs according to the standard, they are considered to be standard-conforming processors. When the option to note deviations from the Fortran standard is in effect, extensions to the standard are flagged with ANSI messages when detected at compile time.

1.2.4. Portability

One of the main purposes of a standard is to describe how to write portable programs. However, some things are standard-conforming but not portable; for example, a program that computes a very large number like 10250. Certain computing systems will not accommodate a number this large. Such a number could be part of a standard-conforming program, but it might not run on all systems; therefore, it might not be portable. Another example is a program that uses a deeper nesting of control constructs than is allowed by a particular compiler.