fix NCF-120

This commit is contained in:
Dennis Heimbigner 2011-09-15 16:57:16 +00:00
parent 51906ca254
commit 16dee702b7
31 changed files with 1190 additions and 837 deletions

2
cf
View File

@ -15,7 +15,7 @@ DAP=1
#cmds="all" #cmds="all"
#cmds="all check" #cmds="all check"
#cmds="all dist" #cmds="all dist"
cmds="all distcheck" #cmds="all distcheck"
PREFIX="/tmp/install/${HOST}" PREFIX="/tmp/install/${HOST}"
stddir="/share/ed/local/${HOST}" stddir="/share/ed/local/${HOST}"

View File

@ -60,7 +60,7 @@ AM_CONDITIONAL([BUILD_DOCS], [test "x$enable_doxygen" != xno])
AC_ARG_ENABLE([internal-docs], AC_ARG_ENABLE([internal-docs],
[AS_HELP_STRING([--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.])]) [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_SUBST([BUILD_INTERNAL_DOCS], [$enable_internal_docs])
AC_MSG_CHECKING([if fsync support is enabled]) AC_MSG_CHECKING([if fsync support is enabled])
@ -566,6 +566,9 @@ AC_FUNC_VPRINTF
# Check for <stdbool.h> that conforms to C99 requirements # Check for <stdbool.h> that conforms to C99 requirements
AC_HEADER_STDBOOL AC_HEADER_STDBOOL
AC_CHECK_FUNCS([mktime])
AC_CHECK_FUNCS([strptime])
# Check for these functions... # Check for these functions...
AC_CHECK_FUNCS([strlcat strerror snprintf strchr strrchr mktemp strcat strcpy strdup \ AC_CHECK_FUNCS([strlcat strerror snprintf strchr strrchr mktemp strcat strcpy strdup \
strcasecmp strtod strtoll strtoull getrlimit gettimeofday fsync MPI_Comm_f2c]) strcasecmp strtod strtoll strtoull getrlimit gettimeofday fsync MPI_Comm_f2c])

View File

@ -19,7 +19,7 @@ typedef long long int64_t;
#define true 1 #define true 1
#define false 0 #define false 0
#define TRUE 1 #define TRUE 1
#define FALSE 1 #define FALSE 0
#endif #endif
typedef unsigned int bool_t; typedef unsigned int bool_t;

View File

@ -137,6 +137,7 @@ nclog(NCLOGNOTE,"prefetch.");
} }
#ifdef DEBUG #ifdef DEBUG
{
/* Log the set of prefetch variables */ /* Log the set of prefetch variables */
NCbytes* buf = ncbytesnew(); NCbytes* buf = ncbytesnew();
ncbytescat(buf,"prefetch.vars: "); ncbytescat(buf,"prefetch.vars: ");
@ -148,6 +149,7 @@ ncbytescat(buf,makesimplepathstring3(var));
ncbytescat(buf,"\n"); ncbytescat(buf,"\n");
nclog(NCLOGNOTE,"%s",ncbytescontents(buf)); nclog(NCLOGNOTE,"%s",ncbytescontents(buf));
ncbytesfree(buf); ncbytesfree(buf);
}
#endif #endif
/* Make cache node be the prefetch node */ /* Make cache node be the prefetch node */

View File

@ -26,11 +26,16 @@ static NCerror testregrid3(CDFnode* node, CDFnode* template, NClist*);
static CDFnode* makenewstruct3(CDFnode* node, CDFnode* template); static CDFnode* makenewstruct3(CDFnode* node, CDFnode* template);
static NCerror regridinsert(CDFnode* newgrid, CDFnode* node); static NCerror regridinsert(CDFnode* newgrid, CDFnode* node);
static NCerror regridremove(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 projection3r(CDFnode*);
static void unprojected3(NClist* nodes); static void unprojected3(NClist* nodes);
static void projectall3(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 */ /* Accumulate useful node sets */
NCerror NCerror
@ -395,6 +400,9 @@ fprintf(stderr,"regrid: template=%s\n",dumptree(template));
This includes containers and subnodes. If there are no This includes containers and subnodes. If there are no
projections then mark all nodes projections then mark all nodes
*/ */
#ifdef DDSNEW
projectall3(template->tree->nodes);
#else
if(nclistlength(projections) == 0) { if(nclistlength(projections) == 0) {
projectall3(template->tree->nodes); projectall3(template->tree->nodes);
} else for(i=0;i<nclistlength(projections);i++) { } 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); ASSERT(proj->discrim == CES_VAR);
projection3r(proj->var->cdfleaf); projection3r(proj->var->cdfleaf);
} }
#endif
if(simplenodematch34(ddsroot,template)) { if(simplenodematch34(ddsroot,template)) {
ncstat = regrid3r(ddsroot,template,newstructs); ncstat = regrid3r(ddsroot,template,newstructs);
@ -655,6 +664,95 @@ findddsnode0(CDFnode* node)
} }
#endif #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 Move data from nodes in src tree to nodes in dst tree where
the nodes match. Src tree is typically a structural subset the nodes match. Src tree is typically a structural subset
@ -741,6 +839,7 @@ unimprint3(CDFnode* root)
} }
} }
} }
#endif /*!DDSNEW*/
void void
setvisible(CDFnode* root, int visible) setvisible(CDFnode* root, int visible)

View File

@ -59,22 +59,22 @@ fprintf(stderr,"constraint: %s",dumpconstraint(dceconstraint));
return ncstat; 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. is that suffix paths are legal.
*/ */
NCerror NCerror
mapconstraints3(NCDAPCOMMON* dapcomm) mapconstraints3(DCEconstraint* constraint,
CDFnode* root)
{ {
int i; int i;
NCerror ncstat = NC_NOERR; NCerror ncstat = NC_NOERR;
CDFnode* root = dapcomm->cdf.ddsroot;
NClist* nodes = root->tree->nodes; NClist* nodes = root->tree->nodes;
NClist* dceprojections; NClist* dceprojections;
NClist* dceselections; NClist* dceselections;
dceprojections = dapcomm->oc.dapconstraint->projections; dceprojections = constraint->projections;
dceselections = dapcomm->oc.dapconstraint->selections; dceselections = constraint->selections;
/* Convert the projection paths to leaves in the dds tree */ /* Convert the projection paths to leaves in the dds tree */
for(i=0;i<nclistlength(dceprojections);i++) { for(i=0;i<nclistlength(dceprojections);i++) {
@ -105,7 +105,7 @@ mapconstraints3(NCDAPCOMMON* dapcomm)
} }
} }
/* Fill in segment information */ /* Fill in segment information */
ncstat = qualifyconstraints3(dapcomm->oc.dapconstraint); ncstat = qualifyconstraints3(constraint);
if(ncstat != NC_NOERR) goto done; if(ncstat != NC_NOERR) goto done;
#ifdef DEBUG #ifdef DEBUG
@ -290,7 +290,7 @@ matchsuffix3(NClist* matchpath, NClist* segments, int index0)
DCEsegment* seg = (DCEsegment*)nclistget(segments,i); DCEsegment* seg = (DCEsegment*)nclistget(segments,i);
CDFnode* node = (CDFnode*)nclistget(matchpath,index0+i); CDFnode* node = (CDFnode*)nclistget(matchpath,index0+i);
int match; int match;
int rank = nclistlength(seg->slices); int rank = seg->rank;
/* Do the names match */ /* Do the names match */
if(strcmp(seg->name,node->name) != 0) return 0; /* no match */ if(strcmp(seg->name,node->name) != 0) return 0; /* no match */
/* Do the ranks match (watch out for sequences) */ /* 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); lastseg = (DCEsegment*)nclistget(segments,nsegs-1);
for(i=0;i<nclistlength(nodes);i++) { for(i=0;i<nclistlength(nodes);i++) {
CDFnode* node = (CDFnode*)nclistget(nodes,i); CDFnode* node = (CDFnode*)nclistget(nodes,i);
if(strcmp(node->name,lastseg->name) != 0)
continue;
if(node->nctype != NC_Sequence if(node->nctype != NC_Sequence
&& node->nctype != NC_Structure && node->nctype != NC_Structure
&& node->nctype != NC_Grid && node->nctype != NC_Grid
&& node->nctype != NC_Primitive && node->nctype != NC_Primitive
) continue; ) continue;
if(strcmp(node->name,lastseg->name) != 0) continue;
nclistpush(namematches,(ncelem)node); nclistpush(namematches,(ncelem)node);
} }
if(nclistlength(namematches)==0) { if(nclistlength(namematches)==0) {
@ -486,11 +487,12 @@ fprintf(stderr,"restriction.before=|%s|\n",
(like a complete grid) */ (like a complete grid) */
nodeset = unifyprojectionnodes3(varlist); nodeset = unifyprojectionnodes3(varlist);
for(i=0;i<nclistlength(nodeset);i++) { for(i=0;i<nclistlength(nodeset);i++) {
DCEprojection* newp;
CDFnode* var = (CDFnode*)nclistget(nodeset,i); CDFnode* var = (CDFnode*)nclistget(nodeset,i);
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr,"restriction.candidate=|%s|\n",var->ncfullname); fprintf(stderr,"restriction.candidate=|%s|\n",var->ncfullname);
#endif #endif
DCEprojection* newp = (DCEprojection*)dcecreate(CES_PROJECT); newp = (DCEprojection*)dcecreate(CES_PROJECT);
newp->discrim = CES_VAR; newp->discrim = CES_VAR;
newp->var = (DCEvar*)dcecreate(CES_VAR); newp->var = (DCEvar*)dcecreate(CES_VAR);
@ -888,7 +890,6 @@ buildvaraprojection3(Getvara* getvar,
int ncrank; int ncrank;
NCerror ncstat = NC_NOERR; NCerror ncstat = NC_NOERR;
CDFnode* var = getvar->target; CDFnode* var = getvar->target;
NClist* vardims = var->array.dimensions;
DCEprojection* projection = NULL; DCEprojection* projection = NULL;
NClist* path = nclistnew(); NClist* path = nclistnew();
NClist* segments = NULL; NClist* segments = NULL;
@ -930,7 +931,7 @@ buildvaraprojection3(Getvara* getvar,
segment->rank = localrank; segment->rank = localrank;
for(j=0;j<localrank;j++) { for(j=0;j<localrank;j++) {
DCEslice* slice = &segment->slices[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 /* make each slice represent the corresponding
start/count/stride */ start/count/stride */
slice->first = startp[dimindex+j]; slice->first = startp[dimindex+j];

View File

@ -7,7 +7,7 @@
#define CONSTRAINTS3_H 1 #define CONSTRAINTS3_H 1
extern NCerror parsedapconstraints(NCDAPCOMMON*, char*, DCEconstraint*); extern NCerror parsedapconstraints(NCDAPCOMMON*, char*, DCEconstraint*);
extern NCerror mapconstraints3(NCDAPCOMMON*); extern NCerror mapconstraints3(DCEconstraint*,CDFnode*);
extern char* simplepathstring(NClist* segments, char* separator); extern char* simplepathstring(NClist* segments, char* separator);
extern void makesegmentstring3(NClist* segments, NCbytes* buf, char* separator); extern void makesegmentstring3(NClist* segments, NCbytes* buf, char* separator);

View File

@ -962,15 +962,18 @@ dap_oc_fetch(NCDAPCOMMON* nccomm, OCconnection conn, const char* ce,
{ {
OCerror ocstat; OCerror ocstat;
char* ext; char* ext;
if(dxd == OCDDS) ext = "dds"; if(dxd == OCDDS) ext = ".dds";
else if(dxd == OCDAS) ext = "das"; else if(dxd == OCDAS) ext = ".das";
else ext = "dods"; else ext = ".dods";
if(ce != NULL && strlen(ce) == 0) ce = NULL; if(ce != NULL && strlen(ce) == 0) ce = NULL;
if(FLAGSET(nccomm->controls,NCF_SHOWFETCH)) { if(FLAGSET(nccomm->controls,NCF_SHOWFETCH)) {
/* Build uri string minus the constraint */
char* baseuri = ocuribuild(nccomm->oc.uri,NULL,ext,0);
if(ce == NULL) if(ce == NULL)
nclog(NCLOGNOTE,"fetch: %s.%s",nccomm->oc.uri->uri,ext); nclog(NCLOGNOTE,"fetch: %s",baseuri);
else 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 #ifdef HAVE_GETTIMEOFDAY
gettimeofday(&time0,NULL); gettimeofday(&time0,NULL);
#endif #endif

View File

@ -130,6 +130,7 @@ dceslicemerge(DCEslice* dst, DCEslice* src)
int err = NC_NOERR; int err = NC_NOERR;
DCEslice tmp; DCEslice tmp;
tmp.node.sort = CES_SLICE;
tmp.stride = (dst->stride * src->stride); tmp.stride = (dst->stride * src->stride);
tmp.first = (dst->first+((src->first)*(dst->stride))); tmp.first = (dst->first+((src->first)*(dst->stride)));
tmp.length = (((src->length - 1) / src->stride) * tmp.stride) + 1; tmp.length = (((src->length - 1) / src->stride) * tmp.stride) + 1;

View File

@ -96,6 +96,7 @@ segment(DCEparsestate* state, Object name, Object slices0)
NClist* slices = (NClist*)slices0; NClist* slices = (NClist*)slices0;
segment->name = strdup((char*)name); segment->name = strdup((char*)name);
if(slices != NULL && nclistlength(slices) > 0) { if(slices != NULL && nclistlength(slices) > 0) {
segment->rank = nclistlength(slices);
segment->slicesdefined = 1; /* but not declsizes */ segment->slicesdefined = 1; /* but not declsizes */
for(i=0;i<nclistlength(slices);i++) { for(i=0;i<nclistlength(slices);i++) {
DCEslice* slice = (DCEslice*)nclistget(slices,i); DCEslice* slice = (DCEslice*)nclistget(slices,i);

View File

@ -2,8 +2,13 @@
PARMS=""; ARGS=""; CON="" ; CE=""; OCON="" PARMS=""; ARGS=""; CON="" ; CE=""; OCON=""
PARMS="[log]" 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 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="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="file:///home/dmh/nc/oc/dataset-duacs-nrt-over30d-global-merged-madt-h"
F="http://oceanwatch.pfeg.noaa.gov/opendap/GLOBEC/GLOBEC_cetaceans" F="http://oceanwatch.pfeg.noaa.gov/opendap/GLOBEC/GLOBEC_cetaceans"

View File

@ -6,6 +6,8 @@
#ifndef NCCOMMON_H #ifndef NCCOMMON_H
#define NCCOMMON_H 1 #define NCCOMMON_H 1
#define DDSNEW 1
/* Mnemonics */ /* Mnemonics */
#ifndef BOOL #ifndef BOOL
#define BOOL int #define BOOL int
@ -129,8 +131,13 @@ typedef struct NCOC {
} NCOC; } NCOC;
typedef struct NCCDF { typedef struct NCCDF {
#ifdef DDSNEW
struct CDFnode* ddsroot; /* constrained dds */
struct CDFnode* fullddsroot; /* unconstrained dds */
#else
struct CDFnode* ddsroot; /* unconstrained dds */ 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* varnodes; /* nodes which can represent netcdf variables */
NClist* seqnodes; /* sequence nodes; */ NClist* seqnodes; /* sequence nodes; */
NClist* gridnodes; /* grid nodes */ NClist* gridnodes; /* grid nodes */
@ -251,6 +258,9 @@ typedef struct CDFnode {
unsigned long sequencelimit; /* 0=>unlimited */ unsigned long sequencelimit; /* 0=>unlimited */
BOOL usesequence; /* If this sequence is usable */ BOOL usesequence; /* If this sequence is usable */
BOOL elided; /* 1 => node does not partipate in naming*/ 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; BOOL visible; /* 1 => node is present in constrained tree;
independent of elided flag */ independent of elided flag */
BOOL zerodim; /* 1 => node has a zero dimension */ BOOL zerodim; /* 1 => node has a zero dimension */

View File

@ -173,17 +173,17 @@ fprintf(stderr,"parsed constraint: %s\n",
ncstat = fetchtemplatemetadata3(&drno->dap); ncstat = fetchtemplatemetadata3(&drno->dap);
if(ncstat != NC_NOERR) goto done; 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 */ /* fetch and build the constrained DDS */
ncstat = fetchconstrainedmetadata3(&drno->dap); ncstat = fetchconstrainedmetadata3(&drno->dap);
if(ncstat != NC_NOERR) goto done; if(ncstat != NC_NOERR) goto done;
/* The following actions are WRT to the /* The following actions are (mostly) WRT to the
constrained tree */ 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 */ /* Accumulate useful nodes sets */
ncstat = computecdfnodesets3(&drno->dap); ncstat = computecdfnodesets3(&drno->dap);
if(ncstat) {THROWCHK(ncstat); goto done;} if(ncstat) {THROWCHK(ncstat); goto done;}

View File

@ -142,10 +142,15 @@ extern NCerror nc3d_open(const char* path, int mode, int* ncidp);
extern int nc3d_close(int ncid); extern int nc3d_close(int ncid);
extern int nc3dinitialize(void); extern int nc3dinitialize(void);
extern NCerror regrid3(CDFnode* ddsroot, CDFnode* template, NClist*); 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 NCerror imprint3(CDFnode* dstroot, CDFnode* srcroot);
extern void unimprint3(CDFnode* root); extern void unimprint3(CDFnode* root);
extern NCerror imprintself3(CDFnode* root); extern NCerror imprintself3(CDFnode* root);
extern void setvisible(CDFnode* root, int visible); #endif
/* From: ncdap3a.c*/ /* From: ncdap3a.c*/
extern NCerror fetchtemplatemetadata3(NCDAPCOMMON* nccomm); extern NCerror fetchtemplatemetadata3(NCDAPCOMMON* nccomm);

View File

@ -648,11 +648,19 @@ fetchtemplatemetadata3(NCDAPCOMMON* nccomm)
if(nccomm->cdf.ddsroot != NULL) if(nccomm->cdf.ddsroot != NULL)
freecdfroot34(&drno->dap->cdf.ddsroot); freecdfroot34(&drno->dap->cdf.ddsroot);
#endif #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); ncstat = dapmerge3(nccomm,ddsroot,nccomm->oc.ocdasroot);
if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto done;} if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto done;}
#endif
done: done:
nullfree(ce); nullfree(ce);
@ -674,11 +682,15 @@ fetchconstrainedmetadata3(NCDAPCOMMON* nccomm)
else else
ce = buildconstraintstring3(nccomm->oc.dapconstraint); ce = buildconstraintstring3(nccomm->oc.dapconstraint);
#ifdef DDSNEW
#else
if(ce == NULL || strlen(ce) == 0) { if(ce == NULL || strlen(ce) == 0) {
/* no need to get the dds again; just imprint on self */ /* no need to get the dds again; just imprint on self */
ncstat = imprintself3(nccomm->cdf.ddsroot); ncstat = imprintself3(nccomm->cdf.ddsroot);
if(ncstat) goto fail; if(ncstat) goto fail;
} else { } else
#endif
{
ocstat = dap_oc_fetch(nccomm,nccomm->oc.conn,ce,OCDDS,&ocroot); ocstat = dap_oc_fetch(nccomm,nccomm->oc.conn,ce,OCDDS,&ocroot);
if(ocstat != OC_NOERR) {THROWCHK(ocstat); goto fail;} if(ocstat != OC_NOERR) {THROWCHK(ocstat); goto fail;}
@ -686,9 +698,17 @@ fetchconstrainedmetadata3(NCDAPCOMMON* nccomm)
ncstat = buildcdftree34(nccomm,ocroot,OCDDS,&ddsroot); ncstat = buildcdftree34(nccomm,ocroot,OCDDS,&ddsroot);
if(ncstat) goto fail; if(ncstat) goto fail;
#ifdef DDSNEW
nccomm->cdf.ddsroot = ddsroot;
#endif
if(!FLAGSET(nccomm->controls,NCF_UNCONSTRAINABLE)) { 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); ncstat = regrid3(ddsroot,nccomm->cdf.ddsroot,nccomm->oc.dapconstraint->projections);
#endif
if(ncstat) goto fail; if(ncstat) goto fail;
} }
@ -696,12 +716,23 @@ fetchconstrainedmetadata3(NCDAPCOMMON* nccomm)
fprintf(stderr,"constrained:\n%s",dumptree(ddsroot)); fprintf(stderr,"constrained:\n%s",dumptree(ddsroot));
#endif #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 */ /* Imprint the constrained DDS data over the unconstrained DDS */
ncstat = imprint3(nccomm->cdf.ddsroot,ddsroot); ncstat = imprint3(nccomm->cdf.ddsroot,ddsroot);
if(ncstat) goto fail; if(ncstat) goto fail;
/* Throw away the constrained DDS */ /* Throw away the constrained DDS */
freecdfroot34(ddsroot); freecdfroot34(ddsroot);
#endif
} }
fail: fail:

View File

@ -199,16 +199,16 @@ ocdebug = 1;
ncstat = fetchtemplatemetadata3(&drno->dap); ncstat = fetchtemplatemetadata3(&drno->dap);
if(ncstat != NC_NOERR) goto done; 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 */ /* fetch and build the constrained DDS */
ncstat = fetchconstrainedmetadata3(&drno->dap); ncstat = fetchconstrainedmetadata3(&drno->dap);
if(ncstat != NC_NOERR) goto done; if(ncstat != NC_NOERR) goto done;
/* The following actions are WRT to the constrained tree */ /* 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 */ /* Accumulate useful nodes sets */
ncstat = computecdfnodesets4(&drno->dap); ncstat = computecdfnodesets4(&drno->dap);
if(ncstat) {THROWCHK(ncstat); goto done;} if(ncstat) {THROWCHK(ncstat); goto done;}

View File

@ -17,8 +17,9 @@ libdispatch_la_CPPFLAGS = ${AM_CPPFLAGS}
# The source files. # The source files.
libdispatch_la_SOURCES = dparallel.c dcopy.c dfile.c ddim.c datt.c \ 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 \ 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 \ dvarinq.c ddispatch.c \
dnclog.c dstring.c dutf8proc.c utf8proc_data.h 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. # Add functions only found in netCDF-4.
if USE_NETCDF4 if USE_NETCDF4

View File

@ -4,7 +4,7 @@
#include <string.h> #include <string.h>
#include <netcdf.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 VAR "i32"
#define ERRCODE 2 #define ERRCODE 2

View File

@ -9,7 +9,7 @@
#include "netcdf.h" #include "netcdf.h"
#define FILE_NAME "tst_files.nc" #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 int
main(int argc, char **argv) main(int argc, char **argv)

View File

@ -8,7 +8,7 @@
#include <nc_tests.h> #include <nc_tests.h>
#include "netcdf.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" #define FILE_NAME "tst_files6.nc"
int int

View File

@ -125,8 +125,9 @@ main()
printf("\n"); printf("\n");
#endif #endif
check(err = nc_get_varm_float (ncid, varid, start, count, stride, imap, // check(err = nc_get_varm_float (ncid, varid, start, count, stride, imap,(float*) dat),__FILE__,__LINE__);
(float*) dat),__FILE__,__LINE__); check(err = nc_get_vara_float (ncid, varid, start, count, (float*) dat),__FILE__,__LINE__);
#ifdef STANDALONE #ifdef STANDALONE
printf("varm: %s =",VAR); printf("varm: %s =",VAR);
for(i=0;i<12;i++) printf(" %f",dat[i]); for(i=0;i<12;i++) printf(" %f",dat[i]);

View File

@ -48,7 +48,7 @@ FILETESTS="${SYNTHETICDATA} ${ACTUALDATA1} ${ACTUALDATA2}"
# Remote test info # 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" # REMOTEURL2="http://test.opendap.org/dap/netcdf/examples"
# #
# #

View File

@ -55,14 +55,14 @@ fi
WHICHTESTS="C2" WHICHTESTS="C2"
# For special testing # For special testing
REMOTEURLX="http://test.opendap.org:8080/dods/dts" REMOTEURLX="http://motherlode.ucar.edu:8081/dods/dts"
REMOTETESTSX="test.03" 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" REMOTETESTSXC="test.03;1;s0,s1"
# These shorter tests are always run # These shorter tests are always run
REMOTEURLS1="http://test.opendap.org:8080/dods/dts" REMOTEURLS1="http://motherlode.ucar.edu:8081/dods/dts"
REMOTETESTSS1="\ REMOTETESTSS1="\
test.01 test.02 test.04 test.05 test.06a test.07a test.07 \ test.01 test.02 test.04 test.05 test.06a test.07a test.07 \
test.21 test.22 test.23 \ 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" ESCAPEDFAIL="test.dfr1 test.dfr2 test.dfr3 test.GridFile test.PointFile test.SwathFile test.sds6 test.sds7"
# Following tests are to check constraint handling # Following tests are to check constraint handling
REMOTEURLC1="http://test.opendap.org:8080/dods/dts" REMOTEURLC1="http://motherlode.ucar.edu:8081/dods/dts"
REMOTETESTSC1="\ REMOTETESTSC1="\
test.01;1;f64 \ test.01;1;f64 \
test.02;1;b[1:2:10] \ test.02;1;b[1:2:10] \
@ -117,7 +117,7 @@ argo_all.cdp;1;&location.LATITUDE<1&location.LATITUDE>-1\
" "
# Constrained long tests # Constrained long tests
REMOTEURLLC1="http://test.opendap.org:8080/dods/dts" REMOTEURLLC1="http://motherlode.ucar.edu:8081/dods/dts"
REMOTETESTSLC1="\ REMOTETESTSLC1="\
test.03;2;s1" test.03;2;s1"

View File

@ -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 "includes.h"
#include "offsets.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 */ /* parser controls */
#define YY_NO_INPUT 1 #define YY_NO_INPUT 1
@ -92,6 +97,7 @@ List* tmp;
/* Forward */ /* Forward */
static Constant makeconstdata(nc_type); static Constant makeconstdata(nc_type);
static Constant evaluate(Symbol* fcn, Datalist* arglist);
static Constant makeenumconst(Symbol*); static Constant makeenumconst(Symbol*);
static void addtogroup(Symbol*); static void addtogroup(Symbol*);
static Symbol* getunlimiteddim(void); static Symbol* getunlimiteddim(void);
@ -189,7 +195,8 @@ Constant constant;
%type <mark> enumidlist fieldlist fields varlist dimspec dimlist field %type <mark> enumidlist fieldlist fields varlist dimspec dimlist field
fielddimspec fielddimlist fielddimspec fielddimlist
%type <constant> dataitem constdata constint conststring constbool %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 */ %start ncdesc /* start symbol for grammar */
@ -789,6 +796,25 @@ dataitem:
; ;
constdata: 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*/ CHAR_CONST {$$=makeconstdata(NC_CHAR);} /* never used apparently*/
| BYTE_CONST {$$=makeconstdata(NC_BYTE);} | BYTE_CONST {$$=makeconstdata(NC_BYTE);}
| SHORT_CONST {$$=makeconstdata(NC_SHORT);} | SHORT_CONST {$$=makeconstdata(NC_SHORT);}
@ -801,9 +827,6 @@ constdata:
| FLOAT_CONST {$$=makeconstdata(NC_FLOAT);} | FLOAT_CONST {$$=makeconstdata(NC_FLOAT);}
| DOUBLE_CONST {$$=makeconstdata(NC_DOUBLE);} | DOUBLE_CONST {$$=makeconstdata(NC_DOUBLE);}
| TERMSTRING {$$=makeconstdata(NC_STRING);} | TERMSTRING {$$=makeconstdata(NC_STRING);}
| OPAQUESTRING {$$=makeconstdata(NC_OPAQUE);}
| path {$$=makeenumconst($1);}
| FILLMARKER {$$=makeconstdata(NC_FILLVALUE);}
; ;
intlist: intlist:
@ -1381,3 +1404,85 @@ vercheck(int ncid)
} }
if(tmsg != NULL) markcdf4(tmsg); 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;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -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 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 it under the terms of the GNU General Public License as published by

View File

@ -27,14 +27,13 @@ extern void ocurifree(OCURI* ocuri);
/* Replace the constraints */ /* Replace the constraints */
extern void ocurisetconstraints(OCURI*,const char* 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 flags to control what is included */
#define OCURICONSTRAINTS 1 #define OCURICONSTRAINTS 1
#define OCURIUSERPWD 2 #define OCURIUSERPWD 2
#define OCURIPARAMS 4 #define OCURIPARAMS 4
#define OCURIENCODE 8 /* If output should be encoded */ #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); extern char* ocuribuild(OCURI*,const char* prefix, const char* suffix, int flags);