[Top] [Prev] [Next] [Bottom]

SDsetattr/sfsnatt/sfscatt

intn SDsetattr(int32 [file, sds, dim]_id, char *attr_name, int32 data_type, int32 count, VOIDP values)
[file, sds, dim]_id

IN:

Identifier of the object the attribute is to be attached to: an file_id for a file, an sds_id for an SDS or a dim_id for a dimension

attr_name

IN:

Name to be assigned to the attribute

data_type

IN:

Data type of the values in the attribute

count

IN:

Total number of values to be stored in the attribute

values

IN:

Data values to be storde in the attribute

Purpose

Defines a new type of attribute for the given variable.

Return value

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

Description

This routine provides a generic way for users to define metadata. It implements the label=value data abstraction.

The attr_name argument can be any ASCII string for which one or more values may be stored. If more than one value is stored, all values must have the same data type. If an attribute with the given scope and name exists, it will be over written.

If an sd_id is given instead of an sds_id, a global attribute is created which applies to the whole file. Global attributes refer to all objects in a file as opposed to specific datasets. For example, "file_creator_date" is a global attribute, whereas "units" is typically considered to be dataset-specific.

Valid values for data_type are prefaced by DFNT_. The following are valid symbolic names and their data types:

32-bit float DFNT_FLOAT32 5

64-bit float DFNT_FLOAT64 6

8-bit signed int DFNT_INT8 20

8-bit unsigned int DFNT_UINT8 21

16-bit signed int DFNT_INT16 22

16-bit unsigned int DFNT_UINT16 23

32-bit signed int DFNT_INT32 24

32-bit unsigned int DFNT_UINT32 25

8-bit signed character DFNT_CHAR8 4

Note that there are two Fortran-77 versions of this routine: sfsnatt and sfscatt. The sfsnatt routine writes numeric attribute data and sfscatt writes character attribute data.

Example

Store a "valid_range" attribute for a dataset.

     int32 range[2];
     int32 sds_id;
     int32 status;
     ...
     sds_id = SDcreate...;
     ...
     range[0] = 5;
     range[1] = 100;
     status = SDsetattr(sds_id, "valid_range", DFNT_INT32, 2, range);
 
FORTRAN

integer function sfsnatt([file, sds, dim]_id, attr_name, data_type, count, values)

character* (*) attr_name

integer [file, sds, dim]_id, data_type, count

<valid numeric data type> values(*)

integer function sfscatt([file, sds, dim]_id, attr_name, data_type, count, values)

character* (*) attr_name, values

integer [file, sds, dim]_id, data_type, count



[Top] [Prev] [Next] [Bottom]

hdfhelp@ncsa.uiuc.edu
HDF User's Reference Manual, Draft 06/09/97, NCSA HDF Development Group.