From c543632ba5cd609d2e6303fa9cf55685568fa851 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 25 Feb 1998 14:13:49 -0500 Subject: [svn-r297] Switched templates to "property lists" and changed API prefix from H5C to H5P --- examples/h5_chunk_read.c | 14 +- examples/h5_compound.c | 12 +- examples/h5_extend_write.c | 12 +- examples/h5_group.c | 14 +- examples/h5_read.c | 4 +- examples/h5_write.c | 6 +- src/H5C.c | 1383 -------------------------------------------- src/H5Cprivate.h | 29 - src/H5Cpublic.h | 77 --- src/H5D.c | 22 +- src/H5F.c | 34 +- src/H5Fpublic.h | 6 +- src/H5M.c | 16 +- src/H5Mpublic.h | 2 +- src/H5P.c | 1383 ++++++++++++++++++++++++++++++++++++++++++++ src/H5Pprivate.h | 29 + src/H5Ppublic.h | 77 +++ src/Makefile.in | 6 +- src/debug.c | 4 +- src/hdf5.h | 24 +- test/cmpd_dset.c | 30 +- test/dsets.c | 22 +- test/extend.c | 10 +- test/istore.c | 6 +- test/tfile.c | 124 ++-- test/th5s.c | 2 +- test/theap.c | 4 +- test/tohdr.c | 4 +- test/tstab.c | 16 +- 29 files changed, 1686 insertions(+), 1686 deletions(-) delete mode 100644 src/H5C.c delete mode 100644 src/H5Cprivate.h delete mode 100644 src/H5Cpublic.h create mode 100644 src/H5P.c create mode 100644 src/H5Pprivate.h create mode 100644 src/H5Ppublic.h diff --git a/examples/h5_chunk_read.c b/examples/h5_chunk_read.c index 916383b..6668c5c 100644 --- a/examples/h5_chunk_read.c +++ b/examples/h5_chunk_read.c @@ -40,7 +40,7 @@ main () /* * Open the file and the dataset. */ -file = H5Fopen(FILE, H5F_ACC_RDONLY, H5C_DEFAULT); +file = H5Fopen(FILE, H5F_ACC_RDONLY, H5P_DEFAULT); dataset = H5Dopen(file, DATASETNAME); /* @@ -60,12 +60,12 @@ cparms = H5Dget_create_parms(dataset); /* Get properties handle first. */ /* * Check if dataset is chunked. */ - if (H5D_CHUNKED == H5Cget_layout(cparms)) { + if (H5D_CHUNKED == H5Pget_layout(cparms)) { /* * Get chunking information: rank and dimensions */ -rank_chunk = H5Cget_chunk(cparms, 2, chunk_dims); +rank_chunk = H5Pget_chunk(cparms, 2, chunk_dims); printf("chunk rank %d, dimensions %d x %d \n", rank_chunk, chunk_dims[0], chunk_dims[1]); } @@ -79,7 +79,7 @@ memspace = H5Screate_simple(RANK,dims,NULL); * Read dataset back and display. */ status = H5Dread(dataset, H5T_NATIVE_INT, memspace, filespace, - H5C_DEFAULT, data_out); + H5P_DEFAULT, data_out); printf("\n"); printf("Dataset: \n"); for (j = 0; j < dims[0]; j++) { @@ -121,7 +121,7 @@ count[0] = 10; count[1] = 1; status = H5Sset_hyperslab(filespace, offset, count, NULL); status = H5Dread(dataset, H5T_NATIVE_INT, memspace, filespace, - H5C_DEFAULT, column); + H5P_DEFAULT, column); printf("\n"); printf("Third column: \n"); for (i = 0; i < 10; i++) { @@ -161,7 +161,7 @@ status = H5Sset_hyperslab(filespace, offset, count, NULL); * Read chunk back and display. */ status = H5Dread(dataset, H5T_NATIVE_INT, memspace, filespace, - H5C_DEFAULT, chunk_out); + H5P_DEFAULT, chunk_out); printf("\n"); printf("Chunk: \n"); for (j = 0; j < chunk_dims[0]; j++) { @@ -177,7 +177,7 @@ for (j = 0; j < chunk_dims[0]; j++) { /* * Close/release resources. */ -H5Cclose(cparms); +H5Pclose(cparms); H5Dclose(dataset); H5Sclose(filespace); H5Sclose(memspace); diff --git a/examples/h5_compound.c b/examples/h5_compound.c index 91061cf..1abd4c2 100644 --- a/examples/h5_compound.c +++ b/examples/h5_compound.c @@ -62,7 +62,7 @@ space = H5Screate_simple(RANK, dim, NULL); /* * Create the file. */ -file = H5Fcreate(FILE, H5F_ACC_TRUNC, H5C_DEFAULT, H5C_DEFAULT); +file = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* * Create the memory data type. @@ -75,12 +75,12 @@ status = H5Tinsert(s1_tid, "b_name", HPOFFSET(s1, b), H5T_NATIVE_FLOAT); /* * Create the dataset. */ -dataset = H5Dcreate(file, DATASETNAME, s1_tid, space, H5C_DEFAULT); +dataset = H5Dcreate(file, DATASETNAME, s1_tid, space, H5P_DEFAULT); /* * Wtite data to the dataset; */ -status = H5Dwrite(dataset, s1_tid, H5S_ALL, H5S_ALL, H5C_DEFAULT, s1); +status = H5Dwrite(dataset, s1_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, s1); /* * Release resources @@ -93,7 +93,7 @@ H5Fclose(file); /* * Open the file and the dataset. */ -file = H5Fopen(FILE, H5F_ACC_RDONLY, H5C_DEFAULT); +file = H5Fopen(FILE, H5F_ACC_RDONLY, H5P_DEFAULT); dataset = H5Dopen(file, DATASETNAME); @@ -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, H5S_ALL, H5S_ALL, H5C_DEFAULT, s2); +status = H5Dread(dataset, s2_tid, H5S_ALL, H5S_ALL, H5P_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, H5S_ALL, H5S_ALL, H5C_DEFAULT, s3); +status = H5Dread(dataset, s3_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, s3); /* * Display the field diff --git a/examples/h5_extend_write.c b/examples/h5_extend_write.c index 1d0438b..2417cc0 100644 --- a/examples/h5_extend_write.c +++ b/examples/h5_extend_write.c @@ -49,13 +49,13 @@ dataspace = H5Screate_simple(RANK, dims, maxdims); /* * Create a new file. If file exists its contents will be overwritten. */ -file = H5Fcreate(FILE, H5F_ACC_TRUNC, H5C_DEFAULT, H5C_DEFAULT); +file = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* * Modify dataset creation properties, i.e. enable chunking. */ -cparms = H5Ccreate (H5C_DATASET_CREATE); -status = H5Cset_chunk( cparms, RANK, chunk_dims); +cparms = H5Pcreate (H5P_DATASET_CREATE); +status = H5Pset_chunk( cparms, RANK, chunk_dims); /* * Create a new dataset within the file using cparms @@ -83,7 +83,7 @@ status = H5Sset_hyperslab(filespace, offset, dims1, NULL); * Write the data to the hyperslab. */ status = H5Dwrite(dataset, H5T_NATIVE_INT, dataspace, filespace, - H5C_DEFAULT, data1); + H5P_DEFAULT, data1); /* * Extend the dataset. Dataset becomes 10 x 3. @@ -110,7 +110,7 @@ dataspace = H5Screate_simple(RANK, dims2, NULL); * Write the data to the hyperslab. */ status = H5Dwrite(dataset, H5T_NATIVE_INT, dataspace, filespace, - H5C_DEFAULT, data2); + H5P_DEFAULT, data2); /* * Extend the dataset. Dataset becomes 10 x 5. @@ -137,7 +137,7 @@ dataspace = H5Screate_simple(RANK, dims3, NULL); * Write the data to the hyperslab. */ status = H5Dwrite(dataset, H5T_NATIVE_INT, dataspace, filespace, - H5C_DEFAULT, data3); + H5P_DEFAULT, data3); /* * Resulting dataset diff --git a/examples/h5_group.c b/examples/h5_group.c index 303ce99..9835bcf 100644 --- a/examples/h5_group.c +++ b/examples/h5_group.c @@ -23,7 +23,7 @@ main() /* * Create a file. */ -file = H5Fcreate(FILE, H5F_ACC_TRUNC, H5C_DEFAULT, H5C_DEFAULT); +file = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* * Create two groups in a file. @@ -43,21 +43,21 @@ dataspace = H5Screate_simple(1, size, NULL); /* * Create dataset "String" in the root group. */ -dataset = H5Dcreate(file, "String", H5T_NATIVE_CHAR, dataspace, H5C_DEFAULT); +dataset = H5Dcreate(file, "String", H5T_NATIVE_CHAR, dataspace, H5P_DEFAULT); H5Dclose(dataset); /* * Create dataset "String" in the /IntData group. */ dataset = H5Dcreate(file, "/IntData/String", H5T_NATIVE_CHAR, dataspace, - H5C_DEFAULT); + H5P_DEFAULT); H5Dclose(dataset); /* * Create dataset "String" in the /FloatData group. */ dataset = H5Dcreate(file, "/FloatData/String", H5T_NATIVE_CHAR, dataspace, - H5C_DEFAULT); + H5P_DEFAULT); H5Sclose(dataspace); H5Dclose(dataset); @@ -68,7 +68,7 @@ dims[0] = 2; dims[1] = 3; dataspace = H5Screate_simple(RANK, dims, NULL); dataset = H5Dcreate(file, "/IntData/IntArray", H5T_NATIVE_INT, dataspace, - H5C_DEFAULT); + H5P_DEFAULT); H5Sclose(dataspace); H5Dclose(dataset); @@ -93,7 +93,7 @@ status = H5Gset (file, "/FloatData"); dims[0] = 5; dims[1] = 10; dataspace = H5Screate_simple(RANK, dims, NULL); -dataset = H5Dcreate(file, "FloatArray", H5T_NATIVE_FLOAT, dataspace, H5C_DEFAULT); +dataset = H5Dcreate(file, "FloatArray", H5T_NATIVE_FLOAT, dataspace, H5P_DEFAULT); H5Sclose(dataspace); H5Dclose(dataset); @@ -101,7 +101,7 @@ dims[0] = 4; dims[1] = 6; dataspace = H5Screate_simple(RANK, dims, NULL); dataset = H5Dcreate(file, "DoubleArray", H5T_NATIVE_DOUBLE, dataspace, - H5C_DEFAULT); + H5P_DEFAULT); H5Sclose(dataspace); H5Dclose(dataset); diff --git a/examples/h5_read.c b/examples/h5_read.c index d95dbe2..8384af9 100644 --- a/examples/h5_read.c +++ b/examples/h5_read.c @@ -48,7 +48,7 @@ for (j = 0; j < NX; j++) { /* * Open the file and the dataset. */ -file = H5Fopen(FILE, H5F_ACC_RDONLY, H5C_DEFAULT); +file = H5Fopen(FILE, H5F_ACC_RDONLY, H5P_DEFAULT); dataset = H5Dopen(file, DATASETNAME); /* @@ -103,7 +103,7 @@ status = H5Sset_hyperslab(memspace, offset_out, count_out, NULL); * memory and display. */ status = H5Dread(dataset, H5T_NATIVE_INT, memspace, dataspace, - H5C_DEFAULT, data_out); + H5P_DEFAULT, data_out); for (j = 0; j < NX; j++) { for (i = 0; i < NY; i++) printf("%d ", data_out[j][i][0]); printf("\n"); diff --git a/examples/h5_write.c b/examples/h5_write.c index 088810d..98e321f 100644 --- a/examples/h5_write.c +++ b/examples/h5_write.c @@ -39,7 +39,7 @@ for (j = 0; j < NX; j++) { * default file creation properties, and default file * access properties. */ -file = H5Fcreate(FILE, H5F_ACC_TRUNC, H5C_DEFAULT, H5C_DEFAULT); +file = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* * Describe the size of the array and create the data space for fixed @@ -60,13 +60,13 @@ status = H5Tset_order(datatype, H5T_ORDER_LE); * datatype and default dataset creation properties. */ dataset = H5Dcreate(file, DATASETNAME, datatype, dataspace, - H5C_DEFAULT); + H5P_DEFAULT); /* * Write the data to the dataset using default transfer properties. */ status = H5Dwrite(dataset, H5T_NATIVE_INT32, H5S_ALL, H5S_ALL, - H5C_DEFAULT, data); + H5P_DEFAULT, data); /* * Close/release resources. diff --git a/src/H5C.c b/src/H5C.c deleted file mode 100644 index d549289..0000000 --- a/src/H5C.c +++ /dev/null @@ -1,1383 +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 - -/* Private header files */ -#include /* Generic Functions */ -#include /* Atoms */ -#include /* B-tree subclass names */ -#include /* Template information */ -#include /* Datasets */ -#include /* Error handling */ -#include /* Memory management */ - -#define PABLO_MASK H5C_mask - -/* Is the interface initialized? */ -static hbool_t interface_initialize_g = FALSE; -#define INTERFACE_INIT H5C_init_interface -static herr_t H5C_init_interface(void); - -/* PRIVATE PROTOTYPES */ -static void H5C_term_interface(void); - -/*-------------------------------------------------------------------------- -NAME - H5C_init_interface -- Initialize interface-specific information -USAGE - herr_t H5C_init_interface() - -RETURNS - SUCCEED/FAIL -DESCRIPTION - Initializes any interface-specific data or routines. - ---------------------------------------------------------------------------*/ -static herr_t -H5C_init_interface(void) -{ - herr_t ret_value = SUCCEED; - intn i; - herr_t status; - - FUNC_ENTER(H5C_init_interface, FAIL); - - /* - * Make sure the file creation and file access default templates are - * initialized since this might be done at run-time instead of compile - * time. - */ - if (H5F_init_interface ()<0) { - HRETURN_ERROR (H5E_INTERNAL, H5E_CANTINIT, FAIL, - "unable to initialize H5F and H5C interfaces"); - } - - assert(H5C_NCLASSES <= H5_TEMPLATE_MAX - H5_TEMPLATE_0); - - /* - * Initialize the mappings between template classes and atom groups. We - * keep the two separate because template classes are publicly visible but - * atom groups aren't. - */ - for (i = 0; i < H5C_NCLASSES; i++) { - status = H5A_init_group((group_t)(H5_TEMPLATE_0 +i), - H5A_TEMPID_HASHSIZE, 0, NULL); - if (status < 0) ret_value = FAIL; - } - if (ret_value < 0) { - HRETURN_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL, - "unable to initialize atom group"); - } - - /* - * Register cleanup function. - */ - if (H5_add_exit(H5C_term_interface) < 0) { - HRETURN_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, - "unable to install atexit function"); - } - - FUNC_LEAVE(ret_value); -} - -/*-------------------------------------------------------------------------- - NAME - H5C_term_interface - PURPOSE - Terminate various H5C objects - USAGE - void H5C_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 -H5C_term_interface(void) -{ - intn i; - - for (i = 0; i < H5C_NCLASSES; i++) { - H5A_destroy_group((group_t)(H5_TEMPLATE_0 + i)); - } -} - -/*-------------------------------------------------------------------------- - NAME - H5Ccreate - PURPOSE - Returns a copy of the default template for some class of templates. - USAGE - herr_t H5Ccreate (type) - H5C_class_t type; IN: Template class whose default is desired. - RETURNS - Template ID or FAIL - - ERRORS - ARGS BADVALUE Unknown template class. - ATOM CANTINIT Can't register template. - INTERNAL UNSUPPORTED Not implemented yet. - - DESCRIPTION - Returns a copy of the default template for some class of templates. ---------------------------------------------------------------------------*/ -hid_t -H5Ccreate(H5C_class_t type) -{ - hid_t ret_value = FAIL; - void *tmpl = NULL; - - FUNC_ENTER(H5Ccreate, FAIL); - - /* Allocate a new template and initialize it with default values */ - switch (type) { - case H5C_FILE_CREATE: - tmpl = H5MM_xmalloc(sizeof(H5F_create_t)); - memcpy(tmpl, &H5F_create_dflt, sizeof(H5F_create_t)); - break; - - case H5C_FILE_ACCESS: - tmpl = H5MM_xmalloc(sizeof(H5F_access_t)); - memcpy(tmpl, &H5F_access_dflt, sizeof(H5F_access_t)); - break; - - case H5C_DATASET_CREATE: - tmpl = H5MM_xmalloc(sizeof(H5D_create_t)); - memcpy(tmpl, &H5D_create_dflt, sizeof(H5D_create_t)); - break; - - case H5C_DATASET_XFER: - tmpl = H5MM_xmalloc(sizeof(H5D_xfer_t)); - memcpy(tmpl, &H5D_xfer_dflt, sizeof(H5D_xfer_t)); - break; - - default: - HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "unknown template class"); - } - - /* Atomize the new template */ - if ((ret_value = H5C_create(type, tmpl)) < 0) { - HRETURN_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL, - "can't register template"); - } - FUNC_LEAVE(ret_value); -} - -/*------------------------------------------------------------------------- - * Function: H5C_create - * - * Purpose: Given a pointer to some template struct, atomize the template - * and return its ID. The template memory is not copied, so the - * caller should not free it; it will be freed by H5C_release(). - * - * Return: Success: A new template ID. - * - * Failure: FAIL - * - * Programmer: Robb Matzke - * Wednesday, December 3, 1997 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -hid_t -H5C_create(H5C_class_t type, void *tmpl) -{ - hid_t ret_value = FAIL; - - FUNC_ENTER(H5C_create, FAIL); - - /* check args */ - assert(type >= 0 && type < H5C_NCLASSES); - assert(tmpl); - - /* Atomize the new template */ - if ((ret_value=H5A_register((group_t)(H5_TEMPLATE_0+type), tmpl)) < 0) { - HRETURN_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL, - "can't register template"); - } - - FUNC_LEAVE(ret_value); -} - -/*-------------------------------------------------------------------------- - NAME - H5Cclose - PURPOSE - Release access to a template object. - USAGE - herr_t H5Cclose(oid) - hid_t oid; IN: Template object to release access to - RETURNS - SUCCEED/FAIL - DESCRIPTION - This function releases access to a template object ---------------------------------------------------------------------------*/ -herr_t -H5Cclose(hid_t tid) -{ - H5C_class_t type; - void *tmpl = NULL; - - FUNC_ENTER(H5Cclose, FAIL); - - /* Check arguments */ - if ((type=H5Cget_class (tid))<0 || - NULL==(tmpl=H5A_object (tid))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); - } - - /* - * Chuck the object! When the reference count reaches zero then - * H5A_dec_ref() removes it from the group and we should free it. The - * free function is not registered as part of the group because it takes - * an extra argument. - */ - if (0==H5A_dec_ref(tid)) H5C_close (type, tmpl); - - FUNC_LEAVE (SUCCEED); -} - - -/*------------------------------------------------------------------------- - * Function: H5C_close - * - * Purpose: Closes a template and frees the memory associated with the - * template. - * - * Return: Success: SUCCEED - * - * Failure: FAIL - * - * Programmer: Robb Matzke - * Wednesday, February 18, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -herr_t -H5C_close (H5C_class_t type, void *tmpl) -{ - FUNC_ENTER (H5C_close, FAIL); - - /* Check args */ - assert (tmpl); - - /* Some templates may need to do special things */ - switch (type) { - case H5C_FILE_ACCESS: -#ifdef LATER - /* Need to free the COMM and INFO objects too. */ -#endif - break; - - case H5C_FILE_CREATE: - case H5C_DATASET_CREATE: - case H5C_DATASET_XFER: - /*nothing to do*/ - break; - - default: - HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, - "unknown property list class"); - } - - /* Free the template struct and return */ - H5MM_xfree(tmpl); - FUNC_LEAVE(SUCCEED); -} - - -/*------------------------------------------------------------------------- - * Function: H5Cget_class - * - * Purpose: Returns the class identifier for a template. - * - * Return: Success: A template class - * - * Failure: H5C_NO_CLASS (-1) - * - * Programmer: Robb Matzke - * Wednesday, December 3, 1997 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -H5C_class_t -H5Cget_class(hid_t tid) -{ - group_t group; - H5C_class_t ret_value = H5C_NO_CLASS; - - FUNC_ENTER(H5Cget_class, H5C_NO_CLASS); - - if ((group = H5A_group(tid)) < 0 || -#ifndef NDEBUG - group >= H5_TEMPLATE_MAX || -#endif - group < H5_TEMPLATE_0) { - HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, H5C_NO_CLASS, "not a template"); - } - ret_value = (H5C_class_t)(group - H5_TEMPLATE_0); - FUNC_LEAVE(ret_value); -} - -/*------------------------------------------------------------------------- - * Function: H5Cget_version - * - * Purpose: Retrieves version information for various parts of a file. - * - * BOOT: The file boot block. - * HEAP: The global heap. - * FREELIST: The global free list. - * STAB: The root symbol table entry. - * SHHDR: Shared object headers. - * - * Any (or even all) of the output arguments can be null - * pointers. - * - * Return: Success: SUCCEED, version information is returned - * through the arguments. - * - * Failure: FAIL - * - * Programmer: Robb Matzke - * Wednesday, January 7, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -herr_t -H5Cget_version(hid_t tid, int *boot /*out */ , int *heap /*out */ , - int *freelist /*out */ , int *stab /*out */ , int *shhdr /*out */ ) -{ - H5F_create_t *tmpl = NULL; - - FUNC_ENTER(H5Cget_version, FAIL); - - /* Check arguments */ - if (H5C_FILE_CREATE != H5Cget_class(tid) || - NULL == (tmpl = H5A_object(tid))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "not a file creation template"); - } - /* Get values */ - if (boot) - *boot = tmpl->bootblock_ver; - if (heap) - *heap = tmpl->smallobject_ver; - if (freelist) - *freelist = tmpl->freespace_ver; - if (stab) - *stab = tmpl->objectdir_ver; - if (shhdr) - *shhdr = tmpl->sharedheader_ver; - - FUNC_LEAVE(SUCCEED); -} - -/*------------------------------------------------------------------------- - * Function: H5Cset_userblock - * - * Purpose: Sets the userblock size field of a file creation template. - * - * Return: Success: SUCCEED - * - * Failure: FAIL - * - * Programmer: Robb Matzke - * Tuesday, January 6, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -herr_t -H5Cset_userblock(hid_t tid, size_t size) -{ - intn i; - H5F_create_t *tmpl = NULL; - - FUNC_ENTER(H5Cset_userblock, FAIL); - - /* Check arguments */ - if (H5C_FILE_CREATE != H5Cget_class(tid) || - NULL == (tmpl = H5A_object(tid))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "not a file creation template"); - } - for (i = 8; i < 8 * sizeof(int); i++) { - uintn p2 = 8 == i ? 0 : 1 << i; - if (size == p2) - break; - } - if (i >= 8 * sizeof(int)) { - HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "userblock size is not valid"); - } - /* Set value */ - tmpl->userblock_size = size; - - FUNC_LEAVE(SUCCEED); -} - -/*------------------------------------------------------------------------- - * Function: H5Cget_userblock - * - * Purpose: Queries the size of a user block in a file creation template. - * - * Return: Success: SUCCEED, size returned through SIZE argument. - * - * Failure: FAIL - * - * Programmer: Robb Matzke - * Wednesday, January 7, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -herr_t -H5Cget_userblock(hid_t tid, size_t *size) -{ - H5F_create_t *tmpl = NULL; - - FUNC_ENTER(H5Cget_userblock, FAIL); - - /* Check args */ - if (H5C_FILE_CREATE != H5Cget_class(tid) || - NULL == (tmpl = H5A_object(tid))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "not a file creation template"); - } - /* Get value */ - if (size) - *size = tmpl->userblock_size; - - FUNC_LEAVE(SUCCEED); -} - -/*------------------------------------------------------------------------- - * Function: H5Cset_sizes - * - * Purpose: Sets file size-of addresses and sizes. TEMPLATE - * should be a file creation template. A value of zero causes - * the property to not change. - * - * Return: Success: SUCCEED - * - * Failure: FAIL - * - * Programmer: Robb Matzke - * Tuesday, January 6, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -herr_t -H5Cset_sizes(hid_t tid, size_t sizeof_addr, size_t sizeof_size) -{ - H5F_create_t *tmpl = NULL; - - FUNC_ENTER(H5Cset_sizeof_addr, FAIL); - - /* Check arguments */ - if (H5C_FILE_CREATE != H5Cget_class(tid) || - NULL == (tmpl = H5A_object(tid))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "not a file creation template"); - } - if (sizeof_addr) { - if (sizeof_addr != 2 && sizeof_addr != 4 && - sizeof_addr != 8 && sizeof_addr != 16) { - HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "file haddr_t size is not valid"); - } - } - if (sizeof_size) { - if (sizeof_size != 2 && sizeof_size != 4 && - sizeof_size != 8 && sizeof_size != 16) { - HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "file size_t size is not valid"); - } - } - /* Set value */ - if (sizeof_addr) - tmpl->sizeof_addr = sizeof_addr; - if (sizeof_size) - tmpl->sizeof_size = sizeof_size; - - FUNC_LEAVE(SUCCEED); -} - -/*------------------------------------------------------------------------- - * Function: H5Cget_sizes - * - * Purpose: Returns the size of address and size quantities stored in a - * file according to a file creation template. Either (or even - * both) SIZEOF_ADDR and SIZEOF_SIZE may be null pointers. - * - * Return: Success: SUCCEED, sizes returned through arguments. - * - * Failure: FAIL - * - * Programmer: Robb Matzke - * Wednesday, January 7, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -herr_t -H5Cget_sizes(hid_t tid, - size_t *sizeof_addr /*out */ , size_t *sizeof_size /*out */ ) -{ - H5F_create_t *tmpl = NULL; - - FUNC_ENTER(H5Cget_sizes, FAIL); - - /* Check args */ - if (H5C_FILE_CREATE != H5Cget_class(tid) || - NULL == (tmpl = H5A_object(tid))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "not a file creation template"); - } - /* Get values */ - if (sizeof_addr) - *sizeof_addr = tmpl->sizeof_addr; - if (sizeof_size) - *sizeof_size = tmpl->sizeof_size; - - FUNC_LEAVE(SUCCEED); -} - -/*------------------------------------------------------------------------- - * Function: H5Cset_sym_k - * - * Purpose: IK is one half the rank of a tree that stores a symbol - * table for a group. Internal nodes of the symbol table are on - * average 75% full. That is, the average rank of the tree is - * 1.5 times the value of IK. - * - * LK is one half of the number of symbols that can be stored in - * a symbol table node. A symbol table node is the leaf of a - * symbol table tree which is used to store a group. When - * symbols are inserted randomly into a group, the group's - * symbol table nodes are 75% full on average. That is, they - * contain 1.5 times the number of symbols specified by LK. - * - * Either (or even both) of IK and LK can be zero in which case - * that value is left unchanged. - * - * Return: Success: SUCCEED - * - * Failure: FAIL - * - * Programmer: Robb Matzke - * Tuesday, January 6, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -herr_t -H5Cset_sym_k(hid_t tid, int ik, int lk) -{ - H5F_create_t *tmpl = NULL; - - FUNC_ENTER(H5Cset_sym_k, FAIL); - - /* Check arguments */ - if (H5C_FILE_CREATE != H5Cget_class(tid) || - NULL == (tmpl = H5A_object(tid))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "not a file creation template"); - } - /* Set values */ - if (ik > 0) { - tmpl->btree_k[H5B_SNODE_ID] = ik; - } - if (lk > 0) { - tmpl->sym_leaf_k = lk; - } - FUNC_LEAVE(SUCCEED); -} - -/*------------------------------------------------------------------------- - * Function: H5Cget_sym_k - * - * Purpose: Retrieves the symbol table B-tree 1/2 rank (IK) and the - * symbol table leaf node 1/2 size (LK). See H5Cset_sym_k() for - * details. Either (or even both) IK and LK may be null - * pointers. - * - * Return: Success: SUCCEED - * - * Failure: FAIL - * - * Programmer: Robb Matzke - * Wednesday, January 7, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -herr_t -H5Cget_sym_k(hid_t tid, int *ik /*out */ , int *lk /*out */ ) -{ - H5F_create_t *tmpl = NULL; - - FUNC_ENTER(H5Cget_sym_k, FAIL); - - /* Check arguments */ - if (H5C_FILE_CREATE != H5Cget_class(tid) || - NULL == (tmpl = H5A_object(tid))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "not a file creation template"); - } - /* Get values */ - if (ik) - *ik = tmpl->btree_k[H5B_SNODE_ID]; - if (lk) - *lk = tmpl->sym_leaf_k; - - FUNC_LEAVE(SUCCEED); -} - -/*------------------------------------------------------------------------- - * Function: H5Cset_istore_k - * - * Purpose: IK is one half the rank of a tree that stores chunked raw - * data. On average, such a tree will be 75% full, or have an - * average rank of 1.5 times the value of IK. - * - * Return: Success: SUCCEED - * - * Failure: FAIL - * - * Programmer: Robb Matzke - * Tuesday, January 6, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -herr_t -H5Cset_istore_k(hid_t tid, int ik) -{ - H5F_create_t *tmpl = NULL; - - FUNC_ENTER(H5Cset_istore_k, FAIL); - - /* Check arguments */ - if (H5C_FILE_CREATE != H5Cget_class(tid) || - NULL == (tmpl = H5A_object(tid))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "not a file creation template"); - } - if (ik <= 0) { - HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "istore IK value must be positive"); - } - /* Set value */ - tmpl->btree_k[H5B_ISTORE_ID] = ik; - - FUNC_LEAVE(SUCCEED); -} - -/*------------------------------------------------------------------------- - * Function: H5Cget_istore_k - * - * Purpose: Queries the 1/2 rank of an indexed storage B-tree. See - * H5Cset_istore_k() for details. The argument IK may be the - * null pointer. - * - * Return: Success: SUCCEED, size returned through IK - * - * Failure: - * - * Programmer: Robb Matzke - * Wednesday, January 7, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -herr_t -H5Cget_istore_k(hid_t tid, int *ik /*out */ ) -{ - H5F_create_t *tmpl = NULL; - - FUNC_ENTER(H5Cget_istore_k, FAIL); - - /* Check arguments */ - if (H5C_FILE_CREATE != H5Cget_class(tid) || - NULL == (tmpl = H5A_object(tid))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "not a file creation template"); - } - /* Get value */ - if (ik) - *ik = tmpl->btree_k[H5B_ISTORE_ID]; - - FUNC_LEAVE(SUCCEED); -} - -/*------------------------------------------------------------------------- - * Function: H5Cset_layout - * - * Purpose: Sets the layout of raw data in the file. - * - * Return: Success: SUCCEED - * - * Failure: FAIL - * - * Programmer: Robb Matzke - * Tuesday, January 6, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -herr_t -H5Cset_layout(hid_t tid, H5D_layout_t layout) -{ - H5D_create_t *tmpl = NULL; - - FUNC_ENTER(H5Cset_layout, FAIL); - - /* Check arguments */ - if (H5C_DATASET_CREATE != H5Cget_class(tid) || - NULL == (tmpl = H5A_object(tid))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "not a dataset creation template"); - } - if (layout < 0 || layout >= H5D_NLAYOUTS) { - HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, - "raw data layout method is not valid"); - } - /* Set value */ - tmpl->layout = layout; - - FUNC_LEAVE(SUCCEED); -} - -/*------------------------------------------------------------------------- - * Function: H5Cget_layout - * - * Purpose: Retrieves layout type of a dataset creation template. - * - * Return: Success: The layout type - * - * Failure: H5D_LAYOUT_ERROR (-1, same as FAIL) - * - * Programmer: Robb Matzke - * Wednesday, January 7, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -H5D_layout_t -H5Cget_layout(hid_t tid) -{ - H5D_create_t *tmpl = NULL; - - FUNC_ENTER(H5Cget_layout, H5D_LAYOUT_ERROR); - - /* Check arguments */ - if (H5C_DATASET_CREATE != H5Cget_class(tid) || - NULL == (tmpl = H5A_object(tid))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5D_LAYOUT_ERROR, - "not a dataset creation template"); - } - FUNC_LEAVE(tmpl->layout); -} - -/*------------------------------------------------------------------------- - * Function: H5Cset_chunk - * - * Purpose: Sets the number of dimensions and the size of each chunk to - * the values specified. The dimensionality of the chunk should - * match the dimensionality of the data space. - * - * As a side effect, the layout method is changed to - * H5D_CHUNKED. - * - * Return: Success: SUCCEED - * - * Failure: FAIL - * - * Programmer: Robb Matzke - * Tuesday, January 6, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -herr_t -H5Cset_chunk(hid_t tid, int ndims, const size_t dim[]) -{ - int i; - H5D_create_t *tmpl = NULL; - - FUNC_ENTER(H5Cset_chunk, FAIL); - - /* Check arguments */ - if (H5C_DATASET_CREATE != H5Cget_class(tid) || - NULL == (tmpl = H5A_object(tid))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "not a dataset creation template"); - } - if (ndims <= 0) { - HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, - "chunk dimensionality must be positive"); - } - if (ndims > NELMTS(tmpl->chunk_size)) { - HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, - "chunk dimensionality is too large"); - } - if (!dim) { - HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "no chunk dimensions specified"); - } - for (i = 0; i < ndims; i++) { - if (dim[i] <= 0) { - HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, - "all chunk dimensions must be positive"); - } - } - - /* Set value */ - tmpl->layout = H5D_CHUNKED; - tmpl->chunk_ndims = ndims; - for (i = 0; i < ndims; i++) - tmpl->chunk_size[i] = dim[i]; - - FUNC_LEAVE(SUCCEED); -} - -/*------------------------------------------------------------------------- - * Function: H5Cget_chunk - * - * Purpose: Retrieves the chunk size of chunked layout. The chunk - * dimensionality is returned and the chunk size in each - * dimension is returned through the DIM argument. At most - * MAX_NDIMS elements of DIM will be initialized. - * - * Return: Success: Positive Chunk dimensionality. - * - * Failure: FAIL - * - * Programmer: Robb Matzke - * Wednesday, January 7, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -int -H5Cget_chunk(hid_t tid, int max_ndims, size_t dim[] /*out */ ) -{ - int i; - H5D_create_t *tmpl = NULL; - - FUNC_ENTER(H5Cget_chunk, FAIL); - - /* Check arguments */ - if (H5C_DATASET_CREATE != H5Cget_class(tid) || - NULL == (tmpl = H5A_object(tid))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "not a dataset creation template"); - } - if (H5D_CHUNKED != tmpl->layout) { - HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "not a chunked storage layout"); - } - for (i = 0; i < tmpl->chunk_ndims && i < max_ndims && dim; i++) { - dim[i] = tmpl->chunk_size[i]; - } - - FUNC_LEAVE(tmpl->chunk_ndims); -} - - -/*------------------------------------------------------------------------- - * Function: H5Cset_stdio - * - * Purpose: Set the low level file driver to use the functions declared - * in the stdio.h file: fopen(), fseek() or fseek64(), fread(), - * fwrite(), and fclose(). - * - * Return: Success: SUCCEED - * - * Failure: FAIL - * - * Programmer: Robb Matzke - * Thursday, February 19, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -herr_t -H5Cset_stdio (hid_t tid) -{ - H5F_access_t *tmpl = NULL; - - FUNC_ENTER (H5Cset_stdio, FAIL); - - /* Check arguments */ - if (H5C_FILE_ACCESS != H5Cget_class(tid) || - NULL == (tmpl = H5A_object(tid))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "not a file access template"); - } - - /* Set driver */ - tmpl->driver = H5F_LOW_STDIO; - - FUNC_LEAVE (SUCCEED); -} - - -/*------------------------------------------------------------------------- - * Function: H5Cset_sec2 - * - * Purpose: Set the low-level file driver to use the functions declared - * in the unistd.h file: open(), lseek() or lseek64(), read(), - * write(), and close(). - * - * Return: Success: SUCCEED - * - * Failure: FAIL - * - * Programmer: Robb Matzke - * Thursday, February 19, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -herr_t -H5Cset_sec2 (hid_t tid) -{ - H5F_access_t *tmpl = NULL; - - FUNC_ENTER (H5Cset_sec2, FAIL); - - /* Check arguments */ - if (H5C_FILE_ACCESS != H5Cget_class(tid) || - NULL == (tmpl = H5A_object(tid))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "not a file access template"); - } - - /* Set driver */ - tmpl->driver = H5F_LOW_SEC2; - - FUNC_LEAVE (SUCCEED); -} - - -/*------------------------------------------------------------------------- - * Function: H5Cset_core - * - * Purpose: Set the low-level file driver to use malloc() and free(). - * This driver is restricted to temporary files which are not - * larger than the amount of virtual memory available. The - * INCREMENT argument determines the file block size and memory - * will be allocated in multiples of INCREMENT bytes. A liberal - * INCREMENT results in fewer calls to realloc() and probably - * less memory fragmentation. - * - * Return: Success: SUCCEED - * - * Failure: FAIL - * - * Programmer: Robb Matzke - * Thursday, February 19, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -herr_t -H5Cset_core (hid_t tid, size_t increment) -{ - H5F_access_t *tmpl = NULL; - - FUNC_ENTER (H5Cset_core, FAIL); - - /* Check arguments */ - if (H5C_FILE_ACCESS != H5Cget_class(tid) || - NULL == (tmpl = H5A_object(tid))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "not a file access template"); - } - if (increment<1) { - HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, - "increment must be positive"); - } - - /* Set driver */ - tmpl->driver = H5F_LOW_CORE; - tmpl->u.core.increment = increment; - - FUNC_LEAVE (SUCCEED); -} - - -/*------------------------------------------------------------------------- - * Function: H5Cset_split - * - * Purpose: Set the low-level driver to split meta data from raw data, - * storing meta data in one file and raw data in another file. - * - * Return: Success: SUCCEED - * - * Failure: FAIL - * - * Programmer: Robb Matzke - * Thursday, February 19, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -herr_t -H5Cset_split (hid_t tid, hid_t meta_tid, hid_t raw_tid) -{ - H5F_access_t *tmpl = NULL; - H5F_access_t *meta_tmpl = NULL; - H5F_access_t *raw_tmpl = NULL; - - FUNC_ENTER (H5Cset_split, FAIL); - - /* Check arguments */ - if (H5C_FILE_ACCESS != H5Cget_class(tid) || - NULL == (tmpl = H5A_object(tid))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "not a file access template"); - } - if (H5C_DEFAULT!=meta_tid && - (H5C_FILE_ACCESS != H5Cget_class(meta_tid) || - NULL == (tmpl = H5A_object(meta_tid)))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "not a file access template"); - } - if (H5C_DEFAULT!=raw_tid && - (H5C_FILE_ACCESS != H5Cget_class(raw_tid) || - NULL == (tmpl = H5A_object(raw_tid)))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "not a file access template"); - } - - /* Set driver */ - tmpl->driver = H5F_LOW_SPLIT; - tmpl->u.split.meta_access = H5C_copy (H5C_FILE_ACCESS, meta_tmpl); - tmpl->u.split.raw_access = H5C_copy (H5C_FILE_ACCESS, raw_tmpl); - - FUNC_LEAVE (SUCCEED); -} - - -/*------------------------------------------------------------------------- - * Function: H5Cset_family - * - * Purpose: Sets the low-level driver to stripe the hdf5 address space - * across a family of files. - * - * Return: Success: SUCCEED - * - * Failure: FAIL - * - * Programmer: Robb Matzke - * Thursday, February 19, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -herr_t -H5Cset_family (hid_t tid, hid_t memb_tid) -{ - - H5F_access_t *tmpl = NULL; - H5F_access_t *memb_tmpl = NULL; - - FUNC_ENTER (H5Cset_family, FAIL); - - /* Check arguments */ - if (H5C_FILE_ACCESS != H5Cget_class(tid) || - NULL == (tmpl = H5A_object(tid))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "not a file access template"); - } - if (H5C_DEFAULT!=memb_tid && - (H5C_FILE_ACCESS != H5Cget_class(memb_tid) || - NULL == (tmpl = H5A_object(memb_tid)))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "not a file access template"); - } - - /* Set driver */ - tmpl->driver = H5F_LOW_FAMILY; - tmpl->u.fam.memb_access = H5C_copy (H5C_FILE_ACCESS, memb_tmpl); - - FUNC_LEAVE (SUCCEED); -} - - - -#ifdef HAVE_PARALLEL -/*------------------------------------------------------------------------- - * Function: H5Cset_mpi - * - * Signature: herr_t H5Cset_mpi(hid_t tid, MPI_Comm comm, MPI_Info info, - * uintn access_mode) - * - * Purpose: Store the access mode for MPIO call and the user supplied - * communicator and info in the access template which can then - * be used to open file. This function is available only in the - * parallel HDF5 library and is not a collective function. - * - * Parameters: - * hid_t tid - * ID of template to modify - * MPI_Comm comm - * MPI communicator to be used for file open as defined in - * MPI_FILE_OPEN of MPI-2. This function does not make a - * duplicated communicator. Any modification to comm after - * this function call returns may have undetermined effect - * to the access template. Users should call this function - * again to setup the template. - * MPI_Info info - * MPI info object to be used for file open as defined in - * MPI_FILE_OPEN of MPI-2. This function does not make a - * duplicated info. Any modification to info after - * this function call returns may have undetermined effect - * to the access template. Users should call this function - * again to setup the template. - * uintn access_mode - * File data access modes: - * H5ACC_INDEPENDENT - * Allow independent datasets access. - * H5ACC_COLLECTIVE - * Allow only collective datasets access. - * - * Return: Success: SUCCEED - * - * Failure: FAIL - * - * Programmer: Albert Cheng - * Feb 3, 1998 - * - * Modifications: - * - * Robb Matzke, 18 Feb 1998 - * Check all arguments before the template is updated so we don't leave - * the template in a bad state if something goes wrong. Also, the - * template data type changed to allow more generality so all the - * mpi-related stuff is in the `u.mpi' member. The `access_mode' will - * contain only mpi-related flags defined in H5Fpublic.h. - * - *------------------------------------------------------------------------- - */ -herr_t -H5Cset_mpi (hid_t tid, MPI_Comm comm, MPI_Info info, uintn access_mode) -{ - H5F_access_t *tmpl = NULL; - MPI_Comm lcomm; - int mrc; /* MPI return code */ - - FUNC_ENTER(H5Cset_mpi, FAIL); - - /* Check arguments */ - if (H5C_FILE_ACCESS != H5Cget_class(tid) || - NULL == (tmpl = H5A_object(tid))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "not a file access template"); - } - - switch (access_mode){ - case H5ACC_INDEPENDENT: - case H5ACC_COLLECTIVE: - /* okay */ - break; - - default: - HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, - "invalid mpio access mode"); - } - -#ifdef LATER - /* - * Need to verify comm and info contain sensible information. - */ -#endif - - - /* - * Everything looks good. Now go ahead and modify the access template. - */ - tmpl->driver = H5F_LOW_MPIO; - tmpl->u.mpio.access_mode = access_mode; - - /* - * Store a duplicate copy of comm so that user may freely modify comm - * after this call. - */ - if ((mrc = MPI_Comm_dup(comm, &lcomm)) != MPI_SUCCESS) { - HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "failure to duplicate communicator"); - } - tmpl->u.mpio.comm = comm; - -#ifdef LATER - /* Need to duplicate info too but don't know a quick way to do it now */ -#endif - tmpl->u.mpio.info = info; - - FUNC_LEAVE(SUCCEED); -} - -#endif /*HAVE_PARALLEL*/ - -/*-------------------------------------------------------------------------- - NAME - H5Ccopy - PURPOSE - Copy a template - USAGE - hid_t H5C_copy(tid) - hid_t tid; IN: Template object to copy - RETURNS - Returns template ID (atom) on success, FAIL on failure - - ERRORS - ARGS BADRANGE Unknown template class. - ATOM BADATOM Can't unatomize template. - ATOM CANTREGISTER Register the atom for the new template. - INTERNAL UNSUPPORTED Dataset transfer properties are not implemented - yet. - INTERNAL UNSUPPORTED File access properties are not implemented yet. - - DESCRIPTION - This function creates a new copy of a template with all the same parameter - settings. ---------------------------------------------------------------------------*/ -hid_t -H5Ccopy(hid_t tid) -{ - const void *tmpl = NULL; - void *new_tmpl = NULL; - H5C_class_t type; - hid_t ret_value = FAIL; - group_t group; - - FUNC_ENTER(H5Ccopy, FAIL); - - /* Check args */ - if (NULL == (tmpl = H5A_object(tid)) || - (type = H5Cget_class(tid)) < 0 || - (group = H5A_group(tid)) < 0) { - HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, - "can't unatomize template"); - } - - /* Copy it */ - if (NULL==(new_tmpl=H5C_copy (type, tmpl))) { - HRETURN_ERROR (H5E_INTERNAL, H5E_CANTINIT, FAIL, - "unable to copy template"); - } - - /* Register the atom for the new template */ - if ((ret_value = H5A_register(group, new_tmpl)) < 0) { - HRETURN_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, - "unable to atomize template pointer"); - } - FUNC_LEAVE(ret_value); -} - -/*------------------------------------------------------------------------- - * Function: H5C_copy - * - * Purpose: Creates a new template and initializes it with some other - * template. - * - * Return: Success: Ptr to new template - * - * Failure: NULL - * - * Programmer: Robb Matzke - * Tuesday, February 3, 1998 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -void * -H5C_copy (H5C_class_t type, const void *src) -{ - size_t size; - void *dst = NULL; - - FUNC_ENTER (H5C_copy, NULL); - - /* How big is the template */ - switch (type) { - case H5C_FILE_CREATE: - size = sizeof(H5F_create_t); - break; - - case H5C_FILE_ACCESS: - size = sizeof(H5F_access_t); - break; - - case H5C_DATASET_CREATE: - size = sizeof(H5D_create_t); - break; - - case H5C_DATASET_XFER: - size = sizeof(H5D_xfer_t); - break; - - default: - HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, - "unknown template class"); - } - - /* Create the new template */ - dst = H5MM_xmalloc(size); - HDmemcpy(dst, src, size); - - FUNC_LEAVE (dst); -} diff --git a/src/H5Cprivate.h b/src/H5Cprivate.h deleted file mode 100644 index a01df14..0000000 --- a/src/H5Cprivate.h +++ /dev/null @@ -1,29 +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 H5C module - */ -#ifndef _H5Cprivate_H -#define _H5Cprivate_H - -#include - -/* Private headers needed by this file */ -#include -#include - -hid_t H5C_create (H5C_class_t type, void *tmpl); -void *H5C_copy (H5C_class_t type, const void *src); -herr_t H5C_close (H5C_class_t type, void *tmpl); - -#endif diff --git a/src/H5Cpublic.h b/src/H5Cpublic.h deleted file mode 100644 index 44444dc..0000000 --- a/src/H5Cpublic.h +++ /dev/null @@ -1,77 +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 function prototypes for each exported function in the - * H5C module. - */ -#ifndef _H5Cpublic_H -#define _H5Cpublic_H - -/* Default Template for creation, access, etc. templates */ -#define H5C_DEFAULT (-2) - -/* Public headers needed by this file */ -#include -#include -#include - -/* Template classes */ -typedef enum H5C_class_t { - H5C_NO_CLASS = -1, /*error return value */ - H5C_FILE_CREATE = 0, /*file creation template */ - H5C_FILE_ACCESS = 1, /*file access template */ - H5C_DATASET_CREATE = 2, /*dataset creation template */ - H5C_DATASET_XFER = 3, /*dataset transfer template */ - - H5C_NCLASSES = 4 /*this must be last! */ -} H5C_class_t; - -#ifdef __cplusplus -extern "C" { -#endif - -/* Public functions */ -hid_t H5Ccreate (H5C_class_t type); -herr_t H5Cclose (hid_t tid); -hid_t H5Ccopy (hid_t tid); -H5C_class_t H5Cget_class (hid_t tid); -herr_t H5Cget_version (hid_t tid, int *boot/*out*/, int *heap/*out*/, - int *freelist/*out*/, int *stab/*out*/, - int *shhdr/*out*/); -herr_t H5Cset_userblock (hid_t tid, size_t size); -herr_t H5Cget_userblock (hid_t tid, size_t *size); -herr_t H5Cset_sizes (hid_t tid, size_t sizeof_addr, size_t sizeof_size); -herr_t H5Cget_sizes (hid_t tid, size_t *sizeof_addr/*out*/, - size_t *sizeof_size/*out*/); -herr_t H5Cset_sym_k (hid_t tid, int ik, int lk); -herr_t H5Cget_sym_k (hid_t tid, int *ik/*out*/, int *lk/*out*/); -herr_t H5Cset_istore_k (hid_t tid, int ik); -herr_t H5Cget_istore_k (hid_t tid, int *ik/*out*/); -herr_t H5Cset_layout (hid_t tid, H5D_layout_t layout); -H5D_layout_t H5Cget_layout (hid_t tid); -herr_t H5Cset_chunk (hid_t tid, int ndims, const size_t dim[]); -int H5Cget_chunk (hid_t tid, int max_ndims, size_t dim[]/*out*/); -herr_t H5Cset_stdio (hid_t tid); -herr_t H5Cset_sec2 (hid_t tid); -herr_t H5Cset_core (hid_t tid, size_t increment); -herr_t H5Cset_split (hid_t tid, hid_t meta_tid, hid_t raw_tid); -herr_t H5Cset_family (hid_t tid, hid_t memb_tid); -#ifdef HAVE_PARALLEL -herr_t H5Cset_mpi (hid_t tid, MPI_Comm comm, MPI_Info info, uintn access_mode); -/* herr_t H5Cget_mpi (hid_t tid, int *ik); */ /* not defined yet */ -#endif - -#ifdef __cplusplus -} -#endif -#endif diff --git a/src/H5D.c b/src/H5D.c index dad5886..c7ac56b 100644 --- a/src/H5D.c +++ b/src/H5D.c @@ -19,7 +19,7 @@ static char RcsId[] = "@(#)$Revision$"; #include /* Generic Functions */ #include /* Atoms */ #include /* Cache */ -#include /* Templates */ +#include /* Templates */ #include /* Dataset functions */ #include /* Error handling */ #include /* Group headers */ @@ -187,7 +187,7 @@ H5Dcreate(hid_t file_id, const char *name, hid_t type_id, hid_t space_id, HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); } if (create_parms_id >= 0) { - if (H5C_DATASET_CREATE != H5Cget_class(create_parms_id) || + if (H5P_DATASET_CREATE != H5Pget_class(create_parms_id) || NULL == (create_parms = H5A_object(create_parms_id))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation template"); @@ -415,7 +415,7 @@ H5Dget_type (hid_t dataset_id) * * Return: Success: ID for a copy of the dataset creation * template. The template should be released by - * calling H5Cclose(). + * calling H5Pclose(). * * Failure: FAIL * @@ -442,14 +442,14 @@ H5Dget_create_parms (hid_t dataset_id) } /* Copy the creation template */ - if (NULL==(copied_parms=H5C_copy (H5C_DATASET_CREATE, + if (NULL==(copied_parms=H5P_copy (H5P_DATASET_CREATE, &(dataset->create_parms)))) { HRETURN_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to copy the creation template"); } /* Create an atom */ - if ((ret_value=H5A_register ((group_t)(H5_TEMPLATE_0+H5C_DATASET_CREATE), + if ((ret_value=H5A_register ((group_t)(H5_TEMPLATE_0+H5P_DATASET_CREATE), copied_parms))<0) { HRETURN_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register creation template"); @@ -478,7 +478,7 @@ H5Dget_create_parms (hid_t dataset_id) * The number of elements in the memory data space must match * the number of elements in the file data space. * - * The XFER_PARMS_ID can be the constant H5C_DEFAULT in which + * The XFER_PARMS_ID can be the constant H5P_DEFAULT in which * case the default data transfer properties are used. * * Return: Success: SUCCEED @@ -534,9 +534,9 @@ H5Dread(hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id, HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); } } - if (H5C_DEFAULT == xfer_parms_id) { + if (H5P_DEFAULT == xfer_parms_id) { xfer_parms = &H5D_xfer_dflt; - } else if (H5C_DATASET_XFER != H5Cget_class(xfer_parms_id) || + } else if (H5P_DATASET_XFER != H5Pget_class(xfer_parms_id) || NULL == (xfer_parms = H5A_object(xfer_parms_id))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms"); } @@ -573,7 +573,7 @@ H5Dread(hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id, * The number of elements in the memory data space must match * the number of elements in the file data space. * - * The XFER_PARMS_ID can be the constant H5C_DEFAULT in which + * The XFER_PARMS_ID can be the constant H5P_DEFAULT in which * case the default data transfer properties are used. * * Return: Success: SUCCEED @@ -623,9 +623,9 @@ H5Dwrite(hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id, HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); } } - if (H5C_DEFAULT == xfer_parms_id) { + if (H5P_DEFAULT == xfer_parms_id) { xfer_parms = &H5D_xfer_dflt; - } else if (H5C_DATASET_XFER != H5Cget_class(xfer_parms_id) || + } else if (H5P_DATASET_XFER != H5Pget_class(xfer_parms_id) || NULL == (xfer_parms = H5A_object(xfer_parms_id))) { HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms"); } diff --git a/src/H5F.c b/src/H5F.c index 6e639c3..e2b884e 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -40,7 +40,7 @@ static char RcsId[] = "@(#)$Revision$"; #include /*library functions */ #include /*atoms */ #include /*cache */ -#include /*templates */ +#include /*templates */ #include /*error handling */ #include /*symbol tables */ #include /*meta data */ @@ -239,7 +239,7 @@ H5F_encode_length_unusual(const H5F_t *f, uint8 **p, uint8 *l) * Modifications: * * Robb Matzke, 18 Feb 1998 - * Calls H5C_copy() to copy the template and H5C_close() to free that + * Calls H5P_copy() to copy the template and H5P_close() to free that * template if an error occurs. * *------------------------------------------------------------------------- @@ -259,15 +259,15 @@ H5Fget_create_template(hid_t fid) } /* Create the template object to return */ - if (NULL==(tmpl=H5C_copy (H5C_FILE_CREATE, + if (NULL==(tmpl=H5P_copy (H5P_FILE_CREATE, &(file->shared->create_parms)))) { HRETURN_ERROR (H5E_INTERNAL, H5E_CANTINIT, FAIL, "unable to copy file creation properties"); } /* Create an atom */ - if ((ret_value = H5C_create(H5C_FILE_CREATE, tmpl)) < 0) { - H5C_close (H5C_FILE_CREATE, tmpl); + if ((ret_value = H5P_create(H5P_FILE_CREATE, tmpl)) < 0) { + H5P_close (H5P_FILE_CREATE, tmpl); HRETURN_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register property list"); } @@ -309,15 +309,15 @@ H5Fget_access_template (hid_t file_id) } /* Create the template object to return */ - if (NULL==(tmpl=H5C_copy (H5C_FILE_ACCESS, + if (NULL==(tmpl=H5P_copy (H5P_FILE_ACCESS, &(f->shared->access_parms)))) { HRETURN_ERROR (H5E_INTERNAL, H5E_CANTINIT, FAIL, "unable to copy file access properties"); } /* Create an atom */ - if ((ret_value = H5C_create (H5C_FILE_ACCESS, tmpl))<0) { - H5C_close (H5C_FILE_ACCESS, tmpl); + if ((ret_value = H5P_create (H5P_FILE_ACCESS, tmpl))<0) { + H5P_close (H5P_FILE_ACCESS, tmpl); HRETURN_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register property list"); } @@ -1009,11 +1009,11 @@ H5F_open(const char *name, uintn flags, * * The more complex behaviors of a file's creation and access * are controlled through the file-creation and file-access - * property lists. The value of H5C_DEFAULT for a template + * property lists. The value of H5P_DEFAULT for a template * value indicates that the library should use the default * values for the appropriate template. * - * See also: H5Fpublic.h for the list of supported flags. H5Cpublic.h for + * See also: H5Fpublic.h for the list of supported flags. H5Ppublic.h for * the list of file creation and file access properties. * * Return: Success: A file ID @@ -1039,7 +1039,7 @@ H5F_open(const char *name, uintn flags, * Better error checking for the creation and access property lists. It * used to be possible to swap the two and core the library. Also, zero * is no longer valid as a default property list; one must use - * H5C_DEFAULT instead. + * H5P_DEFAULT instead. * *------------------------------------------------------------------------- */ @@ -1071,16 +1071,16 @@ H5Fcreate(const char *filename, uintn flags, hid_t create_id, HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "mutually exclusive flags for file creation"); } - if (H5C_DEFAULT==create_id) { + if (H5P_DEFAULT==create_id) { create_parms = &H5F_create_dflt; - } else if (H5C_FILE_CREATE!=H5Cget_class (create_id) || + } else if (H5P_FILE_CREATE!=H5Pget_class (create_id) || NULL == (create_parms = H5A_object(create_id))) { HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file creation property list"); } - if (H5C_DEFAULT==access_id) { + if (H5P_DEFAULT==access_id) { access_parms = &H5F_access_dflt; - } else if (H5C_FILE_ACCESS!=H5Cget_class (access_id) || + } else if (H5P_FILE_ACCESS!=H5Pget_class (access_id) || NULL == (access_parms = H5A_object(access_id))) { HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); @@ -1176,9 +1176,9 @@ H5Fopen(const char *filename, uintn flags, hid_t access_id) (flags & H5F_ACC_TRUNC) || (flags & H5F_ACC_EXCL)) { HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file open flags"); } - if (H5C_DEFAULT==access_id) { + if (H5P_DEFAULT==access_id) { access_parms = &H5F_access_dflt; - } else if (H5C_FILE_ACCESS!=H5Cget_class (access_id) || + } else if (H5P_FILE_ACCESS!=H5Pget_class (access_id) || NULL == (access_parms = H5A_object(access_id))) { HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h index 51d4d56..5843103 100644 --- a/src/H5Fpublic.h +++ b/src/H5Fpublic.h @@ -44,8 +44,8 @@ #endif /* - * Low-level file drivers. These values are returned by H5Cget_file_driver() - * and are set by the various H5Cset_...() functions that set file driver + * Low-level file drivers. These values are returned by H5Pget_file_driver() + * and are set by the various H5Pset_...() functions that set file driver * properties. */ typedef enum H5F_driver_t { @@ -59,7 +59,7 @@ typedef enum H5F_driver_t { } H5F_driver_t; -/* Parallel styles passed to H5Cset_mpi() */ +/* Parallel styles passed to H5Pset_mpi() */ #ifdef HAVE_PARALLEL # define H5ACC_INDEPENDENT 0x0010 /*MPI independent access */ # define H5ACC_COLLECTIVE 0x0011 /*MPI collective access */ diff --git a/src/H5M.c b/src/H5M.c index e805248..5078950 100644 --- a/src/H5M.c +++ b/src/H5M.c @@ -45,13 +45,13 @@ static char RcsId[] = "@(#)$Revision$"; #include /* Generic functions */ #include /* Atom interface */ -#include /* Template interface */ +#include /* Template interface */ #include /* Dataset interface */ #include /*error handling */ #include /* Dataspace functions */ #include /* Datatype interface */ #include /* Meta-object interface */ -#include /* Template interface */ +#include /* Template interface */ #define PABLO_MASK H5M_mask @@ -59,11 +59,11 @@ static char RcsId[] = "@(#)$Revision$"; static meta_func_t meta_func_arr[] = { - { /* Template object meta-functions (defined in H5C.c) */ + { /* Template object meta-functions (defined in H5P.c) */ H5_TEMPLATE_0, /* File-Creation Template Type ID */ NULL, /* File-Creation Template Create */ NULL, /* File-Creation Template Access */ - H5Ccopy, /* File-Creation Template Copy */ + H5Pcopy, /* File-Creation Template Copy */ NULL, /* File-Creation Template FindName */ NULL, /* File-Creation Template NameLen */ NULL, /* File-Creation Template GetName */ @@ -74,13 +74,13 @@ static meta_func_t meta_func_arr[] = NULL, /* File-Creation Template Delete */ NULL, /* File-Creation Template GetParent */ NULL, /* File-Creation Template GetFile */ - H5Cclose /* File-Creation Template Release */ + H5Pclose /* File-Creation Template Release */ }, - { /* Template object meta-functions (defined in H5C.c) */ + { /* Template object meta-functions (defined in H5P.c) */ H5_TEMPLATE_1, /* File-Access Template Type ID */ NULL, /* File-Access Template Create */ NULL, /* File-Access Template Access */ - H5Ccopy, /* File-Access Template Copy */ + H5Pcopy, /* File-Access Template Copy */ NULL, /* File-Access Template FindName */ NULL, /* File-Access Template NameLen */ NULL, /* File-Access Template GetName */ @@ -91,7 +91,7 @@ static meta_func_t meta_func_arr[] = NULL, /* File-Access Template Delete */ NULL, /* File-Access Template GetParent */ NULL, /* File-Access Template GetFile */ - H5Cclose /* File-Access Template Release */ + H5Pclose /* File-Access Template Release */ }, { /* Datatype object meta-functions (defined in H5T.c) */ H5_DATATYPE, /* Datatype Type ID */ diff --git a/src/H5Mpublic.h b/src/H5Mpublic.h index 6366a1f..1f5e582 100644 --- a/src/H5Mpublic.h +++ b/src/H5Mpublic.h @@ -18,7 +18,7 @@ /* Public headers needed by this file */ #include -#include /*for hobjtype_t defn */ +#include /*for hobjtype_t defn */ #ifdef __cplusplus extern "C" { diff --git a/src/H5P.c b/src/H5P.c new file mode 100644 index 0000000..4e180e2b --- /dev/null +++ b/src/H5P.c @@ -0,0 +1,1383 @@ +/**************************************************************************** +* 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 + +/* Private header files */ +#include /* Generic Functions */ +#include /* Atoms */ +#include /* B-tree subclass names */ +#include /* Template information */ +#include /* Datasets */ +#include /* Error handling */ +#include /* Memory management */ + +#define PABLO_MASK H5P_mask + +/* Is the interface initialized? */ +static hbool_t interface_initialize_g = FALSE; +#define INTERFACE_INIT H5P_init_interface +static herr_t H5P_init_interface(void); + +/* PRIVATE PROTOTYPES */ +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; + intn i; + herr_t status; + + FUNC_ENTER(H5P_init_interface, FAIL); + + /* + * Make sure the file creation and file access default templates are + * initialized since this might be done at run-time instead of compile + * time. + */ + if (H5F_init_interface ()<0) { + HRETURN_ERROR (H5E_INTERNAL, H5E_CANTINIT, FAIL, + "unable to initialize H5F and H5P interfaces"); + } + + assert(H5P_NCLASSES <= H5_TEMPLATE_MAX - H5_TEMPLATE_0); + + /* + * Initialize the mappings between template classes and atom groups. We + * keep the two separate because template classes are publicly visible but + * atom groups aren't. + */ + for (i = 0; i < H5P_NCLASSES; i++) { + status = H5A_init_group((group_t)(H5_TEMPLATE_0 +i), + H5A_TEMPID_HASHSIZE, 0, NULL); + if (status < 0) ret_value = FAIL; + } + if (ret_value < 0) { + HRETURN_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL, + "unable to initialize atom group"); + } + + /* + * Register cleanup function. + */ + if (H5_add_exit(H5P_term_interface) < 0) { + HRETURN_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, + "unable to install atexit function"); + } + + 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) +{ + intn i; + + for (i = 0; i < H5P_NCLASSES; i++) { + H5A_destroy_group((group_t)(H5_TEMPLATE_0 + i)); + } +} + +/*-------------------------------------------------------------------------- + NAME + H5Pcreate + PURPOSE + Returns a copy of the default template for some class of templates. + USAGE + herr_t H5Pcreate (type) + H5P_class_t type; IN: Template class whose default is desired. + RETURNS + Template ID or FAIL + + ERRORS + ARGS BADVALUE Unknown template class. + ATOM CANTINIT Can't register template. + INTERNAL UNSUPPORTED Not implemented yet. + + DESCRIPTION + Returns a copy of the default template for some class of templates. +--------------------------------------------------------------------------*/ +hid_t +H5Pcreate(H5P_class_t type) +{ + hid_t ret_value = FAIL; + void *tmpl = NULL; + + FUNC_ENTER(H5Pcreate, FAIL); + + /* Allocate a new template and initialize it with default values */ + switch (type) { + case H5P_FILE_CREATE: + tmpl = H5MM_xmalloc(sizeof(H5F_create_t)); + memcpy(tmpl, &H5F_create_dflt, sizeof(H5F_create_t)); + break; + + case H5P_FILE_ACCESS: + tmpl = H5MM_xmalloc(sizeof(H5F_access_t)); + memcpy(tmpl, &H5F_access_dflt, sizeof(H5F_access_t)); + break; + + case H5P_DATASET_CREATE: + tmpl = H5MM_xmalloc(sizeof(H5D_create_t)); + memcpy(tmpl, &H5D_create_dflt, sizeof(H5D_create_t)); + break; + + case H5P_DATASET_XFER: + tmpl = H5MM_xmalloc(sizeof(H5D_xfer_t)); + memcpy(tmpl, &H5D_xfer_dflt, sizeof(H5D_xfer_t)); + break; + + default: + HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "unknown template class"); + } + + /* Atomize the new template */ + if ((ret_value = H5P_create(type, tmpl)) < 0) { + HRETURN_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL, + "can't register template"); + } + FUNC_LEAVE(ret_value); +} + +/*------------------------------------------------------------------------- + * Function: H5P_create + * + * Purpose: Given a pointer to some template struct, atomize the template + * and return its ID. The template memory is not copied, so the + * caller should not free it; it will be freed by H5P_release(). + * + * Return: Success: A new template ID. + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Wednesday, December 3, 1997 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +hid_t +H5P_create(H5P_class_t type, void *tmpl) +{ + hid_t ret_value = FAIL; + + FUNC_ENTER(H5P_create, FAIL); + + /* check args */ + assert(type >= 0 && type < H5P_NCLASSES); + assert(tmpl); + + /* Atomize the new template */ + if ((ret_value=H5A_register((group_t)(H5_TEMPLATE_0+type), tmpl)) < 0) { + HRETURN_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL, + "can't register template"); + } + + FUNC_LEAVE(ret_value); +} + +/*-------------------------------------------------------------------------- + NAME + H5Pclose + PURPOSE + Release access to a template object. + USAGE + herr_t H5Pclose(oid) + hid_t oid; IN: Template object to release access to + RETURNS + SUCCEED/FAIL + DESCRIPTION + This function releases access to a template object +--------------------------------------------------------------------------*/ +herr_t +H5Pclose(hid_t tid) +{ + H5P_class_t type; + void *tmpl = NULL; + + FUNC_ENTER(H5Pclose, FAIL); + + /* Check arguments */ + if ((type=H5Pget_class (tid))<0 || + NULL==(tmpl=H5A_object (tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); + } + + /* + * Chuck the object! When the reference count reaches zero then + * H5A_dec_ref() removes it from the group and we should free it. The + * free function is not registered as part of the group because it takes + * an extra argument. + */ + if (0==H5A_dec_ref(tid)) H5P_close (type, tmpl); + + FUNC_LEAVE (SUCCEED); +} + + +/*------------------------------------------------------------------------- + * Function: H5P_close + * + * Purpose: Closes a template and frees the memory associated with the + * template. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Wednesday, February 18, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5P_close (H5P_class_t type, void *tmpl) +{ + FUNC_ENTER (H5P_close, FAIL); + + /* Check args */ + assert (tmpl); + + /* Some templates may need to do special things */ + switch (type) { + case H5P_FILE_ACCESS: +#ifdef LATER + /* Need to free the COMM and INFO objects too. */ +#endif + break; + + case H5P_FILE_CREATE: + case H5P_DATASET_CREATE: + case H5P_DATASET_XFER: + /*nothing to do*/ + break; + + default: + HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, + "unknown property list class"); + } + + /* Free the template struct and return */ + H5MM_xfree(tmpl); + FUNC_LEAVE(SUCCEED); +} + + +/*------------------------------------------------------------------------- + * Function: H5Pget_class + * + * Purpose: Returns the class identifier for a template. + * + * Return: Success: A template class + * + * Failure: H5P_NO_CLASS (-1) + * + * Programmer: Robb Matzke + * Wednesday, December 3, 1997 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +H5P_class_t +H5Pget_class(hid_t tid) +{ + group_t group; + H5P_class_t ret_value = H5P_NO_CLASS; + + FUNC_ENTER(H5Pget_class, H5P_NO_CLASS); + + if ((group = H5A_group(tid)) < 0 || +#ifndef NDEBUG + group >= H5_TEMPLATE_MAX || +#endif + group < H5_TEMPLATE_0) { + HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, H5P_NO_CLASS, "not a template"); + } + ret_value = (H5P_class_t)(group - H5_TEMPLATE_0); + FUNC_LEAVE(ret_value); +} + +/*------------------------------------------------------------------------- + * Function: H5Pget_version + * + * Purpose: Retrieves version information for various parts of a file. + * + * BOOT: The file boot block. + * HEAP: The global heap. + * FREELIST: The global free list. + * STAB: The root symbol table entry. + * SHHDR: Shared object headers. + * + * Any (or even all) of the output arguments can be null + * pointers. + * + * Return: Success: SUCCEED, version information is returned + * through the arguments. + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Wednesday, January 7, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pget_version(hid_t tid, int *boot /*out */ , int *heap /*out */ , + int *freelist /*out */ , int *stab /*out */ , int *shhdr /*out */ ) +{ + H5F_create_t *tmpl = NULL; + + FUNC_ENTER(H5Pget_version, FAIL); + + /* Check arguments */ + if (H5P_FILE_CREATE != H5Pget_class(tid) || + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file creation template"); + } + /* Get values */ + if (boot) + *boot = tmpl->bootblock_ver; + if (heap) + *heap = tmpl->smallobject_ver; + if (freelist) + *freelist = tmpl->freespace_ver; + if (stab) + *stab = tmpl->objectdir_ver; + if (shhdr) + *shhdr = tmpl->sharedheader_ver; + + FUNC_LEAVE(SUCCEED); +} + +/*------------------------------------------------------------------------- + * Function: H5Pset_userblock + * + * Purpose: Sets the userblock size field of a file creation template. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Tuesday, January 6, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_userblock(hid_t tid, size_t size) +{ + intn i; + H5F_create_t *tmpl = NULL; + + FUNC_ENTER(H5Pset_userblock, FAIL); + + /* Check arguments */ + if (H5P_FILE_CREATE != H5Pget_class(tid) || + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file creation template"); + } + for (i = 8; i < 8 * sizeof(int); i++) { + uintn p2 = 8 == i ? 0 : 1 << i; + if (size == p2) + break; + } + if (i >= 8 * sizeof(int)) { + HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "userblock size is not valid"); + } + /* Set value */ + tmpl->userblock_size = size; + + FUNC_LEAVE(SUCCEED); +} + +/*------------------------------------------------------------------------- + * Function: H5Pget_userblock + * + * Purpose: Queries the size of a user block in a file creation template. + * + * Return: Success: SUCCEED, size returned through SIZE argument. + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Wednesday, January 7, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pget_userblock(hid_t tid, size_t *size) +{ + H5F_create_t *tmpl = NULL; + + FUNC_ENTER(H5Pget_userblock, FAIL); + + /* Check args */ + if (H5P_FILE_CREATE != H5Pget_class(tid) || + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file creation template"); + } + /* Get value */ + if (size) + *size = tmpl->userblock_size; + + FUNC_LEAVE(SUCCEED); +} + +/*------------------------------------------------------------------------- + * Function: H5Pset_sizes + * + * Purpose: Sets file size-of addresses and sizes. TEMPLATE + * should be a file creation template. A value of zero causes + * the property to not change. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Tuesday, January 6, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_sizes(hid_t tid, size_t sizeof_addr, size_t sizeof_size) +{ + H5F_create_t *tmpl = NULL; + + FUNC_ENTER(H5Pset_sizeof_addr, FAIL); + + /* Check arguments */ + if (H5P_FILE_CREATE != H5Pget_class(tid) || + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file creation template"); + } + if (sizeof_addr) { + if (sizeof_addr != 2 && sizeof_addr != 4 && + sizeof_addr != 8 && sizeof_addr != 16) { + HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "file haddr_t size is not valid"); + } + } + if (sizeof_size) { + if (sizeof_size != 2 && sizeof_size != 4 && + sizeof_size != 8 && sizeof_size != 16) { + HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "file size_t size is not valid"); + } + } + /* Set value */ + if (sizeof_addr) + tmpl->sizeof_addr = sizeof_addr; + if (sizeof_size) + tmpl->sizeof_size = sizeof_size; + + FUNC_LEAVE(SUCCEED); +} + +/*------------------------------------------------------------------------- + * Function: H5Pget_sizes + * + * Purpose: Returns the size of address and size quantities stored in a + * file according to a file creation template. Either (or even + * both) SIZEOF_ADDR and SIZEOF_SIZE may be null pointers. + * + * Return: Success: SUCCEED, sizes returned through arguments. + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Wednesday, January 7, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pget_sizes(hid_t tid, + size_t *sizeof_addr /*out */ , size_t *sizeof_size /*out */ ) +{ + H5F_create_t *tmpl = NULL; + + FUNC_ENTER(H5Pget_sizes, FAIL); + + /* Check args */ + if (H5P_FILE_CREATE != H5Pget_class(tid) || + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file creation template"); + } + /* Get values */ + if (sizeof_addr) + *sizeof_addr = tmpl->sizeof_addr; + if (sizeof_size) + *sizeof_size = tmpl->sizeof_size; + + FUNC_LEAVE(SUCCEED); +} + +/*------------------------------------------------------------------------- + * Function: H5Pset_sym_k + * + * Purpose: IK is one half the rank of a tree that stores a symbol + * table for a group. Internal nodes of the symbol table are on + * average 75% full. That is, the average rank of the tree is + * 1.5 times the value of IK. + * + * LK is one half of the number of symbols that can be stored in + * a symbol table node. A symbol table node is the leaf of a + * symbol table tree which is used to store a group. When + * symbols are inserted randomly into a group, the group's + * symbol table nodes are 75% full on average. That is, they + * contain 1.5 times the number of symbols specified by LK. + * + * Either (or even both) of IK and LK can be zero in which case + * that value is left unchanged. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Tuesday, January 6, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_sym_k(hid_t tid, int ik, int lk) +{ + H5F_create_t *tmpl = NULL; + + FUNC_ENTER(H5Pset_sym_k, FAIL); + + /* Check arguments */ + if (H5P_FILE_CREATE != H5Pget_class(tid) || + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file creation template"); + } + /* Set values */ + if (ik > 0) { + tmpl->btree_k[H5B_SNODE_ID] = ik; + } + if (lk > 0) { + tmpl->sym_leaf_k = lk; + } + FUNC_LEAVE(SUCCEED); +} + +/*------------------------------------------------------------------------- + * Function: H5Pget_sym_k + * + * Purpose: Retrieves the symbol table B-tree 1/2 rank (IK) and the + * symbol table leaf node 1/2 size (LK). See H5Pset_sym_k() for + * details. Either (or even both) IK and LK may be null + * pointers. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Wednesday, January 7, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pget_sym_k(hid_t tid, int *ik /*out */ , int *lk /*out */ ) +{ + H5F_create_t *tmpl = NULL; + + FUNC_ENTER(H5Pget_sym_k, FAIL); + + /* Check arguments */ + if (H5P_FILE_CREATE != H5Pget_class(tid) || + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file creation template"); + } + /* Get values */ + if (ik) + *ik = tmpl->btree_k[H5B_SNODE_ID]; + if (lk) + *lk = tmpl->sym_leaf_k; + + FUNC_LEAVE(SUCCEED); +} + +/*------------------------------------------------------------------------- + * Function: H5Pset_istore_k + * + * Purpose: IK is one half the rank of a tree that stores chunked raw + * data. On average, such a tree will be 75% full, or have an + * average rank of 1.5 times the value of IK. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Tuesday, January 6, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_istore_k(hid_t tid, int ik) +{ + H5F_create_t *tmpl = NULL; + + FUNC_ENTER(H5Pset_istore_k, FAIL); + + /* Check arguments */ + if (H5P_FILE_CREATE != H5Pget_class(tid) || + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file creation template"); + } + if (ik <= 0) { + HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "istore IK value must be positive"); + } + /* Set value */ + tmpl->btree_k[H5B_ISTORE_ID] = ik; + + FUNC_LEAVE(SUCCEED); +} + +/*------------------------------------------------------------------------- + * Function: H5Pget_istore_k + * + * Purpose: Queries the 1/2 rank of an indexed storage B-tree. See + * H5Pset_istore_k() for details. The argument IK may be the + * null pointer. + * + * Return: Success: SUCCEED, size returned through IK + * + * Failure: + * + * Programmer: Robb Matzke + * Wednesday, January 7, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pget_istore_k(hid_t tid, int *ik /*out */ ) +{ + H5F_create_t *tmpl = NULL; + + FUNC_ENTER(H5Pget_istore_k, FAIL); + + /* Check arguments */ + if (H5P_FILE_CREATE != H5Pget_class(tid) || + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file creation template"); + } + /* Get value */ + if (ik) + *ik = tmpl->btree_k[H5B_ISTORE_ID]; + + FUNC_LEAVE(SUCCEED); +} + +/*------------------------------------------------------------------------- + * Function: H5Pset_layout + * + * Purpose: Sets the layout of raw data in the file. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Tuesday, January 6, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_layout(hid_t tid, H5D_layout_t layout) +{ + H5D_create_t *tmpl = NULL; + + FUNC_ENTER(H5Pset_layout, FAIL); + + /* Check arguments */ + if (H5P_DATASET_CREATE != H5Pget_class(tid) || + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a dataset creation template"); + } + if (layout < 0 || layout >= H5D_NLAYOUTS) { + HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, + "raw data layout method is not valid"); + } + /* Set value */ + tmpl->layout = layout; + + FUNC_LEAVE(SUCCEED); +} + +/*------------------------------------------------------------------------- + * Function: H5Pget_layout + * + * Purpose: Retrieves layout type of a dataset creation template. + * + * Return: Success: The layout type + * + * Failure: H5D_LAYOUT_ERROR (-1, same as FAIL) + * + * Programmer: Robb Matzke + * Wednesday, January 7, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +H5D_layout_t +H5Pget_layout(hid_t tid) +{ + H5D_create_t *tmpl = NULL; + + FUNC_ENTER(H5Pget_layout, H5D_LAYOUT_ERROR); + + /* Check arguments */ + if (H5P_DATASET_CREATE != H5Pget_class(tid) || + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5D_LAYOUT_ERROR, + "not a dataset creation template"); + } + FUNC_LEAVE(tmpl->layout); +} + +/*------------------------------------------------------------------------- + * Function: H5Pset_chunk + * + * Purpose: Sets the number of dimensions and the size of each chunk to + * the values specified. The dimensionality of the chunk should + * match the dimensionality of the data space. + * + * As a side effect, the layout method is changed to + * H5D_CHUNKED. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Tuesday, January 6, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_chunk(hid_t tid, int ndims, const size_t dim[]) +{ + int i; + H5D_create_t *tmpl = NULL; + + FUNC_ENTER(H5Pset_chunk, FAIL); + + /* Check arguments */ + if (H5P_DATASET_CREATE != H5Pget_class(tid) || + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a dataset creation template"); + } + if (ndims <= 0) { + HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, + "chunk dimensionality must be positive"); + } + if (ndims > NELMTS(tmpl->chunk_size)) { + HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, + "chunk dimensionality is too large"); + } + if (!dim) { + HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "no chunk dimensions specified"); + } + for (i = 0; i < ndims; i++) { + if (dim[i] <= 0) { + HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, + "all chunk dimensions must be positive"); + } + } + + /* Set value */ + tmpl->layout = H5D_CHUNKED; + tmpl->chunk_ndims = ndims; + for (i = 0; i < ndims; i++) + tmpl->chunk_size[i] = dim[i]; + + FUNC_LEAVE(SUCCEED); +} + +/*------------------------------------------------------------------------- + * Function: H5Pget_chunk + * + * Purpose: Retrieves the chunk size of chunked layout. The chunk + * dimensionality is returned and the chunk size in each + * dimension is returned through the DIM argument. At most + * MAX_NDIMS elements of DIM will be initialized. + * + * Return: Success: Positive Chunk dimensionality. + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Wednesday, January 7, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +int +H5Pget_chunk(hid_t tid, int max_ndims, size_t dim[] /*out */ ) +{ + int i; + H5D_create_t *tmpl = NULL; + + FUNC_ENTER(H5Pget_chunk, FAIL); + + /* Check arguments */ + if (H5P_DATASET_CREATE != H5Pget_class(tid) || + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a dataset creation template"); + } + if (H5D_CHUNKED != tmpl->layout) { + HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "not a chunked storage layout"); + } + for (i = 0; i < tmpl->chunk_ndims && i < max_ndims && dim; i++) { + dim[i] = tmpl->chunk_size[i]; + } + + FUNC_LEAVE(tmpl->chunk_ndims); +} + + +/*------------------------------------------------------------------------- + * Function: H5Pset_stdio + * + * Purpose: Set the low level file driver to use the functions declared + * in the stdio.h file: fopen(), fseek() or fseek64(), fread(), + * fwrite(), and fclose(). + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Thursday, February 19, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_stdio (hid_t tid) +{ + H5F_access_t *tmpl = NULL; + + FUNC_ENTER (H5Pset_stdio, FAIL); + + /* Check arguments */ + if (H5P_FILE_ACCESS != H5Pget_class(tid) || + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file access template"); + } + + /* Set driver */ + tmpl->driver = H5F_LOW_STDIO; + + FUNC_LEAVE (SUCCEED); +} + + +/*------------------------------------------------------------------------- + * Function: H5Pset_sec2 + * + * Purpose: Set the low-level file driver to use the functions declared + * in the unistd.h file: open(), lseek() or lseek64(), read(), + * write(), and close(). + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Thursday, February 19, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_sec2 (hid_t tid) +{ + H5F_access_t *tmpl = NULL; + + FUNC_ENTER (H5Pset_sec2, FAIL); + + /* Check arguments */ + if (H5P_FILE_ACCESS != H5Pget_class(tid) || + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file access template"); + } + + /* Set driver */ + tmpl->driver = H5F_LOW_SEC2; + + FUNC_LEAVE (SUCCEED); +} + + +/*------------------------------------------------------------------------- + * Function: H5Pset_core + * + * Purpose: Set the low-level file driver to use malloc() and free(). + * This driver is restricted to temporary files which are not + * larger than the amount of virtual memory available. The + * INCREMENT argument determines the file block size and memory + * will be allocated in multiples of INCREMENT bytes. A liberal + * INCREMENT results in fewer calls to realloc() and probably + * less memory fragmentation. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Thursday, February 19, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_core (hid_t tid, size_t increment) +{ + H5F_access_t *tmpl = NULL; + + FUNC_ENTER (H5Pset_core, FAIL); + + /* Check arguments */ + if (H5P_FILE_ACCESS != H5Pget_class(tid) || + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file access template"); + } + if (increment<1) { + HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, + "increment must be positive"); + } + + /* Set driver */ + tmpl->driver = H5F_LOW_CORE; + tmpl->u.core.increment = increment; + + FUNC_LEAVE (SUCCEED); +} + + +/*------------------------------------------------------------------------- + * Function: H5Pset_split + * + * Purpose: Set the low-level driver to split meta data from raw data, + * storing meta data in one file and raw data in another file. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Thursday, February 19, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_split (hid_t tid, hid_t meta_tid, hid_t raw_tid) +{ + H5F_access_t *tmpl = NULL; + H5F_access_t *meta_tmpl = NULL; + H5F_access_t *raw_tmpl = NULL; + + FUNC_ENTER (H5Pset_split, FAIL); + + /* Check arguments */ + if (H5P_FILE_ACCESS != H5Pget_class(tid) || + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file access template"); + } + if (H5P_DEFAULT!=meta_tid && + (H5P_FILE_ACCESS != H5Pget_class(meta_tid) || + NULL == (tmpl = H5A_object(meta_tid)))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file access template"); + } + if (H5P_DEFAULT!=raw_tid && + (H5P_FILE_ACCESS != H5Pget_class(raw_tid) || + NULL == (tmpl = H5A_object(raw_tid)))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file access template"); + } + + /* Set driver */ + tmpl->driver = H5F_LOW_SPLIT; + tmpl->u.split.meta_access = H5P_copy (H5P_FILE_ACCESS, meta_tmpl); + tmpl->u.split.raw_access = H5P_copy (H5P_FILE_ACCESS, raw_tmpl); + + FUNC_LEAVE (SUCCEED); +} + + +/*------------------------------------------------------------------------- + * Function: H5Pset_family + * + * Purpose: Sets the low-level driver to stripe the hdf5 address space + * across a family of files. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Thursday, February 19, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_family (hid_t tid, hid_t memb_tid) +{ + + H5F_access_t *tmpl = NULL; + H5F_access_t *memb_tmpl = NULL; + + FUNC_ENTER (H5Pset_family, FAIL); + + /* Check arguments */ + if (H5P_FILE_ACCESS != H5Pget_class(tid) || + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file access template"); + } + if (H5P_DEFAULT!=memb_tid && + (H5P_FILE_ACCESS != H5Pget_class(memb_tid) || + NULL == (tmpl = H5A_object(memb_tid)))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file access template"); + } + + /* Set driver */ + tmpl->driver = H5F_LOW_FAMILY; + tmpl->u.fam.memb_access = H5P_copy (H5P_FILE_ACCESS, memb_tmpl); + + FUNC_LEAVE (SUCCEED); +} + + + +#ifdef HAVE_PARALLEL +/*------------------------------------------------------------------------- + * Function: H5Pset_mpi + * + * Signature: herr_t H5Pset_mpi(hid_t tid, MPI_Comm comm, MPI_Info info, + * uintn access_mode) + * + * Purpose: Store the access mode for MPIO call and the user supplied + * communicator and info in the access template which can then + * be used to open file. This function is available only in the + * parallel HDF5 library and is not a collective function. + * + * Parameters: + * hid_t tid + * ID of template to modify + * MPI_Comm comm + * MPI communicator to be used for file open as defined in + * MPI_FILE_OPEN of MPI-2. This function does not make a + * duplicated communicator. Any modification to comm after + * this function call returns may have undetermined effect + * to the access template. Users should call this function + * again to setup the template. + * MPI_Info info + * MPI info object to be used for file open as defined in + * MPI_FILE_OPEN of MPI-2. This function does not make a + * duplicated info. Any modification to info after + * this function call returns may have undetermined effect + * to the access template. Users should call this function + * again to setup the template. + * uintn access_mode + * File data access modes: + * H5ACC_INDEPENDENT + * Allow independent datasets access. + * H5ACC_COLLECTIVE + * Allow only collective datasets access. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Albert Cheng + * Feb 3, 1998 + * + * Modifications: + * + * Robb Matzke, 18 Feb 1998 + * Check all arguments before the template is updated so we don't leave + * the template in a bad state if something goes wrong. Also, the + * template data type changed to allow more generality so all the + * mpi-related stuff is in the `u.mpi' member. The `access_mode' will + * contain only mpi-related flags defined in H5Fpublic.h. + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_mpi (hid_t tid, MPI_Comm comm, MPI_Info info, uintn access_mode) +{ + H5F_access_t *tmpl = NULL; + MPI_Comm lcomm; + int mrc; /* MPI return code */ + + FUNC_ENTER(H5Pset_mpi, FAIL); + + /* Check arguments */ + if (H5P_FILE_ACCESS != H5Pget_class(tid) || + NULL == (tmpl = H5A_object(tid))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, + "not a file access template"); + } + + switch (access_mode){ + case H5ACC_INDEPENDENT: + case H5ACC_COLLECTIVE: + /* okay */ + break; + + default: + HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, + "invalid mpio access mode"); + } + +#ifdef LATER + /* + * Need to verify comm and info contain sensible information. + */ +#endif + + + /* + * Everything looks good. Now go ahead and modify the access template. + */ + tmpl->driver = H5F_LOW_MPIO; + tmpl->u.mpio.access_mode = access_mode; + + /* + * Store a duplicate copy of comm so that user may freely modify comm + * after this call. + */ + if ((mrc = MPI_Comm_dup(comm, &lcomm)) != MPI_SUCCESS) { + HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "failure to duplicate communicator"); + } + tmpl->u.mpio.comm = comm; + +#ifdef LATER + /* Need to duplicate info too but don't know a quick way to do it now */ +#endif + tmpl->u.mpio.info = info; + + FUNC_LEAVE(SUCCEED); +} + +#endif /*HAVE_PARALLEL*/ + +/*-------------------------------------------------------------------------- + NAME + H5Pcopy + PURPOSE + Copy a template + USAGE + hid_t H5P_copy(tid) + hid_t tid; IN: Template object to copy + RETURNS + Returns template ID (atom) on success, FAIL on failure + + ERRORS + ARGS BADRANGE Unknown template class. + ATOM BADATOM Can't unatomize template. + ATOM CANTREGISTER Register the atom for the new template. + INTERNAL UNSUPPORTED Dataset transfer properties are not implemented + yet. + INTERNAL UNSUPPORTED File access properties are not implemented yet. + + DESCRIPTION + This function creates a new copy of a template with all the same parameter + settings. +--------------------------------------------------------------------------*/ +hid_t +H5Pcopy(hid_t tid) +{ + const void *tmpl = NULL; + void *new_tmpl = NULL; + H5P_class_t type; + hid_t ret_value = FAIL; + group_t group; + + FUNC_ENTER(H5Pcopy, FAIL); + + /* Check args */ + if (NULL == (tmpl = H5A_object(tid)) || + (type = H5Pget_class(tid)) < 0 || + (group = H5A_group(tid)) < 0) { + HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, + "can't unatomize template"); + } + + /* Copy it */ + if (NULL==(new_tmpl=H5P_copy (type, tmpl))) { + HRETURN_ERROR (H5E_INTERNAL, H5E_CANTINIT, FAIL, + "unable to copy template"); + } + + /* Register the atom for the new template */ + if ((ret_value = H5A_register(group, new_tmpl)) < 0) { + HRETURN_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, + "unable to atomize template pointer"); + } + FUNC_LEAVE(ret_value); +} + +/*------------------------------------------------------------------------- + * Function: H5P_copy + * + * Purpose: Creates a new template and initializes it with some other + * template. + * + * Return: Success: Ptr to new template + * + * Failure: NULL + * + * Programmer: Robb Matzke + * Tuesday, February 3, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +void * +H5P_copy (H5P_class_t type, const void *src) +{ + size_t size; + void *dst = NULL; + + FUNC_ENTER (H5P_copy, NULL); + + /* How big is the template */ + switch (type) { + case H5P_FILE_CREATE: + size = sizeof(H5F_create_t); + break; + + case H5P_FILE_ACCESS: + size = sizeof(H5F_access_t); + break; + + case H5P_DATASET_CREATE: + size = sizeof(H5D_create_t); + break; + + case H5P_DATASET_XFER: + size = sizeof(H5D_xfer_t); + break; + + default: + HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, + "unknown template class"); + } + + /* Create the new template */ + dst = H5MM_xmalloc(size); + HDmemcpy(dst, src, size); + + FUNC_LEAVE (dst); +} diff --git a/src/H5Pprivate.h b/src/H5Pprivate.h new file mode 100644 index 0000000..d1b877b --- /dev/null +++ b/src/H5Pprivate.h @@ -0,0 +1,29 @@ +/**************************************************************************** + * 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 + +hid_t H5P_create (H5P_class_t type, void *tmpl); +void *H5P_copy (H5P_class_t type, const void *src); +herr_t H5P_close (H5P_class_t type, void *tmpl); + +#endif diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h new file mode 100644 index 0000000..b8074d2 --- /dev/null +++ b/src/H5Ppublic.h @@ -0,0 +1,77 @@ +/**************************************************************************** + * 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 function prototypes for each exported function in the + * H5P module. + */ +#ifndef _H5Ppublic_H +#define _H5Ppublic_H + +/* Default Template for creation, access, etc. templates */ +#define H5P_DEFAULT (-2) + +/* Public headers needed by this file */ +#include +#include +#include + +/* Template classes */ +typedef enum H5P_class_t { + H5P_NO_CLASS = -1, /*error return value */ + H5P_FILE_CREATE = 0, /*file creation template */ + H5P_FILE_ACCESS = 1, /*file access template */ + H5P_DATASET_CREATE = 2, /*dataset creation template */ + H5P_DATASET_XFER = 3, /*dataset transfer template */ + + H5P_NCLASSES = 4 /*this must be last! */ +} H5P_class_t; + +#ifdef __cplusplus +extern "C" { +#endif + +/* Public functions */ +hid_t H5Pcreate (H5P_class_t type); +herr_t H5Pclose (hid_t tid); +hid_t H5Pcopy (hid_t tid); +H5P_class_t H5Pget_class (hid_t tid); +herr_t H5Pget_version (hid_t tid, int *boot/*out*/, int *heap/*out*/, + int *freelist/*out*/, int *stab/*out*/, + int *shhdr/*out*/); +herr_t H5Pset_userblock (hid_t tid, size_t size); +herr_t H5Pget_userblock (hid_t tid, size_t *size); +herr_t H5Pset_sizes (hid_t tid, size_t sizeof_addr, size_t sizeof_size); +herr_t H5Pget_sizes (hid_t tid, size_t *sizeof_addr/*out*/, + size_t *sizeof_size/*out*/); +herr_t H5Pset_sym_k (hid_t tid, int ik, int lk); +herr_t H5Pget_sym_k (hid_t tid, int *ik/*out*/, int *lk/*out*/); +herr_t H5Pset_istore_k (hid_t tid, int ik); +herr_t H5Pget_istore_k (hid_t tid, int *ik/*out*/); +herr_t H5Pset_layout (hid_t tid, H5D_layout_t layout); +H5D_layout_t H5Pget_layout (hid_t tid); +herr_t H5Pset_chunk (hid_t tid, int ndims, const size_t dim[]); +int H5Pget_chunk (hid_t tid, int max_ndims, size_t dim[]/*out*/); +herr_t H5Pset_stdio (hid_t tid); +herr_t H5Pset_sec2 (hid_t tid); +herr_t H5Pset_core (hid_t tid, size_t increment); +herr_t H5Pset_split (hid_t tid, hid_t meta_tid, hid_t raw_tid); +herr_t H5Pset_family (hid_t tid, hid_t memb_tid); +#ifdef HAVE_PARALLEL +herr_t H5Pset_mpi (hid_t tid, MPI_Comm comm, MPI_Info info, uintn access_mode); +/* herr_t H5Pget_mpi (hid_t tid, int *ik); */ /* not defined yet */ +#endif + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/Makefile.in b/src/Makefile.in index d84fcb1..249e4d7 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -16,7 +16,7 @@ PROGS=debug # Source and object files for the library (lexicographically)... PARALLEL_SRC=H5Fmpio.c -LIB_SRC=H5.c H5A.c H5AC.c H5B.c H5C.c H5D.c H5E.c H5F.c H5Farray.c H5Fcore.c \ +LIB_SRC=H5.c H5A.c H5AC.c H5B.c H5P.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 \ @@ -33,14 +33,14 @@ PROG_SRC=debug.c PROG_OBJ=$(PROG_SRC:.c=.o) # Public header files (to be installed)... -PUB_HDR=H5public.h H5Apublic.h H5ACpublic.h H5Bpublic.h H5Cpublic.h \ +PUB_HDR=H5public.h H5Apublic.h H5ACpublic.h H5Bpublic.h H5Ppublic.h \ H5Dpublic.h H5Epublic.h H5Fpublic.h H5Gpublic.h H5Hpublic.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 \ + H5Pprivate.h H5Dprivate.h H5Eprivate.h H5Fprivate.h H5Gprivate.h \ H5Gpkg.h H5Hprivate.h H5Mprivate.h H5MFprivate.h H5MMprivate.h \ H5Oprivate.h H5Sprivate.h H5Tprivate.h H5Tpkg.h H5Vprivate.h diff --git a/src/debug.c b/src/debug.c index 8356de7..2e7e1c4 100644 --- a/src/debug.c +++ b/src/debug.c @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include #include @@ -57,7 +57,7 @@ main(int argc, char *argv[]) /* * Open the file and get the file descriptor. */ - if ((fid = H5Fopen(argv[1], H5F_ACC_RDONLY, H5C_DEFAULT)) < 0) { + if ((fid = H5Fopen(argv[1], H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) { fprintf(stderr, "cannot open file\n"); HDexit(1); } diff --git a/src/hdf5.h b/src/hdf5.h index a5d8f19..8252a21 100644 --- a/src/hdf5.h +++ b/src/hdf5.h @@ -19,19 +19,19 @@ #define _HDF5_H #include -#include -#include -#include -#include -#include -#include -#include -#include +#include /* Atoms */ +#include /* Metadata cache */ +#include /* B-trees */ +#include /* Datasets */ +#include /* Errors */ +#include /* Files */ +#include /* Groups */ #include -#include +#include /* "Meta" */ #include #include -#include -#include -#include +#include /* Object headers */ +#include /* Property lists */ +#include /* Dataspaces */ +#include /* Datatypes */ #endif diff --git a/test/cmpd_dset.c b/test/cmpd_dset.c index aad6339..a98a9b3 100644 --- a/test/cmpd_dset.c +++ b/test/cmpd_dset.c @@ -130,7 +130,7 @@ main (void) /* Create the file */ file = H5Fcreate ("cmpd_dset.h5", H5F_ACC_TRUNC, - H5C_DEFAULT, H5C_DEFAULT); + H5P_DEFAULT, H5P_DEFAULT); assert (file>=0); /* Create the data space */ @@ -166,11 +166,11 @@ STEP 1: Initialize dataset `s1' and store it on disk in native order.\n"); assert (s1_tid>=0); /* Create the dataset */ - dataset = H5Dcreate (file, "s1", s1_tid, space, H5C_DEFAULT); + dataset = H5Dcreate (file, "s1", s1_tid, space, H5P_DEFAULT); assert (dataset>=0); /* Write the data */ - status = H5Dwrite (dataset, s1_tid, H5S_ALL, H5S_ALL, H5C_DEFAULT, s1); + status = H5Dwrite (dataset, s1_tid, H5S_ALL, H5S_ALL, H5P_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, H5S_ALL, H5S_ALL, H5C_DEFAULT, s2); + status = H5Dread (dataset, s2_tid, H5S_ALL, H5S_ALL, H5P_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, H5S_ALL, H5S_ALL, H5C_DEFAULT, s3); + status = H5Dread (dataset, s3_tid, H5S_ALL, H5S_ALL, H5P_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, H5S_ALL, H5S_ALL, H5C_DEFAULT, s4); + status = H5Dread (dataset, s4_tid, H5S_ALL, H5S_ALL, H5P_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, H5S_ALL, H5S_ALL, H5C_DEFAULT, s5); + status = H5Dread (dataset, s5_tid, H5S_ALL, H5S_ALL, H5P_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, H5S_ALL, H5S_ALL, H5C_DEFAULT, s4); + status = H5Dwrite (dataset, s4_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, s4); assert (status>=0); /* Read the data back */ - status = H5Dread (dataset, s1_tid, H5S_ALL, H5S_ALL, H5C_DEFAULT, s1); + status = H5Dread (dataset, s1_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, s1); assert (status>=0); /* Compare */ @@ -360,7 +360,7 @@ STEP 7: Reading original dataset with explicit data space.\n"); assert (s7_sid>=0); /* Read the dataset */ - status = H5Dread (dataset, s2_tid, s7_sid, H5S_ALL, H5C_DEFAULT, s2); + status = H5Dread (dataset, s2_tid, s7_sid, H5S_ALL, H5P_DEFAULT, s2); assert (status>=0); /* Compare */ @@ -401,7 +401,7 @@ STEP 8: Read middle third hyperslab into memory array.\n"); /* Read the dataset */ s8 = calloc (h_size[0]*h_size[1], sizeof(s1_t)); assert (s8); - status = H5Dread (dataset, s1_tid, s8_m_sid, s8_f_sid, H5C_DEFAULT, s8); + status = H5Dread (dataset, s1_tid, s8_m_sid, s8_f_sid, H5P_DEFAULT, s8); assert (status>=0); /* Compare */ @@ -435,7 +435,7 @@ STEP 9: Read middle third of hyperslab into middle third of memory array.\n"); memset (s2, 0xFF, NX*NY*sizeof(s2_t)); /* Read the hyperslab */ - status = H5Dread (dataset, s2_tid, s8_f_sid, s8_f_sid, H5C_DEFAULT, s2); + status = H5Dread (dataset, s2_tid, s8_f_sid, s8_f_sid, H5P_DEFAULT, s2); assert (status>=0); /* Compare */ @@ -474,7 +474,7 @@ STEP 10: Read middle third of hyperslab into middle third of memory array\n\ memset (s5, 0xFF, NX*NY*sizeof(s5_t)); /* Read the hyperslab */ - status = H5Dread (dataset, s5_tid, s8_f_sid, s8_f_sid, H5C_DEFAULT, s5); + status = H5Dread (dataset, s5_tid, s8_f_sid, s8_f_sid, H5P_DEFAULT, s5); assert (status>=0); /* Compare */ @@ -525,11 +525,11 @@ STEP 11: Write an array back to the middle third of the dataset to\n\ memset (s11, 0xff, h_size[0]*h_size[1]*sizeof(s4_t)); /* Write to disk */ - status = H5Dwrite (dataset, s4_tid, s8_m_sid, s8_f_sid, H5C_DEFAULT, s11); + status = H5Dwrite (dataset, s4_tid, s8_m_sid, s8_f_sid, H5P_DEFAULT, s11); assert (status>=0); /* Read the whole thing */ - status = H5Dread (dataset, s1_tid, H5S_ALL, H5S_ALL, H5C_DEFAULT, s1); + status = H5Dread (dataset, s1_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, s1); assert (status>=0); /* Compare */ diff --git a/test/dsets.c b/test/dsets.c index 16cd541..5d05288 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -65,7 +65,7 @@ test_create(hid_t file) * not sure what they are, so we won't check. */ dataset = H5Dcreate(file, DSET_DEFAULT_NAME, H5T_NATIVE_DOUBLE, space, - H5C_DEFAULT); + H5P_DEFAULT); if (dataset < 0) { puts("*FAILED*"); if (!isatty(1)) { @@ -88,7 +88,7 @@ test_create(hid_t file) * dataset can only be created once. */ dataset = H5Dcreate(file, DSET_DEFAULT_NAME, H5T_NATIVE_DOUBLE, space, - H5C_DEFAULT); + H5P_DEFAULT); if (dataset >= 0) { puts("*FAILED*"); if (!isatty(1)) { @@ -135,11 +135,11 @@ test_create(hid_t file) * Create a new dataset that uses chunked storage instead of the default * layout. */ - create_parms = H5Ccreate(H5C_DATASET_CREATE); + create_parms = H5Pcreate(H5P_DATASET_CREATE); assert(create_parms >= 0); csize[0] = 5; csize[1] = 100; - status = H5Cset_chunk(create_parms, 2, csize); + status = H5Pset_chunk(create_parms, 2, csize); assert(status >= 0); dataset = H5Dcreate(file, DSET_CHUNKED_NAME, H5T_NATIVE_DOUBLE, space, @@ -214,12 +214,12 @@ test_simple_io(hid_t file) /* Create the dataset */ dataset = H5Dcreate(file, DSET_SIMPLE_IO_NAME, H5T_NATIVE_INT, space, - H5C_DEFAULT); + H5P_DEFAULT); assert(dataset >= 0); /* Write the data to the dataset */ status = H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5C_DEFAULT, points); + H5P_DEFAULT, points); if (status < 0) { puts("*FAILED*"); if (!isatty(1)) { @@ -230,7 +230,7 @@ test_simple_io(hid_t file) } /* Read the dataset back */ status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, - H5C_DEFAULT, check); + H5P_DEFAULT, check); if (status < 0) { puts("*FAILED*"); if (!isatty(1)) { @@ -306,12 +306,12 @@ test_tconv(hid_t file) /* Create the data set */ dataset = H5Dcreate(file, DSET_TCONV_NAME, H5T_NATIVE_INT32, space, - H5C_DEFAULT); + H5P_DEFAULT); assert(dataset >= 0); /* Write the data to the dataset */ status = H5Dwrite(dataset, H5T_NATIVE_INT32, H5S_ALL, H5S_ALL, - H5C_DEFAULT, out); + H5P_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, H5S_ALL, H5S_ALL, H5C_DEFAULT, in); + status = H5Dread(dataset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, in); assert(status >= 0); /* Check */ @@ -375,7 +375,7 @@ main(void) assert (status>=0); unlink("dataset.h5"); - file = H5Fcreate("dataset.h5", H5F_ACC_TRUNC, H5C_DEFAULT, H5C_DEFAULT); + file = H5Fcreate("dataset.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); assert(file >= 0); status = test_create(file); diff --git a/test/extend.c b/test/extend.c index a3562fa..2cadb1c 100644 --- a/test/extend.c +++ b/test/extend.c @@ -54,13 +54,13 @@ main (void) assert (mem_space>=0); /* Create the file */ - file = H5Fcreate ("extend.h5", H5F_ACC_TRUNC, H5C_DEFAULT, H5C_DEFAULT); + file = H5Fcreate ("extend.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); assert (file>=0); /* Create the dataset which is originally NX by NY */ - cparms = H5Ccreate (H5C_DATASET_CREATE); + cparms = H5Pcreate (H5P_DATASET_CREATE); assert (cparms>=0); - status = H5Cset_chunk (cparms, 2, chunk_dims); + status = H5Pset_chunk (cparms, 2, chunk_dims); assert (status>=0); dataset = H5Dcreate (file, "dataset", H5T_NATIVE_INT, mem_space, cparms); assert (dataset>=0); @@ -85,7 +85,7 @@ main (void) /* Write to the hyperslab */ status = H5Dwrite (dataset, H5T_NATIVE_INT, mem_space, file_space, - H5C_DEFAULT, buf1); + H5P_DEFAULT, buf1); assert (status>=0); H5Sclose (file_space); } @@ -108,7 +108,7 @@ main (void) /* Read */ status = H5Dread (dataset, H5T_NATIVE_INT, mem_space, file_space, - H5C_DEFAULT, buf2); + H5P_DEFAULT, buf2); assert (status>=0); /* Compare */ diff --git a/test/istore.c b/test/istore.c index f5b4b04..4a07337 100644 --- a/test/istore.c +++ b/test/istore.c @@ -9,7 +9,7 @@ */ #include #include -#include +#include #include #include #include @@ -573,8 +573,8 @@ main(int argc, char *argv[]) /* * Use larger file addresses... */ - template_id = H5Ccreate(H5C_FILE_CREATE); - H5Cset_sizes(template_id, 8, 0); + template_id = H5Pcreate(H5P_FILE_CREATE); + H5Pset_sizes(template_id, 8, 0); creation_template = H5A_object(template_id); /* Create the test file */ diff --git a/test/tfile.c b/test/tfile.c index d252587..1daca76 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -28,7 +28,7 @@ static char RcsId[] = "$Revision$"; #include #include -#include +#include #include #define F1_USERBLOCK_SIZE 0 @@ -71,11 +71,11 @@ test_file_create(void) MESSAGE(5, ("Testing Low-Level File Creation I/O\n")); /* Create first file */ - fid1 = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5C_DEFAULT, H5C_DEFAULT); + fid1 = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(fid1, FAIL, "H5Fcreate"); /* Try to create first file again (should fail) */ - fid2 = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5C_DEFAULT, H5C_DEFAULT); + fid2 = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); VERIFY(fid2, FAIL, "H5Fcreate"); /* Get the file-creation template */ @@ -83,19 +83,19 @@ test_file_create(void) CHECK(tmpl1, FAIL, "H5Fget_create_template"); /* Get the file-creation parameters */ - ret = H5Cget_userblock(tmpl1, &parm); - CHECK(ret, FAIL, "H5Cget_userblock"); - VERIFY(parm, F1_USERBLOCK_SIZE, "H5Cget_userblock"); + ret = H5Pget_userblock(tmpl1, &parm); + CHECK(ret, FAIL, "H5Pget_userblock"); + VERIFY(parm, F1_USERBLOCK_SIZE, "H5Pget_userblock"); - ret = H5Cget_sizes(tmpl1, &parm, &parm2); - CHECK(ret, FAIL, "H5Cget_sizes"); - VERIFY(parm, F1_OFFSET_SIZE, "H5Cget_sizes"); - VERIFY(parm2, F1_LENGTH_SIZE, "H5Cget_sizes"); + ret = H5Pget_sizes(tmpl1, &parm, &parm2); + CHECK(ret, FAIL, "H5Pget_sizes"); + VERIFY(parm, F1_OFFSET_SIZE, "H5Pget_sizes"); + VERIFY(parm2, F1_LENGTH_SIZE, "H5Pget_sizes"); - ret = H5Cget_sym_k(tmpl1, &iparm, &iparm2); - CHECK(ret, FAIL, "H5Cget_sym_k"); - VERIFY(iparm, F1_SYM_INTERN_K, "H5Cget_sym_k"); - VERIFY(iparm2, F1_SYM_LEAF_K, "H5Cget_sym_k"); + ret = H5Pget_sym_k(tmpl1, &iparm, &iparm2); + CHECK(ret, FAIL, "H5Pget_sym_k"); + VERIFY(iparm, F1_SYM_INTERN_K, "H5Pget_sym_k"); + VERIFY(iparm2, F1_SYM_LEAF_K, "H5Pget_sym_k"); /* Release file-creation template */ ret = H5Mclose(tmpl1); @@ -108,24 +108,24 @@ test_file_create(void) #endif /* Create a new file with a non-standard file-creation template */ - tmpl1 = H5Ccreate(H5C_FILE_CREATE); - CHECK(tmpl1, FAIL, "H5Cnew"); + tmpl1 = H5Pcreate(H5P_FILE_CREATE); + CHECK(tmpl1, FAIL, "H5Pnew"); /* Set the new file-creation parameters */ - ret = H5Cset_userblock(tmpl1, F2_USERBLOCK_SIZE); - CHECK(ret, FAIL, "H5Cset_userblock"); + ret = H5Pset_userblock(tmpl1, F2_USERBLOCK_SIZE); + CHECK(ret, FAIL, "H5Pset_userblock"); - ret = H5Cset_sizes(tmpl1, F2_OFFSET_SIZE, F2_LENGTH_SIZE); - CHECK(ret, FAIL, "H5Cset_sizes"); + ret = H5Pset_sizes(tmpl1, F2_OFFSET_SIZE, F2_LENGTH_SIZE); + CHECK(ret, FAIL, "H5Pset_sizes"); - ret = H5Cset_sym_k(tmpl1, F2_SYM_INTERN_K, F2_SYM_LEAF_K); - CHECK(ret, FAIL, "H5Cset_sym_k"); + ret = H5Pset_sym_k(tmpl1, F2_SYM_INTERN_K, F2_SYM_LEAF_K); + CHECK(ret, FAIL, "H5Pset_sym_k"); /* * Try to create second file, with non-standard file-creation template * params. */ - fid2 = H5Fcreate(FILE2, H5F_ACC_TRUNC, tmpl1, H5C_DEFAULT); + fid2 = H5Fcreate(FILE2, H5F_ACC_TRUNC, tmpl1, H5P_DEFAULT); CHECK(fid2, FAIL, "H5Fcreate"); /* Release file-creation template */ @@ -137,19 +137,19 @@ test_file_create(void) CHECK(tmpl1, FAIL, "H5Fget_create_template"); /* Get the file-creation parameters */ - ret = H5Cget_userblock(tmpl1, &parm); - CHECK(ret, FAIL, "H5Cget_userblock"); - VERIFY(parm, F2_USERBLOCK_SIZE, "H5Cget_userblock"); + ret = H5Pget_userblock(tmpl1, &parm); + CHECK(ret, FAIL, "H5Pget_userblock"); + VERIFY(parm, F2_USERBLOCK_SIZE, "H5Pget_userblock"); - ret = H5Cget_sizes(tmpl1, &parm, &parm2); - CHECK(ret, FAIL, "H5Cget_sizes"); - VERIFY(parm, F2_OFFSET_SIZE, "H5Cget_sizes"); - VERIFY(parm2, F2_LENGTH_SIZE, "H5Cget_sizes"); + ret = H5Pget_sizes(tmpl1, &parm, &parm2); + CHECK(ret, FAIL, "H5Pget_sizes"); + VERIFY(parm, F2_OFFSET_SIZE, "H5Pget_sizes"); + VERIFY(parm2, F2_LENGTH_SIZE, "H5Pget_sizes"); - ret = H5Cget_sym_k(tmpl1, &iparm, &iparm2); - CHECK(ret, FAIL, "H5Cget_sym_k"); - VERIFY(iparm, F2_SYM_INTERN_K, "H5Cget_sym_k"); - VERIFY(iparm2, F2_SYM_LEAF_K, "H5Cget_sym_k"); + ret = H5Pget_sym_k(tmpl1, &iparm, &iparm2); + CHECK(ret, FAIL, "H5Pget_sym_k"); + VERIFY(iparm, F2_SYM_INTERN_K, "H5Pget_sym_k"); + VERIFY(iparm2, F2_SYM_LEAF_K, "H5Pget_sym_k"); /* Clone the file-creation template */ tmpl2 = H5Mcopy(tmpl1); @@ -160,14 +160,14 @@ test_file_create(void) CHECK(ret, FAIL, "H5Mrelease"); /* Set the new file-creation parameter */ - ret = H5Cset_userblock(tmpl2, F3_USERBLOCK_SIZE); - CHECK(ret, FAIL, "H5Cset_userblock"); + ret = H5Pset_userblock(tmpl2, F3_USERBLOCK_SIZE); + CHECK(ret, FAIL, "H5Pset_userblock"); /* * Try to create second file, with non-standard file-creation template * params */ - fid3 = H5Fcreate(FILE3, H5F_ACC_TRUNC, tmpl2, H5C_DEFAULT); + fid3 = H5Fcreate(FILE3, H5F_ACC_TRUNC, tmpl2, H5P_DEFAULT); CHECK(fid3, FAIL, "H5Fcreate"); /* Release file-creation template */ @@ -179,19 +179,19 @@ test_file_create(void) CHECK(tmpl1, FAIL, "H5Fget_create_template"); /* Get the file-creation parameters */ - ret = H5Cget_userblock(tmpl1, &parm); - CHECK(ret, FAIL, "H5Cget_userblock"); - VERIFY(parm, F3_USERBLOCK_SIZE, "H5Cget_userblock"); + ret = H5Pget_userblock(tmpl1, &parm); + CHECK(ret, FAIL, "H5Pget_userblock"); + VERIFY(parm, F3_USERBLOCK_SIZE, "H5Pget_userblock"); - ret = H5Cget_sizes(tmpl1, &parm, &parm2); - CHECK(ret, FAIL, "H5Cget_sizes"); - VERIFY(parm, F3_OFFSET_SIZE, "H5Cget_sizes"); - VERIFY(parm2, F3_LENGTH_SIZE, "H5Cget_sizes"); + ret = H5Pget_sizes(tmpl1, &parm, &parm2); + CHECK(ret, FAIL, "H5Pget_sizes"); + VERIFY(parm, F3_OFFSET_SIZE, "H5Pget_sizes"); + VERIFY(parm2, F3_LENGTH_SIZE, "H5Pget_sizes"); - ret = H5Cget_sym_k(tmpl1, &iparm, &iparm2); - CHECK(ret, FAIL, "H5Cget_sym_k"); - VERIFY(iparm, F3_SYM_INTERN_K, "H5Cget_sym_k"); - VERIFY(iparm2, F3_SYM_LEAF_K, "H5Cget_sym_k"); + ret = H5Pget_sym_k(tmpl1, &iparm, &iparm2); + CHECK(ret, FAIL, "H5Pget_sym_k"); + VERIFY(iparm, F3_SYM_INTERN_K, "H5Pget_sym_k"); + VERIFY(iparm2, F3_SYM_LEAF_K, "H5Pget_sym_k"); /* Release file-creation template */ ret = H5Mclose(tmpl1); @@ -229,7 +229,7 @@ test_file_open(void) MESSAGE(5, ("Testing Low-Level File Opening I/O\n")); /* Open first file */ - fid1 = H5Fopen(FILE2, H5F_ACC_RDWR, H5C_DEFAULT); + fid1 = H5Fopen(FILE2, H5F_ACC_RDWR, H5P_DEFAULT); CHECK(fid1, FAIL, "H5Fopen"); /* Get the file-creation template */ @@ -237,19 +237,19 @@ test_file_open(void) CHECK(tmpl1, FAIL, "H5Fget_create_template"); /* Get the file-creation parameters */ - ret = H5Cget_userblock(tmpl1, &parm); - CHECK(ret, FAIL, "H5Cget_userblock"); - VERIFY(parm, F2_USERBLOCK_SIZE, "H5Cget_userblock"); - - ret = H5Cget_sizes(tmpl1, &parm, &parm2); - CHECK(ret, FAIL, "H5Cget_sizes"); - VERIFY(parm, F2_OFFSET_SIZE, "H5Cget_sizes"); - VERIFY(parm2, F2_LENGTH_SIZE, "H5Cget_sizes"); - - ret = H5Cget_sym_k(tmpl1, &iparm, &iparm2); - CHECK(ret, FAIL, "H5Cget_sym_k"); - VERIFY(iparm, F2_SYM_INTERN_K, "H5Cget_sym_k"); - VERIFY(iparm2, F2_SYM_LEAF_K, "H5Cget_sym_k"); + ret = H5Pget_userblock(tmpl1, &parm); + CHECK(ret, FAIL, "H5Pget_userblock"); + VERIFY(parm, F2_USERBLOCK_SIZE, "H5Pget_userblock"); + + ret = H5Pget_sizes(tmpl1, &parm, &parm2); + CHECK(ret, FAIL, "H5Pget_sizes"); + VERIFY(parm, F2_OFFSET_SIZE, "H5Pget_sizes"); + VERIFY(parm2, F2_LENGTH_SIZE, "H5Pget_sizes"); + + ret = H5Pget_sym_k(tmpl1, &iparm, &iparm2); + CHECK(ret, FAIL, "H5Pget_sym_k"); + VERIFY(iparm, F2_SYM_INTERN_K, "H5Pget_sym_k"); + VERIFY(iparm2, F2_SYM_LEAF_K, "H5Pget_sym_k"); /* Release file-creation template */ ret = H5Mclose(tmpl1); diff --git a/test/th5s.c b/test/th5s.c index faafd5e..aca8df0 100644 --- a/test/th5s.c +++ b/test/th5s.c @@ -70,7 +70,7 @@ test_h5p_basic(void) MESSAGE(5, ("Testing Datatype Manipulation\n")); /* Create file */ - fid1 = H5Fcreate(FILE, H5F_ACC_TRUNC, H5C_DEFAULT, H5C_DEFAULT); + fid1 = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(fid1, FAIL, "H5Fcreate"); sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL); diff --git a/test/theap.c b/test/theap.c index ec8a71d..4a4862d 100644 --- a/test/theap.c +++ b/test/theap.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include @@ -55,7 +55,7 @@ test_heap(void) MESSAGE(5, ("Testing Heaps\n")); /* Create the file */ - fid = H5Fcreate("theap.h5", H5F_ACC_TRUNC, H5C_DEFAULT, H5C_DEFAULT); + fid = H5Fcreate("theap.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fcreate"); f = H5A_object(fid); CHECK(f, NULL, "H5Aatom_object"); diff --git a/test/tohdr.c b/test/tohdr.c index bbeb895..00d4322 100644 --- a/test/tohdr.c +++ b/test/tohdr.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include #include @@ -59,7 +59,7 @@ test_ohdr(void) MESSAGE(5, ("Testing Object Headers\n")); /* create the file */ - fid = H5Fcreate("tohdr.h5", H5F_ACC_TRUNC, H5C_DEFAULT, H5C_DEFAULT); + fid = H5Fcreate("tohdr.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fcreate"); f = H5A_object(fid); CHECK(f, NULL, "H5Aatom_object"); diff --git a/test/tstab.c b/test/tstab.c index 58a07d5..4210db7 100644 --- a/test/tstab.c +++ b/test/tstab.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include #include @@ -67,7 +67,7 @@ test_1(void) */ /* create the file */ - fid = H5Fcreate("tstab1.h5", H5F_ACC_TRUNC, H5C_DEFAULT, H5C_DEFAULT); + fid = H5Fcreate("tstab1.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fcreate"); f = H5A_object(fid); CHECK(f, NULL, "H5Aatom_object"); @@ -130,7 +130,7 @@ test_1(void) */ /* create the file */ - fid = H5Fcreate("tstab1.h5", H5F_ACC_TRUNC, H5C_DEFAULT, H5C_DEFAULT); + fid = H5Fcreate("tstab1.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fcreate"); f = H5A_object(fid); CHECK(f, NULL, "H5Aatom_object"); @@ -233,17 +233,17 @@ test_2(void) * Use larger symbol table data structures to be more efficient, use * defaults to bang harder on the library for testing. */ - create_plist = H5Ccreate(H5C_FILE_CREATE); - H5Cset_sym_k(create_plist, 16, 16); + create_plist = H5Pcreate(H5P_FILE_CREATE); + H5Pset_sym_k(create_plist, 16, 16); /* * File access property list. */ #if 0 - access_plist = H5Ccreate (H5C_FILE_ACCESS); - H5Cset_core (access_plist, 3000000); + access_plist = H5Pcreate (H5P_FILE_ACCESS); + H5Pset_core (access_plist, 3000000); #else - access_plist = H5C_DEFAULT; + access_plist = H5P_DEFAULT; #endif /* create the file */ -- cgit v0.12