public void H5DcreateTest2() { hsize_t[] dims = { 10, 10, 10 }; hsize_t[] max_dims = { H5S.UNLIMITED, H5S.UNLIMITED, H5S.UNLIMITED }; hid_t space = H5S.create_simple(3, dims, max_dims); hid_t lcpl = H5P.create(H5P.LINK_CREATE); Assert.IsTrue(H5P.set_create_intermediate_group(lcpl, 1) >= 0); hid_t dcpl = H5P.create(H5P.DATASET_CREATE); Assert.IsTrue(dcpl >= 0); hsize_t[] chunk = { 64, 64, 64 }; Assert.IsTrue(H5P.set_chunk(dcpl, 3, chunk) >= 0); Assert.IsTrue(H5P.set_deflate(dcpl, 9) >= 0); hid_t dset = H5D.create(m_v0_test_file, "A/B/C", H5T.IEEE_F32BE, space, lcpl, dcpl); Assert.IsTrue(dset >= 0); Assert.IsTrue(H5D.close(dset) >= 0); dset = H5D.create(m_v2_test_file, "A/B/C", H5T.IEEE_F32BE, space, lcpl, dcpl); Assert.IsTrue(dset >= 0); Assert.IsTrue(H5D.close(dset) >= 0); Assert.IsTrue(H5P.close(dcpl) >= 0); Assert.IsTrue(H5P.close(lcpl) >= 0); Assert.IsTrue(H5S.close(space) >= 0); }
public static (long DatasetId, bool IsNew) OpenOrCreateDataset(long locationId, string datasetPath, long datasetTypeId, ulong chunkLength, ulong chunkCount, IntPtr fillValue = default) { return(IOHelper.OpenOrCreateDataset(locationId, datasetPath, datasetTypeId, () => { long dcPropertyId = -1; long lcPropertyId = -1; long dataspaceId = -1; long datasetId = -1; try { dcPropertyId = H5P.create(H5P.DATASET_CREATE); if (fillValue != IntPtr.Zero) { H5P.set_fill_value(dcPropertyId, datasetTypeId, fillValue); } H5P.set_shuffle(dcPropertyId); H5P.set_deflate(dcPropertyId, 7); H5P.set_chunk(dcPropertyId, 1, new ulong[] { chunkLength }); lcPropertyId = H5P.create(H5P.LINK_CREATE); H5P.set_create_intermediate_group(lcPropertyId, 1); dataspaceId = H5S.create_simple(1, new ulong[] { chunkLength *chunkCount }, null); datasetId = H5D.create(locationId, datasetPath, datasetTypeId, dataspaceId, lcPropertyId, dcPropertyId); if (H5I.is_valid(datasetId) <= 0) { throw new Exception($"{ ErrorMessage.IOHelper_CouldNotOpenOrCreateDataset } Dataset: '{ datasetPath }'."); } } finally { if (H5I.is_valid(dcPropertyId) > 0) { H5P.close(dcPropertyId); } if (H5I.is_valid(lcPropertyId) > 0) { H5P.close(lcPropertyId); } if (H5I.is_valid(dataspaceId) > 0) { H5S.close(dataspaceId); } } return datasetId; })); }
public static void ClassInit(TestContext testContext) { // create test files which persists across file tests m_v0_class_file = Utilities.H5TempFile(ref m_v0_class_file_name, H5F.libver_t.EARLIEST); Assert.IsTrue(m_v0_class_file >= 0); m_v2_class_file = Utilities.H5TempFile(ref m_v2_class_file_name); Assert.IsTrue(m_v2_class_file >= 0); m_lcpl = H5P.create(H5P.LINK_CREATE); Assert.IsTrue(H5P.set_create_intermediate_group(m_lcpl, 1) >= 0); m_lcpl_utf8 = H5P.copy(m_lcpl); Assert.IsTrue( H5P.set_char_encoding(m_lcpl_utf8, H5T.cset_t.UTF8) >= 0); }
public void H5GcreateTest3() { hid_t lcpl = H5P.create(H5P.LINK_CREATE); Assert.IsTrue(lcpl >= 0); Assert.IsTrue(H5P.set_create_intermediate_group(lcpl, 1) >= 0); hid_t gid = H5G.create(m_v0_test_file, "A/B/C/D/E/F/G/H", lcpl); Assert.IsTrue(gid > 0); Assert.IsTrue(H5G.close(gid) >= 0); hid_t gid1 = H5G.create(m_v2_test_file, "A/B/C/D/E/F/G/H", lcpl); Assert.IsTrue(gid1 > 0); Assert.IsTrue(H5G.close(gid1) >= 0); Assert.IsTrue(H5P.close(lcpl) >= 0); }
public static void ClassInit(TestContext testContext) { #if HDF5_VER1_10 // create test files which persists across file tests m_v3_class_file = Utilities.H5TempFileSWMR(ref m_v3_class_file_name); Assert.IsTrue(m_v3_class_file >= 0); m_lcpl = H5P.create(H5P.LINK_CREATE); Assert.IsTrue(H5P.set_create_intermediate_group(m_lcpl, 1) >= 0); m_lcpl_utf8 = H5P.copy(m_lcpl); Assert.IsTrue( H5P.set_char_encoding(m_lcpl_utf8, H5T.cset_t.UTF8) >= 0); // create a sample dataset hsize_t[] dims = { 6, 6 }; hsize_t[] maxdims = { 6, H5S.UNLIMITED }; hsize_t[] chunk_dims = { 2, 5 }; int[] cbuf = new int[36]; hid_t dsp = H5S.create_simple(2, dims, maxdims); Assert.IsTrue(dsp >= 0); hid_t dcpl = H5P.create(H5P.DATASET_CREATE); Assert.IsTrue(dcpl >= 0); Assert.IsTrue(H5P.set_chunk(dcpl, 2, chunk_dims) >= 0); hid_t dst = H5D.create(m_v3_class_file, "int6x6", H5T.NATIVE_INT, dsp, H5P.DEFAULT, dcpl); Assert.IsTrue(dst >= 0); GCHandle hnd = GCHandle.Alloc(cbuf, GCHandleType.Pinned); Assert.IsTrue(H5D.write(dst, H5T.NATIVE_INT, H5S.ALL, H5S.ALL, H5P.DEFAULT, hnd.AddrOfPinnedObject()) >= 0); hnd.Free(); Assert.IsTrue(H5D.flush(dst) >= 0); Assert.IsTrue(H5D.close(dst) >= 0); Assert.IsTrue(H5P.close(dcpl) >= 0); Assert.IsTrue(H5S.close(dsp) >= 0); #endif }
public static (long GroupId, bool IsNew) OpenOrCreateGroup(long locationId, string groupPath) { long groupId = -1; long propertyId = -1; bool isNew; try { if (IOHelper.CheckLinkExists(locationId, groupPath)) { groupId = H5G.open(locationId, groupPath); isNew = false; } else { propertyId = H5P.create(H5P.LINK_CREATE); H5P.set_create_intermediate_group(propertyId, 1); groupId = H5G.create(locationId, groupPath, propertyId); isNew = true; } if (H5I.is_valid(groupId) <= 0) { throw new Exception($"{ ErrorMessage.IOHelper_CouldNotOpenOrCreateGroup } Group name: '{ groupPath }'."); } } finally { if (H5I.is_valid(propertyId) > 0) { H5P.close(propertyId); } } return(groupId, isNew); }