• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ H5Aread函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了H5Aread函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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,代码来源:VsH5Attribute.C


示例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,代码来源:AMRreader.C


示例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,代码来源:access_tracing.cpp


示例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,代码来源:t_mdset.c


示例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,代码来源:hdf5_wrapper.c


示例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,代码来源:AbstractHdf5Access.cpp


示例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,代码来源:HIntAttribute.cpp


示例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,代码来源:Citcoms_Hdf2Vtk.c


示例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,代码来源:Citcoms_Hdf2Vtk.c


示例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 */
开发者ID:ngcurrier,项目名称:ProteusCFD,代码行数:36,代码来源:h5aImp.c


示例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;
}
开发者ID:ThinkManhattan,项目名称:amelet-hdf,代码行数:26,代码来源:complextype.c


示例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,代码来源:h5Dataset.c


示例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;
}
开发者ID:jb--,项目名称:h5xx,代码行数:34,代码来源:attribute.hpp


示例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;
}
开发者ID:voidcycles,项目名称:void,代码行数:34,代码来源:e5.c


示例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,代码来源:h5_readDataFromFile_v1.c


示例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,代码来源:ah5_attribute.c


示例17: e5_read_attr_list_float

estatus_t
e5_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,代码来源:e5.c


示例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,代码来源:Compartment_Report_HDF5_File_Reader.cpp


示例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,代码来源:file.c


示例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,代码来源:genomedata_load_data.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ H5Awrite函数代码示例发布时间:2022-05-30
下一篇:
C++ H5Aopen函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap