The HDF_SD_REFTOINDEX function returns a scientific dataset's index given its reference number and SD interface ID.
sd_id = HDF_SDSTART('demo.hdf') ; Initialize the SD interface.
refno = 66 ; Define the reference number for which we want to search.
index = HDF_SD_REFTOINDEX(sd_id, refno) ; Return the index number.
sds_id = HDF_SD_SELECT(sd_id, index) ; Now the dataset can be accessed.
HDF_SD_IDTOREF, HDF_SD_NAMETOINDEX