这篇教程C++ H5Pclose函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中H5Pclose函数的典型用法代码示例。如果您正苦于以下问题:C++ H5Pclose函数的具体用法?C++ H5Pclose怎么用?C++ H5Pclose使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了H5Pclose函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: main//.........这里部分代码省略......... /* check if all the parents groups exist. skip root group */ for (i = 1; i < len; i++) { if ('/'==oname_dst[i]) { str_ptr = (char*)HDcalloc((size_t)i+1, sizeof(char)); HDstrncpy (str_ptr, oname_dst, (size_t)i); str_ptr[i]='/0'; if (H5Lexists(fid_dst, str_ptr, H5P_DEFAULT) <= 0) { error_msg("group <%s> doesn't exist. Use -p to create parent groups./n", str_ptr); HDfree(str_ptr); goto error; } HDfree(str_ptr); } } } /*------------------------------------------------------------------------- * do the copy *-------------------------------------------------------------------------*/ if(verbose) linkinfo.opt.msg_mode = 1; li_ret = H5tools_get_symlink_info(fid_src, oname_src, &linkinfo, 1); if (li_ret == 0) /* dangling link */ { if(H5Lcopy(fid_src, oname_src, fid_dst, oname_dst, H5P_DEFAULT, H5P_DEFAULT) < 0) goto error; } else /* valid link */ { if (H5Ocopy(fid_src, /* Source file or group identifier */ oname_src, /* Name of the source object to be copied */ fid_dst, /* Destination file or group identifier */ oname_dst, /* Name of the destination object */ ocpl_id, /* Object copy property list */ lcpl_id)<0) /* Link creation property list */ goto error; } /* free link info path */ if (linkinfo.trg_path) HDfree(linkinfo.trg_path); /* close propertis */ if(H5Pclose(ocpl_id)<0) goto error; if(H5Pclose(lcpl_id)<0) goto error; /* close files */ if (H5Fclose(fid_src)<0) goto error; if (H5Fclose(fid_dst)<0) goto error; if (fname_src) HDfree(fname_src); if (fname_dst) HDfree(fname_dst); if (oname_dst) HDfree(oname_dst); if (oname_src) HDfree(oname_src); h5tools_close(); return EXIT_SUCCESS;error: printf("Error in copy...Exiting/n"); /* free link info path */ if (linkinfo.trg_path) HDfree(linkinfo.trg_path); H5E_BEGIN_TRY { H5Pclose(ocpl_id); H5Pclose(lcpl_id); H5Fclose(fid_src); H5Fclose(fid_dst); } H5E_END_TRY; if (fname_src) HDfree(fname_src); if (fname_dst) HDfree(fname_dst); if (oname_dst) HDfree(oname_dst); if (oname_src) HDfree(oname_src); h5tools_close(); return EXIT_FAILURE;}
开发者ID:Len3d,项目名称:appleseed,代码行数:101,
示例2: main//.........这里部分代码省略......... for(k = 0; k < n; k++) buffer[k] = value; start[0] = j; start[1] = 0; start[2] = 0; if(H5Sselect_hyperslab(fsid, H5S_SELECT_SET, start, NULL, UC_5_PLANE, NULL) < 0) UC_ERROR if(H5Dwrite(did, H5T_NATIVE_INT, msid, fsid, H5P_DEFAULT, buffer) < 0) UC_ERROR } /* end for */ /* set up hyperslabs for source and destination datasets */ start[0] = 0; start[1] = 0; start[2] = 0; if(H5Sselect_hyperslab(src_sid, H5S_SELECT_SET, start, NULL, UC_5_SOURCE_MAX_DIMS, NULL) < 0) UC_ERROR start[0] = map_start; if(H5Sselect_hyperslab(vds_sid, H5S_SELECT_SET, start, stride, count, UC_5_PLANE) < 0) UC_ERROR map_start += 1; /* Add VDS mapping */ if(H5Pset_virtual(vds_dcplid, vds_sid, UC_5_FILE_NAMES[i], UC_5_SOURCE_DSET_PATH, src_sid) < 0) UC_ERROR /* close */ if(H5Sclose(msid) < 0) UC_ERROR if(H5Sclose(fsid) < 0) UC_ERROR if(H5Sclose(src_sid) < 0) UC_ERROR if(H5Pclose(src_dcplid) < 0) UC_ERROR if(H5Dclose(did) < 0) UC_ERROR if(H5Fclose(fid) < 0) UC_ERROR free(buffer); } /* end for */ /******************* * Create VDS file * *******************/ /* file */ if((fid = H5Fcreate(UC_5_VDS_FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) UC_ERROR /* dataset */ if((did = H5Dcreate2(fid, UC_5_VDS_DSET_NAME, UC_5_VDS_DATATYPE, vds_sid, H5P_DEFAULT, vds_dcplid, H5P_DEFAULT)) < 0) UC_ERROR /* close */ if(H5Pclose(vds_dcplid) < 0) UC_ERROR if(H5Sclose(vds_sid) < 0) UC_ERROR if(H5Dclose(did) < 0) UC_ERROR if(H5Fclose(fid) < 0) UC_ERROR return EXIT_SUCCESS;error: H5E_BEGIN_TRY { if(src_sid >= 0) (void)H5Sclose(src_sid); if(src_dcplid >= 0) (void)H5Pclose(src_dcplid); if(vds_sid >= 0) (void)H5Sclose(vds_sid); if(vds_dcplid >= 0) (void)H5Pclose(vds_dcplid); if(fid >= 0) (void)H5Fclose(fid); if(did >= 0) (void)H5Dclose(did); if(msid >= 0) (void)H5Sclose(msid); if(fsid >= 0) (void)H5Sclose(fsid); if(buffer != NULL) free(buffer); } H5E_END_TRY return EXIT_FAILURE;} /* end main() */
开发者ID:ElaraFX,项目名称:hdf5,代码行数:101,
示例3: mainint main(void){ hid_t file=(-1), fapl, space=(-1), dset=(-1); char dname[]="dataset"; int i, j; int buf[FAMILY_NUMBER][FAMILY_SIZE]; hsize_t dims[2]={FAMILY_NUMBER, FAMILY_SIZE}; /* Set property list and file name for FAMILY driver */ if ((fapl=H5Pcreate(H5P_FILE_ACCESS)) < 0) { perror ("H5Pcreate"); exit (1); } if(H5Pset_fapl_family(fapl, (hsize_t)FAMILY_SIZE, H5P_DEFAULT) < 0) { perror ("H5Pset_fapl_family"); exit (1); } if((file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) { perror("H5Fcreate"); exit(1); } /* Create and write dataset */ if((space = H5Screate_simple(2, dims, NULL)) < 0) { perror("H5Screate_simple"); exit(1); } if((dset = H5Dcreate2(file, dname, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) { perror("H5Dcreate2"); exit(1); } for(i = 0; i<FAMILY_NUMBER; i++) for(j = 0; j<FAMILY_SIZE; j++) buf[i][j] = i * 10000 + j; if(H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) { perror("H5Dwrite"); exit(1); } if(H5Sclose(space) < 0) { perror ("H5Sclose"); exit (1); } if(H5Dclose(dset) < 0) { perror ("H5Dclose"); exit (1); } if(H5Pclose(fapl) < 0) { perror ("H5Pclose"); exit (1); } if(H5Fclose(file) < 0) { perror ("H5Fclose"); exit (1); } puts(" PASSED"); fflush(stdout); return 0;}
开发者ID:ihutch,项目名称:sceptic3D,代码行数:71,
示例4: test_ohdr_cache/* * Verify that object headers are held in the cache until they are linked * to a location in the graph, or assigned an ID. This is done by * creating an object header, then forcing it out of the cache by creating * local heaps until the object header is evicted from the cache, then * modifying the object header. The refcount on the object header is * checked as verifying that the object header has remained in the cache. */static herr_ttest_ohdr_cache(char *filename, hid_t fapl){ hid_t file = -1; /* File ID */ hid_t my_fapl; /* FAPL ID */ hid_t my_dxpl; /* DXPL ID */ H5AC_cache_config_t mdc_config; /* Metadata cache configuration info */ H5F_t *f = NULL; /* File handle */ H5HL_t *lheap, *lheap2, *lheap3; /* Pointer to local heaps */ haddr_t lheap_addr, lheap_addr2, lheap_addr3; /* Local heap addresses */ H5O_loc_t oh_loc; /* Object header location */ time_t time_new; /* Time value for modification time message */ unsigned rc; /* Refcount for object */ TESTING("object header creation in cache"); /* Make a copy of the FAPL */ if((my_fapl = H5Pcopy(fapl)) < 0) FAIL_STACK_ERROR /* Tweak down the size of the metadata cache to only 64K */ mdc_config.version = H5AC__CURR_CACHE_CONFIG_VERSION; if(H5Pget_mdc_config(my_fapl, &mdc_config) < 0) FAIL_STACK_ERROR mdc_config.set_initial_size = TRUE; mdc_config.initial_size = 32 * 1024; mdc_config.max_size = 64 * 1024; mdc_config.min_size = 8 * 1024; if(H5Pset_mdc_config(my_fapl, &mdc_config) < 0) FAIL_STACK_ERROR /* Make a copy of the default DXPL */ if((my_dxpl = H5Pcopy(H5P_DATASET_XFER_DEFAULT)) < 0) FAIL_STACK_ERROR /* Create the file to operate on */ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) FAIL_STACK_ERROR if(H5Pclose(my_fapl) < 0) FAIL_STACK_ERROR if(NULL == (f = (H5F_t *)H5I_object(file))) FAIL_STACK_ERROR /* Create object (local heap) that occupies most of cache */ if(H5HL_create(f, my_dxpl, (31 * 1024), &lheap_addr) < 0) FAIL_STACK_ERROR /* Protect local heap (which actually pins it in the cache) */ if(NULL == (lheap = H5HL_protect(f, my_dxpl, lheap_addr, H5AC_READ))) FAIL_STACK_ERROR /* Create an object header */ HDmemset(&oh_loc, 0, sizeof(oh_loc)); if(H5O_create(f, my_dxpl, (size_t)2048, (size_t)1, H5P_GROUP_CREATE_DEFAULT, &oh_loc/*out*/) < 0) FAIL_STACK_ERROR /* Query object header information */ rc = 0; if(H5O_get_rc(&oh_loc, my_dxpl, &rc) < 0) FAIL_STACK_ERROR if(0 != rc) TEST_ERROR /* Create object (local heap) that occupies most of cache */ if(H5HL_create(f, my_dxpl, (31 * 1024), &lheap_addr2) < 0) FAIL_STACK_ERROR /* Protect local heap (which actually pins it in the cache) */ if(NULL == (lheap2 = H5HL_protect(f, my_dxpl, lheap_addr2, H5AC_READ))) FAIL_STACK_ERROR /* Unprotect local heap (which actually unpins it from the cache) */ if(H5HL_unprotect(lheap2) < 0) FAIL_STACK_ERROR /* Create object header message in new object header */ time_new = 11111111; if(H5O_msg_create(&oh_loc, H5O_MTIME_NEW_ID, 0, 0, &time_new, my_dxpl) < 0) FAIL_STACK_ERROR /* Create object (local heap) that occupies most of cache */ if(H5HL_create(f, my_dxpl, (31 * 1024), &lheap_addr3) < 0) FAIL_STACK_ERROR /* Protect local heap (which actually pins it in the cache) */ if(NULL == (lheap3 = H5HL_protect(f, my_dxpl, lheap_addr3, H5AC_READ))) FAIL_STACK_ERROR /* Unprotect local heap (which actually unpins it from the cache) */ if(H5HL_unprotect(lheap3) < 0) FAIL_STACK_ERROR//.........这里部分代码省略.........
开发者ID:AndyHuang7601,项目名称:EpicGames-UnrealEngine,代码行数:101,
示例5: H5Pcreate int FileIO::create(Setup *setup) { hid_t file_plist = H5Pcreate(H5P_FILE_ACCESS);#ifdef GKC_PARALLEL_MPI // pass some information onto the underlying MPI_File_open call MPI_Info file_info; check(MPI_Info_create(&file_info), DMESG("File info")); /* H5Pset_sieve_buf_size(file_plist, 262144); H5Pset_alignment(file_plist, 524288, 262144); MPI_Info_set(file_info, (char *) "access_style" , (char *) "write_once"); MPI_Info_set(file_info, (char *) "collective_buffering", (char *) "true"); MPI_Info_set(file_info, (char *) "cb_block_size" , (char *) "1048576"); MPI_Info_set(file_info, (char *) "cb_buffer_size" , (char *) "4194304"); * */ check( H5Pset_fapl_mpio(file_plist, parallel->Comm[DIR_ALL], file_info), DMESG("Set MPI Property"));#endif file = check(H5Fcreate(outputFileName.c_str(), (overwriteFile ? H5F_ACC_TRUNC : H5F_ACC_EXCL), H5P_DEFAULT, file_plist ), DMESG("H5FCreate : HDF5 File (File already exists ? use -f to overwrite) : " + outputFileName)); check( H5Pclose(file_plist), DMESG("H5Pclose"));#ifdef GKC_PARALLEL_MPI MPI_Info_free(&file_info);#endif //////////////////////////////////////////////////////////////// Info Group //////////////////////////////////////////////////////// hid_t infoGroup = check(H5Gcreate(file, "/Info",H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT), DMESG("Error creating group file for Phasespace : H5Gcreate")); check(H5LTset_attribute_string(infoGroup, ".", "Output", outputFileName.c_str()), DMESG("H5LTset_attribute")); check(H5LTset_attribute_string(infoGroup, ".", "Input", inputFileName.c_str()), DMESG("H5LTset_attribute")); check(H5LTset_attribute_string(infoGroup, ".", "Version", PACKAGE_VERSION), DMESG("H5LTset_attribute")); // Some Simulation specific stuff //check(H5LTset_attribute_string(infoGroup, ".", "Solver", ((setup->Solver & VL_LIN) ? "Linear" : "Non-Linear")), DMESG("H5LTset_attribute")); //heck(H5LTset_attribute_string(infoGroup, ".", "Type", ((setup->VlasovType & VLASOV_LOCAL ) ? "Local" : "Global" )), DMESG("H5LTset_attribute")); //heck(H5LTset_attribute_string(infoGroup, ".", "FFTSolverS", ((setup->VlasovType & VLASOV_LOCAL ) ? "Local" : "Global" )), DMESG("H5LTset_attribute")); //check(H5LTset_attribute_string(infoGroup, ".", "Initial Condition", setup->PerturbationMethod.c_str()), DMESG("H5LTset_attribute")); check(H5LTset_attribute_string(infoGroup, ".", "Info", info.c_str()), DMESG("H5LTset_attribute")); check(H5LTset_attribute_string(infoGroup, ".", "Config", setup->configFileString.c_str()), DMESG("H5LTset_attribute")); H5Gclose(infoGroup); /// Wrote setup constants, ugly here //// hid_t constantsGroup = check(H5Gcreate(file, "/Constants",H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT), DMESG("Error creating group file for Phasespace : H5Gcreate")); // if (!setup->parser_constants.empty()) { std::vector<std::string> const_vec = Setup::split(setup->parser_constants, ","); for(int s = 0; s < const_vec.size(); s++) { std::vector<std::string> key_value = Setup::split(const_vec[s],"="); double value = Setup::string_to_double(key_value[1]); int dim[] = { 1 }; // check(H5LTmake_dataset_double(constantsGroup, Setup::trimLower(key_value[0], false).c_str(), 1, dim, &value ), DMESG("Write Constants Attributes")); check(H5LTset_attribute_double(constantsGroup, ".", Setup::trimLower(key_value[0], false).c_str(), &value, 1), DMESG("H5LTset_attribute")); //check(H5LTset_attribute_double(constantsGroup, ".", Setup::trimLower(key_value[0], false).c_str(), &(Setup::string_to_double(key_value[1])), 1), DMESG("H5LTset_attribute")); }; } H5Gclose(constantsGroup); // ********************* setup Table for CFL *****************88 cfl_table = new CFLTable(); cfl_offset[0] = HOFFSET( CFLTable, timeStep ); cfl_offset[1] = HOFFSET( CFLTable, time ); cfl_offset[2] = HOFFSET( CFLTable, Fx ); cfl_offset[3] = HOFFSET( CFLTable, Fy ); cfl_offset[4] = HOFFSET( CFLTable, Fz ); cfl_offset[5] = HOFFSET( CFLTable, Fv ); cfl_offset[6] = HOFFSET( CFLTable, total ); for(int i = 1; i < 7; i++) cfl_sizes[i] = sizeof(double); cfl_sizes[0] = sizeof(int); hid_t cfl_type[7]; for(int i = 1; i < 7; i++) cfl_type [i] = H5T_NATIVE_DOUBLE; cfl_type[0] = H5T_NATIVE_INT; const char *cfl_names[7]; cfl_names[0] = "timeStep"; cfl_names[1] = "time"; cfl_names[2] = "Fx"; cfl_names[3] = "Fy"; cfl_names[4] = "Fz"; cfl_names[5] = "Fv"; cfl_names[6] = "Total"; check(H5TBmake_table("cflTable", file, "cfl", (hsize_t) 7, (hsize_t) 0, sizeof(CFLTable), (const char**) cfl_names, cfl_offset, cfl_type, 32, NULL, 0, cfl_table ), DMESG("H5Tmake_table : cfl")); return HELIOS_SUCCESS; }
开发者ID:xyuan,项目名称:gkc,代码行数:95,
示例6: check_file/*------------------------------------------------------------------------- * Function: check_file * * Purpose: Part 2 of a two-part H5Fflush() test. * * Return: Success: 0 * * Failure: 1 * * Programmer: Leon Arber * Sept. 26, 2006. * *------------------------------------------------------------------------- */static intcheck_file(char* name, hid_t fapl){ hid_t file, space, dset, groups, grp, plist; hsize_t ds_size[2]; double error; hsize_t i, j; plist = H5Pcreate(H5P_DATASET_XFER); H5Pset_dxpl_mpio(plist, H5FD_MPIO_COLLECTIVE); if((file = H5Fopen(name, H5F_ACC_RDONLY, fapl)) < 0) goto error; /* Open the dataset */ if((dset = H5Dopen2(file, "dset", H5P_DEFAULT)) < 0) goto error; if((space = H5Dget_space(dset)) < 0) goto error; if(H5Sget_simple_extent_dims(space, ds_size, NULL) < 0) goto error; assert(100==ds_size[0] && 100==ds_size[1]); /* Read some data */ if (H5Dread(dset, H5T_NATIVE_DOUBLE, space, space, plist, the_data) < 0) goto error; for (i=0; i<ds_size[0]; i++) { for (j=0; j<ds_size[1]; j++) { /* * The extra cast in the following statement is a bug workaround * for the Win32 version 5.0 compiler. * 1998-11-06 ptl */ error = fabs(the_data[i][j]-(double)(hssize_t)i/((hssize_t)j+1)); if (error>0.0001) { H5_FAILED(); printf(" dset[%lu][%lu] = %g/n", (unsigned long)i, (unsigned long)j, the_data[i][j]); printf(" should be %g/n", (double)(hssize_t)i/(hssize_t)(j+1)); goto error; } } } /* Open some groups */ if((groups = H5Gopen2(file, "some_groups", H5P_DEFAULT)) < 0) goto error; for(i = 0; i < 100; i++) { sprintf(name, "grp%02u", (unsigned)i); if((grp = H5Gopen2(groups, name, H5P_DEFAULT)) < 0) goto error; if(H5Gclose(grp) < 0) goto error; } if(H5Gclose(groups) < 0) goto error; if(H5Dclose(dset) < 0) goto error; if(H5Fclose(file) < 0) goto error; if(H5Pclose(plist) < 0) goto error; if(H5Sclose(space) < 0) goto error; return 0;error: H5E_BEGIN_TRY { H5Pclose(plist); H5Gclose(groups); H5Dclose(dset); H5Fclose(file); H5Sclose(space); } H5E_END_TRY; return 1;}
开发者ID:ElaraFX,项目名称:hdf5,代码行数:80,
示例7: writehdf5file//.........这里部分代码省略......... * | | | | | * - +----+ - -+- * | | * | | * +-------|----|-------+ * localnx * * In this case the blocksizes are (localnx,localny) and the offsets are * (offx,offy) = ((myx)/nxp*globalnx, (myy/nyp)*globalny) */ offsets[0] = (rundata.globalnx/rundata.npx)*rundata.myx; offsets[1] = (rundata.globalny/rundata.npy)*rundata.myy; blocks[0] = rundata.localnx; blocks[1] = rundata.localny; strides[0] = strides[1] = 1; counts[0] = counts[1] = 1; /* select this subset of the density variable's space in the file */ globaldensspace = H5Dget_space(dens_dataset_id); H5Sselect_hyperslab(globaldensspace,H5S_SELECT_SET, offsets, strides, counts, blocks); /* For the velocities, it's the same thing but there's a count of two, * (one for each velocity component) */ offsets[1] = (rundata.globalnx/rundata.npx)*rundata.myx; offsets[2] = (rundata.globalny/rundata.npy)*rundata.myy; blocks[1] = rundata.localnx; blocks[2] = rundata.localny; strides[0] = strides[1] = strides[2] = 1; counts[0] = 2; counts[1] = counts[2] = 1; offsets[0] = 0; blocks[0] = 1; globalvelspace = H5Dget_space(vel_dataset_id); H5Sselect_hyperslab(globalvelspace,H5S_SELECT_SET, offsets, strides, counts, blocks); /* Write the data. We're writing it from memory, where it is saved * in NATIVE_DOUBLE format */ status = H5Dwrite(dens_dataset_id, H5T_NATIVE_DOUBLE, loc_dens_dataspace_id, globaldensspace, dist_id, &(dens[0][0])); status = H5Dwrite(vel_dataset_id, H5T_NATIVE_DOUBLE, loc_vel_dataspace_id, globalvelspace, dist_id, &(vel[0][0][0])); /* We'll create another group for related info and put some things in there */ { hid_t other_group_id; hid_t timestep_id, timestep_space; hid_t comptime_id, comptime_space; hid_t author_id, author_space, author_type; char *authorname="Jonathan Dursi"; int timestep=13; float comptime=81.773; /* create group */ other_group_id = H5Gcreate(file_id,"/OtherStuff", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* scalar space, data for integer timestep */ timestep_space = H5Screate(H5S_SCALAR); timestep_id = H5Dcreate(other_group_id, "Timestep", H5T_STD_U32LE, timestep_space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Dwrite(timestep_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, ×tep); H5Dclose(timestep_id); H5Sclose(timestep_space); /* scalar space, data for floating compute time */ comptime_space = H5Screate(H5S_SCALAR); comptime_id = H5Dcreate(other_group_id, "Compute Time", H5T_IEEE_F32LE, comptime_space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Dwrite(comptime_id, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &comptime); H5Dclose(comptime_id); H5Sclose(comptime_space); /* scalar space, data for author name */ author_space = H5Screate(H5S_SCALAR); author_type = H5Tcopy(H5T_C_S1); /* copy the character type.. */ status = H5Tset_size (author_type, strlen(authorname)); /* and make it longer */ author_id = H5Dcreate(other_group_id, "Simulator Name", author_type, author_space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Dwrite(author_id, author_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, authorname); H5Dclose(author_id); H5Sclose(author_space); H5Tclose(author_type); H5Gclose(other_group_id); } /* End access to groups & data sets and release resources used by them */ status = H5Sclose(dens_dataspace_id); status = H5Dclose(dens_dataset_id); status = H5Sclose(vel_dataspace_id); status = H5Dclose(vel_dataset_id); status = H5Gclose(arr_group_id); status = H5Pclose(fap_id); status = H5Pclose(dist_id); /* Close the file */ status = H5Fclose(file_id); return;}
开发者ID:haghakhani,项目名称:parallel-IO-tutorial,代码行数:101,
示例8: main/*------------------------------------------------------------------------- * Function: main * * Purpose: HDF5 user block unjammer * * Return: Success: 0 * Failure: 1 * * Programmer: * * Modifications: * *------------------------------------------------------------------------- */intmain (int argc, const char *argv[]){ char *ifname; void *edata; H5E_auto2_t func; hid_t ifile; hsize_t usize; htri_t testval; herr_t status; hid_t plist; h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); /* Initialize h5tools lib */ h5tools_init(); /* Disable error reporting */ H5Eget_auto2(H5E_DEFAULT, &func, &edata); H5Eset_auto2(H5E_DEFAULT, NULL, NULL); parse_command_line (argc, argv); if (argc <= (opt_ind)) { error_msg("missing file name/n"); usage (h5tools_getprogname()); return (EXIT_FAILURE); } ifname = HDstrdup (argv[opt_ind]); testval = H5Fis_hdf5 (ifname); if (testval <= 0) { error_msg("Input HDF5 file is not HDF /"%s/"/n", ifname); return (EXIT_FAILURE); } ifile = H5Fopen (ifname, H5F_ACC_RDONLY, H5P_DEFAULT); if (ifile < 0) { error_msg("Can't open input HDF5 file /"%s/"/n", ifname); return (EXIT_FAILURE); } plist = H5Fget_create_plist (ifile); if (plist < 0) { error_msg("Can't get file creation plist for file /"%s/"/n", ifname); return (EXIT_FAILURE); } status = H5Pget_userblock (plist, &usize); if (status < 0) { error_msg("Can't get user block for file /"%s/"/n", ifname); return (EXIT_FAILURE); } printf ("%ld/n", (long) usize); H5Pclose (plist); H5Fclose (ifile); return (EXIT_SUCCESS);}
开发者ID:Starlink,项目名称:hdf5,代码行数:85,
示例9: mainint main(int argc, char **argv){ MPI_Init(&argc, &argv); int mpirank; MPI_Comm_rank(MPI_COMM_WORLD, &mpirank); int nbprocess; MPI_Comm_size(MPI_COMM_WORLD, &nbprocess); if(nbprocess != 3) { print(mpirank, "Please relaunch with three process./n"); return EXIT_FAILURE; } // Open properties of the file hid_t plist_id = H5Pcreate(H5P_FILE_ACCESS); MPI_Info info = MPI_INFO_NULL; // Create the pro herr_t status = H5Pset_fapl_mpio(plist_id, MPI_COMM_WORLD, info); // Create the file hid_t hdf = H5Fcreate("ut_paral2.h5", H5F_ACC_TRUNC, H5P_DEFAULT, plist_id); // close the properties H5Pclose(plist_id); char *message; message = test_assym_low(hdf, mpirank); if(message!=NULL) { printf("%d** %s/n", mpirank, message); return EXIT_FAILURE; } message = test_assym(hdf, mpirank); if(message!=NULL) { printf("%d** %s/n", mpirank, message); return EXIT_FAILURE; } H5Fclose(hdf); MPI_Finalize(); print(mpirank, "SUCCESS/n"); return EXIT_SUCCESS;}
开发者ID:axessim,项目名称:amelethdf-c,代码行数:71,
示例10: woffset void HDFWalkerIOEngine::readAll(hid_t grp, const char* name, Communicate* comm) { int mynode=comm->rank(); int nprocs=comm->size(); vector<int> woffset(nprocs+1,0); const int RANK = 3; hsize_t offset[]={1,1,1}; hsize_t gcount[RANK],count[RANK]; hsize_t stride[]={1,1,1}; hid_t dataset = H5Dopen(grp,name); hid_t dataspace = H5Dget_space(dataset); int rank_n = H5Sget_simple_extent_ndims(dataspace); int status_n = H5Sget_simple_extent_dims(dataspace, gcount, NULL); //assign offsets and size FairDivideLow(gcount[0],nprocs,woffset); offset[0]=woffset[mynode]; offset[1] = 0; offset[2] = 0; count[0]=woffset[mynode+1]-woffset[mynode]; count[1]=gcount[1]; count[2]=gcount[2]; app_log() << " Initial walker distribution: "; std::copy(woffset.begin(),woffset.end(),ostream_iterator<int>(app_log()," ")); app_log() << endl; vector<MCWalkerConfiguration::PosType> posIn(count[0]*count[1]); hid_t memspace = H5Screate_simple(RANK, count, NULL); herr_t status = H5Sselect_hyperslab(dataspace,H5S_SELECT_SET, offset,NULL,count,NULL);#if defined(H5_HAVE_PARALLEL) xfer_plist = H5Pcreate(H5P_DATASET_XFER); H5Pset_dxpl_mpio(xfer_plist,H5FD_MPIO_COLLECTIVE);#else xfer_plist = H5P_DEFAULT;#endif hid_t type_id=get_h5_datatype(posIn[0][0]); status = H5Dread(dataset, type_id, memspace, dataspace, xfer_plist, &(posIn[0][0])); H5Sclose(dataspace); H5Sclose(memspace); H5Dclose(dataset);#if defined(H5_HAVE_PARALLEL) H5Pclose(xfer_plist);#endif int curWalker = W.getActiveWalkers(); if(curWalker) { W.createWalkers(count[0]); } else { W.resize(count[0],count[1]); } MCWalkerConfiguration::iterator it = W.begin()+curWalker; int ii=0; for(int iw=0; iw<count[0]; iw++) { //std::copy(Post_temp[iw],Post_temp[iw+1], (*it)->R.begin()); for(int iat=0; iat < count[1]; iat++,ii++){ (*it)->R(iat) = posIn[ii]; } ++it; } }
开发者ID:digideskio,项目名称:qmcpack,代码行数:66,
示例11: H5Pcreatevoid Simulation3D::dumpFields(std::string filename) { unsigned int p_x = xLine.rank(), p_y = yLine.rank(), p_z = zLine.rank(); hsize_t start[4]; start[0] = xLine.rank()*blockSize; start[1] = yLine.rank()*blockSize; start[2] = zLine.rank()*blockSize; start[3] = 0; hsize_t rhsx_start[3]; rhsx_start[0] = p_y*blockSize; rhsx_start[1] = p_z*blockSize; rhsx_start[2] = p_x*blockSize; hsize_t rhsy_start[3]; rhsy_start[0] = p_x*blockSize; rhsy_start[1] = p_z*blockSize; rhsy_start[2] = p_y*blockSize; hsize_t rhsz_start[3]; rhsz_start[0] = p_x*blockSize; rhsz_start[1] = p_y*blockSize; rhsz_start[2] = p_z*blockSize; hsize_t rhs_count[3]; rhs_count[0] = blockSize; rhs_count[1] = blockSize; rhs_count[2] = blockSize; hsize_t count[4]; count[0] = blockSize; count[1] = blockSize; count[2] = blockSize; count[3] = 3; hsize_t dims[4]; dims[0] = blockSize*procsX; dims[1] = blockSize*procsY; dims[2] = blockSize*procsZ; dims[3] = 3; hsize_t mem_dims[4]; mem_dims[0] = blockSize; mem_dims[1] = blockSize; mem_dims[2] = blockSize; mem_dims[3] = 3; hid_t fa_p_list = H5Pcreate(H5P_FILE_ACCESS); H5Pset_fapl_mpio(fa_p_list, world, MPI_INFO_NULL); hid_t file_id=H5Fcreate(filename.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, fa_p_list); H5Pclose(fa_p_list); hsize_t rhs_dims[3]; rhs_dims[0] = blockSize*procsX; rhs_dims[1] = blockSize*procsY; rhs_dims[2] = blockSize*procsZ; hsize_t rhs_mem_dims[3]; rhs_mem_dims[0] = blockSize; rhs_mem_dims[1] = blockSize; rhs_mem_dims[2] = blockSize; hid_t E_filespace = H5Screate_simple(4, dims, NULL); hid_t E_memspace = H5Screate_simple(4, mem_dims, NULL); hid_t B_filespace = H5Screate_simple(4, dims, NULL); hid_t B_memspace = H5Screate_simple(4, mem_dims, NULL); hid_t rhsx_filespace = H5Screate_simple(3, rhs_dims, NULL); hid_t rhsx_memspace = H5Screate_simple(3, rhs_mem_dims, NULL); hid_t rhsy_filespace = H5Screate_simple(3, rhs_dims, NULL); hid_t rhsy_memspace = H5Screate_simple(3, rhs_mem_dims, NULL); hid_t rhsz_filespace = H5Screate_simple(3, rhs_dims, NULL); hid_t rhsz_memspace = H5Screate_simple(3, rhs_mem_dims, NULL); hid_t E_dset_id = H5Dcreate(file_id, "E", H5T_NATIVE_DOUBLE, E_filespace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); hid_t E_wr_p_list = H5Pcreate(H5P_DATASET_XFER); // H5Pset_dxpl_mpio(E_wr_p_list, H5FD_MPIO_COLLECTIVE); H5Sselect_hyperslab(E_filespace, H5S_SELECT_SET, start, NULL, count, NULL); herr_t status = H5Dwrite(E_dset_id, H5T_NATIVE_DOUBLE, E_memspace, E_filespace, E_wr_p_list, E); H5Dclose(E_dset_id); H5Sclose(E_filespace); H5Sclose(E_memspace); H5Pclose(E_wr_p_list); hid_t B_dset_id = H5Dcreate(file_id, "B", H5T_NATIVE_DOUBLE, B_filespace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); hid_t B_wr_p_list = H5Pcreate(H5P_DATASET_XFER); // H5Pset_dxpl_mpio(B_wr_p_list, H5FD_MPIO_COLLECTIVE); H5Sselect_hyperslab(B_filespace, H5S_SELECT_SET, start, NULL, count, NULL); status = H5Dwrite(B_dset_id, H5T_NATIVE_DOUBLE, B_memspace, B_filespace, B_wr_p_list, B); H5Dclose(B_dset_id); H5Sclose(B_filespace); H5Sclose(B_memspace); H5Pclose(B_wr_p_list); hid_t rhsx_dset_id = H5Dcreate(file_id, "rhsx", H5T_NATIVE_DOUBLE, rhsx_filespace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); hid_t rhsx_wr_p_list = H5Pcreate(H5P_DATASET_XFER); // H5Pset_dxpl_mpio(rhsx_wr_p_list, H5FD_MPIO_COLLECTIVE); H5Sselect_hyperslab(rhsx_filespace, H5S_SELECT_SET, rhsx_start, NULL, rhs_count, NULL); status = H5Dwrite(rhsx_dset_id, H5T_NATIVE_DOUBLE, rhsx_memspace, rhsx_filespace, rhsx_wr_p_list, rhsx); H5Dclose(rhsx_dset_id); H5Sclose(rhsx_filespace); H5Sclose(rhsx_memspace); H5Pclose(rhsx_wr_p_list); hid_t rhsy_dset_id = H5Dcreate(file_id, "rhsy", H5T_NATIVE_DOUBLE, rhsy_filespace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); hid_t rhsy_wr_p_list = H5Pcreate(H5P_DATASET_XFER); // H5Pset_dxpl_mpio(rhsy_wr_p_list, H5FD_MPIO_COLLECTIVE); H5Sselect_hyperslab(rhsy_filespace, H5S_SELECT_SET, rhsy_start, NULL, rhs_count, NULL); status = H5Dwrite(rhsy_dset_id, H5T_NATIVE_DOUBLE, rhsy_memspace, rhsy_filespace, rhsy_wr_p_list, rhsy); H5Dclose(rhsy_dset_id); H5Sclose(rhsy_filespace); H5Sclose(rhsy_memspace); H5Pclose(rhsy_wr_p_list); hid_t rhsz_dset_id = H5Dcreate(file_id, "rhsz", H5T_NATIVE_DOUBLE, rhsz_filespace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); hid_t rhsz_wr_p_list = H5Pcreate(H5P_DATASET_XFER); // H5Pset_dxpl_mpio(rhsx_wr_p_list, H5FD_MPIO_COLLECTIVE); H5Sselect_hyperslab(rhsz_filespace, H5S_SELECT_SET, rhsz_start, NULL, rhs_count, NULL); status = H5Dwrite(rhsz_dset_id, H5T_NATIVE_DOUBLE, rhsz_memspace, rhsz_filespace, rhsz_wr_p_list, rhsz);//.........这里部分代码省略.........
开发者ID:adam-higuera,项目名称:adi-prototype,代码行数:101,
示例12: main//.........这里部分代码省略......... if((ret = encode_plist(dcpl1, little_endian, word_length, "testfiles/plist_files/def_dcpl_")) < 0) assert(ret > 0); if((ret = H5Pset_chunk(dcpl1, 1, &chunk_size)) < 0) assert(ret > 0); if((ret = H5Pset_alloc_time(dcpl1, H5D_ALLOC_TIME_LATE)) < 0) assert(ret > 0); ret = H5Tconvert(H5T_NATIVE_INT, H5T_STD_I32BE, (size_t)1, &fill, NULL, H5P_DEFAULT); assert(ret >= 0); if((ret = H5Pset_fill_value(dcpl1, H5T_STD_I32BE, &fill)) < 0) assert(ret > 0); max_size[0] = 100; if((ret = H5Pset_external(dcpl1, "ext1.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int)/4))) < 0) assert(ret > 0); if((ret = H5Pset_external(dcpl1, "ext2.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int)/4))) < 0) assert(ret > 0); if((ret = H5Pset_external(dcpl1, "ext3.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int)/4))) < 0) assert(ret > 0); if((ret = H5Pset_external(dcpl1, "ext4.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int)/4))) < 0) assert(ret > 0); if((ret = encode_plist(dcpl1, little_endian, word_length, "testfiles/plist_files/dcpl_")) < 0) assert(ret > 0); /* release resource */ if((ret = H5Pclose(dcpl1)) < 0) assert(ret > 0); /******* ENCODE/DECODE DAPLS *****/ if((dapl1 = H5Pcreate(H5P_DATASET_ACCESS)) < 0) assert(dapl1 > 0); if((ret = encode_plist(dapl1, little_endian, word_length, "testfiles/plist_files/def_dapl_")) < 0) assert(ret > 0); if((ret = H5Pset_chunk_cache(dapl1, nslots, nbytes, w0)) < 0) assert(ret > 0); if((ret = encode_plist(dapl1, little_endian, word_length, "testfiles/plist_files/dapl_")) < 0) assert(ret > 0); /* release resource */ if((ret = H5Pclose(dapl1)) < 0) assert(ret > 0); /******* ENCODE/DECODE DXPLS *****/ if((dxpl1 = H5Pcreate(H5P_DATASET_XFER)) < 0) assert(dxpl1 > 0); if((ret = encode_plist(dxpl1, little_endian, word_length, "testfiles/plist_files/def_dxpl_")) < 0) assert(ret > 0); if((ret = H5Pset_btree_ratios(dxpl1, 0.2f, 0.6f, 0.2f)) < 0) assert(ret > 0); if((ret = H5Pset_hyper_vector_size(dxpl1, 5)) < 0) assert(ret > 0);#ifdef H5_HAVE_PARALLEL
开发者ID:Starlink,项目名称:hdf5,代码行数:67,
示例13: SetDescriptionbool BAGRasterBand::Initialize( hid_t hDatasetID, const char *pszName ){ SetDescription( pszName ); this->hDatasetID = hDatasetID; hid_t datatype = H5Dget_type( hDatasetID ); dataspace = H5Dget_space( hDatasetID ); int n_dims = H5Sget_simple_extent_ndims( dataspace ); native = H5Tget_native_type( datatype, H5T_DIR_ASCEND ); hsize_t dims[3], maxdims[3]; eDataType = GH5_GetDataType( native ); if( n_dims == 2 ) { H5Sget_simple_extent_dims( dataspace, dims, maxdims ); nRasterXSize = (int) dims[1]; nRasterYSize = (int) dims[0]; } else { CPLError( CE_Failure, CPLE_AppDefined, "Dataset not of rank 2." ); return false; } nBlockXSize = nRasterXSize; nBlockYSize = 1;/* -------------------------------------------------------------------- *//* Check for chunksize, and use it as blocksize for optimized *//* reading. *//* -------------------------------------------------------------------- */ hid_t listid = H5Dget_create_plist( hDatasetID ); if (listid>0) { if(H5Pget_layout(listid) == H5D_CHUNKED) { hsize_t panChunkDims[3]; int nDimSize = H5Pget_chunk(listid, 3, panChunkDims); nBlockXSize = (int) panChunkDims[nDimSize-1]; nBlockYSize = (int) panChunkDims[nDimSize-2]; } int nfilters = H5Pget_nfilters( listid ); H5Z_filter_t filter; char name[120]; size_t cd_nelmts = 20; unsigned int cd_values[20]; unsigned int flags; for (int i = 0; i < nfilters; i++) { filter = H5Pget_filter(listid, i, &flags, (size_t *)&cd_nelmts, cd_values, 120, name); if (filter == H5Z_FILTER_DEFLATE) poDS->SetMetadataItem( "COMPRESSION", "DEFLATE", "IMAGE_STRUCTURE" ); else if (filter == H5Z_FILTER_NBIT) poDS->SetMetadataItem( "COMPRESSION", "NBIT", "IMAGE_STRUCTURE" ); else if (filter == H5Z_FILTER_SCALEOFFSET) poDS->SetMetadataItem( "COMPRESSION", "SCALEOFFSET", "IMAGE_STRUCTURE" ); else if (filter == H5Z_FILTER_SZIP) poDS->SetMetadataItem( "COMPRESSION", "SZIP", "IMAGE_STRUCTURE" ); } H5Pclose(listid); }/* -------------------------------------------------------------------- *//* Load min/max information. *//* -------------------------------------------------------------------- */ if( EQUAL(pszName,"elevation") && GH5_FetchAttribute( hDatasetID, "Maximum Elevation Value", dfMaximum ) && GH5_FetchAttribute( hDatasetID, "Minimum Elevation Value", dfMinimum ) ) bMinMaxSet = true; else if( EQUAL(pszName,"uncertainty") && GH5_FetchAttribute( hDatasetID, "Maximum Uncertainty Value", dfMaximum ) && GH5_FetchAttribute( hDatasetID, "Minimum Uncertainty Value", dfMinimum ) ) bMinMaxSet = true; else if( EQUAL(pszName,"nominal_elevation") && GH5_FetchAttribute( hDatasetID, "max_value", dfMaximum ) && GH5_FetchAttribute( hDatasetID, "min_value", dfMinimum ) ) bMinMaxSet = true; return true;}
开发者ID:imincik,项目名称:pkg-gdal,代码行数:94,
示例14: test_plist_ed//.........这里部分代码省略......... recv_proc = 0; else recv_proc = 1; dcpl = H5Pcreate(H5P_DATASET_CREATE); VRFY((dcpl >= 0), "H5Pcreate succeeded"); ret = H5Pset_chunk(dcpl, 1, &chunk_size); VRFY((ret >= 0), "H5Pset_chunk succeeded"); ret = H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE); VRFY((ret >= 0), "H5Pset_alloc_time succeeded"); ret = H5Pset_fill_value(dcpl, H5T_NATIVE_DOUBLE, &fill); VRFY((ret>=0), "set fill-value succeeded"); max_size[0] = 100; ret = H5Pset_external(dcpl, "ext1.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int)/4)); VRFY((ret>=0), "set external succeeded"); ret = H5Pset_external(dcpl, "ext2.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int)/4)); VRFY((ret>=0), "set external succeeded"); ret = H5Pset_external(dcpl, "ext3.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int)/4)); VRFY((ret>=0), "set external succeeded"); ret = H5Pset_external(dcpl, "ext4.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int)/4)); VRFY((ret>=0), "set external succeeded"); ret = test_encode_decode(dcpl, mpi_rank, recv_proc); VRFY((ret >= 0), "test_encode_decode succeeded"); ret = H5Pclose(dcpl); VRFY((ret >= 0), "H5Pclose succeeded"); /******* ENCODE/DECODE DAPLS *****/ dapl = H5Pcreate(H5P_DATASET_ACCESS); VRFY((dapl >= 0), "H5Pcreate succeeded"); ret = H5Pset_chunk_cache(dapl, nslots, nbytes, w0); VRFY((ret >= 0), "H5Pset_chunk_cache succeeded"); ret = test_encode_decode(dapl, mpi_rank, recv_proc); VRFY((ret >= 0), "test_encode_decode succeeded"); ret = H5Pclose(dapl); VRFY((ret >= 0), "H5Pclose succeeded"); /******* ENCODE/DECODE OCPLS *****/ ocpl = H5Pcreate(H5P_OBJECT_CREATE); VRFY((ocpl >= 0), "H5Pcreate succeeded"); ret = H5Pset_attr_creation_order(ocpl, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED)); VRFY((ret >= 0), "H5Pset_attr_creation_order succeeded"); ret = H5Pset_attr_phase_change(ocpl, 110, 105); VRFY((ret >= 0), "H5Pset_attr_phase_change succeeded"); ret = H5Pset_filter(ocpl, H5Z_FILTER_FLETCHER32, 0, (size_t)0, NULL); VRFY((ret >= 0), "H5Pset_filter succeeded"); ret = test_encode_decode(ocpl, mpi_rank, recv_proc); VRFY((ret >= 0), "test_encode_decode succeeded");
开发者ID:ElaraFX,项目名称:hdf5,代码行数:67,
示例15: test_family_compat/*------------------------------------------------------------------------- * Function: test_family_compat * * Purpose: Tests the backward compatibility for FAMILY driver. * See if we can open files created with v1.6 library. * The source file was created by the test/file_handle.c * of the v1.6 library. Then tools/misc/h5repart.c was * used to concantenated. The command was "h5repart -m 5k * family_file%05d.h5 family_v16_%05d.h5". * * Return: Success: 0 * Failure: -1 * * Programmer: Raymond Lu * June 3, 2005 * *------------------------------------------------------------------------- */static herr_ttest_family_compat(void){ hid_t file = (-1), fapl; hid_t dset; char dname[]="dataset"; char filename[1024]; char pathname[1024], pathname_individual[1024]; char newname[1024], newname_individual[1024]; int counter = 0; TESTING("FAMILY file driver backward compatibility"); /* Set property list and file name for FAMILY driver */ fapl = h5_fileaccess(); if(H5Pset_fapl_family(fapl, (hsize_t)FAMILY_SIZE2, H5P_DEFAULT) < 0) TEST_ERROR; h5_fixname(COMPAT_BASENAME, fapl, filename, sizeof filename); h5_fixname(FILENAME[3], fapl, newname, sizeof newname); pathname[0] = '/0'; HDstrcat(pathname, filename); /* The following code makes the copies of the family files in the source directory. * Since we're going to open the files with write mode, this protects the original * files. */ sprintf(newname_individual, newname, counter); sprintf(pathname_individual, pathname, counter); while (h5_make_local_copy(pathname_individual, newname_individual) >= 0) { counter++; sprintf(newname_individual, newname, counter); sprintf(pathname_individual, pathname, counter); } /* Make sure we can open the file. Use the read and write mode to flush the * superblock. */ if((file = H5Fopen(newname, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR; if((dset = H5Dopen2(file, dname, H5P_DEFAULT)) < 0) TEST_ERROR; if(H5Dclose(dset) < 0) TEST_ERROR; if(H5Fclose(file) < 0) TEST_ERROR; /* Open the file again to make sure it isn't corrupted. */ if((file = H5Fopen(newname, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR; if((dset = H5Dopen2(file, dname, H5P_DEFAULT)) < 0) TEST_ERROR; if(H5Dclose(dset) < 0) TEST_ERROR; if(H5Fclose(file) < 0) TEST_ERROR; h5_cleanup(FILENAME, fapl); PASSED(); return 0;error: H5E_BEGIN_TRY { H5Fclose(file); H5Pclose(fapl); } H5E_END_TRY; return -1;} /* end test_family_compat() */
开发者ID:ArielleBassanelli,项目名称:gempak,代码行数:97,
示例16: test_multiple_ends//.........这里部分代码省略......... CHECK(ret, FAIL, "H5Sselect_hyperslab"); msid = H5Screate_simple(8, mem3_dims, mem3_dims); CHECK(msid, FAIL, "H5Screate_simple"); ret = H5Sselect_all(msid); CHECK(ret, FAIL, "H5Sselect_all"); ret = H5Dread(did, H5T_NATIVE_INT, msid, sid, H5P_DEFAULT, mem3_buffer); CHECK(ret, FAIL, "H5Dread"); ret = H5Dclose(did); CHECK(ret, FAIL, "H5Dclose"); ret = H5Sclose(msid); CHECK(ret, FAIL, "H5Sclose"); for(i=0; i<5; i++) for(j=0; j<3; j++) for(k=0; k<3; k++) for(l=0; l<6; l++) if(data_buf[0][i][j][0][0][k][l][0] != mem3_buffer[0][i][j][0][0][k][l][0]) { TestErrPrintf("%u: Read different values than written at index 0,%d,%d,0,0,%d,%d,0/n", __LINE__, i, j, k, l); } /* ****** Case 4: ****** * Testing the full selections in the fastest-growing end and the slowest-growing end */ did = H5Dopen2(file, dset_name, H5P_DEFAULT); CHECK(did, FAIL, "H5Dopen"); /* Select the elements in the dataset */ ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, mem4_start, mem4_stride, mem4_count, mem4_block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); msid = H5Screate_simple(8, mem4_dims, mem4_dims); CHECK(msid, FAIL, "H5Screate_simple"); ret = H5Sselect_all(msid); CHECK(ret, FAIL, "H5Sselect_all"); ret = H5Dread(did, H5T_NATIVE_INT, msid, sid, H5P_DEFAULT, mem4_buffer); CHECK(ret, FAIL, "H5Dread"); ret = H5Dclose(did); CHECK(ret, FAIL, "H5Dclose"); ret = H5Sclose(msid); CHECK(ret, FAIL, "H5Sclose"); for(i=0; i<4; i++) for(j=0; j<5; j++) for(k=0; k<6; k++) for(l=0; l<2; l++) if(data_buf[i][j][0][0][0][0][k][l] != mem4_buffer[i][j][0][0][0][0][k][l]) { TestErrPrintf("%u: Read different values than written at index %d,%d,0,0,0,0,%d,%d/n", __LINE__, i, j, k, l); } /* ****** Case 5: ****** * Testing the full selections in the fastest-growing end and the slowest-growing end, * and also in the middle dimensions */ did = H5Dopen2(file, dset_name, H5P_DEFAULT); CHECK(did, FAIL, "H5Dopen"); /* Select the elements in the dataset */ ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, mem5_start, mem5_stride, mem5_count, mem5_block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); msid = H5Screate_simple(8, mem5_dims, mem5_dims); CHECK(msid, FAIL, "H5Screate_simple"); ret = H5Sselect_all(msid); CHECK(ret, FAIL, "H5Sselect_all"); ret = H5Dread(did, H5T_NATIVE_INT, msid, sid, H5P_DEFAULT, mem5_buffer); CHECK(ret, FAIL, "H5Dread"); ret = H5Dclose(did); CHECK(ret, FAIL, "H5Dclose"); ret = H5Sclose(msid); CHECK(ret, FAIL, "H5Sclose"); for(i=0; i<4; i++) for(j=0; j<5; j++) for(k=0; k<4; k++) for(l=0; l<2; l++) for(m=0; m<6; m++) for(n=0; n<2; n++) if(data_buf[i][j][0][k][l][0][m][n] != mem5_buffer[i][j][0][k][l][0][m][n]) { TestErrPrintf("%u: Read different values than written at index %d,%d,0,%d,%d,0,%d,%d/n", __LINE__, i, j, k, l, m, n); } ret = H5Sclose(sid); CHECK(ret, FAIL, "H5Sclose"); ret = H5Pclose(plid); CHECK(ret, FAIL, "H5Pclose");}
开发者ID:ArielleBassanelli,项目名称:gempak,代码行数:101,
示例17: test_multi//.........这里部分代码省略......... if(H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, memb_addr, TRUE) < 0) TEST_ERROR; h5_fixname(FILENAME[4], fapl, filename, sizeof filename); if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR; if(H5Fclose(file) < 0) TEST_ERROR; /* Test wrong ways to reopen multi files */ if(test_multi_opens(filename) < 0) TEST_ERROR; /* Reopen the file */ if((file=H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR; /* Create and write data set */ if((space=H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR; /* Retrieve the access property list... */ if ((access_fapl = H5Fget_access_plist(file)) < 0) TEST_ERROR; /* Check that the driver is correct */ if(H5FD_MULTI != H5Pget_driver(access_fapl)) TEST_ERROR; /* ...and close the property list */ if (H5Pclose(access_fapl) < 0) TEST_ERROR; /* Check file size API */ if(H5Fget_filesize(file, &file_size) < 0) TEST_ERROR; /* Before any data is written, the raw data file is empty. So * the file size is only the size of b-tree + HADDR_MAX/4. */ if(file_size < HADDR_MAX/4 || file_size > HADDR_MAX/2) TEST_ERROR; if((dset=H5Dcreate2(file, dname, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; for(i=0; i<MULTI_SIZE; i++) for(j=0; j<MULTI_SIZE; j++) buf[i][j] = i*10000+j; if(H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR; if((fapl2=H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; if(H5Pset_multi_type(fapl2, H5FD_MEM_SUPER) < 0) TEST_ERROR; if(H5Fget_vfd_handle(file, fapl2, (void **)&fhandle) < 0) TEST_ERROR; if(*fhandle<0) TEST_ERROR; if(H5Pset_multi_type(fapl2, H5FD_MEM_DRAW) < 0) TEST_ERROR;
开发者ID:ArielleBassanelli,项目名称:gempak,代码行数:67,
示例18: test_singleEnd_selElements//.........这里部分代码省略......... elmts_numb = 12; ret = H5Sselect_elements(sid, H5S_SELECT_SET, elmts_numb, (const hsize_t *)da_elmts1); CHECK(ret, FAIL, "H5Sselect_elements"); /* Dataspace for memory buffer */ msid = H5Screate_simple(4, mem1_dims, mem1_dims); CHECK(msid, FAIL, "H5Screate_simple"); ret = H5Sselect_all(msid); CHECK(ret, FAIL, "H5Sselect_all"); ret = H5Dread(did, H5T_NATIVE_INT, msid, sid, H5P_DEFAULT, mem1_buffer); CHECK(ret, FAIL, "H5Dread"); ret = H5Dclose(did); CHECK(ret, FAIL, "H5Dclose"); ret = H5Sclose(msid); CHECK(ret, FAIL, "H5Sclose"); for(i=0; i<6; i++) for(j=0; j<2; j++) if(da_buffer[0][0][i][j] != mem1_buffer[0][0][i][j]) { TestErrPrintf("%u: Read different values than written at index 0,0,%d,%d/n", __LINE__, i, j); } /* ****** Case 2: ****** * Testing the full selection in the slowest-growing end */ did = H5Dopen2(file, dset_name, H5P_DEFAULT); CHECK(did, FAIL, "H5Dopen"); /* Select the elements in the dataset */ elmts_numb = 6; ret = H5Sselect_elements(sid, H5S_SELECT_SET, elmts_numb, (const hsize_t *)da_elmts2); CHECK(ret, FAIL, "H5Sselect_elements"); /* Dataspace for memory buffer */ msid = H5Screate_simple(4, mem2_dims, mem2_dims); CHECK(msid, FAIL, "H5Screate_simple"); ret = H5Sselect_all(msid); CHECK(ret, FAIL, "H5Sselect_all"); ret = H5Dread(did, H5T_NATIVE_INT, msid, sid, H5P_DEFAULT, mem2_buffer); CHECK(ret, FAIL, "H5Dread"); ret = H5Dclose(did); CHECK(ret, FAIL, "H5Dclose"); ret = H5Sclose(msid); CHECK(ret, FAIL, "H5Sclose"); for(i=0; i<2; i++) for(j=0; j<3; j++) if(da_buffer[i][j][0][0] != mem2_buffer[i][j][0][0]) { TestErrPrintf("%u: Read different values than written at index %d,%d,0,0, da_buffer = %d, mem2_buffer = %d/n", __LINE__, i, j, da_buffer[i][j][0][0], mem2_buffer[i][j][0][0]); } /* ****** Case 3: ****** * Testing the full selection in the middle dimensions */ did = H5Dopen2(file, dset_name, H5P_DEFAULT); CHECK(did, FAIL, "H5Dopen"); /* Select the elements in the dataset */ elmts_numb = 18; ret = H5Sselect_elements(sid, H5S_SELECT_SET, elmts_numb, (const hsize_t *)da_elmts3); CHECK(ret, FAIL, "H5Sselect_elements"); /* Dataspace for memory buffer */ msid = H5Screate_simple(4, mem3_dims, mem3_dims); CHECK(msid, FAIL, "H5Screate_simple"); ret = H5Sselect_all(msid); CHECK(ret, FAIL, "H5Sselect_all"); ret = H5Dread(did, H5T_NATIVE_INT, msid, sid, H5P_DEFAULT, mem3_buffer); CHECK(ret, FAIL, "H5Dread"); ret = H5Dclose(did); CHECK(ret, FAIL, "H5Dclose"); ret = H5Sclose(msid); CHECK(ret, FAIL, "H5Sclose"); for(i=0; i<3; i++) for(j=0; j<6; j++) if(da_buffer[0][i][j][0] != mem3_buffer[0][i][j][0]) { TestErrPrintf("%u: Read different values than written at index 0,%d,%d,0/n", __LINE__, i, j); } ret = H5Sclose(sid); CHECK(ret, FAIL, "H5Sclose"); ret = H5Pclose(plid); CHECK(ret, FAIL, "H5Pclose");}
开发者ID:ArielleBassanelli,项目名称:gempak,代码行数:101,
示例19: createPathbool Hdf5Dataset::saveMap(const VecVecDouble &pose_reach, const VecVecDouble &spheres, const VecDouble &ri, const double resolution){ if(!checkPath(this->path_)) { createPath(this->path_); } const char *filepath = this->path_.c_str(); const char *name = this->filename_.c_str(); char fullpath[100]; strcpy(fullpath, filepath); strcat(fullpath, name); ROS_INFO("Saving map %s", this->filename_.c_str()); this->file_ = H5Fcreate(fullpath, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); this->group_poses_ = H5Gcreate(this->file_, "/Poses", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); this->group_spheres_ = H5Gcreate(this->file_, "/Spheres", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); ROS_INFO("Saving poses in reachability map"); const hsize_t ndims = 2; const hsize_t ncols = 10; int posSize =pose_reach.size(); int chunk_size; int PY = 10; if (posSize % 2) { chunk_size = (posSize / 2) + 1; } else { chunk_size = (posSize / 2); } // Create Dataspace hsize_t dims[ndims] = {0, ncols}; // Starting with an empty buffer hsize_t max_dims[ndims] = {H5S_UNLIMITED, ncols}; // Creating dataspace hid_t file_space = H5Screate_simple(ndims, dims, max_dims); // Create Dataset Property list hid_t plist = H5Pcreate(H5P_DATASET_CREATE); H5Pset_layout(plist, H5D_CHUNKED); hsize_t chunk_dims[ndims] = {chunk_size, ncols}; H5Pset_chunk(plist, ndims, chunk_dims); // Create the datset this->poses_dataset_ = H5Dcreate(this->group_poses_, "poses_dataset", H5T_NATIVE_FLOAT, file_space, H5P_DEFAULT, plist, H5P_DEFAULT); // Closing resources H5Pclose(plist); H5Sclose(file_space); // Creating the first buffer hsize_t nlines = chunk_size; float *buffer = new float[nlines * ncols]; float **dset1_data = new float *[nlines]; for (hsize_t i = 0; i < nlines; ++i) { dset1_data[i] = &buffer[i * ncols]; } // Data for the first chunk for (int i = 0; i < chunk_size; i++) { for (int j = 0; j < PY; j++) { dset1_data[i][j] = pose_reach[i][j]; } } // Memory dataspace indicating size of the buffer dims[0] = chunk_size; dims[1] = ncols; hid_t mem_space = H5Screate_simple(ndims, dims, NULL); // Extending dataset dims[0] = chunk_size; dims[1] = ncols; H5Dset_extent(this->poses_dataset_, dims); // Selecting hyperslab on the dataset file_space = H5Dget_space(this->poses_dataset_); hsize_t start[2] = {0, 0}; hsize_t count[2] = {chunk_size, ncols}; H5Sselect_hyperslab(file_space, H5S_SELECT_SET, start, NULL, count, NULL); // Writing buffer to the dataset H5Dwrite(this->poses_dataset_, H5T_NATIVE_FLOAT, mem_space, file_space, H5P_DEFAULT, buffer); // Closing file dataspace H5Sclose(file_space); // Data for the Second chunk for (int i = chunk_size; i < posSize; i++) { for (int j = 0; j < PY; j++) { dset1_data[i - chunk_size][j] = pose_reach[i][j]; } } // Resizing new memory dataspace indicating new size of the buffer dims[0] = posSize - chunk_size; dims[1] = ncols; H5Sset_extent_simple(mem_space, ndims, dims, NULL); // Extend dataset//.........这里部分代码省略.........
开发者ID:jontromanab,项目名称:reuleaux_moveit,代码行数:101,
示例20: test_multi_compat//.........这里部分代码省略......... h5_fixname(FILENAME[9], fapl, newname, sizeof newname); /* Make copy for the data file in the build directory, to protect the * original file in the source directory */ sprintf(filename_s, "%s-%c.h5", MULTI_COMPAT_BASENAME, 's'); sprintf(newname_s, "%s-%c.h5", FILENAME[9], 's'); h5_make_local_copy(filename_s, newname_s); sprintf(filename_r, "%s-%c.h5", MULTI_COMPAT_BASENAME, 'r'); sprintf(newname_r, "%s-%c.h5", FILENAME[9], 'r'); h5_make_local_copy(filename_r, newname_r); /* Reopen the file for read only. Verify 1.8 library can open file * created with 1.6 library. */ if((file=H5Fopen(newname, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR; if((dset = H5Dopen2(file, DSET1_NAME, H5P_DEFAULT)) < 0) TEST_ERROR; if(H5Dclose(dset) < 0) TEST_ERROR; if(H5Fclose(file) < 0) TEST_ERROR; /* Make sure we can reopen the file for read and write */ if((file=H5Fopen(newname, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR; if((dset = H5Dopen2(file, DSET1_NAME, H5P_DEFAULT)) < 0) TEST_ERROR; if(H5Dclose(dset) < 0) TEST_ERROR; if(H5Fclose(file) < 0) TEST_ERROR; /* Reopen the file for adding another dataset. The new EOA for metadata file * should be written to the file */ if((file=H5Fopen(newname, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR; /* Create and write data set */ if((space=H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR; if((dset=H5Dcreate2(file, DSET2_NAME, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; for(i=0; i<MULTI_SIZE; i++) for(j=0; j<MULTI_SIZE; j++) buf[i][j] = i*10000+j; if(H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR; if(H5Dclose(dset) < 0) TEST_ERROR; if(H5Sclose(space) < 0) TEST_ERROR; if(H5Fclose(file) < 0) TEST_ERROR; /* Reopen the file for read only again. Verify the library can handle * the EOA correctly */ if((file=H5Fopen(newname, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR; if((dset = H5Dopen2(file, DSET1_NAME, H5P_DEFAULT)) < 0) TEST_ERROR; if(H5Dclose(dset) < 0) TEST_ERROR; if((dset = H5Dopen2(file, DSET2_NAME, H5P_DEFAULT)) < 0) TEST_ERROR; if(H5Dclose(dset) < 0) TEST_ERROR; if(H5Fclose(file) < 0) TEST_ERROR; h5_cleanup(FILENAME, fapl); PASSED(); return 0;error: H5E_BEGIN_TRY { H5Sclose(space); H5Dclose(dset); H5Pclose(fapl); H5Fclose(file); } H5E_END_TRY; return -1;}
开发者ID:ArielleBassanelli,项目名称:gempak,代码行数:101,
示例21: test_compress/*------------------------------------------------------------------------- * test_compress * * Ensures that a FL packet table can be compressed. * This test creates a file named TEST_COMPRESS_FILE * *------------------------------------------------------------------------- */static inttest_compress(void){ hid_t fid1 = -1; herr_t err; hid_t table = -1; hid_t part_t = -1; hid_t dset_id = -1; hid_t plist_id = -1; size_t c; size_t num_elems = 1; unsigned filter_vals[1]; particle_t readPart; hsize_t count; TESTING("packet table compression"); /* Create a file. */ if((fid1 = H5Fcreate(TEST_COMPRESS_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* Create a datatype for the particle struct */ part_t = make_particle_type(); assert(part_t != -1); /* Create a new table with compression level 8 */ table = H5PTcreate_fl(fid1, "Compressed Test Dataset", part_t, (hsize_t)80, 8); if( H5PTis_valid(table) < 0) TEST_ERROR; /* We can now use this table exactly the same way we use a normal uncompressed * packet table, and it should pass the same tests. */ /* Add many particles */ for(c = 0; c < BIG_TABLE_SIZE ; c+=8) { /* Append eight particles at once*/ err = H5PTappend(table, (size_t)8, &(testPart[0])); if( err < 0) TEST_ERROR; } /* Count the number of packets in the table */ err = H5PTget_num_packets(table, &count); if( err < 0) TEST_ERROR; if( count != BIG_TABLE_SIZE ) TEST_ERROR; /* Read particles to ensure that all of them were written correctly */ for(c = 0; c < BIG_TABLE_SIZE; c++) { err = H5PTget_next(table, 1, &readPart); if(err < 0) TEST_ERROR; /* Ensure that particles were read correctly */ if( cmp_par(c % 8, 0, testPart, &readPart) != 0) TEST_ERROR; } /* Close the table */ err = H5PTclose(table); if( err < 0) TEST_ERROR; /* Open the packet table as a regular dataset and make sure that the * compression filter is set. */ dset_id = H5Dopen2(fid1, "Compressed Test Dataset", H5P_DEFAULT); if( dset_id < 0) TEST_ERROR; plist_id = H5Dget_create_plist(dset_id); if( plist_id < 0) TEST_ERROR; err = H5Pget_filter_by_id2(plist_id, H5Z_FILTER_DEFLATE, NULL, &num_elems, filter_vals, 0, NULL, NULL); if( err < 0) TEST_ERROR; /* The compression level should be 8, the value we passed in */ if(filter_vals[0] != 8) TEST_ERROR; /* Clean up */ err = H5Pclose(plist_id); if( err < 0) TEST_ERROR; err = H5Dclose(dset_id); if( err < 0) TEST_ERROR; /* Create a new table without compression. */ table = H5PTcreate_fl(fid1, "Uncompressed Dataset", part_t, (hsize_t)80, -1); if(table < 0) TEST_ERROR; /* Close the packet table */ err = H5PTclose(table); if( err < 0) TEST_ERROR; /* Open the packet table as a regular dataset and make sure that the * compression filter is not set. */ dset_id = H5Dopen2(fid1, "Uncompressed Dataset", H5P_DEFAULT);//.........这里部分代码省略.........
开发者ID:chaako,项目名称:sceptic3D,代码行数:101,
示例22: test_direct/*------------------------------------------------------------------------- * Function: test_direct * * Purpose: Tests the file handle interface for DIRECT I/O driver * * Return: Success: 0 * Failure: -1 * * Programmer: Raymond Lu * Wednesday, 20 September 2006 * *------------------------------------------------------------------------- */static herr_ttest_direct(void){#ifdef H5_HAVE_DIRECT hid_t file=(-1), fapl, access_fapl = -1; hid_t dset1=-1, dset2=-1, space1=-1, space2=-1; char filename[1024]; int *fhandle=NULL; hsize_t file_size; hsize_t dims1[2], dims2[1]; size_t mbound; size_t fbsize; size_t cbsize; int *points, *check, *p1, *p2; int wdata2[DSET2_DIM] = {11,12,13,14}; int rdata2[DSET2_DIM]; int i, j, n;#endif /*H5_HAVE_DIRECT*/ TESTING("DIRECT I/O file driver");#ifndef H5_HAVE_DIRECT SKIPPED(); return 0;#else /*H5_HAVE_DIRECT*/ /* Set property list and file name for Direct driver. Set memory alignment boundary * and file block size to 512 which is the minimum for Linux 2.6. */ fapl = h5_fileaccess(); if(H5Pset_fapl_direct(fapl, MBOUNDARY, FBSIZE, CBSIZE) < 0) TEST_ERROR; h5_fixname(FILENAME[5], fapl, filename, sizeof filename); /* Verify the file access properties */ if(H5Pget_fapl_direct(fapl, &mbound, &fbsize, &cbsize) < 0) TEST_ERROR; if(mbound != MBOUNDARY || fbsize != FBSIZE || cbsize != CBSIZE) TEST_ERROR; if(H5Pset_alignment(fapl, (hsize_t)THRESHOLD, (hsize_t)FBSIZE) < 0) TEST_ERROR; H5E_BEGIN_TRY { file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); } H5E_END_TRY; if(file<0) { H5Pclose (fapl); SKIPPED(); printf(" Probably the file system doesn't support Direct I/O/n"); return 0; } /* Retrieve the access property list... */ if ((access_fapl = H5Fget_access_plist(file)) < 0) TEST_ERROR; /* Check that the driver is correct */ if(H5FD_DIRECT != H5Pget_driver(access_fapl)) TEST_ERROR; /* ...and close the property list */ if (H5Pclose(access_fapl) < 0) TEST_ERROR; /* Check file handle API */ if(H5Fget_vfd_handle(file, H5P_DEFAULT, (void **)&fhandle) < 0) TEST_ERROR; if(*fhandle<0) TEST_ERROR; /* Check file size API */ if(H5Fget_filesize(file, &file_size) < 0) TEST_ERROR; /* There is no guarantee of the number of metadata allocations, but it's * 4 currently and the size of the file should be between 3 & 4 file buffer * sizes.. */ if(file_size < (FBSIZE * 3) || file_size >= (FBSIZE * 4)) TEST_ERROR; /* Allocate aligned memory for data set 1. For data set 1, everything is aligned including * memory address, size of data, and file address. */ if(posix_memalign(&points, (size_t)FBSIZE, (size_t)(DSET1_DIM1*DSET1_DIM2*sizeof(int)))!=0) TEST_ERROR; if(posix_memalign(&check, (size_t)FBSIZE, (size_t)(DSET1_DIM1*DSET1_DIM2*sizeof(int)))!=0)//.........这里部分代码省略.........
开发者ID:ArielleBassanelli,项目名称:gempak,代码行数:101,
示例23: mainintmain(){ printf("/n*** Checking HDF5 memory use./n"); printf("*** checking HDF5 memory use writing along unlimited dimension..."); {#define NDIMS1 1#define NUM_DATASETS 10000#define CHUNKSIZE 1 hid_t fapl_id, fcpl_id; hid_t datasetid[NUM_DATASETS]; hid_t fileid, grpid, spaceid, plistid; hsize_t chunksize[NDIMS1], dimsize[NDIMS1], maxdimsize[NDIMS1]; char var_name[STR_LEN + 1]; int v; /* Create file, setting latest_format in access propertly list * and H5P_CRT_ORDER_TRACKED in the creation property list. */ if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) ERR; if (H5Pset_libver_bounds(fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 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 ((fileid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, fcpl_id, fapl_id)) < 0) ERR; /* Open root group. */ if ((grpid = H5Gopen(fileid, "/")) < 0) ERR; /* Create 1 D data space with unlimited dimension. */ dimsize[0] = 0; maxdimsize[0] = H5S_UNLIMITED; if ((spaceid = H5Screate_simple(NDIMS1, dimsize, maxdimsize)) < 0) ERR; /* Create property list. */ if ((plistid = H5Pcreate(H5P_DATASET_CREATE)) < 0) ERR; /* Set up chunksizes. */ chunksize[0] = CHUNKSIZE; if (H5Pset_chunk(plistid, NDIMS1, chunksize) < 0)ERR; /* Create the variables. */ for (v = 0; v < NUM_DATASETS; v++) { sprintf(var_name, "var_%d", v);/* printf("creating var %s/n", var_name);*/ if ((datasetid[v] = H5Dcreate(grpid, var_name, H5T_NATIVE_INT, spaceid, plistid)) < 0) ERR_RET; } /* Close the datasets. */ for (v = 0; v < NUM_DATASETS; v++) if (H5Dclose(datasetid[v]) < 0) ERR_RET; /* Close everything. */ if (H5Pclose(fapl_id) < 0 || H5Sclose(spaceid) < 0 || H5Gclose(grpid) < 0 || H5Fclose(fileid) < 0) ERR; /* Now reopen the file and check. */ if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) ERR; if (H5Pset_libver_bounds(fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) ERR; if ((fileid = H5Fopen(FILE_NAME, H5F_ACC_RDONLY, fapl_id)) < 0) ERR; if ((grpid = H5Gopen(fileid, "/")) < 0) ERR;/* if ((datasetid = H5Dopen1(grpid, SIMPLE_VAR_NAME)) < 0) ERR; *//* if ((spaceid = H5Dget_space(datasetid)) < 0) *//* if (H5Sget_simple_extent_dims(spaceid, fdims, fmaxdims) > 0) ERR; *//* if (H5Dread(datasetid, H5T_NATIVE_INT, H5S_ALL, *//* spaceid, H5P_DEFAULT, data_in) < 0) ERR; *//* //* Check the data. *// *//* for (x = 0; x < NX; x++) *//* for (y = 0; y < NY; y++) *//* if (data_in[x][y] != data_out[x][y]) ERR_RET; */ if (H5Pclose(fapl_id) < 0 ||/* H5Dclose(datasetid) < 0 || H5Sclose(spaceid) < 0 ||*/ H5Gclose(grpid) < 0 || H5Fclose(fileid) < 0) ERR; } SUMMARIZE_ERR; FINAL_RESULTS;}
开发者ID:balborian,项目名称:libmesh,代码行数:87,
示例24: test_core/*------------------------------------------------------------------------- * Function: test_core * * Purpose: Tests the file handle interface for CORE driver * * Return: Success: 0 * Failure: -1 * * Programmer: Raymond Lu * Tuesday, Sept 24, 2002 * *------------------------------------------------------------------------- */static herr_ttest_core(void){ hid_t file=(-1), fapl, access_fapl = -1; char filename[1024]; void *fhandle=NULL; hsize_t file_size; int *points, *check, *p1, *p2; hid_t dset1=-1, space1=-1; hsize_t dims1[2]; int i, j, n; TESTING("CORE file driver"); /* Set property list and file name for CORE driver */ fapl = h5_fileaccess(); if(H5Pset_fapl_core(fapl, (size_t)CORE_INCREMENT, TRUE) < 0) TEST_ERROR; h5_fixname(FILENAME[1], fapl, filename, sizeof filename); if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR; /* Retrieve the access property list... */ if ((access_fapl = H5Fget_access_plist(file)) < 0) TEST_ERROR; /* Check that the driver is correct */ if(H5FD_CORE != H5Pget_driver(access_fapl)) TEST_ERROR; /* ...and close the property list */ if (H5Pclose(access_fapl) < 0) TEST_ERROR; if(H5Fget_vfd_handle(file, H5P_DEFAULT, &fhandle) < 0) TEST_ERROR; if(fhandle==NULL) { printf("fhandle==NULL/n"); TEST_ERROR; } /* Check file size API */ if(H5Fget_filesize(file, &file_size) < 0) TEST_ERROR; /* There is no garantee the size of metadata in file is constant. * Just try to check if it's reasonable. Why is this 4KB? */ if(file_size<2*KB || file_size>6*KB) TEST_ERROR; if(H5Fclose(file) < 0) TEST_ERROR; /* Open the file with backing store off for read and write. * Changes won't be saved in file. */ if(H5Pset_fapl_core(fapl, (size_t)CORE_INCREMENT, FALSE) < 0) TEST_ERROR; if((file=H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR; /* Allocate memory for data set. */ points=(int*)malloc(DSET1_DIM1*DSET1_DIM2*sizeof(int)); check=(int*)malloc(DSET1_DIM1*DSET1_DIM2*sizeof(int)); /* Initialize the dset1 */ p1 = points; for(i = n = 0; i < DSET1_DIM1; i++) for(j = 0; j < DSET1_DIM2; j++) *p1++ = n++; /* Create the data space1 */ dims1[0] = DSET1_DIM1; dims1[1] = DSET1_DIM2; if((space1 = H5Screate_simple(2, dims1, NULL)) < 0) TEST_ERROR; /* Create the dset1 */ if((dset1 = H5Dcreate2(file, DSET1_NAME, H5T_NATIVE_INT, space1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* Write the data to the dset1 */ if(H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0)//.........这里部分代码省略.........
开发者ID:ArielleBassanelli,项目名称:gempak,代码行数:101,
示例25: 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,
示例26: test_family/*------------------------------------------------------------------------- * Function: test_family * * Purpose: Tests the file handle interface for FAMILY driver * * Return: Success: 0 * Failure: -1 * * Programmer: Raymond Lu * Tuesday, Sept 24, 2002 * *------------------------------------------------------------------------- */static herr_ttest_family(void){ hid_t file=(-1), fapl, fapl2=(-1), space=(-1), dset=(-1); hid_t access_fapl = -1; char filename[1024]; char dname[]="dataset"; unsigned int i, j; int *fhandle=NULL, *fhandle2=NULL; int buf[FAMILY_NUMBER][FAMILY_SIZE]; hsize_t dims[2]={FAMILY_NUMBER, FAMILY_SIZE}; hsize_t file_size; TESTING("FAMILY file driver"); /* Set property list and file name for FAMILY driver */ fapl = h5_fileaccess(); if(H5Pset_fapl_family(fapl, (hsize_t)FAMILY_SIZE, H5P_DEFAULT) < 0) TEST_ERROR; h5_fixname(FILENAME[2], fapl, filename, sizeof filename); if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR; if(H5Fclose(file) < 0) TEST_ERROR; /* Test different wrong ways to reopen family files where there's only * one member file existing. */ if(test_family_opens(filename, fapl) < 0) TEST_ERROR; /* Reopen the file with default member file size */ if(H5Pset_fapl_family(fapl, (hsize_t)H5F_FAMILY_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; if((file=H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR; /* Check file size API */ if(H5Fget_filesize(file, &file_size) < 0) TEST_ERROR; /* The file size is supposed to be about 800 bytes right now. */ if(file_size < (KB / 2) || file_size > KB) TEST_ERROR; /* Create and write dataset */ if((space=H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR; /* Retrieve the access property list... */ if ((access_fapl = H5Fget_access_plist(file)) < 0) TEST_ERROR; /* Check that the driver is correct */ if(H5FD_FAMILY != H5Pget_driver(access_fapl)) TEST_ERROR; /* ...and close the property list */ if (H5Pclose(access_fapl) < 0) TEST_ERROR; if((dset=H5Dcreate2(file, dname, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; for(i=0; i<FAMILY_NUMBER; i++) for(j=0; j<FAMILY_SIZE; j++) buf[i][j] = i*10000+j; if(H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR; /* check file handle API */ if((fapl2=H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR; if(H5Pset_family_offset(fapl2, (hsize_t)0) < 0) TEST_ERROR; if(H5Fget_vfd_handle(file, fapl2, (void **)&fhandle) < 0) TEST_ERROR; if(*fhandle<0) TEST_ERROR; if(H5Pset_family_offset(fapl2, (hsize_t)(FAMILY_SIZE*2)) < 0) TEST_ERROR;//.........这里部分代码省略.........
开发者ID:ArielleBassanelli,项目名称:gempak,代码行数:101,
示例27: main//.........这里部分代码省略......... dims[0] = 0; dims[1] = 0; maxdims[0] = H5S_UNLIMITED; maxdims[1] = H5S_UNLIMITED; if ((pres_spaceid = H5Screate_simple(DIMS2, dims, maxdims)) < 0) ERR; /* Set up the dataset creation property list for the two dimensions. */ if ((plistid = H5Pcreate(H5P_DATASET_CREATE)) < 0) ERR; if (H5Pset_chunk(plistid, 1, chunksize) < 0) ERR; if (H5Pset_attr_creation_order(plistid, H5P_CRT_ORDER_TRACKED| H5P_CRT_ORDER_INDEXED) < 0) ERR; /* Create our dimension scales. */ if ((lat_dimscaleid = H5Dcreate(grpid, U1_NAME, H5T_NATIVE_INT, lat_spaceid, plistid)) < 0) ERR; if (H5DSset_scale(lat_dimscaleid, NULL) < 0) ERR; if ((lon_dimscaleid = H5Dcreate(grpid, U2_NAME, H5T_NATIVE_INT, lon_spaceid, plistid)) < 0) ERR; if (H5DSset_scale(lon_dimscaleid, NULL) < 0) ERR; /* Set up the dataset creation property list for the variable. */ if ((plistid2 = H5Pcreate(H5P_DATASET_CREATE)) < 0) ERR; if (H5Pset_chunk(plistid2, DIMS2, chunksize) < 0) ERR; if (H5Pset_attr_creation_order(plistid2, H5P_CRT_ORDER_TRACKED| H5P_CRT_ORDER_INDEXED) < 0) ERR; /* Create a variable which uses these two dimscales. */ if ((pres_datasetid = H5Dcreate(grpid, VNAME, H5T_NATIVE_DOUBLE, pres_spaceid, plistid2)) < 0) ERR; if (H5DSattach_scale(pres_datasetid, lat_dimscaleid, 0) < 0) ERR; if (H5DSattach_scale(pres_datasetid, lon_dimscaleid, 1) < 0) ERR; /* Close down the show. */ if (H5Pclose(fapl_id) < 0 || H5Pclose(fcpl_id) < 0 || H5Dclose(lat_dimscaleid) < 0 || H5Dclose(lon_dimscaleid) < 0 || H5Dclose(pres_datasetid) < 0 || H5Sclose(lat_spaceid) < 0 || H5Sclose(lon_spaceid) < 0 || H5Sclose(pres_spaceid) < 0 || H5Pclose(plistid) < 0 || H5Pclose(plistid2) < 0 || H5Gclose(grpid) < 0 || H5Fclose(fileid) < 0) ERR; /* Open the file. */ if ((fileid = H5Fopen(FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) ERR; if ((grpid = H5Gopen2(fileid, "/", H5P_DEFAULT)) < 0) ERR; /* Loop through objects in the root group. */ if (H5Gget_num_objs(grpid, &num_obj) < 0) ERR; for (i = 0; i < num_obj; i++) { /*Get the type (i.e. group, dataset, etc.), and the name of the object. */ if ((obj_class = H5Gget_objtype_by_idx(grpid, i)) < 0) ERR; if (H5Gget_objname_by_idx(grpid, i, obj_name, NC_MAX_NAME) < 0) ERR; /* Deal with object based on its obj_class. */ switch(obj_class) { case H5G_GROUP: break; case H5G_DATASET:
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:67,
示例28: test_sec2/*------------------------------------------------------------------------- * Function: test_sec2 * * Purpose: Tests the file handle interface for SEC2 driver * * Return: Success: 0 * Failure: -1 * * Programmer: Raymond Lu * Tuesday, Sept 24, 2002 * *------------------------------------------------------------------------- */static herr_ttest_sec2(void){ hid_t file = -1; hid_t fapl = -1; hid_t access_fapl = -1; char filename[1024]; int *fhandle = NULL; hsize_t file_size = 0; TESTING("SEC2 file driver"); /* Set property list and file name for SEC2 driver. */ fapl = h5_fileaccess(); if(H5Pset_fapl_sec2(fapl) < 0) TEST_ERROR; h5_fixname(FILENAME[0], fapl, filename, sizeof filename); if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR; /* Retrieve the access property list... */ if((access_fapl = H5Fget_access_plist(file)) < 0) TEST_ERROR; /* Check that the driver is correct */ if(H5FD_SEC2 != H5Pget_driver(access_fapl)) TEST_ERROR; /* ...and close the property list */ if(H5Pclose(access_fapl) < 0) TEST_ERROR; /* Check file handle API */ if(H5Fget_vfd_handle(file, H5P_DEFAULT, (void **)&fhandle) < 0) TEST_ERROR; if(*fhandle < 0) TEST_ERROR; /* Check file size API */ if(H5Fget_filesize(file, &file_size) < 0) TEST_ERROR; /* There is no guarantee the size of metadata in file is constant. * Just try to check if it's reasonable. It's 2KB right now. */ if(file_size < 1 * KB || file_size > 4 * KB) TEST_ERROR; if(H5Fclose(file) < 0) TEST_ERROR; h5_cleanup(FILENAME, fapl); PASSED(); return 0;error: H5E_BEGIN_TRY { H5Pclose(fapl); H5Fclose(file); } H5E_END_TRY; return -1;}
开发者ID:ArielleBassanelli,项目名称:gempak,代码行数:76,
示例29: main//.........这里部分代码省略......... /* * Build the mappings * */ status = H5Sselect_hyperslab (vspace, H5S_SELECT_SET, start, stride, count, block); status = H5Pset_virtual (dcpl, vspace, "f-%b.h5", "/A", src_space); /* Create a virtual dataset */ dset = H5Dcreate2 (file, DATASET, H5T_NATIVE_INT, vspace, H5P_DEFAULT, dcpl, H5P_DEFAULT); status = H5Sclose (vspace); status = H5Sclose (src_space); status = H5Dclose (dset); status = H5Fclose (file); /* * Now we begin the read section of this example. */ /* * Open file and dataset using the default properties. */ file = H5Fopen (FILE, H5F_ACC_RDONLY, H5P_DEFAULT); dset = H5Dopen2 (file, DATASET, H5P_DEFAULT); /* * Get creation property list and mapping properties. */ dcpl = H5Dget_create_plist (dset); /* * Get storage layout. */ layout = H5Pget_layout (dcpl); if (H5D_VIRTUAL == layout) printf(" Dataset has a virtual layout /n"); else printf(" Wrong layout found /n"); /* * Find number of mappings. */ status = H5Pget_virtual_count (dcpl, &num_map); printf(" Number of mappings is %d/n", (int)num_map); /* * Get mapping parameters for each mapping. */ for (i = 0; i < (int)num_map; i++) { printf(" Mapping %d /n", i); printf(" Selection in the virtual dataset /n"); /* Get selection in the virttual dataset */ vspace = H5Pget_virtual_vspace (dcpl, (size_t)i); if (H5Sget_select_type(vspace) == H5S_SEL_HYPERSLABS) { if (H5Sis_regular_hyperslab(vspace)) { status = H5Sget_regular_hyperslab (vspace, start_out, stride_out, count_out, block_out); printf(" start = [%llu, %llu, %llu] /n", (unsigned long long)start_out[0], (unsigned long long)start_out[1], (unsigned long long)start_out[2]); printf(" stride = [%llu, %llu, %llu] /n", (unsigned long long)stride_out[0], (unsigned long long)stride_out[1], (unsigned long long)stride_out[2]); printf(" count = [%llu, %llu, %llu] /n", (unsigned long long)count_out[0], (unsigned long long)count_out[1], (unsigned long long)count_out[2]); printf(" block = [%llu, %llu, %llu] /n", (unsigned long long)block_out[0], (unsigned long long)block_out[1], (unsigned long long)block_out[2]); } } /* Get source file name */ len = H5Pget_virtual_filename (dcpl, (size_t)i, NULL, 0); filename = (char *)malloc((size_t)len*sizeof(char)+1); H5Pget_virtual_filename (dcpl, (size_t)i, filename, len+1); printf(" Source filename %s/n", filename); /* Get source dataset name */ len = H5Pget_virtual_dsetname (dcpl, (size_t)i, NULL, 0); dsetname = (char *)malloc((size_t)len*sizeof(char)+1); H5Pget_virtual_dsetname (dcpl, (size_t)i, dsetname, len+1); printf(" Source dataset name %s/n", dsetname); /* Get selection in the source dataset */ printf(" Selection in the source dataset "); src_space = H5Pget_virtual_srcspace (dcpl, (size_t)i); if(H5Sget_select_type(src_space) == H5S_SEL_ALL) { printf("H5S_ALL /n"); }/* EIP read data back */ H5Sclose(vspace); H5Sclose(src_space); free(filename); free(dsetname); } /* * Close and release resources. */ status = H5Pclose (dcpl); status = H5Dclose (dset); status = H5Fclose (file); return 0;}
开发者ID:ElaraFX,项目名称:hdf5,代码行数:101,
示例30: test_filter_write/*------------------------------------------------------------------------- * Function: test_filter_write_failure * * Purpose: Tests the library's behavior when a mandate filter returns * failure. There're only 5 chunks with each of them having * 2 integers. The filter will fail in the last chunk. The * dataset should release all resources even though the last * chunk can't be flushed to file. The file should close * successfully. * * Return: * Success: 0 * Failure: -1 * * Programmer: Raymond Lu * 25 August 2010 * * Modifications: * *------------------------------------------------------------------------- */static herr_ttest_filter_write(char *file_name, hid_t my_fapl){ char filename[1024]; hid_t file = -1; hid_t dataset=-1; /* dataset ID */ hid_t sid=-1; /* dataspace ID */ hid_t dcpl=-1; /* dataset creation property list ID */ hsize_t dims[1]={DIM}; /* dataspace dimension - 10*/ hsize_t chunk_dims[1]={FILTER_CHUNK_DIM}; /* chunk dimension - 2*/ int nfilters; /* number of filters in DCPL */ unsigned flags; /* flags for filter */ int points[DIM]; /* Data */ int rbuf[DIM]; /* Data */ herr_t ret; /* generic return value */ int i; TESTING("data writing when a mandatory filter fails"); /* Create file */ if((file = H5Fcreate(file_name, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR /* create the data space */ if((sid = H5Screate_simple(1, dims, NULL)) < 0) TEST_ERROR /* Create dcpl and register the filter */ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR if(H5Pset_chunk(dcpl, 1, chunk_dims) < 0) TEST_ERROR if(H5Zregister (H5Z_FAIL_TEST) < 0) TEST_ERROR /* Check that the filter was registered */ if(TRUE != H5Zfilter_avail(H5Z_FILTER_FAIL_TEST)) FAIL_STACK_ERROR /* Enable the filter as mandatory */ if(H5Pset_filter(dcpl, H5Z_FILTER_FAIL_TEST, 0, (size_t)0, NULL) < 0) TEST_ERROR /* create a dataset */ if((dataset = H5Dcreate2(file, DSET_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* Initialize the write buffer */ for(i = 0; i < DIM; i++) points[i] = i; /* Write data */ if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, sid, H5P_DEFAULT, points) < 0) TEST_ERROR /* clean up objects used for this test */ if(H5Pclose (dcpl) < 0) TEST_ERROR if(H5Sclose (sid) < 0) TEST_ERROR /* Dataset closing should fail */ H5E_BEGIN_TRY { ret = H5Dclose (dataset); } H5E_END_TRY; if(ret >= 0) { H5_FAILED(); puts(" Dataset is supposed to fail because the chunk can't be flushed to file."); TEST_ERROR }
开发者ID:worst-nick-ever,项目名称:hdf5,代码行数:83,
注:本文中的H5Pclose函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ H5Pset_chunk函数代码示例 C++ H5Lexists函数代码示例 |