PRO HDF_SD_VARWRITE, HDFID, VARNAME, DATA ;+ ; NAME: ; HDF_SD_VARWRITE ; ; PURPOSE: ; Write data to a Scientific Data Set (SDS) variable in a HDF file. ; ; CATEGORY: ; HDF utilities. ; ; CALLING SEQUENCE: ; HDF_SD_VARWRITE, HDFID, VARNAME, DATA ; ; INPUTS: ; HDFID Identifier of HDF file opened by caller with HDF_SD_START ; in file creation mode. ; VARNAME Name of Scientific Data Set variable. ; DATA Variable to be written to the file. ; ; OPTIONAL INPUTS: ; None. ; ; KEYWORD PARAMETERS: ; None. ; ; OUTPUTS: ; None. ; ; OPTIONAL OUTPUTS: ; None ; ; COMMON BLOCKS: ; None ; ; SIDE EFFECTS: ; None. ; ; RESTRICTIONS: ; Requires IDL 5.0 or higher (square bracket array syntax). ; ; EXAMPLE: ; ;file = 'test.hdf' ;hdfid = hdf_sd_start(file, /create) ;hdf_sd_varwrite, hdfid, 'test array', dist(32) ;hdf_sd_end, hdfid ; ; MODIFICATION HISTORY: ; Liam.Gumley@ssec.wisc.edu ; http://cimss.ssec.wisc.edu/~gumley ; Copyright (C) 1999, 2000 Liam E. Gumley ; ; This program is free software; you can redistribute it and/or ; modify it under the terms of the GNU General Public License ; as published by the Free Software Foundation; either version 2 ; of the License, or (at your option) any later version. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; ; You should have received a copy of the GNU General Public License ; along with this program; if not, write to the Free Software ; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ;- rcs_id = '$Id$' ;- Check arguments if (n_params() ne 3) then message, 'Usage: HDF_SD_VARWRITE, HDFID, VARNAME, DATA' if (n_elements(hdfid) eq 0) then message, 'Argument HDFID is undefined' if (n_elements(varname) eq 0) then message, 'Argument VARNAME is undefined' if (n_elements(data) eq 0) then message, 'Argument DATA is undefined' ;- Get the dimensions and HDF data type for this variable dims = size(data, /dimensions) type = size(data, /type) hdf_type = hdf_idl2hdftype(type) ;- Create the SDS variable varid = hdf_sd_create(hdfid, varname, [dims], hdf_type=hdf_type) ;- Write the data hdf_sd_adddata, varid, data hdf_sd_endaccess, varid END