FORTRAN II IBM's
FORTRAN II appeared in 1958. The main enhancement was to support
procedural programming by allowing user-written subroutines and functions which returned values with parameters passed by
reference. The COMMON statement provided a way for subroutines to access common (or
global) variables. Six new statements were introduced: • , , and • and • In the view of computing pioneer
Robert Bemer, the addition of separately compiled subroutines to the language was "a development equivalent in importance to the original FORTRAN." and indeed limited how programmers could think about such things.
Simple FORTRAN II program This program, for
Heron's formula, reads data on a tape reel containing three 5-digit integers A, B, and C as input. There are no "type" declarations available: variables whose name starts with I, J, K, L, M, or N are "fixed-point" (i.e. integers), otherwise floating-point. Since integers are to be processed in this example, the names of the variables start with the letter "I". The name of a variable must start with a letter and can continue with both letters and digits, up to a limit of six characters in FORTRAN II. If A, B, and C cannot represent the sides of a triangle in plane geometry, then the program's execution will end with an error code of "STOP 1". Otherwise, an output line will be printed showing the input values for A, B, and C, followed by the computed AREA of the triangle as a floating-point number occupying ten spaces along the line of output and showing 2 digits after the decimal point, the .2 in F10.2 of the FORMAT statement with label 601. C AREA OF A TRIANGLE WITH A STANDARD SQUARE ROOT FUNCTION C INPUT - TAPE READER UNIT 5, INTEGER INPUT C OUTPUT - LINE PRINTER UNIT 6, REAL OUTPUT C INPUT ERROR DISPLAY ERROR OUTPUT CODE 1 IN JOB CONTROL LISTING READ INPUT TAPE 5, 501, IA, IB, IC 501 FORMAT (3I5) C IA, IB, AND IC MAY NOT BE NEGATIVE OR ZERO C FURTHERMORE, THE SUM OF TWO SIDES OF A TRIANGLE C MUST BE GREATER THAN THE THIRD SIDE, SO WE CHECK FOR THAT, TOO IF (IA) 777, 777, 701 701 IF (IB) 777, 777, 702 702 IF (IC) 777, 777, 703 703 IF (IA+IB-IC) 777, 777, 704 704 IF (IA+IC-IB) 777, 777, 705 705 IF (IB+IC-IA) 777, 777, 799 777 STOP 1 C USING HERON'S FORMULA WE CALCULATE THE C AREA OF THE TRIANGLE 799 S = FLOATF (IA + IB + IC) / 2.0 AREA = SQRTF( S * (S - FLOATF(IA)) * (S - FLOATF(IB)) * + (S - FLOATF(IC))) WRITE OUTPUT TAPE 6, 601, IA, IB, IC, AREA 601 FORMAT (4H A= ,I5,5H B= ,I5,5H C= ,I5,8H AREA= ,F10.2, + 13H SQUARE UNITS) STOP END
FORTRAN III IBM also developed a
FORTRAN III in 1958 that allowed for
inline assembly code among other features; however, this version was never released as a product. Like the 704 FORTRAN and FORTRAN II, FORTRAN III included machine-dependent features that made code written in it unportable from machine to machine, as well as Boolean expression support. By 1965, FORTRAN IV was supposed to be compliant with the
standard being developed by the
American Standards Association X3.4.3 FORTRAN Working Group. Between 1966 and 1968, IBM offered several FORTRAN IV compilers for its
System/360, each named by letters that indicated the minimum amount of memory the compiler needed to run. The letters (F, G, H) matched the codes used with System/360 model numbers to indicate memory size, each letter increment being a factor of two larger: • 1966 : FORTRAN IV F for DOS/360 (64K bytes) • 1966 : FORTRAN IV G for OS/360 (128K bytes) • 1968 : FORTRAN IV H for OS/360 (256K bytes) In particular, the FORTRAN H compiler played an important role in the development of certain kinds of optimization approaches, such as allocating a specific set of registers to hold the values of variables while in a loop. Overall, the compiler had three levels of possible optimization, Compilers were also available for the
UNIVAC 1100 series and the
Control Data 6000 series and
7000 series systems. In the FORTRAN IV programming environment of the era, except for that used on Control Data Corporation (CDC) systems, only one instruction was placed per line. The CDC version allowed for multiple instructions per line if separated by a (dollar) character. The FORTRAN
sheet was divided into four fields, as described above. Two compilers of the time, IBM "G" and UNIVAC, allowed comments to be written on the same line as instructions, separated by a special character: "master space": V (perforations 7 and 8) for UNIVAC and perforations 12/11/0/7/8/9 (hexadecimal FF) for IBM. These comments were not to be inserted in the middle of continuation cards. The intent was that these would all be replaced by the Defense Department-sponsored
Ada programming language,
FORTRAN 77 175 at
RWTH Aachen University, Germany, in 1987 for the
Digital Equipment Corporation (DEC)
VAX, displaying the
manual for FORTRAN 77 (f77) compiler After the release of the FORTRAN 66 standard, compiler vendors introduced several extensions to
Standard Fortran, prompting ANSI committee X3J3 in 1969 to begin work on revising the 1966 standard, under sponsorship of
CBEMA, the Computer Business Equipment Manufacturers Association (formerly BEMA). Final drafts of this revised standard circulated in 1977, leading to formal approval of the new FORTRAN standard in April 1978. The new standard, called
FORTRAN 77 and officially denoted X3.9-1978, added a number of significant features to address many of the shortcomings of FORTRAN 66: • Block and statements, with optional and clauses, to provide improved language support for
structured programming • loop extensions, including parameter expressions, negative increments, and zero trip counts • , , and statements for improved I/O capability • Direct-access file I/O • data type, replacing Hollerith strings with vastly expanded facilities for character input and output and processing of character-based data • statement for specifying constants • statement for persistent local variables • Generic names for intrinsic functions (e.g. also accepts arguments of other types, such as or ). • A set of intrinsics (, , , ) for
lexical comparison of strings, based upon the
ASCII collating sequence. (These ASCII functions were demanded by the
U.S. Department of Defense, in their conditional approval vote.) • A maximum of seven dimensions in arrays, rather than three. Allowed subscript expressions were also generalized. In this revision of the standard, a number of features were removed or altered in a manner that might invalidate formerly standard-conforming programs. (Removal was the only allowable alternative to X3J3 at that time, since the concept of "
deprecation" was not yet available for ANSI standards.) While most of the 24 items in the conflict list (see Appendix A2 of X3.9-1978) addressed loopholes or pathological cases permitted by the prior standard but rarely used, a small number of specific capabilities were deliberately removed, such as: •
Hollerith constants and
Hollerith data, such as GREET = 12HHELLO THERE! • Reading into an H edit (Hollerith field) descriptor in a FORMAT specification • Overindexing of array bounds by subscripts DIMENSION A(10,5) Y = A(11,1) • Transfer of control out of and back into the range of a DO loop (also known as "Extended Range") A Fortran 77 version of the Heron program requires no modifications to the Fortran 66 version. However this example demonstrates additional cleanup of the I/O statements, including using list-directed I/O, and replacing the Hollerith edit descriptors in the statements with quoted strings. It also uses structured and statements, rather than /. PROGRAM HERON C AREA OF A TRIANGLE WITH A STANDARD SQUARE ROOT FUNCTION C INPUT - DEFAULT STANDARD INPUT UNIT, INTEGER INPUT C OUTPUT - DEFAULT STANDARD OUTPUT UNIT, REAL OUTPUT C INPUT ERROR DISPLAY ERROR OUTPUT CODE 1 IN JOB CONTROL LISTING READ (*, *) IA, IB, IC C C IA, IB, AND IC MAY NOT BE NEGATIVE OR ZERO C FURTHERMORE, THE SUM OF TWO SIDES OF A TRIANGLE C MUST BE GREATER THAN THE THIRD SIDE, SO WE CHECK FOR THAT, TOO IF (IA .LE. 0 .OR. IB .LE. 0 .OR. IC .LE. 0) THEN WRITE (*, *) 'IA, IB, and IC must be greater than zero.' STOP 1 END IF C IF (IA+IB-IC .LE. 0 + .OR. IA+IC-IB .LE. 0 + .OR. IB+IC-IA .LE. 0) THEN WRITE (*, *) 'Sum of two sides must be greater than third side.' STOP 1 END IF C C USING HERON'S FORMULA WE CALCULATE THE C AREA OF THE TRIANGLE S = (IA + IB + IC) / 2.0 AREA = SQRT ( S * (S - IA) * (S - IB) * (S - IC)) WRITE (*, 601) IA, IB, IC, AREA 601 FORMAT ('A= ', I5, ' B= ', I5, ' C= ', I5, ' AREA= ', F10.2, + ' square units') STOP END
Transition to ANSI Standard Fortran The development of a revised standard to succeed FORTRAN 77 would be repeatedly delayed as the standardization process struggled to keep up with rapid changes in computing and programming practice. In the meantime, as the "Standard FORTRAN" for nearly fifteen years, FORTRAN 77 would become the historically most important dialect. An important practical extension to FORTRAN 77 was the release of MIL-STD-1753 in 1978. This specification, developed by the
U.S. Department of Defense, standardized a number of features implemented by most FORTRAN 77 compilers but not included in the ANSI FORTRAN 77 standard. These features would eventually be incorporated into the Fortran 90 standard. • and statements • statement • variant of the statement •
Bit manipulation intrinsic functions, based on similar functions included in
Industrial Real-Time Fortran (ANSI/ISA S61.1 (1976)) The
IEEE 1003.9
POSIX Standard, released in 1991, provided a simple means for FORTRAN 77 programmers to issue POSIX system calls. Over 100 calls were defined in the document allowing access to POSIX-compatible process control, signal handling, file system control, device control, procedure pointing, and stream I/O in a portable manner.
Fortran 90 The much-delayed successor to FORTRAN 77, informally known as
Fortran 90 (and prior to that,
Fortran 8X), was finally released as ISO/IEC standard 1539:1991 in 1991 and an ANSI Standard in 1992. In addition to changing the official spelling from FORTRAN to Fortran, this major revision added many new features to reflect the significant changes in programming practice that had evolved since the 1978 standard: •
Free-form source input removes the need to skip the first six character positions before entering statements. Line continuations are specified by the & character at the end of the line, rather than in column 6 of the next line. Blanks also become significant. Typically files with names ending in .f90 signify free-format source code. The older fixed-form source form is still defined, but considered obsolescent. • Lowercase Fortran keywords • Identifiers up to 31 characters in length (in the previous standard, it was only six characters). • Inline comments • Ability to operate on arrays (or array sections) as a whole, thus greatly simplifying math and engineering computations. • whole, partial and masked array assignment statements and array expressions, such as X(1:N)=R(1:N)*COS(A(1:N)) • statement for selective array assignment • array-valued constants and expressions, • user-defined array-valued functions and array constructors. • recursion (computer science)| procedures •
Modules, to group related
procedures and data together, and make them available to other program units, including the capability to limit the accessibility to only specific parts of the module. • A vastly improved argument-passing mechanism, allowing
interfaces to be checked at compile time • User-written interfaces for generic procedures •
Operator overloading • Derived (structured) data types • New data type declaration syntax, to specify the data type and other attributes of variables •
Dynamic memory allocation by means of the attribute and the and statements • Pointer (computer programming)| attribute, pointer assignment, and statement to facilitate the creation and manipulation of dynamic
data structures • Structured looping constructs, with an statement for loop termination, and and statements for terminating normal loop iterations in an orderly way • , , . . . , construct for
multi-way selection • Portable specification of numerical precision under the user's control • New and enhanced intrinsic procedures.
Obsolescence and deletions Unlike the prior revision, Fortran 90 removed no features. Any standard-conforming FORTRAN 77 program was also standard-conforming under Fortran 90, and either standard should have been usable to define its behavior. A small set of features were identified as "obsolescent" and were expected to be removed in a future standard. All of the functionalities of these early-version features can be performed by newer Fortran features. Some are kept to simplify porting of old programs but many were deleted in Fortran 95.
"Hello, World!" example program helloworld print *, "Hello, World!" end program helloworld
Fortran 95 Fortran 95, published officially as ISO/IEC 1539-1:1997, was a minor revision, mostly to resolve some outstanding issues from the Fortran 90 standard. Nevertheless, Fortran 95 also added a number of extensions, notably from the
High Performance Fortran specification: • and nested constructs to aid vectorization • User-defined
and procedures • Default initialization of derived type components, including pointer initialization • Expanded the ability to use initialization expressions for data objects • Initialization of pointers to • Clearly defined that arrays are automatically deallocated when they go out of scope. A number of intrinsic functions were extended (for example a argument was added to the intrinsic). Several features noted in Fortran 90 to be "obsolescent" were removed from Fortran 95: • statements using and index variables • Branching to an statement from outside its block • statement • and assigned statement, and assigned format specifiers • Hollerith edit descriptor. An important supplement to Fortran 95 was the
ISO technical report TR-15581: Enhanced Data Type Facilities, informally known as the
Allocatable TR. This specification defined enhanced use of arrays, prior to the availability of fully Fortran 2003-compliant Fortran compilers. Such uses include arrays as derived type components, in procedure dummy argument lists, and as function return values. ( arrays are preferable to -based arrays because arrays are guaranteed by Fortran 95 to be deallocated automatically when they go out of scope, eliminating the possibility of
memory leakage. In addition, elements of allocatable arrays are contiguous, and
aliasing is not an issue for optimization of array references, allowing compilers to generate faster code than in the case of pointers.) Another important supplement to Fortran 95 was the
ISO technical report
TR-15580: Floating-point exception handling, informally known as the
IEEE TR. This specification defined support for
IEEE floating-point arithmetic and
floating-point exception handling.
Conditional compilation and varying length strings In addition to the mandatory "Base language" (defined in ISO/IEC 1539-1 : 1997), the Fortran 95 language also included two optional modules: • Varying length character strings (ISO/IEC 1539-2 : 2000) • Conditional compilation (ISO/IEC 1539-3 : 1998) which, together, compose the multi-part International Standard (ISO/IEC 1539). According to the standards developers, "the optional parts describe self-contained features which have been requested by a substantial body of users and/or implementors, but which are not deemed to be of sufficient generality for them to be required in all standard-conforming Fortran compilers." Nevertheless, if a standard-conforming Fortran does provide such options, then they "must be provided in accordance with the description of those facilities in the appropriate Part of the Standard". ==Modern Fortran==