Any number of attributes can be assigned to either a vdata or any single field in a vdata. However, each attribute name should be unique within its scope. In other words, a field attribute name must be unique among all attributes of that field, and a vdata attribute name must be unique among all attributes of the vdata it's contained in.
The field_index parameter is zero-based, and represents the ordinal location of the field within the vdata - for example, a field_index value of 4 would refer to the fifth field in the vdata. If field_index is set to _HDF_VDATA, the attribute of the specified vdata will be set to the value pointed to by values. When using either Fortran-77 version of this routine, specify a field_index value of -1 to attach an attribute to the specified vdata.
VSsetattr returns SUCCEED if successful, FAIL otherwise.
VSnattrs returns total number of attributes assigned to this vdata and its fields when successful, and FAIL otherwise
Routine Name (Fortran-77)
|
Parameter
|
Data Type
|
Description
| |
C
|
Fortran-77
| |||
VSnattrs (vsfnats)
|
vdata_id
|
int32
|
integer
|
Vdata identifier.
|
If field_index is set to _HDF_VDATA, the number of attributes attached to the vdata referred to by the value of vdata_id is returned. When using the Fortran-77 version of this routine, specify a field_index value of -1 to return the number of vdata attributes.
As with VSsetattr, if field_index is set to a zero-based integer value, it will be used as the index of the target vdata field, and the attributes attached to that field will be returned.
VSfnattrs returns number of attributes assigned to this vdata or its fields when successful, and FAIL otherwise.
Routine Name (Fortran-77)
|
Parameter
|
Data Type
|
Description
| |
C
|
Fortran-77
| |||
VSfnattrs (vsffnas)
|
vdata_id
|
int32
|
integer
|
Vdata identifier.
|
field_index
|
int32
|
integer
|
Index of the target field.
|
If field_index is set to _HDF_VDATA, the index of the attribute attached to the vdata referred to by the value of vdata_id is returned. When using the Fortran-77 version of this routine, specify a field_index value of -1 to return the vdata attribute indices.
As with VSsetattr, if field_index is set to a zero-based integer value, the value will be used as the index of the target vdata field, and the index of the attribute with the name specifiedby the attr_name parameter will be returned.
VSfindattr returns the index of the target attribute if successful, and FAIL otherwise.
The values of the attr_name, data_type, count and size parameters can be set to NULL, if the information returned by these parameters are not needed.
The field_index in VSattrinfo is the same as with the field_index parameter in VSsetattr. It can be set to either a integer field index, or _HDF_VDATA to specify the vdata referred to by vdata_id.
VSattrinfo returns SUCCEED if successful, and FAIL otherwise.
The attr_index parameter is the ordinal, zero-based (as with field_index in VSsetattr and this routine) index of the target attribute.
If field_index is set to _HDF_VDATA, the value of the attribute attached to the vdata referred to by the value of vdata_id is returned. If field_index is set to a zero-based integer value, the value will be used as the index of the target vdata field, and the attribute located at the ordinal position specified by attr_index will be returned.
VSgetattr returns SUCCEED if successful, FAIL otherwise.
VSisattr returns TRUE if the vdata is an attribute, and FALSE otherwise.
Routine Name (Fortran-77)
|
Parameter
|
Data Type
|
Description
| |
C
|
Fortran-77
| |||
VSisattr (vsfisat)
|
vdata_id
|
int32
|
integer
|
Vdata identifier.
|
C:
#include "hdf.h" #include "vg.h" #define FILE_NAME "Example3.hdf" #define VATTR_NAME "Vdata Attribute 1" #define FATTR_NAME "Field Attribute 1" main( ) { int32 file_id, vdata_ref, vdata_id, status; int32 n_vdattrs, n_fldattrs; int32 v_type, v_count, v_size, f_type, f_count, f_size; char vd_attr[6] = {`m','N','p', `S', `t', `\0'}; char vattr_buf[6]; char vattrname[30], fattrname[30]; float32 fld_attr[2] = {30.452, 5.467}; float32 fattr_buf[2]; /* Open the HDF file. */ file_id = Hopen(FILE_NAME, DFACC_RDWR, 0); /* Initialize the vdata interface. */ status = Vstart(file_id); /* Get the reference number of the target vdata. */ vdata_ref = VSfind(file_id, "Example Vdata"); /* Attach to the target vdata. */ vdata_id = VSattach(file_id, vdata_ref, "w"); /* Attach an attribute to the vdata. */ status = VSsetattr(vdata_id, _HDF_VDATA, VATTR_NAME, DFNT_CHAR,\ 6, vd_attr); /* Attach an attribute to the first field in the vdata. */ status = VSsetattr(vdata_id, 0, FATTR_NAME, DFNT_FLOAT32, 2, fld_attr); /* Get the number of attributes attached to the first field - should be 1. */ n_fldattrs = VSfnattrs(vdata_id, 0); /* Get the total number of field and vdata attributes. This should be 2. */ n_vdattrs = VSnattrs(vdata_id); /* Get information about the vdata attribute. */ status = VSattrinfo(vdata_id, _HDF_VDATA, 0, vattrname, \ &v_type, &v_count, &v_size); /* Get information about the field attribute. */ status = VSattrinfo(vdata_id, 0, 0, fattrname, &f_type, &f_count, &f_size); /* Get the vdata attribute. */ status = VSgetattr(vdata_id, _HDF_VDATA, 0, vattr_buf); /* Get the field attribute. */ status = VSgetattr(vdata_id, 0, 0, fattr_buf); /* Detach from the vdata, close the VS interface and the file. */ status = VSdetach(vdata_id); status = Vend(file_id); status = Hclose(file_id); }
PROGRAM CREATE QUERY ATTRS integer file_id, vdata_ref, vdata_id, status integer n_fldattrs, n_vdattrs integer hopen, vfstart, vsffnd, vsfatch, vsfdtch, hclose integer vfend, vsfscat, vsfsnat, vsffnas, vsfnats integer vsfainf, vsfgnat, vsfgcat integer v_type, v_count, v_size, f_type, f_count, f_size double precision fld_attr(2), fattr_buf(2) character*20 vattrname, vattr_buf character*50 filename, vd_attr, fattr_name parameter (filename = `Example3.hdf', + vattr_name = `Vdata Attribute 1', + vd_attr = `mnpst', + fattr_name = `Field Attribute 1' + ) C The following parameters are defined in hdf.inc. integer DFACC_RDWR, DFNT_CHAR, DFNT_FLOAT32, _HDF_VDATA parameter (DFACC_RDWR = 3, DFNT_CHAR = 4, DFNT_FLOAT32 = 5, + _HDF_VDATA = -1) fld_attr(1) = 30.452 fld_attr(2) = 5.467 C Open an HDF file with full access. file_id = hopen(filename, DFACC_RDWR, 0) C Initialize the VS interface. status = vfstart(file_id) C Get the reference number of the target vdata. vdata_ref = vsffnd(file_id, `Example Vdata') C Attach to the target vdata. vdata_id = vsfatch(file_id, vdata_ref, `w') C Attach an attribute to the vdata. status = vsfscat(vdata_id, _HDF_VDATA, vattr_name, + DFNT_CHAR, 5, vd_attr) C Attach an attribute to the first field of the vdata. status = vsfsnat(vdata_id, _HDF_VDATA, fattr_name, + DFNT_FLOAT32, 2, fld_attr) C Get the number of attributes attached to the first field. n_fldattrs = vsffnas(vdata_id, 0) C Get the total number of field and vdata attributes. n_vdattrs = vsfnats(vdata_id) C Get information about the vdata attribute. status = vsfainf(vdata_id, _HDF_VDATA, 0, vattrname, + v_type, v_count, v_size) C Get information about the field attribute. status = vsfainf(vdata_id, 0, 0, vattrname, f_type, + f_count, f_size) C Get the vdata attribute. status = vsfgnat(vdata_id, _HDF_VDATA, 0, vattr_buf) C Get the field attribute. status = vsfgcat(vdata_id, 0, 0, fattr_buf) C Detach from the vdata, close the VS interface and the file. status = vsfdtch(vdata_id) status = vfend(file_id) status = hclose(file_id) end