mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-01-24 15:25:00 +08:00
[svn-r20006] I updated the read buffer from float to double to be more appropriate.
Tested on jam and linew.
This commit is contained in:
parent
2f60f82453
commit
2528e7021f
@ -61,6 +61,8 @@ static int read_data(char *fname)
|
||||
hid_t dt;
|
||||
float data_in[NX][NY]; /* input buffer */
|
||||
float data_out[NX][NY]; /* output buffer */
|
||||
double double_data_in[NX][NY]; /* input buffer */
|
||||
double double_data_out[NX][NY]; /* output buffer */
|
||||
int int_data_in[NX][NY]; /* input buffer */
|
||||
int int_data_out[NX][NY]; /* output buffer */
|
||||
int i, j;
|
||||
@ -159,8 +161,8 @@ static int read_data(char *fname)
|
||||
*/
|
||||
for (j = 0; j < NX; j++) {
|
||||
for (i = 0; i < NY; i++) {
|
||||
data_in[j][i] = ((double)(i + j + 1))/3;
|
||||
data_out[j][i] = 0;
|
||||
double_data_in[j][i] = ((double)(i + j + 1))/3;
|
||||
double_data_out[j][i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -177,17 +179,17 @@ static int read_data(char *fname)
|
||||
* Read data from hyperslab in the file into the hyperslab in
|
||||
* memory and display.
|
||||
*/
|
||||
if(H5Dread(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, data_out) < 0)
|
||||
if(H5Dread(dataset, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT, double_data_out) < 0)
|
||||
TEST_ERROR;
|
||||
|
||||
/* Check results */
|
||||
for (j=0; j<NX; j++) {
|
||||
for (i=0; i<NY; i++) {
|
||||
if (!DBL_REL_EQUAL(data_out[j][i], data_in[j][i], 0.001)) {
|
||||
if (!DBL_REL_EQUAL(double_data_out[j][i], double_data_in[j][i], 0.001)) {
|
||||
if (!nerrors++) {
|
||||
H5_FAILED();
|
||||
printf("element [%d][%d] is %g but should have been %g\n",
|
||||
j, i, data_out[j][i], data_in[j][i]);
|
||||
j, i, double_data_out[j][i], double_data_in[j][i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ int create_scale_offset_dset_int(hid_t fid, hid_t sid);
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: create_normal_dset
|
||||
*
|
||||
* Purpose: Create a regular dataset of DOUBLE datatype.
|
||||
* Purpose: Create a regular dataset of FLOAT datatype.
|
||||
*
|
||||
* Return: Success: 0
|
||||
* Failure: -1
|
||||
|
Loading…
Reference in New Issue
Block a user