NCDF_ATTINQ

The NCDF_ATTINQ function returns a structure that contains information about a NetCDF attribute. This structure, described below, has the form:

{ DATATYPE:'', LENGTH:0L }

Examples

id = NCDF_CREATE('test.nc', /CLOBBER) ; Open a new NetCDF file.

id2 = NCDF_CREATE('test2.nc', /CLOBBER) ; Open a second file.

; Create two global attributes TITLE and DATE:

NCDF_ATTPUT, id, /GLOBAL, 'TITLE', 'MY TITLE'

NCDF_ATTPUT, id, /GLOBAL, 'DAY', 'July 1,1996'

; Suppose we wanted to use DATE instead of DAY. We could use

; ATTRENAME to rename the attribute:

NCDF_ATTRENAME, id, 'DAY', 'DATE', /GLOBAL

; Next, copy both attributes into a duplicate file:

result = NCDF_ATTCOPY(id, 'TITLE', id2, /IN_GLOBAL, /OUT_GLOBAL)

result2 = NCDF_ATTCOPY(id, 'DATE', id2, /IN_GLOBAL, /OUT_GLOBAL)

; Put the file into data mode:

NCDF_CONTROL, id, /ENDEF

; Get the second attribute’s name:

name = NCDF_ATTNAME(id, /GLOBAL, 1)

; Retrieve the date:

NCDF_ATTGET, id, /GLOBAL, name, date

; Get info about the attribute:

result = NCDF_ATTINQ(id, /GLOBAL, name)

HELP, name, date, result, /STRUCTURE

PRINT, date

PRINT, STRING(date)

NCDF_CLOSE, id ; Close the NetCDF files.

NCDF_CLOSE, id2

IDL Output

NAME STRING = 'DATE'

DATE BYTE = Array(12)

** Structure <400dac30>, 2 tags, length=12, refs=1:

DATATYPE STRING 'BYTE'

LENGTH LONG 12

Note the length includes the NCDF standard NULL terminator

74 117 108 121 32 49 44 49 57 57 54 0

 

July 1,1996

Syntax

Result = NCDF_ATTINQ( Cdfid [, Varid] , Name [, /GLOBAL])

Return Value

The structure returned by this function contains the following tags:

Tag

Description

DataType

A string describing the data type of the variable. The string will be one of the following: BYTE, CHAR, INT, LONG, FLOAT, or DOUBLE.

Length

The number of values stored in the attribute. If the attribute is a string, the number of values indicates one more character than the string length to include the terminating null character. This is the NetCDF convention, as demonstrated in the following example.

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 name of the attribute for which information is to be returned.

Keywords

GLOBAL

Set this keyword to inquire about a global variable. If this keyword is set, the Varid argument must be omitted.

Version History

Pre 4.0

Introduced

See Also

NCDF_ATTDEL, NCDF_ATTGET, NCDF_ATTNAME, NCDF_ATTPUT