Contact us Heritage collections Image license terms
HOME ACL Associates Technology Literature Applications Society Software revisited
Further reading □ Overview1962: An outline of Fortran1962: Operating experience with Fortran1962: Implementation of Fortran on Atlas1962: Proposed target language (BAS)1962: BAS binary card1963: Intermediate Atlas symbolic programming language (INTERASP)1963: Addendum1963: A primer for Fortran programming1964: Atlas Fortran manual: Part I1964: Part II1964: Using HARTRAN1965: System note 41966: Fortran on Atlas □ Atlas 2 at AWRE □ 1965: BAS subroutines1965: System notes1966: S3 Fortran □ Titan □ 1966: System note 11966: System note 21966: Fortran on Titan1966: Compile Master on Titan1966: System Note 31966: Differences between S3 dialect and Fortran II1966: Magnetic tape library subroutines1967: T3 Fortran reference manual
ACD C&A INF CCD CISD Archives Contact us Heritage archives Image license terms

Search

   
ACLApplicationsHartran :: Hartran and Fortran on Atlas
ACLApplicationsHartran :: Hartran and Fortran on Atlas
ACL ACD C&A INF CCD CISD Archives
Further reading

Overview1962: An outline of Fortran1962: Operating experience with Fortran1962: Implementation of Fortran on Atlas1962: Proposed target language (BAS)1962: BAS binary card1963: Intermediate Atlas symbolic programming language (INTERASP)1963: Addendum1963: A primer for Fortran programming1964: Atlas Fortran manual: Part I1964: Part II1964: Using HARTRAN1965: System note 41966: Fortran on Atlas
Atlas 2 at AWRE
1965: BAS subroutines1965: System notes1966: S3 Fortran
Titan
1966: System note 11966: System note 21966: Fortran on Titan1966: Compile Master on Titan1966: System Note 31966: Differences between S3 dialect and Fortran II1966: Magnetic tape library subroutines1967: T3 Fortran reference manual

ATLAS FORTRAN MANUAL Part I

E J York

April 1964

AERE R 4599

AERE - R 4599

AERE - R 4599
Full image ⇗
© UKRI Science and Technology Facilities Council

CONTENTS

Introduction

This manual describes one operating system (HARTRAN) for the I.C.T. Atlas, Part I defines the FORTRAN language, which except for very few points is not oriented towards any particular machine. Part II describes the use of the HARTRAN system to obtain compilation and execution of a FORTRAN program.

It is emphasised that this document is a Reference Manual for the practising programmer and not an introduction, for which reference should be made to the I.C.T. document "A Primer of FORTRAN' Programming for use on Atlas and Orion Computers" C.S. 390, Oct: 1963.

Attention is drawn to the use of the phrases must, should be and will normally be and variants of these. Violation of rules containing the first of these will cause non-compilation, with printed diagnostics. Possible Errors will be diagnosed but compilation continued if any rules containing the second phrase are violated. The third phrase indicates rules violation of which it is not possible for the compiler to detect. They are therefore advisory in nature, however it is most probable that results obtained will be in error if the advice is ignored. The third paragraph of section 2.2.2 contains an example of each form of words.

General Description of the Fortran Language

FORTRAN is a language resembling the ordinary language of mathematics and it not oriented towards a particular machine. Nevertheless, as in all languages, there are local dialects. This manual defines that dialect used by the I.C.T. Atlas.

The language provides for the input of data; the specification of numerical and logical computation and the manipulation of text; and for the output of results.

Numerical computations are mainly performed with REAL (i.e. single-precision floating point) variables, but provision is also made for operations with INTEGERS for the purpose of subscripting and counting etc. Variables may also be declared COMPLEX or DOUBLE PRECISION (but not both) and the appropriate arithmetic operations performed upon them.

The following character set is used in FORTRAN

ABCDEFGHIJKLMNOPQRSTUVWXYZ
0123456789
( ) . , + - π ' * / =

The elements of a program (scalars, vectors, arrays of virtually any number of dimensions, FUNCTIONS and SUBROUTINES, etc, are identified by names chosen by the programmer.

A program is written as a sequence of statements, which are executable (being instructions to perform the stated operations; or declarations (i.e., definitions and specifications). Executable statements are normally executed in the order in which they are written (presented to the system) but statements can be numbered and there are statements which name their successors, either conditionally or unconditionally.

A program is written as a number of routines, one (possibly the only one) of which is the main routine and others are SUBROUTINES (for carrying out procedures) and FUNCTION routines (for evaluating functions). The main routine may invoke any or all of the other routines and each routine may invoke others and so on to virtually unlimited depth, except that no routine may call itself, either directly or indirectly. Each routine is compiled independently and may be written in FORTRAN or the Atlas symbolic programming language (ASP).

FUNCTIONS and SUBROUTINES are identified by the same name throughout a program, other names are usually private to a routine; hence routines can be written in very largely independent notations. Communication of variables between routines is effected by argument lists and/or the use of COMMON and PUBLIC variables, which are accessible to all the routines.

Chapters 2 to 8 give a detailed description of the language.

2. Identifiers and Storage Assignment

2.1 Identifiers

An Identifier is a string of not more than six characters, the first of which is a letter and the remainder alphanumeric (i.e. letters or numerals). Arbitrary identifiers of this form may be used for simple variables, arrays, labels, PARAMETERS, FUNCTIONS and SUBROUTINES.

The same name cannot be used in the same routine for different entities, for example both a simple variable and an array, or for both a variable and a FUNCTION. Contradictory declarations must not be made.

2.2 Classification of Identifiers

Identifiers are classified either implicitly (by usage) or explicitly (by declaration). All declarations will normally appear before all executable statements, and mode declarations before DIMENSION statements.

2.2.1 Simple Variables

These are not declared. An identifier is automatically taken to be that of a simple variable unless there is evidence that it is not.

2.2.2 Arrays and Dimensions

A reference to a member of an array is written as the array name followed by parentheses enclosing one or more subscripts separated by commas. Each subscript is an expression (which will normally be of INTEGER mode, and should be so unless a TRUNCATION declaration (3.4) is made).

Examples      
A(I)
B(I,J,K)
D(2*I+K-J,L+M(3))
N(2*I,J,3-K)

The numbers of subscripts must not exceed the number of declared dimensions and should not be less (unity is assumed for all omitted subscripts). The value of each subscript will normally be greater than zero and not greater than the corresponding dimension.

An identifier is specified as an array name by the association of dimension information with the identifier in a DIMENSION, mode or storage declaration.

The DIMENSION declaration is written

      DIMENSION a(m1 ,m2 , m3,...), b(n1, n2, n3,...) ....

where a, b, ... are identifiers and each of m1, m2,...,n1, n2, ... (the lengths in successive dimensions) is an INTEGER constant, an INTEGER variable or PARAMETER.

Examples
      DIMENSION A(10), B(19,2,3), C(I), D(2,J)
      INTEGER COUNT(16)
      PUBLIC G(19)

The dimension information specifies:

  1. that the name is that of an array
  2. the number of dimensions (the number of subscripts to be expected)
  3. the lengths in the successive dimensions (all but the last of these are needed to compute the location in store of a subscripted variable) - see 2.3.1
  4. the total storage requirements of an actual array.

There is virtually no limit on the number of dimensions.

There are restrictions on the allowed forms of the lengths, depending upon the storage type of the array.

  1. For a dummy array each length may be an INTEGER constant, a PARAMETER or an INTEGER simple variable.
  2. For a private or PUBLIC array each length must be an INTEGER constant or a PARAMETER.
  3. For a COMMON array each length must be a constant.
Example
      SUBROUTINE ABC(A,E,IE,JE)
      PARAMETER JB,ID
      DIMENSION A(1), B(5,JB), C(2,4,6), D(ID) 
     1  E(IE,JE,1)

JB and JD are parametric dimensions

IE and JE are adjustable dimensions

Note that the last or only length of a dummy array is arbitrary; 1 is convenient.

Duplicate dimensions information should not be given and contradictory information must not be given.

2.2.3 Functions

An identifier is recognised as that of a FUNCTION if either

  1. there is a direct reference to it (which is syntactically indistinguishable from a subscripted variable) and there is no declaration which associates dimensions with it. or
  2. It occurs in an EXTERNAL declaration.

A direct reference is written as the identifier followed by parentheses enclosing one or more arguments separated by commas.

A FUNCTION which is referred to indirectly (as an argument of another FUNCTION or SUBROUTINE) will normally also be named in an EXTERNAL declaration. If the only reference to a FUNCTION is indirect and it is not named in an EXTERNAL declaration then it will be incorrectly classified as a. simple variable.

In all routines in which a name is that of a FUNCTION (other than a local function) the same routine is referred to. The same name may be used in other routines as that of a private or dummy variable (simple or array) or of a label, but not as the name of a PUBLIC variable, PARAMETER or SUBROUTINE. Violation of this rule is not, of course, discovered by the compiler.

2.2.4 Subroutines

A SUBROUTINE may be referred to directly and so recognised by its appearance:

  1. In a CALL statement: (see 6.1)
  2. as a successor (see 5.1.1) other than a statement number or label in a transfer statement.

A SUBROUTINE may also be referred to indirectly as an argument of a FUNCTION or another SUBROUTINE. If so it will normally be named in an EXTERNAL declaration. If the only reference is indirect and it is not named in an EXTERNAL declaration then it will be incorrectly classified as a simple variable.

In all routines in which a name is that of a SUBROUTINE the same routine is referred to. The same name may be used in other routines as that of a private or dummy variable (simple or array) or of a label, but not as the name of a PUBLIC variable, PARAMETER or FUNCTION (other than a local function).

2.2.5 The EXTERNAL Declaration

This is written

      EXTERNAL a1, a2, a3, ...am

where a1, a2, a3, ...am are identifiers, which are thus declared to be routine names.

2.2.6 The PARAMETER Declaration

This is written

      PARAMETER a1, a2, a3, ...am

where a1, a2, a3, ...am are identifiers, which are thus declared to be PARMIETERS. A PARAMETER is an integer constant the value of which is not declared in the source program but at load time by the loader directive DEFINE (Part II). The principal use is in dimension information (2.2.2).

A name refers to the same entity in all routines in which it is declared a PARAMETER and to different entities in routines in which it is not so declared. The same name cannot be used for a parameter. In some routines and for a FUNCTION (other than local function) or SUBROUTINE or PUBLIC variable in others. Violation of the rule is not, of course, discovered by the compiler.

2.2.7 The mode of simple variables, arrays and FUNCTIONS

Each simple variable, array, FUNCTION or local function has a mode which is determined implicitly (by the first character of the identifier) or explicitly (by declaration).

In the absence of an explicit mode declaration the mode is determined by the first character of the identifier. If this is I, J, K, L, M or N the mode is INTEGER, otherwise it is REAL.

The mode declarations are:-

      INTEGER          a1, a2, a3, ....
      REAL             b1, b2, b3, ....
      DOUBLE LENGTH    c1, c2, c3, ....
   or DOUBLE PRECISION c1, c2, c3, ....
      COMPLEX          d1, d2, d3, ....
      LOGICAL          e1, e2, e3, ....
      TEXT             f1, f2, f3, ....

where a1, a2, a3, .... >b1, b2, b3, .... f1, f2, f3, .... are identifiers.

An array identifier appearing in a mode declaration may optionally be followed by dimensions.

Examples
      INTEGER COUNT, T, B(20) 
      REAL LAMDA, KAPPA (10,2) 
      DOUBLE LENGTH A, X(5) 
      COMPLEX Z(10,20.2) 
      LOGICAL L, LO(N) 
      TEXT TITLE(14), NAMB(12), FORM(14)

The variables I, J, ICOUNT unless they appear in mode declarations are of INTEGER mode; similarly Y, ALPHA, THETA are of REAL mode.

2.3 Storage Assignment

2.3.1 Storage of Arrays

Arrays are stored with the earlier subscripts more rapidly varying than the later subscripts. Thus A(I,J,K,L) refers to a storage location which is greater than that of A(1,1,1,1), the base address of A, by

 (I-1) + (J-1)*d1 + (K-1)*d1*d2 + (L-1)*d1*d2*d3

where the relevant DIMENSION statement is

      DIMENSION A(d1,d2,d3,d4)
2.3.2 The EQUIVALENCE declaration

This is written

      EQUIVALENCE (a1,a2), (b1,b2,b3), (c1,c2,...)), .......

where a1,a2, b1,b2,b3, c1,c2,..., ....... are variable names, either simple or array. The latter may be subscripted.

It forces all those variables enclosed in the same pair of parentheses to be assigned the same location in store. Not more than one must be named in a COMMON statement.

When a subscripted array name is referred to in an EQUIVALENCE statement all the declared lengths, except that corresponding to the last or only subscript, must be constants.

2.3.3 The PUBLIC declaration

This is written

      PUBLIC a1, a2, a3, ..... am

where a1, a2, a3, ..... am are variable names (array names may optionally be followed by dimension information).

It forces the variables named to be assigned locations in the PUBLIC store, and causes the same name to refer to the same variable in all those routines in which it is declared PUBLIC. In other routines in which it is not so declared it may be used to refer to different entities (simple variables, arrays or labels, but not PARAMETERS, FUNCTIONS (other than local functions) or SUBROUTINES).

2.3.4 The COMMON declaration

This is written

      COMMON a1,a2,a3,../x/b1,b2,b3,../y/c1,c2,...

where x, y are common block names and a1,a2,a3,.. b1,b2,b3,.. c1,c2,... are variable names (array names may optionally be follov/ed by dimension information).

Example
      COMMON A,B,C /X/ D,E,F /Y/ G(5,5), H(10), U(15) // I,J

It causes the named variables to be assigned locations in the common store. This is a part of the store accessible to all routines of a job and may be divided into any number of common blocks. The variables following a block name are placed in the common block of that name. Any variables not proceeded by a block name, or following two consecutive slashes, are placed in the unlabelled common block.

The above example specifies that the variables A,B,C,I and J are assigned storage in.the unlabelled common block. Also the array G is assigned the first 25 locations in the common block Y, the array A the next 10 locations and the array U the next 15 locations. Thus communication of common variables between routines is by virtue of assignment to the same absolute location and not by having the same name.

Common block names are effectively PUBLIC (i.e. the same block name refers to the same common block in different routines). The length of each common block is defined by the first routine to be loaded in which the block is referred to. Therefore this routine must specify the block to be at least as long as specified by any other routine.

2.4 Storage Initialisation

All variables, simple and array, private, PUBLIC and COMMON are initially set to zero. Private arrays and scalars may be set to values other than zero by use of the INITIAL statement.

2.4.1 The INITIAL Statements

Syntax

      INITIAL item, item, item, ...

each item is written

(a = c1, c2, c3, ....)

where a is a simple or subscripted variable and c1, c2, c3, .... are constants (see 3.2, 4.1).

A simple variable will normally be followed by only one constant, a subscripted variable by not more than is sufficient to fill the array.

PUBLIC, COMMON and dummy variables must not be named in an INITIAL statement.

Semantics

(1) The value of a is set to the constant c

(2) The values of successive members of the named array, starting at the specified member, are set to the successive specified constants.

Example
      LOGICAL C(2) 
      TEXT E 
      INITIAL (PI = 3.14159265),(A(1) = 1.2, 2.4, 3.6, 4.8), (C(1) = .TRUE.,.FALSE) (E = 3HEND)

3. FORTRAN Arithmetic

3.1 Scope

The scope of this chapter is confined to INTEGER and REAL arithmetic. DOUBLE PRECISION and COMPLEX are discussed in chapter 8.

3.2 Constants

A constant is written as a string of decimal digits with possibly a decimal point (before all digits, after all, or between any two), and possibly followed by an exponent part which is written as the character E, an optional + or - sign and a decimal digit string.

The constant has the conventional value (the exponent part being an integer and specifying a power of 10 on a scale factor). It is of mode REAL if it contains either a decimal point or an exponent part. An INTEGER constant is written with neither decimal point not exponent.

Example
0, 6    are INTEGER constants
6., 6.0, 6E0, 0.6E1, 60E-1 are all ways of writing the same REAL constant

If a constant which would be otherwise treated as INTEGER is too large, a following decimal point is assumed by the compiler (giving mode REAL) and a possible error is diagnosed.

3.3 Arithmetic Expressions

3.3.1 Syntax

If E represents an arithmetic expression, then:

E  = E' or +E' or -E'
E' = c            a constant             3.2
     v            a simple variable      2.2.1
     A            a member of an array   2.2.2
     F            a function reference   2.2.3
     (E)          a subexpression   
     E'**E'
     E'*E'
     E'/E'     
     E'+E'     
     E'-E'     

If the number of left and right parentheses are not in agreement the compiler will append or remove (if possible) right parentheses at the end of the expression, and diagnose a possible error. If balance cannot be achieved by removal of right parentheses a serious error is diagnosed.

3.3.2 Semantics

An arithmetic expression is interpreted thus. It is considered to be made up of segments, each of which is either a primary, a factor, a term or the whole expression.

(1) A Primary is any of (l) to (5) of 3.3.1.

(2) A Factor is a primary or sequence of primaries separated by the exponentiation symbol, **.

(3) A Term is a factor or sequence of factors separated by the multiplication or division symbols, * or /.

(4) An expression is a term or sequence of terms separated by + or -, and possibly preceded by + or -.

An expression is evaluated after all constituent terms have been evaluated, a term after all constituent factors and a factor after all constituent primaries.

In an expression the operators + and - apply only to the term immediately following. Hence A-B+C-D is equivalent to ((A-B)+C)-D. Similarly the term A/B/C*D is equivalent to ((A/B)/C)*D and the factor A**B**C is equivalent to (A**B)**C.

The mode of an expression is INTEGER if all the constituent terms have INTEGER mode, if any are REAL then the expression is REAL. Any INTEGER terms in a REAL expression are evaluated in INTEGER mode and the results converted to REAL mode before evaluation of the expression. Any INTEGER factor in a REAL term is treated similarly, so also any INTEGER primary in a REAL factor.

The mode of a subscripted variable is independent of the mode of its subscripts, which should be INTEGER. The mode of a FUNCTION is independent of the mode of its arguments.

The above rules are illustrated by the following example:

(A(2*I+J, 3*J+K) +B*C+ (C**D)**E + COSF (C*F+G)) * (H1 + H2 + AA*BB*CC) 

This is evaluated by tracing the branches of the tree downwards:

2*I I1 +J I2 3*J I3 +K I4 with dimensions of A A( I5 ) B*C + A4 C**D A7 **E + A5 2.0*F A9 +G COSF( A8 ) + A6 A11 AA**BB**CC H1+H2+ A12 * A13 Result

The operator symbol / in an INTEGER term means divide and take the integer nearer to zero. Thus, 2/J is an INTEGER term and if J has the value 3, then the value of the term is zero even though it may now be converted to REAL form for inclusion in a REAL expression.

2.0/J is a REAL term and if J = 3 it has the value 0.6666....

3.3.3 Contexts

An arithmetic expression may appear in any of the following contexts:

  1. On the right hand side of an arithmetic statement (3.4)
  2. As an argument of a FUNCTION or SUBROUTINE (6)
  3. As a subscript (2.2.2)
  4. ; ;:
  5. In a relation (4.3)
  6. As the argument of an arithmetic IF statement (5.3)
  7. As the argument of a computed GO TO statement (5.3)
  8. As an indexing parameter of a FOR or DO statement (5.4)

An expression should be of mode INTEGER where the context demands this. In the absence of a TRUNCATION declaration the use of the NINTF is assumed and a possible error diagnosed, wherever a REAL expression appears in an INTEGER context.

3.4 The TRUNCATION declaration

This is written

      TRUNCATION   a 

where a is one of INTP, IFIXP, NINTF (see Appendix 1).

It specifies the type of truncation to be applied wherever a REAL expression appears in an INTEGER context.

In the absence of this declaration the NINTF is assumed and a possible error diagnosed wherever a REAL expression appears in an INTEGER context.

3.5 The Arithmetic computation statement

An arithmetic statement is written

      a1, a2, a3, ....., an = b

where a1, a2, a3, ....., an are variables (simple or subscripted, of mode REAL or INTEGER) and b is an arithmetic expression.

The symbol = specifies replacement rather than equality, and the statement is interpreted as Evaluate the expression b and take the result as the new value of the variables a1, a2, a3, ....., an. Any or all of the variables a1, a2, a3, ....., an may appear in the expression b, but they are unchanged until evaluation of the expression is complete.

Any of the variables may be of different mode from the expression b. The necessary conversions are made automatically.

Examples: 
(l)  A = I + J       is equivalent to A = FLQATF(I+J)
(2)  I = A + B       is equivalent to I = NINTF(A+B) but a possible error is 
                         diagnosed (unless a TRUNCATION declaration has been made)
(3)  C, I, B = A + B is equivalent to a = A + B
                                      C = a
                                      B = a
                                      a = NINTF(a)
                                      I = a
                                      but a possible error is diagnosed
                                      (unless a TRUNCATION declaration has been made)
(4) C, I, B = I + J  is equivalent to a = I + J
                                      I = a
                                      a = FLOATF (a)
                                      C = a
                                      B = a

Note: If J has the value 3
A, I = 2.0/J causes A and I to assume the values 0.66666... and 0 respectively whereas A, I = 2/J sets both A and I equal to zero

3.6 The local FUNCTION

This is a function defined by a single arithmetic statement and available only to the routine in which it is defined. The definition is written

      a(b1, b2, b3, ... bn) = c

where a is the function name, b1, b2, b3, ... bn are the dummy arguments, of which there must be at least one and c is an arithmetic expression which may involve the dummy arguments, and other variables and FUNCTIONS and any local functions previously defined, but must not involve subscripted variables.

The dummy arguments indicate positions in which actual arguments are to be substituted each time the function is invoked. They must be variable names and will normally be different from names used elsewhere in the routine. At each reference to the function the actual arguments will be constants, variables or expressions.

It is the programmer's responsibility to ensure agreement in number and mode of dummy and actual arguments. Variables appearing in the expression and which are not dummy arguments are assumed to have their current value each time the function is invoked.

The arithmetic statement function definition is not an executable statement. It must appear before all executable statements and before any other arithmetic statement function definition which refers to it.

4. Boolean Variables and Operations

A Boolean entity is a string of 24 (LOGICAL) or 48 (TEXT) binary digits (or bits). A logical operation upon a variable of mode TEXT operates upon the first (left-most) 24 bits.

4.1 Constants

A Boolean constant is written

    nB a1 a2 a3 ...

where n is an INTEGER constant which should not exceed 16 and a1 a2 a3 are octal digits which must not exceed n in number.

Each octal digit is converted to 3 bits. If the number of octal digits is less than n then leading zeros are assumed. If n is less than 16 then 16- n following zeros are assumed.

Examples   
(l) 8B123 specifies the constant
    000000000000000001010011 000 000 000 000 000 000 000 000 
(2) 1BO specifies a string of 48 bits all zero. 

There are two LOGICAL constants

.TRUE. equivalent to the Boolean constant 16B7777777777777777 and

.FALSE, equivalent to 1B0

A TEXT constant is referred to by an identifier which is written nA where n is a statement number. The statement referred to is written

    n  FORMAT  π ..........................π

All the characters between the two characters π, including blanks, constitute the constant. If either terminal character of the constant is not blank then the corresponding π may be omitted.

A TEXT constant may contain any number of characters. It is strictly an array of as many elements as are necessary to contain the constant with 8 characters to each element. Use of the name by itself in a simple variable context refers, as with all arrays, to the first element (i.e. to the first 8 characters).

A TEXT constant may alternatively be written as nH followed by n characters.

4.2 LOGICAL Operator Symbols

There are 4 operators, each operating upon strings of 24 bits.

(l) .NOT. is a unary operator and .NOT. B produces a bit-string with 1's where B has 0's and 0's where B has 1's.

(2) A .AND. B produces a bit-string with 1's where both A and B have 1's and O's elsewhere.

(3) A .OR. B produces a bit-string with 1's where there are 1's in A or B or both and 0's elsewhere.

(4) A .ER. B and A .NONEQ. B both produce a bit-string with 1's where A and B differ and 0's elsewhere.

4.3 Relations

A relation is an implied LOGICAL function of two or more expressions and is written:

      (A φ B φ C φ D .....)

where A, B, C, D ... are expressions which should either be all arithmetic or all TEXT (See 4.7) and φ is one of the following relators:

.GT. for greater than
.GE. greater than or equals
.LT. less than
.LE. less than or equals
.EQ. equals
.NE. not equals

A relation has one of two logical values .TRUE. or .FALSE, when comparing TEXT quantities there is an implied dictionary order. See Appendix.

4.4 LOGICAL Expressions

4.4.1 Syntax

If L represents a LOGICAL expression, and L' one not beginning with the operator .NOT., then the following are possible forms for L.

  1. C a logical constant (4.1)
  2. V a simple variable of mode LOGICAL (2.2.1, 2.1)
  3. A (Subscript list) a member of an array of mode LOGICAL (2.2, 2.2.2)
  4. F (Argument list) a reference to a LOGICAL function (2.2, 2.2.5)
  5. A relation (4.3)
  6. (L) a subexpression
  7. L'
  8. .NOT.L'
  9. L φ L' where φ is any LOGICAL operator (4.2) other than .NOT.
4.4.2 Semantics

A LOGICAL expression is interpreted thus: It is considered to be made up of segments, each of which is a primary, a factor, a term or the whole expression.

(1) A primary is any of (l) to (6) of 4.4.1

(2) A factor is a primary or a sequence of primaries separated by the symbol .AND.

(3) A term is a factor or a sequence of factors separated by the symbol .OR.

(4) An expression is a term or a sequence of terms separated by .ER. and possibly preceded by .NOT.

An expression is evaluated after all its constituent terms have been evaluated, a term after all its constituent factors and a factor after all its constituent primaries. The operator .NOT. applies only to the primary immediately following it.

Example
.NOT.A.AND.B.AND.C.ER.D.ER.E.OR.F.OR.G.AND. (X.GT.Y) 
is equivalent to 
(((.NOT.A).AND.B.AND.C).ER.D.ER.E.).OR.F.OR.(G.AND.(X.GT.Y)) 
A.AND.B.AND.C
A.OR.B.OR.C
A.ER.B.ER.C are not ambiguous
4.4.3 Contexts
A LOGICAL expression may appear in any of the following ways:

(1) on the right hand side of a computation statement

(2) as an argument of a FUNCTION or SUBROUTINE

(3) as the argument of a logical IF statement

(4) in a special form of the arithmetic IF statement (4.7)

4.5 The Logical computation statement

This is written:

a1, a2, a3, ... an = b

where a1, a2, a3, ... an are LOGICAL variables, simple or subscripted and b is a LOGICAL expression.

4.6 The Local logical function

This is used and defined exactly as the local arithmetic function (3.6) but c is a LOGICAL expression and the function name must be declared LOGICAL.

Examples
      LOGICAL ORDER, TEST
      ORDER(A, B, C, D, E) = (A.GT.B.GT.C.GT.D.GT.E) 
      TEST(X) = (X0.LE.X.LT.X1)

4.7 Operations upon TEXT

A TEXT expression is syntactically equivalent to a LOGICAL expression but operations are carried out upon strings of 48 bits.

TEXT expressions (and therefore also LOGICAL expressions) may be compared by appearance in relations(4.3). (See Appendix 2.)

Two TEXT or LOGICAL expressions, L1 and L2, may also appear in the arithmetic .IF statement thus

      IF((L1) - (L2)) n1, n2, n3

The implied ordering is Dictionary order.

5. Flow of Control within one routine: Structure of a routine

The executable statements (instructions) of a routine are executed one at a time; control flows automatically from one to another.

The first statement to be executed in a routine is the first (written) instruction. On completion of execution of each instruction, control usually flows to the next (written) instruction. There are three exceptions to this rule:

  1. Some statements (GOTO, IF) explicitly specify the next instruction to be executed (i.e. their successor). These are called transfers.
  2. Some statements (DO, FOR, REPEAT) cause repetitive execution of a group of instructions, called a loop.
  3. The statement RETURN causes execution of the routine to finish (see 6.4). The last (written) instruction of a routine should be either a transfer or RETURN.

A routine should be so constructed that control can flow to every statement of it.

5.1 Successors and their Specification

5.1.1 Successors

Successors are identified by

  1. The statement number of an executable statement in the same routine.
  2. The name of a subroutine, which has no arguments and from which there is no return.
  3. The name of a label.
5.1.2 The ASSIGN statement
      ASSIGN (α) TO β

where α is a successor identifier and β is a label identifier. (The appearance of a name in the position β defines it to be a label identifier). The parentheses may be omitted if α is a statement number.

Execution of this statement causes subsequent use of the label β as a successor to be equivalent to the successor identifier α, until a different successor is assigned to β.

It is an error to execute any statement of which the specified successor is a label, before execution of an ASSIGN statement assigning a value to that label.

Examples
      ASSIGN 5 TO J
      ASSIGN (J) TO K

These cause subsequent transfer statements containing J or K as successors to transfer to statement number 5.

5.1.3 The CONTINUE statement
      CONTINUE

This is a dummy statement, i.e. execution of it causes no action. It is a convenient statement to carry a statement number which might be placed either at the head of a block of program reached by a transfer or at the tail of a block of program forming a loop. This makes it easier to insert extra statements during the debugging stage. It is essential at the end of a loop where the last statement would otherwise be one which named its successor.

5.2 Transfers

5.2.1 The simple GO TO statement
      GO TO n0
      GO TO n0, (n1, n2, n3, ...) 

where n1, n2, n3, ... are successor identifiers and n is a label.

The next statement executed is that specified by ni or n0: control is transferred to ni or n. The successors n1, n2, n3, .... are those which can be currently assigned to the label n when the statement is executed, i.e. all possible successors. If no list is given when n0 is a label, all values assigned to n0 within the routine are presumed to be possible successors.

      GO TO 5
      GO TO JUMP
      GO TO EXIT
      GO TO LINK, (25,30,40)
5.2.2 The computed GO TO statement
      GOTO (n1, n2, n3, ...., nm), α

where n1, n2, n3, ...., nm are successor identifiers and α is an arithmetic expression which should be made INTEGER (usually an INTEGER variable). (See 3.4).

The expression α is evaluated and control is transferred to ni where i = NINTF(α). It is the programmer's responsibility to ensure that 1 ≤ i ≤ m.

Examples
      GOTO (10,JUMP,EXIT,101,62,10,10,2),(I-5)/2
      GO TO (11,12),I
5.2.3 The Arithmetic IF statement
      IF(α) n1, n2, n3

where α is an expression (normally arithmetic but see 4.7) and n1, n2, n3 are successive identifiers.

The expression α is evaluated and control is transferred to

n1 if α < 0

n2 if α = 0

n3 if α > 0

Examples
      IF(ABSF(A - OLDA) - EPS) 10,10,20
      IF (B(I)) 1,2,1
5.2.4 The Logical IF statement
      IF(α) n1, n2

where α is an expression (normally logical) and n1, n2 are successor identifiers.

If α is simply a relation, double parentheses are not necessary.

The expression α is evaluated, and control is transferred to

n1 if α is non-zero (including .TRUE.)

n2 if α is zero (.FALSE.)

Examples
      IF (A.GT.B) 30,110
      IF (ABSF( (A-OLDA).GT.EPS)20,10
      IF (X.AND.Y.OR.Z)1,2
5.2.5 The next executable statement as a conditional successor

The next executable statement may be specified as a possible successor to an IF or computed GOTO statement by the absence of a successor identifier.

Example
      IF (A) 10,11,

causes control to be transferred to the next executable statement if A > 0; to 11 if A = 0 and 10 if A < 0. The final comma should be present.

      GO TO (10, 20, , , , 60, ,), I

Control is transferred to the next executable statement if I is 3, 4, 5,7 or 8. I should not exceed 8. The number of commas is significant.

5.3 Loops: DO, FOR and REPEAT statements

5.3.1 Syntax
      DO n α = β1, β2, β3
      FOR n α = β1, β2, β3
      REPEAT

Where n is a statement number or omitted

Where α is a numerical variable identifier (the index)

Where β1, β2, β3 are arithmetic expressions (the indexing parameters) which should have the same mode as α (see 3.3.3)

β3 with its preceding comma may be omitted.

5.3.2 Syntax of Loops

A loop consists of a DO or FOR statement followed by a body consisting;= of one or more executable statements or loops (see 5.3.5) and is terminated by the REPEAT statement (if no statement number is specified in the DO or FOR statement) or an executable statement bearing the statement number specified in the DO or FOR statement. This statement must not be one which names its successor.

5.3.3 Semantics

If β3 is not specified, unity is implied. If (β2 - β2) and β3 have opposite signs, the body of a FOR loop is skipped, a DO loop is executed once. Otherwise, the body is executed repeatedly, (unless control is transferred out of the loop), while α takes successive values of the arithmetic progression

β1, β1 + β3, β1 +2 β3 ...

in the closed interval (β1, >β2), i.e. as long as α does not go beyond β2.

Thus the following loop

      FOR I = IEXPR1, IEXPR2, IEXPR3 
      body
      REPEAT

is equivalent to the following sequence of elementary instructions:

      I  = IEXPR1
      I2 = IEXPR2
      I3 = IEXPR3
      I2 = (-I +I2 + I3)/I3 - 1
      IF   (I2) 3, 2, 2
   1  I  = I + I3
   2  body
      IF(I2) , 3,
      I2 = I2 - 1
      GO TO 1
   3  CONTINUE

Note that in the initialisation, I2 becomes the number of repetitions required (i.e. executions -l). This is counted down at the repeat. For a DO loop, we have

      IF (I2) , 2, 2
      I2  =  0
      GO TO 2

instead of the statement before 1.

5.3.4 Notes

The index α may be used within the loop and outside it; the appropriate value is assigned to α before beginning each execution of the body.

There must be no statement inside a loop which changes the value of the index. Statements which change the value of any variable involved in the indexing parameters have the normal effect on these, but do not change the behaviour of the loop.

Example
      SUM = 0.0
      FOR I = J1, J2, 2
      SUM = SUM +A(I)
      REPEAT
      FOR I = 1,21
      IF (I-1) 15, 16, 15
   16 X = PI -SQRTF(2*DELTA)
      GO TO 17
   15 X = FUN (X,I)
   17 CALL OUT (X, I)
      REPEAT
5.3.5 Nests of Loops

As stated in 5.3.2, loops may be nested, i.e. one DO or FOR loop may be part of another, to virtually unlimited extent. For each execution of any loop, all repetitions of any inner loops are carried out.

Example
      FOR I = 1,10
      FOR J = 2,10,2
      ......
      REPEAT
      REPEAT

At each execution of the outer loop (with I = 1, 2, 3, ... ,10) the inner loop is repeated for J = 2, 4, 6, 8 and 10.

The same variable must not be used as the index of two loops one nested within the other. (This is a special case of the rule forbidding statements which change the value of the index within the body of a loop.) The index may, of course, be used in the indexing parameters of an inner loop.

Example
      DO 100 I = 1,10
      DO 101 J = 1,I
      .....
  101 CONTINUE
  100 CONTINUE

Note that it is essential for one loop to be included completely in another, if at all. The REPEAT notation automatically prevents violation of this rule (it was introduced for this reason), but when statement numbers are used to specify loop terminations, syntactic errors are possible.

Example
      DO 100 I = 1,10
      DO 101 J = 1,I
      .....
  101 CONTINUE
  100 CONTINUE

The above example is equivalent to the first example in this section: the first REPEAT matches the second FOR statement. It is a syntactic error to interchange the two CONTINUE statement.

There is no prohibition on mixing the notations: e.g.

      DO 1 I = 1,NL
      FOR J = 1, NR
      .....
   1  REPEAT

Note that these loops are completely nested: the FOR...REPEAT being a complete loop, and the outer DO loop ending at statement number 1 (which is also the last statement of the inner loop). If the DO and FOR statements had been interchanged, there would be a syntactic error, for the last statement of the inner DO loop would be an isolated REPEAT, which is not one of the allowed constituents (see 5.3.2).

6. Communication between Routines: FUNCTIONS and SUBROUTINES

The differences between the two types of routine are very slight, the principal one being the way in which they are invoked, a FUNCTION by reference to it in an expression, a SUBROUTINE generally by means of the CALL statement but also (if there are no arguments and no return) by naming it as a successor in an IF or GO TO.

A SUBROUTINE may have any number of arguments or none. It may operate upon and change any or all of them and any variable declared COMMON or PUBLIC, it may cause input or output, it may be so written that it does nothing at all. It need not return to the point from which it was entered.

A FUNCTION must have at least one argument. It evaluates and returns to the expression in which it is referred to, a scalar value. It will not normally do anything else.

6.1 The CALL statement

This is written

      CALL NAME (a1, a2, a3, ..., am)
   or CALL NAME

where a1, a2, a3, ..., am are the arguments.

It causes control to be transferred to the SUBROUTINE the name of which is NAME. Return from this SUBROUTINE is to the next executable statement following the CALL statement.

6.2 The SUBROUTINE statement

The first statement in a SUBROUTINE the name of which is NAME is written

      SUBROUTINE NAME (a1, a2, ..., am)
   or SUBROUTINE NAME

where a1, a2, a3, ..., am are the dummy arguments.

6.3 The FUNCTION statement

The first statement of a FUNCTION routine the name of which is NAME is written

      FUNCTION NAME (a1, a2, ..., am)

where a1, a2, a3, ..., am are the dummy arguments.

The function name is treated inside the routine as the name of a scalar variable. Its mode may be declared and if not declared depends upon the first character of the name in the usual way. The value of the FUNCTION is the value of this variable on return from the routine. This value may be set by the appearance of the name on the left hand side of a computation statement or in an input list. It may also be set by a SUBROUTINE of which it is an argument.

6.4 The RETURN statement

the statement

      RETURN

in a function routine or SUBROUTINE causes transfer of control back to the point from which it was entered. In the case of a FUNCTION this is into the middle of evaluating an expression, the return from a SUBROUTINE is to the calling routine at the next executable statement following the CALL statement. A RETURN statement in a main routine terminates execution of the job. A routine may contain any number of RETURN statements.

6.5 Dummy Arguments

The dummy arguments following the name in either a FUNCTION or SUBROUTINE statement indicate positions in the body of the routine where actual arguments are to be substituted each time the routine is executed. Dummy arguments must be simple identifiers, i.e. variable names, array names without subscripts or dummy function or subroutine names without arguments. They must not be named in PUBLIC or COMMON statements. They must not appear in EQUIVALENCE statements but an implied equivalence may be combined with a FUNCTION or SUBROUTINE statement thus:-

      FUNCTION NAME (a1, a2 = b2 = c2, a3, a4 = b4)

where a2, b2 and c2 are different names of the same dummy argument and similarly a4 and b4.

6.6 Compatibility of Actual and Dummy Arguments

In this section the word must does not refer to violation of compiler rules but to the necessary conditions for obtaining sensible results. Violation will sometimes result in chaos.

  1. The actual and dummy arguments must be the same in number, of the same kind and presented in the same order.
  2. If a dummy argument is a simple variable name then the actual argument must be an expression of the same mode (but see 6, below).
  3. If a dummy argument is an array name then the actual argument must be an array name, and will not normally be subscripted. The dimensions of dummy and actual arrays must be in agreement. If the dimensions of a dummy array are adjustable then they must be adjusted at each execution to be in agreement with those of the actual array. The last or only dimension need not agree.
  4. If the dummy argument is a dummy SUBROUTINE name then the actual argument must be an actual SUBROUTINE name.
  5. If a dummy argument is a FUNCTION name then the actual argument must be the name of a closed library function or of a FUNCTION routine. It must not be the name of an open library function.
  6. An argument may be an input argument, i.e. a means of communicating to the called routine, or an output argument, i.e. communicating back to the calling routine, or it may be both. An actual output argument must be a variable (not a constant or expression). When an actual argument is an expression, the compiler creates a variable with a hidden name and the calling routine sets the value of this variable to that of the expression.
  7. When FUNCTION and SUBROUTINE names appear as arguments of other FUNCTIONS or SUBROUTINES then the above rules are applied recursively, (See example 2 of 6.7).

6.7 Examples

(1)
      SUBROUTINE ABC (X, Y, Z, L, M, N, IX, IY, IZ)
      DIMENSION X(IX,1), Y(IY,1), Z(IZ,1)
      FOR I = 1,L
      FOR K = 1,N
      Z(I,K) = 0.0
      FOR J = 1,M
      Z(I,K) = Z(I,K) + X(I,J) * Y(J,K)
      REPEAT
      REPEAT
      REPEAT
      RETURN
      END

This SUBROUTINE forms Zik ( = Σ xijyjk) over j=1,m of i= 1 to l, k=1 to n.

The remaining arguments IX, IY and IZ are the adjustable dimensions of the dummy array, X, Y and Z.

Note the distinction between L and IX, and between M and IY, etc.

Examples of calls of this SUBROUTINE are given

      DIMENSION A(10,10), B(10,10), C(10,10), D(10,10), E(IE,JE), F(IF,JF)
      .......
      CALL ABC (A,B,C,5,10,5,10,10,10)
      .........
      CALL ABC (D,E,F,5,10,5,ID,IE,IF)
      .........

The first call causes the evaluation of Cik = Σ AijBjk over j=1,10 of i=1,5 and j=1,5

In the second case, D, E and F are the arrays operated upon.

(2)
      SUBROUTINE ABC (X, DUM, Y)
      -----------
      CALL DUM (W1, W2, IW3)
      -----------
      RETURN
      END

Possible calls are, for example

      CALL ABC (D, DUM,1, E)
      CALL ABC (6.5, DUM2, 13.0)
      CALL ABC (W1, DEF, W2)

where DUM1, DUM2 and DEF are all names of SUBROUTINES each of which require 3 arguments, the first two REAL and the third INTEGER.

Note that W1, W2 in the last call have no connection whatever with the working variables W1, W2 used by the SUBROUTINE ABC.

(3)
      FUNCTION XYZ (A, B, C, I, J)
      K = (I-J)/2
      XYZ = A*B-C**K
      --------------
      RETURN
      END

Examples of calls of the routine

      X = XYZ(U,V,W,J,K)
      X = XYZ(0.2,ALOG(10.3*A**Z)+6.0,A,6,2)
      X = (A + B - XYZ(A,B,C,2,10))*SQRTF(XYZ(U,V,W,J,K))
      X = XYZ(1.3,XYZ(A,B,C,2,10),D,3,5)

7. Input and Output, Magnetic Tapes

7.1 Input and Output Statements

      READ  c  list
      PRINT c  list	,
      PUNCH c  list
      READ (a,d) list
      WRITE (b,d) list
      READ INPUT TAPE m, c, list
      WRITE OUTPUT TAPE n, c, list

where

a is the logical number of an input document,

b of an output document

m of a magnetic tape unit or an input document

n of a magnetic tape unit or an output document

c is either

  1. the number of a FORMAT statement.
  2. the name of a TEXT array in which the format specification, enclosed in parentheses, is stored.
  3. not specified (the comma is still essential, if a list follows

d may be any of the alternative forms of c and in addition a simple format not including parentheses but itself enclosed in parentheses.

      READ (a,c) list
      READ c,    list
      READ INPUT TAPE n, list

cause the copying of information of input documents to locations in the machine store, with conversion from external form specified by the relevant format specification.

READ c, list in which no document is explicitly named is equivalent to READ (0,c) list and refers to the system input document, numbered 0 and defined to be that on which the program is presented.

      PRINT c,    list
      PUNCH c,    list
      WRITE (b,c) list
      WRITE OUTPUT TAPE n, c, list

cause the copying of information specified in the list to the specified output documents, the external form of the information being controlled by the relevant format specification.

      PRINT c, list
      WRITE(0,c) list

are equivalent and. refer to the same channel as used for printed output from the FORTRAN compiler.

      PUNCH c, list
 and  WRITE (15, c) list

are equivalent and refer to the card punch on which are produced the binary cards of the object program resulting from a compilation.

An input or output document is treated one line at a time, using a buffer which can hold 160 characters. The Fortran input/output statements cause the appropriate input or output stream to be selected, and the buffer initialised appropriately. The format specification in the given FORMAT statement controls subsequent action.

The processing of a format specification is independent of whether it is controlling input or output, except that a different group of subsidiary routines is used for conversions.

A format specification can be thought of as a piece of program in a special language, which is executed interpretively when the corresponding input/output statement is obeyed. The various characters which can occur in a format specification correspond to orders, which are implemented by the main format processing routine and its subsidiaries.

7.2 Input/Output Lists

An input/output list is written as any number (including zero, in which case the preceding comma is omitted) of items separated by conmas. A list item may be simple or compound. A simple item is either a simple variable, a subscripted variable or an unsubscripted array name. An item in an output list may be an expression (arithmetic, logical or text). A compound item is written

 
    (list, i = m1, m2, m3)	
or  (list, i = m1, m2)

where list is already defined.

Simple items are input or output in the specified order. An unsubscripted array name specifies the whole array. For example if A is an array then its appearance in a list is equivalent to

   (...(((A(I,J,K,...), I=1,d1), J=1,d2) k=1,d3) ....)

where the relevant dimension statement is

      DIMENSION A(d1, d2, d3, ....  )

A compound item specifies repetition of the items in the list with the index i assuming in turn those members of the sequence m1 , m1+m3, m1+2m3, ... which lie in the closed interval (m1, m2). If m3 is not specified unity is assumed. The implied loop in compound list items may be nested to virtually unlimited depth. The same variable must not be used for the index of two loops one nested within the other even if the inner loop is implied in an input/output list and the outer loop explicitly specified by a DO or FOR statement. The implied loop of an input output list is similar to a DO statement rather than a FOR statement in that the items in the list are input/output at least once.

7.3 Syntax of FORMAT specification

A FORMAT statement must be numbered and is written

   n  FORMAT (Format specification)

When a format specification is stored in a TEXT array the enclosing parentheses are also stored.

A format specification is written as a sequence of field specifications and/or control specifications, in general separated by commas or slashes. The specifications are:-

  1. nH followed by n characters, where n is an unsigned decimal integer.
  2. S followed by 2 characters. [The characters following H and S may be chosen from the complete character set and blanks are significant. Elsewhere blanks are not significant and only the following characters may be used (),*/Ol23456?89+-.ABEFGHIKLOPQRSXY and Z.]
  3. Any of A B G I K L or O followed by an unsigned decimal integer and optionally preceeded by an unsigned decimal integer
  4. Any of E F followed by an unsigned decimal integer then the character . and finally a second unsigned decimal integer, and optionally preceded by an unsigned decimal integer.
  5. Y or Z preceded by an unsigned decimal integer.
  6. Any of P Q R X preceded by a decimal integer signed or unsigned.
  7. A sequence of specifications may be enclosed in parentheses and be optionally preceded by an unsigned decimal integer; this constitutes a specification which may itself be included in a sequence enclosed in further parentheses and so on to depth 8.

7.4 Semantics of a FORMAT specification

When an input/output statement is executed the relevant FORMAT specification is scanned. Whenever a field specification is reached which refers to a list item the next item in the list is processed and transmitted, execution of the input/output statement being ended when all items have been transmitted and another one is called for by the format specification. If the end of the format specification is reached and items still remain in the list then the format is rescanned from the last nest of repeated field specifications, due regard being paid to any associated count. If there are no repeated groups of field specifications then the format specification is rescanned from the beginning.

During repeated scanning of a format specification the scaling factors q and r, the zero suppression control Z and the sign control S are not reset but have the values as at the end of the previous scan. They are reset at each execution of any input/output statement.

7.4.1 Fields

A sequence of adjacent characters to be input or output which are processed together is called a field. The field width is the number of characters concerned and is specified in all field specifications. This width should not cause the field to extend beyond the end of the buffer, it will be appropriately reduced if /necessary. On input a field of width zero is treated like an all blank field on output zero field width means ignore the next item in the list. A negative field width is treated specially on input to allow a free format for the input of numbers.

As will be seen from the table in 7.4.2 each type of conversion has a style of adjustment, either right or left.

Each item has a natural field width which may depend on the value of the item: for example, in A-type output the natural width is 8; and I-type it is 1 + max (z,n) where 10n-1 ≤ item < 10, and z is specified minimum number of digits to be printed (see control Z). The item is conceptually converted in its natural field width and then put in the specified output field.

If the adjustment is to the left (A,B,L-type), the left-most character of the natural field occupies the left-most position of the actual field. Characters at the right hand end of the natural field are lost if the actual field is too small; on the other hand, if the actual field is larger than the natural field, spaces are output to the right of the item.

Conversely, if the adjustment is to the right (E,F,G,I,K,O) the right-most character of the natural field occupies the right-most position of the actual field. Characters at the left hand (i.e. more significant) end of the natural field are lost if the actual field is too small: but if the actual field is larger than the natural field, the characters in the buffer to the left of the natural field are undisturbed.

The input conventions are designed to be compatible, in the sense that anything output can be correctly re-input, provided that the actual fields are big enough. (The converse is not necessarily true). This means that for left adjusted items, characters are collected starting at the left of the field, ending when either the actual field or the natural field ends. If the natural field ends first, the right-hand part of the actual field is ignored.

For right adjusted items, initial spaces are ignored, and collection of character precedes all the way to the end of the actual field.

7.4.2 Conversions

The characters A, B, E, F, G, I, K, L and O specify the conversion of information between internal and external form according to the following table

Code Internal Form External Form Adjustment
A TEXT Characters Left
B Boolean Octal digits Left
E REAL Decimal with exponent Right
F REAL Decimal without exponent Right
G REAL Decimal with or without exponent Right
I INTEGER Decimal integer Right
K INTEGER Characters Right
L Boolean "TRUE" or "FALSE" Left
O INTEGER Octal integer Right

The decimal integer, w, following a conversion code letter specifies the field width (i.e. number of characters) in the external form. The decimal integer d in the forms Ew.d. and Fw.d. specifies the number of digits, following the decimal point.

On input the decimal point need not be present and if present, need not be in the position indicated by the format specification; if not present the number of decimal places is defined by the format specification. An exponent must be present in an E field and absent from an F field. The internal form is determined by the format specification.

On output the external form is determined by the format specification but the internal form may be REAL where the format indicates INTEGER and vice versa.

The standard external forms for E, F and G formats are as follows:

Ew.d   ->  sign, 1
           integral part, max (z,q)
           decimal point, 1
           fractional point, d
           exponent, 4

Total field width required 6 + d + max (z,q.). If this exceeds w the left-most characters are lost and the field adjacent and to the left is not affected.

The exponent takes the form

E, sign, digit, digit if |e| ≤ 99

sign, digit, digit, digit if |e| > 99

The sign of the exponent is always printed + or - and is not affected by S control.

Fw.d   ->  sign, 1
           integral part, max (z,n)
           decimal point, 1
           fractional point, d

The implicit exponent is -r (see scale factors) and n is defined by

10n-1 ≤ internal value * 10r < 10n

The total field width required 2 + d + max (z,n). If this is greater than w the left-most characters are lost and the adjacent field to the left is not affected.

Gw    ->

The F form if the value can be expressed without either an exponent or leading zeros, otherwise the F form is used.

7.4.3 Output of Constant Text

nH followed by n characters in an output format statement causes the n characters following the character H to be output. A specification of this type will not normally be used in conjunction with an input statement.

7.4.4 Spacing

The next character of the line in the external medium to be processed at any stage is identified by a pointer. This pointer is adjusted automatically when fields with specified field widths are processed. It can also be adjusted explicitly by X or Y control. nX moves n places relative to its present position, nY moves it to the specified absolute position. It can be moved backwards or forwards allowing overwriting within the buffer. [Thus 60Y, 4*H****, - 4X, S*-, I4 will cause an integer to be printed, with preceding asterisks instead of spaces in columns 60-63.]

There are checks to prevent the pointer being moved outside the buffer area.

7.4.5 Repetition of specifications and of groups

A decimal integer preceding a conversion code A, B, E, F, G, I, K, L or O specifies that the conversion is to be applied to the specified number of consecutive items in the list.

A group of conversions (field or control) enclosed in parentheses and preceded by a decimal integer is repeated the specified number of times (once if no integer is explicitly specified).

A group is itself a control specification and may occur within another group and so on to depth 8.

7.4.6 Scale Factors (P, Q and R)

Two scale factors q (for E type conversions) and r (for F type) are maintained during processing of a format statement. At the start of execution of an input/output statement they have the values q = 1 , r = 0. These values may be changed by the specifications nP, nQ and nR; P sets them both to the same values (n), Q and R each affects the appropriate one.

In E-type output the mantissa is normalised to the range 10q-1 ≤ mantissa < 10q

(so that there are q integer places) and the decimal exponent formed accordingly. On input q is irrelevant.

In F-type output the number output has the value 10 times than the value of the corresponding list item. On input the number read is multiplied by 10r before assignment to the list item.

7.4.7 Control of sign printing

Sab is relevant to the output of numerical information. The character to be printed immediately to the left of the left most digit is specified; a for zero or positive numbers, b for negative.

In the absence of this specification blank and - are used.

7.4.8 Zero suppression

nZ specifies that n digits are to be printed in I fields, and n digits before the decimal point in E or F fields. It applies to all I, E and F fields processed after this control is processed. In the absence of this control, or before this control is reached, unity is assumed so that all leading zeros are suppressed except that single zero is printed for a zero integer or a zero integral part of a number printed in E or F form.

7.4.9 Line Control

A line in the buffer is terminated by the character / in the format. Each input or output statement specifies the subsequent action. On input the buffer is filled with the next line from the input document. On output the buffer is taken as the next line of output and is then reset to spaces. In both cases the buffer pointer is reset to the beginning of the line.

7.5 Carriage Control

In records output for printing, the initial (zeroth) character of each record serves a special purpose: carriage control. Subsequent characters (1 to 120) in the record constitute the line to be printed.

The carriage control character determines where the line is to be printed, according to the following code (standard in Fortran).

space    (single spacing) print on the next line; 
0        (double spacing) leave one blank line then print 
+        (overprinting)  print on the same line as the previous record;
1        (skip to channel 1) print at the top of the next page;
2 : 7    (skip to channel 2:7) print at the next line identified by the appropriate channel number;
A	     Leave one blank line before printing (=0);
B	     Leave two blank lines before printing;
C : F    Leave three : six blank lines before printing.

The channel skips allow the line to be printed at a standard position on the page, regardless of the current position. A loop of paper tape is held inside the printer, and moved in step with the normal paper feed. In order to skip to a channel, both are moved until a hole in the appropriate track is found on the paper tape.

7.6 Magnetic Tapes

WRITE TAPE n, list causes the copying of the specified information without conversion to a binary tape (no format specification is necessary).

READ TAPE n, list causes the copying of binary information without any conversion from the specified magnetic tape to the specified locations in the machine store (no format specification is required).

All items written on a binary tape by the execution of one statement constitute one logical record.

When reading from a binary tape irrespective of the length of the list the tape is stopped with the reading heads at the start of the next logical record. The list will not normally be longer than the tape record.

Tape n is backspaced over one logical record by execution of the statement

BACKSPACE n

and is positioned at the beginning of the first logical record by execution of

REWIND n

ENDFILE n writes an end of file mark on tape n.

8. DOUBLE PRECISION and COMPLEX Arithmetic

This chapter gives the extension to chapter 3 to allow DOUBLE PRECISION and COMPLEX arithmetic.

8.1 DOUBLE PRECISION Elements

  1. DOUBLE PRECISION constants are written as REAL constants which must have an exponent part in which the character E is replaced by D.
  2. DOUBLE PRECISION variables, arrays and FUNCTIONS are declared (2.2).

8.2 COMPLEX Elements

  1. A COMPLEX constant is written as two REAL constants separated by a comma and enclosed in parentheses.
  2. COMPLEX variables, arrays and FUNCTIONS are declared (2.2).

8.3 The Generalised Arithmetic Expression

The possible arithmetic modes are considered to be ordered thus; INTEGER, then REAL, then DOUBLE PRECISION and COMPLEX at the same (highest) level.

A segment (see 3.3.2) must not have both DOUBLE PRECISION and COMPLEX constituents.

Each segment is evaluated in the highest mode of its constituents, and if necessary the result is converted to higher mode before evaluating the segment of which it is a constituent.

8.4 Use of Generalised Expressions

A DOUBLE PRECISION expression may appear in any of the same contexts as a REAL or INTEGER expression.

A COMPLEX expression may appear as above except in relations and as the argument of IF statements.

8.5 Generalised Arithmetic Statement

Mode changes both up and down are made automatically and also from COMPLEX to DOUBLE PRECISION and vice versa. Loss of information is diagnosed as a possible error.

⇑ Top of page
© Chilton Computing and UKRI Science and Technology Facilities Council webmaster@chilton-computing.org.uk
Our thanks to UKRI Science and Technology Facilities Council for hosting this site