C: file_id = Hopen(filename, access. block_size); an_id = ANstart(file_id); ann_id = ANcreatef(an_id, ann_type); status = ANendaccess(ann_id); status = ANend(an_id); status = Hclose(file_id); FORTRAN: file_id = hopen(filename, access, block_size) an_id = afstart(file_id) ann_id = affcreate(an_id, ann_type) status = afendaccess(ann_id) status = afend(an_id) status = hclose(file_id)
ANstart initializes the multifile annotation interface. ANcreate and ANcreatef creates the annotation. ANendaccess terminates access to the annotation, and ANend terminates access to the multifile annotation interface.
TABLE 10K ANstart, ANcreate, ANcreatef, ANendaccess and ANend Parameter List
C: file_id = Hopen(filename, access. block_size); an_id = ANstart(file_id); ann_id = ANcreatef(an_id, ann_type); status = ANwriteann(ann_id, label, HDstrlen(label)); status = ANendaccess(ann_id); status = ANend(an_id); status = Hclose(file_id); FORTRAN: file_id = hopen(filename, access, block_size) an_id = afstart(file_id) ann_id = affcreate(an_id, ann_type) status = afwriteann(ann_id, label, ann_length) status = anendaccess(ann_id) status = afend(an_id) status = hclose(file_id)
ANwriteann has three parameters: ann_id, label and ann_length. The ann_id parameter is the identifier for the annotation to be written, the label parameter contains the annotation string and the ann_length parameter contains the length of the annotation string. The label must be a null-terminated string. In the C interface, the HDstrlen function can be used to dynamically determine the length of the label string. In either C or Fortran-77, specifying a length value different from the actual length of the label will result in the label either being truncated or null-padded accordingly.
TABLE 10L ANwriteann Parameter List
C:
#include "hdf.h" #include <string.h> main( ) { int32 file_id, an_id, ann_id, vgroup_id, ann_type; uint16 obj_tag, obj_ref; intn status; static char file_label[] = "This is a file label."; /* Create the HDF file. */ file_id = Hopen("Example6.hdf", DFACC_CREATE, 0); /* Initialize the AN interface and obtain an interface id. */ an_id = ANstart(file_id); /* Set the file annotation type to be a file label. */ ann_type = AN_FILE_LABEL; /* Create the file label and obtain an annotation id. */ ann_id = ANcreatef(an_id, ann_type); /* Write the label to the file. */ status = ANwriteann(ann_id, file_label, strlen(file_label)); /* Create a vgroup. */ status = Vstart(file_id); vgroup_id = Vattach(file_id, -1, "w"); status = Vdetach(vgroup_id); status = Vend(file_id); obj_tag = DFTAG_VG; obj_ref = 0; /* Create the data description label. */ ann_id = ANcreate(an_id, obj_tag, obj_ref, AN_DATA_DESC); /* Write the label to the file. */ status = ANwriteann(ann_id, file_label, strlen(file_label)); /* 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 CREATE A FILE LABEL integer hopen, afstart, affcreate, afendaccess, afend integer hclose, status, file_id, an_id, ann_id integer afwriteann integer*4 DFACC_CREATE, AN_FILE_LABEL parameter (DFACC_CREATE = 4, AN_FILE_LABEL = 2) character*21 file_label /"This is a file label."/ C Open the HDF file. file_id = hopen('Example6.hdf', DFACC_CREATE, 0) C Initialize the AN interface and obtain an interface id. an_id = afstart(file_id) C Use the file_id to write the label to the file. ann_id = affcreate(an_id, AN_FILE_LABEL) C Write the label to the file. status = afwriteann(ann_id, file_label, 21) 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