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

C++ H5Dclose函数代码示例

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

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



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


示例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:
 *
 *-------------------------------------------------------------------------
 */
int
create_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,代码来源:gen_cross.c


示例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:
 *
 *-------------------------------------------------------------------------
 */
int
create_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_DEFLATE
error:
    H5E_BEGIN_TRY {
        H5Pclose(dcpl);
        H5Dclose(dataset);
    } H5E_END_TRY;

    return -1;
#endif /* H5_HAVE_FILTER_DEFLATE */
}
开发者ID:AndyHuang7601,项目名称:EpicGames-UnrealEngine,代码行数:98,代码来源:gen_cross.c


示例4: WriteHDF5file

bool 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,代码来源:cbf2hdf5.cpp


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


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


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


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


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


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


示例11: arma_H5Dclose

 herr_t arma_H5Dclose(hid_t dataset_id)
   {
   return H5Dclose(dataset_id);
   }
开发者ID:bingo4508,项目名称:Deep-Learning,代码行数:4,代码来源:wrapper.cpp


示例12: main

int
main (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,代码来源:t_space_zero.c


示例13: main

int
main(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,代码来源:gen_specmetaread.c


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


示例15: main

int
main (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,代码来源:h5_vds-percival-unlim.c


示例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 s 

鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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