您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ H5Aread函数代码示例

51自学网 2021-06-01 21:19:58
  C++
这篇教程C++ H5Aread函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中H5Aread函数的典型用法代码示例。如果您正苦于以下问题:C++ H5Aread函数的具体用法?C++ H5Aread怎么用?C++ H5Aread使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了H5Aread函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;}
开发者ID:HarinarayanKrishnan,项目名称:VisIt26RC_Trunk,代码行数:37,


示例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;}
开发者ID:HarinarayanKrishnan,项目名称:VisIt26RC_Trunk,代码行数:29,


示例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);}
开发者ID:Luffy0011,项目名称:zsim,代码行数:35,


示例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;}
开发者ID:einon,项目名称:affymetrix-power-tools,代码行数:35,


示例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;}
开发者ID:john-regan,项目名称:CoolingModule,代码行数:54,


示例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;}
开发者ID:getshameer,项目名称:Chaste,代码行数:49,


示例7: H5Aread

char HIntAttribute::read(int *data){	herr_t status = H5Aread(fObjectId, dataType(), data);	if(status < 0)		return 0;	return 1;}
开发者ID:ahmidou,项目名称:aphid,代码行数:7,


示例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;}
开发者ID:QuLogic,项目名称:citcoms,代码行数:25,


示例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;}
开发者ID:QuLogic,项目名称:citcoms,代码行数:34,


示例10: h5nullArgument

/* * Class:     hdf_hdf5lib_H5 * Method:    H5Aread * Signature: (JJ[B)I */JNIEXPORT jint JNICALLJava_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 */
开发者ID:ngcurrier,项目名称:ProteusCFD,代码行数:36,


示例11: read_complex_attribute

// read a complex float attributefloat_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;}
开发者ID:ThinkManhattan,项目名称:amelet-hdf,代码行数:26,


示例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;}
开发者ID:DICE-UNC,项目名称:iRODS-FUSE-Mod,代码行数:35,


示例13: read_attribute

inline typename boost::enable_if<boost::is_same<T, std::string>, T>::typeread_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;}
开发者ID:jb--,项目名称:h5xx,代码行数:34,


示例14: e5_read_attr_list_str

estatus_te5_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;}
开发者ID:voidcycles,项目名称:void,代码行数:34,


示例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;}
开发者ID:ASP1234,项目名称:Scilabv5.5.2,代码行数:29,


示例16: AH5_read_str_attr

// Read string attribute <attr_name> given by address <path>char AH5_read_str_attr(hid_t loc_id, const char *path, char *attr_name, char **rdata){    hid_t attr_id, filetype, memtype;    size_t sdim;    char success = AH5_FALSE;    if (AH5_path_valid(loc_id, path) || strcmp(path, ".") == 0)        if (H5Aexists_by_name(loc_id, path, attr_name, H5P_DEFAULT) > 0)        {            attr_id = H5Aopen_by_name(loc_id, path, attr_name, H5P_DEFAULT, H5P_DEFAULT);            filetype = H5Aget_type(attr_id);            sdim = H5Tget_size(filetype);            sdim++;  // make a space for null terminator            *rdata = (char *) malloc(sdim * sizeof(char));            memtype = H5Tcopy(H5T_C_S1);            H5Tset_size(memtype, sdim);            if (H5Aread(attr_id, memtype, *rdata) >= 0)                success = AH5_TRUE;            else                free(*rdata);            H5Tclose(memtype);            H5Tclose(filetype);            H5Aclose(attr_id);        }    if (!success)        *rdata = NULL;    return success;}
开发者ID:ThinkManhattan,项目名称:amelet-hdf,代码行数:29,


示例17: e5_read_attr_list_float

estatus_te5_read_attr_list_float(    hid_t e5_group_id, e5_attr_float* e5_attr_list){    int i;    hid_t e5_attribute_id;    estatus_t status = E5_SUCCESS;    for(i = 0; e5_attr_list && e5_attr_list[i].name != 0; i++)    {        e5_attr_float *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, H5T_NATIVE_FLOAT, &(attr->value));        H5Aclose(e5_attribute_id);        e5_info(e5_group_id, "Read attribute [type='float', name='%s', value='%f']/n",  attr->name, attr->value);    }    return status;}
开发者ID:voidcycles,项目名称:void,代码行数:29,


示例18: read_attribute

bool read_attribute(const char * name, const H5ID & dataset, T & value){    H5ID attribute(H5Aopen_name(dataset, name), H5Aclose);    if (!attribute)        return false;    herr_t status = H5Aread(attribute, H5T_NATIVE_FLOAT, &value);    return status >= 0;}
开发者ID:yonggang985,项目名称:Touch,代码行数:8,


示例19: mhdf_getElemTypeName

void mhdf_getElemTypeName( mhdf_FileHandle file_handle,                      const char* elem_handle,                      char* buffer, size_t buf_len,                      mhdf_Status* status ){  FileHandle* file_ptr;  hid_t elem_id, type_id, attr_id;  char bytes[16];  herr_t rval;  API_BEGIN;   if (NULL == buffer || buf_len < 2)  {    mhdf_setFail( status, "invalid input" );    return;  }  buffer[0] = '/0';    file_ptr = (FileHandle*)(file_handle);  if (!mhdf_check_valid_file( file_ptr, status ))    return;    elem_id = mhdf_elem_group_from_handle( file_ptr, elem_handle, status );  if (elem_id < 0) return;    attr_id = H5Aopen_name( elem_id, ELEM_TYPE_ATTRIB );  H5Gclose( elem_id );  if (attr_id < 0)  {    mhdf_setFail( status, "Missing element type attribute.  Invalid file." );    return;  }    type_id = H5Aget_type( attr_id );  assert( type_id > 0 );    rval = H5Aread( attr_id, type_id, bytes );  H5Aclose( attr_id );  if (rval < 0)  {    H5Tclose( type_id );    mhdf_setFail( status, "Failed to read element type attribute.  Invalid file." );    return;  }    rval = H5Tenum_nameof( type_id, bytes, buffer, buf_len );  H5Tclose( type_id );  if (rval < 0)  {    mhdf_setFail( status, "Invalid datatype for element type attribute.  Invalid file." );    return;  }    mhdf_setOkay( status );    API_END;  return ;}
开发者ID:chrismullins,项目名称:moab,代码行数:58,


示例20: get_cols

/* fetch num_cols and the col for a particular trackname */void get_cols(chromosome_t *chromosome, char *trackname, hsize_t *num_cols,              hsize_t *col) {  hid_t attr, root, dataspace, datatype;  hsize_t data_size, cell_size, num_cells;  char *attr_data;  /* Tracknames are stored in the attributes of the root group of each file */  root = H5Gopen(chromosome->h5group, "/", H5P_DEFAULT);  assert(root >= 0);  attr = H5Aopen_name(root, "tracknames");  assert(attr >= 0);  dataspace = H5Aget_space(attr);  assert(dataspace >= 0);  assert(H5Sget_simple_extent_dims(dataspace, num_cols, NULL) == 1);  assert(H5Sclose(dataspace) >= 0);  if (trackname && col) {    datatype = H5Aget_type(attr);    assert(datatype >= 0);    assert(H5Tget_class(datatype) == H5T_STRING);    cell_size = H5Tget_size(datatype);    assert(cell_size > 0);    data_size = H5Aget_storage_size(attr);    assert(data_size > 0);    num_cells = data_size / cell_size;    /* allocate room for tracknames */    attr_data = xmalloc(data_size);    assert(attr_data);    assert(H5Aread(attr, datatype, attr_data) >= 0);    *col = 0;    for (*col = 0; *col <= num_cells; (*col)++) {      if (*col == num_cells) {        fprintf(stderr, "can't find trackname: %s/n", trackname);        free(attr_data);        exit(EXIT_FAILURE);      } else {        if (!strncmp(attr_data + (*col * cell_size), trackname, cell_size)) {          break;        }      }    }    /* clean up read tracknames */    free(attr_data);  }  assert(H5Aclose(attr) >= 0);}
开发者ID:weallen,项目名称:Seqwill,代码行数:58,


示例21: H5Aopen

bool seissol::checkpoint::h5::Wavefield::validate(hid_t h5file) const{	// Turn of error printing	H5ErrHandler errHandler;	// Check #partitions	hid_t h5attr = H5Aopen(h5file, "partitions", H5P_DEFAULT);	if (h5attr < 0) {		logWarning(rank()) << "Checkpoint does not have a partition attribute.";		return false;	}	int p;	herr_t err = H5Aread(h5attr, H5T_NATIVE_INT, &p);	checkH5Err(H5Aclose(h5attr));	if (err < 0 || p != partitions()) {		logWarning(rank()) << "Partitions in checkpoint do not match.";		return false;	}	// Check dimensions	hid_t h5data = H5Dopen(h5file, "values", H5P_DEFAULT);	if (h5data < 0) {		logWarning(rank()) << "Checkpoint does not contains a data array.";		return false;	}	hid_t h5space = H5Dget_space(h5data);	checkH5Err(H5Dclose(h5data));	if (h5space < 0) {		logWarning(rank()) << "Could not get space identifier in checkpoint.";		return false;	}	bool isValid = true;	int dims = H5Sget_simple_extent_ndims(h5space);	if (dims != 1) {		isValid = false;		logWarning(rank()) << "Number of dimensions in checkpoint does not match.";	} else {		hsize_t dimSize;		if (H5Sget_simple_extent_dims(h5space, &dimSize, 0L) != 1) {			isValid = false;			logWarning(rank()) << "Could not get dimension sizes of checkpoint.";		} else {			if (dimSize != numTotalElems()) {				isValid = false;				logWarning(rank()) << "Number of elements in checkpoint does not match.";			}		}	}	checkH5Err(H5Sclose(h5space));	return isValid;}
开发者ID:jjww2015,项目名称:SeisSol,代码行数:56,


示例22: compare_and_read_scalar_attribute_internal

	void compare_and_read_scalar_attribute_internal(hid_t attribute_id, hid_t type_id, hid_t expected_type, void* buffer)	{		if(H5Tequal(type_id, expected_type))		{			herr_t status = H5Aread(attribute_id, type_id, buffer);			if(status >= 0)				return;		}		throw std::runtime_error("type mismatch");	}
开发者ID:klindworth,项目名称:cvwidgets,代码行数:10,


示例23: get_attr

void get_attr(hid_t loc, const char *name, hid_t mem_type_id, void *buf) {  hid_t attr;  attr = H5Aopen_name(loc, name);  assert(attr >= 0);  assert(H5Aread(attr, mem_type_id, buf) >= 0);  assert(H5Aclose(attr) >= 0);}
开发者ID:weallen,项目名称:Seqwill,代码行数:10,


示例24: get_attribute_str

static herr_t get_attribute_str(hid_t obj_id,                                const char *attr_name,                                char **data){    hid_t attr_id;    hid_t attr_type;    size_t type_size;    herr_t status;    *data = NULL;    attr_id = H5Aopen_name(obj_id, attr_name);    if (attr_id < 0)        return -1;    attr_type = H5Aget_type(attr_id);    if (attr_type < 0)        goto out;    /* Get the size */    type_size = H5Tget_size(attr_type);    if (type_size < 0)        goto out;    /* malloc enough space for the string, plus 1 for trailing '/0' */    *data = (char *)malloc(type_size + 1);    status = H5Aread(attr_id, attr_type, *data);    if (status < 0)        goto out;    /* Set the last character to '/0' in case we are dealing with     * null padded or space padded strings     */    (*data)[type_size] = '/0';    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);    if (*data)        free(*data);    return -1;}
开发者ID:QuLogic,项目名称:citcoms,代码行数:53,


示例25: dataSpaceDimension

char HStringAttribute::read(std::string & str){	const int d = dataSpaceDimension();	char * t = new char[d + 1];	herr_t status = H5Aread(fObjectId, dataType(), t);	if(status < 0)		return 0;	t[d] = '/0';	str = std::string(t);	delete[] t;	return 1;}
开发者ID:ahmidou,项目名称:aphid,代码行数:12,


示例26: ReadStringsT

voidReadStringsT( hid_t iParent,              const std::string &iAttrName,              size_t iNumStrings,              StringT *oStrings ){    ABCA_ASSERT( iParent >= 0, "Invalid parent in ReadStringsT" );    // Open the attribute.    hid_t attrId = H5Aopen( iParent, iAttrName.c_str(), H5P_DEFAULT );    ABCA_ASSERT( attrId >= 0,                 "Couldn't open attribute named: " << iAttrName );    AttrCloser attrCloser( attrId );    // Checking code.    {        hid_t attrFtype = H5Aget_type( attrId );        DtypeCloser dtypeCloser( attrFtype );        hid_t nativeDtype = GetNativeDtype<CharT>();        ABCA_ASSERT( H5Tget_class( attrFtype ) ==                     H5Tget_class( nativeDtype ) &&                     H5Tget_sign( attrFtype ) ==                     H5Tget_sign( nativeDtype ),                     "Invalid datatype for stringT" );    }    hid_t attrSpace = H5Aget_space( attrId );    ABCA_ASSERT( attrSpace >= 0,                 "Couldn't get dataspace for attribute: " << iAttrName );    DspaceCloser dspaceCloser( attrSpace );    hssize_t numPoints = H5Sget_simple_extent_npoints( attrSpace );    ABCA_ASSERT( numPoints > 0,                 "Degenerate string dimensions in ReadStringsT" );    // Create temporary char storage buffer.    std::vector<CharT> charStorage( ( size_t )( 1 + numPoints ),                                    ( CharT )0 );    // Read into it.    herr_t status = H5Aread( attrId, GetNativeDtype<CharT>(),                             ( void * )&charStorage.front() );    ABCA_ASSERT( status >= 0, "Couldn't read from attribute: " << iAttrName );    // Extract 'em.    ExtractStrings( oStrings, ( const CharT * )&charStorage.front(),                    1 + numPoints, iNumStrings );}
开发者ID:ryutaro765,项目名称:Alembic,代码行数:51,


示例27: hdf5_read

int hdf5_read(void *output, hid_t file, char *n_group, char *n_dset, char *n_attr, int c){    hid_t memtype, type, group=-1, dset=-1, attr=-1, tmp_id, space;    herr_t status;    size_t sdim;    int ndims;        tmp_id = file;    if(strlen(n_group)>0){        group = H5Gopen(tmp_id, n_group, H5P_DEFAULT);        tmp_id = group;    }    if(strlen(n_dset)>0){        dset = H5Dopen(tmp_id, n_dset, H5P_DEFAULT);        tmp_id = dset;    }    if(strlen(n_attr)>0){        attr = H5Aopen(tmp_id, n_attr, H5P_DEFAULT);        tmp_id = attr;    }        if(c == 'c'){        memtype = H5Tcopy (H5T_C_S1);        type = H5Aget_type (tmp_id);        sdim = H5Tget_size (type);        sdim++;        status = H5Tset_size (memtype, sdim);    }    else if(c == 'd'){        memtype = H5T_NATIVE_DOUBLE;    }    else if(c == 'i' || c == 'n'){        memtype = H5T_NATIVE_INT;    }    else if(c == 'f'){        memtype = H5T_NATIVE_FLOAT;    }        if (tmp_id == attr){        status = H5Aread(tmp_id, memtype, output);    }    else if(tmp_id == dset && c == 'n'){        space = H5Dget_space (dset);        ndims = H5Sget_simple_extent_dims (space, output, NULL);    }    else{        return(-1);    }        return(1);}
开发者ID:duanuys,项目名称:GMT5SAR,代码行数:50,


示例28: sizeof

herr_tH5AreadVL_str    (JNIEnv *env, hid_t aid, hid_t tid, jobjectArray buf){    char  **strs;    jstring jstr;    jint    i;    jint    n;    hid_t   sid;    hsize_t dims[H5S_MAX_RANK];    herr_t  status = -1;    n = ENVPTR->GetArrayLength(ENVPAR buf);    strs =(char**)HDcalloc((size_t)n, sizeof(char*));    if (strs == NULL) {        h5JNIFatalError(env, "H5AreadVL_str:  failed to allocate buff for read variable length strings");    } /* end if */    else {        status = H5Aread(aid, tid, strs);        if (status < 0) {            dims[0] = (hsize_t)n;            sid = H5Screate_simple(1, dims, NULL);            H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, strs);            H5Sclose(sid);            HDfree(strs);            h5JNIFatalError(env, "H5AreadVL_str: failed to read variable length strings");        } /* end if */        else {            for (i=0; i < n; i++) {                jstr = ENVPTR->NewStringUTF(ENVPAR strs[i]);                ENVPTR->SetObjectArrayElement(ENVPAR buf, i, jstr);                H5free_memory (strs[i]);            } /* end for */            /*            for repeatedly reading a dataset with a large number of strs (e.g., 1,000,000 strings,            H5Dvlen_reclaim() may crash on Windows because the Java GC will not be able to collect            free space in time. Instead, use "H5free_memory(strs[i])" above to free individual strings            after it is done.            H5Dvlen_reclaim(tid, mem_sid, xfer_plist_id, strs);            */            HDfree(strs);        } /* end else */    } /* end else */    return status;} /* end H5AreadVL_str */
开发者ID:Starlink,项目名称:hdf5,代码行数:50,


示例29: H5Tcopy

std::string HdfAttribute::readString() const{  char name[HDF_MAX_NAME];  hid_t datatype = H5Tcopy( H5T_C_S1 );  H5Tset_size( datatype, HDF_MAX_NAME );  herr_t status = H5Aread( d->id, datatype, name );  if ( status < 0 )  {    //MDAL::debug("Failed to read data!");    return std::string();  }  H5Tclose( datatype );  return std::string( name );}
开发者ID:DelazJ,项目名称:QGIS,代码行数:14,


示例30: nh5aread_c

/*---------------------------------------------------------------------------- * Name:        h5aread_c * Purpose:     Call H5Aread to read an attribute * Inputs:      dset_id - dataset identifier *              mem_type_id - memory datatype identifier *              dims     - array to store dimensions sizes of buf; used only *                         by Fortran routine. * Outputs:     buf      - data buffer * Returns:     0 on success, -1 on failure * Programmer:  Elena Pourmal *              Thursday, August 12, 1999 * Modifications: dims paramete added. *                April 4, 2001 *                Added nh5aread_integer(real,double)_s,1-7 functions to eliminate *                complains about wrong parameters types in h5awrite_c function *                called by Fortran routines. *                                           October 9, 2006 EIP *---------------------------------------------------------------------------*/int_fnh5aread_c (hid_t_f *attr_id, hid_t_f *mem_type_id, void *buf, void UNUSED * dims){    int_f ret_value=0;          /* Return value */     /*      * Call H5Aread function.      */     if (H5Aread((hid_t)*attr_id, (hid_t)*mem_type_id, buf) < 0)         HGOTO_DONE(FAIL);done:     return ret_value;}
开发者ID:MattNapsAlot,项目名称:rHDF5,代码行数:32,



注:本文中的H5Aread函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ H5Awrite函数代码示例
C++ H5Aopen函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。