From fc12672cdbd162f47293ec9ee2185e3efe1d0405 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 12 Oct 2017 14:27:38 -0500 Subject: Close ids in loop --- tools/src/h5repack/h5repack.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tools/src/h5repack/h5repack.c b/tools/src/h5repack/h5repack.c index 6b8cf8a..2db7fdd 100644 --- a/tools/src/h5repack/h5repack.c +++ b/tools/src/h5repack/h5repack.c @@ -481,6 +481,19 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, if (options->verbose) printf(FORMAT_OBJ_ATTR, "attr", name); + + /*------------------------------------------------------------------------- + * close + *------------------------------------------------------------------------- + */ + if (H5Tclose(ftype_id) < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed"); + if (H5Tclose(wtype_id) < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed"); + if (H5Sclose(space_id) < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose failed"); + if (H5Aclose(attr_id) < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aclose failed"); } /* u */ done: @@ -792,9 +805,9 @@ static int check_objects(const char* fname, pack_opt_t *options) { done: H5E_BEGIN_TRY { - H5Fclose(fid); - H5Sclose(sid); H5Dclose(did); + H5Sclose(sid); + H5Fclose(fid); } H5E_END_TRY; if (travt) trav_table_free(travt); -- cgit v0.12 From d5c073d406f8d1e1ac3bcb05883bea406c8e9378 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Fri, 13 Oct 2017 16:34:01 -0500 Subject: HDFFV-10296 Update tools lib to use the error handling macros. --- tools/lib/h5diff.c | 932 ++++++++++++++++--------------------- tools/lib/h5diff_array.c | 764 +++++++++++++++--------------- tools/lib/h5diff_attr.c | 223 +++++---- tools/lib/h5diff_dset.c | 452 +++++++++--------- tools/lib/h5diff_util.c | 84 +--- tools/lib/h5tools_dump.c | 177 +++---- tools/lib/h5tools_filters.c | 55 ++- tools/lib/h5tools_type.c | 124 +++-- tools/lib/h5tools_utils.c | 231 +++------ tools/lib/h5trav.c | 533 +++++++++------------ tools/src/h5repack/h5repack_copy.c | 188 +++----- 11 files changed, 1593 insertions(+), 2170 deletions(-) diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c index 0be6f5c..285ec60 100644 --- a/tools/lib/h5diff.c +++ b/tools/lib/h5diff.c @@ -21,9 +21,9 @@ /*------------------------------------------------------------------------- * Function: print_objname * - * Purpose: check if object name is to be printed, only when: - * 1) verbose mode - * 2) when diff was found (normal mode) + * Purpose: check if object name is to be printed, only when: + * 1) verbose mode + * 2) when diff was found (normal mode) *------------------------------------------------------------------------- */ H5_ATTR_PURE int @@ -35,11 +35,11 @@ print_objname (diff_opt_t * options, hsize_t nfound) /*------------------------------------------------------------------------- * Function: do_print_objname * - * Purpose: print object name - * + * Purpose: print object name *------------------------------------------------------------------------- */ -void do_print_objname (const char *OBJ, const char *path1, const char *path2, diff_opt_t * opts) +void +do_print_objname (const char *OBJ, const char *path1, const char *path2, diff_opt_t * opts) { /* if verbose level is higher than 0, put space line before * displaying any object or symbolic links. This improves @@ -53,8 +53,7 @@ void do_print_objname (const char *OBJ, const char *path1, const char *path2, di /*------------------------------------------------------------------------- * Function: do_print_attrname * - * Purpose: print attribute name - * + * Purpose: print attribute name *------------------------------------------------------------------------- */ void @@ -66,17 +65,16 @@ do_print_attrname (const char *attr, const char *path1, const char *path2) /*------------------------------------------------------------------------- * Function: print_warn * - * Purpose: check print warning condition. + * Purpose: check print warning condition. * Return: - * 1 if verbose mode - * 0 if not verbos mode - * Programmer: Jonathan Kim - * Date: Feb 4, 2010 + * 1 if verbose mode + * 0 if not verbos mode *------------------------------------------------------------------------- */ -static int print_warn(diff_opt_t *options) +static int +print_warn(diff_opt_t *options) { - return ((options->m_verbose))?1:0; + return ((options->m_verbose)) ? 1: 0; } @@ -84,20 +82,16 @@ static int print_warn(diff_opt_t *options) /*------------------------------------------------------------------------- * Function: phdiff_dismiss_workers * - * Purpose: tell all workers to end. - * - * Return: none - * - * Programmer: Albert Cheng - * - * Date: Feb 6, 2005 + * Purpose: tell all workers to end. * + * Return: none *------------------------------------------------------------------------- */ -void phdiff_dismiss_workers(void) +void +phdiff_dismiss_workers(void) { int i; - for(i=1; im_quiet && (options->m_verbose || options->m_report)) - { + if(options->m_quiet && (options->m_verbose || options->m_report)) { parallel_print("Error: -q (quiet mode) cannot be added to verbose or report modes\n"); - options->err_stat=1; - ret = 0; - goto out; + options->err_stat = 1; + HGOTO_DONE(0); } /* ------------------------------------------------------- * only allow --no-dangling-links along with --follow-symlinks */ - if(options->no_dangle_links && !options->follow_links) - { + if(options->no_dangle_links && !options->follow_links) { parallel_print("Error: --no-dangling-links must be used along with --follow-symlinks option.\n"); - options->err_stat=1; - ret = 0; - goto out; + options->err_stat = 1; + HGOTO_DONE(0); } -out: +done: - return ret; + return ret_value; } /*------------------------------------------------------------------------- * Function: is_exclude_path * - * Purpose: check if 'paths' are part of exclude path list + * Purpose: check if 'paths' are part of exclude path list * * Return: - * 1 - excluded path - * 0 - not excluded path - * - * Programmer: Jonathan Kim - * Date: Aug 23, 2010 + * 1 - excluded path + * 0 - not excluded path *------------------------------------------------------------------------*/ -static int is_exclude_path (char * path, h5trav_type_t type, diff_opt_t *options) +static int +is_exclude_path (char * path, h5trav_type_t type, diff_opt_t *options) { struct exclude_path_list * exclude_path_ptr; - int ret_cmp; - int ret = 0; + int ret_cmp; + int ret_value = 0; /* check if exclude path option is given */ if (!options->exclude_path) - goto out; + HGOTO_DONE(0); /* assign to local exclude list pointer */ exclude_path_ptr = options->exclude; /* search objects in exclude list */ - while (NULL != exclude_path_ptr) - { + while (NULL != exclude_path_ptr) { /* if exclude path is is group, exclude its members as well */ - if (exclude_path_ptr->obj_type == H5TRAV_TYPE_GROUP) - { + if (exclude_path_ptr->obj_type == H5TRAV_TYPE_GROUP) { ret_cmp = HDstrncmp(exclude_path_ptr->obj_path, path, HDstrlen(exclude_path_ptr->obj_path)); - if (ret_cmp == 0) /* found matching members */ - { + if (ret_cmp == 0) { /* found matching members */ size_t len_grp; /* check if given path belong to an excluding group, if so @@ -223,22 +198,19 @@ static int is_exclude_path (char * path, h5trav_type_t type, diff_opt_t *options * not under “/grp1xxx/” group. */ len_grp = HDstrlen(exclude_path_ptr->obj_path); - if (path[len_grp] == '/') - { + if (path[len_grp] == '/') { /* belong to excluded group! */ - ret = 1; + ret_value = 1; break; /* while */ } } } /* exclude target is not group, just exclude the object */ - else - { + else { ret_cmp = HDstrcmp(exclude_path_ptr->obj_path, path); - if (ret_cmp == 0) /* found matching object */ - { + if (ret_cmp == 0) { /* found matching object */ /* excluded non-group object */ - ret = 1; + ret_value = 1; /* remember the type of this maching object. * if it's group, it can be used for excluding its member * objects in this while() loop */ @@ -249,26 +221,23 @@ static int is_exclude_path (char * path, h5trav_type_t type, diff_opt_t *options exclude_path_ptr = exclude_path_ptr->next; } -out: - return ret; +done: + return ret_value; } /*------------------------------------------------------------------------- * Function: free_exclude_path_list * - * Purpose: free exclud object list from diff options - * - * Programmer: Jonathan Kim - * Date: Aug 23, 2010 + * Purpose: free exclude object list from diff options *------------------------------------------------------------------------*/ -static void free_exclude_path_list(diff_opt_t *options) +static void +free_exclude_path_list(diff_opt_t *options) { - struct exclude_path_list * curr = options->exclude; - struct exclude_path_list * next; + struct exclude_path_list *curr = options->exclude; + struct exclude_path_list *next; - while (NULL != curr) - { + while (NULL != curr) { next = curr->next; HDfree(curr); curr = next; @@ -278,44 +247,43 @@ static void free_exclude_path_list(diff_opt_t *options) /*------------------------------------------------------------------------- * Function: build_match_list * - * Purpose: get list of matching path_name from info1 and info2 + * Purpose: get list of matching path_name from info1 and info2 * * Note: - * Find common objects; the algorithm used for this search is the - * cosequential match algorithm and is described in - * Folk, Michael; Zoellick, Bill. (1992). File Structures. Addison-Wesley. - * Moved out from diff_match() to make code more flexible. + * Find common objects; the algorithm used for this search is the + * cosequential match algorithm and is described in + * Folk, Michael; Zoellick, Bill. (1992). File Structures. Addison-Wesley. + * Moved out from diff_match() to make code more flexible. * * Parameter: - * table_out [OUT] : return the list - * - * Programmer: Jonathan Kim - * - * Date: Aug 18, 2010 + * table_out [OUT] : return the list *------------------------------------------------------------------------*/ -static void build_match_list (const char *objname1, trav_info_t *info1, const char *objname2, trav_info_t *info2, trav_table_t ** table_out, diff_opt_t *options) +static void +build_match_list (const char *objname1, trav_info_t *info1, const char *objname2, trav_info_t *info2, + trav_table_t ** table_out, diff_opt_t *options) { - size_t curr1 = 0; - size_t curr2 = 0; + size_t curr1 = 0; + size_t curr2 = 0; unsigned infile[2]; - char * path1_lp; - char * path2_lp; + char *path1_lp = NULL; + char *path2_lp = NULL; h5trav_type_t type1_l; h5trav_type_t type2_l; - size_t path1_offset = 0; - size_t path2_offset = 0; - int cmp; - trav_table_t *table; - size_t idx; + size_t path1_offset = 0; + size_t path2_offset = 0; + int cmp; + trav_table_t *table = NULL; + size_t idx; h5difftrace("build_match_list start\n"); /* init */ - trav_table_init( &table ); - + trav_table_init(&table); + if (table == NULL) + H5TOOLS_INFO(H5E_tools_min_id_g, "Cannot create tarverse table"); /* * This is necessary for the case that given objects are group and * have different names (ex: obj1 is /grp1 and obj2 is /grp5). - * All the objects belong to given groups are the cadidates. + * All the objects belong to given groups are the candidates. * So prepare to compare paths without the group names. */ @@ -329,8 +297,7 @@ static void build_match_list (const char *objname1, trav_info_t *info1, const ch /*-------------------------------------------------- * build the list */ - while(curr1 < info1->nused && curr2 < info2->nused) - { + while(curr1 < info1->nused && curr2 < info2->nused) { path1_lp = (info1->paths[curr1].path) + path1_offset; path2_lp = (info2->paths[curr2].path) + path2_offset; type1_l = info1->paths[curr1].type; @@ -338,19 +305,15 @@ static void build_match_list (const char *objname1, trav_info_t *info1, const ch /* criteria is string compare */ cmp = HDstrcmp(path1_lp, path2_lp); - - if(cmp == 0) - { - if(!is_exclude_path(path1_lp, type1_l, options)) - { + if(cmp == 0) { + if(!is_exclude_path(path1_lp, type1_l, options)) { infile[0] = 1; infile[1] = 1; trav_table_addflags(infile, path1_lp, info1->paths[curr1].type, table); /* if the two point to the same target object, * mark that in table */ if (info1->paths[curr1].fileno == info2->paths[curr2].fileno && - info1->paths[curr1].objno == info2->paths[curr2].objno ) - { + info1->paths[curr1].objno == info2->paths[curr2].objno) { idx = table->nobjs - 1; table->objs[idx].is_same_trgobj = 1; } @@ -358,20 +321,16 @@ static void build_match_list (const char *objname1, trav_info_t *info1, const ch curr1++; curr2++; } /* end if */ - else if(cmp < 0) - { - if(!is_exclude_path(path1_lp, type1_l, options)) - { + else if(cmp < 0) { + if(!is_exclude_path(path1_lp, type1_l, options)) { infile[0] = 1; infile[1] = 0; trav_table_addflags(infile, path1_lp, info1->paths[curr1].type, table); } curr1++; } /* end else-if */ - else - { - if (!is_exclude_path(path2_lp, type2_l, options)) - { + else { + if (!is_exclude_path(path2_lp, type2_l, options)) { infile[0] = 0; infile[1] = 1; trav_table_addflags(infile, path2_lp, info2->paths[curr2].type, table); @@ -383,13 +342,11 @@ static void build_match_list (const char *objname1, trav_info_t *info1, const ch /* list1 did not end */ infile[0] = 1; infile[1] = 0; - while(curr1 < info1->nused) - { + while(curr1 < info1->nused) { path1_lp = (info1->paths[curr1].path) + path1_offset; type1_l = info1->paths[curr1].type; - if(!is_exclude_path(path1_lp, type1_l, options)) - { + if(!is_exclude_path(path1_lp, type1_l, options)) { trav_table_addflags(infile, path1_lp, info1->paths[curr1].type, table); } curr1++; @@ -398,13 +355,11 @@ static void build_match_list (const char *objname1, trav_info_t *info1, const ch /* list2 did not end */ infile[0] = 0; infile[1] = 1; - while(curr2 < info2->nused) - { + while(curr2 < info2->nused) { path2_lp = (info2->paths[curr2].path) + path2_offset; type2_l = info2->paths[curr2].type; - if (!is_exclude_path(path2_lp, type2_l, options)) - { + if (!is_exclude_path(path2_lp, type2_l, options)) { trav_table_addflags(infile, path2_lp, info2->paths[curr2].type, table); } curr2++; @@ -420,15 +375,11 @@ static void build_match_list (const char *objname1, trav_info_t *info1, const ch /*------------------------------------------------------------------------- * Function: trav_grp_objs * - * Purpose: - * Call back function from h5trav_visit(). - * - * Programmer: Jonathan Kim - * - * Date: Aug 16, 2010 + * Purpose: Call back function from h5trav_visit(). *------------------------------------------------------------------------*/ -static herr_t trav_grp_objs(const char *path, const H5O_info_t *oinfo, - const char *already_visited, void *udata) +static herr_t +trav_grp_objs(const char *path, const H5O_info_t *oinfo, + const char *already_visited, void *udata) { trav_info_visit_obj(path, oinfo, already_visited, udata); @@ -438,18 +389,14 @@ static herr_t trav_grp_objs(const char *path, const H5O_info_t *oinfo, /*------------------------------------------------------------------------- * Function: trav_grp_symlinks * - * Purpose: - * Call back function from h5trav_visit(). - * Track and extra checkings while visiting all symbolic-links. - * - * Programmer: Jonathan Kim - * - * Date: Aug 16, 2010 + * Purpose: Call back function from h5trav_visit(). + * Track and extra checkings while visiting all symbolic-links. *------------------------------------------------------------------------*/ -static herr_t trav_grp_symlinks(const char *path, const H5L_info_t *linfo, +static herr_t +trav_grp_symlinks(const char *path, const H5L_info_t *linfo, void *udata) { - int ret_value = 0; + herr_t ret_value = 0; trav_info_t *tinfo = (trav_info_t *)udata; diff_opt_t *opts = (diff_opt_t *)tinfo->opts; h5tool_link_info_t lnk_info; @@ -461,29 +408,30 @@ static herr_t trav_grp_symlinks(const char *path, const H5L_info_t *linfo, if (!opts->follow_links) { trav_info_visit_lnk(path, linfo, tinfo); - goto done; + HGOTO_DONE(0); } switch(linfo->type) { case H5L_TYPE_SOFT: - if((ret_value = H5tools_get_symlink_info(tinfo->fid, path, &lnk_info, opts->follow_links)) < 0) - goto done; - /* no dangling link option given and detect dangling link */ + if((ret_value = H5tools_get_symlink_info(tinfo->fid, path, &lnk_info, opts->follow_links)) < 0) { + HGOTO_DONE(ret_value); + } else if (ret_value == 0) { - tinfo->symlink_visited.dangle_link = TRUE; + /* no dangling link option given and detect dangling link */ + tinfo->symlink_visited.dangle_link = TRUE; trav_info_visit_lnk(path, linfo, tinfo); if (opts->no_dangle_links) opts->err_stat = 1; /* make dangling link is error */ - goto done; + HGOTO_DONE(0); } /* check if already visit the target object */ if(symlink_is_visited( &(tinfo->symlink_visited), linfo->type, NULL, lnk_info.trg_path)) - goto done; + HGOTO_DONE(0); /* add this link as visited link */ if(symlink_visit_add( &(tinfo->symlink_visited), linfo->type, NULL, lnk_info.trg_path) < 0) - goto done; + HGOTO_DONE(0); if(h5trav_visit(tinfo->fid, path, TRUE, TRUE, trav_grp_objs,trav_grp_symlinks, tinfo) < 0) { @@ -494,27 +442,28 @@ static herr_t trav_grp_symlinks(const char *path, const H5L_info_t *linfo, break; case H5L_TYPE_EXTERNAL: - if ((ret_value = H5tools_get_symlink_info(tinfo->fid, path, &lnk_info, opts->follow_links)) < 0) - goto done; - /* no dangling link option given and detect dangling link */ + if ((ret_value = H5tools_get_symlink_info(tinfo->fid, path, &lnk_info, opts->follow_links)) < 0) { + HGOTO_DONE(ret_value); + } else if (ret_value == 0) { + /* no dangling link option given and detect dangling link */ tinfo->symlink_visited.dangle_link = TRUE; trav_info_visit_lnk(path, linfo, tinfo); if (opts->no_dangle_links) opts->err_stat = 1; /* make dangling link is error */ - goto done; + HGOTO_DONE(0); } if(H5Lunpack_elink_val(lnk_info.trg_path, linfo->u.val_size, NULL, &ext_fname, &ext_path) < 0) - goto done; + HGOTO_DONE(0); /* check if already visit the target object */ if(symlink_is_visited( &(tinfo->symlink_visited), linfo->type, ext_fname, ext_path)) - goto done; + HGOTO_DONE(0); /* add this link as visited link */ if(symlink_visit_add( &(tinfo->symlink_visited), linfo->type, ext_fname, ext_path) < 0) - goto done; + HGOTO_DONE(0); if(h5trav_visit(tinfo->fid, path, TRUE, TRUE, trav_grp_objs,trav_grp_symlinks, tinfo) < 0) { @@ -537,45 +486,41 @@ static herr_t trav_grp_symlinks(const char *path, const H5L_info_t *linfo, done: if (lnk_info.trg_path) HDfree(lnk_info.trg_path); - return 0; + return ret_value; } /*------------------------------------------------------------------------- * Function: h5diff * - * Purpose: public function, can be called in an application program. - * return differences between 2 HDF5 files - * - * Return: Number of differences found. - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: October 22, 2003 + * Purpose: public function, can be called in an application program. + * return differences between 2 HDF5 files * + * Return: Number of differences found. *------------------------------------------------------------------------- */ -hsize_t h5diff(const char *fname1, +hsize_t +h5diff(const char *fname1, const char *fname2, const char *objname1, const char *objname2, diff_opt_t *opts) { - int ret_value = 0; - hid_t file1_id = (-1); - hid_t file2_id = (-1); - char filenames[2][MAX_FILENAME]; - hsize_t nfound = 0; - int l_ret1 = -1; - int l_ret2 = -1; - char * obj1fullname = NULL; - char * obj2fullname = NULL; - int both_objs_grp = 0; + int ret_value = 0; + hid_t file1_id = -1; + hid_t file2_id = -1; + char filenames[2][MAX_FILENAME]; + hsize_t nfound = 0; + int l_ret1 = -1; + int l_ret2 = -1; + char *obj1fullname = NULL; + char *obj2fullname = NULL; + int both_objs_grp = 0; /* init to group type */ h5trav_type_t obj1type = H5TRAV_TYPE_GROUP; h5trav_type_t obj2type = H5TRAV_TYPE_GROUP; /* for single object */ - H5O_info_t oinfo1, oinfo2; /* object info */ + H5O_info_t oinfo1, oinfo2; /* object info */ trav_info_t *info1_obj = NULL; trav_info_t *info2_obj = NULL; /* for group object */ @@ -585,8 +530,8 @@ hsize_t h5diff(const char *fname1, trav_info_t *info1_lp = NULL; trav_info_t *info2_lp = NULL; /* link info from specified object */ - H5L_info_t src_linfo1; - H5L_info_t src_linfo2; + H5L_info_t src_linfo1; + H5L_info_t src_linfo2; /* link info from member object */ h5tool_link_info_t trg_linfo1; h5tool_link_info_t trg_linfo2; @@ -604,34 +549,27 @@ hsize_t h5diff(const char *fname1, * check invalid combination of options *-----------------------------------------------------------------------*/ if(!is_valid_options(opts)) - goto done; + HGOTO_DONE(0); opts->cmn_objs = 1; /* eliminate warning */ + opts->err_stat = 1; /* initialize error status to FAIL */ /*------------------------------------------------------------------------- * open the files first; if they are not valid, no point in continuing *------------------------------------------------------------------------- */ - - /* disable error reporting */ - H5E_BEGIN_TRY - { - /* open file 1 */ - if((file1_id = h5tools_fopen(fname1, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t)0)) < 0) { - parallel_print("h5diff: <%s>: unable to open file\n", fname1); - opts->err_stat = 1; - goto done; - } /* end if */ + /* open file 1 */ + if((file1_id = h5tools_fopen(fname1, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t)0)) < 0) { + parallel_print("h5diff: <%s>: unable to open file\n", fname1); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "<%s>: unable to open file\n", fname1); + } /* end if */ - /* open file 2 */ - if((file2_id = h5tools_fopen(fname2, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t)0)) < 0) { - parallel_print("h5diff: <%s>: unable to open file\n", fname2); - opts->err_stat = 1; - goto done; - } /* end if */ - /* enable error reporting */ - } H5E_END_TRY; + /* open file 2 */ + if((file2_id = h5tools_fopen(fname2, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t)0)) < 0) { + parallel_print("h5diff: <%s>: unable to open file\n", fname2); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "<%s>: unable to open file\n", fname2); + } /* end if */ /*------------------------------------------------------------------------- * Initialize the info structs @@ -648,10 +586,12 @@ hsize_t h5diff(const char *fname1, #ifdef H5_HAVE_ASPRINTF /* Use the asprintf() routine, since it does what we're trying to do below */ if(HDasprintf(&obj1fullname, "/%s", objname1) < 0) - goto done; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "name buffer allocation failed"); #else /* H5_HAVE_ASPRINTF */ /* (malloc 2 more for "/" and end-of-line) */ - obj1fullname = (char*)HDmalloc(HDstrlen(objname1) + 2); + if ((obj1fullname = (char*)HDmalloc(HDstrlen(objname1) + 2)) == NULL) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "name buffer allocation failed"); + HDstrcpy(obj1fullname, "/"); HDstrcat(obj1fullname, objname1); #endif /* H5_HAVE_ASPRINTF */ @@ -664,10 +604,11 @@ hsize_t h5diff(const char *fname1, #ifdef H5_HAVE_ASPRINTF /* Use the asprintf() routine, since it does what we're trying to do below */ if(HDasprintf(&obj2fullname, "/%s", objname2) < 0) - goto done; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "name buffer allocation failed"); #else /* H5_HAVE_ASPRINTF */ /* (malloc 2 more for "/" and end-of-line) */ - obj2fullname = (char*)HDmalloc(HDstrlen(objname2) + 2); + if ((obj2fullname = (char*)HDmalloc(HDstrlen(objname2) + 2)) == NULL) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "name buffer allocation failed"); HDstrcpy(obj2fullname, "/"); HDstrcat(obj2fullname, objname2); #endif /* H5_HAVE_ASPRINTF */ @@ -693,7 +634,7 @@ hsize_t h5diff(const char *fname1, if(H5Lget_info(file1_id, obj1fullname, &src_linfo1, H5P_DEFAULT) < 0) { parallel_print("Unable to get link info from <%s>\n", obj1fullname); H5TOOLS_INFO(H5E_tools_min_id_g, "Unable to get link info\n"); - goto done; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Lget_info failed"); } info1_lp = info1_obj; @@ -745,7 +686,7 @@ hsize_t h5diff(const char *fname1, /* get info from link */ if(H5Lget_info(file2_id, obj2fullname, &src_linfo2, H5P_DEFAULT) < 0) { parallel_print("Unable to get link info from <%s>\n", obj2fullname); - goto done; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Lget_info failed"); } info2_lp = info2_obj; @@ -815,7 +756,7 @@ hsize_t h5diff(const char *fname1, if(opts->m_verbose) parallel_print("Warning: <%s> is a dangling link.\n", obj1fullname); opts->err_stat = 1; - HGOTO_ERROR(opts->err_stat, H5E_tools_min_id_g, "Error: treat dangling link as error"); + HGOTO_ERROR(opts->err_stat, H5E_tools_min_id_g, "treat dangling link as error"); } else { if(opts->m_verbose) @@ -823,14 +764,14 @@ hsize_t h5diff(const char *fname1, if (l_ret1 != 0 || l_ret2 != 0) { nfound++; print_found(nfound); - goto done; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5tools_get_symlink_info error"); } } } else if(l_ret1 < 0) { /* fail */ parallel_print ("Object <%s> could not be found in <%s>\n", obj1fullname, fname1); opts->err_stat = 1; - HGOTO_ERROR(opts->err_stat, H5E_tools_min_id_g, "Error: Object could not be found"); + HGOTO_ERROR(opts->err_stat, H5E_tools_min_id_g, "Object could not be found"); } else if(l_ret1 != 2) { /* symbolic link */ obj1type = (h5trav_type_t)trg_linfo1.trg_type; @@ -858,7 +799,7 @@ hsize_t h5diff(const char *fname1, if(opts->m_verbose) parallel_print("Warning: <%s> is a dangling link.\n", obj2fullname); opts->err_stat = 1; - HGOTO_ERROR(opts->err_stat, H5E_tools_min_id_g, "Error: treat dangling link as error"); + HGOTO_ERROR(opts->err_stat, H5E_tools_min_id_g, "treat dangling link as error"); } else { if(opts->m_verbose) @@ -866,14 +807,14 @@ hsize_t h5diff(const char *fname1, if (l_ret1 != 0 || l_ret2 != 0) { nfound++; print_found(nfound); - goto done; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5tools_get_symlink_info error"); } } } else if(l_ret2 < 0) { /* fail */ parallel_print ("Object <%s> could not be found in <%s>\n", obj2fullname, fname2); opts->err_stat = 1; - HGOTO_ERROR(opts->err_stat, H5E_tools_min_id_g, "Error: Object could not be found"); + HGOTO_ERROR(opts->err_stat, H5E_tools_min_id_g, "Object could not be found"); } else if(l_ret2 != 2) { /* symbolic link */ obj2type = (h5trav_type_t)trg_linfo2.trg_type; @@ -899,9 +840,9 @@ hsize_t h5diff(const char *fname1, if(!(opts->m_verbose || opts->m_report)) { h5difftrace("h5diff NOT (opts->m_verbose || opts->m_report)\n"); /* if no danglink links */ - if ( l_ret1 > 0 && l_ret2 > 0 ) + if (l_ret1 > 0 && l_ret2 > 0) if (h5tools_is_obj_same(file1_id, obj1fullname, file2_id, obj2fullname)!=0) - goto done; + HGOTO_ERROR(opts->err_stat, H5E_tools_min_id_g, "Same object"); } both_objs_grp = (obj1type == H5TRAV_TYPE_GROUP && obj2type == H5TRAV_TYPE_GROUP); @@ -918,7 +859,7 @@ hsize_t h5diff(const char *fname1, trav_grp_objs, trav_grp_symlinks, info1_grp) < 0) { parallel_print("Error: Could not get file contents\n"); opts->err_stat = 1; - HGOTO_ERROR(opts->err_stat, H5E_tools_min_id_g, "Error: Could not get file contents"); + HGOTO_ERROR(opts->err_stat, H5E_tools_min_id_g, "Could not get file contents"); } info1_lp = info1_grp; @@ -933,7 +874,7 @@ hsize_t h5diff(const char *fname1, trav_grp_objs, trav_grp_symlinks, info2_grp) < 0) { parallel_print("Error: Could not get file contents\n"); opts->err_stat = 1; - HGOTO_ERROR(opts->err_stat, H5E_tools_min_id_g, "Error: Could not get file contents"); + HGOTO_ERROR(opts->err_stat, H5E_tools_min_id_g, "Could not get file contents"); } /* end if */ info2_lp = info2_grp; } @@ -957,8 +898,7 @@ hsize_t h5diff(const char *fname1, #endif /* process the objects */ - build_match_list (obj1fullname, info1_lp, obj2fullname, info2_lp, - &match_list, opts); + build_match_list (obj1fullname, info1_lp, obj2fullname, info2_lp, &match_list, opts); if (both_objs_grp) { /*------------------------------------------------------ * print the list @@ -987,6 +927,8 @@ hsize_t h5diff(const char *fname1, file2_id, obj2fullname, info2_lp, match_list, opts); + opts->err_stat = 1; /* success status */ + done: #ifdef H5_HAVE_PARALLEL if(g_Parallel) @@ -1022,6 +964,7 @@ done: H5Fclose(file1_id); H5Fclose(file2_id); } H5E_END_TRY; + h5difftrace("h5diff finish\n"); return nfound; @@ -1032,43 +975,34 @@ done: /*------------------------------------------------------------------------- * Function: diff_match * - * Purpose: - * Compare common objects in given groups according to table structure. - * The table structure has flags which can be used to find common objects - * and will be compared. - * Common object means same name (absolute path) objects in both location. - * - * Return: Number of differences found - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * Purpose: Compare common objects in given groups according to table structure. + * The table structure has flags which can be used to find common objects + * and will be compared. + * Common object means same name (absolute path) objects in both location. * - * Date: May 9, 2003 + * Return: Number of differences found * - * Modifications: Jan 2005 Leon Arber, larber@uiuc.edu - * Added support for parallel diffing - * - * Pedro Vicente, pvn@hdfgroup.org, Nov 4, 2008 - * Compare the graph and make h5diff return 1 for difference if - * 1) the number of objects in file1 is not the same as in file2 - * 2) the graph does not match, i.e same names (absolute path) - * 3) objects with the same name are not of the same type + * Modifications: Compare the graph and make h5diff return 1 for difference if + * 1) the number of objects in file1 is not the same as in file2 + * 2) the graph does not match, i.e same names (absolute path) + * 3) objects with the same name are not of the same type *------------------------------------------------------------------------- */ -hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, +hsize_t +diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, hid_t file2_id, const char *grp2, trav_info_t *info2, trav_table_t *table, diff_opt_t *options) { hsize_t nfound = 0; unsigned i; - - const char * grp1_path = ""; - const char * grp2_path = ""; - char * obj1_fullpath = NULL; - char * obj2_fullpath = NULL; - diff_args_t argdata; - size_t idx1 = 0; - size_t idx2 = 0; - + int ret_value = 0; + const char *grp1_path = ""; + const char *grp2_path = ""; + char *obj1_fullpath = NULL; + char *obj2_fullpath = NULL; + diff_args_t argdata; + size_t idx1 = 0; + size_t idx2 = 0; h5difftrace("diff_match start\n"); /* @@ -1081,85 +1015,82 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, grp2_path = grp2; /*------------------------------------------------------------------------- - * regarding the return value of h5diff (0, no difference in files, 1 difference ) - * 1) the number of objects in file1 must be the same as in file2 - * 2) the graph must match, i.e same names (absolute path) - * 3) objects with the same name must be of the same type - *------------------------------------------------------------------------- - */ + * regarding the return value of h5diff (0, no difference in files, 1 difference ) + * 1) the number of objects in file1 must be the same as in file2 + * 2) the graph must match, i.e same names (absolute path) + * 3) objects with the same name must be of the same type + *------------------------------------------------------------------------- + */ /* not valid compare used when --exclude-path option is used */ - if (!options->exclude_path) - { + if (!options->exclude_path) { /* number of different objects */ - if ( info1->nused != info2->nused ) - { + if (info1->nused != info2->nused) { options->contents = 0; } } /* objects in one file and not the other */ - for( i = 0; i < table->nobjs; i++) - { - if( table->objs[i].flags[0] != table->objs[i].flags[1] ) - { + for(i = 0; i < table->nobjs; i++) { + if(table->objs[i].flags[0] != table->objs[i].flags[1]) { options->contents = 0; break; } } - /*------------------------------------------------------------------------- - * do the diff for common objects - *------------------------------------------------------------------------- - */ + * do the diff for common objects + *------------------------------------------------------------------------- + */ #ifdef H5_HAVE_PARALLEL { - char *workerTasks = (char*)HDmalloc((g_nTasks - 1) * sizeof(char)); - int n; - int busyTasks = 0; - struct diffs_found nFoundbyWorker; - struct diff_mpi_args args; - int havePrintToken = 1; - MPI_Status Status; - - /*set all tasks as free */ - HDmemset(workerTasks, 1, (g_nTasks - 1)); + char *workerTasks = (char*)HDmalloc((g_nTasks - 1) * sizeof(char)); + int n; + int busyTasks = 0; + struct diffs_found nFoundbyWorker; + struct diff_mpi_args args; + int havePrintToken = 1; + MPI_Status Status; + + /*set all tasks as free */ + HDmemset(workerTasks, 1, (g_nTasks - 1)); #endif - for(i = 0; i < table->nobjs; i++) - { - if( table->objs[i].flags[0] && table->objs[i].flags[1]) - { + for(i = 0; i < table->nobjs; i++) { + if(table->objs[i].flags[0] && table->objs[i].flags[1]) { /* make full path for obj1 */ #ifdef H5_HAVE_ASPRINTF /* Use the asprintf() routine, since it does what we're trying to do below */ if(HDasprintf(&obj1_fullpath, "%s%s", grp1_path, table->objs[i].name) < 0) - goto out; + HERROR(FAIL, H5E_tools_min_id_g, "name buffer allocation failed"); #else /* H5_HAVE_ASPRINTF */ - obj1_fullpath = (char*)HDmalloc(HDstrlen(grp1_path) + HDstrlen(table->objs[i].name) + 1); - HDstrcpy(obj1_fullpath, grp1_path); - HDstrcat(obj1_fullpath, table->objs[i].name); + if((obj1_fullpath = (char*)HDmalloc(HDstrlen(grp1_path) + HDstrlen(table->objs[i].name) + 1)) == NULL) + HERROR(FAIL, H5E_tools_min_id_g, "name buffer allocation failed"); + else { + HDstrcpy(obj1_fullpath, grp1_path); + HDstrcat(obj1_fullpath, table->objs[i].name); + } #endif /* H5_HAVE_ASPRINTF */ /* make full path for obj2 */ #ifdef H5_HAVE_ASPRINTF /* Use the asprintf() routine, since it does what we're trying to do below */ if(HDasprintf(&obj2_fullpath, "%s%s", grp2_path, table->objs[i].name) < 0) - goto out; + HERROR(FAIL, H5E_tools_min_id_g, "name buffer allocation failed"); #else /* H5_HAVE_ASPRINTF */ - obj2_fullpath = (char*)HDmalloc(HDstrlen(grp2_path) + HDstrlen(table->objs[i].name) + 1); - HDstrcpy(obj2_fullpath, grp2_path); - HDstrcat(obj2_fullpath, table->objs[i].name); + if((obj2_fullpath = (char*)HDmalloc(HDstrlen(grp2_path) + HDstrlen(table->objs[i].name) + 1)) == NULL) + HERROR(FAIL, H5E_tools_min_id_g, "name buffer allocation failed"); + else { + HDstrcpy(obj2_fullpath, grp2_path); + HDstrcat(obj2_fullpath, table->objs[i].name); + } #endif /* H5_HAVE_ASPRINTF */ /* get index to figure out type of the object in file1 */ - while(info1->paths[idx1].path && - (HDstrcmp(obj1_fullpath, info1->paths[idx1].path) != 0)) + while(info1->paths[idx1].path && (HDstrcmp(obj1_fullpath, info1->paths[idx1].path) != 0)) idx1++; /* get index to figure out type of the object in file2 */ - while(info2->paths[idx2].path && - (HDstrcmp(obj2_fullpath, info2->paths[idx2].path) != 0)) + while(info2->paths[idx2].path && (HDstrcmp(obj2_fullpath, info2->paths[idx2].path) != 0)) idx2++; /* Set argdata to pass other args into diff() */ @@ -1168,15 +1099,13 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, argdata.is_same_trgobj = table->objs[i].is_same_trgobj; options->cmn_objs = 1; - if(!g_Parallel) - { + if(!g_Parallel) { nfound += diff(file1_id, obj1_fullpath, file2_id, obj2_fullpath, options, &argdata); } /* end if */ #ifdef H5_HAVE_PARALLEL - else - { + else { int workerFound = 0; h5difftrace("Beginning of big else block\n"); @@ -1190,8 +1119,7 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, /*Set up args to pass to worker task. */ if(HDstrlen(obj1_fullpath) > 255 || - HDstrlen(obj2_fullpath) > 255) - { + HDstrlen(obj2_fullpath) > 255) { printf("The parallel diff only supports object names up to 255 characters\n"); MPI_Abort(MPI_COMM_WORLD, 0); } /* end if */ @@ -1205,16 +1133,14 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, args.argdata.is_same_trgobj = table->objs[i].is_same_trgobj; /* if there are any outstanding print requests, let's handle one. */ - if(busyTasks > 0) - { + if(busyTasks > 0) { int incomingMessage; /* check if any tasks freed up, and didn't need to print. */ MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &incomingMessage, &Status); /* first block*/ - if(incomingMessage) - { + if(incomingMessage) { workerTasks[Status.MPI_SOURCE - 1] = 1; MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &Status); nfound += nFoundbyWorker.nfound; @@ -1223,8 +1149,7 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, } /* end if */ /* check to see if the print token was returned. */ - if(!havePrintToken) - { + if(!havePrintToken) { /* If we don't have the token, someone is probably sending us output */ print_incoming_data(); @@ -1243,12 +1168,10 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, } /* end if */ /* check to see if anyone needs the print token. */ - if(havePrintToken) - { + if(havePrintToken) { /* check incoming queue for print token requests */ MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_REQUEST, MPI_COMM_WORLD, &incomingMessage, &Status); - if(incomingMessage) - { + if(incomingMessage) { MPI_Recv(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_REQUEST, MPI_COMM_WORLD, &Status); MPI_Send(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD); havePrintToken = 0; @@ -1259,10 +1182,8 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, /* check array of tasks to see which ones are free. * Manager task never does work, so freeTasks[0] is really * worker task 0. */ - for(n = 1; (n < g_nTasks) && !workerFound; n++) - { - if(workerTasks[n-1]) - { + for(n = 1; (n < g_nTasks) && !workerFound; n++) { + if(workerTasks[n-1]) { /* send file id's and names to first free worker */ MPI_Send(&args, sizeof(args), MPI_BYTE, n, MPI_TAG_ARGS, MPI_COMM_WORLD); @@ -1275,24 +1196,20 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, } /* end if */ } /* end for */ - if(!workerFound) - { + if(!workerFound) { /* if they were all busy, we've got to wait for one free up * before we can move on. If we don't have the token, some * task is currently printing so we'll wait for that task to * return it. */ - if(!havePrintToken) - { - while(!havePrintToken) - { + if(!havePrintToken) { + while(!havePrintToken) { int incomingMessage; print_incoming_data(); MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage, &Status); - if(incomingMessage) - { + if(incomingMessage) { MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); havePrintToken = 1; nfound += nFoundbyWorker.nfound; @@ -1303,27 +1220,23 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, } /* end while */ } /* end if */ /* if we do have the token, check for task to free up, or wait for a task to request it */ - else - { + else { /* But first print all the data in our incoming queue */ print_incoming_data(); MPI_Probe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &Status); - if(Status.MPI_TAG == MPI_TAG_DONE) - { + if(Status.MPI_TAG == MPI_TAG_DONE) { MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &Status); nfound += nFoundbyWorker.nfound; options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; MPI_Send(&args, sizeof(args), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_ARGS, MPI_COMM_WORLD); } /* end if */ - else if(Status.MPI_TAG == MPI_TAG_TOK_REQUEST) - { + else if(Status.MPI_TAG == MPI_TAG_TOK_REQUEST) { int incomingMessage; MPI_Recv(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_REQUEST, MPI_COMM_WORLD, &Status); MPI_Send(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD); - do - { + do { MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage, &Status); print_incoming_data(); @@ -1334,8 +1247,7 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; MPI_Send(&args, sizeof(args), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_ARGS, MPI_COMM_WORLD); } /* end else-if */ - else - { + else { printf("ERROR: Invalid tag (%d) received \n", Status.MPI_TAG); MPI_Abort(MPI_COMM_WORLD, 0); MPI_Finalize(); @@ -1353,24 +1265,19 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, h5difftrace("done with for loop\n"); #ifdef H5_HAVE_PARALLEL - if(g_Parallel) - { + if(g_Parallel) { /* make sure all tasks are done */ - while(busyTasks > 0) - { + while(busyTasks > 0) { MPI_Probe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &Status); - if(Status.MPI_TAG == MPI_TAG_DONE) - { + if(Status.MPI_TAG == MPI_TAG_DONE) { MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &Status); nfound += nFoundbyWorker.nfound; options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; busyTasks--; } /* end if */ - else if(Status.MPI_TAG == MPI_TAG_TOK_REQUEST) - { + else if(Status.MPI_TAG == MPI_TAG_TOK_REQUEST) { MPI_Recv(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_REQUEST, MPI_COMM_WORLD, &Status); - if(havePrintToken) - { + if(havePrintToken) { int incomingMessage; MPI_Send(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD); @@ -1387,13 +1294,11 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, busyTasks--; } /* end if */ /* someone else must have it...wait for them to return it, then give it to the task that just asked for it. */ - else - { + else { int source = Status.MPI_SOURCE; int incomingMessage; - do - { + do { MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage, &Status); print_incoming_data(); @@ -1407,16 +1312,14 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, MPI_Send(NULL, 0, MPI_BYTE, source, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD); } /* end else */ } /* end else-if */ - else if(Status.MPI_TAG == MPI_TAG_TOK_RETURN) - { + else if(Status.MPI_TAG == MPI_TAG_TOK_RETURN) { MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); nfound += nFoundbyWorker.nfound; options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; busyTasks--; havePrintToken = 1; } /* end else-if */ - else if(Status.MPI_TAG == MPI_TAG_PRINT_DATA) - { + else if(Status.MPI_TAG == MPI_TAG_PRINT_DATA) { char data[PRINT_DATA_MAX_SIZE + 1]; HDmemset(data, 0, PRINT_DATA_MAX_SIZE + 1); @@ -1424,8 +1327,7 @@ hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, printf("%s", data); } /* end else-if */ - else - { + else { printf("ph5diff-manager: ERROR!! Invalid tag (%d) received \n", Status.MPI_TAG); MPI_Abort(MPI_COMM_WORLD, 0); } /* end else */ @@ -1456,47 +1358,35 @@ out: /*------------------------------------------------------------------------- * Function: diff * - * Purpose: switch between types and choose the diff function - * TYPE is either - * H5G_GROUP Object is a group - * H5G_DATASET Object is a dataset - * H5G_TYPE Object is a named data type - * H5G_LINK Object is a symbolic link - * - * Return: Number of differences found - * - * Programmer: Jonathan Kim - * - Move follow symlinks code toward top. (March 2812) - * - Add following symlinks feature (Feb 11,2010) - * - Change to use diff_args_t to pass the rest of args. - * Passing through it instead of individual args provides smoother - * extensibility through its members along with MPI code update for ph5diff - * as it doesn't require interface change. - * (May 6,2011) + * Purpose: switch between types and choose the diff function + * TYPE is either + * H5G_GROUP Object is a group + * H5G_DATASET Object is a dataset + * H5G_TYPE Object is a named data type + * H5G_LINK Object is a symbolic link * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * Date: May 9, 2003 + * Return: Number of differences found *------------------------------------------------------------------------- */ - -hsize_t diff(hid_t file1_id, +hsize_t +diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_opt_t * options, diff_args_t *argdata) { - hid_t dset1_id = (-1); - hid_t dset2_id = (-1); - hid_t type1_id = (-1); - hid_t type2_id = (-1); - hid_t grp1_id = (-1); - hid_t grp2_id = (-1); - int ret; - hbool_t is_dangle_link1 = FALSE; - hbool_t is_dangle_link2 = FALSE; - hbool_t is_hard_link = FALSE; - hsize_t nfound = 0; + int ret_value = 0; + hid_t dset1_id = -1; + hid_t dset2_id = -1; + hid_t type1_id = -1; + hid_t type2_id = -1; + hid_t grp1_id = -1; + hid_t grp2_id = -1; + hbool_t is_dangle_link1 = FALSE; + hbool_t is_dangle_link2 = FALSE; + hbool_t is_hard_link = FALSE; + hsize_t nfound = 0; h5trav_type_t object_type; /* to get link info */ @@ -1505,9 +1395,12 @@ hsize_t diff(hid_t file1_id, h5difftrace("diff start\n"); + /*init error status */ + options->err_stat = 1; + /*init link info struct */ - HDmemset(&linkinfo1,0,sizeof(h5tool_link_info_t)); - HDmemset(&linkinfo2,0,sizeof(h5tool_link_info_t)); + HDmemset(&linkinfo1, 0, sizeof(h5tool_link_info_t)); + HDmemset(&linkinfo2, 0, sizeof(h5tool_link_info_t)); /* pass how to handle printing warnings to linkinfo option */ if(print_warn(options)) @@ -1518,78 +1411,71 @@ hsize_t diff(hid_t file1_id, if (argdata->type[0] == H5TRAV_TYPE_LINK || argdata->type[0] == H5TRAV_TYPE_UDLINK || argdata->type[1] == H5TRAV_TYPE_LINK || - argdata->type[1] == H5TRAV_TYPE_UDLINK ) - { + argdata->type[1] == H5TRAV_TYPE_UDLINK) { /* * check dangling links for path1 and path2 */ /* target object1 - get type and name */ - ret = H5tools_get_symlink_info(file1_id, path1, &linkinfo1, options->follow_links); + if ((ret_value = H5tools_get_symlink_info(file1_id, path1, &linkinfo1, options->follow_links)) < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5tools_get_symlink_info failed"); + /* dangling link */ - if (ret == 0) - { - if (options->no_dangle_links) - { + if (ret_value == 0) { + if (options->no_dangle_links) { /* dangling link is error */ if(options->m_verbose) parallel_print("Warning: <%s> is a dangling link.\n", path1); - goto out; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "dangling link is error"); } else is_dangle_link1 = TRUE; } - else if (ret < 0) - goto out; /* target object2 - get type and name */ - ret = H5tools_get_symlink_info(file2_id, path2, &linkinfo2, options->follow_links ); + if ((ret_value = H5tools_get_symlink_info(file2_id, path2, &linkinfo2, options->follow_links)) < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5tools_get_symlink_info failed"); /* dangling link */ - if (ret == 0) - { - if (options->no_dangle_links) - { + if (ret_value == 0) { + if (options->no_dangle_links) { /* dangling link is error */ if(options->m_verbose) parallel_print("Warning: <%s> is a dangling link.\n", path2); - goto out; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "dangling link is error"); } else is_dangle_link2 = TRUE; } - else if (ret < 0) - goto out; /* found dangling link */ - if (is_dangle_link1 || is_dangle_link2) - goto out2; + if (is_dangle_link1 || is_dangle_link2) { + options->err_stat = 0; + HGOTO_DONE(0); + } /* follow symbolic link option */ - if (options->follow_links) - { + if (options->follow_links) { if (linkinfo1.linfo.type == H5L_TYPE_SOFT || linkinfo1.linfo.type == H5L_TYPE_EXTERNAL) argdata->type[0] = (h5trav_type_t)linkinfo1.trg_type; - if (linkinfo2.linfo.type == H5L_TYPE_SOFT || - linkinfo2.linfo.type == H5L_TYPE_EXTERNAL) + if (linkinfo2.linfo.type == H5L_TYPE_SOFT || linkinfo2.linfo.type == H5L_TYPE_EXTERNAL) argdata->type[1] = (h5trav_type_t)linkinfo2.trg_type; } } /* if objects are not the same type */ - if (argdata->type[0] != argdata->type[1]) - { - if (options->m_verbose||options->m_list_not_cmp) - { + if (argdata->type[0] != argdata->type[1]) { + if (options->m_verbose||options->m_list_not_cmp) { parallel_print("Not comparable: <%s> is of type %s and <%s> is of type %s\n", path1, get_type(argdata->type[0]), path2, get_type(argdata->type[1])); } - options->not_cmp=1; + options->not_cmp = 1; /* TODO: will need to update non-comparable is different * options->contents = 0; */ - goto out2; + options->err_stat = 0; + HGOTO_DONE(0); } else /* now both object types are same */ object_type = argdata->type[0]; @@ -1602,19 +1488,15 @@ hsize_t diff(hid_t file1_id, * * Perform this to match the outputs as bypassing. */ - if (argdata->is_same_trgobj) - { + if (argdata->is_same_trgobj) { h5difftrace("argdata->is_same_trgobj\n"); is_hard_link = (object_type == H5TRAV_TYPE_DATASET || object_type == H5TRAV_TYPE_NAMED_DATATYPE || object_type == H5TRAV_TYPE_GROUP); - if (options->follow_links || is_hard_link) - { + if (options->follow_links || is_hard_link) { /* print information is only verbose option is used */ - if(options->m_verbose || options->m_report) - { - switch(object_type) - { + if(options->m_verbose || options->m_report) { + switch(object_type) { case H5TRAV_TYPE_DATASET: do_print_objname("dataset", path1, path2, options); break; @@ -1645,46 +1527,41 @@ hsize_t diff(hid_t file1_id, } /* if(options->m_verbose || options->m_report) */ /* exact same, so comparison is done */ - goto out2; + options->err_stat = 0; + HGOTO_DONE(0); } } - switch(object_type) - { + switch(object_type) { /*---------------------------------------------------------------------- * H5TRAV_TYPE_DATASET *---------------------------------------------------------------------- */ case H5TRAV_TYPE_DATASET: if((dset1_id = H5Dopen2(file1_id, path1, H5P_DEFAULT)) < 0) - goto out; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed"); if((dset2_id = H5Dopen2(file2_id, path2, H5P_DEFAULT)) < 0) - goto out; - /* verbose (-v) and report (-r) mode */ - if(options->m_verbose || options->m_report) - { + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed"); + /* verbose (-v) and report (-r) mode */ + if(options->m_verbose || options->m_report) { do_print_objname("dataset", path1, path2, options); nfound = diff_dataset(file1_id, file2_id, path1, path2, options); print_found(nfound); } /* quiet mode (-q), just count differences */ - else if(options->m_quiet) - { + else if(options->m_quiet) { nfound = diff_dataset(file1_id, file2_id, path1, path2, options); } - /* the rest (-c, none, ...) */ - else - { + /* the rest (-c, none, ...) */ + else { nfound = diff_dataset(file1_id, file2_id, path1, path2, options); /* print info if difference found */ - if (nfound) - { + if (nfound) { do_print_objname("dataset", path1, path2, options); print_found(nfound); } } - /*--------------------------------------------------------- * compare attributes * if condition refers to cases when the dataset is a @@ -1696,9 +1573,9 @@ hsize_t diff(hid_t file1_id, if(H5Dclose(dset1_id) < 0) - goto out; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed"); if(H5Dclose(dset2_id) < 0) - goto out; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed"); break; /*---------------------------------------------------------------------- @@ -1707,15 +1584,15 @@ hsize_t diff(hid_t file1_id, */ case H5TRAV_TYPE_NAMED_DATATYPE: if((type1_id = H5Topen2(file1_id, path1, H5P_DEFAULT)) < 0) - goto out; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Topen2 failed"); if((type2_id = H5Topen2(file2_id, path2, H5P_DEFAULT)) < 0) - goto out; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Topen2 failed"); - if((ret = H5Tequal(type1_id, type2_id)) < 0) - goto out; + if((ret_value = H5Tequal(type1_id, type2_id)) < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tequal failed"); /* if H5Tequal is > 0 then the datatypes refer to the same datatype */ - nfound = (ret > 0) ? 0 : 1; + nfound = (ret_value > 0) ? 0 : 1; if(print_objname(options,nfound)) do_print_objname("datatype", path1, path2, options); @@ -1734,9 +1611,9 @@ hsize_t diff(hid_t file1_id, nfound += diff_attr(type1_id, type2_id, path1, path2, options); if(H5Tclose(type1_id) < 0) - goto out; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed"); if(H5Tclose(type2_id) < 0) - goto out; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed"); break; /*---------------------------------------------------------------------- @@ -1752,9 +1629,9 @@ hsize_t diff(hid_t file1_id, print_found(nfound); if((grp1_id = H5Gopen2(file1_id, path1, H5P_DEFAULT)) < 0) - goto out; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gclose failed"); if((grp2_id = H5Gopen2(file2_id, path2, H5P_DEFAULT)) < 0) - goto out; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gclose failed"); /*----------------------------------------------------------------- * compare attributes @@ -1766,9 +1643,9 @@ hsize_t diff(hid_t file1_id, nfound += diff_attr(grp1_id, grp2_id, path1, path2, options); if(H5Gclose(grp1_id) < 0) - goto out; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gclose failed"); if(H5Gclose(grp2_id) < 0) - goto out; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gclose failed"); break; @@ -1778,19 +1655,19 @@ hsize_t diff(hid_t file1_id, */ case H5TRAV_TYPE_LINK: { - ret = HDstrcmp(linkinfo1.trg_path, linkinfo2.trg_path); + ret_value = HDstrcmp(linkinfo1.trg_path, linkinfo2.trg_path); - /* if the target link name is not same then the links are "different" */ - nfound = (ret != 0) ? 1 : 0; + /* if the target link name is not same then the links are "different" */ + nfound = (ret_value != 0) ? 1 : 0; - if(print_objname(options, nfound)) - do_print_objname("link", path1, path2, options); + if(print_objname(options, nfound)) + do_print_objname("link", path1, path2, options); - /* always print the number of differences found in verbose mode */ - if(options->m_verbose) - print_found(nfound); + /* always print the number of differences found in verbose mode */ + if(options->m_verbose) + print_found(nfound); - } + } break; /*---------------------------------------------------------------------- @@ -1799,49 +1676,46 @@ hsize_t diff(hid_t file1_id, */ case H5TRAV_TYPE_UDLINK: { - /* Only external links will have a query function registered */ - if(linkinfo1.linfo.type == H5L_TYPE_EXTERNAL && linkinfo2.linfo.type == H5L_TYPE_EXTERNAL) - { - /* If the buffers are the same size, compare them */ - if(linkinfo1.linfo.u.val_size == linkinfo2.linfo.u.val_size) - { - ret = HDmemcmp(linkinfo1.trg_path, linkinfo2.trg_path, linkinfo1.linfo.u.val_size); - } - else - ret = 1; + /* Only external links will have a query function registered */ + if(linkinfo1.linfo.type == H5L_TYPE_EXTERNAL && linkinfo2.linfo.type == H5L_TYPE_EXTERNAL) { + /* If the buffers are the same size, compare them */ + if(linkinfo1.linfo.u.val_size == linkinfo2.linfo.u.val_size) { + ret_value = HDmemcmp(linkinfo1.trg_path, linkinfo2.trg_path, linkinfo1.linfo.u.val_size); + } + else + ret_value = 1; - /* if "linkinfo1.trg_path" != "linkinfo2.trg_path" then the links - * are "different" extlinkinfo#.path is combination string of - * file_name and obj_name - */ - nfound = (ret != 0) ? 1 : 0; + /* if "linkinfo1.trg_path" != "linkinfo2.trg_path" then the links + * are "different" extlinkinfo#.path is combination string of + * file_name and obj_name + */ + nfound = (ret_value != 0) ? 1 : 0; - if(print_objname(options, nfound)) - do_print_objname("external link", path1, path2, options); + if(print_objname(options, nfound)) + do_print_objname("external link", path1, path2, options); - } /* end if */ - else - { - /* If one or both of these links isn't an external link, we can only - * compare information from H5Lget_info since we don't have a query - * function registered for them. - * - * If the link classes or the buffer length are not the - * same, the links are "different" - */ - if((linkinfo1.linfo.type != linkinfo2.linfo.type) || - (linkinfo1.linfo.u.val_size != linkinfo2.linfo.u.val_size)) - nfound = 1; - else - nfound = 0; - - if (print_objname (options, nfound)) - do_print_objname ("user defined link", path1, path2, options); - } /* end else */ + } /* end if */ + else { + /* If one or both of these links isn't an external link, we can only + * compare information from H5Lget_info since we don't have a query + * function registered for them. + * + * If the link classes or the buffer length are not the + * same, the links are "different" + */ + if((linkinfo1.linfo.type != linkinfo2.linfo.type) || + (linkinfo1.linfo.u.val_size != linkinfo2.linfo.u.val_size)) + nfound = 1; + else + nfound = 0; - /* always print the number of differences found in verbose mode */ - if(options->m_verbose) - print_found(nfound); + if (print_objname (options, nfound)) + do_print_objname ("user defined link", path1, path2, options); + } /* end else */ + + /* always print the number of differences found in verbose mode */ + if(options->m_verbose) + print_found(nfound); } break; @@ -1854,33 +1728,21 @@ hsize_t diff(hid_t file1_id, break; } - /* free link info buffer */ - if (linkinfo1.trg_path) - HDfree(linkinfo1.trg_path); - if (linkinfo2.trg_path) - HDfree(linkinfo2.trg_path); - - return nfound; - -out: - options->err_stat = 1; + options->err_stat = 0; -out2: +done: /*----------------------------------- * handle dangling link(s) */ /* both path1 and path2 are dangling links */ - if(is_dangle_link1 && is_dangle_link2) - { - if(print_objname(options, nfound)) - { + if(is_dangle_link1 && is_dangle_link2) { + if(print_objname(options, nfound)) { do_print_objname("dangling link", path1, path2, options); print_found(nfound); } } /* path1 is dangling link */ - else if (is_dangle_link1) - { + else if (is_dangle_link1) { if(options->m_verbose) parallel_print("obj1 <%s> is a dangling link.\n", path1); nfound++; @@ -1888,8 +1750,7 @@ out2: print_found(nfound); } /* path2 is dangling link */ - else if (is_dangle_link2) - { + else if (is_dangle_link2) { if(options->m_verbose) parallel_print("obj2 <%s> is a dangling link.\n", path2); nfound++; @@ -1906,12 +1767,15 @@ out2: /* close */ /* disable error reporting */ H5E_BEGIN_TRY { + H5Dclose(dset1_id); + H5Dclose(dset2_id); H5Tclose(type1_id); H5Tclose(type2_id); H5Gclose(grp1_id); - H5Tclose(grp2_id); + H5Gclose(grp2_id); /* enable error reporting */ } H5E_END_TRY; + h5difftrace("diff finish\n"); return nfound; diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c index 09894e6..58a5e09 100644 --- a/tools/lib/h5diff_array.c +++ b/tools/lib/h5diff_array.c @@ -256,11 +256,6 @@ static void close_member_types(mcomp_t *members); * Purpose: compare two memory buffers; * * Return: number of differences found - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: November 12, 2003 - * *------------------------------------------------------------------------- */ @@ -378,10 +373,8 @@ hsize_t diff_array( for (i = 0; i < nelmts; i++) { nfound += diff_datum(mem1 + i * size, mem2 + i * size, m_type, i, rank, dims, acc, pos, options, name1, name2, container1_id, container2_id, &ph, &members); - if (options->n && nfound >= options->count) { - close_member_types(&members); - return nfound; - } + if (options->n && nfound >= options->count) + break; } /* i */ close_member_types(&members); } /* switch */ @@ -397,10 +390,6 @@ hsize_t diff_array( * * Return: number of differences found * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: October 29, 2003 - * * The comparison of the 2 buffers read from the files is made datum by datum. * * H5T_INTEGER and H5T_FLOAT @@ -441,13 +430,12 @@ static hsize_t diff_datum( const char *obj2, hid_t container1_id, hid_t container2_id, /*where the reference came from*/ - int *ph, /*print header */ - mcomp_t *members) /*compound members */ + int *ph, /*print header */ + mcomp_t *members) /*compound members */ { unsigned char *mem1 = (unsigned char*) _mem1; unsigned char *mem2 = (unsigned char*) _mem2; size_t u; - hid_t memb_type; size_t type_size; H5T_sign_t type_sign; H5T_class_t type_class; @@ -458,10 +446,8 @@ static hsize_t diff_datum( size_t size = 0; hbool_t iszero1; hbool_t iszero2; - hid_t obj1_id; - hid_t obj2_id; - hsize_t nfound = 0; /* differences found */ - int ret = 0; /* check return error */ + hsize_t nfound = 0; /* differences found */ + hsize_t ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ double per; hbool_t both_zero; @@ -478,14 +464,14 @@ static hsize_t diff_datum( type_class != H5T_STRING && type_class != H5T_VLEN && HDmemcmp(mem1, mem2, type_size) == 0) - return 0; + HGOTO_DONE(0); switch (H5Tget_class(m_type)) { case H5T_NO_CLASS: case H5T_TIME: case H5T_NCLASSES: default: - HDassert(0); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Invalid type class"); break; /*------------------------------------------------------------------------- @@ -494,15 +480,17 @@ static hsize_t diff_datum( */ case H5T_COMPOUND: h5difftrace("diff_datum H5T_COMPOUND\n"); + { + hid_t memb_type = -1; + nmembs = members->n; - nmembs = members->n; - - for (j = 0; j < nmembs; j++) { - offset = members->offsets[j]; - memb_type = members->ids[j]; + for (j = 0; j < nmembs; j++) { + offset = members->offsets[j]; + memb_type = members->ids[j]; - nfound += diff_datum(mem1 + offset, mem2 + offset, memb_type, index, - rank, dims, acc, pos, options, obj1, obj2, container1_id, container2_id, ph, members->m[j]); + nfound += diff_datum(mem1 + offset, mem2 + offset, memb_type, index, + rank, dims, acc, pos, options, obj1, obj2, container1_id, container2_id, ph, members->m[j]); + } } break; @@ -532,6 +520,7 @@ static hsize_t diff_datum( size1 = HDstrlen(s1); else size1 = 0; + /* Get pointer to second string */ s2 = *(char**) mem2; if (s2) @@ -547,14 +536,17 @@ static hsize_t diff_datum( size1 = HDstrlen(s1); else size1 = 0; + if (size1 > size_mtype) size1 = size_mtype; + /* Get pointer to second string */ s2 = (char*) mem2; if (s2) size2 = HDstrlen(s2); else size2 = 0; + if (size2 > size_mtype) size2 = size_mtype; } @@ -562,6 +554,7 @@ static hsize_t diff_datum( /* Get pointer to first string */ s1 = (char *) mem1; size1 = size_mtype; + /* Get pointer to second string */ s2 = (char *) mem2; size2 = size_mtype; @@ -573,8 +566,8 @@ static hsize_t diff_datum( * of length of strings. * For now mimic the previous way. */ - h5diffdebug2("diff_datum string size:%d\n",size1); - h5diffdebug2("diff_datum string size:%d\n",size2); + h5diffdebug2("diff_datum string size:%d\n", size1); + h5diffdebug2("diff_datum string size:%d\n", size2); if (size1 != size2) { h5difftrace("diff_datum string sizes\n"); nfound++; @@ -595,15 +588,15 @@ static hsize_t diff_datum( /* check for NULL pointer for string */ if (s != NULL) { /* try fast compare first */ - if (HDmemcmp(s1, s2, size) == 0) { + if (HDmemcmp(s, sx, size) == 0) { if (size1 != size2) if (print_data(options)) for (u = size; u < sizex; u++) - character_compare(s1 + u, s2 + u, index, u, rank, dims, acc, pos, options, obj1, obj2, ph); + character_compare(s + u, sx + u, index, u, rank, dims, acc, pos, options, obj1, obj2, ph); } else for (u = 0; u < size; u++) - nfound += character_compare(s1 + u, s2 + u, index, u, rank, dims, acc, pos, options, obj1, obj2, ph); + nfound += character_compare(s + u, sx + u, index, u, rank, dims, acc, pos, options, obj1, obj2, ph); } /* end check for NULL pointer for string */ } break; @@ -699,8 +692,9 @@ static hsize_t diff_datum( */ case H5T_ARRAY: { + hid_t memb_type = -1; hsize_t adims[H5S_MAX_RANK]; - int ndims; + int ndims; /* get the array's base datatype for each element */ memb_type = H5Tget_super(m_type); @@ -728,7 +722,7 @@ static hsize_t diff_datum( iszero1 = all_zero(_mem1, H5Tget_size(m_type)); iszero2 = all_zero(_mem2, H5Tget_size(m_type)); if (iszero1 != iszero2) { - return 1; + HGOTO_DONE (1); } else if (!iszero1 && !iszero2) { /*------------------------------------------------------------------------- @@ -736,29 +730,34 @@ static hsize_t diff_datum( * Dataset region reference *------------------------------------------------------------------------- */ + hid_t obj1_id = -1; + hid_t obj2_id = -1; + if (type_size == H5R_DSET_REG_REF_BUF_SIZE) { - hid_t region1_id; - hid_t region2_id; + hid_t region1_id = -1; + hid_t region2_id = -1; if ((obj1_id = H5Rdereference2(container1_id, H5P_DEFAULT, H5R_DATASET_REGION, _mem1)) < 0) - ret = -1; + HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rdereference2 object 1 failed"); if ((obj2_id = H5Rdereference2(container2_id, H5P_DEFAULT, H5R_DATASET_REGION, _mem2)) < 0) - ret = -1; + HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rdereference2 object 2 failed"); if ((region1_id = H5Rget_region(container1_id, H5R_DATASET_REGION, _mem1)) < 0) - ret = -1; + HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rget_region object 1 failed"); if ((region2_id = H5Rget_region(container2_id, H5R_DATASET_REGION, _mem2)) < 0) - ret = -1; + HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rget_region object 2 failed"); - if (ret == -1) { - options->err_stat = 1; - return 0; - } + if (ret_value >= 0) + nfound = diff_region(obj1_id, obj2_id, region1_id, region2_id, options); - nfound = diff_region(obj1_id, obj2_id, region1_id, region2_id, options); H5Oclose(obj1_id); H5Oclose(obj2_id); H5Sclose(region1_id); H5Sclose(region2_id); + + if (ret_value == -1) { + options->err_stat = 1; + HGOTO_DONE(0); + } }/*dataset reference*/ /*------------------------------------------------------------------------- @@ -771,44 +770,43 @@ static hsize_t diff_datum( H5O_type_t obj2_type; if (H5Rget_obj_type2(container1_id, H5R_OBJECT, _mem1, &obj1_type) < 0) - ret = -1; + HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rget_obj_type2 object 1 failed"); if (H5Rget_obj_type2(container2_id, H5R_OBJECT, _mem2, &obj2_type) < 0) - ret = -1; - if (ret == -1) { - options->err_stat = 1; - return 0; - } /* end if */ + HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rget_obj_type2 object 2 failed"); /* check object type */ - if (obj1_type != obj2_type) { - parallel_print( - "Different object types referenced: <%s> and <%s>", obj1, obj2); - options->not_cmp = 1; - return 0; - } + if (ret_value >= 0) + if (obj1_type != obj2_type) { + parallel_print("Different object types referenced: <%s> and <%s>", obj1, obj2); + options->not_cmp = 1; + HGOTO_DONE (0); + } if ((obj1_id = H5Rdereference2(container1_id, H5P_DEFAULT, H5R_OBJECT, _mem1)) < 0) - ret = -1; + HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rdereference2 object 1 failed"); if ((obj2_id = H5Rdereference2(container2_id, H5P_DEFAULT, H5R_OBJECT, _mem2)) < 0) - ret = -1; - if (ret == -1) { - options->err_stat = 1; - return 0; - } + HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rdereference2 object 2 failed"); /* compare */ - if (obj1_type == H5O_TYPE_DATASET) - nfound = diff_datasetid(obj1_id, obj2_id, NULL, NULL, options); - else { - if (options->m_verbose) - parallel_print( - "Warning: Comparison not possible of object types referenced: <%s> and <%s>\n", - obj1, obj2); - options->not_cmp = 1; + if (ret_value >= 0) { + if (obj1_type == H5O_TYPE_DATASET) + nfound = diff_datasetid(obj1_id, obj2_id, NULL, NULL, options); + else { + if (options->m_verbose) + parallel_print( + "Warning: Comparison not possible of object types referenced: <%s> and <%s>\n", + obj1, obj2); + options->not_cmp = 1; + } } H5Oclose(obj1_id); H5Oclose(obj2_id); + + if (ret_value == -1) { + options->err_stat = 1; + HGOTO_DONE(0); + } }/*object reference*/ }/*is zero*/ break; @@ -818,18 +816,22 @@ static hsize_t diff_datum( *------------------------------------------------------------------------- */ case H5T_VLEN: - /* get the VL sequences's base datatype for each element */ - memb_type = H5Tget_super(m_type); - size = H5Tget_size(memb_type); + { + hid_t memb_type = -1; + + /* get the VL sequences's base datatype for each element */ + memb_type = H5Tget_super(m_type); + size = H5Tget_size(memb_type); - /* get the number of sequence elements */ - nelmts = ((hvl_t *) mem1)->len; + /* get the number of sequence elements */ + nelmts = ((hvl_t *) mem1)->len; - for (j = 0; j < nelmts; j++) - nfound += diff_datum(((char *) (((hvl_t *) mem1)->p)) + j * size, ((char *) (((hvl_t *) mem2)->p)) + j * size, memb_type, index, - rank, dims, acc, pos, options, obj1, obj2, container1_id, container2_id, ph, members); + for (j = 0; j < nelmts; j++) + nfound += diff_datum(((char *) (((hvl_t *) mem1)->p)) + j * size, ((char *) (((hvl_t *) mem2)->p)) + j * size, memb_type, index, + rank, dims, acc, pos, options, obj1, obj2, container1_id, container2_id, ph, members); - H5Tclose(memb_type); + H5Tclose(memb_type); + } break; /*------------------------------------------------------------------------- @@ -845,7 +847,9 @@ static hsize_t diff_datum( if (type_size == 1 && type_sign != H5T_SGN_NONE) { char temp1_char; char temp2_char; - HDassert(type_size == sizeof(char)); + + if(type_size != sizeof(char)) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Type size is not char size"); HDmemcpy(&temp1_char, mem1, sizeof(char)); HDmemcpy(&temp2_char, mem2, sizeof(char)); /* -d and !-p */ @@ -918,7 +922,9 @@ static hsize_t diff_datum( else if (type_size == 1 && type_sign == H5T_SGN_NONE) { unsigned char temp1_uchar; unsigned char temp2_uchar; - HDassert(type_size == sizeof(unsigned char)); + + if(type_size != sizeof(unsigned char)) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Type size is not unsigned char size"); HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char)); HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char)); @@ -992,7 +998,9 @@ static hsize_t diff_datum( else if (type_size == 2 && type_sign != H5T_SGN_NONE) { short temp1_short; short temp2_short; - HDassert(type_size == sizeof(short)); + + if(type_size != sizeof(short)) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Type size is not short size"); HDmemcpy(&temp1_short, mem1, sizeof(short)); HDmemcpy(&temp2_short, mem2, sizeof(short)); @@ -1066,7 +1074,9 @@ static hsize_t diff_datum( else if (type_size == 2 && type_sign == H5T_SGN_NONE) { unsigned short temp1_ushort; unsigned short temp2_ushort; - HDassert(type_size == sizeof(short)); + + if(type_size != sizeof(unsigned short)) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Type size is not unsigned short size"); HDmemcpy(&temp1_ushort, mem1, sizeof(unsigned short)); HDmemcpy(&temp2_ushort, mem2, sizeof(unsigned short)); @@ -1140,7 +1150,9 @@ static hsize_t diff_datum( else if (type_size == 4 && type_sign != H5T_SGN_NONE) { int temp1_int; int temp2_int; - HDassert(type_size == sizeof(int)); + + if(type_size != sizeof(int)) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Type size is not int size"); HDmemcpy(&temp1_int, mem1, sizeof(int)); HDmemcpy(&temp2_int, mem2, sizeof(int)); @@ -1214,7 +1226,9 @@ static hsize_t diff_datum( else if (type_size == 4 && type_sign == H5T_SGN_NONE) { unsigned int temp1_uint; unsigned int temp2_uint; - HDassert(type_size == sizeof(int)); + + if(type_size != sizeof(unsigned int)) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Type size is not unsigned int size"); HDmemcpy(&temp1_uint, mem1, sizeof(unsigned int)); HDmemcpy(&temp2_uint, mem2, sizeof(unsigned int)); @@ -1288,7 +1302,9 @@ static hsize_t diff_datum( else if (type_size == 8 && type_sign != H5T_SGN_NONE) { long temp1_long; long temp2_long; - HDassert(type_size == sizeof(long)); + + if(type_size != sizeof(long)) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Type size is not long size"); HDmemcpy(&temp1_long, mem1, sizeof(long)); HDmemcpy(&temp2_long, mem2, sizeof(long)); @@ -1362,7 +1378,9 @@ static hsize_t diff_datum( else if (type_size == 8 && type_sign == H5T_SGN_NONE) { unsigned long temp1_ulong; unsigned long temp2_ulong; - HDassert(type_size == sizeof(unsigned long)); + + if(type_size != sizeof(unsigned long)) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Type size is not unsigned long size"); HDmemcpy(&temp1_ulong, mem1, sizeof(unsigned long)); HDmemcpy(&temp2_ulong, mem2, sizeof(unsigned long)); @@ -1445,7 +1463,8 @@ static hsize_t diff_datum( hbool_t isnan1 = FALSE; hbool_t isnan2 = FALSE; - HDassert(type_size == sizeof(float)); + if(type_size != sizeof(float)) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Type size is not float size"); HDmemcpy(&temp1_float, mem1, sizeof(float)); HDmemcpy(&temp2_float, mem2, sizeof(float)); @@ -1603,7 +1622,8 @@ static hsize_t diff_datum( hbool_t isnan1 = FALSE; hbool_t isnan2 = FALSE; - HDassert(type_size == sizeof(double)); + if(type_size != sizeof(double)) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Type size is not double size"); HDmemcpy(&temp1_double, mem1, sizeof(double)); HDmemcpy(&temp2_double, mem2, sizeof(double)); @@ -1761,7 +1781,8 @@ static hsize_t diff_datum( hbool_t isnan1 = FALSE; hbool_t isnan2 = FALSE; - HDassert(type_size == sizeof(long double)); + if(type_size != sizeof(long double)) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Type size is not long double size"); HDmemcpy(&temp1_double, mem1, sizeof(long double)); HDmemcpy(&temp2_double, mem2, sizeof(long double)); @@ -1852,7 +1873,7 @@ static hsize_t diff_datum( * -d and -p *------------------------------------------------------------------------- */ - else if ( options->d && options->p) { + else if (options->d && options->p) { /*------------------------------------------------------------------------- * detect NaNs *------------------------------------------------------------------------- @@ -1863,7 +1884,7 @@ static hsize_t diff_datum( } /* both not NaN, do the comparison */ - if ( !isnan1 && !isnan2) { + if (!isnan1 && !isnan2) { PER(temp1_double,temp2_double); if (not_comparable && !both_zero) { @@ -1911,6 +1932,8 @@ static hsize_t diff_datum( break; /* H5T_FLOAT class */ } /* switch */ + +done: h5difftrace("diff_datum finish\n"); return nfound; @@ -1922,7 +1945,6 @@ static hsize_t diff_datum( * Purpose: Determines if memory is initialized to all zero bytes. * * Return: TRUE if all bytes are zero; FALSE otherwise - * *------------------------------------------------------------------------- */ @@ -1942,7 +1964,6 @@ static hbool_t all_zero(const void *_mem, size_t size) { * Purpose: print start coordinates and opposite corner of a region block * * Return: void - * *------------------------------------------------------------------------- */ @@ -1965,7 +1986,6 @@ void print_region_block(int i, hsize_t *ptdata, int ndims) { * Purpose: print points of a region reference * * Return: void - * *------------------------------------------------------------------------- */ @@ -1986,18 +2006,18 @@ void print_points(int i, hsize_t *ptdata, int ndims) { * Purpose: diff a dataspace region * * Return: number of differences - * *------------------------------------------------------------------------- */ static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t region2_id, diff_opt_t *options) { + hsize_t ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ hssize_t nblocks1, npoints1; hssize_t nblocks2, npoints2; hsize_t alloc_size; - hsize_t *ptdata1; - hsize_t *ptdata2; + hsize_t *ptdata1 = NULL; + hsize_t *ptdata2 = NULL; int ndims1; int ndims2; int i, j; @@ -2012,18 +2032,17 @@ static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t * respectively. They do not currently know how to translate from one to * the other. */ - H5E_BEGIN_TRY - { - nblocks1 = H5Sget_select_hyper_nblocks(region1_id); - nblocks2 = H5Sget_select_hyper_nblocks(region2_id); + H5E_BEGIN_TRY { + nblocks1 = H5Sget_select_hyper_nblocks(region1_id); + nblocks2 = H5Sget_select_hyper_nblocks(region2_id); - npoints1 = H5Sget_select_elem_npoints(region1_id); - npoints2 = H5Sget_select_elem_npoints(region2_id); - }H5E_END_TRY; + npoints1 = H5Sget_select_elem_npoints(region1_id); + npoints2 = H5Sget_select_elem_npoints(region2_id); + } H5E_END_TRY; if (nblocks1 != nblocks2 || npoints1 != npoints2 || ndims1 != ndims2) { options->not_cmp = 1; - return 0; + HGOTO_DONE (0); } /*------------------------------------------------------------------------- @@ -2032,57 +2051,60 @@ static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t */ if (nblocks1 > 0) { HDassert(ndims1 > 0); - alloc_size = (hsize_t) nblocks1 * (unsigned) ndims1 * 2 - * sizeof(ptdata1[0]); + alloc_size = (hsize_t) nblocks1 * (unsigned) ndims1 * 2 * sizeof(ptdata1[0]); HDassert(alloc_size == (hsize_t)((size_t )alloc_size)); /*check for overflow*/ - ptdata1 = (hsize_t *) HDmalloc((size_t )alloc_size); - H5_CHECK_OVERFLOW(nblocks1, hssize_t, hsize_t); - H5Sget_select_hyper_blocklist(region1_id, (hsize_t) 0, - (hsize_t) nblocks1, ptdata1); - - ptdata2 = (hsize_t *) HDmalloc((size_t )alloc_size); - H5_CHECK_OVERFLOW(nblocks2, hssize_t, hsize_t); - H5Sget_select_hyper_blocklist(region2_id, (hsize_t) 0, - (hsize_t) nblocks2, ptdata2); - - for (i = 0; i < nblocks1; i++) { - /* start coordinates and opposite corner */ - for (j = 0; j < ndims1; j++) { - hsize_t start1, start2, end1, end2; + if((ptdata1 = (hsize_t *) HDmalloc((size_t )alloc_size)) == NULL) { + HERROR(H5E_tools_g, H5E_tools_min_id_g, "Buffer allocation failed"); + } + else { + H5_CHECK_OVERFLOW(nblocks1, hssize_t, hsize_t); + H5Sget_select_hyper_blocklist(region1_id, (hsize_t) 0, (hsize_t) nblocks1, ptdata1); - start1 = ptdata1[i * 2 * ndims1 + j]; - start2 = ptdata2[i * 2 * ndims1 + j]; - end1 = ptdata1[i * 2 * ndims1 + j + ndims1]; - end2 = ptdata2[i * 2 * ndims1 + j + ndims1]; - if (start1 != start2 || end1 != end2) - nfound_b++; + if((ptdata2 = (hsize_t *) HDmalloc((size_t )alloc_size)) == NULL) { + HERROR(H5E_tools_g, H5E_tools_min_id_g, "Buffer allocation failed"); } - } + else { + H5_CHECK_OVERFLOW(nblocks2, hssize_t, hsize_t); + H5Sget_select_hyper_blocklist(region2_id, (hsize_t) 0, (hsize_t) nblocks2, ptdata2); + + for (i = 0; i < nblocks1; i++) { + /* start coordinates and opposite corner */ + for (j = 0; j < ndims1; j++) { + hsize_t start1, start2, end1, end2; + + start1 = ptdata1[i * 2 * ndims1 + j]; + start2 = ptdata2[i * 2 * ndims1 + j]; + end1 = ptdata1[i * 2 * ndims1 + j + ndims1]; + end2 = ptdata2[i * 2 * ndims1 + j + ndims1]; + if (start1 != start2 || end1 != end2) + nfound_b++; + } + } - /* print differences if found */ - if (nfound_b && options->m_verbose) { - H5O_info_t oi1, oi2; + /* print differences if found */ + if (nfound_b && options->m_verbose) { + H5O_info_t oi1, oi2; - H5Oget_info(obj1_id, &oi1); - H5Oget_info(obj2_id, &oi2); + H5Oget_info(obj1_id, &oi1); + H5Oget_info(obj2_id, &oi2); - parallel_print("Referenced dataset %lu %lu\n", - (unsigned long) oi1.addr, (unsigned long) oi2.addr); - parallel_print( - "------------------------------------------------------------\n"); + parallel_print("Referenced dataset %lu %lu\n", (unsigned long) oi1.addr, (unsigned long) oi2.addr); + parallel_print( "------------------------------------------------------------\n"); - parallel_print("Region blocks\n"); - for (i = 0; i < nblocks1; i++) { - parallel_print("block #%d", i); - print_region_block(i, ptdata1, ndims1); - print_region_block(i, ptdata2, ndims1); - parallel_print("\n"); - } - } + parallel_print("Region blocks\n"); + for (i = 0; i < nblocks1; i++) { + parallel_print("block #%d", i); + print_region_block(i, ptdata1, ndims1); + print_region_block(i, ptdata2, ndims1); + parallel_print("\n"); + } + } + HDfree(ptdata2); + } /* else ptdata2 */ - HDfree(ptdata1); - HDfree(ptdata2); + HDfree(ptdata1); + } /* else ptdata1 */ } /*------------------------------------------------------------------------- @@ -2090,95 +2112,104 @@ static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t *------------------------------------------------------------------------- */ if (npoints1 > 0) { - alloc_size = (hsize_t) npoints1 * (unsigned) ndims1 - * sizeof(ptdata1[0]); + alloc_size = (hsize_t) npoints1 * (unsigned) ndims1 * sizeof(ptdata1[0]); HDassert(alloc_size == (hsize_t)((size_t )alloc_size)); /*check for overflow*/ - ptdata1 = (hsize_t *) HDmalloc((size_t )alloc_size); - H5_CHECK_OVERFLOW(npoints1, hssize_t, hsize_t); - H5Sget_select_elem_pointlist(region1_id, (hsize_t) 0, - (hsize_t) npoints1, ptdata1); - - ptdata2 = (hsize_t *) HDmalloc((size_t )alloc_size); - H5_CHECK_OVERFLOW(npoints1, hssize_t, hsize_t); - H5Sget_select_elem_pointlist(region2_id, (hsize_t) 0, - (hsize_t) npoints2, ptdata2); - - for (i = 0; i < npoints1; i++) { - hsize_t pt1, pt2; + if((ptdata1 = (hsize_t *) HDmalloc((size_t )alloc_size)) == NULL) { + HERROR(H5E_tools_g, H5E_tools_min_id_g, "Buffer allocation failed"); + } + else { + H5_CHECK_OVERFLOW(npoints1, hssize_t, hsize_t); + H5Sget_select_elem_pointlist(region1_id, (hsize_t) 0, (hsize_t) npoints1, ptdata1); - for (j = 0; j < ndims1; j++) { - pt1 = ptdata1[i * ndims1 + j]; - pt2 = ptdata2[i * ndims1 + j]; - if (pt1 != pt2) - nfound_p++; + if((ptdata2 = (hsize_t *) HDmalloc((size_t )alloc_size)) == NULL) { + HERROR(H5E_tools_g, H5E_tools_min_id_g, "Buffer allocation failed"); } - } + else { + H5_CHECK_OVERFLOW(npoints1, hssize_t, hsize_t); + H5Sget_select_elem_pointlist(region2_id, (hsize_t) 0, (hsize_t) npoints2, ptdata2); - if (nfound_p && options->m_verbose) { - parallel_print("Region points\n"); - for (i = 0; i < npoints1; i++) { - hsize_t pt1, pt2; - int diff_data = 0; - - for (j = 0; j < ndims1; j++) { - pt1 = ptdata1[i * ndims1 + j]; - pt2 = ptdata2[i * ndims1 + j]; - if (pt1 != pt2) { - diff_data = 1; - break; + for (i = 0; i < npoints1; i++) { + hsize_t pt1, pt2; + + for (j = 0; j < ndims1; j++) { + pt1 = ptdata1[i * ndims1 + j]; + pt2 = ptdata2[i * ndims1 + j]; + if (pt1 != pt2) + nfound_p++; } } - if (diff_data) { - parallel_print("point #%d", i); - print_points(i, ptdata1, ndims1); - print_points(i, ptdata2, ndims1); - parallel_print("\n"); + + if (nfound_p && options->m_verbose) { + parallel_print("Region points\n"); + for (i = 0; i < npoints1; i++) { + hsize_t pt1, pt2; + int diff_data = 0; + + for (j = 0; j < ndims1; j++) { + pt1 = ptdata1[i * ndims1 + j]; + pt2 = ptdata2[i * ndims1 + j]; + if (pt1 != pt2) { + diff_data = 1; + break; + } + } + if (diff_data) { + parallel_print("point #%d", i); + print_points(i, ptdata1, ndims1); + print_points(i, ptdata2, ndims1); + parallel_print("\n"); + } + } } - } - } + HDfree(ptdata2); + } /* else ptdata2 */ #if defined (H5DIFF_DEBUG) - for (i = 0; i < npoints1; i++) { - int j; + for (i = 0; i < npoints1; i++) { + int j; - parallel_print("%sPt%lu: " , i ? "," : "", (unsigned long)i); + parallel_print("%sPt%lu: " , i ? "," : "", (unsigned long)i); - for (j = 0; j < ndims1; j++) - parallel_print("%s%lu", j ? "," : "(", - (unsigned long)(ptdata1[i * ndims1 + j])); + for (j = 0; j < ndims1; j++) + parallel_print("%s%lu", j ? "," : "(", (unsigned long)(ptdata1[i * ndims1 + j])); - parallel_print(")"); - } + parallel_print(")"); + } #endif - HDfree(ptdata1); - HDfree(ptdata2); + HDfree(ptdata1); + } /* else ptdata1 */ } nfound_b = nfound_b / (unsigned) ndims1; nfound_p = nfound_p / (unsigned) ndims1; - return (nfound_p + nfound_b); + + ret_value = nfound_p + nfound_b; + +done: + return ret_value; } /*------------------------------------------------------------------------- * Function: character_compare * - * Purpose: do a byte-by-byte comparison and print in char format - * - * Return: number of differences found + * Purpose: do a byte-by-byte comparison and print in char format * + * Return: number of differences found *------------------------------------------------------------------------- */ static hsize_t character_compare(char *mem1, char *mem2, hsize_t i, size_t u, - int rank, hsize_t *dims, hsize_t *acc, hsize_t *pos, diff_opt_t *options, const char *obj1, const char *obj2, int *ph) { + int rank, hsize_t *dims, hsize_t *acc, hsize_t *pos, diff_opt_t *options, const char *obj1, const char *obj2, int *ph) +{ hsize_t nfound = 0; /* differences found */ char temp1_uchar; char temp2_uchar; HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char)); - HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char)); h5diffdebug3("character_compare start %d=%d\n",temp1_uchar,temp2_uchar); + HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char)); + h5diffdebug3("character_compare start %d=%d\n",temp1_uchar,temp2_uchar); if (temp1_uchar != temp2_uchar) { if (print_data(options)) { @@ -2199,20 +2230,20 @@ static hsize_t character_compare(char *mem1, char *mem2, hsize_t i, size_t u, /*------------------------------------------------------------------------- * Function: character_compare_opt * - * Purpose: do a byte-by-byte comparison and print in numerical format - * - * Return: number of differences found + * Purpose: do a byte-by-byte comparison and print in numerical format * + * Return: number of differences found *------------------------------------------------------------------------- */ static hsize_t character_compare_opt(unsigned char *mem1, unsigned char *mem2, - hsize_t i, int rank, hsize_t *dims, hsize_t *acc, hsize_t *pos, diff_opt_t *options, const char *obj1, const char *obj2, int *ph) { - hsize_t nfound = 0; /* differences found */ + hsize_t i, int rank, hsize_t *dims, hsize_t *acc, hsize_t *pos, diff_opt_t *options, const char *obj1, const char *obj2, int *ph) +{ + hsize_t nfound = 0; /* differences found */ unsigned char temp1_uchar; unsigned char temp2_uchar; - double per; - hbool_t both_zero; + double per; + hbool_t both_zero; HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char)); HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char)); @@ -2269,10 +2300,10 @@ static hsize_t character_compare_opt(unsigned char *mem1, unsigned char *mem2, /*------------------------------------------------------------------------- * Function: diff_float * - * Purpose: diff a H5T_NATIVE_FLOAT type - * - * Return: number of differences found + * Purpose: diff a H5T_NATIVE_FLOAT type * + * Return: number of differences found +* *------------------------------------------------------------------------- */ static hsize_t diff_float(unsigned char *mem1, unsigned char *mem2, @@ -2482,10 +2513,9 @@ static hsize_t diff_float(unsigned char *mem1, unsigned char *mem2, /*------------------------------------------------------------------------- * Function: diff_double * - * Purpose: diff a H5T_NATIVE_DOUBLE type - * - * Return: number of differences found + * Purpose: diff a H5T_NATIVE_DOUBLE type * + * Return: number of differences found *------------------------------------------------------------------------- */ static hsize_t diff_double(unsigned char *mem1, unsigned char *mem2, @@ -2495,10 +2525,10 @@ static hsize_t diff_double(unsigned char *mem1, unsigned char *mem2, { hsize_t nfound = 0; /* number of differences found */ - double temp1_double; - double temp2_double; + double temp1_double; + double temp2_double; hsize_t i; - double per; + double per; hbool_t both_zero; hbool_t isnan1 = FALSE; hbool_t isnan2 = FALSE; @@ -2694,10 +2724,9 @@ static hsize_t diff_double(unsigned char *mem1, unsigned char *mem2, /*------------------------------------------------------------------------- * Function: diff_ldouble * - * Purpose: diff a H5T_NATIVE_LDOUBLE type - * - * Return: number of differences found + * Purpose: diff a H5T_NATIVE_LDOUBLE type * + * Return: number of differences found *------------------------------------------------------------------------- */ #if H5_SIZEOF_LONG_DOUBLE !=0 @@ -2716,7 +2745,7 @@ static hsize_t diff_ldouble(unsigned char *mem1, int *ph) { - hsize_t nfound=0; /* number of differences found */ + hsize_t nfound = 0; /* number of differences found */ long double temp1_double; long double temp2_double; hsize_t i; @@ -2914,10 +2943,9 @@ static hsize_t diff_ldouble(unsigned char *mem1, /*------------------------------------------------------------------------- * Function: diff_schar * - * Purpose: diff a H5T_NATIVE_SCHAR type - * - * Return: number of differences found + * Purpose: diff a H5T_NATIVE_SCHAR type * + * Return: number of differences found *------------------------------------------------------------------------- */ static hsize_t diff_schar(unsigned char *mem1, unsigned char *mem2, @@ -2927,10 +2955,10 @@ static hsize_t diff_schar(unsigned char *mem1, unsigned char *mem2, { hsize_t nfound = 0; /* number of differences found */ - char temp1_char; - char temp2_char; + char temp1_char; + char temp2_char; hsize_t i; - double per; + double per; hbool_t both_zero; h5difftrace("diff_schar start\n"); @@ -3042,10 +3070,9 @@ static hsize_t diff_schar(unsigned char *mem1, unsigned char *mem2, /*------------------------------------------------------------------------- * Function: diff_uchar * - * Purpose: diff a H5T_NATIVE_UCHAR type - * - * Return: number of differences found + * Purpose: diff a H5T_NATIVE_UCHAR type * + * Return: number of differences found *------------------------------------------------------------------------- */ static hsize_t diff_uchar(unsigned char *mem1, unsigned char *mem2, @@ -3053,12 +3080,12 @@ static hsize_t diff_uchar(unsigned char *mem1, unsigned char *mem2, hsize_t *acc, hsize_t *pos, diff_opt_t *options, const char *obj1, const char *obj2, int *ph) { - hsize_t nfound = 0; /* number of differences found */ + hsize_t nfound = 0; /* number of differences found */ unsigned char temp1_uchar; unsigned char temp2_uchar; - hsize_t i; - double per; - hbool_t both_zero; + hsize_t i; + double per; + hbool_t both_zero; h5difftrace("diff_uchar start\n"); /* -d and !-p */ @@ -3169,10 +3196,9 @@ static hsize_t diff_uchar(unsigned char *mem1, unsigned char *mem2, /*------------------------------------------------------------------------- * Function: diff_short * - * Purpose: diff a H5T_NATIVE_SHORT type - * - * Return: number of differences found + * Purpose: diff a H5T_NATIVE_SHORT type * + * Return: number of differences found *------------------------------------------------------------------------- */ static hsize_t diff_short(unsigned char *mem1, unsigned char *mem2, @@ -3181,10 +3207,10 @@ static hsize_t diff_short(unsigned char *mem1, unsigned char *mem2, const char *obj2, int *ph) { hsize_t nfound = 0; /* number of differences found */ - short temp1_short; - short temp2_short; + short temp1_short; + short temp2_short; hsize_t i; - double per; + double per; hbool_t both_zero; h5difftrace("diff_short start\n"); @@ -3296,10 +3322,9 @@ static hsize_t diff_short(unsigned char *mem1, unsigned char *mem2, /*------------------------------------------------------------------------- * Function: diff_ushort * - * Purpose: diff a H5T_NATIVE_USHORT type - * - * Return: number of differences found + * Purpose: diff a H5T_NATIVE_USHORT type * + * Return: number of differences found *------------------------------------------------------------------------- */ static hsize_t diff_ushort(unsigned char *mem1, unsigned char *mem2, @@ -3308,12 +3333,12 @@ static hsize_t diff_ushort(unsigned char *mem1, unsigned char *mem2, const char *obj2, int *ph) { - hsize_t nfound = 0; /* number of differences found */ + hsize_t nfound = 0; /* number of differences found */ unsigned short temp1_ushort; unsigned short temp2_ushort; - hsize_t i; - double per; - hbool_t both_zero; + hsize_t i; + double per; + hbool_t both_zero; h5difftrace("diff_ushort start\n"); /* -d and !-p */ @@ -3422,13 +3447,12 @@ static hsize_t diff_ushort(unsigned char *mem1, unsigned char *mem2, } /*------------------------------------------------------------------------- - * Function: diff_int + * Function: diff_int * - * Purpose: diff a H5T_NATIVE_INT type + * Purpose: diff a H5T_NATIVE_INT type * - * Return: number of differences found - * - *------------------------------------------------------------------------- + * Return: number of differences found + *------------------------------------------------------------------------- */ static hsize_t diff_int(unsigned char *mem1, unsigned char *mem2, hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, @@ -3436,10 +3460,10 @@ static hsize_t diff_int(unsigned char *mem1, unsigned char *mem2, const char *obj2, int *ph) { hsize_t nfound = 0; /* number of differences found */ - int temp1_int; - int temp2_int; + int temp1_int; + int temp2_int; hsize_t i; - double per; + double per; hbool_t both_zero; h5difftrace("diff_int start\n"); @@ -3551,10 +3575,9 @@ static hsize_t diff_int(unsigned char *mem1, unsigned char *mem2, /*------------------------------------------------------------------------- * Function: diff_uint * - * Purpose: diff a H5T_NATIVE_UINT type - * - * Return: number of differences found + * Purpose: diff a H5T_NATIVE_UINT type * + * Return: number of differences found *------------------------------------------------------------------------- */ static hsize_t diff_uint(unsigned char *mem1, unsigned char *mem2, @@ -3679,10 +3702,9 @@ static hsize_t diff_uint(unsigned char *mem1, unsigned char *mem2, /*------------------------------------------------------------------------- * Function: diff_long * - * Purpose: diff a H5T_NATIVE_LONG type - * - * Return: number of differences found + * Purpose: diff a H5T_NATIVE_LONG type * + * Return: number of differences found *------------------------------------------------------------------------- */ static hsize_t diff_long(unsigned char *mem1, unsigned char *mem2, @@ -3808,10 +3830,9 @@ static hsize_t diff_long(unsigned char *mem1, unsigned char *mem2, /*------------------------------------------------------------------------- * Function: diff_ulong * - * Purpose: diff a H5T_NATIVE_ULONG type - * - * Return: number of differences found + * Purpose: diff a H5T_NATIVE_ULONG type * + * Return: number of differences found *------------------------------------------------------------------------- */ static hsize_t diff_ulong(unsigned char *mem1, unsigned char *mem2, @@ -3819,12 +3840,12 @@ static hsize_t diff_ulong(unsigned char *mem1, unsigned char *mem2, hsize_t *acc, hsize_t *pos, diff_opt_t *options, const char *obj1, const char *obj2, int *ph) { - hsize_t nfound = 0; /* number of differences found */ + hsize_t nfound = 0; /* number of differences found */ unsigned long temp1_ulong; unsigned long temp2_ulong; - hsize_t i; - double per; - hbool_t both_zero; + hsize_t i; + double per; + hbool_t both_zero; h5difftrace("diff_ulong start\n"); @@ -3939,10 +3960,9 @@ static hsize_t diff_ulong(unsigned char *mem1, unsigned char *mem2, /*------------------------------------------------------------------------- * Function: diff_llong * - * Purpose: diff a H5T_NATIVE_LLONG type - * - * Return: number of differences found + * Purpose: diff a H5T_NATIVE_LLONG type * + * Return: number of differences found *------------------------------------------------------------------------- */ static hsize_t diff_llong(unsigned char *mem1, unsigned char *mem2, @@ -3950,12 +3970,12 @@ static hsize_t diff_llong(unsigned char *mem1, unsigned char *mem2, hsize_t *acc, hsize_t *pos, diff_opt_t *options, const char *obj1, const char *obj2, int *ph) { - hsize_t nfound = 0; /* number of differences found */ + hsize_t nfound = 0; /* number of differences found */ long long temp1_llong; long long temp2_llong; - hsize_t i; - double per; - hbool_t both_zero; + hsize_t i; + double per; + hbool_t both_zero; h5difftrace("diff_llong start\n"); /* -d and !-p */ @@ -4067,10 +4087,9 @@ static hsize_t diff_llong(unsigned char *mem1, unsigned char *mem2, /*------------------------------------------------------------------------- * Function: diff_ullong * - * Purpose: diff a H5T_NATIVE_ULLONG type - * - * Return: number of differences found + * Purpose: diff a H5T_NATIVE_ULLONG type * + * Return: number of differences found *------------------------------------------------------------------------- */ static hsize_t diff_ullong(unsigned char *mem1, unsigned char *mem2, @@ -4078,13 +4097,13 @@ static hsize_t diff_ullong(unsigned char *mem1, unsigned char *mem2, hsize_t *pos, diff_opt_t *options, const char *obj1, const char *obj2, int *ph) { - hsize_t nfound = 0; /* number of differences found */ + hsize_t nfound = 0; /* number of differences found */ unsigned long long temp1_ullong; unsigned long long temp2_ullong; - hsize_t i; - float f1, f2; - double per; - hbool_t both_zero; + hsize_t i; + float f1, f2; + double per; + hbool_t both_zero; h5difftrace("diff_ullong start\n"); /* -d and !-p */ @@ -4201,64 +4220,54 @@ static hsize_t diff_ullong(unsigned char *mem1, unsigned char *mem2, * Function: ull2float * * Purpose: convert unsigned long long to float - * - * Programmer: pvn - * Mar 22, 2006 - * - * Modifications: - * *------------------------------------------------------------------------- */ static -int ull2float(unsigned long long ull_value, float *f_value) { - hid_t dxpl_id; +int ull2float(unsigned long long ull_value, float *f_value) +{ + int ret_value = SUCCEED; + hid_t dxpl_id = -1; unsigned char *buf = NULL; - size_t src_size; - size_t dst_size; + size_t src_size; + size_t dst_size; h5difftrace("ull2float start\n"); if ((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcreate failed"); src_size = H5Tget_size(H5T_NATIVE_ULLONG); dst_size = H5Tget_size(H5T_NATIVE_FLOAT); - buf = (unsigned char*) HDcalloc((size_t )1, MAX(src_size, dst_size)); - if (!buf) - goto error; + if((buf = (unsigned char*) HDcalloc((size_t )1, MAX(src_size, dst_size))) == NULL) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for dims"); HDmemcpy(buf, &ull_value, src_size); /* do conversion */ if (H5Tconvert(H5T_NATIVE_ULLONG, H5T_NATIVE_FLOAT, (size_t) 1, buf, NULL, dxpl_id) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tconvert failed"); HDmemcpy(f_value, buf, dst_size); if (buf) - HDfree(buf);h5difftrace("ull2float finish\n"); + HDfree(buf); - return 0; - -error: - H5E_BEGIN_TRY - { +done: + H5E_BEGIN_TRY { H5Pclose(dxpl_id); - }H5E_END_TRY; + } H5E_END_TRY; + if (buf) - HDfree(buf);h5difftrace("ull2float errored\n"); + HDfree(buf); - return -1; + h5difftrace("ull2float finish\n"); + + return ret_value; } /*------------------------------------------------------------------------- * Function: equal_double * - * Purpose: use a absolute error formula to deal with floating point - * uncertainty - * - * Modifications: - * 8/1/2007. handle NaNs - * + * Purpose: use a absolute error formula to deal with floating point uncertainty *------------------------------------------------------------------------- */ static hbool_t equal_double(double value, double expected, diff_opt_t *options) { @@ -4275,26 +4284,24 @@ static hbool_t equal_double(double value, double expected, diff_opt_t *options) * we consider NaN == NaN to be true *------------------------------------------------------------------------- */ - if (isnan1 && isnan2) { + if (isnan1 && isnan2) return TRUE; - } /*------------------------------------------------------------------------- * one is a NaN, do not compare but assume difference *------------------------------------------------------------------------- */ - if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { + if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) return FALSE; - } } if (value == expected) return TRUE; - if (options->use_system_epsilon) { - if ( ABS( (value-expected) ) < DBL_EPSILON) + if (options->use_system_epsilon) + if (ABS((value-expected)) < DBL_EPSILON) return TRUE; - } + h5difftrace("equal_double finish\n"); return FALSE; @@ -4303,9 +4310,7 @@ static hbool_t equal_double(double value, double expected, diff_opt_t *options) /*------------------------------------------------------------------------- * Function: equal_ldouble * - * Purpose: use a absolute error formula to deal with floating point - * uncertainty - * + * Purpose: use a absolute error formula to deal with floating point uncertainty *------------------------------------------------------------------------- */ @@ -4326,26 +4331,24 @@ hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *optio * we consider NaN == NaN to be true *------------------------------------------------------------------------- */ - if (isnan1 && isnan2) { + if (isnan1 && isnan2) return TRUE; - } /*------------------------------------------------------------------------- * one is a NaN, do not compare but assume difference *------------------------------------------------------------------------- */ - if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { + if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) return FALSE; - } } if (value == expected) return TRUE; - if (options->use_system_epsilon) { + if (options->use_system_epsilon) if (ABS((value-expected)) < DBL_EPSILON) return TRUE; - } + h5difftrace("equal_ldouble finish\n"); return FALSE; @@ -4356,12 +4359,7 @@ hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *optio /*------------------------------------------------------------------------- * Function: equal_float * - * Purpose: use a absolute error formula to deal with floating point - * uncertainty - * - * Modifications: - * 8/1/2007. handle NaNs - * + * Purpose: use a absolute error formula to deal with floating point uncertainty *------------------------------------------------------------------------- */ static hbool_t equal_float(float value, float expected, diff_opt_t *options) { @@ -4378,46 +4376,35 @@ static hbool_t equal_float(float value, float expected, diff_opt_t *options) { * we consider NaN == NaN to be true *------------------------------------------------------------------------- */ - if (isnan1 && isnan2) { + if (isnan1 && isnan2) return TRUE; - } /*------------------------------------------------------------------------- * one is a NaN, do not compare but assume difference *------------------------------------------------------------------------- */ - if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { + if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) return FALSE; - } } if (value == expected) return TRUE; - if (options->use_system_epsilon) { + if (options->use_system_epsilon) if ( ABS( (value-expected) ) < FLT_EPSILON) return TRUE; - } + h5difftrace("equal_float finish\n"); return FALSE; - } /*------------------------------------------------------------------------- * Function: my_isnan * - * Purpose: Determines whether VAL points to NaN. - * - * Return: TRUE or FALSE - * - * Programmer: Robb Matzke - * Monday, July 6, 1998 - * - * Modifications: - * Pedro Vicente, 12 October 2007. - * Add a string detection type for WIN32 + * Purpose: Determines whether VAL points to NaN. * + * Return: TRUE or FALSE *------------------------------------------------------------------------- */ static hbool_t my_isnan(dtype_t type, void *val) { @@ -4445,9 +4432,8 @@ static hbool_t my_isnan(dtype_t type, void *val) { retval = (x!=x); } #endif - else { + else return FALSE; - } /* * Sometimes NaN==NaN (e.g., DEC Alpha) so we try to print it and see if @@ -4474,9 +4460,8 @@ static hbool_t my_isnan(dtype_t type, void *val) { HDsnprintf(s, sizeof(s), "%Lg", x); } #endif - else { + else return FALSE; - } if (HDstrstr(s, "NaN") || HDstrstr(s, "NAN") || @@ -4501,24 +4486,25 @@ static hbool_t my_isnan(dtype_t type, void *val) { /*------------------------------------------------------------------------- * Function: print_data * - * Purpose: print data only in report or verbose modes, and do not print in quiet mode + * Purpose: print data only in report or verbose modes, and do not print in quiet mode *------------------------------------------------------------------------- */ static -int print_data(diff_opt_t *options) { +int print_data(diff_opt_t *options) +{ return ((options->m_report || options->m_verbose) && !options->m_quiet) ? 1 : 0; } /*------------------------------------------------------------------------- * Function: print_header * - * Purpose: print header for difference - * + * Purpose: print header for difference *------------------------------------------------------------------------- */ static void print_header(int pp, /* print percentage */ - int rank, hsize_t *dims, const char *obj1, const char *obj2) { + int rank, hsize_t *dims, const char *obj1, const char *obj2) +{ /* print header */ parallel_print("%-16s", "size:"); print_dimensions(rank, dims); @@ -4528,8 +4514,7 @@ void print_header(int pp, /* print percentage */ if (pp) { parallel_print("%-15s %-15s %-15s %-15s %-15s\n", "position", - (obj1 != NULL) ? obj1 : " ", (obj2 != NULL) ? obj2 : " ", "difference", - "relative"); + (obj1 != NULL) ? obj1 : " ", (obj2 != NULL) ? obj2 : " ", "difference", "relative"); parallel_print( "------------------------------------------------------------------------\n"); } @@ -4544,15 +4529,15 @@ void print_header(int pp, /* print percentage */ /*------------------------------------------------------------------------- * Function: print_pos * - * Purpose: print in matrix notation, converting from an array index position - * + * Purpose: print in matrix notation, converting from an array index position *------------------------------------------------------------------------- */ static void print_pos(int *ph, /* print header */ int pp, /* print percentage */ hsize_t curr_pos, hsize_t *acc, hsize_t *pos, int rank, hsize_t *dims, - const char *obj1, const char *obj2) { + const char *obj1, const char *obj2) +{ int i; /* print header */ @@ -4576,23 +4561,22 @@ void print_pos(int *ph, /* print header */ } parallel_print("]"); } - else { + else parallel_print(" "); - } } /*------------------------------------------------------------------------- * Function: print_char_pos * - * Purpose: print character position in string - * + * Purpose: print character position in string *------------------------------------------------------------------------- */ static void print_char_pos(int *ph, /* print header */ int pp, /* print percentage */ hsize_t curr_pos, size_t u, hsize_t *acc, hsize_t *pos, int rank, hsize_t *dims, - const char *obj1, const char *obj2) { + const char *obj1, const char *obj2) +{ int i; /* print header */ @@ -4616,20 +4600,20 @@ void print_char_pos(int *ph, /* print header */ } } - else { + else parallel_print("%zu", u); - } + parallel_print("]"); } /*------------------------------------------------------------------------- - * Function: h5diff_print_char. Adapted from h5tools_print_char - * - * Purpose: Print a char + * Function: h5diff_print_char. Adapted from h5tools_print_char * + * Purpose: Print a char *------------------------------------------------------------------------- */ -static void h5diff_print_char(char ch) { +static void h5diff_print_char(char ch) +{ switch (ch) { case '"': parallel_print("\\\""); @@ -4662,12 +4646,13 @@ static void h5diff_print_char(char ch) { } /*------------------------------------------------------------------------- - * XCAO, 11/10/2010 * added to improve performance for compound datasets * set up compound datatype structures. + *------------------------------------------------------------------------- */ -static void get_member_types(hid_t tid, mcomp_t *members) { - int tclass; +static void get_member_types(hid_t tid, mcomp_t *members) +{ + int tclass; unsigned u; if (tid <= 0 || !members) @@ -4682,8 +4667,7 @@ static void get_member_types(hid_t tid, mcomp_t *members) { else if (tclass == H5T_COMPOUND) { int nmembs; - nmembs = H5Tget_nmembers(tid); - if (nmembs <= 0) + if ((nmembs = H5Tget_nmembers(tid)) <= 0) return; members->n = (unsigned) nmembs; @@ -4701,15 +4685,15 @@ static void get_member_types(hid_t tid, mcomp_t *members) { } return; - } /*------------------------------------------------------------------------- - * XCAO, 11/10/2010 * added to improve performance for compound datasets * clean and close compound members. + *------------------------------------------------------------------------- */ -static void close_member_types(mcomp_t *members) { +static void close_member_types(mcomp_t *members) +{ unsigned u; if (!members || members->n <= 0 || !members->ids) diff --git a/tools/lib/h5diff_attr.c b/tools/lib/h5diff_attr.c index 9bebcbe..f381393 100644 --- a/tools/lib/h5diff_attr.c +++ b/tools/lib/h5diff_attr.c @@ -136,32 +136,32 @@ static void table_attr_mark_exist(unsigned *exist, char *name, table_attrs_t *ta * * Parameter: * table_out [OUT] : return the list - * - * Programmer: Jonathan Kim - * - * Date: March 15, 2011 *------------------------------------------------------------------------*/ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t ** table_out, diff_opt_t *options) { - H5O_info_t oinfo1, oinfo2; /* Object info */ - hid_t attr1_id=-1; /* attr ID */ - hid_t attr2_id=-1; /* attr ID */ - size_t curr1 = 0; - size_t curr2 = 0; - unsigned infile[2]; - char name1[ATTR_NAME_MAX]; - char name2[ATTR_NAME_MAX]; - int cmp; - unsigned i; + int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ + H5O_info_t oinfo1, oinfo2; /* Object info */ + hid_t attr1_id = -1; /* attr ID */ + hid_t attr2_id = -1; /* attr ID */ + size_t curr1 = 0; + size_t curr2 = 0; + unsigned infile[2]; + char name1[ATTR_NAME_MAX]; + char name2[ATTR_NAME_MAX]; + int cmp; + unsigned i; table_attrs_t *table_lp = NULL; h5difftrace("build_match_list_attrs start\n"); + if(H5Oget_info(loc1_id, &oinfo1) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Oget_info first object failed"); if(H5Oget_info(loc2_id, &oinfo2) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Oget_info second object failed"); - table_attrs_init( &table_lp ); + table_attrs_init(&table_lp); + if (table_lp == NULL) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Table allocation failed"); h5diffdebug3("build_match_list_attrs: %ld - %ld\n", curr1 < oinfo1.num_attrs, curr2 < oinfo2.num_attrs); @@ -172,18 +172,18 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t /*------------------ * open attribute1 */ if((attr1_id = H5Aopen_by_idx(loc1_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)curr1, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aopen_by_idx first attribute failed"); /* get name */ if(H5Aget_name(attr1_id, (size_t)ATTR_NAME_MAX, name1) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_name first attribute failed"); /*------------------ * open attribute2 */ if((attr2_id = H5Aopen_by_idx(loc2_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)curr2, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aopen_by_idx second attribute failed"); /* get name */ if(H5Aget_name(attr2_id, (size_t)ATTR_NAME_MAX, name2) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_name second attribute failed"); /* criteria is string compare */ cmp = HDstrcmp(name1, name2); @@ -224,10 +224,10 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t /*------------------ * open attribute1 */ if((attr1_id = H5Aopen_by_idx(loc1_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)curr1, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aopen_by_idx first attribute failed"); /* get name */ if(H5Aget_name(attr1_id, (size_t)ATTR_NAME_MAX, name1) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_name first attribute failed"); h5diffdebug2("build_match_list_attrs #1 name - %s\n", name1); table_attr_mark_exist(infile, name1, table_lp); @@ -246,10 +246,10 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t /*------------------ * open attribute2 */ if((attr2_id = H5Aopen_by_idx(loc2_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)curr2, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aopen_by_idx second attribute failed"); /* get name */ if(H5Aget_name(attr2_id, (size_t)ATTR_NAME_MAX, name2) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_name second attribute failed"); h5diffdebug2("build_match_list_attrs #2 name - %s\n", name2); table_attr_mark_exist(infile, name2, table_lp); @@ -258,6 +258,7 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t /* close for next turn */ H5Aclose(attr2_id); + attr2_id = -1; } /*------------------------------------------------------ @@ -280,39 +281,30 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t table_lp->nattrs - table_lp->nattrs_only1 - table_lp->nattrs_only2, table_lp->nattrs_only1, table_lp->nattrs_only2); +done: *table_out = table_lp; - h5difftrace("build_match_list_attrs end\n"); - return 0; - -error: - if (0 < attr1_id) + /* disable error reporting */ + H5E_BEGIN_TRY { H5Aclose(attr1_id); - if (0 < attr2_id) H5Aclose(attr2_id); + } H5E_END_TRY; + + h5difftrace("build_match_list_attrs end\n"); - h5difftrace("build_match_list_attrs end with error\n"); - return -1; + return ret_value; } /*------------------------------------------------------------------------- * Function: diff_attr * - * Purpose: compare attributes located in LOC1_ID and LOC2_ID, which are - * obtained either from - * loc_id = H5Gopen2(fid, name, H5P_DEFAULT); - * loc_id = H5Dopen2(fid, name); - * loc_id = H5Topen2(fid, name, H5P_DEFAULT); - * - * Return: number of differences found - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: November, 03, 2003 - * - * Modifications: - * March, 02, 2007: return the number of differences found + * Purpose: compare attributes located in LOC1_ID and LOC2_ID, which are + * obtained either from + * loc_id = H5Gopen2(fid, name, H5P_DEFAULT); + * loc_id = H5Dopen2(fid, name); + * loc_id = H5Topen2(fid, name, H5P_DEFAULT); * + * Return: number of differences found *------------------------------------------------------------------------- */ @@ -322,41 +314,45 @@ hsize_t diff_attr(hid_t loc1_id, const char *path2, diff_opt_t *options) { - hid_t attr1_id=-1; /* attr ID */ - hid_t attr2_id=-1; /* attr ID */ - hid_t space1_id=-1; /* space ID */ - hid_t space2_id=-1; /* space ID */ - hid_t ftype1_id=-1; /* file data type ID */ - hid_t ftype2_id=-1; /* file data type ID */ - int vstrtype1=0; /* ftype1 is a variable string */ - int vstrtype2=0; /* ftype2 is a variable string */ - hid_t mtype1_id=-1; /* memory data type ID */ - hid_t mtype2_id=-1; /* memory data type ID */ - size_t msize1; /* memory size of memory type */ - size_t msize2; /* memory size of memory type */ - void *buf1=NULL; /* data buffer */ - void *buf2=NULL; /* data buffer */ - hbool_t buf1hasdata=FALSE; /* buffer has data */ - hbool_t buf2hasdata=FALSE; /* buffer has data */ - hsize_t nelmts1; /* number of elements in dataset */ - int rank1; /* rank of dataset */ - int rank2; /* rank of dataset */ - hsize_t dims1[H5S_MAX_RANK];/* dimensions of dataset */ - hsize_t dims2[H5S_MAX_RANK];/* dimensions of dataset */ - char *name1; - char *name2; + int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ + hid_t attr1_id = -1; /* attr ID */ + hid_t attr2_id = -1; /* attr ID */ + hid_t space1_id = -1; /* space ID */ + hid_t space2_id = -1; /* space ID */ + hid_t ftype1_id = -1; /* file data type ID */ + hid_t ftype2_id = -1; /* file data type ID */ + int vstrtype1 = 0; /* ftype1 is a variable string */ + int vstrtype2 = 0; /* ftype2 is a variable string */ + hid_t mtype1_id = -1; /* memory data type ID */ + hid_t mtype2_id = -1; /* memory data type ID */ + size_t msize1; /* memory size of memory type */ + size_t msize2; /* memory size of memory type */ + void *buf1 = NULL; /* data buffer */ + void *buf2 = NULL; /* data buffer */ + hbool_t buf1hasdata = FALSE; /* buffer has data */ + hbool_t buf2hasdata = FALSE; /* buffer has data */ + hsize_t nelmts1; /* number of elements in dataset */ + int rank1; /* rank of dataset */ + int rank2; /* rank of dataset */ + hsize_t dims1[H5S_MAX_RANK]; /* dimensions of dataset */ + hsize_t dims2[H5S_MAX_RANK]; /* dimensions of dataset */ + char *name1 = NULL; + char *name2 = NULL; char np1[512]; char np2[512]; - unsigned u; /* Local index variable */ + unsigned u; /* Local index variable */ hsize_t nfound = 0; hsize_t nfound_total = 0; int j; + /* Initialize error status */ + options->err_stat = 1; + table_attrs_t *match_list_attrs = NULL; h5difftrace("diff_attr start\n"); if(build_match_list_attrs(loc1_id, loc2_id, &match_list_attrs, options) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "build_match_list_attrs failed"); /* if detect any unique extra attr */ if(match_list_attrs->nattrs_only1 || match_list_attrs->nattrs_only2) { @@ -373,21 +369,22 @@ hsize_t diff_attr(hid_t loc1_id, /*-------------- * attribute 1 */ if((attr1_id = H5Aopen(loc1_id, name1, H5P_DEFAULT)) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aopen first attribute failed"); /*-------------- * attribute 2 */ if((attr2_id = H5Aopen(loc2_id, name2, H5P_DEFAULT)) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aopen second attribute failed"); h5difftrace("diff_attr got attributes\n"); /* get the datatypes */ if((ftype1_id = H5Aget_type(attr1_id)) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_type first attribute failed"); vstrtype1 = H5Tis_variable_str(ftype1_id); if((ftype2_id = H5Aget_type(attr2_id)) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_type second attribute failed"); vstrtype2 = H5Tis_variable_str(ftype2_id); + /* no compare if either one but not both are variable string type */ if (vstrtype1 != vstrtype2) { if((options->m_verbose || options->m_list_not_cmp)) @@ -395,37 +392,37 @@ hsize_t diff_attr(hid_t loc1_id, path1, name1, path2, name2); options->not_cmp = 1; if (H5Tclose(ftype1_id) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose first attribute ftype failed"); if (H5Tclose(ftype2_id) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose second attribute ftype failed"); if (H5Aclose(attr1_id) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aclose first attribute failed"); if (H5Aclose(attr2_id) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aclose second attribute failed"); continue; } if((mtype1_id = H5Tget_native_type(ftype1_id, H5T_DIR_DEFAULT)) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_native_type first attribute ftype failed"); if((mtype2_id = H5Tget_native_type(ftype2_id, H5T_DIR_DEFAULT)) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_native_type second attribute ftype failed"); if((msize1 = H5Tget_size(mtype1_id)) == 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_size first attribute mtype failed"); if((msize2 = H5Tget_size(mtype2_id)) == 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_size second attribute mtype failed"); /* get the dataspace */ if((space1_id = H5Aget_space(attr1_id)) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_space first attribute failed"); if((space2_id = H5Aget_space(attr2_id)) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_space second attribute failed"); /* get dimensions */ if((rank1 = H5Sget_simple_extent_dims(space1_id, dims1, NULL)) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims first attribute failed"); if((rank2 = H5Sget_simple_extent_dims(space2_id, dims2, NULL)) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims second attribute failed"); /*---------------------------------------------------------------------- * check for comparable TYPE and SPACE @@ -437,21 +434,21 @@ hsize_t diff_attr(hid_t loc1_id, if(diff_can_type(ftype1_id, ftype2_id, rank1, rank2, dims1, dims2, dims1, dims2, name1, name2, options, 0) != 1) { if(H5Tclose(ftype1_id) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose first attribute ftype failed"); if(H5Tclose(ftype2_id) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose second attribute ftype failed"); if(H5Sclose(space1_id) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose first attribute failed"); if(H5Sclose(space2_id) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose second attribute failed"); if(H5Aclose(attr1_id) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aclose first attribute failed"); if(H5Aclose(attr2_id) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aclose second attribute failed"); if(H5Tclose(mtype1_id) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose first attribute mtype failed"); if(H5Tclose(mtype2_id) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose second attribute mtype failed"); continue; } @@ -462,7 +459,7 @@ hsize_t diff_attr(hid_t loc1_id, */ if(FAIL == match_up_memsize(ftype1_id, ftype2_id, &mtype1_id, &mtype2_id, &msize1, &msize2)) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "match_up_memsize failed"); /*--------------------------------------------------------------------- * read @@ -476,18 +473,18 @@ hsize_t diff_attr(hid_t loc1_id, buf2 = (void *)HDcalloc((size_t)(nelmts1), msize2); if(buf1 == NULL || buf2 == NULL) { parallel_print("cannot read into memory\n"); - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "buffer allocation failed"); } if(H5Aread(attr1_id, mtype1_id, buf1) < 0) { parallel_print("Failed reading attribute1 %s/%s\n", path1, name1); - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_type first attribute failed"); } else buf1hasdata = TRUE; if(H5Aread(attr2_id, mtype2_id, buf2) < 0) { parallel_print("Failed reading attribute2 %s/%s\n", path2, name2); - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_type second attribute failed"); } else buf2hasdata = TRUE; @@ -545,32 +542,29 @@ hsize_t diff_attr(hid_t loc1_id, buf2 = NULL; if(H5Tclose(ftype1_id) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_type first attribute failed"); if(H5Tclose(ftype2_id) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_type second attribute failed"); if(H5Sclose(space1_id) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_type first attribute failed"); if(H5Sclose(space2_id) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_type second attribute failed"); if(H5Aclose(attr1_id) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_type first attribute failed"); if(H5Aclose(attr2_id) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_type second attribute failed"); if(H5Tclose(mtype1_id) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose first attribute mtype failed"); if(H5Tclose(mtype2_id) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose second attribute mtype failed"); nfound_total += nfound; } } /* u */ - table_attrs_free(match_list_attrs); - - h5difftrace("diff_attr end\n"); - return nfound_total; + options->err_stat = 0; -error: +done: H5E_BEGIN_TRY { if(buf1) { if(buf1hasdata && TRUE == h5tools_detect_vlen(mtype1_id)) @@ -595,8 +589,7 @@ error: H5Aclose(attr2_id); } H5E_END_TRY; - options->err_stat = 1; - h5difftrace("diff_attr end with error\n"); + h5difftrace("diff_attr end\n"); return nfound_total; } diff --git a/tools/lib/h5diff_dset.c b/tools/lib/h5diff_dset.c index 998a8ca..16239f5 100644 --- a/tools/lib/h5diff_dset.c +++ b/tools/lib/h5diff_dset.c @@ -1,15 +1,15 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright by The HDF Group. * -* Copyright by the Board of Trustees of the University of Illinois. * -* All rights reserved. * -* * -* This file is part of HDF5. The full HDF5 copyright notice, including * -* terms governing use, modification, and redistribution, is contained in * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * * the COPYING file, which can be found at the root of the source code * * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * * If you do not have access to either file, you may request a copy from * * help@hdfgroup.org. * -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include "H5private.h" #include "h5tools.h" @@ -19,25 +19,21 @@ /*------------------------------------------------------------------------- -* Function: diff_dataset -* -* Purpose: check for comparable datasets and read into a compatible -* memory type -* -* Return: Number of differences found -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: May 9, 2003 -* -*------------------------------------------------------------------------- -*/ -hsize_t diff_dataset( hid_t file1_id, - hid_t file2_id, - const char *obj1_name, - const char *obj2_name, - diff_opt_t *options) + * Function: diff_dataset + * + * Purpose: check for comparable datasets and read into a compatible + * memory type + * + * Return: Number of differences found + *------------------------------------------------------------------------- + */ +hsize_t diff_dataset(hid_t file1_id, + hid_t file2_id, + const char *obj1_name, + const char *obj2_name, + diff_opt_t *options) { + int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ hid_t did1 = -1; hid_t did2 = -1; hid_t dcpl1 = -1; @@ -45,52 +41,40 @@ hsize_t diff_dataset( hid_t file1_id, hsize_t nfound = 0; h5difftrace("diff_dataset start\n"); + options->err_stat = 1; /*------------------------------------------------------------------------- - * open the handles - *------------------------------------------------------------------------- - */ - /* disable error reporting */ - H5E_BEGIN_TRY - { - /* Open the datasets */ - if((did1 = H5Dopen2(file1_id, obj1_name, H5P_DEFAULT)) < 0) { - parallel_print("Cannot open dataset <%s>\n", obj1_name); - goto error; - } - if((did2 = H5Dopen2(file2_id, obj2_name, H5P_DEFAULT)) < 0) { - parallel_print("Cannot open dataset <%s>\n", obj2_name); - goto error; - } - /* enable error reporting */ - } H5E_END_TRY; - + * open the handles + *------------------------------------------------------------------------- + */ + /* Open the datasets */ + if((did1 = H5Dopen2(file1_id, obj1_name, H5P_DEFAULT)) < 0) { + parallel_print("Cannot open dataset <%s>\n", obj1_name); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 first dataset failed"); + } + if((did2 = H5Dopen2(file2_id, obj2_name, H5P_DEFAULT)) < 0) { + parallel_print("Cannot open dataset <%s>\n", obj2_name); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 second dataset failed"); + } if((dcpl1 = H5Dget_create_plist(did1)) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist first dataset failed"); if((dcpl2 = H5Dget_create_plist(did2)) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist second dataset failed"); /*------------------------------------------------------------------------- - * check if the dataset creation property list has filters that - * are not registered in the current configuration - * 1) the external filters GZIP and SZIP might not be available - * 2) the internal filters might be turned off - *------------------------------------------------------------------------- - */ + * check if the dataset creation property list has filters that + * are not registered in the current configuration + * 1) the external filters GZIP and SZIP might not be available + * 2) the internal filters might be turned off + *------------------------------------------------------------------------- + */ if ((h5tools_canreadf((options->m_verbose ? obj1_name : NULL), dcpl1) == 1) && - (h5tools_canreadf((options->m_verbose ? obj2_name : NULL), dcpl2) == 1)) + (h5tools_canreadf((options->m_verbose ? obj2_name : NULL), dcpl2) == 1)) nfound = diff_datasetid(did1, did2, obj1_name, obj2_name, options); else - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5tools_canreadf failed"); - /*------------------------------------------------------------------------- - * close - *------------------------------------------------------------------------- - */ - goto done; - -error: - options->err_stat = 1; + options->err_stat = 0; done: /* disable error reporting */ @@ -107,77 +91,70 @@ done: } /*------------------------------------------------------------------------- -* Function: diff_datasetid -* -* Purpose: check for comparable datasets and read into a compatible -* memory type -* -* Return: Number of differences found -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: May 9, 2003 -* -* Modifications: -* -* -* October 2006: Read by hyperslabs for big datasets. -* -* A threshold of H5TOOLS_MALLOCSIZE (128 MB) is the limit upon which I/O hyperslab is done -* i.e., if the memory needed to read a dataset is greater than this limit, -* then hyperslab I/O is done instead of one operation I/O -* For each dataset, the memory needed is calculated according to -* -* memory needed = number of elements * size of each element -* -* if the memory needed is lower than H5TOOLS_MALLOCSIZE, then the following operations -* are done -* -* H5Dread( input_dataset1 ) -* H5Dread( input_dataset2 ) -* -* with all elements in the datasets selected. If the memory needed is greater than -* H5TOOLS_MALLOCSIZE, then the following operations are done instead: -* -* a strip mine is defined for each dimension k (a strip mine is defined as a -* hyperslab whose size is memory manageable) according to the formula -* -* (1) strip_mine_size[k ] = MIN(dimension[k ], H5TOOLS_BUFSIZE / size of memory type) -* -* where H5TOOLS_BUFSIZE is a constant currently defined as 1MB. This formula assures -* that for small datasets (small relative to the H5TOOLS_BUFSIZE constant), the strip -* mine size k is simply defined as its dimension k, but for larger datasets the -* hyperslab size is still memory manageable. -* a cycle is done until the number of elements in the dataset is reached. In each -* iteration, two parameters are defined for the function H5Sselect_hyperslab, -* the start and size of each hyperslab, according to -* -* (2) hyperslab_size [k] = MIN(dimension[k] - hyperslab_offset[k], strip_mine_size [k]) -* -* where hyperslab_offset [k] is initially set to zero, and later incremented in -* hyperslab_size[k] offsets. The reason for the operation -* -* dimension[k] - hyperslab_offset[k] -* -* in (2) is that, when using the strip mine size, it assures that the "remaining" part -* of the dataset that does not fill an entire strip mine is processed. -* -*------------------------------------------------------------------------- -*/ -hsize_t diff_datasetid( hid_t did1, - hid_t did2, - const char *obj1_name, - const char *obj2_name, - diff_opt_t *options) + * Function: diff_datasetid + * + * Purpose: check for comparable datasets and read into a compatible + * memory type + * + * Return: Number of differences found + * + * October 2006: Read by hyperslabs for big datasets. + * + * A threshold of H5TOOLS_MALLOCSIZE (128 MB) is the limit upon which I/O hyperslab is done + * i.e., if the memory needed to read a dataset is greater than this limit, + * then hyperslab I/O is done instead of one operation I/O + * For each dataset, the memory needed is calculated according to + * + * memory needed = number of elements * size of each element + * + * if the memory needed is lower than H5TOOLS_MALLOCSIZE, then the following operations + * are done + * + * H5Dread( input_dataset1 ) + * H5Dread( input_dataset2 ) + * + * with all elements in the datasets selected. If the memory needed is greater than + * H5TOOLS_MALLOCSIZE, then the following operations are done instead: + * + * a strip mine is defined for each dimension k (a strip mine is defined as a + * hyperslab whose size is memory manageable) according to the formula + * + * (1) strip_mine_size[k ] = MIN(dimension[k ], H5TOOLS_BUFSIZE / size of memory type) + * + * where H5TOOLS_BUFSIZE is a constant currently defined as 1MB. This formula assures + * that for small datasets (small relative to the H5TOOLS_BUFSIZE constant), the strip + * mine size k is simply defined as its dimension k, but for larger datasets the + * hyperslab size is still memory manageable. + * a cycle is done until the number of elements in the dataset is reached. In each + * iteration, two parameters are defined for the function H5Sselect_hyperslab, + * the start and size of each hyperslab, according to + * + * (2) hyperslab_size [k] = MIN(dimension[k] - hyperslab_offset[k], strip_mine_size [k]) + * + * where hyperslab_offset [k] is initially set to zero, and later incremented in + * hyperslab_size[k] offsets. The reason for the operation + * + * dimension[k] - hyperslab_offset[k] + * + * in (2) is that, when using the strip mine size, it assures that the "remaining" part + * of the dataset that does not fill an entire strip mine is processed. + * + *------------------------------------------------------------------------- + */ +hsize_t diff_datasetid(hid_t did1, + hid_t did2, + const char *obj1_name, + const char *obj2_name, + diff_opt_t *options) { - int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ - hid_t sid1=-1; - hid_t sid2=-1; - hid_t f_tid1=-1; - hid_t f_tid2=-1; - hid_t dam_tid=-1; /* m_tid for diff_array function */ - hid_t m_tid1=-1; - hid_t m_tid2=-1; + int ret_value = 0; /* no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ + hid_t sid1 = -1; + hid_t sid2 = -1; + hid_t f_tid1 = -1; + hid_t f_tid2 = -1; + hid_t dam_tid = -1; /* m_tid for diff_array function */ + hid_t m_tid1 = -1; + hid_t m_tid2 = -1; hid_t dcpl1 = -1; hid_t dcpl2 = -1; H5D_layout_t stl1 = -1; @@ -197,20 +174,20 @@ hsize_t diff_datasetid( hid_t did1, hsize_t dims2[H5S_MAX_RANK]; hsize_t maxdim1[H5S_MAX_RANK]; hsize_t maxdim2[H5S_MAX_RANK]; - const char *name1=NULL; /* relative names */ - const char *name2=NULL; + const char *name1 = NULL; /* relative names */ + const char *name2 = NULL; hsize_t storage_size1; hsize_t storage_size2; - hsize_t nfound=0; /* number of differences found */ - int can_compare=1; /* do diff or not */ - void *buf1=NULL; - void *buf2=NULL; - void *sm_buf1=NULL; - void *sm_buf2=NULL; - hid_t sm_space; /*stripmine data space */ - size_t need; /* bytes needed for malloc */ + hsize_t nfound = 0; /* number of differences found */ + int can_compare = 1; /* do diff or not */ + void *buf1 = NULL; + void *buf2 = NULL; + void *sm_buf1 = NULL; + void *sm_buf2 = NULL; + hid_t sm_space; /*stripmine data space */ + size_t need; /* bytes needed for malloc */ int i; - unsigned int vl_data = 0; /*contains VL datatypes */ + unsigned int vl_data = 0; /*contains VL datatypes */ options->err_stat = 1; h5difftrace("diff_datasetid start\n"); @@ -240,9 +217,9 @@ hsize_t diff_datasetid( hid_t did1, h5diffdebug3("rank: %ld - %ld\n", rank1, rank2); /*------------------------------------------------------------------------- - * get the file data type - *------------------------------------------------------------------------- - */ + * get the file data type + *------------------------------------------------------------------------- + */ /* Get the data type */ if((f_tid1 = H5Dget_type(did1)) < 0) @@ -253,9 +230,9 @@ hsize_t diff_datasetid( hid_t did1, HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_type failed"); /*------------------------------------------------------------------------- - * get the storage layout type - *------------------------------------------------------------------------- - */ + * get the storage layout type + *------------------------------------------------------------------------- + */ if((dcpl1 = H5Dget_create_plist(did1)) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist failed"); if((dcpl2 = H5Dget_create_plist(did2)) < 0) @@ -267,9 +244,9 @@ hsize_t diff_datasetid( hid_t did1, HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_layout failed"); /*------------------------------------------------------------------------- - * check for empty datasets - *------------------------------------------------------------------------- - */ + * check for empty datasets + *------------------------------------------------------------------------- + */ h5difftrace("check for empty datasets\n"); storage_size1 = H5Dget_storage_size(did1); @@ -290,9 +267,9 @@ hsize_t diff_datasetid( hid_t did1, } /*------------------------------------------------------------------------- - * check for comparable TYPE and SPACE - *------------------------------------------------------------------------- - */ + * check for comparable TYPE and SPACE + *------------------------------------------------------------------------- + */ if (diff_can_type(f_tid1, f_tid2, rank1, rank2, dims1, dims2, maxdim1, maxdim2, obj1_name, obj2_name, @@ -300,9 +277,9 @@ hsize_t diff_datasetid( hid_t did1, can_compare = 0; /*------------------------------------------------------------------------- - * memory type and sizes - *------------------------------------------------------------------------- - */ + * memory type and sizes + *------------------------------------------------------------------------- + */ h5difftrace("check for memory type and sizes\n"); if((m_tid1 = H5Tget_native_type(f_tid1, H5T_DIR_DEFAULT)) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_native_type failed"); @@ -315,9 +292,9 @@ hsize_t diff_datasetid( hid_t did1, h5diffdebug3("type size: %ld - %ld\n", m_size1, m_size2); /*------------------------------------------------------------------------- - * check for different signed/unsigned types - *------------------------------------------------------------------------- - */ + * check for different signed/unsigned types + *------------------------------------------------------------------------- + */ if(can_compare) { h5difftrace("can_compare for sign\n"); sign1 = H5Tget_sign(m_tid1); @@ -335,14 +312,15 @@ hsize_t diff_datasetid( hid_t did1, } /* Check if type is either VLEN-data or VLEN-string to reclaim any - * VLEN memory buffer later */ + * VLEN memory buffer later + */ if(TRUE == h5tools_detect_vlen(m_tid1)) vl_data = TRUE; /*------------------------------------------------------------------------ - * only attempt to compare if possible - *------------------------------------------------------------------------- - */ + * only attempt to compare if possible + *------------------------------------------------------------------------- + */ if(can_compare) { /* it is possible to compare */ H5T_class_t tclass = H5Tget_class(f_tid1); h5difftrace("can_compare attempt\n"); @@ -363,9 +341,9 @@ hsize_t diff_datasetid( hid_t did1, if(tclass != H5T_ARRAY) { /*----------------------------------------------------------------- - * "upgrade" the smaller memory size - *------------------------------------------------------------------ - */ + * "upgrade" the smaller memory size + *------------------------------------------------------------------ + */ h5difftrace("upgrade the smaller memory size?\n"); if (FAIL == match_up_memsize (f_tid1, f_tid2, &m_tid1, &m_tid2, @@ -405,9 +383,9 @@ hsize_t diff_datasetid( hid_t did1, /*---------------------------------------------------------------- - * read/compare - *----------------------------------------------------------------- - */ + * read/compare + *----------------------------------------------------------------- + */ if(need < H5TOOLS_MALLOCSIZE) { buf1 = HDmalloc(need); buf2 = HDmalloc(need); @@ -605,51 +583,46 @@ done: } /*------------------------------------------------------------------------- -* Function: diff_can_type -* -* Purpose: check for comparable TYPE and SPACE -* -* Return: -* 1, can compare -* 0, cannot compare -* -1, error -* -* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu -* -* Date: November 3, 2003 -* -*------------------------------------------------------------------------- -*/ - -int diff_can_type( hid_t f_tid1, /* file data type */ - hid_t f_tid2, /* file data type */ - int rank1, - int rank2, - hsize_t *dims1, - hsize_t *dims2, - hsize_t *maxdim1, - hsize_t *maxdim2, - const char *obj1_name, - const char *obj2_name, - diff_opt_t *options, - int is_compound) + * Function: diff_can_type + * + * Purpose: check for comparable TYPE and SPACE + * + * Return: + * 1, can compare + * 0, cannot compare + * -1, error + *------------------------------------------------------------------------- + */ + +int diff_can_type(hid_t f_tid1, /* file data type */ + hid_t f_tid2, /* file data type */ + int rank1, + int rank2, + hsize_t *dims1, + hsize_t *dims2, + hsize_t *maxdim1, + hsize_t *maxdim2, + const char *obj1_name, + const char *obj2_name, + diff_opt_t *options, + int is_compound) { + int ret_value = 0; /* can_compare value, no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ H5T_class_t tclass1; H5T_class_t tclass2; int maxdim_diff = 0; /* maximum dimensions are different */ int dim_diff = 0; /* current dimensions are different */ int i; - int can_compare = 1; /* return value */ h5difftrace("diff_can_type start\n"); /*------------------------------------------------------------------------- - * check for the same class - *------------------------------------------------------------------------- - */ + * check for the same class + *------------------------------------------------------------------------- + */ if((tclass1 = H5Tget_class(f_tid1)) < 0) - return -1; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_class first object failed"); if((tclass2 = H5Tget_class(f_tid2)) < 0) - return -1; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_class second object failed"); if(tclass1 != tclass2) { if((options->m_verbose || options->m_list_not_cmp) && obj1_name && obj2_name) { @@ -664,24 +637,22 @@ int diff_can_type( hid_t f_tid1, /* file data type */ obj2_name, get_class(tclass2)); } } - can_compare = 0; options->not_cmp = 1; - goto done; + HGOTO_DONE(0); } /*------------------------------------------------------------------------- - * check for non supported classes - *------------------------------------------------------------------------- - */ + * check for non supported classes + *------------------------------------------------------------------------- + */ switch (tclass1) { case H5T_TIME: if((options->m_verbose || options->m_list_not_cmp) && obj1_name && obj2_name) { parallel_print("Not comparable: <%s> and <%s> are of class %s\n", obj1_name, obj2_name, get_class(tclass2)); } /* end if */ - can_compare = 0; options->not_cmp = 1; - goto done; + HGOTO_DONE(0); case H5T_INTEGER: case H5T_FLOAT: @@ -701,9 +672,9 @@ int diff_can_type( hid_t f_tid1, /* file data type */ } /* end switch */ /*------------------------------------------------------------------------- - * check for equal file datatype; warning only - *------------------------------------------------------------------------- - */ + * check for equal file datatype; warning only + *------------------------------------------------------------------------- + */ if((H5Tequal(f_tid1, f_tid2) == 0) && (options->m_verbose) && obj1_name && obj2_name) { H5T_class_t cl = H5Tget_class(f_tid1); @@ -719,9 +690,9 @@ int diff_can_type( hid_t f_tid1, /* file data type */ } /*------------------------------------------------------------------------- - * check for the same rank - *------------------------------------------------------------------------- - */ + * check for the same rank + *------------------------------------------------------------------------- + */ if(rank1 != rank2) { if((options->m_verbose || options->m_list_not_cmp) && obj1_name && obj2_name) { parallel_print("Not comparable: <%s> has rank %d, dimensions ", obj1_name, rank1); @@ -735,15 +706,14 @@ int diff_can_type( hid_t f_tid1, /* file data type */ print_dimensions(rank2, maxdim2); parallel_print("\n"); } - can_compare = 0; options->not_cmp = 1; - goto done; + HGOTO_DONE(0); } /*------------------------------------------------------------------------- - * check for different dimensions - *------------------------------------------------------------------------- - */ + * check for different dimensions + *------------------------------------------------------------------------- + */ for(i = 0; im_verbose || options->m_list_not_cmp) && obj1_name && obj2_name) { parallel_print("Not comparable: <%s> has rank %d, dimensions ", obj1_name, rank1); @@ -772,15 +742,14 @@ int diff_can_type( hid_t f_tid1, /* file data type */ parallel_print("\n"); } } - can_compare = 0; options->not_cmp = 1; - goto done; + HGOTO_DONE(0); } /*------------------------------------------------------------------------- - * maximum dimensions; just give a warning - *------------------------------------------------------------------------- - */ + * maximum dimensions; just give a warning + *------------------------------------------------------------------------- + */ if(maxdim1 && maxdim2 && maxdim_diff == 1 && obj1_name) { if(options->m_verbose) { parallel_print( "Warning: different maximum dimensions\n"); @@ -797,8 +766,8 @@ int diff_can_type( hid_t f_tid1, /* file data type */ int nmembs1; int nmembs2; int j; - hid_t memb_type1; - hid_t memb_type2; + hid_t memb_type1 = -1; + hid_t memb_type2 = -1; nmembs1 = H5Tget_nmembers(f_tid1); nmembs2 = H5Tget_nmembers(f_tid2); @@ -809,9 +778,8 @@ int diff_can_type( hid_t f_tid1, /* file data type */ parallel_print("<%s> has %d members ", obj2_name, nmembs2); parallel_print("\n"); } - can_compare = 0; options->not_cmp = 1; - goto done; + HGOTO_DONE(0); } for (j = 0; j < nmembs1; j++) { @@ -821,11 +789,10 @@ int diff_can_type( hid_t f_tid1, /* file data type */ if (diff_can_type(memb_type1, memb_type2, rank1, rank2, dims1, dims2, maxdim1, maxdim2, obj1_name, obj2_name, options, 1) != 1) { - can_compare = 0; options->not_cmp = 1; H5Tclose(memb_type1); H5Tclose(memb_type2); - goto done; + HGOTO_DONE(0); } H5Tclose(memb_type1); H5Tclose(memb_type2); @@ -833,17 +800,16 @@ int diff_can_type( hid_t f_tid1, /* file data type */ } done: h5diffdebug2("diff_can_type end - %d\n", can_compare); - return can_compare; + return ret_value; } /*------------------------------------------------------------------------- -* Function: print_sizes -* -* Purpose: Print datatype sizes -* -*------------------------------------------------------------------------- -*/ + * Function: print_sizes + * + * Purpose: Print datatype sizes + *------------------------------------------------------------------------- + */ #if defined (H5DIFF_DEBUG) void print_sizes( const char *obj1, const char *obj2, diff --git a/tools/lib/h5diff_util.c b/tools/lib/h5diff_util.c index ad23ccf..d4fc3a2 100644 --- a/tools/lib/h5diff_util.c +++ b/tools/lib/h5diff_util.c @@ -24,8 +24,7 @@ int g_nTasks = 1; /*------------------------------------------------------------------------- * Function: print_dimensions * - * Purpose: print dimensions - * + * Purpose: print dimensions *------------------------------------------------------------------------- */ void @@ -33,14 +32,14 @@ print_dimensions (int rank, hsize_t *dims) { int i; - if( rank <= 0 ) + if(rank <= 0) parallel_print("H5S_SCALAR" ); else { if (!dims) parallel_print("dimension is NULL"); else { parallel_print("["); - for ( i = 0; i < rank-1; i++) { + for (i = 0; i < rank-1; i++) { parallel_print(HSIZE_T_FORMAT, dims[i]); parallel_print("x"); } @@ -55,16 +54,11 @@ print_dimensions (int rank, hsize_t *dims) /*------------------------------------------------------------------------- * Function: print_type * - * Purpose: Print name of datatype - * - * Return: void - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * Purpose: Print name of datatype * - * Date: May 9, 2003 - * - * Comments: Adapted from h5dump for H5T_INTEGER and H5T_FLOAT classes only + * Return: void * + * Comments: Adapted from h5dump for H5T_INTEGER and H5T_FLOAT classes only *------------------------------------------------------------------------- */ void print_type(hid_t type) @@ -188,12 +182,7 @@ void print_type(hid_t type) /*------------------------------------------------------------------------- * Function: diff_basename * - * Purpose: Returns a pointer to the last component absolute name - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: May 9, 2003 - * + * Purpose: Returns a pointer to the last component absolute name *------------------------------------------------------------------------- */ H5_ATTR_PURE const char* @@ -219,12 +208,7 @@ diff_basename(const char *name) /*------------------------------------------------------------------------- * Function: get_type * - * Purpose: Returns the type as a string - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: May 9, 2003 - * + * Purpose: Returns the type as a string *------------------------------------------------------------------------- */ H5_ATTR_PURE H5_ATTR_CONST const char* @@ -255,21 +239,13 @@ get_type(h5trav_type_t type) /*------------------------------------------------------------------------- * Function: get_sign * - * Purpose: Returns the sign as a string - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: May 9, 2003 - * - * Comments: - * + * Purpose: Returns the sign as a string *------------------------------------------------------------------------- */ H5_ATTR_PURE const char* get_sign(H5T_sign_t sign) { - switch(sign) - { + switch(sign) { case H5T_SGN_NONE: return "H5T_SGN_NONE"; @@ -291,12 +267,7 @@ get_sign(H5T_sign_t sign) /*------------------------------------------------------------------------- * Function: get_class * - * Purpose: Returns the class as a string - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: May 9, 2003 - * + * Purpose: Returns the class as a string *------------------------------------------------------------------------- */ H5_ATTR_PURE const char* @@ -346,8 +317,7 @@ get_class(H5T_class_t tclass) /*------------------------------------------------------------------------- * Function: print_found * - * Purpose: print number of differences found - * + * Purpose: print number of differences found *------------------------------------------------------------------------- */ void print_found(hsize_t nfound) @@ -362,43 +332,37 @@ void print_found(hsize_t nfound) /*----------------------------------------------------------------- * Function: match_up_memsize * - * Purpose: match smaller memory size up to bigger memory size + * Purpose: match smaller memory size up to bigger memory size *------------------------------------------------------------------ */ herr_t match_up_memsize (hid_t f_tid1_id, hid_t f_tid2_id, hid_t *m_tid1, hid_t *m_tid2, size_t *m_size1, size_t *m_size2) { - herr_t ret = SUCCEED; + herr_t ret_value = SUCCEED; if((*m_size1) != (*m_size2)) { if((*m_size1) < (*m_size2)) { - H5Tclose( *m_tid1 ); + H5Tclose(*m_tid1); - if(((*m_tid1) = H5Tget_native_type(f_tid2_id, H5T_DIR_DEFAULT)) < 0) { - ret = FAIL; - goto out; - } + if(((*m_tid1) = H5Tget_native_type(f_tid2_id, H5T_DIR_DEFAULT)) < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_native_type failed"); - *m_size1 = H5Tget_size( *m_tid1 ); + *m_size1 = H5Tget_size(*m_tid1); } /* end if */ else { H5Tclose(*m_tid2); - if(((*m_tid2) = H5Tget_native_type(f_tid1_id, H5T_DIR_DEFAULT)) < 0) { - ret = FAIL; - goto out; - } + if(((*m_tid2) = H5Tget_native_type(f_tid1_id, H5T_DIR_DEFAULT)) < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_native_type failed"); *m_size2 = H5Tget_size(*m_tid2); } /* end else */ } /* end if */ - if((*m_size1) != (*m_size2)) { - ret = FAIL; - goto out; - } + if((*m_size1) != (*m_size2)) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "native type sizes do not compare"); -out: - return ret; +done: + return ret_value; } diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c index fb79b77..7c88151 100644 --- a/tools/lib/h5tools_dump.c +++ b/tools/lib/h5tools_dump.c @@ -1910,9 +1910,8 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_ obj = search_obj(h5dump_type_table, oinfo.addr); if(obj) { - if(!obj->recorded) { + if(!obj->recorded) h5tools_str_append(buffer,"\"/#"H5_PRINTF_HADDR_FMT"\"", obj->objno); - } else h5tools_str_append(buffer, "\"%s\"", obj->objname); } @@ -1929,121 +1928,86 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_ switch (type_class) { case H5T_INTEGER: - if (H5Tequal(type, H5T_STD_I8BE) == TRUE) { + if (H5Tequal(type, H5T_STD_I8BE) == TRUE) h5tools_str_append(buffer, "H5T_STD_I8BE"); - } - else if (H5Tequal(type, H5T_STD_I8LE) == TRUE) { + else if (H5Tequal(type, H5T_STD_I8LE) == TRUE) h5tools_str_append(buffer, "H5T_STD_I8LE"); - } - else if (H5Tequal(type, H5T_STD_I16BE) == TRUE) { + else if (H5Tequal(type, H5T_STD_I16BE) == TRUE) h5tools_str_append(buffer, "H5T_STD_I16BE"); - } - else if (H5Tequal(type, H5T_STD_I16LE) == TRUE) { + else if (H5Tequal(type, H5T_STD_I16LE) == TRUE) h5tools_str_append(buffer, "H5T_STD_I16LE"); - } - else if (H5Tequal(type, H5T_STD_I32BE) == TRUE) { + else if (H5Tequal(type, H5T_STD_I32BE) == TRUE) h5tools_str_append(buffer, "H5T_STD_I32BE"); - } - else if (H5Tequal(type, H5T_STD_I32LE) == TRUE) { + else if (H5Tequal(type, H5T_STD_I32LE) == TRUE) h5tools_str_append(buffer, "H5T_STD_I32LE"); - } - else if (H5Tequal(type, H5T_STD_I64BE) == TRUE) { + else if (H5Tequal(type, H5T_STD_I64BE) == TRUE) h5tools_str_append(buffer, "H5T_STD_I64BE"); - } - else if (H5Tequal(type, H5T_STD_I64LE) == TRUE) { + else if (H5Tequal(type, H5T_STD_I64LE) == TRUE) h5tools_str_append(buffer, "H5T_STD_I64LE"); - } - else if (H5Tequal(type, H5T_STD_U8BE) == TRUE) { + else if (H5Tequal(type, H5T_STD_U8BE) == TRUE) h5tools_str_append(buffer, "H5T_STD_U8BE"); - } - else if (H5Tequal(type, H5T_STD_U8LE) == TRUE) { + else if (H5Tequal(type, H5T_STD_U8LE) == TRUE) h5tools_str_append(buffer, "H5T_STD_U8LE"); - } - else if (H5Tequal(type, H5T_STD_U16BE) == TRUE) { + else if (H5Tequal(type, H5T_STD_U16BE) == TRUE) h5tools_str_append(buffer, "H5T_STD_U16BE"); - } - else if (H5Tequal(type, H5T_STD_U16LE) == TRUE) { + else if (H5Tequal(type, H5T_STD_U16LE) == TRUE) h5tools_str_append(buffer, "H5T_STD_U16LE"); - } - else if (H5Tequal(type, H5T_STD_U32BE) == TRUE) { + else if (H5Tequal(type, H5T_STD_U32BE) == TRUE) h5tools_str_append(buffer, "H5T_STD_U32BE"); - } - else if (H5Tequal(type, H5T_STD_U32LE) == TRUE) { + else if (H5Tequal(type, H5T_STD_U32LE) == TRUE) h5tools_str_append(buffer, "H5T_STD_U32LE"); - } - else if (H5Tequal(type, H5T_STD_U64BE) == TRUE) { + else if (H5Tequal(type, H5T_STD_U64BE) == TRUE) h5tools_str_append(buffer, "H5T_STD_U64BE"); - } - else if (H5Tequal(type, H5T_STD_U64LE) == TRUE) { + else if (H5Tequal(type, H5T_STD_U64LE) == TRUE) h5tools_str_append(buffer, "H5T_STD_U64LE"); - } - else if (H5Tequal(type, H5T_NATIVE_SCHAR) == TRUE) { + else if (H5Tequal(type, H5T_NATIVE_SCHAR) == TRUE) h5tools_str_append(buffer, "H5T_NATIVE_SCHAR"); - } - else if (H5Tequal(type, H5T_NATIVE_UCHAR) == TRUE) { + else if (H5Tequal(type, H5T_NATIVE_UCHAR) == TRUE) h5tools_str_append(buffer, "H5T_NATIVE_UCHAR"); - } - else if (H5Tequal(type, H5T_NATIVE_SHORT) == TRUE) { + else if (H5Tequal(type, H5T_NATIVE_SHORT) == TRUE) h5tools_str_append(buffer, "H5T_NATIVE_SHORT"); - } - else if (H5Tequal(type, H5T_NATIVE_USHORT) == TRUE) { + else if (H5Tequal(type, H5T_NATIVE_USHORT) == TRUE) h5tools_str_append(buffer, "H5T_NATIVE_USHORT"); - } - else if (H5Tequal(type, H5T_NATIVE_INT) == TRUE) { + else if (H5Tequal(type, H5T_NATIVE_INT) == TRUE) h5tools_str_append(buffer, "H5T_NATIVE_INT"); - } - else if (H5Tequal(type, H5T_NATIVE_UINT) == TRUE) { + else if (H5Tequal(type, H5T_NATIVE_UINT) == TRUE) h5tools_str_append(buffer, "H5T_NATIVE_UINT"); - } - else if (H5Tequal(type, H5T_NATIVE_LONG) == TRUE) { + else if (H5Tequal(type, H5T_NATIVE_LONG) == TRUE) h5tools_str_append(buffer, "H5T_NATIVE_LONG"); - } - else if (H5Tequal(type, H5T_NATIVE_ULONG) == TRUE) { + else if (H5Tequal(type, H5T_NATIVE_ULONG) == TRUE) h5tools_str_append(buffer, "H5T_NATIVE_ULONG"); - } - else if (H5Tequal(type, H5T_NATIVE_LLONG) == TRUE) { + else if (H5Tequal(type, H5T_NATIVE_LLONG) == TRUE) h5tools_str_append(buffer, "H5T_NATIVE_LLONG"); - } - else if (H5Tequal(type, H5T_NATIVE_ULLONG) == TRUE) { + else if (H5Tequal(type, H5T_NATIVE_ULLONG) == TRUE) h5tools_str_append(buffer, "H5T_NATIVE_ULLONG"); - } else { /* byte order */ if (H5Tget_size(type) > 1) { order = H5Tget_order(type); - if (H5T_ORDER_LE == order) { + if (H5T_ORDER_LE == order) order_s = " little-endian"; - } - else if (H5T_ORDER_BE == order) { + else if (H5T_ORDER_BE == order) order_s = " big-endian"; - } - else if (H5T_ORDER_VAX == order) { + else if (H5T_ORDER_VAX == order) order_s = " mixed-endian"; - } - else { + else order_s = " unknown-byte-order"; - } } - else { + else order_s = ""; - } /* sign */ if ((sign = H5Tget_sign(type)) >= 0) { - if (H5T_SGN_NONE == sign) { + if (H5T_SGN_NONE == sign) sign_s = " unsigned"; - } - else if (H5T_SGN_2 == sign) { + else if (H5T_SGN_2 == sign) sign_s = ""; - } - else { + else sign_s = " unknown-sign"; - } } - else { + else sign_s = " unknown-sign"; - } /* print size, order, and sign */ h5tools_str_append(buffer, "%lu-bit%s%s integer", @@ -2052,56 +2016,42 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_ break; case H5T_FLOAT: - if (H5Tequal(type, H5T_IEEE_F32BE) == TRUE) { + if (H5Tequal(type, H5T_IEEE_F32BE) == TRUE) h5tools_str_append(buffer, "H5T_IEEE_F32BE"); - } - else if (H5Tequal(type, H5T_IEEE_F32LE) == TRUE) { + else if (H5Tequal(type, H5T_IEEE_F32LE) == TRUE) h5tools_str_append(buffer, "H5T_IEEE_F32LE"); - } - else if (H5Tequal(type, H5T_IEEE_F64BE) == TRUE) { + else if (H5Tequal(type, H5T_IEEE_F64BE) == TRUE) h5tools_str_append(buffer, "H5T_IEEE_F64BE"); - } - else if (H5Tequal(type, H5T_IEEE_F64LE) == TRUE) { + else if (H5Tequal(type, H5T_IEEE_F64LE) == TRUE) h5tools_str_append(buffer, "H5T_IEEE_F64LE"); - } - else if (H5Tequal(type, H5T_VAX_F32) == TRUE) { + else if (H5Tequal(type, H5T_VAX_F32) == TRUE) h5tools_str_append(buffer, "H5T_VAX_F32"); - } - else if (H5Tequal(type, H5T_VAX_F64) == TRUE) { + else if (H5Tequal(type, H5T_VAX_F64) == TRUE) h5tools_str_append(buffer, "H5T_VAX_F64"); - } - else if (H5Tequal(type, H5T_NATIVE_FLOAT) == TRUE) { + else if (H5Tequal(type, H5T_NATIVE_FLOAT) == TRUE) h5tools_str_append(buffer, "H5T_NATIVE_FLOAT"); - } - else if (H5Tequal(type, H5T_NATIVE_DOUBLE) == TRUE) { + else if (H5Tequal(type, H5T_NATIVE_DOUBLE) == TRUE) h5tools_str_append(buffer, "H5T_NATIVE_DOUBLE"); #if H5_SIZEOF_LONG_DOUBLE !=0 - } - else if (H5Tequal(type, H5T_NATIVE_LDOUBLE) == TRUE) { + else if (H5Tequal(type, H5T_NATIVE_LDOUBLE) == TRUE) h5tools_str_append(buffer, "H5T_NATIVE_LDOUBLE"); #endif - } else { /* byte order */ if (H5Tget_size(type) > 1) { order = H5Tget_order(type); - if (H5T_ORDER_LE == order) { + if (H5T_ORDER_LE == order) order_s = " little-endian"; - } - else if (H5T_ORDER_BE == order) { + else if (H5T_ORDER_BE == order) order_s = " big-endian"; - } - else if (H5T_ORDER_VAX == order) { + else if (H5T_ORDER_VAX == order) order_s = " mixed-endian"; - } - else { + else order_s = " unknown-byte-order"; - } } - else { + else order_s = ""; - } /* print size and byte order */ h5tools_str_append(buffer, "%lu-bit%s floating-point", @@ -2308,33 +2258,24 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_ break; case H5T_BITFIELD: - if (H5Tequal(type, H5T_STD_B8BE) == TRUE) { + if (H5Tequal(type, H5T_STD_B8BE) == TRUE) h5tools_str_append(buffer, "H5T_STD_B8BE"); - } - else if (H5Tequal(type, H5T_STD_B8LE) == TRUE) { + else if (H5Tequal(type, H5T_STD_B8LE) == TRUE) h5tools_str_append(buffer, "H5T_STD_B8LE"); - } - else if (H5Tequal(type, H5T_STD_B16BE) == TRUE) { + else if (H5Tequal(type, H5T_STD_B16BE) == TRUE) h5tools_str_append(buffer, "H5T_STD_B16BE"); - } - else if (H5Tequal(type, H5T_STD_B16LE) == TRUE) { + else if (H5Tequal(type, H5T_STD_B16LE) == TRUE) h5tools_str_append(buffer, "H5T_STD_B16LE"); - } - else if (H5Tequal(type, H5T_STD_B32BE) == TRUE) { + else if (H5Tequal(type, H5T_STD_B32BE) == TRUE) h5tools_str_append(buffer, "H5T_STD_B32BE"); - } - else if (H5Tequal(type, H5T_STD_B32LE) == TRUE) { + else if (H5Tequal(type, H5T_STD_B32LE) == TRUE) h5tools_str_append(buffer, "H5T_STD_B32LE"); - } - else if (H5Tequal(type, H5T_STD_B64BE) == TRUE) { + else if (H5Tequal(type, H5T_STD_B64BE) == TRUE) h5tools_str_append(buffer, "H5T_STD_B64BE"); - } - else if (H5Tequal(type, H5T_STD_B64LE) == TRUE) { + else if (H5Tequal(type, H5T_STD_B64LE) == TRUE) h5tools_str_append(buffer, "H5T_STD_B64LE"); - } - else { + else h5tools_str_append(buffer, "undefined bitfield"); - } break; case H5T_OPAQUE: diff --git a/tools/lib/h5tools_filters.c b/tools/lib/h5tools_filters.c index abd55db..a5d0994 100644 --- a/tools/lib/h5tools_filters.c +++ b/tools/lib/h5tools_filters.c @@ -28,18 +28,22 @@ static void print_warning(const char *dname, const char *fname) /*------------------------------------------------------------------------- * Function: h5tools_canreadf * - * Purpose: check if the dataset creation property list has filters that - * are not registered in the current configuration - * 1) the external filters GZIP and SZIP might not be available - * 2) the internal filters might be turned off + * Purpose: check if the dataset creation property list has filters that + * are not registered in the current configuration + * 1) the external filters GZIP and SZIP might not be available + * 2) the internal filters might be turned off * - * Return: 1, can read, 0, cannot, -1 error + * Return: + * 1 can read, + * 0 cannot, + * -1 error *------------------------------------------------------------------------- */ -int h5tools_canreadf(const char* name, /* object name, serves also as boolean print */ +int +h5tools_canreadf(const char* name, /* object name, serves also as boolean print */ hid_t dcpl_id) /* dataset creation property list */ { - int ret_value = 1; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ + int ret_value = 1; int nfilters; /* number of filters */ H5Z_filter_t filtn; /* filter identification number */ int i; /* index */ @@ -130,56 +134,58 @@ done: /*------------------------------------------------------------------------- * Function: h5tools_canwritef * - * Purpose: check if the filter is available and can write data. - * At this time, all filters that are available can write data, - * except SZIP, which may be configured decoder-only. + * Purpose: check if the filter is available and can write data. * - * Return: 1, can write, 0, cannot, -1 error + * Return: 1 can write, + * 0 cannot, + * -1 error *------------------------------------------------------------------------- */ H5_ATTR_CONST int -h5tools_can_encode(H5Z_filter_t filtn) { +h5tools_can_encode(H5Z_filter_t filtn) +{ + int ret_value = 1; + switch (filtn) { /* user defined filter */ default: - return 0; - + HGOTO_DONE(0) case H5Z_FILTER_DEFLATE: #ifndef H5_HAVE_FILTER_DEFLATE - return 0; + HGOTO_DONE(0) #endif break; case H5Z_FILTER_SZIP: #ifndef H5_HAVE_FILTER_SZIP - return 0; + HGOTO_DONE(0) #else - { + { unsigned int filter_config_flags; if (H5Zget_filter_info(filtn, &filter_config_flags) < 0) - return -1; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Zget_filter_info failed"); if ((filter_config_flags & (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) == 0) { /* filter present but neither encode nor decode is supported (???) */ - return -1; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "neither encode nor decode is supported"); } else if ((filter_config_flags & (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) == H5Z_FILTER_CONFIG_DECODE_ENABLED) { /* decoder only: read but not write */ - return 0; + HGOTO_DONE(0) } else if ((filter_config_flags & (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) == H5Z_FILTER_CONFIG_ENCODE_ENABLED) { /* encoder only: write but not read (???) */ - return -1; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "encoder only: write but not read"); } else if ((filter_config_flags & (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) == (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) { - return 1; + HGOTO_DONE(1) } - } + } #endif break; @@ -196,6 +202,7 @@ h5tools_can_encode(H5Z_filter_t filtn) { break; }/*switch*/ - return 1; +done: + return ret_value; } diff --git a/tools/lib/h5tools_type.c b/tools/lib/h5tools_type.c index ee58ccb..f63c228 100644 --- a/tools/lib/h5tools_type.c +++ b/tools/lib/h5tools_type.c @@ -21,12 +21,6 @@ * * Return: Success: datatype ID * Failure: FAIL - * - * Programmer: Pedro Vicente Nunes - * Tuesday, July 18, 2006 - * - * Modifications: - * *------------------------------------------------------------------------- */ hid_t @@ -43,40 +37,40 @@ h5tools_get_little_endian_type(hid_t tid) switch(type_class) { case H5T_INTEGER: - if ( size == 1 && sign == H5T_SGN_2) - p_type=H5Tcopy(H5T_STD_I8LE); - else if ( size == 2 && sign == H5T_SGN_2) - p_type=H5Tcopy(H5T_STD_I16LE); - else if ( size == 4 && sign == H5T_SGN_2) - p_type=H5Tcopy(H5T_STD_I32LE); - else if ( size == 8 && sign == H5T_SGN_2) - p_type=H5Tcopy(H5T_STD_I64LE); - else if ( size == 1 && sign == H5T_SGN_NONE) - p_type=H5Tcopy(H5T_STD_U8LE); - else if ( size == 2 && sign == H5T_SGN_NONE) - p_type=H5Tcopy(H5T_STD_U16LE); - else if ( size == 4 && sign == H5T_SGN_NONE) - p_type=H5Tcopy(H5T_STD_U32LE); - else if ( size == 8 && sign == H5T_SGN_NONE) - p_type=H5Tcopy(H5T_STD_U64LE); + if (size == 1 && sign == H5T_SGN_2) + p_type = H5Tcopy(H5T_STD_I8LE); + else if (size == 2 && sign == H5T_SGN_2) + p_type = H5Tcopy(H5T_STD_I16LE); + else if (size == 4 && sign == H5T_SGN_2) + p_type = H5Tcopy(H5T_STD_I32LE); + else if (size == 8 && sign == H5T_SGN_2) + p_type = H5Tcopy(H5T_STD_I64LE); + else if (size == 1 && sign == H5T_SGN_NONE) + p_type = H5Tcopy(H5T_STD_U8LE); + else if (size == 2 && sign == H5T_SGN_NONE) + p_type = H5Tcopy(H5T_STD_U16LE); + else if (size == 4 && sign == H5T_SGN_NONE) + p_type = H5Tcopy(H5T_STD_U32LE); + else if (size == 8 && sign == H5T_SGN_NONE) + p_type = H5Tcopy(H5T_STD_U64LE); break; case H5T_FLOAT: - if ( size == 4) - p_type=H5Tcopy(H5T_IEEE_F32LE); - else if ( size == 8) - p_type=H5Tcopy(H5T_IEEE_F64LE); + if (size == 4) + p_type = H5Tcopy(H5T_IEEE_F32LE); + else if (size == 8) + p_type = H5Tcopy(H5T_IEEE_F64LE); break; case H5T_BITFIELD: - if ( size == 1) - p_type=H5Tcopy(H5T_STD_B8LE); - else if ( size == 2) - p_type=H5Tcopy(H5T_STD_B16LE); - else if ( size == 4) - p_type=H5Tcopy(H5T_STD_B32LE); - else if ( size == 8) - p_type=H5Tcopy(H5T_STD_B64LE); + if (size == 1) + p_type = H5Tcopy(H5T_STD_B8LE); + else if (size == 2) + p_type = H5Tcopy(H5T_STD_B16LE); + else if (size == 4) + p_type = H5Tcopy(H5T_STD_B32LE); + else if (size == 8) + p_type = H5Tcopy(H5T_STD_B64LE); break; case H5T_TIME: @@ -107,18 +101,12 @@ h5tools_get_little_endian_type(hid_t tid) * * Return: Success: datatype ID * Failure: FAIL - * - * Programmer: Pedro Vicente Nunes - * Tuesday, July 18, 2006 - * - * Modifications: - * *------------------------------------------------------------------------- */ hid_t h5tools_get_big_endian_type(hid_t tid) { - hid_t p_type=-1; + hid_t p_type = -1; H5T_class_t type_class; size_t size; H5T_sign_t sign; @@ -129,39 +117,39 @@ h5tools_get_big_endian_type(hid_t tid) switch(type_class) { case H5T_INTEGER: - if ( size == 1 && sign == H5T_SGN_2) - p_type=H5Tcopy(H5T_STD_I8BE); - else if ( size == 2 && sign == H5T_SGN_2) - p_type=H5Tcopy(H5T_STD_I16BE); - else if ( size == 4 && sign == H5T_SGN_2) - p_type=H5Tcopy(H5T_STD_I32BE); - else if ( size == 8 && sign == H5T_SGN_2) - p_type=H5Tcopy(H5T_STD_I64BE); - else if ( size == 1 && sign == H5T_SGN_NONE) - p_type=H5Tcopy(H5T_STD_U8BE); - else if ( size == 2 && sign == H5T_SGN_NONE) - p_type=H5Tcopy(H5T_STD_U16BE); - else if ( size == 4 && sign == H5T_SGN_NONE) - p_type=H5Tcopy(H5T_STD_U32BE); - else if ( size == 8 && sign == H5T_SGN_NONE) - p_type=H5Tcopy(H5T_STD_U64BE); + if (size == 1 && sign == H5T_SGN_2) + p_type = H5Tcopy(H5T_STD_I8BE); + else if (size == 2 && sign == H5T_SGN_2) + p_type = H5Tcopy(H5T_STD_I16BE); + else if (size == 4 && sign == H5T_SGN_2) + p_type = H5Tcopy(H5T_STD_I32BE); + else if (size == 8 && sign == H5T_SGN_2) + p_type = H5Tcopy(H5T_STD_I64BE); + else if (size == 1 && sign == H5T_SGN_NONE) + p_type = H5Tcopy(H5T_STD_U8BE); + else if (size == 2 && sign == H5T_SGN_NONE) + p_type = H5Tcopy(H5T_STD_U16BE); + else if (size == 4 && sign == H5T_SGN_NONE) + p_type = H5Tcopy(H5T_STD_U32BE); + else if (size == 8 && sign == H5T_SGN_NONE) + p_type = H5Tcopy(H5T_STD_U64BE); break; case H5T_FLOAT: - if ( size == 4) - p_type=H5Tcopy(H5T_IEEE_F32BE); - else if ( size == 8) - p_type=H5Tcopy(H5T_IEEE_F64BE); + if (size == 4) + p_type = H5Tcopy(H5T_IEEE_F32BE); + else if (size == 8) + p_type = H5Tcopy(H5T_IEEE_F64BE); break; case H5T_BITFIELD: - if ( size == 1) - p_type=H5Tcopy(H5T_STD_B8BE); - else if ( size == 2) - p_type=H5Tcopy(H5T_STD_B16BE); - else if ( size == 4) - p_type=H5Tcopy(H5T_STD_B32BE); - else if ( size == 8) + if (size == 1) + p_type = H5Tcopy(H5T_STD_B8BE); + else if (size == 2) + p_type = H5Tcopy(H5T_STD_B16BE); + else if (size == 4) + p_type = H5Tcopy(H5T_STD_B32BE); + else if (size == 8) p_type=H5Tcopy(H5T_STD_B64BE); break; diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c index 8c435b2..1b5911b 100644 --- a/tools/lib/h5tools_utils.c +++ b/tools/lib/h5tools_utils.c @@ -58,15 +58,11 @@ static void add_obj(table_t *table, haddr_t objno, const char *objname, hbool_t /*------------------------------------------------------------------------- * Function: parallel_print * - * Purpose: wrapper for printf for use in parallel mode. - * - * Programmer: Leon Arber - * - * Date: December 1, 2004 - * + * Purpose: wrapper for printf for use in parallel mode. *------------------------------------------------------------------------- */ -void parallel_print(const char* format, ...) +void +parallel_print(const char* format, ...) { int bytes_written; va_list ap; @@ -103,18 +99,12 @@ void parallel_print(const char* format, ...) /*------------------------------------------------------------------------- - * Function: error_msg + * Function: error_msg * - * Purpose: Print a nicely formatted error message to stderr flushing the + * Purpose: Print a nicely formatted error message to stderr flushing the * stdout stream first. * - * Return: Nothing - * - * Programmer: Bill Wendling - * Tuesday, 20. February 2001 - * - * Modifications: - * + * Return: Nothing *------------------------------------------------------------------------- */ void @@ -134,18 +124,12 @@ error_msg(const char *fmt, ...) /*------------------------------------------------------------------------- - * Function: warn_msg + * Function: warn_msg * - * Purpose: Print a nicely formatted warning message to stderr flushing + * Purpose: Print a nicely formatted warning message to stderr flushing * the stdout stream first. * - * Return: Nothing - * - * Programmer: Bill Wendling - * Tuesday, 20. February 2001 - * - * Modifications: - * + * Return: Nothing *------------------------------------------------------------------------- */ void @@ -163,14 +147,11 @@ warn_msg(const char *fmt, ...) } /*------------------------------------------------------------------------- - * Function: help_ref_msg + * Function: help_ref_msg * - * Purpose: Print a message to refer help page - * - * Return: Nothing - * - * Modifications: + * Purpose: Print a message to refer help page * + * Return: Nothing *------------------------------------------------------------------------- */ void @@ -182,24 +163,16 @@ help_ref_msg(FILE *output) /*------------------------------------------------------------------------- - * Function: get_option + * Function: get_option * - * Purpose: Determine the command-line options a user specified. We can - * accept both short and long type command-lines. + * Purpose: Determine the command-line options a user specified. We can + * accept both short and long type command-lines. * * Return: Success: The short valued "name" of the command line * parameter or EOF if there are no more * parameters to process. * - * Failure: A question mark. - * - * Programmer: Bill Wendling - * Friday, 5. January 2001 - * - * Modifications: Pedro Vicente - * October, 27 2008 - * Wilcard "*" argument type - * + * Failure: A question mark. *------------------------------------------------------------------------- */ int @@ -232,9 +205,8 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti opt_opt = l_opts[i].shortval; if (l_opts[i].has_arg != no_arg) { - if (arg[len] == '=') { + if (arg[len] == '=') opt_arg = &arg[len + 1]; - } else if (l_opts[i].has_arg != optional_arg) { if (opt_ind < (argc - 1)) if (argv[opt_ind + 1][0] != '-') @@ -323,16 +295,13 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti opt_ind++; /* we do have an extra argument, check if not last */ if ( (opt_ind+1) < argc ) { - if ( argv[opt_ind][0] != '-' ) { + if ( argv[opt_ind][0] != '-' ) opt_arg = argv[opt_ind++]; - } - else { + else opt_arg = NULL; - } } - else { + else opt_arg = NULL; - } } else { /* set up to look at next char in token, next time */ @@ -351,16 +320,11 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti /*------------------------------------------------------------------------- - * Function: indentation + * Function: indentation * - * Purpose: Print spaces for indentation - * - * Return: void - * - * Programmer: Ruey-Hsia Li - * - * Modifications: + * Purpose: Print spaces for indentation * + * Return: void *------------------------------------------------------------------------- */ void @@ -378,17 +342,12 @@ indentation(unsigned x) /*------------------------------------------------------------------------- - * Function: print_version + * Function: print_version * - * Purpose: Print the program name and the version information which is - * defined the same as the HDF5 library version. - * - * Return: void - * - * Programmer: unknown - * - * Modifications: + * Purpose: Print the program name and the version information which is + * defined the same as the HDF5 library version. * + * Return: void *------------------------------------------------------------------------- */ void @@ -407,11 +366,6 @@ print_version(const char *progname) * and committed types * * Return: void - * - * Programmer: Ruey-Hsia Li - * - * Modifications: - * *------------------------------------------------------------------------- */ static void @@ -434,11 +388,6 @@ init_table(table_t **tbl) * and committed types * * Return: void - * - * Programmer: Paul Harten - * - * Modifications: - * *------------------------------------------------------------------------- */ void @@ -462,11 +411,6 @@ free_table(table_t *table) * Purpose: display the contents of tables for debugging purposes * * Return: void - * - * Programmer: Ruey-Hsia Li - * - * Modifications: - * *------------------------------------------------------------------------- */ static void @@ -488,11 +432,6 @@ dump_table(char* tablename, table_t *table) * Purpose: display the contents of tables for debugging purposes * * Return: void - * - * Programmer: Ruey-Hsia Li - * - * Modifications: - * *------------------------------------------------------------------------- */ void @@ -513,11 +452,6 @@ dump_tables(find_objs_t *info) * Return: Success: an integer, the location of the object * * Failure: FAIL if object is not found - * - * Programmer: Ruey-Hsia Li - * - * Modifications: - * *------------------------------------------------------------------------- */ H5_ATTR_PURE obj_t * @@ -541,11 +475,6 @@ search_obj(table_t *table, haddr_t objno) * Return: Success: SUCCEED * * Failure: FAIL - * - * Programmer: Ruey-Hsia Li - * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t @@ -623,11 +552,6 @@ find_objs_cb(const char *name, const H5O_info_t *oinfo, const char *already_seen * Return: Success: SUCCEED * * Failure: FAIL - * - * Programmer: Ruey-Hsia Li - * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -657,11 +581,6 @@ init_objs(hid_t fid, find_objs_t *info, table_t **group_table, * realloc the table if necessary * * Return: void - * - * Programmer: Ruey-Hsia Li - * - * Modifications: - * *------------------------------------------------------------------------- */ static void @@ -695,11 +614,6 @@ add_obj(table_t *table, haddr_t objno, const char *objname, hbool_t record) * * Return: a stream description when succeeds. * NULL if fails. - * - * Programmer: Albert Cheng, 2005/8/9 - * - * Modifications: - * *------------------------------------------------------------------------- */ FILE * @@ -723,70 +637,61 @@ tmpfile(void) * * Return: * 2 : given pathname is object - * 1 : Succed to get link info. + * 1 : Succeed to get link info. * 0 : Detected as a dangling link * -1 : H5 API failed. * * NOTE: * link_info->trg_path must be freed out of this function - * - * Programmer: Jonathan Kim - * - * Date: Feb 8, 2010 *-------------------------------------------------------------------------*/ int -H5tools_get_symlink_info(hid_t file_id, const char * linkpath, h5tool_link_info_t *link_info, - hbool_t get_obj_type) +H5tools_get_symlink_info(hid_t file_id, const char * linkpath, h5tool_link_info_t *link_info, hbool_t get_obj_type) { htri_t l_ret; H5O_info_t trg_oinfo; hid_t fapl = H5P_DEFAULT; hid_t lapl = H5P_DEFAULT; - int ret = -1; /* init to fail */ + int ret_value = -1; /* init to fail */ /* init */ link_info->trg_type = H5O_TYPE_UNKNOWN; /* if path is root, return group type */ - if(!HDstrcmp(linkpath,"/")) - { + if(!HDstrcmp(linkpath,"/")) { link_info->trg_type = H5O_TYPE_GROUP; - ret = 2; - goto out; + HGOTO_DONE(2); } /* check if link itself exist */ if(H5Lexists(file_id, linkpath, H5P_DEFAULT) <= 0) { if(link_info->opt.msg_mode == 1) parallel_print("Warning: link <%s> doesn't exist \n",linkpath); - goto out; + HGOTO_DONE(FAIL); } /* end if */ /* get info from link */ if(H5Lget_info(file_id, linkpath, &(link_info->linfo), H5P_DEFAULT) < 0) { if(link_info->opt.msg_mode == 1) parallel_print("Warning: unable to get link info from <%s>\n",linkpath); - goto out; + HGOTO_DONE(FAIL); } /* end if */ /* given path is hard link (object) */ - if(link_info->linfo.type == H5L_TYPE_HARD) { - ret = 2; - goto out; - } /* end if */ + if(link_info->linfo.type == H5L_TYPE_HARD) + HGOTO_DONE(2); /* trg_path must be freed out of this function when finished using */ if((link_info->trg_path = (char*)HDcalloc(link_info->linfo.u.val_size, sizeof(char))) == NULL) { if(link_info->opt.msg_mode == 1) parallel_print("Warning: unable to allocate buffer for <%s>\n",linkpath); - goto out; + HGOTO_DONE(FAIL); } /* end if */ /* get link value */ if(H5Lget_val(file_id, linkpath, (void *)link_info->trg_path, link_info->linfo.u.val_size, H5P_DEFAULT) < 0) { if(link_info->opt.msg_mode == 1) parallel_print("Warning: unable to get link value from <%s>\n",linkpath); - goto out; + HGOTO_DONE(FAIL); } /* end if */ /*----------------------------------------------------- @@ -795,13 +700,13 @@ H5tools_get_symlink_info(hid_t file_id, const char * linkpath, h5tool_link_info_ */ if(link_info->linfo.type == H5L_TYPE_EXTERNAL) { if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) - goto out; + HGOTO_DONE(FAIL); if(H5Pset_fapl_sec2(fapl) < 0) - goto out; + HGOTO_DONE(FAIL); if((lapl = H5Pcreate(H5P_LINK_ACCESS)) < 0) - goto out; + HGOTO_DONE(FAIL); if(H5Pset_elink_fapl(lapl, fapl) < 0) - goto out; + HGOTO_DONE(FAIL); } /* end if */ /* Check for retrieving object info */ @@ -814,25 +719,24 @@ H5tools_get_symlink_info(hid_t file_id, const char * linkpath, h5tool_link_info_ /* detect dangling link */ if(l_ret == FALSE) { - ret = 0; - goto out; - } /* end if */ - /* function failed */ - else if(l_ret < 0) - goto out; + HGOTO_DONE(0); + } + else if(l_ret < 0) { /* function failed */ + HGOTO_DONE(FAIL); + } /* get target object info */ if(H5Oget_info_by_name(file_id, linkpath, &trg_oinfo, lapl) < 0) { if(link_info->opt.msg_mode == 1) parallel_print("Warning: unable to get object information for <%s>\n", linkpath); - goto out; + HGOTO_DONE(FAIL); } /* end if */ /* check unknown type */ if(trg_oinfo.type < H5O_TYPE_GROUP || trg_oinfo.type >=H5O_TYPE_NTYPES) { if(link_info->opt.msg_mode == 1) parallel_print("Warning: target object of <%s> is unknown type\n", linkpath); - goto out; + HGOTO_DONE(FAIL); } /* end if */ /* set target obj type to return */ @@ -844,31 +748,34 @@ H5tools_get_symlink_info(hid_t file_id, const char * linkpath, h5tool_link_info_ link_info->trg_type = H5O_TYPE_UNKNOWN; /* succeed */ - ret = 1; + ret_value = 1; -out: +done: if(fapl != H5P_DEFAULT) H5Pclose(fapl); if(lapl != H5P_DEFAULT) H5Pclose(lapl); - return ret; + return ret_value; } /* end H5tools_get_symlink_info() */ /*------------------------------------------------------------------------- * Audience: Public - * Chapter: H5Tools Library + * * Purpose: Initialize the name and operation status of the H5 Tools library + * * Description: * These are utility functions to set/get the program name and operation status. *------------------------------------------------------------------------- */ -void h5tools_setprogname(const char *Progname) +void +h5tools_setprogname(const char *Progname) { h5tools_progname = Progname; } -void h5tools_setstatus(int D_status) +void +h5tools_setstatus(int D_status) { h5tools_d_status = D_status; } @@ -892,25 +799,19 @@ h5tools_getstatus(void) * This can be called from each tools main() as part of initial act. * Note: this is more of debugging purpose for now. */ -int h5tools_getenv_update_hyperslab_bufsize(void) +int +h5tools_getenv_update_hyperslab_bufsize(void) { const char *env_str = NULL; long hyperslab_bufsize_mb; + int ret_value = 1; /* check if environment variable is set for the hyperslab buffer size */ - if (NULL != (env_str = HDgetenv ("H5TOOLS_BUFSIZE"))) - { + if (NULL != (env_str = HDgetenv ("H5TOOLS_BUFSIZE"))) { errno = 0; hyperslab_bufsize_mb = HDstrtol(env_str, (char**)NULL, 10); if (errno != 0 || hyperslab_bufsize_mb <= 0) - { - /* TODO: later when pubilshed - HDfprintf(rawerrorstream,"Error: Invalid environment variable \"H5TOOLS_BUFSIZE\" : %s\n", env_str); - */ - - goto error; - } - + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "hyperslab buffer size failed"); /* convert MB to byte */ H5TOOLS_BUFSIZE = (hsize_t)hyperslab_bufsize_mb * 1024 * 1024; @@ -918,9 +819,7 @@ int h5tools_getenv_update_hyperslab_bufsize(void) H5TOOLS_MALLOCSIZE = MAX(H5TOOLS_BUFSIZE, H5TOOLS_MALLOCSIZE); } - return (1); - -error: - return (-1); +done: + return ret_value; } diff --git a/tools/lib/h5trav.c b/tools/lib/h5trav.c index ddc0109..b6d32f7 100644 --- a/tools/lib/h5trav.c +++ b/tools/lib/h5trav.c @@ -13,6 +13,7 @@ #include "h5trav.h" +#include "h5tools.h" #include "H5private.h" /*------------------------------------------------------------------------- @@ -81,10 +82,9 @@ static int trav_verbosity = 0; /*------------------------------------------------------------------------- * Function: h5trav_set_index * - * Purpose: Set indexing properties for the objects & links in the file - * - * Return: none + * Purpose: Set indexing properties for the objects & links in the file * + * Return: none *------------------------------------------------------------------------- */ void @@ -97,10 +97,9 @@ h5trav_set_index(H5_index_t print_index_by, H5_iter_order_t print_index_order) /*------------------------------------------------------------------------- * Function: h5trav_set_verbose * - * Purpose: Set verbosity of file contents 1=>attributes - * - * Return: none + * Purpose: Set verbosity of file contents 1=>attributes * + * Return: none *------------------------------------------------------------------------- */ void @@ -118,14 +117,9 @@ h5trav_set_verbose(int print_verbose) /*------------------------------------------------------------------------- * Function: trav_addr_add * - * Purpose: Add a hardlink address to visited data structure - * - * Return: void - * - * Programmer: Quincey Koziol, koziol@hdfgroup.org - * - * Date: September 1, 2007 + * Purpose: Add a hardlink address to visited data structure * + * Return: void *------------------------------------------------------------------------- */ static void @@ -149,14 +143,9 @@ trav_addr_add(trav_addr_t *visited, haddr_t addr, const char *path) /*------------------------------------------------------------------------- * Function: trav_addr_visited * - * Purpose: Check if an address has already been visited - * - * Return: TRUE/FALSE - * - * Programmer: Quincey Koziol, koziol@hdfgroup.org - * - * Date: September 1, 2007 + * Purpose: Check if an address has already been visited * + * Return: TRUE/FALSE *------------------------------------------------------------------------- */ H5_ATTR_PURE static const char * @@ -178,12 +167,7 @@ trav_addr_visited(trav_addr_t *visited, haddr_t addr) /*------------------------------------------------------------------------- * Function: traverse_cb * - * Purpose: Iterator callback for traversing objects in file - * - * Programmer: Quincey Koziol, koziol@hdfgroup.org - * - * Date: September 1, 2007 - * + * Purpose: Iterator callback for traversing objects in file *------------------------------------------------------------------------- */ static herr_t @@ -258,26 +242,23 @@ traverse_cb(hid_t loc_id, const char *path, const H5L_info_t *linfo, /*------------------------------------------------------------------------- * Function: traverse * - * Purpose: Iterate over all the objects/links in a file. Conforms to the - * "visitor" pattern. - * - * Return: 0 on success, -1 on failure - * - * Programmer: Quincey Koziol, koziol@hdfgroup.org - * - * Date: September 1, 2007 + * Purpose: Iterate over all the objects/links in a file. Conforms to the + * "visitor" pattern. * + * Return: 0 on success, + * -1 on failure *------------------------------------------------------------------------- */ static int traverse(hid_t file_id, const char *grp_name, hbool_t visit_start, - hbool_t recurse, const trav_visitor_t *visitor) + hbool_t recurse, const trav_visitor_t *visitor) { H5O_info_t oinfo; /* Object info for starting group */ + int ret_value = SUCCEED; /* Get info for starting object */ if(H5Oget_info_by_name(file_id, grp_name, &oinfo, H5P_DEFAULT) < 0) - return -1; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Oget_info_by_name failed"); /* Visit the starting object */ if(visit_start && visitor->visit_obj) @@ -306,12 +287,12 @@ traverse(hid_t file_id, const char *grp_name, hbool_t visit_start, if(recurse) { /* Visit all links in group, recursively */ if(H5Lvisit_by_name(file_id, grp_name, trav_index_by, trav_index_order, traverse_cb, &udata, H5P_DEFAULT) < 0) - return -1; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Lvisit_by_name failed"); } /* end if */ else { /* Iterate over links in group */ if(H5Literate_by_name(file_id, grp_name, trav_index_by, trav_index_order, NULL, traverse_cb, &udata, H5P_DEFAULT) < 0) - return -1; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Literate_by_name failed"); } /* end else */ /* Free visited addresses table */ @@ -325,21 +306,17 @@ traverse(hid_t file_id, const char *grp_name, hbool_t visit_start, } /* end if */ } /* end if */ - return 0; +done: + return ret_value; } /*------------------------------------------------------------------------- * Function: trav_info_add * - * Purpose: Add a link path & type to info struct - * - * Return: void - * - * Programmer: Quincey Koziol, koziol@hdfgroup.org - * - * Date: September 1, 2007 + * Purpose: Add a link path & type to info struct * + * Return: void *------------------------------------------------------------------------- */ void @@ -347,18 +324,20 @@ trav_info_add(trav_info_t *info, const char *path, h5trav_type_t obj_type) { size_t idx; /* Index of address to use */ - /* Allocate space if necessary */ - if(info->nused == info->nalloc) { - info->nalloc = MAX(1, info->nalloc * 2);; - info->paths = (trav_path_t *)HDrealloc(info->paths, info->nalloc * sizeof(trav_path_t)); - } /* end if */ + if (info) { + /* Allocate space if necessary */ + if(info->nused == info->nalloc) { + info->nalloc = MAX(1, info->nalloc * 2);; + info->paths = (trav_path_t *)HDrealloc(info->paths, info->nalloc * sizeof(trav_path_t)); + } /* end if */ - /* Append it */ - idx = info->nused++; - info->paths[idx].path = HDstrdup(path); - info->paths[idx].type = obj_type; - info->paths[idx].fileno = 0; - info->paths[idx].objno = HADDR_UNDEF; + /* Append it */ + idx = info->nused++; + info->paths[idx].path = HDstrdup(path); + info->paths[idx].type = obj_type; + info->paths[idx].fileno = 0; + info->paths[idx].objno = HADDR_UNDEF; + } } /* end trav_info_add() */ @@ -368,7 +347,6 @@ trav_info_add(trav_info_t *info, const char *path, h5trav_type_t obj_type) * Purpose: Add a file addr & fileno to info struct * * Return: void - * *------------------------------------------------------------------------- */ void @@ -390,22 +368,19 @@ trav_fileinfo_add(trav_info_t *info, hid_t loc_id) /*------------------------------------------------------------------------- * Function: trav_info_visit_obj * - * Purpose: Callback for visiting object, with 'info' structure - * - * Return: 0 on success, -1 on failure - * - * Programmer: Quincey Koziol, koziol@hdfgroup.org - * - * Date: September 1, 2007 + * Purpose: Callback for visiting object, with 'info' structure * + * Return: 0 on success, + * -1 on failure *------------------------------------------------------------------------- */ int trav_info_visit_obj(const char *path, const H5O_info_t *oinfo, - const char H5_ATTR_UNUSED *already_visited, void *udata) + const char H5_ATTR_UNUSED *already_visited, void *udata) { size_t idx; trav_info_t *info_p; + /* Add the object to the 'info' struct */ /* (object types map directly to "traversal" types) */ trav_info_add((trav_info_t *)udata, path, (h5trav_type_t)oinfo->type); @@ -423,14 +398,10 @@ trav_info_visit_obj(const char *path, const H5O_info_t *oinfo, /*------------------------------------------------------------------------- * Function: trav_info_visit_lnk * - * Purpose: Callback for visiting link, with 'info' structure - * - * Return: 0 on success, -1 on failure - * - * Programmer: Quincey Koziol, koziol@hdfgroup.org - * - * Date: September 1, 2007 + * Purpose: Callback for visiting link, with 'info' structure * + * Return: 0 on success, + * -1 on failure *------------------------------------------------------------------------- */ int @@ -446,21 +417,18 @@ trav_info_visit_lnk(const char *path, const H5L_info_t *linfo, void *udata) /*------------------------------------------------------------------------- * Function: h5trav_getinfo * - * Purpose: get an array of "trav_info_t" , containing the name and type of - * objects in the file - * - * Return: number of object names in file - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: November 6, 2002 + * Purpose: get an array of "trav_info_t" , containing the name and type of + * objects in the file * + * Return: 0 on success, + * -1 on failure *------------------------------------------------------------------------- */ int h5trav_getinfo(hid_t file_id, trav_info_t *info) { trav_visitor_t info_visitor; /* Visitor structure for trav_info_t's */ + int ret_value = SUCCEED; /* Init visitor structure */ info_visitor.visit_obj = trav_info_visit_obj; @@ -469,25 +437,21 @@ h5trav_getinfo(hid_t file_id, trav_info_t *info) /* Traverse all objects in the file, visiting each object & link */ if(traverse(file_id, "/", TRUE, TRUE, &info_visitor) < 0) - return -1; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "traverse failed"); - return 0; +done: + return ret_value; } /*------------------------------------------------------------------------- * Function: h5trav_getindex * - * Purpose: get index of OBJ in list - * - * Return: index, -1 if not found - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: May 9, 2003 + * Purpose: get index of OBJ in list * + * Return: index on success, + * -1 if not found *------------------------------------------------------------------------- */ - H5_ATTR_PURE ssize_t h5trav_getindex(const trav_info_t *info, const char *obj) { @@ -511,17 +475,11 @@ h5trav_getindex(const trav_info_t *info, const char *obj) /*------------------------------------------------------------------------- * Function: trav_info_init * - * Purpose: Initialize the info - * - * Return: void - * - * Programmer: Quincey Koziol, koziol@hdfgroup.org - * - * Date: September 6, 2007 + * Purpose: Initialize the info * + * Return: void *------------------------------------------------------------------------- */ - void trav_info_init(const char *filename, hid_t fileid, trav_info_t **_info) { @@ -545,11 +503,9 @@ trav_info_init(const char *filename, hid_t fileid, trav_info_t **_info) /*------------------------------------------------------------------------- * Function: trav_info_free * - * Purpose: free info memory - * + * Purpose: free info memory *------------------------------------------------------------------------- */ - void trav_info_free(trav_info_t *info) { @@ -557,11 +513,9 @@ trav_info_free(trav_info_t *info) if(info) { /* Free visited symbolic links path and file (if alloc) */ - for(u=0; u < info->symlink_visited.nused; u++) - { + for(u = 0; u < info->symlink_visited.nused; u++) { if (info->symlink_visited.objs[u].file) HDfree(info->symlink_visited.objs[u].file); - HDfree(info->symlink_visited.objs[u].path); } HDfree(info->symlink_visited.objs); @@ -586,12 +540,8 @@ trav_info_free(trav_info_t *info) * * Purpose: Callback for visiting object, with 'table' sructure * - * Return: 0 on success, -1 on failure - * - * Programmer: Quincey Koziol, koziol@hdfgroup.org - * - * Date: September 1, 2007 - * + * Return: 0 on success, + * -1 on failure *------------------------------------------------------------------------- */ static int @@ -608,21 +558,17 @@ trav_table_visit_obj(const char *path, const H5O_info_t *oinfo, /* Add alias for object to table */ trav_table_addlink(table, oinfo->addr, path); - return(0); + return 0; } /* end trav_table_visit_obj() */ /*------------------------------------------------------------------------- * Function: trav_table_visit_lnk * - * Purpose: Callback for visiting link, with 'table' sructure - * - * Return: 0 on success, -1 on failure - * - * Programmer: Quincey Koziol, koziol@hdfgroup.org - * - * Date: September 1, 2007 + * Purpose: Callback for visiting link, with 'table' sructure * + * Return: 0 on success, + * -1 on failure *------------------------------------------------------------------------- */ static int @@ -631,28 +577,24 @@ trav_table_visit_lnk(const char *path, const H5L_info_t H5_ATTR_UNUSED *linfo, v /* Add the link to the 'table' struct */ trav_table_add((trav_table_t *)udata, path, NULL); - return(0); + return 0; } /* end trav_table_visit_lnk() */ /*------------------------------------------------------------------------- * Function: h5trav_gettable * - * Purpose: get the trav_table_t struct - * - * Return: 0, -1 on error - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: December 17, 2003 + * Purpose: get the trav_table_t struct * + * Return: 0 on success, + * -1 on failure *------------------------------------------------------------------------- */ - int h5trav_gettable(hid_t fid, trav_table_t *table) { trav_visitor_t table_visitor; /* Visitor structure for trav_table_t's */ + int ret_value = SUCCEED; /* Init visitor structure */ table_visitor.visit_obj = trav_table_visit_obj; @@ -661,71 +603,63 @@ h5trav_gettable(hid_t fid, trav_table_t *table) /* Traverse all objects in the file, visiting each object & link */ if(traverse(fid, "/", TRUE, TRUE, &table_visitor) < 0) - return -1; - return 0; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "traverse failed"); + +done: + return ret_value; } /*------------------------------------------------------------------------- * Function: h5trav_getindext * - * Purpose: get index of NAME in list - * - * Return: index, -1 if not found - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: December 18, 2003 + * Purpose: get index of NAME in list * + * Return: index on success, + * -1 if not found *------------------------------------------------------------------------- */ - H5_ATTR_PURE int h5trav_getindext(const char *name, const trav_table_t *table) { unsigned int i; - for(i = 0; i < table->nobjs; i++) { - /* Check for object name having full path (with leading '/') */ - if(HDstrcmp(name, table->objs[i].name) == 0) - return((int)i); - - /* Check for object name without leading '/' */ - if(HDstrcmp(name, table->objs[i].name + 1) == 0) - return((int)i); + if(table) { + for(i = 0; i < table->nobjs; i++) { + /* Check for object name having full path (with leading '/') */ + if(HDstrcmp(name, table->objs[i].name) == 0) + return((int)i); - /* search also in the list of links */ - if(table->objs[i].nlinks) { - unsigned int j; + /* Check for object name without leading '/' */ + if(HDstrcmp(name, table->objs[i].name + 1) == 0) + return((int)i); - for ( j=0; jobjs[i].nlinks; j++) { - /* Check for object name having full path (with leading '/') */ - if(HDstrcmp(name, table->objs[i].links[j].new_name) == 0) - return((int)i); + /* search also in the list of links */ + if(table->objs[i].nlinks) { + unsigned int j; - /* Check for object name without leading '/' */ - if(HDstrcmp(name, table->objs[i].links[j].new_name + 1) == 0) - return((int)i); - } /* end for */ - } /* end if */ - } /* end for */ + for ( j=0; jobjs[i].nlinks; j++) { + /* Check for object name having full path (with leading '/') */ + if(HDstrcmp(name, table->objs[i].links[j].new_name) == 0) + return((int)i); + /* Check for object name without leading '/' */ + if(HDstrcmp(name, table->objs[i].links[j].new_name + 1) == 0) + return((int)i); + } /* end for */ + } /* end if */ + } /* end for */ + } return -1; } /*------------------------------------------------------------------------- * Function: trav_table_add * - * Purpose: Add OBJNO, NAME and TYPE of object to table - * - * Return: void - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: November 4, 2002 + * Purpose: Add OBJNO, NAME and TYPE of object to table * + * Return: void *------------------------------------------------------------------------- */ - static void trav_table_add(trav_table_t *table, const char *path, @@ -733,20 +667,22 @@ trav_table_add(trav_table_t *table, { size_t new_obj; - if(table->nobjs == table->size) { - table->size = MAX(1, table->size * 2); - table->objs = (trav_obj_t *)HDrealloc(table->objs, table->size * sizeof(trav_obj_t)); - } /* end if */ + if(table) { + if(table->nobjs == table->size) { + table->size = MAX(1, table->size * 2); + table->objs = (trav_obj_t *)HDrealloc(table->objs, table->size * sizeof(trav_obj_t)); + } /* end if */ - new_obj = table->nobjs++; - table->objs[new_obj].objno = oinfo ? oinfo->addr : HADDR_UNDEF; - table->objs[new_obj].flags[0] = table->objs[new_obj].flags[1] = 0; - table->objs[new_obj].is_same_trgobj = 0; - table->objs[new_obj].name = (char *)HDstrdup(path); - table->objs[new_obj].type = oinfo ? (h5trav_type_t)oinfo->type : H5TRAV_TYPE_LINK; - table->objs[new_obj].nlinks = 0; - table->objs[new_obj].sizelinks = 0; - table->objs[new_obj].links = NULL; + new_obj = table->nobjs++; + table->objs[new_obj].objno = oinfo ? oinfo->addr : HADDR_UNDEF; + table->objs[new_obj].flags[0] = table->objs[new_obj].flags[1] = 0; + table->objs[new_obj].is_same_trgobj = 0; + table->objs[new_obj].name = (char *)HDstrdup(path); + table->objs[new_obj].type = oinfo ? (h5trav_type_t)oinfo->type : H5TRAV_TYPE_LINK; + table->objs[new_obj].nlinks = 0; + table->objs[new_obj].sizelinks = 0; + table->objs[new_obj].links = NULL; + } } /*------------------------------------------------------------------------- @@ -755,58 +691,47 @@ trav_table_add(trav_table_t *table, * Purpose: Add a hardlink name to the object * * Return: void - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: December 17, 2003 - * *------------------------------------------------------------------------- */ - static void trav_table_addlink(trav_table_t *table, haddr_t objno, const char *path) { size_t i; /* Local index variable */ - for(i = 0; i < table->nobjs; i++) { - if(table->objs[i].objno == objno) { - size_t n; + if(table) { + for(i = 0; i < table->nobjs; i++) { + if(table->objs[i].objno == objno) { + size_t n; - /* already inserted? */ - if(HDstrcmp(table->objs[i].name, path) == 0) - return; + /* already inserted? */ + if(HDstrcmp(table->objs[i].name, path) == 0) + return; - /* allocate space if necessary */ - if(table->objs[i].nlinks == (unsigned)table->objs[i].sizelinks) { - table->objs[i].sizelinks = MAX(1, table->objs[i].sizelinks * 2); - table->objs[i].links = (trav_link_t *)HDrealloc(table->objs[i].links, table->objs[i].sizelinks * sizeof(trav_link_t)); - } /* end if */ + /* allocate space if necessary */ + if(table->objs[i].nlinks == (unsigned)table->objs[i].sizelinks) { + table->objs[i].sizelinks = MAX(1, table->objs[i].sizelinks * 2); + table->objs[i].links = (trav_link_t *)HDrealloc(table->objs[i].links, table->objs[i].sizelinks * sizeof(trav_link_t)); + } /* end if */ - /* insert it */ - n = table->objs[i].nlinks++; - table->objs[i].links[n].new_name = (char *)HDstrdup(path); + /* insert it */ + n = table->objs[i].nlinks++; + table->objs[i].links[n].new_name = (char *)HDstrdup(path); - return; + return; + } /* end for */ } /* end for */ - } /* end for */ + } } - /*------------------------------------------------------------------------- * Function: trav_table_addflags * - * Purpose: Add FLAGS, NAME and TYPE of object to table - * - * Return: void - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: November 4, 2002 + * Purpose: Add FLAGS, NAME and TYPE of object to table * + * Return: void *------------------------------------------------------------------------- */ - void trav_table_addflags(unsigned *flags, char *name, h5trav_type_t type, @@ -814,92 +739,83 @@ void trav_table_addflags(unsigned *flags, { size_t new_obj; - if(table->nobjs == table->size) { - table->size = MAX(1, table->size * 2); - table->objs = (trav_obj_t *)HDrealloc(table->objs, table->size * sizeof(trav_obj_t)); - } /* end if */ + if(table) { + if(table->nobjs == table->size) { + table->size = MAX(1, table->size * 2); + table->objs = (trav_obj_t *)HDrealloc(table->objs, table->size * sizeof(trav_obj_t)); + } /* end if */ - new_obj = table->nobjs++; - table->objs[new_obj].objno = 0; - table->objs[new_obj].flags[0] = flags[0]; - table->objs[new_obj].flags[1] = flags[1]; - table->objs[new_obj].is_same_trgobj = 0; - table->objs[new_obj].name = (char *)HDstrdup(name); - table->objs[new_obj].type = type; - table->objs[new_obj].nlinks = 0; - table->objs[new_obj].sizelinks = 0; - table->objs[new_obj].links = NULL; + new_obj = table->nobjs++; + table->objs[new_obj].objno = 0; + table->objs[new_obj].flags[0] = flags[0]; + table->objs[new_obj].flags[1] = flags[1]; + table->objs[new_obj].is_same_trgobj = 0; + table->objs[new_obj].name = (char *)HDstrdup(name); + table->objs[new_obj].type = type; + table->objs[new_obj].nlinks = 0; + table->objs[new_obj].sizelinks = 0; + table->objs[new_obj].links = NULL; + } } /*------------------------------------------------------------------------- * Function: trav_table_init * - * Purpose: Initialize the table - * - * Return: void - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: November 4, 2002 + * Purpose: Initialize the table * + * Return: void *------------------------------------------------------------------------- */ - void trav_table_init(trav_table_t **tbl) { trav_table_t* table = (trav_table_t*) HDmalloc(sizeof(trav_table_t)); - - table->size = 0; - table->nobjs = 0; - table->objs = NULL; - + if(table) { + table->size = 0; + table->nobjs = 0; + table->objs = NULL; + } *tbl = table; } - /*------------------------------------------------------------------------- * Function: trav_table_free * - * Purpose: free table memory - * - * Return: void - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: November 4, 2002 + * Purpose: free table memory * + * Return: void *------------------------------------------------------------------------- */ - -void trav_table_free( trav_table_t *table ) +void trav_table_free(trav_table_t *table) { - if(table->objs) { - unsigned int i; + if(table) { + if(table->objs) { + unsigned int i; - for(i = 0; i < table->nobjs; i++) { - HDfree(table->objs[i].name ); - if(table->objs[i].nlinks) { - unsigned int j; + for(i = 0; i < table->nobjs; i++) { + HDfree(table->objs[i].name ); + if(table->objs[i].nlinks) { + unsigned int j; - for(j = 0; j < table->objs[i].nlinks; j++) - HDfree(table->objs[i].links[j].new_name); + for(j = 0; j < table->objs[i].nlinks; j++) + HDfree(table->objs[i].links[j].new_name); - HDfree(table->objs[i].links); - } /* end if */ - } /* end for */ - HDfree(table->objs); - } /* end if */ - HDfree(table); + HDfree(table->objs[i].links); + } /* end if */ + } /* end for */ + HDfree(table->objs); + } /* end if */ + HDfree(table); + } } static herr_t trav_attr(hid_t #ifndef H5TRAV_PRINT_SPACE -H5_ATTR_UNUSED + H5_ATTR_UNUSED #endif /* H5TRAV_PRINT_SPACE */ -obj, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *ainfo, void *_op_data) + obj, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *ainfo, void *_op_data) { trav_path_op_data_t *op_data = (trav_path_op_data_t *)_op_data; const char *buf = op_data->path; @@ -938,7 +854,7 @@ obj, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *ainfo, void *_op_da case H5S_SIMPLE: /* simple dataspace */ printf(" {"); - for (i=0; iu.val_size > 0) { - char *targbuf; + char *targbuf = NULL; const char *filename = NULL; const char *objname = NULL; @@ -1097,22 +1005,18 @@ trav_print_visit_lnk(const char *path, const H5L_info_t *linfo, void *udata) /*------------------------------------------------------------------------- * Function: h5trav_print * - * Purpose: Print information about the objects & links in the file - * - * Return: 0, -1 on error - * - * Programmer: Quincey Koziol, koziol@hdfgroup.org - * - * Date: September 6, 2007 + * Purpose: Print information about the objects & links in the file * + * Return: 0 on success, + * -1 on failure *------------------------------------------------------------------------- */ - int h5trav_print(hid_t fid) { trav_print_udata_t print_udata; /* User data for traversal */ trav_visitor_t print_visitor; /* Visitor structure for printing objects */ + int ret_value = SUCCEED; /* Init user data for printing */ print_udata.fid = fid; @@ -1124,9 +1028,10 @@ h5trav_print(hid_t fid) /* Traverse all objects in the file, visiting each object & link */ if(traverse(fid, "/", TRUE, TRUE, &print_visitor) < 0) - return -1; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "traverse failed"); - return 0; +done: + return ret_value; } @@ -1135,21 +1040,17 @@ h5trav_print(hid_t fid) * * Purpose: Generic traversal routine for visiting objects and links * - * Return: 0, -1 on error - * - * Programmer: Quincey Koziol, koziol@hdfgroup.org - * - * Date: November 6, 2007 - * + * Return: 0 on success, + * -1 on failure *------------------------------------------------------------------------- */ - int h5trav_visit(hid_t fid, const char *grp_name, hbool_t visit_start, hbool_t recurse, h5trav_obj_func_t visit_obj, h5trav_lnk_func_t visit_lnk, void *udata) { trav_visitor_t visitor; /* Visitor structure for objects */ + int ret_value = SUCCEED; /* Init visitor structure */ visitor.visit_obj = visit_obj; @@ -1158,9 +1059,10 @@ h5trav_visit(hid_t fid, const char *grp_name, hbool_t visit_start, /* Traverse all objects in the file, visiting each object & link */ if(traverse(fid, grp_name, visit_start, recurse, &visitor) < 0) - return -1; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "traverse failed"); - return 0; +done: + return ret_value; } /*------------------------------------------------------------------------- @@ -1168,19 +1070,15 @@ h5trav_visit(hid_t fid, const char *grp_name, hbool_t visit_start, * * Purpose: Add an symbolic link to visited data structure * - * Return: 0 on success, -1 on failure - * - * Programmer: Neil Fortner, nfortne2@hdfgroup.org - * Adapted from trav_addr_add in h5trav.c by Quincey Koziol - * - * Date: September 5, 2008 - * + * Return: 0 on success, + * -1 on failure *------------------------------------------------------------------------- */ herr_t symlink_visit_add(symlink_trav_t *visited, H5L_type_t type, const char *file, const char *path) { - size_t idx; /* Index of address to use */ + herr_t ret_value = SUCCEED; + size_t idx; /* Index of address to use */ /* Allocate space if necessary */ if(visited->nused == visited->nalloc) { @@ -1188,7 +1086,7 @@ symlink_visit_add(symlink_trav_t *visited, H5L_type_t type, const char *file, co visited->nalloc = MAX(1, visited->nalloc * 2); if(NULL == (tmp_ptr = HDrealloc(visited->objs, visited->nalloc * sizeof(symlink_trav_path_t)))) - return -1; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "visited data structure realloc failed"); visited->objs = (symlink_trav_path_t *)tmp_ptr; } /* end if */ @@ -1202,7 +1100,7 @@ symlink_visit_add(symlink_trav_t *visited, H5L_type_t type, const char *file, co if(type == H5L_TYPE_EXTERNAL) { if(NULL == (visited->objs[idx].file = HDstrdup(file))) { visited->nused--; - return -1; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "visited data structure name allocation failed"); } /* end if */ } /* end if */ @@ -1210,25 +1108,20 @@ symlink_visit_add(symlink_trav_t *visited, H5L_type_t type, const char *file, co visited->nused--; if(visited->objs[idx].file) HDfree (visited->objs[idx].file); - return -1; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "visited data structure path allocation failed"); } /* end if */ - return 0; +done: + return ret_value; } /* end symlink_visit_add() */ /*------------------------------------------------------------------------- * Function: symlink_is_visited * - * Purpose: Check if an symbolic link has already been visited - * - * Return: TRUE/FALSE - * - * Programmer: Neil Fortner, nfortne2@hdfgroup.org - * Adapted from trav_addr_visited in h5trav.c by Quincey Koziol - * - * Date: September 5, 2008 + * Purpose: Check if an symbolic link has already been visited * + * Return: TRUE/FALSE *------------------------------------------------------------------------- */ H5_ATTR_PURE hbool_t diff --git a/tools/src/h5repack/h5repack_copy.c b/tools/src/h5repack/h5repack_copy.c index 9fcf218..7c3dfa5 100644 --- a/tools/src/h5repack/h5repack_copy.c +++ b/tools/src/h5repack/h5repack_copy.c @@ -78,23 +78,21 @@ static herr_t walk_error_callback(H5_ATTR_UNUSED unsigned n, const H5E_error2_t * * Return: 0, ok, * -1 no - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: October, 23, 2003 - * *------------------------------------------------------------------------- */ int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options) { - int ret_value = 0; /* no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ - hid_t fidin; + int ret_value = 0; + hid_t fidin = -1; hid_t fidout = -1; - trav_table_t *travt = NULL; - hsize_t ub_size = 0; /* size of user block */ + hid_t fcpl_in = -1; /* file creation property list ID for input file */ + hid_t grp_in = -1; /* group ID */ + hid_t gcpl_in = -1; /* group creation property list */ hid_t fcpl = H5P_DEFAULT; /* file creation property list ID */ hid_t fapl = H5P_DEFAULT; /* file access property list ID */ + trav_table_t *travt = NULL; + hsize_t ub_size = 0; /* size of user block */ H5F_fspace_strategy_t set_strategy; /* Strategy to be set in outupt file */ hbool_t set_persist; /* Persist free-space status to be set in output file */ hsize_t set_threshold; /* Free-space section threshold to be set in output file */ @@ -114,10 +112,6 @@ int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options) /* get user block size and file space strategy/persist/threshold */ { - hid_t fcpl_in; /* file creation property list ID for input file */ - hid_t grp_in = -1; /* group ID */ - hid_t gcpl_in = -1; /* group creation property list */ - if ((fcpl_in = H5Fget_create_plist(fidin)) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fget_create_plist failed to retrieve file creation property list"); @@ -343,42 +337,26 @@ print_user_block(fnamein, fidin); /* init table */ trav_table_init(&travt); - /* get the list of objects in the file */ - if (h5trav_gettable(fidin, travt) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5trav_gettable failed"); - - /*------------------------------------------------------------------------- - * do the copy - *------------------------------------------------------------------------- - */ - if (do_copy_objects(fidin, fidout, travt, options) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "do_copy_objects from <%s> could not copy data to <%s>", fnamein, fnameout); - - /*------------------------------------------------------------------------- - * do the copy of referenced objects - * and create hard links - *------------------------------------------------------------------------- - */ - if (do_copy_refobjs(fidin, fidout, travt, options) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "do_copy_refobjs from <%s> could not copy data to <%s>", fnamein, fnameout); - - /*------------------------------------------------------------------------- - * close - *------------------------------------------------------------------------- - */ - - if (fapl > 0) - H5Pclose(fapl); - - if (fcpl > 0) - H5Pclose(fcpl); - - H5Fclose(fidin); - H5Fclose(fidout); - - /* free table */ - trav_table_free(travt); - travt = NULL; + if (travt) { + /* get the list of objects in the file */ + if (h5trav_gettable(fidin, travt) < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5trav_gettable failed"); + + /*------------------------------------------------------------------------- + * do the copy + *------------------------------------------------------------------------- + */ + if (do_copy_objects(fidin, fidout, travt, options) < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "do_copy_objects from <%s> could not copy data to <%s>", fnamein, fnameout); + + /*------------------------------------------------------------------------- + * do the copy of referenced objects + * and create hard links + *------------------------------------------------------------------------- + */ + if (do_copy_refobjs(fidin, fidout, travt, options) < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "do_copy_refobjs from <%s> could not copy data to <%s>", fnamein, fnameout); + } /*------------------------------------------------------------------------- * write only the input file user block if there is no user block file input @@ -389,17 +367,15 @@ print_user_block(fnamein, fidin); if (copy_user_block(fnamein, fnameout, ub_size) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not copy user block. Exiting..."); - return 0; - - /*------------------------------------------------------------------------- - * out - *------------------------------------------------------------------------- - */ - done: H5E_BEGIN_TRY { + H5Pclose(fcpl_in); + H5Pclose(gcpl_in); H5Pclose(fapl); H5Pclose(fcpl); + H5Gclose(grp_in); + H5Fclose(fidin); + H5Fclose(fidout); H5Fclose(fidin); H5Fclose(fidout); } H5E_END_TRY; @@ -416,7 +392,7 @@ done: * The size of hyperslab is limitted by H5TOOLS_BUFSIZE. * Return the hyperslab dimentions and size in byte. * - * Return: 0 - SUCCEED, -1 FAILED + * Return: 0 - SUCCEED, -1 FAILED * * Parameters: * dcpl_id : [IN] dataset creation property. @@ -426,8 +402,6 @@ done: * dims_hslab[] : [OUT] calculated hyperslab dimentions * * hslab_nbytes_p : [OUT] total byte of the hyperslab * - * Programmer: Jonathan Kim - * Date: Feburary, 2012 * Update: * The hyperslab calucation would be depend on if the dataset is chunked * or not. @@ -441,25 +415,23 @@ done: * the boundary would be dataset's dims. * * The calulation starts from the last dimention (h5dump dims output). - * - * Note: - * Added for JIRA HDFFV-7862. *-----------------------------------------*/ -int Get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[], +int +Get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[], size_t size_datum, hsize_t dims_hslab[], hsize_t * hslab_nbytes_p) { - int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ + int ret_value = 0; int k; H5D_layout_t dset_layout; int rank_chunk; hsize_t dims_chunk[H5S_MAX_RANK]; hsize_t size_chunk = 1; - hsize_t nchunk_fit; /* number of chunks that fits in hyperslab buffer (H5TOOLS_BUFSIZE) */ - hsize_t ndatum_fit; /* number of dataum that fits in hyperslab buffer (H5TOOLS_BUFSIZE) */ + hsize_t nchunk_fit; /* number of chunks that fits in hyperslab buffer (H5TOOLS_BUFSIZE) */ + hsize_t ndatum_fit; /* number of dataum that fits in hyperslab buffer (H5TOOLS_BUFSIZE) */ hsize_t chunk_dims_map[H5S_MAX_RANK]; /* mapped chunk dimentions */ - hsize_t hs_dims_map[H5S_MAX_RANK]; /* mapped hyperslab dimentions */ - hsize_t hslab_nbytes; /* size of hyperslab in byte */ + hsize_t hs_dims_map[H5S_MAX_RANK]; /* mapped hyperslab dimentions */ + hsize_t hslab_nbytes; /* size of hyperslab in byte */ /* init to set as size of a data element */ hslab_nbytes = size_datum; @@ -572,24 +544,9 @@ done: /*------------------------------------------------------------------------- * Function: do_copy_objects * - * Purpose: duplicate all HDF5 objects in the file - * - * Return: 0, ok, -1 no - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: October, 23, 2003 - * - * Modifications: - * - * July 2004: Introduced the extra EC or NN option for SZIP - * - * December 2004: Added a check for H5Dcreate; if the dataset cannot be created - * with the requested filter, use the input one - * - * October 2006: Read/write using the file type by default. + * Purpose: duplicate all HDF5 objects in the file * - * October 2006: Read by hyperslabs for big datasets. + * Return: 0, ok, -1 no * * A threshold of H5TOOLS_MALLOCSIZE (128 MB) is the limit upon which I/O hyperslab is done * i.e., if the memory needed to read a dataset is greater than this limit, @@ -630,31 +587,6 @@ done: * in (2) is that, when using the strip mine size, it assures that the "remaining" part * of the dataset that does not fill an entire strip mine is processed. * - * November 2006: Use H5Ocopy in the copy of objects. The logic for using - * H5Ocopy or not is if a change of filters or layout is requested by the user - * then use read/write else use H5Ocopy. - * - * May, 1, 2008: Add a printing of the compression ratio of old size / new size - * - * Feburary 2012: improve Read/Write by hyperslabs for big datasets. - * Programmer: Jonathan Kim - * - * A threshold of H5TOOLS_MALLOCSIZE is the limit upon which I/O hyperslab is done - * i.e., if the memory needed to read a dataset is greater than this limit, - * then hyperslab I/O is done instead of one operation I/O - * For each dataset, the memory needed is calculated according to - * - * memory needed = number of elements * size of each element - * - * if the memory needed is lower than H5TOOLS_MALLOCSIZE, then the following operations - * are done - * - * H5Dread( input_dataset ) - * H5Dwrite( output_dataset ) - * - * with all elements in the datasets selected. If the memory needed is greater than - * H5TOOLS_MALLOCSIZE, then the following operations are done instead: - * * 1. figure out a hyperslab (dimentions) and size (refer to Get_hyperslab()). * 2. Calculate the hyperslab selections as the selection is moving forward. * Selection would be same as the hyperslab except for the remaining edge portion @@ -666,7 +598,7 @@ done: int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *options) /* repack options */ { - int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ + int ret_value = 0; hid_t grp_in = -1; /* group ID */ hid_t grp_out = -1; /* group ID */ hid_t dset_in = -1; /* read dataset ID */ @@ -1310,10 +1242,10 @@ done: * Function: print_dataset_info * * Purpose: print name, filters, percentage compression of a dataset - * *------------------------------------------------------------------------- */ -static void print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int pr) +static void +print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int pr) { char strfilter[255]; #if defined (PRINT_DEBUG ) @@ -1325,7 +1257,7 @@ static void print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int p unsigned cd_values[20]; /* filter client data values */ size_t cd_nelmts; /* filter client number of values */ char f_objname[256]; /* filter objname */ - int i; + int i; HDstrcpy(strfilter, "\0"); @@ -1417,19 +1349,15 @@ static void print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int p /*------------------------------------------------------------------------- * Function: copy_user_block * - * Purpose: copy user block from one file to another - * - * Return: 0, ok, -1 no - * - * Programmer: Peter Cao - * - * Date: October, 25, 2007 + * Purpose: copy user block from one file to another * + * Return: 0, ok, -1 no *------------------------------------------------------------------------- */ -static int copy_user_block(const char *infile, const char *outfile, hsize_t size) +static int +copy_user_block(const char *infile, const char *outfile, hsize_t size) { - int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ + int ret_value = 0; int infid = -1, outfid = -1; /* File descriptors */ /* User block must be any power of 2 equal to 512 or greater (512, 1024, 2048, etc.) */ @@ -1491,21 +1419,17 @@ done: /*------------------------------------------------------------------------- * Function: print_user_block * - * Purpose: print user block - * - * Return: 0, ok, -1 no - * - * Programmer: Pedro Vicente - * - * Date: August, 20, 2008 + * Purpose: print user block * + * Return: 0, ok, -1 no *------------------------------------------------------------------------- */ #if defined (H5REPACK_DEBUG_USER_BLOCK) static -void print_user_block(const char *filename, hid_t fid) +void +print_user_block(const char *filename, hid_t fid) { - int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ + int ret_value = 0; int fh; /* file handle */ hsize_t ub_size; /* user block size */ hsize_t size; /* size read */ -- cgit v0.12 From 448217e7e3f15ed6aee5595a6f8bbe7db0abcb56 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 16 Oct 2017 09:19:41 -0500 Subject: HDFFV-10297 Fix compiler compaliants --- tools/lib/h5diff.c | 12 ++++++++---- tools/lib/h5tools_dump.c | 3 +-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c index 285ec60..a584bf2 100644 --- a/tools/lib/h5diff.c +++ b/tools/lib/h5diff.c @@ -1061,11 +1061,13 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, /* make full path for obj1 */ #ifdef H5_HAVE_ASPRINTF /* Use the asprintf() routine, since it does what we're trying to do below */ - if(HDasprintf(&obj1_fullpath, "%s%s", grp1_path, table->objs[i].name) < 0) + if(HDasprintf(&obj1_fullpath, "%s%s", grp1_path, table->objs[i].name) < 0) { HERROR(FAIL, H5E_tools_min_id_g, "name buffer allocation failed"); + } #else /* H5_HAVE_ASPRINTF */ - if((obj1_fullpath = (char*)HDmalloc(HDstrlen(grp1_path) + HDstrlen(table->objs[i].name) + 1)) == NULL) + if((obj1_fullpath = (char*)HDmalloc(HDstrlen(grp1_path) + HDstrlen(table->objs[i].name) + 1)) == NULL) { HERROR(FAIL, H5E_tools_min_id_g, "name buffer allocation failed"); + } else { HDstrcpy(obj1_fullpath, grp1_path); HDstrcat(obj1_fullpath, table->objs[i].name); @@ -1075,11 +1077,13 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, /* make full path for obj2 */ #ifdef H5_HAVE_ASPRINTF /* Use the asprintf() routine, since it does what we're trying to do below */ - if(HDasprintf(&obj2_fullpath, "%s%s", grp2_path, table->objs[i].name) < 0) + if(HDasprintf(&obj2_fullpath, "%s%s", grp2_path, table->objs[i].name) < 0) { HERROR(FAIL, H5E_tools_min_id_g, "name buffer allocation failed"); + } #else /* H5_HAVE_ASPRINTF */ - if((obj2_fullpath = (char*)HDmalloc(HDstrlen(grp2_path) + HDstrlen(table->objs[i].name) + 1)) == NULL) + if((obj2_fullpath = (char*)HDmalloc(HDstrlen(grp2_path) + HDstrlen(table->objs[i].name) + 1)) == NULL) { HERROR(FAIL, H5E_tools_min_id_g, "name buffer allocation failed"); + } else { HDstrcpy(obj2_fullpath, grp2_path); HDstrcat(obj2_fullpath, table->objs[i].name); diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c index 7c88151..f987296 100644 --- a/tools/lib/h5tools_dump.c +++ b/tools/lib/h5tools_dump.c @@ -642,8 +642,7 @@ h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id, alloc_size = nblocks * ndims * 2 * sizeof(ptdata[0]); HDassert(alloc_size == (hsize_t) ((size_t) alloc_size)); /*check for overflow*/ - if((ptdata = (hsize_t*) HDmalloc((size_t) alloc_size)) == NULL) - { + if((ptdata = (hsize_t*) HDmalloc((size_t) alloc_size)) == NULL) { HERROR(H5E_tools_g, H5E_tools_min_id_g, "Could not allocate buffer for ptdata"); HGOTO_DONE(dimension_break); } -- cgit v0.12 From e0bbff9d46eabbbc3a6d63f5b2f5e2f7ca0ed217 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 16 Oct 2017 10:56:54 -0500 Subject: Fix VS2012 declaration error --- tools/lib/h5diff_attr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/lib/h5diff_attr.c b/tools/lib/h5diff_attr.c index f381393..64038f3 100644 --- a/tools/lib/h5diff_attr.c +++ b/tools/lib/h5diff_attr.c @@ -345,12 +345,12 @@ hsize_t diff_attr(hid_t loc1_id, hsize_t nfound_total = 0; int j; - /* Initialize error status */ - options->err_stat = 1; - table_attrs_t *match_list_attrs = NULL; h5difftrace("diff_attr start\n"); + /* Initialize error status */ + options->err_stat = 1; + if(build_match_list_attrs(loc1_id, loc2_id, &match_list_attrs, options) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "build_match_list_attrs failed"); -- cgit v0.12 From 2cbdf46cb9ecd93803aaf5dca22f1f847e505bee Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 16 Oct 2017 17:26:23 -0500 Subject: HDFFV-10297 add h5copy test and fix h5diff errors --- MANIFEST | 5 + tools/lib/h5diff.c | 212 ++--- tools/lib/h5diff.h | 22 +- tools/lib/h5diff_array.c | 1005 +++++++++++----------- tools/lib/h5diff_attr.c | 32 +- tools/lib/h5diff_dset.c | 77 +- tools/lib/h5tools_filters.c | 2 +- tools/lib/ph5diff.h | 2 +- tools/src/h5diff/h5diff_common.c | 82 +- tools/src/h5diff/h5diff_common.h | 4 +- tools/src/h5diff/h5diff_main.c | 12 +- tools/src/h5diff/ph5diff_main.c | 18 +- tools/src/h5repack/h5repack.c | 12 +- tools/test/h5copy/CMakeLists.txt | 48 +- tools/test/h5copy/CMakeTests.cmake | 122 ++- tools/test/h5copy/dynlib_copy.c | 89 ++ tools/test/h5copy/testfiles/tudfilter.h5 | Bin 0 -> 4816 bytes tools/test/h5copy/testfiles/tudfilter.h5.txt | 2 + tools/test/h5copy/testfiles/tudfilter.h5_ERR.txt | 2 + tools/test/h5copy/testfiles/tudfilter2.h5 | Bin 0 -> 4816 bytes tools/test/h5diff/testfiles/h5diff_454_ERR.err | 2 +- tools/test/h5diff/testfiles/h5diff_454_ERR.txt | 2 +- tools/test/h5diff/testfiles/h5diff_455_ERR.err | 2 +- tools/test/h5diff/testfiles/h5diff_455_ERR.txt | 2 +- tools/test/h5diff/testfiles/h5diff_457_ERR.err | 2 +- tools/test/h5diff/testfiles/h5diff_457_ERR.txt | 2 +- tools/test/h5diff/testfiles/h5diff_458_ERR.err | 2 +- tools/test/h5diff/testfiles/h5diff_458_ERR.txt | 2 +- tools/test/h5diff/testfiles/h5diff_459_ERR.err | 2 +- tools/test/h5diff/testfiles/h5diff_459_ERR.txt | 2 +- 30 files changed, 1002 insertions(+), 766 deletions(-) create mode 100644 tools/test/h5copy/dynlib_copy.c create mode 100644 tools/test/h5copy/testfiles/tudfilter.h5 create mode 100644 tools/test/h5copy/testfiles/tudfilter.h5.txt create mode 100644 tools/test/h5copy/testfiles/tudfilter.h5_ERR.txt create mode 100644 tools/test/h5copy/testfiles/tudfilter2.h5 diff --git a/MANIFEST b/MANIFEST index f194f72..0e59ba0 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1433,6 +1433,7 @@ ./tools/test/h5copy/Makefile.am ./tools/test/h5copy/h5copygentest.c ./tools/test/h5copy/testh5copy.sh.in +./tools/test/h5copy/dynlib_copy.c ./tools/lib/Makefile.am @@ -2523,6 +2524,10 @@ ./tools/test/h5copy/testfiles/h5copy_misc1.out ./tools/test/h5copy/testfiles/h5copytst_new.h5 ./tools/test/h5copy/testfiles/h5copytst_new.out.ls +./tools/test/h5diff/testfiles/tudfilter.h5 +./tools/test/h5diff/testfiles/tudfilter2.h5 +./tools/test/h5diff/testfiles/tudfilter.h5.txt +./tools/test/h5diff/testfiles/tudfilter.h5_ERR.txt # test files for h5mkgrp ./tools/testfiles/h5mkgrp_nested_p.ls diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c index a584bf2..ab5d125 100644 --- a/tools/lib/h5diff.c +++ b/tools/lib/h5diff.c @@ -27,9 +27,9 @@ *------------------------------------------------------------------------- */ H5_ATTR_PURE int -print_objname (diff_opt_t * options, hsize_t nfound) +print_objname (diff_opt_t * opts, hsize_t nfound) { - return ((options->m_verbose || nfound) && !options->m_quiet) ? 1 : 0; + return ((opts->m_verbose || nfound) && !opts->m_quiet) ? 1 : 0; } /*------------------------------------------------------------------------- @@ -72,9 +72,9 @@ do_print_attrname (const char *attr, const char *path1, const char *path2) *------------------------------------------------------------------------- */ static int -print_warn(diff_opt_t *options) +print_warn(diff_opt_t *opts) { - return ((options->m_verbose)) ? 1: 0; + return ((opts->m_verbose)) ? 1: 0; } @@ -135,23 +135,23 @@ print_incoming_data(void) * 0 : Not valid *------------------------------------------------------------------------*/ static int -is_valid_options(diff_opt_t *options) +is_valid_options(diff_opt_t *opts) { int ret_value = 1; /* init to valid */ /*----------------------------------------------- * no -q(quiet) with -v (verbose) or -r (report) */ - if(options->m_quiet && (options->m_verbose || options->m_report)) { + if(opts->m_quiet && (opts->m_verbose || opts->m_report)) { parallel_print("Error: -q (quiet mode) cannot be added to verbose or report modes\n"); - options->err_stat = 1; + opts->err_stat = 1; HGOTO_DONE(0); } /* ------------------------------------------------------- * only allow --no-dangling-links along with --follow-symlinks */ - if(options->no_dangle_links && !options->follow_links) { + if(opts->no_dangle_links && !opts->follow_links) { parallel_print("Error: --no-dangling-links must be used along with --follow-symlinks option.\n"); - options->err_stat = 1; + opts->err_stat = 1; HGOTO_DONE(0); } @@ -170,18 +170,18 @@ done: * 0 - not excluded path *------------------------------------------------------------------------*/ static int -is_exclude_path (char * path, h5trav_type_t type, diff_opt_t *options) +is_exclude_path (char * path, h5trav_type_t type, diff_opt_t *opts) { struct exclude_path_list * exclude_path_ptr; int ret_cmp; int ret_value = 0; /* check if exclude path option is given */ - if (!options->exclude_path) + if (!opts->exclude_path) HGOTO_DONE(0); /* assign to local exclude list pointer */ - exclude_path_ptr = options->exclude; + exclude_path_ptr = opts->exclude; /* search objects in exclude list */ while (NULL != exclude_path_ptr) { @@ -232,9 +232,9 @@ done: * Purpose: free exclude object list from diff options *------------------------------------------------------------------------*/ static void -free_exclude_path_list(diff_opt_t *options) +free_exclude_path_list(diff_opt_t *opts) { - struct exclude_path_list *curr = options->exclude; + struct exclude_path_list *curr = opts->exclude; struct exclude_path_list *next; while (NULL != curr) { @@ -260,7 +260,7 @@ free_exclude_path_list(diff_opt_t *options) *------------------------------------------------------------------------*/ static void build_match_list (const char *objname1, trav_info_t *info1, const char *objname2, trav_info_t *info2, - trav_table_t ** table_out, diff_opt_t *options) + trav_table_t ** table_out, diff_opt_t *opts) { size_t curr1 = 0; size_t curr2 = 0; @@ -306,7 +306,7 @@ build_match_list (const char *objname1, trav_info_t *info1, const char *objname2 /* criteria is string compare */ cmp = HDstrcmp(path1_lp, path2_lp); if(cmp == 0) { - if(!is_exclude_path(path1_lp, type1_l, options)) { + if(!is_exclude_path(path1_lp, type1_l, opts)) { infile[0] = 1; infile[1] = 1; trav_table_addflags(infile, path1_lp, info1->paths[curr1].type, table); @@ -322,7 +322,7 @@ build_match_list (const char *objname1, trav_info_t *info1, const char *objname2 curr2++; } /* end if */ else if(cmp < 0) { - if(!is_exclude_path(path1_lp, type1_l, options)) { + if(!is_exclude_path(path1_lp, type1_l, opts)) { infile[0] = 1; infile[1] = 0; trav_table_addflags(infile, path1_lp, info1->paths[curr1].type, table); @@ -330,7 +330,7 @@ build_match_list (const char *objname1, trav_info_t *info1, const char *objname2 curr1++; } /* end else-if */ else { - if (!is_exclude_path(path2_lp, type2_l, options)) { + if (!is_exclude_path(path2_lp, type2_l, opts)) { infile[0] = 0; infile[1] = 1; trav_table_addflags(infile, path2_lp, info2->paths[curr2].type, table); @@ -346,7 +346,7 @@ build_match_list (const char *objname1, trav_info_t *info1, const char *objname2 path1_lp = (info1->paths[curr1].path) + path1_offset; type1_l = info1->paths[curr1].type; - if(!is_exclude_path(path1_lp, type1_l, options)) { + if(!is_exclude_path(path1_lp, type1_l, opts)) { trav_table_addflags(infile, path1_lp, info1->paths[curr1].type, table); } curr1++; @@ -359,13 +359,13 @@ build_match_list (const char *objname1, trav_info_t *info1, const char *objname2 path2_lp = (info2->paths[curr2].path) + path2_offset; type2_l = info2->paths[curr2].type; - if (!is_exclude_path(path2_lp, type2_l, options)) { + if (!is_exclude_path(path2_lp, type2_l, opts)) { trav_table_addflags(infile, path2_lp, info2->paths[curr2].type, table); } curr2++; } /* end while */ - free_exclude_path_list (options); + free_exclude_path_list (opts); *table_out = table; h5difftrace("build_match_list finish\n"); @@ -764,7 +764,7 @@ h5diff(const char *fname1, if (l_ret1 != 0 || l_ret2 != 0) { nfound++; print_found(nfound); - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5tools_get_symlink_info error"); + HGOTO_DONE(0); } } } @@ -804,10 +804,10 @@ h5diff(const char *fname1, else { if(opts->m_verbose) parallel_print("obj2 <%s> is a dangling link.\n", obj2fullname); - if (l_ret1 != 0 || l_ret2 != 0) { + if (l_ret1 != 0 || l_ret2 != 0) { nfound++; print_found(nfound); - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5tools_get_symlink_info error"); + HGOTO_DONE(0); } } } @@ -842,7 +842,7 @@ h5diff(const char *fname1, /* if no danglink links */ if (l_ret1 > 0 && l_ret2 > 0) if (h5tools_is_obj_same(file1_id, obj1fullname, file2_id, obj2fullname)!=0) - HGOTO_ERROR(opts->err_stat, H5E_tools_min_id_g, "Same object"); + HGOTO_DONE(0); } both_objs_grp = (obj1type == H5TRAV_TYPE_GROUP && obj2type == H5TRAV_TYPE_GROUP); @@ -903,8 +903,7 @@ h5diff(const char *fname1, /*------------------------------------------------------ * print the list */ - if(opts->m_verbose) - { + if(opts->m_verbose) { unsigned u; parallel_print("\n"); @@ -927,7 +926,7 @@ h5diff(const char *fname1, file2_id, obj2fullname, info2_lp, match_list, opts); - opts->err_stat = 1; /* success status */ + opts->err_stat = 0; /* success status */ done: #ifdef H5_HAVE_PARALLEL @@ -991,7 +990,7 @@ done: hsize_t diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, hid_t file2_id, const char *grp2, trav_info_t *info2, - trav_table_t *table, diff_opt_t *options) + trav_table_t *table, diff_opt_t *opts) { hsize_t nfound = 0; unsigned i; @@ -1023,17 +1022,17 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, */ /* not valid compare used when --exclude-path option is used */ - if (!options->exclude_path) { + if (!opts->exclude_path) { /* number of different objects */ if (info1->nused != info2->nused) { - options->contents = 0; + opts->contents = 0; } } /* objects in one file and not the other */ for(i = 0; i < table->nobjs; i++) { if(table->objs[i].flags[0] != table->objs[i].flags[1]) { - options->contents = 0; + opts->contents = 0; break; } } @@ -1073,6 +1072,7 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, HDstrcat(obj1_fullpath, table->objs[i].name); } #endif /* H5_HAVE_ASPRINTF */ + h5diffdebug2("diff_match path1 - %s\n", obj1_fullpath); /* make full path for obj2 */ #ifdef H5_HAVE_ASPRINTF @@ -1089,6 +1089,7 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, HDstrcat(obj2_fullpath, table->objs[i].name); } #endif /* H5_HAVE_ASPRINTF */ + h5diffdebug2("diff_match path2 - %s\n", obj2_fullpath); /* get index to figure out type of the object in file1 */ while(info1->paths[idx1].path && (HDstrcmp(obj1_fullpath, info1->paths[idx1].path) != 0)) @@ -1102,11 +1103,11 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, argdata.type[1] = info2->paths[idx2].type; argdata.is_same_trgobj = table->objs[i].is_same_trgobj; - options->cmn_objs = 1; + opts->cmn_objs = 1; if(!g_Parallel) { nfound += diff(file1_id, obj1_fullpath, file2_id, obj2_fullpath, - options, &argdata); + opts, &argdata); } /* end if */ #ifdef H5_HAVE_PARALLEL else { @@ -1131,7 +1132,7 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, /* set args struct to pass */ HDstrcpy(args.name1, obj1_fullpath); HDstrcpy(args.name2, obj2_fullpath); - args.options = *options; + args.opts = *opts; args.argdata.type[0] = info1->paths[idx1].type; args.argdata.type[1] = info2->paths[idx2].type; args.argdata.is_same_trgobj = table->objs[i].is_same_trgobj; @@ -1148,7 +1149,7 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, workerTasks[Status.MPI_SOURCE - 1] = 1; MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &Status); nfound += nFoundbyWorker.nfound; - options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; + opts->not_cmp = opts->not_cmp | nFoundbyWorker.not_cmp; busyTasks--; } /* end if */ @@ -1165,7 +1166,7 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, workerTasks[Status.MPI_SOURCE - 1] = 1; MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); nfound += nFoundbyWorker.nfound; - options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; + opts->not_cmp = opts->not_cmp | nFoundbyWorker.not_cmp; busyTasks--; havePrintToken = 1; } /* end if */ @@ -1217,7 +1218,7 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); havePrintToken = 1; nfound += nFoundbyWorker.nfound; - options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; + opts->not_cmp = opts->not_cmp | nFoundbyWorker.not_cmp; /* send this task the work unit. */ MPI_Send(&args, sizeof(args), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_ARGS, MPI_COMM_WORLD); } /* end if */ @@ -1231,7 +1232,7 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, if(Status.MPI_TAG == MPI_TAG_DONE) { MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &Status); nfound += nFoundbyWorker.nfound; - options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; + opts->not_cmp = opts->not_cmp | nFoundbyWorker.not_cmp; MPI_Send(&args, sizeof(args), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_ARGS, MPI_COMM_WORLD); } /* end if */ else if(Status.MPI_TAG == MPI_TAG_TOK_REQUEST) { @@ -1248,7 +1249,7 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); nfound += nFoundbyWorker.nfound; - options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; + opts->not_cmp = opts->not_cmp | nFoundbyWorker.not_cmp; MPI_Send(&args, sizeof(args), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_ARGS, MPI_COMM_WORLD); } /* end else-if */ else { @@ -1276,7 +1277,7 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, if(Status.MPI_TAG == MPI_TAG_DONE) { MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &Status); nfound += nFoundbyWorker.nfound; - options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; + opts->not_cmp = opts->not_cmp | nFoundbyWorker.not_cmp; busyTasks--; } /* end if */ else if(Status.MPI_TAG == MPI_TAG_TOK_REQUEST) { @@ -1294,7 +1295,7 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); nfound += nFoundbyWorker.nfound; - options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; + opts->not_cmp = opts->not_cmp | nFoundbyWorker.not_cmp; busyTasks--; } /* end if */ /* someone else must have it...wait for them to return it, then give it to the task that just asked for it. */ @@ -1311,7 +1312,7 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); nfound += nFoundbyWorker.nfound; - options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; + opts->not_cmp = opts->not_cmp | nFoundbyWorker.not_cmp; busyTasks--; MPI_Send(NULL, 0, MPI_BYTE, source, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD); } /* end else */ @@ -1319,7 +1320,7 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, else if(Status.MPI_TAG == MPI_TAG_TOK_RETURN) { MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); nfound += nFoundbyWorker.nfound; - options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; + opts->not_cmp = opts->not_cmp | nFoundbyWorker.not_cmp; busyTasks--; havePrintToken = 1; } /* end else-if */ @@ -1353,7 +1354,7 @@ out: /* free table */ if (table) trav_table_free(table); - h5difftrace("diff_match finish\n"); + h5diffdebug2("diff_match finish:%d\n", nfound); return nfound; } @@ -1377,7 +1378,7 @@ diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, - diff_opt_t * options, + diff_opt_t * opts, diff_args_t *argdata) { int ret_value = 0; @@ -1400,14 +1401,14 @@ diff(hid_t file1_id, h5difftrace("diff start\n"); /*init error status */ - options->err_stat = 1; + opts->err_stat = 1; /*init link info struct */ HDmemset(&linkinfo1, 0, sizeof(h5tool_link_info_t)); HDmemset(&linkinfo2, 0, sizeof(h5tool_link_info_t)); /* pass how to handle printing warnings to linkinfo option */ - if(print_warn(options)) + if(print_warn(opts)) linkinfo1.opt.msg_mode = linkinfo2.opt.msg_mode = 1; /* for symbolic links, take care follow symlink and no dangling link @@ -1421,14 +1422,14 @@ diff(hid_t file1_id, */ /* target object1 - get type and name */ - if ((ret_value = H5tools_get_symlink_info(file1_id, path1, &linkinfo1, options->follow_links)) < 0) + if ((ret_value = H5tools_get_symlink_info(file1_id, path1, &linkinfo1, opts->follow_links)) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5tools_get_symlink_info failed"); /* dangling link */ if (ret_value == 0) { - if (options->no_dangle_links) { + if (opts->no_dangle_links) { /* dangling link is error */ - if(options->m_verbose) + if(opts->m_verbose) parallel_print("Warning: <%s> is a dangling link.\n", path1); HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "dangling link is error"); } @@ -1437,13 +1438,13 @@ diff(hid_t file1_id, } /* target object2 - get type and name */ - if ((ret_value = H5tools_get_symlink_info(file2_id, path2, &linkinfo2, options->follow_links)) < 0) + if ((ret_value = H5tools_get_symlink_info(file2_id, path2, &linkinfo2, opts->follow_links)) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5tools_get_symlink_info failed"); /* dangling link */ if (ret_value == 0) { - if (options->no_dangle_links) { + if (opts->no_dangle_links) { /* dangling link is error */ - if(options->m_verbose) + if(opts->m_verbose) parallel_print("Warning: <%s> is a dangling link.\n", path2); HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "dangling link is error"); } @@ -1453,12 +1454,12 @@ diff(hid_t file1_id, /* found dangling link */ if (is_dangle_link1 || is_dangle_link2) { - options->err_stat = 0; + opts->err_stat = 0; HGOTO_DONE(0); } /* follow symbolic link option */ - if (options->follow_links) { + if (opts->follow_links) { if (linkinfo1.linfo.type == H5L_TYPE_SOFT || linkinfo1.linfo.type == H5L_TYPE_EXTERNAL) argdata->type[0] = (h5trav_type_t)linkinfo1.trg_type; @@ -1469,16 +1470,16 @@ diff(hid_t file1_id, } /* if objects are not the same type */ if (argdata->type[0] != argdata->type[1]) { - if (options->m_verbose||options->m_list_not_cmp) { + if (opts->m_verbose||opts->m_list_not_cmp) { parallel_print("Not comparable: <%s> is of type %s and <%s> is of type %s\n", path1, get_type(argdata->type[0]), path2, get_type(argdata->type[1])); } - options->not_cmp = 1; + opts->not_cmp = 1; /* TODO: will need to update non-comparable is different - * options->contents = 0; + * opts->contents = 0; */ - options->err_stat = 0; + opts->err_stat = 0; HGOTO_DONE(0); } else /* now both object types are same */ @@ -1497,41 +1498,41 @@ diff(hid_t file1_id, is_hard_link = (object_type == H5TRAV_TYPE_DATASET || object_type == H5TRAV_TYPE_NAMED_DATATYPE || object_type == H5TRAV_TYPE_GROUP); - if (options->follow_links || is_hard_link) { + if (opts->follow_links || is_hard_link) { /* print information is only verbose option is used */ - if(options->m_verbose || options->m_report) { + if(opts->m_verbose || opts->m_report) { switch(object_type) { case H5TRAV_TYPE_DATASET: - do_print_objname("dataset", path1, path2, options); + do_print_objname("dataset", path1, path2, opts); break; case H5TRAV_TYPE_NAMED_DATATYPE: - do_print_objname("datatype", path1, path2, options); + do_print_objname("datatype", path1, path2, opts); break; case H5TRAV_TYPE_GROUP: - do_print_objname("group", path1, path2, options); + do_print_objname("group", path1, path2, opts); break; case H5TRAV_TYPE_LINK: - do_print_objname("link", path1, path2, options); + do_print_objname("link", path1, path2, opts); break; case H5TRAV_TYPE_UDLINK: if(linkinfo1.linfo.type == H5L_TYPE_EXTERNAL && linkinfo2.linfo.type == H5L_TYPE_EXTERNAL) - do_print_objname("external link", path1, path2, options); + do_print_objname("external link", path1, path2, opts); else - do_print_objname ("user defined link", path1, path2, options); + do_print_objname ("user defined link", path1, path2, opts); break; case H5TRAV_TYPE_UNKNOWN: default: parallel_print("Comparison not supported: <%s> and <%s> are of type %s\n", path1, path2, get_type(object_type) ); - options->not_cmp = 1; + opts->not_cmp = 1; break; } /* switch(type)*/ print_found(nfound); - } /* if(options->m_verbose || options->m_report) */ + } /* if(opts->m_verbose || opts->m_report) */ /* exact same, so comparison is done */ - options->err_stat = 0; + opts->err_stat = 0; HGOTO_DONE(0); } } @@ -1547,24 +1548,25 @@ diff(hid_t file1_id, if((dset2_id = H5Dopen2(file2_id, path2, H5P_DEFAULT)) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed"); /* verbose (-v) and report (-r) mode */ - if(options->m_verbose || options->m_report) { - do_print_objname("dataset", path1, path2, options); - nfound = diff_dataset(file1_id, file2_id, path1, path2, options); + if(opts->m_verbose || opts->m_report) { + do_print_objname("dataset", path1, path2, opts); + nfound = diff_dataset(file1_id, file2_id, path1, path2, opts); print_found(nfound); } /* quiet mode (-q), just count differences */ - else if(options->m_quiet) { - nfound = diff_dataset(file1_id, file2_id, path1, path2, options); + else if(opts->m_quiet) { + nfound = diff_dataset(file1_id, file2_id, path1, path2, opts); } /* the rest (-c, none, ...) */ else { - nfound = diff_dataset(file1_id, file2_id, path1, path2, options); + nfound = diff_dataset(file1_id, file2_id, path1, path2, opts); /* print info if difference found */ if (nfound) { - do_print_objname("dataset", path1, path2, options); + do_print_objname("dataset", path1, path2, opts); print_found(nfound); } } + h5diffdebug2("diff after dataset:%d\n", nfound); /*--------------------------------------------------------- * compare attributes @@ -1573,7 +1575,7 @@ diff(hid_t file1_id, *--------------------------------------------------------- */ if(path1) - nfound += diff_attr(dset1_id, dset2_id, path1, path2, options); + nfound += diff_attr(dset1_id, dset2_id, path1, path2, opts); if(H5Dclose(dset1_id) < 0) @@ -1598,11 +1600,11 @@ diff(hid_t file1_id, /* if H5Tequal is > 0 then the datatypes refer to the same datatype */ nfound = (ret_value > 0) ? 0 : 1; - if(print_objname(options,nfound)) - do_print_objname("datatype", path1, path2, options); + if(print_objname(opts, nfound)) + do_print_objname("datatype", path1, path2, opts); /* always print the number of differences found in verbose mode */ - if(options->m_verbose) + if(opts->m_verbose) print_found(nfound); /*----------------------------------------------------------------- @@ -1612,7 +1614,7 @@ diff(hid_t file1_id, *----------------------------------------------------------------- */ if(path1) - nfound += diff_attr(type1_id, type2_id, path1, path2, options); + nfound += diff_attr(type1_id, type2_id, path1, path2, opts); if(H5Tclose(type1_id) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed"); @@ -1625,11 +1627,11 @@ diff(hid_t file1_id, *---------------------------------------------------------------------- */ case H5TRAV_TYPE_GROUP: - if(print_objname(options, nfound)) - do_print_objname("group", path1, path2, options); + if(print_objname(opts, nfound)) + do_print_objname("group", path1, path2, opts); /* always print the number of differences found in verbose mode */ - if(options->m_verbose) + if(opts->m_verbose) print_found(nfound); if((grp1_id = H5Gopen2(file1_id, path1, H5P_DEFAULT)) < 0) @@ -1644,7 +1646,7 @@ diff(hid_t file1_id, *----------------------------------------------------------------- */ if(path1) - nfound += diff_attr(grp1_id, grp2_id, path1, path2, options); + nfound += diff_attr(grp1_id, grp2_id, path1, path2, opts); if(H5Gclose(grp1_id) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gclose failed"); @@ -1664,11 +1666,11 @@ diff(hid_t file1_id, /* if the target link name is not same then the links are "different" */ nfound = (ret_value != 0) ? 1 : 0; - if(print_objname(options, nfound)) - do_print_objname("link", path1, path2, options); + if(print_objname(opts, nfound)) + do_print_objname("link", path1, path2, opts); /* always print the number of differences found in verbose mode */ - if(options->m_verbose) + if(opts->m_verbose) print_found(nfound); } @@ -1695,8 +1697,8 @@ diff(hid_t file1_id, */ nfound = (ret_value != 0) ? 1 : 0; - if(print_objname(options, nfound)) - do_print_objname("external link", path1, path2, options); + if(print_objname(opts, nfound)) + do_print_objname("external link", path1, path2, opts); } /* end if */ else { @@ -1713,26 +1715,26 @@ diff(hid_t file1_id, else nfound = 0; - if (print_objname (options, nfound)) - do_print_objname ("user defined link", path1, path2, options); + if (print_objname (opts, nfound)) + do_print_objname ("user defined link", path1, path2, opts); } /* end else */ /* always print the number of differences found in verbose mode */ - if(options->m_verbose) + if(opts->m_verbose) print_found(nfound); } break; case H5TRAV_TYPE_UNKNOWN: default: - if(options->m_verbose) + if(opts->m_verbose) parallel_print("Comparison not supported: <%s> and <%s> are of type %s\n", path1, path2, get_type(object_type) ); - options->not_cmp = 1; + opts->not_cmp = 1; break; } - options->err_stat = 0; + opts->err_stat = 0; done: /*----------------------------------- @@ -1740,25 +1742,25 @@ done: */ /* both path1 and path2 are dangling links */ if(is_dangle_link1 && is_dangle_link2) { - if(print_objname(options, nfound)) { - do_print_objname("dangling link", path1, path2, options); + if(print_objname(opts, nfound)) { + do_print_objname("dangling link", path1, path2, opts); print_found(nfound); } } /* path1 is dangling link */ else if (is_dangle_link1) { - if(options->m_verbose) + if(opts->m_verbose) parallel_print("obj1 <%s> is a dangling link.\n", path1); nfound++; - if(print_objname(options, nfound)) + if(print_objname(opts, nfound)) print_found(nfound); } /* path2 is dangling link */ else if (is_dangle_link2) { - if(options->m_verbose) + if(opts->m_verbose) parallel_print("obj2 <%s> is a dangling link.\n", path2); nfound++; - if(print_objname(options, nfound)) + if(print_objname(opts, nfound)) print_found(nfound); } @@ -1780,7 +1782,7 @@ done: /* enable error reporting */ } H5E_END_TRY; - h5difftrace("diff finish\n"); + h5diffdebug2("diff finish:%d\n", nfound); return nfound; } diff --git a/tools/lib/h5diff.h b/tools/lib/h5diff.h index 0226e83..26bcd95 100644 --- a/tools/lib/h5diff.h +++ b/tools/lib/h5diff.h @@ -38,7 +38,7 @@ /*------------------------------------------------------------------------- * This is used to pass multiple args into diff(). - * Passing this instead of several each arg provides smoother extensibility + * Passing this instead of several each arg provides smoother extensibility * through its members along with MPI code for ph5diff * as it doesn't require interface change. *------------------------------------------------------------------------*/ @@ -95,13 +95,13 @@ H5TOOLS_DLL hsize_t h5diff(const char *fname1, const char *fname2, const char *objname1, const char *objname2, - diff_opt_t *options); + diff_opt_t *opts); H5TOOLS_DLL hsize_t diff( hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, - diff_opt_t *options, + diff_opt_t *opts, diff_args_t *argdata); #ifdef H5_HAVE_PARALLEL @@ -125,18 +125,18 @@ hsize_t diff_dataset( hid_t file1_id, hid_t file2_id, const char *obj1_name, const char *obj2_name, - diff_opt_t *options); + diff_opt_t *opts); hsize_t diff_datasetid( hid_t dset1_id, hid_t dset2_id, const char *obj1_name, const char *obj2_name, - diff_opt_t *options); + diff_opt_t *opts); hsize_t diff_match( hid_t file1_id, const char *grp1, trav_info_t *info1, hid_t file2_id, const char *grp2, trav_info_t *info2, - trav_table_t *table, diff_opt_t *options ); + trav_table_t *table, diff_opt_t *opts ); hsize_t diff_array( void *_mem1, void *_mem2, @@ -144,7 +144,7 @@ hsize_t diff_array( void *_mem1, hsize_t hyper_start, int rank, hsize_t *dims, - diff_opt_t *options, + diff_opt_t *opts, const char *name1, const char *name2, hid_t m_type, @@ -162,7 +162,7 @@ int diff_can_type( hid_t f_type1, /* file data type */ hsize_t *maxdim2, const char *obj1_name, const char *obj2_name, - diff_opt_t *options, + diff_opt_t *opts, int is_compound); @@ -170,7 +170,7 @@ hsize_t diff_attr(hid_t loc1_id, hid_t loc2_id, const char *path1, const char *path2, - diff_opt_t *options); + diff_opt_t *opts); /*------------------------------------------------------------------------- @@ -187,10 +187,10 @@ const char* get_class(H5T_class_t tclass); const char* get_sign(H5T_sign_t sign); void print_dimensions (int rank, hsize_t *dims); herr_t match_up_memsize (hid_t f_tid1_id, hid_t f_tid2_id, - hid_t *m_tid1, hid_t *m_tid2, + hid_t *m_tid1, hid_t *m_tid2, size_t *m_size1, size_t *m_size2); /* in h5diff.c */ -int print_objname(diff_opt_t *options, hsize_t nfound); +int print_objname(diff_opt_t *opts, hsize_t nfound); void do_print_objname (const char *OBJ, const char *path1, const char *path2, diff_opt_t * opts); void do_print_attrname (const char *attr, const char *path1, const char *path2); diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c index 58a5e09..5d77de3 100644 --- a/tools/lib/h5diff_array.c +++ b/tools/lib/h5diff_array.c @@ -131,21 +131,21 @@ typedef struct mcomp_t { *------------------------------------------------------------------------- */ static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, - hid_t region2_id, diff_opt_t *options); + hid_t region2_id, diff_opt_t *opts); static hbool_t all_zero(const void *_mem, size_t size); static int ull2float(unsigned long long ull_value, float *f_value); static hsize_t character_compare(char *mem1, char *mem2, hsize_t i, size_t u, int rank, hsize_t *dims, hsize_t *acc, hsize_t *pos, - diff_opt_t *options, const char *obj1, const char *obj2, int *ph); + diff_opt_t *opts, const char *obj1, const char *obj2, int *ph); static hsize_t character_compare_opt(unsigned char *mem1, unsigned char *mem2, hsize_t i, int rank, hsize_t *dims, hsize_t *acc, hsize_t *pos, - diff_opt_t *options, const char *obj1, const char *obj2, int *ph); -static hbool_t equal_float(float value, float expected, diff_opt_t *options); -static hbool_t equal_double(double value, double expected, diff_opt_t *options); + diff_opt_t *opts, const char *obj1, const char *obj2, int *ph); +static hbool_t equal_float(float value, float expected, diff_opt_t *opts); +static hbool_t equal_double(double value, double expected, diff_opt_t *opts); #if H5_SIZEOF_LONG_DOUBLE !=0 -static hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *options); +static hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *opts); #endif -static int print_data(diff_opt_t *options); +static int print_data(diff_opt_t *opts); static void print_pos(int *ph, int pp, hsize_t curr_pos, hsize_t *acc, hsize_t *pos, int rank, hsize_t *dims, const char *obj1, const char *obj2); @@ -155,17 +155,17 @@ static void print_char_pos(int *ph, int pp, hsize_t curr_pos, size_t u, static void h5diff_print_char(char ch); static hsize_t diff_datum(void *_mem1, void *_mem2, hid_t m_type, hsize_t index, int rank, hsize_t *dims, hsize_t *acc, hsize_t *pos, - diff_opt_t *options, const char *obj1, const char *obj2, + diff_opt_t *opts, const char *obj1, const char *obj2, hid_t container1_id, hid_t container2_id, /*where the reference came from*/ int *ph, /*print header */ mcomp_t *members); /*compound members */ static hsize_t diff_float(unsigned char *mem1, unsigned char *mem2, hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *options, const char *obj1, + hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, const char *obj2, int *ph); static hsize_t diff_double(unsigned char *mem1, unsigned char *mem2, hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *options, const char *obj1, + hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, const char *obj2, int *ph); #if H5_SIZEOF_LONG_DOUBLE !=0 static hsize_t diff_ldouble(unsigned char *mem1, @@ -176,50 +176,50 @@ static hsize_t diff_ldouble(unsigned char *mem1, hsize_t *dims, hsize_t *acc, hsize_t *pos, - diff_opt_t *options, + diff_opt_t *opts, const char *obj1, const char *obj2, int *ph); #endif static hsize_t diff_schar(unsigned char *mem1, unsigned char *mem2, hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *options, const char *obj1, + hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, const char *obj2, int *ph); static hsize_t diff_uchar(unsigned char *mem1, unsigned char *mem2, hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *options, const char *obj1, + hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, const char *obj2, int *ph); static hsize_t diff_short(unsigned char *mem1, unsigned char *mem2, hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *options, const char *obj1, + hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, const char *obj2, int *ph); static hsize_t diff_ushort(unsigned char *mem1, unsigned char *mem2, hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *options, const char *obj1, + hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, const char *obj2, int *ph); static hsize_t diff_int(unsigned char *mem1, unsigned char *mem2, hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *options, const char *obj1, + hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, const char *obj2, int *ph); static hsize_t diff_uint(unsigned char *mem1, unsigned char *mem2, hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *options, const char *obj1, + hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, const char *obj2, int *ph); static hsize_t diff_long(unsigned char *mem1, unsigned char *mem2, hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *options, const char *obj1, + hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, const char *obj2, int *ph); static hsize_t diff_ulong(unsigned char *mem1, unsigned char *mem2, hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *options, const char *obj1, + hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, const char *obj2, int *ph); static hsize_t diff_llong(unsigned char *mem1, unsigned char *mem2, hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *options, const char *obj1, + hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, const char *obj2, int *ph); static hsize_t diff_ullong(unsigned char *mem1, unsigned char *mem2, hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *options, const char *obj1, + hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, const char *obj2, int *ph); /*------------------------------------------------------------------------- @@ -266,7 +266,7 @@ hsize_t diff_array( hsize_t hyper_start, int rank, hsize_t *dims, - diff_opt_t *options, + diff_opt_t *opts, const char *name1, const char *name2, hid_t m_type, @@ -324,36 +324,36 @@ hsize_t diff_array( */ case H5T_FLOAT: if (H5Tequal(m_type, H5T_NATIVE_FLOAT)) - nfound = diff_float(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, options, name1, name2, &ph); + nfound = diff_float(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, opts, name1, name2, &ph); else if (H5Tequal(m_type, H5T_NATIVE_DOUBLE)) - nfound = diff_double(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, options, name1, name2, &ph); + nfound = diff_double(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, opts, name1, name2, &ph); #if H5_SIZEOF_LONG_DOUBLE != 0 else if (H5Tequal(m_type, H5T_NATIVE_LDOUBLE)) - nfound = diff_ldouble(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, options, name1, name2, &ph); + nfound = diff_ldouble(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, opts, name1, name2, &ph); #endif break; case H5T_INTEGER: if (H5Tequal(m_type, H5T_NATIVE_SCHAR)) - nfound = diff_schar(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, options, name1, name2, &ph); + nfound = diff_schar(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, opts, name1, name2, &ph); else if (H5Tequal(m_type, H5T_NATIVE_UCHAR)) - nfound = diff_uchar(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, options, name1, name2, &ph); + nfound = diff_uchar(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, opts, name1, name2, &ph); else if (H5Tequal(m_type, H5T_NATIVE_SHORT)) - nfound = diff_short(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, options, name1, name2, &ph); + nfound = diff_short(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, opts, name1, name2, &ph); else if (H5Tequal(m_type, H5T_NATIVE_USHORT)) - nfound = diff_ushort(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, options, name1, name2, &ph); + nfound = diff_ushort(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, opts, name1, name2, &ph); else if (H5Tequal(m_type, H5T_NATIVE_INT)) - nfound = diff_int(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, options, name1, name2, &ph); + nfound = diff_int(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, opts, name1, name2, &ph); else if (H5Tequal(m_type, H5T_NATIVE_UINT)) - nfound = diff_uint(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, options, name1, name2, &ph); + nfound = diff_uint(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, opts, name1, name2, &ph); else if (H5Tequal(m_type, H5T_NATIVE_LONG)) - nfound = diff_long(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, options, name1, name2, &ph); + nfound = diff_long(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, opts, name1, name2, &ph); else if (H5Tequal(m_type, H5T_NATIVE_ULONG)) - nfound = diff_ulong(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, options, name1, name2, &ph); + nfound = diff_ulong(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, opts, name1, name2, &ph); else if (H5Tequal(m_type, H5T_NATIVE_LLONG)) - nfound = diff_llong(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, options, name1, name2, &ph); + nfound = diff_llong(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, opts, name1, name2, &ph); else if (H5Tequal(m_type, H5T_NATIVE_ULLONG)) - nfound = diff_ullong(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, options, name1, name2, &ph); + nfound = diff_ullong(mem1, mem2, nelmts, hyper_start, rank, dims, acc, pos, opts, name1, name2, &ph); break; /*------------------------------------------------------------------------- @@ -371,14 +371,14 @@ hsize_t diff_array( HDmemset(&members, 0, sizeof(mcomp_t)); get_member_types(m_type, &members); for (i = 0; i < nelmts; i++) { - nfound += diff_datum(mem1 + i * size, mem2 + i * size, m_type, i, rank, dims, acc, pos, options, + nfound += diff_datum(mem1 + i * size, mem2 + i * size, m_type, i, rank, dims, acc, pos, opts, name1, name2, container1_id, container2_id, &ph, &members); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) break; } /* i */ close_member_types(&members); } /* switch */ - h5difftrace("diff_array finish\n"); + h5diffdebug2("diff_array finish:%d\n", nfound); return nfound; } @@ -425,7 +425,7 @@ static hsize_t diff_datum( hsize_t *dims, hsize_t *acc, hsize_t *pos, - diff_opt_t *options, + diff_opt_t *opts, const char *obj1, const char *obj2, hid_t container1_id, @@ -447,11 +447,14 @@ static hsize_t diff_datum( hbool_t iszero1; hbool_t iszero2; hsize_t nfound = 0; /* differences found */ - hsize_t ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ + hsize_t ret_value = 0; double per; hbool_t both_zero; h5difftrace("diff_datum start\n"); + /* default error sttaus */ + opts->err_stat = 1; + type_size = H5Tget_size(m_type); type_class = H5Tget_class(m_type); @@ -489,7 +492,7 @@ static hsize_t diff_datum( memb_type = members->ids[j]; nfound += diff_datum(mem1 + offset, mem2 + offset, memb_type, index, - rank, dims, acc, pos, options, obj1, obj2, container1_id, container2_id, ph, members->m[j]); + rank, dims, acc, pos, opts, obj1, obj2, container1_id, container2_id, ph, members->m[j]); } } break; @@ -590,13 +593,13 @@ static hsize_t diff_datum( /* try fast compare first */ if (HDmemcmp(s, sx, size) == 0) { if (size1 != size2) - if (print_data(options)) + if (print_data(opts)) for (u = size; u < sizex; u++) - character_compare(s + u, sx + u, index, u, rank, dims, acc, pos, options, obj1, obj2, ph); + character_compare(s + u, sx + u, index, u, rank, dims, acc, pos, opts, obj1, obj2, ph); } else for (u = 0; u < size; u++) - nfound += character_compare(s + u, sx + u, index, u, rank, dims, acc, pos, options, obj1, obj2, ph); + nfound += character_compare(s + u, sx + u, index, u, rank, dims, acc, pos, opts, obj1, obj2, ph); } /* end check for NULL pointer for string */ } break; @@ -609,7 +612,7 @@ static hsize_t diff_datum( h5difftrace("diff_datum H5T_BITFIELD\n"); /* byte-by-byte comparison */ for (u = 0; u < type_size; u++) - nfound += character_compare_opt(mem1 + u, mem2 + u, index, rank, dims, acc, pos, options, obj1, obj2, ph); + nfound += character_compare_opt(mem1 + u, mem2 + u, index, rank, dims, acc, pos, opts, obj1, obj2, ph); break; /*------------------------------------------------------------------------- @@ -620,7 +623,7 @@ static hsize_t diff_datum( h5difftrace("diff_datum H5T_OPAQUE\n"); /* byte-by-byte comparison */ for (u = 0; u < type_size; u++) - nfound += character_compare_opt(mem1 + u, mem2 + u, index, rank, dims, acc, pos, options, obj1, obj2, ph); + nfound += character_compare_opt(mem1 + u, mem2 + u, index, rank, dims, acc, pos, opts, obj1, obj2, ph); break; /*------------------------------------------------------------------------- @@ -660,7 +663,7 @@ static hsize_t diff_datum( * don't attempt to convert them - just report errors. */ nfound += 1; - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(S_FORMAT, enum_name1, enum_name2); @@ -670,7 +673,7 @@ static hsize_t diff_datum( /* Both enum values were valid */ if (HDstrcmp(enum_name1, enum_name2) != 0) { nfound = 1; - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(S_FORMAT, enum_name1, enum_name2); @@ -678,7 +681,7 @@ static hsize_t diff_datum( } else { for (u = 0; u < type_size; u++) - nfound += character_compare_opt(mem1 + u, mem2 + u, index, rank, dims, acc, pos, options, obj1, obj2, ph); + nfound += character_compare_opt(mem1 + u, mem2 + u, index, rank, dims, acc, pos, opts, obj1, obj2, ph); } } /* enable error reporting */ @@ -708,7 +711,7 @@ static hsize_t diff_datum( nelmts *= adims[u]; for (u = 0; u < nelmts; u++) { nfound += diff_datum(mem1 + u * size, mem2 + u * size, memb_type, index, - rank, dims, acc, pos, options, obj1, obj2, container1_id, container2_id, ph, members); + rank, dims, acc, pos, opts, obj1, obj2, container1_id, container2_id, ph, members); } H5Tclose(memb_type); } @@ -746,18 +749,12 @@ static hsize_t diff_datum( if ((region2_id = H5Rget_region(container2_id, H5R_DATASET_REGION, _mem2)) < 0) HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rget_region object 2 failed"); - if (ret_value >= 0) - nfound = diff_region(obj1_id, obj2_id, region1_id, region2_id, options); + nfound = diff_region(obj1_id, obj2_id, region1_id, region2_id, opts); H5Oclose(obj1_id); H5Oclose(obj2_id); H5Sclose(region1_id); H5Sclose(region2_id); - - if (ret_value == -1) { - options->err_stat = 1; - HGOTO_DONE(0); - } }/*dataset reference*/ /*------------------------------------------------------------------------- @@ -778,7 +775,7 @@ static hsize_t diff_datum( if (ret_value >= 0) if (obj1_type != obj2_type) { parallel_print("Different object types referenced: <%s> and <%s>", obj1, obj2); - options->not_cmp = 1; + opts->not_cmp = 1; HGOTO_DONE (0); } @@ -788,25 +785,18 @@ static hsize_t diff_datum( HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rdereference2 object 2 failed"); /* compare */ - if (ret_value >= 0) { - if (obj1_type == H5O_TYPE_DATASET) - nfound = diff_datasetid(obj1_id, obj2_id, NULL, NULL, options); - else { - if (options->m_verbose) - parallel_print( - "Warning: Comparison not possible of object types referenced: <%s> and <%s>\n", - obj1, obj2); - options->not_cmp = 1; - } + if (obj1_type == H5O_TYPE_DATASET) + nfound = diff_datasetid(obj1_id, obj2_id, NULL, NULL, opts); + else { + if (opts->m_verbose) + parallel_print( + "Warning: Comparison not possible of object types referenced: <%s> and <%s>\n", + obj1, obj2); + opts->not_cmp = 1; } H5Oclose(obj1_id); H5Oclose(obj2_id); - - if (ret_value == -1) { - options->err_stat = 1; - HGOTO_DONE(0); - } }/*object reference*/ }/*is zero*/ break; @@ -828,7 +818,7 @@ static hsize_t diff_datum( for (j = 0; j < nelmts; j++) nfound += diff_datum(((char *) (((hvl_t *) mem1)->p)) + j * size, ((char *) (((hvl_t *) mem2)->p)) + j * size, memb_type, index, - rank, dims, acc, pos, options, obj1, obj2, container1_id, container2_id, ph, members); + rank, dims, acc, pos, opts, obj1, obj2, container1_id, container2_id, ph, members); H5Tclose(memb_type); } @@ -853,9 +843,9 @@ static hsize_t diff_datum( HDmemcpy(&temp1_char, mem1, sizeof(char)); HDmemcpy(&temp2_char, mem2, sizeof(char)); /* -d and !-p */ - if (options->d && !options->p) { - if (ABS(temp1_char-temp2_char) > options->delta) { - if (print_data(options)) { + if (opts->d && !opts->p) { + if (ABS(temp1_char-temp2_char) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT, temp1_char, temp2_char, ABS(temp1_char - temp2_char)); @@ -864,19 +854,19 @@ static hsize_t diff_datum( } } /* !-d and -p */ - else if (!options->d && options->p) { + else if (!opts->d && opts->p) { PER(temp1_char, temp2_char); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P_NOTCOMP, temp1_char, temp2_char, ABS(temp1_char - temp2_char)); } nfound++; } - else if (per > options->percent) { - if (print_data(options)) { + else if (per > opts->percent) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P, temp1_char, temp2_char, ABS(temp1_char - temp2_char), per); @@ -885,19 +875,19 @@ static hsize_t diff_datum( } } /* -d and -p */ - else if (options->d && options->p) { + else if (opts->d && opts->p) { PER(temp1_char, temp2_char); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P_NOTCOMP, temp1_char, temp2_char, ABS(temp1_char - temp2_char)); } nfound++; } - else if (per > options->percent && ABS(temp1_char - temp2_char) > options->delta) { - if (print_data(options)) { + else if (per > opts->percent && ABS(temp1_char - temp2_char) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P, temp1_char, temp2_char, ABS(temp1_char - temp2_char), per); @@ -906,7 +896,7 @@ static hsize_t diff_datum( } } else if (temp1_char != temp2_char) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT, temp1_char, temp2_char, ABS(temp1_char - temp2_char)); @@ -929,9 +919,9 @@ static hsize_t diff_datum( HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char)); HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char)); /* -d and !-p */ - if (options->d && !options->p) { - if (PDIFF(temp1_uchar, temp2_uchar) > options->delta) { - if (print_data(options)) { + if (opts->d && !opts->p) { + if (PDIFF(temp1_uchar, temp2_uchar) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar)); @@ -940,19 +930,19 @@ static hsize_t diff_datum( } } /* !-d and -p */ - else if (!options->d && options->p) { + else if (!opts->d && opts->p) { PER_UNSIGN(signed char, temp1_uchar, temp2_uchar); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P_NOTCOMP, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar)); } nfound++; } - else if (per > options->percent) { - if (print_data(options)) { + else if (per > opts->percent) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar), per); @@ -961,19 +951,19 @@ static hsize_t diff_datum( } } /* -d and -p */ - else if (options->d && options->p) { + else if (opts->d && opts->p) { PER_UNSIGN(signed char, temp1_uchar, temp2_uchar); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P_NOTCOMP, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar)); } nfound++; } - else if (per > options->percent && PDIFF(temp1_uchar, temp2_uchar) > options->delta) { - if (print_data(options)) { + else if (per > opts->percent && PDIFF(temp1_uchar, temp2_uchar) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar), per); @@ -982,7 +972,7 @@ static hsize_t diff_datum( } } else if (temp1_uchar != temp2_uchar) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar)); @@ -1005,9 +995,9 @@ static hsize_t diff_datum( HDmemcpy(&temp1_short, mem1, sizeof(short)); HDmemcpy(&temp2_short, mem2, sizeof(short)); /* -d and !-p */ - if (options->d && !options->p) { - if (ABS(temp1_short - temp2_short) > options->delta) { - if (print_data(options)) { + if (opts->d && !opts->p) { + if (ABS(temp1_short - temp2_short) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT, temp1_short, temp2_short, ABS(temp1_short - temp2_short)); @@ -1016,19 +1006,19 @@ static hsize_t diff_datum( } } /* !-d and -p */ - else if (!options->d && options->p) { + else if (!opts->d && opts->p) { PER(temp1_short, temp2_short); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P_NOTCOMP, temp1_short, temp2_short, ABS(temp1_short - temp2_short)); } nfound++; } - else if (per > options->percent) { - if (print_data(options)) { + else if (per > opts->percent) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P, temp1_short, temp2_short, ABS(temp1_short - temp2_short), per); @@ -1037,19 +1027,19 @@ static hsize_t diff_datum( } } /* -d and -p */ - else if (options->d && options->p) { + else if (opts->d && opts->p) { PER(temp1_short, temp2_short); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P_NOTCOMP, temp1_short, temp2_short, ABS(temp1_short - temp2_short)); } nfound++; } - else if (per > options->percent && ABS(temp1_short - temp2_short) > options->delta) { - if (print_data(options)) { + else if (per > opts->percent && ABS(temp1_short - temp2_short) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P, temp1_short, temp2_short, ABS(temp1_short - temp2_short), per); @@ -1058,7 +1048,7 @@ static hsize_t diff_datum( } } else if (temp1_short != temp2_short) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT, temp1_short, temp2_short, ABS(temp1_short - temp2_short)); @@ -1081,9 +1071,9 @@ static hsize_t diff_datum( HDmemcpy(&temp1_ushort, mem1, sizeof(unsigned short)); HDmemcpy(&temp2_ushort, mem2, sizeof(unsigned short)); /* -d and !-p */ - if (options->d && !options->p) { - if (PDIFF(temp1_ushort, temp2_ushort) > options->delta) { - if (print_data(options)) { + if (opts->d && !opts->p) { + if (PDIFF(temp1_ushort, temp2_ushort) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort)); @@ -1092,19 +1082,19 @@ static hsize_t diff_datum( } } /* !-d and -p */ - else if (!options->d && options->p) { + else if (!opts->d && opts->p) { PER_UNSIGN(signed short, temp1_ushort, temp2_ushort); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P_NOTCOMP, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort)); } nfound++; } - else if (per > options->percent) { - if (print_data(options)) { + else if (per > opts->percent) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort), per); @@ -1113,19 +1103,19 @@ static hsize_t diff_datum( } } /* -d and -p */ - else if (options->d && options->p) { + else if (opts->d && opts->p) { PER_UNSIGN(signed short, temp1_ushort, temp2_ushort); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P_NOTCOMP, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort)); } nfound++; } - else if (per > options->percent && PDIFF(temp1_ushort, temp2_ushort) > options->delta) { - if (print_data(options)) { + else if (per > opts->percent && PDIFF(temp1_ushort, temp2_ushort) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort), per); @@ -1134,7 +1124,7 @@ static hsize_t diff_datum( } } else if (temp1_ushort != temp2_ushort) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort)); @@ -1157,9 +1147,9 @@ static hsize_t diff_datum( HDmemcpy(&temp1_int, mem1, sizeof(int)); HDmemcpy(&temp2_int, mem2, sizeof(int)); /* -d and !-p */ - if (options->d && !options->p) { - if (ABS(temp1_int-temp2_int) > options->delta) { - if (print_data(options)) { + if (opts->d && !opts->p) { + if (ABS(temp1_int-temp2_int) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT, temp1_int, temp2_int, ABS(temp1_int - temp2_int)); @@ -1168,19 +1158,19 @@ static hsize_t diff_datum( } } /* !-d and -p */ - else if (!options->d && options->p) { + else if (!opts->d && opts->p) { PER(temp1_int, temp2_int); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P_NOTCOMP, temp1_int, temp2_int, ABS(temp1_int - temp2_int)); } nfound++; } - else if (per > options->percent) { - if (print_data(options)) { + else if (per > opts->percent) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P, temp1_int, temp2_int, ABS(temp1_int - temp2_int), per); @@ -1189,19 +1179,19 @@ static hsize_t diff_datum( } } /* -d and -p */ - else if (options->d && options->p) { + else if (opts->d && opts->p) { PER(temp1_int, temp2_int); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P_NOTCOMP, temp1_int, temp2_int, ABS(temp1_int - temp2_int)); } nfound++; } - else if (per > options->percent && ABS(temp1_int - temp2_int) > options->delta) { - if (print_data(options)) { + else if (per > opts->percent && ABS(temp1_int - temp2_int) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P, temp1_int, temp2_int, ABS(temp1_int - temp2_int), per); @@ -1210,7 +1200,7 @@ static hsize_t diff_datum( } } else if (temp1_int != temp2_int) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT, temp1_int, temp2_int, ABS(temp1_int - temp2_int)); @@ -1233,9 +1223,9 @@ static hsize_t diff_datum( HDmemcpy(&temp1_uint, mem1, sizeof(unsigned int)); HDmemcpy(&temp2_uint, mem2, sizeof(unsigned int)); /* -d and !-p */ - if (options->d && !options->p) { - if (PDIFF(temp1_uint, temp2_uint) > options->delta) { - if (print_data(options)) { + if (opts->d && !opts->p) { + if (PDIFF(temp1_uint, temp2_uint) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(UI_FORMAT, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint)); @@ -1244,19 +1234,19 @@ static hsize_t diff_datum( } } /* !-d and -p */ - else if (!options->d && options->p) { + else if (!opts->d && opts->p) { PER_UNSIGN(signed int, temp1_uint, temp2_uint); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(UI_FORMAT_P_NOTCOMP, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint)); } nfound++; } - else if (per > options->percent) { - if (print_data(options)) { + else if (per > opts->percent) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(UI_FORMAT_P, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint), per); @@ -1265,19 +1255,19 @@ static hsize_t diff_datum( } } /* -d and -p */ - else if (options->d && options->p) { + else if (opts->d && opts->p) { PER_UNSIGN(signed int, temp1_uint, temp2_uint); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(UI_FORMAT_P_NOTCOMP, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint)); } nfound++; } - else if (per > options->percent && PDIFF(temp1_uint,temp2_uint) > options->delta) { - if (print_data(options)) { + else if (per > opts->percent && PDIFF(temp1_uint,temp2_uint) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(UI_FORMAT_P, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint), per); @@ -1286,7 +1276,7 @@ static hsize_t diff_datum( } } else if (temp1_uint != temp2_uint) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(UI_FORMAT, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint)); @@ -1309,9 +1299,9 @@ static hsize_t diff_datum( HDmemcpy(&temp1_long, mem1, sizeof(long)); HDmemcpy(&temp2_long, mem2, sizeof(long)); /* -d and !-p */ - if (options->d && !options->p) { - if (ABS(temp1_long-temp2_long) > options->delta) { - if (print_data(options)) { + if (opts->d && !opts->p) { + if (ABS(temp1_long-temp2_long) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(LI_FORMAT, temp1_long, temp2_long, ABS(temp1_long - temp2_long)); @@ -1320,19 +1310,19 @@ static hsize_t diff_datum( } } /* !-d and -p */ - else if (!options->d && options->p) { + else if (!opts->d && opts->p) { PER(temp1_long, temp2_long); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(LI_FORMAT_P_NOTCOMP, temp1_long, temp2_long, ABS(temp1_long - temp2_long)); } nfound++; } - else if (per > options->percent) { - if (print_data(options)) { + else if (per > opts->percent) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(LI_FORMAT_P, temp1_long, temp2_long, ABS(temp1_long - temp2_long), per); @@ -1341,19 +1331,19 @@ static hsize_t diff_datum( } } /* -d and -p */ - else if (options->d && options->p) { + else if (opts->d && opts->p) { PER(temp1_long, temp2_long); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(LI_FORMAT_P_NOTCOMP, temp1_long, temp2_long, ABS(temp1_long - temp2_long)); } nfound++; } - else if (per > options->percent && ABS(temp1_long-temp2_long) > options->delta) { - if (print_data(options)) { + else if (per > opts->percent && ABS(temp1_long-temp2_long) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(LI_FORMAT_P, temp1_long, temp2_long, ABS(temp1_long - temp2_long), per); @@ -1362,7 +1352,7 @@ static hsize_t diff_datum( } } else if (temp1_long != temp2_long) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(LI_FORMAT, temp1_long, temp2_long, ABS(temp1_long - temp2_long)); @@ -1385,9 +1375,9 @@ static hsize_t diff_datum( HDmemcpy(&temp1_ulong, mem1, sizeof(unsigned long)); HDmemcpy(&temp2_ulong, mem2, sizeof(unsigned long)); /* -d and !-p */ - if (options->d && !options->p) { - if (PDIFF(temp1_ulong, temp2_ulong) > options->delta) { - if (print_data(options)) { + if (opts->d && !opts->p) { + if (PDIFF(temp1_ulong, temp2_ulong) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(ULI_FORMAT, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong)); @@ -1396,19 +1386,19 @@ static hsize_t diff_datum( } } /* !-d and -p */ - else if (!options->d && options->p) { + else if (!opts->d && opts->p) { PER_UNSIGN(signed long, temp1_ulong, temp2_ulong); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(ULI_FORMAT_P_NOTCOMP, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong)); } nfound++; } - else if (per > options->percent) { - if (print_data(options)) { + else if (per > opts->percent) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(ULI_FORMAT_P, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong), per); @@ -1417,19 +1407,19 @@ static hsize_t diff_datum( } } /* -d and -p */ - else if (options->d && options->p) { + else if (opts->d && opts->p) { PER_UNSIGN(signed long, temp1_ulong, temp2_ulong); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(ULI_FORMAT_P_NOTCOMP, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong)); } nfound++; } - else if (per > options->percent && PDIFF(temp1_ulong,temp2_ulong) > options->delta) { - if (print_data(options)) { + else if (per > opts->percent && PDIFF(temp1_ulong,temp2_ulong) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(ULI_FORMAT_P, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong), per); @@ -1438,7 +1428,7 @@ static hsize_t diff_datum( } } else if (temp1_ulong != temp2_ulong) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(ULI_FORMAT, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong)); @@ -1469,26 +1459,26 @@ static hsize_t diff_datum( HDmemcpy(&temp1_float, mem1, sizeof(float)); HDmemcpy(&temp2_float, mem2, sizeof(float)); - /* logic for detecting NaNs is different with options -d, -p and no options */ + /* logic for detecting NaNs is different with opts -d, -p and no opts */ /*------------------------------------------------------------------------- * -d and !-p *------------------------------------------------------------------------- */ - if (options->d && !options->p) { + if (opts->d && !opts->p) { /*------------------------------------------------------------------------- * detect NaNs *------------------------------------------------------------------------- */ - if (options->do_nans) { + if (opts->do_nans) { isnan1 = my_isnan(FLT_FLOAT, &temp1_float); isnan2 = my_isnan(FLT_FLOAT, &temp2_float); } /* both not NaN, do the comparison */ if (!isnan1 && !isnan2) { - if (ABS(temp1_float-temp2_float) > (float) options->delta) { - if (print_data(options)) { + if (ABS(temp1_float-temp2_float) > (float) opts->delta) { + if (print_data(opts)) { print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float)); @@ -1498,7 +1488,7 @@ static hsize_t diff_datum( } /* only one is NaN, assume difference */ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float)); @@ -1510,12 +1500,12 @@ static hsize_t diff_datum( * !-d and -p *------------------------------------------------------------------------- */ - else if (!options->d && options->p) { + else if (!opts->d && opts->p) { /*------------------------------------------------------------------------- * detect NaNs *------------------------------------------------------------------------- */ - if (options->do_nans) { + if (opts->do_nans) { isnan1 = my_isnan(FLT_FLOAT, &temp1_float); isnan2 = my_isnan(FLT_FLOAT, &temp2_float); } @@ -1525,15 +1515,15 @@ static hsize_t diff_datum( PER(temp1_float, temp2_float); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT_P_NOTCOMP, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float)); } nfound++; } - else if (per > options->percent && (double) ABS(temp1_float - temp2_float) > options->delta) { - if (print_data(options)) { + else if (per > opts->percent && (double) ABS(temp1_float - temp2_float) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT_P, (double) temp1_float, (double) temp2_float, @@ -1544,7 +1534,7 @@ static hsize_t diff_datum( } /* only one is NaN, assume difference */ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float)); @@ -1556,12 +1546,12 @@ static hsize_t diff_datum( * -d and -p *------------------------------------------------------------------------- */ - else if (options->d && options->p) { + else if (opts->d && opts->p) { /*------------------------------------------------------------------------- * detect NaNs *------------------------------------------------------------------------- */ - if (options->do_nans) { + if (opts->do_nans) { isnan1 = my_isnan(FLT_FLOAT, &temp1_float); isnan2 = my_isnan(FLT_FLOAT, &temp2_float); } @@ -1571,15 +1561,15 @@ static hsize_t diff_datum( PER(temp1_float, temp2_float); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT_P_NOTCOMP, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float)); } nfound++; } - else if (per > options->percent) { - if (print_data(options)) { + else if (per > opts->percent) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT_P, (double) temp1_float, (double) temp2_float, @@ -1590,7 +1580,7 @@ static hsize_t diff_datum( } /* only one is NaN, assume difference */ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float)); @@ -1602,8 +1592,8 @@ static hsize_t diff_datum( * no -d and -p *------------------------------------------------------------------------- */ - else if (equal_float(temp1_float, temp2_float, options) == FALSE) { - if (print_data(options)) { + else if (equal_float(temp1_float, temp2_float, opts) == FALSE) { + if (print_data(opts)) { print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float)); @@ -1628,25 +1618,25 @@ static hsize_t diff_datum( HDmemcpy(&temp1_double, mem1, sizeof(double)); HDmemcpy(&temp2_double, mem2, sizeof(double)); - /* logic for detecting NaNs is different with options -d, -p and no options */ + /* logic for detecting NaNs is different with opts -d, -p and no opts */ /*------------------------------------------------------------------------- * -d and !-p *------------------------------------------------------------------------- */ - if (options->d && !options->p) { + if (opts->d && !opts->p) { /*------------------------------------------------------------------------- * detect NaNs *------------------------------------------------------------------------- */ - if (options->do_nans) { + if (opts->do_nans) { isnan1 = my_isnan(FLT_DOUBLE, &temp1_double); isnan2 = my_isnan(FLT_DOUBLE, &temp2_double); } /* both not NaN, do the comparison */ if (!isnan1 && !isnan2) { - if (ABS(temp1_double-temp2_double) > options->delta) { - if (print_data(options)) { + if (ABS(temp1_double-temp2_double) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); @@ -1656,24 +1646,24 @@ static hsize_t diff_datum( } /* only one is NaN, assume difference */ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); } nfound++; } - } /* options->d && !options->p */ + } /* opts->d && !opts->p */ /*------------------------------------------------------------------------- * !-d and -p *------------------------------------------------------------------------- */ - else if (!options->d && options->p) { + else if (!opts->d && opts->p) { /*------------------------------------------------------------------------- * detect NaNs *------------------------------------------------------------------------- */ - if (options->do_nans) { + if (opts->do_nans) { isnan1 = my_isnan(FLT_DOUBLE, &temp1_double); isnan2 = my_isnan(FLT_DOUBLE, &temp2_double); } @@ -1683,15 +1673,15 @@ static hsize_t diff_datum( PER(temp1_double, temp2_double); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); } nfound++; } - else if (per > options->percent) { - if (print_data(options)) { + else if (per > opts->percent) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT_P, temp1_double, temp2_double, ABS(temp1_double - temp2_double), ABS(1 - temp2_double / temp1_double)); @@ -1701,7 +1691,7 @@ static hsize_t diff_datum( } /* only one is NaN, assume difference */ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); @@ -1713,12 +1703,12 @@ static hsize_t diff_datum( * -d and -p *------------------------------------------------------------------------- */ - else if (options->d && options->p) { + else if (opts->d && opts->p) { /*------------------------------------------------------------------------- * detect NaNs *------------------------------------------------------------------------- */ - if (options->do_nans) { + if (opts->do_nans) { isnan1 = my_isnan(FLT_DOUBLE, &temp1_double); isnan2 = my_isnan(FLT_DOUBLE, &temp2_double); } @@ -1728,16 +1718,16 @@ static hsize_t diff_datum( PER(temp1_double, temp2_double); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); } nfound++; } - else if (per > options->percent && - ABS(temp1_double-temp2_double) > options->delta) { - if (print_data(options)) { + else if (per > opts->percent && + ABS(temp1_double-temp2_double) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT_P, temp1_double, temp2_double, ABS(temp1_double - temp2_double), ABS(1 - temp2_double / temp1_double)); @@ -1747,7 +1737,7 @@ static hsize_t diff_datum( } /* only one is NaN, assume difference */ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); @@ -1759,8 +1749,8 @@ static hsize_t diff_datum( * no -d and -p *------------------------------------------------------------------------- */ - else if (equal_double(temp1_double, temp2_double, options) == FALSE) { - if (print_data(options)) { + else if (equal_double(temp1_double, temp2_double, opts) == FALSE) { + if (print_data(opts)) { print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); @@ -1793,20 +1783,20 @@ static hsize_t diff_datum( * -d and !-p *------------------------------------------------------------------------- */ - if (options->d && !options->p) { + if (opts->d && !opts->p) { /*------------------------------------------------------------------------- * detect NaNs *------------------------------------------------------------------------- */ - if (options->do_nans) { + if (opts->do_nans) { isnan1 = my_isnan(FLT_LDOUBLE,&temp1_double); isnan2 = my_isnan(FLT_LDOUBLE,&temp2_double); } /* both not NaN, do the comparison */ if (!isnan1 && !isnan2) { - if (ABS(temp1_double-temp2_double) > options->delta) { - if (print_data(options)) { + if (ABS(temp1_double-temp2_double) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(LD_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); @@ -1816,7 +1806,7 @@ static hsize_t diff_datum( } /* NaN */ /* only one is NaN, assume difference */ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); @@ -1828,12 +1818,12 @@ static hsize_t diff_datum( * !-d and -p *------------------------------------------------------------------------- */ - else if (!options->d && options->p) { + else if (!opts->d && opts->p) { /*------------------------------------------------------------------------- * detect NaNs *------------------------------------------------------------------------- */ - if (options->do_nans) { + if (opts->do_nans) { isnan1 = my_isnan(FLT_LDOUBLE, &temp1_double); isnan2 = my_isnan(FLT_LDOUBLE, &temp2_double); } @@ -1843,15 +1833,15 @@ static hsize_t diff_datum( PER(temp1_double,temp2_double); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(LD_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); } nfound++; } - else if (per > options->percent) { - if (print_data(options)) { + else if (per > opts->percent) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(LD_FORMAT_P, temp1_double, temp2_double, ABS(temp1_double - temp2_double), ABS(1 - temp2_double / temp1_double)); @@ -1861,7 +1851,7 @@ static hsize_t diff_datum( } /* NaN */ /* only one is NaN, assume difference */ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); @@ -1873,12 +1863,12 @@ static hsize_t diff_datum( * -d and -p *------------------------------------------------------------------------- */ - else if (options->d && options->p) { + else if (opts->d && opts->p) { /*------------------------------------------------------------------------- * detect NaNs *------------------------------------------------------------------------- */ - if (options->do_nans) { + if (opts->do_nans) { isnan1 = my_isnan(FLT_LDOUBLE, &temp1_double); isnan2 = my_isnan(FLT_LDOUBLE, &temp2_double); } @@ -1888,15 +1878,15 @@ static hsize_t diff_datum( PER(temp1_double,temp2_double); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(LD_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); } nfound++; } - else if (per > options->percent && ABS(temp1_double-temp2_double) > options->delta) { - if (print_data(options)) { + else if (per > opts->percent && ABS(temp1_double-temp2_double) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 1, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(LD_FORMAT_P, temp1_double, temp2_double, ABS(temp1_double - temp2_double), ABS(1 - temp2_double / temp1_double)); @@ -1906,7 +1896,7 @@ static hsize_t diff_datum( } /* NaN */ /* only one is NaN, assume difference */ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); @@ -1918,8 +1908,8 @@ static hsize_t diff_datum( * no -d and -p *------------------------------------------------------------------------- */ - else if (equal_ldouble(temp1_double, temp2_double, options) == FALSE) { - if (print_data(options)) { + else if (equal_ldouble(temp1_double, temp2_double, opts) == FALSE) { + if (print_data(opts)) { print_pos(ph, 0, index, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(LD_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); @@ -1932,9 +1922,10 @@ static hsize_t diff_datum( break; /* H5T_FLOAT class */ } /* switch */ + opts->err_stat = 0; done: - h5difftrace("diff_datum finish\n"); + h5diffdebug2("diff_datum finish:%d\n", nfound); return nfound; } @@ -2009,7 +2000,7 @@ void print_points(int i, hsize_t *ptdata, int ndims) { *------------------------------------------------------------------------- */ -static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t region2_id, diff_opt_t *options) +static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t region2_id, diff_opt_t *opts) { hsize_t ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ @@ -2041,7 +2032,7 @@ static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t } H5E_END_TRY; if (nblocks1 != nblocks2 || npoints1 != npoints2 || ndims1 != ndims2) { - options->not_cmp = 1; + opts->not_cmp = 1; HGOTO_DONE (0); } @@ -2083,7 +2074,7 @@ static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t } /* print differences if found */ - if (nfound_b && options->m_verbose) { + if (nfound_b && opts->m_verbose) { H5O_info_t oi1, oi2; H5Oget_info(obj1_id, &oi1); @@ -2140,7 +2131,7 @@ static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t } } - if (nfound_p && options->m_verbose) { + if (nfound_p && opts->m_verbose) { parallel_print("Region points\n"); for (i = 0; i < npoints1; i++) { hsize_t pt1, pt2; @@ -2167,8 +2158,6 @@ static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t #if defined (H5DIFF_DEBUG) for (i = 0; i < npoints1; i++) { - int j; - parallel_print("%sPt%lu: " , i ? "," : "", (unsigned long)i); for (j = 0; j < ndims1; j++) @@ -2201,7 +2190,7 @@ done: */ static hsize_t character_compare(char *mem1, char *mem2, hsize_t i, size_t u, - int rank, hsize_t *dims, hsize_t *acc, hsize_t *pos, diff_opt_t *options, const char *obj1, const char *obj2, int *ph) + int rank, hsize_t *dims, hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, const char *obj2, int *ph) { hsize_t nfound = 0; /* differences found */ char temp1_uchar; @@ -2212,7 +2201,7 @@ static hsize_t character_compare(char *mem1, char *mem2, hsize_t i, size_t u, h5diffdebug3("character_compare start %d=%d\n",temp1_uchar,temp2_uchar); if (temp1_uchar != temp2_uchar) { - if (print_data(options)) { + if (print_data(opts)) { print_char_pos(ph, 0, i, u, acc, pos, rank, dims, obj1, obj2); parallel_print(" "); h5diff_print_char(temp1_uchar); @@ -2237,7 +2226,7 @@ static hsize_t character_compare(char *mem1, char *mem2, hsize_t i, size_t u, */ static hsize_t character_compare_opt(unsigned char *mem1, unsigned char *mem2, - hsize_t i, int rank, hsize_t *dims, hsize_t *acc, hsize_t *pos, diff_opt_t *options, const char *obj1, const char *obj2, int *ph) + hsize_t i, int rank, hsize_t *dims, hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, const char *obj2, int *ph) { hsize_t nfound = 0; /* differences found */ unsigned char temp1_uchar; @@ -2251,9 +2240,9 @@ static hsize_t character_compare_opt(unsigned char *mem1, unsigned char *mem2, h5difftrace("character_compare_opt start\n"); /* -d and !-p */ - if (options->d && !options->p) { - if (PDIFF(temp1_uchar,temp2_uchar) > options->delta) { - if (print_data(options)) { + if (opts->d && !opts->p) { + if (PDIFF(temp1_uchar,temp2_uchar) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 0, i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar)); @@ -2262,10 +2251,10 @@ static hsize_t character_compare_opt(unsigned char *mem1, unsigned char *mem2, } } /* !-d and -p */ - else if (!options->d && options->p) { + else if (!opts->d && opts->p) { PER_UNSIGN(signed char, temp1_uchar, temp2_uchar); - if (per > options->percent) { - if (print_data(options)) { + if (per > opts->percent) { + if (print_data(opts)) { print_pos(ph, 1, i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar), per); @@ -2274,10 +2263,10 @@ static hsize_t character_compare_opt(unsigned char *mem1, unsigned char *mem2, } } /* -d and -p */ - else if (options->d && options->p) { + else if (opts->d && opts->p) { PER_UNSIGN(signed char, temp1_uchar, temp2_uchar); - if (per > options->percent && PDIFF(temp1_uchar,temp2_uchar) > options->delta) { - if (print_data(options)) { + if (per > opts->percent && PDIFF(temp1_uchar,temp2_uchar) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 1, i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar), per); @@ -2286,7 +2275,7 @@ static hsize_t character_compare_opt(unsigned char *mem1, unsigned char *mem2, } } else if (temp1_uchar != temp2_uchar) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 0, i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar)); @@ -2307,7 +2296,7 @@ static hsize_t character_compare_opt(unsigned char *mem1, unsigned char *mem2, *------------------------------------------------------------------------- */ static hsize_t diff_float(unsigned char *mem1, unsigned char *mem2, - hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, hsize_t *acc, hsize_t *pos, diff_opt_t *options, const char *obj1, + hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, const char *obj2, int *ph) { @@ -2327,7 +2316,7 @@ static hsize_t diff_float(unsigned char *mem1, unsigned char *mem2, *------------------------------------------------------------------------- */ - if (options->d && !options->p) { + if (opts->d && !opts->p) { for (i = 0; i < nelmts; i++) { HDmemcpy(&temp1_float, mem1, sizeof(float)); HDmemcpy(&temp2_float, mem2, sizeof(float)); @@ -2336,15 +2325,15 @@ static hsize_t diff_float(unsigned char *mem1, unsigned char *mem2, * detect NaNs *------------------------------------------------------------------------- */ - if (options->do_nans) { + if (opts->do_nans) { isnan1 = my_isnan(FLT_FLOAT, &temp1_float); isnan2 = my_isnan(FLT_FLOAT, &temp2_float); } /* both not NaN, do the comparison */ if (!isnan1 && !isnan2) { - if ((double) ABS(temp1_float - temp2_float) > options->delta) { - if (print_data(options)) { + if ((double) ABS(temp1_float - temp2_float) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float)); @@ -2354,7 +2343,7 @@ static hsize_t diff_float(unsigned char *mem1, unsigned char *mem2, } /* only one is NaN, assume difference */ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float)); @@ -2364,7 +2353,7 @@ static hsize_t diff_float(unsigned char *mem1, unsigned char *mem2, } mem1 += sizeof(float); mem2 += sizeof(float); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } /* i */ } @@ -2372,7 +2361,7 @@ static hsize_t diff_float(unsigned char *mem1, unsigned char *mem2, * !-d and -p *------------------------------------------------------------------------- */ - else if (!options->d && options->p) { + else if (!opts->d && opts->p) { for (i = 0; i < nelmts; i++) { HDmemcpy(&temp1_float, mem1, sizeof(float)); HDmemcpy(&temp2_float, mem2, sizeof(float)); @@ -2381,7 +2370,7 @@ static hsize_t diff_float(unsigned char *mem1, unsigned char *mem2, * detect NaNs *------------------------------------------------------------------------- */ - if (options->do_nans) { + if (opts->do_nans) { isnan1 = my_isnan(FLT_FLOAT, &temp1_float); isnan2 = my_isnan(FLT_FLOAT, &temp2_float); } @@ -2390,15 +2379,15 @@ static hsize_t diff_float(unsigned char *mem1, unsigned char *mem2, PER(temp1_float, temp2_float); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT_P_NOTCOMP, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float)); } nfound++; } - else if (per > options->percent) { - if (print_data(options)) { + else if (per > opts->percent) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT_P, (double) temp1_float, (double) temp2_float, @@ -2409,7 +2398,7 @@ static hsize_t diff_float(unsigned char *mem1, unsigned char *mem2, } /* only one is NaN, assume difference */ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float)); @@ -2419,7 +2408,7 @@ static hsize_t diff_float(unsigned char *mem1, unsigned char *mem2, } mem1 += sizeof(float); mem2 += sizeof(float); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } /* i */ } @@ -2427,7 +2416,7 @@ static hsize_t diff_float(unsigned char *mem1, unsigned char *mem2, * -d and -p *------------------------------------------------------------------------- */ - else if (options->d && options->p) { + else if (opts->d && opts->p) { for (i = 0; i < nelmts; i++) { HDmemcpy(&temp1_float, mem1, sizeof(float)); HDmemcpy(&temp2_float, mem2, sizeof(float)); @@ -2436,7 +2425,7 @@ static hsize_t diff_float(unsigned char *mem1, unsigned char *mem2, * detect NaNs *------------------------------------------------------------------------- */ - if (options->do_nans) { + if (opts->do_nans) { isnan1 = my_isnan(FLT_FLOAT, &temp1_float); isnan2 = my_isnan(FLT_FLOAT, &temp2_float); } @@ -2446,15 +2435,15 @@ static hsize_t diff_float(unsigned char *mem1, unsigned char *mem2, PER(temp1_float, temp2_float); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT_P_NOTCOMP, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float)); } nfound++; } - else if (per > options->percent && (double) ABS(temp1_float - temp2_float) > options->delta) { - if (print_data(options)) { + else if (per > opts->percent && (double) ABS(temp1_float - temp2_float) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT_P, (double) temp1_float, (double) temp2_float, @@ -2466,7 +2455,7 @@ static hsize_t diff_float(unsigned char *mem1, unsigned char *mem2, } /* only one is NaN, assume difference */ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float)); @@ -2476,7 +2465,7 @@ static hsize_t diff_float(unsigned char *mem1, unsigned char *mem2, } mem1 += sizeof(float); mem2 += sizeof(float); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } /* i */ } @@ -2490,8 +2479,8 @@ static hsize_t diff_float(unsigned char *mem1, unsigned char *mem2, HDmemcpy(&temp1_float, mem1, sizeof(float)); HDmemcpy(&temp2_float, mem2, sizeof(float)); - if (equal_float(temp1_float, temp2_float, options) == FALSE) { - if (print_data(options)) { + if (equal_float(temp1_float, temp2_float, opts) == FALSE) { + if (print_data(opts)) { print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT, (double) temp1_float, (double) temp2_float, (double) ABS(temp1_float - temp2_float)); @@ -2501,7 +2490,7 @@ static hsize_t diff_float(unsigned char *mem1, unsigned char *mem2, mem1 += sizeof(float); mem2 += sizeof(float); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } /* nelmts */ } @@ -2520,7 +2509,7 @@ static hsize_t diff_float(unsigned char *mem1, unsigned char *mem2, */ static hsize_t diff_double(unsigned char *mem1, unsigned char *mem2, hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *options, const char *obj1, + hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, const char *obj2, int *ph) { @@ -2539,7 +2528,7 @@ static hsize_t diff_double(unsigned char *mem1, unsigned char *mem2, *------------------------------------------------------------------------- */ - if (options->d && !options->p) { + if (opts->d && !opts->p) { for (i = 0; i < nelmts; i++) { HDmemcpy(&temp1_double, mem1, sizeof(double)); HDmemcpy(&temp2_double, mem2, sizeof(double)); @@ -2548,15 +2537,15 @@ static hsize_t diff_double(unsigned char *mem1, unsigned char *mem2, * detect NaNs *------------------------------------------------------------------------- */ - if (options->do_nans) { + if (opts->do_nans) { isnan1 = my_isnan(FLT_DOUBLE, &temp1_double); isnan2 = my_isnan(FLT_DOUBLE, &temp2_double); } /* both not NaN, do the comparison */ if (!isnan1 && !isnan2) { - if (ABS(temp1_double-temp2_double) > options->delta) { - if (print_data(options)) { + if (ABS(temp1_double-temp2_double) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); @@ -2566,7 +2555,7 @@ static hsize_t diff_double(unsigned char *mem1, unsigned char *mem2, } /* only one is NaN, assume difference */ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); @@ -2576,7 +2565,7 @@ static hsize_t diff_double(unsigned char *mem1, unsigned char *mem2, } mem1 += sizeof(double); mem2 += sizeof(double); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } /* i */ } @@ -2585,7 +2574,7 @@ static hsize_t diff_double(unsigned char *mem1, unsigned char *mem2, * !-d and -p *------------------------------------------------------------------------- */ - else if (!options->d && options->p) { + else if (!opts->d && opts->p) { for (i = 0; i < nelmts; i++) { HDmemcpy(&temp1_double, mem1, sizeof(double)); HDmemcpy(&temp2_double, mem2, sizeof(double)); @@ -2594,7 +2583,7 @@ static hsize_t diff_double(unsigned char *mem1, unsigned char *mem2, * detect NaNs *------------------------------------------------------------------------- */ - if (options->do_nans) { + if (opts->do_nans) { isnan1 = my_isnan(FLT_DOUBLE, &temp1_double); isnan2 = my_isnan(FLT_DOUBLE, &temp2_double); } @@ -2603,15 +2592,15 @@ static hsize_t diff_double(unsigned char *mem1, unsigned char *mem2, PER(temp1_double, temp2_double); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); } nfound++; } - else if (per > options->percent) { - if (print_data(options)) { + else if (per > opts->percent) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT_P, temp1_double, temp2_double, @@ -2622,7 +2611,7 @@ static hsize_t diff_double(unsigned char *mem1, unsigned char *mem2, } /* only one is NaN, assume difference */ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); @@ -2632,7 +2621,7 @@ static hsize_t diff_double(unsigned char *mem1, unsigned char *mem2, } mem1 += sizeof(double); mem2 += sizeof(double); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } /* i */ } @@ -2640,7 +2629,7 @@ static hsize_t diff_double(unsigned char *mem1, unsigned char *mem2, * -d and -p *------------------------------------------------------------------------- */ - else if (options->d && options->p) { + else if (opts->d && opts->p) { for (i = 0; i < nelmts; i++) { HDmemcpy(&temp1_double, mem1, sizeof(double)); @@ -2650,7 +2639,7 @@ static hsize_t diff_double(unsigned char *mem1, unsigned char *mem2, * detect NaNs *------------------------------------------------------------------------- */ - if (options->do_nans) { + if (opts->do_nans) { isnan1 = my_isnan(FLT_DOUBLE, &temp1_double); isnan2 = my_isnan(FLT_DOUBLE, &temp2_double); } @@ -2660,15 +2649,15 @@ static hsize_t diff_double(unsigned char *mem1, unsigned char *mem2, PER(temp1_double, temp2_double); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); } nfound++; } - else if (per > options->percent && ABS(temp1_double-temp2_double) > options->delta) { - if (print_data(options)) { + else if (per > opts->percent && ABS(temp1_double-temp2_double) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT_P, temp1_double, temp2_double, @@ -2679,7 +2668,7 @@ static hsize_t diff_double(unsigned char *mem1, unsigned char *mem2, } /* only one is NaN, assume difference */ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); @@ -2688,7 +2677,7 @@ static hsize_t diff_double(unsigned char *mem1, unsigned char *mem2, } mem1 += sizeof(double); mem2 += sizeof(double); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } /* i */ } @@ -2701,8 +2690,8 @@ static hsize_t diff_double(unsigned char *mem1, unsigned char *mem2, HDmemcpy(&temp1_double, mem1, sizeof(double)); HDmemcpy(&temp2_double, mem2, sizeof(double)); - if (equal_double(temp1_double, temp2_double, options) == FALSE) { - if (print_data(options)) { + if (equal_double(temp1_double, temp2_double, opts) == FALSE) { + if (print_data(opts)) { print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); @@ -2712,7 +2701,7 @@ static hsize_t diff_double(unsigned char *mem1, unsigned char *mem2, mem1 += sizeof(double); mem2 += sizeof(double); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } /* nelmts */ } @@ -2739,7 +2728,7 @@ static hsize_t diff_ldouble(unsigned char *mem1, hsize_t *dims, hsize_t *acc, hsize_t *pos, - diff_opt_t *options, + diff_opt_t *opts, const char *obj1, const char *obj2, int *ph) @@ -2761,7 +2750,7 @@ static hsize_t diff_ldouble(unsigned char *mem1, *------------------------------------------------------------------------- */ - if (options->d && !options->p) { + if (opts->d && !opts->p) { for ( i = 0; i < nelmts; i++) { HDmemcpy(&temp1_double, mem1, sizeof(long double)); HDmemcpy(&temp2_double, mem2, sizeof(long double)); @@ -2770,15 +2759,15 @@ static hsize_t diff_ldouble(unsigned char *mem1, * detect NaNs *------------------------------------------------------------------------- */ - if (options->do_nans) { + if (opts->do_nans) { isnan1 = my_isnan(FLT_LDOUBLE,&temp1_double); isnan2 = my_isnan(FLT_LDOUBLE,&temp2_double); } /* both not NaN, do the comparison */ if (!isnan1 && !isnan2) { - if (ABS(temp1_double-temp2_double) > options->delta) { - if (print_data(options)) { + if (ABS(temp1_double-temp2_double) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); @@ -2788,7 +2777,7 @@ static hsize_t diff_ldouble(unsigned char *mem1, } /* only one is NaN, assume difference */ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); @@ -2798,7 +2787,7 @@ static hsize_t diff_ldouble(unsigned char *mem1, } mem1 += sizeof(long double); mem2 += sizeof(long double); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } /* i */ } @@ -2807,7 +2796,7 @@ static hsize_t diff_ldouble(unsigned char *mem1, * !-d and -p *------------------------------------------------------------------------- */ - else if (!options->d && options->p) { + else if (!opts->d && opts->p) { for (i = 0; i < nelmts; i++) { HDmemcpy(&temp1_double, mem1, sizeof(long double)); HDmemcpy(&temp2_double, mem2, sizeof(long double)); @@ -2816,7 +2805,7 @@ static hsize_t diff_ldouble(unsigned char *mem1, * detect NaNs *------------------------------------------------------------------------- */ - if (options->do_nans) { + if (opts->do_nans) { isnan1 = my_isnan(FLT_LDOUBLE, &temp1_double); isnan2 = my_isnan(FLT_LDOUBLE, &temp2_double); } @@ -2825,15 +2814,15 @@ static hsize_t diff_ldouble(unsigned char *mem1, PER(temp1_double, temp2_double); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); } nfound++; } - else if (per > options->percent) { - if (print_data(options)) { + else if (per > opts->percent) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT_P, temp1_double, temp2_double, @@ -2844,7 +2833,7 @@ static hsize_t diff_ldouble(unsigned char *mem1, } /* only one is NaN, assume difference */ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 0, hyper_start+i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); @@ -2853,7 +2842,7 @@ static hsize_t diff_ldouble(unsigned char *mem1, } mem1 += sizeof(long double); mem2 += sizeof(long double); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } /* i */ } @@ -2861,7 +2850,7 @@ static hsize_t diff_ldouble(unsigned char *mem1, * -d and -p *------------------------------------------------------------------------- */ - else if (options->d && options->p) { + else if (opts->d && opts->p) { for (i = 0; i < nelmts; i++) { HDmemcpy(&temp1_double, mem1, sizeof(long double)); HDmemcpy(&temp2_double, mem2, sizeof(long double)); @@ -2870,7 +2859,7 @@ static hsize_t diff_ldouble(unsigned char *mem1, * detect NaNs *------------------------------------------------------------------------- */ - if (options->do_nans) { + if (opts->do_nans) { isnan1 = my_isnan(FLT_LDOUBLE, &temp1_double); isnan2 = my_isnan(FLT_LDOUBLE, &temp2_double); } @@ -2880,15 +2869,15 @@ static hsize_t diff_ldouble(unsigned char *mem1, PER(temp1_double, temp2_double); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT_P_NOTCOMP, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); } nfound++; } - else if (per > options->percent && ABS(temp1_double - temp2_double) > options->delta) { - if (print_data(options)) { + else if (per > opts->percent && ABS(temp1_double - temp2_double) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT_P, temp1_double, temp2_double, ABS(temp1_double - temp2_double), ABS(1-temp2_double / temp1_double)); @@ -2898,7 +2887,7 @@ static hsize_t diff_ldouble(unsigned char *mem1, } /* only one is NaN, assume difference */ else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); @@ -2907,7 +2896,7 @@ static hsize_t diff_ldouble(unsigned char *mem1, } mem1 += sizeof(long double); mem2 += sizeof(long double); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } /* i */ } @@ -2920,8 +2909,8 @@ static hsize_t diff_ldouble(unsigned char *mem1, HDmemcpy(&temp1_double, mem1, sizeof(long double)); HDmemcpy(&temp2_double, mem2, sizeof(long double)); - if (equal_ldouble(temp1_double, temp2_double, options) == FALSE) { - if (print_data(options)) { + if (equal_ldouble(temp1_double, temp2_double, opts) == FALSE) { + if (print_data(opts)) { print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(F_FORMAT, temp1_double, temp2_double, ABS(temp1_double - temp2_double)); @@ -2930,7 +2919,7 @@ static hsize_t diff_ldouble(unsigned char *mem1, } mem1 += sizeof(long double); mem2 += sizeof(long double); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } /* nelmts */ } @@ -2950,7 +2939,7 @@ static hsize_t diff_ldouble(unsigned char *mem1, */ static hsize_t diff_schar(unsigned char *mem1, unsigned char *mem2, hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *options, const char *obj1, + hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, const char *obj2, int *ph) { @@ -2963,13 +2952,13 @@ static hsize_t diff_schar(unsigned char *mem1, unsigned char *mem2, h5difftrace("diff_schar start\n"); /* -d and !-p */ - if (options->d && !options->p) { + if (opts->d && !opts->p) { for (i = 0; i < nelmts; i++) { HDmemcpy(&temp1_char, mem1, sizeof(char)); HDmemcpy(&temp2_char, mem2, sizeof(char)); - if (ABS(temp1_char-temp2_char) > options->delta) { - if (print_data(options)) { + if (ABS(temp1_char-temp2_char) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT, temp1_char, temp2_char, ABS(temp1_char - temp2_char)); @@ -2978,12 +2967,12 @@ static hsize_t diff_schar(unsigned char *mem1, unsigned char *mem2, } mem1 += sizeof(char); mem2 += sizeof(char); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } } /* !-d and -p */ - else if (!options->d && options->p) { + else if (!opts->d && opts->p) { for (i = 0; i < nelmts; i++) { HDmemcpy(&temp1_char, mem1, sizeof(char)); HDmemcpy(&temp2_char, mem2, sizeof(char)); @@ -2991,15 +2980,15 @@ static hsize_t diff_schar(unsigned char *mem1, unsigned char *mem2, PER(temp1_char, temp2_char); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P_NOTCOMP, temp1_char, temp2_char, ABS(temp1_char - temp2_char)); } nfound++; } - else if (per > options->percent) { - if (print_data(options)) { + else if (per > opts->percent) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P, temp1_char, temp2_char, ABS(temp1_char - temp2_char), per); @@ -3008,12 +2997,12 @@ static hsize_t diff_schar(unsigned char *mem1, unsigned char *mem2, } mem1 += sizeof(char); mem2 += sizeof(char); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } } /* -d and -p */ - else if (options->d && options->p) { + else if (opts->d && opts->p) { for (i = 0; i < nelmts; i++) { HDmemcpy(&temp1_char, mem1, sizeof(char)); HDmemcpy(&temp2_char, mem2, sizeof(char)); @@ -3021,15 +3010,15 @@ static hsize_t diff_schar(unsigned char *mem1, unsigned char *mem2, PER(temp1_char, temp2_char); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P_NOTCOMP, temp1_char, temp2_char, ABS(temp1_char - temp2_char)); } nfound++; } - else if (per > options->percent && ABS(temp1_char-temp2_char) > options->delta) { - if (print_data(options)) { + else if (per > opts->percent && ABS(temp1_char-temp2_char) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P, temp1_char, temp2_char, ABS(temp1_char - temp2_char), per); @@ -3038,7 +3027,7 @@ static hsize_t diff_schar(unsigned char *mem1, unsigned char *mem2, } mem1 += sizeof(char); mem2 += sizeof(char); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } } @@ -3048,7 +3037,7 @@ static hsize_t diff_schar(unsigned char *mem1, unsigned char *mem2, HDmemcpy(&temp2_char, mem2, sizeof(char)); if (temp1_char != temp2_char) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT, temp1_char, temp2_char, ABS(temp1_char - temp2_char)); @@ -3058,7 +3047,7 @@ static hsize_t diff_schar(unsigned char *mem1, unsigned char *mem2, mem1 += sizeof(char); mem2 += sizeof(char); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } /* nelmts */ } @@ -3077,7 +3066,7 @@ static hsize_t diff_schar(unsigned char *mem1, unsigned char *mem2, */ static hsize_t diff_uchar(unsigned char *mem1, unsigned char *mem2, hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *options, const char *obj1, + hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, const char *obj2, int *ph) { hsize_t nfound = 0; /* number of differences found */ @@ -3089,13 +3078,13 @@ static hsize_t diff_uchar(unsigned char *mem1, unsigned char *mem2, h5difftrace("diff_uchar start\n"); /* -d and !-p */ - if (options->d && !options->p) { + if (opts->d && !opts->p) { for (i = 0; i < nelmts; i++) { HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char)); HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char)); - if (PDIFF(temp1_uchar,temp2_uchar) > options->delta) { - if (print_data(options)) { + if (PDIFF(temp1_uchar,temp2_uchar) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar)); @@ -3104,12 +3093,12 @@ static hsize_t diff_uchar(unsigned char *mem1, unsigned char *mem2, } mem1 += sizeof(unsigned char); mem2 += sizeof(unsigned char); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } } /* !-d and -p */ - else if (!options->d && options->p) { + else if (!opts->d && opts->p) { for (i = 0; i < nelmts; i++) { HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char)); HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char)); @@ -3117,15 +3106,15 @@ static hsize_t diff_uchar(unsigned char *mem1, unsigned char *mem2, PER_UNSIGN(signed char, temp1_uchar, temp2_uchar); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P_NOTCOMP, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar)); } nfound++; } - else if (per > options->percent) { - if (print_data(options)) { + else if (per > opts->percent) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar), per); @@ -3134,12 +3123,12 @@ static hsize_t diff_uchar(unsigned char *mem1, unsigned char *mem2, } mem1 += sizeof(unsigned char); mem2 += sizeof(unsigned char); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } } /* -d and -p */ - else if (options->d && options->p) { + else if (opts->d && opts->p) { for (i = 0; i < nelmts; i++) { HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char)); HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char)); @@ -3147,15 +3136,15 @@ static hsize_t diff_uchar(unsigned char *mem1, unsigned char *mem2, PER_UNSIGN(signed char, temp1_uchar, temp2_uchar); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P_NOTCOMP, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar)); } nfound++; } - else if (per > options->percent && PDIFF(temp1_uchar,temp2_uchar) > options->delta) { - if (print_data(options)) { + else if (per > opts->percent && PDIFF(temp1_uchar,temp2_uchar) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar), per); @@ -3164,7 +3153,7 @@ static hsize_t diff_uchar(unsigned char *mem1, unsigned char *mem2, } mem1 += sizeof(unsigned char); mem2 += sizeof(unsigned char); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } } @@ -3174,7 +3163,7 @@ static hsize_t diff_uchar(unsigned char *mem1, unsigned char *mem2, HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char)); if (temp1_uchar != temp2_uchar) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT, temp1_uchar, temp2_uchar, PDIFF(temp1_uchar, temp2_uchar)); @@ -3184,7 +3173,7 @@ static hsize_t diff_uchar(unsigned char *mem1, unsigned char *mem2, mem1 += sizeof(unsigned char); mem2 += sizeof(unsigned char); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } /* nelmts */ } @@ -3203,7 +3192,7 @@ static hsize_t diff_uchar(unsigned char *mem1, unsigned char *mem2, */ static hsize_t diff_short(unsigned char *mem1, unsigned char *mem2, hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *options, const char *obj1, + hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, const char *obj2, int *ph) { hsize_t nfound = 0; /* number of differences found */ @@ -3215,13 +3204,13 @@ static hsize_t diff_short(unsigned char *mem1, unsigned char *mem2, h5difftrace("diff_short start\n"); /* -d and !-p */ - if (options->d && !options->p) { + if (opts->d && !opts->p) { for (i = 0; i < nelmts; i++) { HDmemcpy(&temp1_short, mem1, sizeof(short)); HDmemcpy(&temp2_short, mem2, sizeof(short)); - if (ABS(temp1_short-temp2_short) > options->delta) { - if (print_data(options)) { + if (ABS(temp1_short-temp2_short) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT, temp1_short, temp2_short, ABS(temp1_short - temp2_short)); @@ -3230,12 +3219,12 @@ static hsize_t diff_short(unsigned char *mem1, unsigned char *mem2, } mem1 += sizeof(short); mem2 += sizeof(short); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } } /* !-d and -p */ - else if (!options->d && options->p) { + else if (!opts->d && opts->p) { for (i = 0; i < nelmts; i++) { HDmemcpy(&temp1_short, mem1, sizeof(short)); HDmemcpy(&temp2_short, mem2, sizeof(short)); @@ -3243,15 +3232,15 @@ static hsize_t diff_short(unsigned char *mem1, unsigned char *mem2, PER(temp1_short, temp2_short); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P_NOTCOMP, temp1_short, temp2_short, ABS(temp1_short - temp2_short)); } nfound++; } - else if (per > options->percent) { - if (print_data(options)) { + else if (per > opts->percent) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P, temp1_short, temp2_short, ABS(temp1_short - temp2_short), per); @@ -3260,12 +3249,12 @@ static hsize_t diff_short(unsigned char *mem1, unsigned char *mem2, } mem1 += sizeof(short); mem2 += sizeof(short); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } } /* -d and -p */ - else if (options->d && options->p) { + else if (opts->d && opts->p) { for (i = 0; i < nelmts; i++) { HDmemcpy(&temp1_short, mem1, sizeof(short)); HDmemcpy(&temp2_short, mem2, sizeof(short)); @@ -3273,15 +3262,15 @@ static hsize_t diff_short(unsigned char *mem1, unsigned char *mem2, PER(temp1_short, temp2_short); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P_NOTCOMP, temp1_short, temp2_short, ABS(temp1_short - temp2_short)); } nfound++; } - else if (per > options->percent && ABS(temp1_short-temp2_short) > options->delta) { - if (print_data(options)) { + else if (per > opts->percent && ABS(temp1_short-temp2_short) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P, temp1_short, temp2_short, ABS(temp1_short - temp2_short), per); @@ -3290,7 +3279,7 @@ static hsize_t diff_short(unsigned char *mem1, unsigned char *mem2, } mem1 += sizeof(short); mem2 += sizeof(short); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } } @@ -3300,7 +3289,7 @@ static hsize_t diff_short(unsigned char *mem1, unsigned char *mem2, HDmemcpy(&temp2_short, mem2, sizeof(short)); if (temp1_short != temp2_short) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT, temp1_short, temp2_short, ABS(temp1_short - temp2_short)); @@ -3310,7 +3299,7 @@ static hsize_t diff_short(unsigned char *mem1, unsigned char *mem2, mem1 += sizeof(short); mem2 += sizeof(short); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } /* nelmts */ } @@ -3329,7 +3318,7 @@ static hsize_t diff_short(unsigned char *mem1, unsigned char *mem2, */ static hsize_t diff_ushort(unsigned char *mem1, unsigned char *mem2, hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *options, const char *obj1, + hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, const char *obj2, int *ph) { @@ -3342,13 +3331,13 @@ static hsize_t diff_ushort(unsigned char *mem1, unsigned char *mem2, h5difftrace("diff_ushort start\n"); /* -d and !-p */ - if (options->d && !options->p) { + if (opts->d && !opts->p) { for (i = 0; i < nelmts; i++) { HDmemcpy(&temp1_ushort, mem1, sizeof(unsigned short)); HDmemcpy(&temp2_ushort, mem2, sizeof(unsigned short)); - if (PDIFF(temp1_ushort,temp2_ushort) > options->delta) { - if (print_data(options)) { + if (PDIFF(temp1_ushort,temp2_ushort) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort)); @@ -3357,12 +3346,12 @@ static hsize_t diff_ushort(unsigned char *mem1, unsigned char *mem2, } mem1 += sizeof(unsigned short); mem2 += sizeof(unsigned short); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } } /* !-d and -p */ - else if (!options->d && options->p) { + else if (!opts->d && opts->p) { for (i = 0; i < nelmts; i++) { HDmemcpy(&temp1_ushort, mem1, sizeof(unsigned short)); HDmemcpy(&temp2_ushort, mem2, sizeof(unsigned short)); @@ -3370,15 +3359,15 @@ static hsize_t diff_ushort(unsigned char *mem1, unsigned char *mem2, PER_UNSIGN(signed short, temp1_ushort, temp2_ushort); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P_NOTCOMP, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort)); } nfound++; } - else if (per > options->percent) { - if (print_data(options)) { + else if (per > opts->percent) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort), per); @@ -3387,12 +3376,12 @@ static hsize_t diff_ushort(unsigned char *mem1, unsigned char *mem2, } mem1 += sizeof(unsigned short); mem2 += sizeof(unsigned short); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } } /* -d and -p */ - else if (options->d && options->p) { + else if (opts->d && opts->p) { for (i = 0; i < nelmts; i++) { HDmemcpy(&temp1_ushort, mem1, sizeof(unsigned short)); HDmemcpy(&temp2_ushort, mem2, sizeof(unsigned short)); @@ -3400,15 +3389,15 @@ static hsize_t diff_ushort(unsigned char *mem1, unsigned char *mem2, PER_UNSIGN(signed short, temp1_ushort, temp2_ushort); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P_NOTCOMP, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort)); } nfound++; } - else if (per > options->percent && PDIFF(temp1_ushort,temp2_ushort) > options->delta) { - if (print_data(options)) { + else if (per > opts->percent && PDIFF(temp1_ushort,temp2_ushort) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort), per); @@ -3417,7 +3406,7 @@ static hsize_t diff_ushort(unsigned char *mem1, unsigned char *mem2, } mem1 += sizeof(unsigned short); mem2 += sizeof(unsigned short); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } } @@ -3427,7 +3416,7 @@ static hsize_t diff_ushort(unsigned char *mem1, unsigned char *mem2, HDmemcpy(&temp2_ushort, mem2, sizeof(unsigned short)); if (temp1_ushort != temp2_ushort) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT, temp1_ushort, temp2_ushort, PDIFF(temp1_ushort, temp2_ushort)); @@ -3437,7 +3426,7 @@ static hsize_t diff_ushort(unsigned char *mem1, unsigned char *mem2, mem1 += sizeof(unsigned short); mem2 += sizeof(unsigned short); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } /* nelmts */ } @@ -3456,7 +3445,7 @@ static hsize_t diff_ushort(unsigned char *mem1, unsigned char *mem2, */ static hsize_t diff_int(unsigned char *mem1, unsigned char *mem2, hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *options, const char *obj1, + hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, const char *obj2, int *ph) { hsize_t nfound = 0; /* number of differences found */ @@ -3468,13 +3457,13 @@ static hsize_t diff_int(unsigned char *mem1, unsigned char *mem2, h5difftrace("diff_int start\n"); /* -d and !-p */ - if (options->d && !options->p) { + if (opts->d && !opts->p) { for (i = 0; i < nelmts; i++) { HDmemcpy(&temp1_int, mem1, sizeof(int)); HDmemcpy(&temp2_int, mem2, sizeof(int)); - if (ABS(temp1_int-temp2_int) > options->delta) { - if (print_data(options)) { + if (ABS(temp1_int-temp2_int) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT, temp1_int, temp2_int, ABS(temp1_int - temp2_int)); @@ -3483,12 +3472,12 @@ static hsize_t diff_int(unsigned char *mem1, unsigned char *mem2, } mem1 += sizeof(int); mem2 += sizeof(int); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } } /* !-d and -p */ - else if (!options->d && options->p) { + else if (!opts->d && opts->p) { for (i = 0; i < nelmts; i++) { HDmemcpy(&temp1_int, mem1, sizeof(int)); HDmemcpy(&temp2_int, mem2, sizeof(int)); @@ -3496,15 +3485,15 @@ static hsize_t diff_int(unsigned char *mem1, unsigned char *mem2, PER(temp1_int, temp2_int); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P_NOTCOMP, temp1_int, temp2_int, ABS(temp1_int - temp2_int)); } nfound++; } - else if (per > options->percent) { - if (print_data(options)) { + else if (per > opts->percent) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P, temp1_int, temp2_int, ABS(temp1_int - temp2_int), per); @@ -3513,12 +3502,12 @@ static hsize_t diff_int(unsigned char *mem1, unsigned char *mem2, } mem1 += sizeof(int); mem2 += sizeof(int); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } } /* -d and -p */ - else if (options->d && options->p) { + else if (opts->d && opts->p) { for (i = 0; i < nelmts; i++) { HDmemcpy(&temp1_int, mem1, sizeof(int)); HDmemcpy(&temp2_int, mem2, sizeof(int)); @@ -3526,15 +3515,15 @@ static hsize_t diff_int(unsigned char *mem1, unsigned char *mem2, PER(temp1_int, temp2_int); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P_NOTCOMP, temp1_int, temp2_int, ABS(temp1_int - temp2_int)); } nfound++; } - else if (per > options->percent && ABS(temp1_int-temp2_int) > options->delta) { - if (print_data(options)) { + else if (per > opts->percent && ABS(temp1_int-temp2_int) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P, temp1_int, temp2_int, ABS(temp1_int - temp2_int), per); @@ -3543,7 +3532,7 @@ static hsize_t diff_int(unsigned char *mem1, unsigned char *mem2, } mem1 += sizeof(int); mem2 += sizeof(int); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } } @@ -3553,7 +3542,7 @@ static hsize_t diff_int(unsigned char *mem1, unsigned char *mem2, HDmemcpy(&temp2_int, mem2, sizeof(int)); if (temp1_int != temp2_int) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT, temp1_int, temp2_int, ABS(temp1_int - temp2_int)); @@ -3563,7 +3552,7 @@ static hsize_t diff_int(unsigned char *mem1, unsigned char *mem2, mem1 += sizeof(int); mem2 += sizeof(int); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } /* nelmts */ @@ -3582,7 +3571,7 @@ static hsize_t diff_int(unsigned char *mem1, unsigned char *mem2, */ static hsize_t diff_uint(unsigned char *mem1, unsigned char *mem2, hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *options, const char *obj1, + hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, const char *obj2, int *ph) { hsize_t nfound = 0; /* number of differences found */ @@ -3594,13 +3583,13 @@ static hsize_t diff_uint(unsigned char *mem1, unsigned char *mem2, h5difftrace("diff_uint start\n"); /* -d and !-p */ - if (options->d && !options->p) { + if (opts->d && !opts->p) { for (i = 0; i < nelmts; i++) { HDmemcpy(&temp1_uint, mem1, sizeof(unsigned int)); HDmemcpy(&temp2_uint, mem2, sizeof(unsigned int)); - if (PDIFF(temp1_uint,temp2_uint) > options->delta) { - if (print_data(options)) { + if (PDIFF(temp1_uint,temp2_uint) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint)); @@ -3609,12 +3598,12 @@ static hsize_t diff_uint(unsigned char *mem1, unsigned char *mem2, } mem1 += sizeof(unsigned int); mem2 += sizeof(unsigned int); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } } /* !-d and -p */ - else if (!options->d && options->p) { + else if (!opts->d && opts->p) { for (i = 0; i < nelmts; i++) { HDmemcpy(&temp1_uint, mem1, sizeof(unsigned int)); HDmemcpy(&temp2_uint, mem2, sizeof(unsigned int)); @@ -3622,15 +3611,15 @@ static hsize_t diff_uint(unsigned char *mem1, unsigned char *mem2, PER_UNSIGN(signed int, temp1_uint, temp2_uint); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P_NOTCOMP, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint)); } nfound++; } - else if (per > options->percent) { - if (print_data(options)) { + else if (per > opts->percent) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint), per); @@ -3639,12 +3628,12 @@ static hsize_t diff_uint(unsigned char *mem1, unsigned char *mem2, } mem1 += sizeof(unsigned int); mem2 += sizeof(unsigned int); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } } /* -d and -p */ - else if (options->d && options->p) { + else if (opts->d && opts->p) { for (i = 0; i < nelmts; i++) { HDmemcpy(&temp1_uint, mem1, sizeof(unsigned int)); HDmemcpy(&temp2_uint, mem2, sizeof(unsigned int)); @@ -3652,16 +3641,16 @@ static hsize_t diff_uint(unsigned char *mem1, unsigned char *mem2, PER_UNSIGN(signed int, temp1_uint, temp2_uint); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P_NOTCOMP, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint)); } nfound++; } - else if (per > options->percent - && PDIFF(temp1_uint,temp2_uint) > options->delta) { - if (print_data(options)) { + else if (per > opts->percent + && PDIFF(temp1_uint,temp2_uint) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT_P, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint), per); @@ -3670,7 +3659,7 @@ static hsize_t diff_uint(unsigned char *mem1, unsigned char *mem2, } mem1 += sizeof(unsigned int); mem2 += sizeof(unsigned int); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } } @@ -3680,7 +3669,7 @@ static hsize_t diff_uint(unsigned char *mem1, unsigned char *mem2, HDmemcpy(&temp2_uint, mem2, sizeof(unsigned int)); if (temp1_uint != temp2_uint) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(I_FORMAT, temp1_uint, temp2_uint, PDIFF(temp1_uint, temp2_uint)); @@ -3690,7 +3679,7 @@ static hsize_t diff_uint(unsigned char *mem1, unsigned char *mem2, mem1 += sizeof(unsigned int); mem2 += sizeof(unsigned int); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } /* nelmts */ } @@ -3709,7 +3698,7 @@ static hsize_t diff_uint(unsigned char *mem1, unsigned char *mem2, */ static hsize_t diff_long(unsigned char *mem1, unsigned char *mem2, hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *options, const char *obj1, + hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, const char *obj2, int *ph) { hsize_t nfound = 0; /* number of differences found */ @@ -3721,14 +3710,14 @@ static hsize_t diff_long(unsigned char *mem1, unsigned char *mem2, h5difftrace("diff_long start\n"); /* -d and !-p */ - if (options->d && !options->p) { + if (opts->d && !opts->p) { for (i = 0; i < nelmts; i++) { for (i = 0; i < nelmts; i++) { HDmemcpy(&temp1_long, mem1, sizeof(long)); HDmemcpy(&temp2_long, mem2, sizeof(long)); - if (ABS(temp1_long-temp2_long) > options->delta) { - if (print_data(options)) { + if (ABS(temp1_long-temp2_long) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(LI_FORMAT, temp1_long, temp2_long, ABS(temp1_long - temp2_long)); @@ -3737,13 +3726,13 @@ static hsize_t diff_long(unsigned char *mem1, unsigned char *mem2, } mem1 += sizeof(long); mem2 += sizeof(long); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } } } /* !-d and -p */ - else if (!options->d && options->p) { + else if (!opts->d && opts->p) { for (i = 0; i < nelmts; i++) { HDmemcpy(&temp1_long, mem1, sizeof(long)); HDmemcpy(&temp2_long, mem2, sizeof(long)); @@ -3751,15 +3740,15 @@ static hsize_t diff_long(unsigned char *mem1, unsigned char *mem2, PER(temp1_long, temp2_long); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(LI_FORMAT_P_NOTCOMP, temp1_long, temp2_long, ABS(temp1_long - temp2_long)); } nfound++; } - else if (per > options->percent) { - if (print_data(options)) { + else if (per > opts->percent) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(LI_FORMAT_P, temp1_long, temp2_long, ABS(temp1_long - temp2_long), per); @@ -3768,12 +3757,12 @@ static hsize_t diff_long(unsigned char *mem1, unsigned char *mem2, } mem1 += sizeof(long); mem2 += sizeof(long); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } } /* -d and -p */ - else if (options->d && options->p) { + else if (opts->d && opts->p) { for (i = 0; i < nelmts; i++) { HDmemcpy(&temp1_long, mem1, sizeof(long)); HDmemcpy(&temp2_long, mem2, sizeof(long)); @@ -3781,15 +3770,15 @@ static hsize_t diff_long(unsigned char *mem1, unsigned char *mem2, PER(temp1_long, temp2_long); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(LI_FORMAT_P_NOTCOMP, temp1_long, temp2_long, ABS(temp1_long - temp2_long)); } nfound++; } - else if (per > options->percent && ABS(temp1_long-temp2_long) > options->delta) { - if (print_data(options)) { + else if (per > opts->percent && ABS(temp1_long-temp2_long) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(LI_FORMAT_P, temp1_long, temp2_long, ABS(temp1_long - temp2_long), per); @@ -3798,7 +3787,7 @@ static hsize_t diff_long(unsigned char *mem1, unsigned char *mem2, } mem1 += sizeof(long); mem2 += sizeof(long); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } } @@ -3808,7 +3797,7 @@ static hsize_t diff_long(unsigned char *mem1, unsigned char *mem2, HDmemcpy(&temp2_long, mem2, sizeof(long)); if (temp1_long != temp2_long) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(LI_FORMAT, temp1_long, temp2_long, ABS(temp1_long - temp2_long)); @@ -3818,7 +3807,7 @@ static hsize_t diff_long(unsigned char *mem1, unsigned char *mem2, mem1 += sizeof(long); mem2 += sizeof(long); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } /* nelmts */ } @@ -3837,7 +3826,7 @@ static hsize_t diff_long(unsigned char *mem1, unsigned char *mem2, */ static hsize_t diff_ulong(unsigned char *mem1, unsigned char *mem2, hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *options, const char *obj1, + hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, const char *obj2, int *ph) { hsize_t nfound = 0; /* number of differences found */ @@ -3850,14 +3839,14 @@ static hsize_t diff_ulong(unsigned char *mem1, unsigned char *mem2, h5difftrace("diff_ulong start\n"); /* -d and !-p */ - if (options->d && !options->p) { + if (opts->d && !opts->p) { for (i = 0; i < nelmts; i++) { for (i = 0; i < nelmts; i++) { HDmemcpy(&temp1_ulong, mem1, sizeof(unsigned long)); HDmemcpy(&temp2_ulong, mem2, sizeof(unsigned long)); - if (PDIFF(temp1_ulong,temp2_ulong) > options->delta) { - if (print_data(options)) { + if (PDIFF(temp1_ulong,temp2_ulong) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(LI_FORMAT, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong)); @@ -3866,13 +3855,13 @@ static hsize_t diff_ulong(unsigned char *mem1, unsigned char *mem2, } mem1 += sizeof(unsigned long); mem2 += sizeof(unsigned long); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } } } /* !-d and -p */ - else if (!options->d && options->p) { + else if (!opts->d && opts->p) { for (i = 0; i < nelmts; i++) { HDmemcpy(&temp1_ulong, mem1, sizeof(unsigned long)); HDmemcpy(&temp2_ulong, mem2, sizeof(unsigned long)); @@ -3880,15 +3869,15 @@ static hsize_t diff_ulong(unsigned char *mem1, unsigned char *mem2, PER_UNSIGN(signed long, temp1_ulong, temp2_ulong); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(ULI_FORMAT_P_NOTCOMP, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong)); } nfound++; } - else if (per > options->percent) { - if (print_data(options)) { + else if (per > opts->percent) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(LI_FORMAT_P, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong), per); @@ -3897,12 +3886,12 @@ static hsize_t diff_ulong(unsigned char *mem1, unsigned char *mem2, } mem1 += sizeof(unsigned long); mem2 += sizeof(unsigned long); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } } /* -d and -p */ - else if (options->d && options->p) { + else if (opts->d && opts->p) { for (i = 0; i < nelmts; i++) { HDmemcpy(&temp1_ulong, mem1, sizeof(unsigned long)); HDmemcpy(&temp2_ulong, mem2, sizeof(unsigned long)); @@ -3910,16 +3899,16 @@ static hsize_t diff_ulong(unsigned char *mem1, unsigned char *mem2, PER_UNSIGN(signed long, temp1_ulong, temp2_ulong); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(ULI_FORMAT_P_NOTCOMP, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong)); } nfound++; } - else if (per > options->percent - && PDIFF(temp1_ulong,temp2_ulong) > options->delta) { - if (print_data(options)) { + else if (per > opts->percent + && PDIFF(temp1_ulong,temp2_ulong) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(LI_FORMAT_P, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong), per); @@ -3928,7 +3917,7 @@ static hsize_t diff_ulong(unsigned char *mem1, unsigned char *mem2, } mem1 += sizeof(unsigned long); mem2 += sizeof(unsigned long); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } } @@ -3938,7 +3927,7 @@ static hsize_t diff_ulong(unsigned char *mem1, unsigned char *mem2, HDmemcpy(&temp2_ulong, mem2, sizeof(unsigned long)); if (temp1_ulong != temp2_ulong) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(LI_FORMAT, temp1_ulong, temp2_ulong, PDIFF(temp1_ulong, temp2_ulong)); @@ -3948,7 +3937,7 @@ static hsize_t diff_ulong(unsigned char *mem1, unsigned char *mem2, mem1 += sizeof(unsigned long); mem2 += sizeof(unsigned long); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } /* nelmts */ } @@ -3967,7 +3956,7 @@ static hsize_t diff_ulong(unsigned char *mem1, unsigned char *mem2, */ static hsize_t diff_llong(unsigned char *mem1, unsigned char *mem2, hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, - hsize_t *acc, hsize_t *pos, diff_opt_t *options, const char *obj1, + hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, const char *obj2, int *ph) { hsize_t nfound = 0; /* number of differences found */ @@ -3979,13 +3968,13 @@ static hsize_t diff_llong(unsigned char *mem1, unsigned char *mem2, h5difftrace("diff_llong start\n"); /* -d and !-p */ - if (options->d && !options->p) { + if (opts->d && !opts->p) { for (i = 0; i < nelmts; i++) { HDmemcpy(&temp1_llong, mem1, sizeof(long long)); HDmemcpy(&temp2_llong, mem2, sizeof(long long)); - if (ABS( temp1_llong-temp2_llong) > options->delta) { - if (print_data(options)) { + if (ABS( temp1_llong-temp2_llong) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(LLI_FORMAT, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong)); @@ -3994,12 +3983,12 @@ static hsize_t diff_llong(unsigned char *mem1, unsigned char *mem2, } mem1 += sizeof(long long); mem2 += sizeof(long long); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } } /* !-d and -p */ - else if (!options->d && options->p) { + else if (!opts->d && opts->p) { for (i = 0; i < nelmts; i++) { HDmemcpy(&temp1_llong, mem1, sizeof(long long)); HDmemcpy(&temp2_llong, mem2, sizeof(long long)); @@ -4007,15 +3996,15 @@ static hsize_t diff_llong(unsigned char *mem1, unsigned char *mem2, PER(temp1_llong, temp2_llong); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(LLI_FORMAT_P_NOTCOMP, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong)); } nfound++; } - else if (per > options->percent) { - if (print_data(options)) { + else if (per > opts->percent) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(LLI_FORMAT_P, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong),per); @@ -4024,12 +4013,12 @@ static hsize_t diff_llong(unsigned char *mem1, unsigned char *mem2, } mem1 += sizeof(long long); mem2 += sizeof(long long); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } } /* -d and -p */ - else if (options->d && options->p) { + else if (opts->d && opts->p) { for (i = 0; i < nelmts; i++) { HDmemcpy(&temp1_llong, mem1, sizeof(long long)); HDmemcpy(&temp2_llong, mem2, sizeof(long long)); @@ -4037,16 +4026,16 @@ static hsize_t diff_llong(unsigned char *mem1, unsigned char *mem2, PER(temp1_llong, temp2_llong); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(LLI_FORMAT_P_NOTCOMP, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong)); } nfound++; } - else if (per > options->percent - && ABS(temp1_llong-temp2_llong) > options->delta) { - if (print_data(options)) { + else if (per > opts->percent + && ABS(temp1_llong-temp2_llong) > opts->delta) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(LLI_FORMAT_P, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong),per); @@ -4055,7 +4044,7 @@ static hsize_t diff_llong(unsigned char *mem1, unsigned char *mem2, } mem1 += sizeof(long long); mem2 += sizeof(long long); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } } @@ -4065,7 +4054,7 @@ static hsize_t diff_llong(unsigned char *mem1, unsigned char *mem2, HDmemcpy(&temp2_llong, mem2, sizeof(long long)); if (temp1_llong != temp2_llong) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(LLI_FORMAT, temp1_llong, temp2_llong, ABS(temp1_llong - temp2_llong)); @@ -4075,7 +4064,7 @@ static hsize_t diff_llong(unsigned char *mem1, unsigned char *mem2, mem1 += sizeof(long long); mem2 += sizeof(long long); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } /* nelmts */ } @@ -4094,7 +4083,7 @@ static hsize_t diff_llong(unsigned char *mem1, unsigned char *mem2, */ static hsize_t diff_ullong(unsigned char *mem1, unsigned char *mem2, hsize_t nelmts, hsize_t hyper_start, int rank, hsize_t *dims, hsize_t *acc, - hsize_t *pos, diff_opt_t *options, const char *obj1, const char *obj2, int *ph) + hsize_t *pos, diff_opt_t *opts, const char *obj1, const char *obj2, int *ph) { hsize_t nfound = 0; /* number of differences found */ @@ -4107,13 +4096,13 @@ static hsize_t diff_ullong(unsigned char *mem1, unsigned char *mem2, h5difftrace("diff_ullong start\n"); /* -d and !-p */ - if (options->d && !options->p) { + if (opts->d && !opts->p) { for (i = 0; i < nelmts; i++) { HDmemcpy(&temp1_ullong, mem1, sizeof(unsigned long long)); HDmemcpy(&temp2_ullong, mem2, sizeof(unsigned long long)); - if (PDIFF(temp1_ullong,temp2_ullong) > (unsigned long long) options->delta) { - if (print_data(options)) { + if (PDIFF(temp1_ullong,temp2_ullong) > (unsigned long long) opts->delta) { + if (print_data(opts)) { print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(ULLI_FORMAT,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong)); @@ -4122,12 +4111,12 @@ static hsize_t diff_ullong(unsigned char *mem1, unsigned char *mem2, } mem1 += sizeof(unsigned long long); mem2 += sizeof(unsigned long long); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } } /* !-d and -p */ - else if (!options->d && options->p) { + else if (!opts->d && opts->p) { for (i = 0; i < nelmts; i++) { HDmemcpy(&temp1_ullong, mem1, sizeof(unsigned long long)); HDmemcpy(&temp2_ullong, mem2, sizeof(unsigned long long)); @@ -4137,15 +4126,15 @@ static hsize_t diff_ullong(unsigned char *mem1, unsigned char *mem2, PER(f1, f2); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(ULLI_FORMAT_P_NOTCOMP,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong)); } nfound++; } - else if (per > options->percent) { - if (print_data(options)) { + else if (per > opts->percent) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(ULLI_FORMAT_P,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong),per); @@ -4154,12 +4143,12 @@ static hsize_t diff_ullong(unsigned char *mem1, unsigned char *mem2, } mem1 += sizeof(unsigned long long); mem2 += sizeof(unsigned long long); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } } /* -d and -p */ - else if (options->d && options->p) { + else if (opts->d && opts->p) { for (i = 0; i < nelmts; i++) { HDmemcpy(&temp1_ullong, mem1, sizeof(unsigned long long)); HDmemcpy(&temp2_ullong, mem2, sizeof(unsigned long long)); @@ -4169,16 +4158,16 @@ static hsize_t diff_ullong(unsigned char *mem1, unsigned char *mem2, PER(f1, f2); if (not_comparable && !both_zero) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(ULLI_FORMAT_P_NOTCOMP,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong)); } nfound++; } - else if (per > options->percent - && PDIFF(temp1_ullong,temp2_ullong) > (unsigned long long) options->delta) { - if (print_data(options)) { + else if (per > opts->percent + && PDIFF(temp1_ullong,temp2_ullong) > (unsigned long long) opts->delta) { + if (print_data(opts)) { print_pos(ph, 1, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(ULLI_FORMAT_P,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong),per); @@ -4187,7 +4176,7 @@ static hsize_t diff_ullong(unsigned char *mem1, unsigned char *mem2, } mem1 += sizeof(unsigned long long); mem2 += sizeof(unsigned long long); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } } @@ -4197,7 +4186,7 @@ static hsize_t diff_ullong(unsigned char *mem1, unsigned char *mem2, HDmemcpy(&temp2_ullong, mem2, sizeof(unsigned long long)); if (temp1_ullong != temp2_ullong) { - if (print_data(options)) { + if (print_data(opts)) { print_pos(ph, 0, hyper_start + i, acc, pos, rank, dims, obj1, obj2); parallel_print(SPACES); parallel_print(ULLI_FORMAT,temp1_ullong,temp2_ullong,PDIFF(temp1_ullong,temp2_ullong)); @@ -4207,7 +4196,7 @@ static hsize_t diff_ullong(unsigned char *mem1, unsigned char *mem2, mem1 += sizeof(unsigned long long); mem2 += sizeof(unsigned long long); - if (options->n && nfound >= options->count) + if (opts->n && nfound >= opts->count) return nfound; } /* nelmts */ } @@ -4270,9 +4259,9 @@ done: * Purpose: use a absolute error formula to deal with floating point uncertainty *------------------------------------------------------------------------- */ -static hbool_t equal_double(double value, double expected, diff_opt_t *options) { +static hbool_t equal_double(double value, double expected, diff_opt_t *opts) { h5difftrace("equal_double start\n"); - if (options->do_nans) { + if (opts->do_nans) { /*------------------------------------------------------------------------- * detect NaNs *------------------------------------------------------------------------- @@ -4298,7 +4287,7 @@ static hbool_t equal_double(double value, double expected, diff_opt_t *options) if (value == expected) return TRUE; - if (options->use_system_epsilon) + if (opts->use_system_epsilon) if (ABS((value-expected)) < DBL_EPSILON) return TRUE; @@ -4316,10 +4305,10 @@ static hbool_t equal_double(double value, double expected, diff_opt_t *options) #if H5_SIZEOF_LONG_DOUBLE !=0 static -hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *options) +hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *opts) { h5difftrace("equal_ldouble start\n"); - if (options->do_nans) { + if (opts->do_nans) { /*------------------------------------------------------------------------- * detect NaNs *------------------------------------------------------------------------- @@ -4345,7 +4334,7 @@ hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *optio if (value == expected) return TRUE; - if (options->use_system_epsilon) + if (opts->use_system_epsilon) if (ABS((value-expected)) < DBL_EPSILON) return TRUE; @@ -4362,9 +4351,9 @@ hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *optio * Purpose: use a absolute error formula to deal with floating point uncertainty *------------------------------------------------------------------------- */ -static hbool_t equal_float(float value, float expected, diff_opt_t *options) { +static hbool_t equal_float(float value, float expected, diff_opt_t *opts) { h5difftrace("equal_float start\n"); - if (options->do_nans) { + if (opts->do_nans) { /*------------------------------------------------------------------------- * detect NaNs *------------------------------------------------------------------------- @@ -4390,7 +4379,7 @@ static hbool_t equal_float(float value, float expected, diff_opt_t *options) { if (value == expected) return TRUE; - if (options->use_system_epsilon) + if (opts->use_system_epsilon) if ( ABS( (value-expected) ) < FLT_EPSILON) return TRUE; @@ -4490,9 +4479,9 @@ static hbool_t my_isnan(dtype_t type, void *val) { *------------------------------------------------------------------------- */ static -int print_data(diff_opt_t *options) +int print_data(diff_opt_t *opts) { - return ((options->m_report || options->m_verbose) && !options->m_quiet) ? 1 : 0; + return ((opts->m_report || opts->m_verbose) && !opts->m_quiet) ? 1 : 0; } /*------------------------------------------------------------------------- diff --git a/tools/lib/h5diff_attr.c b/tools/lib/h5diff_attr.c index 64038f3..d671449 100644 --- a/tools/lib/h5diff_attr.c +++ b/tools/lib/h5diff_attr.c @@ -137,7 +137,7 @@ static void table_attr_mark_exist(unsigned *exist, char *name, table_attrs_t *ta * Parameter: * table_out [OUT] : return the list *------------------------------------------------------------------------*/ -static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t ** table_out, diff_opt_t *options) +static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t ** table_out, diff_opt_t *opts) { int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ H5O_info_t oinfo1, oinfo2; /* Object info */ @@ -264,7 +264,7 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t /*------------------------------------------------------ * print the list */ - if(options->m_verbose_level == 2) { + if(opts->m_verbose_level == 2) { /* if '-v2' is detected */ parallel_print(" obj1 obj2\n"); parallel_print(" --------------------------------------\n"); @@ -276,7 +276,7 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t } /* end for */ } - if(options->m_verbose_level >= 1) + if(opts->m_verbose_level >= 1) parallel_print("Attributes status: %d common, %d only in obj1, %d only in obj2\n", table_lp->nattrs - table_lp->nattrs_only1 - table_lp->nattrs_only2, table_lp->nattrs_only1, table_lp->nattrs_only2); @@ -312,7 +312,7 @@ hsize_t diff_attr(hid_t loc1_id, hid_t loc2_id, const char *path1, const char *path2, - diff_opt_t *options) + diff_opt_t *opts) { int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ hid_t attr1_id = -1; /* attr ID */ @@ -349,16 +349,16 @@ hsize_t diff_attr(hid_t loc1_id, h5difftrace("diff_attr start\n"); /* Initialize error status */ - options->err_stat = 1; + opts->err_stat = 1; - if(build_match_list_attrs(loc1_id, loc2_id, &match_list_attrs, options) < 0) + if(build_match_list_attrs(loc1_id, loc2_id, &match_list_attrs, opts) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "build_match_list_attrs failed"); /* if detect any unique extra attr */ if(match_list_attrs->nattrs_only1 || match_list_attrs->nattrs_only2) { h5difftrace("diff_attr attributes only in one file\n"); /* exit will be 1 */ - options->contents = 0; + opts->contents = 0; } for(u = 0; u < (unsigned)match_list_attrs->nattrs; u++) { @@ -387,10 +387,10 @@ hsize_t diff_attr(hid_t loc1_id, /* no compare if either one but not both are variable string type */ if (vstrtype1 != vstrtype2) { - if((options->m_verbose || options->m_list_not_cmp)) + if((opts->m_verbose || opts->m_list_not_cmp)) parallel_print("Not comparable: one of attribute <%s/%s> or <%s/%s> is of variable length type\n", path1, name1, path2, name2); - options->not_cmp = 1; + opts->not_cmp = 1; if (H5Tclose(ftype1_id) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose first attribute ftype failed"); if (H5Tclose(ftype2_id) < 0) @@ -432,7 +432,7 @@ hsize_t diff_attr(hid_t loc1_id, /* pass dims1 and dims2 for maxdims as well since attribute's maxdims * are always same */ if(diff_can_type(ftype1_id, ftype2_id, rank1, rank2, dims1, dims2, - dims1, dims2, name1, name2, options, 0) != 1) { + dims1, dims2, name1, name2, opts, 0) != 1) { if(H5Tclose(ftype1_id) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose first attribute ftype failed"); if(H5Tclose(ftype2_id) < 0) @@ -500,22 +500,22 @@ hsize_t diff_attr(hid_t loc1_id, /* always print name */ /* verbose (-v) and report (-r) mode */ - if(options->m_verbose || options->m_report) { + if(opts->m_verbose || opts->m_report) { do_print_attrname("attribute", np1, np2); nfound = diff_array(buf1, buf2, nelmts1, (hsize_t) 0, rank1, - dims1, options, np1, np2, mtype1_id, attr1_id, attr2_id); + dims1, opts, np1, np2, mtype1_id, attr1_id, attr2_id); print_found(nfound); } /* quiet mode (-q), just count differences */ - else if(options->m_quiet) { + else if(opts->m_quiet) { nfound = diff_array(buf1, buf2, nelmts1, (hsize_t) 0, rank1, - dims1, options, np1, np2, mtype1_id, attr1_id, attr2_id); + dims1, opts, np1, np2, mtype1_id, attr1_id, attr2_id); } /* the rest (-c, none, ...) */ else { nfound = diff_array(buf1, buf2, nelmts1, (hsize_t) 0, rank1, - dims1, options, np1, np2, mtype1_id, attr1_id, attr2_id); + dims1, opts, np1, np2, mtype1_id, attr1_id, attr2_id); /* print info if compatible and difference found */ if (nfound) { @@ -562,7 +562,7 @@ hsize_t diff_attr(hid_t loc1_id, } } /* u */ - options->err_stat = 0; + opts->err_stat = 0; done: H5E_BEGIN_TRY { diff --git a/tools/lib/h5diff_dset.c b/tools/lib/h5diff_dset.c index 16239f5..768caff 100644 --- a/tools/lib/h5diff_dset.c +++ b/tools/lib/h5diff_dset.c @@ -31,7 +31,7 @@ hsize_t diff_dataset(hid_t file1_id, hid_t file2_id, const char *obj1_name, const char *obj2_name, - diff_opt_t *options) + diff_opt_t *opts) { int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ hid_t did1 = -1; @@ -41,7 +41,7 @@ hsize_t diff_dataset(hid_t file1_id, hsize_t nfound = 0; h5difftrace("diff_dataset start\n"); - options->err_stat = 1; + opts->err_stat = 1; /*------------------------------------------------------------------------- * open the handles *------------------------------------------------------------------------- @@ -68,13 +68,16 @@ hsize_t diff_dataset(hid_t file1_id, * 2) the internal filters might be turned off *------------------------------------------------------------------------- */ - if ((h5tools_canreadf((options->m_verbose ? obj1_name : NULL), dcpl1) == 1) && - (h5tools_canreadf((options->m_verbose ? obj2_name : NULL), dcpl2) == 1)) - nfound = diff_datasetid(did1, did2, obj1_name, obj2_name, options); - else + if ((ret_value = h5tools_canreadf((opts->m_verbose ? obj1_name : NULL), dcpl1) == 1) && + (ret_value = h5tools_canreadf((opts->m_verbose ? obj2_name : NULL), dcpl2) == 1)) + nfound = diff_datasetid(did1, did2, obj1_name, obj2_name, opts); + else if (ret_value < 0) { HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5tools_canreadf failed"); + } + else + opts->not_cmp = 1; - options->err_stat = 0; + opts->err_stat = 0; done: /* disable error reporting */ @@ -86,7 +89,7 @@ done: /* enable error reporting */ } H5E_END_TRY; - h5difftrace("diff_dataset end\n"); + h5diffdebug2("diff_dataset finish:%d\n", nfound); return nfound; } @@ -145,7 +148,7 @@ hsize_t diff_datasetid(hid_t did1, hid_t did2, const char *obj1_name, const char *obj2_name, - diff_opt_t *options) + diff_opt_t *opts) { int ret_value = 0; /* no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ hid_t sid1 = -1; @@ -189,7 +192,7 @@ hsize_t diff_datasetid(hid_t did1, int i; unsigned int vl_data = 0; /*contains VL datatypes */ - options->err_stat = 1; + opts->err_stat = 1; h5difftrace("diff_datasetid start\n"); /* Get the dataspace handle */ if((sid1 = H5Dget_space(did1)) < 0) @@ -255,14 +258,14 @@ hsize_t diff_datasetid(hid_t did1, if(storage_size1 == 0 || storage_size2 == 0) { if(stl1 == H5D_VIRTUAL || stl2 == H5D_VIRTUAL) { - if((options->m_verbose||options->m_list_not_cmp) && obj1_name && obj2_name) + if((opts->m_verbose||opts->m_list_not_cmp) && obj1_name && obj2_name) parallel_print("Warning: <%s> or <%s> is a virtual dataset\n", obj1_name, obj2_name); } else { - if((options->m_verbose || options->m_list_not_cmp) && obj1_name && obj2_name) + if((opts->m_verbose || opts->m_list_not_cmp) && obj1_name && obj2_name) parallel_print("Not comparable: <%s> or <%s> is an empty dataset\n", obj1_name, obj2_name); can_compare = 0; - options->not_cmp = 1; + opts->not_cmp = 1; } } @@ -273,7 +276,7 @@ hsize_t diff_datasetid(hid_t did1, if (diff_can_type(f_tid1, f_tid2, rank1, rank2, dims1, dims2, maxdim1, maxdim2, obj1_name, obj2_name, - options, 0) != 1) + opts, 0) != 1) can_compare = 0; /*------------------------------------------------------------------------- @@ -301,13 +304,13 @@ hsize_t diff_datasetid(hid_t did1, sign2 = H5Tget_sign(m_tid2); if(sign1 != sign2) { h5difftrace("sign1 != sign2\n"); - if((options->m_verbose || options->m_list_not_cmp) && obj1_name && obj2_name) { + if((opts->m_verbose || opts->m_list_not_cmp) && obj1_name && obj2_name) { parallel_print("Not comparable: <%s> has sign %s ", obj1_name, get_sign(sign1)); parallel_print("and <%s> has sign %s\n", obj2_name, get_sign(sign2)); } can_compare = 0; - options->not_cmp = 1; + opts->not_cmp = 1; } } @@ -401,7 +404,7 @@ hsize_t diff_datasetid(hid_t did1, /* array diff */ nfound = diff_array(buf1, buf2, danelmts, (hsize_t)0, rank1, dadims, - options, name1, name2, dam_tid, did1, did2); + opts, name1, name2, dam_tid, did1, did2); h5diffdebug2("diff_array nfound:%d\n", nfound); /* reclaim any VL memory, if necessary */ @@ -496,7 +499,7 @@ hsize_t diff_datasetid(hid_t did1, /* get array differences. in the case of hyperslab read, increment the number of differences found in each hyperslab and pass the position at the beginning for printing */ nfound += diff_array(sm_buf1, sm_buf2, hs_nelmts, elmtno, rank1, - dadims, options, name1, name2, dam_tid, did1, did2); + dadims, opts, name1, name2, dam_tid, did1, did2); /* reclaim any VL memory, if necessary */ if(vl_data) { @@ -535,7 +538,7 @@ hsize_t diff_datasetid(hid_t did1, done: - options->err_stat = ret_value; + opts->err_stat = ret_value; /* free */ if(buf1 != NULL) { @@ -577,8 +580,8 @@ done: H5Tclose(m_tid2); /* enable error reporting */ } H5E_END_TRY; - h5diffdebug3("diff_datasetid return:%d with nfound:%d\n", ret_value, nfound); + h5diffdebug3("diff_datasetid return:%d with nfound:%d\n", ret_value, nfound); return nfound; } @@ -604,10 +607,10 @@ int diff_can_type(hid_t f_tid1, /* file data type */ hsize_t *maxdim2, const char *obj1_name, const char *obj2_name, - diff_opt_t *options, + diff_opt_t *opts, int is_compound) { - int ret_value = 0; /* can_compare value, no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ + int ret_value = 1; /* can_compare value */ H5T_class_t tclass1; H5T_class_t tclass2; int maxdim_diff = 0; /* maximum dimensions are different */ @@ -625,7 +628,7 @@ int diff_can_type(hid_t f_tid1, /* file data type */ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_class second object failed"); if(tclass1 != tclass2) { - if((options->m_verbose || options->m_list_not_cmp) && obj1_name && obj2_name) { + if((opts->m_verbose || opts->m_list_not_cmp) && obj1_name && obj2_name) { if(is_compound) { parallel_print("Not comparable: <%s> has a class %s and <%s> has a class %s\n", obj1_name, get_class(tclass1), @@ -637,7 +640,7 @@ int diff_can_type(hid_t f_tid1, /* file data type */ obj2_name, get_class(tclass2)); } } - options->not_cmp = 1; + opts->not_cmp = 1; HGOTO_DONE(0); } @@ -647,11 +650,11 @@ int diff_can_type(hid_t f_tid1, /* file data type */ */ switch (tclass1) { case H5T_TIME: - if((options->m_verbose || options->m_list_not_cmp) && obj1_name && obj2_name) { + if((opts->m_verbose || opts->m_list_not_cmp) && obj1_name && obj2_name) { parallel_print("Not comparable: <%s> and <%s> are of class %s\n", obj1_name, obj2_name, get_class(tclass2)); } /* end if */ - options->not_cmp = 1; + opts->not_cmp = 1; HGOTO_DONE(0); case H5T_INTEGER: @@ -675,7 +678,7 @@ int diff_can_type(hid_t f_tid1, /* file data type */ * check for equal file datatype; warning only *------------------------------------------------------------------------- */ - if((H5Tequal(f_tid1, f_tid2) == 0) && (options->m_verbose) && obj1_name && obj2_name) { + if((H5Tequal(f_tid1, f_tid2) == 0) && (opts->m_verbose) && obj1_name && obj2_name) { H5T_class_t cl = H5Tget_class(f_tid1); parallel_print("Warning: different storage datatype\n"); @@ -694,7 +697,7 @@ int diff_can_type(hid_t f_tid1, /* file data type */ *------------------------------------------------------------------------- */ if(rank1 != rank2) { - if((options->m_verbose || options->m_list_not_cmp) && obj1_name && obj2_name) { + if((opts->m_verbose || opts->m_list_not_cmp) && obj1_name && obj2_name) { parallel_print("Not comparable: <%s> has rank %d, dimensions ", obj1_name, rank1); print_dimensions(rank1, dims1); parallel_print(", max dimensions "); @@ -706,7 +709,7 @@ int diff_can_type(hid_t f_tid1, /* file data type */ print_dimensions(rank2, maxdim2); parallel_print("\n"); } - options->not_cmp = 1; + opts->not_cmp = 1; HGOTO_DONE(0); } @@ -728,7 +731,7 @@ int diff_can_type(hid_t f_tid1, /* file data type */ *------------------------------------------------------------------------- */ if(dim_diff == 1) { - if((options->m_verbose || options->m_list_not_cmp) && obj1_name && obj2_name) { + if((opts->m_verbose || opts->m_list_not_cmp) && obj1_name && obj2_name) { parallel_print("Not comparable: <%s> has rank %d, dimensions ", obj1_name, rank1); print_dimensions(rank1, dims1); if(maxdim1 && maxdim2) { @@ -742,7 +745,7 @@ int diff_can_type(hid_t f_tid1, /* file data type */ parallel_print("\n"); } } - options->not_cmp = 1; + opts->not_cmp = 1; HGOTO_DONE(0); } @@ -751,7 +754,7 @@ int diff_can_type(hid_t f_tid1, /* file data type */ *------------------------------------------------------------------------- */ if(maxdim1 && maxdim2 && maxdim_diff == 1 && obj1_name) { - if(options->m_verbose) { + if(opts->m_verbose) { parallel_print( "Warning: different maximum dimensions\n"); parallel_print("<%s> has max dimensions ", obj1_name); print_dimensions(rank1, maxdim1); @@ -773,12 +776,12 @@ int diff_can_type(hid_t f_tid1, /* file data type */ nmembs2 = H5Tget_nmembers(f_tid2); if(nmembs1 != nmembs2) { - if((options->m_verbose || options->m_list_not_cmp) && obj1_name && obj2_name) { + if((opts->m_verbose || opts->m_list_not_cmp) && obj1_name && obj2_name) { parallel_print("Not comparable: <%s> has %d members ", obj1_name, nmembs1); parallel_print("<%s> has %d members ", obj2_name, nmembs2); parallel_print("\n"); } - options->not_cmp = 1; + opts->not_cmp = 1; HGOTO_DONE(0); } @@ -788,8 +791,8 @@ int diff_can_type(hid_t f_tid1, /* file data type */ if (diff_can_type(memb_type1, memb_type2, rank1, rank2, dims1, dims2, maxdim1, maxdim2, obj1_name, obj2_name, - options, 1) != 1) { - options->not_cmp = 1; + opts, 1) != 1) { + opts->not_cmp = 1; H5Tclose(memb_type1); H5Tclose(memb_type2); HGOTO_DONE(0); @@ -799,7 +802,7 @@ int diff_can_type(hid_t f_tid1, /* file data type */ } } done: - h5diffdebug2("diff_can_type end - %d\n", can_compare); + h5diffdebug2("diff_can_type end - %d\n", ret_value); return ret_value; } diff --git a/tools/lib/h5tools_filters.c b/tools/lib/h5tools_filters.c index a5d0994..132e69a 100644 --- a/tools/lib/h5tools_filters.c +++ b/tools/lib/h5tools_filters.c @@ -21,7 +21,7 @@ static void print_warning(const char *dname, const char *fname) { fprintf(stderr, - "warning: dataset <%s> cannot be read, %s filter is not available\n", + "Warning: dataset <%s> cannot be read, %s filter is not available\n", dname, fname); } diff --git a/tools/lib/ph5diff.h b/tools/lib/ph5diff.h index 996a611..2189e31 100644 --- a/tools/lib/ph5diff.h +++ b/tools/lib/ph5diff.h @@ -32,7 +32,7 @@ struct diff_mpi_args { char name1[256]; char name2[256]; - diff_opt_t options; + diff_opt_t opts; diff_args_t argdata; /* rest args */ }; diff --git a/tools/src/h5diff/h5diff_common.c b/tools/src/h5diff/h5diff_common.c index e4696c0..532169f 100644 --- a/tools/src/h5diff/h5diff_common.c +++ b/tools/src/h5diff/h5diff_common.c @@ -52,7 +52,7 @@ static struct long_options l_opts[] = { * *------------------------------------------------------------------------- */ -static void check_options(diff_opt_t* options) +static void check_options(diff_opt_t* opts) { /*-------------------------------------------------------------- * check for mutually exclusive options @@ -61,7 +61,7 @@ static void check_options(diff_opt_t* options) /* check between -d , -p, --use-system-epsilon. * These options are mutually exclusive. */ - if ((options->d + options->p + options->use_system_epsilon) > 1) { + if ((opts->d + opts->p + opts->use_system_epsilon) > 1) { printf("%s error: -d, -p and --use-system-epsilon options are mutually-exclusive;\n", PROGRAMNAME); printf("use no more than one.\n"); printf("Try '-h' or '--help' option for more information or see the %s entry in the 'HDF5 Reference Manual'.\n", PROGRAMNAME); @@ -84,27 +84,27 @@ void parse_command_line(int argc, const char** fname2, const char** objname1, const char** objname2, - diff_opt_t* options) + diff_opt_t* opts) { int i; int opt; struct exclude_path_list *exclude_head, *exclude_prev, *exclude_node; /* process the command-line */ - memset(options, 0, sizeof (diff_opt_t)); + memset(opts, 0, sizeof (diff_opt_t)); /* assume equal contents initially */ - options->contents = 1; + opts->contents = 1; /* NaNs are handled by default */ - options->do_nans = 1; + opts->do_nans = 1; /* not Listing objects that are not comparable */ - options->m_list_not_cmp = 0; + opts->m_list_not_cmp = 0; /* initially no not-comparable. */ /**this is bad in mixing option with results**/ - options->not_cmp=0; + opts->not_cmp=0; /* init for exclude-path option */ exclude_head = NULL; @@ -125,7 +125,7 @@ void parse_command_line(int argc, h5diff_exit(EXIT_SUCCESS); case 'v': - options->m_verbose = 1; + opts->m_verbose = 1; /* This for loop is for handling style like * -v, -v1, --verbose, --verbose=1. */ @@ -135,11 +135,11 @@ void parse_command_line(int argc, */ if (!strcmp (argv[i], "-v")) { /* no arg */ opt_ind--; - options->m_verbose_level = 0; + opts->m_verbose_level = 0; break; } else if (!strncmp (argv[i], "-v", (size_t)2)) { - options->m_verbose_level = atoi(&argv[i][2]); + opts->m_verbose_level = atoi(&argv[i][2]); break; } @@ -147,11 +147,11 @@ void parse_command_line(int argc, * long opt */ if (!strcmp (argv[i], "--verbose")) { /* no arg */ - options->m_verbose_level = 0; + opts->m_verbose_level = 0; break; } else if ( !strncmp (argv[i], "--verbose", (size_t)9) && argv[i][9]=='=') { - options->m_verbose_level = atoi(&argv[i][10]); + opts->m_verbose_level = atoi(&argv[i][10]); break; } } @@ -159,19 +159,19 @@ void parse_command_line(int argc, case 'q': /* use quiet mode; supress the message "0 differences found" */ - options->m_quiet = 1; + opts->m_quiet = 1; break; case 'r': - options->m_report = 1; + opts->m_report = 1; break; case 'l': - options->follow_links = TRUE; + opts->follow_links = TRUE; break; case 'x': - options->no_dangle_links = 1; + opts->no_dangle_links = 1; break; case 'S': @@ -179,7 +179,7 @@ void parse_command_line(int argc, break; case 'E': - options->exclude_path = 1; + opts->exclude_path = 1; /* create linked list of excluding objects */ if( (exclude_node = (struct exclude_path_list*) HDmalloc(sizeof(struct exclude_path_list))) == NULL) { @@ -206,64 +206,64 @@ void parse_command_line(int argc, break; case 'd': - options->d=1; + opts->d=1; if (check_d_input(opt_arg) == - 1) { printf("<-d %s> is not a valid option\n", opt_arg); usage(); h5diff_exit(EXIT_FAILURE); } - options->delta = atof(opt_arg); + opts->delta = atof(opt_arg); /* -d 0 is the same as default */ - if (H5_DBL_ABS_EQUAL(options->delta, (double)0.0F)) - options->d=0; + if (H5_DBL_ABS_EQUAL(opts->delta, (double)0.0F)) + opts->d=0; break; case 'p': - options->p=1; + opts->p=1; if (check_p_input(opt_arg) == -1) { printf("<-p %s> is not a valid option\n", opt_arg); usage(); h5diff_exit(EXIT_FAILURE); } - options->percent = atof(opt_arg); + opts->percent = atof(opt_arg); /* -p 0 is the same as default */ - if (H5_DBL_ABS_EQUAL(options->percent, (double)0.0F)) - options->p = 0; + if (H5_DBL_ABS_EQUAL(opts->percent, (double)0.0F)) + opts->p = 0; break; case 'n': - options->n=1; + opts->n=1; if ( check_n_input(opt_arg) == -1) { printf("<-n %s> is not a valid option\n", opt_arg); usage(); h5diff_exit(EXIT_FAILURE); } - options->count = HDstrtoull(opt_arg, NULL, 0); + opts->count = HDstrtoull(opt_arg, NULL, 0); break; case 'N': - options->do_nans = 0; + opts->do_nans = 0; break; case 'c': - options->m_list_not_cmp = 1; + opts->m_list_not_cmp = 1; break; case 'e': - options->use_system_epsilon = 1; + opts->use_system_epsilon = 1; break; } } /* check options */ - check_options(options); + check_options(opts); /* if exclude-path option is used, keep the exclude path list */ - if (options->exclude_path) - options->exclude = exclude_head; + if (opts->exclude_path) + opts->exclude = exclude_head; /* check for file names to be processed */ if (argc <= opt_ind || argv[ opt_ind + 1 ] == NULL) { @@ -300,23 +300,23 @@ void parse_command_line(int argc, *------------------------------------------------------------------------- */ - void print_info(diff_opt_t* options) + void print_info(diff_opt_t* opts) { - if (options->m_quiet || options->err_stat) + if (opts->m_quiet || opts->err_stat) return; - if (options->cmn_objs == 0) { + if (opts->cmn_objs == 0) { printf("No common objects found. Files are not comparable.\n"); - if (!options->m_verbose) + if (!opts->m_verbose) printf("Use -v for a list of objects.\n"); } - if (options->not_cmp == 1) { - if (options->m_list_not_cmp == 0) { + if (opts->not_cmp == 1) { + if (opts->m_list_not_cmp == 0) { printf("--------------------------------\n"); printf("Some objects are not comparable\n"); printf("--------------------------------\n"); - if (options->m_verbose) + if (opts->m_verbose) printf("Use -c for a list of objects without details of differences.\n"); else printf("Use -c for a list of objects.\n"); diff --git a/tools/src/h5diff/h5diff_common.h b/tools/src/h5diff/h5diff_common.h index e5dfe3f..dc0676c 100644 --- a/tools/src/h5diff/h5diff_common.h +++ b/tools/src/h5diff/h5diff_common.h @@ -23,9 +23,9 @@ extern "C" { #endif void usage(void); -void parse_command_line(int argc, const char* argv[], const char** fname1, const char** fname2, const char** objname1, const char** objname2, diff_opt_t* options); +void parse_command_line(int argc, const char* argv[], const char** fname1, const char** fname2, const char** objname1, const char** objname2, diff_opt_t* opts); void h5diff_exit(int status); -void print_info(diff_opt_t* options); +void print_info(diff_opt_t* opts); #ifdef __cplusplus } diff --git a/tools/src/h5diff/h5diff_main.c b/tools/src/h5diff/h5diff_main.c index 8dab3b4..ad488a4 100644 --- a/tools/src/h5diff/h5diff_main.c +++ b/tools/src/h5diff/h5diff_main.c @@ -78,7 +78,7 @@ int main(int argc, const char *argv[]) const char *objname1 = NULL; const char *objname2 = NULL; hsize_t nfound=0; - diff_opt_t options; + diff_opt_t opts; h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); @@ -98,7 +98,7 @@ int main(int argc, const char *argv[]) * process the command-line *------------------------------------------------------------------------- */ - parse_command_line(argc, argv, &fname1, &fname2, &objname1, &objname2, &options); + parse_command_line(argc, argv, &fname1, &fname2, &objname1, &objname2, &opts); if (enable_error_stack) { H5Eset_auto2(H5E_DEFAULT, func, edata); @@ -110,9 +110,9 @@ int main(int argc, const char *argv[]) *------------------------------------------------------------------------- */ - nfound = h5diff(fname1, fname2, objname1, objname2, &options); + nfound = h5diff(fname1, fname2, objname1, objname2, &opts); - print_info(&options); + print_info(&opts); /*------------------------------------------------------------------------- * exit code @@ -123,11 +123,11 @@ int main(int argc, const char *argv[]) ret = (nfound == 0 ? 0 : 1); /* if graph difference return 1 for differences */ - if (options.contents == 0) + if (opts.contents == 0) ret = 1; /* and return 2 for error */ - if (options.err_stat) + if (opts.err_stat) ret = 2; h5diff_exit(ret); diff --git a/tools/src/h5diff/ph5diff_main.c b/tools/src/h5diff/ph5diff_main.c index 89efc39..83240cb 100644 --- a/tools/src/h5diff/ph5diff_main.c +++ b/tools/src/h5diff/ph5diff_main.c @@ -50,7 +50,7 @@ int main(int argc, const char *argv[]) const char *fname2 = NULL; const char *objname1 = NULL; const char *objname2 = NULL; - diff_opt_t options; + diff_opt_t opts; h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); @@ -72,11 +72,11 @@ int main(int argc, const char *argv[]) g_Parallel = 0; - parse_command_line(argc, argv, &fname1, &fname2, &objname1, &objname2, &options); + parse_command_line(argc, argv, &fname1, &fname2, &objname1, &objname2, &opts); - h5diff(fname1, fname2, objname1, objname2, &options); + h5diff(fname1, fname2, objname1, objname2, &opts); - print_info(&options); + print_info(&opts); } /* Parallel h5diff */ else { @@ -84,13 +84,13 @@ int main(int argc, const char *argv[]) /* Have the manager process the command-line */ if(nID == 0) { - parse_command_line(argc, argv, &fname1, &fname2, &objname1, &objname2, &options); + parse_command_line(argc, argv, &fname1, &fname2, &objname1, &objname2, &opts); - h5diff(fname1, fname2, objname1, objname2, &options); + h5diff(fname1, fname2, objname1, objname2, &opts); MPI_Barrier(MPI_COMM_WORLD); - print_info(&options); + print_info(&opts); print_manager_output(); } /* All other tasks become workers and wait for assignments. */ @@ -178,8 +178,8 @@ ph5diff_worker(int nID) MPI_Recv(&args, sizeof(args), MPI_BYTE, 0, MPI_TAG_ARGS, MPI_COMM_WORLD, &Status); /* Do the diff */ - diffs.nfound = diff(file1_id, args.name1, file2_id, args.name2, &(args.options), &(args.argdata)); - diffs.not_cmp = args.options.not_cmp; + diffs.nfound = diff(file1_id, args.name1, file2_id, args.name2, &(args.opts), &(args.argdata)); + diffs.not_cmp = args.opts.not_cmp; /* If print buffer has something in it, request print token.*/ if(outBuffOffset>0) diff --git a/tools/src/h5repack/h5repack.c b/tools/src/h5repack/h5repack.c index 2db7fdd..d570d02 100644 --- a/tools/src/h5repack/h5repack.c +++ b/tools/src/h5repack/h5repack.c @@ -221,7 +221,7 @@ hid_t copy_named_datatype(hid_t type_in, hid_t fidout, hid_t ret_value = -1; /* The identifier of the named dtype in the out file */ if (H5Oget_info(type_in, &oinfo) < 0) - goto done; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Oget_info failed"); if (*named_dt_head_p) { /* Stack already exists, search for the datatype */ @@ -238,7 +238,7 @@ hid_t copy_named_datatype(hid_t type_in, hid_t fidout, if (travt->objs[i].type == H5TRAV_TYPE_NAMED_DATATYPE) { /* Push onto the stack */ if (NULL == (dt = (named_dt_t *)HDmalloc(sizeof(named_dt_t)))) - goto done; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "buffer allocation failed failed"); dt->next = *named_dt_head_p; *named_dt_head_p = dt; @@ -259,7 +259,7 @@ hid_t copy_named_datatype(hid_t type_in, hid_t fidout, if (!dt_ret) { /* Push the new datatype onto the stack */ if (NULL == (dt_ret = (named_dt_t *)HDmalloc(sizeof(named_dt_t)))) - goto done; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "buffer allocation failed failed"); dt_ret->next = *named_dt_head_p; *named_dt_head_p = dt_ret; @@ -276,9 +276,9 @@ hid_t copy_named_datatype(hid_t type_in, hid_t fidout, else dt_ret->id_out = H5Tcopy(type_in); if (dt_ret->id_out < 0) - goto done; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_native_type-H5Tcopy failed"); if (H5Tcommit_anon(fidout, dt_ret->id_out, H5P_DEFAULT, H5P_DEFAULT) < 0) - goto done; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tcommit_anon failed"); } /* end if */ /* Set return value */ @@ -305,7 +305,7 @@ int named_datatype_free(named_dt_t **named_dt_head_p, int ignore_err) { while (dt) { /* Pop the datatype off the stack and free it */ if (H5Tclose(dt->id_out) < 0 && !ignore_err) - goto done; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed"); dt = dt->next; HDfree(*named_dt_head_p); *named_dt_head_p = dt; diff --git a/tools/test/h5copy/CMakeLists.txt b/tools/test/h5copy/CMakeLists.txt index 4a519ab..c57cd5e 100644 --- a/tools/test/h5copy/CMakeLists.txt +++ b/tools/test/h5copy/CMakeLists.txt @@ -10,14 +10,44 @@ INCLUDE_DIRECTORIES (${HDF5_TOOLS_DIR}/lib) # Add the h5copy test executables # -------------------------------------------------------------------- - if (HDF5_BUILD_GENERATORS) - add_executable (h5copygentest ${HDF5_TOOLS_TEST_H5COPY_SOURCE_DIR}/h5copygentest.c) - TARGET_NAMING (h5copygentest STATIC) - TARGET_C_PROPERTIES (h5copygentest STATIC " " " ") - target_link_libraries (h5copygentest ${HDF5_LIB_TARGET}) - set_target_properties (h5copygentest PROPERTIES FOLDER generator/tools) +if (HDF5_BUILD_GENERATORS) + add_executable (h5copygentest ${HDF5_TOOLS_TEST_H5COPY_SOURCE_DIR}/h5copygentest.c) + TARGET_NAMING (h5copygentest STATIC) + TARGET_C_PROPERTIES (h5copygentest STATIC " " " ") + target_link_libraries (h5copygentest ${HDF5_LIB_TARGET}) + set_target_properties (h5copygentest PROPERTIES FOLDER generator/tools) - #add_test (NAME h5copygentest COMMAND $) - endif () + #add_test (NAME h5copygentest COMMAND $) +endif () - include (CMakeTests.cmake) +#----------------------------------------------------------------------------- +# If plugin library tests can be tested +#----------------------------------------------------------------------------- +if (BUILD_SHARED_LIBS) + set (HDF5_TOOL_PLUGIN_LIB_CORENAME "dynlibcopy") + set (HDF5_TOOL_PLUGIN_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_TOOL_PLUGIN_LIB_CORENAME}") + set (HDF5_TOOL_PLUGIN_LIB_TARGET ${HDF5_TOOL_PLUGIN_LIB_CORENAME}) + add_definitions (${HDF_EXTRA_C_FLAGS}) + INCLUDE_DIRECTORIES (${HDF5_SRC_DIR}) + + add_library (${HDF5_TOOL_PLUGIN_LIB_TARGET} SHARED dynlib_copy.c) + TARGET_C_PROPERTIES (${HDF5_TOOL_PLUGIN_LIB_TARGET} SHARED " " " ") + target_link_libraries (${HDF5_TOOL_PLUGIN_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) + H5_SET_LIB_OPTIONS (${HDF5_TOOL_PLUGIN_LIB_TARGET} ${HDF5_TOOL_PLUGIN_LIB_NAME} SHARED ${HDF5_PACKAGE_SOVERSION}) + + # make plugins dir + file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/plugins") + #----------------------------------------------------------------------------- + # Copy plugin library to a plugins folder + #----------------------------------------------------------------------------- + add_custom_command ( + TARGET ${HDF5_TOOL_PLUGIN_LIB_TARGET} + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different + "$" + "${CMAKE_BINARY_DIR}/plugins/$" + ) +endif () + +include (CMakeTests.cmake) diff --git a/tools/test/h5copy/CMakeTests.cmake b/tools/test/h5copy/CMakeTests.cmake index b60c0e9..f9733cf 100644 --- a/tools/test/h5copy/CMakeTests.cmake +++ b/tools/test/h5copy/CMakeTests.cmake @@ -24,10 +24,14 @@ ${HDF5_TOOLS_TEST_H5COPY_SOURCE_DIR}/testfiles/h5copy_extlinks_trg.h5 ${HDF5_TOOLS_TEST_H5COPY_SOURCE_DIR}/testfiles/h5copy_ref.h5 ${HDF5_TOOLS_TEST_H5COPY_SOURCE_DIR}/testfiles/h5copytst.h5 + ${HDF5_TOOLS_TEST_H5COPY_SOURCE_DIR}/testfiles/tudfilter.h5 + ${HDF5_TOOLS_TEST_H5COPY_SOURCE_DIR}/testfiles/tudfilter2.h5 ) set (LIST_OTHER_TEST_FILES ${HDF5_TOOLS_TEST_H5COPY_SOURCE_DIR}/testfiles/h5copy_misc1.out + ${HDF5_TOOLS_TEST_H5COPY_SOURCE_DIR}/testfiles/tudfilter.h5.txt + ${HDF5_TOOLS_TEST_H5COPY_SOURCE_DIR}/testfiles/tudfilter.h5_ERR.txt ) file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") @@ -74,7 +78,7 @@ if (NOT "${resultcode}" STREQUAL "2") add_test ( NAME H5COPY_F-${testname}-DIFF - COMMAND $ -q ./testfiles/${infile} ./testfiles/${testname}.out.h5 ${srcname} ${dstname} + COMMAND $ -v ./testfiles/${infile} ./testfiles/${testname}.out.h5 ${srcname} ${dstname} ) SET_TESTS_PROPERTIES(H5COPY_F-${testname}-DIFF PROPERTIES DEPENDS H5COPY_F-${testname}) if ("${resultcode}" STREQUAL "1") @@ -110,7 +114,7 @@ if (NOT "${resultcode}" STREQUAL "2") add_test ( NAME H5COPY-${testname}-DIFF - COMMAND $ -q ./testfiles/${infile} ./testfiles/${testname}.out.h5 ${srcname} ${dstname} + COMMAND $ -v ./testfiles/${infile} ./testfiles/${testname}.out.h5 ${srcname} ${dstname} ) SET_TESTS_PROPERTIES(H5COPY-${testname}-DIFF PROPERTIES DEPENDS H5COPY-${testname}) if ("${resultcode}" STREQUAL "1") @@ -160,7 +164,7 @@ if (NOT "${resultcode}" STREQUAL "2") add_test ( NAME H5COPY-${testname}-DIFF - COMMAND $ -q ./testfiles/${infile} ./testfiles/${testname}.out.h5 ${srcname} ${dstname} + COMMAND $ -v ./testfiles/${infile} ./testfiles/${testname}.out.h5 ${srcname} ${dstname} ) SET_TESTS_PROPERTIES(H5COPY-${testname}-DIFF PROPERTIES DEPENDS H5COPY-${testname}) if ("${resultcode}" STREQUAL "1") @@ -201,7 +205,7 @@ if (NOT "${resultcode}" STREQUAL "2") add_test ( NAME H5COPY_SAME-${testname}-DIFF - COMMAND $ -q ./testfiles/${testname}.out.h5 ./testfiles/${testname}.out.h5 ${srcname} ${dstname} + COMMAND $ -v ./testfiles/${testname}.out.h5 ./testfiles/${testname}.out.h5 ${srcname} ${dstname} ) SET_TESTS_PROPERTIES(H5COPY_SAME-${testname}-DIFF PROPERTIES DEPENDS H5COPY_SAME-${testname}) if ("${resultcode}" STREQUAL "1") @@ -250,6 +254,108 @@ endif () endmacro () + macro (ADD_H5_UD_TEST testname resultcode infile sparam srcname dparam dstname cmpfile) + if (NOT HDF5_ENABLE_USING_MEMCHECKER) + # Remove any output file left over from previous test run + add_test ( + NAME H5COPY_UD-${testname}-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + testfiles/${testname}.out.h5 + testfiles/${infile}.out + testfiles/${infile}.out.err + ) + if ("${resultcode}" STREQUAL "2") + add_test ( + NAME H5COPY_UD-${testname} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=-v;-i;./testfiles/${infile};-o;./testfiles/${testname}.out.h5;${sparam};${srcname};${dparam};${dstname}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" + -D "TEST_OUTPUT=./testfiles/${infile}.out" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_REFERENCE=./testfiles/${infile}.txt" + -D "TEST_APPEND=EXIT CODE:" + -D "TEST_ENV_VAR=HDF5_PLUGIN_PATH" + -D "TEST_ENV_VALUE=${CMAKE_BINARY_DIR}" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + else () + add_test ( + NAME H5COPY_UD-${testname} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=-v;-i;./testfiles/${infile};-o;./testfiles/${testname}.out.h5;${sparam};${srcname};${dparam};${dstname}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" + -D "TEST_OUTPUT=./testfiles/${infile}.out" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_REFERENCE=./testfiles/${infile}.txt" + -D "TEST_APPEND=EXIT CODE:" + -D "TEST_ENV_VAR=HDF5_PLUGIN_PATH" + -D "TEST_ENV_VALUE=${CMAKE_BINARY_DIR}/plugins" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + add_test ( + NAME H5COPY_UD-${testname}-DIFF + COMMAND $ -v ./testfiles/${cmpfile} ./testfiles/${testname}.out.h5 ${srcname} ${dstname} + ) + SET_TESTS_PROPERTIES(H5COPY_UD-${testname}-DIFF PROPERTIES DEPENDS H5COPY_UD-${testname}) + if ("${resultcode}" STREQUAL "1") + set_tests_properties (H5COPY_UD-${testname}-DIFF PROPERTIES WILL_FAIL "true") + endif () + endif () + set_tests_properties (H5COPY_UD-${testname} PROPERTIES DEPENDS H5COPY_UD-${testname}-clear-objects) + endif () + endmacro () + + macro (ADD_H5_UD_ERR_TEST testname resultcode infile sparam srcname dparam dstname cmpfile) + if (NOT HDF5_ENABLE_USING_MEMCHECKER) + # Remove any output file left over from previous test run + add_test ( + NAME H5COPY_UD_ERR-${testname}-clearall-objects + COMMAND ${CMAKE_COMMAND} + -E remove + testfiles/${testname}_ERR.out.h5 + testfiles/${infile}_ERR.out + testfiles/${infile}_ERR.out.err + ) + if ("${resultcode}" STREQUAL "2") + add_test ( + NAME H5COPY_UD_ERR-${testname} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=-v;--enable-error-stack;-i;./testfiles/${infile};-o;./testfiles/${testname}_ERR.out.h5;${sparam};${srcname};${dparam};${dstname}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" + -D "TEST_OUTPUT=./testfiles/${infile}_ERR.out" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_REFERENCE=./testfiles/${infile}_ERR.txt" + -D "TEST_MASK_ERROR=true" + -D "TEST_APPEND=EXIT CODE:" + -D "TEST_ENV_VAR=HDF5_PLUGIN_PATH" + -D "TEST_ENV_VALUE=${CMAKE_BINARY_DIR}" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + else () + add_test ( + NAME H5COPY_UD_ERR-${testname} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=-v;--enable-error-stack;-i;./testfiles/${infile};-o;./testfiles/${testname}_ERR.out.h5;${sparam};${srcname};${dparam};${dstname}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" + -D "TEST_OUTPUT=./testfiles/${infile}_ERR.out" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_REFERENCE=./testfiles/${infile}_ERR.txt" + -D "TEST_MASK_ERROR=true" + -D "TEST_APPEND=EXIT CODE:" + -D "TEST_ENV_VAR=HDF5_PLUGIN_PATH" + -D "TEST_ENV_VALUE=${CMAKE_BINARY_DIR}/plugins" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + endif () + set_tests_properties (H5COPY_UD_ERR-${testname} PROPERTIES DEPENDS H5COPY_UD_ERR-${testname}-clearall-objects) + endif () + endmacro () + ############################################################################## ############################################################################## ### T H E T E S T S ### @@ -434,3 +540,11 @@ else () ADD_H5_TEST_SAME (samefile2 2 ${HDF_FILE1}.h5 /grp_dsets /grp_dsets -v -s /grp_dsets -d /grp_dsets_cp) endif () + +############################################################################## +### P L U G I N T E S T S +############################################################################## +if (BUILD_SHARED_LIBS) + ADD_H5_UD_TEST (h5copy_plugin_test 0 tudfilter.h5 -s /dynlibud -d /dynlibud tudfilter2.h5 ) + ADD_H5_UD_TEST (h5copy_plugin_fail 2 tudfilter.h5 -s /dynlibud -d /dynlibud tudfilter2.h5) +endif () diff --git a/tools/test/h5copy/dynlib_copy.c b/tools/test/h5copy/dynlib_copy.c new file mode 100644 index 0000000..571452e --- /dev/null +++ b/tools/test/h5copy/dynlib_copy.c @@ -0,0 +1,89 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* + * Purpose: Tests the plugin module (H5PL) + */ + +#include +#include +#include "H5PLextern.h" + +#define H5Z_FILTER_DYNLIBUD 300 +#define MULTIPLIER 3 + +static size_t H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, + const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); + +/* This message derives from H5Z */ +const H5Z_class2_t H5Z_DYNLIBUD[1] = {{ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + H5Z_FILTER_DYNLIBUD, /* Filter id number */ + 1, 1, /* Encoding and decoding enabled */ + "dynlibud", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + (H5Z_func_t)H5Z_filter_dynlibud, /* The actual filter function */ +}}; + +H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} +const void *H5PLget_plugin_info(void) {return H5Z_DYNLIBUD;} + +/*------------------------------------------------------------------------- + * Function: H5Z_filter_dynlibud + * + * Purpose: A dynlib2 filter method that multiplies the original value + * during write and divide the original value during read. It + * will be built as a shared library. plugin.c test will load + * and use this filter library. + * + * Return: Success: Data chunk size + * + * Failure: 0 + *------------------------------------------------------------------------- + */ +static size_t +H5Z_filter_dynlibud(unsigned int flags, size_t cd_nelmts, + const unsigned int *cd_values, size_t nbytes, + size_t *buf_size, void **buf) +{ + char *int_ptr = (char *)*buf; /* Pointer to the data values */ + size_t buf_left = *buf_size; /* Amount of data buffer left to process */ + + /* Check for the correct number of parameters */ + if(cd_nelmts > 0) + return(0); + + /* Assignment to eliminate unused parameter warning. */ + cd_values = cd_values; + + if(flags & H5Z_FLAG_REVERSE) { /*read*/ + /* Subtract the original value with MULTIPLIER */ + while(buf_left > 0) { + char temp = *int_ptr; + *int_ptr = temp - MULTIPLIER; + int_ptr++; + buf_left -= sizeof(*int_ptr); + } /* end while */ + } /* end if */ + else { /*write*/ + /* Add the original value with MULTIPLIER */ + while(buf_left > 0) { + char temp = *int_ptr; + *int_ptr = temp + MULTIPLIER; + int_ptr++; + buf_left -= sizeof(*int_ptr); + } /* end while */ + } /* end else */ + + return nbytes; +} /* end H5Z_filter_dynlibud() */ + diff --git a/tools/test/h5copy/testfiles/tudfilter.h5 b/tools/test/h5copy/testfiles/tudfilter.h5 new file mode 100644 index 0000000..081b000 Binary files /dev/null and b/tools/test/h5copy/testfiles/tudfilter.h5 differ diff --git a/tools/test/h5copy/testfiles/tudfilter.h5.txt b/tools/test/h5copy/testfiles/tudfilter.h5.txt new file mode 100644 index 0000000..8f3d0b5 --- /dev/null +++ b/tools/test/h5copy/testfiles/tudfilter.h5.txt @@ -0,0 +1,2 @@ +Copying file <./testfiles/tudfilter.h5> and object to file <./testfiles/h5copy_plugin_fail.out.h5> and object +EXIT CODE: 0 diff --git a/tools/test/h5copy/testfiles/tudfilter.h5_ERR.txt b/tools/test/h5copy/testfiles/tudfilter.h5_ERR.txt new file mode 100644 index 0000000..8f3d0b5 --- /dev/null +++ b/tools/test/h5copy/testfiles/tudfilter.h5_ERR.txt @@ -0,0 +1,2 @@ +Copying file <./testfiles/tudfilter.h5> and object to file <./testfiles/h5copy_plugin_fail.out.h5> and object +EXIT CODE: 0 diff --git a/tools/test/h5copy/testfiles/tudfilter2.h5 b/tools/test/h5copy/testfiles/tudfilter2.h5 new file mode 100644 index 0000000..081b000 Binary files /dev/null and b/tools/test/h5copy/testfiles/tudfilter2.h5 differ diff --git a/tools/test/h5diff/testfiles/h5diff_454_ERR.err b/tools/test/h5diff/testfiles/h5diff_454_ERR.err index 8fa1718..82802a1 100644 --- a/tools/test/h5diff/testfiles/h5diff_454_ERR.err +++ b/tools/test/h5diff/testfiles/h5diff_454_ERR.err @@ -1,4 +1,4 @@ H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): - #000: (file name) line (number) in h5diff(): Error: treat dangling link as error + #000: (file name) line (number) in h5diff(): treat dangling link as error major: Failure in tools library minor: error in function diff --git a/tools/test/h5diff/testfiles/h5diff_454_ERR.txt b/tools/test/h5diff/testfiles/h5diff_454_ERR.txt index de25a69..4501071 100644 --- a/tools/test/h5diff/testfiles/h5diff_454_ERR.txt +++ b/tools/test/h5diff/testfiles/h5diff_454_ERR.txt @@ -1,6 +1,6 @@ Warning: is a dangling link. H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): - #000: (file name) line (number) in h5diff(): Error: treat dangling link as error + #000: (file name) line (number) in h5diff(): treat dangling link as error major: Failure in tools library minor: error in function EXIT CODE: 2 diff --git a/tools/test/h5diff/testfiles/h5diff_455_ERR.err b/tools/test/h5diff/testfiles/h5diff_455_ERR.err index 8fa1718..82802a1 100644 --- a/tools/test/h5diff/testfiles/h5diff_455_ERR.err +++ b/tools/test/h5diff/testfiles/h5diff_455_ERR.err @@ -1,4 +1,4 @@ H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): - #000: (file name) line (number) in h5diff(): Error: treat dangling link as error + #000: (file name) line (number) in h5diff(): treat dangling link as error major: Failure in tools library minor: error in function diff --git a/tools/test/h5diff/testfiles/h5diff_455_ERR.txt b/tools/test/h5diff/testfiles/h5diff_455_ERR.txt index de25a69..4501071 100644 --- a/tools/test/h5diff/testfiles/h5diff_455_ERR.txt +++ b/tools/test/h5diff/testfiles/h5diff_455_ERR.txt @@ -1,6 +1,6 @@ Warning: is a dangling link. H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): - #000: (file name) line (number) in h5diff(): Error: treat dangling link as error + #000: (file name) line (number) in h5diff(): treat dangling link as error major: Failure in tools library minor: error in function EXIT CODE: 2 diff --git a/tools/test/h5diff/testfiles/h5diff_457_ERR.err b/tools/test/h5diff/testfiles/h5diff_457_ERR.err index 8fa1718..82802a1 100644 --- a/tools/test/h5diff/testfiles/h5diff_457_ERR.err +++ b/tools/test/h5diff/testfiles/h5diff_457_ERR.err @@ -1,4 +1,4 @@ H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): - #000: (file name) line (number) in h5diff(): Error: treat dangling link as error + #000: (file name) line (number) in h5diff(): treat dangling link as error major: Failure in tools library minor: error in function diff --git a/tools/test/h5diff/testfiles/h5diff_457_ERR.txt b/tools/test/h5diff/testfiles/h5diff_457_ERR.txt index 6594c9a..9d73750 100644 --- a/tools/test/h5diff/testfiles/h5diff_457_ERR.txt +++ b/tools/test/h5diff/testfiles/h5diff_457_ERR.txt @@ -1,6 +1,6 @@ Warning: is a dangling link. H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): - #000: (file name) line (number) in h5diff(): Error: treat dangling link as error + #000: (file name) line (number) in h5diff(): treat dangling link as error major: Failure in tools library minor: error in function EXIT CODE: 2 diff --git a/tools/test/h5diff/testfiles/h5diff_458_ERR.err b/tools/test/h5diff/testfiles/h5diff_458_ERR.err index 8fa1718..82802a1 100644 --- a/tools/test/h5diff/testfiles/h5diff_458_ERR.err +++ b/tools/test/h5diff/testfiles/h5diff_458_ERR.err @@ -1,4 +1,4 @@ H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): - #000: (file name) line (number) in h5diff(): Error: treat dangling link as error + #000: (file name) line (number) in h5diff(): treat dangling link as error major: Failure in tools library minor: error in function diff --git a/tools/test/h5diff/testfiles/h5diff_458_ERR.txt b/tools/test/h5diff/testfiles/h5diff_458_ERR.txt index 9a09c17..b084914 100644 --- a/tools/test/h5diff/testfiles/h5diff_458_ERR.txt +++ b/tools/test/h5diff/testfiles/h5diff_458_ERR.txt @@ -1,6 +1,6 @@ Warning: is a dangling link. H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): - #000: (file name) line (number) in h5diff(): Error: treat dangling link as error + #000: (file name) line (number) in h5diff(): treat dangling link as error major: Failure in tools library minor: error in function EXIT CODE: 2 diff --git a/tools/test/h5diff/testfiles/h5diff_459_ERR.err b/tools/test/h5diff/testfiles/h5diff_459_ERR.err index 8fa1718..82802a1 100644 --- a/tools/test/h5diff/testfiles/h5diff_459_ERR.err +++ b/tools/test/h5diff/testfiles/h5diff_459_ERR.err @@ -1,4 +1,4 @@ H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): - #000: (file name) line (number) in h5diff(): Error: treat dangling link as error + #000: (file name) line (number) in h5diff(): treat dangling link as error major: Failure in tools library minor: error in function diff --git a/tools/test/h5diff/testfiles/h5diff_459_ERR.txt b/tools/test/h5diff/testfiles/h5diff_459_ERR.txt index 6594c9a..9d73750 100644 --- a/tools/test/h5diff/testfiles/h5diff_459_ERR.txt +++ b/tools/test/h5diff/testfiles/h5diff_459_ERR.txt @@ -1,6 +1,6 @@ Warning: is a dangling link. H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): - #000: (file name) line (number) in h5diff(): Error: treat dangling link as error + #000: (file name) line (number) in h5diff(): treat dangling link as error major: Failure in tools library minor: error in function EXIT CODE: 2 -- cgit v0.12 From e071e746f86c2ab13f8a93b9680b20ee8a557b29 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 16 Oct 2017 17:39:56 -0500 Subject: HDFFV-1097 Changed file columns --- tools/test/h5diff/testfiles/h5diff_417.txt | 2 +- tools/test/h5diff/testfiles/h5diff_418.txt | 2 +- tools/test/h5diff/testfiles/h5diff_419.txt | 2 +- tools/test/h5diff/testfiles/h5diff_420.txt | 2 +- tools/test/h5diff/testfiles/h5diff_421.txt | 2 +- tools/test/h5diff/testfiles/h5diff_422.txt | 2 +- tools/test/h5diff/testfiles/h5diff_60.txt | 4 +- tools/test/h5diff/testfiles/h5diff_61.txt | 48 +- tools/test/h5diff/testfiles/h5diff_62.txt | 62 +-- tools/test/h5diff/testfiles/h5diff_63.txt | 8 +- tools/test/h5diff/testfiles/h5diff_70.txt | 756 ++++++++++++++--------------- tools/test/h5diff/testfiles/h5diff_700.txt | 756 ++++++++++++++--------------- tools/test/h5diff/testfiles/h5diff_701.txt | 756 ++++++++++++++--------------- tools/test/h5diff/testfiles/h5diff_702.txt | 756 ++++++++++++++--------------- tools/test/h5diff/testfiles/h5diff_703.txt | 756 ++++++++++++++--------------- tools/test/h5diff/testfiles/h5diff_80.txt | 252 +++++----- 16 files changed, 2083 insertions(+), 2083 deletions(-) diff --git a/tools/test/h5diff/testfiles/h5diff_417.txt b/tools/test/h5diff/testfiles/h5diff_417.txt index 0ea2542..29d467a 100644 --- a/tools/test/h5diff/testfiles/h5diff_417.txt +++ b/tools/test/h5diff/testfiles/h5diff_417.txt @@ -1,3 +1,3 @@ obj1 is a dangling link. 1 differences found -EXIT CODE: 1 +EXIT CODE: 2 diff --git a/tools/test/h5diff/testfiles/h5diff_418.txt b/tools/test/h5diff/testfiles/h5diff_418.txt index 46222bb..b6173d9 100644 --- a/tools/test/h5diff/testfiles/h5diff_418.txt +++ b/tools/test/h5diff/testfiles/h5diff_418.txt @@ -1,3 +1,3 @@ obj2 is a dangling link. 1 differences found -EXIT CODE: 1 +EXIT CODE: 2 diff --git a/tools/test/h5diff/testfiles/h5diff_419.txt b/tools/test/h5diff/testfiles/h5diff_419.txt index 387c600..ee6e831 100644 --- a/tools/test/h5diff/testfiles/h5diff_419.txt +++ b/tools/test/h5diff/testfiles/h5diff_419.txt @@ -1,3 +1,3 @@ obj1 is a dangling link. 1 differences found -EXIT CODE: 1 +EXIT CODE: 2 diff --git a/tools/test/h5diff/testfiles/h5diff_420.txt b/tools/test/h5diff/testfiles/h5diff_420.txt index f3e65d9..67c22ba 100644 --- a/tools/test/h5diff/testfiles/h5diff_420.txt +++ b/tools/test/h5diff/testfiles/h5diff_420.txt @@ -1,3 +1,3 @@ obj2 is a dangling link. 1 differences found -EXIT CODE: 1 +EXIT CODE: 2 diff --git a/tools/test/h5diff/testfiles/h5diff_421.txt b/tools/test/h5diff/testfiles/h5diff_421.txt index 833c60c..7fd70ee 100644 --- a/tools/test/h5diff/testfiles/h5diff_421.txt +++ b/tools/test/h5diff/testfiles/h5diff_421.txt @@ -1,3 +1,3 @@ obj2 is a dangling link. 1 differences found -EXIT CODE: 1 +EXIT CODE: 2 diff --git a/tools/test/h5diff/testfiles/h5diff_422.txt b/tools/test/h5diff/testfiles/h5diff_422.txt index 3e675d5..d1114af 100644 --- a/tools/test/h5diff/testfiles/h5diff_422.txt +++ b/tools/test/h5diff/testfiles/h5diff_422.txt @@ -1,3 +1,3 @@ obj1 is a dangling link. 1 differences found -EXIT CODE: 1 +EXIT CODE: 2 diff --git a/tools/test/h5diff/testfiles/h5diff_60.txt b/tools/test/h5diff/testfiles/h5diff_60.txt index 938f279..dde17f6 100644 --- a/tools/test/h5diff/testfiles/h5diff_60.txt +++ b/tools/test/h5diff/testfiles/h5diff_60.txt @@ -2,8 +2,8 @@ dataset: and size: [3x4] [3x4] position string1 string1 difference ------------------------------------------------------------ -[ 1 0 ] 5 \000 -[ 1 1 ] 6 \000 +[ 1 0 ] \000 5 +[ 1 1 ] \000 6 [ 1 2 ] \000 7 [ 1 3 ] \000 8 4 differences found diff --git a/tools/test/h5diff/testfiles/h5diff_61.txt b/tools/test/h5diff/testfiles/h5diff_61.txt index 1f238b1..5553d63 100644 --- a/tools/test/h5diff/testfiles/h5diff_61.txt +++ b/tools/test/h5diff/testfiles/h5diff_61.txt @@ -2,29 +2,29 @@ dataset: and size: [20] [20] position string2 string2 difference ------------------------------------------------------------ -[ 8 ] 9 e -[ 8 ] f -[ 8 ] 9 -[ 9 ] 0 e -[ 9 ] f -[ 9 ] 0 -[ 10 ] 1 e -[ 10 ] f -[ 10 ] 1 -[ 11 ] 2 e -[ 11 ] f -[ 11 ] 2 -[ 12 ] e 3 -[ 12 ] f -[ 12 ] 3 -[ 13 ] e 4 -[ 13 ] f -[ 13 ] 4 -[ 14 ] e 5 -[ 14 ] f -[ 14 ] 5 -[ 15 ] e 6 -[ 15 ] f -[ 15 ] 6 +[ 8 ] e 9 +[ 8 ] f +[ 8 ] 9 +[ 9 ] e 0 +[ 9 ] f +[ 9 ] 0 +[ 10 ] e 1 +[ 10 ] f +[ 10 ] 1 +[ 11 ] e 2 +[ 11 ] f +[ 11 ] 2 +[ 12 ] 3 e +[ 12 ] f +[ 12 ] 3 +[ 13 ] 4 e +[ 13 ] f +[ 13 ] 4 +[ 14 ] 5 e +[ 14 ] f +[ 14 ] 5 +[ 15 ] 6 e +[ 15 ] f +[ 15 ] 6 24 differences found EXIT CODE: 1 diff --git a/tools/test/h5diff/testfiles/h5diff_62.txt b/tools/test/h5diff/testfiles/h5diff_62.txt index 0cc0947..934f61e 100644 --- a/tools/test/h5diff/testfiles/h5diff_62.txt +++ b/tools/test/h5diff/testfiles/h5diff_62.txt @@ -2,36 +2,36 @@ dataset: and size: [27] [27] position string3 string3 difference ------------------------------------------------------------ -[ 12 ] d c -[ 12 ] 2 d -[ 12 ] \000 2 -[ 13 ] 3 d -[ 13 ] \000 3 -[ 14 ] b a -[ 14 ] c b -[ 14 ] d c -[ 14 ] 4 d -[ 14 ] \000 4 -[ 15 ] c b -[ 15 ] d c -[ 15 ] 5 d -[ 15 ] \000 5 -[ 16 ] c d -[ 16 ] d 6 -[ 16 ] 6 \000 -[ 17 ] d 7 -[ 17 ] 7 \000 -[ 18 ] a b -[ 18 ] b c -[ 18 ] c d -[ 18 ] d 8 -[ 18 ] 8 \000 -[ 19 ] b c -[ 19 ] c d -[ 19 ] d 9 -[ 19 ] 9 \000 -[ 24 ] c d -[ 25 ] c d -[ 26 ] c d +[ 12 ] c d +[ 12 ] d 2 +[ 12 ] 2 \000 +[ 13 ] d 3 +[ 13 ] 3 \000 +[ 14 ] a b +[ 14 ] b c +[ 14 ] c d +[ 14 ] d 4 +[ 14 ] 4 \000 +[ 15 ] b c +[ 15 ] c d +[ 15 ] d 5 +[ 15 ] 5 \000 +[ 16 ] d c +[ 16 ] 6 d +[ 16 ] \000 6 +[ 17 ] 7 d +[ 17 ] \000 7 +[ 18 ] b a +[ 18 ] c b +[ 18 ] d c +[ 18 ] 8 d +[ 18 ] \000 8 +[ 19 ] c b +[ 19 ] d c +[ 19 ] 9 d +[ 19 ] \000 9 +[ 24 ] d c +[ 25 ] d c +[ 26 ] d c 31 differences found EXIT CODE: 1 diff --git a/tools/test/h5diff/testfiles/h5diff_63.txt b/tools/test/h5diff/testfiles/h5diff_63.txt index 043da16..6b46c18 100644 --- a/tools/test/h5diff/testfiles/h5diff_63.txt +++ b/tools/test/h5diff/testfiles/h5diff_63.txt @@ -2,9 +2,9 @@ dataset: and size: [3] [3] position string4 string4 difference ------------------------------------------------------------ -[ 1 ] 8 -[ 1 ] 9 -[ 2 ] 8 -[ 2 ] 9 +[ 1 ] 8 +[ 1 ] 9 +[ 2 ] 8 +[ 2 ] 9 4 differences found EXIT CODE: 1 diff --git a/tools/test/h5diff/testfiles/h5diff_70.txt b/tools/test/h5diff/testfiles/h5diff_70.txt index 0a6b0c0..efa34ea 100644 --- a/tools/test/h5diff/testfiles/h5diff_70.txt +++ b/tools/test/h5diff/testfiles/h5diff_70.txt @@ -11,79 +11,79 @@ attribute: > and > size: [2] [2] position VLstring of VLstring of difference ------------------------------------------------------------ -[ 0 ] a z -[ 0 ] b z -[ 1 ] d z -[ 1 ] e z +[ 0 ] z a +[ 0 ] z b +[ 1 ] z d +[ 1 ] z e 4 differences found attribute: > and > size: [3x2] [3x2] position VLstring2D of VLstring2D of difference ------------------------------------------------------------ -[ 0 0 ] a z -[ 0 0 ] b z -[ 0 1 ] c z -[ 0 1 ] d z -[ 1 0 ] e z -[ 1 0 ] f z -[ 1 1 ] g z -[ 1 1 ] h z -[ 2 0 ] i z -[ 2 0 ] j z -[ 2 1 ] k z -[ 2 1 ] l z +[ 0 0 ] z a +[ 0 0 ] z b +[ 0 1 ] z c +[ 0 1 ] z d +[ 1 0 ] z e +[ 1 0 ] z f +[ 1 1 ] z g +[ 1 1 ] z h +[ 2 0 ] z i +[ 2 0 ] z j +[ 2 1 ] z k +[ 2 1 ] z l 12 differences found attribute: > and > size: [4x3x2] [4x3x2] position VLstring3D of VLstring3D of difference ------------------------------------------------------------ -[ 0 0 0 ] a z -[ 0 0 0 ] b z -[ 0 0 1 ] c z -[ 0 0 1 ] d z -[ 0 1 0 ] e z -[ 0 1 0 ] f z -[ 0 1 1 ] g z -[ 0 1 1 ] h z -[ 0 2 0 ] i z -[ 0 2 0 ] j z -[ 0 2 1 ] k z -[ 0 2 1 ] l z -[ 1 0 0 ] m z -[ 1 0 0 ] n z -[ 1 0 1 ] p z -[ 1 0 1 ] q z -[ 1 1 0 ] r z -[ 1 1 0 ] s z -[ 1 1 1 ] t z -[ 1 1 1 ] u z -[ 1 2 0 ] v z -[ 1 2 0 ] w z -[ 1 2 1 ] x z -[ 2 0 0 ] A z -[ 2 0 0 ] B z -[ 2 0 1 ] C z -[ 2 0 1 ] D z -[ 2 1 0 ] E z -[ 2 1 0 ] F z -[ 2 1 1 ] G z -[ 2 1 1 ] H z -[ 2 2 0 ] I z -[ 2 2 0 ] J z -[ 2 2 1 ] K z -[ 2 2 1 ] L z -[ 3 0 0 ] M z -[ 3 0 0 ] N z -[ 3 0 1 ] P z -[ 3 0 1 ] Q z -[ 3 1 0 ] R z -[ 3 1 0 ] S z -[ 3 1 1 ] T z -[ 3 1 1 ] U z -[ 3 2 0 ] V z -[ 3 2 0 ] W z -[ 3 2 1 ] X z -[ 3 2 1 ] Z z +[ 0 0 0 ] z a +[ 0 0 0 ] z b +[ 0 0 1 ] z c +[ 0 0 1 ] z d +[ 0 1 0 ] z e +[ 0 1 0 ] z f +[ 0 1 1 ] z g +[ 0 1 1 ] z h +[ 0 2 0 ] z i +[ 0 2 0 ] z j +[ 0 2 1 ] z k +[ 0 2 1 ] z l +[ 1 0 0 ] z m +[ 1 0 0 ] z n +[ 1 0 1 ] z p +[ 1 0 1 ] z q +[ 1 1 0 ] z r +[ 1 1 0 ] z s +[ 1 1 1 ] z t +[ 1 1 1 ] z u +[ 1 2 0 ] z v +[ 1 2 0 ] z w +[ 1 2 1 ] z x +[ 2 0 0 ] z A +[ 2 0 0 ] z B +[ 2 0 1 ] z C +[ 2 0 1 ] z D +[ 2 1 0 ] z E +[ 2 1 0 ] z F +[ 2 1 1 ] z G +[ 2 1 1 ] z H +[ 2 2 0 ] z I +[ 2 2 0 ] z J +[ 2 2 1 ] z K +[ 2 2 1 ] z L +[ 3 0 0 ] z M +[ 3 0 0 ] z N +[ 3 0 1 ] z P +[ 3 0 1 ] z Q +[ 3 1 0 ] z R +[ 3 1 0 ] z S +[ 3 1 1 ] z T +[ 3 1 1 ] z U +[ 3 2 0 ] z V +[ 3 2 0 ] z W +[ 3 2 1 ] z X +[ 3 2 1 ] z Z 47 differences found attribute: > and > size: [2] [2] @@ -514,79 +514,79 @@ attribute: > and > size: [2] [2] position string of string of difference ------------------------------------------------------------ -[ 0 ] a z -[ 0 ] b z -[ 1 ] d z -[ 1 ] e z +[ 0 ] z a +[ 0 ] z b +[ 1 ] z d +[ 1 ] z e 4 differences found attribute: > and > size: [3x2] [3x2] position string2D of string2D of difference ------------------------------------------------------------ -[ 0 0 ] a z -[ 0 0 ] b z -[ 0 1 ] c z -[ 0 1 ] d z -[ 1 0 ] e z -[ 1 0 ] f z -[ 1 1 ] g z -[ 1 1 ] h z -[ 2 0 ] i z -[ 2 0 ] j z -[ 2 1 ] k z -[ 2 1 ] l z +[ 0 0 ] z a +[ 0 0 ] z b +[ 0 1 ] z c +[ 0 1 ] z d +[ 1 0 ] z e +[ 1 0 ] z f +[ 1 1 ] z g +[ 1 1 ] z h +[ 2 0 ] z i +[ 2 0 ] z j +[ 2 1 ] z k +[ 2 1 ] z l 12 differences found attribute: > and > size: [4x3x2] [4x3x2] position string3D of string3D of difference ------------------------------------------------------------ -[ 0 0 0 ] a z -[ 0 0 0 ] b z -[ 0 0 1 ] c z -[ 0 0 1 ] d z -[ 0 1 0 ] e z -[ 0 1 0 ] f z -[ 0 1 1 ] g z -[ 0 1 1 ] h z -[ 0 2 0 ] i z -[ 0 2 0 ] j z -[ 0 2 1 ] k z -[ 0 2 1 ] l z -[ 1 0 0 ] m z -[ 1 0 0 ] n z -[ 1 0 1 ] p z -[ 1 0 1 ] q z -[ 1 1 0 ] r z -[ 1 1 0 ] s z -[ 1 1 1 ] t z -[ 1 1 1 ] u z -[ 1 2 0 ] v z -[ 1 2 0 ] w z -[ 1 2 1 ] x z -[ 2 0 0 ] A z -[ 2 0 0 ] B z -[ 2 0 1 ] C z -[ 2 0 1 ] D z -[ 2 1 0 ] E z -[ 2 1 0 ] F z -[ 2 1 1 ] G z -[ 2 1 1 ] H z -[ 2 2 0 ] I z -[ 2 2 0 ] J z -[ 2 2 1 ] K z -[ 2 2 1 ] L z -[ 3 0 0 ] M z -[ 3 0 0 ] N z -[ 3 0 1 ] P z -[ 3 0 1 ] Q z -[ 3 1 0 ] R z -[ 3 1 0 ] S z -[ 3 1 1 ] T z -[ 3 1 1 ] U z -[ 3 2 0 ] V z -[ 3 2 0 ] W z -[ 3 2 1 ] X z -[ 3 2 1 ] Z z +[ 0 0 0 ] z a +[ 0 0 0 ] z b +[ 0 0 1 ] z c +[ 0 0 1 ] z d +[ 0 1 0 ] z e +[ 0 1 0 ] z f +[ 0 1 1 ] z g +[ 0 1 1 ] z h +[ 0 2 0 ] z i +[ 0 2 0 ] z j +[ 0 2 1 ] z k +[ 0 2 1 ] z l +[ 1 0 0 ] z m +[ 1 0 0 ] z n +[ 1 0 1 ] z p +[ 1 0 1 ] z q +[ 1 1 0 ] z r +[ 1 1 0 ] z s +[ 1 1 1 ] z t +[ 1 1 1 ] z u +[ 1 2 0 ] z v +[ 1 2 0 ] z w +[ 1 2 1 ] z x +[ 2 0 0 ] z A +[ 2 0 0 ] z B +[ 2 0 1 ] z C +[ 2 0 1 ] z D +[ 2 1 0 ] z E +[ 2 1 0 ] z F +[ 2 1 1 ] z G +[ 2 1 1 ] z H +[ 2 2 0 ] z I +[ 2 2 0 ] z J +[ 2 2 1 ] z K +[ 2 2 1 ] z L +[ 3 0 0 ] z M +[ 3 0 0 ] z N +[ 3 0 1 ] z P +[ 3 0 1 ] z Q +[ 3 1 0 ] z R +[ 3 1 0 ] z S +[ 3 1 1 ] z T +[ 3 1 1 ] z U +[ 3 2 0 ] z V +[ 3 2 0 ] z W +[ 3 2 1 ] z X +[ 3 2 1 ] z Z 47 differences found attribute: > and > size: [2] [2] @@ -683,79 +683,79 @@ attribute: > and > size: [2] [2] position VLstring of VLstring of difference ------------------------------------------------------------ -[ 0 ] a z -[ 0 ] b z -[ 1 ] d z -[ 1 ] e z +[ 0 ] z a +[ 0 ] z b +[ 1 ] z d +[ 1 ] z e 4 differences found attribute: > and > size: [3x2] [3x2] position VLstring2D of VLstring2D of difference ------------------------------------------------------------ -[ 0 0 ] a z -[ 0 0 ] b z -[ 0 1 ] c z -[ 0 1 ] d z -[ 1 0 ] e z -[ 1 0 ] f z -[ 1 1 ] g z -[ 1 1 ] h z -[ 2 0 ] i z -[ 2 0 ] j z -[ 2 1 ] k z -[ 2 1 ] l z +[ 0 0 ] z a +[ 0 0 ] z b +[ 0 1 ] z c +[ 0 1 ] z d +[ 1 0 ] z e +[ 1 0 ] z f +[ 1 1 ] z g +[ 1 1 ] z h +[ 2 0 ] z i +[ 2 0 ] z j +[ 2 1 ] z k +[ 2 1 ] z l 12 differences found attribute: > and > size: [4x3x2] [4x3x2] position VLstring3D of VLstring3D of difference ------------------------------------------------------------ -[ 0 0 0 ] a z -[ 0 0 0 ] b z -[ 0 0 1 ] c z -[ 0 0 1 ] d z -[ 0 1 0 ] e z -[ 0 1 0 ] f z -[ 0 1 1 ] g z -[ 0 1 1 ] h z -[ 0 2 0 ] i z -[ 0 2 0 ] j z -[ 0 2 1 ] k z -[ 0 2 1 ] l z -[ 1 0 0 ] m z -[ 1 0 0 ] n z -[ 1 0 1 ] p z -[ 1 0 1 ] q z -[ 1 1 0 ] r z -[ 1 1 0 ] s z -[ 1 1 1 ] t z -[ 1 1 1 ] u z -[ 1 2 0 ] v z -[ 1 2 0 ] w z -[ 1 2 1 ] x z -[ 2 0 0 ] A z -[ 2 0 0 ] B z -[ 2 0 1 ] C z -[ 2 0 1 ] D z -[ 2 1 0 ] E z -[ 2 1 0 ] F z -[ 2 1 1 ] G z -[ 2 1 1 ] H z -[ 2 2 0 ] I z -[ 2 2 0 ] J z -[ 2 2 1 ] K z -[ 2 2 1 ] L z -[ 3 0 0 ] M z -[ 3 0 0 ] N z -[ 3 0 1 ] P z -[ 3 0 1 ] Q z -[ 3 1 0 ] R z -[ 3 1 0 ] S z -[ 3 1 1 ] T z -[ 3 1 1 ] U z -[ 3 2 0 ] V z -[ 3 2 0 ] W z -[ 3 2 1 ] X z -[ 3 2 1 ] Z z +[ 0 0 0 ] z a +[ 0 0 0 ] z b +[ 0 0 1 ] z c +[ 0 0 1 ] z d +[ 0 1 0 ] z e +[ 0 1 0 ] z f +[ 0 1 1 ] z g +[ 0 1 1 ] z h +[ 0 2 0 ] z i +[ 0 2 0 ] z j +[ 0 2 1 ] z k +[ 0 2 1 ] z l +[ 1 0 0 ] z m +[ 1 0 0 ] z n +[ 1 0 1 ] z p +[ 1 0 1 ] z q +[ 1 1 0 ] z r +[ 1 1 0 ] z s +[ 1 1 1 ] z t +[ 1 1 1 ] z u +[ 1 2 0 ] z v +[ 1 2 0 ] z w +[ 1 2 1 ] z x +[ 2 0 0 ] z A +[ 2 0 0 ] z B +[ 2 0 1 ] z C +[ 2 0 1 ] z D +[ 2 1 0 ] z E +[ 2 1 0 ] z F +[ 2 1 1 ] z G +[ 2 1 1 ] z H +[ 2 2 0 ] z I +[ 2 2 0 ] z J +[ 2 2 1 ] z K +[ 2 2 1 ] z L +[ 3 0 0 ] z M +[ 3 0 0 ] z N +[ 3 0 1 ] z P +[ 3 0 1 ] z Q +[ 3 1 0 ] z R +[ 3 1 0 ] z S +[ 3 1 1 ] z T +[ 3 1 1 ] z U +[ 3 2 0 ] z V +[ 3 2 0 ] z W +[ 3 2 1 ] z X +[ 3 2 1 ] z Z 47 differences found attribute: > and > size: [2] [2] @@ -1192,79 +1192,79 @@ attribute: > and > size: [2] [2] position string of string of difference ------------------------------------------------------------ -[ 0 ] a z -[ 0 ] b z -[ 1 ] d z -[ 1 ] e z +[ 0 ] z a +[ 0 ] z b +[ 1 ] z d +[ 1 ] z e 4 differences found attribute: > and > size: [3x2] [3x2] position string2D of string2D of difference ------------------------------------------------------------ -[ 0 0 ] a z -[ 0 0 ] b z -[ 0 1 ] c z -[ 0 1 ] d z -[ 1 0 ] e z -[ 1 0 ] f z -[ 1 1 ] g z -[ 1 1 ] h z -[ 2 0 ] i z -[ 2 0 ] j z -[ 2 1 ] k z -[ 2 1 ] l z +[ 0 0 ] z a +[ 0 0 ] z b +[ 0 1 ] z c +[ 0 1 ] z d +[ 1 0 ] z e +[ 1 0 ] z f +[ 1 1 ] z g +[ 1 1 ] z h +[ 2 0 ] z i +[ 2 0 ] z j +[ 2 1 ] z k +[ 2 1 ] z l 12 differences found attribute: > and > size: [4x3x2] [4x3x2] position string3D of string3D of difference ------------------------------------------------------------ -[ 0 0 0 ] a z -[ 0 0 0 ] b z -[ 0 0 1 ] c z -[ 0 0 1 ] d z -[ 0 1 0 ] e z -[ 0 1 0 ] f z -[ 0 1 1 ] g z -[ 0 1 1 ] h z -[ 0 2 0 ] i z -[ 0 2 0 ] j z -[ 0 2 1 ] k z -[ 0 2 1 ] l z -[ 1 0 0 ] m z -[ 1 0 0 ] n z -[ 1 0 1 ] p z -[ 1 0 1 ] q z -[ 1 1 0 ] r z -[ 1 1 0 ] s z -[ 1 1 1 ] t z -[ 1 1 1 ] u z -[ 1 2 0 ] v z -[ 1 2 0 ] w z -[ 1 2 1 ] x z -[ 2 0 0 ] A z -[ 2 0 0 ] B z -[ 2 0 1 ] C z -[ 2 0 1 ] D z -[ 2 1 0 ] E z -[ 2 1 0 ] F z -[ 2 1 1 ] G z -[ 2 1 1 ] H z -[ 2 2 0 ] I z -[ 2 2 0 ] J z -[ 2 2 1 ] K z -[ 2 2 1 ] L z -[ 3 0 0 ] M z -[ 3 0 0 ] N z -[ 3 0 1 ] P z -[ 3 0 1 ] Q z -[ 3 1 0 ] R z -[ 3 1 0 ] S z -[ 3 1 1 ] T z -[ 3 1 1 ] U z -[ 3 2 0 ] V z -[ 3 2 0 ] W z -[ 3 2 1 ] X z -[ 3 2 1 ] Z z +[ 0 0 0 ] z a +[ 0 0 0 ] z b +[ 0 0 1 ] z c +[ 0 0 1 ] z d +[ 0 1 0 ] z e +[ 0 1 0 ] z f +[ 0 1 1 ] z g +[ 0 1 1 ] z h +[ 0 2 0 ] z i +[ 0 2 0 ] z j +[ 0 2 1 ] z k +[ 0 2 1 ] z l +[ 1 0 0 ] z m +[ 1 0 0 ] z n +[ 1 0 1 ] z p +[ 1 0 1 ] z q +[ 1 1 0 ] z r +[ 1 1 0 ] z s +[ 1 1 1 ] z t +[ 1 1 1 ] z u +[ 1 2 0 ] z v +[ 1 2 0 ] z w +[ 1 2 1 ] z x +[ 2 0 0 ] z A +[ 2 0 0 ] z B +[ 2 0 1 ] z C +[ 2 0 1 ] z D +[ 2 1 0 ] z E +[ 2 1 0 ] z F +[ 2 1 1 ] z G +[ 2 1 1 ] z H +[ 2 2 0 ] z I +[ 2 2 0 ] z J +[ 2 2 1 ] z K +[ 2 2 1 ] z L +[ 3 0 0 ] z M +[ 3 0 0 ] z N +[ 3 0 1 ] z P +[ 3 0 1 ] z Q +[ 3 1 0 ] z R +[ 3 1 0 ] z S +[ 3 1 1 ] z T +[ 3 1 1 ] z U +[ 3 2 0 ] z V +[ 3 2 0 ] z W +[ 3 2 1 ] z X +[ 3 2 1 ] z Z 47 differences found attribute: > and > size: [2] [2] @@ -1360,79 +1360,79 @@ attribute: > and > size: [2] [2] position VLstring of VLstring of difference ------------------------------------------------------------ -[ 0 ] a z -[ 0 ] b z -[ 1 ] d z -[ 1 ] e z +[ 0 ] z a +[ 0 ] z b +[ 1 ] z d +[ 1 ] z e 4 differences found attribute: > and > size: [3x2] [3x2] position VLstring2D of VLstring2D of difference ------------------------------------------------------------ -[ 0 0 ] a z -[ 0 0 ] b z -[ 0 1 ] c z -[ 0 1 ] d z -[ 1 0 ] e z -[ 1 0 ] f z -[ 1 1 ] g z -[ 1 1 ] h z -[ 2 0 ] i z -[ 2 0 ] j z -[ 2 1 ] k z -[ 2 1 ] l z +[ 0 0 ] z a +[ 0 0 ] z b +[ 0 1 ] z c +[ 0 1 ] z d +[ 1 0 ] z e +[ 1 0 ] z f +[ 1 1 ] z g +[ 1 1 ] z h +[ 2 0 ] z i +[ 2 0 ] z j +[ 2 1 ] z k +[ 2 1 ] z l 12 differences found attribute: > and > size: [4x3x2] [4x3x2] position VLstring3D of VLstring3D of difference ------------------------------------------------------------ -[ 0 0 0 ] a z -[ 0 0 0 ] b z -[ 0 0 1 ] c z -[ 0 0 1 ] d z -[ 0 1 0 ] e z -[ 0 1 0 ] f z -[ 0 1 1 ] g z -[ 0 1 1 ] h z -[ 0 2 0 ] i z -[ 0 2 0 ] j z -[ 0 2 1 ] k z -[ 0 2 1 ] l z -[ 1 0 0 ] m z -[ 1 0 0 ] n z -[ 1 0 1 ] p z -[ 1 0 1 ] q z -[ 1 1 0 ] r z -[ 1 1 0 ] s z -[ 1 1 1 ] t z -[ 1 1 1 ] u z -[ 1 2 0 ] v z -[ 1 2 0 ] w z -[ 1 2 1 ] x z -[ 2 0 0 ] A z -[ 2 0 0 ] B z -[ 2 0 1 ] C z -[ 2 0 1 ] D z -[ 2 1 0 ] E z -[ 2 1 0 ] F z -[ 2 1 1 ] G z -[ 2 1 1 ] H z -[ 2 2 0 ] I z -[ 2 2 0 ] J z -[ 2 2 1 ] K z -[ 2 2 1 ] L z -[ 3 0 0 ] M z -[ 3 0 0 ] N z -[ 3 0 1 ] P z -[ 3 0 1 ] Q z -[ 3 1 0 ] R z -[ 3 1 0 ] S z -[ 3 1 1 ] T z -[ 3 1 1 ] U z -[ 3 2 0 ] V z -[ 3 2 0 ] W z -[ 3 2 1 ] X z -[ 3 2 1 ] Z z +[ 0 0 0 ] z a +[ 0 0 0 ] z b +[ 0 0 1 ] z c +[ 0 0 1 ] z d +[ 0 1 0 ] z e +[ 0 1 0 ] z f +[ 0 1 1 ] z g +[ 0 1 1 ] z h +[ 0 2 0 ] z i +[ 0 2 0 ] z j +[ 0 2 1 ] z k +[ 0 2 1 ] z l +[ 1 0 0 ] z m +[ 1 0 0 ] z n +[ 1 0 1 ] z p +[ 1 0 1 ] z q +[ 1 1 0 ] z r +[ 1 1 0 ] z s +[ 1 1 1 ] z t +[ 1 1 1 ] z u +[ 1 2 0 ] z v +[ 1 2 0 ] z w +[ 1 2 1 ] z x +[ 2 0 0 ] z A +[ 2 0 0 ] z B +[ 2 0 1 ] z C +[ 2 0 1 ] z D +[ 2 1 0 ] z E +[ 2 1 0 ] z F +[ 2 1 1 ] z G +[ 2 1 1 ] z H +[ 2 2 0 ] z I +[ 2 2 0 ] z J +[ 2 2 1 ] z K +[ 2 2 1 ] z L +[ 3 0 0 ] z M +[ 3 0 0 ] z N +[ 3 0 1 ] z P +[ 3 0 1 ] z Q +[ 3 1 0 ] z R +[ 3 1 0 ] z S +[ 3 1 1 ] z T +[ 3 1 1 ] z U +[ 3 2 0 ] z V +[ 3 2 0 ] z W +[ 3 2 1 ] z X +[ 3 2 1 ] z Z 47 differences found attribute: > and > size: [2] [2] @@ -1863,79 +1863,79 @@ attribute: > and > size: [2] [2] position string of string of difference ------------------------------------------------------------ -[ 0 ] a z -[ 0 ] b z -[ 1 ] d z -[ 1 ] e z +[ 0 ] z a +[ 0 ] z b +[ 1 ] z d +[ 1 ] z e 4 differences found attribute: > and > size: [3x2] [3x2] position string2D of string2D of difference ------------------------------------------------------------ -[ 0 0 ] a z -[ 0 0 ] b z -[ 0 1 ] c z -[ 0 1 ] d z -[ 1 0 ] e z -[ 1 0 ] f z -[ 1 1 ] g z -[ 1 1 ] h z -[ 2 0 ] i z -[ 2 0 ] j z -[ 2 1 ] k z -[ 2 1 ] l z +[ 0 0 ] z a +[ 0 0 ] z b +[ 0 1 ] z c +[ 0 1 ] z d +[ 1 0 ] z e +[ 1 0 ] z f +[ 1 1 ] z g +[ 1 1 ] z h +[ 2 0 ] z i +[ 2 0 ] z j +[ 2 1 ] z k +[ 2 1 ] z l 12 differences found attribute: > and > size: [4x3x2] [4x3x2] position string3D of string3D of difference ------------------------------------------------------------ -[ 0 0 0 ] a z -[ 0 0 0 ] b z -[ 0 0 1 ] c z -[ 0 0 1 ] d z -[ 0 1 0 ] e z -[ 0 1 0 ] f z -[ 0 1 1 ] g z -[ 0 1 1 ] h z -[ 0 2 0 ] i z -[ 0 2 0 ] j z -[ 0 2 1 ] k z -[ 0 2 1 ] l z -[ 1 0 0 ] m z -[ 1 0 0 ] n z -[ 1 0 1 ] p z -[ 1 0 1 ] q z -[ 1 1 0 ] r z -[ 1 1 0 ] s z -[ 1 1 1 ] t z -[ 1 1 1 ] u z -[ 1 2 0 ] v z -[ 1 2 0 ] w z -[ 1 2 1 ] x z -[ 2 0 0 ] A z -[ 2 0 0 ] B z -[ 2 0 1 ] C z -[ 2 0 1 ] D z -[ 2 1 0 ] E z -[ 2 1 0 ] F z -[ 2 1 1 ] G z -[ 2 1 1 ] H z -[ 2 2 0 ] I z -[ 2 2 0 ] J z -[ 2 2 1 ] K z -[ 2 2 1 ] L z -[ 3 0 0 ] M z -[ 3 0 0 ] N z -[ 3 0 1 ] P z -[ 3 0 1 ] Q z -[ 3 1 0 ] R z -[ 3 1 0 ] S z -[ 3 1 1 ] T z -[ 3 1 1 ] U z -[ 3 2 0 ] V z -[ 3 2 0 ] W z -[ 3 2 1 ] X z -[ 3 2 1 ] Z z +[ 0 0 0 ] z a +[ 0 0 0 ] z b +[ 0 0 1 ] z c +[ 0 0 1 ] z d +[ 0 1 0 ] z e +[ 0 1 0 ] z f +[ 0 1 1 ] z g +[ 0 1 1 ] z h +[ 0 2 0 ] z i +[ 0 2 0 ] z j +[ 0 2 1 ] z k +[ 0 2 1 ] z l +[ 1 0 0 ] z m +[ 1 0 0 ] z n +[ 1 0 1 ] z p +[ 1 0 1 ] z q +[ 1 1 0 ] z r +[ 1 1 0 ] z s +[ 1 1 1 ] z t +[ 1 1 1 ] z u +[ 1 2 0 ] z v +[ 1 2 0 ] z w +[ 1 2 1 ] z x +[ 2 0 0 ] z A +[ 2 0 0 ] z B +[ 2 0 1 ] z C +[ 2 0 1 ] z D +[ 2 1 0 ] z E +[ 2 1 0 ] z F +[ 2 1 1 ] z G +[ 2 1 1 ] z H +[ 2 2 0 ] z I +[ 2 2 0 ] z J +[ 2 2 1 ] z K +[ 2 2 1 ] z L +[ 3 0 0 ] z M +[ 3 0 0 ] z N +[ 3 0 1 ] z P +[ 3 0 1 ] z Q +[ 3 1 0 ] z R +[ 3 1 0 ] z S +[ 3 1 1 ] z T +[ 3 1 1 ] z U +[ 3 2 0 ] z V +[ 3 2 0 ] z W +[ 3 2 1 ] z X +[ 3 2 1 ] z Z 47 differences found attribute: > and > size: [2] [2] diff --git a/tools/test/h5diff/testfiles/h5diff_700.txt b/tools/test/h5diff/testfiles/h5diff_700.txt index 1cf71dd..851a407 100644 --- a/tools/test/h5diff/testfiles/h5diff_700.txt +++ b/tools/test/h5diff/testfiles/h5diff_700.txt @@ -13,79 +13,79 @@ attribute: > and > size: [2] [2] position VLstring of VLstring of difference ------------------------------------------------------------ -[ 0 ] a z -[ 0 ] b z -[ 1 ] d z -[ 1 ] e z +[ 0 ] z a +[ 0 ] z b +[ 1 ] z d +[ 1 ] z e 4 differences found attribute: > and > size: [3x2] [3x2] position VLstring2D of VLstring2D of difference ------------------------------------------------------------ -[ 0 0 ] a z -[ 0 0 ] b z -[ 0 1 ] c z -[ 0 1 ] d z -[ 1 0 ] e z -[ 1 0 ] f z -[ 1 1 ] g z -[ 1 1 ] h z -[ 2 0 ] i z -[ 2 0 ] j z -[ 2 1 ] k z -[ 2 1 ] l z +[ 0 0 ] z a +[ 0 0 ] z b +[ 0 1 ] z c +[ 0 1 ] z d +[ 1 0 ] z e +[ 1 0 ] z f +[ 1 1 ] z g +[ 1 1 ] z h +[ 2 0 ] z i +[ 2 0 ] z j +[ 2 1 ] z k +[ 2 1 ] z l 12 differences found attribute: > and > size: [4x3x2] [4x3x2] position VLstring3D of VLstring3D of difference ------------------------------------------------------------ -[ 0 0 0 ] a z -[ 0 0 0 ] b z -[ 0 0 1 ] c z -[ 0 0 1 ] d z -[ 0 1 0 ] e z -[ 0 1 0 ] f z -[ 0 1 1 ] g z -[ 0 1 1 ] h z -[ 0 2 0 ] i z -[ 0 2 0 ] j z -[ 0 2 1 ] k z -[ 0 2 1 ] l z -[ 1 0 0 ] m z -[ 1 0 0 ] n z -[ 1 0 1 ] p z -[ 1 0 1 ] q z -[ 1 1 0 ] r z -[ 1 1 0 ] s z -[ 1 1 1 ] t z -[ 1 1 1 ] u z -[ 1 2 0 ] v z -[ 1 2 0 ] w z -[ 1 2 1 ] x z -[ 2 0 0 ] A z -[ 2 0 0 ] B z -[ 2 0 1 ] C z -[ 2 0 1 ] D z -[ 2 1 0 ] E z -[ 2 1 0 ] F z -[ 2 1 1 ] G z -[ 2 1 1 ] H z -[ 2 2 0 ] I z -[ 2 2 0 ] J z -[ 2 2 1 ] K z -[ 2 2 1 ] L z -[ 3 0 0 ] M z -[ 3 0 0 ] N z -[ 3 0 1 ] P z -[ 3 0 1 ] Q z -[ 3 1 0 ] R z -[ 3 1 0 ] S z -[ 3 1 1 ] T z -[ 3 1 1 ] U z -[ 3 2 0 ] V z -[ 3 2 0 ] W z -[ 3 2 1 ] X z -[ 3 2 1 ] Z z +[ 0 0 0 ] z a +[ 0 0 0 ] z b +[ 0 0 1 ] z c +[ 0 0 1 ] z d +[ 0 1 0 ] z e +[ 0 1 0 ] z f +[ 0 1 1 ] z g +[ 0 1 1 ] z h +[ 0 2 0 ] z i +[ 0 2 0 ] z j +[ 0 2 1 ] z k +[ 0 2 1 ] z l +[ 1 0 0 ] z m +[ 1 0 0 ] z n +[ 1 0 1 ] z p +[ 1 0 1 ] z q +[ 1 1 0 ] z r +[ 1 1 0 ] z s +[ 1 1 1 ] z t +[ 1 1 1 ] z u +[ 1 2 0 ] z v +[ 1 2 0 ] z w +[ 1 2 1 ] z x +[ 2 0 0 ] z A +[ 2 0 0 ] z B +[ 2 0 1 ] z C +[ 2 0 1 ] z D +[ 2 1 0 ] z E +[ 2 1 0 ] z F +[ 2 1 1 ] z G +[ 2 1 1 ] z H +[ 2 2 0 ] z I +[ 2 2 0 ] z J +[ 2 2 1 ] z K +[ 2 2 1 ] z L +[ 3 0 0 ] z M +[ 3 0 0 ] z N +[ 3 0 1 ] z P +[ 3 0 1 ] z Q +[ 3 1 0 ] z R +[ 3 1 0 ] z S +[ 3 1 1 ] z T +[ 3 1 1 ] z U +[ 3 2 0 ] z V +[ 3 2 0 ] z W +[ 3 2 1 ] z X +[ 3 2 1 ] z Z 47 differences found attribute: > and > size: [2] [2] @@ -516,79 +516,79 @@ attribute: > and > size: [2] [2] position string of string of difference ------------------------------------------------------------ -[ 0 ] a z -[ 0 ] b z -[ 1 ] d z -[ 1 ] e z +[ 0 ] z a +[ 0 ] z b +[ 1 ] z d +[ 1 ] z e 4 differences found attribute: > and > size: [3x2] [3x2] position string2D of string2D of difference ------------------------------------------------------------ -[ 0 0 ] a z -[ 0 0 ] b z -[ 0 1 ] c z -[ 0 1 ] d z -[ 1 0 ] e z -[ 1 0 ] f z -[ 1 1 ] g z -[ 1 1 ] h z -[ 2 0 ] i z -[ 2 0 ] j z -[ 2 1 ] k z -[ 2 1 ] l z +[ 0 0 ] z a +[ 0 0 ] z b +[ 0 1 ] z c +[ 0 1 ] z d +[ 1 0 ] z e +[ 1 0 ] z f +[ 1 1 ] z g +[ 1 1 ] z h +[ 2 0 ] z i +[ 2 0 ] z j +[ 2 1 ] z k +[ 2 1 ] z l 12 differences found attribute: > and > size: [4x3x2] [4x3x2] position string3D of string3D of difference ------------------------------------------------------------ -[ 0 0 0 ] a z -[ 0 0 0 ] b z -[ 0 0 1 ] c z -[ 0 0 1 ] d z -[ 0 1 0 ] e z -[ 0 1 0 ] f z -[ 0 1 1 ] g z -[ 0 1 1 ] h z -[ 0 2 0 ] i z -[ 0 2 0 ] j z -[ 0 2 1 ] k z -[ 0 2 1 ] l z -[ 1 0 0 ] m z -[ 1 0 0 ] n z -[ 1 0 1 ] p z -[ 1 0 1 ] q z -[ 1 1 0 ] r z -[ 1 1 0 ] s z -[ 1 1 1 ] t z -[ 1 1 1 ] u z -[ 1 2 0 ] v z -[ 1 2 0 ] w z -[ 1 2 1 ] x z -[ 2 0 0 ] A z -[ 2 0 0 ] B z -[ 2 0 1 ] C z -[ 2 0 1 ] D z -[ 2 1 0 ] E z -[ 2 1 0 ] F z -[ 2 1 1 ] G z -[ 2 1 1 ] H z -[ 2 2 0 ] I z -[ 2 2 0 ] J z -[ 2 2 1 ] K z -[ 2 2 1 ] L z -[ 3 0 0 ] M z -[ 3 0 0 ] N z -[ 3 0 1 ] P z -[ 3 0 1 ] Q z -[ 3 1 0 ] R z -[ 3 1 0 ] S z -[ 3 1 1 ] T z -[ 3 1 1 ] U z -[ 3 2 0 ] V z -[ 3 2 0 ] W z -[ 3 2 1 ] X z -[ 3 2 1 ] Z z +[ 0 0 0 ] z a +[ 0 0 0 ] z b +[ 0 0 1 ] z c +[ 0 0 1 ] z d +[ 0 1 0 ] z e +[ 0 1 0 ] z f +[ 0 1 1 ] z g +[ 0 1 1 ] z h +[ 0 2 0 ] z i +[ 0 2 0 ] z j +[ 0 2 1 ] z k +[ 0 2 1 ] z l +[ 1 0 0 ] z m +[ 1 0 0 ] z n +[ 1 0 1 ] z p +[ 1 0 1 ] z q +[ 1 1 0 ] z r +[ 1 1 0 ] z s +[ 1 1 1 ] z t +[ 1 1 1 ] z u +[ 1 2 0 ] z v +[ 1 2 0 ] z w +[ 1 2 1 ] z x +[ 2 0 0 ] z A +[ 2 0 0 ] z B +[ 2 0 1 ] z C +[ 2 0 1 ] z D +[ 2 1 0 ] z E +[ 2 1 0 ] z F +[ 2 1 1 ] z G +[ 2 1 1 ] z H +[ 2 2 0 ] z I +[ 2 2 0 ] z J +[ 2 2 1 ] z K +[ 2 2 1 ] z L +[ 3 0 0 ] z M +[ 3 0 0 ] z N +[ 3 0 1 ] z P +[ 3 0 1 ] z Q +[ 3 1 0 ] z R +[ 3 1 0 ] z S +[ 3 1 1 ] z T +[ 3 1 1 ] z U +[ 3 2 0 ] z V +[ 3 2 0 ] z W +[ 3 2 1 ] z X +[ 3 2 1 ] z Z 47 differences found attribute: > and > size: [2] [2] @@ -687,79 +687,79 @@ attribute: > and > size: [2] [2] position VLstring of VLstring of difference ------------------------------------------------------------ -[ 0 ] a z -[ 0 ] b z -[ 1 ] d z -[ 1 ] e z +[ 0 ] z a +[ 0 ] z b +[ 1 ] z d +[ 1 ] z e 4 differences found attribute: > and > size: [3x2] [3x2] position VLstring2D of VLstring2D of difference ------------------------------------------------------------ -[ 0 0 ] a z -[ 0 0 ] b z -[ 0 1 ] c z -[ 0 1 ] d z -[ 1 0 ] e z -[ 1 0 ] f z -[ 1 1 ] g z -[ 1 1 ] h z -[ 2 0 ] i z -[ 2 0 ] j z -[ 2 1 ] k z -[ 2 1 ] l z +[ 0 0 ] z a +[ 0 0 ] z b +[ 0 1 ] z c +[ 0 1 ] z d +[ 1 0 ] z e +[ 1 0 ] z f +[ 1 1 ] z g +[ 1 1 ] z h +[ 2 0 ] z i +[ 2 0 ] z j +[ 2 1 ] z k +[ 2 1 ] z l 12 differences found attribute: > and > size: [4x3x2] [4x3x2] position VLstring3D of VLstring3D of difference ------------------------------------------------------------ -[ 0 0 0 ] a z -[ 0 0 0 ] b z -[ 0 0 1 ] c z -[ 0 0 1 ] d z -[ 0 1 0 ] e z -[ 0 1 0 ] f z -[ 0 1 1 ] g z -[ 0 1 1 ] h z -[ 0 2 0 ] i z -[ 0 2 0 ] j z -[ 0 2 1 ] k z -[ 0 2 1 ] l z -[ 1 0 0 ] m z -[ 1 0 0 ] n z -[ 1 0 1 ] p z -[ 1 0 1 ] q z -[ 1 1 0 ] r z -[ 1 1 0 ] s z -[ 1 1 1 ] t z -[ 1 1 1 ] u z -[ 1 2 0 ] v z -[ 1 2 0 ] w z -[ 1 2 1 ] x z -[ 2 0 0 ] A z -[ 2 0 0 ] B z -[ 2 0 1 ] C z -[ 2 0 1 ] D z -[ 2 1 0 ] E z -[ 2 1 0 ] F z -[ 2 1 1 ] G z -[ 2 1 1 ] H z -[ 2 2 0 ] I z -[ 2 2 0 ] J z -[ 2 2 1 ] K z -[ 2 2 1 ] L z -[ 3 0 0 ] M z -[ 3 0 0 ] N z -[ 3 0 1 ] P z -[ 3 0 1 ] Q z -[ 3 1 0 ] R z -[ 3 1 0 ] S z -[ 3 1 1 ] T z -[ 3 1 1 ] U z -[ 3 2 0 ] V z -[ 3 2 0 ] W z -[ 3 2 1 ] X z -[ 3 2 1 ] Z z +[ 0 0 0 ] z a +[ 0 0 0 ] z b +[ 0 0 1 ] z c +[ 0 0 1 ] z d +[ 0 1 0 ] z e +[ 0 1 0 ] z f +[ 0 1 1 ] z g +[ 0 1 1 ] z h +[ 0 2 0 ] z i +[ 0 2 0 ] z j +[ 0 2 1 ] z k +[ 0 2 1 ] z l +[ 1 0 0 ] z m +[ 1 0 0 ] z n +[ 1 0 1 ] z p +[ 1 0 1 ] z q +[ 1 1 0 ] z r +[ 1 1 0 ] z s +[ 1 1 1 ] z t +[ 1 1 1 ] z u +[ 1 2 0 ] z v +[ 1 2 0 ] z w +[ 1 2 1 ] z x +[ 2 0 0 ] z A +[ 2 0 0 ] z B +[ 2 0 1 ] z C +[ 2 0 1 ] z D +[ 2 1 0 ] z E +[ 2 1 0 ] z F +[ 2 1 1 ] z G +[ 2 1 1 ] z H +[ 2 2 0 ] z I +[ 2 2 0 ] z J +[ 2 2 1 ] z K +[ 2 2 1 ] z L +[ 3 0 0 ] z M +[ 3 0 0 ] z N +[ 3 0 1 ] z P +[ 3 0 1 ] z Q +[ 3 1 0 ] z R +[ 3 1 0 ] z S +[ 3 1 1 ] z T +[ 3 1 1 ] z U +[ 3 2 0 ] z V +[ 3 2 0 ] z W +[ 3 2 1 ] z X +[ 3 2 1 ] z Z 47 differences found attribute: > and > size: [2] [2] @@ -1196,79 +1196,79 @@ attribute: > and > size: [2] [2] position string of string of difference ------------------------------------------------------------ -[ 0 ] a z -[ 0 ] b z -[ 1 ] d z -[ 1 ] e z +[ 0 ] z a +[ 0 ] z b +[ 1 ] z d +[ 1 ] z e 4 differences found attribute: > and > size: [3x2] [3x2] position string2D of string2D of difference ------------------------------------------------------------ -[ 0 0 ] a z -[ 0 0 ] b z -[ 0 1 ] c z -[ 0 1 ] d z -[ 1 0 ] e z -[ 1 0 ] f z -[ 1 1 ] g z -[ 1 1 ] h z -[ 2 0 ] i z -[ 2 0 ] j z -[ 2 1 ] k z -[ 2 1 ] l z +[ 0 0 ] z a +[ 0 0 ] z b +[ 0 1 ] z c +[ 0 1 ] z d +[ 1 0 ] z e +[ 1 0 ] z f +[ 1 1 ] z g +[ 1 1 ] z h +[ 2 0 ] z i +[ 2 0 ] z j +[ 2 1 ] z k +[ 2 1 ] z l 12 differences found attribute: > and > size: [4x3x2] [4x3x2] position string3D of string3D of difference ------------------------------------------------------------ -[ 0 0 0 ] a z -[ 0 0 0 ] b z -[ 0 0 1 ] c z -[ 0 0 1 ] d z -[ 0 1 0 ] e z -[ 0 1 0 ] f z -[ 0 1 1 ] g z -[ 0 1 1 ] h z -[ 0 2 0 ] i z -[ 0 2 0 ] j z -[ 0 2 1 ] k z -[ 0 2 1 ] l z -[ 1 0 0 ] m z -[ 1 0 0 ] n z -[ 1 0 1 ] p z -[ 1 0 1 ] q z -[ 1 1 0 ] r z -[ 1 1 0 ] s z -[ 1 1 1 ] t z -[ 1 1 1 ] u z -[ 1 2 0 ] v z -[ 1 2 0 ] w z -[ 1 2 1 ] x z -[ 2 0 0 ] A z -[ 2 0 0 ] B z -[ 2 0 1 ] C z -[ 2 0 1 ] D z -[ 2 1 0 ] E z -[ 2 1 0 ] F z -[ 2 1 1 ] G z -[ 2 1 1 ] H z -[ 2 2 0 ] I z -[ 2 2 0 ] J z -[ 2 2 1 ] K z -[ 2 2 1 ] L z -[ 3 0 0 ] M z -[ 3 0 0 ] N z -[ 3 0 1 ] P z -[ 3 0 1 ] Q z -[ 3 1 0 ] R z -[ 3 1 0 ] S z -[ 3 1 1 ] T z -[ 3 1 1 ] U z -[ 3 2 0 ] V z -[ 3 2 0 ] W z -[ 3 2 1 ] X z -[ 3 2 1 ] Z z +[ 0 0 0 ] z a +[ 0 0 0 ] z b +[ 0 0 1 ] z c +[ 0 0 1 ] z d +[ 0 1 0 ] z e +[ 0 1 0 ] z f +[ 0 1 1 ] z g +[ 0 1 1 ] z h +[ 0 2 0 ] z i +[ 0 2 0 ] z j +[ 0 2 1 ] z k +[ 0 2 1 ] z l +[ 1 0 0 ] z m +[ 1 0 0 ] z n +[ 1 0 1 ] z p +[ 1 0 1 ] z q +[ 1 1 0 ] z r +[ 1 1 0 ] z s +[ 1 1 1 ] z t +[ 1 1 1 ] z u +[ 1 2 0 ] z v +[ 1 2 0 ] z w +[ 1 2 1 ] z x +[ 2 0 0 ] z A +[ 2 0 0 ] z B +[ 2 0 1 ] z C +[ 2 0 1 ] z D +[ 2 1 0 ] z E +[ 2 1 0 ] z F +[ 2 1 1 ] z G +[ 2 1 1 ] z H +[ 2 2 0 ] z I +[ 2 2 0 ] z J +[ 2 2 1 ] z K +[ 2 2 1 ] z L +[ 3 0 0 ] z M +[ 3 0 0 ] z N +[ 3 0 1 ] z P +[ 3 0 1 ] z Q +[ 3 1 0 ] z R +[ 3 1 0 ] z S +[ 3 1 1 ] z T +[ 3 1 1 ] z U +[ 3 2 0 ] z V +[ 3 2 0 ] z W +[ 3 2 1 ] z X +[ 3 2 1 ] z Z 47 differences found attribute: > and > size: [2] [2] @@ -1366,79 +1366,79 @@ attribute: > and > size: [2] [2] position VLstring of VLstring of difference ------------------------------------------------------------ -[ 0 ] a z -[ 0 ] b z -[ 1 ] d z -[ 1 ] e z +[ 0 ] z a +[ 0 ] z b +[ 1 ] z d +[ 1 ] z e 4 differences found attribute: > and > size: [3x2] [3x2] position VLstring2D of VLstring2D of difference ------------------------------------------------------------ -[ 0 0 ] a z -[ 0 0 ] b z -[ 0 1 ] c z -[ 0 1 ] d z -[ 1 0 ] e z -[ 1 0 ] f z -[ 1 1 ] g z -[ 1 1 ] h z -[ 2 0 ] i z -[ 2 0 ] j z -[ 2 1 ] k z -[ 2 1 ] l z +[ 0 0 ] z a +[ 0 0 ] z b +[ 0 1 ] z c +[ 0 1 ] z d +[ 1 0 ] z e +[ 1 0 ] z f +[ 1 1 ] z g +[ 1 1 ] z h +[ 2 0 ] z i +[ 2 0 ] z j +[ 2 1 ] z k +[ 2 1 ] z l 12 differences found attribute: > and > size: [4x3x2] [4x3x2] position VLstring3D of VLstring3D of difference ------------------------------------------------------------ -[ 0 0 0 ] a z -[ 0 0 0 ] b z -[ 0 0 1 ] c z -[ 0 0 1 ] d z -[ 0 1 0 ] e z -[ 0 1 0 ] f z -[ 0 1 1 ] g z -[ 0 1 1 ] h z -[ 0 2 0 ] i z -[ 0 2 0 ] j z -[ 0 2 1 ] k z -[ 0 2 1 ] l z -[ 1 0 0 ] m z -[ 1 0 0 ] n z -[ 1 0 1 ] p z -[ 1 0 1 ] q z -[ 1 1 0 ] r z -[ 1 1 0 ] s z -[ 1 1 1 ] t z -[ 1 1 1 ] u z -[ 1 2 0 ] v z -[ 1 2 0 ] w z -[ 1 2 1 ] x z -[ 2 0 0 ] A z -[ 2 0 0 ] B z -[ 2 0 1 ] C z -[ 2 0 1 ] D z -[ 2 1 0 ] E z -[ 2 1 0 ] F z -[ 2 1 1 ] G z -[ 2 1 1 ] H z -[ 2 2 0 ] I z -[ 2 2 0 ] J z -[ 2 2 1 ] K z -[ 2 2 1 ] L z -[ 3 0 0 ] M z -[ 3 0 0 ] N z -[ 3 0 1 ] P z -[ 3 0 1 ] Q z -[ 3 1 0 ] R z -[ 3 1 0 ] S z -[ 3 1 1 ] T z -[ 3 1 1 ] U z -[ 3 2 0 ] V z -[ 3 2 0 ] W z -[ 3 2 1 ] X z -[ 3 2 1 ] Z z +[ 0 0 0 ] z a +[ 0 0 0 ] z b +[ 0 0 1 ] z c +[ 0 0 1 ] z d +[ 0 1 0 ] z e +[ 0 1 0 ] z f +[ 0 1 1 ] z g +[ 0 1 1 ] z h +[ 0 2 0 ] z i +[ 0 2 0 ] z j +[ 0 2 1 ] z k +[ 0 2 1 ] z l +[ 1 0 0 ] z m +[ 1 0 0 ] z n +[ 1 0 1 ] z p +[ 1 0 1 ] z q +[ 1 1 0 ] z r +[ 1 1 0 ] z s +[ 1 1 1 ] z t +[ 1 1 1 ] z u +[ 1 2 0 ] z v +[ 1 2 0 ] z w +[ 1 2 1 ] z x +[ 2 0 0 ] z A +[ 2 0 0 ] z B +[ 2 0 1 ] z C +[ 2 0 1 ] z D +[ 2 1 0 ] z E +[ 2 1 0 ] z F +[ 2 1 1 ] z G +[ 2 1 1 ] z H +[ 2 2 0 ] z I +[ 2 2 0 ] z J +[ 2 2 1 ] z K +[ 2 2 1 ] z L +[ 3 0 0 ] z M +[ 3 0 0 ] z N +[ 3 0 1 ] z P +[ 3 0 1 ] z Q +[ 3 1 0 ] z R +[ 3 1 0 ] z S +[ 3 1 1 ] z T +[ 3 1 1 ] z U +[ 3 2 0 ] z V +[ 3 2 0 ] z W +[ 3 2 1 ] z X +[ 3 2 1 ] z Z 47 differences found attribute: > and > size: [2] [2] @@ -1869,79 +1869,79 @@ attribute: > and > size: [2] [2] position string of string of difference ------------------------------------------------------------ -[ 0 ] a z -[ 0 ] b z -[ 1 ] d z -[ 1 ] e z +[ 0 ] z a +[ 0 ] z b +[ 1 ] z d +[ 1 ] z e 4 differences found attribute: > and > size: [3x2] [3x2] position string2D of string2D of difference ------------------------------------------------------------ -[ 0 0 ] a z -[ 0 0 ] b z -[ 0 1 ] c z -[ 0 1 ] d z -[ 1 0 ] e z -[ 1 0 ] f z -[ 1 1 ] g z -[ 1 1 ] h z -[ 2 0 ] i z -[ 2 0 ] j z -[ 2 1 ] k z -[ 2 1 ] l z +[ 0 0 ] z a +[ 0 0 ] z b +[ 0 1 ] z c +[ 0 1 ] z d +[ 1 0 ] z e +[ 1 0 ] z f +[ 1 1 ] z g +[ 1 1 ] z h +[ 2 0 ] z i +[ 2 0 ] z j +[ 2 1 ] z k +[ 2 1 ] z l 12 differences found attribute: > and > size: [4x3x2] [4x3x2] position string3D of string3D of difference ------------------------------------------------------------ -[ 0 0 0 ] a z -[ 0 0 0 ] b z -[ 0 0 1 ] c z -[ 0 0 1 ] d z -[ 0 1 0 ] e z -[ 0 1 0 ] f z -[ 0 1 1 ] g z -[ 0 1 1 ] h z -[ 0 2 0 ] i z -[ 0 2 0 ] j z -[ 0 2 1 ] k z -[ 0 2 1 ] l z -[ 1 0 0 ] m z -[ 1 0 0 ] n z -[ 1 0 1 ] p z -[ 1 0 1 ] q z -[ 1 1 0 ] r z -[ 1 1 0 ] s z -[ 1 1 1 ] t z -[ 1 1 1 ] u z -[ 1 2 0 ] v z -[ 1 2 0 ] w z -[ 1 2 1 ] x z -[ 2 0 0 ] A z -[ 2 0 0 ] B z -[ 2 0 1 ] C z -[ 2 0 1 ] D z -[ 2 1 0 ] E z -[ 2 1 0 ] F z -[ 2 1 1 ] G z -[ 2 1 1 ] H z -[ 2 2 0 ] I z -[ 2 2 0 ] J z -[ 2 2 1 ] K z -[ 2 2 1 ] L z -[ 3 0 0 ] M z -[ 3 0 0 ] N z -[ 3 0 1 ] P z -[ 3 0 1 ] Q z -[ 3 1 0 ] R z -[ 3 1 0 ] S z -[ 3 1 1 ] T z -[ 3 1 1 ] U z -[ 3 2 0 ] V z -[ 3 2 0 ] W z -[ 3 2 1 ] X z -[ 3 2 1 ] Z z +[ 0 0 0 ] z a +[ 0 0 0 ] z b +[ 0 0 1 ] z c +[ 0 0 1 ] z d +[ 0 1 0 ] z e +[ 0 1 0 ] z f +[ 0 1 1 ] z g +[ 0 1 1 ] z h +[ 0 2 0 ] z i +[ 0 2 0 ] z j +[ 0 2 1 ] z k +[ 0 2 1 ] z l +[ 1 0 0 ] z m +[ 1 0 0 ] z n +[ 1 0 1 ] z p +[ 1 0 1 ] z q +[ 1 1 0 ] z r +[ 1 1 0 ] z s +[ 1 1 1 ] z t +[ 1 1 1 ] z u +[ 1 2 0 ] z v +[ 1 2 0 ] z w +[ 1 2 1 ] z x +[ 2 0 0 ] z A +[ 2 0 0 ] z B +[ 2 0 1 ] z C +[ 2 0 1 ] z D +[ 2 1 0 ] z E +[ 2 1 0 ] z F +[ 2 1 1 ] z G +[ 2 1 1 ] z H +[ 2 2 0 ] z I +[ 2 2 0 ] z J +[ 2 2 1 ] z K +[ 2 2 1 ] z L +[ 3 0 0 ] z M +[ 3 0 0 ] z N +[ 3 0 1 ] z P +[ 3 0 1 ] z Q +[ 3 1 0 ] z R +[ 3 1 0 ] z S +[ 3 1 1 ] z T +[ 3 1 1 ] z U +[ 3 2 0 ] z V +[ 3 2 0 ] z W +[ 3 2 1 ] z X +[ 3 2 1 ] z Z 47 differences found attribute: > and > size: [2] [2] diff --git a/tools/test/h5diff/testfiles/h5diff_701.txt b/tools/test/h5diff/testfiles/h5diff_701.txt index 405ab2f..33f1a0f 100644 --- a/tools/test/h5diff/testfiles/h5diff_701.txt +++ b/tools/test/h5diff/testfiles/h5diff_701.txt @@ -45,79 +45,79 @@ attribute: > and > size: [2] [2] position VLstring of VLstring of difference ------------------------------------------------------------ -[ 0 ] a z -[ 0 ] b z -[ 1 ] d z -[ 1 ] e z +[ 0 ] z a +[ 0 ] z b +[ 1 ] z d +[ 1 ] z e 4 differences found attribute: > and > size: [3x2] [3x2] position VLstring2D of VLstring2D of difference ------------------------------------------------------------ -[ 0 0 ] a z -[ 0 0 ] b z -[ 0 1 ] c z -[ 0 1 ] d z -[ 1 0 ] e z -[ 1 0 ] f z -[ 1 1 ] g z -[ 1 1 ] h z -[ 2 0 ] i z -[ 2 0 ] j z -[ 2 1 ] k z -[ 2 1 ] l z +[ 0 0 ] z a +[ 0 0 ] z b +[ 0 1 ] z c +[ 0 1 ] z d +[ 1 0 ] z e +[ 1 0 ] z f +[ 1 1 ] z g +[ 1 1 ] z h +[ 2 0 ] z i +[ 2 0 ] z j +[ 2 1 ] z k +[ 2 1 ] z l 12 differences found attribute: > and > size: [4x3x2] [4x3x2] position VLstring3D of VLstring3D of difference ------------------------------------------------------------ -[ 0 0 0 ] a z -[ 0 0 0 ] b z -[ 0 0 1 ] c z -[ 0 0 1 ] d z -[ 0 1 0 ] e z -[ 0 1 0 ] f z -[ 0 1 1 ] g z -[ 0 1 1 ] h z -[ 0 2 0 ] i z -[ 0 2 0 ] j z -[ 0 2 1 ] k z -[ 0 2 1 ] l z -[ 1 0 0 ] m z -[ 1 0 0 ] n z -[ 1 0 1 ] p z -[ 1 0 1 ] q z -[ 1 1 0 ] r z -[ 1 1 0 ] s z -[ 1 1 1 ] t z -[ 1 1 1 ] u z -[ 1 2 0 ] v z -[ 1 2 0 ] w z -[ 1 2 1 ] x z -[ 2 0 0 ] A z -[ 2 0 0 ] B z -[ 2 0 1 ] C z -[ 2 0 1 ] D z -[ 2 1 0 ] E z -[ 2 1 0 ] F z -[ 2 1 1 ] G z -[ 2 1 1 ] H z -[ 2 2 0 ] I z -[ 2 2 0 ] J z -[ 2 2 1 ] K z -[ 2 2 1 ] L z -[ 3 0 0 ] M z -[ 3 0 0 ] N z -[ 3 0 1 ] P z -[ 3 0 1 ] Q z -[ 3 1 0 ] R z -[ 3 1 0 ] S z -[ 3 1 1 ] T z -[ 3 1 1 ] U z -[ 3 2 0 ] V z -[ 3 2 0 ] W z -[ 3 2 1 ] X z -[ 3 2 1 ] Z z +[ 0 0 0 ] z a +[ 0 0 0 ] z b +[ 0 0 1 ] z c +[ 0 0 1 ] z d +[ 0 1 0 ] z e +[ 0 1 0 ] z f +[ 0 1 1 ] z g +[ 0 1 1 ] z h +[ 0 2 0 ] z i +[ 0 2 0 ] z j +[ 0 2 1 ] z k +[ 0 2 1 ] z l +[ 1 0 0 ] z m +[ 1 0 0 ] z n +[ 1 0 1 ] z p +[ 1 0 1 ] z q +[ 1 1 0 ] z r +[ 1 1 0 ] z s +[ 1 1 1 ] z t +[ 1 1 1 ] z u +[ 1 2 0 ] z v +[ 1 2 0 ] z w +[ 1 2 1 ] z x +[ 2 0 0 ] z A +[ 2 0 0 ] z B +[ 2 0 1 ] z C +[ 2 0 1 ] z D +[ 2 1 0 ] z E +[ 2 1 0 ] z F +[ 2 1 1 ] z G +[ 2 1 1 ] z H +[ 2 2 0 ] z I +[ 2 2 0 ] z J +[ 2 2 1 ] z K +[ 2 2 1 ] z L +[ 3 0 0 ] z M +[ 3 0 0 ] z N +[ 3 0 1 ] z P +[ 3 0 1 ] z Q +[ 3 1 0 ] z R +[ 3 1 0 ] z S +[ 3 1 1 ] z T +[ 3 1 1 ] z U +[ 3 2 0 ] z V +[ 3 2 0 ] z W +[ 3 2 1 ] z X +[ 3 2 1 ] z Z 47 differences found attribute: > and > size: [2] [2] @@ -548,79 +548,79 @@ attribute: > and > size: [2] [2] position string of string of difference ------------------------------------------------------------ -[ 0 ] a z -[ 0 ] b z -[ 1 ] d z -[ 1 ] e z +[ 0 ] z a +[ 0 ] z b +[ 1 ] z d +[ 1 ] z e 4 differences found attribute: > and > size: [3x2] [3x2] position string2D of string2D of difference ------------------------------------------------------------ -[ 0 0 ] a z -[ 0 0 ] b z -[ 0 1 ] c z -[ 0 1 ] d z -[ 1 0 ] e z -[ 1 0 ] f z -[ 1 1 ] g z -[ 1 1 ] h z -[ 2 0 ] i z -[ 2 0 ] j z -[ 2 1 ] k z -[ 2 1 ] l z +[ 0 0 ] z a +[ 0 0 ] z b +[ 0 1 ] z c +[ 0 1 ] z d +[ 1 0 ] z e +[ 1 0 ] z f +[ 1 1 ] z g +[ 1 1 ] z h +[ 2 0 ] z i +[ 2 0 ] z j +[ 2 1 ] z k +[ 2 1 ] z l 12 differences found attribute: > and > size: [4x3x2] [4x3x2] position string3D of string3D of difference ------------------------------------------------------------ -[ 0 0 0 ] a z -[ 0 0 0 ] b z -[ 0 0 1 ] c z -[ 0 0 1 ] d z -[ 0 1 0 ] e z -[ 0 1 0 ] f z -[ 0 1 1 ] g z -[ 0 1 1 ] h z -[ 0 2 0 ] i z -[ 0 2 0 ] j z -[ 0 2 1 ] k z -[ 0 2 1 ] l z -[ 1 0 0 ] m z -[ 1 0 0 ] n z -[ 1 0 1 ] p z -[ 1 0 1 ] q z -[ 1 1 0 ] r z -[ 1 1 0 ] s z -[ 1 1 1 ] t z -[ 1 1 1 ] u z -[ 1 2 0 ] v z -[ 1 2 0 ] w z -[ 1 2 1 ] x z -[ 2 0 0 ] A z -[ 2 0 0 ] B z -[ 2 0 1 ] C z -[ 2 0 1 ] D z -[ 2 1 0 ] E z -[ 2 1 0 ] F z -[ 2 1 1 ] G z -[ 2 1 1 ] H z -[ 2 2 0 ] I z -[ 2 2 0 ] J z -[ 2 2 1 ] K z -[ 2 2 1 ] L z -[ 3 0 0 ] M z -[ 3 0 0 ] N z -[ 3 0 1 ] P z -[ 3 0 1 ] Q z -[ 3 1 0 ] R z -[ 3 1 0 ] S z -[ 3 1 1 ] T z -[ 3 1 1 ] U z -[ 3 2 0 ] V z -[ 3 2 0 ] W z -[ 3 2 1 ] X z -[ 3 2 1 ] Z z +[ 0 0 0 ] z a +[ 0 0 0 ] z b +[ 0 0 1 ] z c +[ 0 0 1 ] z d +[ 0 1 0 ] z e +[ 0 1 0 ] z f +[ 0 1 1 ] z g +[ 0 1 1 ] z h +[ 0 2 0 ] z i +[ 0 2 0 ] z j +[ 0 2 1 ] z k +[ 0 2 1 ] z l +[ 1 0 0 ] z m +[ 1 0 0 ] z n +[ 1 0 1 ] z p +[ 1 0 1 ] z q +[ 1 1 0 ] z r +[ 1 1 0 ] z s +[ 1 1 1 ] z t +[ 1 1 1 ] z u +[ 1 2 0 ] z v +[ 1 2 0 ] z w +[ 1 2 1 ] z x +[ 2 0 0 ] z A +[ 2 0 0 ] z B +[ 2 0 1 ] z C +[ 2 0 1 ] z D +[ 2 1 0 ] z E +[ 2 1 0 ] z F +[ 2 1 1 ] z G +[ 2 1 1 ] z H +[ 2 2 0 ] z I +[ 2 2 0 ] z J +[ 2 2 1 ] z K +[ 2 2 1 ] z L +[ 3 0 0 ] z M +[ 3 0 0 ] z N +[ 3 0 1 ] z P +[ 3 0 1 ] z Q +[ 3 1 0 ] z R +[ 3 1 0 ] z S +[ 3 1 1 ] z T +[ 3 1 1 ] z U +[ 3 2 0 ] z V +[ 3 2 0 ] z W +[ 3 2 1 ] z X +[ 3 2 1 ] z Z 47 differences found attribute: > and > size: [2] [2] @@ -754,79 +754,79 @@ attribute: > and > size: [2] [2] position VLstring of VLstring of difference ------------------------------------------------------------ -[ 0 ] a z -[ 0 ] b z -[ 1 ] d z -[ 1 ] e z +[ 0 ] z a +[ 0 ] z b +[ 1 ] z d +[ 1 ] z e 4 differences found attribute: > and > size: [3x2] [3x2] position VLstring2D of VLstring2D of difference ------------------------------------------------------------ -[ 0 0 ] a z -[ 0 0 ] b z -[ 0 1 ] c z -[ 0 1 ] d z -[ 1 0 ] e z -[ 1 0 ] f z -[ 1 1 ] g z -[ 1 1 ] h z -[ 2 0 ] i z -[ 2 0 ] j z -[ 2 1 ] k z -[ 2 1 ] l z +[ 0 0 ] z a +[ 0 0 ] z b +[ 0 1 ] z c +[ 0 1 ] z d +[ 1 0 ] z e +[ 1 0 ] z f +[ 1 1 ] z g +[ 1 1 ] z h +[ 2 0 ] z i +[ 2 0 ] z j +[ 2 1 ] z k +[ 2 1 ] z l 12 differences found attribute: > and > size: [4x3x2] [4x3x2] position VLstring3D of VLstring3D of difference ------------------------------------------------------------ -[ 0 0 0 ] a z -[ 0 0 0 ] b z -[ 0 0 1 ] c z -[ 0 0 1 ] d z -[ 0 1 0 ] e z -[ 0 1 0 ] f z -[ 0 1 1 ] g z -[ 0 1 1 ] h z -[ 0 2 0 ] i z -[ 0 2 0 ] j z -[ 0 2 1 ] k z -[ 0 2 1 ] l z -[ 1 0 0 ] m z -[ 1 0 0 ] n z -[ 1 0 1 ] p z -[ 1 0 1 ] q z -[ 1 1 0 ] r z -[ 1 1 0 ] s z -[ 1 1 1 ] t z -[ 1 1 1 ] u z -[ 1 2 0 ] v z -[ 1 2 0 ] w z -[ 1 2 1 ] x z -[ 2 0 0 ] A z -[ 2 0 0 ] B z -[ 2 0 1 ] C z -[ 2 0 1 ] D z -[ 2 1 0 ] E z -[ 2 1 0 ] F z -[ 2 1 1 ] G z -[ 2 1 1 ] H z -[ 2 2 0 ] I z -[ 2 2 0 ] J z -[ 2 2 1 ] K z -[ 2 2 1 ] L z -[ 3 0 0 ] M z -[ 3 0 0 ] N z -[ 3 0 1 ] P z -[ 3 0 1 ] Q z -[ 3 1 0 ] R z -[ 3 1 0 ] S z -[ 3 1 1 ] T z -[ 3 1 1 ] U z -[ 3 2 0 ] V z -[ 3 2 0 ] W z -[ 3 2 1 ] X z -[ 3 2 1 ] Z z +[ 0 0 0 ] z a +[ 0 0 0 ] z b +[ 0 0 1 ] z c +[ 0 0 1 ] z d +[ 0 1 0 ] z e +[ 0 1 0 ] z f +[ 0 1 1 ] z g +[ 0 1 1 ] z h +[ 0 2 0 ] z i +[ 0 2 0 ] z j +[ 0 2 1 ] z k +[ 0 2 1 ] z l +[ 1 0 0 ] z m +[ 1 0 0 ] z n +[ 1 0 1 ] z p +[ 1 0 1 ] z q +[ 1 1 0 ] z r +[ 1 1 0 ] z s +[ 1 1 1 ] z t +[ 1 1 1 ] z u +[ 1 2 0 ] z v +[ 1 2 0 ] z w +[ 1 2 1 ] z x +[ 2 0 0 ] z A +[ 2 0 0 ] z B +[ 2 0 1 ] z C +[ 2 0 1 ] z D +[ 2 1 0 ] z E +[ 2 1 0 ] z F +[ 2 1 1 ] z G +[ 2 1 1 ] z H +[ 2 2 0 ] z I +[ 2 2 0 ] z J +[ 2 2 1 ] z K +[ 2 2 1 ] z L +[ 3 0 0 ] z M +[ 3 0 0 ] z N +[ 3 0 1 ] z P +[ 3 0 1 ] z Q +[ 3 1 0 ] z R +[ 3 1 0 ] z S +[ 3 1 1 ] z T +[ 3 1 1 ] z U +[ 3 2 0 ] z V +[ 3 2 0 ] z W +[ 3 2 1 ] z X +[ 3 2 1 ] z Z 47 differences found attribute: > and > size: [2] [2] @@ -1263,79 +1263,79 @@ attribute: > and > size: [2] [2] position string of string of difference ------------------------------------------------------------ -[ 0 ] a z -[ 0 ] b z -[ 1 ] d z -[ 1 ] e z +[ 0 ] z a +[ 0 ] z b +[ 1 ] z d +[ 1 ] z e 4 differences found attribute: > and > size: [3x2] [3x2] position string2D of string2D of difference ------------------------------------------------------------ -[ 0 0 ] a z -[ 0 0 ] b z -[ 0 1 ] c z -[ 0 1 ] d z -[ 1 0 ] e z -[ 1 0 ] f z -[ 1 1 ] g z -[ 1 1 ] h z -[ 2 0 ] i z -[ 2 0 ] j z -[ 2 1 ] k z -[ 2 1 ] l z +[ 0 0 ] z a +[ 0 0 ] z b +[ 0 1 ] z c +[ 0 1 ] z d +[ 1 0 ] z e +[ 1 0 ] z f +[ 1 1 ] z g +[ 1 1 ] z h +[ 2 0 ] z i +[ 2 0 ] z j +[ 2 1 ] z k +[ 2 1 ] z l 12 differences found attribute: > and > size: [4x3x2] [4x3x2] position string3D of string3D of difference ------------------------------------------------------------ -[ 0 0 0 ] a z -[ 0 0 0 ] b z -[ 0 0 1 ] c z -[ 0 0 1 ] d z -[ 0 1 0 ] e z -[ 0 1 0 ] f z -[ 0 1 1 ] g z -[ 0 1 1 ] h z -[ 0 2 0 ] i z -[ 0 2 0 ] j z -[ 0 2 1 ] k z -[ 0 2 1 ] l z -[ 1 0 0 ] m z -[ 1 0 0 ] n z -[ 1 0 1 ] p z -[ 1 0 1 ] q z -[ 1 1 0 ] r z -[ 1 1 0 ] s z -[ 1 1 1 ] t z -[ 1 1 1 ] u z -[ 1 2 0 ] v z -[ 1 2 0 ] w z -[ 1 2 1 ] x z -[ 2 0 0 ] A z -[ 2 0 0 ] B z -[ 2 0 1 ] C z -[ 2 0 1 ] D z -[ 2 1 0 ] E z -[ 2 1 0 ] F z -[ 2 1 1 ] G z -[ 2 1 1 ] H z -[ 2 2 0 ] I z -[ 2 2 0 ] J z -[ 2 2 1 ] K z -[ 2 2 1 ] L z -[ 3 0 0 ] M z -[ 3 0 0 ] N z -[ 3 0 1 ] P z -[ 3 0 1 ] Q z -[ 3 1 0 ] R z -[ 3 1 0 ] S z -[ 3 1 1 ] T z -[ 3 1 1 ] U z -[ 3 2 0 ] V z -[ 3 2 0 ] W z -[ 3 2 1 ] X z -[ 3 2 1 ] Z z +[ 0 0 0 ] z a +[ 0 0 0 ] z b +[ 0 0 1 ] z c +[ 0 0 1 ] z d +[ 0 1 0 ] z e +[ 0 1 0 ] z f +[ 0 1 1 ] z g +[ 0 1 1 ] z h +[ 0 2 0 ] z i +[ 0 2 0 ] z j +[ 0 2 1 ] z k +[ 0 2 1 ] z l +[ 1 0 0 ] z m +[ 1 0 0 ] z n +[ 1 0 1 ] z p +[ 1 0 1 ] z q +[ 1 1 0 ] z r +[ 1 1 0 ] z s +[ 1 1 1 ] z t +[ 1 1 1 ] z u +[ 1 2 0 ] z v +[ 1 2 0 ] z w +[ 1 2 1 ] z x +[ 2 0 0 ] z A +[ 2 0 0 ] z B +[ 2 0 1 ] z C +[ 2 0 1 ] z D +[ 2 1 0 ] z E +[ 2 1 0 ] z F +[ 2 1 1 ] z G +[ 2 1 1 ] z H +[ 2 2 0 ] z I +[ 2 2 0 ] z J +[ 2 2 1 ] z K +[ 2 2 1 ] z L +[ 3 0 0 ] z M +[ 3 0 0 ] z N +[ 3 0 1 ] z P +[ 3 0 1 ] z Q +[ 3 1 0 ] z R +[ 3 1 0 ] z S +[ 3 1 1 ] z T +[ 3 1 1 ] z U +[ 3 2 0 ] z V +[ 3 2 0 ] z W +[ 3 2 1 ] z X +[ 3 2 1 ] z Z 47 differences found attribute: > and > size: [2] [2] @@ -1465,79 +1465,79 @@ attribute: > and > size: [2] [2] position VLstring of VLstring of difference ------------------------------------------------------------ -[ 0 ] a z -[ 0 ] b z -[ 1 ] d z -[ 1 ] e z +[ 0 ] z a +[ 0 ] z b +[ 1 ] z d +[ 1 ] z e 4 differences found attribute: > and > size: [3x2] [3x2] position VLstring2D of VLstring2D of difference ------------------------------------------------------------ -[ 0 0 ] a z -[ 0 0 ] b z -[ 0 1 ] c z -[ 0 1 ] d z -[ 1 0 ] e z -[ 1 0 ] f z -[ 1 1 ] g z -[ 1 1 ] h z -[ 2 0 ] i z -[ 2 0 ] j z -[ 2 1 ] k z -[ 2 1 ] l z +[ 0 0 ] z a +[ 0 0 ] z b +[ 0 1 ] z c +[ 0 1 ] z d +[ 1 0 ] z e +[ 1 0 ] z f +[ 1 1 ] z g +[ 1 1 ] z h +[ 2 0 ] z i +[ 2 0 ] z j +[ 2 1 ] z k +[ 2 1 ] z l 12 differences found attribute: > and > size: [4x3x2] [4x3x2] position VLstring3D of VLstring3D of difference ------------------------------------------------------------ -[ 0 0 0 ] a z -[ 0 0 0 ] b z -[ 0 0 1 ] c z -[ 0 0 1 ] d z -[ 0 1 0 ] e z -[ 0 1 0 ] f z -[ 0 1 1 ] g z -[ 0 1 1 ] h z -[ 0 2 0 ] i z -[ 0 2 0 ] j z -[ 0 2 1 ] k z -[ 0 2 1 ] l z -[ 1 0 0 ] m z -[ 1 0 0 ] n z -[ 1 0 1 ] p z -[ 1 0 1 ] q z -[ 1 1 0 ] r z -[ 1 1 0 ] s z -[ 1 1 1 ] t z -[ 1 1 1 ] u z -[ 1 2 0 ] v z -[ 1 2 0 ] w z -[ 1 2 1 ] x z -[ 2 0 0 ] A z -[ 2 0 0 ] B z -[ 2 0 1 ] C z -[ 2 0 1 ] D z -[ 2 1 0 ] E z -[ 2 1 0 ] F z -[ 2 1 1 ] G z -[ 2 1 1 ] H z -[ 2 2 0 ] I z -[ 2 2 0 ] J z -[ 2 2 1 ] K z -[ 2 2 1 ] L z -[ 3 0 0 ] M z -[ 3 0 0 ] N z -[ 3 0 1 ] P z -[ 3 0 1 ] Q z -[ 3 1 0 ] R z -[ 3 1 0 ] S z -[ 3 1 1 ] T z -[ 3 1 1 ] U z -[ 3 2 0 ] V z -[ 3 2 0 ] W z -[ 3 2 1 ] X z -[ 3 2 1 ] Z z +[ 0 0 0 ] z a +[ 0 0 0 ] z b +[ 0 0 1 ] z c +[ 0 0 1 ] z d +[ 0 1 0 ] z e +[ 0 1 0 ] z f +[ 0 1 1 ] z g +[ 0 1 1 ] z h +[ 0 2 0 ] z i +[ 0 2 0 ] z j +[ 0 2 1 ] z k +[ 0 2 1 ] z l +[ 1 0 0 ] z m +[ 1 0 0 ] z n +[ 1 0 1 ] z p +[ 1 0 1 ] z q +[ 1 1 0 ] z r +[ 1 1 0 ] z s +[ 1 1 1 ] z t +[ 1 1 1 ] z u +[ 1 2 0 ] z v +[ 1 2 0 ] z w +[ 1 2 1 ] z x +[ 2 0 0 ] z A +[ 2 0 0 ] z B +[ 2 0 1 ] z C +[ 2 0 1 ] z D +[ 2 1 0 ] z E +[ 2 1 0 ] z F +[ 2 1 1 ] z G +[ 2 1 1 ] z H +[ 2 2 0 ] z I +[ 2 2 0 ] z J +[ 2 2 1 ] z K +[ 2 2 1 ] z L +[ 3 0 0 ] z M +[ 3 0 0 ] z N +[ 3 0 1 ] z P +[ 3 0 1 ] z Q +[ 3 1 0 ] z R +[ 3 1 0 ] z S +[ 3 1 1 ] z T +[ 3 1 1 ] z U +[ 3 2 0 ] z V +[ 3 2 0 ] z W +[ 3 2 1 ] z X +[ 3 2 1 ] z Z 47 differences found attribute: > and > size: [2] [2] @@ -1968,79 +1968,79 @@ attribute: > and > size: [2] [2] position string of string of difference ------------------------------------------------------------ -[ 0 ] a z -[ 0 ] b z -[ 1 ] d z -[ 1 ] e z +[ 0 ] z a +[ 0 ] z b +[ 1 ] z d +[ 1 ] z e 4 differences found attribute: > and > size: [3x2] [3x2] position string2D of string2D of difference ------------------------------------------------------------ -[ 0 0 ] a z -[ 0 0 ] b z -[ 0 1 ] c z -[ 0 1 ] d z -[ 1 0 ] e z -[ 1 0 ] f z -[ 1 1 ] g z -[ 1 1 ] h z -[ 2 0 ] i z -[ 2 0 ] j z -[ 2 1 ] k z -[ 2 1 ] l z +[ 0 0 ] z a +[ 0 0 ] z b +[ 0 1 ] z c +[ 0 1 ] z d +[ 1 0 ] z e +[ 1 0 ] z f +[ 1 1 ] z g +[ 1 1 ] z h +[ 2 0 ] z i +[ 2 0 ] z j +[ 2 1 ] z k +[ 2 1 ] z l 12 differences found attribute: > and > size: [4x3x2] [4x3x2] position string3D of string3D of difference ------------------------------------------------------------ -[ 0 0 0 ] a z -[ 0 0 0 ] b z -[ 0 0 1 ] c z -[ 0 0 1 ] d z -[ 0 1 0 ] e z -[ 0 1 0 ] f z -[ 0 1 1 ] g z -[ 0 1 1 ] h z -[ 0 2 0 ] i z -[ 0 2 0 ] j z -[ 0 2 1 ] k z -[ 0 2 1 ] l z -[ 1 0 0 ] m z -[ 1 0 0 ] n z -[ 1 0 1 ] p z -[ 1 0 1 ] q z -[ 1 1 0 ] r z -[ 1 1 0 ] s z -[ 1 1 1 ] t z -[ 1 1 1 ] u z -[ 1 2 0 ] v z -[ 1 2 0 ] w z -[ 1 2 1 ] x z -[ 2 0 0 ] A z -[ 2 0 0 ] B z -[ 2 0 1 ] C z -[ 2 0 1 ] D z -[ 2 1 0 ] E z -[ 2 1 0 ] F z -[ 2 1 1 ] G z -[ 2 1 1 ] H z -[ 2 2 0 ] I z -[ 2 2 0 ] J z -[ 2 2 1 ] K z -[ 2 2 1 ] L z -[ 3 0 0 ] M z -[ 3 0 0 ] N z -[ 3 0 1 ] P z -[ 3 0 1 ] Q z -[ 3 1 0 ] R z -[ 3 1 0 ] S z -[ 3 1 1 ] T z -[ 3 1 1 ] U z -[ 3 2 0 ] V z -[ 3 2 0 ] W z -[ 3 2 1 ] X z -[ 3 2 1 ] Z z +[ 0 0 0 ] z a +[ 0 0 0 ] z b +[ 0 0 1 ] z c +[ 0 0 1 ] z d +[ 0 1 0 ] z e +[ 0 1 0 ] z f +[ 0 1 1 ] z g +[ 0 1 1 ] z h +[ 0 2 0 ] z i +[ 0 2 0 ] z j +[ 0 2 1 ] z k +[ 0 2 1 ] z l +[ 1 0 0 ] z m +[ 1 0 0 ] z n +[ 1 0 1 ] z p +[ 1 0 1 ] z q +[ 1 1 0 ] z r +[ 1 1 0 ] z s +[ 1 1 1 ] z t +[ 1 1 1 ] z u +[ 1 2 0 ] z v +[ 1 2 0 ] z w +[ 1 2 1 ] z x +[ 2 0 0 ] z A +[ 2 0 0 ] z B +[ 2 0 1 ] z C +[ 2 0 1 ] z D +[ 2 1 0 ] z E +[ 2 1 0 ] z F +[ 2 1 1 ] z G +[ 2 1 1 ] z H +[ 2 2 0 ] z I +[ 2 2 0 ] z J +[ 2 2 1 ] z K +[ 2 2 1 ] z L +[ 3 0 0 ] z M +[ 3 0 0 ] z N +[ 3 0 1 ] z P +[ 3 0 1 ] z Q +[ 3 1 0 ] z R +[ 3 1 0 ] z S +[ 3 1 1 ] z T +[ 3 1 1 ] z U +[ 3 2 0 ] z V +[ 3 2 0 ] z W +[ 3 2 1 ] z X +[ 3 2 1 ] z Z 47 differences found attribute: > and > size: [2] [2] diff --git a/tools/test/h5diff/testfiles/h5diff_702.txt b/tools/test/h5diff/testfiles/h5diff_702.txt index 1cf71dd..851a407 100644 --- a/tools/test/h5diff/testfiles/h5diff_702.txt +++ b/tools/test/h5diff/testfiles/h5diff_702.txt @@ -13,79 +13,79 @@ attribute: > and > size: [2] [2] position VLstring of VLstring of difference ------------------------------------------------------------ -[ 0 ] a z -[ 0 ] b z -[ 1 ] d z -[ 1 ] e z +[ 0 ] z a +[ 0 ] z b +[ 1 ] z d +[ 1 ] z e 4 differences found attribute: > and > size: [3x2] [3x2] position VLstring2D of VLstring2D of difference ------------------------------------------------------------ -[ 0 0 ] a z -[ 0 0 ] b z -[ 0 1 ] c z -[ 0 1 ] d z -[ 1 0 ] e z -[ 1 0 ] f z -[ 1 1 ] g z -[ 1 1 ] h z -[ 2 0 ] i z -[ 2 0 ] j z -[ 2 1 ] k z -[ 2 1 ] l z +[ 0 0 ] z a +[ 0 0 ] z b +[ 0 1 ] z c +[ 0 1 ] z d +[ 1 0 ] z e +[ 1 0 ] z f +[ 1 1 ] z g +[ 1 1 ] z h +[ 2 0 ] z i +[ 2 0 ] z j +[ 2 1 ] z k +[ 2 1 ] z l 12 differences found attribute: > and > size: [4x3x2] [4x3x2] position VLstring3D of VLstring3D of difference ------------------------------------------------------------ -[ 0 0 0 ] a z -[ 0 0 0 ] b z -[ 0 0 1 ] c z -[ 0 0 1 ] d z -[ 0 1 0 ] e z -[ 0 1 0 ] f z -[ 0 1 1 ] g z -[ 0 1 1 ] h z -[ 0 2 0 ] i z -[ 0 2 0 ] j z -[ 0 2 1 ] k z -[ 0 2 1 ] l z -[ 1 0 0 ] m z -[ 1 0 0 ] n z -[ 1 0 1 ] p z -[ 1 0 1 ] q z -[ 1 1 0 ] r z -[ 1 1 0 ] s z -[ 1 1 1 ] t z -[ 1 1 1 ] u z -[ 1 2 0 ] v z -[ 1 2 0 ] w z -[ 1 2 1 ] x z -[ 2 0 0 ] A z -[ 2 0 0 ] B z -[ 2 0 1 ] C z -[ 2 0 1 ] D z -[ 2 1 0 ] E z -[ 2 1 0 ] F z -[ 2 1 1 ] G z -[ 2 1 1 ] H z -[ 2 2 0 ] I z -[ 2 2 0 ] J z -[ 2 2 1 ] K z -[ 2 2 1 ] L z -[ 3 0 0 ] M z -[ 3 0 0 ] N z -[ 3 0 1 ] P z -[ 3 0 1 ] Q z -[ 3 1 0 ] R z -[ 3 1 0 ] S z -[ 3 1 1 ] T z -[ 3 1 1 ] U z -[ 3 2 0 ] V z -[ 3 2 0 ] W z -[ 3 2 1 ] X z -[ 3 2 1 ] Z z +[ 0 0 0 ] z a +[ 0 0 0 ] z b +[ 0 0 1 ] z c +[ 0 0 1 ] z d +[ 0 1 0 ] z e +[ 0 1 0 ] z f +[ 0 1 1 ] z g +[ 0 1 1 ] z h +[ 0 2 0 ] z i +[ 0 2 0 ] z j +[ 0 2 1 ] z k +[ 0 2 1 ] z l +[ 1 0 0 ] z m +[ 1 0 0 ] z n +[ 1 0 1 ] z p +[ 1 0 1 ] z q +[ 1 1 0 ] z r +[ 1 1 0 ] z s +[ 1 1 1 ] z t +[ 1 1 1 ] z u +[ 1 2 0 ] z v +[ 1 2 0 ] z w +[ 1 2 1 ] z x +[ 2 0 0 ] z A +[ 2 0 0 ] z B +[ 2 0 1 ] z C +[ 2 0 1 ] z D +[ 2 1 0 ] z E +[ 2 1 0 ] z F +[ 2 1 1 ] z G +[ 2 1 1 ] z H +[ 2 2 0 ] z I +[ 2 2 0 ] z J +[ 2 2 1 ] z K +[ 2 2 1 ] z L +[ 3 0 0 ] z M +[ 3 0 0 ] z N +[ 3 0 1 ] z P +[ 3 0 1 ] z Q +[ 3 1 0 ] z R +[ 3 1 0 ] z S +[ 3 1 1 ] z T +[ 3 1 1 ] z U +[ 3 2 0 ] z V +[ 3 2 0 ] z W +[ 3 2 1 ] z X +[ 3 2 1 ] z Z 47 differences found attribute: > and > size: [2] [2] @@ -516,79 +516,79 @@ attribute: > and > size: [2] [2] position string of string of difference ------------------------------------------------------------ -[ 0 ] a z -[ 0 ] b z -[ 1 ] d z -[ 1 ] e z +[ 0 ] z a +[ 0 ] z b +[ 1 ] z d +[ 1 ] z e 4 differences found attribute: > and > size: [3x2] [3x2] position string2D of string2D of difference ------------------------------------------------------------ -[ 0 0 ] a z -[ 0 0 ] b z -[ 0 1 ] c z -[ 0 1 ] d z -[ 1 0 ] e z -[ 1 0 ] f z -[ 1 1 ] g z -[ 1 1 ] h z -[ 2 0 ] i z -[ 2 0 ] j z -[ 2 1 ] k z -[ 2 1 ] l z +[ 0 0 ] z a +[ 0 0 ] z b +[ 0 1 ] z c +[ 0 1 ] z d +[ 1 0 ] z e +[ 1 0 ] z f +[ 1 1 ] z g +[ 1 1 ] z h +[ 2 0 ] z i +[ 2 0 ] z j +[ 2 1 ] z k +[ 2 1 ] z l 12 differences found attribute: > and > size: [4x3x2] [4x3x2] position string3D of string3D of difference ------------------------------------------------------------ -[ 0 0 0 ] a z -[ 0 0 0 ] b z -[ 0 0 1 ] c z -[ 0 0 1 ] d z -[ 0 1 0 ] e z -[ 0 1 0 ] f z -[ 0 1 1 ] g z -[ 0 1 1 ] h z -[ 0 2 0 ] i z -[ 0 2 0 ] j z -[ 0 2 1 ] k z -[ 0 2 1 ] l z -[ 1 0 0 ] m z -[ 1 0 0 ] n z -[ 1 0 1 ] p z -[ 1 0 1 ] q z -[ 1 1 0 ] r z -[ 1 1 0 ] s z -[ 1 1 1 ] t z -[ 1 1 1 ] u z -[ 1 2 0 ] v z -[ 1 2 0 ] w z -[ 1 2 1 ] x z -[ 2 0 0 ] A z -[ 2 0 0 ] B z -[ 2 0 1 ] C z -[ 2 0 1 ] D z -[ 2 1 0 ] E z -[ 2 1 0 ] F z -[ 2 1 1 ] G z -[ 2 1 1 ] H z -[ 2 2 0 ] I z -[ 2 2 0 ] J z -[ 2 2 1 ] K z -[ 2 2 1 ] L z -[ 3 0 0 ] M z -[ 3 0 0 ] N z -[ 3 0 1 ] P z -[ 3 0 1 ] Q z -[ 3 1 0 ] R z -[ 3 1 0 ] S z -[ 3 1 1 ] T z -[ 3 1 1 ] U z -[ 3 2 0 ] V z -[ 3 2 0 ] W z -[ 3 2 1 ] X z -[ 3 2 1 ] Z z +[ 0 0 0 ] z a +[ 0 0 0 ] z b +[ 0 0 1 ] z c +[ 0 0 1 ] z d +[ 0 1 0 ] z e +[ 0 1 0 ] z f +[ 0 1 1 ] z g +[ 0 1 1 ] z h +[ 0 2 0 ] z i +[ 0 2 0 ] z j +[ 0 2 1 ] z k +[ 0 2 1 ] z l +[ 1 0 0 ] z m +[ 1 0 0 ] z n +[ 1 0 1 ] z p +[ 1 0 1 ] z q +[ 1 1 0 ] z r +[ 1 1 0 ] z s +[ 1 1 1 ] z t +[ 1 1 1 ] z u +[ 1 2 0 ] z v +[ 1 2 0 ] z w +[ 1 2 1 ] z x +[ 2 0 0 ] z A +[ 2 0 0 ] z B +[ 2 0 1 ] z C +[ 2 0 1 ] z D +[ 2 1 0 ] z E +[ 2 1 0 ] z F +[ 2 1 1 ] z G +[ 2 1 1 ] z H +[ 2 2 0 ] z I +[ 2 2 0 ] z J +[ 2 2 1 ] z K +[ 2 2 1 ] z L +[ 3 0 0 ] z M +[ 3 0 0 ] z N +[ 3 0 1 ] z P +[ 3 0 1 ] z Q +[ 3 1 0 ] z R +[ 3 1 0 ] z S +[ 3 1 1 ] z T +[ 3 1 1 ] z U +[ 3 2 0 ] z V +[ 3 2 0 ] z W +[ 3 2 1 ] z X +[ 3 2 1 ] z Z 47 differences found attribute: > and > size: [2] [2] @@ -687,79 +687,79 @@ attribute: > and > size: [2] [2] position VLstring of VLstring of difference ------------------------------------------------------------ -[ 0 ] a z -[ 0 ] b z -[ 1 ] d z -[ 1 ] e z +[ 0 ] z a +[ 0 ] z b +[ 1 ] z d +[ 1 ] z e 4 differences found attribute: > and > size: [3x2] [3x2] position VLstring2D of VLstring2D of difference ------------------------------------------------------------ -[ 0 0 ] a z -[ 0 0 ] b z -[ 0 1 ] c z -[ 0 1 ] d z -[ 1 0 ] e z -[ 1 0 ] f z -[ 1 1 ] g z -[ 1 1 ] h z -[ 2 0 ] i z -[ 2 0 ] j z -[ 2 1 ] k z -[ 2 1 ] l z +[ 0 0 ] z a +[ 0 0 ] z b +[ 0 1 ] z c +[ 0 1 ] z d +[ 1 0 ] z e +[ 1 0 ] z f +[ 1 1 ] z g +[ 1 1 ] z h +[ 2 0 ] z i +[ 2 0 ] z j +[ 2 1 ] z k +[ 2 1 ] z l 12 differences found attribute: > and > size: [4x3x2] [4x3x2] position VLstring3D of VLstring3D of difference ------------------------------------------------------------ -[ 0 0 0 ] a z -[ 0 0 0 ] b z -[ 0 0 1 ] c z -[ 0 0 1 ] d z -[ 0 1 0 ] e z -[ 0 1 0 ] f z -[ 0 1 1 ] g z -[ 0 1 1 ] h z -[ 0 2 0 ] i z -[ 0 2 0 ] j z -[ 0 2 1 ] k z -[ 0 2 1 ] l z -[ 1 0 0 ] m z -[ 1 0 0 ] n z -[ 1 0 1 ] p z -[ 1 0 1 ] q z -[ 1 1 0 ] r z -[ 1 1 0 ] s z -[ 1 1 1 ] t z -[ 1 1 1 ] u z -[ 1 2 0 ] v z -[ 1 2 0 ] w z -[ 1 2 1 ] x z -[ 2 0 0 ] A z -[ 2 0 0 ] B z -[ 2 0 1 ] C z -[ 2 0 1 ] D z -[ 2 1 0 ] E z -[ 2 1 0 ] F z -[ 2 1 1 ] G z -[ 2 1 1 ] H z -[ 2 2 0 ] I z -[ 2 2 0 ] J z -[ 2 2 1 ] K z -[ 2 2 1 ] L z -[ 3 0 0 ] M z -[ 3 0 0 ] N z -[ 3 0 1 ] P z -[ 3 0 1 ] Q z -[ 3 1 0 ] R z -[ 3 1 0 ] S z -[ 3 1 1 ] T z -[ 3 1 1 ] U z -[ 3 2 0 ] V z -[ 3 2 0 ] W z -[ 3 2 1 ] X z -[ 3 2 1 ] Z z +[ 0 0 0 ] z a +[ 0 0 0 ] z b +[ 0 0 1 ] z c +[ 0 0 1 ] z d +[ 0 1 0 ] z e +[ 0 1 0 ] z f +[ 0 1 1 ] z g +[ 0 1 1 ] z h +[ 0 2 0 ] z i +[ 0 2 0 ] z j +[ 0 2 1 ] z k +[ 0 2 1 ] z l +[ 1 0 0 ] z m +[ 1 0 0 ] z n +[ 1 0 1 ] z p +[ 1 0 1 ] z q +[ 1 1 0 ] z r +[ 1 1 0 ] z s +[ 1 1 1 ] z t +[ 1 1 1 ] z u +[ 1 2 0 ] z v +[ 1 2 0 ] z w +[ 1 2 1 ] z x +[ 2 0 0 ] z A +[ 2 0 0 ] z B +[ 2 0 1 ] z C +[ 2 0 1 ] z D +[ 2 1 0 ] z E +[ 2 1 0 ] z F +[ 2 1 1 ] z G +[ 2 1 1 ] z H +[ 2 2 0 ] z I +[ 2 2 0 ] z J +[ 2 2 1 ] z K +[ 2 2 1 ] z L +[ 3 0 0 ] z M +[ 3 0 0 ] z N +[ 3 0 1 ] z P +[ 3 0 1 ] z Q +[ 3 1 0 ] z R +[ 3 1 0 ] z S +[ 3 1 1 ] z T +[ 3 1 1 ] z U +[ 3 2 0 ] z V +[ 3 2 0 ] z W +[ 3 2 1 ] z X +[ 3 2 1 ] z Z 47 differences found attribute: > and > size: [2] [2] @@ -1196,79 +1196,79 @@ attribute: > and > size: [2] [2] position string of string of difference ------------------------------------------------------------ -[ 0 ] a z -[ 0 ] b z -[ 1 ] d z -[ 1 ] e z +[ 0 ] z a +[ 0 ] z b +[ 1 ] z d +[ 1 ] z e 4 differences found attribute: > and > size: [3x2] [3x2] position string2D of string2D of difference ------------------------------------------------------------ -[ 0 0 ] a z -[ 0 0 ] b z -[ 0 1 ] c z -[ 0 1 ] d z -[ 1 0 ] e z -[ 1 0 ] f z -[ 1 1 ] g z -[ 1 1 ] h z -[ 2 0 ] i z -[ 2 0 ] j z -[ 2 1 ] k z -[ 2 1 ] l z +[ 0 0 ] z a +[ 0 0 ] z b +[ 0 1 ] z c +[ 0 1 ] z d +[ 1 0 ] z e +[ 1 0 ] z f +[ 1 1 ] z g +[ 1 1 ] z h +[ 2 0 ] z i +[ 2 0 ] z j +[ 2 1 ] z k +[ 2 1 ] z l 12 differences found attribute: > and > size: [4x3x2] [4x3x2] position string3D of string3D of difference ------------------------------------------------------------ -[ 0 0 0 ] a z -[ 0 0 0 ] b z -[ 0 0 1 ] c z -[ 0 0 1 ] d z -[ 0 1 0 ] e z -[ 0 1 0 ] f z -[ 0 1 1 ] g z -[ 0 1 1 ] h z -[ 0 2 0 ] i z -[ 0 2 0 ] j z -[ 0 2 1 ] k z -[ 0 2 1 ] l z -[ 1 0 0 ] m z -[ 1 0 0 ] n z -[ 1 0 1 ] p z -[ 1 0 1 ] q z -[ 1 1 0 ] r z -[ 1 1 0 ] s z -[ 1 1 1 ] t z -[ 1 1 1 ] u z -[ 1 2 0 ] v z -[ 1 2 0 ] w z -[ 1 2 1 ] x z -[ 2 0 0 ] A z -[ 2 0 0 ] B z -[ 2 0 1 ] C z -[ 2 0 1 ] D z -[ 2 1 0 ] E z -[ 2 1 0 ] F z -[ 2 1 1 ] G z -[ 2 1 1 ] H z -[ 2 2 0 ] I z -[ 2 2 0 ] J z -[ 2 2 1 ] K z -[ 2 2 1 ] L z -[ 3 0 0 ] M z -[ 3 0 0 ] N z -[ 3 0 1 ] P z -[ 3 0 1 ] Q z -[ 3 1 0 ] R z -[ 3 1 0 ] S z -[ 3 1 1 ] T z -[ 3 1 1 ] U z -[ 3 2 0 ] V z -[ 3 2 0 ] W z -[ 3 2 1 ] X z -[ 3 2 1 ] Z z +[ 0 0 0 ] z a +[ 0 0 0 ] z b +[ 0 0 1 ] z c +[ 0 0 1 ] z d +[ 0 1 0 ] z e +[ 0 1 0 ] z f +[ 0 1 1 ] z g +[ 0 1 1 ] z h +[ 0 2 0 ] z i +[ 0 2 0 ] z j +[ 0 2 1 ] z k +[ 0 2 1 ] z l +[ 1 0 0 ] z m +[ 1 0 0 ] z n +[ 1 0 1 ] z p +[ 1 0 1 ] z q +[ 1 1 0 ] z r +[ 1 1 0 ] z s +[ 1 1 1 ] z t +[ 1 1 1 ] z u +[ 1 2 0 ] z v +[ 1 2 0 ] z w +[ 1 2 1 ] z x +[ 2 0 0 ] z A +[ 2 0 0 ] z B +[ 2 0 1 ] z C +[ 2 0 1 ] z D +[ 2 1 0 ] z E +[ 2 1 0 ] z F +[ 2 1 1 ] z G +[ 2 1 1 ] z H +[ 2 2 0 ] z I +[ 2 2 0 ] z J +[ 2 2 1 ] z K +[ 2 2 1 ] z L +[ 3 0 0 ] z M +[ 3 0 0 ] z N +[ 3 0 1 ] z P +[ 3 0 1 ] z Q +[ 3 1 0 ] z R +[ 3 1 0 ] z S +[ 3 1 1 ] z T +[ 3 1 1 ] z U +[ 3 2 0 ] z V +[ 3 2 0 ] z W +[ 3 2 1 ] z X +[ 3 2 1 ] z Z 47 differences found attribute: > and > size: [2] [2] @@ -1366,79 +1366,79 @@ attribute: > and > size: [2] [2] position VLstring of VLstring of difference ------------------------------------------------------------ -[ 0 ] a z -[ 0 ] b z -[ 1 ] d z -[ 1 ] e z +[ 0 ] z a +[ 0 ] z b +[ 1 ] z d +[ 1 ] z e 4 differences found attribute: > and > size: [3x2] [3x2] position VLstring2D of VLstring2D of difference ------------------------------------------------------------ -[ 0 0 ] a z -[ 0 0 ] b z -[ 0 1 ] c z -[ 0 1 ] d z -[ 1 0 ] e z -[ 1 0 ] f z -[ 1 1 ] g z -[ 1 1 ] h z -[ 2 0 ] i z -[ 2 0 ] j z -[ 2 1 ] k z -[ 2 1 ] l z +[ 0 0 ] z a +[ 0 0 ] z b +[ 0 1 ] z c +[ 0 1 ] z d +[ 1 0 ] z e +[ 1 0 ] z f +[ 1 1 ] z g +[ 1 1 ] z h +[ 2 0 ] z i +[ 2 0 ] z j +[ 2 1 ] z k +[ 2 1 ] z l 12 differences found attribute: > and > size: [4x3x2] [4x3x2] position VLstring3D of VLstring3D of difference ------------------------------------------------------------ -[ 0 0 0 ] a z -[ 0 0 0 ] b z -[ 0 0 1 ] c z -[ 0 0 1 ] d z -[ 0 1 0 ] e z -[ 0 1 0 ] f z -[ 0 1 1 ] g z -[ 0 1 1 ] h z -[ 0 2 0 ] i z -[ 0 2 0 ] j z -[ 0 2 1 ] k z -[ 0 2 1 ] l z -[ 1 0 0 ] m z -[ 1 0 0 ] n z -[ 1 0 1 ] p z -[ 1 0 1 ] q z -[ 1 1 0 ] r z -[ 1 1 0 ] s z -[ 1 1 1 ] t z -[ 1 1 1 ] u z -[ 1 2 0 ] v z -[ 1 2 0 ] w z -[ 1 2 1 ] x z -[ 2 0 0 ] A z -[ 2 0 0 ] B z -[ 2 0 1 ] C z -[ 2 0 1 ] D z -[ 2 1 0 ] E z -[ 2 1 0 ] F z -[ 2 1 1 ] G z -[ 2 1 1 ] H z -[ 2 2 0 ] I z -[ 2 2 0 ] J z -[ 2 2 1 ] K z -[ 2 2 1 ] L z -[ 3 0 0 ] M z -[ 3 0 0 ] N z -[ 3 0 1 ] P z -[ 3 0 1 ] Q z -[ 3 1 0 ] R z -[ 3 1 0 ] S z -[ 3 1 1 ] T z -[ 3 1 1 ] U z -[ 3 2 0 ] V z -[ 3 2 0 ] W z -[ 3 2 1 ] X z -[ 3 2 1 ] Z z +[ 0 0 0 ] z a +[ 0 0 0 ] z b +[ 0 0 1 ] z c +[ 0 0 1 ] z d +[ 0 1 0 ] z e +[ 0 1 0 ] z f +[ 0 1 1 ] z g +[ 0 1 1 ] z h +[ 0 2 0 ] z i +[ 0 2 0 ] z j +[ 0 2 1 ] z k +[ 0 2 1 ] z l +[ 1 0 0 ] z m +[ 1 0 0 ] z n +[ 1 0 1 ] z p +[ 1 0 1 ] z q +[ 1 1 0 ] z r +[ 1 1 0 ] z s +[ 1 1 1 ] z t +[ 1 1 1 ] z u +[ 1 2 0 ] z v +[ 1 2 0 ] z w +[ 1 2 1 ] z x +[ 2 0 0 ] z A +[ 2 0 0 ] z B +[ 2 0 1 ] z C +[ 2 0 1 ] z D +[ 2 1 0 ] z E +[ 2 1 0 ] z F +[ 2 1 1 ] z G +[ 2 1 1 ] z H +[ 2 2 0 ] z I +[ 2 2 0 ] z J +[ 2 2 1 ] z K +[ 2 2 1 ] z L +[ 3 0 0 ] z M +[ 3 0 0 ] z N +[ 3 0 1 ] z P +[ 3 0 1 ] z Q +[ 3 1 0 ] z R +[ 3 1 0 ] z S +[ 3 1 1 ] z T +[ 3 1 1 ] z U +[ 3 2 0 ] z V +[ 3 2 0 ] z W +[ 3 2 1 ] z X +[ 3 2 1 ] z Z 47 differences found attribute: > and > size: [2] [2] @@ -1869,79 +1869,79 @@ attribute: > and > size: [2] [2] position string of string of difference ------------------------------------------------------------ -[ 0 ] a z -[ 0 ] b z -[ 1 ] d z -[ 1 ] e z +[ 0 ] z a +[ 0 ] z b +[ 1 ] z d +[ 1 ] z e 4 differences found attribute: > and > size: [3x2] [3x2] position string2D of string2D of difference ------------------------------------------------------------ -[ 0 0 ] a z -[ 0 0 ] b z -[ 0 1 ] c z -[ 0 1 ] d z -[ 1 0 ] e z -[ 1 0 ] f z -[ 1 1 ] g z -[ 1 1 ] h z -[ 2 0 ] i z -[ 2 0 ] j z -[ 2 1 ] k z -[ 2 1 ] l z +[ 0 0 ] z a +[ 0 0 ] z b +[ 0 1 ] z c +[ 0 1 ] z d +[ 1 0 ] z e +[ 1 0 ] z f +[ 1 1 ] z g +[ 1 1 ] z h +[ 2 0 ] z i +[ 2 0 ] z j +[ 2 1 ] z k +[ 2 1 ] z l 12 differences found attribute: > and > size: [4x3x2] [4x3x2] position string3D of string3D of difference ------------------------------------------------------------ -[ 0 0 0 ] a z -[ 0 0 0 ] b z -[ 0 0 1 ] c z -[ 0 0 1 ] d z -[ 0 1 0 ] e z -[ 0 1 0 ] f z -[ 0 1 1 ] g z -[ 0 1 1 ] h z -[ 0 2 0 ] i z -[ 0 2 0 ] j z -[ 0 2 1 ] k z -[ 0 2 1 ] l z -[ 1 0 0 ] m z -[ 1 0 0 ] n z -[ 1 0 1 ] p z -[ 1 0 1 ] q z -[ 1 1 0 ] r z -[ 1 1 0 ] s z -[ 1 1 1 ] t z -[ 1 1 1 ] u z -[ 1 2 0 ] v z -[ 1 2 0 ] w z -[ 1 2 1 ] x z -[ 2 0 0 ] A z -[ 2 0 0 ] B z -[ 2 0 1 ] C z -[ 2 0 1 ] D z -[ 2 1 0 ] E z -[ 2 1 0 ] F z -[ 2 1 1 ] G z -[ 2 1 1 ] H z -[ 2 2 0 ] I z -[ 2 2 0 ] J z -[ 2 2 1 ] K z -[ 2 2 1 ] L z -[ 3 0 0 ] M z -[ 3 0 0 ] N z -[ 3 0 1 ] P z -[ 3 0 1 ] Q z -[ 3 1 0 ] R z -[ 3 1 0 ] S z -[ 3 1 1 ] T z -[ 3 1 1 ] U z -[ 3 2 0 ] V z -[ 3 2 0 ] W z -[ 3 2 1 ] X z -[ 3 2 1 ] Z z +[ 0 0 0 ] z a +[ 0 0 0 ] z b +[ 0 0 1 ] z c +[ 0 0 1 ] z d +[ 0 1 0 ] z e +[ 0 1 0 ] z f +[ 0 1 1 ] z g +[ 0 1 1 ] z h +[ 0 2 0 ] z i +[ 0 2 0 ] z j +[ 0 2 1 ] z k +[ 0 2 1 ] z l +[ 1 0 0 ] z m +[ 1 0 0 ] z n +[ 1 0 1 ] z p +[ 1 0 1 ] z q +[ 1 1 0 ] z r +[ 1 1 0 ] z s +[ 1 1 1 ] z t +[ 1 1 1 ] z u +[ 1 2 0 ] z v +[ 1 2 0 ] z w +[ 1 2 1 ] z x +[ 2 0 0 ] z A +[ 2 0 0 ] z B +[ 2 0 1 ] z C +[ 2 0 1 ] z D +[ 2 1 0 ] z E +[ 2 1 0 ] z F +[ 2 1 1 ] z G +[ 2 1 1 ] z H +[ 2 2 0 ] z I +[ 2 2 0 ] z J +[ 2 2 1 ] z K +[ 2 2 1 ] z L +[ 3 0 0 ] z M +[ 3 0 0 ] z N +[ 3 0 1 ] z P +[ 3 0 1 ] z Q +[ 3 1 0 ] z R +[ 3 1 0 ] z S +[ 3 1 1 ] z T +[ 3 1 1 ] z U +[ 3 2 0 ] z V +[ 3 2 0 ] z W +[ 3 2 1 ] z X +[ 3 2 1 ] z Z 47 differences found attribute: > and > size: [2] [2] diff --git a/tools/test/h5diff/testfiles/h5diff_703.txt b/tools/test/h5diff/testfiles/h5diff_703.txt index 405ab2f..33f1a0f 100644 --- a/tools/test/h5diff/testfiles/h5diff_703.txt +++ b/tools/test/h5diff/testfiles/h5diff_703.txt @@ -45,79 +45,79 @@ attribute: > and > size: [2] [2] position VLstring of VLstring of difference ------------------------------------------------------------ -[ 0 ] a z -[ 0 ] b z -[ 1 ] d z -[ 1 ] e z +[ 0 ] z a +[ 0 ] z b +[ 1 ] z d +[ 1 ] z e 4 differences found attribute: > and > size: [3x2] [3x2] position VLstring2D of VLstring2D of difference ------------------------------------------------------------ -[ 0 0 ] a z -[ 0 0 ] b z -[ 0 1 ] c z -[ 0 1 ] d z -[ 1 0 ] e z -[ 1 0 ] f z -[ 1 1 ] g z -[ 1 1 ] h z -[ 2 0 ] i z -[ 2 0 ] j z -[ 2 1 ] k z -[ 2 1 ] l z +[ 0 0 ] z a +[ 0 0 ] z b +[ 0 1 ] z c +[ 0 1 ] z d +[ 1 0 ] z e +[ 1 0 ] z f +[ 1 1 ] z g +[ 1 1 ] z h +[ 2 0 ] z i +[ 2 0 ] z j +[ 2 1 ] z k +[ 2 1 ] z l 12 differences found attribute: > and > size: [4x3x2] [4x3x2] position VLstring3D of VLstring3D of difference ------------------------------------------------------------ -[ 0 0 0 ] a z -[ 0 0 0 ] b z -[ 0 0 1 ] c z -[ 0 0 1 ] d z -[ 0 1 0 ] e z -[ 0 1 0 ] f z -[ 0 1 1 ] g z -[ 0 1 1 ] h z -[ 0 2 0 ] i z -[ 0 2 0 ] j z -[ 0 2 1 ] k z -[ 0 2 1 ] l z -[ 1 0 0 ] m z -[ 1 0 0 ] n z -[ 1 0 1 ] p z -[ 1 0 1 ] q z -[ 1 1 0 ] r z -[ 1 1 0 ] s z -[ 1 1 1 ] t z -[ 1 1 1 ] u z -[ 1 2 0 ] v z -[ 1 2 0 ] w z -[ 1 2 1 ] x z -[ 2 0 0 ] A z -[ 2 0 0 ] B z -[ 2 0 1 ] C z -[ 2 0 1 ] D z -[ 2 1 0 ] E z -[ 2 1 0 ] F z -[ 2 1 1 ] G z -[ 2 1 1 ] H z -[ 2 2 0 ] I z -[ 2 2 0 ] J z -[ 2 2 1 ] K z -[ 2 2 1 ] L z -[ 3 0 0 ] M z -[ 3 0 0 ] N z -[ 3 0 1 ] P z -[ 3 0 1 ] Q z -[ 3 1 0 ] R z -[ 3 1 0 ] S z -[ 3 1 1 ] T z -[ 3 1 1 ] U z -[ 3 2 0 ] V z -[ 3 2 0 ] W z -[ 3 2 1 ] X z -[ 3 2 1 ] Z z +[ 0 0 0 ] z a +[ 0 0 0 ] z b +[ 0 0 1 ] z c +[ 0 0 1 ] z d +[ 0 1 0 ] z e +[ 0 1 0 ] z f +[ 0 1 1 ] z g +[ 0 1 1 ] z h +[ 0 2 0 ] z i +[ 0 2 0 ] z j +[ 0 2 1 ] z k +[ 0 2 1 ] z l +[ 1 0 0 ] z m +[ 1 0 0 ] z n +[ 1 0 1 ] z p +[ 1 0 1 ] z q +[ 1 1 0 ] z r +[ 1 1 0 ] z s +[ 1 1 1 ] z t +[ 1 1 1 ] z u +[ 1 2 0 ] z v +[ 1 2 0 ] z w +[ 1 2 1 ] z x +[ 2 0 0 ] z A +[ 2 0 0 ] z B +[ 2 0 1 ] z C +[ 2 0 1 ] z D +[ 2 1 0 ] z E +[ 2 1 0 ] z F +[ 2 1 1 ] z G +[ 2 1 1 ] z H +[ 2 2 0 ] z I +[ 2 2 0 ] z J +[ 2 2 1 ] z K +[ 2 2 1 ] z L +[ 3 0 0 ] z M +[ 3 0 0 ] z N +[ 3 0 1 ] z P +[ 3 0 1 ] z Q +[ 3 1 0 ] z R +[ 3 1 0 ] z S +[ 3 1 1 ] z T +[ 3 1 1 ] z U +[ 3 2 0 ] z V +[ 3 2 0 ] z W +[ 3 2 1 ] z X +[ 3 2 1 ] z Z 47 differences found attribute: > and > size: [2] [2] @@ -548,79 +548,79 @@ attribute: > and > size: [2] [2] position string of string of difference ------------------------------------------------------------ -[ 0 ] a z -[ 0 ] b z -[ 1 ] d z -[ 1 ] e z +[ 0 ] z a +[ 0 ] z b +[ 1 ] z d +[ 1 ] z e 4 differences found attribute: > and > size: [3x2] [3x2] position string2D of string2D of difference ------------------------------------------------------------ -[ 0 0 ] a z -[ 0 0 ] b z -[ 0 1 ] c z -[ 0 1 ] d z -[ 1 0 ] e z -[ 1 0 ] f z -[ 1 1 ] g z -[ 1 1 ] h z -[ 2 0 ] i z -[ 2 0 ] j z -[ 2 1 ] k z -[ 2 1 ] l z +[ 0 0 ] z a +[ 0 0 ] z b +[ 0 1 ] z c +[ 0 1 ] z d +[ 1 0 ] z e +[ 1 0 ] z f +[ 1 1 ] z g +[ 1 1 ] z h +[ 2 0 ] z i +[ 2 0 ] z j +[ 2 1 ] z k +[ 2 1 ] z l 12 differences found attribute: > and > size: [4x3x2] [4x3x2] position string3D of string3D of difference ------------------------------------------------------------ -[ 0 0 0 ] a z -[ 0 0 0 ] b z -[ 0 0 1 ] c z -[ 0 0 1 ] d z -[ 0 1 0 ] e z -[ 0 1 0 ] f z -[ 0 1 1 ] g z -[ 0 1 1 ] h z -[ 0 2 0 ] i z -[ 0 2 0 ] j z -[ 0 2 1 ] k z -[ 0 2 1 ] l z -[ 1 0 0 ] m z -[ 1 0 0 ] n z -[ 1 0 1 ] p z -[ 1 0 1 ] q z -[ 1 1 0 ] r z -[ 1 1 0 ] s z -[ 1 1 1 ] t z -[ 1 1 1 ] u z -[ 1 2 0 ] v z -[ 1 2 0 ] w z -[ 1 2 1 ] x z -[ 2 0 0 ] A z -[ 2 0 0 ] B z -[ 2 0 1 ] C z -[ 2 0 1 ] D z -[ 2 1 0 ] E z -[ 2 1 0 ] F z -[ 2 1 1 ] G z -[ 2 1 1 ] H z -[ 2 2 0 ] I z -[ 2 2 0 ] J z -[ 2 2 1 ] K z -[ 2 2 1 ] L z -[ 3 0 0 ] M z -[ 3 0 0 ] N z -[ 3 0 1 ] P z -[ 3 0 1 ] Q z -[ 3 1 0 ] R z -[ 3 1 0 ] S z -[ 3 1 1 ] T z -[ 3 1 1 ] U z -[ 3 2 0 ] V z -[ 3 2 0 ] W z -[ 3 2 1 ] X z -[ 3 2 1 ] Z z +[ 0 0 0 ] z a +[ 0 0 0 ] z b +[ 0 0 1 ] z c +[ 0 0 1 ] z d +[ 0 1 0 ] z e +[ 0 1 0 ] z f +[ 0 1 1 ] z g +[ 0 1 1 ] z h +[ 0 2 0 ] z i +[ 0 2 0 ] z j +[ 0 2 1 ] z k +[ 0 2 1 ] z l +[ 1 0 0 ] z m +[ 1 0 0 ] z n +[ 1 0 1 ] z p +[ 1 0 1 ] z q +[ 1 1 0 ] z r +[ 1 1 0 ] z s +[ 1 1 1 ] z t +[ 1 1 1 ] z u +[ 1 2 0 ] z v +[ 1 2 0 ] z w +[ 1 2 1 ] z x +[ 2 0 0 ] z A +[ 2 0 0 ] z B +[ 2 0 1 ] z C +[ 2 0 1 ] z D +[ 2 1 0 ] z E +[ 2 1 0 ] z F +[ 2 1 1 ] z G +[ 2 1 1 ] z H +[ 2 2 0 ] z I +[ 2 2 0 ] z J +[ 2 2 1 ] z K +[ 2 2 1 ] z L +[ 3 0 0 ] z M +[ 3 0 0 ] z N +[ 3 0 1 ] z P +[ 3 0 1 ] z Q +[ 3 1 0 ] z R +[ 3 1 0 ] z S +[ 3 1 1 ] z T +[ 3 1 1 ] z U +[ 3 2 0 ] z V +[ 3 2 0 ] z W +[ 3 2 1 ] z X +[ 3 2 1 ] z Z 47 differences found attribute: > and > size: [2] [2] @@ -754,79 +754,79 @@ attribute: > and > size: [2] [2] position VLstring of VLstring of difference ------------------------------------------------------------ -[ 0 ] a z -[ 0 ] b z -[ 1 ] d z -[ 1 ] e z +[ 0 ] z a +[ 0 ] z b +[ 1 ] z d +[ 1 ] z e 4 differences found attribute: > and > size: [3x2] [3x2] position VLstring2D of VLstring2D of difference ------------------------------------------------------------ -[ 0 0 ] a z -[ 0 0 ] b z -[ 0 1 ] c z -[ 0 1 ] d z -[ 1 0 ] e z -[ 1 0 ] f z -[ 1 1 ] g z -[ 1 1 ] h z -[ 2 0 ] i z -[ 2 0 ] j z -[ 2 1 ] k z -[ 2 1 ] l z +[ 0 0 ] z a +[ 0 0 ] z b +[ 0 1 ] z c +[ 0 1 ] z d +[ 1 0 ] z e +[ 1 0 ] z f +[ 1 1 ] z g +[ 1 1 ] z h +[ 2 0 ] z i +[ 2 0 ] z j +[ 2 1 ] z k +[ 2 1 ] z l 12 differences found attribute: > and > size: [4x3x2] [4x3x2] position VLstring3D of VLstring3D of difference ------------------------------------------------------------ -[ 0 0 0 ] a z -[ 0 0 0 ] b z -[ 0 0 1 ] c z -[ 0 0 1 ] d z -[ 0 1 0 ] e z -[ 0 1 0 ] f z -[ 0 1 1 ] g z -[ 0 1 1 ] h z -[ 0 2 0 ] i z -[ 0 2 0 ] j z -[ 0 2 1 ] k z -[ 0 2 1 ] l z -[ 1 0 0 ] m z -[ 1 0 0 ] n z -[ 1 0 1 ] p z -[ 1 0 1 ] q z -[ 1 1 0 ] r z -[ 1 1 0 ] s z -[ 1 1 1 ] t z -[ 1 1 1 ] u z -[ 1 2 0 ] v z -[ 1 2 0 ] w z -[ 1 2 1 ] x z -[ 2 0 0 ] A z -[ 2 0 0 ] B z -[ 2 0 1 ] C z -[ 2 0 1 ] D z -[ 2 1 0 ] E z -[ 2 1 0 ] F z -[ 2 1 1 ] G z -[ 2 1 1 ] H z -[ 2 2 0 ] I z -[ 2 2 0 ] J z -[ 2 2 1 ] K z -[ 2 2 1 ] L z -[ 3 0 0 ] M z -[ 3 0 0 ] N z -[ 3 0 1 ] P z -[ 3 0 1 ] Q z -[ 3 1 0 ] R z -[ 3 1 0 ] S z -[ 3 1 1 ] T z -[ 3 1 1 ] U z -[ 3 2 0 ] V z -[ 3 2 0 ] W z -[ 3 2 1 ] X z -[ 3 2 1 ] Z z +[ 0 0 0 ] z a +[ 0 0 0 ] z b +[ 0 0 1 ] z c +[ 0 0 1 ] z d +[ 0 1 0 ] z e +[ 0 1 0 ] z f +[ 0 1 1 ] z g +[ 0 1 1 ] z h +[ 0 2 0 ] z i +[ 0 2 0 ] z j +[ 0 2 1 ] z k +[ 0 2 1 ] z l +[ 1 0 0 ] z m +[ 1 0 0 ] z n +[ 1 0 1 ] z p +[ 1 0 1 ] z q +[ 1 1 0 ] z r +[ 1 1 0 ] z s +[ 1 1 1 ] z t +[ 1 1 1 ] z u +[ 1 2 0 ] z v +[ 1 2 0 ] z w +[ 1 2 1 ] z x +[ 2 0 0 ] z A +[ 2 0 0 ] z B +[ 2 0 1 ] z C +[ 2 0 1 ] z D +[ 2 1 0 ] z E +[ 2 1 0 ] z F +[ 2 1 1 ] z G +[ 2 1 1 ] z H +[ 2 2 0 ] z I +[ 2 2 0 ] z J +[ 2 2 1 ] z K +[ 2 2 1 ] z L +[ 3 0 0 ] z M +[ 3 0 0 ] z N +[ 3 0 1 ] z P +[ 3 0 1 ] z Q +[ 3 1 0 ] z R +[ 3 1 0 ] z S +[ 3 1 1 ] z T +[ 3 1 1 ] z U +[ 3 2 0 ] z V +[ 3 2 0 ] z W +[ 3 2 1 ] z X +[ 3 2 1 ] z Z 47 differences found attribute: > and > size: [2] [2] @@ -1263,79 +1263,79 @@ attribute: > and > size: [2] [2] position string of string of difference ------------------------------------------------------------ -[ 0 ] a z -[ 0 ] b z -[ 1 ] d z -[ 1 ] e z +[ 0 ] z a +[ 0 ] z b +[ 1 ] z d +[ 1 ] z e 4 differences found attribute: > and > size: [3x2] [3x2] position string2D of string2D of difference ------------------------------------------------------------ -[ 0 0 ] a z -[ 0 0 ] b z -[ 0 1 ] c z -[ 0 1 ] d z -[ 1 0 ] e z -[ 1 0 ] f z -[ 1 1 ] g z -[ 1 1 ] h z -[ 2 0 ] i z -[ 2 0 ] j z -[ 2 1 ] k z -[ 2 1 ] l z +[ 0 0 ] z a +[ 0 0 ] z b +[ 0 1 ] z c +[ 0 1 ] z d +[ 1 0 ] z e +[ 1 0 ] z f +[ 1 1 ] z g +[ 1 1 ] z h +[ 2 0 ] z i +[ 2 0 ] z j +[ 2 1 ] z k +[ 2 1 ] z l 12 differences found attribute: > and > size: [4x3x2] [4x3x2] position string3D of string3D of difference ------------------------------------------------------------ -[ 0 0 0 ] a z -[ 0 0 0 ] b z -[ 0 0 1 ] c z -[ 0 0 1 ] d z -[ 0 1 0 ] e z -[ 0 1 0 ] f z -[ 0 1 1 ] g z -[ 0 1 1 ] h z -[ 0 2 0 ] i z -[ 0 2 0 ] j z -[ 0 2 1 ] k z -[ 0 2 1 ] l z -[ 1 0 0 ] m z -[ 1 0 0 ] n z -[ 1 0 1 ] p z -[ 1 0 1 ] q z -[ 1 1 0 ] r z -[ 1 1 0 ] s z -[ 1 1 1 ] t z -[ 1 1 1 ] u z -[ 1 2 0 ] v z -[ 1 2 0 ] w z -[ 1 2 1 ] x z -[ 2 0 0 ] A z -[ 2 0 0 ] B z -[ 2 0 1 ] C z -[ 2 0 1 ] D z -[ 2 1 0 ] E z -[ 2 1 0 ] F z -[ 2 1 1 ] G z -[ 2 1 1 ] H z -[ 2 2 0 ] I z -[ 2 2 0 ] J z -[ 2 2 1 ] K z -[ 2 2 1 ] L z -[ 3 0 0 ] M z -[ 3 0 0 ] N z -[ 3 0 1 ] P z -[ 3 0 1 ] Q z -[ 3 1 0 ] R z -[ 3 1 0 ] S z -[ 3 1 1 ] T z -[ 3 1 1 ] U z -[ 3 2 0 ] V z -[ 3 2 0 ] W z -[ 3 2 1 ] X z -[ 3 2 1 ] Z z +[ 0 0 0 ] z a +[ 0 0 0 ] z b +[ 0 0 1 ] z c +[ 0 0 1 ] z d +[ 0 1 0 ] z e +[ 0 1 0 ] z f +[ 0 1 1 ] z g +[ 0 1 1 ] z h +[ 0 2 0 ] z i +[ 0 2 0 ] z j +[ 0 2 1 ] z k +[ 0 2 1 ] z l +[ 1 0 0 ] z m +[ 1 0 0 ] z n +[ 1 0 1 ] z p +[ 1 0 1 ] z q +[ 1 1 0 ] z r +[ 1 1 0 ] z s +[ 1 1 1 ] z t +[ 1 1 1 ] z u +[ 1 2 0 ] z v +[ 1 2 0 ] z w +[ 1 2 1 ] z x +[ 2 0 0 ] z A +[ 2 0 0 ] z B +[ 2 0 1 ] z C +[ 2 0 1 ] z D +[ 2 1 0 ] z E +[ 2 1 0 ] z F +[ 2 1 1 ] z G +[ 2 1 1 ] z H +[ 2 2 0 ] z I +[ 2 2 0 ] z J +[ 2 2 1 ] z K +[ 2 2 1 ] z L +[ 3 0 0 ] z M +[ 3 0 0 ] z N +[ 3 0 1 ] z P +[ 3 0 1 ] z Q +[ 3 1 0 ] z R +[ 3 1 0 ] z S +[ 3 1 1 ] z T +[ 3 1 1 ] z U +[ 3 2 0 ] z V +[ 3 2 0 ] z W +[ 3 2 1 ] z X +[ 3 2 1 ] z Z 47 differences found attribute: > and > size: [2] [2] @@ -1465,79 +1465,79 @@ attribute: > and > size: [2] [2] position VLstring of VLstring of difference ------------------------------------------------------------ -[ 0 ] a z -[ 0 ] b z -[ 1 ] d z -[ 1 ] e z +[ 0 ] z a +[ 0 ] z b +[ 1 ] z d +[ 1 ] z e 4 differences found attribute: > and > size: [3x2] [3x2] position VLstring2D of VLstring2D of difference ------------------------------------------------------------ -[ 0 0 ] a z -[ 0 0 ] b z -[ 0 1 ] c z -[ 0 1 ] d z -[ 1 0 ] e z -[ 1 0 ] f z -[ 1 1 ] g z -[ 1 1 ] h z -[ 2 0 ] i z -[ 2 0 ] j z -[ 2 1 ] k z -[ 2 1 ] l z +[ 0 0 ] z a +[ 0 0 ] z b +[ 0 1 ] z c +[ 0 1 ] z d +[ 1 0 ] z e +[ 1 0 ] z f +[ 1 1 ] z g +[ 1 1 ] z h +[ 2 0 ] z i +[ 2 0 ] z j +[ 2 1 ] z k +[ 2 1 ] z l 12 differences found attribute: > and > size: [4x3x2] [4x3x2] position VLstring3D of VLstring3D of difference ------------------------------------------------------------ -[ 0 0 0 ] a z -[ 0 0 0 ] b z -[ 0 0 1 ] c z -[ 0 0 1 ] d z -[ 0 1 0 ] e z -[ 0 1 0 ] f z -[ 0 1 1 ] g z -[ 0 1 1 ] h z -[ 0 2 0 ] i z -[ 0 2 0 ] j z -[ 0 2 1 ] k z -[ 0 2 1 ] l z -[ 1 0 0 ] m z -[ 1 0 0 ] n z -[ 1 0 1 ] p z -[ 1 0 1 ] q z -[ 1 1 0 ] r z -[ 1 1 0 ] s z -[ 1 1 1 ] t z -[ 1 1 1 ] u z -[ 1 2 0 ] v z -[ 1 2 0 ] w z -[ 1 2 1 ] x z -[ 2 0 0 ] A z -[ 2 0 0 ] B z -[ 2 0 1 ] C z -[ 2 0 1 ] D z -[ 2 1 0 ] E z -[ 2 1 0 ] F z -[ 2 1 1 ] G z -[ 2 1 1 ] H z -[ 2 2 0 ] I z -[ 2 2 0 ] J z -[ 2 2 1 ] K z -[ 2 2 1 ] L z -[ 3 0 0 ] M z -[ 3 0 0 ] N z -[ 3 0 1 ] P z -[ 3 0 1 ] Q z -[ 3 1 0 ] R z -[ 3 1 0 ] S z -[ 3 1 1 ] T z -[ 3 1 1 ] U z -[ 3 2 0 ] V z -[ 3 2 0 ] W z -[ 3 2 1 ] X z -[ 3 2 1 ] Z z +[ 0 0 0 ] z a +[ 0 0 0 ] z b +[ 0 0 1 ] z c +[ 0 0 1 ] z d +[ 0 1 0 ] z e +[ 0 1 0 ] z f +[ 0 1 1 ] z g +[ 0 1 1 ] z h +[ 0 2 0 ] z i +[ 0 2 0 ] z j +[ 0 2 1 ] z k +[ 0 2 1 ] z l +[ 1 0 0 ] z m +[ 1 0 0 ] z n +[ 1 0 1 ] z p +[ 1 0 1 ] z q +[ 1 1 0 ] z r +[ 1 1 0 ] z s +[ 1 1 1 ] z t +[ 1 1 1 ] z u +[ 1 2 0 ] z v +[ 1 2 0 ] z w +[ 1 2 1 ] z x +[ 2 0 0 ] z A +[ 2 0 0 ] z B +[ 2 0 1 ] z C +[ 2 0 1 ] z D +[ 2 1 0 ] z E +[ 2 1 0 ] z F +[ 2 1 1 ] z G +[ 2 1 1 ] z H +[ 2 2 0 ] z I +[ 2 2 0 ] z J +[ 2 2 1 ] z K +[ 2 2 1 ] z L +[ 3 0 0 ] z M +[ 3 0 0 ] z N +[ 3 0 1 ] z P +[ 3 0 1 ] z Q +[ 3 1 0 ] z R +[ 3 1 0 ] z S +[ 3 1 1 ] z T +[ 3 1 1 ] z U +[ 3 2 0 ] z V +[ 3 2 0 ] z W +[ 3 2 1 ] z X +[ 3 2 1 ] z Z 47 differences found attribute: > and > size: [2] [2] @@ -1968,79 +1968,79 @@ attribute: > and > size: [2] [2] position string of string of difference ------------------------------------------------------------ -[ 0 ] a z -[ 0 ] b z -[ 1 ] d z -[ 1 ] e z +[ 0 ] z a +[ 0 ] z b +[ 1 ] z d +[ 1 ] z e 4 differences found attribute: > and > size: [3x2] [3x2] position string2D of string2D of difference ------------------------------------------------------------ -[ 0 0 ] a z -[ 0 0 ] b z -[ 0 1 ] c z -[ 0 1 ] d z -[ 1 0 ] e z -[ 1 0 ] f z -[ 1 1 ] g z -[ 1 1 ] h z -[ 2 0 ] i z -[ 2 0 ] j z -[ 2 1 ] k z -[ 2 1 ] l z +[ 0 0 ] z a +[ 0 0 ] z b +[ 0 1 ] z c +[ 0 1 ] z d +[ 1 0 ] z e +[ 1 0 ] z f +[ 1 1 ] z g +[ 1 1 ] z h +[ 2 0 ] z i +[ 2 0 ] z j +[ 2 1 ] z k +[ 2 1 ] z l 12 differences found attribute: > and > size: [4x3x2] [4x3x2] position string3D of string3D of difference ------------------------------------------------------------ -[ 0 0 0 ] a z -[ 0 0 0 ] b z -[ 0 0 1 ] c z -[ 0 0 1 ] d z -[ 0 1 0 ] e z -[ 0 1 0 ] f z -[ 0 1 1 ] g z -[ 0 1 1 ] h z -[ 0 2 0 ] i z -[ 0 2 0 ] j z -[ 0 2 1 ] k z -[ 0 2 1 ] l z -[ 1 0 0 ] m z -[ 1 0 0 ] n z -[ 1 0 1 ] p z -[ 1 0 1 ] q z -[ 1 1 0 ] r z -[ 1 1 0 ] s z -[ 1 1 1 ] t z -[ 1 1 1 ] u z -[ 1 2 0 ] v z -[ 1 2 0 ] w z -[ 1 2 1 ] x z -[ 2 0 0 ] A z -[ 2 0 0 ] B z -[ 2 0 1 ] C z -[ 2 0 1 ] D z -[ 2 1 0 ] E z -[ 2 1 0 ] F z -[ 2 1 1 ] G z -[ 2 1 1 ] H z -[ 2 2 0 ] I z -[ 2 2 0 ] J z -[ 2 2 1 ] K z -[ 2 2 1 ] L z -[ 3 0 0 ] M z -[ 3 0 0 ] N z -[ 3 0 1 ] P z -[ 3 0 1 ] Q z -[ 3 1 0 ] R z -[ 3 1 0 ] S z -[ 3 1 1 ] T z -[ 3 1 1 ] U z -[ 3 2 0 ] V z -[ 3 2 0 ] W z -[ 3 2 1 ] X z -[ 3 2 1 ] Z z +[ 0 0 0 ] z a +[ 0 0 0 ] z b +[ 0 0 1 ] z c +[ 0 0 1 ] z d +[ 0 1 0 ] z e +[ 0 1 0 ] z f +[ 0 1 1 ] z g +[ 0 1 1 ] z h +[ 0 2 0 ] z i +[ 0 2 0 ] z j +[ 0 2 1 ] z k +[ 0 2 1 ] z l +[ 1 0 0 ] z m +[ 1 0 0 ] z n +[ 1 0 1 ] z p +[ 1 0 1 ] z q +[ 1 1 0 ] z r +[ 1 1 0 ] z s +[ 1 1 1 ] z t +[ 1 1 1 ] z u +[ 1 2 0 ] z v +[ 1 2 0 ] z w +[ 1 2 1 ] z x +[ 2 0 0 ] z A +[ 2 0 0 ] z B +[ 2 0 1 ] z C +[ 2 0 1 ] z D +[ 2 1 0 ] z E +[ 2 1 0 ] z F +[ 2 1 1 ] z G +[ 2 1 1 ] z H +[ 2 2 0 ] z I +[ 2 2 0 ] z J +[ 2 2 1 ] z K +[ 2 2 1 ] z L +[ 3 0 0 ] z M +[ 3 0 0 ] z N +[ 3 0 1 ] z P +[ 3 0 1 ] z Q +[ 3 1 0 ] z R +[ 3 1 0 ] z S +[ 3 1 1 ] z T +[ 3 1 1 ] z U +[ 3 2 0 ] z V +[ 3 2 0 ] z W +[ 3 2 1 ] z X +[ 3 2 1 ] z Z 47 differences found attribute: > and > size: [2] [2] diff --git a/tools/test/h5diff/testfiles/h5diff_80.txt b/tools/test/h5diff/testfiles/h5diff_80.txt index 836e073..b223eed 100644 --- a/tools/test/h5diff/testfiles/h5diff_80.txt +++ b/tools/test/h5diff/testfiles/h5diff_80.txt @@ -59,79 +59,79 @@ dataset: and size: [2] [2] position VLstring VLstring difference ------------------------------------------------------------ -[ 0 ] a z -[ 0 ] b z -[ 1 ] d z -[ 1 ] e z +[ 0 ] z a +[ 0 ] z b +[ 1 ] z d +[ 1 ] z e 4 differences found dataset: and size: [3x2] [3x2] position VLstring2D VLstring2D difference ------------------------------------------------------------ -[ 0 0 ] a z -[ 0 0 ] b z -[ 0 1 ] c z -[ 0 1 ] d z -[ 1 0 ] e z -[ 1 0 ] f z -[ 1 1 ] g z -[ 1 1 ] h z -[ 2 0 ] i z -[ 2 0 ] j z -[ 2 1 ] k z -[ 2 1 ] l z +[ 0 0 ] z a +[ 0 0 ] z b +[ 0 1 ] z c +[ 0 1 ] z d +[ 1 0 ] z e +[ 1 0 ] z f +[ 1 1 ] z g +[ 1 1 ] z h +[ 2 0 ] z i +[ 2 0 ] z j +[ 2 1 ] z k +[ 2 1 ] z l 12 differences found dataset: and size: [4x3x2] [4x3x2] position VLstring3D VLstring3D difference ------------------------------------------------------------ -[ 0 0 0 ] a z -[ 0 0 0 ] b z -[ 0 0 1 ] c z -[ 0 0 1 ] d z -[ 0 1 0 ] e z -[ 0 1 0 ] f z -[ 0 1 1 ] g z -[ 0 1 1 ] h z -[ 0 2 0 ] i z -[ 0 2 0 ] j z -[ 0 2 1 ] k z -[ 0 2 1 ] l z -[ 1 0 0 ] m z -[ 1 0 0 ] n z -[ 1 0 1 ] p z -[ 1 0 1 ] q z -[ 1 1 0 ] r z -[ 1 1 0 ] s z -[ 1 1 1 ] t z -[ 1 1 1 ] u z -[ 1 2 0 ] v z -[ 1 2 0 ] w z -[ 1 2 1 ] x z -[ 2 0 0 ] A z -[ 2 0 0 ] B z -[ 2 0 1 ] C z -[ 2 0 1 ] D z -[ 2 1 0 ] E z -[ 2 1 0 ] F z -[ 2 1 1 ] G z -[ 2 1 1 ] H z -[ 2 2 0 ] I z -[ 2 2 0 ] J z -[ 2 2 1 ] K z -[ 2 2 1 ] L z -[ 3 0 0 ] M z -[ 3 0 0 ] N z -[ 3 0 1 ] P z -[ 3 0 1 ] Q z -[ 3 1 0 ] R z -[ 3 1 0 ] S z -[ 3 1 1 ] T z -[ 3 1 1 ] U z -[ 3 2 0 ] V z -[ 3 2 0 ] W z -[ 3 2 1 ] X z -[ 3 2 1 ] Z z +[ 0 0 0 ] z a +[ 0 0 0 ] z b +[ 0 0 1 ] z c +[ 0 0 1 ] z d +[ 0 1 0 ] z e +[ 0 1 0 ] z f +[ 0 1 1 ] z g +[ 0 1 1 ] z h +[ 0 2 0 ] z i +[ 0 2 0 ] z j +[ 0 2 1 ] z k +[ 0 2 1 ] z l +[ 1 0 0 ] z m +[ 1 0 0 ] z n +[ 1 0 1 ] z p +[ 1 0 1 ] z q +[ 1 1 0 ] z r +[ 1 1 0 ] z s +[ 1 1 1 ] z t +[ 1 1 1 ] z u +[ 1 2 0 ] z v +[ 1 2 0 ] z w +[ 1 2 1 ] z x +[ 2 0 0 ] z A +[ 2 0 0 ] z B +[ 2 0 1 ] z C +[ 2 0 1 ] z D +[ 2 1 0 ] z E +[ 2 1 0 ] z F +[ 2 1 1 ] z G +[ 2 1 1 ] z H +[ 2 2 0 ] z I +[ 2 2 0 ] z J +[ 2 2 1 ] z K +[ 2 2 1 ] z L +[ 3 0 0 ] z M +[ 3 0 0 ] z N +[ 3 0 1 ] z P +[ 3 0 1 ] z Q +[ 3 1 0 ] z R +[ 3 1 0 ] z S +[ 3 1 1 ] z T +[ 3 1 1 ] z U +[ 3 2 0 ] z V +[ 3 2 0 ] z W +[ 3 2 1 ] z X +[ 3 2 1 ] z Z 47 differences found dataset: and size: [2] [2] @@ -702,79 +702,79 @@ dataset: and size: [2] [2] position string string difference ------------------------------------------------------------ -[ 0 ] a z -[ 0 ] b z -[ 1 ] d z -[ 1 ] e z +[ 0 ] z a +[ 0 ] z b +[ 1 ] z d +[ 1 ] z e 4 differences found dataset: and size: [3x2] [3x2] position string2D string2D difference ------------------------------------------------------------ -[ 0 0 ] a z -[ 0 0 ] b z -[ 0 1 ] c z -[ 0 1 ] d z -[ 1 0 ] e z -[ 1 0 ] f z -[ 1 1 ] g z -[ 1 1 ] h z -[ 2 0 ] i z -[ 2 0 ] j z -[ 2 1 ] k z -[ 2 1 ] l z +[ 0 0 ] z a +[ 0 0 ] z b +[ 0 1 ] z c +[ 0 1 ] z d +[ 1 0 ] z e +[ 1 0 ] z f +[ 1 1 ] z g +[ 1 1 ] z h +[ 2 0 ] z i +[ 2 0 ] z j +[ 2 1 ] z k +[ 2 1 ] z l 12 differences found dataset: and size: [4x3x2] [4x3x2] position string3D string3D difference ------------------------------------------------------------ -[ 0 0 0 ] a z -[ 0 0 0 ] b z -[ 0 0 1 ] c z -[ 0 0 1 ] d z -[ 0 1 0 ] e z -[ 0 1 0 ] f z -[ 0 1 1 ] g z -[ 0 1 1 ] h z -[ 0 2 0 ] i z -[ 0 2 0 ] j z -[ 0 2 1 ] k z -[ 0 2 1 ] l z -[ 1 0 0 ] m z -[ 1 0 0 ] n z -[ 1 0 1 ] p z -[ 1 0 1 ] q z -[ 1 1 0 ] r z -[ 1 1 0 ] s z -[ 1 1 1 ] t z -[ 1 1 1 ] u z -[ 1 2 0 ] v z -[ 1 2 0 ] w z -[ 1 2 1 ] x z -[ 2 0 0 ] A z -[ 2 0 0 ] B z -[ 2 0 1 ] C z -[ 2 0 1 ] D z -[ 2 1 0 ] E z -[ 2 1 0 ] F z -[ 2 1 1 ] G z -[ 2 1 1 ] H z -[ 2 2 0 ] I z -[ 2 2 0 ] J z -[ 2 2 1 ] K z -[ 2 2 1 ] L z -[ 3 0 0 ] M z -[ 3 0 0 ] N z -[ 3 0 1 ] P z -[ 3 0 1 ] Q z -[ 3 1 0 ] R z -[ 3 1 0 ] S z -[ 3 1 1 ] T z -[ 3 1 1 ] U z -[ 3 2 0 ] V z -[ 3 2 0 ] W z -[ 3 2 1 ] X z -[ 3 2 1 ] Z z +[ 0 0 0 ] z a +[ 0 0 0 ] z b +[ 0 0 1 ] z c +[ 0 0 1 ] z d +[ 0 1 0 ] z e +[ 0 1 0 ] z f +[ 0 1 1 ] z g +[ 0 1 1 ] z h +[ 0 2 0 ] z i +[ 0 2 0 ] z j +[ 0 2 1 ] z k +[ 0 2 1 ] z l +[ 1 0 0 ] z m +[ 1 0 0 ] z n +[ 1 0 1 ] z p +[ 1 0 1 ] z q +[ 1 1 0 ] z r +[ 1 1 0 ] z s +[ 1 1 1 ] z t +[ 1 1 1 ] z u +[ 1 2 0 ] z v +[ 1 2 0 ] z w +[ 1 2 1 ] z x +[ 2 0 0 ] z A +[ 2 0 0 ] z B +[ 2 0 1 ] z C +[ 2 0 1 ] z D +[ 2 1 0 ] z E +[ 2 1 0 ] z F +[ 2 1 1 ] z G +[ 2 1 1 ] z H +[ 2 2 0 ] z I +[ 2 2 0 ] z J +[ 2 2 1 ] z K +[ 2 2 1 ] z L +[ 3 0 0 ] z M +[ 3 0 0 ] z N +[ 3 0 1 ] z P +[ 3 0 1 ] z Q +[ 3 1 0 ] z R +[ 3 1 0 ] z S +[ 3 1 1 ] z T +[ 3 1 1 ] z U +[ 3 2 0 ] z V +[ 3 2 0 ] z W +[ 3 2 1 ] z X +[ 3 2 1 ] z Z 47 differences found dataset: and size: [2] [2] -- cgit v0.12 From c83e11d436e3fdfa16d6fd196fc2416f798003c3 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Tue, 17 Oct 2017 12:15:02 -0500 Subject: Cleanup valgrind issues --- tools/src/h5repack/h5repack.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/tools/src/h5repack/h5repack.c b/tools/src/h5repack/h5repack.c index d570d02..eaca0a5 100644 --- a/tools/src/h5repack/h5repack.c +++ b/tools/src/h5repack/h5repack.c @@ -332,7 +332,7 @@ int copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_t *travt, pack_opt_t *options) { - int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ + int ret_value = 0; hid_t attr_id = -1; /* attr ID */ hid_t attr_out = -1; /* attr ID */ hid_t space_id = -1; /* space ID */ @@ -486,12 +486,14 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, * close *------------------------------------------------------------------------- */ - if (H5Tclose(ftype_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed"); - if (H5Tclose(wtype_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed"); + if (H5Aclose(attr_out) < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aclose failed"); if (H5Sclose(space_id) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose failed"); + if (H5Tclose(wtype_id) < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed"); + if (H5Tclose(ftype_id) < 0) + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed"); if (H5Aclose(attr_id) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aclose failed"); } /* u */ @@ -508,11 +510,11 @@ done: HDfree(buf); } /* end if */ - H5Tclose(ftype_id); - H5Tclose(wtype_id); + H5Aclose(attr_out); H5Sclose(space_id); + H5Tclose(wtype_id); + H5Tclose(ftype_id); H5Aclose(attr_id); - H5Aclose(attr_out); } H5E_END_TRY; return ret_value; @@ -805,8 +807,8 @@ static int check_objects(const char* fname, pack_opt_t *options) { done: H5E_BEGIN_TRY { - H5Dclose(did); H5Sclose(sid); + H5Dclose(did); H5Fclose(fid); } H5E_END_TRY; if (travt) -- cgit v0.12 From d9bfebc1db91f7313df179661ccadbcca277fc91 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Tue, 17 Oct 2017 12:23:05 -0500 Subject: Correct test results --- tools/test/h5diff/CMakeTests.cmake | 16 ++++++++-------- tools/test/h5diff/testfiles/h5diff_467.txt | 2 +- tools/test/h5diff/testfiles/h5diff_469.txt | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tools/test/h5diff/CMakeTests.cmake b/tools/test/h5diff/CMakeTests.cmake index d87a47f..165c29a 100644 --- a/tools/test/h5diff/CMakeTests.cmake +++ b/tools/test/h5diff/CMakeTests.cmake @@ -1441,22 +1441,22 @@ ADD_H5_TEST (h5diff_415 1 --follow-symlinks -v ${FILE14} ${FILE14} /softlink3_to ADD_H5_TEST (h5diff_416 0 --follow-symlinks -v ${FILE14} ${FILE14} /softlink3_to_slink2 /softlink4_to_slink2) # non-exist-softlink vs softlink" -ADD_H5_TEST (h5diff_417 1 --follow-symlinks -v ${FILE13} ${FILE13} /softlink_noexist /softlink_dset2) +ADD_H5_TEST (h5diff_417 2 --follow-symlinks -v ${FILE13} ${FILE13} /softlink_noexist /softlink_dset2) # softlink vs non-exist-softlink" -ADD_H5_TEST (h5diff_418 1 --follow-symlinks -v ${FILE13} ${FILE13} /softlink_dset2 /softlink_noexist) +ADD_H5_TEST (h5diff_418 2 --follow-symlinks -v ${FILE13} ${FILE13} /softlink_dset2 /softlink_noexist) # non-exist-extlink_file vs extlink" -ADD_H5_TEST (h5diff_419 1 --follow-symlinks -v ${FILE15} ${FILE15} /ext_link_noexist2 /ext_link_dset2) +ADD_H5_TEST (h5diff_419 2 --follow-symlinks -v ${FILE15} ${FILE15} /ext_link_noexist2 /ext_link_dset2) # exlink vs non-exist-extlink_file" -ADD_H5_TEST (h5diff_420 1 --follow-symlinks -v ${FILE15} ${FILE15} /ext_link_dset2 /ext_link_noexist2) +ADD_H5_TEST (h5diff_420 2 --follow-symlinks -v ${FILE15} ${FILE15} /ext_link_dset2 /ext_link_noexist2) # extlink vs non-exist-extlink_obj" -ADD_H5_TEST (h5diff_421 1 --follow-symlinks -v ${FILE15} ${FILE15} /ext_link_dset2 /ext_link_noexist1) +ADD_H5_TEST (h5diff_421 2 --follow-symlinks -v ${FILE15} ${FILE15} /ext_link_dset2 /ext_link_noexist1) # non-exist-extlink_obj vs extlink" -ADD_H5_TEST (h5diff_422 1 --follow-symlinks -v ${FILE15} ${FILE15} /ext_link_noexist1 /ext_link_dset2) +ADD_H5_TEST (h5diff_422 2 --follow-symlinks -v ${FILE15} ${FILE15} /ext_link_noexist1 /ext_link_dset2) # extlink_to_softlink_to_dset1 vs dset2" ADD_H5_TEST (h5diff_423 1 --follow-symlinks -v ${FILE17} ${FILE18} /ext_link_to_slink1 /dset2) @@ -1512,11 +1512,11 @@ ADD_H5_TEST (h5diff_465 0 --follow-symlinks h5diff_danglelinks1.h5 h5diff_dangle # soft dangling vs. soft dangling ADD_H5_TEST (h5diff_466 0 -v --follow-symlinks h5diff_danglelinks1.h5 h5diff_danglelinks2.h5 /soft_link1) # soft link vs. soft dangling -ADD_H5_TEST (h5diff_467 1 -v --follow-symlinks h5diff_danglelinks1.h5 h5diff_danglelinks2.h5 /soft_link2) +ADD_H5_TEST (h5diff_467 2 -v --follow-symlinks h5diff_danglelinks1.h5 h5diff_danglelinks2.h5 /soft_link2) # ext dangling vs. ext dangling ADD_H5_TEST (h5diff_468 0 -v --follow-symlinks h5diff_danglelinks1.h5 h5diff_danglelinks2.h5 /ext_link4) # ext link vs. ext dangling -ADD_H5_TEST (h5diff_469 1 -v --follow-symlinks h5diff_danglelinks1.h5 h5diff_danglelinks2.h5 /ext_link2) +ADD_H5_TEST (h5diff_469 2 -v --follow-symlinks h5diff_danglelinks1.h5 h5diff_danglelinks2.h5 /ext_link2) #--------------------------------------------------- # dangling links without follow symlink diff --git a/tools/test/h5diff/testfiles/h5diff_467.txt b/tools/test/h5diff/testfiles/h5diff_467.txt index f5195c0..35d3b74 100644 --- a/tools/test/h5diff/testfiles/h5diff_467.txt +++ b/tools/test/h5diff/testfiles/h5diff_467.txt @@ -1,3 +1,3 @@ obj2 is a dangling link. 1 differences found -EXIT CODE: 1 +EXIT CODE: 2 diff --git a/tools/test/h5diff/testfiles/h5diff_469.txt b/tools/test/h5diff/testfiles/h5diff_469.txt index 594fd80..23cb62f 100644 --- a/tools/test/h5diff/testfiles/h5diff_469.txt +++ b/tools/test/h5diff/testfiles/h5diff_469.txt @@ -1,3 +1,3 @@ obj2 is a dangling link. 1 differences found -EXIT CODE: 1 +EXIT CODE: 2 -- cgit v0.12 From c230ffa26873f256092d68de854de5c7f09bf1ee Mon Sep 17 00:00:00 2001 From: "Richard.Warren" Date: Tue, 17 Oct 2017 15:23:54 -0500 Subject: Make fixes to avoid test failures in 'production' mode builds --- testpar/t_pread.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/testpar/t_pread.c b/testpar/t_pread.c index 7f23b9b..b2eec97 100644 --- a/testpar/t_pread.c +++ b/testpar/t_pread.c @@ -99,11 +99,11 @@ generate_test_file( MPI_Comm comm, int mpi_rank, int group_id ) FILE *header = NULL; const char *fcn_name = "generate_test_file()"; const char *failure_mssg = NULL; - const char *group_filename = NULL; + char *group_filename = NULL; char data_filename[FILENAME_BUF_SIZE]; char reloc_data_filename[FILENAME_BUF_SIZE]; char prolog_filename[FILENAME_BUF_SIZE]; - int file_index; + int file_index = 0; int group_size; int group_rank; int local_failure = 0; @@ -162,10 +162,11 @@ generate_test_file( MPI_Comm comm, int mpi_rank, int group_id ) * is used to call into the h5_fixname function. No * need to worry that we reassign it for each file! */ - HDassert((group_filename = FILENAMES[file_index])); + group_filename = FILENAMES[file_index]; + HDassert( group_filename ); /* Assign the 'data_filename' */ - if ( h5_fixname(group_filename, H5P_DEFAULT, data_filename, + if ( h5_fixname((const char *)group_filename, H5P_DEFAULT, data_filename, sizeof(data_filename)) == NULL ) { pass = FALSE; failure_mssg = "h5_fixname(0) failed.\n"; @@ -174,7 +175,8 @@ generate_test_file( MPI_Comm comm, int mpi_rank, int group_id ) if ( pass ) { - HDassert( (group_filename = FILENAMES[file_index+1]) ); + group_filename = FILENAMES[file_index+1]; + HDassert( group_filename ); /* Assign the 'reloc_data_filename' */ if ( h5_fixname(group_filename, H5P_DEFAULT, reloc_data_filename, @@ -186,8 +188,8 @@ generate_test_file( MPI_Comm comm, int mpi_rank, int group_id ) } if ( pass ) { - - HDassert( (group_filename = FILENAMES[file_index+2]) ); + group_filename = FILENAMES[file_index+2]; + HDassert( group_filename ); /* Assign the 'prolog_filename' */ if ( h5_fixname(group_filename, H5P_DEFAULT, prolog_filename, -- cgit v0.12 From 9aada2bdb51f1c235e483f2bce109262bfbe22fa Mon Sep 17 00:00:00 2001 From: "Richard.Warren" Date: Tue, 17 Oct 2017 15:34:36 -0500 Subject: in 'production' mode builds --- testpar/t_pread.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testpar/t_pread.c b/testpar/t_pread.c index b2eec97..b5a84f2 100644 --- a/testpar/t_pread.c +++ b/testpar/t_pread.c @@ -162,11 +162,11 @@ generate_test_file( MPI_Comm comm, int mpi_rank, int group_id ) * is used to call into the h5_fixname function. No * need to worry that we reassign it for each file! */ - group_filename = FILENAMES[file_index]; + group_filename = FILENAMES[file_index]; HDassert( group_filename ); /* Assign the 'data_filename' */ - if ( h5_fixname((const char *)group_filename, H5P_DEFAULT, data_filename, + if ( h5_fixname(group_filename, H5P_DEFAULT, data_filename, sizeof(data_filename)) == NULL ) { pass = FALSE; failure_mssg = "h5_fixname(0) failed.\n"; -- cgit v0.12 From 78a5870680770a8827c0e1e805688be30d1a33a7 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Tue, 17 Oct 2017 16:13:12 -0500 Subject: Fix error handling issues --- tools/lib/h5diff.c | 157 ++++++++++++-------------- tools/lib/h5diff_array.c | 111 ++++++++++-------- tools/lib/h5diff_attr.c | 103 +++++++++-------- tools/lib/h5diff_dset.c | 85 +++++++------- tools/test/h5diff/CMakeTests.cmake | 18 +-- tools/test/h5diff/testfiles/h5diff_417.txt | 2 +- tools/test/h5diff/testfiles/h5diff_418.txt | 2 +- tools/test/h5diff/testfiles/h5diff_419.txt | 2 +- tools/test/h5diff/testfiles/h5diff_420.txt | 2 +- tools/test/h5diff/testfiles/h5diff_421.txt | 2 +- tools/test/h5diff/testfiles/h5diff_422.txt | 2 +- tools/test/h5diff/testfiles/h5diff_467.txt | 2 +- tools/test/h5diff/testfiles/h5diff_469.txt | 2 +- tools/test/h5diff/testfiles/h5diff_udfail.txt | 12 +- 14 files changed, 261 insertions(+), 241 deletions(-) diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c index ab5d125..94cca58 100644 --- a/tools/lib/h5diff.c +++ b/tools/lib/h5diff.c @@ -393,8 +393,7 @@ trav_grp_objs(const char *path, const H5O_info_t *oinfo, * Track and extra checkings while visiting all symbolic-links. *------------------------------------------------------------------------*/ static herr_t -trav_grp_symlinks(const char *path, const H5L_info_t *linfo, - void *udata) +trav_grp_symlinks(const char *path, const H5L_info_t *linfo, void *udata) { herr_t ret_value = 0; trav_info_t *tinfo = (trav_info_t *)udata; @@ -414,7 +413,7 @@ trav_grp_symlinks(const char *path, const H5L_info_t *linfo, switch(linfo->type) { case H5L_TYPE_SOFT: if((ret_value = H5tools_get_symlink_info(tinfo->fid, path, &lnk_info, opts->follow_links)) < 0) { - HGOTO_DONE(ret_value); + HGOTO_DONE(FAIL); } else if (ret_value == 0) { /* no dangling link option given and detect dangling link */ @@ -437,13 +436,13 @@ trav_grp_symlinks(const char *path, const H5L_info_t *linfo, trav_grp_objs,trav_grp_symlinks, tinfo) < 0) { parallel_print("Error: Could not get file contents\n"); opts->err_stat = 1; - HGOTO_ERROR(opts->err_stat, H5E_tools_min_id_g, "Error: Could not get file contents"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Error: Could not get file contents"); } break; case H5L_TYPE_EXTERNAL: if ((ret_value = H5tools_get_symlink_info(tinfo->fid, path, &lnk_info, opts->follow_links)) < 0) { - HGOTO_DONE(ret_value); + HGOTO_DONE(FAIL); } else if (ret_value == 0) { /* no dangling link option given and detect dangling link */ @@ -469,7 +468,7 @@ trav_grp_symlinks(const char *path, const H5L_info_t *linfo, trav_grp_objs,trav_grp_symlinks, tinfo) < 0) { parallel_print("Error: Could not get file contents\n"); opts->err_stat = 1; - HGOTO_ERROR(opts->err_stat, H5E_tools_min_id_g, "Error: Could not get file contents\n"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Error: Could not get file contents\n"); } break; @@ -479,7 +478,7 @@ trav_grp_symlinks(const char *path, const H5L_info_t *linfo, default: parallel_print("Error: Invalid link type\n"); opts->err_stat = 1; - HGOTO_ERROR(opts->err_stat, H5E_tools_min_id_g, "Error: Invalid link type"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Error: Invalid link type"); break; } /* end of switch */ @@ -552,7 +551,7 @@ h5diff(const char *fname1, HGOTO_DONE(0); opts->cmn_objs = 1; /* eliminate warning */ - opts->err_stat = 1; /* initialize error status to FAIL */ + opts->err_stat = 0; /* initialize error status */ /*------------------------------------------------------------------------- * open the files first; if they are not valid, no point in continuing @@ -561,14 +560,14 @@ h5diff(const char *fname1, /* open file 1 */ if((file1_id = h5tools_fopen(fname1, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t)0)) < 0) { parallel_print("h5diff: <%s>: unable to open file\n", fname1); - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "<%s>: unable to open file\n", fname1); + HGOTO_ERROR(1, H5E_tools_min_id_g, "<%s>: unable to open file\n", fname1); } /* end if */ /* open file 2 */ if((file2_id = h5tools_fopen(fname2, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t)0)) < 0) { parallel_print("h5diff: <%s>: unable to open file\n", fname2); - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "<%s>: unable to open file\n", fname2); + HGOTO_ERROR(1, H5E_tools_min_id_g, "<%s>: unable to open file\n", fname2); } /* end if */ /*------------------------------------------------------------------------- @@ -586,11 +585,11 @@ h5diff(const char *fname1, #ifdef H5_HAVE_ASPRINTF /* Use the asprintf() routine, since it does what we're trying to do below */ if(HDasprintf(&obj1fullname, "/%s", objname1) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "name buffer allocation failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "name buffer allocation failed"); #else /* H5_HAVE_ASPRINTF */ /* (malloc 2 more for "/" and end-of-line) */ if ((obj1fullname = (char*)HDmalloc(HDstrlen(objname1) + 2)) == NULL) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "name buffer allocation failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "name buffer allocation failed"); HDstrcpy(obj1fullname, "/"); HDstrcat(obj1fullname, objname1); @@ -604,11 +603,11 @@ h5diff(const char *fname1, #ifdef H5_HAVE_ASPRINTF /* Use the asprintf() routine, since it does what we're trying to do below */ if(HDasprintf(&obj2fullname, "/%s", objname2) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "name buffer allocation failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "name buffer allocation failed"); #else /* H5_HAVE_ASPRINTF */ /* (malloc 2 more for "/" and end-of-line) */ if ((obj2fullname = (char*)HDmalloc(HDstrlen(objname2) + 2)) == NULL) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "name buffer allocation failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "name buffer allocation failed"); HDstrcpy(obj2fullname, "/"); HDstrcat(obj2fullname, objname2); #endif /* H5_HAVE_ASPRINTF */ @@ -627,14 +626,12 @@ h5diff(const char *fname1, /* check if link itself exist */ if(H5Lexists(file1_id, obj1fullname, H5P_DEFAULT) <= 0) { parallel_print ("Object <%s> could not be found in <%s>\n", obj1fullname, fname1); - opts->err_stat = 1; - HGOTO_ERROR(opts->err_stat, H5E_tools_min_id_g, "Error: Object could not be found"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "Error: Object could not be found"); } /* get info from link */ if(H5Lget_info(file1_id, obj1fullname, &src_linfo1, H5P_DEFAULT) < 0) { parallel_print("Unable to get link info from <%s>\n", obj1fullname); - H5TOOLS_INFO(H5E_tools_min_id_g, "Unable to get link info\n"); - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Lget_info failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Lget_info failed"); } info1_lp = info1_obj; @@ -650,8 +647,7 @@ h5diff(const char *fname1, if(H5Oget_info_by_name(file1_id, obj1fullname, &oinfo1, H5P_DEFAULT) < 0) { parallel_print("Error: Could not get file contents\n"); - opts->err_stat = 1; - HGOTO_ERROR(opts->err_stat, H5E_tools_min_id_g, "Error: Could not get file contents"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "Error: Could not get file contents"); } obj1type = (h5trav_type_t)oinfo1.type; trav_info_add(info1_obj, obj1fullname, obj1type); @@ -680,13 +676,12 @@ h5diff(const char *fname1, /* check if link itself exist */ if(H5Lexists(file2_id, obj2fullname, H5P_DEFAULT) <= 0) { parallel_print ("Object <%s> could not be found in <%s>\n", obj2fullname, fname2); - opts->err_stat = 1; - HGOTO_ERROR(opts->err_stat, H5E_tools_min_id_g, "Error: Object could not be found"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "Error: Object could not be found"); } /* get info from link */ if(H5Lget_info(file2_id, obj2fullname, &src_linfo2, H5P_DEFAULT) < 0) { parallel_print("Unable to get link info from <%s>\n", obj2fullname); - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Lget_info failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Lget_info failed"); } info2_lp = info2_obj; @@ -702,8 +697,7 @@ h5diff(const char *fname1, if(H5Oget_info_by_name(file2_id, obj2fullname, &oinfo2, H5P_DEFAULT) < 0) { parallel_print("Error: Could not get file contents\n"); - opts->err_stat = 1; - HGOTO_ERROR(opts->err_stat, H5E_tools_min_id_g, "Error: Could not get file contents"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "Error: Could not get file contents"); } obj2type = (h5trav_type_t)oinfo2.type; trav_info_add(info2_obj, obj2fullname, obj2type); @@ -731,7 +725,7 @@ h5diff(const char *fname1, obj2type = H5TRAV_TYPE_GROUP; } - + h5diffdebug2("get any symbolic links info - errstat:%d\n", opts->err_stat); /* get any symbolic links info */ l_ret1 = H5tools_get_symlink_info(file1_id, obj1fullname, &trg_linfo1, opts->follow_links); l_ret2 = H5tools_get_symlink_info(file2_id, obj2fullname, &trg_linfo2, opts->follow_links); @@ -755,8 +749,7 @@ h5diff(const char *fname1, /* treat dangling link as error */ if(opts->m_verbose) parallel_print("Warning: <%s> is a dangling link.\n", obj1fullname); - opts->err_stat = 1; - HGOTO_ERROR(opts->err_stat, H5E_tools_min_id_g, "treat dangling link as error"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "treat dangling link as error"); } else { if(opts->m_verbose) @@ -770,8 +763,7 @@ h5diff(const char *fname1, } else if(l_ret1 < 0) { /* fail */ parallel_print ("Object <%s> could not be found in <%s>\n", obj1fullname, fname1); - opts->err_stat = 1; - HGOTO_ERROR(opts->err_stat, H5E_tools_min_id_g, "Object could not be found"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "Object could not be found"); } else if(l_ret1 != 2) { /* symbolic link */ obj1type = (h5trav_type_t)trg_linfo1.trg_type; @@ -798,8 +790,7 @@ h5diff(const char *fname1, /* treat dangling link as error */ if(opts->m_verbose) parallel_print("Warning: <%s> is a dangling link.\n", obj2fullname); - opts->err_stat = 1; - HGOTO_ERROR(opts->err_stat, H5E_tools_min_id_g, "treat dangling link as error"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "treat dangling link as error"); } else { if(opts->m_verbose) @@ -813,8 +804,7 @@ h5diff(const char *fname1, } else if(l_ret2 < 0) { /* fail */ parallel_print ("Object <%s> could not be found in <%s>\n", obj2fullname, fname2); - opts->err_stat = 1; - HGOTO_ERROR(opts->err_stat, H5E_tools_min_id_g, "Object could not be found"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "Object could not be found"); } else if(l_ret2 != 2) { /* symbolic link */ obj2type = (h5trav_type_t)trg_linfo2.trg_type; @@ -841,7 +831,7 @@ h5diff(const char *fname1, h5difftrace("h5diff NOT (opts->m_verbose || opts->m_report)\n"); /* if no danglink links */ if (l_ret1 > 0 && l_ret2 > 0) - if (h5tools_is_obj_same(file1_id, obj1fullname, file2_id, obj2fullname)!=0) + if (h5tools_is_obj_same(file1_id, obj1fullname, file2_id, obj2fullname) != 0) HGOTO_DONE(0); } @@ -858,8 +848,7 @@ h5diff(const char *fname1, if(h5trav_visit(file1_id, obj1fullname, TRUE, TRUE, trav_grp_objs, trav_grp_symlinks, info1_grp) < 0) { parallel_print("Error: Could not get file contents\n"); - opts->err_stat = 1; - HGOTO_ERROR(opts->err_stat, H5E_tools_min_id_g, "Could not get file contents"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "Could not get file contents"); } info1_lp = info1_grp; @@ -873,11 +862,11 @@ h5diff(const char *fname1, if(h5trav_visit(file2_id, obj2fullname, TRUE, TRUE, trav_grp_objs, trav_grp_symlinks, info2_grp) < 0) { parallel_print("Error: Could not get file contents\n"); - opts->err_stat = 1; - HGOTO_ERROR(opts->err_stat, H5E_tools_min_id_g, "Could not get file contents"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "Could not get file contents"); } /* end if */ info2_lp = info2_grp; } + h5diffdebug2("groups traversed - errstat:%d\n", opts->err_stat); #ifdef H5_HAVE_PARALLEL if(g_Parallel) { @@ -926,9 +915,9 @@ h5diff(const char *fname1, file2_id, obj2fullname, info2_lp, match_list, opts); - opts->err_stat = 0; /* success status */ - done: + opts->err_stat = opts->err_stat | ret_value; + #ifdef H5_HAVE_PARALLEL if(g_Parallel) /* All done at this point, let tasks know that they won't be needed */ @@ -994,7 +983,7 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, { hsize_t nfound = 0; unsigned i; - int ret_value = 0; + int ret_value = opts->err_stat; const char *grp1_path = ""; const char *grp2_path = ""; char *obj1_fullpath = NULL; @@ -1056,16 +1045,17 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, #endif for(i = 0; i < table->nobjs; i++) { + h5diffdebug3("diff for common objects[%d] - errstat:%d\n", i, opts->err_stat); if(table->objs[i].flags[0] && table->objs[i].flags[1]) { /* make full path for obj1 */ #ifdef H5_HAVE_ASPRINTF /* Use the asprintf() routine, since it does what we're trying to do below */ if(HDasprintf(&obj1_fullpath, "%s%s", grp1_path, table->objs[i].name) < 0) { - HERROR(FAIL, H5E_tools_min_id_g, "name buffer allocation failed"); + HERROR(1, H5E_tools_min_id_g, "name buffer allocation failed"); } #else /* H5_HAVE_ASPRINTF */ if((obj1_fullpath = (char*)HDmalloc(HDstrlen(grp1_path) + HDstrlen(table->objs[i].name) + 1)) == NULL) { - HERROR(FAIL, H5E_tools_min_id_g, "name buffer allocation failed"); + HERROR(1, H5E_tools_min_id_g, "name buffer allocation failed"); } else { HDstrcpy(obj1_fullpath, grp1_path); @@ -1078,11 +1068,11 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, #ifdef H5_HAVE_ASPRINTF /* Use the asprintf() routine, since it does what we're trying to do below */ if(HDasprintf(&obj2_fullpath, "%s%s", grp2_path, table->objs[i].name) < 0) { - HERROR(FAIL, H5E_tools_min_id_g, "name buffer allocation failed"); + HERROR(1, H5E_tools_min_id_g, "name buffer allocation failed"); } #else /* H5_HAVE_ASPRINTF */ if((obj2_fullpath = (char*)HDmalloc(HDstrlen(grp2_path) + HDstrlen(table->objs[i].name) + 1)) == NULL) { - HERROR(FAIL, H5E_tools_min_id_g, "name buffer allocation failed"); + HERROR(1, H5E_tools_min_id_g, "name buffer allocation failed"); } else { HDstrcpy(obj2_fullpath, grp2_path); @@ -1267,7 +1257,7 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, HDfree(obj2_fullpath); } /* end if */ } /* end for */ - h5difftrace("done with for loop\n"); + h5diffdebug2("done with for loop - errstat:%d\n", opts->err_stat); #ifdef H5_HAVE_PARALLEL if(g_Parallel) { @@ -1351,7 +1341,9 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, #endif /* H5_HAVE_PARALLEL */ out: - /* free table */ + opts->err_stat = opts->err_stat | ret_value; + +/* free table */ if (table) trav_table_free(table); h5diffdebug2("diff_match finish:%d\n", nfound); @@ -1381,7 +1373,8 @@ diff(hid_t file1_id, diff_opt_t * opts, diff_args_t *argdata) { - int ret_value = 0; + int ret_value = opts->err_stat; + int status = -1; hid_t dset1_id = -1; hid_t dset2_id = -1; hid_t type1_id = -1; @@ -1400,9 +1393,6 @@ diff(hid_t file1_id, h5difftrace("diff start\n"); - /*init error status */ - opts->err_stat = 1; - /*init link info struct */ HDmemset(&linkinfo1, 0, sizeof(h5tool_link_info_t)); HDmemset(&linkinfo2, 0, sizeof(h5tool_link_info_t)); @@ -1422,26 +1412,26 @@ diff(hid_t file1_id, */ /* target object1 - get type and name */ - if ((ret_value = H5tools_get_symlink_info(file1_id, path1, &linkinfo1, opts->follow_links)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5tools_get_symlink_info failed"); + if ((status = H5tools_get_symlink_info(file1_id, path1, &linkinfo1, opts->follow_links)) < 0) + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5tools_get_symlink_info failed"); /* dangling link */ - if (ret_value == 0) { + if (status == 0) { if (opts->no_dangle_links) { /* dangling link is error */ if(opts->m_verbose) parallel_print("Warning: <%s> is a dangling link.\n", path1); - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "dangling link is error"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "dangling link is error"); } else is_dangle_link1 = TRUE; } /* target object2 - get type and name */ - if ((ret_value = H5tools_get_symlink_info(file2_id, path2, &linkinfo2, opts->follow_links)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5tools_get_symlink_info failed"); + if ((status = H5tools_get_symlink_info(file2_id, path2, &linkinfo2, opts->follow_links)) < 0) + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5tools_get_symlink_info failed"); /* dangling link */ - if (ret_value == 0) { + if (status == 0) { if (opts->no_dangle_links) { /* dangling link is error */ if(opts->m_verbose) @@ -1454,7 +1444,6 @@ diff(hid_t file1_id, /* found dangling link */ if (is_dangle_link1 || is_dangle_link2) { - opts->err_stat = 0; HGOTO_DONE(0); } @@ -1479,7 +1468,6 @@ diff(hid_t file1_id, /* TODO: will need to update non-comparable is different * opts->contents = 0; */ - opts->err_stat = 0; HGOTO_DONE(0); } else /* now both object types are same */ @@ -1532,7 +1520,6 @@ diff(hid_t file1_id, } /* if(opts->m_verbose || opts->m_report) */ /* exact same, so comparison is done */ - opts->err_stat = 0; HGOTO_DONE(0); } } @@ -1544,9 +1531,9 @@ diff(hid_t file1_id, */ case H5TRAV_TYPE_DATASET: if((dset1_id = H5Dopen2(file1_id, path1, H5P_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dopen2 failed"); if((dset2_id = H5Dopen2(file2_id, path2, H5P_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dopen2 failed"); /* verbose (-v) and report (-r) mode */ if(opts->m_verbose || opts->m_report) { do_print_objname("dataset", path1, path2, opts); @@ -1579,9 +1566,9 @@ diff(hid_t file1_id, if(H5Dclose(dset1_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dclose failed"); if(H5Dclose(dset2_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dclose failed"); break; /*---------------------------------------------------------------------- @@ -1590,15 +1577,15 @@ diff(hid_t file1_id, */ case H5TRAV_TYPE_NAMED_DATATYPE: if((type1_id = H5Topen2(file1_id, path1, H5P_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Topen2 failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Topen2 failed"); if((type2_id = H5Topen2(file2_id, path2, H5P_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Topen2 failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Topen2 failed"); - if((ret_value = H5Tequal(type1_id, type2_id)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tequal failed"); + if((status = H5Tequal(type1_id, type2_id)) < 0) + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tequal failed"); /* if H5Tequal is > 0 then the datatypes refer to the same datatype */ - nfound = (ret_value > 0) ? 0 : 1; + nfound = (status > 0) ? 0 : 1; if(print_objname(opts, nfound)) do_print_objname("datatype", path1, path2, opts); @@ -1617,9 +1604,9 @@ diff(hid_t file1_id, nfound += diff_attr(type1_id, type2_id, path1, path2, opts); if(H5Tclose(type1_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose failed"); if(H5Tclose(type2_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose failed"); break; /*---------------------------------------------------------------------- @@ -1635,9 +1622,9 @@ diff(hid_t file1_id, print_found(nfound); if((grp1_id = H5Gopen2(file1_id, path1, H5P_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gclose failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Gclose failed"); if((grp2_id = H5Gopen2(file2_id, path2, H5P_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gclose failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Gclose failed"); /*----------------------------------------------------------------- * compare attributes @@ -1649,9 +1636,9 @@ diff(hid_t file1_id, nfound += diff_attr(grp1_id, grp2_id, path1, path2, opts); if(H5Gclose(grp1_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gclose failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Gclose failed"); if(H5Gclose(grp2_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gclose failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Gclose failed"); break; @@ -1661,10 +1648,10 @@ diff(hid_t file1_id, */ case H5TRAV_TYPE_LINK: { - ret_value = HDstrcmp(linkinfo1.trg_path, linkinfo2.trg_path); + status = HDstrcmp(linkinfo1.trg_path, linkinfo2.trg_path); /* if the target link name is not same then the links are "different" */ - nfound = (ret_value != 0) ? 1 : 0; + nfound = (status != 0) ? 1 : 0; if(print_objname(opts, nfound)) do_print_objname("link", path1, path2, opts); @@ -1686,16 +1673,16 @@ diff(hid_t file1_id, if(linkinfo1.linfo.type == H5L_TYPE_EXTERNAL && linkinfo2.linfo.type == H5L_TYPE_EXTERNAL) { /* If the buffers are the same size, compare them */ if(linkinfo1.linfo.u.val_size == linkinfo2.linfo.u.val_size) { - ret_value = HDmemcmp(linkinfo1.trg_path, linkinfo2.trg_path, linkinfo1.linfo.u.val_size); + status = HDmemcmp(linkinfo1.trg_path, linkinfo2.trg_path, linkinfo1.linfo.u.val_size); } else - ret_value = 1; + status = 1; /* if "linkinfo1.trg_path" != "linkinfo2.trg_path" then the links * are "different" extlinkinfo#.path is combination string of * file_name and obj_name */ - nfound = (ret_value != 0) ? 1 : 0; + nfound = (status != 0) ? 1 : 0; if(print_objname(opts, nfound)) do_print_objname("external link", path1, path2, opts); @@ -1734,9 +1721,9 @@ diff(hid_t file1_id, break; } - opts->err_stat = 0; - done: + opts->err_stat = opts->err_stat | ret_value; + /*----------------------------------- * handle dangling link(s) */ @@ -1782,7 +1769,7 @@ done: /* enable error reporting */ } H5E_END_TRY; - h5diffdebug2("diff finish:%d\n", nfound); + h5diffdebug3("diff finish:%d - errstat:%d\n", nfound, opts->err_stat); return nfound; } diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c index 5d77de3..54b9109 100644 --- a/tools/lib/h5diff_array.c +++ b/tools/lib/h5diff_array.c @@ -285,7 +285,7 @@ hsize_t diff_array( mcomp_t members; H5T_class_t type_class; - h5difftrace("diff_array start\n"); + h5diffdebug2("diff_array start - errstat:%d\n", opts->err_stat); /* get the size. */ size = H5Tget_size(m_type); type_class = H5Tget_class(m_type); @@ -378,7 +378,7 @@ hsize_t diff_array( } /* i */ close_member_types(&members); } /* switch */ - h5diffdebug2("diff_array finish:%d\n", nfound); + h5diffdebug3("diff_array finish:%d - errstat:%d\n", nfound, opts->err_stat); return nfound; } @@ -447,13 +447,11 @@ static hsize_t diff_datum( hbool_t iszero1; hbool_t iszero2; hsize_t nfound = 0; /* differences found */ - hsize_t ret_value = 0; + hsize_t ret_value = opts->err_stat; double per; hbool_t both_zero; h5difftrace("diff_datum start\n"); - /* default error sttaus */ - opts->err_stat = 1; type_size = H5Tget_size(m_type); type_class = H5Tget_class(m_type); @@ -467,14 +465,14 @@ static hsize_t diff_datum( type_class != H5T_STRING && type_class != H5T_VLEN && HDmemcmp(mem1, mem2, type_size) == 0) - HGOTO_DONE(0); + HGOTO_DONE(opts->err_stat); switch (H5Tget_class(m_type)) { case H5T_NO_CLASS: case H5T_TIME: case H5T_NCLASSES: default: - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Invalid type class"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "Invalid type class"); break; /*------------------------------------------------------------------------- @@ -725,7 +723,8 @@ static hsize_t diff_datum( iszero1 = all_zero(_mem1, H5Tget_size(m_type)); iszero2 = all_zero(_mem2, H5Tget_size(m_type)); if (iszero1 != iszero2) { - HGOTO_DONE (1); + nfound++; + HGOTO_DONE (opts->err_stat); } else if (!iszero1 && !iszero2) { /*------------------------------------------------------------------------- @@ -740,14 +739,22 @@ static hsize_t diff_datum( hid_t region1_id = -1; hid_t region2_id = -1; - if ((obj1_id = H5Rdereference2(container1_id, H5P_DEFAULT, H5R_DATASET_REGION, _mem1)) < 0) - HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rdereference2 object 1 failed"); - if ((obj2_id = H5Rdereference2(container2_id, H5P_DEFAULT, H5R_DATASET_REGION, _mem2)) < 0) - HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rdereference2 object 2 failed"); - if ((region1_id = H5Rget_region(container1_id, H5R_DATASET_REGION, _mem1)) < 0) - HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rget_region object 1 failed"); - if ((region2_id = H5Rget_region(container2_id, H5R_DATASET_REGION, _mem2)) < 0) - HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rget_region object 2 failed"); + if ((obj1_id = H5Rdereference2(container1_id, H5P_DEFAULT, H5R_DATASET_REGION, _mem1)) < 0) { + opts->err_stat = 1; + H5TOOLS_INFO(H5E_tools_min_id_g, "H5Rdereference2 object 1 failed"); + } + if ((obj2_id = H5Rdereference2(container2_id, H5P_DEFAULT, H5R_DATASET_REGION, _mem2)) < 0) { + opts->err_stat = 1; + H5TOOLS_INFO(H5E_tools_min_id_g, "H5Rdereference2 object 2 failed"); + } + if ((region1_id = H5Rget_region(container1_id, H5R_DATASET_REGION, _mem1)) < 0) { + opts->err_stat = 1; + H5TOOLS_INFO(H5E_tools_min_id_g, "H5Rget_region object 1 failed"); + } + if ((region2_id = H5Rget_region(container2_id, H5R_DATASET_REGION, _mem2)) < 0) { + opts->err_stat = 1; + H5TOOLS_INFO(H5E_tools_min_id_g, "H5Rget_region object 2 failed"); + } nfound = diff_region(obj1_id, obj2_id, region1_id, region2_id, opts); @@ -766,23 +773,31 @@ static hsize_t diff_datum( H5O_type_t obj1_type; H5O_type_t obj2_type; - if (H5Rget_obj_type2(container1_id, H5R_OBJECT, _mem1, &obj1_type) < 0) - HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rget_obj_type2 object 1 failed"); - if (H5Rget_obj_type2(container2_id, H5R_OBJECT, _mem2, &obj2_type) < 0) - HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rget_obj_type2 object 2 failed"); + if (H5Rget_obj_type2(container1_id, H5R_OBJECT, _mem1, &obj1_type) < 0) { + opts->err_stat = 1; + H5TOOLS_INFO(H5E_tools_min_id_g, "H5Rget_obj_type2 object 1 failed"); + } + if (H5Rget_obj_type2(container2_id, H5R_OBJECT, _mem2, &obj2_type) < 0) { + opts->err_stat = 1; + H5TOOLS_INFO(H5E_tools_min_id_g, "H5Rget_obj_type2 object 2 failed"); + } /* check object type */ if (ret_value >= 0) if (obj1_type != obj2_type) { parallel_print("Different object types referenced: <%s> and <%s>", obj1, obj2); opts->not_cmp = 1; - HGOTO_DONE (0); + HGOTO_DONE (opts->err_stat); } - if ((obj1_id = H5Rdereference2(container1_id, H5P_DEFAULT, H5R_OBJECT, _mem1)) < 0) - HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rdereference2 object 1 failed"); - if ((obj2_id = H5Rdereference2(container2_id, H5P_DEFAULT, H5R_OBJECT, _mem2)) < 0) - HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rdereference2 object 2 failed"); + if ((obj1_id = H5Rdereference2(container1_id, H5P_DEFAULT, H5R_OBJECT, _mem1)) < 0) { + opts->err_stat = 1; + H5TOOLS_INFO(H5E_tools_min_id_g, "H5Rdereference2 object 1 failed"); + } + if ((obj2_id = H5Rdereference2(container2_id, H5P_DEFAULT, H5R_OBJECT, _mem2)) < 0) { + opts->err_stat = 1; + H5TOOLS_INFO(H5E_tools_min_id_g, "H5Rdereference2 object 2 failed"); + } /* compare */ if (obj1_type == H5O_TYPE_DATASET) @@ -839,7 +854,7 @@ static hsize_t diff_datum( char temp2_char; if(type_size != sizeof(char)) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Type size is not char size"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not char size"); HDmemcpy(&temp1_char, mem1, sizeof(char)); HDmemcpy(&temp2_char, mem2, sizeof(char)); /* -d and !-p */ @@ -914,7 +929,7 @@ static hsize_t diff_datum( unsigned char temp2_uchar; if(type_size != sizeof(unsigned char)) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Type size is not unsigned char size"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not unsigned char size"); HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char)); HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char)); @@ -990,7 +1005,7 @@ static hsize_t diff_datum( short temp2_short; if(type_size != sizeof(short)) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Type size is not short size"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not short size"); HDmemcpy(&temp1_short, mem1, sizeof(short)); HDmemcpy(&temp2_short, mem2, sizeof(short)); @@ -1066,7 +1081,7 @@ static hsize_t diff_datum( unsigned short temp2_ushort; if(type_size != sizeof(unsigned short)) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Type size is not unsigned short size"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not unsigned short size"); HDmemcpy(&temp1_ushort, mem1, sizeof(unsigned short)); HDmemcpy(&temp2_ushort, mem2, sizeof(unsigned short)); @@ -1142,7 +1157,7 @@ static hsize_t diff_datum( int temp2_int; if(type_size != sizeof(int)) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Type size is not int size"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not int size"); HDmemcpy(&temp1_int, mem1, sizeof(int)); HDmemcpy(&temp2_int, mem2, sizeof(int)); @@ -1218,7 +1233,7 @@ static hsize_t diff_datum( unsigned int temp2_uint; if(type_size != sizeof(unsigned int)) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Type size is not unsigned int size"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not unsigned int size"); HDmemcpy(&temp1_uint, mem1, sizeof(unsigned int)); HDmemcpy(&temp2_uint, mem2, sizeof(unsigned int)); @@ -1294,7 +1309,7 @@ static hsize_t diff_datum( long temp2_long; if(type_size != sizeof(long)) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Type size is not long size"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not long size"); HDmemcpy(&temp1_long, mem1, sizeof(long)); HDmemcpy(&temp2_long, mem2, sizeof(long)); @@ -1370,7 +1385,7 @@ static hsize_t diff_datum( unsigned long temp2_ulong; if(type_size != sizeof(unsigned long)) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Type size is not unsigned long size"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not unsigned long size"); HDmemcpy(&temp1_ulong, mem1, sizeof(unsigned long)); HDmemcpy(&temp2_ulong, mem2, sizeof(unsigned long)); @@ -1454,7 +1469,7 @@ static hsize_t diff_datum( hbool_t isnan2 = FALSE; if(type_size != sizeof(float)) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Type size is not float size"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not float size"); HDmemcpy(&temp1_float, mem1, sizeof(float)); HDmemcpy(&temp2_float, mem2, sizeof(float)); @@ -1613,7 +1628,7 @@ static hsize_t diff_datum( hbool_t isnan2 = FALSE; if(type_size != sizeof(double)) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Type size is not double size"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not double size"); HDmemcpy(&temp1_double, mem1, sizeof(double)); HDmemcpy(&temp2_double, mem2, sizeof(double)); @@ -1771,8 +1786,9 @@ static hsize_t diff_datum( hbool_t isnan1 = FALSE; hbool_t isnan2 = FALSE; - if(type_size != sizeof(long double)) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Type size is not long double size"); + if(type_size != sizeof(long double)) { + HGOTO_ERROR(1, H5E_tools_min_id_g, "Type size is not long double size"); + } HDmemcpy(&temp1_double, mem1, sizeof(long double)); HDmemcpy(&temp2_double, mem2, sizeof(long double)); @@ -1922,10 +1938,11 @@ static hsize_t diff_datum( break; /* H5T_FLOAT class */ } /* switch */ - opts->err_stat = 0; done: - h5diffdebug2("diff_datum finish:%d\n", nfound); + opts->err_stat = opts->err_stat | ret_value; + + h5diffdebug3("diff_datum finish:%d - errstat:%d\n", nfound, opts->err_stat); return nfound; } @@ -2003,7 +2020,7 @@ void print_points(int i, hsize_t *ptdata, int ndims) { static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t region2_id, diff_opt_t *opts) { - hsize_t ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ + hsize_t ret_value = 0; hssize_t nblocks1, npoints1; hssize_t nblocks2, npoints2; hsize_t alloc_size; @@ -2046,14 +2063,16 @@ static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t HDassert(alloc_size == (hsize_t)((size_t )alloc_size)); /*check for overflow*/ if((ptdata1 = (hsize_t *) HDmalloc((size_t )alloc_size)) == NULL) { - HERROR(H5E_tools_g, H5E_tools_min_id_g, "Buffer allocation failed"); + opts->err_stat = 1; + H5TOOLS_INFO(H5E_tools_min_id_g, "Buffer allocation failed"); } else { H5_CHECK_OVERFLOW(nblocks1, hssize_t, hsize_t); H5Sget_select_hyper_blocklist(region1_id, (hsize_t) 0, (hsize_t) nblocks1, ptdata1); if((ptdata2 = (hsize_t *) HDmalloc((size_t )alloc_size)) == NULL) { - HERROR(H5E_tools_g, H5E_tools_min_id_g, "Buffer allocation failed"); + opts->err_stat = 1; + H5TOOLS_INFO(H5E_tools_min_id_g, "Buffer allocation failed"); } else { H5_CHECK_OVERFLOW(nblocks2, hssize_t, hsize_t); @@ -2107,14 +2126,16 @@ static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t HDassert(alloc_size == (hsize_t)((size_t )alloc_size)); /*check for overflow*/ if((ptdata1 = (hsize_t *) HDmalloc((size_t )alloc_size)) == NULL) { - HERROR(H5E_tools_g, H5E_tools_min_id_g, "Buffer allocation failed"); + opts->err_stat = 1; + H5TOOLS_INFO(H5E_tools_min_id_g, "Buffer allocation failed"); } else { H5_CHECK_OVERFLOW(npoints1, hssize_t, hsize_t); H5Sget_select_elem_pointlist(region1_id, (hsize_t) 0, (hsize_t) npoints1, ptdata1); if((ptdata2 = (hsize_t *) HDmalloc((size_t )alloc_size)) == NULL) { - HERROR(H5E_tools_g, H5E_tools_min_id_g, "Buffer allocation failed"); + opts->err_stat = 1; + H5TOOLS_INFO(H5E_tools_min_id_g, "Buffer allocation failed"); } else { H5_CHECK_OVERFLOW(npoints1, hssize_t, hsize_t); @@ -4380,7 +4401,7 @@ static hbool_t equal_float(float value, float expected, diff_opt_t *opts) { return TRUE; if (opts->use_system_epsilon) - if ( ABS( (value-expected) ) < FLT_EPSILON) + if (ABS( (value-expected) ) < FLT_EPSILON) return TRUE; h5difftrace("equal_float finish\n"); diff --git a/tools/lib/h5diff_attr.c b/tools/lib/h5diff_attr.c index d671449..6019738 100644 --- a/tools/lib/h5diff_attr.c +++ b/tools/lib/h5diff_attr.c @@ -139,7 +139,7 @@ static void table_attr_mark_exist(unsigned *exist, char *name, table_attrs_t *ta *------------------------------------------------------------------------*/ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t ** table_out, diff_opt_t *opts) { - int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ + int ret_value = 0; H5O_info_t oinfo1, oinfo2; /* Object info */ hid_t attr1_id = -1; /* attr ID */ hid_t attr2_id = -1; /* attr ID */ @@ -163,12 +163,13 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t if (table_lp == NULL) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Table allocation failed"); - h5diffdebug3("build_match_list_attrs: %ld - %ld\n", curr1 < oinfo1.num_attrs, curr2 < oinfo2.num_attrs); - /*-------------------------------------------------- * build the list */ while(curr1 < oinfo1.num_attrs && curr2 < oinfo2.num_attrs) { + h5diffdebug3("build_match_list_attrs 1: %ld - %ld\n", curr1, oinfo1.num_attrs); + h5diffdebug3("build_match_list_attrs 2: %ld - %ld\n", curr2, oinfo2.num_attrs); + /*------------------ * open attribute1 */ if((attr1_id = H5Aopen_by_idx(loc1_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)curr1, H5P_DEFAULT, H5P_DEFAULT)) < 0) @@ -221,6 +222,8 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t infile[0] = 1; infile[1] = 0; while(curr1 < oinfo1.num_attrs) { + h5diffdebug3("build_match_list_attrs 1: %ld - %ld\n", curr1, oinfo1.num_attrs); + /*------------------ * open attribute1 */ if((attr1_id = H5Aopen_by_idx(loc1_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)curr1, H5P_DEFAULT, H5P_DEFAULT)) < 0) @@ -243,6 +246,7 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t infile[0] = 0; infile[1] = 1; while(curr2 < oinfo2.num_attrs) { + h5diffdebug3("build_match_list_attrs 2: %ld - %ld\n", curr2, oinfo2.num_attrs); /*------------------ * open attribute2 */ if((attr2_id = H5Aopen_by_idx(loc2_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)curr2, H5P_DEFAULT, H5P_DEFAULT)) < 0) @@ -290,7 +294,7 @@ done: H5Aclose(attr2_id); } H5E_END_TRY; - h5difftrace("build_match_list_attrs end\n"); + h5diffdebug2("build_match_list_attrs end - errstat:%d\n", opts->err_stat); return ret_value; } @@ -314,7 +318,7 @@ hsize_t diff_attr(hid_t loc1_id, const char *path2, diff_opt_t *opts) { - int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ + int ret_value = opts->err_stat; hid_t attr1_id = -1; /* attr ID */ hid_t attr2_id = -1; /* attr ID */ hid_t space1_id = -1; /* space ID */ @@ -348,11 +352,10 @@ hsize_t diff_attr(hid_t loc1_id, table_attrs_t *match_list_attrs = NULL; h5difftrace("diff_attr start\n"); - /* Initialize error status */ - opts->err_stat = 1; - - if(build_match_list_attrs(loc1_id, loc2_id, &match_list_attrs, opts) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "build_match_list_attrs failed"); + if(build_match_list_attrs(loc1_id, loc2_id, &match_list_attrs, opts) < 0) { + HGOTO_ERROR(1, H5E_tools_min_id_g, "build_match_list_attrs failed"); + } + h5diffdebug2("build_match_list_attrs - errstat:%d\n", opts->err_stat); /* if detect any unique extra attr */ if(match_list_attrs->nattrs_only1 || match_list_attrs->nattrs_only2) { @@ -360,8 +363,10 @@ hsize_t diff_attr(hid_t loc1_id, /* exit will be 1 */ opts->contents = 0; } + h5diffdebug2("match_list_attrs info - errstat:%d\n", opts->err_stat); for(u = 0; u < (unsigned)match_list_attrs->nattrs; u++) { + h5diffdebug3("match_list_attrs loop[%d] - errstat:%d\n", u, opts->err_stat); if((match_list_attrs->attrs[u].exist[0]) && (match_list_attrs->attrs[u].exist[1])) { name1 = name2 = match_list_attrs->attrs[u].name; h5diffdebug2("diff_attr name - %s\n", name1); @@ -369,20 +374,20 @@ hsize_t diff_attr(hid_t loc1_id, /*-------------- * attribute 1 */ if((attr1_id = H5Aopen(loc1_id, name1, H5P_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aopen first attribute failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aopen first attribute failed"); /*-------------- * attribute 2 */ if((attr2_id = H5Aopen(loc2_id, name2, H5P_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aopen second attribute failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aopen second attribute failed"); h5difftrace("diff_attr got attributes\n"); /* get the datatypes */ if((ftype1_id = H5Aget_type(attr1_id)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_type first attribute failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type first attribute failed"); vstrtype1 = H5Tis_variable_str(ftype1_id); if((ftype2_id = H5Aget_type(attr2_id)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_type second attribute failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type second attribute failed"); vstrtype2 = H5Tis_variable_str(ftype2_id); /* no compare if either one but not both are variable string type */ @@ -392,37 +397,37 @@ hsize_t diff_attr(hid_t loc1_id, path1, name1, path2, name2); opts->not_cmp = 1; if (H5Tclose(ftype1_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose first attribute ftype failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose first attribute ftype failed"); if (H5Tclose(ftype2_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose second attribute ftype failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose second attribute ftype failed"); if (H5Aclose(attr1_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aclose first attribute failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aclose first attribute failed"); if (H5Aclose(attr2_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aclose second attribute failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aclose second attribute failed"); continue; } if((mtype1_id = H5Tget_native_type(ftype1_id, H5T_DIR_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_native_type first attribute ftype failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tget_native_type first attribute ftype failed"); if((mtype2_id = H5Tget_native_type(ftype2_id, H5T_DIR_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_native_type second attribute ftype failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tget_native_type second attribute ftype failed"); if((msize1 = H5Tget_size(mtype1_id)) == 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_size first attribute mtype failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tget_size first attribute mtype failed"); if((msize2 = H5Tget_size(mtype2_id)) == 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_size second attribute mtype failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tget_size second attribute mtype failed"); /* get the dataspace */ if((space1_id = H5Aget_space(attr1_id)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_space first attribute failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_space first attribute failed"); if((space2_id = H5Aget_space(attr2_id)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_space second attribute failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_space second attribute failed"); /* get dimensions */ if((rank1 = H5Sget_simple_extent_dims(space1_id, dims1, NULL)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims first attribute failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Sget_simple_extent_dims first attribute failed"); if((rank2 = H5Sget_simple_extent_dims(space2_id, dims2, NULL)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims second attribute failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Sget_simple_extent_dims second attribute failed"); /*---------------------------------------------------------------------- * check for comparable TYPE and SPACE @@ -434,21 +439,21 @@ hsize_t diff_attr(hid_t loc1_id, if(diff_can_type(ftype1_id, ftype2_id, rank1, rank2, dims1, dims2, dims1, dims2, name1, name2, opts, 0) != 1) { if(H5Tclose(ftype1_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose first attribute ftype failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose first attribute ftype failed"); if(H5Tclose(ftype2_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose second attribute ftype failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose second attribute ftype failed"); if(H5Sclose(space1_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose first attribute failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Sclose first attribute failed"); if(H5Sclose(space2_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose second attribute failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Sclose second attribute failed"); if(H5Aclose(attr1_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aclose first attribute failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aclose first attribute failed"); if(H5Aclose(attr2_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aclose second attribute failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aclose second attribute failed"); if(H5Tclose(mtype1_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose first attribute mtype failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose first attribute mtype failed"); if(H5Tclose(mtype2_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose second attribute mtype failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose second attribute mtype failed"); continue; } @@ -459,7 +464,7 @@ hsize_t diff_attr(hid_t loc1_id, */ if(FAIL == match_up_memsize(ftype1_id, ftype2_id, &mtype1_id, &mtype2_id, &msize1, &msize2)) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "match_up_memsize failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "match_up_memsize failed"); /*--------------------------------------------------------------------- * read @@ -473,18 +478,18 @@ hsize_t diff_attr(hid_t loc1_id, buf2 = (void *)HDcalloc((size_t)(nelmts1), msize2); if(buf1 == NULL || buf2 == NULL) { parallel_print("cannot read into memory\n"); - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "buffer allocation failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "buffer allocation failed"); } if(H5Aread(attr1_id, mtype1_id, buf1) < 0) { parallel_print("Failed reading attribute1 %s/%s\n", path1, name1); - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_type first attribute failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type first attribute failed"); } else buf1hasdata = TRUE; if(H5Aread(attr2_id, mtype2_id, buf2) < 0) { parallel_print("Failed reading attribute2 %s/%s\n", path2, name2); - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_type second attribute failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type second attribute failed"); } else buf2hasdata = TRUE; @@ -542,29 +547,29 @@ hsize_t diff_attr(hid_t loc1_id, buf2 = NULL; if(H5Tclose(ftype1_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_type first attribute failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type first attribute failed"); if(H5Tclose(ftype2_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_type second attribute failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type second attribute failed"); if(H5Sclose(space1_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_type first attribute failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type first attribute failed"); if(H5Sclose(space2_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_type second attribute failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type second attribute failed"); if(H5Aclose(attr1_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_type first attribute failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type first attribute failed"); if(H5Aclose(attr2_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_type second attribute failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type second attribute failed"); if(H5Tclose(mtype1_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose first attribute mtype failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose first attribute mtype failed"); if(H5Tclose(mtype2_id) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose second attribute mtype failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose second attribute mtype failed"); nfound_total += nfound; } } /* u */ - opts->err_stat = 0; - done: + opts->err_stat = opts->err_stat | ret_value; + H5E_BEGIN_TRY { if(buf1) { if(buf1hasdata && TRUE == h5tools_detect_vlen(mtype1_id)) @@ -589,7 +594,7 @@ done: H5Aclose(attr2_id); } H5E_END_TRY; - h5difftrace("diff_attr end\n"); + h5diffdebug2("diff_attr end - errstat:%d\n", opts->err_stat); return nfound_total; } diff --git a/tools/lib/h5diff_dset.c b/tools/lib/h5diff_dset.c index 768caff..bea008c 100644 --- a/tools/lib/h5diff_dset.c +++ b/tools/lib/h5diff_dset.c @@ -33,7 +33,8 @@ hsize_t diff_dataset(hid_t file1_id, const char *obj2_name, diff_opt_t *opts) { - int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ + int ret_value = opts->err_stat; + int status = -1; hid_t did1 = -1; hid_t did2 = -1; hid_t dcpl1 = -1; @@ -41,7 +42,6 @@ hsize_t diff_dataset(hid_t file1_id, hsize_t nfound = 0; h5difftrace("diff_dataset start\n"); - opts->err_stat = 1; /*------------------------------------------------------------------------- * open the handles *------------------------------------------------------------------------- @@ -49,17 +49,17 @@ hsize_t diff_dataset(hid_t file1_id, /* Open the datasets */ if((did1 = H5Dopen2(file1_id, obj1_name, H5P_DEFAULT)) < 0) { parallel_print("Cannot open dataset <%s>\n", obj1_name); - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 first dataset failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dopen2 first dataset failed"); } if((did2 = H5Dopen2(file2_id, obj2_name, H5P_DEFAULT)) < 0) { parallel_print("Cannot open dataset <%s>\n", obj2_name); - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 second dataset failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dopen2 second dataset failed"); } if((dcpl1 = H5Dget_create_plist(did1)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist first dataset failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dget_create_plist first dataset failed"); if((dcpl2 = H5Dget_create_plist(did2)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist second dataset failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dget_create_plist second dataset failed"); /*------------------------------------------------------------------------- * check if the dataset creation property list has filters that @@ -68,18 +68,18 @@ hsize_t diff_dataset(hid_t file1_id, * 2) the internal filters might be turned off *------------------------------------------------------------------------- */ - if ((ret_value = h5tools_canreadf((opts->m_verbose ? obj1_name : NULL), dcpl1) == 1) && - (ret_value = h5tools_canreadf((opts->m_verbose ? obj2_name : NULL), dcpl2) == 1)) + if ((status = h5tools_canreadf((opts->m_verbose ? obj1_name : NULL), dcpl1) == 1) && + (status = h5tools_canreadf((opts->m_verbose ? obj2_name : NULL), dcpl2) == 1)) nfound = diff_datasetid(did1, did2, obj1_name, obj2_name, opts); - else if (ret_value < 0) { - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5tools_canreadf failed"); + else if (status < 0) { + HGOTO_ERROR(1, H5E_tools_min_id_g, "h5tools_canreadf failed"); } else opts->not_cmp = 1; - opts->err_stat = 0; - done: + opts->err_stat = opts->err_stat | ret_value; + /* disable error reporting */ H5E_BEGIN_TRY { H5Pclose(dcpl1); @@ -89,7 +89,7 @@ done: /* enable error reporting */ } H5E_END_TRY; - h5diffdebug2("diff_dataset finish:%d\n", nfound); + h5diffdebug3("diff_dataset finish:%d - errstat:%d\n", nfound, opts->err_stat); return nfound; } @@ -150,7 +150,7 @@ hsize_t diff_datasetid(hid_t did1, const char *obj2_name, diff_opt_t *opts) { - int ret_value = 0; /* no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ + int ret_value = opts->err_stat; hid_t sid1 = -1; hid_t sid2 = -1; hid_t f_tid1 = -1; @@ -192,27 +192,26 @@ hsize_t diff_datasetid(hid_t did1, int i; unsigned int vl_data = 0; /*contains VL datatypes */ - opts->err_stat = 1; h5difftrace("diff_datasetid start\n"); /* Get the dataspace handle */ if((sid1 = H5Dget_space(did1)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dget_space failed"); /* Get rank */ if((rank1 = H5Sget_simple_extent_ndims(sid1)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed"); /* Get the dataspace handle */ if((sid2 = H5Dget_space(did2)) < 0 ) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dget_space failed"); /* Get rank */ if((rank2 = H5Sget_simple_extent_ndims(sid2)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed"); /* Get dimensions */ if(H5Sget_simple_extent_dims(sid1, dims1, maxdim1) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed"); /* Get dimensions */ if(H5Sget_simple_extent_dims(sid2, dims2, maxdim2) < 0) @@ -226,25 +225,25 @@ hsize_t diff_datasetid(hid_t did1, /* Get the data type */ if((f_tid1 = H5Dget_type(did1)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_type failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dget_type failed"); /* Get the data type */ if((f_tid2 = H5Dget_type(did2)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_type failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dget_type failed"); /*------------------------------------------------------------------------- * get the storage layout type *------------------------------------------------------------------------- */ if((dcpl1 = H5Dget_create_plist(did1)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dget_create_plist failed"); if((dcpl2 = H5Dget_create_plist(did2)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dget_create_plist failed"); if((stl1 = H5Pget_layout(dcpl1)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_layout failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Pget_layout failed"); if((stl2 = H5Pget_layout(dcpl2)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_layout failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Pget_layout failed"); /*------------------------------------------------------------------------- * check for empty datasets @@ -278,6 +277,7 @@ hsize_t diff_datasetid(hid_t did1, obj1_name, obj2_name, opts, 0) != 1) can_compare = 0; + h5diffdebug2("diff_can_type - errstat:%d\n", opts->err_stat); /*------------------------------------------------------------------------- * memory type and sizes @@ -285,10 +285,10 @@ hsize_t diff_datasetid(hid_t did1, */ h5difftrace("check for memory type and sizes\n"); if((m_tid1 = H5Tget_native_type(f_tid1, H5T_DIR_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_native_type failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tget_native_type failed"); if((m_tid2 = H5Tget_native_type(f_tid2, H5T_DIR_DEFAULT)) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_native_type failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Tget_native_type failed"); m_size1 = H5Tget_size(m_tid1); m_size2 = H5Tget_size(m_tid2); @@ -319,6 +319,7 @@ hsize_t diff_datasetid(hid_t did1, */ if(TRUE == h5tools_detect_vlen(m_tid1)) vl_data = TRUE; + h5diffdebug2("h5tools_detect_vlen - errstat:%d\n", opts->err_stat); /*------------------------------------------------------------------------ * only attempt to compare if possible @@ -351,7 +352,7 @@ hsize_t diff_datasetid(hid_t did1, if (FAIL == match_up_memsize (f_tid1, f_tid2, &m_tid1, &m_tid2, &m_size1, &m_size2)) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "match_up_memsize failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "match_up_memsize failed"); h5diffdebug3("m_size: %ld - %ld\n", m_size1, m_size2); dadims = dims1; dam_size = m_size1; @@ -397,10 +398,10 @@ hsize_t diff_datasetid(hid_t did1, if(buf1 != NULL && buf2 != NULL) { h5difftrace("buf1 != NULL && buf2 != NULL\n"); if(H5Dread(did1, m_tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf1) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dread failed"); h5difftrace("H5Dread did2\n"); if(H5Dread(did2, m_tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dread failed"); /* array diff */ nfound = diff_array(buf1, buf2, danelmts, (hsize_t)0, rank1, dadims, @@ -463,9 +464,9 @@ hsize_t diff_datasetid(hid_t did1, * E.g., sm_space. */ if((sm_buf1 = HDmalloc((size_t)sm_nbytes)) == NULL) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDmalloc failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "HDmalloc failed"); if((sm_buf2 = HDmalloc((size_t)sm_nbytes)) == NULL) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDmalloc failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "HDmalloc failed"); sm_nelmts = sm_nbytes / p_type_nbytes; sm_space = H5Screate_simple(1, &sm_nelmts, NULL); @@ -482,19 +483,19 @@ hsize_t diff_datasetid(hid_t did1, hs_nelmts *= hs_size[i]; } /* end for */ if(H5Sselect_hyperslab(sid1, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sselect_hyperslab failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Sselect_hyperslab failed"); if(H5Sselect_hyperslab(sid2, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sselect_hyperslab failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Sselect_hyperslab failed"); if(H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &hs_nelmts, NULL) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sselect_hyperslab failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Sselect_hyperslab failed"); } /* end if */ else hs_nelmts = 1; if(H5Dread(did1, m_tid1, sm_space, sid1, H5P_DEFAULT, sm_buf1) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dread failed"); if(H5Dread(did2, m_tid2, sm_space, sid2, H5P_DEFAULT, sm_buf2) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed"); + HGOTO_ERROR(1, H5E_tools_min_id_g, "H5Dread failed"); /* get array differences. in the case of hyperslab read, increment the number of differences found in each hyperslab and pass the position at the beginning for printing */ @@ -534,11 +535,10 @@ hsize_t diff_datasetid(hid_t did1, * close *------------------------------------------------------------------------- */ - h5difftrace("reclaim any VL memory\n"); + h5diffdebug2("reclaim any VL memory - errstat:%d\n", opts->err_stat); done: - - opts->err_stat = ret_value; + opts->err_stat = opts->err_stat | ret_value; /* free */ if(buf1 != NULL) { @@ -802,6 +802,9 @@ int diff_can_type(hid_t f_tid1, /* file data type */ } } done: + if (ret_value < 0) + opts->err_stat = 1; + h5diffdebug2("diff_can_type end - %d\n", ret_value); return ret_value; } diff --git a/tools/test/h5diff/CMakeTests.cmake b/tools/test/h5diff/CMakeTests.cmake index 165c29a..b5dd820 100644 --- a/tools/test/h5diff/CMakeTests.cmake +++ b/tools/test/h5diff/CMakeTests.cmake @@ -1441,22 +1441,22 @@ ADD_H5_TEST (h5diff_415 1 --follow-symlinks -v ${FILE14} ${FILE14} /softlink3_to ADD_H5_TEST (h5diff_416 0 --follow-symlinks -v ${FILE14} ${FILE14} /softlink3_to_slink2 /softlink4_to_slink2) # non-exist-softlink vs softlink" -ADD_H5_TEST (h5diff_417 2 --follow-symlinks -v ${FILE13} ${FILE13} /softlink_noexist /softlink_dset2) +ADD_H5_TEST (h5diff_417 1 --follow-symlinks -v ${FILE13} ${FILE13} /softlink_noexist /softlink_dset2) # softlink vs non-exist-softlink" -ADD_H5_TEST (h5diff_418 2 --follow-symlinks -v ${FILE13} ${FILE13} /softlink_dset2 /softlink_noexist) +ADD_H5_TEST (h5diff_418 1 --follow-symlinks -v ${FILE13} ${FILE13} /softlink_dset2 /softlink_noexist) # non-exist-extlink_file vs extlink" -ADD_H5_TEST (h5diff_419 2 --follow-symlinks -v ${FILE15} ${FILE15} /ext_link_noexist2 /ext_link_dset2) +ADD_H5_TEST (h5diff_419 1 --follow-symlinks -v ${FILE15} ${FILE15} /ext_link_noexist2 /ext_link_dset2) # exlink vs non-exist-extlink_file" -ADD_H5_TEST (h5diff_420 2 --follow-symlinks -v ${FILE15} ${FILE15} /ext_link_dset2 /ext_link_noexist2) +ADD_H5_TEST (h5diff_420 1 --follow-symlinks -v ${FILE15} ${FILE15} /ext_link_dset2 /ext_link_noexist2) # extlink vs non-exist-extlink_obj" -ADD_H5_TEST (h5diff_421 2 --follow-symlinks -v ${FILE15} ${FILE15} /ext_link_dset2 /ext_link_noexist1) +ADD_H5_TEST (h5diff_421 1 --follow-symlinks -v ${FILE15} ${FILE15} /ext_link_dset2 /ext_link_noexist1) # non-exist-extlink_obj vs extlink" -ADD_H5_TEST (h5diff_422 2 --follow-symlinks -v ${FILE15} ${FILE15} /ext_link_noexist1 /ext_link_dset2) +ADD_H5_TEST (h5diff_422 1 --follow-symlinks -v ${FILE15} ${FILE15} /ext_link_noexist1 /ext_link_dset2) # extlink_to_softlink_to_dset1 vs dset2" ADD_H5_TEST (h5diff_423 1 --follow-symlinks -v ${FILE17} ${FILE18} /ext_link_to_slink1 /dset2) @@ -1512,11 +1512,11 @@ ADD_H5_TEST (h5diff_465 0 --follow-symlinks h5diff_danglelinks1.h5 h5diff_dangle # soft dangling vs. soft dangling ADD_H5_TEST (h5diff_466 0 -v --follow-symlinks h5diff_danglelinks1.h5 h5diff_danglelinks2.h5 /soft_link1) # soft link vs. soft dangling -ADD_H5_TEST (h5diff_467 2 -v --follow-symlinks h5diff_danglelinks1.h5 h5diff_danglelinks2.h5 /soft_link2) +ADD_H5_TEST (h5diff_467 1 -v --follow-symlinks h5diff_danglelinks1.h5 h5diff_danglelinks2.h5 /soft_link2) # ext dangling vs. ext dangling ADD_H5_TEST (h5diff_468 0 -v --follow-symlinks h5diff_danglelinks1.h5 h5diff_danglelinks2.h5 /ext_link4) # ext link vs. ext dangling -ADD_H5_TEST (h5diff_469 2 -v --follow-symlinks h5diff_danglelinks1.h5 h5diff_danglelinks2.h5 /ext_link2) +ADD_H5_TEST (h5diff_469 1 -v --follow-symlinks h5diff_danglelinks1.h5 h5diff_danglelinks2.h5 /ext_link2) #--------------------------------------------------- # dangling links without follow symlink @@ -1655,7 +1655,7 @@ ADD_H5_TEST (h5diff_v3 0 -c ${FILEV1} ${FILEV2}) ############################################################################## if (BUILD_SHARED_LIBS) ADD_H5_UD_TEST (h5diff_plugin_test 0 h5diff_ud -v tudfilter.h5 tudfilter2.h5) - ADD_H5_UD_TEST (h5diff_plugin_fail 2 h5diff_udfail -v tudfilter.h5 tudfilter2.h5) + ADD_H5_UD_TEST (h5diff_plugin_fail 0 h5diff_udfail -v tudfilter.h5 tudfilter2.h5) endif () # ############################################################################## diff --git a/tools/test/h5diff/testfiles/h5diff_417.txt b/tools/test/h5diff/testfiles/h5diff_417.txt index 29d467a..0ea2542 100644 --- a/tools/test/h5diff/testfiles/h5diff_417.txt +++ b/tools/test/h5diff/testfiles/h5diff_417.txt @@ -1,3 +1,3 @@ obj1 is a dangling link. 1 differences found -EXIT CODE: 2 +EXIT CODE: 1 diff --git a/tools/test/h5diff/testfiles/h5diff_418.txt b/tools/test/h5diff/testfiles/h5diff_418.txt index b6173d9..46222bb 100644 --- a/tools/test/h5diff/testfiles/h5diff_418.txt +++ b/tools/test/h5diff/testfiles/h5diff_418.txt @@ -1,3 +1,3 @@ obj2 is a dangling link. 1 differences found -EXIT CODE: 2 +EXIT CODE: 1 diff --git a/tools/test/h5diff/testfiles/h5diff_419.txt b/tools/test/h5diff/testfiles/h5diff_419.txt index ee6e831..387c600 100644 --- a/tools/test/h5diff/testfiles/h5diff_419.txt +++ b/tools/test/h5diff/testfiles/h5diff_419.txt @@ -1,3 +1,3 @@ obj1 is a dangling link. 1 differences found -EXIT CODE: 2 +EXIT CODE: 1 diff --git a/tools/test/h5diff/testfiles/h5diff_420.txt b/tools/test/h5diff/testfiles/h5diff_420.txt index 67c22ba..f3e65d9 100644 --- a/tools/test/h5diff/testfiles/h5diff_420.txt +++ b/tools/test/h5diff/testfiles/h5diff_420.txt @@ -1,3 +1,3 @@ obj2 is a dangling link. 1 differences found -EXIT CODE: 2 +EXIT CODE: 1 diff --git a/tools/test/h5diff/testfiles/h5diff_421.txt b/tools/test/h5diff/testfiles/h5diff_421.txt index 7fd70ee..833c60c 100644 --- a/tools/test/h5diff/testfiles/h5diff_421.txt +++ b/tools/test/h5diff/testfiles/h5diff_421.txt @@ -1,3 +1,3 @@ obj2 is a dangling link. 1 differences found -EXIT CODE: 2 +EXIT CODE: 1 diff --git a/tools/test/h5diff/testfiles/h5diff_422.txt b/tools/test/h5diff/testfiles/h5diff_422.txt index d1114af..3e675d5 100644 --- a/tools/test/h5diff/testfiles/h5diff_422.txt +++ b/tools/test/h5diff/testfiles/h5diff_422.txt @@ -1,3 +1,3 @@ obj1 is a dangling link. 1 differences found -EXIT CODE: 2 +EXIT CODE: 1 diff --git a/tools/test/h5diff/testfiles/h5diff_467.txt b/tools/test/h5diff/testfiles/h5diff_467.txt index 35d3b74..f5195c0 100644 --- a/tools/test/h5diff/testfiles/h5diff_467.txt +++ b/tools/test/h5diff/testfiles/h5diff_467.txt @@ -1,3 +1,3 @@ obj2 is a dangling link. 1 differences found -EXIT CODE: 2 +EXIT CODE: 1 diff --git a/tools/test/h5diff/testfiles/h5diff_469.txt b/tools/test/h5diff/testfiles/h5diff_469.txt index 23cb62f..594fd80 100644 --- a/tools/test/h5diff/testfiles/h5diff_469.txt +++ b/tools/test/h5diff/testfiles/h5diff_469.txt @@ -1,3 +1,3 @@ obj2 is a dangling link. 1 differences found -EXIT CODE: 2 +EXIT CODE: 1 diff --git a/tools/test/h5diff/testfiles/h5diff_udfail.txt b/tools/test/h5diff/testfiles/h5diff_udfail.txt index c154c6b..aac5528 100644 --- a/tools/test/h5diff/testfiles/h5diff_udfail.txt +++ b/tools/test/h5diff/testfiles/h5diff_udfail.txt @@ -1,12 +1,16 @@ file1 file2 --------------------------------------- - x x / - x x /dynlibud + x x / + x x /dynlibud group : and 0 differences found dataset: and 0 differences found -warning: dataset cannot be read, user defined filter is not available -EXIT CODE: 2 +-------------------------------- +Some objects are not comparable +-------------------------------- +Use -c for a list of objects without details of differences. +Warning: dataset cannot be read, user defined filter is not available +EXIT CODE: 0 -- cgit v0.12 From cf3342f8fc53108e831b208d8ccb48628fb23e51 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 18 Oct 2017 14:03:27 -0500 Subject: Fix tools error handling and valgrind issues --- MANIFEST | 10 +++-- tools/lib/h5diff_dset.c | 4 +- tools/lib/h5tools_filters.c | 8 ++-- tools/src/h5repack/h5repack.c | 17 ++++--- tools/src/h5repack/h5repack_copy.c | 21 +++++---- tools/src/h5repack/h5repack_refs.c | 32 ++++++++----- tools/test/h5copy/CMakeTests.cmake | 52 ++++++++++++++++------ .../h5copy/testfiles/h5copy_plugin_fail.out.h5.txt | 3 ++ .../h5copy/testfiles/h5copy_plugin_test.out.h5.txt | 3 ++ tools/test/h5copy/testfiles/tudfilter.h5.txt | 2 +- tools/test/h5copy/testfiles/tudfilter.h5_ERR.txt | 2 +- tools/test/h5diff/CMakeTests.cmake | 2 +- tools/test/h5diff/testfiles/h5diff_udfail.txt | 10 ++--- .../test/h5format_convert/testfiles/h5fc_v_err.ddl | 7 +++ tools/test/h5repack/CMakeTests.cmake | 4 +- tools/test/h5repack/h5repacktst.c | 6 ++- 16 files changed, 120 insertions(+), 63 deletions(-) create mode 100644 tools/test/h5copy/testfiles/h5copy_plugin_fail.out.h5.txt create mode 100644 tools/test/h5copy/testfiles/h5copy_plugin_test.out.h5.txt diff --git a/MANIFEST b/MANIFEST index 0e59ba0..39b3432 100644 --- a/MANIFEST +++ b/MANIFEST @@ -2524,10 +2524,12 @@ ./tools/test/h5copy/testfiles/h5copy_misc1.out ./tools/test/h5copy/testfiles/h5copytst_new.h5 ./tools/test/h5copy/testfiles/h5copytst_new.out.ls -./tools/test/h5diff/testfiles/tudfilter.h5 -./tools/test/h5diff/testfiles/tudfilter2.h5 -./tools/test/h5diff/testfiles/tudfilter.h5.txt -./tools/test/h5diff/testfiles/tudfilter.h5_ERR.txt +./tools/test/h5copy/testfiles/h5copy_plugin_fail.out.h5.txt +./tools/test/h5copy/testfiles/h5copy_plugin_test.out.h5.txt +./tools/test/h5copy/testfiles/tudfilter.h5 +./tools/test/h5copy/testfiles/tudfilter2.h5 +./tools/test/h5copy/testfiles/tudfilter.h5.txt +./tools/test/h5copy/testfiles/tudfilter.h5_ERR.txt # test files for h5mkgrp ./tools/testfiles/h5mkgrp_nested_p.ls diff --git a/tools/lib/h5diff_dset.c b/tools/lib/h5diff_dset.c index bea008c..b03295b 100644 --- a/tools/lib/h5diff_dset.c +++ b/tools/lib/h5diff_dset.c @@ -74,8 +74,10 @@ hsize_t diff_dataset(hid_t file1_id, else if (status < 0) { HGOTO_ERROR(1, H5E_tools_min_id_g, "h5tools_canreadf failed"); } - else + else { + ret_value = 1; opts->not_cmp = 1; + } done: opts->err_stat = opts->err_stat | ret_value; diff --git a/tools/lib/h5tools_filters.c b/tools/lib/h5tools_filters.c index 132e69a..db61d51 100644 --- a/tools/lib/h5tools_filters.c +++ b/tools/lib/h5tools_filters.c @@ -18,7 +18,7 @@ * print a warning message *------------------------------------------------------------------------- */ -static void print_warning(const char *dname, const char *fname) +static void print_filter_warning(const char *dname, const char *fname) { fprintf(stderr, "Warning: dataset <%s> cannot be read, %s filter is not available\n", @@ -73,7 +73,7 @@ h5tools_canreadf(const char* name, /* object name, serves also as boolean pr } else if (!udfilter_avail) { if (name) - print_warning(name, "user defined"); + print_filter_warning(name, "user defined"); ret_value = 0; } break; @@ -85,7 +85,7 @@ h5tools_canreadf(const char* name, /* object name, serves also as boolean pr case H5Z_FILTER_DEFLATE: #ifndef H5_HAVE_FILTER_DEFLATE if (name) - print_warning(name,"deflate"); + print_filter_warning(name,"deflate"); ret_value = 0; #endif break; @@ -96,7 +96,7 @@ h5tools_canreadf(const char* name, /* object name, serves also as boolean pr case H5Z_FILTER_SZIP: #ifndef H5_HAVE_FILTER_SZIP if (name) - print_warning(name,"SZIP"); + print_filter_warning(name,"SZIP"); ret_value = 0; #endif break; diff --git a/tools/src/h5repack/h5repack.c b/tools/src/h5repack/h5repack.c index eaca0a5..14b9461 100644 --- a/tools/src/h5repack/h5repack.c +++ b/tools/src/h5repack/h5repack.c @@ -227,7 +227,6 @@ hid_t copy_named_datatype(hid_t type_in, hid_t fidout, /* Stack already exists, search for the datatype */ while (dt && dt->addr_in != oinfo.addr) dt = dt->next; - dt_ret = dt; } else { @@ -286,7 +285,7 @@ hid_t copy_named_datatype(hid_t type_in, hid_t fidout, /* Increment the ref count on id_out, because the calling function will try to close it */ if(H5Iinc_ref(ret_value) < 0) - ret_value = -1; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Iinc_ref failed"); done: return ret_value; @@ -426,7 +425,8 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, base_type = H5Tget_super(ftype_id); is_ref = (is_ref || (H5Tget_class(base_type) == H5T_REFERENCE)); - H5Tclose(base_type); + if (H5Tclose(base_type) < 0) + H5TOOLS_INFO(H5E_tools_min_id_g, "H5Tclose base_type failed"); } if (type_class == H5T_COMPOUND) { @@ -435,7 +435,8 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, for (j = 0; j < nmembers; j++) { hid_t mtid = H5Tget_member_type(wtype_id, (unsigned)j); H5T_class_t mtclass = H5Tget_class(mtid); - H5Tclose(mtid); + if (H5Tclose(mtid) < 0) + H5TOOLS_INFO(H5E_tools_min_id_g, "H5Tclose mtid failed"); if (mtclass == H5T_REFERENCE) { is_ref = 1; @@ -486,17 +487,19 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, * close *------------------------------------------------------------------------- */ - if (H5Aclose(attr_out) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aclose failed"); if (H5Sclose(space_id) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose failed"); + space_id = -1; if (H5Tclose(wtype_id) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed"); + wtype_id = -1; if (H5Tclose(ftype_id) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed"); + ftype_id = -1; if (H5Aclose(attr_id) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aclose failed"); - } /* u */ + attr_id = -1; + } /* for u */ done: H5E_BEGIN_TRY { diff --git a/tools/src/h5repack/h5repack_copy.c b/tools/src/h5repack/h5repack_copy.c index 7c3dfa5..b043047 100644 --- a/tools/src/h5repack/h5repack_copy.c +++ b/tools/src/h5repack/h5repack_copy.c @@ -1175,6 +1175,7 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed"); if (H5Tclose(type_out) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed"); + type_out = -1; /* named datatypes stack, named_dt_head, manages allocation */ break; @@ -1205,6 +1206,18 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, } /* end if */ done: + + /* Finalize (link) the stack of named datatypes (if any) first + * because of reference counting */ + if (0 == ret_value && named_dt_head != NULL) { + if (named_datatype_free(&named_dt_head, 0) < 0) + H5TOOLS_INFO(H5E_tools_min_id_g, "named_datatype_free failed"); + } + else + H5E_BEGIN_TRY { + named_datatype_free(&named_dt_head, 1); + } H5E_END_TRY; + H5E_BEGIN_TRY { H5Gclose(grp_in); @@ -1227,14 +1240,6 @@ done: if (hslab_buf != NULL) HDfree(hslab_buf); - /* Finalize (link) the stack of named datatypes (if any) */ - if (0 == ret_value && named_dt_head != NULL) - named_datatype_free(&named_dt_head, 0); - else - H5E_BEGIN_TRY { - named_datatype_free(&named_dt_head, 1); - } H5E_END_TRY; - return ret_value; } diff --git a/tools/src/h5repack/h5repack_refs.c b/tools/src/h5repack/h5repack_refs.c index 376ab92..14294ea 100644 --- a/tools/src/h5repack/h5repack_refs.c +++ b/tools/src/h5repack/h5repack_refs.c @@ -189,7 +189,8 @@ int do_copy_refobjs(hid_t fidin, refname); } } /*refname*/ - H5Oclose(refobj_id); + if (H5Oclose(refobj_id) < 0) + H5TOOLS_INFO(H5E_tools_min_id_g, "H5Oclose refob failed"); } /* u */ } /*nelmts*/ @@ -276,7 +277,8 @@ int do_copy_refobjs(hid_t fidin, refname); } } /*refname*/ - H5Oclose(refobj_id); + if (H5Oclose(refobj_id) < 0) + H5TOOLS_INFO(H5E_tools_min_id_g, "H5Oclose refobj_id failed"); } /* u */ } /*nelmts*/ @@ -377,7 +379,8 @@ int do_copy_refobjs(hid_t fidin, * This function is paired with copy_named_datatype() which is called * in copy_attr(), so need to free. */ - named_datatype_free(&named_dt_head, 0); + if (named_datatype_free(&named_dt_head, 0) < 0) + H5TOOLS_INFO(H5E_tools_min_id_g, "named_datatype_free failed"); return ret_value; @@ -392,7 +395,7 @@ done: H5Tclose(ftype_id); H5Tclose(mtype_id); H5Tclose(type_in); - named_datatype_free(&named_dt_head, 0); + named_datatype_free(&named_dt_head, 1); } H5E_END_TRY; return ret_value; @@ -483,7 +486,8 @@ static int copy_refs_attr(hid_t loc_in, base_type = H5Tget_super(ftype_id); is_ref_vlen = (H5Tget_class(base_type) == H5T_REFERENCE); msize = H5Tget_size(base_type); - H5Tclose(base_type); + if (H5Tclose(base_type) < 0) + H5TOOLS_INFO(H5E_tools_min_id_g, "H5Tclose base_type failed"); } else if(type_class == H5T_ARRAY ) { hid_t base_type; @@ -491,7 +495,8 @@ static int copy_refs_attr(hid_t loc_in, base_type = H5Tget_super(ftype_id); is_ref_array = (H5Tget_class(base_type) == H5T_REFERENCE); msize = H5Tget_size(base_type); - H5Tclose(base_type); + if (H5Tclose(base_type) < 0) + H5TOOLS_INFO(H5E_tools_min_id_g, "H5Tclose base_type failed"); } else if(type_class == H5T_COMPOUND) { int nmembers = H5Tget_nmembers(ftype_id) ; @@ -511,7 +516,8 @@ static int copy_refs_attr(hid_t loc_in, ref_comp_size[ref_comp_field_n] = H5Tget_size(mtid); ref_comp_field_n++; } - H5Tclose(mtid); + if (H5Tclose(mtid) < 0) + H5TOOLS_INFO(H5E_tools_min_id_g, "H5Tclose mtid failed"); } /* if compound don't contain reference type member, free the above @@ -533,9 +539,12 @@ static int copy_refs_attr(hid_t loc_in, is_ref_comp = (ref_comp_field_n > 0); if (!(is_ref || is_ref_vlen || is_ref_array || is_ref_comp)) { - H5Tclose(mtype_id); - H5Tclose(ftype_id); - H5Aclose(attr_id); + if (H5Tclose(mtype_id) < 0) + H5TOOLS_INFO(H5E_tools_min_id_g, "H5Tclose mtype_id failed"); + if (H5Tclose(ftype_id) < 0) + H5TOOLS_INFO(H5E_tools_min_id_g, "H5Tclose ftype_id failed"); + if (H5Aclose(attr_id) < 0) + H5TOOLS_INFO(H5E_tools_min_id_g, "H5Aclose attr_id failed"); continue; } @@ -568,7 +577,8 @@ static int copy_refs_attr(hid_t loc_in, base_type = H5Tget_super(ftype_id); msize = H5Tget_size(base_type); - H5Tclose(base_type); + if (H5Tclose(base_type) < 0) + H5TOOLS_INFO(H5E_tools_min_id_g, "H5Tclose base_type failed"); array_rank = (unsigned)H5Tget_array_ndims(mtype_id); H5Tget_array_dims2(mtype_id, array_dims); diff --git a/tools/test/h5copy/CMakeTests.cmake b/tools/test/h5copy/CMakeTests.cmake index f9733cf..616a459 100644 --- a/tools/test/h5copy/CMakeTests.cmake +++ b/tools/test/h5copy/CMakeTests.cmake @@ -32,6 +32,8 @@ ${HDF5_TOOLS_TEST_H5COPY_SOURCE_DIR}/testfiles/h5copy_misc1.out ${HDF5_TOOLS_TEST_H5COPY_SOURCE_DIR}/testfiles/tudfilter.h5.txt ${HDF5_TOOLS_TEST_H5COPY_SOURCE_DIR}/testfiles/tudfilter.h5_ERR.txt + ${HDF5_TOOLS_TEST_H5COPY_SOURCE_DIR}/testfiles/h5copy_plugin_fail.out.h5.txt + ${HDF5_TOOLS_TEST_H5COPY_SOURCE_DIR}/testfiles/h5copy_plugin_test.out.h5.txt ) file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") @@ -80,7 +82,7 @@ NAME H5COPY_F-${testname}-DIFF COMMAND $ -v ./testfiles/${infile} ./testfiles/${testname}.out.h5 ${srcname} ${dstname} ) - SET_TESTS_PROPERTIES(H5COPY_F-${testname}-DIFF PROPERTIES DEPENDS H5COPY_F-${testname}) + set_tests_properties (H5COPY_F-${testname}-DIFF PROPERTIES DEPENDS H5COPY_F-${testname}) if ("${resultcode}" STREQUAL "1") set_tests_properties (H5COPY_F-${testname}-DIFF PROPERTIES WILL_FAIL "true") endif () @@ -116,7 +118,7 @@ NAME H5COPY-${testname}-DIFF COMMAND $ -v ./testfiles/${infile} ./testfiles/${testname}.out.h5 ${srcname} ${dstname} ) - SET_TESTS_PROPERTIES(H5COPY-${testname}-DIFF PROPERTIES DEPENDS H5COPY-${testname}) + set_tests_properties (H5COPY-${testname}-DIFF PROPERTIES DEPENDS H5COPY-${testname}) if ("${resultcode}" STREQUAL "1") set_tests_properties (H5COPY-${testname}-DIFF PROPERTIES WILL_FAIL "true") endif () @@ -166,7 +168,7 @@ NAME H5COPY-${testname}-DIFF COMMAND $ -v ./testfiles/${infile} ./testfiles/${testname}.out.h5 ${srcname} ${dstname} ) - SET_TESTS_PROPERTIES(H5COPY-${testname}-DIFF PROPERTIES DEPENDS H5COPY-${testname}) + set_tests_properties (H5COPY-${testname}-DIFF PROPERTIES DEPENDS H5COPY-${testname}) if ("${resultcode}" STREQUAL "1") set_tests_properties (H5COPY-${testname}-DIFF PROPERTIES WILL_FAIL "true") endif () @@ -207,7 +209,7 @@ NAME H5COPY_SAME-${testname}-DIFF COMMAND $ -v ./testfiles/${testname}.out.h5 ./testfiles/${testname}.out.h5 ${srcname} ${dstname} ) - SET_TESTS_PROPERTIES(H5COPY_SAME-${testname}-DIFF PROPERTIES DEPENDS H5COPY_SAME-${testname}) + set_tests_properties (H5COPY_SAME-${testname}-DIFF PROPERTIES DEPENDS H5COPY_SAME-${testname}) if ("${resultcode}" STREQUAL "1") set_tests_properties (H5COPY_SAME-${testname}-DIFF PROPERTIES WILL_FAIL "true") endif () @@ -295,16 +297,23 @@ -D "TEST_ENV_VALUE=${CMAKE_BINARY_DIR}/plugins" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - add_test ( - NAME H5COPY_UD-${testname}-DIFF - COMMAND $ -v ./testfiles/${cmpfile} ./testfiles/${testname}.out.h5 ${srcname} ${dstname} - ) - SET_TESTS_PROPERTIES(H5COPY_UD-${testname}-DIFF PROPERTIES DEPENDS H5COPY_UD-${testname}) - if ("${resultcode}" STREQUAL "1") - set_tests_properties (H5COPY_UD-${testname}-DIFF PROPERTIES WILL_FAIL "true") - endif () endif () set_tests_properties (H5COPY_UD-${testname} PROPERTIES DEPENDS H5COPY_UD-${testname}-clear-objects) + add_test ( + NAME H5COPY_UD-${testname}-DIFF + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=-v;./testfiles/${cmpfile};./testfiles/${testname}.out.h5;${srcname};${dstname}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" + -D "TEST_OUTPUT=./testfiles/${testname}.out.h5.out" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_REFERENCE=./testfiles/${testname}.out.h5.txt" + -D "TEST_APPEND=EXIT CODE:" + -D "TEST_ENV_VAR=HDF5_PLUGIN_PATH" + -D "TEST_ENV_VALUE=${CMAKE_BINARY_DIR}/plugins" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + set_tests_properties (H5COPY_UD-${testname}-DIFF PROPERTIES DEPENDS H5COPY_UD-${testname}) endif () endmacro () @@ -327,7 +336,7 @@ -D "TEST_ARGS:STRING=-v;--enable-error-stack;-i;./testfiles/${infile};-o;./testfiles/${testname}_ERR.out.h5;${sparam};${srcname};${dparam};${dstname}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" -D "TEST_OUTPUT=./testfiles/${infile}_ERR.out" - -D "TEST_EXPECT=${resultcode}" + -D "TEST_EXPECT=0" -D "TEST_REFERENCE=./testfiles/${infile}_ERR.txt" -D "TEST_MASK_ERROR=true" -D "TEST_APPEND=EXIT CODE:" @@ -353,6 +362,21 @@ ) endif () set_tests_properties (H5COPY_UD_ERR-${testname} PROPERTIES DEPENDS H5COPY_UD_ERR-${testname}-clearall-objects) + add_test ( + NAME H5COPY_UD_ERR-${testname}-DIFF + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=-v;./testfiles/${cmpfile};./testfiles/${testname}.out.h5;${srcname};${dstname}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" + -D "TEST_OUTPUT=./testfiles/${testname}.out.h5.out" + -D "TEST_EXPECT=0" + -D "TEST_REFERENCE=./testfiles/${testname}.out.h5.txt" + -D "TEST_APPEND=EXIT CODE:" + -D "TEST_ENV_VAR=HDF5_PLUGIN_PATH" + -D "TEST_ENV_VALUE=${CMAKE_BINARY_DIR}/plugins" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + set_tests_properties (H5COPY_UD_ERR-${testname}-DIFF PROPERTIES DEPENDS H5COPY_UD_ERR-${testname}) endif () endmacro () @@ -546,5 +570,5 @@ ############################################################################## if (BUILD_SHARED_LIBS) ADD_H5_UD_TEST (h5copy_plugin_test 0 tudfilter.h5 -s /dynlibud -d /dynlibud tudfilter2.h5 ) - ADD_H5_UD_TEST (h5copy_plugin_fail 2 tudfilter.h5 -s /dynlibud -d /dynlibud tudfilter2.h5) + ADD_H5_UD_ERR_TEST (h5copy_plugin_fail 2 tudfilter.h5 -s /dynlibud -d /dynlibud tudfilter2.h5) endif () diff --git a/tools/test/h5copy/testfiles/h5copy_plugin_fail.out.h5.txt b/tools/test/h5copy/testfiles/h5copy_plugin_fail.out.h5.txt new file mode 100644 index 0000000..66e9eb2 --- /dev/null +++ b/tools/test/h5copy/testfiles/h5copy_plugin_fail.out.h5.txt @@ -0,0 +1,3 @@ +dataset: and +0 differences found +EXIT CODE: 0 diff --git a/tools/test/h5copy/testfiles/h5copy_plugin_test.out.h5.txt b/tools/test/h5copy/testfiles/h5copy_plugin_test.out.h5.txt new file mode 100644 index 0000000..66e9eb2 --- /dev/null +++ b/tools/test/h5copy/testfiles/h5copy_plugin_test.out.h5.txt @@ -0,0 +1,3 @@ +dataset: and +0 differences found +EXIT CODE: 0 diff --git a/tools/test/h5copy/testfiles/tudfilter.h5.txt b/tools/test/h5copy/testfiles/tudfilter.h5.txt index 8f3d0b5..eabe407 100644 --- a/tools/test/h5copy/testfiles/tudfilter.h5.txt +++ b/tools/test/h5copy/testfiles/tudfilter.h5.txt @@ -1,2 +1,2 @@ -Copying file <./testfiles/tudfilter.h5> and object to file <./testfiles/h5copy_plugin_fail.out.h5> and object +Copying file <./testfiles/tudfilter.h5> and object to file <./testfiles/h5copy_plugin_test.out.h5> and object EXIT CODE: 0 diff --git a/tools/test/h5copy/testfiles/tudfilter.h5_ERR.txt b/tools/test/h5copy/testfiles/tudfilter.h5_ERR.txt index 8f3d0b5..3c5b3ca 100644 --- a/tools/test/h5copy/testfiles/tudfilter.h5_ERR.txt +++ b/tools/test/h5copy/testfiles/tudfilter.h5_ERR.txt @@ -1,2 +1,2 @@ -Copying file <./testfiles/tudfilter.h5> and object to file <./testfiles/h5copy_plugin_fail.out.h5> and object +Copying file <./testfiles/tudfilter.h5> and object to file <./testfiles/h5copy_plugin_fail_ERR.out.h5> and object EXIT CODE: 0 diff --git a/tools/test/h5diff/CMakeTests.cmake b/tools/test/h5diff/CMakeTests.cmake index b5dd820..d87a47f 100644 --- a/tools/test/h5diff/CMakeTests.cmake +++ b/tools/test/h5diff/CMakeTests.cmake @@ -1655,7 +1655,7 @@ ADD_H5_TEST (h5diff_v3 0 -c ${FILEV1} ${FILEV2}) ############################################################################## if (BUILD_SHARED_LIBS) ADD_H5_UD_TEST (h5diff_plugin_test 0 h5diff_ud -v tudfilter.h5 tudfilter2.h5) - ADD_H5_UD_TEST (h5diff_plugin_fail 0 h5diff_udfail -v tudfilter.h5 tudfilter2.h5) + ADD_H5_UD_TEST (h5diff_plugin_fail 2 h5diff_udfail -v tudfilter.h5 tudfilter2.h5) endif () # ############################################################################## diff --git a/tools/test/h5diff/testfiles/h5diff_udfail.txt b/tools/test/h5diff/testfiles/h5diff_udfail.txt index aac5528..d51de38 100644 --- a/tools/test/h5diff/testfiles/h5diff_udfail.txt +++ b/tools/test/h5diff/testfiles/h5diff_udfail.txt @@ -1,16 +1,12 @@ file1 file2 --------------------------------------- - x x / - x x /dynlibud + x x / + x x /dynlibud group : and 0 differences found dataset: and 0 differences found --------------------------------- -Some objects are not comparable --------------------------------- -Use -c for a list of objects without details of differences. Warning: dataset cannot be read, user defined filter is not available -EXIT CODE: 0 +EXIT CODE: 2 diff --git a/tools/test/h5format_convert/testfiles/h5fc_v_err.ddl b/tools/test/h5format_convert/testfiles/h5fc_v_err.ddl index b671db0..fa2f078 100644 --- a/tools/test/h5format_convert/testfiles/h5fc_v_err.ddl +++ b/tools/test/h5format_convert/testfiles/h5fc_v_err.ddl @@ -11,3 +11,10 @@ Converting the dataset... Error encountered Close the file h5format_convert error: unable to downgrade dataset "/DSET_ERR" +H5tools-DIAG: Error detected in HDF5:tools (1.11.0) thread 0: + #000: /home/byrn/HDF_Projects/hdf5/dev/tools/lib/h5trav.c line 1062 in h5trav_visit(): traverse failed + major: Failure in tools library + minor: error in function + #001: /home/byrn/HDF_Projects/hdf5/dev/tools/lib/h5trav.c line 290 in traverse(): H5Lvisit_by_name failed + major: Failure in tools library + minor: error in function diff --git a/tools/test/h5repack/CMakeTests.cmake b/tools/test/h5repack/CMakeTests.cmake index 559dd88..13ebd17 100644 --- a/tools/test/h5repack/CMakeTests.cmake +++ b/tools/test/h5repack/CMakeTests.cmake @@ -275,12 +275,12 @@ endif () add_test ( NAME H5REPACK-${testname} - COMMAND $ ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} + COMMAND $ --enable-error-stack ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} ) set_tests_properties (H5REPACK-${testname} PROPERTIES DEPENDS H5REPACK-${testname}-clear-objects) add_test ( NAME H5REPACK-${testname}_DFF - COMMAND $ ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} + COMMAND $ --enable-error-stack ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile} ) set_tests_properties (H5REPACK-${testname}_DFF PROPERTIES DEPENDS H5REPACK-${testname}) endif () diff --git a/tools/test/h5repack/h5repacktst.c b/tools/test/h5repack/h5repacktst.c index 264550e..f6166da 100644 --- a/tools/test/h5repack/h5repacktst.c +++ b/tools/test/h5repack/h5repacktst.c @@ -3041,9 +3041,9 @@ int make_all_filters(hid_t loc_id) /* close */ if(H5Tclose(dtid) < 0) - return -1; + goto out; if(H5Dclose(dsid) < 0) - return -1; + goto out; if(H5Sclose(sid) < 0) goto out; @@ -3055,6 +3055,8 @@ int make_all_filters(hid_t loc_id) out: H5E_BEGIN_TRY { + H5Tclose(dtid); + H5Dclose(dsid); H5Pclose(dcpl); H5Sclose(sid); } H5E_END_TRY; -- cgit v0.12 From d68de1621c98cc0b5d8d82af01ffcb608603366d Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 18 Oct 2017 15:06:14 -0500 Subject: Fix format convert error mask test --- MANIFEST | 1 + tools/test/h5format_convert/CMakeTests.cmake | 58 +++++++++++++++++++++- .../test/h5format_convert/testfiles/h5fc_v_err.ddl | 8 --- .../test/h5format_convert/testfiles/h5fc_v_err.err | 8 +++ 4 files changed, 66 insertions(+), 9 deletions(-) create mode 100644 tools/test/h5format_convert/testfiles/h5fc_v_err.err diff --git a/MANIFEST b/MANIFEST index 39b3432..24ab056 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1354,6 +1354,7 @@ ./tools/test/h5format_convert/testfiles/h5fc_v_n_all.ddl ./tools/test/h5format_convert/testfiles/h5fc_v_bt1.ddl ./tools/test/h5format_convert/testfiles/h5fc_v_err.ddl +./tools/test/h5format_convert/testfiles/h5fc_v_err.err ./tools/test/h5format_convert/testfiles/h5fc_v_non_chunked.ddl ./tools/test/h5format_convert/testfiles/h5fc_d_file.ddl ./tools/test/h5format_convert/testfiles/h5fc_v_ndata_bt1.ddl diff --git a/tools/test/h5format_convert/CMakeTests.cmake b/tools/test/h5format_convert/CMakeTests.cmake index 4af220b..c2b2d3a 100644 --- a/tools/test/h5format_convert/CMakeTests.cmake +++ b/tools/test/h5format_convert/CMakeTests.cmake @@ -140,6 +140,62 @@ endif () endmacro () + macro (ADD_H5_MASK_OUTPUT testname resultfile resultcode testfile) + # If using memchecker add tests without using scripts + if (NOT HDF5_ENABLE_USING_MEMCHECKER) + add_test ( + NAME H5FC-${testname}-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + ./testfiles/outtmp.h5 + ./testfiles/${testname}.out + ./testfiles/${testname}.out.err + ) + if (NOT "${last_test}" STREQUAL "") + set_tests_properties (H5FC-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) + endif () + if (NOT "${testfile}" STREQUAL "") + add_test ( + NAME H5FC-${testname}-${testfile}-tmpfile + COMMAND ${CMAKE_COMMAND} + -E copy_if_different ${HDF5_TOOLS_TEST_H5FC_SOURCE_DIR}/testfiles/${testfile} ./testfiles/outtmp.h5 + ) + set_tests_properties (H5FC-${testname}-${testfile}-tmpfile PROPERTIES DEPENDS "H5FC-${testname}-clear-objects") + add_test ( + NAME H5FC-${testname}-${testfile} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS=${ARGN};outtmp.h5" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" + -D "TEST_OUTPUT=${testname}.out" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_REFERENCE=${resultfile}" + -D "TEST_ERRREF=${resultfile}.err" + -D "TEST_MASK_ERROR=true" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + set_tests_properties (H5FC-${testname}-${testfile} PROPERTIES DEPENDS "H5FC-${testname}-${testfile}-tmpfile") + set (last_test "H5FC-${testname}-${testfile}") + else () + add_test ( + NAME H5FC-${testname}-NA + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS=${ARGN}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" + -D "TEST_OUTPUT=${testname}.out" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_REFERENCE=${resultfile}" + -D "TEST_ERRREF=${resultfile}.err" + -D "TEST_MASK_ERROR=true" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + set_tests_properties (H5FC-${testname}-NA PROPERTIES DEPENDS "H5FC-${testname}-clear-objects") + set (last_test "H5FC-${testname}-NA") + endif () + endif () + endmacro () + macro (ADD_H5_TEST testname resultcode testfile) # If using memchecker add tests without using scripts if (NOT HDF5_ENABLE_USING_MEMCHECKER) @@ -391,7 +447,7 @@ # # # h5format_convert -v h5fc_err_level.h5 (error encountered in converting the dataset) - ADD_H5_OUTPUT (h5fc_v_err h5fc_v_err.ddl 1 h5fc_err_level.h5 -v) + ADD_H5_MASK_OUTPUT (h5fc_v_err h5fc_v_err.ddl 1 h5fc_err_level.h5 -v) # # # diff --git a/tools/test/h5format_convert/testfiles/h5fc_v_err.ddl b/tools/test/h5format_convert/testfiles/h5fc_v_err.ddl index fa2f078..0b7d0ac 100644 --- a/tools/test/h5format_convert/testfiles/h5fc_v_err.ddl +++ b/tools/test/h5format_convert/testfiles/h5fc_v_err.ddl @@ -10,11 +10,3 @@ Dataset's chunk indexing type is not version 1 B-tree Converting the dataset... Error encountered Close the file -h5format_convert error: unable to downgrade dataset "/DSET_ERR" -H5tools-DIAG: Error detected in HDF5:tools (1.11.0) thread 0: - #000: /home/byrn/HDF_Projects/hdf5/dev/tools/lib/h5trav.c line 1062 in h5trav_visit(): traverse failed - major: Failure in tools library - minor: error in function - #001: /home/byrn/HDF_Projects/hdf5/dev/tools/lib/h5trav.c line 290 in traverse(): H5Lvisit_by_name failed - major: Failure in tools library - minor: error in function diff --git a/tools/test/h5format_convert/testfiles/h5fc_v_err.err b/tools/test/h5format_convert/testfiles/h5fc_v_err.err new file mode 100644 index 0000000..d85a999 --- /dev/null +++ b/tools/test/h5format_convert/testfiles/h5fc_v_err.err @@ -0,0 +1,8 @@ +h5format_convert error: unable to downgrade dataset "/DSET_ERR" +H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): + #000: (file name) line (number) in h5trav_visit(): traverse failed + major: Failure in tools library + minor: error in function + #001: (file name) line (number) in traverse(): H5Lvisit_by_name failed + major: Failure in tools library + minor: error in function -- cgit v0.12 From 49c21ebcf22380e6c402b05d981a539c8c85a5b7 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 18 Oct 2017 15:14:46 -0500 Subject: Fix name of output files --- MANIFEST | 2 +- tools/test/h5copy/CMakeTests.cmake | 8 ++++---- tools/test/h5copy/testfiles/h5copy_plugin_fail.out.h5.txt | 3 --- tools/test/h5copy/testfiles/h5copy_plugin_fail_ERR.out.h5.txt | 3 +++ 4 files changed, 8 insertions(+), 8 deletions(-) delete mode 100644 tools/test/h5copy/testfiles/h5copy_plugin_fail.out.h5.txt create mode 100644 tools/test/h5copy/testfiles/h5copy_plugin_fail_ERR.out.h5.txt diff --git a/MANIFEST b/MANIFEST index 24ab056..261de1d 100644 --- a/MANIFEST +++ b/MANIFEST @@ -2525,7 +2525,7 @@ ./tools/test/h5copy/testfiles/h5copy_misc1.out ./tools/test/h5copy/testfiles/h5copytst_new.h5 ./tools/test/h5copy/testfiles/h5copytst_new.out.ls -./tools/test/h5copy/testfiles/h5copy_plugin_fail.out.h5.txt +./tools/test/h5copy/testfiles/h5copy_plugin_fail_ERR.out.h5.txt ./tools/test/h5copy/testfiles/h5copy_plugin_test.out.h5.txt ./tools/test/h5copy/testfiles/tudfilter.h5 ./tools/test/h5copy/testfiles/tudfilter2.h5 diff --git a/tools/test/h5copy/CMakeTests.cmake b/tools/test/h5copy/CMakeTests.cmake index 616a459..270d546 100644 --- a/tools/test/h5copy/CMakeTests.cmake +++ b/tools/test/h5copy/CMakeTests.cmake @@ -32,7 +32,7 @@ ${HDF5_TOOLS_TEST_H5COPY_SOURCE_DIR}/testfiles/h5copy_misc1.out ${HDF5_TOOLS_TEST_H5COPY_SOURCE_DIR}/testfiles/tudfilter.h5.txt ${HDF5_TOOLS_TEST_H5COPY_SOURCE_DIR}/testfiles/tudfilter.h5_ERR.txt - ${HDF5_TOOLS_TEST_H5COPY_SOURCE_DIR}/testfiles/h5copy_plugin_fail.out.h5.txt + ${HDF5_TOOLS_TEST_H5COPY_SOURCE_DIR}/testfiles/h5copy_plugin_fail_ERR.out.h5.txt ${HDF5_TOOLS_TEST_H5COPY_SOURCE_DIR}/testfiles/h5copy_plugin_test.out.h5.txt ) @@ -366,11 +366,11 @@ NAME H5COPY_UD_ERR-${testname}-DIFF COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$" - -D "TEST_ARGS:STRING=-v;./testfiles/${cmpfile};./testfiles/${testname}.out.h5;${srcname};${dstname}" + -D "TEST_ARGS:STRING=-v;./testfiles/${cmpfile};./testfiles/${testname}_ERR.out.h5;${srcname};${dstname}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" - -D "TEST_OUTPUT=./testfiles/${testname}.out.h5.out" + -D "TEST_OUTPUT=./testfiles/${testname}_ERR.out.h5.out" -D "TEST_EXPECT=0" - -D "TEST_REFERENCE=./testfiles/${testname}.out.h5.txt" + -D "TEST_REFERENCE=./testfiles/${testname}_ERR.out.h5.txt" -D "TEST_APPEND=EXIT CODE:" -D "TEST_ENV_VAR=HDF5_PLUGIN_PATH" -D "TEST_ENV_VALUE=${CMAKE_BINARY_DIR}/plugins" diff --git a/tools/test/h5copy/testfiles/h5copy_plugin_fail.out.h5.txt b/tools/test/h5copy/testfiles/h5copy_plugin_fail.out.h5.txt deleted file mode 100644 index 66e9eb2..0000000 --- a/tools/test/h5copy/testfiles/h5copy_plugin_fail.out.h5.txt +++ /dev/null @@ -1,3 +0,0 @@ -dataset: and -0 differences found -EXIT CODE: 0 diff --git a/tools/test/h5copy/testfiles/h5copy_plugin_fail_ERR.out.h5.txt b/tools/test/h5copy/testfiles/h5copy_plugin_fail_ERR.out.h5.txt new file mode 100644 index 0000000..66e9eb2 --- /dev/null +++ b/tools/test/h5copy/testfiles/h5copy_plugin_fail_ERR.out.h5.txt @@ -0,0 +1,3 @@ +dataset: and +0 differences found +EXIT CODE: 0 -- cgit v0.12 From c475dd05a6b20e19da5b6fdf5000ba63120c1301 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 18 Oct 2017 15:45:07 -0500 Subject: Correct name of err file --- MANIFEST | 2 +- tools/test/h5format_convert/CMakeTests.cmake | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/MANIFEST b/MANIFEST index 261de1d..4a62884 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1354,7 +1354,7 @@ ./tools/test/h5format_convert/testfiles/h5fc_v_n_all.ddl ./tools/test/h5format_convert/testfiles/h5fc_v_bt1.ddl ./tools/test/h5format_convert/testfiles/h5fc_v_err.ddl -./tools/test/h5format_convert/testfiles/h5fc_v_err.err +./tools/test/h5format_convert/testfiles/h5fc_v_err.ddl.err ./tools/test/h5format_convert/testfiles/h5fc_v_non_chunked.ddl ./tools/test/h5format_convert/testfiles/h5fc_d_file.ddl ./tools/test/h5format_convert/testfiles/h5fc_v_ndata_bt1.ddl diff --git a/tools/test/h5format_convert/CMakeTests.cmake b/tools/test/h5format_convert/CMakeTests.cmake index c2b2d3a..2240813 100644 --- a/tools/test/h5format_convert/CMakeTests.cmake +++ b/tools/test/h5format_convert/CMakeTests.cmake @@ -47,6 +47,7 @@ old_h5fc_ext2_sf.ddl old_h5fc_ext3_isf.ddl h5fc_v_err.ddl + h5fc_v_err.ddl.err ) set (HDF5_REFERENCE_TEST_FILES h5fc_non_v3.h5 -- cgit v0.12 From cfad6bf6f8a678dc03c52b7474a6f04a4a69b030 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 18 Oct 2017 15:51:56 -0500 Subject: Add new output files to clear test --- tools/test/h5copy/CMakeTests.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/test/h5copy/CMakeTests.cmake b/tools/test/h5copy/CMakeTests.cmake index 270d546..1bdefa6 100644 --- a/tools/test/h5copy/CMakeTests.cmake +++ b/tools/test/h5copy/CMakeTests.cmake @@ -266,6 +266,8 @@ testfiles/${testname}.out.h5 testfiles/${infile}.out testfiles/${infile}.out.err + testfiles/${testname}.out.h5.out + testfiles/${testname}.out.h5.out.err ) if ("${resultcode}" STREQUAL "2") add_test ( @@ -327,6 +329,8 @@ testfiles/${testname}_ERR.out.h5 testfiles/${infile}_ERR.out testfiles/${infile}_ERR.out.err + testfiles/${testname}_ERR.out.h5.out + testfiles/${testname}_ERR.out.h5.out.err ) if ("${resultcode}" STREQUAL "2") add_test ( -- cgit v0.12 From f071b2ff97699f2981715fa038e34777ac1d5dd8 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 18 Oct 2017 16:07:42 -0500 Subject: Add Mask test to script --- tools/test/h5format_convert/testh5fc.sh.in | 137 +++++++++++++++++++++-------- 1 file changed, 100 insertions(+), 37 deletions(-) diff --git a/tools/test/h5format_convert/testh5fc.sh.in b/tools/test/h5format_convert/testh5fc.sh.in index c3056e8..9250df3 100644 --- a/tools/test/h5format_convert/testh5fc.sh.in +++ b/tools/test/h5format_convert/testh5fc.sh.in @@ -32,8 +32,8 @@ EXIT_FAILURE=1 FORMCONV=../../src/h5format_convert/h5format_convert # The tool name FORMCONV_BIN=`pwd`/$FORMCONV # The path of the tool binary -CHK_IDX=h5fc_chk_idx # The program name -CHK_IDX_BIN=`pwd`/$CHK_IDX # The program to verify the chunk indexing type is v1 B-tree +CHK_IDX=h5fc_chk_idx # The program name +CHK_IDX_BIN=`pwd`/$CHK_IDX # The program to verify the chunk indexing type is v1 B-tree RM='rm -rf' CMP='cmp -s' @@ -131,6 +131,7 @@ $SRC_H5FORMCONV_TESTFILES/old_h5fc_ext2_is.ddl $SRC_H5FORMCONV_TESTFILES/old_h5fc_ext2_sf.ddl $SRC_H5FORMCONV_TESTFILES/old_h5fc_ext3_isf.ddl $SRC_H5FORMCONV_TESTFILES/h5fc_v_err.ddl +$SRC_H5FORMCONV_TESTFILES/h5fc_v_err.ddl.err " # @@ -154,10 +155,10 @@ COPY_TESTFILES_TO_TESTDIR() INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'` INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'` if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then - $CP -f $tstfile $TESTDIR + $CP -f $tstfile $TESTDIR if [ $? -ne 0 ]; then echo "Error: FAILED to copy $tstfile ." - + # Comment out this to CREATE expected file exit $EXIT_FAILURE fi @@ -177,7 +178,7 @@ CLEAN_TESTFILES_AND_TESTDIR() if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then $RM $TESTDIR else - $RM $TESTDIR/$TMPFILE + $RM $TESTDIR/$TMPFILE $RM $TESTDIR/$TMPOUTFILE $RM $TESTDIR/$TMPCHKFILE $RM $TESTDIR/$TMPDMPFILE @@ -201,13 +202,13 @@ TESTING() { # non-zero value. # # $1: expected output -# $2: the test file name -# --fname might be empty or fname does not exist -# --fname is copied to a temporary file for testing +# $2: the test file name +# --fname might be empty or fname does not exist +# --fname is copied to a temporary file for testing # $3 to at most $6--options to the tool such as: -# -d dname or --dname=dname -# -v or --verbose -# -n or --noop +# -d dname or --dname=dname +# -v or --verbose +# -n or --noop TOOLTEST_OUT() { # Prepare expected and actual output expect="$TESTDIR/$1" @@ -220,15 +221,15 @@ TOOLTEST_OUT() { $RM $TESTDIR/$TMPOUTFILE TFILE=$2 if [ ! -z "$2" ] && [ -e $TESTDIR/$2 ] ; then - $CP $TESTDIR/$2 $TESTDIR/$TMPOUTFILE - TFILE=$TMPOUTFILE + $CP $TESTDIR/$2 $TESTDIR/$TMPOUTFILE + TFILE=$TMPOUTFILE fi # Run test. TESTING $FORMCONV $3 $4 $5 $6 $2 ( - cd $TESTDIR - $RUNSERIAL $FORMCONV_BIN $3 $4 $5 $6 $TFILE + cd $TESTDIR + $RUNSERIAL $FORMCONV_BIN $3 $4 $5 $6 $TFILE ) >$actual 2>$actual_err cp $actual $actual_sav cp $actual_err $actual_err_sav @@ -239,20 +240,82 @@ TOOLTEST_OUT() { # Clean up output file if test -z "$HDF5_NOCLEANUP"; then - $RM $actual $actual_err - $RM $actual $actual_err $actual_sav $actual_err_sav + $RM $actual $actual_err + $RM $actual $actual_err $actual_sav $actual_err_sav + fi +} +# Same as TOOLTEST_OUT but filters error stack output and compares to an error file +TOOLTEST_MASK_OUT() { + # Prepare expected and actual output + expect="$TESTDIR/$1" + expect_err="$TESTDIR/$1.err" + actual_ext="$TESTDIR/$1.ext" + actual="$TESTDIR/`basename $1 .ddl`.out" + actual_err="$TESTDIR/`basename $1 .ddl`.err" + actual_sav=${actual}-sav + actual_err_sav=${actual_err}-sav + + # Prepare the test file + $RM $TESTDIR/$TMPOUTFILE + TFILE=$2 + if [ ! -z "$2" ] && [ -e $TESTDIR/$2 ] ; then + $CP $TESTDIR/$2 $TESTDIR/$TMPOUTFILE + TFILE=$TMPOUTFILE + fi + + # Run test. + TESTING $FORMCONV $3 $4 $5 $6 $2 + ( + cd $TESTDIR + $RUNSERIAL $FORMCONV_BIN $3 $4 $5 $6 $TFILE + ) >$actual 2>$actual_err + cp $actual $actual_sav + cp $actual_err $actual_err_sav + STDERR_FILTER $actual_err + + # Extract file name, line number, version and thread IDs because they may be different + sed -e 's/thread [0-9]*/thread (IDs)/' -e 's/: .*\.c /: (file name) /' \ + -e 's/line [0-9]*/line (number)/' \ + -e 's/v[1-9]*\.[0-9]*\./version (number)\./' \ + -e 's/[1-9]*\.[0-9]*\.[0-9]*[^)]*/version (number)/' \ + -e 's/H5Eget_auto[1-2]*/H5Eget_auto(1 or 2)/' \ + -e 's/H5Eset_auto[1-2]*/H5Eset_auto(1 or 2)/' \ + $actual_err > $actual_ext + + # Compare output + if $CMP $expect $actual; then + if $CMP $expect_err $actual_ext; then + echo " PASSED" + else + echo "*FAILED*" + echo " Expected result (*.err) differs from actual result (*.oerr)" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF $expect_err $actual_ext |sed 's/^/ /' + fi + else + echo "*FAILED*" + echo " Expected result (*.ddl) differs from actual result (*.out)" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' + fi + COMPARE_OUT $expect_err $actual_err + + # Clean up output file + if test -z "$HDF5_NOCLEANUP"; then + $RM $actual $actual_err + $RM $actual $actual_err $actual_sav $actual_err_sav fi } -# To check that the tool exits success, no output +# To check that the tool exits success, no output # Assume all short options -# $1 is the test file name -# --fname exists -# --fname is copied to a temporary file for testing -# $2 is the temporary file name +# $1 is the test file name +# --fname exists +# --fname is copied to a temporary file for testing +# $2 is the temporary file name # $3 to at most $5--options to the tool such as: -# -d dname -# -n +# -d dname +# -n TOOLTEST() { TESTING $FORMCONV $3 $4 $5 $1 $RM $TESTDIR/$2 @@ -260,11 +323,11 @@ TOOLTEST() { $RUNSERIAL $FORMCONV_BIN $3 $4 $5 $TESTDIR/$2 exitcode=$? if [ $exitcode -ne 0 ]; then - echo "*FAILED*" - echo " The tool exits failure" - nerrors="`expr $nerrors + 1`" + echo "*FAILED*" + echo " The tool exits failure" + nerrors="`expr $nerrors + 1`" else - echo " PASSED" + echo " PASSED" fi } @@ -280,11 +343,11 @@ IDX_CHECK() { $RUNSERIAL $CHK_IDX_BIN $TESTDIR/$TMPCHKFILE $1 ret=$? if [ $ret -eq 0 ]; then - echo " PASSED" + echo " PASSED" else - echo "*FAILED*" - echo " The chunk indexing type is not correct" - nerrors="`expr $nerrors + 1`" + echo "*FAILED*" + echo " The chunk indexing type is not correct" + nerrors="`expr $nerrors + 1`" fi } @@ -317,7 +380,7 @@ H5DUMP_CHECK() { # Clean up output file if test -z "$HDF5_NOCLEANUP"; then - $RM $actual $actual_err + $RM $actual $actual_err fi } @@ -326,12 +389,12 @@ SKIP() { TESTING $STAT $@ echo " -SKIP-" } - + ############################################################################## ############################################################################## -### T H E T E S T S ### +### T H E T E S T S ### ############################################################################## ############################################################################## # prepare for test @@ -377,7 +440,7 @@ TOOLTEST_OUT h5fc_v_n_all.ddl h5fc_non_v3.h5 -v -n # # # h5format_convert -v h5fc_err_level.h5 (error encountered in converting the dataset) -TOOLTEST_OUT h5fc_v_err.ddl h5fc_err_level.h5 -v +TOOLTEST_MASK_OUT h5fc_v_err.ddl h5fc_err_level.h5 -v # # # @@ -436,7 +499,7 @@ TOOLTEST h5fc_non_v3.h5 $TMPFILE -n # # No output from tests: just check exit code # h5format_convert h5fc_non_v3.h5 -# 1) convert all datasets +# 1) convert all datasets # 2) verify indexing types TOOLTEST h5fc_non_v3.h5 $TMPCHKFILE IDX_CHECK /DSET_NDATA_EA -- cgit v0.12 From 4ab2d9f010e7cf76ae81122a627c10c03e8cd00c Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 18 Oct 2017 16:19:32 -0500 Subject: Correct name of file --- tools/test/h5format_convert/testfiles/h5fc_v_err.ddl.err | 8 ++++++++ tools/test/h5format_convert/testfiles/h5fc_v_err.err | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-) create mode 100644 tools/test/h5format_convert/testfiles/h5fc_v_err.ddl.err delete mode 100644 tools/test/h5format_convert/testfiles/h5fc_v_err.err diff --git a/tools/test/h5format_convert/testfiles/h5fc_v_err.ddl.err b/tools/test/h5format_convert/testfiles/h5fc_v_err.ddl.err new file mode 100644 index 0000000..d85a999 --- /dev/null +++ b/tools/test/h5format_convert/testfiles/h5fc_v_err.ddl.err @@ -0,0 +1,8 @@ +h5format_convert error: unable to downgrade dataset "/DSET_ERR" +H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): + #000: (file name) line (number) in h5trav_visit(): traverse failed + major: Failure in tools library + minor: error in function + #001: (file name) line (number) in traverse(): H5Lvisit_by_name failed + major: Failure in tools library + minor: error in function diff --git a/tools/test/h5format_convert/testfiles/h5fc_v_err.err b/tools/test/h5format_convert/testfiles/h5fc_v_err.err deleted file mode 100644 index d85a999..0000000 --- a/tools/test/h5format_convert/testfiles/h5fc_v_err.err +++ /dev/null @@ -1,8 +0,0 @@ -h5format_convert error: unable to downgrade dataset "/DSET_ERR" -H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): - #000: (file name) line (number) in h5trav_visit(): traverse failed - major: Failure in tools library - minor: error in function - #001: (file name) line (number) in traverse(): H5Lvisit_by_name failed - major: Failure in tools library - minor: error in function -- cgit v0.12 From d9e7aad64b590280ac73842c45400210d0755110 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 18 Oct 2017 16:33:00 -0500 Subject: Remove extra command line --- tools/test/h5format_convert/testh5fc.sh.in | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/test/h5format_convert/testh5fc.sh.in b/tools/test/h5format_convert/testh5fc.sh.in index 9250df3..585d389 100644 --- a/tools/test/h5format_convert/testh5fc.sh.in +++ b/tools/test/h5format_convert/testh5fc.sh.in @@ -298,7 +298,6 @@ TOOLTEST_MASK_OUT() { nerrors="`expr $nerrors + 1`" test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' fi - COMPARE_OUT $expect_err $actual_err # Clean up output file if test -z "$HDF5_NOCLEANUP"; then -- cgit v0.12 From afeaceef5fe47a82cf7dbf536dbbe45cbda72500 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 19 Oct 2017 12:45:17 -0500 Subject: Windows had issues - revert code changes for get_option --- tools/lib/h5tools_utils.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c index 1b5911b..a081c7e 100644 --- a/tools/lib/h5tools_utils.c +++ b/tools/lib/h5tools_utils.c @@ -205,8 +205,9 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti opt_opt = l_opts[i].shortval; if (l_opts[i].has_arg != no_arg) { - if (arg[len] == '=') + if (arg[len] == '=') { opt_arg = &arg[len + 1]; + } else if (l_opts[i].has_arg != optional_arg) { if (opt_ind < (argc - 1)) if (argv[opt_ind + 1][0] != '-') @@ -295,13 +296,16 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti opt_ind++; /* we do have an extra argument, check if not last */ if ( (opt_ind+1) < argc ) { - if ( argv[opt_ind][0] != '-' ) + if ( argv[opt_ind][0] != '-' ) { opt_arg = argv[opt_ind++]; - else + } + else { opt_arg = NULL; + } } - else + else { opt_arg = NULL; + } } else { /* set up to look at next char in token, next time */ -- cgit v0.12 From 8e30e7eb19d251089e44256ec5d409badbaf4b39 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 19 Oct 2017 16:51:43 -0500 Subject: Avoid double free --- tools/lib/h5diff_array.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c index 54b9109..11f5e41 100644 --- a/tools/lib/h5diff_array.c +++ b/tools/lib/h5diff_array.c @@ -4258,9 +4258,6 @@ int ull2float(unsigned long long ull_value, float *f_value) HDmemcpy(f_value, buf, dst_size); - if (buf) - HDfree(buf); - done: H5E_BEGIN_TRY { H5Pclose(dxpl_id); -- cgit v0.12 From 1d3b4f6ac9075a2f6ee0c7055e7b5763c346eb78 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Thu, 19 Oct 2017 15:30:57 -0700 Subject: Moved the 'cache image + SWMR' check from H5Fcreate/open to H5F_open. Prep for the VOL merge. --- src/H5F.c | 18 +----------------- src/H5Fint.c | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/H5F.c b/src/H5F.c index 211f1aa..39eca13 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -443,8 +443,6 @@ done: hid_t H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id) { - hbool_t ci_load = FALSE; /* whether MDC ci load requested */ - hbool_t ci_write = FALSE; /* whether MDC CI write requested */ H5F_t *new_file = NULL; /*file struct for new file */ hid_t dxpl_id = H5AC_ind_read_dxpl_id; /*dxpl used by library */ hid_t ret_value; /*return value */ @@ -490,12 +488,6 @@ H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id) if(NULL == (new_file = H5F_open(filename, flags, fcpl_id, fapl_id, dxpl_id))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to create file") - /* Check to see if both SWMR and cache image are requested. Fail if so */ - if(H5C_cache_image_status(new_file, &ci_load, &ci_write) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get MDC cache image status") - if((ci_load || ci_write) && (flags & (H5F_ACC_SWMR_READ | H5F_ACC_SWMR_WRITE))) - HGOTO_ERROR(H5E_FILE, H5E_UNSUPPORTED, FAIL, "can't have both SWMR and cache image") - /* Get an atom for the file */ if((ret_value = H5I_register(H5I_FILE, new_file, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file") @@ -554,8 +546,6 @@ done: hid_t H5Fopen(const char *filename, unsigned flags, hid_t fapl_id) { - hbool_t ci_load = FALSE; /* whether MDC ci load requested */ - hbool_t ci_write = FALSE; /* whether MDC CI write requested */ H5F_t *new_file = NULL; /*file struct for new file */ hid_t dxpl_id = H5AC_ind_read_dxpl_id; /*dxpl used by library */ hid_t ret_value; /*return value */ @@ -585,12 +575,6 @@ H5Fopen(const char *filename, unsigned flags, hid_t fapl_id) if(NULL == (new_file = H5F_open(filename, flags, H5P_FILE_CREATE_DEFAULT, fapl_id, dxpl_id))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to open file") - /* Check to see if both SWMR and cache image are requested. Fail if so */ - if(H5C_cache_image_status(new_file, &ci_load, &ci_write) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get MDC cache image status") - if((ci_load || ci_write) && (flags & (H5F_ACC_SWMR_READ | H5F_ACC_SWMR_WRITE))) - HGOTO_ERROR(H5E_FILE, H5E_UNSUPPORTED, FAIL, "can't have both SWMR and cache image") - /* Get an atom for the file */ if((ret_value = H5I_register(H5I_FILE, new_file, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle") @@ -1649,7 +1633,7 @@ H5Fstart_swmr_write(hid_t file_id) /* Flush the superblock extension */ if(H5F_flush_tagged_metadata(file, file->shared->sblock->ext_addr, H5AC_ind_read_dxpl_id) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, NULL, "unable to flush superblock extension") + HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush superblock extension") /* Flush data buffers */ if(H5F__flush(file, H5AC_ind_read_dxpl_id, H5AC_rawdata_dxpl_id, FALSE) < 0) diff --git a/src/H5Fint.c b/src/H5Fint.c index 4c5e00e..4333e93 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -1186,6 +1186,9 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5F_t *ret_value = NULL; /*actual return value */ char *lock_env_var = NULL;/*env var pointer */ hbool_t use_file_locking; /*read from env var */ + hbool_t ci_load = FALSE; /* whether MDC ci load requested */ + hbool_t ci_write = FALSE; /* whether MDC CI write requested */ + hbool_t ci_swmr_fail = FALSE; /* set w/ SWMR + cache image */ FUNC_ENTER_NOAPI(NULL) @@ -1490,13 +1493,26 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, } /* end else */ } /* end if set_flag */ + /* Check to see if both SWMR and cache image are requested. Fail if so */ + if(H5C_cache_image_status(file, &ci_load, &ci_write) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't get MDC cache image status") + if((ci_load || ci_write) && (flags & (H5F_ACC_SWMR_READ | H5F_ACC_SWMR_WRITE))) { + ci_swmr_fail = TRUE; + HGOTO_ERROR(H5E_FILE, H5E_UNSUPPORTED, NULL, "can't have both SWMR and cache image") + } + /* Success */ ret_value = file; done: - if((NULL == ret_value) && file) + if(ci_swmr_fail) { + if(H5F_try_close(file, NULL) < 0) + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file") + } + else if((NULL == ret_value) && file) { if(H5F__dest(file, meta_dxpl_id, raw_dxpl_id, FALSE) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file") + } FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_open() */ -- cgit v0.12 From 18ba8cb7d247cc2f535e53d66c2a47740724de6a Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Fri, 20 Oct 2017 08:29:31 -0500 Subject: Windows cannot share files easily --- tools/test/misc/CMakeTestsClear.cmake | 38 +++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/tools/test/misc/CMakeTestsClear.cmake b/tools/test/misc/CMakeTestsClear.cmake index b9095fb..fb4826b 100644 --- a/tools/test/misc/CMakeTestsClear.cmake +++ b/tools/test/misc/CMakeTestsClear.cmake @@ -55,6 +55,36 @@ ############################################################################## ############################################################################## + # Need special dependencies for tests that use the same reference file + # This is an issue on Windows + macro (ADD_H5_USAGE testname resultfile resultcode) + if (NOT HDF5_ENABLE_USING_MEMCHECKER) + add_test ( + NAME H5CLEAR_USAGE-${testname}-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + testfiles/${testname}.out + testfiles/${testname}.out.err + ) + if (NOT "${last_test}" STREQUAL "") + set_tests_properties (H5CLEAR_USAGE-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) + endif () + add_test ( + NAME H5CLEAR_USAGE-${testname} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=${ARGN}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" + -D "TEST_OUTPUT=${testname}.out" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_REFERENCE=${resultfile}.ddl" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + set_tests_properties (H5CLEAR_USAGE-${testname} PROPERTIES DEPENDS H5CLEAR_USAGE-${testname}-clear-objects) + set (last_test "H5CLEAR_USAGE-${testname}") + endif () + endmacro () + macro (ADD_H5_CMP testname resultfile resultcode) if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( @@ -212,10 +242,10 @@ endif() # "h5clear -m -s junk.h5" (valid 2 options, nonexisting file) # "h5clear -m orig_h5clear_sec2_v2.h5" (valid 1 option, existing file, no cache image) # "h5clear -s -m orig_h5clear_sec2_v0.h5" (valid 2 options, existing file, no cache image) - ADD_H5_CMP (h5clr_usage_h h5clear_usage 0 "-h") - ADD_H5_CMP (h5clr_usage h5clear_usage 1 "") - ADD_H5_CMP (h5clr_usage_junk h5clear_usage 1 "" junk.h5) - ADD_H5_CMP (h5clr_usage_none h5clear_usage 1 "" orig_h5clear_sec2_v3.h5) + ADD_H5_USAGE (h5clr_usage_h h5clear_usage 0 "-h") + ADD_H5_USAGE (h5clr_usage h5clear_usage 1 "") + ADD_H5_USAGE (h5clr_usage_junk h5clear_usage 1 "" junk.h5) + ADD_H5_USAGE (h5clr_usage_none h5clear_usage 1 "" orig_h5clear_sec2_v3.h5) ADD_H5_CMP (h5clr_missing_file_m h5clear_missing_file 1 "-m") ADD_H5_CMP (h5clr_open_fail_s h5clear_open_fail 1 "-s" junk.h5) ADD_H5_CMP (h5clr_missing_file_ms h5clear_missing_file 1 "-m" "-s") -- cgit v0.12 From c2be993f325813e711ee7cc97bb02b7b482a8290 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Fri, 20 Oct 2017 09:37:12 -0500 Subject: HDFFV-10297 Windows issues fixed --- tools/test/misc/CMakeTestsClear.cmake | 40 +++++++---------------------------- 1 file changed, 8 insertions(+), 32 deletions(-) diff --git a/tools/test/misc/CMakeTestsClear.cmake b/tools/test/misc/CMakeTestsClear.cmake index fb4826b..942ae7a 100644 --- a/tools/test/misc/CMakeTestsClear.cmake +++ b/tools/test/misc/CMakeTestsClear.cmake @@ -57,34 +57,6 @@ # Need special dependencies for tests that use the same reference file # This is an issue on Windows - macro (ADD_H5_USAGE testname resultfile resultcode) - if (NOT HDF5_ENABLE_USING_MEMCHECKER) - add_test ( - NAME H5CLEAR_USAGE-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - testfiles/${testname}.out - testfiles/${testname}.out.err - ) - if (NOT "${last_test}" STREQUAL "") - set_tests_properties (H5CLEAR_USAGE-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () - add_test ( - NAME H5CLEAR_USAGE-${testname} - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$" - -D "TEST_ARGS:STRING=${ARGN}" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" - -D "TEST_OUTPUT=${testname}.out" - -D "TEST_EXPECT=${resultcode}" - -D "TEST_REFERENCE=${resultfile}.ddl" - -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" - ) - set_tests_properties (H5CLEAR_USAGE-${testname} PROPERTIES DEPENDS H5CLEAR_USAGE-${testname}-clear-objects) - set (last_test "H5CLEAR_USAGE-${testname}") - endif () - endmacro () - macro (ADD_H5_CMP testname resultfile resultcode) if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( @@ -94,6 +66,9 @@ testfiles/${testname}.out testfiles/${testname}.out.err ) + if (NOT "${last_test}" STREQUAL "") + set_tests_properties (H5CLEAR_CMP-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) + endif () add_test ( NAME H5CLEAR_CMP-${testname} COMMAND "${CMAKE_COMMAND}" @@ -106,6 +81,7 @@ -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) set_tests_properties (H5CLEAR_CMP-${testname} PROPERTIES DEPENDS H5CLEAR_CMP-${testname}-clear-objects) + set (last_test "H5CLEAR_CMP-${testname}") endif () endmacro () @@ -242,10 +218,10 @@ endif() # "h5clear -m -s junk.h5" (valid 2 options, nonexisting file) # "h5clear -m orig_h5clear_sec2_v2.h5" (valid 1 option, existing file, no cache image) # "h5clear -s -m orig_h5clear_sec2_v0.h5" (valid 2 options, existing file, no cache image) - ADD_H5_USAGE (h5clr_usage_h h5clear_usage 0 "-h") - ADD_H5_USAGE (h5clr_usage h5clear_usage 1 "") - ADD_H5_USAGE (h5clr_usage_junk h5clear_usage 1 "" junk.h5) - ADD_H5_USAGE (h5clr_usage_none h5clear_usage 1 "" orig_h5clear_sec2_v3.h5) + ADD_H5_CMP (h5clr_usage_h h5clear_usage 0 "-h") + ADD_H5_CMP (h5clr_usage h5clear_usage 1 "") + ADD_H5_CMP (h5clr_usage_junk h5clear_usage 1 "" junk.h5) + ADD_H5_CMP (h5clr_usage_none h5clear_usage 1 "" orig_h5clear_sec2_v3.h5) ADD_H5_CMP (h5clr_missing_file_m h5clear_missing_file 1 "-m") ADD_H5_CMP (h5clr_open_fail_s h5clear_open_fail 1 "-s" junk.h5) ADD_H5_CMP (h5clr_missing_file_ms h5clear_missing_file 1 "-m" "-s") -- cgit v0.12 From d8a3782ce49d537d96020dfa250a253d90f4c14f Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Fri, 20 Oct 2017 17:25:18 -0700 Subject: Moved the SWMR + cache image check up before the root group is constructed to avoid the special case close. --- src/H5Fint.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/H5Fint.c b/src/H5Fint.c index 4333e93..7371c46 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -1188,7 +1188,6 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hbool_t use_file_locking; /*read from env var */ hbool_t ci_load = FALSE; /* whether MDC ci load requested */ hbool_t ci_write = FALSE; /* whether MDC CI write requested */ - hbool_t ci_swmr_fail = FALSE; /* set w/ SWMR + cache image */ FUNC_ENTER_NOAPI(NULL) @@ -1322,6 +1321,12 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, set_flag = TRUE; } /* end else */ + /* Check to see if both SWMR and cache image are requested. Fail if so */ + if(H5C_cache_image_status(file, &ci_load, &ci_write) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't get MDC cache image status") + if((ci_load || ci_write) && (flags & (H5F_ACC_SWMR_READ | H5F_ACC_SWMR_WRITE))) + HGOTO_ERROR(H5E_FILE, H5E_UNSUPPORTED, NULL, "can't have both SWMR and cache image") + /* Retain the name the file was opened with */ file->open_name = H5MM_xstrdup(name); @@ -1493,26 +1498,14 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, } /* end else */ } /* end if set_flag */ - /* Check to see if both SWMR and cache image are requested. Fail if so */ - if(H5C_cache_image_status(file, &ci_load, &ci_write) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't get MDC cache image status") - if((ci_load || ci_write) && (flags & (H5F_ACC_SWMR_READ | H5F_ACC_SWMR_WRITE))) { - ci_swmr_fail = TRUE; - HGOTO_ERROR(H5E_FILE, H5E_UNSUPPORTED, NULL, "can't have both SWMR and cache image") - } - /* Success */ ret_value = file; done: - if(ci_swmr_fail) { - if(H5F_try_close(file, NULL) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file") - } - else if((NULL == ret_value) && file) { + if((NULL == ret_value) && file) if(H5F__dest(file, meta_dxpl_id, raw_dxpl_id, FALSE) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file") - } + FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_open() */ -- cgit v0.12 From e92f3f858bf16a84c59aeb6692f5cab5e6b8e66f Mon Sep 17 00:00:00 2001 From: lrknox Date: Sun, 22 Oct 2017 22:35:15 -0500 Subject: Fix for HDFFFV-10308. Initialize hid_ts in function check_objects and check for id > -1 before calling close functions. --- tools/src/h5repack/h5repack.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tools/src/h5repack/h5repack.c b/tools/src/h5repack/h5repack.c index 14b9461..22ca279 100644 --- a/tools/src/h5repack/h5repack.c +++ b/tools/src/h5repack/h5repack.c @@ -707,9 +707,9 @@ done: */ static int check_objects(const char* fname, pack_opt_t *options) { int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ - hid_t fid; - hid_t did; - hid_t sid; + hid_t fid = -1; + hid_t did = -1; + hid_t sid = -1; unsigned int i; unsigned int uf; trav_table_t *travt = NULL; @@ -810,9 +810,12 @@ static int check_objects(const char* fname, pack_opt_t *options) { done: H5E_BEGIN_TRY { - H5Sclose(sid); - H5Dclose(did); - H5Fclose(fid); + if (sid > -1) + H5Sclose(sid); + if (did > -1) + H5Dclose(did); + if (fid > -1) + H5Fclose(fid); } H5E_END_TRY; if (travt) trav_table_free(travt); -- cgit v0.12 From 8e2cedd066e4569bf36b530495bd2f811d95f808 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 23 Oct 2017 09:26:15 -0500 Subject: HDFFV-10297 Cleanup, Initialize variables --- tools/lib/h5diff_dset.c | 2 +- tools/lib/h5tools.c | 464 +++++++++++++++---------------------- tools/lib/h5tools_dump.c | 11 +- tools/lib/h5tools_str.c | 8 +- tools/lib/h5tools_utils.c | 5 +- tools/src/h5repack/h5repack.c | 8 +- tools/src/h5repack/h5repack_copy.c | 28 +-- tools/src/h5repack/h5repack_refs.c | 15 +- 8 files changed, 224 insertions(+), 317 deletions(-) diff --git a/tools/lib/h5diff_dset.c b/tools/lib/h5diff_dset.c index b03295b..ee42b99 100644 --- a/tools/lib/h5diff_dset.c +++ b/tools/lib/h5diff_dset.c @@ -189,7 +189,7 @@ hsize_t diff_datasetid(hid_t did1, void *buf2 = NULL; void *sm_buf1 = NULL; void *sm_buf2 = NULL; - hid_t sm_space; /*stripmine data space */ + hid_t sm_space = -1; /*stripmine data space */ size_t need; /* bytes needed for malloc */ int i; unsigned int vl_data = 0; /*contains VL datatypes */ diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index 344913a..6ea5e47 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -23,10 +23,10 @@ #include "H5private.h" /* global variables */ -hid_t H5tools_ERR_STACK_g = 0; -hid_t H5tools_ERR_CLS_g = -1; -hid_t H5E_tools_g = -1; -hid_t H5E_tools_min_id_g = -1; +hid_t H5tools_ERR_STACK_g = 0; +hid_t H5tools_ERR_CLS_g = -1; +hid_t H5E_tools_g = -1; +hid_t H5E_tools_min_id_g = -1; int compound_data; FILE *rawattrstream = NULL; /* should initialize to stdout but gcc moans about it */ FILE *rawdatastream = NULL; /* should initialize to stdout but gcc moans about it */ @@ -77,18 +77,13 @@ typedef enum { #define NUM_DRIVERS (sizeof(drivernames) / sizeof(drivernames[0])) /*------------------------------------------------------------------------- - * Audience: Public - * Chapter: H5Tools Library - * Purpose: Initialize the H5 Tools library - * Description: - * This should be called before any other h5tools function is called. - * Effect of any h5tools function called before this has been called is - * undetermined. - * Return: - * None - * Programmer: - * Albert Cheng, 2000-10-31 - * Modifications: + * Function: h5tools_init + * + * Purpose: This should be called before any other h5tools function is called. + * Effect of any h5tools function called before this has been called is + * undetermined. + * + * Return None *------------------------------------------------------------------------- */ void @@ -121,19 +116,14 @@ h5tools_init(void) } /*------------------------------------------------------------------------- - * Audience: Public - * Chapter: H5Tools Library - * Purpose: Close the H5 Tools library - * Description: - * Close or release resources such as files opened by the library. This - * should be called after all other h5tools functions have been called. - * Effect of any h5tools function called after this has been called is - * undetermined. - * Return: - * None - * Programmer: - * Albert Cheng, 2000-10-31 - * Modifications: + * Function: h5tools_close + * + * Purpose: Close or release resources such as files opened by the library. This + * should be called after all other h5tools functions have been called. + * Effect of any h5tools function called after this has been called is + * undetermined. + * + * Return: None *------------------------------------------------------------------------- */ void @@ -193,19 +183,13 @@ h5tools_close(void) } /*------------------------------------------------------------------------- - * Function: h5tools_set_data_output_file - * - * Purpose: Open fname as the output file for dataset raw data. - * Set rawdatastream as its file stream. + * Function: h5tools_set_data_output_file * - * Return: 0 -- succeeded - * negative -- failed - * - * Programmer: Albert Cheng, 2000/09/30 - * - * Modifications: - * pvn June, 1, 2006. Add a switch for binary output + * Purpose: Open fname as the output file for dataset raw data. + * Set rawdatastream as its file stream. * + * Return: 0 -- succeeded + * negative -- failed *------------------------------------------------------------------------- */ int @@ -247,14 +231,13 @@ h5tools_set_data_output_file(const char *fname, int is_bin) } /*------------------------------------------------------------------------- - * Function: h5tools_set_attr_output_file + * Function: h5tools_set_attr_output_file * - * Purpose: Open fname as the output file for attribute raw data. - * Set rawattrstream as its file stream. - * - * Return: 0 -- succeeded - * negative -- failed + * Purpose: Open fname as the output file for attribute raw data. + * Set rawattrstream as its file stream. * + * Return: 0 -- succeeded + * negative -- failed *------------------------------------------------------------------------- */ int @@ -296,13 +279,13 @@ h5tools_set_attr_output_file(const char *fname, int is_bin) } /*------------------------------------------------------------------------- - * Function: h5tools_set_input_file + * Function: h5tools_set_input_file * - * Purpose: Open fname as the input file for raw input. - * Set rawinstream as its file stream. + * Purpose: Open fname as the input file for raw input. + * Set rawinstream as its file stream. * - * Return: 0 -- succeeded - * negative -- failed + * Return: 0 -- succeeded + * negative -- failed * *------------------------------------------------------------------------- */ @@ -344,13 +327,13 @@ h5tools_set_input_file(const char *fname, int is_bin) } /*------------------------------------------------------------------------- - * Function: h5tools_set_output_file + * Function: h5tools_set_output_file * - * Purpose: Open fname as the output file for raw output. - * Set rawoutstream as its file stream. + * Purpose: Open fname as the output file for raw output. + * Set rawoutstream as its file stream. * - * Return: 0 -- succeeded - * negative -- failed + * Return: 0 -- succeeded + * negative -- failed * *------------------------------------------------------------------------- */ @@ -392,14 +375,13 @@ h5tools_set_output_file(const char *fname, int is_bin) } /*------------------------------------------------------------------------- - * Function: h5tools_set_error_file - * - * Purpose: Open fname as the error output file for dataset raw error. - * Set rawerrorstream as its file stream. + * Function: h5tools_set_error_file * - * Return: 0 -- succeeded - * negative -- failed + * Purpose: Open fname as the error output file for dataset raw error. + * Set rawerrorstream as its file stream. * + * Return: 0 -- succeeded + * negative -- failed *------------------------------------------------------------------------- */ int @@ -441,33 +423,28 @@ h5tools_set_error_file(const char *fname, int is_bin) } /*------------------------------------------------------------------------- - * Audience: Private - * Chapter: H5Tools Library - * Purpose: Get a FAPL for a driver - * Description: - * Get a FAPL for a given VFL driver name. - * Return: - * None - * Programmer: - * Quincey Koziol, 2004-02-04 - * Modifications: - * Pedro Vicente Nunes, Thursday, July 27, 2006 - * Added error return conditions for the H5Pset_fapl calls + * Function: h5tools_get_fapl + * + * Purpose: Get a FAPL for a given VFL driver name. + * + * Return: positive - succeeded + * negative - failed *------------------------------------------------------------------------- */ static hid_t h5tools_get_fapl(hid_t fapl, const char *driver, unsigned *drivernum) { - hid_t new_fapl; /* Copy of file access property list passed in, or new property list */ + hid_t new_fapl = -1; /* Copy of file access property list passed in, or new property list */ + int ret_value = SUCCEED; /* Make a copy of the FAPL, for the file open call to use, eventually */ if (fapl == H5P_DEFAULT) { if ((new_fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcreate failed"); } /* end if */ else { if ((new_fapl = H5Pcopy(fapl)) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcopy failed"); } /* end else */ /* Determine which driver the user wants to open the file with. Try @@ -475,7 +452,7 @@ h5tools_get_fapl(hid_t fapl, const char *driver, unsigned *drivernum) if (!HDstrcmp(driver, drivernames[SEC2_IDX])) { /* SEC2 driver */ if (H5Pset_fapl_sec2(new_fapl) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_fapl_sec2 failed"); if (drivernum) *drivernum = SEC2_IDX; @@ -487,7 +464,7 @@ h5tools_get_fapl(hid_t fapl, const char *driver, unsigned *drivernum) * is the member size. */ if (H5Pset_fapl_family(new_fapl, (hsize_t) 0, H5P_DEFAULT) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_fapl_family failed"); if (drivernum) *drivernum = FAMILY_IDX; @@ -495,7 +472,7 @@ h5tools_get_fapl(hid_t fapl, const char *driver, unsigned *drivernum) else if (!HDstrcmp(driver, drivernames[SPLIT_IDX])) { /* SPLIT Driver */ if (H5Pset_fapl_split(new_fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_fapl_split failed"); if (drivernum) *drivernum = SPLIT_IDX; @@ -503,7 +480,7 @@ h5tools_get_fapl(hid_t fapl, const char *driver, unsigned *drivernum) else if (!HDstrcmp(driver, drivernames[MULTI_IDX])) { /* MULTI Driver */ if (H5Pset_fapl_multi(new_fapl, NULL, NULL, NULL, NULL, TRUE) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_fapl_multi failed"); if(drivernum) *drivernum = MULTI_IDX; @@ -519,29 +496,28 @@ h5tools_get_fapl(hid_t fapl, const char *driver, unsigned *drivernum) if(mpi_initialized && !mpi_finalized) { if(H5Pset_fapl_mpio(new_fapl, MPI_COMM_WORLD, MPI_INFO_NULL) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_fapl_mpio failed"); if(drivernum) *drivernum = MPIO_IDX; } /* end if */ } #endif /* H5_HAVE_PARALLEL */ else - goto error; + ret_value = -1; - return(new_fapl); - -error: - if(new_fapl != H5P_DEFAULT) +done: + if((new_fapl != H5P_DEFAULT) && (ret_value < 0)) { H5Pclose(new_fapl); - return -1; + new_fapl = -1; + } + + return(new_fapl); } /*------------------------------------------------------------------------- - * Audience: Public - * Chapter: H5Tools Library - * Purpose: Open a file with various VFL drivers. - * Description: - * Loop through the various types of VFL drivers trying to open FNAME. + * Function: h5tools_fopen + * + * Purpose: Loop through the various types of VFL drivers trying to open FNAME. * If the HDF5 library is version 1.2 or less, then we have only the SEC2 * driver to try out. If the HDF5 library is greater than version 1.2, * then we have the FAMILY, SPLIT, and MULTI drivers to play with. @@ -549,6 +525,7 @@ error: * If DRIVER is non-NULL, then it will try to open the file with that * driver first. We assume that the user knows what they are doing so, if * we fail, then we won't try other file drivers. + * * Return: * On success, returns a file id for the opened file. If DRIVERNAME is * non-null then the first DRIVERNAME_SIZE-1 characters of the driver @@ -556,38 +533,6 @@ error: * * Otherwise, the function returns FAIL. If DRIVERNAME is non-null then * the first byte is set to the null terminator. - * Programmer: - * Lost in the mists of time. - * Modifications: - * Robb Matzke, 2000-06-23 - * We only have to initialize driver[] on the first call, thereby - * preventing memory leaks from repeated calls to H5Pcreate(). - * - * Robb Matzke, 2000-06-23 - * Added DRIVERNAME_SIZE arg to prevent overflows when writing to - * DRIVERNAME. - * - * Robb Matzke, 2000-06-23 - * Added test to prevent coredump when the file could not be opened by - * any driver. - * - * Robb Matzke, 2000-06-23 - * Changed name from H5ToolsFopen() so it jives better with the names we - * already have at the top of this source file. - * - * Thomas Radke, 2000-09-12 - * Added Stream VFD to the driver[] array. - * - * Bill Wendling, 2001-01-10 - * Changed macro behavior so that if we have a version other than 1.2.x - * (i.e., > 1.2), then we do the drivers check. - * - * Bill Wendling, 2001-07-30 - * Added DRIVER parameter so that the user can specify "try this driver" - * instead of the default behaviour. If it fails to open the file with - * that driver, this will fail completely (i.e., we won't try the other - * drivers). We're assuming the user knows what they're doing. How UNIX - * of us. *------------------------------------------------------------------------- */ hid_t @@ -652,18 +597,13 @@ done: } /*------------------------------------------------------------------------- - * Audience: Public - * Chapter: H5Tools Library - * Purpose: Count the number of columns in a string. - * Description: - * Count the number of columns in a string. This is the number of - * characters in the string not counting line-control characters. - * Return: - * On success, returns the width of the string. Otherwise this function - * returns 0. - * Programmer: - * Robb Matzke, Tuesday, April 27, 1999 - * Modifications: + * Function: h5tools_count_ncols + * + * Purpose: Count the number of columns in a string. This is the number of + * characters in the string not counting line-control characters. + * + * Return: success - returns the width of the string. + * failure - 0. *------------------------------------------------------------------------- */ H5_ATTR_PURE static size_t @@ -681,20 +621,17 @@ h5tools_count_ncols(const char *s) /*------------------------------------------------------------------------- * Function: h5tools_detect_vlen * - * Purpose: Recursive check for any variable length data in given type. + * Purpose: Recursive check for any variable length data in given type. * - * Return: - * TRUE : type conatains any variable length data - * FALSE : type doesn't contain any variable length data - * Negative value: error occur - * - * Programmer: Jonathan Kim March 18, 2011 + * Return: TRUE : type conatains any variable length data + * FALSE : type doesn't contain any variable length data + * Negative value: error occur *------------------------------------------------------------------------- */ htri_t h5tools_detect_vlen(hid_t tid) { - htri_t ret; + htri_t ret = FALSE; /* recursive detect any vlen data values in type (compound, array ...) */ ret = H5Tdetect_class(tid, H5T_VLEN); @@ -713,20 +650,18 @@ done: /*------------------------------------------------------------------------- * Function: h5tools_detect_vlen_str * - * Purpose: Recursive check for variable length string of a datatype. - * - * Return: - * TRUE : type conatains any variable length string - * FALSE : type doesn't contain any variable length string - * Negative value: error occur + * Purpose: Recursive check for variable length string of a datatype. * + * Return: TRUE : type conatains any variable length string + * FALSE : type doesn't contain any variable length string + * Negative value: error occur *------------------------------------------------------------------------- */ htri_t h5tools_detect_vlen_str(hid_t tid) { H5T_class_t tclass = -1; - htri_t ret = FALSE; + htri_t ret = FALSE; ret = H5Tis_variable_str(tid); if((ret == TRUE) || (ret < 0)) @@ -774,25 +709,13 @@ done: } /*------------------------------------------------------------------------- - * Audience: Public - * Chapter: H5Tools Library - * Purpose: Emit a simple prefix to STREAM. - * Description: - * If /ctx->need_prefix/ is set then terminate the current line (if - * applicable), calculate the prefix string, and display it at the start - * of a line. - * Return: - * None - * Programmer: - * Robb Matzke, Monday, April 26, 1999 - * Modifications: - * Robb Matzke, 1999-09-29 - * If a new prefix is printed then the current element number is set back - * to zero. - * pvn, 2004-07-08 - * Added support for printing array indices: - * the indentation is printed before the prefix (printed one indentation - * level before) + * Function: h5tools_simple_prefix + * + * Purpose: If /ctx->need_prefix/ is set then terminate the current line (if + * applicable), calculate the prefix string, and display it at the start + * of a line. + * + * Return: None *------------------------------------------------------------------------- */ void @@ -800,7 +723,7 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hsize_t elmtno, int secnum) { h5tools_str_t prefix; - h5tools_str_t str; /*temporary for indentation */ + h5tools_str_t str; /*temporary for indentation */ size_t templength = 0; unsigned u, indentlevel = 0; @@ -871,15 +794,13 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info, } /*------------------------------------------------------------------------- - * Audience: Public - * Chapter: H5Tools Library - * Purpose: Emit a simple prefix to STREAM. - * Description: - * If /ctx->need_prefix/ is set then terminate the current line (if - * applicable), calculate the prefix string, and display it at the start - * of a line. Calls region specific function. - * Return: - * None + * Function: h5tools_region_simple_prefix + * + * Purpose: If /ctx->need_prefix/ is set then terminate the current line (if + * applicable), calculate the prefix string, and display it at the start + * of a line. Calls region specific function. + * + * Return: None *------------------------------------------------------------------------- */ void @@ -887,7 +808,7 @@ h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hsize_t elmtno, hsize_t *ptdata, int secnum) { h5tools_str_t prefix; - h5tools_str_t str; /*temporary for indentation */ + h5tools_str_t str; /*temporary for indentation */ size_t templength = 0; unsigned u, indentlevel = 0; @@ -958,28 +879,26 @@ h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info, } /*------------------------------------------------------------------------- - * Audience: Public - * Chapter: H5Tools Library - * Purpose: Render an element to output STREAM. - * Description: - * Prints the string buffer to the output STREAM. The string is - * printed according to the format described in INFO. The CTX struct - * contains context information shared between calls to this function. + * Function: h5tools_render_element * - * Return: - * False if a dimension end is reached, otherwise true + * Purpose: Prints the string buffer to the output STREAM. The string is + * printed according to the format described in INFO. The CTX struct + * contains context information shared between calls to this function. + * + * Return: False if a dimension end is reached + * True otherwise * * In/Out: - * h5tools_context_t *ctx - * h5tools_str_t *buffer - * hsize_t *curr_pos + * h5tools_context_t *ctx + * h5tools_str_t *buffer + * hsize_t *curr_pos * * Parameters Description: - * h5tools_str_t *buffer is the string into which to render - * hsize_t curr_pos is the total data element position - * size_t ncols - * hsize_t local_elmt_counter is the local element loop counter - * hsize_t elmt_count is the data element loop counter + * h5tools_str_t *buffer is the string into which to render + * hsize_t curr_pos is the total data element position + * size_t ncols + * hsize_t local_elmt_counter is the local element loop counter + * hsize_t elmt_count is the data element loop counter *------------------------------------------------------------------------- */ hbool_t @@ -988,10 +907,10 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info, size_t ncols, hsize_t local_elmt_counter, hsize_t elmt_counter) { hbool_t dimension_break = TRUE; - char *s; - char *section; /*a section of output */ - int secnum; /*section sequence number */ - int multiline; /*datum was multiline */ + char *s = NULL; + char *section = NULL; /* a section of output */ + int secnum; /* section sequence number */ + int multiline; /* datum was multiline */ if (stream == NULL) return dimension_break; @@ -1114,29 +1033,28 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info, } /*------------------------------------------------------------------------- - * Audience: Public - * Chapter: H5Tools Library - * Purpose: Render a region element to output STREAM. - * Description: - * Prints the string buffer to the output STREAM. The string is - * printed according to the format described in INFO. The CTX struct - * contains context information shared between calls to this function. + * Function: h5tools_render_region_element + * + * Purpose: Prints the string buffer to the output STREAM. The string is + * printed according to the format described in INFO. The CTX struct + * contains context information shared between calls to this function. * * Return: - * False if a dimension end is reached, otherwise true + * False if a dimension end is reached + * True otherwise * * In/Out: - * h5tools_context_t *ctx - * h5tools_str_t *buffer - * hsize_t *curr_pos + * h5tools_context_t *ctx + * h5tools_str_t *buffer + * hsize_t *curr_pos * * Parameters Description: - * h5tools_str_t *buffer is the string into which to render - * hsize_t curr_pos is the total data element position - * size_t ncols - * hsize_t *ptdata - * hsize_t local_elmt_counter is the local element loop counter - * hsize_t elmt_count is the data element loop counter + * h5tools_str_t *buffer is the string into which to render + * hsize_t curr_pos is the total data element position + * size_t ncols + * hsize_t *ptdata + * hsize_t local_elmt_counter is the local element loop counter + * hsize_t elmt_count is the data element loop counter *------------------------------------------------------------------------- */ hbool_t @@ -1145,10 +1063,10 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, size_t ncols, hsize_t *ptdata, hsize_t local_elmt_counter, hsize_t elmt_counter) { hbool_t dimension_break = TRUE; - char *s; - char *section; /*a section of output */ - int secnum; /*section sequence number */ - int multiline; /*datum was multiline */ + char *s = NULL; + char *section = NULL; /* a section of output */ + int secnum; /* section sequence number */ + int multiline; /* datum was multiline */ s = h5tools_str_fmt(buffer, (size_t)0, "%s"); @@ -1270,11 +1188,11 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, } /*------------------------------------------------------------------------- - * Function: init_acc_pos + * Function: init_acc_pos * - * Purpose: initialize accumulator and matrix position + * Purpose: initialize accumulator and matrix position * - * Return: void + * Return: void *------------------------------------------------------------------------- */ void @@ -1295,10 +1213,10 @@ init_acc_pos(h5tools_context_t *ctx, hsize_t *dims) /*------------------------------------------------------------------------- * Function: render_bin_output * - * Purpose: Write one element of memory buffer to a binary file stream + * Purpose: Write one element of memory buffer to a binary file stream * - * Return: Success: SUCCEED - * Failure: FAIL + * Return: Success: SUCCEED + * Failure: FAIL *------------------------------------------------------------------------- */ int @@ -1344,7 +1262,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t { unsigned int i; H5T_str_t pad; - char *s; + char *s = NULL; unsigned char tempuchar; pad = H5Tget_strpad(tid); @@ -1372,7 +1290,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t break; case H5T_COMPOUND: { - int snmembs; + int snmembs; unsigned nmembs; if((snmembs = H5Tget_nmembers(tid)) < 0) @@ -1384,7 +1302,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t mem = ((unsigned char*)_mem) + block_index * size; for (j = 0; j < nmembs; j++) { - hid_t memb; + hid_t memb = -1; size_t offset; offset = H5Tget_member_offset(tid, j); @@ -1404,7 +1322,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t { int k, ndims; hsize_t dims[H5S_MAX_RANK], temp_nelmts, nelmts; - hid_t memb; + hid_t memb = -1; /* get the array's base datatype for each element */ memb = H5Tget_super(tid); @@ -1437,7 +1355,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t case H5T_VLEN: { hsize_t nelmts; - hid_t memb; + hid_t memb = -1; /* get the VL sequences's base datatype for each element */ memb = H5Tget_super(tid); @@ -1462,7 +1380,8 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t /* if (H5Tequal(tid, H5T_STD_REF_DSETREG)) */ if (region_output) { /* region data */ - hid_t region_id, region_space; + hid_t region_id = -1; + hid_t region_space = -1; H5S_sel_type region_type; for (block_index = 0; block_index < block_nelmts; block_index++) { @@ -1512,15 +1431,13 @@ CATCH } /*------------------------------------------------------------------------- - * Audience: Public - * Chapter: H5Tools Library - * Purpose: Print the data values from a dataset referenced by region blocks. + * Function: render_bin_output_region_data_blocks * - * Description: - * This is a special case subfunction to print the data in a region reference of type blocks. + * Purpose: Print the data values from a dataset referenced by region blocks. + * This is a special case subfunction to print the data in a region reference of type blocks. * - * Return: - * The function returns FAIL if there was an error, otherwise SUCEED + * Return: FAIL if there was an error + * SUCCEED otherwise * *------------------------------------------------------------------------- */ @@ -1609,16 +1526,13 @@ render_bin_output_region_data_blocks(hid_t region_id, FILE *stream, } /*------------------------------------------------------------------------- - * Audience: Public - * Chapter: H5Tools Library - * Purpose: Print some values from a dataset referenced by region blocks. - * - * Description: - * This is a special case subfunction to dump a region reference using blocks. + * Function: render_bin_output_region_blocks * - * Return: - * The function returns False if ERROR, otherwise True + * Purpose: Print some values from a dataset referenced by region blocks. + * This is a special case subfunction to dump a region reference using blocks. * + * Return: False if ERROR + * True otherwise *------------------------------------------------------------------------- */ hbool_t @@ -1629,7 +1543,7 @@ render_bin_output_region_blocks(hid_t region_space, hid_t region_id, hssize_t snblocks; hsize_t nblocks; hsize_t alloc_size; - hsize_t *ptdata; + hsize_t *ptdata = NULL; int sndims; unsigned ndims; hid_t dtype = -1; @@ -1675,8 +1589,7 @@ render_bin_output_region_blocks(hid_t region_space, hid_t region_id, } /*------------------------------------------------------------------------- - * Audience: Public - * Chapter: H5Tools Library + * Function: H5Tools Library * Purpose: Print the data values from a dataset referenced by region points. * * Description: @@ -1736,16 +1649,13 @@ render_bin_output_region_data_points(hid_t region_space, hid_t region_id, } /*------------------------------------------------------------------------- - * Audience: Public - * Chapter: H5Tools Library - * Purpose: Print some values from a dataset referenced by region points. + * Function: render_bin_output_region_points * - * Description: - * This is a special case subfunction to dump a region reference using points. - * - * Return: - * The function returns False if the last dimension has been reached, otherwise True + * Purpose: Print some values from a dataset referenced by region points. + * This is a special case subfunction to dump a region reference using points. * + * Return: False if the last dimension has been reached + * True otherwise *------------------------------------------------------------------------- */ hbool_t @@ -1791,11 +1701,12 @@ CATCH } /*------------------------------------------------------------------------- - * Function: h5tools_is_zero + * Function: h5tools_is_zero * - * Purpose: Determines if memory is initialized to all zero bytes. + * Purpose: Determines if memory is initialized to all zero bytes. * - * Return: TRUE if all bytes are zero; FALSE otherwise + * Return: TRUE if all bytes are zero + * FALSE otherwise *------------------------------------------------------------------------- */ H5_ATTR_PURE hbool_t @@ -1811,23 +1722,20 @@ h5tools_is_zero(const void *_mem, size_t size) } /*------------------------------------------------------------------------- - * Function: h5tools_is_obj_same + * Function: h5tools_is_obj_same * - * Purpose: Check if two given object IDs or link names point to the same object. + * Purpose: Check if two given object IDs or link names point to the same object. * * Parameters: - * hid_t loc_id1: location of the first object - * char *name1: link name of the first object. - * Use "." or NULL if loc_id1 is the object to be compared. - * hid_t loc_id2: location of the second object - * char *name1: link name of the first object. - * Use "." or NULL if loc_id2 is the object to be compared. - * - * Return: TRUE if it is the same object; FALSE otherwise. + * hid_t loc_id1: location of the first object + * char *name1: link name of the first object. + * Use "." or NULL if loc_id1 is the object to be compared. + * hid_t loc_id2: location of the second object + * char *name1: link name of the first object. + * Use "." or NULL if loc_id2 is the object to be compared. * - * Programmer: Peter Cao - * 4/27/2011 - * + * Return: TRUE if it is the same object + * FALSE otherwise. *------------------------------------------------------------------------- */ hbool_t diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c index f987296..ed7d38a 100644 --- a/tools/lib/h5tools_dump.c +++ b/tools/lib/h5tools_dump.c @@ -2888,7 +2888,7 @@ void h5tools_print_fill_value(h5tools_str_t *buffer/*in,out*/, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, hid_t dcpl, hid_t type_id, hid_t obj_id) { size_t size; - hid_t n_type; + hid_t n_type = -1; void *buf = NULL; n_type = H5Tget_native_type(type_id, H5T_DIR_DEFAULT); @@ -3638,7 +3638,8 @@ h5tools_dump_attribute(FILE *stream, const h5tool_format_t *info, error_msg("unable to open attribute \"%s\"\n", attr_name); } else { - hid_t type, space; + hid_t type = -1; + hid_t space = -1; ctx->indent_level++; @@ -3857,9 +3858,9 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, H5S_class_t space_type; int ndims; int i; - hid_t space; - hid_t type; - hid_t p_type; + hid_t space = -1; + hid_t type = -1; + hid_t p_type = -1; hsize_t size[64]; hsize_t alloc_size; hsize_t nelmts = 1; diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c index a66cfe5..a018394 100644 --- a/tools/lib/h5tools_str.c +++ b/tools/lib/h5tools_str.c @@ -715,10 +715,11 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai { size_t nsize, offset, size=0, nelmts, start; H5T_sign_t nsign; - char *name; + char *name = NULL; unsigned char *ucp_vp = (unsigned char *)vp; char *cp_vp = (char *)vp; - hid_t memb, obj; + hid_t memb = -1; + hid_t obj = -1; static char fmt_llong[8], fmt_ullong[8]; H5T_str_t pad; H5T_class_t type_class; @@ -1306,7 +1307,8 @@ void h5tools_str_sprint_region(h5tools_str_t *str, const h5tool_format_t *info, hid_t container, void *vp) { - hid_t obj, region; + hid_t obj = -1; + hid_t region = -1; char ref_name[1024]; H5S_sel_type region_type; diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c index a081c7e..5272e81 100644 --- a/tools/lib/h5tools_utils.c +++ b/tools/lib/h5tools_utils.c @@ -482,8 +482,7 @@ search_obj(table_t *table, haddr_t objno) *------------------------------------------------------------------------- */ static herr_t -find_objs_cb(const char *name, const H5O_info_t *oinfo, const char *already_seen, - void *op_data) +find_objs_cb(const char *name, const H5O_info_t *oinfo, const char *already_seen, void *op_data) { find_objs_t *info = (find_objs_t*)op_data; herr_t ret_value = 0; @@ -496,7 +495,7 @@ find_objs_cb(const char *name, const H5O_info_t *oinfo, const char *already_seen case H5O_TYPE_DATASET: if(NULL == already_seen) { - hid_t dset; + hid_t dset = -1; /* Add the dataset to the list of objects */ add_obj(info->dset_table, oinfo->addr, name, TRUE); diff --git a/tools/src/h5repack/h5repack.c b/tools/src/h5repack/h5repack.c index 14b9461..c98575c 100644 --- a/tools/src/h5repack/h5repack.c +++ b/tools/src/h5repack/h5repack.c @@ -374,7 +374,7 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, if ((is_named = H5Tcommitted(ftype_id)) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tcommitted failed"); if (is_named && travt) { - hid_t fidout; + hid_t fidout = -1; /* Create out file id */ if ((fidout = H5Iget_file_id(loc_out)) < 0) @@ -707,9 +707,9 @@ done: */ static int check_objects(const char* fname, pack_opt_t *options) { int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ - hid_t fid; - hid_t did; - hid_t sid; + hid_t fid = -1; + hid_t did = -1; + hid_t sid = -1; unsigned int i; unsigned int uf; trav_table_t *travt = NULL; diff --git a/tools/src/h5repack/h5repack_copy.c b/tools/src/h5repack/h5repack_copy.c index b043047..fa72cfe 100644 --- a/tools/src/h5repack/h5repack_copy.c +++ b/tools/src/h5repack/h5repack_copy.c @@ -1097,7 +1097,7 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, *------------------------------------------------------------------------- */ else { - hid_t pid; + hid_t pid = -1; /* create property to pass copy options */ if ((pid = H5Pcreate(H5P_OBJECT_COPY)) < 0) @@ -1435,51 +1435,51 @@ void print_user_block(const char *filename, hid_t fid) { int ret_value = 0; - int fh; /* file handle */ - hsize_t ub_size; /* user block size */ - hsize_t size; /* size read */ - hid_t fcpl; /* file creation property list ID for HDF5 file */ + hid_t fh = -1; /* file handle */ + hsize_t ub_size; /* user block size */ + hsize_t size; /* size read */ + hid_t fcpl = -1; /* file creation property list ID for HDF5 file */ int i; /* get user block size */ - if(( fcpl = H5Fget_create_plist(fid)) < 0) { + if ((fcpl = H5Fget_create_plist(fid)) < 0) { HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Fget_create_plist failed to retrieve file creation property list"); } - if(H5Pget_userblock(fcpl, &ub_size) < 0) { + if (H5Pget_userblock(fcpl, &ub_size) < 0) { HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pget_userblock failed to retrieve userblock size"); } - if(H5Pclose(fcpl) < 0) { + if (H5Pclose(fcpl) < 0) { HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed to close property list"); } /* open file */ - if((fh = HDopen(filename, O_RDONLY)) < 0) { + if ((fh = HDopen(filename, O_RDONLY)) < 0) { HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "HDopen failed to open file <%s>", filename); } size = ub_size; /* read file */ - while(size > 0) { + while (size > 0) { ssize_t nread; /* # of bytes read */ char rbuf[USERBLOCK_XFER_SIZE]; /* buffer for reading */ /* read buffer */ - if(size > USERBLOCK_XFER_SIZE) + if (size > USERBLOCK_XFER_SIZE) nread = HDread(fh, rbuf, (size_t)USERBLOCK_XFER_SIZE); else nread = HDread(fh, rbuf, (size_t)size); - for(i = 0; i < nread; i++) { + for (i = 0; i < nread; i++) { printf("%c ", rbuf[i]); } printf("\n"); - if(nread < 0) { + if (nread < 0) { HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "nread < 0"); } @@ -1488,7 +1488,7 @@ print_user_block(const char *filename, hid_t fid) } done: - if(fh > 0) + if (fh > 0) HDclose(fh); return; diff --git a/tools/src/h5repack/h5repack_refs.c b/tools/src/h5repack/h5repack_refs.c index 14294ea..7b610a3 100644 --- a/tools/src/h5repack/h5repack_refs.c +++ b/tools/src/h5repack/h5repack_refs.c @@ -145,7 +145,7 @@ int do_copy_refobjs(hid_t fidin, *------------------------------------------------------------------------- */ if(H5Tequal(mtype_id, H5T_STD_REF_OBJ)) { - hid_t refobj_id; + hid_t refobj_id = -1; hobj_ref_t *refbuf = NULL; /* buffer for object references */ hobj_ref_t *buf = NULL; const char* refname; @@ -221,7 +221,7 @@ int do_copy_refobjs(hid_t fidin, *------------------------------------------------------------------------- */ else if(H5Tequal(mtype_id, H5T_STD_REF_DSETREG)) { - hid_t refobj_id; + hid_t refobj_id = -1; hdset_reg_ref_t *refbuf = NULL; /* input buffer for region references */ hdset_reg_ref_t *buf = NULL; /* output buffer */ const char* refname; @@ -260,7 +260,7 @@ int do_copy_refobjs(hid_t fidin, * in the second traversal of the file */ if((refname = MapIdToName(refobj_id, travt)) != NULL) { - hid_t region_id; /* region id of the referenced dataset */ + hid_t region_id = -1; /* region id of the referenced dataset */ if((region_id = H5Rget_region(dset_in, H5R_DATASET_REGION, &buf[u])) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Rget_region failed"); @@ -481,18 +481,16 @@ static int copy_refs_attr(hid_t loc_in, is_ref = (type_class == H5T_REFERENCE); if(type_class == H5T_VLEN ) { - hid_t base_type; + hid_t base_type = H5Tget_super(ftype_id); - base_type = H5Tget_super(ftype_id); is_ref_vlen = (H5Tget_class(base_type) == H5T_REFERENCE); msize = H5Tget_size(base_type); if (H5Tclose(base_type) < 0) H5TOOLS_INFO(H5E_tools_min_id_g, "H5Tclose base_type failed"); } else if(type_class == H5T_ARRAY ) { - hid_t base_type; + hid_t base_type = H5Tget_super(ftype_id); - base_type = H5Tget_super(ftype_id); is_ref_array = (H5Tget_class(base_type) == H5T_REFERENCE); msize = H5Tget_size(base_type); if (H5Tclose(base_type) < 0) @@ -573,9 +571,8 @@ static int copy_refs_attr(hid_t loc_in, unsigned array_rank = 0; hsize_t array_size = 1; hsize_t array_dims[H5S_MAX_RANK]; - hid_t base_type; + hid_t base_type = H5Tget_super(ftype_id); - base_type = H5Tget_super(ftype_id); msize = H5Tget_size(base_type); if (H5Tclose(base_type) < 0) H5TOOLS_INFO(H5E_tools_min_id_g, "H5Tclose base_type failed"); -- cgit v0.12 From 1743470502095271be64a20d80dc53f085e75a09 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 23 Oct 2017 12:42:41 -0500 Subject: HDFFV-10297 Free buffer inside loop --- tools/src/h5repack/h5repack_copy.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/src/h5repack/h5repack_copy.c b/tools/src/h5repack/h5repack_copy.c index fa72cfe..a85ef08 100644 --- a/tools/src/h5repack/h5repack_copy.c +++ b/tools/src/h5repack/h5repack_copy.c @@ -927,6 +927,11 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, if (TRUE == H5Tdetect_class(wtype_id, H5T_VLEN)) if (H5Dvlen_reclaim(wtype_id, f_space_id, H5P_DEFAULT, buf) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dvlen_reclaim failed"); + /* free */ + if (buf != NULL) { + HDfree(buf); + buf = NULL; + } } else { /* possibly not enough memory, read/write by hyperslabs */ size_t p_type_nbytes = msize; /*size of memory type */ -- cgit v0.12 From 075a32fa0c03beda1cbef88ac7940b75b36454b5 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Tue, 24 Oct 2017 11:03:00 -0500 Subject: Fix typos --- tools/lib/h5tools.c | 10 +++++----- tools/src/h5repack/h5repack_copy.c | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index 6ea5e47..89cb524 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -623,9 +623,9 @@ h5tools_count_ncols(const char *s) * * Purpose: Recursive check for any variable length data in given type. * - * Return: TRUE : type conatains any variable length data + * Return: TRUE : type contains any variable length data * FALSE : type doesn't contain any variable length data - * Negative value: error occur + * Negative value: failed *------------------------------------------------------------------------- */ htri_t @@ -652,9 +652,9 @@ done: * * Purpose: Recursive check for variable length string of a datatype. * - * Return: TRUE : type conatains any variable length string + * Return: TRUE : type contains any variable length string * FALSE : type doesn't contain any variable length string - * Negative value: error occur + * Negative value: failed *------------------------------------------------------------------------- */ htri_t @@ -1652,7 +1652,7 @@ render_bin_output_region_data_points(hid_t region_space, hid_t region_id, * Function: render_bin_output_region_points * * Purpose: Print some values from a dataset referenced by region points. - * This is a special case subfunction to dump a region reference using points. + * This is a special case function to dump a region reference using points. * * Return: False if the last dimension has been reached * True otherwise diff --git a/tools/src/h5repack/h5repack_copy.c b/tools/src/h5repack/h5repack_copy.c index a85ef08..63c26fb 100644 --- a/tools/src/h5repack/h5repack_copy.c +++ b/tools/src/h5repack/h5repack_copy.c @@ -1440,7 +1440,7 @@ void print_user_block(const char *filename, hid_t fid) { int ret_value = 0; - hid_t fh = -1; /* file handle */ + int t fh = -1; /* file handle */ hsize_t ub_size; /* user block size */ hsize_t size; /* size read */ hid_t fcpl = -1; /* file creation property list ID for HDF5 file */ -- cgit v0.12 From def0d66aa2db7e3d87f5527b56b512680703418e Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Tue, 24 Oct 2017 11:04:50 -0500 Subject: fix typo --- tools/src/h5repack/h5repack_copy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/src/h5repack/h5repack_copy.c b/tools/src/h5repack/h5repack_copy.c index 63c26fb..5487c27 100644 --- a/tools/src/h5repack/h5repack_copy.c +++ b/tools/src/h5repack/h5repack_copy.c @@ -1440,7 +1440,7 @@ void print_user_block(const char *filename, hid_t fid) { int ret_value = 0; - int t fh = -1; /* file handle */ + int fh = -1; /* file handle */ hsize_t ub_size; /* user block size */ hsize_t size; /* size read */ hid_t fcpl = -1; /* file creation property list ID for HDF5 file */ -- cgit v0.12 From 7ee40947e1808e63666f3129c30b3d52ac15d4e8 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Tue, 24 Oct 2017 14:05:24 -0500 Subject: Correct typo --- tools/src/h5repack/h5repack_copy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/src/h5repack/h5repack_copy.c b/tools/src/h5repack/h5repack_copy.c index 5487c27..e205fba 100644 --- a/tools/src/h5repack/h5repack_copy.c +++ b/tools/src/h5repack/h5repack_copy.c @@ -920,7 +920,7 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, if(H5Dread(dset_in, wtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed"); if(H5Dwrite(dset_out, wtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dwrite failed"); /* Check if we have VL data in the dataset's * datatype that must be reclaimed */ @@ -1011,7 +1011,7 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, if(H5Dread(dset_in, wtype_id, hslab_space, f_space_id, H5P_DEFAULT, hslab_buf) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed"); if(H5Dwrite(dset_out, wtype_id, hslab_space, f_space_id, H5P_DEFAULT, hslab_buf) < 0) - HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dwrite failed"); /* reclaim any VL memory, if necessary */ if (vl_data) -- cgit v0.12 From 2e2854cbb17086509eb9f2c2a3978c421a511ea5 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 25 Oct 2017 09:05:02 -0500 Subject: Correct test DEPENDS --- tools/test/perform/CMakeTests.cmake | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/test/perform/CMakeTests.cmake b/tools/test/perform/CMakeTests.cmake index 2bd8d46..1f67abe 100644 --- a/tools/test/perform/CMakeTests.cmake +++ b/tools/test/perform/CMakeTests.cmake @@ -167,8 +167,7 @@ else () -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) endif () -set_tests_properties (PERFORM_zip_perf PROPERTIES DEPENDS PERFORM_zip_perf_help) -set_tests_properties (PERFORM_zip_perf PROPERTIES DEPENDS "PERFORM_h5perform-clearall-objects") +set_tests_properties (PERFORM_zip_perf PROPERTIES DEPENDS "PERFORM_zip_perf_help;PERFORM_h5perform-clearall-objects") if (H5_HAVE_PARALLEL) add_test (NAME PERFORM_h5perf COMMAND ${MPIEXEC} ${MPIEXEC_PREFLAGS} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_POSTFLAGS} $) -- cgit v0.12 From 26ae202faa4a761c307bf15eacc28f96bedc7859 Mon Sep 17 00:00:00 2001 From: "M. Scot Breitenfeld" Date: Wed, 25 Oct 2017 10:32:33 -0500 Subject: HDFFV-10037: fixed wrong C link flags --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index ed7727b..3dbd95c 100644 --- a/configure.ac +++ b/configure.ac @@ -3518,7 +3518,7 @@ if test "X$HDF_FORTRAN" = "Xyes"; then case "`uname`" in Linux*) if test "X$FC_BASENAME" = "Xnagfor"; then - cat libtool | awk '/NAG_Fortran/{flag=1}flag&&/wl=/{$NF="wl=\"-Wl,Wl,,\"";flag=0}1' > libtool.tmp && mv -f libtool.tmp libtool && chmod 755 libtool + cat libtool | awk '/BEGIN LIBTOOL TAG CONFIG: FC/{flag=1}flag&&/wl=/{$NF="wl=\"-Wl,-Wl,,\"";flag=0}1' > libtool.tmp && mv -f libtool.tmp libtool && chmod 755 libtool fi ;; esac -- cgit v0.12 From e9067227aed3c8fe0266e3e8d1cc1d5558ceb096 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 25 Oct 2017 14:06:44 -0500 Subject: HDFFV-10297 Update release note --- release_docs/RELEASE.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index db3e4e0..4714232 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -78,7 +78,7 @@ New Features file driver in HDF5 by previously having called H5Pset_fapl_mpio(). HDF5 parallel file operations which do not employ multiple ranks - e.g. specifiying MPI_COMM_SELF (whose MPI_Comm_size == 1) + e.g. specifiying MPI_COMM_SELF (whose MPI_Comm_size == 1) as opposed to MPI_COMM_WORLD, will not be affected by this optimization. Conversely, parallel file operations on subgroups of MPI_COMM_WORLD are allowed to be run in parallel with each @@ -199,6 +199,7 @@ Bug Fixes since HDF5-1.10.1 release Modified H5Zfilter_avail and private function, H5Z_filter_avail. Moved check for plugin from public to private function. Updated H5P__set_filter due to change in H5Z_filter_avail. Updated tests. + Note that the output display of h5repack has changed. (ADB - 2017/10/10, HDFFV-10297) -- cgit v0.12 From 95d8724df84294260ae611c07aec535199e5a23a Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 25 Oct 2017 15:10:42 -0500 Subject: HDFFV-10297 - clarify note. --- release_docs/RELEASE.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 4714232..5ad2b61 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -199,7 +199,10 @@ Bug Fixes since HDF5-1.10.1 release Modified H5Zfilter_avail and private function, H5Z_filter_avail. Moved check for plugin from public to private function. Updated H5P__set_filter due to change in H5Z_filter_avail. Updated tests. - Note that the output display of h5repack has changed. + Note, h5repack output display has changed to clarify the individual + steps of the repack process. The output indicates if an operation + applies to all objects. Lines with notation and no information + has removed. (ADB - 2017/10/10, HDFFV-10297) -- cgit v0.12 From efb505f37a062c2016d409a2d2fce732bf2c6d67 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 25 Oct 2017 15:50:07 -0500 Subject: HDFFV-10297 fix grammar --- release_docs/RELEASE.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 5ad2b61..be5550e 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -202,7 +202,7 @@ Bug Fixes since HDF5-1.10.1 release Note, h5repack output display has changed to clarify the individual steps of the repack process. The output indicates if an operation applies to all objects. Lines with notation and no information - has removed. + have been removed. (ADB - 2017/10/10, HDFFV-10297) -- cgit v0.12 From d14e859a919dee2c153c6faac3a0431d84042f0d Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 26 Oct 2017 10:44:09 -0500 Subject: Correct char type --- release_docs/RELEASE.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index be5550e..7aa6322 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -84,7 +84,7 @@ New Features of MPI_COMM_WORLD are allowed to be run in parallel with each subgroup operating as an independant collection of processes. - (RAW – 2017/10/10, HDFFV-10294) + (RAW - 2017/10/10, HDFFV-10294) - Large MPI-IO transfers @@ -109,7 +109,7 @@ New Features fulfill the original user request without encountering API errors. - (RAW – 2017/07/11, HDFFV-8839) + (RAW - 2017/07/11, HDFFV-8839) Fortran Library: ---------------- -- cgit v0.12 From b6de5127a8b214bfb702c4780bfbe4288fe606fd Mon Sep 17 00:00:00 2001 From: "M. Scot Breitenfeld" Date: Thu, 26 Oct 2017 15:26:54 -0500 Subject: removed extra character --- bin/h5vers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/h5vers b/bin/h5vers index 5228903..5466d13 100755 --- a/bin/h5vers +++ b/bin/h5vers @@ -198,7 +198,7 @@ my $H5_JAVA = $file; $H5_JAVA =~ s/[^\/]*$/..\/java\/src\/hdf\/hdf5lib\/H5.java/; die "unable to read file: $H5_JAVA\n" unless -r $file; my $TESTH5_JAVA = $file; -$TESTH5_JAVA =~ s/[^\/]*$/..\/java\/test\/TestH5.java/; +$TESTH5_JAVA =~ s/[^\/]*$/..\/java\/test\/TestH5.java/; die "unable to read file: $TESTH5_JAVA\n" unless -r $file; my $REPACK_LAYOUT_PLUGIN_VERSION = $file; $REPACK_LAYOUT_PLUGIN_VERSION =~ s/[^\/]*$/..\/tools\/test\/h5repack\/testfiles\/h5repack_layout.h5-plugin_version_test.ddl/; -- cgit v0.12 From b752960f56845f737d0e54cf257474d924fd2f0c Mon Sep 17 00:00:00 2001 From: lrknox Date: Thu, 26 Oct 2017 16:36:21 -0500 Subject: Remove extra spaces and 1 "currently under development" to match hdf5_1_10 version. --- bin/h5vers | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/h5vers b/bin/h5vers index 5228903..a00beb7 100755 --- a/bin/h5vers +++ b/bin/h5vers @@ -198,7 +198,7 @@ my $H5_JAVA = $file; $H5_JAVA =~ s/[^\/]*$/..\/java\/src\/hdf\/hdf5lib\/H5.java/; die "unable to read file: $H5_JAVA\n" unless -r $file; my $TESTH5_JAVA = $file; -$TESTH5_JAVA =~ s/[^\/]*$/..\/java\/test\/TestH5.java/; +$TESTH5_JAVA =~ s/[^\/]*$/..\/java\/test\/TestH5.java/; die "unable to read file: $TESTH5_JAVA\n" unless -r $file; my $REPACK_LAYOUT_PLUGIN_VERSION = $file; $REPACK_LAYOUT_PLUGIN_VERSION =~ s/[^\/]*$/..\/tools\/test\/h5repack\/testfiles\/h5repack_layout.h5-plugin_version_test.ddl/; @@ -354,7 +354,7 @@ if ($HDF5CONFIGCMAKE) { my $sub_rel_ver_str = ( $newver[3] eq "" ? sprintf("\"%s\"", "") - : sprintf("\"%s\"", "-".$newver[3].", currently under development") + : sprintf("\"%s\"", "-".$newver[3]) ); my $version_string = sprintf("\"%d.%d.%d\"", @newver[0,1,2]); @@ -377,7 +377,7 @@ if ($H5_JAVA) { my $version_string2 = sprintf("%d, %d, %d", @newver[0,1,2]); $data =~ s/\@version HDF5 .*
/\@version HDF5 $version_string1
/; - $data =~ s/ public final static int LIB_VERSION\[\] = { \d*, \d*, \d* };/ public final static int LIB_VERSION[] = { $version_string2 };/; + $data =~ s/ public final static int LIB_VERSION\[\] = { \d*, \d*, \d* };/ public final static int LIB_VERSION[] = { $version_string2 };/; write_file($H5_JAVA, $data); } @@ -395,7 +395,7 @@ if ($TESTH5_JAVA) { my $version_string2 = sprintf("int majnum = %d, minnum = %d, relnum = %d", @newver[0,1,2]); $data =~ s/ int libversion\[\] = { .* };/ int libversion\[\] = { $version_string1 };/; - $data =~ s/ int majnum = \d*, minnum = \d*, relnum = \d*;/ $version_string2;/; + $data =~ s/ int majnum = \d*, minnum = \d*, relnum = \d*;/ $version_string2;/; write_file($TESTH5_JAVA, $data); } @@ -410,7 +410,7 @@ if ($REPACK_LAYOUT_PLUGIN_VERSION) { write_file($REPACK_LAYOUT_PLUGIN_VERSION, $data); } -# helper function to read the file for updating c++/src/cpp_doc_config, +# helper function to read the file for updating c++/src/cpp_doc_config, # config/cmake/scripts/HDF5Config.cmake, and java files. # The version string in that file is not at the top, so the string replacement # is not for the first line, and reading/writing the entire file as one string -- cgit v0.12 From 6a52c26162f45e85b88aa6ddab5e5d861aaba7b8 Mon Sep 17 00:00:00 2001 From: lrknox Date: Thu, 26 Oct 2017 16:45:25 -0500 Subject: Revert "Fix for HDFFFV-10308. Initialize hid_ts in function check_objects and" This reverts commit e92f3f858bf16a84c59aeb6692f5cab5e6b8e66f. --- tools/src/h5repack/h5repack.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/tools/src/h5repack/h5repack.c b/tools/src/h5repack/h5repack.c index 22ca279..14b9461 100644 --- a/tools/src/h5repack/h5repack.c +++ b/tools/src/h5repack/h5repack.c @@ -707,9 +707,9 @@ done: */ static int check_objects(const char* fname, pack_opt_t *options) { int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ - hid_t fid = -1; - hid_t did = -1; - hid_t sid = -1; + hid_t fid; + hid_t did; + hid_t sid; unsigned int i; unsigned int uf; trav_table_t *travt = NULL; @@ -810,12 +810,9 @@ static int check_objects(const char* fname, pack_opt_t *options) { done: H5E_BEGIN_TRY { - if (sid > -1) - H5Sclose(sid); - if (did > -1) - H5Dclose(did); - if (fid > -1) - H5Fclose(fid); + H5Sclose(sid); + H5Dclose(did); + H5Fclose(fid); } H5E_END_TRY; if (travt) trav_table_free(travt); -- cgit v0.12 From 4a6904e758cd14673a3ec6f60adb5f8b210bb4c3 Mon Sep 17 00:00:00 2001 From: Richard Warren Date: Thu, 26 Oct 2017 21:18:03 -0400 Subject: Add a missing declaration for testing --- src/H5Sprivate.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h index 60e0630..8934726 100644 --- a/src/H5Sprivate.h +++ b/src/H5Sprivate.h @@ -311,6 +311,7 @@ H5_DLL herr_t H5S_select_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem); H5_DLL herr_t H5S_select_iter_release(H5S_sel_iter_t *sel_iter); #ifdef H5_HAVE_PARALLEL +H5_DLL hsize_t H5S_mpio_set_bigio_count(hsize_t new_count); H5_DLL herr_t H5S_mpio_space_type(const H5S_t *space, size_t elmt_size, /* out: */ MPI_Datatype *new_type, int *count, -- cgit v0.12 From 25a2e40358e32c2421e3958f1b6e3eb73c31aa6b Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 30 Oct 2017 11:37:57 -0500 Subject: New requirement for test --- config/cmake/cacheinit.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/cmake/cacheinit.cmake b/config/cmake/cacheinit.cmake index d37c339..d5c5e52 100644 --- a/config/cmake/cacheinit.cmake +++ b/config/cmake/cacheinit.cmake @@ -29,7 +29,7 @@ set (HDF5_ENABLE_SZIP_SUPPORT ON CACHE BOOL "Use SZip Filter" FORCE) set (HDF5_ENABLE_SZIP_ENCODING ON CACHE BOOL "Use SZip Encoding" FORCE) -set (MPIEXEC_MAX_NUMPROCS "3" CACHE STRING "Minimum number of processes for HDF parallel tests" FORCE) +set (MPIEXEC_MAX_NUMPROCS "4" CACHE STRING "Minimum number of processes for HDF parallel tests" FORCE) set (HDF5_ENABLE_ALL_WARNINGS ON CACHE BOOL "Enable all warnings" FORCE) -- cgit v0.12 From 11ccbed3c93d3c34d63591ba93a355300ab38c96 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Tue, 31 Oct 2017 11:18:09 -0500 Subject: Update H5Zfilter_avail note --- release_docs/RELEASE.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 7aa6322..b66355e 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -166,7 +166,7 @@ Bug Fixes since HDF5-1.10.1 release Moved check for plugin from public to private function. Updated H5P__set_filter due to change in H5Z_filter_avail. Updated tests. - (ADB - 2017/10/10, HDFFV-10297) + (ADB - 2017/10/10, HDFFV-10297, HDFFV-10319) Configuration ------------- @@ -204,7 +204,7 @@ Bug Fixes since HDF5-1.10.1 release applies to all objects. Lines with notation and no information have been removed. - (ADB - 2017/10/10, HDFFV-10297) + (ADB - 2017/10/10, HDFFV-10297, HDFFV-10319) - h5repack -- cgit v0.12 From 80c96bb047b0138c6df4d25fbd14e5d63392454e Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 1 Nov 2017 11:12:47 -0500 Subject: Change MPI target properties for library --- src/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 96ea589..ad0a326 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -886,7 +886,7 @@ if (NOT WIN32) target_link_libraries (${HDF5_LIB_TARGET} dl) endif () if (H5_HAVE_PARALLEL AND MPI_C_FOUND) - target_link_libraries (${HDF5_LIB_TARGET} ${MPI_C_LIBRARIES}) + target_link_libraries (${HDF5_LIB_TARGET} PRIVATE ${MPI_C_LIBRARIES}) endif () set_global_variable (HDF5_LIBRARIES_TO_EXPORT ${HDF5_LIB_TARGET}) H5_SET_LIB_OPTIONS (${HDF5_LIB_TARGET} ${HDF5_LIB_NAME} STATIC) @@ -930,7 +930,7 @@ if (BUILD_SHARED_LIBS) target_link_libraries (${HDF5_LIBSH_TARGET} dl) endif () if (H5_HAVE_PARALLEL AND MPI_C_FOUND) - target_link_libraries (${HDF5_LIBSH_TARGET} ${MPI_C_LIBRARIES}) + target_link_libraries (${HDF5_LIBSH_TARGET} PRIVATE ${MPI_C_LIBRARIES}) endif () set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_LIBSH_TARGET}") H5_SET_LIB_OPTIONS (${HDF5_LIBSH_TARGET} ${HDF5_LIB_NAME} SHARED ${HDF5_PACKAGE_SOVERSION}) -- cgit v0.12 From 765d96456298aa678c072df9debba7d4be6ffb95 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 1 Nov 2017 11:28:11 -0500 Subject: Correct command usage --- src/CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ad0a326..849ced0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -881,9 +881,9 @@ set (gen_SRCS ${HDF5_BINARY_DIR}/H5Tinit.c ${HDF5_BINARY_DIR}/H5lib_settings.c) add_library (${HDF5_LIB_TARGET} STATIC ${common_SRCS} ${gen_SRCS} ${H5_PUBLIC_HEADERS} ${H5_PRIVATE_HEADERS} ${H5_GENERATED_HEADERS}) TARGET_C_PROPERTIES (${HDF5_LIB_TARGET} STATIC " " " ") -target_link_libraries (${HDF5_LIB_TARGET} ${LINK_LIBS}) +target_link_libraries (${HDF5_LIB_TARGET} PRIVATE ${LINK_LIBS}) if (NOT WIN32) - target_link_libraries (${HDF5_LIB_TARGET} dl) + target_link_libraries (${HDF5_LIB_TARGET} PRIVATE dl) endif () if (H5_HAVE_PARALLEL AND MPI_C_FOUND) target_link_libraries (${HDF5_LIB_TARGET} PRIVATE ${MPI_C_LIBRARIES}) @@ -925,9 +925,9 @@ if (BUILD_SHARED_LIBS) set (shared_gen_SRCS ${HDF5_BINARY_DIR}/shared/H5Tinit.c ${HDF5_BINARY_DIR}/shared/H5lib_settings.c) add_library (${HDF5_LIBSH_TARGET} SHARED ${common_SRCS} ${shared_gen_SRCS} ${H5_PUBLIC_HEADERS} ${H5_PRIVATE_HEADERS} ${H5_GENERATED_HEADERS}) TARGET_C_PROPERTIES (${HDF5_LIBSH_TARGET} SHARED " " " ") - target_link_libraries (${HDF5_LIBSH_TARGET} ${LINK_SHARED_LIBS}) + target_link_libraries (${HDF5_LIBSH_TARGET} PUBLIC ${LINK_SHARED_LIBS}) if (NOT WIN32) - target_link_libraries (${HDF5_LIBSH_TARGET} dl) + target_link_libraries (${HDF5_LIBSH_TARGET} PUBLIC dl) endif () if (H5_HAVE_PARALLEL AND MPI_C_FOUND) target_link_libraries (${HDF5_LIBSH_TARGET} PRIVATE ${MPI_C_LIBRARIES}) @@ -945,7 +945,7 @@ if (BUILD_SHARED_LIBS) APPEND PROPERTY COMPILE_DEFINITIONS "H5_HAVE_THREADSAFE" ) - target_link_libraries (${HDF5_LIBSH_TARGET} Threads::Threads) + target_link_libraries (${HDF5_LIBSH_TARGET} PUBLIC Threads::Threads) endif () if (HDF5_ENABLE_DEBUG_APIS) -- cgit v0.12 From 930cfc402dc2f17b1dbe9a6b3c5e15b95cc4c7ea Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 1 Nov 2017 12:29:53 -0500 Subject: Convert to use MPI:: for link --- CMakeLists.txt | 2 +- fortran/CMakeLists.txt | 3 +-- fortran/examples/CMakeLists.txt | 4 ++-- fortran/src/CMakeLists.txt | 4 ++-- src/CMakeLists.txt | 6 ++++-- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 23452cd..40093c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -623,7 +623,7 @@ INCLUDE_DIRECTORIES (${HDF5_BINARY_DIR} ${HDF5_SRC_DIR} ${CMAKE_RUNTIME_OUTPUT_D set (CMAKE_MODULE_PATH ${HDF_RESOURCES_DIR} ${HDF_RESOURCES_EXT_DIR} ${CMAKE_MODULE_PATH}) option (HDF5_ENABLE_PARALLEL "Enable parallel build (requires MPI)" OFF) if (HDF5_ENABLE_PARALLEL) - include (FindMPI) + find_package(MPI REQUIRED) INCLUDE_DIRECTORIES (${MPI_C_INCLUDE_PATH}) if (MPI_C_FOUND) set (H5_HAVE_PARALLEL 1) diff --git a/fortran/CMakeLists.txt b/fortran/CMakeLists.txt index f7179cf..9f7144d 100644 --- a/fortran/CMakeLists.txt +++ b/fortran/CMakeLists.txt @@ -2,8 +2,7 @@ cmake_minimum_required (VERSION 3.2.2) PROJECT (HDF5_F90 C CXX Fortran) if (H5_HAVE_PARALLEL) - INCLUDE (FindMPI) - set (LINK_LIBS ${LINK_LIBS} ${MPI_Fortran_LIBRARIES}) + set (LINK_LIBS ${LINK_LIBS} MPI::MPI_Fortran) if (MPI_Fortran_LINK_FLAGS) set (CMAKE_EXE_LINKER_FLAGS "${MPI_Fortran_LINK_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}") endif () diff --git a/fortran/examples/CMakeLists.txt b/fortran/examples/CMakeLists.txt index a5c3422..119648f 100644 --- a/fortran/examples/CMakeLists.txt +++ b/fortran/examples/CMakeLists.txt @@ -107,7 +107,7 @@ if (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND) target_link_libraries (f90_ex_ph5example ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} - ${MPI_Fortran_LIBRARIES} + MPI::MPI_Fortran ) target_include_directories (f90_ex_ph5example PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/static) set_target_properties (f90_ex_ph5example PROPERTIES @@ -122,7 +122,7 @@ if (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND) target_link_libraries (f90_ex_ph5example-shared ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} - ${MPI_Fortran_LIBRARIES} + MPI::MPI_Fortran ) target_include_directories (f90_ex_ph5example-shared PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/shared) set_target_properties (f90_ex_ph5example-shared PROPERTIES diff --git a/fortran/src/CMakeLists.txt b/fortran/src/CMakeLists.txt index 6d51feb..4a723c7 100644 --- a/fortran/src/CMakeLists.txt +++ b/fortran/src/CMakeLists.txt @@ -243,7 +243,7 @@ set (SHARED_LINK_FLAGS " ") TARGET_FORTRAN_PROPERTIES (${HDF5_F90_LIB_TARGET} STATIC " " " ") target_link_libraries (${HDF5_F90_LIB_TARGET} ${HDF5_F90_C_LIB_TARGET} ${HDF5_LIB_TARGET}) if (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND) - target_link_libraries (${HDF5_F90_LIB_TARGET} ${MPI_Fortran_LIBRARIES}) + target_link_libraries (${HDF5_F90_LIB_TARGET} MPI::MPI_Fortran) endif () set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_F90_LIB_TARGET}") H5_SET_LIB_OPTIONS (${HDF5_F90_LIB_TARGET} ${HDF5_F90_LIB_NAME} STATIC) @@ -270,7 +270,7 @@ if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) TARGET_FORTRAN_PROPERTIES (${HDF5_F90_LIBSH_TARGET} SHARED " " ${SHARED_LINK_FLAGS}) target_link_libraries (${HDF5_F90_LIBSH_TARGET} ${HDF5_F90_C_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) if (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND) - target_link_libraries (${HDF5_F90_LIBSH_TARGET} ${MPI_Fortran_LIBRARIES}) + target_link_libraries (${HDF5_F90_LIBSH_TARGET} MPI::MPI_Fortran) endif () set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_F90_LIBSH_TARGET}") H5_SET_LIB_OPTIONS (${HDF5_F90_LIBSH_TARGET} ${HDF5_F90_LIB_NAME} SHARED ${HDF5_F_PACKAGE_SOVERSION}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 849ced0..1651b15 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -886,7 +886,8 @@ if (NOT WIN32) target_link_libraries (${HDF5_LIB_TARGET} PRIVATE dl) endif () if (H5_HAVE_PARALLEL AND MPI_C_FOUND) - target_link_libraries (${HDF5_LIB_TARGET} PRIVATE ${MPI_C_LIBRARIES}) + target_include_directories (${HDF5_LIB_TARGET} PRIVATE ${MPI_C_INCLUDE_PATH}) + target_link_libraries (${HDF5_LIB_TARGET} PRIVATE MPI::MPI_C}) endif () set_global_variable (HDF5_LIBRARIES_TO_EXPORT ${HDF5_LIB_TARGET}) H5_SET_LIB_OPTIONS (${HDF5_LIB_TARGET} ${HDF5_LIB_NAME} STATIC) @@ -930,7 +931,8 @@ if (BUILD_SHARED_LIBS) target_link_libraries (${HDF5_LIBSH_TARGET} PUBLIC dl) endif () if (H5_HAVE_PARALLEL AND MPI_C_FOUND) - target_link_libraries (${HDF5_LIBSH_TARGET} PRIVATE ${MPI_C_LIBRARIES}) + target_include_directories (${HDF5_LIBSH_TARGET} PRIVATE ${MPI_C_INCLUDE_PATH}) + target_link_libraries (${HDF5_LIBSH_TARGET} PRIVATE MPI::MPI_C) endif () set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_LIBSH_TARGET}") H5_SET_LIB_OPTIONS (${HDF5_LIBSH_TARGET} ${HDF5_LIB_NAME} SHARED ${HDF5_PACKAGE_SOVERSION}) -- cgit v0.12 From f8fd6d0b41a242aae93689e1477478bc78bae471 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 1 Nov 2017 13:41:44 -0500 Subject: Correct usage of MPI vars --- CMakeLists.txt | 1 - config/cmake/UseJava.cmake | 6 +- config/cmake/hdf5-config.cmake.in | 8 +- config/cmake_ext_mod/FindMPI.cmake | 1754 +++++++++++++++++++++++++---------- fortran/examples/CMakeTests.cmake | 4 +- fortran/src/CMakeLists.txt | 8 +- fortran/testpar/CMakeLists.txt | 4 +- fortran/testpar/CMakeTests.cmake | 2 +- src/CMakeLists.txt | 10 +- testpar/CMakeLists.txt | 4 +- testpar/CMakeTests.cmake | 4 +- tools/test/h5diff/CMakeTests.cmake | 4 +- tools/test/perform/CMakeTests.cmake | 4 +- 13 files changed, 1270 insertions(+), 543 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 40093c1..20ff228 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -624,7 +624,6 @@ set (CMAKE_MODULE_PATH ${HDF_RESOURCES_DIR} ${HDF_RESOURCES_EXT_DIR} ${CMAKE_MOD option (HDF5_ENABLE_PARALLEL "Enable parallel build (requires MPI)" OFF) if (HDF5_ENABLE_PARALLEL) find_package(MPI REQUIRED) - INCLUDE_DIRECTORIES (${MPI_C_INCLUDE_PATH}) if (MPI_C_FOUND) set (H5_HAVE_PARALLEL 1) # MPI checks, only do these if MPI_C_FOUND is true, otherwise they always fail diff --git a/config/cmake/UseJava.cmake b/config/cmake/UseJava.cmake index 9b3bf02..52b37a9 100644 --- a/config/cmake/UseJava.cmake +++ b/config/cmake/UseJava.cmake @@ -482,6 +482,8 @@ function(add_jar _TARGET_NAME) else() get_filename_component(_add_jar_OUTPUT_DIR ${_add_jar_OUTPUT_DIR} ABSOLUTE) endif() + # ensure output directory exists + file (MAKE_DIRECTORY "${_add_jar_OUTPUT_DIR}") if (_add_jar_ENTRY_POINT) set(_ENTRY_POINT_OPTION e) @@ -516,7 +518,7 @@ function(add_jar _TARGET_NAME) set(CMAKE_JAVA_INCLUDE_PATH_FINAL "${CMAKE_JAVA_INCLUDE_PATH_FINAL}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${JAVA_INCLUDE_DIR}") endforeach() - set(CMAKE_JAVA_CLASS_OUTPUT_PATH "${_add_jar_OUTPUT_DIR}${CMAKE_FILES_DIRECTORY}/${_TARGET_NAME}.dir") + set(CMAKE_JAVA_CLASS_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_TARGET_NAME}.dir") set(_JAVA_TARGET_OUTPUT_NAME "${_TARGET_NAME}.jar") if (_add_jar_OUTPUT_NAME AND _add_jar_VERSION) @@ -547,7 +549,7 @@ function(add_jar _TARGET_NAME) list(APPEND _JAVA_COMPILE_FILELISTS ${_JAVA_FULL}) elseif (_JAVA_EXT MATCHES ".java") - file(RELATIVE_PATH _JAVA_REL_BINARY_PATH ${_add_jar_OUTPUT_DIR} ${_JAVA_FULL}) + file(RELATIVE_PATH _JAVA_REL_BINARY_PATH ${CMAKE_CURRENT_BINARY_DIR} ${_JAVA_FULL}) file(RELATIVE_PATH _JAVA_REL_SOURCE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${_JAVA_FULL}) string(LENGTH ${_JAVA_REL_BINARY_PATH} _BIN_LEN) string(LENGTH ${_JAVA_REL_SOURCE_PATH} _SRC_LEN) diff --git a/config/cmake/hdf5-config.cmake.in b/config/cmake/hdf5-config.cmake.in index 712dc05..01c27df 100644 --- a/config/cmake/hdf5-config.cmake.in +++ b/config/cmake/hdf5-config.cmake.in @@ -50,8 +50,12 @@ set (${HDF5_PACKAGE_NAME}_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") # Dependencies #----------------------------------------------------------------------------- if (${HDF5_PACKAGE_NAME}_ENABLE_PARALLEL) - set (${HDF5_PACKAGE_NAME}_MPI_C_INCLUDE_PATH "@MPI_C_INCLUDE_PATH@") + set (${HDF5_PACKAGE_NAME}_MPI_C_INCLUDE_PATH "@MPI_C_INCLUDE_DIRS@") set (${HDF5_PACKAGE_NAME}_MPI_C_LIBRARIES "@MPI_C_LIBRARIES@") + if (${HDF5_PACKAGE_NAME}_BUILD_FORTRAN) + set (${HDF5_PACKAGE_NAME}_MPI_Fortran_INCLUDE_PATH "@MPI_Fortran_INCLUDE_DIRS@") + set (${HDF5_PACKAGE_NAME}_MPI_Fortran_LIBRARIES "@MPI_Fortran_LIBRARIES@") + endif () endif () if (${HDF5_PACKAGE_NAME}_BUILD_JAVA) @@ -67,7 +71,7 @@ endif () #----------------------------------------------------------------------------- # Directories #----------------------------------------------------------------------------- -set (${HDF5_PACKAGE_NAME}_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@" "${${HDF5_PACKAGE_NAME}_MPI_C_INCLUDE_PATH}") +set (${HDF5_PACKAGE_NAME}_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@" "${${HDF5_PACKAGE_NAME}_MPI_C_INCLUDE_DIRS}") set (${HDF5_PACKAGE_NAME}_SHARE_DIR "@PACKAGE_SHARE_INSTALL_DIR@") set_and_check (${HDF5_PACKAGE_NAME}_BUILD_DIR "@PACKAGE_CURRENT_BUILD_DIR@") diff --git a/config/cmake_ext_mod/FindMPI.cmake b/config/cmake_ext_mod/FindMPI.cmake index f566ade..61ab4a4 100644 --- a/config/cmake_ext_mod/FindMPI.cmake +++ b/config/cmake_ext_mod/FindMPI.cmake @@ -4,27 +4,45 @@ # FindMPI # ------- # -# Find a Message Passing Interface (MPI) implementation +# Find a Message Passing Interface (MPI) implementation. # # The Message Passing Interface (MPI) is a library used to write # high-performance distributed-memory parallel applications, and is # typically deployed on a cluster. MPI is a standard interface (defined # by the MPI forum) for which many implementations are available. # -# Variables -# ^^^^^^^^^ +# Variables for using MPI +# ^^^^^^^^^^^^^^^^^^^^^^^ +# +# The module exposes the components ``C``, ``CXX``, ``MPICXX`` and ``Fortran``. +# Each of these controls the various MPI languages to search for. +# The difference between ``CXX`` and ``MPICXX`` is that ``CXX`` refers to the +# MPI C API being usable from C++, whereas ``MPICXX`` refers to the MPI-2 C++ API +# that was removed again in MPI-3. +# +# Depending on the enabled components the following variables will be set: +# +# ``MPI_FOUND`` +# Variable indicating that MPI settings for all requested languages have been found. +# If no components are specified, this is true if MPI settings for all enabled languages +# were detected. Note that the ``MPICXX`` component does not affect this variable. +# ``MPI_VERSION`` +# Minimal version of MPI detected among the requested languages, or all enabled languages +# if no components were specified. # # This module will set the following variables per language in your # project, where ```` is one of C, CXX, or Fortran: # # ``MPI__FOUND`` -# Variable indicating the MPI settings for ```` were found. +# Variable indicating the MPI settings for ```` were found and that +# simple MPI test programs compile with the provided settings. # ``MPI__COMPILER`` -# MPI Compiler wrapper for ````. -# ``MPI__COMPILE_FLAGS`` -# Compilation flags for MPI programs, separated by spaces. -# This is *not* a :ref:`;-list `. -# ``MPI__INCLUDE_PATH`` +# MPI compiler for ```` if such a program exists. +# ``MPI__COMPILE_OPTIONS`` +# Compilation options for MPI programs in ````, given as a :ref:`;-list `. +# ``MPI__COMPILE_DEFINITIONS`` +# Compilation definitions for MPI programs in ````, given as a :ref:`;-list `. +# ``MPI__INCLUDE_DIRS`` # Include path(s) for MPI header. # ``MPI__LINK_FLAGS`` # Linker flags for MPI programs. @@ -36,53 +54,172 @@ # ``MPI::MPI_`` # Target for using MPI from ````. # -# Additionally, FindMPI sets the following variables for running MPI -# programs from the command line: +# The following variables indicating which bindings are present will be defined: # -# ``MPIEXEC`` -# Executable for running MPI programs, if provided. +# ``MPI_MPICXX_FOUND`` +# Variable indicating whether the MPI-2 C++ bindings are present (introduced in MPI-2, removed with MPI-3). +# ``MPI_Fortran_HAVE_F77_HEADER`` +# True if the Fortran 77 header ``mpif.h`` is available. +# ``MPI_Fortran_HAVE_F90_MODULE`` +# True if the Fortran 90 module ``mpi`` can be used for accessing MPI (MPI-2 and higher only). +# ``MPI_Fortran_HAVE_F08_MODULE`` +# True if the Fortran 2008 ``mpi_f08`` is available to MPI programs (MPI-3 and higher only). +# +# If possible, the MPI version will be determined by this module. The facilities to detect the MPI version +# were introduced with MPI-1.2, and therefore cannot be found for older MPI versions. +# +# ``MPI__VERSION_MAJOR`` +# Major version of MPI implemented for ```` by the MPI distribution. +# ``MPI__VERSION_MINOR`` +# Minor version of MPI implemented for ```` by the MPI distribution. +# ``MPI__VERSION`` +# MPI version implemented for ```` by the MPI distribution. +# +# Note that there's no variable for the C bindings being accessible through ``mpi.h``, since the MPI standards +# always have required this binding to work in both C and C++ code. +# +# For running MPI programs, the module sets the following variables +# +# ``MPIEXEC_EXECUTABLE`` +# Executable for running MPI programs, if such exists. # ``MPIEXEC_NUMPROC_FLAG`` -# Flag to pass to ``MPIEXEC`` before giving it the number of processors to run on. +# Flag to pass to ``mpiexec`` before giving it the number of processors to run on. # ``MPIEXEC_MAX_NUMPROCS`` # Number of MPI processors to utilize. Defaults to the number # of processors detected on the host system. # ``MPIEXEC_PREFLAGS`` -# Flags to pass to ``MPIEXEC`` directly before the executable to run. +# Flags to pass to ``mpiexec`` directly before the executable to run. # ``MPIEXEC_POSTFLAGS`` -# Flags to pass to ``MPIEXEC`` after other flags. +# Flags to pass to ``mpiexec`` after other flags. +# +# Variables for locating MPI +# ^^^^^^^^^^^^^^^^^^^^^^^^^^ +# +# This module performs a three step search for an MPI implementation: +# +# 1. Check if the compiler has MPI support built-in. This is the case if the user passed a +# compiler wrapper as ``CMAKE__COMPILER`` or if they're on a Cray system. +# 2. Attempt to find an MPI compiler wrapper and determine the compiler information from it. +# 3. Try to find an MPI implementation that does not ship such a wrapper by guessing settings. +# Currently, only Microsoft MPI and MPICH2 on Windows are supported. +# +# For controlling the second step, the following variables may be set: +# +# ``MPI__COMPILER`` +# Search for the specified compiler wrapper and use it. +# ``MPI__COMPILER_FLAGS`` +# Flags to pass to the MPI compiler wrapper during interrogation. Some compiler wrappers +# support linking debug or tracing libraries if a specific flag is passed and this variable +# may be used to obtain them. +# ``MPI_COMPILER_FLAGS`` +# Used to initialize ``MPI__COMPILER_FLAGS`` if no language specific flag has been given. +# Empty by default. +# ``MPI_EXECUTABLE_SUFFIX`` +# A suffix which is appended to all names that are being looked for. For instance you may set this +# to ``.mpich`` or ``.openmpi`` to prefer the one or the other on Debian and its derivatives. +# +# In order to control the guessing step, the following variable may be set: # -# Usage -# ^^^^^ +# ``MPI_GUESS_LIBRARY_NAME`` +# Valid values are ``MSMPI`` and ``MPICH2``. If set, only the given library will be searched for. +# By default, ``MSMPI`` will be preferred over ``MPICH2`` if both are available. +# This also sets ``MPI_SKIP_COMPILER_WRAPPER`` to ``true``, which may be overridden. # -# To use this module, call ``find_package(MPI)``. If you are happy with the -# auto-detected configuration for your language, then you're done. If -# not, you have two options: +# Each of the search steps may be skipped with the following control variables: # -# 1. Set ``MPI__COMPILER`` to the MPI wrapper (e.g. ``mpicc``) of your -# choice and reconfigure. FindMPI will attempt to determine all the -# necessary variables using *that* compiler's compile and link flags. -# 2. If this fails, or if your MPI implementation does not come with -# a compiler wrapper, then set both ``MPI__LIBRARIES`` and -# ``MPI__INCLUDE_PATH``. You may also set any other variables -# listed above, but these two are required. This will circumvent -# autodetection entirely. +# ``MPI_ASSUME_NO_BUILTIN_MPI`` +# If true, the module assumes that the compiler itself does not provide an MPI implementation and +# skips to step 2. +# ``MPI_SKIP_COMPILER_WRAPPER`` +# If true, no compiler wrapper will be searched for. +# ``MPI_SKIP_GUESSING`` +# If true, the guessing step will be skipped. # -# When configuration is successful, ``MPI__COMPILER`` will be set to -# the compiler wrapper for ````, if it was found. ``MPI__FOUND`` -# and other variables above will be set if any MPI implementation was -# found for ````, regardless of whether a compiler was found. +# Additionally, the following control variable is available to change search behavior: # -# When using ``MPIEXEC`` to execute MPI applications, you should typically -# use all of the ``MPIEXEC`` flags as follows: +# ``MPI_CXX_SKIP_MPICXX`` +# Add some definitions that will disable the MPI-2 C++ bindings. +# Currently supported are MPICH, Open MPI, Platform MPI and derivatives thereof, +# for example MVAPICH or Intel MPI. +# +# If the find procedure fails for a variable ``MPI__WORKS``, then the settings detected by or passed to +# the module did not work and even a simple MPI test program failed to compile. +# +# If all of these parameters were not sufficient to find the right MPI implementation, a user may +# disable the entire autodetection process by specifying both a list of libraries in ``MPI__LIBRARIES`` +# and a list of include directories in ``MPI__ADDITIONAL_INCLUDE_DIRS``. +# Any other variable may be set in addition to these two. The module will then validate the MPI settings and store the +# settings in the cache. +# +# Cache variables for MPI +# ^^^^^^^^^^^^^^^^^^^^^^^ +# +# The variable ``MPI__INCLUDE_DIRS`` will be assembled from the following variables. +# For C and CXX: +# +# ``MPI__HEADER_DIR`` +# Location of the ``mpi.h`` header on disk. +# +# For Fortran: +# +# ``MPI_Fortran_F77_HEADER_DIR`` +# Location of the Fortran 77 header ``mpif.h``, if it exists. +# ``MPI_Fortran_MODULE_DIR`` +# Location of the ``mpi`` or ``mpi_f08`` modules, if available. +# +# For all languages the following variables are additionally considered: +# +# ``MPI__ADDITIONAL_INCLUDE_DIRS`` +# A :ref:`;-list ` of paths needed in addition to the normal include directories. +# ``MPI__INCLUDE_DIR`` +# Path variables for include folders referred to by ````. +# ``MPI__ADDITIONAL_INCLUDE_VARS`` +# A :ref:`;-list ` of ```` that will be added to the include locations of ````. +# +# The variable ``MPI__LIBRARIES`` will be assembled from the following variables: +# +# ``MPI__LIBRARY`` +# The location of a library called ```` for use with MPI. +# ``MPI__LIB_NAMES`` +# A :ref:`;-list ` of ```` that will be added to the include locations of ````. +# +# Usage of mpiexec +# ^^^^^^^^^^^^^^^^ +# +# When using ``MPIEXEC_EXECUTABLE`` to execute MPI applications, you should typically +# use all of the ``MPIEXEC_EXECUTABLE`` flags as follows: # # :: # -# ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} +# ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} # ${MPIEXEC_PREFLAGS} EXECUTABLE ${MPIEXEC_POSTFLAGS} ARGS # # where ``EXECUTABLE`` is the MPI program, and ``ARGS`` are the arguments to # pass to the MPI program. # +# Advanced variables for using MPI +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +# +# The module can perform some advanced feature detections upon explicit request. +# +# **Important notice:** The following checks cannot be performed without *executing* an MPI test program. +# Consider the special considerations for the behavior of :command:`try_run` during cross compilation. +# Moreover, running an MPI program can cause additional issues, like a firewall notification on some systems. +# You should only enable these detections if you absolutely need the information. +# +# If the following variables are set to true, the respective search will be performed: +# +# ``MPI_DETERMINE_Fortran_CAPABILITIES`` +# Determine for all available Fortran bindings what the values of ``MPI_SUBARRAYS_SUPPORTED`` and +# ``MPI_ASYNC_PROTECTS_NONBLOCKING`` are and make their values available as ``MPI_Fortran__SUBARRAYS`` +# and ``MPI_Fortran__ASYNCPROT``, where ```` is one of ``F77_HEADER``, ``F90_MODULE`` and +# ``F08_MODULE``. +# ``MPI_DETERMINE_LIBRARY_VERSION`` +# For each language, find the output of ``MPI_Get_library_version`` and make it available as ``MPI__LIBRARY_VERSION``. +# This information is usually tied to the runtime component of an MPI implementation and might differ depending on ````. +# Note that the return value is entirely implementation defined. This information might be used to identify +# the MPI vendor and for example pick the correct one of multiple third party binaries that matches the MPI vendor. +# # Backward Compatibility # ^^^^^^^^^^^^^^^^^^^^^^ # @@ -91,54 +228,62 @@ # # :: # -# MPI_FOUND MPI_COMPILER MPI_LIBRARY -# MPI_COMPILE_FLAGS MPI_INCLUDE_PATH MPI_EXTRA_LIBRARY -# MPI_LINK_FLAGS MPI_LIBRARIES +# MPI_COMPILER MPI_LIBRARY MPI_EXTRA_LIBRARY +# MPI_COMPILE_FLAGS MPI_INCLUDE_PATH MPI_LINK_FLAGS +# MPI_LIBRARIES # # In new projects, please use the ``MPI__XXX`` equivalents. +# Additionally, the following variables are deprecated: +# +# ``MPI__COMPILE_FLAGS`` +# Use ``MPI__COMPILE_OPTIONS`` and ``MPI__COMPILE_DEFINITIONS`` instead. +# ``MPI__INCLUDE_PATH`` +# For consumption use ``MPI__INCLUDE_DIRS`` and for specifying folders use ``MPI__ADDITIONAL_INCLUDE_DIRS`` instead. +# ``MPIEXEC`` +# Use ``MPIEXEC_EXECUTABLE`` instead. + +cmake_policy(PUSH) +cmake_policy(SET CMP0057 NEW) # if IN_LIST # include this to handle the QUIETLY and REQUIRED arguments include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) include(GetPrerequisites) -# -# This part detects MPI compilers, attempting to wade through the mess of compiler names in -# a sensible way. -# -# The compilers are detected in this order: -# -# 1. Try to find the most generic available MPI compiler, as this is usually set up by -# cluster admins, e.g. if plain old mpicc is available, we'll use it and assume it's -# the right compiler. -# -# 2. If a generic mpicc is NOT found, then we attempt to find one that matches -# CMAKE__COMPILER_ID. e.g. if you are using XL compilers, we'll try to find mpixlc -# and company, but not mpiicc. This hopefully prevents toolchain mismatches. -# -# If you want to force a particular MPI compiler other than what we autodetect (e.g. if you -# want to compile regular stuff with GNU and parallel stuff with Intel), you can always set -# your favorite MPI__COMPILER explicitly and this stuff will be ignored. -# - -# Start out with the generic MPI compiler names, as these are most commonly used. -set(_MPI_C_COMPILER_NAMES mpicc mpcc mpicc_r mpcc_r mpicc.bat) -set(_MPI_CXX_COMPILER_NAMES mpicxx mpiCC mpcxx mpCC mpic++ mpc++ - mpicxx_r mpiCC_r mpcxx_r mpCC_r mpic++_r mpc++_r - mpicxx.bat) -set(_MPI_Fortran_COMPILER_NAMES mpif95 mpif95_r mpf95 mpf95_r +# Generic compiler names +set(_MPI_C_GENERIC_COMPILER_NAMES mpicc mpcc mpicc_r mpcc_r) +set(_MPI_CXX_GENERIC_COMPILER_NAMES mpicxx mpiCC mpcxx mpCC mpic++ mpc++ + mpicxx_r mpiCC_r mpcxx_r mpCC_r mpic++_r mpc++_r) +set(_MPI_Fortran_GENERIC_COMPILER_NAMES mpif95 mpif95_r mpf95 mpf95_r mpif90 mpif90_r mpf90 mpf90_r - mpif77 mpif77_r mpf77 mpf77_r) + mpif77 mpif77_r mpf77 mpf77_r + mpifc) # GNU compiler names set(_MPI_GNU_C_COMPILER_NAMES mpigcc mpgcc mpigcc_r mpgcc_r) -set(_MPI_GNU_CXX_COMPILER_NAMES mpig++ mpg++ mpig++_r mpg++_r) +set(_MPI_GNU_CXX_COMPILER_NAMES mpig++ mpg++ mpig++_r mpg++_r mpigxx) set(_MPI_GNU_Fortran_COMPILER_NAMES mpigfortran mpgfortran mpigfortran_r mpgfortran_r mpig77 mpig77_r mpg77 mpg77_r) -# Intel MPI compiler names -set(_MPI_Intel_C_COMPILER_NAMES mpiicc mpiicc.bat) -set(_MPI_Intel_CXX_COMPILER_NAMES mpiicpc mpiicxx mpiic++ mpiiCC mpiicpc.bat) -set(_MPI_Intel_Fortran_COMPILER_NAMES mpiifort mpiif95 mpiif90 mpiif77 mpiifort.bat) +# Intel MPI compiler names on Windows +if(WIN32) + list(APPEND _MPI_C_GENERIC_COMPILER_NAMES mpicc.bat) + list(APPEND _MPI_CXX_GENERIC_COMPILER_NAMES mpicxx.bat) + list(APPEND _MPI_Fortran_GENERIC_COMPILER_NAMES mpifc.bat) + + # Intel MPI compiler names + set(_MPI_Intel_C_COMPILER_NAMES mpiicc.bat) + set(_MPI_Intel_CXX_COMPILER_NAMES mpiicpc.bat) + set(_MPI_Intel_Fortran_COMPILER_NAMES mpiifort.bat mpif77.bat mpif90.bat) + + # Intel MPI compiler names for MSMPI + set(_MPI_MSVC_C_COMPILER_NAMES mpicl.bat) + set(_MPI_MSVC_CXX_COMPILER_NAMES mpicl.bat) +else() + # Intel compiler names + set(_MPI_Intel_C_COMPILER_NAMES mpiicc) + set(_MPI_Intel_CXX_COMPILER_NAMES mpiicpc mpiicxx mpiic++) + set(_MPI_Intel_Fortran_COMPILER_NAMES mpiifort mpiif95 mpiif90 mpiif77) +endif() # PGI compiler names set(_MPI_PGI_C_COMPILER_NAMES mpipgcc mppgcc) @@ -154,548 +299,1127 @@ set(_MPI_XL_Fortran_COMPILER_NAMES mpixlf95 mpixlf95_r mpxlf95 mpxlf95 mpixlf77 mpixlf77_r mpxlf77 mpxlf77_r mpixlf mpixlf_r mpxlf mpxlf_r) -# append vendor-specific compilers to the list if we either don't know the compiler id, -# or if we know it matches the regular compiler. -foreach (lang C CXX Fortran) - foreach (id GNU Intel PGI XL) - if (NOT CMAKE_${lang}_COMPILER_ID OR CMAKE_${lang}_COMPILER_ID STREQUAL id) - list(APPEND _MPI_${lang}_COMPILER_NAMES ${_MPI_${id}_${lang}_COMPILER_NAMES}) +# Prepend vendor-specific compiler wrappers to the list. If we don't know the compiler, +# attempt all of them. +# By attempting vendor-specific compiler names first, we should avoid situations where the compiler wrapper +# stems from a proprietary MPI and won't know which compiler it's being used for. For instance, Intel MPI +# controls its settings via the I_MPI_CC environment variables if the generic name is being used. +# If we know which compiler we're working with, we can use the most specialized wrapper there is in order to +# pick up the right settings for it. +foreach (LANG IN ITEMS C CXX Fortran) + set(_MPI_${LANG}_COMPILER_NAMES "") + foreach (id IN ITEMS GNU Intel MSVC PGI XL) + if (NOT CMAKE_${LANG}_COMPILER_ID OR CMAKE_${LANG}_COMPILER_ID STREQUAL id) + list(APPEND _MPI_${LANG}_COMPILER_NAMES ${_MPI_${id}_${LANG}_COMPILER_NAMES}${MPI_EXECUTABLE_SUFFIX}) endif() - unset(_MPI_${id}_${lang}_COMPILER_NAMES) # clean up the namespace here + unset(_MPI_${id}_${LANG}_COMPILER_NAMES) endforeach() + list(APPEND _MPI_${LANG}_COMPILER_NAMES ${_MPI_${LANG}_GENERIC_COMPILER_NAMES}${MPI_EXECUTABLE_SUFFIX}) + unset(_MPI_${LANG}_GENERIC_COMPILER_NAMES) endforeach() +# Names to try for mpiexec +# Only mpiexec commands are guaranteed to behave as described in the standard, +# mpirun commands are not covered by the standard in any way whatsoever. +# lamexec is the executable for LAM/MPI, srun is for SLURM or Open MPI with SLURM support. +# srun -n X is however a valid command, so it behaves 'like' mpiexec. +set(_MPIEXEC_NAMES_BASE mpiexec mpiexec.hydra mpiexec.mpd mpirun lamexec srun) -# Names to try for MPI exec -set(_MPI_EXEC_NAMES mpiexec mpirun lamexec srun) - -# Grab the path to MPI from the registry if we're on windows. -set(_MPI_PREFIX_PATH) -if(WIN32) - # MSMPI - file(TO_CMAKE_PATH "$ENV{MSMPI_BIN}" msmpi_bin_path) # The default path ends with a '\' and doesn't mix with ';' when appending. - list(APPEND _MPI_PREFIX_PATH "${msmpi_bin_path}") - unset(msmpi_bin_path) - list(APPEND _MPI_PREFIX_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MPI;InstallRoot]/Bin") - list(APPEND _MPI_PREFIX_PATH "$ENV{MSMPI_INC}/..") # The SDK is installed separately from the runtime - # MPICH - list(APPEND _MPI_PREFIX_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MPICH\\SMPD;binary]/..") - list(APPEND _MPI_PREFIX_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MPICH2;Path]") - list(APPEND _MPI_PREFIX_PATH "$ENV{ProgramW6432}/MPICH2/") - # INTEL MPI - list(APPEND _MPI_PREFIX_PATH "$ENV{I_MPI_ROOT}/intel64/") - -endif() - -# Build a list of prefixes to search for MPI. -foreach(SystemPrefixDir ${CMAKE_SYSTEM_PREFIX_PATH}) - foreach(MpiPackageDir ${_MPI_PREFIX_PATH}) - if(EXISTS ${SystemPrefixDir}/${MpiPackageDir}) - list(APPEND _MPI_PREFIX_PATH "${SystemPrefixDir}/${MpiPackageDir}") - endif() - endforeach() +unset(_MPIEXEC_NAMES) +foreach(_MPIEXEC_NAME IN LISTS _MPIEXEC_NAMES_BASE) + list(APPEND _MPIEXEC_NAMES "${_MPIEXEC_NAME}${MPI_EXECUTABLE_SUFFIX}") endforeach() +unset(_MPIEXEC_NAMES_BASE) -function (_mpi_check_compiler compiler options cmdvar resvar) +function (_MPI_check_compiler LANG QUERY_FLAG OUTPUT_VARIABLE RESULT_VARIABLE) + if(DEFINED MPI_${LANG}_COMPILER_FLAGS) + separate_arguments(_MPI_COMPILER_WRAPPER_OPTIONS NATIVE_COMMAND "${MPI_${LANG}_COMPILER_FLAGS}") + else() + separate_arguments(_MPI_COMPILER_WRAPPER_OPTIONS NATIVE_COMMAND "${MPI_COMPILER_FLAGS}") + endif() execute_process( - COMMAND "${compiler}" ${options} - OUTPUT_VARIABLE cmdline OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_VARIABLE cmdline ERROR_STRIP_TRAILING_WHITESPACE - RESULT_VARIABLE success) - # Intel MPI 5.0.1 will return a zero return code even when the - # argument to the MPI compiler wrapper is unknown. Attempt to - # catch this case. - if(cmdline MATCHES "undefined reference" OR cmdline MATCHES "unrecognized") - set(success 255 ) - endif() - set(${cmdvar} "${cmdline}" PARENT_SCOPE) - set(${resvar} "${success}" PARENT_SCOPE) + COMMAND ${MPI_${LANG}_COMPILER} ${_MPI_COMPILER_WRAPPER_OPTIONS} ${QUERY_FLAG} + OUTPUT_VARIABLE WRAPPER_OUTPUT OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_VARIABLE WRAPPER_OUTPUT ERROR_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE WRAPPER_RETURN) + # Some compiler wrappers will yield spurious zero return values, for example + # Intel MPI tolerates unknown arguments and if the MPI wrappers loads a shared + # library that has invalid or missing version information there would be warning + # messages emitted by ld.so in the compiler output. In either case, we'll treat + # the output as invalid. + if("${WRAPPER_OUTPUT}" MATCHES "undefined reference|unrecognized|need to set|no version information available") + set(WRAPPER_RETURN 255) + endif() + # Ensure that no error output might be passed upwards. + if(NOT WRAPPER_RETURN EQUAL 0) + unset(WRAPPER_OUTPUT) + endif() + set(${OUTPUT_VARIABLE} "${WRAPPER_OUTPUT}" PARENT_SCOPE) + set(${RESULT_VARIABLE} "${WRAPPER_RETURN}" PARENT_SCOPE) endfunction() -# -# interrogate_mpi_compiler(lang try_libs) -# -# Attempts to extract compiler and linker args from an MPI compiler. The arguments set -# by this function are: -# -# MPI__INCLUDE_PATH MPI__LINK_FLAGS MPI__FOUND -# MPI__COMPILE_FLAGS MPI__LIBRARIES -# -# MPI__COMPILER must be set beforehand to the absolute path to an MPI compiler for -# . Additionally, MPI__INCLUDE_PATH and MPI__LIBRARIES may be set -# to skip autodetection. -# -# If try_libs is TRUE, this will also attempt to find plain MPI libraries in the usual -# way. In general, this is not as effective as interrogating the compilers, as it -# ignores language-specific flags and libraries. However, some MPI implementations -# (Windows implementations) do not have compiler wrappers, so this approach must be used. -# -function (interrogate_mpi_compiler lang try_libs) - # MPI_${lang}_NO_INTERROGATE will be set to a compiler name when the *regular* compiler was - # discovered to be the MPI compiler. This happens on machines like the Cray XE6 that use - # modules to set cc, CC, and ftn to the MPI compilers. If the user force-sets another MPI - # compiler, MPI_${lang}_COMPILER won't be equal to MPI_${lang}_NO_INTERROGATE, and we'll - # inspect that compiler anew. This allows users to set new compilers w/o rm'ing cache. - string(COMPARE NOTEQUAL "${MPI_${lang}_NO_INTERROGATE}" "${MPI_${lang}_COMPILER}" interrogate) - - # If MPI is set already in the cache, don't bother with interrogating the compiler. - if (interrogate AND ((NOT MPI_${lang}_INCLUDE_PATH) OR (NOT MPI_${lang}_LIBRARIES))) - if (MPI_${lang}_COMPILER) - # Check whether the -showme:compile option works. This indicates that we have either OpenMPI - # or a newer version of LAM-MPI, and implies that -showme:link will also work. - _mpi_check_compiler("${MPI_${lang}_COMPILER}" "-showme:compile" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) - if (MPI_COMPILER_RETURN EQUAL 0) - # If we appear to have -showme:compile, then we should - # also have -showme:link. Try it. - execute_process( - COMMAND ${MPI_${lang}_COMPILER} -showme:link - OUTPUT_VARIABLE MPI_LINK_CMDLINE OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_VARIABLE MPI_LINK_CMDLINE ERROR_STRIP_TRAILING_WHITESPACE - RESULT_VARIABLE MPI_COMPILER_RETURN) - - if (MPI_COMPILER_RETURN EQUAL 0) - # We probably have -showme:incdirs and -showme:libdirs as well, - # so grab that while we're at it. - execute_process( - COMMAND ${MPI_${lang}_COMPILER} -showme:incdirs - OUTPUT_VARIABLE MPI_INCDIRS OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_VARIABLE MPI_INCDIRS ERROR_STRIP_TRAILING_WHITESPACE) - - execute_process( - COMMAND ${MPI_${lang}_COMPILER} -showme:libdirs - OUTPUT_VARIABLE MPI_LIBDIRS OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_VARIABLE MPI_LIBDIRS ERROR_STRIP_TRAILING_WHITESPACE) +function (_MPI_interrogate_compiler lang) + unset(MPI_COMPILE_CMDLINE) + unset(MPI_LINK_CMDLINE) + + unset(MPI_COMPILE_OPTIONS_WORK) + unset(MPI_COMPILE_DEFINITIONS_WORK) + unset(MPI_INCLUDE_DIRS_WORK) + unset(MPI_LINK_FLAGS_WORK) + unset(MPI_LIB_NAMES_WORK) + unset(MPI_LIB_FULLPATHS_WORK) + + # Check whether the -showme:compile option works. This indicates that we have either Open MPI + # or a newer version of LAM/MPI, and implies that -showme:link will also work. + # Open MPI also supports -show, but separates linker and compiler information + _MPI_check_compiler(${LANG} "-showme:compile" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) + if (MPI_COMPILER_RETURN EQUAL 0) + _MPI_check_compiler(${LANG} "-showme:link" MPI_LINK_CMDLINE MPI_COMPILER_RETURN) + + if (NOT MPI_COMPILER_RETURN EQUAL 0) + unset(MPI_COMPILE_CMDLINE) + endif() + endif() - else() - # reset things here if something went wrong. - set(MPI_COMPILE_CMDLINE) - set(MPI_LINK_CMDLINE) - endif() - endif () + # MPICH and MVAPICH offer -compile-info and -link-info. + # For modern versions, both do the same as -show. However, for old versions, they do differ + # when called for mpicxx and mpif90 and it's necessary to use them over -show in order to find the + # removed MPI C++ bindings. + if (NOT MPI_COMPILER_RETURN EQUAL 0) + _MPI_check_compiler(${LANG} "-compile-info" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) + + if (MPI_COMPILER_RETURN EQUAL 0) + _MPI_check_compiler(${LANG} "-link-info" MPI_LINK_CMDLINE MPI_COMPILER_RETURN) - # Older versions of LAM-MPI have "-showme". Try to find that. if (NOT MPI_COMPILER_RETURN EQUAL 0) - _mpi_check_compiler("${MPI_${lang}_COMPILER}" "-showme" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) + unset(MPI_COMPILE_CMDLINE) endif() + endif() + endif() - # MVAPICH uses -compile-info and -link-info. Try them. - if (NOT MPI_COMPILER_RETURN EQUAL 0) - _mpi_check_compiler("${MPI_${lang}_COMPILER}" "-compile-info" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) - - # If we have compile-info, also have link-info. - if (MPI_COMPILER_RETURN EQUAL 0) - execute_process( - COMMAND ${MPI_${lang}_COMPILER} -link-info - OUTPUT_VARIABLE MPI_LINK_CMDLINE OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_VARIABLE MPI_LINK_CMDLINE ERROR_STRIP_TRAILING_WHITESPACE - RESULT_VARIABLE MPI_COMPILER_RETURN) - endif() + # MPICH, MVAPICH2 and Intel MPI just use "-show". Open MPI also offers this, but the + # -showme commands are more specialized. + if (NOT MPI_COMPILER_RETURN EQUAL 0) + _MPI_check_compiler(${LANG} "-show" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) + endif() - # make sure we got compile and link. Reset vars if something's wrong. - if (NOT MPI_COMPILER_RETURN EQUAL 0) - set(MPI_COMPILE_CMDLINE) - set(MPI_LINK_CMDLINE) - endif() - endif() + # Older versions of LAM/MPI have "-showme". Open MPI also supports this. + # Unknown to MPICH, MVAPICH and Intel MPI. + if (NOT MPI_COMPILER_RETURN EQUAL 0) + _MPI_check_compiler(${LANG} "-showme" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) + endif() - # MPICH just uses "-show". Try it. - if (NOT MPI_COMPILER_RETURN EQUAL 0) - _mpi_check_compiler("${MPI_${lang}_COMPILER}" "-show" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) - endif() + if (NOT (MPI_COMPILER_RETURN EQUAL 0) OR NOT (DEFINED MPI_COMPILE_CMDLINE)) + # Cannot interrogate this compiler, so exit. + set(MPI_${LANG}_WRAPPER_FOUND FALSE PARENT_SCOPE) + return() + endif() + unset(MPI_COMPILER_RETURN) - if (MPI_COMPILER_RETURN EQUAL 0) - # We have our command lines, but we might need to copy MPI_COMPILE_CMDLINE - # into MPI_LINK_CMDLINE, if we didn't find the link line. - if (NOT MPI_LINK_CMDLINE) - set(MPI_LINK_CMDLINE ${MPI_COMPILE_CMDLINE}) - endif() + # We have our command lines, but we might need to copy MPI_COMPILE_CMDLINE + # into MPI_LINK_CMDLINE, if we didn't find the link line. + if (NOT DEFINED MPI_LINK_CMDLINE) + set(MPI_LINK_CMDLINE "${MPI_COMPILE_CMDLINE}") + endif() + + # At this point, we obtained some output from a compiler wrapper that works. + # We'll now try to parse it into variables with meaning to us. + if("${LANG}" STREQUAL "Fortran") + # Some MPICH-1 and MVAPICH-1 versions return a three command answer for Fortran, consisting + # out of a symlink command for mpif.h, the actual compiler command and a deletion of the + # created symlink. We need to detect that case, remember the include path and drop the + # symlink/deletion operation to obtain the link/compile lines we'd usually expect. + if("${MPI_COMPILE_CMDLINE}" MATCHES "^ln -s ([^\" ]+|\"[^\"]+\") mpif.h") + get_filename_component(MPI_INCLUDE_DIRS_WORK "${CMAKE_MATCH_1}" DIRECTORY) + string(REGEX REPLACE "^ln -s ([^\" ]+|\"[^\"]+\") mpif.h\n" "" MPI_COMPILE_CMDLINE "${MPI_COMPILE_CMDLINE}") + string(REGEX REPLACE "^ln -s ([^\" ]+|\"[^\"]+\") mpif.h\n" "" MPI_LINK_CMDLINE "${MPI_LINK_CMDLINE}") + string(REGEX REPLACE "\nrm -f mpif.h$" "" MPI_COMPILE_CMDLINE "${MPI_COMPILE_CMDLINE}") + string(REGEX REPLACE "\nrm -f mpif.h$" "" MPI_LINK_CMDLINE "${MPI_LINK_CMDLINE}") + endif() + endif() + + # The Intel MPI wrapper on Linux will emit some objcopy commands after its compile command + # if -static_mpi was passed to the wrapper. To avoid spurious matches, we need to drop these lines. + if(UNIX) + string(REGEX REPLACE "(^|\n)objcopy[^\n]+(\n|$)" "" MPI_COMPILE_CMDLINE "${MPI_COMPILE_CMDLINE}") + string(REGEX REPLACE "(^|\n)objcopy[^\n]+(\n|$)" "" MPI_LINK_CMDLINE "${MPI_LINK_CMDLINE}") + endif() + + # Extract compile options from the compile command line. + string(REGEX MATCHALL "(^| )-f([^\" ]+|\"[^\"]+\")" MPI_ALL_COMPILE_OPTIONS "${MPI_COMPILE_CMDLINE}") + + foreach(_MPI_COMPILE_OPTION IN LISTS MPI_ALL_COMPILE_OPTIONS) + string(REGEX REPLACE "^ " "" _MPI_COMPILE_OPTION "${_MPI_COMPILE_OPTION}") + # Ignore -fstack-protector directives: These occur on MPICH and MVAPICH when the libraries + # themselves were built with this flag. However, this flag is unrelated to using MPI, and + # we won't match the accompanying --param-ssp-size and -Wp,-D_FORTIFY_SOURCE flags and therefore + # produce inconsistent results with the regularly flags. + # Similarly, aliasing flags do not belong into our flag array. + if(NOT "${_MPI_COMPILE_OPTION}" MATCHES "^-f(stack-protector|(no-|)strict-aliasing|PI[CE]|pi[ce])") + list(APPEND MPI_COMPILE_OPTIONS_WORK "${_MPI_COMPILE_OPTION}") + endif() + endforeach() + + # Same deal, with the definitions. We also treat arguments passed to the preprocessor directly. + string(REGEX MATCHALL "(^| )(-Wp,|-Xpreprocessor |)[-/]D([^\" ]+|\"[^\"]+\")" MPI_ALL_COMPILE_DEFINITIONS "${MPI_COMPILE_CMDLINE}") + + foreach(_MPI_COMPILE_DEFINITION IN LISTS MPI_ALL_COMPILE_DEFINITIONS) + string(REGEX REPLACE "^ ?(-Wp,|-Xpreprocessor )?[-/]D" "" _MPI_COMPILE_DEFINITION "${_MPI_COMPILE_DEFINITION}") + string(REPLACE "\"" "" _MPI_COMPILE_DEFINITION "${_MPI_COMPILE_DEFINITION}") + if(NOT "${_MPI_COMPILE_DEFINITION}" MATCHES "^_FORTIFY_SOURCE.*") + list(APPEND MPI_COMPILE_DEFINITIONS_WORK "${_MPI_COMPILE_DEFINITION}") + endif() + endforeach() + + # Extract include paths from compile command line + string(REGEX MATCHALL "(^| )[-/]I([^\" ]+|\"[^\"]+\")" MPI_ALL_INCLUDE_PATHS "${MPI_COMPILE_CMDLINE}") + + # If extracting failed to work, we'll try using -showme:incdirs. + if (NOT MPI_ALL_INCLUDE_PATHS) + _MPI_check_compiler(${LANG} "-showme:incdirs" MPI_INCDIRS_CMDLINE MPI_INCDIRS_COMPILER_RETURN) + if(MPI_INCDIRS_COMPILER_RETURN) + separate_arguments(MPI_ALL_INCLUDE_PATHS NATIVE_COMMAND "${MPI_INCDIRS_CMDLINE}") + endif() + endif() + + foreach(_MPI_INCLUDE_PATH IN LISTS MPI_ALL_INCLUDE_PATHS) + string(REGEX REPLACE "^ ?[-/]I" "" _MPI_INCLUDE_PATH "${_MPI_INCLUDE_PATH}") + string(REPLACE "\"" "" _MPI_INCLUDE_PATH "${_MPI_INCLUDE_PATH}") + get_filename_component(_MPI_INCLUDE_PATH "${_MPI_INCLUDE_PATH}" REALPATH) + list(APPEND MPI_INCLUDE_DIRS_WORK "${_MPI_INCLUDE_PATH}") + endforeach() + + # Extract linker paths from the link command line + string(REGEX MATCHALL "(^| )(-Wl,|-Xlinker |)(-L|[/-]LIBPATH:|[/-]libpath:)([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_PATHS "${MPI_LINK_CMDLINE}") + + # If extracting failed to work, we'll try using -showme:libdirs. + if (NOT MPI_ALL_LINK_PATHS) + _MPI_check_compiler(${LANG} "-showme:libdirs" MPI_LIBDIRS_CMDLINE MPI_LIBDIRS_COMPILER_RETURN) + if(MPI_LIBDIRS_COMPILER_RETURN) + separate_arguments(MPI_ALL_LINK_PATHS NATIVE_COMMAND "${MPI_LIBDIRS_CMDLINE}") + endif() + endif() + + foreach(_MPI_LPATH IN LISTS MPI_ALL_LINK_PATHS) + string(REGEX REPLACE "^ ?(-Wl,|-Xlinker )?(-L|[/-]LIBPATH:|[/-]libpath:)" "" _MPI_LPATH "${_MPI_LPATH}") + string(REPLACE "\"" "" _MPI_LPATH "${_MPI_LPATH}") + get_filename_component(_MPI_LPATH "${_MPI_LPATH}" REALPATH) + list(APPEND MPI_LINK_DIRECTORIES_WORK "${_MPI_LPATH}") + endforeach() + + # Extract linker flags from the link command line + string(REGEX MATCHALL "(^| )(-Wl,|-Xlinker )([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_FLAGS "${MPI_LINK_CMDLINE}") + + foreach(_MPI_LINK_FLAG IN LISTS MPI_ALL_LINK_FLAGS) + string(STRIP "${_MPI_LINK_FLAG}" _MPI_LINK_FLAG) + # MPI might be marked to build with non-executable stacks but this should not propagate. + if (NOT "${_MPI_LINK_FLAG}" MATCHES "(-Wl,|-Xlinker )-z,noexecstack") + if (MPI_LINK_FLAGS_WORK) + string(APPEND MPI_LINK_FLAGS_WORK " ${_MPI_LINK_FLAG}") else() - message(STATUS "Unable to determine MPI from MPI driver ${MPI_${lang}_COMPILER}") - set(MPI_COMPILE_CMDLINE) - set(MPI_LINK_CMDLINE) + set(MPI_LINK_FLAGS_WORK "${_MPI_LINK_FLAG}") endif() + endif() + endforeach() - # Here, we're done with the interrogation part, and we'll try to extract args we care - # about from what we learned from the compiler wrapper scripts. - - # If interrogation came back with something, extract our variable from the MPI command line - if (MPI_COMPILE_CMDLINE OR MPI_LINK_CMDLINE) - # Extract compile flags from the compile command line. - string(REGEX MATCHALL "(^| )-[Df]([^\" ]+|\"[^\"]+\")" MPI_ALL_COMPILE_FLAGS "${MPI_COMPILE_CMDLINE}") - set(MPI_COMPILE_FLAGS_WORK) + # Extract the set of libraries to link against from the link command + # line + string(REGEX MATCHALL "(^| )-l([^\" ]+|\"[^\"]+\")" MPI_LIBNAMES "${MPI_LINK_CMDLINE}") - foreach(FLAG ${MPI_ALL_COMPILE_FLAGS}) - string(REGEX REPLACE "^ " "" FLAG ${FLAG}) - if (MPI_COMPILE_FLAGS_WORK) - set(MPI_COMPILE_FLAGS_WORK "${MPI_COMPILE_FLAGS_WORK} ${FLAG}") - else() - set(MPI_COMPILE_FLAGS_WORK ${FLAG}) - endif() - endforeach() + foreach(_MPI_LIB_NAME IN LISTS MPI_LIBNAMES) + string(REGEX REPLACE "^ ?-l" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") + string(REPLACE "\"" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") + get_filename_component(_MPI_LIB_PATH "${_MPI_LIB_NAME}" DIRECTORY) + if(NOT "${_MPI_LIB_PATH}" STREQUAL "") + list(APPEND MPI_LIB_FULLPATHS_WORK "${_MPI_LIB_NAME}") + else() + list(APPEND MPI_LIB_NAMES_WORK "${_MPI_LIB_NAME}") + endif() + endforeach() - # Extract include paths from compile command line - string(REGEX MATCHALL "(^| )-I([^\" ]+|\"[^\"]+\")" MPI_ALL_INCLUDE_PATHS "${MPI_COMPILE_CMDLINE}") - set(MPI_INCLUDE_PATH_WORK) + if(WIN32) + # A compiler wrapper on Windows will just have the name of the + # library to link on its link line, potentially with a full path + string(REGEX MATCHALL "(^| )([^\" ]+\\.lib|\"[^\"]+\\.lib\")" MPI_LIBNAMES "${MPI_LINK_CMDLINE}") + foreach(_MPI_LIB_NAME IN LISTS MPI_LIBNAMES) + string(REGEX REPLACE "^ " "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") + string(REPLACE "\"" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") + get_filename_component(_MPI_LIB_PATH "${_MPI_LIB_NAME}" DIRECTORY) + if(NOT "${_MPI_LIB_PATH}" STREQUAL "") + list(APPEND MPI_LIB_FULLPATHS_WORK "${_MPI_LIB_NAME}") + else() + list(APPEND MPI_LIB_NAMES_WORK "${_MPI_LIB_NAME}") + endif() + endforeach() + else() + # On UNIX platforms, archive libraries can be given with full path. + string(REGEX MATCHALL "(^| )([^\" ]+\\.a|\"[^\"]+\\.a\")" MPI_LIBFULLPATHS "${MPI_LINK_CMDLINE}") + foreach(_MPI_LIB_NAME IN LISTS MPI_LIBFULLPATHS) + string(REGEX REPLACE "^ " "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") + string(REPLACE "\"" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") + get_filename_component(_MPI_LIB_PATH "${_MPI_LIB_NAME}" DIRECTORY) + if(NOT "${_MPI_LIB_PATH}" STREQUAL "") + list(APPEND MPI_LIB_FULLPATHS_WORK "${_MPI_LIB_NAME}") + else() + list(APPEND MPI_LIB_NAMES_WORK "${_MPI_LIB_NAME}") + endif() + endforeach() + endif() - foreach(IPATH ${MPI_ALL_INCLUDE_PATHS}) - string(REGEX REPLACE "^ ?-I" "" IPATH ${IPATH}) - string(REPLACE "//" "/" IPATH ${IPATH}) - string(REPLACE "\"" "" IPATH ${IPATH}) - file(TO_CMAKE_PATH "${IPATH}" IPATH) - list(APPEND MPI_INCLUDE_PATH_WORK ${IPATH}) - endforeach() + # An MPI compiler wrapper could have its MPI libraries in the implictly + # linked directories of the compiler itself. + if(DEFINED CMAKE_${LANG}_IMPLICIT_LINK_DIRECTORIES) + list(APPEND MPI_LINK_DIRECTORIES_WORK "${CMAKE_${LANG}_IMPLICIT_LINK_DIRECTORIES}") + endif() - # try using showme:incdirs if extracting didn't work. - if (NOT MPI_INCLUDE_PATH_WORK) - set(MPI_INCLUDE_PATH_WORK ${MPI_INCDIRS}) - separate_arguments(MPI_INCLUDE_PATH_WORK) - endif() + # Determine full path names for all of the libraries that one needs + # to link against in an MPI program + unset(MPI_PLAIN_LIB_NAMES_WORK) + foreach(_MPI_LIB_NAME IN LISTS MPI_LIB_NAMES_WORK) + get_filename_component(_MPI_PLAIN_LIB_NAME "${_MPI_LIB_NAME}" NAME_WE) + list(APPEND MPI_PLAIN_LIB_NAMES_WORK "${_MPI_PLAIN_LIB_NAME}") + find_library(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY + NAMES "${_MPI_LIB_NAME}" "lib${_MPI_LIB_NAME}" + HINTS ${MPI_LINK_DIRECTORIES_WORK} + DOC "Location of the ${_MPI_PLAIN_LIB_NAME} library for MPI" + ) + mark_as_advanced(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY) + endforeach() - # If all else fails, just search for mpi.h in the normal include paths. - if (NOT MPI_INCLUDE_PATH_WORK) - set(MPI_HEADER_PATH "MPI_HEADER_PATH-NOTFOUND" CACHE FILEPATH "Cleared" FORCE) - find_path(MPI_HEADER_PATH mpi.h - HINTS ${_MPI_BASE_DIR} ${_MPI_PREFIX_PATH} - PATH_SUFFIXES include) - set(MPI_INCLUDE_PATH_WORK ${MPI_HEADER_PATH}) - endif() + # Deal with the libraries given with full path next + unset(MPI_DIRECT_LIB_NAMES_WORK) + foreach(_MPI_LIB_FULLPATH IN LISTS MPI_LIB_FULLPATHS_WORK) + get_filename_component(_MPI_PLAIN_LIB_NAME "${_MPI_LIB_FULLPATH}" NAME_WE) + get_filename_component(_MPI_LIB_NAME "${_MPI_LIB_FULLPATH}" NAME) + get_filename_component(_MPI_LIB_PATH "${_MPI_LIB_FULLPATH}" DIRECTORY) + list(APPEND MPI_DIRECT_LIB_NAMES_WORK "${_MPI_PLAIN_LIB_NAME}") + find_library(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY + NAMES "${_MPI_LIB_NAME}" + HINTS ${_MPI_LIB_PATH} + DOC "Location of the ${_MPI_PLAIN_LIB_NAME} library for MPI" + ) + mark_as_advanced(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY) + endforeach() + if(MPI_DIRECT_LIB_NAMES_WORK) + set(MPI_PLAIN_LIB_NAMES_WORK "${MPI_DIRECT_LIB_NAMES_WORK};${MPI_PLAIN_LIB_NAMES_WORK}") + endif() - # Extract linker paths from the link command line - string(REGEX MATCHALL "(^| |-Wl,)(-L|/LIBPATH:)([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_PATHS "${MPI_LINK_CMDLINE}") - set(MPI_LINK_PATH) - foreach(LPATH ${MPI_ALL_LINK_PATHS}) - string(REGEX REPLACE "^(| |-Wl,)(-L|/LIBPATH:)" "" LPATH ${LPATH}) - string(REPLACE "//" "/" LPATH ${LPATH}) - list(APPEND MPI_LINK_PATH ${LPATH}) - endforeach() + # MPI might require pthread to work. The above mechanism wouldn't detect it, but we need to + # link it in that case. -lpthread is covered by the normal library treatment on the other hand. + if("${MPI_COMPILE_CMDLINE}" MATCHES "-pthread") + list(APPEND MPI_COMPILE_OPTIONS_WORK "-pthread") + if(MPI_LINK_FLAGS_WORK) + string(APPEND MPI_LINK_FLAGS_WORK " -pthread") + else() + set(MPI_LINK_FLAGS_WORK "-pthread") + endif() + endif() - # try using showme:libdirs if extracting didn't work. - if (NOT MPI_LINK_PATH) - set(MPI_LINK_PATH ${MPI_LIBDIRS}) - separate_arguments(MPI_LINK_PATH) - endif() + # If we found MPI, set up all of the appropriate cache entries + if(NOT MPI_${LANG}_COMPILE_OPTIONS) + set(MPI_${LANG}_COMPILE_OPTIONS ${MPI_COMPILE_OPTIONS_WORK} CACHE STRING "MPI ${LANG} compilation options" FORCE) + endif() + if(NOT MPI_${LANG}_COMPILE_DEFINITIONS) + set(MPI_${LANG}_COMPILE_DEFINITIONS ${MPI_COMPILE_DEFINITIONS_WORK} CACHE STRING "MPI ${LANG} compilation definitions" FORCE) + endif() + if(NOT MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) + set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_INCLUDE_DIRS_WORK} CACHE STRING "MPI ${LANG} additional include directories" FORCE) + endif() + if(NOT MPI_${LANG}_LINK_FLAGS) + set(MPI_${LANG}_LINK_FLAGS ${MPI_LINK_FLAGS_WORK} CACHE STRING "MPI ${LANG} linker flags" FORCE) + endif() + if(NOT MPI_${LANG}_LIB_NAMES) + set(MPI_${LANG}_LIB_NAMES ${MPI_PLAIN_LIB_NAMES_WORK} CACHE STRING "MPI ${LANG} libraries to link against" FORCE) + endif() + set(MPI_${LANG}_WRAPPER_FOUND TRUE PARENT_SCOPE) +endfunction() - # Extract linker flags from the link command line - string(REGEX MATCHALL "(^| )(-Wl,|-Xlinker )([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_FLAGS "${MPI_LINK_CMDLINE}") - set(MPI_LINK_FLAGS_WORK) - foreach(FLAG ${MPI_ALL_LINK_FLAGS}) - string(REGEX REPLACE "^ " "" FLAG ${FLAG}) - if (MPI_LINK_FLAGS_WORK) - set(MPI_LINK_FLAGS_WORK "${MPI_LINK_FLAGS_WORK} ${FLAG}") - else() - set(MPI_LINK_FLAGS_WORK ${FLAG}) - endif() - endforeach() +function(_MPI_guess_settings LANG) + set(MPI_GUESS_FOUND FALSE) + # Currently only MSMPI and MPICH2 on Windows are supported, so we can skip this search if we're not targeting that. + if(WIN32) + # MSMPI + + # The environment variables MSMPI_INC and MSMPILIB32/64 are the only ways of locating the MSMPI_SDK, + # which is installed separately from the runtime. Thus it's possible to have mpiexec but not MPI headers + # or import libraries and vice versa. + if(NOT MPI_GUESS_LIBRARY_NAME OR "${MPI_GUESS_LIBRARY_NAME}" STREQUAL "MSMPI") + # We first attempt to locate the msmpi.lib. Should be find it, we'll assume that the MPI present is indeed + # Microsoft MPI. + if("${CMAKE_SIZEOF_VOID_P}" EQUAL 8) + set(MPI_MSMPI_LIB_PATH "$ENV{MSMPI_LIB64}") + set(MPI_MSMPI_INC_PATH_EXTRA "$ENV{MSMPI_INC}/x64") + else() + set(MPI_MSMPI_LIB_PATH "$ENV{MSMPI_LIB32}") + set(MPI_MSMPI_INC_PATH_EXTRA "$ENV{MSMPI_INC}/x86") + endif() - # Extract the set of libraries to link against from the link command - # line - string(REGEX MATCHALL "(^| )-l([^\" ]+|\"[^\"]+\")" MPI_LIBNAMES "${MPI_LINK_CMDLINE}") - if(WIN32) - # The intel wrappers on windows link against static versions of the MPI libraries. - # The static libraries are simply listed on the command line without -l. - # For instance: " icl ... impi.lib " - string(REGEX MATCHALL "(^| )([^\" ]+)\\.lib" tmp "${MPI_LINK_CMDLINE}") - list(APPEND MPI_LIBNAMES ${tmp}) + find_library(MPI_msmpi_LIBRARY + NAMES msmpi + HINTS ${MPI_MSMPI_LIB_PATH} + DOC "Location of the msmpi library for Microsoft MPI") + mark_as_advanced(MPI_msmpi_LIBRARY) + + if(MPI_msmpi_LIBRARY) + # Next, we attempt to locate the MPI header. Note that for Fortran we know that mpif.h is a way + # MSMPI can be used and therefore that header has to be present. + if(NOT MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) + get_filename_component(MPI_MSMPI_INC_DIR "$ENV{MSMPI_INC}" REALPATH) + set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "${MPI_MSMPI_INC_DIR}" CACHE STRING "MPI ${LANG} additional include directories" FORCE) + unset(MPI_MSMPI_INC_DIR) endif() - # add the compiler implicit directories because some compilers - # such as the intel compiler have libraries that show up - # in the showme list that can only be found in the implicit - # link directories of the compiler. - if (DEFINED CMAKE_${lang}_IMPLICIT_LINK_DIRECTORIES) - set(MPI_LINK_PATH "${MPI_LINK_PATH};${CMAKE_${lang}_IMPLICIT_LINK_DIRECTORIES}") - endif () - - # Determine full path names for all of the libraries that one needs - # to link against in an MPI program - foreach(LIB ${MPI_LIBNAMES}) - string(REGEX REPLACE "^ ?-l" "" LIB ${LIB}) - if(WIN32) - string(REGEX REPLACE "\\.lib$" "" LIB ${LIB}) + # For MSMPI, one can compile the MPI module by building the mpi.f90 shipped with the MSMPI SDK, + # thus it might be present or provided by the user. Figuring out which is supported is done later on. + # The PGI Fortran compiler for instance ships a prebuilt set of modules in its own include folder. + # Should a user be employing PGI or have built its own set and provided it via cache variables, the + # splitting routine would have located the module files. + + # For C and C++, we're done here (MSMPI does not ship the MPI-2 C++ bindings) - however, for Fortran + # we need some extra library to glue Fortran support together: + # MSMPI ships 2-4 Fortran libraries, each for different Fortran compiler behaviors. The library names + # ending with a c are using the cdecl calling convention, whereas those ending with an s are for Fortran + # implementations using stdcall. Therefore, the 64-bit MSMPI only ships those ending in 'c', whereas the 32-bit + # has both variants available. + # The second difference is the last but one letter, if it's an e(nd), the length of a string argument is + # passed by the Fortran compiler after all other arguments on the parameter list, if it's an m(ixed), + # it's passed immediately after the string address. + + # To summarize: + # - msmpifec: CHARACTER length passed after the parameter list and using cdecl calling convention + # - msmpifmc: CHARACTER length passed directly after string address and using cdecl calling convention + # - msmpifes: CHARACTER length passed after the parameter list and using stdcall calling convention + # - msmpifms: CHARACTER length passed directly after string address and using stdcall calling convention + # 32-bit MSMPI ships all four libraries, 64-bit MSMPI ships only the first two. + + # As is, Intel Fortran and PGI Fortran both use the 'ec' variant of the calling convention, whereas + # the old Compaq Visual Fortran compiler defaulted to the 'ms' version. It's possible to make Intel Fortran + # use the CVF calling convention using /iface:cvf, but we assume - and this is also assumed in FortranCInterface - + # this isn't the case. It's also possible to make CVF use the 'ec' variant, using /iface=(cref,nomixed_str_len_arg). + + # Our strategy is now to locate all libraries, but enter msmpifec into the LIB_NAMES array. + # Should this not be adequate it's a straightforward way for a user to change the LIB_NAMES array and + # have his library found. Still, this should not be necessary outside of exceptional cases, as reasoned. + if ("${LANG}" STREQUAL "Fortran") + set(MPI_MSMPI_CALLINGCONVS c) + if("${CMAKE_SIZEOF_VOID_P}" EQUAL 4) + list(APPEND MPI_MSMPI_CALLINGCONVS s) endif() - string(STRIP ${LIB} LIB) - # MPI_LIB is cached by find_library, but we don't want that. Clear it first. - set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE FILEPATH "Cleared" FORCE) - find_library(MPI_LIB NAMES ${LIB} HINTS ${MPI_LINK_PATH}) - - if (MPI_LIB) - list(APPEND MPI_LIBRARIES_WORK ${MPI_LIB}) - elseif (NOT MPI_FIND_QUIETLY) - message(WARNING "Unable to find MPI library ${LIB}") + foreach(mpistrlenpos IN ITEMS e m) + foreach(mpicallingconv IN LISTS MPI_MSMPI_CALLINGCONVS) + find_library(MPI_msmpif${mpistrlenpos}${mpicallingconv}_LIBRARY + NAMES msmpif${mpistrlenpos}${mpicallingconv} + HINTS "${MPI_MSMPI_LIB_PATH}" + DOC "Location of the msmpi${mpistrlenpos}${mpicallingconv} library for Microsoft MPI") + mark_as_advanced(MPI_msmpif${mpistrlenpos}${mpicallingconv}_LIBRARY) + endforeach() + endforeach() + if(NOT MPI_${LANG}_LIB_NAMES) + set(MPI_${LANG}_LIB_NAMES "msmpi;msmpifec" CACHE STRING "MPI ${LANG} libraries to link against" FORCE) endif() - endforeach() - # Sanity check MPI_LIBRARIES to make sure there are enough libraries - list(LENGTH MPI_LIBRARIES_WORK MPI_NUMLIBS) - list(LENGTH MPI_LIBNAMES MPI_NUMLIBS_EXPECTED) - if (NOT MPI_NUMLIBS EQUAL MPI_NUMLIBS_EXPECTED) - set(MPI_LIBRARIES_WORK "MPI_${lang}_LIBRARIES-NOTFOUND") + # At this point we're *not* done. MSMPI requires an additional include file for Fortran giving the value + # of MPI_AINT. This file is called mpifptr.h located in the x64 and x86 subfolders, respectively. + find_path(MPI_mpifptr_INCLUDE_DIR + NAMES "mpifptr.h" + HINTS "${MPI_MSMPI_INC_PATH_EXTRA}" + DOC "Location of the mpifptr.h extra header for Microsoft MPI") + if(NOT MPI_${LANG}_ADDITIONAL_INCLUDE_VARS) + set(MPI_${LANG}_ADDITIONAL_INCLUDE_VARS "mpifptr" CACHE STRING "MPI ${LANG} additional include directory variables, given in the form MPI__INCLUDE_DIR." FORCE) + endif() + mark_as_advanced(MPI_${LANG}_ADDITIONAL_INCLUDE_VARS MPI_mpifptr_INCLUDE_DIR) + else() + if(NOT MPI_${LANG}_LIB_NAMES) + set(MPI_${LANG}_LIB_NAMES "msmpi" CACHE STRING "MPI ${LANG} libraries to link against" FORCE) + endif() endif() + mark_as_advanced(MPI_${LANG}_LIB_NAMES) + set(MPI_GUESS_FOUND TRUE) endif() + endif() - elseif(try_libs) - # If we didn't have an MPI compiler script to interrogate, attempt to find everything - # with plain old find functions. This is nasty because MPI implementations have LOTS of - # different library names, so this section isn't going to be very generic. We need to - # make sure it works for MS MPI, though, since there are no compiler wrappers for that. - find_path(MPI_HEADER_PATH mpi.h - HINTS ${_MPI_BASE_DIR} ${_MPI_PREFIX_PATH} - PATH_SUFFIXES include Inc) - set(MPI_INCLUDE_PATH_WORK ${MPI_HEADER_PATH}) - - # Decide between 32-bit and 64-bit libraries for Microsoft's MPI - if("${CMAKE_SIZEOF_VOID_P}" EQUAL 8) - set(MS_MPI_ARCH_DIR x64) - set(MS_MPI_ARCH_DIR2 amd64) - else() - set(MS_MPI_ARCH_DIR x86) - set(MS_MPI_ARCH_DIR2 i386) - endif() + # At this point there's not many MPIs that we could still consider. + # OpenMPI 1.6.x and below supported Windows, but these ship compiler wrappers that still work. + # The only other relevant MPI implementation without a wrapper is MPICH2, which had Windows support in 1.4.1p1 and older. + if(NOT MPI_GUESS_LIBRARY_NAME OR "${MPI_GUESS_LIBRARY_NAME}" STREQUAL "MPICH2") + set(MPI_MPICH_PREFIX_PATHS + "$ENV{ProgramW6432}/MPICH2/lib" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MPICH\\SMPD;binary]/../lib" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MPICH2;Path]/lib" + ) - set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE FILEPATH "Cleared" FORCE) - find_library(MPI_LIB - NAMES mpi mpich mpich2 msmpi - HINTS ${_MPI_BASE_DIR} ${_MPI_PREFIX_PATH} - PATH_SUFFIXES lib lib/${MS_MPI_ARCH_DIR} Lib Lib/${MS_MPI_ARCH_DIR} lib/${MS_MPI_ARCH_DIR2} Lib/${MS_MPI_ARCH_DIR2}) - set(MPI_LIBRARIES_WORK ${MPI_LIB}) - - # Right now, we only know about the extra libs for C++. - # We could add Fortran here (as there is usually libfmpich, etc.), but - # this really only has to work with MS MPI on Windows. - # Assume that other MPI's are covered by the compiler wrappers. - if (${lang} STREQUAL CXX) - set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE FILEPATH "Cleared" FORCE) - find_library(MPI_LIB - NAMES mpi++ mpicxx cxx mpi_cxx - HINTS ${_MPI_BASE_DIR} ${_MPI_PREFIX_PATH} - PATH_SUFFIXES lib) - if (MPI_LIBRARIES_WORK AND MPI_LIB) - list(APPEND MPI_LIBRARIES_WORK ${MPI_LIB}) + # All of C, C++ and Fortran will need mpi.lib, so we'll look for this first + find_library(MPI_mpi_LIBRARY + NAMES mpi + HINTS ${MPI_MPICH_PREFIX_PATHS}) + mark_as_advanced(MPI_mpi_LIBRARY) + # If we found mpi.lib, we detect the rest of MPICH2 + if(MPI_mpi_LIBRARY) + set(MPI_MPICH_LIB_NAMES "mpi") + # If MPI-2 C++ bindings are requested, we need to locate cxx.lib as well. + # Otherwise, MPICH_SKIP_MPICXX will be defined and these bindings aren't needed. + if("${LANG}" STREQUAL "CXX" AND NOT MPI_CXX_SKIP_MPICXX) + find_library(MPI_cxx_LIBRARY + NAMES cxx + HINTS ${MPI_MPICH_PREFIX_PATHS}) + mark_as_advanced(MPI_cxx_LIBRARY) + list(APPEND MPI_MPICH_LIB_NAMES "cxx") + # For Fortran, MPICH2 provides three different libraries: + # fmpich2.lib which uses uppercase symbols and cdecl, + # fmpich2s.lib which uses uppercase symbols and stdcall (32-bit only), + # fmpich2g.lib which uses lowercase symbols with double underscores and cdecl. + # fmpich2s.lib would be useful for Compaq Visual Fortran, fmpich2g.lib has to be used with GNU g77 and is also + # provided in the form of an .a archive for MinGW and Cygwin. From our perspective, fmpich2.lib is the only one + # we need to try, and if it doesn't work with the given Fortran compiler we'd find out later on during validation + elseif("${LANG}" STREQUAL "Fortran") + find_library(MPI_fmpich2_LIBRARY + NAMES fmpich2 + HINTS ${MPI_MPICH_PREFIX_PATHS}) + find_library(MPI_fmpich2s_LIBRARY + NAMES fmpich2s + HINTS ${MPI_MPICH_PREFIX_PATHS}) + find_library(MPI_fmpich2g_LIBRARY + NAMES fmpich2g + HINTS ${MPI_MPICH_PREFIX_PATHS}) + mark_as_advanced(MPI_fmpich2_LIBRARY MPI_fmpich2s_LIBRARY MPI_fmpich2g_LIBRARY) + list(APPEND MPI_MPICH_LIB_NAMES "fmpich2") endif() - endif() - if (${lang} STREQUAL Fortran) - set(MPI_HEADER_PATH "MPI_HEADER_PATH-NOTFOUND" CACHE FILEPATH "Cleared" FORCE) - find_path(MPI_HEADER_PATH mpifptr.h - HINTS ${_MPI_BASE_DIR} ${_MPI_PREFIX_PATH} - PATH_SUFFIXES include Include include/${MS_MPI_ARCH_DIR} Include/${MS_MPI_ARCH_DIR2} Include/${MS_MPI_ARCH_DIR} include/${MS_MPI_ARCH_DIR2} Inc Inc/${MS_MPI_ARCH_DIR} Inc/${MS_MPI_ARCH_DIR2}) - if (MPI_INCLUDE_PATH_WORK AND MPI_HEADER_PATH) - list(APPEND MPI_INCLUDE_PATH_WORK ${MPI_HEADER_PATH}) - endif () - - set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE FILEPATH "Cleared" FORCE) - find_library(MPI_LIB - NAMES fmpi fmpich fmpich2 fmpich2g msmpifec msmpifmc - HINTS ${_MPI_BASE_DIR} ${_MPI_PREFIX_PATH} - PATH_SUFFIXES lib lib/${MS_MPI_ARCH_DIR} Lib Lib/${MS_MPI_ARCH_DIR}) - if (MPI_LIBRARIES_WORK AND MPI_LIB) - list(APPEND MPI_LIBRARIES_WORK ${MPI_LIB}) - endif () - endif () - - if (NOT MPI_LIBRARIES_WORK) - set(MPI_LIBRARIES_WORK "MPI_${lang}_LIBRARIES-NOTFOUND") + if(NOT MPI_${LANG}_LIB_NAMES) + set(MPI_${LANG}_LIB_NAMES "${MPI_MPICH_LIB_NAMES}" CACHE STRING "MPI ${LANG} libraries to link against" FORCE) + endif() + unset(MPI_MPICH_LIB_NAMES) + + if(NOT MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) + # For MPICH2, the include folder would be in ../include relative to the library folder. + get_filename_component(MPI_MPICH_ROOT_DIR "${MPI_mpi_LIBRARY}" DIRECTORY) + get_filename_component(MPI_MPICH_ROOT_DIR "${MPI_MPICH_ROOT_DIR}" DIRECTORY) + if(IS_DIRECTORY "${MPI_MPICH_ROOT_DIR}/include") + set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "${MPI_MPICH_ROOT_DIR}/include" CACHE STRING "MPI ${LANG} additional include directory variables, given in the form MPI__INCLUDE_DIR." FORCE) + endif() + unset(MPI_MPICH_ROOT_DIR) + endif() + set(MPI_GUESS_FOUND TRUE) endif() + unset(MPI_MPICH_PREFIX_PATHS) endif() + endif() + set(MPI_${LANG}_GUESS_FOUND "${MPI_GUESS_FOUND}" PARENT_SCOPE) +endfunction() - # If we found MPI, set up all of the appropriate cache entries - set(MPI_${lang}_COMPILE_FLAGS ${MPI_COMPILE_FLAGS_WORK} CACHE STRING "MPI ${lang} compilation flags" FORCE) - set(MPI_${lang}_INCLUDE_PATH ${MPI_INCLUDE_PATH_WORK} CACHE STRING "MPI ${lang} include path" FORCE) - set(MPI_${lang}_LINK_FLAGS ${MPI_LINK_FLAGS_WORK} CACHE STRING "MPI ${lang} linking flags" FORCE) - set(MPI_${lang}_LIBRARIES ${MPI_LIBRARIES_WORK} CACHE STRING "MPI ${lang} libraries to link against" FORCE) - mark_as_advanced(MPI_${lang}_COMPILE_FLAGS MPI_${lang}_INCLUDE_PATH MPI_${lang}_LINK_FLAGS MPI_${lang}_LIBRARIES) +function(_MPI_adjust_compile_definitions LANG) + if("${LANG}" STREQUAL "CXX") + # To disable the C++ bindings, we need to pass some definitions since the mpi.h header has to deal with both C and C++ + # bindings in MPI-2. + if(MPI_CXX_SKIP_MPICXX AND NOT MPI_${LANG}_COMPILE_DEFINITIONS MATCHES "SKIP_MPICXX") + # MPICH_SKIP_MPICXX is being used in MPICH and derivatives like MVAPICH or Intel MPI + # OMPI_SKIP_MPICXX is being used in Open MPI + # _MPICC_H is being used for IBM Platform MPI + list(APPEND MPI_${LANG}_COMPILE_DEFINITIONS "MPICH_SKIP_MPICXX" "OMPI_SKIP_MPICXX" "_MPICC_H") + set(MPI_${LANG}_COMPILE_DEFINITIONS "${MPI_${LANG}_COMPILE_DEFINITIONS}" CACHE STRING "MPI ${LANG} compilation definitions" FORCE) + endif() + endif() +endfunction() + +macro(_MPI_assemble_libraries LANG) + set(MPI_${LANG}_LIBRARIES "") + foreach(mpilib IN LISTS MPI_${LANG}_LIB_NAMES) + list(APPEND MPI_${LANG}_LIBRARIES ${MPI_${mpilib}_LIBRARY}) + endforeach() +endmacro() - # clear out our temporary lib/header detection variable here. - set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE INTERNAL "Scratch variable for MPI lib detection" FORCE) - set(MPI_HEADER_PATH "MPI_HEADER_PATH-NOTFOUND" CACHE INTERNAL "Scratch variable for MPI header detection" FORCE) +macro(_MPI_assemble_include_dirs LANG) + set(MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS}") + if("${LANG}" MATCHES "(C|CXX)") + if(MPI_${LANG}_HEADER_DIR) + list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_HEADER_DIR}") + endif() + else() # Fortran + if(MPI_${LANG}_F77_HEADER_DIR) + list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_F77_HEADER_DIR}") + endif() + if(MPI_${LANG}_MODULE_DIR AND NOT "${MPI_${LANG}_MODULE_DIR}" IN_LIST MPI_${LANG}_INCLUDE_DIRS) + list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_MODULE_DIR}") + endif() endif() + if(MPI_${LANG}_ADDITIONAL_INCLUDE_VARS) + foreach(mpiadditionalinclude IN LISTS MPI_${LANG}_ADDITIONAL_INCLUDE_VARS) + list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${mpiadditionalinclude}_INCLUDE_DIR}") + endforeach() + endif() +endmacro() - # finally set a found variable for each MPI language - if (MPI_${lang}_INCLUDE_PATH AND MPI_${lang}_LIBRARIES) - set(MPI_${lang}_FOUND TRUE PARENT_SCOPE) - else() - set(MPI_${lang}_FOUND FALSE PARENT_SCOPE) +function(_MPI_split_include_dirs LANG) + # Backwards compatibility: Search INCLUDE_PATH if given. + if(MPI_${LANG}_INCLUDE_PATH) + list(APPEND MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "${MPI_${LANG}_INCLUDE_PATH}") endif() + + # We try to find the headers/modules among those paths (and system paths) + # For C/C++, we just need to have a look for mpi.h. + if("${LANG}" MATCHES "(C|CXX)") + find_path(MPI_${LANG}_HEADER_DIR "mpi.h" + HINTS ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS} + ) + mark_as_advanced(MPI_${LANG}_HEADER_DIR) + if(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) + list(REMOVE_ITEM MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "${MPI_${LANG}_HEADER_DIR}") + endif() + # Fortran is more complicated here: An implementation could provide + # any of the Fortran 77/90/2008 APIs for MPI. For example, MSMPI + # only provides Fortran 77 and - if mpi.f90 is built - potentially + # a Fortran 90 module. + elseif("${LANG}" STREQUAL "Fortran") + find_path(MPI_${LANG}_F77_HEADER_DIR "mpif.h" + HINTS ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS} + ) + find_path(MPI_${LANG}_MODULE_DIR + NAMES "mpi.mod" "mpi_f08.mod" + HINTS ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS} + ) + if(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) + list(REMOVE_ITEM MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS + "${MPI_${LANG}_F77_HEADER_DIR}" + "${MPI_${LANG}_MODULE_DIR}" + ) + endif() + mark_as_advanced(MPI_${LANG}_F77_HEADER_DIR MPI_${LANG}_MODULE_DIR) + endif() + set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS} CACHE STRING "MPI ${LANG} additional include directories" FORCE) endfunction() +macro(_MPI_create_imported_target LANG) + if(NOT TARGET MPI::MPI_${LANG}) + add_library(MPI::MPI_${LANG} INTERFACE IMPORTED) + endif() + + set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_COMPILE_OPTIONS "${MPI_${LANG}_COMPILE_OPTIONS}") + set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_COMPILE_DEFINITIONS "${MPI_${LANG}_COMPILE_DEFINITIONS}") -# This function attempts to compile with the regular compiler, to see if MPI programs -# work with it. This is a last ditch attempt after we've tried interrogating mpicc and -# friends, and after we've tried to find generic libraries. Works on machines like -# Cray XE6, where the modules environment changes what MPI version cc, CC, and ftn use. -function(try_regular_compiler lang success) - set(scratch_directory ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}) - if (${lang} STREQUAL Fortran) - set(test_file ${scratch_directory}/cmake_mpi_test.f90) - file(WRITE ${test_file} - "program hello\n" - "include 'mpif.h'\n" - "integer ierror\n" - "call MPI_INIT(ierror)\n" - "call MPI_FINALIZE(ierror)\n" - "end\n") + set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_LINK_LIBRARIES "") + if(MPI_${LANG}_LINK_FLAGS) + set_property(TARGET MPI::MPI_${LANG} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${MPI_${LANG}_LINK_FLAGS}") + endif() + # If the compiler links MPI implicitly, no libraries will be found as they're contained within + # CMAKE__IMPLICIT_LINK_LIBRARIES already. + if(MPI_${LANG}_LIBRARIES) + set_property(TARGET MPI::MPI_${LANG} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${MPI_${LANG}_LIBRARIES}") + endif() + # Given the new design of FindMPI, INCLUDE_DIRS will always be located, even under implicit linking. + set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${MPI_${LANG}_INCLUDE_DIRS}") +endmacro() + +function(_MPI_try_staged_settings LANG MPI_TEST_FILE_NAME MODE RUN_BINARY) + set(WORK_DIR "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindMPI") + set(SRC_DIR "${CMAKE_ROOT}/Modules/FindMPI") + set(BIN_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindMPI/${MPI_TEST_FILE_NAME}_${LANG}.bin") + unset(MPI_TEST_COMPILE_DEFINITIONS) + if("${LANG}" STREQUAL "Fortran") + if("${MODE}" STREQUAL "F90_MODULE") + set(MPI_Fortran_INCLUDE_LINE "use mpi\n implicit none") + elseif("${MODE}" STREQUAL "F08_MODULE") + set(MPI_Fortran_INCLUDE_LINE "use mpi_f08\n implicit none") + else() # F77 header + set(MPI_Fortran_INCLUDE_LINE "implicit none\n include 'mpif.h'") + endif() + configure_file("${SRC_DIR}/${MPI_TEST_FILE_NAME}.f90.in" "${WORK_DIR}/${MPI_TEST_FILE_NAME}.f90" @ONLY) + set(MPI_TEST_SOURCE_FILE "${WORK_DIR}/${MPI_TEST_FILE_NAME}.f90") + elseif("${LANG}" STREQUAL "CXX") + configure_file("${SRC_DIR}/${MPI_TEST_FILE_NAME}.c" "${WORK_DIR}/${MPI_TEST_FILE_NAME}.cpp" COPYONLY) + set(MPI_TEST_SOURCE_FILE "${WORK_DIR}/${MPI_TEST_FILE_NAME}.cpp") + if("${MODE}" STREQUAL "TEST_MPICXX") + set(MPI_TEST_COMPILE_DEFINITIONS TEST_MPI_MPICXX) + endif() + else() # C + set(MPI_TEST_SOURCE_FILE "${SRC_DIR}/${MPI_TEST_FILE_NAME}.c") + endif() + if(RUN_BINARY) + try_run(MPI_RUN_RESULT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} MPI_RESULT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} + "${CMAKE_BINARY_DIR}" SOURCES "${MPI_TEST_SOURCE_FILE}" + COMPILE_DEFINITIONS ${MPI_TEST_COMPILE_DEFINITIONS} + LINK_LIBRARIES MPI::MPI_${LANG} + RUN_OUTPUT_VARIABLE MPI_RUN_OUTPUT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE}) + set(MPI_RUN_OUTPUT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} "${MPI_RUN_OUTPUT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE}}" PARENT_SCOPE) else() - if (${lang} STREQUAL CXX) - set(test_file ${scratch_directory}/cmake_mpi_test.cpp) - else() - set(test_file ${scratch_directory}/cmake_mpi_test.c) - endif() - file(WRITE ${test_file} - "#include \n" - "int main(int argc, char **argv) {\n" - " MPI_Init(&argc, &argv);\n" - " MPI_Finalize();\n" - "}\n") - endif() - try_compile(compiler_has_mpi ${scratch_directory} ${test_file}) - if (compiler_has_mpi) - set(MPI_${lang}_NO_INTERROGATE ${CMAKE_${lang}_COMPILER} CACHE STRING "Whether to interrogate MPI ${lang} compiler" FORCE) - set(MPI_${lang}_COMPILER ${CMAKE_${lang}_COMPILER} CACHE STRING "MPI ${lang} compiler" FORCE) - set(MPI_${lang}_COMPILE_FLAGS "" CACHE STRING "MPI ${lang} compilation flags" FORCE) - set(MPI_${lang}_INCLUDE_PATH "" CACHE STRING "MPI ${lang} include path" FORCE) - set(MPI_${lang}_LINK_FLAGS "" CACHE STRING "MPI ${lang} linking flags" FORCE) - set(MPI_${lang}_LIBRARIES "" CACHE STRING "MPI ${lang} libraries to link against" FORCE) - endif() - set(${success} ${compiler_has_mpi} PARENT_SCOPE) - unset(compiler_has_mpi CACHE) + try_compile(MPI_RESULT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} + "${CMAKE_BINARY_DIR}" SOURCES "${MPI_TEST_SOURCE_FILE}" + COMPILE_DEFINITIONS ${MPI_TEST_COMPILE_DEFINITIONS} + LINK_LIBRARIES MPI::MPI_${LANG} + COPY_FILE "${BIN_FILE}") + endif() endfunction() -# End definitions, commence real work here. +macro(_MPI_check_lang_works LANG) + # For Fortran we may have by the MPI-3 standard an implementation that provides: + # - the mpi_f08 module + # - *both*, the mpi module and 'mpif.h' + # Since older MPI standards (MPI-1) did not define anything but 'mpif.h', we need to check all three individually. + if( NOT MPI_${LANG}_WORKS ) + if("${LANG}" STREQUAL "Fortran") + set(MPI_Fortran_INTEGER_LINE "(kind=MPI_INTEGER_KIND)") + _MPI_try_staged_settings(${LANG} test_mpi F77_HEADER FALSE) + _MPI_try_staged_settings(${LANG} test_mpi F90_MODULE FALSE) + _MPI_try_staged_settings(${LANG} test_mpi F08_MODULE FALSE) + + set(MPI_${LANG}_WORKS FALSE) + + foreach(mpimethod IN ITEMS F77_HEADER F08_MODULE F90_MODULE) + if(MPI_RESULT_${LANG}_test_mpi_${mpimethod}) + set(MPI_${LANG}_WORKS TRUE) + set(MPI_${LANG}_HAVE_${mpimethod} TRUE) + else() + set(MPI_${LANG}_HAVE_${mpimethod} FALSE) + endif() + endforeach() + # MPI-1 versions had no MPI_INTGER_KIND defined, so we need to try without it. + # However, MPI-1 also did not define the Fortran 90 and 08 modules, so we only try the F77 header. + unset(MPI_Fortran_INTEGER_LINE) + if(NOT MPI_${LANG}_WORKS) + _MPI_try_staged_settings(${LANG} test_mpi F77_HEADER_NOKIND FALSE) + if(MPI_RESULT_${LANG}_test_mpi_F77_HEADER_NOKIND) + set(MPI_${LANG}_WORKS TRUE) + set(MPI_${LANG}_HAVE_F77_HEADER TRUE) + endif() + endif() + else() + _MPI_try_staged_settings(${LANG} test_mpi normal FALSE) + # If 'test_mpi' built correctly, we've found valid MPI settings. There might not be MPI-2 C++ support, but there can't + # be MPI-2 C++ support without the C bindings being present, so checking for them is sufficient. + set(MPI_${LANG}_WORKS "${MPI_RESULT_${LANG}_test_mpi_normal}") + endif() + endif() +endmacro() + +# Some systems install various MPI implementations in separate folders in some MPI prefix +# This macro enumerates all such subfolders and adds them to the list of hints that will be searched. +macro(MPI_search_mpi_prefix_folder PREFIX_FOLDER) + if(EXISTS "${PREFIX_FOLDER}") + file(GLOB _MPI_folder_children RELATIVE "${PREFIX_FOLDER}" "${PREFIX_FOLDER}/*") + foreach(_MPI_folder_child IN LISTS _MPI_folder_children) + if(IS_DIRECTORY "${PREFIX_FOLDER}/${_MPI_folder_child}") + list(APPEND MPI_HINT_DIRS "${PREFIX_FOLDER}/${_MPI_folder_child}") + endif() + endforeach() + endif() +endmacro() + +set(MPI_HINT_DIRS ${MPI_HOME} $ENV{MPI_HOME} $ENV{I_MPI_ROOT}) +if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Linux") + # SUSE Linux Enterprise Server stores its MPI implementations under /usr/lib64/mpi/gcc/ + # We enumerate the subfolders and append each as a prefix + MPI_search_mpi_prefix_folder("/usr/lib64/mpi/gcc") +elseif("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows") + # MSMPI stores its runtime in a special folder, this adds the possible locations to the hints. + list(APPEND MPI_HINT_DIRS $ENV{MSMPI_BIN} "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MPI;InstallRoot]") +elseif("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "FreeBSD") + # FreeBSD ships mpich under the normal system paths - but available openmpi implementations + # will be found in /usr/local/mpi/ + MPI_search_mpi_prefix_folder("/usr/local/mpi/") +endif() -# Most mpi distros have some form of mpiexec which gives us something we can reliably look for. -find_program(MPIEXEC - NAMES ${_MPI_EXEC_NAMES} - HINTS ${MPI_HOME} $ENV{MPI_HOME} - PATHS ${_MPI_PREFIX_PATH} - PATH_SUFFIXES bin +# Most MPI distributions have some form of mpiexec or mpirun which gives us something we can look for. +# The MPI standard does not mandate the existence of either, but instead only makes requirements if a distribution +# ships an mpiexec program (mpirun executables are not regulated by the standard). +find_program(MPIEXEC_EXECUTABLE + NAMES ${_MPIEXEC_NAMES} + PATH_SUFFIXES bin sbin + HINTS ${MPI_HINT_DIRS} DOC "Executable for running MPI programs.") # call get_filename_component twice to remove mpiexec and the directory it exists in (typically bin). # This gives us a fairly reliable base directory to search for /bin /lib and /include from. -get_filename_component(_MPI_BASE_DIR "${MPIEXEC}" PATH) +get_filename_component(_MPI_BASE_DIR "${MPIEXEC_EXECUTABLE}" PATH) get_filename_component(_MPI_BASE_DIR "${_MPI_BASE_DIR}" PATH) # According to the MPI standard, section 8.8 -n is a guaranteed, and the only guaranteed way to # launch an MPI process using mpiexec if such a program exists. -set(MPIEXEC_NUMPROC_FLAG "-n" CACHE STRING "Flag used by MPI to specify the number of processes for MPIEXEC; the next option will be the number of processes.") -set(MPIEXEC_PREFLAGS "" CACHE STRING "These flags will be directly before the executable that is being run by MPIEXEC.") -set(MPIEXEC_POSTFLAGS "" CACHE STRING "These flags will come after all flags given to MPIEXEC.") - -# Set the number of processes to the processor count and the previous default -# of 2 if that couldn't be determined. -include(${CMAKE_ROOT}/Modules/ProcessorCount.cmake) -ProcessorCount(_MPIEXEC_NUMPROCS) -if("${_MPIEXEC_NUMPROCS}" EQUAL "0") - set(_MPIEXEC_NUMPROCS 2) -endif() -set(MPIEXEC_MAX_NUMPROCS "${_MPIEXEC_NUMPROCS}" CACHE STRING "Maximum number of processors available to run MPI applications.") -unset(_MPIEXEC_NUMPROCS) -mark_as_advanced(MPIEXEC MPIEXEC_NUMPROC_FLAG MPIEXEC_PREFLAGS MPIEXEC_POSTFLAGS MPIEXEC_MAX_NUMPROCS) +set(MPIEXEC_NUMPROC_FLAG "-n" CACHE STRING "Flag used by MPI to specify the number of processes for mpiexec; the next option will be the number of processes.") +set(MPIEXEC_PREFLAGS "" CACHE STRING "These flags will be directly before the executable that is being run by mpiexec.") +set(MPIEXEC_POSTFLAGS "" CACHE STRING "These flags will be placed after all flags passed to mpiexec.") +# Set the number of processes to the physical processor count +cmake_host_system_information(RESULT _MPIEXEC_NUMPROCS QUERY NUMBER_OF_PHYSICAL_CORES) +set(MPIEXEC_MAX_NUMPROCS "${_MPIEXEC_NUMPROCS}" CACHE STRING "Maximum number of processors available to run MPI applications.") +unset(_MPIEXEC_NUMPROCS) +mark_as_advanced(MPIEXEC_EXECUTABLE MPIEXEC_NUMPROC_FLAG MPIEXEC_PREFLAGS MPIEXEC_POSTFLAGS MPIEXEC_MAX_NUMPROCS) #============================================================================= # Backward compatibility input hacks. Propagate the FindMPI hints to C and # CXX if the respective new versions are not defined. Translate the old -# MPI_LIBRARY and MPI_EXTRA_LIBRARY to respective MPI_${lang}_LIBRARIES. +# MPI_LIBRARY and MPI_EXTRA_LIBRARY to respective MPI_${LANG}_LIBRARIES. # # Once we find the new variables, we translate them back into their old # equivalents below. -foreach (lang C CXX) +foreach (LANG IN ITEMS C CXX) # Old input variables. set(_MPI_OLD_INPUT_VARS COMPILER COMPILE_FLAGS INCLUDE_PATH LINK_FLAGS) # Set new vars based on their old equivalents, if the new versions are not already set. foreach (var ${_MPI_OLD_INPUT_VARS}) - if (NOT MPI_${lang}_${var} AND MPI_${var}) - set(MPI_${lang}_${var} "${MPI_${var}}") + if (NOT MPI_${LANG}_${var} AND MPI_${var}) + set(MPI_${LANG}_${var} "${MPI_${var}}") endif() endforeach() - # Special handling for MPI_LIBRARY and MPI_EXTRA_LIBRARY, which we nixed in the - # new FindMPI. These need to be merged into MPI__LIBRARIES - if (NOT MPI_${lang}_LIBRARIES AND (MPI_LIBRARY OR MPI_EXTRA_LIBRARY)) - set(MPI_${lang}_LIBRARIES ${MPI_LIBRARY} ${MPI_EXTRA_LIBRARY}) + # Chop the old compile flags into options and definitions + if(MPI_${LANG}_COMPILE_FLAGS) + unset(MPI_${LANG}_COMPILE_OPTIONS) + unset(MPI_${LANG}_COMPILE_DEFINITIONS) + separate_arguments(MPI_SEPARATE_FLAGS NATIVE_COMMAND "${MPI_${LANG}_COMPILE_FLAGS}") + foreach(_MPI_FLAG IN LISTS MPI_SEPARATE_FLAGS) + if("${_MPI_FLAG}" MATCHES "^ *[-/D]([^ ]+)") + list(APPEND MPI_${LANG}_COMPILE_DEFINITIONS "${CMAKE_MATCH_1}") + else() + list(APPEND MPI_${LANG}_COMPILE_FLAGS "${_MPI_FLAG}") + endif() + endforeach() + unset(MPI_SEPARATE_FLAGS) + endif() + + # If a list of libraries was given, we'll split it into new-style cache variables + if(NOT MPI_${LANG}_LIB_NAMES) + foreach(_MPI_LIB IN LISTS MPI_${LANG}_LIBRARIES MPI_LIBRARY MPI_EXTRA_LIBRARY) + get_filename_component(_MPI_PLAIN_LIB_NAME "${_MPI_LIB}" NAME_WE) + get_filename_component(_MPI_LIB_NAME "${_MPI_LIB}" NAME) + get_filename_component(_MPI_LIB_DIR "${_MPI_LIB}" DIRECTORY) + list(APPEND MPI_PLAIN_LIB_NAMES_WORK "${_MPI_PLAIN_LIB_NAME}") + find_library(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY + NAMES "${_MPI_LIB_NAME}" "lib${_MPI_LIB_NAME}" + HINTS ${_MPI_LIB_DIR} $ENV{MPI_LIB} + DOC "Location of the ${_MPI_PLAIN_LIB_NAME} library for MPI" + ) + mark_as_advanced(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY) + endforeach() endif() endforeach() #============================================================================= +unset(MPI_VERSION) +unset(MPI_VERSION_MAJOR) +unset(MPI_VERSION_MINOR) + +unset(_MPI_MIN_VERSION) # This loop finds the compilers and sends them off for interrogation. -foreach (lang C CXX Fortran) - if (CMAKE_${lang}_COMPILER_WORKS) - # If the user supplies a compiler *name* instead of an absolute path, assume that we need to find THAT compiler. - if (MPI_${lang}_COMPILER) - if (NOT IS_ABSOLUTE "${MPI_${lang}_COMPILER}") - # Get rid of our default list of names and just search for the name the user wants. - set(_MPI_${lang}_COMPILER_NAMES ${MPI_${lang}_COMPILER}) - set(MPI_${lang}_COMPILER "MPI_${lang}_COMPILER-NOTFOUND" CACHE FILEPATH "Cleared" FORCE) - endif() - # If the user specifies a compiler, we don't want to try to search libraries either. - set(try_libs FALSE) +foreach(LANG IN ITEMS C CXX Fortran) + if(CMAKE_${LANG}_COMPILER_LOADED) + if(NOT MPI_FIND_COMPONENTS) + set(_MPI_FIND_${LANG} TRUE) + elseif( ${LANG} IN_LIST MPI_FIND_COMPONENTS) + set(_MPI_FIND_${LANG} TRUE) + elseif( ${LANG} STREQUAL CXX AND NOT MPI_CXX_SKIP_MPICXX AND MPICXX IN_LIST MPI_FIND_COMPONENTS ) + set(_MPI_FIND_${LANG} TRUE) else() - set(try_libs TRUE) + set(_MPI_FIND_${LANG} FALSE) endif() + else() + set(_MPI_FIND_${LANG} FALSE) + endif() + if(_MPI_FIND_${LANG}) + if( ${LANG} STREQUAL CXX AND NOT MPICXX IN_LIST MPI_FIND_COMPONENTS ) + set(MPI_CXX_SKIP_MPICXX FALSE CACHE BOOL "If true, the MPI-2 C++ bindings are disabled using definitions.") + mark_as_advanced(MPI_CXX_SKIP_MPICXX) + endif() + if(NOT (MPI_${LANG}_LIB_NAMES AND (MPI_${LANG}_INCLUDE_PATH OR MPI_${LANG}_INCLUDE_DIRS OR MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS))) + if(NOT MPI_${LANG}_COMPILER AND NOT MPI_ASSUME_NO_BUILTIN_MPI) + # Should the imported targets be empty, we effectively try whether the compiler supports MPI on its own, which is the case on e.g. + # Cray PrgEnv. + _MPI_create_imported_target(${LANG}) + _MPI_check_lang_works(${LANG}) + + # If the compiler can build MPI code on its own, it functions as an MPI compiler and we'll set the variable to point to it. + if(MPI_${LANG}_WORKS) + set(MPI_${LANG}_COMPILER "${CMAKE_${LANG}_COMPILER}" CACHE FILEPATH "MPI compiler for ${LANG}" FORCE) + endif() + endif() - find_program(MPI_${lang}_COMPILER - NAMES ${_MPI_${lang}_COMPILER_NAMES} - HINTS ${_MPI_BASE_DIR}/bin - PATHS ${_MPI_PREFIX_PATH} - ) - interrogate_mpi_compiler(${lang} ${try_libs}) - mark_as_advanced(MPI_${lang}_COMPILER) + # If the user specified a library name we assume they prefer that library over a wrapper. If not, they can disable skipping manually. + if(NOT DEFINED MPI_SKIP_COMPILER_WRAPPER AND MPI_GUESS_LIBRARY_NAME) + set(MPI_SKIP_COMPILER_WRAPPER TRUE) + endif() + if(NOT MPI_SKIP_COMPILER_WRAPPER) + if(MPI_${LANG}_COMPILER) + # If the user supplies a compiler *name* instead of an absolute path, assume that we need to find THAT compiler. + if (NOT IS_ABSOLUTE "${MPI_${LANG}_COMPILER}") + # Get rid of our default list of names and just search for the name the user wants. + set(_MPI_${LANG}_COMPILER_NAMES "${MPI_${LANG}_COMPILER}") + unset(MPI_${LANG}_COMPILER CACHE) + endif() + # If the user specifies a compiler, we don't want to try to search libraries either. + set(MPI_PINNED_COMPILER TRUE) + else() + set(MPI_PINNED_COMPILER FALSE) + endif() - # last ditch try -- if nothing works so far, just try running the regular compiler and - # see if we can create an MPI executable. - set(regular_compiler_worked 0) - if (NOT MPI_${lang}_LIBRARIES OR NOT MPI_${lang}_INCLUDE_PATH) - try_regular_compiler(${lang} regular_compiler_worked) - endif() + # If we have an MPI base directory, we'll try all compiler names in that one first. + # This should prevent mixing different MPI environments + if(_MPI_BASE_DIR) + find_program(MPI_${LANG}_COMPILER + NAMES ${_MPI_${LANG}_COMPILER_NAMES} + PATH_SUFFIXES bin sbin + HINTS ${_MPI_BASE_DIR} + NO_DEFAULT_PATH + DOC "MPI compiler for ${LANG}" + ) + endif() + + # If the base directory did not help (for example because the mpiexec isn't in the same directory as the compilers), + # we shall try searching in the default paths. + find_program(MPI_${LANG}_COMPILER + NAMES ${_MPI_${LANG}_COMPILER_NAMES} + PATH_SUFFIXES bin sbin + DOC "MPI compiler for ${LANG}" + ) + + if(MPI_${LANG}_COMPILER STREQUAL CMAKE_${LANG}_COMPILER) + set(MPI_SKIP_GUESSING TRUE) + elseif(MPI_${LANG}_COMPILER) + _MPI_interrogate_compiler(${LANG}) + else() + set(MPI_${LANG}_WRAPPER_FOUND FALSE) + endif() + else() + set(MPI_${LANG}_WRAPPER_FOUND FALSE) + set(MPI_PINNED_COMPILER FALSE) + endif() - # add fortran mpi module path if ENV VAR exists - set (MPI_${lang}_INCLUDE_PATH "${MPI_${lang}_INCLUDE_PATH};$ENV{MPI_FORTRAN_MOD_DIR}") + if(NOT MPI_${LANG}_WRAPPER_FOUND AND NOT MPI_PINNED_COMPILER) + # For C++, we may use the settings for C. Should a given compiler wrapper for C++ not exist, but one for C does, we copy over the + # settings for C. An MPI distribution that is in this situation would be IBM Platform MPI. + if("${LANG}" STREQUAL "CXX" AND MPI_C_WRAPPER_FOUND) + set(MPI_${LANG}_COMPILE_OPTIONS ${MPI_C_COMPILE_OPTIONS} CACHE STRING "MPI ${LANG} compilation options" ) + set(MPI_${LANG}_COMPILE_DEFINITIONS ${MPI_C_COMPILE_DEFINITIONS} CACHE STRING "MPI ${LANG} compilation definitions" ) + set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_C_INCLUDE_DIRS} CACHE STRING "MPI ${LANG} additional include directories") + set(MPI_${LANG}_LINK_FLAGS ${MPI_C_LINK_FLAGS} CACHE STRING "MPI ${LANG} linker flags" ) + set(MPI_${LANG}_LIB_NAMES ${MPI_C_LIB_NAMES} CACHE STRING "MPI ${LANG} libraries to link against" ) + set(MPI_${LANG}_WRAPPER_FOUND TRUE) + elseif(NOT MPI_SKIP_GUESSING) + _MPI_guess_settings(${LANG}) + endif() + endif() + endif() - set(MPI_${lang}_FIND_QUIETLY ${MPI_FIND_QUIETLY}) - set(MPI_${lang}_FIND_REQUIRED ${MPI_FIND_REQUIRED}) - set(MPI_${lang}_FIND_VERSION ${MPI_FIND_VERSION}) - set(MPI_${lang}_FIND_VERSION_EXACT ${MPI_FIND_VERSION_EXACT}) + _MPI_split_include_dirs(${LANG}) + if(NOT MPI_${LANG}_COMPILER STREQUAL CMAKE_${LANG}_COMPILER) + _MPI_assemble_include_dirs(${LANG}) + _MPI_assemble_libraries(${LANG}) + endif() + _MPI_adjust_compile_definitions(${LANG}) + # We always create imported targets even if they're empty + _MPI_create_imported_target(${LANG}) - if (regular_compiler_worked) - find_package_handle_standard_args(MPI_${lang} DEFAULT_MSG MPI_${lang}_COMPILER) - else() - find_package_handle_standard_args(MPI_${lang} DEFAULT_MSG MPI_${lang}_LIBRARIES MPI_${lang}_INCLUDE_PATH) + if(NOT MPI_${LANG}_WORKS) + _MPI_check_lang_works(${LANG}) endif() - if(MPI_${lang}_FOUND) - if(NOT TARGET MPI::MPI_${lang}) - add_library(MPI::MPI_${lang} INTERFACE IMPORTED) + # Next, we'll initialize the MPI variables that have not been previously set. + set(MPI_${LANG}_COMPILE_OPTIONS "" CACHE STRING "MPI ${LANG} compilation flags" ) + set(MPI_${LANG}_COMPILE_DEFINITIONS "" CACHE STRING "MPI ${LANG} compilation definitions" ) + set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "" CACHE STRING "MPI ${LANG} additional include directories") + set(MPI_${LANG}_LINK_FLAGS "" CACHE STRING "MPI ${LANG} linker flags" ) + set(MPI_${LANG}_LIB_NAMES "" CACHE STRING "MPI ${LANG} libraries to link against" ) + mark_as_advanced(MPI_${LANG}_COMPILE_OPTIONS MPI_${LANG}_COMPILE_DEFINITIONS MPI_${LANG}_LINK_FLAGS + MPI_${LANG}_LIB_NAMES MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS MPI_${LANG}_COMPILER) + + # If we've found MPI, then we'll perform additional analysis: Determine the MPI version, MPI library version, supported + # MPI APIs (i.e. MPI-2 C++ bindings). For Fortran we also need to find specific parameters if we're under MPI-3. + if(MPI_${LANG}_WORKS) + if("${LANG}" STREQUAL "CXX" AND NOT DEFINED MPI_MPICXX_FOUND) + if(NOT MPI_CXX_SKIP_MPICXX AND NOT MPI_CXX_VALIDATE_SKIP_MPICXX) + _MPI_try_staged_settings(${LANG} test_mpi MPICXX FALSE) + if(MPI_RESULT_${LANG}_test_mpi_MPICXX) + set(MPI_MPICXX_FOUND TRUE) + else() + set(MPI_MPICXX_FOUND FALSE) + endif() + else() + set(MPI_MPICXX_FOUND FALSE) + endif() + endif() + + # At this point, we know the bindings present but not the MPI version or anything else. + if(NOT DEFINED MPI_${LANG}_VERSION) + unset(MPI_${LANG}_VERSION_MAJOR) + unset(MPI_${LANG}_VERSION_MINOR) + endif() + set(MPI_BIN_FOLDER ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindMPI) + + # For Fortran, we'll want to use the most modern MPI binding to test capabilities other than the + # Fortran parameters, since those depend on the method of consumption. + # For C++, we can always use the C bindings, and should do so, since the C++ bindings do not exist in MPI-3 + # whereas the C bindings do, and the C++ bindings never offered any feature advantage over their C counterparts. + if("${LANG}" STREQUAL "Fortran") + if(MPI_${LANG}_HAVE_F08_MODULE) + set(MPI_${LANG}_HIGHEST_METHOD F08_MODULE) + elseif(MPI_${LANG}_HAVE_F90_MODULE) + set(MPI_${LANG}_HIGHEST_METHOD F90_MODULE) + else() + set(MPI_${LANG}_HIGHEST_METHOD F77_HEADER) + endif() + + # Another difference between C and Fortran is that we can't use the preprocessor to determine whether MPI_VERSION + # and MPI_SUBVERSION are provided. These defines did not exist in MPI 1.0 and 1.1 and therefore might not + # exist. For C/C++, test_mpi.c will handle the MPI_VERSION extraction, but for Fortran, we need mpiver.f90. + if(NOT DEFINED MPI_${LANG}_VERSION) + _MPI_try_staged_settings(${LANG} mpiver ${MPI_${LANG}_HIGHEST_METHOD} FALSE) + if(MPI_RESULT_${LANG}_mpiver_${MPI_${LANG}_HIGHEST_METHOD}) + file(STRINGS ${MPI_BIN_FOLDER}/mpiver_${LANG}.bin _MPI_VERSION_STRING LIMIT_COUNT 1 REGEX "INFO:MPI-VER") + if("${_MPI_VERSION_STRING}" MATCHES ".*INFO:MPI-VER\\[([0-9]+)\\.([0-9]+)\\].*") + set(MPI_${LANG}_VERSION_MAJOR "${CMAKE_MATCH_1}") + set(MPI_${LANG}_VERSION_MINOR "${CMAKE_MATCH_2}") + set(MPI_${LANG}_VERSION "${MPI_${LANG}_VERSION_MAJOR}.${MPI_${LANG}_VERSION_MINOR}") + endif() + endif() + endif() + + # Finally, we want to find out which capabilities a given interface supports, compare the MPI-3 standard. + # This is determined by interface specific parameters MPI_SUBARRAYS_SUPPORTED and MPI_ASYNC_PROTECTS_NONBLOCKING + # and might vary between the different methods of consumption. + if(MPI_DETERMINE_Fortran_CAPABILITIES AND NOT MPI_Fortran_CAPABILITIES_DETERMINED) + foreach(mpimethod IN ITEMS F08_MODULE F90_MODULE F77_HEADER) + if(MPI_${LANG}_HAVE_${mpimethod}) + set(MPI_${LANG}_${mpimethod}_SUBARRAYS FALSE) + set(MPI_${LANG}_${mpimethod}_ASYNCPROT FALSE) + _MPI_try_staged_settings(${LANG} fortranparam_mpi ${mpimethod} TRUE) + if(MPI_RESULT_${LANG}_fortranparam_mpi_${mpimethod} AND + NOT "${MPI_RUN_RESULT_${LANG}_fortranparam_mpi_${mpimethod}}" STREQUAL "FAILED_TO_RUN") + if("${MPI_RUN_OUTPUT_${LANG}_fortranparam_mpi_${mpimethod}}" MATCHES + ".*INFO:SUBARRAYS\\[ *([TF]) *\\]-ASYNCPROT\\[ *([TF]) *\\].*") + if("${CMAKE_MATCH_1}" STREQUAL "T") + set(MPI_${LANG}_${mpimethod}_SUBARRAYS TRUE) + endif() + if("${CMAKE_MATCH_2}" STREQUAL "T") + set(MPI_${LANG}_${mpimethod}_ASYNCPROT TRUE) + endif() + endif() + endif() + endif() + endforeach() + set(MPI_Fortran_CAPABILITIES_DETERMINED TRUE) + endif() + else() + set(MPI_${LANG}_HIGHEST_METHOD normal) + + # By the MPI-2 standard, MPI_VERSION and MPI_SUBVERSION are valid for both C and C++ bindings. + if(NOT DEFINED MPI_${LANG}_VERSION) + file(STRINGS ${MPI_BIN_FOLDER}/test_mpi_${LANG}.bin _MPI_VERSION_STRING LIMIT_COUNT 1 REGEX "INFO:MPI-VER") + if("${_MPI_VERSION_STRING}" MATCHES ".*INFO:MPI-VER\\[([0-9]+)\\.([0-9]+)\\].*") + set(MPI_${LANG}_VERSION_MAJOR "${CMAKE_MATCH_1}") + set(MPI_${LANG}_VERSION_MINOR "${CMAKE_MATCH_2}") + set(MPI_${LANG}_VERSION "${MPI_${LANG}_VERSION_MAJOR}.${MPI_${LANG}_VERSION_MINOR}") + endif() + endif() endif() - if(MPI_${lang}_COMPILE_FLAGS) - separate_arguments(_MPI_${lang}_COMPILE_OPTIONS NATIVE_COMMAND "${MPI_${lang}_COMPILE_FLAGS}") - set_property(TARGET MPI::MPI_${lang} PROPERTY - INTERFACE_COMPILE_OPTIONS "${_MPI_${lang}_COMPILE_OPTIONS}") + + unset(MPI_BIN_FOLDER) + + # At this point, we have dealt with determining the MPI version and parameters for each Fortran method available. + # The one remaining issue is to determine which MPI library is installed. + # Determining the version and vendor of the MPI library is only possible via MPI_Get_library_version() at runtime, + # and therefore we cannot do this while cross-compiling (a user may still define MPI__LIBRARY_VERSION_STRING + # themselves and we'll attempt splitting it, which is equivalent to provide the try_run output). + # It's also worth noting that the installed version string can depend on the language, or on the system the binary + # runs on if MPI is not statically linked. + if(MPI_DETERMINE_LIBRARY_VERSION AND NOT MPI_${LANG}_LIBRARY_VERSION_STRING) + _MPI_try_staged_settings(${LANG} libver_mpi ${MPI_${LANG}_HIGHEST_METHOD} TRUE) + if(MPI_RESULT_${LANG}_libver_mpi_${MPI_${LANG}_HIGHEST_METHOD} AND + "${MPI_RUN_RESULT_${LANG}_libver_mpi_${MPI_${LANG}_HIGHEST_METHOD}}" EQUAL "0") + string(STRIP "${MPI_RUN_OUTPUT_${LANG}_libver_mpi_${MPI_${LANG}_HIGHEST_METHOD}}" + MPI_${LANG}_LIBRARY_VERSION_STRING) + else() + set(MPI_${LANG}_LIBRARY_VERSION_STRING "NOTFOUND") + endif() endif() + endif() - unset(_MPI_${lang}_LINK_LINE) - if(MPI_${lang}_LINK_FLAGS) - list(APPEND _MPI_${lang}_LINK_LINE "${MPI_${lang}_LINK_FLAGS}") + set(MPI_${LANG}_FIND_QUIETLY ${MPI_FIND_QUIETLY}) + set(MPI_${LANG}_FIND_VERSION ${MPI_FIND_VERSION}) + set(MPI_${LANG}_FIND_VERSION_EXACT ${MPI_FIND_VERSION_EXACT}) + + unset(MPI_${LANG}_REQUIRED_VARS) + if (MPI_${LANG}_WRAPPER_FOUND OR MPI_${LANG}_GUESS_FOUND) + foreach(mpilibname IN LISTS MPI_${LANG}_LIB_NAMES) + list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${mpilibname}_LIBRARY") + endforeach() + list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_LIB_NAMES") + if("${LANG}" STREQUAL "Fortran") + # For Fortran we only need one of the module or header directories to have *some* support for MPI. + if(NOT MPI_${LANG}_MODULE_DIR) + list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_F77_HEADER_DIR") + endif() + if(NOT MPI_${LANG}_F77_HEADER_DIR) + list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_MODULE_DIR") + endif() + else() + list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_HEADER_DIR") + endif() + if(MPI_${LANG}_ADDITIONAL_INCLUDE_VARS) + foreach(mpiincvar IN LISTS MPI_${LANG}_ADDITIONAL_INCLUDE_VARS) + list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${mpiincvar}_INCLUDE_DIR") + endforeach() + endif() + # Append the works variable now. If the settings did not work, this will show up properly. + list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_WORKS") + else() + # If the compiler worked implicitly, use its path as output. + # Should the compiler variable be set, we also require it to work. + list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_COMPILER") + if(MPI_${LANG}_COMPILER) + list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_WORKS") endif() - list(APPEND _MPI_${lang}_LINK_LINE "${MPI_${lang}_LIBRARIES}") - set_property(TARGET MPI::MPI_${lang} PROPERTY - INTERFACE_LINK_LIBRARIES "${_MPI_${lang}_LINK_LINE}") + endif() + find_package_handle_standard_args(MPI_${LANG} REQUIRED_VARS ${MPI_${LANG}_REQUIRED_VARS} + VERSION_VAR MPI_${LANG}_VERSION) - set_property(TARGET MPI::MPI_${lang} PROPERTY - INTERFACE_INCLUDE_DIRECTORIES "${MPI_${lang}_INCLUDE_PATH}") + if(DEFINED MPI_${LANG}_VERSION) + if(NOT _MPI_MIN_VERSION OR _MPI_MIN_VERSION VERSION_GREATER MPI_${LANG}_VERSION) + set(_MPI_MIN_VERSION MPI_${LANG}_VERSION) + endif() endif() endif() endforeach() +unset(_MPI_REQ_VARS) +foreach(LANG IN ITEMS C CXX Fortran) + if((NOT MPI_FIND_COMPONENTS AND CMAKE_${LANG}_COMPILER_LOADED) OR LANG IN_LIST MPI_FIND_COMPONENTS) + list(APPEND _MPI_REQ_VARS "MPI_${LANG}_FOUND") + endif() +endforeach() + +if(MPICXX IN_LIST MPI_FIND_COMPONENTS) + list(APPEND _MPI_REQ_VARS "MPI_MPICXX_FOUND") +endif() + +find_package_handle_standard_args(MPI + REQUIRED_VARS ${_MPI_REQ_VARS} + VERSION_VAR ${_MPI_MIN_VERSION} + HANDLE_COMPONENTS) #============================================================================= # More backward compatibility stuff -# -# Bare MPI sans ${lang} vars are set to CXX then C, depending on what was found. + +# For compatibility reasons, we also define MPIEXEC +set(MPIEXEC "${MPIEXEC_EXECUTABLE}") + +# Copy over MPI__INCLUDE_PATH from the assembled INCLUDE_DIRS. +foreach(LANG IN ITEMS C CXX Fortran) + if(MPI_${LANG}_FOUND) + set(MPI_${LANG}_INCLUDE_PATH "${MPI_${LANG}_INCLUDE_DIRS}") + unset(MPI_${LANG}_COMPILE_FLAGS) + if(MPI_${LANG}_COMPILE_OPTIONS) + set(MPI_${LANG}_COMPILE_FLAGS "${MPI_${LANG}_COMPILE_OPTIONS}") + endif() + if(MPI_${LANG}_COMPILE_DEFINITIONS) + foreach(_MPI_DEF IN LISTS MPI_${LANG}_COMPILE_DEFINITIONS) + string(APPEND MPI_${LANG}_COMPILE_FLAGS " -D${_MPI_DEF}") + endforeach() + endif() + endif() +endforeach() + +# Bare MPI sans ${LANG} vars are set to CXX then C, depending on what was found. # This mimics the behavior of the old language-oblivious FindMPI. -set(_MPI_OLD_VARS FOUND COMPILER INCLUDE_PATH COMPILE_FLAGS LINK_FLAGS LIBRARIES) +set(_MPI_OLD_VARS COMPILER INCLUDE_PATH COMPILE_FLAGS LINK_FLAGS LIBRARIES) if (MPI_CXX_FOUND) foreach (var ${_MPI_OLD_VARS}) set(MPI_${var} ${MPI_CXX_${var}}) @@ -704,28 +1428,26 @@ elseif (MPI_C_FOUND) foreach (var ${_MPI_OLD_VARS}) set(MPI_${var} ${MPI_C_${var}}) endforeach() -else() - # Note that we might still have found Fortran, but you'll need to use MPI_Fortran_FOUND - set(MPI_FOUND FALSE) endif() # Chop MPI_LIBRARIES into the old-style MPI_LIBRARY and MPI_EXTRA_LIBRARY, and set them in cache. if (MPI_LIBRARIES) list(GET MPI_LIBRARIES 0 MPI_LIBRARY_WORK) - set(MPI_LIBRARY ${MPI_LIBRARY_WORK} CACHE FILEPATH "MPI library to link against" FORCE) + set(MPI_LIBRARY "${MPI_LIBRARY_WORK}") + unset(MPI_LIBRARY_WORK) else() - set(MPI_LIBRARY "MPI_LIBRARY-NOTFOUND" CACHE FILEPATH "MPI library to link against" FORCE) + set(MPI_LIBRARY "MPI_LIBRARY-NOTFOUND") endif() list(LENGTH MPI_LIBRARIES MPI_NUMLIBS) if (MPI_NUMLIBS GREATER 1) - set(MPI_EXTRA_LIBRARY_WORK ${MPI_LIBRARIES}) + set(MPI_EXTRA_LIBRARY_WORK "${MPI_LIBRARIES}") list(REMOVE_AT MPI_EXTRA_LIBRARY_WORK 0) - set(MPI_EXTRA_LIBRARY ${MPI_EXTRA_LIBRARY_WORK} CACHE STRING "Extra MPI libraries to link against" FORCE) + set(MPI_EXTRA_LIBRARY "${MPI_EXTRA_LIBRARY_WORK}") + unset(MPI_EXTRA_LIBRARY_WORK) else() - set(MPI_EXTRA_LIBRARY "MPI_EXTRA_LIBRARY-NOTFOUND" CACHE STRING "Extra MPI libraries to link against" FORCE) + set(MPI_EXTRA_LIBRARY "MPI_EXTRA_LIBRARY-NOTFOUND") endif() -mark_as_advanced(MPI_LIBRARY MPI_EXTRA_LIBRARY) #============================================================================= # unset these vars to cleanup namespace @@ -733,5 +1455,7 @@ unset(_MPI_OLD_VARS) unset(_MPI_PREFIX_PATH) unset(_MPI_BASE_DIR) foreach (lang C CXX Fortran) - unset(_MPI_${lang}_COMPILER_NAMES) + unset(_MPI_${LANG}_COMPILER_NAMES) endforeach() + +cmake_policy(POP) diff --git a/fortran/examples/CMakeTests.cmake b/fortran/examples/CMakeTests.cmake index 3403571..b130f30 100644 --- a/fortran/examples/CMakeTests.cmake +++ b/fortran/examples/CMakeTests.cmake @@ -153,8 +153,8 @@ if (HDF5_ENABLE_F2003) endif () if (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND) - add_test (NAME f90_ex_ph5example COMMAND ${MPIEXEC} ${MPIEXEC_PREFLAGS} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_POSTFLAGS} $) + add_test (NAME f90_ex_ph5example COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) - add_test (NAME f90_ex-shared_ph5example COMMAND ${MPIEXEC} ${MPIEXEC_PREFLAGS} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_POSTFLAGS} $) + add_test (NAME f90_ex-shared_ph5example COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) endif () endif () diff --git a/fortran/src/CMakeLists.txt b/fortran/src/CMakeLists.txt index 4a723c7..51db4f0 100644 --- a/fortran/src/CMakeLists.txt +++ b/fortran/src/CMakeLists.txt @@ -241,9 +241,9 @@ endif () add_library (${HDF5_F90_LIB_TARGET} STATIC ${f90_F_SOURCES}) set (SHARED_LINK_FLAGS " ") TARGET_FORTRAN_PROPERTIES (${HDF5_F90_LIB_TARGET} STATIC " " " ") -target_link_libraries (${HDF5_F90_LIB_TARGET} ${HDF5_F90_C_LIB_TARGET} ${HDF5_LIB_TARGET}) +target_link_libraries (${HDF5_F90_LIB_TARGET} ${HDF5_F90_C_LIB_TARGET} ${HDF5_LIB_TARGET} ${LINK_Fortran_LIBS}) if (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND) - target_link_libraries (${HDF5_F90_LIB_TARGET} MPI::MPI_Fortran) + target_include_directories (${HDF5_F90_LIB_TARGET} PUBLIC ${MPI_Fortran_INCLUDE_DIRS}) endif () set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_F90_LIB_TARGET}") H5_SET_LIB_OPTIONS (${HDF5_F90_LIB_TARGET} ${HDF5_F90_LIB_NAME} STATIC) @@ -268,9 +268,9 @@ if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) set (SHARED_LINK_FLAGS "/DLL /DEF:${HDF5_F90_SRC_BINARY_DIR}/hdf5_fortrandll.def") endif () TARGET_FORTRAN_PROPERTIES (${HDF5_F90_LIBSH_TARGET} SHARED " " ${SHARED_LINK_FLAGS}) - target_link_libraries (${HDF5_F90_LIBSH_TARGET} ${HDF5_F90_C_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) + target_link_libraries (${HDF5_F90_LIBSH_TARGET} ${HDF5_F90_C_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} ${LINK_Fortran_LIBS}) if (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND) - target_link_libraries (${HDF5_F90_LIBSH_TARGET} MPI::MPI_Fortran) + target_include_directories (${HDF5_F90_LIBSH_TARGET} PUBLIC ${MPI_Fortran_INCLUDE_DIRS}) endif () set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_F90_LIBSH_TARGET}") H5_SET_LIB_OPTIONS (${HDF5_F90_LIBSH_TARGET} ${HDF5_F90_LIB_NAME} SHARED ${HDF5_F_PACKAGE_SOVERSION}) diff --git a/fortran/testpar/CMakeLists.txt b/fortran/testpar/CMakeLists.txt index 909cbaf..4aa7f43 100644 --- a/fortran/testpar/CMakeLists.txt +++ b/fortran/testpar/CMakeLists.txt @@ -4,7 +4,7 @@ PROJECT (HDF5_FORTRAN_TESTPAR C CXX Fortran) #----------------------------------------------------------------------------- # Setup include Directories #----------------------------------------------------------------------------- -INCLUDE_DIRECTORIES (${MPI_Fortran_INCLUDE_PATH} ${HDF5_F90_BINARY_DIR} ${HDF5_F90_SRC_DIR}/src) +set (TESTPAR_INCLUDES ${MPI_Fortran_INCLUDE_DIRS} ${CMAKE_Fortran_MODULE_DIRECTORY}/static ${HDF5_F90_BINARY_DIR} ${HDF5_F90_SRC_DIR}/src) #----------------------------------------------------------------------------- # Add Tests @@ -27,7 +27,7 @@ target_link_libraries (parallel_test if (WIN32 AND MSVC) target_link_libraries (parallel_test "ws2_32.lib") endif () -target_include_directories (parallel_test PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/static) +target_include_directories (parallel_test PRIVATE ${TESTPAR_INCLUDES}) set_target_properties (parallel_test PROPERTIES LINKER_LANGUAGE Fortran) set_target_properties (parallel_test PROPERTIES FOLDER test/fortran) diff --git a/fortran/testpar/CMakeTests.cmake b/fortran/testpar/CMakeTests.cmake index 5736256..d00a6fc 100644 --- a/fortran/testpar/CMakeTests.cmake +++ b/fortran/testpar/CMakeTests.cmake @@ -15,4 +15,4 @@ ### T E S T I N G ### ############################################################################## ############################################################################## -add_test (NAME FORT_parallel_test COMMAND ${MPIEXEC} ${MPIEXEC_PREFLAGS} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_POSTFLAGS} $) +add_test (NAME FORT_parallel_test COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1651b15..4be86a9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -881,13 +881,12 @@ set (gen_SRCS ${HDF5_BINARY_DIR}/H5Tinit.c ${HDF5_BINARY_DIR}/H5lib_settings.c) add_library (${HDF5_LIB_TARGET} STATIC ${common_SRCS} ${gen_SRCS} ${H5_PUBLIC_HEADERS} ${H5_PRIVATE_HEADERS} ${H5_GENERATED_HEADERS}) TARGET_C_PROPERTIES (${HDF5_LIB_TARGET} STATIC " " " ") -target_link_libraries (${HDF5_LIB_TARGET} PRIVATE ${LINK_LIBS}) +target_link_libraries (${HDF5_LIB_TARGET} PUBLIC ${LINK_LIBS}) if (NOT WIN32) - target_link_libraries (${HDF5_LIB_TARGET} PRIVATE dl) + target_link_libraries (${HDF5_LIB_TARGET} PUBLIC dl) endif () if (H5_HAVE_PARALLEL AND MPI_C_FOUND) - target_include_directories (${HDF5_LIB_TARGET} PRIVATE ${MPI_C_INCLUDE_PATH}) - target_link_libraries (${HDF5_LIB_TARGET} PRIVATE MPI::MPI_C}) + target_include_directories (${HDF5_LIB_TARGET} PUBLIC ${MPI_C_INCLUDE_DIRS}) endif () set_global_variable (HDF5_LIBRARIES_TO_EXPORT ${HDF5_LIB_TARGET}) H5_SET_LIB_OPTIONS (${HDF5_LIB_TARGET} ${HDF5_LIB_NAME} STATIC) @@ -931,8 +930,7 @@ if (BUILD_SHARED_LIBS) target_link_libraries (${HDF5_LIBSH_TARGET} PUBLIC dl) endif () if (H5_HAVE_PARALLEL AND MPI_C_FOUND) - target_include_directories (${HDF5_LIBSH_TARGET} PRIVATE ${MPI_C_INCLUDE_PATH}) - target_link_libraries (${HDF5_LIBSH_TARGET} PRIVATE MPI::MPI_C) + target_include_directories (${HDF5_LIBSH_TARGET} PUBLIC ${MPI_C_INCLUDE_DIRS}) endif () set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_LIBSH_TARGET}") H5_SET_LIB_OPTIONS (${HDF5_LIBSH_TARGET} ${HDF5_LIB_NAME} SHARED ${HDF5_PACKAGE_SOVERSION}) diff --git a/testpar/CMakeLists.txt b/testpar/CMakeLists.txt index 0c9f70e..b116d66 100644 --- a/testpar/CMakeLists.txt +++ b/testpar/CMakeLists.txt @@ -30,14 +30,14 @@ set (testphdf5_SOURCES add_executable (testphdf5 ${testphdf5_SOURCES}) TARGET_NAMING (testphdf5 STATIC) TARGET_C_PROPERTIES (testphdf5 STATIC " " " ") -target_link_libraries (testphdf5 ${HDF5_TEST_LIB_TARGET} ${HDF5_LIB_TARGET} ${LINK_LIBS}) +target_link_libraries (testphdf5 ${HDF5_TEST_LIB_TARGET} ${HDF5_LIB_TARGET}) set_target_properties (testphdf5 PROPERTIES FOLDER test/par) MACRO (ADD_H5P_EXE file) add_executable (${file} ${HDF5_TEST_PAR_SOURCE_DIR}/${file}.c) TARGET_NAMING (${file} STATIC) TARGET_C_PROPERTIES (${file} STATIC " " " ") - target_link_libraries (${file} ${HDF5_TEST_LIB_TARGET} ${HDF5_LIB_TARGET} ${LINK_LIBS}) + target_link_libraries (${file} ${HDF5_TEST_LIB_TARGET} ${HDF5_LIB_TARGET}) set_target_properties (${file} PROPERTIES FOLDER test/par) ENDMACRO (ADD_H5P_EXE file) diff --git a/testpar/CMakeTests.cmake b/testpar/CMakeTests.cmake index 6e2b05e..87470f3 100644 --- a/testpar/CMakeTests.cmake +++ b/testpar/CMakeTests.cmake @@ -16,10 +16,10 @@ ############################################################################## ############################################################################## -add_test (NAME TEST_PAR_testphdf5 COMMAND ${MPIEXEC} ${MPIEXEC_PREFLAGS} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_POSTFLAGS} $) +add_test (NAME TEST_PAR_testphdf5 COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) foreach (testp ${H5P_TESTS}) - add_test (NAME TEST_PAR_${testp} COMMAND ${MPIEXEC} ${MPIEXEC_PREFLAGS} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_POSTFLAGS} $) + add_test (NAME TEST_PAR_${testp} COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) endforeach () # The following will only be correct on windows shared diff --git a/tools/test/h5diff/CMakeTests.cmake b/tools/test/h5diff/CMakeTests.cmake index d87a47f..bbc39d8 100644 --- a/tools/test/h5diff/CMakeTests.cmake +++ b/tools/test/h5diff/CMakeTests.cmake @@ -447,7 +447,7 @@ macro (ADD_PH5_TEST resultfile resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME PH5DIFF-${resultfile} COMMAND $ ${MPIEXEC} ${MPIEXEC_PREFLAGS} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_POSTFLAGS} ${ARGN}) + add_test (NAME PH5DIFF-${resultfile} COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS} ${ARGN}) set_tests_properties (PH5DIFF-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/PAR/testfiles") if (NOT "${resultcode}" STREQUAL "0") set_tests_properties (PH5DIFF-${resultfile} PROPERTIES WILL_FAIL "true") @@ -470,7 +470,7 @@ add_test ( NAME PH5DIFF-${resultfile} COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=${MPIEXEC};${MPIEXEC_PREFLAGS};${MPIEXEC_NUMPROC_FLAG};${MPIEXEC_MAX_NUMPROCS};${MPIEXEC_POSTFLAGS};$" + -D "TEST_PROGRAM=${MPIEXEC_EXECUTABLE};${MPIEXEC_NUMPROC_FLAG};${MPIEXEC_MAX_NUMPROCS};${MPIEXEC_PREFLAGS};$;${MPIEXEC_POSTFLAGS}" -D "TEST_ARGS:STRING=${ARGN}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/PAR/testfiles" -D "TEST_OUTPUT=${resultfile}.out" diff --git a/tools/test/perform/CMakeTests.cmake b/tools/test/perform/CMakeTests.cmake index 1f67abe..450667a 100644 --- a/tools/test/perform/CMakeTests.cmake +++ b/tools/test/perform/CMakeTests.cmake @@ -170,9 +170,9 @@ endif () set_tests_properties (PERFORM_zip_perf PROPERTIES DEPENDS "PERFORM_zip_perf_help;PERFORM_h5perform-clearall-objects") if (H5_HAVE_PARALLEL) - add_test (NAME PERFORM_h5perf COMMAND ${MPIEXEC} ${MPIEXEC_PREFLAGS} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_POSTFLAGS} $) + add_test (NAME PERFORM_h5perf COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) if (HDF5_BUILD_PERFORM_STANDALONE) - add_test (NAME PERFORM_h5perf_alone COMMAND ${MPIEXEC} ${MPIEXEC_PREFLAGS} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_POSTFLAGS} $) + add_test (NAME PERFORM_h5perf_alone COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) endif () endif () -- cgit v0.12 From 9aa8e01e5cf6062f71a6d65dfd76061899ab4a03 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 1 Nov 2017 13:45:44 -0500 Subject: Remove duplicated module --- config/cmake_ext_mod/FindMPI.cmake | 1461 ------------------------------------ 1 file changed, 1461 deletions(-) delete mode 100644 config/cmake_ext_mod/FindMPI.cmake diff --git a/config/cmake_ext_mod/FindMPI.cmake b/config/cmake_ext_mod/FindMPI.cmake deleted file mode 100644 index 61ab4a4..0000000 --- a/config/cmake_ext_mod/FindMPI.cmake +++ /dev/null @@ -1,1461 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See https://cmake.org/licensing for details. - -#.rst: -# FindMPI -# ------- -# -# Find a Message Passing Interface (MPI) implementation. -# -# The Message Passing Interface (MPI) is a library used to write -# high-performance distributed-memory parallel applications, and is -# typically deployed on a cluster. MPI is a standard interface (defined -# by the MPI forum) for which many implementations are available. -# -# Variables for using MPI -# ^^^^^^^^^^^^^^^^^^^^^^^ -# -# The module exposes the components ``C``, ``CXX``, ``MPICXX`` and ``Fortran``. -# Each of these controls the various MPI languages to search for. -# The difference between ``CXX`` and ``MPICXX`` is that ``CXX`` refers to the -# MPI C API being usable from C++, whereas ``MPICXX`` refers to the MPI-2 C++ API -# that was removed again in MPI-3. -# -# Depending on the enabled components the following variables will be set: -# -# ``MPI_FOUND`` -# Variable indicating that MPI settings for all requested languages have been found. -# If no components are specified, this is true if MPI settings for all enabled languages -# were detected. Note that the ``MPICXX`` component does not affect this variable. -# ``MPI_VERSION`` -# Minimal version of MPI detected among the requested languages, or all enabled languages -# if no components were specified. -# -# This module will set the following variables per language in your -# project, where ```` is one of C, CXX, or Fortran: -# -# ``MPI__FOUND`` -# Variable indicating the MPI settings for ```` were found and that -# simple MPI test programs compile with the provided settings. -# ``MPI__COMPILER`` -# MPI compiler for ```` if such a program exists. -# ``MPI__COMPILE_OPTIONS`` -# Compilation options for MPI programs in ````, given as a :ref:`;-list `. -# ``MPI__COMPILE_DEFINITIONS`` -# Compilation definitions for MPI programs in ````, given as a :ref:`;-list `. -# ``MPI__INCLUDE_DIRS`` -# Include path(s) for MPI header. -# ``MPI__LINK_FLAGS`` -# Linker flags for MPI programs. -# ``MPI__LIBRARIES`` -# All libraries to link MPI programs against. -# -# Additionally, the following :prop_tgt:`IMPORTED` targets are defined: -# -# ``MPI::MPI_`` -# Target for using MPI from ````. -# -# The following variables indicating which bindings are present will be defined: -# -# ``MPI_MPICXX_FOUND`` -# Variable indicating whether the MPI-2 C++ bindings are present (introduced in MPI-2, removed with MPI-3). -# ``MPI_Fortran_HAVE_F77_HEADER`` -# True if the Fortran 77 header ``mpif.h`` is available. -# ``MPI_Fortran_HAVE_F90_MODULE`` -# True if the Fortran 90 module ``mpi`` can be used for accessing MPI (MPI-2 and higher only). -# ``MPI_Fortran_HAVE_F08_MODULE`` -# True if the Fortran 2008 ``mpi_f08`` is available to MPI programs (MPI-3 and higher only). -# -# If possible, the MPI version will be determined by this module. The facilities to detect the MPI version -# were introduced with MPI-1.2, and therefore cannot be found for older MPI versions. -# -# ``MPI__VERSION_MAJOR`` -# Major version of MPI implemented for ```` by the MPI distribution. -# ``MPI__VERSION_MINOR`` -# Minor version of MPI implemented for ```` by the MPI distribution. -# ``MPI__VERSION`` -# MPI version implemented for ```` by the MPI distribution. -# -# Note that there's no variable for the C bindings being accessible through ``mpi.h``, since the MPI standards -# always have required this binding to work in both C and C++ code. -# -# For running MPI programs, the module sets the following variables -# -# ``MPIEXEC_EXECUTABLE`` -# Executable for running MPI programs, if such exists. -# ``MPIEXEC_NUMPROC_FLAG`` -# Flag to pass to ``mpiexec`` before giving it the number of processors to run on. -# ``MPIEXEC_MAX_NUMPROCS`` -# Number of MPI processors to utilize. Defaults to the number -# of processors detected on the host system. -# ``MPIEXEC_PREFLAGS`` -# Flags to pass to ``mpiexec`` directly before the executable to run. -# ``MPIEXEC_POSTFLAGS`` -# Flags to pass to ``mpiexec`` after other flags. -# -# Variables for locating MPI -# ^^^^^^^^^^^^^^^^^^^^^^^^^^ -# -# This module performs a three step search for an MPI implementation: -# -# 1. Check if the compiler has MPI support built-in. This is the case if the user passed a -# compiler wrapper as ``CMAKE__COMPILER`` or if they're on a Cray system. -# 2. Attempt to find an MPI compiler wrapper and determine the compiler information from it. -# 3. Try to find an MPI implementation that does not ship such a wrapper by guessing settings. -# Currently, only Microsoft MPI and MPICH2 on Windows are supported. -# -# For controlling the second step, the following variables may be set: -# -# ``MPI__COMPILER`` -# Search for the specified compiler wrapper and use it. -# ``MPI__COMPILER_FLAGS`` -# Flags to pass to the MPI compiler wrapper during interrogation. Some compiler wrappers -# support linking debug or tracing libraries if a specific flag is passed and this variable -# may be used to obtain them. -# ``MPI_COMPILER_FLAGS`` -# Used to initialize ``MPI__COMPILER_FLAGS`` if no language specific flag has been given. -# Empty by default. -# ``MPI_EXECUTABLE_SUFFIX`` -# A suffix which is appended to all names that are being looked for. For instance you may set this -# to ``.mpich`` or ``.openmpi`` to prefer the one or the other on Debian and its derivatives. -# -# In order to control the guessing step, the following variable may be set: -# -# ``MPI_GUESS_LIBRARY_NAME`` -# Valid values are ``MSMPI`` and ``MPICH2``. If set, only the given library will be searched for. -# By default, ``MSMPI`` will be preferred over ``MPICH2`` if both are available. -# This also sets ``MPI_SKIP_COMPILER_WRAPPER`` to ``true``, which may be overridden. -# -# Each of the search steps may be skipped with the following control variables: -# -# ``MPI_ASSUME_NO_BUILTIN_MPI`` -# If true, the module assumes that the compiler itself does not provide an MPI implementation and -# skips to step 2. -# ``MPI_SKIP_COMPILER_WRAPPER`` -# If true, no compiler wrapper will be searched for. -# ``MPI_SKIP_GUESSING`` -# If true, the guessing step will be skipped. -# -# Additionally, the following control variable is available to change search behavior: -# -# ``MPI_CXX_SKIP_MPICXX`` -# Add some definitions that will disable the MPI-2 C++ bindings. -# Currently supported are MPICH, Open MPI, Platform MPI and derivatives thereof, -# for example MVAPICH or Intel MPI. -# -# If the find procedure fails for a variable ``MPI__WORKS``, then the settings detected by or passed to -# the module did not work and even a simple MPI test program failed to compile. -# -# If all of these parameters were not sufficient to find the right MPI implementation, a user may -# disable the entire autodetection process by specifying both a list of libraries in ``MPI__LIBRARIES`` -# and a list of include directories in ``MPI__ADDITIONAL_INCLUDE_DIRS``. -# Any other variable may be set in addition to these two. The module will then validate the MPI settings and store the -# settings in the cache. -# -# Cache variables for MPI -# ^^^^^^^^^^^^^^^^^^^^^^^ -# -# The variable ``MPI__INCLUDE_DIRS`` will be assembled from the following variables. -# For C and CXX: -# -# ``MPI__HEADER_DIR`` -# Location of the ``mpi.h`` header on disk. -# -# For Fortran: -# -# ``MPI_Fortran_F77_HEADER_DIR`` -# Location of the Fortran 77 header ``mpif.h``, if it exists. -# ``MPI_Fortran_MODULE_DIR`` -# Location of the ``mpi`` or ``mpi_f08`` modules, if available. -# -# For all languages the following variables are additionally considered: -# -# ``MPI__ADDITIONAL_INCLUDE_DIRS`` -# A :ref:`;-list ` of paths needed in addition to the normal include directories. -# ``MPI__INCLUDE_DIR`` -# Path variables for include folders referred to by ````. -# ``MPI__ADDITIONAL_INCLUDE_VARS`` -# A :ref:`;-list ` of ```` that will be added to the include locations of ````. -# -# The variable ``MPI__LIBRARIES`` will be assembled from the following variables: -# -# ``MPI__LIBRARY`` -# The location of a library called ```` for use with MPI. -# ``MPI__LIB_NAMES`` -# A :ref:`;-list ` of ```` that will be added to the include locations of ````. -# -# Usage of mpiexec -# ^^^^^^^^^^^^^^^^ -# -# When using ``MPIEXEC_EXECUTABLE`` to execute MPI applications, you should typically -# use all of the ``MPIEXEC_EXECUTABLE`` flags as follows: -# -# :: -# -# ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} -# ${MPIEXEC_PREFLAGS} EXECUTABLE ${MPIEXEC_POSTFLAGS} ARGS -# -# where ``EXECUTABLE`` is the MPI program, and ``ARGS`` are the arguments to -# pass to the MPI program. -# -# Advanced variables for using MPI -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -# -# The module can perform some advanced feature detections upon explicit request. -# -# **Important notice:** The following checks cannot be performed without *executing* an MPI test program. -# Consider the special considerations for the behavior of :command:`try_run` during cross compilation. -# Moreover, running an MPI program can cause additional issues, like a firewall notification on some systems. -# You should only enable these detections if you absolutely need the information. -# -# If the following variables are set to true, the respective search will be performed: -# -# ``MPI_DETERMINE_Fortran_CAPABILITIES`` -# Determine for all available Fortran bindings what the values of ``MPI_SUBARRAYS_SUPPORTED`` and -# ``MPI_ASYNC_PROTECTS_NONBLOCKING`` are and make their values available as ``MPI_Fortran__SUBARRAYS`` -# and ``MPI_Fortran__ASYNCPROT``, where ```` is one of ``F77_HEADER``, ``F90_MODULE`` and -# ``F08_MODULE``. -# ``MPI_DETERMINE_LIBRARY_VERSION`` -# For each language, find the output of ``MPI_Get_library_version`` and make it available as ``MPI__LIBRARY_VERSION``. -# This information is usually tied to the runtime component of an MPI implementation and might differ depending on ````. -# Note that the return value is entirely implementation defined. This information might be used to identify -# the MPI vendor and for example pick the correct one of multiple third party binaries that matches the MPI vendor. -# -# Backward Compatibility -# ^^^^^^^^^^^^^^^^^^^^^^ -# -# For backward compatibility with older versions of FindMPI, these -# variables are set, but deprecated: -# -# :: -# -# MPI_COMPILER MPI_LIBRARY MPI_EXTRA_LIBRARY -# MPI_COMPILE_FLAGS MPI_INCLUDE_PATH MPI_LINK_FLAGS -# MPI_LIBRARIES -# -# In new projects, please use the ``MPI__XXX`` equivalents. -# Additionally, the following variables are deprecated: -# -# ``MPI__COMPILE_FLAGS`` -# Use ``MPI__COMPILE_OPTIONS`` and ``MPI__COMPILE_DEFINITIONS`` instead. -# ``MPI__INCLUDE_PATH`` -# For consumption use ``MPI__INCLUDE_DIRS`` and for specifying folders use ``MPI__ADDITIONAL_INCLUDE_DIRS`` instead. -# ``MPIEXEC`` -# Use ``MPIEXEC_EXECUTABLE`` instead. - -cmake_policy(PUSH) -cmake_policy(SET CMP0057 NEW) # if IN_LIST - -# include this to handle the QUIETLY and REQUIRED arguments -include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) -include(GetPrerequisites) - -# Generic compiler names -set(_MPI_C_GENERIC_COMPILER_NAMES mpicc mpcc mpicc_r mpcc_r) -set(_MPI_CXX_GENERIC_COMPILER_NAMES mpicxx mpiCC mpcxx mpCC mpic++ mpc++ - mpicxx_r mpiCC_r mpcxx_r mpCC_r mpic++_r mpc++_r) -set(_MPI_Fortran_GENERIC_COMPILER_NAMES mpif95 mpif95_r mpf95 mpf95_r - mpif90 mpif90_r mpf90 mpf90_r - mpif77 mpif77_r mpf77 mpf77_r - mpifc) - -# GNU compiler names -set(_MPI_GNU_C_COMPILER_NAMES mpigcc mpgcc mpigcc_r mpgcc_r) -set(_MPI_GNU_CXX_COMPILER_NAMES mpig++ mpg++ mpig++_r mpg++_r mpigxx) -set(_MPI_GNU_Fortran_COMPILER_NAMES mpigfortran mpgfortran mpigfortran_r mpgfortran_r - mpig77 mpig77_r mpg77 mpg77_r) - -# Intel MPI compiler names on Windows -if(WIN32) - list(APPEND _MPI_C_GENERIC_COMPILER_NAMES mpicc.bat) - list(APPEND _MPI_CXX_GENERIC_COMPILER_NAMES mpicxx.bat) - list(APPEND _MPI_Fortran_GENERIC_COMPILER_NAMES mpifc.bat) - - # Intel MPI compiler names - set(_MPI_Intel_C_COMPILER_NAMES mpiicc.bat) - set(_MPI_Intel_CXX_COMPILER_NAMES mpiicpc.bat) - set(_MPI_Intel_Fortran_COMPILER_NAMES mpiifort.bat mpif77.bat mpif90.bat) - - # Intel MPI compiler names for MSMPI - set(_MPI_MSVC_C_COMPILER_NAMES mpicl.bat) - set(_MPI_MSVC_CXX_COMPILER_NAMES mpicl.bat) -else() - # Intel compiler names - set(_MPI_Intel_C_COMPILER_NAMES mpiicc) - set(_MPI_Intel_CXX_COMPILER_NAMES mpiicpc mpiicxx mpiic++) - set(_MPI_Intel_Fortran_COMPILER_NAMES mpiifort mpiif95 mpiif90 mpiif77) -endif() - -# PGI compiler names -set(_MPI_PGI_C_COMPILER_NAMES mpipgcc mppgcc) -set(_MPI_PGI_CXX_COMPILER_NAMES mpipgCC mppgCC) -set(_MPI_PGI_Fortran_COMPILER_NAMES mpipgf95 mpipgf90 mppgf95 mppgf90 mpipgf77 mppgf77) - -# XLC MPI Compiler names -set(_MPI_XL_C_COMPILER_NAMES mpxlc mpxlc_r mpixlc mpixlc_r) -set(_MPI_XL_CXX_COMPILER_NAMES mpixlcxx mpixlC mpixlc++ mpxlcxx mpxlc++ mpixlc++ mpxlCC - mpixlcxx_r mpixlC_r mpixlc++_r mpxlcxx_r mpxlc++_r mpixlc++_r mpxlCC_r) -set(_MPI_XL_Fortran_COMPILER_NAMES mpixlf95 mpixlf95_r mpxlf95 mpxlf95_r - mpixlf90 mpixlf90_r mpxlf90 mpxlf90_r - mpixlf77 mpixlf77_r mpxlf77 mpxlf77_r - mpixlf mpixlf_r mpxlf mpxlf_r) - -# Prepend vendor-specific compiler wrappers to the list. If we don't know the compiler, -# attempt all of them. -# By attempting vendor-specific compiler names first, we should avoid situations where the compiler wrapper -# stems from a proprietary MPI and won't know which compiler it's being used for. For instance, Intel MPI -# controls its settings via the I_MPI_CC environment variables if the generic name is being used. -# If we know which compiler we're working with, we can use the most specialized wrapper there is in order to -# pick up the right settings for it. -foreach (LANG IN ITEMS C CXX Fortran) - set(_MPI_${LANG}_COMPILER_NAMES "") - foreach (id IN ITEMS GNU Intel MSVC PGI XL) - if (NOT CMAKE_${LANG}_COMPILER_ID OR CMAKE_${LANG}_COMPILER_ID STREQUAL id) - list(APPEND _MPI_${LANG}_COMPILER_NAMES ${_MPI_${id}_${LANG}_COMPILER_NAMES}${MPI_EXECUTABLE_SUFFIX}) - endif() - unset(_MPI_${id}_${LANG}_COMPILER_NAMES) - endforeach() - list(APPEND _MPI_${LANG}_COMPILER_NAMES ${_MPI_${LANG}_GENERIC_COMPILER_NAMES}${MPI_EXECUTABLE_SUFFIX}) - unset(_MPI_${LANG}_GENERIC_COMPILER_NAMES) -endforeach() - -# Names to try for mpiexec -# Only mpiexec commands are guaranteed to behave as described in the standard, -# mpirun commands are not covered by the standard in any way whatsoever. -# lamexec is the executable for LAM/MPI, srun is for SLURM or Open MPI with SLURM support. -# srun -n X is however a valid command, so it behaves 'like' mpiexec. -set(_MPIEXEC_NAMES_BASE mpiexec mpiexec.hydra mpiexec.mpd mpirun lamexec srun) - -unset(_MPIEXEC_NAMES) -foreach(_MPIEXEC_NAME IN LISTS _MPIEXEC_NAMES_BASE) - list(APPEND _MPIEXEC_NAMES "${_MPIEXEC_NAME}${MPI_EXECUTABLE_SUFFIX}") -endforeach() -unset(_MPIEXEC_NAMES_BASE) - -function (_MPI_check_compiler LANG QUERY_FLAG OUTPUT_VARIABLE RESULT_VARIABLE) - if(DEFINED MPI_${LANG}_COMPILER_FLAGS) - separate_arguments(_MPI_COMPILER_WRAPPER_OPTIONS NATIVE_COMMAND "${MPI_${LANG}_COMPILER_FLAGS}") - else() - separate_arguments(_MPI_COMPILER_WRAPPER_OPTIONS NATIVE_COMMAND "${MPI_COMPILER_FLAGS}") - endif() - execute_process( - COMMAND ${MPI_${LANG}_COMPILER} ${_MPI_COMPILER_WRAPPER_OPTIONS} ${QUERY_FLAG} - OUTPUT_VARIABLE WRAPPER_OUTPUT OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_VARIABLE WRAPPER_OUTPUT ERROR_STRIP_TRAILING_WHITESPACE - RESULT_VARIABLE WRAPPER_RETURN) - # Some compiler wrappers will yield spurious zero return values, for example - # Intel MPI tolerates unknown arguments and if the MPI wrappers loads a shared - # library that has invalid or missing version information there would be warning - # messages emitted by ld.so in the compiler output. In either case, we'll treat - # the output as invalid. - if("${WRAPPER_OUTPUT}" MATCHES "undefined reference|unrecognized|need to set|no version information available") - set(WRAPPER_RETURN 255) - endif() - # Ensure that no error output might be passed upwards. - if(NOT WRAPPER_RETURN EQUAL 0) - unset(WRAPPER_OUTPUT) - endif() - set(${OUTPUT_VARIABLE} "${WRAPPER_OUTPUT}" PARENT_SCOPE) - set(${RESULT_VARIABLE} "${WRAPPER_RETURN}" PARENT_SCOPE) -endfunction() - -function (_MPI_interrogate_compiler lang) - unset(MPI_COMPILE_CMDLINE) - unset(MPI_LINK_CMDLINE) - - unset(MPI_COMPILE_OPTIONS_WORK) - unset(MPI_COMPILE_DEFINITIONS_WORK) - unset(MPI_INCLUDE_DIRS_WORK) - unset(MPI_LINK_FLAGS_WORK) - unset(MPI_LIB_NAMES_WORK) - unset(MPI_LIB_FULLPATHS_WORK) - - # Check whether the -showme:compile option works. This indicates that we have either Open MPI - # or a newer version of LAM/MPI, and implies that -showme:link will also work. - # Open MPI also supports -show, but separates linker and compiler information - _MPI_check_compiler(${LANG} "-showme:compile" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) - if (MPI_COMPILER_RETURN EQUAL 0) - _MPI_check_compiler(${LANG} "-showme:link" MPI_LINK_CMDLINE MPI_COMPILER_RETURN) - - if (NOT MPI_COMPILER_RETURN EQUAL 0) - unset(MPI_COMPILE_CMDLINE) - endif() - endif() - - # MPICH and MVAPICH offer -compile-info and -link-info. - # For modern versions, both do the same as -show. However, for old versions, they do differ - # when called for mpicxx and mpif90 and it's necessary to use them over -show in order to find the - # removed MPI C++ bindings. - if (NOT MPI_COMPILER_RETURN EQUAL 0) - _MPI_check_compiler(${LANG} "-compile-info" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) - - if (MPI_COMPILER_RETURN EQUAL 0) - _MPI_check_compiler(${LANG} "-link-info" MPI_LINK_CMDLINE MPI_COMPILER_RETURN) - - if (NOT MPI_COMPILER_RETURN EQUAL 0) - unset(MPI_COMPILE_CMDLINE) - endif() - endif() - endif() - - # MPICH, MVAPICH2 and Intel MPI just use "-show". Open MPI also offers this, but the - # -showme commands are more specialized. - if (NOT MPI_COMPILER_RETURN EQUAL 0) - _MPI_check_compiler(${LANG} "-show" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) - endif() - - # Older versions of LAM/MPI have "-showme". Open MPI also supports this. - # Unknown to MPICH, MVAPICH and Intel MPI. - if (NOT MPI_COMPILER_RETURN EQUAL 0) - _MPI_check_compiler(${LANG} "-showme" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) - endif() - - if (NOT (MPI_COMPILER_RETURN EQUAL 0) OR NOT (DEFINED MPI_COMPILE_CMDLINE)) - # Cannot interrogate this compiler, so exit. - set(MPI_${LANG}_WRAPPER_FOUND FALSE PARENT_SCOPE) - return() - endif() - unset(MPI_COMPILER_RETURN) - - # We have our command lines, but we might need to copy MPI_COMPILE_CMDLINE - # into MPI_LINK_CMDLINE, if we didn't find the link line. - if (NOT DEFINED MPI_LINK_CMDLINE) - set(MPI_LINK_CMDLINE "${MPI_COMPILE_CMDLINE}") - endif() - - # At this point, we obtained some output from a compiler wrapper that works. - # We'll now try to parse it into variables with meaning to us. - if("${LANG}" STREQUAL "Fortran") - # Some MPICH-1 and MVAPICH-1 versions return a three command answer for Fortran, consisting - # out of a symlink command for mpif.h, the actual compiler command and a deletion of the - # created symlink. We need to detect that case, remember the include path and drop the - # symlink/deletion operation to obtain the link/compile lines we'd usually expect. - if("${MPI_COMPILE_CMDLINE}" MATCHES "^ln -s ([^\" ]+|\"[^\"]+\") mpif.h") - get_filename_component(MPI_INCLUDE_DIRS_WORK "${CMAKE_MATCH_1}" DIRECTORY) - string(REGEX REPLACE "^ln -s ([^\" ]+|\"[^\"]+\") mpif.h\n" "" MPI_COMPILE_CMDLINE "${MPI_COMPILE_CMDLINE}") - string(REGEX REPLACE "^ln -s ([^\" ]+|\"[^\"]+\") mpif.h\n" "" MPI_LINK_CMDLINE "${MPI_LINK_CMDLINE}") - string(REGEX REPLACE "\nrm -f mpif.h$" "" MPI_COMPILE_CMDLINE "${MPI_COMPILE_CMDLINE}") - string(REGEX REPLACE "\nrm -f mpif.h$" "" MPI_LINK_CMDLINE "${MPI_LINK_CMDLINE}") - endif() - endif() - - # The Intel MPI wrapper on Linux will emit some objcopy commands after its compile command - # if -static_mpi was passed to the wrapper. To avoid spurious matches, we need to drop these lines. - if(UNIX) - string(REGEX REPLACE "(^|\n)objcopy[^\n]+(\n|$)" "" MPI_COMPILE_CMDLINE "${MPI_COMPILE_CMDLINE}") - string(REGEX REPLACE "(^|\n)objcopy[^\n]+(\n|$)" "" MPI_LINK_CMDLINE "${MPI_LINK_CMDLINE}") - endif() - - # Extract compile options from the compile command line. - string(REGEX MATCHALL "(^| )-f([^\" ]+|\"[^\"]+\")" MPI_ALL_COMPILE_OPTIONS "${MPI_COMPILE_CMDLINE}") - - foreach(_MPI_COMPILE_OPTION IN LISTS MPI_ALL_COMPILE_OPTIONS) - string(REGEX REPLACE "^ " "" _MPI_COMPILE_OPTION "${_MPI_COMPILE_OPTION}") - # Ignore -fstack-protector directives: These occur on MPICH and MVAPICH when the libraries - # themselves were built with this flag. However, this flag is unrelated to using MPI, and - # we won't match the accompanying --param-ssp-size and -Wp,-D_FORTIFY_SOURCE flags and therefore - # produce inconsistent results with the regularly flags. - # Similarly, aliasing flags do not belong into our flag array. - if(NOT "${_MPI_COMPILE_OPTION}" MATCHES "^-f(stack-protector|(no-|)strict-aliasing|PI[CE]|pi[ce])") - list(APPEND MPI_COMPILE_OPTIONS_WORK "${_MPI_COMPILE_OPTION}") - endif() - endforeach() - - # Same deal, with the definitions. We also treat arguments passed to the preprocessor directly. - string(REGEX MATCHALL "(^| )(-Wp,|-Xpreprocessor |)[-/]D([^\" ]+|\"[^\"]+\")" MPI_ALL_COMPILE_DEFINITIONS "${MPI_COMPILE_CMDLINE}") - - foreach(_MPI_COMPILE_DEFINITION IN LISTS MPI_ALL_COMPILE_DEFINITIONS) - string(REGEX REPLACE "^ ?(-Wp,|-Xpreprocessor )?[-/]D" "" _MPI_COMPILE_DEFINITION "${_MPI_COMPILE_DEFINITION}") - string(REPLACE "\"" "" _MPI_COMPILE_DEFINITION "${_MPI_COMPILE_DEFINITION}") - if(NOT "${_MPI_COMPILE_DEFINITION}" MATCHES "^_FORTIFY_SOURCE.*") - list(APPEND MPI_COMPILE_DEFINITIONS_WORK "${_MPI_COMPILE_DEFINITION}") - endif() - endforeach() - - # Extract include paths from compile command line - string(REGEX MATCHALL "(^| )[-/]I([^\" ]+|\"[^\"]+\")" MPI_ALL_INCLUDE_PATHS "${MPI_COMPILE_CMDLINE}") - - # If extracting failed to work, we'll try using -showme:incdirs. - if (NOT MPI_ALL_INCLUDE_PATHS) - _MPI_check_compiler(${LANG} "-showme:incdirs" MPI_INCDIRS_CMDLINE MPI_INCDIRS_COMPILER_RETURN) - if(MPI_INCDIRS_COMPILER_RETURN) - separate_arguments(MPI_ALL_INCLUDE_PATHS NATIVE_COMMAND "${MPI_INCDIRS_CMDLINE}") - endif() - endif() - - foreach(_MPI_INCLUDE_PATH IN LISTS MPI_ALL_INCLUDE_PATHS) - string(REGEX REPLACE "^ ?[-/]I" "" _MPI_INCLUDE_PATH "${_MPI_INCLUDE_PATH}") - string(REPLACE "\"" "" _MPI_INCLUDE_PATH "${_MPI_INCLUDE_PATH}") - get_filename_component(_MPI_INCLUDE_PATH "${_MPI_INCLUDE_PATH}" REALPATH) - list(APPEND MPI_INCLUDE_DIRS_WORK "${_MPI_INCLUDE_PATH}") - endforeach() - - # Extract linker paths from the link command line - string(REGEX MATCHALL "(^| )(-Wl,|-Xlinker |)(-L|[/-]LIBPATH:|[/-]libpath:)([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_PATHS "${MPI_LINK_CMDLINE}") - - # If extracting failed to work, we'll try using -showme:libdirs. - if (NOT MPI_ALL_LINK_PATHS) - _MPI_check_compiler(${LANG} "-showme:libdirs" MPI_LIBDIRS_CMDLINE MPI_LIBDIRS_COMPILER_RETURN) - if(MPI_LIBDIRS_COMPILER_RETURN) - separate_arguments(MPI_ALL_LINK_PATHS NATIVE_COMMAND "${MPI_LIBDIRS_CMDLINE}") - endif() - endif() - - foreach(_MPI_LPATH IN LISTS MPI_ALL_LINK_PATHS) - string(REGEX REPLACE "^ ?(-Wl,|-Xlinker )?(-L|[/-]LIBPATH:|[/-]libpath:)" "" _MPI_LPATH "${_MPI_LPATH}") - string(REPLACE "\"" "" _MPI_LPATH "${_MPI_LPATH}") - get_filename_component(_MPI_LPATH "${_MPI_LPATH}" REALPATH) - list(APPEND MPI_LINK_DIRECTORIES_WORK "${_MPI_LPATH}") - endforeach() - - # Extract linker flags from the link command line - string(REGEX MATCHALL "(^| )(-Wl,|-Xlinker )([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_FLAGS "${MPI_LINK_CMDLINE}") - - foreach(_MPI_LINK_FLAG IN LISTS MPI_ALL_LINK_FLAGS) - string(STRIP "${_MPI_LINK_FLAG}" _MPI_LINK_FLAG) - # MPI might be marked to build with non-executable stacks but this should not propagate. - if (NOT "${_MPI_LINK_FLAG}" MATCHES "(-Wl,|-Xlinker )-z,noexecstack") - if (MPI_LINK_FLAGS_WORK) - string(APPEND MPI_LINK_FLAGS_WORK " ${_MPI_LINK_FLAG}") - else() - set(MPI_LINK_FLAGS_WORK "${_MPI_LINK_FLAG}") - endif() - endif() - endforeach() - - # Extract the set of libraries to link against from the link command - # line - string(REGEX MATCHALL "(^| )-l([^\" ]+|\"[^\"]+\")" MPI_LIBNAMES "${MPI_LINK_CMDLINE}") - - foreach(_MPI_LIB_NAME IN LISTS MPI_LIBNAMES) - string(REGEX REPLACE "^ ?-l" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") - string(REPLACE "\"" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") - get_filename_component(_MPI_LIB_PATH "${_MPI_LIB_NAME}" DIRECTORY) - if(NOT "${_MPI_LIB_PATH}" STREQUAL "") - list(APPEND MPI_LIB_FULLPATHS_WORK "${_MPI_LIB_NAME}") - else() - list(APPEND MPI_LIB_NAMES_WORK "${_MPI_LIB_NAME}") - endif() - endforeach() - - if(WIN32) - # A compiler wrapper on Windows will just have the name of the - # library to link on its link line, potentially with a full path - string(REGEX MATCHALL "(^| )([^\" ]+\\.lib|\"[^\"]+\\.lib\")" MPI_LIBNAMES "${MPI_LINK_CMDLINE}") - foreach(_MPI_LIB_NAME IN LISTS MPI_LIBNAMES) - string(REGEX REPLACE "^ " "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") - string(REPLACE "\"" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") - get_filename_component(_MPI_LIB_PATH "${_MPI_LIB_NAME}" DIRECTORY) - if(NOT "${_MPI_LIB_PATH}" STREQUAL "") - list(APPEND MPI_LIB_FULLPATHS_WORK "${_MPI_LIB_NAME}") - else() - list(APPEND MPI_LIB_NAMES_WORK "${_MPI_LIB_NAME}") - endif() - endforeach() - else() - # On UNIX platforms, archive libraries can be given with full path. - string(REGEX MATCHALL "(^| )([^\" ]+\\.a|\"[^\"]+\\.a\")" MPI_LIBFULLPATHS "${MPI_LINK_CMDLINE}") - foreach(_MPI_LIB_NAME IN LISTS MPI_LIBFULLPATHS) - string(REGEX REPLACE "^ " "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") - string(REPLACE "\"" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") - get_filename_component(_MPI_LIB_PATH "${_MPI_LIB_NAME}" DIRECTORY) - if(NOT "${_MPI_LIB_PATH}" STREQUAL "") - list(APPEND MPI_LIB_FULLPATHS_WORK "${_MPI_LIB_NAME}") - else() - list(APPEND MPI_LIB_NAMES_WORK "${_MPI_LIB_NAME}") - endif() - endforeach() - endif() - - # An MPI compiler wrapper could have its MPI libraries in the implictly - # linked directories of the compiler itself. - if(DEFINED CMAKE_${LANG}_IMPLICIT_LINK_DIRECTORIES) - list(APPEND MPI_LINK_DIRECTORIES_WORK "${CMAKE_${LANG}_IMPLICIT_LINK_DIRECTORIES}") - endif() - - # Determine full path names for all of the libraries that one needs - # to link against in an MPI program - unset(MPI_PLAIN_LIB_NAMES_WORK) - foreach(_MPI_LIB_NAME IN LISTS MPI_LIB_NAMES_WORK) - get_filename_component(_MPI_PLAIN_LIB_NAME "${_MPI_LIB_NAME}" NAME_WE) - list(APPEND MPI_PLAIN_LIB_NAMES_WORK "${_MPI_PLAIN_LIB_NAME}") - find_library(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY - NAMES "${_MPI_LIB_NAME}" "lib${_MPI_LIB_NAME}" - HINTS ${MPI_LINK_DIRECTORIES_WORK} - DOC "Location of the ${_MPI_PLAIN_LIB_NAME} library for MPI" - ) - mark_as_advanced(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY) - endforeach() - - # Deal with the libraries given with full path next - unset(MPI_DIRECT_LIB_NAMES_WORK) - foreach(_MPI_LIB_FULLPATH IN LISTS MPI_LIB_FULLPATHS_WORK) - get_filename_component(_MPI_PLAIN_LIB_NAME "${_MPI_LIB_FULLPATH}" NAME_WE) - get_filename_component(_MPI_LIB_NAME "${_MPI_LIB_FULLPATH}" NAME) - get_filename_component(_MPI_LIB_PATH "${_MPI_LIB_FULLPATH}" DIRECTORY) - list(APPEND MPI_DIRECT_LIB_NAMES_WORK "${_MPI_PLAIN_LIB_NAME}") - find_library(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY - NAMES "${_MPI_LIB_NAME}" - HINTS ${_MPI_LIB_PATH} - DOC "Location of the ${_MPI_PLAIN_LIB_NAME} library for MPI" - ) - mark_as_advanced(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY) - endforeach() - if(MPI_DIRECT_LIB_NAMES_WORK) - set(MPI_PLAIN_LIB_NAMES_WORK "${MPI_DIRECT_LIB_NAMES_WORK};${MPI_PLAIN_LIB_NAMES_WORK}") - endif() - - # MPI might require pthread to work. The above mechanism wouldn't detect it, but we need to - # link it in that case. -lpthread is covered by the normal library treatment on the other hand. - if("${MPI_COMPILE_CMDLINE}" MATCHES "-pthread") - list(APPEND MPI_COMPILE_OPTIONS_WORK "-pthread") - if(MPI_LINK_FLAGS_WORK) - string(APPEND MPI_LINK_FLAGS_WORK " -pthread") - else() - set(MPI_LINK_FLAGS_WORK "-pthread") - endif() - endif() - - # If we found MPI, set up all of the appropriate cache entries - if(NOT MPI_${LANG}_COMPILE_OPTIONS) - set(MPI_${LANG}_COMPILE_OPTIONS ${MPI_COMPILE_OPTIONS_WORK} CACHE STRING "MPI ${LANG} compilation options" FORCE) - endif() - if(NOT MPI_${LANG}_COMPILE_DEFINITIONS) - set(MPI_${LANG}_COMPILE_DEFINITIONS ${MPI_COMPILE_DEFINITIONS_WORK} CACHE STRING "MPI ${LANG} compilation definitions" FORCE) - endif() - if(NOT MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) - set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_INCLUDE_DIRS_WORK} CACHE STRING "MPI ${LANG} additional include directories" FORCE) - endif() - if(NOT MPI_${LANG}_LINK_FLAGS) - set(MPI_${LANG}_LINK_FLAGS ${MPI_LINK_FLAGS_WORK} CACHE STRING "MPI ${LANG} linker flags" FORCE) - endif() - if(NOT MPI_${LANG}_LIB_NAMES) - set(MPI_${LANG}_LIB_NAMES ${MPI_PLAIN_LIB_NAMES_WORK} CACHE STRING "MPI ${LANG} libraries to link against" FORCE) - endif() - set(MPI_${LANG}_WRAPPER_FOUND TRUE PARENT_SCOPE) -endfunction() - -function(_MPI_guess_settings LANG) - set(MPI_GUESS_FOUND FALSE) - # Currently only MSMPI and MPICH2 on Windows are supported, so we can skip this search if we're not targeting that. - if(WIN32) - # MSMPI - - # The environment variables MSMPI_INC and MSMPILIB32/64 are the only ways of locating the MSMPI_SDK, - # which is installed separately from the runtime. Thus it's possible to have mpiexec but not MPI headers - # or import libraries and vice versa. - if(NOT MPI_GUESS_LIBRARY_NAME OR "${MPI_GUESS_LIBRARY_NAME}" STREQUAL "MSMPI") - # We first attempt to locate the msmpi.lib. Should be find it, we'll assume that the MPI present is indeed - # Microsoft MPI. - if("${CMAKE_SIZEOF_VOID_P}" EQUAL 8) - set(MPI_MSMPI_LIB_PATH "$ENV{MSMPI_LIB64}") - set(MPI_MSMPI_INC_PATH_EXTRA "$ENV{MSMPI_INC}/x64") - else() - set(MPI_MSMPI_LIB_PATH "$ENV{MSMPI_LIB32}") - set(MPI_MSMPI_INC_PATH_EXTRA "$ENV{MSMPI_INC}/x86") - endif() - - find_library(MPI_msmpi_LIBRARY - NAMES msmpi - HINTS ${MPI_MSMPI_LIB_PATH} - DOC "Location of the msmpi library for Microsoft MPI") - mark_as_advanced(MPI_msmpi_LIBRARY) - - if(MPI_msmpi_LIBRARY) - # Next, we attempt to locate the MPI header. Note that for Fortran we know that mpif.h is a way - # MSMPI can be used and therefore that header has to be present. - if(NOT MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) - get_filename_component(MPI_MSMPI_INC_DIR "$ENV{MSMPI_INC}" REALPATH) - set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "${MPI_MSMPI_INC_DIR}" CACHE STRING "MPI ${LANG} additional include directories" FORCE) - unset(MPI_MSMPI_INC_DIR) - endif() - - # For MSMPI, one can compile the MPI module by building the mpi.f90 shipped with the MSMPI SDK, - # thus it might be present or provided by the user. Figuring out which is supported is done later on. - # The PGI Fortran compiler for instance ships a prebuilt set of modules in its own include folder. - # Should a user be employing PGI or have built its own set and provided it via cache variables, the - # splitting routine would have located the module files. - - # For C and C++, we're done here (MSMPI does not ship the MPI-2 C++ bindings) - however, for Fortran - # we need some extra library to glue Fortran support together: - # MSMPI ships 2-4 Fortran libraries, each for different Fortran compiler behaviors. The library names - # ending with a c are using the cdecl calling convention, whereas those ending with an s are for Fortran - # implementations using stdcall. Therefore, the 64-bit MSMPI only ships those ending in 'c', whereas the 32-bit - # has both variants available. - # The second difference is the last but one letter, if it's an e(nd), the length of a string argument is - # passed by the Fortran compiler after all other arguments on the parameter list, if it's an m(ixed), - # it's passed immediately after the string address. - - # To summarize: - # - msmpifec: CHARACTER length passed after the parameter list and using cdecl calling convention - # - msmpifmc: CHARACTER length passed directly after string address and using cdecl calling convention - # - msmpifes: CHARACTER length passed after the parameter list and using stdcall calling convention - # - msmpifms: CHARACTER length passed directly after string address and using stdcall calling convention - # 32-bit MSMPI ships all four libraries, 64-bit MSMPI ships only the first two. - - # As is, Intel Fortran and PGI Fortran both use the 'ec' variant of the calling convention, whereas - # the old Compaq Visual Fortran compiler defaulted to the 'ms' version. It's possible to make Intel Fortran - # use the CVF calling convention using /iface:cvf, but we assume - and this is also assumed in FortranCInterface - - # this isn't the case. It's also possible to make CVF use the 'ec' variant, using /iface=(cref,nomixed_str_len_arg). - - # Our strategy is now to locate all libraries, but enter msmpifec into the LIB_NAMES array. - # Should this not be adequate it's a straightforward way for a user to change the LIB_NAMES array and - # have his library found. Still, this should not be necessary outside of exceptional cases, as reasoned. - if ("${LANG}" STREQUAL "Fortran") - set(MPI_MSMPI_CALLINGCONVS c) - if("${CMAKE_SIZEOF_VOID_P}" EQUAL 4) - list(APPEND MPI_MSMPI_CALLINGCONVS s) - endif() - foreach(mpistrlenpos IN ITEMS e m) - foreach(mpicallingconv IN LISTS MPI_MSMPI_CALLINGCONVS) - find_library(MPI_msmpif${mpistrlenpos}${mpicallingconv}_LIBRARY - NAMES msmpif${mpistrlenpos}${mpicallingconv} - HINTS "${MPI_MSMPI_LIB_PATH}" - DOC "Location of the msmpi${mpistrlenpos}${mpicallingconv} library for Microsoft MPI") - mark_as_advanced(MPI_msmpif${mpistrlenpos}${mpicallingconv}_LIBRARY) - endforeach() - endforeach() - if(NOT MPI_${LANG}_LIB_NAMES) - set(MPI_${LANG}_LIB_NAMES "msmpi;msmpifec" CACHE STRING "MPI ${LANG} libraries to link against" FORCE) - endif() - - # At this point we're *not* done. MSMPI requires an additional include file for Fortran giving the value - # of MPI_AINT. This file is called mpifptr.h located in the x64 and x86 subfolders, respectively. - find_path(MPI_mpifptr_INCLUDE_DIR - NAMES "mpifptr.h" - HINTS "${MPI_MSMPI_INC_PATH_EXTRA}" - DOC "Location of the mpifptr.h extra header for Microsoft MPI") - if(NOT MPI_${LANG}_ADDITIONAL_INCLUDE_VARS) - set(MPI_${LANG}_ADDITIONAL_INCLUDE_VARS "mpifptr" CACHE STRING "MPI ${LANG} additional include directory variables, given in the form MPI__INCLUDE_DIR." FORCE) - endif() - mark_as_advanced(MPI_${LANG}_ADDITIONAL_INCLUDE_VARS MPI_mpifptr_INCLUDE_DIR) - else() - if(NOT MPI_${LANG}_LIB_NAMES) - set(MPI_${LANG}_LIB_NAMES "msmpi" CACHE STRING "MPI ${LANG} libraries to link against" FORCE) - endif() - endif() - mark_as_advanced(MPI_${LANG}_LIB_NAMES) - set(MPI_GUESS_FOUND TRUE) - endif() - endif() - - # At this point there's not many MPIs that we could still consider. - # OpenMPI 1.6.x and below supported Windows, but these ship compiler wrappers that still work. - # The only other relevant MPI implementation without a wrapper is MPICH2, which had Windows support in 1.4.1p1 and older. - if(NOT MPI_GUESS_LIBRARY_NAME OR "${MPI_GUESS_LIBRARY_NAME}" STREQUAL "MPICH2") - set(MPI_MPICH_PREFIX_PATHS - "$ENV{ProgramW6432}/MPICH2/lib" - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MPICH\\SMPD;binary]/../lib" - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MPICH2;Path]/lib" - ) - - # All of C, C++ and Fortran will need mpi.lib, so we'll look for this first - find_library(MPI_mpi_LIBRARY - NAMES mpi - HINTS ${MPI_MPICH_PREFIX_PATHS}) - mark_as_advanced(MPI_mpi_LIBRARY) - # If we found mpi.lib, we detect the rest of MPICH2 - if(MPI_mpi_LIBRARY) - set(MPI_MPICH_LIB_NAMES "mpi") - # If MPI-2 C++ bindings are requested, we need to locate cxx.lib as well. - # Otherwise, MPICH_SKIP_MPICXX will be defined and these bindings aren't needed. - if("${LANG}" STREQUAL "CXX" AND NOT MPI_CXX_SKIP_MPICXX) - find_library(MPI_cxx_LIBRARY - NAMES cxx - HINTS ${MPI_MPICH_PREFIX_PATHS}) - mark_as_advanced(MPI_cxx_LIBRARY) - list(APPEND MPI_MPICH_LIB_NAMES "cxx") - # For Fortran, MPICH2 provides three different libraries: - # fmpich2.lib which uses uppercase symbols and cdecl, - # fmpich2s.lib which uses uppercase symbols and stdcall (32-bit only), - # fmpich2g.lib which uses lowercase symbols with double underscores and cdecl. - # fmpich2s.lib would be useful for Compaq Visual Fortran, fmpich2g.lib has to be used with GNU g77 and is also - # provided in the form of an .a archive for MinGW and Cygwin. From our perspective, fmpich2.lib is the only one - # we need to try, and if it doesn't work with the given Fortran compiler we'd find out later on during validation - elseif("${LANG}" STREQUAL "Fortran") - find_library(MPI_fmpich2_LIBRARY - NAMES fmpich2 - HINTS ${MPI_MPICH_PREFIX_PATHS}) - find_library(MPI_fmpich2s_LIBRARY - NAMES fmpich2s - HINTS ${MPI_MPICH_PREFIX_PATHS}) - find_library(MPI_fmpich2g_LIBRARY - NAMES fmpich2g - HINTS ${MPI_MPICH_PREFIX_PATHS}) - mark_as_advanced(MPI_fmpich2_LIBRARY MPI_fmpich2s_LIBRARY MPI_fmpich2g_LIBRARY) - list(APPEND MPI_MPICH_LIB_NAMES "fmpich2") - endif() - - if(NOT MPI_${LANG}_LIB_NAMES) - set(MPI_${LANG}_LIB_NAMES "${MPI_MPICH_LIB_NAMES}" CACHE STRING "MPI ${LANG} libraries to link against" FORCE) - endif() - unset(MPI_MPICH_LIB_NAMES) - - if(NOT MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) - # For MPICH2, the include folder would be in ../include relative to the library folder. - get_filename_component(MPI_MPICH_ROOT_DIR "${MPI_mpi_LIBRARY}" DIRECTORY) - get_filename_component(MPI_MPICH_ROOT_DIR "${MPI_MPICH_ROOT_DIR}" DIRECTORY) - if(IS_DIRECTORY "${MPI_MPICH_ROOT_DIR}/include") - set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "${MPI_MPICH_ROOT_DIR}/include" CACHE STRING "MPI ${LANG} additional include directory variables, given in the form MPI__INCLUDE_DIR." FORCE) - endif() - unset(MPI_MPICH_ROOT_DIR) - endif() - set(MPI_GUESS_FOUND TRUE) - endif() - unset(MPI_MPICH_PREFIX_PATHS) - endif() - endif() - set(MPI_${LANG}_GUESS_FOUND "${MPI_GUESS_FOUND}" PARENT_SCOPE) -endfunction() - -function(_MPI_adjust_compile_definitions LANG) - if("${LANG}" STREQUAL "CXX") - # To disable the C++ bindings, we need to pass some definitions since the mpi.h header has to deal with both C and C++ - # bindings in MPI-2. - if(MPI_CXX_SKIP_MPICXX AND NOT MPI_${LANG}_COMPILE_DEFINITIONS MATCHES "SKIP_MPICXX") - # MPICH_SKIP_MPICXX is being used in MPICH and derivatives like MVAPICH or Intel MPI - # OMPI_SKIP_MPICXX is being used in Open MPI - # _MPICC_H is being used for IBM Platform MPI - list(APPEND MPI_${LANG}_COMPILE_DEFINITIONS "MPICH_SKIP_MPICXX" "OMPI_SKIP_MPICXX" "_MPICC_H") - set(MPI_${LANG}_COMPILE_DEFINITIONS "${MPI_${LANG}_COMPILE_DEFINITIONS}" CACHE STRING "MPI ${LANG} compilation definitions" FORCE) - endif() - endif() -endfunction() - -macro(_MPI_assemble_libraries LANG) - set(MPI_${LANG}_LIBRARIES "") - foreach(mpilib IN LISTS MPI_${LANG}_LIB_NAMES) - list(APPEND MPI_${LANG}_LIBRARIES ${MPI_${mpilib}_LIBRARY}) - endforeach() -endmacro() - -macro(_MPI_assemble_include_dirs LANG) - set(MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS}") - if("${LANG}" MATCHES "(C|CXX)") - if(MPI_${LANG}_HEADER_DIR) - list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_HEADER_DIR}") - endif() - else() # Fortran - if(MPI_${LANG}_F77_HEADER_DIR) - list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_F77_HEADER_DIR}") - endif() - if(MPI_${LANG}_MODULE_DIR AND NOT "${MPI_${LANG}_MODULE_DIR}" IN_LIST MPI_${LANG}_INCLUDE_DIRS) - list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_MODULE_DIR}") - endif() - endif() - if(MPI_${LANG}_ADDITIONAL_INCLUDE_VARS) - foreach(mpiadditionalinclude IN LISTS MPI_${LANG}_ADDITIONAL_INCLUDE_VARS) - list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${mpiadditionalinclude}_INCLUDE_DIR}") - endforeach() - endif() -endmacro() - -function(_MPI_split_include_dirs LANG) - # Backwards compatibility: Search INCLUDE_PATH if given. - if(MPI_${LANG}_INCLUDE_PATH) - list(APPEND MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "${MPI_${LANG}_INCLUDE_PATH}") - endif() - - # We try to find the headers/modules among those paths (and system paths) - # For C/C++, we just need to have a look for mpi.h. - if("${LANG}" MATCHES "(C|CXX)") - find_path(MPI_${LANG}_HEADER_DIR "mpi.h" - HINTS ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS} - ) - mark_as_advanced(MPI_${LANG}_HEADER_DIR) - if(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) - list(REMOVE_ITEM MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "${MPI_${LANG}_HEADER_DIR}") - endif() - # Fortran is more complicated here: An implementation could provide - # any of the Fortran 77/90/2008 APIs for MPI. For example, MSMPI - # only provides Fortran 77 and - if mpi.f90 is built - potentially - # a Fortran 90 module. - elseif("${LANG}" STREQUAL "Fortran") - find_path(MPI_${LANG}_F77_HEADER_DIR "mpif.h" - HINTS ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS} - ) - find_path(MPI_${LANG}_MODULE_DIR - NAMES "mpi.mod" "mpi_f08.mod" - HINTS ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS} - ) - if(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) - list(REMOVE_ITEM MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS - "${MPI_${LANG}_F77_HEADER_DIR}" - "${MPI_${LANG}_MODULE_DIR}" - ) - endif() - mark_as_advanced(MPI_${LANG}_F77_HEADER_DIR MPI_${LANG}_MODULE_DIR) - endif() - set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS} CACHE STRING "MPI ${LANG} additional include directories" FORCE) -endfunction() - -macro(_MPI_create_imported_target LANG) - if(NOT TARGET MPI::MPI_${LANG}) - add_library(MPI::MPI_${LANG} INTERFACE IMPORTED) - endif() - - set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_COMPILE_OPTIONS "${MPI_${LANG}_COMPILE_OPTIONS}") - set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_COMPILE_DEFINITIONS "${MPI_${LANG}_COMPILE_DEFINITIONS}") - - set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_LINK_LIBRARIES "") - if(MPI_${LANG}_LINK_FLAGS) - set_property(TARGET MPI::MPI_${LANG} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${MPI_${LANG}_LINK_FLAGS}") - endif() - # If the compiler links MPI implicitly, no libraries will be found as they're contained within - # CMAKE__IMPLICIT_LINK_LIBRARIES already. - if(MPI_${LANG}_LIBRARIES) - set_property(TARGET MPI::MPI_${LANG} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${MPI_${LANG}_LIBRARIES}") - endif() - # Given the new design of FindMPI, INCLUDE_DIRS will always be located, even under implicit linking. - set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${MPI_${LANG}_INCLUDE_DIRS}") -endmacro() - -function(_MPI_try_staged_settings LANG MPI_TEST_FILE_NAME MODE RUN_BINARY) - set(WORK_DIR "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindMPI") - set(SRC_DIR "${CMAKE_ROOT}/Modules/FindMPI") - set(BIN_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindMPI/${MPI_TEST_FILE_NAME}_${LANG}.bin") - unset(MPI_TEST_COMPILE_DEFINITIONS) - if("${LANG}" STREQUAL "Fortran") - if("${MODE}" STREQUAL "F90_MODULE") - set(MPI_Fortran_INCLUDE_LINE "use mpi\n implicit none") - elseif("${MODE}" STREQUAL "F08_MODULE") - set(MPI_Fortran_INCLUDE_LINE "use mpi_f08\n implicit none") - else() # F77 header - set(MPI_Fortran_INCLUDE_LINE "implicit none\n include 'mpif.h'") - endif() - configure_file("${SRC_DIR}/${MPI_TEST_FILE_NAME}.f90.in" "${WORK_DIR}/${MPI_TEST_FILE_NAME}.f90" @ONLY) - set(MPI_TEST_SOURCE_FILE "${WORK_DIR}/${MPI_TEST_FILE_NAME}.f90") - elseif("${LANG}" STREQUAL "CXX") - configure_file("${SRC_DIR}/${MPI_TEST_FILE_NAME}.c" "${WORK_DIR}/${MPI_TEST_FILE_NAME}.cpp" COPYONLY) - set(MPI_TEST_SOURCE_FILE "${WORK_DIR}/${MPI_TEST_FILE_NAME}.cpp") - if("${MODE}" STREQUAL "TEST_MPICXX") - set(MPI_TEST_COMPILE_DEFINITIONS TEST_MPI_MPICXX) - endif() - else() # C - set(MPI_TEST_SOURCE_FILE "${SRC_DIR}/${MPI_TEST_FILE_NAME}.c") - endif() - if(RUN_BINARY) - try_run(MPI_RUN_RESULT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} MPI_RESULT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} - "${CMAKE_BINARY_DIR}" SOURCES "${MPI_TEST_SOURCE_FILE}" - COMPILE_DEFINITIONS ${MPI_TEST_COMPILE_DEFINITIONS} - LINK_LIBRARIES MPI::MPI_${LANG} - RUN_OUTPUT_VARIABLE MPI_RUN_OUTPUT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE}) - set(MPI_RUN_OUTPUT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} "${MPI_RUN_OUTPUT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE}}" PARENT_SCOPE) - else() - try_compile(MPI_RESULT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} - "${CMAKE_BINARY_DIR}" SOURCES "${MPI_TEST_SOURCE_FILE}" - COMPILE_DEFINITIONS ${MPI_TEST_COMPILE_DEFINITIONS} - LINK_LIBRARIES MPI::MPI_${LANG} - COPY_FILE "${BIN_FILE}") - endif() -endfunction() - -macro(_MPI_check_lang_works LANG) - # For Fortran we may have by the MPI-3 standard an implementation that provides: - # - the mpi_f08 module - # - *both*, the mpi module and 'mpif.h' - # Since older MPI standards (MPI-1) did not define anything but 'mpif.h', we need to check all three individually. - if( NOT MPI_${LANG}_WORKS ) - if("${LANG}" STREQUAL "Fortran") - set(MPI_Fortran_INTEGER_LINE "(kind=MPI_INTEGER_KIND)") - _MPI_try_staged_settings(${LANG} test_mpi F77_HEADER FALSE) - _MPI_try_staged_settings(${LANG} test_mpi F90_MODULE FALSE) - _MPI_try_staged_settings(${LANG} test_mpi F08_MODULE FALSE) - - set(MPI_${LANG}_WORKS FALSE) - - foreach(mpimethod IN ITEMS F77_HEADER F08_MODULE F90_MODULE) - if(MPI_RESULT_${LANG}_test_mpi_${mpimethod}) - set(MPI_${LANG}_WORKS TRUE) - set(MPI_${LANG}_HAVE_${mpimethod} TRUE) - else() - set(MPI_${LANG}_HAVE_${mpimethod} FALSE) - endif() - endforeach() - # MPI-1 versions had no MPI_INTGER_KIND defined, so we need to try without it. - # However, MPI-1 also did not define the Fortran 90 and 08 modules, so we only try the F77 header. - unset(MPI_Fortran_INTEGER_LINE) - if(NOT MPI_${LANG}_WORKS) - _MPI_try_staged_settings(${LANG} test_mpi F77_HEADER_NOKIND FALSE) - if(MPI_RESULT_${LANG}_test_mpi_F77_HEADER_NOKIND) - set(MPI_${LANG}_WORKS TRUE) - set(MPI_${LANG}_HAVE_F77_HEADER TRUE) - endif() - endif() - else() - _MPI_try_staged_settings(${LANG} test_mpi normal FALSE) - # If 'test_mpi' built correctly, we've found valid MPI settings. There might not be MPI-2 C++ support, but there can't - # be MPI-2 C++ support without the C bindings being present, so checking for them is sufficient. - set(MPI_${LANG}_WORKS "${MPI_RESULT_${LANG}_test_mpi_normal}") - endif() - endif() -endmacro() - -# Some systems install various MPI implementations in separate folders in some MPI prefix -# This macro enumerates all such subfolders and adds them to the list of hints that will be searched. -macro(MPI_search_mpi_prefix_folder PREFIX_FOLDER) - if(EXISTS "${PREFIX_FOLDER}") - file(GLOB _MPI_folder_children RELATIVE "${PREFIX_FOLDER}" "${PREFIX_FOLDER}/*") - foreach(_MPI_folder_child IN LISTS _MPI_folder_children) - if(IS_DIRECTORY "${PREFIX_FOLDER}/${_MPI_folder_child}") - list(APPEND MPI_HINT_DIRS "${PREFIX_FOLDER}/${_MPI_folder_child}") - endif() - endforeach() - endif() -endmacro() - -set(MPI_HINT_DIRS ${MPI_HOME} $ENV{MPI_HOME} $ENV{I_MPI_ROOT}) -if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Linux") - # SUSE Linux Enterprise Server stores its MPI implementations under /usr/lib64/mpi/gcc/ - # We enumerate the subfolders and append each as a prefix - MPI_search_mpi_prefix_folder("/usr/lib64/mpi/gcc") -elseif("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows") - # MSMPI stores its runtime in a special folder, this adds the possible locations to the hints. - list(APPEND MPI_HINT_DIRS $ENV{MSMPI_BIN} "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MPI;InstallRoot]") -elseif("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "FreeBSD") - # FreeBSD ships mpich under the normal system paths - but available openmpi implementations - # will be found in /usr/local/mpi/ - MPI_search_mpi_prefix_folder("/usr/local/mpi/") -endif() - -# Most MPI distributions have some form of mpiexec or mpirun which gives us something we can look for. -# The MPI standard does not mandate the existence of either, but instead only makes requirements if a distribution -# ships an mpiexec program (mpirun executables are not regulated by the standard). -find_program(MPIEXEC_EXECUTABLE - NAMES ${_MPIEXEC_NAMES} - PATH_SUFFIXES bin sbin - HINTS ${MPI_HINT_DIRS} - DOC "Executable for running MPI programs.") - -# call get_filename_component twice to remove mpiexec and the directory it exists in (typically bin). -# This gives us a fairly reliable base directory to search for /bin /lib and /include from. -get_filename_component(_MPI_BASE_DIR "${MPIEXEC_EXECUTABLE}" PATH) -get_filename_component(_MPI_BASE_DIR "${_MPI_BASE_DIR}" PATH) - -# According to the MPI standard, section 8.8 -n is a guaranteed, and the only guaranteed way to -# launch an MPI process using mpiexec if such a program exists. -set(MPIEXEC_NUMPROC_FLAG "-n" CACHE STRING "Flag used by MPI to specify the number of processes for mpiexec; the next option will be the number of processes.") -set(MPIEXEC_PREFLAGS "" CACHE STRING "These flags will be directly before the executable that is being run by mpiexec.") -set(MPIEXEC_POSTFLAGS "" CACHE STRING "These flags will be placed after all flags passed to mpiexec.") - -# Set the number of processes to the physical processor count -cmake_host_system_information(RESULT _MPIEXEC_NUMPROCS QUERY NUMBER_OF_PHYSICAL_CORES) -set(MPIEXEC_MAX_NUMPROCS "${_MPIEXEC_NUMPROCS}" CACHE STRING "Maximum number of processors available to run MPI applications.") -unset(_MPIEXEC_NUMPROCS) -mark_as_advanced(MPIEXEC_EXECUTABLE MPIEXEC_NUMPROC_FLAG MPIEXEC_PREFLAGS MPIEXEC_POSTFLAGS MPIEXEC_MAX_NUMPROCS) - -#============================================================================= -# Backward compatibility input hacks. Propagate the FindMPI hints to C and -# CXX if the respective new versions are not defined. Translate the old -# MPI_LIBRARY and MPI_EXTRA_LIBRARY to respective MPI_${LANG}_LIBRARIES. -# -# Once we find the new variables, we translate them back into their old -# equivalents below. -foreach (LANG IN ITEMS C CXX) - # Old input variables. - set(_MPI_OLD_INPUT_VARS COMPILER COMPILE_FLAGS INCLUDE_PATH LINK_FLAGS) - - # Set new vars based on their old equivalents, if the new versions are not already set. - foreach (var ${_MPI_OLD_INPUT_VARS}) - if (NOT MPI_${LANG}_${var} AND MPI_${var}) - set(MPI_${LANG}_${var} "${MPI_${var}}") - endif() - endforeach() - - # Chop the old compile flags into options and definitions - if(MPI_${LANG}_COMPILE_FLAGS) - unset(MPI_${LANG}_COMPILE_OPTIONS) - unset(MPI_${LANG}_COMPILE_DEFINITIONS) - separate_arguments(MPI_SEPARATE_FLAGS NATIVE_COMMAND "${MPI_${LANG}_COMPILE_FLAGS}") - foreach(_MPI_FLAG IN LISTS MPI_SEPARATE_FLAGS) - if("${_MPI_FLAG}" MATCHES "^ *[-/D]([^ ]+)") - list(APPEND MPI_${LANG}_COMPILE_DEFINITIONS "${CMAKE_MATCH_1}") - else() - list(APPEND MPI_${LANG}_COMPILE_FLAGS "${_MPI_FLAG}") - endif() - endforeach() - unset(MPI_SEPARATE_FLAGS) - endif() - - # If a list of libraries was given, we'll split it into new-style cache variables - if(NOT MPI_${LANG}_LIB_NAMES) - foreach(_MPI_LIB IN LISTS MPI_${LANG}_LIBRARIES MPI_LIBRARY MPI_EXTRA_LIBRARY) - get_filename_component(_MPI_PLAIN_LIB_NAME "${_MPI_LIB}" NAME_WE) - get_filename_component(_MPI_LIB_NAME "${_MPI_LIB}" NAME) - get_filename_component(_MPI_LIB_DIR "${_MPI_LIB}" DIRECTORY) - list(APPEND MPI_PLAIN_LIB_NAMES_WORK "${_MPI_PLAIN_LIB_NAME}") - find_library(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY - NAMES "${_MPI_LIB_NAME}" "lib${_MPI_LIB_NAME}" - HINTS ${_MPI_LIB_DIR} $ENV{MPI_LIB} - DOC "Location of the ${_MPI_PLAIN_LIB_NAME} library for MPI" - ) - mark_as_advanced(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY) - endforeach() - endif() -endforeach() -#============================================================================= - -unset(MPI_VERSION) -unset(MPI_VERSION_MAJOR) -unset(MPI_VERSION_MINOR) - -unset(_MPI_MIN_VERSION) - -# This loop finds the compilers and sends them off for interrogation. -foreach(LANG IN ITEMS C CXX Fortran) - if(CMAKE_${LANG}_COMPILER_LOADED) - if(NOT MPI_FIND_COMPONENTS) - set(_MPI_FIND_${LANG} TRUE) - elseif( ${LANG} IN_LIST MPI_FIND_COMPONENTS) - set(_MPI_FIND_${LANG} TRUE) - elseif( ${LANG} STREQUAL CXX AND NOT MPI_CXX_SKIP_MPICXX AND MPICXX IN_LIST MPI_FIND_COMPONENTS ) - set(_MPI_FIND_${LANG} TRUE) - else() - set(_MPI_FIND_${LANG} FALSE) - endif() - else() - set(_MPI_FIND_${LANG} FALSE) - endif() - if(_MPI_FIND_${LANG}) - if( ${LANG} STREQUAL CXX AND NOT MPICXX IN_LIST MPI_FIND_COMPONENTS ) - set(MPI_CXX_SKIP_MPICXX FALSE CACHE BOOL "If true, the MPI-2 C++ bindings are disabled using definitions.") - mark_as_advanced(MPI_CXX_SKIP_MPICXX) - endif() - if(NOT (MPI_${LANG}_LIB_NAMES AND (MPI_${LANG}_INCLUDE_PATH OR MPI_${LANG}_INCLUDE_DIRS OR MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS))) - if(NOT MPI_${LANG}_COMPILER AND NOT MPI_ASSUME_NO_BUILTIN_MPI) - # Should the imported targets be empty, we effectively try whether the compiler supports MPI on its own, which is the case on e.g. - # Cray PrgEnv. - _MPI_create_imported_target(${LANG}) - _MPI_check_lang_works(${LANG}) - - # If the compiler can build MPI code on its own, it functions as an MPI compiler and we'll set the variable to point to it. - if(MPI_${LANG}_WORKS) - set(MPI_${LANG}_COMPILER "${CMAKE_${LANG}_COMPILER}" CACHE FILEPATH "MPI compiler for ${LANG}" FORCE) - endif() - endif() - - # If the user specified a library name we assume they prefer that library over a wrapper. If not, they can disable skipping manually. - if(NOT DEFINED MPI_SKIP_COMPILER_WRAPPER AND MPI_GUESS_LIBRARY_NAME) - set(MPI_SKIP_COMPILER_WRAPPER TRUE) - endif() - if(NOT MPI_SKIP_COMPILER_WRAPPER) - if(MPI_${LANG}_COMPILER) - # If the user supplies a compiler *name* instead of an absolute path, assume that we need to find THAT compiler. - if (NOT IS_ABSOLUTE "${MPI_${LANG}_COMPILER}") - # Get rid of our default list of names and just search for the name the user wants. - set(_MPI_${LANG}_COMPILER_NAMES "${MPI_${LANG}_COMPILER}") - unset(MPI_${LANG}_COMPILER CACHE) - endif() - # If the user specifies a compiler, we don't want to try to search libraries either. - set(MPI_PINNED_COMPILER TRUE) - else() - set(MPI_PINNED_COMPILER FALSE) - endif() - - # If we have an MPI base directory, we'll try all compiler names in that one first. - # This should prevent mixing different MPI environments - if(_MPI_BASE_DIR) - find_program(MPI_${LANG}_COMPILER - NAMES ${_MPI_${LANG}_COMPILER_NAMES} - PATH_SUFFIXES bin sbin - HINTS ${_MPI_BASE_DIR} - NO_DEFAULT_PATH - DOC "MPI compiler for ${LANG}" - ) - endif() - - # If the base directory did not help (for example because the mpiexec isn't in the same directory as the compilers), - # we shall try searching in the default paths. - find_program(MPI_${LANG}_COMPILER - NAMES ${_MPI_${LANG}_COMPILER_NAMES} - PATH_SUFFIXES bin sbin - DOC "MPI compiler for ${LANG}" - ) - - if(MPI_${LANG}_COMPILER STREQUAL CMAKE_${LANG}_COMPILER) - set(MPI_SKIP_GUESSING TRUE) - elseif(MPI_${LANG}_COMPILER) - _MPI_interrogate_compiler(${LANG}) - else() - set(MPI_${LANG}_WRAPPER_FOUND FALSE) - endif() - else() - set(MPI_${LANG}_WRAPPER_FOUND FALSE) - set(MPI_PINNED_COMPILER FALSE) - endif() - - if(NOT MPI_${LANG}_WRAPPER_FOUND AND NOT MPI_PINNED_COMPILER) - # For C++, we may use the settings for C. Should a given compiler wrapper for C++ not exist, but one for C does, we copy over the - # settings for C. An MPI distribution that is in this situation would be IBM Platform MPI. - if("${LANG}" STREQUAL "CXX" AND MPI_C_WRAPPER_FOUND) - set(MPI_${LANG}_COMPILE_OPTIONS ${MPI_C_COMPILE_OPTIONS} CACHE STRING "MPI ${LANG} compilation options" ) - set(MPI_${LANG}_COMPILE_DEFINITIONS ${MPI_C_COMPILE_DEFINITIONS} CACHE STRING "MPI ${LANG} compilation definitions" ) - set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_C_INCLUDE_DIRS} CACHE STRING "MPI ${LANG} additional include directories") - set(MPI_${LANG}_LINK_FLAGS ${MPI_C_LINK_FLAGS} CACHE STRING "MPI ${LANG} linker flags" ) - set(MPI_${LANG}_LIB_NAMES ${MPI_C_LIB_NAMES} CACHE STRING "MPI ${LANG} libraries to link against" ) - set(MPI_${LANG}_WRAPPER_FOUND TRUE) - elseif(NOT MPI_SKIP_GUESSING) - _MPI_guess_settings(${LANG}) - endif() - endif() - endif() - - _MPI_split_include_dirs(${LANG}) - if(NOT MPI_${LANG}_COMPILER STREQUAL CMAKE_${LANG}_COMPILER) - _MPI_assemble_include_dirs(${LANG}) - _MPI_assemble_libraries(${LANG}) - endif() - _MPI_adjust_compile_definitions(${LANG}) - # We always create imported targets even if they're empty - _MPI_create_imported_target(${LANG}) - - if(NOT MPI_${LANG}_WORKS) - _MPI_check_lang_works(${LANG}) - endif() - - # Next, we'll initialize the MPI variables that have not been previously set. - set(MPI_${LANG}_COMPILE_OPTIONS "" CACHE STRING "MPI ${LANG} compilation flags" ) - set(MPI_${LANG}_COMPILE_DEFINITIONS "" CACHE STRING "MPI ${LANG} compilation definitions" ) - set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "" CACHE STRING "MPI ${LANG} additional include directories") - set(MPI_${LANG}_LINK_FLAGS "" CACHE STRING "MPI ${LANG} linker flags" ) - set(MPI_${LANG}_LIB_NAMES "" CACHE STRING "MPI ${LANG} libraries to link against" ) - mark_as_advanced(MPI_${LANG}_COMPILE_OPTIONS MPI_${LANG}_COMPILE_DEFINITIONS MPI_${LANG}_LINK_FLAGS - MPI_${LANG}_LIB_NAMES MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS MPI_${LANG}_COMPILER) - - # If we've found MPI, then we'll perform additional analysis: Determine the MPI version, MPI library version, supported - # MPI APIs (i.e. MPI-2 C++ bindings). For Fortran we also need to find specific parameters if we're under MPI-3. - if(MPI_${LANG}_WORKS) - if("${LANG}" STREQUAL "CXX" AND NOT DEFINED MPI_MPICXX_FOUND) - if(NOT MPI_CXX_SKIP_MPICXX AND NOT MPI_CXX_VALIDATE_SKIP_MPICXX) - _MPI_try_staged_settings(${LANG} test_mpi MPICXX FALSE) - if(MPI_RESULT_${LANG}_test_mpi_MPICXX) - set(MPI_MPICXX_FOUND TRUE) - else() - set(MPI_MPICXX_FOUND FALSE) - endif() - else() - set(MPI_MPICXX_FOUND FALSE) - endif() - endif() - - # At this point, we know the bindings present but not the MPI version or anything else. - if(NOT DEFINED MPI_${LANG}_VERSION) - unset(MPI_${LANG}_VERSION_MAJOR) - unset(MPI_${LANG}_VERSION_MINOR) - endif() - set(MPI_BIN_FOLDER ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindMPI) - - # For Fortran, we'll want to use the most modern MPI binding to test capabilities other than the - # Fortran parameters, since those depend on the method of consumption. - # For C++, we can always use the C bindings, and should do so, since the C++ bindings do not exist in MPI-3 - # whereas the C bindings do, and the C++ bindings never offered any feature advantage over their C counterparts. - if("${LANG}" STREQUAL "Fortran") - if(MPI_${LANG}_HAVE_F08_MODULE) - set(MPI_${LANG}_HIGHEST_METHOD F08_MODULE) - elseif(MPI_${LANG}_HAVE_F90_MODULE) - set(MPI_${LANG}_HIGHEST_METHOD F90_MODULE) - else() - set(MPI_${LANG}_HIGHEST_METHOD F77_HEADER) - endif() - - # Another difference between C and Fortran is that we can't use the preprocessor to determine whether MPI_VERSION - # and MPI_SUBVERSION are provided. These defines did not exist in MPI 1.0 and 1.1 and therefore might not - # exist. For C/C++, test_mpi.c will handle the MPI_VERSION extraction, but for Fortran, we need mpiver.f90. - if(NOT DEFINED MPI_${LANG}_VERSION) - _MPI_try_staged_settings(${LANG} mpiver ${MPI_${LANG}_HIGHEST_METHOD} FALSE) - if(MPI_RESULT_${LANG}_mpiver_${MPI_${LANG}_HIGHEST_METHOD}) - file(STRINGS ${MPI_BIN_FOLDER}/mpiver_${LANG}.bin _MPI_VERSION_STRING LIMIT_COUNT 1 REGEX "INFO:MPI-VER") - if("${_MPI_VERSION_STRING}" MATCHES ".*INFO:MPI-VER\\[([0-9]+)\\.([0-9]+)\\].*") - set(MPI_${LANG}_VERSION_MAJOR "${CMAKE_MATCH_1}") - set(MPI_${LANG}_VERSION_MINOR "${CMAKE_MATCH_2}") - set(MPI_${LANG}_VERSION "${MPI_${LANG}_VERSION_MAJOR}.${MPI_${LANG}_VERSION_MINOR}") - endif() - endif() - endif() - - # Finally, we want to find out which capabilities a given interface supports, compare the MPI-3 standard. - # This is determined by interface specific parameters MPI_SUBARRAYS_SUPPORTED and MPI_ASYNC_PROTECTS_NONBLOCKING - # and might vary between the different methods of consumption. - if(MPI_DETERMINE_Fortran_CAPABILITIES AND NOT MPI_Fortran_CAPABILITIES_DETERMINED) - foreach(mpimethod IN ITEMS F08_MODULE F90_MODULE F77_HEADER) - if(MPI_${LANG}_HAVE_${mpimethod}) - set(MPI_${LANG}_${mpimethod}_SUBARRAYS FALSE) - set(MPI_${LANG}_${mpimethod}_ASYNCPROT FALSE) - _MPI_try_staged_settings(${LANG} fortranparam_mpi ${mpimethod} TRUE) - if(MPI_RESULT_${LANG}_fortranparam_mpi_${mpimethod} AND - NOT "${MPI_RUN_RESULT_${LANG}_fortranparam_mpi_${mpimethod}}" STREQUAL "FAILED_TO_RUN") - if("${MPI_RUN_OUTPUT_${LANG}_fortranparam_mpi_${mpimethod}}" MATCHES - ".*INFO:SUBARRAYS\\[ *([TF]) *\\]-ASYNCPROT\\[ *([TF]) *\\].*") - if("${CMAKE_MATCH_1}" STREQUAL "T") - set(MPI_${LANG}_${mpimethod}_SUBARRAYS TRUE) - endif() - if("${CMAKE_MATCH_2}" STREQUAL "T") - set(MPI_${LANG}_${mpimethod}_ASYNCPROT TRUE) - endif() - endif() - endif() - endif() - endforeach() - set(MPI_Fortran_CAPABILITIES_DETERMINED TRUE) - endif() - else() - set(MPI_${LANG}_HIGHEST_METHOD normal) - - # By the MPI-2 standard, MPI_VERSION and MPI_SUBVERSION are valid for both C and C++ bindings. - if(NOT DEFINED MPI_${LANG}_VERSION) - file(STRINGS ${MPI_BIN_FOLDER}/test_mpi_${LANG}.bin _MPI_VERSION_STRING LIMIT_COUNT 1 REGEX "INFO:MPI-VER") - if("${_MPI_VERSION_STRING}" MATCHES ".*INFO:MPI-VER\\[([0-9]+)\\.([0-9]+)\\].*") - set(MPI_${LANG}_VERSION_MAJOR "${CMAKE_MATCH_1}") - set(MPI_${LANG}_VERSION_MINOR "${CMAKE_MATCH_2}") - set(MPI_${LANG}_VERSION "${MPI_${LANG}_VERSION_MAJOR}.${MPI_${LANG}_VERSION_MINOR}") - endif() - endif() - endif() - - unset(MPI_BIN_FOLDER) - - # At this point, we have dealt with determining the MPI version and parameters for each Fortran method available. - # The one remaining issue is to determine which MPI library is installed. - # Determining the version and vendor of the MPI library is only possible via MPI_Get_library_version() at runtime, - # and therefore we cannot do this while cross-compiling (a user may still define MPI__LIBRARY_VERSION_STRING - # themselves and we'll attempt splitting it, which is equivalent to provide the try_run output). - # It's also worth noting that the installed version string can depend on the language, or on the system the binary - # runs on if MPI is not statically linked. - if(MPI_DETERMINE_LIBRARY_VERSION AND NOT MPI_${LANG}_LIBRARY_VERSION_STRING) - _MPI_try_staged_settings(${LANG} libver_mpi ${MPI_${LANG}_HIGHEST_METHOD} TRUE) - if(MPI_RESULT_${LANG}_libver_mpi_${MPI_${LANG}_HIGHEST_METHOD} AND - "${MPI_RUN_RESULT_${LANG}_libver_mpi_${MPI_${LANG}_HIGHEST_METHOD}}" EQUAL "0") - string(STRIP "${MPI_RUN_OUTPUT_${LANG}_libver_mpi_${MPI_${LANG}_HIGHEST_METHOD}}" - MPI_${LANG}_LIBRARY_VERSION_STRING) - else() - set(MPI_${LANG}_LIBRARY_VERSION_STRING "NOTFOUND") - endif() - endif() - endif() - - set(MPI_${LANG}_FIND_QUIETLY ${MPI_FIND_QUIETLY}) - set(MPI_${LANG}_FIND_VERSION ${MPI_FIND_VERSION}) - set(MPI_${LANG}_FIND_VERSION_EXACT ${MPI_FIND_VERSION_EXACT}) - - unset(MPI_${LANG}_REQUIRED_VARS) - if (MPI_${LANG}_WRAPPER_FOUND OR MPI_${LANG}_GUESS_FOUND) - foreach(mpilibname IN LISTS MPI_${LANG}_LIB_NAMES) - list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${mpilibname}_LIBRARY") - endforeach() - list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_LIB_NAMES") - if("${LANG}" STREQUAL "Fortran") - # For Fortran we only need one of the module or header directories to have *some* support for MPI. - if(NOT MPI_${LANG}_MODULE_DIR) - list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_F77_HEADER_DIR") - endif() - if(NOT MPI_${LANG}_F77_HEADER_DIR) - list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_MODULE_DIR") - endif() - else() - list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_HEADER_DIR") - endif() - if(MPI_${LANG}_ADDITIONAL_INCLUDE_VARS) - foreach(mpiincvar IN LISTS MPI_${LANG}_ADDITIONAL_INCLUDE_VARS) - list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${mpiincvar}_INCLUDE_DIR") - endforeach() - endif() - # Append the works variable now. If the settings did not work, this will show up properly. - list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_WORKS") - else() - # If the compiler worked implicitly, use its path as output. - # Should the compiler variable be set, we also require it to work. - list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_COMPILER") - if(MPI_${LANG}_COMPILER) - list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_WORKS") - endif() - endif() - find_package_handle_standard_args(MPI_${LANG} REQUIRED_VARS ${MPI_${LANG}_REQUIRED_VARS} - VERSION_VAR MPI_${LANG}_VERSION) - - if(DEFINED MPI_${LANG}_VERSION) - if(NOT _MPI_MIN_VERSION OR _MPI_MIN_VERSION VERSION_GREATER MPI_${LANG}_VERSION) - set(_MPI_MIN_VERSION MPI_${LANG}_VERSION) - endif() - endif() - endif() -endforeach() - -unset(_MPI_REQ_VARS) -foreach(LANG IN ITEMS C CXX Fortran) - if((NOT MPI_FIND_COMPONENTS AND CMAKE_${LANG}_COMPILER_LOADED) OR LANG IN_LIST MPI_FIND_COMPONENTS) - list(APPEND _MPI_REQ_VARS "MPI_${LANG}_FOUND") - endif() -endforeach() - -if(MPICXX IN_LIST MPI_FIND_COMPONENTS) - list(APPEND _MPI_REQ_VARS "MPI_MPICXX_FOUND") -endif() - -find_package_handle_standard_args(MPI - REQUIRED_VARS ${_MPI_REQ_VARS} - VERSION_VAR ${_MPI_MIN_VERSION} - HANDLE_COMPONENTS) - -#============================================================================= -# More backward compatibility stuff - -# For compatibility reasons, we also define MPIEXEC -set(MPIEXEC "${MPIEXEC_EXECUTABLE}") - -# Copy over MPI__INCLUDE_PATH from the assembled INCLUDE_DIRS. -foreach(LANG IN ITEMS C CXX Fortran) - if(MPI_${LANG}_FOUND) - set(MPI_${LANG}_INCLUDE_PATH "${MPI_${LANG}_INCLUDE_DIRS}") - unset(MPI_${LANG}_COMPILE_FLAGS) - if(MPI_${LANG}_COMPILE_OPTIONS) - set(MPI_${LANG}_COMPILE_FLAGS "${MPI_${LANG}_COMPILE_OPTIONS}") - endif() - if(MPI_${LANG}_COMPILE_DEFINITIONS) - foreach(_MPI_DEF IN LISTS MPI_${LANG}_COMPILE_DEFINITIONS) - string(APPEND MPI_${LANG}_COMPILE_FLAGS " -D${_MPI_DEF}") - endforeach() - endif() - endif() -endforeach() - -# Bare MPI sans ${LANG} vars are set to CXX then C, depending on what was found. -# This mimics the behavior of the old language-oblivious FindMPI. -set(_MPI_OLD_VARS COMPILER INCLUDE_PATH COMPILE_FLAGS LINK_FLAGS LIBRARIES) -if (MPI_CXX_FOUND) - foreach (var ${_MPI_OLD_VARS}) - set(MPI_${var} ${MPI_CXX_${var}}) - endforeach() -elseif (MPI_C_FOUND) - foreach (var ${_MPI_OLD_VARS}) - set(MPI_${var} ${MPI_C_${var}}) - endforeach() -endif() - -# Chop MPI_LIBRARIES into the old-style MPI_LIBRARY and MPI_EXTRA_LIBRARY, and set them in cache. -if (MPI_LIBRARIES) - list(GET MPI_LIBRARIES 0 MPI_LIBRARY_WORK) - set(MPI_LIBRARY "${MPI_LIBRARY_WORK}") - unset(MPI_LIBRARY_WORK) -else() - set(MPI_LIBRARY "MPI_LIBRARY-NOTFOUND") -endif() - -list(LENGTH MPI_LIBRARIES MPI_NUMLIBS) -if (MPI_NUMLIBS GREATER 1) - set(MPI_EXTRA_LIBRARY_WORK "${MPI_LIBRARIES}") - list(REMOVE_AT MPI_EXTRA_LIBRARY_WORK 0) - set(MPI_EXTRA_LIBRARY "${MPI_EXTRA_LIBRARY_WORK}") - unset(MPI_EXTRA_LIBRARY_WORK) -else() - set(MPI_EXTRA_LIBRARY "MPI_EXTRA_LIBRARY-NOTFOUND") -endif() -#============================================================================= - -# unset these vars to cleanup namespace -unset(_MPI_OLD_VARS) -unset(_MPI_PREFIX_PATH) -unset(_MPI_BASE_DIR) -foreach (lang C CXX Fortran) - unset(_MPI_${LANG}_COMPILER_NAMES) -endforeach() - -cmake_policy(POP) -- cgit v0.12 From f190509675e545bdda4e53d561c30f58a5f5ff4a Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 1 Nov 2017 13:50:13 -0500 Subject: Remove incorrect link var --- fortran/CMakeLists.txt | 1 - fortran/examples/CMakeLists.txt | 2 -- 2 files changed, 3 deletions(-) diff --git a/fortran/CMakeLists.txt b/fortran/CMakeLists.txt index 9f7144d..075e1da 100644 --- a/fortran/CMakeLists.txt +++ b/fortran/CMakeLists.txt @@ -2,7 +2,6 @@ cmake_minimum_required (VERSION 3.2.2) PROJECT (HDF5_F90 C CXX Fortran) if (H5_HAVE_PARALLEL) - set (LINK_LIBS ${LINK_LIBS} MPI::MPI_Fortran) if (MPI_Fortran_LINK_FLAGS) set (CMAKE_EXE_LINKER_FLAGS "${MPI_Fortran_LINK_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}") endif () diff --git a/fortran/examples/CMakeLists.txt b/fortran/examples/CMakeLists.txt index 119648f..82cbd5c 100644 --- a/fortran/examples/CMakeLists.txt +++ b/fortran/examples/CMakeLists.txt @@ -107,7 +107,6 @@ if (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND) target_link_libraries (f90_ex_ph5example ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} - MPI::MPI_Fortran ) target_include_directories (f90_ex_ph5example PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/static) set_target_properties (f90_ex_ph5example PROPERTIES @@ -122,7 +121,6 @@ if (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND) target_link_libraries (f90_ex_ph5example-shared ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} - MPI::MPI_Fortran ) target_include_directories (f90_ex_ph5example-shared PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/shared) set_target_properties (f90_ex_ph5example-shared PROPERTIES -- cgit v0.12 From 21874ce5c201b2be7305599434a156b9fbbcfc89 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 1 Nov 2017 15:06:46 -0500 Subject: Add back Find module and add support files --- config/cmake_ext_mod/FindMPI.cmake | 1461 ++++++++++++++++++++ .../cmake_ext_mod/FindMPI/fortranparam_mpi.f90.in | 4 + config/cmake_ext_mod/FindMPI/libver_mpi.c | 19 + config/cmake_ext_mod/FindMPI/libver_mpi.f90.in | 7 + config/cmake_ext_mod/FindMPI/mpiver.f90.in | 10 + config/cmake_ext_mod/FindMPI/test_mpi.c | 37 + config/cmake_ext_mod/FindMPI/test_mpi.f90.in | 6 + 7 files changed, 1544 insertions(+) create mode 100644 config/cmake_ext_mod/FindMPI.cmake create mode 100644 config/cmake_ext_mod/FindMPI/fortranparam_mpi.f90.in create mode 100644 config/cmake_ext_mod/FindMPI/libver_mpi.c create mode 100644 config/cmake_ext_mod/FindMPI/libver_mpi.f90.in create mode 100644 config/cmake_ext_mod/FindMPI/mpiver.f90.in create mode 100644 config/cmake_ext_mod/FindMPI/test_mpi.c create mode 100644 config/cmake_ext_mod/FindMPI/test_mpi.f90.in diff --git a/config/cmake_ext_mod/FindMPI.cmake b/config/cmake_ext_mod/FindMPI.cmake new file mode 100644 index 0000000..61ab4a4 --- /dev/null +++ b/config/cmake_ext_mod/FindMPI.cmake @@ -0,0 +1,1461 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See https://cmake.org/licensing for details. + +#.rst: +# FindMPI +# ------- +# +# Find a Message Passing Interface (MPI) implementation. +# +# The Message Passing Interface (MPI) is a library used to write +# high-performance distributed-memory parallel applications, and is +# typically deployed on a cluster. MPI is a standard interface (defined +# by the MPI forum) for which many implementations are available. +# +# Variables for using MPI +# ^^^^^^^^^^^^^^^^^^^^^^^ +# +# The module exposes the components ``C``, ``CXX``, ``MPICXX`` and ``Fortran``. +# Each of these controls the various MPI languages to search for. +# The difference between ``CXX`` and ``MPICXX`` is that ``CXX`` refers to the +# MPI C API being usable from C++, whereas ``MPICXX`` refers to the MPI-2 C++ API +# that was removed again in MPI-3. +# +# Depending on the enabled components the following variables will be set: +# +# ``MPI_FOUND`` +# Variable indicating that MPI settings for all requested languages have been found. +# If no components are specified, this is true if MPI settings for all enabled languages +# were detected. Note that the ``MPICXX`` component does not affect this variable. +# ``MPI_VERSION`` +# Minimal version of MPI detected among the requested languages, or all enabled languages +# if no components were specified. +# +# This module will set the following variables per language in your +# project, where ```` is one of C, CXX, or Fortran: +# +# ``MPI__FOUND`` +# Variable indicating the MPI settings for ```` were found and that +# simple MPI test programs compile with the provided settings. +# ``MPI__COMPILER`` +# MPI compiler for ```` if such a program exists. +# ``MPI__COMPILE_OPTIONS`` +# Compilation options for MPI programs in ````, given as a :ref:`;-list `. +# ``MPI__COMPILE_DEFINITIONS`` +# Compilation definitions for MPI programs in ````, given as a :ref:`;-list `. +# ``MPI__INCLUDE_DIRS`` +# Include path(s) for MPI header. +# ``MPI__LINK_FLAGS`` +# Linker flags for MPI programs. +# ``MPI__LIBRARIES`` +# All libraries to link MPI programs against. +# +# Additionally, the following :prop_tgt:`IMPORTED` targets are defined: +# +# ``MPI::MPI_`` +# Target for using MPI from ````. +# +# The following variables indicating which bindings are present will be defined: +# +# ``MPI_MPICXX_FOUND`` +# Variable indicating whether the MPI-2 C++ bindings are present (introduced in MPI-2, removed with MPI-3). +# ``MPI_Fortran_HAVE_F77_HEADER`` +# True if the Fortran 77 header ``mpif.h`` is available. +# ``MPI_Fortran_HAVE_F90_MODULE`` +# True if the Fortran 90 module ``mpi`` can be used for accessing MPI (MPI-2 and higher only). +# ``MPI_Fortran_HAVE_F08_MODULE`` +# True if the Fortran 2008 ``mpi_f08`` is available to MPI programs (MPI-3 and higher only). +# +# If possible, the MPI version will be determined by this module. The facilities to detect the MPI version +# were introduced with MPI-1.2, and therefore cannot be found for older MPI versions. +# +# ``MPI__VERSION_MAJOR`` +# Major version of MPI implemented for ```` by the MPI distribution. +# ``MPI__VERSION_MINOR`` +# Minor version of MPI implemented for ```` by the MPI distribution. +# ``MPI__VERSION`` +# MPI version implemented for ```` by the MPI distribution. +# +# Note that there's no variable for the C bindings being accessible through ``mpi.h``, since the MPI standards +# always have required this binding to work in both C and C++ code. +# +# For running MPI programs, the module sets the following variables +# +# ``MPIEXEC_EXECUTABLE`` +# Executable for running MPI programs, if such exists. +# ``MPIEXEC_NUMPROC_FLAG`` +# Flag to pass to ``mpiexec`` before giving it the number of processors to run on. +# ``MPIEXEC_MAX_NUMPROCS`` +# Number of MPI processors to utilize. Defaults to the number +# of processors detected on the host system. +# ``MPIEXEC_PREFLAGS`` +# Flags to pass to ``mpiexec`` directly before the executable to run. +# ``MPIEXEC_POSTFLAGS`` +# Flags to pass to ``mpiexec`` after other flags. +# +# Variables for locating MPI +# ^^^^^^^^^^^^^^^^^^^^^^^^^^ +# +# This module performs a three step search for an MPI implementation: +# +# 1. Check if the compiler has MPI support built-in. This is the case if the user passed a +# compiler wrapper as ``CMAKE__COMPILER`` or if they're on a Cray system. +# 2. Attempt to find an MPI compiler wrapper and determine the compiler information from it. +# 3. Try to find an MPI implementation that does not ship such a wrapper by guessing settings. +# Currently, only Microsoft MPI and MPICH2 on Windows are supported. +# +# For controlling the second step, the following variables may be set: +# +# ``MPI__COMPILER`` +# Search for the specified compiler wrapper and use it. +# ``MPI__COMPILER_FLAGS`` +# Flags to pass to the MPI compiler wrapper during interrogation. Some compiler wrappers +# support linking debug or tracing libraries if a specific flag is passed and this variable +# may be used to obtain them. +# ``MPI_COMPILER_FLAGS`` +# Used to initialize ``MPI__COMPILER_FLAGS`` if no language specific flag has been given. +# Empty by default. +# ``MPI_EXECUTABLE_SUFFIX`` +# A suffix which is appended to all names that are being looked for. For instance you may set this +# to ``.mpich`` or ``.openmpi`` to prefer the one or the other on Debian and its derivatives. +# +# In order to control the guessing step, the following variable may be set: +# +# ``MPI_GUESS_LIBRARY_NAME`` +# Valid values are ``MSMPI`` and ``MPICH2``. If set, only the given library will be searched for. +# By default, ``MSMPI`` will be preferred over ``MPICH2`` if both are available. +# This also sets ``MPI_SKIP_COMPILER_WRAPPER`` to ``true``, which may be overridden. +# +# Each of the search steps may be skipped with the following control variables: +# +# ``MPI_ASSUME_NO_BUILTIN_MPI`` +# If true, the module assumes that the compiler itself does not provide an MPI implementation and +# skips to step 2. +# ``MPI_SKIP_COMPILER_WRAPPER`` +# If true, no compiler wrapper will be searched for. +# ``MPI_SKIP_GUESSING`` +# If true, the guessing step will be skipped. +# +# Additionally, the following control variable is available to change search behavior: +# +# ``MPI_CXX_SKIP_MPICXX`` +# Add some definitions that will disable the MPI-2 C++ bindings. +# Currently supported are MPICH, Open MPI, Platform MPI and derivatives thereof, +# for example MVAPICH or Intel MPI. +# +# If the find procedure fails for a variable ``MPI__WORKS``, then the settings detected by or passed to +# the module did not work and even a simple MPI test program failed to compile. +# +# If all of these parameters were not sufficient to find the right MPI implementation, a user may +# disable the entire autodetection process by specifying both a list of libraries in ``MPI__LIBRARIES`` +# and a list of include directories in ``MPI__ADDITIONAL_INCLUDE_DIRS``. +# Any other variable may be set in addition to these two. The module will then validate the MPI settings and store the +# settings in the cache. +# +# Cache variables for MPI +# ^^^^^^^^^^^^^^^^^^^^^^^ +# +# The variable ``MPI__INCLUDE_DIRS`` will be assembled from the following variables. +# For C and CXX: +# +# ``MPI__HEADER_DIR`` +# Location of the ``mpi.h`` header on disk. +# +# For Fortran: +# +# ``MPI_Fortran_F77_HEADER_DIR`` +# Location of the Fortran 77 header ``mpif.h``, if it exists. +# ``MPI_Fortran_MODULE_DIR`` +# Location of the ``mpi`` or ``mpi_f08`` modules, if available. +# +# For all languages the following variables are additionally considered: +# +# ``MPI__ADDITIONAL_INCLUDE_DIRS`` +# A :ref:`;-list ` of paths needed in addition to the normal include directories. +# ``MPI__INCLUDE_DIR`` +# Path variables for include folders referred to by ````. +# ``MPI__ADDITIONAL_INCLUDE_VARS`` +# A :ref:`;-list ` of ```` that will be added to the include locations of ````. +# +# The variable ``MPI__LIBRARIES`` will be assembled from the following variables: +# +# ``MPI__LIBRARY`` +# The location of a library called ```` for use with MPI. +# ``MPI__LIB_NAMES`` +# A :ref:`;-list ` of ```` that will be added to the include locations of ````. +# +# Usage of mpiexec +# ^^^^^^^^^^^^^^^^ +# +# When using ``MPIEXEC_EXECUTABLE`` to execute MPI applications, you should typically +# use all of the ``MPIEXEC_EXECUTABLE`` flags as follows: +# +# :: +# +# ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} +# ${MPIEXEC_PREFLAGS} EXECUTABLE ${MPIEXEC_POSTFLAGS} ARGS +# +# where ``EXECUTABLE`` is the MPI program, and ``ARGS`` are the arguments to +# pass to the MPI program. +# +# Advanced variables for using MPI +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +# +# The module can perform some advanced feature detections upon explicit request. +# +# **Important notice:** The following checks cannot be performed without *executing* an MPI test program. +# Consider the special considerations for the behavior of :command:`try_run` during cross compilation. +# Moreover, running an MPI program can cause additional issues, like a firewall notification on some systems. +# You should only enable these detections if you absolutely need the information. +# +# If the following variables are set to true, the respective search will be performed: +# +# ``MPI_DETERMINE_Fortran_CAPABILITIES`` +# Determine for all available Fortran bindings what the values of ``MPI_SUBARRAYS_SUPPORTED`` and +# ``MPI_ASYNC_PROTECTS_NONBLOCKING`` are and make their values available as ``MPI_Fortran__SUBARRAYS`` +# and ``MPI_Fortran__ASYNCPROT``, where ```` is one of ``F77_HEADER``, ``F90_MODULE`` and +# ``F08_MODULE``. +# ``MPI_DETERMINE_LIBRARY_VERSION`` +# For each language, find the output of ``MPI_Get_library_version`` and make it available as ``MPI__LIBRARY_VERSION``. +# This information is usually tied to the runtime component of an MPI implementation and might differ depending on ````. +# Note that the return value is entirely implementation defined. This information might be used to identify +# the MPI vendor and for example pick the correct one of multiple third party binaries that matches the MPI vendor. +# +# Backward Compatibility +# ^^^^^^^^^^^^^^^^^^^^^^ +# +# For backward compatibility with older versions of FindMPI, these +# variables are set, but deprecated: +# +# :: +# +# MPI_COMPILER MPI_LIBRARY MPI_EXTRA_LIBRARY +# MPI_COMPILE_FLAGS MPI_INCLUDE_PATH MPI_LINK_FLAGS +# MPI_LIBRARIES +# +# In new projects, please use the ``MPI__XXX`` equivalents. +# Additionally, the following variables are deprecated: +# +# ``MPI__COMPILE_FLAGS`` +# Use ``MPI__COMPILE_OPTIONS`` and ``MPI__COMPILE_DEFINITIONS`` instead. +# ``MPI__INCLUDE_PATH`` +# For consumption use ``MPI__INCLUDE_DIRS`` and for specifying folders use ``MPI__ADDITIONAL_INCLUDE_DIRS`` instead. +# ``MPIEXEC`` +# Use ``MPIEXEC_EXECUTABLE`` instead. + +cmake_policy(PUSH) +cmake_policy(SET CMP0057 NEW) # if IN_LIST + +# include this to handle the QUIETLY and REQUIRED arguments +include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) +include(GetPrerequisites) + +# Generic compiler names +set(_MPI_C_GENERIC_COMPILER_NAMES mpicc mpcc mpicc_r mpcc_r) +set(_MPI_CXX_GENERIC_COMPILER_NAMES mpicxx mpiCC mpcxx mpCC mpic++ mpc++ + mpicxx_r mpiCC_r mpcxx_r mpCC_r mpic++_r mpc++_r) +set(_MPI_Fortran_GENERIC_COMPILER_NAMES mpif95 mpif95_r mpf95 mpf95_r + mpif90 mpif90_r mpf90 mpf90_r + mpif77 mpif77_r mpf77 mpf77_r + mpifc) + +# GNU compiler names +set(_MPI_GNU_C_COMPILER_NAMES mpigcc mpgcc mpigcc_r mpgcc_r) +set(_MPI_GNU_CXX_COMPILER_NAMES mpig++ mpg++ mpig++_r mpg++_r mpigxx) +set(_MPI_GNU_Fortran_COMPILER_NAMES mpigfortran mpgfortran mpigfortran_r mpgfortran_r + mpig77 mpig77_r mpg77 mpg77_r) + +# Intel MPI compiler names on Windows +if(WIN32) + list(APPEND _MPI_C_GENERIC_COMPILER_NAMES mpicc.bat) + list(APPEND _MPI_CXX_GENERIC_COMPILER_NAMES mpicxx.bat) + list(APPEND _MPI_Fortran_GENERIC_COMPILER_NAMES mpifc.bat) + + # Intel MPI compiler names + set(_MPI_Intel_C_COMPILER_NAMES mpiicc.bat) + set(_MPI_Intel_CXX_COMPILER_NAMES mpiicpc.bat) + set(_MPI_Intel_Fortran_COMPILER_NAMES mpiifort.bat mpif77.bat mpif90.bat) + + # Intel MPI compiler names for MSMPI + set(_MPI_MSVC_C_COMPILER_NAMES mpicl.bat) + set(_MPI_MSVC_CXX_COMPILER_NAMES mpicl.bat) +else() + # Intel compiler names + set(_MPI_Intel_C_COMPILER_NAMES mpiicc) + set(_MPI_Intel_CXX_COMPILER_NAMES mpiicpc mpiicxx mpiic++) + set(_MPI_Intel_Fortran_COMPILER_NAMES mpiifort mpiif95 mpiif90 mpiif77) +endif() + +# PGI compiler names +set(_MPI_PGI_C_COMPILER_NAMES mpipgcc mppgcc) +set(_MPI_PGI_CXX_COMPILER_NAMES mpipgCC mppgCC) +set(_MPI_PGI_Fortran_COMPILER_NAMES mpipgf95 mpipgf90 mppgf95 mppgf90 mpipgf77 mppgf77) + +# XLC MPI Compiler names +set(_MPI_XL_C_COMPILER_NAMES mpxlc mpxlc_r mpixlc mpixlc_r) +set(_MPI_XL_CXX_COMPILER_NAMES mpixlcxx mpixlC mpixlc++ mpxlcxx mpxlc++ mpixlc++ mpxlCC + mpixlcxx_r mpixlC_r mpixlc++_r mpxlcxx_r mpxlc++_r mpixlc++_r mpxlCC_r) +set(_MPI_XL_Fortran_COMPILER_NAMES mpixlf95 mpixlf95_r mpxlf95 mpxlf95_r + mpixlf90 mpixlf90_r mpxlf90 mpxlf90_r + mpixlf77 mpixlf77_r mpxlf77 mpxlf77_r + mpixlf mpixlf_r mpxlf mpxlf_r) + +# Prepend vendor-specific compiler wrappers to the list. If we don't know the compiler, +# attempt all of them. +# By attempting vendor-specific compiler names first, we should avoid situations where the compiler wrapper +# stems from a proprietary MPI and won't know which compiler it's being used for. For instance, Intel MPI +# controls its settings via the I_MPI_CC environment variables if the generic name is being used. +# If we know which compiler we're working with, we can use the most specialized wrapper there is in order to +# pick up the right settings for it. +foreach (LANG IN ITEMS C CXX Fortran) + set(_MPI_${LANG}_COMPILER_NAMES "") + foreach (id IN ITEMS GNU Intel MSVC PGI XL) + if (NOT CMAKE_${LANG}_COMPILER_ID OR CMAKE_${LANG}_COMPILER_ID STREQUAL id) + list(APPEND _MPI_${LANG}_COMPILER_NAMES ${_MPI_${id}_${LANG}_COMPILER_NAMES}${MPI_EXECUTABLE_SUFFIX}) + endif() + unset(_MPI_${id}_${LANG}_COMPILER_NAMES) + endforeach() + list(APPEND _MPI_${LANG}_COMPILER_NAMES ${_MPI_${LANG}_GENERIC_COMPILER_NAMES}${MPI_EXECUTABLE_SUFFIX}) + unset(_MPI_${LANG}_GENERIC_COMPILER_NAMES) +endforeach() + +# Names to try for mpiexec +# Only mpiexec commands are guaranteed to behave as described in the standard, +# mpirun commands are not covered by the standard in any way whatsoever. +# lamexec is the executable for LAM/MPI, srun is for SLURM or Open MPI with SLURM support. +# srun -n X is however a valid command, so it behaves 'like' mpiexec. +set(_MPIEXEC_NAMES_BASE mpiexec mpiexec.hydra mpiexec.mpd mpirun lamexec srun) + +unset(_MPIEXEC_NAMES) +foreach(_MPIEXEC_NAME IN LISTS _MPIEXEC_NAMES_BASE) + list(APPEND _MPIEXEC_NAMES "${_MPIEXEC_NAME}${MPI_EXECUTABLE_SUFFIX}") +endforeach() +unset(_MPIEXEC_NAMES_BASE) + +function (_MPI_check_compiler LANG QUERY_FLAG OUTPUT_VARIABLE RESULT_VARIABLE) + if(DEFINED MPI_${LANG}_COMPILER_FLAGS) + separate_arguments(_MPI_COMPILER_WRAPPER_OPTIONS NATIVE_COMMAND "${MPI_${LANG}_COMPILER_FLAGS}") + else() + separate_arguments(_MPI_COMPILER_WRAPPER_OPTIONS NATIVE_COMMAND "${MPI_COMPILER_FLAGS}") + endif() + execute_process( + COMMAND ${MPI_${LANG}_COMPILER} ${_MPI_COMPILER_WRAPPER_OPTIONS} ${QUERY_FLAG} + OUTPUT_VARIABLE WRAPPER_OUTPUT OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_VARIABLE WRAPPER_OUTPUT ERROR_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE WRAPPER_RETURN) + # Some compiler wrappers will yield spurious zero return values, for example + # Intel MPI tolerates unknown arguments and if the MPI wrappers loads a shared + # library that has invalid or missing version information there would be warning + # messages emitted by ld.so in the compiler output. In either case, we'll treat + # the output as invalid. + if("${WRAPPER_OUTPUT}" MATCHES "undefined reference|unrecognized|need to set|no version information available") + set(WRAPPER_RETURN 255) + endif() + # Ensure that no error output might be passed upwards. + if(NOT WRAPPER_RETURN EQUAL 0) + unset(WRAPPER_OUTPUT) + endif() + set(${OUTPUT_VARIABLE} "${WRAPPER_OUTPUT}" PARENT_SCOPE) + set(${RESULT_VARIABLE} "${WRAPPER_RETURN}" PARENT_SCOPE) +endfunction() + +function (_MPI_interrogate_compiler lang) + unset(MPI_COMPILE_CMDLINE) + unset(MPI_LINK_CMDLINE) + + unset(MPI_COMPILE_OPTIONS_WORK) + unset(MPI_COMPILE_DEFINITIONS_WORK) + unset(MPI_INCLUDE_DIRS_WORK) + unset(MPI_LINK_FLAGS_WORK) + unset(MPI_LIB_NAMES_WORK) + unset(MPI_LIB_FULLPATHS_WORK) + + # Check whether the -showme:compile option works. This indicates that we have either Open MPI + # or a newer version of LAM/MPI, and implies that -showme:link will also work. + # Open MPI also supports -show, but separates linker and compiler information + _MPI_check_compiler(${LANG} "-showme:compile" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) + if (MPI_COMPILER_RETURN EQUAL 0) + _MPI_check_compiler(${LANG} "-showme:link" MPI_LINK_CMDLINE MPI_COMPILER_RETURN) + + if (NOT MPI_COMPILER_RETURN EQUAL 0) + unset(MPI_COMPILE_CMDLINE) + endif() + endif() + + # MPICH and MVAPICH offer -compile-info and -link-info. + # For modern versions, both do the same as -show. However, for old versions, they do differ + # when called for mpicxx and mpif90 and it's necessary to use them over -show in order to find the + # removed MPI C++ bindings. + if (NOT MPI_COMPILER_RETURN EQUAL 0) + _MPI_check_compiler(${LANG} "-compile-info" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) + + if (MPI_COMPILER_RETURN EQUAL 0) + _MPI_check_compiler(${LANG} "-link-info" MPI_LINK_CMDLINE MPI_COMPILER_RETURN) + + if (NOT MPI_COMPILER_RETURN EQUAL 0) + unset(MPI_COMPILE_CMDLINE) + endif() + endif() + endif() + + # MPICH, MVAPICH2 and Intel MPI just use "-show". Open MPI also offers this, but the + # -showme commands are more specialized. + if (NOT MPI_COMPILER_RETURN EQUAL 0) + _MPI_check_compiler(${LANG} "-show" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) + endif() + + # Older versions of LAM/MPI have "-showme". Open MPI also supports this. + # Unknown to MPICH, MVAPICH and Intel MPI. + if (NOT MPI_COMPILER_RETURN EQUAL 0) + _MPI_check_compiler(${LANG} "-showme" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) + endif() + + if (NOT (MPI_COMPILER_RETURN EQUAL 0) OR NOT (DEFINED MPI_COMPILE_CMDLINE)) + # Cannot interrogate this compiler, so exit. + set(MPI_${LANG}_WRAPPER_FOUND FALSE PARENT_SCOPE) + return() + endif() + unset(MPI_COMPILER_RETURN) + + # We have our command lines, but we might need to copy MPI_COMPILE_CMDLINE + # into MPI_LINK_CMDLINE, if we didn't find the link line. + if (NOT DEFINED MPI_LINK_CMDLINE) + set(MPI_LINK_CMDLINE "${MPI_COMPILE_CMDLINE}") + endif() + + # At this point, we obtained some output from a compiler wrapper that works. + # We'll now try to parse it into variables with meaning to us. + if("${LANG}" STREQUAL "Fortran") + # Some MPICH-1 and MVAPICH-1 versions return a three command answer for Fortran, consisting + # out of a symlink command for mpif.h, the actual compiler command and a deletion of the + # created symlink. We need to detect that case, remember the include path and drop the + # symlink/deletion operation to obtain the link/compile lines we'd usually expect. + if("${MPI_COMPILE_CMDLINE}" MATCHES "^ln -s ([^\" ]+|\"[^\"]+\") mpif.h") + get_filename_component(MPI_INCLUDE_DIRS_WORK "${CMAKE_MATCH_1}" DIRECTORY) + string(REGEX REPLACE "^ln -s ([^\" ]+|\"[^\"]+\") mpif.h\n" "" MPI_COMPILE_CMDLINE "${MPI_COMPILE_CMDLINE}") + string(REGEX REPLACE "^ln -s ([^\" ]+|\"[^\"]+\") mpif.h\n" "" MPI_LINK_CMDLINE "${MPI_LINK_CMDLINE}") + string(REGEX REPLACE "\nrm -f mpif.h$" "" MPI_COMPILE_CMDLINE "${MPI_COMPILE_CMDLINE}") + string(REGEX REPLACE "\nrm -f mpif.h$" "" MPI_LINK_CMDLINE "${MPI_LINK_CMDLINE}") + endif() + endif() + + # The Intel MPI wrapper on Linux will emit some objcopy commands after its compile command + # if -static_mpi was passed to the wrapper. To avoid spurious matches, we need to drop these lines. + if(UNIX) + string(REGEX REPLACE "(^|\n)objcopy[^\n]+(\n|$)" "" MPI_COMPILE_CMDLINE "${MPI_COMPILE_CMDLINE}") + string(REGEX REPLACE "(^|\n)objcopy[^\n]+(\n|$)" "" MPI_LINK_CMDLINE "${MPI_LINK_CMDLINE}") + endif() + + # Extract compile options from the compile command line. + string(REGEX MATCHALL "(^| )-f([^\" ]+|\"[^\"]+\")" MPI_ALL_COMPILE_OPTIONS "${MPI_COMPILE_CMDLINE}") + + foreach(_MPI_COMPILE_OPTION IN LISTS MPI_ALL_COMPILE_OPTIONS) + string(REGEX REPLACE "^ " "" _MPI_COMPILE_OPTION "${_MPI_COMPILE_OPTION}") + # Ignore -fstack-protector directives: These occur on MPICH and MVAPICH when the libraries + # themselves were built with this flag. However, this flag is unrelated to using MPI, and + # we won't match the accompanying --param-ssp-size and -Wp,-D_FORTIFY_SOURCE flags and therefore + # produce inconsistent results with the regularly flags. + # Similarly, aliasing flags do not belong into our flag array. + if(NOT "${_MPI_COMPILE_OPTION}" MATCHES "^-f(stack-protector|(no-|)strict-aliasing|PI[CE]|pi[ce])") + list(APPEND MPI_COMPILE_OPTIONS_WORK "${_MPI_COMPILE_OPTION}") + endif() + endforeach() + + # Same deal, with the definitions. We also treat arguments passed to the preprocessor directly. + string(REGEX MATCHALL "(^| )(-Wp,|-Xpreprocessor |)[-/]D([^\" ]+|\"[^\"]+\")" MPI_ALL_COMPILE_DEFINITIONS "${MPI_COMPILE_CMDLINE}") + + foreach(_MPI_COMPILE_DEFINITION IN LISTS MPI_ALL_COMPILE_DEFINITIONS) + string(REGEX REPLACE "^ ?(-Wp,|-Xpreprocessor )?[-/]D" "" _MPI_COMPILE_DEFINITION "${_MPI_COMPILE_DEFINITION}") + string(REPLACE "\"" "" _MPI_COMPILE_DEFINITION "${_MPI_COMPILE_DEFINITION}") + if(NOT "${_MPI_COMPILE_DEFINITION}" MATCHES "^_FORTIFY_SOURCE.*") + list(APPEND MPI_COMPILE_DEFINITIONS_WORK "${_MPI_COMPILE_DEFINITION}") + endif() + endforeach() + + # Extract include paths from compile command line + string(REGEX MATCHALL "(^| )[-/]I([^\" ]+|\"[^\"]+\")" MPI_ALL_INCLUDE_PATHS "${MPI_COMPILE_CMDLINE}") + + # If extracting failed to work, we'll try using -showme:incdirs. + if (NOT MPI_ALL_INCLUDE_PATHS) + _MPI_check_compiler(${LANG} "-showme:incdirs" MPI_INCDIRS_CMDLINE MPI_INCDIRS_COMPILER_RETURN) + if(MPI_INCDIRS_COMPILER_RETURN) + separate_arguments(MPI_ALL_INCLUDE_PATHS NATIVE_COMMAND "${MPI_INCDIRS_CMDLINE}") + endif() + endif() + + foreach(_MPI_INCLUDE_PATH IN LISTS MPI_ALL_INCLUDE_PATHS) + string(REGEX REPLACE "^ ?[-/]I" "" _MPI_INCLUDE_PATH "${_MPI_INCLUDE_PATH}") + string(REPLACE "\"" "" _MPI_INCLUDE_PATH "${_MPI_INCLUDE_PATH}") + get_filename_component(_MPI_INCLUDE_PATH "${_MPI_INCLUDE_PATH}" REALPATH) + list(APPEND MPI_INCLUDE_DIRS_WORK "${_MPI_INCLUDE_PATH}") + endforeach() + + # Extract linker paths from the link command line + string(REGEX MATCHALL "(^| )(-Wl,|-Xlinker |)(-L|[/-]LIBPATH:|[/-]libpath:)([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_PATHS "${MPI_LINK_CMDLINE}") + + # If extracting failed to work, we'll try using -showme:libdirs. + if (NOT MPI_ALL_LINK_PATHS) + _MPI_check_compiler(${LANG} "-showme:libdirs" MPI_LIBDIRS_CMDLINE MPI_LIBDIRS_COMPILER_RETURN) + if(MPI_LIBDIRS_COMPILER_RETURN) + separate_arguments(MPI_ALL_LINK_PATHS NATIVE_COMMAND "${MPI_LIBDIRS_CMDLINE}") + endif() + endif() + + foreach(_MPI_LPATH IN LISTS MPI_ALL_LINK_PATHS) + string(REGEX REPLACE "^ ?(-Wl,|-Xlinker )?(-L|[/-]LIBPATH:|[/-]libpath:)" "" _MPI_LPATH "${_MPI_LPATH}") + string(REPLACE "\"" "" _MPI_LPATH "${_MPI_LPATH}") + get_filename_component(_MPI_LPATH "${_MPI_LPATH}" REALPATH) + list(APPEND MPI_LINK_DIRECTORIES_WORK "${_MPI_LPATH}") + endforeach() + + # Extract linker flags from the link command line + string(REGEX MATCHALL "(^| )(-Wl,|-Xlinker )([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_FLAGS "${MPI_LINK_CMDLINE}") + + foreach(_MPI_LINK_FLAG IN LISTS MPI_ALL_LINK_FLAGS) + string(STRIP "${_MPI_LINK_FLAG}" _MPI_LINK_FLAG) + # MPI might be marked to build with non-executable stacks but this should not propagate. + if (NOT "${_MPI_LINK_FLAG}" MATCHES "(-Wl,|-Xlinker )-z,noexecstack") + if (MPI_LINK_FLAGS_WORK) + string(APPEND MPI_LINK_FLAGS_WORK " ${_MPI_LINK_FLAG}") + else() + set(MPI_LINK_FLAGS_WORK "${_MPI_LINK_FLAG}") + endif() + endif() + endforeach() + + # Extract the set of libraries to link against from the link command + # line + string(REGEX MATCHALL "(^| )-l([^\" ]+|\"[^\"]+\")" MPI_LIBNAMES "${MPI_LINK_CMDLINE}") + + foreach(_MPI_LIB_NAME IN LISTS MPI_LIBNAMES) + string(REGEX REPLACE "^ ?-l" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") + string(REPLACE "\"" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") + get_filename_component(_MPI_LIB_PATH "${_MPI_LIB_NAME}" DIRECTORY) + if(NOT "${_MPI_LIB_PATH}" STREQUAL "") + list(APPEND MPI_LIB_FULLPATHS_WORK "${_MPI_LIB_NAME}") + else() + list(APPEND MPI_LIB_NAMES_WORK "${_MPI_LIB_NAME}") + endif() + endforeach() + + if(WIN32) + # A compiler wrapper on Windows will just have the name of the + # library to link on its link line, potentially with a full path + string(REGEX MATCHALL "(^| )([^\" ]+\\.lib|\"[^\"]+\\.lib\")" MPI_LIBNAMES "${MPI_LINK_CMDLINE}") + foreach(_MPI_LIB_NAME IN LISTS MPI_LIBNAMES) + string(REGEX REPLACE "^ " "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") + string(REPLACE "\"" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") + get_filename_component(_MPI_LIB_PATH "${_MPI_LIB_NAME}" DIRECTORY) + if(NOT "${_MPI_LIB_PATH}" STREQUAL "") + list(APPEND MPI_LIB_FULLPATHS_WORK "${_MPI_LIB_NAME}") + else() + list(APPEND MPI_LIB_NAMES_WORK "${_MPI_LIB_NAME}") + endif() + endforeach() + else() + # On UNIX platforms, archive libraries can be given with full path. + string(REGEX MATCHALL "(^| )([^\" ]+\\.a|\"[^\"]+\\.a\")" MPI_LIBFULLPATHS "${MPI_LINK_CMDLINE}") + foreach(_MPI_LIB_NAME IN LISTS MPI_LIBFULLPATHS) + string(REGEX REPLACE "^ " "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") + string(REPLACE "\"" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}") + get_filename_component(_MPI_LIB_PATH "${_MPI_LIB_NAME}" DIRECTORY) + if(NOT "${_MPI_LIB_PATH}" STREQUAL "") + list(APPEND MPI_LIB_FULLPATHS_WORK "${_MPI_LIB_NAME}") + else() + list(APPEND MPI_LIB_NAMES_WORK "${_MPI_LIB_NAME}") + endif() + endforeach() + endif() + + # An MPI compiler wrapper could have its MPI libraries in the implictly + # linked directories of the compiler itself. + if(DEFINED CMAKE_${LANG}_IMPLICIT_LINK_DIRECTORIES) + list(APPEND MPI_LINK_DIRECTORIES_WORK "${CMAKE_${LANG}_IMPLICIT_LINK_DIRECTORIES}") + endif() + + # Determine full path names for all of the libraries that one needs + # to link against in an MPI program + unset(MPI_PLAIN_LIB_NAMES_WORK) + foreach(_MPI_LIB_NAME IN LISTS MPI_LIB_NAMES_WORK) + get_filename_component(_MPI_PLAIN_LIB_NAME "${_MPI_LIB_NAME}" NAME_WE) + list(APPEND MPI_PLAIN_LIB_NAMES_WORK "${_MPI_PLAIN_LIB_NAME}") + find_library(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY + NAMES "${_MPI_LIB_NAME}" "lib${_MPI_LIB_NAME}" + HINTS ${MPI_LINK_DIRECTORIES_WORK} + DOC "Location of the ${_MPI_PLAIN_LIB_NAME} library for MPI" + ) + mark_as_advanced(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY) + endforeach() + + # Deal with the libraries given with full path next + unset(MPI_DIRECT_LIB_NAMES_WORK) + foreach(_MPI_LIB_FULLPATH IN LISTS MPI_LIB_FULLPATHS_WORK) + get_filename_component(_MPI_PLAIN_LIB_NAME "${_MPI_LIB_FULLPATH}" NAME_WE) + get_filename_component(_MPI_LIB_NAME "${_MPI_LIB_FULLPATH}" NAME) + get_filename_component(_MPI_LIB_PATH "${_MPI_LIB_FULLPATH}" DIRECTORY) + list(APPEND MPI_DIRECT_LIB_NAMES_WORK "${_MPI_PLAIN_LIB_NAME}") + find_library(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY + NAMES "${_MPI_LIB_NAME}" + HINTS ${_MPI_LIB_PATH} + DOC "Location of the ${_MPI_PLAIN_LIB_NAME} library for MPI" + ) + mark_as_advanced(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY) + endforeach() + if(MPI_DIRECT_LIB_NAMES_WORK) + set(MPI_PLAIN_LIB_NAMES_WORK "${MPI_DIRECT_LIB_NAMES_WORK};${MPI_PLAIN_LIB_NAMES_WORK}") + endif() + + # MPI might require pthread to work. The above mechanism wouldn't detect it, but we need to + # link it in that case. -lpthread is covered by the normal library treatment on the other hand. + if("${MPI_COMPILE_CMDLINE}" MATCHES "-pthread") + list(APPEND MPI_COMPILE_OPTIONS_WORK "-pthread") + if(MPI_LINK_FLAGS_WORK) + string(APPEND MPI_LINK_FLAGS_WORK " -pthread") + else() + set(MPI_LINK_FLAGS_WORK "-pthread") + endif() + endif() + + # If we found MPI, set up all of the appropriate cache entries + if(NOT MPI_${LANG}_COMPILE_OPTIONS) + set(MPI_${LANG}_COMPILE_OPTIONS ${MPI_COMPILE_OPTIONS_WORK} CACHE STRING "MPI ${LANG} compilation options" FORCE) + endif() + if(NOT MPI_${LANG}_COMPILE_DEFINITIONS) + set(MPI_${LANG}_COMPILE_DEFINITIONS ${MPI_COMPILE_DEFINITIONS_WORK} CACHE STRING "MPI ${LANG} compilation definitions" FORCE) + endif() + if(NOT MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) + set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_INCLUDE_DIRS_WORK} CACHE STRING "MPI ${LANG} additional include directories" FORCE) + endif() + if(NOT MPI_${LANG}_LINK_FLAGS) + set(MPI_${LANG}_LINK_FLAGS ${MPI_LINK_FLAGS_WORK} CACHE STRING "MPI ${LANG} linker flags" FORCE) + endif() + if(NOT MPI_${LANG}_LIB_NAMES) + set(MPI_${LANG}_LIB_NAMES ${MPI_PLAIN_LIB_NAMES_WORK} CACHE STRING "MPI ${LANG} libraries to link against" FORCE) + endif() + set(MPI_${LANG}_WRAPPER_FOUND TRUE PARENT_SCOPE) +endfunction() + +function(_MPI_guess_settings LANG) + set(MPI_GUESS_FOUND FALSE) + # Currently only MSMPI and MPICH2 on Windows are supported, so we can skip this search if we're not targeting that. + if(WIN32) + # MSMPI + + # The environment variables MSMPI_INC and MSMPILIB32/64 are the only ways of locating the MSMPI_SDK, + # which is installed separately from the runtime. Thus it's possible to have mpiexec but not MPI headers + # or import libraries and vice versa. + if(NOT MPI_GUESS_LIBRARY_NAME OR "${MPI_GUESS_LIBRARY_NAME}" STREQUAL "MSMPI") + # We first attempt to locate the msmpi.lib. Should be find it, we'll assume that the MPI present is indeed + # Microsoft MPI. + if("${CMAKE_SIZEOF_VOID_P}" EQUAL 8) + set(MPI_MSMPI_LIB_PATH "$ENV{MSMPI_LIB64}") + set(MPI_MSMPI_INC_PATH_EXTRA "$ENV{MSMPI_INC}/x64") + else() + set(MPI_MSMPI_LIB_PATH "$ENV{MSMPI_LIB32}") + set(MPI_MSMPI_INC_PATH_EXTRA "$ENV{MSMPI_INC}/x86") + endif() + + find_library(MPI_msmpi_LIBRARY + NAMES msmpi + HINTS ${MPI_MSMPI_LIB_PATH} + DOC "Location of the msmpi library for Microsoft MPI") + mark_as_advanced(MPI_msmpi_LIBRARY) + + if(MPI_msmpi_LIBRARY) + # Next, we attempt to locate the MPI header. Note that for Fortran we know that mpif.h is a way + # MSMPI can be used and therefore that header has to be present. + if(NOT MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) + get_filename_component(MPI_MSMPI_INC_DIR "$ENV{MSMPI_INC}" REALPATH) + set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "${MPI_MSMPI_INC_DIR}" CACHE STRING "MPI ${LANG} additional include directories" FORCE) + unset(MPI_MSMPI_INC_DIR) + endif() + + # For MSMPI, one can compile the MPI module by building the mpi.f90 shipped with the MSMPI SDK, + # thus it might be present or provided by the user. Figuring out which is supported is done later on. + # The PGI Fortran compiler for instance ships a prebuilt set of modules in its own include folder. + # Should a user be employing PGI or have built its own set and provided it via cache variables, the + # splitting routine would have located the module files. + + # For C and C++, we're done here (MSMPI does not ship the MPI-2 C++ bindings) - however, for Fortran + # we need some extra library to glue Fortran support together: + # MSMPI ships 2-4 Fortran libraries, each for different Fortran compiler behaviors. The library names + # ending with a c are using the cdecl calling convention, whereas those ending with an s are for Fortran + # implementations using stdcall. Therefore, the 64-bit MSMPI only ships those ending in 'c', whereas the 32-bit + # has both variants available. + # The second difference is the last but one letter, if it's an e(nd), the length of a string argument is + # passed by the Fortran compiler after all other arguments on the parameter list, if it's an m(ixed), + # it's passed immediately after the string address. + + # To summarize: + # - msmpifec: CHARACTER length passed after the parameter list and using cdecl calling convention + # - msmpifmc: CHARACTER length passed directly after string address and using cdecl calling convention + # - msmpifes: CHARACTER length passed after the parameter list and using stdcall calling convention + # - msmpifms: CHARACTER length passed directly after string address and using stdcall calling convention + # 32-bit MSMPI ships all four libraries, 64-bit MSMPI ships only the first two. + + # As is, Intel Fortran and PGI Fortran both use the 'ec' variant of the calling convention, whereas + # the old Compaq Visual Fortran compiler defaulted to the 'ms' version. It's possible to make Intel Fortran + # use the CVF calling convention using /iface:cvf, but we assume - and this is also assumed in FortranCInterface - + # this isn't the case. It's also possible to make CVF use the 'ec' variant, using /iface=(cref,nomixed_str_len_arg). + + # Our strategy is now to locate all libraries, but enter msmpifec into the LIB_NAMES array. + # Should this not be adequate it's a straightforward way for a user to change the LIB_NAMES array and + # have his library found. Still, this should not be necessary outside of exceptional cases, as reasoned. + if ("${LANG}" STREQUAL "Fortran") + set(MPI_MSMPI_CALLINGCONVS c) + if("${CMAKE_SIZEOF_VOID_P}" EQUAL 4) + list(APPEND MPI_MSMPI_CALLINGCONVS s) + endif() + foreach(mpistrlenpos IN ITEMS e m) + foreach(mpicallingconv IN LISTS MPI_MSMPI_CALLINGCONVS) + find_library(MPI_msmpif${mpistrlenpos}${mpicallingconv}_LIBRARY + NAMES msmpif${mpistrlenpos}${mpicallingconv} + HINTS "${MPI_MSMPI_LIB_PATH}" + DOC "Location of the msmpi${mpistrlenpos}${mpicallingconv} library for Microsoft MPI") + mark_as_advanced(MPI_msmpif${mpistrlenpos}${mpicallingconv}_LIBRARY) + endforeach() + endforeach() + if(NOT MPI_${LANG}_LIB_NAMES) + set(MPI_${LANG}_LIB_NAMES "msmpi;msmpifec" CACHE STRING "MPI ${LANG} libraries to link against" FORCE) + endif() + + # At this point we're *not* done. MSMPI requires an additional include file for Fortran giving the value + # of MPI_AINT. This file is called mpifptr.h located in the x64 and x86 subfolders, respectively. + find_path(MPI_mpifptr_INCLUDE_DIR + NAMES "mpifptr.h" + HINTS "${MPI_MSMPI_INC_PATH_EXTRA}" + DOC "Location of the mpifptr.h extra header for Microsoft MPI") + if(NOT MPI_${LANG}_ADDITIONAL_INCLUDE_VARS) + set(MPI_${LANG}_ADDITIONAL_INCLUDE_VARS "mpifptr" CACHE STRING "MPI ${LANG} additional include directory variables, given in the form MPI__INCLUDE_DIR." FORCE) + endif() + mark_as_advanced(MPI_${LANG}_ADDITIONAL_INCLUDE_VARS MPI_mpifptr_INCLUDE_DIR) + else() + if(NOT MPI_${LANG}_LIB_NAMES) + set(MPI_${LANG}_LIB_NAMES "msmpi" CACHE STRING "MPI ${LANG} libraries to link against" FORCE) + endif() + endif() + mark_as_advanced(MPI_${LANG}_LIB_NAMES) + set(MPI_GUESS_FOUND TRUE) + endif() + endif() + + # At this point there's not many MPIs that we could still consider. + # OpenMPI 1.6.x and below supported Windows, but these ship compiler wrappers that still work. + # The only other relevant MPI implementation without a wrapper is MPICH2, which had Windows support in 1.4.1p1 and older. + if(NOT MPI_GUESS_LIBRARY_NAME OR "${MPI_GUESS_LIBRARY_NAME}" STREQUAL "MPICH2") + set(MPI_MPICH_PREFIX_PATHS + "$ENV{ProgramW6432}/MPICH2/lib" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MPICH\\SMPD;binary]/../lib" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MPICH2;Path]/lib" + ) + + # All of C, C++ and Fortran will need mpi.lib, so we'll look for this first + find_library(MPI_mpi_LIBRARY + NAMES mpi + HINTS ${MPI_MPICH_PREFIX_PATHS}) + mark_as_advanced(MPI_mpi_LIBRARY) + # If we found mpi.lib, we detect the rest of MPICH2 + if(MPI_mpi_LIBRARY) + set(MPI_MPICH_LIB_NAMES "mpi") + # If MPI-2 C++ bindings are requested, we need to locate cxx.lib as well. + # Otherwise, MPICH_SKIP_MPICXX will be defined and these bindings aren't needed. + if("${LANG}" STREQUAL "CXX" AND NOT MPI_CXX_SKIP_MPICXX) + find_library(MPI_cxx_LIBRARY + NAMES cxx + HINTS ${MPI_MPICH_PREFIX_PATHS}) + mark_as_advanced(MPI_cxx_LIBRARY) + list(APPEND MPI_MPICH_LIB_NAMES "cxx") + # For Fortran, MPICH2 provides three different libraries: + # fmpich2.lib which uses uppercase symbols and cdecl, + # fmpich2s.lib which uses uppercase symbols and stdcall (32-bit only), + # fmpich2g.lib which uses lowercase symbols with double underscores and cdecl. + # fmpich2s.lib would be useful for Compaq Visual Fortran, fmpich2g.lib has to be used with GNU g77 and is also + # provided in the form of an .a archive for MinGW and Cygwin. From our perspective, fmpich2.lib is the only one + # we need to try, and if it doesn't work with the given Fortran compiler we'd find out later on during validation + elseif("${LANG}" STREQUAL "Fortran") + find_library(MPI_fmpich2_LIBRARY + NAMES fmpich2 + HINTS ${MPI_MPICH_PREFIX_PATHS}) + find_library(MPI_fmpich2s_LIBRARY + NAMES fmpich2s + HINTS ${MPI_MPICH_PREFIX_PATHS}) + find_library(MPI_fmpich2g_LIBRARY + NAMES fmpich2g + HINTS ${MPI_MPICH_PREFIX_PATHS}) + mark_as_advanced(MPI_fmpich2_LIBRARY MPI_fmpich2s_LIBRARY MPI_fmpich2g_LIBRARY) + list(APPEND MPI_MPICH_LIB_NAMES "fmpich2") + endif() + + if(NOT MPI_${LANG}_LIB_NAMES) + set(MPI_${LANG}_LIB_NAMES "${MPI_MPICH_LIB_NAMES}" CACHE STRING "MPI ${LANG} libraries to link against" FORCE) + endif() + unset(MPI_MPICH_LIB_NAMES) + + if(NOT MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) + # For MPICH2, the include folder would be in ../include relative to the library folder. + get_filename_component(MPI_MPICH_ROOT_DIR "${MPI_mpi_LIBRARY}" DIRECTORY) + get_filename_component(MPI_MPICH_ROOT_DIR "${MPI_MPICH_ROOT_DIR}" DIRECTORY) + if(IS_DIRECTORY "${MPI_MPICH_ROOT_DIR}/include") + set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "${MPI_MPICH_ROOT_DIR}/include" CACHE STRING "MPI ${LANG} additional include directory variables, given in the form MPI__INCLUDE_DIR." FORCE) + endif() + unset(MPI_MPICH_ROOT_DIR) + endif() + set(MPI_GUESS_FOUND TRUE) + endif() + unset(MPI_MPICH_PREFIX_PATHS) + endif() + endif() + set(MPI_${LANG}_GUESS_FOUND "${MPI_GUESS_FOUND}" PARENT_SCOPE) +endfunction() + +function(_MPI_adjust_compile_definitions LANG) + if("${LANG}" STREQUAL "CXX") + # To disable the C++ bindings, we need to pass some definitions since the mpi.h header has to deal with both C and C++ + # bindings in MPI-2. + if(MPI_CXX_SKIP_MPICXX AND NOT MPI_${LANG}_COMPILE_DEFINITIONS MATCHES "SKIP_MPICXX") + # MPICH_SKIP_MPICXX is being used in MPICH and derivatives like MVAPICH or Intel MPI + # OMPI_SKIP_MPICXX is being used in Open MPI + # _MPICC_H is being used for IBM Platform MPI + list(APPEND MPI_${LANG}_COMPILE_DEFINITIONS "MPICH_SKIP_MPICXX" "OMPI_SKIP_MPICXX" "_MPICC_H") + set(MPI_${LANG}_COMPILE_DEFINITIONS "${MPI_${LANG}_COMPILE_DEFINITIONS}" CACHE STRING "MPI ${LANG} compilation definitions" FORCE) + endif() + endif() +endfunction() + +macro(_MPI_assemble_libraries LANG) + set(MPI_${LANG}_LIBRARIES "") + foreach(mpilib IN LISTS MPI_${LANG}_LIB_NAMES) + list(APPEND MPI_${LANG}_LIBRARIES ${MPI_${mpilib}_LIBRARY}) + endforeach() +endmacro() + +macro(_MPI_assemble_include_dirs LANG) + set(MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS}") + if("${LANG}" MATCHES "(C|CXX)") + if(MPI_${LANG}_HEADER_DIR) + list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_HEADER_DIR}") + endif() + else() # Fortran + if(MPI_${LANG}_F77_HEADER_DIR) + list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_F77_HEADER_DIR}") + endif() + if(MPI_${LANG}_MODULE_DIR AND NOT "${MPI_${LANG}_MODULE_DIR}" IN_LIST MPI_${LANG}_INCLUDE_DIRS) + list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_MODULE_DIR}") + endif() + endif() + if(MPI_${LANG}_ADDITIONAL_INCLUDE_VARS) + foreach(mpiadditionalinclude IN LISTS MPI_${LANG}_ADDITIONAL_INCLUDE_VARS) + list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${mpiadditionalinclude}_INCLUDE_DIR}") + endforeach() + endif() +endmacro() + +function(_MPI_split_include_dirs LANG) + # Backwards compatibility: Search INCLUDE_PATH if given. + if(MPI_${LANG}_INCLUDE_PATH) + list(APPEND MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "${MPI_${LANG}_INCLUDE_PATH}") + endif() + + # We try to find the headers/modules among those paths (and system paths) + # For C/C++, we just need to have a look for mpi.h. + if("${LANG}" MATCHES "(C|CXX)") + find_path(MPI_${LANG}_HEADER_DIR "mpi.h" + HINTS ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS} + ) + mark_as_advanced(MPI_${LANG}_HEADER_DIR) + if(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) + list(REMOVE_ITEM MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "${MPI_${LANG}_HEADER_DIR}") + endif() + # Fortran is more complicated here: An implementation could provide + # any of the Fortran 77/90/2008 APIs for MPI. For example, MSMPI + # only provides Fortran 77 and - if mpi.f90 is built - potentially + # a Fortran 90 module. + elseif("${LANG}" STREQUAL "Fortran") + find_path(MPI_${LANG}_F77_HEADER_DIR "mpif.h" + HINTS ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS} + ) + find_path(MPI_${LANG}_MODULE_DIR + NAMES "mpi.mod" "mpi_f08.mod" + HINTS ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS} + ) + if(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS) + list(REMOVE_ITEM MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS + "${MPI_${LANG}_F77_HEADER_DIR}" + "${MPI_${LANG}_MODULE_DIR}" + ) + endif() + mark_as_advanced(MPI_${LANG}_F77_HEADER_DIR MPI_${LANG}_MODULE_DIR) + endif() + set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS} CACHE STRING "MPI ${LANG} additional include directories" FORCE) +endfunction() + +macro(_MPI_create_imported_target LANG) + if(NOT TARGET MPI::MPI_${LANG}) + add_library(MPI::MPI_${LANG} INTERFACE IMPORTED) + endif() + + set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_COMPILE_OPTIONS "${MPI_${LANG}_COMPILE_OPTIONS}") + set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_COMPILE_DEFINITIONS "${MPI_${LANG}_COMPILE_DEFINITIONS}") + + set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_LINK_LIBRARIES "") + if(MPI_${LANG}_LINK_FLAGS) + set_property(TARGET MPI::MPI_${LANG} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${MPI_${LANG}_LINK_FLAGS}") + endif() + # If the compiler links MPI implicitly, no libraries will be found as they're contained within + # CMAKE__IMPLICIT_LINK_LIBRARIES already. + if(MPI_${LANG}_LIBRARIES) + set_property(TARGET MPI::MPI_${LANG} APPEND PROPERTY INTERFACE_LINK_LIBRARIES "${MPI_${LANG}_LIBRARIES}") + endif() + # Given the new design of FindMPI, INCLUDE_DIRS will always be located, even under implicit linking. + set_property(TARGET MPI::MPI_${LANG} PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${MPI_${LANG}_INCLUDE_DIRS}") +endmacro() + +function(_MPI_try_staged_settings LANG MPI_TEST_FILE_NAME MODE RUN_BINARY) + set(WORK_DIR "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindMPI") + set(SRC_DIR "${CMAKE_ROOT}/Modules/FindMPI") + set(BIN_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindMPI/${MPI_TEST_FILE_NAME}_${LANG}.bin") + unset(MPI_TEST_COMPILE_DEFINITIONS) + if("${LANG}" STREQUAL "Fortran") + if("${MODE}" STREQUAL "F90_MODULE") + set(MPI_Fortran_INCLUDE_LINE "use mpi\n implicit none") + elseif("${MODE}" STREQUAL "F08_MODULE") + set(MPI_Fortran_INCLUDE_LINE "use mpi_f08\n implicit none") + else() # F77 header + set(MPI_Fortran_INCLUDE_LINE "implicit none\n include 'mpif.h'") + endif() + configure_file("${SRC_DIR}/${MPI_TEST_FILE_NAME}.f90.in" "${WORK_DIR}/${MPI_TEST_FILE_NAME}.f90" @ONLY) + set(MPI_TEST_SOURCE_FILE "${WORK_DIR}/${MPI_TEST_FILE_NAME}.f90") + elseif("${LANG}" STREQUAL "CXX") + configure_file("${SRC_DIR}/${MPI_TEST_FILE_NAME}.c" "${WORK_DIR}/${MPI_TEST_FILE_NAME}.cpp" COPYONLY) + set(MPI_TEST_SOURCE_FILE "${WORK_DIR}/${MPI_TEST_FILE_NAME}.cpp") + if("${MODE}" STREQUAL "TEST_MPICXX") + set(MPI_TEST_COMPILE_DEFINITIONS TEST_MPI_MPICXX) + endif() + else() # C + set(MPI_TEST_SOURCE_FILE "${SRC_DIR}/${MPI_TEST_FILE_NAME}.c") + endif() + if(RUN_BINARY) + try_run(MPI_RUN_RESULT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} MPI_RESULT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} + "${CMAKE_BINARY_DIR}" SOURCES "${MPI_TEST_SOURCE_FILE}" + COMPILE_DEFINITIONS ${MPI_TEST_COMPILE_DEFINITIONS} + LINK_LIBRARIES MPI::MPI_${LANG} + RUN_OUTPUT_VARIABLE MPI_RUN_OUTPUT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE}) + set(MPI_RUN_OUTPUT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} "${MPI_RUN_OUTPUT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE}}" PARENT_SCOPE) + else() + try_compile(MPI_RESULT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} + "${CMAKE_BINARY_DIR}" SOURCES "${MPI_TEST_SOURCE_FILE}" + COMPILE_DEFINITIONS ${MPI_TEST_COMPILE_DEFINITIONS} + LINK_LIBRARIES MPI::MPI_${LANG} + COPY_FILE "${BIN_FILE}") + endif() +endfunction() + +macro(_MPI_check_lang_works LANG) + # For Fortran we may have by the MPI-3 standard an implementation that provides: + # - the mpi_f08 module + # - *both*, the mpi module and 'mpif.h' + # Since older MPI standards (MPI-1) did not define anything but 'mpif.h', we need to check all three individually. + if( NOT MPI_${LANG}_WORKS ) + if("${LANG}" STREQUAL "Fortran") + set(MPI_Fortran_INTEGER_LINE "(kind=MPI_INTEGER_KIND)") + _MPI_try_staged_settings(${LANG} test_mpi F77_HEADER FALSE) + _MPI_try_staged_settings(${LANG} test_mpi F90_MODULE FALSE) + _MPI_try_staged_settings(${LANG} test_mpi F08_MODULE FALSE) + + set(MPI_${LANG}_WORKS FALSE) + + foreach(mpimethod IN ITEMS F77_HEADER F08_MODULE F90_MODULE) + if(MPI_RESULT_${LANG}_test_mpi_${mpimethod}) + set(MPI_${LANG}_WORKS TRUE) + set(MPI_${LANG}_HAVE_${mpimethod} TRUE) + else() + set(MPI_${LANG}_HAVE_${mpimethod} FALSE) + endif() + endforeach() + # MPI-1 versions had no MPI_INTGER_KIND defined, so we need to try without it. + # However, MPI-1 also did not define the Fortran 90 and 08 modules, so we only try the F77 header. + unset(MPI_Fortran_INTEGER_LINE) + if(NOT MPI_${LANG}_WORKS) + _MPI_try_staged_settings(${LANG} test_mpi F77_HEADER_NOKIND FALSE) + if(MPI_RESULT_${LANG}_test_mpi_F77_HEADER_NOKIND) + set(MPI_${LANG}_WORKS TRUE) + set(MPI_${LANG}_HAVE_F77_HEADER TRUE) + endif() + endif() + else() + _MPI_try_staged_settings(${LANG} test_mpi normal FALSE) + # If 'test_mpi' built correctly, we've found valid MPI settings. There might not be MPI-2 C++ support, but there can't + # be MPI-2 C++ support without the C bindings being present, so checking for them is sufficient. + set(MPI_${LANG}_WORKS "${MPI_RESULT_${LANG}_test_mpi_normal}") + endif() + endif() +endmacro() + +# Some systems install various MPI implementations in separate folders in some MPI prefix +# This macro enumerates all such subfolders and adds them to the list of hints that will be searched. +macro(MPI_search_mpi_prefix_folder PREFIX_FOLDER) + if(EXISTS "${PREFIX_FOLDER}") + file(GLOB _MPI_folder_children RELATIVE "${PREFIX_FOLDER}" "${PREFIX_FOLDER}/*") + foreach(_MPI_folder_child IN LISTS _MPI_folder_children) + if(IS_DIRECTORY "${PREFIX_FOLDER}/${_MPI_folder_child}") + list(APPEND MPI_HINT_DIRS "${PREFIX_FOLDER}/${_MPI_folder_child}") + endif() + endforeach() + endif() +endmacro() + +set(MPI_HINT_DIRS ${MPI_HOME} $ENV{MPI_HOME} $ENV{I_MPI_ROOT}) +if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Linux") + # SUSE Linux Enterprise Server stores its MPI implementations under /usr/lib64/mpi/gcc/ + # We enumerate the subfolders and append each as a prefix + MPI_search_mpi_prefix_folder("/usr/lib64/mpi/gcc") +elseif("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows") + # MSMPI stores its runtime in a special folder, this adds the possible locations to the hints. + list(APPEND MPI_HINT_DIRS $ENV{MSMPI_BIN} "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MPI;InstallRoot]") +elseif("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "FreeBSD") + # FreeBSD ships mpich under the normal system paths - but available openmpi implementations + # will be found in /usr/local/mpi/ + MPI_search_mpi_prefix_folder("/usr/local/mpi/") +endif() + +# Most MPI distributions have some form of mpiexec or mpirun which gives us something we can look for. +# The MPI standard does not mandate the existence of either, but instead only makes requirements if a distribution +# ships an mpiexec program (mpirun executables are not regulated by the standard). +find_program(MPIEXEC_EXECUTABLE + NAMES ${_MPIEXEC_NAMES} + PATH_SUFFIXES bin sbin + HINTS ${MPI_HINT_DIRS} + DOC "Executable for running MPI programs.") + +# call get_filename_component twice to remove mpiexec and the directory it exists in (typically bin). +# This gives us a fairly reliable base directory to search for /bin /lib and /include from. +get_filename_component(_MPI_BASE_DIR "${MPIEXEC_EXECUTABLE}" PATH) +get_filename_component(_MPI_BASE_DIR "${_MPI_BASE_DIR}" PATH) + +# According to the MPI standard, section 8.8 -n is a guaranteed, and the only guaranteed way to +# launch an MPI process using mpiexec if such a program exists. +set(MPIEXEC_NUMPROC_FLAG "-n" CACHE STRING "Flag used by MPI to specify the number of processes for mpiexec; the next option will be the number of processes.") +set(MPIEXEC_PREFLAGS "" CACHE STRING "These flags will be directly before the executable that is being run by mpiexec.") +set(MPIEXEC_POSTFLAGS "" CACHE STRING "These flags will be placed after all flags passed to mpiexec.") + +# Set the number of processes to the physical processor count +cmake_host_system_information(RESULT _MPIEXEC_NUMPROCS QUERY NUMBER_OF_PHYSICAL_CORES) +set(MPIEXEC_MAX_NUMPROCS "${_MPIEXEC_NUMPROCS}" CACHE STRING "Maximum number of processors available to run MPI applications.") +unset(_MPIEXEC_NUMPROCS) +mark_as_advanced(MPIEXEC_EXECUTABLE MPIEXEC_NUMPROC_FLAG MPIEXEC_PREFLAGS MPIEXEC_POSTFLAGS MPIEXEC_MAX_NUMPROCS) + +#============================================================================= +# Backward compatibility input hacks. Propagate the FindMPI hints to C and +# CXX if the respective new versions are not defined. Translate the old +# MPI_LIBRARY and MPI_EXTRA_LIBRARY to respective MPI_${LANG}_LIBRARIES. +# +# Once we find the new variables, we translate them back into their old +# equivalents below. +foreach (LANG IN ITEMS C CXX) + # Old input variables. + set(_MPI_OLD_INPUT_VARS COMPILER COMPILE_FLAGS INCLUDE_PATH LINK_FLAGS) + + # Set new vars based on their old equivalents, if the new versions are not already set. + foreach (var ${_MPI_OLD_INPUT_VARS}) + if (NOT MPI_${LANG}_${var} AND MPI_${var}) + set(MPI_${LANG}_${var} "${MPI_${var}}") + endif() + endforeach() + + # Chop the old compile flags into options and definitions + if(MPI_${LANG}_COMPILE_FLAGS) + unset(MPI_${LANG}_COMPILE_OPTIONS) + unset(MPI_${LANG}_COMPILE_DEFINITIONS) + separate_arguments(MPI_SEPARATE_FLAGS NATIVE_COMMAND "${MPI_${LANG}_COMPILE_FLAGS}") + foreach(_MPI_FLAG IN LISTS MPI_SEPARATE_FLAGS) + if("${_MPI_FLAG}" MATCHES "^ *[-/D]([^ ]+)") + list(APPEND MPI_${LANG}_COMPILE_DEFINITIONS "${CMAKE_MATCH_1}") + else() + list(APPEND MPI_${LANG}_COMPILE_FLAGS "${_MPI_FLAG}") + endif() + endforeach() + unset(MPI_SEPARATE_FLAGS) + endif() + + # If a list of libraries was given, we'll split it into new-style cache variables + if(NOT MPI_${LANG}_LIB_NAMES) + foreach(_MPI_LIB IN LISTS MPI_${LANG}_LIBRARIES MPI_LIBRARY MPI_EXTRA_LIBRARY) + get_filename_component(_MPI_PLAIN_LIB_NAME "${_MPI_LIB}" NAME_WE) + get_filename_component(_MPI_LIB_NAME "${_MPI_LIB}" NAME) + get_filename_component(_MPI_LIB_DIR "${_MPI_LIB}" DIRECTORY) + list(APPEND MPI_PLAIN_LIB_NAMES_WORK "${_MPI_PLAIN_LIB_NAME}") + find_library(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY + NAMES "${_MPI_LIB_NAME}" "lib${_MPI_LIB_NAME}" + HINTS ${_MPI_LIB_DIR} $ENV{MPI_LIB} + DOC "Location of the ${_MPI_PLAIN_LIB_NAME} library for MPI" + ) + mark_as_advanced(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY) + endforeach() + endif() +endforeach() +#============================================================================= + +unset(MPI_VERSION) +unset(MPI_VERSION_MAJOR) +unset(MPI_VERSION_MINOR) + +unset(_MPI_MIN_VERSION) + +# This loop finds the compilers and sends them off for interrogation. +foreach(LANG IN ITEMS C CXX Fortran) + if(CMAKE_${LANG}_COMPILER_LOADED) + if(NOT MPI_FIND_COMPONENTS) + set(_MPI_FIND_${LANG} TRUE) + elseif( ${LANG} IN_LIST MPI_FIND_COMPONENTS) + set(_MPI_FIND_${LANG} TRUE) + elseif( ${LANG} STREQUAL CXX AND NOT MPI_CXX_SKIP_MPICXX AND MPICXX IN_LIST MPI_FIND_COMPONENTS ) + set(_MPI_FIND_${LANG} TRUE) + else() + set(_MPI_FIND_${LANG} FALSE) + endif() + else() + set(_MPI_FIND_${LANG} FALSE) + endif() + if(_MPI_FIND_${LANG}) + if( ${LANG} STREQUAL CXX AND NOT MPICXX IN_LIST MPI_FIND_COMPONENTS ) + set(MPI_CXX_SKIP_MPICXX FALSE CACHE BOOL "If true, the MPI-2 C++ bindings are disabled using definitions.") + mark_as_advanced(MPI_CXX_SKIP_MPICXX) + endif() + if(NOT (MPI_${LANG}_LIB_NAMES AND (MPI_${LANG}_INCLUDE_PATH OR MPI_${LANG}_INCLUDE_DIRS OR MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS))) + if(NOT MPI_${LANG}_COMPILER AND NOT MPI_ASSUME_NO_BUILTIN_MPI) + # Should the imported targets be empty, we effectively try whether the compiler supports MPI on its own, which is the case on e.g. + # Cray PrgEnv. + _MPI_create_imported_target(${LANG}) + _MPI_check_lang_works(${LANG}) + + # If the compiler can build MPI code on its own, it functions as an MPI compiler and we'll set the variable to point to it. + if(MPI_${LANG}_WORKS) + set(MPI_${LANG}_COMPILER "${CMAKE_${LANG}_COMPILER}" CACHE FILEPATH "MPI compiler for ${LANG}" FORCE) + endif() + endif() + + # If the user specified a library name we assume they prefer that library over a wrapper. If not, they can disable skipping manually. + if(NOT DEFINED MPI_SKIP_COMPILER_WRAPPER AND MPI_GUESS_LIBRARY_NAME) + set(MPI_SKIP_COMPILER_WRAPPER TRUE) + endif() + if(NOT MPI_SKIP_COMPILER_WRAPPER) + if(MPI_${LANG}_COMPILER) + # If the user supplies a compiler *name* instead of an absolute path, assume that we need to find THAT compiler. + if (NOT IS_ABSOLUTE "${MPI_${LANG}_COMPILER}") + # Get rid of our default list of names and just search for the name the user wants. + set(_MPI_${LANG}_COMPILER_NAMES "${MPI_${LANG}_COMPILER}") + unset(MPI_${LANG}_COMPILER CACHE) + endif() + # If the user specifies a compiler, we don't want to try to search libraries either. + set(MPI_PINNED_COMPILER TRUE) + else() + set(MPI_PINNED_COMPILER FALSE) + endif() + + # If we have an MPI base directory, we'll try all compiler names in that one first. + # This should prevent mixing different MPI environments + if(_MPI_BASE_DIR) + find_program(MPI_${LANG}_COMPILER + NAMES ${_MPI_${LANG}_COMPILER_NAMES} + PATH_SUFFIXES bin sbin + HINTS ${_MPI_BASE_DIR} + NO_DEFAULT_PATH + DOC "MPI compiler for ${LANG}" + ) + endif() + + # If the base directory did not help (for example because the mpiexec isn't in the same directory as the compilers), + # we shall try searching in the default paths. + find_program(MPI_${LANG}_COMPILER + NAMES ${_MPI_${LANG}_COMPILER_NAMES} + PATH_SUFFIXES bin sbin + DOC "MPI compiler for ${LANG}" + ) + + if(MPI_${LANG}_COMPILER STREQUAL CMAKE_${LANG}_COMPILER) + set(MPI_SKIP_GUESSING TRUE) + elseif(MPI_${LANG}_COMPILER) + _MPI_interrogate_compiler(${LANG}) + else() + set(MPI_${LANG}_WRAPPER_FOUND FALSE) + endif() + else() + set(MPI_${LANG}_WRAPPER_FOUND FALSE) + set(MPI_PINNED_COMPILER FALSE) + endif() + + if(NOT MPI_${LANG}_WRAPPER_FOUND AND NOT MPI_PINNED_COMPILER) + # For C++, we may use the settings for C. Should a given compiler wrapper for C++ not exist, but one for C does, we copy over the + # settings for C. An MPI distribution that is in this situation would be IBM Platform MPI. + if("${LANG}" STREQUAL "CXX" AND MPI_C_WRAPPER_FOUND) + set(MPI_${LANG}_COMPILE_OPTIONS ${MPI_C_COMPILE_OPTIONS} CACHE STRING "MPI ${LANG} compilation options" ) + set(MPI_${LANG}_COMPILE_DEFINITIONS ${MPI_C_COMPILE_DEFINITIONS} CACHE STRING "MPI ${LANG} compilation definitions" ) + set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_C_INCLUDE_DIRS} CACHE STRING "MPI ${LANG} additional include directories") + set(MPI_${LANG}_LINK_FLAGS ${MPI_C_LINK_FLAGS} CACHE STRING "MPI ${LANG} linker flags" ) + set(MPI_${LANG}_LIB_NAMES ${MPI_C_LIB_NAMES} CACHE STRING "MPI ${LANG} libraries to link against" ) + set(MPI_${LANG}_WRAPPER_FOUND TRUE) + elseif(NOT MPI_SKIP_GUESSING) + _MPI_guess_settings(${LANG}) + endif() + endif() + endif() + + _MPI_split_include_dirs(${LANG}) + if(NOT MPI_${LANG}_COMPILER STREQUAL CMAKE_${LANG}_COMPILER) + _MPI_assemble_include_dirs(${LANG}) + _MPI_assemble_libraries(${LANG}) + endif() + _MPI_adjust_compile_definitions(${LANG}) + # We always create imported targets even if they're empty + _MPI_create_imported_target(${LANG}) + + if(NOT MPI_${LANG}_WORKS) + _MPI_check_lang_works(${LANG}) + endif() + + # Next, we'll initialize the MPI variables that have not been previously set. + set(MPI_${LANG}_COMPILE_OPTIONS "" CACHE STRING "MPI ${LANG} compilation flags" ) + set(MPI_${LANG}_COMPILE_DEFINITIONS "" CACHE STRING "MPI ${LANG} compilation definitions" ) + set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "" CACHE STRING "MPI ${LANG} additional include directories") + set(MPI_${LANG}_LINK_FLAGS "" CACHE STRING "MPI ${LANG} linker flags" ) + set(MPI_${LANG}_LIB_NAMES "" CACHE STRING "MPI ${LANG} libraries to link against" ) + mark_as_advanced(MPI_${LANG}_COMPILE_OPTIONS MPI_${LANG}_COMPILE_DEFINITIONS MPI_${LANG}_LINK_FLAGS + MPI_${LANG}_LIB_NAMES MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS MPI_${LANG}_COMPILER) + + # If we've found MPI, then we'll perform additional analysis: Determine the MPI version, MPI library version, supported + # MPI APIs (i.e. MPI-2 C++ bindings). For Fortran we also need to find specific parameters if we're under MPI-3. + if(MPI_${LANG}_WORKS) + if("${LANG}" STREQUAL "CXX" AND NOT DEFINED MPI_MPICXX_FOUND) + if(NOT MPI_CXX_SKIP_MPICXX AND NOT MPI_CXX_VALIDATE_SKIP_MPICXX) + _MPI_try_staged_settings(${LANG} test_mpi MPICXX FALSE) + if(MPI_RESULT_${LANG}_test_mpi_MPICXX) + set(MPI_MPICXX_FOUND TRUE) + else() + set(MPI_MPICXX_FOUND FALSE) + endif() + else() + set(MPI_MPICXX_FOUND FALSE) + endif() + endif() + + # At this point, we know the bindings present but not the MPI version or anything else. + if(NOT DEFINED MPI_${LANG}_VERSION) + unset(MPI_${LANG}_VERSION_MAJOR) + unset(MPI_${LANG}_VERSION_MINOR) + endif() + set(MPI_BIN_FOLDER ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindMPI) + + # For Fortran, we'll want to use the most modern MPI binding to test capabilities other than the + # Fortran parameters, since those depend on the method of consumption. + # For C++, we can always use the C bindings, and should do so, since the C++ bindings do not exist in MPI-3 + # whereas the C bindings do, and the C++ bindings never offered any feature advantage over their C counterparts. + if("${LANG}" STREQUAL "Fortran") + if(MPI_${LANG}_HAVE_F08_MODULE) + set(MPI_${LANG}_HIGHEST_METHOD F08_MODULE) + elseif(MPI_${LANG}_HAVE_F90_MODULE) + set(MPI_${LANG}_HIGHEST_METHOD F90_MODULE) + else() + set(MPI_${LANG}_HIGHEST_METHOD F77_HEADER) + endif() + + # Another difference between C and Fortran is that we can't use the preprocessor to determine whether MPI_VERSION + # and MPI_SUBVERSION are provided. These defines did not exist in MPI 1.0 and 1.1 and therefore might not + # exist. For C/C++, test_mpi.c will handle the MPI_VERSION extraction, but for Fortran, we need mpiver.f90. + if(NOT DEFINED MPI_${LANG}_VERSION) + _MPI_try_staged_settings(${LANG} mpiver ${MPI_${LANG}_HIGHEST_METHOD} FALSE) + if(MPI_RESULT_${LANG}_mpiver_${MPI_${LANG}_HIGHEST_METHOD}) + file(STRINGS ${MPI_BIN_FOLDER}/mpiver_${LANG}.bin _MPI_VERSION_STRING LIMIT_COUNT 1 REGEX "INFO:MPI-VER") + if("${_MPI_VERSION_STRING}" MATCHES ".*INFO:MPI-VER\\[([0-9]+)\\.([0-9]+)\\].*") + set(MPI_${LANG}_VERSION_MAJOR "${CMAKE_MATCH_1}") + set(MPI_${LANG}_VERSION_MINOR "${CMAKE_MATCH_2}") + set(MPI_${LANG}_VERSION "${MPI_${LANG}_VERSION_MAJOR}.${MPI_${LANG}_VERSION_MINOR}") + endif() + endif() + endif() + + # Finally, we want to find out which capabilities a given interface supports, compare the MPI-3 standard. + # This is determined by interface specific parameters MPI_SUBARRAYS_SUPPORTED and MPI_ASYNC_PROTECTS_NONBLOCKING + # and might vary between the different methods of consumption. + if(MPI_DETERMINE_Fortran_CAPABILITIES AND NOT MPI_Fortran_CAPABILITIES_DETERMINED) + foreach(mpimethod IN ITEMS F08_MODULE F90_MODULE F77_HEADER) + if(MPI_${LANG}_HAVE_${mpimethod}) + set(MPI_${LANG}_${mpimethod}_SUBARRAYS FALSE) + set(MPI_${LANG}_${mpimethod}_ASYNCPROT FALSE) + _MPI_try_staged_settings(${LANG} fortranparam_mpi ${mpimethod} TRUE) + if(MPI_RESULT_${LANG}_fortranparam_mpi_${mpimethod} AND + NOT "${MPI_RUN_RESULT_${LANG}_fortranparam_mpi_${mpimethod}}" STREQUAL "FAILED_TO_RUN") + if("${MPI_RUN_OUTPUT_${LANG}_fortranparam_mpi_${mpimethod}}" MATCHES + ".*INFO:SUBARRAYS\\[ *([TF]) *\\]-ASYNCPROT\\[ *([TF]) *\\].*") + if("${CMAKE_MATCH_1}" STREQUAL "T") + set(MPI_${LANG}_${mpimethod}_SUBARRAYS TRUE) + endif() + if("${CMAKE_MATCH_2}" STREQUAL "T") + set(MPI_${LANG}_${mpimethod}_ASYNCPROT TRUE) + endif() + endif() + endif() + endif() + endforeach() + set(MPI_Fortran_CAPABILITIES_DETERMINED TRUE) + endif() + else() + set(MPI_${LANG}_HIGHEST_METHOD normal) + + # By the MPI-2 standard, MPI_VERSION and MPI_SUBVERSION are valid for both C and C++ bindings. + if(NOT DEFINED MPI_${LANG}_VERSION) + file(STRINGS ${MPI_BIN_FOLDER}/test_mpi_${LANG}.bin _MPI_VERSION_STRING LIMIT_COUNT 1 REGEX "INFO:MPI-VER") + if("${_MPI_VERSION_STRING}" MATCHES ".*INFO:MPI-VER\\[([0-9]+)\\.([0-9]+)\\].*") + set(MPI_${LANG}_VERSION_MAJOR "${CMAKE_MATCH_1}") + set(MPI_${LANG}_VERSION_MINOR "${CMAKE_MATCH_2}") + set(MPI_${LANG}_VERSION "${MPI_${LANG}_VERSION_MAJOR}.${MPI_${LANG}_VERSION_MINOR}") + endif() + endif() + endif() + + unset(MPI_BIN_FOLDER) + + # At this point, we have dealt with determining the MPI version and parameters for each Fortran method available. + # The one remaining issue is to determine which MPI library is installed. + # Determining the version and vendor of the MPI library is only possible via MPI_Get_library_version() at runtime, + # and therefore we cannot do this while cross-compiling (a user may still define MPI__LIBRARY_VERSION_STRING + # themselves and we'll attempt splitting it, which is equivalent to provide the try_run output). + # It's also worth noting that the installed version string can depend on the language, or on the system the binary + # runs on if MPI is not statically linked. + if(MPI_DETERMINE_LIBRARY_VERSION AND NOT MPI_${LANG}_LIBRARY_VERSION_STRING) + _MPI_try_staged_settings(${LANG} libver_mpi ${MPI_${LANG}_HIGHEST_METHOD} TRUE) + if(MPI_RESULT_${LANG}_libver_mpi_${MPI_${LANG}_HIGHEST_METHOD} AND + "${MPI_RUN_RESULT_${LANG}_libver_mpi_${MPI_${LANG}_HIGHEST_METHOD}}" EQUAL "0") + string(STRIP "${MPI_RUN_OUTPUT_${LANG}_libver_mpi_${MPI_${LANG}_HIGHEST_METHOD}}" + MPI_${LANG}_LIBRARY_VERSION_STRING) + else() + set(MPI_${LANG}_LIBRARY_VERSION_STRING "NOTFOUND") + endif() + endif() + endif() + + set(MPI_${LANG}_FIND_QUIETLY ${MPI_FIND_QUIETLY}) + set(MPI_${LANG}_FIND_VERSION ${MPI_FIND_VERSION}) + set(MPI_${LANG}_FIND_VERSION_EXACT ${MPI_FIND_VERSION_EXACT}) + + unset(MPI_${LANG}_REQUIRED_VARS) + if (MPI_${LANG}_WRAPPER_FOUND OR MPI_${LANG}_GUESS_FOUND) + foreach(mpilibname IN LISTS MPI_${LANG}_LIB_NAMES) + list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${mpilibname}_LIBRARY") + endforeach() + list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_LIB_NAMES") + if("${LANG}" STREQUAL "Fortran") + # For Fortran we only need one of the module or header directories to have *some* support for MPI. + if(NOT MPI_${LANG}_MODULE_DIR) + list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_F77_HEADER_DIR") + endif() + if(NOT MPI_${LANG}_F77_HEADER_DIR) + list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_MODULE_DIR") + endif() + else() + list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_HEADER_DIR") + endif() + if(MPI_${LANG}_ADDITIONAL_INCLUDE_VARS) + foreach(mpiincvar IN LISTS MPI_${LANG}_ADDITIONAL_INCLUDE_VARS) + list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${mpiincvar}_INCLUDE_DIR") + endforeach() + endif() + # Append the works variable now. If the settings did not work, this will show up properly. + list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_WORKS") + else() + # If the compiler worked implicitly, use its path as output. + # Should the compiler variable be set, we also require it to work. + list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_COMPILER") + if(MPI_${LANG}_COMPILER) + list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${LANG}_WORKS") + endif() + endif() + find_package_handle_standard_args(MPI_${LANG} REQUIRED_VARS ${MPI_${LANG}_REQUIRED_VARS} + VERSION_VAR MPI_${LANG}_VERSION) + + if(DEFINED MPI_${LANG}_VERSION) + if(NOT _MPI_MIN_VERSION OR _MPI_MIN_VERSION VERSION_GREATER MPI_${LANG}_VERSION) + set(_MPI_MIN_VERSION MPI_${LANG}_VERSION) + endif() + endif() + endif() +endforeach() + +unset(_MPI_REQ_VARS) +foreach(LANG IN ITEMS C CXX Fortran) + if((NOT MPI_FIND_COMPONENTS AND CMAKE_${LANG}_COMPILER_LOADED) OR LANG IN_LIST MPI_FIND_COMPONENTS) + list(APPEND _MPI_REQ_VARS "MPI_${LANG}_FOUND") + endif() +endforeach() + +if(MPICXX IN_LIST MPI_FIND_COMPONENTS) + list(APPEND _MPI_REQ_VARS "MPI_MPICXX_FOUND") +endif() + +find_package_handle_standard_args(MPI + REQUIRED_VARS ${_MPI_REQ_VARS} + VERSION_VAR ${_MPI_MIN_VERSION} + HANDLE_COMPONENTS) + +#============================================================================= +# More backward compatibility stuff + +# For compatibility reasons, we also define MPIEXEC +set(MPIEXEC "${MPIEXEC_EXECUTABLE}") + +# Copy over MPI__INCLUDE_PATH from the assembled INCLUDE_DIRS. +foreach(LANG IN ITEMS C CXX Fortran) + if(MPI_${LANG}_FOUND) + set(MPI_${LANG}_INCLUDE_PATH "${MPI_${LANG}_INCLUDE_DIRS}") + unset(MPI_${LANG}_COMPILE_FLAGS) + if(MPI_${LANG}_COMPILE_OPTIONS) + set(MPI_${LANG}_COMPILE_FLAGS "${MPI_${LANG}_COMPILE_OPTIONS}") + endif() + if(MPI_${LANG}_COMPILE_DEFINITIONS) + foreach(_MPI_DEF IN LISTS MPI_${LANG}_COMPILE_DEFINITIONS) + string(APPEND MPI_${LANG}_COMPILE_FLAGS " -D${_MPI_DEF}") + endforeach() + endif() + endif() +endforeach() + +# Bare MPI sans ${LANG} vars are set to CXX then C, depending on what was found. +# This mimics the behavior of the old language-oblivious FindMPI. +set(_MPI_OLD_VARS COMPILER INCLUDE_PATH COMPILE_FLAGS LINK_FLAGS LIBRARIES) +if (MPI_CXX_FOUND) + foreach (var ${_MPI_OLD_VARS}) + set(MPI_${var} ${MPI_CXX_${var}}) + endforeach() +elseif (MPI_C_FOUND) + foreach (var ${_MPI_OLD_VARS}) + set(MPI_${var} ${MPI_C_${var}}) + endforeach() +endif() + +# Chop MPI_LIBRARIES into the old-style MPI_LIBRARY and MPI_EXTRA_LIBRARY, and set them in cache. +if (MPI_LIBRARIES) + list(GET MPI_LIBRARIES 0 MPI_LIBRARY_WORK) + set(MPI_LIBRARY "${MPI_LIBRARY_WORK}") + unset(MPI_LIBRARY_WORK) +else() + set(MPI_LIBRARY "MPI_LIBRARY-NOTFOUND") +endif() + +list(LENGTH MPI_LIBRARIES MPI_NUMLIBS) +if (MPI_NUMLIBS GREATER 1) + set(MPI_EXTRA_LIBRARY_WORK "${MPI_LIBRARIES}") + list(REMOVE_AT MPI_EXTRA_LIBRARY_WORK 0) + set(MPI_EXTRA_LIBRARY "${MPI_EXTRA_LIBRARY_WORK}") + unset(MPI_EXTRA_LIBRARY_WORK) +else() + set(MPI_EXTRA_LIBRARY "MPI_EXTRA_LIBRARY-NOTFOUND") +endif() +#============================================================================= + +# unset these vars to cleanup namespace +unset(_MPI_OLD_VARS) +unset(_MPI_PREFIX_PATH) +unset(_MPI_BASE_DIR) +foreach (lang C CXX Fortran) + unset(_MPI_${LANG}_COMPILER_NAMES) +endforeach() + +cmake_policy(POP) diff --git a/config/cmake_ext_mod/FindMPI/fortranparam_mpi.f90.in b/config/cmake_ext_mod/FindMPI/fortranparam_mpi.f90.in new file mode 100644 index 0000000..30f912c --- /dev/null +++ b/config/cmake_ext_mod/FindMPI/fortranparam_mpi.f90.in @@ -0,0 +1,4 @@ + program mpi_ver + @MPI_Fortran_INCLUDE_LINE@ + print *, 'INFO:SUBARRAYS[', MPI_SUBARRAYS_SUPPORTED, ']-ASYNCPROT[', MPI_ASYNC_PROTECTS_NONBLOCKING, ']' + end program mpi_ver diff --git a/config/cmake_ext_mod/FindMPI/libver_mpi.c b/config/cmake_ext_mod/FindMPI/libver_mpi.c new file mode 100644 index 0000000..be9d19d --- /dev/null +++ b/config/cmake_ext_mod/FindMPI/libver_mpi.c @@ -0,0 +1,19 @@ +#include + +#ifdef __cplusplus +#include +#else +#include +#endif + +int main(int argc, char* argv[]) +{ + char mpilibver_str[MPI_MAX_LIBRARY_VERSION_STRING]; + int mpilibver_len; + MPI_Get_library_version(mpilibver_str, &mpilibver_len); +#ifdef __cplusplus + std::puts(mpilibver_str); +#else + puts(mpilibver_str); +#endif +} diff --git a/config/cmake_ext_mod/FindMPI/libver_mpi.f90.in b/config/cmake_ext_mod/FindMPI/libver_mpi.f90.in new file mode 100644 index 0000000..7938587 --- /dev/null +++ b/config/cmake_ext_mod/FindMPI/libver_mpi.f90.in @@ -0,0 +1,7 @@ + program mpi_ver + @MPI_Fortran_INCLUDE_LINE@ + character(len=MPI_MAX_LIBRARY_VERSION_STRING) :: mpilibver_str + integer(kind=MPI_INTEGER_KIND) :: ierror, reslen + call MPI_GET_LIBRARY_VERSION(mpilibver_str, reslen, ierror) + print *, mpilibver_str + end program mpi_ver diff --git a/config/cmake_ext_mod/FindMPI/mpiver.f90.in b/config/cmake_ext_mod/FindMPI/mpiver.f90.in new file mode 100644 index 0000000..a254523 --- /dev/null +++ b/config/cmake_ext_mod/FindMPI/mpiver.f90.in @@ -0,0 +1,10 @@ + program mpi_ver + @MPI_Fortran_INCLUDE_LINE@ + integer(kind=kind(MPI_VERSION)), parameter :: zero = ichar('0') + character, dimension(17), parameter :: mpiver_str =& + (/ 'I', 'N', 'F', 'O', ':', 'M', 'P', 'I', '-', 'V', 'E', 'R', '[', & + char(zero + MPI_VERSION), & + '.', & + char(zero + MPI_SUBVERSION), ']' /) + print *, mpiver_str + end program mpi_ver diff --git a/config/cmake_ext_mod/FindMPI/test_mpi.c b/config/cmake_ext_mod/FindMPI/test_mpi.c new file mode 100644 index 0000000..b8a308a --- /dev/null +++ b/config/cmake_ext_mod/FindMPI/test_mpi.c @@ -0,0 +1,37 @@ +#include + +#ifdef __cplusplus +#include +#else +#include +#endif + +#if defined(MPI_VERSION) && defined(MPI_SUBVERSION) +const char mpiver_str[] = { 'I', 'N', + 'F', 'O', + ':', 'M', + 'P', 'I', + '-', 'V', + 'E', 'R', + '[', ('0' + MPI_VERSION), + '.', ('0' + MPI_SUBVERSION), + ']', '\0' }; +#endif + +int main(int argc, char* argv[]) +{ +#if defined(MPI_VERSION) && defined(MPI_SUBVERSION) +#ifdef __cplusplus + std::puts(mpiver_str); +#else + puts(mpiver_str); +#endif +#endif +#ifdef TEST_MPI_MPICXX + MPI::MPI_Init(&argc, &argv); + MPI::MPI_Finalize(); +#else + MPI_Init(&argc, &argv); + MPI_Finalize(); +#endif +} diff --git a/config/cmake_ext_mod/FindMPI/test_mpi.f90.in b/config/cmake_ext_mod/FindMPI/test_mpi.f90.in new file mode 100644 index 0000000..4d43a04 --- /dev/null +++ b/config/cmake_ext_mod/FindMPI/test_mpi.f90.in @@ -0,0 +1,6 @@ + program hello + @MPI_Fortran_INCLUDE_LINE@ + integer@MPI_Fortran_INTEGER_LINE@ ierror + call MPI_INIT(ierror) + call MPI_FINALIZE(ierror) + end program -- cgit v0.12 From 7222e5f6a3efee53f6747bc66072129b11c529fe Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 1 Nov 2017 15:16:37 -0500 Subject: Change to local path --- config/cmake_ext_mod/FindMPI.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/cmake_ext_mod/FindMPI.cmake b/config/cmake_ext_mod/FindMPI.cmake index 61ab4a4..b67bcae 100644 --- a/config/cmake_ext_mod/FindMPI.cmake +++ b/config/cmake_ext_mod/FindMPI.cmake @@ -911,7 +911,7 @@ endmacro() function(_MPI_try_staged_settings LANG MPI_TEST_FILE_NAME MODE RUN_BINARY) set(WORK_DIR "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindMPI") - set(SRC_DIR "${CMAKE_ROOT}/Modules/FindMPI") + set(SRC_DIR "${CMAKE_CURRENT_LIST_DIR}/Modules/FindMPI") set(BIN_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindMPI/${MPI_TEST_FILE_NAME}_${LANG}.bin") unset(MPI_TEST_COMPILE_DEFINITIONS) if("${LANG}" STREQUAL "Fortran") -- cgit v0.12 From 3de5fa266216fd67999e0ddfcbaad12d4a6d9175 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 1 Nov 2017 15:24:35 -0500 Subject: Correct path --- config/cmake_ext_mod/FindMPI.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/cmake_ext_mod/FindMPI.cmake b/config/cmake_ext_mod/FindMPI.cmake index b67bcae..8084472 100644 --- a/config/cmake_ext_mod/FindMPI.cmake +++ b/config/cmake_ext_mod/FindMPI.cmake @@ -911,7 +911,7 @@ endmacro() function(_MPI_try_staged_settings LANG MPI_TEST_FILE_NAME MODE RUN_BINARY) set(WORK_DIR "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindMPI") - set(SRC_DIR "${CMAKE_CURRENT_LIST_DIR}/Modules/FindMPI") + set(SRC_DIR "${CMAKE_CURRENT_LIST_DIR}/FindMPI") set(BIN_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindMPI/${MPI_TEST_FILE_NAME}_${LANG}.bin") unset(MPI_TEST_COMPILE_DEFINITIONS) if("${LANG}" STREQUAL "Fortran") -- cgit v0.12 From a862d195c35730bdef924a776531e2879678a7a6 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 1 Nov 2017 16:11:03 -0500 Subject: Correct path --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 20ff228..2ec2b2d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -630,8 +630,8 @@ if (HDF5_ENABLE_PARALLEL) # and once set, they are cached as false and not regenerated set (CMAKE_REQUIRED_LIBRARIES "${MPI_C_LIBRARIES}" ) # Used by Fortran + MPI - CHECK_SYMBOL_EXISTS (MPI_Comm_c2f "${MPI_C_INCLUDE_PATH}/mpi.h" H5_HAVE_MPI_MULTI_LANG_Comm) - CHECK_SYMBOL_EXISTS (MPI_Info_c2f "${MPI_C_INCLUDE_PATH}/mpi.h" H5_HAVE_MPI_MULTI_LANG_Info) + CHECK_SYMBOL_EXISTS (MPI_Comm_c2f "${MPI_C_INCLUDE_DIRS}/mpi.h" H5_HAVE_MPI_MULTI_LANG_Comm) + CHECK_SYMBOL_EXISTS (MPI_Info_c2f "${MPI_C_INCLUDE_DIRS}/mpi.h" H5_HAVE_MPI_MULTI_LANG_Info) else () message (STATUS "Parallel libraries not found") endif () -- cgit v0.12 From 03be1267190d2c83379e2ed09d0b86acd3b23388 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 2 Nov 2017 10:07:58 -0500 Subject: HDFFV-10321 change note added. --- release_docs/RELEASE.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index b66355e..54867af 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -170,6 +170,17 @@ Bug Fixes since HDF5-1.10.1 release Configuration ------------- + - cmake MPI + + CMake implementation for MPI was problematic and would create incorrect + MPI library references in the hdf5 libraries. + + Reworked the CMake MPI code to properly create CMake targets.Also merged + the latest CMake FindMPI.cmake changes to the local copy. This is necessary + until HDF changes the CMake minimum to 3.9 or greater. + + (ADB - 2017/11/02, HDFFV-10321) + - cmake Too many commands for POST_BUILD step caused command line to be -- cgit v0.12 From 0fe3dc9b278ad7392502ddce438be97eb3e692e2 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 2 Nov 2017 10:25:22 -0500 Subject: HDFFV-10321 Correct fortran link var --- CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ec2b2d..f21f8b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -877,6 +877,8 @@ if (EXISTS "${HDF5_SOURCE_DIR}/fortran" AND IS_DIRECTORY "${HDF5_SOURCE_DIR}/for endif () include (${HDF_RESOURCES_DIR}/HDF5UseFortran.cmake) + set (LINK_Fortran_LIBS ${LINK_LIBS}) + set (LINK_Fortran_SHARED_LIBS ${LINK_SHARED_LIBS}) if (HDF5_ENABLE_F2003) if (NOT FORTRAN_HAVE_ISO_C_BINDING) @@ -886,8 +888,8 @@ if (EXISTS "${HDF5_SOURCE_DIR}/fortran" AND IS_DIRECTORY "${HDF5_SOURCE_DIR}/for # Parallel IO usage requires MPI to be Linked and Included if (H5_HAVE_PARALLEL) - set (LINK_Fortran_LIBS ${LINK_LIBS} ${MPI_Fortran_LIBRARIES}) - set (LINK_Fortran_SHARED_LIBS ${LINK_SHARED_LIBS} ${MPI_Fortran_LIBRARIES}) + set (LINK_Fortran_LIBS ${LINK_Fortran_LIBS} ${MPI_Fortran_LIBRARIES}) + set (LINK_Fortran_SHARED_LIBS ${LINK_Fortran_SHARED_LIBS} ${MPI_Fortran_LIBRARIES}) if (MPI_Fortran_LINK_FLAGS) set (CMAKE_Fortran_EXE_LINKER_FLAGS "${MPI_Fortran_LINK_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}") endif () -- cgit v0.12 From ede110390a615520daff36885012b0210a4c8cdc Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 2 Nov 2017 10:34:40 -0500 Subject: New cmake MPI files --- MANIFEST | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MANIFEST b/MANIFEST index c325e64..4270479 100644 --- a/MANIFEST +++ b/MANIFEST @@ -3107,6 +3107,12 @@ ./config/cmake_ext_mod/NSIS.template.in ./config/cmake_ext_mod/runTest.cmake ./config/cmake_ext_mod/version.plist.in +./config/cmake_ext_mod/FindMPI/fortranparam_mpi.f90.in +./config/cmake_ext_mod/FindMPI/libver_mpi.c +./config/cmake_ext_mod/FindMPI/libver_mpi.f90.in +./config/cmake_ext_mod/FindMPI/mpiver.f90.in +./config/cmake_ext_mod/FindMPI/test_mpi.c +./config/cmake_ext_mod/FindMPI/test_mpi.f90.in # CMake-specific User Files ./config/cmake/UserMacros/Windows_MT.cmake -- cgit v0.12 From 47f4db394bc488d4311a6e1bf833c90abf3247b9 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 2 Nov 2017 10:54:43 -0500 Subject: Add missing dir reference --- fortran/examples/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fortran/examples/CMakeLists.txt b/fortran/examples/CMakeLists.txt index 82cbd5c..426df7e 100644 --- a/fortran/examples/CMakeLists.txt +++ b/fortran/examples/CMakeLists.txt @@ -81,7 +81,7 @@ foreach (example ${F2003_examples}) set_target_properties (f03_ex_${example} PROPERTIES LINKER_LANGUAGE Fortran FOLDER examples/fortran03 - Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY} + Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/static ) if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) add_executable (f03_ex_${example}-shared ${HDF5_F90_EXAMPLES_SOURCE_DIR}/${example}.f90) -- cgit v0.12 From 0d2fd7ae0cd19c2eb040a4ad733b50c7652639cc Mon Sep 17 00:00:00 2001 From: Richard Warren Date: Thu, 2 Nov 2017 12:33:08 -0400 Subject: Make a fix to allow CMake testing which does not use relative directories. --- hl/tools/h5watch/CMakeLists.txt | 2 +- testpar/t_pread.c | 46 +++++++++++++++++++++++++++++++++++------ 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/hl/tools/h5watch/CMakeLists.txt b/hl/tools/h5watch/CMakeLists.txt index fde40e3..6b8d5f2 100644 --- a/hl/tools/h5watch/CMakeLists.txt +++ b/hl/tools/h5watch/CMakeLists.txt @@ -5,7 +5,7 @@ PROJECT (HDF5_HL_TOOLS_H5WATCH) # Define Sources #----------------------------------------------------------------------------- set (H5WATCH_SOURCES - ${HDF5_HL_TOOLS_H5WATCH_SOURCE_DIR}/h5watch + ${HDF5_HL_TOOLS_H5WATCH_SOURCE_DIR}/h5watch.c ) #-- Add h5watch program diff --git a/testpar/t_pread.c b/testpar/t_pread.c index b5a84f2..a527503 100644 --- a/testpar/t_pread.c +++ b/testpar/t_pread.c @@ -55,6 +55,9 @@ fools.\n"; static int generate_test_file(MPI_Comm comm, int mpi_rank, int group); static int test_parallel_read(MPI_Comm comm, int mpi_rank, int group); +static char *test_argv0 = NULL; +extern char *dirname(char *path); /* Avoids additional includes */ + /*------------------------------------------------------------------------- * Function: generate_test_file @@ -392,9 +395,29 @@ generate_test_file( MPI_Comm comm, int mpi_rank, int group_id ) if ( pass ) { char cmd[256]; - - HDsprintf(cmd, "../tools/src/h5jam/h5jam -i %s -u %s -o %s", - data_filename, prolog_filename, reloc_data_filename); + char exe_path[256]; + char *relative_path = "../tools/src/h5jam"; + char *exe_dirname = relative_path; + + /* We're checking for the existance of the h5jam utility + * With Cmake testing, all binaries are in the same directory + * e.g. the same location where this executable is found. + * We've copied the argv[0] argument and check to see + * if h5jam is co-located here. Otherwise, the autotools + * put things into directories, hence the relative path. + */ + if (test_argv0 != NULL) { + HDstrncpy(exe_path, test_argv0, sizeof(exe_path)); + if ( (exe_dirname = (char *)dirname(exe_path)) != NULL) { + HDsprintf(cmd, "%s/h5jam", exe_dirname); + if ( HDaccess(cmd, F_OK) != 0) + exe_dirname = relative_path; + } + } + HDsprintf(cmd, "%s/h5jam -i %s -u %s -o %s", + exe_dirname, + data_filename, + prolog_filename, reloc_data_filename); if ( system(cmd) != 0 ) { pass = FALSE; @@ -680,7 +703,7 @@ test_parallel_read(MPI_Comm comm, int mpi_rank, int group_id) } /* collect results from other processes. - * Only overwrite the failure message if no preveious error + * Only overwrite the failure message if no previous error * has been detected */ local_failure = ( pass ? 0 : 1 ); @@ -761,6 +784,17 @@ main( int argc, char **argv) int split_size; MPI_Comm group_comm = MPI_COMM_WORLD; + /* I don't believe that argv[0] can ever be NULL. + * It should thus be safe to dup and save as a check + * for cmake testing. Note that in our Cmake builds, + * all executables are located in the same directory. + * We assume (but we'll check) that the h5jam utility + * is in the directory as this executable. If that + * isn't true, then we can use a relative path that + * should be valid for the autotools environment. + */ + test_argv0 = HDstrdup(argv[0]); + if ( (MPI_Init(&argc, &argv)) != MPI_SUCCESS) { HDfprintf(stderr, "FATAL: Unable to initialize MPI\n"); HDexit(EXIT_FAILURE); @@ -785,11 +819,11 @@ main( int argc, char **argv) HDfprintf(stdout, "========================================\n"); } - if ( mpi_size < 4 ) { + if ( mpi_size < 3 ) { if ( mpi_rank == 0 ) { - HDprintf(" Need at least 4 processes. Exiting.\n"); + HDprintf(" Need at least 3 processes. Exiting.\n"); } goto finish; } -- cgit v0.12 From b8cbd11dfb229e79b8a9b22ce45dac3e9a735590 Mon Sep 17 00:00:00 2001 From: "M. Scot Breitenfeld" Date: Thu, 2 Nov 2017 14:26:44 -0500 Subject: Fix for Intel 18 Fortran compilation error. HDFFV-10322 --- fortran/src/H5f90global.F90 | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/fortran/src/H5f90global.F90 b/fortran/src/H5f90global.F90 index dd2b171..629418a 100644 --- a/fortran/src/H5f90global.F90 +++ b/fortran/src/H5f90global.F90 @@ -142,10 +142,7 @@ MODULE H5GLOBAL INTEGER(HID_T), DIMENSION(PREDEF_TYPES_LEN) :: predef_types EQUIVALENCE (predef_types(1), H5T_NATIVE_INTEGER_KIND(1)) - EQUIVALENCE (predef_types(2), H5T_NATIVE_INTEGER_KIND(2)) - EQUIVALENCE (predef_types(3), H5T_NATIVE_INTEGER_KIND(3)) - EQUIVALENCE (predef_types(4), H5T_NATIVE_INTEGER_KIND(4)) - EQUIVALENCE (predef_types(5), H5T_NATIVE_INTEGER_KIND(5)) + ! EQUIVALENCE predef_types(2:5) are unnecessary and violate the standard EQUIVALENCE (predef_types(6), H5T_NATIVE_INTEGER) EQUIVALENCE (predef_types(7), H5T_NATIVE_REAL) EQUIVALENCE (predef_types(8), H5T_NATIVE_DOUBLE) -- cgit v0.12 From df03ecb01d721863f79c86969c56c77d3a846ab2 Mon Sep 17 00:00:00 2001 From: "M. Scot Breitenfeld" Date: Fri, 3 Nov 2017 09:10:26 -0500 Subject: HDFFV-10322 --- release_docs/RELEASE.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 54867af..ca65d7f 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -197,7 +197,8 @@ Bug Fixes since HDF5-1.10.1 release Fortran -------- - - + - Fixed compilation errors when using Intel 18 Fortran compilers + (MSB - 2017/11/3, HDFFV-10322) Tools ----- -- cgit v0.12 From 275fabe6319783b672b6d6e54c1cf68796012224 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 6 Nov 2017 09:28:28 -0600 Subject: Correct issue number --- release_docs/RELEASE.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index ca65d7f..a7465e5 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -225,7 +225,7 @@ Bug Fixes since HDF5-1.10.1 release Added another parameter to the 'UD=' option to set the flag by default to '0' or H5Z_FLAG_MANDATORY, the other choice is '1' or H5Z_FLAG_OPTIONAL. - (ADB - 2017/08/31, HDFFV-10276) + (ADB - 2017/08/31, HDFFV-10269) - h5ls -- cgit v0.12 From e8239b2de56158d9124972ad1ed74aec76aaee25 Mon Sep 17 00:00:00 2001 From: lrknox Date: Mon, 6 Nov 2017 16:26:03 -0600 Subject: Add check for realtimeOutput environment variable set containing characters to indicate test output should be piped through tee to chklog files in order to send output to stdout as tests run instead of waiting to cat chklog file to stdout when each set of tests is completed. This should stop buildbot from timing out when a test set doesn't complete in less than 20 minutes. --- config/conclude.am | 84 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 58 insertions(+), 26 deletions(-) diff --git a/config/conclude.am b/config/conclude.am index 55b805a..97aef27 100644 --- a/config/conclude.am +++ b/config/conclude.am @@ -16,27 +16,25 @@ ## Textually included at the end of most HDF5 Makefiles.am. ## Contains build rules. -# Automake needs to be taught how to build lib, dyn, progs and tests targets. +# Automake needs to be taught how to build lib, progs and tests targets. # These will be filled in automatically for the most part (e.g., # lib_LIBRARIES are built for lib target), but EXTRA_LIB, EXTRA_PROG, and # EXTRA_TEST variables are supplied to allow the user to force targets to # be built at certain times. LIB = $(lib_LIBRARIES) $(lib_LTLIBRARIES) $(noinst_LIBRARIES) \ $(noinst_LTLIBRARIES) $(check_LIBRARIES) $(check_LTLIBRARIES) $(EXTRA_LIB) -DYN = $(dyn_LTLIBRARIES) PROGS = $(bin_PROGRAMS) $(bin_SCRIPTS) $(noinst_PROGRAMS) $(noinst_SCRIPTS) \ $(EXTRA_PROG) chk_TESTS = $(check_PROGRAMS) $(check_SCRIPTS) $(EXTRA_TEST) TESTS = $(TEST_PROG) $(TEST_SCRIPT) $(EXTRA_TEST) -dyndir=$(libdir) TEST_EXTENSIONS = .sh SH_LOG_COMPILER = $(SHELL) AM_SH_LOG_FLAGS = +REALTIMEOUTPUT = $(realtimeOutput) # lib/progs/tests targets recurse into subdirectories. build-* targets # build files in this directory. -build-dyn: $(DYN) build-lib: $(LIB) build-progs: $(LIB) $(PROGS) build-tests: $(LIB) $(PROGS) $(chk_TESTS) @@ -44,7 +42,7 @@ build-tests: $(LIB) $(PROGS) $(chk_TESTS) # General rule for recursive building targets. # BUILT_SOURCES contain targets that need to be built before anything else # in the directory (e.g., for Fortran type detection) -lib dyn progs tests check-s check-p :: $(BUILT_SOURCES) +lib progs tests check-s check-p :: $(BUILT_SOURCES) @$(MAKE) $(AM_MAKEFLAGS) build-$@ || exit 1; @for d in X $(SUBDIRS); do \ if test $$d != X && test $$d != .; then \ @@ -127,28 +125,62 @@ $(TEST_PROG_CHKEXE) $(TEST_PROG_PARA_CHKEXE) dummy.chkexe_: if $(top_srcdir)/bin/newer $(@:.chkexe_=.chkexe) $${tname}; then \ echo "No need to test $${tname} again."; \ else \ - echo "============================" > $${log}; \ - if test "X$(FORTRAN_API)" = "Xyes"; then \ - echo "Fortran API: Testing $(HDF5_DRIVER) $${tname} $(TEST_FLAGS)"; \ - echo "Fortran API: $(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" >> $${log}; \ - elif test "X$(CXX_API)" = "Xyes"; then \ - echo "C++ API: Testing $(HDF5_DRIVER) $${tname} $(TEST_FLAGS)"; \ - echo "C++ API: $(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" >> $${log};\ - else \ - echo "Testing $(HDF5_DRIVER) $${tname} $(TEST_FLAGS)"; \ - echo "$(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" >> $${log}; \ - fi; \ - echo "============================" >> $${log}; \ - srcdir="$(srcdir)" \ - $(TIME) $(RUNEXEC) ./$${tname} $(TEST_FLAGS) >> $${log} 2>&1 \ - && touch $(@:.chkexe_=.chkexe) || \ - (test $$HDF5_Make_Ignore && echo "*** Error ignored") || \ - (cat $${log} && false) || exit 1; \ + if test -n "$(REALTIMEOUTPUT)"; then \ + echo "============================" |& tee $${log}; \ + else \ + echo "============================" > $${log}; \ + fi; \ + if test "X$(FORTRAN_API)" = "Xyes"; then \ + echo "Fortran API: Testing $(HDF5_DRIVER) $${tname} $(TEST_FLAGS)"; \ + if test -n "$(REALTIMEOUTPUT)"; then \ + echo "Fortran API: $(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" |& tee -a $${log}; \ + else \ + echo "Fortran API: $(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" >> $${log}; \ + fi; \ + elif test "X$(CXX_API)" = "Xyes"; then \ + echo "C++ API: Testing $(HDF5_DRIVER) $${tname} $(TEST_FLAGS)"; \ + if test -n "$(REALTIMEOUTPUT)"; then \ + echo "C++ API: $(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" |& tee -a $${log};\ + else \ + echo "C++ API: $(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" >> $${log};\ + fi; \ + else \ + echo "Testing $(HDF5_DRIVER) $${tname} $(TEST_FLAGS)"; \ + if test -n "$(REALTIMEOUTPUT)"; then \ + echo "$(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" |& tee -a $${log}; \ + else \ + echo "$(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" >> $${log}; \ + fi; \ + fi; \ + if test -n "$(REALTIMEOUTPUT)"; then \ + echo "============================" |& tee -a $${log}; \ + else \ + echo "============================" >> $${log}; \ + fi; \ + if test -n "$(REALTIMEOUTPUT)"; then \ + srcdir="$(srcdir)" \ + $(TIME) $(RUNEXEC) ./$${tname} $(TEST_FLAGS) |& tee -a $${log} 2>&1 \ + && touch $(@:.chkexe_=.chkexe) || \ + (test $$HDF5_Make_Ignore && echo "*** Error ignored") || \ + (cat $${log} && false) || exit 1; \ + else \ + srcdir="$(srcdir)" \ + $(TIME) $(RUNEXEC) ./$${tname} $(TEST_FLAGS) >> $${log} 2>&1 \ + && touch $(@:.chkexe_=.chkexe) || \ + (test $$HDF5_Make_Ignore && echo "*** Error ignored") || \ + (cat $${log} && false) || exit 1; \ + fi; \ echo "" >> $${log}; \ - echo "Finished testing $${tname} $(TEST_FLAGS)" >> $${log}; \ - echo "============================" >> $${log}; \ - echo "Finished testing $${tname} $(TEST_FLAGS)"; \ - cat $${log}; \ + if test -n "$(REALTIMEOUTPUT)"; then \ + echo "Finished testing $${tname} $(TEST_FLAGS)" |& tee -a $${log}; \ + echo "============================" |& tee -a $${log}; \ + else \ + echo "Finished testing $${tname} $(TEST_FLAGS)" >> $${log}; \ + echo "============================" >> $${log}; \ + fi; \ + if test -z "$(REALTIMEOUTPUT)"; then \ + cat $${log}; \ + fi; \ fi; \ fi -- cgit v0.12 From d0e32b545c41dcc36a69ab146b54b55e7ac9dc07 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Tue, 7 Nov 2017 17:56:27 -0800 Subject: Split internal H5R functionality into H5Rint.c. --- MANIFEST | 1 + src/CMakeLists.txt | 1 + src/H5Oprivate.h | 4 +- src/H5R.c | 765 +++------------------------------------------------- src/H5Rdeprec.c | 118 ++++----- src/H5Rint.c | 767 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/H5Rmodule.h | 11 +- src/H5Rpkg.h | 14 +- src/H5Rprivate.h | 34 ++- src/H5Rpublic.h | 73 ++--- src/H5Sprivate.h | 4 +- src/H5Tprivate.h | 4 +- src/H5Zprivate.h | 7 +- src/Makefile.am | 2 +- 14 files changed, 951 insertions(+), 854 deletions(-) create mode 100644 src/H5Rint.c diff --git a/MANIFEST b/MANIFEST index 4270479..753d33d 100644 --- a/MANIFEST +++ b/MANIFEST @@ -810,6 +810,7 @@ ./src/H5PLextern.h ./src/H5R.c ./src/H5Rdeprec.c +./src/H5Rint.c ./src/H5Rmodule.h ./src/H5Rpkg.h ./src/H5Rprivate.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4be86a9..7ee423b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -532,6 +532,7 @@ IDE_GENERATED_PROPERTIES ("H5PL" "${H5PL_HDRS}" "${H5PL_SOURCES}" ) set (H5R_SOURCES ${HDF5_SRC_DIR}/H5R.c ${HDF5_SRC_DIR}/H5Rdeprec.c + ${HDF5_SRC_DIR}/H5Rint.c ) set (H5R_HDRS ${HDF5_SRC_DIR}/H5Rpkg.h diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 563f8fa..314ee04 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -24,6 +24,9 @@ #ifndef _H5Oprivate_H #define _H5Oprivate_H +/* Early typedefs to avoid circular dependencies */ +typedef struct H5O_t H5O_t; + /* Include the public header file for this API */ #include "H5Opublic.h" /* Object header functions */ @@ -44,7 +47,6 @@ /* Forward references of package typedefs */ typedef struct H5O_msg_class_t H5O_msg_class_t; typedef struct H5O_mesg_t H5O_mesg_t; -typedef struct H5O_t H5O_t; /* Values used to create the shared message & attribute heaps */ /* (Note that these parameters have been tuned so that the resulting heap ID diff --git a/src/H5R.c b/src/H5R.c index b000183..8b42b35 100644 --- a/src/H5R.c +++ b/src/H5R.c @@ -21,16 +21,13 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Gprivate.h" /* Groups */ -#include "H5HGprivate.h" /* Global Heaps */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Rpkg.h" /* References */ -#include "H5Sprivate.h" /* Dataspaces */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Rpkg.h" /* References */ +#include "H5Sprivate.h" /* Dataspaces */ /****************/ @@ -47,20 +44,11 @@ /* Local Prototypes */ /********************/ -static herr_t H5R_create(void *ref, H5G_loc_t *loc, const char *name, - H5R_type_t ref_type, H5S_t *space, hid_t dxpl_id); -static H5S_t * H5R_get_region(H5F_t *file, hid_t dxpl_id, const void *_ref); -static ssize_t H5R_get_name(H5F_t *file, hid_t lapl_id, hid_t dxpl_id, hid_t id, - H5R_type_t ref_type, const void *_ref, char *name, size_t size); - /*********************/ /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - /*****************************/ /* Library Private Variables */ @@ -71,274 +59,6 @@ hbool_t H5_PKG_INIT_VAR = FALSE; /* Local Variables */ /*******************/ -/* Reference ID class */ -static const H5I_class_t H5I_REFERENCE_CLS[1] = {{ - H5I_REFERENCE, /* ID class value */ - 0, /* Class flags */ - 0, /* # of reserved IDs for class */ - NULL /* Callback routine for closing objects of this class */ -}}; - -/* Flag indicating "top" of interface has been initialized */ -static hbool_t H5R_top_package_initialize_s = FALSE; - - - -/*-------------------------------------------------------------------------- -NAME - H5R__init_package -- Initialize interface-specific information -USAGE - herr_t H5R__init_package() - -RETURNS - Non-negative on success/Negative on failure -DESCRIPTION - Initializes any interface-specific data or routines. - ---------------------------------------------------------------------------*/ -herr_t -H5R__init_package(void) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - /* Initialize the atom group for the file IDs */ - if(H5I_register_type(H5I_REFERENCE_CLS) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to initialize interface") - - /* Mark "top" of interface as initialized, too */ - H5R_top_package_initialize_s = TRUE; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5R__init_package() */ - - -/*-------------------------------------------------------------------------- - NAME - H5R_top_term_package - PURPOSE - Terminate various H5R objects - USAGE - void H5R_top_term_package() - RETURNS - void - DESCRIPTION - Release IDs for the atom group, deferring full interface shutdown - until later (in H5R_term_package). - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - Can't report errors... - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -int -H5R_top_term_package(void) -{ - int n = 0; - - FUNC_ENTER_NOAPI_NOINIT_NOERR - - if(H5R_top_package_initialize_s) { - if(H5I_nmembers(H5I_REFERENCE) > 0) { - (void)H5I_clear_type(H5I_REFERENCE, FALSE, FALSE); - n++; /*H5I*/ - } /* end if */ - - /* Mark closed */ - if(0 == n) - H5R_top_package_initialize_s = FALSE; - } /* end if */ - - FUNC_LEAVE_NOAPI(n) -} /* end H5R_top_term_package() */ - - -/*-------------------------------------------------------------------------- - NAME - H5R_term_package - PURPOSE - Terminate various H5R objects - USAGE - void H5R_term_package() - RETURNS - void - DESCRIPTION - Release the atom group and any other resources allocated. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - Can't report errors... - - Finishes shutting down the interface, after H5R_top_term_package() - is called - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -int -H5R_term_package(void) -{ - int n = 0; - - FUNC_ENTER_NOAPI_NOINIT_NOERR - - if(H5_PKG_INIT_VAR) { - /* Sanity checks */ - HDassert(0 == H5I_nmembers(H5I_REFERENCE)); - HDassert(FALSE == H5R_top_package_initialize_s); - - /* Destroy the reference id group */ - n += (H5I_dec_type_ref(H5I_REFERENCE) > 0); - - /* Mark closed */ - if(0 == n) - H5_PKG_INIT_VAR = FALSE; - } /* end if */ - - FUNC_LEAVE_NOAPI(n) -} /* end H5R_term_package() */ - - -/*-------------------------------------------------------------------------- - NAME - H5R_create - PURPOSE - Creates a particular kind of reference for the user - USAGE - herr_t H5R_create(ref, loc, name, ref_type, space) - void *ref; OUT: Reference created - H5G_loc_t *loc; IN: File location used to locate object pointed to - const char *name; IN: Name of object at location LOC_ID of object - pointed to - H5R_type_t ref_type; IN: Type of reference to create - H5S_t *space; IN: Dataspace ID with selection, used for Dataset - Region references. - - RETURNS - Non-negative on success/Negative on failure - DESCRIPTION - Creates a particular type of reference specified with REF_TYPE, in the - space pointed to by REF. The LOC_ID and NAME are used to locate the object - pointed to and the SPACE_ID is used to choose the region pointed to (for - Dataset Region references). - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -static herr_t -H5R_create(void *_ref, H5G_loc_t *loc, const char *name, H5R_type_t ref_type, H5S_t *space, hid_t dxpl_id) -{ - H5G_loc_t obj_loc; /* Group hier. location of object */ - H5G_name_t path; /* Object group hier. path */ - H5O_loc_t oloc; /* Object object location */ - hbool_t obj_found = FALSE; /* Object location found */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - HDassert(_ref); - HDassert(loc); - HDassert(name); - HDassert(ref_type > H5R_BADTYPE && ref_type < H5R_MAXTYPE); - - /* Set up object location to fill in */ - obj_loc.oloc = &oloc; - obj_loc.path = &path; - H5G_loc_reset(&obj_loc); - - /* Find the object */ - if(H5G_loc_find(loc, name, &obj_loc, H5P_DEFAULT, dxpl_id) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_NOTFOUND, FAIL, "object not found") - obj_found = TRUE; - - switch(ref_type) { - case H5R_OBJECT: - { - hobj_ref_t *ref = (hobj_ref_t *)_ref; /* Get pointer to correct type of reference struct */ - - *ref = obj_loc.oloc->addr; - break; - } - - case H5R_DATASET_REGION: - { - H5HG_t hobjid; /* Heap object ID */ - hdset_reg_ref_t *ref = (hdset_reg_ref_t *)_ref; /* Get pointer to correct type of reference struct */ - hssize_t buf_size; /* Size of buffer needed to serialize selection */ - uint8_t *p; /* Pointer to OID to store */ - uint8_t *buf; /* Buffer to store serialized selection in */ - unsigned heapid_found; /* Flag for non-zero heap ID found */ - unsigned u; /* local index */ - - /* Set up information for dataset region */ - - /* Return any previous heap block to the free list if we are garbage collecting */ - if(H5F_GC_REF(loc->oloc->file)) { - /* Check for an existing heap ID in the reference */ - for(u = 0, heapid_found = 0, p = (uint8_t *)ref; u < H5R_DSET_REG_REF_BUF_SIZE; u++) - if(p[u] != 0) { - heapid_found = 1; - break; - } /* end if */ - - if(heapid_found != 0) { -/* Return heap block to free list */ - } /* end if */ - } /* end if */ - - /* Zero the heap ID out, may leak heap space if user is re-using reference and doesn't have garbage collection on */ - HDmemset(ref, 0, H5R_DSET_REG_REF_BUF_SIZE); - - /* Get the amount of space required to serialize the selection */ - if((buf_size = H5S_SELECT_SERIAL_SIZE(space)) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "Invalid amount of space for serializing selection") - - /* Increase buffer size to allow for the dataset OID */ - buf_size += (hssize_t)sizeof(haddr_t); - - /* Allocate the space to store the serialized information */ - H5_CHECK_OVERFLOW(buf_size, hssize_t, size_t); - if(NULL == (buf = (uint8_t *)H5MM_malloc((size_t)buf_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - - /* Serialize information for dataset OID into heap buffer */ - p = (uint8_t *)buf; - H5F_addr_encode(loc->oloc->file, &p, obj_loc.oloc->addr); - - /* Serialize the selection into heap buffer */ - if(H5S_SELECT_SERIALIZE(space, &p) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "Unable to serialize selection") - - /* Save the serialized buffer for later */ - H5_CHECK_OVERFLOW(buf_size, hssize_t, size_t); - if(H5HG_insert(loc->oloc->file, dxpl_id, (size_t)buf_size, buf, &hobjid) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_WRITEERROR, FAIL, "Unable to serialize selection") - - /* Serialize the heap ID and index for storage in the file */ - p = (uint8_t *)ref; - H5F_addr_encode(loc->oloc->file, &p, hobjid.addr); - UINT32ENCODE(p, hobjid.idx); - - /* Free the buffer we serialized data in */ - H5MM_xfree(buf); - break; - } - - case H5R_BADTYPE: - case H5R_MAXTYPE: - default: - HDassert("unknown reference type" && 0); - HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "internal error (unknown reference type)") - } /* end switch */ - -done: - if(obj_found) - H5G_loc_free(&obj_loc); - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5R_create() */ - /*-------------------------------------------------------------------------- NAME @@ -378,23 +98,23 @@ H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t H5TRACE5("e", "*xi*sRti", ref, loc_id, name, ref_type, space_id); /* Check args */ - if(ref == NULL) + if (ref == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") - if(H5G_loc(loc_id, &loc) < 0) + if (H5G_loc(loc_id, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!name || !*name) + if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name given") - if(ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE) + if (ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type") - if(ref_type != H5R_OBJECT && ref_type != H5R_DATASET_REGION) + if (ref_type != H5R_OBJECT && ref_type != H5R_DATASET_REGION) HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "reference type not supported") - if(space_id == (-1) && ref_type == H5R_DATASET_REGION) + if (space_id == (-1) && ref_type == H5R_DATASET_REGION) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "reference region dataspace id must be valid") - if(space_id != (-1) && (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))) + if (space_id != (-1) && (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") /* Create reference */ - if((ret_value = H5R_create(ref, &loc, name, ref_type, space, H5AC_ind_read_dxpl_id)) < 0) + if ((ret_value = H5R_create(ref, &loc, name, ref_type, space, H5AC_ind_read_dxpl_id)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to create reference") done: @@ -404,166 +124,6 @@ done: /*-------------------------------------------------------------------------- NAME - H5R_dereference - PURPOSE - Opens the HDF5 object referenced. - USAGE - hid_t H5R_dereference(ref) - H5F_t *file; IN: File the object being dereferenced is within - H5R_type_t ref_type; IN: Type of reference - void *ref; IN: Reference to open. - - RETURNS - Valid ID on success, Negative on failure - DESCRIPTION - Given a reference to some object, open that object and return an ID for - that object. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - Currently only set up to work with references to datasets - EXAMPLES - REVISION LOG - Raymond Lu - 13 July 2011 - I added the OAPL_ID parameter for the object being referenced. It only - supports dataset access property list currently. - - M. Scot Breitenfeld - 3 March 2015 - Added a check for undefined reference pointer. ---------------------------------------------------------------------------*/ -hid_t -H5R_dereference(H5F_t *file, hid_t oapl_id, hid_t dxpl_id, H5R_type_t ref_type, const void *_ref, hbool_t app_ref) -{ - H5O_loc_t oloc; /* Object location */ - H5G_name_t path; /* Path of object */ - H5G_loc_t loc; /* Group location */ - unsigned rc; /* Reference count of object */ - H5O_type_t obj_type; /* Type of object */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - HDassert(_ref); - HDassert(ref_type > H5R_BADTYPE && ref_type < H5R_MAXTYPE); - HDassert(file); - - /* Initialize the object location */ - H5O_loc_reset(&oloc); - oloc.file = file; - - switch(ref_type) { - case H5R_OBJECT: - oloc.addr = *(const hobj_ref_t *)_ref; /* Only object references currently supported */ - if(!H5F_addr_defined(oloc.addr) || oloc.addr == 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Undefined reference pointer") - break; - - case H5R_DATASET_REGION: - { - H5HG_t hobjid; /* Heap object ID */ - uint8_t *buf; /* Buffer to store serialized selection in */ - const uint8_t *p; /* Pointer to OID to store */ - - /* Get the heap ID for the dataset region */ - p = (const uint8_t *)_ref; - H5F_addr_decode(oloc.file, &p, &(hobjid.addr)); - UINT32DECODE(p, hobjid.idx); - - if(!H5F_addr_defined(hobjid.addr) || hobjid.addr == 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Undefined reference pointer") - - /* Get the dataset region from the heap (allocate inside routine) */ - if(NULL == (buf = (uint8_t *)H5HG_read(oloc.file, dxpl_id, &hobjid, NULL, NULL))) - HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, FAIL, "Unable to read dataset region information") - - /* Get the object oid for the dataset */ - p = buf; - H5F_addr_decode(oloc.file, &p, &(oloc.addr)); - - /* Free the buffer allocated in H5HG_read() */ - H5MM_xfree(buf); - } /* end case */ - break; - - case H5R_BADTYPE: - case H5R_MAXTYPE: - default: - HDassert("unknown reference type" && 0); - HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "internal error (unknown reference type)") - } /* end switch */ - - /* Get the # of links for object, and its type */ - /* (To check to make certain that this object hasn't been deleted since the reference was created) */ - if(H5O_get_rc_and_type(&oloc, dxpl_id, &rc, &obj_type) < 0 || 0 == rc) - HGOTO_ERROR(H5E_REFERENCE, H5E_LINKCOUNT, FAIL, "dereferencing deleted object") - - /* Construct a group location for opening the object */ - H5G_name_reset(&path); - loc.oloc = &oloc; - loc.path = &path; - - /* Open the object */ - switch(obj_type) { - case H5O_TYPE_GROUP: - { - H5G_t *group; /* Pointer to group to open */ - - if(NULL == (group = H5G_open(&loc, dxpl_id))) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "not found") - - /* Create an atom for the group */ - if((ret_value = H5I_register(H5I_GROUP, group, app_ref)) < 0) { - H5G_close(group); - HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, FAIL, "can't register group") - } /* end if */ - } /* end case */ - break; - - case H5O_TYPE_NAMED_DATATYPE: - { - H5T_t *type; /* Pointer to datatype to open */ - - if(NULL == (type = H5T_open(&loc, dxpl_id))) - HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL, "not found") - - /* Create an atom for the datatype */ - if((ret_value = H5I_register(H5I_DATATYPE, type, app_ref)) < 0) { - H5T_close(type); - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "can't register datatype") - } /* end if */ - } /* end case */ - break; - - case H5O_TYPE_DATASET: - { - H5D_t *dset; /* Pointer to dataset to open */ - - /* Open the dataset */ - if(NULL == (dset = H5D_open(&loc, oapl_id, dxpl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, FAIL, "not found") - - /* Create an atom for the dataset */ - if((ret_value = H5I_register(H5I_DATASET, dset, app_ref)) < 0) { - H5D_close(dset); - HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "can't register dataset") - } /* end if */ - } /* end case */ - break; - - case H5O_TYPE_UNKNOWN: - case H5O_TYPE_NTYPES: - default: - HGOTO_ERROR(H5E_REFERENCE, H5E_BADTYPE, FAIL, "can't identify type of object referenced") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5R_dereference() */ - - -/*-------------------------------------------------------------------------- - NAME H5Rdereference2 PURPOSE Opens the HDF5 object referenced. @@ -601,24 +161,24 @@ H5Rdereference2(hid_t obj_id, hid_t oapl_id, H5R_type_t ref_type, const void *_r H5TRACE4("i", "iiRt*x", obj_id, oapl_id, ref_type, _ref); /* Check args */ - if(H5G_loc(obj_id, &loc) < 0) + if (H5G_loc(obj_id, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(oapl_id < 0) + if (oapl_id < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") - if(ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE) + if (ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type") - if(_ref == NULL) + if (_ref == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") /* Verify access property list and get correct dxpl */ - if(H5P_verify_apl_and_dxpl(&oapl_id, H5P_CLS_DACC, &dxpl_id, obj_id, FALSE) < 0) + if (H5P_verify_apl_and_dxpl(&oapl_id, H5P_CLS_DACC, &dxpl_id, obj_id, FALSE) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "can't set access and transfer property lists") /* Get the file pointer from the entry */ file = loc.oloc->file; /* Create reference */ - if((ret_value = H5R_dereference(file, oapl_id, dxpl_id, ref_type, _ref, TRUE)) < 0) + if ((ret_value = H5R_dereference(file, oapl_id, dxpl_id, ref_type, _ref, TRUE)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to dereference object") done: @@ -628,75 +188,6 @@ done: /*-------------------------------------------------------------------------- NAME - H5R_get_region - PURPOSE - Retrieves a dataspace with the region pointed to selected. - USAGE - H5S_t *H5R_get_region(file, ref_type, ref) - H5F_t *file; IN: File the object being dereferenced is within - void *ref; IN: Reference to open. - - RETURNS - Pointer to the dataspace on success, NULL on failure - DESCRIPTION - Given a reference to some object, creates a copy of the dataset pointed - to's dataspace and defines a selection in the copy which is the region - pointed to. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -static H5S_t * -H5R_get_region(H5F_t *file, hid_t dxpl_id, const void *_ref) -{ - H5O_loc_t oloc; /* Object location */ - const uint8_t *p; /* Pointer to OID to store */ - H5HG_t hobjid; /* Heap object ID */ - uint8_t *buf = NULL; /* Buffer to store serialized selection in */ - H5S_t *ret_value; - - FUNC_ENTER_NOAPI_NOINIT - - HDassert(_ref); - HDassert(file); - - /* Initialize the object location */ - H5O_loc_reset(&oloc); - oloc.file = file; - - /* Get the heap ID for the dataset region */ - p = (const uint8_t *)_ref; - H5F_addr_decode(oloc.file, &p, &(hobjid.addr)); - UINT32DECODE(p, hobjid.idx); - - /* Get the dataset region from the heap (allocate inside routine) */ - if((buf = (uint8_t *)H5HG_read(oloc.file, dxpl_id, &hobjid, NULL, NULL)) == NULL) - HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, NULL, "Unable to read dataset region information") - - /* Get the object oid for the dataset */ - p = buf; - H5F_addr_decode(oloc.file, &p, &(oloc.addr)); - - /* Open and copy the dataset's dataspace */ - if((ret_value = H5S_read(&oloc, dxpl_id)) == NULL) - HGOTO_ERROR(H5E_DATASPACE, H5E_NOTFOUND, NULL, "not found") - - /* Unserialize the selection */ - if(H5S_SELECT_DESERIALIZE(&ret_value, &p) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, NULL, "can't deserialize selection") - -done: - /* Free the buffer allocated in H5HG_read() */ - if(buf) - H5MM_xfree(buf); - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5R_get_region() */ - - -/*-------------------------------------------------------------------------- - NAME H5Rget_region PURPOSE Retrieves a dataspace with the region pointed to selected. @@ -729,19 +220,19 @@ H5Rget_region(hid_t id, H5R_type_t ref_type, const void *ref) H5TRACE3("i", "iRt*x", id, ref_type, ref); /* Check args */ - if(H5G_loc(id, &loc) < 0) + if (H5G_loc(id, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(ref_type != H5R_DATASET_REGION) + if (ref_type != H5R_DATASET_REGION) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type") - if(ref == NULL) + if (ref == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") /* Get the dataspace with the correct region selected */ - if((space = H5R_get_region(loc.oloc->file, H5AC_ind_read_dxpl_id, ref)) == NULL) + if ((space = H5R_get_region(loc.oloc->file, H5AC_ind_read_dxpl_id, ref)) == NULL) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create dataspace") /* Atomize */ - if((ret_value = H5I_register(H5I_DATASPACE, space, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_DATASPACE, space, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom") done: @@ -751,92 +242,6 @@ done: /*-------------------------------------------------------------------------- NAME - H5R_get_obj_type - PURPOSE - Retrieves the type of object that an object reference points to - USAGE - H5O_type_t H5R_get_obj_type(file, ref_type, ref) - H5F_t *file; IN: File the object being dereferenced is within - H5R_type_t ref_type; IN: Type of reference to query - void *ref; IN: Reference to query. - - RETURNS - Success: An object type defined in H5Gpublic.h - Failure: H5G_UNKNOWN - DESCRIPTION - Given a reference to some object, this function returns the type of object - pointed to. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -herr_t -H5R_get_obj_type(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, - const void *_ref, H5O_type_t *obj_type) -{ - H5O_loc_t oloc; /* Object location */ - unsigned rc; /* Reference count of object */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - HDassert(file); - HDassert(_ref); - - /* Initialize the symbol table entry */ - H5O_loc_reset(&oloc); - oloc.file = file; - - switch(ref_type) { - case H5R_OBJECT: - /* Get the object oid */ - oloc.addr = *(const hobj_ref_t *)_ref; /* Only object references currently supported */ - break; - - case H5R_DATASET_REGION: - { - H5HG_t hobjid; /* Heap object ID */ - const uint8_t *p; /* Pointer to reference to decode */ - uint8_t *buf; /* Buffer to store serialized selection in */ - - /* Get the heap ID for the dataset region */ - p = (const uint8_t *)_ref; - H5F_addr_decode(oloc.file, &p, &(hobjid.addr)); - UINT32DECODE(p, hobjid.idx); - - /* Get the dataset region from the heap (allocate inside routine) */ - if((buf = (uint8_t *)H5HG_read(oloc.file, dxpl_id, &hobjid, NULL, NULL)) == NULL) - HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, FAIL, "Unable to read dataset region information") - - /* Get the object oid for the dataset */ - p = buf; - H5F_addr_decode(oloc.file, &p, &(oloc.addr)); - - /* Free the buffer allocated in H5HG_read() */ - H5MM_xfree(buf); - } /* end case */ - break; - - case H5R_BADTYPE: - case H5R_MAXTYPE: - default: - HDassert("unknown reference type" && 0); - HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "internal error (unknown reference type)") - } /* end switch */ - - /* Get the # of links for object, and its type */ - /* (To check to make certain that this object hasn't been deleted since the reference was created) */ - if(H5O_get_rc_and_type(&oloc, dxpl_id, &rc, obj_type) < 0 || 0 == rc) - HGOTO_ERROR(H5E_REFERENCE, H5E_LINKCOUNT, FAIL, "dereferencing deleted object") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5R_get_obj_type() */ - - -/*-------------------------------------------------------------------------- - NAME H5Rget_obj_type2 PURPOSE Retrieves the type of object that an object reference points to @@ -869,16 +274,16 @@ H5Rget_obj_type2(hid_t id, H5R_type_t ref_type, const void *ref, H5TRACE4("e", "iRt*x*Ot", id, ref_type, ref, obj_type); /* Check args */ - if(H5G_loc(id, &loc) < 0) + if (H5G_loc(id, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE) + if (ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type") - if(ref == NULL) + if (ref == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") /* Get the object information */ - if(H5R_get_obj_type(loc.oloc->file, H5AC_ind_read_dxpl_id, ref_type, ref, obj_type) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to determine object type") + if (H5R_get_obj_type(loc.oloc->file, H5AC_ind_read_dxpl_id, ref_type, ref, obj_type) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to determine object type") done: FUNC_LEAVE_API(ret_value) @@ -887,106 +292,6 @@ done: /*-------------------------------------------------------------------------- NAME - H5R_get_name - PURPOSE - Internal routine to determine a name for the object referenced - USAGE - ssize_t H5R_get_name(f, dxpl_id, ref_type, ref, name, size) - H5F_t *f; IN: Pointer to the file that the reference is pointing - into - hid_t lapl_id; IN: LAPL to use for operation - hid_t dxpl_id; IN: DXPL to use for operation - hid_t id; IN: Location ID given for reference - H5R_type_t ref_type; IN: Type of reference - void *ref; IN: Reference to query. - char *name; OUT: Buffer to place name of object referenced - size_t size; IN: Size of name buffer - - RETURNS - Non-negative length of the path on success, Negative on failure - DESCRIPTION - Given a reference to some object, determine a path to the object - referenced in the file. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - This may not be the only path to that object. - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -static ssize_t -H5R_get_name(H5F_t *f, hid_t lapl_id, hid_t dxpl_id, hid_t id, H5R_type_t ref_type, - const void *_ref, char *name, size_t size) -{ - hid_t file_id = H5I_INVALID_HID; /* ID for file that the reference is in */ - H5O_loc_t oloc; /* Object location describing object for reference */ - ssize_t ret_value = -1; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - /* Check args */ - HDassert(f); - HDassert(_ref); - - /* Initialize the object location */ - H5O_loc_reset(&oloc); - oloc.file = f; - - /* Get address for reference */ - switch(ref_type) { - case H5R_OBJECT: - oloc.addr = *(const hobj_ref_t *)_ref; - break; - - case H5R_DATASET_REGION: - { - H5HG_t hobjid; /* Heap object ID */ - uint8_t *buf; /* Buffer to store serialized selection in */ - const uint8_t *p; /* Pointer to OID to store */ - - /* Get the heap ID for the dataset region */ - p = (const uint8_t *)_ref; - H5F_addr_decode(oloc.file, &p, &(hobjid.addr)); - UINT32DECODE(p, hobjid.idx); - - /* Get the dataset region from the heap (allocate inside routine) */ - if((buf = (uint8_t *)H5HG_read(oloc.file, dxpl_id, &hobjid, NULL, NULL)) == NULL) - HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, FAIL, "Unable to read dataset region information") - - /* Get the object oid for the dataset */ - p = buf; - H5F_addr_decode(oloc.file, &p, &(oloc.addr)); - - /* Free the buffer allocated in H5HG_read() */ - H5MM_xfree(buf); - } /* end case */ - break; - - case H5R_BADTYPE: - case H5R_MAXTYPE: - default: - HDassert("unknown reference type" && 0); - HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "internal error (unknown reference type)") - } /* end switch */ - - /* Retrieve file ID for name search */ - if((file_id = H5I_get_file_id(id, FALSE)) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't retrieve file ID") - - /* Get name, length, etc. */ - if((ret_value = H5G_get_name_by_addr(file_id, lapl_id, dxpl_id, &oloc, name, size)) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't determine name") - -done: - /* Close file ID used for search */ - if(file_id > 0 && H5I_dec_ref(file_id) < 0) - HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "can't decrement ref count of temp ID") - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5R_get_name() */ - - -/*-------------------------------------------------------------------------- - NAME H5Rget_name PURPOSE Determines a name for the object referenced @@ -1030,18 +335,18 @@ H5Rget_name(hid_t id, H5R_type_t ref_type, const void *_ref, char *name, H5TRACE5("Zs", "iRt*x*sz", id, ref_type, _ref, name, size); /* Check args */ - if(H5G_loc(id, &loc) < 0) + if (H5G_loc(id, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE) + if (ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type") - if(_ref == NULL) + if (_ref == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") /* Get the file pointer from the entry */ file = loc.oloc->file; /* Get name */ - if((ret_value = H5R_get_name(file, H5P_DEFAULT, H5AC_ind_read_dxpl_id, id, ref_type, _ref, name, size)) < 0) + if ((ret_value = H5R_get_name(file, H5P_DEFAULT, H5AC_ind_read_dxpl_id, id, ref_type, _ref, name, size)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to determine object path") done: diff --git a/src/H5Rdeprec.c b/src/H5Rdeprec.c index 109bbb4..699f8df 100644 --- a/src/H5Rdeprec.c +++ b/src/H5Rdeprec.c @@ -13,11 +13,9 @@ /*------------------------------------------------------------------------- * - * Created: H5Rdeprec.c - * September 13 2007 - * Quincey Koziol + * Created: H5Rdeprec.c * - * Purpose: Deprecated functions from the H5R interface. These + * Purpose: Deprecated functions from the H5R interface. These * functions are here for compatibility purposes and may be * removed in the future. Applications should switch to the * newer APIs. @@ -35,13 +33,16 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Rpkg.h" /* References */ -#include "H5Ppublic.h" /* for using H5P_DATASET_ACCESS_DEFAULT */ +/* Public headers needed by this file */ +#include "H5Ppublic.h" /* Property lists */ + +/* Private headers needed by this file */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Rpkg.h" /* References */ /****************/ @@ -81,29 +82,22 @@ #ifndef H5_NO_DEPRECATED_SYMBOLS -/*-------------------------------------------------------------------------- - NAME - H5Rget_obj_type1 - PURPOSE - Retrieves the type of object that an object reference points to - USAGE - H5G_obj_t H5Rget_obj_type1(id, ref_type, ref) - hid_t id; IN: Dataset reference object is in or location ID of - object that the dataset is located within. - H5R_type_t ref_type; IN: Type of reference to query - void *ref; IN: Reference to query. - - RETURNS - Success: An object type defined in H5Gpublic.h - Failure: H5G_UNKNOWN - DESCRIPTION - Given a reference to some object, this function returns the type of object - pointed to. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ +/*------------------------------------------------------------------------- + * Function: H5Rget_obj_type1 + * + * Purpose: Retrieves the type of the object that an object points to. + * + * Parameters: + * id IN: Dataset reference object is in or location ID of + * object that the dataset is located within + * ref_type IN: Type of reference to query + * ref IN: Reference to query + * + * Return: Success: An object type (as defined in H5Gpublic.h) + * Failure: H5G_UNKNOWN + * + *------------------------------------------------------------------------- + */ H5G_obj_t H5Rget_obj_type1(hid_t id, H5R_type_t ref_type, const void *ref) { @@ -115,16 +109,16 @@ H5Rget_obj_type1(hid_t id, H5R_type_t ref_type, const void *ref) H5TRACE3("Go", "iRt*x", id, ref_type, ref); /* Check args */ - if(H5G_loc(id, &loc) < 0) + if (H5G_loc(id, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "not a location") - if(ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE) + if (ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5G_UNKNOWN, "invalid reference type") - if(ref == NULL) + if (ref == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5G_UNKNOWN, "invalid reference pointer") /* Get the object information */ - if(H5R_get_obj_type(loc.oloc->file, H5AC_ind_read_dxpl_id, ref_type, ref, &obj_type) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, H5G_UNKNOWN, "unable to determine object type") + if (H5R_get_obj_type(loc.oloc->file, H5AC_ind_read_dxpl_id, ref_type, ref, &obj_type) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, H5G_UNKNOWN, "unable to determine object type") /* Set return value */ ret_value = H5G_map_obj_type(obj_type); @@ -134,28 +128,22 @@ done: } /* end H5Rget_obj_type1() */ -/*-------------------------------------------------------------------------- - NAME - H5Rdereference1 - PURPOSE - Opens the HDF5 object referenced. - USAGE - hid_t H5Rdereference1(ref) - hid_t id; IN: Dataset reference object is in or location ID of - object that the dataset is located within. - H5R_type_t ref_type; IN: Type of reference to create - void *ref; IN: Reference to open. - - RETURNS - Valid ID on success, Negative on failure - DESCRIPTION - Given a reference to some object, open that object and return an ID for - that object. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ +/*------------------------------------------------------------------------- + * Function: H5Rdereference1 + * + * Purpose: Opens the HDF5 object referenced. + * + * Parameters: + * id IN: Dataset reference object is in or location ID of + * object that the dataset is located within + * ref_type IN: Type of reference to create + * ref IN: Reference to open + * + * Return: Success: Valid HDF5 ID + * Failure: Negative + * + *------------------------------------------------------------------------- + */ hid_t H5Rdereference1(hid_t obj_id, H5R_type_t ref_type, const void *_ref) { @@ -167,18 +155,18 @@ H5Rdereference1(hid_t obj_id, H5R_type_t ref_type, const void *_ref) H5TRACE3("i", "iRt*x", obj_id, ref_type, _ref); /* Check args */ - if(H5G_loc(obj_id, &loc) < 0) + if (H5G_loc(obj_id, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE) + if (ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type") - if(_ref == NULL) + if (_ref == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") /* Get the file pointer from the entry */ file = loc.oloc->file; /* Create reference */ - if((ret_value = H5R_dereference(file, H5P_DATASET_ACCESS_DEFAULT, H5AC_ind_read_dxpl_id, ref_type, _ref, TRUE)) < 0) + if ((ret_value = H5R_dereference(file, H5P_DATASET_ACCESS_DEFAULT, H5AC_ind_read_dxpl_id, ref_type, _ref, TRUE)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable dereference object") done: diff --git a/src/H5Rint.c b/src/H5Rint.c new file mode 100644 index 0000000..716a573 --- /dev/null +++ b/src/H5Rint.c @@ -0,0 +1,767 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/****************/ +/* Module Setup */ +/****************/ + +#include "H5Rmodule.h" /* This source code file is part of the H5R module */ + + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gprivate.h" /* Groups */ +#include "H5HGprivate.h" /* Global Heaps */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Rpkg.h" /* References */ +#include "H5Sprivate.h" /* Dataspaces */ +#include "H5Tprivate.h" /* Datatypes */ + + +/****************/ +/* Local Macros */ +/****************/ + +/******************/ +/* Local Typedefs */ +/******************/ + +/********************/ +/* Local Prototypes */ +/********************/ + +/*********************/ +/* Package Variables */ +/*********************/ + +/* Package initialization variable */ +hbool_t H5_PKG_INIT_VAR = FALSE; + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/*******************/ +/* Local Variables */ +/*******************/ + +/* Reference ID class + * + * NOTE: H5I_REFERENCE is not used by the library and has been deprecated + * with a tentative removal version of 1.12.0. (DER, July 2017) + */ +static const H5I_class_t H5I_REFERENCE_CLS[1] = {{ + H5I_REFERENCE, /* ID class value */ + 0, /* Class flags */ + 0, /* # of reserved IDs for class */ + NULL /* Callback routine for closing objects of this class */ +}}; + +/* Flag indicating "top" of interface has been initialized */ +static hbool_t H5R_top_package_initialize_s = FALSE; + + +/*-------------------------------------------------------------------------- +NAME + H5R__init_package -- Initialize interface-specific information +USAGE + herr_t H5R__init_package() + +RETURNS + Non-negative on success/Negative on failure +DESCRIPTION + Initializes any interface-specific data or routines. + +--------------------------------------------------------------------------*/ +herr_t +H5R__init_package(void) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* Initialize the atom group for the file IDs */ + if (H5I_register_type(H5I_REFERENCE_CLS) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to initialize interface") + + /* Mark "top" of interface as initialized, too */ + H5R_top_package_initialize_s = TRUE; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5R__init_package() */ + + +/*-------------------------------------------------------------------------- + NAME + H5R_top_term_package + PURPOSE + Terminate various H5R objects + USAGE + void H5R_top_term_package() + RETURNS + void + DESCRIPTION + Release IDs for the atom group, deferring full interface shutdown + until later (in H5R_term_package). + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + Can't report errors... + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +int +H5R_top_term_package(void) +{ + int n = 0; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + if (H5R_top_package_initialize_s) { + if (H5I_nmembers(H5I_REFERENCE) > 0) { + (void)H5I_clear_type(H5I_REFERENCE, FALSE, FALSE); + n++; + } + + /* Mark closed */ + if (0 == n) + H5R_top_package_initialize_s = FALSE; + } + + FUNC_LEAVE_NOAPI(n) +} /* end H5R_top_term_package() */ + + +/*-------------------------------------------------------------------------- + NAME + H5R_term_package + PURPOSE + Terminate various H5R objects + USAGE + void H5R_term_package() + RETURNS + void + DESCRIPTION + Release the atom group and any other resources allocated. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + Can't report errors... + + Finishes shutting down the interface, after H5R_top_term_package() + is called + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +int +H5R_term_package(void) +{ + int n = 0; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + if (H5_PKG_INIT_VAR) { + /* Sanity checks */ + HDassert(0 == H5I_nmembers(H5I_REFERENCE)); + HDassert(FALSE == H5R_top_package_initialize_s); + + /* Destroy the reference id group */ + n += (H5I_dec_type_ref(H5I_REFERENCE) > 0); + + /* Mark closed */ + if (0 == n) + H5_PKG_INIT_VAR = FALSE; + } + + FUNC_LEAVE_NOAPI(n) +} /* end H5R_term_package() */ + + +/*-------------------------------------------------------------------------- + NAME + H5R_create + PURPOSE + Creates a particular kind of reference for the user + USAGE + herr_t H5R_create(ref, loc, name, ref_type, space) + void *ref; OUT: Reference created + H5G_loc_t *loc; IN: File location used to locate object pointed to + const char *name; IN: Name of object at location LOC_ID of object + pointed to + H5R_type_t ref_type; IN: Type of reference to create + H5S_t *space; IN: Dataspace ID with selection, used for Dataset + Region references. + + RETURNS + Non-negative on success/Negative on failure + DESCRIPTION + Creates a particular type of reference specified with REF_TYPE, in the + space pointed to by REF. The LOC_ID and NAME are used to locate the object + pointed to and the SPACE_ID is used to choose the region pointed to (for + Dataset Region references). + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +herr_t +H5R_create(void *_ref, H5G_loc_t *loc, const char *name, H5R_type_t ref_type, H5S_t *space, hid_t dxpl_id) +{ + H5G_loc_t obj_loc; /* Group hier. location of object */ + H5G_name_t path; /* Object group hier. path */ + H5O_loc_t oloc; /* Object object location */ + hbool_t obj_found = FALSE; /* Object location found */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + HDassert(_ref); + HDassert(loc); + HDassert(name); + HDassert(ref_type > H5R_BADTYPE && ref_type < H5R_MAXTYPE); + + /* Set up object location to fill in */ + obj_loc.oloc = &oloc; + obj_loc.path = &path; + H5G_loc_reset(&obj_loc); + + /* Find the object */ + if (H5G_loc_find(loc, name, &obj_loc, H5P_DEFAULT, dxpl_id) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_NOTFOUND, FAIL, "object not found") + obj_found = TRUE; + + switch (ref_type) { + case H5R_OBJECT: + { + hobj_ref_t *ref = (hobj_ref_t *)_ref; /* Get pointer to correct type of reference struct */ + + *ref = obj_loc.oloc->addr; + break; + } + + case H5R_DATASET_REGION: + { + H5HG_t hobjid; /* Heap object ID */ + hdset_reg_ref_t *ref = (hdset_reg_ref_t *)_ref; /* Get pointer to correct type of reference struct */ + hssize_t buf_size; /* Size of buffer needed to serialize selection */ + uint8_t *p; /* Pointer to OID to store */ + uint8_t *buf; /* Buffer to store serialized selection in */ + unsigned heapid_found; /* Flag for non-zero heap ID found */ + unsigned u; /* local index */ + + /* Set up information for dataset region */ + + /* Return any previous heap block to the free list if we are + * garbage collecting + */ + if (H5F_GC_REF(loc->oloc->file)) { + /* Check for an existing heap ID in the reference */ + for (u = 0, heapid_found = 0, p = (uint8_t *)ref; u < H5R_DSET_REG_REF_BUF_SIZE; u++) + if (p[u] != 0) { + heapid_found = 1; + break; + } + + if (heapid_found != 0) { + /* Return heap block to free list */ + } + } + + /* Zero the heap ID out, may leak heap space if user is re-using + * reference and doesn't have garbage collection turned on + */ + HDmemset(ref, 0, H5R_DSET_REG_REF_BUF_SIZE); + + /* Get the amount of space required to serialize the selection */ + if ((buf_size = H5S_SELECT_SERIAL_SIZE(space)) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "Invalid amount of space for serializing selection") + + /* Increase buffer size to allow for the dataset OID */ + buf_size += (hssize_t)sizeof(haddr_t); + + /* Allocate the space to store the serialized information */ + H5_CHECK_OVERFLOW(buf_size, hssize_t, size_t); + if (NULL == (buf = (uint8_t *)H5MM_malloc((size_t)buf_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + + /* Serialize information for dataset OID into heap buffer */ + p = (uint8_t *)buf; + H5F_addr_encode(loc->oloc->file, &p, obj_loc.oloc->addr); + + /* Serialize the selection into heap buffer */ + if (H5S_SELECT_SERIALIZE(space, &p) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOPY, FAIL, "Unable to serialize selection") + + /* Save the serialized buffer for later */ + H5_CHECK_OVERFLOW(buf_size, hssize_t, size_t); + if (H5HG_insert(loc->oloc->file, dxpl_id, (size_t)buf_size, buf, &hobjid) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_WRITEERROR, FAIL, "Unable to serialize selection") + + /* Serialize the heap ID and index for storage in the file */ + p = (uint8_t *)ref; + H5F_addr_encode(loc->oloc->file, &p, hobjid.addr); + UINT32ENCODE(p, hobjid.idx); + + /* Free the buffer we serialized data in */ + H5MM_xfree(buf); + break; + } /* end case H5R_DATASET_REGION */ + + case H5R_BADTYPE: + case H5R_MAXTYPE: + default: + HDassert("unknown reference type" && 0); + HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "internal error (unknown reference type)") + } /* end switch */ + +done: + if (obj_found) + H5G_loc_free(&obj_loc); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5R_create() */ + + +/*-------------------------------------------------------------------------- + NAME + H5R_dereference + PURPOSE + Opens the HDF5 object referenced. + USAGE + hid_t H5R_dereference(ref) + H5F_t *file; IN: File the object being dereferenced is within + H5R_type_t ref_type; IN: Type of reference + void *ref; IN: Reference to open. + + RETURNS + Valid ID on success, Negative on failure + DESCRIPTION + Given a reference to some object, open that object and return an ID for + that object. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + Currently only set up to work with references to datasets + EXAMPLES + REVISION LOG + Raymond Lu + 13 July 2011 + I added the OAPL_ID parameter for the object being referenced. It only + supports dataset access property list currently. + + M. Scot Breitenfeld + 3 March 2015 + Added a check for undefined reference pointer. +--------------------------------------------------------------------------*/ +hid_t +H5R_dereference(H5F_t *file, hid_t oapl_id, hid_t dxpl_id, H5R_type_t ref_type, const void *_ref, hbool_t app_ref) +{ + H5O_loc_t oloc; /* Object location */ + H5G_name_t path; /* Path of object */ + H5G_loc_t loc; /* Group location */ + unsigned rc; /* Reference count of object */ + H5O_type_t obj_type; /* Type of object */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + HDassert(_ref); + HDassert(ref_type > H5R_BADTYPE && ref_type < H5R_MAXTYPE); + HDassert(file); + + /* Initialize the object location */ + H5O_loc_reset(&oloc); + oloc.file = file; + + switch (ref_type) { + case H5R_OBJECT: + { + oloc.addr = *(const hobj_ref_t *)_ref; /* Only object references currently supported */ + if (!H5F_addr_defined(oloc.addr) || oloc.addr == 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Undefined reference pointer") + break; + } + + case H5R_DATASET_REGION: + { + H5HG_t hobjid; /* Heap object ID */ + uint8_t *buf; /* Buffer to store serialized selection in */ + const uint8_t *p; /* Pointer to OID to store */ + + /* Get the heap ID for the dataset region */ + p = (const uint8_t *)_ref; + H5F_addr_decode(oloc.file, &p, &(hobjid.addr)); + UINT32DECODE(p, hobjid.idx); + + if (!H5F_addr_defined(hobjid.addr) || hobjid.addr == 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Undefined reference pointer") + + /* Get the dataset region from the heap (allocate inside routine) */ + if (NULL == (buf = (uint8_t *)H5HG_read(oloc.file, dxpl_id, &hobjid, NULL, NULL))) + HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, FAIL, "Unable to read dataset region information") + + /* Get the object oid for the dataset */ + p = buf; + H5F_addr_decode(oloc.file, &p, &(oloc.addr)); + + /* Free the buffer allocated in H5HG_read() */ + H5MM_xfree(buf); + break; + } /* end case H5R_DATASET_REGION */ + + case H5R_BADTYPE: + case H5R_MAXTYPE: + default: + HDassert("unknown reference type" && 0); + HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "internal error (unknown reference type)") + } /* end switch */ + + /* Get the # of links for object, and its type + * (To check to make certain that this object hasn't been deleted + * since the reference was created) + */ + if (H5O_get_rc_and_type(&oloc, dxpl_id, &rc, &obj_type) < 0 || 0 == rc) + HGOTO_ERROR(H5E_REFERENCE, H5E_LINKCOUNT, FAIL, "dereferencing deleted object") + + /* Construct a group location for opening the object */ + H5G_name_reset(&path); + loc.oloc = &oloc; + loc.path = &path; + + /* Open the object */ + switch (obj_type) { + case H5O_TYPE_GROUP: + { + H5G_t *group; /* Pointer to group to open */ + + if (NULL == (group = H5G_open(&loc, dxpl_id))) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "not found") + + /* Create an atom for the group */ + if ((ret_value = H5I_register(H5I_GROUP, group, app_ref)) < 0) { + H5G_close(group); + HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, FAIL, "can't register group") + } + + break; + } + + case H5O_TYPE_NAMED_DATATYPE: + { + H5T_t *type; /* Pointer to datatype to open */ + + if (NULL == (type = H5T_open(&loc, dxpl_id))) + HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL, "not found") + + /* Create an atom for the datatype */ + if ((ret_value = H5I_register(H5I_DATATYPE, type, app_ref)) < 0) { + H5T_close(type); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "can't register datatype") + } + + break; + } + + case H5O_TYPE_DATASET: + { + H5D_t *dset; /* Pointer to dataset to open */ + + /* Open the dataset */ + if (NULL == (dset = H5D_open(&loc, oapl_id, dxpl_id))) + HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, FAIL, "not found") + + /* Create an atom for the dataset */ + if ((ret_value = H5I_register(H5I_DATASET, dset, app_ref)) < 0) { + H5D_close(dset); + HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "can't register dataset") + } + + break; + } + + case H5O_TYPE_UNKNOWN: + case H5O_TYPE_NTYPES: + default: + HGOTO_ERROR(H5E_REFERENCE, H5E_BADTYPE, FAIL, "can't identify type of object referenced") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5R_dereference() */ + + +/*-------------------------------------------------------------------------- + NAME + H5R_get_region + PURPOSE + Retrieves a dataspace with the region pointed to selected. + USAGE + H5S_t *H5R_get_region(file, ref_type, ref) + H5F_t *file; IN: File the object being dereferenced is within + void *ref; IN: Reference to open. + + RETURNS + Pointer to the dataspace on success, NULL on failure + DESCRIPTION + Given a reference to some object, creates a copy of the dataset pointed + to's dataspace and defines a selection in the copy which is the region + pointed to. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +H5S_t * +H5R_get_region(H5F_t *file, hid_t dxpl_id, const void *_ref) +{ + H5O_loc_t oloc; /* Object location */ + const uint8_t *p; /* Pointer to OID to store */ + H5HG_t hobjid; /* Heap object ID */ + uint8_t *buf = NULL; /* Buffer to store serialized selection in */ + H5S_t *ret_value; + + FUNC_ENTER_NOAPI_NOINIT + + HDassert(_ref); + HDassert(file); + + /* Initialize the object location */ + H5O_loc_reset(&oloc); + oloc.file = file; + + /* Get the heap ID for the dataset region */ + p = (const uint8_t *)_ref; + H5F_addr_decode(oloc.file, &p, &(hobjid.addr)); + UINT32DECODE(p, hobjid.idx); + + /* Get the dataset region from the heap (allocate inside routine) */ + if ((buf = (uint8_t *)H5HG_read(oloc.file, dxpl_id, &hobjid, NULL, NULL)) == NULL) + HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, NULL, "Unable to read dataset region information") + + /* Get the object oid for the dataset */ + p = buf; + H5F_addr_decode(oloc.file, &p, &(oloc.addr)); + + /* Open and copy the dataset's dataspace */ + if ((ret_value = H5S_read(&oloc, dxpl_id)) == NULL) + HGOTO_ERROR(H5E_DATASPACE, H5E_NOTFOUND, NULL, "not found") + + /* Unserialize the selection */ + if (H5S_SELECT_DESERIALIZE(&ret_value, &p) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, NULL, "can't deserialize selection") + +done: + /* Free the buffer allocated in H5HG_read() */ + if (buf) + H5MM_xfree(buf); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5R_get_region() */ + + +/*-------------------------------------------------------------------------- + NAME + H5R_get_obj_type + PURPOSE + Retrieves the type of object that an object reference points to + USAGE + H5O_type_t H5R_get_obj_type(file, ref_type, ref) + H5F_t *file; IN: File the object being dereferenced is within + H5R_type_t ref_type; IN: Type of reference to query + void *ref; IN: Reference to query. + + RETURNS + Success: An object type defined in H5Gpublic.h + Failure: H5G_UNKNOWN + DESCRIPTION + Given a reference to some object, this function returns the type of object + pointed to. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +herr_t +H5R_get_obj_type(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, + const void *_ref, H5O_type_t *obj_type) +{ + H5O_loc_t oloc; /* Object location */ + unsigned rc; /* Reference count of object */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + HDassert(file); + HDassert(_ref); + + /* Initialize the symbol table entry */ + H5O_loc_reset(&oloc); + oloc.file = file; + + switch (ref_type) { + case H5R_OBJECT: + { + /* Get the object oid */ + oloc.addr = *(const hobj_ref_t *)_ref; /* Only object references currently supported */ + break; + } + + case H5R_DATASET_REGION: + { + H5HG_t hobjid; /* Heap object ID */ + const uint8_t *p; /* Pointer to reference to decode */ + uint8_t *buf; /* Buffer to store serialized selection in */ + + /* Get the heap ID for the dataset region */ + p = (const uint8_t *)_ref; + H5F_addr_decode(oloc.file, &p, &(hobjid.addr)); + UINT32DECODE(p, hobjid.idx); + + /* Get the dataset region from the heap (allocate inside routine) */ + if ((buf = (uint8_t *)H5HG_read(oloc.file, dxpl_id, &hobjid, NULL, NULL)) == NULL) + HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, FAIL, "Unable to read dataset region information") + + /* Get the object oid for the dataset */ + p = buf; + H5F_addr_decode(oloc.file, &p, &(oloc.addr)); + + /* Free the buffer allocated in H5HG_read() */ + H5MM_xfree(buf); + + break; + } + + case H5R_BADTYPE: + case H5R_MAXTYPE: + default: + HDassert("unknown reference type" && 0); + HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "internal error (unknown reference type)") + } /* end switch */ + + /* Get the # of links for object, and its type */ + /* (To check to make certain that this object hasn't been deleted since the reference was created) */ + if (H5O_get_rc_and_type(&oloc, dxpl_id, &rc, obj_type) < 0 || 0 == rc) + HGOTO_ERROR(H5E_REFERENCE, H5E_LINKCOUNT, FAIL, "dereferencing deleted object") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5R_get_obj_type() */ + + +/*-------------------------------------------------------------------------- + NAME + H5R_get_name + PURPOSE + Internal routine to determine a name for the object referenced + USAGE + ssize_t H5R_get_name(f, dxpl_id, ref_type, ref, name, size) + H5F_t *f; IN: Pointer to the file that the reference is pointing + into + hid_t lapl_id; IN: LAPL to use for operation + hid_t dxpl_id; IN: DXPL to use for operation + hid_t id; IN: Location ID given for reference + H5R_type_t ref_type; IN: Type of reference + void *ref; IN: Reference to query. + char *name; OUT: Buffer to place name of object referenced + size_t size; IN: Size of name buffer + + RETURNS + Non-negative length of the path on success, Negative on failure + DESCRIPTION + Given a reference to some object, determine a path to the object + referenced in the file. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + This may not be the only path to that object. + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +ssize_t +H5R_get_name(H5F_t *f, hid_t lapl_id, hid_t dxpl_id, hid_t id, H5R_type_t ref_type, + const void *_ref, char *name, size_t size) +{ + hid_t file_id = H5I_INVALID_HID; /* ID for file that the reference is in */ + H5O_loc_t oloc; /* Object location describing object for reference */ + ssize_t ret_value = -1; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* Check args */ + HDassert(f); + HDassert(_ref); + + /* Initialize the object location */ + H5O_loc_reset(&oloc); + oloc.file = f; + + /* Get address for reference */ + switch (ref_type) { + case H5R_OBJECT: + { + oloc.addr = *(const hobj_ref_t *)_ref; + break; + } + + case H5R_DATASET_REGION: + { + H5HG_t hobjid; /* Heap object ID */ + uint8_t *buf; /* Buffer to store serialized selection in */ + const uint8_t *p; /* Pointer to OID to store */ + + /* Get the heap ID for the dataset region */ + p = (const uint8_t *)_ref; + H5F_addr_decode(oloc.file, &p, &(hobjid.addr)); + UINT32DECODE(p, hobjid.idx); + + /* Get the dataset region from the heap (allocate inside routine) */ + if ((buf = (uint8_t *)H5HG_read(oloc.file, dxpl_id, &hobjid, NULL, NULL)) == NULL) + HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, FAIL, "Unable to read dataset region information") + + /* Get the object oid for the dataset */ + p = buf; + H5F_addr_decode(oloc.file, &p, &(oloc.addr)); + + /* Free the buffer allocated in H5HG_read() */ + H5MM_xfree(buf); + + break; + } + + case H5R_BADTYPE: + case H5R_MAXTYPE: + default: + HDassert("unknown reference type" && 0); + HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "internal error (unknown reference type)") + } /* end switch */ + + /* Retrieve file ID for name search */ + if ((file_id = H5I_get_file_id(id, FALSE)) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't retrieve file ID") + + /* Get name, length, etc. */ + if ((ret_value = H5G_get_name_by_addr(file_id, lapl_id, dxpl_id, &oloc, name, size)) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't determine name") + +done: + /* Close file ID used for search */ + if (file_id > 0 && H5I_dec_ref(file_id) < 0) + HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "can't decrement ref count of temp ID") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5R_get_name() */ + diff --git a/src/H5Rmodule.h b/src/H5Rmodule.h index 2eaf050..678a668 100644 --- a/src/H5Rmodule.h +++ b/src/H5Rmodule.h @@ -10,13 +10,9 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* - * Programmer: Quincey Koziol - * Saturday, September 12, 2015 - * - * Purpose: This file contains declarations which define macros for the - * H5R package. Including this header means that the source file - * is part of the H5R package. +/* Purpose: This file contains declarations which define macros for the + * H5R package. Including this header means that the source file + * is part of the H5R package. */ #ifndef _H5Rmodule_H #define _H5Rmodule_H @@ -31,4 +27,3 @@ #endif /* _H5Rmodule_H */ - diff --git a/src/H5Rpkg.h b/src/H5Rpkg.h index 6d5036b..129f944 100644 --- a/src/H5Rpkg.h +++ b/src/H5Rpkg.h @@ -11,11 +11,7 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* - * Programmer: Quincey Koziol - * Thursday, September 13, 2007 - * - * Purpose: This file contains declarations which are visible +/* Purpose: This file contains declarations which are visible * only within the H5R package. Source files outside the * H5R package should include H5Rprivate.h instead. */ @@ -30,7 +26,6 @@ #include "H5Rprivate.h" /* Other private headers needed by this file */ -#include "H5Fprivate.h" /* File access */ /**************************/ /* Package Private Macros */ @@ -51,12 +46,5 @@ /* Package Private Prototypes */ /******************************/ -/* General functions */ -H5_DLL herr_t H5R_get_obj_type(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, - const void *_ref, H5O_type_t *obj_type); -H5_DLL hid_t H5R_dereference(H5F_t *file, hid_t dapl_id, hid_t dxpl_id, H5R_type_t ref_type, - const void *_ref, hbool_t app_ref); - - #endif /* _H5Rpkg_H */ diff --git a/src/H5Rprivate.h b/src/H5Rprivate.h index 7efa225..35e63d2 100644 --- a/src/H5Rprivate.h +++ b/src/H5Rprivate.h @@ -20,10 +20,40 @@ #include "H5Rpublic.h" /* Private headers needed by this file */ +#include "H5Fprivate.h" /* Files */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Sprivate.h" /* Dataspaces */ -/* Internal data structures */ -/* Private functions */ +/**************************/ +/* Library Private Macros */ +/**************************/ + + +/****************************/ +/* Library Private Typedefs */ +/****************************/ + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/******************************/ +/* Library Private Prototypes */ +/******************************/ + +H5_DLL herr_t H5R_create(void *ref, H5G_loc_t *loc, const char *name, + H5R_type_t ref_type, H5S_t *space, hid_t dxpl_id); +H5_DLL H5S_t * H5R_get_region(H5F_t *file, hid_t dxpl_id, const void *_ref); +H5_DLL ssize_t H5R_get_name(H5F_t *file, hid_t lapl_id, hid_t dxpl_id, hid_t id, + H5R_type_t ref_type, const void *_ref, char *name, size_t size); +H5_DLL herr_t H5R_get_obj_type(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, + const void *_ref, H5O_type_t *obj_type); +H5_DLL hid_t H5R_dereference(H5F_t *file, hid_t dapl_id, hid_t dxpl_id, H5R_type_t ref_type, + const void *_ref, hbool_t app_ref); #endif /* _H5Rprivate_H */ diff --git a/src/H5Rpublic.h b/src/H5Rpublic.h index 446b7cd..598bafd 100644 --- a/src/H5Rpublic.h +++ b/src/H5Rpublic.h @@ -22,40 +22,59 @@ #include "H5Gpublic.h" #include "H5Ipublic.h" -/* - * Reference types allowed. - */ -typedef enum { - H5R_BADTYPE = (-1), /*invalid Reference Type */ - H5R_OBJECT, /*Object reference */ - H5R_DATASET_REGION, /*Dataset Region Reference */ - H5R_MAXTYPE /*highest type (Invalid as true type) */ -} H5R_type_t; +/*****************/ +/* Public Macros */ +/*****************/ /* Note! Be careful with the sizes of the references because they should really * depend on the run-time values in the file. Unfortunately, the arrays need - * to be defined at compile-time, so we have to go with the worst case sizes for - * them. -QAK + * to be defined at compile-time, so we have to go with the worst case sizes + * for them. -QAK + */ +#define H5R_OBJ_REF_BUF_SIZE sizeof(haddr_t) + +/* 4 is used instead of sizeof(int) to permit portability between the Crays + * and other machines (the heap ID is always encoded as an int32 anyway). + */ +#define H5R_DSET_REG_REF_BUF_SIZE (sizeof(haddr_t) + 4) + +/*******************/ +/* Public Typedefs */ +/*******************/ + +/* Reference types */ +typedef enum H5R_type_t { + H5R_BADTYPE = (-1), /* Invalid Reference Type */ + H5R_OBJECT, /* Object reference */ + H5R_DATASET_REGION, /* Dataset Region Reference */ + H5R_MAXTYPE /* Highest type (Invalid as true type) */ +} H5R_type_t; + +/* Object reference structure for user's code + * This needs to be large enough to store largest haddr_t on a worst case + * machine (8 bytes currently). + */ +typedef haddr_t hobj_ref_t; + +/* Dataset Region reference structure for user's code + * (Buffer to store heap ID and index) + * This needs to be large enough to store largest haddr_t in a worst case + * machine (8 bytes currently) plus an int */ -#define H5R_OBJ_REF_BUF_SIZE sizeof(haddr_t) -/* Object reference structure for user's code */ -typedef haddr_t hobj_ref_t; /* Needs to be large enough to store largest haddr_t in a worst case machine (ie. 8 bytes currently) */ +typedef unsigned char hdset_reg_ref_t[H5R_DSET_REG_REF_BUF_SIZE]; -#define H5R_DSET_REG_REF_BUF_SIZE (sizeof(haddr_t)+4) -/* 4 is used instead of sizeof(int) to permit portability between - the Crays and other machines (the heap ID is always encoded as an int32 anyway) -*/ -/* Dataset Region reference structure for user's code */ -typedef unsigned char hdset_reg_ref_t[H5R_DSET_REG_REF_BUF_SIZE];/* Buffer to store heap ID and index */ -/* Needs to be large enough to store largest haddr_t in a worst case machine (ie. 8 bytes currently) plus an int */ +/********************/ +/* Public Variables */ +/********************/ -/* Publicly visible data structures */ +/*********************/ +/* Public Prototypes */ +/*********************/ #ifdef __cplusplus extern "C" { #endif -/* Functions in H5R.c */ H5_DLL herr_t H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t space_id); H5_DLL hid_t H5Rdereference2(hid_t obj_id, hid_t oapl_id, H5R_type_t ref_type, const void *ref); @@ -63,7 +82,7 @@ H5_DLL hid_t H5Rget_region(hid_t dataset, H5R_type_t ref_type, const void *ref); H5_DLL herr_t H5Rget_obj_type2(hid_t id, H5R_type_t ref_type, const void *_ref, H5O_type_t *obj_type); H5_DLL ssize_t H5Rget_name(hid_t loc_id, H5R_type_t ref_type, const void *ref, - char *name/*out*/, size_t size); + char *name /*out*/, size_t size); /* Symbols defined for compatibility with previous versions of the HDF5 API. * @@ -71,12 +90,6 @@ H5_DLL ssize_t H5Rget_name(hid_t loc_id, H5R_type_t ref_type, const void *ref, */ #ifndef H5_NO_DEPRECATED_SYMBOLS -/* Macros */ - - -/* Typedefs */ - - /* Function prototypes */ H5_DLL H5G_obj_t H5Rget_obj_type1(hid_t id, H5R_type_t ref_type, const void *_ref); H5_DLL hid_t H5Rdereference1(hid_t obj_id, H5R_type_t ref_type, const void *ref); diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h index 8934726..f125035 100644 --- a/src/H5Sprivate.h +++ b/src/H5Sprivate.h @@ -17,6 +17,9 @@ #ifndef _H5Sprivate_H #define _H5Sprivate_H +/* Early typedefs to avoid circular dependencies */ +typedef struct H5S_t H5S_t; + /* Include package's public header */ #include "H5Spublic.h" @@ -44,7 +47,6 @@ #define H5S_GET_SEQ_LIST_SORTED 0x0001 /* Forward references of package typedefs */ -typedef struct H5S_t H5S_t; typedef struct H5S_extent_t H5S_extent_t; typedef struct H5S_pnt_node_t H5S_pnt_node_t; typedef struct H5S_hyper_span_t H5S_hyper_span_t; diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h index f2da62e..17cdc49 100644 --- a/src/H5Tprivate.h +++ b/src/H5Tprivate.h @@ -17,6 +17,9 @@ #ifndef _H5Tprivate_H #define _H5Tprivate_H +/* Early typedefs to avoid circular dependencies */ +typedef struct H5T_t H5T_t; + /* Get package's public header */ #include "H5Tpublic.h" @@ -45,7 +48,6 @@ #endif /* H5T_MODULE */ /* Forward references of package typedefs (declared in H5Tpkg.h) */ -typedef struct H5T_t H5T_t; typedef struct H5T_stats_t H5T_stats_t; typedef struct H5T_path_t H5T_path_t; diff --git a/src/H5Zprivate.h b/src/H5Zprivate.h index fe182ad..26e35a7 100644 --- a/src/H5Zprivate.h +++ b/src/H5Zprivate.h @@ -18,6 +18,9 @@ #ifndef _H5Zprivate_H #define _H5Zprivate_H +/* Early typedefs to avoid circular dependencies */ +typedef struct H5Z_filter_info_t H5Z_filter_info_t; + /* Include package's public header */ #include "H5Zpublic.h" @@ -49,7 +52,7 @@ /****************************/ /* Structure to store information about each filter's parameters */ -typedef struct H5Z_filter_info_t { +struct H5Z_filter_info_t { H5Z_filter_t id; /*filter identification number */ unsigned flags; /*defn and invocation flags */ char _name[H5Z_COMMON_NAME_LEN]; /*internal filter name */ @@ -57,7 +60,7 @@ typedef struct H5Z_filter_info_t { size_t cd_nelmts; /*number of elements in cd_values[] */ unsigned _cd_values[H5Z_COMMON_CD_VALUES]; /*internal client data values */ unsigned *cd_values; /*client data values */ -} H5Z_filter_info_t; +}; /*****************************/ /* Library-private Variables */ diff --git a/src/Makefile.am b/src/Makefile.am index 9a64717..ad29e2a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -98,7 +98,7 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5Plapl.c H5Plcpl.c H5Pocpl.c H5Pocpypl.c H5Pstrcpl.c H5Ptest.c \ H5PB.c \ H5PL.c H5PLint.c H5PLpath.c H5PLplugin_cache.c \ - H5R.c H5Rdeprec.c \ + H5R.c H5Rint.c H5Rdeprec.c \ H5UC.c \ H5RS.c \ H5S.c H5Sall.c H5Sdbg.c H5Shyper.c H5Snone.c H5Spoint.c \ -- cgit v0.12 From de0076b5ba9869c07056d28318965cf362299162 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 8 Nov 2017 09:05:26 -0600 Subject: Remove tabs --- src/H5Dint.c | 860 ++++++++++++++++++++++++----------------------------------- 1 file changed, 344 insertions(+), 516 deletions(-) diff --git a/src/H5Dint.c b/src/H5Dint.c index bdedd1e..b6c0341 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -21,14 +21,14 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5FOprivate.h" /* File objects */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5private.h" /* Generic Functions */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5FOprivate.h" /* File objects */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5MMprivate.h" /* Memory management */ /****************/ @@ -54,18 +54,18 @@ typedef struct { /* General stuff */ static herr_t H5D__get_dxpl_cache_real(hid_t dxpl_id, H5D_dxpl_cache_t *cache); static H5D_shared_t *H5D__new(hid_t dcpl_id, hbool_t creating, - hbool_t vl_type); + hbool_t vl_type); static herr_t H5D__init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, - const H5T_t *type); + const H5T_t *type); static herr_t H5D__cache_dataspace_info(const H5D_t *dset); static herr_t H5D__init_space(H5F_t *file, const H5D_t *dset, const H5S_t *space); static herr_t H5D__update_oh_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset, - hid_t dapl_id); + hid_t dapl_id); static herr_t H5D_build_extfile_prefix(const H5D_t *dset, hid_t dapl_id, - char **extfile_prefix); + char **extfile_prefix); static herr_t H5D__open_oid(H5D_t *dataset, hid_t dapl_id, hid_t dxpl_id); static herr_t H5D__init_storage(const H5D_io_info_t *io_info, hbool_t full_overwrite, - hsize_t old_dim[]); + hsize_t old_dim[]); static herr_t H5D__append_flush_setup(H5D_t *dset, hid_t dapl_id); /*********************/ @@ -109,9 +109,9 @@ static H5D_shared_t H5D_def_dset; /* Dataset ID class */ static const H5I_class_t H5I_DATASET_CLS[1] = {{ - H5I_DATASET, /* ID class value */ - 0, /* Class flags */ - 0, /* # of reserved IDs for class */ + H5I_DATASET, /* ID class value */ + 0, /* Class flags */ + 0, /* # of reserved IDs for class */ (H5I_free_t)H5D_close /* Callback routine for closing objects of this class */ }}; @@ -121,17 +121,13 @@ static hbool_t H5D_top_package_initialize_s = FALSE; /*------------------------------------------------------------------------- - * Function: H5D_init + * Function: H5D_init * - * Purpose: Initialize the interface from some other layer. + * Purpose: Initialize the interface from some other layer. * - * Return: Success: non-negative - * - * Failure: negative - * - * Programmer: Quincey Koziol - * Saturday, March 4, 2000 + * Return: Success: non-negative * + * Failure: negative *------------------------------------------------------------------------- */ herr_t @@ -149,7 +145,7 @@ done: /*-------------------------------------------------------------------------- NAME - H5D__init_package -- Initialize interface-specific information + H5D__init_package -- Initialize interface-specific information USAGE herr_t H5D__init_package() @@ -211,28 +207,24 @@ done: /*------------------------------------------------------------------------- - * Function: H5D_top_term_package - * - * Purpose: Close the "top" of the interface, releasing IDs, etc. - * - * Return: Success: Positive if anything was done that might - * affect other interfaces; zero otherwise. - * Failure: Negative. + * Function: H5D_top_term_package * - * Programmer: Quincey Koziol - * Sunday, September 13, 2015 + * Purpose: Close the "top" of the interface, releasing IDs, etc. * + * Return: Success: Positive if anything was done that might + * affect other interfaces; zero otherwise. + * Failure: Negative. *------------------------------------------------------------------------- */ int H5D_top_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR if(H5D_top_package_initialize_s) { - if(H5I_nmembers(H5I_DATASET) > 0) { + if(H5I_nmembers(H5I_DATASET) > 0) { /* The dataset API uses the "force" flag set to true because it * is using the "file objects" (H5FO) API functions to track open * objects in the file. Using the H5FO code means that dataset @@ -255,9 +247,9 @@ H5D_top_term_package(void) * * QAK - 5/13/03 */ - (void)H5I_clear_type(H5I_DATASET, TRUE, FALSE); + (void)H5I_clear_type(H5I_DATASET, TRUE, FALSE); n++; /*H5I*/ - } /* end if */ + } /* end if */ /* Mark closed */ if(0 == n) @@ -269,26 +261,22 @@ H5D_top_term_package(void) /*------------------------------------------------------------------------- - * Function: H5D_term_package - * - * Purpose: Terminate this interface. + * Function: H5D_term_package * - * Note: Finishes shutting down the interface, after - * H5D_top_term_package() is called + * Purpose: Terminate this interface. * - * Return: Success: Positive if anything was done that might - * affect other interfaces; zero otherwise. - * Failure: Negative. - * - * Programmer: Robb Matzke - * Friday, November 20, 1998 + * Note: Finishes shutting down the interface, after + * H5D_top_term_package() is called * + * Return: Success: Positive if anything was done that might + * affect other interfaces; zero otherwise. + * Failure: Negative. *------------------------------------------------------------------------- */ int H5D_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -440,17 +428,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__create_named - * - * Purpose: Internal routine to create a new dataset. + * Function: H5D__create_named * - * Return: Success: Non-NULL, pointer to new dataset object. + * Purpose: Internal routine to create a new dataset. * - * Failure: NULL - * - * Programmer: Quincey Koziol - * Thursday, April 5, 2007 + * Return: Success: Non-NULL, pointer to new dataset object. * + * Failure: NULL *------------------------------------------------------------------------- */ H5D_t * @@ -460,7 +444,7 @@ H5D__create_named(const H5G_loc_t *loc, const char *name, hid_t type_id, { H5O_obj_create_t ocrt_info; /* Information for object creation */ H5D_obj_create_t dcrt_info; /* Information for dataset creation */ - H5D_t *ret_value = NULL; /* Return value */ + H5D_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -505,11 +489,7 @@ done: * * Return: * Success: Non-negative - * * Failture: Negative - * - * Programmer: Raymond Lu - * *------------------------------------------------------------------------- */ herr_t @@ -557,7 +537,7 @@ H5D__get_space_status(H5D_t *dset, H5D_space_status_t *allocation, hid_t dxpl_id *allocation = H5D_SPACE_STATUS_NOT_ALLOCATED; else if(space_allocated == full_size) *allocation = H5D_SPACE_STATUS_ALLOCATED; - else + else *allocation = H5D_SPACE_STATUS_PART_ALLOCATED; } /* end if */ else { @@ -575,17 +555,12 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__new - * - * Purpose: Creates a new, empty dataset structure + * Function: H5D__new * - * Return: Success: Pointer to a new dataset descriptor. - * - * Failure: NULL - * - * Programmer: Quincey Koziol - * Monday, October 12, 1998 + * Purpose: Creates a new, empty dataset structure * + * Return: Success: Pointer to a new dataset descriptor. + * Failure: NULL *------------------------------------------------------------------------- */ static H5D_shared_t * @@ -636,26 +611,22 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__init_type + * Function: H5D__init_type * - * Purpose: Copy a datatype for a dataset's use, performing all the + * Purpose: Copy a datatype for a dataset's use, performing all the * necessary adjustments, etc. * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Quincey Koziol - * Thursday, June 24, 2004 - * + * Return: Success: SUCCEED + * Failure: FAIL *------------------------------------------------------------------------- */ static herr_t H5D__init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, const H5T_t *type) { - htri_t relocatable; /* Flag whether the type is relocatable */ - htri_t immutable; /* Flag whether the type is immutable */ - hbool_t use_latest_format; /* Flag indicating the 'latest datatype version support' is enabled */ - herr_t ret_value = SUCCEED; /* Return value */ + htri_t relocatable; /* Flag whether the type is relocatable */ + htri_t immutable; /* Flag whether the type is immutable */ + hbool_t use_latest_format; /* Flag indicating the 'latest datatype version support' is enabled */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -681,8 +652,8 @@ H5D__init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, const H5T_t *type) if((dset->shared->type = H5T_copy(type, H5T_COPY_ALL)) == NULL) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't copy datatype") - /* Convert a datatype (if committed) to a transient type if the committed datatype's file - location is different from the file location where the dataset will be created */ + /* Convert a datatype (if committed) to a transient type if the committed datatype's file + location is different from the file location where the dataset will be created */ if(H5T_convert_committed_datatype(dset->shared->type, file) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't get shared datatype info") @@ -696,8 +667,8 @@ H5D__init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, const H5T_t *type) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set latest version of datatype") /* Get a datatype ID for the dataset's datatype */ - if((dset->shared->type_id = H5I_register(H5I_DATATYPE, dset->shared->type, FALSE)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register type") + if((dset->shared->type_id = H5I_register(H5I_DATATYPE, dset->shared->type, FALSE)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register type") } /* end if */ /* Not a custom datatype, just use it directly */ else { @@ -715,16 +686,12 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__cache_dataspace_info - * - * Purpose: Cache dataspace info for a dataset - * - * Return: Success: SUCCEED - * Failure: FAIL + * Function: H5D__cache_dataspace_info * - * Programmer: Quincey Koziol - * Wednesday, November 19, 2014 + * Purpose: Cache dataspace info for a dataset * + * Return: Success: SUCCEED + * Failure: FAIL *------------------------------------------------------------------------- */ static herr_t @@ -759,17 +726,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__init_space + * Function: H5D__init_space * - * Purpose: Copy a dataspace for a dataset's use, performing all the + * Purpose: Copy a dataspace for a dataset's use, performing all the * necessary adjustments, etc. * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Quincey Koziol - * Tuesday, July 24, 2007 - * + * Return: Success: SUCCEED + * Failure: FAIL *------------------------------------------------------------------------- */ static herr_t @@ -811,16 +774,12 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__update_oh_info - * - * Purpose: Create and fill object header for dataset - * - * Return: Success: SUCCEED - * Failure: FAIL + * Function: H5D__update_oh_info * - * Programmer: Bill Wendling - * Thursday, October 31, 2002 + * Purpose: Create and fill object header for dataset * + * Return: Success: SUCCEED + * Failure: FAIL *------------------------------------------------------------------------- */ static herr_t @@ -831,9 +790,9 @@ H5D__update_oh_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset, hid_t dapl_id) H5O_loc_t *oloc = NULL; /* Dataset's object location */ H5O_layout_t *layout; /* Dataset's layout information */ H5T_t *type; /* Dataset's datatype */ - H5O_fill_t *fill_prop; /* Pointer to dataset's fill value information */ - H5D_fill_value_t fill_status; /* Fill value status */ - hbool_t fill_changed = FALSE; /* Flag indicating the fill value was changed */ + H5O_fill_t *fill_prop; /* Pointer to dataset's fill value information */ + H5D_fill_value_t fill_status; /* Fill value status */ + hbool_t fill_changed = FALSE; /* Flag indicating the fill value was changed */ hbool_t layout_init = FALSE; /* Flag to indicate that chunk information was initialized */ herr_t ret_value = SUCCEED; /* Return value */ @@ -875,10 +834,12 @@ H5D__update_oh_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset, hid_t dapl_id) if(fill_prop->buf && fill_prop->size > 0 && H5O_fill_convert(fill_prop, type, &fill_changed, dxpl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to convert fill value to dataset type") - fill_prop->fill_defined = TRUE; - } else if(fill_status == H5D_FILL_VALUE_UNDEFINED) { - fill_prop->fill_defined = FALSE; - } else + fill_prop->fill_defined = TRUE; + } + else if(fill_status == H5D_FILL_VALUE_UNDEFINED) { + fill_prop->fill_defined = FALSE; + } + else HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to determine if fill value is defined") /* Check for invalid fill & allocation time setting */ @@ -961,17 +922,17 @@ H5D__update_oh_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset, hid_t dapl_id) (H5P_exist_plist(dc_plist, H5O_BOGUS_MSG_ID_NAME) > 0) ) { uint8_t bogus_flags = 0; /* Flags for creating "bogus" message */ - unsigned bogus_id; /* "bogus" ID */ + unsigned bogus_id; /* "bogus" ID */ - /* Retrieve "bogus" message ID */ + /* Retrieve "bogus" message ID */ if(H5P_get(dc_plist, H5O_BOGUS_MSG_ID_NAME, &bogus_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get bogus ID options") + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get bogus ID options") /* Retrieve "bogus" message flags */ if(H5P_get(dc_plist, H5O_BOGUS_MSG_FLAGS_NAME, &bogus_flags) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get bogus message options") /* Add a "bogus" message (for error testing). */ - if(H5O_bogus_oh(file, dxpl_id, oh, bogus_id, (unsigned)bogus_flags) < 0) + if(H5O_bogus_oh(file, dxpl_id, oh, bogus_id, (unsigned)bogus_flags) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create 'bogus' message") } /* end if */ } @@ -1010,9 +971,6 @@ done: * should be used. * * Return: SUCCEED/FAIL - * - * Programmer: Steffen Kiess - * October 16, 2015 *-------------------------------------------------------------------------- */ static herr_t @@ -1025,7 +983,7 @@ H5D_build_extfile_prefix(const H5D_t *dset, hid_t dapl_id, char **extfile_prefix size_t extfile_prefix_len; /* length of expanded prefix */ H5P_genplist_t *plist = NULL; /* Property list pointer */ herr_t ret_value = SUCCEED; /* Return value */ - + FUNC_ENTER_NOAPI_NOINIT @@ -1064,7 +1022,7 @@ H5D_build_extfile_prefix(const H5D_t *dset, hid_t dapl_id, char **extfile_prefix extpath_len = HDstrlen(extpath); prefix_len = HDstrlen(prefix); extfile_prefix_len = extpath_len + prefix_len - HDstrlen("${ORIGIN}") + 1; - + if(NULL == (*extfile_prefix = (char *)H5MM_malloc(extfile_prefix_len))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate buffer") HDsnprintf(*extfile_prefix, extfile_prefix_len, "%s%s", extpath, prefix + HDstrlen("${ORIGIN}")); @@ -1081,32 +1039,27 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__create - * - * Purpose: Creates a new dataset with name NAME in file F and associates - * with it a datatype TYPE for each element as stored in the - * file, dimensionality information or dataspace SPACE, and - * other miscellaneous properties CREATE_PARMS. All arguments - * are deep-copied before being associated with the new dataset, - * so the caller is free to subsequently modify them without - * affecting the dataset. - * - * Return: Success: Pointer to a new dataset - * - * Failure: NULL - * - * Programmer: Robb Matzke - * Thursday, December 4, 1997 - * + * Function: H5D__create + * + * Purpose: Creates a new dataset with name NAME in file F and associates + * with it a datatype TYPE for each element as stored in the + * file, dimensionality information or dataspace SPACE, and + * other miscellaneous properties CREATE_PARMS. All arguments + * are deep-copied before being associated with the new dataset, + * so the caller is free to subsequently modify them without + * affecting the dataset. + * + * Return: Success: Pointer to a new dataset + * Failure: NULL *------------------------------------------------------------------------- */ H5D_t * H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id) { - const H5T_t *type; /* Datatype for dataset */ - H5D_t *new_dset = NULL; - H5P_genplist_t *dc_plist = NULL; /* New Property list */ + const H5T_t *type; /* Datatype for dataset */ + H5D_t *new_dset = NULL; + H5P_genplist_t *dc_plist = NULL; /* New Property list */ hbool_t has_vl_type = FALSE; /* Flag to indicate a VL-type for dataset */ hbool_t layout_init = FALSE; /* Flag to indicate that chunk information was initialized */ hbool_t layout_copied = FALSE; /* Flag to indicate that layout message was copied */ @@ -1114,7 +1067,7 @@ H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, hbool_t pline_copied = FALSE; /* Flag to indicate that pipeline message was copied */ hbool_t efl_copied = FALSE; /* Flag to indicate that external file list message was copied */ H5G_loc_t dset_loc; /* Dataset location */ - H5D_t *ret_value = NULL; /* Return value */ + H5D_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -1218,24 +1171,24 @@ H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, /* Set the latest version of the layout, pline & fill messages, if requested */ if(H5F_USE_LATEST_FLAGS(file, H5F_LATEST_DSET_MSG_FLAGS)) { /* Set the latest version for the I/O pipeline message */ - if(H5F_USE_LATEST_FLAGS(file, H5F_LATEST_PLINE_MSG)) - if(H5O_pline_set_latest_version(&new_dset->shared->dcpl_cache.pline) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set latest version of I/O filter pipeline") + if(H5F_USE_LATEST_FLAGS(file, H5F_LATEST_PLINE_MSG)) + if(H5O_pline_set_latest_version(&new_dset->shared->dcpl_cache.pline) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set latest version of I/O filter pipeline") /* Set the latest version for the fill message */ - if(H5F_USE_LATEST_FLAGS(file, H5F_LATEST_FILL_MSG)) - /* Set the latest version for the fill value message */ - if(H5O_fill_set_latest_version(&new_dset->shared->dcpl_cache.fill) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set latest version of fill value") + if(H5F_USE_LATEST_FLAGS(file, H5F_LATEST_FILL_MSG)) + /* Set the latest version for the fill value message */ + if(H5O_fill_set_latest_version(&new_dset->shared->dcpl_cache.fill) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set latest version of fill value") /* Set the latest version for the layout message */ - if(H5F_USE_LATEST_FLAGS(file, H5F_LATEST_LAYOUT_MSG)) - /* Set the latest version for the layout message */ - if(H5D__layout_set_latest_version(&new_dset->shared->layout, new_dset->shared->space, &new_dset->shared->dcpl_cache) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set latest version of layout") + if(H5F_USE_LATEST_FLAGS(file, H5F_LATEST_LAYOUT_MSG)) + /* Set the latest version for the layout message */ + if(H5D__layout_set_latest_version(&new_dset->shared->layout, new_dset->shared->space, &new_dset->shared->dcpl_cache) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set latest version of layout") } /* end if */ else if(new_dset->shared->layout.version >= H5O_LAYOUT_VERSION_4) { - /* Use latest indexing type for layout message version >= 4 */ + /* Use latest indexing type for layout message version >= 4 */ if(H5D__layout_set_latest_indexing(&new_dset->shared->layout, new_dset->shared->space, &new_dset->shared->dcpl_cache) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set latest indexing") } /* end if */ @@ -1261,7 +1214,7 @@ H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, /* Set up append flush parameters for the dataset */ if(H5D__append_flush_setup(new_dset, dapl_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to set up flush append property") + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to set up flush append property") /* Set the external file prefix */ if(H5D_build_extfile_prefix(new_dset, dapl_id, &new_dset->shared->extfile_prefix) < 0) @@ -1329,10 +1282,6 @@ done: * * Return: Success: Ptr to a new dataset. * Failure: NULL - * - * Programmer: Neil Fortner - * Friday, March 6, 2015 - * *------------------------------------------------------------------------- */ H5D_t * @@ -1387,17 +1336,13 @@ done: /* *------------------------------------------------------------------------- - * Function: H5D_open + * Function: H5D_open * - * Purpose: Checks if dataset is already open, or opens a dataset for + * Purpose: Checks if dataset is already open, or opens a dataset for * access. * - * Return: Success: Dataset ID - * Failure: FAIL - * - * Programmer: Quincey Koziol - * Friday, December 20, 2002 - * + * Return: Success: Dataset ID + * Failure: FAIL *------------------------------------------------------------------------- */ H5D_t * @@ -1509,19 +1454,15 @@ done: /* *------------------------------------------------------------------------- - * Function: H5D__flush_append_setup - * - * Purpose: Set the append flush parameters for a dataset - * - * Return: Non-negative on success/Negative on failure + * Function: H5D__flush_append_setup * - * Programmer: Vailin Choi - * Wednesday, January 8, 2014 + * Purpose: Set the append flush parameters for a dataset * + * Return: Non-negative on success/Negative on failure *------------------------------------------------------------------------- */ static herr_t -H5D__append_flush_setup(H5D_t *dset, hid_t dapl_id) +H5D__append_flush_setup(H5D_t *dset, hid_t dapl_id) { herr_t ret_value = SUCCEED; /* return value */ @@ -1538,47 +1479,47 @@ H5D__append_flush_setup(H5D_t *dset, hid_t dapl_id) if(dapl_id != H5P_DATASET_ACCESS_DEFAULT && dset->shared->layout.type == H5D_CHUNKED) { H5P_genplist_t *dapl; /* data access property list object pointer */ - /* Get dataset access property list */ - if(NULL == (dapl = (H5P_genplist_t *)H5I_object(dapl_id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for dapl ID"); + /* Get dataset access property list */ + if(NULL == (dapl = (H5P_genplist_t *)H5I_object(dapl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for dapl ID"); - /* Check if append flush property exists */ - if(H5P_exist_plist(dapl, H5D_ACS_APPEND_FLUSH_NAME) > 0) { + /* Check if append flush property exists */ + if(H5P_exist_plist(dapl, H5D_ACS_APPEND_FLUSH_NAME) > 0) { H5D_append_flush_t info; - /* Get append flush property */ - if(H5P_get(dapl, H5D_ACS_APPEND_FLUSH_NAME, &info) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get append flush info") - if(info.ndims > 0) { - hsize_t curr_dims[H5S_MAX_RANK]; /* current dimension sizes */ - hsize_t max_dims[H5S_MAX_RANK]; /* current dimension sizes */ - int rank; /* dataspace # of dimensions */ - unsigned u; /* local index variable */ - - /* Get dataset rank */ - if((rank = H5S_get_simple_extent_dims(dset->shared->space, curr_dims, max_dims)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataset dimensions") - if(info.ndims != (unsigned)rank) - HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "boundary dimension rank does not match dataset rank") - - /* Validate boundary sizes */ - for(u = 0; u < info.ndims; u++) - if(info.boundary[u] != 0) /* when a non-zero boundary is set */ - /* the dimension is extendible? */ - if(max_dims[u] != H5S_UNLIMITED && max_dims[u] == curr_dims[u]) - break; + /* Get append flush property */ + if(H5P_get(dapl, H5D_ACS_APPEND_FLUSH_NAME, &info) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get append flush info") + if(info.ndims > 0) { + hsize_t curr_dims[H5S_MAX_RANK]; /* current dimension sizes */ + hsize_t max_dims[H5S_MAX_RANK]; /* current dimension sizes */ + int rank; /* dataspace # of dimensions */ + unsigned u; /* local index variable */ + + /* Get dataset rank */ + if((rank = H5S_get_simple_extent_dims(dset->shared->space, curr_dims, max_dims)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataset dimensions") + if(info.ndims != (unsigned)rank) + HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "boundary dimension rank does not match dataset rank") + + /* Validate boundary sizes */ + for(u = 0; u < info.ndims; u++) + if(info.boundary[u] != 0) /* when a non-zero boundary is set */ + /* the dimension is extendible? */ + if(max_dims[u] != H5S_UNLIMITED && max_dims[u] == curr_dims[u]) + break; /* At least one boundary dimension is not extendible */ - if(u != info.ndims) - HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "boundary dimension is not valid") + if(u != info.ndims) + HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, FAIL, "boundary dimension is not valid") /* Copy append flush settings */ - dset->shared->append_flush.ndims = info.ndims; - dset->shared->append_flush.func = info.func; - dset->shared->append_flush.udata = info.udata; - HDmemcpy(dset->shared->append_flush.boundary, info.boundary, sizeof(info.boundary)); - } /* end if */ - } /* end if */ + dset->shared->append_flush.ndims = info.ndims; + dset->shared->append_flush.func = info.func; + dset->shared->append_flush.udata = info.udata; + HDmemcpy(dset->shared->append_flush.boundary, info.boundary, sizeof(info.boundary)); + } /* end if */ + } /* end if */ } /* end if */ done: @@ -1587,15 +1528,11 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__open_oid - * - * Purpose: Opens a dataset for access. - * - * Return: Dataset pointer on success, NULL on failure + * Function: H5D__open_oid * - * Programmer: Quincey Koziol - * Monday, October 12, 1998 + * Purpose: Opens a dataset for access. * + * Return: Dataset pointer on success, NULL on failure *------------------------------------------------------------------------- */ static herr_t @@ -1605,8 +1542,8 @@ H5D__open_oid(H5D_t *dataset, hid_t dapl_id, hid_t dxpl_id) H5O_fill_t *fill_prop; /* Pointer to dataset's fill value info */ unsigned alloc_time_state; /* Allocation time state */ htri_t msg_exists; /* Whether a particular type of message exists */ - hbool_t layout_init = FALSE; /* Flag to indicate that chunk information was initialized */ - herr_t ret_value = SUCCEED; /* Return value */ + hbool_t layout_init = FALSE; /* Flag to indicate that chunk information was initialized */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_TAG(dxpl_id, dataset->oloc.addr, FAIL) @@ -1652,7 +1589,7 @@ H5D__open_oid(H5D_t *dataset, hid_t dapl_id, hid_t dxpl_id) /* Set up flush append property */ if(H5D__append_flush_setup(dataset, dapl_id)) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set up flush append property") + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set up flush append property") /* Point at dataset's copy, to cache it for later */ fill_prop = &dataset->shared->dcpl_cache.fill; @@ -1665,7 +1602,7 @@ H5D__open_oid(H5D_t *dataset, hid_t dapl_id, hid_t dxpl_id) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve message") } /* end if */ else { - /* For backward compatibility, try to retrieve the old fill value message */ + /* For backward compatibility, try to retrieve the old fill value message */ if((msg_exists = H5O_msg_exists(&(dataset->oloc), H5O_FILL_ID, dxpl_id)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't check if message exists") if(msg_exists) { @@ -1740,7 +1677,7 @@ done: if(H5F_addr_defined(dataset->oloc.addr) && H5O_close(&(dataset->oloc), NULL) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release object header") if(dataset->shared) { - if(layout_init) + if(layout_init) if(dataset->shared->layout.ops->dest && (dataset->shared->layout.ops->dest)(dataset, dxpl_id) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy layout info") if(dataset->shared->space && H5S_close(dataset->shared->space) < 0) @@ -1763,17 +1700,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5D_close - * - * Purpose: Insures that all data has been saved to the file, closes the - * dataset object header, and frees all resources used by the - * descriptor. + * Function: H5D_close * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Robb Matzke - * Thursday, December 4, 1997 + * Purpose: Insures that all data has been saved to the file, closes the + * dataset object header, and frees all resources used by the + * descriptor. * + * Return: Non-negative on success/Negative on failure *------------------------------------------------------------------------- */ herr_t @@ -1896,7 +1829,7 @@ H5D_close(H5D_t *dataset) if(H5AC_cork(dataset->oloc.file, dataset->oloc.addr, H5AC__GET_CORKED, &corked) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve an object's cork status") if(corked) - if(H5AC_cork(dataset->oloc.file, dataset->oloc.addr, H5AC__UNCORK, NULL) < 0) + if(H5AC_cork(dataset->oloc.file, dataset->oloc.addr, H5AC__UNCORK, NULL) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTUNCORK, FAIL, "unable to uncork an object") /* @@ -1920,9 +1853,9 @@ H5D_close(H5D_t *dataset) /* Evict dataset metadata if evicting on close */ if(!file_closed && H5F_SHARED(dataset->oloc.file) && H5F_EVICT_ON_CLOSE(dataset->oloc.file)) { - if(H5AC_flush_tagged_metadata(dataset->oloc.file, dataset->oloc.addr, H5AC_ind_read_dxpl_id) < 0) + if(H5AC_flush_tagged_metadata(dataset->oloc.file, dataset->oloc.addr, H5AC_ind_read_dxpl_id) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush tagged metadata") - if(H5AC_evict_tagged_metadata(dataset->oloc.file, dataset->oloc.addr, FALSE, H5AC_ind_read_dxpl_id) < 0) + if(H5AC_evict_tagged_metadata(dataset->oloc.file, dataset->oloc.addr, FALSE, H5AC_ind_read_dxpl_id) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to evict tagged metadata") } /* end if */ @@ -1969,23 +1902,19 @@ done: /*------------------------------------------------------------------------- - * Function: H5D_mult_refresh_close - * - * Purpose: Closing down the needed information when the dataset has - * multiple opens. (From H5O_refresh_metadata_close()) + * Function: H5D_mult_refresh_close * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Vailin Choi - * 12/24/15 + * Purpose: Closing down the needed information when the dataset has + * multiple opens. (From H5O_refresh_metadata_close()) * + * Return: Non-negative on success/Negative on failure *------------------------------------------------------------------------- */ herr_t H5D_mult_refresh_close(hid_t dset_id, hid_t dxpl_id) { - H5D_t *dataset; /* Dataset to refresh */ - herr_t ret_value = SUCCEED; /* return value */ + H5D_t *dataset; /* Dataset to refresh */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2051,16 +1980,12 @@ done: /*------------------------------------------------------------------------- - * Function: H5D_mult_refresh_reopen - * - * Purpose: Re-initialize the needed info when the dataset has multiple - * opens. (From H5O_refresh_metadata_reopen()) + * Function: H5D_mult_refresh_reopen * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Vailin Choi - * 12/24/15 + * Purpose: Re-initialize the needed info when the dataset has multiple + * opens. (From H5O_refresh_metadata_reopen()) * + * Return: Non-negative on success/Negative on failure *------------------------------------------------------------------------- */ herr_t @@ -2075,25 +2000,25 @@ H5D_mult_refresh_reopen(H5D_t *dataset, hid_t dxpl_id) HDassert(dataset->shared->fo_count > 0); if(dataset->shared->fo_count > 1) { - /* Release dataspace info */ - if(H5S_close(dataset->shared->space) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to release dataspace") - - /* Re-load dataspace info */ - if(NULL == (dataset->shared->space = H5S_read(&(dataset->oloc), dxpl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to load dataspace info from dataset header") - - /* Cache the dataset's dataspace info */ - if(H5D__cache_dataspace_info(dataset) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't cache dataspace info") - - /* Release layout info */ - if(H5O_msg_reset(H5O_LAYOUT_ID, &dataset->shared->layout) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset layout info") - - /* Re-load layout message info */ - if(NULL == H5O_msg_read(&(dataset->oloc), H5O_LAYOUT_ID, &(dataset->shared->layout), dxpl_id)) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to read data layout message") + /* Release dataspace info */ + if(H5S_close(dataset->shared->space) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to release dataspace") + + /* Re-load dataspace info */ + if(NULL == (dataset->shared->space = H5S_read(&(dataset->oloc), dxpl_id))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to load dataspace info from dataset header") + + /* Cache the dataset's dataspace info */ + if(H5D__cache_dataspace_info(dataset) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't cache dataspace info") + + /* Release layout info */ + if(H5O_msg_reset(H5O_LAYOUT_ID, &dataset->shared->layout) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTRESET, FAIL, "unable to reset layout info") + + /* Re-load layout message info */ + if(NULL == H5O_msg_read(&(dataset->oloc), H5O_LAYOUT_ID, &(dataset->shared->layout), dxpl_id)) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to read data layout message") } /* end if */ done: @@ -2102,16 +2027,12 @@ done: /*------------------------------------------------------------------------- - * Function: H5D_oloc - * - * Purpose: Returns a pointer to the object location for a dataset. - * - * Return: Success: Ptr to location - * Failure: NULL + * Function: H5D_oloc * - * Programmer: Robb Matzke - * Friday, April 24, 1998 + * Purpose: Returns a pointer to the object location for a dataset. * + * Return: Success: Ptr to location + * Failure: NULL *------------------------------------------------------------------------- */ H5O_loc_t * @@ -2125,16 +2046,12 @@ H5D_oloc(H5D_t *dataset) /*------------------------------------------------------------------------- - * Function: H5D_nameof + * Function: H5D_nameof * - * Purpose: Returns a pointer to the group hier. path for a dataset. - * - * Return: Success: Ptr to entry - * Failure: NULL - * - * Programmer: Quincey Koziol - * Monday, September 12, 2005 + * Purpose: Returns a pointer to the group hier. path for a dataset. * + * Return: Success: Ptr to entry + * Failure: NULL *------------------------------------------------------------------------- */ H5G_name_t * @@ -2148,17 +2065,13 @@ H5D_nameof(H5D_t *dataset) /*------------------------------------------------------------------------- - * Function: H5D_typeof - * - * Purpose: Returns a pointer to the dataset's datatype. The datatype - * is not copied. - * - * Return: Success: Ptr to the dataset's datatype, uncopied. - * Failure: NULL + * Function: H5D_typeof * - * Programmer: Robb Matzke - * Thursday, June 4, 1998 + * Purpose: Returns a pointer to the dataset's datatype. The datatype + * is not copied. * + * Return: Success: Ptr to the dataset's datatype, uncopied. + * Failure: NULL *------------------------------------------------------------------------- */ H5T_t * @@ -2176,15 +2089,11 @@ H5D_typeof(const H5D_t *dset) /*------------------------------------------------------------------------- - * Function: H5D__alloc_storage + * Function: H5D__alloc_storage * - * Purpose: Allocate storage for the raw data of a dataset. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Robb Matzke - * Friday, January 16, 1998 + * Purpose: Allocate storage for the raw data of a dataset. * + * Return: Non-negative on success/Negative on failure *------------------------------------------------------------------------- */ herr_t @@ -2192,11 +2101,11 @@ H5D__alloc_storage(const H5D_io_info_t *io_info, H5D_time_alloc_t time_alloc, hbool_t full_overwrite, hsize_t old_dim[]) { const H5D_t *dset = io_info->dset; /* The dataset object */ - H5F_t *f = dset->oloc.file; /* The dataset's file pointer */ - H5O_layout_t *layout; /* The dataset's layout information */ - hbool_t must_init_space = FALSE; /* Flag to indicate that space should be initialized */ - hbool_t addr_set = FALSE; /* Flag to indicate that the dataset's storage address was set */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_t *f = dset->oloc.file; /* The dataset's file pointer */ + H5O_layout_t *layout; /* The dataset's layout information */ + hbool_t must_init_space = FALSE; /* Flag to indicate that space should be initialized */ + hbool_t addr_set = FALSE; /* Flag to indicate that the dataset's storage address was set */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2246,19 +2155,18 @@ H5D__alloc_storage(const H5D_io_info_t *io_info, H5D_time_alloc_t time_alloc, } /* end if */ /* If space allocation is set to 'early' and we are extending - * the dataset, indicate that space should be allocated, so the + * the dataset, indicate that space should be allocated, so the * index gets expanded. -QAK */ - if(dset->shared->dcpl_cache.fill.alloc_time == H5D_ALLOC_TIME_EARLY - && time_alloc == H5D_ALLOC_EXTEND) - must_init_space = TRUE; + if(dset->shared->dcpl_cache.fill.alloc_time == H5D_ALLOC_TIME_EARLY && time_alloc == H5D_ALLOC_EXTEND) + must_init_space = TRUE; break; case H5D_COMPACT: /* Check if space is already allocated */ if(NULL == layout->storage.u.compact.buf) { - /* Reserve space in layout header message for the entire array. - * Starting from the 1.8.7 release, we allow dataspace to have + /* Reserve space in layout header message for the entire array. + * Starting from the 1.8.7 release, we allow dataspace to have * zero dimension size. So the storage size can be zero. * SLU 2011/4/4 */ if(layout->storage.u.compact.size > 0) { @@ -2270,7 +2178,8 @@ H5D__alloc_storage(const H5D_io_info_t *io_info, H5D_time_alloc_t time_alloc, /* Indicate that we should initialize storage space */ must_init_space = TRUE; - } else { + } + else { layout->storage.u.compact.dirty = FALSE; must_init_space = FALSE; } @@ -2312,7 +2221,7 @@ H5D__alloc_storage(const H5D_io_info_t *io_info, H5D_time_alloc_t time_alloc, HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize dataset with fill value") } /* end if */ else { - H5D_fill_value_t fill_status; /* The fill value status */ + H5D_fill_value_t fill_status; /* The fill value status */ /* Check the dataset's fill-value status */ if(H5P_is_fill_value_defined(&dset->shared->dcpl_cache.fill, &fill_status) < 0) @@ -2346,24 +2255,20 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__init_storage + * Function: H5D__init_storage * - * Purpose: Initialize the data for a new dataset. If a selection is - * defined for SPACE then initialize only that part of the - * dataset. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Robb Matzke - * Monday, October 5, 1998 + * Purpose: Initialize the data for a new dataset. If a selection is + * defined for SPACE then initialize only that part of the + * dataset. * + * Return: Non-negative on success/Negative on failure *------------------------------------------------------------------------- */ static herr_t H5D__init_storage(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_t old_dim[]) { const H5D_t *dset = io_info->dset; /* dataset pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -2422,22 +2327,18 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__get_storage_size - * - * Purpose: Determines how much space has been reserved to store the raw - * data of a dataset. + * Function: H5D__get_storage_size * - * Return: Non-negative on success, negative on failure - * - * Programmer: Robb Matzke - * Wednesday, April 21, 1999 + * Purpose: Determines how much space has been reserved to store the raw + * data of a dataset. * + * Return: Non-negative on success, negative on failure *------------------------------------------------------------------------- */ herr_t H5D__get_storage_size(H5D_t *dset, hid_t dxpl_id, hsize_t *storage_size) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(dxpl_id, dset->oloc.addr, FAIL) @@ -2481,24 +2382,19 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__get_offset - * - * Purpose: Private function for H5D__get_offset. Returns the address - * of dataset in file. - * - * Return: Success: the address of dataset - * - * Failure: HADDR_UNDEF + * Function: H5D__get_offset * - * Programmer: Raymond Lu - * November 6, 2002 + * Purpose: Private function for H5D__get_offset. Returns the address + * of dataset in file. * + * Return: Success: the address of dataset + * Failure: HADDR_UNDEF *------------------------------------------------------------------------- */ haddr_t H5D__get_offset(const H5D_t *dset) { - haddr_t ret_value = HADDR_UNDEF; + haddr_t ret_value = HADDR_UNDEF; FUNC_ENTER_PACKAGE @@ -2530,18 +2426,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5D_vlen_reclaim + * Function: H5D_vlen_reclaim * - * Purpose: Frees the buffers allocated for storing variable-length data - * in memory. Only frees the VL data in the selection defined in the - * dataspace. The dataset transfer property list is required to find the - * correct allocation/free methods for the VL data in the buffer. - * - * Return: Non-negative on success, negative on failure - * - * Programmer: Quincey Koziol - * Tuesday, November 22, 2005 + * Purpose: Frees the buffers allocated for storing variable-length data + * in memory. Only frees the VL data in the selection defined in the + * dataspace. The dataset transfer property list is required to find the + * correct allocation/free methods for the VL data in the buffer. * + * Return: Non-negative on success, negative on failure *------------------------------------------------------------------------- */ herr_t @@ -2551,7 +2443,7 @@ H5D_vlen_reclaim(hid_t type_id, H5S_t *space, hid_t plist_id, void *buf) H5S_sel_iter_op_t dset_op; /* Operator for iteration */ H5T_vlen_alloc_info_t _vl_alloc_info; /* VL allocation info buffer */ H5T_vlen_alloc_info_t *vl_alloc_info = &_vl_alloc_info; /* VL allocation info */ - herr_t ret_value = FAIL; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2581,18 +2473,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__vlen_get_buf_size_alloc - * - * Purpose: This routine makes certain there is enough space in the temporary - * buffer for the new data to read in. All the VL data read in is actually - * placed in this buffer, overwriting the previous data. Needless to say, - * this data is not actually usable. - * - * Return: Non-negative on success, negative on failure + * Function: H5D__vlen_get_buf_size_alloc * - * Programmer: Quincey Koziol - * Tuesday, August 17, 1999 + * Purpose: This routine makes certain there is enough space in the temporary + * buffer for the new data to read in. All the VL data read in is actually + * placed in this buffer, overwriting the previous data. Needless to say, + * this data is not actually usable. * + * Return: Non-negative on success, negative on failure *------------------------------------------------------------------------- */ void * @@ -2615,14 +2503,14 @@ H5D__vlen_get_buf_size_alloc(size_t size, void *info) /*------------------------------------------------------------------------- - * Function: H5D__vlen_get_buf_size + * Function: H5D__vlen_get_buf_size * - * Purpose: This routine checks the number of bytes required to store a single - * element from a dataset in memory, creating a selection with just the - * single element selected to read in the element and using a custom memory - * allocator for any VL data encountered. - * The *size value is modified according to how many bytes are - * required to store the element in memory. + * Purpose: This routine checks the number of bytes required to store a single + * element from a dataset in memory, creating a selection with just the + * single element selected to read in the element and using a custom memory + * allocator for any VL data encountered. + * The *size value is modified according to how many bytes are + * required to store the element in memory. * * Implementation: This routine actually performs the read with a custom * memory manager which basically just counts the bytes requested and @@ -2632,11 +2520,7 @@ H5D__vlen_get_buf_size_alloc(size_t size, void *info) * Kinda kludgy, but easier than the other method of trying to figure out * the sizes without actually reading the data in... - QAK * - * Return: Non-negative on success, negative on failure - * - * Programmer: Quincey Koziol - * Tuesday, August 17, 1999 - * + * Return: Non-negative on success, negative on failure *------------------------------------------------------------------------- */ herr_t @@ -2673,15 +2557,11 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__check_filters - * - * Purpose: Check if the filters have be initialized for the dataset - * - * Return: Non-negative on success/Negative on failure + * Function: H5D__check_filters * - * Programmer: Quincey Koziol - * Thursday, October 11, 2007 + * Purpose: Check if the filters have be initialized for the dataset * + * Return: Non-negative on success/Negative on failure *------------------------------------------------------------------------- */ herr_t @@ -2727,16 +2607,12 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__set_extent + * Function: H5D__set_extent * - * Purpose: Based on H5D_extend, allows change to a lower dimension, - * calls H5S_set_extent and H5D__chunk_prune_by_extent instead - * - * Return: Non-negative on success, negative on failure - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * April 9, 2002 + * Purpose: Based on H5D_extend, allows change to a lower dimension, + * calls H5S_set_extent and H5D__chunk_prune_by_extent instead * + * Return: Non-negative on success, negative on failure *------------------------------------------------------------------------- */ herr_t @@ -2810,7 +2686,7 @@ H5D__set_extent(H5D_t *dset, const hsize_t *size, hid_t dxpl_id) dset->shared->cache.chunk.scaled_dims[u] > dset->shared->cache.chunk.nslots)) update_chunks = TRUE; - if( !(scaled_power2up = H5VM_power2up(scaled)) ) + if(!(scaled_power2up = H5VM_power2up(scaled))) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get the next power of 2") /* Check if the number of bits required to encode the scaled size value changed */ @@ -2899,7 +2775,7 @@ H5D__set_extent(H5D_t *dset, const hsize_t *size, hid_t dxpl_id) && (dset->shared->dcpl_cache.pline.nused > 0)) if(H5D__chunk_update_old_edge_chunks(dset, dxpl_id, curr_dims) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to do update old edge chunks") - } /* end if */ + } /* end if */ /* Mark the dataspace as dirty, for later writing to the file */ if(H5D__mark(dset, dxpl_id, H5D_MARK_SPACE) < 0) @@ -2912,16 +2788,12 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__flush_sieve_buf + * Function: H5D__flush_sieve_buf * - * Purpose: Flush any dataset sieve buffer info cached in memory - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Quincey Koziol - * July 27, 2009 + * Purpose: Flush any dataset sieve buffer info cached in memory * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t @@ -2953,16 +2825,12 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__flush_real - * - * Purpose: Flush any dataset information cached in memory - * - * Return: Success: Non-negative - * Failure: Negative + * Function: H5D__flush_real * - * Programmer: Quincey Koziol - * December 6, 2007 + * Purpose: Flush any dataset information cached in memory * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t @@ -2990,29 +2858,25 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__format_convert + * Function: H5D__format_convert * - * Purpose: For chunked: downgrade the chunk indexing type to version 1 B-tree - * For compact/contiguous: downgrade layout version to 3 - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Vailin Choi - * Feb 2015 + * Purpose: For chunked: downgrade the chunk indexing type to version 1 B-tree + * For compact/contiguous: downgrade layout version to 3 * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t H5D__format_convert(H5D_t *dataset, hid_t dxpl_id) { - H5D_chk_idx_info_t new_idx_info; /* Index info for the new layout */ - H5D_chk_idx_info_t idx_info; /* Index info for the current layout */ + H5D_chk_idx_info_t new_idx_info; /* Index info for the new layout */ + H5D_chk_idx_info_t idx_info; /* Index info for the current layout */ H5O_layout_t *newlayout = NULL; /* The new layout */ hbool_t init_new_index = FALSE; /* Indicate that the new chunk index is initialized */ - hbool_t delete_old_layout = FALSE; /* Indicate that the old layout message is deleted */ + hbool_t delete_old_layout = FALSE; /* Indicate that the old layout message is deleted */ hbool_t add_new_layout = FALSE; /* Indicate that the new layout message is added */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(dxpl_id, dataset->oloc.addr, FAIL) @@ -3062,7 +2926,7 @@ H5D__format_convert(H5D_t *dataset, hid_t dxpl_id) if((new_idx_info.storage->ops->create)(&new_idx_info) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't create chunk index") - /* Iterate over the chunks in the current index and insert the chunk addresses + /* Iterate over the chunks in the current index and insert the chunk addresses * into the version 1 B-tree chunk index */ if(H5D__chunk_format_convert(dataset, &idx_info, &new_idx_info) < 0) @@ -3105,7 +2969,7 @@ H5D__format_convert(H5D_t *dataset, hid_t dxpl_id) case H5D_NLAYOUTS: HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset layout type") - default: + default: HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unknown dataset layout type") } /* end switch */ @@ -3147,16 +3011,12 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__mark - * - * Purpose: Mark some aspect of a dataset as dirty + * Function: H5D__mark * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Quincey Koziol - * July 4, 2008 + * Purpose: Mark some aspect of a dataset as dirty * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t @@ -3212,24 +3072,20 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__flush_cb - * - * Purpose: Flush any dataset information cached in memory + * Function: H5D__flush_cb * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Quincey Koziol - * November 8, 2007 + * Purpose: Flush any dataset information cached in memory * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ static int H5D__flush_cb(void *_dataset, hid_t H5_ATTR_UNUSED id, void *_udata) { - H5D_t *dataset = (H5D_t *)_dataset; /* Dataset pointer */ + H5D_t *dataset = (H5D_t *)_dataset; /* Dataset pointer */ H5D_flush_ud_t *udata = (H5D_flush_ud_t *)_udata; /* User data for callback */ - int ret_value = H5_ITER_CONT; /* Return value */ + int ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_STATIC @@ -3249,23 +3105,19 @@ done: /*------------------------------------------------------------------------- - * Function: H5D_flush - * - * Purpose: Flush any dataset information cached in memory + * Function: H5D_flush * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Ray Lu - * August 14, 2002 + * Purpose: Flush any dataset information cached in memory * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t H5D_flush(const H5F_t *f, hid_t dxpl_id) { - H5D_flush_ud_t udata; /* User data for callback */ - herr_t ret_value = SUCCEED; /* Return value */ + H5D_flush_ud_t udata; /* User data for callback */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3286,19 +3138,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5D_get_create_plist - * - * Purpose: Private function for H5Dget_create_plist - * - * Return: Success: ID for a copy of the dataset creation - * property list. The template should be - * released by calling H5P_close(). + * Function: H5D_get_create_plist * - * Failure: FAIL - * - * Programmer: Robb Matzke - * Tuesday, February 3, 1998 + * Purpose: Private function for H5Dget_create_plist * + * Return: Success: ID for a copy of the dataset creation + * property list. The template should be + * released by calling H5P_close(). + * Failure: FAIL *------------------------------------------------------------------------- */ hid_t @@ -3309,8 +3156,8 @@ H5D_get_create_plist(H5D_t *dset) H5O_layout_t copied_layout; /* Layout to tweak */ H5O_fill_t copied_fill; /* Fill value to tweak */ H5O_efl_t copied_efl; /* External file list to tweak */ - hid_t new_dcpl_id = FAIL; - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t new_dcpl_id = FAIL; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3351,7 +3198,7 @@ H5D_get_create_plist(H5D_t *dset) /* Reset index info, if the chunk ops are set */ if(copied_layout.storage.u.chunk.ops) - /* Reset address and pointer of the array struct for the chunked storage index */ + /* Reset address and pointer of the array struct for the chunked storage index */ if(H5D_chunk_idx_reset(&copied_layout.storage.u.chunk, TRUE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to reset chunked storage index in dest") @@ -3468,18 +3315,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5D_get_access_plist - * - * Purpose: Returns a copy of the dataset access property list. - * - * Return: Success: ID for a copy of the dataset access - * property list. - * - * Failure: FAIL + * Function: H5D_get_access_plist * - * Programmer: Mohamad Chaarawi - * March, 2012 + * Purpose: Returns a copy of the dataset access property list. * + * Return: Success: ID for a copy of the dataset access + * property list. + * Failure: FAIL *------------------------------------------------------------------------- */ hid_t @@ -3537,24 +3379,19 @@ done: /*------------------------------------------------------------------------- - * Function: H5D_get_space - * - * Purpose: Returns and ID for the dataspace of the dataset. - * - * Return: Success: ID for dataspace - * - * Failure: FAIL + * Function: H5D_get_space * - * Programmer: Mohamad Chaarawi - * March, 2012 + * Purpose: Returns and ID for the dataspace of the dataset. * + * Return: Success: ID for dataspace + * Failure: FAIL *------------------------------------------------------------------------- */ hid_t H5D_get_space(H5D_t *dset) { - H5S_t *space = NULL; - hid_t ret_value = H5I_INVALID_HID; + H5S_t *space = NULL; + hid_t ret_value = H5I_INVALID_HID; FUNC_ENTER_NOAPI_NOINIT @@ -3582,24 +3419,19 @@ done: /*------------------------------------------------------------------------- - * Function: H5D_get_type + * Function: H5D_get_type * - * Purpose: Returns and ID for the datatype of the dataset. - * - * Return: Success: ID for datatype - * - * Failure: FAIL - * - * Programmer: Mohamad Chaarawi - * March, 2012 + * Purpose: Returns and ID for the datatype of the dataset. * + * Return: Success: ID for datatype + * Failure: FAIL *------------------------------------------------------------------------- */ hid_t H5D_get_type(H5D_t *dset) { - H5T_t *dt = NULL; - hid_t ret_value = FAIL; + H5T_t *dt = NULL; + hid_t ret_value = FAIL; FUNC_ENTER_NOAPI_NOINIT @@ -3633,15 +3465,11 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__refresh + * Function: H5D__refresh * - * Purpose: Refreshes all buffers associated with a dataset. - * - * Return: SUCCEED/FAIL - * - * Programmer: Dana Robinson - * November 2015 + * Purpose: Refreshes all buffers associated with a dataset. * + * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ herr_t @@ -3668,7 +3496,7 @@ H5D__refresh(hid_t dset_id, H5D_t *dset, hid_t dxpl_id) if(H5D__virtual_refresh_source_dsets(dset, dxpl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to refresh VDS source datasets") } /* end if */ - + /* Refresh dataset object */ if((H5O_refresh_metadata(dset_id, dset->oloc, dxpl_id)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to refresh dataset") -- cgit v0.12 From 218845c603e1bdbae92fb4ec4483781b0b889a47 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 8 Nov 2017 09:57:15 -0600 Subject: Remove tabs --- src/H5Dpkg.h | 136 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index 097fab7..beb1089 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -12,12 +12,12 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Monday, April 14, 2003 + * Programmer: Quincey Koziol + * Monday, April 14, 2003 * - * Purpose: This file contains declarations which are visible only within - * the H5D package. Source files outside the H5D package should - * include H5Dprivate.h instead. + * Purpose: This file contains declarations which are visible only within + * the H5D package. Source files outside the H5D package should + * include H5Dprivate.h instead. */ #if !(defined H5D_FRIEND || defined H5D_MODULE) #error "Do not include this file outside the H5D package!" @@ -30,12 +30,12 @@ #include "H5Dprivate.h" /* Other private headers needed by this file */ -#include "H5ACprivate.h" /* Metadata cache */ +#include "H5ACprivate.h" /* Metadata cache */ #include "H5B2private.h" /* v2 B-trees */ -#include "H5Fprivate.h" /* File access */ -#include "H5Gprivate.h" /* Groups */ -#include "H5SLprivate.h" /* Skip lists */ -#include "H5Tprivate.h" /* Datatypes */ +#include "H5Fprivate.h" /* File access */ +#include "H5Gprivate.h" /* Groups */ +#include "H5SLprivate.h" /* Skip lists */ +#include "H5Tprivate.h" /* Datatypes */ /**************************/ /* Package Private Macros */ @@ -70,22 +70,22 @@ /* See H5O_layout_chunk_t */ /* Fixed array creation values */ -#define H5D_FARRAY_CREATE_PARAM_SIZE 1 /* Size of the creation parameters in bytes */ -#define H5D_FARRAY_MAX_DBLK_PAGE_NELMTS_BITS 10 /* i.e. 1024 elements per data block page */ +#define H5D_FARRAY_CREATE_PARAM_SIZE 1 /* Size of the creation parameters in bytes */ +#define H5D_FARRAY_MAX_DBLK_PAGE_NELMTS_BITS 10 /* i.e. 1024 elements per data block page */ /* Extensible array creation values */ -#define H5D_EARRAY_CREATE_PARAM_SIZE 5 /* Size of the creation parameters in bytes */ -#define H5D_EARRAY_MAX_NELMTS_BITS 32 /* i.e. 4 giga-elements */ -#define H5D_EARRAY_IDX_BLK_ELMTS 4 -#define H5D_EARRAY_SUP_BLK_MIN_DATA_PTRS 4 -#define H5D_EARRAY_DATA_BLK_MIN_ELMTS 16 -#define H5D_EARRAY_MAX_DBLOCK_PAGE_NELMTS_BITS 10 /* i.e. 1024 elements per data block page */ +#define H5D_EARRAY_CREATE_PARAM_SIZE 5 /* Size of the creation parameters in bytes */ +#define H5D_EARRAY_MAX_NELMTS_BITS 32 /* i.e. 4 giga-elements */ +#define H5D_EARRAY_IDX_BLK_ELMTS 4 +#define H5D_EARRAY_SUP_BLK_MIN_DATA_PTRS 4 +#define H5D_EARRAY_DATA_BLK_MIN_ELMTS 16 +#define H5D_EARRAY_MAX_DBLOCK_PAGE_NELMTS_BITS 10 /* i.e. 1024 elements per data block page */ /* v2 B-tree creation values for raw meta_size */ -#define H5D_BT2_CREATE_PARAM_SIZE 6 /* Size of the creation parameters in bytes */ -#define H5D_BT2_NODE_SIZE 2048 -#define H5D_BT2_SPLIT_PERC 100 -#define H5D_BT2_MERGE_PERC 40 +#define H5D_BT2_CREATE_PARAM_SIZE 6 /* Size of the creation parameters in bytes */ +#define H5D_BT2_NODE_SIZE 2048 +#define H5D_BT2_SPLIT_PERC 100 +#define H5D_BT2_MERGE_PERC 40 /****************************/ @@ -97,23 +97,23 @@ typedef struct H5D_type_info_t { /* Initial values */ const H5T_t *mem_type; /* Pointer to memory datatype */ const H5T_t *dset_type; /* Pointer to dataset datatype */ - H5T_path_t *tpath; /* Datatype conversion path */ + H5T_path_t *tpath; /* Datatype conversion path */ hid_t src_type_id; /* Source datatype ID */ hid_t dst_type_id; /* Destination datatype ID */ /* Computed/derived values */ - size_t src_type_size; /* Size of source type */ - size_t dst_type_size; /* Size of destination type */ - size_t max_type_size; /* Size of largest source/destination type */ - hbool_t is_conv_noop; /* Whether the type conversion is a NOOP */ - hbool_t is_xform_noop; /* Whether the data transform is a NOOP */ + size_t src_type_size; /* Size of source type */ + size_t dst_type_size; /* Size of destination type */ + size_t max_type_size; /* Size of largest source/destination type */ + hbool_t is_conv_noop; /* Whether the type conversion is a NOOP */ + hbool_t is_xform_noop; /* Whether the data transform is a NOOP */ const H5T_subset_info_t *cmpd_subset; /* Info related to the compound subset conversion functions */ - H5T_bkg_t need_bkg; /* Type of background buf needed */ - size_t request_nelmts; /* Requested strip mine */ - uint8_t *tconv_buf; /* Datatype conv buffer */ - hbool_t tconv_buf_allocated; /* Whether the type conversion buffer was allocated */ - uint8_t *bkg_buf; /* Background buffer */ - hbool_t bkg_buf_allocated; /* Whether the background buffer was allocated */ + H5T_bkg_t need_bkg; /* Type of background buf needed */ + size_t request_nelmts; /* Requested strip mine */ + uint8_t *tconv_buf; /* Datatype conv buffer */ + hbool_t tconv_buf_allocated; /* Whether the type conversion buffer was allocated */ + uint8_t *bkg_buf; /* Background buffer */ + hbool_t bkg_buf_allocated; /* Whether the background buffer was allocated */ } H5D_type_info_t; /* Forward declaration of structs used below */ @@ -191,13 +191,13 @@ typedef struct { } H5D_chunk_storage_t; typedef struct { - void *buf; /* Buffer for compact dataset */ + void *buf; /* Buffer for compact dataset */ hbool_t *dirty; /* Pointer to dirty flag to mark */ } H5D_compact_storage_t; typedef union H5D_storage_t { H5D_contig_storage_t contig; /* Contiguous information for dataset */ - H5D_chunk_storage_t chunk; /* Chunk information for dataset */ + H5D_chunk_storage_t chunk; /* Chunk information for dataset */ H5D_compact_storage_t compact; /* Compact information for dataset */ H5O_efl_t efl; /* External file list information for dataset */ } H5D_storage_t; @@ -261,10 +261,10 @@ typedef struct H5D_chk_idx_info_t { * The chunk's file address, filter mask and size on disk are not key values. */ typedef struct H5D_chunk_rec_t { - hsize_t scaled[H5O_LAYOUT_NDIMS]; /* Logical offset to start */ - uint32_t nbytes; /* Size of stored data */ - uint32_t filter_mask; /* Excluded filters */ - haddr_t chunk_addr; /* Address of chunk in file */ + hsize_t scaled[H5O_LAYOUT_NDIMS]; /* Logical offset to start */ + uint32_t nbytes; /* Size of stored data */ + uint32_t filter_mask; /* Excluded filters */ + haddr_t chunk_addr; /* Address of chunk in file */ } H5D_chunk_rec_t; /* @@ -273,9 +273,9 @@ typedef struct H5D_chunk_rec_t { * to which the index points. */ typedef struct H5D_chunk_common_ud_t { - const H5O_layout_chunk_t *layout; /* Chunk layout description */ - const H5O_storage_chunk_t *storage; /* Chunk storage description */ - const hsize_t *scaled; /* Scaled coordinates for a chunk */ + const H5O_layout_chunk_t *layout; /* Chunk layout description */ + const H5O_storage_chunk_t *storage; /* Chunk storage description */ + const hsize_t *scaled; /* Scaled coordinates for a chunk */ } H5D_chunk_common_ud_t; /* B-tree callback info for various operations */ @@ -286,7 +286,7 @@ typedef struct H5D_chunk_ud_t { /* Upward */ unsigned idx_hint; /* Index of chunk in cache, if present */ H5F_block_t chunk_block; /* Offset/length of chunk in file */ - unsigned filter_mask; /* Excluded filters */ + unsigned filter_mask; /* Excluded filters */ hbool_t new_unfilt_chunk; /* Whether the chunk just became unfiltered */ hsize_t chunk_idx; /* Chunk index for EA, FA indexing */ } H5D_chunk_ud_t; @@ -386,11 +386,11 @@ typedef struct H5D_chunk_map_t { /* Cached information about a particular chunk */ typedef struct H5D_chunk_cached_t { hbool_t valid; /*whether cache info is valid*/ - hsize_t scaled[H5O_LAYOUT_NDIMS]; /*scaled offset of chunk*/ - haddr_t addr; /*file address of chunk */ - uint32_t nbytes; /*size of stored data */ - hsize_t chunk_idx; /*index of chunk in dataset */ - unsigned filter_mask; /*excluded filters */ + hsize_t scaled[H5O_LAYOUT_NDIMS]; /*scaled offset of chunk*/ + haddr_t addr; /*file address of chunk */ + uint32_t nbytes; /*size of stored data */ + hsize_t chunk_idx; /*index of chunk in dataset */ + unsigned filter_mask; /*excluded filters */ } H5D_chunk_cached_t; /****************************/ @@ -407,23 +407,23 @@ typedef struct H5D_virtual_held_file_t { struct H5D_rdcc_ent_t; /* Forward declaration of struct used below */ typedef struct H5D_rdcc_t { struct { - unsigned ninits; /* Number of chunk creations */ - unsigned nhits; /* Number of cache hits */ - unsigned nmisses;/* Number of cache misses */ - unsigned nflushes;/* Number of cache flushes */ + unsigned ninits; /* Number of chunk creations */ + unsigned nhits; /* Number of cache hits */ + unsigned nmisses; /* Number of cache misses */ + unsigned nflushes; /* Number of cache flushes */ } stats; - size_t nbytes_max; /* Maximum cached raw data in bytes */ - size_t nslots; /* Number of chunk slots allocated */ - double w0; /* Chunk preemption policy */ - struct H5D_rdcc_ent_t *head; /* Head of doubly linked list */ - struct H5D_rdcc_ent_t *tail; /* Tail of doubly linked list */ + size_t nbytes_max; /* Maximum cached raw data in bytes */ + size_t nslots; /* Number of chunk slots allocated */ + double w0; /* Chunk preemption policy */ + struct H5D_rdcc_ent_t *head; /* Head of doubly linked list */ + struct H5D_rdcc_ent_t *tail; /* Tail of doubly linked list */ struct H5D_rdcc_ent_t *tmp_head; /* Head of temporary doubly linked list. Chunks on this list are not in the hash table (slot). The head entry is a sentinel (does not refer to an actual chunk). */ - size_t nbytes_used; /* Current cached raw data in bytes */ - int nused; /* Number of chunk slots in use */ + size_t nbytes_used; /* Current cached raw data in bytes */ + int nused; /* Number of chunk slots in use */ H5D_chunk_cached_t last; /* Cached copy of last chunk information */ struct H5D_rdcc_ent_t **slot; /* Chunk slots, each points to a chunk*/ - H5SL_t *sel_chunks; /* Skip list containing information for each chunk selected */ - H5S_t *single_space; /* Dataspace for single element I/O on chunks */ + H5SL_t *sel_chunks; /* Skip list containing information for each chunk selected */ + H5S_t *single_space; /* Dataspace for single element I/O on chunks */ H5D_chunk_info_t *single_chunk_info; /* Pointer to single chunk's info */ /* Cached information about scaled dataspace dimensions */ @@ -459,10 +459,10 @@ typedef struct H5D_shared_t { hbool_t checked_filters;/* TRUE if dataset passes can_apply check */ /* Cached dataspace info */ - unsigned ndims; /* The dataset's dataspace rank */ - hsize_t curr_dims[H5S_MAX_RANK]; /* The curr. size of dataset dimensions */ - hsize_t curr_power2up[H5S_MAX_RANK]; /* The curr. dim sizes, rounded up to next power of 2 */ - hsize_t max_dims[H5S_MAX_RANK]; /* The max. size of dataset dimensions */ + unsigned ndims; /* The dataset's dataspace rank */ + hsize_t curr_dims[H5S_MAX_RANK]; /* The curr. size of dataset dimensions */ + hsize_t curr_power2up[H5S_MAX_RANK]; /* The curr. dim sizes, rounded up to next power of 2 */ + hsize_t max_dims[H5S_MAX_RANK]; /* The max. size of dataset dimensions */ /* Buffered/cached information for types of raw data storage*/ struct { @@ -474,7 +474,7 @@ typedef struct H5D_shared_t { H5D_rdcc_t chunk; /* Information about chunked data */ } cache; - H5D_append_flush_t append_flush; /* Append flush property information */ + H5D_append_flush_t append_flush; /* Append flush property information */ char *extfile_prefix; /* expanded external file prefix */ } H5D_shared_t; @@ -689,7 +689,7 @@ H5_DLL herr_t H5D__chunk_bh_info(const H5O_loc_t *loc, hid_t dxpl_id, H5O_t *oh, H5_DLL herr_t H5D__chunk_dump_index(H5D_t *dset, hid_t dxpl_id, FILE *stream); H5_DLL herr_t H5D__chunk_delete(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5O_storage_t *store); -H5_DLL herr_t H5D__chunk_direct_write(const H5D_t *dset, hid_t dxpl_id, uint32_t filters, +H5_DLL herr_t H5D__chunk_direct_write(const H5D_t *dset, hid_t dxpl_id, uint32_t filters, hsize_t *offset, uint32_t data_size, const void *buf); H5_DLL herr_t H5D__chunk_direct_read(const H5D_t *dset, hid_t dxpl_id, hsize_t *offset, uint32_t *filters, void *buf); -- cgit v0.12 From 480fc373a07e4b9a3aefd51f82accbc9411146b3 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 8 Nov 2017 09:59:58 -0600 Subject: Remove tabs --- src/H5Dprivate.h | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h index 5d565bb..fb994d8 100644 --- a/src/H5Dprivate.h +++ b/src/H5Dprivate.h @@ -21,10 +21,10 @@ #include "H5Dpublic.h" /* Private headers needed by this file */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Sprivate.h" /* Dataspaces */ -#include "H5Zprivate.h" /* Data filters */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Sprivate.h" /* Dataspaces */ +#include "H5Zprivate.h" /* Data filters */ /**************************/ @@ -33,18 +33,18 @@ /* * Feature: Define H5D_DEBUG on the compiler command line if you want to - * debug dataset I/O. NDEBUG must not be defined in order for this - * to have any effect. + * debug dataset I/O. NDEBUG must not be defined in order for this + * to have any effect. */ #ifdef NDEBUG # undef H5D_DEBUG #endif /* ======== Dataset creation property names ======== */ -#define H5D_CRT_LAYOUT_NAME "layout" /* Storage layout */ -#define H5D_CRT_FILL_VALUE_NAME "fill_value" /* Fill value */ +#define H5D_CRT_LAYOUT_NAME "layout" /* Storage layout */ +#define H5D_CRT_FILL_VALUE_NAME "fill_value" /* Fill value */ #define H5D_CRT_ALLOC_TIME_STATE_NAME "alloc_time_state" /* Space allocation time state */ -#define H5D_CRT_EXT_FILE_LIST_NAME "efl" /* External file list */ +#define H5D_CRT_EXT_FILE_LIST_NAME "efl" /* External file list */ /* ======== Dataset access property names ======== */ #define H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME "rdcc_nslots" /* Size of raw data chunk cache(slots) */ @@ -75,11 +75,11 @@ #define H5D_XFER_MPIO_CHUNK_OPT_RATIO_NAME "mpio_chunk_opt_ratio" #define H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_NAME "actual_chunk_opt_mode" #define H5D_MPIO_ACTUAL_IO_MODE_NAME "actual_io_mode" -#define H5D_MPIO_LOCAL_NO_COLLECTIVE_CAUSE_NAME "local_no_collective_cause" /* cause of broken collective I/O in each process */ +#define H5D_MPIO_LOCAL_NO_COLLECTIVE_CAUSE_NAME "local_no_collective_cause" /* cause of broken collective I/O in each process */ #define H5D_MPIO_GLOBAL_NO_COLLECTIVE_CAUSE_NAME "global_no_collective_cause" /* cause of broken collective I/O in all processes */ -#define H5D_XFER_EDC_NAME "err_detect" /* EDC */ -#define H5D_XFER_FILTER_CB_NAME "filter_cb" /* Filter callback function */ -#define H5D_XFER_CONV_CB_NAME "type_conv_cb" /* Type conversion callback function */ +#define H5D_XFER_EDC_NAME "err_detect" /* EDC */ +#define H5D_XFER_FILTER_CB_NAME "filter_cb" /* Filter callback function */ +#define H5D_XFER_CONV_CB_NAME "type_conv_cb" /* Type conversion callback function */ #define H5D_XFER_XFORM_NAME "data_transform" /* Data transform */ #ifdef H5_HAVE_INSTRUMENTED_LIBRARY /* Collective chunk instrumentation properties */ @@ -152,10 +152,10 @@ typedef struct H5D_copy_file_ud_t { /* Structure for dataset append flush property (H5Pset_append_flush) */ typedef struct H5D_append_flush_t { - unsigned ndims; /* The # of dimensions for "boundary" */ - hsize_t boundary[H5S_MAX_RANK]; /* The dimension sizes for determining boundary */ - H5D_append_cb_t func; /* The callback function */ - void *udata; /* User data */ + unsigned ndims; /* The # of dimensions for "boundary" */ + hsize_t boundary[H5S_MAX_RANK]; /* The dimension sizes for determining boundary */ + H5D_append_cb_t func; /* The callback function */ + void *udata; /* User data */ } H5D_append_flush_t; -- cgit v0.12 From 5717239a98f61dab289ce7c79d7768dc59755e3a Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 8 Nov 2017 11:11:22 -0600 Subject: Remove tabs --- src/H5F.c | 694 ++++++++++++++++++++------------------------------ src/H5Fint.c | 787 +++++++++++++++++++++++---------------------------------- src/H5Fquery.c | 625 ++++++++++++++++----------------------------- 3 files changed, 809 insertions(+), 1297 deletions(-) diff --git a/src/H5F.c b/src/H5F.c index 39eca13..4b40248 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -21,20 +21,20 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Aprivate.h" /* Attributes */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5SMprivate.h" /* Shared Object Header Messages */ -#include "H5Tprivate.h" /* Datatypes */ +#include "H5private.h" /* Generic Functions */ +#include "H5Aprivate.h" /* Attributes */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5SMprivate.h" /* Shared Object Header Messages */ +#include "H5Tprivate.h" /* Datatypes */ /****************/ @@ -76,10 +76,10 @@ hbool_t H5_PKG_INIT_VAR = FALSE; /* File ID class */ static const H5I_class_t H5I_FILE_CLS[1] = {{ - H5I_FILE, /* ID class value */ - 0, /* Class flags */ - 0, /* # of reserved IDs for class */ - (H5I_free_t)H5F_close /* Callback routine for closing objects of this class */ + H5I_FILE, /* ID class value */ + 0, /* Class flags */ + 0, /* # of reserved IDs for class */ + (H5I_free_t)H5F_close /* Callback routine for closing objects of this class */ }}; @@ -113,27 +113,22 @@ done: /*------------------------------------------------------------------------- - * Function: H5F_term_package + * Function: H5F_term_package * - * Purpose: Terminate this interface: free all memory and reset global - * variables to their initial values. Release all ID groups - * associated with this interface. - * - * Return: Success: Positive if anything was done that might - * have affected other interfaces; zero - * otherwise. - * - * Failure: Never fails. - * - * Programmer: Robb Matzke - * Friday, February 19, 1999 + * Purpose: Terminate this interface: free all memory and reset global + * variables to their initial values. Release all ID groups + * associated with this interface. * + * Return: Success: Positive if anything was done that might + * have affected other interfaces; + * zero otherwise. + * Failure: Never fails. *------------------------------------------------------------------------- */ int H5F_term_package(void) { - int n = 0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -141,7 +136,7 @@ H5F_term_package(void) if(H5I_nmembers(H5I_FILE) > 0) { (void)H5I_clear_type(H5I_FILE, FALSE, FALSE); n++; /*H5I*/ - } /* end if */ + } /* end if */ else { /* Make certain we've cleaned up all the shared file objects */ H5F_sfile_assert_num(0); @@ -160,18 +155,14 @@ H5F_term_package(void) /*------------------------------------------------------------------------- - * Function: H5Fget_create_plist - * - * Purpose: Get an atom for a copy of the file-creation property list for - * this file. This function returns an atom with a copy of the - * properties used to create a file. - * - * Return: Success: template ID + * Function: H5Fget_create_plist * - * Failure: FAIL - * - * Programmer: Unknown + * Purpose: Get an atom for a copy of the file-creation property list for + * this file. This function returns an atom with a copy of the + * properties used to create a file. * + * Return: Success: template ID + * Failure: FAIL *------------------------------------------------------------------------- */ hid_t @@ -200,24 +191,19 @@ done: /*------------------------------------------------------------------------- - * Function: H5Fget_access_plist + * Function: H5Fget_access_plist * - * Purpose: Returns a copy of the file access property list of the - * specified file. + * Purpose: Returns a copy of the file access property list of the + * specified file. * * NOTE: Make sure that, if you are going to overwrite * information in the copied property list that was * previously opened and assigned to the property list, then * you must close it before overwriting the values. * - * Return: Success: Object ID for a copy of the file access - * property list. - * - * Failure: FAIL - * - * Programmer: Robb Matzke - * Wednesday, February 18, 1998 - * + * Return: Success: Object ID for a copy of the file access + * property list. + * Failure: FAIL *------------------------------------------------------------------------- */ hid_t @@ -243,23 +229,19 @@ done: /*------------------------------------------------------------------------- - * Function: H5Fget_obj_count - * - * Purpose: Public function returning the number of opened object IDs - * (files, datasets, groups and datatypes) in the same file. + * Function: H5Fget_obj_count * - * Return: Non-negative on success; negative on failure. - * - * Programmer: Raymond Lu - * Wednesday, Dec 5, 2001 + * Purpose: Public function returning the number of opened object IDs + * (files, datasets, groups and datatypes) in the same file. * + * Return: Non-negative on success; negative on failure. *------------------------------------------------------------------------- */ ssize_t H5Fget_obj_count(hid_t file_id, unsigned types) { H5F_t *f = NULL; /* File to query */ - size_t obj_count = 0; /* Number of opened objects */ + size_t obj_count = 0; /* Number of opened objects */ ssize_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -284,21 +266,11 @@ done: /*------------------------------------------------------------------------- - * Function: H5Fget_object_ids - * - * Purpose: Public function to return a list of opened object IDs. - * - * Return: Non-negative on success; negative on failure. + * Function: H5Fget_object_ids * - * Programmer: Raymond Lu - * Wednesday, Dec 5, 2001 - * - * Modification: - * Raymond Lu - * 24 September 2008 - * Changed the return value to ssize_t and MAX_OBJTS to size_t to - * accommadate potential large number of objects. + * Purpose: Public function to return a list of opened object IDs. * + * Return: Non-negative on success; negative on failure. *------------------------------------------------------------------------- */ ssize_t @@ -339,10 +311,6 @@ done: * * Return: Success: non-negative value. * Failure: negative. - * - * Programmer: Raymond Lu - * Sep. 16, 2002 - * *------------------------------------------------------------------------- */ herr_t @@ -372,23 +340,16 @@ done: /*------------------------------------------------------------------------- - * Function: H5Fis_hdf5 + * Function: H5Fis_hdf5 * - * Purpose: Check the file signature to detect an HDF5 file. + * Purpose: Check the file signature to detect an HDF5 file. * - * Bugs: This function is not robust: it only uses the default file - * driver when attempting to open the file when in fact it - * should use all known file drivers. + * Bugs: This function is not robust: it only uses the default file + * driver when attempting to open the file when in fact it + * should use all known file drivers. * - * Return: Success: TRUE/FALSE - * - * Failure: Negative - * - * Programmer: Unknown - * - * Modifications: - * Robb Matzke, 1999-08-02 - * Rewritten to use the virtual file layer. + * Return: Success: TRUE/FALSE + * Failure: Negative *------------------------------------------------------------------------- */ htri_t @@ -414,38 +375,34 @@ done: /*------------------------------------------------------------------------- - * Function: H5Fcreate - * - * Purpose: This is the primary function for creating HDF5 files . The - * flags parameter determines whether an existing file will be - * overwritten or not. All newly created files are opened for - * both reading and writing. All flags may be combined with the - * bit-wise OR operator (`|') to change the behavior of the file - * create call. - * - * The more complex behaviors of a file's creation and access - * are controlled through the file-creation and file-access - * property lists. The value of H5P_DEFAULT for a template - * value indicates that the library should use the default - * values for the appropriate template. - * - * See also: H5Fpublic.h for the list of supported flags. H5Ppublic.h for - * the list of file creation and file access properties. - * - * Return: Success: A file ID - * - * Failure: FAIL - * - * Programmer: Unknown - * + * Function: H5Fcreate + * + * Purpose: This is the primary function for creating HDF5 files . The + * flags parameter determines whether an existing file will be + * overwritten or not. All newly created files are opened for + * both reading and writing. All flags may be combined with the + * bit-wise OR operator (`|') to change the behavior of the file + * create call. + * + * The more complex behaviors of a file's creation and access + * are controlled through the file-creation and file-access + * property lists. The value of H5P_DEFAULT for a template + * value indicates that the library should use the default + * values for the appropriate template. + * + * See also: H5Fpublic.h for the list of supported flags. H5Ppublic.h for + * the list of file creation and file access properties. + * + * Return: Success: A file ID + * Failure: FAIL *------------------------------------------------------------------------- */ hid_t H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id) { - H5F_t *new_file = NULL; /*file struct for new file */ - hid_t dxpl_id = H5AC_ind_read_dxpl_id; /*dxpl used by library */ - hid_t ret_value; /*return value */ + H5F_t *new_file = NULL; /*file struct for new file */ + hid_t dxpl_id = H5AC_ind_read_dxpl_id; /*dxpl used by library */ + hid_t ret_value; /*return value */ FUNC_ENTER_API(FAIL) H5TRACE4("i", "*sIuii", filename, flags, fcpl_id, fapl_id); @@ -479,7 +436,7 @@ H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id) * reading and writing. */ if (0==(flags & (H5F_ACC_EXCL|H5F_ACC_TRUNC))) - flags |= H5F_ACC_EXCL; /*default*/ + flags |= H5F_ACC_EXCL; /*default*/ flags |= H5F_ACC_RDWR | H5F_ACC_CREAT; /* @@ -504,51 +461,48 @@ done: /*------------------------------------------------------------------------- - * Function: H5Fopen + * Function: H5Fopen * - * Purpose: This is the primary function for accessing existing HDF5 - * files. The FLAGS argument determines whether writing to an - * existing file will be allowed or not. All flags may be - * combined with the bit-wise OR operator (`|') to change the - * behavior of the file open call. The more complex behaviors - * of a file's access are controlled through the file-access - * property list. + * Purpose: This is the primary function for accessing existing HDF5 + * files. The FLAGS argument determines whether writing to an + * existing file will be allowed or not. All flags may be + * combined with the bit-wise OR operator (`|') to change the + * behavior of the file open call. The more complex behaviors + * of a file's access are controlled through the file-access + * property list. * - * See Also: H5Fpublic.h for a list of possible values for FLAGS. + * See Also: H5Fpublic.h for a list of possible values for FLAGS. * - * Return: Success: A file ID - * - * Failure: FAIL - * - * Programmer: Unknown + * Return: Success: A file ID + * Failure: FAIL * * Modifications: - * Robb Matzke, 1997-07-18 - * File struct creation and destruction is through H5F_new() and - * H5F__dest(). Reading the root symbol table entry is done with - * H5G_decode(). - * - * Robb Matzke, 1997-09-23 - * Most of the work is now done by H5F_open() since H5Fcreate() - * and H5Fopen() originally contained almost identical code. - * - * Robb Matzke, 1998-02-18 - * Added better error checking for the flags and the file access - * property list. It used to be possible to make the library - * dump core by passing an object ID that was not a file access - * property list. - * - * Robb Matzke, 1999-08-02 - * The file access property list is passed to the H5F_open() as - * object IDs. + * Robb Matzke, 1997-07-18 + * File struct creation and destruction is through H5F_new() and + * H5F__dest(). Reading the root symbol table entry is done with + * H5G_decode(). + * + * Robb Matzke, 1997-09-23 + * Most of the work is now done by H5F_open() since H5Fcreate() + * and H5Fopen() originally contained almost identical code. + * + * Robb Matzke, 1998-02-18 + * Added better error checking for the flags and the file access + * property list. It used to be possible to make the library + * dump core by passing an object ID that was not a file access + * property list. + * + * Robb Matzke, 1999-08-02 + * The file access property list is passed to the H5F_open() as + * object IDs. *------------------------------------------------------------------------- */ hid_t H5Fopen(const char *filename, unsigned flags, hid_t fapl_id) { - H5F_t *new_file = NULL; /*file struct for new file */ - hid_t dxpl_id = H5AC_ind_read_dxpl_id; /*dxpl used by library */ - hid_t ret_value; /*return value */ + H5F_t *new_file = NULL; /* file struct for new file */ + hid_t dxpl_id = H5AC_ind_read_dxpl_id; /* dxpl used by library */ + hid_t ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("i", "*sIui", filename, flags, fapl_id); @@ -591,25 +545,21 @@ done: /*------------------------------------------------------------------------- - * Function: H5Fflush - * - * Purpose: Flushes all outstanding buffers of a file to disk but does - * not remove them from the cache. The OBJECT_ID can be a file, - * dataset, group, attribute, or named data type. + * Function: H5Fflush * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Robb Matzke - * Thursday, August 6, 1998 + * Purpose: Flushes all outstanding buffers of a file to disk but does + * not remove them from the cache. The OBJECT_ID can be a file, + * dataset, group, attribute, or named data type. * + * Return: Non-negative on success/Negative on failure *------------------------------------------------------------------------- */ herr_t H5Fflush(hid_t object_id, H5F_scope_t scope) { - H5F_t *f = NULL; /* File to flush */ - H5O_loc_t *oloc = NULL; /* Object location for ID */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_t *f = NULL; /* File to flush */ + H5O_loc_t *oloc = NULL; /* Object location for ID */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iFs", object_id, scope); @@ -622,7 +572,7 @@ H5Fflush(hid_t object_id, H5F_scope_t scope) case H5I_GROUP: { - H5G_t *grp; + H5G_t *grp; if(NULL == (grp = (H5G_t *)H5I_object(object_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid group identifier") @@ -632,7 +582,7 @@ H5Fflush(hid_t object_id, H5F_scope_t scope) case H5I_DATATYPE: { - H5T_t *type; + H5T_t *type; if(NULL == (type = (H5T_t *)H5I_object(object_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid type identifier") @@ -642,7 +592,7 @@ H5Fflush(hid_t object_id, H5F_scope_t scope) case H5I_DATASET: { - H5D_t *dset; + H5D_t *dset; if(NULL == (dset = (H5D_t *)H5I_object(object_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier") @@ -652,7 +602,7 @@ H5Fflush(hid_t object_id, H5F_scope_t scope) case H5I_ATTR: { - H5A_t *attr; + H5A_t *attr; if(NULL == (attr = (H5A_t *)H5I_object(object_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid attribute identifier") @@ -685,7 +635,7 @@ H5Fflush(hid_t object_id, H5F_scope_t scope) /* Flush the file */ /* - * Nothing to do if the file is read only. This determination is + * Nothing to do if the file is read only. This determination is * made at the shared open(2) flags level, implying that opening a * file twice, once for read-only and once for read-write, and then * calling H5Fflush() with the read-only handle, still causes data @@ -711,24 +661,17 @@ done: /*------------------------------------------------------------------------- - * Function: H5Fclose + * Function: H5Fclose * - * Purpose: This function closes the file specified by FILE_ID by - * flushing all data to storage, and terminating access to the - * file through FILE_ID. If objects (e.g., datasets, groups, - * etc.) are open in the file then the underlying storage is not - * closed until those objects are closed; however, all data for - * the file and the open objects is flushed. - * - * Return: Success: Non-negative - * - * Failure: Negative - * - * Programmer: Robb Matzke - * Saturday, February 20, 1999 - * - * Modifications: + * Purpose: This function closes the file specified by FILE_ID by + * flushing all data to storage, and terminating access to the + * file through FILE_ID. If objects (e.g., datasets, groups, + * etc.) are open in the file then the underlying storage is not + * closed until those objects are closed; however, all data for + * the file and the open objects is flushed. * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t @@ -736,7 +679,7 @@ H5Fclose(hid_t file_id) { H5F_t *f = NULL; int nref; - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", file_id); @@ -772,29 +715,24 @@ done: /*------------------------------------------------------------------------- - * Function: H5Freopen - * - * Purpose: Reopen a file. The new file handle which is returned points - * to the same file as the specified file handle. Both handles - * share caches and other information. The only difference - * between the handles is that the new handle is not mounted - * anywhere and no files are mounted on it. + * Function: H5Freopen * - * Return: Success: New file ID - * - * Failure: FAIL - * - * Programmer: Robb Matzke - * Friday, October 16, 1998 + * Purpose: Reopen a file. The new file handle which is returned points + * to the same file as the specified file handle. Both handles + * share caches and other information. The only difference + * between the handles is that the new handle is not mounted + * anywhere and no files are mounted on it. * + * Return: Success: New file ID + * Failure: FAIL *------------------------------------------------------------------------- */ hid_t H5Freopen(hid_t file_id) { - H5F_t *old_file = NULL; - H5F_t *new_file = NULL; - hid_t ret_value; + H5F_t *old_file = NULL; + H5F_t *new_file = NULL; + hid_t ret_value; FUNC_ENTER_API(FAIL) H5TRACE1("i", "i", file_id); @@ -828,16 +766,12 @@ done: /*------------------------------------------------------------------------- - * Function: H5Fget_intent - * - * Purpose: Public API to retrieve the file's 'intent' flags passed - * during H5Fopen() + * Function: H5Fget_intent * - * Return: Non-negative on success/negative on failure - * - * Programmer: James Laird - * August 23, 2006 + * Purpose: Public API to retrieve the file's 'intent' flags passed + * during H5Fopen() * + * Return: Non-negative on success/negative on failure *------------------------------------------------------------------------- */ herr_t @@ -850,7 +784,7 @@ H5Fget_intent(hid_t file_id, unsigned *intent_flags) /* If no intent flags were passed in, exit quietly */ if(intent_flags) { - H5F_t * file; /* Pointer to file structure */ + H5F_t *file; /* Pointer to file structure */ /* Get the internal file structure */ if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) @@ -888,18 +822,13 @@ done: * * Return: Success: Amount of free space for type * Failure: Negative - * - * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu - * Oct 6, 2003 - * *------------------------------------------------------------------------- */ hssize_t H5Fget_freespace(hid_t file_id) { H5F_t *file; /* File object for file ID */ - hsize_t tot_space; /* Amount of free space in the file */ + hsize_t tot_space; /* Amount of free space in the file */ hssize_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -925,15 +854,10 @@ done: * * Purpose: Retrieves the file size of the HDF5 file. This function * is called after an existing file is opened in order - * to learn the true size of the underlying file. + * to learn the true size of the underlying file. * * Return: Success: Non-negative * Failure: Negative - * - * Programmer: David Pitt - * david.pitt@bigpond.com - * Apr 27, 2004 - * *------------------------------------------------------------------------- */ herr_t @@ -972,42 +896,38 @@ done: /*------------------------------------------------------------------------- * Function: H5Fget_file_image * - * Purpose: If a buffer is provided (via the buf_ptr argument) and is - * big enough (size in buf_len argument), load *buf_ptr with - * an image of the open file whose ID is provided in the - * file_id parameter, and return the number of bytes copied - * to the buffer. + * Purpose: If a buffer is provided (via the buf_ptr argument) and is + * big enough (size in buf_len argument), load *buf_ptr with + * an image of the open file whose ID is provided in the + * file_id parameter, and return the number of bytes copied + * to the buffer. * - * If the buffer exists, but is too small to contain an image - * of the indicated file, return a negative number. + * If the buffer exists, but is too small to contain an image + * of the indicated file, return a negative number. * - * Finally, if no buffer is provided, return the size of the - * buffer needed. This value is simply the eoa of the target - * file. + * Finally, if no buffer is provided, return the size of the + * buffer needed. This value is simply the eoa of the target + * file. * - * Note that any user block is skipped. + * Note that any user block is skipped. * - * Also note that the function may not be used on files - * opened with either the split/multi file driver or the - * family file driver. + * Also note that the function may not be used on files + * opened with either the split/multi file driver or the + * family file driver. * - * In the former case, the sparse address space makes the - * get file image operation impractical, due to the size of - * the image typically required. + * In the former case, the sparse address space makes the + * get file image operation impractical, due to the size of + * the image typically required. * - * In the case of the family file driver, the problem is - * the driver message in the super block, which will prevent - * the image being opened with any driver other than the - * family file driver -- which negates the purpose of the - * operation. This can be fixed, but no resources for - * this now. + * In the case of the family file driver, the problem is + * the driver message in the super block, which will prevent + * the image being opened with any driver other than the + * family file driver -- which negates the purpose of the + * operation. This can be fixed, but no resources for + * this now. * * Return: Success: Bytes copied / number of bytes needed. * Failure: negative value - * - * Programmer: John Mainzer - * 11/15/11 - * *------------------------------------------------------------------------- */ ssize_t @@ -1033,21 +953,17 @@ done: /*------------------------------------------------------------------------- - * Function: H5Fget_mdc_config + * Function: H5Fget_mdc_config * - * Purpose: Retrieves the current automatic cache resize configuration - * from the metadata cache, and return it in *config_ptr. + * Purpose: Retrieves the current automatic cache resize configuration + * from the metadata cache, and return it in *config_ptr. * - * Note that the version field of *config_Ptr must be correctly - * filled in by the caller. This allows us to adapt for - * obsolete versions of the structure. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: John Mainzer - * 3/24/05 + * Note that the version field of *config_Ptr must be correctly + * filled in by the caller. This allows us to adapt for + * obsolete versions of the structure. * + * Return: Success: SUCCEED + * Failure: FAIL *------------------------------------------------------------------------- */ herr_t @@ -1078,15 +994,11 @@ done: * Function: H5Fset_mdc_config * * Purpose: Sets the current metadata cache automatic resize - * configuration, using the contents of the instance of - * H5AC_cache_config_t pointed to by config_ptr. + * configuration, using the contents of the instance of + * H5AC_cache_config_t pointed to by config_ptr. * * Return: Success: SUCCEED * Failure: FAIL - * - * Programmer: John Mainzer - * 3/24/05 - * *------------------------------------------------------------------------- */ herr_t @@ -1115,16 +1027,12 @@ done: * Function: H5Fget_mdc_hit_rate * * Purpose: Retrieves the current hit rate from the metadata cache. - * This rate is the overall hit rate since the last time - * the hit rate statistics were reset either manually or - * automatically. + * This rate is the overall hit rate since the last time + * the hit rate statistics were reset either manually or + * automatically. * * Return: Success: SUCCEED * Failure: FAIL - * - * Programmer: John Mainzer - * 3/24/05 - * *------------------------------------------------------------------------- */ herr_t @@ -1156,17 +1064,13 @@ done: * Function: H5Fget_mdc_size * * Purpose: Retrieves the maximum size, minimum clean size, current - * size, and current number of entries from the metadata - * cache associated with the specified file. If any of - * the ptr parameters are NULL, the associated datum is - * not returned. + * size, and current number of entries from the metadata + * cache associated with the specified file. If any of + * the ptr parameters are NULL, the associated datum is + * not returned. * * Return: Success: SUCCEED * Failure: FAIL - * - * Programmer: John Mainzer - * 3/24/05 - * *------------------------------------------------------------------------- */ herr_t @@ -1202,20 +1106,16 @@ done: * Function: H5Freset_mdc_hit_rate_stats * * Purpose: Reset the hit rate statistic whose current value can - * be obtained via the H5Fget_mdc_hit_rate() call. Note - * that this statistic will also be reset once per epoch - * by the automatic cache resize code if it is enabled. + * be obtained via the H5Fget_mdc_hit_rate() call. Note + * that this statistic will also be reset once per epoch + * by the automatic cache resize code if it is enabled. * - * It is probably a bad idea to call this function unless - * you are controlling cache size from your program instead - * of using our cache size control code. + * It is probably a bad idea to call this function unless + * you are controlling cache size from your program instead + * of using our cache size control code. * * Return: Success: SUCCEED * Failure: FAIL - * - * Programmer: John Mainzer - * 3/24/05 - * *------------------------------------------------------------------------- */ herr_t @@ -1251,15 +1151,11 @@ done: * If an error occurs then the buffer pointed to by `name' (NULL or non-NULL) * is unchanged and the function returns a negative value. * - * Note: This routine returns the name that was used to open the file, - * not the actual name after resolving symlinks, etc. + * Note: This routine returns the name that was used to open the file, + * not the actual name after resolving symlinks, etc. * * Return: Success: The length of the file name * Failure: Negative - * - * Programmer: Raymond Lu - * June 29, 2004 - * *------------------------------------------------------------------------- */ ssize_t @@ -1309,17 +1205,13 @@ done: * Function: H5Fget_info2 * * Purpose: Gets general information about the file, including: - * 1. Get storage size for superblock extension if there is one. + * 1. Get storage size for superblock extension if there is one. * 2. Get the amount of btree and heap storage for entries * in the SOHM table if there is one. - * 3. The amount of free space tracked in the file. + * 3. The amount of free space tracked in the file. * * Return: Success: non-negative on success * Failure: Negative - * - * Programmer: Vailin Choi - * July 11, 2007 - * *------------------------------------------------------------------------- */ herr_t @@ -1386,18 +1278,15 @@ done: * * Return: Success: non-negative on success * Failure: Negative - * - * Programmer: Vailin Choi; October 2013 - * *------------------------------------------------------------------------- */ herr_t H5Fget_metadata_read_retry_info(hid_t file_id, H5F_retry_info_t *info) { - H5F_t *file; /* File object for file ID */ - unsigned i, j; /* Local index variable */ - size_t tot_size; /* Size of each retries[i] */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_t *file; /* File object for file ID */ + unsigned i, j; /* Local index variable */ + size_t tot_size; /* Size of each retries[i] */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*x", file_id, info); @@ -1417,8 +1306,8 @@ H5Fget_metadata_read_retry_info(hid_t file_id, H5F_retry_info_t *info) HDmemset(info->retries, 0, sizeof(info->retries)); /* Return if there are no bins -- no retries */ - if(!info->nbins) - HGOTO_DONE(SUCCEED); + if(!info->nbins) + HGOTO_DONE(SUCCEED); /* Calculate size for each retries[i] */ tot_size = info->nbins * sizeof(uint32_t); @@ -1477,18 +1366,15 @@ done: /*------------------------------------------------------------------------- - * Function: H5Fget_free_sections - * - * Purpose: To get free-space section information for free-space manager with - * TYPE that is associated with file FILE_ID. - * If SECT_INFO is null, this routine returns the total # of free-space - * sections. - * - * Return: Success: non-negative, the total # of free space sections - * Failure: negative + * Function: H5Fget_free_sections * - * Programmer: Vailin Choi; July 1st, 2009 + * Purpose: To get free-space section information for free-space manager with + * TYPE that is associated with file FILE_ID. + * If SECT_INFO is null, this routine returns the total # of free-space + * sections. * + * Return: Success: non-negative, the total # of free space sections + * Failure: negative *------------------------------------------------------------------------- */ ssize_t @@ -1525,9 +1411,6 @@ done: * * Return: Success: non-negative * Failure: negative - * - * Programmer: Neil Fortner; December 30, 2010 - * *------------------------------------------------------------------------- */ herr_t @@ -1554,37 +1437,33 @@ done: /*------------------------------------------------------------------------- - * Function: H5Fstart_swmr_write - * - * Purpose: To enable SWMR writing mode for the file - * 1) Refresh opened objects: part 1 - * 2) Flush & reset accumulator - * 3) Mark the file in SWMR writing mode - * 4) Set metadata read attempts and retries info - * 5) Disable accumulator - * 6) Evict all cache entries except the superblock - * 7) Refresh opened objects (part 2) - * 8) Unlock the file - * - * Pre-conditions: - * 1) The file being opened has v3 superblock - * 2) The file is opened with H5F_ACC_RDWR - * 3) The file is not already marked for SWMR writing - * 4) Current implementaion for opened objects: - * --only allow datasets and groups without attributes - * --disallow named datatype with/without attributes - * --disallow opened attributes attached to objects - * NOTE: Currently, only opened groups and datasets are allowed - * when enabling SWMR via H5Fstart_swmr_write(). - * Will later implement a different approach-- - * set up flush dependency/proxy even for file opened without - * SWMR to resolve issues with opened objects. - * - * Return: Non-negative on success/negative on failure - * - * Programmer: - * Vailin Choi; Feb 2014 - * + * Function: H5Fstart_swmr_write + * + * Purpose: To enable SWMR writing mode for the file + * 1) Refresh opened objects: part 1 + * 2) Flush & reset accumulator + * 3) Mark the file in SWMR writing mode + * 4) Set metadata read attempts and retries info + * 5) Disable accumulator + * 6) Evict all cache entries except the superblock + * 7) Refresh opened objects (part 2) + * 8) Unlock the file + * + * Pre-conditions: + * 1) The file being opened has v3 superblock + * 2) The file is opened with H5F_ACC_RDWR + * 3) The file is not already marked for SWMR writing + * 4) Current implementaion for opened objects: + * --only allow datasets and groups without attributes + * --disallow named datatype with/without attributes + * --disallow opened attributes attached to objects + * NOTE: Currently, only opened groups and datasets are allowed + * when enabling SWMR via H5Fstart_swmr_write(). + * Will later implement a different approach-- + * set up flush dependency/proxy even for file opened without + * SWMR to resolve issues with opened objects. + * + * Return: Non-negative on success/negative on failure *------------------------------------------------------------------------- */ herr_t @@ -1593,16 +1472,16 @@ H5Fstart_swmr_write(hid_t file_id) hbool_t ci_load = FALSE; /* whether MDC ci load requested */ hbool_t ci_write = FALSE; /* whether MDC CI write requested */ H5F_t *file = NULL; /* File info */ - size_t grp_dset_count=0; /* # of open objects: groups & datasets */ - size_t nt_attr_count=0; /* # of opened named datatypes + opened attributes */ - hid_t *obj_ids=NULL; /* List of ids */ - H5G_loc_t *obj_glocs=NULL; /* Group location of the object */ - H5O_loc_t *obj_olocs=NULL; /* Object location */ - H5G_name_t *obj_paths=NULL; /* Group hierarchy path */ - size_t u; /* Local index variable */ - hbool_t setup = FALSE; /* Boolean flag to indicate whether SWMR setting is enabled */ + size_t grp_dset_count=0; /* # of open objects: groups & datasets */ + size_t nt_attr_count=0; /* # of opened named datatypes + opened attributes */ + hid_t *obj_ids=NULL; /* List of ids */ + H5G_loc_t *obj_glocs=NULL; /* Group location of the object */ + H5O_loc_t *obj_olocs=NULL; /* Object location */ + H5G_name_t *obj_paths=NULL; /* Group hierarchy path */ + size_t u; /* Local index variable */ + hbool_t setup = FALSE; /* Boolean flag to indicate whether SWMR setting is enabled */ H5F_io_info2_t fio_info; /* I/O info for operation */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", file_id); @@ -1651,18 +1530,18 @@ H5Fstart_swmr_write(hid_t file_id) if(grp_dset_count) { /* Allocate space for group and object locations */ - if((obj_ids = (hid_t *) H5MM_malloc(grp_dset_count * sizeof(hid_t))) == NULL) - HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, FAIL, "can't allocate buffer for hid_t") - if((obj_glocs = (H5G_loc_t *) H5MM_malloc(grp_dset_count * sizeof(H5G_loc_t))) == NULL) - HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, FAIL, "can't allocate buffer for H5G_loc_t") - if((obj_olocs = (H5O_loc_t *) H5MM_malloc(grp_dset_count * sizeof(H5O_loc_t))) == NULL) - HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, FAIL, "can't allocate buffer for H5O_loc_t") - if((obj_paths = (H5G_name_t *) H5MM_malloc(grp_dset_count * sizeof(H5G_name_t))) == NULL) - HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, FAIL, "can't allocate buffer for H5G_name_t") + if((obj_ids = (hid_t *) H5MM_malloc(grp_dset_count * sizeof(hid_t))) == NULL) + HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, FAIL, "can't allocate buffer for hid_t") + if((obj_glocs = (H5G_loc_t *) H5MM_malloc(grp_dset_count * sizeof(H5G_loc_t))) == NULL) + HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, FAIL, "can't allocate buffer for H5G_loc_t") + if((obj_olocs = (H5O_loc_t *) H5MM_malloc(grp_dset_count * sizeof(H5O_loc_t))) == NULL) + HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, FAIL, "can't allocate buffer for H5O_loc_t") + if((obj_paths = (H5G_name_t *) H5MM_malloc(grp_dset_count * sizeof(H5G_name_t))) == NULL) + HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, FAIL, "can't allocate buffer for H5G_name_t") /* Get the list of opened object ids (groups & datasets) */ - if(H5F_get_obj_ids(file, H5F_OBJ_GROUP|H5F_OBJ_DATASET, grp_dset_count, obj_ids, FALSE, &grp_dset_count) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "H5F_get_obj_ids failed") + if(H5F_get_obj_ids(file, H5F_OBJ_GROUP|H5F_OBJ_DATASET, grp_dset_count, obj_ids, FALSE, &grp_dset_count) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "H5F_get_obj_ids failed") /* Refresh opened objects (groups, datasets) in the file */ for(u = 0; u < grp_dset_count; u++) { @@ -1790,14 +1669,13 @@ done: * - Logging must have been set up via the fapl. * * Return: Non-negative on success/Negative on errors - * *------------------------------------------------------------------------- */ herr_t H5Fstart_mdc_logging(hid_t file_id) { - H5F_t *file; /* File info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_t *file; /* File info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", file_id); @@ -1823,14 +1701,13 @@ done: * - Logging must have been set up via the fapl. * * Return: Non-negative on success/Negative on errors - * *------------------------------------------------------------------------- */ herr_t H5Fstop_mdc_logging(hid_t file_id) { - H5F_t *file; /* File info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_t *file; /* File info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", file_id); @@ -1856,15 +1733,14 @@ done: * log messages are being recorded at this time. * * Return: Non-negative on success/Negative on errors - * *------------------------------------------------------------------------- */ herr_t H5Fget_mdc_logging_status(hid_t file_id, hbool_t *is_enabled, hbool_t *is_currently_logging) { - H5F_t *file; /* File info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_t *file; /* File info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*b*b", file_id, is_enabled, is_currently_logging); @@ -1888,9 +1764,6 @@ done: * Purpose: Enable switching the "latest format" flag while a file is open. * * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Monday, September 21, 2015 *------------------------------------------------------------------------- */ herr_t @@ -1924,17 +1797,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5Fformat_convert_super (Internal) + * Function: H5Fformat_convert_super (Internal) * - * Purpose: Downgrade the superblock version to v2 and - * downgrade persistent file space to non-persistent - * for 1.8 library. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Vailin Choi - * Jan 2016 + * Purpose: Downgrade the superblock version to v2 and + * downgrade persistent file space to non-persistent + * for 1.8 library. * + * Return: Non-negative on success/Negative on failure *------------------------------------------------------------------------- */ herr_t @@ -1946,8 +1815,8 @@ H5Fformat_convert(hid_t fid) H5TRACE1("e", "i", fid); if(H5I_FILE == H5I_get_type(fid)) { - H5F_t *f; /* File to flush */ - hbool_t mark_dirty = FALSE; + H5F_t *f; /* File to flush */ + hbool_t mark_dirty = FALSE; /* Get file object */ if(NULL == (f = (H5F_t *)H5I_object(fid))) @@ -1961,9 +1830,9 @@ H5Fformat_convert(hid_t fid) /* Check for persistent freespace manager, which needs to be downgraded */ if(!(f->shared->fs_strategy == H5F_FILE_SPACE_STRATEGY_DEF && - f->shared->fs_persist == H5F_FREE_SPACE_PERSIST_DEF && - f->shared->fs_threshold == H5F_FREE_SPACE_THRESHOLD_DEF && - f->shared->fs_page_size == H5F_FILE_SPACE_PAGE_SIZE_DEF)) { + f->shared->fs_persist == H5F_FREE_SPACE_PERSIST_DEF && + f->shared->fs_threshold == H5F_FREE_SPACE_THRESHOLD_DEF && + f->shared->fs_page_size == H5F_FILE_SPACE_PAGE_SIZE_DEF)) { /* Check to remove free-space manager info message from superblock extension */ if(H5F_addr_defined(f->shared->sblock->ext_addr)) if(H5F_super_ext_remove_msg(f, H5AC_ind_read_dxpl_id, H5O_FSINFO_ID) < 0) @@ -2004,9 +1873,6 @@ done: * * Return: Success: SUCCEED * Failure: FAIL - * - * Programmer: Mohamad Chaarawi - * *------------------------------------------------------------------------- */ herr_t @@ -2040,9 +1906,6 @@ done: * * Return: Success: SUCCEED * Failure: FAIL - * - * Programmer: Mohamad Chaarawi - * *------------------------------------------------------------------------- */ herr_t @@ -2084,9 +1947,6 @@ done: * * Return: Success: SUCCEED * Failure: FAIL - * - * Programmer: Vailin Choi; March 2017 - * *------------------------------------------------------------------------- */ herr_t diff --git a/src/H5Fint.c b/src/H5Fint.c index 7371c46..a48e41c 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -21,20 +21,20 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Aprivate.h" /* Attributes */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5SMprivate.h" /* Shared Object Header Messages */ -#include "H5Tprivate.h" /* Datatypes */ +#include "H5private.h" /* Generic Functions */ +#include "H5Aprivate.h" /* Attributes */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5SMprivate.h" /* Shared Object Header Messages */ +#include "H5Tprivate.h" /* Datatypes */ /****************/ @@ -100,26 +100,19 @@ H5FL_DEFINE(H5F_file_t); /*------------------------------------------------------------------------- - * Function: H5F_get_access_plist + * Function: H5F_get_access_plist * - * Purpose: Returns a copy of the file access property list of the - * specified file. + * Purpose: Returns a copy of the file access property list of the + * specified file. * * NOTE: Make sure that, if you are going to overwrite * information in the copied property list that was * previously opened and assigned to the property list, then * you must close it before overwriting the values. * - * Return: Success: Object ID for a copy of the file access - * property list. - * - * Failure: FAIL - * - * Programmer: Quincey Koziol - * Wednesday, May 25, 2005 - * - * Modifications: - * + * Return: Success: Object ID for a copy of the file access + * property list. + * Failure: FAIL *------------------------------------------------------------------------- */ hid_t @@ -129,9 +122,9 @@ H5F_get_access_plist(H5F_t *f, hbool_t app_ref) H5P_genplist_t *old_plist; /* Old property list */ H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */ hbool_t driver_prop_copied = FALSE; /* Whether the driver property has been set up */ - unsigned efc_size = 0; - hbool_t latest_format = FALSE; /* Always use the latest format? */ - hid_t ret_value = SUCCEED; /* Return value */ + unsigned efc_size = 0; + hbool_t latest_format = FALSE; /* Always use the latest format? */ + hid_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -142,7 +135,7 @@ H5F_get_access_plist(H5F_t *f, hbool_t app_ref) if(NULL == (old_plist = (H5P_genplist_t *)H5I_object(H5P_LST_FILE_ACCESS_ID_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") if((ret_value = H5P_copy_plist(old_plist, app_ref)) < 0) - HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "can't copy file access property list") + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "can't copy file access property list") if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(ret_value))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") @@ -222,16 +215,12 @@ done: /*------------------------------------------------------------------------- - * Function: H5F_get_obj_count + * Function: H5F_get_obj_count * - * Purpose: Private function return the number of opened object IDs - * (files, datasets, groups, datatypes) in the same file. + * Purpose: Private function return the number of opened object IDs + * (files, datasets, groups, datatypes) in the same file. * * Return: SUCCEED on success, FAIL on failure. - * - * Programmer: Raymond Lu - * Wednesday, Dec 5, 2001 - * *------------------------------------------------------------------------- */ herr_t @@ -259,10 +248,6 @@ done: * Purpose: Private function to return a list of opened object IDs. * * Return: Non-negative on success; can't fail. - * - * Programmer: Raymond Lu - * Wednesday, Dec 5, 2001 - * *------------------------------------------------------------------------- */ herr_t @@ -285,16 +270,13 @@ done: /*--------------------------------------------------------------------------- - * Function: H5F_get_objects + * Function: H5F_get_objects * - * Purpose: This function is called by H5F_get_obj_count or - * H5F_get_obj_ids to get number of object IDs and/or a - * list of opened object IDs (in return value). - * Return: Non-negative on success; Can't fail. - * - * Programmer: Raymond Lu - * Wednesday, Dec 5, 2001 + * Purpose: This function is called by H5F_get_obj_count or + * H5F_get_obj_ids to get number of object IDs and/or a + * list of opened object IDs (in return value). * + * Return: Non-negative on success; Can't fail. *--------------------------------------------------------------------------- */ herr_t @@ -313,7 +295,7 @@ H5F_get_objects(const H5F_t *f, unsigned types, size_t max_nobjs, hid_t *obj_id_ olist.obj_id_list = (max_nobjs==0 ? NULL : obj_id_list); olist.obj_id_count = &obj_id_count; olist.list_index = 0; - olist.max_nobjs = max_nobjs; + olist.max_nobjs = max_nobjs; /* Determine if we are searching for local or global objects */ if(types & H5F_OBJ_LOCAL) { @@ -337,37 +319,37 @@ H5F_get_objects(const H5F_t *f, unsigned types, size_t max_nobjs, hid_t *obj_id_ * or the caller wants to get the list of IDs and the list isn't full, * search through dataset IDs to count number of datasets, and put their * IDs on the object list */ - if(!olist.max_nobjs || (olist.max_nobjs && olist.list_indexobj_type == H5I_FILE) { if((olist->file_info.local && - (!olist->file_info.ptr.file || (olist->file_info.ptr.file && (H5F_t*)obj_ptr == olist->file_info.ptr.file) )) - || (!olist->file_info.local && - ( !olist->file_info.ptr.shared || (olist->file_info.ptr.shared && ((H5F_t*)obj_ptr)->shared == olist->file_info.ptr.shared) ))) { + (!olist->file_info.ptr.file || + (olist->file_info.ptr.file && (H5F_t*)obj_ptr == olist->file_info.ptr.file))) || + (!olist->file_info.local && + (!olist->file_info.ptr.shared || + (olist->file_info.ptr.shared && ((H5F_t*)obj_ptr)->shared == olist->file_info.ptr.shared)))) { add_obj = TRUE; - } /* end if */ + } /* end if */ } /* end if */ else { /* either count opened object IDs or put the IDs on the list */ H5O_loc_t *oloc; /* Group entry info for object */ - switch(olist->obj_type) { - case H5I_ATTR: - oloc = H5A_oloc((H5A_t *)obj_ptr); - break; - - case H5I_GROUP: - oloc = H5G_oloc((H5G_t *)obj_ptr); - break; - - case H5I_DATASET: - oloc = H5D_oloc((H5D_t *)obj_ptr); - break; - - case H5I_DATATYPE: - if(H5T_is_named((H5T_t*)obj_ptr)==TRUE) - oloc = H5T_oloc((H5T_t*)obj_ptr); - else - oloc = NULL; - break; - - case H5I_UNINIT: - case H5I_BADID: - case H5I_FILE: - case H5I_DATASPACE: - case H5I_REFERENCE: - case H5I_VFL: - case H5I_GENPROP_CLS: - case H5I_GENPROP_LST: - case H5I_ERROR_CLASS: - case H5I_ERROR_MSG: - case H5I_ERROR_STACK: - case H5I_NTYPES: + switch(olist->obj_type) { + case H5I_ATTR: + oloc = H5A_oloc((H5A_t *)obj_ptr); + break; + + case H5I_GROUP: + oloc = H5G_oloc((H5G_t *)obj_ptr); + break; + + case H5I_DATASET: + oloc = H5D_oloc((H5D_t *)obj_ptr); + break; + + case H5I_DATATYPE: + if(H5T_is_named((H5T_t*)obj_ptr)==TRUE) + oloc = H5T_oloc((H5T_t*)obj_ptr); + else + oloc = NULL; + break; + + case H5I_UNINIT: + case H5I_BADID: + case H5I_FILE: + case H5I_DATASPACE: + case H5I_REFERENCE: + case H5I_VFL: + case H5I_GENPROP_CLS: + case H5I_GENPROP_LST: + case H5I_ERROR_CLASS: + case H5I_ERROR_MSG: + case H5I_ERROR_STACK: + case H5I_NTYPES: default: HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5_ITER_ERROR, "unknown data object") - } /* end switch */ + } /* end switch */ if((olist->file_info.local && - ( (!olist->file_info.ptr.file && olist->obj_type == H5I_DATATYPE && H5T_is_immutable((H5T_t *)obj_ptr) == FALSE) - || (!olist->file_info.ptr.file && olist->obj_type != H5I_DATATYPE) - || (oloc && oloc->file == olist->file_info.ptr.file))) - || (!olist->file_info.local && - ((!olist->file_info.ptr.shared && olist->obj_type == H5I_DATATYPE && H5T_is_immutable((H5T_t *)obj_ptr) == FALSE) - || (!olist->file_info.ptr.shared && olist->obj_type != H5I_DATATYPE) - || (oloc && oloc->file && oloc->file->shared == olist->file_info.ptr.shared)))) { + ((!olist->file_info.ptr.file && olist->obj_type == H5I_DATATYPE && H5T_is_immutable((H5T_t *)obj_ptr) == FALSE) || + (!olist->file_info.ptr.file && olist->obj_type != H5I_DATATYPE) || + (oloc && oloc->file == olist->file_info.ptr.file))) || + (!olist->file_info.local && + ((!olist->file_info.ptr.shared && olist->obj_type == H5I_DATATYPE && H5T_is_immutable((H5T_t *)obj_ptr) == FALSE) || + (!olist->file_info.ptr.shared && olist->obj_type != H5I_DATATYPE) || + (oloc && oloc->file && oloc->file->shared == olist->file_info.ptr.shared)))) { add_obj = TRUE; - } /* end if */ + } /* end if */ } /* end else */ if(add_obj) { /* Add the object's ID to the ID list, if appropriate */ if(olist->obj_id_list) { olist->obj_id_list[olist->list_index] = obj_id; - olist->list_index++; - } /* end if */ + olist->list_index++; + } /* end if */ /* Increment the number of open objects */ - if(olist->obj_id_count) + if(olist->obj_id_count) (*olist->obj_id_count)++; /* Check if we've filled up the array. Return H5_ITER_STOP only if * we have filled up the array. Otherwise return H5_ITER_CONT(RET_VALUE is - * preset to H5_ITER_CONT) because H5I_iterate needs the return value of + * preset to H5_ITER_CONT) because H5I_iterate needs the return value of * H5_ITER_CONT to continue the iteration. */ if(olist->max_nobjs > 0 && olist->list_index >= olist->max_nobjs) HGOTO_DONE(H5_ITER_STOP) /* Indicate that the iterator should stop */ @@ -501,35 +481,31 @@ done: /*------------------------------------------------------------------------- - * Function: H5F__is_hdf5 - * - * Purpose: Check the file signature to detect an HDF5 file. - * - * Bugs: This function is not robust: it only uses the default file - * driver when attempting to open the file when in fact it - * should use all known file drivers. - * - * Return: Success: TRUE/FALSE + * Function: H5F__is_hdf5 * - * Failure: Negative + * Purpose: Check the file signature to detect an HDF5 file. * - * Programmer: Unknown + * Bugs: This function is not robust: it only uses the default file + * driver when attempting to open the file when in fact it + * should use all known file drivers. * + * Return: Success: TRUE/FALSE + * * Failure: Negative *------------------------------------------------------------------------- */ htri_t H5F__is_hdf5(const char *name, hid_t meta_dxpl_id, hid_t raw_dxpl_id) { - H5FD_t *file = NULL; /* Low-level file struct */ - H5FD_io_info_t fdio_info; /* File driver I/O info */ - haddr_t sig_addr; /* Addess of hdf5 file signature */ - htri_t ret_value = FAIL; /* Return value */ + H5FD_t *file = NULL; /* Low-level file struct */ + H5FD_io_info_t fdio_info; /* File driver I/O info */ + haddr_t sig_addr; /* Addess of hdf5 file signature */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Open the file at the virtual file layer */ if(NULL == (file = H5FD_open(name, H5F_ACC_RDONLY, H5P_FILE_ACCESS_DEFAULT, HADDR_UNDEF))) - HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to open file") + HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to open file") /* Set up the file driver info */ fdio_info.file = file; @@ -554,31 +530,23 @@ done: /*------------------------------------------------------------------------- - * Function: H5F_new - * - * Purpose: Creates a new file object and initializes it. The - * H5Fopen and H5Fcreate functions then fill in various - * fields. If SHARED is a non-null pointer then the shared info - * to which it points has the reference count incremented. - * Otherwise a new, empty shared info struct is created and - * initialized with the specified file access property list. - * - * Errors: - * - * Return: Success: Ptr to a new file struct. + * Function: H5F_new * - * Failure: NULL - * - * Programmer: Robb Matzke - * matzke@llnl.gov - * Jul 18 1997 + * Purpose: Creates a new file object and initializes it. The + * H5Fopen and H5Fcreate functions then fill in various fields. + * If SHARED is a non-null pointer then the shared info + * to which it points has the reference count incremented. + * Otherwise a new, empty shared info struct is created and + * initialized with the specified file access property list. * + * Return: Success: Ptr to a new file struct. + * Failure: NULL *------------------------------------------------------------------------- */ H5F_t * H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf) { - H5F_t *f = NULL, *ret_value = NULL; + H5F_t *f = NULL, *ret_value = NULL; FUNC_ENTER_NOAPI_NOINIT @@ -592,8 +560,8 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t } /* end if */ else { H5P_genplist_t *plist; /* Property list */ - unsigned efc_size; /* External file cache size */ - hbool_t latest_format; /* Always use the latest format? */ + unsigned efc_size; /* External file cache size */ + hbool_t latest_format; /* Always use the latest format? */ size_t u; /* Local index variable */ HDassert(lf != NULL); @@ -650,7 +618,7 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get file space page size") HDassert(f->shared->fs_page_size >= H5F_FILE_SPACE_PAGE_SIZE_MIN); - /* Temporary for multi/split drivers: fail file creation + /* Temporary for multi/split drivers: fail file creation when persisting free-space or using paged aggregation strategy */ if(H5F_HAS_FEATURE(f, H5FD_FEAT_PAGED_AGGR)) if(f->shared->fs_strategy == H5F_FSPACE_STRATEGY_PAGE || f->shared->fs_persist) @@ -826,25 +794,20 @@ done: /*------------------------------------------------------------------------- - * Function: H5F__dest - * - * Purpose: Destroys a file structure. This function flushes the cache - * but doesn't do any other cleanup other than freeing memory - * for the file struct. The shared info for the file is freed - * only when its reference count reaches zero. + * Function: H5F__dest * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Robb Matzke - * matzke@llnl.gov - * Jul 18 1997 + * Purpose: Destroys a file structure. This function flushes the cache + * but doesn't do any other cleanup other than freeing memory + * for the file struct. The shared info for the file is freed + * only when its reference count reaches zero. * + * Return: Non-negative on success/Negative on failure *------------------------------------------------------------------------- */ herr_t H5F__dest(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t flush) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -866,7 +829,7 @@ H5F__dest(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t flush) HDONE_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush cached data (phase 1)") /* Notify the metadata cache that the file is about to be closed. - * This allows the cache to set up for creating a metadata cache + * This allows the cache to set up for creating a metadata cache * image if this has been requested. */ if(H5AC_prep_for_file_close(f, meta_dxpl_id) < 0) @@ -883,7 +846,7 @@ H5F__dest(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t flush) HDONE_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush cached data (phase 2)") /* With the shutdown modifications, the contents of the metadata cache - * should be clean at this point, with the possible exception of the + * should be clean at this point, with the possible exception of the * the superblock and superblock extension. * * Verify this. @@ -909,10 +872,10 @@ H5F__dest(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t flush) /* Release objects that depend on the superblock being initialized */ if(f->shared->sblock) { /* Shutdown file free space manager(s) */ - /* (We should release the free space information now (before - * truncating the file and before the metadata cache is shut - * down) since the free space manager is holding some data - * structures in memory and also because releasing free space + /* (We should release the free space information now (before + * truncating the file and before the metadata cache is shut + * down) since the free space manager is holding some data + * structures in memory and also because releasing free space * can shrink the file's 'eoa' value) * * Update 11/1/16: @@ -938,7 +901,7 @@ H5F__dest(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t flush) * free space manager may dirty some data structures again. */ if(flush) { - /* Clear status_flags */ + /* Clear status_flags */ f->shared->sblock->status_flags &= (uint8_t)(~H5F_SUPER_WRITE_ACCESS); f->shared->sblock->status_flags &= (uint8_t)(~H5F_SUPER_SWMR_WRITE_ACCESS); @@ -947,8 +910,8 @@ H5F__dest(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t flush) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty") - /* Release any space allocated to space aggregators, - * so that the eoa value corresponds to the end of the + /* Release any space allocated to space aggregators, + * so that the eoa value corresponds to the end of the * space written to in the file. * * At most, this should change the superblock or the @@ -967,11 +930,11 @@ H5F__dest(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t flush) * extension should be dirty. */ HDassert(H5AC_cache_is_clean(f, H5AC_RING_MDFSM)); - } /* end if */ + } /* end if */ } /* end if */ /* if it exists, unpin the driver information block cache entry, - * since we're about to destroy the cache + * since we're about to destroy the cache */ if(f->shared->drvinfo) if(H5AC_unpin_entry(f->shared->drvinfo) < 0) @@ -991,7 +954,7 @@ H5F__dest(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t flush) * Verify this. */ HDassert(H5AC_cache_is_clean(f, H5AC_RING_MDFSM)); - + /* Remove shared file struct from list of open files */ if(H5F_sfile_remove(f->shared) < 0) /* Push error, but keep going*/ @@ -1067,7 +1030,8 @@ H5F__dest(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t flush) /* Destroy shared file struct */ f->shared = (H5F_file_t *)H5FL_FREE(H5F_file_t, f->shared); - } else if(f->shared->nrefs > 0) { + } + else if(f->shared->nrefs > 0) { /* * There are other references to the shared part of the file. * Only decrement the reference count. @@ -1089,42 +1053,42 @@ H5F__dest(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t flush) /*------------------------------------------------------------------------- - * Function: H5F_open + * Function: H5F_open * - * Purpose: Opens (or creates) a file. This function understands the - * following flags which are similar in nature to the Posix - * open(2) flags. + * Purpose: Opens (or creates) a file. This function understands the + * following flags which are similar in nature to the Posix + * open(2) flags. * - * H5F_ACC_RDWR: Open with read/write access. If the file is - * currently open for read-only access then it - * will be reopened. Absence of this flag - * implies read-only access. + * H5F_ACC_RDWR: Open with read/write access. If the file is + * currently open for read-only access then it + * will be reopened. Absence of this flag + * implies read-only access. * - * H5F_ACC_CREAT: Create a new file if it doesn't exist yet. - * The permissions are 0666 bit-wise AND with - * the current umask. H5F_ACC_WRITE must also - * be specified. + * H5F_ACC_CREAT: Create a new file if it doesn't exist yet. + * The permissions are 0666 bit-wise AND with + * the current umask. H5F_ACC_WRITE must also + * be specified. * - * H5F_ACC_EXCL: This flag causes H5F_open() to fail if the - * file already exists. + * H5F_ACC_EXCL: This flag causes H5F_open() to fail if the + * file already exists. * - * H5F_ACC_TRUNC: The file is truncated and a new HDF5 superblock - * is written. This operation will fail if the - * file is already open. + * H5F_ACC_TRUNC: The file is truncated and a new HDF5 superblock + * is written. This operation will fail if the + * file is already open. * - * Unlinking the file name from the group directed graph while - * the file is opened causes the file to continue to exist but - * one will not be able to upgrade the file from read-only - * access to read-write access by reopening it. Disk resources - * for the file are released when all handles to the file are - * closed. NOTE: This paragraph probably only applies to Unix; - * deleting the file name in other OS's has undefined results. + * Unlinking the file name from the group directed graph while + * the file is opened causes the file to continue to exist but + * one will not be able to upgrade the file from read-only + * access to read-write access by reopening it. Disk resources + * for the file are released when all handles to the file are + * closed. NOTE: This paragraph probably only applies to Unix; + * deleting the file name in other OS's has undefined results. * - * The CREATE_PARMS argument is optional. A null pointer will - * cause the default file creation parameters to be used. + * The CREATE_PARMS argument is optional. A null pointer will + * cause the default file creation parameters to be used. * - * The ACCESS_PARMS argument is optional. A null pointer will - * cause the default file access parameters to be used. + * The ACCESS_PARMS argument is optional. A null pointer will + * cause the default file access parameters to be used. * * The following two tables show results of file opens for single and concurrent access: * @@ -1157,12 +1121,8 @@ H5F__dest(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t flush) * s: the open succeeds with flags combination from both the first and second opens * * - * Return: Success: A new file pointer. - * Failure: NULL - * - * Programmer: Robb Matzke - * Tuesday, September 23, 1997 - * + * Return: Success: A new file pointer. + * Failure: NULL *------------------------------------------------------------------------- */ H5F_t * @@ -1181,7 +1141,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, unsigned page_buf_min_meta_perc; unsigned page_buf_min_raw_perc; hbool_t set_flag = FALSE; /*set the status_flags in the superblock */ - hbool_t clear = FALSE; /*clear the status_flags */ + hbool_t clear = FALSE; /*clear the status_flags */ hbool_t evict_on_close; /* evict on close value from plist */ H5F_t *ret_value = NULL; /*actual return value */ char *lock_env_var = NULL;/*env var pointer */ @@ -1210,7 +1170,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, if(lock_env_var && !HDstrcmp(lock_env_var, "FALSE")) use_file_locking = FALSE; else - use_file_locking = TRUE; + use_file_locking = TRUE; /* * Opening a file is a two step process. First we try to open the @@ -1299,8 +1259,8 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, /* Place an advisory lock on the file */ if(use_file_locking) if(H5FD_lock(lf, (hbool_t)((flags & H5F_ACC_RDWR) ? TRUE : FALSE)) < 0) { - /* Locking failed - Closing will remove the lock */ - if(H5FD_close(lf) < 0) + /* Locking failed - Closing will remove the lock */ + if(H5FD_close(lf) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to close low-level file info") HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to lock the file") } /* end if */ @@ -1311,7 +1271,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, * returned is NULL, H5FD_close() will never be called via H5F_dest() * so we have to close lf here before heading to the error handling. */ - if(H5FD_close(lf) < 0) + if(H5FD_close(lf) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to close low-level file info") HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to initialize file structure") } /* end if */ @@ -1475,7 +1435,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, NULL, "unable to flush superblock extension") /* Remove the file lock for SWMR_WRITE */ - if(use_file_locking && (H5F_INTENT(file) & H5F_ACC_SWMR_WRITE)) { + if(use_file_locking && (H5F_INTENT(file) & H5F_ACC_SWMR_WRITE)) { if(H5FD_unlock(file->shared->lf) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to unlock the file") } /* end if */ @@ -1483,11 +1443,11 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, else { /* H5F_ACC_RDONLY: check consistency of status_flags */ /* Skip check of status_flags for file with < superblock version 3 */ if(file->shared->sblock->super_vers >= HDF5_SUPERBLOCK_VERSION_3) { - if(H5F_INTENT(file) & H5F_ACC_SWMR_READ) { - if((file->shared->sblock->status_flags & H5F_SUPER_WRITE_ACCESS && + if(H5F_INTENT(file) & H5F_ACC_SWMR_READ) { + if((file->shared->sblock->status_flags & H5F_SUPER_WRITE_ACCESS && !(file->shared->sblock->status_flags & H5F_SUPER_SWMR_WRITE_ACCESS)) - || - (!(file->shared->sblock->status_flags & H5F_SUPER_WRITE_ACCESS) && + || + (!(file->shared->sblock->status_flags & H5F_SUPER_WRITE_ACCESS) && file->shared->sblock->status_flags & H5F_SUPER_SWMR_WRITE_ACCESS)) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "file is not already open for SWMR writing") } /* end if */ @@ -1511,16 +1471,11 @@ done: /*------------------------------------------------------------------------- - * Function: H5F_flush_phase1 - * - * Purpose: First phase of flushing cached data. + * Function: H5F_flush_phase1 * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * koziol@lbl.gov - * Jan 1 2017 + * Purpose: First phase of flushing cached data. * + * Return: Non-negative on success/Negative on failure *------------------------------------------------------------------------- */ static herr_t @@ -1553,16 +1508,11 @@ H5F__flush_phase1(H5F_t *f, hid_t meta_dxpl_id) /*------------------------------------------------------------------------- - * Function: H5F__flush_phase2 - * - * Purpose: Second phase of flushing cached data. - * - * Return: Non-negative on success/Negative on failure + * Function: H5F__flush_phase2 * - * Programmer: Quincey Koziol - * koziol@lbl.gov - * Jan 1 2017 + * Purpose: Second phase of flushing cached data. * + * Return: Non-negative on success/Negative on failure *------------------------------------------------------------------------- */ static herr_t @@ -1620,16 +1570,11 @@ H5F__flush_phase2(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t closi /*------------------------------------------------------------------------- - * Function: H5F__flush + * Function: H5F__flush * - * Purpose: Flushes cached data. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Robb Matzke - * matzke@llnl.gov - * Aug 29 1997 + * Purpose: Flushes cached data. * + * Return: Non-negative on success/Negative on failure *------------------------------------------------------------------------- */ herr_t @@ -1657,33 +1602,29 @@ H5F__flush(H5F_t *f, hid_t meta_dxpl_id, hid_t raw_dxpl_id, hbool_t closing) /*------------------------------------------------------------------------- - * Function: H5F_close - * - * Purpose: Closes a file or causes the close operation to be pended. - * This function is called two ways: from the API it gets called - * by H5Fclose->H5I_dec_ref->H5F_close when H5I_dec_ref() - * decrements the file ID reference count to zero. The file ID - * is removed from the H5I_FILE group by H5I_dec_ref() just - * before H5F_close() is called. If there are open object - * headers then the close is pended by moving the file to the - * H5I_FILE_CLOSING ID group (the f->closing contains the ID - * assigned to file). - * - * This function is also called directly from H5O_close() when - * the last object header is closed for the file and the file - * has a pending close. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Robb Matzke - * Tuesday, September 23, 1997 - * + * Function: H5F_close + * + * Purpose: Closes a file or causes the close operation to be pended. + * This function is called two ways: from the API it gets called + * by H5Fclose->H5I_dec_ref->H5F_close when H5I_dec_ref() + * decrements the file ID reference count to zero. The file ID + * is removed from the H5I_FILE group by H5I_dec_ref() just + * before H5F_close() is called. If there are open object + * headers then the close is pended by moving the file to the + * H5I_FILE_CLOSING ID group (the f->closing contains the ID + * assigned to file). + * + * This function is also called directly from H5O_close() when + * the last object header is closed for the file and the file + * has a pending close. + * + * Return: Non-negative on success/Negative on failure *------------------------------------------------------------------------- */ herr_t H5F_close(H5F_t *f) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1722,18 +1663,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5F_try_close + * Function: H5F_try_close * - * Purpose: Attempts to close a file due to one of several actions: + * Purpose: Attempts to close a file due to one of several actions: * - The reference count on the file ID dropped to zero * - The last open object was closed in the file * - The file was unmounted * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Tuesday, July 19, 2005 - * + * Return: Non-negative on success/Negative on failure *------------------------------------------------------------------------- */ herr_t @@ -1741,7 +1678,7 @@ H5F_try_close(H5F_t *f, hbool_t *was_closed /*out*/) { unsigned nopen_files = 0; /* Number of open files in file/mount hierarchy */ unsigned nopen_objs = 0; /* Number of open objects in file/mount hierarchy */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1772,12 +1709,12 @@ H5F_try_close(H5F_t *f, hbool_t *was_closed /*out*/) /* * Close file according to close degree: * - * H5F_CLOSE_WEAK: if there are still objects open, wait until - * they are all closed. - * H5F_CLOSE_SEMI: if there are still objects open, return fail; - * otherwise, close file. - * H5F_CLOSE_STRONG: if there are still objects open, close them - * first, then close file. + * H5F_CLOSE_WEAK: if there are still objects open, wait until + * they are all closed. + * H5F_CLOSE_SEMI: if there are still objects open, return fail; + * otherwise, close file. + * H5F_CLOSE_STRONG: if there are still objects open, close them + * first, then close file. */ switch(f->shared->fc_degree) { case H5F_CLOSE_WEAK: @@ -1899,16 +1836,12 @@ done: /*------------------------------------------------------------------------- - * Function: H5F_get_id - * - * Purpose: Get the file ID, incrementing it, or "resurrecting" it as - * appropriate. - * - * Return: Non-negative on success/Negative on failure + * Function: H5F_get_id * - * Programmer: Raymond Lu - * Oct 29, 2003 + * Purpose: Get the file ID, incrementing it, or "resurrecting" it as + * appropriate. * + * Return: Non-negative on success/Negative on failure *------------------------------------------------------------------------- */ hid_t @@ -1923,8 +1856,9 @@ H5F_get_id(H5F_t *file, hbool_t app_ref) if(file->file_id == -1) { /* Get an atom for the file */ if((file->file_id = H5I_register(H5I_FILE, file, app_ref)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file") - } else { + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file") + } + else { /* Increment reference count on atom. */ if(H5I_inc_ref(file->file_id, app_ref) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, FAIL, "incrementing file ID failed") @@ -1938,18 +1872,12 @@ done: /*------------------------------------------------------------------------- - * Function: H5F_incr_nopen_objs - * - * Purpose: Increment the number of open objects for a file. - * - * Return: Success: The number of open objects, after the increment + * Function: H5F_incr_nopen_objs * - * Failure: (can't happen) - * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Mar 6 2007 + * Purpose: Increment the number of open objects for a file. * + * Return: Success: The number of open objects, after the increment + * Failure: (can't happen) *------------------------------------------------------------------------- */ unsigned @@ -1965,18 +1893,12 @@ H5F_incr_nopen_objs(H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_decr_nopen_objs - * - * Purpose: Decrement the number of open objects for a file. - * - * Return: Success: The number of open objects, after the decrement - * - * Failure: (can't happen) + * Function: H5F_decr_nopen_objs * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Mar 6 2007 + * Purpose: Decrement the number of open objects for a file. * + * Return: Success: The number of open objects, after the decrement + * Failure: (can't happen) *------------------------------------------------------------------------- */ unsigned @@ -1992,18 +1914,14 @@ H5F_decr_nopen_objs(H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_build_actual_name + * Function: H5F_build_actual_name * - * Purpose: Retrieve the name of a file, after following symlinks, etc. + * Purpose: Retrieve the name of a file, after following symlinks, etc. * - * Note: Currently only working for "POSIX I/O compatible" VFDs - * - * Return: Success: 0 - * Failure: -1 - * - * Programmer: Quincey Koziol - * November 25, 2009 + * Note: Currently only working for "POSIX I/O compatible" VFDs * + * Return: Success: 0 + * Failure: -1 *------------------------------------------------------------------------- */ static herr_t @@ -2118,17 +2036,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5F_addr_encode_len - * - * Purpose: Encodes an address into the buffer pointed to by *PP and - * then increments the pointer to the first byte after the - * address. An undefined value is stored as all 1's. + * Function: H5F_addr_encode_len * - * Return: void - * - * Programmer: Robb Matzke - * Friday, November 7, 1997 + * Purpose: Encodes an address into the buffer pointed to by *PP and + * then increments the pointer to the first byte after the + * address. An undefined value is stored as all 1's. * + * Return: void *------------------------------------------------------------------------- */ void @@ -2143,15 +2057,15 @@ H5F_addr_encode_len(size_t addr_len, uint8_t **pp/*in,out*/, haddr_t addr) HDassert(pp && *pp); if(H5F_addr_defined(addr)) { - for(u = 0; u < addr_len; u++) { - *(*pp)++ = (uint8_t)(addr & 0xff); - addr >>= 8; - } /* end for */ - HDassert("overflow" && 0 == addr); + for(u = 0; u < addr_len; u++) { + *(*pp)++ = (uint8_t)(addr & 0xff); + addr >>= 8; + } /* end for */ + HDassert("overflow" && 0 == addr); } /* end if */ else { - for(u = 0; u < addr_len; u++) - *(*pp)++ = 0xff; + for(u = 0; u < addr_len; u++) + *(*pp)++ = 0xff; } /* end else */ FUNC_LEAVE_NOAPI_VOID @@ -2159,17 +2073,13 @@ H5F_addr_encode_len(size_t addr_len, uint8_t **pp/*in,out*/, haddr_t addr) /*------------------------------------------------------------------------- - * Function: H5F_addr_encode - * - * Purpose: Encodes an address into the buffer pointed to by *PP and - * then increments the pointer to the first byte after the - * address. An undefined value is stored as all 1's. - * - * Return: void + * Function: H5F_addr_encode * - * Programmer: Robb Matzke - * Friday, November 7, 1997 + * Purpose: Encodes an address into the buffer pointed to by *PP and + * then increments the pointer to the first byte after the + * address. An undefined value is stored as all 1's. * + * Return: void *------------------------------------------------------------------------- */ void @@ -2187,27 +2097,23 @@ H5F_addr_encode(const H5F_t *f, uint8_t **pp/*in,out*/, haddr_t addr) /*------------------------------------------------------------------------- - * Function: H5F_addr_decode_len + * Function: H5F_addr_decode_len * - * Purpose: Decodes an address from the buffer pointed to by *PP and - * updates the pointer to point to the next byte after the - * address. + * Purpose: Decodes an address from the buffer pointed to by *PP and + * updates the pointer to point to the next byte after the + * address. * - * If the value read is all 1's then the address is returned - * with an undefined value. - * - * Return: void - * - * Programmer: Robb Matzke - * Friday, November 7, 1997 + * If the value read is all 1's then the address is returned + * with an undefined value. * + * Return: void *------------------------------------------------------------------------- */ void H5F_addr_decode_len(size_t addr_len, const uint8_t **pp/*in,out*/, haddr_t *addr_p/*out*/) { - hbool_t all_zero = TRUE; /* True if address was all zeroes */ - unsigned u; /* Local index variable */ + hbool_t all_zero = TRUE; /* True if address was all zeroes */ + unsigned u; /* Local index variable */ /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -2221,27 +2127,27 @@ H5F_addr_decode_len(size_t addr_len, const uint8_t **pp/*in,out*/, haddr_t *addr /* Decode bytes from address */ for(u = 0; u < addr_len; u++) { - uint8_t c; /* Local decoded byte */ + uint8_t c; /* Local decoded byte */ /* Get decoded byte (and advance pointer) */ - c = *(*pp)++; + c = *(*pp)++; /* Check for non-undefined address byte value */ - if(c != 0xff) + if(c != 0xff) all_zero = FALSE; - if(u < sizeof(*addr_p)) { - haddr_t tmp = c; /* Local copy of address, for casting */ + if(u < sizeof(*addr_p)) { + haddr_t tmp = c; /* Local copy of address, for casting */ /* Shift decoded byte to correct position */ - tmp <<= (u * 8); /*use tmp to get casting right */ + tmp <<= (u * 8); /*use tmp to get casting right */ /* Merge into already decoded bytes */ - *addr_p |= tmp; - } /* end if */ + *addr_p |= tmp; + } /* end if */ else if(!all_zero) - HDassert(0 == **pp); /*overflow */ + HDassert(0 == **pp); /*overflow */ } /* end for */ /* If 'all_zero' is still TRUE, the address was entirely composed of '0xff' @@ -2255,20 +2161,16 @@ H5F_addr_decode_len(size_t addr_len, const uint8_t **pp/*in,out*/, haddr_t *addr /*------------------------------------------------------------------------- - * Function: H5F_addr_decode + * Function: H5F_addr_decode * - * Purpose: Decodes an address from the buffer pointed to by *PP and - * updates the pointer to point to the next byte after the - * address. + * Purpose: Decodes an address from the buffer pointed to by *PP and + * updates the pointer to point to the next byte after the + * address. * - * If the value read is all 1's then the address is returned - * with an undefined value. - * - * Return: void - * - * Programmer: Robb Matzke - * Friday, November 7, 1997 + * If the value read is all 1's then the address is returned + * with an undefined value. * + * Return: void *------------------------------------------------------------------------- */ void @@ -2292,10 +2194,6 @@ H5F_addr_decode(const H5F_t *f, const uint8_t **pp/*in,out*/, haddr_t *addr_p/*o * * Return: Success: SUCCEED * Failure: FAIL - * - * Programmer: Quincey Koziol - * 7/19/11 - * *------------------------------------------------------------------------- */ herr_t @@ -2322,10 +2220,6 @@ H5F_set_grp_btree_shared(H5F_t *f, H5UC_t *rc) * * Return: Success: SUCCEED * Failure: FAIL - * - * Programmer: Quincey Koziol - * 7/20/11 - * *------------------------------------------------------------------------- */ herr_t @@ -2351,10 +2245,6 @@ H5F_set_sohm_addr(H5F_t *f, haddr_t addr) * * Return: Success: SUCCEED * Failure: FAIL - * - * Programmer: Quincey Koziol - * 7/20/11 - * *------------------------------------------------------------------------- */ herr_t @@ -2380,10 +2270,6 @@ H5F_set_sohm_vers(H5F_t *f, unsigned vers) * * Return: Success: SUCCEED * Failure: FAIL - * - * Programmer: Quincey Koziol - * 7/20/11 - * *------------------------------------------------------------------------- */ herr_t @@ -2409,10 +2295,6 @@ H5F_set_sohm_nindexes(H5F_t *f, unsigned nindexes) * * Return: Success: SUCCEED * Failure: FAIL - * - * Programmer: Quincey Koziol - * 7/20/11 - * *------------------------------------------------------------------------- */ herr_t @@ -2438,10 +2320,6 @@ H5F_set_store_msg_crt_idx(H5F_t *f, hbool_t flag) * * Return: Success: Bytes copied / number of bytes needed. * Failure: negative value - * - * Programmer: John Mainzer - * 11/15/11 - * *------------------------------------------------------------------------- */ ssize_t @@ -2482,20 +2360,20 @@ H5F_get_file_image(H5F_t *file, void *buf_ptr, size_t buf_len, hid_t meta_dxpl_i if(HDstrcmp(fd_ptr->cls->name, "multi") == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Not supported for multi file driver.") - /* While the family file driver is conceptually fully compatible + /* While the family file driver is conceptually fully compatible * with the get file image operation, it sets a file driver message * in the super block that prevents the image being opened with any * driver other than the family file driver. Needless to say, this * rather defeats the purpose of the get file image operation. * - * While this problem is quire solvable, the required time and + * While this problem is quire solvable, the required time and * resources are lacking at present. Hence, for now, we don't - * allow the get file image operation to be perfomed on files + * allow the get file image operation to be perfomed on files * opened with the family file driver. * - * Observe that the following test only looks at the top level + * Observe that the following test only looks at the top level * driver, and fails if there is some other driver sitting on to - * of the family file driver. + * of the family file driver. * * I don't think this can happen at present, but that may change * in the future. @@ -2514,7 +2392,7 @@ H5F_get_file_image(H5F_t *file, void *buf_ptr, size_t buf_len, hid_t meta_dxpl_i /* test to see if a buffer was provided -- if not, we are done */ if(buf_ptr != NULL) { H5FD_io_info_t fdio_info; /* File driver I/O info */ - size_t space_needed; /* size of file image */ + size_t space_needed; /* size of file image */ hsize_t tmp; size_t tmp_size; @@ -2545,34 +2423,31 @@ H5F_get_file_image(H5F_t *file, void *buf_ptr, size_t buf_len, hid_t meta_dxpl_i HDmemset((uint8_t *)(buf_ptr) + tmp, 0, tmp_size); } /* end if */ - + done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F_get_file_image() */ /*------------------------------------------------------------------------- - * Function: H5F_track_metadata_read_retries - * - * Purpose: To track the # of a "retries" (log10) for a metadata item. - * This routine should be used only when: - * "retries" > 0 - * f->shared->read_attempts > 1 (does not have retry when 1) - * f->shared->retries_nbins > 0 (calculated based on f->shared->read_attempts) + * Function: H5F_track_metadata_read_retries * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Vailin Choi; October 2013 + * Purpose: To track the # of a "retries" (log10) for a metadata item. + * This routine should be used only when: + * "retries" > 0 + * f->shared->read_attempts > 1 (does not have retry when 1) + * f->shared->retries_nbins > 0 (calculated based on f->shared->read_attempts) * + * Return: Success: SUCCEED + * Failure: FAIL *------------------------------------------------------------------------- */ herr_t H5F_track_metadata_read_retries(H5F_t *f, unsigned actype, unsigned retries) { - unsigned log_ind; /* Index to the array of retries based on log10 of retries */ - double tmp; /* Temporary value, to keep compiler quiet */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned log_ind; /* Index to the array of retries based on log10 of retries */ + double tmp; /* Temporary value, to keep compiler quiet */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2603,23 +2478,20 @@ done: /*------------------------------------------------------------------------- - * Function: H5F_set_retries - * - * Purpose: To initialize data structures for read retries: - * --zero out "retries" - * --set up "retries_nbins" based on read_attempts - * - * Return: Success: SUCCEED - * Failure: FAIL + * Function: H5F_set_retries * - * Programmer: Vailin Choi; November 2013 + * Purpose: To initialize data structures for read retries: + * --zero out "retries" + * --set up "retries_nbins" based on read_attempts * + * Return: Success: SUCCEED + * Failure: FAIL *------------------------------------------------------------------------- */ herr_t H5F_set_retries(H5F_t *f) { - double tmp; /* Temporary variable */ + double tmp; /* Temporary variable */ /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -2649,9 +2521,6 @@ H5F_set_retries(H5F_t *f) * * Return: Success: SUCCEED * Failure: FAIL - * - * Programmer: Vailin Choi; October 2013 - * *------------------------------------------------------------------------- */ herr_t @@ -2675,15 +2544,11 @@ done: /*------------------------------------------------------------------------- - * Function: H5F__set_base_addr + * Function: H5F__set_base_addr * - * Purpose: Quick and dirty routine to set the file's 'base_addr' value - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * July 19, 2013 + * Purpose: Quick and dirty routine to set the file's 'base_addr' value * + * Return: Non-negative on success/Negative on failure *------------------------------------------------------------------------- */ herr_t @@ -2698,7 +2563,7 @@ H5F__set_base_addr(const H5F_t *f, haddr_t addr) /* Dispatch to driver */ if(H5FD_set_base_addr(f->shared->lf, addr) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "driver set_base_addr request failed") + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "driver set_base_addr request failed") done: FUNC_LEAVE_NOAPI(ret_value) @@ -2706,15 +2571,11 @@ done: /*------------------------------------------------------------------------- - * Function: H5F__set_eoa - * - * Purpose: Quick and dirty routine to set the file's 'eoa' value + * Function: H5F__set_eoa * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * July 19, 2013 + * Purpose: Quick and dirty routine to set the file's 'eoa' value * + * Return: Non-negative on success/Negative on failure *------------------------------------------------------------------------- */ herr_t @@ -2729,7 +2590,7 @@ H5F__set_eoa(const H5F_t *f, H5F_mem_t type, haddr_t addr) /* Dispatch to driver */ if(H5FD_set_eoa(f->shared->lf, type, addr) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "driver set_eoa request failed") + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "driver set_eoa request failed") done: FUNC_LEAVE_NOAPI(ret_value) @@ -2737,15 +2598,11 @@ done: /*------------------------------------------------------------------------- - * Function: H5F__set_paged_aggr - * - * Purpose: Quick and dirty routine to set the file's paged_aggr mode + * Function: H5F__set_paged_aggr * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * June 19, 2015 + * Purpose: Quick and dirty routine to set the file's paged_aggr mode * + * Return: Non-negative on success/Negative on failure *------------------------------------------------------------------------- */ herr_t @@ -2776,10 +2633,6 @@ done: * * Return: Success: SUCCEED * Failure: FAIL - * - * Programmer: Quincey Koziol - * 2/10/16 - * *------------------------------------------------------------------------- */ void @@ -2805,10 +2658,6 @@ H5F_set_coll_md_read(H5F_t *f, H5P_coll_md_read_flag_t cmr) * * Return: Success: SUCCEED * Failure: FAIL - * - * Programmer: Quincey Koziol - * 4/26/16 - * *------------------------------------------------------------------------- */ herr_t diff --git a/src/H5Fquery.c b/src/H5Fquery.c index 41cf4d2..cc2399b 100644 --- a/src/H5Fquery.c +++ b/src/H5Fquery.c @@ -26,16 +26,16 @@ /* Module Setup */ /****************/ -#include "H5Fmodule.h" /* This source code file is part of the H5F module */ +#include "H5Fmodule.h" /* This source code file is part of the H5F module */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ /****************/ @@ -75,17 +75,13 @@ /*------------------------------------------------------------------------- - * Function: H5F_get_intent + * Function: H5F_get_intent * - * Purpose: Quick and dirty routine to retrieve the file's 'intent' flags - * (Mainly added to stop non-file routines from poking about in the - * H5F_t data structure) - * - * Return: 'intent' on success/abort on failure (shouldn't fail) - * - * Programmer: Quincey Koziol - * September 29, 2000 + * Purpose: Quick and dirty routine to retrieve the file's 'intent' flags + * (Mainly added to stop non-file routines from poking about in the + * H5F_t data structure) * + * Return: 'intent' on success/abort on failure (shouldn't fail) *------------------------------------------------------------------------- */ unsigned @@ -101,16 +97,12 @@ H5F_get_intent(const H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_get_open_name - * - * Purpose: Retrieve the name used to open a file. - * - * Return: Success: The name of the file. - * Failure: ? (should not happen) + * Function: H5F_get_open_name * - * Programmer: Neil Fortner - * December 15 2008 + * Purpose: Retrieve the name used to open a file. * + * Return: Success: The name of the file. + * Failure: ? (should not happen) *------------------------------------------------------------------------- */ char * @@ -127,16 +119,12 @@ H5F_get_open_name(const H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_get_actual_name + * Function: H5F_get_actual_name * - * Purpose: Retrieve the actual name of a file, after resolving symlinks, etc. - * - * Return: Success: The name of the file. - * Failure: ? (should not happen) - * - * Programmer: Quincey Koziol - * November 25 2009 + * Purpose: Retrieve the actual name of a file, after resolving symlinks, etc. * + * Return: Success: The name of the file. + * Failure: ? (should not happen) *------------------------------------------------------------------------- */ char * @@ -153,16 +141,13 @@ H5F_get_actual_name(const H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_get_extpath - * - * Purpose: Retrieve the file's 'extpath' flags - * This is used by H5L_extern_traverse() and H5D_build_extfile_prefix() to retrieve the main file's location - * when searching the target file. + * Function: H5F_get_extpath * - * Return: 'extpath' on success/abort on failure (shouldn't fail) - * - * Programmer: Vailin Choi, April 2, 2008 + * Purpose: Retrieve the file's 'extpath' flags + * This is used by H5L_extern_traverse() and H5D_build_extfile_prefix() to retrieve the main file's location + * when searching the target file. * + * Return: 'extpath' on success/abort on failure (shouldn't fail) *------------------------------------------------------------------------- */ char * @@ -179,14 +164,11 @@ H5F_get_extpath(const H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_get_shared - * - * Purpose: Retrieve the file's 'shared' pointer + * Function: H5F_get_shared * - * Return: 'shared' on success/abort on failure (shouldn't fail) - * - * Programmer: Quincey Koziol, July 20, 2011 + * Purpose: Retrieve the file's 'shared' pointer * + * Return: 'shared' on success/abort on failure (shouldn't fail) *------------------------------------------------------------------------- */ H5F_file_t * @@ -202,14 +184,11 @@ H5F_get_shared(const H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_same_shared - * - * Purpose: Determine if two files have the same shared file pointer + * Function: H5F_same_shared * - * Return: TRUE/FALSE on success/abort on failure (shouldn't fail) - * - * Programmer: Quincey Koziol, July 19, 2011 + * Purpose: Determine if two files have the same shared file pointer * + * Return: TRUE/FALSE on success/abort on failure (shouldn't fail) *------------------------------------------------------------------------- */ hbool_t @@ -228,14 +207,11 @@ H5F_same_shared(const H5F_t *f1, const H5F_t *f2) /*------------------------------------------------------------------------- - * Function: H5F_get_nopen_objs - * - * Purpose: Retrieve the file's 'nopen_objs' value - * - * Return: 'nopen_objs' on success/abort on failure (shouldn't fail) + * Function: H5F_get_nopen_objs * - * Programmer: Quincey Koziol, July 20, 2011 + * Purpose: Retrieve the file's 'nopen_objs' value * + * Return: 'nopen_objs' on success/abort on failure (shouldn't fail) *------------------------------------------------------------------------- */ unsigned @@ -251,14 +227,11 @@ H5F_get_nopen_objs(const H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_get_file_id + * Function: H5F_get_file_id * - * Purpose: Retrieve the file's 'file_id' value - * - * Return: 'file_id' on success/abort on failure (shouldn't fail) - * - * Programmer: Quincey Koziol, July 20, 2011 + * Purpose: Retrieve the file's 'file_id' value * + * Return: 'file_id' on success/abort on failure (shouldn't fail) *------------------------------------------------------------------------- */ hid_t @@ -274,14 +247,11 @@ H5F_get_file_id(const H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_get_parent - * - * Purpose: Retrieve the file's 'parent' pointer - * - * Return: 'parent' on success/abort on failure (shouldn't fail) + * Function: H5F_get_parent * - * Programmer: Quincey Koziol, July 19, 2011 + * Purpose: Retrieve the file's 'parent' pointer * + * Return: 'parent' on success/abort on failure (shouldn't fail) *------------------------------------------------------------------------- */ H5F_t * @@ -297,14 +267,11 @@ H5F_get_parent(const H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_get_nmounts + * Function: H5F_get_nmounts * - * Purpose: Retrieve the file's 'nmounts' value - * - * Return: 'nmounts' on success/abort on failure (shouldn't fail) - * - * Programmer: Quincey Koziol, July 20, 2011 + * Purpose: Retrieve the file's 'nmounts' value * + * Return: 'nmounts' on success/abort on failure (shouldn't fail) *------------------------------------------------------------------------- */ unsigned @@ -320,14 +287,11 @@ H5F_get_nmounts(const H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_get_read_attempts - * - * Purpose: Retrieve the file's 'read_attempts' value + * Function: H5F_get_read_attempts * - * Return: '# of read attempts' on success/abort on failure (shouldn't fail) - * - * Programmer: Vaili Choi; Sept 2013 + * Purpose: Retrieve the file's 'read_attempts' value * + * Return: '# of read attempts' on success/abort on failure (shouldn't fail) *------------------------------------------------------------------------- */ unsigned @@ -343,18 +307,12 @@ H5F_get_read_attempts(const H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_get_fcpl - * - * Purpose: Retrieve the value of a file's FCPL. - * - * Return: Success: The FCPL for the file. + * Function: H5F_get_fcpl * - * Failure: ? (should not happen) - * - * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu - * May 25 2005 + * Purpose: Retrieve the value of a file's FCPL. * + * Return: Success: The FCPL for the file. + * Failure: ? (should not happen) *------------------------------------------------------------------------- */ hid_t @@ -371,17 +329,13 @@ H5F_get_fcpl(const H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_sizeof_addr - * - * Purpose: Quick and dirty routine to retrieve the size of the file's size_t - * (Mainly added to stop non-file routines from poking about in the - * H5F_t data structure) - * - * Return: 'sizeof_addr' on success/abort on failure (shouldn't fail) + * Function: H5F_sizeof_addr * - * Programmer: Quincey Koziol - * September 29, 2000 + * Purpose: Quick and dirty routine to retrieve the size of the file's size_t + * (Mainly added to stop non-file routines from poking about in the + * H5F_t data structure) * + * Return: 'sizeof_addr' on success/abort on failure (shouldn't fail) *------------------------------------------------------------------------- */ uint8_t @@ -398,17 +352,13 @@ H5F_sizeof_addr(const H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_sizeof_size + * Function: H5F_sizeof_size * - * Purpose: Quick and dirty routine to retrieve the size of the file's off_t - * (Mainly added to stop non-file routines from poking about in the - * H5F_t data structure) - * - * Return: 'sizeof_size' on success/abort on failure (shouldn't fail) - * - * Programmer: Quincey Koziol - * September 29, 2000 + * Purpose: Quick and dirty routine to retrieve the size of the file's off_t + * (Mainly added to stop non-file routines from poking about in the + * H5F_t data structure) * + * Return: 'sizeof_size' on success/abort on failure (shouldn't fail) *------------------------------------------------------------------------- */ uint8_t @@ -425,14 +375,11 @@ H5F_sizeof_size(const H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_get_sohm_addr - * - * Purpose: Retrieve the file's 'sohm_addr' value - * - * Return: 'sohm_addr' on success/abort on failure (shouldn't fail) + * Function: H5F_get_sohm_addr * - * Programmer: Quincey Koziol, July 20, 2011 + * Purpose: Retrieve the file's 'sohm_addr' value * + * Return: 'sohm_addr' on success/abort on failure (shouldn't fail) *------------------------------------------------------------------------- */ haddr_t @@ -449,14 +396,11 @@ H5F_get_sohm_addr(const H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_get_sohm_vers + * Function: H5F_get_sohm_vers * - * Purpose: Retrieve the file's 'sohm_vers' value - * - * Return: 'sohm_vers' on success/abort on failure (shouldn't fail) - * - * Programmer: Quincey Koziol, July 20, 2011 + * Purpose: Retrieve the file's 'sohm_vers' value * + * Return: 'sohm_vers' on success/abort on failure (shouldn't fail) *------------------------------------------------------------------------- */ unsigned @@ -473,14 +417,11 @@ H5F_get_sohm_vers(const H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_get_sohm_nindexes - * - * Purpose: Retrieve the file's 'sohm_nindexes' value + * Function: H5F_get_sohm_nindexes * - * Return: 'sohm_nindexes' on success/abort on failure (shouldn't fail) - * - * Programmer: Quincey Koziol, July 20, 2011 + * Purpose: Retrieve the file's 'sohm_nindexes' value * + * Return: 'sohm_nindexes' on success/abort on failure (shouldn't fail) *------------------------------------------------------------------------- */ unsigned @@ -497,21 +438,15 @@ H5F_get_sohm_nindexes(const H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_sym_leaf_k + * Function: H5F_sym_leaf_k * - * Purpose: Replaced a macro to retrieve the symbol table leaf size, - * now that the generic properties are being used to store - * the values. + * Purpose: Replaced a macro to retrieve the symbol table leaf size, + * now that the generic properties are being used to store + * the values. * - * Return: Success: Non-negative, and the symbol table leaf size is + * Return: Success: Non-negative, and the symbol table leaf size is * returned. - * - * Failure: Negative (should not happen) - * - * Programmer: Raymond Lu - * slu@ncsa.uiuc.edu - * Oct 14 2001 - * + * Failure: Negative (should not happen) *------------------------------------------------------------------------- */ unsigned @@ -529,21 +464,15 @@ H5F_sym_leaf_k(const H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_Kvalue + * Function: H5F_Kvalue * - * Purpose: Replaced a macro to retrieve a B-tree key value for a certain - * type, now that the generic properties are being used to store - * the B-tree values. + * Purpose: Replaced a macro to retrieve a B-tree key value for a certain + * type, now that the generic properties are being used to store + * the B-tree values. * - * Return: Success: Non-negative, and the B-tree key value is + * Return: Success: Non-negative, and the B-tree key value is * returned. - * - * Failure: Negative (should not happen) - * - * Programmer: Raymond Lu - * slu@ncsa.uiuc.edu - * Oct 14 2001 - * + * Failure: Negative (should not happen) *------------------------------------------------------------------------- */ unsigned @@ -562,14 +491,11 @@ H5F_Kvalue(const H5F_t *f, const H5B_class_t *type) /*------------------------------------------------------------------------- - * Function: H5F_get_nrefs + * Function: H5F_get_nrefs * - * Purpose: Retrieve the file's 'nrefs' value - * - * Return: 'nrefs' on success/abort on failure (shouldn't fail) - * - * Programmer: Quincey Koziol, July 20, 2011 + * Purpose: Retrieve the file's 'nrefs' value * + * Return: 'nrefs' on success/abort on failure (shouldn't fail) *------------------------------------------------------------------------- */ unsigned @@ -586,21 +512,15 @@ H5F_get_nrefs(const H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_rdcc_nslots + * Function: H5F_rdcc_nslots * - * Purpose: Replaced a macro to retrieve the raw data cache number of slots, - * now that the generic properties are being used to store - * the values. + * Purpose: Replaced a macro to retrieve the raw data cache number of slots, + * now that the generic properties are being used to store + * the values. * - * Return: Success: Non-negative, and the raw data cache number of + * Return: Success: Non-negative, and the raw data cache number of * of slots is returned. - * - * Failure: Negative (should not happen) - * - * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu - * Jun 1 2004 - * + * Failure: Negative (should not happen) *------------------------------------------------------------------------- */ size_t @@ -617,21 +537,15 @@ H5F_rdcc_nslots(const H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_rdcc_nbytes + * Function: H5F_rdcc_nbytes * - * Purpose: Replaced a macro to retrieve the raw data cache number of bytes, - * now that the generic properties are being used to store - * the values. + * Purpose: Replaced a macro to retrieve the raw data cache number of bytes, + * now that the generic properties are being used to store + * the values. * - * Return: Success: Non-negative, and the raw data cache number of + * Return: Success: Non-negative, and the raw data cache number of * of bytes is returned. - * - * Failure: Negative (should not happen) - * - * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu - * Jun 1 2004 - * + * Failure: Negative (should not happen) *------------------------------------------------------------------------- */ size_t @@ -648,21 +562,15 @@ H5F_rdcc_nbytes(const H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_rdcc_w0 + * Function: H5F_rdcc_w0 * - * Purpose: Replaced a macro to retrieve the raw data cache 'w0' value - * now that the generic properties are being used to store - * the values. + * Purpose: Replaced a macro to retrieve the raw data cache 'w0' value + * now that the generic properties are being used to store + * the values. * - * Return: Success: Non-negative, and the raw data cache 'w0' value + * Return: Success: Non-negative, and the raw data cache 'w0' value * is returned. - * - * Failure: Negative (should not happen) - * - * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu - * Jun 2 2004 - * + * Failure: Negative (should not happen) *------------------------------------------------------------------------- */ double @@ -679,17 +587,13 @@ H5F_rdcc_w0(const H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_get_base_addr - * - * Purpose: Quick and dirty routine to retrieve the file's 'base_addr' value - * (Mainly added to stop non-file routines from poking about in the - * H5F_t data structure) - * - * Return: Non-negative on success/Negative on failure + * Function: H5F_get_base_addr * - * Programmer: Raymond Lu - * December 20, 2002 + * Purpose: Quick and dirty routine to retrieve the file's 'base_addr' value + * (Mainly added to stop non-file routines from poking about in the + * H5F_t data structure) * + * Return: Non-negative on success/Negative on failure *------------------------------------------------------------------------- */ haddr_t @@ -707,21 +611,15 @@ H5F_get_base_addr(const H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_grp_btree_shared + * Function: H5F_grp_btree_shared * - * Purpose: Replaced a macro to retrieve the shared B-tree node info - * now that the generic properties are being used to store - * the values. + * Purpose: Replaced a macro to retrieve the shared B-tree node info + * now that the generic properties are being used to store + * the values. * - * Return: Success: Non-void, and the shared B-tree node info + * Return: Success: Non-void, and the shared B-tree node info * is returned. - * - * Failure: void (should not happen) - * - * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu - * Jul 5 2004 - * + * Failure: void (should not happen) *------------------------------------------------------------------------- */ H5UC_t * @@ -738,21 +636,15 @@ H5F_grp_btree_shared(const H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_sieve_buf_size + * Function: H5F_sieve_buf_size * - * Purpose: Replaced a macro to retrieve the dataset sieve buffer size - * now that the generic properties are being used to store - * the values. + * Purpose: Replaced a macro to retrieve the dataset sieve buffer size + * now that the generic properties are being used to store + * the values. * - * Return: Success: Non-void, and the dataset sieve buffer size + * Return: Success: Non-void, and the dataset sieve buffer size * is returned. - * - * Failure: void (should not happen) - * - * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu - * Jul 8 2005 - * + * Failure: void (should not happen) *------------------------------------------------------------------------- */ size_t @@ -769,21 +661,15 @@ H5F_sieve_buf_size(const H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_gc_ref + * Function: H5F_gc_ref * - * Purpose: Replaced a macro to retrieve the "garbage collect - * references flag" now that the generic properties are being used - * to store the values. + * Purpose: Replaced a macro to retrieve the "garbage collect + * references flag" now that the generic properties are being used + * to store the values. * - * Return: Success: The "garbage collect references flag" + * Return: Success: The "garbage collect references flag" * is returned. - * - * Failure: (should not happen) - * - * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu - * Jul 8 2005 - * + * Failure: (should not happen) *------------------------------------------------------------------------- */ unsigned @@ -800,18 +686,12 @@ H5F_gc_ref(const H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_use_latest_flags - * - * Purpose: Retrieve the 'latest version support' for the file. - * - * Return: Success: Non-negative, the requested 'version support' + * Function: H5F_use_latest_flags * - * Failure: (can't happen) - * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Mar 5 2007 + * Purpose: Retrieve the 'latest version support' for the file. * + * Return: Success: Non-negative, the requested 'version support' + * Failure: (can't happen) *------------------------------------------------------------------------- */ unsigned @@ -828,18 +708,12 @@ H5F_use_latest_flags(const H5F_t *f, unsigned fl) /*------------------------------------------------------------------------- - * Function: H5F_get_fc_degree - * - * Purpose: Retrieve the 'file close degree' for the file. - * - * Return: Success: Non-negative, the 'file close degree' + * Function: H5F_get_fc_degree * - * Failure: (can't happen) - * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Mar 5 2007 + * Purpose: Retrieve the 'file close degree' for the file. * + * Return: Success: Non-negative, the 'file close degree' + * Failure: (can't happen) *------------------------------------------------------------------------- */ H5F_close_degree_t @@ -864,10 +738,6 @@ H5F_get_fc_degree(const H5F_t *f) * Return: Success: Flag indicating whether the evict-on-close * property was set for the file. * Failure: (can't happen) - * - * Programmer: Dana Robinson - * Spring 2016 - * *------------------------------------------------------------------------- */ hbool_t @@ -884,18 +754,12 @@ H5F_get_evict_on_close(const H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_store_msg_crt_idx - * - * Purpose: Retrieve the 'store message creation index' flag for the file. + * Function: H5F_store_msg_crt_idx * - * Return: Success: Non-negative, the 'store message creation index' flag - * - * Failure: (can't happen) - * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Mar 6 2007 + * Purpose: Retrieve the 'store message creation index' flag for the file. * + * Return: Success: Non-negative, the 'store message creation index' flag + * Failure: (can't happen) *------------------------------------------------------------------------- */ hbool_t @@ -912,17 +776,12 @@ H5F_store_msg_crt_idx(const H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_has_feature - * - * Purpose: Check if a file has a particular feature enabled + * Function: H5F_has_feature * - * Return: Success: Non-negative - TRUE or FALSE - * Failure: Negative (should not happen) - * - * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu - * May 31 2004 + * Purpose: Check if a file has a particular feature enabled * + * Return: Success: Non-negative - TRUE or FALSE + * Failure: Negative (should not happen) *------------------------------------------------------------------------- */ hbool_t @@ -939,17 +798,13 @@ H5F_has_feature(const H5F_t *f, unsigned feature) /*------------------------------------------------------------------------- - * Function: H5F_get_driver_id - * - * Purpose: Quick and dirty routine to retrieve the file's 'driver_id' value - * (Mainly added to stop non-file routines from poking about in the - * H5F_t data structure) - * - * Return: 'driver_id' on success/abort on failure (shouldn't fail) + * Function: H5F_get_driver_id * - * Programmer: Quincey Koziol - * October 10, 2000 + * Purpose: Quick and dirty routine to retrieve the file's 'driver_id' value + * (Mainly added to stop non-file routines from poking about in the + * H5F_t data structure) * + * Return: 'driver_id' on success/abort on failure (shouldn't fail) *------------------------------------------------------------------------- */ hid_t @@ -967,23 +822,19 @@ H5F_get_driver_id(const H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_get_fileno + * Function: H5F_get_fileno * - * Purpose: Quick and dirty routine to retrieve the file's 'fileno' value - * (Mainly added to stop non-file routines from poking about in the - * H5F_t data structure) - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * March 27, 2002 + * Purpose: Quick and dirty routine to retrieve the file's 'fileno' value + * (Mainly added to stop non-file routines from poking about in the + * H5F_t data structure) * + * Return: Non-negative on success/Negative on failure *------------------------------------------------------------------------- */ herr_t H5F_get_fileno(const H5F_t *f, unsigned long *filenum) { - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -994,7 +845,7 @@ H5F_get_fileno(const H5F_t *f, unsigned long *filenum) /* Retrieve the file's serial number */ if(H5FD_get_fileno(f->shared->lf, filenum) < 0) - HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, FAIL, "can't retrieve fileno") + HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, FAIL, "can't retrieve fileno") done: FUNC_LEAVE_NOAPI(ret_value) @@ -1002,21 +853,17 @@ done: /*------------------------------------------------------------------------- - * Function: H5F_get_eoa - * - * Purpose: Quick and dirty routine to retrieve the file's 'eoa' value + * Function: H5F_get_eoa * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * June 1, 2004 + * Purpose: Quick and dirty routine to retrieve the file's 'eoa' value * + * Return: Non-negative on success/Negative on failure *------------------------------------------------------------------------- */ haddr_t H5F_get_eoa(const H5F_t *f, H5FD_mem_t type) { - haddr_t ret_value = HADDR_UNDEF; /* Return value */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI(HADDR_UNDEF) @@ -1025,7 +872,7 @@ H5F_get_eoa(const H5F_t *f, H5FD_mem_t type) /* Dispatch to driver */ if(HADDR_UNDEF == (ret_value = H5FD_get_eoa(f->shared->lf, type))) - HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "driver get_eoa request failed") + HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "driver get_eoa request failed") done: FUNC_LEAVE_NOAPI(ret_value) @@ -1040,10 +887,6 @@ done: * * Return: Success: Non-negative. * Failure: negative. - * - * Programmer: Raymond Lu - * Sep. 16, 2002 - * *------------------------------------------------------------------------- */ herr_t @@ -1067,18 +910,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5F_is_tmp_addr - * - * Purpose: Quick and dirty routine to determine if an address is in - * the 'temporary' file space. - * (Mainly added to stop non-file routines from poking about in the - * H5F_t data structure) + * Function: H5F_is_tmp_addr * - * Return: TRUE/FALSE on success/abort on failure (shouldn't fail) - * - * Programmer: Quincey Koziol - * June 11, 2009 + * Purpose: Quick and dirty routine to determine if an address is in + * the 'temporary' file space. + * (Mainly added to stop non-file routines from poking about in the + * H5F_t data structure) * + * Return: TRUE/FALSE on success/abort on failure (shouldn't fail) *------------------------------------------------------------------------- */ hbool_t @@ -1095,18 +934,14 @@ H5F_is_tmp_addr(const H5F_t *f, haddr_t addr) /*------------------------------------------------------------------------- - * Function: H5F_use_tmp_space - * - * Purpose: Quick and dirty routine to determine if using temporary - * file space is allowed for this file. - * (Mainly added to stop non-file routines from poking about in the - * H5F_t data structure) - * - * Return: TRUE/FALSE on success/abort on failure (shouldn't fail) + * Function: H5F_use_tmp_space * - * Programmer: Quincey Koziol - * July 1, 2009 + * Purpose: Quick and dirty routine to determine if using temporary + * file space is allowed for this file. + * (Mainly added to stop non-file routines from poking about in the + * H5F_t data structure) * + * Return: TRUE/FALSE on success/abort on failure (shouldn't fail) *------------------------------------------------------------------------- */ hbool_t @@ -1124,17 +959,12 @@ H5F_use_tmp_space(const H5F_t *f) #ifdef H5_HAVE_PARALLEL /*------------------------------------------------------------------------- - * Function: H5F_coll_md_read + * Function: H5F_coll_md_read * - * Purpose: Retrieve the 'collective metadata reads' flag for the file. - * - * Return: Success: Non-negative, the 'collective metadata reads' flag - * Failure: (can't happen) - * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Feb 10 2016 + * Purpose: Retrieve the 'collective metadata reads' flag for the file. * + * Return: Success: Non-negative, the 'collective metadata reads' flag + * Failure: (can't happen) *------------------------------------------------------------------------- */ H5P_coll_md_read_flag_t @@ -1151,18 +981,14 @@ H5F_coll_md_read(const H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_use_mdc_logging - * - * Purpose: Quick and dirty routine to determine if using MDC logging - * is enabled for this file. - * (Mainly added to stop non-file routines from poking about in the - * H5F_t data structure) - * - * Return: TRUE/FALSE on success/abort on failure (shouldn't fail) + * Function: H5F_use_mdc_logging * - * Programmer: Quincey Koziol - * June 5, 2016 + * Purpose: Quick and dirty routine to determine if using MDC logging + * is enabled for this file. + * (Mainly added to stop non-file routines from poking about in the + * H5F_t data structure) * + * Return: TRUE/FALSE on success/abort on failure (shouldn't fail) *------------------------------------------------------------------------- */ hbool_t @@ -1179,18 +1005,14 @@ H5F_use_mdc_logging(const H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_start_mdc_log_on_access + * Function: H5F_start_mdc_log_on_access * - * Purpose: Quick and dirty routine to determine if we should start MDC - * logging on access for this file. - * (Mainly added to stop non-file routines from poking about in the - * H5F_t data structure) - * - * Return: TRUE/FALSE on success/abort on failure (shouldn't fail) - * - * Programmer: Quincey Koziol - * June 5, 2016 + * Purpose: Quick and dirty routine to determine if we should start MDC + * logging on access for this file. + * (Mainly added to stop non-file routines from poking about in the + * H5F_t data structure) * + * Return: TRUE/FALSE on success/abort on failure (shouldn't fail) *------------------------------------------------------------------------- */ hbool_t @@ -1207,18 +1029,14 @@ H5F_start_mdc_log_on_access(const H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_mdc_log_location - * - * Purpose: Quick and dirty routine to retrieve the MDC log location - * for this file. - * (Mainly added to stop non-file routines from poking about in the - * H5F_t data structure) + * Function: H5F_mdc_log_location * - * Return: TRUE/FALSE on success/abort on failure (shouldn't fail) - * - * Programmer: Quincey Koziol - * June 5, 2016 + * Purpose: Quick and dirty routine to retrieve the MDC log location + * for this file. + * (Mainly added to stop non-file routines from poking about in the + * H5F_t data structure) * + * Return: TRUE/FALSE on success/abort on failure (shouldn't fail) *------------------------------------------------------------------------- */ char * @@ -1235,16 +1053,12 @@ H5F_mdc_log_location(const H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_get_alignment - * - * Purpose: Retrieve the 'alignment' for the file. - * - * Return: Success: Non-negative, the 'alignment' - * - * Failure: (can't happen) + * Function: H5F_get_alignment * - * Programmer: Vailin Choi; Dec 2012 + * Purpose: Retrieve the 'alignment' for the file. * + * Return: Success: Non-negative, the 'alignment' + * Failure: (can't happen) *------------------------------------------------------------------------- */ hsize_t @@ -1261,16 +1075,12 @@ H5F_get_alignment(const H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_get_threshold - * - * Purpose: Retrieve the 'threshold' for alignment in the file. - * - * Return: Success: Non-negative, the 'threshold' - * - * Failure: (can't happen) + * Function: H5F_get_threshold * - * Programmer: Vailin Choi; Dec 2012 + * Purpose: Retrieve the 'threshold' for alignment in the file. * + * Return: Success: Non-negative, the 'threshold' + * Failure: (can't happen) *------------------------------------------------------------------------- */ hsize_t @@ -1287,16 +1097,12 @@ H5F_get_threshold(const H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_get_pgend_meta_thres + * Function: H5F_get_pgend_meta_thres * - * Purpose: Retrieve the 'page end meta threshold size' for the file. - * - * Return: Success: Non-negative, the 'pgend_meta_thres' - * - * Failure: (can't happen) - * - * Programmer: Vailin Choi; Dec 2012 + * Purpose: Retrieve the 'page end meta threshold size' for the file. * + * Return: Success: Non-negative, the 'pgend_meta_thres' + * Failure: (can't happen) *------------------------------------------------------------------------- */ hsize_t @@ -1313,13 +1119,12 @@ H5F_get_pgend_meta_thres(const H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_get_point_of_no_return + * Function: H5F_get_point_of_no_return * - * Purpose: Retrieve the 'point of no return' value for the file. - * - * Return: Success: Non-negative, the 'point_of_no_return' - * Failure: (can't happen) + * Purpose: Retrieve the 'point of no return' value for the file. * + * Return: Success: Non-negative, the 'point_of_no_return' + * Failure: (can't happen) *------------------------------------------------------------------------- */ hbool_t @@ -1336,13 +1141,12 @@ H5F_get_point_of_no_return(const H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_get_first_alloc_dealloc - * - * Purpose: Retrieve the 'first alloc / dealloc' value for the file. + * Function: H5F_get_first_alloc_dealloc * - * Return: Success: Non-negative, the 'first_alloc_dealloc' - * Failure: (can't happen) + * Purpose: Retrieve the 'first alloc / dealloc' value for the file. * + * Return: Success: Non-negative, the 'first_alloc_dealloc' + * Failure: (can't happen) *------------------------------------------------------------------------- */ hbool_t @@ -1359,13 +1163,12 @@ H5F_get_first_alloc_dealloc(const H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_get_eoa_pre_fsm_fsalloc - * - * Purpose: Retrieve the 'EOA pre-FSM fsalloc' value for the file. + * Function: H5F_get_eoa_pre_fsm_fsalloc * - * Return: Success: Non-negative, the 'EOA pre-FSM fsalloc' - * Failure: (can't happen) + * Purpose: Retrieve the 'EOA pre-FSM fsalloc' value for the file. * + * Return: Success: Non-negative, the 'EOA pre-FSM fsalloc' + * Failure: (can't happen) *------------------------------------------------------------------------- */ hbool_t -- cgit v0.12 From 62124efa7e805bf34b54911e142f488a59867dd2 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 8 Nov 2017 11:25:09 -0600 Subject: Remove tabs --- src/H5Pdapl.c | 278 +++++++++++++++++++++----------------------------------- src/H5Ppublic.h | 82 ++++++++--------- 2 files changed, 144 insertions(+), 216 deletions(-) diff --git a/src/H5Pdapl.c b/src/H5Pdapl.c index 3b0a8c5..494de3e 100644 --- a/src/H5Pdapl.c +++ b/src/H5Pdapl.c @@ -13,11 +13,11 @@ /*------------------------------------------------------------------------- * - * Created: H5Pdapl.c + * Created: H5Pdapl.c * October 27, 2008 * Neil Fortner * - * Purpose: Dataset access property list class routines + * Purpose: Dataset access property list class routines * *------------------------------------------------------------------------- */ @@ -32,13 +32,13 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Ppkg.h" /* Property lists */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5private.h" /* Generic Functions */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Ppkg.h" /* Property lists */ +#include "H5MMprivate.h" /* Memory management */ /****************/ @@ -72,8 +72,8 @@ #define H5D_ACS_VDS_PRINTF_GAP_ENC H5P__encode_hsize_t #define H5D_ACS_VDS_PRINTF_GAP_DEC H5P__decode_hsize_t /* Definition for append flush */ -#define H5D_ACS_APPEND_FLUSH_SIZE sizeof(H5D_append_flush_t) -#define H5D_ACS_APPEND_FLUSH_DEF {0,{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},NULL,NULL} +#define H5D_ACS_APPEND_FLUSH_SIZE sizeof(H5D_append_flush_t) +#define H5D_ACS_APPEND_FLUSH_DEF {0,{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},NULL,NULL} /* Definitions for external file prefix */ #define H5D_ACS_EFILE_PREFIX_SIZE sizeof(char *) #define H5D_ACS_EFILE_PREFIX_DEF NULL /*default is no prefix */ @@ -130,21 +130,21 @@ static herr_t H5P__dapl_efile_pref_close(const char* name, size_t size, void* va /* Dataset access property list class library initialization object */ const H5P_libclass_t H5P_CLS_DACC[1] = {{ - "dataset access", /* Class name for debugging */ + "dataset access", /* Class name for debugging */ H5P_TYPE_DATASET_ACCESS, /* Class type */ - &H5P_CLS_LINK_ACCESS_g, /* Parent class */ - &H5P_CLS_DATASET_ACCESS_g, /* Pointer to class */ - &H5P_CLS_DATASET_ACCESS_ID_g, /* Pointer to class ID */ - &H5P_LST_DATASET_ACCESS_ID_g, /* Pointer to default property list ID */ - H5P__dacc_reg_prop, /* Default property registration routine */ - - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ + &H5P_CLS_LINK_ACCESS_g, /* Parent class */ + &H5P_CLS_DATASET_ACCESS_g, /* Pointer to class */ + &H5P_CLS_DATASET_ACCESS_ID_g, /* Pointer to class ID */ + &H5P_LST_DATASET_ACCESS_ID_g, /* Pointer to default property list ID */ + H5P__dacc_reg_prop, /* Default property registration routine */ + + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ }}; @@ -158,8 +158,8 @@ const H5P_libclass_t H5P_CLS_DACC[1] = {{ /*******************/ /* Property value defaults */ -static const H5D_append_flush_t H5D_def_append_flush_g = H5D_ACS_APPEND_FLUSH_DEF; /* Default setting for append flush */ -static const char *H5D_def_efile_prefix_g = H5D_ACS_EFILE_PREFIX_DEF; /* Default external file prefix string */ +static const H5D_append_flush_t H5D_def_append_flush_g = H5D_ACS_APPEND_FLUSH_DEF; /* Default setting for append flush */ +static const char *H5D_def_efile_prefix_g = H5D_ACS_EFILE_PREFIX_DEF; /* Default external file prefix string */ /*------------------------------------------------------------------------- @@ -169,9 +169,6 @@ static const char *H5D_def_efile_prefix_g = H5D_ACS_EFILE_PREFIX_DEF; /* Default * properties * * Return: Non-negative on success/Negative on failure - * - * Programmer: Neil Fortner - * October 27, 2008 *------------------------------------------------------------------------- */ static herr_t @@ -187,17 +184,17 @@ H5P__dacc_reg_prop(H5P_genclass_t *pclass) FUNC_ENTER_STATIC /* Register the size of raw data chunk cache (elements) */ - if(H5P_register_real(pclass, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, H5D_ACS_DATA_CACHE_NUM_SLOTS_SIZE, &rdcc_nslots, + if(H5P_register_real(pclass, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, H5D_ACS_DATA_CACHE_NUM_SLOTS_SIZE, &rdcc_nslots, NULL, NULL, NULL, H5D_ACS_DATA_CACHE_NUM_SLOTS_ENC, H5D_ACS_DATA_CACHE_NUM_SLOTS_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the size of raw data chunk cache(bytes) */ - if(H5P_register_real(pclass, H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME, H5D_ACS_DATA_CACHE_BYTE_SIZE_SIZE, &rdcc_nbytes, + if(H5P_register_real(pclass, H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME, H5D_ACS_DATA_CACHE_BYTE_SIZE_SIZE, &rdcc_nbytes, NULL, NULL, NULL, H5D_ACS_DATA_CACHE_BYTE_SIZE_ENC, H5D_ACS_DATA_CACHE_BYTE_SIZE_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the preemption for reading chunks */ - if(H5P_register_real(pclass, H5D_ACS_PREEMPT_READ_CHUNKS_NAME, H5D_ACS_PREEMPT_READ_CHUNKS_SIZE, &rdcc_w0, + if(H5P_register_real(pclass, H5D_ACS_PREEMPT_READ_CHUNKS_NAME, H5D_ACS_PREEMPT_READ_CHUNKS_SIZE, &rdcc_w0, NULL, NULL, NULL, H5D_ACS_PREEMPT_READ_CHUNKS_ENC, H5D_ACS_PREEMPT_READ_CHUNKS_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") @@ -215,12 +212,12 @@ H5P__dacc_reg_prop(H5P_genclass_t *pclass) /* Register info for append flush */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P_register_real(pclass, H5D_ACS_APPEND_FLUSH_NAME, H5D_ACS_APPEND_FLUSH_SIZE, &H5D_def_append_flush_g, + if(H5P_register_real(pclass, H5D_ACS_APPEND_FLUSH_NAME, H5D_ACS_APPEND_FLUSH_SIZE, &H5D_def_append_flush_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register property for external file prefix */ - if(H5P_register_real(pclass, H5D_ACS_EFILE_PREFIX_NAME, H5D_ACS_EFILE_PREFIX_SIZE, &H5D_def_efile_prefix_g, + if(H5P_register_real(pclass, H5D_ACS_EFILE_PREFIX_NAME, H5D_ACS_EFILE_PREFIX_SIZE, &H5D_def_efile_prefix_g, NULL, H5D_ACS_EFILE_PREFIX_SET, H5D_ACS_EFILE_PREFIX_GET, H5D_ACS_EFILE_PREFIX_ENC, H5D_ACS_EFILE_PREFIX_DEC, H5D_ACS_EFILE_PREFIX_DEL, H5D_ACS_EFILE_PREFIX_COPY, H5D_ACS_EFILE_PREFIX_CMP, H5D_ACS_EFILE_PREFIX_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") @@ -237,7 +234,6 @@ done: * for a property list * * Return: SUCCEED/FAIL - * *------------------------------------------------------------------------- */ static herr_t @@ -263,7 +259,6 @@ H5P__dapl_efile_pref_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED * from a property list * * Return: SUCCEED/FAIL - * *------------------------------------------------------------------------- */ static herr_t @@ -290,7 +285,6 @@ H5P__dapl_efile_pref_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED * encoded. * * Return: SUCCEED/FAIL - * *------------------------------------------------------------------------- */ static herr_t @@ -341,8 +335,7 @@ H5P__dapl_efile_pref_enc(const void *value, void **_pp, size_t *size) * property in the dataset access property list is * decoded. * - * Return: SUCCEED/FAIL - * + * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ static herr_t @@ -393,7 +386,6 @@ done: * Purpose: Frees memory used to store the external file prefix string * * Return: SUCCEED (Can't fail) - * *------------------------------------------------------------------------- */ static herr_t @@ -416,7 +408,6 @@ H5P__dapl_efile_pref_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED * Purpose: Creates a copy of the external file prefix string * * Return: SUCCEED/FAIL - * *------------------------------------------------------------------------- */ static herr_t @@ -440,7 +431,6 @@ H5P__dapl_efile_pref_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED * compared. * * Return: zero if VALUE1 and VALUE2 are equal, non zero otherwise. - * *------------------------------------------------------------------------- */ static int @@ -470,7 +460,6 @@ done: * Purpose: Frees memory used to store the external file prefix string * * Return: SUCCEED/FAIL - * *------------------------------------------------------------------------- */ static herr_t @@ -487,33 +476,27 @@ H5P__dapl_efile_pref_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSE /*------------------------------------------------------------------------- - * Function: H5Pset_chunk_cache - * - * Purpose: Set the number of objects in the meta data cache and the - * maximum number of chunks and bytes in the raw data chunk cache. - * Once set, these values will override the values in the file access - * property list. Each of thhese values can be individually unset - * (or not set at all) by passing the macros: - * H5D_CHUNK_CACHE_NCHUNKS_DEFAULT, - * H5D_CHUNK_CACHE_NSLOTS_DEFAULT, and/or - * H5D_CHUNK_CACHE_W0_DEFAULT - * as appropriate. - * - * The RDCC_W0 value should be between 0 and 1 inclusive and - * indicates how much chunks that have been fully read or fully - * written are favored for preemption. A value of zero means - * fully read or written chunks are treated no differently than - * other chunks (the preemption is strictly LRU) while a value - * of one means fully read chunks are always preempted before - * other chunks. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Neil Fortner - * Monday, October 27, 2008 - * - * Modifications: - * + * Function: H5Pset_chunk_cache + * + * Purpose: Set the number of objects in the meta data cache and the + * maximum number of chunks and bytes in the raw data chunk cache. + * Once set, these values will override the values in the file access + * property list. Each of thhese values can be individually unset + * (or not set at all) by passing the macros: + * H5D_CHUNK_CACHE_NCHUNKS_DEFAULT, + * H5D_CHUNK_CACHE_NSLOTS_DEFAULT, and/or + * H5D_CHUNK_CACHE_W0_DEFAULT + * as appropriate. + * + * The RDCC_W0 value should be between 0 and 1 inclusive and + * indicates how much chunks that have been fully read or fully + * written are favored for preemption. A value of zero means + * fully read or written chunks are treated no differently than + * other chunks (the preemption is strictly LRU) while a value + * of one means fully read chunks are always preempted before + * other chunks. + * + * Return: Non-negative on success/Negative on failure *------------------------------------------------------------------------- */ herr_t @@ -548,23 +531,17 @@ done: /*------------------------------------------------------------------------- - * Function: H5Pget_chunk_cache - * - * Purpose: Retrieves the maximum possible number of elements in the meta - * data cache and the maximum possible number of elements and - * bytes and the RDCC_W0 value in the raw data chunk cache. Any - * (or all) arguments may be null pointers in which case the - * corresponding datum is not returned. If these properties have - * not been set on this property list, the default values for a - * file access property list are returned. - * - * Return: Non-negative on success/Negative on failure + * Function: H5Pget_chunk_cache * - * Programmer: Neil Fortner - * Monday, October 27, 2008 - * - * Modifications: + * Purpose: Retrieves the maximum possible number of elements in the meta + * data cache and the maximum possible number of elements and + * bytes and the RDCC_W0 value in the raw data chunk cache. Any + * (or all) arguments may be null pointers in which case the + * corresponding datum is not returned. If these properties have + * not been set on this property list, the default values for a + * file access property list are returned. * + * Return: Non-negative on success/Negative on failure *------------------------------------------------------------------------- */ herr_t @@ -625,10 +602,6 @@ done: * * Return: Success: Non-negative * Failure: Negative - * - * Programmer: Neil Fortner - * Wednesday, January 23, 2013 - * *------------------------------------------------------------------------- */ static herr_t @@ -684,10 +657,6 @@ H5P__encode_chunk_cache_nslots(const void *value, void **_pp, size_t *size) * * Return: Success: Non-negative * Failure: Negative - * - * Programmer: Neil Fortner - * Wednesday, January 23, 2013 - * *------------------------------------------------------------------------- */ static herr_t @@ -735,10 +704,6 @@ H5P__decode_chunk_cache_nslots(const void **_pp, void *_value) * * Return: Success: Non-negative * Failure: Negative - * - * Programmer: Neil Fortner - * Wednesday, January 23, 2013 - * *------------------------------------------------------------------------- */ static herr_t @@ -794,10 +759,6 @@ H5P__encode_chunk_cache_nbytes(const void *value, void **_pp, size_t *size) * * Return: Success: Non-negative * Failure: Negative - * - * Programmer: Neil Fortner - * Wednesday, January 23, 2013 - * *------------------------------------------------------------------------- */ static herr_t @@ -849,10 +810,6 @@ H5P__decode_chunk_cache_nbytes(const void **_pp, void *_value) * view defines the extent. * * Return: Non-negative on success/Negative on failure - * - * Programmer: Neil Fortner - * May 4, 2015 - * *------------------------------------------------------------------------- */ herr_t @@ -887,13 +844,9 @@ done: * Purpose: Takes the access property list for the virtual dataset, * dapl_id, and gets the flag, view, set by the * H5Pset_virtual_view call. The possible values of view are - * H5D_VDS_FIRST_MISSING or H5D_VDS_LAST_AVAIALBLE. + * H5D_VDS_FIRST_MISSING or H5D_VDS_LAST_AVAIALBLE. * * Return: Non-negative on success/Negative on failure - * - * Programmer: Neil Fortner - * May 4, 2015 - * *------------------------------------------------------------------------- */ herr_t @@ -927,10 +880,6 @@ done: * * Return: Success: Non-negative * Failure: Negative - * - * Programmer: Neil Fortner - * Tuesday, May 5, 2015 - * *------------------------------------------------------------------------- */ static herr_t @@ -964,10 +913,6 @@ H5P__dacc_vds_view_enc(const void *value, void **_pp, size_t *size) * * Return: Success: Non-negative * Failure: Negative - * - * Programmer: Neil Fortner - * Tuesday, May 5, 2015 - * *------------------------------------------------------------------------- */ static herr_t @@ -1011,10 +956,6 @@ H5P__dacc_vds_view_dec(const void **_pp, void *_value) * the VDS fill value setting. * * Return: Non-negative on success/Negative on failure - * - * Programmer: Neil Fortner - * May 21, 2015 - * *------------------------------------------------------------------------- */ herr_t @@ -1053,10 +994,6 @@ done: * value for gap_size is 0. * * Return: Non-negative on success/Negative on failure - * - * Programmer: Neil Fortner - * May 21, 2015 - * *------------------------------------------------------------------------- */ herr_t @@ -1083,30 +1020,27 @@ done: /*------------------------------------------------------------------------- - * Function: H5Pset_append_flush - * - * Purpose: Sets the boundary, callback function, and user data in the - * property list. - * "ndims": number of array elements for boundary - * "boundary": used to determine whether the current dimension hits - * a boundary; if so, invoke the callback function and - * flush the dataset. - * "func": the callback function to invoke when the boundary is hit - * "udata": the user data to pass as parameter with the callback function - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Vailin Choi; Dec 2013 - * + * Function: H5Pset_append_flush + * + * Purpose: Sets the boundary, callback function, and user data in the + * property list. + * "ndims": number of array elements for boundary + * "boundary": used to determine whether the current dimension hits + * a boundary; if so, invoke the callback function and + * flush the dataset. + * "func": the callback function to invoke when the boundary is hit + * "udata": the user data to pass as parameter with the callback function + * + * Return: Non-negative on success/Negative on failure *------------------------------------------------------------------------- */ herr_t H5Pset_append_flush(hid_t plist_id, unsigned ndims, const hsize_t *boundary, H5D_append_cb_t func, void *udata) { - H5P_genplist_t *plist; /* Property list pointer */ - H5D_append_flush_t info; /* Property for append flush parameters */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + H5D_append_flush_t info; /* Property for append flush parameters */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "iIu*hx*x", plist_id, ndims, boundary, func, udata); @@ -1123,7 +1057,7 @@ H5Pset_append_flush(hid_t plist_id, unsigned ndims, const hsize_t *boundary, H5D * This is almost certainly an error as the user data will not be used. */ if(!func && udata) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "callback is NULL while user data is not") - + /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") @@ -1151,18 +1085,15 @@ done: /*------------------------------------------------------------------------- - * Function: H5Pget_append_flush() - * - * Purpose: Retrieves the boundary, callback function and user data set in - * property list. - * Note that the # of boundary sizes to retrieve will not exceed - * the parameter "ndims" and the ndims set previously via - * H5Pset_append_flush(). - * - * Return: Non-negative on success/Negative on failure + * Function: H5Pget_append_flush() * - * Programmer: Vailin Choi; Dec 2013 + * Purpose: Retrieves the boundary, callback function and user data set in + * property list. + * Note that the # of boundary sizes to retrieve will not exceed + * the parameter "ndims" and the ndims set previously via + * H5Pset_append_flush(). * + * Return: Non-negative on success/Negative on failure *------------------------------------------------------------------------- */ herr_t @@ -1170,7 +1101,7 @@ H5Pget_append_flush(hid_t plist_id, unsigned ndims, hsize_t boundary[], H5D_appe { H5P_genplist_t *plist; /* property list pointer */ H5D_append_flush_t info; - unsigned u; /* local index variable */ + unsigned u; /* local index variable */ herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(FAIL) @@ -1186,15 +1117,15 @@ H5Pget_append_flush(hid_t plist_id, unsigned ndims, hsize_t boundary[], H5D_appe /* Assign return values */ if(boundary) { - HDmemset(boundary, 0, ndims * sizeof(hsize_t)); - if(info.ndims > 0) - for(u = 0; u < info.ndims && u < ndims; u++) - boundary[u] = info.boundary[u]; + HDmemset(boundary, 0, ndims * sizeof(hsize_t)); + if(info.ndims > 0) + for(u = 0; u < info.ndims && u < ndims; u++) + boundary[u] = info.boundary[u]; } /* end if */ if(func) - *func = info.func; + *func = info.func; if(udata) - *udata = info.udata; + *udata = info.udata; done: FUNC_LEAVE_API(ret_value) @@ -1215,8 +1146,7 @@ done: * This property can be overwritten by the environment variable * HDF5_EXTFILE_PREFIX. * - * Return: Non-negative on success/Negative on failure - * + * Return: Non-negative on success/Negative on failure *------------------------------------------------------------------------- */ herr_t @@ -1242,24 +1172,22 @@ done: /*------------------------------------------------------------------------- - * Function: H5Pget_efile_prefix - * - * Purpose: Gets the prefix to be used for any external files. - * - * If the pointer is not NULL, it points to a user-allocated - * buffer. + * Function: H5Pget_efile_prefix * - * Return: Non-negative on success/Negative on failure + * Purpose: Gets the prefix to be used for any external files. + * If the pointer is not NULL, it points to a user-allocated + * buffer. * + * Return: Non-negative on success/Negative on failure *------------------------------------------------------------------------- */ ssize_t H5Pget_efile_prefix(hid_t plist_id, char *prefix, size_t size) { H5P_genplist_t *plist; /* Property list pointer */ - char *my_prefix; /* Library's copy of the prefix */ - size_t len; /* Length of prefix string */ - ssize_t ret_value; /* Return value */ + char *my_prefix; /* Library's copy of the prefix */ + size_t len; /* Length of prefix string */ + ssize_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("Zs", "i*sz", plist_id, prefix, size); diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h index 854b1ef..493a322 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -50,43 +50,43 @@ * The library's property list classes */ -#define H5P_ROOT (H5OPEN H5P_CLS_ROOT_ID_g) -#define H5P_OBJECT_CREATE (H5OPEN H5P_CLS_OBJECT_CREATE_ID_g) -#define H5P_FILE_CREATE (H5OPEN H5P_CLS_FILE_CREATE_ID_g) -#define H5P_FILE_ACCESS (H5OPEN H5P_CLS_FILE_ACCESS_ID_g) -#define H5P_DATASET_CREATE (H5OPEN H5P_CLS_DATASET_CREATE_ID_g) -#define H5P_DATASET_ACCESS (H5OPEN H5P_CLS_DATASET_ACCESS_ID_g) -#define H5P_DATASET_XFER (H5OPEN H5P_CLS_DATASET_XFER_ID_g) -#define H5P_FILE_MOUNT (H5OPEN H5P_CLS_FILE_MOUNT_ID_g) -#define H5P_GROUP_CREATE (H5OPEN H5P_CLS_GROUP_CREATE_ID_g) -#define H5P_GROUP_ACCESS (H5OPEN H5P_CLS_GROUP_ACCESS_ID_g) -#define H5P_DATATYPE_CREATE (H5OPEN H5P_CLS_DATATYPE_CREATE_ID_g) -#define H5P_DATATYPE_ACCESS (H5OPEN H5P_CLS_DATATYPE_ACCESS_ID_g) -#define H5P_STRING_CREATE (H5OPEN H5P_CLS_STRING_CREATE_ID_g) -#define H5P_ATTRIBUTE_CREATE (H5OPEN H5P_CLS_ATTRIBUTE_CREATE_ID_g) -#define H5P_ATTRIBUTE_ACCESS (H5OPEN H5P_CLS_ATTRIBUTE_ACCESS_ID_g) -#define H5P_OBJECT_COPY (H5OPEN H5P_CLS_OBJECT_COPY_ID_g) -#define H5P_LINK_CREATE (H5OPEN H5P_CLS_LINK_CREATE_ID_g) -#define H5P_LINK_ACCESS (H5OPEN H5P_CLS_LINK_ACCESS_ID_g) +#define H5P_ROOT (H5OPEN H5P_CLS_ROOT_ID_g) +#define H5P_OBJECT_CREATE (H5OPEN H5P_CLS_OBJECT_CREATE_ID_g) +#define H5P_FILE_CREATE (H5OPEN H5P_CLS_FILE_CREATE_ID_g) +#define H5P_FILE_ACCESS (H5OPEN H5P_CLS_FILE_ACCESS_ID_g) +#define H5P_DATASET_CREATE (H5OPEN H5P_CLS_DATASET_CREATE_ID_g) +#define H5P_DATASET_ACCESS (H5OPEN H5P_CLS_DATASET_ACCESS_ID_g) +#define H5P_DATASET_XFER (H5OPEN H5P_CLS_DATASET_XFER_ID_g) +#define H5P_FILE_MOUNT (H5OPEN H5P_CLS_FILE_MOUNT_ID_g) +#define H5P_GROUP_CREATE (H5OPEN H5P_CLS_GROUP_CREATE_ID_g) +#define H5P_GROUP_ACCESS (H5OPEN H5P_CLS_GROUP_ACCESS_ID_g) +#define H5P_DATATYPE_CREATE (H5OPEN H5P_CLS_DATATYPE_CREATE_ID_g) +#define H5P_DATATYPE_ACCESS (H5OPEN H5P_CLS_DATATYPE_ACCESS_ID_g) +#define H5P_STRING_CREATE (H5OPEN H5P_CLS_STRING_CREATE_ID_g) +#define H5P_ATTRIBUTE_CREATE (H5OPEN H5P_CLS_ATTRIBUTE_CREATE_ID_g) +#define H5P_ATTRIBUTE_ACCESS (H5OPEN H5P_CLS_ATTRIBUTE_ACCESS_ID_g) +#define H5P_OBJECT_COPY (H5OPEN H5P_CLS_OBJECT_COPY_ID_g) +#define H5P_LINK_CREATE (H5OPEN H5P_CLS_LINK_CREATE_ID_g) +#define H5P_LINK_ACCESS (H5OPEN H5P_CLS_LINK_ACCESS_ID_g) /* * The library's default property lists */ -#define H5P_FILE_CREATE_DEFAULT (H5OPEN H5P_LST_FILE_CREATE_ID_g) -#define H5P_FILE_ACCESS_DEFAULT (H5OPEN H5P_LST_FILE_ACCESS_ID_g) -#define H5P_DATASET_CREATE_DEFAULT (H5OPEN H5P_LST_DATASET_CREATE_ID_g) -#define H5P_DATASET_ACCESS_DEFAULT (H5OPEN H5P_LST_DATASET_ACCESS_ID_g) -#define H5P_DATASET_XFER_DEFAULT (H5OPEN H5P_LST_DATASET_XFER_ID_g) -#define H5P_FILE_MOUNT_DEFAULT (H5OPEN H5P_LST_FILE_MOUNT_ID_g) -#define H5P_GROUP_CREATE_DEFAULT (H5OPEN H5P_LST_GROUP_CREATE_ID_g) -#define H5P_GROUP_ACCESS_DEFAULT (H5OPEN H5P_LST_GROUP_ACCESS_ID_g) -#define H5P_DATATYPE_CREATE_DEFAULT (H5OPEN H5P_LST_DATATYPE_CREATE_ID_g) -#define H5P_DATATYPE_ACCESS_DEFAULT (H5OPEN H5P_LST_DATATYPE_ACCESS_ID_g) -#define H5P_ATTRIBUTE_CREATE_DEFAULT (H5OPEN H5P_LST_ATTRIBUTE_CREATE_ID_g) -#define H5P_ATTRIBUTE_ACCESS_DEFAULT (H5OPEN H5P_LST_ATTRIBUTE_ACCESS_ID_g) -#define H5P_OBJECT_COPY_DEFAULT (H5OPEN H5P_LST_OBJECT_COPY_ID_g) -#define H5P_LINK_CREATE_DEFAULT (H5OPEN H5P_LST_LINK_CREATE_ID_g) -#define H5P_LINK_ACCESS_DEFAULT (H5OPEN H5P_LST_LINK_ACCESS_ID_g) +#define H5P_FILE_CREATE_DEFAULT (H5OPEN H5P_LST_FILE_CREATE_ID_g) +#define H5P_FILE_ACCESS_DEFAULT (H5OPEN H5P_LST_FILE_ACCESS_ID_g) +#define H5P_DATASET_CREATE_DEFAULT (H5OPEN H5P_LST_DATASET_CREATE_ID_g) +#define H5P_DATASET_ACCESS_DEFAULT (H5OPEN H5P_LST_DATASET_ACCESS_ID_g) +#define H5P_DATASET_XFER_DEFAULT (H5OPEN H5P_LST_DATASET_XFER_ID_g) +#define H5P_FILE_MOUNT_DEFAULT (H5OPEN H5P_LST_FILE_MOUNT_ID_g) +#define H5P_GROUP_CREATE_DEFAULT (H5OPEN H5P_LST_GROUP_CREATE_ID_g) +#define H5P_GROUP_ACCESS_DEFAULT (H5OPEN H5P_LST_GROUP_ACCESS_ID_g) +#define H5P_DATATYPE_CREATE_DEFAULT (H5OPEN H5P_LST_DATATYPE_CREATE_ID_g) +#define H5P_DATATYPE_ACCESS_DEFAULT (H5OPEN H5P_LST_DATATYPE_ACCESS_ID_g) +#define H5P_ATTRIBUTE_CREATE_DEFAULT (H5OPEN H5P_LST_ATTRIBUTE_CREATE_ID_g) +#define H5P_ATTRIBUTE_ACCESS_DEFAULT (H5OPEN H5P_LST_ATTRIBUTE_ACCESS_ID_g) +#define H5P_OBJECT_COPY_DEFAULT (H5OPEN H5P_LST_OBJECT_COPY_ID_g) +#define H5P_LINK_CREATE_DEFAULT (H5OPEN H5P_LST_LINK_CREATE_ID_g) +#define H5P_LINK_ACCESS_DEFAULT (H5OPEN H5P_LST_LINK_ACCESS_ID_g) /* Common creation order flags (for links in groups and attributes on objects) */ #define H5P_CRT_ORDER_TRACKED 0x0001 @@ -140,9 +140,9 @@ typedef enum H5D_mpio_actual_chunk_opt_mode_t { typedef enum H5D_mpio_actual_io_mode_t { /* The following four values are conveniently defined as a bit field so that * we can switch from the default to indpendent or collective and then to - * mixed without having to check the original value. - * - * NO_COLLECTIVE means that either collective I/O wasn't requested or that + * mixed without having to check the original value. + * + * NO_COLLECTIVE means that either collective I/O wasn't requested or that * no I/O took place. * * CHUNK_INDEPENDENT means that collective I/O was requested, but the @@ -155,7 +155,7 @@ typedef enum H5D_mpio_actual_io_mode_t { /* The contiguous case is separate from the bit field. */ H5D_MPIO_CONTIGUOUS_COLLECTIVE = 0x4 -} H5D_mpio_actual_io_mode_t; +} H5D_mpio_actual_io_mode_t; /* Broken collective IO property */ typedef enum H5D_mpio_no_collective_cause_t { @@ -326,7 +326,7 @@ H5_DLL herr_t H5Pget_cache(hid_t plist_id, H5_DLL herr_t H5Pset_mdc_config(hid_t plist_id, H5AC_cache_config_t * config_ptr); H5_DLL herr_t H5Pget_mdc_config(hid_t plist_id, - H5AC_cache_config_t * config_ptr); /* out */ + H5AC_cache_config_t * config_ptr); /* out */ H5_DLL herr_t H5Pset_gc_references(hid_t fapl_id, unsigned gc_ref); H5_DLL herr_t H5Pget_gc_references(hid_t fapl_id, unsigned *gc_ref/*out*/); H5_DLL herr_t H5Pset_fclose_degree(hid_t fapl_id, H5F_close_degree_t degree); @@ -402,12 +402,12 @@ H5_DLL herr_t H5Pget_fill_value(hid_t plist_id, hid_t type_id, void *value/*out*/); H5_DLL herr_t H5Pfill_value_defined(hid_t plist, H5D_fill_value_t *status); H5_DLL herr_t H5Pset_alloc_time(hid_t plist_id, H5D_alloc_time_t - alloc_time); + alloc_time); H5_DLL herr_t H5Pget_alloc_time(hid_t plist_id, H5D_alloc_time_t - *alloc_time/*out*/); + *alloc_time/*out*/); H5_DLL herr_t H5Pset_fill_time(hid_t plist_id, H5D_fill_time_t fill_time); H5_DLL herr_t H5Pget_fill_time(hid_t plist_id, H5D_fill_time_t - *fill_time/*out*/); + *fill_time/*out*/); /* Dataset access property list (DAPL) routines */ H5_DLL herr_t H5Pset_chunk_cache(hid_t dapl_id, size_t rdcc_nslots, -- cgit v0.12 From 00ade113c5fe7d48571a36091970328dcca68f50 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 8 Nov 2017 17:52:44 -0800 Subject: Plugin test rework Cleanup of plugin test code. Renames many files. Prep for VOL branch merge. --- MANIFEST | 12 +- configure.ac | 8 +- test/CMakeLists.txt | 92 +-- test/CMakeTests.cmake | 12 +- test/Makefile.am | 49 +- test/dynlib1.c | 95 --- test/dynlib2.c | 92 --- test/dynlib3.c | 103 --- test/dynlib4.c | 102 --- test/filter_plugin.c | 1511 +++++++++++++++++++++++++++++++++++++++ test/filter_plugin1_dsets.c | 93 +++ test/filter_plugin2_dsets.c | 88 +++ test/filter_plugin3_dsets.c | 119 +++ test/filter_plugin4_groups.c | 106 +++ test/plugin.c | 1217 ------------------------------- test/test_filter_plugin.sh.in | 113 +++ test/test_plugin.sh.in | 113 --- tools/test/h5diff/Makefile.am | 3 - tools/test/h5dump/Makefile.am | 3 - tools/test/h5ls/Makefile.am | 3 - tools/test/h5repack/Makefile.am | 5 - 21 files changed, 2111 insertions(+), 1828 deletions(-) delete mode 100644 test/dynlib1.c delete mode 100644 test/dynlib2.c delete mode 100644 test/dynlib3.c delete mode 100644 test/dynlib4.c create mode 100644 test/filter_plugin.c create mode 100644 test/filter_plugin1_dsets.c create mode 100644 test/filter_plugin2_dsets.c create mode 100644 test/filter_plugin3_dsets.c create mode 100644 test/filter_plugin4_groups.c delete mode 100644 test/plugin.c create mode 100644 test/test_filter_plugin.sh.in delete mode 100644 test/test_plugin.sh.in diff --git a/MANIFEST b/MANIFEST index 4270479..230bf1f 100644 --- a/MANIFEST +++ b/MANIFEST @@ -936,10 +936,6 @@ ./test/dt_arith.c ./test/dtypes.c ./test/dtransform.c -./test/dynlib1.c -./test/dynlib2.c -./test/dynlib3.c -./test/dynlib4.c ./test/earray.c ./test/efc.c ./test/enc_dec_plist.c @@ -967,6 +963,11 @@ ./test/fill_old.h5 ./test/fillval.c ./test/filter_fail.c +./test/filter_plugin.c +./test/filter_plugin1_dsets.c +./test/filter_plugin2_dsets.c +./test/filter_plugin3_dsets.c +./test/filter_plugin4_groups.c ./test/flush1.c ./test/flush2.c ./test/flushrefresh.c @@ -1030,7 +1031,6 @@ ./test/page_buffer.c ./test/paged_nopersist.h5 ./test/paged_persist.h5 -./test/plugin.c ./test/reserved.c ./test/pool.c ./test/set_extent.c @@ -1065,12 +1065,12 @@ ./test/testerror.sh.in ./test/testlinks_env.sh.in ./test/test_filenotclosed.sh.in +./test/test_filter_plugin.sh.in ./test/testflushrefresh.sh.in ./test/testframe.c ./test/testhdf5.c ./test/testhdf5.h ./test/testlibinfo.sh.in -./test/test_plugin.sh.in ./test/test_usecases.sh.in ./test/testmeta.c ./test/testswmr.sh.in diff --git a/configure.ac b/configure.ac index 3dbd95c..d8f3873 100644 --- a/configure.ac +++ b/configure.ac @@ -3369,17 +3369,17 @@ AC_CONFIG_FILES([src/libhdf5.settings Makefile src/Makefile test/Makefile + test/H5srcdir_str.h test/testcheck_version.sh test/testerror.sh test/testflushrefresh.sh - test/H5srcdir_str.h test/testlibinfo.sh test/testlinks_env.sh - test/test_filenotclosed.sh test/testswmr.sh - test/test_plugin.sh - test/test_usecases.sh test/testvdsswmr.sh + test/test_filenotclosed.sh + test/test_filter_plugin.sh + test/test_usecases.sh testpar/Makefile tools/Makefile tools/lib/Makefile diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8522c1d..0a2afbf 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -70,73 +70,73 @@ if (BUILD_SHARED_LIBS) endif () #----------------------------------------------------------------------------- -# If plugin library tests can be tested +# If filter plugin tests can be tested #----------------------------------------------------------------------------- # make plugins dir - file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/testdir1") - file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/testdir2") + file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/filter_plugin_dir1") + file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/filter_plugin_dir2") #----------------------------------------------------------------------------- - # Define Plugin Test Sources + # Define Filter Plugin Test Sources #----------------------------------------------------------------------------- - set (TEST_PLUGIN_LIBS - dynlib1 - dynlib3 + set (FILTER_PLUGINS_FOR_DIR1 + filter_plugin1_dsets + filter_plugin3_dsets ) - set (TEST2_PLUGIN_LIBS - dynlib2 - dynlib4 + set (FILTER_PLUGINS_FOR_DIR2 + filter_plugin2_dsets + filter_plugin4_groups ) - foreach (test_lib ${TEST_PLUGIN_LIBS}) - set (HDF5_TEST_PLUGIN_LIB_CORENAME "${test_lib}") - set (HDF5_TEST_PLUGIN_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_TEST_PLUGIN_LIB_CORENAME}") - set (HDF5_TEST_PLUGIN_LIB_TARGET ${HDF5_TEST_PLUGIN_LIB_CORENAME}) + foreach (plugin_name ${FILTER_PLUGINS_FOR_DIR1}) + set (HDF5_TEST_PLUGIN_CORENAME "${plugin_name}") + set (HDF5_TEST_PLUGIN_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_TEST_PLUGIN_CORENAME}") + set (HDF5_TEST_PLUGIN_TARGET ${HDF5_TEST_PLUGIN_CORENAME}) add_definitions (${HDF_EXTRA_C_FLAGS}) INCLUDE_DIRECTORIES (${HDF5_SRC_DIR}) - add_library (${HDF5_TEST_PLUGIN_LIB_TARGET} SHARED ${HDF5_TEST_SOURCE_DIR}/${test_lib}.c) - TARGET_C_PROPERTIES (${HDF5_TEST_PLUGIN_LIB_TARGET} SHARED " " " ") - target_link_libraries (${HDF5_TEST_PLUGIN_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) - H5_SET_LIB_OPTIONS (${HDF5_TEST_PLUGIN_LIB_TARGET} ${HDF5_TEST_PLUGIN_LIB_NAME} SHARED ${HDF5_PACKAGE_SOVERSION}) - set_target_properties (${HDF5_TEST_PLUGIN_LIB_TARGET} PROPERTIES FOLDER libraries/TEST_PLUGIN) + add_library (${HDF5_TEST_PLUGIN_TARGET} SHARED ${HDF5_TEST_SOURCE_DIR}/${plugin_name}.c) + TARGET_C_PROPERTIES (${HDF5_TEST_PLUGIN_TARGET} SHARED " " " ") + target_link_libraries (${HDF5_TEST_PLUGIN_TARGET} ${HDF5_TEST_LIB_TARGET}) + H5_SET_LIB_OPTIONS (${HDF5_TEST_PLUGIN_TARGET} ${HDF5_TEST_PLUGIN_NAME} SHARED ${HDF5_PACKAGE_SOVERSION}) + set_target_properties (${HDF5_TEST_PLUGIN_TARGET} PROPERTIES FOLDER libraries/TEST_PLUGIN) #----------------------------------------------------------------------------- - # Copy plugin library to a plugins folder + # Copy the filter plugin to a plugins folder #----------------------------------------------------------------------------- add_custom_command ( - TARGET ${HDF5_TEST_PLUGIN_LIB_TARGET} + TARGET ${HDF5_TEST_PLUGIN_TARGET} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different - "$" - "${CMAKE_BINARY_DIR}/testdir1/$" + "$" + "${CMAKE_BINARY_DIR}/filter_plugin_dir1/$" ) endforeach () - foreach (test_lib ${TEST2_PLUGIN_LIBS}) - set (HDF5_TEST_PLUGIN_LIB_CORENAME "${test_lib}") - set (HDF5_TEST_PLUGIN_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_TEST_PLUGIN_LIB_CORENAME}") - set (HDF5_TEST_PLUGIN_LIB_TARGET ${HDF5_TEST_PLUGIN_LIB_CORENAME}) + foreach ( plugin_name ${FILTER_PLUGINS_FOR_DIR2}) + set (HDF5_TEST_PLUGIN_CORENAME "${plugin_name}") + set (HDF5_TEST_PLUGIN_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_TEST_PLUGIN_CORENAME}") + set (HDF5_TEST_PLUGIN_TARGET ${HDF5_TEST_PLUGIN_CORENAME}) add_definitions (${HDF_EXTRA_C_FLAGS}) INCLUDE_DIRECTORIES (${HDF5_SRC_DIR}) - add_library (${HDF5_TEST_PLUGIN_LIB_TARGET} SHARED ${HDF5_TEST_SOURCE_DIR}/${test_lib}.c) - TARGET_C_PROPERTIES (${HDF5_TEST_PLUGIN_LIB_TARGET} SHARED " " " ") - target_link_libraries (${HDF5_TEST_PLUGIN_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) - H5_SET_LIB_OPTIONS (${HDF5_TEST_PLUGIN_LIB_TARGET} ${HDF5_TEST_PLUGIN_LIB_NAME} SHARED ${HDF5_PACKAGE_SOVERSION}) - set_target_properties (${HDF5_TEST_PLUGIN_LIB_TARGET} PROPERTIES FOLDER libraries/TEST_PLUGIN) + add_library (${HDF5_TEST_PLUGIN_TARGET} SHARED ${HDF5_TEST_SOURCE_DIR}/${plugin_name}.c) + TARGET_C_PROPERTIES (${HDF5_TEST_PLUGIN_TARGET} SHARED " " " ") + target_link_libraries (${HDF5_TEST_PLUGIN_TARGET} ${HDF5_TEST_LIB_TARGET}) + H5_SET_LIB_OPTIONS (${HDF5_TEST_PLUGIN_TARGET} ${HDF5_TEST_PLUGIN_NAME} SHARED ${HDF5_PACKAGE_SOVERSION}) + set_target_properties (${HDF5_TEST_PLUGIN_TARGET} PROPERTIES FOLDER libraries/TEST_PLUGIN) #----------------------------------------------------------------------------- - # Copy plugin library to a plugins folder + # Copy the filter plugin to a plugins folder #----------------------------------------------------------------------------- add_custom_command ( - TARGET ${HDF5_TEST_PLUGIN_LIB_TARGET} + TARGET ${HDF5_TEST_PLUGIN_TARGET} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different - "$" - "${CMAKE_BINARY_DIR}/testdir2/$" + "$" + "${CMAKE_BINARY_DIR}/filter_plugin_dir2/$" ) endforeach () @@ -411,17 +411,17 @@ endif () ### P L U G I N T E S T S ############################################################################## if (BUILD_SHARED_LIBS) - add_executable (plugin ${HDF5_TEST_SOURCE_DIR}/plugin.c) - TARGET_NAMING (plugin SHARED) - TARGET_C_PROPERTIES (plugin SHARED " " " ") - target_link_libraries (plugin ${HDF5_TEST_LIB_TARGET}) - set_target_properties (plugin PROPERTIES FOLDER test) + add_executable (filter_plugin ${HDF5_TEST_SOURCE_DIR}/filter_plugin.c) + TARGET_NAMING (filter_plugin SHARED) + TARGET_C_PROPERTIES (filter_plugin SHARED " " " ") + target_link_libraries (filter_plugin ${HDF5_TEST_LIB_TARGET}) + set_target_properties (filter_plugin PROPERTIES FOLDER test) else () - add_executable (plugin ${HDF5_TEST_SOURCE_DIR}/plugin.c) - TARGET_NAMING (plugin STATIC) - TARGET_C_PROPERTIES (plugin STATIC " " " ") - target_link_libraries (plugin ${HDF5_TEST_LIB_TARGET}) - set_target_properties (plugin PROPERTIES FOLDER test) + add_executable (filter_plugin ${HDF5_TEST_SOURCE_DIR}/filter_plugin.c) + TARGET_NAMING (filter_plugin STATIC) + TARGET_C_PROPERTIES (filter_plugin STATIC " " " ") + target_link_libraries (filter_plugin ${HDF5_TEST_LIB_TARGET}) + set_target_properties (filter_plugin PROPERTIES FOLDER test) endif () ############################################################################## diff --git a/test/CMakeTests.cmake b/test/CMakeTests.cmake index 61ac3d2..973d389 100644 --- a/test/CMakeTests.cmake +++ b/test/CMakeTests.cmake @@ -1,4 +1,4 @@ -# + # Copyright by The HDF Group. # All rights reserved. # @@ -520,7 +520,7 @@ set (test_CLEANFILES multi_file-r.h5 multi_file-s.h5 core_file - plugin.h5 + filter_plugin.h5 new_move_a.h5 new_move_b.h5 ntypes.h5 @@ -1013,7 +1013,7 @@ if (BUILD_SHARED_LIBS) endif () ############################################################################## -### P L U G I N T E S T S +### F I L T E R P L U G I N T E S T S ############################################################################## if (WIN32) set (CMAKE_SEP "\;") @@ -1023,9 +1023,9 @@ else () set (BIN_REL_PATH "../") endif () -add_test (NAME H5PLUGIN-plugin COMMAND $) -set_tests_properties (H5PLUGIN-plugin PROPERTIES - ENVIRONMENT "HDF5_PLUGIN_PATH=${CMAKE_BINARY_DIR}/testdir1${CMAKE_SEP}${CMAKE_BINARY_DIR}/testdir2;srcdir=${HDF5_TEST_BINARY_DIR}" +add_test (NAME H5PLUGIN-filter_plugin COMMAND $) +set_tests_properties (H5PLUGIN-filter_plugin PROPERTIES + ENVIRONMENT "HDF5_PLUGIN_PATH=${CMAKE_BINARY_DIR}/filter_plugin_dir1${CMAKE_SEP}${CMAKE_BINARY_DIR}/filter_plugin_dir2;srcdir=${HDF5_TEST_BINARY_DIR}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR} ) diff --git a/test/Makefile.am b/test/Makefile.am index ba2d79b..4f192ac 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -26,11 +26,12 @@ AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_builddir)/src # testlibinfo.sh: # testcheck_version.sh: tcheck_version # testlinks_env.sh: links_env -# test_filenotclosed.sh: filenotclosed.c # testflushrefresh.sh: flushrefresh -# test_usecases.sh: use_append_chunk, use_append_mchunks, use_disable_mdc_flushes # testswmr.sh: swmr* # testvdsswmr.sh: vds_swmr* +# test_filenotclosed.sh: filenotclosed.c +# test_filter_plugin.sh: filter_plugin.c +# test_usecases.sh: use_append_chunk, use_append_mchunks, use_disable_mdc_flushes TEST_SCRIPT = testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh test_filenotclosed.sh\ testswmr.sh testvdsswmr.sh testflushrefresh.sh test_usecases.sh SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT) links_env$(EXEEXT) test_filenotclosed$(EXEEXT) \ @@ -40,8 +41,8 @@ SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT) links_env$(EXEEXT) test_ swmr_sparse_reader$(EXEEXT) swmr_sparse_writer$(EXEEXT) swmr_start_write$(EXEEXT) \ vds_swmr_gen$(EXEEXT) vds_swmr_reader$(EXEEXT) vds_swmr_writer$(EXEEXT) if HAVE_SHARED_CONDITIONAL - TEST_SCRIPT += test_plugin.sh - SCRIPT_DEPEND += plugin$(EXEEXT) + TEST_SCRIPT += test_filter_plugin.sh + SCRIPT_DEPEND += filter_plugin$(EXEEXT) endif check_SCRIPTS = $(TEST_SCRIPT) @@ -81,7 +82,7 @@ check_PROGRAMS=$(TEST_PROG) error_test err_compat tcheck_version \ swmr_remove_writer swmr_addrem_writer swmr_sparse_reader swmr_sparse_writer \ swmr_check_compat_vfd vds_swmr_gen vds_swmr_reader vds_swmr_writer if HAVE_SHARED_CONDITIONAL - check_PROGRAMS+= plugin + check_PROGRAMS+= filter_plugin endif # These programs generate test files for the tests. They don't need to be @@ -102,29 +103,17 @@ endif if HAVE_SHARED_CONDITIONAL # The libh5test library provides common support code for the tests. - # The libdynlib1, libdynlib2, libdynlib3, and libdynlib4 library for testing plugin module plugin.c. - # Build them as shared libraries if configure is enabled for shared library. - noinst_LTLIBRARIES=libh5test.la libdynlib1.la libdynlib2.la libdynlib3.la libdynlib4.la - libdynlib1_la_SOURCES=dynlib1.c - libdynlib2_la_SOURCES=dynlib2.c - libdynlib3_la_SOURCES=dynlib3.c - libdynlib4_la_SOURCES=dynlib4.c - libdynlib1_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere - libdynlib2_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere - libdynlib3_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere - libdynlib4_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere - - libdynlib1.la: $(libdynlib1_la_OBJECTS) $(libdynlib1_la_DEPENDENCIES) $(EXTRA_libdynlib1_la_DEPENDENCIES) - $(AM_V_CCLD)$(libdynlib1_la_LINK) $(am_libdynlib1_la_rpath) $(libdynlib1_la_OBJECTS) $(libdynlib1_la_LIBADD) - - libdynlib2.la: $(libdynlib2_la_OBJECTS) $(libdynlib2_la_DEPENDENCIES) $(EXTRA_libdynlib2_la_DEPENDENCIES) - $(AM_V_CCLD)$(libdynlib2_la_LINK) $(am_libdynlib2_la_rpath) $(libdynlib2_la_OBJECTS) $(libdynlib2_la_LIBADD) - - libdynlib3.la: $(libdynlib3_la_OBJECTS) $(libdynlib3_la_DEPENDENCIES) $(EXTRA_libdynlib3_la_DEPENDENCIES) - $(AM_V_CCLD)$(libdynlib3_la_LINK) $(am_libdynlib3_la_rpath) $(libdynlib3_la_OBJECTS) $(libdynlib3_la_LIBADD) - - libdynlib4.la: $(libdynlib4_la_OBJECTS) $(libdynlib4_la_DEPENDENCIES) $(EXTRA_libdynlib4_la_DEPENDENCIES) - $(AM_V_CCLD)$(libdynlib4_la_LINK) $(am_libdynlib4_la_rpath) $(libdynlib4_la_OBJECTS) $(libdynlib4_la_LIBADD) + # The filter_plugin* libraries are for use in filter_plugin.c. + # Build them as shared libraries if that option was enabled in configure. + noinst_LTLIBRARIES=libh5test.la libfilter_plugin1_dsets.la libfilter_plugin2_dsets.la libfilter_plugin3_dsets.la libfilter_plugin4_groups.la + libfilter_plugin1_dsets_la_SOURCES=filter_plugin1_dsets.c + libfilter_plugin2_dsets_la_SOURCES=filter_plugin2_dsets.c + libfilter_plugin3_dsets_la_SOURCES=filter_plugin3_dsets.c + libfilter_plugin4_groups_la_SOURCES=filter_plugin4_groups.c + libfilter_plugin1_dsets_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere + libfilter_plugin2_dsets_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere + libfilter_plugin3_dsets_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere + libfilter_plugin4_groups_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere else # The libh5test library provides common support code for the tests. noinst_LTLIBRARIES=libh5test.la @@ -185,7 +174,7 @@ CHECK_CLEANFILES+=accum.h5 cmpd_dset.h5 compact_dataset.h5 dataset.h5 dset_offse tmisc[0-9]*.h5 set_extent[1-5].h5 ext[12].bin \ getname.h5 getname[1-3].h5 sec2_file.h5 direct_file.h5 \ family_file000[0-3][0-9].h5 new_family_v16_000[0-3][0-9].h5 \ - multi_file-[rs].h5 core_file plugin.h5 \ + multi_file-[rs].h5 core_file filter_plugin.h5 \ new_move_[ab].h5 ntypes.h5 dangle.h5 error_test.h5 err_compat.h5 \ dtransform.h5 test_filters.h5 get_file_name.h5 tstint[1-2].h5 \ unlink_chunked.h5 btree2.h5 btree2_tmp.h5 objcopy_src.h5 objcopy_dst.h5 \ @@ -215,7 +204,7 @@ use_append_mchunks_SOURCES=use_append_mchunks.c use_common.c use_disable_mdc_flushes_SOURCES=use_disable_mdc_flushes.c # Temporary files. -DISTCLEANFILES=testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh test_plugin.sh \ +DISTCLEANFILES=testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh test_filter_plugin.sh \ testswmr.sh testvdsswmr.sh test_usecases.sh testflushrefresh.sh test_filenotclosed.sh include $(top_srcdir)/config/conclude.am diff --git a/test/dynlib1.c b/test/dynlib1.c deleted file mode 100644 index e9137fb..0000000 --- a/test/dynlib1.c +++ /dev/null @@ -1,95 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* - * Programmer: Raymond Lu - * 13 February 2013 - * - * Purpose: Tests the plugin module (H5PL) - */ - -#include -#include -#include "H5PLextern.h" - -#define H5Z_FILTER_DYNLIB1 257 - -static size_t H5Z_filter_dynlib1(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); - -/* This message derives from H5Z */ -const H5Z_class2_t H5Z_DYNLIB1[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - H5Z_FILTER_DYNLIB1, /* Filter id number */ - 1, 1, /* Encoding and decoding enabled */ - "dynlib1", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - (H5Z_func_t)H5Z_filter_dynlib1, /* The actual filter function */ -}}; - -H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} -const void *H5PLget_plugin_info(void) {return H5Z_DYNLIB1;} - -/*------------------------------------------------------------------------- - * Function: H5Z_filter_dynlib1 - * - * Purpose: A dynlib1 filter method that adds on and subtract from - * the original value with another value. It will be built - * as a shared library. plugin.c test will load and use - * this filter library. - * - * Return: Success: Data chunk size - * - * Failure: 0 - * - * Programmer: Raymond Lu - * 29 March 2013 - * - *------------------------------------------------------------------------- - */ -static size_t -H5Z_filter_dynlib1(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, - size_t *buf_size, void **buf) -{ - int *int_ptr = (int *)*buf; /* Pointer to the data values */ - size_t buf_left = *buf_size; /* Amount of data buffer left to process */ - int add_on = 0; - - /* Check for the correct number of parameters */ - if(cd_nelmts == 0) - return(0); - - /* Check that permanent parameters are set correctly */ - if(cd_values[0] > 9) - return(0); - - add_on = (int)cd_values[0]; - - if(flags & H5Z_FLAG_REVERSE) { /*read*/ - /* Substract the "add on" value to all the data values */ - while(buf_left > 0) { - *int_ptr++ -= add_on; - buf_left -= sizeof(int); - } /* end while */ - } /* end if */ - else { /*write*/ - /* Add the "add on" value to all the data values */ - while(buf_left > 0) { - *int_ptr++ += add_on; - buf_left -= sizeof(int); - } /* end while */ - } /* end else */ - - return nbytes; -} /* end H5Z_filter_dynlib1() */ - diff --git a/test/dynlib2.c b/test/dynlib2.c deleted file mode 100644 index 2574d4d..0000000 --- a/test/dynlib2.c +++ /dev/null @@ -1,92 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* - * Programmer: Raymond Lu - * 13 February 2013 - * - * Purpose: Tests the plugin module (H5PL) - */ - -#include -#include -#include "H5PLextern.h" - -#define H5Z_FILTER_DYNLIB2 258 -#define MULTIPLIER 3 - -static size_t H5Z_filter_dynlib2(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); - -/* This message derives from H5Z */ -const H5Z_class2_t H5Z_DYNLIB2[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - H5Z_FILTER_DYNLIB2, /* Filter id number */ - 1, 1, /* Encoding and decoding enabled */ - "dynlib2", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - (H5Z_func_t)H5Z_filter_dynlib2, /* The actual filter function */ -}}; - -H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} -const void *H5PLget_plugin_info(void) {return H5Z_DYNLIB2;} - -/*------------------------------------------------------------------------- - * Function: H5Z_filter_dynlib2 - * - * Purpose: A dynlib2 filter method that multiplies the original value - * during write and divide the original value during read. It - * will be built as a shared library. plugin.c test will load - * and use this filter library. - * - * Return: Success: Data chunk size - * - * Failure: 0 - * - * Programmer: Raymond Lu - * 29 March 2013 - * - *------------------------------------------------------------------------- - */ -static size_t -H5Z_filter_dynlib2(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, - size_t *buf_size, void **buf) -{ - int *int_ptr = (int *)*buf; /* Pointer to the data values */ - size_t buf_left = *buf_size; /* Amount of data buffer left to process */ - - /* Check for the correct number of parameters */ - if(cd_nelmts > 0) - return(0); - - /* Assignment to eliminate unused parameter warning. */ - cd_values = cd_values; - - if(flags & H5Z_FLAG_REVERSE) { /*read*/ - /* Divide the original value with MULTIPLIER */ - while(buf_left > 0) { - *int_ptr++ /= MULTIPLIER; - buf_left -= sizeof(int); - } /* end while */ - } /* end if */ - else { /*write*/ - /* Multiply the original value with MULTIPLIER */ - while(buf_left > 0) { - *int_ptr++ *= MULTIPLIER; - buf_left -= sizeof(int); - } /* end while */ - } /* end else */ - - return nbytes; -} /* end H5Z_filter_dynlib2() */ - diff --git a/test/dynlib3.c b/test/dynlib3.c deleted file mode 100644 index 8871321..0000000 --- a/test/dynlib3.c +++ /dev/null @@ -1,103 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* - * Programmer: Raymond Lu - * 1 April 2013 - * - * Purpose: Tests the plugin module (H5PL) - */ - -#include -#include -#include -#include "H5PLextern.h" - -#define H5Z_FILTER_DYNLIB3 259 -#define SUFFIX_LEN 8 -#define GROUP_SUFFIX ".h5group" - -static size_t H5Z_filter_dynlib3(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); - -/* This message derives from H5Z */ -const H5Z_class2_t H5Z_DYNLIB3[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - H5Z_FILTER_DYNLIB3, /* Filter id number */ - 1, 1, /* Encoding and decoding enabled */ - "dynlib3", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - (H5Z_func_t)H5Z_filter_dynlib3, /* The actual filter function */ -}}; - -H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} -const void *H5PLget_plugin_info(void) {return H5Z_DYNLIB3;} - -/*------------------------------------------------------------------------- - * Function: H5Z_filter_dynlib3 - * - * Purpose: A dynlib3 filter method that is used to test groups. It - * appends the suffix ".h5group" to each group name during - * write and takes it out during read. - * - * Return: Success: Data chunk size - * - * Failure: 0 - * - * Programmer: Raymond Lu - * 1 April 2013 - * - *------------------------------------------------------------------------- - */ -static size_t -H5Z_filter_dynlib3(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, - size_t *buf_size, void **buf) -{ - size_t ret_value; /* Return value */ - - /* Check for the correct number of parameters */ - if(cd_nelmts > 0) - return(0); - - /* Assignment to eliminate unused parameter warning. */ - cd_values = cd_values; - - if(flags & H5Z_FLAG_REVERSE) { /*read*/ - ret_value = *buf_size = nbytes - SUFFIX_LEN; - } /* end if */ - else { /*write*/ - void *outbuf = NULL; /* Pointer to new buffer */ - unsigned char *dst; /* Temporary pointer to destination buffer */ - - dst = (unsigned char *)(outbuf = H5allocate_memory(nbytes + SUFFIX_LEN, 0)); - - /* Copy raw data */ - memcpy((void*)dst, (void*)(*buf), nbytes); - - /* Append suffix to raw data for storage */ - dst += nbytes; - memcpy(dst, (void*)GROUP_SUFFIX, SUFFIX_LEN); - - /* Free input buffer */ - H5free_memory(*buf); - - /* Set return values */ - *buf_size = nbytes + SUFFIX_LEN; - *buf = outbuf; - outbuf = NULL; - ret_value = *buf_size; - } /* end else */ - - return ret_value; -} /* H5Z_filter_dynlib3() */ - diff --git a/test/dynlib4.c b/test/dynlib4.c deleted file mode 100644 index 06d90ff..0000000 --- a/test/dynlib4.c +++ /dev/null @@ -1,102 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* - * Purpose: Tests the plugin module (H5PL) - */ - -#include -#include -#include "H5PLextern.h" - -#define H5Z_FILTER_DYNLIB4 260 - -#define PUSH_ERR(func, minor, str) H5Epush2(H5E_DEFAULT, __FILE__, func, __LINE__, H5E_ERR_CLS, H5E_PLUGIN, minor, str) - -static size_t H5Z_filter_dynlib4(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); - -/* This message derives from H5Z */ -const H5Z_class2_t H5Z_DYNLIB4[1] = {{ - H5Z_CLASS_T_VERS, /* H5Z_class_t version */ - H5Z_FILTER_DYNLIB4, /* Filter id number */ - 1, 1, /* Encoding and decoding enabled */ - "dynlib4", /* Filter name for debugging */ - NULL, /* The "can apply" callback */ - NULL, /* The "set local" callback */ - (H5Z_func_t)H5Z_filter_dynlib4, /* The actual filter function */ -}}; - -H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} -const void *H5PLget_plugin_info(void) {return H5Z_DYNLIB4;} - -/*------------------------------------------------------------------------- - * Function: H5Z_filter_dynlib4 - * - * Purpose: A dynlib4 filter method that adds on and subtract from - * the original value with another value. It will be built - * as a shared library. plugin.c test will load and use - * this filter library. Designed to call a HDF function. - * - * Return: Success: Data chunk size - * - * Failure: 0 - * - *------------------------------------------------------------------------- - */ -static size_t -H5Z_filter_dynlib4(unsigned int flags, size_t cd_nelmts, - const unsigned int *cd_values, size_t nbytes, - size_t *buf_size, void **buf) -{ - int *int_ptr = (int *)*buf; /* Pointer to the data values */ - size_t buf_left = *buf_size; /* Amount of data buffer left to process */ - int add_on = 0; - unsigned ver_info[3]; - - /* Check for the library version */ - if(H5get_libversion(&ver_info[0], &ver_info[1], &ver_info[2]) < 0) { - PUSH_ERR("dynlib4", H5E_CALLBACK, "H5get_libversion"); - return(0); - } - /* Check for the correct number of parameters */ - if(cd_nelmts == 0) - return(0); - - /* Check that permanent parameters are set correctly */ - if(cd_values[0] > 9) - return(0); - - if(ver_info[0] != cd_values[1] || ver_info[1] != cd_values[2]) { - PUSH_ERR("dynlib4", H5E_CALLBACK, "H5get_libversion does not match"); - return(0); - } - - add_on = (int)cd_values[0]; - - if(flags & H5Z_FLAG_REVERSE) { /*read*/ - /* Substract the "add on" value to all the data values */ - while(buf_left > 0) { - *int_ptr++ -= add_on; - buf_left -= sizeof(int); - } /* end while */ - } /* end if */ - else { /*write*/ - /* Add the "add on" value to all the data values */ - while(buf_left > 0) { - *int_ptr++ += add_on; - buf_left -= sizeof(int); - } /* end while */ - } /* end else */ - - return nbytes; -} /* end H5Z_filter_dynlib4() */ - diff --git a/test/filter_plugin.c b/test/filter_plugin.c new file mode 100644 index 0000000..8b7e0e4 --- /dev/null +++ b/test/filter_plugin.c @@ -0,0 +1,1511 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* + * Purpose: Tests the plugin module (H5PL) + */ + +#include "h5test.h" +#include "H5srcdir.h" + +/* + * This file needs to access private datatypes from the H5Z and H5PL package. + */ +#define H5PL_FRIEND +#include "H5PLpkg.h" +#define H5Z_FRIEND +#include "H5Zpkg.h" + +/* Filters IDs for test filter plugins */ +#define FILTER1_ID 257 +#define FILTER2_ID 258 +#define FILTER3_ID 259 +#define FILTER4_ID 260 + +const char *FILENAME[] = { + "filter_plugin", + NULL +}; +#define FILENAME_BUF_SIZE 1024 + +/* Dataset names */ +#define DSET_DEFLATE_NAME "deflate dset" +#define DSET_FILTER1_NAME "filter 1 dset" +#define DSET_FILTER2_NAME "filter 2 dset" +#define DSET_FILTER3_NAME "filter 3 dset" + +/* Array sizes used throughout the test */ +#define DSET_DIM1 100 +#define DSET_DIM2 200 +#define CHUNK_DIM1 2 +#define CHUNK_DIM2 25 +#define HYPERSLAB_OFFSET1 7 +#define HYPERSLAB_OFFSET2 30 +#define HYPERSLAB_SIZE1 4 +#define HYPERSLAB_SIZE2 50 + +/* Global size arrays */ +const hsize_t sizes_g[2] = {DSET_DIM1, DSET_DIM2}; /* Dataset dimensions */ +const hsize_t hs_sizes_g[2] = {HYPERSLAB_SIZE1, HYPERSLAB_SIZE2}; /* Hyperslab sizes */ +const hsize_t hs_offsets_g[2] = {HYPERSLAB_OFFSET1, HYPERSLAB_OFFSET2}; /* Hyperslab offsets */ +const hsize_t chunk_sizes_g[2] = {CHUNK_DIM1, CHUNK_DIM2}; /* Chunk dimensions */ + +/* Limit random number within 20000 */ +#define RANDOM_LIMIT 20000 + +/* Things used in the groups + filter plugins test */ +#define N_SUBGROUPS 1000 +#define SUBGROUP_PREFIX "subgroup_" +#define TOP_LEVEL_GROUP_NAME "top-level group" + +/* Global arrays in which to save data */ +int **orig_deflate_g = NULL; +int **orig_dynlib1_g = NULL; +int **orig_dynlib2_g = NULL; +int **orig_dynlib4_g = NULL; + + + +/*------------------------------------------------------------------------- + * Function: free_2D_array + * + * Purpose: Free up a dynamic 2D pseudo array and set the pointer to NULL + * Designed to be callable in error conditions so NULLs are okay + * + * Return: SUCCEED (always) + * + *------------------------------------------------------------------------- + */ +static herr_t +free_2D_array(int ***arr) { + + if (arr && *arr && (*arr)[0]) + HDfree((*arr)[0]); + if (arr && *arr) + HDfree(*arr); + *arr = NULL; + + return SUCCEED; +} /* end free_2D_array() */ + + +/*------------------------------------------------------------------------- + * Function: allocate_and_init_2D_array + * + * Purpose: Initialize an array as a pseudo 2D array and copy in some + * initial values. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +allocate_and_init_2D_array(int ***arr, const hsize_t *sizes, int **initial_values) { + + size_t r, c; /* Data rows and columns */ + size_t i; /* Iterator */ + size_t n_bytes; /* # of bytes to copy */ + + r = (size_t)sizes[0]; + c = (size_t)sizes[1]; + + /* Allocate and set up pseudo-2D array */ + if (NULL == (*arr = (int **)HDcalloc(r, sizeof(int *)))) + TEST_ERROR; + if (NULL == ((*arr)[0] = (int *)HDcalloc(r * c, sizeof(int)))) + TEST_ERROR; + for (i = 0; i < r; i++) + (*arr)[i] = (**arr + c * i); + + /* Copy over the data elements */ + if (initial_values) { + n_bytes = r * c * sizeof(int); + HDmemcpy((*arr)[0], initial_values[0], n_bytes); + } + + return SUCCEED; +error: + free_2D_array(arr); + + return FAIL; +} /* end allocate_and_init_2D_array() */ + + +/*------------------------------------------------------------------------- + * Function: compare_2D_arrays + * + * Purpose: Compare two pseudo 2D arrays + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +compare_2D_arrays(int **dset1, int **dset2, const hsize_t *sizes, /*OUT*/ hbool_t *are_same) { + hsize_t i, j; /* index variables */ + + *are_same = TRUE; + + /* Check all the array values. This could optionally emit any + * bad data, but it's not clear how that would help debugging. + */ + for (i = 0; i < sizes[0]; i++) + for (j = 0; j < sizes[1]; j++) + if (dset1[i][j] != dset2[i][j]) { + *are_same = FALSE; + return SUCCEED; + } + + return SUCCEED; + +} /* end compare_2D_arrays() */ + + +/*------------------------------------------------------------------------- + * Function: ensure_filter_works + * + * Purpose: Tests writing entire data and partial data with filters + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +ensure_filter_works(hid_t fid, const char *name, hid_t dcpl_id) +{ + hid_t did = -1; /* Dataset ID */ + hid_t dxpl_id = -1; /* Dataset xfer property list ID */ + hid_t write_dxpl_id = -1; /* Dataset xfer property list ID for writing */ + hid_t sid = -1; /* Dataspace ID */ + void *tconv_buf = NULL; /* Temporary conversion buffer */ + int **orig = NULL; /* Data written to the dataset */ + int **read = NULL; /* Data read from the dataset */ + size_t r, c; /* Data rows and columns */ + size_t hs_r, hs_c, hs_offr, hs_offc; /* Hypserslab sizes and offsets */ + size_t i, j; /* Local index variables */ + int n = 0; /* Value written to point array */ + hbool_t are_same; /* Output from dataset compare function */ + int ***save_array = NULL; /* (Global) array where the final data go */ + + /* initialize */ + r = (size_t)sizes_g[0]; + c = (size_t)sizes_g[1]; + + /* Create the data space */ + if ((sid = H5Screate_simple(2, sizes_g, NULL)) < 0) + TEST_ERROR; + + /* Allocate memory for the data buffers + * We're using the hacky way of doing 2D arrays that uses a + * single data buffer but which allows normal 2D access. + */ + if (allocate_and_init_2D_array(&orig, sizes_g, NULL) < 0) + TEST_ERROR; + if (allocate_and_init_2D_array(&read, sizes_g, NULL) < 0) + TEST_ERROR; + + /* Create a small conversion buffer to test strip mining. We + * might as well test all we can! + */ + if ((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) + TEST_ERROR; + if (NULL == (tconv_buf = HDcalloc((size_t)1000, sizeof(char)))) + TEST_ERROR; + if (H5Pset_buffer(dxpl_id, (size_t)1000, tconv_buf, NULL) < 0) + TEST_ERROR; + if ((write_dxpl_id = H5Pcopy(dxpl_id)) < 0) + TEST_ERROR; + + TESTING(" filters (setup)"); + + /* Check if all the filters are available */ + if (H5Pall_filters_avail(dcpl_id) != TRUE) + TEST_ERROR; + + /* Create the dataset */ + if ((did = H5Dcreate2(fid, name, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) + TEST_ERROR; + + PASSED(); + + /*---------------------------------------------------------------------- + * STEP 1: Read uninitialized data. It should be zero. + *---------------------------------------------------------------------- + */ + TESTING(" filters (uninitialized read)"); + + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id, *read) < 0) + TEST_ERROR; + + /* The input buffer was calloc'd and has not been initialized yet */ + if (compare_2D_arrays(orig, read, sizes_g, &are_same) < 0) + TEST_ERROR; + if (FALSE == are_same) + TEST_ERROR; + + PASSED(); + + /*---------------------------------------------------------------------- + * STEP 2: Test filters by setting up a chunked dataset and writing + * to it. + *---------------------------------------------------------------------- + */ + TESTING(" filters (write)"); + + n = 0; + for (i = 0; i < r; i++) + for (j = 0; j < c; j++) + orig[i][j] = n++; + + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl_id, *orig) < 0) + TEST_ERROR; + + PASSED(); + + /*---------------------------------------------------------------------- + * STEP 3: Try to read the data we just wrote. + *---------------------------------------------------------------------- + */ + TESTING(" filters (read)"); + + /* Read the dataset back */ + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id, *read) < 0) + TEST_ERROR; + + /* Check that the values read are the same as the values written */ + if (compare_2D_arrays(orig, read, sizes_g, &are_same) < 0) + TEST_ERROR; + if (FALSE == are_same) + TEST_ERROR; + + PASSED(); + + /*---------------------------------------------------------------------- + * STEP 4: Write new data over the top of the old data. The new data is + * random thus not very compressible, and will cause the chunks to move + * around as they grow. We only change values for the left half of the + * dataset although we rewrite the whole thing. + *---------------------------------------------------------------------- + */ + TESTING(" filters (modify)"); + + for (i = 0; i < r; i++) + for (j = 0; j < c / 2; j++) + orig[i][j] = (int)HDrandom() % RANDOM_LIMIT; + + if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl_id, *orig) < 0) + TEST_ERROR; + + /* Read the dataset back and check it */ + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id, *read) < 0) + TEST_ERROR; + + /* Check that the values read are the same as the values written */ + if (compare_2D_arrays(orig, read, sizes_g, &are_same) < 0) + TEST_ERROR; + if (FALSE == are_same) + TEST_ERROR; + + PASSED(); + + /*---------------------------------------------------------------------- + * STEP 5: Close the dataset and then open it and read it again. This + * insures that the filters message is picked up properly from the + * object header. + *---------------------------------------------------------------------- + */ + TESTING(" filters (re-open)"); + + if (H5Dclose(did) < 0) + TEST_ERROR; + if ((did = H5Dopen2(fid, name, H5P_DEFAULT)) < 0) + TEST_ERROR; + + if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id, *read) < 0) + TEST_ERROR; + + /* Check that the values read are the same as the values written */ + if (compare_2D_arrays(orig, read, sizes_g, &are_same) < 0) + TEST_ERROR; + if (FALSE == are_same) + TEST_ERROR; + + PASSED(); + + /*---------------------------------------------------------------------- + * STEP 6: Test partial I/O by writing to and then reading from a + * hyperslab of the dataset. The hyperslab does not line up on chunk + * boundaries (we know that case already works from above tests). + *---------------------------------------------------------------------- + */ + TESTING(" filters (partial I/O)"); + + hs_r = (size_t)hs_sizes_g[0]; + hs_c = (size_t)hs_sizes_g[1]; + hs_offr = (size_t)hs_offsets_g[0]; + hs_offc = (size_t)hs_offsets_g[1]; + for (i = 0; i < hs_r; i++) + for (j = 0; j < hs_c; j++) + orig[hs_offr + i][hs_offc + j] = (int)HDrandom() % RANDOM_LIMIT; + + if (H5Sselect_hyperslab(sid, H5S_SELECT_SET, hs_offsets_g, NULL, hs_sizes_g, NULL) < 0) + TEST_ERROR; + + /* Use the "read" DXPL because partial I/O on corrupted data test + * needs to ignore errors during writing + */ + if (H5Dwrite(did, H5T_NATIVE_INT, sid, sid, dxpl_id, *orig) < 0) + TEST_ERROR; + + if (H5Dread(did, H5T_NATIVE_INT, sid, sid, dxpl_id, *read) < 0) + TEST_ERROR; + + /* Check that the values read are the same as the values written */ + if (compare_2D_arrays(orig, read, sizes_g, &are_same) < 0) + TEST_ERROR; + if (FALSE == are_same) + TEST_ERROR; + + PASSED(); + + /* Save the data written to the file for later comparison when the file + * is reopened for read test. + */ + if (!HDstrcmp(name, DSET_DEFLATE_NAME)) + save_array = &orig_deflate_g; + else if (!HDstrcmp(name, DSET_FILTER1_NAME)) + save_array = &orig_dynlib1_g; + else if (!HDstrcmp(name, DSET_FILTER2_NAME)) + save_array = &orig_dynlib2_g; + else if (!HDstrcmp(name, DSET_FILTER3_NAME)) + save_array = &orig_dynlib4_g; + else + TEST_ERROR; + if (allocate_and_init_2D_array(save_array, sizes_g, orig) < 0) + TEST_ERROR; + + /* Clean up and exit */ + if (H5Dclose(did) < 0) + TEST_ERROR; + if (H5Sclose(sid) < 0) + TEST_ERROR; + if (H5Pclose(dxpl_id) < 0) + TEST_ERROR; + if (H5Pclose(write_dxpl_id) < 0) + TEST_ERROR; + + free_2D_array(&orig); + free_2D_array(&read); + + HDfree(tconv_buf); + + return SUCCEED; + +error: + /* Clean up objects used for this test */ + H5E_BEGIN_TRY { + H5Dclose(did); + H5Sclose(sid); + H5Pclose(dxpl_id); + H5Pclose(write_dxpl_id); + } H5E_END_TRY + + /* NULLs are okay here */ + free_2D_array(&orig); + free_2D_array(&read); + + if (tconv_buf) + HDfree(tconv_buf); + + return FAIL; +} /* end ensure_filter_works() */ + + +/*------------------------------------------------------------------------- + * Function: test_dataset_write_with_filters + * + * Purpose: Tests creating datasets and writing data with dynamically loaded filters + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +test_dataset_write_with_filters(hid_t fid) +{ + hid_t dcpl_id = -1; /* Dataset creation property list ID */ + unsigned int compress_level; /* Deflate compression level */ + unsigned int filter1_data; /* Data used by filter 1 */ + unsigned int libver_values[4]; /* Used w/ the filter that makes HDF5 calls */ + + /*---------------------------------------------------------- + * STEP 1: Test deflation by itself. + *---------------------------------------------------------- + */ + HDputs("Testing dataset writes with deflate filter"); +#ifdef H5_HAVE_FILTER_DEFLATE + if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR; + if (H5Pset_chunk(dcpl_id, 2, chunk_sizes_g) < 0) + TEST_ERROR; + compress_level = 6; + if (H5Pset_deflate(dcpl_id, compress_level) < 0) + TEST_ERROR; + + /* Ensure the filter works */ + if (ensure_filter_works(fid, DSET_DEFLATE_NAME, dcpl_id) < 0) + TEST_ERROR; + + /* Clean up objects used for this test */ + if (H5Pclose(dcpl_id) < 0) + TEST_ERROR; +#else /* H5_HAVE_FILTER_DEFLATE */ + SKIPPED(); + HDputs(" Deflate filter not enabled"); +#endif /* H5_HAVE_FILTER_DEFLATE */ + + /*---------------------------------------------------------- + * STEP 2: Test filter plugin 1 by itself. + *---------------------------------------------------------- + */ + HDputs(" dataset writes with filter plugin 1"); + if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR; + if (H5Pset_chunk(dcpl_id, 2, chunk_sizes_g) < 0) + TEST_ERROR; + + /* Set up the filter, passing in the amount the filter will add and subtract + * from each data element. Note that this value has an arbitrary max of 9. + */ + filter1_data = 9; + if (H5Pset_filter(dcpl_id, FILTER1_ID, H5Z_FLAG_MANDATORY, (size_t)1, &filter1_data) < 0) + TEST_ERROR; + + /* Ensure the filter works */ + if (ensure_filter_works(fid, DSET_FILTER1_NAME, dcpl_id) < 0) + TEST_ERROR; + + /* Clean up objects used for this test */ + if (H5Pclose(dcpl_id) < 0) + TEST_ERROR; + + /* Unregister the dynamic filter for testing purpose. The next time when this test is run for + * the new file format, the library's H5PL code has to search in the table of loaded plugin libraries + * for this filter. + */ + if (H5Zunregister(FILTER1_ID) < 0) + TEST_ERROR; + + /*---------------------------------------------------------- + * STEP 3: Test filter plugin 2 by itself. + *---------------------------------------------------------- + */ + HDputs(" dataset writes with filter plugin 2"); + if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR; + if (H5Pset_chunk(dcpl_id, 2, chunk_sizes_g) < 0) + TEST_ERROR; + if (H5Pset_filter(dcpl_id, FILTER2_ID, H5Z_FLAG_MANDATORY, 0, NULL) < 0) + TEST_ERROR; + + /* Ensure the filter works */ + if (ensure_filter_works(fid, DSET_FILTER2_NAME, dcpl_id) < 0) + TEST_ERROR; + + /* Clean up objects used for this test */ + if (H5Pclose(dcpl_id) < 0) + TEST_ERROR; + + /* Unregister the dynamic filter for testing purpose. The next time when this test is run for + * the new file format, the library's H5PL code has to search in the table of loaded plugin libraries + * for this filter. + */ + if (H5Zunregister(FILTER2_ID) < 0) + TEST_ERROR; + + /*---------------------------------------------------------- + * STEP 4: Test filter plugin 3 by itself. + * (This filter plugin makes HDF5 API calls) + *---------------------------------------------------------- + */ + HDputs(" dataset writes with filter plugin 3"); + if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR; + if (H5Pset_chunk(dcpl_id, 2, chunk_sizes_g) < 0) + TEST_ERROR; + + /* Set the add/subtract value for the filter */ + libver_values[0] = 9; + + /* Get the library bounds and add to the filter data */ + if (H5get_libversion(&libver_values[1], &libver_values[2], &libver_values[3]) < 0) + TEST_ERROR; + if (H5Pset_filter(dcpl_id, FILTER3_ID, H5Z_FLAG_MANDATORY, (size_t)4, libver_values) < 0) + TEST_ERROR; + + /* Ensure the filter works */ + if (ensure_filter_works(fid, DSET_FILTER3_NAME, dcpl_id) < 0) + TEST_ERROR; + + /* Clean up objects used for this test */ + if (H5Pclose(dcpl_id) < 0) + TEST_ERROR; + + /* Unregister the dynamic filter for testing purpose. The next time when this test is run for + * the new file format, the library's H5PL code has to search in the table of loaded plugin libraries + * for this filter. + */ + if (H5Zunregister(FILTER3_ID) < 0) + TEST_ERROR; + + return SUCCEED; + +error: + /* Clean up objects used for this test */ + H5E_BEGIN_TRY { + H5Pclose(dcpl_id); + } H5E_END_TRY + + return FAIL; +} /* end test_dataset_write_with_filters() */ + + +/*------------------------------------------------------------------------- + * Function: test_read_data + * + * Purpose: Tests reading data and compares values + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +test_read_data(hid_t did, int *origin_data) +{ + int **check = NULL; + int *data_p = origin_data; + size_t i, j; /* Local index variables */ + + if (allocate_and_init_2D_array(&check, sizes_g, NULL) < 0) + TEST_ERROR; + + /* Read the dataset back */ + if (H5Dread(did, 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 */ + for(i = 0; i < sizes_g[0]; i++) + for(j = 0; j < sizes_g[1]; j++) { + if(*data_p != check[i][j]) + TEST_ERROR + data_p++; + } + + free_2D_array(&check); + + PASSED(); + + return SUCCEED; + +error: + free_2D_array(&check); + + return FAIL; +} /* end test_read_data() */ + + + +/*------------------------------------------------------------------------- + * Function: test_dataset_read_with_filters + * + * Purpose: Tests reading datasets created with dynamically-loaded + * filter plugins. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +test_dataset_read_with_filters(hid_t fid) +{ + hid_t did = -1; /* Dataset ID */ + + /*---------------------------------------------------------- + * STEP 1: Test deflation by itself. + *---------------------------------------------------------- + */ + TESTING("dataset read I/O with deflate filter"); + +#ifdef H5_HAVE_FILTER_DEFLATE + if (H5Zfilter_avail(H5Z_FILTER_DEFLATE) != TRUE) + TEST_ERROR; + + if ((did = H5Dopen2(fid, DSET_DEFLATE_NAME, H5P_DEFAULT)) < 0) + TEST_ERROR; + + if (test_read_data(did, orig_deflate_g[0]) < 0) + TEST_ERROR; + + if (H5Dclose(did) < 0) + TEST_ERROR; + +#else /* H5_HAVE_FILTER_DEFLATE */ + SKIPPED(); + HDputs(" Deflate filter not enabled"); +#endif /* H5_HAVE_FILTER_DEFLATE */ + + /*---------------------------------------------------------- + * STEP 2: Test filter plugin 1 by itself. + *---------------------------------------------------------- + */ + TESTING(" dataset reads with filter plugin 1"); + + if ((did = H5Dopen2(fid, DSET_FILTER1_NAME, H5P_DEFAULT)) < 0) + TEST_ERROR; + + if (test_read_data(did, orig_dynlib1_g[0]) < 0) + TEST_ERROR; + + if (H5Dclose(did) < 0) + TEST_ERROR; + + /*---------------------------------------------------------- + * STEP 3: Test filter plugin 2 by itself. + *---------------------------------------------------------- + */ + TESTING(" dataset reads with filter plugin 2"); + + if ((did = H5Dopen2(fid, DSET_FILTER2_NAME, H5P_DEFAULT)) < 0) + TEST_ERROR; + + if (test_read_data(did, orig_dynlib2_g[0]) < 0) + TEST_ERROR; + + if (H5Dclose(did) < 0) + TEST_ERROR; + + /*---------------------------------------------------------- + * STEP 4: Test filter plugin 3 by itself. + *---------------------------------------------------------- + */ + TESTING(" dataset reads with filter plugin 3"); + + if ((did = H5Dopen2(fid, DSET_FILTER3_NAME, H5P_DEFAULT)) < 0) + TEST_ERROR; + + if (test_read_data(did, orig_dynlib4_g[0]) < 0) + TEST_ERROR; + + if (H5Dclose(did) < 0) + TEST_ERROR; + + return SUCCEED; + +error: + /* Clean up objects used for this test */ + H5E_BEGIN_TRY { + H5Dclose(did); + } H5E_END_TRY + + return FAIL; +} /* end test_dataset_read_with_filters() */ + + +/*------------------------------------------------------------------------- + * Function: ensure_data_read_fails + * + * Purpose: Tests not reading data + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +ensure_data_read_fails(hid_t did) +{ + int **check = NULL; + herr_t ret = FAIL; + + if (allocate_and_init_2D_array(&check, sizes_g, NULL) < 0) + TEST_ERROR; + + /* Read the dataset back (should fail) */ + H5E_BEGIN_TRY { + ret = H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, *check); + } H5E_END_TRY + if(ret >= 0) + TEST_ERROR; + + free_2D_array(&check); + + PASSED(); + + return SUCCEED; + +error: + free_2D_array(&check); + return FAIL; +} /* end ensure_data_read_fails() */ + + +/*------------------------------------------------------------------------- + * Function: test_no_read_when_plugins_disabled + * + * Purpose: Ensures we can't read data from a dataset that requires a + * filter located in a plugin. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +test_no_read_when_plugins_disabled(hid_t fid) +{ + hid_t did = -1; /* Dataset ID */ + unsigned plugin_flags; /* Plugin access flags */ + + TESTING("filter plugin 1 with filter plugins disabled"); + + /* Get the existing plugin flags */ + if (H5PLget_loading_state(&plugin_flags) < 0) + TEST_ERROR; + + /* Disable filter plugins and use the new flags */ + plugin_flags &= (unsigned)(~H5PL_FILTER_PLUGIN); + if (H5PLset_loading_state(plugin_flags) < 0) + TEST_ERROR; + + /* Open a dataset that requires a filter plugin to read the data */ + if ((did = H5Dopen2(fid, DSET_FILTER1_NAME, H5P_DEFAULT)) < 0) + TEST_ERROR; + + /* Make sure we can't read the data */ + if (ensure_data_read_fails(did) < 0) + TEST_ERROR; + + /* Close down */ + if (H5Dclose(did) < 0) + TEST_ERROR; + + /* Re-enable filter plugins */ + plugin_flags |= (unsigned)H5PL_FILTER_PLUGIN; + if (H5PLset_loading_state(plugin_flags) < 0) + TEST_ERROR; + + return SUCCEED; + +error: + /* Clean up objects used for this test */ + H5E_BEGIN_TRY { + plugin_flags |= (unsigned)H5PL_FILTER_PLUGIN; + H5PLset_loading_state(plugin_flags); + H5Dclose(did); + } H5E_END_TRY + + return FAIL; +} /* end test_no_read_when_plugins_disabled() */ + + +/*------------------------------------------------------------------------- + * Function: test_creating_groups_using_plugins + * + * Purpose: Tests creating group with dynamically loaded filters + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +test_creating_groups_using_plugins(hid_t fid) +{ + hid_t gcpl_id = -1; + hid_t gid = -1; + hid_t sub_gid = -1; + int i; + char subgroup_name[256]; + + TESTING("creating groups with filter plugin 4"); + + if ((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0) + TEST_ERROR; + + /* Use a filter plugin for creating groups */ + if (H5Pset_filter(gcpl_id, FILTER4_ID, H5Z_FLAG_MANDATORY, (size_t)0, NULL) < 0) + TEST_ERROR; + + /* Create a group using this filter */ + if ((gid = H5Gcreate2(fid, TOP_LEVEL_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) + TEST_ERROR; + + /* Create multiple groups under the top-level group */ + for (i = 0; i < N_SUBGROUPS; i++) { + char *sp = subgroup_name; + + sp += HDsprintf(subgroup_name, SUBGROUP_PREFIX); + HDsprintf(sp, "%d", i); + + if ((sub_gid = H5Gcreate2(gid, subgroup_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; + if (H5Gclose(sub_gid) < 0) + TEST_ERROR; + } + + /* Close everything */ + if (H5Gclose(gid) < 0) + TEST_ERROR; + if (H5Pclose(gcpl_id) < 0) + TEST_ERROR; + + PASSED(); + + return SUCCEED; + +error: + /* Clean up objects used for this test */ + H5E_BEGIN_TRY { + H5Gclose(sub_gid); + H5Gclose(gid); + H5Pclose(gcpl_id); + } H5E_END_TRY + + return FAIL; +} /* end test_creating_groups_using_plugins() */ + + +/*------------------------------------------------------------------------- + * Function: test_opening_groups_using_plugins + * + * Purpose: Tests opening group with dynamically loaded filters + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +test_opening_groups_using_plugins(hid_t fid) +{ + hid_t gid = -1; + hid_t sub_gid = -1; + int i; + char subgroup_name[256]; + + TESTING("opening groups with filter plugin 4"); + + /* Open the top group */ + if ((gid = H5Gopen2(fid, TOP_LEVEL_GROUP_NAME, H5P_DEFAULT)) < 0) + TEST_ERROR; + + /* Open all the sub-groups under the top-level group */ + for (i = 0; i < N_SUBGROUPS; i++) { + char *sp = subgroup_name; + + sp += HDsprintf(subgroup_name, SUBGROUP_PREFIX); + HDsprintf(sp, "%d", i); + + if ((sub_gid = H5Gopen2(gid, subgroup_name, H5P_DEFAULT)) < 0) + TEST_ERROR; + if (H5Gclose(sub_gid) < 0) + TEST_ERROR; + } + + /* Close the top-level group */ + if (H5Gclose(gid) < 0) + TEST_ERROR; + + PASSED(); + + return SUCCEED; + +error: + /* Clean up objects used for this test */ + H5E_BEGIN_TRY { + H5Gclose(gid); + H5Gclose(sub_gid); + } H5E_END_TRY + + return FAIL; +} /* end test_opening_groups_using_plugins() */ + + + +/*------------------------------------------------------------------------- + * Function: test_path_api_calls + * + * Purpose: Tests the H5PL API calls that manipulate the plugin search + * paths. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +test_path_api_calls(void) +{ + unsigned int n_starting_paths; + unsigned int u; + unsigned int n_paths; + herr_t ret; + ssize_t path_len = -1; + char path[256]; + char temp_name[256]; + + HDputs("Testing access to the filter path table"); + + if (H5Zfilter_avail(FILTER1_ID) != TRUE) + TEST_ERROR; + + /* Set the number of paths to create for this test. + * + * This should be set high enough to ensure that at least one array + * expansion will take place. See H5PLpath.c for details. + */ + n_starting_paths = 42; + + /* Check that initialization is correct */ + TESTING(" initialize"); + + if (H5PLsize(&n_paths) < 0) + TEST_ERROR; + if (n_paths != 2) + TEST_ERROR; + + PASSED(); + + /****************/ + /* H5PLremove() */ + /****************/ + + /* Remove all the current paths */ + TESTING(" remove"); + + /* Get the current size */ + if (H5PLsize(&n_paths) < 0) + TEST_ERROR; + + /* Remove all existing paths */ + for (u = n_paths; u > 0; u--) + if (H5PLremove(u-1) < 0) { + HDfprintf(stderr," at %u: %s\n", u, path); + TEST_ERROR; + } + + /* Verify the table is empty */ + if (H5PLsize(&n_paths) < 0) + TEST_ERROR; + if (n_paths > 0) + TEST_ERROR; + + PASSED(); + + + TESTING(" remove (index 0 in empty table)"); + + /* Try to remove index zero in an empty list (SHOULD FAIL) */ + H5E_BEGIN_TRY { + ret = H5PLremove(0); + } H5E_END_TRY + if (ret >= 0) + TEST_ERROR; + + PASSED(); + + + /****************/ + /* H5PLappend() */ + /****************/ + + TESTING(" append"); + + /* Add a bunch of paths to the path table */ + for (u = 0; u < n_starting_paths; u++) { + HDsprintf(path, "a_path_%u", u); + if (H5PLappend(path) < 0) { + HDfprintf(stderr," at %u: %s\n", u, path); + TEST_ERROR; + } + } + + PASSED(); + + + /**********************/ + /* H5PLremove() again */ + /**********************/ + + TESTING(" remove (index too high)"); + + /* Try to remove a path where the index is beyond the table capacity (SHOULD FAIL) */ + H5E_BEGIN_TRY { + ret = H5PLremove(n_starting_paths); + } H5E_END_TRY + + if (ret >= 0) + TEST_ERROR + + PASSED(); + + + /*************/ + /* H5PLget() */ + /*************/ + + TESTING(" get (path name)"); + + /* Get the path length by passing in NULL */ + if ((path_len = H5PLget(0, NULL, 0)) <= 0) { + HDfprintf(stderr," get path 0 length failed\n"); + TEST_ERROR; + } + if (path_len != 8) + TEST_ERROR; + + /* Get the path */ + if ((path_len = H5PLget(0, path, 256)) <= 0) { + HDfprintf(stderr," get 0 len: %u : %s\n", path_len, path); + TEST_ERROR; + } + if (HDstrcmp(path, "a_path_0") != 0) { + HDfprintf(stderr," get 0: %s\n", path); + TEST_ERROR; + } + + PASSED(); + + + TESTING(" get (high and low indices)"); + + /* Get path at index 1 */ + if ((path_len = H5PLget(1, path, 256)) <= 0) + TEST_ERROR; + if (HDstrcmp(path, "a_path_1") != 0) { + HDfprintf(stderr," get 1: %s\n", path); + TEST_ERROR; + } + + /* Get path at the last index */ + if ((path_len = H5PLget(n_starting_paths - 1, path, 256)) <= 0) + TEST_ERROR; + HDsprintf(temp_name, "a_path_%u", n_starting_paths - 1); + if (HDstrcmp(path, temp_name) != 0) { + HDfprintf(stderr," get %u: %s\n", n_starting_paths - 1, path); + TEST_ERROR; + } + + PASSED(); + + + TESTING(" get (index too high)"); + + /* Get path at the last + 1 index (SHOULD FAIL) */ + H5E_BEGIN_TRY { + path_len = H5PLget(n_starting_paths, NULL, 0); + } H5E_END_TRY + if (path_len > 0) + TEST_ERROR; + + PASSED(); + + + /*****************/ + /* H5PLprepend() */ + /*****************/ + + /* We'll remove a path at an arbitrary index and then + * prepend a new path. + */ + + TESTING(" remove (arbitrary index 1)"); + + /* Remove one path */ + if (H5PLremove(8) < 0) + TEST_ERROR; + + /* Verify that the entries were moved */ + if ((path_len = H5PLget(8, path, 256)) <= 0) + TEST_ERROR; + if (HDstrcmp(path, "a_path_9") != 0) { + HDfprintf(stderr," get 8: %s\n", path); + TEST_ERROR; + } + + /* Verify the table shrank */ + if (H5PLsize(&n_paths) < 0) + TEST_ERROR; + if (n_paths != n_starting_paths - 1) + TEST_ERROR; + + PASSED(); + + + TESTING(" prepend"); + + /* Prepend one path */ + HDsprintf(path, "a_path_%d", n_starting_paths + 1); + if (H5PLprepend(path) < 0) { + HDfprintf(stderr," prepend %u: %s\n", n_starting_paths + 1, path); + TEST_ERROR; + } + + /* Verify the table increased */ + if (H5PLsize(&n_paths) < 0) + TEST_ERROR; + if (n_paths != n_starting_paths) + TEST_ERROR; + + /* Verify that the entries were moved */ + if (H5PLget(8, path, 256) <= 0) + TEST_ERROR; + if (HDstrcmp(path, "a_path_7") != 0) { + HDfprintf(stderr," get 8: %s\n", path); + TEST_ERROR; + } + + /* Verify that the path was inserted at index zero */ + if (H5PLget(0, path, 256) <= 0) + TEST_ERROR; + HDsprintf(temp_name, "a_path_%d", n_starting_paths + 1); + if (HDstrcmp(path, temp_name) != 0) { + HDfprintf(stderr," get 0: %s\n", path); + TEST_ERROR; + } + + PASSED(); + + + /*****************/ + /* H5PLreplace() */ + /*****************/ + + TESTING(" replace"); + + /* Replace one path at index 1 */ + HDsprintf(path, "a_path_%u", n_starting_paths + 4); + if (H5PLreplace(path, 1) < 0) { + HDfprintf(stderr," replace 1: %s\n", path); + TEST_ERROR; + } + + /* Verify the table size remained the same */ + if (H5PLsize(&n_paths) < 0) + TEST_ERROR; + if (n_paths != n_starting_paths) + TEST_ERROR; + + /* Verify that the entries were not moved by + * inspecting the paths at indices +/- 1. + */ + + /* Check path at index 0 */ + if (H5PLget(0, path, 256) <= 0) + TEST_ERROR; + HDsprintf(temp_name, "a_path_%u", n_starting_paths + 1); + if (HDstrcmp(path, temp_name) != 0) { + HDfprintf(stderr," get 0: %s\n", path); + TEST_ERROR; + } + + /* Check path at index 2 */ + if (H5PLget(2, path, 256) <= 0) + TEST_ERROR; + if (HDstrcmp(path, "a_path_1") != 0) { + HDfprintf(stderr," get 2: %s\n", path); + TEST_ERROR; + } + + PASSED(); + + + /****************/ + /* H5PLinsert() */ + /****************/ + + /* We'll remove a path at an arbitrary index and then + * insert a new path. + */ + + TESTING(" remove (arbitrary index 2)"); + + /* Remove one path */ + if (H5PLremove(4) < 0) + TEST_ERROR; + + /* Verify that the entries were moved */ + if (H5PLget(4, path, 256) <= 0) + TEST_ERROR; + if (HDstrcmp(path, "a_path_4") != 0) { + HDfprintf(stderr," get 4: %s\n", path); + TEST_ERROR; + } + + /* Verify the table size */ + if (H5PLsize(&n_paths) < 0) + TEST_ERROR; + if (n_paths != n_starting_paths - 1) + TEST_ERROR; + PASSED(); + + + TESTING(" insert"); + + /* Insert one path at index 3*/ + HDsprintf(path, "a_path_%d", n_starting_paths + 5); + if (H5PLinsert(path, 3) < 0) { + HDfprintf(stderr," insert 3: %s\n", path); + TEST_ERROR; + } + + /* Verify that the entries were moved */ + if (H5PLget(4, path, 256) <= 0) + TEST_ERROR; + if (HDstrcmp(path, "a_path_2") != 0) { + HDfprintf(stderr," get 4: %s\n", path); + TEST_ERROR; + } + + /* Verify the table size increased */ + if (H5PLsize(&n_paths) < 0) + TEST_ERROR; + if (n_paths != n_starting_paths) + TEST_ERROR; + + PASSED(); + + + /****************/ + /* H5PLremove() */ + /****************/ + + /* Remove all the current paths */ + TESTING(" remove (all)"); + + /* Get the current size */ + if (H5PLsize(&n_paths) < 0) + TEST_ERROR; + + /* Remove all existing paths */ + for (u = n_paths; u > 0; u--) + if (H5PLremove(u-1) < 0) { + HDfprintf(stderr," at %u: %s\n", u, path); + TEST_ERROR; + } + + /* Verify the table is empty */ + if (H5PLsize(&n_paths) < 0) + TEST_ERROR; + if (n_paths > 0) + TEST_ERROR; + + PASSED(); + + + return SUCCEED; + +error: + return FAIL; +} /* end test_path_api_calls() */ + + +/*------------------------------------------------------------------------- + * Function: disable_chunk_cache + * + * Purpose: Turns the chunk cache off + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +disable_chunk_cache(hid_t fapl_id) { + int mdc_nelmts; + size_t rdcc_nelmts; + size_t rdcc_nbytes; + double rdcc_w0; + + if (H5Pget_cache(fapl_id, &mdc_nelmts, &rdcc_nelmts, &rdcc_nbytes, &rdcc_w0) < 0) + TEST_ERROR; + rdcc_nbytes = 0; + if (H5Pset_cache(fapl_id, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0) < 0) + TEST_ERROR; + + return SUCCEED; +error: + return FAIL; +} /* end disable_chunk_cache() */ + + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: Tests the plugin module (H5PL) + * + * Return: EXIT_SUCCESS/EXIT_FAILURE + * + *------------------------------------------------------------------------- + */ +int +main(void) +{ + char filename[FILENAME_BUF_SIZE]; + hid_t fid = -1; + hid_t old_ff_fapl_id = -1; + hid_t new_ff_fapl_id = -1; + unsigned new_format; + int nerrors = 0; + + /* Testing setup */ + h5_reset(); + + /*******************************************************************/ + /* ENSURE THAT WRITING TO DATASETS AND CREATING GROUPS WORKS */ + /*******************************************************************/ + + /* Get a VFD-dependent filename */ + if ((old_ff_fapl_id = h5_fileaccess()) < 0) + TEST_ERROR; + + /* Turn off the chunk cache, so all the chunks are immediately written to disk */ + if (disable_chunk_cache(old_ff_fapl_id) < 0) + TEST_ERROR; + + /* Copy the file access property list and set the latest file format on it */ + if ((new_ff_fapl_id = H5Pcopy(old_ff_fapl_id)) < 0) + TEST_ERROR; + if (H5Pset_libver_bounds(new_ff_fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + TEST_ERROR; + + /* Fix up the filename for the VFD */ + h5_fixname(FILENAME[0], old_ff_fapl_id, filename, sizeof(filename)); + + /* Test with old & new format groups */ + for (new_format = FALSE; new_format <= TRUE; new_format++) { + hid_t my_fapl_id; + + /* Set the FAPL for the type of format */ + if (new_format) { + HDputs("\nTesting with new file format:"); + my_fapl_id = new_ff_fapl_id; + } + else { + HDputs("Testing with old file format:"); + my_fapl_id = old_ff_fapl_id; + } + + /* Create the file for this test */ + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl_id)) < 0) + TEST_ERROR; + + /* Test creating datasets and writing to them using plugin filters */ + nerrors += (test_dataset_write_with_filters(fid) < 0 ? 1 : 0); + + /* Test creating groups using dynamically-loaded plugin filters */ + nerrors += (test_creating_groups_using_plugins(fid) < 0 ? 1 : 0); + + if (H5Fclose(fid) < 0) + TEST_ERROR; + } /* end for */ + + /* Close FAPLs */ + if (H5Pclose(old_ff_fapl_id) < 0) + TEST_ERROR; + if (H5Pclose(new_ff_fapl_id) < 0) + TEST_ERROR; + + /* Restore the default error handler (set in h5_reset()) */ + h5_restore_err(); + + /*******************************************************************/ + /* ENSURE THAT READING FROM DATASETS AND OPENING GROUPS WORKS */ + /*******************************************************************/ + + HDputs("\nTesting reading data with with dynamic plugin filters:"); + + /* Close the library so that all loaded plugin libraries are unloaded */ + h5_reset(); + if ((old_ff_fapl_id = h5_fileaccess()) < 0) + TEST_ERROR; + + /* Reopen the file for testing data reading */ + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, old_ff_fapl_id)) < 0) + TEST_ERROR; + + /* Read the data with filters */ + nerrors += (test_dataset_read_with_filters(fid) < 0 ? 1 : 0); + + /* Test creating groups using dynamically-loaded plugin filters */ + nerrors += (test_opening_groups_using_plugins(fid) < 0 ? 1 : 0); + + /* Restore the default error handler (set in h5_reset()) */ + h5_restore_err(); + + /*******************************************************************/ + /* ENSURE THAT DISABLING FILTER PLUGINS VIA THE FILTER FLAGS WORKS */ + /*******************************************************************/ + + /* Close the library so that all loaded plugin libraries are unloaded */ + h5_reset(); + if ((old_ff_fapl_id = h5_fileaccess()) < 0) + TEST_ERROR; + + /* Reopen the file for testing data reading */ + if ((fid = H5Fopen(filename, H5F_ACC_RDONLY, old_ff_fapl_id)) < 0) + TEST_ERROR; + + /* When filters are disabled, make sure we can't read data from a + * dataset that requires a filter plugin. + */ + nerrors += (test_no_read_when_plugins_disabled(fid) < 0 ? 1 : 0); + + if (H5Fclose(fid) < 0) + TEST_ERROR; + + /************************************/ + /* TEST THE FILTER PLUGIN API CALLS */ + /************************************/ + + /* Test the APIs for access to the filter plugin path table */ + nerrors += (test_path_api_calls() < 0 ? 1 : 0); + + /*********************/ + /* CLEAN UP AND EXIT */ + /*********************/ + + /* Free up saved arrays */ + free_2D_array(&orig_deflate_g); + free_2D_array(&orig_dynlib1_g); + free_2D_array(&orig_dynlib2_g); + free_2D_array(&orig_dynlib4_g); + + if (nerrors) + TEST_ERROR; + + HDprintf("All plugin tests passed.\n"); + h5_cleanup(FILENAME, old_ff_fapl_id); + + HDexit(EXIT_SUCCESS); + +error: + H5E_BEGIN_TRY { + H5Fclose(fid); + H5Pclose(old_ff_fapl_id); + H5Pclose(new_ff_fapl_id); + } H5E_END_TRY + + /* Free up saved arrays (NULLs okay) */ + free_2D_array(&orig_deflate_g); + free_2D_array(&orig_dynlib1_g); + free_2D_array(&orig_dynlib2_g); + free_2D_array(&orig_dynlib4_g); + + nerrors = MAX(1, nerrors); + HDprintf("***** %d PLUGIN TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S"); + HDexit(EXIT_FAILURE); +} /* end main() */ + diff --git a/test/filter_plugin1_dsets.c b/test/filter_plugin1_dsets.c new file mode 100644 index 0000000..b74e086 --- /dev/null +++ b/test/filter_plugin1_dsets.c @@ -0,0 +1,93 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Test dataset filter plugin for the filter_pluging.c test. + */ + + +#include +#include + +#include "H5PLextern.h" + +#define FILTER1_ID 257 + +static size_t add_sub_value(unsigned int flags, size_t cd_nelmts, + const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); + +/* Filter class struct */ +const H5Z_class2_t FILTER_INFO[1] = {{ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + FILTER1_ID, /* Filter ID number */ + 1, /* Encoding enabled */ + 1, /* Decoding enabled */ + "test filter plugin 1", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + (H5Z_func_t)add_sub_value, /* The actual filter function */ +}}; + +H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} +const void *H5PLget_plugin_info(void) {return FILTER_INFO;} + + +/*------------------------------------------------------------------------- + * Function: add_sub_value + * + * Purpose: On write: + * Adds a caller-supplied value to the element + * On read: + * Subtracts a caller-supplied value from the element + * + * Return: Success: Data chunk size in bytes + * Failure: 0 + * + *------------------------------------------------------------------------- + */ +static size_t +add_sub_value(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, + size_t nbytes, size_t *buf_size, void **buf) +{ + int *int_ptr = (int *)*buf; /* Pointer to the data values */ + size_t buf_left = *buf_size; /* Amount of data buffer left to process */ + int value = 0; /* Data value to add/subtract */ + + /* Check for the correct number of parameters */ + if (0 == cd_nelmts) + return 0; + + /* Check that permanent parameters are set correctly */ + if (cd_values[0] > 9) + return 0; + + value = (int)cd_values[0]; + + if (flags & H5Z_FLAG_REVERSE) { + /* READ - Substract the given value from all the data values */ + while (buf_left > 0) { + *int_ptr++ -= value; + buf_left -= sizeof(int); + } + } + else { + /* WRITE - Add the given value to all the data values */ + while (buf_left > 0) { + *int_ptr++ += value; + buf_left -= sizeof(int); + } + } + + return nbytes; + +} /* end add_sub_value() */ + diff --git a/test/filter_plugin2_dsets.c b/test/filter_plugin2_dsets.c new file mode 100644 index 0000000..6a79148 --- /dev/null +++ b/test/filter_plugin2_dsets.c @@ -0,0 +1,88 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Test dataset filter plugin for the filter_pluging.c test. + */ + +#include +#include + +#include "H5PLextern.h" + +#define FILTER2_ID 258 +#define MULTIPLIER 3 + +static size_t mult_div_value(unsigned int flags, size_t cd_nelmts, + const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); + +/* Filter class struct */ +const H5Z_class2_t FILTER_INFO[1] = {{ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + FILTER2_ID, /* Filter ID number */ + 1, /* Encoding enabled */ + 1, /* Decoding enabled */ + "test filter plugin 2", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + (H5Z_func_t)mult_div_value, /* The actual filter function */ +}}; + +H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} +const void *H5PLget_plugin_info(void) {return FILTER_INFO;} + + +/*------------------------------------------------------------------------- + * Function: mult_div_value + * + * Purpose: On write: + * Multiplies an element by a constant value. + * On read: + * Divides an element by a constant value. + * + * Return: Success: Data chunk size in bytes + * Failure: 0 + * + *------------------------------------------------------------------------- + */ +static size_t +mult_div_value(unsigned int flags, size_t cd_nelmts, + const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf) +{ + int *int_ptr = (int *)*buf; /* Pointer to the data values */ + size_t buf_left = *buf_size; /* Amount of data buffer left to process */ + + /* Check for the correct number of parameters */ + if (cd_nelmts > 0) + return 0; + + /* Assignment to eliminate unused parameter warning */ + cd_values = cd_values; + + if (flags & H5Z_FLAG_REVERSE) { + /* READ - Divide the original value by MULTIPLIER */ + while (buf_left > 0) { + *int_ptr++ /= MULTIPLIER; + buf_left -= sizeof(int); + } + } + else { + /* WRITE - Multiply the original value by MULTIPLIER */ + while (buf_left > 0) { + *int_ptr++ *= MULTIPLIER; + buf_left -= sizeof(int); + } + } + + return nbytes; +} /* end mult_div_value() */ + diff --git a/test/filter_plugin3_dsets.c b/test/filter_plugin3_dsets.c new file mode 100644 index 0000000..b43020f --- /dev/null +++ b/test/filter_plugin3_dsets.c @@ -0,0 +1,119 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Test dataset filter plugin for the filter_pluging.c test. + * This filter makes an HDF5 API call to ensure that works correctly. + */ + +#include +#include + +#include "H5PLextern.h" + +#define FILTER3_ID 259 + +#define PUSH_ERR(func, minor, str) H5Epush2(H5E_DEFAULT, __FILE__, func, __LINE__, H5E_ERR_CLS, H5E_PLUGIN, minor, str) + +static size_t add_sub_value_hdf5(unsigned int flags, size_t cd_nelmts, + const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); + +/* Filter class struct */ +const H5Z_class2_t FILTER_INFO[1] = {{ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + FILTER3_ID, /* Filter ID number */ + 1, /* Encoding enabled */ + 1, /* Decoding enabled */ + "test filter plugin 3", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + (H5Z_func_t)add_sub_value_hdf5, /* The actual filter function */ +}}; + +H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} +const void *H5PLget_plugin_info(void) {return FILTER_INFO;} + + +/*------------------------------------------------------------------------- + * Function: add_sub_value_hdf5 + * + * Purpose: On write: + * Adds a caller-supplied value to the element + * On read: + * Subtracts a caller-supplied value from the element + * + * NOTE: This filter is identical to filter #1 only it makes + * an HDF5 library call to ensure doing that doesn't + * cause problems. + * + * Return: Success: Data chunk size in bytes + * Failure: 0 + * + *------------------------------------------------------------------------- + */ +static size_t +add_sub_value_hdf5(unsigned int flags, size_t cd_nelmts, const unsigned int *cd_values, + size_t nbytes, size_t *buf_size, void **buf) +{ + int *int_ptr = (int *)*buf; /* Pointer to the data values */ + size_t buf_left = *buf_size; /* Amount of data buffer left to process */ + int value = 0; /* Data value to add/subtract */ + unsigned majnum = 0; /* Output data from the HDF5 library call */ + unsigned minnum = 0; + unsigned relnum = 0; + + /* Check for the library version. + * We don't do anything with this information - it's just to ensure that + * HDF5 library calls work properly from inside filter plugins. + */ + if (H5get_libversion(&majnum, &minnum, &relnum) < 0) { + PUSH_ERR("filter plugin 3", H5E_CALLBACK, "H5get_libversion"); + return 0; + } + + /* Check for the correct number of parameters */ + if (cd_nelmts == 0) + return 0; + + /* Check that permanent parameters are set correctly */ + if (cd_values[0] > 9) + return 0; + + /* Ensure that the version numbers match what was passed in. + * Again, this is trivial work, just to ensure that the library calls are + * working properly. + */ + if (majnum != cd_values[1] || minnum != cd_values[2]) { + PUSH_ERR("filter plugin 3", H5E_CALLBACK, "library versions do not match"); + return 0; + } + + value = (int)cd_values[0]; + + if (flags & H5Z_FLAG_REVERSE) { + /* READ - Substract the given value from all the data values */ + while (buf_left > 0) { + *int_ptr++ -= value; + buf_left -= sizeof(int); + } + } + else { + /* WRITE - Add the given value to all the data values */ + while (buf_left > 0) { + *int_ptr++ += value; + buf_left -= sizeof(int); + } + } + + return nbytes; +} /* end add_sub_value_hdf5() */ + diff --git a/test/filter_plugin4_groups.c b/test/filter_plugin4_groups.c new file mode 100644 index 0000000..88ea20d --- /dev/null +++ b/test/filter_plugin4_groups.c @@ -0,0 +1,106 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Test group filter plugin for the filter_pluging.c test. + */ + +#include +#include +#include + +#include "H5PLextern.h" + +#define FILTER4_ID 260 +#define SUFFIX_LEN 8 +#define GROUP_SUFFIX ".h5group" + +static size_t append_to_group_name(unsigned int flags, size_t cd_nelmts, + const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); + +/* Filter class struct */ +const H5Z_class2_t FILTER_INFO[1] = {{ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + FILTER4_ID, /* Filter ID number */ + 1, /* Encoding enabled */ + 1, /* Decoding enabled */ + "test filter plugin 4", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + (H5Z_func_t)append_to_group_name, /* The actual filter function */ +}}; + +H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;} +const void *H5PLget_plugin_info(void) {return FILTER_INFO;} + + +/*------------------------------------------------------------------------- + * Function: append_to_group_name + * + * Purpose: On write: + * Appends the suffix ".h5group" to the group name + * On read: + * Removes the ".h5group" suffix from the group name + * + * Return: Success: Data size in bytes + * Failure: 0 + * + *------------------------------------------------------------------------- + */ +static size_t +append_to_group_name(unsigned int flags, size_t cd_nelmts, + const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf) +{ + size_t new_name_size = 0; /* Return value */ + + /* Check for the correct number of parameters */ + if (cd_nelmts > 0) + return 0; + + /* Assignment to eliminate unused parameter warning. */ + cd_values = cd_values; + + if (flags & H5Z_FLAG_REVERSE) { + /* READ - Remove the suffix from the group name */ + new_name_size = *buf_size = nbytes - SUFFIX_LEN; + } + else { + /* WRITE - Append the suffix to the group name */ + void *outbuf = NULL; /* Pointer to new buffer */ + unsigned char *dst = NULL; /* Temporary pointer to destination buffer */ + + /* Get memory for the new, larger string buffer using the + * library's memory allocator. + */ + if (NULL == (dst = (unsigned char *)(outbuf = H5allocate_memory(nbytes + SUFFIX_LEN, 0)))) + return 0; + + /* Copy raw data */ + memcpy((void *)dst, (const void *)(*buf), nbytes); + + /* Append suffix to raw data for storage */ + dst += nbytes; + memcpy((void *)dst, (const void *)GROUP_SUFFIX, SUFFIX_LEN); + + /* Free the passed-in buffer using the library's allocator */ + H5free_memory(*buf); + + /* Set return values */ + *buf_size = nbytes + SUFFIX_LEN; + *buf = outbuf; + outbuf = NULL; + new_name_size = *buf_size; + } + + return new_name_size; +} /* append_to_group_name() */ + diff --git a/test/plugin.c b/test/plugin.c deleted file mode 100644 index ea199f6..0000000 --- a/test/plugin.c +++ /dev/null @@ -1,1217 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * All rights reserved. * - * * - * This file is part of HDF5. The full HDF5 copyright notice, including * - * terms governing use, modification, and redistribution, is contained in * - * the COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* - * Purpose: Tests the plugin module (H5PL) - */ - -#include "h5test.h" -#include "H5srcdir.h" - -/* - * This file needs to access private datatypes from the H5Z and H5PL package. - */ -#define H5PL_FRIEND -#include "H5PLpkg.h" -#define H5Z_FRIEND -#include "H5Zpkg.h" - -/* Filters for HDF5 internal test */ -#define H5Z_FILTER_DYNLIB1 257 -#define H5Z_FILTER_DYNLIB2 258 -#define H5Z_FILTER_DYNLIB3 259 -#define H5Z_FILTER_DYNLIB4 260 - -const char *FILENAME[] = { - "plugin", - NULL -}; -#define FILENAME_BUF_SIZE 1024 - -/* Dataset names for testing filters */ -#define DSET_DEFLATE_NAME "deflate" -#define DSET_DYNLIB1_NAME "dynlib1" -#define DSET_DYNLIB2_NAME "dynlib2" -#define DSET_DYNLIB4_NAME "dynlib4" - -/* Parameters for internal filter test */ -#define FILTER_CHUNK_DIM1 2 -#define FILTER_CHUNK_DIM2 25 -#define FILTER_HS_OFFSET1 7 -#define FILTER_HS_OFFSET2 30 -#define FILTER_HS_SIZE1 4 -#define FILTER_HS_SIZE2 50 - -/* Shared global arrays */ -#define DSET_DIM1 100 -#define DSET_DIM2 200 - -/* Limit random number within 20000 */ -#define RANDOM_LIMIT 20000 - -#define GROUP_ITERATION 1000 - -int points_deflate[DSET_DIM1][DSET_DIM2], - points_dynlib1[DSET_DIM1][DSET_DIM2], - points_dynlib2[DSET_DIM1][DSET_DIM2], - points_dynlib4[DSET_DIM1][DSET_DIM2], - points_bzip2[DSET_DIM1][DSET_DIM2]; - - -/*------------------------------------------------------------------------- - * Function: test_filter_internal - * - * Purpose: Tests writing entire data and partial data with filters - * - * Return: Success: 0 - * Failure: -1 - *------------------------------------------------------------------------- - */ -static herr_t -test_filter_internal(hid_t fid, const char *name, hid_t dcpl) -{ - herr_t ret_value = -1; - hid_t dataset = -1; /* Dataset ID */ - hid_t dxpl = -1; /* Dataset xfer property list ID */ - hid_t write_dxpl = -1; /* Dataset xfer property list ID for writing */ - hid_t sid = -1; /* Dataspace ID */ - const hsize_t size[2] = {DSET_DIM1, DSET_DIM2}; /* Dataspace dimensions */ - const hsize_t hs_offset[2] = {FILTER_HS_OFFSET1, FILTER_HS_OFFSET2}; /* Hyperslab offset */ - const hsize_t hs_size[2] = {FILTER_HS_SIZE1, FILTER_HS_SIZE2}; /* Hyperslab size */ - void *tconv_buf = NULL; /* Temporary conversion buffer */ - int points[DSET_DIM1][DSET_DIM2], check[DSET_DIM1][DSET_DIM2]; - size_t i, j; /* Local index variables */ - int n = 0; - - /* Create the data space */ - if((sid = H5Screate_simple(2, size, NULL)) < 0) TEST_ERROR - - /* - * Create a small conversion buffer to test strip mining. We - * might as well test all we can! - */ - if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR - tconv_buf = HDmalloc((size_t)1000); - if(H5Pset_buffer(dxpl, (size_t)1000, tconv_buf, NULL) < 0) TEST_ERROR - if((write_dxpl = H5Pcopy(dxpl)) < 0) TEST_ERROR; - - TESTING(" filters (setup)"); - - /* Check if all the filters are available */ - if(H5Pall_filters_avail(dcpl) != TRUE) { - H5_FAILED(); - HDprintf(" Line %d: Incorrect filter availability\n", __LINE__); - TEST_ERROR - } /* end if */ - - /* Create the dataset */ - if((dataset = H5Dcreate2(fid, name, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR - - PASSED(); - - /*---------------------------------------------------------------------- - * STEP 1: Read uninitialized data. It should be zero. - *---------------------------------------------------------------------- - */ - TESTING(" filters (uninitialized read)"); - - if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl, check) < 0) TEST_ERROR; - - for(i=0; i<(size_t)size[0]; i++) - for(j=0; j<(size_t)size[1]; j++) - if(0 != check[i][j]) { - H5_FAILED(); - HDprintf(" Read a non-zero value.\n"); - HDprintf(" At index %lu,%lu\n", (unsigned long)i, (unsigned long)j); - TEST_ERROR - } /* end if */ - PASSED(); - - /*---------------------------------------------------------------------- - * STEP 2: Test filters by setting up a chunked dataset and writing - * to it. - *---------------------------------------------------------------------- - */ - TESTING(" filters (write)"); - - n = 0; - for(i=0; i= 0) - TEST_ERROR - - PASSED(); - ret_value = 0; - -error: - return ret_value; -} - -/*------------------------------------------------------------------------- - * Function: test_noread_with_filters - * - * Purpose: Tests reading dataset created with dynamically loaded filters disabled - * - * Return: Success: 0 - * Failure: -1 - *------------------------------------------------------------------------- - */ -static herr_t -test_noread_with_filters(hid_t file) -{ - herr_t ret_value = -1; - hid_t dset = -1; /* Dataset ID */ - unsigned plugin_state; /* status of plugins */ - - TESTING("DYNLIB1 filter with plugins disabled"); - - /* disable filter plugin */ - if(H5PLget_loading_state(&plugin_state) < 0) TEST_ERROR - - plugin_state = plugin_state & (unsigned)(~H5PL_FILTER_PLUGIN); - - if(H5PLset_loading_state(plugin_state) < 0) TEST_ERROR - - if((dset = H5Dopen2(file, DSET_DYNLIB1_NAME, H5P_DEFAULT)) < 0) TEST_ERROR - - if(test_noread_data(dset) < 0) TEST_ERROR - - if(H5Dclose(dset) < 0) TEST_ERROR - - ret_value = 0; - -error: - /* re-enable filter plugin */ - plugin_state = plugin_state | H5PL_FILTER_PLUGIN; - H5PLset_loading_state(plugin_state); - - /* Clean up objects used for this test */ - H5E_BEGIN_TRY { - H5Dclose(dset); - } H5E_END_TRY - - return ret_value; -} - -/*------------------------------------------------------------------------- - * Function: test_filters_for_groups - * - * Purpose: Tests creating group with dynamically loaded filters - * - * Return: Success: 0 - * Failure: -1 - *------------------------------------------------------------------------- - */ -static herr_t -test_filters_for_groups(hid_t file) -{ - herr_t ret_value = -1; - hid_t gcpl = -1; - hid_t gid = -1; - hid_t group = -1; - int i; - char gname[256]; - - TESTING("DYNLIB3 filter for group"); - - if((gcpl = H5Pcreate(H5P_GROUP_CREATE)) < 0) TEST_ERROR - - /* Use DYNLIB3 for creating groups */ - if(H5Pset_filter (gcpl, H5Z_FILTER_DYNLIB3, H5Z_FLAG_MANDATORY, (size_t)0, NULL) < 0) TEST_ERROR - - /* Create a group using this filter */ - if((gid = H5Gcreate2(file, "group1", H5P_DEFAULT, gcpl, H5P_DEFAULT)) < 0) TEST_ERROR - - /* Create multiple groups under "group1" */ - for(i=0; i < GROUP_ITERATION; i++) { - HDsprintf(gname, "group_%d", i); - if((group = H5Gcreate2(gid, gname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(group) < 0) TEST_ERROR - } - - /* Close the group */ - if(H5Gclose(gid) < 0) TEST_ERROR - - /* Clean up objects used for this test */ - if(H5Pclose(gcpl) < 0) TEST_ERROR - - PASSED(); - - ret_value = 0; - -error: - /* Clean up objects used for this test */ - H5E_BEGIN_TRY { - H5Gclose(group); - H5Gclose(gid); - H5Pclose(gcpl); - } H5E_END_TRY - - return ret_value; -} - -/*------------------------------------------------------------------------- - * Function: test_groups_with_filters - * - * Purpose: Tests opening group with dynamically loaded filters - * - * Return: Success: 0 - * Failure: -1 - * - *------------------------------------------------------------------------- - */ -static herr_t -test_groups_with_filters(hid_t file) -{ - herr_t ret_value = -1; - hid_t gid = -1; - hid_t group = -1; - int i; - char gname[256]; - - TESTING("opening groups with DYNLIB3 filter"); - - /* Open the top group */ - if((gid = H5Gopen2(file, "group1", H5P_DEFAULT)) < 0) TEST_ERROR - - /* Create multiple groups under "group1" */ - for(i=0; i < GROUP_ITERATION; i++) { - HDsprintf(gname, "group_%d", i); - if((group = H5Gopen2(gid, gname, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(group) < 0) TEST_ERROR - } - - /* Close the group */ - if(H5Gclose(gid) < 0) TEST_ERROR - - PASSED(); - - ret_value = 0; - -error: - /* Clean up objects used for this test */ - H5E_BEGIN_TRY { - H5Gclose(group); - H5Gclose(gid); - } H5E_END_TRY - - return ret_value; -} - - -/*------------------------------------------------------------------------- - * Function: test_path_api_calls - * - * Purpose: Tests the H5PL API calls that manipulate the plugin search - * paths. - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -test_path_api_calls(void) -{ - unsigned int n_starting_paths; - unsigned int u; - unsigned int n_paths; - herr_t ret; - ssize_t path_len = -1; - char path[256]; - char temp_name[256]; - - HDputs("Testing access to the filter path table"); - - if(H5Zfilter_avail(H5Z_FILTER_DYNLIB1) != TRUE) - TEST_ERROR - - /* Set the number of paths to create for this test. - * - * This should be set high enough to ensure that at least one array - * expansion will take place. See H5PLpath.c for details. - */ - n_starting_paths = 42; - - /* Check that initialization is correct */ - TESTING(" initialize"); - - if(H5PLsize(&n_paths) < 0) - TEST_ERROR - if(n_paths != 2) - TEST_ERROR - - PASSED(); - - /****************/ - /* H5PLremove() */ - /****************/ - - /* Remove all the current paths */ - TESTING(" remove"); - - /* Get the current size */ - if(H5PLsize(&n_paths) < 0) - TEST_ERROR - - /* Remove all existing paths */ - for(u = n_paths; u > 0; u--) - if(H5PLremove(u-1) < 0) { - HDfprintf(stderr," at %u: %s\n", u, path); - TEST_ERROR - } - - /* Verify the table is empty */ - if(H5PLsize(&n_paths) < 0) - TEST_ERROR - if(n_paths > 0) - TEST_ERROR - - PASSED(); - - - TESTING(" remove (index 0 in empty table)"); - - /* Try to remove index zero in an empty list (SHOULD FAIL) */ - H5E_BEGIN_TRY { - ret = H5PLremove(0); - } H5E_END_TRY - if(ret >= 0) - TEST_ERROR - - PASSED(); - - - /****************/ - /* H5PLappend() */ - /****************/ - - TESTING(" append"); - - /* Add a bunch of paths to the path table */ - for(u = 0; u < n_starting_paths; u++) { - HDsprintf(path, "a_path_%u", u); - if(H5PLappend(path) < 0) { - HDfprintf(stderr," at %u: %s\n", u, path); - TEST_ERROR - } - } - - PASSED(); - - - /**********************/ - /* H5PLremove() again */ - /**********************/ - - TESTING(" remove (index too high)"); - - /* Try to remove a path where the index is beyond the table capacity (SHOULD FAIL) */ - H5E_BEGIN_TRY { - ret = H5PLremove(n_starting_paths); - } H5E_END_TRY - - if(ret >= 0) - TEST_ERROR - - PASSED(); - - - /*************/ - /* H5PLget() */ - /*************/ - - TESTING(" get (path name)"); - - /* Get the path length by passing in NULL */ - if((path_len = H5PLget(0, NULL, 0)) <= 0) { - HDfprintf(stderr," get path 0 length failed\n"); - TEST_ERROR - } - if(path_len != 8) - TEST_ERROR - - /* Get the path */ - if((path_len = H5PLget(0, path, 256)) <= 0) { - HDfprintf(stderr," get 0 len: %u : %s\n", path_len, path); - TEST_ERROR - } - if(HDstrcmp(path, "a_path_0") != 0) { - HDfprintf(stderr," get 0: %s\n", path); - TEST_ERROR - } - - PASSED(); - - - TESTING(" get (high and low indices)"); - - /* Get path at index 1 */ - if((path_len = H5PLget(1, path, 256)) <= 0) - TEST_ERROR - if(HDstrcmp(path, "a_path_1") != 0) { - HDfprintf(stderr," get 1: %s\n", path); - TEST_ERROR - } - - /* Get path at the last index */ - if((path_len = H5PLget(n_starting_paths - 1, path, 256)) <= 0) - TEST_ERROR - HDsprintf(temp_name, "a_path_%u", n_starting_paths - 1); - if(HDstrcmp(path, temp_name) != 0) { - HDfprintf(stderr," get %u: %s\n", n_starting_paths - 1, path); - TEST_ERROR - } - - PASSED(); - - - TESTING(" get (index too high)"); - - /* Get path at the last + 1 index (SHOULD FAIL) */ - H5E_BEGIN_TRY { - path_len = H5PLget(n_starting_paths, NULL, 0); - } H5E_END_TRY - if(path_len > 0) - TEST_ERROR - - PASSED(); - - - /*****************/ - /* H5PLprepend() */ - /*****************/ - - /* We'll remove a path at an arbitrary index and then - * prepend a new path. - */ - - TESTING(" remove (arbitrary index 1)"); - - /* Remove one path */ - if(H5PLremove(8) < 0) - TEST_ERROR - - /* Verify that the entries were moved */ - if((path_len = H5PLget(8, path, 256)) <= 0) - TEST_ERROR - if(HDstrcmp(path, "a_path_9") != 0) { - HDfprintf(stderr," get 8: %s\n", path); - TEST_ERROR - } - - /* Verify the table shrank */ - if(H5PLsize(&n_paths) < 0) - TEST_ERROR - if(n_paths != n_starting_paths - 1) - TEST_ERROR - - PASSED(); - - - TESTING(" prepend"); - - /* Prepend one path */ - HDsprintf(path, "a_path_%d", n_starting_paths + 1); - if(H5PLprepend(path) < 0) { - HDfprintf(stderr," prepend %u: %s\n", n_starting_paths + 1, path); - TEST_ERROR - } - - /* Verify the table increased */ - if(H5PLsize(&n_paths) < 0) - TEST_ERROR - if(n_paths != n_starting_paths) - TEST_ERROR - - /* Verify that the entries were moved */ - if(H5PLget(8, path, 256) <= 0) - TEST_ERROR - if(HDstrcmp(path, "a_path_7") != 0) { - HDfprintf(stderr," get 8: %s\n", path); - TEST_ERROR - } - - /* Verify that the path was inserted at index zero */ - if(H5PLget(0, path, 256) <= 0) - TEST_ERROR - HDsprintf(temp_name, "a_path_%d", n_starting_paths + 1); - if(HDstrcmp(path, temp_name) != 0) { - HDfprintf(stderr," get 0: %s\n", path); - TEST_ERROR - } - - PASSED(); - - - /*****************/ - /* H5PLreplace() */ - /*****************/ - - TESTING(" replace"); - - /* Replace one path at index 1 */ - HDsprintf(path, "a_path_%u", n_starting_paths + 4); - if(H5PLreplace(path, 1) < 0) { - HDfprintf(stderr," replace 1: %s\n", path); - TEST_ERROR - } - - /* Verify the table size remained the same */ - if(H5PLsize(&n_paths) < 0) - TEST_ERROR - if(n_paths != n_starting_paths) - TEST_ERROR - - /* Verify that the entries were not moved by - * inspecting the paths at indices +/- 1. - */ - - /* Check path at index 0 */ - if(H5PLget(0, path, 256) <= 0) - TEST_ERROR - HDsprintf(temp_name, "a_path_%u", n_starting_paths + 1); - if(HDstrcmp(path, temp_name) != 0) { - HDfprintf(stderr," get 0: %s\n", path); - TEST_ERROR - } - - /* Check path at index 2 */ - if(H5PLget(2, path, 256) <= 0) - TEST_ERROR - if(HDstrcmp(path, "a_path_1") != 0) { - HDfprintf(stderr," get 2: %s\n", path); - TEST_ERROR - } - - PASSED(); - - - /****************/ - /* H5PLinsert() */ - /****************/ - - /* We'll remove a path at an arbitrary index and then - * insert a new path. - */ - - TESTING(" remove (arbitrary index 2)"); - - /* Remove one path */ - if(H5PLremove(4) < 0) - TEST_ERROR - - /* Verify that the entries were moved */ - if(H5PLget(4, path, 256) <= 0) - TEST_ERROR - if(HDstrcmp(path, "a_path_4") != 0) { - HDfprintf(stderr," get 4: %s\n", path); - TEST_ERROR - } - - /* Verify the table size */ - if(H5PLsize(&n_paths) < 0) - TEST_ERROR - if(n_paths != n_starting_paths - 1) - TEST_ERROR - PASSED(); - - - TESTING(" insert"); - - /* Insert one path at index 3*/ - HDsprintf(path, "a_path_%d", n_starting_paths + 5); - if(H5PLinsert(path, 3) < 0) { - HDfprintf(stderr," insert 3: %s\n", path); - TEST_ERROR - } - - /* Verify that the entries were moved */ - if(H5PLget(4, path, 256) <= 0) - TEST_ERROR - if(HDstrcmp(path, "a_path_2") != 0) { - HDfprintf(stderr," get 4: %s\n", path); - TEST_ERROR - } - - /* Verify the table size increased */ - if(H5PLsize(&n_paths) < 0) - TEST_ERROR - if(n_paths != n_starting_paths) - TEST_ERROR - - PASSED(); - - - /****************/ - /* H5PLremove() */ - /****************/ - - /* Remove all the current paths */ - TESTING(" remove (all)"); - - /* Get the current size */ - if(H5PLsize(&n_paths) < 0) - TEST_ERROR - - /* Remove all existing paths */ - for(u = n_paths; u > 0; u--) - if(H5PLremove(u-1) < 0) { - HDfprintf(stderr," at %u: %s\n", u, path); - TEST_ERROR - } - - /* Verify the table is empty */ - if(H5PLsize(&n_paths) < 0) - TEST_ERROR - if(n_paths > 0) - TEST_ERROR - - PASSED(); - - - return SUCCEED; - -error: - return FAIL; -} /* end test_path_api_calls() */ - - -/*------------------------------------------------------------------------- - * Function: main - * - * Purpose: Tests the plugin module (H5PL) - * - * Return: EXIT_SUCCESS/EXIT_FAILURE - * - *------------------------------------------------------------------------- - */ -int -main(void) -{ - char filename[FILENAME_BUF_SIZE]; - hid_t file = -1; - hid_t fapl = -1; - hid_t fapl2 = -1; - unsigned new_format; - int mdc_nelmts; - size_t rdcc_nelmts; - size_t rdcc_nbytes; - double rdcc_w0; - int nerrors = 0; - - /* Testing setup */ - h5_reset(); - - if ((fapl = h5_fileaccess()) < 0) - TEST_ERROR - - /* Turn off the chunk cache, so all the chunks are immediately written to disk */ - if (H5Pget_cache(fapl, &mdc_nelmts, &rdcc_nelmts, &rdcc_nbytes, &rdcc_w0) < 0) - TEST_ERROR - rdcc_nbytes = 0; - if (H5Pset_cache(fapl, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0) < 0) - TEST_ERROR - - /* Copy the file access property list */ - if ((fapl2 = H5Pcopy(fapl)) < 0) - TEST_ERROR - - /* Set the "use the latest version of the format" bounds for creating objects in the file */ - if (H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) - TEST_ERROR - - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - - /* Test with old & new format groups */ - for (new_format = FALSE; new_format <= TRUE; new_format++) { - hid_t my_fapl; - - /* Set the FAPL for the type of format */ - if (new_format) { - HDputs("\nTesting with new file format:"); - my_fapl = fapl2; - } - else { - HDputs("Testing with old file format:"); - my_fapl = fapl; - } - - /* Create the file for this test */ - if ((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) - TEST_ERROR - - /* Test dynamically loaded filters for chunked dataset */ - nerrors += (test_filters_for_datasets(file) < 0 ? 1 : 0); - - /* Test dynamically loaded filters for groups */ - nerrors += (test_filters_for_groups(file) < 0 ? 1 : 0); - - if (H5Fclose(file) < 0) - TEST_ERROR - } /* end for */ - - /* Close FAPL */ - if (H5Pclose(fapl2) < 0) - TEST_ERROR - if (H5Pclose(fapl) < 0) - TEST_ERROR - - /* Restore the default error handler (set in h5_reset()) */ - h5_restore_err(); - - HDputs("\nTesting reading data with with dynamic plugin filters:"); - - /* Close the library so that all loaded plugin libraries are unloaded */ - h5_reset(); - if ((fapl = h5_fileaccess()) < 0) - TEST_ERROR - - /* Reopen the file for testing data reading */ - if ((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) - TEST_ERROR - - /* Read the data with filters */ - nerrors += (test_read_with_filters(file) < 0 ? 1 : 0); - - /* Open the groups with filters */ - nerrors += (test_groups_with_filters(file) < 0 ? 1 : 0); - - /* Restore the default error handler (set in h5_reset()) */ - h5_restore_err(); - - /* Close the library so that all loaded plugin libraries are unloaded */ - h5_reset(); - if ((fapl = h5_fileaccess()) < 0) - TEST_ERROR - - /* Reopen the file for testing data reading */ - if ((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) - TEST_ERROR - - /* Read the data with disabled filters */ - nerrors += (test_noread_with_filters(file) < 0 ? 1 : 0); - - if (H5Fclose(file) < 0) - TEST_ERROR - - /* Test the APIs for access to the filter plugin path table */ - nerrors += (test_path_api_calls() < 0 ? 1 : 0); - - if (nerrors) - TEST_ERROR - - HDprintf("All plugin tests passed.\n"); - h5_cleanup(FILENAME, fapl); - - HDexit(EXIT_SUCCESS); - -error: - nerrors = MAX(1, nerrors); - HDprintf("***** %d PLUGIN TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S"); - HDexit(EXIT_FAILURE); -} /* end main() */ - diff --git a/test/test_filter_plugin.sh.in b/test/test_filter_plugin.sh.in new file mode 100644 index 0000000..0a45c0f --- /dev/null +++ b/test/test_filter_plugin.sh.in @@ -0,0 +1,113 @@ +#! /bin/sh +# +# Copyright by The HDF Group. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# +srcdir=@srcdir@ +TOP_BUILDDIR=@top_builddir@ + +# Determine if backward compatibility options enabled +DEPRECATED_SYMBOLS="@DEPRECATED_SYMBOLS@" + +EXIT_SUCCESS=0 +EXIT_FAILURE=1 + +nerrors=0 +verbose=yes +exit_code=$EXIT_SUCCESS + +TEST_NAME=filter_plugin +TEST_BIN=`pwd`/$TEST_NAME +FROM_DIR=`pwd`/.libs +case $(uname) in + CYGWIN* ) + PLUGINS_FOR_DIR1="$FROM_DIR/cygfilter_plugin1* $FROM_DIR/cygfilter_plugin3*" + PLUGINS_FOR_DIR2="$FROM_DIR/cygfilter_plugin2* $FROM_DIR/cygfilter_plugin4*" + ;; + *) + PLUGINS_FOR_DIR1="$FROM_DIR/libfilter_plugin1* $FROM_DIR/libfilter_plugin3*" + PLUGINS_FOR_DIR2="$FROM_DIR/libfilter_plugin2* $FROM_DIR/libfilter_plugin4*" + ;; +esac +PLUGIN_DIR1=filter_plugin_dir1 +PLUGIN_DIR2=filter_plugin_dir2 +CP="cp -p" # Use -p to preserve mode,ownership,timestamps +RM="rm -rf" + +# Print a line-line message left justified in a field of 70 characters +# beginning with the word "Testing". +# +TESTING() { + SPACES=" " + echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012' +} + +# Main Body +# Create test directories if necessary. +test -d $PLUGIN_DIR1 || mkdir -p $PLUGIN_DIR1 +if [ $? != 0 ]; then + echo "Failed to create filter plugin test directory ($PLUGIN_DIR1)" + exit $EXIT_FAILURE +fi + +test -d $PLUGIN_DIR2 || mkdir -p $PLUGIN_DIR2 +if [ $? != 0 ]; then + echo "Failed to create filter plugin test directory ($PLUGIN_DIR2)" + exit $EXIT_FAILURE +fi + +# Copy plugins for the tests. +$CP $PLUGINS_FOR_DIR1 $PLUGIN_DIR1 +if [ $? != 0 ]; then + echo "Failed to copy filter plugins ($PLUGINS_FOR_DIR1) to test directory." + exit $EXIT_FAILURE +fi + +$CP $PLUGINS_FOR_DIR2 $PLUGIN_DIR2 +if [ $? != 0 ]; then + echo "Failed to copy filter plugins ($PLUGINS_FOR_DIR2) to test directory." + exit $EXIT_FAILURE +fi + +# setup plugin path +ENVCMD="env HDF5_PLUGIN_PATH=${PLUGIN_DIR1}:${PLUGIN_DIR2}" + +# Run the test +$ENVCMD $TEST_BIN +if [ $? != 0 ]; then + nerrors=`expr $nerrors + 1` +fi + +############################################ +# HDFFV-9655 test for relative path disabled +# setup filter plugin path relative to test +# actual executable is in the .libs folder +#ENVCMD="env HDF5_PLUGIN_PATH=@/../${PLUGIN_DIR1}:@/../${PLUGIN_DIR2}" +# +# Run the test +#$ENVCMD $TEST_BIN +#if [ $? != 0 ]; then +# nerrors=`expr $nerrors + 1` +#fi +############################################# + +# print results +if test $nerrors -ne 0 ; then + echo "$nerrors errors encountered" + exit_code=$EXIT_FAILURE +else + echo "All filter plugin tests passed." + exit_code=$EXIT_SUCCESS +fi + +# Clean up temporary files/directories and leave +$RM $PLUGIN_DIR1 $PLUGIN_DIR2 + +exit $exit_code diff --git a/test/test_plugin.sh.in b/test/test_plugin.sh.in deleted file mode 100644 index c90a978..0000000 --- a/test/test_plugin.sh.in +++ /dev/null @@ -1,113 +0,0 @@ -#! /bin/sh -# -# Copyright by The HDF Group. -# All rights reserved. -# -# This file is part of HDF5. The full HDF5 copyright notice, including -# terms governing use, modification, and redistribution, is contained in -# the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. -# If you do not have access to either file, you may request a copy from -# help@hdfgroup.org. -# -srcdir=@srcdir@ -TOP_BUILDDIR=@top_builddir@ - -# Determine backward compatibility options enabled -DEPRECATED_SYMBOLS="@DEPRECATED_SYMBOLS@" - -EXIT_SUCCESS=0 -EXIT_FAILURE=1 - -nerrors=0 -verbose=yes -exit_code=$EXIT_SUCCESS - -TEST_NAME=plugin -TEST_BIN=`pwd`/$TEST_NAME -FROM_DIR=`pwd`/.libs -case $(uname) in - CYGWIN* ) - PLUGIN_LIB1="$FROM_DIR/cygdynlib1* $FROM_DIR/cygdynlib3*" - PLUGIN_LIB2="$FROM_DIR/cygdynlib2* $FROM_DIR/cygdynlib4*" - ;; - *) - PLUGIN_LIB1="$FROM_DIR/libdynlib1.* $FROM_DIR/libdynlib3.*" - PLUGIN_LIB2="$FROM_DIR/libdynlib2.* $FROM_DIR/libdynlib4.*" - ;; -esac -PLUGIN_LIBDIR1=testdir1 -PLUGIN_LIBDIR2=testdir2 -CP="cp -p" # Use -p to preserve mode,ownership,timestamps -RM="rm -rf" - -# Print a line-line message left justified in a field of 70 characters -# beginning with the word "Testing". -# -TESTING() { - SPACES=" " - echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012' -} - -# Main Body -# Create test directories if not exists yet. -test -d $PLUGIN_LIBDIR1 || mkdir -p $PLUGIN_LIBDIR1 -if [ $? != 0 ]; then - echo "Failed to create test directory($PLUGIN_LIBDIR1)" - exit $EXIT_FAILURE -fi - -test -d $PLUGIN_LIBDIR2 || mkdir -p $PLUGIN_LIBDIR2 -if [ $? != 0 ]; then - echo "Failed to create test directory($PLUGIN_LIBDIR2)" - exit $EXIT_FAILURE -fi - -# copy plugin library for test -$CP $PLUGIN_LIB1 $PLUGIN_LIBDIR1 -if [ $? != 0 ]; then - echo "Failed to copy plugin library ($PLUGIN_LIB1) for test." - exit $EXIT_FAILURE -fi - -$CP $PLUGIN_LIB2 $PLUGIN_LIBDIR2 -if [ $? != 0 ]; then - echo "Failed to copy plugin library ($PLUGIN_LIB2) for test." - exit $EXIT_FAILURE -fi - -# setup plugin path -ENVCMD="env HDF5_PLUGIN_PATH=${PLUGIN_LIBDIR1}:${PLUGIN_LIBDIR2}" - -# Run the test -$ENVCMD $TEST_BIN -if [ $? != 0 ]; then - nerrors=`expr $nerrors + 1` -fi - -############################################ -# HDFFV-9655 test for relative path disabled -# setup plugin path relative to test -# actual executable is in the .libs folder -#ENVCMD="env HDF5_PLUGIN_PATH=@/../${PLUGIN_LIBDIR1}:@/../${PLUGIN_LIBDIR2}" -# -# Run the test -#$ENVCMD $TEST_BIN -#if [ $? != 0 ]; then -# nerrors=`expr $nerrors + 1` -#fi -############################################# - -# print results -if test $nerrors -ne 0 ; then - echo "$nerrors errors encountered" - exit_code=$EXIT_FAILURE -else - echo "All Plugin API tests passed." - exit_code=$EXIT_SUCCESS -fi - -# Clean up temporary files/directories and leave -$RM $PLUGIN_LIBDIR1 $PLUGIN_LIBDIR2 - -exit $exit_code diff --git a/tools/test/h5diff/Makefile.am b/tools/test/h5diff/Makefile.am index d2b5ebb..4d43a2a 100644 --- a/tools/test/h5diff/Makefile.am +++ b/tools/test/h5diff/Makefile.am @@ -53,9 +53,6 @@ if HAVE_SHARED_CONDITIONAL noinst_LTLIBRARIES=libdynlibdiff.la libdynlibdiff_la_SOURCES=dynlib_diff.c libdynlibdiff_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere - - libdynlibdiff.la: $(libdynlibdiff_la_OBJECTS) $(libdynlibdiff_la_DEPENDENCIES) $(EXTRA_libdynlibdiff_la_DEPENDENCIES) - $(AM_V_CCLD)$(libdynlibdiff_la_LINK) $(am_libdynlibdiff_la_rpath) $(libdynlibdiff_la_OBJECTS) $(libdynlibdiff_la_LIBADD) endif # Temporary files. *.h5 are generated by h5diff. They should diff --git a/tools/test/h5dump/Makefile.am b/tools/test/h5dump/Makefile.am index 1454987..be21119 100644 --- a/tools/test/h5dump/Makefile.am +++ b/tools/test/h5dump/Makefile.am @@ -42,9 +42,6 @@ if HAVE_SHARED_CONDITIONAL noinst_LTLIBRARIES=libdynlibdump.la libdynlibdump_la_SOURCES=dynlib_dump.c libdynlibdump_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere - - libdynlibdump.la: $(libdynlibdump_la_OBJECTS) $(libdynlibdump_la_DEPENDENCIES) $(EXTRA_libdynlibdump_la_DEPENDENCIES) - $(AM_V_CCLD)$(libdynlibdump_la_LINK) $(am_libdynlibdump_la_rpath) $(libdynlibdump_la_OBJECTS) $(libdynlibdump_la_LIBADD) endif # Temporary files. *.h5 are generated by h5dumpgentest. They should diff --git a/tools/test/h5ls/Makefile.am b/tools/test/h5ls/Makefile.am index ec8b8c3..a49c2e8 100644 --- a/tools/test/h5ls/Makefile.am +++ b/tools/test/h5ls/Makefile.am @@ -39,9 +39,6 @@ if HAVE_SHARED_CONDITIONAL noinst_LTLIBRARIES=libdynlibls.la libdynlibls_la_SOURCES=dynlib_ls.c libdynlibls_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere - - libdynlibls.la: $(libdynlibls_la_OBJECTS) $(libdynlibls_la_DEPENDENCIES) $(EXTRA_libdynlibls_la_DEPENDENCIES) - $(AM_V_CCLD)$(libdynlibls_la_LINK) $(am_libdynlibls_la_rpath) $(libdynlibls_la_OBJECTS) $(libdynlibls_la_LIBADD) endif diff --git a/tools/test/h5repack/Makefile.am b/tools/test/h5repack/Makefile.am index d4dc843..fbe88bd 100644 --- a/tools/test/h5repack/Makefile.am +++ b/tools/test/h5repack/Makefile.am @@ -50,11 +50,6 @@ if HAVE_SHARED_CONDITIONAL libdynlibvers_la_SOURCES=dynlib_vrpk.c libdynlibadd_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere libdynlibvers_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere - - libdynlibadd.la: $(libdynlibadd_la_OBJECTS) $(libdynlibadd_la_DEPENDENCIES) $(EXTRA_libdynlibadd_la_DEPENDENCIES) - $(AM_V_CCLD)$(libdynlibadd_la_LINK) $(am_libdynlibadd_la_rpath) $(libdynlibadd_la_OBJECTS) $(libdynlibadd_la_LIBADD) - libdynlibvers.la: $(libdynlibvers_la_OBJECTS) $(libdynlibvers_la_DEPENDENCIES) $(EXTRA_libdynlibvers_la_DEPENDENCIES) - $(AM_V_CCLD)$(libdynlibvers_la_LINK) $(am_libdynlibvers_la_rpath) $(libdynlibvers_la_OBJECTS) $(libdynlibvers_la_LIBADD) endif -- cgit v0.12 From 3e4f6138b60d8363c377e453d63f875775ec907a Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Thu, 9 Nov 2017 13:56:58 -0800 Subject: Removed asserts from H5MM calls that conflict with stated behavior and added a test to ensure that this doesn't happen in the future. --- src/H5MM.c | 8 +------- test/tmisc.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 62 insertions(+), 8 deletions(-) diff --git a/src/H5MM.c b/src/H5MM.c index ee3b28f..866dfbe 100644 --- a/src/H5MM.c +++ b/src/H5MM.c @@ -268,8 +268,6 @@ H5MM_malloc(size_t size) { void *ret_value = NULL; - HDassert(size); - /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -357,8 +355,6 @@ H5MM_calloc(size_t size) { void *ret_value = NULL; - HDassert(size); - /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -407,8 +403,6 @@ H5MM_realloc(void *mem, size_t size) /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR - HDassert(mem || size); - if(NULL == mem && 0 == size) /* Not defined in the standard, return NULL */ ret_value = NULL; @@ -454,7 +448,7 @@ H5MM_realloc(void *mem, size_t size) * NULL is an acceptable value for the input string. * * Return: Success: Pointer to a new string (NULL if s is NULL). - * Failure: abort() + * Failure: NULL * * Programmer: Robb Matzke * Jul 10 1997 diff --git a/test/tmisc.c b/test/tmisc.c index 102325a..6da4589 100644 --- a/test/tmisc.c +++ b/test/tmisc.c @@ -30,6 +30,7 @@ #include "testhdf5.h" #include "H5srcdir.h" #include "H5Dpkg.h" /* Datasets */ +#include "H5MMprivate.h" /* Memory */ /* Definitions for misc. test #1 */ #define MISC1_FILE "tmisc1.h5" @@ -5526,6 +5527,64 @@ test_misc33(void) } /* end test_misc33() */ +/**************************************************************** +** +** test_misc34(): Ensure zero-size memory allocations work +** +****************************************************************/ +static void +test_misc34(void) +{ + void *mem = NULL; /* allocated buffer */ + char *dup = NULL; /* 'duplicated' string */ + size_t sz = 0; /* buffer size */ + + /* Output message about test being performed */ + MESSAGE(5, ("Testing O and NULL behavior in H5MM API calls")); + + /* H5MM_xfree(): Ensure that passing NULL is allowed and returns NULL */ + mem = H5MM_xfree(mem); + CHECK_PTR_NULL(mem, "H5MM_xfree"); + + /* H5MM_malloc(): Ensure that size 0 returns NULL */ + mem = H5MM_malloc(sz); + CHECK_PTR_NULL(mem, "H5MM_malloc"); + mem = H5MM_xfree(mem); + + /* H5MM_calloc(): Ensure that size 0 returns NULL */ + mem = H5MM_calloc(sz); + CHECK_PTR_NULL(mem, "H5MM_calloc"); + mem = H5MM_xfree(mem); + + /* H5MM_realloc(): Check behavior: + * + * H5MM_realloc(NULL, size) <==> H5MM_malloc(size) + * H5MM_realloc(ptr, 0) <==> H5MM_xfree(ptr) + * H5MM_realloc(NULL, 0) <==> NULL + */ + mem = H5MM_xfree(mem); + + sz = 1024; + mem = H5MM_realloc(mem, sz); + CHECK_PTR(mem, "H5MM_realloc (case 1)"); + /* Don't free mem here! */ + + sz = 0; + mem = H5MM_realloc(mem, sz); + CHECK_PTR_NULL(mem, "H5MM_realloc (case 2)"); + mem = H5MM_xfree(mem); + + mem = H5MM_realloc(mem, sz); + CHECK_PTR_NULL(mem, "H5MM_realloc (case 3)"); + mem = H5MM_xfree(mem); + + /* H5MM_xstrdup(): Ensure NULL returns NULL */ + dup = H5MM_xstrdup((const char *)mem); + CHECK_PTR_NULL(dup, "H5MM_xstrdup"); + dup = (char *)H5MM_xfree((void *)dup); + +} /* end test_misc34() */ + /**************************************************************** ** @@ -5575,6 +5634,7 @@ test_misc(void) test_misc31(); /* Test Reentering library through deprecated routines after H5close() */ test_misc32(); /* Test filter memory allocation functions */ test_misc33(); /* Test to verify that H5HL_offset_into() returns error if offset exceeds heap block */ + test_misc34(); /* Test behavior of 0 and NULL in H5MM API calls */ } /* test_misc() */ @@ -5632,5 +5692,5 @@ cleanup_misc(void) HDremove(MISC29_COPY_FILE); HDremove(MISC30_FILE); HDremove(MISC31_FILE); -} +} /* end cleanup_misc() */ -- cgit v0.12 From 0b846cee58af147e92a3ba7db45497fd9eaa09b4 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Thu, 9 Nov 2017 20:04:12 -0800 Subject: Cleaned up misc warnings in src and test. --- src/H5Dchunk.c | 2 +- src/H5Dcompact.c | 2 +- src/H5Dcontig.c | 2 +- src/H5FSint.c | 3 +-- src/H5Gnode.c | 6 +++--- test/filenotclosed.c | 6 +++--- 6 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index af6599a..0d7fcc9 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -5720,7 +5720,7 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) H5D_rdcc_ent_t *ent = NULL; /* Cache entry */ unsigned idx; /* Index of chunk in cache, if present */ unsigned u; /* Counter */ - H5D_shared_t *shared_fo = udata->cpy_info->shared_fo; + H5D_shared_t *shared_fo = (H5D_shared_t *)udata->cpy_info->shared_fo; /* See if the written chunk is in the chunk cache */ if(shared_fo && shared_fo->cache.chunk.nslots > 0) { diff --git a/src/H5Dcompact.c b/src/H5Dcompact.c index 041d28f..43e7754 100644 --- a/src/H5Dcompact.c +++ b/src/H5Dcompact.c @@ -431,7 +431,7 @@ H5D__compact_copy(H5F_t *f_src, H5O_storage_compact_t *_storage_src, H5F_t *f_ds void *bkg = NULL; /* Temporary buffer for copying data */ void *reclaim_buf = NULL; /* Buffer for reclaiming data */ hid_t buf_sid = -1; /* ID for buffer dataspace */ - H5D_shared_t *shared_fo = cpy_info->shared_fo; /* Pointer to the shared struct for dataset object */ + H5D_shared_t *shared_fo = (H5D_shared_t *)cpy_info->shared_fo; /* Pointer to the shared struct for dataset object */ H5O_storage_compact_t *storage_src = _storage_src; /* Pointer to storage_src */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Dcontig.c b/src/H5Dcontig.c index 86de017..aab4901 100644 --- a/src/H5Dcontig.c +++ b/src/H5Dcontig.c @@ -1363,7 +1363,7 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src, hsize_t buf_dim[1] = {0}; /* Dimension for buffer */ hbool_t is_vlen = FALSE; /* Flag to indicate that VL type conversion should occur */ hbool_t fix_ref = FALSE; /* Flag to indicate that ref values should be fixed */ - H5D_shared_t *shared_fo = cpy_info->shared_fo; /* Pointer to the shared struct for dataset object */ + H5D_shared_t *shared_fo = (H5D_shared_t *)cpy_info->shared_fo; /* Pointer to the shared struct for dataset object */ hbool_t try_sieve = FALSE; /* Try to get data from the sieve buffer */ haddr_t sieve_start = HADDR_UNDEF; /* Start location of sieve buffer */ haddr_t sieve_end = HADDR_UNDEF; /* End locations of sieve buffer */ diff --git a/src/H5FSint.c b/src/H5FSint.c index 4297291..264950d 100644 --- a/src/H5FSint.c +++ b/src/H5FSint.c @@ -96,10 +96,9 @@ H5FS_init(void) { herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOERR /* FUNC_ENTER() does all the work */ -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FS_init() */ diff --git a/src/H5Gnode.c b/src/H5Gnode.c index 76e2c4b..b335624 100644 --- a/src/H5Gnode.c +++ b/src/H5Gnode.c @@ -640,7 +640,7 @@ H5G_node_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, while(lt < rt) { idx = (int)((lt + rt) / 2); if((s = (const char *)H5HL_offset_into(udata->common.heap, sn->entry[idx].name_off)) == NULL) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get symbol table name") + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5B_INS_ERROR, "unable to get symbol table name") /* Check if symbol is already present */ if(0 == (cmp = HDstrcmp(udata->common.name, s))) @@ -802,8 +802,8 @@ H5G_node_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key/*in,out*/, const char *s; /* Pointer to string in local heap */ idx = (lt + rt) / 2; - if((s = H5HL_offset_into(udata->common.heap, sn->entry[idx].name_off)) == NULL) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get symbol table name") + if((s = (const char *)H5HL_offset_into(udata->common.heap, sn->entry[idx].name_off)) == NULL) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5B_INS_ERROR, "unable to get symbol table name") cmp = HDstrcmp(udata->common.name, s); if(cmp < 0) rt = idx; diff --git a/test/filenotclosed.c b/test/filenotclosed.c index d1f468a..2c5c8dc 100644 --- a/test/filenotclosed.c +++ b/test/filenotclosed.c @@ -19,8 +19,8 @@ #include "h5test.h" -#define FILENAME "filenotclosed" -#define DATASET "dset" +#define FILENAME "filenotclosed" +#define DATASET_NAME "dset" /*------------------------------------------------------------------------- * Function: catch_signal @@ -114,7 +114,7 @@ main(void) TEST_ERROR /* Create the dataset */ - if((did = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + if((did = H5Dcreate2(fid, DATASET_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR /* Write to the dataset */ -- cgit v0.12 From 576b9c5f5f955aa64814de2ec9f0493656e82f53 Mon Sep 17 00:00:00 2001 From: Neil Fortner Date: Fri, 10 Nov 2017 16:37:40 -0600 Subject: Fix HDFFV-10274. When deleting all (or almost all) of the messages in an object header chunk, where the total amount deleted was greater than 64K, an error would occur due to an off by one error in the code that handled that case. Fixed this and added a test case. --- src/H5Oalloc.c | 15 ++++----- test/tattr.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+), 7 deletions(-) diff --git a/src/H5Oalloc.c b/src/H5Oalloc.c index 3512d3e..478d950 100644 --- a/src/H5Oalloc.c +++ b/src/H5Oalloc.c @@ -2434,16 +2434,17 @@ H5O_alloc_shrink_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned chunkno) oh->nmesgs++; /* Initialize new null message to make the chunk large enough */ - oh->mesg[oh->nmesgs].type = H5O_MSG_NULL; - oh->mesg[oh->nmesgs].dirty = TRUE; - oh->mesg[oh->nmesgs].native = NULL; - oh->mesg[oh->nmesgs].raw = old_image + new_size + sizeof_msghdr - sizeof_chksum; - oh->mesg[oh->nmesgs].raw_size = MAX(H5O_ALIGN_OH(oh, min_chunk_size - total_msg_size), + curr_msg = &oh->mesg[oh->nmesgs - 1]; + curr_msg->type = H5O_MSG_NULL; + curr_msg->dirty = TRUE; + curr_msg->native = NULL; + curr_msg->raw = old_image + new_size + sizeof_msghdr - sizeof_chksum; + curr_msg->raw_size = MAX(H5O_ALIGN_OH(oh, min_chunk_size - total_msg_size), sizeof_msghdr) - sizeof_msghdr; - oh->mesg[oh->nmesgs].chunkno = chunkno; + curr_msg->chunkno = chunkno; /* update the new chunk size */ - new_size += oh->mesg[oh->nmesgs].raw_size + sizeof_msghdr; + new_size += curr_msg->raw_size + sizeof_msghdr; } /* end if */ /* Check for changing the chunk #0 data size enough to need adjusting the flags */ diff --git a/test/tattr.c b/test/tattr.c index 3b0c90e..5b00edc 100644 --- a/test/tattr.c +++ b/test/tattr.c @@ -10578,6 +10578,102 @@ test_attr_bug8(hid_t fcpl, hid_t fapl) /**************************************************************** ** +** test_attr_bug9(): Test basic H5A (attribute) code. +** (Really tests object header code). +** Tests adding several large attributes to an object until +** they convert to dense storage. The total size of all +** attributes is larger than 64K, causing the internal +** object header code to, after merging the deleted +** messages in to a NULL message, shrink the object header +** chunk. Do this twice: once with only attributes in the +** object header chunk and once with a (small) soft link in +** the chunk as well. In both cases, the shrunk chunk will +** initally be too small and a new NULL message must be +** created. +** +****************************************************************/ +static void +test_attr_bug9(hid_t fcpl, hid_t fapl) +{ + hid_t fid; /* File ID */ + hid_t gid; /* Group ID */ + hid_t aid; /* Attribute ID */ + hid_t sid; /* Dataspace ID */ + hsize_t dims[1] = {32768}; /* Attribute dimensions */ + int create_link; /* Whether to create a soft link */ + unsigned max_compact; /* Setting from fcpl */ + unsigned min_dense; /* Setting from fcpl */ + char aname[11]; /* Attribute name */ + unsigned i; /* Local index variable */ + herr_t ret; /* Generic return status */ + + /* Output message about test being performed */ + MESSAGE(5, ("Testing that attributes can always be added to named datatypes\n")); + + /* Create dataspace */ + sid = H5Screate_simple(1, dims, NULL); + CHECK(sid, FAIL, "H5Screate_simple"); + + /* Obtain attribute phase change settings */ + ret = H5Pget_attr_phase_change(fcpl, &max_compact, &min_dense); + CHECK(ret, FAIL, "H5Pget_attr_phase_change"); + + /* Run with and without the soft link */ + for(create_link = 0; create_link < 2; create_link++) { + /* Create file */ + fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl); + CHECK(fid, FAIL, "H5Fcreate"); + + /* Create second group */ + gid = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(gid, FAIL, "H5Gcreate2"); + + /* Close second group */ + ret = H5Gclose(gid); + CHECK(ret, FAIL, "H5Gclose"); + + /* Open root group */ + gid = H5Gopen2(fid, "/", H5P_DEFAULT); + CHECK(gid, FAIL, "H5Gopen2"); + + /* Create enough attributes to cause a change to dense storage */ + for(i = 0; i < max_compact + 1; i++) { + /* Create attribute */ + snprintf(aname, sizeof(aname), "%u", i); + aid = H5Acreate2(gid, aname, H5T_NATIVE_CHAR, sid, H5P_DEFAULT, H5P_DEFAULT); + CHECK(aid, FAIL, "H5Acreate2"); + + /* Close attribute */ + ret = H5Aclose(aid); + CHECK(ret, FAIL, "H5Aclose"); + + /* Create enough soft links that exactly one goes into chunk 1 if + * requested */ + if(i == 0 && create_link) { + ret = H5Lcreate_soft("b", gid, "a", H5P_DEFAULT, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Lcreate_soft"); + ret = H5Lcreate_soft("d", gid, "c", H5P_DEFAULT, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Lcreate_soft"); + ret = H5Lcreate_soft("f", gid, "e", H5P_DEFAULT, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Lcreate_soft"); + } /* end if */ + } /* end for */ + + /* Close IDs */ + ret = H5Gclose(gid); + CHECK(ret, FAIL, "H5Gclose"); + + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + } /* end for */ + + /* Close dataspace */ + ret = H5Sclose(sid); + CHECK(ret, FAIL, "H5Sclose"); +} /* test_attr_bug9() */ + +/**************************************************************** +** ** test_attr(): Main H5A (attribute) testing routine. ** ****************************************************************/ @@ -10724,6 +10820,7 @@ test_attr(void) test_attr_bug6(my_fcpl, my_fapl); /* Test reading empty attribute */ test_attr_bug7(my_fcpl, my_fapl); /* Test creating and deleting large attributes in ohdr chunk 0 */ test_attr_bug8(my_fcpl, my_fapl); /* Test attribute expanding object header with undecoded messages */ + test_attr_bug9(my_fcpl, my_fapl); /* Test large attributes converting to dense storage */ } /* end for */ } /* end if */ else { @@ -10752,6 +10849,7 @@ test_attr(void) * header format and in fact fails if used with the old format, due * to the attributes being larger than 64K */ test_attr_bug8(fcpl, my_fapl); /* Test attribute expanding object header with undecoded messages */ + test_attr_bug9(fcpl, my_fapl); /* Test large attributes converting to dense storage */ } /* end else */ } /* end for */ -- cgit v0.12 From 3a5e15819163e6e7c3de72a9ed8517ff200b02a7 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Sun, 12 Nov 2017 21:14:01 -0800 Subject: Fixed the problems with LDFLAGS and AM_LDFLAGS in filter plugins. --- test/Makefile.am | 8 ++++---- tools/test/h5diff/Makefile.am | 2 +- tools/test/h5dump/Makefile.am | 2 +- tools/test/h5ls/Makefile.am | 2 +- tools/test/h5repack/Makefile.am | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/test/Makefile.am b/test/Makefile.am index 4f192ac..efdc1ca 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -110,10 +110,10 @@ if HAVE_SHARED_CONDITIONAL libfilter_plugin2_dsets_la_SOURCES=filter_plugin2_dsets.c libfilter_plugin3_dsets_la_SOURCES=filter_plugin3_dsets.c libfilter_plugin4_groups_la_SOURCES=filter_plugin4_groups.c - libfilter_plugin1_dsets_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere - libfilter_plugin2_dsets_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere - libfilter_plugin3_dsets_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere - libfilter_plugin4_groups_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere + libfilter_plugin1_dsets_la_LDFLAGS=$(AM_LDFLAGS) -avoid-version -module -shared -export-dynamic -rpath /nowhere + libfilter_plugin2_dsets_la_LDFLAGS=$(AM_LDFLAGS) -avoid-version -module -shared -export-dynamic -rpath /nowhere + libfilter_plugin3_dsets_la_LDFLAGS=$(AM_LDFLAGS) -avoid-version -module -shared -export-dynamic -rpath /nowhere + libfilter_plugin4_groups_la_LDFLAGS=$(AM_LDFLAGS) -avoid-version -module -shared -export-dynamic -rpath /nowhere else # The libh5test library provides common support code for the tests. noinst_LTLIBRARIES=libh5test.la diff --git a/tools/test/h5diff/Makefile.am b/tools/test/h5diff/Makefile.am index 4d43a2a..a2ce9c4 100644 --- a/tools/test/h5diff/Makefile.am +++ b/tools/test/h5diff/Makefile.am @@ -52,7 +52,7 @@ if HAVE_SHARED_CONDITIONAL # Build it as shared library if configure is enabled for shared library. noinst_LTLIBRARIES=libdynlibdiff.la libdynlibdiff_la_SOURCES=dynlib_diff.c - libdynlibdiff_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere + libdynlibdiff_la_LDFLAGS=$(AM_LDFLAGS) -avoid-version -module -shared -export-dynamic -rpath /nowhere endif # Temporary files. *.h5 are generated by h5diff. They should diff --git a/tools/test/h5dump/Makefile.am b/tools/test/h5dump/Makefile.am index be21119..a7a2bcb 100644 --- a/tools/test/h5dump/Makefile.am +++ b/tools/test/h5dump/Makefile.am @@ -41,7 +41,7 @@ if HAVE_SHARED_CONDITIONAL # Build it as shared library if configure is enabled for shared library. noinst_LTLIBRARIES=libdynlibdump.la libdynlibdump_la_SOURCES=dynlib_dump.c - libdynlibdump_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere + libdynlibdump_la_LDFLAGS=$(AM_LDFLAGS) -avoid-version -module -shared -export-dynamic -rpath /nowhere endif # Temporary files. *.h5 are generated by h5dumpgentest. They should diff --git a/tools/test/h5ls/Makefile.am b/tools/test/h5ls/Makefile.am index a49c2e8..f5ec0f7 100644 --- a/tools/test/h5ls/Makefile.am +++ b/tools/test/h5ls/Makefile.am @@ -38,7 +38,7 @@ if HAVE_SHARED_CONDITIONAL # Build it as shared library if configure is enabled for shared library. noinst_LTLIBRARIES=libdynlibls.la libdynlibls_la_SOURCES=dynlib_ls.c - libdynlibls_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere + libdynlibls_la_LDFLAGS=$(AM_LDFLAGS) -avoid-version -module -shared -export-dynamic -rpath /nowhere endif diff --git a/tools/test/h5repack/Makefile.am b/tools/test/h5repack/Makefile.am index fbe88bd..ce7cad4 100644 --- a/tools/test/h5repack/Makefile.am +++ b/tools/test/h5repack/Makefile.am @@ -48,8 +48,8 @@ if HAVE_SHARED_CONDITIONAL noinst_LTLIBRARIES=libdynlibadd.la libdynlibvers.la libdynlibadd_la_SOURCES=dynlib_rpk.c libdynlibvers_la_SOURCES=dynlib_vrpk.c - libdynlibadd_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere - libdynlibvers_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -rpath /nowhere + libdynlibadd_la_LDFLAGS=$(AM_LDFLAGS) -avoid-version -module -shared -export-dynamic -rpath /nowhere + libdynlibvers_la_LDFLAGS=$(AM_LDFLAGS) -avoid-version -module -shared -export-dynamic -rpath /nowhere endif -- cgit v0.12 From a25366cc980695cebe40c2d471bfe5166dcb28a2 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Sun, 12 Nov 2017 23:22:39 -0800 Subject: Fixed that annoying ar warning about -u being ignored. --- config/linux-gnulibc1 | 5 +++++ configure.ac | 2 ++ src/libhdf5.settings.in | 1 + 3 files changed, 8 insertions(+) diff --git a/config/linux-gnulibc1 b/config/linux-gnulibc1 index 39225e7..c32f64e 100644 --- a/config/linux-gnulibc1 +++ b/config/linux-gnulibc1 @@ -30,6 +30,11 @@ if test -z "$CC"; then fi fi +# Set flags for gnu ar (apparently via libtool, so AR_FLAGS, not ARFLAGS) +# If you don't do this, you will get warnings about the 'u' in +# automake's default 'cru' args. +AR_FLAGS=crD + # Figure out GNU C compiler flags . $srcdir/config/gnu-flags diff --git a/configure.ac b/configure.ac index d8f3873..50893f7 100644 --- a/configure.ac +++ b/configure.ac @@ -99,6 +99,7 @@ AC_CONFIG_COMMANDS([pubconf], [ AC_CANONICAL_HOST AC_SUBST([CPPFLAGS]) AC_SUBST([JNIFLAGS]) +AC_SUBST([AR_FLAGS]) ## H5_CFLAGS (and company) are for CFLAGS that should be used on HDF5, but ## not exported to h5cc (or h5fc, etc.) @@ -139,6 +140,7 @@ JNIFLAGS="${JNIFLAGS}" JAVACFLAGS="${JAVACFLAGS}" JAVAFLAGS="${JAVAFLAGS}" LDFLAGS="${LDFLAGS}" +AR_FLAGS="${AR_FLAGS}" ## Configure may need to alter any of the *FLAGS variables in order for ## various checks to work correctly. Save the user's value here so it diff --git a/src/libhdf5.settings.in b/src/libhdf5.settings.in index 8017594..51b24dc 100644 --- a/src/libhdf5.settings.in +++ b/src/libhdf5.settings.in @@ -28,6 +28,7 @@ Linking Options: AM_LDFLAGS: @AM_LDFLAGS@ Extra libraries: @LIBS@ Archiver: @AR@ + AR_FLAGS: @AR_FLAGS@ Ranlib: @RANLIB@ Languages: -- cgit v0.12 From bca20b40b4966552a844051c3d912d6aec50592f Mon Sep 17 00:00:00 2001 From: Neil Fortner Date: Mon, 13 Nov 2017 13:43:32 -0600 Subject: Initialize hid_t variables in test_Attr_bug9. --- test/tattr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/tattr.c b/test/tattr.c index 5b00edc..5eaa882 100644 --- a/test/tattr.c +++ b/test/tattr.c @@ -10595,10 +10595,10 @@ test_attr_bug8(hid_t fcpl, hid_t fapl) static void test_attr_bug9(hid_t fcpl, hid_t fapl) { - hid_t fid; /* File ID */ - hid_t gid; /* Group ID */ - hid_t aid; /* Attribute ID */ - hid_t sid; /* Dataspace ID */ + hid_t fid = -1; /* File ID */ + hid_t gid = -1; /* Group ID */ + hid_t aid = -1; /* Attribute ID */ + hid_t sid = -1; /* Dataspace ID */ hsize_t dims[1] = {32768}; /* Attribute dimensions */ int create_link; /* Whether to create a soft link */ unsigned max_compact; /* Setting from fcpl */ -- cgit v0.12 From 00e640368e71eac1adeb9f630c6de15261b26083 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Tue, 14 Nov 2017 09:47:04 -0600 Subject: Fix Windows link error --- test/tattr.c | 758 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 379 insertions(+), 379 deletions(-) diff --git a/test/tattr.c b/test/tattr.c index 5eaa882..d7152ed 100644 --- a/test/tattr.c +++ b/test/tattr.c @@ -13,7 +13,7 @@ /*********************************************************** * -* Test program: tattr +* Test program: tattr * * Test the attribute functionality * @@ -27,25 +27,25 @@ * This file needs to access private information from the H5O package. * This file also needs to access the object header testing code. */ -#define H5O_FRIEND /*suppress error about including H5Opkg */ +#define H5O_FRIEND /*suppress error about including H5Opkg */ #define H5O_TESTING -#include "H5Opkg.h" /* Object headers */ +#include "H5Opkg.h" /* Object headers */ /* * This file needs to access private information from the H5A package. * This file also needs to access the attribute testing code. */ -#define H5A_FRIEND /*suppress error about including H5Apkg */ +#define H5A_FRIEND /*suppress error about including H5Apkg */ #define H5A_TESTING -#include "H5Apkg.h" /* Attributes */ +#include "H5Apkg.h" /* Attributes */ /* * This file needs to access private information from the H5F package. * This file also needs to access the file testing code. */ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5F_FRIEND /*suppress error about including H5Fpkg */ #define H5F_TESTING -#include "H5Fpkg.h" /* File access */ +#include "H5Fpkg.h" /* File access */ #define FILENAME "tattr.h5" #define NAME_BUF_SIZE 1024 @@ -55,10 +55,10 @@ #define CORDER_ITER_STOP 3 /* 3-D dataset with fixed dimensions */ -#define SPACE1_RANK 3 -#define SPACE1_DIM1 3 -#define SPACE1_DIM2 15 -#define SPACE1_DIM3 13 +#define SPACE1_RANK 3 +#define SPACE1_DIM1 3 +#define SPACE1_DIM2 15 +#define SPACE1_DIM3 13 /* Dataset Information */ #define DSET1_NAME "Dataset1" @@ -76,8 +76,8 @@ /* Attribute Rank & Dimensions */ #define ATTR1_NAME "Attr1" -#define ATTR1_RANK 1 -#define ATTR1_DIM1 3 +#define ATTR1_RANK 1 +#define ATTR1_DIM1 3 int attr_data1[ATTR1_DIM1]={512,-234,98123}; /* Test data for 1st attribute */ /* rank & dimensions for another attribute */ @@ -85,25 +85,25 @@ int attr_data1[ATTR1_DIM1]={512,-234,98123}; /* Test data for 1st attribute */ int attr_data1a[ATTR1_DIM1]={256,11945,-22107}; #define ATTR2_NAME "Attr2" -#define ATTR2_RANK 2 -#define ATTR2_DIM1 2 -#define ATTR2_DIM2 2 +#define ATTR2_RANK 2 +#define ATTR2_DIM1 2 +#define ATTR2_DIM2 2 int attr_data2[ATTR2_DIM1][ATTR2_DIM2]={{7614,-416},{197814,-3}}; /* Test data for 2nd attribute */ #define ATTR3_NAME "Attr3" -#define ATTR3_RANK 3 -#define ATTR3_DIM1 2 -#define ATTR3_DIM2 2 -#define ATTR3_DIM3 2 +#define ATTR3_RANK 3 +#define ATTR3_DIM1 2 +#define ATTR3_DIM2 2 +#define ATTR3_DIM3 2 double attr_data3[ATTR3_DIM1][ATTR3_DIM2][ATTR3_DIM3]={{{2.3F,-26.1F}, {0.123F,-10.0F}},{{973.23F,-0.91827F},{2.0F,23.0F}}}; /* Test data for 3rd attribute */ #define ATTR4_NAME "Attr4" -#define ATTR4_RANK 2 -#define ATTR4_DIM1 2 -#define ATTR4_DIM2 2 -#define ATTR4_FIELDNAME1 "i" -#define ATTR4_FIELDNAME2 "d" -#define ATTR4_FIELDNAME3 "c" +#define ATTR4_RANK 2 +#define ATTR4_DIM1 2 +#define ATTR4_DIM2 2 +#define ATTR4_FIELDNAME1 "i" +#define ATTR4_FIELDNAME2 "d" +#define ATTR4_FIELDNAME3 "c" size_t attr4_field1_off=0; size_t attr4_field2_off=0; size_t attr4_field3_off=0; @@ -115,13 +115,13 @@ struct attr4_struct { {{-23,981724.2F,'Q'},{0,2.0F,'\n'}}}; /* Test data for 4th attribute */ #define ATTR5_NAME "Attr5" -#define ATTR5_RANK 0 +#define ATTR5_RANK 0 float attr_data5=-5.123F; /* Test data for 5th attribute */ -#define ATTR6_RANK 3 -#define ATTR6_DIM1 100 -#define ATTR6_DIM2 100 -#define ATTR6_DIM3 100 +#define ATTR6_RANK 3 +#define ATTR6_DIM1 100 +#define ATTR6_DIM2 100 +#define ATTR6_DIM3 100 #define ATTR7_NAME "attr 1 - 000000" #define ATTR8_NAME "attr 2" @@ -163,21 +163,21 @@ static herr_t attr_op1(hid_t loc_id, const char *name, const H5A_info_t *ainfo, static void test_attr_basic_write(hid_t fapl) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t group; /* Group ID */ - hid_t sid1,sid2; /* Dataspace ID */ - hid_t attr, attr2; /* Attribute ID */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t group; /* Group ID */ + hid_t sid1,sid2; /* Dataspace ID */ + hid_t attr, attr2; /* Attribute ID */ hsize_t attr_size; /* storage size for attribute */ ssize_t attr_name_size; /* size of attribute name */ char *attr_name=NULL; /* name of attribute */ - hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; - hsize_t dims2[] = {ATTR1_DIM1}; - hsize_t dims3[] = {ATTR2_DIM1,ATTR2_DIM2}; + hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + hsize_t dims2[] = {ATTR1_DIM1}; + hsize_t dims3[] = {ATTR2_DIM1,ATTR2_DIM2}; int read_data1[ATTR1_DIM1]={0}; /* Buffer for reading 1st attribute */ int i; - hid_t ret_id; /* Generic hid_t return value */ - herr_t ret; /* Generic return value */ + hid_t ret_id; /* Generic hid_t return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Basic Scalar Attribute Writing Functions\n")); @@ -278,7 +278,7 @@ test_attr_basic_write(hid_t fapl) if(attr_name_size > 0) { attr_name = (char*)HDcalloc((size_t)(attr_name_size + 1), sizeof(char)); CHECK(attr_name, NULL, "HDcalloc"); - + if(attr_name) { ret = (herr_t)H5Aget_name(attr, (size_t)(attr_name_size + 1), attr_name); CHECK(ret, FAIL, "H5Aget_name"); @@ -314,7 +314,7 @@ test_attr_basic_write(hid_t fapl) if(attr_name_size > 0) { attr_name = (char*)HDcalloc((size_t)(attr_name_size+1), sizeof(char)); CHECK(attr_name, NULL, "HDcalloc"); - + if(attr_name) { ret = (herr_t)H5Aget_name(attr2, (size_t)(attr_name_size + 1), attr_name); CHECK(ret, FAIL, "H5Aget_name"); @@ -402,15 +402,15 @@ test_attr_basic_write(hid_t fapl) static void test_attr_basic_read(hid_t fapl) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t group; /* Group ID */ - hid_t attr; /* Attribute ID */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t group; /* Group ID */ + hid_t attr; /* Attribute ID */ H5O_info_t oinfo; /* Object info */ int read_data1[ATTR1_DIM1] = {0}; /* Buffer for reading 1st attribute */ int read_data2[ATTR2_DIM1][ATTR2_DIM2] = {{0}}; /* Buffer for reading 2nd attribute */ int i, j; /* Local index variables */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Basic Attribute Functions\n")); @@ -500,7 +500,7 @@ test_attr_flush(hid_t fapl) set; /* Dataset ID */ double wdata=3.14159F; /* Data to write */ double rdata; /* Data read in */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Attribute Flushing\n")); @@ -560,15 +560,15 @@ test_attr_flush(hid_t fapl) static void test_attr_plist(hid_t fapl) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1,sid2; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1,sid2; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ hid_t plist; /* Property list ID */ - hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; - hsize_t dims2[] = {ATTR1_DIM1}; + hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + hsize_t dims2[] = {ATTR1_DIM1}; H5T_cset_t cset; /* Character set for attributes */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Attribute Property Lists\n")); @@ -674,15 +674,15 @@ test_attr_plist(hid_t fapl) static void test_attr_compound_write(hid_t fapl) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ hid_t tid1; /* Attribute datatype ID */ - hid_t sid1,sid2; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; - hsize_t dims2[] = {ATTR4_DIM1,ATTR4_DIM2}; - hid_t ret_id; /* Generic hid_t return value */ - herr_t ret; /* Generic return value */ + hid_t sid1,sid2; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + hsize_t dims2[] = {ATTR4_DIM1,ATTR4_DIM2}; + hid_t ret_id; /* Generic hid_t return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Multiple Attribute Functions\n")); @@ -762,11 +762,11 @@ test_attr_compound_write(hid_t fapl) static void test_attr_compound_read(hid_t fapl) { - hid_t fid1; /* HDF5 File ID */ - hid_t dataset; /* Dataset ID */ + hid_t fid1; /* HDF5 File ID */ + hid_t dataset; /* Dataset ID */ hid_t space; /* Attribute dataspace */ hid_t type; /* Attribute datatype */ - hid_t attr; /* Attribute ID */ + hid_t attr; /* Attribute ID */ char attr_name[ATTR_NAME_LEN]; /* Buffer for attribute names */ int rank; /* Attribute rank */ hsize_t dims[ATTR_MAX_DIMS]; /* Attribute dimensions */ @@ -781,7 +781,7 @@ test_attr_compound_read(hid_t fapl) ssize_t name_len; /* Length of attribute name */ H5O_info_t oinfo; /* Object info */ int i, j; /* Local index variables */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Basic Attribute Functions\n")); @@ -912,13 +912,13 @@ test_attr_compound_read(hid_t fapl) static void test_attr_scalar_write(hid_t fapl) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1,sid2; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; - hid_t ret_id; /* Generic hid_t return value */ - herr_t ret; /* Generic return value */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1,sid2; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + hid_t ret_id; /* Generic hid_t return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Basic Attribute Functions\n")); @@ -978,14 +978,14 @@ test_attr_scalar_write(hid_t fapl) static void test_attr_scalar_read(hid_t fapl) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ H5S_class_t stype; /* Dataspace class */ float rdata = 0.0F; /* Buffer for reading 1st attribute */ H5O_info_t oinfo; /* Object info */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Basic Scalar Attribute Reading Functions\n")); @@ -1013,8 +1013,8 @@ test_attr_scalar_read(hid_t fapl) /* Verify the floating-poing value in this way to avoid compiler warning. */ if(!H5_FLT_ABS_EQUAL(rdata, attr_data5)) - printf("*** UNEXPECTED VALUE from %s should be %f, but is %f at line %4d in %s\n", - "H5Aread", (double)attr_data5, (double)rdata, (int)__LINE__, __FILE__); + printf("*** UNEXPECTED VALUE from %s should be %f, but is %f at line %4d in %s\n", + "H5Aread", (double)attr_data5, (double)rdata, (int)__LINE__, __FILE__); /* Get the attribute's dataspace */ sid = H5Aget_space(attr); @@ -1050,16 +1050,16 @@ test_attr_scalar_read(hid_t fapl) static void test_attr_mult_write(hid_t fapl) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1,sid2; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; - hsize_t dims2[] = {ATTR1_DIM1}; - hsize_t dims3[] = {ATTR2_DIM1,ATTR2_DIM2}; - hsize_t dims4[] = {ATTR3_DIM1,ATTR3_DIM2,ATTR3_DIM3}; - hid_t ret_id; /* Generic hid_t return value */ - herr_t ret; /* Generic return value */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1,sid2; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + hsize_t dims2[] = {ATTR1_DIM1}; + hsize_t dims3[] = {ATTR2_DIM1,ATTR2_DIM2}; + hsize_t dims4[] = {ATTR3_DIM1,ATTR3_DIM2,ATTR3_DIM3}; + hid_t ret_id; /* Generic hid_t return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Multiple Attribute Functions\n")); @@ -1170,11 +1170,11 @@ test_attr_mult_write(hid_t fapl) static void test_attr_mult_read(hid_t fapl) { - hid_t fid1; /* HDF5 File ID */ - hid_t dataset; /* Dataset ID */ + hid_t fid1; /* HDF5 File ID */ + hid_t dataset; /* Dataset ID */ hid_t space; /* Attribute dataspace */ hid_t type; /* Attribute datatype */ - hid_t attr; /* Attribute ID */ + hid_t attr; /* Attribute ID */ char attr_name[ATTR_NAME_LEN]; /* Buffer for attribute names */ char temp_name[ATTR_NAME_LEN]; /* Buffer for mangling attribute names */ int rank; /* Attribute rank */ @@ -1188,7 +1188,7 @@ test_attr_mult_read(hid_t fapl) ssize_t name_len; /* Length of attribute name */ H5O_info_t oinfo; /* Object info */ int i, j, k; /* Local index values */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Basic Attribute Functions\n")); @@ -1432,12 +1432,12 @@ attr_op1(hid_t H5_ATTR_UNUSED loc_id, const char *name, const H5A_info_t H5_ATTR static void test_attr_iterate(hid_t fapl) { - hid_t file; /* HDF5 File ID */ - hid_t dataset; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ + hid_t file; /* HDF5 File ID */ + hid_t dataset; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ int count; /* operator data for the iterator */ H5O_info_t oinfo; /* Object info */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Basic Attribute Functions\n")); @@ -1504,13 +1504,13 @@ test_attr_iterate(hid_t fapl) static void test_attr_delete(hid_t fapl) { - hid_t fid1; /* HDF5 File ID */ - hid_t dataset; /* Dataset ID */ - hid_t attr; /* Attribute ID */ + hid_t fid1; /* HDF5 File ID */ + hid_t dataset; /* Dataset ID */ + hid_t attr; /* Attribute ID */ char attr_name[ATTR_NAME_LEN]; /* Buffer for attribute names */ ssize_t name_len; /* Length of attribute name */ H5O_info_t oinfo; /* Object info */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Basic Attribute Functions\n")); @@ -1635,7 +1635,7 @@ test_attr_dtype_shared(hid_t fapl) H5O_info_t oinfo; /* Object's information */ h5_stat_size_t empty_filesize; /* Size of empty file */ h5_stat_size_t filesize; /* Size of file after modifications */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Shared Datatypes with Attributes\n")); @@ -1802,17 +1802,17 @@ test_attr_dtype_shared(hid_t fapl) static void test_attr_duplicate_ids(hid_t fapl) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t gid1, gid2; /* Group ID */ - hid_t sid1,sid2; /* Dataspace ID */ - hid_t attr, attr2; /* Attribute ID */ - hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; - hsize_t dims2[] = {ATTR1_DIM1}; + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t gid1, gid2; /* Group ID */ + hid_t sid1,sid2; /* Dataspace ID */ + hid_t attr, attr2; /* Attribute ID */ + hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + hsize_t dims2[] = {ATTR1_DIM1}; int read_data1[ATTR1_DIM1]={0}; /* Buffer for reading 1st attribute */ int rewrite_data[ATTR1_DIM1]={1234, -423, 9907256}; /* Test data for rewrite */ int i; - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing operations with two ID handles\n")); @@ -2047,12 +2047,12 @@ test_attr_duplicate_ids(hid_t fapl) static int test_attr_dense_verify(hid_t loc_id, unsigned max_attr) { - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ - hid_t attr; /* Attribute ID */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + hid_t attr; /* Attribute ID */ unsigned value; /* Attribute value */ unsigned u; /* Local index variable */ int old_nerrs; /* Number of errors when entering this check */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Retrieve the current # of reported errors */ old_nerrs = GetTestNumErrs(); @@ -2117,19 +2117,19 @@ test_attr_dense_verify(hid_t loc_id, unsigned max_attr) static void test_attr_dense_create(hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dataset; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + hid_t fid; /* HDF5 File ID */ + hid_t dataset; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ unsigned max_compact; /* Maximum # of attributes to store compactly */ unsigned min_dense; /* Minimum # of attributes to store "densely" */ - htri_t is_dense; /* Are attributes stored densely? */ + htri_t is_dense; /* Are attributes stored densely? */ unsigned u; /* Local index variable */ h5_stat_size_t empty_filesize; /* Size of empty file */ h5_stat_size_t filesize; /* Size of file after modifications */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Dense Attribute Storage Creation\n")); @@ -2248,19 +2248,19 @@ test_attr_dense_create(hid_t fcpl, hid_t fapl) static void test_attr_dense_open(hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dataset; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + hid_t fid; /* HDF5 File ID */ + hid_t dataset; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ unsigned max_compact; /* Maximum # of attributes to store compactly */ unsigned min_dense; /* Minimum # of attributes to store "densely" */ - htri_t is_dense; /* Are attributes stored densely? */ + htri_t is_dense; /* Are attributes stored densely? */ unsigned u; /* Local index variable */ h5_stat_size_t empty_filesize; /* Size of empty file */ h5_stat_size_t filesize; /* Size of file after modifications */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Opening Attributes in Dense Storage\n")); @@ -2387,20 +2387,20 @@ test_attr_dense_open(hid_t fcpl, hid_t fapl) static void test_attr_dense_delete(hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dataset; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + hid_t fid; /* HDF5 File ID */ + hid_t dataset; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ unsigned max_compact; /* Maximum # of attributes to store compactly */ unsigned min_dense; /* Minimum # of attributes to store "densely" */ - htri_t is_dense; /* Are attributes stored densely? */ + htri_t is_dense; /* Are attributes stored densely? */ unsigned u; /* Local index variable */ h5_stat_size_t empty_filesize; /* Size of empty file */ h5_stat_size_t filesize; /* Size of file after modifications */ H5O_info_t oinfo; /* Object info */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Deleting Attributes in Dense Storage\n")); @@ -2565,21 +2565,21 @@ test_attr_dense_delete(hid_t fcpl, hid_t fapl) static void test_attr_dense_rename(hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dataset; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ - char new_attrname[NAME_BUF_SIZE]; /* New name of attribute */ + hid_t fid; /* HDF5 File ID */ + hid_t dataset; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + char new_attrname[NAME_BUF_SIZE]; /* New name of attribute */ unsigned max_compact; /* Maximum # of attributes to store compactly */ unsigned min_dense; /* Minimum # of attributes to store "densely" */ - htri_t is_dense; /* Are attributes stored densely? */ + htri_t is_dense; /* Are attributes stored densely? */ h5_stat_size_t empty_filesize; /* Size of empty file */ h5_stat_size_t filesize; /* Size of file after modifications */ H5O_info_t oinfo; /* Object info */ unsigned u; /* Local index variable */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Renaming Attributes in Dense Storage\n")); @@ -2724,21 +2724,21 @@ test_attr_dense_rename(hid_t fcpl, hid_t fapl) static void test_attr_dense_unlink(hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dataset; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + hid_t fid; /* HDF5 File ID */ + hid_t dataset; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ unsigned max_compact; /* Maximum # of attributes to store compactly */ unsigned min_dense; /* Minimum # of attributes to store "densely" */ - htri_t is_dense; /* Are attributes stored densely? */ + htri_t is_dense; /* Are attributes stored densely? */ size_t mesg_count; /* # of shared messages */ h5_stat_size_t empty_filesize; /* Size of empty file */ h5_stat_size_t filesize; /* Size of file after modifications */ H5O_info_t oinfo; /* Object info */ unsigned u; /* Local index variable */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Unlinking Object with Attributes in Dense Storage\n")); @@ -2854,19 +2854,19 @@ test_attr_dense_unlink(hid_t fcpl, hid_t fapl) static void test_attr_dense_limits(hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dataset; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + hid_t fid; /* HDF5 File ID */ + hid_t dataset; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ unsigned max_compact, rmax_compact; /* Maximum # of attributes to store compactly */ unsigned min_dense, rmin_dense; /* Minimum # of attributes to store "densely" */ - htri_t is_dense; /* Are attributes stored densely? */ + htri_t is_dense; /* Are attributes stored densely? */ unsigned u; /* Local index variable */ h5_stat_size_t empty_filesize; /* Size of empty file */ h5_stat_size_t filesize; /* Size of file after modifications */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Phase Change Limits For Attributes in Dense Storage\n")); @@ -3019,23 +3019,23 @@ test_attr_dense_limits(hid_t fcpl, hid_t fapl) static void test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dataset; /* Dataset ID */ - hid_t gid1, gid2; /* Group ID */ - hid_t sid, sid2; /* Dataspace ID */ - hid_t attr, attr2, add_attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ - hsize_t dims[] = {ATTR1_DIM1}; + hid_t fid; /* HDF5 File ID */ + hid_t dataset; /* Dataset ID */ + hid_t gid1, gid2; /* Group ID */ + hid_t sid, sid2; /* Dataspace ID */ + hid_t attr, attr2, add_attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + hsize_t dims[] = {ATTR1_DIM1}; int read_data1[ATTR1_DIM1]={0}; /* Buffer for reading attribute */ int rewrite_data[ATTR1_DIM1]={1234, -423, 9907256}; /* Test data for rewrite */ unsigned scalar_data = 1317; /* scalar data for attribute */ unsigned read_scalar; /* variable for reading attribute*/ unsigned max_compact; /* Maximum # of attributes to store compactly */ unsigned min_dense; /* Minimum # of attributes to store "densely" */ - htri_t is_dense; /* Are attributes stored densely? */ + htri_t is_dense; /* Are attributes stored densely? */ unsigned u, i; /* Local index variable */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing operations with two IDs for Dense Storage\n")); @@ -3542,24 +3542,24 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl) static void test_attr_big(hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dataset; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t big_sid; /* "Big" dataspace ID */ + hid_t fid; /* HDF5 File ID */ + hid_t dataset; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t big_sid; /* "Big" dataspace ID */ hsize_t dims[ATTR6_RANK] = {ATTR6_DIM1, ATTR6_DIM2, ATTR6_DIM3}; /* Attribute dimensions */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ unsigned max_compact; /* Maximum # of attributes to store compactly */ unsigned min_dense; /* Minimum # of attributes to store "densely" */ unsigned nshared_indices; /* # of shared message indices */ H5F_libver_t low, high; /* File format bounds */ - htri_t is_empty; /* Are there any attributes? */ - htri_t is_dense; /* Are attributes stored densely? */ + htri_t is_empty; /* Are there any attributes? */ + htri_t is_dense; /* Are attributes stored densely? */ unsigned u; /* Local index variable */ h5_stat_size_t empty_filesize; /* Size of empty file */ h5_stat_size_t filesize; /* Size of file after modifications */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Storing 'Big' Attributes in Dense Storage\n")); @@ -3812,20 +3812,20 @@ test_attr_big(hid_t fcpl, hid_t fapl) static void test_attr_null_space(hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dataset; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t null_sid; /* "null" dataspace ID */ - hid_t attr_sid; /* Attribute's dataspace ID */ - hid_t attr; /* Attribute ID */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + hid_t fid; /* HDF5 File ID */ + hid_t dataset; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t null_sid; /* "null" dataspace ID */ + hid_t attr_sid; /* Attribute's dataspace ID */ + hid_t attr; /* Attribute ID */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ unsigned value; /* Attribute value */ htri_t cmp; /* Results of comparison */ hsize_t storage_size; /* Size of storage for attribute */ H5A_info_t ainfo; /* Attribute info */ h5_stat_size_t empty_filesize; /* Size of empty file */ h5_stat_size_t filesize; /* Size of file after modifications */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Storing Attributes with 'null' dataspace\n")); @@ -4031,11 +4031,11 @@ static void test_attr_deprec(hid_t fcpl, hid_t fapl) { #ifndef H5_NO_DEPRECATED_SYMBOLS - hid_t fid; /* HDF5 File ID */ - hid_t dataset; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - herr_t ret; /* Generic return value */ + hid_t fid; /* HDF5 File ID */ + hid_t dataset; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Deprecated Attribute Routines\n")); @@ -4139,15 +4139,15 @@ test_attr_deprec(hid_t fcpl, hid_t fapl) static void test_attr_many(hbool_t new_format, hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t gid; /* Group ID */ - hid_t sid; /* Dataspace ID */ - hid_t aid; /* Attribute ID */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + hid_t fid; /* HDF5 File ID */ + hid_t gid; /* Group ID */ + hid_t sid; /* Dataspace ID */ + hid_t aid; /* Attribute ID */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ unsigned nattr = (new_format ? NATTR_MANY_NEW : NATTR_MANY_OLD); /* Number of attributes */ htri_t exists; /* Whether the attribute exists or not */ unsigned u; /* Local index variable */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Storing Many Attributes\n")); @@ -4268,14 +4268,14 @@ test_attr_many(hbool_t new_format, hid_t fcpl, hid_t fapl) static void test_attr_corder_create_basic(hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dataset; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t dcpl; /* Dataset creation property list ID */ + hid_t fid; /* HDF5 File ID */ + hid_t dataset; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t dcpl; /* Dataset creation property list ID */ unsigned crt_order_flags;/* Creation order flags */ - htri_t is_empty; /* Are there any attributes? */ - htri_t is_dense; /* Are attributes stored densely? */ - herr_t ret; /* Generic return value */ + htri_t is_empty; /* Are there any attributes? */ + htri_t is_dense; /* Are attributes stored densely? */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Basic Code for Attributes with Creation Order Info\n")); @@ -4384,21 +4384,21 @@ test_attr_corder_create_basic(hid_t fcpl, hid_t fapl) static void test_attr_corder_create_compact(hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dset1, dset2, dset3; /* Dataset IDs */ - hid_t my_dataset; /* Current dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ + hid_t fid; /* HDF5 File ID */ + hid_t dset1, dset2, dset3; /* Dataset IDs */ + hid_t my_dataset; /* Current dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ unsigned max_compact; /* Maximum # of links to store in group compactly */ unsigned min_dense; /* Minimum # of links to store in group "densely" */ - htri_t is_empty; /* Are there any attributes? */ - htri_t is_dense; /* Are attributes stored densely? */ + htri_t is_empty; /* Are there any attributes? */ + htri_t is_dense; /* Are attributes stored densely? */ hsize_t nattrs; /* Number of attributes on object */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ unsigned curr_dset; /* Current dataset to work on */ unsigned u; /* Local index variable */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Compact Storage of Attributes with Creation Order Info\n")); @@ -4582,23 +4582,23 @@ test_attr_corder_create_compact(hid_t fcpl, hid_t fapl) static void test_attr_corder_create_dense(hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dset1, dset2, dset3; /* Dataset IDs */ - hid_t my_dataset; /* Current dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ + hid_t fid; /* HDF5 File ID */ + hid_t dset1, dset2, dset3; /* Dataset IDs */ + hid_t my_dataset; /* Current dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ unsigned max_compact; /* Maximum # of links to store in group compactly */ unsigned min_dense; /* Minimum # of links to store in group "densely" */ - htri_t is_empty; /* Are there any attributes? */ - htri_t is_dense; /* Are attributes stored densely? */ + htri_t is_empty; /* Are there any attributes? */ + htri_t is_dense; /* Are attributes stored densely? */ hsize_t nattrs; /* Number of attributes on object */ hsize_t name_count; /* # of records in name index */ hsize_t corder_count; /* # of records in creation order index */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ unsigned curr_dset; /* Current dataset to work on */ unsigned u; /* Local index variable */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Dense Storage of Attributes with Creation Order Info\n")); @@ -4816,7 +4816,7 @@ test_attr_corder_create_reopen(hid_t fcpl, hid_t fapl) hid_t sid = -1; /* Dataspace ID */ hid_t aid = -1; /* Attribute ID */ int buf; /* Attribute data */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Creating Attributes w/New & Old Format\n")); @@ -4917,23 +4917,23 @@ test_attr_corder_create_reopen(hid_t fcpl, hid_t fapl) static void test_attr_corder_transition(hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dset1, dset2, dset3; /* Dataset IDs */ - hid_t my_dataset; /* Current dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ + hid_t fid; /* HDF5 File ID */ + hid_t dset1, dset2, dset3; /* Dataset IDs */ + hid_t my_dataset; /* Current dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ unsigned max_compact; /* Maximum # of links to store in group compactly */ unsigned min_dense; /* Minimum # of links to store in group "densely" */ - htri_t is_empty; /* Are there any attributes? */ - htri_t is_dense; /* Are attributes stored densely? */ + htri_t is_empty; /* Are there any attributes? */ + htri_t is_dense; /* Are attributes stored densely? */ hsize_t nattrs; /* Number of attributes on object */ hsize_t name_count; /* # of records in name index */ hsize_t corder_count; /* # of records in creation order index */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ unsigned curr_dset; /* Current dataset to work on */ unsigned u; /* Local index variable */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Storage Transitions of Attributes with Creation Order Info\n")); @@ -5323,28 +5323,28 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl) static void test_attr_corder_delete(hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dset1, dset2, dset3; /* Dataset IDs */ - hid_t my_dataset; /* Current dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ + hid_t fid; /* HDF5 File ID */ + hid_t dset1, dset2, dset3; /* Dataset IDs */ + hid_t my_dataset; /* Current dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ unsigned max_compact; /* Maximum # of links to store in group compactly */ unsigned min_dense; /* Minimum # of links to store in group "densely" */ - htri_t is_empty; /* Are there any attributes? */ - htri_t is_dense; /* Are attributes stored densely? */ + htri_t is_empty; /* Are there any attributes? */ + htri_t is_dense; /* Are attributes stored densely? */ hsize_t nattrs; /* Number of attributes on object */ hsize_t name_count; /* # of records in name index */ hsize_t corder_count; /* # of records in creation order index */ unsigned reopen_file; /* Whether to re-open the file before deleting group */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ #ifdef LATER h5_stat_size_t empty_size; /* Size of empty file */ h5_stat_size_t file_size; /* Size of file after operating on it */ #endif /* LATER */ unsigned curr_dset; /* Current dataset to work on */ unsigned u; /* Local index variable */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Deleting Object w/Dense Attribute Storage and Creation Order Info\n")); @@ -5521,7 +5521,7 @@ test_attr_corder_delete(hid_t fcpl, hid_t fapl) * Purpose: Support routine for attr_info_by_idx, to verify the attribute * info is correct for a attribute * - * Note: This routine assumes that the attributes have been added to the + * Note: This routine assumes that the attributes have been added to the * object in alphabetical order. * * Return: Success: 0 @@ -5539,7 +5539,7 @@ attr_info_by_idx_check(hid_t obj_id, const char *attrname, hsize_t n, char tmpname[NAME_BUF_SIZE]; /* Temporary attribute name */ H5A_info_t ainfo; /* Attribute info struct */ int old_nerrs; /* Number of errors when entering this check */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Retrieve the current # of reported errors */ old_nerrs = GetTestNumErrs(); @@ -5671,26 +5671,26 @@ attr_info_by_idx_check(hid_t obj_id, const char *attrname, hsize_t n, static void test_attr_info_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dset1, dset2, dset3; /* Dataset IDs */ - hid_t my_dataset; /* Current dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ + hid_t fid; /* HDF5 File ID */ + hid_t dset1, dset2, dset3; /* Dataset IDs */ + hid_t my_dataset; /* Current dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ H5A_info_t ainfo; /* Attribute information */ unsigned max_compact; /* Maximum # of links to store in group compactly */ unsigned min_dense; /* Minimum # of links to store in group "densely" */ - htri_t is_empty; /* Are there any attributes? */ - htri_t is_dense; /* Are attributes stored densely? */ + htri_t is_empty; /* Are there any attributes? */ + htri_t is_dense; /* Are attributes stored densely? */ hsize_t nattrs; /* Number of attributes on object */ hsize_t name_count; /* # of records in name index */ hsize_t corder_count; /* # of records in creation order index */ unsigned use_index; /* Use index on creation order values */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ char tmpname[NAME_BUF_SIZE]; /* Temporary attribute name */ unsigned curr_dset; /* Current dataset to work on */ unsigned u; /* Local index variable */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Create dataspace for dataset & attributes */ sid = H5Screate(H5S_SCALAR); @@ -5881,28 +5881,28 @@ test_attr_info_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) static void test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dset1, dset2, dset3; /* Dataset IDs */ - hid_t my_dataset; /* Current dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ + hid_t fid; /* HDF5 File ID */ + hid_t dset1, dset2, dset3; /* Dataset IDs */ + hid_t my_dataset; /* Current dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ H5A_info_t ainfo; /* Attribute information */ unsigned max_compact; /* Maximum # of links to store in group compactly */ unsigned min_dense; /* Minimum # of links to store in group "densely" */ - htri_t is_empty; /* Are there any attributes? */ - htri_t is_dense; /* Are attributes stored densely? */ + htri_t is_empty; /* Are there any attributes? */ + htri_t is_dense; /* Are attributes stored densely? */ hsize_t nattrs; /* Number of attributes on object */ hsize_t name_count; /* # of records in name index */ hsize_t corder_count; /* # of records in creation order index */ H5_index_t idx_type; /* Type of index to operate on */ H5_iter_order_t order; /* Order within in the index */ unsigned use_index; /* Use index on creation order values */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ char tmpname[NAME_BUF_SIZE]; /* Temporary attribute name */ unsigned curr_dset; /* Current dataset to work on */ unsigned u; /* Local index variable */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Create dataspace for dataset & attributes */ sid = H5Screate(H5S_SCALAR); @@ -6822,16 +6822,16 @@ attr_iterate_check(hid_t fid, const char *dsetname, hid_t obj_id, static void test_attr_iterate2(hbool_t new_format, hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dset1, dset2, dset3; /* Dataset IDs */ - hid_t my_dataset; /* Current dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ + hid_t fid; /* HDF5 File ID */ + hid_t dset1, dset2, dset3; /* Dataset IDs */ + hid_t my_dataset; /* Current dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ unsigned max_compact; /* Maximum # of links to store in group compactly */ unsigned min_dense; /* Minimum # of links to store in group "densely" */ - htri_t is_empty; /* Are there any attributes? */ - htri_t is_dense; /* Are attributes stored densely? */ + htri_t is_empty; /* Are there any attributes? */ + htri_t is_dense; /* Are attributes stored densely? */ hsize_t nattrs; /* Number of attributes on object */ hsize_t name_count; /* # of records in name index */ hsize_t corder_count; /* # of records in creation order index */ @@ -6842,10 +6842,10 @@ test_attr_iterate2(hbool_t new_format, hid_t fcpl, hid_t fapl) hsize_t idx; /* Start index for iteration */ unsigned use_index; /* Use index on creation order values */ const char *dsetname; /* Name of dataset for attributes */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ unsigned curr_dset; /* Current dataset to work on */ unsigned u; /* Local index variable */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Create dataspace for dataset & attributes */ sid = H5Screate(H5S_SCALAR); @@ -7138,7 +7138,7 @@ attr_open_by_idx_check(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, H5A_info_t ainfo; /* Attribute info */ int old_nerrs; /* Number of errors when entering this check */ unsigned u; /* Local index variable */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Retrieve the current # of reported errors */ old_nerrs = GetTestNumErrs(); @@ -7186,27 +7186,27 @@ attr_open_by_idx_check(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, static void test_attr_open_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dset1, dset2, dset3; /* Dataset IDs */ - hid_t my_dataset; /* Current dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ + hid_t fid; /* HDF5 File ID */ + hid_t dset1, dset2, dset3; /* Dataset IDs */ + hid_t my_dataset; /* Current dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ unsigned max_compact; /* Maximum # of links to store in group compactly */ unsigned min_dense; /* Minimum # of links to store in group "densely" */ - htri_t is_empty; /* Are there any attributes? */ - htri_t is_dense; /* Are attributes stored densely? */ + htri_t is_empty; /* Are there any attributes? */ + htri_t is_dense; /* Are attributes stored densely? */ hsize_t nattrs; /* Number of attributes on object */ hsize_t name_count; /* # of records in name index */ hsize_t corder_count; /* # of records in creation order index */ H5_index_t idx_type; /* Type of index to operate on */ H5_iter_order_t order; /* Order within in the index */ unsigned use_index; /* Use index on creation order values */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ unsigned curr_dset; /* Current dataset to work on */ unsigned u; /* Local index variable */ - hid_t ret_id; /* Generic hid_t return value */ - herr_t ret; /* Generic return value */ + hid_t ret_id; /* Generic hid_t return value */ + herr_t ret; /* Generic return value */ /* Create dataspace for dataset & attributes */ sid = H5Screate(H5S_SCALAR); @@ -7458,10 +7458,10 @@ attr_open_check(hid_t fid, const char *dsetname, hid_t obj_id, { hid_t attr_id; /* ID of attribute to test */ H5A_info_t ainfo; /* Attribute info */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ int old_nerrs; /* Number of errors when entering this check */ unsigned u; /* Local index variable */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Retrieve the current # of reported errors */ old_nerrs = GetTestNumErrs(); @@ -7534,26 +7534,26 @@ attr_open_check(hid_t fid, const char *dsetname, hid_t obj_id, static void test_attr_open_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dset1, dset2, dset3; /* Dataset IDs */ - hid_t my_dataset; /* Current dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ + hid_t fid; /* HDF5 File ID */ + hid_t dset1, dset2, dset3; /* Dataset IDs */ + hid_t my_dataset; /* Current dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ unsigned max_compact; /* Maximum # of links to store in group compactly */ unsigned min_dense; /* Minimum # of links to store in group "densely" */ - htri_t is_empty; /* Are there any attributes? */ - htri_t is_dense; /* Are attributes stored densely? */ + htri_t is_empty; /* Are there any attributes? */ + htri_t is_dense; /* Are attributes stored densely? */ hsize_t nattrs; /* Number of attributes on object */ hsize_t name_count; /* # of records in name index */ hsize_t corder_count; /* # of records in creation order index */ unsigned use_index; /* Use index on creation order values */ const char *dsetname; /* Name of dataset for attributes */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ unsigned curr_dset; /* Current dataset to work on */ unsigned u; /* Local index variable */ - hid_t ret_id; /* Generic hid_t return value */ - herr_t ret; /* Generic return value */ + hid_t ret_id; /* Generic hid_t return value */ + herr_t ret; /* Generic return value */ /* Create dataspace for dataset & attributes */ sid = H5Screate(H5S_SCALAR); @@ -7789,25 +7789,25 @@ test_attr_open_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl) static void test_attr_create_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dset1, dset2, dset3; /* Dataset IDs */ - hid_t my_dataset; /* Current dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ + hid_t fid; /* HDF5 File ID */ + hid_t dset1, dset2, dset3; /* Dataset IDs */ + hid_t my_dataset; /* Current dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ unsigned max_compact; /* Maximum # of links to store in group compactly */ unsigned min_dense; /* Minimum # of links to store in group "densely" */ - htri_t is_empty; /* Are there any attributes? */ - htri_t is_dense; /* Are attributes stored densely? */ + htri_t is_empty; /* Are there any attributes? */ + htri_t is_dense; /* Are attributes stored densely? */ hsize_t nattrs; /* Number of attributes on object */ hsize_t name_count; /* # of records in name index */ hsize_t corder_count; /* # of records in creation order index */ unsigned use_index; /* Use index on creation order values */ const char *dsetname; /* Name of dataset for attributes */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ unsigned curr_dset; /* Current dataset to work on */ unsigned u; /* Local index variable */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Create dataspace for dataset & attributes */ sid = H5Screate(H5S_SCALAR); @@ -8012,28 +8012,28 @@ test_attr_create_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl) static void test_attr_shared_write(hid_t fcpl, hid_t fapl) { - hid_t fid; /* File ID */ - hid_t my_fcpl; /* File creation property list ID */ - hid_t dataset, dataset2; /* Dataset IDs */ - hid_t attr_tid; /* Attribute's datatype ID */ - hid_t sid, big_sid; /* Dataspace IDs */ - hsize_t big_dims[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; /* Dimensions for "big" attribute */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + hid_t fid; /* File ID */ + hid_t my_fcpl; /* File creation property list ID */ + hid_t dataset, dataset2; /* Dataset IDs */ + hid_t attr_tid; /* Attribute's datatype ID */ + hid_t sid, big_sid; /* Dataspace IDs */ + hsize_t big_dims[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; /* Dimensions for "big" attribute */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ unsigned max_compact; /* Maximum # of attributes to store compactly */ unsigned min_dense; /* Minimum # of attributes to store "densely" */ - htri_t is_dense; /* Are attributes stored densely? */ - htri_t is_shared; /* Is attributes shared? */ + htri_t is_dense; /* Are attributes stored densely? */ + htri_t is_shared; /* Is attributes shared? */ hsize_t shared_refcount; /* Reference count of shared attribute */ unsigned attr_value; /* Attribute value */ - unsigned *big_value; /* Data for "big" attribute */ + unsigned *big_value; /* Data for "big" attribute */ size_t mesg_count; /* # of shared messages */ unsigned test_shared; /* Index over shared component type */ unsigned u; /* Local index variable */ h5_stat_size_t empty_filesize; /* Size of empty file */ h5_stat_size_t filesize; /* Size of file after modifications */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Writing Shared & Unshared Attributes in Compact & Dense Storage\n")); @@ -8342,29 +8342,29 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl) static void test_attr_shared_rename(hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t my_fcpl; /* File creation property list ID */ - hid_t dataset, dataset2; /* Dataset ID2 */ - hid_t attr_tid; /* Attribute's datatype ID */ - hid_t sid, big_sid; /* Dataspace IDs */ - hsize_t big_dims[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; /* Dimensions for "big" attribute */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute on first dataset */ - char attrname2[NAME_BUF_SIZE]; /* Name of attribute on second dataset */ + hid_t fid; /* HDF5 File ID */ + hid_t my_fcpl; /* File creation property list ID */ + hid_t dataset, dataset2; /* Dataset ID2 */ + hid_t attr_tid; /* Attribute's datatype ID */ + hid_t sid, big_sid; /* Dataspace IDs */ + hsize_t big_dims[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; /* Dimensions for "big" attribute */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute on first dataset */ + char attrname2[NAME_BUF_SIZE]; /* Name of attribute on second dataset */ unsigned max_compact; /* Maximum # of attributes to store compactly */ unsigned min_dense; /* Minimum # of attributes to store "densely" */ - htri_t is_dense; /* Are attributes stored densely? */ - htri_t is_shared; /* Is attributes shared? */ + htri_t is_dense; /* Are attributes stored densely? */ + htri_t is_shared; /* Is attributes shared? */ hsize_t shared_refcount; /* Reference count of shared attribute */ unsigned attr_value; /* Attribute value */ - unsigned *big_value; /* Data for "big" attribute */ + unsigned *big_value; /* Data for "big" attribute */ size_t mesg_count; /* # of shared messages */ unsigned test_shared; /* Index over shared component type */ unsigned u; /* Local index variable */ h5_stat_size_t empty_filesize; /* Size of empty file */ h5_stat_size_t filesize; /* Size of file after modifications */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Renaming Shared & Unshared Attributes in Compact & Dense Storage\n")); @@ -8789,28 +8789,28 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) static void test_attr_shared_delete(hid_t fcpl, hid_t fapl) { - hid_t fid; /* File ID */ - hid_t my_fcpl; /* File creation property list ID */ - hid_t dataset, dataset2; /* Dataset IDs */ - hid_t attr_tid; /* Attribute's datatype ID */ - hid_t sid, big_sid; /* Dataspace IDs */ - hsize_t big_dims[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; /* Dimensions for "big" attribute */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute on first dataset */ + hid_t fid; /* File ID */ + hid_t my_fcpl; /* File creation property list ID */ + hid_t dataset, dataset2; /* Dataset IDs */ + hid_t attr_tid; /* Attribute's datatype ID */ + hid_t sid, big_sid; /* Dataspace IDs */ + hsize_t big_dims[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; /* Dimensions for "big" attribute */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute on first dataset */ unsigned max_compact; /* Maximum # of attributes to store compactly */ unsigned min_dense; /* Minimum # of attributes to store "densely" */ - htri_t is_dense; /* Are attributes stored densely? */ - htri_t is_shared; /* Is attributes shared? */ + htri_t is_dense; /* Are attributes stored densely? */ + htri_t is_shared; /* Is attributes shared? */ hsize_t shared_refcount; /* Reference count of shared attribute */ unsigned attr_value; /* Attribute value */ - unsigned *big_value; /* Data for "big" attribute */ + unsigned *big_value; /* Data for "big" attribute */ size_t mesg_count; /* # of shared messages */ unsigned test_shared; /* Index over shared component type */ unsigned u; /* Local index variable */ h5_stat_size_t empty_filesize; /* Size of empty file */ h5_stat_size_t filesize; /* Size of file after modifications */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Deleting Shared & Unshared Attributes in Compact & Dense Storage\n")); @@ -9158,28 +9158,28 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl) static void test_attr_shared_unlink(hid_t fcpl, hid_t fapl) { - hid_t fid; /* File ID */ - hid_t my_fcpl; /* File creation property list ID */ - hid_t dataset, dataset2; /* Dataset IDs */ - hid_t attr_tid; /* Attribute's datatype ID */ - hid_t sid, big_sid; /* Dataspace IDs */ - hsize_t big_dims[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; /* Dimensions for "big" attribute */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute on first dataset */ + hid_t fid; /* File ID */ + hid_t my_fcpl; /* File creation property list ID */ + hid_t dataset, dataset2; /* Dataset IDs */ + hid_t attr_tid; /* Attribute's datatype ID */ + hid_t sid, big_sid; /* Dataspace IDs */ + hsize_t big_dims[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; /* Dimensions for "big" attribute */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute on first dataset */ unsigned max_compact; /* Maximum # of attributes to store compactly */ unsigned min_dense; /* Minimum # of attributes to store "densely" */ - htri_t is_dense; /* Are attributes stored densely? */ - htri_t is_shared; /* Is attributes shared? */ + htri_t is_dense; /* Are attributes stored densely? */ + htri_t is_shared; /* Is attributes shared? */ hsize_t shared_refcount; /* Reference count of shared attribute */ unsigned attr_value; /* Attribute value */ - unsigned *big_value; /* Data for "big" attribute */ + unsigned *big_value; /* Data for "big" attribute */ size_t mesg_count; /* # of shared messages */ unsigned test_shared; /* Index over shared component type */ unsigned u; /* Local index variable */ h5_stat_size_t empty_filesize; /* Size of empty file */ h5_stat_size_t filesize; /* Size of file after modifications */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Unlinking Object with Shared Attributes in Compact & Dense Storage\n")); @@ -10639,7 +10639,7 @@ test_attr_bug9(hid_t fcpl, hid_t fapl) /* Create enough attributes to cause a change to dense storage */ for(i = 0; i < max_compact + 1; i++) { /* Create attribute */ - snprintf(aname, sizeof(aname), "%u", i); + HDsnprintf(aname, sizeof(aname), "%u", i); aid = H5Acreate2(gid, aname, H5T_NATIVE_CHAR, sid, H5P_DEFAULT, H5P_DEFAULT); CHECK(aid, FAIL, "H5Acreate2"); @@ -10680,8 +10680,8 @@ test_attr_bug9(hid_t fcpl, hid_t fapl) void test_attr(void) { - hid_t fapl = (-1), fapl2 = (-1); /* File access property lists */ - hid_t fcpl = (-1), fcpl2 = (-1); /* File creation property lists */ + hid_t fapl = (-1), fapl2 = (-1); /* File access property lists */ + hid_t fcpl = (-1), fcpl2 = (-1); /* File creation property lists */ unsigned new_format; /* Whether to use the new format or not */ unsigned use_shared; /* Whether to use shared attributes or not */ herr_t ret; /* Generic return value */ @@ -10868,13 +10868,13 @@ test_attr(void) /*------------------------------------------------------------------------- - * Function: cleanup_attr + * Function: cleanup_attr * - * Purpose: Cleanup temporary test files + * Purpose: Cleanup temporary test files * - * Return: none + * Return: none * - * Programmer: Albert Cheng + * Programmer: Albert Cheng * July 2, 1998 * * Modifications: -- cgit v0.12 From 10a9fb5319ab0dcd0e14e40a8ab5c38e8211f764 Mon Sep 17 00:00:00 2001 From: lrknox Date: Tue, 14 Nov 2017 09:52:47 -0600 Subject: Remove extra '&'s that cause syntax errors on Macs. --- config/conclude.am | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/config/conclude.am b/config/conclude.am index 97aef27..4bdbb0b 100644 --- a/config/conclude.am +++ b/config/conclude.am @@ -126,40 +126,40 @@ $(TEST_PROG_CHKEXE) $(TEST_PROG_PARA_CHKEXE) dummy.chkexe_: echo "No need to test $${tname} again."; \ else \ if test -n "$(REALTIMEOUTPUT)"; then \ - echo "============================" |& tee $${log}; \ + echo "============================" | tee $${log}; \ else \ echo "============================" > $${log}; \ fi; \ if test "X$(FORTRAN_API)" = "Xyes"; then \ echo "Fortran API: Testing $(HDF5_DRIVER) $${tname} $(TEST_FLAGS)"; \ if test -n "$(REALTIMEOUTPUT)"; then \ - echo "Fortran API: $(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" |& tee -a $${log}; \ + echo "Fortran API: $(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" | tee -a $${log}; \ else \ echo "Fortran API: $(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" >> $${log}; \ fi; \ elif test "X$(CXX_API)" = "Xyes"; then \ echo "C++ API: Testing $(HDF5_DRIVER) $${tname} $(TEST_FLAGS)"; \ if test -n "$(REALTIMEOUTPUT)"; then \ - echo "C++ API: $(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" |& tee -a $${log};\ + echo "C++ API: $(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" | tee -a $${log};\ else \ echo "C++ API: $(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" >> $${log};\ fi; \ else \ echo "Testing $(HDF5_DRIVER) $${tname} $(TEST_FLAGS)"; \ if test -n "$(REALTIMEOUTPUT)"; then \ - echo "$(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" |& tee -a $${log}; \ + echo "$(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" | tee -a $${log}; \ else \ echo "$(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" >> $${log}; \ fi; \ fi; \ if test -n "$(REALTIMEOUTPUT)"; then \ - echo "============================" |& tee -a $${log}; \ + echo "============================" | tee -a $${log}; \ else \ echo "============================" >> $${log}; \ fi; \ if test -n "$(REALTIMEOUTPUT)"; then \ srcdir="$(srcdir)" \ - $(TIME) $(RUNEXEC) ./$${tname} $(TEST_FLAGS) |& tee -a $${log} 2>&1 \ + $(TIME) $(RUNEXEC) ./$${tname} $(TEST_FLAGS) | tee -a $${log} 2>&1 \ && touch $(@:.chkexe_=.chkexe) || \ (test $$HDF5_Make_Ignore && echo "*** Error ignored") || \ (cat $${log} && false) || exit 1; \ @@ -172,8 +172,8 @@ $(TEST_PROG_CHKEXE) $(TEST_PROG_PARA_CHKEXE) dummy.chkexe_: fi; \ echo "" >> $${log}; \ if test -n "$(REALTIMEOUTPUT)"; then \ - echo "Finished testing $${tname} $(TEST_FLAGS)" |& tee -a $${log}; \ - echo "============================" |& tee -a $${log}; \ + echo "Finished testing $${tname} $(TEST_FLAGS)" | tee -a $${log}; \ + echo "============================" | tee -a $${log}; \ else \ echo "Finished testing $${tname} $(TEST_FLAGS)" >> $${log}; \ echo "============================" >> $${log}; \ -- cgit v0.12 From 45b561f2f25d2e96a3f569e278919f454b3abf71 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Tue, 14 Nov 2017 12:34:31 -0800 Subject: Added H5Oint.c file. --- MANIFEST | 1 + src/CMakeLists.txt | 1 + src/H5O.c | 6 ++--- src/H5Oint.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/Makefile.am | 2 +- 5 files changed, 77 insertions(+), 5 deletions(-) create mode 100644 src/H5Oint.c diff --git a/MANIFEST b/MANIFEST index cfe720e..9b91c78 100644 --- a/MANIFEST +++ b/MANIFEST @@ -753,6 +753,7 @@ ./src/H5Oflush.c ./src/H5Ofsinfo.c ./src/H5Oginfo.c +./src/H5Oint.c ./src/H5Olayout.c ./src/H5Olinfo.c ./src/H5Olink.c diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7ee423b..2dbef62 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -454,6 +454,7 @@ set (H5O_SOURCES ${HDF5_SRC_DIR}/H5Oflush.c ${HDF5_SRC_DIR}/H5Ofsinfo.c ${HDF5_SRC_DIR}/H5Oginfo.c + ${HDF5_SRC_DIR}/H5Oint.c ${HDF5_SRC_DIR}/H5Olayout.c ${HDF5_SRC_DIR}/H5Olinfo.c ${HDF5_SRC_DIR}/H5Olink.c diff --git a/src/H5O.c b/src/H5O.c index 152e6cc..3c78b04 100644 --- a/src/H5O.c +++ b/src/H5O.c @@ -13,11 +13,9 @@ /*------------------------------------------------------------------------- * - * Created: H5O.c - * Aug 5 1997 - * Robb Matzke + * Created: H5O.c * - * Purpose: Object header routines. + * Purpose: Public object header routines * *------------------------------------------------------------------------- */ diff --git a/src/H5Oint.c b/src/H5Oint.c new file mode 100644 index 0000000..fbaad53 --- /dev/null +++ b/src/H5Oint.c @@ -0,0 +1,72 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Created: H5O.c + * + * Purpose: Internal object header routines + * + *------------------------------------------------------------------------- + */ + +/****************/ +/* Module Setup */ +/****************/ + +#include "H5Omodule.h" /* This source code file is part of the H5O module */ + + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Opkg.h" /* Object headers */ + + +/****************/ +/* Local Macros */ +/****************/ + + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Package Typedefs */ +/********************/ + + +/********************/ +/* Local Prototypes */ +/********************/ + + +/*********************/ +/* Package Variables */ +/*********************/ + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + + diff --git a/src/Makefile.am b/src/Makefile.am index ad29e2a..d8d2cc2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -84,7 +84,7 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5Ochunk.c \ H5Ocont.c H5Ocopy.c H5Odbg.c H5Odrvinfo.c H5Odtype.c H5Oefl.c \ H5Ofill.c H5Oflush.c H5Ofsinfo.c H5Oginfo.c \ - H5Olayout.c \ + H5Oint.c H5Olayout.c \ H5Olinfo.c H5Olink.c H5Omessage.c H5Omtime.c \ H5Oname.c H5Onull.c H5Opline.c H5Orefcount.c \ H5Osdspace.c H5Oshared.c \ -- cgit v0.12 From addde7dcb832b50c16fae3605a904c9daf763a32 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Tue, 14 Nov 2017 15:07:19 -0600 Subject: Correct link lines of libraries --- CMakeLists.txt | 1 - fortran/src/CMakeLists.txt | 10 ++++++---- src/CMakeLists.txt | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f21f8b7..f2640b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -482,7 +482,6 @@ option (BUILD_SHARED_LIBS "Build Shared Libraries" ON) set (H5_ENABLE_SHARED_LIB NO) if (BUILD_SHARED_LIBS) set (H5_ENABLE_SHARED_LIB YES) - set (LINK_SHARED_LIBS ${LINK_LIBS}) endif () set (H5_ENABLE_STATIC_LIB YES) set (CMAKE_POSITION_INDEPENDENT_CODE ON) diff --git a/fortran/src/CMakeLists.txt b/fortran/src/CMakeLists.txt index 51db4f0..e34c778 100644 --- a/fortran/src/CMakeLists.txt +++ b/fortran/src/CMakeLists.txt @@ -126,7 +126,7 @@ set (f90CStub_C_HDRS add_library (${HDF5_F90_C_LIB_TARGET} STATIC ${f90CStub_C_SOURCES} ${f90CStub_C_HDRS}) TARGET_C_PROPERTIES (${HDF5_F90_C_LIB_TARGET} STATIC " " " ") -target_link_libraries (${HDF5_F90_C_LIB_TARGET} ${HDF5_LIB_TARGET} ${LINK_LIBS}) +target_link_libraries (${HDF5_F90_C_LIB_TARGET} PUBLIC ${HDF5_LIB_TARGET}) set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_F90_C_LIB_TARGET}") H5_SET_LIB_OPTIONS (${HDF5_F90_C_LIB_TARGET} ${HDF5_F90_C_LIB_NAME} STATIC) set_target_properties (${HDF5_F90_C_LIB_TARGET} PROPERTIES @@ -139,7 +139,7 @@ set (install_targets ${HDF5_F90_C_LIB_TARGET}) if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) add_library (${HDF5_F90_C_LIBSH_TARGET} SHARED ${f90CStub_C_SOURCES} ${f90CStub_C_HDRS}) TARGET_C_PROPERTIES (${HDF5_F90_C_LIBSH_TARGET} SHARED " " " ") - target_link_libraries (${HDF5_F90_C_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} ${LINK_SHARED_LIBS}) + target_link_libraries (${HDF5_F90_C_LIBSH_TARGET} PUBLIC ${HDF5_LIBSH_TARGET}) set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_F90_C_LIBSH_TARGET}") H5_SET_LIB_OPTIONS (${HDF5_F90_C_LIBSH_TARGET} ${HDF5_F90_C_LIB_NAME} SHARED ${HDF5_F_PACKAGE_SOVERSION}) set_target_properties (${HDF5_F90_C_LIBSH_TARGET} PROPERTIES @@ -241,7 +241,8 @@ endif () add_library (${HDF5_F90_LIB_TARGET} STATIC ${f90_F_SOURCES}) set (SHARED_LINK_FLAGS " ") TARGET_FORTRAN_PROPERTIES (${HDF5_F90_LIB_TARGET} STATIC " " " ") -target_link_libraries (${HDF5_F90_LIB_TARGET} ${HDF5_F90_C_LIB_TARGET} ${HDF5_LIB_TARGET} ${LINK_Fortran_LIBS}) +target_link_libraries (${HDF5_F90_LIB_TARGET} PUBLIC ${HDF5_F90_C_LIB_TARGET}) +target_link_libraries (${HDF5_F90_LIB_TARGET} PRIVATE ${LINK_Fortran_LIBS}) if (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND) target_include_directories (${HDF5_F90_LIB_TARGET} PUBLIC ${MPI_Fortran_INCLUDE_DIRS}) endif () @@ -268,7 +269,8 @@ if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) set (SHARED_LINK_FLAGS "/DLL /DEF:${HDF5_F90_SRC_BINARY_DIR}/hdf5_fortrandll.def") endif () TARGET_FORTRAN_PROPERTIES (${HDF5_F90_LIBSH_TARGET} SHARED " " ${SHARED_LINK_FLAGS}) - target_link_libraries (${HDF5_F90_LIBSH_TARGET} ${HDF5_F90_C_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} ${LINK_Fortran_LIBS}) + target_link_libraries (${HDF5_F90_LIBSH_TARGET} PUBLIC ${HDF5_F90_C_LIBSH_TARGET}) + target_link_libraries (${HDF5_F90_LIBSH_TARGET} PRIVATE ${LINK_Fortran_LIBS}) if (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND) target_include_directories (${HDF5_F90_LIBSH_TARGET} PUBLIC ${MPI_Fortran_INCLUDE_DIRS}) endif () diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7ee423b..e78d8b6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -882,7 +882,7 @@ set (gen_SRCS ${HDF5_BINARY_DIR}/H5Tinit.c ${HDF5_BINARY_DIR}/H5lib_settings.c) add_library (${HDF5_LIB_TARGET} STATIC ${common_SRCS} ${gen_SRCS} ${H5_PUBLIC_HEADERS} ${H5_PRIVATE_HEADERS} ${H5_GENERATED_HEADERS}) TARGET_C_PROPERTIES (${HDF5_LIB_TARGET} STATIC " " " ") -target_link_libraries (${HDF5_LIB_TARGET} PUBLIC ${LINK_LIBS}) +target_link_libraries (${HDF5_LIB_TARGET} PRIVATE ${LINK_LIBS}) if (NOT WIN32) target_link_libraries (${HDF5_LIB_TARGET} PUBLIC dl) endif () @@ -926,7 +926,7 @@ if (BUILD_SHARED_LIBS) set (shared_gen_SRCS ${HDF5_BINARY_DIR}/shared/H5Tinit.c ${HDF5_BINARY_DIR}/shared/H5lib_settings.c) add_library (${HDF5_LIBSH_TARGET} SHARED ${common_SRCS} ${shared_gen_SRCS} ${H5_PUBLIC_HEADERS} ${H5_PRIVATE_HEADERS} ${H5_GENERATED_HEADERS}) TARGET_C_PROPERTIES (${HDF5_LIBSH_TARGET} SHARED " " " ") - target_link_libraries (${HDF5_LIBSH_TARGET} PUBLIC ${LINK_SHARED_LIBS}) + target_link_libraries (${HDF5_LIBSH_TARGET} PRIVATE ${LINK_LIBS}) if (NOT WIN32) target_link_libraries (${HDF5_LIBSH_TARGET} PUBLIC dl) endif () -- cgit v0.12 From 7fbc3df3fa1b5250f13ef7ce7bbf9fc85eb76e0a Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Tue, 14 Nov 2017 15:32:08 -0600 Subject: HDFFV-10329 - Note new JIRA issue --- release_docs/RELEASE.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index a7465e5..f8ad620 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -170,6 +170,18 @@ Bug Fixes since HDF5-1.10.1 release Configuration ------------- + - cmake + + The hdf5 library used shared szip and zlib, which needlessly required + applications to link with the same szip and zlib libraries. + + Changed the target_link_libraries commands to use the static libs. + Removed improper link duplication of szip and zlib. + Adjusted the link dependencies and the link interface values of + the target_link_libraries commands. + + (ADB - 2017/11/14, HDFFV-10329) + - cmake MPI CMake implementation for MPI was problematic and would create incorrect -- cgit v0.12 From fcfc5f116d08642de962919ac26092c74b924644 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Tue, 14 Nov 2017 13:40:30 -0800 Subject: Moved code from H5O.c to H5Oint.c --- src/H5O.c | 2680 +----------------------------------------------------- src/H5Oint.c | 2641 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/H5Oprivate.h | 3 + 3 files changed, 2662 insertions(+), 2662 deletions(-) diff --git a/src/H5O.c b/src/H5O.c index 3c78b04..cf84b47 100644 --- a/src/H5O.c +++ b/src/H5O.c @@ -30,19 +30,12 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5FOprivate.h" /* File objects */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ -#include "H5MFprivate.h" /* File memory management */ -#ifdef H5O_ENABLE_BOGUS -#include "H5MMprivate.h" /* Memory management */ -#endif /* H5O_ENABLE_BOGUS */ -#include "H5Opkg.h" /* Object headers */ -#include "H5SMprivate.h" /* Shared object header messages */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5Opkg.h" /* Object headers */ /****************/ @@ -54,17 +47,6 @@ /* Local Typedefs */ /******************/ -/* User data for recursive traversal over objects from a group */ -typedef struct { - hid_t obj_id; /* The ID for the starting group */ - H5G_loc_t *start_loc; /* Location of starting group */ - hid_t lapl_id; /* LAPL for walking across links */ - hid_t dxpl_id; /* DXPL for operations */ - H5SL_t *visited; /* Skip list for tracking visited nodes */ - H5O_iterate_t op; /* Application callback */ - void *op_data; /* Application's op data */ -} H5O_iter_visit_ud_t; - /********************/ /* Package Typedefs */ @@ -75,136 +57,21 @@ typedef struct { /* Local Prototypes */ /********************/ -static herr_t H5O_delete_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh); -static herr_t H5O_obj_type_real(H5O_t *oh, H5O_type_t *obj_type); -static herr_t H5O_visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type, - H5_iter_order_t order, H5O_iterate_t op, void *op_data, hid_t lapl_id, - hid_t dxpl_id); -static herr_t H5O_get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr); -static const H5O_obj_class_t *H5O_obj_class_real(H5O_t *oh); - /*********************/ /* Package Variables */ /*********************/ -/* Package initialization variable */ -hbool_t H5_PKG_INIT_VAR = FALSE; - -/* Header message ID to class mapping */ - -/* Remember to increment H5O_MSG_TYPES in H5Opkg.h when adding a new - * message. - */ - -const H5O_msg_class_t *const H5O_msg_class_g[] = { - H5O_MSG_NULL, /*0x0000 Null */ - H5O_MSG_SDSPACE, /*0x0001 Dataspace */ - H5O_MSG_LINFO, /*0x0002 Link information */ - H5O_MSG_DTYPE, /*0x0003 Datatype */ - H5O_MSG_FILL, /*0x0004 Old data storage -- fill value */ - H5O_MSG_FILL_NEW, /*0x0005 New data storage -- fill value */ - H5O_MSG_LINK, /*0x0006 Link */ - H5O_MSG_EFL, /*0x0007 Data storage -- external data files */ - H5O_MSG_LAYOUT, /*0x0008 Data Layout */ -#ifdef H5O_ENABLE_BOGUS - H5O_MSG_BOGUS_VALID, /*0x0009 "Bogus valid" (for testing) */ -#else /* H5O_ENABLE_BOGUS */ - NULL, /*0x0009 "Bogus valid" (for testing) */ -#endif /* H5O_ENABLE_BOGUS */ - H5O_MSG_GINFO, /*0x000A Group information */ - H5O_MSG_PLINE, /*0x000B Data storage -- filter pipeline */ - H5O_MSG_ATTR, /*0x000C Attribute */ - H5O_MSG_NAME, /*0x000D Object name */ - H5O_MSG_MTIME, /*0x000E Object modification date and time */ - H5O_MSG_SHMESG, /*0x000F File-wide shared message table */ - H5O_MSG_CONT, /*0x0010 Object header continuation */ - H5O_MSG_STAB, /*0x0011 Symbol table */ - H5O_MSG_MTIME_NEW, /*0x0012 New Object modification date and time */ - H5O_MSG_BTREEK, /*0x0013 Non-default v1 B-tree 'K' values */ - H5O_MSG_DRVINFO, /*0x0014 Driver info settings */ - H5O_MSG_AINFO, /*0x0015 Attribute information */ - H5O_MSG_REFCOUNT, /*0x0016 Object's ref. count */ - H5O_MSG_FSINFO, /*0x0017 Free-space manager info */ - H5O_MSG_MDCI, /*0x0018 Metadata cache image */ - H5O_MSG_UNKNOWN, /*0x0019 Placeholder for unknown message */ -#ifdef H5O_ENABLE_BOGUS - H5O_MSG_BOGUS_INVALID, /*0x001A "Bogus invalid" (for testing) */ -#else /* H5O_ENABLE_BOGUS */ - NULL, /*0x001A "Bogus invalid" (for testing) */ -#endif /* H5O_ENABLE_BOGUS */ -}; - -/* Declare a free list to manage the H5O_t struct */ -H5FL_DEFINE(H5O_t); - -/* Declare a free list to manage the H5O_mesg_t sequence information */ -H5FL_SEQ_DEFINE(H5O_mesg_t); - -/* Declare a free list to manage the H5O_chunk_t sequence information */ -H5FL_SEQ_DEFINE(H5O_chunk_t); - -/* Declare a free list to manage the chunk image information */ -H5FL_BLK_DEFINE(chunk_image); - -/* Declare external the free list for H5O_cont_t sequences */ -H5FL_SEQ_EXTERN(H5O_cont_t); - /*****************************/ /* Library Private Variables */ /*****************************/ -/* Declare external the free list for time_t's */ -H5FL_EXTERN(time_t); - -/* Declare external the free list for H5_obj_t's */ -H5FL_EXTERN(H5_obj_t); - /*******************/ /* Local Variables */ /*******************/ -/* Header object ID to class mapping */ -/* - * Initialize the object class info table. Begin with the most general types - * and end with the most specific. For instance, any object that has a - * datatype message is a datatype but only some of them are datasets. - */ -static const H5O_obj_class_t *const H5O_obj_class_g[] = { - H5O_OBJ_DATATYPE, /* Datatype object (H5O_TYPE_NAMED_DATATYPE - 2) */ - H5O_OBJ_DATASET, /* Dataset object (H5O_TYPE_DATASET - 1) */ - H5O_OBJ_GROUP, /* Group object (H5O_TYPE_GROUP - 0) */ -}; - - - -/*------------------------------------------------------------------------- - * Function: H5O__init_package - * - * Purpose: Initialize information specific to H5O interface. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Thursday, January 18, 2007 - * - *------------------------------------------------------------------------- - */ -herr_t -H5O__init_package(void) -{ - FUNC_ENTER_PACKAGE_NOERR - - /* H5O interface sanity checks */ - HDcompile_assert(H5O_MSG_TYPES == NELMTS(H5O_msg_class_g)); - HDcompile_assert(sizeof(H5O_fheap_id_t) == H5O_FHEAP_ID_LEN); - - HDcompile_assert(H5O_UNKNOWN_ID < H5O_MSG_TYPES); - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5O__init_package() */ /*------------------------------------------------------------------------- @@ -300,11 +167,11 @@ H5Oopen_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, if(H5G_loc(loc_id, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!group_name || !*group_name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") /* Verify access property list and get correct dxpl */ if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id, loc_id, FALSE) < 0) @@ -708,11 +575,11 @@ H5Oget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, if(H5G_loc(loc_id, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!group_name || !*group_name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") if(!oinfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") @@ -956,15 +823,15 @@ H5Ovisit(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, /* Check args */ if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") if(!op) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified") /* Call internal object visitation routine */ if((ret_value = H5O_visit(obj_id, ".", idx_type, order, op, op_data, H5P_LINK_ACCESS_DEFAULT, H5AC_ind_read_dxpl_id)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") + HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") done: FUNC_LEAVE_API(ret_value) @@ -1018,9 +885,9 @@ H5Ovisit_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, if(!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") if(!op) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified") @@ -1030,7 +897,7 @@ H5Ovisit_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, /* Call internal object visitation routine */ if((ret_value = H5O_visit(loc_id, obj_name, idx_type, order, op, op_data, lapl_id, dxpl_id)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") + HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") done: FUNC_LEAVE_API(ret_value) @@ -1210,2514 +1077,3 @@ done: FUNC_LEAVE_API(ret_value) } /* H5Oare_mdc_flushes_disabled() */ - -/*------------------------------------------------------------------------- - * Function: H5O_create - * - * Purpose: Creates a new object header. Allocates space for it and - * then calls an initialization function. The object header - * is opened for write access and should eventually be - * closed by calling H5O_close(). - * - * Return: Success: Non-negative, the ENT argument contains - * information about the object header, - * including its address. - * - * Failure: Negative - * - * Programmer: Robb Matzke - * matzke@llnl.gov - * Aug 5 1997 - * - *------------------------------------------------------------------------- - */ -herr_t -H5O_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, size_t initial_rc, - hid_t ocpl_id, H5O_loc_t *loc/*out*/) -{ - H5P_genplist_t *oc_plist; /* Object creation property list */ - H5O_t *oh = NULL; /* Object header created */ - haddr_t oh_addr; /* Address of initial object header */ - size_t oh_size; /* Size of initial object header */ - uint8_t oh_flags; /* Object header's initial status flags */ - unsigned insert_flags = H5AC__NO_FLAGS_SET; /* Flags for inserting object header into cache */ - hbool_t store_msg_crt_idx; /* Whether to always store message creation indices for this file */ - herr_t ret_value = SUCCEED; /* return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* check args */ - HDassert(f); - HDassert(loc); - HDassert(TRUE == H5P_isa_class(ocpl_id, H5P_OBJECT_CREATE)); - - /* Check for invalid access request */ - if(0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) - HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "no write intent on file") - - /* Make certain we allocate at least a reasonable size for the object header */ - size_hint = H5O_ALIGN_F(f, MAX(H5O_MIN_SIZE, size_hint)); - - /* Get the property list */ - if(NULL == (oc_plist = (H5P_genplist_t *)H5I_object(ocpl_id))) - HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a property list") - - /* Get any object header status flags set by properties */ - if(H5P_get(oc_plist, H5O_CRT_OHDR_FLAGS_NAME, &oh_flags) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object header flags") - - /* Allocate the object header and zero out header fields */ - if(NULL == (oh = H5FL_CALLOC(H5O_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - - /* Initialize file-specific information for object header */ - store_msg_crt_idx = H5F_STORE_MSG_CRT_IDX(f); - if(H5F_USE_LATEST_FLAGS(f, H5F_LATEST_OBJ_HEADER) || store_msg_crt_idx || (oh_flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED)) - oh->version = H5O_VERSION_LATEST; - else - oh->version = H5O_VERSION_1; - oh->sizeof_size = H5F_SIZEOF_SIZE(f); - oh->sizeof_addr = H5F_SIZEOF_ADDR(f); - oh->swmr_write = !!(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE); -#ifdef H5O_ENABLE_BAD_MESG_COUNT - /* Check whether the "bad message count" property is set */ - if(H5P_exist_plist(oc_plist, H5O_BAD_MESG_COUNT_NAME) > 0) { - /* Retrieve bad message count flag */ - if(H5P_get(oc_plist, H5O_BAD_MESG_COUNT_NAME, &oh->store_bad_mesg_count) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get bad message count flag") - } /* end if */ -#endif /* H5O_ENABLE_BAD_MESG_COUNT */ - - /* Create object header proxy if doing SWMR writes */ - if(oh->swmr_write) { - /* Create virtual entry, for use as proxy */ - if(NULL == (oh->proxy = H5AC_proxy_entry_create())) - HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "can't create object header proxy") - } /* end if */ - else - oh->proxy = NULL; - - /* Set initial status flags */ - oh->flags = oh_flags; - - /* Initialize version-specific fields */ - if(oh->version > H5O_VERSION_1) { - /* Initialize all time fields with current time, if we are storing them */ - if(oh->flags & H5O_HDR_STORE_TIMES) - oh->atime = oh->mtime = oh->ctime = oh->btime = H5_now(); - else - oh->atime = oh->mtime = oh->ctime = oh->btime = 0; - - /* Make certain attribute creation order tracking is enabled if - * attributes can be shared in this file. - */ - if(store_msg_crt_idx) - oh->flags |= H5O_HDR_ATTR_CRT_ORDER_TRACKED; - - /* Retrieve attribute storage phase change values from property list */ - if(H5P_get(oc_plist, H5O_CRT_ATTR_MAX_COMPACT_NAME, &oh->max_compact) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get max. # of compact attributes") - if(H5P_get(oc_plist, H5O_CRT_ATTR_MIN_DENSE_NAME, &oh->min_dense) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get min. # of dense attributes") - - /* Check for non-default attribute storage phase change values */ - if(oh->max_compact != H5O_CRT_ATTR_MAX_COMPACT_DEF || oh->min_dense != H5O_CRT_ATTR_MIN_DENSE_DEF) - oh->flags |= H5O_HDR_ATTR_STORE_PHASE_CHANGE; - - /* Determine correct value for chunk #0 size bits */ -/* Avoid compiler warning on 32-bit machines */ -#if H5_SIZEOF_SIZE_T > H5_SIZEOF_INT32_T - if(size_hint > 4294967295UL) - oh->flags |= H5O_HDR_CHUNK0_8; - else -#endif /* H5_SIZEOF_SIZE_T > H5_SIZEOF_INT32_T */ - if(size_hint > 65535) - oh->flags |= H5O_HDR_CHUNK0_4; - else if(size_hint > 255) - oh->flags |= H5O_HDR_CHUNK0_2; - } /* end if */ - else { - /* Reset unused time fields */ - oh->atime = oh->mtime = oh->ctime = oh->btime = 0; - } /* end else */ - - /* Compute total size of initial object header */ - /* (i.e. object header prefix and first chunk) */ - oh_size = (size_t)H5O_SIZEOF_HDR(oh) + size_hint; - - /* Allocate disk space for header and first chunk */ - if(HADDR_UNDEF == (oh_addr = H5MF_alloc(f, H5FD_MEM_OHDR, dxpl_id, (hsize_t)oh_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for object header") - - /* Create the chunk list */ - oh->nchunks = oh->alloc_nchunks = 1; - if(NULL == (oh->chunk = H5FL_SEQ_MALLOC(H5O_chunk_t, (size_t)oh->alloc_nchunks))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - - /* Initialize the first chunk */ - oh->chunk[0].addr = oh_addr; - oh->chunk[0].size = oh_size; - oh->chunk[0].gap = 0; - - /* Allocate enough space for the first chunk */ - /* (including space for serializing the object header prefix */ - if(NULL == (oh->chunk[0].image = H5FL_BLK_CALLOC(chunk_image, oh_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - oh->chunk[0].chunk_proxy = NULL; - - /* Put magic # for object header in first chunk */ - if(oh->version > H5O_VERSION_1) - HDmemcpy(oh->chunk[0].image, H5O_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC); - - /* Create the message list */ - oh->nmesgs = 1; - oh->alloc_nmesgs = H5O_NMESGS; - if(NULL == (oh->mesg = H5FL_SEQ_CALLOC(H5O_mesg_t, oh->alloc_nmesgs))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - - /* Initialize the initial "null" message, covering the entire first chunk */ - oh->mesg[0].type = H5O_MSG_NULL; - oh->mesg[0].dirty = TRUE; - oh->mesg[0].native = NULL; - oh->mesg[0].raw = oh->chunk[0].image + (H5O_SIZEOF_HDR(oh) - H5O_SIZEOF_CHKSUM_OH(oh)) + H5O_SIZEOF_MSGHDR_OH(oh); - oh->mesg[0].raw_size = size_hint - (size_t)H5O_SIZEOF_MSGHDR_OH(oh); - oh->mesg[0].chunkno = 0; - - /* Check for non-zero initial refcount on the object header */ - if(initial_rc > 0) { - /* Set the initial refcount & pin the header when its inserted */ - oh->rc = initial_rc; - insert_flags |= H5AC__PIN_ENTRY_FLAG; - } /* end if */ - - /* Set metadata tag in dxpl_id */ - H5_BEGIN_TAG(dxpl_id, oh_addr, FAIL); - - /* Cache object header */ - if(H5AC_insert_entry(f, dxpl_id, H5AC_OHDR, oh_addr, oh, insert_flags) < 0) - HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTINSERT, FAIL, "unable to cache object header") - - /* Reset object header pointer, now that it's been inserted into the cache */ - oh = NULL; - - /* Reset metadata tag in dxpl_id */ - H5_END_TAG(FAIL); - - /* Set up object location */ - loc->file = f; - loc->addr = oh_addr; - - /* Open it */ - if(H5O_open(loc) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object header") - -done: - if(ret_value < 0 && oh) - if(H5O__free(oh) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy object header data") - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_create() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_open - * - * Purpose: Opens an object header which is described by the symbol table - * entry OBJ_ENT. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Robb Matzke - * Monday, January 5, 1998 - * - * Modification: - * Raymond Lu - * 5 November 2007 - * Turn off the holding file variable if it's on. When it's - * needed, the caller will turn it on again. - *------------------------------------------------------------------------- - */ -herr_t -H5O_open(H5O_loc_t *loc) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Check args */ - HDassert(loc); - HDassert(loc->file); - -#ifdef H5O_DEBUG - if(H5DEBUG(O)) - HDfprintf(H5DEBUG(O), "> %a\n", loc->addr); -#endif - - /* Turn off the variable for holding file or increment open-lock counters */ - if(loc->holding_file) - loc->holding_file = FALSE; - else - H5F_INCR_NOPEN_OBJS(loc->file); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_open() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_open_name - * - * Purpose: Opens an object within an HDF5 file. - * - * Return: Success: An open object identifier - * Failure: Negative - * - * Programmer: Quincey Koziol - * March 5 2007 - * - *------------------------------------------------------------------------- - */ -hid_t -H5O_open_name(H5G_loc_t *loc, const char *name, hid_t lapl_id, hid_t dxpl_id, hbool_t app_ref) -{ - H5G_loc_t obj_loc; /* Location used to open group */ - H5G_name_t obj_path; /* Opened object group hier. path */ - H5O_loc_t obj_oloc; /* Opened object object location */ - hbool_t loc_found = FALSE; /* Entry at 'name' found */ - hid_t ret_value = FAIL; - - FUNC_ENTER_NOAPI(FAIL) - - /* Check args */ - HDassert(loc); - HDassert(name && *name); - - /* Set up opened group location to fill in */ - obj_loc.oloc = &obj_oloc; - obj_loc.path = &obj_path; - H5G_loc_reset(&obj_loc); - - /* Find the object's location */ - if(H5G_loc_find(loc, name, &obj_loc/*out*/, lapl_id, dxpl_id) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") - loc_found = TRUE; - - /* Open the object */ - if((ret_value = H5O_open_by_loc(&obj_loc, lapl_id, dxpl_id, app_ref)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object") - -done: - if(ret_value < 0 && loc_found) - if(H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location") - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_open_name() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_open_by_loc - * - * Purpose: Opens an object and returns an ID given its group loction. - * - * Return: Success: Open object identifier - * Failure: Negative - * - * Programmer: James Laird - * July 25 2006 - * - *------------------------------------------------------------------------- - */ -hid_t -H5O_open_by_loc(const H5G_loc_t *obj_loc, hid_t lapl_id, hid_t dxpl_id, hbool_t app_ref) -{ - const H5O_obj_class_t *obj_class; /* Class of object for location */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - HDassert(obj_loc); - - /* Get the object class for this location */ - if(NULL == (obj_class = H5O_obj_class(obj_loc->oloc, dxpl_id))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine object class") - - /* Call the object class's 'open' routine */ - HDassert(obj_class->open); - if((ret_value = obj_class->open(obj_loc, lapl_id, dxpl_id, app_ref)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_open_by_loc() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_close - * - * Purpose: Closes an object header that was previously open. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Robb Matzke - * Monday, January 5, 1998 - * - *------------------------------------------------------------------------- - */ -herr_t -H5O_close(H5O_loc_t *loc, hbool_t *file_closed /*out*/) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Check args */ - HDassert(loc); - HDassert(loc->file); - HDassert(H5F_NOPEN_OBJS(loc->file) > 0); - - /* Set the file_closed flag to the default value. - * This flag lets downstream code know if the file struct is - * still accessible and/or likely to contain useful data. - * It's needed by the evict-on-close code. Clients can ignore - * this value by passing in NULL. - */ - if(file_closed) - *file_closed = FALSE; - - /* Decrement open-lock counters */ - H5F_DECR_NOPEN_OBJS(loc->file); - -#ifdef H5O_DEBUG - if(H5DEBUG(O)) { - if(H5F_FILE_ID(loc->file)< 0 && 1 == H5F_NREFS(loc->file)) - HDfprintf(H5DEBUG(O), "< %a auto %lu remaining\n", - loc->addr, - (unsigned long)H5F_NOPEN_OBJS(loc->file)); - else - HDfprintf(H5DEBUG(O), "< %a\n", loc->addr); - } /* end if */ -#endif - - /* - * If the file open object count has reached the number of open mount points - * (each of which has a group open in the file) attempt to close the file. - */ - if(H5F_NOPEN_OBJS(loc->file) == H5F_NMOUNTS(loc->file)) - /* Attempt to close down the file hierarchy */ - if(H5F_try_close(loc->file, file_closed) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTCLOSEFILE, FAIL, "problem attempting file close") - - /* Release location information */ - if(H5O_loc_free(loc) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "problem attempting to free location") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_close() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_link_oh - * - * Purpose: Adjust the link count for an open object header by adding - * ADJUST to the link count. - * - * Return: Success: New link count - * - * Failure: Negative - * - * Programmer: Robb Matzke - * matzke@llnl.gov - * Aug 5 1997 - * - *------------------------------------------------------------------------- - */ -int -H5O_link_oh(H5F_t *f, int adjust, hid_t dxpl_id, H5O_t *oh, hbool_t *deleted) -{ - haddr_t addr = H5O_OH_GET_ADDR(oh); /* Object header address */ - int ret_value = -1; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* check args */ - HDassert(f); - HDassert(oh); - HDassert(deleted); - - /* Check for adjusting link count */ - if(adjust) { - if(adjust < 0) { - /* Check for too large of an adjustment */ - if((unsigned)(-adjust) > oh->nlink) - HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "link count would be negative") - - /* Adjust the link count for the object header */ - oh->nlink = (unsigned)((int)oh->nlink + adjust); - - /* Mark object header as dirty in cache */ - if(H5AC_mark_entry_dirty(oh) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTMARKDIRTY, FAIL, "unable to mark object header as dirty") - - /* Check if the object should be deleted */ - if(oh->nlink == 0) { - /* Check if the object is still open by the user */ - if(H5FO_opened(f, addr) != NULL) { - /* Flag the object to be deleted when it's closed */ - if(H5FO_mark(f, addr, TRUE) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't mark object for deletion") - } /* end if */ - else { - /* Mark the object header for deletion */ - *deleted = TRUE; - } /* end else */ - } /* end if */ - } /* end if */ - else { - /* A new object, or one that will be deleted */ - if(0 == oh->nlink) { - /* Check if the object is currently open, but marked for deletion */ - if(H5FO_marked(f, addr)) { - /* Remove "delete me" flag on the object */ - if(H5FO_mark(f, addr, FALSE) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't mark object for deletion") - } /* end if */ - } /* end if */ - - /* Adjust the link count for the object header */ - oh->nlink = (unsigned)((int)oh->nlink + adjust); - - /* Mark object header as dirty in cache */ - if(H5AC_mark_entry_dirty(oh) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTMARKDIRTY, FAIL, "unable to mark object header as dirty") - } /* end if */ - - /* Check for operations on refcount message */ - if(oh->version > H5O_VERSION_1) { - /* Check if the object has a refcount message already */ - if(oh->has_refcount_msg) { - /* Check for removing refcount message */ - if(oh->nlink <= 1) { - if(H5O_msg_remove_real(f, oh, H5O_MSG_REFCOUNT, H5O_ALL, NULL, NULL, TRUE, dxpl_id) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to delete refcount message") - oh->has_refcount_msg = FALSE; - } /* end if */ - /* Update refcount message with new link count */ - else { - H5O_refcount_t refcount = oh->nlink; - - if(H5O_msg_write_real(f, dxpl_id, oh, H5O_MSG_REFCOUNT, H5O_MSG_FLAG_DONTSHARE, 0, &refcount) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTUPDATE, FAIL, "unable to update refcount message") - } /* end else */ - } /* end if */ - else { - /* Check for adding refcount message to object */ - if(oh->nlink > 1) { - H5O_refcount_t refcount = oh->nlink; - - if(H5O_msg_append_real(f, dxpl_id, oh, H5O_MSG_REFCOUNT, H5O_MSG_FLAG_DONTSHARE, 0, &refcount) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "unable to create new refcount message") - oh->has_refcount_msg = TRUE; - } /* end if */ - } /* end else */ - } /* end if */ - } /* end if */ - - /* Set return value */ - ret_value = (int)oh->nlink; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_link_oh() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_link - * - * Purpose: Adjust the link count for an object header by adding - * ADJUST to the link count. - * - * Return: Success: New link count - * - * Failure: Negative - * - * Programmer: Robb Matzke - * matzke@llnl.gov - * Aug 5 1997 - * - *------------------------------------------------------------------------- - */ -int -H5O_link(const H5O_loc_t *loc, int adjust, hid_t dxpl_id) -{ - H5O_t *oh = NULL; - hbool_t deleted = FALSE; /* Whether the object was deleted */ - int ret_value = -1; /* Return value */ - - FUNC_ENTER_NOAPI_TAG(dxpl_id, loc->addr, FAIL) - - /* check args */ - HDassert(loc); - HDassert(loc->file); - HDassert(H5F_addr_defined(loc->addr)); - - /* Pin the object header */ - if(NULL == (oh = H5O_pin(loc, dxpl_id))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTPIN, FAIL, "unable to pin object header") - - /* Call the "real" link routine */ - if((ret_value = H5O_link_oh(loc->file, adjust, dxpl_id, oh, &deleted)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "unable to adjust object link count") - -done: - if(oh && H5O_unpin(oh) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "unable to unpin object header") - if(ret_value >= 0 && deleted && H5O_delete(loc->file, dxpl_id, loc->addr) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't delete object from file") - - FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL) -} /* end H5O_link() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_protect - * - * Purpose: Wrapper around H5AC_protect for use during a H5O_protect-> - * H5O_msg_append->...->H5O_msg_append->H5O_unprotect sequence of calls - * during an object's creation. - * - * Return: Success: Pointer to the object header structure for the - * object. - * Failure: NULL - * - * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu - * Dec 31 2002 - * - *------------------------------------------------------------------------- - */ -H5O_t * -H5O_protect(const H5O_loc_t *loc, hid_t dxpl_id, unsigned prot_flags, - hbool_t pin_all_chunks) -{ - H5O_t *oh = NULL; /* Object header protected */ - H5O_cache_ud_t udata; /* User data for protecting object header */ - H5O_cont_msgs_t cont_msg_info; /* Continuation message info */ - unsigned file_intent; /* R/W intent on file */ - H5O_t *ret_value = NULL; /* Return value */ - - FUNC_ENTER_NOAPI_TAG(dxpl_id, loc->addr, NULL) - - /* check args */ - HDassert(loc); - HDassert(loc->file); - - /* prot_flags may only contain the H5AC__READ_ONLY_FLAG */ - HDassert((prot_flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); - - /* Check for valid address */ - if(!H5F_addr_defined(loc->addr)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "address undefined") - - /* Check for write access on the file */ - file_intent = H5F_INTENT(loc->file); - if((0 == (prot_flags & H5AC__READ_ONLY_FLAG)) && (0 == (file_intent & H5F_ACC_RDWR))) - HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "no write intent on file") - - /* Construct the user data for protect callback */ - udata.made_attempt = FALSE; - udata.v1_pfx_nmesgs = 0; - udata.chunk0_size = 0; - udata.oh = NULL; - udata.common.f = loc->file; - udata.common.dxpl_id = dxpl_id; - udata.common.file_intent = file_intent; - udata.common.merged_null_msgs = 0; - HDmemset(&cont_msg_info, 0, sizeof(cont_msg_info)); - udata.common.cont_msg_info = &cont_msg_info; - udata.common.addr = loc->addr; - - /* Lock the object header into the cache */ - if(NULL == (oh = (H5O_t *)H5AC_protect(loc->file, dxpl_id, H5AC_OHDR, loc->addr, &udata, prot_flags))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, NULL, "unable to load object header") - - /* Check if there are any continuation messages to process */ - if(cont_msg_info.nmsgs > 0) { - size_t curr_msg; /* Current continuation message to process */ - H5O_chk_cache_ud_t chk_udata; /* User data for loading chunk */ - - /* Sanity check - we should only have continuation messages to process - * when the object header is actually loaded from the file. - */ - HDassert(udata.made_attempt == TRUE); - HDassert(cont_msg_info.msgs); - - /* Construct the user data for protecting chunks */ - chk_udata.decoding = TRUE; - chk_udata.oh = oh; - chk_udata.chunkno = UINT_MAX; /* Set to invalid value, for better error detection */ - chk_udata.common.f = loc->file; - chk_udata.common.dxpl_id = dxpl_id; - chk_udata.common.file_intent = file_intent; - chk_udata.common.merged_null_msgs = udata.common.merged_null_msgs; - chk_udata.common.cont_msg_info = &cont_msg_info; - - /* Read in continuation messages, until there are no more */ - /* (Note that loading chunks could increase the # of continuation - * messages if new ones are found - QAK, 19/11/2016) - */ - curr_msg = 0; - while(curr_msg < cont_msg_info.nmsgs) { - H5O_chunk_proxy_t *chk_proxy; /* Proxy for chunk, to bring it into memory */ -#ifndef NDEBUG - size_t chkcnt = oh->nchunks; /* Count of chunks (for sanity checking) */ -#endif /* NDEBUG */ - - /* Bring the chunk into the cache */ - /* (which adds to the object header) */ - chk_udata.common.addr = cont_msg_info.msgs[curr_msg].addr; - chk_udata.size = cont_msg_info.msgs[curr_msg].size; - if(NULL == (chk_proxy = (H5O_chunk_proxy_t *)H5AC_protect(loc->file, dxpl_id, H5AC_OHDR_CHK, cont_msg_info.msgs[curr_msg].addr, &chk_udata, prot_flags))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, NULL, "unable to load object header chunk") - - /* Sanity check */ - HDassert(chk_proxy->oh == oh); - HDassert(chk_proxy->chunkno == chkcnt); - HDassert(oh->nchunks == (chkcnt + 1)); - - /* Release the chunk from the cache */ - if(H5AC_unprotect(loc->file, dxpl_id, H5AC_OHDR_CHK, cont_msg_info.msgs[curr_msg].addr, chk_proxy, H5AC__NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to release object header chunk") - - /* Advance to next continuation message */ - curr_msg++; - } /* end while */ - - /* Release any continuation messages built up */ - cont_msg_info.msgs = (H5O_cont_t *)H5FL_SEQ_FREE(H5O_cont_t, cont_msg_info.msgs); - - /* Pass back out some of the chunk's user data */ - udata.common.merged_null_msgs = chk_udata.common.merged_null_msgs; - } /* end if */ - - /* Check for incorrect # of object header messages, if we've just loaded - * this object header from the file - */ - if(udata.made_attempt) { -/* Don't enforce the error on an incorrect # of object header messages bug - * unless strict format checking is enabled. This allows for older - * files, created with a version of the library that had a bug in tracking - * the correct # of header messages to be read in without the library - * erroring out here. -QAK - */ -#ifdef H5_STRICT_FORMAT_CHECKS - /* Check for incorrect # of messages in v1 object header */ - if(oh->version == H5O_VERSION_1 && - (oh->nmesgs + udata.common.merged_null_msgs) != udata.v1_pfx_nmesgs) - HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "corrupt object header - incorrect # of messages") -#endif /* H5_STRICT_FORMAT_CHECKS */ - } /* end if */ - -#ifdef H5O_DEBUG -H5O_assert(oh); -#endif /* H5O_DEBUG */ - - /* Pin the other chunks also when requested, so that the object header - * proxy can be set up. - */ - if(pin_all_chunks && oh->nchunks > 1) { - unsigned u; /* Local index variable */ - - /* Sanity check */ - HDassert(oh->swmr_write); - - /* Iterate over chunks > 0 */ - for(u = 1; u < oh->nchunks; u++) { - H5O_chunk_proxy_t *chk_proxy; /* Chunk proxy */ - - /* Protect chunk */ - if(NULL == (chk_proxy = H5O_chunk_protect(loc->file, dxpl_id, oh, u))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, NULL, "unable to protect object header chunk") - - /* Pin chunk proxy*/ - if(H5AC_pin_protected_entry(chk_proxy) < 0 ) - HGOTO_ERROR(H5E_OHDR, H5E_CANTPIN, NULL, "unable to pin object header chunk") - - /* Unprotect chunk */ - if(H5O_chunk_unprotect(loc->file, dxpl_id, chk_proxy, FALSE) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to unprotect object header chunk") - - /* Preserve chunk proxy pointer for later */ - oh->chunk[u].chunk_proxy = chk_proxy; - } /* end for */ - - /* Set the flag for the unprotect */ - oh->chunks_pinned = TRUE; - } /* end if */ - - /* Set return value */ - ret_value = oh; - -done: - if(ret_value == NULL && oh) - if(H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to release object header") - - FUNC_LEAVE_NOAPI_TAG(ret_value, NULL) -} /* end H5O_protect() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_pin - * - * Purpose: Pin an object header down for use during a sequence of message - * operations, which prevents the object header from being - * evicted from the cache. - * - * Return: Success: Pointer to the object header structure for the - * object. - * Failure: NULL - * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Jul 13 2008 - * - *------------------------------------------------------------------------- - */ -H5O_t * -H5O_pin(const H5O_loc_t *loc, hid_t dxpl_id) -{ - H5O_t *oh = NULL; /* Object header */ - H5O_t *ret_value = NULL; /* Return value */ - - FUNC_ENTER_NOAPI(NULL) - - /* check args */ - HDassert(loc); - - /* Get header */ - if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC__NO_FLAGS_SET, FALSE))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, NULL, "unable to protect object header") - - /* Increment the reference count on the object header */ - /* (which will pin it, if appropriate) */ - if(H5O_inc_rc(oh) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINC, NULL, "unable to increment reference count on object header") - - /* Set the return value */ - ret_value = oh; - -done: - /* Release the object header from the cache */ - if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to release object header") - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_pin() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_unpin - * - * Purpose: Unpin an object header, allowing it to be evicted from the - * metadata cache. - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Jul 13 2008 - * - *------------------------------------------------------------------------- - */ -herr_t -H5O_unpin(H5O_t *oh) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* check args */ - HDassert(oh); - - /* Decrement the reference count on the object header */ - /* (which will unpin it, if appropriate) */ - if(H5O_dec_rc(oh) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement reference count on object header") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_unpin() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_unprotect - * - * Purpose: Wrapper around H5AC_unprotect for use during a H5O_protect-> - * H5O_msg_append->...->H5O_msg_append->H5O_unprotect sequence of calls - * during an object's creation. - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu - * Dec 31 2002 - * - *------------------------------------------------------------------------- - */ -herr_t -H5O_unprotect(const H5O_loc_t *loc, hid_t dxpl_id, H5O_t *oh, unsigned oh_flags) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* check args */ - HDassert(loc); - HDassert(oh); - - /* Unpin the other chunks */ - if(oh->chunks_pinned && oh->nchunks > 1) { - unsigned u; /* Local index variable */ - - /* Sanity check */ - HDassert(oh->swmr_write); - - /* Iterate over chunks > 0 */ - for(u = 1; u < oh->nchunks; u++) { - if(NULL != oh->chunk[u].chunk_proxy) { - /* Release chunk proxy */ - if(H5AC_unpin_entry(oh->chunk[u].chunk_proxy) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "unable to unpin object header chunk") - oh->chunk[u].chunk_proxy = NULL; - } /* end if */ - } /* end for */ - - /* Reet the flag from the unprotect */ - oh->chunks_pinned = FALSE; - } /* end if */ - - /* Unprotect the object header */ - if(H5AC_unprotect(loc->file, dxpl_id, H5AC_OHDR, oh->chunk[0].addr, oh, oh_flags) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_unprotect() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_touch_oh - * - * Purpose: If FORCE is non-zero then create a modification time message - * unless one already exists. Then update any existing - * modification time message with the current time. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Robb Matzke - * Monday, July 27, 1998 - * - *------------------------------------------------------------------------- - */ -herr_t -H5O_touch_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh, hbool_t force) -{ - H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that message is in */ - hbool_t chk_dirtied = FALSE; /* Flag for unprotecting chunk */ - time_t now; /* Current time */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - HDassert(f); - HDassert(oh); - - /* Check if this object header is tracking times */ - if(oh->flags & H5O_HDR_STORE_TIMES) { - /* Get current time */ - now = H5_now(); - - /* Check version, to determine how to store time information */ - if(oh->version == H5O_VERSION_1) { - size_t idx; /* Index of modification time message to update */ - - /* Look for existing message */ - for(idx = 0; idx < oh->nmesgs; idx++) - if(H5O_MSG_MTIME == oh->mesg[idx].type || H5O_MSG_MTIME_NEW == oh->mesg[idx].type) - break; - - /* Create a new message, if necessary */ - if(idx == oh->nmesgs) { - unsigned mesg_flags = 0; /* Flags for message in object header */ - - /* If we would have to create a new message, but we aren't 'forcing' it, get out now */ - if(!force) - HGOTO_DONE(SUCCEED); /*nothing to do*/ - - /* Allocate space for the modification time message */ - if(H5O_msg_alloc(f, dxpl_id, oh, H5O_MSG_MTIME_NEW, &mesg_flags, &now, &idx) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to allocate space for modification time message") - - /* Set the message's flags if appropriate */ - oh->mesg[idx].flags = (uint8_t)mesg_flags; - } /* end if */ - - /* Protect chunk */ - if(NULL == (chk_proxy = H5O_chunk_protect(f, dxpl_id, oh, oh->mesg[idx].chunkno))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header chunk") - - /* Allocate 'native' space, if necessary */ - if(NULL == oh->mesg[idx].native) { - if(NULL == (oh->mesg[idx].native = H5FL_MALLOC(time_t))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "memory allocation failed for modification time message") - } /* end if */ - - /* Update the message */ - *((time_t *)(oh->mesg[idx].native)) = now; - - /* Mark the message as dirty */ - oh->mesg[idx].dirty = TRUE; - chk_dirtied = TRUE; - } /* end if */ - else { - /* XXX: For now, update access time & change fields in the object header */ - /* (will need to add some code to update modification time appropriately) */ - oh->atime = oh->ctime = now; - - /* Mark object header as dirty in cache */ - if(H5AC_mark_entry_dirty(oh) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTMARKDIRTY, FAIL, "unable to mark object header as dirty") - } /* end else */ - } /* end if */ - -done: - /* Release chunk */ - if(chk_proxy && H5O_chunk_unprotect(f, dxpl_id, chk_proxy, chk_dirtied) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_touch_oh() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_touch - * - * Purpose: Touch an object by setting the modification time to the - * current time and marking the object as dirty. Unless FORCE - * is non-zero, nothing happens if there is no MTIME message in - * the object header. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Robb Matzke - * Monday, July 27, 1998 - * - *------------------------------------------------------------------------- - */ -herr_t -H5O_touch(const H5O_loc_t *loc, hbool_t force, hid_t dxpl_id) -{ - H5O_t *oh = NULL; /* Object header to modify */ - unsigned oh_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting object header */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* check args */ - HDassert(loc); - - /* Get the object header */ - if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC__NO_FLAGS_SET, FALSE))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") - - /* Create/Update the modification time message */ - if(H5O_touch_oh(loc->file, dxpl_id, oh, force) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "unable to update object modificaton time") - - /* Mark object header as changed */ - oh_flags |= H5AC__DIRTIED_FLAG; - -done: - if(oh && H5O_unprotect(loc, dxpl_id, oh, oh_flags) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_touch() */ - -#ifdef H5O_ENABLE_BOGUS - -/*------------------------------------------------------------------------- - * Function: H5O_bogus_oh - * - * Purpose: Create a "bogus" message unless one already exists. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * - * Tuesday, January 21, 2003 - * - *------------------------------------------------------------------------- - */ -herr_t -H5O_bogus_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned bogus_id, unsigned mesg_flags) -{ - size_t idx; /* Local index variable */ - H5O_msg_class_t *type; /* Message class type */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - HDassert(f); - HDassert(oh); - - /* Look for existing message */ - for(idx = 0; idx < oh->nmesgs; idx++) - if(H5O_MSG_BOGUS_VALID == oh->mesg[idx].type || - H5O_MSG_BOGUS_INVALID == oh->mesg[idx].type) - break; - - /* Create a new message */ - if(idx == oh->nmesgs) { - H5O_bogus_t *bogus; /* Pointer to the bogus information */ - - /* Allocate the native message in memory */ - if(NULL == (bogus = H5MM_malloc(sizeof(H5O_bogus_t)))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "memory allocation failed for 'bogus' message") - - /* Update the native value */ - bogus->u = H5O_BOGUS_VALUE; - - if(bogus_id == H5O_BOGUS_VALID_ID) - type = H5O_MSG_BOGUS_VALID; - else if(bogus_id == H5O_BOGUS_INVALID_ID) - type = H5O_MSG_BOGUS_INVALID; - else - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID for 'bogus' message") - - /* Allocate space in the object header for bogus message */ - if(H5O_msg_alloc(f, dxpl_id, oh, type, &mesg_flags, bogus, &idx) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to allocate space for 'bogus' message") - - /* Point to "bogus" information (take it over) */ - oh->mesg[idx].native = bogus; - - /* Set the appropriate flags for the message */ - oh->mesg[idx].flags = mesg_flags; - - /* Mark the message and object header as dirty */ - oh->mesg[idx].dirty = TRUE; - oh->cache_info.is_dirty = TRUE; - } /* end if */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_bogus_oh() */ -#endif /* H5O_ENABLE_BOGUS */ - - -/*------------------------------------------------------------------------- - * Function: H5O_delete - * - * Purpose: Delete an object header from a file. This frees the file - * space used for the object header (and it's continuation blocks) - * and also walks through each header message and asks it to - * remove all the pieces of the file referenced by the header. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu - * Mar 19 2003 - * - *------------------------------------------------------------------------- - */ -herr_t -H5O_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr) -{ - H5O_t *oh = NULL; /* Object header information */ - H5O_loc_t loc; /* Object location for object to delete */ - unsigned oh_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting object header */ - hbool_t corked; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_TAG(dxpl_id, addr, FAIL) - - /* Check args */ - HDassert(f); - HDassert(H5F_addr_defined(addr)); - - /* Set up the object location */ - loc.file = f; - loc.addr = addr; - loc.holding_file = FALSE; - - /* Get the object header information */ - if(NULL == (oh = H5O_protect(&loc, dxpl_id, H5AC__NO_FLAGS_SET, FALSE))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") - - /* Delete object */ - if(H5O_delete_oh(f, dxpl_id, oh) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't delete object from file") - - /* Uncork cache entries with tag: addr */ - if(H5AC_cork(f, addr, H5AC__GET_CORKED, &corked) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to retrieve an object's cork status") - if(corked) - if(H5AC_cork(f, addr, H5AC__UNCORK, NULL) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTUNCORK, FAIL, "unable to uncork an object") - - /* Mark object header as deleted */ - oh_flags = H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG; - -done: - if(oh && H5O_unprotect(&loc, dxpl_id, oh, oh_flags) < 0) - HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header") - - FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL) -} /* end H5O_delete() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_delete_oh - * - * Purpose: Internal function to: - * Delete an object header from a file. This frees the file - * space used for the object header (and it's continuation blocks) - * and also walks through each header message and asks it to - * remove all the pieces of the file referenced by the header. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu - * Mar 19 2003 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5O_delete_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh) -{ - H5O_mesg_t *curr_msg; /* Pointer to current message being operated on */ - unsigned u; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - /* Check args */ - HDassert(f); - HDassert(oh); - - /* Walk through the list of object header messages, asking each one to - * delete any file space used - */ - for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { - /* Free any space referred to in the file from this message */ - if(H5O_delete_mesg(f, dxpl_id, oh, curr_msg) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to delete file space for object header message") - } /* end for */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_delete_oh() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_obj_type - * - * Purpose: Retrieves the type of object pointed to by `loc'. - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Robb Matzke - * Wednesday, November 4, 1998 - * - *------------------------------------------------------------------------- - */ -herr_t -H5O_obj_type(const H5O_loc_t *loc, H5O_type_t *obj_type, hid_t dxpl_id) -{ - H5O_t *oh = NULL; /* Object header for location */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_TAG(dxpl_id, loc->addr, FAIL) - - /* Load the object header */ - if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC__READ_ONLY_FLAG, FALSE))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") - - /* Retrieve the type of the object */ - if(H5O_obj_type_real(oh, obj_type) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to determine object type") - -done: - if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") - - FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL) -} /* end H5O_obj_type() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_obj_type_real - * - * Purpose: Returns the type of object pointed to by `oh'. - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Quincey Koziol - * Monday, November 21, 2005 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5O_obj_type_real(H5O_t *oh, H5O_type_t *obj_type) -{ - const H5O_obj_class_t *obj_class; /* Class of object for header */ - - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Sanity check */ - HDassert(oh); - HDassert(obj_type); - - /* Look up class for object header */ - if(NULL == (obj_class = H5O_obj_class_real(oh))) { - /* Clear error stack from "failed" class lookup */ - H5E_clear_stack(NULL); - - /* Set type to "unknown" */ - *obj_type = H5O_TYPE_UNKNOWN; - } /* end if */ - else { - /* Set object type */ - *obj_type = obj_class->type; - } /* end else */ - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5O_obj_type_real() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_obj_class - * - * Purpose: Returns the class of object pointed to by `loc'. - * - * Return: Success: An object class - * Failure: NULL - * - * Programmer: Quincey Koziol - * Monday, November 6, 2006 - * - *------------------------------------------------------------------------- - */ -const H5O_obj_class_t * -H5O_obj_class(const H5O_loc_t *loc, hid_t dxpl_id) -{ - H5O_t *oh = NULL; /* Object header for location */ - const H5O_obj_class_t *ret_value = NULL; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT_TAG(dxpl_id, loc->addr, NULL) - - /* Load the object header */ - if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC__READ_ONLY_FLAG, FALSE))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, NULL, "unable to load object header") - - /* Test whether entry qualifies as a particular type of object */ - if(NULL == (ret_value = H5O_obj_class_real(oh))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to determine object type") - -done: - if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to release object header") - - FUNC_LEAVE_NOAPI_TAG(ret_value, NULL) -} /* end H5O_obj_class() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_obj_class_real - * - * Purpose: Returns the class of object pointed to by `oh'. - * - * Return: Success: An object class - * Failure: NULL - * - * Programmer: Quincey Koziol - * Monday, November 21, 2005 - * - *------------------------------------------------------------------------- - */ -static const H5O_obj_class_t * -H5O_obj_class_real(H5O_t *oh) -{ - size_t i; /* Local index variable */ - const H5O_obj_class_t *ret_value = NULL; /* Return value */ - - FUNC_ENTER_NOAPI(NULL) - - /* Sanity check */ - HDassert(oh); - - /* Test whether entry qualifies as a particular type of object */ - /* (Note: loop is in reverse order, to test specific objects first) */ - for(i = NELMTS(H5O_obj_class_g); i > 0; --i) { - htri_t isa; /* Is entry a particular type? */ - - if((isa = (H5O_obj_class_g[i - 1]->isa)(oh)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to determine object type") - else if(isa) - HGOTO_DONE(H5O_obj_class_g[i - 1]) - } /* end for */ - - if(0 == i) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to determine object type") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_obj_class_real() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_get_loc - * - * Purpose: Gets the object location for an object given its ID. - * - * Return: Success: Pointer to H5O_loc_t - * Failure: NULL - * - * Programmer: James Laird - * July 25 2006 - * - *------------------------------------------------------------------------- - */ -H5O_loc_t * -H5O_get_loc(hid_t object_id) -{ - H5O_loc_t *ret_value = NULL; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - switch(H5I_get_type(object_id)) { - case H5I_GROUP: - if(NULL == (ret_value = H5O_OBJ_GROUP->get_oloc(object_id))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to get object location from group ID") - break; - - case H5I_DATASET: - if(NULL == (ret_value = H5O_OBJ_DATASET->get_oloc(object_id))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to get object location from dataset ID") - break; - - case H5I_DATATYPE: - if(NULL == (ret_value = H5O_OBJ_DATATYPE->get_oloc(object_id))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to get object location from datatype ID") - break; - - case H5I_UNINIT: - case H5I_BADID: - case H5I_FILE: - case H5I_DATASPACE: - case H5I_ATTR: - case H5I_REFERENCE: - case H5I_VFL: - case H5I_GENPROP_CLS: - case H5I_GENPROP_LST: - case H5I_ERROR_CLASS: - case H5I_ERROR_MSG: - case H5I_ERROR_STACK: - case H5I_NTYPES: - default: - HGOTO_ERROR(H5E_OHDR, H5E_BADTYPE, NULL, "invalid object type") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_get_loc() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_loc_reset - * - * Purpose: Reset a object location to an empty state - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Quincey Koziol - * Monday, September 19, 2005 - * - *------------------------------------------------------------------------- - */ -herr_t -H5O_loc_reset(H5O_loc_t *loc) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Check arguments */ - HDassert(loc); - - /* Clear the object location to an empty state */ - HDmemset(loc, 0, sizeof(H5O_loc_t)); - loc->addr = HADDR_UNDEF; - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5O_loc_reset() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_loc_copy - * - * Purpose: Copy object location information - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu - * Monday, September 19, 2005 - * - * Notes: 'depth' parameter determines how much of the group entry - * structure we want to copy. The values are: - * H5_COPY_SHALLOW - Copy all the field values from the source - * to the destination, but not copying objects pointed to. - * (Destination "takes ownership" of objects pointed to) - * H5_COPY_DEEP - Copy all the fields from the source to - * the destination, deep copying objects pointed to. - * - *------------------------------------------------------------------------- - */ -herr_t -H5O_loc_copy(H5O_loc_t *dst, H5O_loc_t *src, H5_copy_depth_t depth) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Check arguments */ - HDassert(src); - HDassert(dst); - HDassert(depth == H5_COPY_SHALLOW || depth == H5_COPY_DEEP); - - /* Copy the top level information */ - HDmemcpy(dst, src, sizeof(H5O_loc_t)); - - /* Deep copy the names */ - if(depth == H5_COPY_DEEP) { - /* If the original entry was holding open the file, this one should - * hold it open, too. - */ - if(src->holding_file) - H5F_INCR_NOPEN_OBJS(dst->file); - } else if(depth == H5_COPY_SHALLOW) { - H5O_loc_reset(src); - } /* end if */ - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5O_loc_copy() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_loc_hold_file - * - * Purpose: Have this object header hold a file open until it is - * released. - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: James Laird - * Wednesday, August 16, 2006 - * - *------------------------------------------------------------------------- - */ -herr_t -H5O_loc_hold_file(H5O_loc_t *loc) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Check arguments */ - HDassert(loc); - HDassert(loc->file); - - /* If this location is not already holding its file open, do so. */ - if(!loc->holding_file) { - H5F_INCR_NOPEN_OBJS(loc->file); - loc->holding_file = TRUE; - } /* end if */ - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5O_loc_hold_file() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_loc_free - * - * Purpose: Release resources used by this object header location. - * Not to be confused with H5O_close; this is used on - * locations that don't correspond to open objects. - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: James Laird - * Wednesday, August 16, 2006 - * - *------------------------------------------------------------------------- - */ -herr_t -H5O_loc_free(H5O_loc_t *loc) -{ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI_NOINIT - - /* Check arguments */ - HDassert(loc); - - /* If this location is holding its file open try to close the file. */ - if(loc->holding_file) { - H5F_DECR_NOPEN_OBJS(loc->file); - loc->holding_file = FALSE; - if(H5F_NOPEN_OBJS(loc->file) <= 0) { - if(H5F_try_close(loc->file, NULL) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close file") - } /* end if */ - } /* end if */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_loc_free() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_get_hdr_info - * - * Purpose: Retrieve the object header information for an object - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Quincey Koziol - * September 22 2009 - * - *------------------------------------------------------------------------- - */ -herr_t -H5O_get_hdr_info(const H5O_loc_t *loc, hid_t dxpl_id, H5O_hdr_info_t *hdr) -{ - H5O_t *oh = NULL; /* Object header */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Check args */ - HDassert(loc); - HDassert(hdr); - - /* Reset the object header info structure */ - HDmemset(hdr, 0, sizeof(*hdr)); - - /* Get the object header */ - if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC__READ_ONLY_FLAG, FALSE))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header") - - /* Get the information for the object header */ - if(H5O_get_hdr_info_real(oh, hdr) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object header info") - -done: - if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header") - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_get_hdr_info() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_get_hdr_info_real - * - * Purpose: Internal routine to retrieve the object header information for an object - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Quincey Koziol - * September 22 2009 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5O_get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr) -{ - const H5O_mesg_t *curr_msg; /* Pointer to current message being operated on */ - const H5O_chunk_t *curr_chunk; /* Pointer to current message being operated on */ - unsigned u; /* Local index variable */ - - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Check args */ - HDassert(oh); - HDassert(hdr); - - /* Set the version for the object header */ - hdr->version = oh->version; - - /* Set the number of messages & chunks */ - H5_CHECKED_ASSIGN(hdr->nmesgs, unsigned, oh->nmesgs, size_t); - H5_CHECKED_ASSIGN(hdr->nchunks, unsigned, oh->nchunks, size_t); - - /* Set the status flags */ - hdr->flags = oh->flags; - - /* Iterate over all the messages, accumulating message size & type information */ - hdr->space.meta = (hsize_t)H5O_SIZEOF_HDR(oh) + (hsize_t)(H5O_SIZEOF_CHKHDR_OH(oh) * (oh->nchunks - 1)); - hdr->space.mesg = 0; - hdr->space.free = 0; - hdr->mesg.present = 0; - hdr->mesg.shared = 0; - for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { - uint64_t type_flag; /* Flag for message type */ - - /* Accumulate space usage information, based on the type of message */ - if(H5O_NULL_ID == curr_msg->type->id) - hdr->space.free += (hsize_t)((size_t)H5O_SIZEOF_MSGHDR_OH(oh) + curr_msg->raw_size); - else if(H5O_CONT_ID == curr_msg->type->id) - hdr->space.meta += (hsize_t)((size_t)H5O_SIZEOF_MSGHDR_OH(oh) + curr_msg->raw_size); - else { - hdr->space.meta += (hsize_t)H5O_SIZEOF_MSGHDR_OH(oh); - hdr->space.mesg += curr_msg->raw_size; - } /* end else */ - - /* Set flag to indicate presence of message type */ - type_flag = ((uint64_t)1) << curr_msg->type->id; - hdr->mesg.present |= type_flag; - - /* Set flag if the message is shared in some way */ - if(curr_msg->flags & H5O_MSG_FLAG_SHARED) \ - hdr->mesg.shared |= type_flag; - } /* end for */ - - /* Iterate over all the chunks, adding any gaps to the free space */ - hdr->space.total = 0; - for(u = 0, curr_chunk = &oh->chunk[0]; u < oh->nchunks; u++, curr_chunk++) { - /* Accumulate the size of the header on disk */ - hdr->space.total += curr_chunk->size; - - /* If the chunk has a gap, add it to the free space */ - hdr->space.free += curr_chunk->gap; - } /* end for */ - - /* Sanity check that all the bytes are accounted for */ - HDassert(hdr->space.total == (hdr->space.free + hdr->space.meta + hdr->space.mesg)); - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5O_get_hdr_info_real() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_get_info - * - * Purpose: Retrieve the information for an object - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Quincey Koziol - * November 21 2006 - * - *------------------------------------------------------------------------- - */ -herr_t -H5O_get_info(const H5O_loc_t *loc, hid_t dxpl_id, hbool_t want_ih_info, - H5O_info_t *oinfo) -{ - const H5O_obj_class_t *obj_class; /* Class of object for header */ - H5O_t *oh = NULL; /* Object header */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_TAG(dxpl_id, loc->addr, FAIL) - - /* Check args */ - HDassert(loc); - HDassert(oinfo); - - /* Get the object header */ - if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC__READ_ONLY_FLAG, FALSE))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") - - /* Reset the object info structure */ - HDmemset(oinfo, 0, sizeof(*oinfo)); - - /* Retrieve the file's fileno */ - H5F_GET_FILENO(loc->file, oinfo->fileno); - - /* Set the object's address */ - oinfo->addr = loc->addr; - - /* Get class for object */ - if(NULL == (obj_class = H5O_obj_class_real(oh))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine object class") - - /* Retrieve the type of the object */ - oinfo->type = obj_class->type; - - /* Set the object's reference count */ - oinfo->rc = oh->nlink; - - /* Get modification time for object */ - if(oh->version > H5O_VERSION_1) { - oinfo->atime = oh->atime; - oinfo->mtime = oh->mtime; - oinfo->ctime = oh->ctime; - oinfo->btime = oh->btime; - } /* end if */ - else { - htri_t exists; /* Flag if header message of interest exists */ - - /* No information for access & modification fields */ - /* (we stopped updating the "modification time" header message for - * raw data changes, so the "modification time" header message - * is closest to the 'change time', in POSIX terms - QAK) - */ - oinfo->atime = 0; - oinfo->mtime = 0; - oinfo->btime = 0; - - /* Might be information for modification time */ - if((exists = H5O_msg_exists_oh(oh, H5O_MTIME_ID)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "unable to check for MTIME message") - if(exists > 0) { - /* Get "old style" modification time info */ - if(NULL == H5O_msg_read_oh(loc->file, dxpl_id, oh, H5O_MTIME_ID, &oinfo->ctime)) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't read MTIME message") - } /* end if */ - else { - /* Check for "new style" modification time info */ - if((exists = H5O_msg_exists_oh(oh, H5O_MTIME_NEW_ID)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "unable to check for MTIME_NEW message") - if(exists > 0) { - /* Get "new style" modification time info */ - if(NULL == H5O_msg_read_oh(loc->file, dxpl_id, oh, H5O_MTIME_NEW_ID, &oinfo->ctime)) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't read MTIME_NEW message") - } /* end if */ - else - oinfo->ctime = 0; - } /* end else */ - } /* end else */ - - /* Get the information for the object header */ - if(H5O_get_hdr_info_real(oh, &oinfo->hdr) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object header info") - - /* Retrieve # of attributes */ - if(H5O_attr_count_real(loc->file, dxpl_id, oh, &oinfo->num_attrs) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve attribute count") - - /* Get B-tree & heap metadata storage size, if requested */ - if(want_ih_info) { - /* Check for 'bh_info' callback for this type of object */ - if(obj_class->bh_info) { - /* Call the object's class 'bh_info' routine */ - if((obj_class->bh_info)(loc, dxpl_id, oh, &oinfo->meta_size.obj) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object's btree & heap info") - } /* end if */ - - /* Get B-tree & heap info for any attributes */ - if(oinfo->num_attrs > 0) { - if(H5O_attr_bh_info(loc->file, dxpl_id, oh, &oinfo->meta_size.attr) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve attribute btree & heap info") - } /* end if */ - } /* end if */ - -done: - if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") - - FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL) -} /* end H5O_get_info() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_get_create_plist - * - * Purpose: Retrieve the object creation properties for an object - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Quincey Koziol - * November 28 2006 - * - *------------------------------------------------------------------------- - */ -herr_t -H5O_get_create_plist(const H5O_loc_t *loc, hid_t dxpl_id, H5P_genplist_t *oc_plist) -{ - H5O_t *oh = NULL; /* Object header */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Check args */ - HDassert(loc); - HDassert(oc_plist); - - /* Get the object header */ - if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC__READ_ONLY_FLAG, FALSE))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") - - /* Set property values, if they were used for the object */ - if(oh->version > H5O_VERSION_1) { - uint8_t ohdr_flags; /* "User-visible" object header status flags */ - - /* Set attribute storage values */ - if(H5P_set(oc_plist, H5O_CRT_ATTR_MAX_COMPACT_NAME, &oh->max_compact) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set max. # of compact attributes in property list") - if(H5P_set(oc_plist, H5O_CRT_ATTR_MIN_DENSE_NAME, &oh->min_dense) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set min. # of dense attributes in property list") - - /* Mask off non-"user visible" flags */ - ohdr_flags = oh->flags & (H5O_HDR_ATTR_CRT_ORDER_TRACKED | H5O_HDR_ATTR_CRT_ORDER_INDEXED | H5O_HDR_STORE_TIMES); - - /* Set object header flags */ - if(H5P_set(oc_plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set object header flags") - } /* end if */ - -done: - if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_get_create_plist() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_get_nlinks - * - * Purpose: Retrieve the number of link messages read in from the file - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Quincey Koziol - * March 11 2007 - * - *------------------------------------------------------------------------- - */ -herr_t -H5O_get_nlinks(const H5O_loc_t *loc, hid_t dxpl_id, hsize_t *nlinks) -{ - H5O_t *oh = NULL; /* Object header */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Check args */ - HDassert(loc); - HDassert(nlinks); - - /* Get the object header */ - if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC__READ_ONLY_FLAG, FALSE))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") - - /* Retrieve the # of link messages seen when the object header was loaded */ - *nlinks = oh->link_msgs_seen; - -done: - if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_get_nlinks() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_obj_create - * - * Purpose: Creates an object, in an abstract manner. - * - * Return: Success: Pointer to object opened - * Failure: NULL - * - * Programmer: Quincey Koziol - * April 9 2007 - * - *------------------------------------------------------------------------- - */ -void * -H5O_obj_create(H5F_t *f, H5O_type_t obj_type, void *crt_info, H5G_loc_t *obj_loc, - hid_t dxpl_id) -{ - size_t u; /* Local index variable */ - void *ret_value = NULL; /* Return value */ - - FUNC_ENTER_NOAPI(NULL) - - /* Sanity checks */ - HDassert(f); - HDassert(obj_type >= H5O_TYPE_GROUP && obj_type <= H5O_TYPE_NAMED_DATATYPE); - HDassert(crt_info); - HDassert(obj_loc); - - /* Iterate through the object classes */ - for(u = 0; u < NELMTS(H5O_obj_class_g); u++) { - /* Check for correct type of object to create */ - if(H5O_obj_class_g[u]->type == obj_type) { - /* Call the object class's 'create' routine */ - HDassert(H5O_obj_class_g[u]->create); - if(NULL == (ret_value = H5O_obj_class_g[u]->create(f, crt_info, obj_loc, dxpl_id))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object") - - /* Break out of loop */ - break; - } /* end if */ - } /* end for */ - HDassert(ret_value); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_obj_create() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_get_oh_addr - * - * Purpose: Retrieve the address of the object header - * - * Note: This routine participates in the "Inlining C struct access" - * pattern, don't call it directly, use the appropriate macro - * defined in H5Oprivate.h. - * - * Return: Success: Valid haddr_t - * Failure: HADDR_UNDEF - * - * Programmer: Quincey Koziol - * March 15 2007 - * - *------------------------------------------------------------------------- - */ -haddr_t -H5O_get_oh_addr(const H5O_t *oh) -{ - /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - HDassert(oh); - HDassert(oh->chunk); - - FUNC_LEAVE_NOAPI(oh->chunk[0].addr) -} /* end H5O_get_oh_addr() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_get_rc_and_type - * - * Purpose: Retrieve an object's reference count and type - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Quincey Koziol - * November 4 2007 - * - *------------------------------------------------------------------------- - */ -herr_t -H5O_get_rc_and_type(const H5O_loc_t *loc, hid_t dxpl_id, unsigned *rc, H5O_type_t *otype) -{ - H5O_t *oh = NULL; /* Object header */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Check args */ - HDassert(loc); - - /* Get the object header */ - if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC__READ_ONLY_FLAG, FALSE))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") - - /* Set the object's reference count */ - if(rc) - *rc = oh->nlink; - - /* Retrieve the type of the object */ - if(otype) - if(H5O_obj_type_real(oh, otype) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to determine object type") - -done: - if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_get_rc_and_type() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_free_visit_visited - * - * Purpose: Free the key for an object visited during a group traversal - * - * Return: Non-negative on success, negative on failure - * - * Programmer: Quincey Koziol - * Nov 25, 2007 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5O_free_visit_visited(void *item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSED *operator_data/*in,out*/) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - item = H5FL_FREE(H5_obj_t, item); - - FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5O_free_visit_visited() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_visit_cb - * - * Purpose: Callback function for recursively visiting objects from a group - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Quincey Koziol - * Nov 25, 2007 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5O_visit_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info_t *linfo, - void *_udata) -{ - H5O_iter_visit_ud_t *udata = (H5O_iter_visit_ud_t *)_udata; /* User data for callback */ - H5G_loc_t obj_loc; /* Location of object */ - H5G_name_t obj_path; /* Object's group hier. path */ - H5O_loc_t obj_oloc; /* Object's object location */ - hbool_t obj_found = FALSE; /* Object at 'name' found */ - herr_t ret_value = H5_ITER_CONT; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - /* Sanity check */ - HDassert(name); - HDassert(linfo); - HDassert(udata); - - /* Check if this is a hard link */ - if(linfo->type == H5L_TYPE_HARD) { - H5_obj_t obj_pos; /* Object "position" for this object */ - - /* Set up opened group location to fill in */ - obj_loc.oloc = &obj_oloc; - obj_loc.path = &obj_path; - H5G_loc_reset(&obj_loc); - - /* Find the object using the LAPL passed in */ - /* (Correctly handles mounted files) */ - if(H5G_loc_find(udata->start_loc, name, &obj_loc/*out*/, udata->lapl_id, udata->dxpl_id) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, H5_ITER_ERROR, "object not found") - obj_found = TRUE; - - /* Construct unique "position" for this object */ - H5F_GET_FILENO(obj_oloc.file, obj_pos.fileno); - obj_pos.addr = obj_oloc.addr; - - /* Check if we've seen the object the link references before */ - if(NULL == H5SL_search(udata->visited, &obj_pos)) { - H5O_info_t oinfo; /* Object info */ - - /* Get the object's info */ - if(H5O_get_info(&obj_oloc, udata->dxpl_id, TRUE, &oinfo) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5_ITER_ERROR, "unable to get object info") - - /* Make the application callback */ - ret_value = (udata->op)(udata->obj_id, name, &oinfo, udata->op_data); - - /* Check for continuing to visit objects */ - if(ret_value == H5_ITER_CONT) { - /* If its ref count is > 1, we add it to the list of visited objects */ - /* (because it could come up again during traversal) */ - if(oinfo.rc > 1) { - H5_obj_t *new_node; /* New object node for visited list */ - - /* Allocate new object "position" node */ - if((new_node = H5FL_MALLOC(H5_obj_t)) == NULL) - HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, H5_ITER_ERROR, "can't allocate object node") - - /* Set node information */ - *new_node = obj_pos; - - /* Add to list of visited objects */ - if(H5SL_insert(udata->visited, new_node, new_node) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, H5_ITER_ERROR, "can't insert object node into visited list") - } /* end if */ - } /* end if */ - } /* end if */ - } /* end if */ - -done: - /* Release resources */ - if(obj_found && H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, H5_ITER_ERROR, "can't free location") - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_visit_cb() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_visit - * - * Purpose: Recursively visit an object and all the objects reachable - * from it. If the starting object is a group, all the objects - * linked to from that group will be visited. Links within - * each group are visited according to the order within the - * specified index (unless the specified index does not exist for - * a particular group, then the "name" index is used). - * - * NOTE: Soft links and user-defined links are ignored during - * this operation. - * - * NOTE: Each _object_ reachable from the initial group will only - * be visited once. If multiple hard links point to the same - * object, the first link to the object's path (according to the - * iteration index and iteration order given) will be used to in - * the callback about the object. - * - * Return: Success: The return value of the first operator that - * returns non-zero, or zero if all members were - * processed with no operator returning non-zero. - * - * Failure: Negative if something goes wrong within the - * library, or the negative value returned by one - * of the operators. - * - * Programmer: Quincey Koziol - * November 24 2007 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5O_visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type, - H5_iter_order_t order, H5O_iterate_t op, void *op_data, hid_t lapl_id, - hid_t dxpl_id) -{ - H5O_iter_visit_ud_t udata; /* User data for callback */ - H5G_loc_t loc; /* Location of reference object */ - H5G_loc_t obj_loc; /* Location used to open object */ - H5G_name_t obj_path; /* Opened object group hier. path */ - H5O_loc_t obj_oloc; /* Opened object object location */ - hbool_t loc_found = FALSE; /* Entry at 'name' found */ - H5O_info_t oinfo; /* Object info struct */ - hid_t obj_id = (-1); /* ID of object */ - herr_t ret_value = FAIL; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Portably initialize user data struct to zeros */ - HDmemset(&udata, 0, sizeof(udata)); - - /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - - /* Set up opened group location to fill in */ - obj_loc.oloc = &obj_oloc; - obj_loc.path = &obj_path; - H5G_loc_reset(&obj_loc); - - /* Find the object's location */ - if(H5G_loc_find(&loc, obj_name, &obj_loc/*out*/, lapl_id, dxpl_id) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") - loc_found = TRUE; - - /* Get the object's info */ - if(H5O_get_info(&obj_oloc, dxpl_id, TRUE, &oinfo) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to get object info") - - /* Open the object */ - /* (Takes ownership of the obj_loc information) */ - if((obj_id = H5O_open_by_loc(&obj_loc, lapl_id, dxpl_id, TRUE)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object") - - /* Make callback for starting object */ - if((ret_value = op(obj_id, ".", &oinfo, op_data)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "can't visit objects") - - /* Check return value of first callback */ - if(ret_value != H5_ITER_CONT) - HGOTO_DONE(ret_value); - - /* Check for object being a group */ - if(oinfo.type == H5O_TYPE_GROUP) { - H5G_loc_t start_loc; /* Location of starting group */ - - /* Get the location of the starting group */ - if(H5G_loc(obj_id, &start_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - - /* Set up user data for visiting links */ - udata.obj_id = obj_id; - udata.start_loc = &start_loc; - udata.lapl_id = lapl_id; - udata.dxpl_id = dxpl_id; - udata.op = op; - udata.op_data = op_data; - - /* Create skip list to store visited object information */ - if((udata.visited = H5SL_create(H5SL_TYPE_OBJ, NULL)) == NULL) - HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "can't create skip list for visited objects") - - /* If its ref count is > 1, we add it to the list of visited objects */ - /* (because it could come up again during traversal) */ - if(oinfo.rc > 1) { - H5_obj_t *obj_pos; /* New object node for visited list */ - - /* Allocate new object "position" node */ - if((obj_pos = H5FL_MALLOC(H5_obj_t)) == NULL) - HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, FAIL, "can't allocate object node") - - /* Construct unique "position" for this object */ - obj_pos->fileno = oinfo.fileno; - obj_pos->addr = oinfo.addr; - - /* Add to list of visited objects */ - if(H5SL_insert(udata.visited, obj_pos, obj_pos) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't insert object node into visited list") - } /* end if */ - - /* Call internal group visitation routine */ - if((ret_value = H5G_visit(obj_id, ".", idx_type, order, H5O_visit_cb, &udata, lapl_id, dxpl_id)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") - } /* end if */ - -done: - if(obj_id > 0) { - if(H5I_dec_app_ref(obj_id) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to close object") - } /* end if */ - else if(loc_found && H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location") - if(udata.visited) - H5SL_destroy(udata.visited, H5O_free_visit_visited, NULL); - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_visit() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_inc_rc - * - * Purpose: Increments the reference count on an object header - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Jul 13 2008 - * - *------------------------------------------------------------------------- - */ -herr_t -H5O_inc_rc(H5O_t *oh) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* check args */ - HDassert(oh); - - /* Pin the object header when the reference count goes above 0 */ - if(oh->rc == 0) - if(H5AC_pin_protected_entry(oh) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTPIN, FAIL, "unable to pin object header") - - /* Increment reference count */ - oh->rc++; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_inc_rc() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_dec_rc - * - * Purpose: Decrements the reference count on an object header - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Jul 13 2008 - * - *------------------------------------------------------------------------- - */ -herr_t -H5O_dec_rc(H5O_t *oh) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* check args */ - HDassert(oh); - - /* Decrement reference count */ - oh->rc--; - - /* Unpin the object header when the reference count goes back to 0 */ - if(oh->rc == 0) - if(H5AC_unpin_entry(oh) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "unable to unpin object header") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_dec_rc() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_dec_rc_by_loc - * - * Purpose: Decrement the refcount of an object header, using its - * object location information. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Oct 08 2010 - * - *------------------------------------------------------------------------- - */ -herr_t -H5O_dec_rc_by_loc(const H5O_loc_t *loc, hid_t dxpl_id) -{ - H5O_t *oh = NULL; /* Object header */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* check args */ - HDassert(loc); - - /* Get header */ - if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC__READ_ONLY_FLAG, FALSE))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object header") - - /* Decrement the reference count on the object header */ - /* (which will unpin it, if appropriate) */ - if(H5O_dec_rc(oh) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement reference count on object header") - -done: - /* Release the object header from the cache */ - if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_dec_rc_by_loc() */ - - -/*------------------------------------------------------------------------- - * Function: H5O_get_proxy - * - * Purpose: Retrieve the proxy for the object header. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * July 24 2016 - * - *------------------------------------------------------------------------- - */ -H5AC_proxy_entry_t * -H5O_get_proxy(const H5O_t *oh) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - /* Check args */ - HDassert(oh); - - FUNC_LEAVE_NOAPI(oh->proxy) -} /* end H5O_get_proxy() */ - - -/*------------------------------------------------------------------------- - * Function: H5O__free - * - * Purpose: Destroys an object header. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu - * Jan 15 2003 - * - *------------------------------------------------------------------------- - */ -herr_t -H5O__free(H5O_t *oh) -{ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* check args */ - HDassert(oh); - HDassert(0 == oh->rc); - - /* Destroy chunks */ - if(oh->chunk) { - for(u = 0; u < oh->nchunks; u++) - oh->chunk[u].image = H5FL_BLK_FREE(chunk_image, oh->chunk[u].image); - - oh->chunk = (H5O_chunk_t *)H5FL_SEQ_FREE(H5O_chunk_t, oh->chunk); - } /* end if */ - - /* Destroy messages */ - if(oh->mesg) { - for(u = 0; u < oh->nmesgs; u++) { -#ifndef NDEBUG - /* Verify that message is clean, unless it could have been marked - * dirty by decoding */ - if(oh->ndecode_dirtied && oh->mesg[u].dirty) - oh->ndecode_dirtied--; - else - HDassert(oh->mesg[u].dirty == 0); -#endif /* NDEBUG */ - - H5O_msg_free_mesg(&oh->mesg[u]); - } /* end for */ - - /* Make sure we accounted for all the messages dirtied by decoding */ - HDassert(!oh->ndecode_dirtied); - - oh->mesg = (H5O_mesg_t *)H5FL_SEQ_FREE(H5O_mesg_t, oh->mesg); - } /* end if */ - - /* Destroy the proxy */ - if(oh->proxy) - if(H5AC_proxy_entry_dest(oh->proxy) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy virtual entry used for proxy") - - /* destroy object header */ - oh = H5FL_FREE(H5O_t, oh); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O__free() */ - diff --git a/src/H5Oint.c b/src/H5Oint.c index fbaad53..6ab5393 100644 --- a/src/H5Oint.c +++ b/src/H5Oint.c @@ -32,7 +32,17 @@ /***********/ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5FOprivate.h" /* File objects */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5MFprivate.h" /* File memory management */ +#ifdef H5O_ENABLE_BOGUS +#include "H5MMprivate.h" /* Memory management */ +#endif /* H5O_ENABLE_BOGUS */ #include "H5Opkg.h" /* Object headers */ +#include "H5SMprivate.h" /* Shared object header messages */ /****************/ @@ -44,6 +54,17 @@ /* Local Typedefs */ /******************/ +/* User data for recursive traversal over objects from a group */ +typedef struct { + hid_t obj_id; /* The ID for the starting group */ + H5G_loc_t *start_loc; /* Location of starting group */ + hid_t lapl_id; /* LAPL for walking across links */ + hid_t dxpl_id; /* DXPL for operations */ + H5SL_t *visited; /* Skip list for tracking visited nodes */ + H5O_iterate_t op; /* Application callback */ + void *op_data; /* Application's op data */ +} H5O_iter_visit_ud_t; + /********************/ /* Package Typedefs */ @@ -54,19 +75,2639 @@ /* Local Prototypes */ /********************/ +static herr_t H5O_delete_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh); +static herr_t H5O_obj_type_real(H5O_t *oh, H5O_type_t *obj_type); +static herr_t H5O_get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr); +static const H5O_obj_class_t *H5O_obj_class_real(H5O_t *oh); + /*********************/ /* Package Variables */ /*********************/ +/* Package initialization variable */ +hbool_t H5_PKG_INIT_VAR = FALSE; + +/* Header message ID to class mapping + * + * Remember to increment H5O_MSG_TYPES in H5Opkg.h when adding a new + * message. + */ +const H5O_msg_class_t *const H5O_msg_class_g[] = { + H5O_MSG_NULL, /*0x0000 Null */ + H5O_MSG_SDSPACE, /*0x0001 Dataspace */ + H5O_MSG_LINFO, /*0x0002 Link information */ + H5O_MSG_DTYPE, /*0x0003 Datatype */ + H5O_MSG_FILL, /*0x0004 Old data storage -- fill value */ + H5O_MSG_FILL_NEW, /*0x0005 New data storage -- fill value */ + H5O_MSG_LINK, /*0x0006 Link */ + H5O_MSG_EFL, /*0x0007 Data storage -- external data files */ + H5O_MSG_LAYOUT, /*0x0008 Data Layout */ +#ifdef H5O_ENABLE_BOGUS + H5O_MSG_BOGUS_VALID, /*0x0009 "Bogus valid" (for testing) */ +#else /* H5O_ENABLE_BOGUS */ + NULL, /*0x0009 "Bogus valid" (for testing) */ +#endif /* H5O_ENABLE_BOGUS */ + H5O_MSG_GINFO, /*0x000A Group information */ + H5O_MSG_PLINE, /*0x000B Data storage -- filter pipeline */ + H5O_MSG_ATTR, /*0x000C Attribute */ + H5O_MSG_NAME, /*0x000D Object name */ + H5O_MSG_MTIME, /*0x000E Object modification date and time */ + H5O_MSG_SHMESG, /*0x000F File-wide shared message table */ + H5O_MSG_CONT, /*0x0010 Object header continuation */ + H5O_MSG_STAB, /*0x0011 Symbol table */ + H5O_MSG_MTIME_NEW, /*0x0012 New Object modification date and time */ + H5O_MSG_BTREEK, /*0x0013 Non-default v1 B-tree 'K' values */ + H5O_MSG_DRVINFO, /*0x0014 Driver info settings */ + H5O_MSG_AINFO, /*0x0015 Attribute information */ + H5O_MSG_REFCOUNT, /*0x0016 Object's ref. count */ + H5O_MSG_FSINFO, /*0x0017 Free-space manager info */ + H5O_MSG_MDCI, /*0x0018 Metadata cache image */ + H5O_MSG_UNKNOWN, /*0x0019 Placeholder for unknown message */ +#ifdef H5O_ENABLE_BOGUS + H5O_MSG_BOGUS_INVALID, /*0x001A "Bogus invalid" (for testing) */ +#else /* H5O_ENABLE_BOGUS */ + NULL, /*0x001A "Bogus invalid" (for testing) */ +#endif /* H5O_ENABLE_BOGUS */ +}; + +/* Declare a free list to manage the H5O_t struct */ +H5FL_DEFINE(H5O_t); + +/* Declare a free list to manage the H5O_mesg_t sequence information */ +H5FL_SEQ_DEFINE(H5O_mesg_t); + +/* Declare a free list to manage the H5O_chunk_t sequence information */ +H5FL_SEQ_DEFINE(H5O_chunk_t); + +/* Declare a free list to manage the chunk image information */ +H5FL_BLK_DEFINE(chunk_image); + +/* Declare external the free list for H5O_cont_t sequences */ +H5FL_SEQ_EXTERN(H5O_cont_t); + /*****************************/ /* Library Private Variables */ /*****************************/ +/* Declare external the free list for time_t's */ +H5FL_EXTERN(time_t); + +/* Declare external the free list for H5_obj_t's */ +H5FL_EXTERN(H5_obj_t); + /*******************/ /* Local Variables */ /*******************/ +/* Header object ID to class mapping */ +/* + * Initialize the object class info table. Begin with the most general types + * and end with the most specific. For instance, any object that has a + * datatype message is a datatype but only some of them are datasets. + */ +static const H5O_obj_class_t *const H5O_obj_class_g[] = { + H5O_OBJ_DATATYPE, /* Datatype object (H5O_TYPE_NAMED_DATATYPE - 2) */ + H5O_OBJ_DATASET, /* Dataset object (H5O_TYPE_DATASET - 1) */ + H5O_OBJ_GROUP, /* Group object (H5O_TYPE_GROUP - 0) */ +}; + + +/*------------------------------------------------------------------------- + * Function: H5O__init_package + * + * Purpose: Initialize information specific to H5O interface. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Thursday, January 18, 2007 + * + *------------------------------------------------------------------------- + */ +herr_t +H5O__init_package(void) +{ + FUNC_ENTER_PACKAGE_NOERR + + /* H5O interface sanity checks */ + HDcompile_assert(H5O_MSG_TYPES == NELMTS(H5O_msg_class_g)); + HDcompile_assert(sizeof(H5O_fheap_id_t) == H5O_FHEAP_ID_LEN); + + HDcompile_assert(H5O_UNKNOWN_ID < H5O_MSG_TYPES); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5O__init_package() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_create + * + * Purpose: Creates a new object header. Allocates space for it and + * then calls an initialization function. The object header + * is opened for write access and should eventually be + * closed by calling H5O_close(). + * + * Return: Success: Non-negative, the ENT argument contains + * information about the object header, + * including its address. + * + * Failure: Negative + * + * Programmer: Robb Matzke + * matzke@llnl.gov + * Aug 5 1997 + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, size_t initial_rc, + hid_t ocpl_id, H5O_loc_t *loc/*out*/) +{ + H5P_genplist_t *oc_plist; /* Object creation property list */ + H5O_t *oh = NULL; /* Object header created */ + haddr_t oh_addr; /* Address of initial object header */ + size_t oh_size; /* Size of initial object header */ + uint8_t oh_flags; /* Object header's initial status flags */ + unsigned insert_flags = H5AC__NO_FLAGS_SET; /* Flags for inserting object header into cache */ + hbool_t store_msg_crt_idx; /* Whether to always store message creation indices for this file */ + herr_t ret_value = SUCCEED; /* return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* check args */ + HDassert(f); + HDassert(loc); + HDassert(TRUE == H5P_isa_class(ocpl_id, H5P_OBJECT_CREATE)); + + /* Check for invalid access request */ + if(0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "no write intent on file") + + /* Make certain we allocate at least a reasonable size for the object header */ + size_hint = H5O_ALIGN_F(f, MAX(H5O_MIN_SIZE, size_hint)); + + /* Get the property list */ + if(NULL == (oc_plist = (H5P_genplist_t *)H5I_object(ocpl_id))) + HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a property list") + + /* Get any object header status flags set by properties */ + if(H5P_get(oc_plist, H5O_CRT_OHDR_FLAGS_NAME, &oh_flags) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object header flags") + + /* Allocate the object header and zero out header fields */ + if(NULL == (oh = H5FL_CALLOC(H5O_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + + /* Initialize file-specific information for object header */ + store_msg_crt_idx = H5F_STORE_MSG_CRT_IDX(f); + if(H5F_USE_LATEST_FLAGS(f, H5F_LATEST_OBJ_HEADER) || store_msg_crt_idx || (oh_flags & H5O_HDR_ATTR_CRT_ORDER_TRACKED)) + oh->version = H5O_VERSION_LATEST; + else + oh->version = H5O_VERSION_1; + oh->sizeof_size = H5F_SIZEOF_SIZE(f); + oh->sizeof_addr = H5F_SIZEOF_ADDR(f); + oh->swmr_write = !!(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE); +#ifdef H5O_ENABLE_BAD_MESG_COUNT + /* Check whether the "bad message count" property is set */ + if(H5P_exist_plist(oc_plist, H5O_BAD_MESG_COUNT_NAME) > 0) { + /* Retrieve bad message count flag */ + if(H5P_get(oc_plist, H5O_BAD_MESG_COUNT_NAME, &oh->store_bad_mesg_count) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get bad message count flag") + } +#endif /* H5O_ENABLE_BAD_MESG_COUNT */ + + /* Create object header proxy if doing SWMR writes */ + if(oh->swmr_write) { + /* Create virtual entry, for use as proxy */ + if(NULL == (oh->proxy = H5AC_proxy_entry_create())) + HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "can't create object header proxy") + } + else + oh->proxy = NULL; + + /* Set initial status flags */ + oh->flags = oh_flags; + + /* Initialize version-specific fields */ + if(oh->version > H5O_VERSION_1) { + /* Initialize all time fields with current time, if we are storing them */ + if(oh->flags & H5O_HDR_STORE_TIMES) + oh->atime = oh->mtime = oh->ctime = oh->btime = H5_now(); + else + oh->atime = oh->mtime = oh->ctime = oh->btime = 0; + + /* Make certain attribute creation order tracking is enabled if + * attributes can be shared in this file. + */ + if(store_msg_crt_idx) + oh->flags |= H5O_HDR_ATTR_CRT_ORDER_TRACKED; + + /* Retrieve attribute storage phase change values from property list */ + if(H5P_get(oc_plist, H5O_CRT_ATTR_MAX_COMPACT_NAME, &oh->max_compact) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get max. # of compact attributes") + if(H5P_get(oc_plist, H5O_CRT_ATTR_MIN_DENSE_NAME, &oh->min_dense) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get min. # of dense attributes") + + /* Check for non-default attribute storage phase change values */ + if(oh->max_compact != H5O_CRT_ATTR_MAX_COMPACT_DEF || oh->min_dense != H5O_CRT_ATTR_MIN_DENSE_DEF) + oh->flags |= H5O_HDR_ATTR_STORE_PHASE_CHANGE; + + /* Determine correct value for chunk #0 size bits */ +/* Avoid compiler warning on 32-bit machines */ +#if H5_SIZEOF_SIZE_T > H5_SIZEOF_INT32_T + if(size_hint > 4294967295UL) + oh->flags |= H5O_HDR_CHUNK0_8; + else +#endif /* H5_SIZEOF_SIZE_T > H5_SIZEOF_INT32_T */ + if(size_hint > 65535) + oh->flags |= H5O_HDR_CHUNK0_4; + else if(size_hint > 255) + oh->flags |= H5O_HDR_CHUNK0_2; + } /* end if */ + else { + /* Reset unused time fields */ + oh->atime = oh->mtime = oh->ctime = oh->btime = 0; + } /* end else */ + + /* Compute total size of initial object header */ + /* (i.e. object header prefix and first chunk) */ + oh_size = (size_t)H5O_SIZEOF_HDR(oh) + size_hint; + + /* Allocate disk space for header and first chunk */ + if(HADDR_UNDEF == (oh_addr = H5MF_alloc(f, H5FD_MEM_OHDR, dxpl_id, (hsize_t)oh_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for object header") + + /* Create the chunk list */ + oh->nchunks = oh->alloc_nchunks = 1; + if(NULL == (oh->chunk = H5FL_SEQ_MALLOC(H5O_chunk_t, (size_t)oh->alloc_nchunks))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + + /* Initialize the first chunk */ + oh->chunk[0].addr = oh_addr; + oh->chunk[0].size = oh_size; + oh->chunk[0].gap = 0; + + /* Allocate enough space for the first chunk */ + /* (including space for serializing the object header prefix */ + if(NULL == (oh->chunk[0].image = H5FL_BLK_CALLOC(chunk_image, oh_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + oh->chunk[0].chunk_proxy = NULL; + + /* Put magic # for object header in first chunk */ + if(oh->version > H5O_VERSION_1) + HDmemcpy(oh->chunk[0].image, H5O_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC); + + /* Create the message list */ + oh->nmesgs = 1; + oh->alloc_nmesgs = H5O_NMESGS; + if(NULL == (oh->mesg = H5FL_SEQ_CALLOC(H5O_mesg_t, oh->alloc_nmesgs))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + + /* Initialize the initial "null" message, covering the entire first chunk */ + oh->mesg[0].type = H5O_MSG_NULL; + oh->mesg[0].dirty = TRUE; + oh->mesg[0].native = NULL; + oh->mesg[0].raw = oh->chunk[0].image + (H5O_SIZEOF_HDR(oh) - H5O_SIZEOF_CHKSUM_OH(oh)) + H5O_SIZEOF_MSGHDR_OH(oh); + oh->mesg[0].raw_size = size_hint - (size_t)H5O_SIZEOF_MSGHDR_OH(oh); + oh->mesg[0].chunkno = 0; + + /* Check for non-zero initial refcount on the object header */ + if(initial_rc > 0) { + /* Set the initial refcount & pin the header when its inserted */ + oh->rc = initial_rc; + insert_flags |= H5AC__PIN_ENTRY_FLAG; + } + + /* Set metadata tag in dxpl_id */ + H5_BEGIN_TAG(dxpl_id, oh_addr, FAIL); + + /* Cache object header */ + if(H5AC_insert_entry(f, dxpl_id, H5AC_OHDR, oh_addr, oh, insert_flags) < 0) + HGOTO_ERROR_TAG(H5E_OHDR, H5E_CANTINSERT, FAIL, "unable to cache object header") + + /* Reset object header pointer, now that it's been inserted into the cache */ + oh = NULL; + + /* Reset metadata tag in dxpl_id */ + H5_END_TAG(FAIL); + + /* Set up object location */ + loc->file = f; + loc->addr = oh_addr; + + /* Open it */ + if(H5O_open(loc) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object header") + +done: + if(ret_value < 0 && oh) + if(H5O__free(oh) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy object header data") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_open + * + * Purpose: Opens an object header which is described by the symbol table + * entry OBJ_ENT. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Robb Matzke + * Monday, January 5, 1998 + * + * Modification: + * Raymond Lu + * 5 November 2007 + * Turn off the holding file variable if it's on. When it's + * needed, the caller will turn it on again. + *------------------------------------------------------------------------- + */ +herr_t +H5O_open(H5O_loc_t *loc) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Check args */ + HDassert(loc); + HDassert(loc->file); + +#ifdef H5O_DEBUG + if(H5DEBUG(O)) + HDfprintf(H5DEBUG(O), "> %a\n", loc->addr); +#endif + + /* Turn off the variable for holding file or increment open-lock counters */ + if(loc->holding_file) + loc->holding_file = FALSE; + else + H5F_INCR_NOPEN_OBJS(loc->file); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_open_name + * + * Purpose: Opens an object within an HDF5 file. + * + * Return: Success: An open object identifier + * Failure: Negative + * + * Programmer: Quincey Koziol + * March 5 2007 + * + *------------------------------------------------------------------------- + */ +hid_t +H5O_open_name(H5G_loc_t *loc, const char *name, hid_t lapl_id, hid_t dxpl_id, hbool_t app_ref) +{ + H5G_loc_t obj_loc; /* Location used to open group */ + H5G_name_t obj_path; /* Opened object group hier. path */ + H5O_loc_t obj_oloc; /* Opened object object location */ + hbool_t loc_found = FALSE; /* Entry at 'name' found */ + hid_t ret_value = FAIL; + + FUNC_ENTER_NOAPI(FAIL) + + /* Check args */ + HDassert(loc); + HDassert(name && *name); + + /* Set up opened group location to fill in */ + obj_loc.oloc = &obj_oloc; + obj_loc.path = &obj_path; + H5G_loc_reset(&obj_loc); + + /* Find the object's location */ + if(H5G_loc_find(loc, name, &obj_loc/*out*/, lapl_id, dxpl_id) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + loc_found = TRUE; + + /* Open the object */ + if((ret_value = H5O_open_by_loc(&obj_loc, lapl_id, dxpl_id, app_ref)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object") + +done: + if(ret_value < 0 && loc_found) + if(H5G_loc_free(&obj_loc) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_open_name() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_open_by_loc + * + * Purpose: Opens an object and returns an ID given its group loction. + * + * Return: Success: Open object identifier + * Failure: Negative + * + * Programmer: James Laird + * July 25 2006 + * + *------------------------------------------------------------------------- + */ +hid_t +H5O_open_by_loc(const H5G_loc_t *obj_loc, hid_t lapl_id, hid_t dxpl_id, hbool_t app_ref) +{ + const H5O_obj_class_t *obj_class; /* Class of object for location */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + HDassert(obj_loc); + + /* Get the object class for this location */ + if(NULL == (obj_class = H5O_obj_class(obj_loc->oloc, dxpl_id))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine object class") + + /* Call the object class's 'open' routine */ + HDassert(obj_class->open); + if((ret_value = obj_class->open(obj_loc, lapl_id, dxpl_id, app_ref)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_open_by_loc() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_close + * + * Purpose: Closes an object header that was previously open. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Robb Matzke + * Monday, January 5, 1998 + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_close(H5O_loc_t *loc, hbool_t *file_closed /*out*/) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Check args */ + HDassert(loc); + HDassert(loc->file); + HDassert(H5F_NOPEN_OBJS(loc->file) > 0); + + /* Set the file_closed flag to the default value. + * This flag lets downstream code know if the file struct is + * still accessible and/or likely to contain useful data. + * It's needed by the evict-on-close code. Clients can ignore + * this value by passing in NULL. + */ + if(file_closed) + *file_closed = FALSE; + + /* Decrement open-lock counters */ + H5F_DECR_NOPEN_OBJS(loc->file); + +#ifdef H5O_DEBUG + if(H5DEBUG(O)) { + if(H5F_FILE_ID(loc->file)< 0 && 1 == H5F_NREFS(loc->file)) + HDfprintf(H5DEBUG(O), "< %a auto %lu remaining\n", + loc->addr, (unsigned long)H5F_NOPEN_OBJS(loc->file)); + else + HDfprintf(H5DEBUG(O), "< %a\n", loc->addr); + } +#endif + + /* + * If the file open object count has reached the number of open mount points + * (each of which has a group open in the file) attempt to close the file. + */ + if(H5F_NOPEN_OBJS(loc->file) == H5F_NMOUNTS(loc->file)) + /* Attempt to close down the file hierarchy */ + if(H5F_try_close(loc->file, file_closed) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTCLOSEFILE, FAIL, "problem attempting file close") + + /* Release location information */ + if(H5O_loc_free(loc) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "problem attempting to free location") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_link_oh + * + * Purpose: Adjust the link count for an open object header by adding + * ADJUST to the link count. + * + * Return: Success: New link count + * + * Failure: Negative + * + * Programmer: Robb Matzke + * matzke@llnl.gov + * Aug 5 1997 + * + *------------------------------------------------------------------------- + */ +int +H5O_link_oh(H5F_t *f, int adjust, hid_t dxpl_id, H5O_t *oh, hbool_t *deleted) +{ + haddr_t addr = H5O_OH_GET_ADDR(oh); /* Object header address */ + int ret_value = -1; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* check args */ + HDassert(f); + HDassert(oh); + HDassert(deleted); + + /* Check for adjusting link count */ + if(adjust) { + if(adjust < 0) { + /* Check for too large of an adjustment */ + if((unsigned)(-adjust) > oh->nlink) + HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "link count would be negative") + + /* Adjust the link count for the object header */ + oh->nlink = (unsigned)((int)oh->nlink + adjust); + + /* Mark object header as dirty in cache */ + if(H5AC_mark_entry_dirty(oh) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTMARKDIRTY, FAIL, "unable to mark object header as dirty") + + /* Check if the object should be deleted */ + if(oh->nlink == 0) { + /* Check if the object is still open by the user */ + if(H5FO_opened(f, addr) != NULL) { + /* Flag the object to be deleted when it's closed */ + if(H5FO_mark(f, addr, TRUE) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't mark object for deletion") + } /* end if */ + else { + /* Mark the object header for deletion */ + *deleted = TRUE; + } /* end else */ + } /* end if */ + } /* end if */ + else { + /* A new object, or one that will be deleted */ + if(0 == oh->nlink) { + /* Check if the object is currently open, but marked for deletion */ + if(H5FO_marked(f, addr)) { + /* Remove "delete me" flag on the object */ + if(H5FO_mark(f, addr, FALSE) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't mark object for deletion") + } /* end if */ + } /* end if */ + + /* Adjust the link count for the object header */ + oh->nlink = (unsigned)((int)oh->nlink + adjust); + + /* Mark object header as dirty in cache */ + if(H5AC_mark_entry_dirty(oh) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTMARKDIRTY, FAIL, "unable to mark object header as dirty") + } /* end if */ + + /* Check for operations on refcount message */ + if(oh->version > H5O_VERSION_1) { + /* Check if the object has a refcount message already */ + if(oh->has_refcount_msg) { + /* Check for removing refcount message */ + if(oh->nlink <= 1) { + if(H5O_msg_remove_real(f, oh, H5O_MSG_REFCOUNT, H5O_ALL, NULL, NULL, TRUE, dxpl_id) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to delete refcount message") + oh->has_refcount_msg = FALSE; + } /* end if */ + /* Update refcount message with new link count */ + else { + H5O_refcount_t refcount = oh->nlink; + + if(H5O_msg_write_real(f, dxpl_id, oh, H5O_MSG_REFCOUNT, H5O_MSG_FLAG_DONTSHARE, 0, &refcount) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUPDATE, FAIL, "unable to update refcount message") + } /* end else */ + } /* end if */ + else { + /* Check for adding refcount message to object */ + if(oh->nlink > 1) { + H5O_refcount_t refcount = oh->nlink; + + if(H5O_msg_append_real(f, dxpl_id, oh, H5O_MSG_REFCOUNT, H5O_MSG_FLAG_DONTSHARE, 0, &refcount) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "unable to create new refcount message") + oh->has_refcount_msg = TRUE; + } /* end if */ + } /* end else */ + } /* end if */ + } /* end if */ + + /* Set return value */ + ret_value = (int)oh->nlink; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_link_oh() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_link + * + * Purpose: Adjust the link count for an object header by adding + * ADJUST to the link count. + * + * Return: Success: New link count + * + * Failure: Negative + * + * Programmer: Robb Matzke + * matzke@llnl.gov + * Aug 5 1997 + * + *------------------------------------------------------------------------- + */ +int +H5O_link(const H5O_loc_t *loc, int adjust, hid_t dxpl_id) +{ + H5O_t *oh = NULL; + hbool_t deleted = FALSE; /* Whether the object was deleted */ + int ret_value = -1; /* Return value */ + + FUNC_ENTER_NOAPI_TAG(dxpl_id, loc->addr, FAIL) + + /* check args */ + HDassert(loc); + HDassert(loc->file); + HDassert(H5F_addr_defined(loc->addr)); + + /* Pin the object header */ + if(NULL == (oh = H5O_pin(loc, dxpl_id))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPIN, FAIL, "unable to pin object header") + + /* Call the "real" link routine */ + if((ret_value = H5O_link_oh(loc->file, adjust, dxpl_id, oh, &deleted)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "unable to adjust object link count") + +done: + if(oh && H5O_unpin(oh) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "unable to unpin object header") + if(ret_value >= 0 && deleted && H5O_delete(loc->file, dxpl_id, loc->addr) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't delete object from file") + + FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL) +} /* end H5O_link() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_protect + * + * Purpose: Wrapper around H5AC_protect for use during a H5O_protect-> + * H5O_msg_append->...->H5O_msg_append->H5O_unprotect sequence of calls + * during an object's creation. + * + * Return: Success: Pointer to the object header structure for the + * object. + * Failure: NULL + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Dec 31 2002 + * + *------------------------------------------------------------------------- + */ +H5O_t * +H5O_protect(const H5O_loc_t *loc, hid_t dxpl_id, unsigned prot_flags, + hbool_t pin_all_chunks) +{ + H5O_t *oh = NULL; /* Object header protected */ + H5O_cache_ud_t udata; /* User data for protecting object header */ + H5O_cont_msgs_t cont_msg_info; /* Continuation message info */ + unsigned file_intent; /* R/W intent on file */ + H5O_t *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI_TAG(dxpl_id, loc->addr, NULL) + + /* check args */ + HDassert(loc); + HDassert(loc->file); + + /* prot_flags may only contain the H5AC__READ_ONLY_FLAG */ + HDassert((prot_flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); + + /* Check for valid address */ + if(!H5F_addr_defined(loc->addr)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "address undefined") + + /* Check for write access on the file */ + file_intent = H5F_INTENT(loc->file); + if((0 == (prot_flags & H5AC__READ_ONLY_FLAG)) && (0 == (file_intent & H5F_ACC_RDWR))) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "no write intent on file") + + /* Construct the user data for protect callback */ + udata.made_attempt = FALSE; + udata.v1_pfx_nmesgs = 0; + udata.chunk0_size = 0; + udata.oh = NULL; + udata.common.f = loc->file; + udata.common.dxpl_id = dxpl_id; + udata.common.file_intent = file_intent; + udata.common.merged_null_msgs = 0; + HDmemset(&cont_msg_info, 0, sizeof(cont_msg_info)); + udata.common.cont_msg_info = &cont_msg_info; + udata.common.addr = loc->addr; + + /* Lock the object header into the cache */ + if(NULL == (oh = (H5O_t *)H5AC_protect(loc->file, dxpl_id, H5AC_OHDR, loc->addr, &udata, prot_flags))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, NULL, "unable to load object header") + + /* Check if there are any continuation messages to process */ + if(cont_msg_info.nmsgs > 0) { + size_t curr_msg; /* Current continuation message to process */ + H5O_chk_cache_ud_t chk_udata; /* User data for loading chunk */ + + /* Sanity check - we should only have continuation messages to process + * when the object header is actually loaded from the file. + */ + HDassert(udata.made_attempt == TRUE); + HDassert(cont_msg_info.msgs); + + /* Construct the user data for protecting chunks */ + chk_udata.decoding = TRUE; + chk_udata.oh = oh; + chk_udata.chunkno = UINT_MAX; /* Set to invalid value, for better error detection */ + chk_udata.common.f = loc->file; + chk_udata.common.dxpl_id = dxpl_id; + chk_udata.common.file_intent = file_intent; + chk_udata.common.merged_null_msgs = udata.common.merged_null_msgs; + chk_udata.common.cont_msg_info = &cont_msg_info; + + /* Read in continuation messages, until there are no more */ + /* (Note that loading chunks could increase the # of continuation + * messages if new ones are found - QAK, 19/11/2016) + */ + curr_msg = 0; + while(curr_msg < cont_msg_info.nmsgs) { + H5O_chunk_proxy_t *chk_proxy; /* Proxy for chunk, to bring it into memory */ +#ifndef NDEBUG + size_t chkcnt = oh->nchunks; /* Count of chunks (for sanity checking) */ +#endif /* NDEBUG */ + + /* Bring the chunk into the cache */ + /* (which adds to the object header) */ + chk_udata.common.addr = cont_msg_info.msgs[curr_msg].addr; + chk_udata.size = cont_msg_info.msgs[curr_msg].size; + if(NULL == (chk_proxy = (H5O_chunk_proxy_t *)H5AC_protect(loc->file, dxpl_id, H5AC_OHDR_CHK, cont_msg_info.msgs[curr_msg].addr, &chk_udata, prot_flags))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, NULL, "unable to load object header chunk") + + /* Sanity check */ + HDassert(chk_proxy->oh == oh); + HDassert(chk_proxy->chunkno == chkcnt); + HDassert(oh->nchunks == (chkcnt + 1)); + + /* Release the chunk from the cache */ + if(H5AC_unprotect(loc->file, dxpl_id, H5AC_OHDR_CHK, cont_msg_info.msgs[curr_msg].addr, chk_proxy, H5AC__NO_FLAGS_SET) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to release object header chunk") + + /* Advance to next continuation message */ + curr_msg++; + } /* end while */ + + /* Release any continuation messages built up */ + cont_msg_info.msgs = (H5O_cont_t *)H5FL_SEQ_FREE(H5O_cont_t, cont_msg_info.msgs); + + /* Pass back out some of the chunk's user data */ + udata.common.merged_null_msgs = chk_udata.common.merged_null_msgs; + } /* end if */ + + /* Check for incorrect # of object header messages, if we've just loaded + * this object header from the file + */ + if(udata.made_attempt) { +/* Don't enforce the error on an incorrect # of object header messages bug + * unless strict format checking is enabled. This allows for older + * files, created with a version of the library that had a bug in tracking + * the correct # of header messages to be read in without the library + * erroring out here. -QAK + */ +#ifdef H5_STRICT_FORMAT_CHECKS + /* Check for incorrect # of messages in v1 object header */ + if(oh->version == H5O_VERSION_1 && + (oh->nmesgs + udata.common.merged_null_msgs) != udata.v1_pfx_nmesgs) + HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "corrupt object header - incorrect # of messages") +#endif /* H5_STRICT_FORMAT_CHECKS */ + } /* end if */ + +#ifdef H5O_DEBUG +H5O_assert(oh); +#endif /* H5O_DEBUG */ + + /* Pin the other chunks also when requested, so that the object header + * proxy can be set up. + */ + if(pin_all_chunks && oh->nchunks > 1) { + unsigned u; /* Local index variable */ + + /* Sanity check */ + HDassert(oh->swmr_write); + + /* Iterate over chunks > 0 */ + for(u = 1; u < oh->nchunks; u++) { + H5O_chunk_proxy_t *chk_proxy; /* Chunk proxy */ + + /* Protect chunk */ + if(NULL == (chk_proxy = H5O_chunk_protect(loc->file, dxpl_id, oh, u))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, NULL, "unable to protect object header chunk") + + /* Pin chunk proxy*/ + if(H5AC_pin_protected_entry(chk_proxy) < 0 ) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPIN, NULL, "unable to pin object header chunk") + + /* Unprotect chunk */ + if(H5O_chunk_unprotect(loc->file, dxpl_id, chk_proxy, FALSE) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to unprotect object header chunk") + + /* Preserve chunk proxy pointer for later */ + oh->chunk[u].chunk_proxy = chk_proxy; + } /* end for */ + + /* Set the flag for the unprotect */ + oh->chunks_pinned = TRUE; + } /* end if */ + + /* Set return value */ + ret_value = oh; + +done: + if(ret_value == NULL && oh) + if(H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to release object header") + + FUNC_LEAVE_NOAPI_TAG(ret_value, NULL) +} /* end H5O_protect() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_pin + * + * Purpose: Pin an object header down for use during a sequence of message + * operations, which prevents the object header from being + * evicted from the cache. + * + * Return: Success: Pointer to the object header structure for the + * object. + * Failure: NULL + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Jul 13 2008 + * + *------------------------------------------------------------------------- + */ +H5O_t * +H5O_pin(const H5O_loc_t *loc, hid_t dxpl_id) +{ + H5O_t *oh = NULL; /* Object header */ + H5O_t *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* check args */ + HDassert(loc); + + /* Get header */ + if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC__NO_FLAGS_SET, FALSE))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, NULL, "unable to protect object header") + + /* Increment the reference count on the object header */ + /* (which will pin it, if appropriate) */ + if(H5O_inc_rc(oh) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINC, NULL, "unable to increment reference count on object header") + + /* Set the return value */ + ret_value = oh; + +done: + /* Release the object header from the cache */ + if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to release object header") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_pin() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_unpin + * + * Purpose: Unpin an object header, allowing it to be evicted from the + * metadata cache. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Jul 13 2008 + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_unpin(H5O_t *oh) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* check args */ + HDassert(oh); + + /* Decrement the reference count on the object header */ + /* (which will unpin it, if appropriate) */ + if(H5O_dec_rc(oh) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement reference count on object header") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_unpin() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_unprotect + * + * Purpose: Wrapper around H5AC_unprotect for use during a H5O_protect-> + * H5O_msg_append->...->H5O_msg_append->H5O_unprotect sequence of calls + * during an object's creation. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Dec 31 2002 + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_unprotect(const H5O_loc_t *loc, hid_t dxpl_id, H5O_t *oh, unsigned oh_flags) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* check args */ + HDassert(loc); + HDassert(oh); + + /* Unpin the other chunks */ + if(oh->chunks_pinned && oh->nchunks > 1) { + unsigned u; /* Local index variable */ + + /* Sanity check */ + HDassert(oh->swmr_write); + + /* Iterate over chunks > 0 */ + for(u = 1; u < oh->nchunks; u++) { + if(NULL != oh->chunk[u].chunk_proxy) { + /* Release chunk proxy */ + if(H5AC_unpin_entry(oh->chunk[u].chunk_proxy) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "unable to unpin object header chunk") + oh->chunk[u].chunk_proxy = NULL; + } /* end if */ + } /* end for */ + + /* Reet the flag from the unprotect */ + oh->chunks_pinned = FALSE; + } /* end if */ + + /* Unprotect the object header */ + if(H5AC_unprotect(loc->file, dxpl_id, H5AC_OHDR, oh->chunk[0].addr, oh, oh_flags) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_unprotect() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_touch_oh + * + * Purpose: If FORCE is non-zero then create a modification time message + * unless one already exists. Then update any existing + * modification time message with the current time. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Robb Matzke + * Monday, July 27, 1998 + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_touch_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh, hbool_t force) +{ + H5O_chunk_proxy_t *chk_proxy = NULL; /* Chunk that message is in */ + hbool_t chk_dirtied = FALSE; /* Flag for unprotecting chunk */ + time_t now; /* Current time */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + HDassert(f); + HDassert(oh); + + /* Check if this object header is tracking times */ + if(oh->flags & H5O_HDR_STORE_TIMES) { + /* Get current time */ + now = H5_now(); + + /* Check version, to determine how to store time information */ + if(oh->version == H5O_VERSION_1) { + size_t idx; /* Index of modification time message to update */ + + /* Look for existing message */ + for(idx = 0; idx < oh->nmesgs; idx++) + if(H5O_MSG_MTIME == oh->mesg[idx].type || H5O_MSG_MTIME_NEW == oh->mesg[idx].type) + break; + + /* Create a new message, if necessary */ + if(idx == oh->nmesgs) { + unsigned mesg_flags = 0; /* Flags for message in object header */ + + /* If we would have to create a new message, but we aren't 'forcing' it, get out now */ + if(!force) + HGOTO_DONE(SUCCEED); /*nothing to do*/ + + /* Allocate space for the modification time message */ + if(H5O_msg_alloc(f, dxpl_id, oh, H5O_MSG_MTIME_NEW, &mesg_flags, &now, &idx) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to allocate space for modification time message") + + /* Set the message's flags if appropriate */ + oh->mesg[idx].flags = (uint8_t)mesg_flags; + } /* end if */ + + /* Protect chunk */ + if(NULL == (chk_proxy = H5O_chunk_protect(f, dxpl_id, oh, oh->mesg[idx].chunkno))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header chunk") + + /* Allocate 'native' space, if necessary */ + if(NULL == oh->mesg[idx].native) { + if(NULL == (oh->mesg[idx].native = H5FL_MALLOC(time_t))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "memory allocation failed for modification time message") + } /* end if */ + + /* Update the message */ + *((time_t *)(oh->mesg[idx].native)) = now; + + /* Mark the message as dirty */ + oh->mesg[idx].dirty = TRUE; + chk_dirtied = TRUE; + } /* end if */ + else { + /* XXX: For now, update access time & change fields in the object header */ + /* (will need to add some code to update modification time appropriately) */ + oh->atime = oh->ctime = now; + + /* Mark object header as dirty in cache */ + if(H5AC_mark_entry_dirty(oh) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTMARKDIRTY, FAIL, "unable to mark object header as dirty") + } /* end else */ + } /* end if */ + +done: + /* Release chunk */ + if(chk_proxy && H5O_chunk_unprotect(f, dxpl_id, chk_proxy, chk_dirtied) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to unprotect object header chunk") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_touch_oh() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_touch + * + * Purpose: Touch an object by setting the modification time to the + * current time and marking the object as dirty. Unless FORCE + * is non-zero, nothing happens if there is no MTIME message in + * the object header. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Robb Matzke + * Monday, July 27, 1998 + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_touch(const H5O_loc_t *loc, hbool_t force, hid_t dxpl_id) +{ + H5O_t *oh = NULL; /* Object header to modify */ + unsigned oh_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting object header */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* check args */ + HDassert(loc); + + /* Get the object header */ + if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC__NO_FLAGS_SET, FALSE))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") + + /* Create/Update the modification time message */ + if(H5O_touch_oh(loc->file, dxpl_id, oh, force) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "unable to update object modificaton time") + + /* Mark object header as changed */ + oh_flags |= H5AC__DIRTIED_FLAG; + +done: + if(oh && H5O_unprotect(loc, dxpl_id, oh, oh_flags) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_touch() */ + +#ifdef H5O_ENABLE_BOGUS + +/*------------------------------------------------------------------------- + * Function: H5O_bogus_oh + * + * Purpose: Create a "bogus" message unless one already exists. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * + * Tuesday, January 21, 2003 + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_bogus_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned bogus_id, unsigned mesg_flags) +{ + size_t idx; /* Local index variable */ + H5O_msg_class_t *type; /* Message class type */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + HDassert(f); + HDassert(oh); + + /* Look for existing message */ + for(idx = 0; idx < oh->nmesgs; idx++) + if(H5O_MSG_BOGUS_VALID == oh->mesg[idx].type || H5O_MSG_BOGUS_INVALID == oh->mesg[idx].type) + break; + + /* Create a new message */ + if(idx == oh->nmesgs) { + H5O_bogus_t *bogus; /* Pointer to the bogus information */ + + /* Allocate the native message in memory */ + if(NULL == (bogus = H5MM_malloc(sizeof(H5O_bogus_t)))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "memory allocation failed for 'bogus' message") + + /* Update the native value */ + bogus->u = H5O_BOGUS_VALUE; + + if(bogus_id == H5O_BOGUS_VALID_ID) + type = H5O_MSG_BOGUS_VALID; + else if(bogus_id == H5O_BOGUS_INVALID_ID) + type = H5O_MSG_BOGUS_INVALID; + else + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID for 'bogus' message") + + /* Allocate space in the object header for bogus message */ + if(H5O_msg_alloc(f, dxpl_id, oh, type, &mesg_flags, bogus, &idx) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to allocate space for 'bogus' message") + + /* Point to "bogus" information (take it over) */ + oh->mesg[idx].native = bogus; + + /* Set the appropriate flags for the message */ + oh->mesg[idx].flags = mesg_flags; + + /* Mark the message and object header as dirty */ + oh->mesg[idx].dirty = TRUE; + oh->cache_info.is_dirty = TRUE; + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_bogus_oh() */ +#endif /* H5O_ENABLE_BOGUS */ + + +/*------------------------------------------------------------------------- + * Function: H5O_delete + * + * Purpose: Delete an object header from a file. This frees the file + * space used for the object header (and it's continuation blocks) + * and also walks through each header message and asks it to + * remove all the pieces of the file referenced by the header. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Mar 19 2003 + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr) +{ + H5O_t *oh = NULL; /* Object header information */ + H5O_loc_t loc; /* Object location for object to delete */ + unsigned oh_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting object header */ + hbool_t corked; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_TAG(dxpl_id, addr, FAIL) + + /* Check args */ + HDassert(f); + HDassert(H5F_addr_defined(addr)); + + /* Set up the object location */ + loc.file = f; + loc.addr = addr; + loc.holding_file = FALSE; + + /* Get the object header information */ + if(NULL == (oh = H5O_protect(&loc, dxpl_id, H5AC__NO_FLAGS_SET, FALSE))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") + + /* Delete object */ + if(H5O_delete_oh(f, dxpl_id, oh) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "can't delete object from file") + + /* Uncork cache entries with tag: addr */ + if(H5AC_cork(f, addr, H5AC__GET_CORKED, &corked) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to retrieve an object's cork status") + if(corked) + if(H5AC_cork(f, addr, H5AC__UNCORK, NULL) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNCORK, FAIL, "unable to uncork an object") + + /* Mark object header as deleted */ + oh_flags = H5AC__DIRTIED_FLAG | H5AC__DELETED_FLAG | H5AC__FREE_FILE_SPACE_FLAG; + +done: + if(oh && H5O_unprotect(&loc, dxpl_id, oh, oh_flags) < 0) + HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header") + + FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL) +} /* end H5O_delete() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_delete_oh + * + * Purpose: Internal function to: + * Delete an object header from a file. This frees the file + * space used for the object header (and it's continuation blocks) + * and also walks through each header message and asks it to + * remove all the pieces of the file referenced by the header. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Mar 19 2003 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5O_delete_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh) +{ + H5O_mesg_t *curr_msg; /* Pointer to current message being operated on */ + unsigned u; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* Check args */ + HDassert(f); + HDassert(oh); + + /* Walk through the list of object header messages, asking each one to + * delete any file space used + */ + for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { + /* Free any space referred to in the file from this message */ + if(H5O_delete_mesg(f, dxpl_id, oh, curr_msg) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTDELETE, FAIL, "unable to delete file space for object header message") + } /* end for */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_delete_oh() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_obj_type + * + * Purpose: Retrieves the type of object pointed to by `loc'. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Robb Matzke + * Wednesday, November 4, 1998 + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_obj_type(const H5O_loc_t *loc, H5O_type_t *obj_type, hid_t dxpl_id) +{ + H5O_t *oh = NULL; /* Object header for location */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_TAG(dxpl_id, loc->addr, FAIL) + + /* Load the object header */ + if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC__READ_ONLY_FLAG, FALSE))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") + + /* Retrieve the type of the object */ + if(H5O_obj_type_real(oh, obj_type) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to determine object type") + +done: + if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + + FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL) +} /* end H5O_obj_type() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_obj_type_real + * + * Purpose: Returns the type of object pointed to by `oh'. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Monday, November 21, 2005 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5O_obj_type_real(H5O_t *oh, H5O_type_t *obj_type) +{ + const H5O_obj_class_t *obj_class; /* Class of object for header */ + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + /* Sanity check */ + HDassert(oh); + HDassert(obj_type); + + /* Look up class for object header */ + if(NULL == (obj_class = H5O_obj_class_real(oh))) { + /* Clear error stack from "failed" class lookup */ + H5E_clear_stack(NULL); + + /* Set type to "unknown" */ + *obj_type = H5O_TYPE_UNKNOWN; + } + else { + /* Set object type */ + *obj_type = obj_class->type; + } + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5O_obj_type_real() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_obj_class + * + * Purpose: Returns the class of object pointed to by `loc'. + * + * Return: Success: An object class + * Failure: NULL + * + * Programmer: Quincey Koziol + * Monday, November 6, 2006 + * + *------------------------------------------------------------------------- + */ +const H5O_obj_class_t * +H5O_obj_class(const H5O_loc_t *loc, hid_t dxpl_id) +{ + H5O_t *oh = NULL; /* Object header for location */ + const H5O_obj_class_t *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT_TAG(dxpl_id, loc->addr, NULL) + + /* Load the object header */ + if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC__READ_ONLY_FLAG, FALSE))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, NULL, "unable to load object header") + + /* Test whether entry qualifies as a particular type of object */ + if(NULL == (ret_value = H5O_obj_class_real(oh))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to determine object type") + +done: + if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to release object header") + + FUNC_LEAVE_NOAPI_TAG(ret_value, NULL) +} /* end H5O_obj_class() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_obj_class_real + * + * Purpose: Returns the class of object pointed to by `oh'. + * + * Return: Success: An object class + * Failure: NULL + * + * Programmer: Quincey Koziol + * Monday, November 21, 2005 + * + *------------------------------------------------------------------------- + */ +static const H5O_obj_class_t * +H5O_obj_class_real(H5O_t *oh) +{ + size_t i; /* Local index variable */ + const H5O_obj_class_t *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* Sanity check */ + HDassert(oh); + + /* Test whether entry qualifies as a particular type of object */ + /* (Note: loop is in reverse order, to test specific objects first) */ + for(i = NELMTS(H5O_obj_class_g); i > 0; --i) { + htri_t isa; /* Is entry a particular type? */ + + if((isa = (H5O_obj_class_g[i - 1]->isa)(oh)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to determine object type") + else if(isa) + HGOTO_DONE(H5O_obj_class_g[i - 1]) + } + + if(0 == i) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to determine object type") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_obj_class_real() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_get_loc + * + * Purpose: Gets the object location for an object given its ID. + * + * Return: Success: Pointer to H5O_loc_t + * Failure: NULL + * + * Programmer: James Laird + * July 25 2006 + * + *------------------------------------------------------------------------- + */ +H5O_loc_t * +H5O_get_loc(hid_t object_id) +{ + H5O_loc_t *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + switch(H5I_get_type(object_id)) { + case H5I_GROUP: + if(NULL == (ret_value = H5O_OBJ_GROUP->get_oloc(object_id))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to get object location from group ID") + break; + + case H5I_DATASET: + if(NULL == (ret_value = H5O_OBJ_DATASET->get_oloc(object_id))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to get object location from dataset ID") + break; + + case H5I_DATATYPE: + if(NULL == (ret_value = H5O_OBJ_DATATYPE->get_oloc(object_id))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to get object location from datatype ID") + break; + + case H5I_UNINIT: + case H5I_BADID: + case H5I_FILE: + case H5I_DATASPACE: + case H5I_ATTR: + case H5I_REFERENCE: + case H5I_VFL: + case H5I_GENPROP_CLS: + case H5I_GENPROP_LST: + case H5I_ERROR_CLASS: + case H5I_ERROR_MSG: + case H5I_ERROR_STACK: + case H5I_NTYPES: + default: + HGOTO_ERROR(H5E_OHDR, H5E_BADTYPE, NULL, "invalid object type") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_get_loc() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_loc_reset + * + * Purpose: Reset a object location to an empty state + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Monday, September 19, 2005 + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_loc_reset(H5O_loc_t *loc) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + /* Check arguments */ + HDassert(loc); + + /* Clear the object location to an empty state */ + HDmemset(loc, 0, sizeof(H5O_loc_t)); + loc->addr = HADDR_UNDEF; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5O_loc_reset() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_loc_copy + * + * Purpose: Copy object location information + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Monday, September 19, 2005 + * + * Notes: 'depth' parameter determines how much of the group entry + * structure we want to copy. The values are: + * H5_COPY_SHALLOW - Copy all the field values from the source + * to the destination, but not copying objects pointed to. + * (Destination "takes ownership" of objects pointed to) + * H5_COPY_DEEP - Copy all the fields from the source to + * the destination, deep copying objects pointed to. + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_loc_copy(H5O_loc_t *dst, H5O_loc_t *src, H5_copy_depth_t depth) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + /* Check arguments */ + HDassert(src); + HDassert(dst); + HDassert(depth == H5_COPY_SHALLOW || depth == H5_COPY_DEEP); + + /* Copy the top level information */ + HDmemcpy(dst, src, sizeof(H5O_loc_t)); + + /* Deep copy the names */ + if(depth == H5_COPY_DEEP) { + /* If the original entry was holding open the file, this one should + * hold it open, too. + */ + if(src->holding_file) + H5F_INCR_NOPEN_OBJS(dst->file); + } + else if(depth == H5_COPY_SHALLOW) { + H5O_loc_reset(src); + } + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5O_loc_copy() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_loc_hold_file + * + * Purpose: Have this object header hold a file open until it is + * released. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: James Laird + * Wednesday, August 16, 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_loc_hold_file(H5O_loc_t *loc) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + /* Check arguments */ + HDassert(loc); + HDassert(loc->file); + + /* If this location is not already holding its file open, do so. */ + if(!loc->holding_file) { + H5F_INCR_NOPEN_OBJS(loc->file); + loc->holding_file = TRUE; + } + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5O_loc_hold_file() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_loc_free + * + * Purpose: Release resources used by this object header location. + * Not to be confused with H5O_close; this is used on + * locations that don't correspond to open objects. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: James Laird + * Wednesday, August 16, 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_loc_free(H5O_loc_t *loc) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT + + /* Check arguments */ + HDassert(loc); + + /* If this location is holding its file open try to close the file. */ + if(loc->holding_file) { + H5F_DECR_NOPEN_OBJS(loc->file); + loc->holding_file = FALSE; + if(H5F_NOPEN_OBJS(loc->file) <= 0) { + if(H5F_try_close(loc->file, NULL) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close file") + } + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_loc_free() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_get_hdr_info + * + * Purpose: Retrieve the object header information for an object + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * September 22 2009 + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_get_hdr_info(const H5O_loc_t *loc, hid_t dxpl_id, H5O_hdr_info_t *hdr) +{ + H5O_t *oh = NULL; /* Object header */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Check args */ + HDassert(loc); + HDassert(hdr); + + /* Reset the object header info structure */ + HDmemset(hdr, 0, sizeof(*hdr)); + + /* Get the object header */ + if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC__READ_ONLY_FLAG, FALSE))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header") + + /* Get the information for the object header */ + if(H5O_get_hdr_info_real(oh, hdr) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object header info") + +done: + if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_get_hdr_info() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_get_hdr_info_real + * + * Purpose: Internal routine to retrieve the object header information for an object + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * September 22 2009 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5O_get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr) +{ + const H5O_mesg_t *curr_msg; /* Pointer to current message being operated on */ + const H5O_chunk_t *curr_chunk; /* Pointer to current message being operated on */ + unsigned u; /* Local index variable */ + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + /* Check args */ + HDassert(oh); + HDassert(hdr); + + /* Set the version for the object header */ + hdr->version = oh->version; + + /* Set the number of messages & chunks */ + H5_CHECKED_ASSIGN(hdr->nmesgs, unsigned, oh->nmesgs, size_t); + H5_CHECKED_ASSIGN(hdr->nchunks, unsigned, oh->nchunks, size_t); + + /* Set the status flags */ + hdr->flags = oh->flags; + + /* Iterate over all the messages, accumulating message size & type information */ + hdr->space.meta = (hsize_t)H5O_SIZEOF_HDR(oh) + (hsize_t)(H5O_SIZEOF_CHKHDR_OH(oh) * (oh->nchunks - 1)); + hdr->space.mesg = 0; + hdr->space.free = 0; + hdr->mesg.present = 0; + hdr->mesg.shared = 0; + for(u = 0, curr_msg = &oh->mesg[0]; u < oh->nmesgs; u++, curr_msg++) { + uint64_t type_flag; /* Flag for message type */ + + /* Accumulate space usage information, based on the type of message */ + if(H5O_NULL_ID == curr_msg->type->id) + hdr->space.free += (hsize_t)((size_t)H5O_SIZEOF_MSGHDR_OH(oh) + curr_msg->raw_size); + else if(H5O_CONT_ID == curr_msg->type->id) + hdr->space.meta += (hsize_t)((size_t)H5O_SIZEOF_MSGHDR_OH(oh) + curr_msg->raw_size); + else { + hdr->space.meta += (hsize_t)H5O_SIZEOF_MSGHDR_OH(oh); + hdr->space.mesg += curr_msg->raw_size; + } /* end else */ + + /* Set flag to indicate presence of message type */ + type_flag = ((uint64_t)1) << curr_msg->type->id; + hdr->mesg.present |= type_flag; + + /* Set flag if the message is shared in some way */ + if(curr_msg->flags & H5O_MSG_FLAG_SHARED) \ + hdr->mesg.shared |= type_flag; + } /* end for */ + + /* Iterate over all the chunks, adding any gaps to the free space */ + hdr->space.total = 0; + for(u = 0, curr_chunk = &oh->chunk[0]; u < oh->nchunks; u++, curr_chunk++) { + /* Accumulate the size of the header on disk */ + hdr->space.total += curr_chunk->size; + + /* If the chunk has a gap, add it to the free space */ + hdr->space.free += curr_chunk->gap; + } /* end for */ + + /* Sanity check that all the bytes are accounted for */ + HDassert(hdr->space.total == (hdr->space.free + hdr->space.meta + hdr->space.mesg)); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5O_get_hdr_info_real() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_get_info + * + * Purpose: Retrieve the information for an object + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * November 21 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_get_info(const H5O_loc_t *loc, hid_t dxpl_id, hbool_t want_ih_info, + H5O_info_t *oinfo) +{ + const H5O_obj_class_t *obj_class; /* Class of object for header */ + H5O_t *oh = NULL; /* Object header */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_TAG(dxpl_id, loc->addr, FAIL) + + /* Check args */ + HDassert(loc); + HDassert(oinfo); + + /* Get the object header */ + if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC__READ_ONLY_FLAG, FALSE))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") + + /* Reset the object info structure */ + HDmemset(oinfo, 0, sizeof(*oinfo)); + + /* Retrieve the file's fileno */ + H5F_GET_FILENO(loc->file, oinfo->fileno); + + /* Set the object's address */ + oinfo->addr = loc->addr; + + /* Get class for object */ + if(NULL == (obj_class = H5O_obj_class_real(oh))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine object class") + + /* Retrieve the type of the object */ + oinfo->type = obj_class->type; + + /* Set the object's reference count */ + oinfo->rc = oh->nlink; + + /* Get modification time for object */ + if(oh->version > H5O_VERSION_1) { + oinfo->atime = oh->atime; + oinfo->mtime = oh->mtime; + oinfo->ctime = oh->ctime; + oinfo->btime = oh->btime; + } /* end if */ + else { + htri_t exists; /* Flag if header message of interest exists */ + + /* No information for access & modification fields */ + /* (we stopped updating the "modification time" header message for + * raw data changes, so the "modification time" header message + * is closest to the 'change time', in POSIX terms - QAK) + */ + oinfo->atime = 0; + oinfo->mtime = 0; + oinfo->btime = 0; + + /* Might be information for modification time */ + if((exists = H5O_msg_exists_oh(oh, H5O_MTIME_ID)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "unable to check for MTIME message") + if(exists > 0) { + /* Get "old style" modification time info */ + if(NULL == H5O_msg_read_oh(loc->file, dxpl_id, oh, H5O_MTIME_ID, &oinfo->ctime)) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't read MTIME message") + } /* end if */ + else { + /* Check for "new style" modification time info */ + if((exists = H5O_msg_exists_oh(oh, H5O_MTIME_NEW_ID)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "unable to check for MTIME_NEW message") + if(exists > 0) { + /* Get "new style" modification time info */ + if(NULL == H5O_msg_read_oh(loc->file, dxpl_id, oh, H5O_MTIME_NEW_ID, &oinfo->ctime)) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't read MTIME_NEW message") + } /* end if */ + else + oinfo->ctime = 0; + } /* end else */ + } /* end else */ + + /* Get the information for the object header */ + if(H5O_get_hdr_info_real(oh, &oinfo->hdr) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object header info") + + /* Retrieve # of attributes */ + if(H5O_attr_count_real(loc->file, dxpl_id, oh, &oinfo->num_attrs) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve attribute count") + + /* Get B-tree & heap metadata storage size, if requested */ + if(want_ih_info) { + /* Check for 'bh_info' callback for this type of object */ + if(obj_class->bh_info) { + /* Call the object's class 'bh_info' routine */ + if((obj_class->bh_info)(loc, dxpl_id, oh, &oinfo->meta_size.obj) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object's btree & heap info") + } /* end if */ + + /* Get B-tree & heap info for any attributes */ + if(oinfo->num_attrs > 0) { + if(H5O_attr_bh_info(loc->file, dxpl_id, oh, &oinfo->meta_size.attr) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve attribute btree & heap info") + } /* end if */ + } /* end if */ + +done: + if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + + FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL) +} /* end H5O_get_info() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_get_create_plist + * + * Purpose: Retrieve the object creation properties for an object + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * November 28 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_get_create_plist(const H5O_loc_t *loc, hid_t dxpl_id, H5P_genplist_t *oc_plist) +{ + H5O_t *oh = NULL; /* Object header */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Check args */ + HDassert(loc); + HDassert(oc_plist); + + /* Get the object header */ + if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC__READ_ONLY_FLAG, FALSE))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") + + /* Set property values, if they were used for the object */ + if(oh->version > H5O_VERSION_1) { + uint8_t ohdr_flags; /* "User-visible" object header status flags */ + + /* Set attribute storage values */ + if(H5P_set(oc_plist, H5O_CRT_ATTR_MAX_COMPACT_NAME, &oh->max_compact) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set max. # of compact attributes in property list") + if(H5P_set(oc_plist, H5O_CRT_ATTR_MIN_DENSE_NAME, &oh->min_dense) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set min. # of dense attributes in property list") + + /* Mask off non-"user visible" flags */ + ohdr_flags = oh->flags & (H5O_HDR_ATTR_CRT_ORDER_TRACKED | H5O_HDR_ATTR_CRT_ORDER_INDEXED | H5O_HDR_STORE_TIMES); + + /* Set object header flags */ + if(H5P_set(oc_plist, H5O_CRT_OHDR_FLAGS_NAME, &ohdr_flags) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set object header flags") + } /* end if */ + +done: + if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_get_create_plist() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_get_nlinks + * + * Purpose: Retrieve the number of link messages read in from the file + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * March 11 2007 + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_get_nlinks(const H5O_loc_t *loc, hid_t dxpl_id, hsize_t *nlinks) +{ + H5O_t *oh = NULL; /* Object header */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Check args */ + HDassert(loc); + HDassert(nlinks); + + /* Get the object header */ + if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC__READ_ONLY_FLAG, FALSE))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") + + /* Retrieve the # of link messages seen when the object header was loaded */ + *nlinks = oh->link_msgs_seen; + +done: + if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_get_nlinks() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_obj_create + * + * Purpose: Creates an object, in an abstract manner. + * + * Return: Success: Pointer to object opened + * Failure: NULL + * + * Programmer: Quincey Koziol + * April 9 2007 + * + *------------------------------------------------------------------------- + */ +void * +H5O_obj_create(H5F_t *f, H5O_type_t obj_type, void *crt_info, H5G_loc_t *obj_loc, + hid_t dxpl_id) +{ + size_t u; /* Local index variable */ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* Sanity checks */ + HDassert(f); + HDassert(obj_type >= H5O_TYPE_GROUP && obj_type <= H5O_TYPE_NAMED_DATATYPE); + HDassert(crt_info); + HDassert(obj_loc); + + /* Iterate through the object classes */ + for(u = 0; u < NELMTS(H5O_obj_class_g); u++) { + /* Check for correct type of object to create */ + if(H5O_obj_class_g[u]->type == obj_type) { + /* Call the object class's 'create' routine */ + HDassert(H5O_obj_class_g[u]->create); + if(NULL == (ret_value = H5O_obj_class_g[u]->create(f, crt_info, obj_loc, dxpl_id))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object") + + /* Break out of loop */ + break; + } /* end if */ + } /* end for */ + HDassert(ret_value); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_obj_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_get_oh_addr + * + * Purpose: Retrieve the address of the object header + * + * Note: This routine participates in the "Inlining C struct access" + * pattern, don't call it directly, use the appropriate macro + * defined in H5Oprivate.h. + * + * Return: Success: Valid haddr_t + * Failure: HADDR_UNDEF + * + * Programmer: Quincey Koziol + * March 15 2007 + * + *------------------------------------------------------------------------- + */ +haddr_t +H5O_get_oh_addr(const H5O_t *oh) +{ + /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + HDassert(oh); + HDassert(oh->chunk); + + FUNC_LEAVE_NOAPI(oh->chunk[0].addr) +} /* end H5O_get_oh_addr() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_get_rc_and_type + * + * Purpose: Retrieve an object's reference count and type + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * November 4 2007 + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_get_rc_and_type(const H5O_loc_t *loc, hid_t dxpl_id, unsigned *rc, H5O_type_t *otype) +{ + H5O_t *oh = NULL; /* Object header */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Check args */ + HDassert(loc); + + /* Get the object header */ + if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC__READ_ONLY_FLAG, FALSE))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header") + + /* Set the object's reference count */ + if(rc) + *rc = oh->nlink; + + /* Retrieve the type of the object */ + if(otype) + if(H5O_obj_type_real(oh, otype) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to determine object type") + +done: + if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_get_rc_and_type() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_free_visit_visited + * + * Purpose: Free the key for an object visited during a group traversal + * + * Return: Non-negative on success, negative on failure + * + * Programmer: Quincey Koziol + * Nov 25, 2007 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5O_free_visit_visited(void *item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSED *operator_data/*in,out*/) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + item = H5FL_FREE(H5_obj_t, item); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5O_free_visit_visited() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_visit_cb + * + * Purpose: Callback function for recursively visiting objects from a group + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Nov 25, 2007 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5O_visit_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info_t *linfo, + void *_udata) +{ + H5O_iter_visit_ud_t *udata = (H5O_iter_visit_ud_t *)_udata; /* User data for callback */ + H5G_loc_t obj_loc; /* Location of object */ + H5G_name_t obj_path; /* Object's group hier. path */ + H5O_loc_t obj_oloc; /* Object's object location */ + hbool_t obj_found = FALSE; /* Object at 'name' found */ + herr_t ret_value = H5_ITER_CONT; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* Sanity check */ + HDassert(name); + HDassert(linfo); + HDassert(udata); + + /* Check if this is a hard link */ + if(linfo->type == H5L_TYPE_HARD) { + H5_obj_t obj_pos; /* Object "position" for this object */ + + /* Set up opened group location to fill in */ + obj_loc.oloc = &obj_oloc; + obj_loc.path = &obj_path; + H5G_loc_reset(&obj_loc); + + /* Find the object using the LAPL passed in */ + /* (Correctly handles mounted files) */ + if(H5G_loc_find(udata->start_loc, name, &obj_loc/*out*/, udata->lapl_id, udata->dxpl_id) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, H5_ITER_ERROR, "object not found") + obj_found = TRUE; + + /* Construct unique "position" for this object */ + H5F_GET_FILENO(obj_oloc.file, obj_pos.fileno); + obj_pos.addr = obj_oloc.addr; + + /* Check if we've seen the object the link references before */ + if(NULL == H5SL_search(udata->visited, &obj_pos)) { + H5O_info_t oinfo; /* Object info */ + + /* Get the object's info */ + if(H5O_get_info(&obj_oloc, udata->dxpl_id, TRUE, &oinfo) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5_ITER_ERROR, "unable to get object info") + + /* Make the application callback */ + ret_value = (udata->op)(udata->obj_id, name, &oinfo, udata->op_data); + + /* Check for continuing to visit objects */ + if(ret_value == H5_ITER_CONT) { + /* If its ref count is > 1, we add it to the list of visited objects */ + /* (because it could come up again during traversal) */ + if(oinfo.rc > 1) { + H5_obj_t *new_node; /* New object node for visited list */ + + /* Allocate new object "position" node */ + if((new_node = H5FL_MALLOC(H5_obj_t)) == NULL) + HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, H5_ITER_ERROR, "can't allocate object node") + + /* Set node information */ + *new_node = obj_pos; + + /* Add to list of visited objects */ + if(H5SL_insert(udata->visited, new_node, new_node) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, H5_ITER_ERROR, "can't insert object node into visited list") + } /* end if */ + } /* end if */ + } /* end if */ + } /* end if */ + +done: + /* Release resources */ + if(obj_found && H5G_loc_free(&obj_loc) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, H5_ITER_ERROR, "can't free location") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_visit_cb() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_visit + * + * Purpose: Recursively visit an object and all the objects reachable + * from it. If the starting object is a group, all the objects + * linked to from that group will be visited. Links within + * each group are visited according to the order within the + * specified index (unless the specified index does not exist for + * a particular group, then the "name" index is used). + * + * NOTE: Soft links and user-defined links are ignored during + * this operation. + * + * NOTE: Each _object_ reachable from the initial group will only + * be visited once. If multiple hard links point to the same + * object, the first link to the object's path (according to the + * iteration index and iteration order given) will be used to in + * the callback about the object. + * + * Return: Success: The return value of the first operator that + * returns non-zero, or zero if all members were + * processed with no operator returning non-zero. + * + * Failure: Negative if something goes wrong within the + * library, or the negative value returned by one + * of the operators. + * + * Programmer: Quincey Koziol + * November 24 2007 + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type, + H5_iter_order_t order, H5O_iterate_t op, void *op_data, hid_t lapl_id, + hid_t dxpl_id) +{ + H5O_iter_visit_ud_t udata; /* User data for callback */ + H5G_loc_t loc; /* Location of reference object */ + H5G_loc_t obj_loc; /* Location used to open object */ + H5G_name_t obj_path; /* Opened object group hier. path */ + H5O_loc_t obj_oloc; /* Opened object object location */ + hbool_t loc_found = FALSE; /* Entry at 'name' found */ + H5O_info_t oinfo; /* Object info struct */ + hid_t obj_id = (-1); /* ID of object */ + herr_t ret_value = FAIL; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Portably initialize user data struct to zeros */ + HDmemset(&udata, 0, sizeof(udata)); + + /* Check args */ + if(H5G_loc(loc_id, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + + /* Set up opened group location to fill in */ + obj_loc.oloc = &obj_oloc; + obj_loc.path = &obj_path; + H5G_loc_reset(&obj_loc); + + /* Find the object's location */ + if(H5G_loc_find(&loc, obj_name, &obj_loc/*out*/, lapl_id, dxpl_id) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + loc_found = TRUE; + + /* Get the object's info */ + if(H5O_get_info(&obj_oloc, dxpl_id, TRUE, &oinfo) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to get object info") + + /* Open the object */ + /* (Takes ownership of the obj_loc information) */ + if((obj_id = H5O_open_by_loc(&obj_loc, lapl_id, dxpl_id, TRUE)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object") + + /* Make callback for starting object */ + if((ret_value = op(obj_id, ".", &oinfo, op_data)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "can't visit objects") + + /* Check return value of first callback */ + if(ret_value != H5_ITER_CONT) + HGOTO_DONE(ret_value); + + /* Check for object being a group */ + if(oinfo.type == H5O_TYPE_GROUP) { + H5G_loc_t start_loc; /* Location of starting group */ + + /* Get the location of the starting group */ + if(H5G_loc(obj_id, &start_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + + /* Set up user data for visiting links */ + udata.obj_id = obj_id; + udata.start_loc = &start_loc; + udata.lapl_id = lapl_id; + udata.dxpl_id = dxpl_id; + udata.op = op; + udata.op_data = op_data; + + /* Create skip list to store visited object information */ + if((udata.visited = H5SL_create(H5SL_TYPE_OBJ, NULL)) == NULL) + HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "can't create skip list for visited objects") + + /* If its ref count is > 1, we add it to the list of visited objects */ + /* (because it could come up again during traversal) */ + if(oinfo.rc > 1) { + H5_obj_t *obj_pos; /* New object node for visited list */ + + /* Allocate new object "position" node */ + if((obj_pos = H5FL_MALLOC(H5_obj_t)) == NULL) + HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, FAIL, "can't allocate object node") + + /* Construct unique "position" for this object */ + obj_pos->fileno = oinfo.fileno; + obj_pos->addr = oinfo.addr; + + /* Add to list of visited objects */ + if(H5SL_insert(udata.visited, obj_pos, obj_pos) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't insert object node into visited list") + } /* end if */ + + /* Call internal group visitation routine */ + if((ret_value = H5G_visit(obj_id, ".", idx_type, order, H5O_visit_cb, &udata, lapl_id, dxpl_id)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") + } /* end if */ + +done: + if(obj_id > 0) { + if(H5I_dec_app_ref(obj_id) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to close object") + } /* end if */ + else if(loc_found && H5G_loc_free(&obj_loc) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location") + if(udata.visited) + H5SL_destroy(udata.visited, H5O_free_visit_visited, NULL); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_visit() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_inc_rc + * + * Purpose: Increments the reference count on an object header + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Jul 13 2008 + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_inc_rc(H5O_t *oh) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* check args */ + HDassert(oh); + + /* Pin the object header when the reference count goes above 0 */ + if(oh->rc == 0) + if(H5AC_pin_protected_entry(oh) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPIN, FAIL, "unable to pin object header") + + /* Increment reference count */ + oh->rc++; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_inc_rc() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_dec_rc + * + * Purpose: Decrements the reference count on an object header + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Jul 13 2008 + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_dec_rc(H5O_t *oh) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* check args */ + HDassert(oh); + + /* Decrement reference count */ + oh->rc--; + + /* Unpin the object header when the reference count goes back to 0 */ + if(oh->rc == 0) + if(H5AC_unpin_entry(oh) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPIN, FAIL, "unable to unpin object header") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_dec_rc() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_dec_rc_by_loc + * + * Purpose: Decrement the refcount of an object header, using its + * object location information. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Oct 08 2010 + * + *------------------------------------------------------------------------- + */ +herr_t +H5O_dec_rc_by_loc(const H5O_loc_t *loc, hid_t dxpl_id) +{ + H5O_t *oh = NULL; /* Object header */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* check args */ + HDassert(loc); + + /* Get header */ + if(NULL == (oh = H5O_protect(loc, dxpl_id, H5AC__READ_ONLY_FLAG, FALSE))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to protect object header") + + /* Decrement the reference count on the object header */ + /* (which will unpin it, if appropriate) */ + if(H5O_dec_rc(oh) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement reference count on object header") + +done: + /* Release the object header from the cache */ + if(oh && H5O_unprotect(loc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_dec_rc_by_loc() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_get_proxy + * + * Purpose: Retrieve the proxy for the object header. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * July 24 2016 + * + *------------------------------------------------------------------------- + */ +H5AC_proxy_entry_t * +H5O_get_proxy(const H5O_t *oh) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + /* Check args */ + HDassert(oh); + + FUNC_LEAVE_NOAPI(oh->proxy) +} /* end H5O_get_proxy() */ + + +/*------------------------------------------------------------------------- + * Function: H5O__free + * + * Purpose: Destroys an object header. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@ncsa.uiuc.edu + * Jan 15 2003 + * + *------------------------------------------------------------------------- + */ +herr_t +H5O__free(H5O_t *oh) +{ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* check args */ + HDassert(oh); + HDassert(0 == oh->rc); + + /* Destroy chunks */ + if(oh->chunk) { + for(u = 0; u < oh->nchunks; u++) + oh->chunk[u].image = H5FL_BLK_FREE(chunk_image, oh->chunk[u].image); + + oh->chunk = (H5O_chunk_t *)H5FL_SEQ_FREE(H5O_chunk_t, oh->chunk); + } /* end if */ + + /* Destroy messages */ + if(oh->mesg) { + for(u = 0; u < oh->nmesgs; u++) { +#ifndef NDEBUG + /* Verify that message is clean, unless it could have been marked + * dirty by decoding */ + if(oh->ndecode_dirtied && oh->mesg[u].dirty) + oh->ndecode_dirtied--; + else + HDassert(oh->mesg[u].dirty == 0); +#endif /* NDEBUG */ + + H5O_msg_free_mesg(&oh->mesg[u]); + } /* end for */ + + /* Make sure we accounted for all the messages dirtied by decoding */ + HDassert(!oh->ndecode_dirtied); + + oh->mesg = (H5O_mesg_t *)H5FL_SEQ_FREE(H5O_mesg_t, oh->mesg); + } /* end if */ + + /* Destroy the proxy */ + if(oh->proxy) + if(H5AC_proxy_entry_dest(oh->proxy) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy virtual entry used for proxy") + + /* destroy object header */ + oh = H5FL_FREE(H5O_t, oh); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O__free() */ diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 314ee04..e87c148 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -883,6 +883,9 @@ H5_DLL void *H5O_obj_create(H5F_t *f, H5O_type_t obj_type, void *crt_info, H5G_l H5_DLL haddr_t H5O_get_oh_addr(const H5O_t *oh); H5_DLL herr_t H5O_get_rc_and_type(const H5O_loc_t *oloc, hid_t dxpl_id, unsigned *rc, H5O_type_t *otype); H5_DLL H5AC_proxy_entry_t *H5O_get_proxy(const H5O_t *oh); +H5_DLL herr_t H5O_visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type, + H5_iter_order_t order, H5O_iterate_t op, void *op_data, hid_t lapl_id, + hid_t dxpl_id); /* Object header message routines */ H5_DLL herr_t H5O_msg_create(const H5O_loc_t *loc, unsigned type_id, unsigned mesg_flags, -- cgit v0.12 From 5ce8dd5e946c85522edd76f3288e7052bde86b8a Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 15 Nov 2017 02:58:16 -0800 Subject: Minor warning fixes --- hl/tools/h5watch/h5watch.c | 1 + src/H5Zszip.c | 46 +++++++++++++++++------------------ test/cross_read.c | 2 ++ test/tcoords.c | 10 ++++---- tools/src/h5diff/h5diff_common.c | 3 +++ tools/src/h5jam/h5jam.c | 6 ++--- tools/src/h5ls/h5ls.c | 2 ++ tools/src/h5repack/h5repack_filters.c | 4 +-- tools/src/misc/h5mkgrp.c | 2 ++ 9 files changed, 41 insertions(+), 35 deletions(-) diff --git a/hl/tools/h5watch/h5watch.c b/hl/tools/h5watch/h5watch.c index 11514b0..d1f4e32 100644 --- a/hl/tools/h5watch/h5watch.c +++ b/hl/tools/h5watch/h5watch.c @@ -704,6 +704,7 @@ parse_command_line(int argc, const char *argv[]) case 'h': /* --help */ usage(h5tools_getprogname()); leave(EXIT_SUCCESS); + break; case 'V': /* --version */ print_version(progname); diff --git a/src/H5Zszip.c b/src/H5Zszip.c index 769011c..0c60239 100644 --- a/src/H5Zszip.c +++ b/src/H5Zszip.c @@ -70,8 +70,6 @@ H5Z_class2_t H5Z_SZIP[1] = {{ * Programmer: Quincey Koziol * Monday, April 7, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ static htri_t @@ -86,24 +84,24 @@ H5Z_can_apply_szip(hid_t H5_ATTR_UNUSED dcpl_id, hid_t type_id, hid_t H5_ATTR_UN /* Get datatype */ if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Get datatype's size, for checking the "bits-per-pixel" */ if((dtype_size = (8 * H5T_get_size(type))) == 0) - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size") + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size") /* Range check datatype's size */ if(dtype_size > 32 && dtype_size != 64) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FALSE, "invalid datatype size") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FALSE, "invalid datatype size") /* Get datatype's endianness order */ if((dtype_order = H5T_get_order(type)) == H5T_ORDER_ERROR) - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "can't retrieve datatype endianness order") + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "can't retrieve datatype endianness order") /* Range check datatype's endianness order */ /* (Note: this may not handle non-atomic datatypes well) */ if(dtype_order != H5T_ORDER_LE && dtype_order != H5T_ORDER_BE) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FALSE, "invalid datatype endianness order") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FALSE, "invalid datatype endianness order") done: FUNC_LEAVE_NOAPI(ret_value) @@ -157,19 +155,19 @@ H5Z_set_local_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id) /* Get datatype */ if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Get the filter's current parameters */ if(H5P_get_filter_by_id(dcpl_plist, H5Z_FILTER_SZIP, &flags, &cd_nelmts, cd_values, 0, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get szip parameters") + HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get szip parameters") /* Get datatype's size, for checking the "bits-per-pixel" */ if((dtype_size = (8 * H5T_get_size(type))) == 0) - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size"); + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size"); /* Get datatype's precision, in case is less than full bits */ if((dtype_precision = H5T_get_precision(type)) == 0) - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype precision"); + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype precision"); if(dtype_precision < dtype_size) { dtype_offset = H5T_get_offset(type); @@ -177,9 +175,9 @@ H5Z_set_local_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id) dtype_precision = dtype_size; } /* end if */ if(dtype_precision > 24) { - if(dtype_precision <= 32) + if(dtype_precision <= 32) dtype_precision = 32; - else if(dtype_precision <= 64) + else if(dtype_precision <= 64) dtype_precision = 64; } /* end if */ @@ -227,7 +225,7 @@ H5Z_set_local_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id) /* Get datatype's endianness order */ if((dtype_order = H5T_get_order(type)) == H5T_ORDER_ERROR) - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype endianness order") + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype endianness order") /* Set the correct endianness flag for szip */ /* (Note: this may not handle non-atomic datatypes well) */ @@ -241,13 +239,17 @@ H5Z_set_local_szip(hid_t dcpl_id, hid_t type_id, hid_t space_id) cd_values[H5Z_SZIP_PARM_MASK] |= SZ_MSB_OPTION_MASK; break; + case H5T_ORDER_ERROR: + case H5T_ORDER_VAX: + case H5T_ORDER_MIXED: + case H5T_ORDER_NONE: default: HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype endianness order") } /* end switch */ /* Modify the filter's parameters for this dataset */ if(H5P_modify_filter(dcpl_plist, H5Z_FILTER_SZIP, flags, H5Z_SZIP_TOTAL_NPARMS, cd_values) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTSET, FAIL, "can't set local szip parameters") + HGOTO_ERROR(H5E_PLINE, H5E_CANTSET, FAIL, "can't set local szip parameters") done: FUNC_LEAVE_NOAPI(ret_value) @@ -266,10 +268,6 @@ done: * Programmer: Kent Yang * Tuesday, April 1, 2003 * - * Modifications: - * Quincey Koziol, April 2, 2003 - * Cleaned up code. - * *------------------------------------------------------------------------- */ static size_t @@ -296,7 +294,7 @@ H5Z_filter_szip (unsigned flags, size_t cd_nelmts, const unsigned cd_values[], /* Check arguments */ if (cd_nelmts!=4) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid number of filter parameters") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid number of filter parameters") /* Copy the filter parameters into the szip parameter block */ H5_CHECKED_ASSIGN(sz_param.options_mask, int, cd_values[H5Z_SZIP_PARM_MASK], unsigned); @@ -310,12 +308,12 @@ H5Z_filter_szip (unsigned flags, size_t cd_nelmts, const unsigned cd_values[], size_t nalloc; /* Number of bytes the compressed block will expand into */ /* Get the size of the uncompressed buffer */ - newbuf = *buf; + newbuf = (unsigned char *)(*buf); UINT32DECODE(newbuf,stored_nalloc); H5_CHECKED_ASSIGN(nalloc, size_t, stored_nalloc, uint32_t); /* Allocate space for the uncompressed buffer */ - if(NULL==(outbuf = H5MM_malloc(nalloc))) + if(NULL == (outbuf = (unsigned char *)H5MM_malloc(nalloc))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed for szip decompression") /* Decompress the buffer */ @@ -338,7 +336,7 @@ H5Z_filter_szip (unsigned flags, size_t cd_nelmts, const unsigned cd_values[], unsigned char *dst = NULL; /* Temporary pointer to new output buffer */ /* Allocate space for the compressed buffer & header (assume data won't get bigger) */ - if(NULL==(dst=outbuf = H5MM_malloc(nbytes+4))) + if(NULL == (dst=outbuf = (unsigned char *)H5MM_malloc(nbytes+4))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "unable to allocate szip destination buffer") /* Encode the uncompressed length */ @@ -348,7 +346,7 @@ H5Z_filter_szip (unsigned flags, size_t cd_nelmts, const unsigned cd_values[], /* Compress the buffer */ size_out = nbytes; if(SZ_OK!= SZ_BufftoBuffCompress(dst, &size_out, *buf, nbytes, &sz_param)) - HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, 0, "overflow") + HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, 0, "overflow") HDassert(size_out<=nbytes); /* Free the input buffer */ diff --git a/test/cross_read.c b/test/cross_read.c index 5d5ef07..2219151 100644 --- a/test/cross_read.c +++ b/test/cross_read.c @@ -226,7 +226,9 @@ check_file(char *filename) const char *pathname = H5_get_srcdir_filename(filename); /* Corrected test file name */ hid_t fid = -1; /* file ID */ int nerrors = 0; /* # of datasets with errors */ +#if !defined(H5_HAVE_FILTER_DEFLATE) || !defined(H5_HAVE_FILTER_SZIP) const char *not_supported= " filter is not enabled."; /* no filter message */ +#endif /* Open the file. */ if((fid = H5Fopen(pathname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) diff --git a/test/tcoords.c b/test/tcoords.c index d729d4b..f639d4b 100644 --- a/test/tcoords.c +++ b/test/tcoords.c @@ -669,22 +669,22 @@ static void test_multiple_ends(hid_t file, hbool_t is_chunked) void test_coords(void) { hid_t fid; + hbool_t is_chunk[2] = {TRUE, FALSE}; int i; - hbool_t is_chunk; herr_t ret; /* Generic error return */ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fcreate"); - for(i=0, is_chunk=FALSE; i<2; i++, is_chunk++) { + for (i = 0; i < 2; i++) { /* Test H5Sselect_elements with selection of one block of data */ - test_singleEnd_selElements(fid, is_chunk); + test_singleEnd_selElements(fid, is_chunk[i]); /* Test H5Sselect_hyperslab with selection of one block of data */ - test_singleEnd_selHyperslab(fid, is_chunk); + test_singleEnd_selHyperslab(fid, is_chunk[i]); /* Test H5Sselect_hyperslab with selection of multiple blocks of data */ - test_multiple_ends(fid, is_chunk); + test_multiple_ends(fid, is_chunk[i]); } ret = H5Fclose(fid); diff --git a/tools/src/h5diff/h5diff_common.c b/tools/src/h5diff/h5diff_common.c index 532169f..ce5df78 100644 --- a/tools/src/h5diff/h5diff_common.c +++ b/tools/src/h5diff/h5diff_common.c @@ -115,14 +115,17 @@ void parse_command_line(int argc, default: usage(); h5diff_exit(EXIT_FAILURE); + break; case 'h': usage(); h5diff_exit(EXIT_SUCCESS); + break; case 'V': print_version(h5tools_getprogname()); h5diff_exit(EXIT_SUCCESS); + break; case 'v': opts->m_verbose = 1; diff --git a/tools/src/h5jam/h5jam.c b/tools/src/h5jam/h5jam.c index 8c15686..cc5fcdc 100644 --- a/tools/src/h5jam/h5jam.c +++ b/tools/src/h5jam/h5jam.c @@ -179,9 +179,11 @@ parse_command_line (int argc, const char *argv[]) case 'h': usage (h5tools_getprogname()); leave (EXIT_SUCCESS); + break; case 'V': print_version (h5tools_getprogname()); leave (EXIT_SUCCESS); + break; case '?': default: usage (h5tools_getprogname()); @@ -198,10 +200,6 @@ parse_command_line (int argc, const char *argv[]) * Return: Success: 0 * Failure: 1 * - * Programmer: - * - * Modifications: - * *------------------------------------------------------------------------- */ int diff --git a/tools/src/h5ls/h5ls.c b/tools/src/h5ls/h5ls.c index d397067..a07d308 100644 --- a/tools/src/h5ls/h5ls.c +++ b/tools/src/h5ls/h5ls.c @@ -2709,6 +2709,7 @@ main(int argc, const char *argv[]) case 'h': /* --help */ usage(); leave(EXIT_SUCCESS); + break; case 'a': /* --address */ address_g = TRUE; @@ -2759,6 +2760,7 @@ main(int argc, const char *argv[]) case 'V': /* --version */ print_version(h5tools_getprogname()); leave(EXIT_SUCCESS); + break; case 'x': /* --hexdump */ hexdump_g = TRUE; diff --git a/tools/src/h5repack/h5repack_filters.c b/tools/src/h5repack/h5repack_filters.c index e968b3c..067ebad 100644 --- a/tools/src/h5repack/h5repack_filters.c +++ b/tools/src/h5repack/h5repack_filters.c @@ -42,7 +42,7 @@ static int aux_copy_obj(hid_t dcpl_id, /* dataset creation property list */ H5D_layout_t layout; int rank; /* rank of dataset */ hsize_t chsize[64]; /* chunk size in elements */ - unsigned int i, j; + unsigned int i; /* get information about input filters */ if ((nfilters = H5Pget_nfilters(dcpl_id)) < 0) @@ -240,7 +240,7 @@ int apply_filters(const char* name, /* object name from traverse list */ int nfilters; /* number of filters in DCPL */ hsize_t chsize[64]; /* chunk size in elements */ H5D_layout_t layout; - int i, j; + int i; pack_info_t obj; pack_info_t filtobj; diff --git a/tools/src/misc/h5mkgrp.c b/tools/src/misc/h5mkgrp.c index 43d6bfe..b7ff73c 100644 --- a/tools/src/misc/h5mkgrp.c +++ b/tools/src/misc/h5mkgrp.c @@ -129,6 +129,7 @@ parse_command_line(int argc, const char *argv[], param_t *parms) case 'h': usage(); leave(EXIT_SUCCESS); + break; /* Create objects with the latest version of the format */ case 'l': @@ -149,6 +150,7 @@ parse_command_line(int argc, const char *argv[], param_t *parms) case 'V': print_version(h5tools_getprogname()); leave(EXIT_SUCCESS); + break; /* Bad command line argument */ default: -- cgit v0.12 From cb235453a9276c371085e40ea1c87d9b641e511e Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 15 Nov 2017 14:24:59 -0800 Subject: Changed ar to always use -cr instead of the autotools default of cru. --- config/linux-gnulibc1 | 5 ----- configure.ac | 7 ++++++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/config/linux-gnulibc1 b/config/linux-gnulibc1 index c32f64e..39225e7 100644 --- a/config/linux-gnulibc1 +++ b/config/linux-gnulibc1 @@ -30,11 +30,6 @@ if test -z "$CC"; then fi fi -# Set flags for gnu ar (apparently via libtool, so AR_FLAGS, not ARFLAGS) -# If you don't do this, you will get warnings about the 'u' in -# automake's default 'cru' args. -AR_FLAGS=crD - # Figure out GNU C compiler flags . $srcdir/config/gnu-flags diff --git a/configure.ac b/configure.ac index 50893f7..5562d5c 100644 --- a/configure.ac +++ b/configure.ac @@ -759,12 +759,17 @@ fi ## Check which archiving tool to use. This needs to be done before ## the AM_PROG_LIBTOOL macro. ## - if test -z "$AR"; then AC_CHECK_PROGS([AR], [ar xar], [:], [$PATH]) fi AC_SUBST([AR]) +# Set the default ar flags to cr +# The Automake default is to use cru and the 'u' causes ar +# to emit warnings on some platforms. +AR_FLAGS=cr + + ## Export the AR macro so that it will be placed in the libtool file ## correctly. export AR -- cgit v0.12 From 637a8f7562c32f1b76b6ff67926baa2b816a3355 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 15 Nov 2017 17:14:35 -0600 Subject: Correct linkage of filters and other libs --- CMakeFilters.cmake | 16 ++++++++-------- src/CMakeLists.txt | 4 ++-- test/CMakeLists.txt | 4 ++-- test/dsets.c | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/CMakeFilters.cmake b/CMakeFilters.cmake index 804b16b..71dabb1 100644 --- a/CMakeFilters.cmake +++ b/CMakeFilters.cmake @@ -45,8 +45,8 @@ if (HDF5_ENABLE_Z_LIB_SUPPORT) if (NOT ZLIB_FOUND) find_package (ZLIB) # Legacy find if (ZLIB_FOUND) - set (LINK_LIBS ${LINK_LIBS} ${ZLIB_LIBRARIES}) - set (LINK_SHARED_LIBS ${LINK_SHARED_LIBS} ${ZLIB_LIBRARIES}) + set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ${ZLIB_LIBRARIES}) + set (LINK_COMP_SHARED_LIBS ${LINK_COMP_SHARED_LIBS} ${ZLIB_LIBRARIES}) endif () endif () endif () @@ -78,9 +78,9 @@ if (HDF5_ENABLE_Z_LIB_SUPPORT) set (EXTERNAL_FILTERS "${EXTERNAL_FILTERS} DEFLATE") endif () if (BUILD_SHARED_LIBS) - set (LINK_SHARED_LIBS ${LINK_SHARED_LIBS} ${ZLIB_SHARED_LIBRARY}) + set (LINK_COMP_SHARED_LIBS ${LINK_COMP_SHARED_LIBS} ${ZLIB_SHARED_LIBRARY}) endif () - set (LINK_LIBS ${LINK_LIBS} ${ZLIB_STATIC_LIBRARY}) + set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ${ZLIB_STATIC_LIBRARY}) INCLUDE_DIRECTORIES (${ZLIB_INCLUDE_DIRS}) message (STATUS "Filter ZLIB is ON") endif () @@ -96,8 +96,8 @@ if (HDF5_ENABLE_SZIP_SUPPORT) if (NOT SZIP_FOUND) find_package (SZIP) # Legacy find if (SZIP_FOUND) - set (LINK_LIBS ${LINK_LIBS} ${SZIP_LIBRARIES}) - set (LINK_SHARED_LIBS ${LINK_SHARED_LIBS} ${SZIP_LIBRARIES}) + set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ${SZIP_LIBRARIES}) + set (LINK_COMP_SHARED_LIBS ${LINK_COMP_SHARED_LIBS} ${SZIP_LIBRARIES}) endif () endif () endif () @@ -119,9 +119,9 @@ if (HDF5_ENABLE_SZIP_SUPPORT) endif () endif () if (BUILD_SHARED_LIBS) - set (LINK_SHARED_LIBS ${LINK_SHARED_LIBS} ${SZIP_SHARED_LIBRARY}) + set (LINK_COMP_SHARED_LIBS ${LINK_COMP_SHARED_LIBS} ${SZIP_SHARED_LIBRARY}) endif () - set (LINK_LIBS ${LINK_LIBS} ${SZIP_STATIC_LIBRARY}) + set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ${SZIP_STATIC_LIBRARY}) INCLUDE_DIRECTORIES (${SZIP_INCLUDE_DIRS}) message (STATUS "Filter SZIP is ON") if (H5_HAVE_FILTER_SZIP) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 91b8e0c..b163b8a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -883,7 +883,7 @@ set (gen_SRCS ${HDF5_BINARY_DIR}/H5Tinit.c ${HDF5_BINARY_DIR}/H5lib_settings.c) add_library (${HDF5_LIB_TARGET} STATIC ${common_SRCS} ${gen_SRCS} ${H5_PUBLIC_HEADERS} ${H5_PRIVATE_HEADERS} ${H5_GENERATED_HEADERS}) TARGET_C_PROPERTIES (${HDF5_LIB_TARGET} STATIC " " " ") -target_link_libraries (${HDF5_LIB_TARGET} PRIVATE ${LINK_LIBS}) +target_link_libraries (${HDF5_LIB_TARGET} PRIVATE ${LINK_LIBS} ${LINK_COMP_LIBS}) if (NOT WIN32) target_link_libraries (${HDF5_LIB_TARGET} PUBLIC dl) endif () @@ -927,7 +927,7 @@ if (BUILD_SHARED_LIBS) set (shared_gen_SRCS ${HDF5_BINARY_DIR}/shared/H5Tinit.c ${HDF5_BINARY_DIR}/shared/H5lib_settings.c) add_library (${HDF5_LIBSH_TARGET} SHARED ${common_SRCS} ${shared_gen_SRCS} ${H5_PUBLIC_HEADERS} ${H5_PRIVATE_HEADERS} ${H5_GENERATED_HEADERS}) TARGET_C_PROPERTIES (${HDF5_LIBSH_TARGET} SHARED " " " ") - target_link_libraries (${HDF5_LIBSH_TARGET} PRIVATE ${LINK_LIBS}) + target_link_libraries (${HDF5_LIBSH_TARGET} PRIVATE ${LINK_LIBS} ${LINK_COMP_LIBS}) if (NOT WIN32) target_link_libraries (${HDF5_LIBSH_TARGET} PUBLIC dl) endif () diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0a2afbf..fca864b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -37,7 +37,7 @@ endif () if (MINGW) target_link_libraries (${HDF5_TEST_LIB_TARGET} "wsock32.lib") endif () -target_link_libraries (${HDF5_TEST_LIB_TARGET} ${HDF5_LIB_TARGET}) +target_link_libraries (${HDF5_TEST_LIB_TARGET} ${HDF5_LIB_TARGET} ${LINK_LIBS}) H5_SET_LIB_OPTIONS (${HDF5_TEST_LIB_TARGET} ${HDF5_TEST_LIB_NAME} STATIC) set_target_properties (${HDF5_TEST_LIB_TARGET} PROPERTIES FOLDER libraries/test @@ -53,7 +53,7 @@ if (BUILD_SHARED_LIBS) if (MINGW) target_link_libraries (${HDF5_TEST_LIBSH_TARGET} "wsock32.lib") endif () - target_link_libraries (${HDF5_TEST_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) + target_link_libraries (${HDF5_TEST_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} ${LINK_LIBS}) H5_SET_LIB_OPTIONS (${HDF5_TEST_LIBSH_TARGET} ${HDF5_TEST_LIB_NAME} SHARED ${HDF5_PACKAGE_SOVERSION}) set_target_properties (${HDF5_TEST_LIBSH_TARGET} PROPERTIES FOLDER libraries/test diff --git a/test/dsets.c b/test/dsets.c index 4088304..0fff2d1 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -2087,7 +2087,7 @@ test_get_filter_info(void) #ifdef H5_HAVE_FILTER_SZIP if(H5Zget_filter_info(H5Z_FILTER_SZIP, &flags) < 0) TEST_ERROR - if(SZ_encoder_enabled()) { + if(H5Z_SZIP->encoder_present) { if(((flags & H5Z_FILTER_CONFIG_ENCODE_ENABLED) == 0) || ((flags & H5Z_FILTER_CONFIG_DECODE_ENABLED) == 0)) TEST_ERROR -- cgit v0.12 From fea722ec678772a9debcbd56221d1326b11f7ca8 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 16 Nov 2017 09:04:50 -0600 Subject: Add note for plugins --- release_docs/RELEASE.txt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index f8ad620..9e3c3a9 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -157,6 +157,25 @@ Bug Fixes since HDF5-1.10.1 release Library ------- + - filter plugin handling in H5PL.c and H5Z.c + + It was discovered that the dynamic loading process used by + filter plugins had issues with memory allocation and library + dependencies. + + CMake build process changed to use LINK INTERFACE keywords, which + allowed HDF5 C library to make dependent libraries private. The + filter plugin libraries no longer require dependent libraries + (such as szip or zlib) to be available. + (ADB - 2017/11/16, HDFFV-10328) + + The H5Z_class2_t structure returned by the filter plugins are + now dynamically allocated in H5Zregister function. Access to + the functions in the filter library now always use the dynamic + library API. + + (ADB - 2017/11/16, HDFFV-10329) + - H5Zfilter_avail in H5Z.c The public function checked for plugins, while the private -- cgit v0.12 From 8e193705c5700d32866d6e7c71ef17743015a84e Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 16 Nov 2017 09:28:58 -0600 Subject: Fix some of the whitespace --- test/tattr.c | 254 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 127 insertions(+), 127 deletions(-) diff --git a/test/tattr.c b/test/tattr.c index d7152ed..3786d0d 100644 --- a/test/tattr.c +++ b/test/tattr.c @@ -163,21 +163,21 @@ static herr_t attr_op1(hid_t loc_id, const char *name, const H5A_info_t *ainfo, static void test_attr_basic_write(hid_t fapl) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t group; /* Group ID */ - hid_t sid1,sid2; /* Dataspace ID */ - hid_t attr, attr2; /* Attribute ID */ - hsize_t attr_size; /* storage size for attribute */ - ssize_t attr_name_size; /* size of attribute name */ - char *attr_name=NULL; /* name of attribute */ - hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; - hsize_t dims2[] = {ATTR1_DIM1}; - hsize_t dims3[] = {ATTR2_DIM1,ATTR2_DIM2}; - int read_data1[ATTR1_DIM1]={0}; /* Buffer for reading 1st attribute */ - int i; - hid_t ret_id; /* Generic hid_t return value */ - herr_t ret; /* Generic return value */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t group; /* Group ID */ + hid_t sid1,sid2; /* Dataspace ID */ + hid_t attr, attr2; /* Attribute ID */ + hsize_t attr_size; /* storage size for attribute */ + ssize_t attr_name_size; /* size of attribute name */ + char *attr_name=NULL; /* name of attribute */ + hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + hsize_t dims2[] = {ATTR1_DIM1}; + hsize_t dims3[] = {ATTR2_DIM1,ATTR2_DIM2}; + int read_data1[ATTR1_DIM1]={0}; /* Buffer for reading 1st attribute */ + int i; + hid_t ret_id; /* Generic hid_t return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Basic Scalar Attribute Writing Functions\n")); @@ -402,15 +402,15 @@ test_attr_basic_write(hid_t fapl) static void test_attr_basic_read(hid_t fapl) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t group; /* Group ID */ - hid_t attr; /* Attribute ID */ - H5O_info_t oinfo; /* Object info */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t group; /* Group ID */ + hid_t attr; /* Attribute ID */ + H5O_info_t oinfo; /* Object info */ int read_data1[ATTR1_DIM1] = {0}; /* Buffer for reading 1st attribute */ int read_data2[ATTR2_DIM1][ATTR2_DIM2] = {{0}}; /* Buffer for reading 2nd attribute */ - int i, j; /* Local index variables */ - herr_t ret; /* Generic return value */ + int i, j; /* Local index variables */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Basic Attribute Functions\n")); @@ -500,7 +500,7 @@ test_attr_flush(hid_t fapl) set; /* Dataset ID */ double wdata=3.14159F; /* Data to write */ double rdata; /* Data read in */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Attribute Flushing\n")); @@ -563,12 +563,12 @@ test_attr_plist(hid_t fapl) hid_t fid1; /* HDF5 File IDs */ hid_t dataset; /* Dataset ID */ hid_t sid1,sid2; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - hid_t plist; /* Property list ID */ - hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; - hsize_t dims2[] = {ATTR1_DIM1}; - H5T_cset_t cset; /* Character set for attributes */ - herr_t ret; /* Generic return value */ + hid_t attr; /* Attribute ID */ + hid_t plist; /* Property list ID */ + hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + hsize_t dims2[] = {ATTR1_DIM1}; + H5T_cset_t cset; /* Character set for attributes */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Attribute Property Lists\n")); @@ -675,14 +675,14 @@ static void test_attr_compound_write(hid_t fapl) { hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t tid1; /* Attribute datatype ID */ - hid_t sid1,sid2; /* Dataspace ID */ + hid_t dataset; /* Dataset ID */ + hid_t tid1; /* Attribute datatype ID */ + hid_t sid1,sid2; /* Dataspace ID */ hid_t attr; /* Attribute ID */ - hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; - hsize_t dims2[] = {ATTR4_DIM1,ATTR4_DIM2}; + hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + hsize_t dims2[] = {ATTR4_DIM1,ATTR4_DIM2}; hid_t ret_id; /* Generic hid_t return value */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Multiple Attribute Functions\n")); @@ -762,11 +762,11 @@ test_attr_compound_write(hid_t fapl) static void test_attr_compound_read(hid_t fapl) { - hid_t fid1; /* HDF5 File ID */ + hid_t fid1; /* HDF5 File ID */ hid_t dataset; /* Dataset ID */ hid_t space; /* Attribute dataspace */ hid_t type; /* Attribute datatype */ - hid_t attr; /* Attribute ID */ + hid_t attr; /* Attribute ID */ char attr_name[ATTR_NAME_LEN]; /* Buffer for attribute names */ int rank; /* Attribute rank */ hsize_t dims[ATTR_MAX_DIMS]; /* Attribute dimensions */ @@ -781,7 +781,7 @@ test_attr_compound_read(hid_t fapl) ssize_t name_len; /* Length of attribute name */ H5O_info_t oinfo; /* Object info */ int i, j; /* Local index variables */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Basic Attribute Functions\n")); @@ -830,7 +830,7 @@ test_attr_compound_read(hid_t fapl) HDstrcmp(fieldname, ATTR4_FIELDNAME3))) TestErrPrintf("invalid field name for field #%d: %s\n", i, fieldname); H5free_memory(fieldname); - } /* end for */ + } /* end for */ offset = H5Tget_member_offset(type, 0); VERIFY(offset, attr4_field1_off, "H5Tget_member_offset"); offset = H5Tget_member_offset(type, 1); @@ -878,7 +878,7 @@ test_attr_compound_read(hid_t fapl) printf("%d: attribute data different: attr_data4[%d][%d].i=%d, read_data4[%d][%d].i=%d\n", __LINE__, i, j, attr_data4[i][j].i, i, j, read_data4[i][j].i); printf("%d: attribute data different: attr_data4[%d][%d].d=%f, read_data4[%d][%d].d=%f\n", __LINE__, i, j, attr_data4[i][j].d, i, j, read_data4[i][j].d); TestErrPrintf("%d: attribute data different: attr_data4[%d][%d].c=%c, read_data4[%d][%d].c=%c\n", __LINE__, i, j, attr_data4[i][j].c, i, j, read_data4[i][j].c); - } /* end if */ + } /* end if */ /* Verify Name */ name_len = H5Aget_name(attr, (size_t)ATTR_NAME_LEN, attr_name); @@ -913,12 +913,12 @@ static void test_attr_scalar_write(hid_t fapl) { hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1,sid2; /* Dataspace ID */ + hid_t dataset; /* Dataset ID */ + hid_t sid1,sid2; /* Dataspace ID */ hid_t attr; /* Attribute ID */ - hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; hid_t ret_id; /* Generic hid_t return value */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Basic Attribute Functions\n")); @@ -979,13 +979,13 @@ static void test_attr_scalar_read(hid_t fapl) { hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ + hid_t dataset; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ H5S_class_t stype; /* Dataspace class */ - float rdata = 0.0F; /* Buffer for reading 1st attribute */ + float rdata = 0.0F; /* Buffer for reading 1st attribute */ H5O_info_t oinfo; /* Object info */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Basic Scalar Attribute Reading Functions\n")); @@ -1013,8 +1013,8 @@ test_attr_scalar_read(hid_t fapl) /* Verify the floating-poing value in this way to avoid compiler warning. */ if(!H5_FLT_ABS_EQUAL(rdata, attr_data5)) - printf("*** UNEXPECTED VALUE from %s should be %f, but is %f at line %4d in %s\n", - "H5Aread", (double)attr_data5, (double)rdata, (int)__LINE__, __FILE__); + printf("*** UNEXPECTED VALUE from %s should be %f, but is %f at line %4d in %s\n", + "H5Aread", (double)attr_data5, (double)rdata, (int)__LINE__, __FILE__); /* Get the attribute's dataspace */ sid = H5Aget_space(attr); @@ -1051,15 +1051,15 @@ static void test_attr_mult_write(hid_t fapl) { hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1,sid2; /* Dataspace ID */ + hid_t dataset; /* Dataset ID */ + hid_t sid1,sid2; /* Dataspace ID */ hid_t attr; /* Attribute ID */ - hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; - hsize_t dims2[] = {ATTR1_DIM1}; - hsize_t dims3[] = {ATTR2_DIM1,ATTR2_DIM2}; - hsize_t dims4[] = {ATTR3_DIM1,ATTR3_DIM2,ATTR3_DIM3}; + hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + hsize_t dims2[] = {ATTR1_DIM1}; + hsize_t dims3[] = {ATTR2_DIM1,ATTR2_DIM2}; + hsize_t dims4[] = {ATTR3_DIM1,ATTR3_DIM2,ATTR3_DIM3}; hid_t ret_id; /* Generic hid_t return value */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Multiple Attribute Functions\n")); @@ -1170,11 +1170,11 @@ test_attr_mult_write(hid_t fapl) static void test_attr_mult_read(hid_t fapl) { - hid_t fid1; /* HDF5 File ID */ + hid_t fid1; /* HDF5 File ID */ hid_t dataset; /* Dataset ID */ hid_t space; /* Attribute dataspace */ hid_t type; /* Attribute datatype */ - hid_t attr; /* Attribute ID */ + hid_t attr; /* Attribute ID */ char attr_name[ATTR_NAME_LEN]; /* Buffer for attribute names */ char temp_name[ATTR_NAME_LEN]; /* Buffer for mangling attribute names */ int rank; /* Attribute rank */ @@ -1185,10 +1185,10 @@ test_attr_mult_read(hid_t fapl) int read_data1[ATTR1_DIM1] = {0}; /* Buffer for reading 1st attribute */ int read_data2[ATTR2_DIM1][ATTR2_DIM2] = {{0}}; /* Buffer for reading 2nd attribute */ double read_data3[ATTR3_DIM1][ATTR3_DIM2][ATTR3_DIM3] = {{{0}}}; /* Buffer for reading 3rd attribute */ - ssize_t name_len; /* Length of attribute name */ + ssize_t name_len; /* Length of attribute name */ H5O_info_t oinfo; /* Object info */ int i, j, k; /* Local index values */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Basic Attribute Functions\n")); @@ -1432,12 +1432,12 @@ attr_op1(hid_t H5_ATTR_UNUSED loc_id, const char *name, const H5A_info_t H5_ATTR static void test_attr_iterate(hid_t fapl) { - hid_t file; /* HDF5 File ID */ + hid_t file; /* HDF5 File ID */ hid_t dataset; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ + hid_t sid; /* Dataspace ID */ int count; /* operator data for the iterator */ H5O_info_t oinfo; /* Object info */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Basic Attribute Functions\n")); @@ -1504,13 +1504,13 @@ test_attr_iterate(hid_t fapl) static void test_attr_delete(hid_t fapl) { - hid_t fid1; /* HDF5 File ID */ + hid_t fid1; /* HDF5 File ID */ hid_t dataset; /* Dataset ID */ hid_t attr; /* Attribute ID */ char attr_name[ATTR_NAME_LEN]; /* Buffer for attribute names */ ssize_t name_len; /* Length of attribute name */ H5O_info_t oinfo; /* Object info */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Basic Attribute Functions\n")); @@ -1635,7 +1635,7 @@ test_attr_dtype_shared(hid_t fapl) H5O_info_t oinfo; /* Object's information */ h5_stat_size_t empty_filesize; /* Size of empty file */ h5_stat_size_t filesize; /* Size of file after modifications */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Shared Datatypes with Attributes\n")); @@ -1802,17 +1802,17 @@ test_attr_dtype_shared(hid_t fapl) static void test_attr_duplicate_ids(hid_t fapl) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t gid1, gid2; /* Group ID */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t gid1, gid2; /* Group ID */ hid_t sid1,sid2; /* Dataspace ID */ - hid_t attr, attr2; /* Attribute ID */ - hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; - hsize_t dims2[] = {ATTR1_DIM1}; - int read_data1[ATTR1_DIM1]={0}; /* Buffer for reading 1st attribute */ - int rewrite_data[ATTR1_DIM1]={1234, -423, 9907256}; /* Test data for rewrite */ - int i; - herr_t ret; /* Generic return value */ + hid_t attr, attr2; /* Attribute ID */ + hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + hsize_t dims2[] = {ATTR1_DIM1}; + int read_data1[ATTR1_DIM1]={0}; /* Buffer for reading 1st attribute */ + int rewrite_data[ATTR1_DIM1]={1234, -423, 9907256}; /* Test data for rewrite */ + int i; + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing operations with two ID handles\n")); @@ -1830,7 +1830,7 @@ test_attr_duplicate_ids(hid_t fapl) /* Create a dataset */ dataset = H5Dcreate2(fid1, DSET1_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT); + H5P_DEFAULT, H5P_DEFAULT); CHECK(dataset, FAIL, "H5Dcreate2"); /* Create dataspace for attribute */ @@ -2047,12 +2047,12 @@ test_attr_duplicate_ids(hid_t fapl) static int test_attr_dense_verify(hid_t loc_id, unsigned max_attr) { - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ - hid_t attr; /* Attribute ID */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + hid_t attr; /* Attribute ID */ unsigned value; /* Attribute value */ unsigned u; /* Local index variable */ int old_nerrs; /* Number of errors when entering this check */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Retrieve the current # of reported errors */ old_nerrs = GetTestNumErrs(); @@ -2117,19 +2117,19 @@ test_attr_dense_verify(hid_t loc_id, unsigned max_attr) static void test_attr_dense_create(hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dataset; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ + hid_t fid; /* HDF5 File ID */ + hid_t dataset; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ hid_t attr; /* Attribute ID */ hid_t dcpl; /* Dataset creation property list ID */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ unsigned max_compact; /* Maximum # of attributes to store compactly */ unsigned min_dense; /* Minimum # of attributes to store "densely" */ - htri_t is_dense; /* Are attributes stored densely? */ + htri_t is_dense; /* Are attributes stored densely? */ unsigned u; /* Local index variable */ h5_stat_size_t empty_filesize; /* Size of empty file */ h5_stat_size_t filesize; /* Size of file after modifications */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Dense Attribute Storage Creation\n")); @@ -2248,19 +2248,19 @@ test_attr_dense_create(hid_t fcpl, hid_t fapl) static void test_attr_dense_open(hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dataset; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ + hid_t fid; /* HDF5 File ID */ + hid_t dataset; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ hid_t attr; /* Attribute ID */ hid_t dcpl; /* Dataset creation property list ID */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ unsigned max_compact; /* Maximum # of attributes to store compactly */ unsigned min_dense; /* Minimum # of attributes to store "densely" */ - htri_t is_dense; /* Are attributes stored densely? */ + htri_t is_dense; /* Are attributes stored densely? */ unsigned u; /* Local index variable */ h5_stat_size_t empty_filesize; /* Size of empty file */ h5_stat_size_t filesize; /* Size of file after modifications */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Opening Attributes in Dense Storage\n")); @@ -2387,20 +2387,20 @@ test_attr_dense_open(hid_t fcpl, hid_t fapl) static void test_attr_dense_delete(hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dataset; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + hid_t fid; /* HDF5 File ID */ + hid_t dataset; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ unsigned max_compact; /* Maximum # of attributes to store compactly */ unsigned min_dense; /* Minimum # of attributes to store "densely" */ - htri_t is_dense; /* Are attributes stored densely? */ + htri_t is_dense; /* Are attributes stored densely? */ unsigned u; /* Local index variable */ h5_stat_size_t empty_filesize; /* Size of empty file */ h5_stat_size_t filesize; /* Size of file after modifications */ H5O_info_t oinfo; /* Object info */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Deleting Attributes in Dense Storage\n")); @@ -2565,21 +2565,21 @@ test_attr_dense_delete(hid_t fcpl, hid_t fapl) static void test_attr_dense_rename(hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dataset; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ - hid_t attr; /* Attribute ID */ - hid_t dcpl; /* Dataset creation property list ID */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ - char new_attrname[NAME_BUF_SIZE]; /* New name of attribute */ + hid_t fid; /* HDF5 File ID */ + hid_t dataset; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + hid_t dcpl; /* Dataset creation property list ID */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + char new_attrname[NAME_BUF_SIZE]; /* New name of attribute */ unsigned max_compact; /* Maximum # of attributes to store compactly */ unsigned min_dense; /* Minimum # of attributes to store "densely" */ - htri_t is_dense; /* Are attributes stored densely? */ + htri_t is_dense; /* Are attributes stored densely? */ h5_stat_size_t empty_filesize; /* Size of empty file */ h5_stat_size_t filesize; /* Size of file after modifications */ H5O_info_t oinfo; /* Object info */ unsigned u; /* Local index variable */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Renaming Attributes in Dense Storage\n")); @@ -2724,21 +2724,21 @@ test_attr_dense_rename(hid_t fcpl, hid_t fapl) static void test_attr_dense_unlink(hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dataset; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ + hid_t fid; /* HDF5 File ID */ + hid_t dataset; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ hid_t attr; /* Attribute ID */ hid_t dcpl; /* Dataset creation property list ID */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ unsigned max_compact; /* Maximum # of attributes to store compactly */ unsigned min_dense; /* Minimum # of attributes to store "densely" */ - htri_t is_dense; /* Are attributes stored densely? */ + htri_t is_dense; /* Are attributes stored densely? */ size_t mesg_count; /* # of shared messages */ h5_stat_size_t empty_filesize; /* Size of empty file */ h5_stat_size_t filesize; /* Size of file after modifications */ H5O_info_t oinfo; /* Object info */ unsigned u; /* Local index variable */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Unlinking Object with Attributes in Dense Storage\n")); @@ -2856,17 +2856,17 @@ test_attr_dense_limits(hid_t fcpl, hid_t fapl) { hid_t fid; /* HDF5 File ID */ hid_t dataset; /* Dataset ID */ - hid_t sid; /* Dataspace ID */ + hid_t sid; /* Dataspace ID */ hid_t attr; /* Attribute ID */ hid_t dcpl; /* Dataset creation property list ID */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ unsigned max_compact, rmax_compact; /* Maximum # of attributes to store compactly */ unsigned min_dense, rmin_dense; /* Minimum # of attributes to store "densely" */ - htri_t is_dense; /* Are attributes stored densely? */ + htri_t is_dense; /* Are attributes stored densely? */ unsigned u; /* Local index variable */ h5_stat_size_t empty_filesize; /* Size of empty file */ h5_stat_size_t filesize; /* Size of file after modifications */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Phase Change Limits For Attributes in Dense Storage\n")); @@ -3019,13 +3019,13 @@ test_attr_dense_limits(hid_t fcpl, hid_t fapl) static void test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl) { - hid_t fid; /* HDF5 File ID */ - hid_t dataset; /* Dataset ID */ + hid_t fid; /* HDF5 File ID */ + hid_t dataset; /* Dataset ID */ hid_t gid1, gid2; /* Group ID */ - hid_t sid, sid2; /* Dataspace ID */ + hid_t sid, sid2; /* Dataspace ID */ hid_t attr, attr2, add_attr; /* Attribute ID */ hid_t dcpl; /* Dataset creation property list ID */ - char attrname[NAME_BUF_SIZE]; /* Name of attribute */ + char attrname[NAME_BUF_SIZE]; /* Name of attribute */ hsize_t dims[] = {ATTR1_DIM1}; int read_data1[ATTR1_DIM1]={0}; /* Buffer for reading attribute */ int rewrite_data[ATTR1_DIM1]={1234, -423, 9907256}; /* Test data for rewrite */ @@ -3033,9 +3033,9 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl) unsigned read_scalar; /* variable for reading attribute*/ unsigned max_compact; /* Maximum # of attributes to store compactly */ unsigned min_dense; /* Minimum # of attributes to store "densely" */ - htri_t is_dense; /* Are attributes stored densely? */ + htri_t is_dense; /* Are attributes stored densely? */ unsigned u, i; /* Local index variable */ - herr_t ret; /* Generic return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing operations with two IDs for Dense Storage\n")); -- cgit v0.12 From 9f1cd84c158a2a951a0f7680a0b08f09ac64515e Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 16 Nov 2017 11:45:36 -0600 Subject: HDFFV-10328 merge allocation changes from 1.8 --- src/H5PLint.c | 21 +- src/H5PLplugin_cache.c | 26 +- src/H5Z.c | 715 ++++++++++++++++++++++++++----------------------- 3 files changed, 422 insertions(+), 340 deletions(-) diff --git a/src/H5PLint.c b/src/H5PLint.c index c887f86..e969cbf 100644 --- a/src/H5PLint.c +++ b/src/H5PLint.c @@ -342,19 +342,38 @@ H5PL__open(const char *path, H5PL_type_t type, int id, hbool_t *success, const v /* Check if the filter IDs match */ if (info->id == id) { + H5Z_class2_t *plugin_copy = NULL; /* Store the plugin in the cache */ if (H5PL__add_plugin(type, id, handle)) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTINSERT, FAIL, "unable to add new plugin to plugin cache") + /* allocate local copy of plugin info */ + if (NULL == (plugin_copy = (H5Z_class2_t *)H5MM_calloc(sizeof(H5Z_class2_t)))) + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't allocate memory for plugin info") + /* Set the plugin info to return */ + *plugin_info = (const void *)info; + + plugin_copy->version = info->version; + plugin_copy->id = info->id; + plugin_copy->encoder_present = info->encoder_present; + plugin_copy->decoder_present = info->decoder_present; + plugin_copy->can_apply = info->can_apply; + plugin_copy->set_local = info->set_local; + plugin_copy->filter = info->filter; + /* copy the user's string into the property */ + if(NULL == (plugin_copy->name = (char *)H5MM_xstrdup(info->name))) + HGOTO_ERROR(H5E_PLUGIN, H5E_NOSPACE, FAIL, "can't allocate memory for plugin info name") + /* Set output parameters */ *success = TRUE; - *plugin_info = (const void *)info; } } done: if (!success && handle) + if (*plugin_info) { + *plugin_info = (H5Z_class2_t *)H5MM_xfree(*plugin_info); if (H5PL__close(handle) < 0) HDONE_ERROR(H5E_PLUGIN, H5E_CLOSEERROR, FAIL, "can't close dynamic library") diff --git a/src/H5PLplugin_cache.c b/src/H5PLplugin_cache.c index d826ba0..ec14159 100644 --- a/src/H5PLplugin_cache.c +++ b/src/H5PLplugin_cache.c @@ -280,18 +280,34 @@ H5PL__find_plugin_in_cache(const H5PL_search_params_t *search_params, hbool_t *f H5PL_get_plugin_info_t get_plugin_info_function; const H5Z_class2_t *filter_info; + H5Z_class2_t *plugin_copy = NULL; /* Get the "get plugin info" function from the plugin. */ if (NULL == (get_plugin_info_function = (H5PL_get_plugin_info_t)H5PL_GET_LIB_FUNC((H5PL_cache_g[u]).handle, "H5PLget_plugin_info"))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get function for H5PLget_plugin_info") + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "can't get function for H5PLget_plugin_info") /* Call the "get plugin info" function */ if (NULL == (filter_info = (const H5Z_class2_t *)(*get_plugin_info_function)())) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get plugin info") + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "can't get plugin info") + + if (NULL == (plugin_copy = (H5Z_class2_t *)H5MM_calloc(sizeof(H5Z_class2_t)))) + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't allocate memory for plugin info") + /* Set the plugin info to return */ + *plugin_info = plugin_copy; + + plugin_copy->version = filter_info->version; + plugin_copy->id = filter_info->id; + plugin_copy->encoder_present = filter_info->encoder_present; + plugin_copy->decoder_present = filter_info->decoder_present; + plugin_copy->can_apply = filter_info->can_apply; + plugin_copy->set_local = filter_info->set_local; + plugin_copy->filter = filter_info->filter; + /* copy the user's string into the property */ + if(NULL == (plugin_copy->name = (char *)H5MM_xstrdup(filter_info->name))) + HGOTO_ERROR(H5E_PLUGIN, H5E_NOSPACE, FAIL, "can't allocate memory for plugin info name") /* Set output parameters */ *found = TRUE; - *plugin_info = filter_info; /* No need to continue processing */ break; @@ -301,6 +317,10 @@ H5PL__find_plugin_in_cache(const H5PL_search_params_t *search_params, hbool_t *f } /* end for */ done: + /* unallocate local copy of plugin info on failure */ + if (FAIL == ret_value && *plugin_info) { + *plugin_info = (H5Z_class2_t *)H5MM_xfree(*plugin_info); + } FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__find_plugin_in_cache() */ #pragma GCC diagnostic pop diff --git a/src/H5Z.c b/src/H5Z.c index 1d023b5..e7574cd 100644 --- a/src/H5Z.c +++ b/src/H5Z.c @@ -34,15 +34,15 @@ #ifdef H5Z_DEBUG typedef struct H5Z_stats_t { struct { - hsize_t total; /*total number of bytes processed */ - hsize_t errors; /*bytes of total attributable to errors */ - H5_timer_t timer; /*execution time including errors */ - } stats[2]; /*0=output, 1=input */ + hsize_t total; /* total number of bytes processed */ + hsize_t errors; /* bytes of total attributable to errors */ + H5_timer_t timer; /* execution time including errors */ + } stats[2]; /* 0=output, 1=input */ } H5Z_stats_t; #endif /* H5Z_DEBUG */ typedef struct H5Z_object_t { - H5Z_filter_t filter_id; /* ID of the filter we're looking for */ + H5Z_filter_t filter_id; /* ID of the filter we're looking for */ htri_t found; /* Whether we find an object using the filter */ } H5Z_object_t; @@ -86,23 +86,23 @@ H5Z__init_package(void) FUNC_ENTER_PACKAGE /* Internal filters */ - if(H5Z_register(H5Z_SHUFFLE) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register shuffle filter") - if(H5Z_register(H5Z_FLETCHER32) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register fletcher32 filter") - if(H5Z_register(H5Z_NBIT) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register nbit filter") - if(H5Z_register(H5Z_SCALEOFFSET) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register scaleoffset filter") + if (H5Z_register (H5Z_SHUFFLE) < 0) + HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register shuffle filter") + if (H5Z_register (H5Z_FLETCHER32) < 0) + HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register fletcher32 filter") + if (H5Z_register (H5Z_NBIT) < 0) + HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register nbit filter") + if (H5Z_register (H5Z_SCALEOFFSET) < 0) + HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register scaleoffset filter") /* External filters */ #ifdef H5_HAVE_FILTER_DEFLATE - if(H5Z_register(H5Z_DEFLATE) < 0) + if (H5Z_register (H5Z_DEFLATE) < 0) HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register deflate filter") #endif /* H5_HAVE_FILTER_DEFLATE */ #ifdef H5_HAVE_FILTER_SZIP H5Z_SZIP->encoder_present = SZ_encoder_enabled(); - if(H5Z_register(H5Z_SZIP) < 0) + if (H5Z_register (H5Z_SZIP) < 0) HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register szip filter") #endif /* H5_HAVE_FILTER_SZIP */ @@ -123,6 +123,7 @@ int H5Z_term_package(void) { int n = 0; + size_t i; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -130,7 +131,6 @@ H5Z_term_package(void) #ifdef H5Z_DEBUG char comment[16], bandwidth[32]; int dir, nprint = 0; - size_t i; if(H5DEBUG(Z)) { for(i = 0; i < H5Z_table_used_g; i++) { @@ -179,6 +179,12 @@ H5Z_term_package(void) } /* end for */ } /* end if */ #endif /* H5Z_DEBUG */ + for (i = 0; i < H5Z_table_used_g; i++) { + H5Z_class2_t *cls = (H5Z_class2_t *)(H5Z_table_g+i); + /* deallocate plugin info name */ + if (cls->name) + cls->name = (char *)H5MM_xfree(cls->name); + } /* Free the table of filters */ if(H5Z_table_g) { H5Z_table_g = (H5Z_class2_t *)H5MM_xfree(H5Z_table_g); @@ -211,8 +217,8 @@ herr_t H5Zregister(const void *cls) { const H5Z_class2_t *cls_real = (const H5Z_class2_t *) cls; /* "Real" class pointer */ - H5Z_class2_t cls_new; /* Translated class struct */ - herr_t ret_value=SUCCEED; /* Return value */ + H5Z_class2_t cls_new; /* Translated class struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "*x", cls); @@ -231,7 +237,7 @@ H5Zregister(const void *cls) * at least 256, there should be no overlap and the version of the struct * can be determined by the value of the first field. */ - if(cls_real->version != H5Z_CLASS_T_VERS) { + if (cls_real->version != H5Z_CLASS_T_VERS) { #ifndef H5_NO_DEPRECATED_SYMBOLS /* Assume it is an old "H5Z_class1_t" instead */ const H5Z_class1_t *cls_old = (const H5Z_class1_t *) cls; @@ -251,19 +257,19 @@ H5Zregister(const void *cls) #else /* H5_NO_DEPRECATED_SYMBOLS */ /* Deprecated symbols not allowed, throw an error */ - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid H5Z_class_t version number"); + HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid H5Z_class_t version number"); #endif /* H5_NO_DEPRECATED_SYMBOLS */ } /* end if */ - if (cls_real->id<0 || cls_real->id>H5Z_FILTER_MAX) + if (cls_real->id < 0 || cls_real->id > H5Z_FILTER_MAX) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identification number") - if (cls_real->idid < H5Z_FILTER_RESERVED) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "unable to modify predefined filters") - if (cls_real->filter==NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no filter function specified") + if (cls_real->filter == NULL) + HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no filter function specified") /* Do it */ - if (H5Z_register (cls_real)<0) + if (H5Z_register (cls_real) < 0) HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register filter") done: @@ -277,39 +283,40 @@ done: * Purpose: Same as the public version except this one allows filters * to be set for predefined method numbers id >= 0 && cls->id <= H5Z_FILTER_MAX); + HDassert (cls); + HDassert (cls->id >= 0 && cls->id <= H5Z_FILTER_MAX); /* Is the filter already registered? */ - for(i = 0; i < H5Z_table_used_g; i++) - if(H5Z_table_g[i].id == cls->id) + for (i = 0; i < H5Z_table_used_g; i++) + if (H5Z_table_g[i].id == cls->id) break; /* Filter not already registered */ - if(i >= H5Z_table_used_g) { - if(H5Z_table_used_g >= H5Z_table_alloc_g) { - size_t n = MAX(H5Z_MAX_NFILTERS, 2*H5Z_table_alloc_g); + if (i >= H5Z_table_used_g) { + if (H5Z_table_used_g >= H5Z_table_alloc_g) { + size_t n = MAX(H5Z_MAX_NFILTERS, 2 * H5Z_table_alloc_g); H5Z_class2_t *table = (H5Z_class2_t *)H5MM_realloc(H5Z_table_g, n * sizeof(H5Z_class2_t)); #ifdef H5Z_DEBUG H5Z_stats_t *stat_table = (H5Z_stats_t *)H5MM_realloc(H5Z_stat_table_g, n * sizeof(H5Z_stats_t)); #endif /* H5Z_DEBUG */ - if(!table) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to extend filter table") + if (!table) + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to extend filter table") H5Z_table_g = table; #ifdef H5Z_DEBUG - if(!stat_table) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to extend filter statistics table") + if (!stat_table) + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to extend filter statistics table") H5Z_stat_table_g = stat_table; #endif /* H5Z_DEBUG */ H5Z_table_alloc_g = n; @@ -317,15 +324,21 @@ H5Z_register (const H5Z_class2_t *cls) /* Initialize */ i = H5Z_table_used_g++; - HDmemcpy(H5Z_table_g+i, cls, sizeof(H5Z_class2_t)); + HDmemcpy (H5Z_table_g+i, cls, sizeof(H5Z_class2_t)); + H5Z_table_g[i].name = (char *)H5MM_xstrdup(cls->name); #ifdef H5Z_DEBUG - HDmemset(H5Z_stat_table_g+i, 0, sizeof(H5Z_stats_t)); + HDmemset (H5Z_stat_table_g+i, 0, sizeof(H5Z_stats_t)); #endif /* H5Z_DEBUG */ } /* end if */ /* Filter already registered */ else { + H5Z_class2_t *old_cls = (H5Z_class2_t *)(H5Z_table_g+i); + /* deallocate plugin info name */ + if (old_cls->name) + old_cls->name = (char *)H5MM_xfree(old_cls->name); /* Replace old contents */ - HDmemcpy(H5Z_table_g+i, cls, sizeof(H5Z_class2_t)); + HDmemcpy (old_cls, cls, sizeof(H5Z_class2_t)); + old_cls->name = (char *)H5MM_xstrdup(cls->name); } /* end else */ done: @@ -338,25 +351,26 @@ done: * * Purpose: This function unregisters a filter. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success + * Negative on failure *------------------------------------------------------------------------- */ herr_t H5Zunregister(H5Z_filter_t id) { - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "Zf", id); /* Check args */ - if(id < 0 || id > H5Z_FILTER_MAX) + if (id < 0 || id > H5Z_FILTER_MAX) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identification number") - if(id < H5Z_FILTER_RESERVED) + if (id < H5Z_FILTER_RESERVED) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to modify predefined filters") /* Do it */ - if(H5Z_unregister(id) < 0) + if (H5Z_unregister(id) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to unregister filter") done: @@ -370,27 +384,29 @@ done: * Purpose: Same as the public version except this one allows filters * to be unset for predefined method numbers =0 && filter_id<=H5Z_FILTER_MAX); /* Is the filter already registered? */ - for (filter_index=0; filter_index=H5Z_table_used_g) + if (filter_index >= H5Z_table_used_g) HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, FAIL, "filter is not registered") /* Initialize the structure object for iteration */ @@ -398,28 +414,32 @@ H5Z_unregister(H5Z_filter_t filter_id) object.found = FALSE; /* Iterate through all opened datasets, returns a failure if any of them uses the filter */ - if(H5I_iterate(H5I_DATASET, H5Z__check_unregister_dset_cb, &object, FALSE) < 0) + if (H5I_iterate(H5I_DATASET, H5Z__check_unregister_dset_cb, &object, FALSE) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed") - if(object.found) + if (object.found) HGOTO_ERROR(H5E_PLINE, H5E_CANTRELEASE, FAIL, "can't unregister filter because a dataset is still using it") /* Iterate through all opened groups, returns a failure if any of them uses the filter */ - if(H5I_iterate(H5I_GROUP, H5Z__check_unregister_group_cb, &object, FALSE) < 0) + if (H5I_iterate(H5I_GROUP, H5Z__check_unregister_group_cb, &object, FALSE) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed") - if(object.found) + if (object.found) HGOTO_ERROR(H5E_PLINE, H5E_CANTRELEASE, FAIL, "can't unregister filter because a group is still using it") /* Iterate through all opened files and flush them */ - if(H5I_iterate(H5I_FILE, H5Z__flush_file_cb, NULL, FALSE) < 0) + if (H5I_iterate(H5I_FILE, H5Z__flush_file_cb, NULL, FALSE) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed") + /* deallocate plugin info name */ + old_cls = (H5Z_class2_t *)(H5Z_table_g+filter_index); + if (old_cls->name) + old_cls->name = (char *)H5MM_xfree(old_cls->name); /* Remove filter from table */ /* Don't worry about shrinking table size (for now) */ - HDmemmove(&H5Z_table_g[filter_index],&H5Z_table_g[filter_index+1],sizeof(H5Z_class2_t)*((H5Z_table_used_g-1)-filter_index)); + HDmemmove (&H5Z_table_g[filter_index], &H5Z_table_g[filter_index+1], sizeof(H5Z_class2_t)*((H5Z_table_used_g-1)-filter_index)); #ifdef H5Z_DEBUG - HDmemmove(&H5Z_stat_table_g[filter_index],&H5Z_stat_table_g[filter_index+1],sizeof(H5Z_stats_t)*((H5Z_table_used_g-1)-filter_index)); + HDmemmove (&H5Z_stat_table_g[filter_index], &H5Z_stat_table_g[filter_index+1], sizeof(H5Z_stats_t)*((H5Z_table_used_g-1)-filter_index)); #endif /* H5Z_DEBUG */ H5Z_table_used_g--; @@ -431,10 +451,10 @@ done: /*------------------------------------------------------------------------- * Function: H5Z__check_unregister * - * Purpose: Check if an object uses the filter to be unregistered. + * Purpose: Check if an object uses the filter to be unregistered. * - * Return: TRUE if the object uses the filter. - * FALSE if not, NEGATIVE on error. + * Return: TRUE if the object uses the filter. + * FALSE if not, NEGATIVE on error. *------------------------------------------------------------------------- */ static htri_t @@ -446,12 +466,12 @@ H5Z__check_unregister(hid_t ocpl_id, H5Z_filter_t filter_id) FUNC_ENTER_STATIC /* Get the plist structure of object creation */ - if(NULL == (plist = H5P_object_verify(ocpl_id, H5P_OBJECT_CREATE))) - HGOTO_ERROR(H5E_PLINE, H5E_BADATOM, FAIL, "can't find object for ID") + if (NULL == (plist = H5P_object_verify(ocpl_id, H5P_OBJECT_CREATE))) + HGOTO_ERROR (H5E_PLINE, H5E_BADATOM, FAIL, "can't find object for ID") /* Check if the object creation property list uses the filter */ - if((ret_value = H5P_filter_in_pline(plist, filter_id)) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't check filter in pipeline") + if ((ret_value = H5P_filter_in_pline(plist, filter_id)) < 0) + HGOTO_ERROR (H5E_PLINE, H5E_CANTGET, FAIL, "can't check filter in pipeline") done: FUNC_LEAVE_NOAPI(ret_value) @@ -483,25 +503,25 @@ H5Z__check_unregister_group_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, void HDassert(obj_ptr); /* Get the group creation property */ - if((ocpl_id = H5G_get_create_plist((H5G_t *)obj_ptr)) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get group creation property list") + if ((ocpl_id = H5G_get_create_plist((H5G_t *)obj_ptr)) < 0) + HGOTO_ERROR (H5E_PLINE, H5E_CANTGET, FAIL, "can't get group creation property list") /* Check if the filter is in the group creation property list */ - if((filter_in_pline = H5Z__check_unregister(ocpl_id, object->filter_id)) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't check filter in pipeline") + if ((filter_in_pline = H5Z__check_unregister(ocpl_id, object->filter_id)) < 0) + HGOTO_ERROR (H5E_PLINE, H5E_CANTGET, FAIL, "can't check filter in pipeline") /* H5I_iterate expects TRUE to stop the loop over objects. Stop the loop and * let H5Z_unregister return failure. */ - if(filter_in_pline) { + if (filter_in_pline) { object->found = TRUE; ret_value = TRUE; } /* end if */ done: - if(ocpl_id > 0) - if(H5I_dec_app_ref(ocpl_id) < 0) - HDONE_ERROR(H5E_PLINE, H5E_CANTDEC, FAIL, "can't release plist") + if (ocpl_id > 0) + if (H5I_dec_app_ref(ocpl_id) < 0) + HDONE_ERROR (H5E_PLINE, H5E_CANTDEC, FAIL, "can't release plist") FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z__check_unregister_group_cb() */ @@ -510,13 +530,13 @@ done: /*------------------------------------------------------------------------- * Function: H5Z__check_unregister_dset_cb * - * Purpose: The callback function for H5Z_unregister. It iterates - * through all opened objects. If the object is a dataset - * or a group and it uses the filter to be unregistered, the - * function returns TRUE. + * Purpose: The callback function for H5Z_unregister. It iterates + * through all opened objects. If the object is a dataset + * or a group and it uses the filter to be unregistered, the + * function returns TRUE. * - * Return: TRUE if the object uses the filter. - * FALSE otherwise. + * Return: TRUE if the object uses the filter. + * FALSE otherwise. *------------------------------------------------------------------------- */ static int @@ -529,28 +549,28 @@ H5Z__check_unregister_dset_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, void * FUNC_ENTER_STATIC - HDassert(obj_ptr); + HDassert (obj_ptr); /* Get the dataset creation property */ - if((ocpl_id = H5D_get_create_plist((H5D_t *)obj_ptr)) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get dataset creation property list") + if ((ocpl_id = H5D_get_create_plist((H5D_t *)obj_ptr)) < 0) + HGOTO_ERROR (H5E_PLINE, H5E_CANTGET, FAIL, "can't get dataset creation property list") /* Check if the filter is in the dataset creation property list */ - if((filter_in_pline = H5Z__check_unregister(ocpl_id, object->filter_id)) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't check filter in pipeline") + if ((filter_in_pline = H5Z__check_unregister(ocpl_id, object->filter_id)) < 0) + HGOTO_ERROR (H5E_PLINE, H5E_CANTGET, FAIL, "can't check filter in pipeline") /* H5I_iterate expects TRUE to stop the loop over objects. Stop the loop and * let H5Z_unregister return failure. */ - if(filter_in_pline) { + if (filter_in_pline) { object->found = TRUE; ret_value = TRUE; } /* end if */ done: - if(ocpl_id > 0) - if(H5I_dec_app_ref(ocpl_id) < 0) - HDONE_ERROR(H5E_PLINE, H5E_CANTDEC, FAIL, "can't release plist") + if (ocpl_id > 0) + if (H5I_dec_app_ref(ocpl_id) < 0) + HDONE_ERROR (H5E_PLINE, H5E_CANTDEC, FAIL, "can't release plist") FUNC_LEAVE_NOAPI(ret_value) } /* end H5Z__check_unregister_dset_cb() */ @@ -569,17 +589,17 @@ done: static int H5Z__flush_file_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, void H5_ATTR_UNUSED *key) { - int ret_value = FALSE; /* Return value */ + int ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC - HDassert(obj_ptr); + HDassert (obj_ptr); /* Call the flush routine for mounted file hierarchies. Do a global flush * if the file is opened for write */ - if(H5F_ACC_RDWR & H5F_INTENT((H5F_t *)obj_ptr)) { - if(H5F_flush_mounts((H5F_t *)obj_ptr, H5AC_ind_read_dxpl_id, H5AC_rawdata_dxpl_id) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTFLUSH, FAIL, "unable to flush file hierarchy") + if (H5F_ACC_RDWR & H5F_INTENT((H5F_t *)obj_ptr)) { + if (H5F_flush_mounts((H5F_t *)obj_ptr, H5AC_ind_read_dxpl_id, H5AC_rawdata_dxpl_id) < 0) + HGOTO_ERROR (H5E_PLINE, H5E_CANTFLUSH, FAIL, "unable to flush file hierarchy") } /* end if */ done: @@ -598,17 +618,17 @@ done: htri_t H5Zfilter_avail(H5Z_filter_t id) { - htri_t ret_value=FALSE; /* Return value */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("t", "Zf", id); /* Check args */ - if(id<0 || id>H5Z_FILTER_MAX) + if (id < 0 || id > H5Z_FILTER_MAX) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identification number") - if((ret_value = H5Z_filter_avail(id)) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, FAIL, "unable to check the availability of the filter") + if ((ret_value = H5Z_filter_avail(id)) < 0) + HGOTO_ERROR (H5E_PLINE, H5E_NOTFOUND, FAIL, "unable to check the availability of the filter") done: FUNC_LEAVE_API(ret_value) @@ -626,21 +646,25 @@ done: htri_t H5Z_filter_avail(H5Z_filter_t id) { - size_t i; /* Local index variable */ - const H5Z_class2_t *filter_info; - htri_t ret_value = FALSE; /* Return value */ + size_t i; /* Local index variable */ + H5Z_class2_t *filter_info; + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Is the filter already registered? */ - for(i = 0; i < H5Z_table_used_g; i++) - if(H5Z_table_g[i].id == id) - HGOTO_DONE(TRUE) - - if(NULL != (filter_info = (const H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, (int)id))) { - if(H5Z_register(filter_info) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register loaded filter") - HGOTO_DONE(TRUE) + for (i = 0; i < H5Z_table_used_g; i++) + if (H5Z_table_g[i].id == id) + HGOTO_DONE (TRUE) + + if (NULL != (filter_info = (const H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, (int)id))) { + herr_t status = H5Z_register(filter_info); + if (filter_info->name) + filter_info->name = (char *)H5MM_xfree(filter_info->name); + filter_info = (H5Z_class2_t *)H5MM_xfree(filter_info); + if (status < 0) + HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register loaded filter") + HGOTO_DONE (TRUE) } done: FUNC_LEAVE_NOAPI(ret_value) @@ -666,59 +690,59 @@ H5Z_prelude_callback(const H5O_pline_t *pline, hid_t dcpl_id, hid_t type_id, { H5Z_class2_t *fclass; /* Individual filter information */ size_t u; /* Local index variable */ - htri_t ret_value = TRUE; /* Return value */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT HDassert(pline->nused > 0); /* Iterate over filters */ - for(u = 0; u < pline->nused; u++) { + for (u = 0; u < pline->nused; u++) { /* Get filter information */ - if(NULL == (fclass = H5Z_find(pline->filter[u].id))) { + if (NULL == (fclass = H5Z_find(pline->filter[u].id))) { /* Ignore errors from optional filters */ - if(pline->filter[u].flags & H5Z_FLAG_OPTIONAL) - H5E_clear_stack(NULL); + if (pline->filter[u].flags & H5Z_FLAG_OPTIONAL) + H5E_clear_stack (NULL); else - HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, FAIL, "required filter was not located") + HGOTO_ERROR (H5E_PLINE, H5E_NOTFOUND, FAIL, "required filter was not located") } /* end if */ else { /* Make correct callback */ - switch(prelude_type) { + switch (prelude_type) { case H5Z_PRELUDE_CAN_APPLY: /* Check if filter is configured to be able to encode */ - if(!fclass->encoder_present) - HGOTO_ERROR(H5E_PLINE, H5E_NOENCODER, FAIL, "Filter present but encoding is disabled."); + if (!fclass->encoder_present) + HGOTO_ERROR (H5E_PLINE, H5E_NOENCODER, FAIL, "Filter present but encoding is disabled."); /* Check if there is a "can apply" callback */ - if(fclass->can_apply) { + if (fclass->can_apply) { /* Make callback to filter's "can apply" function */ htri_t status = (fclass->can_apply)(dcpl_id, type_id, space_id); /* Indicate error during filter callback */ - if(status < 0) + if (status < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANAPPLY, FAIL, "error during user callback") /* Indicate filter can't apply to this combination of parameters. * If the filter is NOT optional, returns failure. */ - if(status == FALSE && !(pline->filter[u].flags & H5Z_FLAG_OPTIONAL)) + if (status == FALSE && !(pline->filter[u].flags & H5Z_FLAG_OPTIONAL)) HGOTO_ERROR(H5E_PLINE, H5E_CANAPPLY, FAIL, "filter parameters not appropriate") } /* end if */ break; case H5Z_PRELUDE_SET_LOCAL: /* Check if there is a "set local" callback */ - if(fclass->set_local) { + if (fclass->set_local) { /* Make callback to filter's "set local" function */ - if((fclass->set_local)(dcpl_id, type_id, space_id) < 0) + if ((fclass->set_local)(dcpl_id, type_id, space_id) < 0) /* Indicate error during filter callback */ - HGOTO_ERROR(H5E_PLINE, H5E_SETLOCAL, FAIL, "error during user callback") + HGOTO_ERROR (H5E_PLINE, H5E_SETLOCAL, FAIL, "error during user callback") } /* end if */ break; default: - HDassert("invalid prelude type" && 0); + HDassert ("invalid prelude type" && 0); } /* end switch */ } /* end else */ } /* end for */ @@ -745,62 +769,62 @@ done: static herr_t H5Z_prepare_prelude_callback_dcpl(hid_t dcpl_id, hid_t type_id, H5Z_prelude_type_t prelude_type) { - hid_t space_id = -1; /* ID for dataspace describing chunk */ - herr_t ret_value = SUCCEED; /* Return value */ + hid_t space_id = -1; /* ID for dataspace describing chunk */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT - HDassert(H5I_GENPROP_LST == H5I_get_type(dcpl_id)); - HDassert(H5I_DATATYPE == H5I_get_type(type_id)); + HDassert (H5I_GENPROP_LST == H5I_get_type(dcpl_id)); + HDassert (H5I_DATATYPE == H5I_get_type(type_id)); /* Check if the property list is non-default */ - if(dcpl_id != H5P_DATASET_CREATE_DEFAULT) { - H5P_genplist_t *dc_plist; /* Dataset creation property list object */ - H5O_layout_t dcpl_layout; /* Dataset's layout information */ + if (dcpl_id != H5P_DATASET_CREATE_DEFAULT) { + H5P_genplist_t *dc_plist; /* Dataset creation property list object */ + H5O_layout_t dcpl_layout; /* Dataset's layout information */ /* Get dataset creation property list object */ - if(NULL == (dc_plist = (H5P_genplist_t *)H5I_object(dcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get dataset creation property list") + if (NULL == (dc_plist = (H5P_genplist_t *)H5I_object(dcpl_id))) + HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "can't get dataset creation property list") /* Peek at the layout information */ - if(H5P_peek(dc_plist, H5D_CRT_LAYOUT_NAME, &dcpl_layout) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve layout") + if (H5P_peek(dc_plist, H5D_CRT_LAYOUT_NAME, &dcpl_layout) < 0) + HGOTO_ERROR (H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve layout") /* Check if the dataset is chunked */ - if(H5D_CHUNKED == dcpl_layout.type) { + if (H5D_CHUNKED == dcpl_layout.type) { H5O_pline_t dcpl_pline; /* Object's I/O pipeline information */ /* Get I/O pipeline information */ - if(H5P_peek(dc_plist, H5O_CRT_PIPELINE_NAME, &dcpl_pline) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve pipeline filter") + if (H5P_peek(dc_plist, H5O_CRT_PIPELINE_NAME, &dcpl_pline) < 0) + HGOTO_ERROR (H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve pipeline filter") /* Check if the chunks have filters */ - if(dcpl_pline.nused > 0) { + if (dcpl_pline.nused > 0) { hsize_t chunk_dims[H5O_LAYOUT_NDIMS]; /* Size of chunk dimensions */ - H5S_t *space; /* Dataspace describing chunk */ - size_t u; /* Local index variable */ + H5S_t *space; /* Dataspace describing chunk */ + size_t u; /* Local index variable */ - /* Create a data space for a chunk & set the extent */ - for(u = 0; u < dcpl_layout.u.chunk.ndims; u++) + /* Create a dataspace for a chunk & set the extent */ + for (u = 0; u < dcpl_layout.u.chunk.ndims; u++) chunk_dims[u] = dcpl_layout.u.chunk.dim[u]; - if(NULL == (space = H5S_create_simple(dcpl_layout.u.chunk.ndims, chunk_dims, NULL))) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create simple dataspace") + if (NULL == (space = H5S_create_simple(dcpl_layout.u.chunk.ndims, chunk_dims, NULL))) + HGOTO_ERROR (H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create simple dataspace") /* Get ID for dataspace to pass to filter routines */ - if((space_id = H5I_register(H5I_DATASPACE, space, FALSE)) < 0) { - (void)H5S_close(space); - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace ID") + if ((space_id = H5I_register(H5I_DATASPACE, space, FALSE)) < 0) { + (void)H5S_close (space); + HGOTO_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace ID") } /* end if */ /* Make the callbacks */ - if(H5Z_prelude_callback(&dcpl_pline, dcpl_id, type_id, space_id, prelude_type) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_CANAPPLY, FAIL, "unable to apply filter") + if (H5Z_prelude_callback(&dcpl_pline, dcpl_id, type_id, space_id, prelude_type) < 0) + HGOTO_ERROR (H5E_PLINE, H5E_CANAPPLY, FAIL, "unable to apply filter") } /* end if */ } /* end if */ } /* end if */ done: - if(space_id > 0 && H5I_dec_ref(space_id) < 0) + if (space_id > 0 && H5I_dec_ref(space_id) < 0) HDONE_ERROR(H5E_PLINE, H5E_CANTRELEASE, FAIL, "unable to close dataspace") FUNC_LEAVE_NOAPI(ret_value) @@ -814,7 +838,8 @@ done: * property list can be applied to a particular combination of * datatype and dataspace for a dataset. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success + * Negative on failure * * Notes: The chunk dimensions are used to create a dataspace, instead * of passing in the dataset's dataspace, since the chunk @@ -829,8 +854,8 @@ H5Z_can_apply(hid_t dcpl_id, hid_t type_id) FUNC_ENTER_NOAPI(FAIL) /* Make "can apply" callbacks for filters in pipeline */ - if(H5Z_prepare_prelude_callback_dcpl(dcpl_id, type_id, H5Z_PRELUDE_CAN_APPLY) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_CANAPPLY, FAIL, "unable to apply filter") + if (H5Z_prepare_prelude_callback_dcpl(dcpl_id, type_id, H5Z_PRELUDE_CAN_APPLY) < 0) + HGOTO_ERROR (H5E_PLINE, H5E_CANAPPLY, FAIL, "unable to apply filter") done: FUNC_LEAVE_NOAPI(ret_value) @@ -844,7 +869,8 @@ done: * settings for filters on a new dataset, based on the datatype * and dataspace of that dataset (chunk). * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success + * Negative on failure * * Notes: The chunk dimensions are used to create a dataspace, instead * of passing in the dataset's dataspace, since the chunk @@ -859,8 +885,8 @@ H5Z_set_local(hid_t dcpl_id, hid_t type_id) FUNC_ENTER_NOAPI(FAIL) /* Make "set local" callbacks for filters in pipeline */ - if(H5Z_prepare_prelude_callback_dcpl(dcpl_id, type_id, H5Z_PRELUDE_SET_LOCAL) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_SETLOCAL, FAIL, "local filter parameters not set") + if (H5Z_prepare_prelude_callback_dcpl(dcpl_id, type_id, H5Z_PRELUDE_SET_LOCAL) < 0) + HGOTO_ERROR (H5E_PLINE, H5E_SETLOCAL, FAIL, "local filter parameters not set") done: FUNC_LEAVE_NOAPI(ret_value) @@ -874,7 +900,8 @@ done: * applied to an opaque byte stream (currently only a group). * The pipeline is assumed to have at least one filter. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success + * Negative on failure *------------------------------------------------------------------------- */ herr_t @@ -884,11 +911,11 @@ H5Z_can_apply_direct(const H5O_pline_t *pline) FUNC_ENTER_NOAPI(FAIL) - HDassert(pline->nused > 0); + HDassert (pline->nused > 0); /* Make "can apply" callbacks for filters in pipeline */ - if(H5Z_prelude_callback(pline, (hid_t)-1, (hid_t)-1, (hid_t)-1, H5Z_PRELUDE_CAN_APPLY) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_CANAPPLY, FAIL, "unable to apply filter") + if (H5Z_prelude_callback(pline, (hid_t)-1, (hid_t)-1, (hid_t)-1, H5Z_PRELUDE_CAN_APPLY) < 0) + HGOTO_ERROR (H5E_PLINE, H5E_CANAPPLY, FAIL, "unable to apply filter") done: FUNC_LEAVE_NOAPI(ret_value) @@ -902,7 +929,8 @@ done: * new opaque object. The pipeline is assumed to have at * least one filter. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success + * Negative on failure * * Notes: This callback will almost certainly not do anything * useful, other than to make certain that the filter will @@ -916,11 +944,11 @@ H5Z_set_local_direct(const H5O_pline_t *pline) FUNC_ENTER_NOAPI(FAIL) - HDassert(pline->nused > 0); + HDassert (pline->nused > 0); /* Make "set local" callbacks for filters in pipeline */ - if(H5Z_prelude_callback(pline, (hid_t)-1, (hid_t)-1, (hid_t)-1, H5Z_PRELUDE_SET_LOCAL) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_SETLOCAL, FAIL, "local filter parameters not set") + if (H5Z_prelude_callback(pline, (hid_t)-1, (hid_t)-1, (hid_t)-1, H5Z_PRELUDE_SET_LOCAL) < 0) + HGOTO_ERROR (H5E_PLINE, H5E_SETLOCAL, FAIL, "local filter parameters not set") done: FUNC_LEAVE_NOAPI(ret_value) @@ -930,58 +958,59 @@ done: /*------------------------------------------------------------------------- * Function: H5Z_modify * - * Purpose: Modify filter parameters for specified pipeline. + * Purpose: Modify filter parameters for specified pipeline. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success + * Negative on failure *------------------------------------------------------------------------- */ herr_t H5Z_modify(const H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, size_t cd_nelmts, const unsigned int cd_values[/*cd_nelmts*/]) { - size_t idx; /* Index of filter in pipeline */ - herr_t ret_value = SUCCEED; /* Return value */ + size_t idx; /* Index of filter in pipeline */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - HDassert(pline); - HDassert(filter >= 0 && filter <= H5Z_FILTER_MAX); - HDassert(0 == (flags & ~((unsigned)H5Z_FLAG_DEFMASK))); - HDassert(0 == cd_nelmts || cd_values); + HDassert (pline); + HDassert (filter >= 0 && filter <= H5Z_FILTER_MAX); + HDassert (0 == (flags & ~((unsigned)H5Z_FLAG_DEFMASK))); + HDassert (0 == cd_nelmts || cd_values); /* Locate the filter in the pipeline */ - for(idx = 0; idx < pline->nused; idx++) - if(pline->filter[idx].id == filter) + for (idx = 0; idx < pline->nused; idx++) + if (pline->filter[idx].id == filter) break; /* Check if the filter was not already in the pipeline */ - if(idx > pline->nused) - HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, FAIL, "filter not in pipeline") + if (idx > pline->nused) + HGOTO_ERROR (H5E_PLINE, H5E_NOTFOUND, FAIL, "filter not in pipeline") /* Change parameters for filter */ pline->filter[idx].flags = flags; pline->filter[idx].cd_nelmts = cd_nelmts; /* Free any existing parameters */ - if(pline->filter[idx].cd_values != NULL && pline->filter[idx].cd_values != pline->filter[idx]._cd_values) + if (pline->filter[idx].cd_values != NULL && pline->filter[idx].cd_values != pline->filter[idx]._cd_values) H5MM_xfree(pline->filter[idx].cd_values); /* Set parameters */ - if(cd_nelmts > 0) { - size_t i; /* Local index variable */ + if (cd_nelmts > 0) { + size_t i; /* Local index variable */ /* Allocate memory or point at internal buffer */ - if(cd_nelmts > H5Z_COMMON_CD_VALUES) { + if (cd_nelmts > H5Z_COMMON_CD_VALUES) { pline->filter[idx].cd_values = (unsigned *)H5MM_malloc(cd_nelmts * sizeof(unsigned)); - if(NULL == pline->filter[idx].cd_values) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for filter parameters") + if (NULL == pline->filter[idx].cd_values) + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for filter parameters") } /* end if */ else pline->filter[idx].cd_values = pline->filter[idx]._cd_values; /* Copy client data values */ - for(i = 0; i < cd_nelmts; i++) - pline->filter[idx].cd_values[i] = cd_values[i]; + for (i = 0; i < cd_nelmts; i++) + pline->filter[idx].cd_values[i] = cd_values[i]; } /* end if */ else pline->filter[idx].cd_values = NULL; @@ -996,36 +1025,37 @@ done: * * Purpose: Append another filter to the specified pipeline. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success + * Negative on failure *------------------------------------------------------------------------- */ herr_t H5Z_append(H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, size_t cd_nelmts, const unsigned int cd_values[/*cd_nelmts*/]) { - size_t idx; - herr_t ret_value = SUCCEED; /* Return value */ + size_t idx; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - HDassert(pline); - HDassert(filter >= 0 && filter <= H5Z_FILTER_MAX); - HDassert(0 == (flags & ~((unsigned)H5Z_FLAG_DEFMASK))); - HDassert(0 == cd_nelmts || cd_values); + HDassert (pline); + HDassert (filter >= 0 && filter <= H5Z_FILTER_MAX); + HDassert (0 == (flags & ~((unsigned)H5Z_FLAG_DEFMASK))); + HDassert (0 == cd_nelmts || cd_values); /* * Check filter limit. We do it here for early warnings although we may * decide to relax this restriction in the future. */ - if(pline->nused >= H5Z_MAX_NFILTERS) - HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "too many filters in pipeline") + if (pline->nused >= H5Z_MAX_NFILTERS) + HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "too many filters in pipeline") /* Check for freshly allocated filter pipeline */ - if(pline->version == 0) + if (pline->version == 0) pline->version = H5O_PLINE_VERSION_1; /* Allocate additional space in the pipeline if it's full */ - if(pline->nused >= pline->nalloc) { + if (pline->nused >= pline->nalloc) { H5O_pline_t x; size_t n; @@ -1036,14 +1066,14 @@ H5Z_append(H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, * filter struct is reallocated. Set these pointers to ~NULL * so that we can reset them after reallocating the filters array. */ - for(n = 0; n < pline->nalloc; ++n) - if(pline->filter[n].cd_values == pline->filter[n]._cd_values) + for (n = 0; n < pline->nalloc; ++n) + if (pline->filter[n].cd_values == pline->filter[n]._cd_values) pline->filter[n].cd_values = (unsigned *)((void *) ~((size_t)NULL)); x.nalloc = MAX(H5Z_MAX_NFILTERS, 2 * pline->nalloc); x.filter = (H5Z_filter_info_t *)H5MM_realloc(pline->filter, x.nalloc * sizeof(x.filter[0])); - if(NULL == x.filter) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for filter pipeline") + if (NULL == x.filter) + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for filter pipeline") /* Fix pointers in previous filters that need to point to their own * internal data. @@ -1061,22 +1091,22 @@ H5Z_append(H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags, idx = pline->nused; pline->filter[idx].id = filter; pline->filter[idx].flags = flags; - pline->filter[idx].name = NULL; /* we'll pick it up later*/ + pline->filter[idx].name = NULL; /*we'll pick it up later*/ pline->filter[idx].cd_nelmts = cd_nelmts; - if(cd_nelmts > 0) { - size_t i; /* Local index variable */ + if (cd_nelmts > 0) { + size_t i; /* Local index variable */ /* Allocate memory or point at internal buffer */ - if(cd_nelmts > H5Z_COMMON_CD_VALUES) { + if (cd_nelmts > H5Z_COMMON_CD_VALUES) { pline->filter[idx].cd_values = (unsigned *)H5MM_malloc(cd_nelmts * sizeof(unsigned)); - if(NULL == pline->filter[idx].cd_values) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for filter") + if (NULL == pline->filter[idx].cd_values) + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for filter") } /* end if */ else pline->filter[idx].cd_values = pline->filter[idx]._cd_values; /* Copy client data values */ - for(i = 0; i < cd_nelmts; i++) + for (i = 0; i < cd_nelmts; i++) pline->filter[idx].cd_values[i] = cd_values[i]; } /* end if */ else @@ -1095,8 +1125,8 @@ done: * Purpose: Given a filter ID return the offset in the global array * that holds all the registered filters. * - * Return: Success: Non-negative index of entry in global filter table. - * Failure: Negative + * Return: Success: Non-negative index of entry in global filter table. + * Failure: Negative *------------------------------------------------------------------------- */ static int @@ -1107,9 +1137,9 @@ H5Z_find_idx(H5Z_filter_t id) FUNC_ENTER_NOAPI_NOINIT_NOERR - for (i=0; ifilter[].flags). The filters are processed in - * definition order unless the H5Z_FLAG_REVERSE is set. The - * FILTER_MASK is a bit-mask to indicate which filters to skip - * and on exit will indicate which filters failed. Each - * filter has an index number in the pipeline and that index - * number is the filter's bit in the FILTER_MASK. NBYTES is the - * number of bytes of data to filter and on exit should be the - * number of resulting bytes while BUF_SIZE holds the total - * allocated size of the buffer, which is pointed to BUF. - * - * If the buffer must grow during processing of the pipeline - * then the pipeline function should free the original buffer - * and return a fresh buffer, adjusting BUF_SIZE accordingly. - * - * Return: Non-negative on success/Negative on failure + * Purpose: Process data through the filter pipeline. The FLAGS argument + * is the filter invocation flags (definition flags come from + * the PLINE->filter[].flags). The filters are processed in + * definition order unless the H5Z_FLAG_REVERSE is set. The + * FILTER_MASK is a bit-mask to indicate which filters to skip + * and on exit will indicate which filters failed. Each + * filter has an index number in the pipeline and that index + * number is the filter's bit in the FILTER_MASK. NBYTES is the + * number of bytes of data to filter and on exit should be the + * number of resulting bytes while BUF_SIZE holds the total + * allocated size of the buffer, which is pointed to BUF. + * + * If the buffer must grow during processing of the pipeline + * then the pipeline function should free the original buffer + * and return a fresh buffer, adjusting BUF_SIZE accordingly. + * + * Return: Non-negative on success + * Negative on failure *------------------------------------------------------------------------- */ herr_t @@ -1174,51 +1205,55 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, H5Z_cb_t cb_struct, size_t *nbytes/*in,out*/, size_t *buf_size/*in,out*/, void **buf/*in,out*/) { - size_t i, idx, new_nbytes; - int fclass_idx; /* Index of filter class in global table */ - H5Z_class2_t *fclass = NULL; /* Filter class pointer */ + size_t i, idx, new_nbytes; + int fclass_idx; /* Index of filter class in global table */ + H5Z_class2_t *fclass=NULL; /* Filter class pointer */ #ifdef H5Z_DEBUG - H5Z_stats_t *fstats = NULL; /* Filter stats pointer */ + H5Z_stats_t *fstats=NULL; /* Filter stats pointer */ H5_timer_t timer; #endif - unsigned failed = 0; - unsigned tmp_flags; - herr_t ret_value = SUCCEED; /* Return value */ + unsigned failed = 0; + unsigned tmp_flags; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - HDassert(0 == (flags & ~((unsigned)H5Z_FLAG_INVMASK))); - HDassert(filter_mask); - HDassert(nbytes && *nbytes > 0); - HDassert(buf_size && *buf_size > 0); - HDassert(buf && *buf); - HDassert(!pline || pline->nused < H5Z_MAX_NFILTERS); + HDassert (0 == (flags & ~((unsigned)H5Z_FLAG_INVMASK))); + HDassert (filter_mask); + HDassert (nbytes && *nbytes>0); + HDassert (buf_size && *buf_size>0); + HDassert (buf && *buf); + HDassert (!pline || pline->nusednused; i > 0; --i) { - idx = i - 1; + idx = i-1; if (*filter_mask & ((unsigned)1 << idx)) { failed |= (unsigned)1 << idx; - continue;/*filter excluded*/ + continue; /* filter excluded */ } /* If the filter isn't registered and the application doesn't - * indicate no plugin through HDF5_PRELOAD_PLUG (using the symbol "::"), - * try to load it dynamically and register it. Otherwise, return failure - */ - if((fclass_idx = H5Z_find_idx(pline->filter[idx].id)) < 0) { + * indicate no plugin through HDF5_PRELOAD_PLUG (using the symbol "::"), + * try to load it dynamically and register it. Otherwise, return failure + */ + if ((fclass_idx = H5Z_find_idx(pline->filter[idx].id)) < 0) { hbool_t issue_error = FALSE; - const H5Z_class2_t *filter_info; + H5Z_class2_t *filter_info; /* Try loading the filter */ - if(NULL != (filter_info = (const H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, (int)(pline->filter[idx].id)))) { + if (NULL != (filter_info = (const H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, (int)(pline->filter[idx].id)))) { /* Register the filter we loaded */ - if(H5Z_register(filter_info) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register filter") + herr_t status = H5Z_register(filter_info); + if (filter_info->name) + filter_info->name = (char *)H5MM_xfree(filter_info->name); + filter_info = (H5Z_class2_t *)H5MM_xfree(filter_info); + if (status < 0) + HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register filter") /* Search in the table of registered filters again to find the dynamic filter just loaded and registered */ - if((fclass_idx = H5Z_find_idx(pline->filter[idx].id)) < 0) + if ((fclass_idx = H5Z_find_idx(pline->filter[idx].id)) < 0) issue_error = TRUE; } /* end if */ else @@ -1227,8 +1262,8 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, /* Check for error */ if(issue_error) { /* Print out the filter name to give more info. But the name is optional for - * the filter */ - if(pline->filter[idx].name) + * the filter */ + if (pline->filter[idx].name) HGOTO_ERROR(H5E_PLINE, H5E_READERROR, FAIL, "required filter '%s' is not registered", pline->filter[idx].name) else HGOTO_ERROR(H5E_PLINE, H5E_READERROR, FAIL, "required filter (name unavailable) is not registered") @@ -1238,26 +1273,26 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, fclass = &H5Z_table_g[fclass_idx]; #ifdef H5Z_DEBUG fstats = &H5Z_stat_table_g[fclass_idx]; - H5_timer_begin(&timer); + H5_timer_begin (&timer); #endif - tmp_flags = flags|(pline->filter[idx].flags); + tmp_flags = flags | (pline->filter[idx].flags); tmp_flags |= (edc_read== H5Z_DISABLE_EDC) ? H5Z_FLAG_SKIP_EDC : 0; new_nbytes = (fclass->filter)(tmp_flags, pline->filter[idx].cd_nelmts, - pline->filter[idx].cd_values, *nbytes, buf_size, buf); + pline->filter[idx].cd_values, *nbytes, buf_size, buf); #ifdef H5Z_DEBUG - H5_timer_end(&(fstats->stats[1].timer), &timer); + H5_timer_end (&(fstats->stats[1].timer), &timer); fstats->stats[1].total += MAX(*nbytes, new_nbytes); if (0 == new_nbytes) fstats->stats[1].errors += *nbytes; #endif - if(0==new_nbytes) { - if((cb_struct.func && (H5Z_CB_FAIL == cb_struct.func(pline->filter[idx].id, *buf, *buf_size, cb_struct.op_data))) || !cb_struct.func) - HGOTO_ERROR(H5E_PLINE, H5E_READERROR, FAIL, "filter returned failure during read") + if (0 == new_nbytes) { + if ((cb_struct.func && (H5Z_CB_FAIL == cb_struct.func (pline->filter[idx].id, *buf, *buf_size, cb_struct.op_data))) || !cb_struct.func) + HGOTO_ERROR (H5E_PLINE, H5E_READERROR, FAIL, "filter returned failure during read") *nbytes = *buf_size; failed |= (unsigned)1 << idx; - H5E_clear_stack(NULL); + H5E_clear_stack (NULL); } else { *nbytes = new_nbytes; @@ -1276,35 +1311,34 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, HGOTO_ERROR(H5E_PLINE, H5E_WRITEERROR, FAIL, "required filter is not registered") failed |= (unsigned)1 << idx; - H5E_clear_stack(NULL); + H5E_clear_stack (NULL); continue; /*filter excluded*/ } fclass = &H5Z_table_g[fclass_idx]; #ifdef H5Z_DEBUG fstats = &H5Z_stat_table_g[fclass_idx]; - H5_timer_begin(&timer); + H5_timer_begin (&timer); #endif - new_nbytes = (fclass->filter)(flags|(pline->filter[idx].flags), pline->filter[idx].cd_nelmts, - pline->filter[idx].cd_values, *nbytes, buf_size, buf); + new_nbytes = (fclass->filter)(flags | (pline->filter[idx].flags), pline->filter[idx].cd_nelmts, + pline->filter[idx].cd_values, *nbytes, buf_size, buf); #ifdef H5Z_DEBUG - H5_timer_end(&(fstats->stats[0].timer), &timer); + H5_timer_end (&(fstats->stats[0].timer), &timer); fstats->stats[0].total += MAX(*nbytes, new_nbytes); if (0 == new_nbytes) fstats->stats[0].errors += *nbytes; #endif - if(0 == new_nbytes) { + if (0 == new_nbytes) { if (0 == (pline->filter[idx].flags & H5Z_FLAG_OPTIONAL)) { - if((cb_struct.func && (H5Z_CB_FAIL == cb_struct.func(pline->filter[idx].id, *buf, *nbytes, cb_struct.op_data))) || !cb_struct.func) - HGOTO_ERROR(H5E_PLINE, H5E_WRITEERROR, FAIL, "filter returned failure") + if ((cb_struct.func && (H5Z_CB_FAIL == cb_struct.func (pline->filter[idx].id, *buf, *nbytes, cb_struct.op_data))) || !cb_struct.func) + HGOTO_ERROR (H5E_PLINE, H5E_WRITEERROR, FAIL, "filter returned failure") *nbytes = *buf_size; } failed |= (unsigned)1 << idx; - H5E_clear_stack(NULL); + H5E_clear_stack (NULL); } - else { + else *nbytes = new_nbytes; - } } } @@ -1320,7 +1354,8 @@ done: * * Purpose: Get pointer to filter info for pipeline * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success + * Negative on failure *------------------------------------------------------------------------- */ H5Z_filter_info_t * @@ -1331,17 +1366,17 @@ H5Z_filter_info(const H5O_pline_t *pline, H5Z_filter_t filter) FUNC_ENTER_NOAPI(NULL) - HDassert(pline); - HDassert(filter >= 0 && filter <= H5Z_FILTER_MAX); + HDassert (pline); + HDassert (filter >= 0 && filter <= H5Z_FILTER_MAX); /* Locate the filter in the pipeline */ - for(idx = 0; idx < pline->nused; idx++) - if(pline->filter[idx].id == filter) + for (idx = 0; idx < pline->nused; idx++) + if (pline->filter[idx].id == filter) break; /* Check if the filter was not already in the pipeline */ - if(idx >= pline->nused) - HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, NULL, "filter not in pipeline") + if (idx >= pline->nused) + HGOTO_ERROR (H5E_PLINE, H5E_NOTFOUND, NULL, "filter not in pipeline") /* Set return value */ ret_value = &pline->filter[idx]; @@ -1365,21 +1400,21 @@ done: htri_t H5Z_filter_in_pline(const H5O_pline_t *pline, H5Z_filter_t filter) { - size_t idx; /* Index of filter in pipeline */ - htri_t ret_value = TRUE; /* Return value */ + size_t idx; /* Index of filter in pipeline */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - HDassert(pline); - HDassert(filter >= 0 && filter <= H5Z_FILTER_MAX); + HDassert (pline); + HDassert (filter >= 0 && filter <= H5Z_FILTER_MAX); /* Locate the filter in the pipeline */ - for(idx = 0; idx < pline->nused; idx++) - if(pline->filter[idx].id == filter) + for (idx = 0; idx < pline->nused; idx++) + if (pline->filter[idx].id == filter) break; /* Check if the filter was not already in the pipeline */ - if(idx >= pline->nused) + if (idx >= pline->nused) ret_value = FALSE; done: @@ -1394,30 +1429,31 @@ done: * Purpose: Verify that all the filters in a pipeline are currently * available (i.e. registered) * - * Return: Non-negative (TRUE/FALSE) on success/Negative on failure + * Return: Non-negative (TRUE/FALSE) on success + * Negative on failure *------------------------------------------------------------------------- */ htri_t H5Z_all_filters_avail(const H5O_pline_t *pline) { - size_t i,j; /* Local index variable */ - htri_t ret_value=TRUE; /* Return value */ + size_t i, j; /* Local index variable */ + htri_t ret_value = TRUE; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Check args */ - HDassert(pline); + HDassert (pline); /* Iterate through all the filters in pipeline */ - for(i = 0; i < pline->nused; i++) { + for (i = 0; i < pline->nused; i++) { /* Look for each filter in the list of registered filters */ - for(j = 0; j < H5Z_table_used_g; j++) - if(H5Z_table_g[j].id == pline->filter[i].id) + for (j = 0; j < H5Z_table_used_g; j++) + if (H5Z_table_g[j].id == pline->filter[i].id) break; /* Check if we didn't find the filter */ - if(j == H5Z_table_used_g) - HGOTO_DONE(FALSE) + if (j == H5Z_table_used_g) + HGOTO_DONE (FALSE) } /* end for */ done: @@ -1432,7 +1468,8 @@ done: * Purpose: Delete filter FILTER from pipeline PLINE; * deletes all filters if FILTER is H5Z_FILTER_NONE * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success + * Negative on failure *------------------------------------------------------------------------- */ herr_t @@ -1443,52 +1480,52 @@ H5Z_delete(H5O_pline_t *pline, H5Z_filter_t filter) FUNC_ENTER_NOAPI(FAIL) /* Check args */ - HDassert(pline); - HDassert(filter >= 0 && filter <= H5Z_FILTER_MAX); + HDassert (pline); + HDassert (filter >= 0 && filter <= H5Z_FILTER_MAX); /* if the pipeline has no filters, just return */ - if(pline->nused == 0) - HGOTO_DONE(SUCCEED) + if (pline->nused == 0) + HGOTO_DONE (SUCCEED) /* Delete all filters */ - if(H5Z_FILTER_ALL == filter) { - if(H5O_msg_reset(H5O_PLINE_ID, pline) < 0) + if (H5Z_FILTER_ALL == filter) { + if (H5O_msg_reset(H5O_PLINE_ID, pline) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTFREE, FAIL, "can't release pipeline info") } /* end if */ /* Delete filter */ else { - size_t idx; /* Index of filter in pipeline */ - hbool_t found = FALSE; /* Indicate filter was found in pipeline */ + size_t idx; /* Index of filter in pipeline */ + hbool_t found = FALSE; /* Indicate filter was found in pipeline */ /* Locate the filter in the pipeline */ - for(idx = 0; idx < pline->nused; idx++) - if(pline->filter[idx].id == filter) { + for (idx = 0; idx < pline->nused; idx++) + if (pline->filter[idx].id == filter) { found = TRUE; break; } /* end if */ /* filter was not found in the pipeline */ - if(!found) - HGOTO_ERROR(H5E_PLINE, H5E_NOTFOUND, FAIL, "filter not in pipeline") + if (!found) + HGOTO_ERROR (H5E_PLINE, H5E_NOTFOUND, FAIL, "filter not in pipeline") /* Free information for deleted filter */ - if(pline->filter[idx].name && pline->filter[idx].name != pline->filter[idx]._name) - HDassert((HDstrlen(pline->filter[idx].name) + 1) > H5Z_COMMON_NAME_LEN); - if(pline->filter[idx].name != pline->filter[idx]._name) + if (pline->filter[idx].name && pline->filter[idx].name != pline->filter[idx]._name) + HDassert ((HDstrlen(pline->filter[idx].name) + 1) > H5Z_COMMON_NAME_LEN); + if (pline->filter[idx].name != pline->filter[idx]._name) pline->filter[idx].name = (char *)H5MM_xfree(pline->filter[idx].name); - if(pline->filter[idx].cd_values && pline->filter[idx].cd_values != pline->filter[idx]._cd_values) - HDassert(pline->filter[idx].cd_nelmts > H5Z_COMMON_CD_VALUES); - if(pline->filter[idx].cd_values != pline->filter[idx]._cd_values) + if (pline->filter[idx].cd_values && pline->filter[idx].cd_values != pline->filter[idx]._cd_values) + HDassert (pline->filter[idx].cd_nelmts > H5Z_COMMON_CD_VALUES); + if (pline->filter[idx].cd_values != pline->filter[idx]._cd_values) pline->filter[idx].cd_values = (unsigned *)H5MM_xfree(pline->filter[idx].cd_values); /* Remove filter from pipeline array */ - if((idx + 1) < pline->nused) { + if ((idx + 1) < pline->nused) { /* Copy filters down & fix up any client data value arrays using internal storage */ - for(; (idx + 1) < pline->nused; idx++) { + for (; (idx + 1) < pline->nused; idx++) { pline->filter[idx] = pline->filter[idx + 1]; - if(pline->filter[idx].name && (HDstrlen(pline->filter[idx].name) + 1) <= H5Z_COMMON_NAME_LEN) + if (pline->filter[idx].name && (HDstrlen(pline->filter[idx].name) + 1) <= H5Z_COMMON_NAME_LEN) pline->filter[idx].name = pline->filter[idx]._name; - if(pline->filter[idx].cd_nelmts <= H5Z_COMMON_CD_VALUES) + if (pline->filter[idx].cd_nelmts <= H5Z_COMMON_CD_VALUES) pline->filter[idx].cd_values = pline->filter[idx]._cd_values; } /* end for */ } /* end if */ @@ -1497,7 +1534,7 @@ H5Z_delete(H5O_pline_t *pline, H5Z_filter_t filter) pline->nused--; /* Reset information for previous last filter in pipeline */ - HDmemset(&pline->filter[pline->nused], 0, sizeof(H5Z_filter_info_t)); + HDmemset (&pline->filter[pline->nused], 0, sizeof(H5Z_filter_info_t)); } /* end else */ done: @@ -1510,6 +1547,9 @@ done: * * Purpose: Gets information about a pipeline data filter and stores it * in filter_config_flags. + * + * Return: zero on success + * negative on failure *------------------------------------------------------------------------- */ herr_t @@ -1521,8 +1561,8 @@ H5Zget_filter_info(H5Z_filter_t filter, unsigned int *filter_config_flags) H5TRACE2("e", "Zf*Iu", filter, filter_config_flags); /* Get the filter info */ - if(H5Z_get_filter_info(filter, filter_config_flags) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "Filter info not retrieved") + if (H5Z_get_filter_info(filter, filter_config_flags) < 0) + HGOTO_ERROR (H5E_PLINE, H5E_CANTGET, FAIL, "Filter info not retrieved") done: FUNC_LEAVE_API(ret_value) @@ -1534,6 +1574,9 @@ done: * * Purpose: Gets information about a pipeline data filter and stores it * in filter_config_flags. + * + * Return: zero on success + * negative on failure *------------------------------------------------------------------------- */ herr_t @@ -1545,16 +1588,16 @@ H5Z_get_filter_info(H5Z_filter_t filter, unsigned int *filter_config_flags) FUNC_ENTER_NOAPI(FAIL) /* Look up the filter class info */ - if(NULL == (fclass = H5Z_find(filter))) - HGOTO_ERROR(H5E_PLINE, H5E_BADVALUE, FAIL, "Filter not defined") + if (NULL == (fclass = H5Z_find(filter))) + HGOTO_ERROR (H5E_PLINE, H5E_BADVALUE, FAIL, "Filter not defined") /* Set the filter config flags for the application */ - if(filter_config_flags != NULL) { + if (filter_config_flags != NULL) { *filter_config_flags = 0; - if(fclass->encoder_present) + if (fclass->encoder_present) *filter_config_flags |= H5Z_FILTER_CONFIG_ENCODE_ENABLED; - if(fclass->decoder_present) + if (fclass->decoder_present) *filter_config_flags |= H5Z_FILTER_CONFIG_DECODE_ENABLED; } /* end if */ -- cgit v0.12 From dfaeaa35cd6b765581d1f0d86076d549135b9500 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 16 Nov 2017 15:00:13 -0600 Subject: Fix typo --- src/H5PLint.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/H5PLint.c b/src/H5PLint.c index e969cbf..33dda96 100644 --- a/src/H5PLint.c +++ b/src/H5PLint.c @@ -372,7 +372,7 @@ H5PL__open(const char *path, H5PL_type_t type, int id, hbool_t *success, const v done: if (!success && handle) - if (*plugin_info) { + if (*plugin_info) *plugin_info = (H5Z_class2_t *)H5MM_xfree(*plugin_info); if (H5PL__close(handle) < 0) HDONE_ERROR(H5E_PLUGIN, H5E_CLOSEERROR, FAIL, "can't close dynamic library") -- cgit v0.12 From 9599e55176104ab55576ee921be4475e860da5fa Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Fri, 17 Nov 2017 13:59:57 -0600 Subject: HDFFV-10328 - remove allocation changes --- src/H5PLint.c | 21 +-------------------- src/H5PLplugin_cache.c | 22 +--------------------- src/H5Z.c | 33 ++++----------------------------- 3 files changed, 6 insertions(+), 70 deletions(-) diff --git a/src/H5PLint.c b/src/H5PLint.c index 33dda96..c887f86 100644 --- a/src/H5PLint.c +++ b/src/H5PLint.c @@ -342,38 +342,19 @@ H5PL__open(const char *path, H5PL_type_t type, int id, hbool_t *success, const v /* Check if the filter IDs match */ if (info->id == id) { - H5Z_class2_t *plugin_copy = NULL; /* Store the plugin in the cache */ if (H5PL__add_plugin(type, id, handle)) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTINSERT, FAIL, "unable to add new plugin to plugin cache") - /* allocate local copy of plugin info */ - if (NULL == (plugin_copy = (H5Z_class2_t *)H5MM_calloc(sizeof(H5Z_class2_t)))) - HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't allocate memory for plugin info") - /* Set the plugin info to return */ - *plugin_info = (const void *)info; - - plugin_copy->version = info->version; - plugin_copy->id = info->id; - plugin_copy->encoder_present = info->encoder_present; - plugin_copy->decoder_present = info->decoder_present; - plugin_copy->can_apply = info->can_apply; - plugin_copy->set_local = info->set_local; - plugin_copy->filter = info->filter; - /* copy the user's string into the property */ - if(NULL == (plugin_copy->name = (char *)H5MM_xstrdup(info->name))) - HGOTO_ERROR(H5E_PLUGIN, H5E_NOSPACE, FAIL, "can't allocate memory for plugin info name") - /* Set output parameters */ *success = TRUE; + *plugin_info = (const void *)info; } } done: if (!success && handle) - if (*plugin_info) - *plugin_info = (H5Z_class2_t *)H5MM_xfree(*plugin_info); if (H5PL__close(handle) < 0) HDONE_ERROR(H5E_PLUGIN, H5E_CLOSEERROR, FAIL, "can't close dynamic library") diff --git a/src/H5PLplugin_cache.c b/src/H5PLplugin_cache.c index ec14159..e483e01 100644 --- a/src/H5PLplugin_cache.c +++ b/src/H5PLplugin_cache.c @@ -280,7 +280,6 @@ H5PL__find_plugin_in_cache(const H5PL_search_params_t *search_params, hbool_t *f H5PL_get_plugin_info_t get_plugin_info_function; const H5Z_class2_t *filter_info; - H5Z_class2_t *plugin_copy = NULL; /* Get the "get plugin info" function from the plugin. */ if (NULL == (get_plugin_info_function = (H5PL_get_plugin_info_t)H5PL_GET_LIB_FUNC((H5PL_cache_g[u]).handle, "H5PLget_plugin_info"))) @@ -290,24 +289,9 @@ H5PL__find_plugin_in_cache(const H5PL_search_params_t *search_params, hbool_t *f if (NULL == (filter_info = (const H5Z_class2_t *)(*get_plugin_info_function)())) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "can't get plugin info") - if (NULL == (plugin_copy = (H5Z_class2_t *)H5MM_calloc(sizeof(H5Z_class2_t)))) - HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't allocate memory for plugin info") - /* Set the plugin info to return */ - *plugin_info = plugin_copy; - - plugin_copy->version = filter_info->version; - plugin_copy->id = filter_info->id; - plugin_copy->encoder_present = filter_info->encoder_present; - plugin_copy->decoder_present = filter_info->decoder_present; - plugin_copy->can_apply = filter_info->can_apply; - plugin_copy->set_local = filter_info->set_local; - plugin_copy->filter = filter_info->filter; - /* copy the user's string into the property */ - if(NULL == (plugin_copy->name = (char *)H5MM_xstrdup(filter_info->name))) - HGOTO_ERROR(H5E_PLUGIN, H5E_NOSPACE, FAIL, "can't allocate memory for plugin info name") - /* Set output parameters */ *found = TRUE; + *plugin_info = filter_info; /* No need to continue processing */ break; @@ -317,10 +301,6 @@ H5PL__find_plugin_in_cache(const H5PL_search_params_t *search_params, hbool_t *f } /* end for */ done: - /* unallocate local copy of plugin info on failure */ - if (FAIL == ret_value && *plugin_info) { - *plugin_info = (H5Z_class2_t *)H5MM_xfree(*plugin_info); - } FUNC_LEAVE_NOAPI(ret_value) } /* end H5PL__find_plugin_in_cache() */ #pragma GCC diagnostic pop diff --git a/src/H5Z.c b/src/H5Z.c index e7574cd..1f1a905 100644 --- a/src/H5Z.c +++ b/src/H5Z.c @@ -123,7 +123,6 @@ int H5Z_term_package(void) { int n = 0; - size_t i; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -131,6 +130,7 @@ H5Z_term_package(void) #ifdef H5Z_DEBUG char comment[16], bandwidth[32]; int dir, nprint = 0; + size_t i; if(H5DEBUG(Z)) { for(i = 0; i < H5Z_table_used_g; i++) { @@ -179,12 +179,6 @@ H5Z_term_package(void) } /* end for */ } /* end if */ #endif /* H5Z_DEBUG */ - for (i = 0; i < H5Z_table_used_g; i++) { - H5Z_class2_t *cls = (H5Z_class2_t *)(H5Z_table_g+i); - /* deallocate plugin info name */ - if (cls->name) - cls->name = (char *)H5MM_xfree(cls->name); - } /* Free the table of filters */ if(H5Z_table_g) { H5Z_table_g = (H5Z_class2_t *)H5MM_xfree(H5Z_table_g); @@ -325,20 +319,14 @@ H5Z_register (const H5Z_class2_t *cls) /* Initialize */ i = H5Z_table_used_g++; HDmemcpy (H5Z_table_g+i, cls, sizeof(H5Z_class2_t)); - H5Z_table_g[i].name = (char *)H5MM_xstrdup(cls->name); #ifdef H5Z_DEBUG HDmemset (H5Z_stat_table_g+i, 0, sizeof(H5Z_stats_t)); #endif /* H5Z_DEBUG */ } /* end if */ /* Filter already registered */ else { - H5Z_class2_t *old_cls = (H5Z_class2_t *)(H5Z_table_g+i); - /* deallocate plugin info name */ - if (old_cls->name) - old_cls->name = (char *)H5MM_xfree(old_cls->name); /* Replace old contents */ - HDmemcpy (old_cls, cls, sizeof(H5Z_class2_t)); - old_cls->name = (char *)H5MM_xstrdup(cls->name); + HDmemcpy (H5Z_table_g+i, cls, sizeof(H5Z_class2_t)); } /* end else */ done: @@ -394,7 +382,6 @@ H5Z_unregister(H5Z_filter_t filter_id) size_t filter_index; /* Local index variable for filter */ H5Z_object_t object; herr_t ret_value = SUCCEED; /* Return value */ - H5Z_class2_t *old_cls = NULL; FUNC_ENTER_NOAPI(FAIL) @@ -431,10 +418,6 @@ H5Z_unregister(H5Z_filter_t filter_id) if (H5I_iterate(H5I_FILE, H5Z__flush_file_cb, NULL, FALSE) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed") - /* deallocate plugin info name */ - old_cls = (H5Z_class2_t *)(H5Z_table_g+filter_index); - if (old_cls->name) - old_cls->name = (char *)H5MM_xfree(old_cls->name); /* Remove filter from table */ /* Don't worry about shrinking table size (for now) */ HDmemmove (&H5Z_table_g[filter_index], &H5Z_table_g[filter_index+1], sizeof(H5Z_class2_t)*((H5Z_table_used_g-1)-filter_index)); @@ -658,11 +641,7 @@ H5Z_filter_avail(H5Z_filter_t id) HGOTO_DONE (TRUE) if (NULL != (filter_info = (const H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, (int)id))) { - herr_t status = H5Z_register(filter_info); - if (filter_info->name) - filter_info->name = (char *)H5MM_xfree(filter_info->name); - filter_info = (H5Z_class2_t *)H5MM_xfree(filter_info); - if (status < 0) + if (H5Z_register (filter_info) < 0) HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register loaded filter") HGOTO_DONE (TRUE) } @@ -1245,11 +1224,7 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, /* Try loading the filter */ if (NULL != (filter_info = (const H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, (int)(pline->filter[idx].id)))) { /* Register the filter we loaded */ - herr_t status = H5Z_register(filter_info); - if (filter_info->name) - filter_info->name = (char *)H5MM_xfree(filter_info->name); - filter_info = (H5Z_class2_t *)H5MM_xfree(filter_info); - if (status < 0) + if (H5Z_register(filter_info < 0) HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register filter") /* Search in the table of registered filters again to find the dynamic filter just loaded and registered */ -- cgit v0.12 From bd28c0b42d43edc53f1bfd12ecb2ab397e92cbab Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Fri, 17 Nov 2017 14:02:07 -0600 Subject: HDFFV-10328 remove allocation note --- release_docs/RELEASE.txt | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 9e3c3a9..a1b59b1 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -160,8 +160,7 @@ Bug Fixes since HDF5-1.10.1 release - filter plugin handling in H5PL.c and H5Z.c It was discovered that the dynamic loading process used by - filter plugins had issues with memory allocation and library - dependencies. + filter plugins had issues with library dependencies. CMake build process changed to use LINK INTERFACE keywords, which allowed HDF5 C library to make dependent libraries private. The @@ -169,13 +168,6 @@ Bug Fixes since HDF5-1.10.1 release (such as szip or zlib) to be available. (ADB - 2017/11/16, HDFFV-10328) - The H5Z_class2_t structure returned by the filter plugins are - now dynamically allocated in H5Zregister function. Access to - the functions in the filter library now always use the dynamic - library API. - - (ADB - 2017/11/16, HDFFV-10329) - - H5Zfilter_avail in H5Z.c The public function checked for plugins, while the private -- cgit v0.12 From bb3fb6f13461d724baa635e464585cb49d8848d2 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Fri, 17 Nov 2017 14:20:14 -0600 Subject: HDFFV-10328 - fix typos --- src/H5Z.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/H5Z.c b/src/H5Z.c index 1f1a905..a9f7336 100644 --- a/src/H5Z.c +++ b/src/H5Z.c @@ -1219,12 +1219,12 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, */ if ((fclass_idx = H5Z_find_idx(pline->filter[idx].id)) < 0) { hbool_t issue_error = FALSE; - H5Z_class2_t *filter_info; + const H5Z_class2_t *filter_info; /* Try loading the filter */ if (NULL != (filter_info = (const H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, (int)(pline->filter[idx].id)))) { /* Register the filter we loaded */ - if (H5Z_register(filter_info < 0) + if (H5Z_register(filter_info) < 0) HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register filter") /* Search in the table of registered filters again to find the dynamic filter just loaded and registered */ @@ -1235,7 +1235,7 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, issue_error = TRUE; /* Check for error */ - if(issue_error) { + if (issue_error) { /* Print out the filter name to give more info. But the name is optional for * the filter */ if (pline->filter[idx].name) @@ -1269,9 +1269,8 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, failed |= (unsigned)1 << idx; H5E_clear_stack (NULL); } - else { + else *nbytes = new_nbytes; - } } } else if (pline) { /* Write */ -- cgit v0.12