I am trying to emulate HDF5 table functions in IDL. I thought it would
be feasible to just follow the lines in hl/src/H5TA.c from HDF5 source
code, since tables are high level functions in HDF5. But, I'm getting
a segfault at H5D_Write line below. I wonder if anybody has an insight
on my problem.
best,
Nobuki Matsui
------------------------------------------------------------ ------------------------------------------------------------ -
FUNCTION H5TBmake_table, table_title, loc_id, dsetname, nrecords,
chunksize, data
print, "Table Title ", table_title
print, "N of Records", nrecords
; bail out if no proper args
if (n_elements(table_title) eq 0 || n_elements(loc_id) eq 0 ||
n_elements(nrecords) eq 0 || n_elements(nrecords) eq 0 ||
n_elements(dsetname) eq 0) then return, -1
datatype_id = H5T_IDL_CREATE(data) ; create a datatype object
; I was doing this manually with 20 lines of the code for a while.
sid = H5S_Create_Simple(nrecords,max_dimensions=-1) ; create a
simple dataspace
did = H5D_Create(loc_id, dsetname, datatype_id, sid,
chunk_dimensions=chunksize)
H5D_Extend,did,size(data,/dimensions)
print, "writing data"
H5D_Write, did, data
print, "Closing Dataspace"
H5S_Close, sid
H5D_Close, did
print, "All done"
END
PRO TEST_H5TBmake_table
file = 'hdf5_test_table.h5'
fid = H5F_CREATE(file)
nrecords = 100
chunk_size = 20
cat = REPLICATE({cat, name:'', Weight:0.0, Sex:"", Color:""
},nrecords) ; create an array of structures
;test = h5tbmake_table( "Cat", fid, 'Cat Stats', nrecords+1,
chunk_size, cat)
test = h5tbmake_table( "Cat", fid, 'Cat Stats', nrecords,
chunk_size, cat)
H5F_Close,fid
END
|