TOPS-10: Fortran

Today we'll take a quick look at programming using Fortran on TOPS-10.

Compiler versions

As noted in the programming introduction , there were two Fortran compilers for TOPS-10: the original compiler, later called F40, that supported Fortran 66, and Fortran-10 which was introduced in around 1972 that supported Fortran 66 and, in later versions, Fortran 77. The 6.03 disk images we have contains both, under SYS:F40.EXE and SYS:FORTRA.EXE respectively. We will look at Fortran-10 in this article.

By default, files with an extension of either .F40 or .FOR will be compiled by Fortran-10: to force the use of F40 you need to provide the /F40 compile-time switch eg COMPILE/F40 HWORLD.F4.

Implementation features

The standard Fortran-66 fixed format is used (labels in columns 1-5, comment/continuation in col 6, program text cols 7-72) but is relaxed slightly: a line starting with a tab is assumed to skip over the initial label.

There are a number of extensions to standard Fortran 66 including:

  • Multiple statements can be combined on a single line using ;.
  • Comments can be added anywhere in the line by starting them with !.
  • Octal constants allowed, starting with a ".
  • Literal strings, eg "YES" are allowed along with Hollerith literals (eg 3HYES).
  • Two-way IF statements for logical comparisons, eg IF B THEN 100,200 will go to statement label 100 if B is true, else 200.
  • PAUSE allows you turn on trace mode, which prints subroutine calls.

There is also extensive I/O capabilities via a package called FOROTS. Random access, and append to files is supported, as well as utilisation of TOPS-10 devices.

The 1974 manual describes a source level called FORDDT, but this does not seem to be available on the version of TOPS-10 we have.

Running TPK

Let's use the compiler to run the TPK algorithm. The source code can be found here. This can be loaded onto the disk using the techniques described in this article.

Type EXEC TPK to compile and run the program. To get a listing of the program you can add /LIST to the EXEC or COMPILE command. It will create a temporary listing file and send it to the printer when you log out.

While developing this, I found I had to change both the WRITE and READ unit numbers to be 5.

The compiler also uncovered a mistake I had made in the original version of the program. Before I had the function definition followed the DIMENSION for the array:

      FTPK(X) = SQRT(ABS(X)) + 5.0*X**3
      DIMENSION A(11)

but I got a warning

00004	      DIMENSION A(11)
%FTNSOD LINE:00004  DIMENSION STATEMENT OUT OF ORDER

The fix for this is to switch the order of the two lines. After that, it ran as expected.

Here's the compile and execution looks:

.type tpk.for
C     TPK ALGORITH IN FORTRAN 66
      DIMENSION A(11)
      FTPK(X) = SQRT(ABS(X)) + 5.0*X**3
C     MAIN PROGRAM
      N=11
      WRITE(5, 100)
 100  FORMAT(24H PLEASE ENTER 11 NUMBERS)
      READ(5, 101) A
 101  FORMAT(F9.4)
      WRITE(5, 102)
 102  FORMAT(12H RESULTS ARE)
      DO 3 J = 1, N
      K = N - J + 1
      RESULT = FTPK(A(K))
      IF (RESULT .LE. 400) GOTO 2
 1    WRITE(5, 103)
 103  FORMAT(10H TOO LARGE)
      GOTO 3
 2    WRITE(5, 101) RESULT
 3    CONTINUE
      STOP
      END

.exec tpk.for
FORTRAN: TPK
MAIN.
LINK:	Loading
[LNKXCT TPK Execution]

PLEASE ENTER 11 NUMBERS
10.
-1.
1.
2.
3.
4.
4.3
4.305
4.303
4.302
4.301

RESULTS ARE
399.8863
TOO LARGE
TOO LARGE
TOO LARGE
399.6086
322.0000
136.7320
 41.4142
  6.0000
 -4.0000
TOO LARGE
STOP

END OF EXECUTION
CPU TIME: 0.00	ELAPSED TIME: 1:19.92
EXIT

.

Further information

On Bitsavers, the FORTRAN-10 Language Manual from 1974 is the closest reference to the version of Fortran-10 that we have on TOPS-10 6.03. There's also a guide to F40 in the FORTRAN IV Programming Manual from 1969.

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 and I will add it here and update the main text.