mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-02-23 16:20:57 +08:00
[svn-r16663] cleaned compiler warnings in linux
tested: linux
This commit is contained in:
parent
385f2b4854
commit
ced8683011
@ -1,17 +1,17 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* Copyright by The HDF Group. *
|
||||
* Copyright by the Board of Trustees of the University of Illinois. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* This file is part of HDF5. The full HDF5 copyright notice, including *
|
||||
* terms governing use, modification, and redistribution, is contained in *
|
||||
* the files COPYING and Copyright.html. COPYING can be found at the root *
|
||||
* of the source code distribution tree; Copyright.html can be found at the *
|
||||
* root level of an installed copy of the electronic HDF5 document set and *
|
||||
* is linked from the top-level documents page. It can also be found at *
|
||||
* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
|
||||
* access to either file, you may request a copy from help@hdfgroup.org. *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
* Copyright by The HDF Group. *
|
||||
* Copyright by the Board of Trustees of the University of Illinois. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* This file is part of HDF5. The full HDF5 copyright notice, including *
|
||||
* terms governing use, modification, and redistribution, is contained in *
|
||||
* the files COPYING and Copyright.html. COPYING can be found at the root *
|
||||
* of the source code distribution tree; Copyright.html can be found at the *
|
||||
* root level of an installed copy of the electronic HDF5 document set and *
|
||||
* is linked from the top-level documents page. It can also be found at *
|
||||
* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
|
||||
* access to either file, you may request a copy from help@hdfgroup.org. *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -27,10 +27,10 @@ extern char *progname;
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* File: h5repack.c
|
||||
* Purpose: Public API functions
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
* File: h5repack.c
|
||||
* Purpose: Public API functions
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static int check_options(pack_opt_t *options);
|
||||
static int check_objects(const char* fname, pack_opt_t *options);
|
||||
@ -40,24 +40,24 @@ static int have_request(pack_opt_t *options);
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: h5repack
|
||||
*
|
||||
* Purpose: locate all high-level HDF5 objects in the file
|
||||
* and compress/chunk them using options
|
||||
*
|
||||
* Algorithm: 2 traversals are made to the file; the 1st builds a list of
|
||||
* the objects, the 2nd makes a copy of them, using the options;
|
||||
* the reason for the 1st traversal is to check for invalid
|
||||
* object name requests
|
||||
*
|
||||
* Return: 0, ok, -1, fail
|
||||
*
|
||||
* Programmer: pvn@ncsa.uiuc.edu
|
||||
*
|
||||
* Date: September, 22, 2003
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
* Function: h5repack
|
||||
*
|
||||
* Purpose: locate all high-level HDF5 objects in the file
|
||||
* and compress/chunk them using options
|
||||
*
|
||||
* Algorithm: 2 traversals are made to the file; the 1st builds a list of
|
||||
* the objects, the 2nd makes a copy of them, using the options;
|
||||
* the reason for the 1st traversal is to check for invalid
|
||||
* object name requests
|
||||
*
|
||||
* Return: 0, ok, -1, fail
|
||||
*
|
||||
* Programmer: pvn@ncsa.uiuc.edu
|
||||
*
|
||||
* Date: September, 22, 2003
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
int h5repack(const char* infile,
|
||||
const char* outfile,
|
||||
pack_opt_t *options)
|
||||
@ -81,14 +81,14 @@ int h5repack(const char* infile,
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: h5repack_init
|
||||
*
|
||||
* Purpose: initialize options
|
||||
*
|
||||
* Return: 0, ok, -1, fail
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
* Function: h5repack_init
|
||||
*
|
||||
* Purpose: initialize options
|
||||
*
|
||||
* Return: 0, ok, -1, fail
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int h5repack_init (pack_opt_t *options,
|
||||
int verbose)
|
||||
@ -110,12 +110,12 @@ int h5repack_init (pack_opt_t *options,
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: h5repack_end
|
||||
*
|
||||
* Purpose: free options table
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
* Function: h5repack_end
|
||||
*
|
||||
* Purpose: free options table
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int h5repack_end (pack_opt_t *options)
|
||||
{
|
||||
@ -123,15 +123,15 @@ int h5repack_end (pack_opt_t *options)
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: h5repack_addfilter
|
||||
*
|
||||
* Purpose: add a compression -f option to table
|
||||
* Example: -f dset:GZIP=6
|
||||
*
|
||||
* Return: 0, ok, -1, fail
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
* Function: h5repack_addfilter
|
||||
*
|
||||
* Purpose: add a compression -f option to table
|
||||
* Example: -f dset:GZIP=6
|
||||
*
|
||||
* Return: 0, ok, -1, fail
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int h5repack_addfilter(const char* str,
|
||||
pack_opt_t *options)
|
||||
@ -177,14 +177,14 @@ int h5repack_addfilter(const char* str,
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: h5repack_addlayout
|
||||
*
|
||||
* Purpose: add a layout option
|
||||
*
|
||||
* Return: 0, ok, -1, fail
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
* Function: h5repack_addlayout
|
||||
*
|
||||
* Purpose: add a layout option
|
||||
*
|
||||
* Return: 0, ok, -1, fail
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
int h5repack_addlayout(const char* str,
|
||||
@ -199,9 +199,9 @@ int h5repack_addlayout(const char* str,
|
||||
init_packobject(&pack);
|
||||
|
||||
if (options->all_layout==1){
|
||||
error_msg(progname, "invalid layout input: 'all' option \
|
||||
is present with other objects <%s>\n",str);
|
||||
return -1;
|
||||
error_msg(progname, "invalid layout input: 'all' option \
|
||||
is present with other objects <%s>\n",str);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* parse the layout option */
|
||||
@ -215,7 +215,7 @@ int h5repack_addlayout(const char* str,
|
||||
options->layout_g=pack.layout;
|
||||
if (pack.layout==H5D_CHUNKED)
|
||||
{
|
||||
/* -2 means the NONE option, remove chunking
|
||||
/* -2 means the NONE option, remove chunking
|
||||
and set the global layout to contiguous */
|
||||
if (pack.chunk.rank==-2)
|
||||
{
|
||||
@ -243,22 +243,22 @@ int h5repack_addlayout(const char* str,
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: check_options
|
||||
*
|
||||
* Purpose: print options, checks for invalid options
|
||||
*
|
||||
* Return: void, return -1 on error
|
||||
*
|
||||
* Programmer: pvn@ncsa.uiuc.edu
|
||||
*
|
||||
* Date: September, 22, 2003
|
||||
*
|
||||
* Modification:
|
||||
* Peter Cao, July 9, 2007
|
||||
* Add "-L, --latest" and other options to pack a file with the latest file format
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
* Function: check_options
|
||||
*
|
||||
* Purpose: print options, checks for invalid options
|
||||
*
|
||||
* Return: void, return -1 on error
|
||||
*
|
||||
* Programmer: pvn@ncsa.uiuc.edu
|
||||
*
|
||||
* Date: September, 22, 2003
|
||||
*
|
||||
* Modification:
|
||||
* Peter Cao, July 9, 2007
|
||||
* Add "-L, --latest" and other options to pack a file with the latest file format
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static int check_options(pack_opt_t *options)
|
||||
{
|
||||
unsigned int i;
|
||||
@ -272,7 +272,8 @@ static int check_options(pack_opt_t *options)
|
||||
if (options->verbose && have_request(options) /* only print if requested */)
|
||||
{
|
||||
printf("Objects to modify layout are...\n");
|
||||
if (options->all_layout==1) {
|
||||
if (options->all_layout==1)
|
||||
{
|
||||
switch (options->layout_g)
|
||||
{
|
||||
case H5D_COMPACT:
|
||||
@ -284,12 +285,17 @@ static int check_options(pack_opt_t *options)
|
||||
case H5D_CHUNKED:
|
||||
strcpy(slayout,"chunked");
|
||||
break;
|
||||
case H5D_LAYOUT_ERROR:
|
||||
case H5D_NLAYOUTS:
|
||||
error_msg(progname, "invalid layout\n");
|
||||
return -1;
|
||||
default:
|
||||
strcpy(slayout,"unknown");
|
||||
break;
|
||||
strcpy(slayout,"invalid layout\n");
|
||||
return -1;
|
||||
}
|
||||
printf(" Apply %s layout to all\n", slayout);
|
||||
if (H5D_CHUNKED==options->layout_g) {
|
||||
if (H5D_CHUNKED==options->layout_g)
|
||||
{
|
||||
printf("with dimension [");
|
||||
for ( j = 0; j < options->chunk_g.rank; j++)
|
||||
printf("%d ",(int)options->chunk_g.chunk_lengths[j]);
|
||||
@ -322,9 +328,9 @@ static int check_options(pack_opt_t *options)
|
||||
|
||||
if (options->all_layout==1 && has_ck)
|
||||
{
|
||||
error_msg(progname, "invalid chunking input: 'all' option\
|
||||
is present with other objects\n");
|
||||
return -1;
|
||||
error_msg(progname, "invalid chunking input: 'all' option\
|
||||
is present with other objects\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
@ -356,6 +362,8 @@ static int check_options(pack_opt_t *options)
|
||||
get_sfilter(filtn),
|
||||
options->filter_g[k].cd_values[0]);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
} /* k */
|
||||
};
|
||||
}
|
||||
@ -382,9 +390,9 @@ static int check_options(pack_opt_t *options)
|
||||
|
||||
if (options->all_filter==1 && has_cp)
|
||||
{
|
||||
error_msg(progname, "invalid compression input: 'all' option\
|
||||
is present with other objects\n");
|
||||
return -1;
|
||||
error_msg(progname, "invalid compression input: 'all' option\
|
||||
is present with other objects\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
@ -455,19 +463,19 @@ static int check_options(pack_opt_t *options)
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: check_objects
|
||||
*
|
||||
* Purpose: locate all HDF5 objects in the file and compare with user
|
||||
* supplied list
|
||||
*
|
||||
* Return: 0, ok, -1 no
|
||||
*
|
||||
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
|
||||
*
|
||||
* Date: September, 23, 2003
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
* Function: check_objects
|
||||
*
|
||||
* Purpose: locate all HDF5 objects in the file and compare with user
|
||||
* supplied list
|
||||
*
|
||||
* Return: 0, ok, -1 no
|
||||
*
|
||||
* Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
|
||||
*
|
||||
* Date: September, 23, 2003
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static int check_objects(const char* fname,
|
||||
pack_opt_t *options)
|
||||
{
|
||||
@ -480,9 +488,9 @@ static int check_objects(const char* fname,
|
||||
return 0;
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* open the file
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
* open the file
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
if((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, 0)) < 0)
|
||||
{
|
||||
printf("<%s>: %s\n", fname, H5FOPENERROR );
|
||||
@ -490,9 +498,9 @@ static int check_objects(const char* fname,
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* get the list of objects in the file
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
* get the list of objects in the file
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* init table */
|
||||
trav_table_init(&travt);
|
||||
@ -502,9 +510,9 @@ static int check_objects(const char* fname,
|
||||
goto out;
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* compare with user supplied list
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
* compare with user supplied list
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
if(options->verbose)
|
||||
printf("Opening file <%s>. Searching for objects to modify...\n", fname);
|
||||
@ -529,7 +537,7 @@ static int check_objects(const char* fname,
|
||||
switch(options->op_tbl->objs[i].filter->filtn)
|
||||
{
|
||||
/* chunk size must be smaller than pixels per block */
|
||||
case H5Z_FILTER_SZIP:
|
||||
case H5Z_FILTER_SZIP:
|
||||
{
|
||||
int j;
|
||||
hsize_t csize = 1;
|
||||
@ -568,10 +576,12 @@ static int check_objects(const char* fname,
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} /* i */
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
/*-------------------------------------------------------------------------
|
||||
* close
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -590,16 +600,16 @@ out:
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: have_request
|
||||
*
|
||||
* Purpose: check if a filter or layout was requested
|
||||
*
|
||||
* Return: 1 yes, 0 no
|
||||
*
|
||||
* Date: May, 24, 2007
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
* Function: have_request
|
||||
*
|
||||
* Purpose: check if a filter or layout was requested
|
||||
*
|
||||
* Return: 1 yes, 0 no
|
||||
*
|
||||
* Date: May, 24, 2007
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static int have_request(pack_opt_t *options)
|
||||
{
|
||||
|
||||
@ -612,14 +622,14 @@ static int have_request(pack_opt_t *options)
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: get_sfilter
|
||||
*
|
||||
* Purpose: return the filter as a string name
|
||||
*
|
||||
* Return: name of filter, exit on error
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
* Function: get_sfilter
|
||||
*
|
||||
* Purpose: return the filter as a string name
|
||||
*
|
||||
* Return: name of filter, exit on error
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static const char* get_sfilter(H5Z_filter_t filtn)
|
||||
{
|
||||
@ -641,6 +651,5 @@ static const char* get_sfilter(H5Z_filter_t filtn)
|
||||
error_msg(progname, "input error in filter type\n");
|
||||
exit(1);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -98,6 +98,11 @@ int aux_assign_obj(const char* name, /* object name from traverse lis
|
||||
for ( i=0; i<tmp.chunk.rank; i++)
|
||||
tmp.chunk.chunk_lengths[i]=options->chunk_g.chunk_lengths[i];
|
||||
break;
|
||||
case H5D_LAYOUT_ERROR:
|
||||
case H5D_COMPACT:
|
||||
case H5D_CONTIGUOUS:
|
||||
case H5D_NLAYOUTS:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}/*switch*/
|
||||
@ -112,6 +117,11 @@ int aux_assign_obj(const char* name, /* object name from traverse lis
|
||||
for ( i=0; i<tmp.chunk.rank; i++)
|
||||
tmp.chunk.chunk_lengths[i]=options->op_tbl->objs[idx].chunk.chunk_lengths[i];
|
||||
break;
|
||||
case H5D_LAYOUT_ERROR:
|
||||
case H5D_COMPACT:
|
||||
case H5D_CONTIGUOUS:
|
||||
case H5D_NLAYOUTS:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}/*switch*/
|
||||
@ -163,6 +173,11 @@ int aux_assign_obj(const char* name, /* object name from traverse lis
|
||||
for ( i=0; i<tmp.chunk.rank; i++)
|
||||
tmp.chunk.chunk_lengths[i]=options->chunk_g.chunk_lengths[i];
|
||||
break;
|
||||
case H5D_LAYOUT_ERROR:
|
||||
case H5D_COMPACT:
|
||||
case H5D_CONTIGUOUS:
|
||||
case H5D_NLAYOUTS:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}/*switch*/
|
||||
|
@ -95,7 +95,7 @@ obj_list_t* parse_filter(const char *str,
|
||||
}
|
||||
|
||||
n++;
|
||||
obj_list = malloc(n*sizeof(obj_list_t));
|
||||
obj_list = (obj_list_t*) malloc(n*sizeof(obj_list_t));
|
||||
if (obj_list==NULL)
|
||||
{
|
||||
error_msg(progname, "could not allocate object list\n");
|
||||
@ -446,6 +446,8 @@ obj_list_t* parse_filter(const char *str,
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
|
||||
};
|
||||
@ -514,7 +516,7 @@ obj_list_t* parse_layout(const char *str,
|
||||
}
|
||||
|
||||
n++;
|
||||
obj_list=malloc(n*sizeof(obj_list_t));
|
||||
obj_list = (obj_list_t*) malloc(n*sizeof(obj_list_t));
|
||||
if (obj_list==NULL)
|
||||
{
|
||||
error_msg(progname, "could not allocate object list\n");
|
||||
|
@ -74,7 +74,8 @@ int do_copy_refobjs(hid_t fidin,
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
for(i = 0; i < travt->nobjs; i++) {
|
||||
switch(travt->objs[i].type) {
|
||||
switch(travt->objs[i].type)
|
||||
{
|
||||
/*-------------------------------------------------------------------------
|
||||
* H5TRAV_TYPE_GROUP
|
||||
*-------------------------------------------------------------------------
|
||||
@ -165,7 +166,7 @@ int do_copy_refobjs(hid_t fidin,
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
if(nelmts) {
|
||||
buf = (void *)HDmalloc((unsigned)(nelmts * msize));
|
||||
buf = (hobj_ref_t *)HDmalloc((unsigned)(nelmts * msize));
|
||||
if(buf==NULL) {
|
||||
printf("cannot read into memory\n" );
|
||||
goto error;
|
||||
@ -173,7 +174,7 @@ int do_copy_refobjs(hid_t fidin,
|
||||
if(H5Dread(dset_in, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0)
|
||||
goto error;
|
||||
|
||||
refbuf = HDcalloc((unsigned)nelmts, msize);
|
||||
refbuf = (hobj_ref_t*) HDcalloc((unsigned)nelmts, msize);
|
||||
if(refbuf == NULL){
|
||||
printf("cannot allocate memory\n" );
|
||||
goto error;
|
||||
@ -237,7 +238,7 @@ int do_copy_refobjs(hid_t fidin,
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
if(nelmts) {
|
||||
buf = (void *)HDmalloc((unsigned)(nelmts * msize));
|
||||
buf = (hdset_reg_ref_t *)HDmalloc((unsigned)(nelmts * msize));
|
||||
if(buf == NULL) {
|
||||
printf("cannot read into memory\n");
|
||||
goto error;
|
||||
@ -249,7 +250,7 @@ int do_copy_refobjs(hid_t fidin,
|
||||
* create output
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
refbuf = HDcalloc(sizeof(hdset_reg_ref_t), (size_t)nelmts); /*init to zero */
|
||||
refbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)nelmts); /*init to zero */
|
||||
if(refbuf == NULL) {
|
||||
printf("cannot allocate memory\n");
|
||||
goto error;
|
||||
@ -370,6 +371,10 @@ int do_copy_refobjs(hid_t fidin,
|
||||
/*nothing to do */
|
||||
break;
|
||||
|
||||
case H5TRAV_TYPE_UNKNOWN:
|
||||
case H5TRAV_TYPE_UDLINK:
|
||||
goto error;
|
||||
|
||||
default:
|
||||
break;
|
||||
} /* end switch */
|
||||
@ -436,7 +441,8 @@ static int copy_refs_attr(hid_t loc_in,
|
||||
if(H5Oget_info(loc_in, &oinfo) < 0)
|
||||
goto error;
|
||||
|
||||
for(u = 0; u < (unsigned)oinfo.num_attrs; u++) {
|
||||
for(u = 0; u < (unsigned)oinfo.num_attrs; u++)
|
||||
{
|
||||
/*-------------------------------------------------------------------------
|
||||
* open
|
||||
*-------------------------------------------------------------------------
|
||||
@ -482,7 +488,8 @@ static int copy_refs_attr(hid_t loc_in,
|
||||
* we cannot just copy the buffers, but instead we recreate the reference
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
if(H5Tequal(mtype_id, H5T_STD_REF_OBJ)) {
|
||||
if(H5Tequal(mtype_id, H5T_STD_REF_OBJ))
|
||||
{
|
||||
hid_t refobj_id;
|
||||
hobj_ref_t *refbuf = NULL;
|
||||
unsigned k;
|
||||
@ -494,23 +501,28 @@ static int copy_refs_attr(hid_t loc_in,
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
if (nelmts) {
|
||||
buf = (void *)HDmalloc((unsigned)(nelmts * msize));
|
||||
if(buf == NULL) {
|
||||
if (nelmts)
|
||||
{
|
||||
buf = (hobj_ref_t *)HDmalloc((unsigned)(nelmts * msize));
|
||||
if(buf == NULL)
|
||||
{
|
||||
printf("cannot read into memory\n");
|
||||
goto error;
|
||||
} /* end if */
|
||||
if(H5Aread(attr_id, mtype_id, buf) < 0)
|
||||
goto error;
|
||||
|
||||
refbuf = HDcalloc((unsigned)nelmts, msize);
|
||||
if(refbuf == NULL) {
|
||||
refbuf = (hobj_ref_t *)HDcalloc((unsigned)nelmts, msize);
|
||||
if(refbuf == NULL)
|
||||
{
|
||||
printf( "cannot allocate memory\n" );
|
||||
goto error;
|
||||
} /* end if */
|
||||
|
||||
for(k = 0; k < nelmts; k++) {
|
||||
H5E_BEGIN_TRY {
|
||||
for(k = 0; k < nelmts; k++)
|
||||
{
|
||||
H5E_BEGIN_TRY
|
||||
{
|
||||
if((refobj_id = H5Rdereference(attr_id, H5R_OBJECT, &buf[k])) < 0)
|
||||
goto error;
|
||||
} H5E_END_TRY;
|
||||
@ -518,7 +530,8 @@ static int copy_refs_attr(hid_t loc_in,
|
||||
/* get the name. a valid name could only occur in the
|
||||
* second traversal of the file
|
||||
*/
|
||||
if((refname = MapIdToName(refobj_id, travt)) != NULL) {
|
||||
if((refname = MapIdToName(refobj_id, travt)) != NULL)
|
||||
{
|
||||
/* create the reference */
|
||||
if(H5Rcreate(&refbuf[k], fidout, refname, H5R_OBJECT, -1) < 0)
|
||||
goto error;
|
||||
@ -552,7 +565,8 @@ static int copy_refs_attr(hid_t loc_in,
|
||||
* dataset region references
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
else if(H5Tequal(mtype_id, H5T_STD_REF_DSETREG)) {
|
||||
else if(H5Tequal(mtype_id, H5T_STD_REF_DSETREG))
|
||||
{
|
||||
hid_t refobj_id;
|
||||
hdset_reg_ref_t *refbuf = NULL; /* input buffer for region references */
|
||||
hdset_reg_ref_t *buf = NULL; /* output buffer */
|
||||
@ -563,9 +577,11 @@ static int copy_refs_attr(hid_t loc_in,
|
||||
* read input to memory
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
if(nelmts) {
|
||||
buf = (void *)HDmalloc((unsigned)(nelmts * msize));
|
||||
if(buf == NULL) {
|
||||
if(nelmts)
|
||||
{
|
||||
buf = (hdset_reg_ref_t *)HDmalloc((unsigned)(nelmts * msize));
|
||||
if(buf == NULL)
|
||||
{
|
||||
printf( "cannot read into memory\n" );
|
||||
goto error;
|
||||
} /* end if */
|
||||
@ -576,14 +592,17 @@ static int copy_refs_attr(hid_t loc_in,
|
||||
* create output
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
refbuf = HDcalloc(sizeof(hdset_reg_ref_t), (size_t)nelmts); /*init to zero */
|
||||
if(refbuf == NULL) {
|
||||
refbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)nelmts); /*init to zero */
|
||||
if(refbuf == NULL)
|
||||
{
|
||||
printf( "cannot allocate memory\n" );
|
||||
goto error;
|
||||
} /* end if */
|
||||
|
||||
for(k = 0; k < nelmts; k++) {
|
||||
H5E_BEGIN_TRY {
|
||||
for(k = 0; k < nelmts; k++)
|
||||
{
|
||||
H5E_BEGIN_TRY
|
||||
{
|
||||
if((refobj_id = H5Rdereference(attr_id, H5R_DATASET_REGION, &buf[k])) < 0)
|
||||
continue;
|
||||
} H5E_END_TRY;
|
||||
@ -591,7 +610,8 @@ static int copy_refs_attr(hid_t loc_in,
|
||||
/* get the name. a valid name could only occur in the
|
||||
* second traversal of the file
|
||||
*/
|
||||
if((refname = MapIdToName(refobj_id, travt)) != NULL) {
|
||||
if((refname = MapIdToName(refobj_id, travt)) != NULL)
|
||||
{
|
||||
hid_t region_id; /* region id of the referenced dataset */
|
||||
|
||||
if((region_id = H5Rget_region(attr_id, H5R_DATASET_REGION, &buf[k])) < 0)
|
||||
@ -616,8 +636,10 @@ static int copy_refs_attr(hid_t loc_in,
|
||||
if((attr_out = H5Acreate2(loc_out, name, ftype_id, space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0)
|
||||
goto error;
|
||||
if(nelmts)
|
||||
{
|
||||
if(H5Awrite(attr_out, mtype_id, refbuf) < 0)
|
||||
goto error;
|
||||
}
|
||||
|
||||
if(H5Aclose(attr_out) < 0)
|
||||
goto error;
|
||||
@ -670,8 +692,10 @@ static const char* MapIdToName(hid_t refobj_id,
|
||||
unsigned int i;
|
||||
|
||||
/* linear search */
|
||||
for(i = 0; i < travt->nobjs; i++) {
|
||||
if(travt->objs[i].type == H5O_TYPE_DATASET) {
|
||||
for(i = 0; i < travt->nobjs; i++)
|
||||
{
|
||||
if(travt->objs[i].type == H5O_TYPE_DATASET)
|
||||
{
|
||||
H5O_info_t ref_oinfo; /* Stat for the refobj id */
|
||||
|
||||
/* obtain information to identify the referenced object uniquely */
|
||||
|
@ -40,9 +40,11 @@
|
||||
#define FNAME5 "h5repack_early.h5"
|
||||
#define FNAME5OUT "h5repack_early_out.h5"
|
||||
#define FNAME6 "h5repack_early2.h5"
|
||||
#ifdef H5_HAVE_FILTER_SZIP
|
||||
/* SZIP filter */
|
||||
#define FNAME7 "h5repack_szip.h5"
|
||||
#define FNAME7OUT "h5repack_szip_out.h5"
|
||||
#endif
|
||||
/* GZIP filter */
|
||||
#define FNAME8 "h5repack_deflate.h5"
|
||||
#define FNAME8OUT "h5repack_deflate_out.h5"
|
||||
@ -92,7 +94,6 @@ int d_status = EXIT_SUCCESS;
|
||||
#define CDIM1 DIM1/2
|
||||
#define CDIM2 DIM2/2
|
||||
#define RANK 2
|
||||
#define GBLL ((unsigned long long) 1024*1024*1024)
|
||||
|
||||
/* Size of userblock (for userblock test) */
|
||||
#define USERBLOCK_SIZE 2048
|
||||
@ -101,30 +102,30 @@ int d_status = EXIT_SUCCESS;
|
||||
* prototypes
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
int make_all_objects(hid_t loc_id);
|
||||
int make_attributes(hid_t loc_id);
|
||||
int make_hlinks(hid_t loc_id);
|
||||
int make_early(void);
|
||||
int make_layout(hid_t loc_id);
|
||||
static int make_all_objects(hid_t loc_id);
|
||||
static int make_attributes(hid_t loc_id);
|
||||
static int make_hlinks(hid_t loc_id);
|
||||
static int make_early(void);
|
||||
static int make_layout(hid_t loc_id);
|
||||
#ifdef H5_HAVE_FILTER_SZIP
|
||||
int make_szip(hid_t loc_id);
|
||||
#endif /* H5_HAVE_FILTER_SZIP */
|
||||
int make_deflate(hid_t loc_id);
|
||||
int make_shuffle(hid_t loc_id);
|
||||
int make_fletcher32(hid_t loc_id);
|
||||
int make_nbit(hid_t loc_id);
|
||||
int make_scaleoffset(hid_t loc_id);
|
||||
int make_all(hid_t loc_id);
|
||||
int make_fill(hid_t loc_id);
|
||||
int make_big(hid_t loc_id);
|
||||
int make_testfiles(void);
|
||||
int write_dset_in(hid_t loc_id,const char* dset_name,hid_t file_id,int make_diffs );
|
||||
int write_attr_in(hid_t loc_id,const char* dset_name,hid_t fid,int make_diffs );
|
||||
int write_dset(hid_t loc_id,int rank,hsize_t *dims,const char *dset_name,hid_t tid,void *buf );
|
||||
int make_dset(hid_t loc_id,const char *name,hid_t sid,hid_t dcpl,void *buf);
|
||||
int make_attr(hid_t loc_id,int rank,hsize_t *dims,const char *attr_name,hid_t tid,void *buf);
|
||||
int make_dset_reg_ref(hid_t loc_id);
|
||||
int make_external(hid_t loc_id);
|
||||
static int make_deflate(hid_t loc_id);
|
||||
static int make_shuffle(hid_t loc_id);
|
||||
static int make_fletcher32(hid_t loc_id);
|
||||
static int make_nbit(hid_t loc_id);
|
||||
static int make_scaleoffset(hid_t loc_id);
|
||||
static int make_all_filters(hid_t loc_id);
|
||||
static int make_fill(hid_t loc_id);
|
||||
static int make_big(hid_t loc_id);
|
||||
static int make_testfiles(void);
|
||||
static int write_dset_in(hid_t loc_id,const char* dset_name,hid_t file_id,int make_diffs );
|
||||
static int write_attr_in(hid_t loc_id,const char* dset_name,hid_t fid,int make_diffs );
|
||||
static int write_dset(hid_t loc_id,int rank,hsize_t *dims,const char *dset_name,hid_t tid,void *buf );
|
||||
static int make_dset(hid_t loc_id,const char *name,hid_t sid,hid_t dcpl,void *buf);
|
||||
static int make_attr(hid_t loc_id,int rank,hsize_t *dims,const char *attr_name,hid_t tid,void *buf);
|
||||
static int make_dset_reg_ref(hid_t loc_id);
|
||||
static int make_external(hid_t loc_id);
|
||||
static int make_userblock(void);
|
||||
static int verify_userblock( const char* filename);
|
||||
static int make_userblock_file(void);
|
||||
@ -1522,6 +1523,7 @@ error:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static
|
||||
int make_testfiles(void)
|
||||
{
|
||||
hid_t fid;
|
||||
@ -1641,7 +1643,7 @@ int make_testfiles(void)
|
||||
*/
|
||||
if((fid = H5Fcreate(FNAME11,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0)
|
||||
return -1;
|
||||
if (make_all(fid) < 0)
|
||||
if (make_all_filters(fid) < 0)
|
||||
goto out;
|
||||
if(H5Fclose(fid) < 0)
|
||||
return -1;
|
||||
@ -1720,6 +1722,7 @@ out:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static
|
||||
int make_all_objects(hid_t loc_id)
|
||||
{
|
||||
hid_t did=-1;
|
||||
@ -1841,6 +1844,7 @@ out:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static
|
||||
int make_attributes(hid_t loc_id)
|
||||
{
|
||||
hid_t did=-1;
|
||||
@ -1910,6 +1914,7 @@ out:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static
|
||||
int make_hlinks(hid_t loc_id)
|
||||
{
|
||||
hid_t g1id=-1;
|
||||
@ -1980,6 +1985,7 @@ out:
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifdef H5_HAVE_FILTER_SZIP
|
||||
static
|
||||
int make_szip(hid_t loc_id)
|
||||
{
|
||||
hid_t dcpl; /* dataset creation property list */
|
||||
@ -2056,6 +2062,7 @@ out:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static
|
||||
int make_deflate(hid_t loc_id)
|
||||
{
|
||||
hid_t dcpl; /* dataset creation property list */
|
||||
@ -2132,6 +2139,7 @@ out:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static
|
||||
int make_shuffle(hid_t loc_id)
|
||||
{
|
||||
hid_t dcpl; /* dataset creation property list */
|
||||
@ -2197,6 +2205,7 @@ out:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static
|
||||
int make_fletcher32(hid_t loc_id)
|
||||
{
|
||||
hid_t dcpl; /* dataset creation property list */
|
||||
@ -2266,6 +2275,7 @@ out:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static
|
||||
int make_nbit(hid_t loc_id)
|
||||
{
|
||||
hid_t dcpl; /* dataset creation property list */
|
||||
@ -2366,6 +2376,7 @@ out:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static
|
||||
int make_scaleoffset(hid_t loc_id)
|
||||
{
|
||||
hid_t dcpl; /* dataset creation property list */
|
||||
@ -2448,13 +2459,14 @@ out:
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: make_all
|
||||
* Function: make_all_filters
|
||||
*
|
||||
* Purpose: make a file with all filters
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
int make_all(hid_t loc_id)
|
||||
static
|
||||
int make_all_filters(hid_t loc_id)
|
||||
{
|
||||
hid_t dcpl; /* dataset creation property list */
|
||||
hid_t sid; /* dataspace ID */
|
||||
@ -2632,6 +2644,7 @@ out:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static
|
||||
int make_early(void)
|
||||
{
|
||||
hsize_t dims[1] ={3000};
|
||||
@ -2728,6 +2741,7 @@ out:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static
|
||||
int make_layout(hid_t loc_id)
|
||||
{
|
||||
hid_t dcpl=-1; /* dataset creation property list */
|
||||
@ -2832,6 +2846,7 @@ out:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static
|
||||
int make_fill(hid_t loc_id)
|
||||
{
|
||||
hid_t did=-1;
|
||||
@ -2884,7 +2899,7 @@ out:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static
|
||||
int make_big(hid_t loc_id)
|
||||
{
|
||||
hid_t did=-1;
|
||||
@ -2965,7 +2980,7 @@ out:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static
|
||||
int make_external(hid_t loc_id)
|
||||
{
|
||||
hid_t did=-1;
|
||||
@ -3196,7 +3211,7 @@ out:
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
static
|
||||
int write_dset_in(hid_t loc_id,
|
||||
const char* dset_name, /* for saving reference to dataset*/
|
||||
hid_t file_id,
|
||||
@ -3459,21 +3474,18 @@ int write_dset_in(hid_t loc_id,
|
||||
|
||||
{
|
||||
|
||||
double *dbuf; /* information to write */
|
||||
hid_t did; /* dataset ID */
|
||||
hid_t sid; /* dataspace ID */
|
||||
hid_t tid; /* datatype ID */
|
||||
size_t size;
|
||||
hsize_t sdims[] = {1};
|
||||
hsize_t tdims[] = {H5TOOLS_MALLOCSIZE / sizeof(double) + 1};
|
||||
int j;
|
||||
double *dbuf; /* information to write */
|
||||
size_t size;
|
||||
hsize_t sdims[] = {1};
|
||||
hsize_t tdims[] = {H5TOOLS_MALLOCSIZE / sizeof(double) + 1};
|
||||
unsigned u;
|
||||
|
||||
/* allocate and initialize array data to write */
|
||||
size = ( H5TOOLS_MALLOCSIZE / sizeof(double) + 1 ) * sizeof(double);
|
||||
dbuf = malloc( size );
|
||||
dbuf = (double*)malloc( size );
|
||||
|
||||
for( j = 0; j < H5TOOLS_MALLOCSIZE / sizeof(double) + 1; j++)
|
||||
dbuf[j] = j;
|
||||
for( u = 0; u < H5TOOLS_MALLOCSIZE / sizeof(double) + 1; u++)
|
||||
dbuf[u] = u;
|
||||
|
||||
if (make_diffs)
|
||||
{
|
||||
@ -3971,8 +3983,7 @@ out:
|
||||
#define SPACE2_RANK 2
|
||||
#define SPACE2_DIM1 10
|
||||
#define SPACE2_DIM2 10
|
||||
#define NPOINTS 10
|
||||
|
||||
static
|
||||
int make_dset_reg_ref(hid_t loc_id)
|
||||
{
|
||||
hid_t did1=-1; /* Dataset ID */
|
||||
@ -4075,7 +4086,7 @@ out:
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
static
|
||||
int write_attr_in(hid_t loc_id,
|
||||
const char* dset_name, /* for saving reference to dataset*/
|
||||
hid_t fid, /* for reference create */
|
||||
@ -5244,6 +5255,7 @@ out:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static
|
||||
int make_dset(hid_t loc_id,
|
||||
const char *name,
|
||||
hid_t sid,
|
||||
@ -5279,7 +5291,7 @@ out:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static
|
||||
int write_dset( hid_t loc_id,
|
||||
int rank,
|
||||
hsize_t *dims,
|
||||
@ -5317,7 +5329,7 @@ out:
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: write_attr
|
||||
* Function: make_attr
|
||||
*
|
||||
* Purpose: utility function to write an attribute in LOC_ID
|
||||
*
|
||||
@ -5327,7 +5339,7 @@ out:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static
|
||||
int make_attr(hid_t loc_id,
|
||||
int rank,
|
||||
hsize_t *dims,
|
||||
|
Loading…
Reference in New Issue
Block a user