summaryrefslogtreecommitdiffstats
path: root/hl
diff options
context:
space:
mode:
authorScot Breitenfeld <brtnfld@hdfgroup.org>2009-05-19 21:53:05 (GMT)
committerScot Breitenfeld <brtnfld@hdfgroup.org>2009-05-19 21:53:05 (GMT)
commit1954264710de0ef07edb0040cffd48afdd7e121d (patch)
tree7f85690174ca337146588369fec2c08c9e53af5d /hl
parent659d94591e41eb83586dd6b5438b49fd6b7d8166 (diff)
downloadhdf5-1954264710de0ef07edb0040cffd48afdd7e121d.zip
hdf5-1954264710de0ef07edb0040cffd48afdd7e121d.tar.gz
hdf5-1954264710de0ef07edb0040cffd48afdd7e121d.tar.bz2
[svn-r16963] Description:
Changed some APIs to match the APIs in the RFC, H5LRcopy_region is not working. Fixed error in H5LT and H5LR error handling. Platform tested: smirom (icc)
Diffstat (limited to 'hl')
-rw-r--r--hl/src/H5LR.c76
-rw-r--r--hl/src/H5LRpkg.h2
-rw-r--r--hl/src/H5LRpublic.h7
-rw-r--r--hl/src/H5LT.c10
-rw-r--r--hl/src/H5LTpkg.h2
-rw-r--r--hl/src/H5LTpublic.h4
-rw-r--r--hl/test/test_regref_hyper.c29
7 files changed, 63 insertions, 67 deletions
diff --git a/hl/src/H5LR.c b/hl/src/H5LR.c
index a2696d3..768d23b 100644
--- a/hl/src/H5LR.c
+++ b/hl/src/H5LR.c
@@ -319,7 +319,7 @@ herr_t, SUCCEED, FAIL,
H5LRcreate_region_references(hid_t file_id,
size_t num_elem,
const char **path,
- hsize_t *block_coord,
+ const hsize_t *block_coord,
hdset_reg_ref_t *buf) )
hid_t sid1 = -1;
@@ -445,13 +445,15 @@ END_FUNC(PUB)
*/
BEGIN_FUNC(PUB, ERR,
herr_t, SUCCEED, FAIL,
- 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) )
+ H5LRmake_dataset(hid_t loc_id, const char *path, hid_t type_id,
+ const size_t buf_size, const hid_t *loc_id_ref, const hdset_reg_ref_t *ref) )
hid_t dset_ref = -1, sid_ref = -1;
H5S_sel_type sel_type;
hid_t dset_id;
int nrank;
- int i,j;
+ size_t i;
+ int j;
hsize_t *dims1;
void *buf;
herr_t status;
@@ -465,7 +467,8 @@ BEGIN_FUNC(PUB, ERR,
hbool_t bounds_coor_alloc = FALSE;
hbool_t buf_alloc = FALSE;
- for (i=0; i<buf_size; i++) {
+/* for (i=0; i<buf_size; i++) { */
+ for (i=1; i<2; i++) {
/* status= H5LRread_region(loc_id_ref,
ref[i],
@@ -672,6 +675,7 @@ H5LRcopy_region(hid_t obj_id,
hid_t dset_id;
int ndim;
void *buf;
+ int *buf2;
size_t numelem;
int nrank;
int i, j;
@@ -686,6 +690,9 @@ H5LRcopy_region(hid_t obj_id,
hbool_t start_alloc = FALSE;
hbool_t count_alloc = FALSE;
hid_t current_stack_id = -1;
+hsize_t dims_mem[1];
+hid_t sel_type, mem_space;
+int inte;
/* Region reference data */
dset_ref = H5Rdereference(obj_id, H5R_DATASET_REGION, ref);
@@ -741,26 +748,21 @@ H5LRcopy_region(hid_t obj_id,
}
buf_alloc = TRUE;
+ buf2 = malloc(sizeof(int) * numelem);
+
status= H5LRread_region(obj_id,
- (const hdset_reg_ref_t*)ref,
+ (const hdset_reg_ref_t*)ref,
type_id,
&numelem,
- buf );
- if(status < 0)
- H5E_THROW(H5E_NONE_MINOR, "H5LR: Failed in internal H5LRread_region")
+ buf2 );
-/* sel_type = H5Sget_select_type(sid); */
-
-/* dims1[0] = H5Sget_select_npoints(sid); */
-
-/* mem_space = H5Screate_simple (1, dims1, NULL); */
-
-/* Allocate space for the dimension array */
-/* dims1 = (hsize_t *)malloc (sizeof (hsize_t) * ndim); */
+ for (j=0; j<6; j++) {
+ printf(" here %d \n",buf2[j]);
+ }
-/* status = H5Dread (dset, mem_type, mem_space, sid, H5P_DEFAULT, buf); */
+ if(status < 0)
+ H5E_THROW(H5E_NONE_MINOR, "H5LR: Failed in internal H5LRread_region")
-
if(sid_ref > 0) {
status = H5Sclose(sid_ref);
sid_ref = -1;
@@ -777,7 +779,7 @@ H5LRcopy_region(hid_t obj_id,
}
-/* Open the file */
+/* Open the file */
file_id = H5Fopen(file, H5F_ACC_RDWR, H5P_DEFAULT);
if(file_id < 0) {
H5E_THROW(H5E_CANTOPENFILE, "H5LR: Failed to open file")
@@ -794,19 +796,13 @@ H5LRcopy_region(hid_t obj_id,
H5E_THROW(H5E_CANTOPENOBJ, "H5LR: Failed to open dataspace for given path")
/* Find the rank of the dataspace */
- ndim = H5Sget_simple_extent_ndims(sid1);
- if(ndim < 0)
- H5E_THROW(H5E_NOTFOUND, "H5LR: Failed to find extents of dataspace")
-
-/* /\* 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; */
+/* ndim = H5Sget_simple_extent_ndims(sid1); */
+/* if(ndim < 0) */
+/* H5E_THROW(H5E_NOTFOUND, "H5LR: Failed to find extents of dataspace") */
+ dims_mem[0] = numelem;
/* Create dataspace for writing the buffer */
- if((sid2 = H5Screate_simple(ndim, dims1, NULL) < 0))
+ if((sid2 = H5Screate_simple(1, dims_mem, NULL) < 0))
H5E_THROW(H5E_CANTCREATE, "H5LR: Unable to create dataspace for retrieving elements")
/* Select (x , x , ..., x ) x (y , y , ..., y ) hyperslab for writing memory dataset */
@@ -822,15 +818,9 @@ H5LRcopy_region(hid_t obj_id,
H5E_THROW(H5E_CANTALLOC, "H5LR: Failed to allocate enough memory")
count_alloc = TRUE;
-
-/* for (i=0; i<ndim; i++) { */
-/* start[i] = block_coord[i]; */
-/* count[i] = block_coord[i + ndim] - start[i] + 1; */
-/* } */
-
for (i=0; i<ndim; i++) {
start[i] = block_coord[i];
- count[i] = dims1[i];
+ count[i] = block_coord[i + ndim] - start[i] + 1;
}
status = H5Sselect_hyperslab(sid1,H5S_SELECT_SET,start,NULL,count,NULL);
@@ -841,18 +831,6 @@ H5LRcopy_region(hid_t obj_id,
if(status < 0)
H5E_THROW(H5E_CANTCREATE, "H5LR: Unable to create dataset")
-/* H5Sget_select_npoints(sid); */
-
-
-/* sel_type = H5Sget_select_type(sid); */
-
-/* dims1[0] = H5Sget_select_npoints(sid); */
-
-/* *numelem = dims1[0]; */
-
-/* mem_space = H5Screate_simple (1, dims1, NULL); */
-
-/* status = H5Dread (dset, mem_type, mem_space, sid, H5P_DEFAULT, buf); */
free(start);
free(count);
diff --git a/hl/src/H5LRpkg.h b/hl/src/H5LRpkg.h
index 8af7276..412db8f 100644
--- a/hl/src/H5LRpkg.h
+++ b/hl/src/H5LRpkg.h
@@ -34,7 +34,7 @@
*/
#ifdef H5LR_MODULE
#define H5_MY_PKG H5LR
-#define H5_MY_PKG_ERR H5E_LR
+#define H5_MY_PKG_ERR H5E_HL
#define H5_MY_PKG_INIT YES
#endif /* H5LR_MODULE */
diff --git a/hl/src/H5LRpublic.h b/hl/src/H5LRpublic.h
index a6b3096..a48a697 100644
--- a/hl/src/H5LRpublic.h
+++ b/hl/src/H5LRpublic.h
@@ -37,8 +37,9 @@ extern "C" {
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);
+ hid_t type_id, const size_t buf_size,
+ const hid_t *loc_id_ref,
+ const hdset_reg_ref_t *buf);
/*-------------------------------------------------------------------------
*
@@ -49,7 +50,7 @@ H5_HLDLL herr_t H5LRmake_dataset(hid_t loc_id,
H5_HLDLL herr_t H5LRcreate_region_references(hid_t obj_id,
size_t num_elem,
const char **path,
- hsize_t *block_coord,
+ const hsize_t *block_coord,
hdset_reg_ref_t *buf);
H5_HLDLL herr_t H5LRcopy_references(hid_t obj_id, hdset_reg_ref_t *ref, const char *file,
diff --git a/hl/src/H5LT.c b/hl/src/H5LT.c
index ff5b9d1..05db2b5 100644
--- a/hl/src/H5LT.c
+++ b/hl/src/H5LT.c
@@ -68,10 +68,10 @@ hid_t H5_MY_PKG_ERR;
hbool_t H5_H5LT_init_g = FALSE;
/* High-Level API error class */
-hid_t H5HL_ERR_CLS_g = (-1);
+ hid_t H5HL_ERR_CLS_g = (-1);
/* Major error codes */
-hid_t H5E_HL_g = (-1);
+ hid_t H5E_HL_g = (-1);
/*****************************/
/* Library Private Variables */
@@ -3008,7 +3008,7 @@ BEGIN_FUNC(PUB, ERR,
herr_t, SUCCEED, FAIL,
H5LTread_region(const char *file,
const char *path,
- hsize_t *block_coord,
+ const hsize_t *block_coord,
hid_t mem_type,
void *buf ) )
@@ -3180,7 +3180,7 @@ H5LTcopy_region(const char *file_src,
const hsize_t *block_coord_src,
const char *file_dest,
const char *path_dest,
- hsize_t *block_coord_dset) )
+ const hsize_t *block_coord_dset) )
herr_t status;
hsize_t *dims1, *dims_src;
@@ -3200,7 +3200,7 @@ H5LTcopy_region(const char *file_src,
hbool_t buf_alloc = FALSE;
hbool_t start_alloc = FALSE;
hbool_t count_alloc = FALSE;
- hid_t current_stack_id = -1;
+ hid_t current_stack_id = -1;
/* Open the file */
fid_src = H5Fopen(file_src, H5F_ACC_RDONLY, H5P_DEFAULT);
diff --git a/hl/src/H5LTpkg.h b/hl/src/H5LTpkg.h
index 4c3d448..793d457 100644
--- a/hl/src/H5LTpkg.h
+++ b/hl/src/H5LTpkg.h
@@ -34,7 +34,7 @@
*/
#ifdef H5LT_MODULE
#define H5_MY_PKG H5LT
-#define H5_MY_PKG_ERR H5E_LT
+#define H5_MY_PKG_ERR H5E_HL
#define H5_MY_PKG_INIT YES
#endif /* H5LT_MODULE */
diff --git a/hl/src/H5LTpublic.h b/hl/src/H5LTpublic.h
index 53caaaf..019c812 100644
--- a/hl/src/H5LTpublic.h
+++ b/hl/src/H5LTpublic.h
@@ -88,7 +88,7 @@ H5_HLDLL herr_t H5LTcopy_region(const char *file_src,
const hsize_t *block_coord_src,
const char *file_dest,
const char *path_dest,
- hsize_t *block_coord_dset);
+ const hsize_t *block_coord_dset);
/*-------------------------------------------------------------------------
@@ -134,7 +134,7 @@ H5_HLDLL herr_t H5LTread_dataset_string( hid_t loc_id,
H5_HLDLL herr_t H5LTread_region(const char *file,
const char *path,
- hsize_t *block_coord,
+ const hsize_t *block_coord,
hid_t mem_type,
void *buf );
diff --git a/hl/test/test_regref_hyper.c b/hl/test/test_regref_hyper.c
index 9d6f120..3867c47 100644
--- a/hl/test/test_regref_hyper.c
+++ b/hl/test/test_regref_hyper.c
@@ -79,8 +79,8 @@ int main(void)
hsize_t block_coord[4] ={ 3, 3, 5, 4};
hsize_t num_elem = 2;
const char *path[num_elem];
- hsize_t block_coord_6[6] ={ 0, 5, 0, 0, 2, 2};
- hsize_t block_coord_4[4] ={ 1, 2, 3, 4};
+ hsize_t block_coord_6[6] ={ 0, 5, 0, 0, 1, 2};
+ hsize_t block_coord_4[4] ={ 1, 3, 3, 4};
hsize_t block_coord_1D_src[2] ={ 0, 5};
hsize_t block_coord_1D_dest[2] ={ 5, 10};
hsize_t block_coord_2D_src[4] ={ 0, 0, 1, 2};
@@ -467,16 +467,33 @@ int main(void)
/* create a */
+
+
+ status = H5LRcopy_region(file_id, &ref[1], filename, "/Group_2D/DS2", block_coord_4);
+
+ /* check the region was copied correctly */
+
+ status = H5LTread_dataset(file_id,"/Group_2D/DS2",H5T_NATIVE_INT,data_read_2D);
+
+ printf("2D DATA AFTER H5LRCOPY_REGION: [(%d,%d)-(%d,%d)] --> [(%d,%d)-(%d,%d)]",
+ (int)block_coord[0],(int)block_coord[1],(int)block_coord[2],(int)block_coord[3],
+ (int)block_coord_4[0], (int)block_coord_4[1],(int)block_coord_4[2], (int)block_coord_4[3]);
+ for (i=0; i<9; i++) {
+ printf("\n[ ");
+ for (j=0; j<8; j++) {
+ printf("%d ", data_read_2D[i][j]);
+ }
+ printf("]");
+ }
+ printf("\n");
+
status = H5LRcreate_region_references(file_id,
num_elem,
path,
block_coord_6,
ref6);
- status = H5LRcopy_region(file_id, &ref[1], filename, "/Group_2D/DS2", block_coord_4);
-
-
-/* status = H5LRmake_dataset(file_id, "/Group_2D/DS2a", H5T_NATIVE_INT, file_id, 2, ref6); */
+ status = H5LRmake_dataset(file_id, "/Group_2D/DS2a", H5T_NATIVE_INT, 2, file_id, ref6);