本文整理汇总了C++中H5Gopen函数的典型用法代码示例。如果您正苦于以下问题:C++ H5Gopen函数的具体用法?C++ H5Gopen怎么用?C++ H5Gopen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了H5Gopen函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: H5Fopen
void CheMPS2::DMRG::loadMPS(const std::string name, TensorT ** MPSlocation, bool * isConverged){
//The hdf5 file
hid_t file_id = H5Fopen(name.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
//Whether the MPS was converged or not
hid_t group_id = H5Gopen(file_id, "/Convergence", H5P_DEFAULT);
hid_t dataset_id = H5Dopen(group_id, "Converged_yn", H5P_DEFAULT);
int toRead;
H5Dread(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &toRead);
isConverged[0] = (toRead==0)?false:true;
H5Dclose(dataset_id);
H5Gclose(group_id);
//The MPS
for (int site=0; site<L; site++){
std::stringstream sstream;
sstream << "/MPS_" << site;
hid_t group_id3 = H5Gopen(file_id, sstream.str().c_str(), H5P_DEFAULT);
hid_t dataset_id3 = H5Dopen(group_id3, "Values", H5P_DEFAULT);
H5Dread(dataset_id3, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, MPSlocation[site]->gStorage());
H5Dclose(dataset_id3);
H5Gclose(group_id3);
}
H5Fclose(file_id);
}
开发者ID:SebWouters,项目名称:CheMPS2,代码行数:35,代码来源:DMRGmpsio.cpp
示例2: out_dir_
H5Converter::H5Converter(const std::string& h5_fname, const std::string& out_dir) :
out_dir_(out_dir)
{
file_id_ = H5Fopen(h5_fname.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
root_ = H5Gopen(file_id_, "/", H5P_DEFAULT);
aux_ = H5Gopen(file_id_, "/aux", H5P_DEFAULT);
// <aux info>
// read target ids
read_dataset(aux_, "ids", targ_ids_);
std::cerr << "[h5dump] number of targets: " << targ_ids_.size() <<
std::endl;
n_targs_ = targ_ids_.size();
read_dataset(aux_, "lengths", lengths_);
assert( n_targs_ == lengths_.size() );
read_dataset(aux_, "eff_lengths", eff_lengths_);
assert( n_targs_ == eff_lengths_.size() );
// read bootstrap info
std::vector<int> n_bs_vec;
read_dataset(aux_, "num_bootstrap", n_bs_vec);
n_bs_ = n_bs_vec[0];
std::cerr << "[h5dump] number of bootstraps: " << n_bs_ << std::endl;
// </aux info>
if (n_bs_ > 0) {
bs_ = H5Gopen(file_id_, "/bootstrap", H5P_DEFAULT);
}
std::vector<std::string> tmp;
read_dataset(aux_, "kallisto_version", tmp);
kal_version_ = tmp[0];
tmp.clear();
std::cerr << "[h5dump] kallisto version: " << kal_version_ << std::endl;
std::vector<int> idx_version;
read_dataset(aux_, "index_version", idx_version);
idx_version_ = static_cast<size_t>(idx_version[0]);
std::cerr << "[h5dump] index version: " << idx_version_ << std::endl;
read_dataset(aux_, "start_time", tmp);
start_time_ = tmp[0];
tmp.clear();
std::cerr << "[h5dump] start time: " << start_time_ << std::endl;
read_dataset(aux_, "call", tmp);
call_ = tmp[0];
tmp.clear();
std::cerr << "[h5dump] shell call: " << call_ << std::endl;
alpha_buf_.resize( n_targs_, 0.0 );
assert( n_targs_ == alpha_buf_.size() );
tpm_buf_.resize( n_targs_, 0.0 );
assert( n_targs_ == tpm_buf_.size() );
}
开发者ID:FriendlyNeighborhoodNematode,项目名称:kallisto,代码行数:59,代码来源:H5Writer.cpp
示例3: test_misc
/*-------------------------------------------------------------------------
* Function: test_misc
*
* Purpose: Test miscellaneous group stuff.
*
* Return: Success: 0
*
* Failure: number of errors
*
* Programmer: Robb Matzke
* Tuesday, November 24, 1998
*
* Modifications:
* Robb Matzke, 2002-03-28
* File is opened by parent instead of here.
*-------------------------------------------------------------------------
*/
static int
test_misc(hid_t file)
{
hid_t g1=-1, g2=-1, g3=-1;
char comment[64];
/* Test current working groups */
TESTING("miscellaneous group tests");
/* Create initial groups for testing, then close */
if ((g1=H5Gcreate(file, "test_1a", 0))<0) goto error;
if ((g2=H5Gcreate(g1, "sub_1", 0))<0) goto error;
if ((g3=H5Gcreate(file, "test_1b", 0))<0) goto error;
if (H5Gset_comment(g3, ".", "hello world")<0) goto error;
if (H5Gclose(g1)<0) goto error;
if (H5Gclose(g2)<0) goto error;
if (H5Gclose(g3)<0) goto error;
/* Open all groups with absolute names to check for exsistence */
if ((g1=H5Gopen(file, "/test_1a"))<0) goto error;
if ((g2=H5Gopen(file, "/test_1a/sub_1"))<0) goto error;
if ((g3=H5Gopen(file, "/test_1b"))<0) goto error;
if (H5Gget_comment(g3, "././.", sizeof comment, comment)<0) goto error;
if (strcmp(comment, "hello world")) {
H5_FAILED();
puts(" Read the wrong comment string from the group.");
printf(" got: \"%s\"\n ans: \"hello world\"\n", comment);
goto error;
}
if (H5Gclose(g1)<0) goto error;
if (H5Gclose(g2)<0) goto error;
if (H5Gclose(g3)<0) goto error;
/* Check that creating groups with no-op names isn't allowed */
H5E_BEGIN_TRY {
g1=H5Gcreate(file, "/", 0);
} H5E_END_TRY
if(g1 >= 0) goto error;
H5E_BEGIN_TRY {
g1=H5Gcreate(file, "./././", 0);
} H5E_END_TRY
if(g1 >= 0) goto error;
PASSED();
return 0;
error:
H5E_BEGIN_TRY {
H5Gclose(g1);
H5Gclose(g2);
H5Gclose(g3);
} H5E_END_TRY;
return 1;
}
开发者ID:MattNapsAlot,项目名称:rHDF5,代码行数:72,代码来源:stab.c
示例4: _extract_all_tasks
static void _extract_all_tasks(FILE *fp, hid_t gid_step, hid_t gid_nodes,
int nnodes, int stepx)
{
hid_t gid_tasks, gid_task = 0, gid_node = -1, gid_level = -1;
H5G_info_t group_info;
int ntasks, itx, len, task_id;
char task_name[MAX_GROUP_NAME+1];
char* node_name;
char buf[MAX_GROUP_NAME+1];
bool hd = true;
gid_tasks = get_group(gid_step, GRP_TASKS);
if (gid_tasks < 0)
fatal("No tasks in step %d", stepx);
H5Gget_info(gid_tasks, &group_info);
ntasks = (int) group_info.nlinks;
if (ntasks <= 0)
fatal("No tasks in step %d", stepx);
for (itx = 0; itx<ntasks; itx++) {
// Get the name of the group.
len = H5Lget_name_by_idx(gid_tasks, ".", H5_INDEX_NAME,
H5_ITER_INC, itx, buf, MAX_GROUP_NAME,
H5P_DEFAULT);
if ((len > 0) && (len < MAX_GROUP_NAME)) {
gid_task = H5Gopen(gid_tasks, buf, H5P_DEFAULT);
if (gid_task < 0)
fatal("Failed to open %s", buf);
} else
fatal("Illegal task name %s",buf);
task_id = get_int_attribute(gid_task, ATTR_TASKID);
node_name = get_string_attribute(gid_task, ATTR_NODENAME);
sprintf(task_name,"%s_%d", GRP_TASK, task_id);
gid_node = H5Gopen(gid_nodes, node_name, H5P_DEFAULT);
if (gid_node < 0)
fatal("Failed to open %s for Task_%d",
node_name, task_id);
gid_level = get_group(gid_node, GRP_SAMPLES);
if (gid_level < 0)
fatal("Failed to open group %s for node=%s task=%d",
GRP_SAMPLES,node_name, task_id);
_extract_series(fp, stepx, hd, gid_level, node_name, task_name);
hd = false;
xfree(node_name);
H5Gclose(gid_level);
H5Gclose(gid_node);
H5Gclose(gid_task);
}
H5Gclose(gid_tasks);
}
开发者ID:FredHutch,项目名称:slurm,代码行数:52,代码来源:sh5util.c
示例5: _merge_node_step_data
static void _merge_node_step_data(hid_t fid_job, char* file_name, int nodeIndex,
char* node_name, hid_t jgid_nodes,
hid_t jgid_tasks)
{
hid_t fid_nodestep, jgid_node, nsgid_root, nsgid_node;
char *start_time;
char group_name[MAX_GROUP_NAME+1];
jgid_node = H5Gcreate(jgid_nodes, node_name,
H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
if (jgid_node < 0) {
error("Failed to create group %s",node_name);
return;
}
put_string_attribute(jgid_node, ATTR_NODENAME, node_name);
// Process node step file
// Open the file and the node group.
fid_nodestep = H5Fopen(file_name, H5F_ACC_RDONLY, H5P_DEFAULT);
if (fid_nodestep < 0) {
H5Gclose(jgid_node);
error("Failed to open %s",file_name);
return;
}
nsgid_root = H5Gopen(fid_nodestep,"/", H5P_DEFAULT);
sprintf(group_name, "/%s_%s", GRP_NODE, node_name);
nsgid_node = H5Gopen(nsgid_root, group_name, H5P_DEFAULT);
if (nsgid_node < 0) {
H5Gclose(fid_nodestep);
H5Gclose(jgid_node);
error("Failed to open node group");
return;;
}
start_time = get_string_attribute(nsgid_node,ATTR_STARTTIME);
if (start_time == NULL) {
info("No %s attribute", ATTR_STARTTIME);
} else {
put_string_attribute(jgid_node, ATTR_STARTTIME, start_time);
xfree(start_time);
}
_merge_node_totals(jgid_node, nsgid_node);
_merge_task_totals(jgid_tasks, nsgid_node, node_name);
_merge_series_data(jgid_tasks, jgid_node, nsgid_node);
H5Gclose(nsgid_node);
H5Fclose(fid_nodestep);
H5Gclose(jgid_node);
if (!params.keepfiles)
remove(file_name);
return;
}
开发者ID:jsollom,项目名称:slurm,代码行数:51,代码来源:sh5util.c
示例6: read_new
/*-------------------------------------------------------------------------
* Function: read_new
*
* Purpose: Test reading a file with "new style" (compact) groups
*
* Return: Success: 0
*
* Failure: -1
*
* Programmer: Quincey Koziol
* Monday, October 24, 2005
*
*-------------------------------------------------------------------------
*/
static int
read_new(hid_t fapl)
{
hid_t fid = (-1); /* File ID */
hid_t gid = (-1); /* Group ID */
char *srcdir = HDgetenv("srcdir"); /*where the src code is located*/
char filename[512]=""; /* test file name */
TESTING("reading new groups");
/* Generate correct name for test file by prepending the source path */
if(srcdir && ((HDstrlen(srcdir) + HDstrlen(FILE_NEW_GROUPS) + 1) < sizeof(filename))) {
HDstrcpy(filename, srcdir);
HDstrcat(filename, "/");
}
HDstrcat(filename, FILE_NEW_GROUPS);
/* Open file */
if((fid = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR;
/* Attempt to open root group */
if((gid = H5Gopen(fid, "/")) < 0) TEST_ERROR;
/* Attempt to open new "empty" group (should fail) */
H5E_BEGIN_TRY {
if(H5Gopen(gid, "empty") >= 0) TEST_ERROR;
} H5E_END_TRY;
/* Attempt to open new group with link messages (should fail) */
H5E_BEGIN_TRY {
if(H5Gopen(gid, "links") >= 0) TEST_ERROR;
} H5E_END_TRY;
/* Close root group */
if(H5Gclose(gid) < 0) TEST_ERROR;
/* Close first file */
if(H5Fclose(fid)<0) TEST_ERROR;
PASSED();
return 0;
error:
H5E_BEGIN_TRY {
H5Gclose(gid);
H5Fclose(fid);
} H5E_END_TRY;
return 1;
} /* end read_new() */
开发者ID:MattNapsAlot,项目名称:rHDF5,代码行数:63,代码来源:stab.c
示例7: fast5_get_channel_params
fast5_raw_scaling fast5_get_channel_params(fast5_file& fh, const std::string& read_id)
{
// from scrappie
fast5_raw_scaling scaling = { NAN, NAN, NAN, NAN };
std::string scaling_path = fh.is_multi_fast5 ? "/read_" + read_id + "/channel_id"
: "/UniqueGlobalKey/channel_id";
hid_t scaling_group = H5Gopen(fh.hdf5_file, scaling_path.c_str(), H5P_DEFAULT);
if (scaling_group < 0) {
#ifdef DEBUG_FAST5_IO
fprintf(stderr, "Failed to open group %s\n", scaling_path.c_str());
#endif
return scaling;
}
scaling.digitisation = fast5_read_float_attribute(scaling_group, "digitisation");
scaling.offset = fast5_read_float_attribute(scaling_group, "offset");
scaling.range = fast5_read_float_attribute(scaling_group, "range");
scaling.sample_rate = fast5_read_float_attribute(scaling_group, "sampling_rate");
H5Gclose(scaling_group);
return scaling;
}
开发者ID:jts,项目名称:nanopolish,代码行数:25,代码来源:nanopolish_fast5_io.cpp
示例8: PYTABLE_open_group
/*+++++++++++++++++++++++++
.IDENTifer PYTABLE_open_group
.PURPOSE Open/Create a group in an exsisting HDF5-file
.INPUT/OUTPUT
call as grpID = PYTABLE_open_group( locID, name, sz_hint );
input:
hid_t locID : HDF5 object id
char name[] : name of the group
.RETURNS A negative value is returned on failure.
.COMMENTS none
-------------------------*/
hid_t PYTABLE_open_group( hid_t locID, const char *name )
{
hid_t grpID;
/*
* check if the group exists, if not create it
*/
H5E_BEGIN_TRY {
if ( (grpID = H5Gopen( locID, name, H5P_DEFAULT )) < 0 ) {
grpID = H5Gcreate( locID, name,
H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT );
(void) H5LTset_attribute_string( locID, name, "CLASS",
PY_GROUP_CLASS );
(void) H5LTset_attribute_string( locID, name,
"PYTABLES_FORMAT_VERSION",
PY_FORMAT_VERSION );
(void) H5LTset_attribute_string( locID, name, "TITLE",
name );
(void) H5LTset_attribute_string( locID, name, "VERSION",
PY_GROUP_VERSION );
}
} H5E_END_TRY;
/*
* return id of the group
*/
return grpID;
}
开发者ID:rmvanhees,项目名称:nadc_tools,代码行数:39,代码来源:nadc_pytable_api.c
示例9: foreach
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void DataContainer::ReadDataContainerStructure(hid_t dcArrayGroupId, DataContainerArrayProxy& proxy, QString h5InternalPath)
{
QList<QString> dataContainers;
QH5Utilities::getGroupObjects(dcArrayGroupId, H5Utilities::H5Support_GROUP, dataContainers);
foreach(QString dataContainerName, dataContainers)
{
if(__SHOW_DEBUG_MSG__)
{
std::cout << "Data Container:" << dataContainerName.toStdString() << std::endl;
}
hid_t containerGid = H5Gopen(dcArrayGroupId, dataContainerName.toLatin1().constData(), H5P_DEFAULT);
if (containerGid < 0)
{
continue;
}
HDF5ScopedGroupSentinel sentinel(&containerGid, false);
DataContainerProxy dcProxy(dataContainerName);
dcProxy.name = dataContainerName;
dcProxy.flag = Qt::Checked;
QString h5Path = h5InternalPath + "/" + dataContainerName;
// Read the Attribute Matricies for this Data Container
AttributeMatrix::ReadAttributeMatrixStructure(containerGid, dcProxy, h5Path);
// Insert the DataContainerProxy proxy into the DataContainerArrayProxy
proxy.dataContainers.insert(dcProxy.name, dcProxy);
}
}
开发者ID:ravishivaraman,项目名称:DREAM3D,代码行数:31,代码来源:DataContainer.cpp
示例10: get_group
extern hid_t get_group(hid_t parent, const char *name)
{
char buf[MAX_GROUP_NAME];
hsize_t nobj;
hid_t gid;
int i, len;
H5G_info_t group_info;
if (parent < 0) {
debug3("PROFILE: parent is not HDF5 object");
return -1;
}
H5Gget_info(parent, &group_info);
nobj = group_info.nlinks;
for (i = 0; (nobj>0) && (i<nobj); i++) {
// Get the name of the group.
len = H5Lget_name_by_idx(parent, ".", H5_INDEX_NAME,
H5_ITER_INC, i, buf, MAX_GROUP_NAME,
H5P_DEFAULT);
if ((len > 0) && (len < MAX_GROUP_NAME)) {
if (strcmp(buf, name) == 0) {
gid = H5Gopen(parent, name, H5P_DEFAULT);
if (gid < 0)
error("PROFILE: Failed to open %s",
name);
return gid;
}
}
}
return -1;
}
开发者ID:diorsman,项目名称:slurm,代码行数:32,代码来源:hdf5_api.c
示例11: copyToBuffer
void MultiChain::record() {
//h_config = H5Gopen(h_file,"MultiChain");
typedef Bead::RealType PosType;
typedef Bead::Buffer_t Buffer_t;
Buffer_t chain_buffer,bead_buffer;
(*(this->begin()))->registerData(bead_buffer);
chain_buffer.rewind();
copyToBuffer(chain_buffer);
HDFAttribIO<Buffer_t> mcout(chain_buffer);
mcout.overwrite(h_config,"state");
std::deque<Bead*>::iterator bead_it(this->begin());
std::deque<Bead*>::iterator bead_end(this->end());
//create the group and increment counter
char GrpName[128];
int ibead=0;
while(bead_it != bead_end) {
sprintf(GrpName,"bead%04d",ibead);
hid_t bead_id = H5Gopen(h_config,GrpName);
bead_buffer.rewind();
Bead& bead(**bead_it);
bead.copyToBuffer(bead_buffer);
HDFAttribIO<Buffer_t> bout(bead_buffer);
bout.overwrite(bead_id,"state");
H5Gclose(bead_id);
++bead_it;
++ibead;
}
}
开发者ID:digideskio,项目名称:qmcpack,代码行数:32,代码来源:MultiChain.cpp
示例12: H5Lexists_safe
int H5Lexists_safe(hid_t base, char *path)
// -----------------------------------------------------------------------------
// The HDF5 specification only allows H5Lexists to be called on an immediate
// child of the current object. However, you may wish to see whether a whole
// relative path exists, returning false if any of the intermediate links are
// not present. This function does that.
// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5L.html#Link-Exists
// -----------------------------------------------------------------------------
{
hid_t last = base, next;
char *pch;
char pathc[2048];
strcpy(pathc, path);
pch = strtok(pathc, "/");
while (pch != NULL) {
int exists = H5Lexists(last, pch, H5P_DEFAULT);
if (!exists) {
if (last != base) H5Gclose(last);
return 0;
}
else {
next = H5Gopen(last, pch, H5P_DEFAULT);
if (last != base) H5Gclose(last);
last = next;
}
pch = strtok(NULL, "/");
}
if (last != base) H5Gclose(last);
return 1;
}
开发者ID:geoffryan,项目名称:calvis,代码行数:30,代码来源:hist.c
示例13: scan_for_max_id
static int
scan_for_max_id( FileHandle* file_ptr, mhdf_Status* status )
{
hid_t group_id;
herr_t rval;
/* Check for new format, with max_id as attrib of root group */
#if defined(H5Gopen_vers) && H5Gopen_vers > 1
group_id = H5Gopen2( file_ptr->hdf_handle, ROOT_GROUP, H5P_DEFAULT );
#else
group_id = H5Gopen( file_ptr->hdf_handle, ROOT_GROUP );
#endif
if (group_id < 0)
{
mhdf_setFail( status, "Internal error - invalid file.");
return 0;
}
if (mhdf_read_scalar_attrib( group_id, MAX_ID_ATTRIB,
H5T_NATIVE_ULONG, &file_ptr->max_id,
status ))
{
H5Gclose( group_id );
return 1;
}
/* Didn't find it, scan the elements group */
rval = H5Giterate( group_id, ELEMENT_GROUP_NAME, 0, &max_id_iter, &file_ptr->max_id );
if (rval)
{
H5Gclose( group_id );
mhdf_setFail( status, "Internal error -- invalid file." );
return 0;
}
/* Check node table too */
rval = get_max_id( group_id, NODE_GROUP_NAME, "coordinates", (unsigned long*)(&file_ptr->max_id) );
if (rval)
{
H5Gclose( group_id );
mhdf_setFail( status, "Internal error -- invalid file." );
return 0;
}
/* Check set table, if it exists */
rval = mhdf_is_in_group( group_id, SET_GROUP_NAME, status );
if (rval < 1)
{
H5Gclose( group_id );
return !rval;
}
rval = get_max_id( group_id, SET_GROUP_NAME, SET_META_NAME, (unsigned long*)(&file_ptr->max_id) );
H5Gclose( group_id );
if (rval)
{
mhdf_setFail( status, "Internal error -- invalid file." );
return 0;
}
return 1;
}
开发者ID:chrismullins,项目名称:moab,代码行数:60,代码来源:file.c
示例14: h5_value_doubles
void h5_value_doubles(hid_t file_id, char *group, char *name, double **values,
int *numValues)
{
int kk;
hid_t group_id = H5Gopen(file_id, group, H5P_DEFAULT);
hid_t data_id = H5Dopen(group_id, name, H5P_DEFAULT);
hid_t data_space = H5Dget_space(data_id);
int rank = H5Sget_simple_extent_ndims(data_space);
hsize_t dims[H5S_MAX_RANK], maxdim[H5S_MAX_RANK];
H5Sget_simple_extent_dims(data_space, dims, maxdim);
hid_t data_type = H5Dget_type(data_id);
H5T_class_t data_class = H5Tget_native_type(data_type, H5T_DIR_DEFAULT);
size_t data_size = H5Tget_size(data_class);
hsize_t elements = 1;
for (kk=0; kk<rank; kk++)
elements *= dims[kk];
void *buf = (void *) MALLOC((size_t)(elements*data_size));
H5Dread(data_id, data_class, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf);
*values = buf;
*numValues = elements;
H5Tclose(data_type);
H5Tclose(data_class);
H5Sclose(data_space);
H5Dclose(data_id);
H5Gclose(group_id);
}
开发者ID:khogenso,项目名称:ASF_MapReady,代码行数:26,代码来源:measures_hdf2csv.c
示例15: F77_FUNC_
/* write eigen value and eigen vector for (ibnd, ispin) */
void F77_FUNC_(pwhdf_write_band,PWHDF_WRITE_BAND)(const int* ibnd,
const int* ispin, const double* e,
const double* eigv, const int* ngtot)
{
char spinname[16];
sprintf(spinname,"band%i/spin%i",(*ibnd)-1,(*ispin)-1);
hid_t h_spin = H5Gopen(h_twist,spinname);
hsize_t dim=1;
hid_t dataspace= H5Screate_simple(1, &dim, NULL);
hid_t dataset= H5Dcreate(h_spin, "eigenvalue", H5T_NATIVE_DOUBLE, dataspace, H5P_DEFAULT);
hid_t ret = H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT,e);
H5Sclose(dataspace);
H5Dclose(dataset);
hsize_t dims[2];
dims[0] = *ngtot;
dims[1] = 2;
dataspace = H5Screate_simple(2, dims, NULL);
dataset = H5Dcreate(h_spin, "eigenvector", H5T_NATIVE_DOUBLE, dataspace, H5P_DEFAULT);
ret = H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT,eigv);
H5Sclose(dataspace);
H5Dclose(dataset);
H5Gclose(h_spin);
}
开发者ID:digideskio,项目名称:qmcpack,代码行数:26,代码来源:pw_hdf5.c
示例16: cxi_open_data
CXI_Data * cxi_open_data(CXI_Data_Reference * ref){
cxi_debug("opening data");
char buffer[1024];
if(!ref){
return NULL;
}
CXI_Data * data = calloc(sizeof(CXI_Data),1);
if(!data){
return NULL;
}
data->handle = H5Gopen(ref->parent_handle,ref->group_name,H5P_DEFAULT);
if(data->handle < 0){
free(data);
return NULL;
}
ref->data = data;
if(H5Lexists(data->handle,"data",H5P_DEFAULT)){
data->data = calloc(sizeof(CXI_Dataset_Reference),1);
data->data->parent_handle = data->handle;
data->data->group_name = malloc(sizeof(char)*(strlen(buffer)+1));
strcpy(data->data->group_name,"data");
}
if(H5Lexists(data->handle,"errors",H5P_DEFAULT)){
data->errors = calloc(sizeof(CXI_Dataset_Reference),1);
data->errors->parent_handle = data->handle;
data->errors->group_name = malloc(sizeof(char)*(strlen(buffer)+1));
strcpy(data->errors->group_name,"errors");
}
return data;
}
开发者ID:cxidb,项目名称:libcxi,代码行数:32,代码来源:cxi.c
示例17: _series_data
static int _series_data(void)
{
FILE *fp;
bool hd = false;
hid_t fid_job;
hid_t jgid_root;
hid_t jgid_step;
int nsteps;
int stepx;
char jgrp_step_name[MAX_GROUP_NAME + 1];
fp = fopen(params.output, "w");
if (fp == NULL) {
error("Failed open file %s -- %m", params.output);
return -1;
}
fid_job = H5Fopen(params.input, H5F_ACC_RDONLY, H5P_DEFAULT);
if (fid_job < 0) {
fclose(fp);
error("Failed to open %s", params.input);
return -1;
}
jgid_root = H5Gopen(fid_job, "/", H5P_DEFAULT);
if (jgid_root < 0) {
fclose(fp);
H5Fclose(fid_job);
error("Failed to open root");
return -1;
}
nsteps = get_int_attribute(jgid_root, ATTR_NSTEPS);
for (stepx = 0; stepx < nsteps; stepx++) {
if ((params.step_id != -1) && (stepx != params.step_id))
continue;
sprintf(jgrp_step_name, "%s_%d", GRP_STEP, stepx);
jgid_step = get_group(jgid_root, jgrp_step_name);
if (jgid_step < 0) {
error("Failed to open group %s", jgrp_step_name);
return -1;
}
if (strncmp(params.series,GRP_TASK,strlen(GRP_TASK)) == 0)
_get_all_task_series(fp,hd,jgid_step, stepx);
else
_get_all_node_series(fp,hd,jgid_step, stepx);
hd = true;
H5Gclose(jgid_step);
}
H5Gclose(jgid_root);
H5Fclose(fid_job);
fclose(fp);
return 0;
}
开发者ID:FredHutch,项目名称:slurm,代码行数:60,代码来源:sh5util.c
示例18: cxi_open_image
CXI_Image * cxi_open_image(CXI_Image_Reference * ref){
cxi_debug("opening image");
char buffer[1024];
if(!ref){
return NULL;
}
CXI_Image * image = calloc(sizeof(CXI_Image),1);
if(!image){
return NULL;
}
image->handle = H5Gopen(ref->parent_handle,ref->group_name,H5P_DEFAULT);
if(image->handle < 0){
free(image);
return NULL;
}
/* Search for Detector groups */
int n = find_max_suffix(image->handle, "detector");
image->detector_count = n;
image->detectors = calloc(sizeof(CXI_Detector_Reference *),n);
for(int i = 0;i<n;i++){
image->detectors[i] = calloc(sizeof(CXI_Detector_Reference),1);
sprintf(buffer,"detector_%d",i+1);
image->detectors[i]->parent_handle = image->handle;
image->detectors[i]->group_name = malloc(sizeof(char)*(strlen(buffer)+1));
strcpy(image->detectors[i]->group_name,buffer);
}
ref->image = image;
if(H5Lexists(image->handle,"data",H5P_DEFAULT)){
image->data = calloc(sizeof(CXI_Dataset_Reference),1);
image->data->parent_handle = image->handle;
image->data->group_name = malloc(sizeof(char)*(strlen(buffer)+1));
strcpy(image->data->group_name,"data");
}
if(H5Lexists(image->handle,"data_error",H5P_DEFAULT)){
image->data_error = calloc(sizeof(CXI_Dataset_Reference),1);
image->data_error->parent_handle = image->handle;
image->data_error->group_name = malloc(sizeof(char)*(strlen(buffer)+1));
strcpy(image->data_error->group_name,"data_error");
}
if(H5Lexists(image->handle,"mask",H5P_DEFAULT)){
image->mask = calloc(sizeof(CXI_Dataset_Reference),1);
image->mask->parent_handle = image->handle;
image->mask->group_name = malloc(sizeof(char)*(strlen(buffer)+1));
strcpy(image->mask->group_name,"mask");
}
// try_read_string(image->handle, "data_space",&image->data_space);
// try_read_string(image->handle, "data_type",&image->data_type);
image->dimensionality_valid = try_read_int(image->handle, "dimensionality",&image->dimensionality);
image->image_center_valid = try_read_float_array(image->handle, "image_center",image->image_center,3);
return image;
}
开发者ID:cxidb,项目名称:libcxi,代码行数:60,代码来源:cxi.c
示例19: cxi_open_attenuator
CXI_Attenuator * cxi_open_attenuator(CXI_Attenuator_Reference * ref){
cxi_debug("opening attenuator");
if(!ref){
return NULL;
}
CXI_Attenuator * attenuator = calloc(sizeof(CXI_Attenuator),1);
if(!attenuator){
return NULL;
}
attenuator->handle = H5Gopen(ref->parent_handle,ref->group_name,H5P_DEFAULT);
if(attenuator->handle < 0){
free(attenuator);
return NULL;
}
ref->attenuator = attenuator;
attenuator->distance_valid = try_read_float(attenuator->handle, "distance",&attenuator->distance);
attenuator->thickness_valid = try_read_float(attenuator->handle, "thickness",&attenuator->thickness);
attenuator->attenuator_transmission_valid = try_read_float(attenuator->handle, "attenuator_transmission",
&attenuator->attenuator_transmission);
try_read_string(attenuator->handle, "type",&attenuator->type);
return attenuator;
}
开发者ID:cxidb,项目名称:libcxi,代码行数:25,代码来源:cxi.c
示例20: main
int
main()
{
printf("\n*** Checking HDF5 file c0.nc.\n");
printf("*** Checking HDF5 objcts...");
{
hid_t fileid, grpid;
hsize_t num_obj, i;
char obj_name[MAX_NAME];
if ((fileid = H5Fopen(FILE_NAME, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) ERR;
if ((grpid = H5Gopen(fileid, "/")) < 0) ERR;
/* Find the variables. Read their metadata and attributes. */
if (H5Gget_num_objs(grpid, &num_obj) < 0) ERR;
for (i=0; i<num_obj; i++)
{
/* Get the class (i.e. group, dataset, etc.), and the name of
* the object. */
if (H5Gget_objtype_by_idx(grpid, i) < 0) ERR;
if (H5Gget_objname_by_idx(grpid, i, obj_name, MAX_NAME) < 0) ERR;
}
if (H5Gclose(grpid) < 0 ||
H5Fclose(fileid) < 0) ERR;
}
SUMMARIZE_ERR;
FINAL_RESULTS;
}
开发者ID:BJangeofan,项目名称:netcdf-c,代码行数:31,代码来源:tst_h_rdc0.c
注:本文中的H5Gopen函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论