Dervish Tape I/O Extensions

Dervish adheres to the FITS standard for performing I/O on physical media (example DLT cartridges). FITS standard dictates that individual FITS files be terminated by a tape-mark, and the end of that physical medium be denoted by two (2) consecutive tape-marks. FITS files should not span multiple mediums.

Logically, one can visualize FITS images stored on tape as follows:

FITS-image-1 [EOF] FITS-image-2 [EOF] . . . FITS-image-n [EOF] [EOF]

The remaining discussion assumes the physical media to be 8mm or DLT tape cartridges.

In order to use dervish for FITS tape I/O, a device driver must be chosen that has the following properties:

  • it must be a no-rewind device
  • it must be a variable block type device
  • it must be a no-swapping device
  • The following devices correspond to the above list here at Fermilab:
  • sdss.fnal.gov:/dev/rmt/tps1d5nrnsv.8500
  • sdss.fnal.gov:/dev/rmt/tps1d6nrnsv.8500
  • sdssdp1.fnal.gov:/dev/rmt/tps4d3nrnsv.8500 (8mm)
  • sdssdp1.fnal.gov:/dev/rmt/tps4d2nrnsv.8500 (8mm)
  • sdssdp1.fnal.gov:/dev/rmt/tps4d3nrnsv (DLT)
  • sdssdp1.fnal.gov:/dev/rmt/tps5d3nrnsv (DLT)
  • fncase.fnal.gov:/dev/nrst8
  • Accessing Tapes from Region, Header, and Mask Commands

    The following TCL commands all take an optional switch, [-tape], which causes data to be read/written from the tape device specified:
  • regReadAsFits,
  • regWriteAsFits,
  • hdrReadAsFits,
  • hdrWriteAsFits,
  • maskReadAsFits,
  • maskWriteAsFits
  • During execution, these commands all cause a copy of the UNIX "dd" command to be forked from Dervish. The actual tape I/O is handled by dd, and the data are passed to Dervish via a pipe. Each of these commands also has a [-pipe] switch, which causes data to be read/written from a user specified pipe. These two commands are equivalent in effect:
    regReadAsFits -tape h0 /dev/rmt/tps4d3nrnsv
    regReadAsFits -pipe h0 [open "|dd if=/dev/rmt/tps4d3nrnsv bs=144000 files=1"]
    
    The [-tape] option uses a tape blocksize of 144000 bytes, which corresponds to the blocking used in the data acquisition system. Tapes with smaller blocksizes may be read successfully; tapes with larger blocking must be read using a variation on the command with the [-pipe] option shown above. Similarly, if you require tapes to be written with blocksizes other than 144000 bytes, you must use the [-pipe] form of these commands with an explicit dd command specified.

    Accessing Tapes from Region, Header, and Mask Routines

    The following routines all take an argument which, if set, causes data to be read/written from the tape device specified:
  • shRegReadAsFits,
  • shRegWriteAsFits,
  • shHdrReadAsFits,
  • shHdrWriteAsFits,
  • shMaskReadAsFits,
  • shMaskWriteAsFits
  • During execution, these commands all cause a copy of the UNIX "dd" command to be forked from Dervish. The actual tape I/O is handled by dd, and the data are passed to Dervish via a pipe. The dd uses a tape blocksize of 144000 bytes, which corresponds to the blocking used in the data acquisition system. Tapes with smaller blocksizes may be read successfully.

    TCL Extensions for Tape Movement

    The following TCL extensions are available for positioning tapes and writing EOT markers:
  • tapeRewind
  • tapeEject
  • tapePositionOverImage
  • tapePositionOverNextImage
  • tapeWriteEot
  • All of the above extensions expect to find the tape drive to be used in an environment variable called $TAPE. This behaviour can be changed by specifying an optional command line parameter containing the name of tape drive. If both the $TAPE environmental variable and the command line parameter naming the drive are specifed, the latter takes precedence.

    Examples

    The following example assumes the existence of two regions, h1 and h2, and one mask, m1. The regions and mask are previously read from elsewhere and are going to be written on tape. Here is the sequence of commands that will accomplish this: dervish> tapeRewind /dev/nrst8 dervish> regWriteAsFits -tape h1 /dev/nrst8 h1 dervish> regWriteAsFits -tape h2 /dev/nrst8 h2 dervish> maskWriteAsFits -tape m1 /dev/nrst8 m1 dervish> tapeWriteEot /dev/nrst8 dervish> tapeRewind /dev/nrst8 dervish> tapeEject /dev/nrst8 In the above example, note that no explicit EOF marker was written after each region or mask. The device driver automatically writes a EOF marker on encountering the close(1) UNIX system call. However, note that we had to explicitly write an End-of-Tape marker.

    The following examples will read the data written on tape. It is assumed that the data stored on tape is of the following format:

    region-1 [EOF] region-2 [EOF] mask-1 [EOF][EOF]

    In the examples below, assume that the tape drive to be used is specified in the environment variable $TAPE:

    1. Reading the third image on tape: dervish> tapeRewind dervish> tapePositionOverImage 3 dervish> maskReadAsFits -tape [maskNew] /dev/nrst8 h1 dervish> tapeRewind dervish> tapeEject
    2. Reading all images sequentially from tape: dervish> tapeRewind dervish> regReadAsFits -tape [regNew] /dev/nrst8 h1 dervish> tapePositionOverNextImage dervish> regReadAsFits -tape [regNew] $env(TAPE) h2 dervish> tapePositionOverNextImage dervish> maskReadAsFits -tape [maskNew] /dev/nrst8 h3 dervish> tapeRewind dervish> tapeEject

    tapeRewind

    Rewind a tape drive

    TCL SYNTAX: tapeRewind [tapeDevice] [tapeDevice] - name of the tape device. If omitted, the value of the environmental variable $TAPE is used instead. Specifying tapeDevicetakes precedence over using $TAPE

    tapeEject

    Eject a tape drive

    TCL SYNTAX: tapeEject [tapeDevice] [tapeDevice] - name of the tape device. If omitted, the value of the environmental variable $TAPE is used instead. Specifying tapeDevicetakes precedence over using $TAPE

    tapePositionOverImage

    Position the tape head over the nth image for a subsequent read operation. Note that n is relative to the beginning of tape, not the current position.

    TCL SYNTAX: tapePositionOverImage [tapeDevice] <n> [tapeDevice] - name of the tape device. If omitted, the value of the environmental variable $TAPE is used instead. Specifying tapeDevicetakes precedence over using $TAPE n - Number of the desired image on tape. The head will be positioned over this image.

    tapePositionOverNextImage

    Position the tape head over the next image for a subsequent read operation. If the preceeding image was the last one on tape, the tape head will be positioned on an [EOF]

    TCL SYNTAX: tapePositionOverNextImage [tapeDevice] [tapeDevice] - name of the tape device. If omitted, the value of the environmental variable $TAPE is used instead. Specifying tapeDevicetakes precedence over using $TAPE

    tapeWriteEot

    Write a FITS standard End-of-Tape marker on the tape. This extension MUST be used after writing the last FITS image on tape.

    TCL SYNTAX: tapeWriteEot [tapeDevice] [tapeDevice] - name of the tape device. If omitted, the value of the environmental variable $TAPE is used instead. Specifying tapeDevicetakes precedence over using $TAPE