diff options
author | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2003-12-16 18:08:45 (GMT) |
---|---|---|
committer | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2003-12-16 18:08:45 (GMT) |
commit | dc4f40f02f16d182ffad1fcbfa3dfdaf0d9426b9 (patch) | |
tree | 9914f9b0c661d5bdd73e83f559a4048fe6975724 /tools | |
parent | 991bd6c9e3f590104269c70c4e7becb55770091f (diff) | |
download | hdf5-dc4f40f02f16d182ffad1fcbfa3dfdaf0d9426b9.zip hdf5-dc4f40f02f16d182ffad1fcbfa3dfdaf0d9426b9.tar.gz hdf5-dc4f40f02f16d182ffad1fcbfa3dfdaf0d9426b9.tar.bz2 |
[svn-r7962] Purpose:
h5repack new features
Description:
added the copy of referenced objects
Solution:
Platforms tested:
linux
solaris 2.7
IRIX
Misc. update:
Diffstat (limited to 'tools')
-rw-r--r-- | tools/h5repack/Makefile.in | 6 | ||||
-rw-r--r-- | tools/h5repack/h5repack.h | 41 | ||||
-rw-r--r-- | tools/h5repack/h5repack_copy.c | 233 | ||||
-rw-r--r-- | tools/h5repack/h5repack_refs.c | 600 | ||||
-rw-r--r-- | tools/h5repack/testh5repack_attr.c (renamed from tools/h5repack/test_h5repack_add.c) | 300 | ||||
-rw-r--r-- | tools/h5repack/testh5repack_dset.c | 668 | ||||
-rw-r--r-- | tools/h5repack/testh5repack_filters.c | 295 | ||||
-rw-r--r-- | tools/h5repack/testh5repack_main.c (renamed from tools/h5repack/test_h5repack_main.c) | 4 |
8 files changed, 1751 insertions, 396 deletions
diff --git a/tools/h5repack/Makefile.in b/tools/h5repack/Makefile.in index 617e4c6..dc4d686 100644 --- a/tools/h5repack/Makefile.in +++ b/tools/h5repack/Makefile.in @@ -50,10 +50,10 @@ MOSTLYCLEAN=*.h5 ## Source and object files for programs... ## -PROG_SRC=h5repack.c h5repack_copy.c h5repack_list.c h5repack_main.c h5repack_opttable.c h5repack_parse.c test_h5repack_add.c test_h5repack_main.c +PROG_SRC=h5repack.c h5repack_copy.c h5repack_refs.c h5repack_list.c h5repack_main.c h5repack_opttable.c h5repack_parse.c testh5repack_attr.c testh5repack_dset.c testh5repack_filters.c testh5repack_main.c PROG_OBJ=$(PROG_SRC:.c=.lo) -OBJS=h5repack.lo h5repack_copy.lo h5repack_list.lo h5repack_main.lo h5repack_opttable.lo h5repack_parse.lo -TEST_OBJS=h5repack.lo h5repack_copy.lo h5repack_list.lo h5repack_opttable.lo h5repack_parse.lo test_h5repack_add.lo test_h5repack_main.lo +OBJS=h5repack.lo h5repack_copy.lo h5repack_refs.lo h5repack_list.lo h5repack_main.lo h5repack_opttable.lo h5repack_parse.lo +TEST_OBJS=h5repack.lo h5repack_copy.lo h5repack_refs.lo h5repack_list.lo h5repack_opttable.lo h5repack_parse.lo testh5repack_attr.lo testh5repack_dset.lo testh5repack_filters.lo testh5repack_main.lo PRIVATE_HDR= diff --git a/tools/h5repack/h5repack.h b/tools/h5repack/h5repack.h index bb0f8fc..9e857e7 100644 --- a/tools/h5repack/h5repack.h +++ b/tools/h5repack/h5repack.h @@ -64,6 +64,7 @@ typedef struct { char path[MAX_NC_NAME]; /* name of object */ comp_info_t comp; /* compression information */ chunk_info_t chunk; /* chunk information */ + hid_t refobj_id; /* object ID */ } pack_info_t; /* store a table of all objects */ @@ -129,7 +130,7 @@ int copy_file(const char* fnamein, void print_objlist(const char *filename, int nobjects, - trav_info_t *info ); + trav_info_t *travi ); int do_copy_file(hid_t fidin, hid_t fidout, @@ -139,13 +140,39 @@ int do_copy_file(hid_t fidin, int copy_attr(hid_t loc_in, hid_t loc_out, - pack_opt_t *options + pack_opt_t *options, + int nobjects, /* number of objects */ + trav_info_t *travi, /* array of object names */ + hid_t fidout /*for saving references */ ); void read_info(const char *filename,pack_opt_t *options); +void close_obj(H5G_obj_t obj_type, hid_t obj_id); + +const char* MapIdToName(hid_t refobj_id, + int nobjects, /* number of objects */ + trav_info_t *travi, /* array of object names */ + pack_opt_t *options) /* repack options */; + + + +int do_copy_refobjs(hid_t fidin, + hid_t fidout, + int nobjects, /* number of objects */ + trav_info_t *travi, /* array of object names */ + pack_opt_t *options); /* repack options */ + +int do_copy_refobjs_inattr(hid_t loc_in, + hid_t loc_out, + pack_opt_t *options, + int nobjects, /* number of objects */ + trav_info_t *travi, /* array of object names */ + hid_t fidout /* for saving references */ + ); + /*------------------------------------------------------------------------- * options table @@ -224,6 +251,16 @@ int write_attr(hid_t loc_id, hid_t type_id, void *buf); + +void write_attr_in(hid_t loc_id, + const char* dset_name, /* for saving reference to dataset*/ + hid_t fid, /* for reference create */ + int make_diffs /* flag to modify data buffers */); + +void write_dset_in(hid_t loc_id, + const char* dset_name, /* for saving reference to dataset*/ + hid_t file_id, + int make_diffs /* flag to modify data buffers */); diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c index 5c28b17..f236889 100644 --- a/tools/h5repack/h5repack_copy.c +++ b/tools/h5repack/h5repack_copy.c @@ -19,8 +19,6 @@ #include "H5private.h" #include "h5repack.h" - - /*------------------------------------------------------------------------- * Function: copy_file * @@ -42,7 +40,7 @@ int copy_file(const char* fnamein, hid_t fidin; hid_t fidout; int nobjects; - trav_info_t *info=NULL; + trav_info_t *travi=NULL; /*------------------------------------------------------------------------- * open the files @@ -84,11 +82,11 @@ int copy_file(const char* fnamein, *------------------------------------------------------------------------- */ - if ((info = (trav_info_t*) malloc( nobjects * sizeof(trav_info_t)))==NULL){ + if ((travi = (trav_info_t*) malloc( nobjects * sizeof(trav_info_t)))==NULL){ printf("h5repack: <%s>: Could not allocate object list\n", fnamein ); return -1; } - if (h5trav_getinfo(fidin, info )<0) { + if (h5trav_getinfo(fidin, travi )<0) { printf("h5repack: <%s>: Could not obtain object list\n", fnamein ); return -1; } @@ -97,8 +95,16 @@ int copy_file(const char* fnamein, * do the copy *------------------------------------------------------------------------- */ - - if(do_copy_file(fidin,fidout,nobjects,info,options)<0) { + if(do_copy_file(fidin,fidout,nobjects,travi,options)<0) { + printf("h5repack: <%s>: Could not copy data to: %s\n", fnamein, fnameout); + return -1; + } + +/*------------------------------------------------------------------------- + * do the copy of referenced objects + *------------------------------------------------------------------------- + */ + if(do_copy_refobjs(fidin,fidout,nobjects,travi,options)<0) { printf("h5repack: <%s>: Could not copy data to: %s\n", fnamein, fnameout); return -1; } @@ -109,7 +115,7 @@ int copy_file(const char* fnamein, */ H5Fclose(fidin); H5Fclose(fidout); - h5trav_freeinfo(info,nobjects); + h5trav_freeinfo(travi,nobjects); return 0; } @@ -131,9 +137,9 @@ int copy_file(const char* fnamein, int do_copy_file(hid_t fidin, hid_t fidout, - int nobjects, - trav_info_t *info, - pack_opt_t *options) + int nobjects, /* number of objects */ + trav_info_t *travi, /* array of object names */ + pack_opt_t *options) /* repack options */ { hid_t grp_in; /* group ID */ hid_t grp_out; /* group ID */ @@ -152,7 +158,6 @@ int do_copy_file(hid_t fidin, hsize_t dims[H5S_MAX_RANK];/* dimensions of dataset */ int i, j; - /*------------------------------------------------------------------------- * copy the suppplied object list *------------------------------------------------------------------------- @@ -160,7 +165,8 @@ int do_copy_file(hid_t fidin, for ( i = 0; i < nobjects; i++) { - switch ( info[i].type ) + + switch ( travi[i].type ) { /*------------------------------------------------------------------------- * H5G_GROUP @@ -168,19 +174,19 @@ int do_copy_file(hid_t fidin, */ case H5G_GROUP: if (options->verbose) - printf(" %-10s %s\n", "group",info[i].name ); + printf(" %-10s %s\n", "group",travi[i].name ); - if ((grp_out=H5Gcreate(fidout, info[i].name, 0))<0) + if ((grp_out=H5Gcreate(fidout,travi[i].name, 0))<0) goto error; - if((grp_in = H5Gopen (fidin, info[i].name))<0) + if((grp_in = H5Gopen (fidin,travi[i].name))<0) goto error; /*------------------------------------------------------------------------- * copy attrs *------------------------------------------------------------------------- */ - if (copy_attr(grp_in,grp_out,options)<0) + if (copy_attr(grp_in,grp_out,options,nobjects,travi,fidout)<0) goto error; if (H5Gclose(grp_out)<0) @@ -196,9 +202,9 @@ int do_copy_file(hid_t fidin, */ case H5G_DATASET: if (options->verbose) - printf(" %-10s %s\n", "dataset",info[i].name ); + printf(" %-10s %s\n", "dataset",travi[i].name ); - if ((dset_in=H5Dopen(fidin,info[i].name))<0) + if ((dset_in=H5Dopen(fidin,travi[i].name))<0) goto error; if ((space_id=H5Dget_space(dset_in))<0) goto error; @@ -210,11 +216,6 @@ int do_copy_file(hid_t fidin, goto error; if ( H5Sget_simple_extent_dims(space_id,dims,NULL)<0) goto error; - -/*------------------------------------------------------------------------- - * read to memory - *------------------------------------------------------------------------- - */ nelmts=1; for (j=0; j<rank; j++) nelmts*=dims[j]; @@ -222,30 +223,55 @@ int do_copy_file(hid_t fidin, goto error; if ((msize=H5Tget_size(mtype_id))==0) goto error; - buf=(void *) HDmalloc((unsigned)(nelmts*msize)); - if ( buf==NULL){ - printf( "cannot read into memory\n" ); - goto error; - } - if (H5Dread(dset_in,mtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0) - goto error; -/*------------------------------------------------------------------------- - * create/write dataset/close - *------------------------------------------------------------------------- - */ - if ((dset_out=H5Dcreate(fidout,info[i].name,ftype_id,space_id,dcpl_id))<0) - goto error; - if (H5Dwrite(dset_out,mtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0) - goto error; - /*------------------------------------------------------------------------- - * copy attrs + * object references are a special case + * we cannot just copy the buffers, but instead we recreate the reference + * in a second traversal of the output file *------------------------------------------------------------------------- */ - if (copy_attr(dset_in,dset_out,options)<0) - goto error; + if ( ! H5Tequal(mtype_id, H5T_STD_REF_OBJ) ) + { + + /*------------------------------------------------------------------------- + * read to memory + *------------------------------------------------------------------------- + */ + + buf=(void *) HDmalloc((unsigned)(nelmts*msize)); + if ( buf==NULL){ + printf( "cannot read into memory\n" ); + goto error; + } + if (H5Dread(dset_in,mtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0) + goto error; + + /*------------------------------------------------------------------------- + * create/write dataset/close + *------------------------------------------------------------------------- + */ + if ((dset_out=H5Dcreate(fidout,travi[i].name,ftype_id,space_id,dcpl_id))<0) + goto error; + if (H5Dwrite(dset_out,mtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0) + goto error; + + /*------------------------------------------------------------------------- + * copy attrs + *------------------------------------------------------------------------- + */ + if (copy_attr(dset_in,dset_out,options,nobjects,travi,fidout)<0) + goto error; + + /*close */ + if (H5Dclose(dset_out)<0) + goto error; + + if (buf) + free(buf); + + }/*H5T_STD_REF_OBJ*/ + /*------------------------------------------------------------------------- * close @@ -262,11 +288,8 @@ int do_copy_file(hid_t fidin, goto error; if (H5Dclose(dset_in)<0) goto error; - if (H5Dclose(dset_out)<0) - goto error; + - if (buf) - free(buf); break; @@ -276,20 +299,20 @@ int do_copy_file(hid_t fidin, */ case H5G_TYPE: - if ((type_in = H5Topen (fidin, info[i].name))<0) + if ((type_in = H5Topen (fidin,travi[i].name))<0) goto error; if ((type_out = H5Tcopy(type_in))<0) goto error; - if ((H5Tcommit(fidout, info[i].name, type_out))<0) + if ((H5Tcommit(fidout,travi[i].name,type_out))<0) goto error; /*------------------------------------------------------------------------- * copy attrs *------------------------------------------------------------------------- */ - if (copy_attr(type_in,type_out,options)<0) + if (copy_attr(type_in,type_out,options,nobjects,travi,fidout)<0) goto error; if (H5Tclose(type_in)<0) @@ -298,10 +321,16 @@ int do_copy_file(hid_t fidin, goto error; if (options->verbose) - printf(" %-10s %s\n", "datatype",info[i].name ); + printf(" %-10s %s\n","datatype",travi[i].name ); break; + +/*------------------------------------------------------------------------- + * H5G_LINK + *------------------------------------------------------------------------- + */ + case H5G_LINK: { @@ -309,32 +338,32 @@ int do_copy_file(hid_t fidin, H5G_stat_t statbuf; char *targbuf=NULL; - if (H5Gget_objinfo(fidin,info[i].name,FALSE,&statbuf)<0) + if (H5Gget_objinfo(fidin,travi[i].name,FALSE,&statbuf)<0) goto error; targbuf = malloc(statbuf.linklen); - if (H5Gget_linkval(fidin,info[i].name,statbuf.linklen,targbuf)<0) + if (H5Gget_linkval(fidin,travi[i].name,statbuf.linklen,targbuf)<0) goto error; if (H5Glink(fidout, H5G_LINK_SOFT, - targbuf, /* current name of object */ - info[i].name /* new name of object */ + targbuf, /* current name of object */ + travi[i].name /* new name of object */ )<0) goto error; free(targbuf); if (options->verbose) - printf(" %-10s %s\n", "link",info[i].name ); + printf(" %-10s %s\n","link",travi[i].name ); } break; default: if (options->verbose) - printf(" %-10s %s\n", "User defined object", info[i].name); + printf(" %-10s %s\n","User defined object",travi[i].name); break; } } @@ -355,17 +384,14 @@ int do_copy_file(hid_t fidin, if ((grp_in = H5Gopen(fidin,"/"))<0) goto error; - if (copy_attr(grp_in,grp_out,options)<0) + if (copy_attr(grp_in,grp_out,options,nobjects,travi,fidout)<0) goto error; if (H5Gclose(grp_out)<0) goto error; if (H5Gclose(grp_in)<0) goto error; - - - - + return 0; error: @@ -407,7 +433,10 @@ error: int copy_attr(hid_t loc_in, hid_t loc_out, - pack_opt_t *options + pack_opt_t *options, + int nobjects, /* number of objects */ + trav_info_t *travi, /* array of object names */ + hid_t fidout /* for saving references */ ) { hid_t attr_id; /* attr ID */ @@ -415,20 +444,26 @@ int copy_attr(hid_t loc_in, hid_t space_id; /* space ID */ hid_t ftype_id; /* file data type ID */ hid_t mtype_id; /* memory data type ID */ - size_t msize; /* memory size of memory type */ - void *buf=NULL; /* data buffer */ + size_t msize; /* memory size of type */ + void *buf; /* data buffer */ hsize_t nelmts; /* number of elements in dataset */ int rank; /* rank of dataset */ hsize_t dims[H5S_MAX_RANK];/* dimensions of dataset */ char name[255]; int n, j; - unsigned u; + unsigned u; + int have_ref=0; if ((n = H5Aget_num_attrs(loc_in))<0) goto error; for ( u = 0; u < (unsigned)n; u++) { + + /* set data buffer to NULL each iteration + we might not use it in the case of references + */ + buf=NULL; /*------------------------------------------------------------------------- * open *------------------------------------------------------------------------- @@ -452,18 +487,31 @@ int copy_attr(hid_t loc_in, /* get dimensions */ if ( (rank = H5Sget_simple_extent_dims(space_id, dims, NULL)) < 0 ) goto error; - + + nelmts=1; + for (j=0; j<rank; j++) + nelmts*=dims[j]; + if ((mtype_id=H5Tget_native_type(ftype_id,H5T_DIR_DEFAULT))<0) + goto error; + if ((msize=H5Tget_size(mtype_id))==0) + goto error; + /*------------------------------------------------------------------------- - * read to memory + * object references are a special case + * we cannot just copy the buffers, but instead we recreate the reference + * this is done on a second sweep of the file that just copies + * the referenced objects *------------------------------------------------------------------------- */ - nelmts=1; - for (j=0; j<rank; j++) - nelmts*=dims[j]; - if ((mtype_id=H5Tget_native_type(ftype_id,H5T_DIR_DEFAULT))<0) - goto error; - if ((msize=H5Tget_size(mtype_id))==0) - goto error; + if ( ! H5Tequal(mtype_id, H5T_STD_REF_OBJ)) + { + + + /*------------------------------------------------------------------------- + * read to memory + *------------------------------------------------------------------------- + */ + buf=(void *) HDmalloc((unsigned)(nelmts*msize)); if ( buf==NULL){ printf( "cannot read into memory\n" ); @@ -471,17 +519,28 @@ int copy_attr(hid_t loc_in, } if (H5Aread(attr_id,mtype_id,buf)<0) goto error; - -/*------------------------------------------------------------------------- - * copy - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * copy + *------------------------------------------------------------------------- + */ + + if ((attr_out=H5Acreate(loc_out,name,ftype_id,space_id,H5P_DEFAULT))<0) + goto error; + if(H5Awrite(attr_out,mtype_id,buf)<0) + goto error; + + /*close*/ + if (H5Aclose(attr_out)<0) + goto error; + + + if (buf) + free(buf); + + + } /*H5T_STD_REF_OBJ*/ - if ((attr_out=H5Acreate(loc_out,name,ftype_id,space_id,H5P_DEFAULT))<0) - goto error; - if(H5Awrite(attr_out,mtype_id,buf)<0) - goto error; if (options->verbose) printf(" %-13s %s\n", "attr", name); @@ -495,9 +554,7 @@ int copy_attr(hid_t loc_in, if (H5Tclose(mtype_id)<0) goto error; if (H5Sclose(space_id)<0) goto error; if (H5Aclose(attr_id)<0) goto error; - if (H5Aclose(attr_out)<0) goto error; - if (buf) - free(buf); + } /* u */ return 0; @@ -514,3 +571,5 @@ error: } H5E_END_TRY; return -1; } + + diff --git a/tools/h5repack/h5repack_refs.c b/tools/h5repack/h5repack_refs.c new file mode 100644 index 0000000..cd5fe80 --- /dev/null +++ b/tools/h5repack/h5repack_refs.c @@ -0,0 +1,600 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + + +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include "H5private.h" +#include "h5repack.h" + + +/*------------------------------------------------------------------------- + * Function: do_copy_refobjs + * + * Purpose: duplicate all referenced HDF5 objects in the file + * + * Return: 0, ok, -1 no + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * + * Date: December, 10, 2003 + * + *------------------------------------------------------------------------- + */ + +int do_copy_refobjs(hid_t fidin, + hid_t fidout, + int nobjects, /* number of objects */ + trav_info_t *travi, /* array of object names */ + pack_opt_t *options) /* repack options */ +{ + hid_t grp_in; /* group ID */ + hid_t grp_out; /* group ID */ + hid_t dset_in; /* read dataset ID */ + hid_t dset_out; /* write dataset ID */ + hid_t type_in; /* named type ID */ + hid_t dcpl_id; /* dataset creation property list ID */ + hid_t space_id; /* space ID */ + hid_t ftype_id; /* file data type ID */ + hid_t mtype_id; /* memory data type ID */ + size_t msize; /* memory size of memory type */ + hsize_t nelmts; /* number of elements in dataset */ + int rank; /* rank of dataset */ + hsize_t dims[H5S_MAX_RANK];/* dimensions of dataset */ + int i, j; + + /* initialize to test for non reference cases */ + +/*------------------------------------------------------------------------- + * browse + *------------------------------------------------------------------------- + */ + + for ( i = 0; i < nobjects; i++) + { + + switch ( travi[i].type ) + { + /*------------------------------------------------------------------------- + * H5G_GROUP + *------------------------------------------------------------------------- + */ + case H5G_GROUP: + + if((grp_in = H5Gopen (fidin,travi[i].name))<0) + goto error; + + if (H5Gclose(grp_in)<0) + goto error; + + break; + + /*------------------------------------------------------------------------- + * H5G_DATASET + *------------------------------------------------------------------------- + */ + case H5G_DATASET: + + if ((dset_in=H5Dopen(fidin,travi[i].name))<0) + goto error; + if ((space_id=H5Dget_space(dset_in))<0) + goto error; + if ((ftype_id=H5Dget_type (dset_in))<0) + goto error; + if ((dcpl_id=H5Dget_create_plist(dset_in))<0) + goto error; + if ( (rank=H5Sget_simple_extent_ndims(space_id))<0) + goto error; + if ( H5Sget_simple_extent_dims(space_id,dims,NULL)<0) + goto error; + nelmts=1; + for (j=0; j<rank; j++) + nelmts*=dims[j]; + if ((mtype_id=H5Tget_native_type(ftype_id,H5T_DIR_DEFAULT))<0) + goto error; + if ((msize=H5Tget_size(mtype_id))==0) + goto error; + + +/*------------------------------------------------------------------------- + * object references are a special case + * we cannot just copy the buffers, but instead we recreate the reference + *------------------------------------------------------------------------- + */ + if (H5Tequal(mtype_id, H5T_STD_REF_OBJ)) + { + H5G_obj_t obj_type; + hid_t refobj_id; + hobj_ref_t *refbuf; + const char* refname; + hobj_ref_t *buf; + + /*------------------------------------------------------------------------- + * read to memory + *------------------------------------------------------------------------- + */ + + buf=(void *) HDmalloc((unsigned)(nelmts*msize)); + if ( buf==NULL){ + printf( "cannot read into memory\n" ); + goto error; + } + if (H5Dread(dset_in,mtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0) + goto error; + + + if ((obj_type = H5Rget_obj_type(dset_in,H5R_OBJECT,buf))<0) + goto error; + refbuf=HDmalloc((unsigned)nelmts*msize); + if ( refbuf==NULL){ + printf( "cannot allocate memory\n" ); + goto error; + } + for ( j=0; j<nelmts; j++) + { + if ((refobj_id = H5Rdereference(dset_in,H5R_OBJECT,&buf[j]))<0) + goto error; + + /* get the name. a valid name could only occur in the + second traversal of the file */ + if ((refname=MapIdToName(refobj_id,nobjects,travi,options))!=NULL) + { + /* create the reference */ + if (H5Rcreate(&refbuf[j],fidout,refname,H5R_OBJECT,-1)<0) + goto error; + + if (options->verbose) + printf("object <%s> reference created to <%s>\n",travi[i].name,refname); + } + close_obj(obj_type,refobj_id); + }/* j */ + + + + /*------------------------------------------------------------------------- + * create/write dataset/close + *------------------------------------------------------------------------- + */ + if ((dset_out=H5Dcreate(fidout,travi[i].name,ftype_id,space_id,dcpl_id))<0) + goto error; + if (H5Dwrite(dset_out,mtype_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,refbuf)<0) + goto error; + + free(buf); + free(refbuf); + + }/*H5T_STD_REF_OBJ*/ + + + /*------------------------------------------------------------------------- + * open previously created object in 1st traversal + *------------------------------------------------------------------------- + */ + + else + { + if ((dset_out=H5Dopen(fidout,travi[i].name))<0) + goto error; + } + + /*------------------------------------------------------------------------- + * copy referenced objects in attributes + *------------------------------------------------------------------------- + */ + + if (do_copy_refobjs_inattr(dset_in,dset_out,options,nobjects,travi,fidout)<0) + goto error; + + + /*------------------------------------------------------------------------- + * close + *------------------------------------------------------------------------- + */ + + if (H5Tclose(ftype_id)<0) + goto error; + if (H5Tclose(mtype_id)<0) + goto error; + if (H5Pclose(dcpl_id)<0) + goto error; + if (H5Sclose(space_id)<0) + goto error; + if (H5Dclose(dset_in)<0) + goto error; + if (H5Dclose(dset_out)<0) + goto error; + + + break; + + /*------------------------------------------------------------------------- + * H5G_TYPE + *------------------------------------------------------------------------- + */ + case H5G_TYPE: + + if ((type_in = H5Topen (fidin,travi[i].name))<0) + goto error; + + if (H5Tclose(type_in)<0) + goto error; + + + break; + + + /*------------------------------------------------------------------------- + * H5G_LINK + *------------------------------------------------------------------------- + */ + + case H5G_LINK: + + /*nothing to do */ + break; + + default: + + break; + } + } + + + +/*------------------------------------------------------------------------- + * the root is a special case, we get an ID for the root group + * and copy its attributes using that ID + * it must be done last, because the attributes might contain references to + * objects in the object list + *------------------------------------------------------------------------- + */ + + if ((grp_out = H5Gopen(fidout,"/"))<0) + goto error; + + if ((grp_in = H5Gopen(fidin,"/"))<0) + goto error; + + if (do_copy_refobjs_inattr(grp_in,grp_out,options,nobjects,travi,fidout)<0) + goto error; + + if (H5Gclose(grp_out)<0) + goto error; + if (H5Gclose(grp_in)<0) + goto error; + + return 0; + +error: + H5E_BEGIN_TRY { + H5Gclose(grp_in); + H5Gclose(grp_out); + H5Pclose(dcpl_id); + H5Sclose(space_id); + H5Dclose(dset_in); + H5Dclose(dset_out); + H5Tclose(ftype_id); + H5Tclose(mtype_id); + H5Tclose(type_in); + } H5E_END_TRY; + return -1; + +} + + +/*------------------------------------------------------------------------- + * Function: do_copy_refobjs_inattr + * + * Purpose: copy attributes located in LOC_IN, which is obtained either from + * loc_id = H5Gopen( fid, name); + * loc_id = H5Dopen( fid, name); + * loc_id = H5Topen( fid, name); + * + * Return: 0, ok, -1 no + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * + * Date: October, 28, 2003 + * + *------------------------------------------------------------------------- + */ + +int do_copy_refobjs_inattr(hid_t loc_in, + hid_t loc_out, + pack_opt_t *options, + int nobjects, /* number of objects */ + trav_info_t *travi, /* array of object names */ + hid_t fidout /* for saving references */ + ) +{ + hid_t attr_id; /* attr ID */ + hid_t attr_out; /* attr ID */ + hid_t space_id; /* space ID */ + hid_t ftype_id; /* file data type ID */ + hid_t mtype_id; /* memory data type ID */ + size_t msize; /* memory size of type */ + hsize_t nelmts; /* number of elements in dataset */ + int rank; /* rank of dataset */ + hsize_t dims[H5S_MAX_RANK];/* dimensions of dataset */ + char name[255]; + int n, j; + unsigned u; + + if ((n = H5Aget_num_attrs(loc_in))<0) + goto error; + + for ( u = 0; u < (unsigned)n; u++) + { + +/*------------------------------------------------------------------------- + * open + *------------------------------------------------------------------------- + */ + /* open attribute */ + if ((attr_id = H5Aopen_idx(loc_in, u))<0) + goto error; + + /* get name */ + if (H5Aget_name( attr_id, 255, name )<0) + goto error; + + /* get the file datatype */ + if ((ftype_id = H5Aget_type( attr_id )) < 0 ) + goto error; + + /* get the dataspace handle */ + if ((space_id = H5Aget_space( attr_id )) < 0 ) + goto error; + + /* get dimensions */ + if ( (rank = H5Sget_simple_extent_dims(space_id, dims, NULL)) < 0 ) + goto error; + + + /*------------------------------------------------------------------------- + * elements + *------------------------------------------------------------------------- + */ + nelmts=1; + for (j=0; j<rank; j++) + nelmts*=dims[j]; + if ((mtype_id=H5Tget_native_type(ftype_id,H5T_DIR_DEFAULT))<0) + goto error; + if ((msize=H5Tget_size(mtype_id))==0) + goto error; + + + +/*------------------------------------------------------------------------- + * object references are a special case + * we cannot just copy the buffers, but instead we recreate the reference + *------------------------------------------------------------------------- + */ + if (H5Tequal(mtype_id, H5T_STD_REF_OBJ)) + { + H5G_obj_t obj_type; + hid_t refobj_id; + hobj_ref_t *refbuf; + int i; + const char* refname; + hobj_ref_t *buf; + + + buf=(void *) HDmalloc((unsigned)(nelmts*msize)); + if ( buf==NULL){ + printf( "cannot read into memory\n" ); + goto error; + } + if (H5Aread(attr_id,mtype_id,buf)<0) + goto error; + + if ((obj_type = H5Rget_obj_type(attr_id,H5R_OBJECT,buf))<0) + goto error; + refbuf=HDmalloc((unsigned)nelmts*msize); + if ( refbuf==NULL){ + printf( "cannot allocate memory\n" ); + goto error; + } + for ( i=0; i<nelmts; i++) + { + if ((refobj_id = H5Rdereference(attr_id,H5R_OBJECT,&buf[i]))<0) + goto error; + + /* get the name. a valid name could only occur in the + second traversal of the file */ + if ((refname=MapIdToName(refobj_id,nobjects,travi,options))!=NULL) + { + /* create the reference */ + if (H5Rcreate(&refbuf[i],fidout,refname,H5R_OBJECT,-1)<0) + goto error; + + if (options->verbose) + printf("object <%s> reference created to <%s>\n",name,refname); + } + close_obj(obj_type,refobj_id); + }/* i */ + + + /*------------------------------------------------------------------------- + * copy + *------------------------------------------------------------------------- + */ + + if ((attr_out=H5Acreate(loc_out,name,ftype_id,space_id,H5P_DEFAULT))<0) + goto error; + if(H5Awrite(attr_out,mtype_id,refbuf)<0) + goto error; + + if (H5Aclose(attr_out)<0) + goto error; + + free(refbuf); + free(buf); + + }/*H5T_STD_REF_OBJ*/ + + +/*------------------------------------------------------------------------- + * close + *------------------------------------------------------------------------- + */ + + if (H5Tclose(ftype_id)<0) goto error; + if (H5Tclose(mtype_id)<0) goto error; + if (H5Sclose(space_id)<0) goto error; + if (H5Aclose(attr_id)<0) goto error; + } /* u */ + + return 0; + +error: + H5E_BEGIN_TRY { + H5Tclose(ftype_id); + H5Tclose(mtype_id); + H5Sclose(space_id); + H5Aclose(attr_id); + H5Aclose(attr_out); + } H5E_END_TRY; + return -1; +} + +/*------------------------------------------------------------------------- + * Function: close_obj + * + * Purpose: Auxiliary function to close an object + * + *------------------------------------------------------------------------- + */ + +static void close_obj(H5G_obj_t obj_type, hid_t obj_id) +{ + + switch (obj_type) { + case H5G_GROUP: + H5Gclose(obj_id); + break; + case H5G_DATASET: + H5Dclose(obj_id); + break; + case H5G_TYPE: + H5Tclose(obj_id); + break; + default: + assert(0); + break; + } +} + +/*------------------------------------------------------------------------- + * Function: MapIdToName + * + * Purpose: map an object ID to a name + * + *------------------------------------------------------------------------- + */ + +const char* MapIdToName(hid_t refobj_id, + int nobjects, /* number of objects */ + trav_info_t *travi, /* array of object names */ + pack_opt_t *options) /* repack options */ +{ + hid_t id; + hid_t fid; + int i; + + if ((fid = H5Iget_file_id(refobj_id))<0) + { + assert(0); + return NULL; + } + + + for ( i=0; i<nobjects; i++) + { + switch ( travi[i].type ) + { + + /*------------------------------------------------------------------------- + * H5G_GROUP + *------------------------------------------------------------------------- + */ + + case H5G_GROUP: + + + break; + + /*------------------------------------------------------------------------- + * H5G_DATASET + *------------------------------------------------------------------------- + */ + + case H5G_DATASET: + + if ((id = H5Dopen(fid,travi[i].name))<0) + { + assert(0); + return NULL; + } + + if (H5Dclose(id)<0) + { + assert(0); + return NULL; + } + + if (id==refobj_id) + { + H5Fclose(fid); + return travi[i].name; + } + + + break; + + /*------------------------------------------------------------------------- + * H5G_TYPE + *------------------------------------------------------------------------- + */ + + case H5G_TYPE: + + + + break; + + + /*------------------------------------------------------------------------- + * H5G_LINK + *------------------------------------------------------------------------- + */ + + case H5G_LINK: + break; + + default: + assert(0); + break; + + } + + + } /* i */ + + if (H5Fclose(fid)<0) + return NULL; + + return NULL; +} diff --git a/tools/h5repack/test_h5repack_add.c b/tools/h5repack/testh5repack_attr.c index 40a7af5..9862b80 100644 --- a/tools/h5repack/test_h5repack_add.c +++ b/tools/h5repack/testh5repack_attr.c @@ -16,190 +16,6 @@ #include "h5test.h" #include "h5repack.h" - -/*------------------------------------------------------------------------- - * Function: make_deflate - * - * Purpose: make a dataset using DEFLATE (GZIP) compression in FID - * - * Return: Success: zero - * Failure: 1 - * - * Programmer: Pedro Vicente <pvn@ncsa.uiuc.edu> - * September, 19, 2003 - * - *------------------------------------------------------------------------- - */ -static int -make_deflate(hid_t fid) -{ - hid_t dcpl; /* dataset creation property list */ - hid_t dsid; /* dataset ID */ - hid_t sid; /* dataspace ID */ - int rank=2; - hsize_t dims[2]={4,2}; - hsize_t chunk_dims[2]={2,1}; - int buf[4][2]={{1,2},{3,4},{5,6},{7,8}}; - - /* create a space */ - if((sid = H5Screate_simple(rank, dims, NULL))<0) - TEST_ERROR; - - /* create the dataset creation property list */ - if ((dcpl = H5Pcreate(H5P_DATASET_CREATE))<0) - TEST_ERROR; - - /* set up for deflated data */ - if(H5Pset_chunk(dcpl, rank, chunk_dims)<0) - TEST_ERROR; - if(H5Pset_deflate(dcpl, 9)<0) - TEST_ERROR; - - /* create the dataset */ - if((dsid = H5Dcreate (fid, "dset_gzip", H5T_NATIVE_INT, sid, dcpl))<0) - TEST_ERROR; - - /* write the data to the dataset */ - if(H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf)<0) - TEST_ERROR; - - /* close */ - if(H5Dclose(dsid)<0) - TEST_ERROR; - if(H5Pclose(dcpl)<0) - TEST_ERROR; - if(H5Sclose(sid)<0) - TEST_ERROR; - - return 0; - -error: - return 1; -} - -/*------------------------------------------------------------------------- - * Function: make_szip - * - * Purpose: make a dataset using SZIP compression in FID - * - * Return: Success: zero - * Failure: 1 - * - * Programmer: Pedro Vicente <pvn@ncsa.uiuc.edu> - * September, 19, 2003 - * - *------------------------------------------------------------------------- - */ -static int -make_szip(hid_t fid) -{ - hid_t dcpl; /* dataset creation property list */ - hid_t dsid; /* dataset ID */ - hid_t sid; /* dataspace ID */ - int rank=2; - hsize_t dims[2]={4,2}; - hsize_t chunk_dims[2]={2,1}; - int buf[4][2]={{1,2},{3,4},{5,6},{7,8}}; - unsigned szip_options_mask=H5_SZIP_ALLOW_K13_OPTION_MASK|H5_SZIP_NN_OPTION_MASK; - unsigned szip_pixels_per_block; - - /* - pixels_per_block must be an even number, and <= pixels_per_scanline - and <= MAX_PIXELS_PER_BLOCK - */ - szip_pixels_per_block=16; - - /* create a space */ - if((sid = H5Screate_simple(rank, dims, NULL))<0) - TEST_ERROR; - - /* create the dataset creation property list */ - if ((dcpl = H5Pcreate(H5P_DATASET_CREATE))<0) - TEST_ERROR; - - /* set up for sziped data */ - if(H5Pset_chunk(dcpl, rank, chunk_dims)<0) - TEST_ERROR; - if(H5Pset_szip (dcpl, szip_options_mask, szip_pixels_per_block)<0) - TEST_ERROR; - - /* create the dataset */ - if((dsid = H5Dcreate (fid, "dset_szip", H5T_NATIVE_INT, sid, dcpl))<0) - TEST_ERROR; - - /* write the data to the dataset */ - if(H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf)<0) - TEST_ERROR; - - /* close */ - if(H5Dclose(dsid)<0) - TEST_ERROR; - if(H5Pclose(dcpl)<0) - TEST_ERROR; - if(H5Sclose(sid)<0) - TEST_ERROR; - - return 0; - -error: - return 1; -} - - -/*------------------------------------------------------------------------- - * Function: make_testfile - * - * Purpose: make a test file with all types of HDF5 objects, - * datatypes and filters - * - * Return: Success: zero - * Failure: 1 - * - * Programmer: Pedro Vicente <pvn@ncsa.uiuc.edu> - * September, 19, 2003 - * - *------------------------------------------------------------------------- - */ -int make_testfiles(void) -{ - hid_t fid; /* file ID */ - int nerrors=0; - - TESTING(" generating datasets"); - - /* create a file for the copy test */ - if((fid = H5Fcreate(FNAME1,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT))<0) - TEST_ERROR; - - nerrors += make_all_objects(fid); - - /* close */ - if(H5Fclose(fid)<0) - TEST_ERROR; - - /* create a file for the filters test */ - if((fid = H5Fcreate(FNAME2,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT))<0) - TEST_ERROR; - - nerrors += make_deflate(fid); - nerrors += make_szip(fid); - - /* close */ - if(H5Fclose(fid)<0) - TEST_ERROR; - - if (nerrors) - goto error; - - PASSED(); - return 0; - -error: - return 1; -} - - - /*------------------------------------------------------------------------- * Function: write_attr_in * @@ -1213,77 +1029,6 @@ etc -/*------------------------------------------------------------------------- - * Check all HDF5 classes - * H5T_INTEGER, H5T_FLOAT - * H5T_TIME, H5T_STRING, H5T_BITFIELD, H5T_OPAQUE, H5T_COMPOUND, H5T_REFERENCE, - * H5T_ENUM, H5T_VLEN, H5T_ARRAY - *------------------------------------------------------------------------- - */ - - -int make_attr(hid_t fid) -{ - hid_t dset_id; - hid_t group_id; - hid_t root_id; - hid_t space_id; - hsize_t dims[1]={2}; - - /* Create a 1D dataset */ - space_id = H5Screate_simple(1,dims,NULL); - dset_id = H5Dcreate(fid,"dset_ref",H5T_NATIVE_INT,space_id,H5P_DEFAULT); - H5Sclose(space_id); - - /* Create groups */ - group_id = H5Gcreate(fid,"g1",0); - root_id = H5Gopen(fid, "/"); - -/*------------------------------------------------------------------------- - * write a series of attributes on the dataset, group, and root group - *------------------------------------------------------------------------- - */ - - write_attr_in(dset_id,"dset_ref",fid,0); - write_attr_in(group_id,"dset_ref",fid,0); - write_attr_in(root_id,"dset_ref",fid,0); - - - /* Close */ - H5Dclose(dset_id); - H5Gclose(group_id); - H5Gclose(root_id); - - return 0; -} - - -/*------------------------------------------------------------------------- - * Function: make_all_objects - * - * Purpose: make a test file with all types of HDF5 objects, datatypes - * - * Return: Success: zero - * Failure: 1 - * - * Programmer: Pedro Vicente <pvn@ncsa.uiuc.edu> - * September, 19, 2003 - * - *------------------------------------------------------------------------- - */ -int make_all_objects(hid_t fid) -{ - - - /* create attributes */ - if((make_attr(fid))<0) - TEST_ERROR; - - return 0; - -error: - return 1; -} @@ -1327,48 +1072,3 @@ int write_attr(hid_t loc_id, return status; } -/*------------------------------------------------------------------------- - * Function: write_dset - * - * Purpose: utility function to create and write a dataset in LOC_ID - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: November 12, 2003 - * - *------------------------------------------------------------------------- - */ - - -int write_dset( hid_t loc_id, - int rank, - hsize_t *dims, - const char *dset_name, - hid_t type_id, - void *buf ) -{ - hid_t dset_id; - hid_t space_id; - herr_t status; - - /* Create a buf space */ - space_id = H5Screate_simple(rank,dims,NULL); - - /* Create a dataset */ - dset_id = H5Dcreate(loc_id,dset_name,type_id,space_id,H5P_DEFAULT); - - /* Write the buf */ - if ( buf ) - status = H5Dwrite(dset_id,type_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf); - - /* Close */ - status = H5Dclose(dset_id); - status = H5Sclose(space_id); - - return status; - -} - - - - diff --git a/tools/h5repack/testh5repack_dset.c b/tools/h5repack/testh5repack_dset.c new file mode 100644 index 0000000..e5fe500 --- /dev/null +++ b/tools/h5repack/testh5repack_dset.c @@ -0,0 +1,668 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include "hdf5.h" +#include "h5test.h" +#include "h5repack.h" + +/*------------------------------------------------------------------------- + * Function: write_dset + * + * Purpose: utility function to create and write a dataset in LOC_ID + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * + * Date: November 12, 2003 + * + *------------------------------------------------------------------------- + */ + +int write_dset( hid_t loc_id, + int rank, + hsize_t *dims, + const char *dset_name, + hid_t type_id, + void *buf ) +{ + hid_t dset_id; + hid_t space_id; + + /* Create a buf space */ + if ((space_id = H5Screate_simple(rank,dims,NULL))<0) + return -1; + + /* Create a dataset */ + if ((dset_id = H5Dcreate(loc_id,dset_name,type_id,space_id,H5P_DEFAULT))<0) + return -1; + + /* Write the buf */ + if ( buf ) + if (H5Dwrite(dset_id,type_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf)<0) + return -1; + + /* Close */ + if (H5Dclose(dset_id)<0) + return -1; + if (H5Sclose(space_id)<0) + return -1; + + return 0; + +} + + +/*------------------------------------------------------------------------- + * Function: write_dset_in + * + * Purpose: write datasets in LOC_ID + * + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * + * Date: November 12, 2003 + * + *------------------------------------------------------------------------- + */ + + +void write_dset_in(hid_t loc_id, + const char* dset_name, /* for saving reference to dataset*/ + hid_t file_id, + int make_diffs /* flag to modify data buffers */) +{ + /* Compound datatype */ + typedef struct s_t + { + char a; + double b; + } s_t; + + typedef enum + { + RED, + GREEN + } e_t; + + hid_t dset_id; + hid_t space_id; + hid_t type_id; + hid_t plist_id; + herr_t status; + int val, i, j, k, n; + float f; + int fillvalue=2; + + /* create 1D attributes with dimension [2], 2 elements */ + hsize_t dims[1]={2}; + char buf1[2][2]= {"ab","de"}; /* string */ + char buf2[2]= {1,2}; /* bitfield, opaque */ + s_t buf3[2]= {{1,2},{3,4}}; /* compound */ + hobj_ref_t buf4[2]; /* reference */ + e_t buf45[2]= {RED,GREEN}; /* enum */ + hvl_t buf5[2]; /* vlen */ + hsize_t dimarray[1]={3}; /* array dimension */ + int buf6[2][3]= {{1,2,3},{4,5,6}}; /* array */ + int buf7[2]= {1,2}; /* integer */ + float buf8[2]= {1,2}; /* float */ + + /* create 2D attributes with dimension [3][2], 6 elements */ + hsize_t dims2[2]={3,2}; + char buf12[6][2]= {"ab","cd","ef","gh","ij","kl"}; /* string */ + char buf22[3][2]= {{1,2},{3,4},{5,6}}; /* bitfield, opaque */ + s_t buf32[6]= {{1,2},{3,4},{5,6},{7,8},{9,10},{11,12}}; /* compound */ + hobj_ref_t buf42[3][2]; /* reference */ + e_t buf452[3][2]; /* enum */ + hvl_t buf52[3][2]; /* vlen */ + int buf62[6][3]= {{1,2,3},{4,5,6},{7,8,9},{10,11,12},{13,14,15},{16,17,18}}; /* array */ + int buf72[3][2]= {{1,2},{3,4},{5,6}}; /* integer */ + float buf82[3][2]= {{1,2},{3,4},{5,6}}; /* float */ + + /* create 3D attributes with dimension [4][3][2], 24 elements */ + hsize_t dims3[3]={4,3,2}; + char buf13[24][2]= {"ab","cd","ef","gh","ij","kl","mn","pq", + "rs","tu","vw","xz","AB","CD","EF","GH", + "IJ","KL","MN","PQ","RS","TU","VW","XZ"}; /* string */ + char buf23[4][3][2]; /* bitfield, opaque */ + s_t buf33[4][3][2]; /* compound */ + hobj_ref_t buf43[4][3][2]; /* reference */ + e_t buf453[4][3][2]; /* enum */ + hvl_t buf53[4][3][2]; /* vlen */ + int buf63[24][3]; /* array */ + int buf73[4][3][2]; /* integer */ + float buf83[4][3][2]; /* float */ + + +/*------------------------------------------------------------------------- + * 1D + *------------------------------------------------------------------------- + */ + +/*------------------------------------------------------------------------- + * H5T_STRING + *------------------------------------------------------------------------- + */ + + + if (make_diffs) + { + for (i=0; i<2; i++) + for (j=0; j<2; j++) + { + buf1[i][j]='z'; + } + } + + + type_id = H5Tcopy(H5T_C_S1); + status = H5Tset_size(type_id, 2); + write_dset(loc_id,1,dims,"string",type_id,buf1); + status = H5Tclose(type_id); + +/*------------------------------------------------------------------------- + * H5T_BITFIELD + *------------------------------------------------------------------------- + */ + + if (make_diffs) + { + for (i=0; i<2; i++) + buf2[i]=buf2[1]=0; + } + + type_id = H5Tcopy(H5T_STD_B8LE); + write_dset(loc_id,1,dims,"bitfield",type_id,buf2); + status = H5Tclose(type_id); + +/*------------------------------------------------------------------------- + * H5T_OPAQUE + *------------------------------------------------------------------------- + */ + + if (make_diffs) + { + for (i=0; i<2; i++) + { + buf3[i].a=0; buf3[i].b=0; + } + } + + type_id = H5Tcreate(H5T_OPAQUE, 1); + status = H5Tset_tag(type_id, "1-byte opaque type"); /* must set this */ + write_dset(loc_id,1,dims,"opaque",type_id,buf2); + status = H5Tclose(type_id); + +/*------------------------------------------------------------------------- + * H5T_COMPOUND + *------------------------------------------------------------------------- + */ + + + if (make_diffs) + { + for (i=0; i<2; i++) + { + buf45[i]=GREEN; + } + } + + type_id = H5Tcreate (H5T_COMPOUND, sizeof(s_t)); + H5Tinsert(type_id, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR); + H5Tinsert(type_id, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE); + write_dset(loc_id,1,dims,"compound",type_id,buf3); + status = H5Tclose(type_id); + +/*------------------------------------------------------------------------- + * H5T_REFERENCE + *------------------------------------------------------------------------- + */ + /* Create references to dataset */ + if (dset_name) + { + status=H5Rcreate(&buf4[0],file_id,dset_name,H5R_OBJECT,-1); + status=H5Rcreate(&buf4[1],file_id,dset_name,H5R_OBJECT,-1); + write_dset(loc_id,1,dims,"reference",H5T_STD_REF_OBJ,buf4); + } + +/*------------------------------------------------------------------------- + * H5T_ENUM + *------------------------------------------------------------------------- + */ + type_id = H5Tcreate(H5T_ENUM, sizeof(e_t)); + H5Tenum_insert(type_id, "RED", (val = 0, &val)); + H5Tenum_insert(type_id, "GREEN", (val = 1, &val)); + write_dset(loc_id,1,dims,"enum",type_id,buf45); + status = H5Tclose(type_id); + +/*------------------------------------------------------------------------- + * H5T_VLEN + *------------------------------------------------------------------------- + */ + + /* Allocate and initialize VL dataset to write */ + + buf5[0].len = 1; + buf5[0].p = malloc( 1 * sizeof(int)); + ((int *)buf5[0].p)[0]=1; + buf5[1].len = 2; + buf5[1].p = malloc( 2 * sizeof(int)); + ((int *)buf5[1].p)[0]=2; + ((int *)buf5[1].p)[1]=3; + + if (make_diffs) + { + ((int *)buf5[0].p)[0]=0; + ((int *)buf5[1].p)[0]=0; + ((int *)buf5[1].p)[1]=0; + } + + space_id = H5Screate_simple(1,dims,NULL); + type_id = H5Tvlen_create(H5T_NATIVE_INT); + dset_id = H5Dcreate(loc_id,"vlen",type_id,space_id,H5P_DEFAULT); + status = H5Dwrite(dset_id,type_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf5); + assert(status>=0); + status = H5Dvlen_reclaim(type_id,space_id,H5P_DEFAULT,buf5); + assert(status>=0); + status = H5Dclose(dset_id); + status = H5Tclose(type_id); + status = H5Sclose(space_id); + +/*------------------------------------------------------------------------- + * H5T_ARRAY + *------------------------------------------------------------------------- + */ + + if (make_diffs) + { + for (i=0; i<2; i++) + for (j=0; j<3; j++) + { + buf6[i][j]=0; + } + } + + type_id = H5Tarray_create(H5T_NATIVE_INT,1,dimarray,NULL); + write_dset(loc_id,1,dims,"array",type_id,buf6); + status = H5Tclose(type_id); + +/*------------------------------------------------------------------------- + * H5T_INTEGER and H5T_FLOAT + *------------------------------------------------------------------------- + */ + + if (make_diffs) + { + for (i=0; i<2; i++) + { + buf7[i]=0; + buf8[i]=0; + } + } + + write_dset(loc_id,1,dims,"integer",H5T_NATIVE_INT,buf7); + write_dset(loc_id,1,dims,"float",H5T_NATIVE_FLOAT,buf8); + + +/*------------------------------------------------------------------------- + * 2D + *------------------------------------------------------------------------- + */ + +/*------------------------------------------------------------------------- + * H5T_STRING + *------------------------------------------------------------------------- + */ + + if (make_diffs) + { + memset(buf12, 'z', sizeof buf12); + } + + + type_id = H5Tcopy(H5T_C_S1); + status = H5Tset_size(type_id, 2); + write_dset(loc_id,2,dims2,"string2D",type_id,buf12); + status = H5Tclose(type_id); + +/*------------------------------------------------------------------------- + * H5T_BITFIELD + *------------------------------------------------------------------------- + */ + + + if (make_diffs) + { + memset(buf22,0,sizeof buf22); + } + + type_id = H5Tcopy(H5T_STD_B8LE); + write_dset(loc_id,2,dims2,"bitfield2D",type_id,buf22); + status = H5Tclose(type_id); + +/*------------------------------------------------------------------------- + * H5T_OPAQUE + *------------------------------------------------------------------------- + */ + type_id = H5Tcreate(H5T_OPAQUE, 1); + status = H5Tset_tag(type_id, "1-byte opaque type"); /* must set this */ + write_dset(loc_id,2,dims2,"opaque2D",type_id,buf22); + status = H5Tclose(type_id); + +/*------------------------------------------------------------------------- + * H5T_COMPOUND + *------------------------------------------------------------------------- + */ + + if (make_diffs) + { + memset(buf32,0,sizeof buf32); + } + + type_id = H5Tcreate (H5T_COMPOUND, sizeof(s_t)); + H5Tinsert(type_id, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR); + H5Tinsert(type_id, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE); + write_dset(loc_id,2,dims2,"compound2D",type_id,buf32); + status = H5Tclose(type_id); + +/*------------------------------------------------------------------------- + * H5T_REFERENCE + *------------------------------------------------------------------------- + */ + /* Create references to dataset */ + if (dset_name) + { + for (i = 0; i < 3; i++) { + for (j = 0; j < 2; j++) { + status=H5Rcreate(&buf42[i][j],file_id,dset_name,H5R_OBJECT,-1); + } + } + write_dset(loc_id,2,dims2,"reference2D",H5T_STD_REF_OBJ,buf42); + } + +/*------------------------------------------------------------------------- + * H5T_ENUM + *------------------------------------------------------------------------- + */ + + for (i=0; i<3; i++) + for (j=0; j<2; j++) + { + if (make_diffs) buf452[i][j]=GREEN; else buf452[i][j]=RED; + } + + + type_id = H5Tcreate(H5T_ENUM, sizeof(e_t)); + H5Tenum_insert(type_id, "RED", (val = 0, &val)); + H5Tenum_insert(type_id, "GREEN", (val = 1, &val)); + write_dset(loc_id,2,dims2,"enum2D",type_id,0); + status = H5Tclose(type_id); + +/*------------------------------------------------------------------------- + * H5T_VLEN + *------------------------------------------------------------------------- + */ + +/* Allocate and initialize VL dataset to write */ + n=0; + for (i = 0; i < 3; i++) { + for (j = 0; j < 2; j++) { + int l; + buf52[i][j].p = malloc((i + 1) * sizeof(int)); + buf52[i][j].len = i + 1; + for (l = 0; l < i + 1; l++) + if (make_diffs)((int *)buf52[i][j].p)[l] = 0; + else ((int *)buf52[i][j].p)[l] = n++; + } + } + + space_id = H5Screate_simple(2,dims2,NULL); + type_id = H5Tvlen_create(H5T_NATIVE_INT); + dset_id = H5Dcreate(loc_id,"vlen2D",type_id,space_id,H5P_DEFAULT); + status = H5Dwrite(dset_id,type_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf52); + assert(status>=0); + status = H5Dvlen_reclaim(type_id,space_id,H5P_DEFAULT,buf52); + assert(status>=0); + status = H5Dclose(dset_id); + status = H5Tclose(type_id); + status = H5Sclose(space_id); + +/*------------------------------------------------------------------------- + * H5T_ARRAY + *------------------------------------------------------------------------- + */ + + if (make_diffs) + { + memset(buf62,0,sizeof buf62); + } + + + type_id = H5Tarray_create(H5T_NATIVE_INT,1,dimarray,NULL); + write_dset(loc_id,2,dims2,"array2D",type_id,buf62); + status = H5Tclose(type_id); + +/*------------------------------------------------------------------------- + * H5T_INTEGER, write a fill value + *------------------------------------------------------------------------- + */ + + + if (make_diffs) + { + memset(buf72,0,sizeof buf72); + memset(buf82,0,sizeof buf82); + } + + + plist_id = H5Pcreate(H5P_DATASET_CREATE); + status = H5Pset_fill_value(plist_id, H5T_NATIVE_INT, &fillvalue); + space_id = H5Screate_simple(2,dims2,NULL); + dset_id = H5Dcreate(loc_id,"integer2D",H5T_NATIVE_INT,space_id,plist_id); + status = H5Dwrite(dset_id,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf72); + status = H5Pclose(plist_id); + status = H5Dclose(dset_id); + status = H5Sclose(space_id); + +/*------------------------------------------------------------------------- + * H5T_FLOAT + *------------------------------------------------------------------------- + */ + + write_dset(loc_id,2,dims2,"float2D",H5T_NATIVE_FLOAT,buf82); + + +/*------------------------------------------------------------------------- + * 3D + *------------------------------------------------------------------------- + */ + +/*------------------------------------------------------------------------- + * H5T_STRING + *------------------------------------------------------------------------- + */ + + if (make_diffs) + { + memset(buf13,'z',sizeof buf13); + } + + type_id = H5Tcopy(H5T_C_S1); + status = H5Tset_size(type_id, 2); + write_dset(loc_id,3,dims3,"string3D",type_id,buf13); + status = H5Tclose(type_id); + +/*------------------------------------------------------------------------- + * H5T_BITFIELD + *------------------------------------------------------------------------- + */ + + + n=1; + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 2; k++) { + if (make_diffs) buf23[i][j][k]=0; + else buf23[i][j][k]=n++; + } + } + } + + + type_id = H5Tcopy(H5T_STD_B8LE); + write_dset(loc_id,3,dims3,"bitfield3D",type_id,buf23); + status = H5Tclose(type_id); + +/*------------------------------------------------------------------------- + * H5T_OPAQUE + *------------------------------------------------------------------------- + */ + type_id = H5Tcreate(H5T_OPAQUE, 1); + status = H5Tset_tag(type_id, "1-byte opaque type"); /* must set this */ + write_dset(loc_id,3,dims3,"opaque3D",type_id,buf23); + status = H5Tclose(type_id); + +/*------------------------------------------------------------------------- + * H5T_COMPOUND + *------------------------------------------------------------------------- + */ + + n=1; + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 2; k++) { + if (make_diffs) { + buf33[i][j][k].a=0; + buf33[i][j][k].b=0; + } + else { + buf33[i][j][k].a=n++; + buf33[i][j][k].b=n++; + } + } + } + } + + + type_id = H5Tcreate (H5T_COMPOUND, sizeof(s_t)); + H5Tinsert(type_id, "a", HOFFSET(s_t, a), H5T_NATIVE_CHAR); + H5Tinsert(type_id, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE); + write_dset(loc_id,3,dims3,"compound3D",type_id,buf33); + status = H5Tclose(type_id); + +/*------------------------------------------------------------------------- + * H5T_REFERENCE + *------------------------------------------------------------------------- + */ + /* Create references to dataset */ + if (dset_name) + { + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 2; k++) + status=H5Rcreate(&buf43[i][j][k],file_id,dset_name,H5R_OBJECT,-1); + } + } + write_dset(loc_id,3,dims3,"reference3D",H5T_STD_REF_OBJ,buf43); + } + +/*------------------------------------------------------------------------- + * H5T_ENUM + *------------------------------------------------------------------------- + */ + + + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 2; k++) { + if (make_diffs) buf453[i][j][k]=RED; else buf453[i][j][k]=GREEN; + } + } + } + + type_id = H5Tcreate(H5T_ENUM, sizeof(e_t)); + H5Tenum_insert(type_id, "RED", (val = 0, &val)); + H5Tenum_insert(type_id, "GREEN", (val = 1, &val)); + write_dset(loc_id,3,dims3,"enum3D",type_id,0); + status = H5Tclose(type_id); + +/*------------------------------------------------------------------------- + * H5T_VLEN + *------------------------------------------------------------------------- + */ + + /* Allocate and initialize VL dataset to write */ + n=0; + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 2; k++) { + int l; + buf53[i][j][k].p = malloc((i + 1) * sizeof(int)); + buf53[i][j][k].len = i + 1; + for (l = 0; l < i + 1; l++) + if (make_diffs)((int *)buf53[i][j][k].p)[l] = 0; + else ((int *)buf53[i][j][k].p)[l] = n++; + } + } + } + + space_id = H5Screate_simple(3,dims3,NULL); + type_id = H5Tvlen_create(H5T_NATIVE_INT); + dset_id = H5Dcreate(loc_id,"vlen3D",type_id,space_id,H5P_DEFAULT); + status = H5Dwrite(dset_id,type_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,buf53); + assert(status>=0); + status = H5Dvlen_reclaim(type_id,space_id,H5P_DEFAULT,buf53); + assert(status>=0); + status = H5Dclose(dset_id); + status = H5Tclose(type_id); + status = H5Sclose(space_id); + +/*------------------------------------------------------------------------- + * H5T_ARRAY + *------------------------------------------------------------------------- + */ + + + n=1; + for (i = 0; i < 24; i++) { + for (j = 0; j < (int)dimarray[0]; j++) { + if (make_diffs) buf63[i][j]=0; + else buf63[i][j]=n++; + } + } + + type_id = H5Tarray_create(H5T_NATIVE_INT,1,dimarray,NULL); + write_dset(loc_id,3,dims3,"array3D",type_id,buf63); + status = H5Tclose(type_id); + +/*------------------------------------------------------------------------- + * H5T_INTEGER and H5T_FLOAT + *------------------------------------------------------------------------- + */ + n=1; f=1; + for (i = 0; i < 4; i++) { + for (j = 0; j < 3; j++) { + for (k = 0; k < 2; k++) { + if (make_diffs) { + buf73[i][j][k]=0; + buf83[i][j][k]=0; + } + else { + buf73[i][j][k]=n++; + buf83[i][j][k]=f++; + } + } + } + } + write_dset(loc_id,3,dims3,"integer3D",H5T_NATIVE_INT,buf73); + write_dset(loc_id,3,dims3,"float3D",H5T_NATIVE_FLOAT,buf83); +} + diff --git a/tools/h5repack/testh5repack_filters.c b/tools/h5repack/testh5repack_filters.c new file mode 100644 index 0000000..36abc06 --- /dev/null +++ b/tools/h5repack/testh5repack_filters.c @@ -0,0 +1,295 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include "hdf5.h" +#include "h5test.h" +#include "h5repack.h" + + +/*------------------------------------------------------------------------- + * Function: make_deflate + * + * Purpose: make a dataset using DEFLATE (GZIP) compression in FID + * + * Return: Success: zero + * Failure: 1 + * + * Programmer: Pedro Vicente <pvn@ncsa.uiuc.edu> + * September, 19, 2003 + * + *------------------------------------------------------------------------- + */ +static int +make_deflate(hid_t fid) +{ + hid_t dcpl; /* dataset creation property list */ + hid_t dsid; /* dataset ID */ + hid_t sid; /* dataspace ID */ + int rank=2; + hsize_t dims[2]={4,2}; + hsize_t chunk_dims[2]={2,1}; + int buf[4][2]={{1,2},{3,4},{5,6},{7,8}}; + + /* create a space */ + if((sid = H5Screate_simple(rank, dims, NULL))<0) + TEST_ERROR; + + /* create the dataset creation property list */ + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE))<0) + TEST_ERROR; + + /* set up for deflated data */ + if(H5Pset_chunk(dcpl, rank, chunk_dims)<0) + TEST_ERROR; + if(H5Pset_deflate(dcpl, 9)<0) + TEST_ERROR; + + /* create the dataset */ + if((dsid = H5Dcreate (fid, "dset_gzip", H5T_NATIVE_INT, sid, dcpl))<0) + TEST_ERROR; + + /* write the data to the dataset */ + if(H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf)<0) + TEST_ERROR; + + /* close */ + if(H5Dclose(dsid)<0) + TEST_ERROR; + if(H5Pclose(dcpl)<0) + TEST_ERROR; + if(H5Sclose(sid)<0) + TEST_ERROR; + + return 0; + +error: + return 1; +} + +/*------------------------------------------------------------------------- + * Function: make_szip + * + * Purpose: make a dataset using SZIP compression in FID + * + * Return: Success: zero + * Failure: 1 + * + * Programmer: Pedro Vicente <pvn@ncsa.uiuc.edu> + * September, 19, 2003 + * + *------------------------------------------------------------------------- + */ +static int +make_szip(hid_t fid) +{ + hid_t dcpl; /* dataset creation property list */ + hid_t dsid; /* dataset ID */ + hid_t sid; /* dataspace ID */ + int rank=2; + hsize_t dims[2]={4,2}; + hsize_t chunk_dims[2]={2,1}; + int buf[4][2]={{1,2},{3,4},{5,6},{7,8}}; + unsigned szip_options_mask=H5_SZIP_ALLOW_K13_OPTION_MASK|H5_SZIP_NN_OPTION_MASK; + unsigned szip_pixels_per_block; + + /* + pixels_per_block must be an even number, and <= pixels_per_scanline + and <= MAX_PIXELS_PER_BLOCK + */ + szip_pixels_per_block=16; + + /* create a space */ + if((sid = H5Screate_simple(rank, dims, NULL))<0) + TEST_ERROR; + + /* create the dataset creation property list */ + if ((dcpl = H5Pcreate(H5P_DATASET_CREATE))<0) + TEST_ERROR; + + /* set up for sziped data */ + if(H5Pset_chunk(dcpl, rank, chunk_dims)<0) + TEST_ERROR; + if(H5Pset_szip (dcpl, szip_options_mask, szip_pixels_per_block)<0) + TEST_ERROR; + + /* create the dataset */ + if((dsid = H5Dcreate (fid, "dset_szip", H5T_NATIVE_INT, sid, dcpl))<0) + TEST_ERROR; + + /* write the data to the dataset */ + if(H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf)<0) + TEST_ERROR; + + /* close */ + if(H5Dclose(dsid)<0) + TEST_ERROR; + if(H5Pclose(dcpl)<0) + TEST_ERROR; + if(H5Sclose(sid)<0) + TEST_ERROR; + + return 0; + +error: + return 1; +} + + +/*------------------------------------------------------------------------- + * Function: make_testfiles + * + * Purpose: make a test file with all types of HDF5 objects, + * datatypes and filters + * + * Return: Success: zero + * Failure: 1 + * + * Programmer: Pedro Vicente <pvn@ncsa.uiuc.edu> + * September, 19, 2003 + * + *------------------------------------------------------------------------- + */ +int make_testfiles(void) +{ + hid_t fid; /* file ID */ + int nerrors=0; + + TESTING(" generating datasets"); + + /* create a file for the copy test */ + if((fid = H5Fcreate(FNAME1,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT))<0) + TEST_ERROR; + + nerrors += make_all_objects(fid); + + /* close */ + if(H5Fclose(fid)<0) + TEST_ERROR; + + /* create a file for the filters test */ + if((fid = H5Fcreate(FNAME2,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT))<0) + TEST_ERROR; + + nerrors += make_deflate(fid); + nerrors += make_szip(fid); + + /* close */ + if(H5Fclose(fid)<0) + TEST_ERROR; + + if (nerrors) + goto error; + + PASSED(); + return 0; + +error: + return 1; +} + + + + + +/*------------------------------------------------------------------------- + * Function: make_all_objects + * + * Purpose: make a test file with all types of HDF5 objects, datatypes + * + * Return: Success: zero + * Failure: 1 + * + * Programmer: Pedro Vicente <pvn@ncsa.uiuc.edu> + * September, 19, 2003 + * + *------------------------------------------------------------------------- + */ +int make_all_objects(hid_t fid) +{ + hid_t dset_id; + hid_t group_id; + hid_t type_id; + hid_t root_id; + hid_t space_id; + hsize_t dims[1]={2}; + /* Compound datatype */ + typedef struct s_t + { + int a; + float b; + } s_t; + +/*------------------------------------------------------------------------- + * H5G_DATASET + *------------------------------------------------------------------------- + */ + + space_id = H5Screate_simple(1,dims,NULL); + dset_id = H5Dcreate(fid,"dset_ref",H5T_NATIVE_INT,space_id,H5P_DEFAULT); + H5Sclose(space_id); + +/*------------------------------------------------------------------------- + * H5G_GROUP + *------------------------------------------------------------------------- + */ + group_id = H5Gcreate(fid,"g1",0); + root_id = H5Gopen(fid, "/"); + +/*------------------------------------------------------------------------- + * H5G_TYPE + *------------------------------------------------------------------------- + */ + + /* Create a memory compound datatype */ + type_id = H5Tcreate (H5T_COMPOUND, sizeof(s_t)); + H5Tinsert(type_id, "a", HOFFSET(s_t, a), H5T_NATIVE_INT); + H5Tinsert(type_id, "b", HOFFSET(s_t, b), H5T_NATIVE_FLOAT); + /* Commit compound datatype and close it */ + H5Tcommit(fid, "type", type_id); + H5Tclose(type_id); + +/*------------------------------------------------------------------------- + * H5G_LINK + *------------------------------------------------------------------------- + */ + + H5Glink(fid, H5G_LINK_SOFT, "dset", "link"); + +/*------------------------------------------------------------------------- + * write a series of attributes on the dataset, group, and root group + *------------------------------------------------------------------------- + */ + + write_attr_in(dset_id,"dset_ref",fid,0); + write_attr_in(group_id,"dset_ref",fid,0); + write_attr_in(root_id,"dset_ref",fid,0); + +/*------------------------------------------------------------------------- + * write a series of datasetes on the group, and root group + *------------------------------------------------------------------------- + */ + + write_dset_in(root_id,"dset_ref",fid,0); + write_dset_in(group_id,"dset_ref",fid,0); + + + /* Close */ + H5Dclose(dset_id); + H5Gclose(group_id); + H5Gclose(root_id); + + return 0; + +} + diff --git a/tools/h5repack/test_h5repack_main.c b/tools/h5repack/testh5repack_main.c index 5bfed95..0acd632 100644 --- a/tools/h5repack/test_h5repack_main.c +++ b/tools/h5repack/testh5repack_main.c @@ -112,10 +112,6 @@ error: } - - - - /*------------------------------------------------------------------------- * Function: main * |