UNET

CMS Tape User's Guide

Magnetic tape is an inexpensive, large capacity medium for data storage. The operating systems at CAPS include several commands related to tape use. This document explains a number of concepts relevant to tape use and the commands to store and retrieve data from tape.


Introduction

A computer system is designed to manipulate information - "data". The storage of data is therefore an important aspect of computing and the choice of a storage method can be very important for the computer user. The purpose of this document is to discuss one of the several storage possibilities available to the UNET CMS account holder.

Data can be stored on magnetic tape, on magnetic disks, and on various other devices. Disk storage is reliable and fast, but suffers from its scarcity, cost, and lack of portability from one computer system to the next, particularly for very large disk files.

Tapes can suffer physical damage over long usage or improper storage conditions, but they are relatively cheap and portable, and offer a good medium for backing up important disk files. Compatibility can be a problem however, so before you commit data to tape determine whether the tape formats supported on CMS are usable on any other computer systems you may need to access.

The material below describes how tapes can be used on CMS. There are two sections: "Physical Characteristics", which defines a number of terms related to the physical recording of data on tape; and "Using Tapes on CMS", which gives the operating system commands for reading and writing tapes.


Physical Characteristics

A 9 track tape is a 1/2 in. wide strip coated with magnetic material. Tape reels come in varying lengths - a full size reel contains 2400 feet of tape. Cartridge tapes..... Information is stored on the tape surface in the form of magnetized areas. One polarity represents 0; the opposite is 1. Information is recorded on the tape as patterns of 1's and 0's (bits). Eight bits make up a "byte" which is the fundamental data unit. A 9-track tape has 9 stripes running the length of the tape where bits can be stored. Each byte of data is written across the width of the tape, one bit per track, with the extra track used for error checking. The "density" with which data is stored on a tape is measured in "Bytes Per Inch" or BPI. Thus theoretically, a 1600 BPI tape that is 2400 feet long can hold 1600 x 12 x 2400 = 46 million bytes. In fact, data is not recorded in a continuous stream end to end of a tape, so the actual capacity of a 1600 BPI full reel of 9-track tape is somewhat less (there is unused tape at the beginning and end of the reel, each block of data is terminated by special checksum bytes and some blank tape that separates one data block from the next - roughly 1/2 inch between blocks).

The machine that records data on and retrieves data from a tape is called a tape drive. The process of storing data is called "writing" and the retrieval of data is called "reading" the tape.


EBCDIC Character Code

An IBM mainframe computer uses 8 bits (8 1's and 0's) to represent one character. Thus the character "A" is represented by the bit pattern 11000001. In IBM computer jargon, 8 bits is called a "byte", so we can store one character in one byte. On a 9-track tape, data is recorded one character or byte across the width of the tape.

The method used by large IBM computers for translation of characters into 8-bit patterns of 1's and 0's is called EBCDIC. Different computer systems may use different translation schemes, so if the tape will be taken to another computer installation it is important to know that UNET uses IBM mainframes and therefore uses EBCDIC. (Note that UNET can work with other character codes. See the UNET consultants for assistance.)


Files

A set of data stored on some device in a computer system is called a file. A tape can hold many files; files are physically separated from one another by special characters called tapemarks and short stretches of blank tape. The computer system automatically recognizes the tapemarks. Data is normally dealt with one file at a time.


Logical Records and Physical Blocks

Data is written on a tape by a computer program of some sort. Roughly speaking, programs deal with data one "line" at a time. The "line" of data that a program reads or writes is called a logical record. For example, if a user is copying a disk file onto tape, each line of the disk file will constitute a logical record.

Logical records can be written one at a time on the tape or be collected into groups of several logical records which are then written as a unit. In either case, the collection of data actually transmitted to the tape is called a physical block or a physical record. Thus a block can contain a single logical record or several.

On the tape, each physical block is separated from the next by a gap of unused tape approximately .6 inch long. Recall that an 80-character line or record occupies only .05 inch of tape at density 1600 BPI. If a tape is to be used for such short records and each block contains only one logical record, then a great deal of tape will be wasted (approximately .65 inch per block, of which only .05 inch contains data).

The person using the tape may request a "blocking factor" - i.e., may specify how many logical records are to be combined into each physical block. The greater the physical block length, the more efficient the usage of tape will be (less unused tape). For most programs, the user need only specify the logical record length (measured in characters or bytes) and the block length (a multiple of the logical record length) and the computer system will automatically collect logical records into blocks and transmit the blocks to the tape. The user need not be concerned with how this process is accomplished.

The means used to inform the computer system of the logical record length and block length vary somewhat with the programming language. Some information on this is found below in Part II. The CMS "keywords" used to refer to this information are LRECL for logical record length and BLOCK for block size or length. Thus a file containing 80-character lines blocked with 15 lines per physical block would have LRECL 80 and BLOCK 1200. CMS limits the BLOCK and LRECL lengths to 64K or less.


Record Format

Logical records may all be of the same length, or they may vary in length. If all are the same length, the LRECL (see above) specifies what this length is, and if necessary blanks are added at the end of short records to pad them out. Records of this type are said to be "fixed format". On the other hand, logical records may vary in length, in which case the LRECL specifies a maximum record length, and no padding occurs. Records of this type have "varying format".

The command language keyword used to specify what record format is desired is RECFM. Some of the possibilities for RECFM are F, FB, U, V, VB, VS, VBS.

F, FB, and U are the most common formats for tape files on our system.

F means fixed format with one logical record per physical block (LRECL = BLOCK). FB means fixed format with more than one logical record per block (BLOCK is a multiple of LRECL).

U stands for "undefined format" and is used for records that vary in length. For U format, the LRECL = BLOCK = the max. record length. (Note that tape format U is similar to disk file format V.)

Record formats V, VB, VS and VBS are seldom used for tape files. We describe them below for the sake of completeness.

V stands for varying format with one logical record per block, and with LRECL equal to the maximum record length plus 4. BLOCK must equal LRECL + 4. The extra 4s in the LRECL and BLOCK are to hold length information which the system needs to process the varying length records. VB is similar to V except that there are multiple logical records per block and BLOCK is a multiple of LRECL plus 4. (e.g. BLOCK = 408 where LRECL = 104 and the actual max. record has length less than or equal to 100).

VS and VBS are used for so-called "binary files" -- tape files written without conversion to EBCDIC. VS is similar to V and VBS to VB, except that the LRECL does not have to be a maximum. VS and VBS files can handle logical records that exceed the LRECL length.

For example: RECFM F LRECL 80 BLOCK 80
RECFM FB LRECL 80 BLOCK 1600
RECFM U LRECL 100 BLOCK 100
RECFM V LRECL 304 BLOCK 308
RECFM VS LRECL 304 BLOCK 308
RECFM VB LRECL 304 BLOCK 1220
RECFM VBS LRECL 20004 BLOCK 20008


Tape Labels

Some computer systems allow the user to "label" his or her tapes. Tape labels contain names and other information about the files on the tape. The UNET CMS system does not create or process tape labels by default. Tapes written on our CMS system are usually unlabeled.

If a user brings a labeled tape from some other computer installation, the labels on the tape can be read as short files. Tape labels normally are terminated by standard tapemarks and can therefore be treated in the same way as data files. Alternatively, the user can request tape label processing via the FILEDEF command.

The advantage of unlabeled tapes is that tape handling is simplified. On the other hand, labels have the advantage that file information (such as file name, RECFM, LRECL and BLOCK) is automatically written to the tape along with the data.


Acquiring a Tape

Tapes can be rented from UNET or can be purchased. To use a privately owned tape at UNET, the tape must be "signed in", and stored in UNET's tape racks. When it is signed in, the tape is assigned a "reel id number" that is used to identify the tape.

The tape's owner (or renter) should choose one or two passwords for the tape. One password controls read-only access to the tape, the other controls read/write access. The passwords are written on a paper label on the outside of the tape reel. When anyone requests the tape, that person must supply the appropriate password. The computer center operators check the supplied password against the paper label on the tape reel, and if there is a mismatch, will not allow the tape to be used. Do not confuse the tape passwords with your CMS logon password.

All inquiries, rentals, and purchases of tapes should be directed to the UNET Tape Librarian at 581-3552 at the Orono offices.

Mounting a Tape

To use a tape on the computer, the tape must be mounted on a tape drive. Once the tape is mounted, data can be read or written from/to the tape either from a program or using CMS commands.

To mount a tape, the user must request that a tape drive be assigned to him/her, then that the operator retrieve the tape from the tape racks and place the tape on the tape drive. Please recall that there are a limite number of tape drives available, so that it is possible that a request for a tape drive will be denied or delayed because all the drives are already in use.

In CMS you request that a tape be mounted by typing the MOUNT command.

MOUNT TAPE xxnnnn ON 181 RING cc PASS pword DEN mmm
where "xxnnnn" is the tape reel id number assigned to the tape, "cc" is either "IN" or "OUT" (see below), "pword" is the appropriate password for the tape, and "mmm" is the recording density (800 or 1600). If the default density of 1600 is desired, DEN 1600 can be omitted.

RING IN means that the user can either read from or write to the tape. The password supplied must be the "read/write" password.

RING OUT means that the user can read data from the tape, but cannot alter the tape contents in any way. The password supplied must be the "read-only" password.

181 is the device number used for the tape drive by the virtual machine. If the user has already requested a tape using 181, and now wants a second tape drive (for example to copy one tape to another, necessitating two tape drives simultaneously), the second MOUNT request should use 182 as the device number:

     MOUNT TAPE xxnnnn ON 182  etc.
Having typed in the MOUNT request, the user should proceed to do other work until the operator responds. The operator will send a message to the user, either to tell him/her that no tape drives are available, or that the tape drive has been assigned to the user and that the requested tape is mounted. The user should not attempt to use the tape until the operator has said that the tape is actually mounted on the tape drive.

When the CMS user is finished with the tape, he/she should type in the command to rewind and "unload" the tape reel:

     TAPE RUN (TAP1
If desired, another tape can then be requested - the same tape drive will be used (issue another MOUNT request). If the user is finished with the tape drive, type the following command after the TAPE RUN:

     DETACH 181
The DETACH command releases the tape drive so another user can have it. Logging off will DETACH the tape drive automatically.


Reading and Writing Tapes: General Considerations

There are three commonly used ways to store (and retrieve) data on tape: using a program, the MOVEFILE command, the TAPE command. If you use a program, whether you have written it yourself or not, you must know something about how the program works with the tape before you can access the data successfully. See section K. below for more details.

TAPE and MOVEFILE are CMS commands that can be used in full CMS or CMSBATCH to read and write tape files. Each of these is discussed below. Each of the two has advantages and disadvantages.

MOVEFILE stores data on tape in "card image" form -- i.e., the data is stored exactly as it would appear if printed or displayed on a terminal screen. This format is especially desirable if the data is to be read by a program or the tape will be taken to some other computer center. MOVEFILE does not automatically store the name of the file along with the data on the tape. (However, using tape labels can get around this problem.)

The TAPE command is very simple and convenient to use. It is intended for "backup" tapes -- i.e., storage to supplement disk storage, or for second copies of files. Tapes written using the TAPE command generally cannot be used at other computer centers. The TAPE command stores the file name along with the data, so that files can be retrieved from tape by name.


Reading and Writing: the MOVEFILE Command

In CMS, the MOVEFILE (MOVE for short) command is a general purpose file copying command. MOVE can be used to copy a file from any storage device to any other. People frequently use it to copy files between disk and tape.

To use MOVE, the user must first issue FILEDEF commands to designate the device and other characteristics of the source file, and the device etc. of the destination. The FILEDEF command is described in detail in the CMS Reference manual and in online HELP on CMS.

The following is a simple example of copying a disk file named "MYFILE DATA A" to a tape. We will assume that the disk file is stored on disk with all lines or logical records the same length - 80 characters. For efficiency, the logical records will be grouped or blocked on the tape with 20 records per block.

FILEDEF INMOVE DISK MYFILE DATA A (RECFM F LRECL 80 BLOCK 80
FILEDEF OUTMOVE TAP1 (RECFM FB LRECL 80 BLOCK 1600
MOVE

Note that the source, the disk file, is marked "INMOVE" and the destination, the tape, is marked "OUTMOVE". The order of the two FILEDEF's is immaterial. INMOVE and OUTMOVE are special names for the MOVEFILE command. The RECFM, LRECL and BLOCK for the source (INMOVE) file must match the way the file is actually stored. To find out how a disk file is stored, use FILELIST or LISTFILE.

MOVE leaves the source file unchanged. The file is copied onto the tape starting at the spot on the tape which is currently under the tape drive's read/write head. If the tape contained any information already in that location, that information is lost. At the end of the copying, MOVE writes a "tapemark" (q.v.) indicating the end of the file. In order to write on the tape, the MOUNT command line must have specified RING IN.

To copy a file from tape to disk, use the same set of commands as above, only reverse the roles of "INMOVE" and "OUTMOVE" - i.e., use INMOVE for the tape, and OUTMOVE for the disk.

If a file (on either tape or disk) has a record format other than F or FB, use RECFM U for the two FILEDEF commands.


Positioning the Tape: the TAPE Command

In CMS, the TAPE command is used to position a tape on its tape drive, and to create and retrieve backup files for disk. The TAPE positioning subcommands move the the tape forward or backward on the tape drive, measuring the moves either by files or by physical blocks (q.v.). The TAPE command can also be used to rewind the tape back to the beginning, and unload it from the drive (i.e., prepare it for dismounting by the operator).

The following is a list of the command options relating to tape positioning:

   TAPE FSF n (TAPx
   TAPE FSR n (TAPx
   TAPE BSF n (TAPx
   TAPE BSR n (TAPx
   TAPE REW   (TAPx
   TAPE RUN   (TAPx

where "n" is an integer, and TAPx designates which tape is to be moved. If the user has only one tape currently mounted on a drive, that tape is called TAP1. If the user has two tapes simultaneously mounted, they are TAP1 and TAP2 (on drives 181 and 182, respectively), etc. FSF and BSF stand for "forward space file" and "backward space file". FSF n moves the tape forward until n tapemarks have been sensed by the tape drive -- in other words, it skips forward over n files. BSF n does the same in the backwards direction, leaving the tape positioned immediately before the nth tapemark found. FSR and BSR behave the same as FSF and BSF, except the forward or backward spacing is by physical records or blocks, rather than files. REW rewinds the tape back to the beginning of the first file. RUN rewinds and unloads the tape, readying it for dismounting.

For example, suppose a user wishes to use MOVE to copy the third file on a tape onto disk for use by some program. The following CMS commands can be used:

MOUNT TAPE xxnnnn ON TAP1 RING OUT PASS password
TAPE FSF 2
FILEDEF INMOVE TAP1 (RECFM FB LRECL 80 BLOCK 32000
FILEDEF OUTMOVE DISK MYDATA DATA A (RECFM F LRECL 80 BLOCK 80
MOVE

Please note that the RECFM, LRECL and BLOCK parameters on the FILEDEF's must reflect the reality of how the data is written on the tape.

The CMS user must remember to rewind and unload his/her tape and DETACH 181 after finishing with the tape.


Reading and Writing: the TAPE Command

It is frequently necessary to store backup copies of disk files on tape. UNET backs up users' disks, but the CMS user may want to control his/her own backups, and may want to store disk files on tape in order to erase them from disk to free up disk storage. This copying of files from disk to tape can be performed on a file-by-file basis by the MOVE command. However, the TAPE command provides a convenient, fast method which has certain advantages.

The following TAPE options relate to storage and retrieval of disk files onto tape:

   TAPE DUMP fn ft fm (TAPx
   TAPE LOAD fn ft fm (TAPx
   TAPE SCAN fn ft    (TAPx
   TAPE SKIP fn ft    (TAPx
In each case "TAPx" is as described above. "fn ft fm" is the three part identifier of a disk file. "fn ft" refers to the identifier of a disk file presently stored on the tape ("fm" has no meaning when the file is on tape).

TAPE DUMP fn ft fm copies the disk file designated by "fn ft fm" onto the tape starting at the current position of the tape drive read/write head. The tape must have been mounted RING IN. Any or all of the three parts of the file identifier can be replaced by * (thus, * * A, or MYDATA * B). In this case, all files satisfying the non-asterisk parts of the identifier will be copied to the tape. The asterisk acts as a "wildcard" character and allows multiple files to be specified on a single command.

TAPE DUMP copies all the files in a special backup format, and includes the filename and filetype of each file along with the actual contents of the file. Thus TAPE DUMP preserves a record of which disk files have been stored on the tape. All disk files placed on the tape by a single TAPE DUMP command go into one actual tape file. TAPE DUMP writes two tapemarks after the files it has copied onto the tape. The TAPE command then backspaces the tape and leaves it positioned just before those two tapemarks. This means that a second TAPE DUMP command will copy its disk files into the same physical file on the tape. Please remember the distinction here between the disk files that have been copied to the tape, and the single tape file, defined by a terminating tapemark, created by the TAPE DUMP command to hold those disk files. There may be many disk files stored in one tape file.

The reverse of TAPE DUMP is TAPE LOAD.

     TAPE LOAD fn ft fm
will search the tape starting at the current position for a file called "fn ft". If it finds a file of that name, the file will be copied to disk under the name "fn ft fm". Note that "fm" applies to the resultant disk file. The search on the tape will normally continue until the first tapemark is sensed. However, the option
     (TAPx EOT
where "TAPx" is described above and "EOT" stands for "end-of-tape", will continue the search until two consecutive tapemarks are sensed. Two consecutive tapemarks are regarded as meaning that no more data is stored on the tape. TAPE LOAD can only work with tapes written using TAPE DUMP. TAPE LOAD will accept asterisks for either fn or ft or both, thus allowing multiple loads from one command.

     TAPE SCAN fn ft (TAPx
will position the tape to the beginning of the file "fn ft" on the tape. The tape must have been written using TAPE DUMP. If desired, an EOT can be added just as for TAPE LOAD. TAPE SCAN will list the names of all the files it finds, either on the printer or at the user's terminal:

     TAPE SCAN (TAPx EOT TERM

The above command will list all TAPE DUMP files found on the tape from the current position until two consecutive tapemarks are read. The list appears on the terminal display. The tape is left positioned following the second tapemark.

     TAPE SKIP fn ft (TAPx
will search the tape for a file "fn ft". It differs from TAPE SCAN by leaving the tape positioned after the "fn ft" file.

For complete descriptions of the TAPE command with all its variations, please consult the CMS command reference manual or the online HELP facility.


Exploring a Tape: the TBROWSE Command

See HELP TBROWSE on CMS.


Reading and Writing from a Program

A tape can be used for input or output from a program in the same way as a disk file can. The program can be written by the user or be a package that CAPS provides.

If the program is a package, then the user must follow the rules of the package when using the tape. For example, a particular package may require that the input data file have a certain name. The user must use that name on a FILEDEF command before running the package. Consult the documentation for the program for details of this sort.

Whether the program is "home-grown" or a package, the commonest way of specifying input and output files is via the FILEDEF command. Normally, this command is issued immediately before the program is run. The user would enter the FILEDEF command before actually running the program.

The following examples show how this is done:

Ex. 1: A job using SAS. The raw data are on a tape. The user types in the MOUNT command and the FILEDEF command as follows:

MOUNT TAPE USXXXX ON TAP1 RING OUT PASS MYTAPE
FILEDEF MYDATA TAP1 (RECFM FB LRECL 100 BLOCK 900
Then runs the following SAS file:
 DATA RAW;
 INFILE MYDATA;
 INPUT VAR1 VAR2 VAR3;
 PROC SORT DATA=RAW;
    .
    .
    (more SAS statements)

Ex. 2: A simple FORTRAN program that writes data to a tape: The user mounts the tape and types in the FILEDEF command:

MOUNT TAPE TOXXXX ON TAP1 RING IN PASS ZZZZZ
FILEDEF 9 TAP1 (RECFM FB LRECL 60 BLOCK 600 PERM
Then the user runs the following FORTRAN program (which he/she has previously compiled - see the next chapter for information on this process):
      REAL*8 DSEED
      DIMENSION X(6)
C GENERATE 6000 RANDOM NUMBERS AND WRITE THEM TO TAPE
C USE A RANDOM NUMBER SUBROUTINE GGUBS.
C
      DO 1 I=1,1000
        CALL GGUBS(DSEED,6,X)
1       WRITE(9,99) X
99    FORMAT(6F10.7)
      END


Troubleshooting

This section lists some common errors that occur during tape processing.

  1. Trying to write on a tape when the RING is OUT. RING must be IN to write data onto a tape. When the RING is OUT the tape is said to be "file protected".

  2. Incorrect RECFM or BLOCK on the FILEDEF for a tape. DUMPT can help here. If you do not know the correct specifications, you can look at the tape using DUMPT, or use RECFM U with a large LRECL and BLOCK.

  3. Using MOVEFILE to read a tape created by TAPE DUMP (and vice versa). MOVE and TAPE DUMP write files to tape using incompatible formats. If you are not sure which format was used on your tape, try doing a TAPE SCAN first. If the tape is in TAPE DUMP format, the TAPE SCAN should give you a list of the files on the tape. If not, TAPE SCAN will tell you the tape is in the wrong format.

  4. Running off the end of the tape reel. Unless you are working with a labeled tape, CMS will not automatically detect the last file on the tape and stop the tape at that point. This means that you can try to read past the last file, running the tape right off the reel. This causes intense annoyance in the machine room, because the operator must rethread the tape on the reel. To avoid doing this, be sure that you know how many physical files you have on the tape. Some people write many tapemarks at the end of the last physical file (use TAPE WTM for this). Then if they find several tapemarks in a row (essentially empty files), they assume this marks the end of the data on the tape.

  5. ASCII vs EBCDIC. IBM mainframe computers use EBCDIC code. Most other computers use ASCII. If you receive a tape from some other computer center, it may be in ASCII rather than EBCDIC. In order to use the data on the tape, it must be translated from ASCII to EBCDIC. Ask the CAPS consultants for a program to do this.

  6. Physical defects on the tape or problems with the tape drive. If you get a message saying there is a "permanent I/O error" on the tape, you probably have a physical problem. You should probably try to read the tape again, in hopes that the difficulty was transient (a speck of dirt on the tape surface, for example). Even if you succeed in reading the tape subsequently, you should regard it with suspicion. In a situation like this, you should immediately copy the data from the suspect tape to another. Tapes are subject to physical deterioration. Note that occasionally a tape drive will misbehave, generating "false" errors when using a tape.

  7. Programming problems. The same I/O errors you can get while using a disk file from a program are possible when using tape. For example, if you specify a logical record length that is smaller than the actual logical records your program generates, you may receive an error message saying that your "buffer" is too small.

Using CMS: Contents Chapter Top Next Chapter Previous Chapter


Topic Index Frequently Asked Questions Document List Return to User Services Home


University of Maine System Network for Education and Technology Services, Copyright © 1999, revision date 2/26/99.