I've figured out one of my problems; I didn't use *H5Tarray_create2* to
make the *dataType* argument to *H5Tinsert*.


On Thu, Jul 25, 2013 at 1:33 PM, Josiah Slack <[email protected]> wrote:

> Hi Folks -
> I've made progress on my "iteratively writing to compound datatype"
> project, but have a new question. Let me first summarize my situation. I am
> working on an application that reads messages in a variety of formats and
> presents their data to users. I am experimenting with creating compound
> datatypes to represent messages. As I'm reading messages, when I hit a new
> type, I essentially read it twice: the first time to build the datatype,
> the second time to write the data.
>
> Some of the messages contain arrays of values, and I'm not getting more
> than one element to show up in the output file. I'm hoping that if I
> describe what I'm doing, someone can spot my mistake (or mistakes).
>
> As I go through the message, when I hit an array (let's say that its name
> is *arrayField*), I create a slot for it in my compound datatype:
> *HT5insert(compoundType, "arrayField", currentOffset, dataType)*.
> I then increase currentOffset by the total size of the array (e.g. 3x4
> array of int means *currentOffset += 12*sizeof(int)*).
>
> I then skip over the remaining values in the array as I continue reading
> through the message.
>
> Once I've finished building the datatype, I start writing the values. When
> I hit *arrayField*, I set up an *offset *array, initialized to 0s. I then
> go through the following sequence:
> *valueDT = H5Tcreate(H5T_COMPOUND, dtSize);* // creating in-memory
> datatype for value
> *H5Tinsert(valueDT, "arrayField", 0, dataType);*
> *filespace = H5Dget_space(dataSet);*
> *hsize_t* count = new hsize_t[dimensions+1];* // +1 for datatype itself
> *hsize_t* stride = **new hsize_t[dimensions+1];*
> *hsize_t* block = **new hsize_t[dimensions+1];
> *
> // fill in values for count, stride and block.
> // count gets [1, dim1, dim2],
> // stride and block get [1, 1, 1]
> *H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, count, stride,
> block);*
> *H5Dwrite(dataSet, valueDT, dataSpace, filespace, H5P_DEFAULT, &value);*
>
> The next value gets read, and I use "odometer" logic on *offset*.* *In* *this
> case, the last value in the array goes from 0 to 1.  The above steps then
> get repeated.
>
> I'm most suspicious of my settings for *count*, *stride* and *block*.
> That said, I'm not overly confident about any other aspect of my approach :)
>
> -Josiah
>
>
>
>
_______________________________________________
Hdf-forum is for HDF software users discussion.
[email protected]
http://mail.lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org

Reply via email to