The NCDF_ATTPUT procedure creates an attribute in a NetCDF file. If the attribute is new, or if the space required to store the attribute is greater than before, the NetCDF file must be in define mode.

Examples


NCDF_ATTPUT, cdfid, /GLOBAL, "Title", "My Favorite Data File"
NCDF_ATTPUT, cdfid, "data", "scale_factor", 12.5D

Syntax


NCDF_ATTPUT, Cdfid [, Varid] , Name , Value [, /GLOBAL] [, LENGTH=value] [, /BYTE | , /CHAR | , /DOUBLE | , /FLOAT | , /LONG | , /SHORT] [, /INT64] [, /STRING] [, /UBYTE] [, /UINT64] [, /ULONG] [, / USHORT]

Arguments


Cdfid

The NetCDF ID, returned from a previous call to NCDF_OPEN, NCDF_CREATE, or NCDF_GROUPDEF.

Varid

The NetCDF variable ID, returned from a previous call to NCDF_VARDEF or NCDF_VARID, or the name of the variable. If the GLOBAL keyword is set, this argument must be omitted.

Name

A scalar string containing the attribute name.

Note: The Name string may contain only alphanumeric characters and the - , _ , and . characters.

Note: You may use the special "_FillValue" attribute name to specify a default fill value for the variable. However, due to a bug in the underlying NetCDF library, you should only set "_FillValue" during the initial file creation. If you attempt to set "_FillValue" in REDEF mode, IDL will crash.

Value

An expression containing the data to be written. Although this procedure checks that there are a sufficient number of bytes of data, the data type is not checked or altered.

Keywords


GLOBAL

Set this keyword to create a global attribute.

LENGTH

Use this keyword to override the default length (the whole value). Set this keyword to a value less than or equal to the number of elements in Value. For example:

ATTR_ID = NCDF_ATTPUT(CDFID, VARID, 'Attr1', $
   INDGEN(10), LENGTH=5

writes Attr1 as [0,1,2,3,4].

 

The following keywords specify a non-default data type for the variable. By default, NCDF_ATTPUT chooses one based upon the type of data. If a data type flag is specified, the data supplied in Value is converted to that data type before being written to the file. Only one of these keywords can be used in a single call to NCDF_ATTPUT. By default, IDL strings are treated as type STRING.

BYTE

Set this keyword to indicate that the data is composed of bytes.

CHAR

Set this keyword to indicate that the data is composed of bytes (assumed to be ASCII).

DOUBLE

Set this keyword to indicate that the data is composed of 8-byte floating point numbers (doubles).

FLOAT

Set this keyword to indicate that the data is composed of 4-byte floating point numbers (floats).

INT64

Set this keyword to indicate that the data is composed of signed eight-byte integers.

LONG

Set this keyword to indicate that the data is composed of 4-byte integers (longs).

SHORT

Set this keyword to indicate that the data is composed of 2-byte integers.

STRING 

Set this keyword to indicate that the data is composed of string.

UBYTE

Set this keyword to indicate that the data is composed of unsigned bytes.

UINT64

Set this keyword to indicate that the data is composed of unsigned eight-byte integers.

ULONG

Set this keyword to indicate that the data is composed of unsigned four-byte integers.

USHORT

Set this keyword to indicate that the data is composed of unsigned two-byte integers.

Version History


Pre 4.0

Introduced

8.1 Added STRING, UBYTE, UINT64, ULONG, and USHORT keywords

See Also


NCDF_ATTINQ