2011-04-18 02:56:10 +08:00
|
|
|
/*********************************************************************
|
2018-12-07 05:21:03 +08:00
|
|
|
* Copyright 2018, UCAR/Unidata
|
2014-12-25 01:22:47 +08:00
|
|
|
* See netcdf/COPYRIGHT file for copying and redistribuution conditions.
|
2011-04-18 02:56:10 +08:00
|
|
|
*********************************************************************/
|
|
|
|
|
2013-07-28 04:54:50 +08:00
|
|
|
|
2017-03-09 08:01:10 +08:00
|
|
|
#include "dapincludes.h"
|
2011-04-18 02:56:10 +08:00
|
|
|
#include "dapodom.h"
|
|
|
|
#include "dapdump.h"
|
2014-03-25 04:02:52 +08:00
|
|
|
#include "ncd2dispatch.h"
|
2012-08-01 04:34:13 +08:00
|
|
|
#include "ocx.h"
|
2023-11-27 19:36:03 +08:00
|
|
|
#include <stddef.h>
|
2012-01-30 02:56:29 +08:00
|
|
|
|
2011-04-18 02:56:10 +08:00
|
|
|
#define NEWVARM
|
|
|
|
|
2012-01-30 02:56:29 +08:00
|
|
|
/* Define a tracker for memory to support*/
|
|
|
|
/* the concatenation*/
|
|
|
|
struct NCMEMORY {
|
|
|
|
void* memory;
|
|
|
|
char* next; /* where to store the next chunk of data*/
|
2014-08-12 02:52:57 +08:00
|
|
|
};
|
2012-01-30 02:56:29 +08:00
|
|
|
|
2011-04-18 02:56:10 +08:00
|
|
|
/* Forward:*/
|
|
|
|
static NCerror moveto(NCDAPCOMMON*, Getvara*, CDFnode* dataroot, void* memory);
|
2012-08-01 04:34:13 +08:00
|
|
|
static NCerror movetor(NCDAPCOMMON*, OCdatanode currentcontent,
|
2024-03-14 00:51:24 +08:00
|
|
|
NClist* path, size_t depth,
|
2012-08-01 04:34:13 +08:00
|
|
|
Getvara*, size_t dimindex,
|
2011-04-18 02:56:10 +08:00
|
|
|
struct NCMEMORY*, NClist* segments);
|
2012-08-01 04:34:13 +08:00
|
|
|
static NCerror movetofield(NCDAPCOMMON*, OCdatanode,
|
2024-03-14 00:51:24 +08:00
|
|
|
NClist*, size_t depth,
|
2012-08-01 04:34:13 +08:00
|
|
|
Getvara*, size_t dimindex,
|
|
|
|
struct NCMEMORY*, NClist* segments);
|
2011-04-18 02:56:10 +08:00
|
|
|
|
|
|
|
static int findfield(CDFnode* node, CDFnode* subnode);
|
2012-02-04 05:31:50 +08:00
|
|
|
static NCerror removepseudodims(DCEprojection* proj);
|
2011-11-14 12:20:19 +08:00
|
|
|
|
2012-08-01 04:34:13 +08:00
|
|
|
static int extract(NCDAPCOMMON*, Getvara*, CDFnode*, DCEsegment*, size_t dimindex, OClink, OCdatanode, struct NCMEMORY*);
|
|
|
|
static int extractstring(NCDAPCOMMON*, Getvara*, CDFnode*, DCEsegment*, size_t dimindex, OClink, OCdatanode, struct NCMEMORY*);
|
2014-03-25 04:02:52 +08:00
|
|
|
static void freegetvara(Getvara* vara);
|
|
|
|
static NCerror makegetvar(NCDAPCOMMON*, CDFnode*, void*, nc_type, Getvara**);
|
2015-01-16 05:19:51 +08:00
|
|
|
static NCerror attachsubset(CDFnode* target, CDFnode* pattern);
|
2012-01-30 02:56:29 +08:00
|
|
|
|
2014-03-25 04:02:52 +08:00
|
|
|
/**************************************************/
|
2011-11-14 12:20:19 +08:00
|
|
|
/**
|
|
|
|
1. We build the projection to be sent to the server aka
|
|
|
|
the fetch constraint. We want the server do do as much work
|
|
|
|
as possible, so we send it a url with a fetch constraint
|
|
|
|
that is the merge of the url constraint with the vara
|
|
|
|
constraint.
|
|
|
|
|
|
|
|
The url constraint, if any, is the one that was provided
|
|
|
|
in the url specified in nc_open().
|
|
|
|
|
|
|
|
The vara constraint is the one formed from the arguments
|
|
|
|
(start, count, stride) provided to the call to nc_get_vara().
|
|
|
|
|
|
|
|
There are some exceptions to the formation of the fetch constraint.
|
2012-01-30 12:32:12 +08:00
|
|
|
In all cases, the fetch constraint will use any URL selections,
|
|
|
|
but will use different fetch projections.
|
|
|
|
a. URL is unconstrainable (e.g. file://...):
|
2012-03-15 07:26:48 +08:00
|
|
|
fetchprojection = null => fetch whole dataset
|
2012-01-30 12:32:12 +08:00
|
|
|
b. The target variable (as specified in nc_get_vara())
|
2012-08-01 04:34:13 +08:00
|
|
|
is already in the cache and is whole variable, but note
|
|
|
|
that it might be part of the prefetch mixed in with other prefetched
|
|
|
|
variables.
|
2012-03-15 07:26:48 +08:00
|
|
|
fetchprojection = N.A. since variable is in the cache
|
|
|
|
c. Vara is requesting part of a variable but NCF_WHOLEVAR flag is set.
|
|
|
|
fetchprojection = unsliced vara variable => fetch whole variable
|
|
|
|
d. Vara is requesting part of a variable and NCF_WHOLEVAR flag is not set.
|
|
|
|
fetchprojection = sliced vara variable => fetch part variable
|
2012-01-30 12:32:12 +08:00
|
|
|
|
2012-03-15 07:26:48 +08:00
|
|
|
2. At this point, all or part of the target variable is available in the cache.
|
2011-11-14 12:20:19 +08:00
|
|
|
|
|
|
|
3. We build a projection to walk (guide) the use of the oc
|
2012-08-01 04:34:13 +08:00
|
|
|
data procedures to extract the required data from the cache.
|
2012-03-15 07:26:48 +08:00
|
|
|
For cases a,b,c:
|
|
|
|
walkprojection = merge(urlprojection,varaprojection)
|
|
|
|
For case d:
|
|
|
|
walkprojection = varaprojection without slicing.
|
|
|
|
This means we need only extract the complete contents of the cache.
|
|
|
|
Notice that this will not necessarily be a direct memory to
|
|
|
|
memory copy because the dap encoding still needs to be
|
|
|
|
interpreted. For this case, we derive a walk projection
|
|
|
|
from the vara projection that will properly access the cached data.
|
|
|
|
This walk projection shifts the merged projection so all slices
|
|
|
|
start at 0 and have a stride of 1.
|
2012-01-30 12:32:12 +08:00
|
|
|
*/
|
2011-04-18 02:56:10 +08:00
|
|
|
|
|
|
|
NCerror
|
|
|
|
nc3d_getvarx(int ncid, int varid,
|
|
|
|
const size_t *startp,
|
|
|
|
const size_t *countp,
|
|
|
|
const ptrdiff_t* stridep,
|
|
|
|
void *data,
|
|
|
|
nc_type dsttype0)
|
|
|
|
{
|
|
|
|
NCerror ncstat = NC_NOERR;
|
|
|
|
OCerror ocstat = OC_NOERR;
|
2023-11-27 19:36:03 +08:00
|
|
|
size_t i;
|
2011-09-17 02:36:08 +08:00
|
|
|
NC* drno;
|
2011-09-19 04:57:51 +08:00
|
|
|
NC* substrate;
|
2011-09-17 02:36:08 +08:00
|
|
|
NCDAPCOMMON* dapcomm;
|
2012-11-01 05:31:47 +08:00
|
|
|
CDFnode* cdfvar = NULL; /* cdf node mapping to var*/
|
2011-04-18 02:56:10 +08:00
|
|
|
NClist* varnodes;
|
|
|
|
nc_type dsttype;
|
2011-11-14 12:20:19 +08:00
|
|
|
Getvara* varainfo = NULL;
|
2011-04-18 02:56:10 +08:00
|
|
|
CDFnode* xtarget = NULL; /* target in DATADDS */
|
|
|
|
CDFnode* target = NULL; /* target in constrained DDS */
|
|
|
|
DCEprojection* varaprojection = NULL;
|
|
|
|
NCcachenode* cachenode = NULL;
|
|
|
|
size_t localcount[NC_MAX_VAR_DIMS];
|
2011-11-14 12:20:19 +08:00
|
|
|
NClist* ncdimsall;
|
2011-04-18 02:56:10 +08:00
|
|
|
size_t ncrank;
|
2011-11-14 12:20:19 +08:00
|
|
|
NClist* vars = NULL;
|
|
|
|
DCEconstraint* fetchconstraint = NULL;
|
|
|
|
DCEprojection* fetchprojection = NULL;
|
|
|
|
DCEprojection* walkprojection = NULL;
|
|
|
|
int state;
|
|
|
|
#define FETCHWHOLE 1 /* fetch whole data set */
|
2012-03-15 07:26:48 +08:00
|
|
|
#define FETCHVAR 2 /* fetch whole variable */
|
|
|
|
#define FETCHPART 4 /* fetch constrained variable */
|
|
|
|
#define CACHED 8 /* whole variable is already in the cache */
|
2011-04-18 02:56:10 +08:00
|
|
|
|
2012-09-07 03:44:03 +08:00
|
|
|
ncstat = NC_check_id(ncid, (NC**)&drno);
|
2011-04-18 02:56:10 +08:00
|
|
|
if(ncstat != NC_NOERR) goto fail;
|
2011-09-17 02:36:08 +08:00
|
|
|
dapcomm = (NCDAPCOMMON*)drno->dispatchdata;
|
2014-08-12 02:52:57 +08:00
|
|
|
|
2016-04-07 04:05:58 +08:00
|
|
|
ncstat = NC_check_id(getnc3id(drno), (NC**)&substrate);
|
2011-09-19 04:57:51 +08:00
|
|
|
if(ncstat != NC_NOERR) goto fail;
|
2011-04-18 02:56:10 +08:00
|
|
|
|
|
|
|
/* Locate var node via varid */
|
2013-03-03 12:06:43 +08:00
|
|
|
varnodes = dapcomm->cdf.ddsroot->tree->varnodes;
|
2011-04-18 02:56:10 +08:00
|
|
|
for(i=0;i<nclistlength(varnodes);i++) {
|
|
|
|
CDFnode* node = (CDFnode*)nclistget(varnodes,i);
|
|
|
|
if(node->array.basevar == NULL
|
2012-08-01 04:34:13 +08:00
|
|
|
&& node->nctype == NC_Atomic
|
2011-04-18 02:56:10 +08:00
|
|
|
&& node->ncid == varid) {
|
|
|
|
cdfvar = node;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ASSERT((cdfvar != NULL));
|
|
|
|
|
2013-03-03 12:06:43 +08:00
|
|
|
/* If the variable is prefetchable, then now
|
|
|
|
is the time to do a lazy prefetch */
|
|
|
|
if(FLAGSET(dapcomm->controls,NCF_PREFETCH)
|
|
|
|
&& !FLAGSET(dapcomm->controls,NCF_PREFETCH_EAGER)) {
|
|
|
|
if(dapcomm->cdf.cache != NULL && dapcomm->cdf.cache->prefetch == NULL) {
|
2014-03-25 04:02:52 +08:00
|
|
|
ncstat = prefetchdata(dapcomm);
|
2013-03-03 12:06:43 +08:00
|
|
|
if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto fail;}
|
|
|
|
}
|
|
|
|
}
|
2014-08-12 02:52:57 +08:00
|
|
|
|
2011-04-18 02:56:10 +08:00
|
|
|
/* Get the dimension info */
|
2011-11-14 12:20:19 +08:00
|
|
|
ncdimsall = cdfvar->array.dimsetall;
|
|
|
|
ncrank = nclistlength(ncdimsall);
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
fprintf(stderr,"getvarx: %s",cdfvar->ncfullname);
|
|
|
|
for(i=0;i<ncrank;i++)
|
2013-04-24 04:18:16 +08:00
|
|
|
fprintf(stderr,"(%ld:%ld:%ld)",
|
2011-11-14 12:20:19 +08:00
|
|
|
(long)startp[i],
|
|
|
|
(long)countp[i],
|
|
|
|
(long)stridep[i]
|
|
|
|
);
|
|
|
|
fprintf(stderr,"\n");
|
|
|
|
}
|
|
|
|
#endif
|
2011-04-18 02:56:10 +08:00
|
|
|
|
|
|
|
/* Fill in missing arguments */
|
|
|
|
if(startp == NULL)
|
2019-03-31 04:06:20 +08:00
|
|
|
startp = NC_coord_zero;
|
2011-04-18 02:56:10 +08:00
|
|
|
|
|
|
|
if(countp == NULL) {
|
|
|
|
/* Accumulate the dimension sizes */
|
|
|
|
for(i=0;i<ncrank;i++) {
|
2011-11-14 12:20:19 +08:00
|
|
|
CDFnode* dim = (CDFnode*)nclistget(ncdimsall,i);
|
2011-04-18 02:56:10 +08:00
|
|
|
localcount[i] = dim->dim.declsize;
|
|
|
|
}
|
|
|
|
countp = localcount;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(stridep == NULL)
|
2019-03-31 04:06:20 +08:00
|
|
|
stridep = NC_stride_one;
|
2011-04-18 02:56:10 +08:00
|
|
|
|
|
|
|
/* Validate the dimension sizes */
|
|
|
|
for(i=0;i<ncrank;i++) {
|
2013-08-06 04:36:33 +08:00
|
|
|
CDFnode* dim = (CDFnode*)nclistget(ncdimsall,i);
|
|
|
|
/* countp and startp are unsigned, so will never be < 0 */
|
|
|
|
if(stridep[i] < 1) {
|
|
|
|
ncstat = NC_EINVALCOORDS;
|
2014-08-12 02:52:57 +08:00
|
|
|
goto fail;
|
2013-08-06 04:36:33 +08:00
|
|
|
}
|
|
|
|
if(startp[i] >= dim->dim.declsize
|
2024-03-14 00:51:24 +08:00
|
|
|
|| startp[i]+((size_t)stridep[i]*(countp[i]-1)) >= dim->dim.declsize) {
|
2013-08-06 04:36:33 +08:00
|
|
|
ncstat = NC_EINVALCOORDS;
|
2014-08-12 02:52:57 +08:00
|
|
|
goto fail;
|
2013-08-06 04:36:33 +08:00
|
|
|
}
|
2014-08-12 02:52:57 +08:00
|
|
|
}
|
2011-04-18 02:56:10 +08:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2011-11-14 12:20:19 +08:00
|
|
|
{
|
|
|
|
NClist* dims = cdfvar->array.dimsetall;
|
2011-04-18 02:56:10 +08:00
|
|
|
fprintf(stderr,"getvarx: %s",cdfvar->ncfullname);
|
|
|
|
if(nclistlength(dims) > 0) {int i;
|
2014-08-12 02:52:57 +08:00
|
|
|
for(i=0;i<nclistlength(dims);i++)
|
2013-04-24 04:18:16 +08:00
|
|
|
fprintf(stderr,"(%lu:%lu:%lu)",(unsigned long)startp[i],(unsigned long)countp[i],(unsigned long)stridep[i]);
|
2011-04-18 02:56:10 +08:00
|
|
|
fprintf(stderr," -> ");
|
2014-08-12 02:52:57 +08:00
|
|
|
for(i=0;i<nclistlength(dims);i++)
|
2011-04-18 02:56:10 +08:00
|
|
|
if(stridep[i]==1)
|
|
|
|
fprintf(stderr,"[%lu:%lu]",(unsigned long)startp[i],(unsigned long)((startp[i]+countp[i])-1));
|
2012-08-16 01:55:25 +08:00
|
|
|
else {
|
|
|
|
unsigned long iend = (stridep[i] * countp[i]);
|
|
|
|
iend = (iend + startp[i]);
|
|
|
|
iend = (iend - 1);
|
2011-04-18 02:56:10 +08:00
|
|
|
fprintf(stderr,"[%lu:%lu:%lu]",
|
2012-08-16 01:55:25 +08:00
|
|
|
(unsigned long)startp[i],(unsigned long)stridep[i],iend);
|
|
|
|
}
|
|
|
|
}
|
2011-04-18 02:56:10 +08:00
|
|
|
fprintf(stderr,"\n");
|
2011-11-14 12:20:19 +08:00
|
|
|
}
|
2011-04-18 02:56:10 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
dsttype = (dsttype0);
|
|
|
|
|
|
|
|
/* Default to using the inquiry type for this var*/
|
|
|
|
if(dsttype == NC_NAT) dsttype = cdfvar->externaltype;
|
|
|
|
|
|
|
|
/* Validate any implied type conversion*/
|
|
|
|
if(cdfvar->etype != dsttype && dsttype == NC_CHAR) {
|
2012-01-30 02:56:29 +08:00
|
|
|
/* The only disallowed conversion is to/from char and non-byte
|
2011-04-18 02:56:10 +08:00
|
|
|
numeric types*/
|
|
|
|
switch (cdfvar->etype) {
|
|
|
|
case NC_STRING: case NC_URL:
|
|
|
|
case NC_CHAR: case NC_BYTE: case NC_UBYTE:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return THROW(NC_ECHAR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-25 04:02:52 +08:00
|
|
|
ncstat = makegetvar(dapcomm,cdfvar,data,dsttype,&varainfo);
|
2011-04-18 02:56:10 +08:00
|
|
|
if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto fail;}
|
|
|
|
|
2012-08-01 04:34:13 +08:00
|
|
|
/* Compile the start/stop/stride info into a projection */
|
2014-12-25 01:22:47 +08:00
|
|
|
ncstat = dapbuildvaraprojection(varainfo->target,
|
2011-11-14 12:20:19 +08:00
|
|
|
startp,countp,stridep,
|
|
|
|
&varaprojection);
|
|
|
|
if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto fail;}
|
|
|
|
|
|
|
|
fetchprojection = NULL;
|
|
|
|
walkprojection = NULL;
|
2012-01-30 02:56:29 +08:00
|
|
|
|
2012-01-30 12:32:12 +08:00
|
|
|
/* Create walkprojection as the merge of the url projections
|
2012-03-15 07:26:48 +08:00
|
|
|
and the vara projection; may change in FETCHPART case below*/
|
2012-01-30 12:32:12 +08:00
|
|
|
ncstat = daprestrictprojection(dapcomm->oc.dapconstraint->projections,
|
|
|
|
varaprojection,&walkprojection);
|
|
|
|
if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto fail;}
|
2012-03-15 07:26:48 +08:00
|
|
|
|
2012-02-04 05:31:50 +08:00
|
|
|
#ifdef DEBUG
|
|
|
|
fprintf(stderr,"getvarx: walkprojection: |%s|\n",dumpprojection(walkprojection));
|
|
|
|
#endif
|
2012-01-30 12:32:12 +08:00
|
|
|
|
2012-01-30 02:56:29 +08:00
|
|
|
/* define the var list of interest */
|
|
|
|
vars = nclistnew();
|
2012-08-20 05:12:35 +08:00
|
|
|
nclistpush(vars,(void*)varainfo->target);
|
2012-01-30 02:56:29 +08:00
|
|
|
|
2013-03-03 12:06:43 +08:00
|
|
|
state = 0;
|
|
|
|
if(iscached(dapcomm,cdfvar,&cachenode)) { /* ignores non-whole variable cache entries */
|
|
|
|
state = CACHED;
|
|
|
|
ASSERT((cachenode != NULL));
|
|
|
|
#ifdef DEBUG
|
|
|
|
fprintf(stderr,"var is in cache\n");
|
|
|
|
#endif
|
|
|
|
/* If it is cached, then it is a whole variable but may still
|
|
|
|
need to apply constraints during the walk */
|
|
|
|
ASSERT(cachenode->wholevariable); /* by construction */
|
|
|
|
} else if(FLAGSET(dapcomm->controls,NCF_UNCONSTRAINABLE)) {
|
|
|
|
state = FETCHWHOLE;
|
|
|
|
} else {/* load using constraints */
|
|
|
|
if(FLAGSET(dapcomm->controls,NCF_WHOLEVAR))
|
|
|
|
state = FETCHVAR;
|
|
|
|
else
|
|
|
|
state = FETCHPART;
|
|
|
|
}
|
2014-08-12 02:52:57 +08:00
|
|
|
ASSERT(state != 0);
|
2013-03-03 12:06:43 +08:00
|
|
|
|
2012-01-30 02:56:29 +08:00
|
|
|
switch (state) {
|
2012-02-04 05:31:50 +08:00
|
|
|
|
|
|
|
case FETCHWHOLE: {
|
|
|
|
/* buildcachenode3 will create a new cachenode and
|
|
|
|
will also fetch the whole corresponding datadds.
|
|
|
|
*/
|
|
|
|
/* Build the complete constraint to use in the fetch */
|
|
|
|
fetchconstraint = (DCEconstraint*)dcecreate(CES_CONSTRAINT);
|
|
|
|
/* Use no projections or selections */
|
|
|
|
fetchconstraint->projections = nclistnew();
|
|
|
|
fetchconstraint->selections = nclistnew();
|
|
|
|
#ifdef DEBUG
|
|
|
|
fprintf(stderr,"getvarx: FETCHWHOLE: fetchconstraint: %s\n",dumpconstraint(fetchconstraint));
|
|
|
|
#endif
|
2014-03-25 04:02:52 +08:00
|
|
|
ncstat = buildcachenode(dapcomm,fetchconstraint,vars,&cachenode,0);
|
2012-02-04 05:31:50 +08:00
|
|
|
fetchconstraint = NULL; /*buildcachenode34 takes control of fetchconstraint.*/
|
2014-08-23 05:12:24 +08:00
|
|
|
if(ncstat != NC_NOERR) {THROWCHK(ncstat); nullfree(varainfo);
|
|
|
|
varainfo=NULL;
|
|
|
|
goto fail;}
|
2012-02-04 05:31:50 +08:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case CACHED: {
|
|
|
|
} break;
|
|
|
|
|
2012-03-15 07:26:48 +08:00
|
|
|
case FETCHVAR: { /* Fetch a complete single variable */
|
|
|
|
/* Create fetch projection as the merge of the url projections
|
|
|
|
and the vara projection */
|
|
|
|
ncstat = daprestrictprojection(dapcomm->oc.dapconstraint->projections,
|
|
|
|
varaprojection,&fetchprojection);
|
|
|
|
/* elide any sequence and string dimensions (dap servers do not allow such). */
|
|
|
|
ncstat = removepseudodims(fetchprojection);
|
|
|
|
if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto fail;}
|
|
|
|
|
|
|
|
/* Convert to a whole variable projection */
|
|
|
|
dcemakewholeprojection(fetchprojection);
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2014-08-12 02:52:57 +08:00
|
|
|
fprintf(stderr,"getvarx: FETCHVAR: fetchprojection: |%s|\n",dumpprojection(fetchprojection));
|
2012-03-15 07:26:48 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Build the complete constraint to use in the fetch */
|
|
|
|
fetchconstraint = (DCEconstraint*)dcecreate(CES_CONSTRAINT);
|
|
|
|
/* merged constraint just uses the url constraint selection */
|
|
|
|
fetchconstraint->selections = dceclonelist(dapcomm->oc.dapconstraint->selections);
|
|
|
|
/* and the created fetch projection */
|
|
|
|
fetchconstraint->projections = nclistnew();
|
2014-08-12 02:52:57 +08:00
|
|
|
nclistpush(fetchconstraint->projections,(void*)fetchprojection);
|
2012-03-15 07:26:48 +08:00
|
|
|
#ifdef DEBUG
|
|
|
|
fprintf(stderr,"getvarx: FETCHVAR: fetchconstraint: %s\n",dumpconstraint(fetchconstraint));
|
|
|
|
#endif
|
|
|
|
/* buildcachenode3 will create a new cachenode and
|
|
|
|
will also fetch the corresponding datadds.
|
|
|
|
*/
|
2014-08-12 02:52:57 +08:00
|
|
|
ncstat = buildcachenode(dapcomm,fetchconstraint,vars,&cachenode,0);
|
|
|
|
fetchconstraint = NULL; /*buildcachenode34 takes control of fetchconstraint.*/
|
2012-03-15 07:26:48 +08:00
|
|
|
if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto fail;}
|
|
|
|
} break;
|
|
|
|
|
2012-01-30 02:56:29 +08:00
|
|
|
case FETCHPART: {
|
2012-01-30 12:32:12 +08:00
|
|
|
/* Create fetch projection as the merge of the url projections
|
|
|
|
and the vara projection */
|
|
|
|
ncstat = daprestrictprojection(dapcomm->oc.dapconstraint->projections,
|
|
|
|
varaprojection,&fetchprojection);
|
2012-02-04 05:31:50 +08:00
|
|
|
/* elide any sequence and string dimensions (dap servers do not allow such). */
|
|
|
|
ncstat = removepseudodims(fetchprojection);
|
2011-11-14 12:20:19 +08:00
|
|
|
if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto fail;}
|
2012-02-04 05:31:50 +08:00
|
|
|
|
2012-01-30 12:32:12 +08:00
|
|
|
/* Shift the varaprojection for simple walk */
|
2014-08-12 02:52:57 +08:00
|
|
|
dcefree((DCEnode*)walkprojection) ; /* reclaim any existing walkprojection */
|
2012-01-30 12:32:12 +08:00
|
|
|
walkprojection = (DCEprojection*)dceclone((DCEnode*)varaprojection);
|
|
|
|
dapshiftprojection(walkprojection);
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2014-08-12 02:52:57 +08:00
|
|
|
fprintf(stderr,"getvarx: FETCHPART: fetchprojection: |%s|\n",dumpprojection(fetchprojection));
|
2012-01-30 12:32:12 +08:00
|
|
|
#endif
|
|
|
|
|
2011-11-14 12:20:19 +08:00
|
|
|
/* Build the complete constraint to use in the fetch */
|
|
|
|
fetchconstraint = (DCEconstraint*)dcecreate(CES_CONSTRAINT);
|
|
|
|
/* merged constraint just uses the url constraint selection */
|
|
|
|
fetchconstraint->selections = dceclonelist(dapcomm->oc.dapconstraint->selections);
|
2012-02-04 05:31:50 +08:00
|
|
|
/* and the created fetch projection */
|
2011-11-14 12:20:19 +08:00
|
|
|
fetchconstraint->projections = nclistnew();
|
2014-08-12 02:52:57 +08:00
|
|
|
nclistpush(fetchconstraint->projections,(void*)fetchprojection);
|
2011-11-14 12:20:19 +08:00
|
|
|
#ifdef DEBUG
|
2014-08-12 02:52:57 +08:00
|
|
|
fprintf(stderr,"getvarx: FETCHPART: fetchconstraint: %s\n",dumpconstraint(fetchconstraint));
|
2011-11-14 12:20:19 +08:00
|
|
|
#endif
|
|
|
|
/* buildcachenode3 will create a new cachenode and
|
2012-01-30 12:32:12 +08:00
|
|
|
will also fetch the corresponding datadds.
|
2012-01-30 02:56:29 +08:00
|
|
|
*/
|
2014-03-25 04:02:52 +08:00
|
|
|
ncstat = buildcachenode(dapcomm,fetchconstraint,vars,&cachenode,0);
|
2013-07-28 04:20:13 +08:00
|
|
|
|
2012-01-30 02:56:29 +08:00
|
|
|
fetchconstraint = NULL; /*buildcachenode34 takes control of fetchconstraint.*/
|
2011-11-14 12:20:19 +08:00
|
|
|
if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto fail;}
|
2012-01-30 02:56:29 +08:00
|
|
|
} break;
|
|
|
|
|
|
|
|
default: PANIC1("unknown fetch state: %d\n",state);
|
2011-11-14 12:20:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ASSERT(cachenode != NULL);
|
2011-04-18 02:56:10 +08:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
fprintf(stderr,"cache.datadds=%s\n",dumptree(cachenode->datadds));
|
|
|
|
#endif
|
|
|
|
|
2011-11-14 12:20:19 +08:00
|
|
|
/* attach DATADDS to (constrained) DDS */
|
2014-03-25 04:02:52 +08:00
|
|
|
unattach(dapcomm->cdf.ddsroot);
|
|
|
|
ncstat = attachsubset(cachenode->datadds,dapcomm->cdf.ddsroot);
|
2014-08-12 02:52:57 +08:00
|
|
|
if(ncstat) goto fail;
|
2011-04-18 02:56:10 +08:00
|
|
|
|
2011-11-14 12:20:19 +08:00
|
|
|
/* Fix up varainfo to use the cache */
|
|
|
|
varainfo->cache = cachenode;
|
2012-03-15 07:26:48 +08:00
|
|
|
cachenode = NULL;
|
2011-11-14 12:20:19 +08:00
|
|
|
varainfo->varaprojection = walkprojection;
|
|
|
|
walkprojection = NULL;
|
|
|
|
|
2011-04-18 02:56:10 +08:00
|
|
|
/* Get the var correlate from the datadds */
|
2011-11-14 12:20:19 +08:00
|
|
|
target = varainfo->target;
|
2011-04-18 02:56:10 +08:00
|
|
|
xtarget = target->attachment;
|
2014-08-12 02:52:57 +08:00
|
|
|
if(xtarget == NULL)
|
2011-04-18 02:56:10 +08:00
|
|
|
{THROWCHK(ncstat=NC_ENODATA); goto fail;}
|
|
|
|
|
|
|
|
/* Switch to datadds tree space*/
|
2011-11-14 12:20:19 +08:00
|
|
|
varainfo->target = xtarget;
|
2012-03-15 07:26:48 +08:00
|
|
|
ncstat = moveto(dapcomm,varainfo,varainfo->cache->datadds,data);
|
2011-04-18 02:56:10 +08:00
|
|
|
if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto fail;}
|
2012-03-15 07:26:48 +08:00
|
|
|
|
2012-08-01 04:34:13 +08:00
|
|
|
fail:
|
2014-08-18 04:12:19 +08:00
|
|
|
if(vars != NULL) nclistfree(vars);
|
|
|
|
if(varaprojection != NULL) dcefree((DCEnode*)varaprojection);
|
|
|
|
if(fetchconstraint != NULL) dcefree((DCEnode*)fetchconstraint);
|
|
|
|
if(varainfo != NULL) freegetvara(varainfo);
|
2012-08-01 04:34:13 +08:00
|
|
|
if(ocstat != OC_NOERR) ncstat = ocerrtoncerr(ocstat);
|
2011-04-18 02:56:10 +08:00
|
|
|
return THROW(ncstat);
|
|
|
|
}
|
|
|
|
|
2012-02-04 05:31:50 +08:00
|
|
|
/* Remove any pseudodimensions (sequence and string)*/
|
2011-11-14 12:20:19 +08:00
|
|
|
static NCerror
|
2012-02-04 05:31:50 +08:00
|
|
|
removepseudodims(DCEprojection* proj)
|
2011-11-14 12:20:19 +08:00
|
|
|
{
|
2023-11-27 19:36:03 +08:00
|
|
|
size_t i;
|
2011-11-14 12:20:19 +08:00
|
|
|
#ifdef DEBUG1
|
2012-01-30 12:32:12 +08:00
|
|
|
fprintf(stderr,"removesequencedims.before: %s\n",dumpprojection(proj));
|
2011-11-14 12:20:19 +08:00
|
|
|
#endif
|
|
|
|
for(i=0;i<nclistlength(proj->var->segments);i++) {
|
|
|
|
DCEsegment* seg = (DCEsegment*)nclistget(proj->var->segments,i);
|
2012-01-30 02:56:29 +08:00
|
|
|
CDFnode* cdfnode = (CDFnode*)seg->annotation;
|
|
|
|
if(cdfnode->array.seqdim != NULL)
|
2011-11-14 12:20:19 +08:00
|
|
|
seg->rank = 0;
|
2012-02-04 05:31:50 +08:00
|
|
|
else if(cdfnode->array.stringdim != NULL)
|
|
|
|
seg->rank--;
|
2011-11-14 12:20:19 +08:00
|
|
|
}
|
|
|
|
#ifdef DEBUG1
|
2012-02-04 05:31:50 +08:00
|
|
|
fprintf(stderr,"removepseudodims.after: %s\n",dumpprojection(proj));
|
2011-11-14 12:20:19 +08:00
|
|
|
#endif
|
|
|
|
return NC_NOERR;
|
|
|
|
}
|
|
|
|
|
2011-04-18 02:56:10 +08:00
|
|
|
static NCerror
|
|
|
|
moveto(NCDAPCOMMON* nccomm, Getvara* xgetvar, CDFnode* xrootnode, void* memory)
|
|
|
|
{
|
|
|
|
OCerror ocstat = OC_NOERR;
|
|
|
|
NCerror ncstat = NC_NOERR;
|
2012-08-01 04:34:13 +08:00
|
|
|
OClink conn = nccomm->oc.conn;
|
|
|
|
OCdatanode xrootcontent;
|
|
|
|
OCddsnode ocroot;
|
2011-04-18 02:56:10 +08:00
|
|
|
NClist* path = nclistnew();
|
|
|
|
struct NCMEMORY memstate;
|
|
|
|
|
|
|
|
memstate.next = (memstate.memory = memory);
|
|
|
|
|
|
|
|
/* Get the root content*/
|
|
|
|
ocroot = xrootnode->tree->ocroot;
|
2012-08-01 04:34:13 +08:00
|
|
|
ocstat = oc_data_getroot(conn,ocroot,&xrootcontent);
|
2012-01-30 02:56:29 +08:00
|
|
|
if(ocstat != OC_NOERR) {THROWCHK(ocstat); goto done;}
|
2011-04-18 02:56:10 +08:00
|
|
|
|
|
|
|
/* Remember: xgetvar->target is in DATADDS tree */
|
2014-03-25 04:02:52 +08:00
|
|
|
collectnodepath(xgetvar->target,path,WITHDATASET);
|
2011-04-18 02:56:10 +08:00
|
|
|
ncstat = movetor(nccomm,xrootcontent,
|
|
|
|
path,0,xgetvar,0,&memstate,
|
|
|
|
xgetvar->varaprojection->var->segments);
|
2012-01-30 02:56:29 +08:00
|
|
|
done:
|
2011-04-18 02:56:10 +08:00
|
|
|
nclistfree(path);
|
|
|
|
oc_data_free(conn,xrootcontent);
|
|
|
|
if(ocstat != OC_NOERR) ncstat = ocerrtoncerr(ocstat);
|
|
|
|
return THROW(ncstat);
|
|
|
|
}
|
|
|
|
|
|
|
|
static NCerror
|
|
|
|
movetor(NCDAPCOMMON* nccomm,
|
2012-08-01 04:34:13 +08:00
|
|
|
OCdatanode currentcontent,
|
2011-11-14 12:20:19 +08:00
|
|
|
NClist* path,
|
2024-03-14 00:51:24 +08:00
|
|
|
size_t depth, /* depth is position in segment list*/
|
2011-11-14 12:20:19 +08:00
|
|
|
Getvara* xgetvar,
|
2012-08-01 04:34:13 +08:00
|
|
|
size_t dimindex, /* dimindex is position in xgetvar->slices*/
|
2011-04-18 02:56:10 +08:00
|
|
|
struct NCMEMORY* memory,
|
|
|
|
NClist* segments)
|
|
|
|
{
|
|
|
|
OCerror ocstat = OC_NOERR;
|
|
|
|
NCerror ncstat = NC_NOERR;
|
2012-08-01 04:34:13 +08:00
|
|
|
OClink conn = nccomm->oc.conn;
|
2011-04-18 02:56:10 +08:00
|
|
|
CDFnode* xnode = (CDFnode*)nclistget(path,depth);
|
2012-08-01 04:34:13 +08:00
|
|
|
OCdatanode reccontent = NULL;
|
|
|
|
OCdatanode dimcontent = NULL;
|
|
|
|
Dapodometer* odom = NULL;
|
2011-04-18 02:56:10 +08:00
|
|
|
int hasstringdim = 0;
|
|
|
|
DCEsegment* segment;
|
2012-08-01 04:34:13 +08:00
|
|
|
OCDT mode;
|
2011-04-18 02:56:10 +08:00
|
|
|
|
|
|
|
/* Note that we use depth-1 because the path contains the DATASET
|
|
|
|
but the segment list does not */
|
|
|
|
segment = (DCEsegment*)nclistget(segments,depth-1); /*may be NULL*/
|
|
|
|
if(xnode->etype == NC_STRING || xnode->etype == NC_URL) hasstringdim = 1;
|
|
|
|
|
2012-08-01 04:34:13 +08:00
|
|
|
/* Get the mode */
|
2018-02-25 11:36:24 +08:00
|
|
|
ocstat = oc_data_mode(conn,currentcontent,&mode);
|
|
|
|
if(ocstat != OC_NOERR) {THROWCHK(ocstat); goto done;}
|
2011-04-18 02:56:10 +08:00
|
|
|
|
2011-11-14 12:20:19 +08:00
|
|
|
#ifdef DEBUG2
|
This PR adds EXPERIMENTAL support for accessing data in the
cloud using a variant of the Zarr protocol and storage
format. This enhancement is generically referred to as "NCZarr".
The data model supported by NCZarr is netcdf-4 minus the user-defined
types and the String type. In this sense it is similar to the CDF-5
data model.
More detailed information about enabling and using NCZarr is
described in the document NUG/nczarr.md and in a
[Unidata Developer's blog entry](https://www.unidata.ucar.edu/blogs/developer/en/entry/overview-of-zarr-support-in).
WARNING: this code has had limited testing, so do use this version
for production work. Also, performance improvements are ongoing.
Note especially the following platform matrix of successful tests:
Platform | Build System | S3 support
------------------------------------
Linux+gcc | Automake | yes
Linux+gcc | CMake | yes
Visual Studio | CMake | no
Additionally, and as a consequence of the addition of NCZarr,
major changes have been made to the Filter API. NOTE: NCZarr
does not yet support filters, but these changes are enablers for
that support in the future. Note that it is possible
(probable?) that there will be some accidental reversions if the
changes here did not correctly mimic the existing filter testing.
In any case, previously filter ids and parameters were of type
unsigned int. In order to support the more general zarr filter
model, this was all converted to char*. The old HDF5-specific,
unsigned int operations are still supported but they are
wrappers around the new, char* based nc_filterx_XXX functions.
This entailed at least the following changes:
1. Added the files libdispatch/dfilterx.c and include/ncfilter.h
2. Some filterx utilities have been moved to libdispatch/daux.c
3. A new entry, "filter_actions" was added to the NCDispatch table
and the version bumped.
4. An overly complex set of structs was created to support funnelling
all of the filterx operations thru a single dispatch
"filter_actions" entry.
5. Move common code to from libhdf5 to libsrc4 so that it is accessible
to nczarr.
Changes directly related to Zarr:
1. Modified CMakeList.txt and configure.ac to support both C and C++
-- this is in support of S3 support via the awd-sdk libraries.
2. Define a size64_t type to support nczarr.
3. More reworking of libdispatch/dinfermodel.c to
support zarr and to regularize the structure of the fragments
section of a URL.
Changes not directly related to Zarr:
1. Make client-side filter registration be conditional, with default off.
2. Hack include/nc4internal.h to make some flags added by Ed be unique:
e.g. NC_CREAT, NC_INDEF, etc.
3. cleanup include/nchttp.h and libdispatch/dhttp.c.
4. Misc. changes to support compiling under Visual Studio including:
* Better testing under windows for dirent.h and opendir and closedir.
5. Misc. changes to the oc2 code to support various libcurl CURLOPT flags
and to centralize error reporting.
6. By default, suppress the vlen tests that have unfixed memory leaks; add option to enable them.
7. Make part of the nc_test/test_byterange.sh test be contingent on remotetest.unidata.ucar.edu being accessible.
Changes Left TO-DO:
1. fix provenance code, it is too HDF5 specific.
2020-06-29 08:02:47 +08:00
|
|
|
fprintf(stderr,"moveto: nctype=%d depth=%d dimindex=%d",
|
|
|
|
xnode->nctype, (int)depth, (int)dimindex);
|
2011-11-14 12:20:19 +08:00
|
|
|
fprintf(stderr," segment=%s hasstringdim=%d\n",
|
|
|
|
dcetostring((DCEnode*)segment),hasstringdim);
|
|
|
|
#endif
|
|
|
|
|
2012-08-01 04:34:13 +08:00
|
|
|
switch (xnode->nctype) {
|
2011-04-18 02:56:10 +08:00
|
|
|
|
2012-08-01 04:34:13 +08:00
|
|
|
#if 0
|
|
|
|
#define OCDT_FIELD ((OCDT)(1)) /* field of a container */
|
|
|
|
#define OCDT_ELEMENT ((OCDT)(2)) /* element of a structure array */
|
|
|
|
#define OCDT_RECORD ((OCDT)(4)) /* record of a sequence */
|
|
|
|
#define OCDT_ARRAY ((OCDT)(8)) /* is structure array */
|
|
|
|
#define OCDT_SEQUENCE ((OCDT)(16)) /* is sequence */
|
|
|
|
#define OCDT_ATOMIC ((OCDT)(32)) /* is atomic leaf */
|
|
|
|
#endif
|
2011-04-18 02:56:10 +08:00
|
|
|
|
|
|
|
default:
|
2012-08-01 04:34:13 +08:00
|
|
|
goto done;
|
|
|
|
|
|
|
|
case NC_Grid:
|
|
|
|
case NC_Dataset:
|
|
|
|
case NC_Structure:
|
|
|
|
/* Separate out the case where structure is dimensioned */
|
|
|
|
if(oc_data_indexable(conn,currentcontent)) {
|
|
|
|
/* => dimensioned structure */
|
|
|
|
/* The current segment should reflect the
|
|
|
|
proper parts of the nc_get_vara argument
|
|
|
|
*/
|
|
|
|
/* Create odometer for this structure's part of the projection */
|
|
|
|
odom = dapodom_fromsegment(segment,0,segment->rank);
|
|
|
|
while(dapodom_more(odom)) {
|
|
|
|
/* Compute which instance to move to*/
|
|
|
|
ocstat = oc_data_ithelement(conn,currentcontent,
|
|
|
|
odom->index,&dimcontent);
|
|
|
|
if(ocstat != OC_NOERR) {THROWCHK(ocstat); goto done;}
|
|
|
|
ASSERT(oc_data_indexed(conn,dimcontent));
|
|
|
|
ncstat = movetor(nccomm,dimcontent,
|
|
|
|
path,depth,/*keep same depth*/
|
|
|
|
xgetvar,dimindex+segment->rank,
|
|
|
|
memory,segments);
|
|
|
|
dapodom_next(odom);
|
|
|
|
}
|
|
|
|
dapodom_free(odom);
|
2014-08-01 05:59:47 +08:00
|
|
|
odom = NULL;
|
2012-08-01 04:34:13 +08:00
|
|
|
} else {/* scalar instance */
|
|
|
|
ncstat = movetofield(nccomm,currentcontent,path,depth,xgetvar,dimindex,memory,segments);
|
|
|
|
if(ocstat != OC_NOERR) {THROWCHK(ocstat); goto done;}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case NC_Sequence:
|
|
|
|
if(fIsSet(mode,OCDT_SEQUENCE)) {
|
|
|
|
ASSERT((xnode->attachment != NULL));
|
|
|
|
ASSERT((segment != NULL));
|
|
|
|
ASSERT((segment->rank == 1));
|
|
|
|
/* Build an odometer for walking the sequence,
|
|
|
|
however, watch out
|
|
|
|
for the case when the user set a limit and that limit
|
|
|
|
is not actually reached in this request.
|
|
|
|
*/
|
2014-08-12 02:52:57 +08:00
|
|
|
/* By construction, this sequence represents the first
|
2012-08-01 04:34:13 +08:00
|
|
|
(and only) dimension of this segment */
|
|
|
|
odom = dapodom_fromsegment(segment,0,1);
|
|
|
|
while(dapodom_more(odom)) {
|
|
|
|
size_t recordindex = dapodom_count(odom);
|
|
|
|
ocstat = oc_data_ithrecord(conn,currentcontent,
|
|
|
|
recordindex,&reccontent);
|
|
|
|
if(ocstat != OC_NOERR) {
|
|
|
|
if(ocstat == OC_EINDEX)
|
|
|
|
ocstat = OC_EINVALCOORDS;
|
|
|
|
THROWCHK(ocstat); goto done;
|
|
|
|
}
|
|
|
|
ncstat = movetor(nccomm,reccontent,
|
|
|
|
path,depth,
|
|
|
|
xgetvar,dimindex+1,
|
|
|
|
memory,segments);
|
|
|
|
if(ncstat != OC_NOERR) {THROWCHK(ncstat); goto done;}
|
|
|
|
dapodom_next(odom);
|
|
|
|
}
|
|
|
|
} else if(fIsSet(mode,OCDT_RECORD)) {
|
|
|
|
/* Treat like structure */
|
|
|
|
/* currentcontent points to the record instance */
|
|
|
|
ncstat = movetofield(nccomm,currentcontent,path,depth,xgetvar,dimindex,memory,segments);
|
|
|
|
if(ocstat != OC_NOERR) {THROWCHK(ocstat); goto done;}
|
2011-04-18 02:56:10 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-08-01 04:34:13 +08:00
|
|
|
case NC_Atomic:
|
2011-04-18 02:56:10 +08:00
|
|
|
|
2012-01-30 02:56:29 +08:00
|
|
|
if(hasstringdim)
|
2024-03-14 00:51:24 +08:00
|
|
|
ncstat = extractstring(nccomm, xgetvar, xnode, segment, dimindex, conn, currentcontent, memory);
|
|
|
|
else
|
|
|
|
ncstat = extract(nccomm, xgetvar, xnode, segment, dimindex, conn, currentcontent, memory);
|
|
|
|
break;
|
2011-04-18 02:56:10 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-08-01 04:34:13 +08:00
|
|
|
done:
|
|
|
|
oc_data_free(conn,dimcontent);
|
|
|
|
oc_data_free(conn,reccontent);
|
|
|
|
if(ocstat != OC_NOERR) ncstat = ocerrtoncerr(ocstat);
|
2014-08-01 05:59:47 +08:00
|
|
|
if(odom) dapodom_free(odom);
|
2012-08-01 04:34:13 +08:00
|
|
|
return THROW(ncstat);
|
|
|
|
}
|
|
|
|
|
|
|
|
static NCerror
|
|
|
|
movetofield(NCDAPCOMMON* nccomm,
|
|
|
|
OCdatanode currentcontent,
|
|
|
|
NClist* path,
|
2024-03-14 00:51:24 +08:00
|
|
|
size_t depth, /* depth is position in segment list*/
|
2012-08-01 04:34:13 +08:00
|
|
|
Getvara* xgetvar,
|
|
|
|
size_t dimindex, /* dimindex is position in xgetvar->slices*/
|
|
|
|
struct NCMEMORY* memory,
|
|
|
|
NClist* segments)
|
|
|
|
{
|
|
|
|
OCerror ocstat = OC_NOERR;
|
|
|
|
NCerror ncstat = NC_NOERR;
|
|
|
|
size_t fieldindex,gridindex;
|
|
|
|
OClink conn = nccomm->oc.conn;
|
|
|
|
CDFnode* xnode = (CDFnode*)nclistget(path,depth);
|
|
|
|
OCdatanode fieldcontent = NULL;
|
|
|
|
CDFnode* xnext;
|
2024-03-14 00:51:24 +08:00
|
|
|
size_t newdepth;
|
2014-08-16 06:09:07 +08:00
|
|
|
int ffield;
|
2012-08-01 04:34:13 +08:00
|
|
|
|
|
|
|
/* currentcontent points to the grid/dataset/structure/record instance */
|
|
|
|
xnext = (CDFnode*)nclistget(path,depth+1);
|
|
|
|
ASSERT((xnext != NULL));
|
2014-08-16 06:09:07 +08:00
|
|
|
|
|
|
|
/* If findfield is less than 0,
|
|
|
|
and passes through this stanza,
|
|
|
|
an undefined value will be passed to
|
|
|
|
oc_data_ithfield. See coverity
|
|
|
|
issue 712596. */
|
|
|
|
ffield = findfield(xnode, xnext);
|
|
|
|
if(ffield < 0) {
|
|
|
|
ncstat = NC_EBADFIELD;
|
|
|
|
goto done;
|
|
|
|
} else {
|
|
|
|
fieldindex = findfield(xnode,xnext);
|
|
|
|
}
|
|
|
|
|
2012-09-21 00:31:31 +08:00
|
|
|
/* If the next node is a nc_virtual node, then
|
2012-08-01 04:34:13 +08:00
|
|
|
we need to effectively
|
|
|
|
ignore it and use the appropriate subnode.
|
2012-08-16 01:55:25 +08:00
|
|
|
If the next node is a re-struct'd node, then
|
2012-08-01 04:34:13 +08:00
|
|
|
use it as is.
|
|
|
|
*/
|
2012-09-21 00:31:31 +08:00
|
|
|
if(xnext->nc_virtual) {
|
2012-08-01 04:34:13 +08:00
|
|
|
CDFnode* xgrid = xnext;
|
|
|
|
xnext = (CDFnode*)nclistget(path,depth+2); /* real node */
|
|
|
|
gridindex = fieldindex;
|
|
|
|
fieldindex = findfield(xgrid,xnext);
|
|
|
|
fieldindex += gridindex;
|
|
|
|
newdepth = depth+2;
|
|
|
|
} else {
|
|
|
|
newdepth = depth+1;
|
|
|
|
}
|
|
|
|
/* Move to appropriate field */
|
|
|
|
ocstat = oc_data_ithfield(conn,currentcontent,fieldindex,&fieldcontent);
|
|
|
|
if(ocstat != OC_NOERR) {THROWCHK(ocstat); goto done;}
|
|
|
|
ncstat = movetor(nccomm,fieldcontent,
|
|
|
|
path,newdepth,xgetvar,dimindex,memory,
|
|
|
|
segments);
|
|
|
|
|
|
|
|
done:
|
2011-04-18 02:56:10 +08:00
|
|
|
oc_data_free(conn,fieldcontent);
|
|
|
|
if(ocstat != OC_NOERR) ncstat = ocerrtoncerr(ocstat);
|
|
|
|
return THROW(ncstat);
|
|
|
|
}
|
|
|
|
|
2012-08-01 04:34:13 +08:00
|
|
|
#if 0
|
2012-09-28 06:50:41 +08:00
|
|
|
|
2011-04-18 02:56:10 +08:00
|
|
|
/* Determine the index in the odometer at which
|
|
|
|
the odometer will be walking the whole subslice
|
|
|
|
This will allow us to optimize.
|
|
|
|
*/
|
2014-08-12 02:52:57 +08:00
|
|
|
static int
|
2011-04-18 02:56:10 +08:00
|
|
|
wholeslicepoint(Dapodometer* odom)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
int point;
|
|
|
|
for(point=-1,i=0;i<odom->rank;i++) {
|
2012-08-01 04:34:13 +08:00
|
|
|
ASSERT((odom->size[i] != 0));
|
|
|
|
if(odom->start[i] != 0 || odom->stride[i] != 1
|
|
|
|
|| odom->count[i] != odom->size[i])
|
2011-04-18 02:56:10 +08:00
|
|
|
point = i;
|
|
|
|
}
|
|
|
|
if(point == -1)
|
|
|
|
point = 0; /* wholevariable */
|
2014-08-12 02:52:57 +08:00
|
|
|
else if(point == (odom->rank - 1))
|
2011-04-18 02:56:10 +08:00
|
|
|
point = -1; /* no whole point */
|
|
|
|
else
|
|
|
|
point += 1; /* intermediate point */
|
|
|
|
return point;
|
|
|
|
}
|
2012-08-01 04:34:13 +08:00
|
|
|
#endif
|
2011-04-18 02:56:10 +08:00
|
|
|
|
|
|
|
static int
|
|
|
|
findfield(CDFnode* node, CDFnode* field)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
for(i=0;i<nclistlength(node->subnodes);i++) {
|
|
|
|
CDFnode* test = (CDFnode*) nclistget(node->subnodes,i);
|
|
|
|
if(test == field) return i;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-01-30 02:56:29 +08:00
|
|
|
static int
|
|
|
|
conversionrequired(nc_type t1, nc_type t2)
|
|
|
|
{
|
|
|
|
if(t1 == t2)
|
|
|
|
return 0;
|
|
|
|
if(nctypesizeof(t1) != nctypesizeof(t2))
|
|
|
|
return 1;
|
|
|
|
/* Avoid too many cases by making t1 < t2 */
|
|
|
|
if(t1 > t2) {int tmp = t1; t1 = t2; t2 = tmp;}
|
|
|
|
#undef CASE
|
|
|
|
#define CASE(t1,t2) ((t1)<<5 | (t2))
|
|
|
|
switch (CASE(t1,t2)) {
|
|
|
|
case CASE(NC_BYTE,NC_UBYTE):
|
|
|
|
case CASE(NC_BYTE,NC_CHAR):
|
|
|
|
case CASE(NC_CHAR,NC_UBYTE):
|
|
|
|
case CASE(NC_SHORT,NC_USHORT):
|
|
|
|
case CASE(NC_INT,NC_UINT):
|
|
|
|
case CASE(NC_INT64,NC_UINT64):
|
|
|
|
return 0;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We are at a primitive variable or scalar that has no string dimensions.
|
2012-08-01 04:34:13 +08:00
|
|
|
Extract the data. (This is way too complicated)
|
2012-01-30 02:56:29 +08:00
|
|
|
*/
|
|
|
|
static int
|
|
|
|
extract(
|
|
|
|
NCDAPCOMMON* nccomm,
|
|
|
|
Getvara* xgetvar,
|
|
|
|
CDFnode* xnode,
|
|
|
|
DCEsegment* segment,
|
2012-08-01 04:34:13 +08:00
|
|
|
size_t dimindex,/*notused*/
|
2012-01-30 02:56:29 +08:00
|
|
|
OClink conn,
|
2012-08-01 04:34:13 +08:00
|
|
|
OCdatanode currentcontent,
|
2012-01-30 02:56:29 +08:00
|
|
|
struct NCMEMORY* memory
|
|
|
|
)
|
|
|
|
{
|
|
|
|
OCerror ocstat = OC_NOERR;
|
|
|
|
NCerror ncstat = NC_NOERR;
|
2012-08-01 04:34:13 +08:00
|
|
|
size_t count,rank0;
|
|
|
|
Dapodometer* odom = NULL;
|
2012-01-30 02:56:29 +08:00
|
|
|
size_t externtypesize;
|
|
|
|
size_t interntypesize;
|
|
|
|
int requireconversion;
|
2014-08-12 02:52:57 +08:00
|
|
|
char value[16];
|
2012-01-30 02:56:29 +08:00
|
|
|
|
|
|
|
ASSERT((segment != NULL));
|
|
|
|
|
|
|
|
requireconversion = conversionrequired(xgetvar->dsttype,xnode->etype);
|
|
|
|
|
2012-08-01 04:34:13 +08:00
|
|
|
ASSERT(xgetvar->cache != NULL);
|
|
|
|
externtypesize = nctypesizeof(xgetvar->dsttype);
|
|
|
|
interntypesize = nctypesizeof(xnode->etype);
|
|
|
|
|
|
|
|
rank0 = nclistlength(xnode->array.dimset0);
|
|
|
|
|
|
|
|
#ifdef DEBUG2
|
|
|
|
fprintf(stderr,"moveto: primitive: segment=%s",
|
|
|
|
dcetostring((DCEnode*)segment));
|
|
|
|
fprintf(stderr," iswholevariable=%d",xgetvar->cache->wholevariable);
|
|
|
|
fprintf(stderr,"\n");
|
|
|
|
#endif
|
2012-01-30 02:56:29 +08:00
|
|
|
|
2012-08-01 04:34:13 +08:00
|
|
|
if(rank0 == 0) {/* scalar */
|
2012-01-30 02:56:29 +08:00
|
|
|
char* mem = (requireconversion?value:memory->next);
|
|
|
|
ASSERT(externtypesize <= sizeof(value));
|
|
|
|
/* Read the whole scalar directly into memory */
|
2012-08-01 04:34:13 +08:00
|
|
|
ocstat = oc_data_readscalar(conn,currentcontent,externtypesize,mem);
|
2012-01-30 02:56:29 +08:00
|
|
|
if(ocstat != OC_NOERR) {THROWCHK(ocstat); goto done;}
|
|
|
|
if(requireconversion) {
|
|
|
|
/* convert the value to external type */
|
2014-03-25 04:02:52 +08:00
|
|
|
ncstat = dapconvert(xnode->etype,xgetvar->dsttype,memory->next,value,1);
|
2012-01-30 02:56:29 +08:00
|
|
|
if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto done;}
|
|
|
|
}
|
|
|
|
memory->next += (externtypesize);
|
2012-08-01 04:34:13 +08:00
|
|
|
} else if(xgetvar->cache->wholevariable) {/* && rank0 > 0 */
|
|
|
|
/* There are multiple cases, assuming no conversion required.
|
|
|
|
1) client is asking for whole variable
|
|
|
|
=> start=0, count=totalsize, stride=1
|
|
|
|
=> read whole thing at one shot
|
|
|
|
2) client is asking for non-strided subset
|
|
|
|
and edges are maximal
|
|
|
|
=> start=x, count=y, stride=1
|
|
|
|
=> read whole subset at one shot
|
|
|
|
3) client is asking for strided subset or edges are not maximal
|
|
|
|
=> start=x, count=y, stride=s
|
|
|
|
=> we have to use odometer on leading prefix.
|
|
|
|
If conversion required, then read one-by-one
|
|
|
|
*/
|
2024-03-14 00:51:24 +08:00
|
|
|
size_t safeindex = dcesafeindex(segment,0,rank0);
|
|
|
|
assert(safeindex <= rank0);
|
2012-08-01 04:34:13 +08:00
|
|
|
|
|
|
|
if(!requireconversion && safeindex == 0) { /* can read whole thing */
|
|
|
|
size_t internlen;
|
|
|
|
count = dcesegmentsize(segment,0,rank0); /* how many to read */
|
|
|
|
internlen = interntypesize*count;
|
|
|
|
/* Read the whole variable directly into memory.*/
|
2017-03-09 08:01:10 +08:00
|
|
|
ocstat = oc_data_readn(conn,currentcontent,NC_coord_zero,count,internlen,memory->next);
|
2012-08-01 04:34:13 +08:00
|
|
|
/* bump memory pointer */
|
|
|
|
memory->next += internlen;
|
|
|
|
if(ocstat != OC_NOERR) {THROWCHK(ocstat); goto done;}
|
|
|
|
} else if(!requireconversion && safeindex > 0 && safeindex < rank0) {
|
|
|
|
size_t internlen;
|
|
|
|
/* We need to build an odometer for the unsafe prefix of the slices */
|
|
|
|
odom = dapodom_fromsegment(segment,0,safeindex);
|
|
|
|
count = dcesegmentsize(segment,safeindex,rank0); /* read in count chunks */
|
|
|
|
internlen = interntypesize*count;
|
|
|
|
while(dapodom_more(odom)) {
|
|
|
|
ocstat = oc_data_readn(conn,currentcontent,odom->index,count,internlen,memory->next);
|
|
|
|
if(ocstat != OC_NOERR) {THROWCHK(ocstat); goto done;}
|
|
|
|
memory->next += internlen;
|
|
|
|
dapodom_next(odom);
|
|
|
|
}
|
|
|
|
dapodom_free(odom);
|
2012-01-30 02:56:29 +08:00
|
|
|
} else {
|
2012-08-01 04:34:13 +08:00
|
|
|
/* Cover following cases, all of which require reading
|
|
|
|
values one-by-one:
|
|
|
|
1. requireconversion
|
|
|
|
2. !requireconversion but safeindex == rank0 =>no safe indices
|
|
|
|
Note that in case 2, we will do a no-op conversion.
|
|
|
|
*/
|
|
|
|
odom = dapodom_fromsegment(segment,0,rank0);
|
|
|
|
while(dapodom_more(odom)) {
|
|
|
|
char value[16]; /* Big enough to hold any numeric value */
|
|
|
|
ocstat = oc_data_readn(conn,currentcontent,odom->index,1,interntypesize,value);
|
|
|
|
if(ocstat != OC_NOERR) {THROWCHK(ocstat); goto done;}
|
2014-03-25 04:02:52 +08:00
|
|
|
ncstat = dapconvert(xnode->etype,xgetvar->dsttype,memory->next,value,1);
|
2012-08-01 04:34:13 +08:00
|
|
|
if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto done;}
|
|
|
|
memory->next += (externtypesize);
|
|
|
|
dapodom_next(odom);
|
|
|
|
}
|
|
|
|
dapodom_free(odom);
|
2012-01-30 02:56:29 +08:00
|
|
|
}
|
2012-08-01 04:34:13 +08:00
|
|
|
} else { /* !xgetvar->cache->wholevariable && rank0 > 0 */
|
|
|
|
/* This is the case where the constraint was applied by the server,
|
|
|
|
so we just read it in, possibly with conversion
|
|
|
|
*/
|
|
|
|
if(requireconversion) {
|
|
|
|
/* read one-by-one */
|
|
|
|
odom = dapodom_fromsegment(segment,0,rank0);
|
|
|
|
while(dapodom_more(odom)) {
|
|
|
|
char value[16]; /* Big enough to hold any numeric value */
|
|
|
|
ocstat = oc_data_readn(conn,currentcontent,odom->index,1,interntypesize,value);
|
|
|
|
if(ocstat != OC_NOERR) {THROWCHK(ocstat); goto done;}
|
2014-03-25 04:02:52 +08:00
|
|
|
ncstat = dapconvert(xnode->etype,xgetvar->dsttype,memory->next,value,1);
|
2012-08-01 04:34:13 +08:00
|
|
|
if(ncstat != NC_NOERR) {THROWCHK(ncstat); goto done;}
|
|
|
|
memory->next += (externtypesize);
|
|
|
|
dapodom_next(odom);
|
|
|
|
}
|
|
|
|
dapodom_free(odom);
|
|
|
|
} else {/* Read straight to memory */
|
|
|
|
size_t internlen;
|
|
|
|
count = dcesegmentsize(segment,0,rank0); /* how many to read */
|
|
|
|
internlen = interntypesize*count;
|
2017-03-09 08:01:10 +08:00
|
|
|
ocstat = oc_data_readn(conn,currentcontent,NC_coord_zero,count,internlen,memory->next);
|
2012-01-30 02:56:29 +08:00
|
|
|
if(ocstat != OC_NOERR) {THROWCHK(ocstat); goto done;}
|
2012-08-01 04:34:13 +08:00
|
|
|
}
|
2012-01-30 02:56:29 +08:00
|
|
|
}
|
|
|
|
done:
|
|
|
|
return THROW(ncstat);
|
|
|
|
}
|
|
|
|
|
|
|
|
static NCerror
|
2012-08-01 04:34:13 +08:00
|
|
|
slicestring(OClink conn, char* stringmem, DCEslice* slice, struct NCMEMORY* memory)
|
2012-01-30 02:56:29 +08:00
|
|
|
{
|
|
|
|
size_t stringlen;
|
|
|
|
NCerror ncstat = NC_NOERR;
|
|
|
|
char* lastchar;
|
|
|
|
size_t charcount; /* number of characters inserted into memory */
|
|
|
|
|
|
|
|
/* libnc-dap chooses to convert string escapes to the corresponding
|
|
|
|
character; so we do likewise.
|
|
|
|
*/
|
2014-08-12 02:52:57 +08:00
|
|
|
dapexpandescapes(stringmem);
|
2012-01-30 02:56:29 +08:00
|
|
|
stringlen = strlen(stringmem);
|
|
|
|
|
|
|
|
#ifdef DEBUG2
|
|
|
|
fprintf(stderr,"moveto: slicestring: string/%lu=%s\n",stringlen,stringmem);
|
2012-02-04 05:31:50 +08:00
|
|
|
fprintf(stderr,"slicestring: %lu string=|%s|\n",stringlen,stringmem);
|
|
|
|
fprintf(stderr,"slicestring: slice=[%lu:%lu:%lu/%lu]\n",
|
This PR adds EXPERIMENTAL support for accessing data in the
cloud using a variant of the Zarr protocol and storage
format. This enhancement is generically referred to as "NCZarr".
The data model supported by NCZarr is netcdf-4 minus the user-defined
types and the String type. In this sense it is similar to the CDF-5
data model.
More detailed information about enabling and using NCZarr is
described in the document NUG/nczarr.md and in a
[Unidata Developer's blog entry](https://www.unidata.ucar.edu/blogs/developer/en/entry/overview-of-zarr-support-in).
WARNING: this code has had limited testing, so do use this version
for production work. Also, performance improvements are ongoing.
Note especially the following platform matrix of successful tests:
Platform | Build System | S3 support
------------------------------------
Linux+gcc | Automake | yes
Linux+gcc | CMake | yes
Visual Studio | CMake | no
Additionally, and as a consequence of the addition of NCZarr,
major changes have been made to the Filter API. NOTE: NCZarr
does not yet support filters, but these changes are enablers for
that support in the future. Note that it is possible
(probable?) that there will be some accidental reversions if the
changes here did not correctly mimic the existing filter testing.
In any case, previously filter ids and parameters were of type
unsigned int. In order to support the more general zarr filter
model, this was all converted to char*. The old HDF5-specific,
unsigned int operations are still supported but they are
wrappers around the new, char* based nc_filterx_XXX functions.
This entailed at least the following changes:
1. Added the files libdispatch/dfilterx.c and include/ncfilter.h
2. Some filterx utilities have been moved to libdispatch/daux.c
3. A new entry, "filter_actions" was added to the NCDispatch table
and the version bumped.
4. An overly complex set of structs was created to support funnelling
all of the filterx operations thru a single dispatch
"filter_actions" entry.
5. Move common code to from libhdf5 to libsrc4 so that it is accessible
to nczarr.
Changes directly related to Zarr:
1. Modified CMakeList.txt and configure.ac to support both C and C++
-- this is in support of S3 support via the awd-sdk libraries.
2. Define a size64_t type to support nczarr.
3. More reworking of libdispatch/dinfermodel.c to
support zarr and to regularize the structure of the fragments
section of a URL.
Changes not directly related to Zarr:
1. Make client-side filter registration be conditional, with default off.
2. Hack include/nc4internal.h to make some flags added by Ed be unique:
e.g. NC_CREAT, NC_INDEF, etc.
3. cleanup include/nchttp.h and libdispatch/dhttp.c.
4. Misc. changes to support compiling under Visual Studio including:
* Better testing under windows for dirent.h and opendir and closedir.
5. Misc. changes to the oc2 code to support various libcurl CURLOPT flags
and to centralize error reporting.
6. By default, suppress the vlen tests that have unfixed memory leaks; add option to enable them.
7. Make part of the nc_test/test_byterange.sh test be contingent on remotetest.unidata.ucar.edu being accessible.
Changes Left TO-DO:
1. fix provenance code, it is too HDF5 specific.
2020-06-29 08:02:47 +08:00
|
|
|
slice->first,slice->stride,slice->last,slice->declsize);
|
2012-01-30 02:56:29 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Stride across string; if we go past end of string, then pad*/
|
|
|
|
charcount = 0;
|
2024-03-14 00:51:24 +08:00
|
|
|
for(size_t i=slice->first;i<slice->length;i+=slice->stride) {
|
2012-01-30 02:56:29 +08:00
|
|
|
if(i < stringlen)
|
|
|
|
*memory->next = stringmem[i];
|
|
|
|
else /* i >= stringlen*/
|
|
|
|
*memory->next = NC_FILL_CHAR;
|
|
|
|
memory->next++;
|
|
|
|
charcount++;
|
|
|
|
}
|
|
|
|
lastchar = (memory->next);
|
|
|
|
if(charcount > 0) {
|
|
|
|
lastchar--;
|
|
|
|
}
|
|
|
|
|
|
|
|
return THROW(ncstat);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Extract data for a netcdf variable that has a string dimension.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
extractstring(
|
|
|
|
NCDAPCOMMON* nccomm,
|
|
|
|
Getvara* xgetvar,
|
|
|
|
CDFnode* xnode,
|
|
|
|
DCEsegment* segment,
|
2012-08-01 04:34:13 +08:00
|
|
|
size_t dimindex, /*notused*/
|
2012-01-30 02:56:29 +08:00
|
|
|
OClink conn,
|
2012-08-01 04:34:13 +08:00
|
|
|
OCdatanode currentcontent,
|
2012-01-30 02:56:29 +08:00
|
|
|
struct NCMEMORY* memory
|
|
|
|
)
|
|
|
|
{
|
|
|
|
NCerror ncstat = NC_NOERR;
|
|
|
|
OCerror ocstat = OC_NOERR;
|
2023-11-27 19:36:03 +08:00
|
|
|
size_t i;
|
2012-08-01 04:34:13 +08:00
|
|
|
size_t rank0;
|
2012-01-30 02:56:29 +08:00
|
|
|
NClist* strings = NULL;
|
2012-08-01 04:34:13 +08:00
|
|
|
Dapodometer* odom = NULL;
|
2012-01-30 02:56:29 +08:00
|
|
|
|
2012-08-01 04:34:13 +08:00
|
|
|
ASSERT(xnode->etype == NC_STRING || xnode->etype == NC_URL);
|
2012-01-30 02:56:29 +08:00
|
|
|
|
2014-08-12 02:52:57 +08:00
|
|
|
/* Compute rank minus string dimension */
|
2012-08-01 04:34:13 +08:00
|
|
|
rank0 = nclistlength(xnode->array.dimset0);
|
2012-01-30 02:56:29 +08:00
|
|
|
|
2012-08-01 04:34:13 +08:00
|
|
|
/* keep whole extracted strings stored in an NClist */
|
2012-01-30 02:56:29 +08:00
|
|
|
strings = nclistnew();
|
2012-08-01 04:34:13 +08:00
|
|
|
|
|
|
|
if(rank0 == 0) {/*=> scalar*/
|
2012-01-30 02:56:29 +08:00
|
|
|
char* value = NULL;
|
2012-08-01 04:34:13 +08:00
|
|
|
ocstat = oc_data_readscalar(conn,currentcontent,sizeof(value),&value);
|
2012-01-30 02:56:29 +08:00
|
|
|
if(ocstat != OC_NOERR) goto done;
|
2014-08-12 02:52:57 +08:00
|
|
|
nclistpush(strings,(void*)value);
|
2012-08-01 04:34:13 +08:00
|
|
|
} else {
|
|
|
|
/* Use the odometer to walk to the appropriate fields*/
|
|
|
|
odom = dapodom_fromsegment(segment,0,rank0);
|
|
|
|
while(dapodom_more(odom)) {
|
|
|
|
char* value = NULL;
|
|
|
|
ocstat = oc_data_readn(conn,currentcontent,odom->index,1,sizeof(value),&value);
|
2013-05-02 06:31:01 +08:00
|
|
|
if(ocstat != OC_NOERR)
|
|
|
|
goto done;
|
2014-08-12 02:52:57 +08:00
|
|
|
nclistpush(strings,(void*)value);
|
2012-08-01 04:34:13 +08:00
|
|
|
dapodom_next(odom);
|
|
|
|
}
|
|
|
|
dapodom_free(odom);
|
2014-08-18 02:03:23 +08:00
|
|
|
odom = NULL;
|
2012-01-30 02:56:29 +08:00
|
|
|
}
|
2012-08-01 04:34:13 +08:00
|
|
|
/* Get each string in turn, slice it by applying the string dimm
|
|
|
|
and store in user supplied memory
|
|
|
|
*/
|
2012-01-30 02:56:29 +08:00
|
|
|
for(i=0;i<nclistlength(strings);i++) {
|
|
|
|
char* s = (char*)nclistget(strings,i);
|
2012-08-01 04:34:13 +08:00
|
|
|
slicestring(conn,s,&segment->slices[rank0],memory);
|
2014-08-23 05:12:24 +08:00
|
|
|
free(s);
|
|
|
|
}
|
2012-01-30 02:56:29 +08:00
|
|
|
done:
|
2014-08-18 04:12:19 +08:00
|
|
|
if(strings != NULL) nclistfree(strings);
|
2012-01-30 02:56:29 +08:00
|
|
|
if(ocstat != OC_NOERR) ncstat = ocerrtoncerr(ocstat);
|
|
|
|
return THROW(ncstat);
|
|
|
|
}
|
2013-05-02 06:31:01 +08:00
|
|
|
|
2014-03-25 04:02:52 +08:00
|
|
|
static NCerror
|
|
|
|
makegetvar(NCDAPCOMMON* nccomm, CDFnode* var, void* data, nc_type dsttype, Getvara** getvarp)
|
|
|
|
{
|
|
|
|
NCerror ncstat = NC_NOERR;
|
|
|
|
|
|
|
|
if(getvarp)
|
|
|
|
{
|
|
|
|
Getvara* getvar;
|
|
|
|
|
|
|
|
getvar = (Getvara*)calloc(1,sizeof(Getvara));
|
|
|
|
MEMCHECK(getvar,NC_ENOMEM);
|
|
|
|
|
|
|
|
getvar->target = var;
|
|
|
|
getvar->memory = data;
|
|
|
|
getvar->dsttype = dsttype;
|
|
|
|
|
|
|
|
*getvarp = getvar;
|
|
|
|
}
|
|
|
|
return ncstat;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Given DDS node, locate the node
|
|
|
|
in a DATADDS that matches the DDS node.
|
|
|
|
Return NULL if no node found
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
unattach(CDFnode* root)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
CDFtree* xtree = root->tree;
|
|
|
|
for(i=0;i<nclistlength(xtree->nodes);i++) {
|
|
|
|
CDFnode* xnode = (CDFnode*)nclistget(xtree->nodes,i);
|
|
|
|
/* break bi-directional link */
|
|
|
|
xnode->attachment = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-01-16 05:19:51 +08:00
|
|
|
setattach(CDFnode* target, CDFnode* pattern)
|
2014-03-25 04:02:52 +08:00
|
|
|
{
|
2015-01-16 05:19:51 +08:00
|
|
|
target->attachment = pattern;
|
|
|
|
pattern->attachment = target;
|
2014-03-25 04:02:52 +08:00
|
|
|
/* Transfer important information */
|
2015-01-16 05:19:51 +08:00
|
|
|
target->externaltype = pattern->externaltype;
|
|
|
|
target->maxstringlength = pattern->maxstringlength;
|
|
|
|
target->sequencelimit = pattern->sequencelimit;
|
|
|
|
target->ncid = pattern->ncid;
|
2014-03-25 04:02:52 +08:00
|
|
|
/* also transfer libncdap4 info */
|
2015-01-16 05:19:51 +08:00
|
|
|
target->typeid = pattern->typeid;
|
|
|
|
target->typesize = pattern->typesize;
|
2014-03-25 04:02:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static NCerror
|
2015-01-16 05:19:51 +08:00
|
|
|
attachdims(CDFnode* xnode, CDFnode* pattern)
|
2014-03-25 04:02:52 +08:00
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
for(i=0;i<nclistlength(xnode->array.dimsetall);i++) {
|
|
|
|
CDFnode* xdim = (CDFnode*)nclistget(xnode->array.dimsetall,i);
|
2015-01-16 05:19:51 +08:00
|
|
|
CDFnode* tdim = (CDFnode*)nclistget(pattern->array.dimsetall,i);
|
2014-03-25 04:02:52 +08:00
|
|
|
setattach(xdim,tdim);
|
|
|
|
#ifdef DEBUG2
|
|
|
|
fprintf(stderr,"attachdim: %s->%s\n",xdim->ocname,tdim->ocname);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
return NC_NOERR;
|
|
|
|
}
|
|
|
|
|
2014-08-12 02:52:57 +08:00
|
|
|
/*
|
2014-03-25 04:02:52 +08:00
|
|
|
Match a DATADDS node to a DDS node.
|
|
|
|
It is assumed that both trees have been re-struct'ed if necessary.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static NCerror
|
2023-11-27 19:36:03 +08:00
|
|
|
attachr(CDFnode* xnode, NClist* patternpath, size_t depth)
|
2014-03-25 04:02:52 +08:00
|
|
|
{
|
2023-11-27 19:36:03 +08:00
|
|
|
size_t i,plen,lastnode,gridable;
|
2014-03-25 04:02:52 +08:00
|
|
|
NCerror ncstat = NC_NOERR;
|
2015-01-16 05:19:51 +08:00
|
|
|
CDFnode* patternpathnode;
|
|
|
|
CDFnode* patternpathnext;
|
2014-03-25 04:02:52 +08:00
|
|
|
|
2015-01-16 05:19:51 +08:00
|
|
|
plen = nclistlength(patternpath);
|
2014-03-25 04:02:52 +08:00
|
|
|
if(depth >= plen) {THROWCHK(ncstat=NC_EINVAL); goto done;}
|
|
|
|
|
|
|
|
lastnode = (depth == (plen-1));
|
2015-01-16 05:19:51 +08:00
|
|
|
patternpathnode = (CDFnode*)nclistget(patternpath,depth);
|
|
|
|
ASSERT((simplenodematch(xnode,patternpathnode)));
|
|
|
|
setattach(xnode,patternpathnode);
|
2014-03-25 04:02:52 +08:00
|
|
|
#ifdef DEBUG2
|
2015-01-16 05:19:51 +08:00
|
|
|
fprintf(stderr,"attachnode: %s->%s\n",xnode->ocname,patternpathnode->ocname);
|
2014-03-25 04:02:52 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if(lastnode) goto done; /* We have the match and are done */
|
|
|
|
|
|
|
|
if(nclistlength(xnode->array.dimsetall) > 0) {
|
2015-01-16 05:19:51 +08:00
|
|
|
attachdims(xnode,patternpathnode);
|
2014-03-25 04:02:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ASSERT((!lastnode));
|
2015-01-16 05:19:51 +08:00
|
|
|
patternpathnext = (CDFnode*)nclistget(patternpath,depth+1);
|
2014-03-25 04:02:52 +08:00
|
|
|
|
2015-01-16 05:19:51 +08:00
|
|
|
gridable = (patternpathnext->nctype == NC_Grid && depth+2 < plen);
|
2014-03-25 04:02:52 +08:00
|
|
|
|
2015-01-16 05:19:51 +08:00
|
|
|
/* Try to find an xnode subnode that matches patternpathnext */
|
2014-03-25 04:02:52 +08:00
|
|
|
for(i=0;i<nclistlength(xnode->subnodes);i++) {
|
|
|
|
CDFnode* xsubnode = (CDFnode*)nclistget(xnode->subnodes,i);
|
2015-01-16 05:19:51 +08:00
|
|
|
if(simplenodematch(xsubnode,patternpathnext)) {
|
|
|
|
ncstat = attachr(xsubnode,patternpath,depth+1);
|
2014-03-25 04:02:52 +08:00
|
|
|
if(ncstat) goto done;
|
|
|
|
} else if(gridable && xsubnode->nctype == NC_Atomic) {
|
|
|
|
/* grids may or may not appear in the datadds;
|
|
|
|
try to match the xnode subnodes against the parts of the grid
|
|
|
|
*/
|
2015-01-16 05:19:51 +08:00
|
|
|
CDFnode* patternpathnext2 = (CDFnode*)nclistget(patternpath,depth+2);
|
|
|
|
if(simplenodematch(xsubnode,patternpathnext2)) {
|
|
|
|
ncstat = attachr(xsubnode,patternpath,depth+2);
|
2014-03-25 04:02:52 +08:00
|
|
|
if(ncstat) goto done;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
done:
|
|
|
|
return THROW(ncstat);
|
|
|
|
}
|
|
|
|
|
|
|
|
NCerror
|
2015-01-16 05:19:51 +08:00
|
|
|
attach(CDFnode* xroot, CDFnode* pattern)
|
2014-03-25 04:02:52 +08:00
|
|
|
{
|
|
|
|
NCerror ncstat = NC_NOERR;
|
2015-01-16 05:19:51 +08:00
|
|
|
NClist* patternpath = nclistnew();
|
|
|
|
CDFnode* ddsroot = pattern->root;
|
2014-03-25 04:02:52 +08:00
|
|
|
|
|
|
|
if(xroot->attachment) unattach(xroot);
|
|
|
|
if(ddsroot != NULL && ddsroot->attachment) unattach(ddsroot);
|
|
|
|
if(!simplenodematch(xroot,ddsroot))
|
|
|
|
{THROWCHK(ncstat=NC_EINVAL); goto done;}
|
2015-01-16 05:19:51 +08:00
|
|
|
collectnodepath(pattern,patternpath,WITHDATASET);
|
|
|
|
ncstat = attachr(xroot,patternpath,0);
|
2014-03-25 04:02:52 +08:00
|
|
|
done:
|
2015-01-16 05:19:51 +08:00
|
|
|
nclistfree(patternpath);
|
2014-03-25 04:02:52 +08:00
|
|
|
return ncstat;
|
|
|
|
}
|
|
|
|
|
|
|
|
static NCerror
|
2015-01-16 05:19:51 +08:00
|
|
|
attachsubsetr(CDFnode* target, CDFnode* pattern)
|
2014-03-25 04:02:52 +08:00
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
NCerror ncstat = NC_NOERR;
|
2023-11-27 19:36:03 +08:00
|
|
|
size_t fieldindex;
|
2014-03-25 04:02:52 +08:00
|
|
|
|
|
|
|
#ifdef DEBUG2
|
2015-01-16 05:19:51 +08:00
|
|
|
fprintf(stderr,"attachsubsetr: attach: target=%s pattern=%s\n",
|
|
|
|
target->ocname,pattern->ocname);
|
2014-03-25 04:02:52 +08:00
|
|
|
#endif
|
|
|
|
|
2015-01-16 05:19:51 +08:00
|
|
|
ASSERT((nodematch(target,pattern)));
|
|
|
|
setattach(target,pattern);
|
2014-03-25 04:02:52 +08:00
|
|
|
|
2015-01-16 05:19:51 +08:00
|
|
|
/* Try to match target subnodes against pattern subnodes */
|
2014-03-25 04:02:52 +08:00
|
|
|
|
|
|
|
fieldindex = 0;
|
2015-01-16 05:19:51 +08:00
|
|
|
for(fieldindex=0,i=0;i<nclistlength(pattern->subnodes) && fieldindex<nclistlength(target->subnodes);i++) {
|
|
|
|
CDFnode* patternsubnode = (CDFnode*)nclistget(pattern->subnodes,i);
|
2014-03-25 04:02:52 +08:00
|
|
|
CDFnode* targetsubnode = (CDFnode*)nclistget(target->subnodes,fieldindex);
|
2015-01-16 05:19:51 +08:00
|
|
|
if(nodematch(targetsubnode,patternsubnode)) {
|
2014-03-25 04:02:52 +08:00
|
|
|
#ifdef DEBUG2
|
2015-01-16 05:19:51 +08:00
|
|
|
fprintf(stderr,"attachsubsetr: match: %s :: %s\n",targetsubnode->ocname,patternsubnode->ocname);
|
2014-03-25 04:02:52 +08:00
|
|
|
#endif
|
2015-01-16 05:19:51 +08:00
|
|
|
ncstat = attachsubsetr(targetsubnode,patternsubnode);
|
2014-03-25 04:02:52 +08:00
|
|
|
if(ncstat) goto done;
|
|
|
|
fieldindex++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
done:
|
|
|
|
return THROW(ncstat);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-08-12 02:52:57 +08:00
|
|
|
/*
|
2015-01-16 05:19:51 +08:00
|
|
|
Match nodes in pattern tree to nodes in target tree;
|
|
|
|
pattern tree is typically a structural superset of target tree.
|
2014-08-12 02:52:57 +08:00
|
|
|
WARNING: Dimensions are not attached
|
2014-03-25 04:02:52 +08:00
|
|
|
*/
|
|
|
|
|
2014-06-03 04:02:34 +08:00
|
|
|
static NCerror
|
2015-01-16 05:19:51 +08:00
|
|
|
attachsubset(CDFnode* target, CDFnode* pattern)
|
2014-03-25 04:02:52 +08:00
|
|
|
{
|
|
|
|
NCerror ncstat = NC_NOERR;
|
|
|
|
|
2015-01-16 05:19:51 +08:00
|
|
|
if(pattern == NULL) {THROWCHK(ncstat=NC_NOERR); goto done;}
|
|
|
|
if(!nodematch(target,pattern)) {THROWCHK(ncstat=NC_EINVAL); goto done;}
|
2014-03-25 04:02:52 +08:00
|
|
|
#ifdef DEBUG2
|
|
|
|
fprintf(stderr,"attachsubset: target=%s\n",dumptree(target));
|
2015-01-16 05:19:51 +08:00
|
|
|
fprintf(stderr,"attachsubset: pattern=%s\n",dumptree(pattern));
|
2014-03-25 04:02:52 +08:00
|
|
|
#endif
|
2015-01-16 05:19:51 +08:00
|
|
|
ncstat = attachsubsetr(target,pattern);
|
2014-03-25 04:02:52 +08:00
|
|
|
done:
|
|
|
|
return ncstat;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
freegetvara(Getvara* vara)
|
|
|
|
{
|
|
|
|
if(vara == NULL) return;
|
|
|
|
dcefree((DCEnode*)vara->varaprojection);
|
|
|
|
nullfree(vara);
|
|
|
|
}
|
2013-05-02 06:31:01 +08:00
|
|
|
|
|
|
|
#ifdef EXTERN_UNUSED
|
|
|
|
int
|
|
|
|
nc3d_getvarmx(int ncid, int varid,
|
|
|
|
const size_t *start,
|
|
|
|
const size_t *edges,
|
|
|
|
const ptrdiff_t* stride,
|
|
|
|
const ptrdiff_t* map,
|
|
|
|
void* data,
|
|
|
|
nc_type dsttype0)
|
|
|
|
{
|
|
|
|
NCerror ncstat = NC_NOERR;
|
|
|
|
int i;
|
|
|
|
NC* drno;
|
|
|
|
NC* substrate;
|
|
|
|
NC3_INFO* substrate3;
|
|
|
|
NCDAPCOMMON* dapcomm;
|
|
|
|
NC_var* var;
|
|
|
|
CDFnode* cdfvar; /* cdf node mapping to var*/
|
|
|
|
NClist* varnodes;
|
|
|
|
nc_type dsttype;
|
|
|
|
size_t externsize;
|
|
|
|
size_t dimsizes[NC_MAX_VAR_DIMS];
|
|
|
|
Dapodometer* odom = NULL;
|
|
|
|
unsigned int ncrank;
|
|
|
|
NClist* ncdims = NULL;
|
|
|
|
size_t nelems;
|
|
|
|
#ifdef NEWVARM
|
|
|
|
char* localcopy; /* of whole variable */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
ncstat = NC_check_id(ncid, (NC**)&drno);
|
|
|
|
if(ncstat != NC_NOERR) goto done;
|
|
|
|
dapcomm = (NCDAPCOMMON*)drno->dispatchdata;
|
|
|
|
|
|
|
|
ncstat = NC_check_id(drno->substrate, &substrate);
|
|
|
|
if(ncstat != NC_NOERR) goto done;
|
|
|
|
substrate3 = (NC3_INFO*)drno->dispatchdata;
|
|
|
|
|
|
|
|
var = NC_lookupvar(substrate3,varid);
|
|
|
|
if(var == NULL) {ncstat = NC_ENOTVAR; goto done;}
|
|
|
|
|
|
|
|
/* Locate var node via varid */
|
|
|
|
varnodes = dapcomm->cdf.ddsroot->tree->varnodes;
|
|
|
|
for(i=0;i<nclistlength(varnodes);i++) {
|
|
|
|
CDFnode* node = (CDFnode*)nclistget(varnodes,i);
|
|
|
|
if(node->array.basevar == NULL
|
|
|
|
&& node->nctype == NC_Atomic
|
|
|
|
&& node->ncid == varid) {
|
|
|
|
cdfvar = node;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ASSERT((cdfvar != NULL));
|
|
|
|
ASSERT((strcmp(cdfvar->ncfullname,var->name->cp)==0));
|
|
|
|
|
|
|
|
if(nclistlength(cdfvar->array.dimsetplus) == 0) {
|
|
|
|
/* The variable is a scalar; consequently, there is only one
|
|
|
|
thing to get and only one place to put it. */
|
|
|
|
/* recurse with additional parameters */
|
|
|
|
return THROW(nc3d_getvarx(ncid,varid,
|
|
|
|
NULL,NULL,NULL,
|
|
|
|
data,dsttype0));
|
|
|
|
}
|
2014-08-12 02:52:57 +08:00
|
|
|
|
2013-05-02 06:31:01 +08:00
|
|
|
dsttype = (dsttype0);
|
|
|
|
|
|
|
|
/* Default to using the inquiry type for this var*/
|
|
|
|
if(dsttype == NC_NAT) dsttype = cdfvar->externaltype;
|
|
|
|
|
|
|
|
/* Validate any implied type conversion*/
|
|
|
|
if(cdfvar->etype != dsttype && dsttype == NC_CHAR) {
|
|
|
|
/* The only disallowed conversion is to/from char and non-byte
|
|
|
|
numeric types*/
|
|
|
|
switch (cdfvar->etype) {
|
|
|
|
case NC_STRING: case NC_URL:
|
|
|
|
case NC_CHAR: case NC_BYTE: case NC_UBYTE:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return THROW(NC_ECHAR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
externsize = nctypesizeof(dsttype);
|
|
|
|
|
|
|
|
/* Accumulate the dimension sizes and the total # of elements */
|
|
|
|
ncdims = cdfvar->array.dimsetall;
|
|
|
|
ncrank = nclistlength(ncdims);
|
|
|
|
|
|
|
|
nelems = 1; /* also Compute the number of elements being retrieved */
|
|
|
|
for(i=0;i<ncrank;i++) {
|
|
|
|
CDFnode* dim = (CDFnode*)nclistget(ncdims,i);
|
|
|
|
dimsizes[i] = dim->dim.declsize;
|
|
|
|
nelems *= edges[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Originally, this code repeatedly extracted single values
|
|
|
|
using get_var1. In an attempt to improve performance,
|
|
|
|
I have converted to reading the whole variable at once
|
|
|
|
and walking it locally.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef NEWVARM
|
|
|
|
localcopy = (char*)malloc(nelems*externsize);
|
|
|
|
|
|
|
|
/* We need to use the varieties of get_vars in order to
|
|
|
|
properly do conversion to the external type
|
|
|
|
*/
|
|
|
|
|
|
|
|
switch (dsttype) {
|
|
|
|
|
|
|
|
case NC_CHAR:
|
|
|
|
ncstat = nc_get_vars_text(ncid,varid,start, edges, stride,
|
|
|
|
(char*)localcopy);
|
|
|
|
break;
|
|
|
|
case NC_BYTE:
|
|
|
|
ncstat = nc_get_vars_schar(ncid,varid,start, edges, stride,
|
|
|
|
(signed char*)localcopy);
|
|
|
|
break;
|
|
|
|
case NC_SHORT:
|
|
|
|
ncstat = nc_get_vars_short(ncid,varid, start, edges, stride,
|
|
|
|
(short*)localcopy);
|
|
|
|
break;
|
|
|
|
case NC_INT:
|
|
|
|
ncstat = nc_get_vars_int(ncid,varid,start, edges, stride,
|
|
|
|
(int*)localcopy);
|
|
|
|
break;
|
|
|
|
case NC_FLOAT:
|
|
|
|
ncstat = nc_get_vars_float(ncid,varid,start, edges, stride,
|
|
|
|
(float*)localcopy);
|
|
|
|
break;
|
|
|
|
case NC_DOUBLE:
|
|
|
|
ncstat = nc_get_vars_double(ncid,varid, start, edges, stride,
|
|
|
|
(double*)localcopy);
|
|
|
|
break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
odom = dapodom_new(ncrank,start,edges,stride,NULL);
|
|
|
|
|
|
|
|
/* Walk the local copy */
|
|
|
|
for(i=0;i<nelems;i++) {
|
|
|
|
size_t voffset = dapodom_varmcount(odom,map,dimsizes);
|
|
|
|
void* dataoffset = (void*)(((char*)data) + (externsize*voffset));
|
|
|
|
char* localpos = (localcopy + externsize*i);
|
|
|
|
/* extract the indexset'th value from local copy */
|
|
|
|
memcpy(dataoffset,(void*)localpos,externsize);
|
|
|
|
/*
|
|
|
|
fprintf(stderr,"new: %lu -> %lu %f\n",
|
|
|
|
(unsigned long)(i),
|
|
|
|
(unsigned long)voffset,
|
|
|
|
*(float*)localpos);
|
|
|
|
*/
|
|
|
|
dapodom_next(odom);
|
2014-08-12 02:52:57 +08:00
|
|
|
}
|
2013-05-02 06:31:01 +08:00
|
|
|
#else
|
|
|
|
odom = dapodom_new(ncrank,start,edges,stride,NULL);
|
|
|
|
while(dapodom_more(odom)) {
|
|
|
|
size_t* indexset = odom->index;
|
|
|
|
size_t voffset = dapodom_varmcount(odom,map,dimsizes);
|
|
|
|
char internalmem[128];
|
|
|
|
char externalmem[128];
|
|
|
|
void* dataoffset = (void*)(((char*)data) + (externsize*voffset));
|
|
|
|
|
|
|
|
/* get the indexset'th value using variable's internal type */
|
|
|
|
ncstat = nc_get_var1(ncid,varid,indexset,(void*)&internalmem);
|
|
|
|
if(ncstat != NC_NOERR) goto done;
|
|
|
|
/* Convert to external type */
|
2014-03-25 04:02:52 +08:00
|
|
|
ncstat = dapconvert(cdfvar->etype,dsttype,externalmem,internalmem);
|
2013-05-02 06:31:01 +08:00
|
|
|
if(ncstat != NC_NOERR) goto done;
|
|
|
|
memcpy(dataoffset,(void*)externalmem,externsize);
|
|
|
|
/*
|
|
|
|
fprintf(stderr,"old: %lu -> %lu %f\n",
|
|
|
|
(unsigned long)dapodom_count(odom),
|
|
|
|
(unsigned long)voffset,
|
|
|
|
*(float*)externalmem);
|
|
|
|
*/
|
|
|
|
dapodom_next(odom);
|
2014-08-12 02:52:57 +08:00
|
|
|
}
|
2013-05-02 06:31:01 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
done:
|
|
|
|
return ncstat;
|
|
|
|
}
|
|
|
|
#endif /*EXTERN_UNUSED*/
|