2003-10-23 05:30:19 +08:00
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
|
|
* Copyright by the Board of Trustees of the University of Illinois. *
|
|
|
|
* All rights reserved. *
|
|
|
|
* *
|
|
|
|
* This file is part of HDF5. The full HDF5 copyright notice, including *
|
|
|
|
* terms governing use, modification, and redistribution, is contained in *
|
|
|
|
* the files COPYING and Copyright.html. COPYING can be found at the root *
|
|
|
|
* of the source code distribution tree; Copyright.html can be found at the *
|
|
|
|
* root level of an installed copy of the electronic HDF5 document set and *
|
|
|
|
* is linked from the top-level documents page. It can also be found at *
|
|
|
|
* http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
|
|
|
|
* access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
|
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
|
|
|
|
#include "h5diff.h"
|
2005-01-27 07:03:29 +08:00
|
|
|
#include "ph5diff.h"
|
2005-08-14 04:53:35 +08:00
|
|
|
#include "H5private.h"
|
2004-03-03 02:12:25 +08:00
|
|
|
#include "h5tools.h"
|
2003-10-23 05:30:19 +08:00
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: diff_dataset
|
|
|
|
*
|
2005-08-14 04:53:35 +08:00
|
|
|
* Purpose: check for comparable datasets and read into a compatible
|
2003-10-23 05:30:19 +08:00
|
|
|
* memory type
|
|
|
|
*
|
|
|
|
* Return: Number of differences found
|
|
|
|
*
|
|
|
|
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
|
|
|
|
*
|
|
|
|
* Date: May 9, 2003
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2005-08-14 04:53:35 +08:00
|
|
|
hsize_t diff_dataset( hid_t file1_id,
|
|
|
|
hid_t file2_id,
|
|
|
|
const char *obj1_name,
|
|
|
|
const char *obj2_name,
|
2004-07-21 03:21:03 +08:00
|
|
|
diff_opt_t *options )
|
2003-10-23 05:30:19 +08:00
|
|
|
{
|
2004-07-21 03:21:03 +08:00
|
|
|
hid_t dset1_id=-1;
|
|
|
|
hid_t dset2_id=-1;
|
|
|
|
hid_t dcpl1_id=-1;
|
|
|
|
hid_t dcpl2_id=-1;
|
|
|
|
hsize_t nfound=0;
|
2003-10-23 05:30:19 +08:00
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* open the handles
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2004-07-21 03:21:03 +08:00
|
|
|
/* disable error reporting */
|
|
|
|
H5E_BEGIN_TRY {
|
2003-10-23 05:30:19 +08:00
|
|
|
/* Open the datasets */
|
|
|
|
if ( (dset1_id = H5Dopen(file1_id,obj1_name)) < 0 )
|
|
|
|
{
|
|
|
|
printf("Cannot open dataset <%s>\n", obj1_name );
|
2004-07-21 03:21:03 +08:00
|
|
|
goto error;
|
2003-10-23 05:30:19 +08:00
|
|
|
}
|
|
|
|
if ( (dset2_id = H5Dopen(file2_id,obj2_name)) < 0 )
|
|
|
|
{
|
|
|
|
printf("Cannot open dataset <%s>\n", obj2_name );
|
2004-07-21 03:21:03 +08:00
|
|
|
goto error;
|
2003-10-23 05:30:19 +08:00
|
|
|
}
|
|
|
|
/* enable error reporting */
|
|
|
|
} H5E_END_TRY;
|
2004-07-21 03:21:03 +08:00
|
|
|
|
2003-10-23 05:30:19 +08:00
|
|
|
|
2005-08-14 04:53:35 +08:00
|
|
|
if ((dcpl1_id=H5Dget_create_plist(dset1_id))<0)
|
2004-07-21 03:21:03 +08:00
|
|
|
goto error;
|
2005-08-14 04:53:35 +08:00
|
|
|
if ((dcpl2_id=H5Dget_create_plist(dset2_id))<0)
|
2004-07-21 03:21:03 +08:00
|
|
|
goto error;
|
2004-03-03 02:12:25 +08:00
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2005-08-14 04:53:35 +08:00
|
|
|
* check if the dataset creation property list has filters that
|
|
|
|
* are not registered in the current configuration
|
2004-03-03 02:12:25 +08:00
|
|
|
* 1) the external filters GZIP and SZIP might not be available
|
|
|
|
* 2) the internal filters might be turned off
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2004-07-21 03:21:03 +08:00
|
|
|
if ((h5tools_canreadf((options->m_verbose?obj1_name:NULL),dcpl1_id)==1) &&
|
2005-08-14 04:53:35 +08:00
|
|
|
(h5tools_canreadf((options->m_verbose?obj2_name:NULL),dcpl2_id)==1))
|
2004-03-03 02:12:25 +08:00
|
|
|
{
|
|
|
|
nfound=diff_datasetid(dset1_id,
|
2003-12-03 07:13:27 +08:00
|
|
|
dset2_id,
|
|
|
|
obj1_name,
|
|
|
|
obj2_name,
|
|
|
|
options);
|
2004-03-03 02:12:25 +08:00
|
|
|
}
|
2003-12-03 07:13:27 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* close
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2004-07-21 03:21:03 +08:00
|
|
|
/* disable error reporting */
|
|
|
|
H5E_BEGIN_TRY {
|
|
|
|
H5Pclose(dcpl1_id);
|
|
|
|
H5Pclose(dcpl2_id);
|
|
|
|
H5Dclose(dset1_id);
|
|
|
|
H5Dclose(dset2_id);
|
|
|
|
/* enable error reporting */
|
|
|
|
} H5E_END_TRY;
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2004-07-21 03:21:03 +08:00
|
|
|
return nfound;
|
|
|
|
|
|
|
|
error:
|
|
|
|
options->err_stat=1;
|
2003-12-03 07:13:27 +08:00
|
|
|
/* disable error reporting */
|
|
|
|
H5E_BEGIN_TRY {
|
2004-03-03 02:12:25 +08:00
|
|
|
H5Pclose(dcpl1_id);
|
|
|
|
H5Pclose(dcpl2_id);
|
2003-12-03 07:13:27 +08:00
|
|
|
H5Dclose(dset1_id);
|
|
|
|
H5Dclose(dset2_id);
|
|
|
|
/* enable error reporting */
|
|
|
|
} H5E_END_TRY;
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2003-12-03 07:13:27 +08:00
|
|
|
return nfound;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: diff_datasetid
|
|
|
|
*
|
2005-08-14 04:53:35 +08:00
|
|
|
* Purpose: check for comparable datasets and read into a compatible
|
2003-12-03 07:13:27 +08:00
|
|
|
* memory type
|
|
|
|
*
|
|
|
|
* Return: Number of differences found
|
|
|
|
*
|
|
|
|
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
|
|
|
|
*
|
|
|
|
* Date: May 9, 2003
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2005-08-14 04:53:35 +08:00
|
|
|
hsize_t diff_datasetid( hid_t dset1_id,
|
|
|
|
hid_t dset2_id,
|
|
|
|
const char *obj1_name,
|
|
|
|
const char *obj2_name,
|
2004-07-21 03:21:03 +08:00
|
|
|
diff_opt_t *options )
|
2003-12-03 07:13:27 +08:00
|
|
|
{
|
|
|
|
hid_t space1_id =-1;
|
|
|
|
hid_t space2_id =-1;
|
2005-08-14 04:53:35 +08:00
|
|
|
hid_t f_type1=-1, f_type2=-1; /* file data type */
|
2003-12-03 07:13:27 +08:00
|
|
|
hid_t m_type1=-1, m_type2=-1; /* memory data type */
|
|
|
|
size_t m_size1, m_size2; /* size of type in memory */
|
|
|
|
H5T_sign_t sign1, sign2; /* sign of type */
|
2005-08-14 04:53:35 +08:00
|
|
|
int rank1, rank2;
|
2003-12-03 07:13:27 +08:00
|
|
|
void *buf1=NULL, *buf2=NULL;
|
|
|
|
hsize_t nelmts1, nelmts2;
|
|
|
|
hsize_t dims1[H5S_MAX_RANK];
|
|
|
|
hsize_t dims2[H5S_MAX_RANK];
|
|
|
|
hsize_t maxdim1[H5S_MAX_RANK];
|
|
|
|
hsize_t maxdim2[H5S_MAX_RANK];
|
|
|
|
const char *name1=NULL; /* relative names */
|
|
|
|
const char *name2=NULL;
|
|
|
|
hsize_t storage_size1;
|
|
|
|
hsize_t storage_size2;
|
2004-07-21 03:21:03 +08:00
|
|
|
hsize_t nfound=0; /* number of differences found */
|
|
|
|
int cmp=1; /* do diff or not */
|
2004-04-18 12:10:09 +08:00
|
|
|
int i;
|
2003-12-03 07:13:27 +08:00
|
|
|
|
2004-07-21 03:21:03 +08:00
|
|
|
/* Get the dataspace handle */
|
2004-05-26 23:46:26 +08:00
|
|
|
if ( (space1_id = H5Dget_space(dset1_id)) < 0 )
|
2004-07-21 03:21:03 +08:00
|
|
|
goto error;
|
2004-05-26 23:46:26 +08:00
|
|
|
|
2003-10-23 05:30:19 +08:00
|
|
|
/* Get rank */
|
2004-05-26 23:46:26 +08:00
|
|
|
if ( (rank1 = H5Sget_simple_extent_ndims(space1_id)) < 0 )
|
2004-07-21 03:21:03 +08:00
|
|
|
goto error;
|
2004-05-26 23:46:26 +08:00
|
|
|
|
2004-07-21 03:21:03 +08:00
|
|
|
/* Get the dataspace handle */
|
|
|
|
if ( (space2_id = H5Dget_space(dset2_id)) < 0 )
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
/* Get rank */
|
2003-10-23 05:30:19 +08:00
|
|
|
if ( (rank2 = H5Sget_simple_extent_ndims(space2_id)) < 0 )
|
2004-07-21 03:21:03 +08:00
|
|
|
goto error;
|
2003-10-23 05:30:19 +08:00
|
|
|
|
|
|
|
/* Get dimensions */
|
|
|
|
if ( H5Sget_simple_extent_dims(space1_id,dims1,maxdim1) < 0 )
|
2004-07-21 03:21:03 +08:00
|
|
|
goto error;
|
2003-10-23 05:30:19 +08:00
|
|
|
|
2004-07-21 03:21:03 +08:00
|
|
|
/* Get dimensions */
|
2003-10-23 05:30:19 +08:00
|
|
|
if ( H5Sget_simple_extent_dims(space2_id,dims2,maxdim2) < 0 )
|
2004-07-21 03:21:03 +08:00
|
|
|
goto error;
|
2003-10-23 05:30:19 +08:00
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2005-08-14 04:53:35 +08:00
|
|
|
* Get the file data type
|
2003-10-23 05:30:19 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Get the data type */
|
|
|
|
if ( (f_type1 = H5Dget_type(dset1_id)) < 0 )
|
2004-07-21 03:21:03 +08:00
|
|
|
goto error;
|
2003-10-23 05:30:19 +08:00
|
|
|
|
|
|
|
/* Get the data type */
|
|
|
|
if ( (f_type2 = H5Dget_type(dset2_id)) < 0 )
|
2004-07-21 03:21:03 +08:00
|
|
|
goto error;
|
2003-10-23 05:30:19 +08:00
|
|
|
|
|
|
|
|
2003-10-30 22:40:01 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* check for empty datasets
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
storage_size1=H5Dget_storage_size(dset1_id);
|
|
|
|
storage_size2=H5Dget_storage_size(dset2_id);
|
|
|
|
if (storage_size1<=0 && storage_size2<=0)
|
2003-10-31 01:15:56 +08:00
|
|
|
{
|
2005-08-14 04:53:35 +08:00
|
|
|
if (options->m_verbose && obj1_name && obj2_name)
|
2005-06-29 00:25:42 +08:00
|
|
|
parallel_print("<%s> and <%s> are empty datasets\n", obj1_name, obj2_name);
|
|
|
|
cmp=0;
|
|
|
|
options->not_cmp=1;
|
2003-10-31 01:15:56 +08:00
|
|
|
}
|
2003-10-30 22:40:01 +08:00
|
|
|
|
|
|
|
|
2003-10-23 05:30:19 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2003-11-04 06:10:57 +08:00
|
|
|
* check for comparable TYPE and SPACE
|
2003-10-23 05:30:19 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2005-08-14 04:53:35 +08:00
|
|
|
if (diff_can_type(f_type1,
|
|
|
|
f_type2,
|
|
|
|
rank1,
|
2003-11-04 06:10:57 +08:00
|
|
|
rank2,
|
2005-08-14 04:53:35 +08:00
|
|
|
dims1,
|
2003-11-04 06:10:57 +08:00
|
|
|
dims2,
|
2005-08-14 04:53:35 +08:00
|
|
|
maxdim1,
|
2003-11-04 06:10:57 +08:00
|
|
|
maxdim2,
|
2005-08-14 04:53:35 +08:00
|
|
|
obj1_name,
|
|
|
|
obj2_name,
|
2003-11-04 06:10:57 +08:00
|
|
|
options)!=1)
|
2005-06-29 00:25:42 +08:00
|
|
|
{
|
2004-07-21 03:21:03 +08:00
|
|
|
cmp=0;
|
2005-06-29 00:25:42 +08:00
|
|
|
options->not_cmp=1;
|
|
|
|
}
|
2006-03-21 03:39:46 +08:00
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* only attempt to compare if possible
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
if (cmp)
|
|
|
|
{
|
|
|
|
|
2003-10-23 05:30:19 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* get number of elements
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2003-12-03 07:13:27 +08:00
|
|
|
nelmts1 = 1;
|
2005-08-14 04:53:35 +08:00
|
|
|
for (i = 0; i < rank1; i++)
|
2003-10-23 05:30:19 +08:00
|
|
|
{
|
2003-12-03 07:13:27 +08:00
|
|
|
nelmts1 *= dims1[i];
|
2003-10-23 05:30:19 +08:00
|
|
|
}
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2003-12-03 07:13:27 +08:00
|
|
|
nelmts2 = 1;
|
2005-08-14 04:53:35 +08:00
|
|
|
for (i = 0; i < rank2; i++)
|
2003-10-23 05:30:19 +08:00
|
|
|
{
|
2003-12-03 07:13:27 +08:00
|
|
|
nelmts2 *= dims2[i];
|
2003-10-23 05:30:19 +08:00
|
|
|
}
|
|
|
|
|
2006-03-21 03:39:46 +08:00
|
|
|
/* only assert if the space is the same */
|
|
|
|
assert(nelmts1==nelmts2);
|
2003-10-23 05:30:19 +08:00
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* memory type and sizes
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2004-10-07 00:11:18 +08:00
|
|
|
if ((m_type1=h5tools_get_native_type(f_type1))<0)
|
|
|
|
goto error;
|
2003-10-23 05:30:19 +08:00
|
|
|
|
2004-10-07 00:11:18 +08:00
|
|
|
if ((m_type2=h5tools_get_native_type(f_type2))<0)
|
|
|
|
goto error;
|
2003-10-23 05:30:19 +08:00
|
|
|
|
|
|
|
m_size1 = H5Tget_size( m_type1 );
|
|
|
|
m_size2 = H5Tget_size( m_type2 );
|
|
|
|
|
|
|
|
#if defined (H5DIFF_DEBUG)
|
2003-12-03 07:13:27 +08:00
|
|
|
if (obj1_name)
|
|
|
|
print_sizes(obj1_name,obj2_name,f_type1,f_type2,m_type1,m_type2);
|
2005-08-14 04:53:35 +08:00
|
|
|
#endif
|
2003-10-23 05:30:19 +08:00
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* check for different signed/unsigned types
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
sign1=H5Tget_sign(m_type1);
|
|
|
|
sign2=H5Tget_sign(m_type2);
|
|
|
|
if ( sign1 != sign2 )
|
|
|
|
{
|
2006-03-21 03:39:46 +08:00
|
|
|
if (options->m_verbose && obj1_name) {
|
|
|
|
parallel_print("Comparison not supported: <%s> has sign %s ", obj1_name, get_sign(sign1));
|
|
|
|
parallel_print("and <%s> has sign %s\n", obj2_name, get_sign(sign2));
|
|
|
|
}
|
|
|
|
|
|
|
|
cmp=0;
|
|
|
|
options->not_cmp=1;
|
2003-10-23 05:30:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2005-08-14 04:53:35 +08:00
|
|
|
* "upgrade" the smaller memory size
|
2003-10-23 05:30:19 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
if ( m_size1 != m_size2 )
|
|
|
|
{
|
|
|
|
if ( m_size1 < m_size2 )
|
|
|
|
{
|
2003-11-01 05:18:09 +08:00
|
|
|
H5Tclose(m_type1);
|
2006-03-21 03:39:46 +08:00
|
|
|
|
2004-10-07 00:11:18 +08:00
|
|
|
if ((m_type1=h5tools_get_native_type(f_type2))<0)
|
2006-03-21 03:39:46 +08:00
|
|
|
goto error;
|
|
|
|
|
2003-10-23 05:30:19 +08:00
|
|
|
m_size1 = H5Tget_size( m_type1 );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-11-01 05:18:09 +08:00
|
|
|
H5Tclose(m_type2);
|
2006-03-21 03:39:46 +08:00
|
|
|
|
2004-10-07 00:11:18 +08:00
|
|
|
if ((m_type2=h5tools_get_native_type(f_type1))<0)
|
2006-03-21 03:39:46 +08:00
|
|
|
goto error;
|
|
|
|
|
2003-10-23 05:30:19 +08:00
|
|
|
m_size2 = H5Tget_size( m_type2 );
|
|
|
|
}
|
|
|
|
#if defined (H5DIFF_DEBUG)
|
|
|
|
printf("WARNING: Size was upgraded\n");
|
2003-12-03 07:13:27 +08:00
|
|
|
if (obj1_name)
|
2006-03-21 03:39:46 +08:00
|
|
|
print_sizes(obj1_name,obj2_name,f_type1,f_type2,m_type1,m_type2);
|
2005-08-14 04:53:35 +08:00
|
|
|
#endif
|
2003-10-23 05:30:19 +08:00
|
|
|
}
|
|
|
|
assert(m_size1==m_size2);
|
|
|
|
|
2004-07-21 03:21:03 +08:00
|
|
|
|
2003-12-03 07:13:27 +08:00
|
|
|
buf1 = (void *) HDmalloc((unsigned) (nelmts1*m_size1));
|
|
|
|
buf2 = (void *) HDmalloc((unsigned) (nelmts2*m_size2));
|
2003-10-23 05:30:19 +08:00
|
|
|
|
|
|
|
if ( buf1 == NULL || buf2 == NULL )
|
|
|
|
{
|
|
|
|
printf( "cannot read into memory\n" );
|
2004-07-21 03:21:03 +08:00
|
|
|
goto error;
|
2003-10-23 05:30:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* read
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
if ( H5Dread(dset1_id,m_type1,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf1) < 0 )
|
2004-07-21 03:21:03 +08:00
|
|
|
goto error;
|
2003-10-23 05:30:19 +08:00
|
|
|
|
|
|
|
if ( H5Dread(dset2_id,m_type2,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf2) < 0 )
|
2004-07-21 03:21:03 +08:00
|
|
|
goto error;
|
2003-10-23 05:30:19 +08:00
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* array compare
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2005-06-14 04:06:47 +08:00
|
|
|
if (obj1_name) {
|
2004-07-21 03:21:03 +08:00
|
|
|
name1=diff_basename(obj1_name);
|
2005-06-14 04:06:47 +08:00
|
|
|
}
|
|
|
|
if (obj2_name) {
|
2004-07-21 03:21:03 +08:00
|
|
|
name2=diff_basename(obj2_name);
|
2005-06-14 04:06:47 +08:00
|
|
|
}
|
2005-08-14 04:53:35 +08:00
|
|
|
nfound = diff_array(buf1,
|
2003-12-03 07:13:27 +08:00
|
|
|
buf2,
|
|
|
|
nelmts1,
|
|
|
|
rank1,
|
|
|
|
dims1,
|
|
|
|
options,
|
|
|
|
name1,
|
|
|
|
name2,
|
|
|
|
m_type1,
|
|
|
|
dset1_id,
|
|
|
|
dset2_id);
|
2003-11-04 06:10:57 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* compare attributes
|
2003-12-05 03:35:33 +08:00
|
|
|
* the if condition refers to cases when the dataset is a referenced object
|
2003-11-04 06:10:57 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2003-12-05 03:35:33 +08:00
|
|
|
if (obj1_name)
|
2004-07-21 03:21:03 +08:00
|
|
|
diff_attr(dset1_id,dset2_id,obj1_name,obj2_name,options);
|
|
|
|
|
|
|
|
}/*cmp*/
|
2003-11-04 06:10:57 +08:00
|
|
|
|
2003-10-23 05:30:19 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* close
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
|
|
|
2003-10-23 05:30:19 +08:00
|
|
|
if ( buf1) HDfree(buf1);
|
|
|
|
if ( buf2) HDfree(buf2);
|
2004-07-21 03:21:03 +08:00
|
|
|
/* close */
|
|
|
|
/* disable error reporting */
|
|
|
|
H5E_BEGIN_TRY {
|
|
|
|
H5Sclose(space1_id);
|
|
|
|
H5Sclose(space2_id);
|
|
|
|
H5Tclose(f_type1);
|
|
|
|
H5Tclose(f_type2);
|
|
|
|
H5Tclose(m_type1);
|
|
|
|
H5Tclose(m_type2);
|
|
|
|
/* enable error reporting */
|
|
|
|
} H5E_END_TRY;
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2004-07-21 03:21:03 +08:00
|
|
|
return nfound;
|
|
|
|
|
|
|
|
error:
|
|
|
|
options->err_stat=1;
|
|
|
|
if ( buf1) HDfree(buf1);
|
|
|
|
if ( buf2) HDfree(buf2);
|
2003-11-01 05:18:09 +08:00
|
|
|
/* close */
|
|
|
|
/* disable error reporting */
|
|
|
|
H5E_BEGIN_TRY {
|
|
|
|
H5Sclose(space1_id);
|
|
|
|
H5Sclose(space2_id);
|
|
|
|
H5Tclose(f_type1);
|
|
|
|
H5Tclose(f_type2);
|
|
|
|
H5Tclose(m_type1);
|
|
|
|
H5Tclose(m_type2);
|
|
|
|
/* enable error reporting */
|
|
|
|
} H5E_END_TRY;
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2003-10-23 05:30:19 +08:00
|
|
|
return nfound;
|
|
|
|
}
|
|
|
|
|
2003-11-04 06:10:57 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: diff_can_type
|
|
|
|
*
|
|
|
|
* Purpose: check for comparable TYPE and SPACE
|
|
|
|
*
|
2005-08-14 04:53:35 +08:00
|
|
|
* Return:
|
2003-11-04 06:10:57 +08:00
|
|
|
* 1, can compare
|
|
|
|
* 0, cannot compare
|
|
|
|
* -1, error
|
|
|
|
*
|
|
|
|
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
|
|
|
|
*
|
|
|
|
* Date: November 3, 2003
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2005-08-14 04:53:35 +08:00
|
|
|
int diff_can_type( hid_t f_type1, /* file data type */
|
2003-11-04 06:10:57 +08:00
|
|
|
hid_t f_type2, /* file data type */
|
2005-08-14 04:53:35 +08:00
|
|
|
int rank1,
|
2003-11-04 06:10:57 +08:00
|
|
|
int rank2,
|
2005-08-14 04:53:35 +08:00
|
|
|
hsize_t *dims1,
|
2003-11-04 06:10:57 +08:00
|
|
|
hsize_t *dims2,
|
2005-08-14 04:53:35 +08:00
|
|
|
hsize_t *maxdim1,
|
2003-11-04 06:10:57 +08:00
|
|
|
hsize_t *maxdim2,
|
2005-08-14 04:53:35 +08:00
|
|
|
const char *obj1_name,
|
|
|
|
const char *obj2_name,
|
2003-11-04 06:10:57 +08:00
|
|
|
diff_opt_t *options )
|
|
|
|
{
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
|
|
|
2003-11-04 06:10:57 +08:00
|
|
|
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;
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2005-08-14 04:53:35 +08:00
|
|
|
* check for the same class
|
2003-11-04 06:10:57 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2005-08-14 04:53:35 +08:00
|
|
|
if ((tclass1=H5Tget_class(f_type1))<0)
|
2003-11-04 06:10:57 +08:00
|
|
|
return -1;
|
|
|
|
|
2005-08-14 04:53:35 +08:00
|
|
|
if ((tclass2=H5Tget_class(f_type2))<0)
|
2003-11-04 06:10:57 +08:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
if ( tclass1 != tclass2 )
|
|
|
|
{
|
2004-07-21 03:21:03 +08:00
|
|
|
if (options->m_verbose && obj1_name) {
|
2005-08-14 04:53:35 +08:00
|
|
|
printf("Comparison not possible: <%s> is of class %s and <%s> is of class %s\n",
|
|
|
|
obj1_name, get_class(tclass1),
|
2003-11-04 06:10:57 +08:00
|
|
|
obj2_name, get_class(tclass2) );
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* check for non supported classes
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
assert(tclass1==tclass2);
|
2005-08-14 04:53:35 +08:00
|
|
|
switch (tclass1)
|
2003-11-04 06:10:57 +08:00
|
|
|
{
|
|
|
|
case H5T_INTEGER:
|
|
|
|
case H5T_FLOAT:
|
|
|
|
case H5T_COMPOUND:
|
|
|
|
case H5T_STRING:
|
|
|
|
case H5T_ARRAY:
|
|
|
|
case H5T_BITFIELD:
|
|
|
|
case H5T_OPAQUE:
|
|
|
|
case H5T_ENUM:
|
|
|
|
case H5T_VLEN:
|
2003-12-03 07:13:27 +08:00
|
|
|
case H5T_REFERENCE:
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2003-12-03 07:13:27 +08:00
|
|
|
break;
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2003-12-03 07:13:27 +08:00
|
|
|
default: /*H5T_TIME */
|
2005-08-14 04:53:35 +08:00
|
|
|
if (options->m_verbose && obj1_name )
|
|
|
|
printf("Comparison not supported: <%s> and <%s> are of class %s\n",
|
2003-12-03 07:13:27 +08:00
|
|
|
obj1_name,obj2_name,get_class(tclass2) );
|
2003-11-04 06:10:57 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* check for equal file datatype; warning only
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2005-08-14 04:53:35 +08:00
|
|
|
if ( (H5Tequal(f_type1, f_type2)==0) && options->m_verbose && obj1_name)
|
2003-11-04 06:10:57 +08:00
|
|
|
{
|
|
|
|
printf("Warning: Different storage datatype\n");
|
|
|
|
printf("<%s> has file datatype ", obj1_name);
|
|
|
|
print_type(f_type1);
|
|
|
|
printf("\n");
|
|
|
|
printf("<%s> has file datatype ", obj2_name);
|
|
|
|
print_type(f_type2);
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* check for the same rank
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2003-11-04 06:10:57 +08:00
|
|
|
if ( rank1 != rank2 )
|
|
|
|
{
|
2004-07-21 03:21:03 +08:00
|
|
|
if (options->m_verbose && obj1_name) {
|
2003-12-03 07:13:27 +08:00
|
|
|
printf("Comparison not supported: <%s> has rank %d, dimensions ", obj1_name, rank1);
|
2003-11-04 06:10:57 +08:00
|
|
|
print_dims(rank1,dims1);
|
|
|
|
printf(", max dimensions ");
|
|
|
|
print_dims(rank1,maxdim1);
|
|
|
|
printf("\n" );
|
|
|
|
printf("<%s> has rank %d, dimensions ", obj2_name, rank2);
|
|
|
|
print_dims(rank2,dims2);
|
|
|
|
printf(", max dimensions ");
|
|
|
|
print_dims(rank2,maxdim2);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* check for different dimensions
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2003-11-04 06:10:57 +08:00
|
|
|
assert(rank1==rank2);
|
2005-08-14 04:53:35 +08:00
|
|
|
for ( i=0; i<rank1; i++)
|
2003-11-04 06:10:57 +08:00
|
|
|
{
|
|
|
|
if (maxdim1 && maxdim2)
|
|
|
|
{
|
|
|
|
if ( maxdim1[i] != maxdim2[i] )
|
|
|
|
maxdim_diff=1;
|
|
|
|
}
|
|
|
|
if ( dims1[i] != dims2[i] )
|
|
|
|
dim_diff=1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* current dimensions
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (dim_diff==1)
|
|
|
|
{
|
2004-07-21 03:21:03 +08:00
|
|
|
if (options->m_verbose && obj1_name) {
|
2003-12-03 07:13:27 +08:00
|
|
|
printf("Comparison not supported: <%s> has rank %d, dimensions ", obj1_name, rank1);
|
2003-11-04 06:10:57 +08:00
|
|
|
print_dims(rank1,dims1);
|
|
|
|
if (maxdim1 && maxdim2) {
|
|
|
|
printf(", max dimensions ");
|
|
|
|
print_dims(rank1,maxdim1);
|
|
|
|
printf("\n" );
|
|
|
|
printf("<%s> has rank %d, dimensions ", obj2_name, rank2);
|
|
|
|
print_dims(rank2,dims2);
|
|
|
|
printf(", max dimensions ");
|
|
|
|
print_dims(rank2,maxdim2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* maximum dimensions; just give a warning
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2003-12-03 07:13:27 +08:00
|
|
|
if (maxdim1 && maxdim2 && maxdim_diff==1 && obj1_name )
|
2003-11-04 06:10:57 +08:00
|
|
|
{
|
2004-07-21 03:21:03 +08:00
|
|
|
if (options->m_verbose) {
|
2003-11-04 06:10:57 +08:00
|
|
|
printf( "Warning: Different maximum dimensions\n");
|
|
|
|
printf("<%s> has max dimensions ", obj1_name);
|
|
|
|
print_dims(rank1,maxdim1);
|
|
|
|
printf("\n");
|
|
|
|
printf("<%s> has max dimensions ", obj2_name);
|
|
|
|
print_dims(rank2,maxdim2);
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|