mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-03-31 17:10:47 +08:00
[svn-r14317] code maintenance: code cleaning and reorganizing of the h5repack verify routines
tested: windows, linux
This commit is contained in:
parent
06f2e446a6
commit
46e3f4ad7e
@ -194,8 +194,6 @@ int can_read(const char* name, /* object name from traverse list */
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int has_layout(hid_t dcpl_id,
|
||||
pack_info_t *obj);
|
||||
|
||||
int layout_this(hid_t dcpl_id, /* DCPL from input object */
|
||||
const char* name, /* object name from traverse list */
|
||||
|
@ -18,6 +18,195 @@
|
||||
#include "h5tools_utils.h"
|
||||
|
||||
extern char *progname;
|
||||
static int has_filter(hid_t dcpl_id, H5Z_filter_t filtnin);
|
||||
static int has_layout(hid_t dcpl_id,pack_info_t *obj);
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: h5repack_verify
|
||||
*
|
||||
* Purpose: verify if the filters and layout specified in the options list are
|
||||
* present on the OUTPUT file
|
||||
*
|
||||
* Return: 1=present, 0=not present, -1=error
|
||||
*
|
||||
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
|
||||
*
|
||||
* Date: December 19, 2003
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int h5repack_verify(const char *fname,
|
||||
pack_opt_t *options)
|
||||
{
|
||||
hid_t fid; /* file ID */
|
||||
hid_t dset_id = -1; /* dataset ID */
|
||||
hid_t dcpl_id = -1; /* dataset creation property list ID */
|
||||
hid_t space_id = -1; /* space ID */
|
||||
unsigned int i;
|
||||
int j;
|
||||
trav_table_t *travt = NULL;
|
||||
int have = 1;
|
||||
|
||||
/* open the file */
|
||||
if((fid = H5Fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0 )
|
||||
return -1;
|
||||
|
||||
for(i = 0; i < options->op_tbl->nelems; i++)
|
||||
{
|
||||
char* name = options->op_tbl->objs[i].path;
|
||||
pack_info_t *obj = &options->op_tbl->objs[i];
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* open
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
if((dset_id = H5Dopen2(fid, name, H5P_DEFAULT)) < 0)
|
||||
goto error;
|
||||
if((space_id = H5Dget_space(dset_id)) < 0)
|
||||
goto error;
|
||||
if((dcpl_id = H5Dget_create_plist(dset_id)) < 0)
|
||||
goto error;
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* filter check
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
for(j = 0; j < obj->nfilters; j++)
|
||||
{
|
||||
if(has_filter(dcpl_id, obj->filter[j].filtn) == 0)
|
||||
have = 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* layout check
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
if((obj->layout != -1) && (has_layout(dcpl_id, obj) == 0))
|
||||
have = 0;
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* close
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
if(H5Pclose(dcpl_id) < 0)
|
||||
goto error;
|
||||
if (H5Sclose(space_id) < 0)
|
||||
goto error;
|
||||
if (H5Dclose(dset_id) < 0)
|
||||
goto error;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* check for the "all" objects option
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
if(options->all_filter == 1 || options->all_layout == 1)
|
||||
{
|
||||
|
||||
/* init table */
|
||||
trav_table_init(&travt);
|
||||
|
||||
/* get the list of objects in the file */
|
||||
if(h5trav_gettable(fid, travt) < 0)
|
||||
goto error;
|
||||
|
||||
for(i = 0; i < travt->nobjs; i++)
|
||||
{
|
||||
char *name = travt->objs[i].name;
|
||||
|
||||
if(travt->objs[i].type == H5TRAV_TYPE_DATASET)
|
||||
{
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* open
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
if((dset_id = H5Dopen2(fid, name, H5P_DEFAULT)) < 0)
|
||||
goto error;
|
||||
if((space_id = H5Dget_space(dset_id)) < 0)
|
||||
goto error;
|
||||
if((dcpl_id = H5Dget_create_plist(dset_id)) < 0)
|
||||
goto error;
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* filter check
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
if(options->all_filter == 1)
|
||||
{
|
||||
int k;
|
||||
|
||||
for (k = 0; k < options->n_filter_g; k++ )
|
||||
{
|
||||
if (has_filter(dcpl_id, options->filter_g[k].filtn) == 0)
|
||||
have = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* layout check
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
if(options->all_layout == 1)
|
||||
{
|
||||
pack_info_t pack;
|
||||
init_packobject(&pack);
|
||||
pack.layout = options->layout_g;
|
||||
pack.chunk = options->chunk_g;
|
||||
if(has_layout(dcpl_id, &pack) == 0)
|
||||
have = 0;
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* close
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
if (H5Pclose(dcpl_id) < 0)
|
||||
goto error;
|
||||
if (H5Sclose(space_id) < 0)
|
||||
goto error;
|
||||
if (H5Dclose(dset_id) < 0)
|
||||
goto error;
|
||||
} /* if */
|
||||
|
||||
} /* i */
|
||||
|
||||
/* free table */
|
||||
trav_table_free(travt);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* close
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
if (H5Fclose(fid) < 0)
|
||||
return -1;
|
||||
|
||||
return have;
|
||||
|
||||
error:
|
||||
H5E_BEGIN_TRY {
|
||||
H5Pclose(dcpl_id);
|
||||
H5Sclose(space_id);
|
||||
H5Dclose(dset_id);
|
||||
H5Fclose(fid);
|
||||
if (travt)
|
||||
trav_table_free(travt);
|
||||
} H5E_END_TRY;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
@ -34,40 +223,40 @@ extern char *progname;
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static int
|
||||
has_filter(hid_t dcpl_id, H5Z_filter_t filtnin)
|
||||
static int has_filter(hid_t dcpl_id, H5Z_filter_t filtnin)
|
||||
{
|
||||
int nfilters; /* number of filters */
|
||||
unsigned filt_flags; /* filter flags */
|
||||
H5Z_filter_t filtn; /* filter identification number */
|
||||
unsigned cd_values[20]; /* filter client data values */
|
||||
size_t cd_nelmts; /* filter client number of values */
|
||||
char f_name[256]; /* filter name */
|
||||
int have = 0; /* flag, filter is present */
|
||||
int i; /* index */
|
||||
|
||||
/* if no information about the input filter is requested return exit */
|
||||
if(filtnin == -1)
|
||||
return 1;
|
||||
|
||||
/* get information about filters */
|
||||
if((nfilters = H5Pget_nfilters(dcpl_id)) < 0)
|
||||
return -1;
|
||||
|
||||
/* if we do not have filters and the requested filter is NONE, return 1 */
|
||||
if(!nfilters && filtnin == H5Z_FILTER_NONE)
|
||||
return 1;
|
||||
|
||||
for(i = 0; i < nfilters; i++) {
|
||||
cd_nelmts = NELMTS(cd_values);
|
||||
filtn = H5Pget_filter2(dcpl_id, (unsigned)i, &filt_flags, &cd_nelmts,
|
||||
cd_values, sizeof(f_name), f_name, NULL);
|
||||
|
||||
if(filtnin == filtn)
|
||||
have = 1;
|
||||
}
|
||||
|
||||
return have;
|
||||
unsigned nfilters; /* number of filters */
|
||||
unsigned filt_flags; /* filter flags */
|
||||
H5Z_filter_t filtn; /* filter identification number */
|
||||
unsigned cd_values[20]; /* filter client data values */
|
||||
size_t cd_nelmts; /* filter client number of values */
|
||||
char f_name[256]; /* filter name */
|
||||
int have = 0; /* flag, filter is present */
|
||||
unsigned i; /* index */
|
||||
|
||||
/* if no information about the input filter is requested return exit */
|
||||
if(filtnin == -1)
|
||||
return 1;
|
||||
|
||||
/* get information about filters */
|
||||
if((nfilters = H5Pget_nfilters(dcpl_id)) < 0)
|
||||
return -1;
|
||||
|
||||
/* if we do not have filters and the requested filter is NONE, return 1 */
|
||||
if(!nfilters && filtnin == H5Z_FILTER_NONE)
|
||||
return 1;
|
||||
|
||||
for(i = 0; i < nfilters; i++)
|
||||
{
|
||||
cd_nelmts = NELMTS(cd_values);
|
||||
filtn = H5Pget_filter2(dcpl_id, i, &filt_flags, &cd_nelmts,
|
||||
cd_values, sizeof(f_name), f_name, NULL);
|
||||
|
||||
if(filtnin == filtn)
|
||||
have = 1;
|
||||
}
|
||||
|
||||
return have;
|
||||
}
|
||||
|
||||
|
||||
@ -92,223 +281,49 @@ has_filter(hid_t dcpl_id, H5Z_filter_t filtnin)
|
||||
int has_layout(hid_t dcpl_id,
|
||||
pack_info_t *obj)
|
||||
{
|
||||
hsize_t chsize[64]; /* chunk size in elements */
|
||||
H5D_layout_t layout; /* layout */
|
||||
int nfilters; /* number of filters */
|
||||
int rank; /* rank */
|
||||
int i; /* index */
|
||||
|
||||
/* if no information about the input layout is requested return exit */
|
||||
if (obj==NULL)
|
||||
return 1;
|
||||
|
||||
/* check if we have filters in the input object */
|
||||
if ((nfilters = H5Pget_nfilters(dcpl_id)) < 0)
|
||||
return -1;
|
||||
|
||||
/* a non chunked layout was requested on a filtered object; avoid the test */
|
||||
if (nfilters && obj->layout!=H5D_CHUNKED)
|
||||
return 1;
|
||||
|
||||
/* get layout */
|
||||
if ((layout = H5Pget_layout(dcpl_id)) < 0)
|
||||
return -1;
|
||||
|
||||
if (obj->layout != layout)
|
||||
return 0;
|
||||
|
||||
if (layout==H5D_CHUNKED)
|
||||
{
|
||||
if ((rank = H5Pget_chunk(dcpl_id,NELMTS(chsize),chsize/*out*/)) < 0)
|
||||
return -1;
|
||||
if (obj->chunk.rank != rank)
|
||||
return 0;
|
||||
for ( i=0; i<rank; i++)
|
||||
if (chsize[i] != obj->chunk.chunk_lengths[i])
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: h5repack_verify
|
||||
*
|
||||
* Purpose: verify if the filters specified in the options list are
|
||||
* present on the OUTPUT file
|
||||
*
|
||||
* Return: 1=filter present, 0=filter not present, -1=error
|
||||
*
|
||||
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
|
||||
*
|
||||
* Date: December 19, 2003
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int h5repack_verify(const char *fname,
|
||||
pack_opt_t *options)
|
||||
{
|
||||
hid_t fid; /* file ID */
|
||||
hid_t dset_id = -1; /* dataset ID */
|
||||
hid_t dcpl_id = -1; /* dataset creation property list ID */
|
||||
hid_t space_id = -1; /* space ID */
|
||||
int ret = 1;
|
||||
unsigned int i;
|
||||
int j;
|
||||
trav_table_t *travt = NULL;
|
||||
|
||||
/* open the file */
|
||||
if((fid = H5Fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0 )
|
||||
return -1;
|
||||
|
||||
for(i = 0; i < options->op_tbl->nelems; i++) {
|
||||
char* name = options->op_tbl->objs[i].path;
|
||||
pack_info_t *obj = &options->op_tbl->objs[i];
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* open
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
if((dset_id = H5Dopen2(fid, name, H5P_DEFAULT)) < 0)
|
||||
goto error;
|
||||
if((space_id = H5Dget_space(dset_id)) < 0)
|
||||
goto error;
|
||||
if((dcpl_id = H5Dget_create_plist(dset_id)) < 0)
|
||||
goto error;
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* filter check
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
for(j = 0; j < obj->nfilters; j++) {
|
||||
if(has_filter(dcpl_id, obj->filter[j].filtn) == 0)
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* layout check
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
if((obj->layout != -1) && (has_layout(dcpl_id, obj) == 0))
|
||||
ret = 0;
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* close
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
if(H5Pclose(dcpl_id) < 0)
|
||||
goto error;
|
||||
if (H5Sclose(space_id) < 0)
|
||||
goto error;
|
||||
if (H5Dclose(dset_id) < 0)
|
||||
goto error;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* check for the "all" objects option
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
if(options->all_filter == 1 || options->all_layout == 1) {
|
||||
|
||||
/* init table */
|
||||
trav_table_init(&travt);
|
||||
|
||||
/* get the list of objects in the file */
|
||||
if(h5trav_gettable(fid, travt) < 0)
|
||||
goto error;
|
||||
|
||||
for(i = 0; i < travt->nobjs; i++) {
|
||||
char *name = travt->objs[i].name;
|
||||
|
||||
if(travt->objs[i].type == H5TRAV_TYPE_DATASET) {
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* open
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
if((dset_id = H5Dopen2(fid, name, H5P_DEFAULT)) < 0)
|
||||
goto error;
|
||||
if((space_id = H5Dget_space(dset_id)) < 0)
|
||||
goto error;
|
||||
if((dcpl_id = H5Dget_create_plist(dset_id)) < 0)
|
||||
goto error;
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* filter check
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
if(options->all_filter == 1)
|
||||
hsize_t chsize[64]; /* chunk size in elements */
|
||||
H5D_layout_t layout; /* layout */
|
||||
int nfilters; /* number of filters */
|
||||
int rank; /* rank */
|
||||
int i; /* index */
|
||||
|
||||
/* if no information about the input layout is requested return exit */
|
||||
if (obj==NULL)
|
||||
return 1;
|
||||
|
||||
/* check if we have filters in the input object */
|
||||
if ((nfilters = H5Pget_nfilters(dcpl_id)) < 0)
|
||||
return -1;
|
||||
|
||||
/* a non chunked layout was requested on a filtered object; avoid the test */
|
||||
if (nfilters && obj->layout!=H5D_CHUNKED)
|
||||
return 1;
|
||||
|
||||
/* get layout */
|
||||
if ((layout = H5Pget_layout(dcpl_id)) < 0)
|
||||
return -1;
|
||||
|
||||
if (obj->layout != layout)
|
||||
return 0;
|
||||
|
||||
if (layout==H5D_CHUNKED)
|
||||
{
|
||||
int k;
|
||||
|
||||
for (k = 0; k < options->n_filter_g; k++ )
|
||||
{
|
||||
if (has_filter(dcpl_id, options->filter_g[k].filtn) == 0)
|
||||
ret = 0;
|
||||
}
|
||||
if ((rank = H5Pget_chunk(dcpl_id,NELMTS(chsize),chsize/*out*/)) < 0)
|
||||
return -1;
|
||||
if (obj->chunk.rank != rank)
|
||||
return 0;
|
||||
for ( i=0; i<rank; i++)
|
||||
if (chsize[i] != obj->chunk.chunk_lengths[i])
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* layout check
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
if(options->all_layout == 1) {
|
||||
pack_info_t pack;
|
||||
init_packobject(&pack);
|
||||
pack.layout = options->layout_g;
|
||||
pack.chunk = options->chunk_g;
|
||||
if(has_layout(dcpl_id, &pack) == 0)
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* close
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
if (H5Pclose(dcpl_id) < 0)
|
||||
goto error;
|
||||
if (H5Sclose(space_id) < 0)
|
||||
goto error;
|
||||
if (H5Dclose(dset_id) < 0)
|
||||
goto error;
|
||||
} /* if */
|
||||
|
||||
} /* i */
|
||||
|
||||
/* free table */
|
||||
trav_table_free(travt);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* close
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
if (H5Fclose(fid) < 0)
|
||||
return -1;
|
||||
|
||||
return ret;
|
||||
|
||||
error:
|
||||
H5E_BEGIN_TRY {
|
||||
H5Pclose(dcpl_id);
|
||||
H5Sclose(space_id);
|
||||
H5Dclose(dset_id);
|
||||
H5Fclose(fid);
|
||||
if (travt)
|
||||
trav_table_free(travt);
|
||||
} H5E_END_TRY;
|
||||
return -1;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: h5repack_cmpdcpl
|
||||
*
|
||||
@ -326,128 +341,133 @@ error:
|
||||
int h5repack_cmpdcpl(const char *fname1,
|
||||
const char *fname2)
|
||||
{
|
||||
hid_t fid1=-1; /* file ID */
|
||||
hid_t fid2=-1; /* file ID */
|
||||
hid_t dset1=-1; /* dataset ID */
|
||||
hid_t dset2=-1; /* dataset ID */
|
||||
hid_t dcpl1=-1; /* dataset creation property list ID */
|
||||
hid_t dcpl2=-1; /* dataset creation property list ID */
|
||||
trav_table_t *travt1=NULL;
|
||||
trav_table_t *travt2=NULL;
|
||||
int ret=1;
|
||||
unsigned int i;
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* open the files first; if they are not valid, no point in continuing
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* disable error reporting */
|
||||
H5E_BEGIN_TRY {
|
||||
|
||||
/* Open the files */
|
||||
if ((fid1=H5Fopen(fname1,H5F_ACC_RDONLY,H5P_DEFAULT)) < 0 )
|
||||
{
|
||||
error_msg(progname, "<%s>: %s\n", fname1, H5FOPENERROR );
|
||||
return -1;
|
||||
}
|
||||
if ((fid2=H5Fopen(fname2,H5F_ACC_RDONLY,H5P_DEFAULT)) < 0 )
|
||||
{
|
||||
error_msg(progname, "<%s>: %s\n", fname2, H5FOPENERROR );
|
||||
H5Fclose(fid1);
|
||||
return -1;
|
||||
}
|
||||
/* enable error reporting */
|
||||
} H5E_END_TRY;
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* get file table list of objects
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
trav_table_init(&travt1);
|
||||
trav_table_init(&travt2);
|
||||
if(h5trav_gettable(fid1, travt1) < 0)
|
||||
goto error;
|
||||
if(h5trav_gettable(fid2, travt2) < 0)
|
||||
goto error;
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* traverse the suppplied object list
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
for(i = 0; i < travt1->nobjs; i++) {
|
||||
if(travt1->objs[i].type == H5TRAV_TYPE_DATASET) {
|
||||
if((dset1 = H5Dopen2(fid1, travt1->objs[i].name, H5P_DEFAULT)) < 0)
|
||||
goto error;
|
||||
if((dset2 = H5Dopen2(fid2, travt1->objs[i].name, H5P_DEFAULT)) < 0)
|
||||
goto error;
|
||||
if((dcpl1 = H5Dget_create_plist(dset1)) < 0)
|
||||
goto error;
|
||||
if((dcpl2 = H5Dget_create_plist(dset2)) < 0)
|
||||
goto error;
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* compare the property lists
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
if((ret = H5Pequal(dcpl1, dcpl2)) < 0)
|
||||
goto error;
|
||||
|
||||
if(ret == 0) {
|
||||
error_msg(progname, "property lists for <%s> are different\n",travt1->objs[i].name);
|
||||
goto error;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* close
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
if(H5Pclose(dcpl1) < 0)
|
||||
goto error;
|
||||
if(H5Pclose(dcpl2) < 0)
|
||||
goto error;
|
||||
if(H5Dclose(dset1) < 0)
|
||||
goto error;
|
||||
if(H5Dclose(dset2) < 0)
|
||||
goto error;
|
||||
} /*if*/
|
||||
} /*i*/
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* free
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
trav_table_free(travt1);
|
||||
trav_table_free(travt2);
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* close
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
H5Fclose(fid1);
|
||||
H5Fclose(fid2);
|
||||
return ret;
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* error
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
hid_t fid1=-1; /* file ID */
|
||||
hid_t fid2=-1; /* file ID */
|
||||
hid_t dset1=-1; /* dataset ID */
|
||||
hid_t dset2=-1; /* dataset ID */
|
||||
hid_t dcpl1=-1; /* dataset creation property list ID */
|
||||
hid_t dcpl2=-1; /* dataset creation property list ID */
|
||||
trav_table_t *travt1=NULL;
|
||||
trav_table_t *travt2=NULL;
|
||||
int ret=1;
|
||||
unsigned int i;
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* open the files
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* disable error reporting */
|
||||
H5E_BEGIN_TRY
|
||||
{
|
||||
|
||||
/* Open the files */
|
||||
if ((fid1=H5Fopen(fname1,H5F_ACC_RDONLY,H5P_DEFAULT)) < 0 )
|
||||
{
|
||||
error_msg(progname, "<%s>: %s\n", fname1, H5FOPENERROR );
|
||||
return -1;
|
||||
}
|
||||
if ((fid2=H5Fopen(fname2,H5F_ACC_RDONLY,H5P_DEFAULT)) < 0 )
|
||||
{
|
||||
error_msg(progname, "<%s>: %s\n", fname2, H5FOPENERROR );
|
||||
H5Fclose(fid1);
|
||||
return -1;
|
||||
}
|
||||
/* enable error reporting */
|
||||
} H5E_END_TRY;
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* get file table list of objects
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
trav_table_init(&travt1);
|
||||
trav_table_init(&travt2);
|
||||
if(h5trav_gettable(fid1, travt1) < 0)
|
||||
goto error;
|
||||
if(h5trav_gettable(fid2, travt2) < 0)
|
||||
goto error;
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* traverse the suppplied object list
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
for(i = 0; i < travt1->nobjs; i++)
|
||||
{
|
||||
if(travt1->objs[i].type == H5TRAV_TYPE_DATASET)
|
||||
{
|
||||
if((dset1 = H5Dopen2(fid1, travt1->objs[i].name, H5P_DEFAULT)) < 0)
|
||||
goto error;
|
||||
if((dset2 = H5Dopen2(fid2, travt1->objs[i].name, H5P_DEFAULT)) < 0)
|
||||
goto error;
|
||||
if((dcpl1 = H5Dget_create_plist(dset1)) < 0)
|
||||
goto error;
|
||||
if((dcpl2 = H5Dget_create_plist(dset2)) < 0)
|
||||
goto error;
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* compare the property lists
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
if((ret = H5Pequal(dcpl1, dcpl2)) < 0)
|
||||
goto error;
|
||||
|
||||
if(ret == 0)
|
||||
{
|
||||
error_msg(progname, "property lists for <%s> are different\n",travt1->objs[i].name);
|
||||
goto error;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* close
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
if(H5Pclose(dcpl1) < 0)
|
||||
goto error;
|
||||
if(H5Pclose(dcpl2) < 0)
|
||||
goto error;
|
||||
if(H5Dclose(dset1) < 0)
|
||||
goto error;
|
||||
if(H5Dclose(dset2) < 0)
|
||||
goto error;
|
||||
} /*if*/
|
||||
} /*i*/
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* free
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
trav_table_free(travt1);
|
||||
trav_table_free(travt2);
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* close
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
H5Fclose(fid1);
|
||||
H5Fclose(fid2);
|
||||
return ret;
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* error
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
error:
|
||||
H5E_BEGIN_TRY {
|
||||
H5Pclose(dcpl1);
|
||||
H5Pclose(dcpl2);
|
||||
H5Dclose(dset1);
|
||||
H5Dclose(dset2);
|
||||
H5Fclose(fid1);
|
||||
H5Fclose(fid2);
|
||||
trav_table_free(travt1);
|
||||
trav_table_free(travt2);
|
||||
} H5E_END_TRY;
|
||||
return -1;
|
||||
|
||||
H5E_BEGIN_TRY
|
||||
{
|
||||
H5Pclose(dcpl1);
|
||||
H5Pclose(dcpl2);
|
||||
H5Dclose(dset1);
|
||||
H5Dclose(dset2);
|
||||
H5Fclose(fid1);
|
||||
H5Fclose(fid2);
|
||||
trav_table_free(travt1);
|
||||
trav_table_free(travt2);
|
||||
} H5E_END_TRY;
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user