The FORTRAN II language became available very shortly after the original FORTRAN language. It resembled the original FORTRAN language in its syntax; for example, function names still ended in the letter F. But it added a very important new feature.
It was now possible to write subroutines in FORTRAN that could be compiled separately; the SUBROUTINE, FUNCTION, CALL, and RETURN statements were added to the language.
It was possible to use the ASSIGNed GO TO statement in the original FORTRAN language as a way of returning from a subroutine in the body of the main program, and this statement was used for that purpose; the manual for the original FORTRAN language explicitly referred to subroutines. Users could also define their own statement functions in the original FORTRAN language.
In FORMAT statements, O format, for printing out or reading in the internal binary representation of a number in octal form, and A format, for directly transmitting the binary contents of variables without editing, were added.
In the version of FORTRAN II offered for the IBM 7090 computer, but not the version for the IBM 704, some other features were added:
Bitwise logical operations could be performed on integer variables. This was done by placing the letter B in column 1 of the line containing an assignment statement; then, + would mean OR, * would mean AND, and - would mean bitwise negation.
If D were placed in column 1 of a card containing a statement, the floating-point variables and functions referenced in that line would be double-precision. In addition to assignment statements, this was used with function declarations.
Similarly, if the letter I was placed in column 1, the line of the program would deal with complex numbers rather than real numbers.
Finally, the letter F in column 1 was used to declare functions that could be passed as arguments to subroutines. In this declaration, the trailing letter F was stripped off the function names.
Of course, C in column 1 still indicated a comment.
Also, the END statement which indicated the end of a program had an unusual feature: it could look like this:
END (2,2,0,1,2)
and the END statement in this example meant that the actual values of sense switches 1, 2, and 5 would be visible to the program, but it would run as if sense switch 3 was OFF, and sense switch 4 was ON, regardless of their actual values. The actual value of sense switch 6 could never be hidden from a program.
When the computer was directly available to the programmer, this statement allowed whether the program was to run in a debugging mode or not to be controlled conveniently from one place.
Many other computer manufacturers, besides IBM, made FORTRAN compilers available for their computers. One of the first companies to do so was Philco; as they did so while FORTRAN was still perhaps an IBM trademark, they called their language ALTAC (ALgebraic translator into TRANSAC Assembly Code).
However, ALTAC and FORTRAN II were not absolutely identical. A very short program (unlike the example on the previous page) is shown first in FORTRAN II below, and then in its ALTAC version.
In FORTRAN II:
C PROGRAM TO SOLVE THE QUADRATIC EQUATION MAIN0001 READ 10,A,B,C MAIN0002 DISC = B*B-4*A*C MAIN0003 IF (DISC) 15,25,35 MAIN0004 15 R = 0.0 - 0.5 * B/A MAIN0005 AI = 0.5 * SQRTF(0.0-DISC)/A MAIN0006 PRINT 11,R,AI MAIN0007 GO TO 99 MAIN0008 25 R = 0.0 - 0.5 * B/A MAIN0009 PRINT 21,R MAIN0010 GO TO 99 MAIN0011 35 SD = SQRTF(DISC) MAIN0012 R1 = 0.5*(SD-B)/A MAIN0013 R2 = 0.5*(0.0-(B+SD))/A MAIN0014 PRINT 31,R2,R1 MAIN0015 99 STOP MAIN0016 10 FORMAT( 3F12.5 ) MAIN0017 11 FORMAT( 19H TWO COMPLEX ROOTS:, F12.5,14H PLUS OR MINUS, MAIN0018 * F12.5, 2H I ) MAIN0019 21 FORMAT( 15H ONE REAL ROOT:, F12.5 ) MAIN0020 31 FORMAT( 16H TWO REAL ROOTS:, F12.5, 5H AND , F12.5 ) MAIN0021 END MAIN0022
This illustrative program, unlike the one on the previous page, has sequence numbers. Now, here's the same program in ALTAC:
MAIN0001* PROGRAM TO SOLVE THE QUADRATIC EQUATION MAIN0002 READ 10,A,B,C $ MAIN0003 DISC = B*B-4*A*C $ MAIN0004 IF (DISC) NEGA,ZERO,POSI $ MAIN0005 NEGA R = 0.0 - 0.5 * B/A $ MAIN0006 AI = 0.5 * SQRTF(0.0-DISC)/A $ MAIN0007 PRINT 11,R,AI $ MAIN0008 GO TO FINISH $ MAIN0009 ZERO R = 0.0 - 0.5 * B/A $ MAIN0010 PRINT 21,R $ MAIN0011 GO TO FINISH $ MAIN0012 POSI SD = SQRTF(DISC) $ MAIN0013 R1 = 0.5*(SD-B)/A $ MAIN0014 R2 = 0.5*(0.0-(B+SD))/A $ MAIN0015 PRINT 31,R2,R1 $ MAIN0016 FINISH STOP $ MAIN0017 10 FORMAT( 3F12.5 ) $ MAIN0018 11 FORMAT( 19H TWO COMPLEX ROOTS:, F12.5,14H PLUS OR MINUS, MAIN0019 F12.5, 2H I ) $ MAIN0020 21 FORMAT( 15H ONE REAL ROOT:, F12.5 ) $ MAIN0021 31 FORMAT( 16H TWO REAL ROOTS:, F12.5, 5H AND , F12.5 ) $ MAIN0022 END $
In ALTAC, by default, the first 8 characters, rather than the last 8 characters, of the card were ignored. This was done in order to retain compatibility with the format of the existing assembler language for that computer. An option was available, however, to read in programs using the same columns as regular FORTRAN, although using that option did not do away with the requirement to end each statement with a dollar sign.
ALTAC III, however, improved on that, allowing an input format which basically was fully compatible with FORTRAN II.
Note that ALTAC, like PL/I and ALGOL, allowed labels to be names, not just numbers, and that ending each statement with a dollar sign means that no explicit symbol for a continuation card is required.
Also note that the asterisk character is required to indicate a comment.
There were other versions of FORTRAN II that were modified slightly, so that the format of the language was not quite compatible.
The same program, in 4K FORTRAN for the PDP-8 computer (and its predecessor, the PDP-5) would look like this:
C; PROGRAM TO SOLVE THE QUADRATIC EQUATION READ 10,A,B,C DISC = B*B-4*A*C IF (DISC) 15,25,35 15; R = 0.0 - 0.5 * B/A AI = 0.5 * SQTF(0.0-DISC)/A PRINT 11,R,AI GO TO 99 25; R = 0.0 - 0.5 * B/A PRINT 21,R GO TO 99 35; SD = SQTF(DISC) R1 = 0.5*(SD-B)/A R2 = 0.5*(0.0-(B+SD))/A PRINT 31,R2,R1 99; STOP 10; FORMAT( 3F12.5 ) 11; FORMAT( 19H TWO COMPLEX ROOTS:, F12.5,14H PLUS OR MINUS, ' F12.5, 2H I ) 21; FORMAT( 15H ONE REAL ROOT:, F12.5 ) 31; FORMAT( 16H TWO REAL ROOTS:, F12.5, 5H AND , F12.5 ) END
The most noticeable difference between this version of FORTRAN and conventional FORTRAN is that a semicolon is required after every statement label. Note that one is also required after the C indicating a comment card.
Less easily visible is that a continuation card is indicated by a single quote on the previous line, the one to be continued. Also, the square root function is now SQTF.
As the PDP-8 is a computer with a 12-bit word, statement numbers can only be in the range from 1 to 2047.
Using a semicolon to separate the statement number from the statement, and ' to continue a statement on the next line, indicates that this form of FORTRAN supported free-format entry of programs. This was reasonable, given that it was for use with smaller PDP-8 systems that used an ASR 33 teletypewriter for input and not a card reader. The semicolon after the C for a comment may have meant that statements could even start in column 1; in designing my own language, I felt this was taking free format too far, but free-format input in Fortran 90 and its successors also permits this, but in a different way, as we shall see.
Copyright (c) 2007 John J. G. Savard