mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-01-18 15:55:12 +08:00
Fix a number of potential problems by changing calls to nc_XXX to NC3/4_XXX
This commit is contained in:
parent
fc91587e26
commit
5f2eb8afbf
@ -828,6 +828,7 @@ nc_get_var_chunk_cache(int ncid, int varid, size_t *sizep, size_t *nelemsp,
|
|||||||
EXTERNL int
|
EXTERNL int
|
||||||
nc_redef(int ncid);
|
nc_redef(int ncid);
|
||||||
|
|
||||||
|
/* Is this ever used? */
|
||||||
EXTERNL int
|
EXTERNL int
|
||||||
nc__enddef(int ncid, size_t h_minfree, size_t v_align,
|
nc__enddef(int ncid, size_t h_minfree, size_t v_align,
|
||||||
size_t v_minfree, size_t r_align);
|
size_t v_minfree, size_t r_align);
|
||||||
|
@ -202,7 +202,7 @@ NC3_inq_unlimdims(int ncid, int *ndimsp, int *unlimdimidsp)
|
|||||||
int retval;
|
int retval;
|
||||||
int unlimid;
|
int unlimid;
|
||||||
|
|
||||||
if ((retval = nc_inq_unlimdim(ncid, &unlimid)))
|
if ((retval = NC3_inq_unlimdim(ncid, &unlimid)))
|
||||||
return retval;
|
return retval;
|
||||||
if (unlimid != -1) {
|
if (unlimid != -1) {
|
||||||
if(ndimsp) *ndimsp = 1;
|
if(ndimsp) *ndimsp = 1;
|
||||||
@ -267,9 +267,9 @@ static int
|
|||||||
NC3_inq_varids(int ncid, int *nvarsp, int *varids)
|
NC3_inq_varids(int ncid, int *nvarsp, int *varids)
|
||||||
{
|
{
|
||||||
int retval,v,nvars;
|
int retval,v,nvars;
|
||||||
/* If this is a netcdf-3 file, there is only one group, the root
|
/* This is a netcdf-3 file, there is only one group, the root
|
||||||
group, and its vars have ids 0 thru nvars - 1. */
|
group, and its vars have ids 0 thru nvars - 1. */
|
||||||
if ((retval = nc_inq(ncid, NULL, &nvars, NULL, NULL)))
|
if ((retval = NC3_inq(ncid, NULL, &nvars, NULL, NULL)))
|
||||||
return retval;
|
return retval;
|
||||||
if(nvarsp) *nvarsp = nvars;
|
if(nvarsp) *nvarsp = nvars;
|
||||||
if (varids)
|
if (varids)
|
||||||
@ -284,7 +284,7 @@ NC3_inq_dimids(int ncid, int *ndimsp, int *dimids, int include_parents)
|
|||||||
int retval,d,ndims;
|
int retval,d,ndims;
|
||||||
/* If this is a netcdf-3 file, then the dimids are going to be 0
|
/* If this is a netcdf-3 file, then the dimids are going to be 0
|
||||||
thru ndims-1, so just provide them. */
|
thru ndims-1, so just provide them. */
|
||||||
if ((retval = nc_inq(ncid, &ndims, NULL, NULL, NULL)))
|
if ((retval = NC3_inq(ncid, &ndims, NULL, NULL, NULL)))
|
||||||
return retval;
|
return retval;
|
||||||
if(ndimsp) *ndimsp = ndims;
|
if(ndimsp) *ndimsp = ndims;
|
||||||
if (dimids)
|
if (dimids)
|
||||||
|
@ -1097,7 +1097,7 @@ NC3_close(int ncid)
|
|||||||
status = NC_endef(nc3, 0, 1, 0, 1); /* TODO: defaults */
|
status = NC_endef(nc3, 0, 1, 0, 1); /* TODO: defaults */
|
||||||
if(status != NC_NOERR )
|
if(status != NC_NOERR )
|
||||||
{
|
{
|
||||||
(void) nc_abort(ncid);
|
(void) NC3_abort(ncid);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ $Id: nc4dim.c,v 1.41 2010/05/25 17:54:23 dmh Exp $
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "nc4internal.h"
|
#include "nc4internal.h"
|
||||||
|
#include "nc4dispatch.h"
|
||||||
|
|
||||||
#ifdef USE_PNETCDF
|
#ifdef USE_PNETCDF
|
||||||
#include <pnetcdf.h>
|
#include <pnetcdf.h>
|
||||||
@ -113,7 +114,7 @@ NC4_def_dim(int ncid, const char *name, size_t len, int *idp)
|
|||||||
|
|
||||||
/* If it's not in define mode, enter define mode. */
|
/* If it's not in define mode, enter define mode. */
|
||||||
if (!(h5->flags & NC_INDEF))
|
if (!(h5->flags & NC_INDEF))
|
||||||
if ((retval = nc_redef(ncid)))
|
if ((retval = NC4_redef(ncid)))
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
/* Make sure this is a valid netcdf name. */
|
/* Make sure this is a valid netcdf name. */
|
||||||
@ -328,7 +329,7 @@ NC4_rename_dim(int ncid, int dimid, const char *name)
|
|||||||
/* { */
|
/* { */
|
||||||
/* if (h5->cmode & NC_CLASSIC_MODEL) */
|
/* if (h5->cmode & NC_CLASSIC_MODEL) */
|
||||||
/* return NC_ENOTINDEFINE; */
|
/* return NC_ENOTINDEFINE; */
|
||||||
/* if ((retval = nc_redef(ncid))) */
|
/* if ((retval = NC4_redef(ncid))) */
|
||||||
/* return retval; */
|
/* return retval; */
|
||||||
/* } */
|
/* } */
|
||||||
|
|
||||||
|
@ -1245,8 +1245,7 @@ read_type(NC_GRP_INFO_T *grp, char *type_name)
|
|||||||
if ((retval = nc4_enum_member_add(&type->enum_member, type->size,
|
if ((retval = nc4_enum_member_add(&type->enum_member, type->size,
|
||||||
member_name, value)))
|
member_name, value)))
|
||||||
return retval;
|
return retval;
|
||||||
|
H5MM_xfree(member_name); /* Where is this defined? */
|
||||||
H5MM_xfree(member_name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free the tempory memory for one value, and the member name
|
/* Free the tempory memory for one value, and the member name
|
||||||
@ -2900,7 +2899,7 @@ NC4_sync(int ncid)
|
|||||||
{
|
{
|
||||||
if (nc4_info->cmode & NC_CLASSIC_MODEL)
|
if (nc4_info->cmode & NC_CLASSIC_MODEL)
|
||||||
return NC_EINDEFINE;
|
return NC_EINDEFINE;
|
||||||
if ((retval = nc_enddef(ncid)))
|
if ((retval = NC4_enddef(ncid)))
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ NC4_inq_grpname_full(int ncid, size_t *lenp, char *full_name)
|
|||||||
int i, ret = NC_NOERR;
|
int i, ret = NC_NOERR;
|
||||||
|
|
||||||
/* How many generations? */
|
/* How many generations? */
|
||||||
for (g = 0; !nc_inq_grp_parent(id, &parent_id); g++, id = parent_id)
|
for (g = 0; !NC4_inq_grp_parent(id, &parent_id); g++, id = parent_id)
|
||||||
;
|
;
|
||||||
|
|
||||||
/* Allocate storage. */
|
/* Allocate storage. */
|
||||||
@ -197,12 +197,12 @@ NC4_inq_grpname_full(int ncid, size_t *lenp, char *full_name)
|
|||||||
/* Get the ncids for all generations. */
|
/* Get the ncids for all generations. */
|
||||||
gid[0] = ncid;
|
gid[0] = ncid;
|
||||||
for (i = 1; i < g && !ret; i++)
|
for (i = 1; i < g && !ret; i++)
|
||||||
ret = nc_inq_grp_parent(gid[i - 1], &gid[i]);
|
ret = NC4_inq_grp_parent(gid[i - 1], &gid[i]);
|
||||||
|
|
||||||
/* Assemble the full name. */
|
/* Assemble the full name. */
|
||||||
for (i = g - 1; !ret && i >= 0 && !ret; i--)
|
for (i = g - 1; !ret && i >= 0 && !ret; i--)
|
||||||
{
|
{
|
||||||
if ((ret = nc_inq_grpname(gid[i], grp_name)))
|
if ((ret = NC4_inq_grpname(gid[i], grp_name)))
|
||||||
break;
|
break;
|
||||||
strcat(name, grp_name);
|
strcat(name, grp_name);
|
||||||
if (i)
|
if (i)
|
||||||
@ -297,7 +297,7 @@ NC4_inq_grp_full_ncid(int ncid, const char *full_name, int *grp_ncid)
|
|||||||
/* Keep parsing the string. */
|
/* Keep parsing the string. */
|
||||||
for (; cp; id1 = id2)
|
for (; cp; id1 = id2)
|
||||||
{
|
{
|
||||||
if ((ret = nc_inq_grp_ncid(id1, cp, &id2)))
|
if ((ret = NC4_inq_ncid(id1, cp, &id2)))
|
||||||
{
|
{
|
||||||
free(full_name_cpy);
|
free(full_name_cpy);
|
||||||
return ret;
|
return ret;
|
||||||
@ -335,7 +335,7 @@ NC4_inq_varids(int ncid, int *nvars, int *varids)
|
|||||||
{
|
{
|
||||||
/* If this is a netcdf-3 file, there is only one group, the root
|
/* If this is a netcdf-3 file, there is only one group, the root
|
||||||
* group, and its vars have ids 0 thru nvars - 1. */
|
* group, and its vars have ids 0 thru nvars - 1. */
|
||||||
if ((retval = nc_inq(ncid, NULL, &num_vars, NULL, NULL)))
|
if ((retval = NC4_inq(ncid, NULL, &num_vars, NULL, NULL)))
|
||||||
return retval;
|
return retval;
|
||||||
if (varids)
|
if (varids)
|
||||||
for (v = 0; v < num_vars; v++)
|
for (v = 0; v < num_vars; v++)
|
||||||
@ -396,7 +396,7 @@ NC4_inq_dimids(int ncid, int *ndims, int *dimids, int include_parents)
|
|||||||
{
|
{
|
||||||
/* If this is a netcdf-3 file, then the dimids are going to be 0
|
/* If this is a netcdf-3 file, then the dimids are going to be 0
|
||||||
* thru ndims-1, so just provide them. */
|
* thru ndims-1, so just provide them. */
|
||||||
if ((retval = nc_inq(ncid, &num, NULL, NULL, NULL)))
|
if ((retval = NC4_inq(ncid, &num, NULL, NULL, NULL)))
|
||||||
return retval;
|
return retval;
|
||||||
if (dimids)
|
if (dimids)
|
||||||
for (d = 0; d < num; d++)
|
for (d = 0; d < num; d++)
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "nc4internal.h"
|
#include "nc4internal.h"
|
||||||
|
#include "nc4dispatch.h"
|
||||||
#include <H5DSpublic.h>
|
#include <H5DSpublic.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
@ -924,7 +925,7 @@ nc4_get_vara(NC *nc, int ncid, int varid, const size_t *startp,
|
|||||||
|
|
||||||
/* We can't go beyond the latgest current extent of
|
/* We can't go beyond the latgest current extent of
|
||||||
the unlimited dim. */
|
the unlimited dim. */
|
||||||
if ((retval = nc_inq_dimlen(ncid, dim->dimid, &ulen)))
|
if ((retval = NC4_inq_dim(ncid, dim->dimid, NULL, &ulen)))
|
||||||
BAIL(retval);
|
BAIL(retval);
|
||||||
|
|
||||||
/* Check for out of bound requests. */
|
/* Check for out of bound requests. */
|
||||||
@ -2561,7 +2562,7 @@ pg_var(NC_PG_T pg, NC *nc, int ncid, int varid, nc_type xtype,
|
|||||||
for (i = 0; i < var->ndims; i++)
|
for (i = 0; i < var->ndims; i++)
|
||||||
{
|
{
|
||||||
start[i] = 0;
|
start[i] = 0;
|
||||||
if ((retval = nc_inq_dimlen(ncid, var->dimids[i], &(count[i]))))
|
if ((retval = NC4_inq_dim(ncid, var->dimids[i], NULL, &(count[i]))))
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2662,7 +2663,7 @@ nc4_pg_varm(NC_PG_T pg, NC *nc, int ncid, int varid, const size_t *start,
|
|||||||
{
|
{
|
||||||
if (h5->cmode & NC_CLASSIC_MODEL)
|
if (h5->cmode & NC_CLASSIC_MODEL)
|
||||||
return NC_EINDEFINE;
|
return NC_EINDEFINE;
|
||||||
if ((retval = nc_enddef(ncid)))
|
if ((retval = NC4__enddef(ncid,0,0,0,0)))
|
||||||
BAIL(retval);
|
BAIL(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2748,7 +2749,7 @@ nc4_pg_varm(NC_PG_T pg, NC *nc, int ncid, int varid, const size_t *start,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
size_t len;
|
size_t len;
|
||||||
if ((retval = nc_inq_dimlen(ncid, var->dimids[idim], &len)))
|
if ((retval = NC4_inq_dim(ncid, var->dimids[idim], NULL, &len)))
|
||||||
goto done;
|
goto done;
|
||||||
myedges[idim] = len - mystart[idim];
|
myedges[idim] = len - mystart[idim];
|
||||||
}
|
}
|
||||||
@ -2773,13 +2774,13 @@ nc4_pg_varm(NC_PG_T pg, NC *nc, int ncid, int varid, const size_t *start,
|
|||||||
for (idim = maxidim; idim >= 0; --idim)
|
for (idim = maxidim; idim >= 0; --idim)
|
||||||
{
|
{
|
||||||
size_t dimlen;
|
size_t dimlen;
|
||||||
if ((retval = nc_inq_dimlen(ncid, var->dimids[idim], &dimlen)))
|
if ((retval = NC4_inq_dim(ncid, var->dimids[idim], NULL, &dimlen)))
|
||||||
goto done;
|
goto done;
|
||||||
/* Don't check unlimited dimension on PUTs. */
|
/* Don't check unlimited dimension on PUTs. */
|
||||||
if (pg == PUT)
|
if (pg == PUT)
|
||||||
{
|
{
|
||||||
int stop = 0, d, num_unlim_dim, unlim_dimids[NC_MAX_DIMS];
|
int stop = 0, d, num_unlim_dim, unlim_dimids[NC_MAX_DIMS];
|
||||||
if ((retval = nc_inq_unlimdims(ncid, &num_unlim_dim, unlim_dimids)))
|
if ((retval = NC4_inq_unlimdims(ncid, &num_unlim_dim, unlim_dimids)))
|
||||||
goto done;
|
goto done;
|
||||||
for (d = 0; d < num_unlim_dim; d++)
|
for (d = 0; d < num_unlim_dim; d++)
|
||||||
if (var->dimids[idim] == unlim_dimids[d])
|
if (var->dimids[idim] == unlim_dimids[d])
|
||||||
|
@ -13,6 +13,7 @@ $Id: nc4type.c,v 1.73 2010/05/25 17:54:24 dmh Exp $
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "nc4internal.h"
|
#include "nc4internal.h"
|
||||||
|
#include "nc4dispatch.h"
|
||||||
|
|
||||||
#define NUM_ATOMIC_TYPES 13
|
#define NUM_ATOMIC_TYPES 13
|
||||||
char atomic_name[NUM_ATOMIC_TYPES][NC_MAX_NAME + 1] = {"none", "byte", "char",
|
char atomic_name[NUM_ATOMIC_TYPES][NC_MAX_NAME + 1] = {"none", "byte", "char",
|
||||||
@ -206,7 +207,7 @@ add_user_type(int ncid, size_t size, const char *name, nc_type base_typeid,
|
|||||||
|
|
||||||
/* Turn on define mode if it is not on. */
|
/* Turn on define mode if it is not on. */
|
||||||
if (!(h5->cmode & NC_INDEF))
|
if (!(h5->cmode & NC_INDEF))
|
||||||
if ((retval = nc_redef(ncid)))
|
if ((retval = NC4_redef(ncid)))
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
/* No size is provided for vlens or enums, get it from the base type. */
|
/* No size is provided for vlens or enums, get it from the base type. */
|
||||||
|
@ -137,7 +137,7 @@ nc_set_var_chunk_cache_ints(int ncid, int varid, int size, int nelems,
|
|||||||
if (preemption >= 0)
|
if (preemption >= 0)
|
||||||
real_preemption = preemption / 100.;
|
real_preemption = preemption / 100.;
|
||||||
|
|
||||||
return nc_set_var_chunk_cache(ncid, varid, real_size, real_nelems,
|
return NC4_set_var_chunk_cache(ncid, varid, real_size, real_nelems,
|
||||||
real_preemption);
|
real_preemption);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,7 +190,7 @@ nc_get_var_chunk_cache_ints(int ncid, int varid, int *sizep,
|
|||||||
float real_preemption;
|
float real_preemption;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if ((ret = nc_get_var_chunk_cache(ncid, varid, &real_size,
|
if ((ret = NC4_get_var_chunk_cache(ncid, varid, &real_size,
|
||||||
&real_nelems, &real_preemption)))
|
&real_nelems, &real_preemption)))
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
@ -915,7 +915,7 @@ nc_def_var_extra(int ncid, int varid, int *shuffle, int *deflate,
|
|||||||
memcpy(var->fill_value, fill_value, type_size);
|
memcpy(var->fill_value, fill_value, type_size);
|
||||||
|
|
||||||
/* If there's a _FillValue attribute, delete it. */
|
/* If there's a _FillValue attribute, delete it. */
|
||||||
retval = nc_del_att(ncid, varid, _FillValue);
|
retval = NC4_del_att(ncid, varid, _FillValue);
|
||||||
if (retval && retval != NC_ENOTATT)
|
if (retval && retval != NC_ENOTATT)
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user