summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorMuQun Yang <ymuqun@hdfgroup.org>2000-10-18 03:48:10 (GMT)
committerMuQun Yang <ymuqun@hdfgroup.org>2000-10-18 03:48:10 (GMT)
commit3cea3093c854b225088c4cabe140b333d08e5462 (patch)
tree2f076db0619461182b322a719a529ab302b47c07 /tools
parentf71aa7cb6c60a94190fd8039c31a24fa994643e3 (diff)
downloadhdf5-3cea3093c854b225088c4cabe140b333d08e5462.zip
hdf5-3cea3093c854b225088c4cabe140b333d08e5462.tar.gz
hdf5-3cea3093c854b225088c4cabe140b333d08e5462.tar.bz2
[svn-r2691]
Purpose: 1. fix multiple defination warnings at sgi platform 2. adding chunking information from hdf4 to hdf5 property list. Description: 1. Orginally global varibles were defined at one header file and this header file were included by other .c file and .h file so multiple warnings are generated. 2. Chunking information was not included in the previous version. Solution: 1. use "extern" to define global variables at h4toh5util.h file and define global variables at h4toh5main.c 2. retrieve the chunking info from sdgetchunkinfo and GRgetchunkinfo and store these information into hdf5 property list. Platforms tested: eirene,arabica,paz,gondolin
Diffstat (limited to 'tools')
-rw-r--r--tools/h4toh5image.c86
-rw-r--r--tools/h4toh5main.c17
-rw-r--r--tools/h4toh5sds.c68
-rw-r--r--tools/h4toh5util.c2
-rw-r--r--tools/h4toh5util.h28
-rw-r--r--tools/h4toh5vgroup.c1
6 files changed, 178 insertions, 24 deletions
diff --git a/tools/h4toh5image.c b/tools/h4toh5image.c
index ad04dae..373a854 100644
--- a/tools/h4toh5image.c
+++ b/tools/h4toh5image.c
@@ -1,5 +1,6 @@
#include "h4toh5main.h"
+
/*-------------------------------------------------------------------------
* Function: Image_h4_to_h5
*
@@ -34,6 +35,9 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup) {
char image_class[MAX_GR_NAME];
char* h5cimage_name;
void* image_data;
+ HDF_CHUNK_DEF c_def_out;
+ int32 chunk_dims[2];
+ int32 c_flags;
/* define varibles for hdf5. */
@@ -51,10 +55,15 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup) {
size_t fielddim[1];
hsize_t h5dims[2];
herr_t ret;
-
+ hid_t create_plist;
/* Obtain information of the image.*/
+ if(GRgetchunkinfo(ri_id,&c_def_out,&c_flags)==FAIL){
+ printf("error in getting chunking information. \n");
+ return FAIL;
+ }
+
istat = GRgetiminfo(ri_id, image_name, &ncomp, &image_dtype,
NULL, dimsizes, &ngrattrs);
@@ -144,6 +153,24 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup) {
return FAIL;
}
+ /* create property list. */
+
+ create_plist = H5Pcreate(H5P_DATASET_CREATE);
+
+ if(c_flags == HDF_CHUNK || c_flags == (HDF_CHUNK | HDF_COMP)
+ || c_flags == (HDF_CHUNK | HDF_NBIT) ){
+
+ chunk_dims[0] = c_def_out.chunk_lengths[0];
+ chunk_dims[1] = c_def_out.chunk_lengths[1];
+
+ if(H5Pset_chunk(create_plist, 2, (hsize_t *)chunk_dims)<0) {
+ printf("failed to set up chunking information for ");
+ printf("property list.\n");
+ free(image_data);
+ H5Pclose(create_plist);
+ return FAIL;
+ }
+ }
if (ncomp == 1) {
h5d_sid = H5Screate_simple(2,h5dims,NULL);
@@ -155,12 +182,13 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup) {
return FAIL;
}
- h5dset = H5Dcreate(h5_group,h5cimage_name,h5ty_id,h5d_sid,H5P_DEFAULT);
+ h5dset = H5Dcreate(h5_group,h5cimage_name,h5ty_id,h5d_sid,create_plist);
if(h5dset < 0) {
printf("error in creating hdf5 dataset converted from images. \n");
free(image_data);
free(h5cimage_name);
+ H5Pclose(create_plist);
return FAIL;
}
@@ -169,6 +197,7 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup) {
printf("error writing data for hdf5 dataset converted from images.\n");
free(image_data);
free(h5cimage_name);
+ H5Pclose(create_plist);
return FAIL;
}
@@ -181,6 +210,7 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup) {
printf("error in generating hdf5 compound data type. \n");
free(image_data);
free(h5cimage_name);
+ H5Pclose(create_plist);
return FAIL;
}
@@ -189,6 +219,7 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup) {
printf("error in generating hdf5 memory compound data type. \n");
free(image_data);
free(h5cimage_name);
+ H5Pclose(create_plist);
return FAIL;
}
@@ -202,6 +233,7 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup) {
printf("error in inserting array of compound datatype. \n");
free(image_data);
free(h5cimage_name);
+ H5Pclose(create_plist);
return FAIL;
}
@@ -211,6 +243,7 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup) {
printf("error in inserting array of compound datatype at memory. \n");
free(image_data);
free(h5cimage_name);
+ H5Pclose(create_plist);
return FAIL;
}
@@ -219,15 +252,17 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup) {
printf("error in creating space. \n");
free(image_data);
free(h5cimage_name);
+ H5Pclose(create_plist);
return FAIL;
}
h5dset = H5Dcreate(h5_group,h5cimage_name,h5_ctype,h5d_sid,
- H5P_DEFAULT);
+ create_plist);
if(h5dset < 0) {
printf("error in creating dataset. \n");
free(image_data);
free(h5cimage_name);
+ H5Pclose(create_plist);
return FAIL;
}
@@ -236,9 +271,9 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup) {
printf("error writing data\n");
free(image_data);
free(h5cimage_name);
+ H5Pclose(create_plist);
return FAIL;
}
-
ret = H5Tclose(h5_ctype);
if(ret < 0) {
printf("error in closing h5_ctype. \n");
@@ -261,6 +296,9 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup) {
printf("failed to convert image annotation into hdf5 attribute.\n");
free(image_data);
free(h5cimage_name);
+ H5Pclose(create_plist);
+ H5Sclose(h5d_sid);
+ H5Dclose(h5dset);
return FAIL;
}
@@ -268,6 +306,9 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup) {
printf("failed to convert image annotation into hdf5 attribute.\n");
free(h5cimage_name);
free(image_data);
+ H5Pclose(create_plist);
+ H5Sclose(h5d_sid);
+ H5Dclose(h5dset);
return FAIL;
}
@@ -275,6 +316,9 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup) {
printf("failed to convert image annotation into hdf5 attribute.\n");
free(h5cimage_name);
free(image_data);
+ H5Pclose(create_plist);
+ H5Sclose(h5d_sid);
+ H5Dclose(h5dset);
return FAIL;
}
@@ -285,6 +329,10 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup) {
check_gloattr = 0;
if(gr_tranattrs(ri_id,h5dset,ngrattrs,check_gloattr)==FAIL){
printf(" cannot obtain attributes. \n");
+ free(image_data);
+ H5Pclose(create_plist);
+ H5Sclose(h5d_sid);
+ H5Dclose(h5dset);
return FAIL;
}
@@ -304,19 +352,31 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup) {
/* transfer hdf4 predefined attributes into hdf5 dataset.*/
if(h4_transpredattrs(h5dset,HDF4_OBJECT_TYPE,grlabel)==FAIL){
printf("error in getting hdf4 image type attribute \n");
+ H5Pclose(create_plist);
+ H5Sclose(h5d_sid);
+ H5Dclose(h5dset);
free(h5cimage_name);
+ free(image_data);
return FAIL;
}
if(h4_transpredattrs(h5dset,HDF4_OBJECT_NAME,image_name)==FAIL){
printf("error in getting hdf4 image name attribute. \n");
+ H5Pclose(create_plist);
+ H5Sclose(h5d_sid);
+ H5Dclose(h5dset);
free(h5cimage_name);
+ free(image_data);
return FAIL;
}
if(h4_transpredattrs(h5dset,HDF4_IMAGE_CLASS,image_class)==FAIL){
printf("error in getting hdf4 image class attribute. \n");
+ H5Pclose(create_plist);
+ H5Sclose(h5d_sid);
+ H5Dclose(h5dset);
free(h5cimage_name);
+ free(image_data);
return FAIL;
}
@@ -324,13 +384,21 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup) {
if(gr_ref == 0) {
printf("error in obtaining reference number of GR.\n");
+ H5Pclose(create_plist);
+ H5Sclose(h5d_sid);
+ H5Dclose(h5dset);
free(h5cimage_name);
+ free(image_data);
return FAIL;
}
if(h4_transnumattr(h5dset,HDF4_REF_NUM,gr_ref)==FAIL) {
printf("error in getting hdf4 image number attribute.\n");
+ H5Pclose(create_plist);
+ H5Sclose(h5d_sid);
+ H5Dclose(h5dset);
free(h5cimage_name);
+ free(image_data);
return FAIL;
}
@@ -338,16 +406,20 @@ int Image_h4_to_h5(int32 file_id,int32 ri_id,hid_t h5_group,hid_t h5_palgroup) {
if(gr_palette(file_id,ri_id,h5dset,h5_palgroup)== FAIL) {
printf("error in translating palette into h5 dataset.\n");
+ H5Pclose(create_plist);
+ H5Sclose(h5d_sid);
+ H5Dclose(h5dset);
free(h5cimage_name);
+ free(image_data);
return FAIL;
}
-
+ ret = H5Pclose(create_plist);
ret = H5Sclose(h5d_sid);
ret = H5Dclose(h5dset);
istat = GRendaccess(ri_id);
- if(image_data != NULL) free(image_data);
- if(h5cimage_name != NULL) free(h5cimage_name);
+ free(image_data);
+ free(h5cimage_name);
return SUCCEED;
}
diff --git a/tools/h4toh5main.c b/tools/h4toh5main.c
index 0947bb8..de51554 100644
--- a/tools/h4toh5main.c
+++ b/tools/h4toh5main.c
@@ -2,6 +2,21 @@
#include "h4toh5main.h"
+int32 estnum_vg;
+int32 estnum_vd;
+int32 num_sds;
+int32 num_images;
+int num_objects;
+int32 num_glsdsattrs;
+int32 num_glgrattrs;
+struct table* sds_hashtab;
+struct table* gr_hashtab;
+struct table* vg_hashtab;
+struct table* vd_hashtab;
+struct table* pal_hashtab;
+struct name_table* name_hashtab;
+struct name_table* dim_hashtab;
+
/*-------------------------------------------------------------------------
* Function: main
*
@@ -13,6 +28,8 @@
*-------------------------------------------------------------------------
*/
+
+
int main(int argc, char ** argv) {
char *h5_filename=NULL;
diff --git a/tools/h4toh5sds.c b/tools/h4toh5sds.c
index a2592bb..265ea55 100644
--- a/tools/h4toh5sds.c
+++ b/tools/h4toh5sds.c
@@ -1,4 +1,6 @@
#include "h4toh5main.h"
+
+
/*-------------------------------------------------------------------------
* Function: Sds_h4_to_h5
*
@@ -36,6 +38,9 @@ int Sds_h4_to_h5(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimgroup){
char sdslabel[MAX_NC_NAME];
size_t h4size;
size_t h4memsize;
+ HDF_CHUNK_DEF c_def_out;
+ int32* chunk_dims;
+ int32 c_flags;
/* define varibles for hdf5. */
@@ -43,8 +48,9 @@ int Sds_h4_to_h5(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimgroup){
hid_t h5d_sid;
hid_t h5ty_id;
hid_t h5_memtype;
-
+ hid_t create_plist;
hsize_t h5dims[MAX_VAR_DIMS];
+
char* h5csds_name;
herr_t ret;
@@ -61,6 +67,11 @@ int Sds_h4_to_h5(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimgroup){
#endif
/*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");
+ return FAIL;
+ }
if(SDisrecord(sds_id)) {
if (SDgetinfo(sds_id,sdsname,&sds_rank,sds_dimsizes,&sds_dtype,
@@ -215,8 +226,32 @@ int Sds_h4_to_h5(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimgroup){
free(sds_data);
return FAIL;
}
-
- h5dset = H5Dcreate(h5_group,h5csds_name,h5ty_id,h5d_sid,H5P_DEFAULT);
+
+ /* create property list. */
+
+ create_plist = H5Pcreate(H5P_DATASET_CREATE);
+ chunk_dims = malloc(4*sds_rank);
+
+ if(c_flags == HDF_CHUNK || c_flags == (HDF_CHUNK | HDF_COMP)
+ || c_flags == (HDF_CHUNK | HDF_NBIT) ){
+
+ for(i=0;i<sds_rank;i++)
+ chunk_dims[i] = c_def_out.chunk_lengths[i];
+
+ if(H5Pset_chunk(create_plist, sds_rank, (hsize_t *)chunk_dims)<0) {
+ printf("failed to set up chunking information for ");
+ printf("property list.\n");
+ free(sds_start);
+ free(sds_edge);
+ free(sds_stride);
+ free(sds_data);
+ free(chunk_dims);
+ H5Sclose(h5d_sid);
+ H5Pclose(create_plist);
+ return FAIL;
+ }
+ }
+ h5dset = H5Dcreate(h5_group,h5csds_name,h5ty_id,h5d_sid,create_plist);
if (h5dset < 0) {
printf("failed to create hdf5 dataset converted from SDS. \n");
@@ -225,6 +260,7 @@ int Sds_h4_to_h5(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimgroup){
free(sds_stride);
free(sds_data);
H5Sclose(h5d_sid);
+ H5Pclose(create_plist);
return FAIL;
}
@@ -234,6 +270,7 @@ int Sds_h4_to_h5(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimgroup){
printf(" converted from SDS.\n");
H5Sclose(h5d_sid);
H5Dclose(h5dset);
+ H5Pclose(create_plist);
free(sds_start);
free(sds_edge);
free(sds_stride);
@@ -256,6 +293,9 @@ int Sds_h4_to_h5(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimgroup){
free(sds_edge);
free(sds_stride);
free(sds_data);
+ H5Sclose(h5d_sid);
+ H5Dclose(h5dset);
+ H5Pclose(create_plist);
return FAIL;
}
@@ -265,6 +305,9 @@ int Sds_h4_to_h5(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimgroup){
free(sds_edge);
free(sds_stride);
free(sds_data);
+ H5Sclose(h5d_sid);
+ H5Dclose(h5dset);
+ H5Pclose(create_plist);
return FAIL;
}
@@ -274,6 +317,9 @@ int Sds_h4_to_h5(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimgroup){
free(sds_edge);
free(sds_stride);
free(sds_data);
+ H5Sclose(h5d_sid);
+ H5Dclose(h5dset);
+ H5Pclose(create_plist);
return FAIL;
}
@@ -284,6 +330,9 @@ int Sds_h4_to_h5(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimgroup){
free(sds_edge);
free(sds_stride);
free(sds_data);
+ H5Sclose(h5d_sid);
+ H5Dclose(h5dset);
+ H5Pclose(create_plist);
return FAIL;
}
check_gloattr = 0;
@@ -292,6 +341,9 @@ int Sds_h4_to_h5(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimgroup){
free(sds_edge);
free(sds_stride);
free(sds_data);
+ H5Sclose(h5d_sid);
+ H5Dclose(h5dset);
+ H5Pclose(create_plist);
printf(" Error in obtaining sds attributes. \n");
return FAIL;
}
@@ -307,6 +359,9 @@ int Sds_h4_to_h5(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimgroup){
free(sds_edge);
free(sds_stride);
free(sds_data);
+ H5Sclose(h5d_sid);
+ H5Dclose(h5dset);
+ H5Pclose(create_plist);
printf("unable to transfer sds label to HDF4 OBJECT TYPE.\n");
return FAIL;
}
@@ -317,6 +372,9 @@ int Sds_h4_to_h5(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimgroup){
free(sds_edge);
free(sds_stride);
free(sds_data);
+ H5Sclose(h5d_sid);
+ H5Dclose(h5dset);
+ H5Pclose(create_plist);
printf("unable to transfer sds name to HDF5 dataset attribute.\n");
return FAIL;
}
@@ -327,11 +385,15 @@ int Sds_h4_to_h5(int32 file_id,int32 sds_id,hid_t h5_group,hid_t h5_dimgroup){
free(sds_edge);
free(sds_stride);
free(sds_data);
+ H5Sclose(h5d_sid);
+ H5Dclose(h5dset);
+ H5Pclose(create_plist);
printf("unable to transfer sds ref. to HDF5 dataset attribute.\n");
return FAIL;
}
istat = SDendaccess(sds_id);
+ ret = H5Pclose(create_plist);
ret = H5Sclose(h5d_sid);
ret = H5Dclose(h5dset);
free(h5csds_name);
diff --git a/tools/h4toh5util.c b/tools/h4toh5util.c
index a36ca93..4c76dd5 100644
--- a/tools/h4toh5util.c
+++ b/tools/h4toh5util.c
@@ -1,4 +1,6 @@
#include "h4toh5util.h"
+
+
/* Function h4toh5_ZeroMemory
* Purpose: Zero out memory
* return: None
diff --git a/tools/h4toh5util.h b/tools/h4toh5util.h
index 0cba454..503e02c 100644
--- a/tools/h4toh5util.h
+++ b/tools/h4toh5util.h
@@ -98,13 +98,13 @@ converter.*/
/*considering the string size of HDF4_DIMGROUP. we add this into 276.*/
#define MAX_DIM_NAME 276
-int32 estnum_vg;
-int32 estnum_vd;
-int32 num_sds;
-int32 num_images;
-int num_objects;
-int32 num_glsdsattrs;
-int32 num_glgrattrs;
+extern int32 estnum_vg;
+extern int32 estnum_vd;
+extern int32 num_sds;
+extern int32 num_images;
+extern int num_objects;
+extern int32 num_glsdsattrs;
+extern int32 num_glgrattrs;
/**********************************************/
/*************** section II *******************/
@@ -129,13 +129,13 @@ struct name_table {
struct name_table *next;
};
-struct table* sds_hashtab;
-struct table* gr_hashtab;
-struct table* vg_hashtab;
-struct table* vd_hashtab;
-struct table* pal_hashtab;
-struct name_table* name_hashtab;
-struct name_table* dim_hashtab;
+extern struct table* sds_hashtab;
+extern struct table* gr_hashtab;
+extern struct table* vg_hashtab;
+extern struct table* vd_hashtab;
+extern struct table* pal_hashtab;
+extern struct name_table* name_hashtab;
+extern struct name_table* dim_hashtab;
/* routine for zeroing out the memory. */
void h4toh5_ZeroMemory(void*s,size_t n);
diff --git a/tools/h4toh5vgroup.c b/tools/h4toh5vgroup.c
index 14e1c0f..4bea19e 100644
--- a/tools/h4toh5vgroup.c
+++ b/tools/h4toh5vgroup.c
@@ -24,6 +24,7 @@
*-------------------------------------------------------------------------
*/
+
int Vgroup_h4_to_h5(int32 file_id,int32 vgroup_id,int32 sd_id,hid_t h5_group,hid_t h5_dimgroup,hid_t h5_palgroup)
{