Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ Recent releases include references to Jira issue identifiers for more informatio
## 4.3.1 Released TBD


* Corrected behavior of nc_inq_unlimdim and nv_inq_unlimdims to report dimids
in same order as nc_inq_dimids

* Addressed an issue reported by Jeff Whitaker regarding `nc_inq_nvars` returning an incorrect number of dimensions (this issue was introduced in 4.3.1-rc5). Integrated a test contributed by Jeff Whitaker.

### 4.3.1-rc5 Released 2013-12-06
Expand Down
38 changes: 16 additions & 22 deletions include/nc4internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,22 @@ typedef enum {VAR, DIM, ATT} NC_OBJ_T;
* as the netCDF dimid. */
#define NC_DIMID_ATT_NAME "_Netcdf4Dimid"

/* Generic doubly-linked list node */
typedef struct NC_LIST_NODE
{
void *next;
void *prev;
} NC_LIST_NODE_T;

/* This is a struct to handle the dim metadata. */
typedef struct NC_DIM_INFO
{
NC_LIST_NODE_T l; /* Use generic doubly-linked list (must be first) */
char *name;
size_t len;
int dimid;
int unlimited;
int extended;
struct NC_DIM_INFO *next;
struct NC_DIM_INFO *prev;
hid_t hdf_dimscaleid;
HDF5_OBJID_T hdf5_objid;
struct NC_VAR_INFO *coord_var; /* The coord var, if it exists. */
Expand All @@ -115,10 +121,9 @@ typedef struct NC_DIM_INFO

typedef struct NC_ATT_INFO
{
NC_LIST_NODE_T l; /* Use generic doubly-linked list (must be first) */
int len;
char *name;
struct NC_ATT_INFO *next;
struct NC_ATT_INFO *prev;
int dirty;
int created;
nc_type xtype;
Expand All @@ -133,15 +138,14 @@ typedef struct NC_ATT_INFO
/* This is a struct to handle the var metadata. */
typedef struct NC_VAR_INFO
{
NC_LIST_NODE_T l; /* Use generic doubly-linked list (must be first) */
char *name;
char *hdf5_name; /* used if different from name */
int ndims;
int *dimids;
NC_DIM_INFO_T **dim;
int varid;
int natts;
struct NC_VAR_INFO *next;
struct NC_VAR_INFO *prev;
int dirty;
int created; /* Variable has already been created (_not_ that it was just created) */
int written_to;
Expand Down Expand Up @@ -174,8 +178,7 @@ typedef struct NC_VAR_INFO

typedef struct NC_FIELD_INFO
{
struct NC_FIELD_INFO *next;
struct NC_FIELD_INFO *prev;
NC_LIST_NODE_T l; /* Use generic doubly-linked list (must be first) */
nc_type nctype;
hid_t hdf_typeid;
hid_t native_typeid;
Expand All @@ -188,16 +191,14 @@ typedef struct NC_FIELD_INFO

typedef struct NC_ENUM_MEMBER_INFO
{
struct NC_ENUM_MEMBER_INFO *next;
struct NC_ENUM_MEMBER_INFO *prev;
NC_LIST_NODE_T l; /* Use generic doubly-linked list (must be first) */
char *name;
void *value;
} NC_ENUM_MEMBER_INFO_T;

typedef struct NC_TYPE_INFO
{
struct NC_TYPE_INFO *next;
struct NC_TYPE_INFO *prev;
NC_LIST_NODE_T l; /* Use generic doubly-linked list (must be first) */
nc_type nc_typeid;
hid_t hdf_typeid;
hid_t native_typeid;
Expand All @@ -219,11 +220,10 @@ typedef struct NC_TYPE_INFO
* parthenogenesis. */
typedef struct NC_GRP_INFO
{
NC_LIST_NODE_T l; /* Use generic doubly-linked list (must be first) */
int nc_grpid;
struct NC_GRP_INFO *parent;
struct NC_GRP_INFO *children;
struct NC_GRP_INFO *next; /* points to siblings */
struct NC_GRP_INFO *prev; /* points to siblings */
NC_VAR_INFO_T *var;
NC_DIM_INFO_T *dim;
NC_ATT_INFO_T *att;
Expand Down Expand Up @@ -291,16 +291,10 @@ int nc4_convert_type(const void *src, void *dest,
/* These functions do HDF5 things. */
int rec_detach_scales(NC_GRP_INFO_T *grp, int dimid, hid_t dimscaleid);
int nc4_open_var_grp2(NC_GRP_INFO_T *grp, int varid, hid_t *dataset);
int pg_var(NC_PG_T pg, NC *nc, int ncid, int varid, nc_type xtype, int is_long, void *ip);
int nc4_pg_var1(NC_PG_T pg, NC *nc, int ncid, int varid, const size_t *indexp,
nc_type xtype, int is_long, void *ip);
int nc4_put_vara(NC *nc, int ncid, int varid, const size_t *startp,
const size_t *countp, nc_type xtype, int is_long, void *op);
int nc4_get_vara(NC *nc, int ncid, int varid, const size_t *startp,
const size_t *countp, nc_type xtype, int is_long, void *op);
int nc4_pg_varm(NC_PG_T pg, NC *nc, int ncid, int varid, const size_t *startp,
const size_t *countp, const ptrdiff_t *stridep,
const ptrdiff_t *imapp, nc_type xtype, int is_long, void *op);
int nc4_rec_match_dimscales(NC_GRP_INFO_T *grp);
int nc4_rec_detect_need_to_preserve_dimids(NC_GRP_INFO_T *grp, int *bad_coord_orderp);
int nc4_rec_write_metadata(NC_GRP_INFO_T *grp, int bad_coord_order);
Expand Down Expand Up @@ -341,9 +335,9 @@ int nc4_get_hdf_typeid(NC_HDF5_FILE_INFO_T *h5, nc_type xtype,
int nc4_nc4f_list_add(NC *nc, const char *path, int mode);
int nc4_var_list_add(NC_VAR_INFO_T **list, NC_VAR_INFO_T **var);
int nc4_var_list_del(NC_VAR_INFO_T **list, NC_VAR_INFO_T *var);
int nc4_dim_list_add(NC_DIM_INFO_T **list);
int nc4_dim_list_add(NC_DIM_INFO_T **list, NC_DIM_INFO_T **dim);
int nc4_dim_list_del(NC_DIM_INFO_T **list, NC_DIM_INFO_T *dim);
int nc4_att_list_add(NC_ATT_INFO_T **list);
int nc4_att_list_add(NC_ATT_INFO_T **list, NC_ATT_INFO_T **att);
int nc4_type_list_add(NC_TYPE_INFO_T **list, NC_TYPE_INFO_T **new_type);
int nc4_field_list_add(NC_FIELD_INFO_T **list, int fieldid, const char *name,
size_t offset, hid_t field_hdf_typeid, hid_t native_typeid,
Expand Down
8 changes: 6 additions & 2 deletions libsrc/memio.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ memio_new(const char* path, int ioflags, off_t initialsize, ncio** nciopp, NCMEM
int status = NC_NOERR;
ncio* nciop = NULL;
NCMEMIO* memio = NULL;
int openfd = -1;

if(pagesize == 0) {

Expand Down Expand Up @@ -156,15 +155,20 @@ memio_new(const char* path, int ioflags, off_t initialsize, ncio** nciopp, NCMEM
memio->persist = fIsSet(ioflags,NC_WRITE);

if(nciopp) *nciopp = nciop;
else {
free((char*)nciop->path);
free(nciop);
}
if(memiop) *memiop = memio;
else free(memio);

done:
if(openfd >= 0) close(openfd);
return status;

fail:
if(nciop != NULL) {
if(nciop->path != NULL) free((char*)nciop->path);
free(nciop);
}
goto done;
}
Expand Down
5 changes: 0 additions & 5 deletions libsrc4/nc3stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,6 @@ nc3_inq_unlimdim(int ncid, int *unlimdimidp) {abort();}
int
nc3_show_metadata(int ncid) {abort();}

#ifdef IGNORE
int
nc3_delete_mp(const char * path, int basepe) {abort();}
#endif

int
nc3_put_att_text(int ncid, int varid, const char *name,
size_t len, const char *op) {abort();}
Expand Down
30 changes: 13 additions & 17 deletions libsrc4/nc4attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ nc4_put_att(int ncid, NC *nc, int varid, const char *name,
attlist = &grp->att;
else
{
for (var = grp->var; var; var = var->next)
for (var = grp->var; var; var = var->l.next)
if (var->varid == varid)
{
attlist = &var->att;
Expand All @@ -243,7 +243,7 @@ nc4_put_att(int ncid, NC *nc, int varid, const char *name,
if (!var)
return NC_ENOTVAR;
}
for (att = *attlist; att; att = att->next)
for (att = *attlist; att; att = att->l.next)
if (!strcmp(att->name, norm_name))
break;

Expand Down Expand Up @@ -299,20 +299,16 @@ nc4_put_att(int ncid, NC *nc, int varid, const char *name,
if (new_att)
{
LOG((3, "adding attribute %s to the list...", norm_name));
if ((res = nc4_att_list_add(attlist)))
if ((res = nc4_att_list_add(attlist, &att)))
BAIL (res);
/* Find this att's entry in the list (the last one). */
for (att=*attlist; att->next; att=att->next)
;
}

/* Now fill in the metadata. */
att->dirty++;
if (att->name)
free(att->name);
if (!(att->name = malloc((strlen(norm_name) + 1) * sizeof(char))))
if (!(att->name = strdup(norm_name)))
return NC_ENOMEM;
strcpy(att->name, norm_name);
att->xtype = file_type;

/* If this att has vlen or string data, release it before we lose the length value. */
Expand All @@ -333,8 +329,8 @@ nc4_put_att(int ncid, NC *nc, int varid, const char *name,
}

att->len = len;
if (att->prev)
att->attnum = att->prev->attnum + 1;
if (att->l.prev)
att->attnum = ((NC_ATT_INFO_T *)att->l.prev)->attnum + 1;
else
att->attnum = 0;
if (type)
Expand Down Expand Up @@ -415,7 +411,7 @@ nc4_put_att(int ncid, NC *nc, int varid, const char *name,
/* Mark the var and all its atts as dirty, so they get
* rewritten. */
var->dirty++;
for (varatt = var->att; varatt; varatt = varatt->next)
for (varatt = var->att; varatt; varatt = varatt->l.next)
varatt->dirty++;
}

Expand Down Expand Up @@ -645,7 +641,7 @@ NC4_rename_att(int ncid, int varid, const char *name,
}
else
{
for (var = grp->var; var; var = var->next)
for (var = grp->var; var; var = var->l.next)
if (var->varid == varid)
{
list = var->att;
Expand All @@ -654,14 +650,14 @@ NC4_rename_att(int ncid, int varid, const char *name,
if (!var)
return NC_ENOTVAR;
}
for (att = list; att; att = att->next)
for (att = list; att; att = att->l.next)
if (!strncmp(att->name, norm_newname, NC_MAX_NAME))
return NC_ENAMEINUSE;

/* Normalize name and find the attribute. */
if ((retval = nc4_normalize_name(name, norm_name)))
return retval;
for (att = list; att; att = att->next)
for (att = list; att; att = att->l.next)
if (!strncmp(att->name, norm_name, NC_MAX_NAME))
break;
if (!att)
Expand Down Expand Up @@ -758,7 +754,7 @@ NC4_del_att(int ncid, int varid, const char *name)
}
else
{
for(var = grp->var; var; var = var->next)
for(var = grp->var; var; var = var->l.next)
{
if (var->varid == varid)
{
Expand All @@ -775,7 +771,7 @@ NC4_del_att(int ncid, int varid, const char *name)
}

/* Now find the attribute by name or number. */
for (att = *attlist; att; att = att->next)
for (att = *attlist; att; att = att->l.next)
if (!strcmp(att->name, name))
break;

Expand All @@ -789,7 +785,7 @@ NC4_del_att(int ncid, int varid, const char *name)
BAIL(NC_EATTMETA);

/* Renumber all following attributes. */
for (natt = att->next; natt; natt = natt->next)
for (natt = att->l.next; natt; natt = natt->l.next)
natt->attnum--;

/* Delete this attribute from this list. */
Expand Down
27 changes: 13 additions & 14 deletions libsrc4/nc4dim.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ NC4_inq_unlimdim(int ncid, int *unlimdimidp)
*unlimdimidp = -1;
for (g = grp; g && !found; g = g->parent)
{
for (dim = g->dim; dim; dim = dim->next)
for (dim = g->dim; dim; dim = dim->l.next)
{
if (dim->unlimited)
{
Expand Down Expand Up @@ -98,7 +98,7 @@ NC4_def_dim(int ncid, const char *name, size_t len, int *idp)
{
/* Only one limited dimenson for strict nc3. */
if (len == NC_UNLIMITED)
for (dim = grp->dim; dim; dim = dim->next)
for (dim = grp->dim; dim; dim = dim->l.next)
if (dim->unlimited)
return NC_EUNLIMIT;

Expand All @@ -123,26 +123,25 @@ NC4_def_dim(int ncid, const char *name, size_t len, int *idp)
return NC_EDIMSIZE;

/* Make sure the name is not already in use. */
for (dim = grp->dim; dim; dim = dim->next)
for (dim = grp->dim; dim; dim = dim->l.next)
if (!strncmp(dim->name, norm_name, NC_MAX_NAME))
return NC_ENAMEINUSE;

/* Add a dimension to the list. The ID must come from the file
* information, since dimids are visible in more than one group. */
nc4_dim_list_add(&grp->dim);
grp->dim->dimid = grp->nc4_info->next_dimid++;
nc4_dim_list_add(&grp->dim, &dim);
dim->dimid = grp->nc4_info->next_dimid++;

/* Initialize the metadata for this dimension. */
if (!(grp->dim->name = malloc((strlen(norm_name) + 1) * sizeof(char))))
if (!(dim->name = strdup(norm_name)))
return NC_ENOMEM;
strcpy(grp->dim->name, norm_name);
grp->dim->len = len;
dim->len = len;
if (len == NC_UNLIMITED)
grp->dim->unlimited++;
dim->unlimited++;

/* Pass back the dimid. */
if (idp)
*idp = grp->dim->dimid;
*idp = dim->dimid;

return retval;
}
Expand Down Expand Up @@ -180,7 +179,7 @@ NC4_inq_dimid(int ncid, const char *name, int *idp)

/* Go through each dim and check for a name match. */
for (g = grp; g && !finished; g = g->parent)
for (dim = g->dim; dim; dim = dim->next)
for (dim = g->dim; dim; dim = dim->l.next)
if (!strncmp(dim->name, norm_name, NC_MAX_NAME))
{
if (idp)
Expand Down Expand Up @@ -301,12 +300,12 @@ NC4_rename_dim(int ncid, int dimid, const char *name)
return retval;

/* Make sure the new name is not already in use in this group. */
for (dim = grp->dim; dim; dim = dim->next)
for (dim = grp->dim; dim; dim = dim->l.next)
if (!strncmp(dim->name, norm_name, NC_MAX_NAME))
return NC_ENAMEINUSE;

/* Find the dim. */
for (dim = grp->dim; dim; dim = dim->next)
for (dim = grp->dim; dim; dim = dim->l.next)
if (dim->dimid == dimid)
break;
if (!dim)
Expand Down Expand Up @@ -393,7 +392,7 @@ NC4_inq_unlimdims(int ncid, int *nunlimdimsp, int *unlimdimidsp)
/* Get our dim info. */
assert(h5);
{
for (dim=grp->dim; dim; dim=dim->next)
for (dim=grp->dim; dim; dim=dim->l.next)
{
if (dim->unlimited)
{
Expand Down
Loading