本文整理汇总了C++中H5Dopen2函数的典型用法代码示例。如果您正苦于以下问题:C++ H5Dopen2函数的具体用法?C++ H5Dopen2怎么用?C++ H5Dopen2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了H5Dopen2函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: region_origin
int ErrorData::readH5(hid_t group_id) {
// Read all the data
hid_t dataset_id;
vector<unsigned int> region_origin(2,0);
dataset_id = H5Dopen2(group_id,"region_origin",H5P_DEFAULT);
H5Dread(dataset_id, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, ®ion_origin[0]);
H5Dclose(dataset_id);
vector<unsigned int> region_dim(2,0);
dataset_id = H5Dopen2(group_id,"region_dim",H5P_DEFAULT);
H5Dread(dataset_id, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, ®ion_dim[0]);
H5Dclose(dataset_id);
vector<unsigned int> error_data_dim(2,0);
dataset_id = H5Dopen2(group_id,"error_data_dim",H5P_DEFAULT);
H5Dread(dataset_id, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &error_data_dim[0]);
H5Dclose(dataset_id);
if(error_data_dim[0] != ERROR_DATA_N_ROWS)
return(EXIT_FAILURE);
vector<uint64_t> error_data(error_data_dim[0]*error_data_dim[1],0);
dataset_id = H5Dopen2(group_id,"error_data",H5P_DEFAULT);
H5Dread(dataset_id, H5T_NATIVE_UINT_LEAST64, H5S_ALL, H5S_ALL, H5P_DEFAULT, &error_data[0]);
H5Dclose(dataset_id);
// Store data in object
Initialize(region_origin,region_dim,error_data_dim,error_data);
return(EXIT_SUCCESS);
}
开发者ID:Brainiarc7,项目名称:TS,代码行数:29,代码来源:ionstats_data.cpp
示例2: H5Fopen
void Fast5Files::convertFasta(QString outfile){
hid_t fast5id;
hid_t fastq;
for(int i = 0; i < filenames.size(); ++i){
fast5id = H5Fopen(filenames.at(i).toLatin1().data(), H5F_ACC_RDONLY, H5P_DEFAULT);
fastq = H5Dopen2(fast5id, "/Analyses/Basecall_2D_000/BaseCalled_template/Fastq", H5P_DEFAULT);
if(fastq > 0){
getFastq(fastq);
}
fastq = H5Dopen2(fast5id, "/Analyses/Basecall_2D_000/BaseCalled_complement/Fastq", H5P_DEFAULT);
if(fastq > 0){
getFastq(fastq);
}
fastq = H5Dopen2(fast5id, "/Analyses/Basecall_2D_000/BaseCalled_2D/Fastq", H5P_DEFAULT);
if(fastq > 0){
getFastq(fastq);
}
H5Fclose(fast5id);
}
}
开发者ID:TravisCG,项目名称:Fast5-Studio,代码行数:25,代码来源:fast5files.cpp
示例3: test_read_with_filters
/*-------------------------------------------------------------------------
* Function: test_read_with_filters
*
* Purpose: Tests reading dataset created with dynamically loaded filters
*
* Return: Success: 0
* Failure: -1
*
* Programmer: Raymond Lu
* 14 March 2013
*
*-------------------------------------------------------------------------
*/
static herr_t
test_read_with_filters(hid_t file)
{
hid_t dset; /* Dataset ID */
/*----------------------------------------------------------
* STEP 1: Test deflation by itself.
*----------------------------------------------------------
*/
#ifdef H5_HAVE_FILTER_DEFLATE
TESTING("Testing deflate filter");
if(H5Zfilter_avail(H5Z_FILTER_DEFLATE) != TRUE) TEST_ERROR
if((dset = H5Dopen2(file,DSET_DEFLATE_NAME,H5P_DEFAULT)) < 0) TEST_ERROR
if(test_read_data(dset, (int *)points_deflate) < 0) TEST_ERROR
if(H5Dclose(dset) < 0) TEST_ERROR
/* Clean up objects used for this test */
#else /* H5_HAVE_FILTER_DEFLATE */
TESTING("deflate filter");
SKIPPED();
puts(" Deflate filter not enabled");
#endif /* H5_HAVE_FILTER_DEFLATE */
/*----------------------------------------------------------
* STEP 2: Test DYNLIB1 by itself.
*----------------------------------------------------------
*/
TESTING("Testing DYNLIB1 filter");
if((dset = H5Dopen2(file,DSET_DYNLIB1_NAME,H5P_DEFAULT)) < 0) TEST_ERROR
if(test_read_data(dset, (int *)points_dynlib1) < 0) TEST_ERROR
if(H5Dclose(dset) < 0) TEST_ERROR
/*----------------------------------------------------------
* STEP 3: Test Bogus2 by itself.
*----------------------------------------------------------
*/
TESTING("Testing DYNLIB2 filter");
if((dset = H5Dopen2(file,DSET_DYNLIB2_NAME,H5P_DEFAULT)) < 0) TEST_ERROR
if(test_read_data(dset, (int *)points_dynlib2) < 0) TEST_ERROR
if(H5Dclose(dset) < 0) TEST_ERROR
return 0;
error:
return -1;
}
开发者ID:schwehr,项目名称:hdf5,代码行数:69,代码来源:plugin.c
示例4: loadHdf5Input
/* Read and load coefficients Knlm and scale radius a */
int loadHdf5Input(char *filename, struct Indata *var){
hid_t hdf_file,hdf_group,hdf_data;
herr_t status;
double temp[NMAX][LMAX][LMAX][2];
fprintf(stdout,"Reading file %s ...",filename);
hdf_file = H5Fopen(filename,H5F_ACC_RDONLY,H5P_DEFAULT);
if (hdf_file < 0){
return -1;
}
if ( (hdf_group=H5Gopen2(hdf_file,"/",H5P_DEFAULT)) < 0){
H5Gclose(hdf_file);
return -1;
}
if ( (hdf_data=H5Dopen2(hdf_file,"/Knlm",H5P_DEFAULT)) < 0){
H5Dclose(hdf_data);
return -1;
}
//status=H5Dread(hdf_data, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, var->Knlm);
status=H5Dread(hdf_data, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, temp);
for (int n=0; n<NMAX; n++){
for (int l=0; l<LMAX; l++){
for (int m=0; m<LMAX; m++){
var->Knlm[l][m][n][0]=temp[n][l][m][0]; // I reorder the matrix since the summation
var->Knlm[l][m][n][1]=temp[n][l][m][1]; // over n is done first
// [0]/[1] -> cosine/sine terms
}
}
}
/* Read virial radius (not really needed) */
if ( (hdf_data=H5Dopen2(hdf_file,"/Rvir",H5P_DEFAULT)) < 0){
H5Dclose(hdf_data);
return -1;
}
status=H5Dread(hdf_data, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &var->virialrad);
/* Read Hernquist scale radius needed to normalize positions */
if ( (hdf_data=H5Dopen2(hdf_file,"/a",H5P_DEFAULT)) < 0){
H5Dclose(hdf_data);
return -1;
}
status=H5Dread(hdf_data, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, &var->scalerad);
//H5Gclose(hdf_group);
H5Fclose(hdf_file);
H5Dclose(hdf_data);
fprintf(stdout," file read successfully!\n");
return 0;
}
开发者ID:edjocute,项目名称:Orbit,代码行数:54,代码来源:readfile.cpp
示例5: H5IMread_image
herr_t H5IMread_image( hid_t loc_id,
const char *dset_name,
unsigned char *buf )
{
hid_t did;
/* check the arguments */
if (dset_name == NULL)
return -1;
/* Open the dataset. */
if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
return -1;
/* Read */
if ( H5Dread( did, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf ) < 0)
goto out;
/* End access to the dataset and release resources used by it. */
if ( H5Dclose( did ) )
return -1;
return 0;
out:
H5Dclose( did );
return -1;
}
开发者ID:AndyHuang7601,项目名称:EpicGames-UnrealEngine,代码行数:29,代码来源:H5IM.c
示例6: read_vector
int read_vector(hid_t loc_id,const char *name,T *value,int len)
{
hid_t space_id,dset_id,dti_file;
int hdferr,ndims;
hsize_t dims[2], maxdims[2];
printf("Attempting to read vector '%s'\n",name);
dset_id= H5Dopen2(loc_id,name,H5P_DEFAULT);
space_id= H5Dget_space(dset_id);
ndims= H5Sget_simple_extent_ndims(space_id);
if(ndims!=1) return -1;
H5Sget_simple_extent_dims(space_id,dims,maxdims);
if(dims[0]>len) return -1;
hdferr= H5Dread(dset_id,TypeTraits<T>::hdf5Type(),H5S_ALL,H5S_ALL,H5P_DEFAULT,value);
if(hdferr<0) return -1;
H5Sclose(space_id);
H5Dclose(dset_id);
return dims[0];
}
开发者ID:sidjana,项目名称:lsms-shmem,代码行数:25,代码来源:HDF5io.hpp
示例7: test_duplicatelong_attachscales
static int test_duplicatelong_attachscales(const char *filename)
{
hid_t fid = -1;
hid_t did = -1;
char dsname[32];
char scalename[32];
strcpy(dsname, DATASET_NAME);
strcat(dsname, "al2");
TESTING2("test_duplicatelong_attachscales");
if((fid = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
goto out;
/* make a dataset 2 */
if(create_long_dataset(fid, dsname, "al2") < 0)
goto out;
if((did = H5Dopen2(fid, dsname, H5P_DEFAULT)) >= 0) {
strcpy(scalename, DS_1_NAME);
strcat(scalename, "al");
if(test_attach_scale(fid, did, scalename, DIM0) < 0)
goto out;
strcpy(scalename, DS_2_NAME);
strcat(scalename, "al");
if(test_attach_scale(fid, did, scalename, DIM1) < 0)
goto out;
strcpy(scalename, DS_3_NAME);
strcat(scalename, "al");
if(test_attach_scale(fid, did, scalename, DIM2) < 0)
goto out;
strcpy(scalename, DS_4_NAME);
strcat(scalename, "al");
if(test_attach_scale(fid, did, scalename, DIM3) < 0)
goto out;
if(H5Dclose(did) < 0)
goto out;
}
else
goto out;
PASSED();
H5Fclose(fid);
return SUCCEED;
out:
H5E_BEGIN_TRY {
H5Dclose(did);
H5Fclose(fid);
} H5E_END_TRY;
H5_FAILED();
return FAIL;
}
开发者ID:herr-biber,项目名称:hdf5,代码行数:60,代码来源:gen_test_ds.c
示例8: h5dopen_c
/****if* H5Df/h5dopen_c
* NAME
* h5dopen_c
* PURPOSE
* Call H5Dopen2 to open a dataset
* INPUTS
* loc_id - file or group identifier
* name - name of the dataset
* namelen - name length
* dapl_id - Dataset access property list
* OUTPUTS
* dset_id - dataset identifier
* RETURNS
* 0 on success, -1 on failure
* AUTHOR
* Elena Pourmal
* Wednesday, August 4, 1999
* HISTORY
* Added 1.8 parameter: dapl_id
* SOURCE
*/
int_f
h5dopen_c(hid_t_f *loc_id, _fcd name, int_f *namelen, hid_t_f *dapl_id, hid_t_f *dset_id)
/******/
{
char *c_name = NULL;
hid_t c_dset_id;
int ret_value = -1;
/*
* Convert FORTRAN name to C name
*/
if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen)))
goto DONE;
/*
* Call H5Dopen2 function.
*/
if((c_dset_id = H5Dopen2((hid_t)*loc_id, c_name, (hid_t)*dapl_id)) < 0)
goto DONE;
*dset_id = (hid_t_f)c_dset_id;
ret_value = 0;
DONE:
if(c_name)
HDfree(c_name);
return ret_value;
}
开发者ID:ElaraFX,项目名称:hdf5,代码行数:49,代码来源:H5Df.c
示例9: test_filter_error
/*-------------------------------------------------------------------------
* Function: test_filter_error
*
* Purpose: Make sure the error message prints out the filter name
* when the existent file is opened but the filter isn't
* registered. The existent file was created with
* gen_filters.c.
*
* Return: Success: 0
*
* Failure: -1
*
* Programmer: Raymond Lu
* 2 June 2011
*
*-------------------------------------------------------------------------
*/
static herr_t
test_filter_error(const char *fname)
{
const char *pathname = H5_get_srcdir_filename(fname); /* Corrected test file name */
hid_t file, dataset; /* handles */
int buf[20];
HDfprintf(stderr, "\nTesting error message during data reading when filter isn't registered\n");
/* Open the file */
if((file = H5Fopen(pathname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
TEST_ERROR;
/* Open the regular dataset */
if((dataset = H5Dopen2(file, DSET_FILTER_NAME, H5P_DEFAULT)) < 0)
TEST_ERROR;
if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) >= 0)
TEST_ERROR;
/* Close/release resources */
if(H5Dclose(dataset) < 0)
TEST_ERROR
if(H5Fclose(file) < 0)
TEST_ERROR
return 0;
error:
return -1;
}
开发者ID:adasworks,项目名称:hdf5,代码行数:49,代码来源:error_test.c
示例10: test_noread_with_filters
/*-------------------------------------------------------------------------
* Function: test_noread_with_filters
*
* Purpose: Tests reading dataset created with dynamically loaded filters disabled
*
* Return: Success: 0
* Failure: -1
*
*-------------------------------------------------------------------------
*/
static herr_t
test_noread_with_filters(hid_t file)
{
hid_t dset; /* Dataset ID */
unsigned plugin_state; /* status of plugins */
TESTING("Testing DYNLIB1 filter with plugins disabled");
/* disable filter plugin */
if(H5PLget_loading_state(&plugin_state) < 0) TEST_ERROR
plugin_state = plugin_state & ~H5PL_FILTER_PLUGIN;
if(H5PLset_loading_state(plugin_state) < 0) TEST_ERROR
if((dset = H5Dopen2(file,DSET_DYNLIB1_NAME,H5P_DEFAULT)) < 0) TEST_ERROR
if(test_noread_data(dset) < 0) TEST_ERROR
if(H5Dclose(dset) < 0) TEST_ERROR
/* re-enable filter plugin */
plugin_state = plugin_state | H5PL_FILTER_PLUGIN;
if(H5PLset_loading_state(plugin_state) < 0) TEST_ERROR
return 0;
error:
/* re-enable filter plugin */
plugin_state = plugin_state | H5PL_FILTER_PLUGIN;
if(H5PLset_loading_state(plugin_state) < 0) TEST_ERROR
return -1;
}
开发者ID:adasworks,项目名称:hdf5,代码行数:40,代码来源:plugin.c
示例11: test_cmp_scalename
herr_t test_cmp_scalename(hid_t fid, hid_t did, const char *name, const char *scalename, unsigned int idx)
{
herr_t ret_value = FAIL;
hid_t dsid = -1;
ssize_t name_len;
char *name_out=NULL;
if((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) {
if(H5DSis_attached(did, dsid, idx) == 1) {
if((name_len=H5DSget_scale_name(dsid,NULL,(size_t)0)) > 0) {
name_out = (char*)malloc((size_t)name_len * sizeof (char));
if(name_out != NULL) {
if(H5DSget_scale_name(dsid, name_out, (size_t)name_len) >= 0) {
if(strcmp(scalename,name_out)==0) {
ret_value = SUCCEED;
}
free(name_out);
name_out=NULL;
}
}
}
}
if(H5Dclose(dsid) < 0)
ret_value = FAIL;
}
return ret_value;
}
开发者ID:herr-biber,项目名称:hdf5,代码行数:28,代码来源:gen_test_ds.c
示例12: H5IMread_imagef
herr_t H5IMread_imagef(hid_t loc_id,
const char *dset_name,
int_f *buf)
{
hid_t did;
hid_t tid;
/* open the dataset */
if((did = H5Dopen2(loc_id, dset_name, H5P_DEFAULT)) < 0)
return -1;
/* determine appropriate datatype to use */
if(sizeof(int_f) == sizeof(int))
tid = H5T_NATIVE_INT;
else if(sizeof(int_f) == sizeof(long))
tid = H5T_NATIVE_LONG;
else if(sizeof(int_f) == sizeof(long long))
tid = H5T_NATIVE_LLONG;
else
goto out;
/* read to memory */
if(H5Dread(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
goto out;
/* close */
if(H5Dclose(did))
return -1;
return 0;
out:
H5Dclose(did);
return -1;
}
开发者ID:ArielleBassanelli,项目名称:gempak,代码行数:35,代码来源:H5IMcc.c
示例13: ls2_hdf5_read_anchors
ls2_hdf5_read_anchors(hid_t file, vector2** anchors, size_t *no_anchors)
{
hid_t dataset, dataspace, memspace;
hsize_t dims[2];
int rank;
dataset = H5Dopen2(file, "/Anchors", H5P_DEFAULT);
dataspace = H5Dget_space(dataset);
rank = H5Sget_simple_extent_ndims(dataspace);
if (rank != 2) {
fprintf(stderr, "/Anchors wrong rank %d\n", (int) rank);
return -1;
}
H5Sget_simple_extent_dims(dataspace, dims, NULL);
if (dims[1] != 2) {
fprintf(stderr, "/Anchors dimension (%d, %d)\n",
(int) dims[0], (int) dims[1]);
return -1;
}
*no_anchors = (size_t) dims[0];
*anchors = (vector2 *) calloc(*no_anchors, sizeof(vector2));
memspace = H5Screate_simple(2, dims, NULL);
H5Dread(dataset, H5T_NATIVE_FLOAT, memspace, dataspace, H5P_DEFAULT,
*anchors);
H5Dclose(dataset);
H5Sclose(dataspace);
H5Sclose(memspace);
return 0;
}
开发者ID:madcowpp,项目名称:LS2,代码行数:30,代码来源:be_hdf5.c
示例14: H5Gopen2
void pyne::Material::_load_comp_protocol0(hid_t db, std::string datapath, int row) {
hid_t matgroup = H5Gopen2(db, datapath.c_str(), H5P_DEFAULT);
hid_t nucset;
double nucvalue;
ssize_t nuckeylen;
std::string nuckey;
// get the number of members in the material group
H5G_info_t group_info;
H5Gget_info(matgroup, &group_info);
hsize_t matG = group_info.nlinks;
// Iterate over datasets in the group.
for (int matg = 0; matg < matG; matg++) {
nuckeylen = 1 + H5Lget_name_by_idx(matgroup, ".", H5_INDEX_NAME, H5_ITER_INC, matg,
NULL, 0, H5P_DEFAULT);
char * nkey = new char[nuckeylen];
nuckeylen = H5Lget_name_by_idx(matgroup, ".", H5_INDEX_NAME, H5_ITER_INC, matg,
nkey, nuckeylen, H5P_DEFAULT);
nuckey = nkey;
nucset = H5Dopen2(matgroup, nkey, H5P_DEFAULT);
nucvalue = h5wrap::get_array_index<double>(nucset, row);
if (nuckey == "Mass" || nuckey == "MASS" || nuckey == "mass")
mass = nucvalue;
else
comp[pyne::nucname::id(nuckey)] = nucvalue;
H5Dclose(nucset);
delete[] nkey;
};
// Set meta data
atoms_per_molecule = -1.0;
};
开发者ID:crbates,项目名称:pyne,代码行数:35,代码来源:material.cpp
示例15: path_
hdf5_dataset::hdf5_dataset(
hdf5_file const& file,
std::string const& path
)
:
path_(path)
{
// Check if name exists in this file.
htri_t status = H5Lexists(file.get_id(), path.c_str(), H5P_DEFAULT);
if(status > 0) { // Full path exists.
// Attempt to open it as a dataset
set_id(H5Dopen2(file.get_id(), path.c_str(), H5P_DEFAULT));
if(get_id() < 0) {
boost::serialization::throw_exception(
hdf5_archive_exception(
hdf5_archive_exception::hdf5_archive_dataset_access_error,
path.c_str()
)
);
}
}
else { // path does not exist, or other error
boost::serialization::throw_exception(
hdf5_archive_exception(
hdf5_archive_exception::hdf5_archive_bad_path_error,
path.c_str()
)
);
}
}
开发者ID:warn-naught,项目名称:serialization,代码行数:30,代码来源:hdf5_dataset.cpp
示例16: H5Fopen
int64_t GWriteHDFFile::WriteBlock(std::string BlockName, int type, void *data, int partlen, uint32_t np_write, uint32_t begin)
{
herr_t herr;
hid_t handle = H5Fopen(filename.c_str(), H5F_ACC_RDWR, H5P_DEFAULT);
hid_t group = H5Gopen2(handle, g_name[type], H5P_DEFAULT);
if(group < 0)
return group;
hsize_t size[2];
int rank=1;
//Get type
char b_type = get_block_type(BlockName);
hid_t dtype;
if(b_type == 'f') {
size[1] = partlen/sizeof(float);
dtype=H5T_NATIVE_FLOAT;
}else if (b_type == 'i') {
size[1] = partlen/sizeof(int64_t);
//Hopefully this is 64 bits; the HDF5 manual is not clear.
dtype = H5T_NATIVE_LLONG;
}
else{
return -1000;
}
if (size[1] > 1) {
rank = 2;
}
/* I don't totally understand why the below works (it is not clear to me from the documentation).
* I gleaned it from a posting to the HDF5 mailing list and a related stack overflow thread here:
* http://stackoverflow.com/questions/24883461/hdf5-updating-a-cell-in-a-table-of-integers
* http://lists.hdfgroup.org/pipermail/hdf-forum_lists.hdfgroup.org/2014-July/007966.html
* The important thing seems to be that we have a dataspace for the whole array and create a hyperslab on that dataspace.
* Then we need another dataspace with the size of the stuff we want to write.*/
//Make space in memory for the whole array
//Create a hyperslab that we will write to
size[0] = npart[type];
hid_t full_space_id = H5Screate_simple(rank, size, NULL);
//If this is the first write, create the dataset
if (begin==0) {
H5Dcreate2(group,BlockName.c_str(),dtype, full_space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
}
hid_t dset = H5Dopen2(group,BlockName.c_str(),H5P_DEFAULT);
if (dset < 0)
return dset;
size[0] = np_write;
hid_t space_id = H5Screate_simple(rank, size, NULL);
hsize_t begins[2]={begin,0};
//Select the hyperslab of elements we are about to write to
H5Sselect_hyperslab(full_space_id, H5S_SELECT_SET, begins, NULL, size, NULL);
/* Write to the dataset */
herr = H5Dwrite(dset, dtype, space_id, full_space_id, H5P_DEFAULT, data);
H5Dclose(dset);
H5Sclose(space_id);
H5Sclose(full_space_id);
H5Gclose(group);
H5Fclose(handle);
if (herr < 0)
return herr;
return np_write;
}
开发者ID:sbird,项目名称:GadgetReader,代码行数:59,代码来源:gadgetwritehdf.cpp
示例17: H5Dopen2
void H5Dataset::init()
{
dataset = H5Dopen2(getParent().getH5Id(), name.c_str(), H5P_DEFAULT);
if (dataset < 0)
{
throw H5Exception(__LINE__, __FILE__, _("Cannot open the given dataset %s."), name.c_str());
}
}
开发者ID:ASP1234,项目名称:Scilabv5.5.2,代码行数:8,代码来源:H5Dataset.cpp
示例18: test_rowmaj
/*-------------------------------------------------------------------------
* Function: test_rowmaj
*
* Purpose: Reads the entire dataset using the specified size-squared
* I/O requests in row major order.
*
* Return: Efficiency: data requested divided by data actually read.
*
* Programmer: Robb Matzke
* Thursday, May 14, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static double
test_rowmaj (int op, size_t cache_size, size_t io_size)
{
hid_t file, dset, mem_space, file_space;
signed char *buf = calloc (1, (size_t)(SQUARE(io_size)));
hsize_t i, j, hs_size[2];
hsize_t hs_offset[2];
int mdc_nelmts;
size_t rdcc_nelmts;
double w0;
H5Pget_cache (fapl_g, &mdc_nelmts, &rdcc_nelmts, NULL, &w0);
#ifdef RM_W0
w0 = RM_W0;
#endif
#ifdef RM_NRDCC
rdcc_nelmts = RM_NRDCC;
#endif
H5Pset_cache (fapl_g, mdc_nelmts, rdcc_nelmts,
cache_size*SQUARE (CH_SIZE), w0);
file = H5Fopen(FILE_NAME, H5F_ACC_RDWR, fapl_g);
dset = H5Dopen2(file, "dset", H5P_DEFAULT);
file_space = H5Dget_space(dset);
nio_g = 0;
for (i=0; i<CH_SIZE*DS_SIZE; i+=io_size) {
#if 0
fprintf (stderr, "%5d\b\b\b\b\b", (int)i);
fflush (stderr);
#endif
for (j=0; j<CH_SIZE*DS_SIZE; j+=io_size) {
hs_offset[0] = i;
hs_size[0] = MIN (io_size, CH_SIZE*DS_SIZE-i);
hs_offset[1] = j;
hs_size[1] = MIN (io_size, CH_SIZE*DS_SIZE-j);
mem_space = H5Screate_simple (2, hs_size, hs_size);
H5Sselect_hyperslab (file_space, H5S_SELECT_SET, hs_offset,
NULL, hs_size, NULL);
if (READ==op) {
H5Dread (dset, H5T_NATIVE_SCHAR, mem_space, file_space,
H5P_DEFAULT, buf);
} else {
H5Dwrite (dset, H5T_NATIVE_SCHAR, mem_space, file_space,
H5P_DEFAULT, buf);
}
H5Sclose (mem_space);
}
}
free (buf);
H5Sclose (file_space);
H5Dclose (dset);
H5Fclose (file);
return (double)SQUARE(CH_SIZE*DS_SIZE)/(double)nio_g;
}
开发者ID:ArielleBassanelli,项目名称:gempak,代码行数:72,代码来源:chunk.c
示例19: test_foreign_scaleattached
static int test_foreign_scaleattached(const char *filename)
{
herr_t ret_value = FAIL;
hid_t fid = -1;
hid_t did = -1;
hid_t dsid = -1;
TESTING2("test_foreign_scaleattached");
if((fid = H5Fopen(filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
goto out;
if((did = H5Dopen2(fid, "/dset_al", H5P_DEFAULT)) >= 0) {
if((dsid = H5Dopen2(fid, "/ds_4_al", H5P_DEFAULT)) >= 0) {
if(H5DSis_attached(did, dsid, 3) == 1) {
ret_value = SUCCEED;
}
if(H5Dclose(dsid) < 0)
goto out;
}
if(H5Dclose(did) < 0)
goto out;
}
else
goto out;
if(ret_value == FAIL)
goto out;
PASSED();
H5Fclose(fid);
return 0;
out:
H5E_BEGIN_TRY {
H5Dclose(did);
H5Fclose(fid);
} H5E_END_TRY;
H5_FAILED();
return FAIL;
}
开发者ID:herr-biber,项目名称:hdf5,代码行数:44,代码来源:gen_test_ds.c
示例20: test_diag
/*-------------------------------------------------------------------------
* Function: test_diag
*
* Purpose: Reads windows diagonally across the dataset. Each window is
* offset from the previous window by OFFSET in the x and y
* directions. The reading ends after the (k,k) value is read
* where k is the maximum index in the dataset.
*
* Return: Efficiency.
*
* Programmer: Robb Matzke
* Friday, May 15, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static double
test_diag (int op, size_t cache_size, size_t io_size, size_t offset)
{
hid_t file, dset, mem_space, file_space;
hsize_t i, hs_size[2];
hsize_t nio = 0;
hsize_t hs_offset[2];
signed char *buf = calloc (1, (size_t)(SQUARE (io_size)));
int mdc_nelmts;
size_t rdcc_nelmts;
double w0;
H5Pget_cache (fapl_g, &mdc_nelmts, &rdcc_nelmts, NULL, &w0);
#ifdef DIAG_W0
w0 = DIAG_W0;
#endif
#ifdef DIAG_NRDCC
rdcc_nelmts = DIAG_NRDCC;
#endif
H5Pset_cache (fapl_g, mdc_nelmts, rdcc_nelmts,
cache_size*SQUARE (CH_SIZE), w0);
file = H5Fopen(FILE_NAME, H5F_ACC_RDWR, fapl_g);
dset = H5Dopen2(file, "dset", H5P_DEFAULT);
file_space = H5Dget_space(dset);
nio_g = 0;
for (i=0, hs_size[0]=io_size; hs_size[0]==io_size; i+=offset) {
hs_offset[0] = hs_offset[1] = i;
hs_size[0] = hs_size[1] = MIN (io_size, CH_SIZE*DS_SIZE-i);
mem_space = H5Screate_simple (2, hs_size, hs_size);
H5Sselect_hyperslab (file_space, H5S_SELECT_SET, hs_offset, NULL,
hs_size, NULL);
if (READ==op) {
H5Dread (dset, H5T_NATIVE_SCHAR, mem_space, file_space,
H5P_DEFAULT, buf);
} else {
H5Dwrite (dset, H5T_NATIVE_SCHAR, mem_space, file_space,
H5P_DEFAULT, buf);
}
H5Sclose (mem_space);
nio += hs_size[0]*hs_size[1];
if (i>0) nio -= SQUARE (io_size-offset);
}
free (buf);
H5Sclose (file_space);
H5Dclose (dset);
H5Fclose (file);
/*
* The extra cast in the following statement is a bug workaround for the
* Win32 version 5.0 compiler.
* 1998-11-06 ptl
*/
return (double)(hssize_t)nio/(hssize_t)nio_g;
}
开发者ID:ArielleBassanelli,项目名称:gempak,代码行数:73,代码来源:chunk.c
注:本文中的H5Dopen2函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论