Fortran Library Reference

tread: Read Next Physical Record from Tape

The function is called by:

INTEGER*4 tread

n = tread( tlu, buffer )

tlu

INTEGER*4

Input 

Tape logical unit, in range 0 to 7.  

buffer

character

Input 

Must be sized at a multiple of 512, and must be large enough to hold the largest physical record to be read.  

n

INTEGER*4

Return value 

n>0: OK, and n is the number of bytes read.

n<0: Error

n=0: EOF

If the tape is at EOF or EOT, then tread does a return; it does not read tapes.

Example: tread()--read the first record of the file written above:


    CHARACTER devnam*9 / '/dev/rst0' /, onerec*512 / " " /
    INTEGER*4 n / 0 /, tlu / 1 /, topen, tread
    LOGICAL islabeled / .false. /
    n = topen( tlu, devnam, islabeled )
    IF ( n .LT. 0 ) STOP "topen: cannot open"
    n = tread( tlu, onerec )
    IF ( n .LT. 0 ) STOP "tread: cannot read"
    WRITE(*,'("tread ok:", 2I4, 1X, A10)')  n, tlu,  devnam
    WRITE(*,'( A4)')  onerec
    END

The output is:


tread ok: 512 1 /dev/rst0
abcd