An ATLAS AUTOCODE PROGRAM consists of a series of Statements which describe in algebraic notation the calculation to be executed. The statements are of two kinds, declarative statements giving the nature of the quantities involved, and imperative statements which describe the actual operations to be performed on them, and the sequence in which they are to be carried out. The statements are not immediately recognisable by the computer and must first be converted into an equivalent sequence of basic machine instructions. This is done by a special translation program called a compiler which is held permanently available in the machine. Not until the program has been compiled can it be executed.
The following example gives a general idea of the principles involved in writing a program. We wish to fit a straight line y = ax + b to sets of data of the form X1,Y1; X2,Y2; ----; Xn, Yn which are to be punched and presented on a data tape in this order. Each such set is to be terminated by the number 999999 and the final set by two such numbers. For each set the quantities:
a = (nΣXiYi - ΣXiΣYi) /(nΣXi2 - (ΣXi)2)
b = (ΣYi - aΣXi) / n
c = ΣYi2 - 2(aΣXiYi + bΣYi) + a2ΣXi2 + 2abΣXi + nb2
are calculated, the last being the sum of the squares of the deviations
Σ(Yi - aXi - b)2.
The following is the formal program for this calculation. The statements are to be interpreted in the written order unless a statement is encountered which transfers control to another specifically labelled statement. In general each statement is written as a new line, otherwise it must be separated from the previous statement by a semi-colon.
begin real a, b, c, Sx, Sy, Sxx, Sxy, Syy, nextx, nexty integer n read (nextx) 2: Sx = 0; Sy = 0; Sxx = 0; Sxy = 0; Syy = 0 n = 0 1: read (nexty) ; n = n + 1 Sx = Sx + nextx; Sy = Sy + nexty Sxx = Sxx + nextx2 ; Syy = Syy + nexty2 Sxy = Sxy + nextx*nexty 3: read (nextx) ; ->1 unless nextx = 999 999 a = (n*Sxy - Sx*Sy)/(n*Sxx - Sx2) b = (Sy - a*Sx)/n c = Syy - 2(a*Sxy + b*Sy) + a2*Sxx - 2a*b*Sx + n*b2 newline print fl(a,3) ; space ; print fl(b,3) ; space ; print fl(c,3) read (nextx) ; ->2 unless nextx = 999 999 stop end of program
Complete programs are generally split up into a number of self-contained units called routines, and each routine may be further split into a number of blocks. A detailed description of their construction and use is deferred until later, but in the earlier sections it is sufficient to note that the Autocode statements between begin and end constitute a block. However when a block defines a complete program as in the above example, end is replaced by end of program.
Atlas Autocode is a Phrase Structure Language and to assist in its description we sometimes have resort to phrase structure notation. In general, whenever a name appears in square brackets in the description of an Autocode statement, we mean that in an actual statement it would be replaced by a particular element of the class defined by the name. For example, in the next section we define [NAME] and [EXPR] to denote a general name and a general expression respectively, and with these definitions we could go on to define a function of a single variable by
[NAME] ([EXPR])
and in an actual program this might be replaced by
g(x + y - 2)since g is a name, and x + y - 2 is an expression. Further notes on phrase structure notation will be found in Appendix 1