Next: References Up: EPIO Previous: Auxiliary routines used

Technical details

Status words

One set of status words per unit will be kept in a common block (which should reside in the root for overlayed programs). The status words contain all information the routines have to know in order to operate. The shorthand notations 'physical header' and 'record header' refer to the physical and logical headers respectively of the EP format description.

Words marked '*' can be defined and changed by the user through calls to special routines (the user should not write into the status word area directly).

r, w, and r/w under 'use' means reading or writing only, or both.




                   Table 5.1: Overview of the status words


1    *    r/w    Physical block length in 16-bit words. Used for writing;
                 should always be a multiple of the ``magic'' 180. For the UNIX
                 and ``standard Fortran'' versions it is the actual block
                 length.

                 For reading, it is the upper limit of the EPIO buffer IBUF.
                 The user has to provide sufficient space in IBUF.

                 Example: for a buffer length of 1800 16-bit words, IBUF(480)
                 is needed on a 60-bit machine.

                 Default=1800

2    *    r      Maximum logical record length (in machine words).
                 Default=999999

3    *    r/w    Reading : as read from physical header word 11

                 Writing : Logical record word length (16 or 32-bits); a word
                 of this length will be called a ``unit'' in the following.

                 Default=16
4    *    r/w    P.h. word 5 (run number), read or written

                 Default=10101

5    *    w      If >=0, logical record type identifier (will be used as
                 record header word 2).

                 If <=0, for user purposes.
                 Default=0

6    *    w      If >=0, logical record count will be placed in record header
                 word 4

                 If <0, record header word 4 will not be set (i.e. for user
                 purposes).

                 Default=0
7    *    r/w    Reading : as read from physical header word 2, or 0 if no

                 physical header
                  Writing : Actual physical header length. Is automatically set

                  at call to EPADDH.
                  Default=12 (see control word 6), 24 for 32 bit p.h.

 8    *    w      Output padding flag, values i+j

                  i=0 : span logical records over blocks
                  i=10: do not span logical records

                  Remark: headers will never be spanned on writing

                  j=1 : pad physical block with zeros to full length (i.e. write
                  fixed length blocks)
                  j=2 : pad up to next magic multiple (see control word 5)

                  j=3 : do not pad at all

                  Default=1
 9    *    r/w    Physical header word 6 (physical record type)

                  Default=0 (16 bit p.h.), 1 for 32 bit p.h.

10         r/w    Logical unit number

11         r/w    Number of blocks read or written
12         r/w    Number of records read or written

13         r/w    Number of read or write parities

14         r/w    Actual occupation of I/O buffer (16-bit words)
15         r/w    Displacement to start of first logical record (physical

                  header)
16         r/w    Status indicator: 0 at start, 1 writing, 2 reading.

17         r      Flag for old (=1) or new (=0) EP format. Recognized when
                  reading.

18         r      Number of headerless blocks still following (from physical
                  header word 9)

19         r      Normally 0, 1 if last read access resulted in E.O.F.
20         r      Actual number of units read, including header, in current

                  logical record (logical record header word 1)
21         r      Logical record header length (logical record header word 3)

22         r      Position indicator - Internal in EPREAD

                  =0 : pointer at start of logical record (header)
                  =1 : pointer at start of logical record (data)

                  =2 : pointer at end of physical header

23         r      Internal pointer IP1 in EPREAD
24         r/w    Internal unit name UNIVAC and Apollo only

25    *    r/w    VAX: Channel address (magnetic tape)

                  UNIVAC: -1 if tape, otherwise sector address

                  IBM: if 0 (default) ULP option, else NULP (see IOPACK)

                  NULP allows concatenation of files, ULP does not

                  Apollo: must be set before first read Stream _$ID
                  UNIX C I/O: stream address (not user settable!)

26    *    r      Maximum logical record header length, for calls to EPREAD with
                  MODE=20 (default 999999)

27    *    r      User wants automatic byte-swapping if 1 (default) or
                  suppression of it (=0).

                  User forces new format if 2
28         r      Internal usage

29    *    r/w    Select physical header record format

                  writing: 16 bit headers = 0 (default) or 32 bit headers = 1
                  reading: as deduced from header words 7 and 8

30    *    w      Vax tape append option,

                  = 0 (default) new tape file,= 1 append.

31         r      =Pointer to logical reader header, for random access
32         r      =Internal usage

33    *    r/w    Select type of I/O in the UNIX version; see section ?? ``Usage
                  on UNIX''.

The status words are kept in a common block

COMMON/EPCOMM/NMUNIT,NWUNIT,NCONT,ISTART,LASTUT,LREF,LIST($dim)

with

NMUNIT
max. no. of units supported simultaneously, reading plus writing (default = 10).
NWUNIT
number of status words per unit according to list above (default = 32).
NCONT
number of overall control words for package according to list below (default = 8).
ISTART
internal reference flag
LASTUT
internal reference flag
LREF
internal reference flag
LIST
status word list, with $dim = NCONT+NWUNIT+NMUNIT, this allows the support of more units than the default 10. The default is $dim = 350.

Important note

These defaults may change in a later version of the package. Users who want to use or modify these values (e.g.: to support more than 10 simultaneous units) are urged to check the current values by printing the start of above COMMON block after a call to EPINIT.

Control words

These control words are kept in the first 8 locations of the array LIST in common block /EPCOMM/.

1
no. of units actually in use
2
max. no. of error print messages (default=100)
3
actual number of error print messages
4
no. bits/machine word
5
no. of 16-bit words / recommended unit (default=180)
6
standard physical header length (default=12) in words (16 or 32 bit)
7
number of unit control words accessible to user mods
8
logical print output unit

Important remark on logical record headers

The logical record header consists of 3 words minimum, but the standard form has four words, being:

  1. the logical record length
  2. the logical record type identifier
  3. the logical record header length
  4. the logical record sequence number.
Of these, words 1 and 3 will always be provided by the output routines when writing (basic protection).

Words 2 and 4 of the logical record will always be assigned the values described above when the user writes via calls to EPOUTS.

For use with EPOUTL, two status words, number 5 and 6, are used to assign values in the following way:

let the status words be S5, S6, S12 and the header words be H2, H4,
then

if S5 >= 0
H2 is set to S5 by EPOUTL
if S5 < 0
H2 is not set by EPOUTL, i.e. the user should have set it before calling EPOUTL.
if S6 >= 0
H4 is set to S12 (!) by EPOUTL
if S6 < 0
H4 is not set by EPOUTL, i.e. the user should have set it before calling EPOUTL.

Remark on padding

Full padding, partial padding, and no padding have certain consequences on the different computers, and should therefore be considered beforehand.

  1. Full padding: all blocks on the output file have the same (user specified) length, which should be a multiple of 180 16-bit words. This mode will probably work on any computer for reading and writing.
  2. Partial padding: ensures the blocks to have an integer length when counted in machine words (no trailing bits, or incomplete words on reading, no extra-bits when writing). This should normally work except on computers which can only read and write fixed length blocks.
  3. No padding: since in the current package, full machine words are written on all computers, this may lead to problems when reading, on another machine but normally only if the physical or logical lengths are not known. For example, due to extra padding during the transfer, records of unknown length may not be processed correctly when received through a network.

List of errors

Table explains the meaning of the integer IERR returned as the last parameter of most EPIO subroutine calls, zero meaning no error. For each error two types of routines are quoted: those called by the user, and in which the error condition was detected, and those in which the error occurred.

Control is always returned to the user, but some of the errors (marked by * in first column) are so serious that it becomes meaningless to continue reading or writing on the unit concerned, at least after a limited number of them.




                  Table 5.2: Overview of the error codes


Error    Routine    User       Meaning
                    routine
----------------------------------------------------------------------------
1        EPBLIN     EPREAD     End of file on reading or open failure on
                               IBM

         EPBOUT     EPOUTL     reading or writing

                    EPOUTS
2        EPBLIN     EPREAD     r/w parity, or I/O error (IBM)

         EPBOUT     EPOUTL

                    EPOUTS
                    EPRWND

3        EPBLIN     EPREAD     end of information on reading, or in some
                               cases after an open error on IBM

4*       EPBLIN     EPREAD     physical record length <=0

5*       EPBLIN     EPREAD     physical record length of record just read >
                               actual length of block read or user buffer
                               too small

6        see )      EPREAD     user record chopped (IREC too small, status
                               word 2) the actual length (including header)
                               can be retrieved from status word 20 using
                               EPGETW

7*       see )      EPREAD     physical header error; could be a record in
                               the old format

8        see )      EPOUTS     invalid mode specified in call
                    EPOUTL

                    EPREAD

9        see )      EPREAD     call to EPREAD with mode 11, 12, or 13,
                               without prior call with MODE=20

                               You can also get this error reading OLD for-
                               mat, with MODE=20 followed by 11, 12 or 13

10       EPBLIN     EPREAD     end-of-run (logical record length = 0)
11*      EPBOUT     EPOUTS     unit not declared on JCL card,

                    EPOUTL     or wrong BLKSIZE (only IBM)

         EPBLIN     EPREAD
12       EPBOUT     EPOUTS     end of volume, or unrecovered write

                    EPOUTL     parity (only IBM [?])
                    EPCLOS

                    EPRWND

13       EPUNIT     EPOUTS     maximum number of units reached
                    EPOUTL

                    EPRWND

                    EPADDH

                    EPSETW
                    EPSETA

                    EPREAD

                    EPGETA
                    EPGETW

14       see )      EPDROP     unit does not exist

                    EPADDH
                    EPEND

15       see )      EPOUTS     logical record header (or complete record)

                    EPOUTL     too long to fit in physical block

16       see )      EPGETW     status word address out of range
                    EPGETA

                    EPSETW

                    EPSETA
17       see )      EPADDH     user switches from reading to writing

                    EPREAD     or vice versa, without rewinding unit

                    EPOUTL
                    EPOUTS

18       see )      EPREAD     displacement to start of logical record
                               inconsistent with current logical record
                               length, not tested by EPFRD

Format Description

Tapes

Logical records may be of fixed or variable length. A logical record may be entirely contained in one physical record or may overflow into one or more physical records. Normally an event or trigger corresponds to one logical record but it may equally well consist of a sequence of related logical records.

Physical records may be of fixed or variable length.

A fixed record length is recommended (for ease of reading using standard system and particularly FORTRAN, input routines). A fixed record length is particularly important if the record has no header specifying the length.

A record length which is a multiple of 360 bytes is recommended (corresponding to an integral number of 16, 18, 24, 32, 36, 48, 60, 64-bits).

The following table indicates the increase in tape utilisation with record length up to the maximum of 32K bytes for IBM 370 [4].

Files

It is recommended that logical records relating to the same experimental conditions or 'run' are grouped in one file.

For unlabelled tapes the end-of-file (and end-of-run) is indicated by one EOF mark.

For labelled tapes the end-of-file (and end-of-run) is indicated by an EOF mark and the associated EOF records [5].

End-of-data on the tape (and end-of-file) is indicated by two consecutive EOF marks. It is NOT recommended that files (runs) span from one tape to another.

End-of-tape. It is NOT recommended to write past the EOT reflective marker, therefore, on detection of the EOT marker, the software should backspace over a sufficient number of data records to allow the required end-of-run and EOF records to be written.

Record formats. Logical records and physical records, (i.e. physical tape blocks) normally consist of a number of header words, followed by data. In some cases the number of header words in a physical record may be 0.

Word lengths. All lengths in the physical header are expressed in words where a word is defined as a 16-bit unsigned integer. The logical record wordlength is defined in the physical record header.

byte 0
is defined as the highest order 8-bits of the word,
byte 1
is defined as the next highest order 8-bits, etc.
byte 0
is written to tape before byte 1.

Logical Record Format

A logical record normally has a minimum of three header words followed by data. The logical record wordlength is defined in the physical record header. Logical record headers with 32 bit words should have their 16 bit components in ``IBM'' order.

Physical Record Format

Each physical record normally has a variable length physical record header, followed by data. However, certain records, following a record with a suitable header may have no header. The word length may be 16 or 32 bits but in both cases the values of lengths and pointers are in units of 16 bits.

The physical header identifier fields (7 and 8) are used by the off-line package to identify the header word length, to help in error detection and recovery, and to decide if byte swapping is required. For the 32 bit header words, the least significant 16 bits are in the leftmost 16 bits of the word, i.e. "IBM format". The off-line package achieves this by calling CTOIBM before the header is output.


Next: References Up: EPIO Previous: Auxiliary routines used



goossens@cern.ch