diff --git a/tools/h4toh5/h4toh5sds.c b/tools/h4toh5/h4toh5sds.c index 89e5ddfd32..b488f78b20 100644 --- a/tools/h4toh5/h4toh5sds.c +++ b/tools/h4toh5/h4toh5sds.c @@ -72,6 +72,13 @@ int Sds_h4_to_h5(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimgroup){ hsize_t* chunk_dims; int32 c_flags; + /* for checking compression */ + + sp_info_block_t info_block; + int16 special_code; + int32 access_id; + uint16 sd_ref; + int gzip_level; /* define varibles for hdf5. */ hid_t h5dset; @@ -79,39 +86,47 @@ int Sds_h4_to_h5(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimgroup){ hid_t h5ty_id; hid_t h5_memtype; hid_t create_plist; + hid_t write_plist; hsize_t h5dims[MAX_VAR_DIMS]; hsize_t max_h5dims[MAX_VAR_DIMS]; - + hsize_t bufsize; char* h5csds_name; - herr_t ret; + + special_code = -1; /* zeroing out the memory for sdsname and sdslabel.*/ h4toh5_ZeroMemory(sdsname,MAX_NC_NAME); h4toh5_ZeroMemory(sdslabel,MAX_NC_NAME); + /* check whether the sds is empty. */ - if(SDcheckempty(sds_id,&sds_empty)== FAIL) { - printf("error in running SDcheckempty routine. \n"); - return FAIL; - } - - if(sds_empty != 0) return SUCCEED; - - - /*check whether the sds is created with unlimited dimension. */ - - if(SDgetchunkinfo(sds_id,&c_def_out, &c_flags)== FAIL) { - printf("error in getting chunking information. \n"); + printf("error in running SDcheckempty routine. \n"); return FAIL; } + /*check whether the sds is created with unlimited dimension. */ + + /*obtain name,rank,dimsizes,datatype and num of attributes of sds */ - if (SDgetinfo(sds_id,sdsname,&sds_rank,sds_dimsizes,&sds_dtype, - &num_sdsattrs)==FAIL) { - printf("unable to get information of sds h5dset.\n"); + if (SDgetinfo(sds_id,sdsname,&sds_rank,sds_dimsizes,&sds_dtype, + &num_sdsattrs)==FAIL) { + printf("unable to get information of sds h5dset.\n"); + return FAIL; + } + if(sds_empty !=0) { + if(convert_sdsfillvalue(file_id,sds_id,h5_group,h5_dimgroup)==FAIL) { + printf("cannot convert fill value successfully.\n"); return FAIL; } + return SUCCEED; + } + + if(SDgetchunkinfo(sds_id,&c_def_out, &c_flags)== FAIL) { + printf("error in getting chunking information. \n"); + return FAIL; + } + /* obtain start,edge, stride and number of sds data. */ @@ -138,31 +153,31 @@ int Sds_h4_to_h5(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimgroup){ count_sdsdata = 1; for (i=0;i0 ) + access_id = Hstartread(file_id,DFTAG_SD,sd_ref); - if(c_flags == HDF_NONE && SDisrecord(sds_id)) - { - for(i=0;i0){ + + if(HDget_special_info(access_id,&info_block)==FAIL){ + printf("fail to get special info.\n"); + free(sds_start); + free(sds_edge); + free(sds_stride); + free(sds_data); + free(chunk_dims); + H5Sclose(h5d_sid); + H5Pclose(create_plist); + return FAIL; + } + + /* free(info_block.cdims);*/ + if(info_block.key == SPECIAL_COMP) { + + if(c_flags == HDF_NONE){ + /* 1. if the first dimension is unlimited dimension, + we have to provide a chunking size. + 2. the current HDF5 will not handle compression case itself, + in order that the converted HDF5 is compressed, we have to + provide a chunking size. currently it is set to h5dim[i].*/ + + for(i=0;i