Previous Scientific Data Formats: Hierarchical Data Format - HDF5 Next

Example: Creating a Data File

The following example creates a simple HDF5 data file with a single sample data set. The file is created in the current working directory.

PRO ex_create_hdf5  
  
   file = filepath('hdf5_out.h5')  
   fid = H5F_CREATE(file)  
  
   ;; create data  
   data = hanning(100,150)  
  
   ;; get data type and space, needed to create the dataset  
   datatype_id = H5T_IDL_CREATE(data)  
   dataspace_id = H5S_CREATE_SIMPLE(size(data,/DIMENSIONS))  
  
   ;; create dataset in the output file  
   dataset_id = H5D_CREATE(fid,$  
      'Sample data',datatype_id,dataspace_id)  
   ;; write data to dataset  
   H5D_WRITE,dataset_id,data  
  
   ;; close all open identifiers  
   H5D_CLOSE,dataset_id    
   H5S_CLOSE,dataspace_id  
   H5T_CLOSE,datatype_id  
   H5F_CLOSE,fid  
  
END  

  IDL Online Help (March 06, 2007)