summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorMuQun Yang <ymuqun@hdfgroup.org>2000-10-12 23:33:22 (GMT)
committerMuQun Yang <ymuqun@hdfgroup.org>2000-10-12 23:33:22 (GMT)
commit0c70d84368b815d09b706274277e19d40a6c7ded (patch)
tree7498f04d31ae7379a5f3c7ed72135d0a31479096 /tools
parent95c1f3d82947acc2356c4351363fe33e002d4034 (diff)
downloadhdf5-0c70d84368b815d09b706274277e19d40a6c7ded.zip
hdf5-0c70d84368b815d09b706274277e19d40a6c7ded.tar.gz
hdf5-0c70d84368b815d09b706274277e19d40a6c7ded.tar.bz2
[svn-r2678]
Purpose: fixing output format of character array converted from hdf4 vdata. Description: Now one dimensional chactacter array can be outputed as one H5 string instead of string of array before. Solution: modify gen_h5comtype() so that when we detect the datatype is hdf5 string, we will merge hdf4 fieldorder into H5T string size and output the whole character array into hdf5 string(with string size = size of the array length). Platforms tested: eirene(LINUX), arabica(sun 5.6)
Diffstat (limited to 'tools')
-rw-r--r--tools/h4toh5vdata.c38
1 files changed, 28 insertions, 10 deletions
diff --git a/tools/h4toh5vdata.c b/tools/h4toh5vdata.c
index ff23ce9..f15922a 100644
--- a/tools/h4toh5vdata.c
+++ b/tools/h4toh5vdata.c
@@ -655,23 +655,27 @@ int gen_h5comptype(int32 vdata_id,int32 nfields,
size_t fieldsizef;
size_t fielddim[1];
hid_t h5str_type;
+ int check_ifstr;/* flag to check if the h5 type is string.*/
int i;
+
+ check_ifstr = 0;
fil_offset = 0;
mem_offset = 0;
fieldsizef = 0;
-
for (i =0;i< nfields;i++) {
fieldname = NULL;
fieldorder = VFfieldorder(vdata_id,i);
- /* printf(" %d fieldorder%d\n",i,fieldorder);*/
+ /* printf(" %d fieldorder%d\n",i,fieldorder);*/
+
if(fieldorder == FAIL){
printf("error in obtaining fieldorder.\n");
return FAIL;
}
+
/* temp_fieldname = VFfieldname(vdata_id,i);
if(temp_fieldname== NULL) {
printf("fail to obtain Vdata field name. \n");
@@ -696,19 +700,25 @@ int gen_h5comptype(int32 vdata_id,int32 nfields,
return FAIL;
}
+ /* when vdata is a character array, we will write the whole
+ array as one hdf5 type string. */
+
if(sh5type[i] == H5T_STRING) {
- /* printf("sh4size in the string %d\n",sh4size[i]);
- printf("fieldsize in the string %d\n",fieldsize);*/
- if ((h5str_type = mkstr(sh4size[i],H5T_STR_NULLTERM))<0) {
+ /* printf("sh4size in the string %d\n",sh4size[i]);
+ printf("fieldsize in the string %d\n",fieldsize);*/
+ /* if ((h5str_type = mkstr(sh4size[i],H5T_STR_NULLTERM))<0) {*/
+ if ((h5str_type = mkstr(sh4size[i]*fieldorder,H5T_STR_NULLTERM))<0) {
printf("error in making string of hdf5 string. \n");
return FAIL;
}
sh5type[i] = h5str_type;
+ check_ifstr = 1;
}
if (sh5memtype[i] == H5T_STRING) {
- if((h5str_type = mkstr(sh4memsize[i],H5T_STR_NULLTERM))<0){
+ /*if((h5str_type = mkstr(sh4memsize[i],H5T_STR_NULLTERM))<0){ */
+ if((h5str_type = mkstr(sh4memsize[i]*fieldorder,H5T_STR_NULLTERM))<0){
printf("error in making string for VDATA in memory. \n");
return FAIL;
}
@@ -720,9 +730,9 @@ int gen_h5comptype(int32 vdata_id,int32 nfields,
/* if field type is an array, use H5Tinsert_array.*/
- if (fielddim[0] == 1) {
+ if (fielddim[0] == 1 || check_ifstr == 1) {
- /* printf("i%d,sh5type[i] %d\n",i,sh5type[i]);
+ /* printf("i%d,sh5type[i] %d\n",i,sh5type[i]);
printf("i%d,fieldname%s\n",i,fieldname);
printf("i%d,fil_offset%d\n",i,fil_offset);*/
if(H5Tinsert(h5_ctype,fieldname,fil_offset,sh5type[i])<0) {
@@ -765,8 +775,16 @@ int gen_h5comptype(int32 vdata_id,int32 nfields,
fil_offset = fil_offset + fieldsizef;
mem_offset = mem_offset + sh4memsize[i];*/
- fil_offset = fil_offset + sh4size[i]*fieldorder;
- mem_offset = mem_offset + sh4memsize[i]*fieldorder;
+ if( check_ifstr == 1) {
+ fil_offset = fil_offset + sh4size[i];
+ mem_offset = mem_offset + sh4memsize[i];
+ check_ifstr = 0;
+ }
+ else {
+
+ fil_offset = fil_offset + sh4size[i]*fieldorder;
+ mem_offset = mem_offset + sh4memsize[i]*fieldorder;
+ }
/* free(fieldname);*/
}