Est. 1958 Intermediate

FORTRAN II

IBM's 1958 revision of FORTRAN for the IBM 704 that added separately compiled SUBROUTINE and FUNCTION subprograms, CALL, RETURN and COMMON, making modular Fortran programming possible for the first time.

Created by John Backus, Irving Ziller and Robert Nelson (IBM Programming Research)

Paradigm Imperative, Procedural
Typing Static, implicit by first letter (I-N fixed point, otherwise floating point)
First Appeared 1958
Latest Version No single final version; IBM was still revising 7090/7094 FORTRAN II manuals in 1964

FORTRAN II is the second version of IBM’s FORTRAN, distributed for the IBM 704 in the spring of 1958, about a year after the original compiler shipped. Its main contribution was a single idea: a program no longer had to be one monolithic deck compiled in one long run. FORTRAN II introduced user-written SUBROUTINE and FUNCTION subprograms, the CALL and RETURN statements, shared COMMON storage, and a loader that could link separately compiled pieces, including pieces written in assembly language. The basic structure of a Fortran program as a main program plus a library of separately compiled procedures starts here.

For the language family as a whole, see Fortran. For the version that replaced it, see FORTRAN IV.

History & Origins

The problem with FORTRAN I

The first FORTRAN compiler was delivered for the IBM 704 in 1957. It was a success. In his history of the project, John Backus quotes a November 1958 report saying that by the fall of 1958 there were some 60 installations with about 66 704s and that “more than half the machine instructions for these machines are being produced by FORTRAN.”

FORTRAN I had a structural weakness, though. An application was a single FORTRAN program, compiled in one long run. A small change anywhere meant recompiling everything, and there was no way to write your own subroutines in FORTRAN and combine them with others. In practice, as Backus and William Heising put it in 1964, an application had to be done entirely in FORTRAN or not at all.

Designing FORTRAN II

According to Backus’s History of FORTRAN I, II, and III (presented at the first ACM History of Programming Languages conference in 1978), the team began planning corrections in the early fall of 1957, while the original compiler was still being debugged in the field. A document dated September 25, 1957, “Proposed Specifications for FORTRAN II for the 704”, named two needs: better diagnostics with clearer messages about source errors, and a way to define subroutines.

The surviving drafts, preserved by the Computer History Museum, show the design changing as it went. In the August and September 1957 versions there is no CALL keyword. A subroutine is invoked by writing its name followed by its arguments, and the September draft opens a subroutine with a SUBROUTINE DEFINITION statement. The November 18, 1957 version introduces COMMON in place of an earlier UPPER statement.

Backus writes that FORTRAN II “was designed mostly by Nelson, Ziller, and myself.” Grace E. Mitchell, who had written the FORTRAN Programmer’s Primer, programmed most of the new code. Backus notes that she delivered it ahead of schedule, which he calls “the most unusual feature.” She was helped by Bernyce Brady and LeRoy May, and Peter Sheridan and Roy Nutt made the changes to their own sections of the compiler. Backus gives the release simply as “FORTRAN II was distributed in the spring of 1958.”

FORTRAN III: the version that wasn’t

While FORTRAN II was under development, Irving Ziller designed a more ambitious system he called FORTRAN III. It let programmers mix 704 assembly instructions with FORTRAN statements, using FORTRAN variables as addresses. It also had Boolean expressions, function and subroutine names as arguments, and an A format code for alphanumeric data. According to Backus, the machine-specific inline assembly “assured the demise of FORTRAN III along with that of the 704.” It reached about 20 mostly IBM installations from the winter of 1958-59 but was never generally distributed. Several of its ideas returned in FORTRAN IV.

Design Philosophy

FORTRAN II kept almost everything about FORTRAN I: the punched-card layout, the arithmetic IF, the DO loop, and the rule that names beginning with I through N are fixed point (integer) and all others floating point. What changed was the unit of compilation.

The key piece was the Binary Symbolic Subroutine (BSS) loader. FORTRAN II kept symbolic names in the relocatable binary output of each compiled subprogram, so the loader could resolve references between separately compiled pieces at load time. Backus notes that the September 1957 proposal already pointed out that “mixtures of FORTRAN-coded and assembly-coded relocatable binary programs could be loaded and run together.” A routine that was awkward in FORTRAN could be written by hand in assembly and called like any other subprogram.

Dennis Hamilton, in a 2005 note quoted by the Computer History Museum’s FORTRAN project, summed up the effect: “In Fortran I programs were one giant file and there was no modularization structure. That small change in Fortran II was earthshaking in terms of software development.”

Key Features

New statements

The 1958 IBM 704 reference manual (Form C28-6000-2) was a 63-page supplement to the original FORTRAN manual. It described the new CALL, SUBROUTINE, FUNCTION, COMMON and END statements and the BSS loader. Along with RETURN, these six statements are what made FORTRAN II different:

StatementPurpose
SUBROUTINE name (args)Begins a subprogram that returns results through its arguments
FUNCTION name (args)Begins a single-valued subprogram called from within an expression
CALL name (args)Invokes a SUBROUTINE
RETURNReturns control to the caller
COMMON listPlaces variables in storage shared between programs
ENDMarks the end of a source program, so several can be compiled in one run

IBM’s 709 FORTRAN Automatic Coding System manual, which describes the same language on the 709, counts 38 statement types in all.

Subprogram rules

The 709 manual spells out the naming rules. A FUNCTION or SUBROUTINE name was 1 to 6 characters, beginning with a letter. A function’s name had to start with I through N if, and only if, it returned a fixed-point value. Its final character could not be F if the name was longer than three characters, because names ending in F were reserved for the built-in and library functions such as SINF, SQRTF and ABSF. The arguments in a CALL had to match the subprogram’s dummy arguments in number, order and mode. Array arguments had to be declared with the same dimensions in both programs. A CALL could also pass alphanumeric text written as a Hollerith constant (9HEND POINT), but only to hand-coded routines.

FORTRAN II had no recursion. The 704 had no hardware stack, and a subprogram could not call itself.

What stayed machine-specific

FORTRAN II was still a 704-family language, and many statements referred directly to the hardware:

  • READ INPUT TAPE, WRITE OUTPUT TAPE, READ TAPE, WRITE TAPE, READ DRUM and WRITE DRUM
  • IF ACCUMULATOR OVERFLOW, IF QUOTIENT OVERFLOW and IF DIVIDE CHECK
  • SENSE LIGHT, IF (SENSE LIGHT) and IF (SENSE SWITCH)
  • FREQUENCY, a hint to the optimizer about how often each branch would be taken
  • PAUSE n and STOP n, which halted the machine and displayed an octal number on the console

Even END carried hardware settings. On the 709, END (I1, I2, I3, I4, I5) told the compiler how to treat console sense switches 1 to 5 during compilation.

On the IBM 7090/7094, FORTRAN II gained double-precision, complex and Boolean arithmetic. These were not declared with types. Instead, a code in column 1 of the card changed the meaning of the whole statement: D for double precision, I for complex, and B for Boolean, where +, * and - meant or, and and complement. FORTRAN IV later replaced these card codes with DOUBLE PRECISION, COMPLEX and LOGICAL type statements and moved the hardware tests into library subroutines.

Source layout

FORTRAN II used the fixed card format inherited from FORTRAN I:

ColumnsMeaning
1C marks a comment card (on the 7090, also D, I or B mode codes)
1-5Statement number
6Non-zero character marks a continuation card (up to nine)
7-72Statement text
73-80Identification, ignored by the compiler

Blanks outside Hollerith fields were ignored.

Example: a separately compiled subroutine

The following sketch shows the kind of program FORTRAN II made possible: a main program and a subroutine, compiled separately and sharing data through COMMON.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
C     MAIN PROGRAM - READS N VALUES AND PRINTS THEIR TOTAL
      DIMENSION A(100)
      COMMON A, N
      READ 10, N, (A(I), I = 1, N)
   10 FORMAT (I3/(12F6.2))
      CALL SUM (TOTAL)
      PRINT 20, TOTAL
   20 FORMAT (7H TOTAL=, F10.2)
      STOP
      END
1
2
3
4
5
6
7
8
9
C     SUBPROGRAM - COMPILED ON ITS OWN AND LINKED BY THE BSS LOADER
      SUBROUTINE SUM (S)
      DIMENSION A(100)
      COMMON A, N
      S = 0.0
      DO 5 I = 1, N
    5 S = S + A(I)
      RETURN
      END

N and I are fixed point because of their first letters. A, S and TOTAL are floating point. There are no type declarations.

Hello, World!

1
2
3
4
5
C     HELLO WORLD IN FORTRAN II STYLE
      PRINT 10
   10 FORMAT (13H HELLO, WORLD)
      STOP
      END

On the 704, PRINT wrote to the online printer. Text could appear only as a Hollerith field: 13H means “the next 13 characters.” The 704’s character set had no exclamation mark. GCC’s gfortran should accept this program with -std=legacy, because it uses none of the hardware-specific statements, but the example has not been compiled for this page.

Implementations

FORTRAN II spread well beyond the 704. The main implementations are listed below. Dates in parentheses come from the BCS Fortran Specialist Group’s list of FORTRAN implementations from 1957 to 1967. That list is based on one published in the Annals of the History of Computing in 1984 and has had a few later corrections.

  • IBM 704 (1958): Backus and colleagues, with Mitchell, Sheridan, Brady and May
  • IBM 709 and 7090/7094: The 709 translator was built on the same procedures as the 704 FORTRAN II translator. IBM’s 7090/7094 FORTRAN II ran either under its own FORTRAN Monitor System or under the IBSYS basic monitor, and the manual was still being revised in 1963 and 1964.
  • IBM 1620: IBM’s 1620 FORTRAN II Programming System manual carries copyright dates from 1961. A disk-based FORTRAN II-D ran under the 1620 Monitor I system.
  • RCA 301 (1961) and RCA 3301 (1964)
  • Remington Rand UNIVAC LARC (1961-62, Computer Sciences Corporation)

Other vendors followed with their own FORTRAN II compilers. Surviving manuals include DEC’s PDP-6 FORTRAN II Language Programming Manual (1965), Scientific Data Systems’ 900-series FORTRAN II documents, and FORTRAN II manuals for the Computer Control Company DDP-24 and the Raytheon (Packard Bell) 250. A listing headed “FORTRAN II COMPILER PASS 1, D. E. KNUTH 1962” for the UNIVAC Solid State 80/90 also survives.

Evolution

By 1961, as Backus and Heising wrote in 1964, FORTRAN II was so widely accepted that IBM began designing an expanded language with new compilers. The result was FORTRAN IV, released for the 7090/7094 around 1962. It dropped FORTRAN II’s machine-specific statements, replaced the column-1 mode codes with type declarations, and added the LOGICAL type and the logical IF. Backus himself was not entirely happy with the result. In his 1978 history he wrote that he had urged IBM to build a fast non-optimizing compiler for debugging alongside an optimizing one. In his view, the original FORTRAN IV compiler that IBM built instead was “not nearly as fast as later compilers like WATFOR … nor did it produce as good code as FORTRAN II.”

When IBM introduced System/360, it offered no FORTRAN II compiler for it. Instead, IBM published the FORTRAN II Language Conversion Program (Form C28-6560-0, 1965). It accepted source in the “current IBM FORTRAN II languages” of the 1401, 1410, 1620, 7070, 705, 7080 and 7090/7094, converted it to one of the System/360 FORTRAN IV levels where possible, and flagged statements it could not convert.

FORTRAN II also left a mark on standardization. In March 1966 the American Standards Association approved two standards: X3.9-1966 FORTRAN, based on FORTRAN IV (later called FORTRAN 66), and X3.10-1966 Basic FORTRAN, a smaller language based on FORTRAN II without its machine-dependent features.

Its influence reached beyond Fortran too. According to accounts that draw on Thomas Kurtz’s history of BASIC, Dartmouth BASIC (1964) was heavily patterned on FORTRAN II. It took one statement per line, numbered statements as branch targets, and a number of similar or identical commands.

Current Relevance

FORTRAN II has not been used for new work in decades. Its core ideas survive in every later Fortran: separately compiled subroutines and functions, CALL/RETURN, and COMMON (now considered obsolescent but still accepted). Simple FORTRAN II programs that avoid the hardware-specific statements can usually be built with a modern compiler in legacy mode. Programs that use READ INPUT TAPE, sense switches or column-1 mode codes need rewriting.

The original software has been preserved. Paul McJones’s “History of FORTRAN and FORTRAN II” project at the Computer History Museum holds design memos from 1957, IBM manuals, a three-volume listing of the final 704 FORTRAN II compiler from the Smithsonian’s collection, and tape images of 709/7090 FORTRAN II digitized by Paul Pierce. The project also documents IBM 7090/7094 emulators by Dave Pitts and Rob Storey, the latter shipping with system tapes and scripts that demonstrate early languages. Pitts’s emulator has been used to compile programs with FORTRAN II.

Why It Matters

FORTRAN I proved that a compiler could produce efficient code. FORTRAN II made the language practical for large programs. Separate compilation, linkable subprograms and shared COMMON storage meant a team could divide an application among programmers, reuse tested routines, and fix one subroutine without recompiling the rest. Because the loader treated FORTRAN and assembly subprograms the same way, programmers no longer had to choose between them. These changes, made in 1958, are the basis of the subroutine libraries that scientific computing has used ever since.

Timeline

1957
IBM's Programming Research Department drafts "Proposed Specifications for FORTRAN II for the 704" (versions dated August 28, September 25 and November 18), calling for better diagnostics and user-defined subroutines
1958
FORTRAN II is distributed for the IBM 704 in the spring, documented in the Reference Manual, FORTRAN II for the IBM 704 Data Processing System (Form C28-6000-2)
1958
Irving Ziller's experimental FORTRAN III, an extension of FORTRAN II, reaches about 20 mostly IBM installations in the winter of 1958-59 but is never generally released
1961
IBM issues the 709/7090 FORTRAN II reference manual (Form C28-6054-2, January 1961); its 1620 FORTRAN II manual also carries a 1961 copyright; a list of early implementations based on the 1984 *Annals of the History of Computing* also dates RCA 301 and UNIVAC LARC FORTRAN II work to 1961
1962
Donald Knuth writes a FORTRAN II compiler for the UNIVAC Solid State 80/90, whose Pass 1 listing survives; IBM's FORTRAN IV, its successor, becomes available on the 7090/7094 around this time
1965
IBM publishes the FORTRAN II Language Conversion Program (Form C28-6560-0) to translate FORTRAN II source into System/360 FORTRAN IV; DEC publishes a FORTRAN II manual for its PDP-6
1966
The American Standards Association approves two FORTRAN standards in March; the smaller Basic FORTRAN (X3.10-1966) is based on FORTRAN II without its machine-dependent features
2006
Paul McJones's Computer History Museum project makes a scanned listing of the final IBM 704 FORTRAN II compiler, from the Smithsonian's collection, available online

Notable Uses & Legacy

Naval Research Laboratory X-ray crystallography

H. G. Norment's 1962 NRL Report 5739 describes an automatic program for reducing single-crystal X-ray diffraction data to structure factors, written in IBM 704 FORTRAN II and run on the 704 and 7090. A 1963 follow-up collection of crystal-structure analysis programs was also written in FORTRAN II for 32K 704 and 7090 machines.

National Bureau of Standards cryogenic data

J. G. Hust's NBS Report 8474, from the NBS Boulder Laboratories, presents IBM 7090 FORTRAN II subroutines for calculating the thermodynamic properties of oxygen from enthalpy and pressure or from pressure and density.

IBM 1620 program library

IBM offered FORTRAN II for its small scientific computer, the 1620, and later the disk-based FORTRAN II-D. The 1620 General Program Library distributed FORTRAN II subroutines, such as relocatable plotting and random-number routines, to 1620 installations.

Compiler writing beyond IBM

Other manufacturers implemented the FORTRAN II language for their own machines, including RCA (301 and 3301), Remington Rand (LARC), Digital Equipment Corporation (PDP-6) and Scientific Data Systems (900 series). A 1962 FORTRAN II compiler for the UNIVAC Solid State 80/90 carries the name of Donald Knuth.

Language Influence

Influenced By

Influenced

FORTRAN III FORTRAN IV Basic FORTRAN (ASA X3.10-1966) Dartmouth BASIC

Running Today

Run examples using the official Docker image:

docker pull gcc:latest

Example usage:

docker run --rm -v $(pwd):/app -w /app gcc:latest sh -c 'gfortran -std=legacy -o hello hello.f && ./hello'
Last updated: