[svn-r14192] Description:

Deprecate H5Dextend in favor of H5Dset_extent (without using API
versioning, due to changed behavior) and switch internal usage to H5Dset_extent

Tested on:
        FreeBSD/32 6.2 (duty) in debug mode
        FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
        Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
                                in debug mode
        Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
                                in production mode
        Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
                                in production mode
        Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
                                w/szip filter, in production mode
        Mac OS X/32 10.4.10 (amazon) in debug mode
This commit is contained in:
Quincey Koziol 2007-10-08 10:26:02 -05:00
parent a6f5c79346
commit d3ee3988b6
21 changed files with 1181 additions and 1068 deletions

View File

@ -405,11 +405,9 @@ int DataSet::iterateElems( void* buf, const DataType& type, const DataSpace& spa
//--------------------------------------------------------------------------
void DataSet::extend( const hsize_t* size ) const
{
herr_t ret_value = H5Dextend( id, size );
if( ret_value < 0 ) // raise exception when H5Dextend returns a neg value
{
throw DataSetIException("DataSet::extend", "H5Dextend failed");
}
herr_t ret_value = H5Dset_extent( id, size );
if( ret_value < 0 ) // raise exception when H5Dset_extent returns a neg value
throw DataSetIException("DataSet::extend", "H5Dset_extent failed");
}
//--------------------------------------------------------------------------

View File

@ -89,12 +89,12 @@ main (void)
*/
size[0] = 3;
size[1] = 3;
status = H5Dextend (dataset, size);
status = H5Dset_extent(dataset, size);
/*
* Select a hyperslab.
*/
filespace = H5Dget_space (dataset);
filespace = H5Dget_space(dataset);
offset[0] = 0;
offset[1] = 0;
status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL,
@ -112,12 +112,12 @@ main (void)
dims[0] = dims1[0] + dims2[0];
size[0] = dims[0];
size[1] = dims[1];
status = H5Dextend (dataset, size);
status = H5Dset_extent(dataset, size);
/*
* Select a hyperslab.
*/
filespace = H5Dget_space (dataset);
filespace = H5Dget_space(dataset);
offset[0] = 3;
offset[1] = 0;
status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL,
@ -140,12 +140,12 @@ main (void)
dims[1] = dims1[1] + dims3[1];
size[0] = dims[0];
size[1] = dims[1];
status = H5Dextend (dataset, size);
status = H5Dset_extent(dataset, size);
/*
* Select a hyperslab
*/
filespace = H5Dget_space (dataset);
filespace = H5Dget_space(dataset);
offset[0] = 0;
offset[1] = 3;
status = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL,

View File

@ -1273,7 +1273,7 @@ nh5dget_create_plist_c ( hid_t_f *dset_id , hid_t_f *plist_id)
/*----------------------------------------------------------------------------
* Name: h5dextend_c
* Purpose: Call H5Dextend to extend dataset with unlimited dimensions
* Purpose: Call H5Dset_extent to extend dataset with unlimited dimensions
* Inputs: dset_id - identifier of the dataset
* Outputs: dims - array with the dimension sizes
* Returns: 0 on success, -1 on failure
@ -1285,34 +1285,27 @@ nh5dget_create_plist_c ( hid_t_f *dset_id , hid_t_f *plist_id)
int_f
nh5dextend_c ( hid_t_f *dset_id , hsize_t_f *dims)
{
int ret_value = -1;
hsize_t *c_dims;
int status;
hid_t c_space_id;
hsize_t c_dims[H5S_MAX_RANK];
int rank;
int i;
hid_t c_dset_id;
hid_t c_space_id;
int status;
int ret_value = -1;
c_dset_id = (hid_t)*dset_id;
c_space_id = H5Dget_space(c_dset_id);
if (c_space_id < 0) return ret_value;
if((c_space_id = H5Dget_space((hid_t)*dset_id)) < 0) return ret_value;
rank = H5Sget_simple_extent_ndims(c_space_id);
if (rank < 0) return ret_value;
c_dims = malloc(sizeof(hsize_t)*rank);
if (!c_dims) return ret_value;
if((rank = H5Sget_simple_extent_ndims(c_space_id)) < 0) return ret_value;
/*
* Reverse dimensions due to C-FORTRAN storage order.
*/
for (i=0; i < rank; i++)
for(i = 0; i < rank; i++)
c_dims[i] = dims[rank - i - 1];
status = H5Dextend(c_dset_id, c_dims);
status = H5Dset_extent((hid_t)*dset_id, c_dims);
if ( status >= 0 ) ret_value = 0;
HDfree(c_dims);
if(status >= 0)
ret_value = 0;
return ret_value;
}

View File

@ -1550,7 +1550,7 @@ herr_t H5TBinsert_record( hid_t loc_id,
goto out;
read_nrecords = ntotal_records - start;
tmp_buf = (unsigned char *)calloc((size_t) read_nrecords, type_size );
tmp_buf = (unsigned char *)calloc((size_t) read_nrecords, type_size);
/* Read the records after the inserted one(s) */
if(H5TBread_records( loc_id, dset_name, start, read_nrecords, type_size, field_offset,
@ -1560,7 +1560,7 @@ herr_t H5TBinsert_record( hid_t loc_id,
/* Extend the dataset */
dims[0] = ntotal_records + nrecords;
if(H5Dextend ( did, dims ) < 0)
if(H5Dset_extent(did, dims) < 0)
goto out;
/*-------------------------------------------------------------------------
@ -1569,8 +1569,8 @@ herr_t H5TBinsert_record( hid_t loc_id,
*/
/* Create a simple memory data space */
mem_dims[0]=nrecords;
if((mem_space_id = H5Screate_simple( 1, mem_dims, NULL )) < 0)
mem_dims[0] = nrecords;
if((mem_space_id = H5Screate_simple(1, mem_dims, NULL)) < 0)
return -1;
/* Get the file data space */
@ -3691,16 +3691,16 @@ herr_t H5TB_common_append_records( hid_t dataset_id,
/* Extend the dataset */
dims[0] = nrecords + orig_table_size;
if(H5Dextend ( dataset_id, dims ) < 0)
if(H5Dset_extent(dataset_id, dims) < 0)
goto out;
/* Create a simple memory data space */
mem_dims[0]=nrecords;
if((mem_space_id = H5Screate_simple( 1, mem_dims, NULL )) < 0)
mem_dims[0] = nrecords;
if((mem_space_id = H5Screate_simple(1, mem_dims, NULL)) < 0)
goto out;
/* Get a copy of the new file data space for writing */
if((space_id = H5Dget_space( dataset_id )) < 0)
if((space_id = H5Dget_space(dataset_id)) < 0)
goto out;
/* Define a hyperslab in the dataset */

View File

@ -3077,8 +3077,8 @@ done:
/*-------------------------------------------------------------------------
* Function: H5Dset_extent
*
* Purpose: Modifies the dimensions of a dataset, based on H5Dextend.
* Can change to a lower dimension.
* Purpose: Modifies the dimensions of a dataset.
* Can change to a smaller dimension.
*
* Return: Non-negative on success, negative on failure
*
@ -3130,10 +3130,7 @@ H5D_set_extent(H5D_t *dset, const hsize_t *size, hid_t dxpl_id)
H5S_t *space; /* Dataset's dataspace */
int rank; /* Dataspace # of dimensions */
hsize_t curr_dims[H5O_LAYOUT_NDIMS]; /* Current dimension sizes */
hbool_t shrink = FALSE; /* Flag to indicate a dimension has shrank */
hbool_t expand = FALSE; /* Flag to indicate a dimension has grown */
htri_t changed; /* Whether the dataspace changed size */
unsigned u; /* Local index variable */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5D_set_extent, FAIL)
@ -3142,40 +3139,44 @@ H5D_set_extent(H5D_t *dset, const hsize_t *size, hid_t dxpl_id)
HDassert(dset);
HDassert(size);
/*-------------------------------------------------------------------------
* Get the data space
*-------------------------------------------------------------------------
*/
/*-------------------------------------------------------------------------
* Get the data space
*-------------------------------------------------------------------------
*/
space = dset->shared->space;
/*-------------------------------------------------------------------------
* Check if we are shrinking or expanding any of the dimensions
*-------------------------------------------------------------------------
*/
/*-------------------------------------------------------------------------
* Check if we are shrinking or expanding any of the dimensions
*-------------------------------------------------------------------------
*/
if((rank = H5S_get_simple_extent_dims(space, curr_dims, NULL)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataset dimensions")
/* Determine if we are shrinking and/or expanding any dimensions */
for(u = 0; u < (unsigned)rank; u++) {
if(size[u] < curr_dims[u])
shrink = TRUE;
if(size[u] > curr_dims[u])
expand = TRUE;
} /* end for */
/*-------------------------------------------------------------------------
* Modify the size of the data space
*-------------------------------------------------------------------------
*/
/*-------------------------------------------------------------------------
* Modify the size of the data space
*-------------------------------------------------------------------------
*/
if((changed = H5S_set_extent(space, size)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to modify size of data space")
/* Don't bother updating things, unless they've changed */
if(changed) {
/*-------------------------------------------------------------------------
* Modify the dataset storage
*-------------------------------------------------------------------------
*/
hbool_t shrink = FALSE; /* Flag to indicate a dimension has shrank */
hbool_t expand = FALSE; /* Flag to indicate a dimension has grown */
unsigned u; /* Local index variable */
/* Determine if we are shrinking and/or expanding any dimensions */
for(u = 0; u < (unsigned)rank; u++) {
if(size[u] < curr_dims[u])
shrink = TRUE;
if(size[u] > curr_dims[u])
expand = TRUE;
} /* end for */
/*-------------------------------------------------------------------------
* Modify the dataset storage
*-------------------------------------------------------------------------
*/
/* Save the new dataspace in the file if necessary */
if(H5S_write(&(dset->oloc), space, TRUE, dxpl_id) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to update file with new dataspace")
@ -3191,11 +3192,11 @@ H5D_set_extent(H5D_t *dset, const hsize_t *size, hid_t dxpl_id)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize dataset storage")
/*-------------------------------------------------------------------------
* Remove chunk information in the case of chunked datasets
* This removal takes place only in case we are shrinking the dateset
*-------------------------------------------------------------------------
*/
/*-------------------------------------------------------------------------
* Remove chunk information in the case of chunked datasets
* This removal takes place only in case we are shrinking the dateset
*-------------------------------------------------------------------------
*/
if(shrink && H5D_CHUNKED == dset->shared->layout.type) {
H5D_io_info_t io_info; /* Dataset I/O info */
H5D_dxpl_cache_t _dxpl_cache; /* Data transfer property cache buffer */

View File

@ -65,7 +65,9 @@
/* Local Prototypes */
/********************/
#ifndef H5_NO_DEPRECATED_SYMBOLS
static herr_t H5D_extend(H5D_t *dataset, const hsize_t *size, hid_t dxpl_id);
#endif /* H5_NO_DEPRECATED_SYMBOLS */
/*********************/
@ -256,6 +258,7 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Dopen() */
#ifndef H5_NO_DEPRECATED_SYMBOLS
/*-------------------------------------------------------------------------
* Function: H5Dextend
@ -264,6 +267,8 @@ done:
* SIZE. The dimensionality of SIZE is the same as the data
* space of the dataset being changed.
*
* Note: Deprecated in favor of H5Dset_extent
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Robb Matzke
@ -377,4 +382,5 @@ H5D_extend(H5D_t *dataset, const hsize_t *size, hid_t dxpl_id)
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5D_extend() */
#endif /* H5_NO_DEPRECATED_SYMBOLS */

View File

@ -124,8 +124,24 @@ H5_DLL herr_t H5Ddebug(hid_t dset_id);
H5_DLL hid_t H5Dcreate(hid_t file_id, const char *name, hid_t type_id,
hid_t space_id, hid_t plist_id);
H5_DLL hid_t H5Dopen(hid_t file_id, const char *name);
/* Symbols defined for compatibility with previous versions of the HDF5 API.
*
* Use of these symbols is deprecated.
*/
#ifndef H5_NO_DEPRECATED_SYMBOLS
/* Macros */
/* Typedefs */
/* Function prototypes */
H5_DLL herr_t H5Dextend(hid_t dset_id, const hsize_t *size);
#endif /* H5_NO_DEPRECATED_SYMBOLS */
#ifdef __cplusplus
}
#endif

130
src/H5S.c
View File

@ -1497,70 +1497,6 @@ done:
} /* end H5S_find() */
#endif /* H5S_DEBUG */
/*-------------------------------------------------------------------------
* Function: H5S_extend
*
* Purpose: Extend the dimensions of a data space.
*
* Return: Success: Number of dimensions whose size increased.
*
* Failure: Negative
*
* Programmer: Robb Matzke
* Friday, January 30, 1998
*
*-------------------------------------------------------------------------
*/
int
H5S_extend(H5S_t *space, const hsize_t *size)
{
unsigned u;
int ret_value = 0;
FUNC_ENTER_NOAPI(H5S_extend, FAIL)
/* Check args */
HDassert(space && H5S_SIMPLE == H5S_GET_EXTENT_TYPE(space));
HDassert(size);
/* Check through all the dimensions to see if modifying the dataspace is allowed */
for(u = 0; u < space->extent.rank; u++) {
if(space->extent.size[u]<size[u]) {
if(space->extent.max && H5S_UNLIMITED!=space->extent.max[u] &&
space->extent.max[u]<size[u])
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dimension cannot be increased")
ret_value++;
} /* end if */
} /* end for */
/* Update */
if(ret_value) {
hsize_t nelem; /* Number of elements in extent */
/* Change the dataspace size & re-compute the number of elements in the extent */
for(u = 0, nelem = 1; u < space->extent.rank; u++) {
if(space->extent.size[u] < size[u])
space->extent.size[u] = size[u];
nelem *= space->extent.size[u];
} /* end for */
space->extent.nelem = nelem;
/* If the selection is 'all', update the number of elements selected */
if(H5S_GET_SELECT_TYPE(space) == H5S_SEL_ALL)
if(H5S_select_all(space, FALSE) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection")
/* Mark the dataspace as no longer shared if it was before */
if(H5O_msg_reset_share(H5O_SDSPACE_ID, space) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRESET, FAIL, "can't stop sharing dataspace")
} /* end if */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S_extend() */
/*-------------------------------------------------------------------------
* Function: H5Screate_simple
@ -2355,3 +2291,69 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S_set_latest_version() */
#ifndef H5_NO_DEPRECATED_SYMBOLS
/*-------------------------------------------------------------------------
* Function: H5S_extend
*
* Purpose: Extend the dimensions of a data space.
*
* Return: Success: Number of dimensions whose size increased.
*
* Failure: Negative
*
* Programmer: Robb Matzke
* Friday, January 30, 1998
*
*-------------------------------------------------------------------------
*/
int
H5S_extend(H5S_t *space, const hsize_t *size)
{
unsigned u;
int ret_value = 0;
FUNC_ENTER_NOAPI(H5S_extend, FAIL)
/* Check args */
HDassert(space && H5S_SIMPLE == H5S_GET_EXTENT_TYPE(space));
HDassert(size);
/* Check through all the dimensions to see if modifying the dataspace is allowed */
for(u = 0; u < space->extent.rank; u++) {
if(space->extent.size[u]<size[u]) {
if(space->extent.max && H5S_UNLIMITED!=space->extent.max[u] &&
space->extent.max[u]<size[u])
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dimension cannot be increased")
ret_value++;
} /* end if */
} /* end for */
/* Update */
if(ret_value) {
hsize_t nelem; /* Number of elements in extent */
/* Change the dataspace size & re-compute the number of elements in the extent */
for(u = 0, nelem = 1; u < space->extent.rank; u++) {
if(space->extent.size[u] < size[u])
space->extent.size[u] = size[u];
nelem *= space->extent.size[u];
} /* end for */
space->extent.nelem = nelem;
/* If the selection is 'all', update the number of elements selected */
if(H5S_GET_SELECT_TYPE(space) == H5S_SEL_ALL)
if(H5S_select_all(space, FALSE) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection")
/* Mark the dataspace as no longer shared if it was before */
if(H5O_msg_reset_share(H5O_SDSPACE_ID, space) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRESET, FAIL, "can't stop sharing dataspace")
} /* end if */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5S_extend() */
#endif /* H5_NO_DEPRECATED_SYMBOLS */

View File

@ -208,7 +208,6 @@ H5_DLL herr_t H5S_write(struct H5O_loc_t *loc, const H5S_t *space,
H5_DLL herr_t H5S_append(H5F_t *f, hid_t dxpl_id, struct H5O_t *oh,
const H5S_t *ds);
H5_DLL H5S_t *H5S_read(const struct H5O_loc_t *loc, hid_t dxpl_id);
H5_DLL int H5S_extend(H5S_t *space, const hsize_t *size);
H5_DLL int H5S_set_extent(H5S_t *space, const hsize_t *size);
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);
@ -217,6 +216,9 @@ H5_DLL H5S_t *H5S_create_simple(unsigned rank, const hsize_t dims[/*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);
#ifndef H5_NO_DEPRECATED_SYMBOLS
H5_DLL int H5S_extend(H5S_t *space, const hsize_t *size);
#endif /* H5_NO_DEPRECATED_SYMBOLS */
H5_DLL hsize_t H5S_extent_nelem(const H5S_extent_t *ext);

File diff suppressed because it is too large Load Diff

View File

@ -31,7 +31,7 @@ const char *FILENAME[] = {
#define NY 100 /* USE AN EVEN NUMBER!*/
/* Data buffers */
static int buf1[NY][NX], buf2[NX/2][NY/2];
static int buf1[NY][NX], buf2[NX / 2][NY / 2];
/*-------------------------------------------------------------------------
@ -45,8 +45,6 @@ static int buf1[NY][NX], buf2[NX/2][NY/2];
* Programmer: Quincey Koziol
* Tuesday, June 10, 2003
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static int
@ -54,80 +52,172 @@ write_data(const char *msg, hid_t file, const char *name, hid_t cparms, hid_t me
{
hid_t dataset, file_space, half_space;
static const hsize_t dims[2] = {NX, NY};
static const hsize_t half_dims[2] = {NX/2, NY/2};
static hsize_t size[2];
static const hsize_t half_dims[2] = {NX / 2, NY / 2};
hsize_t size[2];
hsize_t max_size[2] = {0, 0};
hsize_t offset[2];
int i, j, k, m;
TESTING(msg);
if ((dataset = H5Dcreate (file, name, H5T_NATIVE_INT, mem_space,
cparms))<0) TEST_ERROR;
/* Create the dataset */
if((dataset = H5Dcreate(file, name, H5T_NATIVE_INT, mem_space, cparms)) < 0) TEST_ERROR;
/* Write the data */
for (i=0; i<5; i++) {
for (j=0; j<5; j++) {
for(i = 0; i < 5; i++)
for(j = 0; j < 5; j++) {
/* Extend the dataset */
offset[0] = i * NX;
offset[1] = j * NY;
size[0] = offset[0] + NX;
size[1] = offset[1] + NY;
if (H5Dextend (dataset, size)<0) TEST_ERROR;
if(size[0] > max_size[0] || size[1] > max_size[1]) {
if(size[0] > max_size[0])
max_size[0] = size[0];
if(size[1] > max_size[1])
max_size[1] = size[1];
if(H5Dset_extent(dataset, max_size) < 0) TEST_ERROR;
} /* end if */
/* Select a hyperslab */
if ((file_space = H5Dget_space (dataset))<0) TEST_ERROR;
if (H5Sselect_hyperslab (file_space, H5S_SELECT_SET, offset,
NULL, dims, NULL)<0) TEST_ERROR;
if((file_space = H5Dget_space(dataset)) < 0) TEST_ERROR;
if(H5Sselect_hyperslab(file_space, H5S_SELECT_SET, offset, NULL, dims, NULL) < 0) TEST_ERROR;
/* Write to the hyperslab */
if (H5Dwrite (dataset, H5T_NATIVE_INT, mem_space, file_space,
H5P_DEFAULT, buf1)<0) TEST_ERROR;
if (H5Sclose (file_space)<0) TEST_ERROR;
}
}
if(H5Dwrite(dataset, H5T_NATIVE_INT, mem_space, file_space, H5P_DEFAULT, buf1) < 0) TEST_ERROR;
if(H5Sclose(file_space) < 0) TEST_ERROR;
} /* end for */
/* Read the data */
if ((half_space = H5Screate_simple (2, half_dims, NULL))<0) TEST_ERROR;
if ((file_space = H5Dget_space (dataset))<0) TEST_ERROR;
for (i=0; i<10; i++) {
for (j=0; j<10; j++) {
if((half_space = H5Screate_simple(2, half_dims, NULL)) < 0) TEST_ERROR;
if((file_space = H5Dget_space(dataset)) < 0) TEST_ERROR;
for(i = 0; i < 10; i++) {
for(j = 0; j < 10; j++) {
/* Select a hyperslab */
offset[0] = i * NX/2;
offset[1] = j * NY/2;
if (H5Sselect_hyperslab (file_space, H5S_SELECT_SET, offset,
NULL, half_dims, NULL)<0) TEST_ERROR;
offset[0] = i * (NX / 2);
offset[1] = j * (NY / 2);
if(H5Sselect_hyperslab(file_space, H5S_SELECT_SET, offset, NULL, half_dims, NULL) < 0) TEST_ERROR;
/* Read */
if (H5Dread (dataset, H5T_NATIVE_INT, half_space, file_space,
H5P_DEFAULT, buf2)<0) TEST_ERROR;
if(H5Dread(dataset, H5T_NATIVE_INT, half_space, file_space, H5P_DEFAULT, buf2) < 0) TEST_ERROR;
/* Compare */
for (k=0; k<NX/2; k++) {
for (m=0; m<NY/2; m++) {
if (buf2[k][m]!=buf1[(i%2)*NX/2+k][(j%2)*NY/2+m]) {
for(k = 0; k < (NX / 2); k++)
for(m = 0; m < (NY / 2); m++)
if(buf2[k][m] != buf1[(i % 2) * (NX / 2) + k][(j % 2) * (NY / 2) + m]) {
printf(" i=%d, j=%d, k=%d, m=%d\n", i, j, k, m);
printf(" buf2[%d][%d]=%d\n",k,m,buf2[k][m]);
printf(" buf1[%d][%d]=%d\n",(i%2)*NX/2+k,(j%2)*NY/2+m,buf1[(i%2)*NX/2+k][(j%2)*NY/2+m]);
printf(" buf2[%d][%d]=%d\n", k, m, buf2[k][m]);
printf(" buf1[%d][%d]=%d\n", (i % 2) * (NX / 2) + k, (j % 2) * (NY / 2) + m, buf1[(i % 2) * (NX / 2) + k][(j % 2) * (NY / 2) + m]);
TEST_ERROR;
}
}
}
}
}
} /* end if */
} /* end for */
} /* end for */
/* Cleanup */
if (H5Dclose (dataset)<0) TEST_ERROR;
if (H5Sclose (file_space)<0) TEST_ERROR;
if (H5Sclose (half_space)<0) TEST_ERROR;
if(H5Dclose(dataset) < 0) TEST_ERROR;
if(H5Sclose(file_space) < 0) TEST_ERROR;
if(H5Sclose(half_space) < 0) TEST_ERROR;
PASSED();
return 0;
error:
return -1;
}
} /* end write_data() */
#ifndef H5_NO_DEPRECATED_SYMBOLS
/*-------------------------------------------------------------------------
* Function: write_data_deprec
*
* Purpose: Create extendible dataset and test extend/write/read, with
* deprecated API routine (H5Dextend)
*
* Return: Success: 0
* Failure: -1
*
* Programmer: Quincey Koziol
* Monday, October 8, 2007
*
*-------------------------------------------------------------------------
*/
static int
write_data_deprec(const char *msg, hid_t file, const char *name, hid_t cparms, hid_t mem_space)
{
hid_t dataset, file_space, half_space;
static const hsize_t dims[2] = {NX, NY};
static const hsize_t half_dims[2] = {NX / 2, NY / 2};
static hsize_t size[2];
hsize_t offset[2];
int i, j, k, m;
TESTING(msg);
/* Create the dataset */
if((dataset = H5Dcreate(file, name, H5T_NATIVE_INT, mem_space, cparms)) < 0) TEST_ERROR;
/* Write the data */
for(i = 0; i < 5; i++)
for(j = 0; j < 5; j++) {
/* Extend the dataset */
offset[0] = i * NX;
offset[1] = j * NY;
size[0] = offset[0] + NX;
size[1] = offset[1] + NY;
if(H5Dextend(dataset, size) < 0) TEST_ERROR;
/* Select a hyperslab */
if((file_space = H5Dget_space(dataset)) < 0) TEST_ERROR;
if(H5Sselect_hyperslab(file_space, H5S_SELECT_SET, offset, NULL, dims, NULL) < 0) TEST_ERROR;
/* Write to the hyperslab */
if(H5Dwrite(dataset, H5T_NATIVE_INT, mem_space, file_space, H5P_DEFAULT, buf1) < 0) TEST_ERROR;
if(H5Sclose(file_space) < 0) TEST_ERROR;
} /* end for */
/* Read the data */
if((half_space = H5Screate_simple(2, half_dims, NULL)) < 0) TEST_ERROR;
if((file_space = H5Dget_space(dataset)) < 0) TEST_ERROR;
for(i = 0; i < 10; i++) {
for(j = 0; j < 10; j++) {
/* Select a hyperslab */
offset[0] = i * (NX / 2);
offset[1] = j * (NY / 2);
if(H5Sselect_hyperslab(file_space, H5S_SELECT_SET, offset, NULL, half_dims, NULL) < 0) TEST_ERROR;
/* Read */
if(H5Dread(dataset, H5T_NATIVE_INT, half_space, file_space, H5P_DEFAULT, buf2) < 0) TEST_ERROR;
/* Compare */
for(k = 0; k < (NX / 2); k++)
for(m = 0; m < (NY / 2); m++)
if(buf2[k][m] != buf1[(i % 2) * (NX / 2) + k][(j % 2) * (NY / 2) + m]) {
printf(" i=%d, j=%d, k=%d, m=%d\n", i, j, k, m);
printf(" buf2[%d][%d]=%d\n", k, m, buf2[k][m]);
printf(" buf1[%d][%d]=%d\n", (i % 2) * (NX / 2) + k, (j % 2) * (NY / 2) + m, buf1[(i % 2) * (NX / 2) + k][(j % 2) * (NY / 2) + m]);
TEST_ERROR;
} /* end if */
} /* end for */
} /* end for */
/* Cleanup */
if(H5Dclose(dataset) < 0) TEST_ERROR;
if(H5Sclose(file_space) < 0) TEST_ERROR;
if(H5Sclose(half_space) < 0) TEST_ERROR;
PASSED();
return 0;
error:
return -1;
} /* end write_data_deprec() */
#endif /* H5_NO_DEPRECATED_SYMBOLS */
/*-------------------------------------------------------------------------
@ -164,51 +254,59 @@ main (void)
const char *envval = NULL;
envval = HDgetenv("HDF5_DRIVER");
if (envval == NULL)
if(envval == NULL)
envval = "nomatch";
if (HDstrcmp(envval, "split")) {
if(HDstrcmp(envval, "split")) {
h5_reset();
fapl = h5_fileaccess();
/* Initialize buffer and space */
for (i=0; i<NX; i++) {
for (j=0; j<NY; j++) {
buf1[i][j] = i*NY+j;
}
}
if ((mem_space = H5Screate_simple (2, dims, maxdims))<0) TEST_ERROR;
for(i = 0; i < NX; i++)
for(j = 0; j < NY; j++)
buf1[i][j] = i * NY + j;
if((mem_space = H5Screate_simple(2, dims, maxdims)) < 0) TEST_ERROR;
/* Create the file */
h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
if ((file = H5Fcreate (filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) TEST_ERROR;
if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR;
/* Create the dataset which is originally NX by NY */
if((cparms = H5Pcreate(H5P_DATASET_CREATE))<0) TEST_ERROR;
if (H5Pset_chunk (cparms, 2, chunk_dims)<0) TEST_ERROR;
nerrors += write_data("extendible dataset with incremental allocation",file,"dataset1",cparms,mem_space)<0 ?1:0;
if(H5Pset_alloc_time(cparms, H5D_ALLOC_TIME_EARLY)<0) TEST_ERROR;
nerrors += write_data("extendible dataset with early allocation",file,"dataset2",cparms,mem_space)<0 ?1:0;
/* Create the dataset creation property list */
if((cparms = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR;
if(H5Pset_chunk(cparms, 2, chunk_dims) < 0) TEST_ERROR;
if (H5Pclose (cparms)<0) TEST_ERROR;
if (H5Sclose (mem_space)<0) TEST_ERROR;
/* Test with incremental allocation */
nerrors += write_data("extendible dataset with incr. allocation", file, "dataset1a", cparms, mem_space) < 0 ? 1 : 0;
#ifndef H5_NO_DEPRECATED_SYMBOLS
nerrors += write_data_deprec("extendible dataset with incr. allocation w/deprec. symbols", file, "dataset1b", cparms, mem_space) < 0 ? 1 : 0;
#endif /* H5_NO_DEPRECATED_SYMBOLS */
if (H5Fclose (file)<0) TEST_ERROR;
if (nerrors) {
printf("***** %d FAILURE%s! *****\n", nerrors, 1==nerrors?"":"S");
/* Test with early allocation */
if(H5Pset_alloc_time(cparms, H5D_ALLOC_TIME_EARLY) < 0) TEST_ERROR;
nerrors += write_data("extendible dataset with early allocation", file, "dataset2a", cparms, mem_space) < 0 ? 1 : 0;
#ifndef H5_NO_DEPRECATED_SYMBOLS
nerrors += write_data_deprec("extendible dataset with early allocation w/deprec. symbols", file, "dataset2b", cparms, mem_space) < 0 ? 1 : 0;
#endif /* H5_NO_DEPRECATED_SYMBOLS */
if(H5Pclose(cparms) < 0) TEST_ERROR;
if(H5Sclose(mem_space) < 0) TEST_ERROR;
if(H5Fclose(file) < 0) TEST_ERROR;
if(nerrors) {
printf("***** %d FAILURE%s! *****\n", nerrors, (1 == nerrors) ? "" : "S");
exit(1);
}
} /* end if */
printf("All extend tests passed.\n");
h5_cleanup(FILENAME, fapl);
}
} /* end if */
else
{
puts("All extend tests skipped - Incompatible with current Virtual File Driver");
}
return 0;
error:
printf("*** One or more extend tests failed ***\n");
return 1;
error:
printf("*** One or more extend tests failed ***\n");
return 1;
}

View File

@ -107,25 +107,25 @@ test_1a(hid_t file)
TESTING("fixed-size data space, exact storage");
/* Create the dataset */
if((dcpl=H5Pcreate(H5P_DATASET_CREATE))<0) goto error;
if((dcpl=H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error;
cur_size[0] = max_size[0] = 100;
if (H5Pset_external(dcpl, "ext1.data", (off_t)0,
(hsize_t)(max_size[0]*sizeof(int)))<0) goto error;
if ((space = H5Screate_simple (1, cur_size, max_size))<0) goto error;
if ((dset = H5Dcreate (file, "dset1", H5T_NATIVE_INT, space, dcpl))<0)
(hsize_t)(max_size[0]*sizeof(int))) < 0) goto error;
if ((space = H5Screate_simple (1, cur_size, max_size)) < 0) goto error;
if ((dset = H5Dcreate (file, "dset1", H5T_NATIVE_INT, space, dcpl)) < 0)
goto error;
if (H5Dclose (dset)<0) goto error;
if (H5Sclose (space)<0) goto error;
if (H5Pclose (dcpl)<0) goto error;
if (H5Dclose (dset) < 0) goto error;
if (H5Sclose (space) < 0) goto error;
if (H5Pclose (dcpl) < 0) goto error;
/* Read dataset creation information */
if ((dset = H5Dopen (file, "dset1"))<0) goto error;
if ((dset = H5Dopen (file, "dset1")) < 0) goto error;
/* Test dataset address. Should be undefined. */
if (H5Dget_offset(dset)!=HADDR_UNDEF) goto error;
if ((dcpl = H5Dget_create_plist (dset))<0) goto error;
if ((n=H5Pget_external_count (dcpl))<0) goto error;
if ((dcpl = H5Dget_create_plist (dset)) < 0) goto error;
if ((n=H5Pget_external_count (dcpl)) < 0) goto error;
if (1!=n) {
H5_FAILED();
puts(" Returned external count is wrong.");
@ -134,7 +134,7 @@ test_1a(hid_t file)
}
strcpy (name+sizeof(name)-4, "...");
if (H5Pget_external (dcpl, 0, sizeof(name)-4, name, &file_offset,
&file_size)<0) goto error;
&file_size) < 0) goto error;
if (file_offset!=0) {
H5_FAILED();
puts(" Wrong file offset.");
@ -148,8 +148,8 @@ test_1a(hid_t file)
(unsigned long)max_size[0]*sizeof(int));
goto error;
}
if (H5Pclose (dcpl)<0) goto error;
if (H5Dclose (dset)<0) goto error;
if (H5Pclose (dcpl) < 0) goto error;
if (H5Dclose (dset) < 0) goto error;
PASSED();
return 0;
error:
@ -189,11 +189,11 @@ test_1b(hid_t file)
hsize_t max_size[1]; /*maximum data space size */
TESTING("external storage is too small");
if((dcpl = H5Pcreate(H5P_DATASET_CREATE))<0) goto error;
if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error;
cur_size[0] = max_size[0] = 100;
if (H5Pset_external(dcpl, "ext1.data", (off_t)0,
(hsize_t)(max_size[0]*sizeof(int)-1))<0) goto error;
if ((space = H5Screate_simple (1, cur_size, max_size))<0) goto error;
(hsize_t)(max_size[0]*sizeof(int)-1)) < 0) goto error;
if ((space = H5Screate_simple (1, cur_size, max_size)) < 0) goto error;
H5E_BEGIN_TRY {
dset = H5Dcreate (file, "dset2", H5T_NATIVE_INT, space, dcpl);
} H5E_END_TRY;
@ -202,8 +202,8 @@ test_1b(hid_t file)
puts(" Small external file succeeded instead of failing.");
goto error;
}
if (H5Sclose (space)<0) goto error;
if (H5Pclose (dcpl)<0) goto error;
if (H5Sclose (space) < 0) goto error;
if (H5Pclose (dcpl) < 0) goto error;
PASSED();
return 0;
@ -245,17 +245,17 @@ test_1c(hid_t file)
hsize_t max_size[1]; /*maximum data space size */
TESTING("extendible dataspace, exact external size");
if((dcpl=H5Pcreate (H5P_DATASET_CREATE))<0) goto error;
if((dcpl=H5Pcreate (H5P_DATASET_CREATE)) < 0) goto error;
cur_size[0] = 100;
max_size[0] = 200;
if (H5Pset_external(dcpl, "ext1.data", (off_t)0,
(hsize_t)(max_size[0]*sizeof(int)))<0) goto error;
if ((space = H5Screate_simple (1, cur_size, max_size))<0) goto error;
if ((dset = H5Dcreate (file, "dset3", H5T_NATIVE_INT, space, dcpl))<0)
(hsize_t)(max_size[0]*sizeof(int))) < 0) goto error;
if ((space = H5Screate_simple (1, cur_size, max_size)) < 0) goto error;
if ((dset = H5Dcreate (file, "dset3", H5T_NATIVE_INT, space, dcpl)) < 0)
goto error;
if (H5Dclose (dset)<0) goto error;
if (H5Sclose (space)<0) goto error;
if (H5Pclose (dcpl)<0) goto error;
if (H5Dclose (dset) < 0) goto error;
if (H5Sclose (space) < 0) goto error;
if (H5Pclose (dcpl) < 0) goto error;
PASSED();
return 0;
@ -296,12 +296,12 @@ test_1d(hid_t file)
hsize_t max_size[1]; /*maximum data space size */
TESTING("extendible dataspace, external storage is too small");
if((dcpl=H5Pcreate(H5P_DATASET_CREATE))<0) goto error;
if((dcpl=H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error;
cur_size[0] = 100;
max_size[0] = 200;
if (H5Pset_external(dcpl, "ext1.data", (off_t)0,
(hsize_t)(max_size[0]*sizeof(int)-1))<0) goto error;
if ((space=H5Screate_simple(1, cur_size, max_size))<0) goto error;
(hsize_t)(max_size[0]*sizeof(int)-1)) < 0) goto error;
if ((space=H5Screate_simple(1, cur_size, max_size)) < 0) goto error;
H5E_BEGIN_TRY {
dset = H5Dcreate (file, "dset4", H5T_NATIVE_INT, space, dcpl);
} H5E_END_TRY;
@ -310,8 +310,8 @@ test_1d(hid_t file)
puts(" Small external file succeeded instead of failing.");
goto error;
}
if (H5Sclose (space)<0) goto error;
if (H5Pclose (dcpl)<0) goto error;
if (H5Sclose (space) < 0) goto error;
if (H5Pclose (dcpl) < 0) goto error;
PASSED();
return 0;
@ -359,20 +359,20 @@ test_1e(hid_t file)
/* Create dataset */
if((dcpl=H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error;
if (H5Pset_external(dcpl, "ext1.data", (off_t)0, H5F_UNLIMITED)<0) goto error;
if (H5Pset_external(dcpl, "ext1.data", (off_t)0, H5F_UNLIMITED) < 0) goto error;
cur_size[0] = 100;
max_size[0] = H5S_UNLIMITED;
if ((space=H5Screate_simple(1, cur_size, max_size))<0) goto error;
if ((dset=H5Dcreate(file, "dset5", H5T_NATIVE_INT, space, dcpl))<0)
if ((space=H5Screate_simple(1, cur_size, max_size)) < 0) goto error;
if ((dset=H5Dcreate(file, "dset5", H5T_NATIVE_INT, space, dcpl)) < 0)
goto error;
if (H5Dclose (dset)<0) goto error;
if (H5Sclose (space)<0) goto error;
if (H5Pclose (dcpl)<0) goto error;
if (H5Dclose (dset) < 0) goto error;
if (H5Sclose (space) < 0) goto error;
if (H5Pclose (dcpl) < 0) goto error;
/* Read dataset creation information */
if ((dset = H5Dopen (file, "dset5"))<0) goto error;
if ((dcpl = H5Dget_create_plist (dset))<0) goto error;
if ((n = H5Pget_external_count (dcpl))<0) goto error;
if ((dset = H5Dopen (file, "dset5")) < 0) goto error;
if ((dcpl = H5Dget_create_plist (dset)) < 0) goto error;
if ((n = H5Pget_external_count (dcpl)) < 0) goto error;
if (1!=n) {
H5_FAILED();
puts(" Returned external count is wrong.");
@ -381,7 +381,7 @@ test_1e(hid_t file)
}
strcpy (name+sizeof(name)-4, "...");
if (H5Pget_external (dcpl, 0, sizeof(name)-4, name, &file_offset,
&file_size)<0) goto error;
&file_size) < 0) goto error;
if (file_offset!=0) {
H5_FAILED();
puts(" Wrong file offset.");
@ -394,8 +394,8 @@ test_1e(hid_t file)
printf(" got: %lu\n ans: INF\n", (unsigned long)file_size);
goto error;
}
if (H5Pclose (dcpl)<0) goto error;
if (H5Dclose (dset)<0) goto error;
if (H5Pclose (dcpl) < 0) goto error;
if (H5Dclose (dset) < 0) goto error;
PASSED();
return 0;
@ -435,22 +435,22 @@ test_1f(hid_t file)
hsize_t max_size[1]; /*data space maximum size */
TESTING("multiple external files");
if((dcpl=H5Pcreate(H5P_DATASET_CREATE))<0) goto error;
if((dcpl=H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error;
cur_size[0] = max_size[0] = 100;
if (H5Pset_external(dcpl, "ext1.data", (off_t)0,
(hsize_t)(max_size[0]*sizeof(int)/4))<0) goto error;
(hsize_t)(max_size[0]*sizeof(int)/4)) < 0) goto error;
if (H5Pset_external(dcpl, "ext2.data", (off_t)0,
(hsize_t)(max_size[0]*sizeof(int)/4))<0) goto error;
(hsize_t)(max_size[0]*sizeof(int)/4)) < 0) goto error;
if (H5Pset_external(dcpl, "ext3.data", (off_t)0,
(hsize_t)(max_size[0]*sizeof(int)/4))<0) goto error;
(hsize_t)(max_size[0]*sizeof(int)/4)) < 0) goto error;
if (H5Pset_external(dcpl, "ext4.data", (off_t)0,
(hsize_t)(max_size[0]*sizeof(int)/4))<0) goto error;
if ((space=H5Screate_simple(1, cur_size, max_size))<0) goto error;
if ((dset=H5Dcreate(file, "dset6", H5T_NATIVE_INT, space, dcpl))<0)
(hsize_t)(max_size[0]*sizeof(int)/4)) < 0) goto error;
if ((space=H5Screate_simple(1, cur_size, max_size)) < 0) goto error;
if ((dset=H5Dcreate(file, "dset6", H5T_NATIVE_INT, space, dcpl)) < 0)
goto error;
if (H5Dclose(dset)<0) goto error;
if (H5Sclose(space)<0) goto error;
if (H5Pclose(dcpl)<0) goto error;
if (H5Dclose(dset) < 0) goto error;
if (H5Sclose(space) < 0) goto error;
if (H5Pclose(dcpl) < 0) goto error;
PASSED();
return 0;
@ -489,8 +489,8 @@ test_1g(void)
int n; /*number of external files */
TESTING("external file following unlimited file");
if ((dcpl=H5Pcreate (H5P_DATASET_CREATE))<0) goto error;
if (H5Pset_external(dcpl, "ext1.data", (off_t)0, H5F_UNLIMITED)<0) goto error;
if ((dcpl=H5Pcreate (H5P_DATASET_CREATE)) < 0) goto error;
if (H5Pset_external(dcpl, "ext1.data", (off_t)0, H5F_UNLIMITED) < 0) goto error;
H5E_BEGIN_TRY {
status = H5Pset_external(dcpl, "ext2.data", (off_t)0, (hsize_t)100);
} H5E_END_TRY;
@ -499,13 +499,13 @@ test_1g(void)
puts (" H5Pset_external() succeeded when it should have failed.");
goto error;
}
if ((n = H5Pget_external_count(dcpl))<0) goto error;
if ((n = H5Pget_external_count(dcpl)) < 0) goto error;
if (1!=n) {
H5_FAILED();
puts(" Wrong external file count returned.");
goto error;
}
if (H5Pclose(dcpl)<0) goto error;
if (H5Pclose(dcpl) < 0) goto error;
PASSED();
return 0;
@ -541,8 +541,8 @@ test_1h(void)
herr_t status; /*return status */
TESTING("address overflow in external files");
if((dcpl=H5Pcreate(H5P_DATASET_CREATE))<0) goto error;
if (H5Pset_external(dcpl, "ext1.data", (off_t)0, H5F_UNLIMITED-1)<0) goto error;
if((dcpl=H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error;
if (H5Pset_external(dcpl, "ext1.data", (off_t)0, H5F_UNLIMITED-1) < 0) goto error;
H5E_BEGIN_TRY {
status = H5Pset_external(dcpl, "ext2.data", (off_t)0, (hsize_t)100);
} H5E_END_TRY;
@ -551,7 +551,7 @@ test_1h(void)
puts(" H5Pset_external() succeeded when it should have failed.");
goto error;
}
if (H5Pclose(dcpl)<0) goto error;
if (H5Pclose(dcpl) < 0) goto error;
PASSED();
return 0;
@ -628,7 +628,7 @@ test_2 (hid_t fapl)
if(H5Gclose(grp) < 0) FAIL_STACK_ERROR
/* Create the dataset */
if((dcpl = H5Pcreate(H5P_DATASET_CREATE))<0) goto error;
if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error;
if(H5Pset_external(dcpl, "extern_1a.raw", (off_t)0, (hsize_t)sizeof part) < 0 ||
H5Pset_external(dcpl, "extern_2a.raw", (off_t)10, (hsize_t)sizeof part) < 0 ||
H5Pset_external(dcpl, "extern_3a.raw", (off_t)20, (hsize_t)sizeof part) < 0 ||
@ -654,13 +654,13 @@ test_2 (hid_t fapl)
/*
* Read the middle of the dataset
*/
if ((hs_space=H5Scopy(space))<0) goto error;
if ((hs_space=H5Scopy(space)) < 0) goto error;
if (H5Sselect_hyperslab(hs_space, H5S_SELECT_SET, &hs_start, NULL,
&hs_count, NULL)<0) goto error;
&hs_count, NULL) < 0) goto error;
memset(whole, 0, sizeof(whole));
if (H5Dread (dset, H5T_NATIVE_INT, hs_space, hs_space, H5P_DEFAULT,
whole)<0) goto error;
if (H5Sclose (hs_space)<0) goto error;
whole) < 0) goto error;
if (H5Sclose (hs_space) < 0) goto error;
for (i=hs_start; i<hs_start+hs_count; i++) {
if (whole[i]!=(signed)i) {
H5_FAILED();
@ -669,10 +669,10 @@ test_2 (hid_t fapl)
}
}
if (H5Dclose(dset)<0) goto error;
if (H5Pclose(dcpl)<0) goto error;
if (H5Sclose(space)<0) goto error;
if (H5Fclose(file)<0) goto error;
if (H5Dclose(dset) < 0) goto error;
if (H5Pclose(dcpl) < 0) goto error;
if (H5Sclose(space) < 0) goto error;
if (H5Fclose(file) < 0) goto error;
PASSED();
return 0;
@ -725,22 +725,22 @@ test_3 (hid_t fapl)
/* Create another file */
h5_fixname(FILENAME[2], fapl, filename, sizeof filename);
if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) {
if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) {
goto error;
}
/* Create the external file list */
if((dcpl=H5Pcreate(H5P_DATASET_CREATE))<0) goto error;
if (H5Pset_external(dcpl, "extern_1b.raw", (off_t)0, (hsize_t)sizeof part)<0 ||
H5Pset_external(dcpl, "extern_2b.raw", (off_t)10, (hsize_t)sizeof part)<0 ||
H5Pset_external(dcpl, "extern_3b.raw", (off_t)20, (hsize_t)sizeof part)<0 ||
H5Pset_external(dcpl, "extern_4b.raw", (off_t)30, H5F_UNLIMITED)<0)
if((dcpl=H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error;
if (H5Pset_external(dcpl, "extern_1b.raw", (off_t)0, (hsize_t)sizeof part) < 0 ||
H5Pset_external(dcpl, "extern_2b.raw", (off_t)10, (hsize_t)sizeof part) < 0 ||
H5Pset_external(dcpl, "extern_3b.raw", (off_t)20, (hsize_t)sizeof part) < 0 ||
H5Pset_external(dcpl, "extern_4b.raw", (off_t)30, H5F_UNLIMITED) < 0)
goto error;
/* Make sure the output files are fresh*/
for (i=1; i<=4; i++) {
sprintf(filename, "extern_%db.raw", i);
if ((fd= open(filename, O_RDWR|O_CREAT|O_TRUNC, 0666))<0) {
if ((fd= open(filename, O_RDWR|O_CREAT|O_TRUNC, 0666)) < 0) {
H5_FAILED();
printf(" cannot open %s: %s\n", filename, strerror(errno));
goto error;
@ -751,44 +751,45 @@ test_3 (hid_t fapl)
}
/* Create the dataset */
if ((mem_space=H5Screate_simple(1, &cur_size, &max_size))<0) goto error;
if ((file_space=H5Scopy(mem_space))<0) goto error;
if ((dset=H5Dcreate(file, "dset1", H5T_NATIVE_INT, file_space, dcpl))<0)
if((mem_space = H5Screate_simple(1, &cur_size, &max_size)) < 0) goto error;
if((file_space = H5Scopy(mem_space)) < 0) goto error;
if((dset = H5Dcreate(file, "dset1", H5T_NATIVE_INT, file_space, dcpl)) < 0)
goto error;
/* Write the entire dataset and compare with the original */
for (i=0; i<cur_size; i++) whole[i] = i;
if (H5Dwrite(dset, H5T_NATIVE_INT, mem_space, file_space, H5P_DEFAULT,
whole)<0) goto error;
for (i=0; i<4; i++) {
for(i = 0; i < cur_size; i++)
whole[i] = i;
if(H5Dwrite(dset, H5T_NATIVE_INT, mem_space, file_space, H5P_DEFAULT, whole) < 0) goto error;
for(i = 0; i < 4; i++) {
char name1[64], name2[64];
sprintf (name1, "extern_%da.raw", i+1);
sprintf (name2, "extern_%db.raw", i+1);
if (!same_contents (name1, name2)) {
sprintf(name1, "extern_%da.raw", i + 1);
sprintf(name2, "extern_%db.raw", i + 1);
if(!same_contents(name1, name2)) {
H5_FAILED();
puts (" Output differs from expected value.");
goto error;
}
}
} /* end if */
} /* end for */
/* Extend the dataset by another 100 elements */
if (H5Dextend(dset, &max_size)<0) goto error;
if (H5Sclose(file_space)<0) goto error;
if ((file_space=H5Dget_space(dset))<0) goto error;
if(H5Dset_extent(dset, &max_size) < 0) goto error;
if(H5Sclose(file_space) < 0) goto error;
if((file_space = H5Dget_space(dset)) < 0) goto error;
/* Write second half of dataset */
for (i=0; i<hs_count; i++) whole[i] = 100+i;
if (H5Sselect_hyperslab(file_space, H5S_SELECT_SET, &hs_start, NULL,
&hs_count, NULL)<0) goto error;
if (H5Dwrite(dset, H5T_NATIVE_INT, mem_space, file_space, H5P_DEFAULT,
whole)<0) goto error;
for(i = 0; i < hs_count; i++)
whole[i] = 100 + i;
if(H5Sselect_hyperslab(file_space, H5S_SELECT_SET, &hs_start, NULL, &hs_count, NULL) < 0) goto error;
if(H5Dwrite(dset, H5T_NATIVE_INT, mem_space, file_space, H5P_DEFAULT, whole) < 0) goto error;
if (H5Dclose (dset)<0) goto error;
if (H5Pclose (dcpl)<0) goto error;
if (H5Sclose (mem_space)<0) goto error;
if (H5Sclose (file_space)<0) goto error;
if (H5Fclose (file)<0) goto error;
if(H5Dclose(dset) < 0) goto error;
if(H5Pclose(dcpl) < 0) goto error;
if(H5Sclose(mem_space) < 0) goto error;
if(H5Sclose(file_space) < 0) goto error;
if(H5Fclose(file) < 0) goto error;
PASSED();
return 0;
@ -854,7 +855,7 @@ main (void)
nerrors += test_3(fapl);
if (nerrors>0) goto error;
if (H5Fclose(file)<0) goto error;
if (H5Fclose(file) < 0) goto error;
puts("All external storage tests passed.");
if (h5_cleanup(FILENAME, fapl)) {
remove("extern_1a.raw");

View File

@ -1569,7 +1569,7 @@ test_extend_cases(hid_t file, hid_t _dcpl, const char *dset_name,
/* Extend the dataset one element in each dimension */
for(i = 0; i < 5; i++)
extend_size[i] = start_size[i] + 1;
if(H5Dextend(dset, extend_size) < 0) TEST_ERROR
if(H5Dset_extent(dset, extend_size) < 0) TEST_ERROR
/* Re-open file dataspace */
if(H5Sclose(fspace) < 0) TEST_ERROR
@ -1608,7 +1608,7 @@ test_extend_cases(hid_t file, hid_t _dcpl, const char *dset_name,
/* Extend the dataset to the maximum dimension sizes */
if(H5Dextend(dset, max_size) < 0) TEST_ERROR
if(H5Dset_extent(dset, max_size) < 0) TEST_ERROR
/* Re-open file dataspace */
if(H5Sclose(fspace) < 0) TEST_ERROR

View File

@ -2335,7 +2335,7 @@ test_copy_dataset_chunked_sparse(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl)
new_dim2d[1] = DIM_SIZE_2 * 2;
/* Extend dataset's dimensions */
if(H5Dextend(did, new_dim2d) < 0) TEST_ERROR
if(H5Dset_extent(did, new_dim2d) < 0) TEST_ERROR
/* close dataspace */
if(H5Sclose(sid) < 0) TEST_ERROR

View File

@ -180,27 +180,24 @@ int main(void)
status = H5Gclose(group_id);
/* Extend attribute arrays */
for(i=0; i<NEXTARRAYS; i++)
{
for(i = 0; i < NEXTARRAYS; i++) {
/* Open extendable dataset */
sprintf(name, "/ExtArray%06d", i);
dataset_id = H5Dopen(file_id, name);
if(dataset_id < 0)
{
if(dataset_id < 0) {
fprintf(stderr, "Failed to open ExtArray dataset.\n");
status = H5Fclose(file_id);
return -1;
}
} /* end if */
/* Extend attribute dataset */
dims[0] = (hsize_t)j + 1;
status = H5Dextend(dataset_id, dims);
if(status < 0)
{
status = H5Dset_extent(dataset_id, dims);
if(status < 0) {
fprintf(stderr, "Failed to extend DataArray dataset.\n");
status = H5Fclose(file_id);
return -1;
}
} /* end if */
/* Select element and write value to attribute dataset */
dims[0] = 1;

View File

@ -1967,15 +1967,15 @@ test_misc12(void)
MESSAGE(5, ("Testing VL-type in chunked dataset\n"));
/* This test requirese a relatively "fresh" library environment */
ret=H5garbage_collect();
ret = H5garbage_collect();
CHECK(ret, FAIL, "H5garbage_collect");
/* Create file */
fid1 = H5Fcreate (MISC12_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
fid1 = H5Fcreate(MISC12_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
CHECK(fid1, FAIL, "H5Fcreate");
/* Create dataspace for datasets */
sid1 = H5Screate_simple (MISC12_SPACE1_RANK, dims1, maxdims1);
sid1 = H5Screate_simple(MISC12_SPACE1_RANK, dims1, maxdims1);
CHECK(sid1, FAIL, "H5Screate_simple");
/* Create a datatype to refer to */
@ -1988,66 +1988,66 @@ test_misc12(void)
cparms = H5Pcreate(H5P_DATASET_CREATE);
CHECK(cparms, FAIL, "H5Pcreate");
ret = H5Pset_chunk ( cparms, 1, chkdims1);
ret = H5Pset_chunk(cparms, 1, chkdims1);
CHECK(ret, FAIL, "H5Pset_chunk");
/* Create a dataset */
dataset = H5Dcreate (fid1, MISC12_DSET_NAME, tid1, sid1, cparms);
dataset = H5Dcreate(fid1, MISC12_DSET_NAME, tid1, sid1, cparms);
CHECK(dataset, FAIL, "H5Dcreate");
/* Write dataset to disk */
ret = H5Dwrite (dataset, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata);
ret = H5Dwrite(dataset, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata);
CHECK(ret, FAIL, "H5Dwrite");
/* Extend dataset */
ret = H5Dextend (dataset, newsize);
CHECK(ret, FAIL, "H5Dextend");
ret = H5Dset_extent(dataset, newsize);
CHECK(ret, FAIL, "H5Dset_extent");
memspace = H5Screate_simple (MISC12_SPACE1_RANK, dimsn, NULL);
memspace = H5Screate_simple(MISC12_SPACE1_RANK, dimsn, NULL);
CHECK(memspace, FAIL, "H5Screate_simple");
space = H5Dget_space (dataset);
space = H5Dget_space(dataset);
CHECK(space, FAIL, "H5Dget_space");
ret = H5Sselect_hyperslab (space, H5S_SELECT_SET, offset, NULL, count, NULL);
ret = H5Sselect_hyperslab(space, H5S_SELECT_SET, offset, NULL, count, NULL);
CHECK(ret, FAIL, "H5Sselect_hyperslab");
/* Write data to new portion of dataset */
ret = H5Dwrite (dataset, tid1, memspace, space, H5P_DEFAULT, wdata1);
ret = H5Dwrite(dataset, tid1, memspace, space, H5P_DEFAULT, wdata1);
CHECK(ret, FAIL, "H5Dwrite");
/* Read all data back */
ret= H5Dread (dataset, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata);
ret= H5Dread(dataset, tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata);
CHECK(ret, FAIL, "H5Dread");
for(i=0; i<MISC12_SPACE1_DIM1; i++)
if(HDstrcmp(wdata[i],rdata[i]))
TestErrPrintf("Error on line %d: wdata[%d]=%s, rdata[%d]=%s\n",__LINE__,i,wdata[i],i,rdata[i]);
for(; i<(MISC12_SPACE1_DIM1+MISC12_APPEND_SIZE); i++)
if(HDstrcmp(wdata1[i-MISC12_SPACE1_DIM1],rdata[i]))
TestErrPrintf("Error on line %d: wdata1[%d]=%s, rdata[%d]=%s\n",__LINE__,i-MISC12_SPACE1_DIM1,wdata1[i-MISC12_SPACE1_DIM1],i,rdata[i]);
for(i = 0; i < MISC12_SPACE1_DIM1; i++)
if(HDstrcmp(wdata[i], rdata[i]))
TestErrPrintf("Error on line %d: wdata[%d]=%s, rdata[%d]=%s\n", __LINE__, i, wdata[i], i, rdata[i]);
for(; i < (MISC12_SPACE1_DIM1 + MISC12_APPEND_SIZE); i++)
if(HDstrcmp(wdata1[i - MISC12_SPACE1_DIM1], rdata[i]))
TestErrPrintf("Error on line %d: wdata1[%d]=%s, rdata[%d]=%s\n", __LINE__, i - MISC12_SPACE1_DIM1, wdata1[i - MISC12_SPACE1_DIM1], i, rdata[i]);
ret = H5Sselect_all (space);
ret = H5Sselect_all(space);
CHECK(ret, FAIL, "H5Sselect_all");
/* Reclaim VL data memory */
ret = H5Dvlen_reclaim (tid1, space, H5P_DEFAULT, rdata);
ret = H5Dvlen_reclaim(tid1, space, H5P_DEFAULT, rdata);
CHECK(ret, FAIL, "H5Dvlen_reclaim");
/* Close Everything */
ret = H5Dclose (dataset);
ret = H5Dclose(dataset);
CHECK(ret, FAIL, "H5Dclose");
ret = H5Tclose (tid1);
ret = H5Tclose(tid1);
CHECK(ret, FAIL, "H5Tclose");
ret = H5Sclose (space);
ret = H5Sclose(space);
CHECK(ret, FAIL, "H5Sclose");
ret = H5Sclose (memspace);
ret = H5Sclose(memspace);
CHECK(ret, FAIL, "H5Sclose");
ret = H5Sclose (sid1);
ret = H5Sclose(sid1);
CHECK(ret, FAIL, "H5Sclose");
ret = H5Pclose (cparms);
ret = H5Pclose(cparms);
CHECK(ret, FAIL, "H5Pclose");
ret = H5Fclose (fid1);
ret = H5Fclose(fid1);
CHECK(ret, FAIL, "H5Fclose");
} /* end test_misc12() */

View File

@ -7309,48 +7309,48 @@ test_select_hyper_chunk_offset(void)
CHECK(did, FAIL, "H5Dcreate");
/* Close the dataspace */
ret=H5Sclose (sid);
ret = H5Sclose(sid);
CHECK(ret, FAIL, "H5Sclose");
/* Close the dataset creation property list */
ret=H5Pclose (dcpl);
ret = H5Pclose(dcpl);
CHECK(ret, FAIL, "H5Pclose");
/* Loop over writing out each chunk */
for(i=SPACE10_CHUNK_SIZE; i<=SPACE10_DIM1; i+=SPACE10_CHUNK_SIZE) {
for(i = SPACE10_CHUNK_SIZE; i <= SPACE10_DIM1; i += SPACE10_CHUNK_SIZE) {
hssize_t offset[1]; /* Offset of selection */
hid_t fsid; /* File dataspace ID */
hsize_t size[1]; /* The size to extend the dataset to */
/* Extend the dataset */
size[0] = i; /* The size to extend the dataset to */
ret=H5Dextend (did, size);
CHECK(ret, FAIL, "H5Dextend");
ret = H5Dset_extent(did, size);
CHECK(ret, FAIL, "H5Dset_extent");
/* Get the (extended) dataspace from the dataset */
fsid = H5Dget_space (did);
fsid = H5Dget_space(did);
CHECK(fsid, FAIL, "H5Dget_space");
/* Select the correct chunk in the dataset */
ret=H5Sselect_hyperslab (fsid, H5S_SELECT_SET, start, NULL, count, NULL);
ret = H5Sselect_hyperslab (fsid, H5S_SELECT_SET, start, NULL, count, NULL);
CHECK(ret, FAIL, "H5Sselect_hyperslab");
/* Set the selection offset for the file dataspace */
offset[0] = i - SPACE10_CHUNK_SIZE;
ret=H5Soffset_simple (fsid, offset);
ret = H5Soffset_simple(fsid, offset);
CHECK(ret, FAIL, "H5Soffset_simple");
/* Set the selection offset for the memory dataspace */
offset[0] = SPACE10_DIM1-i;
ret=H5Soffset_simple (msid, offset);
ret = H5Soffset_simple(msid, offset);
CHECK(ret, FAIL, "H5Soffset_simple");
/* Write the data to the chunk */
ret=H5Dwrite (did, H5T_NATIVE_INT, msid, fsid, H5P_DEFAULT, wbuf);
ret = H5Dwrite(did, H5T_NATIVE_INT, msid, fsid, H5P_DEFAULT, wbuf);
CHECK(ret, FAIL, "H5Soffset_simple");
/* Close the file dataspace copy */
ret=H5Sclose (fsid);
ret = H5Sclose(fsid);
CHECK(ret, FAIL, "H5Sclose");
}
@ -7369,28 +7369,28 @@ test_select_hyper_chunk_offset(void)
*/
/* Re-initialize the write buffer */
for(i=0; i<SPACE10_DIM1; i++)
wbuf[i]=i*2;
for(i = 0; i < SPACE10_DIM1; i++)
wbuf[i] = i * 2;
/* Change the selected the region in the memory dataspace */
start[0] = 0;
count[0] = SPACE10_CHUNK_SIZE/3;
ret=H5Sselect_hyperslab (msid, H5S_SELECT_SET, start, NULL, count, NULL);
ret = H5Sselect_hyperslab(msid, H5S_SELECT_SET, start, NULL, count, NULL);
CHECK(ret, FAIL, "H5Sselect_hyperslab");
start[0] = (2*SPACE10_CHUNK_SIZE)/3;
ret=H5Sselect_hyperslab (msid, H5S_SELECT_OR, start, NULL, count, NULL);
start[0] = (2 * SPACE10_CHUNK_SIZE)/3;
ret = H5Sselect_hyperslab(msid, H5S_SELECT_OR, start, NULL, count, NULL);
CHECK(ret, FAIL, "H5Sselect_hyperslab");
/* Loop over writing out each chunk */
for(i=SPACE10_CHUNK_SIZE; i<=SPACE10_DIM1; i+=SPACE10_CHUNK_SIZE) {
for(i = SPACE10_CHUNK_SIZE; i <= SPACE10_DIM1; i += SPACE10_CHUNK_SIZE) {
hssize_t offset[1]; /* Offset of selection */
hid_t fsid; /* File dataspace ID */
hsize_t size[1]; /* The size to extend the dataset to */
/* Extend the dataset */
size[0] = i; /* The size to extend the dataset to */
ret=H5Dextend (did, size);
CHECK(ret, FAIL, "H5Dextend");
ret = H5Dset_extent(did, size);
CHECK(ret, FAIL, "H5Dset_extent");
/* Get the (extended) dataspace from the dataset */
fsid = H5Dget_space (did);
@ -7398,33 +7398,33 @@ test_select_hyper_chunk_offset(void)
/* Select the correct region in the dataset */
start[0] = 0;
ret=H5Sselect_hyperslab (fsid, H5S_SELECT_SET, start, NULL, count, NULL);
ret = H5Sselect_hyperslab(fsid, H5S_SELECT_SET, start, NULL, count, NULL);
CHECK(ret, FAIL, "H5Sselect_hyperslab");
start[0] = (2*SPACE10_CHUNK_SIZE)/3;
ret=H5Sselect_hyperslab (fsid, H5S_SELECT_OR, start, NULL, count, NULL);
ret = H5Sselect_hyperslab(fsid, H5S_SELECT_OR, start, NULL, count, NULL);
CHECK(ret, FAIL, "H5Sselect_hyperslab");
/* Set the selection offset for the file dataspace */
offset[0] = i - SPACE10_CHUNK_SIZE;
ret=H5Soffset_simple (fsid, offset);
ret = H5Soffset_simple(fsid, offset);
CHECK(ret, FAIL, "H5Soffset_simple");
/* Set the selection offset for the memory dataspace */
offset[0] = SPACE10_DIM1-i;
ret=H5Soffset_simple (msid, offset);
ret = H5Soffset_simple(msid, offset);
CHECK(ret, FAIL, "H5Soffset_simple");
/* Write the data to the chunk */
ret=H5Dwrite (did, H5T_NATIVE_INT, msid, fsid, H5P_DEFAULT, wbuf);
ret = H5Dwrite(did, H5T_NATIVE_INT, msid, fsid, H5P_DEFAULT, wbuf);
CHECK(ret, FAIL, "H5Soffset_simple");
/* Close the file dataspace copy */
ret=H5Sclose (fsid);
ret = H5Sclose(fsid);
CHECK(ret, FAIL, "H5Sclose");
}
/* Read the data back in */
ret=H5Dread (did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf);
ret = H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf);
CHECK(ret, FAIL, "H5Soffset_simple");
/* Verify the information read in */

View File

@ -3267,8 +3267,8 @@ test_sohm_extend_dset_helper(hid_t fcpl_id, hbool_t close_reopen)
}
/* Extend the first dataset */
ret = H5Dextend(dset1_id, dims2);
CHECK_I(ret, "H5Dextend");
ret = H5Dset_extent(dset1_id, dims2);
CHECK_I(ret, "H5Dset_extent");
if(close_reopen) {
/* If requested, close all open IDs and reopen them */
ret = H5Dclose(dset1_id);
@ -3329,8 +3329,8 @@ test_sohm_extend_dset_helper(hid_t fcpl_id, hbool_t close_reopen)
CHECK_I(ret, "H5Sclose");
/* Extend the second dataset */
ret = H5Dextend(dset2_id, dims2);
CHECK_I(ret, "H5Dextend");
ret = H5Dset_extent(dset2_id, dims2);
CHECK_I(ret, "H5Dset_extent");
if(close_reopen) {
/* If requested, close all open IDs and reopen them */
ret = H5Dclose(dset1_id);
@ -3391,8 +3391,8 @@ test_sohm_extend_dset_helper(hid_t fcpl_id, hbool_t close_reopen)
CHECK_I(ret, "H5Sclose");
/* Extend the third dataset */
ret = H5Dextend(dset3_id, dims2);
CHECK_I(ret, "H5Dextend");
ret = H5Dset_extent(dset3_id, dims2);
CHECK_I(ret, "H5Dset_extent");
if(close_reopen) {
/* If requested, close all open IDs and reopen them */
ret = H5Dclose(dset1_id);
@ -3486,8 +3486,8 @@ test_sohm_extend_dset_helper(hid_t fcpl_id, hbool_t close_reopen)
}
/* Extend the first dataset */
ret = H5Dextend(dset1_id, dims2);
CHECK_I(ret, "H5Dextend");
ret = H5Dset_extent(dset1_id, dims2);
CHECK_I(ret, "H5Dset_extent");
if(close_reopen) {
/* If requested, close all open IDs and reopen them */
ret = H5Dclose(dset1_id);
@ -3524,8 +3524,8 @@ test_sohm_extend_dset_helper(hid_t fcpl_id, hbool_t close_reopen)
}
/* Extend the second dataset */
ret = H5Dextend(dset2_id, dims2);
CHECK_I(ret, "H5Dextend");
ret = H5Dset_extent(dset2_id, dims2);
CHECK_I(ret, "H5Dset_extent");
if(close_reopen) {
/* If requested, close all open IDs and reopen them */
ret = H5Dclose(dset1_id);
@ -3570,8 +3570,8 @@ test_sohm_extend_dset_helper(hid_t fcpl_id, hbool_t close_reopen)
}
/* Extend the third dataset */
ret = H5Dextend(dset3_id, dims2);
CHECK_I(ret, "H5Dextend");
ret = H5Dset_extent(dset3_id, dims2);
CHECK_I(ret, "H5Dset_extent");
if(close_reopen) {
/* If requested, close all open IDs and reopen them */
ret = H5Dclose(dset1_id);

View File

@ -1251,7 +1251,7 @@ test_vltypes_compound_vlstr(void)
/* Create a VL datatype of first layer compound type */
tid1 = H5Tvlen_create (tid5);
tid1 = H5Tvlen_create(tid5);
CHECK(tid1, FAIL, "H5Tvlen_create");
/* Create the base compound type */
@ -1259,33 +1259,32 @@ test_vltypes_compound_vlstr(void)
CHECK(tid2, FAIL, "H5Tcreate");
/* Insert fields */
ret=H5Tinsert(tid2, "v", HOFFSET(s1, v), tid1);
ret = H5Tinsert(tid2, "v", HOFFSET(s1, v), tid1);
CHECK(ret, FAIL, "H5Tinsert");
/* Modify dataset creation properties, i.e. enable chunking */
cparms = H5Pcreate (H5P_DATASET_CREATE);
ret = H5Pset_chunk ( cparms, SPACE1_RANK, chunk_dims);
cparms = H5Pcreate(H5P_DATASET_CREATE);
ret = H5Pset_chunk(cparms, SPACE1_RANK, chunk_dims);
CHECK(ret, FAIL, "H5Pset_chunk");
/* Create a dataset */
dataset=H5Dcreate(fid1,"Dataset1",tid2,sid1,cparms);
dataset = H5Dcreate(fid1, "Dataset1", tid2, sid1, cparms);
CHECK(dataset, FAIL, "H5Dcreate");
/* Extend the dataset. This call assures that dataset is 4.*/
ret = H5Dextend (dataset, size);
CHECK(ret, FAIL, "H5Dextend");
ret = H5Dset_extent(dataset, size);
CHECK(ret, FAIL, "H5Dset_extent");
/* Select a hyperslab */
filespace = H5Dget_space (dataset);
ret = H5Sselect_hyperslab (filespace, H5S_SELECT_SET, offset, NULL,
dims1, NULL);
filespace = H5Dget_space(dataset);
ret = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, dims1, NULL);
CHECK(ret, FAIL, "H5Sselect_hyperslab");
/* Write dataset to disk */
ret=H5Dwrite(dataset,tid2,sid1,filespace,H5P_DEFAULT,wdata);
ret = H5Dwrite(dataset, tid2, sid1, filespace, H5P_DEFAULT, wdata);
CHECK(ret, FAIL, "H5Dwrite");
ret=H5Fflush(fid1,H5F_SCOPE_GLOBAL);
ret = H5Fflush(fid1, H5F_SCOPE_GLOBAL);
CHECK(ret, FAIL, "H5Fflush");
/* Close Dataset */

View File

@ -290,7 +290,7 @@ parallel_access_dataset(const char *filename, int nchunks, access_type action, h
/* only extends the dataset */
case extend_only:
/* Extend dataset*/
hrc = H5Dextend(*dataset, size);
hrc = H5Dset_extent(*dataset, size);
VRFY((hrc >= 0), "");
break;

View File

@ -1238,8 +1238,8 @@ extend_writeInd(void)
/* Extend its current dim sizes before writing */
dims[0] = dim0;
dims[1] = dim1;
ret = H5Dextend (dataset1, dims);
VRFY((ret >= 0), "H5Dextend succeeded");
ret = H5Dset_extent(dataset1, dims);
VRFY((ret >= 0), "H5Dset_extent succeeded");
/* create a file dataspace independently */
file_dataspace = H5Dget_space (dataset1);
@ -1298,8 +1298,8 @@ extend_writeInd(void)
/* Extend dataset2 and try again. Should succeed. */
dims[0] = dim0;
dims[1] = dim1;
ret = H5Dextend (dataset2, dims);
VRFY((ret >= 0), "H5Dextend succeeded");
ret = H5Dset_extent(dataset2, dims);
VRFY((ret >= 0), "H5Dset_extent succeeded");
/* create a file dataspace independently */
file_dataspace = H5Dget_space (dataset2);
@ -1448,9 +1448,9 @@ extend_writeInd2(void)
/* -------------------------
* Extend the dataset & retrieve new dataspace
* -------------------------*/
ret =H5Dextend(dataset, &new_size);
VRFY((ret >= 0), "H5Dextend succeeded");
ret=H5Sclose(fs);
ret = H5Dset_extent(dataset, &new_size);
VRFY((ret >= 0), "H5Dset_extent succeeded");
ret = H5Sclose(fs);
VRFY((ret >= 0), "H5Sclose succeeded");
fs = H5Dget_space(dataset);
VRFY((fs >= 0), "H5Dget_space succeeded");
@ -1572,11 +1572,11 @@ extend_readInd(void)
file_dataspace = H5Dget_space (dataset1);
VRFY((file_dataspace >= 0), "H5Dget_space succeeded");
ret=H5Sget_simple_extent_dims(file_dataspace, dims, NULL);
ret = H5Sget_simple_extent_dims(file_dataspace, dims, NULL);
VRFY((ret > 0), "H5Sget_simple_extent_dims succeeded");
dims[0]++;
ret=H5Dextend(dataset1, dims);
VRFY((ret < 0), "H5Dextend failed as expected");
ret = H5Dset_extent(dataset1, dims);
VRFY((ret < 0), "H5Dset_extent failed as expected");
/* restore auto error reporting */
H5Eset_auto2(H5E_DEFAULT, old_func, old_client_data);
@ -1812,8 +1812,8 @@ extend_writeAll(void)
/* Extend its current dim sizes before writing */
dims[0] = dim0;
dims[1] = dim1;
ret = H5Dextend (dataset1, dims);
VRFY((ret >= 0), "H5Dextend succeeded");
ret = H5Dset_extent(dataset1, dims);
VRFY((ret >= 0), "H5Dset_extent succeeded");
/* create a file dataspace independently */
file_dataspace = H5Dget_space (dataset1);
@ -1895,8 +1895,8 @@ extend_writeAll(void)
/* Extend dataset2 and try again. Should succeed. */
dims[0] = dim0;
dims[1] = dim1;
ret = H5Dextend (dataset2, dims);
VRFY((ret >= 0), "H5Dextend succeeded");
ret = H5Dset_extent(dataset2, dims);
VRFY((ret >= 0), "H5Dset_extent succeeded");
/* create a file dataspace independently */
file_dataspace = H5Dget_space (dataset2);
@ -2004,11 +2004,11 @@ extend_readAll(void)
file_dataspace = H5Dget_space (dataset1);
VRFY((file_dataspace >= 0), "H5Dget_space succeeded");
ret=H5Sget_simple_extent_dims(file_dataspace, dims, NULL);
ret = H5Sget_simple_extent_dims(file_dataspace, dims, NULL);
VRFY((ret > 0), "H5Sget_simple_extent_dims succeeded");
dims[0]++;
ret=H5Dextend(dataset1, dims);
VRFY((ret < 0), "H5Dextend failed as expected");
ret = H5Dset_extent(dataset1, dims);
VRFY((ret < 0), "H5Dset_extent failed as expected");
/* restore auto error reporting */
H5Eset_auto2(H5E_DEFAULT, old_func, old_client_data);