Routines (alphabetical) > Routines: G > GRIB Routines > GRIB_SET

# GRIB_SET

The GRIB_SET procedure sets the value of a scalar key in a GRIB message.

## Examples

This example procedure reads the GRIB file filename_in, sets key/value pairs, and writes the output to the file filename_out.

Set the KEY keyword to a case-sensitive string. If KEY is set, VALUE must be set.

Set the VALUE keyword to the KEY value. If VALUE is set, KEY must be set.

PRO GRIB_WRITE_EX, filename_in, filename_out, KEY=key, VALUE=value

ON_ERROR, 2

IF(filename_in EQ !null) THEN MESSAGE, 'File is undefined.'

IF(filename_out EQ !null) THEN MESSAGE, 'File is undefined.'

IF(ARG_PRESENT(key) AND ~ ARG_PRESENT(value)) $

THEN MESSAGE, 'If key is set then value has to be set.'

IF(ARG_PRESENT(value) AND ~ ARG_PRESENT(key)) $

THEN MESSAGE, 'If value is set then key has to be set.'

fin = GRIB_OPEN(filename_in)

h = GRIB_NEW_FROM_FILE(fin)

IF (ARG_PRESENT(key)) THEN BEGIN

IF (ISA(value, /ARRAY)) THEN GRIB_SET_ARRAY, h, key, value $

ELSE GRIB_SET, h, key, value

ENDIF

GRIB_WRITE_MESSAGE, filename_out, h

GRIB_RELEASE, h

GRIB_CLOSE, fin

END

## Syntax

GRIB_SET, Ghandle, Key, Value

## Arguments

### Ghandle

The GRIB file handle.

### Key

The key name, which must be a case-sensitive string.

### Value

The key value to set (must be a scalar value). Value is set as the native type.

## Version History

8.1 | Introduced

## See Also

GRIB_SET_VALUES