From faa3f5739e0b52d84d119791b6859fe610b76d37 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 25 Feb 1998 13:48:33 -0500 Subject: [svn-r296] Switched prefix for dataspaces from H5P to H5S --- examples/h5_chunk_read.c | 18 +- examples/h5_compound.c | 12 +- examples/h5_extend_write.c | 18 +- examples/h5_group.c | 16 +- examples/h5_read.c | 14 +- examples/h5_write.c | 6 +- src/H5D.c | 86 +-- src/H5Dprivate.h | 8 +- src/H5M.c | 6 +- src/H5Oprivate.h | 4 +- src/H5Osdspace.c | 22 +- src/H5P.c | 1294 -------------------------------------------- src/H5Pprivate.h | 126 ----- src/H5Ppublic.h | 56 -- src/H5Psimp.c | 469 ---------------- src/H5S.c | 1294 ++++++++++++++++++++++++++++++++++++++++++++ src/H5Sprivate.h | 126 +++++ src/H5Spublic.h | 56 ++ src/H5Ssimp.c | 469 ++++++++++++++++ src/H5T.c | 2 +- src/Makefile.in | 6 +- src/hdf5.h | 2 +- test/Makefile.in | 6 +- test/cmpd_dset.c | 28 +- test/dsets.c | 14 +- test/dspace.c | 2 +- test/extend.c | 14 +- test/th5p.c | 129 ----- test/th5s.c | 129 +++++ 29 files changed, 2216 insertions(+), 2216 deletions(-) delete mode 100644 src/H5P.c delete mode 100644 src/H5Pprivate.h delete mode 100644 src/H5Ppublic.h delete mode 100644 src/H5Psimp.c create mode 100644 src/H5S.c create mode 100644 src/H5Sprivate.h create mode 100644 src/H5Spublic.h create mode 100644 src/H5Ssimp.c delete mode 100644 test/th5p.c create mode 100644 test/th5s.c diff --git a/examples/h5_chunk_read.c b/examples/h5_chunk_read.c index 3460d9d..916383b 100644 --- a/examples/h5_chunk_read.c +++ b/examples/h5_chunk_read.c @@ -48,8 +48,8 @@ dataset = H5Dopen(file, DATASETNAME); */ filespace = H5Dget_space(dataset); /* Get filespace handle first. */ -rank = H5Pget_ndims(filespace); -status_n = H5Pget_dims(filespace, dims); +rank = H5Sget_ndims(filespace); +status_n = H5Sget_dims(filespace, dims); printf("dataset rank %d, dimensions %d x %d \n", rank, dims[0], dims[1]); /* @@ -73,7 +73,7 @@ printf("chunk rank %d, dimensions %d x %d \n", rank_chunk, /* * Define the memory space to read dataset. */ -memspace = H5Pcreate_simple(RANK,dims,NULL); +memspace = H5Screate_simple(RANK,dims,NULL); /* * Read dataset back and display. @@ -110,7 +110,7 @@ for (j = 0; j < dims[0]; j++) { * and read it into column array. */ col_dims[0] = 10; -memspace = H5Pcreate_simple(RANKC, col_dims, NULL); +memspace = H5Screate_simple(RANKC, col_dims, NULL); /* * Define the column (hyperslab) to read. @@ -119,7 +119,7 @@ offset[0] = 0; offset[1] = 2; count[0] = 10; count[1] = 1; -status = H5Pset_hyperslab(filespace, offset, count, NULL); +status = H5Sset_hyperslab(filespace, offset, count, NULL); status = H5Dread(dataset, H5T_NATIVE_INT, memspace, filespace, H5C_DEFAULT, column); printf("\n"); @@ -146,7 +146,7 @@ for (i = 0; i < 10; i++) { /* * Define the memory space to read a chunk. */ -memspace = H5Pcreate_simple(rank_chunk,chunk_dims,NULL); +memspace = H5Screate_simple(rank_chunk,chunk_dims,NULL); /* * Define chunk in the file (hyperslab) to read. @@ -155,7 +155,7 @@ offset[0] = 2; offset[1] = 0; count[0] = chunk_dims[0]; count[1] = chunk_dims[1]; -status = H5Pset_hyperslab(filespace, offset, count, NULL); +status = H5Sset_hyperslab(filespace, offset, count, NULL); /* * Read chunk back and display. @@ -179,8 +179,8 @@ for (j = 0; j < chunk_dims[0]; j++) { */ H5Cclose(cparms); H5Dclose(dataset); -H5Pclose(filespace); -H5Pclose(memspace); +H5Sclose(filespace); +H5Sclose(memspace); H5Fclose(file); } diff --git a/examples/h5_compound.c b/examples/h5_compound.c index 05add7d..91061cf 100644 --- a/examples/h5_compound.c +++ b/examples/h5_compound.c @@ -57,7 +57,7 @@ size_t size; /* * Create the data space. */ -space = H5Pcreate_simple(RANK, dim, NULL); +space = H5Screate_simple(RANK, dim, NULL); /* * Create the file. @@ -80,13 +80,13 @@ dataset = H5Dcreate(file, DATASETNAME, s1_tid, space, H5C_DEFAULT); /* * Wtite data to the dataset; */ -status = H5Dwrite(dataset, s1_tid, H5P_ALL, H5P_ALL, H5C_DEFAULT, s1); +status = H5Dwrite(dataset, s1_tid, H5S_ALL, H5S_ALL, H5C_DEFAULT, s1); /* * Release resources */ H5Tclose(s1_tid); -H5Pclose(space); +H5Sclose(space); H5Dclose(dataset); H5Fclose(file); @@ -109,7 +109,7 @@ status = H5Tinsert(s2_tid, "a_name", HPOFFSET(s2, a), H5T_NATIVE_INT); * Read two fields c and a from s1 dataset. Fields iin the file * are found by their names "c_name" and "a_name". */ -status = H5Dread(dataset, s2_tid, H5P_ALL, H5P_ALL, H5C_DEFAULT, s2); +status = H5Dread(dataset, s2_tid, H5S_ALL, H5S_ALL, H5C_DEFAULT, s2); /* * Display the fields @@ -134,7 +134,7 @@ status = H5Tinsert(s3_tid, "b_name", 0, H5T_NATIVE_FLOAT); /* * Read field b from s1 dataset. Field in the file is found by its name. */ -status = H5Dread(dataset, s3_tid, H5P_ALL, H5P_ALL, H5C_DEFAULT, s3); +status = H5Dread(dataset, s3_tid, H5S_ALL, H5S_ALL, H5C_DEFAULT, s3); /* * Display the field @@ -150,6 +150,6 @@ printf("\n"); H5Tclose(s2_tid); H5Tclose(s3_tid); H5Dclose(dataset); -H5Pclose(space); +H5Sclose(space); H5Fclose(file); } diff --git a/examples/h5_extend_write.c b/examples/h5_extend_write.c index 69e18ad..1d0438b 100644 --- a/examples/h5_extend_write.c +++ b/examples/h5_extend_write.c @@ -25,7 +25,7 @@ main () size_t dims2[2] = { 7, 1}; /* data2 dimensions */ size_t dims3[2] = { 2, 2}; /* data3 dimensions */ - size_t maxdims[2] = {H5P_UNLIMITED, H5P_UNLIMITED}; + size_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; size_t chunk_dims[2] ={2, 5}; size_t size[2]; int offset[2]; @@ -44,7 +44,7 @@ main () /* * Create the data space with ulimited dimensions. */ -dataspace = H5Pcreate_simple(RANK, dims, maxdims); +dataspace = H5Screate_simple(RANK, dims, maxdims); /* * Create a new file. If file exists its contents will be overwritten. @@ -77,7 +77,7 @@ status = H5Dextend (dataset, size); filespace = H5Dget_space (dataset); offset[0] = 0; offset[1] = 0; -status = H5Pset_hyperslab(filespace, offset, dims1, NULL); +status = H5Sset_hyperslab(filespace, offset, dims1, NULL); /* * Write the data to the hyperslab. @@ -99,12 +99,12 @@ status = H5Dextend (dataset, size); filespace = H5Dget_space (dataset); offset[0] = 3; offset[1] = 0; -status = H5Pset_hyperslab(filespace, offset, dims2, NULL); +status = H5Sset_hyperslab(filespace, offset, dims2, NULL); /* * Define memory space */ -dataspace = H5Pcreate_simple(RANK, dims2, NULL); +dataspace = H5Screate_simple(RANK, dims2, NULL); /* * Write the data to the hyperslab. @@ -126,12 +126,12 @@ status = H5Dextend (dataset, size); filespace = H5Dget_space (dataset); offset[0] = 0; offset[1] = 3; -status = H5Pset_hyperslab(filespace, offset, dims3, NULL); +status = H5Sset_hyperslab(filespace, offset, dims3, NULL); /* * Define memory space. */ -dataspace = H5Pcreate_simple(RANK, dims3, NULL); +dataspace = H5Screate_simple(RANK, dims3, NULL); /* * Write the data to the hyperslab. @@ -157,8 +157,8 @@ status = H5Dwrite(dataset, H5T_NATIVE_INT, dataspace, filespace, * Close/release resources. */ H5Dclose(dataset); -H5Pclose(dataspace); -H5Pclose(filespace); +H5Sclose(dataspace); +H5Sclose(filespace); H5Fclose(file); } diff --git a/examples/h5_group.c b/examples/h5_group.c index 0ff7945..303ce99 100644 --- a/examples/h5_group.c +++ b/examples/h5_group.c @@ -38,7 +38,7 @@ status = H5Gclose(dir); * Create dataspace for the character string */ size[0] = 80; -dataspace = H5Pcreate_simple(1, size, NULL); +dataspace = H5Screate_simple(1, size, NULL); /* * Create dataset "String" in the root group. @@ -58,7 +58,7 @@ H5Dclose(dataset); */ dataset = H5Dcreate(file, "/FloatData/String", H5T_NATIVE_CHAR, dataspace, H5C_DEFAULT); -H5Pclose(dataspace); +H5Sclose(dataspace); H5Dclose(dataset); /* @@ -66,10 +66,10 @@ H5Dclose(dataset); */ dims[0] = 2; dims[1] = 3; -dataspace = H5Pcreate_simple(RANK, dims, NULL); +dataspace = H5Screate_simple(RANK, dims, NULL); dataset = H5Dcreate(file, "/IntData/IntArray", H5T_NATIVE_INT, dataspace, H5C_DEFAULT); -H5Pclose(dataspace); +H5Sclose(dataspace); H5Dclose(dataset); /* @@ -92,17 +92,17 @@ status = H5Gset (file, "/FloatData"); dims[0] = 5; dims[1] = 10; -dataspace = H5Pcreate_simple(RANK, dims, NULL); +dataspace = H5Screate_simple(RANK, dims, NULL); dataset = H5Dcreate(file, "FloatArray", H5T_NATIVE_FLOAT, dataspace, H5C_DEFAULT); -H5Pclose(dataspace); +H5Sclose(dataspace); H5Dclose(dataset); dims[0] = 4; dims[1] = 6; -dataspace = H5Pcreate_simple(RANK, dims, NULL); +dataspace = H5Screate_simple(RANK, dims, NULL); dataset = H5Dcreate(file, "DoubleArray", H5T_NATIVE_DOUBLE, dataspace, H5C_DEFAULT); -H5Pclose(dataspace); +H5Sclose(dataspace); H5Dclose(dataset); /* diff --git a/examples/h5_read.c b/examples/h5_read.c index a7813c0..d95dbe2 100644 --- a/examples/h5_read.c +++ b/examples/h5_read.c @@ -66,8 +66,8 @@ size = H5Tget_size(datatype); printf(" Data size is %d \n", size); dataspace = H5Dget_space(dataset); /* dataspace handle */ -rank = H5Pget_ndims(dataspace); -status_n = H5Pget_dims(dataspace, dims_out); +rank = H5Sget_ndims(dataspace); +status_n = H5Sget_dims(dataspace, dims_out); printf("rank %d, dimensions %d x %d \n", rank, dims_out[0], dims_out[1]); /* @@ -77,7 +77,7 @@ offset[0] = 1; offset[1] = 2; count[0] = NX_SUB; count[1] = NY_SUB; -status = H5Pset_hyperslab(dataspace, offset, count, NULL); +status = H5Sset_hyperslab(dataspace, offset, count, NULL); /* * Define the memory dataspace. @@ -85,7 +85,7 @@ status = H5Pset_hyperslab(dataspace, offset, count, NULL); dimsm[0] = NX; dimsm[1] = NY; dimsm[2] = NZ ; -memspace = H5Pcreate_simple(RANK_OUT,dimsm,NULL); +memspace = H5Screate_simple(RANK_OUT,dimsm,NULL); /* * Define memory hyperslab. @@ -96,7 +96,7 @@ offset_out[2] = 0; count_out[0] = NX_SUB; count_out[1] = NY_SUB; count_out[2] = 1; -status = H5Pset_hyperslab(memspace, offset_out, count_out, NULL); +status = H5Sset_hyperslab(memspace, offset_out, count_out, NULL); /* * Read data from hyperslab in the file into the hyperslab in @@ -121,8 +121,8 @@ for (j = 0; j < NX; j++) { */ H5Tclose(datatype); H5Dclose(dataset); -H5Pclose(dataspace); -H5Pclose(memspace); +H5Sclose(dataspace); +H5Sclose(memspace); H5Fclose(file); } diff --git a/examples/h5_write.c b/examples/h5_write.c index 5d631d3..088810d 100644 --- a/examples/h5_write.c +++ b/examples/h5_write.c @@ -47,7 +47,7 @@ file = H5Fcreate(FILE, H5F_ACC_TRUNC, H5C_DEFAULT, H5C_DEFAULT); */ dimsf[0] = NX; dimsf[1] = NY; -dataspace = H5Pcreate_simple(RANK, dimsf, NULL); +dataspace = H5Screate_simple(RANK, dimsf, NULL); /* * Define datatype for the data in the file. @@ -65,13 +65,13 @@ dataset = H5Dcreate(file, DATASETNAME, datatype, dataspace, /* * Write the data to the dataset using default transfer properties. */ -status = H5Dwrite(dataset, H5T_NATIVE_INT32, H5P_ALL, H5P_ALL, +status = H5Dwrite(dataset, H5T_NATIVE_INT32, H5S_ALL, H5S_ALL, H5C_DEFAULT, data); /* * Close/release resources. */ -H5Pclose(dataspace); +H5Sclose(dataspace); H5Tclose(datatype); H5Dclose(dataset); H5Fclose(file); diff --git a/src/H5D.c b/src/H5D.c index 28a3d2e..dad5886 100644 --- a/src/H5D.c +++ b/src/H5D.c @@ -37,7 +37,7 @@ static char RcsId[] = "@(#)$Revision$"; struct H5D_t { H5G_entry_t ent; /*cached object header stuff */ H5T_t *type; /*datatype of this dataset */ - H5P_t *space; /*dataspace of this dataset */ + H5S_t *space; /*dataspace of this dataset */ H5D_create_t create_parms; /*creation parameters */ H5O_layout_t layout; /*data layout */ }; @@ -163,7 +163,7 @@ H5Dcreate(hid_t file_id, const char *name, hid_t type_id, hid_t space_id, { H5F_t *f = NULL; H5T_t *type = NULL; - H5P_t *space = NULL; + H5S_t *space = NULL; H5D_t *new_dset = NULL; hid_t ret_value = FAIL; const H5D_create_t *create_parms = NULL; @@ -317,7 +317,7 @@ H5Dclose(hid_t dataset_id) * * Return: Success: ID for a copy of the data space. The data * space should be released by calling - * H5Pclose(). + * H5Sclose(). * * Failure: FAIL * @@ -332,7 +332,7 @@ hid_t H5Dget_space (hid_t dataset_id) { H5D_t *dataset = NULL; - H5P_t *copied_space = NULL; + H5S_t *copied_space = NULL; hid_t ret_value = FAIL; FUNC_ENTER (H5Dget_space, FAIL); @@ -344,7 +344,7 @@ H5Dget_space (hid_t dataset_id) } /* Copy the data space */ - if (NULL==(copied_space=H5P_copy (dataset->space))) { + if (NULL==(copied_space=H5S_copy (dataset->space))) { HRETURN_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to copy the data space"); } @@ -468,10 +468,10 @@ H5Dget_create_parms (hid_t dataset_id) * Additional miscellaneous data transfer properties can be * passed to this function with the XFER_PARMS_ID argument. * - * The FILE_SPACE_ID can be the constant H5P_ALL which indicates + * The FILE_SPACE_ID can be the constant H5S_ALL which indicates * that the entire file data space is to be referenced. * - * The MEM_SPACE_ID can be the constant H5P_ALL in which case + * The MEM_SPACE_ID can be the constant H5S_ALL in which case * the memory data space is the same as the file data space * defined when the dataset was created. * @@ -506,8 +506,8 @@ H5Dread(hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id, { H5D_t *dataset = NULL; const H5T_t *mem_type = NULL; - const H5P_t *mem_space = NULL; - const H5P_t *file_space = NULL; + const H5S_t *mem_space = NULL; + const H5S_t *file_space = NULL; const H5D_xfer_t *xfer_parms = NULL; FUNC_ENTER(H5Dread, FAIL); @@ -522,13 +522,13 @@ H5Dread(hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id, NULL == (mem_type = H5A_object(mem_type_id))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); } - if (H5P_ALL != mem_space_id) { + if (H5S_ALL != mem_space_id) { if (H5_DATASPACE != H5A_group(mem_space_id) || NULL == (mem_space = H5A_object(mem_space_id))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); } } - if (H5P_ALL != file_space_id) { + if (H5S_ALL != file_space_id) { if (H5_DATASPACE != H5A_group(file_space_id) || NULL == (file_space = H5A_object(file_space_id))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); @@ -563,10 +563,10 @@ H5Dread(hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id, * properties can be passed to this function with the * XFER_PARMS_ID argument. * - * The FILE_SPACE_ID can be the constant H5P_ALL which indicates + * The FILE_SPACE_ID can be the constant H5S_ALL which indicates * that the entire file data space is to be referenced. * - * The MEM_SPACE_ID can be the constant H5P_ALL in which case + * The MEM_SPACE_ID can be the constant H5S_ALL in which case * the memory data space is the same as the file data space * defined when the dataset was created. * @@ -595,8 +595,8 @@ H5Dwrite(hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id, { H5D_t *dataset = NULL; const H5T_t *mem_type = NULL; - const H5P_t *mem_space = NULL; - const H5P_t *file_space = NULL; + const H5S_t *mem_space = NULL; + const H5S_t *file_space = NULL; const H5D_xfer_t *xfer_parms = NULL; FUNC_ENTER(H5Dwrite, FAIL); @@ -611,13 +611,13 @@ H5Dwrite(hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id, NULL == (mem_type = H5A_object(mem_type_id))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); } - if (H5P_ALL != mem_space_id) { + if (H5S_ALL != mem_space_id) { if (H5_DATASPACE != H5A_group(mem_space_id) || NULL == (mem_space = H5A_object(mem_space_id))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); } } - if (H5P_ALL != file_space_id) { + if (H5S_ALL != file_space_id) { if (H5_DATASPACE != H5A_group(file_space_id) || NULL == (file_space = H5A_object(file_space_id))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); @@ -737,7 +737,7 @@ H5D_find_name(hid_t file_id, group_t UNUSED, const char *name) *------------------------------------------------------------------------- */ H5D_t * -H5D_create(H5F_t *f, const char *name, const H5T_t *type, const H5P_t *space, +H5D_create(H5F_t *f, const char *name, const H5T_t *type, const H5S_t *space, const H5D_create_t *create_parms) { H5D_t *new_dset = NULL; @@ -757,7 +757,7 @@ H5D_create(H5F_t *f, const char *name, const H5T_t *type, const H5P_t *space, new_dset = H5MM_xcalloc(1, sizeof(H5D_t)); H5F_addr_undef(&(new_dset->ent.header)); new_dset->type = H5T_copy(type); - new_dset->space = H5P_copy(space); + new_dset->space = H5S_copy(space); new_dset->create_parms = *create_parms; /* @@ -769,27 +769,27 @@ H5D_create(H5F_t *f, const char *name, const H5T_t *type, const H5P_t *space, } /* Update the type and space header messages */ if (H5O_modify(&(new_dset->ent), H5O_DTYPE, 0, 0, new_dset->type) < 0 || - H5P_modify(&(new_dset->ent), new_dset->space) < 0) { + H5S_modify(&(new_dset->ent), new_dset->space) < 0) { HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "can't update type or space header messages"); } /* Total raw data size */ new_dset->layout.type = new_dset->create_parms.layout; - new_dset->layout.ndims = H5P_get_ndims(space) + 1; + new_dset->layout.ndims = H5S_get_ndims(space) + 1; assert(new_dset->layout.ndims <= NELMTS(new_dset->layout.dim)); new_dset->layout.dim[new_dset->layout.ndims - 1] = H5T_get_size(type); switch (new_dset->create_parms.layout) { case H5D_CONTIGUOUS: - if (H5P_get_dims(space, new_dset->layout.dim) < 0) { + if (H5S_get_dims(space, new_dset->layout.dim) < 0) { HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize contiguous storage"); } break; case H5D_CHUNKED: - if (new_dset->create_parms.chunk_ndims != H5P_get_ndims(space)) { + if (new_dset->create_parms.chunk_ndims != H5S_get_ndims(space)) { HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, NULL, "dimensionality of chunks doesn't match the data space"); } @@ -825,7 +825,7 @@ H5D_create(H5F_t *f, const char *name, const H5T_t *type, const H5P_t *space, if (new_dset->type) H5T_close(new_dset->type); if (new_dset->space) - H5P_close(new_dset->space); + H5S_close(new_dset->space); if (H5F_addr_defined(&(new_dset->ent.header))) { H5O_close(&(new_dset->ent)); } @@ -880,7 +880,7 @@ H5D_open(H5F_t *f, const char *name) } /* Get the type and space */ if (NULL==(dataset->type=H5O_read(&(dataset->ent), H5O_DTYPE, 0, NULL)) || - NULL==(dataset->space=H5P_read(f, &(dataset->ent)))) { + NULL==(dataset->space=H5S_read(f, &(dataset->ent)))) { HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to load type or space info from dataset header"); } @@ -928,7 +928,7 @@ H5D_open(H5F_t *f, const char *name) if (dataset->type) H5T_close(dataset->type); if (dataset->space) - H5P_close(dataset->space); + H5S_close(dataset->space); dataset->ent.file = NULL; H5MM_xfree(dataset); } @@ -972,7 +972,7 @@ H5D_close(H5D_t *dataset) * these fails, so we just continue. */ free_failed = (H5T_close(dataset->type) < 0 || - H5P_close(dataset->space) < 0); + H5S_close(dataset->space) < 0); /* Close the dataset object */ H5O_close(&(dataset->ent)); @@ -1012,8 +1012,8 @@ H5D_close(H5D_t *dataset) *------------------------------------------------------------------------- */ herr_t -H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space, - const H5P_t *file_space, const H5D_xfer_t *xfer_parms, +H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, + const H5S_t *file_space, const H5D_xfer_t *xfer_parms, void *buf/*out*/) { size_t nelmts ; /*number of elements */ @@ -1021,8 +1021,8 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space, uint8 *bkg_buf = NULL; /*background buffer */ H5T_conv_t tconv_func = NULL; /*conversion function */ hid_t src_id = -1, dst_id = -1;/*temporary type atoms */ - const H5P_conv_t *sconv_func = NULL; /*space conversion funcs*/ - H5P_number_t numbering; /*element numbering info*/ + const H5S_conv_t *sconv_func = NULL; /*space conversion funcs*/ + H5S_number_t numbering; /*element numbering info*/ H5T_cdata_t *cdata = NULL; /*type conversion data */ herr_t ret_value = FAIL; @@ -1054,7 +1054,7 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space, HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest data types"); } - if (NULL==(sconv_func=H5P_find (mem_space, file_space))) { + if (NULL==(sconv_func=H5S_find (mem_space, file_space))) { HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert from file to memory data space"); } @@ -1066,7 +1066,7 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space, } else { HDmemset (&numbering, 0, sizeof numbering); } - if (H5P_get_npoints (mem_space)!=H5P_get_npoints (file_space)) { + if (H5S_get_npoints (mem_space)!=H5S_get_npoints (file_space)) { HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "src and dest data spaces have different sizes"); } @@ -1074,7 +1074,7 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space, /* * Compute the size of the request and allocate scratch buffers. */ - nelmts = H5P_get_npoints(mem_space); + nelmts = H5S_get_npoints(mem_space); #ifndef LATER /* * Note: this prototype version allocates a buffer large enough to @@ -1155,8 +1155,8 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space, *------------------------------------------------------------------------- */ herr_t -H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space, - const H5P_t *file_space, const H5D_xfer_t *xfer_parms, +H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, + const H5S_t *file_space, const H5D_xfer_t *xfer_parms, const void *buf) { size_t nelmts; @@ -1164,8 +1164,8 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space, uint8 *bkg_buf = NULL; /*background buffer */ H5T_conv_t tconv_func = NULL; /*conversion function */ hid_t src_id = -1, dst_id = -1;/*temporary type atoms */ - const H5P_conv_t *sconv_func = NULL; /*space conversion funcs*/ - H5P_number_t numbering; /*element numbering info*/ + const H5S_conv_t *sconv_func = NULL; /*space conversion funcs*/ + H5S_number_t numbering; /*element numbering info*/ H5T_cdata_t *cdata = NULL; /*type conversion data */ herr_t ret_value = FAIL; @@ -1197,7 +1197,7 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space, HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest data types"); } - if (NULL==(sconv_func=H5P_find (mem_space, file_space))) { + if (NULL==(sconv_func=H5S_find (mem_space, file_space))) { HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unable to convert from memory to file data space"); } @@ -1209,7 +1209,7 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space, } else { HDmemset (&numbering, 0, sizeof numbering); } - if (H5P_get_npoints (mem_space)!=H5P_get_npoints (file_space)) { + if (H5S_get_npoints (mem_space)!=H5S_get_npoints (file_space)) { HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "src and dest data spaces have different sizes"); } @@ -1217,7 +1217,7 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space, /* * Compute the size of the request and allocate scratch buffers. */ - nelmts = H5P_get_npoints(mem_space); + nelmts = H5S_get_npoints(mem_space); #ifndef LATER /* * Note: This prototype version allocates a buffer large enough to @@ -1314,14 +1314,14 @@ H5D_extend (H5D_t *dataset, const size_t *size) } /* Increase the size of the data space */ - if ((changed=H5P_extend (dataset->space, size))<0) { + if ((changed=H5S_extend (dataset->space, size))<0) { HRETURN_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to increase size of data space"); } /* Save the new dataspace in the file if necessary */ if (changed>0 && - H5P_modify (&(dataset->ent), dataset->space)<0) { + H5S_modify (&(dataset->ent), dataset->space)<0) { HRETURN_ERROR (H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update file with new dataspace"); } diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h index 840b462..d4360d4 100644 --- a/src/H5Dprivate.h +++ b/src/H5Dprivate.h @@ -23,7 +23,7 @@ #include /*for the H5F_t type */ #include /*symbol tables */ #include /*for the H5T_t type */ -#include /*for the H5P_t type */ +#include /*for the H5S_t type */ #include /*object Headers */ #define H5D_RESERVED_ATOMS 0 @@ -48,14 +48,14 @@ extern const H5D_xfer_t H5D_xfer_dflt; /* Functions defined in H5D.c */ H5D_t *H5D_create (H5F_t *f, const char *name, const H5T_t *type, - const H5P_t *space, const H5D_create_t *create_parms); + const H5S_t *space, const H5D_create_t *create_parms); H5D_t *H5D_open (H5F_t *f, const char *name); herr_t H5D_close (H5D_t *dataset); herr_t H5D_read (H5D_t *dataset, const H5T_t *mem_type, - const H5P_t *mem_space, const H5P_t *file_space, + const H5S_t *mem_space, const H5S_t *file_space, const H5D_xfer_t *xfer_parms, void *buf/*out*/); herr_t H5D_write (H5D_t *dataset, const H5T_t *mem_type, - const H5P_t *mem_space, const H5P_t *file_space, + const H5S_t *mem_space, const H5S_t *file_space, const H5D_xfer_t *xfer_parms, const void *buf); hid_t H5D_find_name (hid_t file_id, group_t UNUSED, const char *name); herr_t H5D_extend (H5D_t *dataset, const size_t *size); diff --git a/src/H5M.c b/src/H5M.c index a9dc02b..e805248 100644 --- a/src/H5M.c +++ b/src/H5M.c @@ -48,7 +48,7 @@ static char RcsId[] = "@(#)$Revision$"; #include /* Template interface */ #include /* Dataset interface */ #include /*error handling */ -#include /* Dataspace functions */ +#include /* Dataspace functions */ #include /* Datatype interface */ #include /* Meta-object interface */ #include /* Template interface */ @@ -110,7 +110,7 @@ static meta_func_t meta_func_arr[] = NULL, /* Datatype GetFile */ H5Tclose /* Datatype Release */ }, - { /* Dimensionality object meta-functions (defined in H5P.c) */ + { /* Dimensionality object meta-functions (defined in H5S.c) */ H5_DATASPACE, /* Dimensionality Type ID */ NULL, /* Dimensionality Create */ NULL, /* Dimensionality Access */ @@ -125,7 +125,7 @@ static meta_func_t meta_func_arr[] = NULL, /* Dimensionality Delete */ NULL, /* Dimensionality GetParent */ NULL, /* Dimensionality GetFile */ - H5Pclose /* Dimensionality Release */ + H5Sclose /* Dimensionality Release */ }, { /* Dataset object meta-functions (defined in H5D.c) */ H5_DATASET, /* Dataset Type ID */ diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 0cd671a..0d3b2f7 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -24,7 +24,7 @@ #include #include #include -#include +#include /* * Align messages on 8-byte boundaries because we would like to copy the @@ -116,7 +116,7 @@ extern const H5O_class_t H5O_NULL[1]; #define H5O_SDSPACE_ID 0x0001 extern const H5O_class_t H5O_SDSPACE[1]; -/* operates on an H5P_simple_t struct */ +/* operates on an H5S_simple_t struct */ /* * Data Type Message. diff --git a/src/H5Osdspace.c b/src/H5Osdspace.c index 561eb5a..7957122 100644 --- a/src/H5Osdspace.c +++ b/src/H5Osdspace.c @@ -37,7 +37,7 @@ static herr_t H5O_sdspace_debug(H5F_t *f, const void *_mesg, const H5O_class_t H5O_SDSPACE[1] = {{ H5O_SDSPACE_ID, /* message id number */ "simple_dspace", /* message name for debugging */ - sizeof(H5P_simple_t), /* native message size */ + sizeof(H5S_simple_t), /* native message size */ H5O_sdspace_decode, /* decode message */ H5O_sdspace_encode, /* encode message */ H5O_sdspace_copy, /* copy the native value */ @@ -71,7 +71,7 @@ static hbool_t interface_initialize_g = FALSE; static void * H5O_sdspace_decode(H5F_t *f, size_t raw_size, const uint8 *p) { - H5P_simple_t *sdim = NULL;/* New simple dimensionality structure */ + H5S_simple_t *sdim = NULL;/* New simple dimensionality structure */ uintn u; /* local counting variable */ uintn flags; @@ -83,7 +83,7 @@ H5O_sdspace_decode(H5F_t *f, size_t raw_size, const uint8 *p) assert(p); /* decode */ - if ((sdim = H5MM_xcalloc(1, sizeof(H5P_simple_t))) != NULL) { + if ((sdim = H5MM_xcalloc(1, sizeof(H5S_simple_t))) != NULL) { UINT32DECODE(p, sdim->rank); UINT32DECODE(p, flags); if (sdim->rank > 0) { @@ -133,7 +133,7 @@ H5O_sdspace_decode(H5F_t *f, size_t raw_size, const uint8 *p) static herr_t H5O_sdspace_encode(H5F_t *f, size_t raw_size, uint8 *p, const void *mesg) { - const H5P_simple_t *sdim = (const H5P_simple_t *) mesg; + const H5S_simple_t *sdim = (const H5S_simple_t *) mesg; uintn u; /* Local counting variable */ uintn flags = 0; @@ -185,18 +185,18 @@ H5O_sdspace_encode(H5F_t *f, size_t raw_size, uint8 *p, const void *mesg) static void * H5O_sdspace_copy(const void *mesg, void *dest) { - const H5P_simple_t *src = (const H5P_simple_t *) mesg; - H5P_simple_t *dst = (H5P_simple_t *) dest; + const H5S_simple_t *src = (const H5S_simple_t *) mesg; + H5S_simple_t *dst = (H5S_simple_t *) dest; FUNC_ENTER(H5O_sdspace_copy, NULL); /* check args */ assert(src); if (!dst) - dst = H5MM_xcalloc(1, sizeof(H5P_simple_t)); + dst = H5MM_xcalloc(1, sizeof(H5S_simple_t)); /* deep copy -- pointed-to values are copied also */ - HDmemcpy(dst, src, sizeof(H5P_simple_t)); + HDmemcpy(dst, src, sizeof(H5S_simple_t)); if (src->size) { dst->size = H5MM_xcalloc(src->rank, sizeof(src->size[0])); @@ -233,7 +233,7 @@ H5O_sdspace_copy(const void *mesg, void *dest) static size_t H5O_sdspace_size(H5F_t *f, const void *mesg) { - const H5P_simple_t *sdim = (const H5P_simple_t *) mesg; + const H5S_simple_t *sdim = (const H5S_simple_t *) mesg; size_t ret_value = 8; /* all dimensionality messages are at least 8 bytes long (rank and flags) */ FUNC_ENTER(H5O_sim_dtype_size, FAIL); @@ -267,7 +267,7 @@ static herr_t H5O_sdspace_debug(H5F_t *f, const void *mesg, FILE * stream, intn indent, intn fwidth) { - const H5P_simple_t *sdim = (const H5P_simple_t *) mesg; + const H5S_simple_t *sdim = (const H5S_simple_t *) mesg; uintn u; /* local counting variable */ FUNC_ENTER(H5O_sdspace_debug, FAIL); @@ -293,7 +293,7 @@ H5O_sdspace_debug(H5F_t *f, const void *mesg, FILE * stream, if (sdim->max) { fprintf (stream, "{"); for (u = 0; u < sdim->rank; u++) { - if (H5P_UNLIMITED==sdim->max[u]) { + if (H5S_UNLIMITED==sdim->max[u]) { fprintf (stream, "%sINF", u?", ":""); } else { fprintf (stream, "%s%lu\n", u?", ":"", diff --git a/src/H5P.c b/src/H5P.c deleted file mode 100644 index 2d39edf..0000000 --- a/src/H5P.c +++ /dev/null @@ -1,1294 +0,0 @@ -/**************************************************************************** -* NCSA HDF * -* Software Development Group * -* National Center for Supercomputing Applications * -* University of Illinois at Urbana-Champaign * -* 605 E. Springfield, Champaign IL 61820 * -* * -* For conditions of distribution and use, see the accompanying * -* hdf/COPYING file. * -* * -****************************************************************************/ - -#ifdef RCSID -static char RcsId[] = "@(#)$Revision$"; -#endif - -/* $Id$ */ - -#include /* Generic Functions */ -#include /* Atom Functions */ -#include /* Error handling */ -#include /* Memory Management functions */ -#include /*object headers */ -#include /* Data-space functions */ - -/* Interface initialization */ -#define PABLO_MASK H5P_mask -#define INTERFACE_INIT H5P_init_interface -static intn interface_initialize_g = FALSE; -static herr_t H5P_init_interface(void); -static void H5P_term_interface(void); - - -/*-------------------------------------------------------------------------- -NAME - H5P_init_interface -- Initialize interface-specific information -USAGE - herr_t H5P_init_interface() - -RETURNS - SUCCEED/FAIL -DESCRIPTION - Initializes any interface-specific data or routines. - ---------------------------------------------------------------------------*/ -static herr_t -H5P_init_interface(void) -{ - herr_t ret_value = SUCCEED; - FUNC_ENTER(H5P_init_interface, FAIL); - - /* Initialize the atom group for the file IDs */ - if ((ret_value = H5A_init_group(H5_DATASPACE, H5A_DATASPACEID_HASHSIZE, - H5P_RESERVED_ATOMS, - (herr_t (*)(void *)) H5P_close)) != FAIL) { - ret_value = H5_add_exit(&H5P_term_interface); - } - FUNC_LEAVE(ret_value); -} - - -/*-------------------------------------------------------------------------- - NAME - H5P_term_interface - PURPOSE - Terminate various H5P objects - USAGE - void H5P_term_interface() - RETURNS - SUCCEED/FAIL - DESCRIPTION - Release the atom group and any other resources allocated. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - Can't report errors... - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -static void -H5P_term_interface(void) -{ - H5A_destroy_group(H5_DATASPACE); -} - -/*------------------------------------------------------------------------- - * Function: H5Pcreate_simple - * - * Purpose: Creates a new simple data space object and opens it for - * access. The DIMS argument is the size of the simple dataset - * and the MAXDIMS argument is the upper limit on the size of - * the dataset. MAXDIMS may be the null pointer in which case - * the upper limit is the same as DIMS. If an element of - * MAXDIMS is zero then the corresponding dimension is unlimited, - * otherwise no element of MAXDIMS should be smaller than the - * corresponding element of DIMS. - * - * Return: Success: The ID for the new simple data space object. - * - * Failure: FAIL - * - * Errors: - * - * Programmer: Quincey Koziol - * Tuesday, January 27, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -hid_t -H5Pcreate_simple(int rank, const size_t *dims, const size_t *maxdims) -{ - H5P_t *ds = NULL; - hid_t ret_value = FAIL; - int i; - - FUNC_ENTER(H5Pcreate, FAIL); - - /* Check arguments */ - if (rank<0) { - HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, - "dimensionality cannot be negative"); - } - if (!dims) { - HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, - "no dimensions specified"); - } - if (maxdims) { - for (i=0; i0) /* for creating simple dataspace */ - { -#endif /* LATER */ - ds->type = H5P_SIMPLE; - ds->hslab_def = FALSE; /* no hyperslab defined currently */ - - /* Initialize rank and dimensions */ - ds->u.simple.rank = rank; - - ds->u.simple.size = H5MM_xcalloc(1, rank*sizeof(size_t)); - HDmemcpy(ds->u.simple.size, dims, rank*sizeof(size_t)); - - if (maxdims) { - ds->u.simple.max = H5MM_xcalloc(1, rank*sizeof(size_t)); - HDmemcpy (ds->u.simple.max, maxdims, rank*sizeof(size_t)); - } -#ifdef LATER /* QAK */ - } /* end if */ - else /* rank==0, for scalar data space */ - { - ds->type = H5P_SCALAR; - } /* end else */ -#endif /* LATER */ - - /* Register the new data space and get an ID for it */ - if ((ret_value = H5A_register(H5_DATASPACE, ds)) < 0) { - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, - "unable to register data space for ID"); - } - - done: - if (ret_value < 0) { - H5MM_xfree(ds); - } - FUNC_LEAVE(ret_value); -} - -/*------------------------------------------------------------------------- - * Function: H5Pclose - * - * Purpose: Release access to a data space object. - * - * Return: Success: SUCCEED - * - * Failure: FAIL - * - * Errors: - * - * Programmer: Robb Matzke - * Tuesday, December 9, 1997 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -herr_t -H5Pclose(hid_t space_id) -{ - FUNC_ENTER(H5Pclose, FAIL); - - /* Check args */ - if (H5_DATASPACE != H5A_group(space_id) || - NULL == H5A_object(space_id)) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); - } - /* When the reference count reaches zero the resources are freed */ - if (H5A_dec_ref(space_id) < 0) { - HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "problem freeing id"); - } - FUNC_LEAVE(SUCCEED); -} - -/*------------------------------------------------------------------------- - * Function: H5P_close - * - * Purpose: Releases all memory associated with a data space. - * - * Return: Success: SUCCEED - * - * Failure: FAIL - * - * Programmer: Robb Matzke - * Tuesday, December 9, 1997 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -herr_t -H5P_close(H5P_t *ds) -{ - FUNC_ENTER(H5P_close, FAIL); - - assert(ds); - - switch (ds->type) { - case H5P_SCALAR: - /*void */ - break; - - case H5P_SIMPLE: - H5MM_xfree(ds->u.simple.size); - H5MM_xfree(ds->u.simple.max); - H5MM_xfree(ds->u.simple.perm); - break; - - case H5P_COMPLEX: - /* nothing */ - break; - - default: - assert("unknown data space type" && 0); - break; - } - if(ds->hslab_def==TRUE) { - H5MM_xfree(ds->h.start); - H5MM_xfree(ds->h.count); - H5MM_xfree(ds->h.stride); - } /* end if */ - H5MM_xfree(ds); - - FUNC_LEAVE(SUCCEED); -} - -/*------------------------------------------------------------------------- - * Function: H5Pcopy - * - * Purpose: Copies a dataspace. - * - * Return: Success: ID of the new dataspace - * - * Failure: FAIL - * - * Programmer: Robb Matzke - * Friday, January 30, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -hid_t -H5Pcopy (hid_t space_id) -{ - H5P_t *src = NULL; - H5P_t *dst = NULL; - hid_t ret_value = FAIL; - - FUNC_ENTER (H5Pcopy, FAIL); - - /* Check args */ - if (H5_DATASPACE!=H5A_group (space_id) || - NULL==(src=H5A_object (space_id))) { - HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); - } - - /* Copy */ - if (NULL==(dst=H5P_copy (src))) { - HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, - "unable to copy data space"); - } - - /* Atomize */ - if ((ret_value=H5A_register (H5_DATASPACE, dst))<0) { - HRETURN_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL, - "unable to register data space atom"); - } - - FUNC_LEAVE (ret_value); -} - - -/*------------------------------------------------------------------------- - * Function: H5P_copy - * - * Purpose: Copies a data space. - * - * Return: Success: A pointer to a new copy of SRC - * - * Failure: NULL - * - * Programmer: Robb Matzke - * Thursday, December 4, 1997 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -H5P_t * -H5P_copy(const H5P_t *src) -{ - H5P_t *dst = NULL; - int i; - - FUNC_ENTER(H5P_copy, NULL); - - dst = H5MM_xmalloc(sizeof(H5P_t)); - *dst = *src; - - switch (dst->type) { - case H5P_SCALAR: - /*void */ - break; - - case H5P_SIMPLE: - if (dst->u.simple.size) { - dst->u.simple.size = H5MM_xmalloc(dst->u.simple.rank * - sizeof(dst->u.simple.size[0])); - for (i = 0; i < dst->u.simple.rank; i++) { - dst->u.simple.size[i] = src->u.simple.size[i]; - } - } - if (dst->u.simple.max) { - dst->u.simple.max = H5MM_xmalloc(dst->u.simple.rank * - sizeof(dst->u.simple.max[0])); - for (i = 0; i < dst->u.simple.rank; i++) { - dst->u.simple.max[i] = src->u.simple.max[i]; - } - } - if (dst->u.simple.perm) { - dst->u.simple.perm = H5MM_xmalloc(dst->u.simple.rank * - sizeof(dst->u.simple.perm[0])); - for (i = 0; i < dst->u.simple.rank; i++) { - dst->u.simple.perm[i] = src->u.simple.perm[i]; - } - } - break; - - case H5P_COMPLEX: - /*void */ - break; - - default: - assert("unknown data space type" && 0); - break; - } - - FUNC_LEAVE(dst); -} - -/*------------------------------------------------------------------------- - * Function: H5Pget_npoints - * - * Purpose: Determines how many data points a data set has. - * - * Return: Success: Number of data points in the data set. - * - * Failure: 0 - * - * Programmer: Robb Matzke - * Tuesday, December 9, 1997 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -size_t -H5Pget_npoints(hid_t space_id) -{ - H5P_t *ds = NULL; - size_t ret_value = 0; - - FUNC_ENTER(H5Pget_npoints, 0); - - /* Check args */ - if (H5_DATASPACE != H5A_group(space_id) || - NULL == (ds = H5A_object(space_id))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a data space"); - } - ret_value = H5P_get_npoints(ds); - - FUNC_LEAVE(ret_value); -} - -/*------------------------------------------------------------------------- - * Function: H5P_get_npoints - * - * Purpose: Determines how many data points a data set has. - * - * Return: Success: Number of data points in the data set. - * - * Failure: 0 - * - * Programmer: Robb Matzke - * Tuesday, December 9, 1997 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -size_t -H5P_get_npoints(const H5P_t *ds) -{ - size_t ret_value = 0; - intn i; - - FUNC_ENTER(H5P_get_npoints, 0); - - /* check args */ - assert(ds); - - switch (ds->type) { - case H5P_SCALAR: - ret_value = 1; - break; - - case H5P_SIMPLE: - /* - * Count the elements selected by the hypeslab if there is one, - * otherwise count all the elements. - */ - if (ds->hslab_def) { - for (ret_value=1, i=0; iu.simple.rank; i++) { - ret_value *= ds->h.count[i]; - } - } else { - for (ret_value=1, i=0; iu.simple.rank; i++) { - ret_value *= ds->u.simple.size[i]; - } - } - break; - - case H5P_COMPLEX: - HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, 0, - "complex data spaces are not supported yet"); - - default: - assert("unknown data space class" && 0); - HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, 0, - "internal error (unknown data space class)"); - } - - FUNC_LEAVE(ret_value); -} - -/*------------------------------------------------------------------------- - * Function: H5Pget_ndims - * - * Purpose: Determines the dimensionality of a data space. - * - * Return: Success: The number of dimensions in a data space. - * - * Failure: FAIL - * - * Programmer: Robb Matzke - * Thursday, December 11, 1997 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -int -H5Pget_ndims(hid_t space_id) -{ - H5P_t *ds = NULL; - intn ret_value = 0; - - FUNC_ENTER(H5Pget_ndims, FAIL); - - /* Check args */ - if (H5_DATASPACE != H5A_group(space_id) || - NULL == (ds = H5A_object(space_id))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); - } - ret_value = H5P_get_ndims(ds); - - FUNC_LEAVE(ret_value); -} - -/*------------------------------------------------------------------------- - * Function: H5P_get_ndims - * - * Purpose: Returns the number of dimensions in a data space. - * - * Return: Success: Non-negative number of dimensions. Zero - * implies a scalar. - * - * Failure: FAIL - * - * Programmer: Robb Matzke - * Thursday, December 11, 1997 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -intn -H5P_get_ndims(const H5P_t *ds) -{ - intn ret_value = FAIL; - - FUNC_ENTER(H5P_get_ndims, FAIL); - - /* check args */ - assert(ds); - - switch (ds->type) { - case H5P_SCALAR: - ret_value = 0; - break; - - case H5P_SIMPLE: - ret_value = ds->u.simple.rank; - break; - - case H5P_COMPLEX: - HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, - "complex data spaces are not supported yet"); - - default: - assert("unknown data space class" && 0); - HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, - "internal error (unknown data space class)"); - } - - FUNC_LEAVE(ret_value); -} - -/*------------------------------------------------------------------------- - * Function: H5Pget_dims - * - * Purpose: Returns the size in each dimension of a data space DS through - * the DIMS argument. - * - * Return: Success: Number of dimensions, the same value as - * returned by H5Pget_ndims(). - * - * Failure: FAIL - * - * Programmer: Robb Matzke - * Thursday, December 11, 1997 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -int -H5Pget_dims(hid_t space_id, size_t dims[]/*out*/) -{ - - H5P_t *ds = NULL; - intn ret_value = 0; - - FUNC_ENTER(H5Pget_dims, FAIL); - - /* Check args */ - if (H5_DATASPACE != H5A_group(space_id) || - NULL == (ds = H5A_object(space_id))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); - } - if (!dims) { - HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer"); - } - ret_value = H5P_get_dims(ds, dims); - - FUNC_LEAVE(ret_value); -} - -/*------------------------------------------------------------------------- - * Function: H5P_get_dims - * - * Purpose: Returns the size in each dimension of a data space. This - * function may not be meaningful for all types of data spaces. - * - * Return: Success: Number of dimensions. Zero implies scalar. - * - * Failure: FAIL - * - * Programmer: Robb Matzke - * Thursday, December 11, 1997 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -intn -H5P_get_dims(const H5P_t *ds, size_t dims[]) -{ - intn ret_value = FAIL; - intn i; - - FUNC_ENTER(H5P_get_dims, FAIL); - - /* check args */ - assert(ds); - assert(dims); - - switch (ds->type) { - case H5P_SCALAR: - ret_value = 0; - break; - - case H5P_SIMPLE: - ret_value = ds->u.simple.rank; - for (i = 0; i < ret_value; i++) { - dims[i] = ds->u.simple.size[i]; - } - break; - - case H5P_COMPLEX: - HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, - "complex data spaces are not supported yet"); - - default: - assert("unknown data space class" && 0); - HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, - "internal error (unknown data space class)"); - } - - FUNC_LEAVE(ret_value); -} - -/*------------------------------------------------------------------------- - * Function: H5P_modify - * - * Purpose: Updates a data space by writing a message to an object - * header. - * - * Return: Success: SUCCEED - * - * Failure: FAIL - * - * Programmer: Robb Matzke - * Tuesday, December 9, 1997 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -herr_t -H5P_modify(H5G_entry_t *ent, const H5P_t *ds) -{ - FUNC_ENTER(H5P_modify, FAIL); - - assert(ent); - assert(ds); - - switch (ds->type) { - case H5P_SCALAR: - HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, - "scalar data spaces are not implemented yet"); - - case H5P_SIMPLE: - if (H5O_modify(ent, H5O_SDSPACE, 0, 0, &(ds->u.simple)) < 0) { - HRETURN_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, - "can't update simple data space message"); - } - break; - - case H5P_COMPLEX: - HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, - "complex data spaces are not implemented yet"); - - default: - assert("unknown data space class" && 0); - break; - } - - FUNC_LEAVE(SUCCEED); -} - -/*------------------------------------------------------------------------- - * Function: H5P_read - * - * Purpose: Reads the data space from an object header. - * - * Return: Success: Pointer to a new data space. - * - * Failure: NULL - * - * Programmer: Robb Matzke - * Tuesday, December 9, 1997 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -H5P_t * -H5P_read(H5F_t *f, H5G_entry_t *ent) -{ - H5P_t *ds = NULL; - - FUNC_ENTER(H5P_read, NULL); - - /* check args */ - assert(f); - assert(ent); - - ds = H5MM_xcalloc(1, sizeof(H5P_t)); - - if (H5O_read(ent, H5O_SDSPACE, 0, &(ds->u.simple))) { - ds->type = H5P_SIMPLE; - - } else { - ds->type = H5P_SCALAR; - } - - FUNC_LEAVE(ds); -} - -/*------------------------------------------------------------------------- - * Function: H5P_cmp - * - * Purpose: Compares two data spaces. - * - * Return: Success: 0 if DS1 and DS2 are the same. - * <0 if DS1 is less than DS2. - * >0 if DS1 is greater than DS2. - * - * Failure: 0, never fails - * - * Programmer: Robb Matzke - * Wednesday, December 10, 1997 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -intn -H5P_cmp(const H5P_t *ds1, const H5P_t *ds2) -{ - intn i; - - FUNC_ENTER(H5P_cmp, 0); - - /* check args */ - assert(ds1); - assert(ds2); - - /* compare */ - if (ds1->type < ds2->type) - HRETURN(-1); - if (ds1->type > ds2->type) - HRETURN(1); - - switch (ds1->type) { - case H5P_SIMPLE: - if (ds1->u.simple.rank < ds2->u.simple.rank) - HRETURN(-1); - if (ds1->u.simple.rank > ds2->u.simple.rank) - HRETURN(1); - - for (i = 0; i < ds1->u.simple.rank; i++) { - if (ds1->u.simple.size[i] < ds2->u.simple.size[i]) - HRETURN(-1); - if (ds1->u.simple.size[i] > ds2->u.simple.size[i]) - HRETURN(1); - } - - /* don't compare max dimensions */ - - for (i = 0; i < ds1->u.simple.rank; i++) { - if ((ds1->u.simple.perm ? ds1->u.simple.perm[i] : i) < - (ds2->u.simple.perm ? ds2->u.simple.perm[i] : i)) - HRETURN(-1); - if ((ds1->u.simple.perm ? ds2->u.simple.perm[i] : i) > - (ds2->u.simple.perm ? ds2->u.simple.perm[i] : i)) - HRETURN(1); - } - - /* Check if we should compare hyperslab definitions */ - if(ds1->hslab_def==TRUE && ds2->hslab_def==TRUE) { - for (i = 0; i < ds1->u.simple.rank; i++) { - if (ds1->h.start[i] < ds2->h.start[i]) - HRETURN(-1); - if (ds1->h.start[i] > ds2->h.start[i]) - HRETURN(1); - if (ds1->h.count[i] < ds2->h.count[i]) - HRETURN(-1); - if (ds1->h.count[i] > ds2->h.count[i]) - HRETURN(1); - if (ds1->h.stride[i] < ds2->h.stride[i]) - HRETURN(-1); - if (ds1->h.stride[i] > ds2->h.stride[i]) - HRETURN(1); - } - } else { - if(ds1->hslab_def!=ds2->hslab_def) - HRETURN(ds1->hslab_def==TRUE ? 1 : -1); - } - - break; - - default: - assert("not implemented yet" && 0); - } - - FUNC_LEAVE(0); -} - - -/*-------------------------------------------------------------------------- - NAME - H5P_is_simple - PURPOSE - Check if a dataspace is simple (internal) - USAGE - hbool_t H5P_is_simple(sdim) - H5P_t *sdim; IN: Pointer to dataspace object to query - RETURNS - TRUE/FALSE/FAIL - DESCRIPTION - This function determines the if a dataspace is "simple". ie. if it - has orthogonal, evenly spaced dimensions. ---------------------------------------------------------------------------*/ -hbool_t -H5P_is_simple(const H5P_t *sdim) -{ - hbool_t ret_value = FAIL; - - FUNC_ENTER(H5P_is_simple, FAIL); - - /* Check args and all the boring stuff. */ - assert(sdim); - ret_value = sdim->type == H5P_SIMPLE ? TRUE : FALSE; /* Currently all dataspaces are simple, but check anyway */ - - FUNC_LEAVE(ret_value); -} - - -/*-------------------------------------------------------------------------- - NAME - H5Pis_simple - PURPOSE - Check if a dataspace is simple - USAGE - hbool_t H5Pis_simple(sid) - hid_t sid; IN: ID of dataspace object to query - RETURNS - TRUE/FALSE/FAIL - DESCRIPTION - This function determines the if a dataspace is "simple". ie. if it - has orthogonal, evenly spaced dimensions. ---------------------------------------------------------------------------*/ -hbool_t -H5Pis_simple(hid_t sid) -{ - H5P_t *space = NULL; /* dataspace to modify */ - hbool_t ret_value = FAIL; - - FUNC_ENTER(H5Pis_simple, FAIL); - - /* Check args and all the boring stuff. */ - if ((space = H5A_object(sid)) == NULL) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space"); - - ret_value = H5P_is_simple(space); - - done: - if (ret_value == FAIL) { /* Error condition cleanup */ - - } /* end if */ - /* Normal function cleanup */ - FUNC_LEAVE(ret_value); -} - - -/*-------------------------------------------------------------------------- - NAME - H5Pset_space - PURPOSE - Determine the size of a dataspace - USAGE - herr_t H5Pset_space(sid, rank, dims) - hid_t sid; IN: Dataspace object to query - intn rank; IN: # of dimensions for the dataspace - const size_t *dims; IN: Size of each dimension for the dataspace - RETURNS - SUCCEED/FAIL - DESCRIPTION - This function sets the number and size of each dimension in the - dataspace. Setting RANK to a value of zero allows scalar objects to be - created. Dimensions are specified from slowest to fastest changing in the - DIMS array (i.e. 'C' order). Setting the size of a dimension to zero - indicates that the dimension is of unlimited size and should be allowed to - expand. Currently, only the first dimension in the array (the slowest) may - be unlimited in size. ---------------------------------------------------------------------------*/ -herr_t -H5Pset_space(hid_t sid, int rank, const size_t *dims) -{ - H5P_t *space = NULL; /* dataspace to modify */ - intn u; /* local counting variable */ - herr_t ret_value = SUCCEED; - - FUNC_ENTER(H5Pset_space, FAIL); - - /* Check args */ - if ((space = H5A_object(sid)) == NULL) - HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space"); - if (rank > 0 && dims == NULL) - HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no dimensions specified"); - if (rank<0) - HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid rank"); - if (dims) { - for (u=0; utype) { - case H5P_SCALAR: - case H5P_SIMPLE: - /* do nothing */ - break; - - case H5P_COMPLEX: - /* - * eventually this will destroy whatever "complex" dataspace info - * is retained, right now it's an error - */ - /* Fall through to report error */ - - default: - HRETURN_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, - "unknown data space class"); - } - space->type = H5P_SIMPLE; - - /* Reset hyperslab definition, if one is defined */ - if(space->hslab_def==TRUE) { - H5MM_xfree(space->h.start); - H5MM_xfree(space->h.count); - H5MM_xfree(space->h.stride); - space->hslab_def=FALSE; - } - - if (rank == 0) { /* scalar variable */ - space->type = H5P_SCALAR; - space->u.simple.rank = 0; /* set to scalar rank */ - if (space->u.simple.size != NULL) - space->u.simple.size = H5MM_xfree(space->u.simple.size); - if (space->u.simple.max != NULL) - space->u.simple.max = H5MM_xfree(space->u.simple.max); - if (space->u.simple.perm != NULL) - space->u.simple.max = H5MM_xfree(space->u.simple.perm); - } else { - /* Free the old space for now */ - if (space->u.simple.size != NULL) - space->u.simple.size = H5MM_xfree(space->u.simple.size); - if (space->u.simple.max != NULL) - space->u.simple.max = H5MM_xfree(space->u.simple.max); - if (space->u.simple.perm != NULL) - space->u.simple.perm = H5MM_xfree(space->u.simple.perm); - - /* Set the rank and copy the dims */ - space->u.simple.rank = rank; - space->u.simple.size = H5MM_xcalloc(rank, sizeof(size_t)); - HDmemcpy(space->u.simple.size, dims, sizeof(size_t) * rank); - - } - FUNC_LEAVE(ret_value); -} - -/*-------------------------------------------------------------------------- - NAME - H5Pset_hyperslab - PURPOSE - Select a hyperslab from a simple dataspace - USAGE - herr_t H5Pset_hyperslab(sid, start, count, stride) - hid_t sid; IN: Dataspace object to select hyperslab from - const int *start; IN: Starting location for hyperslab to select - const size_t *count; IN: Number of elements in hyperslab - const size_t *stride; IN: Packing of elements in hyperslab - RETURNS - SUCCEED/FAIL - DESCRIPTION - This function selects a hyperslab from a simple dataspace. The stride - array may be used to sub-sample the hyperslab chosen, a value of 1 in each - position of the stride array selects contiguous elements in the array, - a value of 2 selects every other element, etc. If the stride parameter is - set to NULL, a contiguous hyperslab is chosen. The values in the start and - count arrays may be negative, to allow for selecting hyperslabs in chunked - datasets which extend in arbitrary directions. ---------------------------------------------------------------------------*/ -herr_t -H5Pset_hyperslab(hid_t sid, const int *start, const size_t *count, const size_t *stride) -{ - H5P_t *space = NULL; /* dataspace to modify */ - size_t *tmp_stride=NULL; /* temp. copy of stride */ - intn u; /* local counting variable */ - herr_t ret_value = SUCCEED; - - FUNC_ENTER(H5Pset_hyperslab, FAIL); - - /* Get the object */ - if (H5_DATASPACE != H5A_group(sid) || (space = H5A_object(sid)) == NULL) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space"); - if (start == NULL || count==NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "invalid hyperslab selected"); - - /* We can't modify other types of dataspaces currently, so error out */ - if (space->type!=H5P_SIMPLE) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, - "unknown dataspace type"); - - /* Set up stride values for later use */ - tmp_stride= H5MM_xmalloc(space->u.simple.rank*sizeof(tmp_stride[0])); - for (u=0; uu.simple.rank; u++) { - tmp_stride[u] = stride ? stride[u] : 1; - } - - /* Range check arguments */ - for (u=0; uu.simple.rank; u++) { - if (start[u]<0 || start[u]>=space->u.simple.size[u]) { - HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, - "hyperslab bounds out of range"); - } - if (start[u]<0 || - start[u]+(count[u]*tmp_stride[u])>space->u.simple.size[u]) { - HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, - "hyperslab bounds out of range"); - } - } - - /* Allocate space for the hyperslab information */ - if (NULL==space->h.start) { - space->h.start= H5MM_xcalloc(space->u.simple.rank,sizeof(intn)); - space->h.count= H5MM_xcalloc(space->u.simple.rank,sizeof(size_t)); - space->h.stride= H5MM_xcalloc(space->u.simple.rank,sizeof(size_t)); - } - - /* Build hyperslab */ - for(u=0; uu.simple.rank; u++) { - space->h.start[u] = start[u]; - space->h.count[u] = count[u]; - space->h.stride[u] = tmp_stride[u]; - } - space->hslab_def=TRUE; - -done: - if (ret_value == FAIL) { /* Error condition cleanup */ - - } /* end if */ - - /* Normal function cleanup */ - H5MM_xfree(tmp_stride); - FUNC_LEAVE(ret_value); -} - -/*------------------------------------------------------------------------- - * Function: H5Pget_hyperslab - * - * Purpose: Retrieves information about the hyperslab from a simple data - * space. If no hyperslab has been defined then the hyperslab - * is the same as the entire array. - * - * Return: Success: Hyperslab dimensionality. - * - * Failure: FAIL - * - * Programmer: Robb Matzke - * Wednesday, January 28, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -int -H5Pget_hyperslab (hid_t sid, int offset[]/*out*/, size_t size[]/*out*/, - size_t stride[]/*out*/) -{ - const H5P_t *ds = NULL; - intn ret_value = FAIL; - - FUNC_ENTER (H5Pget_hyperslab, FAIL); - - /* Check args */ - if (H5_DATASPACE!=H5A_group (sid) || NULL==(ds=H5A_object (sid))) { - HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); - } - - /* Get hyperslab info */ - if ((ret_value=H5P_get_hyperslab (ds, offset, size, stride))<0) { - HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, - "unable to retrieve hyperslab information"); - } - - FUNC_LEAVE (ret_value); -} - -/*------------------------------------------------------------------------- - * Function: H5P_get_hyperslab - * - * Purpose: Retrieves information about the hyperslab from a simple data - * space. If no hyperslab has been defined then the hyperslab - * is the same as the entire array. - * - * Return: Success: Hyperslab dimensionality. - * - * Failure: FAIL - * - * Programmer: Robb Matzke - * Wednesday, January 28, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -intn -H5P_get_hyperslab (const H5P_t *ds, int offset[]/*out*/, - size_t size[]/*out*/, size_t stride[]/*out*/) -{ - intn i; - intn ret_value = FAIL; - - FUNC_ENTER (H5P_get_hyperslab, FAIL); - - /* Check args */ - assert (ds); - switch (ds->type) { - case H5P_SCALAR: - break; - - case H5P_SIMPLE: - if (ds->hslab_def) { - for (i=0; iu.simple.rank; i++) { - if (offset) offset[i] = ds->h.start[i]; - if (size) size[i] = ds->h.count[i]; - if (stride) stride[i] = ds->h.stride[i]; - } - } else { - for (i=0; iu.simple.rank; i++) { - if (offset) offset[i] = 0; - if (size) size[i] = ds->u.simple.size[i]; - if (stride) stride[i] = 1; - } - } - ret_value = ds->u.simple.rank; - break; - - case H5P_COMPLEX: /*fall through*/ - default: - HRETURN_ERROR (H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, - "hyperslabs not supported for this type of space"); - } - - FUNC_LEAVE (ret_value); -} - - -/*------------------------------------------------------------------------- - * Function: H5P_find - * - * Purpose: Given two data spaces (MEM_SPACE and FILE_SPACE) this - * function locates the data space conversion functions and - * initializes CONV to point to them. The CONV contains - * function pointers for converting in either direction. - * - * Return: Success: Pointer to a data space conversion callback - * list. - * - * Failure: NULL - * - * Programmer: Robb Matzke - * Wednesday, January 21, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -const H5P_conv_t * -H5P_find (const H5P_t *mem_space, const H5P_t *file_space) -{ - static H5P_conv_t _conv; - static const H5P_conv_t *conv = NULL; - - FUNC_ENTER (H5P_find, NULL); - - /* Check args */ - assert (mem_space && H5P_SIMPLE==mem_space->type); - assert (file_space && H5P_SIMPLE==file_space->type); - - /* - * We can't do conversion if the source and destination select a - * different number of data points. - */ - if (H5P_get_npoints (mem_space) != H5P_get_npoints (file_space)) { - HRETURN_ERROR (H5E_DATASPACE, H5E_BADRANGE, NULL, - "memory and file data spaces are different sizes"); - } - - /* - * Initialize pointers. This will eventually be a table lookup based - * on the source and destination data spaces, similar to H5T_find(), but - * for now we only support simple data spaces. - */ - if (!conv) { - _conv.init = H5P_simp_init; - _conv.fgath = H5P_simp_fgath; - _conv.mscat = H5P_simp_mscat; - _conv.mgath = H5P_simp_mgath; - _conv.fscat = H5P_simp_fscat; - conv = &_conv; - } - - FUNC_LEAVE (conv); -} - -/*------------------------------------------------------------------------- - * Function: H5P_extend - * - * Purpose: Extend the dimensions of a data space. - * - * Return: Success: Number of dimensions whose size increased. - * - * Failure: FAIL - * - * Programmer: Robb Matzke - * Friday, January 30, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -intn -H5P_extend (H5P_t *space, const size_t *size) -{ - intn i, ret_value=0; - - FUNC_ENTER (H5P_extend, FAIL); - - /* Check args */ - assert (space && H5P_SIMPLE==space->type); - assert (size); - - for (i=0; iu.simple.rank; i++) { - if (space->u.simple.size[i]u.simple.max && - H5P_UNLIMITED!=space->u.simple.max[i] && - space->u.simple.max[i]u.simple.rank; i++) { - if (space->u.simple.size[i]u.simple.size[i] = size[i]; - } - } - } - - FUNC_LEAVE (ret_value); -} - diff --git a/src/H5Pprivate.h b/src/H5Pprivate.h deleted file mode 100644 index 0ac73b3..0000000 --- a/src/H5Pprivate.h +++ /dev/null @@ -1,126 +0,0 @@ -/**************************************************************************** - * NCSA HDF * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * * - * For conditions of distribution and use, see the accompanying * - * hdf/COPYING file. * - * * - ****************************************************************************/ - -/* - * This file contains private information about the H5P module - */ -#ifndef _H5Pprivate_H -#define _H5Pprivate_H - -#include - -/* Private headers needed by this file */ -#include -#include /*for H5G_entry_t */ -#include - -#define H5P_RESERVED_ATOMS 2 - -/* Flags to indicate special dataspace features are active */ -#define H5P_VALID_MAX 0x01 -#define H5P_VALID_PERM 0x02 - -typedef struct H5P_hyperslab_t { - intn *start; /* Location of start of hyperslab */ - size_t *count; /* Number of elements in hyperslab */ - size_t *stride; /* Packing of values of hyperslab */ -} H5P_hyperslab_t; - -typedef struct H5P_simple_t { - intn rank; /*number of dimensions */ - size_t *size; /*dimension sizes */ - size_t *max; /*maximum dimension sizes or NULL */ - intn *perm; /*dimension permutations or NULL */ -} H5P_simple_t; - -typedef struct H5P_t { - H5P_class_t type; /*type of dimensionality object */ - union { - H5P_simple_t simple; /*simple dimensionality information */ - } u; - uintn hslab_def; /* Whether the hyperslab is defined */ - H5P_hyperslab_t h; /* Hyperslab information */ -} H5P_t; - -/* - * This structure contains information about how the elements of a data space - * are numbered. - */ -typedef struct H5P_number_t { - int _place_holder; /*remove this field! */ -} H5P_number_t; - -/* - * Callbacks for data space conversion. - */ -typedef struct H5P_tconv_t { - /* Initialize element numbering information */ - size_t (*init)(const struct H5O_layout_t *layout, const H5P_t *mem_space, - const H5P_t *file_space, H5P_number_t *numbering/*out*/); - - /* Gather elements from disk to type conversion buffer */ - size_t (*fgath)(H5F_t *f, const struct H5O_layout_t *layout, - size_t elmt_size, const H5P_t *file_space, - const H5P_number_t *numbering, size_t start, size_t nelmts, - void *tconv_buf/*out*/); - - /* Scatter elements from type conversion buffer to application buffer */ - herr_t (*mscat)(const void *tconv_buf, size_t elmt_size, - const H5P_t *mem_space, const H5P_number_t *numbering, - size_t start, size_t nelmts, void *buf/*out*/); - - /* Gather elements from app buffer to type conversion buffer */ - size_t (*mgath)(const void *buf, size_t elmt_size, - const H5P_t *mem_space, const H5P_number_t *numbering, - size_t start, size_t nelmts, void *tconv_buf/*out*/); - - /* Scatter elements from type conversion buffer to disk */ - herr_t (*fscat)(H5F_t *f, const struct H5O_layout_t *layout, - size_t elmt_size, const H5P_t *file_space, - const H5P_number_t *numbering, size_t start, size_t nelmts, - const void *tconv_buf); -} H5P_conv_t; - -H5P_t *H5P_copy (const H5P_t *src); -herr_t H5P_close (H5P_t *ds); -size_t H5P_get_npoints (const H5P_t *ds); -intn H5P_get_ndims (const H5P_t *ds); -intn H5P_get_dims (const H5P_t *ds, size_t dims[]/*out*/); -herr_t H5P_modify (H5G_entry_t *ent, const H5P_t *space); -H5P_t *H5P_read (H5F_t *f, H5G_entry_t *ent); -intn H5P_cmp (const H5P_t *ds1, const H5P_t *ds2); -hbool_t H5P_is_simple (const H5P_t *sdim); -uintn H5P_nelem (const H5P_t *space); -const H5P_conv_t *H5P_find (const H5P_t *mem_space, const H5P_t *file_space); -intn H5P_get_hyperslab (const H5P_t *ds, int offset[]/*out*/, - size_t size[]/*out*/, size_t stride[]/*out*/); -intn H5P_extend (H5P_t *space, const size_t *size); - -/* Conversion functions for simple data spaces */ -size_t H5P_simp_init (const struct H5O_layout_t *layout, - const H5P_t *mem_space, const H5P_t *file_space, - H5P_number_t *numbering/*out*/); -size_t H5P_simp_fgath (H5F_t *f, const struct H5O_layout_t *layout, - size_t elmt_size, const H5P_t *file_space, - const H5P_number_t *numbering, size_t start, - size_t nelmts, void *tconv_buf/*out*/); -herr_t H5P_simp_mscat (const void *tconv_buf, size_t elmt_size, - const H5P_t *mem_space, const H5P_number_t *numbering, - size_t start, size_t nelmts, void *buf/*out*/); -size_t H5P_simp_mgath (const void *buf, size_t elmt_size, - const H5P_t *mem_space, const H5P_number_t *numbering, - size_t start, size_t nelmts, void *tconv_buf/*out*/); -herr_t H5P_simp_fscat (H5F_t *f, const struct H5O_layout_t *layout, - size_t elmt_size, const H5P_t *file_space, - const H5P_number_t *numbering, size_t start, - size_t nelmts, const void *tconv_buf); -#endif diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h deleted file mode 100644 index 72f3c55..0000000 --- a/src/H5Ppublic.h +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** - * NCSA HDF * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * * - * For conditions of distribution and use, see the accompanying * - * hdf/COPYING file. * - * * - ****************************************************************************/ - -/* - * This file contains public declarations for the H5P module. - */ -#ifndef _H5pproto_H -#define _H5Pproto_H - -/* Public headers needed by this file */ -#include -#include - -/* Define atomic datatypes */ -#define H5P_ALL (-2) -#define H5P_UNLIMITED 0 - -/* Different types of dataspaces */ -typedef enum H5P_class_t { - H5P_NO_CLASS = -1, /*error */ - H5P_SCALAR = 0, /*scalar variable */ - H5P_SIMPLE = 1, /*simple data space */ - H5P_COMPLEX = 2 /*complex data space */ -} H5P_class_t; - -#ifdef __cplusplus -extern "C" { -#endif - -/* Functions in H5P.c */ -hid_t H5Pcreate_simple (int rank, const size_t dims[], const size_t maxdims[]); -hid_t H5Pcopy (hid_t space_id); -herr_t H5Pclose (hid_t space_id); -size_t H5Pget_npoints (hid_t space_id); -int H5Pget_ndims (hid_t space_id); -int H5Pget_dims (hid_t space_id, size_t dims[]); -hbool_t H5Pis_simple (hid_t space_id); -herr_t H5Pset_space (hid_t space_id, int rank, const size_t *dims); -herr_t H5Pset_hyperslab(hid_t sid, const int *start, const size_t *count, - const size_t *stride); -int H5Pget_hyperslab (hid_t sid, int offset[]/*out*/, - size_t size[]/*out*/, size_t stride[]/*out*/); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/src/H5Psimp.c b/src/H5Psimp.c deleted file mode 100644 index 7f78236..0000000 --- a/src/H5Psimp.c +++ /dev/null @@ -1,469 +0,0 @@ -/* - * Copyright (C) 1998 NCSA - * All rights reserved. - * - * Programmer: Robb Matzke - * Wednesday, January 21, 1998 - * - * Purpose: Simple data space functions. - */ -#include -#include -#include -#include - -/* Interface initialization */ -#define PABLO_MASK H5P_simp_mask -#define INTERFACE_INIT NULL -static intn interface_initialize_g = FALSE; - -/*------------------------------------------------------------------------- - * Function: H5P_simp_init - * - * Purpose: Generates element numbering information for the data - * spaces involved in a data space conversion. - * - * Return: Success: Number of elements that can be efficiently - * transferred at a time. - * - * Failure: Zero - * - * Programmer: Robb Matzke - * Wednesday, January 21, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -size_t -H5P_simp_init (const struct H5O_layout_t *layout, const H5P_t *mem_space, - const H5P_t *file_space, H5P_number_t *numbering/*out*/) -{ - size_t nelmts; - - FUNC_ENTER (H5P_simp_init, 0); - - /* Check args */ - assert (layout); - assert (mem_space && H5P_SIMPLE==mem_space->type); - assert (file_space && H5P_SIMPLE==file_space->type); - assert (numbering); - - /* Numbering is implied by the hyperslab, C order */ - HDmemset (numbering, 0, sizeof(H5P_number_t)); - - /* Data can be efficiently copied at any size */ - nelmts = H5P_get_npoints (file_space); - - FUNC_LEAVE (nelmts); -} - -/*------------------------------------------------------------------------- - * Function: H5P_simp_fgath - * - * Purpose: Gathers data points from file F and accumulates them in the - * type conversion buffer BUF. The LAYOUT argument describes - * how the data is stored on disk. ELMT_SIZE is the size in - * bytes of a datum which this function treats as opaque. - * FILE_SPACE describes the data space of the dataset on disk - * and the elements that have been selected for reading (via - * hyperslab, etc) and NUMBERING describes how those elements - * are numbered (initialized by the H5P_*_init() call). This - * function will copy at most NELMTS elements beginning at the - * element numbered START. - * - * Return: Success: Number of elements copied. - * - * Failure: 0 - * - * Programmer: Robb Matzke - * Wednesday, January 21, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -size_t -H5P_simp_fgath (H5F_t *f, const struct H5O_layout_t *layout, - size_t elmt_size, const H5P_t *file_space, - const H5P_number_t *numbering, size_t start, size_t nelmts, - void *buf/*out*/) -{ - size_t file_offset[H5O_LAYOUT_NDIMS]; /*offset of slab in file*/ - size_t hsize[H5O_LAYOUT_NDIMS]; /*size of hyperslab */ - size_t zero[H5O_LAYOUT_NDIMS]; /*zero */ - size_t sample[H5O_LAYOUT_NDIMS]; /*hyperslab sampling */ -#ifndef LATER - intn file_offset_signed[H5O_LAYOUT_NDIMS]; -#endif - intn space_ndims; /*dimensionality of space*/ - intn i; /*counters */ - - FUNC_ENTER (H5P_simp_fgath, 0); - - /* Check args */ - assert (f); - assert (layout); - assert (elmt_size>0); - assert (file_space); - assert (numbering); - assert (nelmts>0); - assert (buf); - - /* - * The prototype doesn't support strip mining. - */ - assert (0==start); - assert (nelmts==H5P_get_npoints (file_space)); - - /* - * Get hyperslab information to determine what elements are being - * selected (there might eventually be other selection methods too). - * We only support hyperslabs with unit sample because there's no way to - * currently pass sample information into H5F_arr_read() much less - * H5F_istore_read(). - */ -#ifdef LATER - if ((space_ndims=H5P_get_hyperslab (file_space, file_offset, - hsize, sample))<0) { - HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, 0, - "unable to retrieve hyperslab parameters"); - } -#else - if ((space_ndims=H5P_get_hyperslab (file_space, file_offset_signed, - hsize, sample))<0) { - HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, 0, - "unable to retrieve hyperslab parameters"); - } - for (i=0; i=0); - file_offset[i] = file_offset_signed[i]; - } -#endif - for (i=0; indims*sizeof(size_t)); - - /* - * Gather from file. - */ - if (H5F_arr_read (f, layout, hsize, hsize, zero, file_offset, - buf/*out*/)<0) { - HRETURN_ERROR (H5E_DATASPACE, H5E_READERROR, 0, "read error"); - } - - FUNC_LEAVE (nelmts); -} - -/*------------------------------------------------------------------------- - * Function: H5P_simp_mscat - * - * Purpose: Scatters data points from the type conversion buffer - * TCONV_BUF to the application buffer BUF. Each element is - * ELMT_SIZE bytes and they are organized in application memory - * according to MEM_SPACE. The NUMBERING information together - * with START and NELMTS describe how the elements stored in - * TCONV_BUF are globally numbered. - * - * Return: Success: SUCCEED - * - * Failure: FAIL - * - * Programmer: Robb Matzke - * Wednesday, January 21, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -herr_t -H5P_simp_mscat (const void *tconv_buf, size_t elmt_size, - const H5P_t *mem_space, const H5P_number_t *numbering, - size_t start, size_t nelmts, void *buf/*out*/) -{ - size_t mem_offset[H5O_LAYOUT_NDIMS]; /*slab offset in app buf*/ - size_t mem_size[H5O_LAYOUT_NDIMS]; /*total size of app buf */ - size_t hsize[H5O_LAYOUT_NDIMS]; /*size of hyperslab */ - size_t zero[H5O_LAYOUT_NDIMS]; /*zero */ - size_t sample[H5O_LAYOUT_NDIMS]; /*hyperslab sampling */ -#ifndef LATER - intn mem_offset_signed[H5O_LAYOUT_NDIMS]; -#endif - intn space_ndims; /*dimensionality of space*/ - intn i; /*counters */ - - FUNC_ENTER (H5P_simp_mscat, FAIL); - - /* Check args */ - assert (tconv_buf); - assert (elmt_size>0); - assert (mem_space && H5P_SIMPLE==mem_space->type); - assert (numbering); - assert (nelmts>0); - assert (buf); - - /* - * The prototype doesn't support strip mining. - */ - assert (0==start); - assert (nelmts==H5P_get_npoints (mem_space)); - - /* - * Retrieve hyperslab information to determine what elements are being - * selected (there might be other selection methods in the future). We - * only handle hyperslabs with unit sample because there's currently no - * way to pass sample information to H5V_hyper_copy(). - */ -#ifdef LATER - if ((space_ndims=H5P_get_hyperslab (mem_space, mem_offset, hsize, - sample))<0) { - HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, - "unable to retrieve hyperslab parameters"); - } -#else - if ((space_ndims=H5P_get_hyperslab (mem_space, mem_offset_signed, - hsize, sample))<0) { - HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, - "unable to retrieve hyperslab parameters"); - } - for (i=0; i=0); - mem_offset[i] = mem_offset_signed[i]; - } -#endif - for (i=0; i0); - assert (mem_space && H5P_SIMPLE==mem_space->type); - assert (numbering); - assert (nelmts>0); - assert (tconv_buf); - - /* - * The prototype doesn't support strip mining. - */ - assert (0==start); - assert (nelmts==H5P_get_npoints (mem_space)); - - /* - * Retrieve hyperslab information to determine what elements are being - * selected (there might be other selection methods in the future). We - * only handle hyperslabs with unit sample because there's currently no - * way to pass sample information to H5V_hyper_copy(). - */ -#ifdef LATER - if ((space_ndims=H5P_get_hyperslab (mem_space, mem_offset, hsize, - sample))<0) { - HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, 0, - "unable to retrieve hyperslab parameters"); - } -#else - if ((space_ndims=H5P_get_hyperslab (mem_space, mem_offset_signed, - hsize, sample))<0) { - HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, - "unable to retrieve hyperslab parameters"); - } - for (i=0; i=0); - mem_offset[i] = mem_offset_signed[i]; - } -#endif - for (i=0; i0); - assert (file_space); - assert (numbering); - assert (nelmts>0); - assert (buf); - - /* - * The prototype doesn't support strip mining. - */ - assert (0==start); - assert (nelmts==H5P_get_npoints (file_space)); - - /* - * Get hyperslab information to determine what elements are being - * selected (there might eventually be other selection methods too). - * We only support hyperslabs with unit sample because there's no way to - * currently pass sample information into H5F_arr_read() much less - * H5F_istore_read(). - */ -#ifdef LATER - if ((space_ndims=H5P_get_hyperslab (file_space, file_offset, hsize, - sample))<0) { - HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, - "unable to retrieve hyperslab parameters"); - } -#else - if ((space_ndims=H5P_get_hyperslab (file_space, file_offset_signed, - hsize, sample))<0) { - HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, - "unable to retrieve hyperslab parameters"); - } - for (i=0; i=0); - file_offset[i] = file_offset_signed[i]; - } -#endif - for (i=0; indims*sizeof(size_t)); - - /* - * Scatter to file. - */ - if (H5F_arr_write (f, layout, hsize, hsize, zero, file_offset, buf)<0) { - HRETURN_ERROR (H5E_DATASPACE, H5E_WRITEERROR, FAIL, "write error"); - } - - FUNC_LEAVE (SUCCEED); -} diff --git a/src/H5S.c b/src/H5S.c new file mode 100644 index 0000000..c6f03b2 --- /dev/null +++ b/src/H5S.c @@ -0,0 +1,1294 @@ +/**************************************************************************** +* NCSA HDF * +* Software Development Group * +* National Center for Supercomputing Applications * +* University of Illinois at Urbana-Champaign * +* 605 E. Springfield, Champaign IL 61820 * +* * +* For conditions of distribution and use, see the accompanying * +* hdf/COPYING file. * +* * +****************************************************************************/ + +#ifdef RCSID +static char RcsId[] = "@(#)$Revision$"; +#endif + +/* $Id$ */ + +#include /* Generic Functions */ +#include /* Atom Functions */ +#include /* Error handling */ +#include /* Memory Management functions */ +#include /*object headers */ +#include /* Data-space functions */ + +/* Interface initialization */ +#define PABLO_MASK H5S_mask +#define INTERFACE_INIT H5S_init_interface +static intn interface_initialize_g = FALSE; +static herr_t H5S_init_interface(void); +static void H5S_term_interface(void); + + +/*-------------------------------------------------------------------------- +NAME + H5S_init_interface -- Initialize interface-specific information +USAGE + herr_t H5S_init_interface() + +RETURNS + SUCCEED/FAIL +DESCRIPTION + Initializes any interface-specific data or routines. + +--------------------------------------------------------------------------*/ +static herr_t +H5S_init_interface(void) +{ + herr_t ret_value = SUCCEED; + FUNC_ENTER(H5S_init_interface, FAIL); + + /* Initialize the atom group for the file IDs */ + if ((ret_value = H5A_init_group(H5_DATASPACE, H5A_DATASPACEID_HASHSIZE, + H5S_RESERVED_ATOMS, + (herr_t (*)(void *)) H5S_close)) != FAIL) { + ret_value = H5_add_exit(&H5S_term_interface); + } + FUNC_LEAVE(ret_value); +} + + +/*-------------------------------------------------------------------------- + NAME + H5S_term_interface + PURPOSE + Terminate various H5S objects + USAGE + void H5S_term_interface() + RETURNS + SUCCEED/FAIL + DESCRIPTION + Release the atom group and any other resources allocated. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + Can't report errors... + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +static void +H5S_term_interface(void) +{ + H5A_destroy_group(H5_DATASPACE); +} + +/*------------------------------------------------------------------------- + * Function: H5Screate_simple + * + * Purpose: Creates a new simple data space object and opens it for + * access. The DIMS argument is the size of the simple dataset + * and the MAXDIMS argument is the upper limit on the size of + * the dataset. MAXDIMS may be the null pointer in which case + * the upper limit is the same as DIMS. If an element of + * MAXDIMS is zero then the corresponding dimension is unlimited, + * otherwise no element of MAXDIMS should be smaller than the + * corresponding element of DIMS. + * + * Return: Success: The ID for the new simple data space object. + * + * Failure: FAIL + * + * Errors: + * + * Programmer: Quincey Koziol + * Tuesday, January 27, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +hid_t +H5Screate_simple(int rank, const size_t *dims, const size_t *maxdims) +{ + H5S_t *ds = NULL; + hid_t ret_value = FAIL; + int i; + + FUNC_ENTER(H5Screate, FAIL); + + /* Check arguments */ + if (rank<0) { + HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, + "dimensionality cannot be negative"); + } + if (!dims) { + HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, + "no dimensions specified"); + } + if (maxdims) { + for (i=0; i0) /* for creating simple dataspace */ + { +#endif /* LATER */ + ds->type = H5S_SIMPLE; + ds->hslab_def = FALSE; /* no hyperslab defined currently */ + + /* Initialize rank and dimensions */ + ds->u.simple.rank = rank; + + ds->u.simple.size = H5MM_xcalloc(1, rank*sizeof(size_t)); + HDmemcpy(ds->u.simple.size, dims, rank*sizeof(size_t)); + + if (maxdims) { + ds->u.simple.max = H5MM_xcalloc(1, rank*sizeof(size_t)); + HDmemcpy (ds->u.simple.max, maxdims, rank*sizeof(size_t)); + } +#ifdef LATER /* QAK */ + } /* end if */ + else /* rank==0, for scalar data space */ + { + ds->type = H5S_SCALAR; + } /* end else */ +#endif /* LATER */ + + /* Register the new data space and get an ID for it */ + if ((ret_value = H5A_register(H5_DATASPACE, ds)) < 0) { + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, + "unable to register data space for ID"); + } + + done: + if (ret_value < 0) { + H5MM_xfree(ds); + } + FUNC_LEAVE(ret_value); +} + +/*------------------------------------------------------------------------- + * Function: H5Sclose + * + * Purpose: Release access to a data space object. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Errors: + * + * Programmer: Robb Matzke + * Tuesday, December 9, 1997 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Sclose(hid_t space_id) +{ + FUNC_ENTER(H5Sclose, FAIL); + + /* Check args */ + if (H5_DATASPACE != H5A_group(space_id) || + NULL == H5A_object(space_id)) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); + } + /* When the reference count reaches zero the resources are freed */ + if (H5A_dec_ref(space_id) < 0) { + HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "problem freeing id"); + } + FUNC_LEAVE(SUCCEED); +} + +/*------------------------------------------------------------------------- + * Function: H5S_close + * + * Purpose: Releases all memory associated with a data space. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Tuesday, December 9, 1997 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5S_close(H5S_t *ds) +{ + FUNC_ENTER(H5S_close, FAIL); + + assert(ds); + + switch (ds->type) { + case H5S_SCALAR: + /*void */ + break; + + case H5S_SIMPLE: + H5MM_xfree(ds->u.simple.size); + H5MM_xfree(ds->u.simple.max); + H5MM_xfree(ds->u.simple.perm); + break; + + case H5S_COMPLEX: + /* nothing */ + break; + + default: + assert("unknown data space type" && 0); + break; + } + if(ds->hslab_def==TRUE) { + H5MM_xfree(ds->h.start); + H5MM_xfree(ds->h.count); + H5MM_xfree(ds->h.stride); + } /* end if */ + H5MM_xfree(ds); + + FUNC_LEAVE(SUCCEED); +} + +/*------------------------------------------------------------------------- + * Function: H5Scopy + * + * Purpose: Copies a dataspace. + * + * Return: Success: ID of the new dataspace + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Friday, January 30, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +hid_t +H5Scopy (hid_t space_id) +{ + H5S_t *src = NULL; + H5S_t *dst = NULL; + hid_t ret_value = FAIL; + + FUNC_ENTER (H5Scopy, FAIL); + + /* Check args */ + if (H5_DATASPACE!=H5A_group (space_id) || + NULL==(src=H5A_object (space_id))) { + HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); + } + + /* Copy */ + if (NULL==(dst=H5S_copy (src))) { + HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, + "unable to copy data space"); + } + + /* Atomize */ + if ((ret_value=H5A_register (H5_DATASPACE, dst))<0) { + HRETURN_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL, + "unable to register data space atom"); + } + + FUNC_LEAVE (ret_value); +} + + +/*------------------------------------------------------------------------- + * Function: H5S_copy + * + * Purpose: Copies a data space. + * + * Return: Success: A pointer to a new copy of SRC + * + * Failure: NULL + * + * Programmer: Robb Matzke + * Thursday, December 4, 1997 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +H5S_t * +H5S_copy(const H5S_t *src) +{ + H5S_t *dst = NULL; + int i; + + FUNC_ENTER(H5S_copy, NULL); + + dst = H5MM_xmalloc(sizeof(H5S_t)); + *dst = *src; + + switch (dst->type) { + case H5S_SCALAR: + /*void */ + break; + + case H5S_SIMPLE: + if (dst->u.simple.size) { + dst->u.simple.size = H5MM_xmalloc(dst->u.simple.rank * + sizeof(dst->u.simple.size[0])); + for (i = 0; i < dst->u.simple.rank; i++) { + dst->u.simple.size[i] = src->u.simple.size[i]; + } + } + if (dst->u.simple.max) { + dst->u.simple.max = H5MM_xmalloc(dst->u.simple.rank * + sizeof(dst->u.simple.max[0])); + for (i = 0; i < dst->u.simple.rank; i++) { + dst->u.simple.max[i] = src->u.simple.max[i]; + } + } + if (dst->u.simple.perm) { + dst->u.simple.perm = H5MM_xmalloc(dst->u.simple.rank * + sizeof(dst->u.simple.perm[0])); + for (i = 0; i < dst->u.simple.rank; i++) { + dst->u.simple.perm[i] = src->u.simple.perm[i]; + } + } + break; + + case H5S_COMPLEX: + /*void */ + break; + + default: + assert("unknown data space type" && 0); + break; + } + + FUNC_LEAVE(dst); +} + +/*------------------------------------------------------------------------- + * Function: H5Sget_npoints + * + * Purpose: Determines how many data points a data set has. + * + * Return: Success: Number of data points in the data set. + * + * Failure: 0 + * + * Programmer: Robb Matzke + * Tuesday, December 9, 1997 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +size_t +H5Sget_npoints(hid_t space_id) +{ + H5S_t *ds = NULL; + size_t ret_value = 0; + + FUNC_ENTER(H5Sget_npoints, 0); + + /* Check args */ + if (H5_DATASPACE != H5A_group(space_id) || + NULL == (ds = H5A_object(space_id))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a data space"); + } + ret_value = H5S_get_npoints(ds); + + FUNC_LEAVE(ret_value); +} + +/*------------------------------------------------------------------------- + * Function: H5S_get_npoints + * + * Purpose: Determines how many data points a data set has. + * + * Return: Success: Number of data points in the data set. + * + * Failure: 0 + * + * Programmer: Robb Matzke + * Tuesday, December 9, 1997 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +size_t +H5S_get_npoints(const H5S_t *ds) +{ + size_t ret_value = 0; + intn i; + + FUNC_ENTER(H5S_get_npoints, 0); + + /* check args */ + assert(ds); + + switch (ds->type) { + case H5S_SCALAR: + ret_value = 1; + break; + + case H5S_SIMPLE: + /* + * Count the elements selected by the hypeslab if there is one, + * otherwise count all the elements. + */ + if (ds->hslab_def) { + for (ret_value=1, i=0; iu.simple.rank; i++) { + ret_value *= ds->h.count[i]; + } + } else { + for (ret_value=1, i=0; iu.simple.rank; i++) { + ret_value *= ds->u.simple.size[i]; + } + } + break; + + case H5S_COMPLEX: + HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, 0, + "complex data spaces are not supported yet"); + + default: + assert("unknown data space class" && 0); + HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, 0, + "internal error (unknown data space class)"); + } + + FUNC_LEAVE(ret_value); +} + +/*------------------------------------------------------------------------- + * Function: H5Sget_ndims + * + * Purpose: Determines the dimensionality of a data space. + * + * Return: Success: The number of dimensions in a data space. + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Thursday, December 11, 1997 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +int +H5Sget_ndims(hid_t space_id) +{ + H5S_t *ds = NULL; + intn ret_value = 0; + + FUNC_ENTER(H5Sget_ndims, FAIL); + + /* Check args */ + if (H5_DATASPACE != H5A_group(space_id) || + NULL == (ds = H5A_object(space_id))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); + } + ret_value = H5S_get_ndims(ds); + + FUNC_LEAVE(ret_value); +} + +/*------------------------------------------------------------------------- + * Function: H5S_get_ndims + * + * Purpose: Returns the number of dimensions in a data space. + * + * Return: Success: Non-negative number of dimensions. Zero + * implies a scalar. + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Thursday, December 11, 1997 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +intn +H5S_get_ndims(const H5S_t *ds) +{ + intn ret_value = FAIL; + + FUNC_ENTER(H5S_get_ndims, FAIL); + + /* check args */ + assert(ds); + + switch (ds->type) { + case H5S_SCALAR: + ret_value = 0; + break; + + case H5S_SIMPLE: + ret_value = ds->u.simple.rank; + break; + + case H5S_COMPLEX: + HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, + "complex data spaces are not supported yet"); + + default: + assert("unknown data space class" && 0); + HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, + "internal error (unknown data space class)"); + } + + FUNC_LEAVE(ret_value); +} + +/*------------------------------------------------------------------------- + * Function: H5Sget_dims + * + * Purpose: Returns the size in each dimension of a data space DS through + * the DIMS argument. + * + * Return: Success: Number of dimensions, the same value as + * returned by H5Sget_ndims(). + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Thursday, December 11, 1997 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +int +H5Sget_dims(hid_t space_id, size_t dims[]/*out*/) +{ + + H5S_t *ds = NULL; + intn ret_value = 0; + + FUNC_ENTER(H5Sget_dims, FAIL); + + /* Check args */ + if (H5_DATASPACE != H5A_group(space_id) || + NULL == (ds = H5A_object(space_id))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); + } + if (!dims) { + HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer"); + } + ret_value = H5S_get_dims(ds, dims); + + FUNC_LEAVE(ret_value); +} + +/*------------------------------------------------------------------------- + * Function: H5S_get_dims + * + * Purpose: Returns the size in each dimension of a data space. This + * function may not be meaningful for all types of data spaces. + * + * Return: Success: Number of dimensions. Zero implies scalar. + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Thursday, December 11, 1997 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +intn +H5S_get_dims(const H5S_t *ds, size_t dims[]) +{ + intn ret_value = FAIL; + intn i; + + FUNC_ENTER(H5S_get_dims, FAIL); + + /* check args */ + assert(ds); + assert(dims); + + switch (ds->type) { + case H5S_SCALAR: + ret_value = 0; + break; + + case H5S_SIMPLE: + ret_value = ds->u.simple.rank; + for (i = 0; i < ret_value; i++) { + dims[i] = ds->u.simple.size[i]; + } + break; + + case H5S_COMPLEX: + HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, + "complex data spaces are not supported yet"); + + default: + assert("unknown data space class" && 0); + HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, + "internal error (unknown data space class)"); + } + + FUNC_LEAVE(ret_value); +} + +/*------------------------------------------------------------------------- + * Function: H5S_modify + * + * Purpose: Updates a data space by writing a message to an object + * header. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Tuesday, December 9, 1997 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5S_modify(H5G_entry_t *ent, const H5S_t *ds) +{ + FUNC_ENTER(H5S_modify, FAIL); + + assert(ent); + assert(ds); + + switch (ds->type) { + case H5S_SCALAR: + HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, + "scalar data spaces are not implemented yet"); + + case H5S_SIMPLE: + if (H5O_modify(ent, H5O_SDSPACE, 0, 0, &(ds->u.simple)) < 0) { + HRETURN_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, + "can't update simple data space message"); + } + break; + + case H5S_COMPLEX: + HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, + "complex data spaces are not implemented yet"); + + default: + assert("unknown data space class" && 0); + break; + } + + FUNC_LEAVE(SUCCEED); +} + +/*------------------------------------------------------------------------- + * Function: H5S_read + * + * Purpose: Reads the data space from an object header. + * + * Return: Success: Pointer to a new data space. + * + * Failure: NULL + * + * Programmer: Robb Matzke + * Tuesday, December 9, 1997 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +H5S_t * +H5S_read(H5F_t *f, H5G_entry_t *ent) +{ + H5S_t *ds = NULL; + + FUNC_ENTER(H5S_read, NULL); + + /* check args */ + assert(f); + assert(ent); + + ds = H5MM_xcalloc(1, sizeof(H5S_t)); + + if (H5O_read(ent, H5O_SDSPACE, 0, &(ds->u.simple))) { + ds->type = H5S_SIMPLE; + + } else { + ds->type = H5S_SCALAR; + } + + FUNC_LEAVE(ds); +} + +/*------------------------------------------------------------------------- + * Function: H5S_cmp + * + * Purpose: Compares two data spaces. + * + * Return: Success: 0 if DS1 and DS2 are the same. + * <0 if DS1 is less than DS2. + * >0 if DS1 is greater than DS2. + * + * Failure: 0, never fails + * + * Programmer: Robb Matzke + * Wednesday, December 10, 1997 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +intn +H5S_cmp(const H5S_t *ds1, const H5S_t *ds2) +{ + intn i; + + FUNC_ENTER(H5S_cmp, 0); + + /* check args */ + assert(ds1); + assert(ds2); + + /* compare */ + if (ds1->type < ds2->type) + HRETURN(-1); + if (ds1->type > ds2->type) + HRETURN(1); + + switch (ds1->type) { + case H5S_SIMPLE: + if (ds1->u.simple.rank < ds2->u.simple.rank) + HRETURN(-1); + if (ds1->u.simple.rank > ds2->u.simple.rank) + HRETURN(1); + + for (i = 0; i < ds1->u.simple.rank; i++) { + if (ds1->u.simple.size[i] < ds2->u.simple.size[i]) + HRETURN(-1); + if (ds1->u.simple.size[i] > ds2->u.simple.size[i]) + HRETURN(1); + } + + /* don't compare max dimensions */ + + for (i = 0; i < ds1->u.simple.rank; i++) { + if ((ds1->u.simple.perm ? ds1->u.simple.perm[i] : i) < + (ds2->u.simple.perm ? ds2->u.simple.perm[i] : i)) + HRETURN(-1); + if ((ds1->u.simple.perm ? ds2->u.simple.perm[i] : i) > + (ds2->u.simple.perm ? ds2->u.simple.perm[i] : i)) + HRETURN(1); + } + + /* Check if we should compare hyperslab definitions */ + if(ds1->hslab_def==TRUE && ds2->hslab_def==TRUE) { + for (i = 0; i < ds1->u.simple.rank; i++) { + if (ds1->h.start[i] < ds2->h.start[i]) + HRETURN(-1); + if (ds1->h.start[i] > ds2->h.start[i]) + HRETURN(1); + if (ds1->h.count[i] < ds2->h.count[i]) + HRETURN(-1); + if (ds1->h.count[i] > ds2->h.count[i]) + HRETURN(1); + if (ds1->h.stride[i] < ds2->h.stride[i]) + HRETURN(-1); + if (ds1->h.stride[i] > ds2->h.stride[i]) + HRETURN(1); + } + } else { + if(ds1->hslab_def!=ds2->hslab_def) + HRETURN(ds1->hslab_def==TRUE ? 1 : -1); + } + + break; + + default: + assert("not implemented yet" && 0); + } + + FUNC_LEAVE(0); +} + + +/*-------------------------------------------------------------------------- + NAME + H5S_is_simple + PURPOSE + Check if a dataspace is simple (internal) + USAGE + hbool_t H5S_is_simple(sdim) + H5S_t *sdim; IN: Pointer to dataspace object to query + RETURNS + TRUE/FALSE/FAIL + DESCRIPTION + This function determines the if a dataspace is "simple". ie. if it + has orthogonal, evenly spaced dimensions. +--------------------------------------------------------------------------*/ +hbool_t +H5S_is_simple(const H5S_t *sdim) +{ + hbool_t ret_value = FAIL; + + FUNC_ENTER(H5S_is_simple, FAIL); + + /* Check args and all the boring stuff. */ + assert(sdim); + ret_value = sdim->type == H5S_SIMPLE ? TRUE : FALSE; /* Currently all dataspaces are simple, but check anyway */ + + FUNC_LEAVE(ret_value); +} + + +/*-------------------------------------------------------------------------- + NAME + H5Sis_simple + PURPOSE + Check if a dataspace is simple + USAGE + hbool_t H5Sis_simple(sid) + hid_t sid; IN: ID of dataspace object to query + RETURNS + TRUE/FALSE/FAIL + DESCRIPTION + This function determines the if a dataspace is "simple". ie. if it + has orthogonal, evenly spaced dimensions. +--------------------------------------------------------------------------*/ +hbool_t +H5Sis_simple(hid_t sid) +{ + H5S_t *space = NULL; /* dataspace to modify */ + hbool_t ret_value = FAIL; + + FUNC_ENTER(H5Sis_simple, FAIL); + + /* Check args and all the boring stuff. */ + if ((space = H5A_object(sid)) == NULL) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space"); + + ret_value = H5S_is_simple(space); + + done: + if (ret_value == FAIL) { /* Error condition cleanup */ + + } /* end if */ + /* Normal function cleanup */ + FUNC_LEAVE(ret_value); +} + + +/*-------------------------------------------------------------------------- + NAME + H5Sset_space + PURPOSE + Determine the size of a dataspace + USAGE + herr_t H5Sset_space(sid, rank, dims) + hid_t sid; IN: Dataspace object to query + intn rank; IN: # of dimensions for the dataspace + const size_t *dims; IN: Size of each dimension for the dataspace + RETURNS + SUCCEED/FAIL + DESCRIPTION + This function sets the number and size of each dimension in the + dataspace. Setting RANK to a value of zero allows scalar objects to be + created. Dimensions are specified from slowest to fastest changing in the + DIMS array (i.e. 'C' order). Setting the size of a dimension to zero + indicates that the dimension is of unlimited size and should be allowed to + expand. Currently, only the first dimension in the array (the slowest) may + be unlimited in size. +--------------------------------------------------------------------------*/ +herr_t +H5Sset_space(hid_t sid, int rank, const size_t *dims) +{ + H5S_t *space = NULL; /* dataspace to modify */ + intn u; /* local counting variable */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER(H5Sset_space, FAIL); + + /* Check args */ + if ((space = H5A_object(sid)) == NULL) + HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space"); + if (rank > 0 && dims == NULL) + HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no dimensions specified"); + if (rank<0) + HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid rank"); + if (dims) { + for (u=0; utype) { + case H5S_SCALAR: + case H5S_SIMPLE: + /* do nothing */ + break; + + case H5S_COMPLEX: + /* + * eventually this will destroy whatever "complex" dataspace info + * is retained, right now it's an error + */ + /* Fall through to report error */ + + default: + HRETURN_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, + "unknown data space class"); + } + space->type = H5S_SIMPLE; + + /* Reset hyperslab definition, if one is defined */ + if(space->hslab_def==TRUE) { + H5MM_xfree(space->h.start); + H5MM_xfree(space->h.count); + H5MM_xfree(space->h.stride); + space->hslab_def=FALSE; + } + + if (rank == 0) { /* scalar variable */ + space->type = H5S_SCALAR; + space->u.simple.rank = 0; /* set to scalar rank */ + if (space->u.simple.size != NULL) + space->u.simple.size = H5MM_xfree(space->u.simple.size); + if (space->u.simple.max != NULL) + space->u.simple.max = H5MM_xfree(space->u.simple.max); + if (space->u.simple.perm != NULL) + space->u.simple.max = H5MM_xfree(space->u.simple.perm); + } else { + /* Free the old space for now */ + if (space->u.simple.size != NULL) + space->u.simple.size = H5MM_xfree(space->u.simple.size); + if (space->u.simple.max != NULL) + space->u.simple.max = H5MM_xfree(space->u.simple.max); + if (space->u.simple.perm != NULL) + space->u.simple.perm = H5MM_xfree(space->u.simple.perm); + + /* Set the rank and copy the dims */ + space->u.simple.rank = rank; + space->u.simple.size = H5MM_xcalloc(rank, sizeof(size_t)); + HDmemcpy(space->u.simple.size, dims, sizeof(size_t) * rank); + + } + FUNC_LEAVE(ret_value); +} + +/*-------------------------------------------------------------------------- + NAME + H5Sset_hyperslab + PURPOSE + Select a hyperslab from a simple dataspace + USAGE + herr_t H5Sset_hyperslab(sid, start, count, stride) + hid_t sid; IN: Dataspace object to select hyperslab from + const int *start; IN: Starting location for hyperslab to select + const size_t *count; IN: Number of elements in hyperslab + const size_t *stride; IN: Packing of elements in hyperslab + RETURNS + SUCCEED/FAIL + DESCRIPTION + This function selects a hyperslab from a simple dataspace. The stride + array may be used to sub-sample the hyperslab chosen, a value of 1 in each + position of the stride array selects contiguous elements in the array, + a value of 2 selects every other element, etc. If the stride parameter is + set to NULL, a contiguous hyperslab is chosen. The values in the start and + count arrays may be negative, to allow for selecting hyperslabs in chunked + datasets which extend in arbitrary directions. +--------------------------------------------------------------------------*/ +herr_t +H5Sset_hyperslab(hid_t sid, const int *start, const size_t *count, const size_t *stride) +{ + H5S_t *space = NULL; /* dataspace to modify */ + size_t *tmp_stride=NULL; /* temp. copy of stride */ + intn u; /* local counting variable */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER(H5Sset_hyperslab, FAIL); + + /* Get the object */ + if (H5_DATASPACE != H5A_group(sid) || (space = H5A_object(sid)) == NULL) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space"); + if (start == NULL || count==NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "invalid hyperslab selected"); + + /* We can't modify other types of dataspaces currently, so error out */ + if (space->type!=H5S_SIMPLE) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, + "unknown dataspace type"); + + /* Set up stride values for later use */ + tmp_stride= H5MM_xmalloc(space->u.simple.rank*sizeof(tmp_stride[0])); + for (u=0; uu.simple.rank; u++) { + tmp_stride[u] = stride ? stride[u] : 1; + } + + /* Range check arguments */ + for (u=0; uu.simple.rank; u++) { + if (start[u]<0 || start[u]>=space->u.simple.size[u]) { + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, + "hyperslab bounds out of range"); + } + if (start[u]<0 || + start[u]+(count[u]*tmp_stride[u])>space->u.simple.size[u]) { + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, + "hyperslab bounds out of range"); + } + } + + /* Allocate space for the hyperslab information */ + if (NULL==space->h.start) { + space->h.start= H5MM_xcalloc(space->u.simple.rank,sizeof(intn)); + space->h.count= H5MM_xcalloc(space->u.simple.rank,sizeof(size_t)); + space->h.stride= H5MM_xcalloc(space->u.simple.rank,sizeof(size_t)); + } + + /* Build hyperslab */ + for(u=0; uu.simple.rank; u++) { + space->h.start[u] = start[u]; + space->h.count[u] = count[u]; + space->h.stride[u] = tmp_stride[u]; + } + space->hslab_def=TRUE; + +done: + if (ret_value == FAIL) { /* Error condition cleanup */ + + } /* end if */ + + /* Normal function cleanup */ + H5MM_xfree(tmp_stride); + FUNC_LEAVE(ret_value); +} + +/*------------------------------------------------------------------------- + * Function: H5Sget_hyperslab + * + * Purpose: Retrieves information about the hyperslab from a simple data + * space. If no hyperslab has been defined then the hyperslab + * is the same as the entire array. + * + * Return: Success: Hyperslab dimensionality. + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Wednesday, January 28, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +int +H5Sget_hyperslab (hid_t sid, int offset[]/*out*/, size_t size[]/*out*/, + size_t stride[]/*out*/) +{ + const H5S_t *ds = NULL; + intn ret_value = FAIL; + + FUNC_ENTER (H5Sget_hyperslab, FAIL); + + /* Check args */ + if (H5_DATASPACE!=H5A_group (sid) || NULL==(ds=H5A_object (sid))) { + HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); + } + + /* Get hyperslab info */ + if ((ret_value=H5S_get_hyperslab (ds, offset, size, stride))<0) { + HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, + "unable to retrieve hyperslab information"); + } + + FUNC_LEAVE (ret_value); +} + +/*------------------------------------------------------------------------- + * Function: H5S_get_hyperslab + * + * Purpose: Retrieves information about the hyperslab from a simple data + * space. If no hyperslab has been defined then the hyperslab + * is the same as the entire array. + * + * Return: Success: Hyperslab dimensionality. + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Wednesday, January 28, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +intn +H5S_get_hyperslab (const H5S_t *ds, int offset[]/*out*/, + size_t size[]/*out*/, size_t stride[]/*out*/) +{ + intn i; + intn ret_value = FAIL; + + FUNC_ENTER (H5S_get_hyperslab, FAIL); + + /* Check args */ + assert (ds); + switch (ds->type) { + case H5S_SCALAR: + break; + + case H5S_SIMPLE: + if (ds->hslab_def) { + for (i=0; iu.simple.rank; i++) { + if (offset) offset[i] = ds->h.start[i]; + if (size) size[i] = ds->h.count[i]; + if (stride) stride[i] = ds->h.stride[i]; + } + } else { + for (i=0; iu.simple.rank; i++) { + if (offset) offset[i] = 0; + if (size) size[i] = ds->u.simple.size[i]; + if (stride) stride[i] = 1; + } + } + ret_value = ds->u.simple.rank; + break; + + case H5S_COMPLEX: /*fall through*/ + default: + HRETURN_ERROR (H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, + "hyperslabs not supported for this type of space"); + } + + FUNC_LEAVE (ret_value); +} + + +/*------------------------------------------------------------------------- + * Function: H5S_find + * + * Purpose: Given two data spaces (MEM_SPACE and FILE_SPACE) this + * function locates the data space conversion functions and + * initializes CONV to point to them. The CONV contains + * function pointers for converting in either direction. + * + * Return: Success: Pointer to a data space conversion callback + * list. + * + * Failure: NULL + * + * Programmer: Robb Matzke + * Wednesday, January 21, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +const H5S_conv_t * +H5S_find (const H5S_t *mem_space, const H5S_t *file_space) +{ + static H5S_conv_t _conv; + static const H5S_conv_t *conv = NULL; + + FUNC_ENTER (H5S_find, NULL); + + /* Check args */ + assert (mem_space && H5S_SIMPLE==mem_space->type); + assert (file_space && H5S_SIMPLE==file_space->type); + + /* + * We can't do conversion if the source and destination select a + * different number of data points. + */ + if (H5S_get_npoints (mem_space) != H5S_get_npoints (file_space)) { + HRETURN_ERROR (H5E_DATASPACE, H5E_BADRANGE, NULL, + "memory and file data spaces are different sizes"); + } + + /* + * Initialize pointers. This will eventually be a table lookup based + * on the source and destination data spaces, similar to H5T_find(), but + * for now we only support simple data spaces. + */ + if (!conv) { + _conv.init = H5S_simp_init; + _conv.fgath = H5S_simp_fgath; + _conv.mscat = H5S_simp_mscat; + _conv.mgath = H5S_simp_mgath; + _conv.fscat = H5S_simp_fscat; + conv = &_conv; + } + + FUNC_LEAVE (conv); +} + +/*------------------------------------------------------------------------- + * Function: H5S_extend + * + * Purpose: Extend the dimensions of a data space. + * + * Return: Success: Number of dimensions whose size increased. + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Friday, January 30, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +intn +H5S_extend (H5S_t *space, const size_t *size) +{ + intn i, ret_value=0; + + FUNC_ENTER (H5S_extend, FAIL); + + /* Check args */ + assert (space && H5S_SIMPLE==space->type); + assert (size); + + for (i=0; iu.simple.rank; i++) { + if (space->u.simple.size[i]u.simple.max && + H5S_UNLIMITED!=space->u.simple.max[i] && + space->u.simple.max[i]u.simple.rank; i++) { + if (space->u.simple.size[i]u.simple.size[i] = size[i]; + } + } + } + + FUNC_LEAVE (ret_value); +} + diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h new file mode 100644 index 0000000..25e758e --- /dev/null +++ b/src/H5Sprivate.h @@ -0,0 +1,126 @@ +/**************************************************************************** + * NCSA HDF * + * Software Development Group * + * National Center for Supercomputing Applications * + * University of Illinois at Urbana-Champaign * + * 605 E. Springfield, Champaign IL 61820 * + * * + * For conditions of distribution and use, see the accompanying * + * hdf/COPYING file. * + * * + ****************************************************************************/ + +/* + * This file contains private information about the H5S module + */ +#ifndef _H5Sprivate_H +#define _H5Sprivate_H + +#include + +/* Private headers needed by this file */ +#include +#include /*for H5G_entry_t */ +#include + +#define H5S_RESERVED_ATOMS 2 + +/* Flags to indicate special dataspace features are active */ +#define H5S_VALID_MAX 0x01 +#define H5S_VALID_PERM 0x02 + +typedef struct H5S_hyperslab_t { + intn *start; /* Location of start of hyperslab */ + size_t *count; /* Number of elements in hyperslab */ + size_t *stride; /* Packing of values of hyperslab */ +} H5S_hyperslab_t; + +typedef struct H5S_simple_t { + intn rank; /*number of dimensions */ + size_t *size; /*dimension sizes */ + size_t *max; /*maximum dimension sizes or NULL */ + intn *perm; /*dimension permutations or NULL */ +} H5S_simple_t; + +typedef struct H5S_t { + H5S_class_t type; /*type of dimensionality object */ + union { + H5S_simple_t simple; /*simple dimensionality information */ + } u; + uintn hslab_def; /* Whether the hyperslab is defined */ + H5S_hyperslab_t h; /* Hyperslab information */ +} H5S_t; + +/* + * This structure contains information about how the elements of a data space + * are numbered. + */ +typedef struct H5S_number_t { + int _place_holder; /*remove this field! */ +} H5S_number_t; + +/* + * Callbacks for data space conversion. + */ +typedef struct H5S_tconv_t { + /* Initialize element numbering information */ + size_t (*init)(const struct H5O_layout_t *layout, const H5S_t *mem_space, + const H5S_t *file_space, H5S_number_t *numbering/*out*/); + + /* Gather elements from disk to type conversion buffer */ + size_t (*fgath)(H5F_t *f, const struct H5O_layout_t *layout, + size_t elmt_size, const H5S_t *file_space, + const H5S_number_t *numbering, size_t start, size_t nelmts, + void *tconv_buf/*out*/); + + /* Scatter elements from type conversion buffer to application buffer */ + herr_t (*mscat)(const void *tconv_buf, size_t elmt_size, + const H5S_t *mem_space, const H5S_number_t *numbering, + size_t start, size_t nelmts, void *buf/*out*/); + + /* Gather elements from app buffer to type conversion buffer */ + size_t (*mgath)(const void *buf, size_t elmt_size, + const H5S_t *mem_space, const H5S_number_t *numbering, + size_t start, size_t nelmts, void *tconv_buf/*out*/); + + /* Scatter elements from type conversion buffer to disk */ + herr_t (*fscat)(H5F_t *f, const struct H5O_layout_t *layout, + size_t elmt_size, const H5S_t *file_space, + const H5S_number_t *numbering, size_t start, size_t nelmts, + const void *tconv_buf); +} H5S_conv_t; + +H5S_t *H5S_copy (const H5S_t *src); +herr_t H5S_close (H5S_t *ds); +size_t H5S_get_npoints (const H5S_t *ds); +intn H5S_get_ndims (const H5S_t *ds); +intn H5S_get_dims (const H5S_t *ds, size_t dims[]/*out*/); +herr_t H5S_modify (H5G_entry_t *ent, const H5S_t *space); +H5S_t *H5S_read (H5F_t *f, H5G_entry_t *ent); +intn H5S_cmp (const H5S_t *ds1, const H5S_t *ds2); +hbool_t H5S_is_simple (const H5S_t *sdim); +uintn H5S_nelem (const H5S_t *space); +const H5S_conv_t *H5S_find (const H5S_t *mem_space, const H5S_t *file_space); +intn H5S_get_hyperslab (const H5S_t *ds, int offset[]/*out*/, + size_t size[]/*out*/, size_t stride[]/*out*/); +intn H5S_extend (H5S_t *space, const size_t *size); + +/* Conversion functions for simple data spaces */ +size_t H5S_simp_init (const struct H5O_layout_t *layout, + const H5S_t *mem_space, const H5S_t *file_space, + H5S_number_t *numbering/*out*/); +size_t H5S_simp_fgath (H5F_t *f, const struct H5O_layout_t *layout, + size_t elmt_size, const H5S_t *file_space, + const H5S_number_t *numbering, size_t start, + size_t nelmts, void *tconv_buf/*out*/); +herr_t H5S_simp_mscat (const void *tconv_buf, size_t elmt_size, + const H5S_t *mem_space, const H5S_number_t *numbering, + size_t start, size_t nelmts, void *buf/*out*/); +size_t H5S_simp_mgath (const void *buf, size_t elmt_size, + const H5S_t *mem_space, const H5S_number_t *numbering, + size_t start, size_t nelmts, void *tconv_buf/*out*/); +herr_t H5S_simp_fscat (H5F_t *f, const struct H5O_layout_t *layout, + size_t elmt_size, const H5S_t *file_space, + const H5S_number_t *numbering, size_t start, + size_t nelmts, const void *tconv_buf); +#endif diff --git a/src/H5Spublic.h b/src/H5Spublic.h new file mode 100644 index 0000000..3fe0a31 --- /dev/null +++ b/src/H5Spublic.h @@ -0,0 +1,56 @@ +/**************************************************************************** + * NCSA HDF * + * Software Development Group * + * National Center for Supercomputing Applications * + * University of Illinois at Urbana-Champaign * + * 605 E. Springfield, Champaign IL 61820 * + * * + * For conditions of distribution and use, see the accompanying * + * hdf/COPYING file. * + * * + ****************************************************************************/ + +/* + * This file contains public declarations for the H5S module. + */ +#ifndef _H5pproto_H +#define _H5Sproto_H + +/* Public headers needed by this file */ +#include +#include + +/* Define atomic datatypes */ +#define H5S_ALL (-2) +#define H5S_UNLIMITED 0 + +/* Different types of dataspaces */ +typedef enum H5S_class_t { + H5S_NO_CLASS = -1, /*error */ + H5S_SCALAR = 0, /*scalar variable */ + H5S_SIMPLE = 1, /*simple data space */ + H5S_COMPLEX = 2 /*complex data space */ +} H5S_class_t; + +#ifdef __cplusplus +extern "C" { +#endif + +/* Functions in H5S.c */ +hid_t H5Screate_simple (int rank, const size_t dims[], const size_t maxdims[]); +hid_t H5Scopy (hid_t space_id); +herr_t H5Sclose (hid_t space_id); +size_t H5Sget_npoints (hid_t space_id); +int H5Sget_ndims (hid_t space_id); +int H5Sget_dims (hid_t space_id, size_t dims[]); +hbool_t H5Sis_simple (hid_t space_id); +herr_t H5Sset_space (hid_t space_id, int rank, const size_t *dims); +herr_t H5Sset_hyperslab(hid_t sid, const int *start, const size_t *count, + const size_t *stride); +int H5Sget_hyperslab (hid_t sid, int offset[]/*out*/, + size_t size[]/*out*/, size_t stride[]/*out*/); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/H5Ssimp.c b/src/H5Ssimp.c new file mode 100644 index 0000000..99900c2 --- /dev/null +++ b/src/H5Ssimp.c @@ -0,0 +1,469 @@ +/* + * Copyright (C) 1998 NCSA + * All rights reserved. + * + * Programmer: Robb Matzke + * Wednesday, January 21, 1998 + * + * Purpose: Simple data space functions. + */ +#include +#include +#include +#include + +/* Interface initialization */ +#define PABLO_MASK H5S_simp_mask +#define INTERFACE_INIT NULL +static intn interface_initialize_g = FALSE; + +/*------------------------------------------------------------------------- + * Function: H5S_simp_init + * + * Purpose: Generates element numbering information for the data + * spaces involved in a data space conversion. + * + * Return: Success: Number of elements that can be efficiently + * transferred at a time. + * + * Failure: Zero + * + * Programmer: Robb Matzke + * Wednesday, January 21, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +size_t +H5S_simp_init (const struct H5O_layout_t *layout, const H5S_t *mem_space, + const H5S_t *file_space, H5S_number_t *numbering/*out*/) +{ + size_t nelmts; + + FUNC_ENTER (H5S_simp_init, 0); + + /* Check args */ + assert (layout); + assert (mem_space && H5S_SIMPLE==mem_space->type); + assert (file_space && H5S_SIMPLE==file_space->type); + assert (numbering); + + /* Numbering is implied by the hyperslab, C order */ + HDmemset (numbering, 0, sizeof(H5S_number_t)); + + /* Data can be efficiently copied at any size */ + nelmts = H5S_get_npoints (file_space); + + FUNC_LEAVE (nelmts); +} + +/*------------------------------------------------------------------------- + * Function: H5S_simp_fgath + * + * Purpose: Gathers data points from file F and accumulates them in the + * type conversion buffer BUF. The LAYOUT argument describes + * how the data is stored on disk. ELMT_SIZE is the size in + * bytes of a datum which this function treats as opaque. + * FILE_SPACE describes the data space of the dataset on disk + * and the elements that have been selected for reading (via + * hyperslab, etc) and NUMBERING describes how those elements + * are numbered (initialized by the H5S_*_init() call). This + * function will copy at most NELMTS elements beginning at the + * element numbered START. + * + * Return: Success: Number of elements copied. + * + * Failure: 0 + * + * Programmer: Robb Matzke + * Wednesday, January 21, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +size_t +H5S_simp_fgath (H5F_t *f, const struct H5O_layout_t *layout, + size_t elmt_size, const H5S_t *file_space, + const H5S_number_t *numbering, size_t start, size_t nelmts, + void *buf/*out*/) +{ + size_t file_offset[H5O_LAYOUT_NDIMS]; /*offset of slab in file*/ + size_t hsize[H5O_LAYOUT_NDIMS]; /*size of hyperslab */ + size_t zero[H5O_LAYOUT_NDIMS]; /*zero */ + size_t sample[H5O_LAYOUT_NDIMS]; /*hyperslab sampling */ +#ifndef LATER + intn file_offset_signed[H5O_LAYOUT_NDIMS]; +#endif + intn space_ndims; /*dimensionality of space*/ + intn i; /*counters */ + + FUNC_ENTER (H5S_simp_fgath, 0); + + /* Check args */ + assert (f); + assert (layout); + assert (elmt_size>0); + assert (file_space); + assert (numbering); + assert (nelmts>0); + assert (buf); + + /* + * The prototype doesn't support strip mining. + */ + assert (0==start); + assert (nelmts==H5S_get_npoints (file_space)); + + /* + * Get hyperslab information to determine what elements are being + * selected (there might eventually be other selection methods too). + * We only support hyperslabs with unit sample because there's no way to + * currently pass sample information into H5F_arr_read() much less + * H5F_istore_read(). + */ +#ifdef LATER + if ((space_ndims=H5S_get_hyperslab (file_space, file_offset, + hsize, sample))<0) { + HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, 0, + "unable to retrieve hyperslab parameters"); + } +#else + if ((space_ndims=H5S_get_hyperslab (file_space, file_offset_signed, + hsize, sample))<0) { + HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, 0, + "unable to retrieve hyperslab parameters"); + } + for (i=0; i=0); + file_offset[i] = file_offset_signed[i]; + } +#endif + for (i=0; indims*sizeof(size_t)); + + /* + * Gather from file. + */ + if (H5F_arr_read (f, layout, hsize, hsize, zero, file_offset, + buf/*out*/)<0) { + HRETURN_ERROR (H5E_DATASPACE, H5E_READERROR, 0, "read error"); + } + + FUNC_LEAVE (nelmts); +} + +/*------------------------------------------------------------------------- + * Function: H5S_simp_mscat + * + * Purpose: Scatters data points from the type conversion buffer + * TCONV_BUF to the application buffer BUF. Each element is + * ELMT_SIZE bytes and they are organized in application memory + * according to MEM_SPACE. The NUMBERING information together + * with START and NELMTS describe how the elements stored in + * TCONV_BUF are globally numbered. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Wednesday, January 21, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5S_simp_mscat (const void *tconv_buf, size_t elmt_size, + const H5S_t *mem_space, const H5S_number_t *numbering, + size_t start, size_t nelmts, void *buf/*out*/) +{ + size_t mem_offset[H5O_LAYOUT_NDIMS]; /*slab offset in app buf*/ + size_t mem_size[H5O_LAYOUT_NDIMS]; /*total size of app buf */ + size_t hsize[H5O_LAYOUT_NDIMS]; /*size of hyperslab */ + size_t zero[H5O_LAYOUT_NDIMS]; /*zero */ + size_t sample[H5O_LAYOUT_NDIMS]; /*hyperslab sampling */ +#ifndef LATER + intn mem_offset_signed[H5O_LAYOUT_NDIMS]; +#endif + intn space_ndims; /*dimensionality of space*/ + intn i; /*counters */ + + FUNC_ENTER (H5S_simp_mscat, FAIL); + + /* Check args */ + assert (tconv_buf); + assert (elmt_size>0); + assert (mem_space && H5S_SIMPLE==mem_space->type); + assert (numbering); + assert (nelmts>0); + assert (buf); + + /* + * The prototype doesn't support strip mining. + */ + assert (0==start); + assert (nelmts==H5S_get_npoints (mem_space)); + + /* + * Retrieve hyperslab information to determine what elements are being + * selected (there might be other selection methods in the future). We + * only handle hyperslabs with unit sample because there's currently no + * way to pass sample information to H5V_hyper_copy(). + */ +#ifdef LATER + if ((space_ndims=H5S_get_hyperslab (mem_space, mem_offset, hsize, + sample))<0) { + HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, + "unable to retrieve hyperslab parameters"); + } +#else + if ((space_ndims=H5S_get_hyperslab (mem_space, mem_offset_signed, + hsize, sample))<0) { + HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, + "unable to retrieve hyperslab parameters"); + } + for (i=0; i=0); + mem_offset[i] = mem_offset_signed[i]; + } +#endif + for (i=0; i0); + assert (mem_space && H5S_SIMPLE==mem_space->type); + assert (numbering); + assert (nelmts>0); + assert (tconv_buf); + + /* + * The prototype doesn't support strip mining. + */ + assert (0==start); + assert (nelmts==H5S_get_npoints (mem_space)); + + /* + * Retrieve hyperslab information to determine what elements are being + * selected (there might be other selection methods in the future). We + * only handle hyperslabs with unit sample because there's currently no + * way to pass sample information to H5V_hyper_copy(). + */ +#ifdef LATER + if ((space_ndims=H5S_get_hyperslab (mem_space, mem_offset, hsize, + sample))<0) { + HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, 0, + "unable to retrieve hyperslab parameters"); + } +#else + if ((space_ndims=H5S_get_hyperslab (mem_space, mem_offset_signed, + hsize, sample))<0) { + HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, + "unable to retrieve hyperslab parameters"); + } + for (i=0; i=0); + mem_offset[i] = mem_offset_signed[i]; + } +#endif + for (i=0; i0); + assert (file_space); + assert (numbering); + assert (nelmts>0); + assert (buf); + + /* + * The prototype doesn't support strip mining. + */ + assert (0==start); + assert (nelmts==H5S_get_npoints (file_space)); + + /* + * Get hyperslab information to determine what elements are being + * selected (there might eventually be other selection methods too). + * We only support hyperslabs with unit sample because there's no way to + * currently pass sample information into H5F_arr_read() much less + * H5F_istore_read(). + */ +#ifdef LATER + if ((space_ndims=H5S_get_hyperslab (file_space, file_offset, hsize, + sample))<0) { + HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, + "unable to retrieve hyperslab parameters"); + } +#else + if ((space_ndims=H5S_get_hyperslab (file_space, file_offset_signed, + hsize, sample))<0) { + HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, + "unable to retrieve hyperslab parameters"); + } + for (i=0; i=0); + file_offset[i] = file_offset_signed[i]; + } +#endif + for (i=0; indims*sizeof(size_t)); + + /* + * Scatter to file. + */ + if (H5F_arr_write (f, layout, hsize, hsize, zero, file_offset, buf)<0) { + HRETURN_ERROR (H5E_DATASPACE, H5E_WRITEERROR, FAIL, "write error"); + } + + FUNC_LEAVE (SUCCEED); +} diff --git a/src/H5T.c b/src/H5T.c index 49a0019..b34860b 100644 --- a/src/H5T.c +++ b/src/H5T.c @@ -22,7 +22,7 @@ static char RcsId[] = "@(#)$Revision$"; #include /*error handling */ #include /*meta data */ #include /*memory management */ -#include /*data space */ +#include /*data space */ #include /*data-type functions */ #define PABLO_MASK H5T_mask diff --git a/src/Makefile.in b/src/Makefile.in index 6780aa1..d84fcb1 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -20,7 +20,7 @@ LIB_SRC=H5.c H5A.c H5AC.c H5B.c H5C.c H5D.c H5E.c H5F.c H5Farray.c H5Fcore.c \ H5Ffamily.c H5Fistore.c H5Flow.c H5Fsec2.c H5Fsplit.c H5Fstdio.c \ H5G.c H5Gent.c H5Gnode.c H5Gstab.c H5H.c H5M.c H5MF.c H5MM.c H5O.c \ H5Ocont.c H5Odtype.c H5Oefl.c H5Olayout.c H5Oname.c H5Onull.c \ - H5Osdspace.c H5Ostab.c H5P.c H5Psimp.c H5T.c H5Tconv.c H5Tinit.c \ + H5Osdspace.c H5Ostab.c H5S.c H5Ssimp.c H5T.c H5Tconv.c H5Tinit.c \ H5V.c @PARALLEL_SRC@ LIB_OBJ=$(LIB_SRC:.c=.o) @@ -35,14 +35,14 @@ PROG_OBJ=$(PROG_SRC:.c=.o) # Public header files (to be installed)... PUB_HDR=H5public.h H5Apublic.h H5ACpublic.h H5Bpublic.h H5Cpublic.h \ H5Dpublic.h H5Epublic.h H5Fpublic.h H5Gpublic.h H5Hpublic.h \ - H5Mpublic.h H5MFpublic.h H5MMpublic.h H5Opublic.h H5Ppublic.h \ + H5Mpublic.h H5MFpublic.h H5MMpublic.h H5Opublic.h H5Spublic.h \ H5Tpublic.h H5config.h hdf5.h # Other header files (not to be installed)... PRIVATE_HDR=H5private.h H5Aprivate.h H5ACprivate.h H5Bprivate.h \ H5Cprivate.h H5Dprivate.h H5Eprivate.h H5Fprivate.h H5Gprivate.h \ H5Gpkg.h H5Hprivate.h H5Mprivate.h H5MFprivate.h H5MMprivate.h \ - H5Oprivate.h H5Pprivate.h H5Tprivate.h H5Tpkg.h H5Vprivate.h + H5Oprivate.h H5Sprivate.h H5Tprivate.h H5Tpkg.h H5Vprivate.h # Number format detection H5Tinit.c: H5detect diff --git a/src/hdf5.h b/src/hdf5.h index 39be4a5..a5d8f19 100644 --- a/src/hdf5.h +++ b/src/hdf5.h @@ -32,6 +32,6 @@ #include #include #include -#include +#include #include #endif diff --git a/test/Makefile.in b/test/Makefile.in index 76cc68d..3c61e91 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -16,17 +16,17 @@ TESTS=$(PROGS) # Temporary files MOSTLYCLEAN=cmpd_dset.h5 dataset.h5 extend.h5 istore.h5 tfile1.h5 tfile2.h5 \ - tfile3.h5 th5p1.h5 theap.h5 tohdr.h5 tstab1.h5 tstab2.h5 + tfile3.h5 th5s1.h5 theap.h5 tohdr.h5 tstab1.h5 tstab2.h5 # Source and object files for programs... The PROG_SRC list contains all the # source files and is used for things like dependencies, archiving, etc. The # other source lists are for the individual tests, the files of which may # overlap with other tests. -PROG_SRC=testhdf5.c tfile.c theap.c tmeta.c tohdr.c tstab.c th5p.c dtypes.c \ +PROG_SRC=testhdf5.c tfile.c theap.c tmeta.c tohdr.c tstab.c th5s.c dtypes.c \ hyperslab.c istore.c dsets.c cmpd_dset.c extend.c PROG_OBJ=$(PROG_SRC:.c=.o) -TESTHDF5_SRC=testhdf5.c tfile.c theap.c tmeta.c tohdr.c tstab.c th5p.c +TESTHDF5_SRC=testhdf5.c tfile.c theap.c tmeta.c tohdr.c tstab.c th5s.c TESTHDF5_OBJ=$(TESTHDF5_SRC:.c=.o) DSETS_SRC=dsets.c diff --git a/test/cmpd_dset.c b/test/cmpd_dset.c index 6ad4b31..aad6339 100644 --- a/test/cmpd_dset.c +++ b/test/cmpd_dset.c @@ -134,7 +134,7 @@ main (void) assert (file>=0); /* Create the data space */ - space = H5Pcreate_simple (2, dim, NULL); + space = H5Screate_simple (2, dim, NULL); assert (space>=0); @@ -170,7 +170,7 @@ STEP 1: Initialize dataset `s1' and store it on disk in native order.\n"); assert (dataset>=0); /* Write the data */ - status = H5Dwrite (dataset, s1_tid, H5P_ALL, H5P_ALL, H5C_DEFAULT, s1); + status = H5Dwrite (dataset, s1_tid, H5S_ALL, H5S_ALL, H5C_DEFAULT, s1); assert (status>=0); /* @@ -195,7 +195,7 @@ STEP 2: Read the dataset from disk into a new memory buffer which has the\n\ assert (s2_tid>=0); /* Read the data */ - status = H5Dread (dataset, s2_tid, H5P_ALL, H5P_ALL, H5C_DEFAULT, s2); + status = H5Dread (dataset, s2_tid, H5S_ALL, H5S_ALL, H5C_DEFAULT, s2); assert (status>=0); /* Compare s2 with s1. They should be the same */ @@ -227,7 +227,7 @@ STEP 3: Read the dataset again with members in a different order.\n"); assert (s3_tid>=0); /* Read the data */ - status = H5Dread (dataset, s3_tid, H5P_ALL, H5P_ALL, H5C_DEFAULT, s3); + status = H5Dread (dataset, s3_tid, H5S_ALL, H5S_ALL, H5C_DEFAULT, s3); assert (status>=0); /* Compare s3 with s1. They should be the same */ @@ -255,7 +255,7 @@ STEP 4: Read a subset of the members.\n"); assert (s4_tid>=0); /* Read the data */ - status = H5Dread (dataset, s4_tid, H5P_ALL, H5P_ALL, H5C_DEFAULT, s4); + status = H5Dread (dataset, s4_tid, H5S_ALL, H5S_ALL, H5C_DEFAULT, s4); assert (status>=0); /* Compare s4 with s1 */ @@ -291,7 +291,7 @@ STEP 5: Read members into a superset which is partially initialized.\n"); assert (s5_tid>=0); /* Read the data */ - status = H5Dread (dataset, s5_tid, H5P_ALL, H5P_ALL, H5C_DEFAULT, s5); + status = H5Dread (dataset, s5_tid, H5S_ALL, H5S_ALL, H5C_DEFAULT, s5); assert (status>=0); /* Check that the data was read properly */ @@ -329,11 +329,11 @@ STEP 6: Update fields `b' and `d' on the file, leaving the other fields\n\ } /* Write the data to file */ - status = H5Dwrite (dataset, s4_tid, H5P_ALL, H5P_ALL, H5C_DEFAULT, s4); + status = H5Dwrite (dataset, s4_tid, H5S_ALL, H5S_ALL, H5C_DEFAULT, s4); assert (status>=0); /* Read the data back */ - status = H5Dread (dataset, s1_tid, H5P_ALL, H5P_ALL, H5C_DEFAULT, s1); + status = H5Dread (dataset, s1_tid, H5S_ALL, H5S_ALL, H5C_DEFAULT, s1); assert (status>=0); /* Compare */ @@ -356,11 +356,11 @@ STEP 7: Reading original dataset with explicit data space.\n"); fflush (stdout); /* Create the data space */ - s7_sid = H5Pcreate_simple (2, dim, NULL); + s7_sid = H5Screate_simple (2, dim, NULL); assert (s7_sid>=0); /* Read the dataset */ - status = H5Dread (dataset, s2_tid, s7_sid, H5P_ALL, H5C_DEFAULT, s2); + status = H5Dread (dataset, s2_tid, s7_sid, H5S_ALL, H5C_DEFAULT, s2); assert (status>=0); /* Compare */ @@ -391,11 +391,11 @@ STEP 8: Read middle third hyperslab into memory array.\n"); h_size[1] = 2*NY/3 - f_offset[1]; h_sample[0] = 1; h_sample[1] = 1; - status = H5Pset_hyperslab (s8_f_sid, f_offset, h_size, h_sample); + status = H5Sset_hyperslab (s8_f_sid, f_offset, h_size, h_sample); assert (status>=0); /* Create memory data space */ - s8_m_sid = H5Pcreate_simple (2, h_size, NULL); + s8_m_sid = H5Screate_simple (2, h_size, NULL); assert (s8_m_sid>=0); /* Read the dataset */ @@ -518,7 +518,7 @@ STEP 11: Write an array back to the middle third of the dataset to\n\ fflush (stdout); /* Create the memory array and initialize all fields to zero */ - ndims = H5Pget_hyperslab (s8_f_sid, f_offset, h_size, h_sample); + ndims = H5Sget_hyperslab (s8_f_sid, f_offset, h_size, h_sample); assert (ndims==2); s11 = malloc (h_size[0]*h_size[1]*sizeof(s4_t)); assert (s11); @@ -529,7 +529,7 @@ STEP 11: Write an array back to the middle third of the dataset to\n\ assert (status>=0); /* Read the whole thing */ - status = H5Dread (dataset, s1_tid, H5P_ALL, H5P_ALL, H5C_DEFAULT, s1); + status = H5Dread (dataset, s1_tid, H5S_ALL, H5S_ALL, H5C_DEFAULT, s1); assert (status>=0); /* Compare */ diff --git a/test/dsets.c b/test/dsets.c index 8261103..16cd541 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -57,7 +57,7 @@ test_create(hid_t file) /* Create the data space */ dims[0] = 256; dims[1] = 512; - space = H5Pcreate_simple(2, dims, NULL); + space = H5Screate_simple(2, dims, NULL); assert(space != FAIL); /* @@ -209,7 +209,7 @@ test_simple_io(hid_t file) /* Create the data space */ dims[0] = 100; dims[1] = 200; - space = H5Pcreate_simple(2, dims, NULL); + space = H5Screate_simple(2, dims, NULL); assert(space != FAIL); /* Create the dataset */ @@ -218,7 +218,7 @@ test_simple_io(hid_t file) assert(dataset >= 0); /* Write the data to the dataset */ - status = H5Dwrite(dataset, H5T_NATIVE_INT, H5P_ALL, H5P_ALL, + status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5C_DEFAULT, points); if (status < 0) { puts("*FAILED*"); @@ -229,7 +229,7 @@ test_simple_io(hid_t file) goto error; } /* Read the dataset back */ - status = H5Dread(dataset, H5T_NATIVE_INT, H5P_ALL, H5P_ALL, + status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5C_DEFAULT, check); if (status < 0) { puts("*FAILED*"); @@ -301,7 +301,7 @@ test_tconv(hid_t file) /* Create the data space */ dims[0] = 1000000; - space = H5Pcreate_simple (1, dims, NULL); + space = H5Screate_simple (1, dims, NULL); assert(space != FAIL); /* Create the data set */ @@ -310,7 +310,7 @@ test_tconv(hid_t file) assert(dataset >= 0); /* Write the data to the dataset */ - status = H5Dwrite(dataset, H5T_NATIVE_INT32, H5P_ALL, H5P_ALL, + status = H5Dwrite(dataset, H5T_NATIVE_INT32, H5S_ALL, H5S_ALL, H5C_DEFAULT, out); if (status<0) H5Eprint (H5E_thrdid_g, stdout); assert(status >= 0); @@ -330,7 +330,7 @@ test_tconv(hid_t file) } /* Read data with byte order conversion */ - status = H5Dread(dataset, type, H5P_ALL, H5P_ALL, H5C_DEFAULT, in); + status = H5Dread(dataset, type, H5S_ALL, H5S_ALL, H5C_DEFAULT, in); assert(status >= 0); /* Check */ diff --git a/test/dspace.c b/test/dspace.c index 54fa17f..e833995 100644 --- a/test/dspace.c +++ b/test/dspace.c @@ -5,7 +5,7 @@ * Programmer: Robb Matzke * Tuesday, December 9, 1997 * - * Purpose: Tests the data space interface (H5P). + * Purpose: Tests the data space interface (H5S). */ int diff --git a/test/extend.c b/test/extend.c index 7de127e..a3562fa 100644 --- a/test/extend.c +++ b/test/extend.c @@ -40,7 +40,7 @@ main (void) static const size_t dims[2] = {NX, NY}; static const size_t half_dims[2] = {NX/2, NY/2}; static const size_t chunk_dims[2] = {NX/2, NY/2}; - static size_t maxdims[2] = {H5P_UNLIMITED, H5P_UNLIMITED}; + static size_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; static size_t size[2]; int offset[2]; @@ -50,7 +50,7 @@ main (void) buf1[i][j] = i*NY+j; } } - mem_space = H5Pcreate_simple (2, dims, maxdims); + mem_space = H5Screate_simple (2, dims, maxdims); assert (mem_space>=0); /* Create the file */ @@ -80,21 +80,21 @@ main (void) /* Select a hyperslab */ file_space = H5Dget_space (dataset); assert (file_space>=0); - status = H5Pset_hyperslab (file_space, offset, dims, NULL); + status = H5Sset_hyperslab (file_space, offset, dims, NULL); assert (status>=0); /* Write to the hyperslab */ status = H5Dwrite (dataset, H5T_NATIVE_INT, mem_space, file_space, H5C_DEFAULT, buf1); assert (status>=0); - H5Pclose (file_space); + H5Sclose (file_space); } } - H5Pclose (mem_space); + H5Sclose (mem_space); /* Read the data */ - mem_space = H5Pcreate_simple (2, half_dims, NULL); + mem_space = H5Screate_simple (2, half_dims, NULL); file_space = H5Dget_space (dataset); for (i=0; i<10; i++) { for (j=0; j<10; j++) { @@ -103,7 +103,7 @@ main (void) offset[0] = i * NX/2; offset[1] = j * NY/2; assert (file_space>=0); - status = H5Pset_hyperslab (file_space, offset, half_dims, NULL); + status = H5Sset_hyperslab (file_space, offset, half_dims, NULL); assert (status>=0); /* Read */ diff --git a/test/th5p.c b/test/th5p.c deleted file mode 100644 index e856e3c..0000000 --- a/test/th5p.c +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************** - * NCSA HDF * - * Software Development Group * - * National Center for Supercomputing Applications * - * University of Illinois at Urbana-Champaign * - * 605 E. Springfield, Champaign IL 61820 * - * * - * For conditions of distribution and use, see the accompanying * - * hdf/COPYING file. * - * * - ****************************************************************************/ - -#ifdef RCSID -static char RcsId[] = "$Revision$"; -#endif - -/* $Id$ */ - -/*********************************************************** -* -* Test program: th5p -* -* Test the dataspace functionality -* -*************************************************************/ - -#include - -#include -#include -#include -#include - -#define FILE "th5p1.h5" - -/* 3-D dataset with fixed dimensions */ -#define SPACE1_NAME "Space1" -#define SPACE1_RANK 3 -#define SPACE1_DIM1 3 -#define SPACE1_DIM2 15 -#define SPACE1_DIM3 13 - -/* 4-D dataset with one unlimited dimension */ -#define SPACE2_NAME "Space2" -#define SPACE2_RANK 4 -#define SPACE2_DIM1 0 -#define SPACE2_DIM2 15 -#define SPACE2_DIM3 13 -#define SPACE2_DIM4 23 - -/**************************************************************** -** -** test_h5p_basic(): Test basic H5P (dataspace) code. -** -****************************************************************/ -static void -test_h5p_basic(void) -{ - hid_t fid1; /* HDF5 File IDs */ - hid_t sid1, sid2; /* Dataspace ID */ - uint32 rank; /* Logical rank of dataspace */ - size_t dims1[] = - {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}, /* dataspace dim sizes */ - dims2[] = - {SPACE2_DIM1, SPACE2_DIM2, SPACE2_DIM3, SPACE2_DIM4}, tdims[4]; /* Dimension array to test with */ - size_t n; /* number of dataspace elements */ - herr_t ret; /* Generic return value */ - - /* Output message about test being performed */ - MESSAGE(5, ("Testing Datatype Manipulation\n")); - - /* Create file */ - fid1 = H5Fcreate(FILE, H5F_ACC_TRUNC, H5C_DEFAULT, H5C_DEFAULT); - CHECK(fid1, FAIL, "H5Fcreate"); - - sid1 = H5Pcreate_simple(SPACE1_RANK, dims1, NULL); - CHECK(sid1, FAIL, "H5Pcreate_simple"); - - n = H5Pget_npoints(sid1); - CHECK(n, UFAIL, "H5Pget_npoints"); - VERIFY(n, SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3, "H5Pget_npoints"); - - rank = H5Pget_ndims(sid1); - CHECK(rank, UFAIL, "H5Pget_lrank"); - VERIFY(rank, SPACE1_RANK, "H5Pget_lrank"); - - ret = H5Pget_dims(sid1, tdims); - CHECK(ret, FAIL, "H5Pget_ldims"); - VERIFY(HDmemcmp(tdims, dims1, SPACE1_RANK * sizeof(uint32)), 0, "H5Pget_ldims"); - - sid2 = H5Pcreate_simple(SPACE2_RANK, dims2, NULL); - CHECK(sid2, FAIL, "H5Pcreate_simple"); - - n = H5Pget_npoints(sid2); - CHECK(n, UFAIL, "H5Pnelem"); - VERIFY(n, SPACE2_DIM1 * SPACE2_DIM2 * SPACE2_DIM3 * SPACE2_DIM4, "H5Pnelem"); - - rank = H5Pget_ndims(sid2); - CHECK(rank, UFAIL, "H5Pget_lrank"); - VERIFY(rank, SPACE2_RANK, "H5Pget_lrank"); - - ret = H5Pget_dims(sid2, tdims); - CHECK(ret, FAIL, "H5Pget_ldims"); - VERIFY(HDmemcmp(tdims, dims2, SPACE2_RANK * sizeof(uint32)), 0, "H5Pget_ldims"); - - ret = H5Mclose(sid1); - CHECK(ret, FAIL, "H5Mrelease"); - - ret = H5Mclose(sid2); - CHECK(ret, FAIL, "H5Mrelease"); - - /* Close first file */ - ret = H5Fclose(fid1); - CHECK(ret, FAIL, "H5Fclose"); -} /* test_h5p_basic() */ - -/**************************************************************** -** -** test_h5p(): Main H5P (dataspace) testing routine. -** -****************************************************************/ -void -test_h5p(void) -{ - /* Output message about test being performed */ - MESSAGE(5, ("Testing Dataspaces\n")); - - test_h5p_basic(); /* Test basic H5P code */ -} /* test_h5p() */ diff --git a/test/th5s.c b/test/th5s.c new file mode 100644 index 0000000..faafd5e --- /dev/null +++ b/test/th5s.c @@ -0,0 +1,129 @@ +/**************************************************************************** + * NCSA HDF * + * Software Development Group * + * National Center for Supercomputing Applications * + * University of Illinois at Urbana-Champaign * + * 605 E. Springfield, Champaign IL 61820 * + * * + * For conditions of distribution and use, see the accompanying * + * hdf/COPYING file. * + * * + ****************************************************************************/ + +#ifdef RCSID +static char RcsId[] = "$Revision$"; +#endif + +/* $Id$ */ + +/*********************************************************** +* +* Test program: th5p +* +* Test the dataspace functionality +* +*************************************************************/ + +#include + +#include +#include +#include +#include + +#define FILE "th5p1.h5" + +/* 3-D dataset with fixed dimensions */ +#define SPACE1_NAME "Space1" +#define SPACE1_RANK 3 +#define SPACE1_DIM1 3 +#define SPACE1_DIM2 15 +#define SPACE1_DIM3 13 + +/* 4-D dataset with one unlimited dimension */ +#define SPACE2_NAME "Space2" +#define SPACE2_RANK 4 +#define SPACE2_DIM1 0 +#define SPACE2_DIM2 15 +#define SPACE2_DIM3 13 +#define SPACE2_DIM4 23 + +/**************************************************************** +** +** test_h5p_basic(): Test basic H5S (dataspace) code. +** +****************************************************************/ +static void +test_h5p_basic(void) +{ + hid_t fid1; /* HDF5 File IDs */ + hid_t sid1, sid2; /* Dataspace ID */ + uint32 rank; /* Logical rank of dataspace */ + size_t dims1[] = + {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}, /* dataspace dim sizes */ + dims2[] = + {SPACE2_DIM1, SPACE2_DIM2, SPACE2_DIM3, SPACE2_DIM4}, tdims[4]; /* Dimension array to test with */ + size_t n; /* number of dataspace elements */ + herr_t ret; /* Generic return value */ + + /* Output message about test being performed */ + MESSAGE(5, ("Testing Datatype Manipulation\n")); + + /* Create file */ + fid1 = H5Fcreate(FILE, H5F_ACC_TRUNC, H5C_DEFAULT, H5C_DEFAULT); + CHECK(fid1, FAIL, "H5Fcreate"); + + sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL); + CHECK(sid1, FAIL, "H5Screate_simple"); + + n = H5Sget_npoints(sid1); + CHECK(n, UFAIL, "H5Sget_npoints"); + VERIFY(n, SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3, "H5Sget_npoints"); + + rank = H5Sget_ndims(sid1); + CHECK(rank, UFAIL, "H5Sget_lrank"); + VERIFY(rank, SPACE1_RANK, "H5Sget_lrank"); + + ret = H5Sget_dims(sid1, tdims); + CHECK(ret, FAIL, "H5Sget_ldims"); + VERIFY(HDmemcmp(tdims, dims1, SPACE1_RANK * sizeof(uint32)), 0, "H5Sget_ldims"); + + sid2 = H5Screate_simple(SPACE2_RANK, dims2, NULL); + CHECK(sid2, FAIL, "H5Screate_simple"); + + n = H5Sget_npoints(sid2); + CHECK(n, UFAIL, "H5Snelem"); + VERIFY(n, SPACE2_DIM1 * SPACE2_DIM2 * SPACE2_DIM3 * SPACE2_DIM4, "H5Snelem"); + + rank = H5Sget_ndims(sid2); + CHECK(rank, UFAIL, "H5Sget_lrank"); + VERIFY(rank, SPACE2_RANK, "H5Sget_lrank"); + + ret = H5Sget_dims(sid2, tdims); + CHECK(ret, FAIL, "H5Sget_ldims"); + VERIFY(HDmemcmp(tdims, dims2, SPACE2_RANK * sizeof(uint32)), 0, "H5Sget_ldims"); + + ret = H5Mclose(sid1); + CHECK(ret, FAIL, "H5Mrelease"); + + ret = H5Mclose(sid2); + CHECK(ret, FAIL, "H5Mrelease"); + + /* Close first file */ + ret = H5Fclose(fid1); + CHECK(ret, FAIL, "H5Fclose"); +} /* test_h5p_basic() */ + +/**************************************************************** +** +** test_h5p(): Main H5S (dataspace) testing routine. +** +****************************************************************/ +void +test_h5p(void) +{ + /* Output message about test being performed */ + MESSAGE(5, ("Testing Dataspaces\n")); + + test_h5p_basic(); /* Test basic H5S code */ +} /* test_h5p() */ -- cgit v0.12