diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/H5A.c | 5 | ||||
-rw-r--r-- | src/H5D.c | 79 | ||||
-rw-r--r-- | src/H5Osdspace.c | 38 | ||||
-rw-r--r-- | src/H5S.c | 52 | ||||
-rw-r--r-- | src/H5Sdbg.c | 124 | ||||
-rw-r--r-- | src/H5Spkg.h | 16 | ||||
-rw-r--r-- | src/H5Sprivate.h | 1 | ||||
-rwxr-xr-x | src/Makefile.am | 3 | ||||
-rw-r--r-- | src/Makefile.in | 5 |
9 files changed, 239 insertions, 84 deletions
@@ -358,6 +358,11 @@ H5A_create(const H5G_loc_t *loc, const char *name, const H5T_t *type, /* Copy the dataspace for the attribute */ attr->ds = H5S_copy(space, FALSE); + /* Set the latest format for dataspace, if requested */ + if(H5F_USE_LATEST_FORMAT(loc->oloc->file)) + if(H5S_set_latest_version(attr->ds) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set latest version of dataspace") + /* Mark it initially set to initialized */ attr->initialized = TRUE; /*for now, set to false later*/ @@ -67,6 +67,7 @@ static herr_t H5D_init_storage(H5D_t *dataset, hbool_t full_overwrite, hid_t dxp static H5D_shared_t *H5D_new(hid_t dcpl_id, hbool_t creating, hbool_t vl_type); static herr_t H5D_init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, const H5T_t *type); +static herr_t H5D_init_space(H5F_t *file, const H5D_t *dset, const H5S_t *space); static herr_t H5D_update_oh_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset); static herr_t H5D_open_oid(H5D_t *dataset, hid_t dxpl_id); static herr_t H5D_get_space_status(H5D_t *dset, H5D_space_status_t *allocation, hid_t dxpl_id); @@ -1076,6 +1077,54 @@ done: /*------------------------------------------------------------------------- + * Function: H5D_init_space + * + * Purpose: Copy a dataspace for a dataset's use, performing all the + * necessary adjustments, etc. + * + * Return: Success: SUCCEED + * Failure: FAIL + * + * Programmer: Quincey Koziol + * Tuesday, July 24, 2007 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5D_init_space(H5F_t *file, const H5D_t *dset, const H5S_t *space) +{ + hbool_t use_latest_format; /* Flag indicating the newest file format should be used */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5D_init_space) + + /* Sanity checking */ + HDassert(file); + HDassert(dset); + HDassert(space); + + /* Get the file's 'use the latest version of the format' flag */ + use_latest_format = H5F_USE_LATEST_FORMAT(file); + + /* Copy dataspace for dataset */ + if(NULL == (dset->shared->space = H5S_copy(space, FALSE))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't copy dataspace") + + /* Set the latest format, if requested */ + if(use_latest_format) + if(H5S_set_latest_version(dset->shared->space) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set latest version of datatype") + + /* Set the dataset's dataspace to 'all' selection */ + if(H5S_select_all(dset->shared->space, TRUE) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set all selection") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5D_init_space() */ + + +/*------------------------------------------------------------------------- * Function: H5D_update_oh_info * * Purpose: Create and fill object header for dataset @@ -1389,35 +1438,31 @@ H5D_create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, if(NULL == (new_dset->shared = H5D_new(dcpl_id, TRUE, has_vl_type))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - /* Copy datatype for dataset */ + /* Copy & initialize datatype for dataset */ if(H5D_init_type(file, new_dset, type_id, type) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "can't copy datatype") + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "can't copy datatype") - /* Check if the filters in the DCPL can be applied to this dataset */ - if(H5Z_can_apply(new_dset->shared->dcpl_id,new_dset->shared->type_id) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, NULL, "I/O filters can't operate on this dataset") + /* Copy & initialize dataspace for dataset */ + if(H5D_init_space(file, new_dset, space) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "can't copy dataspace") /* Set the dataset's checked_filters flag to enable writing */ new_dset->shared->checked_filters = TRUE; - /* Copy dataspace for dataset */ - if((new_dset->shared->space = H5S_copy(space, FALSE))==NULL) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy dataspace") - - /* Set the dataset's dataspace to 'all' selection */ - if(H5S_select_all(new_dset->shared->space, TRUE) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set all selection") - - /* Make the "set local" filter callbacks for this dataset */ - if(H5Z_set_local(new_dset->shared->dcpl_id,new_dset->shared->type_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to set local filter parameters") - /* Check if the dataset has a non-default DCPL & get important values, if so */ if(new_dset->shared->dcpl_id != H5P_DATASET_CREATE_DEFAULT) { H5D_layout_t *layout; /* Dataset's layout information */ H5O_pline_t *pline; /* Dataset's I/O pipeline information */ H5O_fill_t *fill; /* Dataset's fill value info */ + /* Check if the filters in the DCPL can be applied to this dataset */ + if(H5Z_can_apply(new_dset->shared->dcpl_id, new_dset->shared->type_id) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, NULL, "I/O filters can't operate on this dataset") + + /* Make the "set local" filter callbacks for this dataset */ + if(H5Z_set_local(new_dset->shared->dcpl_id, new_dset->shared->type_id) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to set local filter parameters") + /* Get new dataset's property list object */ if(NULL == (dc_plist = (H5P_genplist_t *)H5I_object(new_dset->shared->dcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "can't get dataset creation property list") diff --git a/src/H5Osdspace.c b/src/H5Osdspace.c index bb3e349..3581863 100644 --- a/src/H5Osdspace.c +++ b/src/H5Osdspace.c @@ -81,19 +81,6 @@ const H5O_msg_class_t H5O_MSG_SDSPACE[1] = {{ H5O_sdspace_shared_debug /* debug the message */ }}; -/* Initial version of the dataspace information */ -#define H5O_SDSPACE_VERSION_1 1 - -/* This version adds support for "null" dataspaces, encodes the type of the - * dataspace in the message and eliminated the rest of the "reserved" - * bytes. - */ -#define H5O_SDSPACE_VERSION_2 2 - -/* The latest version of the format. Look through the 'encode' - * and 'size' callbacks for places to change when updating this. */ -#define H5O_SDSPACE_VERSION_LATEST H5O_SDSPACE_VERSION_2 - /* Declare external the free list for H5S_extent_t's */ H5FL_EXTERN(H5S_extent_t); @@ -143,6 +130,7 @@ H5O_sdspace_decode(H5F_t *f, hid_t UNUSED dxpl_id, unsigned UNUSED mesg_flags, version = *p++; if(version < H5O_SDSPACE_VERSION_1 || version > H5O_SDSPACE_VERSION_2) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "wrong version number in dataspace message") + sdim->version = version; /* Get rank */ sdim->rank = *p++; @@ -165,6 +153,7 @@ H5O_sdspace_decode(H5F_t *f, hid_t UNUSED dxpl_id, unsigned UNUSED mesg_flags, /* Increment past reserved byte */ p++; } /* end else */ + HDassert(sdim->type != H5S_NULL || sdim->version >= H5O_SDSPACE_VERSION_2); /* Only Version 1 has these reserved bytes */ if(version == H5O_SDSPACE_VERSION_1) @@ -248,8 +237,6 @@ H5O_sdspace_encode(H5F_t *f, uint8_t *p, const void *_mesg) { const H5S_extent_t *sdim = (const H5S_extent_t *)_mesg; unsigned flags = 0; - unsigned version; - hbool_t use_latest_format; /* Flag indicating the newest file format should be used */ unsigned u; /* Local counting variable */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_sdspace_encode) @@ -259,17 +246,10 @@ H5O_sdspace_encode(H5F_t *f, uint8_t *p, const void *_mesg) HDassert(p); HDassert(sdim); - /* Get the file's 'use the latest version of the format' flag */ - use_latest_format = H5F_USE_LATEST_FORMAT(f); - /* Version */ - if(use_latest_format) - version = H5O_SDSPACE_VERSION_LATEST; - else if(sdim->type == H5S_NULL) - version = H5O_SDSPACE_VERSION_2; - else - version = H5O_SDSPACE_VERSION_1; - *p++ = version; + HDassert(sdim->version > 0); + HDassert(sdim->type != H5S_NULL || sdim->version >= H5O_SDSPACE_VERSION_2); + *p++ = sdim->version; /* Rank */ *p++ = sdim->rank; @@ -280,7 +260,7 @@ H5O_sdspace_encode(H5F_t *f, uint8_t *p, const void *_mesg) *p++ = flags; /* Dataspace type */ - if(version > H5O_SDSPACE_VERSION_1) + if(sdim->version > H5O_SDSPACE_VERSION_1) *p++ = sdim->type; else { *p++ = 0; /*reserved*/ @@ -370,20 +350,16 @@ static size_t H5O_sdspace_size(const H5F_t *f, const void *_mesg) { const H5S_extent_t *space = (const H5S_extent_t *)_mesg; - hbool_t use_latest_format; /* Flag indicating the newest file format should be used */ size_t ret_value; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5O_sdspace_size) - /* Get the file's 'use the latest version of the format' flag */ - use_latest_format = H5F_USE_LATEST_FORMAT(f); - /* Basic information for all dataspace messages */ ret_value = 1 + /* Version */ 1 + /* Rank */ 1 + /* Flags */ 1 + /* Dataspace type/reserved */ - (use_latest_format ? 0 : 4); /* Eliminated/reserved */ + ((space->version > H5O_SDSPACE_VERSION_1) ? 0 : 4); /* Eliminated/reserved */ /* Add in the dimension sizes */ ret_value += space->rank * H5F_SIZEOF_SIZE(f); @@ -313,6 +313,10 @@ H5S_create(H5S_class_t type) /* Initialize default dataspace state */ new_ds->extent.type = type; + if(type == H5S_NULL) + new_ds->extent.version = H5O_SDSPACE_VERSION_2; + else + new_ds->extent.version = H5O_SDSPACE_VERSION_1; new_ds->extent.rank = 0; new_ds->extent.size = new_ds->extent.max = NULL; @@ -618,6 +622,7 @@ H5S_extent_copy(H5S_extent_t *dst, const H5S_extent_t *src) /* Copy the regular fields */ dst->type = src->type; + dst->version = src->version; dst->nelem = src->nelem; dst->rank = src->rank; @@ -2322,50 +2327,31 @@ H5S_extent_nelem(const H5S_extent_t *ext) /*------------------------------------------------------------------------- - * Function: H5S_debug + * Function: H5S_set_latest_version * - * Purpose: Prints debugging information about a data space. + * Purpose: Set the encoding for a dataspace to the latest version. * * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke - * Tuesday, July 21, 1998 - * - * Modifications: + * Programmer: Quincey Koziol + * Tuesday, July 24, 2007 * *------------------------------------------------------------------------- */ herr_t -H5S_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE *stream, int indent, int fwidth) +H5S_set_latest_version(H5S_t *ds) { - const H5S_t *mesg = (const H5S_t*)_mesg; - - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_debug) + herr_t ret_value = SUCCEED; /* Return value */ - switch(H5S_GET_EXTENT_TYPE(mesg)) { - case H5S_NULL: - fprintf(stream, "%*s%-*s H5S_NULL\n", indent, "", fwidth, - "Space class:"); - break; - - case H5S_SCALAR: - fprintf(stream, "%*s%-*s H5S_SCALAR\n", indent, "", fwidth, - "Space class:"); - break; + FUNC_ENTER_NOAPI(H5S_set_latest_version, FAIL) - case H5S_SIMPLE: - fprintf(stream, "%*s%-*s H5S_SIMPLE\n", indent, "", fwidth, - "Space class:"); - H5O_debug_id(H5O_SDSPACE_ID, f, dxpl_id, &(mesg->extent), stream, - indent + 3, MAX(0, fwidth - 3)); - break; + /* Sanity check */ + HDassert(ds); - default: - fprintf(stream, "%*s%-*s **UNKNOWN-%ld**\n", indent, "", fwidth, - "Space class:", (long)(H5S_GET_EXTENT_TYPE(mesg))); - break; - } /* end switch */ + /* Set encoding of extent to latest version */ + ds->extent.version = H5O_SDSPACE_VERSION_LATEST; - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5S_debug() */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5S_set_latest_version() */ diff --git a/src/H5Sdbg.c b/src/H5Sdbg.c new file mode 100644 index 0000000..352795e --- /dev/null +++ b/src/H5Sdbg.c @@ -0,0 +1,124 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Created: H5Sdbg.c + * Jul 24 2007 + * Quincey Koziol <koziol@hdfgroup.org> + * + * Purpose: Dump debugging information about a dataspace + * + *------------------------------------------------------------------------- + */ + +/****************/ +/* Module Setup */ +/****************/ + +#define H5S_PACKAGE /*suppress error about including H5Spkg */ + + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Spkg.h" /* Dataspaces */ + + +/****************/ +/* Local Macros */ +/****************/ + + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Package Typedefs */ +/********************/ + + +/********************/ +/* Local Prototypes */ +/********************/ + + +/*********************/ +/* Package Variables */ +/*********************/ + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + + + +/*------------------------------------------------------------------------- + * Function: H5S_debug + * + * Purpose: Prints debugging information about a data space. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Robb Matzke + * Tuesday, July 21, 1998 + * + *------------------------------------------------------------------------- + */ +herr_t +H5S_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE *stream, int indent, + int fwidth) +{ + const H5S_t *mesg = (const H5S_t*)_mesg; + + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_debug) + + switch(H5S_GET_EXTENT_TYPE(mesg)) { + case H5S_NULL: + fprintf(stream, "%*s%-*s H5S_NULL\n", indent, "", fwidth, + "Space class:"); + break; + + case H5S_SCALAR: + fprintf(stream, "%*s%-*s H5S_SCALAR\n", indent, "", fwidth, + "Space class:"); + break; + + case H5S_SIMPLE: + fprintf(stream, "%*s%-*s H5S_SIMPLE\n", indent, "", fwidth, + "Space class:"); + H5O_debug_id(H5O_SDSPACE_ID, f, dxpl_id, &(mesg->extent), stream, + indent + 3, MAX(0, fwidth - 3)); + break; + + default: + fprintf(stream, "%*s%-*s **UNKNOWN-%ld**\n", indent, "", fwidth, + "Space class:", (long)(H5S_GET_EXTENT_TYPE(mesg))); + break; + } /* end switch */ + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5S_debug() */ + diff --git a/src/H5Spkg.h b/src/H5Spkg.h index 907b6fd..8dc2991 100644 --- a/src/H5Spkg.h +++ b/src/H5Spkg.h @@ -34,6 +34,21 @@ #define H5S_VALID_MAX 0x01 #define H5S_VALID_PERM 0x02 + +/* Initial version of the dataspace information */ +#define H5O_SDSPACE_VERSION_1 1 + +/* This version adds support for "null" dataspaces, encodes the type of the + * dataspace in the message and eliminated the rest of the "reserved" + * bytes. + */ +#define H5O_SDSPACE_VERSION_2 2 + +/* The latest version of the format. Look through the 'encode' + * and 'size' callbacks for places to change when updating this. */ +#define H5O_SDSPACE_VERSION_LATEST H5O_SDSPACE_VERSION_2 + + /* * Dataspace extent information */ @@ -42,6 +57,7 @@ struct H5S_extent_t { H5O_shared_t sh_loc; /* Shared message info (must be first) */ H5S_class_t type; /* Type of extent */ + unsigned version; /* Version of object header message to encode this object with */ hsize_t nelem; /* Number of elements in extent */ unsigned rank; /* Number of dimensions */ diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h index 1892e18..3eca730 100644 --- a/src/H5Sprivate.h +++ b/src/H5Sprivate.h @@ -214,6 +214,7 @@ H5_DLL herr_t H5S_set_extent_real(H5S_t *space, const hsize_t *size); H5_DLL H5S_t *H5S_create(H5S_class_t type); H5_DLL H5S_t *H5S_create_simple(unsigned rank, const hsize_t dims[/*rank*/], const hsize_t maxdims[/*rank*/]); +H5_DLL herr_t H5S_set_latest_version(H5S_t *ds); H5_DLL herr_t H5S_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE *stream, int indent, int fwidth); diff --git a/src/Makefile.am b/src/Makefile.am index a00dc05..a07892f 100755 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -76,7 +76,8 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5Pgcpl.c \ H5Plapl.c H5Plcpl.c H5Pocpl.c H5Pocpypl.c H5Pstrcpl.c H5Ptest.c \ H5R.c H5RC.c \ - H5RS.c H5S.c H5Sall.c H5Shyper.c H5Smpio.c H5Snone.c H5Spoint.c \ + H5RS.c \ + H5S.c H5Sall.c H5Sdbg.c H5Shyper.c H5Smpio.c H5Snone.c H5Spoint.c \ H5Sselect.c H5Stest.c H5SL.c H5SM.c H5SMbtree2.c \ H5SMcache.c H5SMtest.c H5ST.c \ H5T.c H5Tarray.c H5Tbit.c H5Tcommit.c H5Tcompound.c H5Tconv.c \ diff --git a/src/Makefile.in b/src/Makefile.in index 89f99bf..bbcab43 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -108,7 +108,7 @@ am_libhdf5_la_OBJECTS = H5.lo H5checksum.lo H5dbg.lo H5system.lo \ H5P.lo H5Pacpl.lo H5Pdcpl.lo H5Pdxpl.lo H5Pfapl.lo H5Pfcpl.lo \ H5Pfmpl.lo H5Pgcpl.lo H5Plapl.lo H5Plcpl.lo H5Pocpl.lo \ H5Pocpypl.lo H5Pstrcpl.lo H5Ptest.lo H5R.lo H5RC.lo H5RS.lo \ - H5S.lo H5Sall.lo H5Shyper.lo H5Smpio.lo H5Snone.lo H5Spoint.lo \ + H5S.lo H5Sall.lo H5Sdbg.lo H5Shyper.lo H5Smpio.lo H5Snone.lo H5Spoint.lo \ H5Sselect.lo H5Stest.lo H5SL.lo H5SM.lo H5SMbtree2.lo \ H5SMcache.lo H5SMtest.lo H5ST.lo H5T.lo H5Tarray.lo H5Tbit.lo \ H5Tcommit.lo H5Tcompound.lo H5Tconv.lo H5Tcset.lo H5Tdbg.lo H5Tdeprec.lo \ @@ -431,7 +431,7 @@ libhdf5_la_SOURCES = H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5Pgcpl.c \ H5Plapl.c H5Plcpl.c H5Pocpl.c H5Pocpypl.c H5Pstrcpl.c H5Ptest.c \ H5R.c H5RC.c \ - H5RS.c H5S.c H5Sall.c H5Shyper.c H5Smpio.c H5Snone.c H5Spoint.c \ + H5RS.c H5S.c H5Sall.c H5Sdbg.c H5Shyper.c H5Smpio.c H5Snone.c H5Spoint.c \ H5Sselect.c H5Stest.c H5SL.c H5SM.c H5SMbtree2.c \ H5SMcache.c H5SMtest.c H5ST.c H5T.c H5Tarray.c H5Tbit.c H5Tcommit.c \ H5Tcompound.c H5Tconv.c H5Tcset.c H5Tdbg.c H5Tdeprec.c H5Tenum.c H5Tfields.c \ @@ -731,6 +731,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5SMtest.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5ST.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Sall.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Sdbg.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Shyper.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Smpio.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Snone.Plo@am__quote@ |