The HDF_SD_SETEXTFILE procedure moves data values from a dataset into an external file. Only the data is moved, all other information remains in the original file. This routine can only be used with HDF version 3.3 (and later) files, not on older HDF files or NetCDF files. Data can only be moved once, and the user must keep track of the external file(s). The OFFSET keyword allows writing to an arbitrary location in the external file.
As shown in the example, when adding data to an external file SD, you must first use HDF_SD_ENDACCESS to sync the file, then reacquire the SDS ID with HDF_SD_SELECT before using HDF_SD_SETEXTFILE.
sd_id = HDF_SD_START('ext_main.hdf', /CREATE)
;
Create an HDF file.
sds_id = HDF_SD_CREATE(sd_id, 'float_findgen', [3,5], /FLOAT)
;
Add an SD.
HDF_SD_ADDDATA, sds_id, FINDGEN(3,5) ; Put some data into the SD.
HDF_SD_ENDACCESS,sds_id ; Call HDF_SD_ENDACCESS to sync the file.
sds_id = HDF_SD_SELECT(sd_id, 0) ; Reacquire the SDS_ID.
HDF_SD_SETEXTFILE, sds_id, 'findgen.hdf'
;
Move data to an external file named
findgen.hdf.
HDF_SD_GETDATA, sds_id, fout ; Retrieve data from the external file into the variable fout.
PRINT, fout ; Print the contents of fout.
HDF_SD_END , HDF_SD_ENDACCESS , HDF_SD_SELECT , HDF_SD_START