Routines (alphabetical) > Routines: H > HDF-EOS Routines > EOS_GD_DEFCOMP

# EOS_GD_DEFCOMP

This function sets the HDF field compression for subsequent grid field definitions. The compression does not apply to one-dimensional fields. The compression schemes currently supported are: run length encoding (1), skipping Huffman (3), deflate (gzip) (4) and no compression (0, the default). Deflate compression requires a single integer compression parameter in the range of one to nine with higher values corresponding to greater compression.

Compressed fields are written using the standard EOS_GD_WRITEFIELD function, however, the entire field must be written in a single call. If this is not possible, the user should consider tiling. See EOS_GD_DEFTILE for further information. Any portion of a compressed field can then be accessed with the EOS_GD_READFIELD function. Compression takes precedence over merging so that multi-dimensional fields that are compressed are not merged. The user should refer to the HDF Reference Manual for a fuller explanation of compression schemes and parameters.

## Examples

Suppose we wish to compress the Pressure field using run length encoding, the Opacity field using deflate compression, the Spectra field with skipping Huffman compression, and use no compression for the Temperature field:

status = EOS_GD_DEFCOMP(gridID, 1)

status = EOS_GD_DEFFIELD(gridID, "Pressure", "YDim,XDim", 5)

compparm[0] = 5

status = EOS_GD_DEFCOMP(gridID, 4, compparm)

status = EOS_GD_DEFFIELD(gridID, "Opacity", "YDim,XDim", 5)

status = EOS_GD_DEFCOMP(gridID, 3)

status = EOS_GD_DEFFIELD(gridID, "Spectra", "Bands,YDim,XDim", 5)

status = EOS_GD_DEFCOMP(gridID, 0)

status = EOS_GD_DEFFIELD(gridID, "Temperature", "YDim,XDim", 5,$ /MERGE)

Note that the MERGE keyword will be ignored in the Temperature field definition.

## Syntax

Result = EOS_GD_DEFCOMP(gridID, compcode [, compparm] )

## Return Value

Returns SUCCEED(0) if successful and FAIL(–1) otherwise.

## Arguments

### gridID

Grid id (long) returned by EOS_GD_CREATE or EOS_GD_ATTACH.

### compcode

HDF compression code (long).

Allowable values are:

- 0 = None
- 1 = Run Length Encoding (RLE)
- 3 = Skipping Huffman
- 4 = Deflate (gzip)

### compparm

Compression parameters array. Compparm is an array argument whose value(s) depend on the compression scheme selected.

## Keywords

None

## Version History

5.2 | Introduced