mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-11-27 07:30:33 +08:00
Merge branch 'master' of https://github.com/Unidata/netcdf-c
This commit is contained in:
commit
fd2d8e71de
1
cf
1
cf
@ -24,7 +24,6 @@ CFLAGS=""
|
||||
PREFIX=/usr/local
|
||||
stddir="/usr/local"
|
||||
|
||||
|
||||
if test "x$cmds" = x ; then
|
||||
cmds=""
|
||||
#cmds="all"
|
||||
|
@ -130,6 +130,8 @@ ncaux_add_field(void* tag, const char *name, nc_type field_type,
|
||||
cmpd->nfields++;
|
||||
|
||||
done:
|
||||
if(newfields)
|
||||
free(newfields);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -1161,6 +1161,10 @@ read_type(NC_GRP_INFO_T *grp, hid_t hdf_typeid, char *type_name)
|
||||
{
|
||||
int nmembers;
|
||||
unsigned int m;
|
||||
char* member_name = NULL;
|
||||
#ifdef JNA
|
||||
char jna[1001];
|
||||
#endif
|
||||
|
||||
type->nc_type_class = NC_COMPOUND;
|
||||
|
||||
@ -1171,22 +1175,32 @@ read_type(NC_GRP_INFO_T *grp, hid_t hdf_typeid, char *type_name)
|
||||
{
|
||||
hid_t member_hdf_typeid;
|
||||
hid_t member_native_typeid;
|
||||
char *member_name;
|
||||
size_t member_offset;
|
||||
H5T_class_t mem_class;
|
||||
nc_type member_xtype;
|
||||
|
||||
retval = NC_NOERR;
|
||||
|
||||
/* Get the typeid and native typeid of this member of the
|
||||
* compound type. */
|
||||
if ((member_hdf_typeid = H5Tget_member_type(type->native_hdf_typeid, m)) < 0)
|
||||
return NC_EHDFERR;
|
||||
|
||||
if ((member_native_typeid = H5Tget_native_type(member_hdf_typeid, H5T_DIR_DEFAULT)) < 0)
|
||||
return NC_EHDFERR;
|
||||
|
||||
/* Get the name of the member.*/
|
||||
member_name = H5Tget_member_name(type->native_hdf_typeid, m);
|
||||
if (!member_name || strlen(member_name) > NC_MAX_NAME)
|
||||
return NC_EBADNAME;
|
||||
if (!member_name || strlen(member_name) > NC_MAX_NAME) {
|
||||
retval = NC_EBADNAME;
|
||||
break;
|
||||
}
|
||||
#ifdef JNA
|
||||
else {
|
||||
strncpy(jna,member_name,1000);
|
||||
member_name = jna;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Offset in bytes on *this* platform. */
|
||||
member_offset = H5Tget_member_offset(type->native_hdf_typeid, m);
|
||||
@ -1200,42 +1214,55 @@ read_type(NC_GRP_INFO_T *grp, hid_t hdf_typeid, char *type_name)
|
||||
hsize_t dims[NC_MAX_VAR_DIMS];
|
||||
int d;
|
||||
|
||||
if ((ndims = H5Tget_array_ndims(member_hdf_typeid)) < 0)
|
||||
return NC_EHDFERR;
|
||||
if (H5Tget_array_dims(member_hdf_typeid, dims, NULL) != ndims)
|
||||
return NC_EHDFERR;
|
||||
if ((ndims = H5Tget_array_ndims(member_hdf_typeid)) < 0) {
|
||||
retval = NC_EHDFERR;
|
||||
break;
|
||||
}
|
||||
if (H5Tget_array_dims(member_hdf_typeid, dims, NULL) != ndims) {
|
||||
retval = NC_EHDFERR;
|
||||
break;
|
||||
}
|
||||
for (d = 0; d < ndims; d++)
|
||||
dim_size[d] = dims[d];
|
||||
|
||||
/* What is the netCDF typeid of this member? */
|
||||
if ((retval = get_netcdf_type(grp->nc4_info, H5Tget_super(member_hdf_typeid),
|
||||
&member_xtype)))
|
||||
return retval;
|
||||
break;
|
||||
|
||||
/* Add this member to our list of fields in this compound type. */
|
||||
if ((retval = nc4_field_list_add(&type->u.c.field, type->u.c.num_fields++, member_name,
|
||||
member_offset, H5Tget_super(member_hdf_typeid),
|
||||
H5Tget_super(member_native_typeid),
|
||||
member_xtype, ndims, dim_size)))
|
||||
return retval;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* What is the netCDF typeid of this member? */
|
||||
if ((retval = get_netcdf_type(grp->nc4_info, member_native_typeid,
|
||||
&member_xtype)))
|
||||
return retval;
|
||||
break;
|
||||
|
||||
/* Add this member to our list of fields in this compound type. */
|
||||
if ((retval = nc4_field_list_add(&type->u.c.field, type->u.c.num_fields++, member_name,
|
||||
member_offset, member_hdf_typeid, member_native_typeid,
|
||||
member_xtype, 0, NULL)))
|
||||
return retval;
|
||||
break;
|
||||
}
|
||||
|
||||
/* HDF5 allocated this for us. */
|
||||
free(member_name);
|
||||
#ifndef JNA
|
||||
/* Free the member name (which HDF5 allocated for us). */
|
||||
if(member_name != NULL) free(member_name);
|
||||
#endif
|
||||
member_name = NULL;
|
||||
}
|
||||
#ifndef JNA
|
||||
if(member_name != NULL)
|
||||
free(member_name);
|
||||
#endif
|
||||
if(retval) /* error exit from loop */
|
||||
return retval;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1363,6 +1390,7 @@ read_type(NC_GRP_INFO_T *grp, hid_t hdf_typeid, char *type_name)
|
||||
#endif
|
||||
member_name = NULL;
|
||||
}
|
||||
|
||||
#ifndef JNA
|
||||
if(member_name != NULL)
|
||||
free(member_name);
|
||||
|
@ -2320,7 +2320,7 @@ write_dim(NC_DIM_INFO_T *dim, NC_GRP_INFO_T *grp, int write_dimid)
|
||||
|
||||
if (v1)
|
||||
{
|
||||
hsize_t *new_size;
|
||||
hsize_t *new_size = NULL;
|
||||
NC_GRP_INFO_T *g;
|
||||
NC_DIM_INFO_T *dim1;
|
||||
int d1;
|
||||
@ -2347,8 +2347,10 @@ write_dim(NC_DIM_INFO_T *dim, NC_GRP_INFO_T *grp, int write_dimid)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (H5Dset_extent(v1->hdf_datasetid, new_size) < 0)
|
||||
BAIL(NC_EHDFERR);
|
||||
if (H5Dset_extent(v1->hdf_datasetid, new_size) < 0) {
|
||||
free(new_size);
|
||||
BAIL(NC_EHDFERR);
|
||||
}
|
||||
free(new_size);
|
||||
}
|
||||
}
|
||||
@ -2363,6 +2365,7 @@ write_dim(NC_DIM_INFO_T *dim, NC_GRP_INFO_T *grp, int write_dimid)
|
||||
|
||||
return NC_NOERR;
|
||||
exit:
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
@ -412,7 +412,10 @@ main(
|
||||
|
||||
cdlname = (char*)emalloc(NC_MAX_NAME);
|
||||
cdlname = nulldup(argv[0]);
|
||||
if(strlen(cdlname) > NC_MAX_NAME) cdlname[NC_MAX_NAME] = '\0';
|
||||
if(cdlname != NULL) {
|
||||
if(strlen(cdlname) > NC_MAX_NAME)
|
||||
cdlname[NC_MAX_NAME] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
/* Standard Unidata java interface => usingclassic */
|
||||
|
Loading…
Reference in New Issue
Block a user