这篇教程C++ H5Dclose函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中H5Dclose函数的典型用法代码示例。如果您正苦于以下问题:C++ H5Dclose函数的具体用法?C++ H5Dclose怎么用?C++ H5Dclose使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了H5Dclose函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: forAll forAll(scalarFields_, fieldI) { Info<< " fieldWriteScalar: " << scalarFields_[fieldI] << endl; // Lookup field const volScalarField& field = obr_.lookupObject<volScalarField> ( scalarFields_[fieldI] ); // Initialize a plain continous array for the data ioScalar* scalarData; scalarData = new ioScalar[field.size()]; // Loop through the field and construct the array forAll(field, iter) { scalarData[iter] = field[iter]; } // Create the different datasets (needs to be done collectively) char datasetName[80]; hsize_t dimsf[1]; hid_t fileSpace; hid_t dsetID; hid_t plistID; hid_t plistDCreate; forAll(nCells_, proc) { // Create the dataspace for the dataset dimsf[0] = nCells_[proc]; fileSpace = H5Screate_simple(1, dimsf, NULL); // Set property to create parent groups as neccesary plistID = H5Pcreate(H5P_LINK_CREATE); H5Pset_create_intermediate_group(plistID, 1); // Set chunking, compression and other HDF5 dataset properties plistDCreate = H5Pcreate(H5P_DATASET_CREATE); dsetSetProps(1, sizeof(ioScalar), nCells_[proc], plistDCreate); // Create the dataset for points sprintf ( datasetName, "FIELDS/%s/processor%i/%s", mesh_.time().timeName().c_str(), proc, scalarFields_[fieldI].c_str() ); dsetID = H5Dcreate2 ( fileID_, datasetName, H5T_SCALAR, fileSpace, plistID, plistDCreate, H5P_DEFAULT ); H5Dclose(dsetID); H5Pclose(plistID); H5Pclose(plistDCreate); H5Sclose(fileSpace); }
开发者ID:hakostra,项目名称:IOH5Write,代码行数:71,
示例2: create_nbit_dsets_float/*------------------------------------------------------------------------- * Function: create_nbit_dsets_float * * Purpose: Create a dataset of FLOAT datatype with nbit filter * * Return: Success: 0 * Failure: -1 * * Programmer: Raymond Lu * 29 March 2011 * * Modifications: * *------------------------------------------------------------------------- */intcreate_nbit_dsets_float(hid_t fid, hid_t fsid, hid_t msid){ hid_t dataset; /* dataset handles */ hid_t datatype; hid_t dcpl; size_t precision, offset; float data[NX][NY]; /* data to write */ float fillvalue = -2.2f; hsize_t chunk[RANK] = {CHUNK0, CHUNK1}; int i, j; /* * Data and output buffer initialization. */ for (j = 0; j < NX; j++) { for (i = 0; i < NY; i++) data[j][i] = ((float)(i + j + 1))/3; } /* * Create the dataset creation property list, add the Scale-Offset * filter, set the chunk size, and set the fill value. */ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR if(H5Pset_nbit(dcpl) < 0) TEST_ERROR if(H5Pset_chunk(dcpl, RANK, chunk) < 0) TEST_ERROR if(H5Pset_fill_value(dcpl, H5T_NATIVE_FLOAT, &fillvalue) < 0) TEST_ERROR /* Define user-defined single-precision floating-point type for dataset. * A 20-bit little-endian data type. */ if((datatype = H5Tcopy(H5T_IEEE_F32LE)) < 0) TEST_ERROR if(H5Tset_fields(datatype, (size_t)26, (size_t)20, (size_t)6, (size_t)7, (size_t)13) < 0) TEST_ERROR offset = 7; if(H5Tset_offset(datatype,offset) < 0) TEST_ERROR precision = 20; if(H5Tset_precision(datatype,precision) < 0) TEST_ERROR if(H5Tset_size(datatype, (size_t)4) < 0) TEST_ERROR if(H5Tset_ebias(datatype, (size_t)31) < 0) TEST_ERROR /* * Create a new dataset within the file using defined dataspace, * user-defined datatype, and default dataset creation properties. */ if((dataset = H5Dcreate2(fid, DATASETNAME22, datatype, fsid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* * Write the data to the dataset using default transfer properties. */ if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) TEST_ERROR /* Close dataset */ if(H5Dclose(dataset) < 0) TEST_ERROR /* Now create a dataset with a big-endian type */ if(H5Tset_order(datatype, H5T_ORDER_BE) < 0) TEST_ERROR if((dataset = H5Dcreate2(fid, DATASETNAME23, datatype, fsid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) TEST_ERROR if(H5Dclose(dataset) < 0) TEST_ERROR /* * Close/release resources. */ if(H5Pclose(dcpl) < 0) TEST_ERROR//.........这里部分代码省略.........
开发者ID:AndyHuang7601,项目名称:EpicGames-UnrealEngine,代码行数:101,
示例3: create_deflate_dsets_float/*------------------------------------------------------------------------- * Function: create_deflate_dsets_float * * Purpose: Create a dataset of FLOAT datatype with deflate filter * * Return: Success: 0 * Failure: -1 * * Programmer: Raymond Lu * 29 March 2011 * * Modifications: * *------------------------------------------------------------------------- */intcreate_deflate_dsets_float(hid_t fid, hid_t fsid, hid_t msid){#ifdef H5_HAVE_FILTER_DEFLATE hid_t dataset; /* dataset handles */ hid_t dcpl; float data[NX][NY]; /* data to write */ float fillvalue = -2.2f; hsize_t chunk[RANK] = {CHUNK0, CHUNK1}; int i, j; /* * Data and output buffer initialization. */ for (j = 0; j < NX; j++) { for (i = 0; i < NY; i++) data[j][i] = ((float)(i + j + 1))/3; } /* * Create the dataset creation property list, add the Scale-Offset * filter, set the chunk size, and set the fill value. */ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR if(H5Pset_deflate (dcpl, 6) < 0) TEST_ERROR if(H5Pset_chunk(dcpl, RANK, chunk) < 0) TEST_ERROR if(H5Pset_fill_value(dcpl, H5T_NATIVE_FLOAT, &fillvalue) < 0) TEST_ERROR /* * Create a new dataset within the file using defined dataspace, little * endian datatype and default dataset creation properties. */ if((dataset = H5Dcreate2(fid, DATASETNAME16, H5T_IEEE_F32LE, fsid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* * Write the data to the dataset using default transfer properties. */ if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) TEST_ERROR /* Close dataset */ if(H5Dclose(dataset) < 0) TEST_ERROR /* Now create a dataset with a big-endian type */ if((dataset = H5Dcreate2(fid, DATASETNAME17, H5T_IEEE_F32BE, fsid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) TEST_ERROR if(H5Dclose(dataset) < 0) TEST_ERROR /* * Close/release resources. */ if(H5Pclose(dcpl) < 0) TEST_ERROR#else /* H5_HAVE_FILTER_DEFLATE */ const char *not_supported= "Deflate filter is not enabled. Can't create the dataset."; puts(not_supported);#endif /* H5_HAVE_FILTER_DEFLATE */ return 0;#ifdef H5_HAVE_FILTER_DEFLATEerror: H5E_BEGIN_TRY { H5Pclose(dcpl); H5Dclose(dataset); } H5E_END_TRY; return -1;#endif /* H5_HAVE_FILTER_DEFLATE */}
开发者ID:AndyHuang7601,项目名称:EpicGames-UnrealEngine,代码行数:98,
示例4: WriteHDF5filebool WriteHDF5file(char* fname, dtype* outArray, int* dims, float* pixel, float* expo, float* waveLen, float* dist, float* beamxy, float* flux, bool compress, unsigned short* badmask){#ifdef _HDF5_H hid_t out_type_id = H5T_NATIVE_FLOAT; hid_t file_id = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); hid_t gid = H5Gcreate1(file_id,"LCLS",0); hid_t dataspace_id, dataset_id; int ndims = 1; hsize_t dimsH[2]; dimsH[0] = 1; dimsH[1] = 0; dataspace_id = H5Screate_simple(1, dimsH, NULL); dataset_id = H5Dcreate1(gid, "detectorPosition", out_type_id, dataspace_id, H5P_DEFAULT); if(H5Dwrite(dataset_id, out_type_id, H5S_ALL, H5S_ALL,H5P_DEFAULT, dist)< 0) printf("Error writing 1D data to file/n"); H5Dclose(dataset_id); dataset_id = H5Dcreate1(gid, "photon_wavelength_A", out_type_id, dataspace_id, H5P_DEFAULT); if(H5Dwrite(dataset_id, out_type_id, H5S_ALL, H5S_ALL,H5P_DEFAULT, waveLen)< 0) printf("Error writing 1D data to file/n"); H5Dclose(dataset_id); dataset_id = H5Dcreate1(gid, "exposure_s", out_type_id, dataspace_id, H5P_DEFAULT); if(H5Dwrite(dataset_id, out_type_id, H5S_ALL, H5S_ALL,H5P_DEFAULT, expo)< 0) printf("Error writing 1D data to file/n"); H5Dclose(dataset_id); dataset_id = H5Dcreate1(gid, "pixelX_m", out_type_id, dataspace_id, H5P_DEFAULT); if(H5Dwrite(dataset_id, out_type_id, H5S_ALL, H5S_ALL,H5P_DEFAULT, &pixel[0])< 0) printf("Error writing 1D data to file/n"); H5Dclose(dataset_id); dataset_id = H5Dcreate1(gid, "pixelY_m", out_type_id, dataspace_id, H5P_DEFAULT); if(H5Dwrite(dataset_id, out_type_id, H5S_ALL, H5S_ALL,H5P_DEFAULT, &pixel[1])< 0) printf("Error writing 1D data to file/n"); H5Dclose(dataset_id); dataset_id = H5Dcreate1(gid, "flux_ph_s", out_type_id, dataspace_id, H5P_DEFAULT); if(H5Dwrite(dataset_id, out_type_id, H5S_ALL, H5S_ALL,H5P_DEFAULT, flux)< 0) printf("Error writing 1D data to file/n"); H5Dclose(dataset_id); dataset_id = H5Dcreate1(gid, "beamX_px", out_type_id, dataspace_id, H5P_DEFAULT); if(H5Dwrite(dataset_id, out_type_id, H5S_ALL, H5S_ALL,H5P_DEFAULT, &beamxy[0])< 0) printf("Error writing 1D data to file/n"); H5Dclose(dataset_id); dataset_id = H5Dcreate1(gid, "beamY_px", out_type_id, dataspace_id, H5P_DEFAULT); if(H5Dwrite(dataset_id, out_type_id, H5S_ALL, H5S_ALL,H5P_DEFAULT, &beamxy[1])< 0) printf("Error writing 1D data to file/n"); H5Dclose(dataset_id); H5Sclose(dataspace_id); ndims = 2; dimsH[0] = dims[1]; dimsH[1] = dims[0]; hid_t gid2 = H5Gcreate1(file_id,"data",0); dataspace_id = H5Screate_simple(ndims, dimsH, NULL); //COMPRESSION hid_t dcpl = H5Pcreate (H5P_DATASET_CREATE);// hsize_t chunk[2] = {dimsH[0], dimsH[1]};//#ifdef ZLIB_H//CASS hsize_t chunk[2] = {40,2}; hsize_t chunk[2] = {64, 64}; if (compress) { H5Pset_deflate (dcpl, 9); H5Pset_chunk (dcpl, 2, chunk); }//#endif // H5Pset_szip (dcpl, H5_SZIP_NN_OPTION_MASK, 8); // H5Pset_chunk (dcpl, 2, chunk); dataset_id = H5Dcreate(file_id, "/data/data", out_type_id, dataspace_id, H5P_DEFAULT, dcpl, H5P_DEFAULT);// dataset_id = H5Dcreate1(file_id, "/data/data", out_type_id, dataspace_id, H5P_DEFAULT); if(H5Dwrite(dataset_id, out_type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, outArray)< 0) printf("Error writing 2D data to file/n"); H5Dclose(dataset_id); H5Sclose(dataspace_id); H5Gclose(gid2); //Here badmask H5Gclose(gid); H5Fclose(file_id); return true;#endif return false;}
开发者ID:shibom,项目名称:scripts_sls,代码行数:92,
示例5: create_attrs_3/*------------------------------------------------------------------------- * Function: create_attrs_3 * * Purpose: Attempts to create some attributes for each dataset in a * loop. * * Return: Success: 0 * * Failure: -1 * * Programmer: Raymond Lu * Friday, Oct 3, 2003 * * Modifications: * *------------------------------------------------------------------------- */static herr_tcreate_attrs_3(void){ hid_t file, dataset, attr; char filename[128]; char dset_name[64]; char attr_name[128]; int loop_num; int i, j, k; p_time attr_t = {0, 0, 0, 1000000, 0, ""}; p_time open_t = {0, 0, 0, 1000000, 0, "H5Dopen2"}; p_time close_t = {0, 0, 0, 1000000, 0, ""};#ifdef H5_HAVE_PARALLEL /* need the rank for printing data */ int mpi_rank; if(facc_type == FACC_MPIO) MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);#endif /*H5_HAVE_PARALLEL*/ h5_fixname(FILENAME[2], fapl, filename, sizeof filename); if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) goto error; if(create_dsets(file) < 0) goto error; /* * Create some(user specifies the number) attributes for each dataset * in a loop */ loop_num = NUM_ATTRS/BATCH_ATTRS; for(i = 0; i < loop_num; i++) { for(j = 0; j < NUM_DSETS; j++) { sprintf(dset_name, "dataset %d", j); open_t.start = retrieve_time(); if((dataset = H5Dopen2(file, dset_name, H5P_DEFAULT)) < 0) goto error; perf(&open_t, open_t.start, retrieve_time()); for(k = 0; k < BATCH_ATTRS; k++) { sprintf(attr_name, "some attrs for each dset %d %d", i, k); attr_t.start = retrieve_time(); if((attr = H5Acreate2(dataset, attr_name, H5T_NATIVE_DOUBLE, small_space, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; if(H5Aclose(attr) < 0) goto error; perf(&attr_t, attr_t.start, retrieve_time()); if(flush_attr && H5Fflush(file, H5F_SCOPE_LOCAL) < 0) goto error; } /* end for */ close_t.start = retrieve_time(); if(H5Dclose(dataset) < 0) goto error; perf(&close_t, close_t.start, retrieve_time()); if(flush_dset && H5Fflush(file, H5F_SCOPE_LOCAL) < 0) goto error; } /* end for */ } /* end for */#ifdef H5_HAVE_PARALLEL if(facc_type == FACC_MPIO) MPI_Barrier(MPI_COMM_WORLD);#endif /*H5_HAVE_PARALLEL*/#ifdef H5_HAVE_PARALLEL /* only process 0 reports if parallel */ if (facc_type == FACC_DEFAULT || (facc_type != FACC_DEFAULT && MAINPROCESS))#endif /*H5_HAVE_PARALLEL*/ { /* Calculate the average time */ open_t.avg = open_t.total / (loop_num*NUM_DSETS); close_t.avg = close_t.total / (loop_num*NUM_DSETS); attr_t.avg = attr_t.total / (NUM_ATTRS*NUM_DSETS); /* Print out the performance result */ fprintf(stderr, "3. Create %d attributes for each of %d existing datasets for %d times/n", BATCH_ATTRS, NUM_DSETS, loop_num);//.........这里部分代码省略.........
开发者ID:ElaraFX,项目名称:hdf5,代码行数:101,
示例6: write_data2//.........这里部分代码省略......... Matrix2[y][z][x].re = Re(C[z][BETA][y][x]); Matrix2[y][z][x].im = Im(C[z][BETA][y][x]); IMatrix1[y][z][x].re = Re(IC[z][ALPHA][y][x]); /* storing solved solutions to Matrix */ IMatrix1[y][z][x].im = Im(IC[z][ALPHA][y][x]); IMatrix2[y][z][x].re = Re(IC[z][BETA][y][x]); IMatrix2[y][z][x].im = Im(IC[z][BETA][y][x]); } } } sprintf(filename, "data_t=%d.h5", n); /* create File data.h5 for three data sets */ file_id1 = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* create the dataspace */ fid1 = H5Screate_simple(3, fdim, NULL); fid2 = H5Screate_simple(1, fdim2, NULL); /* create datasets with name u v w */ dataset_a = H5Dcreate1(file_id1, "/data_alpha", complex_id, fid1, H5P_DEFAULT); dataset_b = H5Dcreate1(file_id1, "/data_beta", complex_id, fid1, H5P_DEFAULT); dataset_ia = H5Dcreate1(file_id1, "/data_ialpha", complex_id, fid1, H5P_DEFAULT); dataset_ib = H5Dcreate1(file_id1, "/data_ibeta", complex_id, fid1, H5P_DEFAULT); dataset_Nx = H5Dcreate1(file_id1, "data_Nx", H5T_STD_I32LE, fid2, H5P_DEFAULT); dataset_Ny = H5Dcreate1(file_id1, "data_Ny", H5T_STD_I32LE, fid2, H5P_DEFAULT); dataset_Nz = H5Dcreate1(file_id1, "data_Nz", H5T_STD_I32LE, fid2, H5P_DEFAULT); dataset_dt = H5Dcreate1(file_id1, "data_dt", H5T_IEEE_F64LE, fid2, H5P_DEFAULT); dataset_Re = H5Dcreate1(file_id1, "data_Re", H5T_IEEE_F64LE, fid2, H5P_DEFAULT); dataset_mpg = H5Dcreate1(file_id1, "data_mpg", H5T_IEEE_F64LE, fid2, H5P_DEFAULT); /* write data to corresponding datasets */ ret = H5Dwrite(dataset_a, complex_id, H5S_ALL, fid1, H5P_DEFAULT, Matrix1); ret = H5Dwrite(dataset_b, complex_id, H5S_ALL, fid1, H5P_DEFAULT, Matrix2); ret = H5Dwrite(dataset_ia, complex_id, H5S_ALL, fid1, H5P_DEFAULT, IMatrix1); ret = H5Dwrite(dataset_ib, complex_id, H5S_ALL, fid1, H5P_DEFAULT, IMatrix2); ret = H5Dwrite(dataset_Nx, H5T_NATIVE_INT, H5S_ALL, fid2, H5P_DEFAULT, &Nx); ret = H5Dwrite(dataset_Ny, H5T_NATIVE_INT, H5S_ALL, fid2, H5P_DEFAULT, &Ny); ret = H5Dwrite(dataset_Nz, H5T_NATIVE_INT, H5S_ALL, fid2, H5P_DEFAULT, &Nz); ret = H5Dwrite(dataset_dt, H5T_IEEE_F64LE, H5S_ALL, fid2, H5P_DEFAULT, &dt); ret = H5Dwrite(dataset_Re, H5T_IEEE_F64LE, H5S_ALL, fid2, H5P_DEFAULT, &re); ret = H5Dwrite(dataset_mpg, H5T_IEEE_F64LE, H5S_ALL, fid2, H5P_DEFAULT, &mpg); /* close datasets and file */ ret = H5Dclose(dataset_a); ret = H5Dclose(dataset_b); ret = H5Dclose(dataset_ia); ret = H5Dclose(dataset_ib); ret = H5Dclose(dataset_Nx); ret = H5Dclose(dataset_Ny); ret = H5Dclose(dataset_Nz); ret = H5Dclose(dataset_dt); ret = H5Dclose(dataset_Re); ret = H5Dclose(dataset_mpg); ret = H5Sclose(fid1); ret = H5Sclose(fid2); ret = H5Fclose(file_id1); return (EXIT_SUCCESS);}
开发者ID:huahbo,项目名称:shadow-channel,代码行数:101,
示例7: if/* * Write 2D data to HDF5 file */void cData2d::writeHDF5(char* filename){ // Figure out the HDF5 data type hid_t out_type_id = 0; if(sizeof(tData2d) == sizeof(float)) out_type_id = H5T_NATIVE_FLOAT; else if(sizeof(tData2d) == sizeof(double)) out_type_id = H5T_NATIVE_DOUBLE; else { printf("2dData::writeHDF5: unsuppoted data type/n"); exit(1); } // Create the file and data group hid_t file_id; file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); H5Gcreate1(file_id,"data",0); // Data space dimensions int ndims = 2; hsize_t dims[ndims]; dims[0] = ny; dims[1] = nx; // Write the data hid_t dataspace_id; hid_t dataset_id; dataspace_id = H5Screate_simple(ndims, dims, NULL); dataset_id = H5Dcreate1(file_id, "/data/data", out_type_id, dataspace_id, H5P_DEFAULT); if(H5Dwrite(dataset_id,out_type_id , H5S_ALL, H5S_ALL,H5P_DEFAULT, data)< 0){ printf("2dData::writeHDF5: Error writing data to file/n"); exit(1); } // Close and exit H5Dclose(dataset_id); // Cleanup stale IDs hid_t ids[256]; int n_ids = H5Fget_obj_ids(file_id, H5F_OBJ_ALL, 256, ids); for (long i=0; i<n_ids; i++ ) { hid_t id; H5I_type_t type; id = ids[i]; type = H5Iget_type(id); if ( type == H5I_GROUP ) H5Gclose(id); if ( type == H5I_DATASET ) H5Dclose(id); if ( type == H5I_DATASPACE ) H5Sclose(id); //if ( type == H5I_DATATYPE ) // H5Dclose(id); } H5Fclose(file_id);}
开发者ID:antonbarty,项目名称:cheetah-old,代码行数:64,
示例8: test_multi_compat/*------------------------------------------------------------------------- * Function: test_multi_compat * * Purpose: Tests the backward compatibility for MULTI 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. This test verifies the fix for * Issue 2598. In v1.6 library, there was EOA for the whole * MULTI file saved in the super block. We took it out in * v1.8 library because it's meaningless for the MULTI file. * v1.8 library saves the EOA for the metadata file, instead. * * Return: Success: 0 * Failure: -1 * * Programmer: Raymond Lu * 21 June 2011 * *------------------------------------------------------------------------- */static herr_ttest_multi_compat(void){ hid_t file=(-1), fapl, dset=(-1), space=(-1); char newname[1024]; char filename_s[1024], newname_s[1024]; char filename_r[1024], newname_r[1024]; H5FD_mem_t mt, memb_map[H5FD_MEM_NTYPES]; hid_t memb_fapl[H5FD_MEM_NTYPES]; haddr_t memb_addr[H5FD_MEM_NTYPES]; const char *memb_name[H5FD_MEM_NTYPES]; char sv[H5FD_MEM_NTYPES][32]; hsize_t dims[2]={MULTI_SIZE, MULTI_SIZE}; int i, j; int buf[MULTI_SIZE][MULTI_SIZE]; TESTING("MULTI file driver backward compatibility"); /* Set file access property list for MULTI driver */ fapl = h5_fileaccess(); HDmemset(memb_map, 0, sizeof memb_map); HDmemset(memb_fapl, 0, sizeof memb_fapl); HDmemset(memb_name, 0, sizeof memb_name); HDmemset(memb_addr, 0, sizeof memb_addr); HDmemset(sv, 0, sizeof sv); for(mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t,mt)) memb_map[mt] = H5FD_MEM_SUPER; memb_map[H5FD_MEM_DRAW] = H5FD_MEM_DRAW; memb_fapl[H5FD_MEM_SUPER] = H5P_DEFAULT; sprintf(sv[H5FD_MEM_SUPER], "%%s-%c.h5", 's'); memb_name[H5FD_MEM_SUPER] = sv[H5FD_MEM_SUPER]; memb_addr[H5FD_MEM_SUPER] = 0; memb_fapl[H5FD_MEM_DRAW] = H5P_DEFAULT; sprintf(sv[H5FD_MEM_DRAW], "%%s-%c.h5", 'r'); memb_name[H5FD_MEM_DRAW] = sv[H5FD_MEM_DRAW]; memb_addr[H5FD_MEM_DRAW] = HADDR_MAX/2; if(H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, memb_addr, TRUE)<0) TEST_ERROR; 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;//.........这里部分代码省略.........
开发者ID:FilipeMaia,项目名称:hdf5,代码行数:101,
示例9: test_direct//.........这里部分代码省略......... * 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(0 != HDposix_memalign(&points, (size_t)FBSIZE, (size_t)(DSET1_DIM1 * DSET1_DIM2 * sizeof(int)))) TEST_ERROR; if(0 != HDposix_memalign(&check, (size_t)FBSIZE, (size_t)(DSET1_DIM1 * DSET1_DIM2 * sizeof(int)))) TEST_ERROR; /* 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) TEST_ERROR; if(H5Dclose(dset1) < 0) TEST_ERROR; if((dset1 = H5Dopen2(file, DSET1_NAME, H5P_DEFAULT)) < 0) TEST_ERROR; /* Read the data back from dset1 */ if(H5Dread(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check) < 0) TEST_ERROR; /* Check that the values read are the same as the values written */ p1 = points; p2 = check; for(i = 0; i < DSET1_DIM1; i++) for(j = 0; j < DSET1_DIM2; j++) if(*p1++ != *p2++) { H5_FAILED(); printf(" Read different values than written in data set 1./n"); printf(" At index %d,%d/n", i, j); TEST_ERROR; } /* end if */ /* Create the data space2. For data set 2, memory address and data size are not aligned. */ dims2[0] = DSET2_DIM; if((space2 = H5Screate_simple(1, dims2, NULL)) < 0) TEST_ERROR; /* Create the dset2 */ if((dset2 = H5Dcreate2(file, DSET2_NAME, H5T_NATIVE_INT, space2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; /* Write the data to the dset1 */ if(H5Dwrite(dset2, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata2) < 0)
开发者ID:FilipeMaia,项目名称:hdf5,代码行数:67,
示例10: read_file//.........这里部分代码省略......... dims[0] = pc; hdf5_dataspace_in_memory = H5Screate_simple(rank, dims, NULL); start[0] = pcsum; start[1] = 0; count[0] = pc; count[1] = get_values_per_blockelement(blocknr); pcsum += pc; H5Sselect_hyperslab(hdf5_dataspace_in_file, H5S_SELECT_SET, start, NULL, count, NULL); switch (get_datatype_in_block(blocknr)) { case 0: hdf5_datatype = H5Tcopy(H5T_NATIVE_UINT); break; case 1: hdf5_datatype = H5Tcopy(H5T_NATIVE_FLOAT); break; case 2: hdf5_datatype = H5Tcopy(H5T_NATIVE_UINT64); break; } H5Dread(hdf5_dataset, hdf5_datatype, hdf5_dataspace_in_memory, hdf5_dataspace_in_file, H5P_DEFAULT, CommBuffer); H5Tclose(hdf5_datatype); H5Sclose(hdf5_dataspace_in_memory); H5Sclose(hdf5_dataspace_in_file); H5Dclose(hdf5_dataset); }#endif } if(ThisTask == readTask && task != readTask) MPI_Ssend(CommBuffer, bytes_per_blockelement * pc, MPI_BYTE, task, TAG_PDATA, MPI_COMM_WORLD); if(ThisTask != readTask && task == ThisTask) MPI_Recv(CommBuffer, bytes_per_blockelement * pc, MPI_BYTE, readTask, TAG_PDATA, MPI_COMM_WORLD, &status); if(ThisTask == task) { empty_read_buffer(blocknr, nstart + offset, pc, type); offset += pc; } n_for_this_task -= pc; } while(n_for_this_task > 0); } } } if(ThisTask == readTask) { if(All.ICFormat == 1 || All.ICFormat == 2) { SKIP2; if(blksize1 != blksize2) {
开发者ID:zighany,项目名称:gadget2-AccretionDiscs,代码行数:67,
示例11: arma_H5Dclose herr_t arma_H5Dclose(hid_t dataset_id) { return H5Dclose(dataset_id); }
开发者ID:bingo4508,项目名称:Deep-Learning,代码行数:4,
示例12: mainintmain (void){ hid_t file, dataset2; /* file and dataset handles */ hid_t datatype16; /* handles */ hid_t dataspace2; /* handles */ hsize_t dimsf2[2]; /* dataset dimensions */ hid_t aid; /* dataspace identifiers */ hid_t attr2; /* attribute identifiers */ herr_t status; int16_t data2[SIZE][SIZE]; /* data to write*/ int i, j, n; n = 0; for(i = 0; i < SIZE; i++) for(j = 0; j < SIZE; j++) data2[i][j] = n++; /* * Assigns minimal and maximal values of int16 to data2 and * they will be used to check boudary values. */ data2[0][0] = -32768; data2[1][1] = 32767; /* * Create a new file using H5F_ACC_TRUNC access, * default file creation properties, and default file * access properties. */ file = H5Fcreate(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* * Set each dimension size to 0. */ dimsf2[0] = 0; dimsf2[1] = 0; dataspace2 = H5Screate_simple(2, dimsf2, NULL); /* * Define datatype for the data in the file. */ datatype16 = H5Tcopy(H5T_NATIVE_SHORT); /* * Create a new dataset within the file using defined dataspace and * datatype and default dataset creation properties. */ dataset2 = H5Dcreate2(file, "dataset_2d", datatype16, dataspace2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* * Write the data although it has no effect because each dim size is 0. */ status = H5Dwrite(dataset2, H5T_NATIVE_SHORT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data2); /* * Create 2D attributes. */ attr2 = H5Acreate2(dataset2, "attribute_2d", datatype16, dataspace2, H5P_DEFAULT, H5P_DEFAULT); /* * Write the data although it has no effect because each dim size is 0. */ status = H5Awrite(attr2, datatype16, data2); H5Aclose(attr2); /* * Close/release resources. */ H5Dclose(dataset2); H5Tclose(datatype16); H5Sclose(dataspace2); H5Fclose(file); return 0;}
开发者ID:OPENDAP,项目名称:hdf5_handler,代码行数:79,
示例13: mainintmain(void){ hid_t fid; hid_t fapl; hid_t did; hid_t space; hsize_t dim[1] = {DIM}; unsigned data[DIM]; unsigned u; herr_t ret; /* Generic return value */ /* Initialize the data */ for(u = 0; u < DIM; u++) data[u] = u; /* Create a FAPL with the metadata and small data aggregators turned off */ fapl = H5Pcreate(H5P_FILE_ACCESS); assert(fapl > 0); ret = H5Pset_meta_block_size(fapl, (hsize_t)0); assert(ret >= 0); ret = H5Pset_small_data_block_size(fapl, (hsize_t)0); assert(ret >= 0); /* Create file */ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); assert(fid > 0); /* Close FAPL */ ret = H5Pclose(fapl); assert(ret >= 0); /* Create dataspace */ space = H5Screate_simple(1, dim, NULL); assert(space > 0); /* Create dataset #1 */ did = H5Dcreate2(fid, "dset1", H5T_NATIVE_UINT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); assert(did > 0); ret = H5Dwrite(did, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); assert(ret >= 0); ret = H5Dclose(did); assert(ret >= 0); /* Create dataset #2 */ did = H5Dcreate2(fid, "dset2", H5T_NATIVE_UINT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); assert(did > 0); ret = H5Dwrite(did, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); assert(ret >= 0); ret = H5Dclose(did); assert(ret >= 0); /* Close dataspace */ ret = H5Sclose(space); assert(ret >= 0); /* Close file */ ret = H5Fclose(fid); assert(ret >= 0); return 0;}
开发者ID:ElaraFX,项目名称:hdf5,代码行数:62,
示例14: getProvider//.........这里部分代码省略......... nDimFile = nobjEman; else nDimFile = ( rank<3 || !isStack )?1:dims[0] ; if (select_img > nDimFile) REPORT_ERROR(ERR_INDEX_OUTOFBOUNDS, formatString("readHDF5 (%s): Image number %lu exceeds stack size %lu", filename.c_str(), select_img, nDimFile)); aDim.ndim = replaceNsize = (select_img == ALL_IMAGES)? nDimFile :1 ; setDimensions(aDim); //Read header only if(dataMode == HEADER || (dataMode == _HEADER_ALL && aDim.ndim > 1)) return errCode; // EMAN stores each image in a separate dataset if ( provider.first == EMAN ) select_img = 1; size_t imgStart = IMG_INDEX(select_img); size_t imgEnd = (select_img != ALL_IMAGES) ? imgStart + 1 : aDim.ndim; MD.clear(); MD.resize(imgEnd - imgStart,MDL::emptyHeader); if (dataMode < DATA) // Don't read data if not necessary but read the header return errCode; if ( H5Pget_layout(cparms) == H5D_CONTIGUOUS ) //We can read it directly readData(fimg, select_img, datatype, 0); else // We read it by hyperslabs { // Allocate memory for image data (Assume xdim, ydim, zdim and ndim are already set //if memory already allocated use it (no resize allowed) mdaBase->coreAllocateReuse(); hid_t memspace; hsize_t offset[4]; // Hyperslab offset in the file hsize_t count[4]; // Size of the hyperslab in the file // Define the offset and count of the hyperslab to be read. switch (rank) { case 4: count[0] = 1; case 3: // if (stack) count[rank-3] = aDim.zdim; offset[rank-2] = 0; case 2: count[rank-2] = aDim.ydim; offset[rank-2] = 0; break; } count[rank-1] = aDim.xdim; offset[rank-1] = 0; aDim.xdim = dims[rank-1]; aDim.ydim = (rank>1)?dims[rank-2]:1; aDim.zdim = (rank == 4)?dims[1]:1; // size_t nDimFile = (rank>2)?dims[0]:1 ; // Define the memory space to read a hyperslab. memspace = H5Screate_simple(rank,count,NULL); size_t data = (size_t) this->mdaBase->getArrayPointer(); size_t pad = aDim.zyxdim*gettypesize(myT()); for (size_t idx = imgStart, imN = 0; idx < imgEnd; ++idx, ++imN) { // Set the offset of the hyperslab to be read offset[0] = idx; if ( H5Sselect_hyperslab(filespace, H5S_SELECT_SET, offset, NULL, count, NULL) < 0 ) REPORT_ERROR(ERR_IO_NOREAD, formatString("readHDF5: Error selecting hyperslab %d from filename %s", imgStart, filename.c_str())); // movePointerTo(ALL_SLICES,imN); // Read if ( H5Dread(dataset, H5Datatype(myT()), memspace, filespace, H5P_DEFAULT, (void*)(data + pad*imN)) < 0 ) REPORT_ERROR(ERR_IO_NOREAD,formatString("readHDF5: Error reading hyperslab %d from filename %s", imgStart, filename.c_str())); } H5Sclose(memspace); } H5Pclose(cparms); H5Sclose(filespace); H5Dclose(dataset); return errCode;}
开发者ID:I2PC,项目名称:scipion,代码行数:101,
示例15: mainintmain (void){ hid_t vfile, file, src_space, mem_space, vspace, vdset, dset; /* Handles */ hid_t dcpl; herr_t status; hsize_t vdsdims[3] = {4*DIM0_1, VDSDIM1, VDSDIM2}, vdsdims_max[3] = {VDSDIM0, VDSDIM1, VDSDIM2}, dims[3] = {DIM0_1, DIM1, DIM2}, extdims[3] = {2*DIM0_1, DIM1, DIM2}, chunk_dims[3] = {DIM0_1, DIM1, DIM2}, dims_max[3] = {DIM0, DIM1, DIM2}, vdsdims_out[3], vdsdims_max_out[3], start[3], /* Hyperslab parameters */ stride[3], count[3], src_count[3], block[3]; hsize_t start_out[3], /* Hyperslab parameter out */ stride_out[3], count_out[3], block_out[3]; int i, j, k; H5D_layout_t layout; /* Storage layout */ size_t num_map; /* Number of mappings */ ssize_t len; /* Length of the string; also a return value */ char *filename; char *dsetname; int wdata[DIM0_1*DIM1*DIM2]; int rdata[80][10][10]; int a_rdata[20][10][10]; /* * Create source files and datasets. This step is optional. */ for (i=0; i < PLANE_STRIDE; i++) { /* * Initialize data for i-th source dataset. */ for (j = 0; j < DIM0_1*DIM1*DIM2; j++) wdata[j] = i+1; /* * Create the source files and datasets. Write data to each dataset and * close all resources. */ file = H5Fcreate (SRC_FILE[i], H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); src_space = H5Screate_simple (RANK, dims, dims_max); dcpl = H5Pcreate(H5P_DATASET_CREATE); status = H5Pset_chunk (dcpl, RANK, chunk_dims); dset = H5Dcreate2 (file, SRC_DATASET[i], H5T_NATIVE_INT, src_space, H5P_DEFAULT, dcpl, H5P_DEFAULT); status = H5Dwrite (dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); status = H5Sclose (src_space); status = H5Pclose (dcpl); status = H5Dclose (dset); status = H5Fclose (file); } vfile = H5Fcreate (VFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* Create VDS dataspace. */ vspace = H5Screate_simple (RANK, vdsdims, vdsdims_max); /* Create dataspaces for the source dataset. */ src_space = H5Screate_simple (RANK, dims, dims_max); /* Create VDS creation property */ dcpl = H5Pcreate (H5P_DATASET_CREATE); /* Initialize hyperslab values */ start[0] = 0; start[1] = 0; start[2] = 0; stride[0] = PLANE_STRIDE; /* we will select every fifth plane in VDS */ stride[1] = 1; stride[2] = 1; count[0] = H5S_UNLIMITED; count[1] = 1; count[2] = 1; src_count[0] = H5S_UNLIMITED; src_count[1] = 1; src_count[2] = 1; block[0] = 1; block[1] = DIM1; block[2] = DIM2; /* * Build the mappings * */ status = H5Sselect_hyperslab (src_space, H5S_SELECT_SET, start, NULL, src_count, block); for (i=0; i < PLANE_STRIDE; i++) { status = H5Sselect_hyperslab (vspace, H5S_SELECT_SET, start, stride, count, block); status = H5Pset_virtual (dcpl, vspace, SRC_FILE[i], SRC_DATASET[i], src_space); start[0]++; //.........这里部分代码省略.........
开发者ID:Starlink,项目名称:hdf5,代码行数:101,
示例16: test_core//.........这里部分代码省略......... * 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. */ if(NULL == (points = (int *)HDmalloc(DSET1_DIM1 * DSET1_DIM2 * sizeof(int)))) TEST_ERROR; if(NULL == (check = (int *)HDmalloc(DSET1_DIM1 * DSET1_DIM2 * sizeof(int)))) TEST_ERROR; /* 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) TEST_ERROR; if(H5Dclose(dset1) < 0) TEST_ERROR; if((dset1 = H5Dopen2(file, DSET1_NAME, H5P_DEFAULT)) < 0) TEST_ERROR; /* Read the data back from dset1 */ if(H5Dread(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, check) < 0) TEST_ERROR; /* Check that the values read are the same as the values written */ p1 = points; p2 = check; for(i = 0; i < DSET1_DIM1; i++) for(j = 0; j < DSET1_DIM2; j++) if(*p1++ != *p2++) { H5_FAILED(); printf(" Read different values than written in data set 1./n"); printf(" At index %d,%d/n", i, j); TEST_ERROR; } /* end if */ if(H5Dclose(dset1) < 0) TEST_ERROR; if(H5Fclose(file) < 0) TEST_ERROR; /* Open the file with backing store on for read and write. * Changes will be saved in file. */ if(H5Pset_fapl_core(fapl, (size_t)CORE_INCREMENT, TRUE) < 0) TEST_ERROR;
开发者ID:FilipeMaia,项目名称:hdf5,代码行数:66,
示例17: NC4_rename_dim/* Rename a dimension, for those who like to prevaricate. */intNC4_rename_dim(int ncid, int dimid, const char *name){ NC *nc; NC_GRP_INFO_T *grp; NC_HDF5_FILE_INFO_T *h5; NC_DIM_INFO_T *dim, *tmp_dim; char norm_name[NC_MAX_NAME + 1]; int retval; if (!name) return NC_EINVAL; LOG((2, "%s: ncid 0x%x dimid %d name %s", __func__, ncid, dimid, name)); /* Find info for this file and group, and set pointer to each. */ if ((retval = nc4_find_nc_grp_h5(ncid, &nc, &grp, &h5))) return retval; assert(nc); assert(h5 && grp); /* Trying to write to a read-only file? No way, Jose! */ if (h5->no_write) return NC_EPERM;#if 0 /*def USE_PNETCDF*/ /* Take care of files created/opened with parallel-netcdf library. */ if (h5->pnetcdf_file) return ncmpi_rename_dim(nc->int_ncid, dimid, name);#endif /* USE_PNETCDF */ /* Make sure this is a valid netcdf name. */ if ((retval = nc4_check_name(name, norm_name))) return retval; /* Check if name is in use, and retain a pointer to the correct dim */ tmp_dim = NULL; for (dim = grp->dim; dim; dim = dim->l.next) { if (!strncmp(dim->name, norm_name, NC_MAX_NAME)) return NC_ENAMEINUSE; if (dim->dimid == dimid) tmp_dim = dim; } if (!tmp_dim) return NC_EBADDIM; dim = tmp_dim; /* Check for renaming dimension w/o variable */ if (dim->hdf_dimscaleid) { /* Sanity check */ assert(!dim->coord_var); /* Close the HDF5 dataset */ if (H5Dclose(dim->hdf_dimscaleid) < 0) return NC_EHDFERR; dim->hdf_dimscaleid = 0; /* Now delete the dataset (it will be recreated later, if necessary) */ if (H5Gunlink(grp->hdf_grpid, dim->name) < 0) return NC_EDIMMETA; } /* Give the dimension its new name in metadata. UTF8 normalization * has been done. */ if(dim->name) free(dim->name); if (!(dim->name = malloc((strlen(norm_name) + 1) * sizeof(char)))) return NC_ENOMEM; strcpy(dim->name, norm_name); /* Check if dimension was a coordinate variable, but names are different now */ if (dim->coord_var && strcmp(dim->name, dim->coord_var->name)) { /* Break up the coordinate variable */ if ((retval = nc4_break_coord_var(grp, dim->coord_var, dim))) return retval; } /* Check if dimension should become a coordinate variable */ if (!dim->coord_var) { NC_VAR_INFO_T *var; /* Attempt to find a variable with the same name as the dimension in * the current group. */ if ((retval = nc4_find_var(grp, dim->name, &var))) return retval; /* Check if we found a variable and the variable has the dimension in * index 0. */ if (var && var->dim[0] == dim) { /* Sanity check */ assert(var->dimids[0] == dim->dimid);//.........这里部分代码省略.........
开发者ID:bishtgautam,项目名称:sbetr,代码行数:101,
示例18: test_family//.........这里部分代码省略......... /* 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] = (int)((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; if(H5Fget_vfd_handle(file, fapl2, (void **)&fhandle2) < 0) TEST_ERROR; if(*fhandle2 < 0) TEST_ERROR; /* Check file size API */ if(H5Fget_filesize(file, &file_size) < 0) TEST_ERROR; /* Some data has been written. The file size should be bigger (18KB+976) * bytes if int size is 4 bytes) now. */#if H5_SIZEOF_INT <= 4 if(file_size < (18 * KB) || file_size > (20 * KB)) TEST_ERROR;#elif H5_SIZEOF_INT >= 8 if(file_size < (32 * KB) || file_size > (40 * KB)) TEST_ERROR;#endif if(H5Sclose(space) < 0) TEST_ERROR; if(H5Dclose(dset) < 0) TEST_ERROR; if(H5Pclose(fapl2) < 0) TEST_ERROR; if(H5Fclose(file) < 0) TEST_ERROR; /* Test different wrong ways to reopen family files when there're multiple * member files existing. */ if(test_family_opens(filename, fapl) < 0) TEST_ERROR; /* Reopen the file with correct member file size. */ if(H5Pset_fapl_family(fapl, (hsize_t)FAMILY_SIZE, H5P_DEFAULT) < 0) TEST_ERROR; if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 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 (fapl2); H5Fclose(file); } H5E_END_TRY; return -1;}
开发者ID:FilipeMaia,项目名称:hdf5,代码行数:101,
示例19: RD_verify_datasetint RD_verify_dataset(hid_t file_id, const char *dset_name, int ndims, int *dims, hid_t dtype, int dims_known){ hid_t dset_id, dspc_id, dtyp_id; herr_t err; /* data sizes */ hsize_t *this_dims; int i; /* get dataset */ dset_id = H5Dopen2(file_id, dset_name, H5P_DEFAULT); if (!RD_ID_ISVALID(dset_id)) return RD_ERROR_DSETNOTVALID; /* get dataspace */ dspc_id = H5Dget_space(dset_id); if (!RD_ID_ISVALID(dspc_id)) return RD_ERROR_DSPACENOTVALID; /* check number of dimensions */ if (H5Sget_simple_extent_ndims(dspc_id) != ndims) return RD_ERROR_DSETBADNDIMS; /* get dimensions */ this_dims = malloc(sizeof(*this_dims)*ndims); if (H5Sget_simple_extent_dims(dspc_id, this_dims, NULL) < 0) return RD_ERROR_DSETBADDIMS; /* copy into or check agains dims */ if (dims_known) { for (i=0; i<ndims; i++) { if (dims[i] != (int)(this_dims[i])) return RD_ERROR_DSETBADDIMS; } } else { for (i=0; i<ndims; i++) { dims[i] = (int)(this_dims[i]); } } /* clean up */ free(this_dims); /* close dataspace */ err = H5Sclose(dspc_id); if (err < 0) return RD_ERROR_DSPACENOTVALID; /* get datatype */ dtyp_id = H5Dget_type(dset_id); if (!RD_ID_ISVALID(dtyp_id)) return RD_ERROR_DTYPENOTVALID; if (H5Tequal(dtyp_id, dtype) <= 0) return RD_ERROR_DTYPENOTVALID; /* close dataset */ err = H5Tclose(dtyp_id); if (err < 0) return RD_ERROR_DTYPENOTVALID; /* close dataset */ err = H5Dclose(dset_id); if (err < 0) return RD_ERROR_DSETNOTVALID; return 0;}
开发者ID:CCATObservatory,项目名称:mpi-mapmaker-test,代码行数:63,
示例20: 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. */ HDsnprintf(newname_individual, sizeof(newname_individual), newname, counter); HDsnprintf(pathname_individual, sizeof(pathname_individual), pathname, counter); while(h5_make_local_copy(pathname_individual, newname_individual) >= 0) { counter++; HDsnprintf(newname_individual, sizeof(newname_individual), newname, counter); HDsnprintf(pathname_individual, sizeof(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:FilipeMaia,项目名称:hdf5,代码行数:97,
示例21: H5Fopen//.........这里部分代码省略......... free(data); data = NULL; data = (tData2d *) calloc(nn, sizeof(tData2d)); // Read in data after setting up a temporary buffer of the appropriate variable type // Somehow this works best when split out accordint to different data types // Fix into general form later hid_t datatype_id; H5T_class_t dataclass; size_t size; datatype_id = H5Dget_type(dataset_id); dataclass = H5Tget_class(datatype_id); size = H5Tget_size(datatype_id); if(dataclass == H5T_FLOAT){ if (size == sizeof(float)) { float* buffer = (float *) calloc(nn, sizeof(float)); H5Dread(dataset_id, datatype_id, H5S_ALL,H5S_ALL, H5P_DEFAULT, buffer); for(long i=0; i<nn; i++) data[i] = buffer[i]; free(buffer); } else if (size == sizeof(double)) { double* buffer = (double *) calloc(nn, sizeof(double)); H5Dread(dataset_id, datatype_id, H5S_ALL,H5S_ALL, H5P_DEFAULT, buffer); for(long i=0; i<nn; i++) data[i] = buffer[i]; free(buffer); } else { printf("2dData::readHDF5: unknown floating point type, size=%i/n",(int) size); return; } } else if(dataclass == H5T_INTEGER){ if (size == sizeof(char)) { char* buffer = (char*) calloc(nn, sizeof(char)); H5Dread(dataset_id, datatype_id, H5S_ALL,H5S_ALL, H5P_DEFAULT, buffer); for(long i=0; i<nn; i++) data[i] = buffer[i]; free(buffer); } else if (size == sizeof(short)) { short* buffer = (short*) calloc(nn, sizeof(short)); H5Dread(dataset_id, datatype_id, H5S_ALL,H5S_ALL, H5P_DEFAULT, buffer); for(long i=0; i<nn; i++) data[i] = buffer[i]; free(buffer); } else if (size == sizeof(int)) { int* buffer = (int *) calloc(nn, sizeof(int)); H5Dread(dataset_id, datatype_id, H5S_ALL,H5S_ALL, H5P_DEFAULT, buffer); for(long i=0; i<nn; i++) data[i] = buffer[i]; free(buffer); } else if (size == sizeof(long)) { long* buffer = (long *) calloc(nn, sizeof(long)); H5Dread(dataset_id, datatype_id, H5S_ALL,H5S_ALL, H5P_DEFAULT, buffer); for(long i=0; i<nn; i++) data[i] = buffer[i]; free(buffer); } else { printf("2dData::readHDF5: unknown integer type, size=%lu/n",size); exit(1); } } else { printf("2dData::readHDF5: unknown HDF5 data type/n"); return; } // Close and cleanup H5Dclose(dataset_id); // Cleanup stale IDs hid_t ids[256]; int n_ids = H5Fget_obj_ids(file_id, H5F_OBJ_ALL, 256, ids); for (long i=0; i<n_ids; i++ ) { hid_t id; H5I_type_t type; id = ids[i]; type = H5Iget_type(id); if ( type == H5I_GROUP ) H5Gclose(id); if ( type == H5I_DATASET ) H5Dclose(id); if ( type == H5I_DATASPACE ) H5Sclose(id); //if ( type == H5I_DATATYPE ) // H5Dclose(id); } H5Fclose(file_id);}
开发者ID:antonbarty,项目名称:cheetah-old,代码行数:101,
示例22: test_multi//.........这里部分代码省略......... /* 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; if(H5Fget_vfd_handle(file, fapl2, (void **)&fhandle2) < 0) TEST_ERROR; if(*fhandle2<0) TEST_ERROR; /* Check file size API */ if(H5Fget_filesize(file, &file_size) < 0) TEST_ERROR; /* After the data is written, the file size is huge because the * beginning of raw data file is set at HADDR_MAX/2. It's supposed * to be (HADDR_MAX/2 + 128*128*4) */ if(file_size < HADDR_MAX/2 || file_size > HADDR_MAX) TEST_ERROR; if(H5Sclose(space) < 0) TEST_ERROR; if(H5Dclose(dset) < 0) TEST_ERROR; if(H5Pclose(fapl2) < 0) TEST_ERROR; /* Create and write attribute for the root group. */ if((root = H5Gopen2(file, "/", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Attribute string. */ if((atype = H5Tcopy(H5T_C_S1)) < 0) TEST_ERROR; if(H5Tset_size(atype, strlen(meta) + 1) < 0) TEST_ERROR; if(H5Tset_strpad(atype, H5T_STR_NULLTERM) < 0) TEST_ERROR; /* Create and write attribute */ if((aspace = H5Screate_simple(1, adims, NULL)) < 0) TEST_ERROR; if((attr = H5Acreate2(root, "Metadata", atype, aspace, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; if(H5Awrite(attr, atype, meta) < 0) TEST_ERROR; /* Close IDs */ if(H5Tclose(atype) < 0) TEST_ERROR; if(H5Sclose(aspace) < 0) TEST_ERROR; if(H5Aclose(attr) < 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); H5Pclose(fapl2); H5Fclose(file); } H5E_END_TRY; return -1;}
开发者ID:FilipeMaia,项目名称:hdf5,代码行数:101,
示例23: ReadHDF5file//.........这里部分代码省略......... dims[i] = dimsl[ndims-1-i]; //!!!!!!!! NOT SURE size_t nn = 1; for(int i = 0;i<ndims;i++) nn *= dimsl[i]; // Create space for the new data dtype* data = *outArray; if (data!=NULL) delete data;//free(data); *outArray = new dtype[nn]; data = *outArray; hid_t datatype_id; H5T_class_t dataclass; size_t size; datatype_id = H5Dget_type(dataset_id); dataclass = H5Tget_class(datatype_id); size = H5Tget_size(datatype_id); int rrr = sizeof(int); if(dataclass == H5T_FLOAT){ if (size == sizeof(float)) { float* buffer = (float *) calloc(nn, sizeof(float)); H5Dread(dataset_id, datatype_id, H5S_ALL,H5S_ALL, H5P_DEFAULT, buffer); for(long i=0; i<nn; i++) data[i] = buffer[i]; free(buffer); } else if (size == sizeof(double)) { double* buffer = (double *) calloc(nn, sizeof(double)); H5Dread(dataset_id, datatype_id, H5S_ALL,H5S_ALL, H5P_DEFAULT, buffer); for(long i=0; i<nn; i++) data[i] = buffer[i]; free(buffer); } else { printf("2dData::readHDF5: unknown floating point type, size=%i/n",(int) size); return false; } } else if(dataclass == H5T_INTEGER){ if (size == sizeof(short)) { short* buffer = (short*) calloc(nn, sizeof(short)); H5Dread(dataset_id, datatype_id, H5S_ALL,H5S_ALL, H5P_DEFAULT, buffer); for(long i=0; i<nn; i++) data[i] = buffer[i]; free(buffer); } else if (size == sizeof(int)) { int* buffer = (int *) calloc(nn, sizeof(int)); H5Dread(dataset_id, datatype_id, H5S_ALL,H5S_ALL, H5P_DEFAULT, buffer); for(long i=0; i<nn; i++) data[i] = buffer[i]; free(buffer); } else if (size == sizeof(long)) { long* buffer = (long *) calloc(nn, sizeof(long)); H5Dread(dataset_id, datatype_id, H5S_ALL,H5S_ALL, H5P_DEFAULT, buffer); for(long i=0; i<nn; i++) data[i] = buffer[i]; free(buffer); } else { printf("2dData::readHDF5: unknown integer type, size=%i/n",(int) size); return false; } } else { printf("2dData::readHDF5: unknown HDF5 data type/n"); return false; } // Close and cleanup H5Dclose(dataset_id); // Cleanup stale IDs hid_t ids[256]; int n_ids = H5Fget_obj_ids(file_id, H5F_OBJ_ALL, 256, ids); for (long i=0; i<n_ids; i++ ) { hid_t id; H5I_type_t type; id = ids[i]; type = H5Iget_type(id); if ( type == H5I_GROUP ) H5Gclose(id); if ( type == H5I_DATASET ) H5Dclose(id); if ( type == H5I_DATASPACE ) H5Sclose(id); //if ( type == H5I_DATATYPE ) // H5Dclose(id); } H5Fclose(file_id); return true;#endif return false;}
开发者ID:shibom,项目名称:scripts_sls,代码行数:101,
示例24: h5_write_bnd_box_max_sp_void h5_write_bnd_box_max_sp_(hid_t* file_identifier, int* maximum_blocks, int* bnd_box, int* local_blocks, int* total_blocks, int* global_offset){ hid_t dataspace, dataset, memspace, dxfer_template; herr_t status; int rank; hsize_t dimens_2d[2], dimens_3d[3]; hsize_t start_2d[2], start_3d[3]; hsize_t stride_2d[2], stride_3d[3], count_2d[2], count_3d[3]; int ierr; /* set the dimensions of the dataset */ rank = 2; dimens_2d[0] = *total_blocks; dimens_2d[1] = NDIM; dataspace = H5Screate_simple(rank, dimens_2d, NULL); /* create the dataset */ dataset = H5Dcreate(*file_identifier, "bounding box maximum", H5T_NATIVE_FLOAT, dataspace, H5P_DEFAULT); /* create the hyperslab -- this will differ on the different processors */ start_2d[0] = (hsize_t) (*global_offset); start_2d[1] = 0; stride_2d[0] = 1; stride_2d[1] = 1; count_2d[0] = (hsize_t) (*local_blocks); count_2d[1] = NDIM; status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start_2d, stride_2d, count_2d, NULL); /* create the memory space */ rank = 3; dimens_3d[0] = *maximum_blocks; dimens_3d[1] = MDIM; dimens_3d[2] = 2; memspace = H5Screate_simple(rank, dimens_3d, NULL); start_3d[0] = 0; start_3d[1] = 0; start_3d[2] = 1; /* we want the maximum */ stride_3d[0] = 1; stride_3d[1] = 1; stride_3d[2] = 1; count_3d[0] = *local_blocks; count_3d[1] = NDIM; count_3d[2] = 1; ierr = H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start_3d, stride_3d, count_3d, NULL); flash_tune_plist(&dxfer_template ); /* write the data */ status = H5Dwrite(dataset, H5T_NATIVE_FLOAT, memspace, dataspace, dxfer_template, bnd_box); H5Pclose(dxfer_template); H5Sclose(memspace); H5Sclose(dataspace); H5Dclose(dataset);}
开发者ID:gcongiu,项目名称:E10,代码行数:76,
示例25: mainint main(int argc,char *argv[]) { struct options opts = { 0, 1, 0, 0, -1, 1, 0, -1, 1, NULL, }; getopts(argc,argv,&opts); H5Eset_auto2(H5E_DEFAULT,NULL,NULL); hid_t fid = H5Fopen(opts.filename,H5F_ACC_RDONLY,H5P_DEFAULT); if(fid < 0) { fprintf(stderr,"Failed to open %s./n",opts.filename); return fid; } if(opts.info) { // count the number of trials in the file hid_t trial; int num_trials = 0; std::stringstream trial_name; for(;;) { trial_name.str(""); trial_name << "/Trial" << num_trials+1; if((trial = H5Gopen(fid,trial_name.str().c_str(),H5P_DEFAULT)) < 0) break; else { print_trial_info(trial,++num_trials); H5Gclose(trial); } } H5Fclose(fid); return 0; } std::stringstream data_name; data_name << "/Trial" << opts.trial << "/Synchronous Data/Channel Data"; hid_t table = H5Dopen(fid,data_name.str().c_str(),H5P_DEFAULT); if(table < 0) { fprintf(stderr,"Requested trial #%d does not exist./n",opts.trial); return table; } hsize_t ncols = H5Tget_size(H5Dget_type(table))/sizeof(double); H5Dclose(table); table = H5PTopen(fid,data_name.str().c_str()); hsize_t nrows; H5PTget_num_packets(table,&nrows); // validate column and row ranges if(opts.cols_end == -1 || opts.cols_end >= ncols) opts.cols_end = ncols-1; if(opts.rows_end == -1 || opts.rows_end >= nrows) opts.rows_end = nrows-1; opts.cols_end -= (opts.cols_end-opts.cols_start)%opts.cols_step; opts.rows_end -= (opts.rows_end-opts.rows_start)%opts.rows_step; if((opts.cols_start-opts.cols_end)*opts.cols_step > 0) opts.cols_step *= -1; if((opts.rows_start-opts.rows_end)*opts.rows_step > 0) opts.rows_step *= -1; int row_idx = opts.rows_start; do { H5PTset_index(table,row_idx); double data[ncols]; H5PTget_next(table,1,data); int col_idx = opts.cols_start; do { if(opts.binary) { write(1,data+col_idx,sizeof(double)); } else { printf("%e ",data[col_idx]); } if(col_idx == opts.cols_end) break; col_idx += opts.cols_step; } while(1); if(!opts.binary) printf("/n"); if(row_idx == opts.rows_end) break;//.........这里部分代码省略.........
开发者ID:misterboyle,项目名称:rtxi,代码行数:101,
示例26: h5_write_unknowns_sp_//.........这里部分代码省略......... record_label_new, the 5th character is for the /0 termination */ strncpy(record_label_new, record_label,4); *(record_label_new + 4) = '/0'; /* set the dimensions of the dataset */ rank = 4; dimens_4d[0] = *total_blocks; dimens_4d[1] = *nzb; dimens_4d[2] = *nyb; dimens_4d[3] = *nxb; dataspace = H5Screate_simple(rank, dimens_4d, NULL);#ifdef DEBUG_IO printf("UNKNOWNS: dataspace = %d/n", (int) dataspace);#endif dataset_plist = H5Pcreate(H5P_DATASET_CREATE);#ifdef CHUNK /* set the layout to chunked */ ierr = H5Pset_layout(dataset_plist, H5D_CHUNKED); /* create a chunk containing 10 blocks worth of data */ dimens_chunk[0] = 10; dimens_chunk[1] = *nzb; dimens_chunk[2] = *nyb; dimens_chunk[3] = *nxb; ierr = H5Pset_chunk(dataset_plist, 4, dimens_chunk);#endif dataset = H5Dcreate(*file_identifier, record_label_new, H5T_NATIVE_FLOAT, dataspace, dataset_plist); #ifdef DEBUG_IO printf("UNKNOWNS: dataset = %d/n", (int) dataset);#endif /* create the hyperslab -- this will differ on the different processors */ start_4d[0] = (hsize_t) (*global_offset); start_4d[1] = 0; start_4d[2] = 0; start_4d[3] = 0; stride_4d[0] = 1; stride_4d[1] = 1; stride_4d[2] = 1; stride_4d[3] = 1; count_4d[0] = (hsize_t) (*local_blocks); count_4d[1] = *nzb; count_4d[2] = *nyb; count_4d[3] = *nxb; status = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, start_4d, stride_4d, count_4d, NULL);#ifdef DEBUG_IO printf("UNKNOWNS: hyperslab selection = %d/n", (int) status);#endif /* create the memory space -- we can get away with a simple memory space for the unknowns, since we are passing a contiguous block of memory now, and the block count is the last index in FORTRAN */ rank = 5; dimens_5d[0] = *local_blocks; dimens_5d[1] = *nzb+(*nguard)*2*k3d; dimens_5d[2] = *nyb+(*nguard)*2*k2d; dimens_5d[3] = *nxb+(*nguard)*2; dimens_5d[4] = *nvar; memspace = H5Screate_simple(rank, dimens_5d, NULL);#ifdef DEBUG_IO printf("UNKNOWNS: memspace = %d/n", (int) memspace);#endif /* setting the transfer template */ flash_tune_plist(&dxfer_template);#ifdef DEBUG_IO printf("UNKNOWNS: dxfer_template = %d/n", (int) dxfer_template);#endif /* write the data */ status = H5Dwrite(dataset, H5T_NATIVE_FLOAT, memspace, dataspace, dxfer_template, unknowns);#ifdef DEBUG_IO printf("UNKNOWNS: wrote unknowns, status = %d/n", (int) status);#endif H5Pclose(dxfer_template); H5Sclose(memspace); H5Sclose(dataspace); H5Dclose(dataset);}
开发者ID:gcongiu,项目名称:E10,代码行数:101,
示例27: create_scale_offset_dsets_long_long/*------------------------------------------------------------------------- * Function: create_scale_offset_dset_long_long * * Purpose: Create a dataset of LONG LONG datatype with scale-offset * filter * * Return: Success: 0 * Failure: -1 * * Programmer: Neil Fortner * 27 January 2011 * * Modifications: * *------------------------------------------------------------------------- */intcreate_scale_offset_dsets_long_long(hid_t fid, hid_t fsid, hid_t msid){ hid_t dataset; /* dataset handles */ hid_t dcpl; long long data[NX][NY]; /* data to write */ long long fillvalue = -2; hsize_t chunk[RANK] = {CHUNK0, CHUNK1}; int i, j; /* * Data and output buffer initialization. */ for (j = 0; j < NX; j++) { for (i = 0; i < NY; i++) data[j][i] = i + j; } /* * 0 1 2 3 4 5 * 1 2 3 4 5 6 * 2 3 4 5 6 7 * 3 4 5 6 7 8 * 4 5 6 7 8 9 * 5 6 7 8 9 10 */ /* * Create the dataset creation property list, add the Scale-Offset * filter, set the chunk size, and set the fill value. */ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR if(H5Pset_scaleoffset(dcpl, H5Z_SO_INT, H5Z_SO_INT_MINBITS_DEFAULT) < 0) TEST_ERROR if(H5Pset_chunk(dcpl, RANK, chunk) < 0) TEST_ERROR if(H5Pset_fill_value(dcpl, H5T_NATIVE_LLONG, &fillvalue) < 0) TEST_ERROR /* * Create a new dataset within the file using defined dataspace, little * endian datatype and default dataset creation properties. */ if((dataset = H5Dcreate2(fid, DATASETNAME12, H5T_STD_I64LE, fsid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* * Write the data to the dataset using default transfer properties. */ if(H5Dwrite(dataset, H5T_NATIVE_LLONG, msid, fsid, H5P_DEFAULT, data) < 0) TEST_ERROR /* Close dataset */ if(H5Dclose(dataset) < 0) TEST_ERROR /* Now create a dataset with a big-endian type */ if((dataset = H5Dcreate2(fid, DATASETNAME13, H5T_STD_I64BE, fsid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR if(H5Dwrite(dataset, H5T_NATIVE_LLONG, msid, fsid, H5P_DEFAULT, data) < 0) TEST_ERROR if(H5Dclose(dataset) < 0) TEST_ERROR /* * Close/release resources. */ if(H5Pclose(dcpl) < 0) TEST_ERROR return 0;error: H5E_BEGIN_TRY { H5Pclose(dcpl); H5Dclose(dataset); } H5E_END_TRY; return -1;}
开发者ID:AndyHuang7601,项目名称:EpicGames-UnrealEngine,代码行数:98,
示例28: h5_write_header_info_sp_void h5_write_header_info_sp_(int* MyPE, int* nvar_out, /* num vars to store */ hid_t* file_identifier, /* file handle */ char file_creation_time[],/* time / date stamp */ char flash_version[], /* FLASH version num */ char run_comment[], /* runtime comment */ int* total_blocks, /* total # of blocks */ float* time, /* simulation time */ float* timestep, /* current timestep */ int* nsteps, /* # of timestep */ int nzones_block[3], /* nxb, nyb, nzb */ char unk_labels[][5]) /* unknown labels */{ hid_t dataspace, dataset; herr_t status; int rank; hsize_t dimens_1d, dimens_2d[2]; int string_size; hid_t string_type, sp_type; typedef struct sim_params_t { int total_blocks; int nsteps; int nxb; int nyb; int nzb; float time; float timestep; } sim_params_t; sim_params_t sim_params; /* file creation time */ rank = 1; dimens_1d = 1; /* manually set the string size, and make it null terminated */ string_size = 40; /* setup the datatype for this string length */ string_type = H5Tcopy(H5T_C_S1); H5Tset_size(string_type, string_size); dataspace = H5Screate_simple(rank, &dimens_1d, NULL); dataset = H5Dcreate(*file_identifier, "file creation time", string_type, dataspace, H5P_DEFAULT); if (*MyPE == 0) { status = H5Dwrite(dataset, string_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, file_creation_time);#ifdef DEBUG_IO printf("MyPE = %d, wrote file creation time, status = %d/n", *MyPE, (int) status);#endif } H5Tclose(string_type); H5Sclose(dataspace); H5Dclose(dataset); /* FLASH version */ /* manually set the string size, and make it null terminated */ string_size = 20; /* setup the datatype for this string length */ string_type = H5Tcopy(H5T_C_S1); H5Tset_size(string_type, string_size); dataspace = H5Screate_simple(rank, &dimens_1d, NULL); dataset = H5Dcreate(*file_identifier, "FLASH version", string_type, dataspace, H5P_DEFAULT); if (*MyPE == 0) { status = H5Dwrite(dataset, string_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, flash_version);#ifdef DEBUG_IO printf("wrote flash version, status = %d/n", (int) status);#endif } H5Tclose(string_type); H5Sclose(dataspace); H5Dclose(dataset); /*----------------------------------------------------------------------- create a compound datatype to hold the simulation parameters -- this will cut down on the number of writes issued, and should improve performance ------------------------------------------------------------------------- */ sim_params.total_blocks = *total_blocks;//.........这里部分代码省略.........
开发者ID:gcongiu,项目名称:E10,代码行数:101,
示例29: create_szip_dsets_float/*------------------------------------------------------------------------- * Function: create_szip_dsets_float * * Purpose: Create a dataset of FLOAT datatype with szip filter * * Return: Success: 0 * Failure: -1 * * Programmer: Raymond Lu * 29 March 2011 * * Modifications: * *------------------------------------------------------------------------- */intcreate_szip_dsets_float(hid_t fid, hid_t fsid, hid_t msid){ hid_t dataset; /* dataset handles */ hid_t dcpl; float data[NX][NY]; /* data to write */ float fillvalue = -2.2f; hsize_t chunk[RANK] = {CHUNK0, CHUNK1}; int i, j; /* * Data and output buffer initialization. */ for (j = 0; j < NX; j++) { for (i = 0; i < NY; i++) data[j][i] = ((float)(i + j + 1))/3; } /* * Create the dataset creation property list, add the Scale-Offset * filter, set the chunk size, and set the fill value. */ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR if(H5Pset_szip(dcpl, H5_SZIP_NN_OPTION_MASK, 4) < 0) TEST_ERROR if(H5Pset_chunk(dcpl, RANK, chunk) < 0) TEST_ERROR if(H5Pset_fill_value(dcpl, H5T_NATIVE_FLOAT, &fillvalue) < 0) TEST_ERROR /* * Create a new dataset within the file using defined dataspace, little * endian datatype and default dataset creation properties. */ if((dataset = H5Dcreate2(fid, DATASETNAME18, H5T_IEEE_F32LE, fsid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* * Write the data to the dataset using default transfer properties. */ if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) TEST_ERROR /* Close dataset */ if(H5Dclose(dataset) < 0) TEST_ERROR /* Now create a dataset with a big-endian type */ if((dataset = H5Dcreate2(fid, DATASETNAME19, H5T_IEEE_F32BE, fsid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) TEST_ERROR if(H5Dclose(dataset) < 0) TEST_ERROR /* * Close/release resources. */ if(H5Pclose(dcpl) < 0) TEST_ERROR return 0;error: H5E_BEGIN_TRY { H5Pclose(dcpl); H5Dclose(dataset); } H5E_END_TRY; return -1;}
开发者ID:AndyHuang7601,项目名称:EpicGames-UnrealEngine,代码行数:89,
示例30: output//.........这里部分代码省略......... for (ll = 0; ll < ne; ll++) { dimsf[0] = nx; dimsf[1] = ny; dataspace = H5Screate_simple (RANK, dimsf, NULL); /* * Define datatype for the data in the file. * We will store little endian DOUBLE numbers. */ datatype = H5Tcopy (H5T_NATIVE_DOUBLE); status = H5Tset_order (datatype, H5T_ORDER_LE); /* * Create a new dataset within the file using defined dataspace and * datatype and default dataset creation properties. */ dataset = H5Dcreate (file, names[ll], datatype, dataspace, H5P_DEFAULT); for (jj = 0; jj < ny; jj++) { for (ii = 0; ii < nx; ii++) data[ii][jj] = grid[ii][jj][kk].array[ll]; } /* * Write the data to the dataset using default transfer properties. */ status = H5Dwrite (dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); /* * Close/release resources. */ H5Sclose (dataspace); H5Tclose (datatype); H5Dclose (dataset); } dimsf[0] = nx; dimsf[1] = ny; dataspace = H5Screate_simple (RANK, dimsf, NULL); /* * Define datatype for the data in the file. * We will store little endian DOUBLE numbers. */ datatype = H5Tcopy (H5T_NATIVE_DOUBLE); status = H5Tset_order (datatype, H5T_ORDER_LE); /* * Create a new dataset within the file using defined dataspace and * datatype and default dataset creation properties. */ dataset = H5Dcreate (file, "Pressure", datatype, dataspace, H5P_DEFAULT); for (jj = 0; jj < ny; jj++) { for (ii = 0; ii < nx; ii++) { rl = grid[ii][jj][kk] _MASS; px = grid[ii][jj][kk] _MOMX; py = grid[ii][jj][kk] _MOMY; pz = grid[ii][jj][kk] _MOMZ; et = grid[ii][jj][kk] _ENER; bx = grid[ii][jj][kk] _B_X; by = grid[ii][jj][kk] _B_Y; bz = grid[ii][jj][kk] _B_Z; ri = 1.0 / rl;
开发者ID:garethcmurphy,项目名称:mhdvanleer,代码行数:67,
注:本文中的H5Dclose函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ H5Dcreate函数代码示例 C++ H5Awrite函数代码示例 |