mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-01-12 15:45:21 +08:00
fix NCF-120
This commit is contained in:
parent
51906ca254
commit
16dee702b7
2
cf
2
cf
@ -15,7 +15,7 @@ DAP=1
|
||||
#cmds="all"
|
||||
#cmds="all check"
|
||||
#cmds="all dist"
|
||||
cmds="all distcheck"
|
||||
#cmds="all distcheck"
|
||||
|
||||
PREFIX="/tmp/install/${HOST}"
|
||||
stddir="/share/ed/local/${HOST}"
|
||||
|
@ -60,7 +60,7 @@ AM_CONDITIONAL([BUILD_DOCS], [test "x$enable_doxygen" != xno])
|
||||
AC_ARG_ENABLE([internal-docs],
|
||||
[AS_HELP_STRING([--enable-internal-docs],
|
||||
[Include documentation of library internals. This is of interest only to those developing the netCDF library.])])
|
||||
test $enable_internal_docs = yes || enable_internal_docs=no
|
||||
test "x$enable_internal_docs" = xyes || enable_internal_docs=no
|
||||
AC_SUBST([BUILD_INTERNAL_DOCS], [$enable_internal_docs])
|
||||
|
||||
AC_MSG_CHECKING([if fsync support is enabled])
|
||||
@ -566,6 +566,9 @@ AC_FUNC_VPRINTF
|
||||
# Check for <stdbool.h> that conforms to C99 requirements
|
||||
AC_HEADER_STDBOOL
|
||||
|
||||
AC_CHECK_FUNCS([mktime])
|
||||
AC_CHECK_FUNCS([strptime])
|
||||
|
||||
# Check for these functions...
|
||||
AC_CHECK_FUNCS([strlcat strerror snprintf strchr strrchr mktemp strcat strcpy strdup \
|
||||
strcasecmp strtod strtoll strtoull getrlimit gettimeofday fsync MPI_Comm_f2c])
|
||||
|
@ -19,7 +19,7 @@ typedef long long int64_t;
|
||||
#define true 1
|
||||
#define false 0
|
||||
#define TRUE 1
|
||||
#define FALSE 1
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
typedef unsigned int bool_t;
|
||||
|
@ -137,6 +137,7 @@ nclog(NCLOGNOTE,"prefetch.");
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
/* Log the set of prefetch variables */
|
||||
NCbytes* buf = ncbytesnew();
|
||||
ncbytescat(buf,"prefetch.vars: ");
|
||||
@ -148,6 +149,7 @@ ncbytescat(buf,makesimplepathstring3(var));
|
||||
ncbytescat(buf,"\n");
|
||||
nclog(NCLOGNOTE,"%s",ncbytescontents(buf));
|
||||
ncbytesfree(buf);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Make cache node be the prefetch node */
|
||||
|
103
libdap2/cdf3.c
103
libdap2/cdf3.c
@ -26,11 +26,16 @@ static NCerror testregrid3(CDFnode* node, CDFnode* template, NClist*);
|
||||
static CDFnode* makenewstruct3(CDFnode* node, CDFnode* template);
|
||||
static NCerror regridinsert(CDFnode* newgrid, CDFnode* node);
|
||||
static NCerror regridremove(CDFnode* newgrid, CDFnode* node);
|
||||
static NCerror imprint3r(CDFnode*, CDFnode*, int depth);
|
||||
static NCerror imprintdims3(CDFnode*, CDFnode*);
|
||||
static void projection3r(CDFnode*);
|
||||
static void unprojected3(NClist* nodes);
|
||||
static void projectall3(NClist* nodes);
|
||||
#ifdef DDSNEW
|
||||
static NCerror mapnodes3r(CDFnode*, CDFnode*, int depth);
|
||||
static NCerror mapdims3(CDFnode*, CDFnode*);
|
||||
#else
|
||||
static NCerror imprint3r(CDFnode*, CDFnode*, int depth);
|
||||
static NCerror imprintdims3(CDFnode*, CDFnode*);
|
||||
#endif
|
||||
|
||||
/* Accumulate useful node sets */
|
||||
NCerror
|
||||
@ -395,6 +400,9 @@ fprintf(stderr,"regrid: template=%s\n",dumptree(template));
|
||||
This includes containers and subnodes. If there are no
|
||||
projections then mark all nodes
|
||||
*/
|
||||
#ifdef DDSNEW
|
||||
projectall3(template->tree->nodes);
|
||||
#else
|
||||
if(nclistlength(projections) == 0) {
|
||||
projectall3(template->tree->nodes);
|
||||
} else for(i=0;i<nclistlength(projections);i++) {
|
||||
@ -402,6 +410,7 @@ fprintf(stderr,"regrid: template=%s\n",dumptree(template));
|
||||
ASSERT(proj->discrim == CES_VAR);
|
||||
projection3r(proj->var->cdfleaf);
|
||||
}
|
||||
#endif
|
||||
|
||||
if(simplenodematch34(ddsroot,template)) {
|
||||
ncstat = regrid3r(ddsroot,template,newstructs);
|
||||
@ -655,6 +664,95 @@ findddsnode0(CDFnode* node)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DDSNEW
|
||||
/**
|
||||
|
||||
Make the constrained dds nodes (root)
|
||||
point to the corresponding unconstrained
|
||||
dds nodes (fullroot)
|
||||
*/
|
||||
|
||||
NCerror
|
||||
mapnodes3(CDFnode* root, CDFnode* fullroot)
|
||||
{
|
||||
NCerror ncstat = NC_NOERR;
|
||||
ASSERT(root != NULL && fullroot != NULL);
|
||||
if(!simplenodematch34(root,fullroot))
|
||||
{THROWCHK(ncstat=NC_EINVAL); goto done;}
|
||||
/* clear out old associations*/
|
||||
unmap3(root);
|
||||
ncstat = mapnodes3r(root,fullroot,0);
|
||||
done:
|
||||
return ncstat;
|
||||
}
|
||||
|
||||
static NCerror
|
||||
mapnodes3r(CDFnode* connode, CDFnode* fullnode, int depth)
|
||||
{
|
||||
unsigned int i,j;
|
||||
NCerror ncstat = NC_NOERR;
|
||||
|
||||
ASSERT((simplenodematch34(connode,fullnode)));
|
||||
|
||||
/* Map node */
|
||||
connode->basenode = fullnode;
|
||||
connode->visible = 1;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"mapnode: %s\n",makecdfpathstring3(connode,"."));
|
||||
#endif
|
||||
|
||||
/* Do dimension imprinting */
|
||||
ASSERT((nclistlength(connode->array.dimensions) == nclistlength(fullnode->array.dimensions)));
|
||||
if(nclistlength(connode->array.dimensions) > 0) {
|
||||
ncstat = mapdims3(connode,fullnode);
|
||||
if(ncstat) goto done;
|
||||
}
|
||||
|
||||
/* Try to match connode subnodes against fullnode subnodes */
|
||||
ASSERT(nclistlength(connode->subnodes) <= nclistlength(fullnode->subnodes));
|
||||
|
||||
for(i=0;i<nclistlength(connode->subnodes);i++) {
|
||||
CDFnode* consubnode = (CDFnode*)nclistget(connode->subnodes,i);
|
||||
/* Search full subnodes for a matching subnode from con */
|
||||
for(j=0;j<nclistlength(fullnode->subnodes);j++) {
|
||||
CDFnode* fullsubnode = (CDFnode*)nclistget(fullnode->subnodes,j);
|
||||
if(simplenodematch34(fullsubnode,consubnode)) {
|
||||
ncstat = mapnodes3r(consubnode,fullsubnode,depth+1);
|
||||
if(ncstat) goto done;
|
||||
}
|
||||
}
|
||||
}
|
||||
done:
|
||||
return THROW(ncstat);
|
||||
}
|
||||
|
||||
void
|
||||
unmap3(CDFnode* root)
|
||||
{
|
||||
unsigned int i;
|
||||
CDFtree* tree = root->tree;
|
||||
for(i=0;i<nclistlength(tree->nodes);i++) {
|
||||
CDFnode* node = (CDFnode*)nclistget(tree->nodes,i);
|
||||
node->basenode = NULL;
|
||||
node->visible = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static NCerror
|
||||
mapdims3(CDFnode* connode, CDFnode* fullnode)
|
||||
{
|
||||
unsigned int i;
|
||||
for(i=0;i<nclistlength(connode->array.dimensions);i++) {
|
||||
CDFnode* cdim = (CDFnode*)nclistget(connode->array.dimensions,i);
|
||||
CDFnode* fdim = (CDFnode*)nclistget(fullnode->array.dimensions,i);
|
||||
cdim->basenode = fdim;
|
||||
cdim->visible = 1;
|
||||
}
|
||||
return NC_NOERR;
|
||||
}
|
||||
|
||||
#else /*!DDSNEW*/
|
||||
|
||||
/*
|
||||
Move data from nodes in src tree to nodes in dst tree where
|
||||
the nodes match. Src tree is typically a structural subset
|
||||
@ -741,6 +839,7 @@ unimprint3(CDFnode* root)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /*!DDSNEW*/
|
||||
|
||||
void
|
||||
setvisible(CDFnode* root, int visible)
|
||||
|
@ -59,22 +59,22 @@ fprintf(stderr,"constraint: %s",dumpconstraint(dceconstraint));
|
||||
return ncstat;
|
||||
}
|
||||
|
||||
/* Map constrain paths to a CDFnode path; the difficulty
|
||||
/* Map constraint paths to CDFnode paths in specied tree; the difficulty
|
||||
is that suffix paths are legal.
|
||||
*/
|
||||
|
||||
NCerror
|
||||
mapconstraints3(NCDAPCOMMON* dapcomm)
|
||||
mapconstraints3(DCEconstraint* constraint,
|
||||
CDFnode* root)
|
||||
{
|
||||
int i;
|
||||
NCerror ncstat = NC_NOERR;
|
||||
CDFnode* root = dapcomm->cdf.ddsroot;
|
||||
NClist* nodes = root->tree->nodes;
|
||||
NClist* dceprojections;
|
||||
NClist* dceselections;
|
||||
|
||||
dceprojections = dapcomm->oc.dapconstraint->projections;
|
||||
dceselections = dapcomm->oc.dapconstraint->selections;
|
||||
dceprojections = constraint->projections;
|
||||
dceselections = constraint->selections;
|
||||
|
||||
/* Convert the projection paths to leaves in the dds tree */
|
||||
for(i=0;i<nclistlength(dceprojections);i++) {
|
||||
@ -105,7 +105,7 @@ mapconstraints3(NCDAPCOMMON* dapcomm)
|
||||
}
|
||||
}
|
||||
/* Fill in segment information */
|
||||
ncstat = qualifyconstraints3(dapcomm->oc.dapconstraint);
|
||||
ncstat = qualifyconstraints3(constraint);
|
||||
if(ncstat != NC_NOERR) goto done;
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -290,7 +290,7 @@ matchsuffix3(NClist* matchpath, NClist* segments, int index0)
|
||||
DCEsegment* seg = (DCEsegment*)nclistget(segments,i);
|
||||
CDFnode* node = (CDFnode*)nclistget(matchpath,index0+i);
|
||||
int match;
|
||||
int rank = nclistlength(seg->slices);
|
||||
int rank = seg->rank;
|
||||
/* Do the names match */
|
||||
if(strcmp(seg->name,node->name) != 0) return 0; /* no match */
|
||||
/* Do the ranks match (watch out for sequences) */
|
||||
@ -322,12 +322,13 @@ matchpartialname3(NClist* nodes, NClist* segments, CDFnode** nodep)
|
||||
lastseg = (DCEsegment*)nclistget(segments,nsegs-1);
|
||||
for(i=0;i<nclistlength(nodes);i++) {
|
||||
CDFnode* node = (CDFnode*)nclistget(nodes,i);
|
||||
if(strcmp(node->name,lastseg->name) != 0)
|
||||
continue;
|
||||
if(node->nctype != NC_Sequence
|
||||
&& node->nctype != NC_Structure
|
||||
&& node->nctype != NC_Grid
|
||||
&& node->nctype != NC_Primitive
|
||||
) continue;
|
||||
if(strcmp(node->name,lastseg->name) != 0) continue;
|
||||
nclistpush(namematches,(ncelem)node);
|
||||
}
|
||||
if(nclistlength(namematches)==0) {
|
||||
@ -486,11 +487,12 @@ fprintf(stderr,"restriction.before=|%s|\n",
|
||||
(like a complete grid) */
|
||||
nodeset = unifyprojectionnodes3(varlist);
|
||||
for(i=0;i<nclistlength(nodeset);i++) {
|
||||
DCEprojection* newp;
|
||||
CDFnode* var = (CDFnode*)nclistget(nodeset,i);
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"restriction.candidate=|%s|\n",var->ncfullname);
|
||||
#endif
|
||||
DCEprojection* newp = (DCEprojection*)dcecreate(CES_PROJECT);
|
||||
newp = (DCEprojection*)dcecreate(CES_PROJECT);
|
||||
|
||||
newp->discrim = CES_VAR;
|
||||
newp->var = (DCEvar*)dcecreate(CES_VAR);
|
||||
@ -888,7 +890,6 @@ buildvaraprojection3(Getvara* getvar,
|
||||
int ncrank;
|
||||
NCerror ncstat = NC_NOERR;
|
||||
CDFnode* var = getvar->target;
|
||||
NClist* vardims = var->array.dimensions;
|
||||
DCEprojection* projection = NULL;
|
||||
NClist* path = nclistnew();
|
||||
NClist* segments = NULL;
|
||||
@ -930,7 +931,7 @@ buildvaraprojection3(Getvara* getvar,
|
||||
segment->rank = localrank;
|
||||
for(j=0;j<localrank;j++) {
|
||||
DCEslice* slice = &segment->slices[j];
|
||||
CDFnode* dim = (CDFnode*)nclistget(vardims,dimindex+j);
|
||||
CDFnode* dim = (CDFnode*)nclistget(dimset,dimindex+j);
|
||||
/* make each slice represent the corresponding
|
||||
start/count/stride */
|
||||
slice->first = startp[dimindex+j];
|
||||
|
@ -7,7 +7,7 @@
|
||||
#define CONSTRAINTS3_H 1
|
||||
|
||||
extern NCerror parsedapconstraints(NCDAPCOMMON*, char*, DCEconstraint*);
|
||||
extern NCerror mapconstraints3(NCDAPCOMMON*);
|
||||
extern NCerror mapconstraints3(DCEconstraint*,CDFnode*);
|
||||
|
||||
extern char* simplepathstring(NClist* segments, char* separator);
|
||||
extern void makesegmentstring3(NClist* segments, NCbytes* buf, char* separator);
|
||||
|
@ -962,15 +962,18 @@ dap_oc_fetch(NCDAPCOMMON* nccomm, OCconnection conn, const char* ce,
|
||||
{
|
||||
OCerror ocstat;
|
||||
char* ext;
|
||||
if(dxd == OCDDS) ext = "dds";
|
||||
else if(dxd == OCDAS) ext = "das";
|
||||
else ext = "dods";
|
||||
if(dxd == OCDDS) ext = ".dds";
|
||||
else if(dxd == OCDAS) ext = ".das";
|
||||
else ext = ".dods";
|
||||
if(ce != NULL && strlen(ce) == 0) ce = NULL;
|
||||
if(FLAGSET(nccomm->controls,NCF_SHOWFETCH)) {
|
||||
/* Build uri string minus the constraint */
|
||||
char* baseuri = ocuribuild(nccomm->oc.uri,NULL,ext,0);
|
||||
if(ce == NULL)
|
||||
nclog(NCLOGNOTE,"fetch: %s.%s",nccomm->oc.uri->uri,ext);
|
||||
nclog(NCLOGNOTE,"fetch: %s",baseuri);
|
||||
else
|
||||
nclog(NCLOGNOTE,"fetch: %s.%s?%s",nccomm->oc.uri->uri,ext,ce);
|
||||
nclog(NCLOGNOTE,"fetch: %s?%s",baseuri,ce);
|
||||
nullfree(baseuri);
|
||||
#ifdef HAVE_GETTIMEOFDAY
|
||||
gettimeofday(&time0,NULL);
|
||||
#endif
|
||||
|
@ -130,6 +130,7 @@ dceslicemerge(DCEslice* dst, DCEslice* src)
|
||||
int err = NC_NOERR;
|
||||
DCEslice tmp;
|
||||
|
||||
tmp.node.sort = CES_SLICE;
|
||||
tmp.stride = (dst->stride * src->stride);
|
||||
tmp.first = (dst->first+((src->first)*(dst->stride)));
|
||||
tmp.length = (((src->length - 1) / src->stride) * tmp.stride) + 1;
|
||||
|
@ -96,6 +96,7 @@ segment(DCEparsestate* state, Object name, Object slices0)
|
||||
NClist* slices = (NClist*)slices0;
|
||||
segment->name = strdup((char*)name);
|
||||
if(slices != NULL && nclistlength(slices) > 0) {
|
||||
segment->rank = nclistlength(slices);
|
||||
segment->slicesdefined = 1; /* but not declsizes */
|
||||
for(i=0;i<nclistlength(slices);i++) {
|
||||
DCEslice* slice = (DCEslice*)nclistget(slices,i);
|
||||
|
@ -2,8 +2,13 @@
|
||||
PARMS=""; ARGS=""; CON="" ; CE=""; OCON=""
|
||||
PARMS="[log]"
|
||||
|
||||
F="http://ferret.pmel.noaa.gov/geoide/dodsC/ct_flux"
|
||||
|
||||
F="http://nomads.ncep.noaa.gov:9090/dods/gfs_hd/gfs_hd20110908/gfs_hd_00z"
|
||||
CON="absvprs[0:10][6:6][0:10][0:10]"
|
||||
if test 1 = 0; then
|
||||
F="http://nomads.ncep.noaa.gov:9090/dods/gfs_hd/gfs_hd20110908/gfs_hd_00z"
|
||||
CON="absvprs[0:1:64][6:1:6][0:1:360][0:1:719]"
|
||||
F="http://ferret.pmel.noaa.gov/geoide/dodsC/ct_flux"
|
||||
F="http://motherlode.ucar.edu:9080/thredds/dodsC/fmrc/NCEP/GFS/Alaska_191km/NCEP-GFS-Alaska_191km_fmrc.ncx"
|
||||
F="file:///home/dmh/nc/oc/dataset-duacs-nrt-over30d-global-merged-madt-h"
|
||||
F="http://oceanwatch.pfeg.noaa.gov/opendap/GLOBEC/GLOBEC_cetaceans"
|
||||
|
@ -6,6 +6,8 @@
|
||||
#ifndef NCCOMMON_H
|
||||
#define NCCOMMON_H 1
|
||||
|
||||
#define DDSNEW 1
|
||||
|
||||
/* Mnemonics */
|
||||
#ifndef BOOL
|
||||
#define BOOL int
|
||||
@ -129,8 +131,13 @@ typedef struct NCOC {
|
||||
} NCOC;
|
||||
|
||||
typedef struct NCCDF {
|
||||
#ifdef DDSNEW
|
||||
struct CDFnode* ddsroot; /* constrained dds */
|
||||
struct CDFnode* fullddsroot; /* unconstrained dds */
|
||||
#else
|
||||
struct CDFnode* ddsroot; /* unconstrained dds */
|
||||
/* Collected sets of useful nodes (in unconstrainted tree space) */
|
||||
#endif
|
||||
/* Collected sets of useful nodes (in ddsroot tree space) */
|
||||
NClist* varnodes; /* nodes which can represent netcdf variables */
|
||||
NClist* seqnodes; /* sequence nodes; */
|
||||
NClist* gridnodes; /* grid nodes */
|
||||
@ -251,6 +258,9 @@ typedef struct CDFnode {
|
||||
unsigned long sequencelimit; /* 0=>unlimited */
|
||||
BOOL usesequence; /* If this sequence is usable */
|
||||
BOOL elided; /* 1 => node does not partipate in naming*/
|
||||
#ifdef DDSNEW
|
||||
struct CDFnode* basenode; /* map from constrained tree to unconstrained */
|
||||
#endif
|
||||
BOOL visible; /* 1 => node is present in constrained tree;
|
||||
independent of elided flag */
|
||||
BOOL zerodim; /* 1 => node has a zero dimension */
|
||||
|
@ -173,17 +173,17 @@ fprintf(stderr,"parsed constraint: %s\n",
|
||||
ncstat = fetchtemplatemetadata3(&drno->dap);
|
||||
if(ncstat != NC_NOERR) goto done;
|
||||
|
||||
/* Process the constraints to map the CDF tree */
|
||||
ncstat = mapconstraints3(&drno->dap);
|
||||
if(ncstat != NC_NOERR) goto done;
|
||||
|
||||
/* fetch and build the constrained DDS */
|
||||
ncstat = fetchconstrainedmetadata3(&drno->dap);
|
||||
if(ncstat != NC_NOERR) goto done;
|
||||
|
||||
/* The following actions are WRT to the
|
||||
/* The following actions are (mostly) WRT to the
|
||||
constrained tree */
|
||||
|
||||
/* Process the constraints to map to the constrained CDF tree */
|
||||
ncstat = mapconstraints3(drno->dap.oc.dapconstraint,drno->dap.cdf.ddsroot);
|
||||
if(ncstat != NC_NOERR) goto done;
|
||||
|
||||
/* Accumulate useful nodes sets */
|
||||
ncstat = computecdfnodesets3(&drno->dap);
|
||||
if(ncstat) {THROWCHK(ncstat); goto done;}
|
||||
|
@ -142,10 +142,15 @@ extern NCerror nc3d_open(const char* path, int mode, int* ncidp);
|
||||
extern int nc3d_close(int ncid);
|
||||
extern int nc3dinitialize(void);
|
||||
extern NCerror regrid3(CDFnode* ddsroot, CDFnode* template, NClist*);
|
||||
extern void setvisible(CDFnode* root, int visible);
|
||||
#ifdef DDSNEW
|
||||
extern NCerror mapnodes3(CDFnode* dstroot, CDFnode* srcroot);
|
||||
extern void unmap3(CDFnode* root);
|
||||
#else
|
||||
extern NCerror imprint3(CDFnode* dstroot, CDFnode* srcroot);
|
||||
extern void unimprint3(CDFnode* root);
|
||||
extern NCerror imprintself3(CDFnode* root);
|
||||
extern void setvisible(CDFnode* root, int visible);
|
||||
#endif
|
||||
|
||||
/* From: ncdap3a.c*/
|
||||
extern NCerror fetchtemplatemetadata3(NCDAPCOMMON* nccomm);
|
||||
|
@ -648,11 +648,19 @@ fetchtemplatemetadata3(NCDAPCOMMON* nccomm)
|
||||
if(nccomm->cdf.ddsroot != NULL)
|
||||
freecdfroot34(&drno->dap->cdf.ddsroot);
|
||||
#endif
|
||||
nccomm->cdf.ddsroot = ddsroot;
|
||||
|
||||
/* Combine */
|
||||
#ifdef DDSNEW
|
||||
nccomm->cdf.fullddsroot = ddsroot;
|
||||
#else
|
||||
nccomm->cdf.ddsroot = ddsroot;
|
||||
#endif
|
||||
|
||||
#ifdef DDSNEW
|
||||
#else
|
||||
/* Combine DDS and DAS */
|
||||
ncstat = dapmerge3(nccomm,ddsroot,nccomm->oc.ocdasroot);
|
||||
if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto done;}
|
||||
#endif
|
||||
|
||||
done:
|
||||
nullfree(ce);
|
||||
@ -674,11 +682,15 @@ fetchconstrainedmetadata3(NCDAPCOMMON* nccomm)
|
||||
else
|
||||
ce = buildconstraintstring3(nccomm->oc.dapconstraint);
|
||||
|
||||
#ifdef DDSNEW
|
||||
#else
|
||||
if(ce == NULL || strlen(ce) == 0) {
|
||||
/* no need to get the dds again; just imprint on self */
|
||||
ncstat = imprintself3(nccomm->cdf.ddsroot);
|
||||
if(ncstat) goto fail;
|
||||
} else {
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
ocstat = dap_oc_fetch(nccomm,nccomm->oc.conn,ce,OCDDS,&ocroot);
|
||||
if(ocstat != OC_NOERR) {THROWCHK(ocstat); goto fail;}
|
||||
|
||||
@ -686,9 +698,17 @@ fetchconstrainedmetadata3(NCDAPCOMMON* nccomm)
|
||||
ncstat = buildcdftree34(nccomm,ocroot,OCDDS,&ddsroot);
|
||||
if(ncstat) goto fail;
|
||||
|
||||
#ifdef DDSNEW
|
||||
nccomm->cdf.ddsroot = ddsroot;
|
||||
#endif
|
||||
|
||||
if(!FLAGSET(nccomm->controls,NCF_UNCONSTRAINABLE)) {
|
||||
/* fix DAP server problem by adding back any missing grid nodes */
|
||||
/* fix DAP server problem by adding back any missing grid structure nodes */
|
||||
#ifdef DDSNEW
|
||||
ncstat = regrid3(ddsroot,nccomm->cdf.fullddsroot,nccomm->oc.dapconstraint->projections);
|
||||
#else
|
||||
ncstat = regrid3(ddsroot,nccomm->cdf.ddsroot,nccomm->oc.dapconstraint->projections);
|
||||
#endif
|
||||
if(ncstat) goto fail;
|
||||
}
|
||||
|
||||
@ -696,12 +716,23 @@ fetchconstrainedmetadata3(NCDAPCOMMON* nccomm)
|
||||
fprintf(stderr,"constrained:\n%s",dumptree(ddsroot));
|
||||
#endif
|
||||
|
||||
#ifdef DDSNEW
|
||||
/* Combine DDS and DAS */
|
||||
if(nccomm->oc.ocdasroot != NULL) {
|
||||
ncstat = dapmerge3(nccomm,ddsroot,nccomm->oc.ocdasroot);
|
||||
if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto fail;}
|
||||
}
|
||||
|
||||
/* map the constrained DDS to the unconstrained DDS */
|
||||
ncstat = mapnodes3(ddsroot,nccomm->cdf.fullddsroot);
|
||||
if(ncstat) goto fail;
|
||||
#else
|
||||
/* Imprint the constrained DDS data over the unconstrained DDS */
|
||||
ncstat = imprint3(nccomm->cdf.ddsroot,ddsroot);
|
||||
if(ncstat) goto fail;
|
||||
|
||||
/* Throw away the constrained DDS */
|
||||
freecdfroot34(ddsroot);
|
||||
#endif
|
||||
}
|
||||
|
||||
fail:
|
||||
|
@ -199,16 +199,16 @@ ocdebug = 1;
|
||||
ncstat = fetchtemplatemetadata3(&drno->dap);
|
||||
if(ncstat != NC_NOERR) goto done;
|
||||
|
||||
/* Process the constraints to map the CDF tree */
|
||||
ncstat = mapconstraints3(&drno->dap);
|
||||
if(ncstat != NC_NOERR) goto done;
|
||||
|
||||
/* fetch and build the constrained DDS */
|
||||
ncstat = fetchconstrainedmetadata3(&drno->dap);
|
||||
if(ncstat != NC_NOERR) goto done;
|
||||
|
||||
/* The following actions are WRT to the constrained tree */
|
||||
|
||||
/* Process the constraints to map the CDF tree */
|
||||
ncstat = mapconstraints3(drno->dap.oc.dapconstraint,drno->dap.cdf.ddsroot);
|
||||
if(ncstat != NC_NOERR) goto done;
|
||||
|
||||
/* Accumulate useful nodes sets */
|
||||
ncstat = computecdfnodesets4(&drno->dap);
|
||||
if(ncstat) {THROWCHK(ncstat); goto done;}
|
||||
|
@ -17,8 +17,9 @@ libdispatch_la_CPPFLAGS = ${AM_CPPFLAGS}
|
||||
# The source files.
|
||||
libdispatch_la_SOURCES = dparallel.c dcopy.c dfile.c ddim.c datt.c \
|
||||
dattinq.c dattput.c dattget.c derror.c dvar.c dvarget.c dvarput.c \
|
||||
dvarinq.c ddispatch.c nc_uri.c dnclist.c dncbytes.c dnchashmap.c \
|
||||
dnclog.c dstring.c dutf8proc.c utf8proc_data.h
|
||||
dvarinq.c ddispatch.c \
|
||||
dnclog.c dstring.c dutf8proc.c utf8proc_data.h \
|
||||
nc_uri.c nclist.c ncbytes.c nchashmap.c
|
||||
|
||||
# Add functions only found in netCDF-4.
|
||||
if USE_NETCDF4
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include <string.h>
|
||||
#include <netcdf.h>
|
||||
|
||||
#define URL "http://test.opendap.org:8080/dods/dts/test.02"
|
||||
#define URL "http://motherlod.ucar.edu:8081/dods/dts/test.02"
|
||||
#define VAR "i32"
|
||||
|
||||
#define ERRCODE 2
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "netcdf.h"
|
||||
|
||||
#define FILE_NAME "tst_files.nc"
|
||||
#define URL "http://test.opendap.org:8080/dods/dts/test.01"
|
||||
#define URL "http://motherlode.ucar.edu:8081/dods/dts/test.01"
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include <nc_tests.h>
|
||||
#include "netcdf.h"
|
||||
|
||||
#define URL "http://test.opendap.org:8080/dods/dts/test.01"
|
||||
#define URL "http://motherlode.ucar.edu:8081/dods/dts/test.01"
|
||||
#define FILE_NAME "tst_files6.nc"
|
||||
|
||||
int
|
||||
|
@ -125,8 +125,9 @@ main()
|
||||
printf("\n");
|
||||
#endif
|
||||
|
||||
check(err = nc_get_varm_float (ncid, varid, start, count, stride, imap,
|
||||
(float*) dat),__FILE__,__LINE__);
|
||||
// check(err = nc_get_varm_float (ncid, varid, start, count, stride, imap,(float*) dat),__FILE__,__LINE__);
|
||||
check(err = nc_get_vara_float (ncid, varid, start, count, (float*) dat),__FILE__,__LINE__);
|
||||
|
||||
#ifdef STANDALONE
|
||||
printf("varm: %s =",VAR);
|
||||
for(i=0;i<12;i++) printf(" %f",dat[i]);
|
||||
|
@ -48,7 +48,7 @@ FILETESTS="${SYNTHETICDATA} ${ACTUALDATA1} ${ACTUALDATA2}"
|
||||
# Remote test info
|
||||
##################################################
|
||||
|
||||
# REMOTEURL1="http://test.opendap.org:8080/dods/dts"
|
||||
# REMOTEURL1="http://motherlode.ucar.edu:8081/dods/dts"
|
||||
# REMOTEURL2="http://test.opendap.org/dap/netcdf/examples"
|
||||
#
|
||||
#
|
||||
|
@ -55,14 +55,14 @@ fi
|
||||
WHICHTESTS="C2"
|
||||
|
||||
# For special testing
|
||||
REMOTEURLX="http://test.opendap.org:8080/dods/dts"
|
||||
REMOTEURLX="http://motherlode.ucar.edu:8081/dods/dts"
|
||||
REMOTETESTSX="test.03"
|
||||
|
||||
REMOTEURLXC="http://test.opendap.org:8080/dods/dts"
|
||||
REMOTEURLXC="http://motherlode.ucar.edu:8081/dods/dts"
|
||||
REMOTETESTSXC="test.03;1;s0,s1"
|
||||
|
||||
# These shorter tests are always run
|
||||
REMOTEURLS1="http://test.opendap.org:8080/dods/dts"
|
||||
REMOTEURLS1="http://motherlode.ucar.edu:8081/dods/dts"
|
||||
REMOTETESTSS1="\
|
||||
test.01 test.02 test.04 test.05 test.06a test.07a test.07 \
|
||||
test.21 test.22 test.23 \
|
||||
@ -92,7 +92,7 @@ TOOBIG="parserBug0001 test.satimage Sat_Images test.06 test.32"
|
||||
ESCAPEDFAIL="test.dfr1 test.dfr2 test.dfr3 test.GridFile test.PointFile test.SwathFile test.sds6 test.sds7"
|
||||
|
||||
# Following tests are to check constraint handling
|
||||
REMOTEURLC1="http://test.opendap.org:8080/dods/dts"
|
||||
REMOTEURLC1="http://motherlode.ucar.edu:8081/dods/dts"
|
||||
REMOTETESTSC1="\
|
||||
test.01;1;f64 \
|
||||
test.02;1;b[1:2:10] \
|
||||
@ -117,7 +117,7 @@ argo_all.cdp;1;&location.LATITUDE<1&location.LATITUDE>-1\
|
||||
"
|
||||
|
||||
# Constrained long tests
|
||||
REMOTEURLLC1="http://test.opendap.org:8080/dods/dts"
|
||||
REMOTEURLLC1="http://motherlode.ucar.edu:8081/dods/dts"
|
||||
REMOTETESTSLC1="\
|
||||
test.03;2;s1"
|
||||
|
||||
|
113
ncgen/ncgen.y
113
ncgen/ncgen.y
@ -14,6 +14,11 @@ static char SccsId[] = "$Id: ncgen.y,v 1.42 2010/05/18 21:32:46 dmh Exp $";
|
||||
*/
|
||||
#include "includes.h"
|
||||
#include "offsets.h"
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
|
||||
#define TIMEFORMAT "%Y-%m-%d"
|
||||
extern char *strptime(const char *s, const char *format, struct tm *tm);
|
||||
|
||||
/* parser controls */
|
||||
#define YY_NO_INPUT 1
|
||||
@ -92,6 +97,7 @@ List* tmp;
|
||||
|
||||
/* Forward */
|
||||
static Constant makeconstdata(nc_type);
|
||||
static Constant evaluate(Symbol* fcn, Datalist* arglist);
|
||||
static Constant makeenumconst(Symbol*);
|
||||
static void addtogroup(Symbol*);
|
||||
static Symbol* getunlimiteddim(void);
|
||||
@ -189,7 +195,8 @@ Constant constant;
|
||||
%type <mark> enumidlist fieldlist fields varlist dimspec dimlist field
|
||||
fielddimspec fielddimlist
|
||||
%type <constant> dataitem constdata constint conststring constbool
|
||||
%type <datalist> datalist intlist datalist1 datalist0
|
||||
%type <constant> simpleconstant function
|
||||
%type <datalist> datalist intlist datalist1 datalist0 arglist
|
||||
|
||||
|
||||
%start ncdesc /* start symbol for grammar */
|
||||
@ -789,6 +796,25 @@ dataitem:
|
||||
;
|
||||
|
||||
constdata:
|
||||
simpleconstant {$$=$1;}
|
||||
| OPAQUESTRING {$$=makeconstdata(NC_OPAQUE);}
|
||||
| FILLMARKER {$$=makeconstdata(NC_FILLVALUE);}
|
||||
| path {$$=makeenumconst($1);}
|
||||
| function
|
||||
;
|
||||
|
||||
function:
|
||||
IDENT '(' arglist ')' {$$=evaluate($1,$3);}
|
||||
;
|
||||
|
||||
arglist:
|
||||
simpleconstant
|
||||
{$$ = builddatalist(0); datalistextend($$,&($1));}
|
||||
| arglist ',' simpleconstant
|
||||
{datalistextend($1,&($3)); $$=$1;}
|
||||
;
|
||||
|
||||
simpleconstant:
|
||||
CHAR_CONST {$$=makeconstdata(NC_CHAR);} /* never used apparently*/
|
||||
| BYTE_CONST {$$=makeconstdata(NC_BYTE);}
|
||||
| SHORT_CONST {$$=makeconstdata(NC_SHORT);}
|
||||
@ -801,9 +827,6 @@ constdata:
|
||||
| FLOAT_CONST {$$=makeconstdata(NC_FLOAT);}
|
||||
| DOUBLE_CONST {$$=makeconstdata(NC_DOUBLE);}
|
||||
| TERMSTRING {$$=makeconstdata(NC_STRING);}
|
||||
| OPAQUESTRING {$$=makeconstdata(NC_OPAQUE);}
|
||||
| path {$$=makeenumconst($1);}
|
||||
| FILLMARKER {$$=makeconstdata(NC_FILLVALUE);}
|
||||
;
|
||||
|
||||
intlist:
|
||||
@ -1381,3 +1404,85 @@ vercheck(int ncid)
|
||||
}
|
||||
if(tmsg != NULL) markcdf4(tmsg);
|
||||
}
|
||||
|
||||
/*
|
||||
Since the arguments are all simple constant,
|
||||
we can evaluate the function immediately
|
||||
and return its value.
|
||||
*/
|
||||
|
||||
static Constant
|
||||
evaluate(Symbol* fcn, Datalist* arglist)
|
||||
{
|
||||
Constant result;
|
||||
|
||||
/* prepare the result */
|
||||
result.lineno = fcn->lineno;
|
||||
result.filled = 0;
|
||||
|
||||
#if defined(HAVE_STRPTIME) && defined(HAVE_MKTIME)
|
||||
if(strcasecmp(fcn->name,"time") == 0) {
|
||||
result.nctype = NC_INT;
|
||||
result.value.int32v = 0;
|
||||
/* int time(string,string) */
|
||||
if(arglist->length != 2
|
||||
|| arglist->data[0].nctype != NC_STRING
|
||||
|| arglist->data[1].nctype != NC_STRING) {
|
||||
derror("Expected function signature: time(string,string)");
|
||||
goto done;
|
||||
} else {
|
||||
char* timekind = arglist->data[0].value.stringv.stringv;
|
||||
char* timevalue = arglist->data[1].value.stringv.stringv;
|
||||
if(strcasecmp(timekind,"timetest")==0) {
|
||||
struct tm time;
|
||||
memset(&time,0,sizeof(time));
|
||||
if(strptime(timevalue,TIMEFORMAT,&time) == NULL) {
|
||||
derror("Malformed time string: %s",timevalue);
|
||||
goto done;
|
||||
} else {
|
||||
result.value.int32v = (int)mktime(&time);
|
||||
}
|
||||
} else {
|
||||
derror("Time conversion '%s' not supported",timekind);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
} else if(strcasecmp(fcn->name,"math") == 0) {
|
||||
/* int match(string,string) */
|
||||
if(arglist->length != 2
|
||||
|| arglist->data[0].nctype != NC_STRING
|
||||
|| arglist->data[1].nctype != NC_STRING) {
|
||||
derror("Expected function signature: math(string,string)");
|
||||
goto done;
|
||||
} else {
|
||||
char* fcn = arglist->data[0].value.stringv.stringv;
|
||||
char* arg = arglist->data[1].value.stringv.stringv;
|
||||
double matharg = 0.0;
|
||||
result.nctype = NC_INT64;
|
||||
result.value.int64v = 0;
|
||||
if(sscanf(arg,"%le",&matharg) != 1) {
|
||||
derror("Malformed math function value: %s",arg);
|
||||
goto done;
|
||||
}
|
||||
if(strcasecmp(fcn,"sin")==0) {
|
||||
result.value.int64v = sin(matharg);
|
||||
} else if(strcasecmp(fcn,"cos")==0) {
|
||||
result.value.int64v = cos(matharg);
|
||||
} else if(strcasecmp(fcn,"tan")==0) {
|
||||
result.value.int64v = tan(matharg);
|
||||
} else {
|
||||
derror("Math function '%s' not supported",fcn);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
{ /* Unknown function */
|
||||
derror("Unknown function name: %s",fcn->name);
|
||||
goto done;
|
||||
}
|
||||
|
||||
done:
|
||||
return result;
|
||||
}
|
||||
|
||||
|
794
ncgen/ncgentab.c
794
ncgen/ncgentab.c
File diff suppressed because it is too large
Load Diff
743
oc/daptab.c
743
oc/daptab.c
File diff suppressed because it is too large
Load Diff
@ -1,8 +1,9 @@
|
||||
/* A Bison parser, made by GNU Bison 2.5. */
|
||||
/* A Bison parser, made by GNU Bison 2.4.3. */
|
||||
|
||||
/* Bison interface for Yacc-like parsers in C
|
||||
/* Skeleton interface for Bison's Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
|
||||
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
|
||||
2009, 2010 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -27,14 +27,13 @@ extern void ocurifree(OCURI* ocuri);
|
||||
/* Replace the constraints */
|
||||
extern void ocurisetconstraints(OCURI*,const char* constraints);
|
||||
|
||||
/* Construct a complete OC URI; caller frees returned string */
|
||||
|
||||
/* Define flags to control what is included */
|
||||
#define OCURICONSTRAINTS 1
|
||||
#define OCURIUSERPWD 2
|
||||
#define OCURIPARAMS 4
|
||||
#define OCURIENCODE 8 /* If output should be encoded */
|
||||
|
||||
/* Construct a complete OC URI; caller frees returned string */
|
||||
extern char* ocuribuild(OCURI*,const char* prefix, const char* suffix, int flags);
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user