Commit 0de2f00b authored by Marc Howison's avatar Marc Howison

fixed H5PartGetNumParticles to correctly count indexed views; added type...

fixed H5PartGetNumParticles to correctly count indexed views; added type parameter to H5BlockGetFieldInfo/ByName
parent 3300a665
......@@ -82,6 +82,9 @@ to perform queries that select a small subset of non-contiguous particles.
Because views are now supported on write, it is possible to write a dataset
using multiple 'passes' or to leave some values unwritten.
Also, all views are now *inclusive*, so that a view of (0,9) corresponds
to the 10 items 0, 1, 2, ... 9.
Internal Handling of Dataspaces
-------------------------------
......@@ -121,6 +124,12 @@ fixed limit of 64 chars is imposed. Dataset names that are longer than this are
truncated and a warning is printed. We expect that most users are using
short canoncical names like x, px, id, etc.
Changes to Existing API
-----------------------
The H5BlockGetFieldInfo and H5BlockGetFieldInfoByName calls now both include
a parameter for the 'type' of the field.
#### H5PART 1.4 ##############################################################
......
......@@ -1495,10 +1495,12 @@ _get_field_info (
const char *field_name, /*!< IN: field name to get info about */
h5part_int64_t *grid_rank, /*!< OUT: rank of grid */
h5part_int64_t *grid_dims, /*!< OUT: dimensions of grid */
h5part_int64_t *field_rank /*!< OUT: rank of field (1 or 3) */
h5part_int64_t *field_rank, /*!< OUT: rank of field (1 or 3) */
h5part_int64_t *type /*!< OUT: datatype */
) {
hsize_t dims[16];
hsize_t _grid_rank, _field_rank;
h5part_int64_t i, j;
h5part_int64_t herr = _open_block_group ( f );
......@@ -1523,17 +1525,29 @@ _get_field_info (
hid_t dataspace_id = H5Dget_space ( dataset_id );
if ( dataspace_id < 0 ) return HANDLE_H5D_GET_SPACE_ERR;
*grid_rank = H5Sget_simple_extent_dims ( dataspace_id, dims, NULL );
if ( *grid_rank < 0 ) return HANDLE_H5S_GET_SIMPLE_EXTENT_DIMS_ERR;
for ( i = 0, j = *grid_rank-1; i < *grid_rank; i++, j-- )
grid_dims[i] = (h5part_int64_t)dims[j];
_grid_rank = H5Sget_simple_extent_dims ( dataspace_id, dims, NULL );
if ( _grid_rank < 0 ) return HANDLE_H5S_GET_SIMPLE_EXTENT_DIMS_ERR;
if ( grid_rank ) *grid_rank = (h5part_int64_t) _grid_rank;
if ( grid_dims ) {
for ( i = 0, j = _grid_rank-1; i < _grid_rank; i++, j-- )
grid_dims[i] = (h5part_int64_t)dims[j];
}
*field_rank = _H5Part_get_num_objects (
_field_rank = _H5Part_get_num_objects (
f->block->blockgroup,
field_name,
H5G_DATASET );
if ( *field_rank < 0 ) return *field_rank;
if ( _field_rank < 0 ) return *field_rank;
if ( field_rank ) *field_rank = (h5part_int64_t) _field_rank;
hid_t h5type = H5Dget_type ( dataset_id );
if ( h5type < 0 ) return HANDLE_H5D_GET_TYPE_ERR;
if ( type ) {
*type = _H5Part_normalize_h5_type ( h5type );
if ( *type < 0 ) return *type;
}
herr = H5Sclose ( dataspace_id );
if ( herr < 0 ) return HANDLE_H5S_CLOSE_ERR;
......@@ -1568,7 +1582,8 @@ H5BlockGetFieldInfo (
const h5part_int64_t len_field_name, /*!< IN: buffer size */
h5part_int64_t *grid_rank, /*!< OUT: grid rank */
h5part_int64_t *grid_dims, /*!< OUT: grid dimensions */
h5part_int64_t *field_rank /*!< OUT: field rank */
h5part_int64_t *field_rank, /*!< OUT: field rank */
h5part_int64_t *type /*!< OUT: datatype */
) {
SET_FNAME ( "H5BlockGetFieldInfo" );
......@@ -1585,7 +1600,7 @@ H5BlockGetFieldInfo (
if ( herr < 0 ) return herr;
return _get_field_info (
f, field_name, grid_rank, grid_dims, field_rank );
f, field_name, grid_rank, grid_dims, field_rank, type );
}
/*!
......@@ -1601,7 +1616,8 @@ H5BlockGetFieldInfoByName (
const char *field_name, /*!< IN: field name */
h5part_int64_t *grid_rank, /*!< OUT: grid rank */
h5part_int64_t *grid_dims, /*!< OUT: grid dimensions */
h5part_int64_t *field_rank /*!< OUT: field rank */
h5part_int64_t *field_rank, /*!< OUT: field rank */
h5part_int64_t *type /*!< OUT: datatype */
) {
SET_FNAME ( "H5BlockGetFieldInfo" );
......@@ -1609,7 +1625,7 @@ H5BlockGetFieldInfoByName (
CHECK_TIMEGROUP( f );
return _get_field_info (
f, field_name, grid_rank, grid_dims, field_rank );
f, field_name, grid_rank, grid_dims, field_rank, type );
}
/********************** reading and writing attribute ************************/
......
......@@ -102,6 +102,7 @@ INTEGER*8 FUNCTION h5bl_getfieldinfo ( filehandle, idx, field_name, grid_rank, g
INTEGER*8, INTENT(OUT) :: grid_rank
INTEGER*8, INTENT(OUT) :: grid_dims(*)
INTEGER*8, INTENT(OUT) :: field_dims
INTEGER*8, INTENT(OUT) :: type
END FUNCTION
!> \ingroup h5blockf_model
......
......@@ -88,7 +88,8 @@ H5BlockGetFieldInfo (
const h5part_int64_t len_name,
h5part_int64_t *grid_rank,
h5part_int64_t *grid_dims,
h5part_int64_t *field_rank
h5part_int64_t *field_rank,
h5part_int64_t *type
);
h5part_int64_t
......@@ -97,7 +98,8 @@ H5BlockGetFieldInfoByName (
const char *field_name,
h5part_int64_t *grid_rank,
h5part_int64_t *grid_dims,
h5part_int64_t *field_rank
h5part_int64_t *field_rank,
h5part_int64_t *type
);
h5part_int64_t
......
......@@ -194,6 +194,7 @@ h5bl_getfieldinfo (
h5part_int64_t *grid_rank,
h5part_int64_t *grid_dims,
h5part_int64_t *field_dims,
h5part_int64_t *type,
const int l_field_name
) {
......@@ -201,7 +202,7 @@ h5bl_getfieldinfo (
h5part_int64_t herr = H5BlockGetFieldInfo (
filehandle, *idx, field_name, l_field_name,
grid_rank, grid_dims, field_dims );
grid_rank, grid_dims, field_dims, type );
_H5Part_strc2for ( field_name, l_field_name );
return herr;
}
......
......@@ -340,6 +340,7 @@ _H5Part_open_file (
f->memshape = H5S_ALL;
f->viewstart = -1;
f->viewend = -1;
f->viewindexed = 0;
f->throttle = 0;
_H5Part_print_debug (
......@@ -2399,13 +2400,15 @@ H5PartGetDatasetInfo (
, H5P_DEFAULT
#endif
);
if ( dataset < 0 ) HANDLE_H5D_OPEN_ERR ( dataset_name );
if ( dataset < 0 ) return HANDLE_H5D_OPEN_ERR ( dataset_name );
h5type = H5Dget_type ( dataset );
if ( h5type < 0 ) HANDLE_H5D_GET_TYPE_ERR;
if ( h5type < 0 ) return HANDLE_H5D_GET_TYPE_ERR;
if ( type ) *type = _H5Part_normalize_h5_type ( h5type );
if ( *type < 0 ) return *type;
if ( type ) {
*type = _H5Part_normalize_h5_type ( h5type );
if ( *type < 0 ) return *type;
}
if ( nelem )
{
......@@ -2434,7 +2437,7 @@ _H5Part_has_view (
H5PartFile *f
) {
return ( f->viewstart >= 0 ) && ( f->viewend >= 0 );
return ( f->viewindexed || ( f->viewstart >= 0 && f->viewend >= 0 ));
}
h5part_int64_t
......@@ -2491,6 +2494,11 @@ _H5Part_get_num_particles (
nparticles = H5Sget_select_npoints ( f->diskshape );
if ( nparticles < 0 ) return HANDLE_H5S_GET_SELECT_NPOINTS_ERR;
_H5Part_print_debug (
"Found %lld points with H5Sget_select_npoints",
(long long)nparticles );
#if 0 // this does not work for indices
/* double check that the size of the diskshape agrees with
* the size of the view */
if ( nparticles != f->viewend - f->viewstart + 1 ) {
......@@ -2500,6 +2508,7 @@ _H5Part_get_num_particles (
return HANDLE_H5PART_BAD_VIEW_ERR (
f->viewstart, f->viewend);
}
#endif
}
/* otherwise, report all particles on disk in the first dataset
* for this timestep */
......@@ -2577,6 +2586,7 @@ _reset_view (
f->viewstart = -1;
f->viewend = -1;
f->viewindexed = 0;
if ( f->diskshape != H5S_ALL ) {
herr = H5Sclose ( f->diskshape );
......@@ -2781,6 +2791,8 @@ _set_view_indices (
}
if ( herr < 0 ) return HANDLE_H5S_SELECT_ELEMENTS_ERR;
f->viewindexed = 1;
return H5PART_SUCCESS;
}
......@@ -2869,7 +2881,7 @@ H5PartSetViewIndices (
Use \c H5PartHasView() to see if the view is smaller than the
total dataset.
\return the number of elements in the view
\return number of elements in the view or error code
*/
h5part_int64_t
H5PartGetView (
......@@ -2882,6 +2894,13 @@ H5PartGetView (
CHECK_FILEHANDLE( f );
if ( f->viewindexed ) {
_H5Part_print_error (
"The current view has an index selection, but "
"this function only works for ranged views." );
return H5PART_ERR_INVAL;
}
if ( f->timegroup < 0 ) {
h5part_int64_t herr = _H5Part_set_step ( f, 0 );
if ( herr < 0 ) return herr;
......
......@@ -60,6 +60,7 @@ struct H5PartFile {
h5part_int64_t viewstart; /* -1 if no view is available: A "view" looks */
h5part_int64_t viewend; /* at a subset of the data. */
char viewindexed; /* flag for an indexed view */
/**
the number of particles in each processor.
......
......@@ -209,10 +209,16 @@ test_read_data64(H5PartFile *file, int nparticles, int step)
status = H5PartSetViewIndices(file, indices, 4);
RETURN(status, H5PART_SUCCESS, "H5PartSetViewIndices");
val = H5PartGetNumParticles(file);
IVALUE(val, 4, "particle count");
status = H5PartReadDataFloat64(file, "x", x);
RETURN(status, H5PART_SUCCESS, "H5PartReadDataFloat64");
FVALUE(x[2], (double)(rank*2+9+nparticles*t), "x data");
val = H5PartGetNumParticles(file);
IVALUE(val, 4, "particle count");
status = H5PartSetViewIndices(file, NULL, 4);
RETURN(status, H5PART_SUCCESS, "H5PartSetViewIndices");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment