Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ topen(3F) — Sun FORTRAN 1.3.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

mtio(4S)

perror(3f)

read(2)

write(2)

ioctl(2)

TOPEN(3F)  —  FORTRAN LIBRARY ROUTINES

NAME

topen, tclose, tread, twrite, trewin, tskipf, tstate − f77 tape I/O

SYNOPSIS

integer function topen ( tlu, devnam, islabeled )
integer tlu
character∗(∗) devnam
logical islabeled integer function tclose ( tlu )
integer tlu integer function tread ( tlu, buffer )
integer tlu
character∗(∗) buffer integer function twrite ( tlu, buffer )
integer tlu
character∗(∗) buffer integer function trewin ( tlu )
integer tlu integer function tskipf ( tlu, nfiles, nrecs )
integer tlu, nfiles, nrecs integer function tstate ( tlu, fileno, recno, errf, eoff, eotf, tcsr )
integer tlu, fileno, recno, tcsr
logical errf, eoff, eotf

DESCRIPTION

These functions provide a simple interface between FORTRAN and magnetic tape devices.  Use topen() to open a tape logical unit ( tlu) for the specified device. This works in much the same way as opening a normal FORTRAN logical unit using open().  All other operations are performed via the tlu. The tlu has no relationship at all to any normal FORTRAN logical unit. 

topen( tlu, devnam, islabeled ) — Associate a device name with a tape logical unit (does not move tape). 

tlu is the tape logical unit.  It is an integer input argument.  It must be in the range 0 to 3.  islabeled indicates whether the tape is labeled.  It is a logical input argument. 

If the tape contains a tape label, then you set islabeled to true. 

Return value — A 0 indicates OK.  A negative indicates an error.  See perror(3f) for details.

tclose( tlu ) — Close the tape device channel and remove its association with tlu.

Return value — A 0 indicates OK.  A negative indicates an error. 

tread( tlu, buffer ) — Read the next physical record from tape into buffer.

buffer must be of type character. 

The size of buffer should be large enough to hold the largest physical record to be read. 

Return value — tread() returns the actual number of bytes read. 

0 indicates the end-of-file. 
A negative indicates an error.

twrite( tlu, buffer ) — Write a physical record to tape from buffer.

buffer is an input argument and must be of type character.  Return value — twrite() returns the number of bytes written. 

A value of 0 or negative indicates an error. 
The physical record length will be the size of buffer.

trewin( tlu ) — Rewind the tape to the beginning of the first data file. 

Return value — A 0 indicates OK.  A negative value indicates an error.  If the tape is labeled (see topen above) then the label is skipped over after rewinding. 

tskipf( tlu, nfiles, nrecords ) — Skip over files and/or records. 

Return value — A 0 indicates OK.  A negative value indicates an error.  First it skips nfiles end-of-file marks. If the current file is at EOF, this counts as 1 file to skip.  (Note: This is the way to reset the EOF status for a tlu.) Next it skips over nrecs physical records. 

tstate( tlu, fileno, recno, errf, eoff, eotf, tscr ) — Determine the logical state of the tape I/O channel. 

tlu is an integer input argument, the tape logical unit.  fileno is an integer output argument indicating the current file number.  recno is an integer output argument indicating the current record number.  errf is a logical output argument indicating an error occurred.  eoff is a logical output argument indicating the current file is at EOF. 

While eoff is true, you cannot read from that tlu. You can set this EOF indicater to false by using tskipf() to skip one file and zero records: I=tskipf( tlu, 1, 0 ).  Then you can read any valid record that follows. 

eotf is a logical output argument indicating the tape has reached logical end-of-tape. 

End-of-tape (EOT) is indicated by an empty file, often referred to as a double EOF mark.  You cannot read past EOT, but you can write past EOT. 

tcsr is an integer output argument containing the tape drive control status register. 

See mtio(4S) for details.

EOF & EOT Summary

1. If at either EOF or EOT, then

a.  Any tread() will just return; it will not read the tape. 
b.  A tskipf( tlu, 1, 0 ) resets the EOF status to false, and returns; it does not advance the tape pointer. 

2. A successfull twrite() resets the EOF and EOT status flags.  3. A succesfull tclose() resets all those flags to false. 

FILES

/usr/lang/SC0.0/libF77.a

SEE ALSO

mtio(4S), perror(3f), read(2), write(2), ioctl(2)

Sun Release 4.1  —  Last change: 18 December 1989

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026