C: isfirst = 1; label_length = DFANgetfidlen(file_id, isfirst); label_buffer = HDgetspace(label_length); fid_len = DFANgetfid(file_id, label_buffer, label_length, isfirst); FORTRAN: isfirst = 1 label_length = dagfidl(file_id, isfirst) fid_len = dagfid(file_id, label_buffer, label_length, isfirst)
DFANgetfidlen has two parameters: file_id and isfirst. The isfirst parameter specifies whether the first or subsequent file annotations are to be read. To read the first file label length isfirst should be set to the value 1, to sequentially step through all the remaining file labels assigned to a file isfirst should be set to 0.
10.6.2 Reading a File Description: DFANgetfdslen and DFANgetfds
The DFAN programming model for reading a file description is as follows:
C: isfirst = 1; desc_length = DFANgetfdslen(file_id, isfirst); desc_buffer = HDgetspace(desc_length); fds_len = DFANgetfds(file_id, desc_buf, desc_length, isfirst); FORTRAN: isfirst = 1 desc_length = dagfdsl(file_id, isfirst) fds_len = dagfds(file_id, desc_buf, desc_length, isfirst)
DFANgetfdslen has two parameters: file_id and isfirst. The isfirst parameter specifies whether the first or subsequent file annotations are to be read. To read the first file description length isfirst should be set to the value 1, to sequentially step through all the remaining file descriptions assigned to a file isfirst should be set to 0.
TABLE 10E DFANgetfidlen, DFANgetfid, DFANgetfdslen and DFANgetfds Parameter List
C:
#include "hdf.h"
main( )
{
int32 file_id, file_label_len;
char *file_label;
intn status;
/* Open the HDF file containing the annotation. */
file_id = Hopen("Example1.hdf", DFACC_READ, 0);
/* Determine the length of the file label. */
file_label_len = DFANgetfidlen(file_id, 1);
/* Allocated memory for the file label buffer. */
file_label = HDgetspace(file_label_len);
/* Read the file label. */
file_label_len = DFANgetfid(file_id, file_label, file_label_len, 1);
/* Close the file */
status = Hclose(file_id);
}
FORTRAN:
PROGRAM GET ANNOTATION
integer status, file_id, label_length
integer hopen, hclose, dagfidl, dagfid
character file_label(50)
integer*4 DFACC_READ
parameter(DFACC_READ = 1)
C Open the HDF file containing the file label.
file_id = hopen("Example1.hdf", DFACC_READ, 0)
C Determine the length of the file label.
label_length = dagfidl(file_id, 1)
C Read the file label.
status = dagfid(file_id, file_label, label_length, 1)
C Close the HDF file.
status = hclose(file_id)
end
10.6.3 Reading an Object Label: DFANgetlablen and DFANgetlabel
The DFAN programming model for reading a object label is as follows:
C: label_length = DFANgetlablen(filename, tag, ref); label_buf = HDgetspace(label_length); status = DFANgetlabel(filename, tag, ref, label_buf, label_length); FORTRAN: label_length = daglabl(filename, tag, ref) status = daglab(filename, tag, ref, label_buf, label_length)
DFANgetlablen returns the length of the label assigned to the object identified by the given tag/reference number pair. DFANgetlabel must be called between calls to DFANgetlablen - it is the routine that actually returns the label and prepares the API to read the next label.
10.6.4 Reading an Object Description: DFANgetdesclen and DFANgetdesc
The DFAN programming model for reading a object description is as follows:
C: desc_length = DFANgetdesclen(filename, tag, ref); desc_buf = HDgetspace(desc_length); status = DFANgetdesc(filename, tag, ref, desc_buf, desc_length); FORTRAN: label_length = dagdlen(filename, tag, ref) status = dagdesc(filename, tag, ref, desc_buf, desc_length)
DFANgetdesclen returns the length of the description assigned to the object identified by the specified tag/reference number pair. DFANgetdesc must be called between calls to DFANgetdesclen to reset the current object description to the next in the file.
TABLE 10F DFANgetlablen, DFANgetlabel, DFANgetdesc and DFANgetdesclen Parameter List
C:
#include "hdf.h"
main( )
{
intn desc_length = -1, status;
char desc[50];
int32 file_id;
uint16 tag = 0, ref = 0;
uint32 find_offset, find_length;
/* Open the file and initialize the searching parameters to 0. */
file_id = Hopen("Example1.hdf", DFACC_READ, 0);
/*
* Start a sequential forward search for the first reference
* number assigned to a scientific data set.
*/
while (Hfind(file_id, DFTAG_NDG, DFREF_WILDCARD, &tag, &ref, \
&find_offset, &find_length, DF_FORWARD) != FAIL) {
/*
* After discovering a valid reference number, check for an
* object description by returning the length of the description.
* If the inquiry fails, continue searching for the next valid
* reference number assigned to a scientific data set.
*/
if ((desc_length = DFANgetdesclen("Example1.hdf", tag, ref)) \
== FAIL)
break;
/*
* If a description exists and it will fit in the description buffer,
* print it.
*/
if (desc_length != FAIL && desc_length <= 50) {
status = DFANgetdesc("Example1.hdf", tag, ref, desc, desc_length);
printf("Description: %s\n", desc);
}
}
/* Close the file. */
status = Hclose(file_id);
}
FORTRAN: