mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-03-31 17:50:26 +08:00
cleanup and remove unused code
This commit is contained in:
parent
a169a8383c
commit
f5bd3bf525
4
cf
4
cf
@ -124,8 +124,8 @@ FLAGS="$FLAGS --disable-pnetcdf"
|
||||
#FLAGS="$FLAGS --enable-cxx-4"
|
||||
#FLAGS="$FLAGS --enable-dap-long-tests"
|
||||
#FLAGS="$FLAGS --enable-ffio"
|
||||
FLAGS="$FLAGS --enable-benchmarks"
|
||||
#FLAGS="$FLAGS --enable-extra-tests"
|
||||
#FLAGS="$FLAGS --enable-benchmarks"
|
||||
FLAGS="$FLAGS --enable-extra-tests"
|
||||
FLAGS="$FLAGS --enable-large-file-tests"
|
||||
FLAGS="$FLAGS --enable-logging"
|
||||
|
||||
|
@ -311,9 +311,6 @@ freenccachenode(NCDAPCOMMON* nccomm, NCcachenode* node)
|
||||
{
|
||||
if(node == NULL) return;
|
||||
oc_data_free(nccomm->oc.conn,node->content);
|
||||
#ifdef IGNORE
|
||||
oc_root_free(nccomm->oc.conn,node->ocroot);
|
||||
#endif
|
||||
dcefree((DCEnode*)node->constraint);
|
||||
freecdfroot34(node->datadds);
|
||||
nclistfree(node->vars);
|
||||
|
203
libdap2/cdf3.c
203
libdap2/cdf3.c
@ -10,15 +10,6 @@
|
||||
|
||||
CDFnode* v4node = NULL;
|
||||
|
||||
/* Define a local structure */
|
||||
#ifdef IGNORE
|
||||
struct NCregrid {
|
||||
CDFnode* template;
|
||||
CDFnode* newgrid;
|
||||
int fieldindex;
|
||||
};
|
||||
#endif
|
||||
|
||||
/* Forward*/
|
||||
static NCerror sequencecheck3r(CDFnode* node, NClist* vars, CDFnode* topseq);
|
||||
static NCerror regrid3r(CDFnode*, CDFnode*, NClist*);
|
||||
@ -122,19 +113,6 @@ fprintf(stderr,"computevarnodes: var: %s\n",makecdfpathstring3(node,"."));
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
#ifdef IGNORE
|
||||
static void
|
||||
computecdfattributes(CDFnode* node)
|
||||
{
|
||||
NClist* path = nclistnew();
|
||||
if(node->nctype == NC_Primitive) {
|
||||
/* Add in copies of the attributes of all parent nodes*/
|
||||
collectnodepath(node->container,path,WITHDATASET);
|
||||
}
|
||||
nclistfree(path);
|
||||
}
|
||||
#endif
|
||||
|
||||
NCerror
|
||||
fixgrids3(NCDAPCOMMON* nccomm)
|
||||
{
|
||||
@ -210,14 +188,6 @@ fprintf(stderr,"basevar invoked: %s\n",var->ncfullname);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef IGNORE
|
||||
/* Remove elided marks */
|
||||
for(i=0;i<nclistlength(root->tree->nodes);i++) {
|
||||
CDFnode* node = (CDFnode*)nclistget(root->tree->nodes,i);
|
||||
node->elided = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Finally, verify unique names */
|
||||
for(i=0;i<nclistlength(varnodes);i++) {
|
||||
CDFnode* var1 = (CDFnode*)nclistget(varnodes,i);
|
||||
@ -233,87 +203,6 @@ fprintf(stderr,"basevar invoked: %s\n",var->ncfullname);
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
#ifdef IGNORE
|
||||
static NClist*
|
||||
hoist(NCDAPCOMMON* nccomm, CDFnode* container)
|
||||
{
|
||||
int i,j;
|
||||
NClist* containers = nclistnew();
|
||||
NClist* unique = nclistnew();
|
||||
/* Divide the subnodes of this node into containers and unique*/
|
||||
for(i=0;i<nclistlength(container->subnodes);i++) {
|
||||
CDFnode* sub = (CDFnode*)nclistget(container->subnodes,i);
|
||||
switch (sub->nctype) {
|
||||
case NC_Structure:
|
||||
case NC_Sequence:
|
||||
case NC_Grid:
|
||||
case NC_Dataset:
|
||||
nclistpush(containers,(ncelem)sub);
|
||||
break;
|
||||
case NC_Primitive:
|
||||
nclistpush(unique,(ncelem)sub);
|
||||
break;
|
||||
default: PANIC1("computecdfvarnames: bad node type: %d",sub->nctype);
|
||||
}
|
||||
}
|
||||
|
||||
/* Tentatively hoist each container in turn*/
|
||||
while(nclistlength(containers) > 0) {
|
||||
CDFnode* subcontainer = (CDFnode*)nclistremove(containers,0);
|
||||
NClist* vars = hoist(nccomm,subcontainer);
|
||||
int match;
|
||||
/* compute path names without this container*/
|
||||
subcontainer->elided = 1;
|
||||
if(ncdap3debug > 1) fprintf(stderr,"eliding: %s\n",subcontainer->name);
|
||||
makevarnames(nccomm,vars);
|
||||
/* look for duplicates in the unique list*/
|
||||
match = 0;
|
||||
for(i=0;i<nclistlength(unique);i++) {
|
||||
CDFnode* unode = (CDFnode*)nclistget(unique,i);
|
||||
for(j=0;j<nclistlength(vars);j++) {
|
||||
CDFnode* var = (CDFnode*)nclistget(vars,j);
|
||||
if(strcmp(var->ncfullname,unode->ncfullname)==0) {
|
||||
match = 1;
|
||||
if(ncdap3debug > 1) fprintf(stderr,"match: %s\n",var->ncfullname);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(match) break;
|
||||
}
|
||||
if(match) {
|
||||
/* Since our goal is to hoist all the vars in a compound type or none,*/
|
||||
/* match => we have a collision, so restore the path name of the vars*/
|
||||
/* to include their container*/
|
||||
subcontainer->elided = 0;
|
||||
makevarnames(nccomm,vars);
|
||||
}
|
||||
/* Add the subcontainer vars to our list of uniquely named vars*/
|
||||
for(i=0;i<nclistlength(vars);i++) {
|
||||
CDFnode* var = (CDFnode*)nclistget(vars,i);
|
||||
nclistpush(unique,(ncelem)var);
|
||||
}
|
||||
nclistfree(vars);
|
||||
}
|
||||
nclistfree(containers);
|
||||
return unique;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef UNUSED
|
||||
static void
|
||||
makevarnames(NCDAPCOMMON* nccomm, NClist* vars)
|
||||
{
|
||||
int i;
|
||||
for(i=0;i<nclistlength(vars);i++) {
|
||||
CDFnode* var = (CDFnode*)nclistget(vars,i);
|
||||
nullfree(var->ncfullname);
|
||||
var->ncfullname = makecdfpathstring3(var,nccomm->cdf.separator);
|
||||
if(var==v4node && var->ncfullname[0] != 'Q')dappanic("");
|
||||
if(ncdap3debug > 1)
|
||||
fprintf(stderr,"makevarname: %s->ncfullname=%s\n",var->name,var->ncfullname);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* locate and connect usable sequences and vars.
|
||||
A sequence is usable iff:
|
||||
@ -634,56 +523,6 @@ regridremove(CDFnode* newgrid, CDFnode* node)
|
||||
return NC_EINVAL;
|
||||
}
|
||||
|
||||
#ifdef IGNORE
|
||||
static void
|
||||
regridclean3(NClist* nodes, struct NCregrid* gridnodes)
|
||||
{
|
||||
int i;
|
||||
NCregrid* ncregrid;
|
||||
|
||||
for(i=0;i<nclistlength(nodes);i++) {
|
||||
CDFnode* node = (CDFnode*)nclistget(nodes,i);
|
||||
/* See if this node is a newgrid */
|
||||
ncregrid = gridnodes;
|
||||
while(ncregrid->newgrid != NULL && ncregrid->newgrid != node) ncregrid++;
|
||||
if(ncregrid->newgrid == node) continue; /* no need to process this */
|
||||
for(i=nclistlength(node->subnodes)-1;i>=0;i--) { /* walk backwards */
|
||||
CDFnode* subnode = (CDFnode*)nclistget(node->subnodes,i);
|
||||
/* Remove any subnodes of this node that now point to a regrid node */
|
||||
ncregrid = gridnodes;
|
||||
while(ncregrid->newgrid != NULL && ncregrid->newgrid != subnode) ncregrid++;
|
||||
/* Found, remove from this list */
|
||||
if(ncregrid->newgrid != NULL) nclistremove(node->subnodes,i);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef IGNORE
|
||||
/*
|
||||
Given a node in some constrained
|
||||
DDS or DATADDS tree,
|
||||
return the equivalent node from the
|
||||
unconstrained DDS tree.
|
||||
*/
|
||||
|
||||
CDFnode*
|
||||
findddsnode0(CDFnode* node)
|
||||
{
|
||||
if(!node->root->tree->constrained)
|
||||
return node; /* node is already
|
||||
from unconstrained tree */
|
||||
if(node->attachment0 == NULL
|
||||
&& node->attachment != NULL)
|
||||
node = node->attachment; /* DATADDS node -> DDS node */
|
||||
|
||||
if(node->attachment0 == NULL)
|
||||
return NULL; /* cannot reach the unconstrained tree */
|
||||
|
||||
return node->attachment0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
||||
Make the constrained dds nodes (root)
|
||||
@ -753,28 +592,6 @@ mapfcn(CDFnode* dstnode, CDFnode* srcnode)
|
||||
/* Mark node as having been mapped */
|
||||
dstnode->visible = 1;
|
||||
dstnode->basenode = srcnode;
|
||||
#ifdef IGNORE
|
||||
/* Do dimension imprinting */
|
||||
ASSERT((nclistlength(dstnode->array.dimsetplus) == nclistlength(srcnode->array.dimsetplus)));
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"mapfcn: %s(%d)\n",
|
||||
makecdfpathstring3(srcnode,"."),
|
||||
nclistlength(srcnode->array.dimsetplus));
|
||||
#endif
|
||||
if(nclistlength(dstnode->array.dimset0) > 0) {
|
||||
unsigned int i;
|
||||
for(i=0;i<nclistlength(dstnode->array.dimset0);i++) {
|
||||
CDFnode* ddim = (CDFnode*)nclistget(dstnode->array.dimset0,i);
|
||||
CDFnode* sdim = (CDFnode*)nclistget(srcnode->array.dimset0,i);
|
||||
ddim->basenode = sdim;
|
||||
ddim->visible = 1;
|
||||
ddim->dim.declsize0 = sdim->dim.declsize;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"mapfcn: %d: %lu -> %lu\n",i,sdim->dim.declsize,ddim->dim.declsize0);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif /*IGNORE*/
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
@ -832,26 +649,6 @@ fprintf(stderr,"dimimprint: %d: %lu -> %lu\n",i,basedim->dim.declsize,dim->dim.d
|
||||
return ncstat;
|
||||
}
|
||||
|
||||
#ifdef IGNORE
|
||||
void
|
||||
setvisible(CDFnode* root, int visible)
|
||||
{
|
||||
unsigned int i;
|
||||
CDFtree* tree = root->tree;
|
||||
for(i=0;i<nclistlength(tree->nodes);i++) {
|
||||
CDFnode* node = (CDFnode*)nclistget(tree->nodes,i);
|
||||
node->visible = visible;
|
||||
}
|
||||
}
|
||||
|
||||
NCerror
|
||||
imprintself3(CDFnode* root)
|
||||
{
|
||||
setvisible(root,1);
|
||||
return NC_NOERR;
|
||||
}
|
||||
#endif
|
||||
|
||||
static CDFnode*
|
||||
clonedim(NCDAPCOMMON* nccomm, CDFnode* dim, CDFnode* var)
|
||||
{
|
||||
|
@ -40,10 +40,6 @@ fix1node34(NCDAPCOMMON* nccomm, CDFnode* node)
|
||||
if(node->ncfullname == NULL) return NC_ENOMEM;
|
||||
if(node->nctype == NC_Primitive)
|
||||
node->externaltype = nctypeconvert(nccomm,node->etype);
|
||||
#ifdef IGNORE
|
||||
if(node->nctype == NC_Dimension)
|
||||
node->maxstringlength = nccomm->cdf.defaultstringlength;
|
||||
#endif
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
@ -59,36 +55,6 @@ fixnodes34(NCDAPCOMMON* nccomm, NClist* cdfnodes)
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
#ifdef IGNORE
|
||||
NCerror
|
||||
computecdfinfo34(NCDAPCOMMON* nccomm, NClist* cdfnodes)
|
||||
{
|
||||
int i;
|
||||
/* Ensure every node has an initial base name defined and fullname */
|
||||
/* Exceptions: anonymous dimensions. */
|
||||
for(i=0;i<nclistlength(cdfnodes);i++) {
|
||||
CDFnode* node = (CDFnode*)nclistget(cdfnodes,i);
|
||||
if(node->nctype == NC_Dimension && node->name == NULL) continue;
|
||||
ASSERT((node->name != NULL));
|
||||
nullfree(node->ncbasename);
|
||||
node->ncbasename = cdflegalname3(node->name);
|
||||
nullfree(node->ncfullname);
|
||||
node->ncfullname = makecdfpathstring3(node,nccomm->cdf.separator);
|
||||
if(node==v4node && node->ncfullname[0] != 'Q')dappanic("");
|
||||
}
|
||||
for(i=0;i<nclistlength(cdfnodes);i++) {
|
||||
CDFnode* node = (CDFnode*)nclistget(cdfnodes,i);
|
||||
if(node->nctype == NC_Primitive)
|
||||
node->externaltype = nctypeconvert(node->etype);
|
||||
}
|
||||
for(i=0;i<nclistlength(cdfnodes);i++) {
|
||||
CDFnode* node = (CDFnode*)nclistget(cdfnodes,i);
|
||||
if(node->nctype != NC_Dimension) continue;
|
||||
node->maxstringlength = nccomm->cdf.defaultstringlength;
|
||||
}
|
||||
return NC_NOERR;
|
||||
}
|
||||
#endif
|
||||
|
||||
NCerror
|
||||
fixgrid34(NCDAPCOMMON* nccomm, CDFnode* grid)
|
||||
@ -153,55 +119,6 @@ invalid:
|
||||
return NC_EINVAL; /* mal-formed grid */
|
||||
}
|
||||
|
||||
|
||||
#ifdef IGNORE
|
||||
static void
|
||||
cloneseqdims(NCDAPCOMMON* nccomm, NClist* dimset, CDFnode* var)
|
||||
{
|
||||
int i;
|
||||
for(i=0;i<nclistlength(dimset);i++) {
|
||||
CDFnode* dim = (CDFnode*)nclistget(dimset,i);
|
||||
if(DIMFLAG(dim,CDFDIMSEQ))
|
||||
nclistset(dimset,i,(ncelem)clonedim(nccomm,dim,var));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef IGNORE
|
||||
/* Compute the dimsetall for the given node; do not assume
|
||||
parent container dimsetall is defined
|
||||
*/
|
||||
int
|
||||
getcompletedimset3(CDFnode* var, NClist* dimset)
|
||||
{
|
||||
int i,j;
|
||||
NClist* path = nclistnew();
|
||||
CDFnode* node;
|
||||
|
||||
nclistclear(dimset);
|
||||
/* Get the inherited dimensions first*/
|
||||
collectnodepath3(var,path,WITHOUTDATASET);
|
||||
for(i=0;i<nclistlength(path)-1;i++) {
|
||||
node = (CDFnode*)nclistget(path,i);
|
||||
for(j=0;j<nclistlength(node->array.dimsetplus);jj++) {
|
||||
CDFnode* dim = (CDFnode*)nclistget(node->array.dimset,j);
|
||||
nclistpush(dimset,(ncelem)dim);
|
||||
}
|
||||
}
|
||||
inherited = nclistlength(dimset); /* mark the # of inherited dimensions */
|
||||
/* Now add the base dimensions */
|
||||
node = (CDFnode*)nclistpop(path);
|
||||
for(j=0;j<nclistlength(node->array.dimsetplus);j++) {
|
||||
CDFnode* dim = (CDFnode*)nclistget(node->array.dimset0,j);
|
||||
nclistpush(dimset,(ncelem)dim);
|
||||
}
|
||||
nclistfree(path);
|
||||
return inherited;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Given an anonymous dimension, compute the
|
||||
* effective 0-based index wrt to the specified var.
|
||||
@ -363,23 +280,6 @@ fprintf(stderr,"conflict: %s[%lu] %s[%lu]\n",
|
||||
/* cleanup */
|
||||
nclistfree(alldims);
|
||||
|
||||
#ifdef IGNORE
|
||||
/* Process record dim */
|
||||
if(nccomm->cdf.unlimited != NULL && DIMFLAG(nccomm->cdf.unlimited,CDFDIMRECORD)) {
|
||||
CDFnode* recdim = nccomm->cdf.unlimited;
|
||||
for(i=0;i<nclistlength(alldims);i++) {
|
||||
int match;
|
||||
CDFnode* dupdim = (CDFnode*)nclistget(alldims,i);
|
||||
if(dupdim->dim.basedim != NULL) continue; /* already processed */
|
||||
match = (strcmp(dupdim->ncfullname,recdim->ncfullname) == 0
|
||||
&& dupdim->dim.declsize == recdim->dim.declsize);
|
||||
if(match) {
|
||||
dupdim->dim.basedim = recdim;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Assign ncbasenames and ncfullnames to base dimensions */
|
||||
for(i=0;i<nclistlength(basedims);i++) {
|
||||
CDFnode* dim = (CDFnode*)nclistget(basedims,i);
|
||||
@ -595,9 +495,6 @@ defdimensions(OCobject ocnode, CDFnode* cdfnode, NCDAPCOMMON* nccomm, CDFtree* t
|
||||
nclistpush(tree->nodes,(ncelem)cdfdim);
|
||||
/* Initially, constrained and unconstrained are same */
|
||||
cdfdim->dim.declsize = declsize;
|
||||
#ifdef IGNORE
|
||||
cdfdim->dim.declsize0 = declsize;
|
||||
#endif
|
||||
cdfdim->dim.array = cdfnode;
|
||||
if(cdfnode->array.dimset0 == NULL)
|
||||
cdfnode->array.dimset0 = nclistnew();
|
||||
@ -814,55 +711,6 @@ in a DATADDS that matches the DDS node.
|
||||
Return NULL if no node found
|
||||
*/
|
||||
|
||||
#ifdef IGNORE
|
||||
static CDFnode*
|
||||
findxnode34r(NClist* path, int depth, CDFnode* xnode)
|
||||
{
|
||||
unsigned int i;
|
||||
CDFnode* pathnode;
|
||||
unsigned int len = nclistlength(path);
|
||||
int lastnode = (depth == (len - 1));
|
||||
|
||||
if(depth >= len) return NULL;
|
||||
|
||||
pathnode = (CDFnode*)nclistget(path,depth);
|
||||
|
||||
/* If this path element matches the current xnode, then recurse */
|
||||
if(nodematch34(pathnode,xnode)) {
|
||||
if(lastnode) return xnode;
|
||||
for(i=0;i<nclistlength(xnode->subnodes);i++) {
|
||||
CDFnode* xsubnode = (CDFnode*)nclistget(xnode->subnodes,i);
|
||||
CDFnode* matchnode;
|
||||
matchnode = findxnode34r(path,depth+1,xsubnode);
|
||||
if(matchnode != NULL) return matchnode;
|
||||
}
|
||||
} else
|
||||
/* Ok, we have a node mismatch; normally return NULL,
|
||||
but must handle the special case of an elided Grid.
|
||||
*/
|
||||
if(pathnode->nctype == NC_Grid && xnode->nctype == NC_Primitive) {
|
||||
/* Try to match the xnode to one of the subparts of the grid */
|
||||
CDFnode* matchnode;
|
||||
matchnode = findxnode34r(path,depth+1,xnode);
|
||||
if(matchnode != NULL) return matchnode;
|
||||
}
|
||||
/* Could not find node, return NULL */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
CDFnode*
|
||||
findxnode34(CDFnode* target, CDFnode* xroot)
|
||||
{
|
||||
CDFnode* xtarget = NULL;
|
||||
NClist* path = nclistnew();
|
||||
collectnodepath3(target,path,WITHDATASET);
|
||||
xtarget = findxnode34r(path,0,xroot);
|
||||
nclistfree(path);
|
||||
return xtarget;
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
unattach34(CDFnode* root)
|
||||
{
|
||||
@ -1035,58 +883,6 @@ done:
|
||||
return THROW(ncstat);
|
||||
}
|
||||
|
||||
#ifdef IGNORE
|
||||
/* Attach all dstnodes to all templates; all dstnodes must match */
|
||||
static NCerror
|
||||
attachall34r(CDFnode* dstnode, CDFnode* srcnode)
|
||||
{
|
||||
unsigned int i;
|
||||
NCerror ncstat = NC_NOERR;
|
||||
|
||||
ASSERT((nodematch34(dstnode,srcnode)));
|
||||
setattach(dstnode,srcnode);
|
||||
|
||||
if(dstnode->array.rank > 0) {
|
||||
attachdims34(dstnode,srcnode);
|
||||
}
|
||||
|
||||
/* Try to match dstnode subnodes against srcnode subnodes */
|
||||
if(nclistlength(dstnode->subnodes) != nclistlength(srcnode->subnodes))
|
||||
{THROWCHK(ncstat=NC_EINVAL); goto done;}
|
||||
|
||||
for(i=0;i<nclistlength(dstnode->subnodes);i++) {
|
||||
CDFnode* dstsubnode = (CDFnode*)nclistget(dstnode->subnodes,i);
|
||||
CDFnode* srcsubnode = (CDFnode*)nclistget(srcnode->subnodes,i);
|
||||
if(!nodematch34(dstsubnode,srcsubnode))
|
||||
{THROWCHK(ncstat=NC_EINVAL); goto done;}
|
||||
ncstat = attachall34r(dstsubnode,srcsubnode);
|
||||
if(ncstat) goto done;
|
||||
}
|
||||
done:
|
||||
return THROW(ncstat);
|
||||
}
|
||||
|
||||
/*
|
||||
Match nodes in one tree to nodes in another.
|
||||
Usually used to attach the DATADDS to the DDS,
|
||||
but not always.
|
||||
*/
|
||||
NCerror
|
||||
attachall34(CDFnode* dstroot, CDFnode* srcroot)
|
||||
{
|
||||
NCerror ncstat = NC_NOERR;
|
||||
|
||||
if(dstroot->attachment) unattach34(dstroot);
|
||||
if(srcroot != NULL && srcroot->attachment) unattach34(srcroot);
|
||||
if(!nodematch34(dstroot,srcroot)) {THROWCHK(ncstat=NC_EINVAL); goto done;}
|
||||
ncstat = attachall34r(dstroot,srcroot);
|
||||
done:
|
||||
return ncstat;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
static void
|
||||
getalldims34a(NClist* dimset, NClist* alldims)
|
||||
{
|
||||
|
@ -38,19 +38,6 @@ parsedapconstraints(NCDAPCOMMON* dapcomm, char* constraints,
|
||||
nullfree(errmsg);
|
||||
nclistclear(dceconstraint->projections);
|
||||
nclistclear(dceconstraint->selections);
|
||||
} else {
|
||||
#ifdef IGNORE
|
||||
int i;
|
||||
#ifdef DEBUG
|
||||
NClist* allnodes;
|
||||
fprintf(stderr,"constraint: %s",dumpconstraint(dceconstraint));
|
||||
#endif
|
||||
/* Go thru each node and add annotation */
|
||||
allnodes = dceallnodes((DCEnode*)dceconstraint,CES_NIL);
|
||||
for(i=0;i<nclistlength(allnodes);i++) {
|
||||
DCEnode* node = (DCEnode*)nclistget(allnodes,i);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return ncstat;
|
||||
}
|
||||
@ -81,31 +68,6 @@ mapconstraints3(DCEconstraint* constraint,
|
||||
if(ncstat) goto done;
|
||||
}
|
||||
|
||||
#ifdef IGNORE
|
||||
Only care about projections
|
||||
/* Convert the selection paths to leaves in the dds tree */
|
||||
for(i=0;i<nclistlength(dceselections);i++) {
|
||||
DCEselection* sel = (DCEselection*)nclistget(dceselections,i);
|
||||
if(sel->lhs->discrim != CES_VAR) continue;
|
||||
ncstat = matchpartialname3(nodes,sel->lhs->var->segments,
|
||||
(CDFnode**)&sel->lhs->var->annotation);
|
||||
if(ncstat) goto done;
|
||||
}
|
||||
|
||||
/* Convert the selection path values to leaves in the dds tree */
|
||||
for(i=0;i<nclistlength(dceselections);i++) {
|
||||
int j;
|
||||
DCEselection* sel = (DCEselection*)nclistget(dceselections,i);
|
||||
for(j=0;j<nclistlength(sel->rhs);j++) {
|
||||
DCEvalue* value = (DCEvalue*)nclistget(sel->rhs,j);
|
||||
if(value->discrim != CES_VAR) continue;
|
||||
ncstat = matchpartialname3(nodes,value->var->segments,
|
||||
(CDFnode**)&value->var->annotation);
|
||||
if(ncstat) goto done;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"mapconstraint.projections: %s\n",
|
||||
dumpprojections(dceprojections));
|
||||
@ -136,12 +98,6 @@ fprintf(stderr,"qualifyconstraints.before: %s\n",
|
||||
ncstat = qualifyprojectionnames3(p);
|
||||
ncstat = qualifyprojectionsizes3(p);
|
||||
}
|
||||
#ifdef IGNORE
|
||||
for(i=0;i<nclistlength(constraint->selections);i++) {
|
||||
DCEselection* s = (DCEselection*)nclistget(constraint->selections,i);
|
||||
ncstat = qualifyselectionnames3(s);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"qualifyconstraints.after: %s\n",
|
||||
@ -216,37 +172,6 @@ fprintf(stderr,"qualifyprojectionsizes.after: %s\n",
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
#ifdef IGNORE
|
||||
/* convert all names in selections to be fully qualified */
|
||||
static NCerror
|
||||
qualifyselectionnames3(DCEselection* sel)
|
||||
{
|
||||
NCerror ncstat = NC_NOERR;
|
||||
int i;
|
||||
NClist* segments = NULL;
|
||||
NClist* fullpath = nclistnew();
|
||||
|
||||
ASSERT(sel->lhs->discrim == CES_VAR);
|
||||
collectnodepath3((CDFnode*)sel->lhs->var->annotation,fullpath,!WITHDATASET);
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"qualify.sel: %s -> ",
|
||||
dumpselection(sel));
|
||||
#endif
|
||||
/* Now add path nodes to create full path */
|
||||
completesegments3(fullpath,sel->lhs->var->segments);
|
||||
for(i=0;i<nclistlength(sel->rhs);i++) {
|
||||
DCEvalue* value = (DCEvalue*)nclistget(sel->rhs,i);
|
||||
if(value->discrim != CES_VAR) continue;
|
||||
nclistclear(fullpath);
|
||||
collectnodepath3((CDFnode*)value->var->annotation,fullpath,!WITHDATASET);
|
||||
completesegments3(fullpath,value->var->segments);
|
||||
}
|
||||
nclistfree(segments);
|
||||
nclistfree(fullpath);
|
||||
return THROW(ncstat);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
completesegments3(NClist* fullpath, NClist* segments)
|
||||
{
|
||||
@ -260,12 +185,6 @@ completesegments3(NClist* fullpath, NClist* segments)
|
||||
seg->name = nulldup(node->ocname);
|
||||
seg->annotation = (void*)node;
|
||||
seg->rank = nclistlength(node->array.dimset0);
|
||||
#ifdef IGNORE
|
||||
for(j=0;j<seg->rank;j++) {
|
||||
CDFnode* dim = (CDFnode*)nclistget(node->array.dimset0,j);
|
||||
dcemakewholeslice(seg->slices+j,dim->dim.declsize);
|
||||
}
|
||||
#endif
|
||||
nclistinsert(segments,i,(ncelem)seg);
|
||||
}
|
||||
/* Now modify the segments to point to the appropriate node
|
||||
@ -275,11 +194,6 @@ completesegments3(NClist* fullpath, NClist* segments)
|
||||
DCEsegment* seg = (DCEsegment*)nclistget(segments,i);
|
||||
CDFnode* node = (CDFnode*)nclistget(fullpath,i);
|
||||
seg->annotation = (void*)node;
|
||||
#ifdef IGNORE
|
||||
if(!seg->slicesdefined) {
|
||||
makewholesegment3(seg,node);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -536,9 +450,6 @@ fprintf(stderr,"buildvaraprojection: %s\n",dumpprojection(projection));
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"buildvaraprojection.final: %s\n",dumpprojection(projection));
|
||||
#endif
|
||||
#ifdef IGNORE
|
||||
removepseudodims3(projection);
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"buildvaraprojection3: projection=%s\n",
|
||||
@ -552,40 +463,6 @@ fprintf(stderr,"buildvaraprojection3: projection=%s\n",
|
||||
return ncstat;
|
||||
}
|
||||
|
||||
#ifdef IGNORE
|
||||
static void
|
||||
removepseudodims3(DCEprojection* clone)
|
||||
{
|
||||
int i;
|
||||
int nsegs;
|
||||
DCEsegment* seg;
|
||||
|
||||
ASSERT((clone != NULL));
|
||||
nsegs = nclistlength(clone->var->segments);
|
||||
|
||||
/* 1. scan for sequences and remove any index projections. */
|
||||
|
||||
for(i=0;i<nsegs;i++) {
|
||||
seg = (DCEsegment*)nclistget(clone->var->segments,i);
|
||||
if(seg->cdfnode->nctype != NC_Sequence) continue; /* not a sequence */
|
||||
seg->rank = 0;
|
||||
}
|
||||
|
||||
/* 2. Check the terminal segment to see if it is a String primitive,
|
||||
and if so, then remove the string dimension
|
||||
*/
|
||||
if(nsegs > 0) {
|
||||
seg = (DCEsegment*)nclistget(clone->var->segments,nsegs-1);
|
||||
/* See if the node has a string dimension */
|
||||
if(seg->cdfnode->nctype == NC_Primitive
|
||||
&& seg->cdfnode->array.stringdim != NULL) {
|
||||
/* Remove the string dimension projection from the segment */
|
||||
seg->rank--;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
iswholeslice(DCEslice* slice, CDFnode* dim)
|
||||
{
|
||||
|
@ -87,19 +87,6 @@ It seems to work for HDF5 for a wide variety of machines.
|
||||
|
||||
#define NCCTYPECOUNT (NCCTYPENCVLEN+1)
|
||||
|
||||
#ifdef IGNORE
|
||||
static char* ncctypenames[NCCTYPECOUNT] = {
|
||||
(char*)NULL,
|
||||
"char","unsigned char",
|
||||
"short","unsigned short",
|
||||
"int","unsigned int",
|
||||
"long","unsigned long",
|
||||
"long long","unsigned long long",
|
||||
"float","double",
|
||||
"void*","alignvlen_t"
|
||||
};
|
||||
#endif
|
||||
|
||||
static NCtypealignvec vec[NCCTYPECOUNT];
|
||||
static NCtypealignset set;
|
||||
static int dapaligninit = 0;
|
||||
|
@ -13,50 +13,6 @@ static NCerror buildattribute(char*,nc_type,NClist*,NCattribute**);
|
||||
static int mergedas1(NCDAPCOMMON*, OCconnection, CDFnode* dds, OCobject das);
|
||||
static int isglobalname3(char* name);
|
||||
|
||||
#ifdef IGNORE
|
||||
/* Extract attributes from the underlying oc objects
|
||||
and rematerialize them with the CDFnodes.
|
||||
*/
|
||||
|
||||
NCerror
|
||||
dapmerge3(NCDAPCOMMON* nccomm, CDFnode* node)
|
||||
{
|
||||
unsigned int i;
|
||||
char* aname;
|
||||
unsigned int nvalues,nattrs;
|
||||
void* values;
|
||||
OCtype atype;
|
||||
OCerror ocstat = OC_NOERR;
|
||||
NCerror ncstat = NC_NOERR;
|
||||
NCattribute* att;
|
||||
|
||||
if(node->dds == OCNULL) goto done;
|
||||
OCHECK(oc_inq_nattr(nccomm->conn,node->dds,&nattrs));
|
||||
if(nattrs == 0) goto done;
|
||||
if(node->attributes == NULL) node->attributes = nclistnew();
|
||||
for(i=0;i<nattrs;i++) {
|
||||
ocstat = oc_inq_attr(nccomm->conn,node->dds,i,
|
||||
&aname,
|
||||
&atype,
|
||||
&nvalues,
|
||||
&values);
|
||||
if(ocstat != OC_NOERR) continue; /* ignore */
|
||||
if(aname == NULL || nvalues == 0 || values == NULL)
|
||||
continue; /* nothing to do */
|
||||
ncstat = buildattribute(aname,octypetonc(atype),
|
||||
nvalues,values,&att);
|
||||
if(ncstat == NC_NOERR)
|
||||
nclistpush(node->attributes,(ncelem)att);
|
||||
nullfree(aname);
|
||||
oc_attr_reclaim(atype,nvalues,values);
|
||||
}
|
||||
done:
|
||||
if(ocstat != OC_NOERR) ncstat = ocerrtoncerr(ocstat);
|
||||
return THROW(ncstat);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static NCerror
|
||||
buildattribute(char* name, nc_type ptype,
|
||||
NClist* values, NCattribute** attp)
|
||||
@ -76,36 +32,6 @@ buildattribute(char* name, nc_type ptype,
|
||||
return THROW(ncstat);
|
||||
}
|
||||
|
||||
#ifdef IGNORE
|
||||
static NCerror
|
||||
cvttype(nc_type etype, char** srcp, char** dstp)
|
||||
{
|
||||
unsigned int typesize = nctypesizeof(etype);
|
||||
char* src = *srcp;
|
||||
char* dst = *dstp;
|
||||
|
||||
switch (etype) {
|
||||
case NC_STRING: case NC_URL: {
|
||||
char* ssrc = *(char**)src;
|
||||
*((char**)dst) = nulldup(ssrc);
|
||||
srcp += typesize;
|
||||
dstp += typesize;
|
||||
} break;
|
||||
|
||||
default:
|
||||
if(typesize == 0) goto fail;
|
||||
memcpy((void*)dst,(void*)src,typesize);
|
||||
srcp += typesize;
|
||||
dstp += typesize;
|
||||
break;
|
||||
}
|
||||
return NC_NOERR;
|
||||
fail:
|
||||
nclog(NCLOGERR,"cvttype bad value: %s",oc_typetostring(etype));
|
||||
return NC_EINVAL;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
Given a das attribute walk it to see if it
|
||||
has at least 1 actual attribute (no recursion)
|
||||
@ -400,46 +326,6 @@ done:
|
||||
return THROW(ncstat);
|
||||
}
|
||||
|
||||
#ifdef IGNORE
|
||||
static NCerror
|
||||
dodsextra3(NCDAPCOMMON* nccomm, NCattribute* att)
|
||||
{
|
||||
int i,j;
|
||||
OCtype octype;
|
||||
NCerror ncstat = NC_NOERR;
|
||||
OCerror ocstat = OC_NOERR;
|
||||
|
||||
for(i=0;i<nclistlength(dodsextra);i++) {
|
||||
OCobject das = (OCobject)nclistget(dodsextra,i);
|
||||
unsigned int ndodsnodes;
|
||||
OCobject* dodsnodes = NULL;
|
||||
OCHECK(oc_inq_class(conn,das,&octype));
|
||||
if(octype != OC_Attributeset) continue;
|
||||
/* Get the attributes within the DODS_EXTRA */
|
||||
OCHECK(oc_inq_nsubnodes(conn,das,&ndodsnodes));
|
||||
OCHECK(oc_inq_subnodes(conn,das,&dodsnodes));
|
||||
for(j=0;j<ndodsnodes;j++) {
|
||||
OCobject extranode = dodsnodes[j];
|
||||
char* dodsname = NULL;
|
||||
char* stringval;
|
||||
unsigned int ocnvalues;
|
||||
OCHECK(oc_inq_class(conn,extranode,&octype));
|
||||
if(octype != OC_Attribute) continue;
|
||||
OCHECK(oc_inq_name(conn,extranode,&dodsname));
|
||||
OCHECK(oc_inq_dasattr_nvalues(conn,extranode,&ocnvalues));
|
||||
if(strcmp(dodsname,"Unlimited_Dimension")==0 && ocnvalues > 0) {
|
||||
OCHECK(oc_inq_dasattr(conn,extranode,0,NULL,&stringval));
|
||||
nccomm->cdf.recorddimname = stringval;
|
||||
}
|
||||
nullfree(dodsname);
|
||||
}
|
||||
nullfree(dodsnodes);
|
||||
}
|
||||
done:
|
||||
return ncstat;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
isglobalname3(char* name)
|
||||
{
|
||||
|
@ -349,20 +349,6 @@ dumptreer(CDFnode* root, NCbytes* buf, int indent, int visible)
|
||||
default: break;
|
||||
}
|
||||
|
||||
#ifdef IGNORE
|
||||
if(root->nctype == NC_Sequence && root->array.seqdim != NULL) {
|
||||
CDFnode* dim = root->array.seqdim;
|
||||
char tmp[64];
|
||||
ncbytescat(buf,"[");
|
||||
if(dim->ncbasename != NULL) {
|
||||
ncbytescat(buf,dim->ncbasename);
|
||||
ncbytescat(buf,"=");
|
||||
}
|
||||
snprintf(tmp,sizeof(tmp),"%lu",(unsigned long)dim->dim.declsize);
|
||||
ncbytescat(buf,tmp);
|
||||
ncbytescat(buf,"]");
|
||||
} else
|
||||
#endif
|
||||
if(nclistlength(root->array.dimsetplus) > 0) dimset = root->array.dimsetplus;
|
||||
else if(nclistlength(root->array.dimset0) > 0) dimset = root->array.dimset0;
|
||||
if(dimset != NULL) {
|
||||
@ -489,11 +475,6 @@ dumpnode(CDFnode* node)
|
||||
snprintf(tmp,sizeof(tmp)," declsize=%lu\n",
|
||||
(unsigned long)dim->dim.declsize);
|
||||
ncbytescat(buf,tmp);
|
||||
#ifdef IGNORE
|
||||
snprintf(tmp,sizeof(tmp)," declsize0=%lu\n",
|
||||
(unsigned long)dim->dim.declsize0);
|
||||
ncbytescat(buf,tmp);
|
||||
#endif
|
||||
snprintf(tmp,sizeof(tmp)," }\n");
|
||||
ncbytescat(buf,tmp);
|
||||
}
|
||||
|
@ -163,26 +163,6 @@ dapodometerpoints(Dapodometer* odom)
|
||||
return count;
|
||||
}
|
||||
|
||||
#ifdef IGNORE
|
||||
/*
|
||||
Return an dapodometer that covers the last tail
|
||||
elements in the input dapodometer and removes
|
||||
them from the input dapodometer.
|
||||
*/
|
||||
Dapodometer*
|
||||
dapodometersplit(Dapodometer* odom, int tail)
|
||||
{
|
||||
int i;
|
||||
Dapodometer* split = (Dapodometer*)calloc(1,sizeof(Dapodometer));
|
||||
MEMCHECK(split,NULL);
|
||||
assert(odom->rank >= tail);
|
||||
split->rank = tail;
|
||||
odom->rank = odom->rank - tail;
|
||||
for(i=0;i<tail;i++) {split->slices[i] = odom->slices[odom->rank+i];}
|
||||
return split;
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
dapodometerincr(Dapodometer* odom)
|
||||
{
|
||||
|
@ -47,17 +47,6 @@ nc__testurl(const char* path, char** basenamep)
|
||||
|
||||
/**************************************************/
|
||||
|
||||
#ifdef UNUSED
|
||||
static char cvtchars1[] = "0123456789 !#$%&'()*,:;<=>?[\\]^`{|}~\"\\";
|
||||
|
||||
static char hexchars[16] = {
|
||||
'0', '1', '2', '3',
|
||||
'4', '5', '6', '7',
|
||||
'8', '9', 'a', 'b',
|
||||
'c', 'd', 'e', 'f',
|
||||
};
|
||||
#endif
|
||||
|
||||
/*
|
||||
Given a legal dap name with arbitrary characters,
|
||||
convert to equivalent legal cdf name
|
||||
@ -68,75 +57,9 @@ does nothing.
|
||||
char*
|
||||
cdflegalname3(char* dapname)
|
||||
{
|
||||
#ifndef IGNORE
|
||||
return nulldup(dapname);
|
||||
#else
|
||||
int c;
|
||||
char* newname;
|
||||
char* cvtchars;
|
||||
NCbytes* buf;
|
||||
if(dapname == NULL) return NULL;
|
||||
buf = ncbytesnew();
|
||||
cvtchars = cvtchars1;
|
||||
while((c=*dapname++)) {
|
||||
if(c < 127 && strchr(cvtchars,c) != NULL) {
|
||||
ncbytesappend(buf,'\\');
|
||||
ncbytesappend(buf,c);
|
||||
} else if(c < ' ' || c >= 127) {/* non-printable */
|
||||
char tmp[8];
|
||||
int hex1, hex2;
|
||||
hex1 = (c & 0x0F);
|
||||
hex2 = (c & 0xF0) >> 4;
|
||||
tmp[0] = '\\';
|
||||
tmp[1] = 'x';
|
||||
tmp[2] = hexchars[hex2];
|
||||
tmp[3] = hexchars[hex1];
|
||||
tmp[4] = '\0';
|
||||
ncbytescat(buf,tmp);
|
||||
} else
|
||||
ncbytesappend(buf,c);
|
||||
cvtchars = cvtcharsn; /* for non-first tests*/
|
||||
}
|
||||
newname = ncbytesdup(buf);
|
||||
ncbytesfree(buf);
|
||||
return newname;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef IGNORE
|
||||
/* Convert a string, s0, to replace some characters with %XX */
|
||||
char*
|
||||
urlescape(char* s0)
|
||||
{
|
||||
int c;
|
||||
unsigned int slen;
|
||||
char* newname;
|
||||
char* p;
|
||||
char* q;
|
||||
static char urlescapes[] = " %&/:;,=?@'\"<>{}|\\^[]`";
|
||||
|
||||
|
||||
if(s0 == NULL) return NULL;
|
||||
slen = strlen(s0);
|
||||
newname = (char*)emalloc(1+(slen*3)); /* if every char goes to %XX */
|
||||
p = s0;
|
||||
q = newname;
|
||||
while((c=*p++)) {
|
||||
if(c < ' ' || c >= 127 || strchr(urlescapes,c) != NULL) {
|
||||
int hex1, hex2;
|
||||
hex1 = (c & 0x0F);
|
||||
hex2 = (c & 0xF0) >> 4;
|
||||
*q++ = '%';
|
||||
*q++ = hexchars[hex2];
|
||||
*q++ = hexchars[hex1];
|
||||
} else
|
||||
*q++ = c;
|
||||
}
|
||||
*q = '\0';
|
||||
return newname;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Define the type conversion of the DAP variables
|
||||
to the external netCDF variable type.
|
||||
The proper way is to, for example, convert unsigned short
|
||||
@ -296,57 +219,6 @@ nctypetostring(nc_type nctype)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef IGNORE
|
||||
/*
|
||||
Assuming node is in the dds or datadds space,
|
||||
move to the corresponding node in dds0 space
|
||||
(guaranteed to exist) and collect the set of
|
||||
the node plus all container nodesin depth first order.
|
||||
*/
|
||||
void
|
||||
collectnode0path3(CDFnode* node, NClist* path, int withdataset)
|
||||
{
|
||||
/* Move to dds0 space */
|
||||
if(node->attachment0 == NULL && node->attachment != NULL)
|
||||
node = node->attachment;
|
||||
if(node->attachment0 != NULL)
|
||||
node = node->attachment0;
|
||||
|
||||
collectnodepath3(node,path,withdataset);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef IGNORE
|
||||
/* Compute the 1+deepest occurrence of a sequence in the path*/
|
||||
int
|
||||
dividepoint(NClist* path)
|
||||
{
|
||||
/* find divide point*/
|
||||
int i,len = nclistlength(path);
|
||||
int divide = 0; /* to indicate not found*/
|
||||
for(i=0;i<len;i++) {
|
||||
CDFnode* node = (CDFnode*)nclistget(path,i);
|
||||
if(node->nctype == NC_Sequence) divide = i+1;
|
||||
}
|
||||
return divide;
|
||||
}
|
||||
|
||||
/* Divide the set into two parts, those before and including the*/
|
||||
/* innermost sequence and those below that point*/
|
||||
void
|
||||
dividepath(NClist* path, NClist* prefix)
|
||||
{
|
||||
int i,divide;
|
||||
divide = dividepoint(path);
|
||||
if(divide > 0) { /* move the prefix part if divide >= 0*/
|
||||
for(i=0;i<=divide;i++) {
|
||||
ncelem node = nclistget(path,0);
|
||||
nclistpush(prefix,node);
|
||||
nclistremove(path,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Pad a buffer */
|
||||
int
|
||||
@ -577,81 +449,6 @@ makecdfpathstring3(CDFnode* var, const char* separator)
|
||||
return spath;
|
||||
}
|
||||
|
||||
#ifdef IGNORE
|
||||
/* Like makecdfpathstring, but using node->ncbasename. */
|
||||
char*
|
||||
makesimplepathstring3(CDFnode* var)
|
||||
{
|
||||
int slen,i,len,first;
|
||||
char* pathname;
|
||||
NClist* path = nclistnew();
|
||||
|
||||
collectnodepath3(var,path,!WITHDATASET);
|
||||
len = nclistlength(path);
|
||||
if(len == 0) {pathname = nulldup(""); goto done;} /* Dataset only */
|
||||
for(slen=0,i=0;i<len;i++) {
|
||||
CDFnode* node = (CDFnode*)nclistget(path,i);
|
||||
slen += (node->ncbasename?strlen(node->ncbasename):0);
|
||||
}
|
||||
slen += (len-1); /* for 1-char separators */
|
||||
slen += 1; /* for null terminator*/
|
||||
pathname = (char*)malloc(slen);
|
||||
MEMCHECK(pathname,NULL);
|
||||
pathname[0] = '\0';
|
||||
for(first=1,i=0;i<len;i++) {
|
||||
CDFnode* node = (CDFnode*)nclistget(path,i);
|
||||
char* name = node->ncbasename;
|
||||
if(!first) strcat(pathname,".");
|
||||
strcat(pathname,name?name:"null");
|
||||
first = 0;
|
||||
}
|
||||
done:
|
||||
nclistfree(path);
|
||||
return pathname;
|
||||
}
|
||||
|
||||
/* Make path string in oc space */
|
||||
char*
|
||||
makeocpathstring3(OCconnection conn, OCobject var, const char* separator)
|
||||
{
|
||||
char* pathname = NULL;
|
||||
NClist* path = nclistnew();
|
||||
size_t slen;
|
||||
unsigned long len;
|
||||
char* name;
|
||||
unsigned int i,first;
|
||||
|
||||
if(var == OCNULL) return NULL;
|
||||
collectocpath(conn,var,path);
|
||||
len = nclistlength(path);
|
||||
assert(len > 0); /* var at least */
|
||||
for(slen=0,i=0;i<len;i++) {
|
||||
OCobject o = (OCobject)nclistget(path,i);
|
||||
oc_inq_name(conn,o,&name);
|
||||
if(name == NULL) name = nulldup("");
|
||||
slen += strlen(name);
|
||||
nullfree(name);
|
||||
}
|
||||
slen += ((len-1)); /* for 1-char separators */
|
||||
slen += 1; /* for null terminator*/
|
||||
pathname = (char*)malloc(slen);
|
||||
MEMCHECK(pathname,NULL);
|
||||
pathname[0] = '\0';
|
||||
for(first=1,i=0;i<len;i++) {
|
||||
OCobject o = (OCobject)nclistget(path,i);
|
||||
oc_inq_name(conn,o,&name);
|
||||
if(name == NULL) name = nulldup("");
|
||||
if(!first) strcat(pathname,separator);
|
||||
strcat(pathname,name);
|
||||
nullfree(name);
|
||||
first = 0;
|
||||
}
|
||||
|
||||
nclistfree(path);
|
||||
return pathname;
|
||||
}
|
||||
#endif /*IGNORE*/
|
||||
|
||||
/* Collect the set names of container nodes ending in "container"*/
|
||||
void
|
||||
clonenodenamepath3(CDFnode* node, NClist* path, int withdataset)
|
||||
@ -687,38 +484,6 @@ simplepathstring3(NClist* names, char* separator)
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef IGNORE
|
||||
/* DO NOT FREE RESULT STRING */
|
||||
char*
|
||||
getvaraprint(void* arg)
|
||||
{
|
||||
int i;
|
||||
static NCbytes* line = NULL;
|
||||
char tmp[64];
|
||||
Getvara* gv;
|
||||
|
||||
if(line == NULL) line = ncbytesnew();
|
||||
gv = (Getvara*)arg;
|
||||
ncbytescat(line,gv->target->name);
|
||||
if(gv->walk != NULL) {
|
||||
for(i=0;i<nclistlength(gv->walk->segments);i++) {
|
||||
NCsegment* segment = (NCsegment*)nclistget(gv->walk->segments,i);
|
||||
ncbytescat(line,segment->segment);
|
||||
if(segment->slicerank == 0)
|
||||
ncbytescat(line,"[]");
|
||||
else {
|
||||
sprintf(tmp,"[%lu:%lu:%lu]",
|
||||
(unsigned long)segment->slices[i].first,
|
||||
(unsigned long)segment->slices[i].stride,
|
||||
(unsigned long)segment->slices[i].length);
|
||||
ncbytescat(line,tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ncbytescontents(line);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Define a number of location tests */
|
||||
|
||||
/* Is node contained (transitively) in a sequence ? */
|
||||
@ -788,108 +553,6 @@ daptoplevel(CDFnode* node)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#ifdef IGNORE
|
||||
/*
|
||||
Client parameters are assumed to be
|
||||
one or more instances of bracketed pairs:
|
||||
e.g "[...][...]...".
|
||||
The bracket content in turn is assumed to be a
|
||||
comma separated list of <name>=<value> pairs.
|
||||
e.g. x=y,z=,a=b.
|
||||
If the same parameter is specifed more than once,
|
||||
then the first occurrence is used; this is so that
|
||||
is possible to forcibly override user specified
|
||||
parameters by prefixing.
|
||||
IMPORTANT: client parameter string is assumed to
|
||||
have blanks compress out.
|
||||
*/
|
||||
|
||||
NClist*
|
||||
dapparamdecode(char* params0)
|
||||
{
|
||||
char* cp;
|
||||
char* cq;
|
||||
int c;
|
||||
int i;
|
||||
int nparams;
|
||||
NClist* plist = nclistnew();
|
||||
char* params;
|
||||
char* params1;
|
||||
|
||||
if(params0 == NULL) return plist;
|
||||
|
||||
/* Kill the leading "[" and trailing "]" */
|
||||
if(params0[0] == '[')
|
||||
params = nulldup(params0+1);
|
||||
else
|
||||
params = nulldup(params0);
|
||||
|
||||
params[strlen(params)-1] = '\0';
|
||||
|
||||
params1 = nulldup(params);
|
||||
|
||||
/* Pass 1 to replace "][" pairs with ','*/
|
||||
cp=params; cq = params1;
|
||||
while((c=*cp++)) {
|
||||
if(c == RBRACKET && *cp == LBRACKET) {cp++; c = ',';}
|
||||
*cq++ = c;
|
||||
}
|
||||
*cq = '\0';
|
||||
free(params);
|
||||
params = params1;
|
||||
|
||||
/* Pass 2 to break string into pieces and count # of pairs */
|
||||
nparams=0;
|
||||
for(cp=params;(c=*cp);cp++) {
|
||||
if(c == ',') {*cp = '\0'; nparams++;}
|
||||
}
|
||||
nparams++; /* for last one */
|
||||
|
||||
/* Pass 3 to break up each pass into a (name,value) pair*/
|
||||
/* and insert into the param list */
|
||||
/* parameters of the form name name= are converted to name=""*/
|
||||
cp = params;
|
||||
for(i=0;i<nparams;i++) {
|
||||
char* next = cp+strlen(cp)+1; /* save ptr to next pair*/
|
||||
char* vp;
|
||||
/*break up the ith param*/
|
||||
vp = strchr(cp,'=');
|
||||
if(vp != NULL) {*vp = '\0'; vp++;} else {vp = "";}
|
||||
if(!nclistcontains(plist,(ncelem)cp)) {
|
||||
nclistpush(plist,(ncelem)nulldup(cp));
|
||||
nclistpush(plist,(ncelem)nulldup(vp));
|
||||
}
|
||||
cp = next;
|
||||
}
|
||||
free(params);
|
||||
return plist;
|
||||
}
|
||||
|
||||
const char*
|
||||
dapparamlookup(NClist* params, const char* clientparam)
|
||||
{
|
||||
int i;
|
||||
if(params == NULL || clientparam == NULL) return NULL;
|
||||
for(i=0;i<nclistlength(params);i+=2) {
|
||||
char* name = (char*)nclistget(params,i);
|
||||
if(strcmp(clientparam,name)==0)
|
||||
return (char*)nclistget(params,i+1);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
dapparamfree(NClist* params)
|
||||
{
|
||||
int i;
|
||||
if(params == NULL) return;
|
||||
for(i=0;i<nclistlength(params);i++) {
|
||||
nullfree((void*)nclistget(params,i));
|
||||
}
|
||||
nclistfree(params);
|
||||
}
|
||||
#endif
|
||||
|
||||
unsigned int
|
||||
modeldecode(int translation, const char* smodel,
|
||||
const struct NCTMODEL* models,
|
||||
|
@ -512,10 +512,6 @@ dcetobuffer(DCEnode* node, NCbytes* buf)
|
||||
case CES_SLICE: {
|
||||
DCEslice* slice = (DCEslice*)node;
|
||||
size_t last = (slice->first+slice->length)-1;
|
||||
#ifdef IGNORE
|
||||
if(last > slice->declsize && slice->declsize > 0)
|
||||
last = slice->declsize - 1;
|
||||
#endif
|
||||
if(slice->count == 1) {
|
||||
snprintf(tmp,sizeof(tmp),"[%lu%s]",
|
||||
(unsigned long)slice->first,dimdecl(slice->declsize));
|
||||
@ -832,28 +828,6 @@ dceiswholesegment(DCEsegment* seg)
|
||||
return whole;
|
||||
}
|
||||
|
||||
#ifdef IGNORE
|
||||
int
|
||||
dceiswholevar(DCEvar* var)
|
||||
{
|
||||
int i,whole;
|
||||
whole = 1; /* assume so */
|
||||
for(i=0;i<nclistlength(var->segments);i++) {
|
||||
DCEsegment* segment = (DCEsegment*)nclistget(var->segments,i);
|
||||
if(!dceiswholesegment(segment)) {whole = 0; break;}
|
||||
}
|
||||
return whole;
|
||||
}
|
||||
|
||||
int
|
||||
dceiswholeprojection(DCEprojection* p)
|
||||
{
|
||||
if(p == NULL || p->discrim != CES_VAR) return 0;
|
||||
return dceiswholevar(p->var);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void
|
||||
dcemakewholeslice(DCEslice* slice, size_t declsize)
|
||||
{
|
||||
|
@ -20,11 +20,6 @@ static int tohex(int c);
|
||||
static void ceaddyytext(DCElexstate* lex, int c);
|
||||
|
||||
/****************************************************/
|
||||
#ifdef UNUSED
|
||||
static char* worddelims =
|
||||
"{}[]:;=,";
|
||||
#endif
|
||||
|
||||
/* Define 1 and > 1st legal characters */
|
||||
static char* wordchars1 =
|
||||
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-+_/%\\";
|
||||
|
@ -27,15 +27,6 @@ and the per-retrieval maximum size
|
||||
/* Max number of cache nodes */
|
||||
#define DFALTCACHECOUNT (100)
|
||||
|
||||
#ifdef IGNORE
|
||||
typedef int nc_tactic;
|
||||
#define tactic_null 0
|
||||
#define tactic_all 1
|
||||
#define tactic_partial 2
|
||||
#define tactic_grid 4
|
||||
#define tactic_var 8
|
||||
#endif
|
||||
|
||||
typedef struct Getvara {
|
||||
void* memory; /* where result is put*/
|
||||
struct NCcachenode* cache;
|
||||
@ -43,14 +34,7 @@ typedef struct Getvara {
|
||||
/* associated variable*/
|
||||
OCtype dsttype;
|
||||
CDFnode* target;
|
||||
#ifdef IGNORE
|
||||
CDFnode* target0;
|
||||
#endif
|
||||
int wholevariable;
|
||||
} Getvara;
|
||||
|
||||
#ifdef IGNORE
|
||||
extern int varamergeprojections3(NClist*,DCEprojection*,NClist*,NClist**);
|
||||
#endif
|
||||
|
||||
#endif /*GETVARA_H*/
|
||||
|
@ -650,26 +650,6 @@ wholeslicepoint(Dapodometer* odom)
|
||||
return point;
|
||||
}
|
||||
|
||||
#ifdef UNUSED
|
||||
static int
|
||||
samevarinfo(Getvara* v1, Getvara* v2)
|
||||
{
|
||||
unsigned int i;
|
||||
NCCslice *s1, *s2;
|
||||
if(v1 == NULL || v2 == NULL) return 0;
|
||||
if(v1->target != v2->target) return 0;
|
||||
if(v1->nslices != v2->nslices) return 0;
|
||||
s1 = v1->slices;
|
||||
s2 = v2->slices;
|
||||
for(i=0;i<v1->nslices;i++) {
|
||||
if(s1->first != s2->first) return 0;
|
||||
if(s1->count != s2->count) return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static int
|
||||
findfield(CDFnode* node, CDFnode* field)
|
||||
{
|
||||
@ -1030,51 +1010,6 @@ done:
|
||||
}
|
||||
|
||||
|
||||
#ifdef IGNORE
|
||||
/* We are at a primitive variable or scalar, without a string dimension; extract the data */
|
||||
/* This is way too complicated */
|
||||
static int
|
||||
extractstring(
|
||||
NCDAPCOMMON* nccomm,
|
||||
Getvara* xgetvar,
|
||||
CDFnode* xnode,
|
||||
DCEsegment* segment,
|
||||
OClink conn,
|
||||
OCdata currentcontent,
|
||||
struct NCMEMORY* memory
|
||||
)
|
||||
{
|
||||
NCerror ncstat = NC_NOERR;
|
||||
size_t rank;
|
||||
DCEslice* stringslice;
|
||||
CDFnode* strdim;
|
||||
|
||||
rank = segment->rank;
|
||||
|
||||
if(rank == 0) {/* scalar */
|
||||
ASSERT((segment != NULL));
|
||||
/* Get the string dimension */
|
||||
strdim = xnode->attachment->array.stringdim;
|
||||
ASSERT((strdim != NULL));
|
||||
stringslice = &segment->slices[segment->rank-1];
|
||||
ncstat = slicestring(conn,currentcontent,0,stringslice,memory);
|
||||
} else { /* rank > 0 */
|
||||
if(xgetvar->cache->wholevariable) {
|
||||
/* Get the string dimension */
|
||||
stringslice = &segment->slices[rank-1];
|
||||
strdim = xnode->attachment->array.stringdim;
|
||||
ASSERT((strdim != NULL));
|
||||
} else { /*!xgetvar->cache->wholevariable*/
|
||||
/* Get the string dimension */
|
||||
stringslice = &segment->slices[rank-1];
|
||||
strdim = xnode->attachment->array.stringdim;
|
||||
ASSERT((strdim != NULL));
|
||||
}
|
||||
}
|
||||
return THROW(ncstat);
|
||||
}
|
||||
#endif
|
||||
|
||||
static NCerror
|
||||
slicestring(OCconnection conn, char* stringmem, DCEslice* slice, struct NCMEMORY* memory)
|
||||
{
|
||||
@ -1110,18 +1045,6 @@ slice->first,slice->stride,slice->stop,slice->declsize);
|
||||
lastchar = (memory->next);
|
||||
if(charcount > 0) {
|
||||
lastchar--;
|
||||
#ifdef IGNORE
|
||||
/* I think we cannot do this because
|
||||
memory may not have made room for
|
||||
a trailing null.
|
||||
*/
|
||||
/* See if already null terminated */
|
||||
if(*lastchar != '\0') {
|
||||
/* null terminate (should we do this?) */
|
||||
*memory->next = '\0';
|
||||
memory->next++;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return THROW(ncstat);
|
||||
|
@ -185,9 +185,6 @@ typedef int CDFdimflags;
|
||||
typedef struct CDFdim {
|
||||
CDFdimflags dimflags;
|
||||
struct CDFnode* basedim; /* for duplicate dimensions*/
|
||||
#ifdef IGNORE
|
||||
struct CDFnode* srcdim; /* for cloned dimensions*/
|
||||
#endif
|
||||
struct CDFnode* array; /* parent array node */
|
||||
size_t declsize; /* from constrained DDS*/
|
||||
size_t declsize0; /* from unconstrained DDS*/
|
||||
@ -198,10 +195,6 @@ typedef struct CDFarray {
|
||||
NClist* dimsetall; /* inherited+originals+pseudo */
|
||||
NClist* dimsetplus; /* originals+pseudo */
|
||||
NClist* dimset0; /* original dims from the dds */
|
||||
#ifdef IGNORE
|
||||
NClist* dimensions; /* inherited+originals */
|
||||
NClist* dimensions0; /* Complete set of dimensions for this var */
|
||||
#endif
|
||||
struct CDFnode* stringdim;
|
||||
/* Track sequence related information */
|
||||
struct CDFnode* seqdim; /* if this node is a sequence */
|
||||
|
@ -45,19 +45,6 @@ nc3dinitialize(void)
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
/**************************************************/
|
||||
#ifdef NOTUSED
|
||||
int
|
||||
NCD3_new_nc(NC** ncpp)
|
||||
{
|
||||
NCDAPCOMMON* ncp;
|
||||
/* Allocate memory for this info. */
|
||||
if (!(ncp = calloc(1, sizeof(struct NCDAP3))))
|
||||
return NC_ENOMEM;
|
||||
if(ncpp) *ncpp = (NC*)ncp;
|
||||
return NC_NOERR;
|
||||
}
|
||||
#endif
|
||||
/**************************************************/
|
||||
|
||||
/* See ncd3dispatch.c for other version */
|
||||
|
@ -82,16 +82,6 @@ struct NCsegment;
|
||||
#endif /*USE_NETCDF4*/
|
||||
|
||||
|
||||
/**************************************************/
|
||||
/* The NCDAP3 structure is an extension of the NC structure (libsrc/nc.h) */
|
||||
|
||||
#ifdef NOTUSED
|
||||
typedef struct NCDAP3 {
|
||||
NC nc; /* Used to store meta-data */
|
||||
NCDAPCOMMON dap;
|
||||
} NCDAP3;
|
||||
#endif
|
||||
|
||||
/**************************************************/
|
||||
|
||||
extern struct NCTMODEL nctmodels[];
|
||||
@ -99,17 +89,7 @@ extern struct NCTMODEL nctmodels[];
|
||||
/**************************************************/
|
||||
/* Import some internal procedures from libsrc*/
|
||||
|
||||
#ifdef IGNORE
|
||||
extern void drno_add_to_NCList(struct NC *ncp);
|
||||
extern void drno_del_from_NCList(struct NC *ncp);
|
||||
extern void drno_free_NC(struct NC *ncp);
|
||||
extern struct NC* drno_new_NC(const size_t *chunkp);
|
||||
extern void drno_set_numrecs(NC* ncp, size_t size);
|
||||
extern size_t drno_get_numrecs(NC* ncp);
|
||||
extern int drno_ncio_open(NC* ncp, const char* path, int mode);
|
||||
#endif
|
||||
|
||||
/* Internal, but non-static procedures */
|
||||
/* Internal, but non-static procedures */
|
||||
extern NCerror computecdfvarnames3(NCDAPCOMMON*,CDFnode*,NClist*);
|
||||
extern NCerror computecdfnodesets3(NCDAPCOMMON* drno);
|
||||
extern NCerror computevarnodes3(NCDAPCOMMON*, NClist*, NClist*);
|
||||
|
@ -61,31 +61,6 @@ freeNCDAPCOMMON(NCDAPCOMMON* dapcomm)
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
#ifdef IGNORE
|
||||
I think this dups a procedure in common34
|
||||
/* Given a path, collect the set of dimensions along that path */
|
||||
static void
|
||||
collectdims3(NClist* path, NClist* dimset)
|
||||
{
|
||||
int i,j;
|
||||
nclistclear(dimset);
|
||||
for(i=0;i<nclistlength(path);i++) {
|
||||
CDFnode* node = (CDFnode*)nclistget(path,i);
|
||||
if(node->nctype == NC_Sequence) {
|
||||
CDFnode* sqdim = (CDFnode*)nclistget(node->array.dimensions,0);
|
||||
if(DIMFLAG(sqdim,CDFDIMUNLIM))
|
||||
nclistclear(dimset); /* unlimited is always first */
|
||||
}
|
||||
for(j=0;j<nclistlength(node->array.dimensions);j++) {
|
||||
CDFnode* dim = (CDFnode*)nclistget(node->array.dimensions,j);
|
||||
nclistpush(dimset,(ncelem)dim);
|
||||
}
|
||||
if(node->array.stringdim != NULL)
|
||||
nclistpush(dimset,(ncelem)node->array.stringdim);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
NCerror
|
||||
addstringdims(NCDAPCOMMON* dapcomm)
|
||||
{
|
||||
@ -173,28 +148,6 @@ defrecorddim3(NCDAPCOMMON* dapcomm)
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef IGNORE
|
||||
Can never happen?
|
||||
/* Now, locate all the string dims and see if they are the record dim,
|
||||
then replace */
|
||||
if(dapcomm->cdf.unlimited != NULL) {
|
||||
CDFnode* unlim = dapcomm->cdf.unlimited;
|
||||
for(i=0;i<nclistlength(dapcomm->cdf.varnodes);i++) {
|
||||
CDFnode* var = (CDFnode*)nclistget(dapcomm->cdf.varnodes,i);
|
||||
CDFnode* sdim = var->array.stringdim;
|
||||
if(sdim == NULL) continue;
|
||||
if(strcmp(sdim->ncfullname,unlim->ncfullname)==0
|
||||
&& sdim->dim.declsize == unlim->dim.declsize) {
|
||||
var->array.stringdim = unlim;
|
||||
nclistpop(var->array.dimsetplus);
|
||||
nclistpush(var->array.dimsetplus,(ncelem)dapcomm->cdf.unlimited);
|
||||
nclistpop(var->array.dimsetall);
|
||||
nclistpush(var->array.dimsetall,(ncelem)dapcomm->cdf.unlimited);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return ncstat;
|
||||
}
|
||||
|
||||
@ -337,9 +290,6 @@ makeseqdim(NCDAPCOMMON* dapcomm, CDFnode* seq, size_t count, CDFnode** sqdimp)
|
||||
sqdim->dim.declsize = count;
|
||||
sqdim->dim.declsize0 = count;
|
||||
sqdim->dim.array = seq;
|
||||
#ifdef IGNORE
|
||||
sqdim->dim.index1 = 1;
|
||||
#endif
|
||||
if(sqdimp) *sqdimp = sqdim;
|
||||
return NC_NOERR;
|
||||
}
|
||||
@ -459,37 +409,6 @@ showprojection3(NCDAPCOMMON* dapcomm, CDFnode* var)
|
||||
return ncstat;
|
||||
}
|
||||
|
||||
#ifdef IGNORE
|
||||
NCerror
|
||||
detachdatadds3(NCDAPCOMMON* dapcomm)
|
||||
{
|
||||
int i;
|
||||
for(i=0;i<nclistlength(dapcomm->cdf.dds->tree.nodes);i++) {
|
||||
CDFnode* node = (CDFnode*)nclistget(dapcomm->cdf.dds->tree.nodes,i);
|
||||
node->active = 0;
|
||||
node->dim.datasize = node->dim.declsize;
|
||||
}
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
NCerror
|
||||
attachdatadds3(NCDAPCOMMON* dapcomm)
|
||||
{
|
||||
int i;
|
||||
NClist* cdfnodes = dapcomm->cdf.dds->tree.nodes;
|
||||
for(i=0;i<nclistlength(cdfnodes);i++) {
|
||||
CDFnode* node = (CDFnode*)nclistget(cdfnodes,i);
|
||||
OCobject dds = node->dds;
|
||||
if(dds == OCNULL) continue;
|
||||
node->active = oc_datadds_active(dapcomm->oc.conn,dds);
|
||||
if(node->nctype == NC_Dimension) {
|
||||
oc_datadds_dimsize(dapcomm->oc.conn,node->dds,&node->dim.datasize);
|
||||
}
|
||||
}
|
||||
return NC_NOERR;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
This is more complex than one might think. We want to find
|
||||
a path to a variable inside the given node so that we can
|
||||
@ -513,24 +432,9 @@ computeseqcountconstraints3(NCDAPCOMMON* dapcomm, CDFnode* seq, NCbytes* seqcoun
|
||||
|
||||
ASSERT((var != NULL));
|
||||
|
||||
#ifdef IGNORE
|
||||
/* collect seq path prefix */
|
||||
prefix = makecdfpathstring3(seq->container,".");
|
||||
ncbytescat(seqcountconstraints,prefix);
|
||||
if(strlen(prefix) > 0) ncbytescat(seqcountconstraints,".");
|
||||
#endif
|
||||
|
||||
/* Compute var path */
|
||||
path = nclistnew();
|
||||
collectnodepath3(var,path,WITHOUTDATASET);
|
||||
#ifdef IGNORE
|
||||
while(nclistlength(path) > 0) {
|
||||
CDFnode* node = (CDFnode*)nclistget(path,0);
|
||||
if(node == seq) break;
|
||||
nclistremove(path,0);
|
||||
}
|
||||
ASSERT((nclistlength(path) > 0));
|
||||
#endif
|
||||
|
||||
/* construct the projection path using minimal index values */
|
||||
for(i=0;i<nclistlength(path);i++) {
|
||||
@ -637,94 +541,6 @@ computeseqcountconstraints3r(NCDAPCOMMON* dapcomm, CDFnode* node, CDFnode** cand
|
||||
}
|
||||
|
||||
|
||||
#ifdef IGNORE
|
||||
/* computeseqcountconstraints3 recursive helper function */
|
||||
static NCerror
|
||||
computeseqcountconstraints3r(NCDAPCOMMON* dapcomm, CDFnode* seq, NCbytes* seqcountconstraints)
|
||||
{
|
||||
NClist* path = nclistnew();
|
||||
CDFnode* var;
|
||||
CDFnode* candidate;
|
||||
unsigned int i,j,ndims;
|
||||
char* prefix;
|
||||
|
||||
nclistpush(path,(ncelem)seq);
|
||||
/* Locate a variable that is inside this sequence */
|
||||
/* Preferably one that is a numeric type and if possible, scalar */
|
||||
for(candidate=NULL,var=NULL,i=0;i<nclistlength(dapcomm->cdf.varnodes);i++){
|
||||
CDFnode* node = (CDFnode*)nclistget(dapcomm->cdf.varnodes,i);
|
||||
if(node->array.sequence == seq) {
|
||||
if(node->nctype == NC_Primitive) {
|
||||
switch(node->etype) {
|
||||
case NC_BYTE: case NC_SHORT: case NC_INT:
|
||||
case NC_FLOAT: case NC_DOUBLE:
|
||||
case NC_UBYTE: case NC_USHORT: case NC_UINT:
|
||||
case NC_INT64: case NC_UINT64:
|
||||
if(var == NULL) {
|
||||
var = node; /* good choice */
|
||||
}
|
||||
break;
|
||||
case NC_CHAR: case NC_STRING:
|
||||
default:
|
||||
candidate = node; /* usable */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(var == NULL && candidate != NULL) var = candidate;
|
||||
else if(var == NULL) return THROW(NC_EINVAL);
|
||||
|
||||
/* collect seq path prefix */
|
||||
prefix = makecdfpathstring3(seq->container,".");
|
||||
ncbytescat(seqcountconstraints,prefix);
|
||||
if(strlen(prefix) > 0) ncbytescat(seqcountconstraints,".");
|
||||
|
||||
/* Compute a short path from the var back to and including
|
||||
the sequence
|
||||
*/
|
||||
collectnodepath3(var,path,WITHOUTDATASET);
|
||||
while(nclistlength(path) > 0) {
|
||||
CDFnode* node = (CDFnode*)nclistget(path,0);
|
||||
if(node == seq) break;
|
||||
nclistremove(path,0);
|
||||
}
|
||||
ASSERT((nclistlength(path) > 0));
|
||||
|
||||
/* construct the projection path using minimal index values */
|
||||
for(i=0;i<nclistlength(path);i++) {
|
||||
CDFnode* node = (CDFnode*)nclistget(path,i);
|
||||
if(i > 0) ncbytescat(seqcountconstraints,".");
|
||||
ncbytescat(seqcountconstraints,node->ocname);
|
||||
if(node == seq) {
|
||||
/* Use the limit */
|
||||
if(node->sequencelimit > 0) {
|
||||
char tmp[64];
|
||||
snprintf(tmp,sizeof(tmp),"[0:%lu]",
|
||||
(unsigned long)(node->sequencelimit - 1));
|
||||
ncbytescat(seqcountconstraints,tmp);
|
||||
}
|
||||
} else if(nclistlength(node->array.dimset0) > 0) {
|
||||
ndims = nclistlength(node->array.dimset0);
|
||||
for(j=0;j<ndims;j++) {
|
||||
CDFnode* dim = (CDFnode*)nclistget(node->array.dimset0,j);
|
||||
if(DIMFLAG(dim,CDFDIMSTRING)) {
|
||||
ASSERT((j == (ndims - 1)));
|
||||
break;
|
||||
}
|
||||
ncbytescat(seqcountconstraints,"[0]");
|
||||
}
|
||||
}
|
||||
}
|
||||
nclistfree(path);
|
||||
/* Finally, add in any selection from the original URL */
|
||||
if(dapcomm->oc.url->selection != NULL)
|
||||
ncbytescat(seqcountconstraints,dapcomm->oc.url->selection);
|
||||
nullfree(prefix);
|
||||
return NC_NOERR;
|
||||
}
|
||||
#endif
|
||||
|
||||
static unsigned long
|
||||
cdftotalsize3(NClist* dimensions)
|
||||
{
|
||||
@ -828,12 +644,6 @@ fetchtemplatemetadata3(NCDAPCOMMON* dapcomm)
|
||||
if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto done;}
|
||||
dapcomm->cdf.fullddsroot = ddsroot;
|
||||
|
||||
#ifdef NOTUSED
|
||||
/* Combine DDS and DAS */
|
||||
ncstat = dapmerge3(dapcomm,ddsroot,dapcomm->oc.ocdasroot);
|
||||
if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto done;}
|
||||
#endif
|
||||
|
||||
done:
|
||||
nullfree(ce);
|
||||
if(ocstat != OC_NOERR) ncstat = ocerrtoncerr(ocstat);
|
||||
@ -854,13 +664,6 @@ fetchconstrainedmetadata3(NCDAPCOMMON* dapcomm)
|
||||
else
|
||||
ce = buildconstraintstring3(dapcomm->oc.dapconstraint);
|
||||
|
||||
#ifdef NOTUSED
|
||||
if(ce == NULL || strlen(ce) == 0) {
|
||||
/* no need to get the dds again; just imprint on self */
|
||||
ncstat = imprintself3(dapcomm->cdf.ddsroot);
|
||||
if(ncstat) goto fail;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
ocstat = dap_fetch(dapcomm,dapcomm->oc.conn,ce,OCDDS,&ocroot);
|
||||
if(ocstat != OC_NOERR) {THROWCHK(ocstat); goto fail;}
|
||||
|
@ -3,10 +3,6 @@
|
||||
|
||||
extern int NCSUBSTRATE_intialize(void);
|
||||
|
||||
#ifdef NOTUSED
|
||||
#define INITCOORD1 if(coord_one[0] != 1) {int i; for(i=0;i<NC_MAX_VAR_DIMS;i++) coord_one[i] = 1;}
|
||||
#endif
|
||||
|
||||
/* Define vectors of zeros and ones for use with various nc_get_varX function*/
|
||||
size_t nc_sizevector0[NC_MAX_DIMS];
|
||||
size_t nc_sizevector1[NC_MAX_DIMS];
|
||||
|
@ -1415,13 +1415,6 @@ NC_create(const char *path, int cmode, size_t initialsz,
|
||||
if(model == (NC_DISPATCH_NC4 | NC_DISPATCH_NCR))
|
||||
dispatcher = NCCR_dispatch_table;
|
||||
else
|
||||
#endif
|
||||
#ifdef USE_DAP
|
||||
#ifdef NOTUSED
|
||||
if(model == (NC_DISPATCH_NC4 | NC_DISPATCH_NCD))
|
||||
dispatcher = NCD4_dispatch_table;
|
||||
else
|
||||
#endif
|
||||
#endif
|
||||
if(model == (NC_DISPATCH_NC4))
|
||||
dispatcher = NC4_dispatch_table;
|
||||
@ -1534,13 +1527,6 @@ NC_open(const char *path, int cmode,
|
||||
dispatcher = NCCR_dispatch_table;
|
||||
else
|
||||
#endif
|
||||
#if defined(USE_NETCDF4) && defined(USE_DAP)
|
||||
#ifdef NOTUSED
|
||||
if(model == (NC_DISPATCH_NC4 | NC_DISPATCH_NCD))
|
||||
dispatcher = NCD4_dispatch_table;
|
||||
else
|
||||
#endif
|
||||
#endif
|
||||
#if defined(USE_DAP)
|
||||
if(model == (NC_DISPATCH_NC3 | NC_DISPATCH_NCD))
|
||||
dispatcher = NCD3_dispatch_table;
|
||||
|
@ -122,30 +122,6 @@ nclog(int tag, const char* fmt, ...)
|
||||
fflush(nclogstream);
|
||||
}
|
||||
|
||||
#ifdef IGNORE
|
||||
void
|
||||
nclogtext(int tag, const char* text)
|
||||
{
|
||||
char line[1024];
|
||||
size_t delta = 0;
|
||||
const char* eol = text;
|
||||
|
||||
if(!nclogging || nclogstream == NULL) return;
|
||||
|
||||
while(*text) {
|
||||
eol = strchr(text,'\n');
|
||||
if(eol == NULL)
|
||||
delta = strlen(text);
|
||||
else
|
||||
delta = (eol - text);
|
||||
if(delta > 0) memcpy(line,text,delta);
|
||||
line[delta] = '\0';
|
||||
fprintf(nclogstream," %s\n",line);
|
||||
text = eol+1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
nclogtext(int tag, const char* text)
|
||||
{
|
||||
|
@ -454,78 +454,3 @@ nc_paramfree(char** params)
|
||||
}
|
||||
free(params);
|
||||
}
|
||||
|
||||
#ifdef IGNORE
|
||||
/*
|
||||
Delete the entry.
|
||||
return value = 1 => found and deleted;
|
||||
0 => param not found
|
||||
*/
|
||||
int
|
||||
nc_paramdelete(char** params, const char* key)
|
||||
{
|
||||
int i;
|
||||
char** p;
|
||||
char** q;
|
||||
if(params == NULL || key == NULL) return 0;
|
||||
i = nc_find(params,key);
|
||||
if(i < 0) return 0;
|
||||
p = params+(2*i);
|
||||
for(q=p+2;*q;) {
|
||||
*p++ = *q++;
|
||||
}
|
||||
*p = NULL;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
nc_length(char** params)
|
||||
{
|
||||
int i = 0;
|
||||
if(params != NULL) {
|
||||
while(*params) {params+=2; i++;}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
/*
|
||||
Insert new client param (name,value);
|
||||
return value = 1 => not already defined
|
||||
0 => param already defined (no change)
|
||||
*/
|
||||
char**
|
||||
nc_paraminsert(char** params, const char* key, const char* value)
|
||||
{
|
||||
int i;
|
||||
char** newp;
|
||||
size_t len;
|
||||
if(params == NULL || key == NULL) return 0;
|
||||
i = nc_find(params,key);
|
||||
if(i >= 0) return 0;
|
||||
/* not found, append */
|
||||
i = nc_length(params);
|
||||
len = sizeof(char*)*((2*i)+1);
|
||||
newp = realloc(params,len+2*sizeof(char*));
|
||||
memcpy(newp,params,len);
|
||||
newp[2*i] = strdup(key);
|
||||
newp[2*i+1] = (value==NULL?NULL:strdup(value));
|
||||
return newp;
|
||||
}
|
||||
|
||||
/*
|
||||
Replace new client param (name,value);
|
||||
return value = 1 => replacement performed
|
||||
0 => key not found (no change)
|
||||
*/
|
||||
int
|
||||
nc_paramreplace(char** params, const char* key, const char* value)
|
||||
{
|
||||
int i;
|
||||
if(params == NULL || key == NULL) return 0;
|
||||
i = nc_find(params,key);
|
||||
if(i < 0) return 0;
|
||||
if(params[2*i+1] != NULL) free(params[2*i+1]);
|
||||
params[2*i+1] = nulldup(value);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
@ -246,19 +246,6 @@ typedef struct Typealignset {
|
||||
Alignment ncvlenalign; /* nc_vlen_t*/
|
||||
} Typealignset;
|
||||
|
||||
#ifdef IGNORE
|
||||
static char* Ctypenames[NCTYPES] = {
|
||||
(char*)NULL,
|
||||
"char","unsigned char",
|
||||
"short","unsigned short",
|
||||
"int","unsigned int",
|
||||
"long","unsigned long",
|
||||
"long long","unsigned long long",
|
||||
"float","double",
|
||||
"void*","nc_vlen_t"
|
||||
};
|
||||
#endif
|
||||
|
||||
static Typealignvec vec[NCTYPES];
|
||||
static Typealignset set;
|
||||
|
||||
|
@ -247,14 +247,6 @@ bbFree(buf);
|
||||
void
|
||||
report0(char* lead, Datasrc* src, int index)
|
||||
{
|
||||
#ifdef IGNORE
|
||||
fprintf(stderr,"%s src ",lead);
|
||||
if(index >=0 ) fprintf(stderr,"(%d)",index);
|
||||
fprintf(stderr,":: ");
|
||||
dumpdatasrc(src);
|
||||
fprintf(stderr,"\n");
|
||||
fflush(stderr);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -11,10 +11,6 @@
|
||||
|
||||
#undef TRACE
|
||||
|
||||
#ifdef IGNORE
|
||||
extern List* vlenconstants;
|
||||
#endif
|
||||
|
||||
/* Forward*/
|
||||
static void genbin_defineattr(Symbol* asym);
|
||||
static void genbin_definevardata(Symbol* vsym);
|
||||
@ -127,11 +123,6 @@ gen_netcdf(const char *filename)
|
||||
}
|
||||
|
||||
#ifdef USE_NETCDF4
|
||||
/* Collect vlen data*/
|
||||
#ifdef IGNORE
|
||||
bindata_vlenconstants(vlenconstants);
|
||||
#endif
|
||||
|
||||
/* define special variable properties */
|
||||
if(nvars > 0) {
|
||||
for(ivar = 0; ivar < nvars; ivar++) {
|
||||
|
10
ncgen/genc.c
10
ncgen/genc.c
@ -295,16 +295,6 @@ gen_ncc(const char *filename)
|
||||
codelined(1,"/* define dimensions */");
|
||||
for(idim = 0; idim < ndims; idim++) {
|
||||
Symbol* dsym = (Symbol*)listget(dimdefs,idim);
|
||||
#ifdef IGNORE
|
||||
if(dsym->dim.isunlimited) {
|
||||
bbprintf0(stmt,
|
||||
" stat = nc_def_dim(%s, \"%s\", %s, &%s);\n",
|
||||
groupncid(dsym->container),
|
||||
escapifyname(dsym->name),
|
||||
"NC_UNLIMITED",
|
||||
dimncid(dsym));
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
bbprintf0(stmt,
|
||||
" stat = nc_def_dim(%s, \"%s\", %s_len, &%s);\n",
|
||||
|
11
ncgen/genj.c
11
ncgen/genj.c
@ -102,17 +102,6 @@ gen_ncjava(const char *filename)
|
||||
codeline("");
|
||||
codelined(1,"/* enter define mode */");
|
||||
|
||||
#ifdef IGNORE
|
||||
if(!cmode_modifier) {
|
||||
cmode_string = "NC_CLOBBER";
|
||||
} else if(cmode_modifier & NC_64BIT_OFFSET) {
|
||||
cmode_string = "NC_CLOBBER|NC_64BIT_OFFSET";
|
||||
} else {
|
||||
derror("unknown cmode modifier");
|
||||
cmode_string = "NC_CLOBBER";
|
||||
}
|
||||
#endif
|
||||
|
||||
bbprintf0(stmt,
|
||||
"%sNetcdfFileWriteable ncfile = NetcdfFileWriteable.createNew(\"%s\", %s);\n",
|
||||
indented(1),filename,(nofill_flag?"false":"true"));
|
||||
|
108
ncgen/getfill.c
108
ncgen/getfill.c
@ -143,114 +143,6 @@ fillarray(Symbol* basetype, Dimset* dimset, int index, Datalist* arraylist)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef NOTUSED
|
||||
/* Verify that a user provided fill value does in fact*/
|
||||
/* conform to the structure of a given type or variable*/
|
||||
/* Structure conforms to fill procedures above.*/
|
||||
|
||||
static int
|
||||
checkfill(Symbol* tsym, Datasrc* src)
|
||||
{
|
||||
int i,iscmpd,result;
|
||||
Constant* con;
|
||||
Symbol* original = tsym;
|
||||
|
||||
result = 1;
|
||||
switch (tsym->subclass) {
|
||||
case NC_ENUM: case NC_OPAQUE: case NC_PRIM:
|
||||
con = srcnext(src);
|
||||
if(src == NULL) {
|
||||
semerror(srcline(src),"%s: malformed _FillValue",original->name);
|
||||
result = 0;
|
||||
} else if(con->nctype != tsym->typ.typecode) result = 0; /* wrong type*/
|
||||
break;
|
||||
|
||||
case NC_COMPOUND:
|
||||
if(!issublist(src)) {/* fail on no compound*/
|
||||
semerror(srcline(src),"Compound constants must be enclosed in {..}");
|
||||
}
|
||||
srcpush(src);
|
||||
for(i=0;i<listlength(tsym->subnodes);i++) {
|
||||
Symbol* field = (Symbol*)listget(tsym->subnodes,i);
|
||||
result = checkfill(field,src,original);
|
||||
if(!result) break;
|
||||
}
|
||||
srcpop(src);
|
||||
break;
|
||||
|
||||
case NC_VLEN:
|
||||
if(!issublist(src)) {
|
||||
semerror(srcline(src),"%s: vlen instances in _FillValue must be enclosed in {...}",original->name);
|
||||
result = 0;
|
||||
} else {
|
||||
srcpush(src);
|
||||
while(srcmore(src)) {
|
||||
result = checkfill(tsym->typ.basetype,src,original);
|
||||
if(!result) break;
|
||||
}
|
||||
srcpop(src);
|
||||
}
|
||||
break;
|
||||
|
||||
case NC_FIELD:
|
||||
/* Braces are optional */
|
||||
if((iscmpd=issublist(src))) srcpush(src);
|
||||
if(tsym->typ.dimset.ndims > 0) {
|
||||
result = checkarray(tsym->typ.basetype,&tsym->typ.dimset,0,src,original,!TOPLEVEL);
|
||||
} else
|
||||
result = checkfill(tsym->typ.basetype,src,original);
|
||||
if(iscmpd) srcpop(src);
|
||||
break;
|
||||
|
||||
default: PANIC1("checkfillvalue: unexpected subclass %d",tsym->subclass);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static int
|
||||
checkarray(Symbol* basetype, Dimset* dimset, int index, Datasrc* src, Symbol* original, int toplevel)
|
||||
{
|
||||
int i,result;
|
||||
Symbol* dim = dimset->dimsyms[index];
|
||||
unsigned int size = dim->dim.declsize;
|
||||
int lastdim = (index == (dimset->ndims - 1));
|
||||
int isunlimited = (size == 0);
|
||||
|
||||
result = 1;
|
||||
if(isunlimited) {
|
||||
if(!toplevel) {
|
||||
if(!issublist(src)) {
|
||||
semerror(srcline(src),"UNLIMITED dimension constants (other than top level) must be enclosed in {...}");
|
||||
result = 0;
|
||||
goto done;
|
||||
} else
|
||||
srcpush(src);
|
||||
}
|
||||
if(lastdim) {
|
||||
while(srcmore(src) && result) {
|
||||
result = checkfill(basetype,src,original);
|
||||
}
|
||||
} else { /*!lastdim*/
|
||||
while(srcmore(src) && result) {
|
||||
result = checkarray(basetype,dimset,index+1,src,original,toplevel);
|
||||
}
|
||||
}
|
||||
} else { /* bounded*/
|
||||
if(lastdim) {
|
||||
for(i=0;i<size && result;i++) {
|
||||
result = checkfill(basetype,src,original);
|
||||
}
|
||||
} else { /* !lastdim*/
|
||||
for(i=0;i<size && result;i++) {
|
||||
result = checkarray(basetype,dimset,index+1,src,original,toplevel);
|
||||
}
|
||||
}
|
||||
}
|
||||
done:
|
||||
return result;
|
||||
}
|
||||
#endif /*NOTUSED*/
|
||||
|
||||
/*
|
||||
* Given primitive netCDF type, return a default fill_value appropriate for
|
||||
* that type.
|
||||
|
@ -112,23 +112,6 @@ genjstd_arraydata(Symbol* vsym, Putvar* closure, Bytebuffer* databuf)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef UNUSED
|
||||
static void
|
||||
getindex(Odometer* odom, Bytebuffer* indices)
|
||||
{
|
||||
int i;
|
||||
bbClear(indices);
|
||||
bbCat(indices,"ima.set(");
|
||||
for(i=0;i<odom->rank;i++) {
|
||||
char tmp[32];
|
||||
nprintf(tmp,sizeof(tmp),"%s%ld",
|
||||
(i==0?"":","),odom->dims[i].index);
|
||||
bbCat(indices,tmp);
|
||||
}
|
||||
bbCat(indices,")");
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
genjstd_arraydatar(Symbol* vsym,
|
||||
Datasrc* src,
|
||||
|
@ -33,11 +33,4 @@ extern int odometermore(Odometer* odom);
|
||||
extern int odometerincr(Odometer* odo);
|
||||
extern size_t odometeroffset(Odometer* odom);
|
||||
|
||||
#ifdef NOTUSED
|
||||
extern void odometerreset(Odometer*);
|
||||
extern size_t odometertotal(Odometer*,int);
|
||||
extern size_t odomsubarray(Odometer* odom, int index);
|
||||
extern size_t odomprefixcount(Odometer* odom, int index);
|
||||
#endif
|
||||
|
||||
#endif /*ODOM_H*/
|
||||
|
@ -584,9 +584,6 @@ processattributes(void)
|
||||
/* If the attribute has a zero length, then default it */
|
||||
if(asym->data == NULL || asym->data->length == 0) {
|
||||
asym->data = builddatalist(1);
|
||||
#ifdef IGNORE
|
||||
dlappend(asym->data,NULL);
|
||||
#endif
|
||||
emptystringconst(asym->lineno,&asym->data->data[asym->data->length]);
|
||||
/* force type to be NC_CHAR */
|
||||
asym->typ.basetype = primsymbols[NC_CHAR];
|
||||
@ -601,9 +598,6 @@ processattributes(void)
|
||||
/* If the attribute has a zero length, then default it */
|
||||
if(asym->data == NULL || asym->data->length == 0) {
|
||||
asym->data = builddatalist(1);
|
||||
#ifdef IGNORE
|
||||
dlappend(asym->data,NULL);
|
||||
#endif
|
||||
emptystringconst(asym->lineno,&asym->data->data[asym->data->length]);
|
||||
/* force type to be NC_CHAR */
|
||||
asym->typ.basetype = primsymbols[NC_CHAR];
|
||||
|
Loading…
x
Reference in New Issue
Block a user