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 }

Calling Sequence

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

Arguments

Cdfid

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

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.

Explanation of the Structure Tags

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 example below.

Example

Open two netCDF files:

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'
; Insert a global attribute.

NCDF_ATTPUT, id, /GLOBAL, 'DAY', 'July 1,1996'
; Insert a global attribute.

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)

NCDF_CONTROL, id, /ENDEF ; Put the file into data mode.

name = NCDF_ATTNAME(id, /GLOBAL, 1) ; Get the second attribute's name.

NCDF_ATTGET, id, /GLOBAL, name, date ; Retrieve the date.

result = NCDF_ATTINQ(id, /GLOBAL, name) ; Get info about the attribute.

HELP, name, date, result, /STRUCTURE

IDL prints:

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

PRINT, date

IDL prints:

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

PRINT, STRING(date)

IDL prints:

July 1,1996

NCDF_DELETE, id ; Close the netCDF files.

NCDF_DELETE, id2

See Also

NCDF_ATTDEL , NCDF_ATTGET , NCDF_ATTNAME , NCDF_ATTPUT