wiki:ProgrammingTip20070806

Version 2 (modified by trac, 12 years ago) ( diff )

Programming Issue 2007-08-06


For the last few days, the MakeChomboFile function I've been working on has been writing gibberish to the "boxes" dataset for every node past the first on a given level. As it turns out, the problem had to do with a limitation of the HDF5 API. I had been constructing my dataset using the following sequence of function calls:

CALL h5pcreate_f(H5P_DATASET_XFER_F, hid_boxes_property_id, i_err)

CALL h5pset_preserve_f(hid_boxes_property_id, .TRUE., i_err)

CALL h5screate_simple_f(I_DATASET_RANK, ia_dataset_dims, hid_boxes_dataspace_id, i_err)

CALL h5dcreate_f(hid_level_group_id, "boxes", hid_box_id, hid_boxes_dataspace_id, hid_boxes_dataset_id, i_err)

Apparently datasets constructed in this fashion are supposed to be written to and then closed; when you loop over the nodes on a level and write to the grid after each pass of the loop (which is what I did), you will get one good entry for the level and nonsense data for all the others.

According to Tim might be some way of constructing an extensible dataset, but I have not been able to figure out how. In this case there was no need to figure out how, as it was easier to just dynamically allocate enough space to cache all the boxes data on a level , write it to the HDF file all at once, and then deallocate the boxes data array. Since each Box is only 24 bytes per node, it's reasonable to assume that if a cluster is capable of processing x number of grids, it's capable of caching their box data for a second or two.

Note: See TracWiki for help on using the wiki.