Contact us Heritage collections Image license terms
HOME ACL Associates Technology Literature Applications Society Software revisited
Further reading □ CONTENTS1. Basic Facilities2. Further Facilities3. Matrix Operations4. Programme LibraryA1. Punching ServiceA2. Running YourselfA3. Interpretation of Machine OrdersA4. At ManchesterA5. Library Programmes
ACD C&A INF CCD CISD Archives Contact us Heritage archives Image license terms

Search

   
ACLLiteratureOther manualsMercury Autocode :: Mercury Autocode Manual
ACLLiteratureOther manualsMercury Autocode :: Mercury Autocode Manual
ACL ACD C&A INF CCD CISD Archives
Further reading

CONTENTS
1. Basic Facilities
2. Further Facilities
3. Matrix Operations
4. Programme Library
A1. Punching Service
A2. Running Yourself
A3. Interpretation of Machine Orders
A4. At Manchester
A5. Library Programmes

Chapter 4: The Programme Library

This part describes the arrangements for using routines consisting of one or more chapters as sub-programmes of a larger programme.

Specification of parameters

The master programme bas to provide the sub-programme with certain information before the latter can carry out its task. Thus it has to be told where to find the operands and where to place the results. In either case these may take the form of individual numbers and/or sets of numbers, e,g., series, matrices, etc. In addition the sub-programme may refer to other programmes (or smaller routines), as in the case of the quadrature programme where the argument is a function. These programme parameters are provided when calling-in the sub-programme. The preserve and restore instructions were introduced so that a subchapter could use the working store quite independently of the master chapter. and hence the names of the main variables (e.g.. a ® 19) in the subchapter need not bear any relation to those in the master chapter. However. the special variables a.b.c,..., a'.b'.c'.. .., and the indices i.j.k...., all refer to fixed locations in the working store and it is by means of these that the master chapter communicates with the subchapter. Thus after the preserve instruction in the main chapter these quantities can be reset to new values which are then available to the subchapter. which will be designed to select its information in accordance with the following conventions.

(a) Individual arguments, field dimensions. etc.. will be selected from

a b c d e f g h u v w x y z
i j k l m n o p q r s t

(b) Fields of numbers (e.g., vectors. matrices) will be kept in the auxiliary store, and their locations (i.e.. the location of first element or other reference position) specified by primed variables. i.e.

a' b' c' d' e' f' g' h' u' v' w' x' y' z'

The primed variables will also specify where the sub-programme is to place its results, which must all be transferred to the auxiliary store before returning to the main programme. This applies to individual numbers as well as sets of numbers, for otherwise. if left in the working store, they would be destroyed by the subsequent restore instruction in the main programme. Instead they are recovered from the auxiliary store by means of Æ6 instructions after restoring the contents of the working store.

Example

Consider a programme for the best solution of a set of linear equations in the sense of least squares. Let these be:

ai1x1 + ai2x2 +...+ ainxn i=1(1)m where m ≥ n

The programme will have to be supplied with the numerical values of m and n, and with means to refer to the coefficient matrix and the vector of the right hand sides. Thus, for instance, it may assume that aij stands in a' + (i-1) n + (j-1), and bi in b' + (i-1), a', b' being specified on entry. In addition the programme may require further variables as working space in which to set up the normal equations, and provision for this will have to be made in the main programme. Finally provision for the results xi has to be made.

The specification of the programme parameters might therefore read as follows:

m, n     field dimensions
a', b'   location of coefficient matrix and r.h,s. vector
w'       first of 0.5n(n+l) consecutive auxiliary variables*
x'       location of result vector (xi will be placed in x' + (i-1) ).

* A desirable minimum. This assumes that only the distinct elements of the symmetric coefficient array are calculated, and that the r.h.s. can be stored in the space allocated for the result vector, x.

Except insofar as the auxiliary working space is unnecessarily large, the following programme would meet this specification. Matrix operations are employed. Denoting the original equations by Ax = b the normal equations are ATA x = ATb.

u = m 
v = n 
y' ≠ w' + mn 
w' = Æ16 (a', u, v)            AT
y' = Æ26 (w', a', v, v, u)      ATA 
x' = Æ26 (w', b', v, 1, u)      ATb
x' = Æ28 (y', n, 1)            (ATA)-1 ATb 
up 

The programme is unsatisfactory for two reasons. Since there is no matrix instruction which will give the product ATA directly (in this respect the list is inadequate) it is necessary to form AT explicitly. This involves extra working space (for mn variables) and extra computing time. Secondly no advantage is taken of the fact that ATA is symmetrical, so that 0.5n(n-l) extra elements are computed and stored. Altogether, therefore, the auxiliary working space could be reduced from mn + n2 to 0.5n(n+l) - and possibly further still - by programming the calculation directly, using only the Æ6 and Æ7 instructions to refer to the auxiliary store.

The following sequence illustrates, for a particular case, how such a programme would be called in from the main programme.

...............
preserve
m = 70 
n = 50 
a' = 0 
b' = 3500 
x' = 3570 
w' = 3620
down ?/?         enters subprogramme
restore          returns from subprogramme
Æ6 (3570)?, 50
...............

The last instruction recovers the results from the auxiliary store. The down instruction has been deliberately left incomplete as it serves to introduce the new assembly facilities.

Assembly of the programme

A new directive of the form programme -N enables a group of chapters constituting a single sub-programme to be given a number (N) which can be referred to in the down and across instructions, which have been extended to deal with this situation. To illustrate this facility a typical layout is shown below:

programme -1
chapter 1
chapter 2
............
chapter 5
programme -2
chapter 1
chapter 2
programme -550
chapter 1
programme -584
chapter 1
chapter 2
chapter 3
chapter 0

Any programme can be assigned a number in the range 1 to 1023, and it is suggested that the range 501 upwards be reserved for library programmes. Thus in the above example the first two programmes would have been specially written for the problem, while the last two programmes would be drawn from the library.

If now it is required to call in programme -2 as a subprogramme, this is done by means of a modified down instruction, for example:

down 1/1 - 2

which refers to chapter 1 of programme 2. Tbe "across" instructions can be used in a similar fashion.

The first directive (programme -1) is not necessary if these are master chapters not referred to by the other subprogrammes (except implicitly via the up instruction).

The directive variables N now assumes a relative significance: it refers to a previous chapter in the same subprogramme. In Mercury the directive variables 0 refers to the last chapter in the previous subprogramme. In the master chapters or in the final chapter 0 it refers to the previous chapter 0 in the machine, i.e., the chapter 0 of the last complete programme, It is possible to take advantage of this in certain situations but in this case the current programme must be read in by an rmp instruction or a manual restart; otherwise the previous chapter 0 will be destroyed.

Auxiliary routines

Consider for example a programme to evaluate a triple integral:

∫∫∫f(x, y, z) dx dy dz

Depending on the actual process used, the integrand has to be calculated at certain specified points x,y,z so that if the programme is to be used for a general function this must be calculated by an auxiliary routine provided by the user. This should be designed so that, given the particular arguments x, y, z the routine calculates the corresponding function value and places it in a preassigned location. If there is a substantial amount of calculation involved, the auxiliary routine can be a separate chapter and be treated as a subprogramme of the library programme, that is a sub-subprogramme of the main programme. The programme parameters of the function programme would be the arguments x, y, z and the auxiliary location (say f') of the result f(x, y, z).

Alternatively the function programme can be called in by an across instruction, in which case it must also terminate with an across instruction, returning control to a preassigned point in the library programme. This arrangement has the advantage that it confines the whole integration process to one level. In both cases the library programme will assign a definite programme number to the auxiliary function chapter because it is not (easily) possible to make this a programme parameter.

By-pass parameters

It is not likely that the library programme will make use of all the special variables and indices, in which case those that remain undisturbed can serve as by-pass programme parameters linking the main programme directly with the auxiliary function programme (whether treated as a sub or across programme of the library programme). This may be useful if the function involves certain parameters, e.g., f(x,y,z; a, b, c) and it is desired to specify the values a, b, c in the main programme before starting the integration process.

The auxiliary chapter may also consist of several different function routines, any of which can be selected from the main programme by using a by-pass index to serve as a multiway switch in the function chapter.

Incomplete chapters

If the function is of a fairly simple nature it is desirable to incorporate the auxiliary routine as an integral part of the library chapter in which it is used, and eliminate the operations of chapter changing and preserve and restore. The quadrature programme -503, e.g., consists of two chapters, the first of which computes the coefficients of the quadrature formula, while the second carries out the integration proper, It is intended that the instructions for calculating the integrand shall be included in the second chapter, which is otherwise only about one-third full. The structure of the programme is therefore as follows:

programme -503   on library tape
chapter 1        on library tape
chapter 2        on library tape
1st part         on library tape
further directives      provided by user
auxiliary sequence      provided by user
close

In such a programme it is obviously necessary to know how much of the chapter space is available for the auxiliary sequence, what labels can be used, and so on, It is convenient to assume that it would be entered at the first instruction and terminated by returning control to a prereassigned point in the first part of the chapter, e.g., label 127.

Once again communication with the auxiliary sequence is by means of the special variables and indices, but since there is now no preserve instruction these are limited to those which are not used for other purposes by the first part of the chapter. On the other hand however, the absence of the restore operation means that they can now be used for communication in both directions, so that e.g., a function value calculated by the auxiliary sequence can be recorded directly as a working variable or index. Those available special variables and indices which are not used to communicate between the two parts of the chapter can serve as by-pass parameters to link the main programme with the auxil1ary sequence. As already explained this allows the quadrature programme to be used on different integrands, although the multiway switch device described in the previous section is relatively time consuming in the present context ( n) = m) takes 18 millisecs to execute). Instead the different function sequences can be called in by a series of conditional jump instructions, thus

jump 1, m = 1 
jump 2, m = 2 
jump 3. m = 3 
etc.

This is particularly suitable if there are only 2 or 3 different functions involved.

It is necessary to say something about the directives which are written at the head of the auxiliary sequence. These are limited only in their extent. i.e. the total number of variables specified must not exceed the number left unspecified in the first part of the chapter. There is no limitation however in the letters which can be employed. and if necessary these may duplicate those used in the first part. Thus e.g., we may write:

chapter 1
a ® 119           (0-119)
b ® 119           (120-239)
first part
a ® 119           (240-359)
c ® 119           (360-479)
second part
close

The duplicate a directive simply means that wherever (say) a3 occurs in the first part of the chapter it refers to the absolute location 3, whereas in the second part it refers to location 243. To summarise: in order to be able to write an auxiliary sequence for a library programme of the kind considered above. the specification must include the following information.

  1. proportion of chapter available (or number of registers)
  2. permissible range of labels
  3. entry* and exit
  4. permissible working space
    1. number of main variables available
    2. list of special variables and indices available (by-pass parameters)
  5. programme parameters (i.e.. where to find the arguments and where to place the results)

* Unless otherwise specified, this would be the first instruction, i.e. at the head of the sequence

A selection of library programmes will be found in Appendix 5.

⇑ 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