%N xyzwrite %F $MIR/src/subs/xyzio.c
%D Write arbitrary subcube
%P bpw
%: image-i/o
%B
      subroutine xyzwrite( tno, coords, data, mask, ndata )
      integer    tno
      integer    coords(*)
      real       data(*)
      logical    mask(*)
      integer    ndata

This routine, xyzsetup and xyzs2c work together to allow writing an
arbitrary subcube in a n-dimensional datacube. xyzwrite writes a subcube
to the datacube, as defined by xyzsetup at coordinates calculated by
xyzs2c.

The array coords gives the coordinates of the axes complementary to
the subcube axes. E.g., if 'subcube' in the call to xyzsetup was 'y'
and the datacube is 3-dimensional, coords(1) and coords(2) give the
'x' and 'z' coordinate of the requested line profile, respectively. Or,
if 'subcube' was 'xz', coords(1) gives the 'y'-coordinate of the plane.
For a datacube of dimension 'd', only the first 'd - dimsub' elements
of the array coords will be used (where 'dimsub' is the dimension of the
subcube).

The array data (of dimension ndata) holds the information to be written.
If the subcube was 0-dimensional, the first element of data is written.
For a 1-d subcube a profile is written. The first vircubesize(1) (as
returned by xyzsetup) elements of data are used. For a 2-d subcube the
array data gives the requested plane, as a 1-d array of length
vircubesize(2). Etc.

The mask array indicates if pixels in the data array must be set to
"undefined". A TRUE value means the data is OK, FALSE means it is
undefined. Element 1 corresponds to data 1, etc.
(this is not yet implemented, so ignored)

N.B.: to write a datacube pixel by pixel it is more efficient to use
subroutine xyzpixwr instead of xyzwrite, as the conversion from
offset to coordinates to offset that xyzs2c and xyzwrite do then is
superfluous and time-consuming.

    Input:
      tno           image file handle
      coords        array of which the first (dim cube)-(dim subcube)
                     elements are used, giving the coordinate values
                     along the complementary axes
      data          array containing data to be written
      mask          FALSE values indicate undefined pixel
      ndata         number of elements to write                               
