这篇教程C++ H5Fcreate函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中H5Fcreate函数的典型用法代码示例。如果您正苦于以下问题:C++ H5Fcreate函数的具体用法?C++ H5Fcreate怎么用?C++ H5Fcreate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了H5Fcreate函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: mainintmain(){ printf("/n*** Checking HDF5 dimscales detach./n"); printf("*** Creating a file with two vars with one dimension scale..."); { hid_t fileid, grpid, spaceid, var1_id, var2_id, dimscaleid, cparmsid; hid_t fcpl_id, fapl_id, create_propid, access_propid; hsize_t dims[NDIMS] = {DIM_LEN}; char dimscale_wo_var[STR_LEN]; float data = 42; /* Create file. */ if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) ERR; if (H5Pset_fclose_degree(fapl_id, H5F_CLOSE_STRONG)) ERR; if (H5Pset_cache(fapl_id, 0, CHUNK_CACHE_NELEMS, CHUNK_CACHE_SIZE, CHUNK_CACHE_PREEMPTION) < 0) ERR; if (H5Pset_libver_bounds(fapl_id, H5F_LIBVER_18, H5F_LIBVER_18) < 0) ERR; if ((fcpl_id = H5Pcreate(H5P_FILE_CREATE)) < 0) ERR; if (H5Pset_link_creation_order(fcpl_id, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED)) < 0) ERR; if (H5Pset_attr_creation_order(fcpl_id, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED)) < 0) ERR; if ((fileid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, fcpl_id, fapl_id)) < 0) ERR; if (H5Pclose(fapl_id) < 0) ERR; if (H5Pclose(fcpl_id) < 0) ERR; if ((grpid = H5Gopen2(fileid, "/", H5P_DEFAULT)) < 0) ERR; /* Create dimension scale. */ if ((create_propid = H5Pcreate(H5P_DATASET_CREATE)) < 0) ERR; if (H5Pset_attr_creation_order(create_propid, H5P_CRT_ORDER_TRACKED| H5P_CRT_ORDER_INDEXED) < 0) ERR; if ((spaceid = H5Screate_simple(1, dims, dims)) < 0) ERR; if ((dimscaleid = H5Dcreate1(grpid, DIMSCALE_NAME, H5T_IEEE_F32BE, spaceid, create_propid)) < 0) ERR; if (H5Sclose(spaceid) < 0) ERR; if (H5Pclose(create_propid) < 0) ERR; sprintf(dimscale_wo_var, "%s%10d", DIM_WITHOUT_VARIABLE, DIM_LEN); if (H5DSset_scale(dimscaleid, dimscale_wo_var) < 0) ERR; /* Create a variable that uses this dimension scale. */ if ((access_propid = H5Pcreate(H5P_DATASET_ACCESS)) < 0) ERR; if (H5Pset_chunk_cache(access_propid, CHUNK_CACHE_NELEMS, CHUNK_CACHE_SIZE, CHUNK_CACHE_PREEMPTION) < 0) ERR; if ((create_propid = H5Pcreate(H5P_DATASET_CREATE)) < 0) ERR; if (H5Pset_fill_value(create_propid, H5T_NATIVE_FLOAT, &data) < 0) ERR; if (H5Pset_layout(create_propid, H5D_CONTIGUOUS) < 0) ERR; if (H5Pset_attr_creation_order(create_propid, H5P_CRT_ORDER_TRACKED| H5P_CRT_ORDER_INDEXED) < 0) ERR; if ((spaceid = H5Screate_simple(NDIMS, dims, dims)) < 0) ERR; if ((var1_id = H5Dcreate2(grpid, VAR1_NAME, H5T_NATIVE_FLOAT, spaceid, H5P_DEFAULT, create_propid, access_propid)) < 0) ERR; if (H5Pclose(create_propid) < 0) ERR; if (H5Pclose(access_propid) < 0) ERR; if (H5Sclose(spaceid) < 0) ERR; if (H5DSattach_scale(var1_id, dimscaleid, 0) < 0) ERR; /* Create another variable that uses this dimension scale. */ if ((access_propid = H5Pcreate(H5P_DATASET_ACCESS)) < 0) ERR; if (H5Pset_chunk_cache(access_propid, CHUNK_CACHE_NELEMS, CHUNK_CACHE_SIZE, CHUNK_CACHE_PREEMPTION) < 0) ERR; if ((create_propid = H5Pcreate(H5P_DATASET_CREATE)) < 0) ERR; if (H5Pset_fill_value(create_propid, H5T_NATIVE_FLOAT, &data) < 0) ERR; if (H5Pset_layout(create_propid, H5D_CONTIGUOUS) < 0) ERR; if (H5Pset_attr_creation_order(create_propid, H5P_CRT_ORDER_TRACKED| H5P_CRT_ORDER_INDEXED) < 0) ERR; if ((spaceid = H5Screate_simple(NDIMS, dims, dims)) < 0) ERR; if ((var2_id = H5Dcreate2(grpid, VAR2_NAME, H5T_NATIVE_FLOAT, spaceid, H5P_DEFAULT, create_propid, access_propid)) < 0) ERR; if (H5Pclose(create_propid) < 0) ERR; if (H5Pclose(access_propid) < 0) ERR; if (H5Sclose(spaceid) < 0) ERR; if (H5DSattach_scale(var2_id, dimscaleid, 0) < 0) ERR; /* Now detach the scales and remove the dimscale. This doesn't * work if I reverse the order of the statements. */ if (H5DSdetach_scale(var2_id, dimscaleid, 0) < 0) ERR; if (H5DSdetach_scale(var1_id, dimscaleid, 0) < 0) ERR; /* Fold up our tents. */ if (H5Dclose(var1_id) < 0) ERR; if (H5Dclose(dimscaleid) < 0) ERR; if (H5Gclose(grpid) < 0) ERR; if (H5Fclose(fileid) < 0) ERR; /* //* Now read the file and check it. *// */ /* { */ /* hid_t fileid, spaceid = 0, datasetid = 0; */ /* hsize_t num_obj, i; */ /* int obj_class; */ /* char obj_name[STR_LEN + 1]; */ /* char dimscale_name[STR_LEN+1]; */ /* htri_t is_scale; */ /* char label[STR_LEN+1]; */ /* int num_scales; */ /* hsize_t dims[1], maxdims[1]; */ /* H5G_stat_t statbuf; */ /* HDF5_OBJID_T dimscale_obj, vars_dimscale_obj; */ /* struct nc_hdf5_link_info link_info; */ /* hsize_t idx = 0; *///.........这里部分代码省略.........
开发者ID:U-238,项目名称:gempak,代码行数:101,
示例2: h5block_init/* initializes hdf5 struct and writes some of the initially known problem properties such as state variable names into hdf5 file*/hdf5block_t* /*freshly allocated struct with ids and size parameters*/h5block_init(char *output_file, /*will create this file for writing*/ ode_model_parameters *omp, /*contains MCMC problem description*/ size_t Samples, /* MCMC sample size*/ const char **x_name, /*ODE model State Variable names, array of strings*/ const char **p_name, /*ODE model parameter names, array of strings*/ const char **f_name)/*ODE model output function names, array of strings*/{ hsize_t *size=malloc(sizeof(hsize_t)*2); hsize_t *chunk_size=malloc(sizeof(hsize_t)*2); hid_t file_id = H5Fcreate(output_file, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); assert(file_id>0); int D=get_number_of_MCMC_variables(omp); int N=get_number_of_state_variables(omp); int P=get_number_of_model_parameters(omp); int F=get_number_of_model_outputs(omp); char *x_names=flatten(x_name, (size_t) N, "; "); char *p_names=flatten(p_name, (size_t) P, "; "); char *f_names=flatten(f_name, (size_t) F, "; "); herr_t NameWriteError=0; NameWriteError&=H5LTmake_dataset_string(file_id,"StateVariableNames",x_names); NameWriteError&=H5LTmake_dataset_string(file_id,"ParameterNames",p_names); NameWriteError&=H5LTmake_dataset_string(file_id,"OutputFunctionNames",f_names); if (NameWriteError){ fprintf(stderr,"[h5block_init] writing (x,p,f)-names into hdf5 file failed."); }/* else { printf("# [main] all names have been written to file C++ H5Fopen函数代码示例 C++ H5Fclose函数代码示例
|