CTSS: Fortran II translator
Fortran became a very popular language for scientific computation on the IBM 7x series soon after its creation in 1957. Although it could run as a FMS batch job, it was not available for online users of CTSS - according to Tom Van Vleck 'IBM FORTRAN II would not run in CTSS foreground, because the FORTRAN compiler was a complex multi-pass monster.'
What was available was a translator from Fortran to MAD called
MADTRN
. This would take a Fortran file as input (with name2 of
MADTRN
), translate it to MAD and then compile it. The
CTSS Programmer's Guide does provide some warnings on its use,
however:
MADTRN does not always produce perfect results and, therefore, should not be used unless absolutely necessary. MADTRN assumes a working Fortran program and therefore MADTRN diagnostics are minimal.
In any case, let's try this out on CTSS by implementing the TPK algorithm.

Blank Fortran punched card. Source: IBM 7090/7094 Programming Systems: FORTRAN II Programming
TPK in Fortran II
This is based on Knuth's Fortran I version in the original paper. See the file on Github or the annotated version below.
The source format, as shown in the illustration above, is fixed, with
C
in column 1 indicating a comment, line numbers in cols 1-85 and
code starting at column 7.
C TPK ALGORITH IN FORTRAN II
FTPKF(X)=SQRTF(ABSF(X))+5.0*X**3 ②
C MAIN PROGRAM
DIMENSION A(11)
N=11
PRINT 100
100 FORMAT(23HPLEASE ENTER 11 NUMBERS) ⑦
READ 101,A
101 FORMAT(F9.4)
PRINT 102
102 FORMAT(11HRESULTS ARE)
DO 3 J=1,N ⑫
RESULT=FTPKF(A(J))
IF (RESULT-400.0) 2,2,1 ⑭
1 PRINT 103
103 FORMAT(9HTOO LARGE)
GO TO 3
2 PRINT 101,RESULT
3 CONTINUE
STOP
END
The function to be called is on line ②, and is an example of a single
expression function. Note that functions have to end with the letter
F
, including built in ones like SQRTF
.
Variable types are indicated by the first letter: I
- N
means an
integer, otherwise it is floating point.
Strings can be printed, as shown on line ⑦, but need to be
incorporated in the format definition as the string length followed by
H
.
Arrays can be read in by a single statement, but are stored in
reversed order on the IBM 7x series, so the first line of input goes
to A(11)
.
Line ⑫ introduces a loop. ⑭ is a 'computed if', with the test
expression being compared against zero and a branch taken to the
first, second or third label if the result is less than, equal to or
greater to the test. So here if RESULT
is > 400 control will
transfer to label 1
, otherwise to label 2
. This is the only 'if'
syntax available in Fortran II.
Compiling the program
To compile, run MADTRN TPK
, optionally with the (LIST)
switch.
Noe that MADTRN
will create TPK MAD
as its output before compiling
it, so if you already have TPK MAD
from the previous post in your
directory it will be overwritten.
As indicated by the warning in the manual, if there is a mistake it is
unlikely to be caught until the MAD program is compiled which means
you need to trace back from the translated source. The only MADTRN
diagnostic I could get was if I forgot the END
statement:
****ERROR 20 *****NO END CARD ***** PROBABLE ERROR IN MADTRN FILE. MAD FILE CREATED,USE AT OWN RISK.
Otherwise, the compile and execution is straightforwards:
madtrn tpk (list) W 1905.1 LENGTH 00205. TV SIZE 00006. ENTRY 00055 R .033+.066 loadgo tpk W 1905.2 EXECUTION. PLEASE ENTER 11 NUMBERS ...
The MAD output of the translator is reasonably clean so could be used as a starting point for further development.
Further information
The IBM manual IBM 7090/7094 Programming Systems: FORTRAN II Programming is a short and readable guide to the language.
There's lots of information about early Fortran at softwarepreservation.org.
Questions, corrections, comments
I welcome any questions or comments, and also especially any corrections if I have got something wrong. Please email me at rupert@timereshared.com