mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-01-18 15:15:56 +08:00
[svn-r7042] Purpose: bug fix
Description: H5Tget_native_type fails on Cray for compound datatype. Solution: there's size comfusion in the library on H5T_get_native_int function Platforms tested: Cray, h5committest Misc. update:
This commit is contained in:
parent
6f94c274c4
commit
20848c55fd
@ -524,6 +524,7 @@ H5T_get_native_integer(size_t size, H5T_sign_t sign, H5T_direction_t direction,
|
|||||||
H5T_t *dt; /* Appropriate native datatype to copy */
|
H5T_t *dt; /* Appropriate native datatype to copy */
|
||||||
hid_t tid=(-1); /* Datatype ID of appropriate native datatype */
|
hid_t tid=(-1); /* Datatype ID of appropriate native datatype */
|
||||||
size_t align=0; /* Alignment necessary for native datatype */
|
size_t align=0; /* Alignment necessary for native datatype */
|
||||||
|
size_t native_size=0; /* Datatype size of the native type */
|
||||||
enum match_type { /* The different kinds of integers we can match */
|
enum match_type { /* The different kinds of integers we can match */
|
||||||
H5T_NATIVE_INT_MATCH_CHAR,
|
H5T_NATIVE_INT_MATCH_CHAR,
|
||||||
H5T_NATIVE_INT_MATCH_SHORT,
|
H5T_NATIVE_INT_MATCH_SHORT,
|
||||||
@ -539,47 +540,69 @@ H5T_get_native_integer(size_t size, H5T_sign_t sign, H5T_direction_t direction,
|
|||||||
assert(size>0);
|
assert(size>0);
|
||||||
|
|
||||||
if(direction == H5T_DIR_DEFAULT || direction == H5T_DIR_ASCEND) {
|
if(direction == H5T_DIR_DEFAULT || direction == H5T_DIR_ASCEND) {
|
||||||
if(size<=sizeof(char))
|
if(size<=sizeof(char)) {
|
||||||
match=H5T_NATIVE_INT_MATCH_CHAR;
|
match=H5T_NATIVE_INT_MATCH_CHAR;
|
||||||
else if(size<=sizeof(short))
|
native_size = sizeof(char);
|
||||||
|
} else if(size<=sizeof(short)) {
|
||||||
match=H5T_NATIVE_INT_MATCH_SHORT;
|
match=H5T_NATIVE_INT_MATCH_SHORT;
|
||||||
else if(size<=sizeof(int))
|
native_size = sizeof(short);
|
||||||
|
} else if(size<=sizeof(int)) {
|
||||||
match=H5T_NATIVE_INT_MATCH_INT;
|
match=H5T_NATIVE_INT_MATCH_INT;
|
||||||
else if(size<=sizeof(long))
|
native_size = sizeof(int);
|
||||||
|
} else if(size<=sizeof(long)) {
|
||||||
match=H5T_NATIVE_INT_MATCH_LONG;
|
match=H5T_NATIVE_INT_MATCH_LONG;
|
||||||
else if(size<=sizeof(long_long))
|
native_size = sizeof(long);
|
||||||
|
} else if(size<=sizeof(long_long)) {
|
||||||
match=H5T_NATIVE_INT_MATCH_LLONG;
|
match=H5T_NATIVE_INT_MATCH_LLONG;
|
||||||
else /* If no native type matches the querried datatype, simply choose the type of biggest size. */
|
native_size = sizeof(long long);
|
||||||
|
} else { /* If no native type matches the querried datatype, simply choose the type of biggest size. */
|
||||||
match=H5T_NATIVE_INT_MATCH_LLONG;
|
match=H5T_NATIVE_INT_MATCH_LLONG;
|
||||||
|
native_size = sizeof(long long);
|
||||||
|
}
|
||||||
} else if(direction == H5T_DIR_DESCEND) {
|
} else if(direction == H5T_DIR_DESCEND) {
|
||||||
if(size>=sizeof(long_long))
|
if(size>=sizeof(long_long)) {
|
||||||
match=H5T_NATIVE_INT_MATCH_LLONG;
|
match=H5T_NATIVE_INT_MATCH_LLONG;
|
||||||
else if(size>=sizeof(long)) {
|
native_size = sizeof(long long);
|
||||||
if(size==sizeof(long))
|
} else if(size>=sizeof(long)) {
|
||||||
|
if(size==sizeof(long)) {
|
||||||
match=H5T_NATIVE_INT_MATCH_LONG;
|
match=H5T_NATIVE_INT_MATCH_LONG;
|
||||||
else
|
native_size = sizeof(long);
|
||||||
|
} else {
|
||||||
match=H5T_NATIVE_INT_MATCH_LLONG;
|
match=H5T_NATIVE_INT_MATCH_LLONG;
|
||||||
|
native_size = sizeof(long long);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(size>=sizeof(int)) {
|
else if(size>=sizeof(int)) {
|
||||||
if(size==sizeof(int))
|
if(size==sizeof(int)) {
|
||||||
match=H5T_NATIVE_INT_MATCH_INT;
|
match=H5T_NATIVE_INT_MATCH_INT;
|
||||||
else
|
native_size = sizeof(int);
|
||||||
|
} else {
|
||||||
match=H5T_NATIVE_INT_MATCH_LONG;
|
match=H5T_NATIVE_INT_MATCH_LONG;
|
||||||
|
native_size = sizeof(long);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(size>=sizeof(short)) {
|
else if(size>=sizeof(short)) {
|
||||||
if(size==sizeof(short))
|
if(size==sizeof(short)) {
|
||||||
match=H5T_NATIVE_INT_MATCH_SHORT;
|
match=H5T_NATIVE_INT_MATCH_SHORT;
|
||||||
else
|
native_size = sizeof(short);
|
||||||
|
} else {
|
||||||
match=H5T_NATIVE_INT_MATCH_INT;
|
match=H5T_NATIVE_INT_MATCH_INT;
|
||||||
|
native_size = sizeof(int);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(size>=sizeof(char)) {
|
else if(size>=sizeof(char)) {
|
||||||
if(size==sizeof(char))
|
if(size==sizeof(char)) {
|
||||||
match=H5T_NATIVE_INT_MATCH_CHAR;
|
match=H5T_NATIVE_INT_MATCH_CHAR;
|
||||||
else
|
native_size = sizeof(char);
|
||||||
|
} else {
|
||||||
match=H5T_NATIVE_INT_MATCH_SHORT;
|
match=H5T_NATIVE_INT_MATCH_SHORT;
|
||||||
|
native_size = sizeof(short);
|
||||||
}
|
}
|
||||||
else /* If no native type matches the querried datatype, simple choose the type of smallest size. */
|
}
|
||||||
|
else { /* If no native type matches the querried datatype, simple choose the type of smallest size. */
|
||||||
match=H5T_NATIVE_INT_MATCH_CHAR;
|
match=H5T_NATIVE_INT_MATCH_CHAR;
|
||||||
|
native_size = sizeof(char);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set the appropriate native datatype information */
|
/* Set the appropriate native datatype information */
|
||||||
@ -641,7 +664,7 @@ H5T_get_native_integer(size_t size, H5T_sign_t sign, H5T_direction_t direction,
|
|||||||
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type");
|
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type");
|
||||||
|
|
||||||
/* compute size and offset of compound type member. */
|
/* compute size and offset of compound type member. */
|
||||||
if(H5T_cmp_offset(comp_size, offset, size, 1, align, struct_align)<0)
|
if(H5T_cmp_offset(comp_size, offset, native_size, 1, align, struct_align)<0)
|
||||||
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset");
|
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset");
|
||||||
|
|
||||||
done:
|
done:
|
||||||
@ -671,6 +694,7 @@ H5T_get_native_float(size_t size, H5T_direction_t direction, size_t *struct_alig
|
|||||||
H5T_t *dt=NULL; /* Appropriate native datatype to copy */
|
H5T_t *dt=NULL; /* Appropriate native datatype to copy */
|
||||||
hid_t tid=(-1); /* Datatype ID of appropriate native datatype */
|
hid_t tid=(-1); /* Datatype ID of appropriate native datatype */
|
||||||
size_t align=0; /* Alignment necessary for native datatype */
|
size_t align=0; /* Alignment necessary for native datatype */
|
||||||
|
size_t native_size=0; /* Datatype size of the native type */
|
||||||
enum match_type { /* The different kinds of floating point types we can match */
|
enum match_type { /* The different kinds of floating point types we can match */
|
||||||
H5T_NATIVE_FLOAT_MATCH_FLOAT,
|
H5T_NATIVE_FLOAT_MATCH_FLOAT,
|
||||||
H5T_NATIVE_FLOAT_MATCH_DOUBLE,
|
H5T_NATIVE_FLOAT_MATCH_DOUBLE,
|
||||||
@ -684,31 +708,45 @@ H5T_get_native_float(size_t size, H5T_direction_t direction, size_t *struct_alig
|
|||||||
assert(size>0);
|
assert(size>0);
|
||||||
|
|
||||||
if(direction == H5T_DIR_DEFAULT || direction == H5T_DIR_ASCEND) {
|
if(direction == H5T_DIR_DEFAULT || direction == H5T_DIR_ASCEND) {
|
||||||
if(size<=sizeof(float))
|
if(size<=sizeof(float)) {
|
||||||
match=H5T_NATIVE_FLOAT_MATCH_FLOAT;
|
match=H5T_NATIVE_FLOAT_MATCH_FLOAT;
|
||||||
else if(size<=sizeof(double))
|
native_size = sizeof(float);
|
||||||
|
} else if(size<=sizeof(double)) {
|
||||||
match=H5T_NATIVE_FLOAT_MATCH_DOUBLE;
|
match=H5T_NATIVE_FLOAT_MATCH_DOUBLE;
|
||||||
else if(size<=sizeof(long double))
|
native_size = sizeof(double);
|
||||||
|
} else if(size<=sizeof(long double)) {
|
||||||
match=H5T_NATIVE_FLOAT_MATCH_LDOUBLE;
|
match=H5T_NATIVE_FLOAT_MATCH_LDOUBLE;
|
||||||
else /* If not match, return the biggest datatype */
|
native_size = sizeof(long double);
|
||||||
|
} else { /* If not match, return the biggest datatype */
|
||||||
match=H5T_NATIVE_FLOAT_MATCH_LDOUBLE;
|
match=H5T_NATIVE_FLOAT_MATCH_LDOUBLE;
|
||||||
|
native_size = sizeof(long);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if(size>=sizeof(long double))
|
if(size>=sizeof(long double)) {
|
||||||
match=H5T_NATIVE_FLOAT_MATCH_LDOUBLE;
|
match=H5T_NATIVE_FLOAT_MATCH_LDOUBLE;
|
||||||
else if(size>=sizeof(double)) {
|
native_size = sizeof(long double);
|
||||||
if(size==sizeof(double))
|
} else if(size>=sizeof(double)) {
|
||||||
|
if(size==sizeof(double)) {
|
||||||
match=H5T_NATIVE_FLOAT_MATCH_DOUBLE;
|
match=H5T_NATIVE_FLOAT_MATCH_DOUBLE;
|
||||||
else
|
native_size = sizeof(double);
|
||||||
|
} else {
|
||||||
match=H5T_NATIVE_FLOAT_MATCH_LDOUBLE;
|
match=H5T_NATIVE_FLOAT_MATCH_LDOUBLE;
|
||||||
|
native_size = sizeof(long double);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(size>=sizeof(float)) {
|
else if(size>=sizeof(float)) {
|
||||||
if(size==sizeof(float))
|
if(size==sizeof(float)) {
|
||||||
match=H5T_NATIVE_FLOAT_MATCH_FLOAT;
|
match=H5T_NATIVE_FLOAT_MATCH_FLOAT;
|
||||||
else
|
native_size = sizeof(float);
|
||||||
|
} else {
|
||||||
match=H5T_NATIVE_FLOAT_MATCH_DOUBLE;
|
match=H5T_NATIVE_FLOAT_MATCH_DOUBLE;
|
||||||
|
native_size = sizeof(double);
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
match=H5T_NATIVE_FLOAT_MATCH_FLOAT;
|
match=H5T_NATIVE_FLOAT_MATCH_FLOAT;
|
||||||
|
native_size = sizeof(float);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set the appropriate native floating point information */
|
/* Set the appropriate native floating point information */
|
||||||
@ -741,7 +779,7 @@ H5T_get_native_float(size_t size, H5T_direction_t direction, size_t *struct_alig
|
|||||||
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type");
|
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot retrieve float type");
|
||||||
|
|
||||||
/* compute offset of compound type member. */
|
/* compute offset of compound type member. */
|
||||||
if(H5T_cmp_offset(comp_size, offset, size, 1, align, struct_align)<0)
|
if(H5T_cmp_offset(comp_size, offset, native_size, 1, align, struct_align)<0)
|
||||||
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset");
|
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "cannot compute compound offset");
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
Loading…
Reference in New Issue
Block a user