TABLE 10N ANselect Parameter List
The ANfileinfo routine returns either a SUCCEED or FAIL return code. These status codes are defined in the "hdf.h" header file.
|
Routine Name (Fortran-77)
|
Parameter
|
Data Type
|
Description
| |
|
C
|
Fortran-77
| |||
|
ANannlen (afannlen)
|
ann_id
|
int32
|
integer
|
Identifier of the target annotation.
|
C:
#include "hdf.h"
main( )
{
int32 file_id, an_id, ann_id, ann_idx, i, ann_length;
int32 n_file_label, n_file_desc, n_data_label, n_data_desc;
int32 status;
char *ann_buf;
/* Open the HDF file for reading. */
file_id = Hopen("Example6.hdf", DFACC_RDWR, 0);
/* Initialize the AN interface and obtain an interface id. */
an_id = ANstart(file_id);
/* Get the annotation information. */
status = ANfileinfo(an_id, &n_file_label, &n_file_desc, \
&n_data_label, &n_data_desc);
/* Get the file labels. */
for (i = 0; i < n_file_label; i++) {
/* Get the identifier for the current file label. */
ann_id = ANselect(an_id, i, AN_FILE_LABEL);
/* Get the length of the file label. */
ann_length = ANannlen(ann_id);
/* Get the length of the file label. */
ann_buf = HDmalloc(ann_length * sizeof(char));
/* Read the file label. */
status = ANreadann(ann_id, ann_buf, ann_length);
}
/* Terminate access to the annotation. */
status = ANendaccess(ann_id);
/* Terminate access to the AN interface. */
status = ANend(an_id);
/* Close the file. */
status = Hclose(file_id);
}
FORTRAN:
PROGRAM GET LABELS
integer*4 afstart, affileinfo, afselect, afendaccess, afend
integer*4 afannlen, afendaccess, afend, hopen, hclose
integer*4 status, file_id, an_id, ann_id, i
character ann_buf(50)
integer*4 DFACC_RDWR, AN_FILE_LABEL
parameter (DFACC_RDWR = 3, AN_FILE_LABEL = 2)
C Open the HDF file.
file_id = hopen('Example6.hdf', DFACC_RDWR, 0)
C Initialize the AN interface and obtain an interface id.
an_id = afstart(file_id)
C Get the annotation information.
status = affileinfo(an_id, n_file_label, n_file_desc,
+ n_data_label, n_data_desc)
C Get file label lengths.
do 10 i = 0, n_file_label
C Get the identifier for the current index.
ann_id = afselect(i, AN_FILE_LABEL)
C Get the length of the annotation for the current id.
ann_length = afannlen(ann_id)
C Read the file label.
status = afreadann(ann_id, ann_buf, ann_length)
10 continue
C Terminate access to the annotation.
status = afendaccess(ann_id)
C Terminate access to the AN interface.
status = afend(an_id)
C Close the file.
status = hclose(file_id)
end
10.13.4 Obtaining the Number of Annotations Corresponding to Given Search Criteria: ANnumann
The ANnumann routine returns the total number of annotations in the file that satisfy the search criteria supplied in the latter three parameters of the call. These parameters are: type, which is set to one of the type definitions listed in Section 10.9.2 on page 265, obj_tag, which is the tag of the object the annotation to be searched for is attached to, and obj_ref, which is the reference number of the object the annotation to be searched for is attached to. Upon unsuccessful completion ANnumann returns a FAIL status code.
TABLE 10Q ANnumann Parameter List
C:
#include "hdf.h"
main( )
{
int32 status, file_id, an_id, ann_id, ann_num;
int32 *ann_list;
uint16 obj_tag, obj_ref;
int32 annot_type;
/* Create the HDF file. */
file_id = Hopen("Example6.hdf", DFACC_RDWR, 0);
/* Initialize the AN interface and obtain an interface id. */
an_id = ANstart(file_id);
/* Set the annotation type to be a data description. */
annot_type = AN_DATA_DESC;
/* Set the tag to be a data identifier. */
obj_tag = DFTAG_DIA;
/* Set the reference number to be the first object. */
obj_ref = 0;
/* Get the number of object descriptions. */
ann_num = ANnumann(an_id, annot_type, obj_tag, obj_ref);
/* Allocate space for the annotation identifier. */
ann_list = HDmalloc(ann_num * sizeof(int32));
/* Get the list of object descriptions. */
status = ANannlist(an_id, annot_type, obj_tag, obj_ref, ann_list);
/* Terminate access to the annotation. */
status = ANendaccess(ann_id);
/* Terminate access to the AN interface. */
status = ANend(an_id);
/* Free the space allocated for the annotation identifier. */
HDfree(ann_list);
/* Close the file. */
status = Hclose(file_id);
}
FORTRAN:
PROGRAM GET DATA DESC LIST
integer hopen, afstart, affcreate, afendaccess, afend
integer hclose status, file_id, an_id, ann_id
integer annot_type, obj_tag, ann_num
integer ann_list(50)
integer*4 DFACC_CREATE, AN_DATA_DESC, DFTAG_DIA
parameter (DFACC_CREATE = 4, AN_DATA_DESC = 1,
+ DFTAG_DIA = 105)
C Open the HDF file.
file_id = hopen('Example6.hdf', DFACC_RDWR, 0)
C Initialize the AN interface and obtain an interface id.
an_id = afstart(file_id)
C Set the annotation type to be a data description.
annot_type = AN_DATA_DESC
C Set the tag to be a data identifier description.
obj_tag = DFTAG_DIA
C Set the reference number to be the first object.
obj_ref = 0
C Get the number of file labels.
ann_num = afnumann(an_id, annot_type, obj_tag, obj_ref)
C Get the list of file labels.
status = afannlist(an_id, annot_type, obj_tag, obj_ref, ann_list)
C Terminate access to the annotation.
status = afendaccess(ann_id)
C Terminate access to the AN interface.
status = afend(an_id)
C Close the file.
status = hclose(file_id)
end
10.13.6 Obtaining the Tag/Reference Number Pair From a Specified Annotation Identifiers: ANget_tagref
The ANget_tagref routine returns the tag/reference number pair of the annotation identified by the specfied annotation identifier, index and annotation type. TABLE 10S ANget_tagref Parameter List
ANid2tagref returns the tag/reference number pair if successful and FAIL (or -1) otherwise.
ANtagref2id returns the annotation identifier if successful and FAIL (or -1) otherwise.
Return values are DFTAG_FID, DFTAG_FD, DFTAG_DIL or DFTAG_DIA.
|
Routine Name (Fortran-77)
|
Parameter
|
Data Type
|
Description
| |
|
C
|
Fortran-77
| |||
|
ANatype2tag
|
tag
|
int32 *
|
integer
|
Object type.
|
Return values are AN_FILE_LABEL, AN_FILE_DESC, AN_DATA_LABEL, AN_DATA_DESC.
|
Routine Name (Fortran-77)
|
Parameter
|
Data Type
|
Description
| |
|
C
|
Fortran-77
| |||
|
ANtag2atype (aftagatype)
|
ann_type
|
uint16
|
integer
|
Annotation type.
|