FORTRAN II as implemented

Dialect mode --std=2 (the default). This note is the checklist for the subset in src/. It is a reading of two manuals, not a transcript of them.

  • Programmer’s Reference Manual, FORTRAN, IBM 704, 15 October 1956. Form of the original language. Chapters 2–5 were used for constants, names, subscripts, expressions, control, DO, I/O lists, and FORMAT. Card layout is the “Keypunching the Program” section: columns 1–5 hold a statement number less than 32768, column 6 is continuation, columns 7–72 are the statement, columns 73–80 are ignored, and C in column 1 is a comment. --std=0 is the exception: columns 1-5 may hold 99999. A statement may have nine continuation cards (ten cards, 660 characters).

  • FORTRAN II for the IBM 704, form C28-6000-2. The General Introduction, printed page 1, adds six statement kinds and says that any program used with the earlier system can also be used with FORTRAN II. That page does not print a ceiling for the translator tables, and it does not qualify the compatibility by table size or object size. Chapter 3 (CALL, SUBROUTINE, FUNCTION, COMMON, RETURN, END), Appendix A (the 38 statements), Appendix B (the 20 open built-in functions).

Appendix A of C28-6000-2 is the inventory: 1 arithmetic + 18 control + 13 input/output + 6 specification = 38. The six that are new in FORTRAN II are CALL, RETURN, END, SUBROUTINE, FUNCTION, and COMMON. The 1956 manual’s “32 statements” are the rest. An OCR of Appendix A swaps ASSIGN and the assigned GO TO. The 1956 wording is the one used here: ASSIGN i TO n and GO TO n, (n1, ..., nm).

709/7090 FORTRAN II is a different dialect. DOUBLE PRECISION, COMPLEX, and column-1 B/D/I flags are not 704 FORTRAN II. FORTRANSIT and 1401 FORTRAN II are cousins, not this language.

What the driver accepts

fortran704 [--std=0|1|2] [--ss=UUUUUU] [--bss module.cbn]
  [--debug-script commands --debug-output new-log]
  [--load-media image] [--save-media image]
  [--export-text unit text-file] program.f

--std=2 is the default. --std=1 is the C28-6003 subset in fortran1.md: the same implementation, rejecting CALL, RETURN, SUBROUTINE, FUNCTION, COMMON and the five-switch END(...) form. A bare END is accepted. --std=0 is the 10 November 1954 subset in fortran0-deviations.md. Any other value is rejected. Data for READ comes from standard input. STOP and PAUSE write to standard error so a stdout comparison stays the program’s printed lines. STOP then exits 0.

Source is an ASCII transcription of the 704 character set. Lower case letters are folded, except inside Hollerith text, which is copied as written. A c in column 1 is accepted as a comment. Tabs are rejected. Blank lines are ignored. Column 6 of the first card of a statement must be blank or 0. A continuation card has something else there; columns 1–5 of that card are ignored. Each card contributes its blank-padded columns 7–72, with no additional separator between fields. Blanks may separate tokens and appear inside keywords. The arithmetic-expression scanner requires contiguous numeric constants: A=1 2 is rejected. Blanks in Hollerith text and column 6 retain their meaning.

FREQUENCY is parsed and ignored. Honouring it must not change results, and ignoring it does not.

Statements in this subset

Arithmetic assignment a = b. An arithmetic statement function, name(arguments) = expression, may precede the first executable statement. It is not a FUNCTION subprogram.

Control: unconditional GO TO, assigned GO TO, ASSIGN, computed GO TO, arithmetic IF, SENSE LIGHT, IF (SENSE LIGHT), IF (SENSE SWITCH), IF ACCUMULATOR OVERFLOW, IF QUOTIENT OVERFLOW, IF DIVIDE CHECK, PAUSE, STOP, DO, CONTINUE, CALL, RETURN.

Input/output: FORMAT, READ, PUNCH, PRINT, READ INPUT TAPE, WRITE OUTPUT TAPE, READ TAPE, WRITE TAPE, READ DRUM, WRITE DRUM, END FILE, REWIND, BACKSPACE.

Specification: DIMENSION, FREQUENCY, SUBROUTINE, FUNCTION, COMMON, EQUIVALENCE, END.

END is the last physical statement of a program unit. A bare END is accepted in --std=1 and --std=2. END(i1,i2,i3,i4,i5) with each digit 0, 1, or 2 is accepted under --std=2 and recorded. Those digits are translator switches in C28-6000-2 (punch binary cards, tape units, batch compile). They do nothing at run time. --std=1 rejects that form. If one FORTRAN II program is compiled and the END card is absent, printed page 22 treats that absence as END(2,2,2,2,2). This implementation records those five digits and counts the statement with the other non-executable statements. A file of several programs still requires an END as the last statement of each. --std=0 and --std=1 still require the card. A unit is a main program, a subroutine, or a function. One main program is required. Several units may sit in one source file, each closed by END. SUBROUTINE or FUNCTION is the first statement of its unit.

Chosen readings

These are the behaviours a test is entitled to rely on.

DO trip count. The 1956 DO section says the index starts at m1 and increases by m3, for values that do not exceed m2. If m1 is already past m2, the body is not entered. This is not the FORTRAN 66 one-trip rule. m3 taken from a variable may be negative: the loop continues while i >= m2 when m3 < 0, and m3 = 0 is an error. m1, m2, and m3 are captured on entry. After a normal exit the index is undefined. A transfer out of the range leaves the index defined. The 15 October 1956 Programmer’s Reference Manual, printed page 21, allows control to leave a nest for a section completely outside that nest and to return to the same part, when that section does not change an index or an indexing parameter. --std=1 and --std=2 accept that return. The frame stays live, so an assignment to the index is still “DO index or parameter redefined”. A one-way exit pops the frame and leaves the index defined. A GO TO of the DO statement is not a return into the extended range. The frame is dropped, and so is every frame nested inside it, and the DO starts again at m1. --std=0 steps the index instead when the control formula is inside the range, as section 10.A.v of the 1954 report states. A GO TO from outside the range still starts at m1.

Paths of control. The 1956 sequencing summary, printed page 24, says every executable statement except the first needs a path of control. FORMAT, DIMENSION, EQUIVALENCE, and FREQUENCY are ignored. Under --std=1 and --std=2 the compiler rejects a statement that the flow does not reach, with “no path of control leads to this statement”. Control starts at the first executable statement. A transfer goes only to its own targets. A DO reaches every statement in its range, and the statement after that range, including a zero-trip loop. A transfer, STOP, or RETURN is an end of a path and is not itself reported. --std=0 is not checked: a variable GO TO names its target when the program runs.

A transfer into a DO that was not left that way is “transfer into a DO”, at compile time when the path is visible and at run time if control reaches a DO that is not on the stack. A jump that remains inside an outer DO of the same nest is not this exception. An inner DO that leaves into a section used by an outer DO does not keep the outer frame unless that section returns to the inner DO. The outside section includes the body of a DO that runs there. A transfer from that body back to the suspended DO is the same return. A transfer to another statement of that same part keeps the suspended DO, including a statement still inside the outside DO. A transfer to a statement that returns to a different part does not. --std=0 builds no extended range. The outside section may contain a DO. Printed page 22 of the 15 October 1956 manual says that when an assigned GO TO exists in the range of a DO, every statement it may transfer to must lie in one part of the nest, or every one of them must lie completely outside the nest. Two statements are the same part when exactly the same DOs contain them and no DO range lies strictly between them. The DO statement itself is outside its own range. --std=0 still rejects ASSIGN and an assigned GO TO. A split set is “an assigned GO TO must aim at one part of the nest, or entirely outside it”. Shared terminals use the nearest unsatisfied DO, which is the innermost one on the stack. A range of one statement repeats that statement. The trip count is not finished by falling into the next statement.

Assignment converts, expressions do not. A = I and I = A are legal. I = A truncates toward zero, so ±3.569 becomes ±3. A = 3 * B is a mixed expression and is rejected. The 1956 hierarchy is exponentiation, then * and /, then + and -. + and - group from the left. Under --std=1 and --std=2, an unparenthesised run of fixed-point * and / is computed by moving each division onto the first factor and then grouping from the left. That is C28-6003 printed page 43. 5*4/2 is ((5/2)*4), which is 8. (5*4)/2 stays ((5*4)/2), which is 10. A parenthesis on an operator keeps that operator where it is written. Floating-point * and / stay grouped from the left. --std=0 groups fixed-point * and / from the left as well. ** does not chain: A**B**C is rejected and A**(B**C) is legal. The exponent may be floating only when the base is floating. A unary sign is legal only when the next character is not + or -, so A--B and +-A are rejected and A+(-B) is legal.

Integers. Fixed-point values must satisfy magnitude < 32768, so the stored range is −32767..32767. Overflow is a run-time error. It does not wrap, and it does not raise the accumulator-overflow trigger. Input I conversion is reduced modulo 32768, as the FORMAT chapter says, and that reduction is allowed to land inside the stored range. Integer division truncates toward zero. A negative integer exponent of an integer base is rejected.

Floating point. Constants need a decimal point (1E2 is rejected, 1.0E2 is accepted). A real value is one normalized IBM 704 word from form 24-6661-2: a sign, an 8-bit characteristic (the exponent plus 128), and a 27-bit fraction with the leading 1 stored. The cell holds the exact double of that word. 0**0 is 1. A negative real base to a non-integer power is a domain error. A real exponent is evaluated by multiplication only when it is an exact integer. A value merely close to an integer is not that integer. Addition, subtraction, multiplication, and division follow FAD, FSB, FMP, and FDP. An expression divided by zero sets the divide-check trigger, yields +0, and continues. That +0 is the expression result. It is not the FDP machine state that leaves the accumulator unchanged.

Values use 704 words; a printed field is the decimal rendering of that word. The oracle corpus checks 14 programs in 26 dialect comparisons against original FORTRAN II output, including the leading physical PRINT column. The corpus guide describes normalisation and numerical-context limits.

Subscripts. Only the seven 1956 forms: v, c, v+c, v-c, c*v, c*v+c', c*v-c'. The minimum subscript is 1. Under --std=1 and --std=2, the part of that expression exclusive of the addend must also be greater than zero and not greater than the dimension. The addend is the ±c of v±c and of c*v±c. A bare v or c, and the product c*v, are that part in full. --std=0 keeps the 1954 subscript and does not split off an addend. Arrays are column-major. Elements occupy descending physical addresses, as on the 704. The first subscript varies fastest in their logical column-major order.

DO parameters and the index are non-subscripted fixed-point variables, or unsigned fixed-point constants for the parameters. Redefining the index or a parameter variable inside the range is a run-time error. The 1956 Programmer’s Reference Manual, printed page 21, forbids any statement that redefines the index or an indexing parameter. A store through an EQUIVALENCE name, through a COMMON name in a called subprogram, or through a subroutine dummy writes that cell and is the same error. ASSIGN stores a new value, and READ of the cell does too. A scalar extended by an EQUIVALENCE subscript still writes its first cell when the name itself is stored. A statement function may rebind a dummy of the same name and evaluate it in a temporary. A store into that temporary is not a redefinition. A store of the cell captured when the DO was entered still is, including a COMMON store from a function called by the statement function. The diagnostic is “DO index or parameter redefined”.

C28-6003 printed page 23 says the first statement in the range of a DO must not be non-executable. Under --std=1 and --std=2 that statement is the one that follows the DO. FORMAT, FREQUENCY, DIMENSION, and EQUIVALENCE are rejected there, and under --std=2 so is COMMON. Under --std=1, COMMON is still “COMMON is not in FORTRAN I”, including later in the range. The diagnostic for the opening is “the first statement of a DO must be executable”. If a dropped specification is followed by a FORMAT or FREQUENCY that is also inside the range, that first diagnostic is the one reported. A later FORMAT, FREQUENCY, DIMENSION, or EQUIVALENCE is still ignored for sequencing, and under --std=2 a later COMMON is too. An inner DO or a CONTINUE may open the range. A FORMAT or FREQUENCY that ends the range is still “DO ends on a statement that cannot terminate it”. A labeled DIMENSION, EQUIVALENCE, or COMMON used as that terminal is dropped, so the error is “missing statement number”. --std=0 does not apply this rule. The 15 October 1956 manual does not print the sentence. Page 23 is not one of the October 1958 changes, so the sentence belongs to the reference manual that C28-6000-2 incorporates as Form 32-7026.

Computed GO TO out of range is a run-time error. An assigned variable may be used only by an assigned GO TO until an ordinary assignment replaces it.

Sense lights. Four lights, initially off. SENSE LIGHT 0 turns all off. SENSE LIGHT i turns light i on. IF (SENSE LIGHT i) branches and then turns that light off.

Sense switches. Six switches, initially up. --ss takes six U or D characters. IF (SENSE SWITCH i) takes the first label if the switch is down and the second if it is up, so the default takes the second label.

Overflow triggers. Characteristic overflow or underflow of a kept result sets the accumulator-overflow trigger and stores the characteristic wrapped to 8 bits. The quotient-overflow trigger is the machine FPMQERR condition: a result characteristic below 27 on add or multiply, or an MQ characteristic overflow or underflow on divide. Ordinary magnitudes do not set it. 1.0E-20 * 1.0E-20 sets both triggers. Each of IF ACCUMULATOR OVERFLOW, IF QUOTIENT OVERFLOW, and IF DIVIDE CHECK takes the first label when its trigger is on and then clears it. Integer overflow stays a run-time error and does not use these triggers.

PAUSE and STOP. The optional number is unsigned octal. It is displayed in the address field of the storage register, so it is at most 77777 octal. A larger value is “PAUSE and STOP octal number is out of range”. A digit 8 or 9 is “PAUSE and STOP take an octal number”, including a number that is also too large. An omitted n is taken to be 0 and the message shows that 0. A FORTRAN 0 bare STOP shows that 0. STOP n stays rejected there. The message goes to standard error and, for PAUSE, execution continues.

PRINT carriage control. The first character controls motion and is suppressed, but its physical column remains blank, as in the original SPH routine. Blank single-spaces before printing; 0 double-spaces; + overprints without advancing. Output is buffered until the next advance or process exit. This printer stream is intended for batch input; a PRINT before an interactive READ is not a terminal prompt and can remain buffered. PAUSE/STOP diagnostics use stderr, whose ordering relative to stdout is not part of the printer model. Blanks do not erase existing ink; a conflicting character replaces prior ink, as in Sim704’s text representation. Trailing blank padding is omitted. Channel 1 writes FF; channel 2 writes VT. Other channels and J-R short skips use FF (K uses VT), an explicit host-text approximation without a configurable carriage tape. Other nonblank control characters also use FF and are unvalidated. These are not validated channel positions. A final all-blank record has no pending ink to emit at exit, following Sim704. PUNCH writes its full record and flushes pending PRINT text first to preserve stdout order. PRINT and PUNCH limits remain 120 and 72 characters respectively. The carriage oracle preserves LF/FF/VT and internal blank lines, and matches blank, 0, +, 1, 2 and slash behaviour. Native i704’s printer differs.

nX. Not in the 1956 FORMAT list. It is accepted as a transcription aid (skip or emit n blanks) and is not used by the strict tests. Spacing in those tests is field width and Hollerith.

FORMAT. Iw, Fw.d, Ew.d, nH, nP, slashes, a repeat count, and one level of parentheses. A comma may be omitted immediately after a Hollerith field, as in the historical MatInv deck. A slash also separates fields without commas. A scale factor and its following descriptor require a comma (1P,E12.4). d >= 10 is reduced mod 10. The scale factor defaults to 0, sticks for later F and E in that input/output statement, and does not affect I. For F, the printed value is the internal value times 10 to the scale. For E at scale 0 the field is a sign column (blank if positive), 0., d digits, E, a blank or minus, and a two-digit exponent, right-justified in w. Original zero output is 0. (or -0.) followed by blanks instead of fractional/exponent digits. A positive scale puts that many digits before the decimal and reduces the exponent, matching the 1956 example that turns -0.9321E 02 into -9.3210E 01 under 1P. A negative scale on E moves the decimal left and increases the exponent. If the list outlasts the format, a new record starts and the format resumes at the last parenthesised group, or at the beginning if there is none. On input, blanks in a numeric field are zeros, a punched decimal point overrides d, and an exponent may be marked by E or by + or -. Hollerith on input replaces the text stored in that format.

I/O lists. Left to right. Under --std=1 and --std=2, a bare array name transmits the whole array in the inverse of its natural order. C28-6003 printed page 26 says so. A binary tape list uses that same abbreviated notation. Natural order is column-major, the first subscript varying fastest, so the last element is transmitted first. An implied DO is not reversed. Its control sits just before the closing parenthesis, and a missing third parameter is 1. A subscripted element is that one element. A round trip of the same bare name restores the array. --std=0 keeps column-major order. FORTRAN I and II list only variables; FORTRAN 0 also permits constants in output lists, as described in its list rules. On input, an index written earlier in the list supplies the value used later in that list.

Subprograms. One file may contain a main program and several SUBROUTINE and FUNCTION units. Arguments are passed by reference, so a dummy bound to a common variable is that common cell, not a copy. Expression and constant arguments are temporaries. COMMON is one blank common block. A name that appears in no EQUIVALENCE group keeps storage of its own and is overlaid with the other such names in order of appearance. A variable equivalenced to a COMMON variable is placed in COMMON with it. The C28-6000-2 example COMMON A, B, C, D with EQUIVALENCE (C, G), (E, B) is stored high address first as C and G, then B and E, then A, then D. Labelled common is FORTRAN IV.

An array in COMMON must be named in a DIMENSION in the same unit. Locals are static. The function name is a local variable of the implicit type; its value on RETURN is the result. C28-6000-2 printed pages 19–20 require that name on the left of an arithmetic formula at least once in the unit. The error is “the function name must be on the left of an arithmetic formula”. READ into the name, or a store through another name, does not count. A path that skips the store still fails at run time: a function result that was never assigned is “undefined variable”. A recursive call of a unit that is still active is an error. Array arguments must match in rank, mode, and dimensions. C28-6000-2 printed pages 17–19 require the same DIMENSION extents on the dummy and on the actual argument. The portion used may be shorter. That length is another argument, used as an indexing parameter, and the spare locations stay reserved. A bound that is smaller or larger is rejected. The subprogram name must not occur in a DIMENSION statement in that subprogram, nor in a program that CALLs the subroutine or uses the function. A program that does not call or use it may give that name to an array. A subscript of that array is not a use. A parenthesized reference that is not a subscript is a use, and is rejected.

The primer, printed page 28, is “Restriction on Statements Involving Dummy Variables”. It says a dummy argument of a function should not normally be stored into, except as a subscript, and that a fixed-point dummy should not normally appear in ASSIGN. Printed page 32 says a subroutine result may be stored into. This compiler does not turn the advice into an error. An assignment to a dummy writes the actual argument.

The COMMON chapter’s dummy names are names placed in COMMON so that later names line up. They may be dimensioned. They are ordinary names, not subprogram arguments, and each one reserves its own storage. A subprogram argument named in COMMON is not given a storage rule in C28-6000-2. The error is “a dummy argument in COMMON is not defined”.

EQUIVALENCE. The form is EQUIVALENCE (a, b, c, ...), .... Each name may carry one unsigned fixed-point constant in parentheses. That constant is the 1-based storage location of the variable: the 1956 text says A(p) is the pth location of A. A scalar subscript p greater than 1 extends that scalar’s cell count to p and does not make it an array. An array subscript past the dimension is an error. The statement may appear before DIMENSION. A group needs two names. Two groups that force one array onto two offsets are a conflict. A subprogram argument in an EQUIVALENCE group is not given a storage rule in C28-6000-2. The error is “a dummy argument in EQUIVALENCE is not defined”. Under --std=0 the 1954 form is bare names. See fortran0-deviations.md.

Names. Variables are 1–6 alphanumeric characters, the first alphabetic, with I–N fixed-point. Subroutine and function subprogram names follow the FORTRAN II rule: 1–6 characters, not ending in F when the length is 4, 5, or 6. A function subprogram is fixed-point when its name begins with I–N. Built-in and library names are the exception: 4–7 characters ending in F, and fixed-point when they begin with X.

Built-ins (Appendix B)

Twenty open routines. DIMF and XDIMF are the two FORTRAN II added to the earlier eighteen. Spellings use the digit 0 (MAX0F, not the OCR MAXOF).

Name

Arguments

Result

ABSF

one real

real absolute value

XABSF

one integer

integer absolute value

INTF

one real

real, truncated toward zero

XINTF, XFIXF

one real

integer, truncated toward zero

MODF

two reals

a - trunc(a/b)*b

XMODF

two integers

the same, integer

MAX0F / MIN0F

two or more integers

real

MAX1F / MIN1F

two or more reals

real

XMAX0F / XMIN0F

two or more integers

integer

XMAX1F / XMIN1F

two or more reals

integer

FLOATF

one integer

real

SIGNF

two reals

sign of the second times the absolute value of the first

XSIGNF

two integers

the same, integer

DIMF

two reals

a - min(a,b)

XDIMF

two integers

the same, integer

INTF truncates toward zero. The Appendix B line that says “largest integer less than the absolute value” disagrees with the assignment example ±3.569 → ±3, including on an exact integer.

704 library algorithms

SQRTF, SINF, COSF, EXPF, LOGF, and ATANF each take one real argument and return a real result. Independent C formulations reproduce the preserved library’s approximations, quantised coefficients, fixed-point reduction and 704 arithmetic. The original library’s domain behaviour is retained, including SQRT/LOG using the magnitude, LOG returning signed zero at zero, and EXP’s original range guard.

The measured corpus agrees at nine decimal digits, including 150 function values in the wider grid. Direct SINF calls use an incoming MQ of zero; original compiled calls can retain earlier MQ bits and therefore differ. COSF retains the MQ produced by its own subtraction before calling sine. The AST does not reproduce every original compiler instruction ordering or register lifetime. See validation.

Tape and drum

Tape units are 1 through 10. Drum units are 1 through 8. The unit, and a drum address, is an unsigned fixed-point constant or a non-subscripted fixed-point variable. The range is checked when the statement runs, so a constant outside it compiles and then fails with “unit out of range”. The same units are visible to every subprogram. They start empty unless --load-media mounts a saved bundle. Optional --save-media preserves their records, marks, positions and words on STOP. They retain their native device semantics; see the media guide.

READ INPUT TAPE and WRITE OUTPUT TAPE use the same FORMAT subset as READ and PRINT. A BCD record holds at most 120 characters and keeps its first character, the carriage-control character. PRINT still consumes that character. WRITE OUTPUT TAPE stores it. Extra records from a run of slashes are zero-length BCD records. An empty BCD record is not an end of file.

READ TAPE and WRITE TAPE move one binary record. The list may be empty. An empty READ TAPE skips one record. An end-of-file mark counts as a record for that skip and for BACKSPACE. A shorter list still consumes the whole record. A longer list is “read-write check”. A fixed-point value uses sign bit 35 and the 15-bit decrement field in bits 18–32 (numbering from bit 0 at the least significant end). Numeric reads ignore bits 0–17; a word with bit 33 or 34 set raises “fixed-point overflow” when read as fixed-point. Successful binary transfers preserve all 36 raw bits. A sign-only word reads numerically as zero. Floating values use the 704 floating format. A later binary write emits the word last stored, so a fixed-point word read into a real name is written back unchanged. An arithmetic store uses the numeric value and replaces the word with a normalized one. That store does not repeat the 704 instruction on the original bits. The fixed word 12, read into a real, is below the normalized range: storing it writes zero and sets accumulator overflow, and a cell that was not stored still writes 12. A format that runs out of fields starts a new record, on tape as on cards. A slash finishes the record in hand. The next field reads or writes the following record, and a slash at the end of the format does not skip an extra one.

READ DRUM and WRITE DRUM move consecutive words. A negative address is “drum address out of range”. An address of 2048 or more is reduced modulo 2048, and a list that passes word 2047 continues at word 0. The list is unsubscripted names only, and it needs at least one name. C28-6003 printed page 34 says the full array is transmitted in the inverse of natural order. Printed page 35 gives WRITE DRUM that same list. A round trip of the same bare name restores the array.

END FILE writes an end-of-file mark. REWIND returns to the start. BACKSPACE moves back one record, and at the start of the tape it is “BACKSPACE at start of tape”. A write, including END FILE, at the current position discards every later record.

The 1956 manual halts on an end of file or a redundancy check, and START continues the same list. This runtime has no START button and does not model a redundancy check. End of file is the runtime error “end of file”. A BCD read of a binary record, and the reverse, are their own errors. The 15 October 1956 manual, printed page 42, gives restrictions on the parenthesised parts of a READ TAPE or WRITE TAPE list which must be observed if the object program’s indexing is not to exceed 288 microseconds between CPY instructions. The same page gives rules for lists that can be relied upon to work, and it says that other lists, excluded by those rules, would also work. For an element that contains no three-subscript variable, the sufficient condition is that 4N1+6N2+max(M1,M2) does not exceed 18. N1 and N2 count different one- and two-dimensional subscript combinations. M1 is 0 when N1 is 0 and otherwise 1. M2 is 0 when N2 is 0 and otherwise 5. The printed example ((A(I,J), B(I,J), J = 1,10), C(I), I = 1,10) sums to 15 when the first dimensions of A and B match, and the page calls that element permissible. An element with no subscripted variable has no restriction on that page. This compiler does not time the object program and does not insert a delay. It does not reject a list for failing the inequality, because the page says an excluded list would also work.

Printed page 46 gives three skeletons for an element that contains a three-subscript variable. The innermost parenthesis controls v3, v3, or v2, the middle parenthesis of those three forms holds no subscripted variable, and the outermost parenthesis holds one subscript combination. The printed example (((A(I,J,K), B(I,J,K), K = 1,10), J = 1,5), C(I), D(I), I = 1,10) uses the first skeleton and works when the first two dimensions of A and B match. In the special case the next element is neither subscripted nor inside controlling parentheses, and the middle parenthesis of that first skeleton may then hold one subscript combination. Printed page 47 continues with the natural-order skeleton ((( , v1 = 1,d1), v2 = 1,d2), v3 = ). It indexes with the first subscript varying fastest, and v1 and v2 run through the array consecutively. These are ways to build a list that can be relied upon. A three-subscript list that matches none of them still compiles, for the same reason as the inequality. This compiler does not time the indexing and does not reject the excluded list.

Printed page 47 then states a restriction for a READ TAPE or WRITE TAPE list. A relative constant is a subscript whose variable is not under a DO or a controlling parenthesis. An index governed by variable indexing parameters is a DO or implied-DO index with a bound that is not a constant. A subscripted variable that uses either one may appear only in the first element of the list, and one of its subscripts must be controlled by that element’s first parenthesis. The worked example is ((A(I,J), I = 1,L), B(K,J), J = 1,M). Both subscripts of A are governed by variable indexing parameters. One subscript of B is too, and K is a relative constant unless the statement is in the range of a DO for K. J is the index of the first parenthesis and is a subscript of both, so the element is accepted when it is the first element. The same list after another element is rejected. A constant subscript does not bring the restriction in. --std=1 applies it. --std=2 does not, and --std=0 does not: that mode’s relative constants are the 1954 subscript rule. Printed pages 47 and 48 then restrict a relative-constant definition in an input list, under --std=1 only. A definition is an unsubscripted fixed-point name in the list, and only when that name is used as a relative constant somewhere in the program. In a READ TAPE list, a use that is only elsewhere may sit in any position, except that a 2- or 3-dimensional use, or a 1-dimensional use with a coefficient, forbids a definition to the left of a DO-implying parenthesis, to the left of an unsubscripted array name, or inside a DO-implying parenthesis. A coefficient here is any subscript other than a bare variable, so A(I) has none and A(I+1) has one. When every use is 1-dimensional and has no coefficient, those three positions are allowed, and one list may hold five such definitions. A use later in the same READ TAPE list is allowed only when every use of that variable is a later 1-dimensional subscript without a coefficient, and the subscripted name is wrapped in an extra pair of parentheses. I, (A(I)) is that form. I, A(I) is not, and (B(J, L)) is not, because the subscript is 2-dimensional. READ DRUM forbids a definition to the left of an unsubscripted array name and does not add subscripted drum elements. READ and READ INPUT TAPE require a left parenthesis other than a subscript parenthesis between a definition and a later relative constant in the same list. A, B, K, M, (C(I), J = 1, 10), G(K) has that parenthesis. A, B, K, M, G(K) does not. A, B, K, M, (G(K)) does. A READ TAPE subscript whose variable is an unsubscripted item earlier in that same list is this definition rule. The first-element rule does not also reject it. WRITE TAPE is unchanged. These are placement rules. They are not a delay and they are not the timing inequality.

A bare WRITE, such as WRITE 1, I, is not a 1956 statement. The form on the manual’s list is WRITE OUTPUT TAPE. The error is “a bare WRITE is not a FORTRAN statement”.

--std=0 uses the parenthesized forms on printed pages 19 and 20 of the 1954 report. That reading, including section K and the 1-based drum address, is in dialect/fortran0-deviations.md. The comma syntax in this section is --std=1 and --std=2.

Statement functions

C28-6003 chapter 3 defines name(arguments) = expression. The name is not a subprogram, and it is not a built-in. --std=1 and --std=2 accept it. --std=0 rejects it: the 1954 report has no function statement, and the error is “statement functions are not in FORTRAN 0”. A FUNCTION header is still absent from FORTRAN I.

The statement must precede the first executable statement of its unit. The name is 4 to 7 alphabetic or numeric characters, the first alphabetic and the last F. The value is fixed-point if and only if the name begins with X. That replaces the I–N rule for this name, and it does not apply to a FUNCTION subprogram. SIXTHF(J) = J+K is floating-point, so the integer expression is converted. XSIXTHF(J) = J+K is fixed-point. The arguments are distinct non-subscripted variables, and there is at least one. Empty parentheses remain “a statement function needs an argument”. The 1956 reference, printed page 17, states an argument only when that variable appears in the right-hand expression. Each stated argument must appear there as a variable. The error is “X does not appear in the function statement”. A name in the expression that is not an argument is a parameter of the program. The right-hand expression must not use a subscripted variable. A dummy may share its name with a program variable. At a call the actuals are evaluated first. Each dummy’s binding and alias are saved, and its actual value is stored in a temporary word bound to that dummy. After the expression is evaluated, the original bindings and aliases are restored. A name in the expression that is not a dummy of that statement is read at the call. The expression may call a built-in or an earlier statement function. Under FORTRAN II it may also call a native FUNCTION subprogram or a supported BSS function entry. A call of itself, or of a statement function defined later in the unit, is a compile error. The result is converted to the mode of the function name the way an assignment converts. A variable in the same program must not be a function used there, including a statement function defined there, once the terminal F of that function name is removed. A subscripted name of four or more characters must not end in F.

Hollerith arguments of CALL

A CALL argument nH followed by 1 to 120 characters is accepted in --std=2. C28-6000-2 printed page 16 specifies six BCD characters per 36-bit word, left to right, blank-padding the last word, then a word of 36 one-bits. Those words are stored at the call site. The native original-compiler memory witness checks 11 words including a seven-character argument, a padded one-character argument and terminators.

Letters, digits, blank and the standard punctuation + - / . ( ) , = $ * are accepted; lowercase letters denote uppercase punches. Unsupported characters are rejected. A scalar dummy refers to the first word of an argument of any supported length. Binary tape/drum output preserves all 36 bits for either real or integer dummies. Numeric real access decodes the word as 704 floating point; numeric integer access decodes the sign and bits 18–34, rejecting a magnitude above 32767 as “fixed-point overflow”. Bits 0–17 are ignored numerically. Assignment replaces the raw word with the assigned numeric value. There is no A-format.

Every address belongs to the same 32K word store. FORTRAN array elements occupy descending addresses; Hollerith text occupies ascending addresses, followed by the terminator. Passing a literal associates its first address, without an array-size copy or reversal. A FORTRAN array dummy therefore cannot use increasing subscripts to walk successive text words. Undefined neighbouring words cause diagnostics. Literal mutation persists at the same call site.

Fixed integers occupy the sign and 15-bit decrement field (magnitude shifted 18 bits); binary I/O preserves all raw bits until arithmetic assignment. COMMON, EQUIVALENCE and dummy references share physical cells. --bss accepts supported computational subprogram decks; details and the small SAP assembler are in the bridge guide. --std=0 and --std=1 reject CALL and BSS subprograms.

Translator tables

C28-6000-2 does not print numeric ceilings for the tables numbered 1-22 in C28-6003. --std=2 does not apply those ceilings. A source past a C28-6003 ceiling still compiles in this mode. The figures below are the ones on C28-6003 printed page 50, under the heading that those tables apply exclusively to FORTRAN II. The bound is allowed. --std=1 and --std=0 do not apply them. HOLARG is the only one of the five that says “any one program”. SUBDEF, COMMON, NONEXC, and TSTOPS are totals for the compilation.

SUBDEF uses one word for each SUBROUTINE or FUNCTION name and one word for each argument of that statement. The total must not exceed 900. A repeated dummy in one statement is rejected as a duplicate before this table is consulted. One statement holds at most 32 arguments, which is this compiler’s own cap, so the printed 900 is reached only across statements. A statement function is not a FUNCTION statement and does not add a word.

COMMON counts literal appearances of variables. The same spelling in two program units is two appearances. The total must not exceed 600. A name repeated in one unit is rejected as appearing twice in COMMON and does not reach this table. One unit holds at most 256 names, which is this compiler’s own cap, so the printed 600 is reached only across units.

HOLARG, for each nH argument of a CALL, divides n by 6, adds 1 when the remainder is not 0, and then adds 1. The total for any one program must not exceed 900. A Hollerith field in a FORMAT is not an argument of a CALL.

NONEXC counts non-executable statements. The total must not be greater than 1500. Counted here: DIMENSION, EQUIVALENCE, FREQUENCY, FORMAT, COMMON, a statement function, a SUBROUTINE or FUNCTION header, and END. STOP, PAUSE, CALL, and RETURN are executable and are not counted. Appendix A of C28-6000-2 lists END with the control statements. This compiler does not place it in the executable stream, so it counts.

TSTOPS counts STOP statements, including STOP n. The total must not be greater than 300. PAUSE is not a STOP.

Remaining implementation limits

Persistent media and scripted debug runs are implemented in the media/debug guide. Graphical inspection, next/finish and execution restoration remain future work in the joint design. SAP execution supports the explicit computational subset in the bridge guide; unsupported machine instructions fail with their opcode and location.