本文整理汇总了C++中H5Aread函数的典型用法代码示例。如果您正苦于以下问题:C++ H5Aread函数的具体用法?C++ H5Aread怎么用?C++ H5Aread使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了H5Aread函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: H5Aget_type
// JRC: This fat interface may not scale? What about
// scalar attributes?
herr_t VsH5Attribute::getDoubleVectorValue(std::vector<double>* dvals) {
herr_t err = 0;
size_t npoints;
hid_t atype = H5Aget_type(getId());
H5T_class_t type = H5Tget_class(atype);
hid_t aspace = H5Aget_space(getId());
size_t rank = H5Sget_simple_extent_ndims(aspace);
if (type != H5T_FLOAT) {
VsLog::warningLog() <<"VsH5Attribute::getDoubleVectorValue() - Requested attribute " <<getShortName()
<<" is not a floating point vector." <<std::endl;
dvals->resize(0);
return -1;
}
if (rank == 0) {
dvals->resize(1);
double v;
err = H5Aread(getId(), H5T_NATIVE_DOUBLE, &v);
(*dvals)[0] = v;
return err;
}
// rank>0
npoints = H5Sget_simple_extent_npoints(aspace);
double* v = new double[npoints];
err = H5Aread(getId(), H5T_NATIVE_DOUBLE, v);
dvals->resize(npoints);
for (size_t i = 0; i<npoints; ++i) {
(*dvals)[i] = v[i];
}
delete [] v;
return err;
}
示例2: getIntfInfo
int AMRreader::
getIntfInfo( hid_t gid )
{
hid_t aid = H5Aopen_name( gid, intf_np_name );
if( aid<0 ) {
nvert_=0;
debug1 << "Failed to find number of interface points.\n";
return -1;
}
else {
H5Aread( aid, H5T_NATIVE_INT, &nvert_ );
H5Aclose(aid);
}
debug2 << "nvert is " << nvert_ << "\n";
aid = H5Aopen_name( gid, intf_ne_name );
if( aid<0 ) {
nrect_=0;
debug1 << "Failed to find number of interface elements.\n";
return -2;
}
else {
H5Aread( aid, H5T_NATIVE_INT, &nrect_ );
H5Aclose(aid);
}
debug2 << "nrect is " << nrect_ << "\n";
return 0;
}
示例3: fname
AccessTraceReader::AccessTraceReader(std::string _fname) : fname(_fname.c_str()) {
hid_t fid = H5Fopen(fname.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
if (fid == H5I_INVALID_HID) panic("Could not open HDF5 file %s", fname.c_str());
// Check that the trace finished
hid_t fAttr = H5Aopen(fid, "finished", H5P_DEFAULT);
uint32_t finished;
H5Aread(fAttr, H5T_NATIVE_UINT, &finished);
H5Aclose(fAttr);
if (!finished) panic("Trace file %s unfinished (halted simulation?)", fname.c_str());
// Populate numRecords & numChildren
hsize_t nPackets;
hid_t table = H5PTopen(fid, "accs");
if (table == H5I_INVALID_HID) panic("Could not open HDF5 packet table");
H5PTget_num_packets(table, &nPackets);
numRecords = nPackets;
hid_t ncAttr = H5Aopen(fid, "numChildren", H5P_DEFAULT);
H5Aread(ncAttr, H5T_NATIVE_UINT, &numChildren);
H5Aclose(ncAttr);
curFrameRecord = 0;
cur = 0;
max = MIN(PT_CHUNKSIZE, numRecords);
buf = max? gm_calloc<PackedAccessRecord>(max) : nullptr;
if (max) {
H5PTread_packets(table, 0, max, buf);
}
H5PTclose(table);
H5Fclose(fid);
}
示例4: read_attribute
/* Read and verify attribute for group or dataset. */
int read_attribute(hid_t obj_id, int this_type, int num)
{
hid_t aid;
hsize_t group_block[2]={1,1}, dset_block[2]={1, 8};
int i, mpi_rank, in_num, in_data[8], out_data[8], vrfy_errors = 0;
char attr_name[32];
MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
if(this_type == is_group) {
sprintf(attr_name, "Group Attribute %d", num);
aid = H5Aopen_name(obj_id, attr_name);
if(MAINPROCESS) {
H5Aread(aid, H5T_NATIVE_INT, &in_num);
vrfy_errors = dataset_vrfy(NULL, NULL, NULL, group_block,
&in_num, &num);
}
H5Aclose(aid);
}
else if(this_type == is_dset) {
sprintf(attr_name, "Dataset Attribute %d", num);
for(i=0; i<8; i++)
out_data[i] = i;
aid = H5Aopen_name(obj_id, attr_name);
if(MAINPROCESS) {
H5Aread(aid, H5T_NATIVE_INT, in_data);
vrfy_errors = dataset_vrfy(NULL, NULL, NULL, dset_block, in_data,
out_data);
}
H5Aclose(aid);
}
return vrfy_errors;
}
示例5: attribute_read
herr_t attribute_read(char *attribute_name, enum my_hdf5_types hdf5_type,
hid_t hdf5_file_handle, void *buf)
{
hid_t hdf5_attribute_id, hdf5_dataspace, hdf5_datatype;
herr_t hdf5_status = 0;
//here we get an identifier for a datatype
switch (hdf5_type)
{
case my_hdf5_int:
hdf5_datatype = H5Tcopy(H5T_NATIVE_INT);
break;
case my_hdf5_long:
hdf5_datatype = H5Tcopy(H5T_NATIVE_LONG);
break;
case my_hdf5_float:
hdf5_datatype = H5Tcopy(H5T_NATIVE_FLOAT);
break;
case my_hdf5_double:
hdf5_datatype = H5Tcopy(H5T_NATIVE_DOUBLE);
break;
default:
exit(-1);
break;
}
hdf5_dataspace = H5Screate(H5S_SCALAR);
hdf5_attribute_id =
H5Acreate(hdf5_file_handle, attribute_name, hdf5_datatype, hdf5_dataspace, H5P_DEFAULT); //here we 'create' an attribute
switch (hdf5_type)
{
case my_hdf5_int:
hdf5_status = H5Aread(hdf5_attribute_id, hdf5_datatype, (int *) buf);
break;
case my_hdf5_long:
hdf5_status = H5Aread(hdf5_attribute_id, hdf5_datatype, (long *) buf);
break;
case my_hdf5_float:
hdf5_status = H5Aread(hdf5_attribute_id, hdf5_datatype, (float *) buf);
break;
case my_hdf5_double:
hdf5_status = H5Aread(hdf5_attribute_id, hdf5_datatype, (double *) buf);
break;
default:
exit(-1);
break;
}
H5Tclose(hdf5_datatype);
H5Aclose(hdf5_attribute_id);
H5Sclose(hdf5_dataspace);
return hdf5_status;
}
示例6: H5Dopen
void AbstractHdf5Access::SetUnlimitedDatasetId()
{
// Now deal with the unlimited dimension
// In terms of an Unlimited dimension dataset:
// * Files pre - r16738 (inc. Release 3.1 and earlier) use simply "Time" for "Data"'s unlimited variable.
// * Files generated by r16738 - r18257 used "<DatasetName>_Time" for "<DatasetName>"'s unlimited variable,
// - These are not to be used and there is no backwards compatibility for them, since they weren't in a release.
// * Files post r18257 (inc. Release 3.2 onwards) use "<DatasetName>_Unlimited" for "<DatasetName>"'s
// unlimited variable,
// - a new attribute "Name" has been added to the Unlimited Dataset to allow it to assign
// any name to the unlimited variable. Which can then be easily read by Hdf5DataReader.
// - if this dataset is missing we look for simply "Time" to remain backwards compatible with Releases <= 3.1
if (DoesDatasetExist(mDatasetName + "_Unlimited"))
{
mUnlimitedDatasetId = H5Dopen(mFileId, (mDatasetName + "_Unlimited").c_str());
hid_t name_attribute_id = H5Aopen_name(mUnlimitedDatasetId, "Name");
hid_t unit_attribute_id = H5Aopen_name(mUnlimitedDatasetId, "Unit");
hid_t attribute_type = H5Aget_type(name_attribute_id);
// Read into it.
char* string_array = (char *)malloc(sizeof(char)*MAX_STRING_SIZE);
H5Aread( name_attribute_id, attribute_type, string_array);
std::string name_string(&string_array[0]);
mUnlimitedDimensionName = name_string;
H5Aread( unit_attribute_id, attribute_type, string_array);
std::string unit_string(&string_array[0]);
mUnlimitedDimensionUnit = unit_string;
free(string_array);
H5Tclose(attribute_type);
H5Aclose(name_attribute_id);
H5Aclose(unit_attribute_id);
}
else if (DoesDatasetExist("Time"))
{
mUnlimitedDimensionName = "Time";
mUnlimitedDimensionUnit = "msec";
mUnlimitedDatasetId = H5Dopen(mFileId, mUnlimitedDimensionName.c_str());
}
else
{
NEVER_REACHED;
}
mIsUnlimitedDimensionSet = true;
}
示例7: H5Aread
char HIntAttribute::read(int *data)
{
herr_t status = H5Aread(fObjectId, dataType(), data);
if(status < 0)
return 0;
return 1;
}
示例8: get_attribute_mem
static herr_t get_attribute_mem(hid_t obj_id,
const char *attr_name,
hid_t mem_type_id,
void *data)
{
hid_t attr_id;
herr_t status;
attr_id = H5Aopen_name(obj_id, attr_name);
if (attr_id < 0)
return -1;
status = H5Aread(attr_id, mem_type_id, data);
if (status < 0)
{
H5Aclose(attr_id);
return -1;
}
status = H5Aclose(attr_id);
if (status < 0)
return -1;
return 0;
}
示例9: get_attribute_disk
static herr_t get_attribute_disk(hid_t loc_id,
const char *attr_name,
void *attr_out)
{
hid_t attr_id;
hid_t attr_type;
herr_t status;
attr_id = H5Aopen_name(loc_id, attr_name);
if (attr_id < 0)
return -1;
attr_type = H5Aget_type(attr_id);
if (attr_type < 0)
goto out;
status = H5Aread(attr_id, attr_type, attr_out);
if (status < 0)
goto out;
status = H5Tclose(attr_type);
if (status < 0)
goto out;
status = H5Aclose(attr_id);
if (status < 0)
return -1;
return 0;
out:
H5Tclose(attr_type);
H5Aclose(attr_id);
return -1;
}
示例10: h5nullArgument
/*
* Class: hdf_hdf5lib_H5
* Method: H5Aread
* Signature: (JJ[B)I
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Aread
(JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jbyteArray buf)
{
herr_t status = -1;
jbyte *byteP;
jboolean isCopy;
if (buf == NULL) {
h5nullArgument( env,"H5Aread: buf is NULL");
} /* end if */
else {
byteP = ENVPTR->GetByteArrayElements(ENVPAR buf, &isCopy);
if (byteP == NULL) {
h5JNIFatalError( env,"H5Aread: buf is not pinned");
} /* end if */
else {
status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, byteP);
if (status < 0) {
ENVPTR->ReleaseByteArrayElements(ENVPAR buf, byteP, JNI_ABORT);
h5libraryError(env);
} /* end if */
else {
ENVPTR->ReleaseByteArrayElements(ENVPAR buf, byteP, 0);
} /* end else */
} /* end else */
} /* end else */
return (jint)status;
} /* end Java_hdf_hdf5lib_H5_H5Aread */
示例11: read_complex_attribute
// read a complex float attribute
float_complex read_complex_attribute(hid_t loc_id, const char* path,
const char* name)
{
float_complex value;
float *buf;
hid_t attr_id, real_type_id;
;
hsize_t *dims;
herr_t status;
status = H5Aexists_by_name(loc_id, path, name, H5P_DEFAULT);
if (status < 0)
{
printf("attribut %s does not exist \n", name);
}
real_type_id = create_real_type_id();
attr_id = H5Aopen_by_name(loc_id, path, name, H5P_DEFAULT, H5P_DEFAULT);
status = H5Aread(attr_id, real_type_id, buf);
if (status < 0)
{
printf("Can't read attribute : %s\n", name);
}
value.re = buf[0]; value.im=buf[1];
return value;
}
示例12: H5Dataset_read_attr_value
/* read attribute value */
char* H5Dataset_read_attr_value(hid_t aid)
{
hid_t asid=-1, atid=-1;
int i, rank;
hsize_t *dims;
size_t size=1;
char *attr_buf=NULL;
asid = H5Aget_space(aid);
atid = H5Aget_type(aid);
rank = H5Sget_simple_extent_ndims(asid);
if (rank > 0) {
dims = (hsize_t *)malloc(rank * sizeof(hsize_t));
H5Sget_simple_extent_dims(asid, dims, NULL);
for (i=0; i<rank; i++) {
size *= (size_t)dims[i];
free(dims);
}
size *= H5Tget_size(atid);
attr_buf = (char *)malloc(size);
if (H5Aread( aid, atid, attr_buf) < 0) {
free(attr_buf);
attr_buf = NULL;
}
}
if( atid > 0) H5Tclose(atid);
if (asid > 0) H5Sclose(asid);
return attr_buf;
}
示例13: read_attribute
inline typename boost::enable_if<boost::is_same<T, std::string>, T>::type
read_attribute(H5::H5Object const& object, std::string const& name)
{
H5::Attribute attr;
try {
H5XX_NO_AUTO_PRINT(H5::AttributeIException);
attr = object.openAttribute(name);
}
catch (H5::AttributeIException const&) {
throw;
}
if (!has_scalar_space(attr)) {
throw H5::AttributeIException("H5::attribute::as", "incompatible dataspace");
}
H5::DataType tid = attr.getDataType();
std::string value;
if (!tid.isVariableStr()) {
// read fixed-size string, allocate space in advance and let the HDF5
// library take care about NULLTERM and NULLPAD strings
value.resize(tid.getSize(), std::string::value_type());
attr.read(tid, &*value.begin());
}
else {
// read variable-length string, memory will be allocated by HDF5 C
// library and must be freed by us
char *c_str;
if (H5Aread(attr.getId(), tid.getId(), &c_str) < 0) {
throw H5::AttributeIException("Attribute::read", "H5Aread failed");
}
value = c_str; // copy '\0'-terminated string
free(c_str);
}
return value;
}
示例14: e5_read_attr_list_str
estatus_t
e5_read_attr_list_str(
hid_t e5_group_id, e5_attr_str* e5_attr_list)
{
int i;
estatus_t status = E5_SUCCESS;
hid_t e5_attribute_id;
hid_t e5_dataspace_id = H5Screate(H5S_SCALAR);
hid_t e5_string_type = H5Tcopy(H5T_C_S1);
H5Tset_size(e5_string_type, E5_MAX_ATTR_STRING_LENGTH);
for(i = 0; e5_attr_list && e5_attr_list[i].name != 0; i++)
{
e5_attr_str *attr = &e5_attr_list[i];
if(attr->name == 0 || strlen(attr->name) < 1)
continue;
if(H5Aexists(e5_group_id, attr->name) <= 0)
{
status = E5_INVALID_ATTRIBUTE;
e5_error(e5_group_id, status, "Specified attribute '%s' does not exist\n", attr->name);
continue;
}
e5_attribute_id = H5Aopen(e5_group_id, attr->name, H5P_DEFAULT);
H5Aread(e5_attribute_id, e5_string_type, &(attr->value));
H5Aclose(e5_attribute_id);
e5_info(e5_group_id, "Read attribute [type='str', name='%s', value='%s']\n", attr->name, attr->value);
}
H5Sclose(e5_dataspace_id);
return status;
}
示例15: readIntAttribute_v1
static int readIntAttribute_v1(int _iDatasetId, const char *_pstName)
{
hid_t iAttributeId;
herr_t status;
hsize_t n = 0;
int iVal = -1;
if (H5Aiterate(_iDatasetId, H5_INDEX_NAME, H5_ITER_NATIVE, &n, find_attr_by_name_v1, (void *)_pstName) > 0)
{
iAttributeId = H5Aopen_by_name(_iDatasetId, ".", _pstName, H5P_DEFAULT, H5P_DEFAULT);
if (iAttributeId < 0)
{
return -1;
}
status = H5Aread(iAttributeId, H5T_NATIVE_INT, &iVal);
if (status < 0)
{
return -1;
}
status = H5Aclose(iAttributeId);
if (status < 0)
{
return -1;
}
}
return iVal;
}