summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-08-10 17:08:27 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-08-10 17:08:27 (GMT)
commit9d27b9765ad7d5ec04762895752bc77b8ac1ec3d (patch)
treea0e442dbb7b27f963a9ba8240db1605ca6de6615 /tools
parent61c693615a1f4f90f7654f639170eed2f3c85262 (diff)
downloadhdf5-9d27b9765ad7d5ec04762895752bc77b8ac1ec3d.zip
hdf5-9d27b9765ad7d5ec04762895752bc77b8ac1ec3d.tar.gz
hdf5-9d27b9765ad7d5ec04762895752bc77b8ac1ec3d.tar.bz2
[svn-r17313] Description:
Bring back various minor code cleanups from the file free space branch Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode Mac OS X/32 10.5.8 (amazon) in debug mode Mac OS X/32 10.5.8 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode
Diffstat (limited to 'tools')
-rw-r--r--tools/h5dump/h5dump.c26
-rw-r--r--tools/h5repack/h5repack_copy.c8
-rw-r--r--tools/h5repack/h5repack_main.c5
-rw-r--r--tools/h5repack/h5repacktst.c3
-rw-r--r--tools/h5stat/h5stat.c91
-rw-r--r--tools/h5stat/testfiles/h5stat_filters-F.ddl1
-rw-r--r--tools/h5stat/testfiles/h5stat_filters.ddl1
-rw-r--r--tools/h5stat/testfiles/h5stat_help1.ddl7
-rw-r--r--tools/h5stat/testfiles/h5stat_help2.ddl7
-rw-r--r--tools/h5stat/testfiles/h5stat_newgrat.ddl1
-rw-r--r--tools/h5stat/testfiles/h5stat_tsohm.ddl1
11 files changed, 64 insertions, 87 deletions
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c
index a8b6832..beacdbb 100644
--- a/tools/h5dump/h5dump.c
+++ b/tools/h5dump/h5dump.c
@@ -731,10 +731,11 @@ table_list_add(hid_t oid, unsigned long file_no)
{
size_t idx; /* Index of table to use */
find_objs_t info;
- void *tmp_ptr;
/* Allocate space if necessary */
if(table_list.nused == table_list.nalloc) {
+ void *tmp_ptr;
+
table_list.nalloc = MAX(1, table_list.nalloc * 2);
if(NULL == (tmp_ptr = HDrealloc(table_list.tables, table_list.nalloc * sizeof(table_list.tables[0]))))
return -1;
@@ -1441,7 +1442,7 @@ dump_selected_attr(hid_t loc_id, const char *name)
int j;
j = (int)HDstrlen(name) - 1;
- obj_name = HDmalloc((size_t)j + 2);
+ obj_name = (char *)HDmalloc((size_t)j + 2);
/* find the last / */
while(name[j] != '/' && j >= 0)
@@ -1533,7 +1534,7 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED
herr_t ret = SUCCEED;
/* Build the object's path name */
- obj_path = HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2);
+ obj_path = (char *)HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2);
HDassert(obj_path);
HDstrcpy(obj_path, prefix);
HDstrcat(obj_path, "/");
@@ -1692,7 +1693,7 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED
switch(linfo->type) {
case H5L_TYPE_SOFT:
indentation(indent);
- targbuf = HDmalloc(linfo->u.val_size);
+ targbuf = (char *)HDmalloc(linfo->u.val_size);
HDassert(targbuf);
if(!doxml) {
@@ -1722,7 +1723,7 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED
char *t_link_path;
int res;
- t_link_path = HDmalloc(HDstrlen(prefix) + linfo->u.val_size + 1);
+ t_link_path = (char *)HDmalloc(HDstrlen(prefix) + linfo->u.val_size + 1);
if(targbuf[0] == '/')
HDstrcpy(t_link_path, targbuf);
else {
@@ -1785,7 +1786,7 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED
break;
case H5L_TYPE_EXTERNAL:
- targbuf = HDmalloc(linfo->u.val_size);
+ targbuf = (char *)HDmalloc(linfo->u.val_size);
HDassert(targbuf);
indentation(indent);
@@ -2057,7 +2058,7 @@ dump_group(hid_t gid, const char *name)
}
- tmp = HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2);
+ tmp = (char *)HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2);
HDstrcpy(tmp, prefix);
indentation(indent);
begin_obj(dump_header_format->groupbegin, name, dump_header_format->groupblockbegin);
@@ -2714,9 +2715,7 @@ dump_dcpl(hid_t dcpl_id,hid_t type_id, hid_t obj_id)
hsize_t dims[H5S_MAX_RANK];
int ndims = H5Sget_simple_extent_dims( sid, dims, NULL);
hsize_t nelmts = 1;
- hsize_t size;
double ratio = 0;
- hssize_t a, b;
int ok = 0;
/* only print the compression ratio for these filters */
@@ -2739,19 +2738,18 @@ dump_dcpl(hid_t dcpl_id,hid_t type_id, hid_t obj_id)
if (ndims && ok )
{
+ hsize_t uncomp_size;
for (i = 0; i < ndims; i++)
{
nelmts *= dims[i];
}
- size = nelmts * datum_size;
-
- a = size; b = storage_size;
+ uncomp_size = nelmts * datum_size;
/* compression ratio = uncompressed size / compressed size */
- if (b!=0)
- ratio = (double) a / (double) b;
+ if (storage_size != 0)
+ ratio = (double) uncomp_size / (double) storage_size;
HDfprintf(stdout, "SIZE %Hu (%.3f:1 COMPRESSION)\n ", storage_size, ratio);
diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c
index 73f57e3..0fb8fc8 100644
--- a/tools/h5repack/h5repack_copy.c
+++ b/tools/h5repack/h5repack_copy.c
@@ -930,16 +930,12 @@ int do_copy_objects(hid_t fidin,
/* only print the compression ration if there was a filter request */
if (apply_s && apply_f && req_filter)
{
- hssize_t a, b;
-
/* get the storage size of the output dataset */
dsize_out=H5Dget_storage_size(dset_out);
/* compression ratio = uncompressed size / compressed size */
-
- a = dsize_in; b = dsize_out;
- if (b!=0)
- ratio = (double) a / (double) b;
+ if (dsize_out!=0)
+ ratio = (double) dsize_in / (double) dsize_out;
print_dataset_info(dcpl_out,travt->objs[i].name,ratio,1);
}
diff --git a/tools/h5repack/h5repack_main.c b/tools/h5repack/h5repack_main.c
index f55bd2e..d9ec7ad 100644
--- a/tools/h5repack/h5repack_main.c
+++ b/tools/h5repack/h5repack_main.c
@@ -411,13 +411,12 @@ void parse_command_line(int argc, const char **argv, pack_opt_t* options)
case 'b':
- options->ublock_size = atol( opt_arg );
+ options->ublock_size = (hsize_t)atol( opt_arg );
break;
case 't':
- options->threshold = atol( opt_arg );
-
+ options->threshold = (hsize_t)atol( opt_arg );
break;
case 'a':
diff --git a/tools/h5repack/h5repacktst.c b/tools/h5repack/h5repacktst.c
index b36afde..d28750c 100644
--- a/tools/h5repack/h5repacktst.c
+++ b/tools/h5repack/h5repacktst.c
@@ -1507,7 +1507,6 @@ int main (void)
SKIPPED();
#endif
-
/*-------------------------------------------------------------------------
* test file with userblock
*-------------------------------------------------------------------------
@@ -1529,8 +1528,6 @@ int main (void)
PASSED();
-
-
/*-------------------------------------------------------------------------
* clean temporary test files
*-------------------------------------------------------------------------
diff --git a/tools/h5stat/h5stat.c b/tools/h5stat/h5stat.c
index 315c558..75481ff 100644
--- a/tools/h5stat/h5stat.c
+++ b/tools/h5stat/h5stat.c
@@ -51,7 +51,7 @@ typedef struct iter_t {
unsigned long uniq_groups; /* Number of unique groups */
unsigned long uniq_dsets; /* Number of unique datasets */
- unsigned long uniq_types; /* Number of unique named datatypes */
+ unsigned long uniq_dtypes; /* Number of unique named datatypes */
unsigned long uniq_links; /* Number of unique links */
unsigned long uniq_others; /* Number of other unique objects */
@@ -64,11 +64,11 @@ typedef struct iter_t {
hsize_t max_attrs; /* Maximum attributes from a group */
unsigned long num_small_attrs[SIZE_SMALL_ATTRS]; /* Size of small attributes tracked */
- unsigned attr_nbins;
- unsigned long *attr_bins;
+ unsigned attr_nbins; /* Number of bins for attribute counts */
+ unsigned long *attr_bins; /* Pointer to array of bins for attribute counts */
- unsigned long max_dset_rank; /* Maximum rank of dataset */
- unsigned long dset_rank_count[H5S_MAX_RANK]; /* Number of datasets of each rank */
+ unsigned max_dset_rank; /* Maximum rank of dataset */
+ unsigned long dset_rank_count[H5S_MAX_RANK]; /* Number of datasets of each rank */
hsize_t max_dset_dims; /* Maximum dimension size of dataset */
unsigned long small_dset_dims[SIZE_SMALL_DSETS]; /* Size of dimensions of small datasets tracked */
unsigned long dset_layouts[H5D_NLAYOUTS]; /* Type of storage for each dataset */
@@ -79,6 +79,7 @@ typedef struct iter_t {
unsigned long *dset_dim_bins; /* Pointer to array of bins for dataset dimensions */
ohdr_info_t dset_ohdr_info; /* Object header information for datasets */
hsize_t dset_storage_size; /* Size of raw data for datasets */
+ ohdr_info_t dtype_ohdr_info; /* Object header information for datatypes */
hsize_t groups_btree_storage_size; /* btree size for group */
hsize_t groups_heap_storage_size; /* heap size for group */
hsize_t attrs_btree_storage_size; /* btree size for attributes (1.8) */
@@ -110,7 +111,7 @@ struct handler_t {
};
-static const char *s_opts ="AFfhGgDdTO:V";
+static const char *s_opts ="ADdFfhGgTO:V";
static struct long_options l_opts[] = {
{"help", no_arg, 'h'},
{"hel", no_arg, 'h'},
@@ -192,13 +193,6 @@ leave(int ret)
static void usage(const char *prog)
{
fflush(stdout);
- fprintf(stdout, "\n");
- fprintf(stdout, "This tool is under development. For detailed information\n");
- fprintf(stdout, "please see the specification document at\n");
- fprintf(stdout, "http://hdf.ncsa.uiuc.edu/RFC/h5stat/h5stat-spec.pdf\n");
- fprintf(stdout, "\n");
- fprintf(stdout, "Please send your comments and questions to help@hdfgroup.org\n");
- fprintf(stdout, "\n");
fprintf(stdout, "Usage: %s [OPTIONS] file\n", prog);
fprintf(stdout, "\n");
fprintf(stdout, " OPTIONS\n");
@@ -277,7 +271,7 @@ attribute_stats(iter_t *iter, const H5O_info_t *oi)
/* Add attribute count to proper bin */
bin = ceil_log10((unsigned long)oi->num_attrs);
if((bin + 1) > iter->attr_nbins) {
- iter->attr_bins = realloc(iter->attr_bins, (bin + 1) * sizeof(unsigned long));
+ iter->attr_bins = (unsigned long *)realloc(iter->attr_bins, (bin + 1) * sizeof(unsigned long));
assert(iter->attr_bins);
/* Initialize counts for intermediate bins */
@@ -349,7 +343,7 @@ group_stats(iter_t *iter, const char *name, const H5O_info_t *oi)
bin = ceil_log10((unsigned long)ginfo.nlinks);
if((bin + 1) > iter->group_nbins) {
/* Allocate more storage for info about dataset's datatype */
- iter->group_bins = realloc(iter->group_bins, (bin + 1) * sizeof(unsigned long));
+ iter->group_bins = (unsigned long *)realloc(iter->group_bins, (bin + 1) * sizeof(unsigned long));
assert(iter->group_bins);
/* Initialize counts for intermediate bins */
@@ -451,7 +445,7 @@ dataset_stats(iter_t *iter, const char *name, const H5O_info_t *oi)
/* Check for larger rank of dataset */
if((unsigned)ndims > iter->max_dset_rank)
- iter->max_dset_rank = ndims;
+ iter->max_dset_rank = (unsigned)ndims;
/* Track the number of datasets with each rank */
(iter->dset_rank_count[ndims])++;
@@ -466,7 +460,7 @@ dataset_stats(iter_t *iter, const char *name, const H5O_info_t *oi)
bin = ceil_log10((unsigned long)dims[0]);
if((bin + 1) > iter->dset_dim_nbins) {
/* Allocate more storage for info about dataset's datatype */
- iter->dset_dim_bins = realloc(iter->dset_dim_bins, (bin + 1) * sizeof(unsigned long));
+ iter->dset_dim_bins = (unsigned long *)realloc(iter->dset_dim_bins, (bin + 1) * sizeof(unsigned long));
assert(iter->dset_dim_bins);
/* Initialize counts for intermediate bins */
@@ -503,7 +497,7 @@ dataset_stats(iter_t *iter, const char *name, const H5O_info_t *oi)
iter->dset_ntypes++;
/* Allocate more storage for info about dataset's datatype */
- iter->dset_type_info = realloc(iter->dset_type_info, iter->dset_ntypes * sizeof(dtype_info_t));
+ iter->dset_type_info = (dtype_info_t *)realloc(iter->dset_type_info, iter->dset_ntypes * sizeof(dtype_info_t));
assert(iter->dset_type_info);
/* Initialize information about datatype */
@@ -537,7 +531,7 @@ dataset_stats(iter_t *iter, const char *name, const H5O_info_t *oi)
assert (num_ext >= 0);
if(num_ext)
- iter->nexternal = iter->nexternal + num_ext;
+ iter->nexternal += (unsigned long)num_ext;
/* Track different filters */
if((nfltr = H5Pget_nfilters(dcpl)) >= 0) {
@@ -561,6 +555,31 @@ dataset_stats(iter_t *iter, const char *name, const H5O_info_t *oi)
return 0;
} /* end dataset_stats() */
+/*-------------------------------------------------------------------------
+ * Function: datatype_stats
+ *
+ * Purpose: Gather statistics about the datatype
+ *
+ * Return: Success: 0
+ * Failure: -1
+ *
+ * Programmer: Vailin Choi; July 7th, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+datatype_stats(iter_t *iter, const H5O_info_t *oi)
+{
+ /* Gather statistics about this type of object */
+ iter->uniq_dtypes++;
+
+ /* Get object header information */
+ iter->dtype_ohdr_info.total_size += oi->hdr.space.total;
+ iter->dtype_ohdr_info.free_size += oi->hdr.space.free;
+
+ return 0;
+} /* end datatype_stats() */
+
/*-------------------------------------------------------------------------
* Function: obj_stats
@@ -598,8 +617,7 @@ obj_stats(const char *path, const H5O_info_t *oi, const char *already_visited,
break;
case H5O_TYPE_NAMED_DATATYPE:
- /* Gather statistics about this type of object */
- iter->uniq_types++;
+ datatype_stats(iter, oi);
break;
default:
@@ -661,10 +679,6 @@ lnk_stats(const char UNUSED *path, const H5L_info_t *li, void *_iter)
* Programmer: Elena Pourmal
* Saturday, August 12, 2006
*
- * Modifications:
- * Vailin Choi 12 July 2007
- * Added 'A' option to display attribute info
- *
*-------------------------------------------------------------------------
*/
static struct handler_t *
@@ -674,7 +688,7 @@ parse_command_line(int argc, const char *argv[])
struct handler_t *hand;
/* Allocate space to hold the command line info */
- hand = calloc((size_t)argc, sizeof(struct handler_t));
+ hand = (struct handler_t *)calloc((size_t)argc, sizeof(struct handler_t));
/* parse command line options */
while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) {
@@ -801,7 +815,7 @@ print_file_info(const iter_t *iter)
printf("File information\n");
printf("\t# of unique groups: %lu\n", iter->uniq_groups);
printf("\t# of unique datasets: %lu\n", iter->uniq_dsets);
- printf("\t# of unique named dataypes: %lu\n", iter->uniq_types);
+ printf("\t# of unique named dataypes: %lu\n", iter->uniq_dtypes);
printf("\t# of unique links: %lu\n", iter->uniq_links);
printf("\t# of unique other: %lu\n", iter->uniq_others);
printf("\tMax. # of links to object: %lu\n", iter->max_links);
@@ -823,14 +837,6 @@ print_file_info(const iter_t *iter)
* Programmer: Elena Pourmal
* Saturday, August 12, 2006
*
- * Modifications:
- * Vailin Choi 12 July 2007
- * Print storage info for:
- * 1. btree/heap storage for groups and attributes
- * 2. btree storage for chunked dataset
- * 3. hdr/btree/list/heap storage for SOHM table
- * 4. superblock extension size
- *
*-------------------------------------------------------------------------
*/
static herr_t
@@ -841,6 +847,8 @@ print_file_metadata(const iter_t *iter)
iter->group_ohdr_info.free_size);
HDfprintf(stdout, "\tDatasets: %Hu/%Hu\n", iter->dset_ohdr_info.total_size,
iter->dset_ohdr_info.free_size);
+ HDfprintf(stdout, "\tDatatypes: %Hu/%Hu\n", iter->dtype_ohdr_info.total_size,
+ iter->dtype_ohdr_info.free_size);
printf("Storage information:\n");
HDfprintf(stdout, "\tGroups:\n");
@@ -999,7 +1007,7 @@ print_dataset_info(const iter_t *iter)
if(iter->uniq_dsets > 0) {
printf("Dataset dimension information:\n");
- printf("\tMax. rank of datasets: %lu\n", iter->max_dset_rank);
+ printf("\tMax. rank of datasets: %u\n", iter->max_dset_rank);
printf("\tDataset ranks:\n");
for(u = 0; u < H5S_MAX_RANK; u++)
if(iter->dset_rank_count[u] > 0)
@@ -1091,8 +1099,6 @@ print_dataset_info(const iter_t *iter)
* Programmer: Elena Pourmal
* Saturday, August 12, 2006
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static void
@@ -1163,15 +1169,6 @@ print_statistics(const char *name, const iter_t *iter)
print_file_statistics(iter);
}
-/*-------------------------------------------------------------------------
- *
- * Modifications:
- * bug #1253; Oct 6th 2008; Vailin Choi
- * Call print_statistics() when objects/links are successfully traversed.
- * Otherwise, return warning message.
- *
- *-------------------------------------------------------------------------
- */
int
main(int argc, const char *argv[])
diff --git a/tools/h5stat/testfiles/h5stat_filters-F.ddl b/tools/h5stat/testfiles/h5stat_filters-F.ddl
index 544d0c7..6bc6cc2 100644
--- a/tools/h5stat/testfiles/h5stat_filters-F.ddl
+++ b/tools/h5stat/testfiles/h5stat_filters-F.ddl
@@ -5,6 +5,7 @@ Filename: h5stat_filters.h5
Object header size: (total/unused)
Groups: 48/8
Datasets: 4936/1344
+ Datatypes: 80/0
Storage information:
Groups:
B-tree/List: 1200
diff --git a/tools/h5stat/testfiles/h5stat_filters.ddl b/tools/h5stat/testfiles/h5stat_filters.ddl
index 8afdf82..8243a23 100644
--- a/tools/h5stat/testfiles/h5stat_filters.ddl
+++ b/tools/h5stat/testfiles/h5stat_filters.ddl
@@ -13,6 +13,7 @@ File information
Object header size: (total/unused)
Groups: 48/8
Datasets: 4936/1344
+ Datatypes: 80/0
Storage information:
Groups:
B-tree/List: 1200
diff --git a/tools/h5stat/testfiles/h5stat_help1.ddl b/tools/h5stat/testfiles/h5stat_help1.ddl
index 0841572..0a86b4c 100644
--- a/tools/h5stat/testfiles/h5stat_help1.ddl
+++ b/tools/h5stat/testfiles/h5stat_help1.ddl
@@ -1,13 +1,6 @@
#############################
Expected output for 'h5stat -h'
#############################
-
-This tool is under development. For detailed information
-please see the specification document at
-http://hdf.ncsa.uiuc.edu/RFC/h5stat/h5stat-spec.pdf
-
-Please send your comments and questions to help@hdfgroup.org
-
Usage: h5stat [OPTIONS] file
OPTIONS
diff --git a/tools/h5stat/testfiles/h5stat_help2.ddl b/tools/h5stat/testfiles/h5stat_help2.ddl
index 1e6295b..e41eb9e 100644
--- a/tools/h5stat/testfiles/h5stat_help2.ddl
+++ b/tools/h5stat/testfiles/h5stat_help2.ddl
@@ -1,13 +1,6 @@
#############################
Expected output for 'h5stat --help'
#############################
-
-This tool is under development. For detailed information
-please see the specification document at
-http://hdf.ncsa.uiuc.edu/RFC/h5stat/h5stat-spec.pdf
-
-Please send your comments and questions to help@hdfgroup.org
-
Usage: h5stat [OPTIONS] file
OPTIONS
diff --git a/tools/h5stat/testfiles/h5stat_newgrat.ddl b/tools/h5stat/testfiles/h5stat_newgrat.ddl
index 5ba2e7f..f87f297 100644
--- a/tools/h5stat/testfiles/h5stat_newgrat.ddl
+++ b/tools/h5stat/testfiles/h5stat_newgrat.ddl
@@ -13,6 +13,7 @@ File information
Object header size: (total/unused)
Groups: 5145147/3220092
Datasets: 414/312
+ Datatypes: 0/0
Storage information:
Groups:
B-tree/List: 470054
diff --git a/tools/h5stat/testfiles/h5stat_tsohm.ddl b/tools/h5stat/testfiles/h5stat_tsohm.ddl
index 56524e1..577dfdd 100644
--- a/tools/h5stat/testfiles/h5stat_tsohm.ddl
+++ b/tools/h5stat/testfiles/h5stat_tsohm.ddl
@@ -13,6 +13,7 @@ File information
Object header size: (total/unused)
Groups: 51/2
Datasets: 852/447
+ Datatypes: 0/0
Storage information:
Groups:
B-tree/List: 872