diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2001-07-10 20:16:42 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2001-07-10 20:16:42 (GMT) |
commit | 0f6a8fbaad992aa3392889042fb6ba828fbde15e (patch) | |
tree | a3b5793aaae719bf72557c8a0330c56d55e553df | |
parent | 6b269cb0d74bf72b392129d50b2a819712de8218 (diff) | |
download | hdf5-0f6a8fbaad992aa3392889042fb6ba828fbde15e.zip hdf5-0f6a8fbaad992aa3392889042fb6ba828fbde15e.tar.gz hdf5-0f6a8fbaad992aa3392889042fb6ba828fbde15e.tar.bz2 |
[svn-r4177] Purpose:
Bug fix
Description:
Accommodate v1.2.x behavior when --enable-hdf5v1_2 is enabled.
Platforms tested:
FreeBSD 4.3 (hawkwind)
-rw-r--r-- | test/tarray.c | 54 | ||||
-rw-r--r-- | tools/h5dump/h5dump.c | 66 | ||||
-rw-r--r-- | tools/h5toh4/h5toh4.c | 44 | ||||
-rw-r--r-- | tools/lib/h5tools.c | 22 | ||||
-rw-r--r-- | tools/lib/h5tools_str.c | 22 |
5 files changed, 207 insertions, 1 deletions
diff --git a/test/tarray.c b/test/tarray.c index 7a1f27b..4175d9f 100644 --- a/test/tarray.c +++ b/test/tarray.c @@ -710,11 +710,13 @@ test_array_compound_array(void) hsize_t sdims1[] = {SPACE1_DIM1}; hsize_t tdims1[] = {ARRAY1_DIM1}; #ifdef WANT_H5_V1_2_COMPAT + size_t msize; size_t otdims1[] = {ARRAY1_DIM1}; #endif /* WANT_H5_V1_2_COMPAT */ int ndims; /* Array rank for reading */ hsize_t rdims1[H5S_MAX_RANK]; /* Array dimensions for reading */ #ifdef WANT_H5_V1_2_COMPAT + size_t rdims2[H5S_MAX_RANK]; /* Array dimensions for reading */ size_t ordims1[H5S_MAX_RANK]; /* Array dimensions for reading */ #endif /* WANT_H5_V1_2_COMPAT */ int nmemb; /* Number of compound members */ @@ -770,7 +772,7 @@ test_array_compound_array(void) /* Compatibility code to verify that the old API functions are still working */ #ifdef WANT_H5_V1_2_COMPAT - /* Insert float array field */ + /* Insert double array field */ ret = H5Tinsert_array (tid2, "d", HOFFSET(s1_t,d), ARRAY1_RANK,otdims1,NULL,H5T_NATIVE_DOUBLE); CHECK(ret, FAIL, "H5Tinsert_array"); #endif /* WANT_H5_V1_2_COMPAT */ @@ -888,6 +890,29 @@ test_array_compound_array(void) mtid=H5Tget_member_type(tid2,1); CHECK(mtid, FAIL, "H5Tget_member_type"); +#ifdef WANT_H5_V1_2_COMPAT + /* H5Tget_member_type() returns the base type in v1.2 */ + /* Get the 2nd field's class */ + mclass=H5Tget_class(mtid); + VERIFY(mclass, H5T_FLOAT, "H5Tget_class"); + + /* Get the 2nd field's size */ + msize=H5Tget_size(mtid); + VERIFY(msize, sizeof(float), "H5Tget_size"); + + /* Get the array dimensions */ + ndims=H5Tget_member_dims(tid2,1,rdims2,NULL); + VERIFY(ndims, ARRAY1_RANK, "H5Tget_member_dims"); + VERIFY(rdims2[0], ARRAY1_DIM1, "H5Tget_member_dims"); + + /* Check the array dimensions */ + for(i=0; i<ndims; i++) + if(rdims2[i]!=tdims1[i]) { + num_errs++; + printf("Nested array dimension information doesn't match!, rdims2[%d]=%d, tdims1[%d]=%d\n",(int)i,(int)rdims2[i],(int)i,(int)tdims1[i]); + continue; + } /* end if */ +#else /* WANT_H5_V1_2_COMPAT */ /* Get the 2nd field's class */ mclass=H5Tget_class(mtid); VERIFY(mclass, H5T_ARRAY, "H5Tget_class"); @@ -920,6 +945,7 @@ test_array_compound_array(void) /* Close the array's base type datatype */ ret=H5Tclose(tid3); CHECK(mtid, FAIL, "H5Tclose"); +#endif /* WANT_H5_V1_2_COMPAT */ /* Close the member datatype */ ret=H5Tclose(mtid); @@ -940,6 +966,19 @@ test_array_compound_array(void) off=H5Tget_member_offset(tid2,2); VERIFY(off, HOFFSET(s1_t,d), "H5Tget_member_offset"); + /* Check the 2nd field's datatype */ + mtid=H5Tget_member_type(tid2,2); + CHECK(mtid, FAIL, "H5Tget_member_type"); + + /* H5Tget_member_type() returns the base type in v1.2 */ + /* Get the 3rd field's class */ + mclass=H5Tget_class(mtid); + VERIFY(mclass, H5T_FLOAT, "H5Tget_class"); + + /* Get the 3rd field's size */ + msize=H5Tget_size(mtid); + VERIFY(msize, sizeof(double), "H5Tget_size"); + /* Check the array rank */ ndims=H5Tget_member_dims(tid2,2,ordims1,NULL); VERIFY(ndims,ARRAY1_RANK,"H5Tget_member_dims"); @@ -951,6 +990,11 @@ test_array_compound_array(void) printf("Nested array dimension information doesn't match!, ordims1[%d]=%d, otdims1[%d]=%d\n",(int)i,(int)ordims1[i],(int)i,(int)otdims1[i]); continue; } /* end if */ + + /* Close the member datatype */ + ret=H5Tclose(mtid); + CHECK(mtid, FAIL, "H5Tclose"); + #endif /* WANT_H5_V1_2_COMPAT */ /* Close Compound Datatype */ @@ -1831,16 +1875,20 @@ test_compat(void) hid_t fid1; /* HDF5 File IDs */ hid_t dataset; /* Dataset ID */ hid_t tid1; /* Array Datatype ID */ +#ifndef WANT_H5_V1_2_COMPAT hid_t tid2; /* Datatype ID */ hsize_t tdims1[] = {ARRAY1_DIM1}; int ndims; /* Array rank for reading */ hsize_t rdims1[H5S_MAX_RANK]; /* Array dimensions for reading */ +#endif /* !WANT_H5_V1_2_COMPAT */ H5T_class_t mclass; /* Datatype class for VL */ int nmemb; /* Number of compound members */ char *mname; /* Name of compound field */ size_t off; /* Offset of compound field */ hid_t mtid; /* Datatype ID for field */ +#ifndef WANT_H5_V1_2_COMPAT intn i; /* Index variables */ +#endif /* !WANT_H5_V1_2_COMPAT */ herr_t ret; /* Generic return value */ /* Output message about test being performed */ @@ -2014,6 +2062,7 @@ test_compat(void) off=H5Tget_member_offset(tid1,1); VERIFY(off, 4, "H5Tget_member_offset"); +#ifndef WANT_H5_V1_2_COMPAT /* Check the 2nd field's datatype */ mtid=H5Tget_member_type(tid1,1); CHECK(mtid, FAIL, "H5Tget_member_type"); @@ -2050,6 +2099,7 @@ test_compat(void) CHECK(ret, FAIL, "H5Tclose"); ret=H5Tclose(mtid); CHECK(ret, FAIL, "H5Tclose"); +#endif /* !WANT_H5_V1_2_COMPAT */ /* Check the 3rd field's name */ mname=H5Tget_member_name(tid1,2); @@ -2064,6 +2114,7 @@ test_compat(void) off=H5Tget_member_offset(tid1,2); VERIFY(off, 20, "H5Tget_member_offset"); +#ifndef WANT_H5_V1_2_COMPAT /* Check the 3rd field's datatype */ mtid=H5Tget_member_type(tid1,2); CHECK(mtid, FAIL, "H5Tget_member_type"); @@ -2100,6 +2151,7 @@ test_compat(void) CHECK(ret, FAIL, "H5Tclose"); ret=H5Tclose(mtid); CHECK(ret, FAIL, "H5Tclose"); +#endif /* !WANT_H5_V1_2_COMPAT */ /* Check the 4th field's name */ mname=H5Tget_member_name(tid1,3); diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index 50c293c..eea5913 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -862,6 +862,28 @@ print_datatype(hid_t type) for (i = 0; i < nmembers; i++) { fname = H5Tget_member_name(type, i); mtype = H5Tget_member_type(type, i); +#ifdef WANT_H5_V1_2_COMPAT + /* v1.2 returns the base type of an array field, work around this */ + { + hid_t new_mtype; /* datatype for array, if necessary */ + int arrndims; /* Array rank for reading */ + size_t dims[H5S_MAX_RANK]; /* Array dimensions for reading */ + hsize_t arrdims[H5S_MAX_RANK]; /* Array dimensions for reading */ + int k; /* Local index variable */ + + /* Get the array dimensions */ + arrndims=H5Tget_member_dims(type,i,dims,NULL); + + /* Patch up array information */ + if(arrndims>0) { + for(k=0; k<arrndims; k++) + arrdims[k]=dims[k]; + new_mtype=H5Tarray_create(mtype,arrndims,arrdims,NULL); + H5Tclose(mtype); + mtype=new_mtype; + } /* end if */ + } +#endif /* WANT_H5_V1_2_COMPAT */ indentation(indent + COL); @@ -3623,6 +3645,28 @@ xml_print_datatype(hid_t type) fname = H5Tget_member_name(type, i); mtype = H5Tget_member_type(type, i); +#ifdef WANT_H5_V1_2_COMPAT + /* v1.2 returns the base type of an array field, work around this */ + { + hid_t new_mtype; /* datatype for array, if necessary */ + int arrndims; /* Array rank for reading */ + size_t dims[H5S_MAX_RANK]; /* Array dimensions for reading */ + hsize_t arrdims[H5S_MAX_RANK]; /* Array dimensions for reading */ + int k; /* Local index variable */ + + /* Get the array dimensions */ + arrndims=H5Tget_member_dims(type,i,dims,NULL); + + /* Patch up array information */ + if(arrndims>0) { + for(k=0; k<arrndims; k++) + arrdims[k]=dims[k]; + new_mtype=H5Tarray_create(mtype,arrndims,arrdims,NULL); + H5Tclose(mtype); + mtype=new_mtype; + } /* end if */ + } +#endif /* WANT_H5_V1_2_COMPAT */ indentation(indent); t_fname = xml_escape_the_name(fname); printf("<Field FieldName=\"%s\">\n", t_fname); @@ -4180,6 +4224,28 @@ xml_dump_named_datatype(hid_t type, const char *name) fname = H5Tget_member_name(type, x); mtype = H5Tget_member_type(type, x); +#ifdef WANT_H5_V1_2_COMPAT + /* v1.2 returns the base type of an array field, work around this */ + { + hid_t new_mtype; /* datatype for array, if necessary */ + int arrndims; /* Array rank for reading */ + size_t dims[H5S_MAX_RANK]; /* Array dimensions for reading */ + hsize_t arrdims[H5S_MAX_RANK]; /* Array dimensions for reading */ + int k; /* Local index variable */ + + /* Get the array dimensions */ + arrndims=H5Tget_member_dims(type,x,dims,NULL); + + /* Patch up array information */ + if(arrndims>0) { + for(k=0; k<arrndims; k++) + arrdims[k]=dims[k]; + new_mtype=H5Tarray_create(mtype,arrndims,arrdims,NULL); + H5Tclose(mtype); + mtype=new_mtype; + } /* end if */ + } +#endif /* WANT_H5_V1_2_COMPAT */ indentation(indent); t_fname = xml_escape_the_name(fname); printf("<Field FieldName=\"%s\">\n", t_fname); diff --git a/tools/h5toh4/h5toh4.c b/tools/h5toh4/h5toh4.c index 853bfd8..09138b0 100644 --- a/tools/h5toh4/h5toh4.c +++ b/tools/h5toh4/h5toh4.c @@ -788,6 +788,28 @@ int32 order_array[512]; DEBUG_PRINT("Error detected in %s() [%s line %d]\n", "convert_dataset", __FILE__, __LINE__); break; } +#ifdef H5_WANT_H5_V1_2_COMPAT + /* v1.2 returns the base type of an array field, work around this */ + { + hid_t new_fieldtype; /* datatype for array, if necessary */ + int arrndims; /* Array rank for reading */ + size_t dims[H5S_MAX_RANK]; /* Array dimensions for reading */ + hsize_t arrdims[H5S_MAX_RANK]; /* Array dimensions for reading */ + int k; /* Local index variable */ + + /* Get the array dimensions */ + arrndims=H5Tget_member_dims(type,idx,dims,NULL); + + /* Patch up array information */ + if(arrndims>0) { + for(k=0; k<arrndims; k++) + arrdims[k]=dims[k]; + new_fieldtype=H5Tarray_create(fieldtype,arrndims,arrdims,NULL); + H5Tclose(fieldtype); + fieldtype=new_fieldtype; + } /* end if */ + } +#endif /* WANT_H5_V1_2_COMPAT */ /* Special case for array fields */ if(H5Tget_class(fieldtype)==H5T_ARRAY) { hid_t arr_base_type; @@ -910,6 +932,28 @@ int32 order_array[512]; DEBUG_PRINT("Error detected in %s() [%s line %d]\n", "convert_dataset", __FILE__, __LINE__); break; } +#ifdef H5_WANT_H5_V1_2_COMPAT + /* v1.2 returns the base type of an array field, work around this */ + { + hid_t new_arr_type; /* datatype for array, if necessary */ + int arrndims; /* Array rank for reading */ + size_t dims[H5S_MAX_RANK]; /* Array dimensions for reading */ + hsize_t arrdims[H5S_MAX_RANK]; /* Array dimensions for reading */ + int k; /* Local index variable */ + + /* Get the array dimensions */ + arrndims=H5Tget_member_dims(type,idx,dims,NULL); + + /* Patch up array information */ + if(arrndims>0) { + for(k=0; k<arrndims; k++) + arrdims[k]=dims[k]; + new_arr_type=H5Tarray_create(arr_type,arrndims,arrdims,NULL); + H5Tclose(arr_type); + arr_type=new_arr_type; + } /* end if */ + } +#endif /* WANT_H5_V1_2_COMPAT */ /* Get the number of dimensions */ if ((ndimf = H5Tget_array_ndims(arr_type)) < 0 || ndimf > H5S_MAX_RANK ) { fprintf(stderr, "Error: rank of members of compound type should not be %d\n",ndimf); diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index 202d70b..ca3c8a6 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -1001,6 +1001,28 @@ h5tools_fixtype(hid_t f_type) for (i = 0, size = 0; i < nmembs; i++) { /* Get the member type and fix it */ f_memb = H5Tget_member_type(f_type, i); +#ifdef WANT_H5_V1_2_COMPAT + /* v1.2 returns the base type of an array field, work around this */ + { + hid_t new_f_memb; /* datatype for array, if necessary */ + int arrndims; /* Array rank for reading */ + size_t dims[H5S_MAX_RANK]; /* Array dimensions for reading */ + hsize_t arrdims[H5S_MAX_RANK]; /* Array dimensions for reading */ + int j; /* Local index variable */ + + /* Get the array dimensions */ + arrndims=H5Tget_member_dims(f_type,i,dims,NULL); + + /* Patch up array information */ + if(arrndims>0) { + for(j=0; j<arrndims; j++) + arrdims[j]=dims[j]; + new_f_memb=H5Tarray_create(f_memb,arrndims,arrdims,NULL); + H5Tclose(f_memb); + f_memb=new_f_memb; + } /* end if */ + } +#endif /* WANT_H5_V1_2_COMPAT */ memb[i] = h5tools_fixtype(f_memb); H5Tclose(f_memb); diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c index e594ebd..0836537 100644 --- a/tools/lib/h5tools_str.c +++ b/tools/lib/h5tools_str.c @@ -682,6 +682,28 @@ h5tools_str_sprint(h5tools_str_t *str, const h5dump_t *info, hid_t container, /* The value */ offset = H5Tget_member_offset(type, j); memb = H5Tget_member_type(type, j); +#ifdef WANT_H5_V1_2_COMPAT + /* v1.2 returns the base type of an array field, work around this */ + { + hid_t new_memb; /* datatype for array, if necessary */ + int arrndims; /* Array rank for reading */ + size_t dims[H5S_MAX_RANK]; /* Array dimensions for reading */ + hsize_t arrdims[H5S_MAX_RANK]; /* Array dimensions for reading */ + int k; /* Local index variable */ + + /* Get the array dimensions */ + arrndims=H5Tget_member_dims(type,j,dims,NULL); + + /* Patch up array information */ + if(arrndims>0) { + for(k=0; k<arrndims; k++) + arrdims[k]=dims[k]; + new_memb=H5Tarray_create(memb,arrndims,arrdims,NULL); + H5Tclose(memb); + memb=new_memb; + } /* end if */ + } +#endif /* WANT_H5_V1_2_COMPAT */ ctx->indent_level++; h5tools_str_sprint(str, info, container, memb, cp_vp + offset , ctx); |