diff options
Diffstat (limited to 'tools/h5repack/h5repack_verify.c')
-rw-r--r-- | tools/h5repack/h5repack_verify.c | 246 |
1 files changed, 109 insertions, 137 deletions
diff --git a/tools/h5repack/h5repack_verify.c b/tools/h5repack/h5repack_verify.c index 9565ce3..6765c49 100644 --- a/tools/h5repack/h5repack_verify.c +++ b/tools/h5repack/h5repack_verify.c @@ -80,20 +80,20 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options *------------------------------------------------------------------------- */ if((did = H5Dopen2(fidout, name, H5P_DEFAULT)) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dopen2 failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed"); if((sid = H5Dget_space(did)) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dget_space failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed"); if((pid = H5Dget_create_plist(did)) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dget_create_plist failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist failed"); if((tid = H5Dget_type(did)) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dget_type failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_type failed"); /*------------------------------------------------------------------------- * filter check *------------------------------------------------------------------------- */ if(verify_filters(pid, tid, obj->nfilters, obj->filter) <= 0) - ok = 0; + ok = 0; /*------------------------------------------------------------------------- @@ -108,13 +108,13 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options *------------------------------------------------------------------------- */ if(H5Pclose(pid) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed"); if (H5Sclose(sid) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose failed"); if (H5Dclose(did) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dclose failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed"); if (H5Tclose(tid) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed"); } @@ -132,7 +132,7 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options /* get the list of objects in the file */ if(h5trav_gettable(fidout, travt) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "h5trav_gettable failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5trav_gettable failed"); for(i = 0; i < travt->nobjs; i++) { @@ -146,13 +146,13 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options *------------------------------------------------------------------------- */ if((did = H5Dopen2(fidout, name, H5P_DEFAULT)) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dopen2 failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed"); if((sid = H5Dget_space(did)) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dget_space failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed"); if((pid = H5Dget_create_plist(did)) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dget_create_plist failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist failed"); if((tid = H5Dget_type(did)) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dget_type failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_type failed"); /*------------------------------------------------------------------------- * filter check @@ -160,7 +160,6 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options */ if(options->all_filter == 1) { - if(verify_filters(pid, tid, options->n_filter_g, options->filter_g) <= 0) ok = 0; } @@ -172,6 +171,7 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options if(options->all_layout == 1) { pack_info_t pack; + init_packobject(&pack); pack.layout = options->layout_g; pack.chunk = options->chunk_g; @@ -185,13 +185,13 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options *------------------------------------------------------------------------- */ if (H5Pclose(pid) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed"); if (H5Sclose(sid) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose failed"); if (H5Dclose(did) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dclose failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed"); if (H5Tclose(tid) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed"); } /* if */ } /* i */ @@ -208,31 +208,31 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options /* open the input file */ if((fidin = H5Fopen(in_fname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0 ) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Fopen failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fopen failed"); /* Get file creation property list for input file */ if((fcpl_in = H5Fget_create_plist(fidin)) < 0) { error_msg("failed to retrieve file creation property list\n"); - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Fget_create_plist failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fget_create_plist failed"); } /* Get file space management info for input file */ if(H5Pget_file_space(fcpl_in, &in_strat, &in_thresh) < 0) { error_msg("failed to retrieve file space strategy & threshold\n"); - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pget_file_space failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_file_space failed"); } /* Output file is already opened */ /* Get file creation property list for output file */ if((fcpl_out = H5Fget_create_plist(fidout)) < 0) { error_msg("failed to retrieve file creation property list\n"); - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Fget_create_plist failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fget_create_plist failed"); } /* Get file space management info for output file */ if(H5Pget_file_space(fcpl_out, &out_strat, &out_thresh) < 0) { error_msg("failed to retrieve file space strategy & threshold\n"); - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pget_file_space failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_file_space failed"); } /* @@ -245,12 +245,12 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options */ if(!options->fs_strategy && out_strat != in_strat) { error_msg("file space strategy not set as unexpected\n"); - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "file space strategy not set as unexpected"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file space strategy not set as unexpected"); } else if(options->fs_strategy && out_strat!= options->fs_strategy) { error_msg("file space strategy not set as unexpected\n"); - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "file space strategy not set as unexpected"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file space strategy not set as unexpected"); } /* @@ -263,22 +263,22 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options */ if(!options->fs_threshold && out_thresh != in_thresh) { error_msg("free space threshold not set as unexpected\n"); - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "free space threshold not set as unexpected"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "free space threshold not set as unexpected"); } else if(options->fs_threshold && out_thresh != options->fs_threshold) { error_msg("free space threshold not set as unexpected\n"); - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "free space threshold not set as unexpected"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "free space threshold not set as unexpected"); } /* Closing */ if (H5Pclose(fcpl_in) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed"); if (H5Pclose(fcpl_out) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed"); if (H5Fclose(fidin) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Fclose failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fclose failed"); if (H5Fclose(fidout) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Fclose failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fclose failed"); return ok; @@ -294,7 +294,8 @@ done: if (travt) trav_table_free(travt); } H5E_END_TRY; - return -1; + + return ret_value; } /* h5repack_verify() */ @@ -397,12 +398,12 @@ int h5repack_cmp_pl(const char *fname1, { /* Open the files */ - if ((fid1=H5Fopen(fname1,H5F_ACC_RDONLY,H5P_DEFAULT)) < 0 ) + if ((fid1 = H5Fopen(fname1,H5F_ACC_RDONLY,H5P_DEFAULT)) < 0 ) { error_msg("<%s>: %s\n", fname1, H5FOPENERROR ); return -1; } - if ((fid2=H5Fopen(fname2,H5F_ACC_RDONLY,H5P_DEFAULT)) < 0 ) + if ((fid2 = H5Fopen(fname2,H5F_ACC_RDONLY,H5P_DEFAULT)) < 0 ) { error_msg("<%s>: %s\n", fname2, H5FOPENERROR ); H5Fclose(fid1); @@ -417,7 +418,7 @@ int h5repack_cmp_pl(const char *fname1, */ trav_table_init(&trav); if(h5trav_gettable(fid1, trav) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "h5trav_gettable failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5trav_gettable failed"); /*------------------------------------------------------------------------- * traverse the suppplied object list @@ -430,30 +431,30 @@ int h5repack_cmp_pl(const char *fname1, { if ((gid = H5Gopen2(fid1, trav->objs[i].name, H5P_DEFAULT)) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Gopen2 failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gopen2 failed"); if ((gcplid = H5Gget_create_plist(gid)) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Gget_create_plist failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gget_create_plist failed"); if (H5Pget_link_creation_order(gcplid, &crt_order_flag1) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pget_link_creation_order failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_link_creation_order failed"); if (H5Pclose(gcplid) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed"); if (H5Gclose(gid) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Gclose failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gclose failed"); if ((gid = H5Gopen2(fid2, trav->objs[i].name, H5P_DEFAULT)) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Gopen2 failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gopen2 failed"); if ((gcplid = H5Gget_create_plist(gid)) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Gget_create_plist failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gget_create_plist failed"); if (H5Pget_link_creation_order(gcplid, &crt_order_flag2) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pget_link_creation_order failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_link_creation_order failed"); if (H5Pclose(gcplid) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed"); if (H5Gclose(gid) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Gclose failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gclose failed"); if (crt_order_flag1 != crt_order_flag2) { error_msg("property lists for <%s> are different\n",trav->objs[i].name); - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "property lists failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "property lists failed"); } } @@ -463,24 +464,24 @@ int h5repack_cmp_pl(const char *fname1, else if(trav->objs[i].type == H5TRAV_TYPE_DATASET) { if((dset1 = H5Dopen2(fid1, trav->objs[i].name, H5P_DEFAULT)) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dopen2 failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed"); if((dset2 = H5Dopen2(fid2, trav->objs[i].name, H5P_DEFAULT)) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dopen2 failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed"); if((dcpl1 = H5Dget_create_plist(dset1)) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dget_create_plist failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist failed"); if((dcpl2 = H5Dget_create_plist(dset2)) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dget_create_plist failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist failed"); /*------------------------------------------------------------------------- * compare the property lists *------------------------------------------------------------------------- */ if((ret = H5Pequal(dcpl1, dcpl2)) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pequal failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pequal failed"); if(ret == 0) { error_msg("property lists for <%s> are different\n",trav->objs[i].name); - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "property lists failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "property lists failed"); } /*------------------------------------------------------------------------- @@ -488,13 +489,13 @@ int h5repack_cmp_pl(const char *fname1, *------------------------------------------------------------------------- */ if(H5Pclose(dcpl1) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed"); if(H5Pclose(dcpl2) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed"); if(H5Dclose(dset1) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dclose failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed"); if(H5Dclose(dset2) < 0) - HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dclose failed"); + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed"); } /*if*/ } /*i*/ @@ -512,13 +513,13 @@ int h5repack_cmp_pl(const char *fname1, H5Fclose(fid1); H5Fclose(fid2); - return ret; - /*------------------------------------------------------------------------- - * error - *------------------------------------------------------------------------- - */ + return ret; +/*------------------------------------------------------------------------- +* error +*------------------------------------------------------------------------- +*/ done: H5E_BEGIN_TRY { @@ -532,8 +533,8 @@ done: H5Gclose(gid); trav_table_free(trav); } H5E_END_TRY; - return -1; + return ret_value; } @@ -602,100 +603,71 @@ int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *filter) switch (filtn) { - case H5Z_FILTER_NONE: + case H5Z_FILTER_NONE: break; - case H5Z_FILTER_SHUFFLE: - - /* 1 private client value is returned by DCPL */ - if ( cd_nelmts != H5Z_SHUFFLE_TOTAL_NPARMS && filter[i].cd_nelmts != H5Z_SHUFFLE_USER_NPARMS ) - return 0; - - /* get dataset's type size */ - if((size = H5Tget_size(tid)) <= 0) - return -1; - - /* the private client value holds the dataset's type size */ - if ( size != cd_values[0] ) - return 0; - - - break; - - case H5Z_FILTER_SZIP: - - /* 4 private client values are returned by DCPL */ - if ( cd_nelmts != H5Z_SZIP_TOTAL_NPARMS && filter[i].cd_nelmts != H5Z_SZIP_USER_NPARMS ) - return 0; - - /* "User" parameter for pixels-per-block (index 1) */ - if ( cd_values[H5Z_SZIP_PARM_PPB] != filter[i].cd_values[H5Z_SZIP_PARM_PPB] ) - return 0; - - - break; - - case H5Z_FILTER_NBIT: - - /* only client data values number of values checked */ - if ( H5Z_NBIT_USER_NPARMS != filter[i].cd_nelmts) - return 0; - - - - break; + case H5Z_FILTER_SHUFFLE: + /* 1 private client value is returned by DCPL */ + if ( cd_nelmts != H5Z_SHUFFLE_TOTAL_NPARMS && filter[i].cd_nelmts != H5Z_SHUFFLE_USER_NPARMS ) + return 0; - case H5Z_FILTER_SCALEOFFSET: + /* get dataset's type size */ + if((size = H5Tget_size(tid)) <= 0) + return -1; - /* only client data values checked */ - for( j = 0; j < H5Z_SCALEOFFSET_USER_NPARMS; j++) - { - if (cd_values[j] != filter[i].cd_values[j]) - { + /* the private client value holds the dataset's type size */ + if ( size != cd_values[0] ) return 0; - } - } + break; + case H5Z_FILTER_SZIP: + /* 4 private client values are returned by DCPL */ + if ( cd_nelmts != H5Z_SZIP_TOTAL_NPARMS && filter[i].cd_nelmts != H5Z_SZIP_USER_NPARMS ) + return 0; - break; - - /* for these filters values must match, no local values set in DCPL */ - case H5Z_FILTER_FLETCHER32: - case H5Z_FILTER_DEFLATE: + /* "User" parameter for pixels-per-block (index 1) */ + if ( cd_values[H5Z_SZIP_PARM_PPB] != filter[i].cd_values[H5Z_SZIP_PARM_PPB] ) + return 0; - if ( cd_nelmts != filter[i].cd_nelmts) - return 0; + break; - for( j = 0; j < cd_nelmts; j++) - { - if (cd_values[j] != filter[i].cd_values[j]) - { + case H5Z_FILTER_NBIT: + /* only client data values number of values checked */ + if ( H5Z_NBIT_USER_NPARMS != filter[i].cd_nelmts) return 0; - } + break; - } + case H5Z_FILTER_SCALEOFFSET: + /* only client data values checked */ + for( j = 0; j < H5Z_SCALEOFFSET_USER_NPARMS; j++) + if (cd_values[j] != filter[i].cd_values[j]) + return 0; + break; + /* for these filters values must match, no local values set in DCPL */ + case H5Z_FILTER_FLETCHER32: + case H5Z_FILTER_DEFLATE: + if ( cd_nelmts != filter[i].cd_nelmts) + return 0; - break; + for( j = 0; j < cd_nelmts; j++) + if (cd_values[j] != filter[i].cd_values[j]) + return 0; - default: - if ( cd_nelmts != filter[i].cd_nelmts) - return 0; + break; - for( j = 0; j < cd_nelmts; j++) - { - if (cd_values[j] != filter[i].cd_values[j]) - { - return 0; - } + default: + if ( cd_nelmts != filter[i].cd_nelmts) + return 0; - } - break; + for( j = 0; j < cd_nelmts; j++) + if (cd_values[j] != filter[i].cd_values[j]) + return 0; + break; } /* switch */ - } return 1; |