FORTRAN IV
IBM's early-1960s revision of FORTRAN that removed machine-dependent statements, added LOGICAL data and the logical IF, and became the basis of the first American Standard FORTRAN in 1966.
Created by IBM
FORTRAN IV is the version of FORTRAN that IBM developed in the early 1960s to replace FORTRAN II. It removed the machine-specific statements of its predecessors, introduced the LOGICAL data type and the logical IF statement, and replaced FORTRAN II’s punched-card “mode” markers with proper type declarations. For most of the 1960s it was the closest thing scientific computing had to a common language. When the American Standards Association published the first official FORTRAN standard in 1966, it was based on FORTRAN IV. That standard, X3.9-1966, became known as FORTRAN 66, but many programmers simply kept calling it FORTRAN IV.
For the language family as a whole, see Fortran. For the standard that followed, see FORTRAN 77.
History & Origins
From FORTRAN II to FORTRAN IV
The original FORTRAN (1957) and FORTRAN II (1958) were tied closely to the IBM 704 and 709 family. Many FORTRAN II statements referred directly to hardware: READ INPUT TAPE, WRITE OUTPUT TAPE, IF ACCUMULATOR OVERFLOW, IF (SENSE SWITCH i) and SENSE LIGHT. Some data types were not set by declarations at all. A programmer marked them by punching a code in column 1 of the card, such as D for double precision or I for complex arithmetic. Function names were 4 to 7 characters long and had to end in F.
IBM started work on FORTRAN IV in 1961 because customers asked for it. (IBM had developed a FORTRAN III in 1958, but it was never released as a product.) The new language was designed to depend less on any particular machine. A list of early FORTRAN implementations published in the Annals of the History of Computing in January 1984 dates IBM’s 7090/7094 FORTRAN IV to 1961, a 7040/7044 version to 1962, and a version for the IBM 7030 “Stretch” to 1963. Most histories give 1962 as the year FORTRAN IV was released. The exact first-ship date is hard to pin down. The earliest IBM manual found for this page, the 7090/7094 FORTRAN IV Language (Form C28-6274-1), is dated May 1963 and calls itself “a major revision of the previous edition,” so an earlier edition already existed.
On the 7090/7094, FORTRAN IV was not a standalone product. It was the FORTRAN compiler (“IBFTC”) inside the IBJOB processor, which ran under the IBSYS operating system alongside the MAP macro assembler.
What IBM changed
Appendix C of the 1963 manual lists the differences from FORTRAN II:
| FORTRAN II | FORTRAN IV |
|---|---|
Column-1 mode punch D (double precision) | DOUBLE PRECISION type statement |
Column-1 mode punch I (complex) | COMPLEX type statement |
F-card | EXTERNAL statement |
Function names of 4–7 characters ending in F | Names of 1–6 characters; a final F has no special meaning |
READ INPUT TAPE i,n,list | READ (i,n) list |
WRITE OUTPUT TAPE i,n,list | WRITE (i,n) list |
IF ACCUMULATOR OVERFLOW n1,n2 | CALL OVERFL (j) |
IF DIVIDE CHECK n1,n2 | CALL DVCHK (j) |
IF (SENSE SWITCH i) n1,n2 | CALL SSWTCH (i,j) |
SENSE LIGHT i | CALL SLITE (i) |
The manual also lists new statements (DATA, BLOCK DATA and the LOGICAL type) and drops FREQUENCY, READ DRUM and WRITE DRUM. FORTRAN II’s “implicit multiplication”, a side effect of its expression translator that let K(...) mean multiplication, is no longer allowed.
The change to I/O mattered most. In FORTRAN II, tape and drum operations were separate statements. In FORTRAN IV, every device is a numbered unit used through the same READ and WRITE statements. Machine-specific checks like overflow and sense switches became ordinary subroutine calls, which other vendors could supply or leave out.
Design Philosophy
FORTRAN IV was not a redesign. It kept the fixed-column card layout, the arithmetic IF, the DO loop, and the rule that variables starting with I through N are integers. What it changed was where machine dependence lived. Hardware-specific behavior moved out of the language and into library subroutines, and the core of the language became small enough for other manufacturers to implement. That is why FORTRAN IV became the de facto standard that the 1966 standard was built on.
Key Features
Data types
FORTRAN IV supported five data types, all declared with type statements:
INTEGERREALDOUBLE PRECISIONCOMPLEXLOGICAL(new, with the constants.TRUE.and.FALSE.)
Undeclared variables still followed the implicit rule. Names beginning with I, J, K, L, M or N were integers, and all others were real. Typed functions could be declared directly, as in LOGICAL FUNCTION or DOUBLE PRECISION FUNCTION.
There was no character type. Text was stored as Hollerith data, characters packed into numeric variables, and written in FORMAT statements as a count followed by H. For example, 13H HELLO, WORLD means “the next 13 characters”. A proper CHARACTER type did not arrive in standard Fortran until FORTRAN 77.
Logical expressions and the logical IF
FORTRAN II had only the three-way arithmetic IF, which jumps to one of three labels depending on whether an expression is negative, zero or positive. FORTRAN IV kept it and added the logical IF, which runs a single statement when a condition is true. Conditions use relational operators written with dots (.LT., .LE., .EQ., .NE., .GT., .GE.) and the logical operators .AND., .OR. and .NOT.:
| |
Under the 7090/7094 manual, the statement controlled by a logical IF could be any executable statement except a DO or another logical IF. There was still no ELSE and no block IF. Structured conditionals came with FORTRAN 77.
Program structure
A FORTRAN IV program consisted of a main program plus separately compiled SUBROUTINE and FUNCTION subprograms. Data was shared through COMMON blocks, which could now carry array dimensions, and storage could be overlaid with EQUIVALENCE. The new BLOCK DATA subprogram was the only standard way to set initial values in COMMON.
Fixed-form source
Source code kept the punched-card layout used by every early FORTRAN:
| Columns | Meaning |
|---|---|
| 1 | C marks a comment line |
| 1–5 | Statement label |
| 6 | Any non-blank, non-zero character marks a continuation line |
| 7–72 | Statement text |
| 73–80 | Ignored (used for card sequence numbers) |
Blanks were ignored everywhere outside Hollerith fields, so GO TO, GOTO and G O T O all meant the same thing.
Hello, World!
A program written in typical FORTRAN IV style:
| |
Unit 6 was the usual line printer. The first character of each output record, here the blank inside the Hollerith string, was a carriage-control character, and the printer consumed it rather than printing it. GCC’s gfortran still compiles this kind of source in legacy mode (gfortran -std=legacy hello.f), though modern runtimes print the carriage-control character instead of acting on it.
Implementations
FORTRAN IV was IBM’s language, but by the mid-1960s nearly every major manufacturer of scientific computers offered its own version. The Annals list includes FORTRAN IV compilers for the UNIVAC 1107 and UNIVAC III (Computer Sciences Corporation, 1963), the Philco 2000 (1964), the RCA 601 (1964), the ICT 1900 series (1965), the SDS 9300 (1966), RCA Spectra (1966) and Philips (1967), among others. Dialects differed in their extensions, so “FORTRAN IV” usually meant “the vendor’s FORTRAN IV” more than a single exact language.
IBM System/360
When IBM introduced System/360, it offered FORTRAN IV at several levels. The lettered levels roughly tracked how much main memory each compiler needed: Basic Programming Support and Basic Operating System FORTRAN IV, FORTRAN IV (E), FORTRAN IV (G) and the optimizing FORTRAN IV (H). IBM’s 1966 System/360 FORTRAN IV Language manual (Form C28-6515) states that the language “is compatible with and encompasses” the ASA FORTRAN standard. The manual also lists features that IBM’s earlier FORTRAN IV lacked. Some of them went beyond the ASA standard, including mixed-mode expressions, the IMPLICIT statement, explicit storage lengths such as REAL*8, literal and hexadecimal constants, the T format code and NAMELIST-style “named I/O lists”. Others, such as adjustable array dimensions and the G format code, were also part of the 1966 standard. The FORTRAN H optimizer was described by Edward Lowry and C. W. Medlock in “Object Code Optimization” (Communications of the ACM, January 1969), one of the early published accounts of a production optimizing compiler.
Minicomputers
DEC’s FORTRAN IV compilers carried the language onto smaller machines. Surviving manuals include a PDP-10 FORTRAN IV Programming Manual (August 1969), Fortran IV for the PDP-11 under DOS (May 1971), and FORTRAN IV-PLUS for the PDP-11 and VAX-11 (VAX-11 FORTRAN IV-PLUS User’s Guide, August 1978). Hewlett-Packard, Data General and others offered FORTRAN IV on their minicomputers as well.
WATFOR and WATFIV
Batch compile-link-go cycles were slow and expensive for student work. In summer 1965, four undergraduates at the University of Waterloo wrote WATFOR, a one-pass FORTRAN IV compiler for the IBM 7040 that compiled and ran programs in memory with detailed error messages. A System/360 version followed in early 1967. WATFIV (1968) added CHARACTER variables, formatted writes to memory and direct-access I/O. For a generation of students, “FORTRAN IV” meant WATFOR or WATFIV.
Evolution: FORTRAN 66 and Beyond
In the early 1960s the American Standards Association (later ANSI) formed a committee to standardize FORTRAN. In March 1966 it approved two standards: X3.9-1966 FORTRAN, based on FORTRAN IV, and a separate Basic FORTRAN standard for a smaller language based on FORTRAN II without its machine-dependent features. The full standard became known as FORTRAN 66 and covered the core of FORTRAN IV:
INTEGER,REAL,DOUBLE PRECISION,COMPLEXandLOGICALtypes- Main programs,
SUBROUTINE,FUNCTIONandBLOCK DATAprogram units COMMON,DIMENSION,EQUIVALENCEandDATA- Arithmetic and logical
IF, computed and assignedGO TO, andDOloops - Unit-based
READ/WRITE,REWIND,BACKSPACEandENDFILE - Hollerith constants and identifiers of up to six characters
Vendor extensions like IBM’s IMPLICIT were left out of the 1966 standard. Some were picked up later in FORTRAN 77.
Because FORTRAN IV had no structured control flow, programmers built workarounds. The best known is Brian Kernighan’s Ratfor (1974), a preprocessor that added if/else, while and braces and produced FORTRAN 66 as output. FORTRAN 77, published as ANSI X3.9-1978, replaced the 1966 standard. It added the block IF, the CHARACTER type and a modern file I/O model, while keeping almost all FORTRAN IV code valid.
Current Relevance
FORTRAN IV is no longer used for new work. Its successors kept backward compatibility, so a great deal of 1960s and 1970s FORTRAN IV-era code survives inside later Fortran programs and numerical libraries. Modern compilers can still build much of it. GCC’s gfortran, for example, accepts Hollerith constants, arithmetic IF and other obsolescent features under -std=legacy. Original FORTRAN IV environments, such as IBM 7094 IBSYS, OS/360 with FORTRAN G and H, and DEC TOPS-10 and RSX-11, can also be run in simulators like SIMH and Hercules, and bitsavers.org preserves many of the original vendor manuals.
Why It Matters
FORTRAN IV turned FORTRAN from an IBM 704-family product into a language that many manufacturers could implement. Moving hardware-specific behavior into subroutine calls, replacing card-column type codes with declarations, and adding logical expressions together made the language portable enough to standardize. FORTRAN 66, the result, was the first standardized version of FORTRAN. For roughly 15 years, from the IBM 7090 era to the arrival of FORTRAN 77, FORTRAN IV and its dialects were the main language of scientific and engineering programming, and the language in which many physicists, engineers and computer science students wrote their first programs.
Timeline
Notable Uses & Legacy
SPICE circuit simulator
SPICE1, the first version of the Berkeley circuit simulator that became the foundation of analog circuit simulation, was written in FORTRAN IV and ran on the University of California, Berkeley's CDC 6400. It was first presented in 1973.
Colossal Cave Adventure
Will Crowther's 1976 game and Don Woods's 1977 expansion were written for the PDP-10 and relied on features specific to DECsystem-10 FORTRAN IV, which made early ports to other machines difficult.
WATFOR and WATFIV at universities
The University of Waterloo's FORTRAN IV teaching compilers ran student jobs in a single compile-and-go pass. More than 75 institutions installed the original WATFOR on their IBM 7040s, and WATFIV was used for teaching from the late 1960s into the mid-1980s.
IBM System/360 scientific computing
IBM's System/360 FORTRAN IV compilers (E, G and H levels) were reportedly the standard tool for scientific and engineering programs on System/360 from the mid-1960s. The optimizing FORTRAN H compiler was the subject of an early published account of compiler optimization (Lowry and Medlock, *Communications of the ACM*, 1969).
Language Influence
Influenced By
Influenced
Running Today
Run examples using the official Docker image:
docker pull gcc:latestExample usage:
docker run --rm -v $(pwd):/app -w /app gcc:latest sh -c 'gfortran -std=legacy -o hello hello.f && ./hello'