[svn-r20855] Issue 2599 - Cross-test BE and LE data. I added the test for deflate, szip, fletcher32, shuffle and nbit filter in cross_read.c and gen_cross.c. I also took out the data file for OpenVMS because the data isn't native but IEEE for floating-numbers.

Tested on koala, heiwa, and jam.
This commit is contained in:
Raymond Lu 2011-05-17 17:18:05 -05:00
parent 29411fc602
commit 89339ccce5
5 changed files with 841 additions and 783 deletions

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -27,7 +27,8 @@
#include "h5test.h"
#define H5FILE_NAME "data.h5"
#define DATASETNAME "Array"
#define DATASETNAME "Array_le"
#define DATASETNAME1 "Array_be"
#define DATASETNAME2 "Scale_offset_float_data_le"
#define DATASETNAME3 "Scale_offset_float_data_be"
#define DATASETNAME4 "Scale_offset_double_data_le"
@ -40,6 +41,18 @@
#define DATASETNAME11 "Scale_offset_int_data_be"
#define DATASETNAME12 "Scale_offset_long_long_data_le"
#define DATASETNAME13 "Scale_offset_long_long_data_be"
#define DATASETNAME14 "Fletcher_float_data_le"
#define DATASETNAME15 "Fletcher_float_data_be"
#define DATASETNAME16 "Deflate_float_data_le"
#define DATASETNAME17 "Deflate_float_data_be"
#define DATASETNAME18 "Szip_float_data_le"
#define DATASETNAME19 "Szip_float_data_be"
#define DATASETNAME20 "Shuffle_float_data_le"
#define DATASETNAME21 "Shuffle_float_data_be"
#define DATASETNAME22 "Nbit_float_data_le"
#define DATASETNAME23 "Nbit_float_data_be"
#define NX 6
#define NY 6
#define RANK 2
@ -53,6 +66,11 @@ int create_scale_offset_dsets_char(hid_t fid, hid_t fsid, hid_t msid);
int create_scale_offset_dsets_short(hid_t fid, hid_t fsid, hid_t msid);
int create_scale_offset_dsets_int(hid_t fid, hid_t fsid, hid_t msid);
int create_scale_offset_dsets_long_long(hid_t fid, hid_t fsid, hid_t msid);
int create_fletcher_dsets_float(hid_t fid, hid_t fsid, hid_t msid);
int create_deflate_dsets_float(hid_t fid, hid_t fsid, hid_t msid);
int create_szip_dsets_float(hid_t fid, hid_t fsid, hid_t msid);
int create_shuffle_dsets_float(hid_t fid, hid_t fsid, hid_t msid);
int create_nbit_dsets_float(hid_t fid, hid_t fsid, hid_t msid);
/*-------------------------------------------------------------------------
@ -84,15 +102,15 @@ create_normal_dset(hid_t fid, hid_t fsid, hid_t msid)
*/
for (j = 0; j < NX; j++) {
for (i = 0; i < NY; i++)
data[j][i] = i + j;
data[j][i] = ((float)(i + j + 1)) / 3;
}
/*
* 0 1 2 3 4 5
* 1 2 3 4 5 6
* 2 3 4 5 6 7
* 3 4 5 6 7 8
* 4 5 6 7 8 9
* 5 6 7 8 9 10
* 1/3 2/3 3/3 4/3 5/3 6/3
* 2/3 3/3 4/3 5/3 6/3 7/3
* 3/3 4/3 5/3 6/3 7/3 8/3
* 4/3 5/3 6/3 7/3 8/3 9/3
* 5/3 6/3 7/3 8/3 9/3 10/3
* 6/3 7/3 8/3 9/3 10/3 11/3
* -2.2 -2.2 -2.2 -2.2 -2.2 -2.2
*/
@ -106,9 +124,9 @@ create_normal_dset(hid_t fid, hid_t fsid, hid_t msid)
/*
* Create a new dataset within the file using defined dataspace and
* datatype and default dataset creation properties.
* little-endian datatype and default dataset creation properties.
*/
if((dataset = H5Dcreate2(fid, DATASETNAME, H5T_NATIVE_DOUBLE, fsid,
if((dataset = H5Dcreate2(fid, DATASETNAME, H5T_IEEE_F64LE, fsid,
H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
TEST_ERROR
@ -118,13 +136,37 @@ create_normal_dset(hid_t fid, hid_t fsid, hid_t msid)
if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0)
TEST_ERROR
/*
* Close dataset
*/
if(H5Dclose(dataset) < 0)
TEST_ERROR
/*
* Create a new dataset within the file using defined dataspace and
* big-endian datatype and default dataset creation properties.
*/
if((dataset = H5Dcreate2(fid, DATASETNAME1, H5T_IEEE_F64BE, fsid,
H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
TEST_ERROR
/*
* Write the data to the dataset using default transfer properties.
*/
if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0)
TEST_ERROR
/*
* Close dataset
*/
if(H5Dclose(dataset) < 0)
TEST_ERROR
/*
* Close/release resources.
*/
if(H5Pclose(dcpl) < 0)
TEST_ERROR
if(H5Dclose(dataset) < 0)
TEST_ERROR
return 0;
@ -772,6 +814,527 @@ error:
#endif /* H5_HAVE_FILTER_SCALEOFFSET */
}
/*-------------------------------------------------------------------------
* Function: create_fletcher_dsets_float
*
* Purpose: Create a dataset of FLOAT datatype with fletcher filter
*
* Return: Success: 0
* Failure: -1
*
* Programmer: Raymond Lu
* 29 March 2011
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
int
create_fletcher_dsets_float(hid_t fid, hid_t fsid, hid_t msid)
{
#ifdef H5_HAVE_FILTER_FLETCHER32
hid_t dataset; /* dataset handles */
hid_t dcpl;
float data[NX][NY]; /* data to write */
float fillvalue = -2.2;
hsize_t chunk[RANK] = {CHUNK0, CHUNK1};
int i, j;
/*
* Data and output buffer initialization.
*/
for (j = 0; j < NX; j++) {
for (i = 0; i < NY; i++)
data[j][i] = ((float)(i + j + 1))/3;
}
/*
* Create the dataset creation property list, add the Scale-Offset
* filter, set the chunk size, and set the fill value.
*/
if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
TEST_ERROR
if(H5Pset_filter(dcpl, H5Z_FILTER_FLETCHER32, 0, (size_t)0, NULL) < 0)
TEST_ERROR
if(H5Pset_chunk(dcpl, RANK, chunk) < 0)
TEST_ERROR
if(H5Pset_fill_value(dcpl, H5T_NATIVE_FLOAT, &fillvalue) < 0)
TEST_ERROR
/*
* Create a new dataset within the file using defined dataspace, little
* endian datatype and default dataset creation properties.
*/
if((dataset = H5Dcreate2(fid, DATASETNAME14, H5T_IEEE_F32LE, fsid,
H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
TEST_ERROR
/*
* Write the data to the dataset using default transfer properties.
*/
if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0)
TEST_ERROR
/* Close dataset */
if(H5Dclose(dataset) < 0)
TEST_ERROR
/* Now create a dataset with a big-endian type */
if((dataset = H5Dcreate2(fid, DATASETNAME15, H5T_IEEE_F32BE, fsid,
H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
TEST_ERROR
if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0)
TEST_ERROR
if(H5Dclose(dataset) < 0)
TEST_ERROR
/*
* Close/release resources.
*/
if(H5Pclose(dcpl) < 0)
TEST_ERROR
#else /* H5_HAVE_FILTER_FLETCHER32 */
const char *not_supported= "Fletcher filter is not enabled. Can't create the dataset.";
puts(not_supported);
#endif /* H5_HAVE_FILTER_FLETCHER32 */
return 0;
#ifdef H5_HAVE_FILTER_FLETCHER32
error:
H5E_BEGIN_TRY {
H5Pclose(dcpl);
H5Dclose(dataset);
} H5E_END_TRY;
return -1;
#endif /* H5_HAVE_FILTER_FLETCHER32 */
}
/*-------------------------------------------------------------------------
* Function: create_deflate_dsets_float
*
* Purpose: Create a dataset of FLOAT datatype with deflate filter
*
* Return: Success: 0
* Failure: -1
*
* Programmer: Raymond Lu
* 29 March 2011
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
int
create_deflate_dsets_float(hid_t fid, hid_t fsid, hid_t msid)
{
#ifdef H5_HAVE_FILTER_DEFLATE
hid_t dataset; /* dataset handles */
hid_t dcpl;
float data[NX][NY]; /* data to write */
float fillvalue = -2.2;
hsize_t chunk[RANK] = {CHUNK0, CHUNK1};
int i, j;
/*
* Data and output buffer initialization.
*/
for (j = 0; j < NX; j++) {
for (i = 0; i < NY; i++)
data[j][i] = ((float)(i + j + 1))/3;
}
/*
* Create the dataset creation property list, add the Scale-Offset
* filter, set the chunk size, and set the fill value.
*/
if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
TEST_ERROR
if(H5Pset_deflate (dcpl, 6) < 0)
TEST_ERROR
if(H5Pset_chunk(dcpl, RANK, chunk) < 0)
TEST_ERROR
if(H5Pset_fill_value(dcpl, H5T_NATIVE_FLOAT, &fillvalue) < 0)
TEST_ERROR
/*
* Create a new dataset within the file using defined dataspace, little
* endian datatype and default dataset creation properties.
*/
if((dataset = H5Dcreate2(fid, DATASETNAME16, H5T_IEEE_F32LE, fsid,
H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
TEST_ERROR
/*
* Write the data to the dataset using default transfer properties.
*/
if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0)
TEST_ERROR
/* Close dataset */
if(H5Dclose(dataset) < 0)
TEST_ERROR
/* Now create a dataset with a big-endian type */
if((dataset = H5Dcreate2(fid, DATASETNAME17, H5T_IEEE_F32BE, fsid,
H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
TEST_ERROR
if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0)
TEST_ERROR
if(H5Dclose(dataset) < 0)
TEST_ERROR
/*
* Close/release resources.
*/
if(H5Pclose(dcpl) < 0)
TEST_ERROR
#else /* H5_HAVE_FILTER_DEFLATE */
const char *not_supported= "Deflate filter is not enabled. Can't create the dataset.";
puts(not_supported);
#endif /* H5_HAVE_FILTER_DEFLATE */
return 0;
#ifdef H5_HAVE_FILTER_DEFLATE
error:
H5E_BEGIN_TRY {
H5Pclose(dcpl);
H5Dclose(dataset);
} H5E_END_TRY;
return -1;
#endif /* H5_HAVE_FILTER_DEFLATE */
}
/*-------------------------------------------------------------------------
* Function: create_szip_dsets_float
*
* Purpose: Create a dataset of FLOAT datatype with szip filter
*
* Return: Success: 0
* Failure: -1
*
* Programmer: Raymond Lu
* 29 March 2011
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
int
create_szip_dsets_float(hid_t fid, hid_t fsid, hid_t msid)
{
#ifdef H5_HAVE_FILTER_SZIP
hid_t dataset; /* dataset handles */
hid_t dcpl;
float data[NX][NY]; /* data to write */
float fillvalue = -2.2;
hsize_t chunk[RANK] = {CHUNK0, CHUNK1};
int i, j;
/*
* Data and output buffer initialization.
*/
for (j = 0; j < NX; j++) {
for (i = 0; i < NY; i++)
data[j][i] = ((float)(i + j + 1))/3;
}
/*
* Create the dataset creation property list, add the Scale-Offset
* filter, set the chunk size, and set the fill value.
*/
if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
TEST_ERROR
if(H5Pset_szip(dcpl, H5_SZIP_NN_OPTION_MASK, 4) < 0)
TEST_ERROR
if(H5Pset_chunk(dcpl, RANK, chunk) < 0)
TEST_ERROR
if(H5Pset_fill_value(dcpl, H5T_NATIVE_FLOAT, &fillvalue) < 0)
TEST_ERROR
/*
* Create a new dataset within the file using defined dataspace, little
* endian datatype and default dataset creation properties.
*/
if((dataset = H5Dcreate2(fid, DATASETNAME18, H5T_IEEE_F32LE, fsid,
H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
TEST_ERROR
/*
* Write the data to the dataset using default transfer properties.
*/
if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0)
TEST_ERROR
/* Close dataset */
if(H5Dclose(dataset) < 0)
TEST_ERROR
/* Now create a dataset with a big-endian type */
if((dataset = H5Dcreate2(fid, DATASETNAME19, H5T_IEEE_F32BE, fsid,
H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
TEST_ERROR
if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0)
TEST_ERROR
if(H5Dclose(dataset) < 0)
TEST_ERROR
/*
* Close/release resources.
*/
if(H5Pclose(dcpl) < 0)
TEST_ERROR
#else /* H5_HAVE_FILTER_SZIP */
const char *not_supported= "Szip filter is not enabled. Can't create the dataset.";
puts(not_supported);
#endif /* H5_HAVE_FILTER_SZIP */
return 0;
#ifdef H5_HAVE_FILTER_SZIP
error:
H5E_BEGIN_TRY {
H5Pclose(dcpl);
H5Dclose(dataset);
} H5E_END_TRY;
return -1;
#endif /* H5_HAVE_FILTER_SZIP */
}
/*-------------------------------------------------------------------------
* Function: create_shuffle_dsets_float
*
* Purpose: Create a dataset of FLOAT datatype with shuffle filter
*
* Return: Success: 0
* Failure: -1
*
* Programmer: Raymond Lu
* 29 March 2011
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
int
create_shuffle_dsets_float(hid_t fid, hid_t fsid, hid_t msid)
{
#ifdef H5_HAVE_FILTER_SHUFFLE
hid_t dataset; /* dataset handles */
hid_t dcpl;
float data[NX][NY]; /* data to write */
float fillvalue = -2.2;
hsize_t chunk[RANK] = {CHUNK0, CHUNK1};
int i, j;
/*
* Data and output buffer initialization.
*/
for (j = 0; j < NX; j++) {
for (i = 0; i < NY; i++)
data[j][i] = ((float)(i + j + 1))/3;
}
/*
* Create the dataset creation property list, add the Scale-Offset
* filter, set the chunk size, and set the fill value.
*/
if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
TEST_ERROR
if(H5Pset_shuffle (dcpl) < 0)
TEST_ERROR
if(H5Pset_chunk(dcpl, RANK, chunk) < 0)
TEST_ERROR
if(H5Pset_fill_value(dcpl, H5T_NATIVE_FLOAT, &fillvalue) < 0)
TEST_ERROR
/*
* Create a new dataset within the file using defined dataspace, little
* endian datatype and default dataset creation properties.
*/
if((dataset = H5Dcreate2(fid, DATASETNAME20, H5T_IEEE_F32LE, fsid,
H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
TEST_ERROR
/*
* Write the data to the dataset using default transfer properties.
*/
if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0)
TEST_ERROR
/* Close dataset */
if(H5Dclose(dataset) < 0)
TEST_ERROR
/* Now create a dataset with a big-endian type */
if((dataset = H5Dcreate2(fid, DATASETNAME21, H5T_IEEE_F32BE, fsid,
H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
TEST_ERROR
if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0)
TEST_ERROR
if(H5Dclose(dataset) < 0)
TEST_ERROR
/*
* Close/release resources.
*/
if(H5Pclose(dcpl) < 0)
TEST_ERROR
#else /* H5_HAVE_FILTER_SHUFFLE */
const char *not_supported= "Shuffle filter is not enabled. Can't create the dataset.";
puts(not_supported);
#endif /* H5_HAVE_FILTER_SHUFFLE */
return 0;
#ifdef H5_HAVE_FILTER_SHUFFLE
error:
H5E_BEGIN_TRY {
H5Pclose(dcpl);
H5Dclose(dataset);
} H5E_END_TRY;
return -1;
#endif /* H5_HAVE_FILTER_SHUFFLE */
}
/*-------------------------------------------------------------------------
* Function: create_nbit_dsets_float
*
* Purpose: Create a dataset of FLOAT datatype with nbit filter
*
* Return: Success: 0
* Failure: -1
*
* Programmer: Raymond Lu
* 29 March 2011
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
int
create_nbit_dsets_float(hid_t fid, hid_t fsid, hid_t msid)
{
#ifdef H5_HAVE_FILTER_NBIT
hid_t dataset; /* dataset handles */
hid_t datatype;
hid_t dcpl;
size_t precision, offset;
float data[NX][NY]; /* data to write */
float fillvalue = -2.2;
hsize_t chunk[RANK] = {CHUNK0, CHUNK1};
int i, j;
/*
* Data and output buffer initialization.
*/
for (j = 0; j < NX; j++) {
for (i = 0; i < NY; i++)
data[j][i] = ((float)(i + j + 1))/3;
}
/*
* Create the dataset creation property list, add the Scale-Offset
* filter, set the chunk size, and set the fill value.
*/
if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0)
TEST_ERROR
if(H5Pset_nbit(dcpl) < 0)
TEST_ERROR
if(H5Pset_chunk(dcpl, RANK, chunk) < 0)
TEST_ERROR
if(H5Pset_fill_value(dcpl, H5T_NATIVE_FLOAT, &fillvalue) < 0)
TEST_ERROR
/* Define user-defined single-precision floating-point type for dataset.
* A 20-bit little-endian data type. */
if((datatype = H5Tcopy(H5T_IEEE_F32LE)) < 0)
TEST_ERROR
if(H5Tset_fields(datatype, (size_t)26, (size_t)20, (size_t)6, (size_t)7, (size_t)13) < 0)
TEST_ERROR
offset = 7;
if(H5Tset_offset(datatype,offset) < 0)
TEST_ERROR
precision = 20;
if(H5Tset_precision(datatype,precision) < 0)
TEST_ERROR
if(H5Tset_size(datatype, (size_t)4) < 0)
TEST_ERROR
if(H5Tset_ebias(datatype, (size_t)31) < 0)
TEST_ERROR
/*
* Create a new dataset within the file using defined dataspace,
* user-defined datatype, and default dataset creation properties.
*/
if((dataset = H5Dcreate2(fid, DATASETNAME22, datatype, fsid,
H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
TEST_ERROR
/*
* Write the data to the dataset using default transfer properties.
*/
if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0)
TEST_ERROR
/* Close dataset */
if(H5Dclose(dataset) < 0)
TEST_ERROR
/* Now create a dataset with a big-endian type */
if(H5Tset_order(datatype, H5T_ORDER_BE) < 0)
TEST_ERROR
if((dataset = H5Dcreate2(fid, DATASETNAME23, datatype, fsid,
H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
TEST_ERROR
if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0)
TEST_ERROR
if(H5Dclose(dataset) < 0)
TEST_ERROR
/*
* Close/release resources.
*/
if(H5Pclose(dcpl) < 0)
TEST_ERROR
#else /* H5_HAVE_FILTER_NBIT */
const char *not_supported= "Nbit filter is not enabled. Can't create the dataset.";
puts(not_supported);
#endif /* H5_HAVE_FILTER_NBIT */
return 0;
#ifdef H5_HAVE_FILTER_NBIT
error:
H5E_BEGIN_TRY {
H5Pclose(dcpl);
H5Dclose(dataset);
} H5E_END_TRY;
return -1;
#endif /* H5_HAVE_FILTER_NBIT */
}
/*-------------------------------------------------------------------------
* Function: main
@ -853,6 +1416,27 @@ main (void)
if(create_scale_offset_dsets_long_long(file, filespace, memspace) < 0)
{H5_FAILED(); AT(); return 1;}
/* Create a dataset of FLOAT with fletcher filter */
if(create_fletcher_dsets_float(file, filespace, memspace) < 0)
{H5_FAILED(); AT(); return 1;}
/* Create a dataset of FLOAT with deflate filter */
if(create_deflate_dsets_float(file, filespace, memspace) < 0)
{H5_FAILED(); AT(); return 1;}
/* Create a dataset of FLOAT with szip filter */
if(create_szip_dsets_float(file, filespace, memspace) < 0)
{H5_FAILED(); AT(); return 1;}
/* Create a dataset of FLOAT with shuffle filter */
if(create_shuffle_dsets_float(file, filespace, memspace) < 0)
{H5_FAILED(); AT(); return 1;}
/* Create a dataset of FLOAT with nbit filter */
if(create_nbit_dsets_float(file, filespace, memspace) < 0)
{H5_FAILED(); AT(); return 1;}
/*
* Close/release resources.
*/

Binary file not shown.

Binary file not shown.