mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-11-27 07:30:33 +08:00
removing HDF5 type info from libsrc4
This commit is contained in:
parent
9aedbd0c41
commit
ab963e3d41
@ -195,7 +195,7 @@ typedef struct NC_TYPE_INFO
|
||||
NC_OBJ hdr; /* NetCDF type ID. */
|
||||
struct NC_GRP_INFO *container; /* Containing group */
|
||||
unsigned rc; /* Ref. count of objects using this type */
|
||||
hid_t hdf_typeid; /* HDF5 type ID, in the file */
|
||||
/* hid_t hdf_typeid; /\* HDF5 type ID, in the file *\/ */
|
||||
/* hid_t native_hdf_typeid; /\* HDF5 type ID, in memory *\/ */
|
||||
int endianness; /* What endianness for the type? */
|
||||
size_t size; /* Size of the type in memory, in bytes */
|
||||
|
@ -634,9 +634,8 @@ nc4_rec_grp_HDF5_del(NC_GRP_INFO_T *grp)
|
||||
hdf5_type = (NC_HDF5_TYPE_INFO_T *)type->format_type_info;
|
||||
|
||||
/* Close any open user-defined HDF5 typeids. */
|
||||
if (type->hdf_typeid && H5Tclose(type->hdf_typeid) < 0)
|
||||
if (hdf5_type->hdf_typeid && H5Tclose(hdf5_type->hdf_typeid) < 0)
|
||||
return NC_EHDFERR;
|
||||
type->hdf_typeid = 0;
|
||||
hdf5_type->hdf_typeid = 0;
|
||||
if (hdf5_type->native_hdf_typeid &&
|
||||
H5Tclose(hdf5_type->native_hdf_typeid) < 0)
|
||||
|
@ -209,7 +209,6 @@ get_type_info2(NC_FILE_INFO_T *h5, hid_t datasetid,
|
||||
(*type_info)->size = nc_type_size_g[t];
|
||||
if (!((*type_info)->hdr.name = strdup(nc_type_name_g[t])))
|
||||
return NC_ENOMEM;
|
||||
(*type_info)->hdf_typeid = hdf_typeid;
|
||||
hdf5_type->hdf_typeid = hdf_typeid;
|
||||
hdf5_type->native_hdf_typeid = native_typeid;
|
||||
return NC_NOERR;
|
||||
@ -1328,9 +1327,8 @@ read_type(NC_GRP_INFO_T *grp, hid_t hdf_typeid, char *type_name)
|
||||
|
||||
/* Remember common info about this type. */
|
||||
type->committed = NC_TRUE;
|
||||
type->hdf_typeid = hdf_typeid;
|
||||
hdf5_type->hdf_typeid = hdf_typeid;
|
||||
H5Iinc_ref(type->hdf_typeid); /* Increment number of objects using ID */
|
||||
H5Iinc_ref(hdf5_type->hdf_typeid); /* Increment number of objects using ID */
|
||||
hdf5_type->native_hdf_typeid = native_typeid;
|
||||
|
||||
/* What is the class of this type, compound, vlen, etc. */
|
||||
|
@ -356,12 +356,12 @@ NC4_def_var(int ncid, const char *name, nc_type xtype,
|
||||
type->format_type_info = hdf5_type;
|
||||
|
||||
/* Get HDF5 typeids. */
|
||||
if ((retval = nc4_get_hdf_typeid(h5, xtype, &type->hdf_typeid,
|
||||
if ((retval = nc4_get_hdf_typeid(h5, xtype, &hdf5_type->hdf_typeid,
|
||||
type->endianness)))
|
||||
BAIL(retval);
|
||||
|
||||
/* Get the native HDF5 typeid. */
|
||||
if ((hdf5_type->native_hdf_typeid = H5Tget_native_type(type->hdf_typeid,
|
||||
if ((hdf5_type->native_hdf_typeid = H5Tget_native_type(hdf5_type->hdf_typeid,
|
||||
H5T_DIR_DEFAULT)) < 0)
|
||||
BAIL(NC_EHDFERR);
|
||||
|
||||
@ -372,7 +372,7 @@ NC4_def_var(int ncid, const char *name, nc_type xtype,
|
||||
{
|
||||
H5T_class_t class;
|
||||
|
||||
if ((class = H5Tget_class(type->hdf_typeid)) < 0)
|
||||
if ((class = H5Tget_class(hdf5_type->hdf_typeid)) < 0)
|
||||
BAIL(NC_EHDFERR);
|
||||
switch(class)
|
||||
{
|
||||
@ -1592,7 +1592,8 @@ NC4_put_vars(int ncid, int varid, const size_t *startp, const size_t *countp,
|
||||
/* Write the data. At last! */
|
||||
LOG((4, "about to H5Dwrite datasetid 0x%x mem_spaceid 0x%x "
|
||||
"file_spaceid 0x%x", hdf5_var->hdf_datasetid, mem_spaceid, file_spaceid));
|
||||
if (H5Dwrite(hdf5_var->hdf_datasetid, var->type_info->hdf_typeid,
|
||||
if (H5Dwrite(hdf5_var->hdf_datasetid,
|
||||
((NC_HDF5_TYPE_INFO_T *)var->type_info->format_type_info)->hdf_typeid,
|
||||
mem_spaceid, file_spaceid, xfer_plistid, bufr) < 0)
|
||||
BAIL(NC_EHDFERR);
|
||||
|
||||
@ -1665,6 +1666,7 @@ NC4_get_vars(int ncid, int varid, const size_t *startp, const size_t *countp,
|
||||
NC_VAR_INFO_T *var;
|
||||
NC_HDF5_VAR_INFO_T *hdf5_var;
|
||||
NC_DIM_INFO_T *dim;
|
||||
NC_HDF5_TYPE_INFO_T *hdf5_type;
|
||||
hid_t file_spaceid = 0, mem_spaceid = 0;
|
||||
hid_t xfer_plistid = 0;
|
||||
size_t file_type_size;
|
||||
@ -1686,8 +1688,9 @@ NC4_get_vars(int ncid, int varid, const size_t *startp, const size_t *countp,
|
||||
assert(h5 && grp && var && var->hdr.id == varid && var->format_var_info &&
|
||||
var->type_info && var->type_info->size && var->type_info->format_type_info);
|
||||
|
||||
/* Get the HDF5-specific var info. */
|
||||
/* Get the HDF5-specific var and type info. */
|
||||
hdf5_var = (NC_HDF5_VAR_INFO_T *)var->format_var_info;
|
||||
hdf5_type = (NC_HDF5_TYPE_INFO_T *)var->type_info->format_type_info;
|
||||
|
||||
LOG((3, "%s: var->hdr.name %s mem_nc_type %d", __func__,
|
||||
var->hdr.name, mem_nc_type));
|
||||
@ -1832,12 +1835,12 @@ NC4_get_vars(int ncid, int varid, const size_t *startp, const size_t *countp,
|
||||
* variable-length strings are in allocated memory that user has
|
||||
* to free, which we allocate here. */
|
||||
if (var->type_info->nc_type_class == NC_STRING &&
|
||||
H5Tget_size(var->type_info->hdf_typeid) > 1 &&
|
||||
!H5Tis_variable_str(var->type_info->hdf_typeid))
|
||||
H5Tget_size(hdf5_type->hdf_typeid) > 1 &&
|
||||
!H5Tis_variable_str(hdf5_type->hdf_typeid))
|
||||
{
|
||||
hsize_t fstring_len;
|
||||
|
||||
if ((fstring_len = H5Tget_size(var->type_info->hdf_typeid)) == 0)
|
||||
if ((fstring_len = H5Tget_size(hdf5_type->hdf_typeid)) == 0)
|
||||
BAIL(NC_EHDFERR);
|
||||
if (!(*(char **)data = malloc(1 + fstring_len)))
|
||||
BAIL(NC_ENOMEM);
|
||||
|
@ -537,7 +537,7 @@ nc4_get_hdf_typeid(NC_FILE_INFO_T *h5, nc_type xtype,
|
||||
return NC_EBADTYPE;
|
||||
if (!type)
|
||||
return NC_EBADTYPE;
|
||||
typeid = type->hdf_typeid;
|
||||
typeid = ((NC_HDF5_TYPE_INFO_T *)type->format_type_info)->hdf_typeid;
|
||||
break;
|
||||
}
|
||||
assert(typeid);
|
||||
@ -1214,7 +1214,6 @@ commit_type(NC_GRP_INFO_T *grp, NC_TYPE_INFO_T *type)
|
||||
|
||||
if ((hdf5_type->hdf_typeid = H5Tcreate(H5T_COMPOUND, type->size)) < 0)
|
||||
return NC_EHDFERR;
|
||||
type->hdf_typeid = hdf5_type->hdf_typeid;
|
||||
LOG((4, "creating compound type %s hdf_typeid 0x%x", type->hdr.name,
|
||||
hdf5_type->hdf_typeid));
|
||||
|
||||
@ -1265,14 +1264,12 @@ commit_type(NC_GRP_INFO_T *grp, NC_TYPE_INFO_T *type)
|
||||
/* Create a vlen type. */
|
||||
if ((hdf5_type->hdf_typeid = H5Tvlen_create(base_hdf_typeid)) < 0)
|
||||
return NC_EHDFERR;
|
||||
type->hdf_typeid = hdf5_type->hdf_typeid;
|
||||
}
|
||||
else if (type->nc_type_class == NC_OPAQUE)
|
||||
{
|
||||
/* Create the opaque type. */
|
||||
if ((hdf5_type->hdf_typeid = H5Tcreate(H5T_OPAQUE, type->size)) < 0)
|
||||
return NC_EHDFERR;
|
||||
type->hdf_typeid = hdf5_type->hdf_typeid;
|
||||
}
|
||||
else if (type->nc_type_class == NC_ENUM)
|
||||
{
|
||||
@ -1290,7 +1287,6 @@ commit_type(NC_GRP_INFO_T *grp, NC_TYPE_INFO_T *type)
|
||||
/* Create an enum type. */
|
||||
if ((hdf5_type->hdf_typeid = H5Tenum_create(base_hdf_typeid)) < 0)
|
||||
return NC_EHDFERR;
|
||||
type->hdf_typeid = hdf5_type->hdf_typeid;
|
||||
|
||||
/* Add all the members to the HDF5 type. */
|
||||
for(i=0;i<nclistlength(type->u.e.enum_member);i++) {
|
||||
|
Loading…
Reference in New Issue
Block a user