The birth of the FORTRAN II subroutine

By comparing three versions of the memo (unsigned, but believed written by Irv Ziller) “Proposed Specifications for FORTRAN II for the 704”, dated August 28, September 25, and November 18, 1957, you can watch the design of the subroutine feature of FORTRAN II unfold. The original FORTRAN system (see here or here) had a variety of built-in library functions and allowed the programmer to write single-statement function statements, or to add additional library functions written in assembler, but there were no separately compiled FORTRAN subroutines or functions.

The first version of the memo says:

The FORTRAN II translator will accept an unlimited number of different statements. All statements presently in the system and a few others to be described below will be recognized and translated in the normal way. All others will refer to subroutines and must have the following form:

NAME ( A, B, C, I, X )

where NAME denotes the name of the desired subroutine to be executed. Enclosed in parentheses are the names of variable and/or arrays which the subroutine is to operate on and also the names of variables and/or arrays which are to receive the results produced by the subroutine. Variables may be fixed or floating point. After the subroutine has been executed the next executable statement in the FORTRAN program will be executed.

In this version, a subroutine begins with a SUB DEF statement, which also includes the name and argument list. There is a RETURN statement, but no END statement.

In the second version, SUB DEF becomes SUBROUTINE DEFINITION, and the END statement appears. An UPPER statement is added, for definining variables and arrays that will be allocated at the high end of memory, where they can be accessed from more than one subprogram.

In the third version, a subroutine call begins with the reserved word CALL. The UPPER statement becomes the COMMON statement.

By the time FORTRAN II shipped and the manual was published, a FUNCTION statement was added.

The last page of this 1959 research report by Grace Mitchell describes the changes that were required to add these features to the compiler.

In his 1978 HOPL paper (see here or here), Backus noted, “FORTRAN II was designed mostly by Nelson, Ziller, and myself. Mitchell programmed the majority of new code for FORTRAN II (with the most unusual feature that she delivered it ahead of schedule). She was aided in this by Bernyce Brady and LeRoy May. Sheridan planned and made the necessary changes in his part of section 1; Nutt did the same for section 6. FORTRAN II was distributed in the spring of 1958.”

Today the ability to build programs from separately compiled units is taken for granted, but 47 years ago this was a big thing. Recently Dennis E. Hamilton, who remembers the release of FORTRAN II, told me:

“However, the impact of small changes and improvements can be immense. The ability to build Fortran programs out of independently-compilable modules and to have the ability to decompose into functions and subroutines using Fortran or any other tool that produced compatible code (usually the assembler, in those days) had an immense impact. 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 and, I think, the endurance of Fortran as a technical-software programming tool.

It also changed the way that computers had to operate to make software building and use work more smoothly. I think it is no coincidence that this paralleled increased interest in operating systems (called things like tape monitors, at the time) and the use of the computer for organizing the data processing workflows. (There was also a lot of resistance to operating systems in those days.)”

For much more about the FORTRAN/FORTRAN II project, visit the Computer History Museum’s History of FORTRAN web site.

[Edited 10 May 2014: =>; updated links for Backus’s HOPL paper.]