mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-12-15 08:30:11 +08:00
cleanup of whitespace in HDF4 directory
This commit is contained in:
parent
f9a9100d9a
commit
bb9a7dee53
@ -25,11 +25,11 @@
|
||||
int
|
||||
NC_HDF4_inq_format(int ncid, int *formatp)
|
||||
{
|
||||
/* HDF4 is the format. */
|
||||
if (formatp)
|
||||
*formatp = NC_FORMATX_NC_HDF4;
|
||||
/* HDF4 is the format. */
|
||||
if (formatp)
|
||||
*formatp = NC_FORMATX_NC_HDF4;
|
||||
|
||||
return NC_NOERR;
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -49,19 +49,19 @@ NC_HDF4_inq_format(int ncid, int *formatp)
|
||||
int
|
||||
NC_HDF4_inq_format_extended(int ncid, int *formatp, int *modep)
|
||||
{
|
||||
NC *nc;
|
||||
int retval;
|
||||
NC *nc;
|
||||
int retval;
|
||||
|
||||
LOG((2, "%s: ncid 0x%x", __func__, ncid));
|
||||
LOG((2, "%s: ncid 0x%x", __func__, ncid));
|
||||
|
||||
if ((retval = nc4_find_nc_grp_h5(ncid, &nc, NULL, NULL)))
|
||||
return NC_EBADID;
|
||||
if ((retval = nc4_find_nc_grp_h5(ncid, &nc, NULL, NULL)))
|
||||
return NC_EBADID;
|
||||
|
||||
if (modep)
|
||||
*modep = nc->mode|NC_NETCDF4;
|
||||
if (modep)
|
||||
*modep = nc->mode|NC_NETCDF4;
|
||||
|
||||
if (formatp)
|
||||
*formatp = NC_FORMATX_NC_HDF4;
|
||||
|
||||
return NC_NOERR;
|
||||
if (formatp)
|
||||
*formatp = NC_FORMATX_NC_HDF4;
|
||||
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
@ -33,64 +33,64 @@ int
|
||||
NC_HDF4_get_vara(int ncid, int varid, const size_t *startp,
|
||||
const size_t *countp, void *ip, int memtype)
|
||||
{
|
||||
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;
|
||||
void *data;
|
||||
int retval, d;
|
||||
int range_error;
|
||||
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;
|
||||
void *data;
|
||||
int retval, d;
|
||||
int range_error;
|
||||
|
||||
LOG((2, "%s: ncid 0x%x varid %d memtype %d", __func__, ncid, varid,
|
||||
memtype));
|
||||
LOG((2, "%s: ncid 0x%x varid %d memtype %d", __func__, ncid, varid,
|
||||
memtype));
|
||||
|
||||
/* No scalars in HDF4 SD API. Caller must also provide place to put
|
||||
* data. */
|
||||
if (!startp || !countp || !ip)
|
||||
return NC_EINVAL;
|
||||
/* No scalars in HDF4 SD API. Caller must also provide place to put
|
||||
* data. */
|
||||
if (!startp || !countp || !ip)
|
||||
return NC_EINVAL;
|
||||
|
||||
/* Find our metadata for this file, group, and var. */
|
||||
if ((retval = nc4_find_grp_h5_var(ncid, varid, NULL, NULL, &var)))
|
||||
return retval;
|
||||
assert(var && var->hdr.name && var->format_var_info);
|
||||
/* Find our metadata for this file, group, and var. */
|
||||
if ((retval = nc4_find_grp_h5_var(ncid, varid, NULL, NULL, &var)))
|
||||
return retval;
|
||||
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;
|
||||
/* Get the HDF4 specific var metadata. */
|
||||
hdf4_var = (NC_VAR_HDF4_INFO_T *)var->format_var_info;
|
||||
|
||||
/* 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++)
|
||||
{
|
||||
start32[d] = startp[d];
|
||||
edge32[d] = countp[d];
|
||||
nelem *= countp[d];
|
||||
}
|
||||
/* 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++)
|
||||
{
|
||||
start32[d] = startp[d];
|
||||
edge32[d] = countp[d];
|
||||
nelem *= countp[d];
|
||||
}
|
||||
|
||||
/* If memtype was not give, use variable type. */
|
||||
if (memtype == NC_NAT)
|
||||
memtype = var->type_info->hdr.id;
|
||||
/* If memtype was not give, use variable type. */
|
||||
if (memtype == NC_NAT)
|
||||
memtype = var->type_info->hdr.id;
|
||||
|
||||
/* If we need to convert data, allocate temp storage. */
|
||||
if (var->type_info->hdr.id == memtype)
|
||||
data = ip;
|
||||
else
|
||||
if (!(data = malloc(var->type_info->size * nelem)))
|
||||
return NC_ENOMEM;
|
||||
/* If we need to convert data, allocate temp storage. */
|
||||
if (var->type_info->hdr.id == memtype)
|
||||
data = ip;
|
||||
else
|
||||
if (!(data = malloc(var->type_info->size * nelem)))
|
||||
return NC_ENOMEM;
|
||||
|
||||
/* Read the data with HDF4. */
|
||||
if (SDreaddata(hdf4_var->sdsid, start32, NULL, edge32, data))
|
||||
return NC_EHDFERR;
|
||||
/* Read the data with HDF4. */
|
||||
if (SDreaddata(hdf4_var->sdsid, start32, NULL, edge32, data))
|
||||
return NC_EHDFERR;
|
||||
|
||||
/* Do we need to convert data? */
|
||||
if (var->type_info->hdr.id != memtype)
|
||||
{
|
||||
if ((retval = nc4_convert_type(data, ip, var->type_info->hdr.id, memtype, nelem,
|
||||
&range_error, NULL, 0)))
|
||||
return retval;
|
||||
free(data);
|
||||
if (range_error)
|
||||
return range_error;
|
||||
}
|
||||
/* Do we need to convert data? */
|
||||
if (var->type_info->hdr.id != memtype)
|
||||
{
|
||||
if ((retval = nc4_convert_type(data, ip, var->type_info->hdr.id, memtype, nelem,
|
||||
&range_error, NULL, 0)))
|
||||
return retval;
|
||||
free(data);
|
||||
if (range_error)
|
||||
return range_error;
|
||||
}
|
||||
|
||||
return NC_NOERR;
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user