diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2010-03-25 03:51:41 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2010-03-25 03:51:41 (GMT) |
commit | 42efc1c2b591e4cd45ec6cb3bdf32044343118d2 (patch) | |
tree | 0ab542871c32246199479e8933ff26286aaf629a /tools/lib | |
parent | 3360c3af0c100ac4d3a2fe2865f34661da862ec5 (diff) | |
download | hdf5-42efc1c2b591e4cd45ec6cb3bdf32044343118d2.zip hdf5-42efc1c2b591e4cd45ec6cb3bdf32044343118d2.tar.gz hdf5-42efc1c2b591e4cd45ec6cb3bdf32044343118d2.tar.bz2 |
[svn-r18451] Description:
Bring r18172:18446 from trunk to revise_chunks branch.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Diffstat (limited to 'tools/lib')
-rw-r--r-- | tools/lib/h5diff.c | 1005 | ||||
-rw-r--r-- | tools/lib/h5diff.h | 3 | ||||
-rw-r--r-- | tools/lib/h5diff_array.c | 81 | ||||
-rw-r--r-- | tools/lib/h5diff_dset.c | 250 | ||||
-rw-r--r-- | tools/lib/h5diff_util.c | 4 | ||||
-rw-r--r-- | tools/lib/h5tools.c | 314 | ||||
-rw-r--r-- | tools/lib/h5tools.h | 18 | ||||
-rw-r--r-- | tools/lib/h5tools_error.h | 6 | ||||
-rw-r--r-- | tools/lib/h5tools_str.c | 36 | ||||
-rw-r--r-- | tools/lib/h5tools_str.h | 2 | ||||
-rw-r--r-- | tools/lib/h5tools_utils.c | 12 | ||||
-rw-r--r-- | tools/lib/h5trav.c | 2 |
12 files changed, 874 insertions, 859 deletions
diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c index 4b7b796..9e753fe 100644 --- a/tools/lib/h5diff.c +++ b/tools/lib/h5diff.c @@ -27,24 +27,21 @@ typedef enum toolname_t { /* this struct can be used to differntiate among tools if necessary */ typedef struct { h5tool_toolname_t toolname; - int mode; + int msg_mode; } h5tool_opt_t; -/* To return link's target info +/* To return link info * Functions: - * H5tools_get_softlink_target_info() - * H5tools_get_extlink_target_info() + * H5tools_get_link_info() * Note: this may be move to h5tools code if used by other tools */ typedef struct { - const char *buf; /* IN: must be allocated along with H5Lget_info[li.u.val_size] */ - H5O_type_t type; /* OUT: target type */ - const char *path; /* OUT: target name */ - int is_path_malloced; /* VAR: Set to TRUE if path is malloced, so can be freed by checking this later. Needed when ext-link's target is soft-link */ - const char *extfile; /* OUT: if external link, external filename */ - hid_t extfile_id; /* OUT: if external link, external file id */ - h5tool_opt_t opt; /* IN: options */ -} h5tool_link_trg_info_t; + H5O_type_t trg_type; /* OUT: target type */ + const char *trg_path; /* OUT: target obj path. This must be freed + * when used with H5tools_get_link_info() */ + H5L_info_t linfo; /* OUT: link info */ + h5tool_opt_t opt; /* IN: options */ +} h5tool_link_info_t; /* * Debug printf macros. The prefix allows output filtering by test scripts. */ @@ -90,6 +87,21 @@ do_print_objname (const char *OBJ, const char *path1, const char *path2) parallel_print("%-7s: <%s> and <%s>\n", OBJ, path1, path2); } +/*------------------------------------------------------------------------- + * Function: print_warn + * + * Purpose: check print warning condition. + * Return: + * 1 if verbose mode + * 0 if not verbos mode + * Programmer: Jonathan Kim + * Date: Feb 4, 2010 + *------------------------------------------------------------------------- + */ +static int print_warn(diff_opt_t *options) +{ + return ((options->m_verbose))?1:0; +} #ifdef H5_HAVE_PARALLEL @@ -108,9 +120,9 @@ do_print_objname (const char *OBJ, const char *path1, const char *path2) */ void phdiff_dismiss_workers(void) { - int i; - for(i=1; i<g_nTasks; i++) - MPI_Send(NULL, 0, MPI_BYTE, i, MPI_TAG_END, MPI_COMM_WORLD); + int i; + for(i=1; i<g_nTasks; i++) + MPI_Send(NULL, 0, MPI_BYTE, i, MPI_TAG_END, MPI_COMM_WORLD); } @@ -130,31 +142,29 @@ void phdiff_dismiss_workers(void) */ void print_manager_output(void) { - /* If there was something we buffered, let's print it now */ - if( (outBuffOffset>0) && g_Parallel) - { - printf("%s", outBuff); - - if(overflow_file) - { - int tmp; - - rewind(overflow_file); - while((tmp = getc(overflow_file)) >= 0) - putchar(tmp); - - fclose(overflow_file); - overflow_file = NULL; - } - - fflush(stdout); - memset(outBuff, 0, OUTBUFF_SIZE); - outBuffOffset = 0; - } - else if( (outBuffOffset>0) && !g_Parallel) - { - fprintf(stderr, "h5diff error: outBuffOffset>0, but we're not in parallel!\n"); - } + /* If there was something we buffered, let's print it now */ + if( (outBuffOffset>0) && g_Parallel) + { + printf("%s", outBuff); + + if(overflow_file) + { + int tmp; + rewind(overflow_file); + while((tmp = getc(overflow_file)) >= 0) + putchar(tmp); + fclose(overflow_file); + overflow_file = NULL; + } + + fflush(stdout); + memset(outBuff, 0, OUTBUFF_SIZE); + outBuffOffset = 0; + } + else if( (outBuffOffset>0) && !g_Parallel) + { + fprintf(stderr, "h5diff error: outBuffOffset>0, but we're not in parallel!\n"); + } } /*------------------------------------------------------------------------- @@ -174,253 +184,200 @@ void print_manager_output(void) static void print_incoming_data(void) { - char data[PRINT_DATA_MAX_SIZE+1]; - int incomingMessage; - MPI_Status Status; - - do - { - MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_PRINT_DATA, MPI_COMM_WORLD, &incomingMessage, &Status); - if(incomingMessage) - { - memset(data, 0, PRINT_DATA_MAX_SIZE+1); - MPI_Recv(data, PRINT_DATA_MAX_SIZE, MPI_CHAR, Status.MPI_SOURCE, MPI_TAG_PRINT_DATA, MPI_COMM_WORLD, &Status); - - printf("%s", data); - } - } while(incomingMessage); + char data[PRINT_DATA_MAX_SIZE+1]; + int incomingMessage; + MPI_Status Status; + + do + { + MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_PRINT_DATA, MPI_COMM_WORLD, &incomingMessage, &Status); + if(incomingMessage) + { + memset(data, 0, PRINT_DATA_MAX_SIZE+1); + MPI_Recv(data, PRINT_DATA_MAX_SIZE, MPI_CHAR, Status.MPI_SOURCE, MPI_TAG_PRINT_DATA, MPI_COMM_WORLD, &Status); + + printf("%s", data); + } + } while(incomingMessage); } #endif /*------------------------------------------------------------------------- - * Function: H5tools_get_softlink_target_info + * Function: is_valid_options * - * Purpose: Get target object's type and path from soft-link path - * - * Patameters: - * - [IN] fileid : soft-link file id - * - [IN] linkpath : soft-link's source path - * - [IN] h5li : soft-link's source H5L_info_t - * - [OUT] trg_info: returning target info (refer to struct) + * Purpose: check if options are valid * * Return: - * Success - 1 and return data via trg_info struct - * Fail - 0 - * - * Note: - * trg_info->buf must be allocated along with H5Lget_info[li.u.val_size] - * before passing to this function. + * 1 : Valid + * 0 : Not valid * * Programmer: Jonathan Kim * - * Date: Jan 20, 2010 - *-------------------------------------------------------------------------*/ -static int H5tools_get_softlink_target_info(hid_t file_id, const char * linkpath, H5L_info_t h5li, h5tool_link_trg_info_t *s_trg_info) + * Date: Feb 17, 2010 + * + *------------------------------------------------------------------------*/ +static int is_valid_options(diff_opt_t *options) { - H5O_type_t otype = H5O_TYPE_UNKNOWN; - H5O_info_t oinfo; - H5L_info_t linfo; - int ret = 0; /* init to fail */ - + int ret=1; /* init to valid */ - if((H5Lexists(file_id, linkpath, H5P_DEFAULT) <= 0)) + /*----------------------------------------------- + * no -q(quiet) with -v (verbose) or -r (report) */ + if(options->m_quiet && (options->m_verbose || options->m_report)) { - parallel_print("error: \"%s\" doesn't exist \n",linkpath); + parallel_print("Error: -q (quiet mode) cannot be added to verbose or report modes\n"); + options->err_stat=1; + ret = 0; goto out; } - if(H5Lget_info(file_id, linkpath, &linfo, H5P_DEFAULT) < 0) + /* ------------------------------------------------------- + * only allow --no-dangling-links along with --follow-links */ + if(options->no_dangle_links && !options->follow_links) { - parallel_print("error: unable to get link info from \"%s\"\n",linkpath); + parallel_print("Error: --no-dangling-links must be used along with --follow-links option.\n"); + options->err_stat=1; + ret = 0; goto out; } - /* get target name for softlink */ - if(linfo.type == H5L_TYPE_SOFT) - { - /* s_trg_info->buf should be already allocated out of - * this function and free when done */ - if(H5Lget_val(file_id, linkpath, s_trg_info->buf, h5li.u.val_size, H5P_DEFAULT) < 0) - { - parallel_print("error: unable to get link value from \"%s\"\n",s_trg_info->path); - goto out; - } - /* target path */ - s_trg_info->path = s_trg_info->buf; - } - /* if obj is hard link, will still get the type */ - else if (linfo.type == H5L_TYPE_HARD) - { - s_trg_info->path = linkpath; - } - - /*-------------------------------------------------------------- - * if link target or object exit, get type - */ - if((H5Lexists(file_id, s_trg_info->path, H5P_DEFAULT) == TRUE)) - { - - if(H5Oget_info_by_name(file_id, s_trg_info->path, &oinfo, H5P_DEFAULT) < 0) - { - parallel_print("error: unable to get object information for \"%s\"\n", s_trg_info->path); - goto out; - } - - otype = oinfo.type; - - - /* check unknown type */ - if (otype < H5O_TYPE_GROUP || otype >=H5O_TYPE_NTYPES) - { - parallel_print("<%s> is unknown type\n", s_trg_info->path); - goto out; - } - } - else +out: + if (!ret) { - parallel_print("warn: link target \"%s\" doesn't exist \n", s_trg_info->path); +#ifdef H5_HAVE_PARALLEL + if(g_Parallel) + /* Let tasks know that they won't be needed */ + phdiff_dismiss_workers(); +#endif } - /* set target obj type to return */ - s_trg_info->type = otype; - - /* succeed */ - ret = 1; -out: return ret; } + /*------------------------------------------------------------------------- - * Function: H5tools_get_extlink_target_info + * Function: H5tools_get_link_info * - * Purpose: Get target object's type, path, file_id and filename from - * external-link + * Purpose: Get link (soft, external) info and its target object type + (dataset, group, named datatype) and path, if exist * * Patameters: - * - [IN] fileid : external-link source file-id - * - [IN] linkpath : external-link source path - * - [IN] h5li : external-link source H5L_info_t - * - [OUT] trg_info : returning target info (refer to struct) + * - [IN] fileid : link file id + * - [IN] linkpath : link path + * - [OUT] h5li : link's info (H5L_info_t) + * - [OUT] link_info: returning target object info (h5tool_link_info_t) * * Return: - * Success - 1 and return data via trg_info struct - * Fail - 0 + * 1 : Succed to get link info. + * 0 : Detected as a dangling link + * -1 : H5 API failed. * - * Note: - * - trg_info->buf must be allocated along with H5Lget_info[li.u.val_size] - * before passing to this function. - * - if target is soft-link, trg_info->path will be malloced. so check if - * trg_info->is_path_malloced==TRUE, then free trg_info->path along with freeing - * trg_info->buf outside of this function. + * NOTE: + * link_info->trg_path must be freed out of this function * * Programmer: Jonathan Kim * - * Date: Jan 20, 2010 + * Date: Feb 8, 2010 *-------------------------------------------------------------------------*/ -static int H5tools_get_extlink_target_info(hid_t fileid, const char *linkpath, H5L_info_t h5li, h5tool_link_trg_info_t *trg_info) +static int H5tools_get_link_info(hid_t file_id, const char * linkpath, h5tool_link_info_t *link_info) { - - hid_t extfile_id; - const char *extlink_file; - const char *extlink_path; - h5tool_link_trg_info_t soft_trg_info; - H5L_info_t slinfo; - int ret=0; /* init to Fail */ + int Ret = -1; /* init to fail */ + htri_t l_ret; + H5O_info_t trg_oinfo; + hid_t fapl; + hid_t lapl = H5P_DEFAULT; /* init */ - HDmemset(&soft_trg_info, 0, sizeof(h5tool_link_trg_info_t)); - trg_info->type = H5O_TYPE_UNKNOWN; - - if(H5Lget_val(fileid, linkpath, trg_info->buf, h5li.u.val_size, H5P_DEFAULT) < 0) + link_info->trg_type = H5O_TYPE_UNKNOWN; + + /* check if link itself exist */ + if((H5Lexists(file_id, linkpath, H5P_DEFAULT) <= 0)) { - parallel_print("error: unable to get link value from \"%s\"\n",linkpath); + if(link_info->opt.msg_mode==1) + parallel_print("Warning: link <%s> doesn't exist \n",linkpath); goto out; } - /*--------------------------------------- - * get target filename and object path - */ - if(H5Lunpack_elink_val(trg_info->buf, h5li.u.val_size, NULL, &extlink_file, &extlink_path)<0) + + /* get info from link */ + if(H5Lget_info(file_id, linkpath, &(link_info->linfo), H5P_DEFAULT) < 0) { - parallel_print("error: unable to unpack external link value\n"); + if(link_info->opt.msg_mode==1) + parallel_print("Warning: unable to get link info from <%s>\n",linkpath); goto out; } - /* return target filename and obj path */ - trg_info->path = extlink_path; - trg_info->extfile = extlink_file; - - /* --------------------------------- - * get file id from external file - * mimicked from h5diff() for Parallel code - * , but not sure if it's needed - */ - H5E_BEGIN_TRY + /* trg_path must be freed out of this function when finished using */ + link_info->trg_path = (char*)HDcalloc(link_info->linfo.u.val_size, sizeof(char)); + HDassert(link_info->trg_path); + + /* get link value */ + if(H5Lget_val(file_id, linkpath, link_info->trg_path, link_info->linfo.u.val_size, H5P_DEFAULT) < 0) { - /* open file */ - if((extfile_id = h5tools_fopen(extlink_file, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t)0)) < 0) - { - parallel_print("error: <%s>: unable to open file\n", extlink_file); -#ifdef H5_HAVE_PARALLEL - if(g_Parallel) - /* Let tasks know that they won't be needed */ - phdiff_dismiss_workers(); -#endif - goto out; - } /* end if */ - } H5E_END_TRY; + if(link_info->opt.msg_mode==1) + parallel_print("Warning: unable to get link value from <%s>\n",linkpath); + goto out; + } - /* get external file id */ - trg_info->extfile_id = extfile_id; + /*----------------------------------------------------- + * if link type is external link use different lapl to + * follow object in other file + */ + if (link_info->linfo.type == H5L_TYPE_EXTERNAL) + { + fapl = H5Pcreate(H5P_FILE_ACCESS); + H5Pset_fapl_sec2(fapl); + lapl = H5Pcreate(H5P_LINK_ACCESS); + H5Pset_elink_fapl(lapl, fapl); + } - /* -------------------------------------------------- - * check if target is soft link, if so allocate buffer + /*-------------------------------------------------------------- + * if link's target object exist, get type */ - if((H5Lexists(trg_info->extfile_id, trg_info->path, H5P_DEFAULT) <= 0)) + /* check if target object exist */ + l_ret = H5Oexists_by_name(file_id, linkpath, lapl); + + /* detect dangling link */ + if(l_ret == FALSE) { - parallel_print("error: \"%s\" doesn't exist \n", trg_info->path); - goto out; + Ret = 0; + goto out; } - if(H5Lget_info(trg_info->extfile_id, trg_info->path, &slinfo, H5P_DEFAULT) < 0) + /* function failed */ + else if (l_ret < 0) { - parallel_print("error: unable to get link info from \"%s\"\n", trg_info->path); - goto out; + goto out; } - /* if ext-link's target is soft-link */ - if(slinfo.type == H5L_TYPE_SOFT) + /* get target object info */ + if(H5Oget_info_by_name(file_id, linkpath, &trg_oinfo, lapl) < 0) { - size_t bufsize = (h5li.u.val_size > slinfo.u.val_size)?h5li.u.val_size:slinfo.u.val_size; - soft_trg_info.buf = (char*)HDcalloc(bufsize, sizeof(char)); - HDassert(trg_info->path); + if(link_info->opt.msg_mode==1) + parallel_print("Warning: unable to get object information for <%s>\n", linkpath); + goto out; } - /* get target obj type */ - if(H5tools_get_softlink_target_info(trg_info->extfile_id, trg_info->path, h5li, &soft_trg_info)==0) + /* check unknown type */ + if (trg_oinfo.type < H5O_TYPE_GROUP || trg_oinfo.type >=H5O_TYPE_NTYPES) { - parallel_print("error: unable to get link info from \"%s\"\n", trg_info->path); + if(link_info->opt.msg_mode==1) + parallel_print("Warning: target object of <%s> is unknown type\n", linkpath); goto out; - } + } - /* target obj type */ - trg_info->type = soft_trg_info.type; + /* set target obj type to return */ + link_info->trg_type = trg_oinfo.type; - /* if ext-link's target is soft-link */ - if(slinfo.type == H5L_TYPE_SOFT) + /* succeed */ + Ret = 1; +out: + if (link_info->linfo.type == H5L_TYPE_EXTERNAL) { - trg_info->path = HDstrdup(soft_trg_info.buf); - HDassert(trg_info->path); - /* set TRUE so this can be freed later */ - trg_info->is_path_malloced = TRUE; + H5Pclose(fapl); + H5Pclose(lapl); } - /* Success */ - ret=1; -out: - if(soft_trg_info.buf) - HDfree(soft_trg_info.buf); - - return ret; + return Ret; } + /*------------------------------------------------------------------------- * Function: h5diff * @@ -435,7 +392,6 @@ out: * *------------------------------------------------------------------------- */ - hsize_t h5diff(const char *fname1, const char *fname2, const char *objname1, @@ -451,12 +407,11 @@ hsize_t h5diff(const char *fname1, HDmemset(filenames, 0, 1024 * 2); - 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; - return 0; - } /* end if */ + /*------------------------------------------------------------------------- + * check invalid combination of options + *-----------------------------------------------------------------------*/ + if(!is_valid_options(options)) + goto out; /*------------------------------------------------------------------------- * open the files first; if they are not valid, no point in continuing @@ -546,12 +501,10 @@ hsize_t h5diff(const char *fname1, info2, options); } /* end if */ - /*------------------------------------------------------------------------- * compare all *------------------------------------------------------------------------- */ - else { #ifdef H5_HAVE_PARALLEL @@ -751,8 +704,8 @@ hsize_t diff_match(hid_t file1_id, *------------------------------------------------------------------------- */ #ifdef H5_HAVE_PARALLEL -{ - char *workerTasks = HDmalloc((g_nTasks - 1) * sizeof(char)); + { + char *workerTasks = (char*)HDmalloc((g_nTasks - 1) * sizeof(char)); int n; int busyTasks = 0; struct diffs_found nFoundbyWorker; @@ -1043,7 +996,7 @@ hsize_t diff_match(hid_t file1_id, h5diffdebug("done with if block\n"); free(workerTasks); -} + } #endif /* H5_HAVE_PARALLEL */ /* free table */ @@ -1061,9 +1014,10 @@ hsize_t diff_match(hid_t file1_id, * Return: Number of differences found * * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * * Date: May 9, 2003 * + * Programmer: Jonathan Kim + * - add following links feature (Feb 11,2010) *------------------------------------------------------------------------- */ @@ -1081,30 +1035,20 @@ hsize_t diff_compare(hid_t file1_id, int f2 = 0; hsize_t nfound = 0; ssize_t i,j; + int l_ret; + int is_dangle_link1 = 0; + int is_dangle_link2 = 0; /* local variables for diff() */ - hid_t l_fileid1=file1_id; - hid_t l_fileid2=file2_id; h5trav_type_t obj1type, obj2type; - const char *obj1name, *obj2name; - - /* softlink info to get target name and type */ - h5tool_link_trg_info_t softlinkinfo1; - h5tool_link_trg_info_t softlinkinfo2; - /* external link file id */ - hid_t extfile1_id = (-1); - hid_t extfile2_id = (-1); - h5tool_link_trg_info_t extlinkinfo1; - h5tool_link_trg_info_t extlinkinfo2; + /* to get link info */ + h5tool_link_info_t linkinfo1; + h5tool_link_info_t linkinfo2; - /* init softlink info */ - HDmemset(&softlinkinfo1, 0, sizeof(h5tool_link_trg_info_t)); - HDmemset(&softlinkinfo2, 0, sizeof(h5tool_link_trg_info_t)); - - /* init external link info */ - HDmemset(&extlinkinfo1, 0, sizeof(h5tool_link_trg_info_t)); - HDmemset(&extlinkinfo2, 0, sizeof(h5tool_link_trg_info_t)); + /* init link info struct */ + HDmemset(&linkinfo1, 0, sizeof(h5tool_link_info_t)); + HDmemset(&linkinfo2, 0, sizeof(h5tool_link_info_t)); i = h5trav_getindex (info1, obj1_name); j = h5trav_getindex (info2, obj2_name); @@ -1128,8 +1072,8 @@ hsize_t diff_compare(hid_t file1_id, } /* use the name with "/" first, as obtained by iterator function */ - obj1name = info1->paths[i].path; - obj2name = info2->paths[j].path; + obj1_name = info1->paths[i].path; + obj2_name = info2->paths[j].path; obj1type = info1->paths[i].type; obj2type = info2->paths[j].type; @@ -1137,151 +1081,157 @@ hsize_t diff_compare(hid_t file1_id, /*----------------------------------------------------------------- * follow link option, compare with target object */ - if (options->linkfollow) + if (options->follow_links) { - H5L_info_t li1, li2; + /* pass how to handle printing warning to linkinfo option */ + if(print_warn(options)) + linkinfo1.opt.msg_mode = linkinfo2.opt.msg_mode = 1; /*------------------------------------------------------------ * Soft links *------------------------------------------------------------*/ - /*------------------------ - * if object1 softlink - */ + /*-------------------------- + * if object1 soft link */ if (obj1type == H5TRAV_TYPE_LINK) { - if(H5Lget_info(file1_id, obj1_name, &li1, H5P_DEFAULT) < 0) + /* get type of target object */ + l_ret = H5tools_get_link_info(file1_id, obj1_name, &linkinfo1); + /* dangling link */ + if (l_ret == 0) { - parallel_print("error: unable to get link info from \"%s\"\n",obj1_name); - goto out; + if (options->no_dangle_links) + { + /* gangling link is error */ + if(options->m_verbose) + parallel_print("Warning: <%s> is a dangling link.\n", obj1_name); + options->err_stat = 1; + goto out; + } + else + is_dangle_link1 = 1; } - - softlinkinfo1.buf = (char*)HDcalloc(li1.u.val_size, sizeof(char)); - HDassert(softlinkinfo1.buf); - - /* get type and name of target object */ - if(H5tools_get_softlink_target_info(file1_id, obj1_name, li1, &softlinkinfo1)==0) + /* fail */ + else if(l_ret < 0) { - parallel_print("error: unable to get softlink info from \"%s\"\n",obj1_name); + options->err_stat = 1; goto out; } - - /* set target name and type to pass diff() */ - obj1type = softlinkinfo1.type; - obj1name = softlinkinfo1.path; + else /* OK */ + { + /* target type for diff() */ + obj1type = linkinfo1.trg_type; + } } - /*------------------------ - * if object2 is softlink - */ + /*----------------------------- + * if object2 is soft link */ if (obj2type == H5TRAV_TYPE_LINK) { - if(H5Lget_info(file2_id, obj2_name, &li2, H5P_DEFAULT) < 0) + /* get type target object */ + l_ret = H5tools_get_link_info(file2_id, obj2_name, &linkinfo2); + /* dangling link */ + if (l_ret == 0) { - parallel_print("error: unable to get link info from \"%s\"\n",obj2_name); - goto out; + if (options->no_dangle_links) + { + /* gangling link is error */ + if(options->m_verbose) + parallel_print("Warning: <%s> is a dangling link.\n", obj2_name); + options->err_stat = 1; + goto out; + } + else + is_dangle_link2=1; } - - - softlinkinfo2.buf = (char*)HDcalloc(li2.u.val_size, sizeof(char)); - HDassert(softlinkinfo2.buf); - - /* get type and name of target object */ - if(H5tools_get_softlink_target_info(file2_id, obj2_name, li2, &softlinkinfo2)==0) + /* fail */ + else if(l_ret < 0) { - parallel_print("error: unable to get softlink info from \"%s\"\n",obj2_name); + options->err_stat = 1; goto out; } - - /* set target name and type to pass diff() */ - obj2type = softlinkinfo2.type; - obj2name = softlinkinfo2.path; + else /* OK */ + { + /* target type for diff() */ + obj2type = linkinfo2.trg_type; + } } /*------------------------------------------------------------ * External links *------------------------------------------------------------*/ - /*------------------------------- - * if object1 is external link - */ + /*-------------------------------- + * if object1 is external link */ if (obj1type == H5TRAV_TYPE_UDLINK) { - if(H5Lget_info(file1_id, obj1_name, &li1, H5P_DEFAULT) < 0) - { - parallel_print("error: unable to get link info from \"%s\"\n",obj1_name); - goto out; - } - - /* for external link */ - if(li1.type == H5L_TYPE_EXTERNAL) + /* get type and name of target object */ + l_ret = H5tools_get_link_info(file1_id, obj1_name, &linkinfo1); + /* dangling link */ + if (l_ret == 0) { - extlinkinfo1.buf = (char*)HDcalloc(li1.u.val_size, sizeof(char)); - HDassert(extlinkinfo1.buf); - - /* get type and name of target object */ - if(H5tools_get_extlink_target_info(file1_id, obj1_name, li1, &extlinkinfo1)==0) + if (options->no_dangle_links) { - parallel_print("error: unable to get external link info from \"%s\"\n",obj1_name); + /* gangling link is error */ + if(options->m_verbose) + parallel_print("Warning: <%s> is a dangling link.\n", obj1_name); + options->err_stat = 1; goto out; } - - /* if valid actual object */ - if (extlinkinfo1.type < H5O_TYPE_GROUP || extlinkinfo1.type >= H5O_TYPE_NTYPES) - { - if (options->m_verbose) - { - parallel_print("<%s> is invaild type\n", obj1_name); - } - goto out; - } - - /* set target fileid, name and type to pass diff() */ - l_fileid1 = extlinkinfo1.extfile_id; - obj1name = extlinkinfo1.path; - obj1type = extlinkinfo1.type; + else + is_dangle_link1 = 1; } - } - - /*------------------------------- - * if object2 is external link - */ - if (obj2type == H5TRAV_TYPE_UDLINK) - { - if(H5Lget_info(file2_id, obj2_name, &li2, H5P_DEFAULT) < 0) + /* fail */ + else if(l_ret < 0) { - parallel_print("error: unable to get link info from \"%s\"\n",obj2_name); + options->err_stat = 1; goto out; } - /* for external link */ - if(li2.type == H5L_TYPE_EXTERNAL) + else /* OK */ { - extlinkinfo2.buf = (char*)HDcalloc(li2.u.val_size, sizeof(char)); - HDassert(extlinkinfo2.buf); + /* for external link */ + if(linkinfo1.linfo.type == H5L_TYPE_EXTERNAL) + obj1type = linkinfo1.trg_type; + } + } - /* get type and name of target object */ - if(H5tools_get_extlink_target_info(file2_id, obj2_name, li2, &extlinkinfo2)==0) - { - parallel_print("error: unable to get external link info from \"%s\"\n",obj2_name); - goto out; - } - /* if valid actual object */ - if (extlinkinfo2.type < H5O_TYPE_GROUP || extlinkinfo2.type >= H5O_TYPE_NTYPES) + /*-------------------------------- + * if object2 is external link */ + if (obj2type == H5TRAV_TYPE_UDLINK) + { + /* get type and name of target object */ + l_ret = H5tools_get_link_info(file2_id, obj2_name, &linkinfo2); + /* dangling link */ + if (l_ret == 0) + { + if (options->no_dangle_links) { - if (options->m_verbose) - { - parallel_print("<%s> is invaild type\n", obj2_name); - } + /* gangling link is error */ + if(options->m_verbose) + parallel_print("Warning: <%s> is a dangling link.\n", obj2_name); + options->err_stat = 1; goto out; } - - /* set target fileid, name and type to pass diff() */ - l_fileid2 = extlinkinfo2.extfile_id; - obj2name = extlinkinfo2.path; - obj2type = extlinkinfo2.type; + else + is_dangle_link2 = 1; + } + /* fail */ + else if(l_ret < 0) + { + options->err_stat = 1; + goto out; + } + else /* OK */ + { + /* for external link */ + if(linkinfo2.linfo.type == H5L_TYPE_EXTERNAL) + obj2type = linkinfo2.trg_type; } } - } /* end of linkfollow */ + /* found dangling link */ + if (is_dangle_link1 || is_dangle_link2) + goto out; + } /* end of follow_links */ /* objects are not the same type */ if (obj1type != obj2type) @@ -1289,45 +1239,53 @@ hsize_t diff_compare(hid_t file1_id, if (options->m_verbose||options->m_list_not_cmp) { parallel_print("<%s> is of type %s and <%s> is of type %s\n", - obj1name, get_type(obj1type), obj2name, - get_type(obj2type)); + obj1_name, get_type(obj1type), + obj2_name, get_type(obj2type)); } options->not_cmp=1; goto out; } - nfound = diff(l_fileid1, obj1name, - l_fileid2, obj2name, + nfound = diff(file1_id, obj1_name, + file2_id, obj2_name, options, obj1type); out: - /* free soft link buffer */ - if (softlinkinfo1.buf) - HDfree(softlinkinfo1.buf); - if (softlinkinfo2.buf) - HDfree(softlinkinfo2.buf); - /* free external link buffer */ - if (extlinkinfo1.buf); + /*------------------------------- + * handle dangling link(s) */ + /* both obj1 and obj2 are dangling links */ + if(is_dangle_link1 && is_dangle_link2) { - HDfree(extlinkinfo1.buf); - /* case for ext-link's target is soft-link */ - if(extlinkinfo1.is_path_malloced) - HDfree(extlinkinfo1.path); + if(print_objname(options, nfound)) + { + do_print_objname("dangling link", obj1_name, obj2_name); + print_found(nfound); + } } - if (extlinkinfo2.buf); + /* obj1 is dangling link */ + else if (is_dangle_link1) { - HDfree(extlinkinfo2.buf); - /* case for ext-link's target is soft-link */ - if(extlinkinfo2.is_path_malloced) - HDfree(extlinkinfo2.path); + if(options->m_verbose) + parallel_print("obj1 <%s> is a dangling link.\n", obj1_name); + nfound++; + if(print_objname(options, nfound)) + print_found(nfound); } - - /* close external file */ - H5E_BEGIN_TRY + /* obj2 is dangling link */ + else if (is_dangle_link2) { - H5Fclose(extfile1_id); - H5Fclose(extfile2_id); - } H5E_END_TRY; + if(options->m_verbose) + parallel_print("obj2 <%s> is a dangling link.\n", obj2_name); + nfound++; + if(print_objname(options, nfound)) + print_found(nfound); + } + + /* free link info buffer */ + if (linkinfo1.trg_path) + HDfree(linkinfo1.trg_path); + if (linkinfo2.trg_path) + HDfree(linkinfo2.trg_path); return nfound; } @@ -1346,9 +1304,10 @@ out: * Return: Number of differences found * * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * * Date: May 9, 2003 * + * Programmer: Jonathan Kim + * - add following links feature (Feb 11,2010) *------------------------------------------------------------------------- */ @@ -1364,24 +1323,28 @@ hsize_t diff(hid_t file1_id, hid_t grp1_id = (-1); hid_t grp2_id = (-1); int ret; + int is_dangle_link1 = 0; + int is_dangle_link2 = 0; hsize_t nfound = 0; - char *extlinkbuf1=NULL; - char *extlinkbuf2=NULL; - /* used in soft link case (H5TRAV_TYPE_LINK) */ - h5tool_link_trg_info_t softlinkinfo1; - h5tool_link_trg_info_t softlinkinfo2; - /*init */ - HDmemset(&softlinkinfo1,0,sizeof(h5tool_link_trg_info_t)); - HDmemset(&softlinkinfo2,0,sizeof(h5tool_link_trg_info_t)); - + /* to get link info */ + h5tool_link_info_t linkinfo1; + h5tool_link_info_t linkinfo2; + + /*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)) + linkinfo1.opt.msg_mode = linkinfo2.opt.msg_mode = 1; switch(type) { - /*------------------------------------------------------------------------- + /*---------------------------------------------------------------------- * H5TRAV_TYPE_DATASET - *------------------------------------------------------------------------- + *---------------------------------------------------------------------- */ case H5TRAV_TYPE_DATASET: /* verbose (-v) and report (-r) mode */ @@ -1409,9 +1372,9 @@ hsize_t diff(hid_t file1_id, } break; - /*------------------------------------------------------------------------- + /*---------------------------------------------------------------------- * H5TRAV_TYPE_NAMED_DATATYPE - *------------------------------------------------------------------------- + *---------------------------------------------------------------------- */ case H5TRAV_TYPE_NAMED_DATATYPE: if((type1_id = H5Topen2(file1_id, path1, H5P_DEFAULT)) < 0) @@ -1432,10 +1395,11 @@ hsize_t diff(hid_t file1_id, if(options->m_verbose) print_found(nfound); - /*------------------------------------------------------------------------- + /*----------------------------------------------------------------- * compare attributes - * the if condition refers to cases when the dataset is a referenced object - *------------------------------------------------------------------------- + * the if condition refers to cases when the dataset is a + * referenced object + *----------------------------------------------------------------- */ if(path1) nfound += diff_attr(type1_id, type2_id, path1, path2, options); @@ -1446,9 +1410,9 @@ hsize_t diff(hid_t file1_id, goto out; break; - /*------------------------------------------------------------------------- + /*---------------------------------------------------------------------- * H5TRAV_TYPE_GROUP - *------------------------------------------------------------------------- + *---------------------------------------------------------------------- */ case H5TRAV_TYPE_GROUP: ret = HDstrcmp(path1, path2); @@ -1468,10 +1432,11 @@ hsize_t diff(hid_t file1_id, if((grp2_id = H5Gopen2(file2_id, path2, H5P_DEFAULT)) < 0) goto out; - /*------------------------------------------------------------------------- + /*----------------------------------------------------------------- * compare attributes - * the if condition refers to cases when the dataset is a referenced object - *------------------------------------------------------------------------- + * the if condition refers to cases when the dataset is a + * referenced object + *----------------------------------------------------------------- */ if(path1) nfound += diff_attr(grp1_id, grp2_id, path1, path2, options); @@ -1483,42 +1448,54 @@ hsize_t diff(hid_t file1_id, break; - /*------------------------------------------------------------------------- + /*---------------------------------------------------------------------- * H5TRAV_TYPE_LINK - *------------------------------------------------------------------------- + *---------------------------------------------------------------------- */ case H5TRAV_TYPE_LINK: { - H5L_info_t li1, li2; - - if(H5Lget_info(file1_id, path1, &li1, H5P_DEFAULT) < 0) + /* get type and name of target object */ + ret = H5tools_get_link_info(file1_id, path1, &linkinfo1); + /* dangling link */ + if (ret == 0) { - parallel_print("error: unable to get link info from \"%s\"\n", path1); - goto out; + if (options->no_dangle_links) + { + /* gangling link is error */ + if(options->m_verbose) + parallel_print("Warning: <%s> is a dangling link.\n", path1); + goto out; + } + else + is_dangle_link1 = 1; } - if(H5Lget_info(file2_id, path2, &li2, H5P_DEFAULT) < 0) - { - parallel_print("error: unable to get link info from \"%s\"\n", path2); + else if (ret < 0) goto out; - } - - softlinkinfo1.buf = (char*)HDcalloc(li1.u.val_size, sizeof(char)); - HDassert(softlinkinfo1.buf); - softlinkinfo2.buf = (char*)HDcalloc(li2.u.val_size, sizeof(char)); - HDassert(softlinkinfo2.buf); - if(H5tools_get_softlink_target_info(file1_id,path1,li1,&softlinkinfo1)==0) + /* get type and name of target object */ + ret = H5tools_get_link_info(file2_id, path2, &linkinfo2); + /* dangling link */ + if (ret == 0) { - parallel_print("error: unable to get softlink info from \"%s\"\n", path1); - goto out; + if (options->no_dangle_links) + { + /* gangling link is error */ + if(options->m_verbose) + parallel_print("Warning: <%s> is a dangling link.\n", path2); + goto out; + } + else + is_dangle_link2 = 1; } - if(H5tools_get_softlink_target_info(file2_id,path2,li2,&softlinkinfo2)==0) - { - parallel_print("error: unable to get softlink info from \"%s\"\n", path2); + else if (ret < 0) goto out; - } + + + /* found dangling link */ + if (is_dangle_link1 || is_dangle_link2) + goto out2; - ret = HDstrcmp(softlinkinfo1.path, softlinkinfo2.path); + ret = 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; @@ -1526,113 +1503,122 @@ hsize_t diff(hid_t file1_id, if(print_objname(options, nfound)) do_print_objname("link", path1, path2); - if (options->linkfollow) + if (options->follow_links) { /* objects are not the same type */ - if (softlinkinfo1.type != softlinkinfo2.type) + if (linkinfo1.trg_type != linkinfo2.trg_type) { if (options->m_verbose||options->m_list_not_cmp) { - parallel_print("<%s> is of type %d and <%s> is of type %d\n", softlinkinfo1.path, softlinkinfo1.type, softlinkinfo2.path, softlinkinfo2.type); + parallel_print("<%s> is of type %s and <%s> is of type %s\n", path1, get_type(linkinfo1.trg_type), path2, get_type(linkinfo2.trg_type)); } options->not_cmp=1; goto out; } - nfound += diff(file1_id, softlinkinfo1.path, - file2_id, softlinkinfo2.path, - options, softlinkinfo1.type); + /* call self to compare target object */ + nfound += diff(file1_id, path1, + file2_id, path2, + options, linkinfo1.trg_type); } /* always print the number of differences found in verbose mode */ if(options->m_verbose) print_found(nfound); - HDfree(softlinkinfo1.buf); - HDfree(softlinkinfo2.buf); + /* free link info buffer */ + HDfree(linkinfo1.trg_path); + HDfree(linkinfo2.trg_path); } break; - /*------------------------------------------------------------------------- + /*---------------------------------------------------------------------- * H5TRAV_TYPE_UDLINK - *------------------------------------------------------------------------- + *---------------------------------------------------------------------- */ case H5TRAV_TYPE_UDLINK: { - H5L_info_t li1, li2; - - if(H5Lget_info(file1_id, path1, &li1, H5P_DEFAULT) < 0) + /* get type and name of target object */ + ret = H5tools_get_link_info(file1_id, path1, &linkinfo1); + /* dangling link */ + if (ret == 0) { - parallel_print("error: unable to get udlink info from \"%s\"\n", path1); - goto out; + if (options->no_dangle_links) + { + /* gangling link is error */ + if(options->m_verbose) + parallel_print("Warning: <%s> is a dangling link.\n", path1); + goto out; + } + else + is_dangle_link1=1; } - if(H5Lget_info(file2_id, path2, &li2, H5P_DEFAULT) < 0) - { - parallel_print("error: unable to get udlink info from \"%s\"\n", path2); + else if (ret < 0) goto out; - } - /* Only external links will have a query function registered */ - if(li1.type == H5L_TYPE_EXTERNAL && li2.type == H5L_TYPE_EXTERNAL) + /* get type and name of target object */ + ret = H5tools_get_link_info(file2_id, path2, &linkinfo2); + /* dangling link */ + if (ret == 0) { - - extlinkbuf1 = (char*)HDcalloc(li1.u.val_size, sizeof(char)); - HDassert(extlinkbuf1); - extlinkbuf2 = (char*)HDcalloc(li2.u.val_size, sizeof(char)); - HDassert(extlinkbuf2); - - if(H5Lget_val(file1_id, path1, extlinkbuf1, li1.u.val_size, H5P_DEFAULT) < 0) - { - parallel_print("error: unable to get link value from \"%s\"\n",path1); - goto out; - } /* end if */ - if(H5Lget_val(file2_id, path2, extlinkbuf2, li2.u.val_size, H5P_DEFAULT) < 0) + if (options->no_dangle_links) { - parallel_print("error: unable to get link value from \"%s\"\n",path2); + /* gangling link is error */ + if(options->m_verbose) + parallel_print("Warning: <%s> is a dangling link.\n", path2); goto out; - } /* end if */ + } + else + is_dangle_link2=1; + } + else if (ret < 0) + goto out; + + /* found dangling link */ + if (is_dangle_link1 || is_dangle_link2) + goto out2; + /* 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(li1.u.val_size == li2.u.val_size) + if(linkinfo1.linfo.u.val_size == linkinfo2.linfo.u.val_size) { - ret = HDmemcmp(extlinkbuf1, extlinkbuf2, li1.u.val_size); + ret = HDmemcmp(linkinfo1.trg_path, linkinfo2.trg_path, linkinfo1.linfo.u.val_size); } else ret = 1; - /* if "extlinkbuf1" != "extlinkbuf2" then the links are "different" */ + /* 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(print_objname(options, nfound)) do_print_objname("external link", path1, path2); - if (options->linkfollow) + if (options->follow_links) { - const char *extlink_file1; - const char *extlink_path1; - const char *extlink_file2; - const char *extlink_path2; - - /* get file name and obj path */ - if(H5Lunpack_elink_val(extlinkbuf1, li1.u.val_size, NULL, &extlink_file1, &extlink_path1)<0) + /* objects are not the same type */ + if (linkinfo1.trg_type != linkinfo2.trg_type) { - parallel_print("error: unable to unpack external link value of obj1\n"); - goto out; - } - - /* get file name and obj path */ - if(H5Lunpack_elink_val(extlinkbuf2, li2.u.val_size, NULL, &extlink_file2, &extlink_path2)<0) - { - parallel_print("error: unable to unpack external link value of obj2\n"); + if (options->m_verbose||options->m_list_not_cmp) + { + parallel_print("<%s> is of type %s and <%s> is of type %s\n", path1, get_type(linkinfo1.trg_type), path2, get_type(linkinfo2.trg_type)); + } + options->not_cmp=1; goto out; } - nfound = h5diff(extlink_file1, extlink_file2, - extlink_path1, extlink_path2, options); + nfound = diff(file1_id, path1, + file2_id, path2, + options, linkinfo1.trg_type); } - HDfree(extlinkbuf1); - HDfree(extlinkbuf2); + /* free link info buffer */ + HDfree(linkinfo1.trg_path); + HDfree(linkinfo2.trg_path); } /* end if */ else { @@ -1643,7 +1629,8 @@ hsize_t diff(hid_t file1_id, * If the link classes or the buffer length are not the * same, the links are "different" */ - if((li1.type != li2.type) || (li1.u.val_size != li2.u.val_size)) + if((linkinfo1.linfo.type != linkinfo2.linfo.type) || + (linkinfo1.linfo.u.val_size != linkinfo2.linfo.u.val_size)) nfound = 1; else nfound = 0; @@ -1671,17 +1658,43 @@ hsize_t diff(hid_t file1_id, out: options->err_stat = 1; - /* free buf used for softlink */ - if (softlinkinfo1.buf) - HDfree(softlinkinfo1.buf); - if (softlinkinfo2.buf) - HDfree(softlinkinfo2.buf); - - /* free buf used for softlink */ - if (extlinkbuf1) - HDfree(extlinkbuf1); - if (extlinkbuf2) - HDfree(extlinkbuf2); +out2: + /*----------------------------------- + * handle dangling link(s) + */ + /* 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); + print_found(nfound); + } + } + /* path1 is dangling link */ + else if (is_dangle_link1) + { + if(options->m_verbose) + parallel_print("obj1 <%s> is a dangling link.\n", path1); + nfound++; + if(print_objname(options, nfound)) + print_found(nfound); + } + /* path2 is dangling link */ + else if (is_dangle_link2) + { + if(options->m_verbose) + parallel_print("obj2 <%s> is a dangling link.\n", path2); + nfound++; + if(print_objname(options, nfound)) + print_found(nfound); + } + + /* free link info buffer */ + if (linkinfo1.trg_path) + HDfree(linkinfo1.trg_path); + if (linkinfo2.trg_path) + HDfree(linkinfo2.trg_path); /* close */ /* disable error reporting */ diff --git a/tools/lib/h5diff.h b/tools/lib/h5diff.h index 090d3d9..6718d9a 100644 --- a/tools/lib/h5diff.h +++ b/tools/lib/h5diff.h @@ -35,7 +35,8 @@ typedef struct { double percent; /* relative error value */ int n; /* count, compare up to count */ hsize_t count; /* count value */ - int linkfollow; /* link follow*/ + int follow_links; /* follow symbolic links */ + int no_dangle_links; /* return error when find dangling link */ int err_stat; /* an error ocurred (1, error, 0, no error) */ int cmn_objs; /* do we have common objects */ int not_cmp; /* are the objects comparable */ diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c index 91acb10..48e08a5 100644 --- a/tools/lib/h5diff_array.c +++ b/tools/lib/h5diff_array.c @@ -74,7 +74,7 @@ #define ULLI_FORMAT_P_NOTCOMP "%-15"H5_PRINTF_LL_WIDTH"u %-15"H5_PRINTF_LL_WIDTH"u %-15"H5_PRINTF_LL_WIDTH"d not comparable\n" -/* if system EPSILON is defined, use the system EPSILON; otherwise, use +/* if system EPSILON is defined, use the system EPSILON; otherwise, use constants that are close to most EPSILON values */ #ifndef FLT_EPSILON @@ -167,7 +167,7 @@ static void h5diff_print_char(char ch); #if H5_SIZEOF_LONG_DOUBLE !=0 typedef enum dtype_t { - FLT_FLOAT, + FLT_FLOAT, FLT_DOUBLE, FLT_LDOUBLE } dtype_t; @@ -175,7 +175,7 @@ typedef enum dtype_t typedef enum dtype_t { - FLT_FLOAT, + FLT_FLOAT, FLT_DOUBLE } dtype_t; #endif @@ -227,7 +227,7 @@ hsize_t diff_array( void *_mem1, if ( rank > 0 ) { - + acc[rank-1]=1; for(j=(rank-2); j>=0; j--) { @@ -275,7 +275,7 @@ hsize_t diff_array( void *_mem1, */ 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); else if (H5Tequal(m_type, H5T_NATIVE_DOUBLE)) @@ -283,7 +283,7 @@ hsize_t diff_array( void *_mem1, #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); -#endif +#endif break; case H5T_INTEGER: @@ -747,7 +747,8 @@ hsize_t diff_datum(void *_mem1, NULL, options); else { - parallel_print("Warning: Comparison not possible of object types referenced: <%s> and <%s>", + if(options->m_verbose) + parallel_print("Warning: Comparison not possible of object types referenced: <%s> and <%s>\n", obj1, obj2); options->not_cmp = 1; } @@ -1862,7 +1863,7 @@ hsize_t diff_datum(void *_mem1, nfound++; } - } + } /* one is NaN, assume difference */ else if ( isnan1==1 || isnan2==1) { @@ -1925,7 +1926,7 @@ hsize_t diff_datum(void *_mem1, nfound++; } - } + } /* one is NaN, assume difference */ else if ( isnan1==1 || isnan2==1) { @@ -1991,7 +1992,7 @@ hsize_t diff_datum(void *_mem1, nfound++; } - } + } /* one is NaN, assume difference */ else if ( isnan1==1 || isnan2==1) { @@ -2074,7 +2075,7 @@ hsize_t diff_datum(void *_mem1, nfound++; } - } + } /* one is NaN, assume difference */ else if ( isnan1==1 || isnan2==1) { @@ -2139,7 +2140,7 @@ hsize_t diff_datum(void *_mem1, nfound++; } - } + } /* one is NaN, assume difference */ else if ( isnan1==1 || isnan2==1) { @@ -2205,7 +2206,7 @@ hsize_t diff_datum(void *_mem1, nfound++; } - } + } /* one is NaN, assume difference */ else if ( isnan1==1 || isnan2==1) { @@ -2889,7 +2890,7 @@ hsize_t diff_float(unsigned char *mem1, } nfound++; } - } + } /* one is NaN, assume difference */ else if ( isnan1==1 || isnan2==1) { @@ -2961,7 +2962,7 @@ hsize_t diff_float(unsigned char *mem1, } nfound++; } - } + } /* one is NaN, assume difference */ else if ( isnan1==1 || isnan2==1) { @@ -3036,7 +3037,7 @@ hsize_t diff_float(unsigned char *mem1, nfound++; } - } + } /* one is NaN, assume difference */ else if ( isnan1==1 || isnan2==1) { @@ -3163,7 +3164,7 @@ hsize_t diff_double(unsigned char *mem1, } nfound++; } - } + } /* one is NaN, assume difference */ else if ( isnan1==1 || isnan2==1) { @@ -3235,7 +3236,7 @@ hsize_t diff_double(unsigned char *mem1, } nfound++; } - } + } /* one is NaN, assume difference */ else if ( isnan1==1 || isnan2==1) { @@ -3310,7 +3311,7 @@ hsize_t diff_double(unsigned char *mem1, nfound++; } - } + } /* one is NaN, assume difference */ else if ( isnan1==1 || isnan2==1) { @@ -3446,7 +3447,7 @@ hsize_t diff_ldouble(unsigned char *mem1, } nfound++; } - } + } /* one is NaN, assume difference */ else if ( isnan1==1 || isnan2==1) { @@ -3518,7 +3519,7 @@ hsize_t diff_ldouble(unsigned char *mem1, } nfound++; } - } + } /* one is NaN, assume difference */ else if ( isnan1==1 || isnan2==1) { @@ -3593,7 +3594,7 @@ hsize_t diff_ldouble(unsigned char *mem1, nfound++; } - } + } /* one is NaN, assume difference */ else if ( isnan1==1 || isnan2==1) { @@ -5511,14 +5512,14 @@ hbool_t equal_double(double value, double expected, diff_opt_t *options) { if ( options->do_nans ) { - + /*------------------------------------------------------------------------- * detect NaNs *------------------------------------------------------------------------- */ int isnan1 = my_isnan(FLT_DOUBLE,&value); int isnan2 = my_isnan(FLT_DOUBLE,&expected); - + /*------------------------------------------------------------------------- * we consider NaN == NaN to be true *------------------------------------------------------------------------- @@ -5527,7 +5528,7 @@ hbool_t equal_double(double value, double expected, diff_opt_t *options) { return TRUE; } - + /*------------------------------------------------------------------------- * one is a NaN, do not compare but assume difference *------------------------------------------------------------------------- @@ -5535,7 +5536,7 @@ hbool_t equal_double(double value, double expected, diff_opt_t *options) if ( (isnan1 && !isnan2) || ( !isnan1 && isnan2 ) ) { return FALSE; - } + } } if (value == expected) @@ -5564,14 +5565,14 @@ hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *optio { if ( options->do_nans ) { - + /*------------------------------------------------------------------------- * detect NaNs *------------------------------------------------------------------------- */ int isnan1 = my_isnan(FLT_LDOUBLE,&value); int isnan2 = my_isnan(FLT_LDOUBLE,&expected); - + /*------------------------------------------------------------------------- * we consider NaN == NaN to be true *------------------------------------------------------------------------- @@ -5580,7 +5581,7 @@ hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *optio { return TRUE; } - + /*------------------------------------------------------------------------- * one is a NaN, do not compare but assume difference *------------------------------------------------------------------------- @@ -5588,7 +5589,7 @@ hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *optio if ( (isnan1 && !isnan2) || ( !isnan1 && isnan2 ) ) { return FALSE; - } + } } if (value == expected) @@ -5603,7 +5604,7 @@ hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *optio } #endif /* #if H5_SIZEOF_LONG_DOUBLE !=0 */ - + /*------------------------------------------------------------------------- * Function: equal_float @@ -5621,14 +5622,14 @@ hbool_t equal_float(float value, float expected, diff_opt_t *options) { if ( options->do_nans ) { - + /*------------------------------------------------------------------------- * detect NaNs *------------------------------------------------------------------------- */ int isnan1 = my_isnan(FLT_FLOAT,&value); int isnan2 = my_isnan(FLT_FLOAT,&expected); - + /*------------------------------------------------------------------------- * we consider NaN == NaN to be true *------------------------------------------------------------------------- @@ -5637,7 +5638,7 @@ hbool_t equal_float(float value, float expected, diff_opt_t *options) { return TRUE; } - + /*------------------------------------------------------------------------- * one is a NaN, do not compare but assume difference *------------------------------------------------------------------------- @@ -5645,7 +5646,7 @@ hbool_t equal_float(float value, float expected, diff_opt_t *options) if ( (isnan1 && !isnan2) || ( !isnan1 && isnan2 ) ) { return FALSE; - } + } } if (value == expected) @@ -5946,13 +5947,13 @@ void print_char_pos( int *ph, /* print header */ parallel_print("[ " ); if ( rank > 0 ) { - + for ( i = 0; i < rank; i++) { parallel_print(HSIZE_T_FORMAT, (unsigned long long)pos[i]); parallel_print(" "); } - + } else { @@ -5970,8 +5971,8 @@ void print_char_pos( int *ph, /* print header */ */ static void h5diff_print_char(char ch) { - - switch (ch) + + switch (ch) { case '"': parallel_print("\\\""); @@ -5999,7 +6000,7 @@ static void h5diff_print_char(char ch) parallel_print( "%c", ch); else parallel_print( "\\%03o", ch); - + break; } } diff --git a/tools/lib/h5diff_dset.c b/tools/lib/h5diff_dset.c index 2cc84ca..8e25b6d 100644 --- a/tools/lib/h5diff_dset.c +++ b/tools/lib/h5diff_dset.c @@ -44,36 +44,36 @@ hsize_t diff_dataset( hid_t file1_id, hid_t dcpl1 = -1; hid_t dcpl2 = -1; hsize_t nfound = 0; - + /*------------------------------------------------------------------------- * open the handles *------------------------------------------------------------------------- */ /* disable error reporting */ - H5E_BEGIN_TRY + H5E_BEGIN_TRY { /* Open the datasets */ - if((did1 = H5Dopen2(file1_id, obj1_name, H5P_DEFAULT)) < 0) + 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) + 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; - - + + if((dcpl1 = H5Dget_create_plist(did1)) < 0) goto error; if((dcpl2 = H5Dget_create_plist(did2)) < 0) { goto error; } - + /*------------------------------------------------------------------------- * check if the dataset creation property list has filters that * are not registered in the current configuration @@ -103,9 +103,9 @@ hsize_t diff_dataset( hid_t file1_id, /* enable error reporting */ } H5E_END_TRY; - + return nfound; - + error: options->err_stat=1; /* disable error reporting */ @@ -116,7 +116,7 @@ error: H5Dclose(did2); /* enable error reporting */ } H5E_END_TRY; - + return nfound; } @@ -214,56 +214,56 @@ hsize_t diff_datasetid( hid_t did1, void *sm_buf2=NULL; size_t need; /* bytes needed for malloc */ int i; - + /* Get the dataspace handle */ if ( (sid1 = H5Dget_space(did1)) < 0 ) goto error; - + /* Get rank */ if ( (rank1 = H5Sget_simple_extent_ndims(sid1)) < 0 ) goto error; - + /* Get the dataspace handle */ if ( (sid2 = H5Dget_space(did2)) < 0 ) goto error; - + /* Get rank */ if ( (rank2 = H5Sget_simple_extent_ndims(sid2)) < 0 ) goto error; - + /* Get dimensions */ if ( H5Sget_simple_extent_dims(sid1,dims1,maxdim1) < 0 ) goto error; - + /* Get dimensions */ if ( H5Sget_simple_extent_dims(sid2,dims2,maxdim2) < 0 ) { goto error; } - + /*------------------------------------------------------------------------- * get the file data type *------------------------------------------------------------------------- */ - + /* Get the data type */ if ( (f_tid1 = H5Dget_type(did1)) < 0 ) goto error; - + /* Get the data type */ if ( (f_tid2 = H5Dget_type(did2)) < 0 ) { goto error; } - + /*------------------------------------------------------------------------- * check for empty datasets *------------------------------------------------------------------------- */ - + storage_size1=H5Dget_storage_size(did1); storage_size2=H5Dget_storage_size(did2); - + if (storage_size1==0 || storage_size2==0) { if ( (options->m_verbose||options->m_list_not_cmp) && obj1_name && obj2_name) @@ -271,12 +271,12 @@ hsize_t diff_datasetid( hid_t did1, can_compare=0; options->not_cmp=1; } - + /*------------------------------------------------------------------------- * check for comparable TYPE and SPACE *------------------------------------------------------------------------- */ - + if (diff_can_type(f_tid1, f_tid2, rank1, @@ -292,46 +292,46 @@ hsize_t diff_datasetid( hid_t did1, { can_compare=0; } - + /*------------------------------------------------------------------------- * memory type and sizes *------------------------------------------------------------------------- */ if ((m_tid1=h5tools_get_native_type(f_tid1)) < 0) goto error; - + if ((m_tid2=h5tools_get_native_type(f_tid2)) < 0) goto error; - + m_size1 = H5Tget_size( m_tid1 ); m_size2 = H5Tget_size( m_tid2 ); - + /*------------------------------------------------------------------------- * check for different signed/unsigned types *------------------------------------------------------------------------- */ - + sign1=H5Tget_sign(m_tid1); sign2=H5Tget_sign(m_tid2); if ( sign1 != sign2 ) { - if ((options->m_verbose||options->m_list_not_cmp) && obj1_name && obj2_name) + if ((options->m_verbose||options->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; } - + /*------------------------------------------------------------------------- * only attempt to compare if possible *------------------------------------------------------------------------- */ if (can_compare ) /* it is possible to compare */ { - + /*------------------------------------------------------------------------- * get number of elements *------------------------------------------------------------------------- @@ -341,43 +341,43 @@ hsize_t diff_datasetid( hid_t did1, { nelmts1 *= dims1[i]; } - + nelmts2 = 1; for (i = 0; i < rank2; i++) { nelmts2 *= dims2[i]; } - + assert(nelmts1==nelmts2); - + /*------------------------------------------------------------------------- * "upgrade" the smaller memory size *------------------------------------------------------------------------- */ - + if ( m_size1 != m_size2 ) { if ( m_size1 < m_size2 ) { H5Tclose(m_tid1); - + if ((m_tid1=h5tools_get_native_type(f_tid2)) < 0) goto error; - + m_size1 = H5Tget_size( m_tid1 ); } else { H5Tclose(m_tid2); - + if ((m_tid2=h5tools_get_native_type(f_tid1)) < 0) goto error; - + m_size2 = H5Tget_size( m_tid2 ); } } assert(m_size1==m_size2); - + /* print names */ if (obj1_name) { name1=diff_basename(obj1_name); @@ -385,27 +385,27 @@ hsize_t diff_datasetid( hid_t did1, if (obj2_name) { name2=diff_basename(obj2_name); } - - + + /*------------------------------------------------------------------------- * read/compare *------------------------------------------------------------------------- */ - + need = (size_t)(nelmts1*m_size1); /* bytes needed */ if ( need < H5TOOLS_MALLOCSIZE) { buf1 = HDmalloc(need); buf2 = HDmalloc(need); } - + if ( buf1!=NULL && buf2!=NULL) { if ( H5Dread(did1,m_tid1,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf1) < 0 ) goto error; if ( H5Dread(did2,m_tid2,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf2) < 0 ) goto error; - + /* array diff */ nfound = diff_array(buf1, buf2, @@ -420,39 +420,39 @@ hsize_t diff_datasetid( hid_t did1, did1, did2); } - + else /* possibly not enough memory, read/compare by hyperslabs */ - + { size_t p_type_nbytes = m_size1; /*size of memory type */ hsize_t p_nelmts = nelmts1; /*total selected elmts */ hsize_t elmtno; /*counter */ int carry; /*counter carry value */ unsigned int vl_data = 0; /*contains VL datatypes */ - + /* stripmine info */ hsize_t sm_size[H5S_MAX_RANK]; /*stripmine size */ hsize_t sm_nbytes; /*bytes per stripmine */ hsize_t sm_nelmts; /*elements per stripmine*/ hid_t sm_space; /*stripmine data space */ - + /* hyperslab info */ hsize_t hs_offset[H5S_MAX_RANK]; /*starting offset */ hsize_t hs_size[H5S_MAX_RANK]; /*size this pass */ hsize_t hs_nelmts; /*elements in request */ hsize_t zero[8]; /*vector of zeros */ - + /* check if we have VL data in the dataset's datatype */ if (H5Tdetect_class(m_tid1, H5T_VLEN) == TRUE) vl_data = TRUE; - + /* * determine the strip mine size and allocate a buffer. The strip mine is * a hyperslab whose size is manageable. */ sm_nbytes = p_type_nbytes; - - for (i = rank1; i > 0; --i) + + for (i = rank1; i > 0; --i) { hsize_t size = H5TOOLS_BUFSIZE / sm_nbytes; if ( size == 0) /* datum size > H5TOOLS_BUFSIZE */ @@ -461,7 +461,7 @@ hsize_t diff_datasetid( hid_t did1, sm_nbytes *= sm_size[i - 1]; assert(sm_nbytes > 0); } - + /* malloc return code should be verified. * If fail, need to handle the error. * This else branch should be recoded as a separate function. @@ -473,14 +473,14 @@ hsize_t diff_datasetid( hid_t did1, assert(sm_buf1); sm_buf2 = malloc((size_t)sm_nbytes); assert(sm_buf2); - + sm_nelmts = sm_nbytes / p_type_nbytes; sm_space = H5Screate_simple(1, &sm_nelmts, NULL); - + /* the stripmine loop */ memset(hs_offset, 0, sizeof hs_offset); memset(zero, 0, sizeof zero); - + for (elmtno = 0; elmtno < p_nelmts; elmtno += hs_nelmts) { /* calculate the hyperslab size */ @@ -505,12 +505,12 @@ hsize_t diff_datasetid( hid_t did1, H5Sselect_all(sm_space); hs_nelmts = 1; } /* rank */ - + if ( H5Dread(did1,m_tid1,sm_space,sid1,H5P_DEFAULT,sm_buf1) < 0 ) goto error; if ( H5Dread(did2,m_tid2,sm_space,sid2,H5P_DEFAULT,sm_buf2) < 0 ) goto error; - + /* get array differences. in the case of hyperslab read, increment the number of differences found in each hyperslab and pass the position at the beggining for printing */ nfound += diff_array(sm_buf1, @@ -525,14 +525,14 @@ hsize_t diff_datasetid( hid_t did1, m_tid1, did1, did2); - + /* reclaim any VL memory, if necessary */ if(vl_data) { H5Dvlen_reclaim(m_tid1, sm_space, H5P_DEFAULT, sm_buf1); H5Dvlen_reclaim(m_tid1, sm_space, H5P_DEFAULT, sm_buf2); } - + /* calculate the next hyperslab offset */ for (i = rank1, carry = 1; i > 0 && carry; --i) { @@ -543,27 +543,27 @@ hsize_t diff_datasetid( hid_t did1, carry = 0; } /* i */ } /* elmtno */ - + H5Sclose(sm_space); } /* hyperslab read */ }/*can_compare*/ - + /*------------------------------------------------------------------------- * compare attributes * the if condition refers to cases when the dataset is a referenced object *------------------------------------------------------------------------- */ - + if (obj1_name) { nfound += diff_attr(did1,did2,obj1_name,obj2_name,options); } - + /*------------------------------------------------------------------------- * close *------------------------------------------------------------------------- */ - + /* free */ if (buf1!=NULL) { @@ -585,7 +585,7 @@ hsize_t diff_datasetid( hid_t did1, free(sm_buf2); sm_buf2=NULL; } - + H5E_BEGIN_TRY { H5Sclose(sid1); H5Sclose(sid2); @@ -594,12 +594,12 @@ hsize_t diff_datasetid( hid_t did1, H5Tclose(m_tid1); H5Tclose(m_tid2); } H5E_END_TRY; - + return nfound; - + error: options->err_stat=1; - + /* free */ if (buf1!=NULL) { @@ -621,7 +621,7 @@ error: free(sm_buf2); sm_buf2=NULL; } - + /* disable error reporting */ H5E_BEGIN_TRY { H5Sclose(sid1); @@ -632,7 +632,7 @@ error: H5Tclose(m_tid2); /* enable error reporting */ } H5E_END_TRY; - + return nfound; } @@ -666,64 +666,64 @@ int diff_can_type( hid_t f_tid1, /* file data type */ diff_opt_t *options, int is_compound) { - - + + 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 */ - + /*------------------------------------------------------------------------- * check for the same class *------------------------------------------------------------------------- */ - + if ((tclass1=H5Tget_class(f_tid1)) < 0) return -1; - + if ((tclass2=H5Tget_class(f_tid2)) < 0) return -1; - + if ( tclass1 != tclass2 ) { if ( (options->m_verbose||options->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), obj2_name, get_class(tclass2) ); - + } - + else - + { - + parallel_print("Not comparable: <%s> is of class %s and <%s> is of class %s\n", obj1_name, get_class(tclass1), obj2_name, get_class(tclass2) ); - + } } - + can_compare = 0; options->not_cmp = 1; return can_compare; } - + /*------------------------------------------------------------------------- * check for non supported classes *------------------------------------------------------------------------- */ - + assert(tclass1==tclass2); switch (tclass1) { @@ -737,11 +737,11 @@ int diff_can_type( hid_t f_tid1, /* file data type */ case H5T_ENUM: case H5T_VLEN: case H5T_REFERENCE: - + break; - + default: /*H5T_TIME */ - + if ( (options->m_verbose||options->m_list_not_cmp) && obj1_name && obj2_name) { @@ -752,18 +752,18 @@ int diff_can_type( hid_t f_tid1, /* file data type */ options->not_cmp = 1; return can_compare; } - + /*------------------------------------------------------------------------- * 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); - + parallel_print("Warning: different storage datatype\n"); if ( cl == H5T_INTEGER || cl == H5T_FLOAT ) @@ -777,14 +777,14 @@ int diff_can_type( hid_t f_tid1, /* file data type */ } - + } - + /*------------------------------------------------------------------------- * check for the same rank *------------------------------------------------------------------------- */ - + if ( rank1 != rank2 ) { @@ -807,12 +807,12 @@ int diff_can_type( hid_t f_tid1, /* file data type */ options->not_cmp = 1; return can_compare; } - + /*------------------------------------------------------------------------- * check for different dimensions *------------------------------------------------------------------------- */ - + assert(rank1==rank2); for ( i=0; i<rank1; i++) { @@ -824,19 +824,19 @@ int diff_can_type( hid_t f_tid1, /* file data type */ if ( dims1[i] != dims2[i] ) dim_diff=1; } - + /*------------------------------------------------------------------------- * current dimensions *------------------------------------------------------------------------- */ - + if (dim_diff==1) { 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); print_dimensions(rank1,dims1); - if (maxdim1 && maxdim2) + if (maxdim1 && maxdim2) { parallel_print(", max dimensions "); print_dimensions(rank1,maxdim1); @@ -848,7 +848,7 @@ int diff_can_type( hid_t f_tid1, /* file data type */ parallel_print("\n"); } } - + can_compare = 0; options->not_cmp = 1; @@ -857,7 +857,7 @@ int diff_can_type( hid_t f_tid1, /* file data type */ } - + /*------------------------------------------------------------------------- * maximum dimensions; just give a warning *------------------------------------------------------------------------- @@ -878,7 +878,7 @@ int diff_can_type( hid_t f_tid1, /* file data type */ if ( tclass1 == H5T_COMPOUND ) { - + int nmembs1; int nmembs2; int j; @@ -890,7 +890,7 @@ int diff_can_type( hid_t f_tid1, /* file data type */ if ( nmembs1 != nmembs2 ) { - + if ( (options->m_verbose||options->m_list_not_cmp) && obj1_name && obj2_name) { parallel_print("Not comparable: <%s> has %d members ", obj1_name, nmembs1); @@ -902,7 +902,7 @@ int diff_can_type( hid_t f_tid1, /* file data type */ options->not_cmp = 1; return can_compare; } - + for (j = 0; j < nmembs1; j++) { memb_type1 = H5Tget_member_type(f_tid1, (unsigned)j); @@ -927,22 +927,22 @@ int diff_can_type( hid_t f_tid1, /* file data type */ H5Tclose(memb_type2); return can_compare; } - + H5Tclose(memb_type1); H5Tclose(memb_type2); - + } - - - - - + + + + + } - - - + + + return can_compare; } @@ -966,12 +966,12 @@ void print_sizes( const char *obj1, { size_t f_size1, f_size2; /* size of type in file */ size_t m_size1, m_size2; /* size of type in memory */ - + f_size1 = H5Tget_size( f_tid1 ); f_size2 = H5Tget_size( f_tid2 ); m_size1 = H5Tget_size( m_tid1 ); m_size2 = H5Tget_size( m_tid2 ); - + parallel_print("\n"); parallel_print("------------------\n"); parallel_print("sizeof(char) %u\n", sizeof(char) ); @@ -983,18 +983,18 @@ void print_sizes( const char *obj1, print_type(f_tid1); parallel_print("\n"); parallel_print("size on file %u\n", f_size1 ); - + parallel_print("type on memory "); print_type(m_tid1); parallel_print("\n"); parallel_print("size on memory %u\n", m_size1 ); - + parallel_print("<%s> ------------------\n", obj2); parallel_print("type on file "); print_type(f_tid2); parallel_print("\n"); parallel_print("size on file %u\n", f_size2 ); - + parallel_print("type on memory "); print_type(m_tid2); parallel_print("\n"); diff --git a/tools/lib/h5diff_util.c b/tools/lib/h5diff_util.c index 1acc493..721c3d7 100644 --- a/tools/lib/h5diff_util.c +++ b/tools/lib/h5diff_util.c @@ -106,14 +106,14 @@ print_dimensions (int rank, hsize_t *dims) if ( rank > 0 ) { - + parallel_print("[" ); for ( i = 0; i < rank-1; i++) { parallel_print(HSIZE_T_FORMAT, dims[i]); parallel_print("x"); } - + parallel_print(HSIZE_T_FORMAT, dims[rank-1]); parallel_print("]" ); } diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index 7f1019a..e997d03 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -43,7 +43,7 @@ int bin_output; /* binary output */ int bin_form; /* binary form */ int region_output; /* region output */ -static h5tool_format_t h5tools_dataformat = { +static h5tool_format_t h5tools_dataformat = { 0, /*raw */ "", /*fmt_raw */ @@ -112,7 +112,7 @@ NULL, /*fmt_ullong */ 1 /*escape non printable characters */ }; -static const h5tools_dump_header_t h5tools_standardformat = { +static const h5tools_dump_header_t h5tools_standardformat = { "standardformat", /*name */ "HDF5", /*fileebgin */ "", /*fileend */ @@ -217,8 +217,8 @@ hbool_t h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, hsize_t elmt_counter); int h5tools_print_region_data_blocks(hid_t region_space, hid_t region_id, - FILE *stream, const h5tool_format_t *info, h5tools_context_t ctx, - h5tools_str_t *buffer/*string into which to render */, size_t ncols, + FILE *stream, const h5tool_format_t *info, h5tools_context_t ctx, + h5tools_str_t *buffer/*string into which to render */, size_t ncols, int ndims, hid_t type_id, hssize_t nblocks, hsize_t *ptdata); hbool_t h5tools_dump_region_data_points(hid_t region_space, hid_t region_id, @@ -230,8 +230,8 @@ hbool_t h5tools_dump_region_data_points(hid_t region_space, hid_t region_id, hsize_t elmt_counter); int h5tools_print_region_data_points(hid_t region_space, hid_t region_id, - FILE *stream, const h5tool_format_t *info, h5tools_context_t ctx, - h5tools_str_t *buffer, size_t ncols, + FILE *stream, const h5tool_format_t *info, h5tools_context_t ctx, + h5tools_str_t *buffer, size_t ncols, int ndims, hid_t type_id, hssize_t npoints, hsize_t *ptdata); hbool_t h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id, @@ -299,13 +299,13 @@ void h5tools_init(void) { char lib_str[256]; - + if (!h5tools_init_g) { /* register the error class */ sprintf(lib_str, "%d.%d.%d",H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE); - + H5TOOLS_INIT_ERROR() - + if (!rawdatastream) rawdatastream = stdout; @@ -346,7 +346,7 @@ h5tools_close(void) term_ref_path_table(); H5TOOLS_CLOSE_ERROR() - + /* Shut down the library */ H5close(); @@ -445,7 +445,7 @@ h5tools_get_fapl(hid_t fapl, const char *driver, unsigned *drivernum) if(drivernum) *drivernum = MPIO_IDX; } /* end if */ - } + } else if (!strcmp(driver, drivernames[MPIPOSIX_IDX])) { /* MPI-I/O Driver */ /* check if MPI has been initialized. */ @@ -727,9 +727,9 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info, * None *------------------------------------------------------------------------- */ -static void +static void h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info, - h5tools_context_t *ctx, hsize_t elmtno, hsize_t *ptdata, int secnum) + h5tools_context_t *ctx, hsize_t elmtno, hsize_t *ptdata, int secnum) { h5tools_str_t prefix; h5tools_str_t str; /*temporary for indentation */ @@ -841,7 +841,7 @@ h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info, * new field sm_pos in h5tools_context_t, the current stripmine element position *------------------------------------------------------------------------- */ -void +void h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t container, h5tools_context_t *ctx/*in,out*/, unsigned flags, hsize_t nelmts, hid_t type, void *_mem) @@ -928,13 +928,13 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai if(H5Sclose(region_space) < 0) HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed"); } /* end if (region_space >= 0) */ - else + else HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rget_region failed"); if(H5Dclose(region_id) < 0) HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dclose failed"); } /* if (region_id >= 0) */ - else + else HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rdereference failed"); ctx->need_prefix = TRUE; @@ -966,17 +966,17 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai * 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. - * + * 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 - * - * In/Out: + * + * In/Out: * 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 @@ -985,10 +985,10 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai * hsize_t elmt_count is the data element loop counter *------------------------------------------------------------------------- */ -hbool_t +hbool_t h5tools_render_element(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, h5tools_str_t *buffer, hsize_t *curr_pos, - size_t ncols, hsize_t local_elmt_counter, hsize_t elmt_counter) + size_t ncols, hsize_t local_elmt_counter, hsize_t elmt_counter) { hbool_t dimension_break = TRUE; char *s; @@ -1002,9 +1002,9 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info, * If the element would split on multiple lines if printed at our * current location... */ - if (info->line_multi_new == 1 && - (ctx->cur_column + h5tools_ncols(s) + - strlen(OPT(info->elmt_suf2, " ")) + + if (info->line_multi_new == 1 && + (ctx->cur_column + h5tools_ncols(s) + + strlen(OPT(info->elmt_suf2, " ")) + strlen(OPT(info->line_suf, ""))) > ncols) { if (ctx->prev_multiline) { /* @@ -1013,8 +1013,8 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info, */ ctx->need_prefix = TRUE; } - else if ((ctx->prev_prefix_len + h5tools_ncols(s) + - strlen(OPT(info->elmt_suf2, " ")) + + else if ((ctx->prev_prefix_len + h5tools_ncols(s) + + strlen(OPT(info->elmt_suf2, " ")) + strlen(OPT(info->line_suf, ""))) <= ncols) { /* * ...but *could* fit on one line otherwise, then we @@ -1045,11 +1045,11 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info, * is too long to fit on a line then start this element at the * beginning of the line. */ - if (info->line_multi_new == 1 && - ctx->prev_multiline && - (ctx->cur_column + - h5tools_ncols(s) + - strlen(OPT(info->elmt_suf2, " ")) + + if (info->line_multi_new == 1 && + ctx->prev_multiline && + (ctx->cur_column + + h5tools_ncols(s) + + strlen(OPT(info->elmt_suf2, " ")) + strlen(OPT(info->line_suf, ""))) > ncols) ctx->need_prefix = TRUE; @@ -1066,8 +1066,8 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info, * one-at a time. */ multiline = 0; - for (secnum = 0, multiline = 0; - (section = strtok(secnum ? NULL : s, OPTIONAL_LINE_BREAK)); + for (secnum = 0, multiline = 0; + (section = strtok(secnum ? NULL : s, OPTIONAL_LINE_BREAK)); secnum++) { /* * If the current section plus possible suffix and end-of-line @@ -1079,10 +1079,10 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info, * Added the info->skip_first because the dumper does not want * this check to happen for the first line */ - if ((!info->skip_first || local_elmt_counter) && - (ctx->cur_column + - strlen(section) + - strlen(OPT(info->elmt_suf2, " ")) + + if ((!info->skip_first || local_elmt_counter) && + (ctx->cur_column + + strlen(section) + + strlen(OPT(info->elmt_suf2, " ")) + strlen(OPT(info->line_suf, ""))) > ncols) ctx->need_prefix = 1; @@ -1122,17 +1122,17 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info, * 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. - * + * 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 - * - * In/Out: + * + * In/Out: * 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 @@ -1142,10 +1142,10 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info, * hsize_t elmt_count is the data element loop counter *------------------------------------------------------------------------- */ -hbool_t +hbool_t h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, h5tools_str_t *buffer, hsize_t *curr_pos, - size_t ncols, hsize_t *ptdata, hsize_t local_elmt_counter, hsize_t elmt_counter) + size_t ncols, hsize_t *ptdata, hsize_t local_elmt_counter, hsize_t elmt_counter) { hbool_t dimension_break = TRUE; char *s; @@ -1159,9 +1159,9 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, * If the element would split on multiple lines if printed at our * current location... */ - if (info->line_multi_new == 1 && - (ctx->cur_column + h5tools_ncols(s) + - strlen(OPT(info->elmt_suf2, " ")) + + if (info->line_multi_new == 1 && + (ctx->cur_column + h5tools_ncols(s) + + strlen(OPT(info->elmt_suf2, " ")) + strlen(OPT(info->line_suf, ""))) > ncols) { if (ctx->prev_multiline) { /* @@ -1170,8 +1170,8 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, */ ctx->need_prefix = TRUE; } - else if ((ctx->prev_prefix_len + h5tools_ncols(s) + - strlen(OPT(info->elmt_suf2, " ")) + + else if ((ctx->prev_prefix_len + h5tools_ncols(s) + + strlen(OPT(info->elmt_suf2, " ")) + strlen(OPT(info->line_suf, ""))) <= ncols) { /* * ...but *could* fit on one line otherwise, then we @@ -1202,11 +1202,11 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, * is too long to fit on a line then start this element at the * beginning of the line. */ - if (info->line_multi_new == 1 && - ctx->prev_multiline && - (ctx->cur_column + - h5tools_ncols(s) + - strlen(OPT(info->elmt_suf2, " ")) + + if (info->line_multi_new == 1 && + ctx->prev_multiline && + (ctx->cur_column + + h5tools_ncols(s) + + strlen(OPT(info->elmt_suf2, " ")) + strlen(OPT(info->line_suf, ""))) > ncols) ctx->need_prefix = TRUE; @@ -1235,10 +1235,10 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, * Added the info->skip_first because the dumper does not want * this check to happen for the first line */ - if ((!info->skip_first || local_elmt_counter) && - (ctx->cur_column + - strlen(section) + - strlen(OPT(info->elmt_suf2, " ")) + + if ((!info->skip_first || local_elmt_counter) && + (ctx->cur_column + + strlen(section) + + strlen(OPT(info->elmt_suf2, " ")) + strlen(OPT(info->line_suf, ""))) > ncols) ctx->need_prefix = 1; @@ -1276,13 +1276,13 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, * Audience: Public * Chapter: H5Tools Library * Purpose: Print the data values from a dataset referenced by region blocks. - * + * * Description: * 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 - * + * * Parameters Description: * h5tools_str_t *buffer is the string into which to render * size_t ncols @@ -1290,10 +1290,10 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, * hssize_t nblocks is the number of blocks in the region *------------------------------------------------------------------------- */ -int +int h5tools_print_region_data_blocks(hid_t region_space, hid_t region_id, - FILE *stream, const h5tool_format_t *info, h5tools_context_t ctx, - h5tools_str_t *buffer/*string into which to render */, size_t ncols, + FILE *stream, const h5tool_format_t *info, h5tools_context_t ctx, + h5tools_str_t *buffer/*string into which to render */, size_t ncols, int ndims, hid_t type_id, hssize_t nblocks, hsize_t *ptdata) { HERR_INIT(int, SUCCEED) hbool_t dimension_break = TRUE; @@ -1364,12 +1364,12 @@ h5tools_print_region_data_blocks(hid_t region_space, hid_t region_id, ctx.indent_level++; if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) < 0) HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed"); - + /* assume entire data space to be printed */ for (jndx = 0; jndx < (size_t) ctx.ndims; jndx++) ctx.p_min_idx[jndx] = start[jndx]; init_acc_pos(&ctx, total_size); - + /* print the data */ region_flags = START_OF_DATA; if (blkndx == nblocks - 1) @@ -1390,7 +1390,7 @@ h5tools_print_region_data_blocks(hid_t region_space, hid_t region_id, h5tools_str_reset(buffer); h5tools_str_append(buffer, "%s", jndx ? OPTIONAL_LINE_BREAK "" : ""); - h5tools_str_sprint(buffer, info, region_id, type_id, + h5tools_str_sprint(buffer, info, region_id, type_id, ((char*)region_buf + jndx * type_size), &ctx); if (jndx + 1 < numelem || (region_flags & END_OF_DATA) == 0) @@ -1399,7 +1399,7 @@ h5tools_print_region_data_blocks(hid_t region_space, hid_t region_id, dimension_break = h5tools_render_region_element(stream, info, &ctx, buffer, &curr_pos, ncols, ptdata, jndx, elmtno); /* Render the region data element end */ - + if(FALSE == dimension_break) elmtno = 0; } /* end for (jndx = 0; jndx < numelem; jndx++, region_elmtno++, ctx.cur_elmt++) */ @@ -1412,12 +1412,12 @@ h5tools_print_region_data_blocks(hid_t region_space, hid_t region_id, HDfree(count); HDfree(region_buf); HDfree(dims1); - + if(H5Sclose(mem_space) < 0) HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed"); if(H5Sclose(sid1) < 0) HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed"); - + CATCH return ret_value; } @@ -1426,17 +1426,17 @@ CATCH * 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. - * + * * Return: * The function returns False if the last dimension has been reached, otherwise True - * - * In/Out: + * + * In/Out: * h5tools_context_t *ctx * 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 @@ -1445,7 +1445,7 @@ CATCH * hsize_t elmt_count is the data element loop counter *------------------------------------------------------------------------- */ -hbool_t +hbool_t h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id, FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, @@ -1469,7 +1469,7 @@ h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id, /* Print block information */ if((ndims = H5Sget_simple_extent_ndims(region_space)) < 0) H5E_THROW(dimension_break, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed"); - + /* Render the region { element begin */ h5tools_str_reset(buffer); @@ -1483,7 +1483,7 @@ h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id, ctx->indent_level++; ctx->need_prefix = TRUE; h5tools_str_append(buffer, "REGION_TYPE BLOCK "); - + alloc_size = nblocks * ndims * 2 * sizeof(ptdata[0]); assert(alloc_size == (hsize_t) ((size_t) alloc_size)); /*check for overflow*/ if((ptdata = (hsize_t*) malloc((size_t) alloc_size)) == NULL) @@ -1580,10 +1580,10 @@ h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id, done: free(ptdata); - + if(H5Tclose(type_id) < 0) HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed"); - + if(H5Tclose(dtype) < 0) HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed"); @@ -1594,7 +1594,7 @@ h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id, h5tools_str_append(buffer, "%s %s ", h5tools_dump_header_format->dataend, h5tools_dump_header_format->datablockend); - dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, + dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter); /* Render the dataend element end */ @@ -1604,7 +1604,7 @@ h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id, /* Render the region } element begin */ h5tools_str_reset(buffer); h5tools_str_append(buffer, "}"); - dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, + dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter); /* Render the region } element end */ @@ -1618,13 +1618,13 @@ h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id, * Audience: Public * Chapter: H5Tools Library * Purpose: Print the data values from a dataset referenced by region points. - * + * * Description: * This is a special case subfunction to print the data in a region reference of type points. - * + * * Return: * The function returns FAIL on error, otherwise SUCCEED - * + * * Parameters Description: * h5tools_str_t *buffer is the string into which to render * size_t ncols @@ -1632,10 +1632,10 @@ h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id, * hssize_t npoints is the number of points in the region *------------------------------------------------------------------------- */ -int +int h5tools_print_region_data_points(hid_t region_space, hid_t region_id, - FILE *stream, const h5tool_format_t *info, h5tools_context_t ctx, - h5tools_str_t *buffer, size_t ncols, + FILE *stream, const h5tool_format_t *info, h5tools_context_t ctx, + h5tools_str_t *buffer, size_t ncols, int ndims, hid_t type_id, hssize_t npoints, hsize_t *ptdata) { HERR_INIT(int, SUCCEED) hbool_t dimension_break = TRUE; @@ -1688,7 +1688,7 @@ h5tools_print_region_data_points(hid_t region_space, hid_t region_id, if (ctx.ndims > 0) { ctx.size_last_dim = (int) (ctx.p_max_idx[ctx.ndims - 1]); - } + } else ctx.size_last_dim = 0; @@ -1702,17 +1702,17 @@ h5tools_print_region_data_points(hid_t region_space, hid_t region_id, curr_pos = 0; /* points requires constant 0 */ ctx.sm_pos = jndx * ndims; - + h5tools_region_simple_prefix(stream, info, &ctx, curr_pos, ptdata, 0); - h5tools_str_sprint(buffer, info, region_id, type_id, + h5tools_str_sprint(buffer, info, region_id, type_id, ((char*)region_buf + jndx * type_size), &ctx); if (jndx + 1 < npoints || (region_flags & END_OF_DATA) == 0) h5tools_str_append(buffer, "%s", OPT(info->elmt_suf1, ",")); - dimension_break = - h5tools_render_region_element(stream, info, &ctx, buffer, &curr_pos, + dimension_break = + h5tools_render_region_element(stream, info, &ctx, buffer, &curr_pos, ncols, ptdata, 0, elmtno); /* Render the point element end */ @@ -1724,7 +1724,7 @@ h5tools_print_region_data_points(hid_t region_space, hid_t region_id, done: HDfree(region_buf); HDfree(dims1); - + if(H5Sclose(mem_space) < 0) HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed"); CATCH @@ -1735,17 +1735,17 @@ CATCH * Audience: Public * Chapter: H5Tools Library * Purpose: Print some values from a dataset referenced by 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 - * - * In/Out: + * + * In/Out: * h5tools_context_t *ctx * 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 @@ -1754,9 +1754,9 @@ CATCH * hsize_t elmt_count is the data element loop counter *------------------------------------------------------------------------- */ -hbool_t +hbool_t h5tools_dump_region_data_points(hid_t region_space, hid_t region_id, - FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, + FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, h5tools_str_t *buffer, hsize_t *curr_pos, size_t ncols, hsize_t region_elmt_counter, hsize_t elmt_counter) { HERR_INIT(hbool_t, TRUE) @@ -1819,7 +1819,7 @@ h5tools_dump_region_data_points(hid_t region_space, hid_t region_id, if((dtype = H5Dget_type(region_id)) < 0) HGOTO_ERROR(dimension_break, H5E_tools_min_id_g, "H5Dget_type failed"); - + if((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) HGOTO_ERROR(dimension_break, H5E_tools_min_id_g, "H5Tget_native_type failed"); @@ -1882,7 +1882,7 @@ h5tools_dump_region_data_points(hid_t region_space, hid_t region_id, done: free(ptdata); - + if(H5Tclose(type_id) < 0) HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed"); @@ -1896,7 +1896,7 @@ h5tools_dump_region_data_points(hid_t region_space, hid_t region_id, h5tools_str_append(buffer, "%s %s ", h5tools_dump_header_format->dataend, h5tools_dump_header_format->datablockend); - dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, + dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter); /* Render the dataend element end*/ @@ -1906,7 +1906,7 @@ h5tools_dump_region_data_points(hid_t region_space, hid_t region_id, /* Render the region } element begin */ h5tools_str_reset(buffer); h5tools_str_append(buffer, "}"); - dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, + dimension_break = h5tools_render_element(stream, info, ctx, buffer, curr_pos, ncols, region_elmt_counter, elmt_counter); /* Render the region } element end */ @@ -1948,7 +1948,7 @@ CATCH *------------------------------------------------------------------------- */ static herr_t -h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, +h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t dset, hid_t p_type, struct subset_t *sset, hid_t f_space, hsize_t hyperslab_count, hsize_t *temp_start,/* start inside offset count loop */ @@ -1987,7 +1987,7 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c for (; hyperslab_count > 0; temp_start[row_dim] += temp_stride[row_dim], hyperslab_count--) { /* jump rows if size of block exceeded cases where block > 1 only and stride > block */ - if (size_row_block > 1 + if (size_row_block > 1 && row_counter == size_row_block && sset->stride[row_dim] > sset->block[row_dim]) { @@ -2001,7 +2001,7 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c /* calculate the potential number of elements we're going to print */ if(H5Sselect_hyperslab(f_space, H5S_SELECT_SET, temp_start, temp_stride, temp_count, temp_block) < 0) H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sselect_hyperslab failed"); - + if((sm_nelmts = H5Sget_select_npoints(f_space)) < 0) H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sget_select_npoints failed"); @@ -2012,7 +2012,7 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c */ if((sm_nbytes = p_type_nbytes = H5Tget_size(p_type)) == 0) H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size failed"); - + if (ctx->ndims > 0) for (i = ctx->ndims; i > 0; --i) { hsize_t size = H5TOOLS_BUFSIZE / sm_nbytes; @@ -2022,35 +2022,35 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c sm_nbytes *= sm_size[i - 1]; assert(sm_nbytes > 0); } - + assert(sm_nbytes == (hsize_t) ((size_t) sm_nbytes)); /*check for overflow*/ if((sm_buf = HDmalloc((size_t) sm_nelmts * p_type_nbytes)) == NULL) H5E_THROW(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for strip-mine"); - + if((sm_space = H5Screate_simple(1, &sm_nelmts, NULL)) < 0) H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Screate_simple failed"); - + if(H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, &zero, NULL, &sm_nelmts, NULL) < 0) H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sselect_hyperslab failed"); - + /* read the data */ if(H5Dread(dset, p_type, sm_space, f_space, H5P_DEFAULT, sm_buf) < 0) H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Dread failed"); - + /* print the data */ flags = START_OF_DATA; - + if (hyperslab_count == 1) flags |= END_OF_DATA; - + for (i = 0; i < ctx->ndims; i++) ctx->p_max_idx[i] = ctx->p_min_idx[i] + MIN(total_size[i], sm_size[i]); - + /* print array indices. get the lower bound of the hyperslab and calulate the element position at the start of hyperslab */ if(H5Sget_select_bounds(f_space, low, high) < 0) H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Sget_select_bounds failed"); - + elmtno = 0; for (i = 0; i < (size_t) ctx->ndims - 1; i++) { hsize_t offset = 1; /* accumulation of the previous dimensions */ @@ -2059,11 +2059,11 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c elmtno += low[i] * offset; } elmtno += low[ctx->ndims - 1]; - + /* initialize the current stripmine position; this is necessary to print the array indices */ ctx->sm_pos = elmtno; - + h5tools_dump_simple_data(stream, info, dset, ctx, flags, sm_nelmts, p_type, sm_buf); if(H5Sclose(sm_space) < 0) @@ -2121,7 +2121,7 @@ CATCH *------------------------------------------------------------------------- */ static herr_t -h5tools_display_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, +h5tools_display_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t dset, hid_t p_type, struct subset_t *sset, hid_t f_space, hsize_t *total_size) { @@ -2192,11 +2192,11 @@ h5tools_display_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools else { count = 1; } - + h5tools_print_simple_subset(stream, info, ctx, dset, p_type, sset, - f_space, count, temp_start, temp_count, + f_space, count, temp_start, temp_count, temp_block, temp_stride, total_size, row_dim); - + if (ctx->ndims > 2) { /* dimension for start */ current_outer_dim = (ctx->ndims - 2) - 1; @@ -2337,9 +2337,9 @@ CATCH * returns FAIL. *------------------------------------------------------------------------- */ -static int +static int h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, - hid_t dset, hid_t p_type, int indentlevel) + hid_t dset, hid_t p_type, int indentlevel) { hid_t f_space; /* file data space */ hsize_t elmtno; /* counter */ @@ -2612,9 +2612,9 @@ h5tools_dump_simple_mem(FILE *stream, const h5tool_format_t *info, hid_t obj_id, * *------------------------------------------------------------------------- */ -int +int h5tools_dump_dset(FILE *stream, const h5tool_format_t *info, hid_t dset, - hid_t _p_type, struct subset_t *sset, int indentlevel) + hid_t _p_type, struct subset_t *sset, int indentlevel) { hid_t f_space; hid_t p_type = _p_type; @@ -2727,9 +2727,9 @@ CATCH * *------------------------------------------------------------------------- */ -int -h5tools_print_datatype(h5tools_str_t *buffer, const h5tool_format_t *info, - h5tools_context_t *ctx, hid_t type) +int +h5tools_print_datatype(h5tools_str_t *buffer, const h5tool_format_t *info, + h5tools_context_t *ctx, hid_t type) { HERR_INIT(int, FAIL) char *mname; @@ -3081,7 +3081,7 @@ h5tools_print_datatype(h5tools_str_t *buffer, const h5tool_format_t *info, case H5T_COMPOUND: if((nmembers = H5Tget_nmembers(type)) < 0) H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_nmembers failed"); - + h5tools_str_append(buffer, "H5T_COMPOUND %s\n", h5tools_dump_header_format->structblockbegin); for (i = 0; i < nmembers; i++) { @@ -3089,12 +3089,12 @@ h5tools_print_datatype(h5tools_str_t *buffer, const h5tool_format_t *info, if((mtype = H5Tget_member_type(type, i))>=0) { if (H5Tget_class(mtype) == H5T_COMPOUND) ctx->indent_level++; - + h5tools_print_datatype(buffer, info, ctx, mtype); - + if (H5Tget_class(mtype) == H5T_COMPOUND) ctx->indent_level--; - + h5tools_str_append(buffer, " \"%s\";\n", mname); if(H5Tclose(mtype) < 0) HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed"); @@ -3129,10 +3129,10 @@ h5tools_print_datatype(h5tools_str_t *buffer, const h5tool_format_t *info, h5tools_print_datatype(buffer, info, ctx, super); if(H5Tclose(super) < 0) HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed"); - + h5tools_str_append(buffer, ";\n"); h5tools_print_enum(buffer, type); - + ctx->indent_level--; h5tools_str_append(buffer, "%s", h5tools_dump_header_format->enumblockend); @@ -3161,7 +3161,7 @@ h5tools_print_datatype(h5tools_str_t *buffer, const h5tool_format_t *info, /* Print array dimensions */ for (i = 0; i < ndims; i++) h5tools_str_append(buffer, "[%d]", (int) dims[i]); - + h5tools_str_append(buffer, " "); } else @@ -3206,8 +3206,8 @@ CATCH * *------------------------------------------------------------------------- */ -int -h5tools_print_dataspace(h5tools_str_t *buffer, hid_t space) +int +h5tools_print_dataspace(h5tools_str_t *buffer, hid_t space) { HERR_INIT(int, SUCCEED) hsize_t size[H5TOOLS_DUMP_MAX_RANK]; @@ -3282,8 +3282,8 @@ CATCH * h5tools_context_t *ctx * *-----------------------------------------------------------------------*/ -int -h5tools_print_enum(h5tools_str_t *buffer, hid_t type) +int +h5tools_print_enum(h5tools_str_t *buffer, hid_t type) { HERR_INIT(int, SUCCEED) char **name = NULL; /*member names */ @@ -3293,7 +3293,7 @@ h5tools_print_enum(h5tools_str_t *buffer, hid_t type) int nchars; /*number of output characters */ hid_t super = -1; /*enum base integer type */ hid_t native = -1; /*native integer datatype */ - H5T_sign_t sign_type; /*sign of value type */ + H5T_sign_t sign_type; /*sign of value type */ size_t type_size; /*value type size */ size_t dst_size; /*destination value type size */ int snmembs; @@ -3303,10 +3303,10 @@ h5tools_print_enum(h5tools_str_t *buffer, hid_t type) H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_nmembers failed"); nmembs = (unsigned)snmembs; assert(nmembs > 0); - + if((super = H5Tget_super(type)) < 0) H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_super failed"); - + if((type_size = H5Tget_size(type)) <= 0) H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size(type) failed"); @@ -3410,13 +3410,13 @@ CATCH * atomic datatype or committed/transient datatype. * * Return: void - * + * * In/Out: h5tools_context_t *ctx *------------------------------------------------------------------------- */ -void +void h5tools_dump_datatype(FILE *stream, const h5tool_format_t *info, - h5tools_context_t *ctx, hid_t type) + h5tools_context_t *ctx, hid_t type) { size_t ncols = 80; /* available output width */ h5tools_str_t buffer; /* string into which to render */ @@ -3470,8 +3470,8 @@ h5tools_dump_datatype(FILE *stream, const h5tool_format_t *info, * Return: void *------------------------------------------------------------------------- */ -void -init_acc_pos(h5tools_context_t *ctx, hsize_t *dims) +void +init_acc_pos(h5tools_context_t *ctx, hsize_t *dims) { int i; @@ -3525,7 +3525,7 @@ CATCH * Failure: FAIL *------------------------------------------------------------------------- */ -static int +static int render_bin_output(FILE *stream, hid_t tid, void *_mem) { HERR_INIT(int, SUCCEED) @@ -3880,8 +3880,8 @@ CATCH * Return: TRUE if all bytes are zero; FALSE otherwise *------------------------------------------------------------------------- */ -static -hbool_t h5tools_is_zero(const void *_mem, size_t size) +static +hbool_t h5tools_is_zero(const void *_mem, size_t size) { const unsigned char *mem = (const unsigned char *) _mem; diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h index 2b1e4bf..7d207ba 100644 --- a/tools/lib/h5tools.h +++ b/tools/lib/h5tools.h @@ -53,9 +53,9 @@ #define H5TOOLS_DUMP_MAX_RANK H5S_MAX_RANK -/* - * Strings for output - these were duplicated from the h5dump.h - * file in order to support region reference data display +/* + * Strings for output - these were duplicated from the h5dump.h + * file in order to support region reference data display */ #define ATTRIBUTE "ATTRIBUTE" #define BLOCK "BLOCK" @@ -105,9 +105,9 @@ #define BEGIN "{" #define END "}" -/* - * dump structure for output - this was duplicated from the h5dump.h - * file in order to support region reference data display +/* + * dump structure for output - this was duplicated from the h5dump.h + * file in order to support region reference data display */ typedef struct h5tools_dump_header_t { const char *name; @@ -515,7 +515,7 @@ struct subset_t { hsize_t *block; }; -/* The following include, h5tools_str.h, must be after the +/* The following include, h5tools_str.h, must be after the * above stucts are defined. There is a dependency in the following * include that hasn't been identified yet. */ @@ -554,11 +554,11 @@ extern int h5tools_canreadf(const char* name, extern int h5tools_can_encode(H5Z_filter_t filtn); void init_acc_pos(h5tools_context_t *ctx, hsize_t *dims); -/* +/* * new functions needed to display region reference data */ void h5tools_dump_datatype(FILE *stream, const h5tool_format_t *info, - h5tools_context_t *ctx/*in,out*/, hid_t type); + h5tools_context_t *ctx/*in,out*/, hid_t type); int h5tools_print_dataspace(h5tools_str_t *buffer/*in,out*/, hid_t space); int h5tools_print_datatype(h5tools_str_t *buffer/*in,out*/, const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/, diff --git a/tools/lib/h5tools_error.h b/tools/lib/h5tools_error.h index dc5f87b..a7c0d3c 100644 --- a/tools/lib/h5tools_error.h +++ b/tools/lib/h5tools_error.h @@ -87,7 +87,7 @@ extern hid_t H5E_tools_min_id_g; } /* - * H5E_THROW macro, used to facilitate error reporting within a function body. + * H5E_THROW macro, used to facilitate error reporting within a function body. * The arguments are the minor error number, and an error string. * The return value is assigned to a variable `ret_value' and control branches * to the `catch_except' label, if we're not already past it. @@ -109,8 +109,8 @@ extern hid_t H5E_tools_min_id_g; } /* - * HGOTO_DONE macro, used to facilitate normal return within a function body. - * The argument is the return value which is assigned to the `ret_value' + * HGOTO_DONE macro, used to facilitate normal return within a function body. + * The argument is the return value which is assigned to the `ret_value' * variable. Control branches to the `done' label. */ #define HGOTO_DONE(ret_val) {ret_value = ret_val; goto done;} diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c index 3567975..55596cd 100644 --- a/tools/lib/h5tools_str.c +++ b/tools/lib/h5tools_str.c @@ -350,8 +350,8 @@ h5tools_str_prefix(h5tools_str_t *str/*in,out*/, const h5tool_format_t *info, * * Return: Success: Pointer to the prefix. * Failure: NULL - * - * In/Out: + * + * In/Out: * h5tools_context_t *ctx * h5tools_str_t *str *------------------------------------------------------------------------- @@ -359,7 +359,7 @@ h5tools_str_prefix(h5tools_str_t *str/*in,out*/, const h5tool_format_t *info, char * h5tools_str_region_prefix(h5tools_str_t *str, const h5tool_format_t *info, hsize_t elmtno, hsize_t *ptdata, unsigned ndims, hsize_t min_idx[], hsize_t max_idx[], - h5tools_context_t *ctx) + h5tools_context_t *ctx) { hsize_t p_prod[H5S_MAX_RANK]; size_t i = 0; @@ -406,15 +406,15 @@ h5tools_str_region_prefix(h5tools_str_t *str, const h5tool_format_t *info, * the information to the specified string. * * Return: none - * - * In/Out: + * + * In/Out: * h5tools_context_t *ctx * h5tools_str_t *str *------------------------------------------------------------------------- */ -void +void h5tools_str_dump_region_blocks(h5tools_str_t *str, hid_t region, - const h5tool_format_t *info, h5tools_context_t *ctx) + const h5tool_format_t *info, h5tools_context_t *ctx) { hssize_t nblocks; hsize_t alloc_size; @@ -422,7 +422,7 @@ h5tools_str_dump_region_blocks(h5tools_str_t *str, hid_t region, int ndims = H5Sget_simple_extent_ndims(region); /* - * This function fails if the region does not have blocks. + * This function fails if the region does not have blocks. */ H5E_BEGIN_TRY { nblocks = H5Sget_select_hyper_nblocks(region); @@ -467,15 +467,15 @@ h5tools_str_dump_region_blocks(h5tools_str_t *str, hid_t region, * the information to the specified string. * * Return: none - * - * In/Out: + * + * In/Out: * h5tools_context_t *ctx * h5tools_str_t *str *------------------------------------------------------------------------- */ -void +void h5tools_str_dump_region_points(h5tools_str_t *str, hid_t region, - const h5tool_format_t *info, h5tools_context_t *ctx) + const h5tool_format_t *info, h5tools_context_t *ctx) { hssize_t npoints; hsize_t alloc_size; @@ -699,7 +699,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai h5tools_str_append(str, "%Lf", templdouble); #endif } - else if (info->ascii && (H5Tequal(type, H5T_NATIVE_SCHAR) || + else if (info->ascii && (H5Tequal(type, H5T_NATIVE_SCHAR) || H5Tequal(type, H5T_NATIVE_UCHAR))) { h5tools_print_char(str, info, (char) (*ucp_vp)); } @@ -788,13 +788,13 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai else if (H5Tequal(type, H5T_NATIVE_UINT)) { HDmemcpy(&tempuint, vp, sizeof(unsigned int)); h5tools_str_append(str, OPT(info->fmt_uint, "%u"), tempuint); - } + } else if (H5Tequal(type, H5T_NATIVE_SCHAR)) { h5tools_str_append(str, OPT(info->fmt_schar, "%d"), *cp_vp); - } + } else if (H5Tequal(type, H5T_NATIVE_UCHAR)) { h5tools_str_append(str, OPT(info->fmt_uchar, "%u"), *ucp_vp); - } + } else if (H5Tequal(type, H5T_NATIVE_SHORT)) { short tempshort; @@ -1110,9 +1110,9 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai * Return: Nothing *------------------------------------------------------------------------- */ -void +void h5tools_str_sprint_region(h5tools_str_t *str, const h5tool_format_t *info, - hid_t container, void *vp, h5tools_context_t *ctx) + hid_t container, void *vp, h5tools_context_t *ctx) { hid_t obj, region; char ref_name[1024]; diff --git a/tools/lib/h5tools_str.h b/tools/lib/h5tools_str.h index 61b7905..98dd065 100644 --- a/tools/lib/h5tools_str.h +++ b/tools/lib/h5tools_str.h @@ -35,7 +35,7 @@ extern char *h5tools_str_fmt(h5tools_str_t *str, size_t start, const char *fm extern char *h5tools_str_prefix(h5tools_str_t *str, const h5tool_format_t *info, hsize_t elmtno, unsigned ndims, hsize_t min_idx[], hsize_t max_idx[], h5tools_context_t *ctx); -/* +/* * new functions needed to display region reference data */ extern char *h5tools_str_region_prefix(h5tools_str_t *str, const h5tool_format_t *info, diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c index 46b425b..82e9ab9 100644 --- a/tools/lib/h5tools_utils.c +++ b/tools/lib/h5tools_utils.c @@ -232,8 +232,8 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti } sp = 1; - } - + } + /* wildcard argument */ else if (*cp == '*') { @@ -249,16 +249,16 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti opt_arg = NULL; } } - - else + + else { /* set up to look at next char in token, next time */ if (argv[opt_ind][++sp] == '\0') { /* no more in current token, so setup next token */ opt_ind++; sp = 1; - - + + } opt_arg = NULL; diff --git a/tools/lib/h5trav.c b/tools/lib/h5trav.c index 69b4512..287af29 100644 --- a/tools/lib/h5trav.c +++ b/tools/lib/h5trav.c @@ -150,7 +150,7 @@ traverse_cb(hid_t loc_id, const char *path, const H5L_info_t *linfo, if(udata->is_absolute) { size_t base_len = HDstrlen(udata->base_grp_name); size_t add_slash = base_len ? ((udata->base_grp_name)[base_len-1] != '/') : 1; - + if(NULL == (new_name = HDmalloc(base_len + add_slash + HDstrlen(path) + 1))) return(H5_ITER_ERROR); HDstrcpy(new_name, udata->base_grp_name); |