diff --git a/NEWS b/NEWS index cac6f41..51aedf3 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,16 @@ +#### H5PART 1.6.3 ############################################################ + +New build system uses libtool and can build shared libraries. + +Fixed a bug that incorrectly identifies the number of selected points in a view +when using H5PartSetViewIndices. + +Fixed bug in Fortran test reported by several people, as well as several +incorrect views set in the C test that were causing segfaults. + +Fixed name mismatches in the Fortran interface, and an off-by-one indexing +problem. + #### H5PART 1.6.2 ############################################################ Removed H5PartSetViewEmpty diff --git a/src/H5Part.c b/src/H5Part.c index 2702cca..efe9f56 100644 --- a/src/H5Part.c +++ b/src/H5Part.c @@ -2585,7 +2585,30 @@ _H5Part_get_num_particles ( 0, dataset_name, H5PART_DATANAME_LEN ); if ( herr < 0 ) return herr; - /* returns 0 if there are no datasets on disk */ + + /* if a view exists, use its size as the number of particles */ + if ( _H5Part_has_view ( f ) ) + { + 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 ) { + _H5Part_print_warn ( + "Number of particles (%lld) does not agree " + "with view range.", (long long)nparticles ); + return HANDLE_H5PART_BAD_VIEW_ERR ( + f->viewstart, f->viewend); + } +#endif + } + /* herr is 0 if there are no datasets on disk */ else if ( herr == 0 ) { /* try to recover number of particles from a previous @@ -2614,29 +2637,6 @@ _H5Part_get_num_particles ( return 0; } } - - /* if a view exists, use its size as the number of particles */ - if ( _H5Part_has_view ( f ) ) - { - 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 ) { - _H5Part_print_warn ( - "Number of particles (%lld) does not agree " - "with view range.", (long long)nparticles ); - return HANDLE_H5PART_BAD_VIEW_ERR ( - f->viewstart, f->viewend); - } -#endif - } /* otherwise, report all particles on disk in the first dataset * for this timestep */ else @@ -2855,9 +2855,9 @@ _set_view_indices ( herr = _reset_view ( f ); if ( herr < 0 ) return herr; - if ( indices == NULL ) { + if ( indices == NULL || nelems <= 0 ) { _H5Part_print_warn ( - "View indices array is null: reseting view." ); + "View indices array is null or size is <= 0: reseting view." ); return H5PART_SUCCESS; } @@ -2880,15 +2880,7 @@ _set_view_indices ( if ( total == 0 ) return H5PART_SUCCESS; - /* check length of list */ - if ( nelems < 0 ) { - _H5Part_print_warn ( - "Array of view indices has length < 0: " - "resetting view."); - f->nparticles = 0; - } else { - f->nparticles = (hsize_t) nelems; - } + f->nparticles = (hsize_t) nelems; /* declare overall data size but then will select a subset */ f->diskshape = H5Screate_simple ( 1, &total, NULL ); @@ -3203,7 +3195,7 @@ _read_data ( if ( f->memshape != H5S_ALL ) { - nmem = H5Sget_select_npoints ( f->memshape ); + nmem = H5Sget_simple_extent_npoints ( f->memshape ); if ( nmem < 0 ) return HANDLE_H5S_GET_SELECT_NPOINTS_ERR; /* make sure the memory space selected by the view has diff --git a/test/read.c b/test/read.c index 245ae4e..213097d 100644 --- a/test/read.c +++ b/test/read.c @@ -175,10 +175,6 @@ test_read_data64(H5PartFile *file, int nparticles, int step) status = H5PartSetView(file, start, end); RETURN(status, H5PART_SUCCESS, "H5PartSetView"); - status = H5PartReadDataFloat64(file, "x", x); - RETURN(status, H5PART_SUCCESS, "H5PartReadDataFloat64"); - FVALUE(x[rank], (double)(start+rank+nparticles*t), "x data"); - val = H5PartGetView(file, &start, &end); IVALUE(val, nprocs*nparticles-start, "particle count"); IVALUE(start, rank, "view start"); @@ -187,51 +183,60 @@ test_read_data64(H5PartFile *file, int nparticles, int step) status = H5PartSetView(file, -1, -1); RETURN(status, H5PART_SUCCESS, "H5PartSetView"); + status = H5PartSetView(file, 0, nparticles-1); + RETURN(status, H5PART_SUCCESS, "H5PartSetView"); + + val = H5PartGetNumParticles(file); + IVALUE(val, nparticles, "particle count"); + status = H5PartReadDataFloat64(file, "x", x); RETURN(status, H5PART_SUCCESS, "H5PartReadDataFloat64"); IVALUE(x[rank], (double)(rank+nparticles*t), "x data"); + status = H5PartResetView(file); + RETURN(status, H5PART_SUCCESS, "H5PartResetView"); + + val = H5PartGetNumParticles(file); + IVALUE(val, nprocs*nparticles, "particle count"); + indices[0] = rank*2 + 0; indices[1] = rank*2 + 3; indices[2] = rank*2 + 9; indices[3] = rank*2 + 7; - status = H5PartSetViewIndices(file, indices, -1); - RETURN(status, H5PART_SUCCESS, "H5PartSetViewIndices"); - - status = H5PartReadDataFloat64(file, "x", x); - RETURN(status, H5PART_SUCCESS, "H5PartReadDataFloat64"); - FVALUE(x[2*rank], (double)(2*rank+nparticles*t), "x data"); - - status = H5PartResetView(file); - RETURN(status, H5PART_SUCCESS, "H5PartResetView"); - status = H5PartSetViewIndices(file, indices, 4); RETURN(status, H5PART_SUCCESS, "H5PartSetViewIndices"); val = H5PartGetNumParticles(file); IVALUE(val, 4, "particle count"); - status = H5PartReadDataFloat64(file, "x", x); + double x2[4]; + status = H5PartReadDataFloat64(file, "x", x2); RETURN(status, H5PART_SUCCESS, "H5PartReadDataFloat64"); - FVALUE(x[2], (double)(rank*2+9+nparticles*t), "x data"); + FVALUE(x2[0], (double)(2*rank+0+nparticles*t), "x data"); + FVALUE(x2[1], (double)(2*rank+3+nparticles*t), "x data"); + FVALUE(x2[2], (double)(2*rank+9+nparticles*t), "x data"); + FVALUE(x2[3], (double)(2*rank+7+nparticles*t), "x data"); - val = H5PartGetNumParticles(file); - IVALUE(val, 4, "particle count"); - - status = H5PartSetViewIndices(file, NULL, 4); + status = H5PartSetViewIndices(file, indices, -1); RETURN(status, H5PART_SUCCESS, "H5PartSetViewIndices"); - status = H5PartReadDataFloat64(file, "x", x); - RETURN(status, H5PART_SUCCESS, "H5PartReadDataFloat64"); + val = H5PartGetNumParticles(file); + IVALUE(val, nprocs*nparticles, "particle count"); status = H5PartSetCanonicalView(file); RETURN(status, H5PART_SUCCESS, "H5PartSetCanonicalView"); + val = H5PartGetNumParticles(file); + IVALUE(val, nparticles, "particle count"); + status = H5PartReadParticleStep ( file, t, x, y, z, px, py, pz, id); RETURN(status, H5PART_SUCCESS, "H5PartReadParticleStep"); + status = H5PartSetViewIndices(file, NULL, 4); + RETURN(status, H5PART_SUCCESS, "H5PartSetViewIndices"); + for (i=0; i