本文整理汇总了C++中H5Dget_space函数的典型用法代码示例。如果您正苦于以下问题:C++ H5Dget_space函数的具体用法?C++ H5Dget_space怎么用?C++ H5Dget_space使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了H5Dget_space函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: H5VLARRAYmodify_records
herr_t H5VLARRAYmodify_records( hid_t dataset_id,
hid_t type_id,
hsize_t nrow,
int nobjects,
const void *data )
{
hid_t space_id;
hid_t mem_space_id;
hsize_t start[1];
hsize_t dims_new[1] = {1}; /* Only a record on each update */
hvl_t wdata; /* Information to write */
/* Initialize VL data to write */
wdata.p=(void *)data;
wdata.len=nobjects;
/* Create a simple memory data space */
if ( (mem_space_id = H5Screate_simple( 1, dims_new, NULL )) < 0 )
return -1;
/* Get the file data space */
if ( (space_id = H5Dget_space( dataset_id )) < 0 )
return -1;
/* Define a hyperslab in the dataset */
start[0] = nrow;
if ( H5Sselect_hyperslab( space_id, H5S_SELECT_SET, start, NULL, dims_new, NULL) < 0 )
goto out;
if ( H5Dwrite( dataset_id, type_id, mem_space_id, space_id, H5P_DEFAULT, &wdata ) < 0 )
goto out;
/* Terminate access to the dataspace */
if ( H5Sclose( space_id ) < 0 )
goto out;
if ( H5Sclose( mem_space_id ) < 0 )
goto out;
return 1;
out:
return -1;
}
开发者ID:r0k3,项目名称:PyTables,代码行数:46,代码来源:H5VLARRAY.c
示例2: H5Sclose
int H5mdfile::H5_Dextend(int argc, char **argv, Tcl_Interp *interp)
{
/* Extend dataset to higher dimensions */
H5Sclose(dataspace_id);
for(int i=0;i<dataset_rank;i++)
{
if(atoi(argv[3+i])>(int)dims[i])
{
dims[i]=atoi(argv[3+i])-dimstotal[i];
}
dimstotal[i] = atoi(argv[3+i]);
}
status = H5Dset_extent(dataset_id, dimstotal);
dataspace_id = H5Dget_space(dataset_id);
return TCL_OK;
}
开发者ID:Clemson-MSE,项目名称:espresso,代码行数:17,代码来源:h5mdfile_tcl.cpp
示例3: main
int main (int argc, char ** argv)
{
char filename [256];
int rank, size, i, j;
uint64_t start[2], count[2], bytes_read = 0;
int ndims, nsf;
hid_t file;
hid_t dataset;
hid_t filespace;
hid_t memspace;
int data_out[size];
struct timeval t1;
gettimeofday (&t1, NULL);
file = H5Fopen("write_test.h5", H5F_ACC_RDONLY, H5P_DEFAULT);
dataset = H5Dopen(file, "index");
filespace = H5Dget_space(dataset); /* Get filespace handle first. */
ndims = H5Sget_simple_extent_ndims(filespace);
hsize_t dims[ndims];
herr_t status_n = H5Sget_simple_extent_dims(filespace, dims, NULL);
/*
printf("dataset(temperature) rank %d, dimensions %lux%lu\n",
ndims, (unsigned long)(dims[0]), (unsigned long)(dims[1]));
*/
/*
* Define the memory space to read dataset.
*/
memspace = H5Screate_simple(ndims,dims,NULL);
double data[dims[0]];
/*
* Read dataset back and display.
*/
herr_t status = H5Dread(dataset, H5T_NATIVE_DOUBLE, memspace, filespace,
H5P_DEFAULT, data);
struct timeval t2;
gettimeofday (&t2, NULL);
printf ("read time = %f\n", t2.tv_sec + t2.tv_usec/1000000.0 - t1.tv_sec - t1.tv_usec/1000000.0);
return 0;
}
开发者ID:qliu21,项目名称:read-aio,代码行数:45,代码来源:test_read.c
示例4: freeStringMatrix
int freeStringMatrix(int _iDatasetId, char** _pstData)
{
herr_t status;
hid_t typeId;
hid_t space;
if (_iDatasetId == -1)
{
return 0;
}
typeId = H5Tcopy(H5T_C_S1);
status = H5Tset_size(typeId, H5T_VARIABLE);
if (status < 0)
{
return -1;
}
space = H5Dget_space (_iDatasetId);
status = H5Dvlen_reclaim (typeId, space, H5P_DEFAULT, _pstData);
if (status < 0)
{
return -1;
}
status = H5Sclose(space);
if (status < 0)
{
return -1;
}
status = H5Tclose(typeId);
if (status < 0)
{
return -1;
}
status = H5Dclose(_iDatasetId);
if (status < 0)
{
return -1;
}
return 0;
}
开发者ID:ScilabOrg,项目名称:scilab,代码行数:45,代码来源:h5_readDataFromFile.c
示例5: H5Fopen
void FWSingle::readInLong(int step, string IDstring, vector<long>& data_out)
{
int RANK=1;
hid_t dataset;
hid_t filespace;
hid_t memspace;
hid_t cparms;
hsize_t dims[1]; /* dataset and chunk dimensions*/
hsize_t chunk_dims[1];
herr_t status, status_n;
int rank, rank_chunk;
hsize_t hi, hj;
c_file = H5Fopen(fname.str().c_str(),H5F_ACC_RDONLY,H5P_DEFAULT);
stringstream gname("");
gname<<"Block_"<< step;
hid_t d_file = H5Gopen(c_file,gname.str().c_str());
dataset = H5Dopen(d_file, IDstring.c_str());
filespace = H5Dget_space(dataset);
rank = H5Sget_simple_extent_ndims(filespace);
status_n = H5Sget_simple_extent_dims(filespace, dims, NULL);
// if (verbose>1) printf("dataset ",IDstring.c_str(),"rank %d, dimensions %lu x %lu\n", rank, (unsigned long)(dims[0]), (unsigned long)(dims[1]));
data_out.resize(dims[0]);
cparms = H5Dget_create_plist(dataset);
if (H5D_CHUNKED == H5Pget_layout(cparms))
{
rank_chunk = H5Pget_chunk(cparms, 2, chunk_dims);
// if (verbose>1) printf("chunk rank %d, dimensions %lu \n", rank_chunk, (unsigned long)(chunk_dims[0]) );
}
memspace = H5Screate_simple(RANK,dims,NULL);
status = H5Dread(dataset, H5T_NATIVE_LONG, memspace, filespace, H5P_DEFAULT, &(data_out[0]));
// if(verbose>2)
// {
// printf("\n");
// app_log()<<IDstring.c_str()<<" Dataset: \n"<<endl;
// for (int j = 0; j < dims[0]; j++) app_log()<<data_out[j]<<" ";
// app_log()<<endl;
// }
H5Pclose(cparms);
H5Dclose(dataset);
H5Sclose(filespace);
H5Sclose(memspace);
H5Gclose(d_file);
H5Fclose(c_file);
}
开发者ID:jyamu,项目名称:qmc,代码行数:44,代码来源:FWSingle.cpp
示例6: gridReaderHDF5_readIntoPatchForVar
extern void
gridReaderHDF5_readIntoPatchForVar(gridReader_t reader,
gridPatch_t patch,
int idxOfVar)
{
assert(reader != NULL);
assert(reader->type = GRIDIO_TYPE_HDF5);
assert(patch != NULL);
assert(idxOfVar >= 0 && idxOfVar < gridPatch_getNumVars(patch));
hid_t dataSet;
hid_t dataSpaceFile, dataTypeFile;
hid_t dataSpacePatch, dataTypePatch;
gridPointUint32_t idxLoPatch, dimsPatch;
dataVar_t var = gridPatch_getVarHandle(patch, idxOfVar);
void *data = gridPatch_getVarDataHandle(patch, idxOfVar);
gridPatch_getIdxLo(patch, idxLoPatch);
gridPatch_getDims(patch, dimsPatch);
dataSet = H5Dopen(((gridReaderHDF5_t)reader)->file,
dataVar_getName(var), H5P_DEFAULT);
dataTypeFile = H5Dget_type(dataSet);
dataSpaceFile = H5Dget_space(dataSet);
dataTypePatch = dataVar_getHDF5Datatype(var);
dataSpacePatch = gridUtilHDF5_getDataSpaceFromDims(dimsPatch);
gridUtilHDF5_selectHyperslab(dataSpaceFile, idxLoPatch, dimsPatch);
if (H5Tequal(dataTypeFile, dataTypePatch)) {
H5Dread(dataSet, dataTypeFile, dataSpacePatch,
dataSpaceFile, H5P_DEFAULT, data);
} else {
fprintf(stderr, "ERROR: Datatype in memory differs from file.\n");
diediedie(EXIT_FAILURE);
}
H5Sclose(dataSpacePatch);
H5Tclose(dataTypePatch);
H5Sclose(dataSpaceFile);
H5Tclose(dataTypeFile);
H5Dclose(dataSet);
} /* gridReaderHDF5_readIntoPatchForVar */
开发者ID:satlank,项目名称:ginnungagap,代码行数:44,代码来源:gridReaderHDF5.c
示例7: H5TBOread_records
herr_t H5TBOread_records( hid_t dataset_id,
hid_t mem_type_id,
hsize_t start,
hsize_t nrecords,
void *data )
{
hid_t space_id;
hid_t mem_space_id;
hsize_t count[1];
hsize_t offset[1];
/* Get the dataspace handle */
if ( (space_id = H5Dget_space( dataset_id )) < 0 )
goto out;
/* Define a hyperslab in the dataset of the size of the records */
offset[0] = start;
count[0] = nrecords;
if ( H5Sselect_hyperslab(space_id, H5S_SELECT_SET, offset, NULL, count, NULL) < 0 )
goto out;
/* Create a memory dataspace handle */
if ( (mem_space_id = H5Screate_simple( 1, count, NULL )) < 0 )
goto out;
if ( H5Dread(dataset_id, mem_type_id, mem_space_id, space_id, H5P_DEFAULT, data ) < 0 )
goto out;
/* Terminate access to the memory dataspace */
if ( H5Sclose( mem_space_id ) < 0 )
goto out;
/* Terminate access to the dataspace */
if ( H5Sclose( space_id ) < 0 )
goto out;
return 0;
out:
return -1;
}
开发者ID:tomkooij,项目名称:PyTables,代码行数:43,代码来源:H5TB-opt.c
示例8: fh5d_open_
void fh5d_open_(char *dname, int *hdferr)
{
extern hid_t fileid;
herr_t herr;
dsetid = H5Dopen(fileid, dname);
//printf("fh5d_open: %d\n",dsetid);
if (dsetid < 0) { *hdferr = dsetid; return;}
dspcid = H5Dget_space(dsetid);
//printf("fh5d_get_space: %d\n",dspcid);
*hdferr = dspcid;
return;
}
开发者ID:abudnick,项目名称:TigerED,代码行数:19,代码来源:hdf5_f2c.c
示例9: get_data
// Extract information from HDF5 file
void get_data(std::string data_path, std::string dataset_name, std::vector<double> &data_out){
// Declare variables
const char *fname = data_path.c_str();
hid_t file_id , dataset_id , dataspace_id , file_dataspace_id;
hsize_t* dims;
hssize_t num_elem;
int rank;
int ndims;
// Open existing HDF5 file
file_id = H5Fopen(fname , H5F_ACC_RDONLY , H5P_DEFAULT);
// Open existing dataset
dataset_id = H5Dopen(file_id , dataset_name.c_str(), H5P_DEFAULT);
// Determine dataset parameters
file_dataspace_id = H5Dget_space(dataset_id);
rank = H5Sget_simple_extent_ndims(file_dataspace_id);
dims = (hsize_t*) malloc(rank *sizeof(hsize_t));
ndims = H5Sget_simple_extent_dims(file_dataspace_id, dims, NULL);
//std::cout << "rank: " << std::to_string(rank) << std::endl;
// Allocate matrix
num_elem = H5Sget_simple_extent_npoints(file_dataspace_id);
std::vector<double> data_out_tmp(num_elem);
// = (double*)malloc(num_elem *sizeof(double));
//std::cout << "num_elem: " << std::to_string(num_elem) << std::endl;
// Create dataspace
dataspace_id = H5Screate_simple(rank , dims , NULL);
// Read matrix data from file
H5Dread(dataset_id, H5T_NATIVE_DOUBLE, dataspace_id, file_dataspace_id , H5P_DEFAULT , &data_out_tmp[0]);
data_out = data_out_tmp;
// Release resources and close file
H5Dclose(dataset_id);
H5Sclose(dataspace_id);
H5Sclose(file_dataspace_id);
H5Fclose(file_id);
free(dims);
}
开发者ID:TusharGupta01,项目名称:CellNet,代码行数:44,代码来源:utils.cpp
示例10: get_rank_by_name
/*
* utility function to get dimensionality of a dataset
*/
int get_rank_by_name(hid_t group_id, char *name)
{
if (!checkfordataset(group_id,name)) { return 0; }
herr_t HDF5_error = -1;
#if H5_VERSION_GE(1,8,0)
hid_t dataset_id = H5Dopen2(group_id,name,H5P_DEFAULT);
#else
hid_t dataset_id = H5Dopen(group_id,name);
#endif
if (dataset_id == HDF5_error)
{ printf("ERROR opening %s data set \n",name); return 0; }
hid_t dataspace_id = H5Dget_space(dataset_id);
int rank = get_rank(dataspace_id);
H5Dclose(dataset_id);
return rank;
}
开发者ID:amoose136,项目名称:splash,代码行数:22,代码来源:read_data_amuse_hdf5_utils.c
示例11: hdf5_object
hdf5_dataspace::hdf5_dataspace(hdf5_dataset const& dataset)
:
hdf5_object(H5Dget_space(dataset.get_id()))
{
if(dataset.get_id() < 0) {
boost::serialization::throw_exception(
hdf5_archive_exception(
hdf5_archive_exception::hdf5_archive_dataset_access_error
)
);
}
if(get_id() < 0) {
boost::serialization::throw_exception(
hdf5_archive_exception(
hdf5_archive_exception::hdf5_archive_dataspace_access_error
)
);
}
}
开发者ID:bingzhang00,项目名称:serialization,代码行数:19,代码来源:hdf5_dataspace.cpp
示例12: H5ARRAYget_info
herr_t H5ARRAYget_info( hid_t dataset_id,
hid_t type_id,
hsize_t *dims,
hsize_t *maxdims,
H5T_class_t *class_id,
char *byteorder)
{
hid_t space_id;
/* Get the class. */
*class_id = H5Tget_class( type_id );
/* Get the dataspace handle */
if ( (space_id = H5Dget_space( dataset_id )) < 0 )
goto out;
/* Get dimensions */
if ( H5Sget_simple_extent_dims( space_id, dims, maxdims) < 0 )
goto out;
/* Terminate access to the dataspace */
if ( H5Sclose( space_id ) < 0 )
goto out;
/* Get the byteorder */
/* Only integer, float, time, enumerate and array classes can be
byteordered */
if ((*class_id == H5T_INTEGER) || (*class_id == H5T_FLOAT)
|| (*class_id == H5T_BITFIELD) || (*class_id == H5T_COMPOUND)
|| (*class_id == H5T_TIME) || (*class_id == H5T_ENUM)
|| (*class_id == H5T_ARRAY)) {
get_order(type_id, byteorder);
}
else {
strcpy(byteorder, "irrelevant");
}
return 0;
out:
return -1;
}
开发者ID:87,项目名称:PyTables,代码行数:43,代码来源:H5ARRAY.c
示例13: ASDF_write_partial_waveform
herr_t ASDF_write_partial_waveform(hid_t data_id, const float *waveform,
int offset, int nsamples) {
hid_t space_id, slab_id;
CHK_H5(space_id = H5Dget_space(data_id));
hsize_t start[1] = {offset};
hsize_t count[1] = {1};
hsize_t block[1] = {nsamples};
CHK_H5(H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start,
NULL, count, block));
CHK_H5(slab_id = H5Screate_simple(1, block, NULL));
CHK_H5(H5Dwrite(data_id, H5T_IEEE_F32LE, slab_id, space_id,
H5P_DEFAULT, waveform));
CHK_H5(H5Sclose(slab_id));
CHK_H5(H5Sclose(space_id));
return 0; // Success
}
开发者ID:QuLogic,项目名称:asdf-library,代码行数:19,代码来源:ASDF_write.c
示例14: cow_domain_readsize
void cow_domain_readsize(cow_domain *d, char *fname, char *dname)
{
#if (COW_HDF5)
if (_io_check_file_exists(fname)) return;
hid_t file = H5Fopen(fname, H5F_ACC_RDONLY, d->fapl);
hid_t dset = H5Dopen(file, dname, H5P_DEFAULT);
hid_t fspc = H5Dget_space(dset);
hsize_t dims[3] = { 1, 1, 1 };
int ndims = H5Sget_simple_extent_dims(fspc, dims, NULL);
H5Dclose(dset);
H5Fclose(file);
cow_domain_setndim(d, ndims);
for (int n=0; n<ndims; ++n) {
cow_domain_setsize(d, n, dims[n]);
}
printf("[%s] inferred global domain size of (%lld %lld %lld) from %s/%s\n",
MODULE, dims[0], dims[1], dims[2], fname, dname);
#endif
}
开发者ID:darien0,项目名称:cow,代码行数:19,代码来源:io.c
示例15: h5_read
void h5_read(group g, std::string const& name, std::string& value) {
dataset ds = g.open_dataset(name);
h5::dataspace d_space = H5Dget_space(ds);
int rank = H5Sget_simple_extent_ndims(d_space);
if (rank != 0) TRIQS_RUNTIME_ERROR << "Reading a string and got rank !=0";
size_t size = H5Dget_storage_size(ds);
datatype strdatatype = H5Tcopy(H5T_C_S1);
H5Tset_size(strdatatype, size);
//auto status = H5Tset_size(strdatatype, size);
// auto status = H5Tset_size (strdatatype, H5T_VARIABLE);
std::vector<char> buf(size + 1, 0x00);
auto err = H5Dread(ds, strdatatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, &buf[0]);
if (err < 0) TRIQS_RUNTIME_ERROR << "Error reading the string named" << name << " in the group" << g.name();
value = "";
value.append(&(buf.front()));
}
开发者ID:JaksaVucicevic,项目名称:triqs,代码行数:19,代码来源:string.cpp
示例16: H5TBOwrite_elements
herr_t H5TBOwrite_elements( hid_t dataset_id,
hid_t mem_type_id,
hsize_t nrecords,
const void *coords,
const void *data )
{
hsize_t count[1];
hid_t space_id;
hid_t mem_space_id;
/* Get the dataspace handle */
if ( (space_id = H5Dget_space( dataset_id )) < 0 )
goto out;
/* Define a selection of points in the dataset */
if ( H5Sselect_elements(space_id, H5S_SELECT_SET, (size_t)nrecords, (const hsize_t *)coords) < 0 )
goto out;
/* Create a memory dataspace handle */
count[0] = nrecords;
if ( (mem_space_id = H5Screate_simple( 1, count, NULL )) < 0 )
goto out;
if ( H5Dwrite( dataset_id, mem_type_id, mem_space_id, space_id, H5P_DEFAULT, data ) < 0 )
goto out;
/* Terminate access to the memory dataspace */
if ( H5Sclose( mem_space_id ) < 0 )
goto out;
/* Terminate access to the dataspace */
if ( H5Sclose( space_id ) < 0 )
goto out;
return 0;
out:
return -1;
}
开发者ID:tomkooij,项目名称:PyTables,代码行数:42,代码来源:H5TB-opt.c
示例17: H5Dget_space
/**
* Write hyperslab.
*
* @param [in] HDF5_Dataset_id - Dataset id
* @param [in] Position - Position in the dataset
* @param [in] Size - Size of the hyperslab
* @param [in] Data
* @throw ios::failure
*/
void THDF5_File::WriteHyperSlab(const hid_t HDF5_Dataset_id, const TDimensionSizes & Position , const TDimensionSizes & Size, const long * Data){
// Select hyperslab
const int MatrixRank = 3;
hsize_t ElementCount[MatrixRank] = {Size.Z, Size.Y, Size.X};
hsize_t Offset[MatrixRank] = {Position.Z,Position.Y,Position.X};
herr_t status;
hid_t HDF5_Filespace,HDF5_Memspace;
// Select hyperslab in the file.
HDF5_Filespace = H5Dget_space(HDF5_Dataset_id);
status = H5Sselect_hyperslab(HDF5_Filespace, H5S_SELECT_SET, Offset, 0, ElementCount, NULL);
if (status < 0) {
char ErrorMessage[256];
sprintf(ErrorMessage,HDF5_ERR_FMT_CouldNotWriteTo,"");
throw ios::failure(ErrorMessage);
}
// assign memspace
HDF5_Memspace = H5Screate_simple(MatrixRank, ElementCount, NULL);
status = H5Dwrite(HDF5_Dataset_id, H5T_STD_U64LE, HDF5_Memspace, HDF5_Filespace, H5P_DEFAULT, Data);
if (status < 0) {
char ErrorMessage[256];
sprintf(ErrorMessage,HDF5_ERR_FMT_CouldNotWriteTo,"");
throw ios::failure(ErrorMessage);
}
H5Sclose(HDF5_Memspace);
H5Sclose(HDF5_Filespace);
}// end of WriteHyperSlab
开发者ID:nhjun,项目名称:AO-KWave-MCBoost,代码行数:51,代码来源:HDF5_File.cpp
示例18: H5Dopen
bool PWParameterSet::getEigVectorType(hid_t h)
{
int rank=0;
if(is_manager())
{
ostringstream oss;
oss << "/"<<eigTag << "/"<<twistTag<<twistIndex << "/"<< bandTag << 0;
//if(version[1]==10)
if(hasSpin)
oss << "/" << spinTag << 0;
oss << "/eigenvector";
hsize_t dimTot[4];
hid_t dataset = H5Dopen(h,oss.str().c_str());
hid_t dataspace = H5Dget_space(dataset);
rank = H5Sget_simple_extent_ndims(dataspace);
int status_n = H5Sget_simple_extent_dims(dataspace, dimTot, NULL);
}
myComm->bcast(rank);
return rank==4;
}
开发者ID:digideskio,项目名称:qmcpack,代码行数:20,代码来源:PWParameterSet.cpp
示例19: writeAtmos_p
/* ------- begin -------------------------- writeAtmos_p.c --- */
void writeAtmos_p(void)
{
/* Write atmos arrays. This has now been modified and writes the interpolated
arrays, from depth_refine. With that, now this is the only viable option
to write the atmos data, as there is no option to save in memory and
writeAtmos_all used to write from the input file, not the interpolated
quantities
IMPORTANT: at the moment this is a trimmed version, only writing z to save
space and computational time.
*/
const char routineName[] = "writeAtmos_p";
hsize_t offset[] = {0, 0, 0, 0};
hsize_t count[] = {1, 1, 1, 1};
hsize_t dims[4];
hid_t file_dspace, mem_dspace;
/* Memory dataspace */
dims[0] = atmos.Nspace;
if (( mem_dspace = H5Screate_simple(1, dims, NULL) ) < 0)
HERR(routineName);
/* File dataspace */
offset[0] = mpi.ix;
offset[1] = mpi.iy;
offset[2] = mpi.zcut;
count[2] = atmos.Nspace;
if (( file_dspace = H5Dget_space(io.in_atmos_T) ) < 0) HERR(routineName);
if (( H5Sselect_hyperslab(file_dspace, H5S_SELECT_SET, offset,
NULL, count, NULL) ) < 0) HERR(routineName);
if (( H5Dwrite(io.in_atmos_T, H5T_NATIVE_DOUBLE, mem_dspace,
file_dspace, H5P_DEFAULT, atmos.T) ) < 0) HERR(routineName);
if (( H5Dwrite(io.in_atmos_vz, H5T_NATIVE_DOUBLE, mem_dspace,
file_dspace, H5P_DEFAULT, geometry.vel) ) < 0) HERR(routineName);
if (( H5Dwrite(io.in_atmos_z, H5T_NATIVE_DOUBLE, mem_dspace,
file_dspace, H5P_DEFAULT, geometry.height) ) < 0) HERR(routineName);
/* release dataspace resources */
if (( H5Sclose(mem_dspace) ) < 0) HERR(routineName);
if (( H5Sclose(file_dspace) ) < 0) HERR(routineName);
return;
}
开发者ID:kouui,项目名称:rh,代码行数:42,代码来源:writeindata_p.c
示例20: check_dset
/*-------------------------------------------------------------------------
* Function: check_dset
*
* Purpose: Part 2 of a two-part H5Fflush() test, checks if the data in a dataset
* is what it is supposed to be.
*
* Return: Success: 0
*
* Failure: 1
*
* Programmer: Leon Arber
* Oct. 4, 2006.
*
*-------------------------------------------------------------------------
*/
static int
check_dset(hid_t file, const char* name)
{
hid_t space, dset;
hsize_t ds_size[2] = {100, 100};
double error;
size_t i, j;
/* Open the dataset */
if((dset = H5Dopen2(file, name, H5P_DEFAULT)) < 0) goto error;
if((space = H5Dget_space(dset)) < 0) goto error;
if(H5Sget_simple_extent_dims(space, ds_size, NULL) < 0) goto error;
assert(100 == ds_size[0] && 100 == ds_size[1]);
/* Read some data */
if(H5Dread(dset, H5T_NATIVE_DOUBLE, space, space, H5P_DEFAULT, the_data) < 0)
goto error;
for(i = 0; i < (size_t)ds_size[0]; i++)
for(j = 0; j < (size_t)ds_size[1]; j++) {
/*
* The extra cast in the following statement is a bug workaround
* for the Win32 version 5.0 compiler.
* 1998-11-06 ptl
*/
error = fabs(the_data[i][j] - (double)(hssize_t)i / ((hssize_t)j + 1));
if(error > 0.0001F) {
H5_FAILED();
printf(" dset[%lu][%lu] = %g\n",
(unsigned long)i, (unsigned long)j, the_data[i][j]);
printf(" should be %g\n",
(double)(hssize_t)i/(hssize_t)(j+1));
goto error;
} /* end if */
} /* end for */
if(H5Dclose(dset) < 0)
goto error;
return 0;
error:
return 1;
}
开发者ID:CommonLibrary,项目名称:hdf5,代码行数:56,代码来源:flush2.c
注:本文中的H5Dget_space函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论