removed unneeded lookup function

This commit is contained in:
Ed Hartnett 2018-08-21 11:54:06 -06:00
parent 990a75d5d7
commit d8c1a6209a
6 changed files with 26 additions and 78 deletions

View File

@ -357,8 +357,6 @@ NC_TYPE_INFO_T *nc4_rec_find_named_type(NC_GRP_INFO_T *start_grp, char *name);
NC_TYPE_INFO_T *nc4_rec_find_equal_type(NC_GRP_INFO_T *start_grp, int ncid1, NC_TYPE_INFO_T *type);
int nc4_find_nc_att(int ncid, int varid, const char *name, int attnum,
NC_ATT_INFO_T **att);
int nc4_find_g_var_nc(NC *nc, int ncid, int varid,
NC_GRP_INFO_T **grp, NC_VAR_INFO_T **var);
int nc4_find_grp_h5_var(int ncid, int varid, NC_FILE_INFO_T **h5, NC_GRP_INFO_T **grp,
NC_VAR_INFO_T **var);
int nc4_find_grp_att(NC_GRP_INFO_T *grp, int varid, const char *name, int attnum,

View File

@ -33,10 +33,7 @@ int
NC_HDF4_get_vara(int ncid, int varid, const size_t *startp,
const size_t *countp, void *ip, int memtype)
{
NC *nc;
NC_FILE_INFO_T* h5;
NC_GRP_INFO_T *grp;
NC_VAR_HDF4_INFO_T *hdf4_var;
NC_VAR_HDF4_INFO_T *hdf4_var;
NC_VAR_INFO_T *var;
int32 start32[NC_MAX_VAR_DIMS], edge32[NC_MAX_VAR_DIMS];
size_t nelem = 1;
@ -52,22 +49,14 @@ NC_HDF4_get_vara(int ncid, int varid, const size_t *startp,
if (!startp || !countp || !ip)
return NC_EINVAL;
/* Find file info. */
if (!(nc = nc4_find_nc_file(ncid, &h5)))
return NC_EBADID;
/* Find our metadata for this file, group, and var. */
if ((retval = nc4_find_g_var_nc(nc, ncid, varid, &grp, &var)))
if ((retval = nc4_find_grp_h5_var(ncid, varid, NULL, NULL, &var)))
return retval;
assert(grp && var && var->hdr.name && var->format_var_info);
assert(var && var->hdr.name && var->format_var_info);
/* Get the HDF4 specific var metadata. */
hdf4_var = (NC_VAR_HDF4_INFO_T *)var->format_var_info;
h5 = NC4_DATA(nc);
assert(h5);
/* Convert starts/edges to the int32 type HDF4 wants. Also learn
* how many elements of data are being read. */
for (d = 0; d < var->ndims; d++)

View File

@ -817,21 +817,26 @@ NC4_def_var_chunking(int ncid, int varid, int contiguous, const size_t *chunksiz
int
nc_def_var_chunking_ints(int ncid, int varid, int contiguous, int *chunksizesp)
{
NC *nc;
NC_GRP_INFO_T *grp;
/* NC *nc; */
/* NC_GRP_INFO_T *grp; */
NC_VAR_INFO_T *var;
NC_FILE_INFO_T *h5;
/* NC_FILE_INFO_T *h5; */
size_t *cs = NULL;
int i, retval;
/* Find this ncid's file info. */
if ((retval = nc4_find_nc_grp_h5(ncid, &nc, &grp, &h5)))
/* Get pointer to the var. */
if ((retval = nc4_find_grp_h5_var(ncid, varid, NULL, NULL, &var)))
return retval;
assert(nc);
assert(var);
/* Find var cause I need the number of dims. */
if ((retval = nc4_find_g_var_nc(nc, ncid, varid, &grp, &var)))
return retval;
/* /\* Find this ncid's file info. *\/ */
/* if ((retval = nc4_find_nc_grp_h5(ncid, &nc, &grp, &h5))) */
/* return retval; */
/* assert(nc); */
/* /\* Find var cause I need the number of dims. *\/ */
/* if ((retval = nc4_find_g_var_nc(nc, ncid, varid, &grp, &var))) */
/* return retval; */
/* Allocate space for the size_t copy of the chunksizes array. */
if (var->ndims)

View File

@ -127,8 +127,7 @@ nc4_nc4f_list_add(NC *nc, const char *path, int mode)
/**
* @internal Given an ncid, find the relevant group and return a
* pointer to it, return an error of this is not a netcdf-4 file (or
* if strict nc3 is turned on for this file.)
* pointer to it.
*
* @param ncid File and group ID.
* @param grp Pointer that gets pointer to group info struct. Ignored
@ -136,7 +135,6 @@ nc4_nc4f_list_add(NC *nc, const char *path, int mode)
*
* @return ::NC_NOERR No error.
* @return ::NC_ENOTNC4 Not a netCDF-4 file.
* @return ::NC_ESTRICTNC3 Not allowed for classic model.
* @author Ed Hartnett
*/
int
@ -206,43 +204,6 @@ nc4_find_nc_grp_h5(int ncid, NC **nc, NC_GRP_INFO_T **grp, NC_FILE_INFO_T **h5)
return NC_NOERR;
}
/**
* @internal Given an ncid and varid, get pointers to the group and var
* metadata.
*
* @param nc Pointer to file's NC struct.
* @param ncid File ID.
* @param varid Variable ID.
* @param grp Pointer that gets pointer to group info.
* @param var Pointer that gets pointer to var info.
*
* @return ::NC_NOERR No error.
*/
int
nc4_find_g_var_nc(NC *nc, int ncid, int varid,
NC_GRP_INFO_T **grp, NC_VAR_INFO_T **var)
{
NC_FILE_INFO_T* h5 = NC4_DATA(nc);
/* Find the group info. */
assert(grp && var && h5 && h5->root_grp);
if (!(*grp = nclistget(h5->allgroups, (ncid & GRP_ID_MASK))))
return NC_EBADID;
/* It is possible for *grp to be NULL. If it is,
return an error. */
if(*grp == NULL)
return NC_EBADID;
/* Find the var info. */
(*var) = (NC_VAR_INFO_T*)ncindexith((*grp)->vars,varid);
if((*var) == NULL)
return NC_ENOTVAR;
return NC_NOERR;
}
/**
* @internal Given an ncid and varid, get pointers to the group and var
* metadata.

View File

@ -395,40 +395,35 @@ NC4_inq_var_all(int ncid, int varid, char *name, nc_type *xtypep,
int
nc_inq_var_chunking_ints(int ncid, int varid, int *contiguousp, int *chunksizesp)
{
NC *nc;
NC_GRP_INFO_T *grp;
NC_VAR_INFO_T *var;
NC_FILE_INFO_T *h5;
size_t *cs = NULL;
int i, retval;
/* Find this ncid's file info. */
if ((retval = nc4_find_nc_grp_h5(ncid, &nc, &grp, &h5)))
return retval;
assert(nc);
/* Find var cause I need the number of dims. */
if ((retval = nc4_find_g_var_nc(nc, ncid, varid, &grp, &var)))
/* Get pointer to the var. */
if ((retval = nc4_find_grp_h5_var(ncid, varid, NULL, NULL, &var)))
return retval;
assert(var);
/* Allocate space for the size_t copy of the chunksizes array. */
if (var->ndims)
if (!(cs = malloc(var->ndims * sizeof(size_t))))
return NC_ENOMEM;
/* Call the netcdf-4 version directly. */
retval = NC4_inq_var_all(ncid, varid, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, contiguousp, cs, NULL,
NULL, NULL, NULL, NULL, NULL);
/* Copy from size_t array. */
if (chunksizesp && var->contiguous == NC_CHUNKED)
if (!retval && chunksizesp && var->contiguous == NC_CHUNKED)
{
for (i = 0; i < var->ndims; i++)
{
chunksizesp[i] = (int)cs[i];
if (cs[i] > NC_MAX_INT)
retval = NC_ERANGE;
}
}
if (var->ndims)
free(cs);

View File

@ -62,7 +62,7 @@ main(int argc, char **argv)
SUMMARIZE_ERR;
printf("*** testing HDF5 file with circular group structure...");
{
hid_t hdfid, grpid, grpid2, fapl_id;
hid_t hdfid, grpid, grpid2;
int ncid;
/* First use HDF5 to create a file with circular group