本文整理汇总了C++中H5Gcreate2函数的典型用法代码示例。如果您正苦于以下问题:C++ H5Gcreate2函数的具体用法?C++ H5Gcreate2怎么用?C++ H5Gcreate2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了H5Gcreate2函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: main
int
main (void)
{
hid_t file; /* file handle */
hid_t grp_a, grp_b, grp_c; /* group handlers */
/*
* Create a new file using H5F_ACC_TRUNC access,
* default file creation properties, and default file
* access properties.
*/
file = H5Fcreate(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
/*
* Create groups in the file.
*/
grp_a = H5Gcreate2(file, "/a", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
grp_b = H5Gcreate2(grp_a, "b", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
grp_c = H5Gcreate2(grp_b, "c", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
H5Gclose(grp_a);
H5Gclose(grp_b);
H5Gclose(grp_c);
H5Fclose(file);
return 0;
}
开发者ID:OPENDAP,项目名称:hdf5_handler,代码行数:27,代码来源:d_group.c
示例2: main
int main(){
hid_t fprop;
hid_t fid;
hid_t vol_id = H5VL_memvol_init();
herr_t status;
hid_t g1, g2;
hid_t plist;
char name[1024];
fprop = H5Pcreate(H5P_FILE_ACCESS);
H5Pset_vol(fprop, vol_id, &fprop);
fid = H5Fcreate("test", H5F_ACC_TRUNC, H5P_DEFAULT, fprop);
H5VLget_plugin_name(fid, name, 1024);
printf ("Using VOL %s\n", name);
g1 = H5Gcreate2(fid, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
H5Gclose(g1);
g2 = H5Gcreate2(fid, "g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
g1 = H5Gcreate2(g2, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
H5Gclose(g1);
H5Gclose(g2);
// is this allowed?
//g3 = H5Gcreate2(fid, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
//H5Gclose(g3);
printf("Testing additional functions\n");
g1 = H5Gopen2(fid, "g1", H5P_DEFAULT );
plist = H5Gget_create_plist(g1);
H5G_info_t group_info;
H5Gget_info(g1, & group_info );
H5Gget_info_by_idx(fid, "g1", H5_INDEX_CRT_ORDER, H5_ITER_NATIVE, 0, & group_info, H5P_DEFAULT ) ;
H5Gget_info_by_idx(fid, "g1", H5_INDEX_NAME, H5_ITER_NATIVE, 0, & group_info, H5P_DEFAULT ) ;
H5Gget_info_by_name(fid, "g1", & group_info, H5P_DEFAULT);
H5Pclose(plist);
status = H5Gclose(g1);
g1 = H5Gopen2(fid, "g2", H5P_DEFAULT );
H5Gclose(g1);
//g1 = H5Gopen2(fid, "INVALID", H5P_DEFAULT );
//H5Gclose(g1);
g1 = H5Gcreate_anon( fid, H5P_DEFAULT, H5P_DEFAULT );
H5Gclose(g1);
H5Fclose(fid);
H5VL_memvol_finalize();
printf("Status: %d\n", status);
return 0;
}
开发者ID:ESiWACE,项目名称:ESD-Middleware,代码行数:58,代码来源:direct-group.c
示例3: test_creating_groups_using_plugins
/*-------------------------------------------------------------------------
* Function: test_creating_groups_using_plugins
*
* Purpose: Tests creating group with dynamically loaded filters
*
* Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
static herr_t
test_creating_groups_using_plugins(hid_t fid)
{
hid_t gcpl_id = -1;
hid_t gid = -1;
hid_t sub_gid = -1;
int i;
char subgroup_name[256];
TESTING("creating groups with filter plugin 4");
if ((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0)
TEST_ERROR;
/* Use a filter plugin for creating groups */
if (H5Pset_filter(gcpl_id, FILTER4_ID, H5Z_FLAG_MANDATORY, (size_t)0, NULL) < 0)
TEST_ERROR;
/* Create a group using this filter */
if ((gid = H5Gcreate2(fid, TOP_LEVEL_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0)
TEST_ERROR;
/* Create multiple groups under the top-level group */
for (i = 0; i < N_SUBGROUPS; i++) {
char *sp = subgroup_name;
sp += HDsprintf(subgroup_name, SUBGROUP_PREFIX);
HDsprintf(sp, "%d", i);
if ((sub_gid = H5Gcreate2(gid, subgroup_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
TEST_ERROR;
if (H5Gclose(sub_gid) < 0)
TEST_ERROR;
}
/* Close everything */
if (H5Gclose(gid) < 0)
TEST_ERROR;
if (H5Pclose(gcpl_id) < 0)
TEST_ERROR;
PASSED();
return SUCCEED;
error:
/* Clean up objects used for this test */
H5E_BEGIN_TRY {
H5Gclose(sub_gid);
H5Gclose(gid);
H5Pclose(gcpl_id);
} H5E_END_TRY
return FAIL;
} /* end test_creating_groups_using_plugins() */
开发者ID:Starlink,项目名称:hdf5,代码行数:64,代码来源:filter_plugin.c
示例4: main
int
main (void)
{
hid_t fid1=-1;
hid_t fid2=-1;
hid_t gid=-1;
char filename1[NAME_BUF_SIZE];
char filename2[NAME_BUF_SIZE];
/* Name the files differently depending on the endianness of this platform */
switch(H5Tget_order(H5T_NATIVE_INT))
{
case H5T_ORDER_LE:
strcpy(filename1, NAME_LE_1);
strcpy(filename2, NAME_LE_2);
break;
case H5T_ORDER_BE:
strcpy(filename1, NAME_BE_1);
strcpy(filename2, NAME_BE_2);
break;
default:
goto error;
}
/* Create the two files */
if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error;
if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error;
/* Create two groups in the second file */
if((gid = H5Gcreate2(fid2, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error;
if((H5Gclose(gid)) < 0) goto error;
if((gid = H5Gcreate2(fid2, "group/subgroup", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error;
if((H5Gclose(gid)) < 0) goto error;
/* Create an external link in the first file pointing to the group in the second file */
if(H5Lcreate_external(filename2, "group", fid1, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) goto error;
if((H5Fclose(fid1)) < 0) goto error;
if((H5Fclose(fid2)) < 0) goto error;
return 0;
error:
H5E_BEGIN_TRY {
H5Fclose(fid1);
H5Fclose(fid2);
H5Gclose(gid);
} H5E_END_TRY
return 1;
}
开发者ID:FilipeMaia,项目名称:hdf5,代码行数:51,代码来源:gen_udlinks.c
示例5: _hdf_create
/**
* Create an HDF5 file.
*/
static hid_t _hdf_create(const char *path, int cmode)
{
hid_t grp_id;
hid_t fd;
hid_t tmp_id;
hid_t hdf_gpid;
hid_t fpid;
fpid = H5Pcreate (H5P_FILE_ACCESS);
/*VF use all the features of new HDF5 1.8*/
H5Pset_libver_bounds (fpid, H5F_LIBVER_18, H5F_LIBVER_18);
H5E_BEGIN_TRY {
fd = H5Fcreate(path, cmode, H5P_DEFAULT, fpid);
} H5E_END_TRY;
if (fd < 0) {
/*TODO: report error properly*/
return MI_LOG_ERROR(MI2_MSG_CREATEFILE,path);
}
/* Create the default groups.
* Should we use a non-zero value for size_hint (parameter 3)???
*/
hdf_gpid = H5Pcreate (H5P_GROUP_CREATE);
H5Pset_attr_phase_change (hdf_gpid, 0, 0);
MI_CHECK_HDF_CALL_RET(grp_id = H5Gcreate2(fd, MI_ROOT_PATH , H5P_DEFAULT, hdf_gpid, H5P_DEFAULT),"H5Gcreate2")
MI_CHECK_HDF_CALL_RET(tmp_id = H5Gcreate2(grp_id, "dimensions", H5P_DEFAULT, hdf_gpid, H5P_DEFAULT),"H5Gcreate2")
H5Gclose(tmp_id);
MI_CHECK_HDF_CALL_RET(tmp_id = H5Gcreate2(grp_id, "info", H5P_DEFAULT, hdf_gpid, H5P_DEFAULT),"H5Gcreate2")
H5Gclose(tmp_id);
MI_CHECK_HDF_CALL_RET(tmp_id = H5Gcreate2(grp_id, "image", H5P_DEFAULT, hdf_gpid, H5P_DEFAULT),"H5Gcreate2")
H5Gclose(tmp_id);
MI_CHECK_HDF_CALL_RET(tmp_id = H5Gcreate2(grp_id, "image/0", H5P_DEFAULT, hdf_gpid, H5P_DEFAULT),"H5Gcreate2")
H5Pclose ( hdf_gpid );
H5Gclose(tmp_id);
H5Gclose(grp_id);
return fd;
}
开发者ID:bcdarwin,项目名称:libminc,代码行数:51,代码来源:volume.c
示例6: create_file
/*-------------------------------------------------------------------------
* Function: create_file
*
* Purpose: Creates file used in part 1 of the test
*
* Return: Success: 0
*
* Failure: 1
*
* Programmer: Leon Arber
* Sept. 26, 2006
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static hid_t
create_file(char* name, hid_t fapl)
{
hid_t file, dcpl, space, dset, groups, grp, plist;
hsize_t ds_size[2] = {100, 100};
hsize_t ch_size[2] = {5, 5};
hsize_t i, j;
if((file=H5Fcreate(name, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) goto error;
/* Create a chunked dataset */
if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error;
if(H5Pset_chunk(dcpl, 2, ch_size) < 0) goto error;
if((space = H5Screate_simple(2, ds_size, NULL)) < 0) goto error;
if((dset = H5Dcreate2(file, "dset", H5T_NATIVE_FLOAT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto error;
plist = H5Pcreate(H5P_DATASET_XFER);
H5Pset_dxpl_mpio(plist, H5FD_MPIO_COLLECTIVE);
/* Write some data */
for(i = 0; i < ds_size[0]; i++) {
/*
* The extra cast in the following statement is a bug workaround
* for the Win32 version 5.0 compiler.
* 1998-11-06 ptl
*/
for(j = 0; j < ds_size[1]; j++)
the_data[i][j] = (double)(hssize_t)i/(hssize_t)(j+1);
}
if(H5Dwrite(dset, H5T_NATIVE_DOUBLE, space, space, plist, the_data) < 0) goto error;
/* Create some groups */
if((groups = H5Gcreate2(file, "some_groups", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error;
for(i = 0; i < 100; i++) {
sprintf(name, "grp%02u", (unsigned)i);
if((grp = H5Gcreate2(groups, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error;
if(H5Gclose(grp) < 0) goto error;
}
return file;
error:
HD_exit(1);
}
开发者ID:Starlink,项目名称:hdf5,代码行数:64,代码来源:t_pflush1.c
示例7: GBaseWriteFile
GWriteHDFFile::GWriteHDFFile(std::string filename, std::valarray<uint32_t> npart_in, std::vector<block_info>* BlockNames, bool format_2, bool debug) : GBaseWriteFile(filename, npart_in), debug(debug)
{
//Create file
hid_t hdf_file = H5Fcreate(filename.c_str(),H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT);
if(hdf_file < 0){
throw std::ios_base::failure(std::string("Unable to create file: ")+filename);
}
//Create groups in the file
for(int i = 0; i < N_TYPE; i++){
if(npart_in[i] == 0)
continue;
snprintf(g_name[i], 20,"PartType%d",i);
hid_t group = H5Gcreate2(hdf_file,g_name[i],H5P_DEFAULT, H5P_DEFAULT,H5P_DEFAULT);
if (group < 0)
throw std::ios_base::failure(std::string("Unable to create group: ")+std::string(g_name[i]));
}
//Create metadata about datablocks: we only actually use partlen.
std::vector<block_info>::iterator it;
for(it=(*BlockNames).begin(); it<(*BlockNames).end(); ++it){
//Detect an integer type
if ((*it).partlen == sizeof(int64_t))
m_ints.insert((*it).name);
}
return;
}
开发者ID:sbird,项目名称:GadgetReader,代码行数:26,代码来源:gadgetwritehdf.cpp
示例8: LOG
void SGDSolver<Dtype>::SnapshotSolverStateToHDF5(
const string& model_filename) {
#ifdef USE_HDF5
string snapshot_filename =
Solver<Dtype>::SnapshotFilename(".solverstate.h5");
LOG(INFO) << "Snapshotting solver state to HDF5 file " << snapshot_filename;
hid_t file_hid = H5Fcreate(snapshot_filename.c_str(), H5F_ACC_TRUNC,
H5P_DEFAULT, H5P_DEFAULT);
CHECK_GE(file_hid, 0)
<< "Couldn't open " << snapshot_filename << " to save solver state.";
hdf5_save_int(file_hid, "iter", this->iter_);
hdf5_save_string(file_hid, "learned_net", model_filename);
hdf5_save_int(file_hid, "current_step", this->current_step_);
hid_t history_hid = H5Gcreate2(file_hid, "history", H5P_DEFAULT, H5P_DEFAULT,
H5P_DEFAULT);
CHECK_GE(history_hid, 0)
<< "Error saving solver state to " << snapshot_filename << ".";
for (int i = 0; i < history_.size(); ++i) {
ostringstream oss;
oss << i;
hdf5_save_nd_dataset<Dtype>(history_hid, oss.str(), *history_[i]);
}
H5Gclose(history_hid);
H5Fclose(file_hid);
#else
LOG(FATAL) << "SnapshotSolverStateToHDF5 requires hdf5;"
<< " compile with USE_HDF5.";
#endif // USE_HDF5
}
开发者ID:fossabot,项目名称:caffe,代码行数:29,代码来源:sgd_solver.cpp
示例9: PetscViewerHDF5OpenGroup
PetscErrorCode PetscViewerHDF5OpenGroup(PetscViewer viewer, hid_t *fileId, hid_t *groupId)
{
hid_t file_id, group;
const char *groupName = NULL;
PetscErrorCode ierr;
PetscFunctionBegin;
ierr = PetscViewerHDF5GetFileId(viewer, &file_id);CHKERRQ(ierr);
ierr = PetscViewerHDF5GetGroup(viewer, &groupName);CHKERRQ(ierr);
/* Open group */
if (groupName) {
PetscBool root;
ierr = PetscStrcmp(groupName, "/", &root);CHKERRQ(ierr);
if (!root && !H5Lexists(file_id, groupName, H5P_DEFAULT)) {
#if (H5_VERS_MAJOR * 10000 + H5_VERS_MINOR * 100 + H5_VERS_RELEASE >= 10800)
group = H5Gcreate2(file_id, groupName, 0, H5P_DEFAULT, H5P_DEFAULT);
#else /* deprecated HDF5 1.6 API */
group = H5Gcreate(file_id, groupName, 0);
#endif
if (group < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_LIB, "Could not create group %s", groupName);
ierr = H5Gclose(group);CHKERRQ(ierr);
}
#if (H5_VERS_MAJOR * 10000 + H5_VERS_MINOR * 100 + H5_VERS_RELEASE >= 10800)
group = H5Gopen2(file_id, groupName, H5P_DEFAULT);
#else
group = H5Gopen(file_id, groupName);
#endif
if (group < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_LIB, "Could not open group %s", groupName);
} else group = file_id;
*fileId = file_id;
*groupId = group;
PetscFunctionReturn(0);
}
开发者ID:feelpp,项目名称:debian-petsc,代码行数:35,代码来源:vecio.c
示例10: throwException
//--------------------------------------------------------------------------
// Function: CommonFG::createGroup
///\brief Creates a new group at this location which can be a file
/// or another group.
///\param name - IN: Name of the group to create
///\param size_hint - IN: Indicates the number of bytes to reserve for
/// the names that will appear in the group
///\return Group instance
///\exception H5::FileIException or H5::GroupIException
///\par Description
/// The optional \a size_hint specifies how much file space to
/// reserve for storing the names that will appear in this new
/// group. If a non-positive value is provided for the \a size_hint
/// then a default size is chosen.
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
Group CommonFG::createGroup( const char* name, size_t size_hint ) const
{
// Group creation property list for size_hint
hid_t gcpl_id = 0;
// Set the local heap size hint
if(!(size_hint == (size_t)-1 || size_hint == 0)) {
// If the creation of the property list failed, throw an exception
if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0)
throwException("createGroup", "H5Pcreate failed");
if( H5Pset_local_heap_size_hint(gcpl_id, size_hint) < 0) {
H5Pclose(gcpl_id);
throwException("createGroup", "H5Pset_local_heap_size failed");
}
}
// Call C routine H5Gcreate2 to create the named group, giving the
// location id which can be a file id or a group id
hid_t group_id = H5Gcreate2( getLocId(), name, H5P_DEFAULT, gcpl_id, H5P_DEFAULT );
// Close the group creation property list, if necessary
if(gcpl_id > 0)
H5Pclose(gcpl_id);
// If the creation of the group failed, throw an exception
if( group_id < 0 )
throwException("createGroup", "H5Gcreate2 failed");
// No failure, create and return the Group object
Group group( group_id );
return( group );
}
开发者ID:ArielleBassanelli,项目名称:gempak,代码行数:50,代码来源:H5CommonFG.cpp
示例11: soft_link_example
static void soft_link_example(void)
{
hid_t file_id;
hid_t group_id;
/* Define the link class that we'll use to register "user-defined soft
* links" using the callbacks we defined above.
* A link class can have NULL for any callback except its traverse
* callback.
*/
const H5L_class_t UD_soft_class[1] = {{
H5L_LINK_CLASS_T_VERS, /* Version number for this struct.
* This field is always H5L_LINK_CLASS_T_VERS */
(H5L_type_t)UD_SOFT_CLASS, /* Link class id number. This can be any
* value between H5L_TYPE_UD_MIN (64) and
* H5L_TYPE_MAX (255). It should be a
* value that isn't already being used by
* another kind of link. We'll use 65. */
"UD_soft_link", /* Link class name for debugging */
NULL, /* Creation callback */
NULL, /* Move callback */
NULL, /* Copy callback */
UD_soft_traverse, /* The actual traversal function */
NULL, /* Deletion callback */
NULL /* Query callback */
}};
/* First, create a file and an object within the file for the link to
* point to.
*/
file_id = H5Fcreate(SOFT_LINK_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
group_id = H5Gcreate2(file_id, TARGET_GROUP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
H5Gclose(group_id);
/* This is how we create a normal soft link to the group.
*/
H5Lcreate_soft(TARGET_GROUP, file_id, SOFT_LINK_NAME, H5P_DEFAULT, H5P_DEFAULT);
/* To do the same thing using a user-defined link, we first have to
* register the link class we defined.
*/
H5Lregister(UD_soft_class);
/* Now create a user-defined link. We give it the path to the group
* as its udata.1
*/
H5Lcreate_ud(file_id, UD_SOFT_LINK_NAME, (H5L_type_t)UD_SOFT_CLASS, TARGET_GROUP,
strlen(TARGET_GROUP) + 1, H5P_DEFAULT, H5P_DEFAULT);
/* We can access the group through the UD soft link like we would through
* a normal soft link. This link will still dangle if the object's
* original name is changed or unlinked.
*/
group_id = H5Gopen2(file_id, UD_SOFT_LINK_NAME, H5P_DEFAULT);
/* The group is now open normally. Don't forget to close it! */
H5Gclose(group_id);
H5Fclose(file_id);
}
开发者ID:ngcurrier,项目名称:ProteusCFD,代码行数:60,代码来源:h5_extlink.c
示例12: extlink_example
/* Basic external link example
*
* Creates two files and uses an external link to access an object in the
* second file from the first file.
*/
static void extlink_example(void)
{
hid_t source_file_id, targ_file_id;
hid_t group_id, group2_id;
/* Create two files, a source and a target */
source_file_id = H5Fcreate(SOURCE_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
targ_file_id = H5Fcreate(TARGET_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
/* Create a group in the target file for the external link to point to. */
group_id = H5Gcreate2(targ_file_id, "target_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
/* Close the group and the target file */
H5Gclose(group_id);
/* Create an external link in the source file pointing to the target group.
* We could instead have created the external link first, then created the
* group it points to; the order doesn't matter.
*/
H5Lcreate_external(TARGET_FILE, "target_group", source_file_id, "ext_link", H5P_DEFAULT, H5P_DEFAULT);
/* Now we can use the external link to create a new group inside the
* target group (even though the target file is closed!). The external
* link works just like a soft link.
*/
group_id = H5Gcreate2(source_file_id, "ext_link/new_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
/* The group is inside the target file and we can access it normally.
* Here, group_id and group2_id point to the same group inside the
* target file.
*/
group2_id = H5Gopen2(targ_file_id, "target_group/new_group", H5P_DEFAULT);
/* Don't forget to close the IDs we opened. */
H5Gclose(group2_id);
H5Gclose(group_id);
H5Fclose(targ_file_id);
H5Fclose(source_file_id);
/* The link from the source file to the target file will work as long as
* the target file can be found. If the target file is moved, renamed,
* or deleted in the filesystem, HDF5 won't be able to find it and the
* external link will "dangle."
*/
}
开发者ID:ngcurrier,项目名称:ProteusCFD,代码行数:51,代码来源:h5_extlink.c
示例13: main
/*-------------------------------------------------------------------------
* Function: main
*
* Purpose: Runs external dataset tests.
*
* Return: Success: exit(0)
*
* Failure: exit(non-zero)
*
* Programmer: Robb Matzke
* Tuesday, March 3, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
int
main (void)
{
hid_t fapl=-1; /*file access properties */
hid_t file=-1; /*file for test_1* functions */
char filename[1024]; /*file name for test_1* funcs */
hid_t grp=-1; /*group to emit diagnostics */
int nerrors=0; /*number of errors */
h5_reset();
fapl = h5_fileaccess();
h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR
if((grp = H5Gcreate2(file, "emit-diagnostics", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
if(H5Gclose(grp) < 0) goto error;
nerrors += test_1a(file);
nerrors += test_1b(file);
nerrors += test_1c(file);
nerrors += test_1d(file);
nerrors += test_1e(file);
nerrors += test_1f(file);
nerrors += test_1g();
nerrors += test_1h();
nerrors += test_2(fapl);
nerrors += test_3(fapl);
nerrors += test_4(fapl);
/* Verify symbol table messages are cached */
nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0);
if (nerrors>0) goto error;
if (H5Fclose(file) < 0) goto error;
puts("All external storage tests passed.");
if (h5_cleanup(FILENAME, fapl)) {
remove("extern_1a.raw");
remove("extern_1b.raw");
remove("extern_2a.raw");
remove("extern_2b.raw");
remove("extern_3a.raw");
remove("extern_3b.raw");
remove("extern_4a.raw");
remove("extern_4b.raw");
}
return 0;
error:
H5E_BEGIN_TRY {
H5Fclose(file);
H5Pclose(fapl);
} H5E_END_TRY;
nerrors = MAX(1, nerrors);
printf ("%d TEST%s FAILED.\n", nerrors, 1==nerrors?"":"s");
return 1;
}
开发者ID:EgoIncarnate,项目名称:appleseed,代码行数:73,代码来源:external.c
示例14: H5Eset_auto2
/**
Traverse the path of an object in HDF5 file, checking existence of
groups in the path and creating them if required. */
hid_t HDF5DataWriter::getDataset(string path)
{
if (filehandle_ < 0){
return -1;
}
herr_t status = H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
// Create the groups corresponding to this path
string::size_type lastslash = path.find_last_of("/");
vector<string> pathTokens;
moose::tokenize(path, "/", pathTokens);
hid_t prev_id = filehandle_;
hid_t id = -1;
for ( unsigned int ii = 0; ii < pathTokens.size()-1; ++ii ){
// check if object exists
htri_t exists = H5Lexists(prev_id, pathTokens[ii].c_str(),
H5P_DEFAULT);
if (exists > 0){
// try to open existing group
id = H5Gopen2(prev_id, pathTokens[ii].c_str(), H5P_DEFAULT);
} else if (exists == 0) {
// If that fails, try to create a group
id = H5Gcreate2(prev_id, pathTokens[ii].c_str(),
H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
}
if ((exists < 0) || (id < 0)){
// Failed to open/create a group, print the
// offending path (for debugging; the error is
// perhaps at the level of hdf5 or file system).
cerr << "Error: failed to open/create group: ";
for (unsigned int jj = 0; jj <= ii; ++jj){
cerr << "/" << pathTokens[jj];
}
cerr << endl;
prev_id = -1;
}
if (prev_id >= 0 && prev_id != filehandle_){
// Successfully opened/created new group, close the old group
status = H5Gclose(prev_id);
assert( status >= 0 );
}
prev_id = id;
}
string name = pathTokens[pathTokens.size()-1];
htri_t exists = H5Lexists(prev_id, name.c_str(), H5P_DEFAULT);
hid_t dataset_id = -1;
if (exists > 0){
dataset_id = H5Dopen2(prev_id, name.c_str(), H5P_DEFAULT);
} else if (exists == 0){
dataset_id = createDoubleDataset(prev_id, name);
} else {
cerr << "Error: H5Lexists returned "
<< exists << " for path \""
<< path << "\"" << endl;
}
return dataset_id;
}
开发者ID:hrani,项目名称:moose-core,代码行数:59,代码来源:HDF5DataWriter.cpp
示例15: gent_empty_group
/*-------------------------------------------------------------------------
* Function: gent_empty_group
*
* Purpose: Generate an empty group in a location
*
*-------------------------------------------------------------------------
*/
static void gent_empty_group(hid_t loc_id)
{
hid_t gid;
/* Create group in location */
gid = H5Gcreate2(loc_id, GROUP_EMPTY, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
/* Release resources */
H5Gclose(gid);
}
开发者ID:Hulalazz,项目名称:rnnlib,代码行数:17,代码来源:h5copygentest.c
示例16: group
group(h5a::node const & parent, std::string const & path, bool create) {
if (!create) {
open_group(parent, path);
return;
}
h5p::proplist gcpl(H5P_GROUP_CREATE);
h5e::check_error(H5Pset_link_creation_order(gcpl.hid(),
H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED));
_self = h5e::check_error(H5Gcreate2(parent.hid(), path.c_str(), H5P_DEFAULT,
gcpl.hid(), H5P_DEFAULT));
}
开发者ID:margoliashlab,项目名称:arf,代码行数:11,代码来源:h5g.hpp
示例17: gent_nested_group
/*-------------------------------------------------------------------------
* Function: gent_nested_group
*
* Purpose: Generate a group in a location and populate it with another group
* containing the "standard" datasets
*
*-------------------------------------------------------------------------
*/
static void gent_nested_group(hid_t loc_id)
{
hid_t gid;
/* Create group in location */
gid = H5Gcreate2(loc_id, GROUP_NESTED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
/* Add datasets to group created */
gent_nested_datasets(gid);
/* Release resources */
H5Gclose(gid);
}
开发者ID:Hulalazz,项目名称:rnnlib,代码行数:21,代码来源:h5copygentest.c
示例18: main
int main()
{
char* filename = "file-test.h5";
hid_t fprop;
hid_t vol_id = H5VLregister_by_name("h5-esdm");
hid_t file_id, group_id, dataset_id, dataspace_id, attribute_id;
herr_t status;
char name[1024];
// SET VOL PLUGIN /////////////////////////////////////////////////////////
fprop = H5Pcreate(H5P_FILE_ACCESS);
H5Pset_vol(fprop, vol_id, &fprop);
// TODO
// MOCK SETUP /////////////////////////////////////////////////////////////
/* Create a new file using default properties. */
file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fprop);
/* Create a group named "/MyGroup" in the file. */
group_id = H5Gcreate2(file_id, "/MyGroup", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
/* Close the group. */
status = H5Gclose(group_id);
/* Terminate access to the file. */
status = H5Fclose(file_id);
// MOCK CLEANUP ///////////////////////////////////////////////////////////
// CREATE /////////////////////////////////////////////////////////////////
// OPEN ///////////////////////////////////////////////////////////////////
// CLOSE //////////////////////////////////////////////////////////////////
// READ ///////////////////////////////////////////////////////////////////
// WRITE //////////////////////////////////////////////////////////////////
// GET ////////////////////////////////////////////////////////////////////
// SPECIFIC ///////////////////////////////////////////////////////////////
// OPTIONAL ///////////////////////////////////////////////////////////////
// Clean up ///////////////////////////////////////////////////////////////
H5VLunregister(vol_id);
return 0;
}
开发者ID:ESiWACE,项目名称:ESD-Middleware,代码行数:51,代码来源:H5G-Group-Interface.c
示例19: H5Fopen
int GWriteHDFFile::WriteHeader(gadget_header& header)
{
herr_t herr;
for(int i=0; i<N_TYPE; i++){
header.npart[i]=npart[i];
}
hid_t handle = H5Fopen(filename.c_str(), H5F_ACC_RDWR, H5P_DEFAULT);
if (handle < 0)
return -1*handle;
// Lite interface for making simple attributes
// H5LTset_attribute_int (file_id, dset_name, attr_name, data, size);
// herr_t H5LTset_attribute_int( hid_t loc_id, const char *obj_name, const char *attr_name, int *buffer, size_t size)
hid_t hdgrp = H5Gcreate2(handle, "Header", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
herr = H5LTset_attribute_uint(handle, "Header", "NumPart_ThisFile", header.npart, N_TYPE);
if (herr < 0) {
WARN("Could not write to header");
return -1*herr;
}
herr = H5LTset_attribute_uint(handle, "Header", "NumPart_Total", header.npartTotal, N_TYPE);
herr = H5LTset_attribute_uint(handle, "Header", "NumPart_Total_HighWord", header.NallHW, N_TYPE);
herr = H5LTset_attribute_double(handle, "Header", "MassTable", header.mass, N_TYPE);
if (herr < 0) {
WARN("Could not write particle numbers");
return -1*herr;
}
herr = H5LTset_attribute_double(handle, "Header", "Time", &header.time, 1);
herr = H5LTset_attribute_double(handle, "Header", "Redshift", &header.redshift, 1);
herr = H5LTset_attribute_double(handle, "Header", "BoxSize", &header.BoxSize, 1);
herr = H5LTset_attribute_int(handle, "Header", "NumFilesPerSnapshot", &header.num_files, 1);
herr = H5LTset_attribute_double(handle, "Header", "Omega0", &header.Omega0, 1);
herr = H5LTset_attribute_double(handle, "Header", "OmegaLambda", &header.OmegaLambda, 1);
herr = H5LTset_attribute_double(handle, "Header", "HubbleParam", &header.HubbleParam, 1);
herr = H5LTset_attribute_int(handle, "Header", "Flag_Sfr", &header.flag_sfr, 1);
herr = H5LTset_attribute_int(handle, "Header", "Flag_Cooling", &header.flag_cooling, 1);
herr = H5LTset_attribute_int(handle, "Header", "Flag_StellarAge", &header.flag_stellarage, 1);
herr = H5LTset_attribute_int(handle, "Header", "Flag_Metals", &header.flag_metals, 1);
herr = H5LTset_attribute_int(handle, "Header", "Flag_Feedback", &header.flag_feedback, 1);
herr = H5LTset_attribute_int(handle, "Header", "Flag_DoublePrecision", &header.flag_doubleprecision, 1);
herr = H5LTset_attribute_int(handle, "Header", "Flag_IC_Info", &header.flag_ic_info, 1);
herr = H5LTset_attribute_double(handle, "Header", "UnitLength_in_cm", &header.UnitLength_in_cm, 1);
herr = H5LTset_attribute_double(handle, "Header", "UnitMass_in_g", &header.UnitMass_in_g, 1);
herr = H5LTset_attribute_double(handle, "Header", "UnitVelocity_in_cm_per_s", &header.UnitVelocity_in_cm_per_s, 1);
if (herr < 0) {
WARN("Could not write final header flags");
return -1*herr;
}
H5Gclose(hdgrp);
H5Fclose(handle);
return 0;
}
开发者ID:sbird,项目名称:GadgetReader,代码行数:50,代码来源:gadgetwritehdf.cpp
示例20: test_misc
/*-------------------------------------------------------------------------
* Function: test_misc
*
* Purpose: Test miscellaneous group stuff.
*
* Return: Success: 0
*
* Failure: number of errors
*
* Programmer: Robb Matzke
* Tuesday, November 24, 1998
*
*-------------------------------------------------------------------------
*/
static int
test_misc(hid_t fapl, hbool_t new_format)
{
hid_t fid = (-1); /* File ID */
hid_t g1 = (-1), g2 = (-1), g3 = (-1);
char filename[NAME_BUF_SIZE];
char comment[64];
if(new_format)
TESTING("miscellaneous group tests (w/new group format)")
else
TESTING("miscellaneous group tests")
/* Create file */
h5_fixname(FILENAME[0], fapl, filename, sizeof(filename));
if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR
/* Create initial groups for testing, then close */
if((g1 = H5Gcreate2(fid, "test_1a", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
if((g2 = H5Gcreate2(g1, "sub_1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
if((g3 = H5Gcreate2(fid, "test_1b", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
if(H5Oset_comment(g3, "hello world") < 0) TEST_ERROR
if(H5Gclose(g1) < 0) TEST_ERROR
if(H5Gclose(g2) < 0) TEST_ERROR
if(H5Gclose(g3) < 0) TEST_ERROR
/* Open all groups with absolute names to check for exsistence */
if((g1 = H5Gopen2(fid, "/test_1a", H5P_DEFAULT)) < 0) TEST_ERROR
if((g2 = H5Gopen2(fid, "/test_1a/sub_1", H5P_DEFAULT)) < 0) TEST_ERROR
if((g3 = H5Gopen2(fid, "/test_1b", H5P_DEFAULT)) < 0) TEST_ERROR
if(H5Oget_comment_by_name(g3, "././.", comment, sizeof comment, H5P_DEFAULT) < 0) TEST_ERROR
if(HDstrcmp(comment, "hello world")) {
H5_FAILED();
puts(" Read the wrong comment string from the group.");
printf(" got: \"%s\"\n ans: \"hello world\"\n", comment);
TEST_ERROR
}
开发者ID:FilipeMaia,项目名称:hdf5,代码行数:51,代码来源:stab.c
注:本文中的H5Gcreate2函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论