Z203: Short List Reading and Writing

Author(s): R. Matthews, J. Zoll Library: KERNLIB
Submitter: Submitted: 15.07.1978
Language: Fortran Revised: 18.09.1991

The 'long list' form SPMquot WRITE(LUN) (A(J),J=1,N) " is translated into slow object code by some compilers. Normally, these compilers handle the 'short list' form

    DIMENSION A(N)
    WRITE(LUN) A
correctly, compiling just one system request, rather than N requests.

Furthermore, some machines require the calling program to know the record size beforehand, if reading is done in Fortran. The problem can be solved by adding the record size as the first word of the record, thus for
writing: WRITE(LUN) N,(B(J),J=1,N)
reading: READ (LUN) N,(B(J),J=1,N)

This way of reading and writing is an extra convention; it is called 'variable length' in the descriptions below.

Sometimes it is convenient to prefix each record with some identifiers, always the same number of words, say NA words:
writing: WRITE(LUN) N,(A(J),J=1,NA),(B(J),J=1,N)
reading: READ (LUN) N,(A(J),J=1,NA),(B(J),J=1,N)

This mode is called 'split mode' in the descriptions below.

The routines of XINOUT provide 'short list' reading and writing for split mode, variable length mode and also for fixed length mode.

Structure:

SUBROUTINE subprograms
User Entry Names: XINB, XINBF, XINBS, XOUTB, XOUTBF, XOUTBS
COMMON Block Names and Lengths: /SLATE/ NR,DUMMY(39)
Files Referenced: Parameter

Notes:

The routines XINCF and XOUTCF to handle formatted files are obsolete.

Usage:

Reading:
The vectors to be read are XAV and XV of length NA and NX; the read routines contain effectively

    DIMENSION XV(NX) [,XAV(NA)]
Before calling, NX must be preset to the maximum number of words to be accepted into XV with, say, tex2html_wrap_inline129 .
CALL XINB(LUN,XV,NX) Read binary, variable length:
READ(LUN) NR,(XV(J),J=1,MIN(NR,NX))
CALL XINBF(LUN,XV,NX) Read binary, fixed length:
READ(LUN) XV
CALL XINBS(LUN,XAV,NA,XV,NX) Read binary, split mode:
READ(LUN) NR,XAV,(XV(J),J=1,MIN(NR,NX))

On return NX contains:
NX
tex2html_wrap_inline131 Read successful, number of words transmitted into XV.
tex2html_wrap_inline133 End-of-file.
tex2html_wrap_inline135 Read error, its value contains the IOSTAT error code on most machines.
For XINB and XINBS the record length NR read from the file is stored into the first word of /SLATE/.
Writing:
The vectors to be written are AV and V of length NA and N; the write routines contain
DIMENSION V(N) [,AV(NA)]
CALL XOUTB(LUN,V,N) Write binary, variable length:
WRITE(LUN) N,V
CALL XOUTBF(LUN,V,N) Write binary, fixed length:
WRITE(LUN) V
CALL XOUTBS(LUN,AV,NA,V,N) Write binary, split mode:
WRITE(LUN) N,AV,V


tex2html_wrap_inline137


Michel Goossens Wed Jun 5 10:01:24 METDST 1996