FORTRAN, the IBM Mathematical FORmula TRANslating System, was designed and implemented by a team at IBM led by John Backus.
| 1954 | FORTRAN I | - specified |
| 1956 | FORTRAN I | - implemented for the IBM 704 |
| 1958 | FORTRAN II | |
| 1958 | FORTRAN III | |
| 1962 | FORTRAN IV | - still an important dialect |
| 1966 | ANS FORTRAN | - ANSI standard FORTRAN IV (2 versions) |
| 1977 | FORTRAN 77 | |
| 1990 | FORTRAN 90 | |
| Columns | Purpose |
|---|---|
| 1 - 5 | statement number |
| 6 | continuation |
| 7 - 72 | statement |
| 73 - 80 | sequence number |
DO 20 j=1,100(DO statement)
DO 20 j=1.100(assignment toDO20J)
GOTOGOTO 400IFIF (X .EQ. A(I)) K=I-1IF (J.GT.3) GOTO 100GOTOGOTO (10, 20, 30, 40), JGOTOASSIGNed to an integer variableGOTO N, (10, 20, 30, 40)DO loopCONTINUE statement, and increment a control variable
by a fixed amount each time, terminating when the specified maximum is reached; e.g.,
DO 100 J=1, N, 3
A(J)=A(J)*2
100 CONTINUE
GOTO shows machine dependence.
IF and GOTO used for leading-, trailing-, and mid-decision loops.
100 IF (loop done) GOTO 200
. . . body of loop . . .
GOTO 100
200 . . .
100 . . . first half of loop . . .
IF (loop done) GOTO 200
. . . second half of loop . . .
GOTO 100
200 . . .
100 . . . body of loop . . .
IF (loop not done) GOTO 100
GOTOs are easily confused
(a violation of the Syntactic Consistency Principle).
GOTO actually contains an address.
PROBLEM in language design: foreseeing problems due to the interaction of features (e.g., between the syntax of GOTOs and the decision to use integer variables to hold the addresses of statements).
DO-loops may be nested, but can be jumped into and out of.
IF, but only a simple unconditional statement
(assignment, GOTO).
DO-loop provides the compiler with enough information
to optimize performance.
SUBROUTINE name (formal parameters)
body
RETURN
END
CALL name (actual parameters)
| + | Time and space efficiency for arrays (no time to copy, no extra space to store). |
| - | Time inefficiency for look-up due to indirection. |
| - | Side effects to parameters meant to be in-only are possible. E.g.,
This changes the constant value 2 to 3, as constants are kept in a literal table.
|
| + | Although side effects are possible, security is maintained by the compiler -- it can omit the copy-out if the parameter is a literal or an expression. |
| - | Passing arrays is inefficient. |
An activation record (AR) is a data structure which contains all of the information (the state) of one activation of a subprogram.
| Activation Unit (caller) | Activation Unit (callee) | ||||||||
|---|---|---|---|---|---|---|---|---|---|
|
|
||||||||
Subroutine S |
Subroutine F(p, q) |
AR(S).TMP
AR(S).IP
AR(F).PAR[1] <-- address(p)
AR(F).PAR[2] <-- address(q) [call by reference]
AR(F).DL <-- address(AR(S))
GOTO entry(F)
(AR(F).DL).TMP
GOTO (AR(F).DL).IP
The two steps for return may be reversed if the caller is responsible for restoring its own state.
Copyright © 2000 Jonathan Mohr