HDF_DFSD_STARTSLICE

The HDF_DFSD_STARTSLICE procedure prepares the system to write a slice of data to a Hierarchical Data Format file. HDF_DFSD_SETINFO must be called before HDF_DFSD_STARTSLICE to set the dimensions and attributes of the slice.

This procedure must be called before calling HDF_DFSD_PUTSLICE, and must be terminated with a call to HDF_DFSD_ENDSLICE.

Calling Sequence

HDF_DFSD_STARTSLICE, Filename

Arguments

Filename

A scalar string containing the name of the file to be written.

Example

fid=HDF_OPEN('test.hdf',/ALL) ; Open an HDF file.

Create two datasets:

slicedata1=FINDGEN(5,10,15)

slicedata2=DINDGEN(4,5)

Use HDF_DFSD_SETINFO to set the dimensions, then add the first slice:

HDF_DFSD_SETINFO,LABEL='label1', DIMS=[5,10,15], /FLOAT

HDF_DFSD_STARTSLICE,'test.hdf'

HDF_DFSD_PUTSLICE, slicedata1

HDF_DFSD_ENDSLICE

Repeat the process for the second slice:

HDF_DFSD_SETINFO, LABEL='label2', DIMS=[4,5], /DOUBLE

HDF_DFSD_STARTSLICE,'test.hdf'

HDF_DFSD_PUTSLICE, slicedata2

HDF_DFSD_ENDSLICE

HDF_DFSD_SETINFO, /RESTART

Use HDF_DFSD_GETINFO to advance slices and set slice attributes, then get the slices:

HDF_DFSD_GETINFO, name, DIMS=dims, TYPE=type

HDF_DFSD_GETSLICE, out1

HDF_DFSD_GETINFO, name, DIMS=dims, TYPE=type

HDF_DFSD_GETSLICE, out2

Close the HDF file:

HDF_CLOSE('test.hdf')

Check the first slice to see if everything worked:

IF TOTAL(out1 EQ slicedata1) EQ N_ELEMENTS(out1) THEN $

    PRINT, 'SLICE 1 WRITTEN/READ CORRECTLY' ELSE $

    PRINT, 'SLICE 1 WRITTEN/READ INCORRECTLY'

IDL prints:

SLICE 1 WRITTEN/READ CORRECTLY

Check the second slice to see if everything worked:

IF TOTAL(out2 EQ slicedata2) EQ N_ELEMENTS(out2) THEN $

    PRINT, 'SLICE 2 WRITTEN/READ CORRECTLY' ELSE $

    PRINT, 'SLICE 2 WRITTEN/READ INCORRECTLY'

IDL prints:

SLICE 2 WRITTEN/READ CORRECTLY

See Also

HDF_DFSD_ENDSLICE , HDF_DFSD_GETINFO , HDF_DFSD_GETSLICE , HDF_DFSD_PUTSLICE , HDF_DFSD_SETINFO