Академический Документы
Профессиональный Документы
Культура Документы
1
2 2 HISTORY
the increasing popularity of FORTRAN spurred compet- (CAS Compare AC with Storage), but using this in-
ing computer manufacturers to provide FORTRAN com- struction to implement the IF would consume 4 instruc-
pilers for their machines, so that by 1963 over 40 FOR- tion words, require the constant Zero in a word of storage,
TRAN compilers existed. For these reasons, FORTRAN and take 3 machine cycles to execute; using the Trans-
is considered to be the rst widely used programming lan- fer instructions to implement the IF could be done in 1
guage supported across a variety of computer architec- to 3 instruction words, required no constants in storage,
tures. and take 1 to 3 machine cycles to execute. An optimiz-
The development of FORTRAN paralleled the early evo- ing compiler like FORTRAN would most likely select
the more compact and usually faster Transfers instead of
lution of compiler technology, and many advances in the
theory and design of compilers were specically moti- the Compare (use of Transfers also allowed the FRE-
QUENCY statement to optimize IFs, which could not
vated by the need to generate ecient code for FOR-
TRAN programs. be done using the Compare). Also the Compare consid-
ered 0 and +0 to be dierent values while the Transfer
Zero and Transfer Not Zero considered them to be the
2.1 FORTRAN same. The FREQUENCY statement in FORTRAN was
used originally (and optionally) to give branch probabili-
The initial release of FORTRAN for the IBM 704 con- ties for the three branch cases of the arithmetic IF state-
tained 32 statements, including: ment. The rst FORTRAN compiler used this weighting
to perform at compile time a Monte Carlo simulation of
the generated code, the results of which were used to op-
DIMENSION and EQUIVALENCE statements timize the placement of basic blocks in memory a very
Assignment statements sophisticated optimization for its time. The Monte Carlo
technique is documented in Backus et al.'s paper on this
Three-way arithmetic IF statement, which passed original implementation, The FORTRAN Automatic Cod-
control to one of three locations in the program de- ing System:
pending on whether the result of the arithmetic state-
ment was negative, zero, or positive
The fundamental unit of program is the
IF statements for checking exceptions (ACCU- basic block; a basic block is a stretch of pro-
MULATOR OVERFLOW, QUOTIENT OVER- gram which has one entry point and one exit
FLOW, and DIVIDE CHECK); and IF statements point. The purpose of section 4 is to prepare
for manipulating sense switches and sense lights for section 5 a table of predecessors (PRED
table) which enumerates the basic blocks and
GO TO, computed GO TO, ASSIGN, and assigned
lists for every basic block each of the basic
GO TO
blocks which can be its immediate predeces-
DO loops sor in ow, together with the absolute fre-
quency of each such basic block link. This ta-
Formatted I/O: FORMAT, READ, READ INPUT ble is obtained by running the program once
TAPE, WRITE, WRITE OUTPUT TAPE, PRINT, in Monte-Carlo fashion, in which the outcome
and PUNCH of conditional transfers arising out of IF-type
statements and computed GO TO'S is deter-
Unformatted I/O: READ TAPE, READ DRUM, mined by a random number generator suit-
WRITE TAPE, and WRITE DRUM ably weighted according to whatever FRE-
QUENCY statements have been provided.[10]
Other I/O: END FILE, REWIND, and
BACKSPACE
PAUSE, STOP, and CONTINUE Many years later, the FREQUENCY statement had no ef-
fect on the code, and was treated as a comment statement,
FREQUENCY statement (for providing since the compilers no longer did this kind of compile-
optimization hints to the compiler). time simulation. A similar fate has befallen compiler hints
in several other programming languages; for example C's
The arithmetic IF statement was similar to a three-way register keyword.
branch instruction on the IBM 704. However, the 704 The rst FORTRAN compiler reported diagnostic infor-
branch instructions all contained only one destination ad- mation by halting the program when an error was found
dress (e.g., TZE Transfer AC Zero, TNZ Transfer and outputting an error code on its console. That code
AC Not Zero, TPL Transfer AC Plus, TMI Trans- could be looked up by the programmer in a error mes-
fer AC Minus). The machine (and its successors in the sages table in the operators manual, providing them with
700/7000 series) did have a three-way skip instruction a brief description of the problem.[11][12]
2.2 FORTRAN II 3
2.1.1 Fixed layout and punched cards restrictions due to limitations on their card readers.[14]
Keypunches could be programmed to tab to column 7
and skip out after column 72. Later compilers relaxed
most xed-format restrictions, and the requirement was
eliminated in the Fortran 90 standard.
Within the statement eld, whitespace characters
(blanks) were ignored outside a text literal. This allowed
omitting spaces between tokens for brevity or including
spaces within identiers for clarity. For example, AVG
OF X was a valid identier, equivalent to AVGOFX,
and 101010DO101I=1,101 was a valid statement,
equivalent to 10101 DO 101 I = 1, 101 because the zero
FORTRAN code on a punched card, showing the specialized uses
of columns 15, 6 and 7380
in column 6 is treated as if it were a space (!), while
101010DO101I=1.101 was instead 10101 DO101I =
Further information: Computer programming in the 1.101, the assignment of 1.101 to a variable called
punched card era DO101I. Note the slight visual dierence between a
comma and a period.
Before the development of disk les, text editors and ter- Hollerith strings, originally allowed only in FORMAT
minals, programs were most often entered on a keypunch and DATA statements, were prexed by a character count
keyboard onto 80-column punched cards, one line to a and the letter H (e.g., 26HTHIS IS ALPHANUMERIC
card. The resulting deck of cards would be fed into a DATA.), allowing blanks to be retained within the char-
card reader to be compiled. Punched-card codes included acter string. Miscounts were a problem.
no lower-case letters or many special characters, and spe-
cial versions of the IBM 026 keypunch were oered that
would correctly print the repurposed special characters 2.2 FORTRAN II
used in Fortran.
IBMs FORTRAN II appeared in 1958. The main en-
Reecting punched-card input practice, Fortran pro-
hancement was to support procedural programming by
grams were originally written in a xed-column format,
allowing user-written subroutines and functions which re-
with the rst 72 columns read into twelve 36-bit words.
turned values, with parameters passed by reference. The
A letter C in column 1 caused the entire card to be COMMON statement provided a way for subroutines to
treated as a comment and ignored by the compiler. Oth- access common (or global) variables. Six new statements
erwise, the columns of the card were divided into four were introduced:
elds:
SUBROUTINE, FUNCTION, and END
1 to 5 were the label eld: a sequence of digits here
was taken as a label for use in DO or control state- CALL and RETURN
ments such as GO TO and IF, or to identify a FOR-
MAT statement referred to in a WRITE or READ COMMON
statement. Leading zeros are ignored and 0 is not a
valid label number.
Over the next few years, FORTRAN II would also add
6 was a continuation eld: a character other than a support for the DOUBLE PRECISION and COMPLEX
blank or a zero here caused the card to be taken as data types.
a continuation of the statement on the prior card.
Early FORTRAN compilers supported no recursion in
7 to 72 served as the statement eld. subroutines. Early computer architectures supported no
concept of a stack, and when they did directly support
73 to 80 were ignored (the IBM 704s card reader subroutine calls, the return location was often stored in
only used 72 columns).[13] one xed location adjacent to the subroutine code (e.g.
the IBM 1130) or a specic machine register (IBM 360
Columns 73 to 80 could therefore be used for identica- et seq), which does not permit a subroutine to be called
tion information, such as punching a sequence number or again before a prior call of the subroutine has returned.
text, which could be used to re-order cards if a stack of Although not specied in Fortran 77, many F77 compil-
cards was dropped; though in practice this was reserved ers supported recursion as an option, and the Burroughs
for stable, production programs. An IBM 519 could be mainframes, designed with recursion built-in, did so by
used to copy a program deck and add sequence numbers. default. It became a standard in Fortran 90 via the new
Some early compilers, e.g., the IBM 650s, had additional keyword RECURSIVE.[15]
4 2 HISTORY
2.2.1 Simple FORTRAN II program IBM also developed a FORTRAN III in 1958 that allowed
for inline assembly code among other features; however,
This program, for Herons formula, reads data on a tape this version was never released as a product. Like the 704
reel containing three 5-digit integers A, B, and C as in- FORTRAN and FORTRAN II, FORTRAN III included
put. There are no type declarations available: variables machine-dependent features that made code written in it
whose name starts with I, J, K, L, M, or N are xed- unportable from machine to machine. Early versions of
point (i.e. integers), otherwise oating-point. If A, B, FORTRAN provided by other vendors suered from the
and C cannot represent the sides of a triangle in plane same disadvantage.
geometry, then the programs 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 2.4 IBM 1401 FORTRAN
by the computed AREA of the triangle as a oating-point
number occupying ten spaces along the line of output and FORTRAN was provided for the IBM 1401 computer by
showing 2 digits after the decimal point, the .2 in F10.2 an innovative 63-phase compiler that ran entirely in its
of the FORMAT statement with label 601. core memory of only 8000 (6-bit) characters. The com-
piler could be run from tape, or from a 2200-card deck;
C AREA OF A TRIANGLE WITH A STANDARD it used no further tape or disk storage. It kept the pro-
SQUARE ROOT FUNCTION C INPUT - TAPE gram in memory and loaded overlays that gradually trans-
READER UNIT 5, INTEGER INPUT C OUTPUT - formed it, in place, into executable form, as described by
LINE PRINTER UNIT 6, REAL OUTPUT C INPUT Haines.[16] and in IBM document C24-1455. The exe-
ERROR DISPLAY ERROR OUTPUT CODE 1 IN JOB cutable form was not entirely machine language; rather,
CONTROL LISTING READ INPUT TAPE 5, 501, IA, oating-point arithmetic, subscripting, input/output, and
IB, IC 501 FORMAT (3I5) C IA, IB, AND IC MAY function references were interpreted, anticipating UCSD
NOT BE NEGATIVE OR ZERO C FURTHERMORE, Pascal P-code by two decades.
THE SUM OF TWO SIDES OF A TRIANGLE C
MUST BE GREATER THAN THE THIRD SIDE, SO IBM later provided a FORTRAN IV compiler for the
WE CHECK FOR THAT, TOO IF (IA) 777, 777, 701 1400 series of computers, described in IBM document
701 IF (IB) 777, 777, 702 702 IF (IC) 777, 777, 703 C24-3322.
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
2.5 FORTRAN IV
STOP 1 C USING HERON'S FORMULA WE CAL-
CULATE THE C AREA OF THE TRIANGLE 799
Starting in 1961, as a result of customer demands, IBM
S = FLOATF (IA + IB + IC) / 2.0 AREA = SQRTF(
began development of a FORTRAN IV that removed the
S * (S - FLOATF(IA)) * (S - FLOATF(IB)) * + (S -
machine-dependent features of FORTRAN II (such as
FLOATF(IC))) WRITE OUTPUT TAPE 6, 601, IA,
READ INPUT TAPE), while adding new features such as
IB, IC, AREA 601 FORMAT (4H A= ,I5,5H B= ,I5,5H
a LOGICAL data type, logical Boolean expressions and
C= ,I5,8H AREA= ,F10.2, + 13H SQUARE UNITS)
the logical IF statement as an alternative to the arithmetic
STOP END
IF statement. FORTRAN IV was eventually released in
1962, rst for the IBM 7030 (Stretch) computer, fol-
lowed by versions for the IBM 7090, IBM 7094, and later
for the IBM 1401 in 1966.
2.3 FORTRAN III
By 1965, FORTRAN IV was supposed to be compli-
ant with the standard being developed by the American
Standards Association X3.4.3 FORTRAN Working
Group.[17]
At about this time FORTRAN IV had started to become
an important educational tool and implementations such
as the University of Waterloos WATFOR and WATFIV
were created to simplify the complex compile and link
processes of earlier compilers.
2.6 FORTRAN 66
Perhaps the most signicant development in the early
A FORTRAN coding form, printed on paper and intended to be history of FORTRAN was the decision by the Ameri-
used by programmers to prepare programs for punching onto can Standards Association (now American National Stan-
cards by keypunch operators. Now obsolete. dards Institute (ANSI)) to form a committee sponsored
2.7 FORTRAN 77 5
2.7 FORTRAN 77
Block IF and END IF statements, with optional
After the release of the FORTRAN 66 standard, com- ELSE and ELSE IF clauses, to provide improved
piler vendors introduced several extensions to Standard language support for structured programming
Fortran, prompting ANSI committee X3J3 in 1969 to DO loop extensions, including parameter expres-
begin work on revising the 1966 standard, under spon- sions, negative increments, and zero trip counts
sorship of CBEMA, the Computer Business Equip-
ment Manufacturers Association (formerly BEMA). Fi- OPEN, CLOSE, and INQUIRE statements for im-
nal drafts of this revised standard circulated in 1977, proved I/O capability
leading to formal approval of the new FORTRAN stan-
dard in April 1978. The new standard, called FORTRAN Direct-access le I/O
6 2 HISTORY
IMPLICIT statement, to override implicit conven- 2.8 Transition to ANSI Standard Fortran
tions that undeclared variables are INTEGER if
their name begins with I, J, K, L, M, or N (and The development of a revised standard to succeed FOR-
REAL otherwise) TRAN 77 would be repeatedly delayed as the standard-
ization process struggled to keep up with rapid changes in
CHARACTER data type, replacing Hollerith computing and programming practice. In the meantime,
strings with vastly expanded facilities for character as the Standard FORTRAN for nearly fteen years,
input and output and processing of character-based FORTRAN 77 would become the historically most im-
data portant dialect.
An important practical extension to FORTRAN 77 was
PARAMETER statement for specifying constants
the release of MIL-STD-1753 in 1978.[19] This speci-
cation, developed by the U.S. Department of Defense,
SAVE statement for persistent local variables
standardized a number of features implemented by most
Generic names for intrinsic functions (e.g. SQRT FORTRAN 77 compilers but not included in the ANSI
also accepts arguments of other types, such as FORTRAN 77 standard. These features would eventu-
COMPLEX or REAL*16 ). ally be incorporated into the Fortran 90 standard.
A set of intrinsics (LGE, LGT, LLE, LLT) for lex- DO WHILE and END DO statements
ical comparison of strings, based upon the ASCII
collating sequence. (These ASCII functions were INCLUDE statement
demanded by the U.S. Department of Defense, in IMPLICIT NONE variant of the IMPLICIT state-
their conditional approval vote.) ment
In this revision of the standard, a number of features were Bit manipulation intrinsic functions, based on simi-
removed or altered in a manner that might invalidate for- lar functions included in Industrial Real-Time For-
merly standard-conforming programs. (Removal was the tran (ANSI/ISA S61.1 (1976))
only allowable alternative to X3J3 at that time, since the
concept of "deprecation" was not yet available for ANSI The IEEE 1003.9 POSIX Standard, released in 1991,
standards.) While most of the 24 items in the conict provided a simple means for FORTRAN 77 program-
list (see Appendix A2 of X3.9-1978) addressed loopholes mers to issue POSIX system calls.[20] Over 100 calls were
or pathological cases permitted by the prior standard but dened in the document allowing access to POSIX-
rarely used, a small number of specic capabilities were compatible process control, signal handling, le system
deliberately removed, such as: control, device control, procedure pointing, and stream
I/O in a portable manner.
Hollerith constants and Hollerith data, such as
GREET = 12HHELLO THERE! 2.9 Fortran 90
Reading into an H edit (Hollerith eld) descriptor in
The much delayed successor to FORTRAN 77, infor-
a FORMAT specication
mally known as Fortran 90 (and prior to that, Fortran
8X), was nally released as ISO/IEC standard 1539:1991
Overindexing of array bounds by subscripts
in 1991 and an ANSI Standard in 1992. In addition to
DIMENSION A(10,5) Y= A(11,1)
changing the ocial spelling from FORTRAN to For-
tran, this major revision added many new features to re-
ect the signicant changes in programming practice that
Transfer of control out of and back into the range of
had evolved since the 1978 standard:
a DO loop (also known as Extended Range)
whole, partial and masked array assignment 2.9.2 Hello world example
statements and array expressions, such as
X(1:N)=R(1:N)*COS(A(1:N)) program helloworld print *, Hello world!" end program
WHERE statement for selective array assign- helloworld
ment
array-valued constants and expressions,
user-dened array-valued functions and array
2.10 Fortran 95
constructors.
Main article: Fortran 95 language features
RECURSIVE procedures
Fortran 95, published ocially as ISO/IEC 1539-1:1997,
Modules, to group related procedures and data to- was a minor revision, mostly to resolve some outstanding
gether, and make them available to other program issues from the Fortran 90 standard. Nevertheless, For-
units, including the capability to limit the accessi- tran 95 also added a number of extensions, notably from
bility to only specic parts of the module. the High Performance Fortran specication:
A vastly improved argument-passing mechanism, al-
lowing interfaces to be checked at compile time FORALL and nested WHERE constructs to aid vec-
torization
User-written interfaces for generic procedures
User-dened PURE and ELEMENTAL procedures
Operator overloading Default initialization of derived type components,
Derived (structured) data types including pointer initialization
Expanded the ability to use initialization expressions
New data type declaration syntax, to specify the data
for data objects
type and other attributes of variables
Initialization of pointers to NULL()
Dynamic memory allocation by means of the AL-
LOCATABLE attribute and the ALLOCATE and Clearly dened that ALLOCATABLE arrays are
DEALLOCATE statements automatically deallocated when they go out of scope.
POINTER attribute, pointer assignment, and NUL- A number of intrinsic functions were extended (for exam-
LIFY statement to facilitate the creation and manip- ple a dim argument was added to the maxloc intrinsic).
ulation of dynamic data structures
Several features noted in Fortran 90 to be obsolescent
Structured looping constructs, with an END DO were removed from Fortran 95:
statement for loop termination, and EXIT and CY-
CLE statements for terminating normal DO loop it- DO statements using REAL and DOUBLE PRECI-
erations in an orderly way SION index variables
SELECT . . . CASE construct for multi-way selec- Branching to an END IF statement from outside its
tion block
Fortran 95 to be deallocated automatically when they go Data manipulation enhancements: allocatable com-
out of scope, eliminating the possibility of memory leak- ponents (incorporating TR 15581), deferred type
age. In addition, elements of allocatable arrays are con- parameters, VOLATILE attribute, explicit type
tiguous, and aliasing is not an issue for optimization of ar- specication in array constructors and allocate state-
ray references, allowing compilers to generate faster code ments, pointer enhancements, extended initializa-
than in the case of pointers.[22] ) tion expressions, and enhanced intrinsic procedures
Another important supplement to Fortran 95 was the ISO Input/output enhancements: asynchronous transfer,
technical report TR-15580: Floating-point exception han- stream access, user specied transfer operations for
dling, informally known as the IEEE TR. This specica- derived types, user specied control of rounding
tion dened support for IEEE oating-point arithmetic during format conversions, named constants for pre-
and oating point exception handling. connected units, the FLUSH statement, regulariza-
tion of keywords, and access to error messages
2.10.1 Conditional compilation and varying length Procedure pointers
strings
Support for IEEE oating-point arithmetic and
In addition to the mandatory Base language (dened in oating point exception handling (incorporating TR
ISO/IEC 1539-1 : 1997), the Fortran 95 language also 15580)
includes two optional modules: Interoperability with the C programming language
Support for international usage: access to ISO
Varying length character strings (ISO/IEC 1539-2 :
10646 4-byte characters and choice of decimal or
2000)
comma in numeric formatted input/output
Conditional compilation (ISO/IEC 1539-3 : 1998) Enhanced integration with the host operating
system: access to command line arguments,
which, together, compose the multi-part International environment variables, and processor error mes-
Standard (ISO/IEC 1539). sages
According to the standards developers, the optional
parts describe self-contained features which have been An important supplement to Fortran 2003 was the ISO
requested by a substantial body of users and/or im- technical report TR-19767: Enhanced module facilities
plementors, but which are not deemed to be of in Fortran. This report provided submodules, which
sucient generality for them to be required in all make Fortran modules more similar to Modula-2 mod-
standard-conforming Fortran compilers. Nevertheless, ules. They are similar to Ada private child subunits. This
if a standard-conforming Fortran does provide such op- allows the specication and implementation of a mod-
tions, then they must be provided in accordance with the ule to be expressed in separate program units, which im-
description of those facilities in the appropriate Part of proves packaging of large libraries, allows preservation
the Standard. of trade secrets while publishing denitive interfaces, and
prevents compilation cascades.
The BLOCK construct can contain declarations of almost all of the most widely used support libraries have
objects with construct scope been written in C and, more often, C++. Consequently, a
growing fraction of scientic code is also written in these
Recursive allocatable components as an alternative languages. For this reason, facilities for interoperation
to recursive pointers in derived types with C were added to Fortran 2003, and enhanced by
ISO/IEC technical specication 29113, which will be in-
The Final Draft international Standard (FDIS) is available corporated into Fortran 2015. This shift is also evident
as document N1830.[27] in the selection of applications between the SPEC CPU
2000 and SPEC CPU 2006 oating point benchmarks.
An important supplement to Fortran 2008 is the ISO
Technical Specication (TS) 29113 on Further Interop-
erability of Fortran with C,[28][29] which has been submit-
ted to ISO in May 2012 for approval. The specication 4 Language features
adds support for accessing the array descriptor from C
and allows ignoring the type and rank of arguments. The precise characteristics and syntax of Fortran 95 are
discussed in Fortran 95 language features.
It is now possible (and relatively easy) to write an entirely Such machine-specic extensions have either disappeared
portable program in Fortran, even without recourse to a over time or have had elements incorporated into the main
preprocessor. standards. The major remaining extension is OpenMP,
which is a cross-platform extension for shared memory
programming. One new extension, Coarray Fortran, is
6 Variants intended to support parallel programming.
Fortran 5 was marketed by Data General Corp in the late FOR TRANSIT was the name of a reduced version of
1970s and early 1980s, for the Nova, Eclipse, and MV the IBM 704 FORTRAN language, which was imple-
line of computers. It had an optimizing compiler that was mented for the IBM 650, using a translator program de-
quite good for minicomputers of its time. The language veloped at Carnegie in the late 1950s.[39] The following
most closely resembles Fortran 66. The name is a pun on comment appears in the IBM Reference Manual (FOR
the earlier Fortran IV. TRANSIT Automatic Coding System C28-4038, Copyright
1957, 1959 by IBM):
Fortran 6 or Visual Fortran 2001 was licensed to The permissible statements were:
Compaq by Microsoft. They have licensed Compaq Vi-
sual Fortran and have provided the Visual Studio 5 envi- Arithmetic assignment statements, e.g., a = b
ronment interface for Compaq v6 up to v6.1.[38]
GO to n
GO TO (n1 , n2 , ..., n ), i
6.4 Specic variants
IF (a) n1 , n2 , n3
Vendors of high-performance scientic computers (e.g.,
Burroughs, Control Data Corporation (CDC), Cray, PAUSE
Honeywell, IBM, Texas Instruments, and UNIVAC) STOP
added extensions to Fortran to take advantage of spe-
cial hardware features such as instruction cache, CPU DO n i = m1, m2
pipelines, and vector arrays. For example, one of
CONTINUE
IBMs FORTRAN compilers (H Extended IUP) had a
level of optimization which reordered the machine code END
instructions to keep multiple internal arithmetic units
busy simultaneously. Another example is CFD, a special READ n, list
variant of Fortran designed specically for the ILLIAC
PUNCH n, list
IV supercomputer, running at NASA's Ames Research
Center. IBM Research Labs also developed an extended DIMENSION V, V, V, ...
FORTRAN-based language called VECTRAN for pro-
cessing vectors and matrices. EQUIVALENCE (a,b,c), (d,c), ...
Object-Oriented Fortran was an object-oriented exten-
sion of Fortran, in which data items can be grouped into Up to ten subroutines could be used in one program.
objects, which can be instantiated and executed in paral- FOR TRANSIT statements were limited to columns 7
lel. It was available for Sun, Iris, iPSC, and nCUBE, but through 56, only. Punched cards were used for input and
is no longer supported. output on the IBM 650. Three passes were required to
11
translate source code to the IT language, then to com- The Fortran-95 Standard includes an optional Part 3
pile the IT statements into SOAP assembly language, and which denes an optional conditional compilation capa-
nally to produce the object program, which could then bility. This capability is often referred to as CoCo.
be loaded into the machine to run the program (using Many Fortran compilers have integrated subsets of the C
punched cards for data input, and outputting results onto preprocessor into their systems.
punched cards).
SIMSCRIPT is an application specic Fortran preproces-
Two versions existed for the 650s with a 2000 word mem-
sor for modeling and simulating large discrete systems.
ory drum: FOR TRANSIT I (S) and FOR TRANSIT II,
the latter for machines equipped with indexing registers The F programming language was designed to be a clean
and automatic oating point decimal (bi-quinary) arith- subset of Fortran 95 that attempted to remove the redun-
metic. Appendix A of the manual included wiring dia- dant, unstructured, and deprecated features of Fortran,
grams for the IBM 533 card reader/punch control panel. such as the EQUIVALENCE statement. F retains the
array features added in Fortran 90, and removes control
statements that were made obsolete by structured pro-
gramming constructs added to both Fortran 77 and For-
6.5 Fortran-based languages tran 90. F is described by its creators as a compiled,
structured, array programming language especially well
Prior to FORTRAN 77, a number of preprocessors were suited to education and scientic computing.[40]
commonly used to provide a friendlier language, with the
advantage that the preprocessed code could be compiled Lahey and Fujitsu teamed up to create Fortran for the
[41]
on any machine with a standard FORTRAN compiler. Microsoft .NET Framework. Silverfrost FTN95 is also
[42]
These preprocessors would typically support structured capable of creating .NET code.
programming, variable names longer than six charac-
ters, additional data types, conditional compilation, and
even macro capabilities. Popular preprocessors included
FLECS, iftran, MORTRAN, SFtran, S-Fortran, Ratfor,
7 Code examples
and Ratv. Ratfor and Ratv, for example, implemented
a C-like language, outputting preprocessed code in stan- For more details on this topic, see Wikibooks:
dard FORTRAN 66. Despite advances in the Fortran lan- Fortran/Fortran examples.
guage, preprocessors continue to be used for conditional
compilation and macro substitution. The following program illustrates dynamic memory al-
One of the earliest versions of FORTRAN, introduced in location and array-based operations, two features intro-
the 60s, was popularly used in colleges and universities. duced with Fortran 90. Particularly noteworthy is the ab-
Developed, supported, and distributed by the University sence of DO loops and IF/THEN statements in manipu-
of Waterloo, WATFOR was based largely on FORTRAN lating the array; mathematical operations are applied to
IV. A WATFOR student could submit their batch FOR- the array as a whole. Also apparent is the use of descrip-
TRAN job and, if there were no syntax errors, the pro- tive variable names and general code formatting that con-
gram would move straight to execution. This simplica- form with contemporary programming style. This exam-
tion allowed students to concentrate on their programs ple computes an average over data entered interactively.
syntax and semantics, or execution logic ow, rather than program average ! Read in some numbers and take
dealing with submission Job Control Language (JCL), the average ! As written, if there are no data points,
the compile/link-edit/execution successive process(es), an average of zero is returned ! While this may not
or other complexities of the mainframe/minicomputer be desired behavior, it keeps this example simple
environment. A down side to this simplied environment implicit none real, dimension(:), allocatable :: points
was that WATFOR was not a good choice for program- integer :: number_of_points real :: average_points=0.,
mers needing the expanded abilities of their host proces- positive_average=0., negative_average=0. write (*,*)
sor(s), e.g., WATFOR typically had very limited access Input number of points to average:" read (*,*) num-
to I/O devices. WATFOR was succeeded by WATFIV ber_of_points allocate (points(number_of_points))
and its later versions. write (*,*) Enter the points to average:" read (*,*)
program; s=0 i=1,n; s=s+1; stop i; s='s Stop points ! Take the average by summing points and
dividing by number_of_points if (number_of_points >
0) average_points = sum(points) / number_of_points
(line programing) ! Now form average over positive and negative points
LRLTRAN was developed at the Lawrence Radiation only if (count(points > 0.) > 0) then positive_average
Laboratory to provide support for vector arithmetic and = sum(points, points > 0.) / count(points > 0.) end
dynamic storage, among other extensions to support sys- if if (count(points < 0.) > 0) then negative_average
tems programming. The distribution included the LTSS = sum(points, points < 0.) / count(points < 0.) end
operating system. if deallocate (points) ! Print result to terminal write
12 10 REFERENCES
10 References
8 Humor [1] Chapel spec (Acknowledgements)" (PDF). Cray Inc.
2015-10-01. Retrieved 2016-01-14.
During the same Fortran standards committee meeting at [2] FORTRAN. American Heritage Dictionary of the En-
which the name FORTRAN 77 was chosen, a satirical glish Language (5 ed.). The Free Dictionary. 2011. Re-
technical proposal was incorporated into the ocial dis- trieved 2016-02-08.
tribution bearing the title Letter O Considered Harm-
ful". This proposal purported to address the confusion [3] John Backus. The history of FORTRAN I, II and III
that sometimes arises between the letter O and the nu- (PDF). Softwarepreservation.org. Retrieved 19 Novem-
ber 2014.
meral zero, by eliminating the letter from allowable vari-
able names. However, the method proposed was to elim- [4] Eugene Loh (18 June 2010). The Ideal HPC Program-
inate the letter from the character set entirely (thereby ming Language. Queue. Association of Computing Ma-
retaining 48 as the number of lexical characters, which chines. 8 (6).
the colon had increased to 49). This was considered
benecial in that it would promote structured program- [5] HPL A Portable Implementation of the High-
ming, by making it impossible to use the notorious GO Performance Linpack Benchmark for Distributed-
Memory Computers. Retrieved 2015-02-21.
TO statement as before. (Troublesome FORMAT state-
ments would also be eliminated.) It was noted that this [6] Softwarepreservation.org. Retrieved 22 September
might invalidate some existing programs but that most 2014.
of these probably were non-conforming, anyway.[43][44]
[7] Mindell, David, Digital Apollo, MIT Press, Cambridge
During the standards committee battle over whether the MA, 2008, p.99
minimum trip count for the FORTRAN 77 DO state-
ment should be zero (allowing no execution of the block) [8] The Fortran I Compiler The Fortran I compiler was the
or one (the plunge-ahead DO), another facetious alter- rst major project in code optimization. It tackled prob-
native was proposed (by Loren Meissner) to have the min- lems of crucial importance whose general solution was an
imum be two since there is no need for a loop if it is only important research focus in compiler technology for sev-
executed once. eral decades. Many classical techniques for compiler anal-
ysis and optimization can trace their origins and inspira-
When assumed-length arrays were being added, there was tion to the Fortran I compiler.
a dispute as to the appropriate character to separate up-
per and lower bounds. In a comment examining these [9] Fortran creator John Backus dies. msnbc.com. Re-
arguments, Dr. Walt Brainerd penned an article entitled trieved 19 November 2014.
Astronomy vs. Gastroenterology because some propo- [10] Backus, J. W.; H. Stern, I. Ziller, R. A. Hughes, R.
nents had suggested using the star or asterisk ("*"), while Nutt, R. J. Beeber, S. Best, R. Goldberg, L. M. Haibt,
others favored the colon (":"). H. L. Herrick, R. A. Nelson, D. Sayre, P. B. Sheridan
In Fortran 77, variable names beginning with the let- (1957). The FORTRAN Automatic Coding System.
Western joint computer conference: Techniques for relia-
ters IN had a default type of integer, while variables
bility. Los Angeles, California: Institute of Radio Engi-
starting with any other letters defaulted to real, although
neers, American Institute of Electrical Engineers, ACM:
programmers could override the defaults with an explicit 188198. doi:10.1145/1455567.1455599. Online at ,
declaration.[45] This led to the joke: In Fortran, GOD is
REAL (unless declared INTEGER). [11] Applied Science Division and Programming Research
Department, International Business Machines Corpora-
tion (October 15, 1956). The FORTRAN Automatic Cod-
ing System for the IBM 704 EDPM : Programmers Refer-
9 See also ence Manual (PDF). pp. 1920.
[14] Fortran II User Manual (PDF). Bitsavers.org. Retrieved [35] Pasacho, Jay M. (April 1984). Scientists: Fortran vs.
19 November 2014. Modula-2. BYTE (letter). p. 404. Retrieved 6 February
2015.
[15] Ibibilio.org. Ibiblio.org. Retrieved 15 September 2014.
[36] Galperin, Boris (1993). 26. Large Eddy Simulation of
[16] Haines, L. H. (1965). Serial compilation and the 1401 Complex Engineering and Geophysical Flows. London:
FORTRAN compiler. IBM Systems Journal. 4 (1): 73 Cambridgey. p. 573. ISBN 0-521-43009-7.
80. doi:10.1147/sj.41.0073. This article was reprinted,
edited, in both editions of Lee, John A. N. (1967). [37] Healy, MJR (1968). Towards FORTRAN VI. Ad-
Anatomy of a Compiler. Van Nostrand Reinhold. vanced scientic Fortran by CDC. CDC. pp. 169172.
Retrieved 10 April 2009.
[17] McCracken, Daniel D. (1965). Preface. A Guide to
FORTRAN IV Programming. New York: Wiley. p. v. [38] third party release notes for Fortran v6.1. Cs-
ISBN 0-471-58281-6. software.com. 15 March 2011. Retrieved 19 November
2014.
[18] FORTRAN Compilers and Loaders. Chilton-
programming.org.uk. Retrieved 19 November 2014. [39] Internal Translator (IT) A Compiler for the IBM 650,
by A. J. Perlis, J. W. Smith, and H. R. Van Zoeren, Com-
[19] Mil-std-1753. DoD Supplement to X3.9-1978. United putation Center, Carnegie Institute of Technology
States Government Printing Oce.
[40] F Programming Language Homepage. Fortran.com.
[20] Posix 1003.9-1992. POSIX FORTRAN 77 Language In- Retrieved 19 November 2014.
terface Part 1: Binding for System Application Program
[41] Fortran for .NET Language System.
Interface API. IEEE. Retrieved 19 November 2014.
[42] FTN95: Fortran 95 for Windows. Silverfrost.com. Re-
[21] Fortran Variable Declarations. Compaq Fortran. Texas, trieved 19 November 2014.
Huston, US: Compaq Computer Corporation. 1999. Re-
trieved 19 November 2014. The form CHARACTER*(*) [43] X3J3 post-meeting distribution for meeting held at
is an obsolescent feature in Fortran 95. Brookhaven National Laboratory in November 1976.
[22] Fortran 95 Reference. Gnu.Org. Retrieved 10 May [44] The obliteration of O, Computer Weekly, 3 March
2014. 1977.
[23] Fortran 2003- Last Working Draft. Gnu.Org. Retrieved [45] Rules for Data Typing (FORTRAN 77 Language Refer-
10 May 2014. ence)". docs.oracle.com. Retrieved 2016-09-29.
Pigott, Diarmuid (2006). FORTRAN Backus et ECMA Standard on FORTRAN (PDF). European
al high-level compiler (Computer Language)". The Computer Manufacturers Association. April 1965.
Encyclopedia of Computer Languages. Murdoch Retrieved 2014-11-17.
University. Archived from the original on 8 October
2009. Retrieved 5 May 2010. FORTRAN 77 4.0 Reference Manual (PDF). Sun
Microsystems, Inc. 1995. Retrieved 2014-11-17.
Roberts, Mark L.; Griths, Peter D. (1985).
FORTRAN Coding Form (PDF). IBM. Retrieved
Design Considerations for IBM Personal Computer
2014-11-17.
Professional FORTRAN, an Optimizing Compiler
(PDF). IBM Systems Journal. IBM. 24 (1): 4960. IBM System/360 and System/370 Fortran IV Lan-
doi:10.1147/sj.241.0049. guage (PDF). International Business Machines.
May 1974. Retrieved 2014-11-17.
Core language standards
Goerz, Michael (2014). Modern Fortran Reference
Card (PDF). Retrieved 2014-12-14.
Ansi x3.9-1966. USA Standard FORTRAN (PDF).
American National Standards Institute. Informally
Textbooks
known as FORTRAN 66.
Ansi x3.9-1978. American National Standard Adams, Jeanne C.; Brainerd, Walter S.; Hendrick-
Programming Language FORTRAN. American Na- son, Richard A.; Maine, Richard E.; Martin, Jeanne
tional Standards Institute. Also known as ISO 1539- T.; Smith, Brian T. (2009). The Fortran 2003 Hand-
1980, informally known as FORTRAN 77. book (1st ed.). Springer. ISBN 978-1-84628-378-9.
ANSI X3.198-1992 (R1997) / ISO/IEC 1539:1991. Akin, Ed (2003). Object Oriented Programming
American National Standard Programming Lan- via Fortran 90/95 (1st ed.). Cambridge University
guage Fortran Extended. American National Stan- Press. ISBN 0-521-52408-3.
dards Institute / ISO/IEC. Archived from the orig-
Chapman, Stephen J. (2007). Fortran 95/2003 for
inal on 2002-05-01. Informally known as Fortran
Scientists and Engineers (3rd ed.). McGraw-Hill.
90.
ISBN 978-0-07-319157-7.
ISO/IEC 1539-1:1997. Information technology Chivers, Ian; Sleightholme, Jane (2015). Intro-
Programming languages Fortran Part 1: Base duction to Programming with Fortran (3rd ed.).
language (PDF). Informally known as Fortran 95. Springer. ISBN 978-3-319-17700-7.
There are a further two parts to this standard. Part
1 has been formally adopted by ANSI. Etter, D. M. (1990). Structured FORTRAN 77
for Engineers and Scientists (3rd ed.). The Ben-
ISO/IEC 1539-1:2004. Information technology jamin/Cummings Publishing Company, Inc. ISBN
Programming languages Fortran Part 1: Base 0-8053-0051-1.
language (PDF). Informally known as Fortran 2003.
Ellis, T. M. R.; Phillips, Ivor R.; Lahey, Thomas M.
ISO/IEC 1539-1:2010 (Final Draft International (1994). Fortran 90 Programming (1st ed.). Addison
Standard). Information technology Programming Wesley. ISBN 0-201-54446-6.
languages Fortran Part 1: Base language (PDF).
Informally known as Fortran 2008. Kupferschmid, Michael (2002). Classical Fortran:
Programming for Engineering and Scientic Applica-
tions. Marcel Dekker (CRC Press). ISBN 0-8247-
Related standards
0802-4.
Kneis, Wilfried (October 1981). Draft stan- McCracken, Daniel D. (1961). A Guide to FOR-
dard Industrial Real-Time FORTRAN". ACM TRAN Programming. New York: Wiley. LCCN
SIGPLAN Notices. ACM Press. 16 (7): 4560. 61016618.
doi:10.1145/947864.947868. ISSN 0362-1340.
Metcalf, Michael; John Reid; Malcolm Cohen
ISO 8651-1:1988 Information processing systems (2011). Modern Fortran Explained. Oxford Univer-
Computer graphics Graphical Kernel System (GKS) sity Press. ISBN 0-19-960142-9.
language bindings Part 1: FORTRAN. Geneva, Nyho, Larry; Sanford Leestma (1995). FORTRAN
Switzerland: ISO. 1988. 77 for Engineers and Scientists with an Introduction
to Fortran 90 (4th ed.). Prentice Hall. ISBN 0-13-
Other reference material 363003-X.
15
12 External links
ISO/IEC JTC1/SC22/WG5 the ocial home of
Fortran standards
Fortran Standards Documents GFortran standards
13.2 Images
File:4.3_BSD_UWisc_VAX_Emulation_f77_Manual.png Source: https://upload.wikimedia.org/wikipedia/commons/b/b0/4.3_BSD_
UWisc_VAX_Emulation_f77_Manual.png License: CC0 Contributors: Own work Original artist: Huihermit
File:8bit-dynamiclist_(reversed).gif Source: https://upload.wikimedia.org/wikipedia/commons/c/cc/8bit-dynamiclist_%28reversed%
29.gif License: CC-BY-SA-3.0 Contributors: This le was derived from: 8bit-dynamiclist.gif
Original artist: Seahen, User:Rezonansowy
File:Folder_Hexagonal_Icon.svg Source: https://upload.wikimedia.org/wikipedia/en/4/48/Folder_Hexagonal_Icon.svg License: Cc-by-
sa-3.0 Contributors: ? Original artist: ?
File:FortranCardPROJ039.agr.jpg Source: https://upload.wikimedia.org/wikipedia/commons/5/58/FortranCardPROJ039.agr.jpg Li-
cense: CC BY-SA 2.5 Contributors: I took this picture of an artifact in my possession. The card was created in the late 1960s or early 1970s
and has no copyright notice. Original artist: Arnold Reinhold
File:FortranCodingForm.png Source: https://upload.wikimedia.org/wikipedia/commons/1/18/FortranCodingForm.png License: Public
domain Contributors: Transferred from en.wikipedia to Commons by Sreejithk2000 using CommonsHelper. Original artist: Agateller at
English Wikipedia
File:Fortran_acs_cover.jpeg Source: https://upload.wikimedia.org/wikipedia/commons/0/07/Fortran_acs_cover.jpeg License: Public
domain Contributors: en:File:Fortran acs cover.jpeg Original artist: original uploader was en:User:Muhandis
File:Ftn-elim-1240x1709.jpg Source: https://upload.wikimedia.org/wikipedia/commons/e/ee/Ftn-elim-1240x1709.jpg License: CC
BY-SA 3.0 Contributors: Own work (including own program) Original artist: Phrontis
13.3 Content license 17