diff options
-rw-r--r-- | src/H5D.c | 2 | ||||
-rw-r--r-- | src/H5Distore.c | 8 | ||||
-rw-r--r-- | src/H5G.c | 4 | ||||
-rw-r--r-- | src/H5L.c | 57 | ||||
-rw-r--r-- | src/H5Lpublic.h | 2 | ||||
-rw-r--r-- | src/H5O.c | 55 | ||||
-rw-r--r-- | src/H5Opublic.h | 2 | ||||
-rw-r--r-- | src/H5Plcpl.c | 4 | ||||
-rw-r--r-- | src/H5Tcommit.c | 2 | ||||
-rw-r--r-- | test/links.c | 133 | ||||
-rw-r--r-- | test/th5o.c | 165 |
11 files changed, 223 insertions, 211 deletions
@@ -197,7 +197,7 @@ done: * create other datasets. * * The resulting ID should be linked into the file with - * H5Llink or it will be deleted when closed. + * H5Olink or it will be deleted when closed. * * Return: Success: The object ID of the new dataset. At this * point, the dataset is ready to receive its diff --git a/src/H5Distore.c b/src/H5Distore.c index 66fc41a..399f9f9 100644 --- a/src/H5Distore.c +++ b/src/H5Distore.c @@ -2101,10 +2101,8 @@ H5D_istore_readvv(const H5D_io_info_t *io_info, haddr_t chunk_addr, void *chunk, void *buf) { H5D_t *dset=io_info->dset; /* Local pointer to the dataset info */ - H5D_istore_ud1_t udata; /*B-tree pass-through */ size_t u; /* Local index variables */ ssize_t ret_value; /* Return value */ - ssize_t naccessed; /* Number of bytes accessed in chunk */ FUNC_ENTER_NOAPI(H5D_istore_readvv, FAIL) @@ -2285,8 +2283,6 @@ H5D_istore_writevv(const H5D_io_info_t *io_info, haddr_t chunk_addr, void *chunk, const void *buf) { H5D_t *dset = io_info->dset; /* Local pointer to the dataset info */ - H5D_istore_ud1_t udata; /*B-tree pass-through */ - size_t u; /* Local index variables */ ssize_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(H5D_istore_writevv, FAIL) @@ -2304,6 +2300,9 @@ H5D_istore_writevv(const H5D_io_info_t *io_info, HDassert(buf); #ifdef QAK +{ +size_t u; /* Local index variables */ + HDfprintf(stderr,"%s: io_info->store->chunk.offset={",FUNC); for(u=0; u<dset->shared->layout.u.chunk.ndims; u++) HDfprintf(stderr,"%Hd%s",io_info->store->chunk.offset[u],(u<(dset->shared->layout.u.chunk.ndims-1) ? ", " : "}\n")); @@ -2313,6 +2312,7 @@ HDfprintf(stderr,"%s: chunk_len_arr[%Zu]=%Zu\n",FUNC,*chunk_curr_seq,chunk_len_a HDfprintf(stderr,"%s: chunk_offset_arr[%Zu]=%Hu\n",FUNC,*chunk_curr_seq,chunk_offset_arr[*chunk_curr_seq]); HDfprintf(stderr,"%s: mem_len_arr[%Zu]=%Zu\n",FUNC,*mem_curr_seq,mem_len_arr[*mem_curr_seq]); HDfprintf(stderr,"%s: mem_offset_arr[%Zu]=%Hu\n",FUNC,*mem_curr_seq,mem_offset_arr[*mem_curr_seq]); +} #endif /* QAK */ /* @@ -252,10 +252,10 @@ done: * property list GAPL_ID. * * The resulting ID should be linked into the file with - * H5Llink or it will be deleted when closed. + * H5Olink or it will be deleted when closed. * * Given the default setting, H5Gcreate_anon() followed by - * H5Llink() will have the same function as H5Gcreate2(). + * H5Olink() will have the same function as H5Gcreate2(). * * Usage: H5Gcreate_anon(loc_id, char *name, gcpl_id, gapl_id) * hid_t loc_id; IN: File or group identifier @@ -409,61 +409,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5Llink - * - * Purpose: Creates a hard link from NEW_NAME to the object specified - * by OBJ_ID using properties defined in the Link Creation - * Property List LCPL. - * - * This function should be used to link objects that have just - * been created. - * - * CUR_NAME and NEW_NAME are interpreted relative to - * CUR_LOC_ID and NEW_LOC_ID, which is either a file ID or a - * group ID. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: James Laird - * Tuesday, December 13, 2005 - * - *------------------------------------------------------------------------- - */ -herr_t -H5Llink(hid_t new_loc_id, const char *new_name, hid_t obj_id, hid_t lcpl_id, - hid_t lapl_id) -{ - H5G_loc_t new_loc; - H5G_loc_t obj_loc; - herr_t ret_value=SUCCEED; /* Return value */ - - FUNC_ENTER_API(H5Llink, FAIL) - H5TRACE5("e", "i*siii", new_loc_id, new_name, obj_id, lcpl_id, lapl_id); - - /* Check arguments */ - if(new_loc_id == H5L_SAME_LOC) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "cannot use H5L_SAME_LOC when only one location is specified") - if(H5G_loc(new_loc_id, &new_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(H5G_loc(obj_id, &obj_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!new_name || !*new_name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") - if(HDstrlen(new_name) > H5L_MAX_LINK_NAME_LEN) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "name too long") - if(lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a link creation property list") - - /* Link to the object */ - if(H5L_link(&new_loc, new_name, &obj_loc, lcpl_id, lapl_id, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5Llink() */ - - -/*------------------------------------------------------------------------- * Function: H5Lcreate_soft * * Purpose: Creates a soft link from LINK_NAME to LINK_TARGET. @@ -1488,7 +1433,7 @@ done: /*------------------------------------------------------------------------- * Function: H5L_link * - * Purpose: Creates a link from OBJ_ID to CUR_NAME. See H5Llink() for + * Purpose: Creates a link from OBJ_ID to CUR_NAME. See H5Olink() for * full documentation. * * Return: Non-negative on success/Negative on failure diff --git a/src/H5Lpublic.h b/src/H5Lpublic.h index 9a85900..1645e4b 100644 --- a/src/H5Lpublic.h +++ b/src/H5Lpublic.h @@ -140,8 +140,6 @@ typedef herr_t (*H5L_iterate_t)(hid_t group, const char *name, const H5L_info_t /*********************/ /* Public Prototypes */ /*********************/ -H5_DLL herr_t H5Llink(hid_t cur_loc_id, const char *cur_name, - hid_t obj_id, hid_t lcpl_id, hid_t lapl_id); H5_DLL herr_t H5Lmove(hid_t src_loc, const char *src_name, hid_t dst_loc, const char *dst_name, hid_t lcpl_id, hid_t lapl_id); H5_DLL herr_t H5Lcopy(hid_t src_loc, const char *src_name, hid_t dst_loc, @@ -369,6 +369,61 @@ done: /*------------------------------------------------------------------------- + * Function: H5Olink + * + * Purpose: Creates a hard link from NEW_NAME to the object specified + * by OBJ_ID using properties defined in the Link Creation + * Property List LCPL. + * + * This function should be used to link objects that have just + * been created. + * + * NEW_NAME is interpreted relative to + * NEW_LOC_ID, which is either a file ID or a + * group ID. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: James Laird + * Tuesday, December 13, 2005 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Olink(hid_t obj_id, hid_t new_loc_id, const char *new_name, hid_t lcpl_id, + hid_t lapl_id) +{ + H5G_loc_t new_loc; + H5G_loc_t obj_loc; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(H5Olink, FAIL) + H5TRACE5("e", "ii*sii", obj_id, new_loc_id, new_name, lcpl_id, lapl_id); + + /* Check arguments */ + if(H5G_loc(obj_id, &obj_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + if(new_loc_id == H5L_SAME_LOC) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "cannot use H5L_SAME_LOC when only one location is specified") + if(H5G_loc(new_loc_id, &new_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + if(!new_name || !*new_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") + if(HDstrlen(new_name) > H5L_MAX_LINK_NAME_LEN) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "name too long") + if(lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a link creation property list") + + /* Link to the object */ + if(H5L_link(&new_loc, new_name, &obj_loc, lcpl_id, lapl_id, H5AC_dxpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Olink() */ + + +/*------------------------------------------------------------------------- * Function: H5Oincr_refcount * * Purpose: Warning! This function is EXTREMELY DANGEROUS! diff --git a/src/H5Opublic.h b/src/H5Opublic.h index d85d164..c3ce1b6 100644 --- a/src/H5Opublic.h +++ b/src/H5Opublic.h @@ -147,6 +147,8 @@ H5_DLL herr_t H5Oget_info_by_name(hid_t loc_id, const char *name, H5O_info_t *oi H5_DLL herr_t H5Oget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_info_t *oinfo, hid_t lapl_id); +H5_DLL herr_t H5Olink(hid_t obj_id, hid_t new_loc_id, const char *new_name, + hid_t lcpl_id, hid_t lapl_id); H5_DLL herr_t H5Oincr_refcount(hid_t object_id); H5_DLL herr_t H5Odecr_refcount(hid_t object_id); H5_DLL herr_t H5Ocopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, diff --git a/src/H5Plcpl.c b/src/H5Plcpl.c index fb3169d..4006f0e 100644 --- a/src/H5Plcpl.c +++ b/src/H5Plcpl.c @@ -131,7 +131,7 @@ done: /*------------------------------------------------------------------------- * Function: H5Pset_create_intermediate_group * - * Purpose: set crt_intmd_group so that H5Lcreate_*, H5Llink, etc. + * Purpose: set crt_intmd_group so that H5Lcreate_*, H5Olink, etc. * will create missing groups along the given path "name" * * Note: XXX: This property should really be an access property. -QAK @@ -169,7 +169,7 @@ done: * Function: H5Pget_create_intermediate_group * * Purpose: Returns the crt_intmd_group, which is set to create missing - * groups during H5Llink, etc. + * groups during H5Olink, etc. * * Return: Non-negative on success/Negative on failure * diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c index 9739668..bcb9962 100644 --- a/src/H5Tcommit.c +++ b/src/H5Tcommit.c @@ -209,7 +209,7 @@ done: * into a "named", immutable type. * * The resulting ID should be linked into the file with - * H5Llink or it will be deleted when closed. + * H5Olink or it will be deleted when closed. * * Note: Datatype access property list is unused currently, but is * checked for sanity anyway. diff --git a/test/links.c b/test/links.c index bee4f07..8a8ab3a 100644 --- a/test/links.c +++ b/test/links.c @@ -690,134 +690,6 @@ toomany(hid_t fapl, hbool_t new_format) /*------------------------------------------------------------------------- - * Function: test_h5l_create - * - * Purpose: Tests H5Lcreate - * - * Return: Success: 0 - * Failure: number of errors - * - * Programmer: James Laird - * Monday, January 30, 2006 - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static int -test_h5l_create(hid_t fapl, hbool_t new_format) -{ - hid_t file_id=-1; - hid_t group_id=-1; - hid_t space_id=-1; - hid_t dset_id=-1; - hid_t type_id=-1; - hid_t lcpl_id=-1; - char filename[1024]; - hsize_t dims[2]; - int i, n, j; - int wdata[H5L_DIM1][H5L_DIM2]; - int rdata[H5L_DIM1][H5L_DIM2]; - - if(new_format) - TESTING("H5Llink (w/new group format)") - else - TESTING("H5Llink") - - /* Create file */ - h5_fixname(FILENAME[3], fapl, filename, sizeof filename); - - if((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - - /* Create and commit a datatype with no name */ - if((type_id = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR - if(H5Tcommit_anon(file_id, type_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(!H5Tcommitted(type_id)) TEST_ERROR - - /* Create the dataspace */ - dims[0] = H5L_DIM1; - dims[1] = H5L_DIM2; - if((space_id = H5Screate_simple(2 ,dims, NULL)) < 0) TEST_ERROR - - /* Create a dataset with no name using the committed datatype*/ - if ((dset_id = H5Dcreate_anon(file_id, type_id, space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - - /* Verify that we can write to and read from the dataset */ - /* Initialize the dataset */ - for (i = n = 0; i < H5L_DIM1; i++) - for (j = 0; j < H5L_DIM2; j++) - wdata[i][j] = n++; - - /* Write the data to the dataset */ - if (H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata) < 0) TEST_ERROR - - /* Read the data back */ - if (H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata) < 0) TEST_ERROR - - /* Verify the data */ - for (i = 0; i < H5L_DIM1; i++) - for (j = 0; j < H5L_DIM2; j++) - if (wdata[i][j] != rdata[i][j]) - TEST_ERROR - - /* Create a group with no name*/ - if((group_id = H5Gcreate_anon(file_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - - /* Link nameless datatype into nameless group */ - if(H5Llink(group_id, "datatype", type_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - - /* Create LCPL with intermediate group creation flag set */ - if((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) TEST_ERROR - if(H5Pset_create_intermediate_group(lcpl_id, TRUE) < 0) TEST_ERROR - - /* Link nameless dataset into nameless group with intermediate group */ - if(H5Llink(group_id, "inter_group/dataset", dset_id, lcpl_id, H5P_DEFAULT) < 0) TEST_ERROR - - /* Close IDs for dataset and datatype */ - if(H5Dclose(dset_id) < 0) TEST_ERROR - if(H5Tclose(type_id) < 0) TEST_ERROR - - /* Re-open datatype using new link */ - if((type_id = H5Topen2(group_id, "datatype", H5P_DEFAULT)) < 0) TEST_ERROR - - /* Link nameless group to root group and close the group ID*/ - if(H5Llink(file_id, "/group", group_id, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if(H5Gclose(group_id) < 0) TEST_ERROR - - /* Open dataset through root group and verify its data */ - if((dset_id = H5Dopen2(file_id, "/group/inter_group/dataset", H5P_DEFAULT)) < 0) TEST_ERROR - - /* Read data from dataset */ - if (H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata) < 0) TEST_ERROR - for (i = 0; i < H5L_DIM1; i++) - for (j = 0; j < H5L_DIM2; j++) - if (wdata[i][j] != rdata[i][j]) - TEST_ERROR - - /* Close open IDs */ - if(H5Dclose(dset_id) < 0) TEST_ERROR - if(H5Tclose(type_id) < 0) TEST_ERROR - if(H5Pclose(lcpl_id) < 0) TEST_ERROR - if(H5Sclose(space_id) < 0) TEST_ERROR - if(H5Fclose(file_id) < 0) TEST_ERROR - - PASSED(); - return 0; - -error: - H5E_BEGIN_TRY { - H5Gclose(group_id); - H5Dclose(dset_id); - H5Tclose(type_id); - H5Pclose(lcpl_id); - H5Sclose(space_id); - H5Fclose(file_id); - } H5E_END_TRY; - return 1; -} /* end test_h5l_create() */ - - -/*------------------------------------------------------------------------- * Function: test_lcpl * * Purpose: Tests Link Creation Property Lists @@ -5052,8 +4924,8 @@ lapl_nlinks(hid_t fapl, hbool_t new_format) if(H5Lcopy(fid, "soft17", fid, "soft17/newer_soft", H5P_DEFAULT, plist) < 0) TEST_ERROR if(H5Lmove(fid, "soft17/newer_soft", fid, "soft17/newest_soft", H5P_DEFAULT, plist) < 0) TEST_ERROR - /* H5Llink */ - if(H5Llink(fid, "soft17/link_to_group", gid, H5P_DEFAULT, plist) < 0) TEST_ERROR + /* H5Olink */ + if(H5Olink(gid, fid, "soft17/link_to_group", H5P_DEFAULT, plist) < 0) TEST_ERROR /* H5Lcreate_hard and H5Lcreate_soft */ if(H5Lcreate_hard(fid, "soft17", fid, "soft17/link2_to_group", H5P_DEFAULT, plist) < 0) TEST_ERROR @@ -9732,7 +9604,6 @@ main(void) nerrors += toomany((new_format ? fapl2 : fapl), new_format) < 0 ? 1 : 0; /* Test new H5L link creation routine */ - nerrors += test_h5l_create((new_format ? fapl2 : fapl), new_format); nerrors += test_lcpl((new_format ? fapl2 : fapl), new_format); nerrors += test_move((new_format ? fapl2 : fapl), new_format); nerrors += test_copy((new_format ? fapl2 : fapl), new_format); diff --git a/test/th5o.c b/test/th5o.c index cd1fc77..d913e47 100644 --- a/test/th5o.c +++ b/test/th5o.c @@ -23,17 +23,15 @@ #include "testhdf5.h" -/*#include "H5private.h" -#include "H5Bprivate.h" -#include "H5Sprivate.h" -#include "H5Pprivate.h" -*/ - #define TEST_FILENAME "th5o_file" #define RANK 2 #define DIM0 5 #define DIM1 10 + +#define TEST6_DIM1 100 +#define TEST6_DIM2 100 + /**************************************************************** ** @@ -632,16 +630,16 @@ test_h5o_plist(void) /* Create the group anonymously and link it in */ grp = H5Gcreate_anon(fid, gcpl, H5P_DEFAULT); CHECK(grp, FAIL, "H5Gcreate_anon"); - ret = H5Llink(fid, "group", grp, H5P_DEFAULT, H5P_DEFAULT); - CHECK(ret, FAIL, "H5Llink"); + ret = H5Olink(grp, fid, "group", H5P_DEFAULT, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Olink"); /* Commit the type inside the group anonymously and link it in */ dtype = H5Tcopy(H5T_NATIVE_INT); CHECK(dtype, FAIL, "H5Tcopy"); ret = H5Tcommit_anon(fid, dtype, tcpl, H5P_DEFAULT); CHECK(ret, FAIL, "H5Tcommit_anon"); - ret = H5Llink(fid, "datatype", dtype, H5P_DEFAULT, H5P_DEFAULT); - CHECK(ret, FAIL, "H5Llink"); + ret = H5Olink(dtype, fid, "datatype", H5P_DEFAULT, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Olink"); /* Create the dataspace for the dataset. */ dspace = H5Screate(H5S_SCALAR); @@ -650,8 +648,8 @@ test_h5o_plist(void) /* Create the dataset anonymously and link it in */ dset = H5Dcreate_anon(fid, H5T_NATIVE_INT, dspace, dcpl, H5P_DEFAULT); CHECK(dset, FAIL, "H5Dcreate_anon"); - ret = H5Llink(fid, "dataset", dset, H5P_DEFAULT, H5P_DEFAULT); - CHECK(ret, FAIL, "H5Llink"); + ret = H5Olink(dset, fid, "dataset", H5P_DEFAULT, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Olink"); ret = H5Sclose(dspace); CHECK(ret, FAIL, "H5Sclose"); @@ -759,6 +757,147 @@ test_h5o_plist(void) /**************************************************************** ** +** test_h5o_link(): Test creating link to object +** +****************************************************************/ +static void +test_h5o_link(void) +{ + hid_t file_id=-1; + hid_t group_id=-1; + hid_t space_id=-1; + hid_t dset_id=-1; + hid_t type_id=-1; + hid_t fapl_id=-1; + hid_t lcpl_id=-1; + hsize_t dims[2] = {TEST6_DIM1, TEST6_DIM2}; + htri_t committed; /* Whether the named datatype is committed */ + hbool_t new_format; /* Whether to use the new format or not */ + int wdata[TEST6_DIM1][TEST6_DIM2]; + int rdata[TEST6_DIM1][TEST6_DIM2]; + int i, n, j; + herr_t ret; /* Value returned from API calls */ + + /* Initialize the raw data */ + for(i = n = 0; i < TEST6_DIM1; i++) + for(j = 0; j < TEST6_DIM2; j++) + wdata[i][j] = n++; + + /* Create the dataspace */ + space_id = H5Screate_simple(2 ,dims, NULL); + CHECK(space_id, FAIL, "H5Screate_simple"); + + /* Create LCPL with intermediate group creation flag set */ + lcpl_id = H5Pcreate(H5P_LINK_CREATE); + CHECK(lcpl_id, FAIL, "H5Pcreate"); + ret = H5Pset_create_intermediate_group(lcpl_id, TRUE); + CHECK(ret, FAIL, "H5Pset_create_intermediate_group"); + + /* Loop over using new group format */ + for(new_format = FALSE; new_format <= TRUE; new_format++) { + + /* Make a FAPL that uses the "use the latest version of the format" flag */ + fapl_id = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl_id, FAIL, "H5Pcreate"); + + /* Set the "use the latest version of the format" flag for creating objects in the file */ + ret = H5Pset_latest_format(fapl_id, new_format); + CHECK(ret, FAIL, "H5Pset_latest_format"); + + /* Create a new HDF5 file */ + file_id = H5Fcreate(TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); + CHECK(file_id, FAIL, "H5Fcreate"); + + /* Close the FAPL */ + ret = H5Pclose(fapl_id); + CHECK(ret, FAIL, "H5Pclose"); + + + /* Create and commit a datatype with no name */ + type_id = H5Tcopy(H5T_NATIVE_INT); + CHECK(type_id, FAIL, "H5Fcreate"); + ret = H5Tcommit_anon(file_id, type_id, H5P_DEFAULT, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Tcommit_anon"); + committed = H5Tcommitted(type_id); + VERIFY(committed, TRUE, "H5Tcommitted"); + + /* Create a dataset with no name using the committed datatype*/ + dset_id = H5Dcreate_anon(file_id, type_id, space_id, H5P_DEFAULT, H5P_DEFAULT); + CHECK(dset_id, FAIL, "H5Dcreate_anon"); + + /* Verify that we can write to and read from the dataset */ + + /* Write the data to the dataset */ + ret = H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); + CHECK(ret, FAIL, "H5Dwrite"); + + /* Read the data back */ + ret = H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata); + CHECK(ret, FAIL, "H5Dread"); + + /* Verify the data */ + for(i = 0; i < TEST6_DIM1; i++) + for(j = 0; j < TEST6_DIM2; j++) + VERIFY(wdata[i][j], rdata[i][j], "H5Dread"); + + /* Create a group with no name*/ + group_id = H5Gcreate_anon(file_id, H5P_DEFAULT, H5P_DEFAULT); + CHECK(group_id, FAIL, "H5Gcreate_anon"); + + /* Link nameless datatype into nameless group */ + ret = H5Olink(type_id, group_id, "datatype", H5P_DEFAULT, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Olink"); + + /* Link nameless dataset into nameless group with intermediate group */ + ret = H5Olink(dset_id, group_id, "inter_group/dataset", lcpl_id, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Olink"); + + /* Close IDs for dataset and datatype */ + ret = H5Dclose(dset_id); + CHECK(ret, FAIL, "H5Dclose"); + ret = H5Tclose(type_id); + CHECK(ret, FAIL, "H5Tclose"); + + /* Re-open datatype using new link */ + type_id = H5Topen2(group_id, "datatype", H5P_DEFAULT); + CHECK(type_id, FAIL, "H5Topen2"); + + /* Link nameless group to root group and close the group ID*/ + ret = H5Olink(group_id, file_id, "/group", H5P_DEFAULT, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Olink"); + ret = H5Gclose(group_id); + CHECK(ret, FAIL, "H5Gclose"); + + /* Open dataset through root group and verify its data */ + dset_id = H5Dopen2(file_id, "/group/inter_group/dataset", H5P_DEFAULT); + CHECK(dset_id, FAIL, "H5Dopen2"); + + /* Read data from dataset */ + ret = H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata); + CHECK(ret, FAIL, "H5Dread"); + for(i = 0; i < TEST6_DIM1; i++) + for(j = 0; j < TEST6_DIM2; j++) + VERIFY(wdata[i][j], rdata[i][j], "H5Dread"); + + /* Close open IDs */ + ret = H5Dclose(dset_id); + CHECK(ret, FAIL, "H5Dclose"); + ret = H5Tclose(type_id); + CHECK(ret, FAIL, "H5Tclose"); + ret = H5Fclose(file_id); + CHECK(ret, FAIL, "H5Fclose"); + } /* end for */ + + /* Close remaining IDs */ + ret = H5Sclose(space_id); + CHECK(ret, FAIL, "H5Sclose"); + ret = H5Pclose(lcpl_id); + CHECK(ret, FAIL, "H5Pclose"); +} /* end test_h5o_link() */ + + +/**************************************************************** +** ** test_h5o(): Main H5O (generic object) testing routine. ** ****************************************************************/ @@ -773,6 +912,7 @@ test_h5o(void) test_h5o_close(); /* Test generic close function */ test_h5o_refcount(); /* Test incrementing and decrementing reference count */ test_h5o_plist(); /* Test object creation properties */ + test_h5o_link(); /* Test object link routine */ } /* test_h5o() */ @@ -793,3 +933,4 @@ cleanup_h5o(void) { remove(TEST_FILENAME); } + |