The HDF_SD_END function closes the SD interface to an HDF file. Failure to close the file without a call to HDF_SD_END results in the loss of any changed or added SD data. Therefore, HDF_SD_END calls should always be paired with calls to HDF_SD_START. Before HDF_SD_END is called, all access to SD datasets should be terminated with calls to HDF_SD_ENDACCESS.
sd_id = HDF_SD_START('test.hdf', /CREATE)
;
O;
pen a new HDF file.
... ; Various commands could now be used to access SD data in the HDF file.
HDF_SD_ENDACESS, sds_id_1 ; When done with datasets, access should be ended with calls to HDF_SD_ENDACCESS.
HDF_SD_END, sd_id ; When done with an HDF file, it should be closed.
Another example can be seen in the documentation for HDF_SD_ATTRSET.