Commit 217e93e9 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Added missing code from charxy.

parent f861459a
......@@ -3384,8 +3384,8 @@ void gridPrintKernel(int gridID, int opt, FILE *fp)
int gridsize = gridInqSize(gridID);
int xsize = gridInqXsize(gridID);
int ysize = gridInqYsize(gridID);
int xstrlen = gridInqXIscPtr(gridID);
int ystrlen = gridInqYIscPtr(gridID);
int xstrlen = gridInqXIsc(gridID);
int ystrlen = gridInqYIsc(gridID);
int nvertex = gridInqNvertex(gridID);
int prec = gridInqPrec(gridID);
......@@ -3705,6 +3705,11 @@ static const double *gridInqXValsPtrSerial(grid_t *gridptr)
return gridptr->x.vals;
}
static const char **gridInqXCvalsPtrSerial(grid_t *gridptr)
{
return (const char **) gridptr->x.cvals;
}
const double *gridInqXvalsPtr(int gridID)
{
......@@ -3719,16 +3724,14 @@ const char **gridInqXCvalsPtr(int gridID)
return gridptr->vtable->inqXCvalsPtr(gridptr);
}
int gridInqXIscPtr(int gridID)
static const double *gridInqYValsPtrSerial(grid_t *gridptr)
{
grid_t *gridptr = grid_to_pointer(gridID);
return gridptr->vtable->inqXIscPtr(gridptr);
return gridptr->y.vals;
}
static const double *gridInqYValsPtrSerial(grid_t *gridptr)
static const char **gridInqYCvalsPtrSerial(grid_t *gridptr)
{
return gridptr->y.vals;
return (const char **) gridptr->y.cvals;
}
const double *gridInqYvalsPtr(int gridID)
......@@ -3743,12 +3746,6 @@ const char **gridInqYCvalsPtr(int gridID)
return gridptr->vtable->inqYCvalsPtr(gridptr);
}
int gridInqYIscPtr(int gridID)
{
grid_t *gridptr = grid_to_pointer(gridID);
return gridptr->vtable->inqYIscPtr(gridptr);
}
/*
@Function gridDefParamLCC
@Title Define the parameter of a Lambert Conformal Conic grid
......@@ -4898,6 +4895,8 @@ const struct gridVirtTable cdiGridVtable
.inqYIsc = gridInqYIscSerial,
.inqXValsPtr = gridInqXValsPtrSerial,
.inqYValsPtr = gridInqYValsPtrSerial,
.inqXCvalsPtr = gridInqXCvalsPtrSerial,
.inqYCvalsPtr = gridInqYCvalsPtrSerial,
.compareXYFull = compareXYvals,
.compareXYAO = compareXYvals2,
.inqArea = gridInqAreaSerial,
......
......@@ -37,10 +37,8 @@ struct gridVirtTable
int (*inqYIsc)(grid_t *gridptr);
const double *(*inqXValsPtr)(grid_t *gridptr);
const char **(*inqXCvalsPtr)(grid_t *gridptr);
int (*inqXIscPtr)(grid_t *gridptr);
const double *(*inqYValsPtr)(grid_t *gridptr);
const char **(*inqYCvalsPtr)(grid_t *gridptr);
int (*inqYIscPtr)(grid_t *gridptr);
/* return if for both grids, all xval and all yval are equal */
bool (*compareXYFull)(grid_t *gridRef, grid_t *gridTest);
/* return if for both grids, x[0], y[0], x[size-1] and y[size-1] are
......@@ -137,9 +135,7 @@ const double *gridInqXvalsPtr(int gridID);
const double *gridInqYvalsPtr(int gridID);
const char **gridInqXCvalsPtr(int gridID);
int gridInqXIscPtr(int gridID);
const char **gridInqYCvalsPtr(int gridID);
int gridInqYIscPtr(int gridID);
const double *gridInqXboundsPtr(int gridID);
const double *gridInqYboundsPtr(int gridID);
......
......@@ -45,6 +45,7 @@ typedef struct {
bool ignore;
bool isx;
bool isy;
bool isc;
bool islon;
bool islat;
bool islev;
......@@ -310,7 +311,7 @@ int cdfInqDatatype(int xtype, bool lunsigned)
#endif
if ( xtype == NC_BYTE ) datatype = CDI_DATATYPE_INT8;
/* else if ( xtype == NC_CHAR ) datatype = CDI_DATATYPE_UINT8; */
else if ( xtype == NC_CHAR ) datatype = CDI_DATATYPE_UINT8;
else if ( xtype == NC_SHORT ) datatype = CDI_DATATYPE_INT16;
else if ( xtype == NC_INT ) datatype = CDI_DATATYPE_INT32;
else if ( xtype == NC_FLOAT ) datatype = CDI_DATATYPE_FLT32;
......@@ -628,6 +629,7 @@ void init_ncvars(long nvars, ncvar_t *ncvars)
ncvars[ncvarid].ignore = false;
ncvars[ncvarid].isx = false;
ncvars[ncvarid].isy = false;
ncvars[ncvarid].isc = false;
ncvars[ncvarid].islon = false;
ncvars[ncvarid].islat = false;
ncvars[ncvarid].islev = false;
......@@ -1937,6 +1939,12 @@ void verify_coordinate_vars_2(int nvars, ncvar_t *ncvars)
continue;
}
}
else if ( strcmp(ncvars[ncvarid].stdname, "region") == 0 ||
strcmp(ncvars[ncvarid].stdname, "area_type") == 0 ||
cdfInqDatatype(ncvars[ncvarid].xtype, ncvars[ncvarid].lunsigned) == CDI_DATATYPE_UINT8 )
{
ncvars[ncvarid].isc = true;
}
/* not needed anymore for rotated grids */
if ( !ncvars[ncvarid].islon && ncvars[ncvarid].longname[0] != 0 &&
......@@ -2300,7 +2308,7 @@ bool cdf_read_coordinates(struct cdfLazyGrid *restrict lazyGrid, ncvar_t *ncvar,
if ( xvarid != CDI_UNDEFID && yvarid != CDI_UNDEFID )
{
int ndims = ncvars[xvarid].ndims;
if ( ndims != ncvars[yvarid].ndims )
if ( ndims != ncvars[yvarid].ndims && !ncvars[xvarid].isc && !ncvars[yvarid].isc )
{
Warning("Inconsistent grid structure for variable %s!", ncvar->name);
ncvar->xvarid = xvarid = CDI_UNDEFID;
......@@ -3864,6 +3872,7 @@ int cdfInqContents(stream_t *streamptr)
else if ( ncvars[ncvar->coordvarids[i]].islat ||
ncvars[ncvar->coordvarids[i]].isy ) ncvar->yvarid = ncvar->coordvarids[i];
else if ( ncvars[ncvar->coordvarids[i]].islev ) ncvar->zvarid = ncvar->coordvarids[i];
else if ( ncvars[ncvar->coordvarids[i]].isc ) ncvar->cvarids[i] = ncvar->coordvarids[i];
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment