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

Magnetic Tape Library Subroutines

B C Chapman

11 October 1966

1. Introduction

The magnetic tape library subroutines in use at Aldermaston depend upon some special extracodes provided by the supervisor there, which enable buffered transfers to and from backing store (one inch tape, half inch tape or disc) to take place without the user having to provide any buffers. These extracodes are not provided by the supervisor on Titan, and it was therefore necessary to provide subroutines to control all buffering within the object program. Since these subroutines are largely independent of the existing library routines, the opportunity has been taken to considerably improve the efficiency of binary transfers. Due to interface problems and residual inefficiencies, transfers under format control remain slow and should be avoided whenever possible. No provision has been made within the routines for the use of half inch tape, but both one inch tape and disc can be used. In this connection note that the words TAPE and DISC in the Fortran statements READ TAPE, READ DISC etc, are merely used to determine the syntax of the statement and the modes of the transfer. The actual medium will be determined by the job description or the *TAPFILE directive.

2. Entries Provided

The following entry points are provided by this part of the library for specific Fortran statements:

05LIBRR         READ TAPE
06LIBRR         WRITE TAPE
07LIBRR         READ DISC
08LIBRR         WRITE DISC
BSLIBRR         BACKSPACE
EFLIBRR         END FILE
RWLIBRR         REWIND

In addition, READ INPUT TAPE and WRITE OUTPUT TAPE use the existing format control routines which require the magnetic tape entries /POFP, /RPFP and /WPFP.

To enable files to be manipulated the following Fortran subroutines are available for use in CALL statements:

BFFORT     Backspace over a file and its preceding file mark.
SFFORT     Skip to and over the next file mark. 
SRFORT     Skip one record.

Each of these subroutines has just one argument - the number of the tape concerned. N.B. There are no specific entries in this part of the library for 02LIBRR (end transfer) and 03LIBRR (transfer items). Instead the action of, for example CALIBER, is to temporarily overwrite the first instructions of the subroutines 02LIBRR and 03LIBRR in the format part of the library with transfers to equivalent routines in the magnetic tape package. The original state of these two instructions is restored by the magnetic tape "02LIBRR". Further the indirect jump for 03LIBRR is replaced by a direct jump by altering the jump address in the calling routine. In the case of a READ call of 03LIBRR with just one arguments as occurs for example in

      READ TAPE 2, (A(I), I = 1,N)     or
      READ DISC 3, 10, (A(I), I = 1,N),(B(I),I =1,N))

further modification of the calling subroutine takes place, the actual transfer instructions being planted permanently in it.

In chain jobs these principal entry points can be of either chapter or global significance, as the programmer desires, but the central control routines will always be forced into the global area since it is essential to preserve tape positions throughout a job.

3. Tape Format

Transfers are divided into two classes known as record separator mode and physical block mode. The latter mode is used with the READ DISC and WRITE DISC statements. No separators are written to tape and an instruction to write an array 512 words long will just fill one block, which may selectively overwrite a given block on the tape or disc. The REWIND is a neutralising statement restoring a tape to its initial state, and moving it to the first block. All other statements use tapes in the record separator mode, in which each record (the information in one binary transfer statement, or one line of a format transfer statement) is separated from the next by a special marker word defining the length of a record and the degree of marker. The format used is identical with that at Aldermaston, except that the supervisor there will sometimes combine two adjacent markers whereas these library routines do not. This does not affect interchange of tapes in either direction.

The tape format is similar but not identical to that in use on Atlas 1, whose supervisor allows one logical record to be split between two physical blocks without additional separators, and whose library routines deal differently with file markers. It should, however, be possible to read any tape produced on Atlas 1 satisfactorily, but a tape containing file marks written by Titan cannot be read by Atlas 1.

4. Errors Diagnosed

The following psuedo supervisor error numbers may appear:

21   Tape number out of range (see B84)
43   File mark encountered whilst reading or skipping
44   Attempt to write, read or skip a record whilst in physical block mode.
45   Attempt to read a record without rewinding after writing.
46   Attempt to backspace when at the beginning of tape.

The occurrence of these errors is illustrated by the table below which lists all the possible permutations of successive operations. A Y indicates that the operation is permissible.

Second Operation >First Operation
04,05,SR,BS 01,06 EF BF SF 07,08 RW
04LIBRR (READ INPUT TAPE) Y 45 45 43 Y 44 Y
05LIBRR (READ TAPE)
SRFORT (Skip record)
B5LIBRR (BACKSPACE) Y Y 43 43 44 46
01LIBRR (WRITE OUTPUT TAPE) Y Y Y Y Y 44 Y
06LIBRR (WRITE TAPE)
EFLIBRR (END FILE)
BFFORT (Backspace file) Y Y Y Y Y 44 46
SFFORT (Skip file) Y 45 45 Y Y 44 Y
07LIBRR (READ DISC) Y Y Y Y Y Y Y
08LIBRR (WRITE DISC)
RWLIBRR (REWIND)

5. The Buffers

The buffer control routines are written so that they will always give the desired effect no matter how many tapes are currently in use. The preset number of buffers in 3, and they are initiated at the top of the programmers store at J0075, J0076, J0077, i.e. immediately below the ceiling of 32K. The user must avoid using this area for his COMMON arrays.

If it is desired to use more than 3 blocks for buffering, say 5, then insert the following sequence immediately before *ENTER:

*LIBRARY
*ALTER /BUFMAX 
H2,0

The number inserted is half of one less than the number of buffers. If the required number was 6, then the count would have been 2.4. The number of buffers must not exceed 8. The addresses of the buffers may be altered from their preset values by following the count card with a series giving the addresses of the required buffers, two per card, The standard setting is as though the following sequence had: been used:

*LIBRARY
*ALTER /BUFMAX
H1,0
H .770000,   .760000
H .750000,   .740000
H .730000,   .720000
H .710000,   .700000

It is only necessary for the user to specify as many addresses as he is using.

6. Use of the Buffers

Whenever a tape statement, other than REWIND, is obeyed, it is essential that a buffer be made available for that statement. It may be that the tape block concerned is already in core, in which case it will be used. If it isn't, then a buffer must be chosen so that least subsequent shuffling of blocks to and from tape will result. A note is kept of the use of each buffer, and within each use buffers are further sorted to discover the order in which they entered that use. Thus in the case of writing to tape it is known which transfer commenced first, and is therefore likely to finish first (it is not possible to know when a transfer has actually finished). This sounds complicated, but a simple arithmetic test enables a satisfactory choice of buffer to be made. The hierarchy of different uses is as follows.

1. Unused
2. Old writing buffer now being written to tape
3. Advance read fail
4. Advance read
5. Read
6. Current write.

It will be appreciated that buffers in classes 1, 2 and 3 can easily be re-used. Classes 4 and 5 may require the read to be repeated. Class 6 requires that the partial block be written now, and will have to be read back should further writing be required. Reading from tape can take place in either direction, thus reducing tape movements. Apart from the demand for buffers, there is another type of request for buffer space. During all read transfers an attempt is made to read one block down in advance. All advance read requests are queued, and each time a new request is made it is added to the queue, if not already present. The current uses of all buffers are expected, and as many advance reads as possible are initiated. An advance read will never pinch a buffer currently holding a read or write block, and will only take over a prior advance read buffer if that advance read took place so long ago that it is probably redundant or refers to the current tape and is definitely redundant. It will, however, take over any buffer of lower class.

Note that if, for example we have consecutive statements

READ DISC 3, 12, (A(I), I=1, 1000) 
READ DISC 3, 14, (B(I), I=1, 1000)

then block 14 brought into core as an advance read for the first statement will not be re-read for the second.

With advance reads there is a real danger of the buffers becoming choked with unwanted information, and subsequently working inefficiently, particularly where use is made of the READ DISC statement. It is not reasonable to delete the use made of a buffer completely because it may be required in the next transfer, Also, care must be taken to ensure that should a tape transfer failure occur, as it easily can with a new tape where blocks have not yet been written to, the job is not monitored unnecessarily. The following steps are taken:

  1. At the end of each READ DISC:
    1. if partway through a block (it must he in core) mark as unused, otherwise if at beginning of a block (it may not be in core) mark as advance read.
    2. as for REWIND.
  2. At a REWIND:
    1. clear read queue of all requests for this tape.
    2. alter use of any buffers associated with this tape to unused except for write going and advance read. These are left unaltered to preserve ages and facilitate failure action.
  3. A request for an advance read will, if there are no buffers in the unused, old write or advance read fail status, look at any buffers currently used for advance reading The head of the tape queue will pinch such a buffer if:
    1. the tape number is the same
    2. the advance read was initiated so long ago that it probably won't be required.

7. Tape Transfer Errors

Whenever a request is made for an advance read, a trap is set for fault 54, so that reading an extra block on a new tape that has not previously been written will not result in a job being unnecessarily terminated. This situation could arise at the end of any READ DISC statement, or the last READ TAPE statement. The trap routine easily catches the latter, and marks the appropriate table position. The former is similarly caught when the number of words transferred is not a multiple of 512, but if it is, difficulty is experienced since the next block is updated to read status from advance read. However, unless a program change occurs after the updating and before obeying of the termination routine, the buffer will have been marked as advance read before the error arises, and the job will not be terminated.

The trap routine deals with the current fault 54 as indicated above, if the tape number is less than 16 and the core address given corresponds to a buffer. Otherwise the trap 54 is removed and the fault simulated to delay it. A similar action occurs if the transfer affected a buffer with a current read or write. If the buffer is now classed as unused, the function digits are inspected, and if they are 1273, i.e. the buffer was used for writing, but has now been re-allocated, then the fault is again delayed and the trap removed. In any case all current delayed faults are interrogated and if they are of type 53 and refer to this tape, the action is repeated. Otherwise the fault is delayed further but this time the trap on fault 54 is retained.

When a block is definitely required, and its previous transfer as an advance read resulted in a failure, one further attempt is made to read it.

8. Optimisation of Transfers

The central transfer routine is fairly efficient, involving 3+6n. instructions obeyed for a call of 03LIBRR with n arguments, each time that call is repeated. The first time 03LIBRR is called, from any location initialisation will take a few extra instructions.

In the case of a READ DISC or READ TAPE statement if a call of 03LIBRR contains just one argument, then the code of the calling routine is physically altered so that in the case of, e.g. READ TAPE 3, (A(I), I = 1, N) the inner loop may contain just 6 instructions. It is assumed that the sequence is of the form

CANBI *+4           set link
TRA   03LIBRR       jump to transfer routine
HWDS  0, .40000000  marks end of argument list
HWDS  0, **         low half contains address of item to be read. 
                    This address is normally planted by preceding code.
(next instruction to be obeyed)
These four instructions are replaced by
XCA    ,89,88      pick up next word
TCIF    *+2,88      jump unless end of records increasing b89
1101    EOR,,1      jump to end of record routine with link in B1
STO     **          store word. The low half is not altered

The end of record routine may temporarily overwrite the first instruction of this sequence, to prevent reading over the end of a record, with a further 1101 instruction. The above state will be restored the next time the statement is obeyed. This only applies to a READ TAPE statement.

9. Information printed at end of job

At the end of a job the position of a tape is printed for all tapes with numbers less than 16. If a job does not use the magnetic tape library routines, or stops before doing so, the position of the tape quoted is that provided by the supervisor. Once the tape routines have been used, then unless the tape is believed to be in its initial state, the block number printed corresponds to the logical position of the tape. When using a tape in record separator mode, the word address of the last marker is also printed, unless it happens to be zero.

⇑ 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