diff options
author | Scot Breitenfeld <brtnfld@hdfgroup.org> | 2009-03-30 21:33:45 (GMT) |
---|---|---|
committer | Scot Breitenfeld <brtnfld@hdfgroup.org> | 2009-03-30 21:33:45 (GMT) |
commit | 9bb1ff9c13f6a57c383954f5d68599891d2e94aa (patch) | |
tree | 70c2f0faab7b63b9cd4e855ee1b0225bc84da512 /hl/src | |
parent | ee0ecefd5420a4fa00bafb3ae84bbcf80b6cba1c (diff) | |
download | hdf5-9bb1ff9c13f6a57c383954f5d68599891d2e94aa.zip hdf5-9bb1ff9c13f6a57c383954f5d68599891d2e94aa.tar.gz hdf5-9bb1ff9c13f6a57c383954f5d68599891d2e94aa.tar.bz2 |
[svn-r16628] Description:
Cleaned up unused comments, fixed warnings issued by gcc compiler.
Tested: jam, smirom
Diffstat (limited to 'hl/src')
-rw-r--r-- | hl/src/H5LR.c | 335 | ||||
-rw-r--r-- | hl/src/H5LRpublic.h | 393 | ||||
-rw-r--r-- | hl/src/H5LT.c | 254 | ||||
-rw-r--r-- | hl/src/H5LTpublic.h | 22 |
4 files changed, 434 insertions, 570 deletions
diff --git a/hl/src/H5LR.c b/hl/src/H5LR.c index 5613c3d..f02899d 100644 --- a/hl/src/H5LR.c +++ b/hl/src/H5LR.c @@ -20,6 +20,8 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5LRprivate.h" + + /*------------------------------------------------------------------------- * * internal functions @@ -88,7 +90,7 @@ herr_t H5LRget_region_info(hid_t obj_id, if( path == NULL) { /* Determine the size of the name buffer, with null character included */ - *len = (size_t)(1 + H5Iget_name (dset, NULL, 0)); + *len = (size_t)(1 + H5Iget_name (dset, NULL, (size_t)0)); /* Determine the rank of the space */ H5E_BEGIN_TRY { @@ -211,108 +213,63 @@ herr_t H5LRget_region_info(hid_t obj_id, FUNC_LEAVE_API(ret_value) } -herr_t H5LRread_region(hid_t obj_id, - const hdset_reg_ref_t *ref, - hid_t mem_type, - size_t *numelem, - void *buf ) +/*------------------------------------------------------------------------- + * Function: H5LRread_region + * + * Purpose: Read raw data pointed by a region reference + * to an application buffer + * + * Return: Success: 0, Failure: -1 + * + * Programmer: M. Scot Breitenfeld + * + * Date: February 17, 2009 + * + *------------------------------------------------------------------------- + */ +herr_t H5LRread_region(hid_t obj_id, /* -IN- Id. of any object in a file associated with reference */ + const hdset_reg_ref_t *ref, /* -IN- Id. of the memory datatype */ + hid_t mem_type, /* -IN- Id. of the memory datatype */ + size_t *numelem, /* -IN/OUT- Number of elements in the referenced region */ + void *buf /* -OUT- Buffer containing data from the referenced region */ + ) { - hid_t dset = -1, sid = -1; - hid_t ret_value = SUCCEED; /* Return value */ - H5S_sel_type sel_type; - hid_t mem_space; - herr_t status; - hsize_t dims1[1]; + hid_t dset = -1, file_space = -1; /* Identifier of the dataset's dataspace in the file */ + hid_t ret_value = SUCCEED; /* Return value */ + H5S_sel_type sel_type; /* Type of the dataspace selection */ + hid_t mem_space; /* Identifier of the memory dataspace */ + herr_t status; /* API's error status */ + hsize_t dims1[1]; FUNC_ENTER_API(H5LRread_region, FAIL) + /* Open the HDF5 object referenced */ dset = H5Rdereference(obj_id, H5R_DATASET_REGION, ref); - sid = H5Rget_region (dset, H5R_DATASET_REGION, ref); - - sel_type = H5Sget_select_type(sid); + /* Retrieve the dataspace with the specified region selected */ + file_space = H5Rget_region (dset, H5R_DATASET_REGION, ref); - dims1[0] = H5Sget_select_npoints(sid); - - *numelem = (size_t)dims1[0]; + /* Determine the type of the dataspace selection */ + sel_type = H5Sget_select_type(file_space); + /* Determine the number of elements the dataspace selection */ + dims1[0] = H5Sget_select_npoints(file_space); + *numelem = (size_t)dims1[0]; + + /* If only wanted the number of elments, return */ if( buf == NULL) return SUCCEED; + /* Create a new simple dataspace in memory and open it for access */ mem_space = H5Screate_simple (1, dims1, NULL); + /* Read the region data from the file_space into the mem_space */ + status = H5Dread (dset, mem_type, mem_space, file_space, H5P_DEFAULT, buf); - status = H5Dread (dset, mem_type, mem_space, sid, H5P_DEFAULT, buf); - -/* close the data */ - - return SUCCEED; - - done: - FUNC_LEAVE_API(ret_value) -} - -herr_t H5LTread_region(const char *file, - const char *path, - hsize_t *block_coord, - hid_t mem_type, - void *buf ) -{ - hid_t ret_value = SUCCEED; /* Return value */ - herr_t status; - H5S_sel_type sel_type; - hsize_t *dims1; - hid_t file_id; - hid_t dset_id; - hid_t sid1; - hid_t sid2; - int ndim; - int i; - hsize_t *start, *count; - - FUNC_ENTER_API(H5LTread_region, FAIL) - - /* Open the file */ - file_id = H5Fopen(file, H5F_ACC_RDONLY, H5P_DEFAULT); - - /* Open the dataset for a given the path */ - dset_id = H5Dopen2(file_id, path, H5P_DEFAULT); - - /* Get the dataspace of the dataset */ - sid1 = H5Dget_space(dset_id); - - /* Find the rank of the dataspace */ - ndim = H5Sget_simple_extent_ndims(sid1); - - - /* Allocate space for the dimension array */ - dims1 = (hsize_t *)malloc (sizeof (hsize_t) * ndim); - - /* find the dimensions of each data space from the block coordinates */ - for (i=0; i<ndim; i++) - dims1[i] = block_coord[i+ndim] - block_coord[i] + 1; - - /* Create dataspace for reading buffer */ - sid2 = H5Screate_simple(ndim, dims1, NULL); - - /* Select (x , x , ..., x ) x (y , y , ..., y ) hyperslab for reading memory dataset */ - /* 1 2 n 1 2 n */ - - start = (hsize_t *)malloc (sizeof (hsize_t) * ndim); - count = (hsize_t *)malloc (sizeof (hsize_t) * ndim); - for (i=0; i<ndim; i++) { - start[i] = block_coord[i]; - count[i] = dims1[i]; - } - - status = H5Sselect_hyperslab(sid1,H5S_SELECT_SET,start,NULL,count,NULL); - - status = H5Dread(dset_id, mem_type, sid2, sid1, H5P_DEFAULT, buf); - -/* H5Sget_select_npoints(hid_t space_id) */ - - -/* close the data */ + /* Close appropriate items */ + status = H5Dclose(dset); + status = H5Sclose(mem_space); + status = H5Sclose(file_space); return SUCCEED; @@ -320,6 +277,21 @@ herr_t H5LTread_region(const char *file, FUNC_LEAVE_API(ret_value) } +/*------------------------------------------------------------------------- + * Function: H5LRcreate_region_references + * + * Purpose: Create an array of region references using an array of paths + * to datasets in a file and an array of the corresponding + * hyperslab descriptions. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: M. Scot Breitenfeld + * + * Date: February 17, 2009 + * + *------------------------------------------------------------------------- + */ herr_t H5LRcreate_region_references(hid_t file_id, size_t num_elem, @@ -339,7 +311,7 @@ herr_t H5LRcreate_region_references(hid_t file_id, FUNC_ENTER_API(H5LRcreate_region_references, FAIL) nstart = 0; - for(i=0; i<num_elem; i++) { + for(i=0; i<(int)num_elem; i++) { /* Open the dataset for a given the path */ dset_id = H5Dopen2(file_id, path[i], H5P_DEFAULT); @@ -386,6 +358,20 @@ herr_t H5LRcreate_region_references(hid_t file_id, } +/*------------------------------------------------------------------------- + * Function: H5LRmake_dataset + * + * Purpose: Creates a dataset and writes data associated with a list of + * region references to it. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: M. Scot Breitenfeld + * + * Date: February 17, 2009 + * + *------------------------------------------------------------------------- + */ herr_t H5LRmake_dataset(hid_t loc_id, const char *path, hid_t type_id, hid_t loc_id_ref, int buf_size, hdset_reg_ref_t *ref) { @@ -430,7 +416,7 @@ herr_t H5LRmake_dataset(hid_t loc_id, const char *path, hid_t type_id, hid_t loc bounds_coor = (hsize_t *)malloc (sizeof (hsize_t) * nrank * 2); /* a region reference is only allowed to reference one block */ - status = H5Sget_select_hyper_blocklist(sid_ref, 0, 1, bounds_coor ); + status = H5Sget_select_hyper_blocklist(sid_ref, (hsize_t)0, (hsize_t)1, bounds_coor ); for (j=0; j<nrank; j++) dims1[j] = bounds_coor[nrank +j] - bounds_coor[j] + 1; @@ -449,7 +435,7 @@ herr_t H5LRmake_dataset(hid_t loc_id, const char *path, hid_t type_id, hid_t loc status = H5Sget_select_bounds(sid_ref, start, end ); /* dims1[0] = 6; */ - + /* Create dataspace for datasets */ sid = H5Screate_simple(nrank, dims1, NULL); dset_id = H5Dcreate2(loc_id, path, type_id, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT ); @@ -496,6 +482,21 @@ herr_t H5LRmake_dataset(hid_t loc_id, const char *path, hid_t type_id, hid_t loc } +/*------------------------------------------------------------------------- + * Function: H5LRcopy_region + * + * Purpose: Copies data from a region specified by a reference to a region + * in a destination dataset. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: M. Scot Breitenfeld + * + * Date: February 17, 2009 + * + *------------------------------------------------------------------------- + */ + herr_t H5LRcopy_region(hid_t obj_id, hdset_reg_ref_t *ref, const char *file, @@ -535,7 +536,7 @@ herr_t H5LRcopy_region(hid_t obj_id, dims1 = (hsize_t *)malloc (sizeof (hsize_t) * nrank); bounds_coor = (hsize_t *)malloc (sizeof (hsize_t) * nrank * 2); - status = H5Sget_select_hyper_blocklist(sid_ref, 0, 1, bounds_coor); + status = H5Sget_select_hyper_blocklist(sid_ref, (hsize_t)0, (hsize_t)1, bounds_coor); numelem = 1; for (j=0; j<nrank; j++) { @@ -630,137 +631,20 @@ herr_t H5LRcopy_region(hid_t obj_id, FUNC_LEAVE_API(ret_value) } - -herr_t H5LTcopy_region(const char *file_src, - const char *path_src, - const hsize_t *block_coord_src, - const char *file_dest, - const char *path_dest, - hsize_t *block_coord_dset) -{ - hid_t ret_value = SUCCEED; /* Return value */ - herr_t status; - H5S_sel_type sel_type; - hsize_t *dims1, *dims_src; - hid_t sid1; - hid_t sid2; - hid_t fid_src, type_id, file_id; - hid_t did_src, sid_src,dset_id; - int ndim; - void *buf; - hsize_t numelem_src; - int nrank_src; - int i, j; - hsize_t *start, *count; - hid_t dtype; - - FUNC_ENTER_API(H5LTcopy_region, FAIL) - - /* Open the file */ - fid_src = H5Fopen(file_src, H5F_ACC_RDONLY, H5P_DEFAULT); - - /* Open the dataset for a given the path */ - did_src = H5Dopen2(fid_src, path_src, H5P_DEFAULT); - - /* Get the dataspace of the dataset */ - sid_src = H5Dget_space(did_src); - - /* Find the rank of the dataspace */ - nrank_src = H5Sget_simple_extent_ndims(sid_src); - - /* Allocate space for the dimension array */ - dims_src = (hsize_t *)malloc (sizeof (hsize_t) * nrank_src); - -/* bounds_coor = (hsize_t *)malloc (sizeof (hsize_t) * nrank * 2); */ -/* status = H5Sget_select_hyper_blocklist(sid_ref, 0, 1, bounds_coor); */ - - numelem_src = 1; - for (j=0; j<nrank_src; j++) { - dims_src[j] = block_coord_src[nrank_src + j] - block_coord_src[j] + 1; - numelem_src = dims_src[j]*numelem_src; - } - - dtype = H5Dget_type(did_src); - type_id = H5Tget_native_type(dtype , H5T_DIR_DEFAULT ); - - buf = malloc(sizeof(type_id) * numelem_src); - - /* Create dataspace for reading buffer */ - sid2 = H5Screate_simple(nrank_src, dims_src, NULL); - - /* Select (x , x , ..., x ) x (y , y , ..., y ) hyperslab for reading memory dataset */ - /* 1 2 n 1 2 n */ - - start = (hsize_t *)malloc (sizeof (hsize_t) * nrank_src); - count = (hsize_t *)malloc (sizeof (hsize_t) * nrank_src); - for (i=0; i<nrank_src; i++) { - start[i] = block_coord_src[i]; - count[i] = dims_src[i]; - } - - status = H5Sselect_hyperslab(sid_src,H5S_SELECT_SET,start,NULL,count,NULL); - - status = H5Dread(did_src, type_id, sid2, sid_src, H5P_DEFAULT, buf); - - status = H5Dclose(did_src); - status = H5Sclose(sid_src); - status = H5Sclose(sid2); - status = H5Fclose(fid_src); - free(dims_src); - -/* Open the file */ - file_id = H5Fopen(file_dest, H5F_ACC_RDWR, H5P_DEFAULT); - -/* Open the dataset for a given the path */ - dset_id = H5Dopen2(file_id, path_dest, H5P_DEFAULT); - -/* Get the dataspace of the dataset */ - sid1 = H5Dget_space(dset_id); - - -/* Find the rank of the dataspace */ - ndim = H5Sget_simple_extent_ndims(sid1); - - /* Allocate space for the dimension array */ - dims1 = (hsize_t *)malloc (sizeof (hsize_t) * ndim); - - /* find the dimensions of each data space from the block coordinates */ - for (i=0; i<ndim; i++) - dims1[i] = block_coord_dset[i+ndim] - block_coord_dset[i] + 1; - - /* Create dataspace for writing the buffer */ - sid2 = H5Screate_simple(ndim, dims1, NULL); - -/* Select (x , x , ..., x ) x (y , y , ..., y ) hyperslab for writing memory dataset */ -/* 1 2 n 1 2 n */ - - start = (hsize_t *)malloc (sizeof (hsize_t) * ndim); - count = (hsize_t *)malloc (sizeof (hsize_t) * ndim); - - for (i=0; i<ndim; i++) { - start[i] = block_coord_dset[i]; - count[i] = block_coord_dset[i + ndim] - start[i] + 1; - } - - status = H5Sselect_hyperslab(sid1,H5S_SELECT_SET,start,NULL,count,NULL); - - status = H5Dwrite(dset_id, type_id, sid2, sid1, H5P_DEFAULT, buf); - -/* close the data */ - - status = H5Dclose(dset_id); - status = H5Sclose(sid1); - status = H5Sclose(sid2); - status = H5Tclose(type_id); - status = H5Fclose(file_id); - free(dims1); - free(buf); - - return SUCCEED; - - done: - FUNC_LEAVE_API(ret_value) -} +/*------------------------------------------------------------------------- + * Function: H5LRcopy_references + * + * Purpose: Copy data from the specified dataset to a new location and + * create a reference to it. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: M. Scot Breitenfeld + * + * Date: February 17, 2009 + * + *------------------------------------------------------------------------- + */ herr_t H5LRcopy_references(hid_t obj_id, hdset_reg_ref_t *ref, const char *file, const char *path, const hsize_t *block_coord_dset, hdset_reg_ref_t *ref_new) @@ -797,7 +681,7 @@ herr_t H5LRcopy_references(hid_t obj_id, hdset_reg_ref_t *ref, const char *file, dims_src = (hsize_t *)malloc (sizeof (hsize_t) * nrank_src); bounds_coor = (hsize_t *)malloc (sizeof (hsize_t) * nrank_src * 2); - status = H5Sget_select_hyper_blocklist(sid_src, 0, 1, bounds_coor); + status = H5Sget_select_hyper_blocklist(sid_src, (hsize_t)0, (hsize_t)1, bounds_coor); numelem_src = 1; for (j=0; j<nrank_src; j++) { @@ -889,3 +773,4 @@ herr_t H5LRcopy_references(hid_t obj_id, hdset_reg_ref_t *ref, const char *file, done: FUNC_LEAVE_API(ret_value) } + diff --git a/hl/src/H5LRpublic.h b/hl/src/H5LRpublic.h index 2d5fc87..a6b3096 100644 --- a/hl/src/H5LRpublic.h +++ b/hl/src/H5LRpublic.h @@ -16,13 +16,13 @@ #ifndef _H5LRpublic_H #define _H5LRpublic_H -/* typedef enum H5LT_lang_t { */ -/* H5LT_LANG_ERR = -1, /\*this is the first*\/ */ -/* H5LT_DDL = 0, /\*for DDL*\/ */ -/* H5LT_C = 1, /\*for C*\/ */ -/* H5LT_FORTRAN = 2, /\*for Fortran*\/ */ -/* H5LT_NO_LANG = 3 /\*this is the last*\/ */ -/* } H5LT_lang_t; */ +typedef enum H5LR_lang_t { + H5LR_LANG_ERR = -1, /*this is the first*/ + H5LR_DDL = 0, /*for DDL*/ + H5LR_C = 1, /*for C*/ + H5LR_FORTRAN = 2, /*for Fortran*/ + H5LR_NO_LANG = 3 /*this is the last*/ +} H5LR_lang_t; #ifdef __cplusplus extern "C" { @@ -35,93 +35,45 @@ extern "C" { *------------------------------------------------------------------------- */ -/* H5_HLDLL herr_t H5LTmake_dataset( hid_t loc_id, */ -/* const char *dset_name, */ -/* int rank, */ -/* const hsize_t *dims, */ -/* hid_t type_id, */ -/* const void *buffer ); */ - -/* H5_HLDLL herr_t H5LTmake_dataset_char( hid_t loc_id, */ -/* const char *dset_name, */ -/* int rank, */ -/* const hsize_t *dims, */ -/* const char *buffer ); */ - -/* H5_HLDLL herr_t H5LTmake_dataset_short( hid_t loc_id, */ -/* const char *dset_name, */ -/* int rank, */ -/* const hsize_t *dims, */ -/* const short *buffer ); */ - -/* H5_HLDLL herr_t H5LTmake_dataset_int( hid_t loc_id, */ -/* const char *dset_name, */ -/* int rank, */ -/* const hsize_t *dims, */ -/* const int *buffer ); */ - -/* H5_HLDLL herr_t H5LTmake_dataset_long( hid_t loc_id, */ -/* const char *dset_name, */ -/* int rank, */ -/* const hsize_t *dims, */ -/* const long *buffer ); */ - -/* H5_HLDLL herr_t H5LTmake_dataset_float( hid_t loc_id, */ -/* const char *dset_name, */ -/* int rank, */ -/* const hsize_t *dims, */ -/* const float *buffer ); */ - -/* H5_HLDLL herr_t H5LTmake_dataset_double( hid_t loc_id, */ -/* const char *dset_name, */ -/* int rank, */ -/* const hsize_t *dims, */ -/* const double *buffer ); */ - -/* H5_HLDLL herr_t H5LTmake_dataset_string( hid_t loc_id, */ -/* const char *dset_name, */ -/* const char *buf ); */ - - -/* /\*------------------------------------------------------------------------- */ -/* * */ -/* * Read dataset functions */ -/* * */ -/* *------------------------------------------------------------------------- */ -/* *\/ */ - -/* H5_HLDLL herr_t H5LTread_dataset( hid_t loc_id, */ -/* const char *dset_name, */ -/* hid_t type_id, */ -/* void *buffer ); */ - -/* H5_HLDLL herr_t H5LTread_dataset_char( hid_t loc_id, */ -/* const char *dset_name, */ -/* char *buffer ); */ - -/* H5_HLDLL herr_t H5LTread_dataset_short( hid_t loc_id, */ -/* const char *dset_name, */ -/* short *buffer ); */ +H5_HLDLL herr_t H5LRmake_dataset(hid_t loc_id, + const char *path, + hid_t type_id, hid_t loc_id_ref, + int buf_size, hdset_reg_ref_t *buf); -/* H5_HLDLL herr_t H5LTread_dataset_int( hid_t loc_id, */ -/* const char *dset_name, */ -/* int *buffer ); */ +/*------------------------------------------------------------------------- + * + * Make and manipulate dataset region references functions + * + *------------------------------------------------------------------------- + */ +H5_HLDLL herr_t H5LRcreate_region_references(hid_t obj_id, + size_t num_elem, + const char **path, + hsize_t *block_coord, + hdset_reg_ref_t *buf); -/* H5_HLDLL herr_t H5LTread_dataset_long( hid_t loc_id, */ -/* const char *dset_name, */ -/* long *buffer ); */ +H5_HLDLL herr_t H5LRcopy_references(hid_t obj_id, hdset_reg_ref_t *ref, const char *file, + const char *path, const hsize_t *block_coord, + hdset_reg_ref_t *ref_new); -/* H5_HLDLL herr_t H5LTread_dataset_float( hid_t loc_id, */ -/* const char *dset_name, */ -/* float *buffer ); */ +H5_HLDLL herr_t H5LRcopy_region(hid_t obj_id, + hdset_reg_ref_t *ref, + const char *file, + const char *path, + hsize_t *block_coord); -/* H5_HLDLL herr_t H5LTread_dataset_double( hid_t loc_id, */ -/* const char *dset_name, */ -/* double *buffer ); */ +/*------------------------------------------------------------------------- + * + * Read dataset functions + * + *------------------------------------------------------------------------- + */ -/* H5_HLDLL herr_t H5LTread_dataset_string( hid_t loc_id, */ -/* const char *dset_name, */ -/* char *buf ); */ +H5_HLDLL herr_t H5LRread_region(hid_t obj_id, + const hdset_reg_ref_t *ref, + hid_t mem_type, + size_t *numelem, + void *buf ); /*------------------------------------------------------------------------- * @@ -130,7 +82,6 @@ extern "C" { *------------------------------------------------------------------------- */ - H5_HLDLL herr_t H5LRget_region_info(hid_t obj_id, const hdset_reg_ref_t *ref, size_t *len, @@ -141,258 +92,20 @@ H5_HLDLL herr_t H5LRget_region_info(hid_t obj_id, size_t *numelem, hsize_t *buf ); -H5_HLDLL herr_t H5LRread_region(hid_t obj_id, - const hdset_reg_ref_t *ref, - hid_t mem_type, - size_t *numelem, - void *buf ); - -H5_HLDLL herr_t H5LTread_region(const char *file, - const char *path, - hsize_t *block_coord, - hid_t mem_type, - void *buf ); - -H5_HLDLL herr_t H5LRcopy_region(hid_t obj_id, - hdset_reg_ref_t *ref, - const char *file, - const char *path, - hsize_t *block_coord); - -H5_HLDLL herr_t H5LRcreate_region_references(hid_t obj_id, - size_t num_elem, - const char **path, - hsize_t *block_coord, - hdset_reg_ref_t *buf); - -H5_HLDLL herr_t H5LRmake_dataset(hid_t loc_id, - const char *path, - hid_t type_id, hid_t loc_id_ref, - int buf_size, hdset_reg_ref_t *buf); - -H5_HLDLL herr_t H5LTcopy_region(const char *file_src, - const char *path_src, - const hsize_t *block_coord_src, - const char *file_dest, - const char *path_dest, - hsize_t *block_coord_dset); - -H5_HLDLL herr_t H5LRcopy_references(hid_t obj_id, hdset_reg_ref_t *ref, const char *file, - const char *path, const hsize_t *block_coord, hdset_reg_ref_t *ref_new); - - - - -/* H5_HLDLL herr_t H5LTget_dataset_ndims( hid_t loc_id, */ -/* const char *dset_name, */ -/* int *rank ); */ - -/* H5_HLDLL herr_t H5LTget_dataset_info( hid_t loc_id, */ -/* const char *dset_name, */ -/* hsize_t *dims, */ -/* H5T_class_t *type_class, */ -/* size_t *type_size ); */ - -/* H5_HLDLL herr_t H5LTfind_dataset( hid_t loc_id, const char *name ); */ - - - -/* /\*------------------------------------------------------------------------- */ -/* * */ -/* * Set attribute functions */ -/* * */ -/* *------------------------------------------------------------------------- */ -/* *\/ */ - - -/* H5_HLDLL herr_t H5LTset_attribute_string( hid_t loc_id, */ -/* const char *obj_name, */ -/* const char *attr_name, */ -/* const char *attr_data ); */ - -/* H5_HLDLL herr_t H5LTset_attribute_char( hid_t loc_id, */ -/* const char *obj_name, */ -/* const char *attr_name, */ -/* const char *buffer, */ -/* size_t size ); */ - -/* H5_HLDLL herr_t H5LTset_attribute_uchar( hid_t loc_id, */ -/* const char *obj_name, */ -/* const char *attr_name, */ -/* const unsigned char *buffer, */ -/* size_t size ); */ - -/* H5_HLDLL herr_t H5LTset_attribute_short( hid_t loc_id, */ -/* const char *obj_name, */ -/* const char *attr_name, */ -/* const short *buffer, */ -/* size_t size ); */ - -/* H5_HLDLL herr_t H5LTset_attribute_ushort( hid_t loc_id, */ -/* const char *obj_name, */ -/* const char *attr_name, */ -/* const unsigned short *buffer, */ -/* size_t size ); */ - -/* H5_HLDLL herr_t H5LTset_attribute_int( hid_t loc_id, */ -/* const char *obj_name, */ -/* const char *attr_name, */ -/* const int *buffer, */ -/* size_t size ); */ - -/* H5_HLDLL herr_t H5LTset_attribute_uint( hid_t loc_id, */ -/* const char *obj_name, */ -/* const char *attr_name, */ -/* const unsigned int *buffer, */ -/* size_t size ); */ - -/* H5_HLDLL herr_t H5LTset_attribute_long( hid_t loc_id, */ -/* const char *obj_name, */ -/* const char *attr_name, */ -/* const long *buffer, */ -/* size_t size ); */ - -/* H5_HLDLL herr_t H5LTset_attribute_long_long( hid_t loc_id, */ -/* const char *obj_name, */ -/* const char *attr_name, */ -/* const long_long *buffer, */ -/* size_t size ); */ - -/* H5_HLDLL herr_t H5LTset_attribute_ulong( hid_t loc_id, */ -/* const char *obj_name, */ -/* const char *attr_name, */ -/* const unsigned long *buffer, */ -/* size_t size ); */ - -/* H5_HLDLL herr_t H5LTset_attribute_float( hid_t loc_id, */ -/* const char *obj_name, */ -/* const char *attr_name, */ -/* const float *buffer, */ -/* size_t size ); */ - -/* H5_HLDLL herr_t H5LTset_attribute_double( hid_t loc_id, */ -/* const char *obj_name, */ -/* const char *attr_name, */ -/* const double *buffer, */ -/* size_t size ); */ - -/* /\*------------------------------------------------------------------------- */ -/* * */ -/* * Get attribute functions */ -/* * */ -/* *------------------------------------------------------------------------- */ -/* *\/ */ - -/* H5_HLDLL herr_t H5LTget_attribute( hid_t loc_id, */ -/* const char *obj_name, */ -/* const char *attr_name, */ -/* hid_t mem_type_id, */ -/* void *data ); */ - -/* H5_HLDLL herr_t H5LTget_attribute_string( hid_t loc_id, */ -/* const char *obj_name, */ -/* const char *attr_name, */ -/* char *data ); */ - -/* H5_HLDLL herr_t H5LTget_attribute_char( hid_t loc_id, */ -/* const char *obj_name, */ -/* const char *attr_name, */ -/* char *data ); */ - -/* H5_HLDLL herr_t H5LTget_attribute_uchar( hid_t loc_id, */ -/* const char *obj_name, */ -/* const char *attr_name, */ -/* unsigned char *data ); */ - -/* H5_HLDLL herr_t H5LTget_attribute_short( hid_t loc_id, */ -/* const char *obj_name, */ -/* const char *attr_name, */ -/* short *data ); */ - -/* H5_HLDLL herr_t H5LTget_attribute_ushort( hid_t loc_id, */ -/* const char *obj_name, */ -/* const char *attr_name, */ -/* unsigned short *data ); */ - -/* H5_HLDLL herr_t H5LTget_attribute_int( hid_t loc_id, */ -/* const char *obj_name, */ -/* const char *attr_name, */ -/* int *data ); */ - -/* H5_HLDLL herr_t H5LTget_attribute_uint( hid_t loc_id, */ -/* const char *obj_name, */ -/* const char *attr_name, */ -/* unsigned int *data ); */ - -/* H5_HLDLL herr_t H5LTget_attribute_long( hid_t loc_id, */ -/* const char *obj_name, */ -/* const char *attr_name, */ -/* long *data ); */ - -/* H5_HLDLL herr_t H5LTget_attribute_long_long( hid_t loc_id, */ -/* const char *obj_name, */ -/* const char *attr_name, */ -/* long_long *data ); */ - -/* H5_HLDLL herr_t H5LTget_attribute_ulong( hid_t loc_id, */ -/* const char *obj_name, */ -/* const char *attr_name, */ -/* unsigned long *data ); */ - -/* H5_HLDLL herr_t H5LTget_attribute_float( hid_t loc_id, */ -/* const char *obj_name, */ -/* const char *attr_name, */ -/* float *data ); */ - -/* H5_HLDLL herr_t H5LTget_attribute_double( hid_t loc_id, */ -/* const char *obj_name, */ -/* const char *attr_name, */ -/* double *data ); */ - - -/* /\*------------------------------------------------------------------------- */ -/* * */ -/* * Query attribute functions */ -/* * */ -/* *------------------------------------------------------------------------- */ -/* *\/ */ - - -/* H5_HLDLL herr_t H5LTget_attribute_ndims( hid_t loc_id, */ -/* const char *obj_name, */ -/* const char *attr_name, */ -/* int *rank ); */ - -/* H5_HLDLL herr_t H5LTget_attribute_info( hid_t loc_id, */ -/* const char *obj_name, */ -/* const char *attr_name, */ -/* hsize_t *dims, */ -/* H5T_class_t *type_class, */ -/* size_t *type_size ); */ - - - - - -/* /\*------------------------------------------------------------------------- */ -/* * */ -/* * General functions */ -/* * */ -/* *------------------------------------------------------------------------- */ -/* *\/ */ - -/* H5_HLDLL hid_t H5LTtext_to_dtype(const char *text, H5LT_lang_t lang_type); */ -/* H5_HLDLL herr_t H5LTdtype_to_text(hid_t dtype, char *str, H5LT_lang_t lang_type, size_t *len); */ - +/*------------------------------------------------------------------------- + * + * General functions + * + *------------------------------------------------------------------------- + */ -/* /\*------------------------------------------------------------------------- */ -/* * */ -/* * Utility functions */ -/* * */ -/* *------------------------------------------------------------------------- */ -/* *\/ */ -/* H5_HLDLL herr_t H5LTfind_attribute( hid_t loc_id, const char *name ); */ +/*------------------------------------------------------------------------- + * + * Utility functions + * + *------------------------------------------------------------------------- + */ #ifdef __cplusplus diff --git a/hl/src/H5LT.c b/hl/src/H5LT.c index 92965fd..8b390d6 100644 --- a/hl/src/H5LT.c +++ b/hl/src/H5LT.c @@ -1573,8 +1573,6 @@ out: } - - /*------------------------------------------------------------------------- * Function: H5LTtext_to_dtype * @@ -2892,4 +2890,256 @@ out: } +/*------------------------------------------------------------------------- + * Function: H5LTread_region + * + * Purpose: Reads selected data to an appication buffer + * + * Return: FAIL on error, SUCCESS on success + * + * Programmer: M. Scot Breitenfeld + * + * Date: February 17, 2009 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +herr_t H5LTread_region(const char *file, /* */ + const char *path, + hsize_t *block_coord, + hid_t mem_type, + void *buf ) +{ + hid_t ret_value = SUCCEED; /* Return value */ + herr_t status; + hsize_t *dims1; + hid_t file_id; + hid_t dset_id; + hid_t sid1; + hid_t sid2; + int ndim; + int i; + hsize_t *start, *count; + + + /* Open the file */ + file_id = H5Fopen(file, H5F_ACC_RDONLY, H5P_DEFAULT); + + /* Open the dataset for a given the path */ + dset_id = H5Dopen2(file_id, path, H5P_DEFAULT); + + /* Get the dataspace of the dataset */ + sid1 = H5Dget_space(dset_id); + + /* Find the rank of the dataspace */ + ndim = H5Sget_simple_extent_ndims(sid1); + + + /* Allocate space for the dimension array */ + dims1 = (hsize_t *)malloc (sizeof (hsize_t) * ndim); + + /* find the dimensions of each data space from the block coordinates */ + for (i=0; i<ndim; i++) + dims1[i] = block_coord[i+ndim] - block_coord[i] + 1; + + /* Create dataspace for reading buffer */ + sid2 = H5Screate_simple(ndim, dims1, NULL); + + /* Select (x , x , ..., x ) x (y , y , ..., y ) hyperslab for reading memory dataset */ + /* 1 2 n 1 2 n */ + + start = (hsize_t *)malloc (sizeof (hsize_t) * ndim); + count = (hsize_t *)malloc (sizeof (hsize_t) * ndim); + for (i=0; i<ndim; i++) { + start[i] = block_coord[i]; + count[i] = dims1[i]; + } + + status = H5Sselect_hyperslab(sid1,H5S_SELECT_SET,start,NULL,count,NULL); + + status = H5Dread(dset_id, mem_type, sid2, sid1, H5P_DEFAULT, buf); + +/* H5Sget_select_npoints(hid_t space_id) */ + + return ret_value; +} + +/*------------------------------------------------------------------------- + * Function: H5LTcopy_region + * + * Purpose: Copy data from a specified region in a source dataset to a + * specified region in a destination dataset. + * + * Return: FAIL on error, SUCCESS on success + * + * Programmer: M. Scot Breitenfeld + * + * Date: February 17, 2009 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +herr_t H5LTcopy_region(const char *file_src, + const char *path_src, + const hsize_t *block_coord_src, + const char *file_dest, + const char *path_dest, + hsize_t *block_coord_dset) +{ + hid_t ret_value = SUCCEED; /* Return value */ + herr_t status; + hsize_t *dims1, *dims_src; + hid_t sid1; + hid_t sid2; + hid_t fid_src, type_id, file_id; + hid_t did_src, sid_src,dset_id; + int ndim; + void *buf; + hsize_t numelem_src; + int nrank_src; + int i, j; + hsize_t *start, *count; + hid_t dtype; + + + /* Open the file */ + fid_src = H5Fopen(file_src, H5F_ACC_RDONLY, H5P_DEFAULT); + + /* Open the dataset for a given the path */ + did_src = H5Dopen2(fid_src, path_src, H5P_DEFAULT); + /* Get the dataspace of the dataset */ + sid_src = H5Dget_space(did_src); + + /* Find the rank of the dataspace */ + nrank_src = H5Sget_simple_extent_ndims(sid_src); + + /* Allocate space for the dimension array */ + dims_src = (hsize_t *)malloc (sizeof (hsize_t) * nrank_src); + +/* bounds_coor = (hsize_t *)malloc (sizeof (hsize_t) * nrank * 2); */ +/* status = H5Sget_select_hyper_blocklist(sid_ref, 0, 1, bounds_coor); */ + + numelem_src = 1; + for (j=0; j<nrank_src; j++) { + dims_src[j] = block_coord_src[nrank_src + j] - block_coord_src[j] + 1; + numelem_src = dims_src[j]*numelem_src; + } + + dtype = H5Dget_type(did_src); + type_id = H5Tget_native_type(dtype , H5T_DIR_DEFAULT ); + + buf = malloc(sizeof(type_id) * numelem_src); + + /* Create dataspace for reading buffer */ + sid2 = H5Screate_simple(nrank_src, dims_src, NULL); + + /* Select (x , x , ..., x ) x (y , y , ..., y ) hyperslab for reading memory dataset */ + /* 1 2 n 1 2 n */ + + start = (hsize_t *)malloc (sizeof (hsize_t) * nrank_src); + count = (hsize_t *)malloc (sizeof (hsize_t) * nrank_src); + for (i=0; i<nrank_src; i++) { + start[i] = block_coord_src[i]; + count[i] = dims_src[i]; + } + + status = H5Sselect_hyperslab(sid_src,H5S_SELECT_SET,start,NULL,count,NULL); + + status = H5Dread(did_src, type_id, sid2, sid_src, H5P_DEFAULT, buf); + + status = H5Dclose(did_src); + status = H5Sclose(sid_src); + status = H5Sclose(sid2); + status = H5Fclose(fid_src); + free(dims_src); + +/* Open the file */ + file_id = H5Fopen(file_dest, H5F_ACC_RDWR, H5P_DEFAULT); + +/* Open the dataset for a given the path */ + dset_id = H5Dopen2(file_id, path_dest, H5P_DEFAULT); + +/* Get the dataspace of the dataset */ + sid1 = H5Dget_space(dset_id); + + +/* Find the rank of the dataspace */ + ndim = H5Sget_simple_extent_ndims(sid1); + + /* Allocate space for the dimension array */ + dims1 = (hsize_t *)malloc (sizeof (hsize_t) * ndim); + + /* find the dimensions of each data space from the block coordinates */ + for (i=0; i<ndim; i++) + dims1[i] = block_coord_dset[i+ndim] - block_coord_dset[i] + 1; + + /* Create dataspace for writing the buffer */ + sid2 = H5Screate_simple(ndim, dims1, NULL); + +/* Select (x , x , ..., x ) x (y , y , ..., y ) hyperslab for writing memory dataset */ +/* 1 2 n 1 2 n */ + + start = (hsize_t *)malloc (sizeof (hsize_t) * ndim); + count = (hsize_t *)malloc (sizeof (hsize_t) * ndim); + + for (i=0; i<ndim; i++) { + start[i] = block_coord_dset[i]; + count[i] = block_coord_dset[i + ndim] - start[i] + 1; + } + + status = H5Sselect_hyperslab(sid1,H5S_SELECT_SET,start,NULL,count,NULL); + + status = H5Dwrite(dset_id, type_id, sid2, sid1, H5P_DEFAULT, buf); + +/* close the data */ + + status = H5Dclose(dset_id); + status = H5Sclose(sid1); + status = H5Sclose(sid2); + status = H5Tclose(type_id); + status = H5Fclose(file_id); + free(dims1); + free(buf); + + return ret_value; + +} + +/*------------------------------------------------------------------------- + * Function: H5LTread_quality_flag + * + * Purpose: Retrieves the values of quality flags for each element to the + * application provided buffer. + * + * Return: FAIL on error, SUCCESS on success + * + * Programmer: M. Scot Breitenfeld + * + * Date: March 30, 2009 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ + +herr_t H5LTread_quality_flag(hid_t dset_id, int num_flags, const unsigned *offset, + const unsigned *length, hid_t *dtype, hid_t *space, void *buf) +{ + hid_t ret_value = SUCCEED; /* Return value */ + herr_t status; + + + return ret_value; + +} diff --git a/hl/src/H5LTpublic.h b/hl/src/H5LTpublic.h index 7fb873a..1158a4c 100644 --- a/hl/src/H5LTpublic.h +++ b/hl/src/H5LTpublic.h @@ -83,6 +83,14 @@ H5_HLDLL herr_t H5LTmake_dataset_string( hid_t loc_id, const char *buf ); +H5_HLDLL herr_t H5LTcopy_region(const char *file_src, + const char *path_src, + const hsize_t *block_coord_src, + const char *file_dest, + const char *path_dest, + hsize_t *block_coord_dset); + + /*------------------------------------------------------------------------- * * Read dataset functions @@ -123,6 +131,17 @@ H5_HLDLL herr_t H5LTread_dataset_string( hid_t loc_id, const char *dset_name, char *buf ); + +H5_HLDLL herr_t H5LTread_region(const char *file, + const char *path, + hsize_t *block_coord, + hid_t mem_type, + void *buf ); + +H5_HLDLL herr_t H5LTread_quality_flag(hid_t dset_id, int num_flags, const unsigned *offset, + const unsigned *length, hid_t *dtype, hid_t *space, void *buf); + + /*------------------------------------------------------------------------- * * Query dataset functions @@ -319,9 +338,6 @@ H5_HLDLL herr_t H5LTget_attribute_info( hid_t loc_id, size_t *type_size ); - - - /*------------------------------------------------------------------------- * * General functions |