Commit 87e021f5 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

NetCDF: added support for grid datatype integer.

parent e26b5a43
2016-10-10 Uwe Schulzweida
* NetCDF: added support for grid datatype integer
* NetCDF: added support for proj coordinate without mapping attribute
2016-10-04 Uwe Schulzweida
......
......@@ -41,7 +41,7 @@ void cdfDefVarDeflate(int ncid, int ncvarid, int deflate_level)
#endif
}
static
int cdfDefDatatype(int datatype, int filetype)
{
int xtype = NC_FLOAT;
......@@ -64,7 +64,7 @@ int cdfDefDatatype(int datatype, int filetype)
else if ( datatype == CDI_DATATYPE_UINT32 ) xtype = NC_INT;
#endif
else if ( datatype == CDI_DATATYPE_FLT64 ) xtype = NC_DOUBLE;
else xtype = NC_FLOAT;
else xtype = NC_FLOAT;
}
else
{
......@@ -75,7 +75,7 @@ int cdfDefDatatype(int datatype, int filetype)
else if ( datatype == CDI_DATATYPE_UINT16 ) xtype = NC_INT;
else if ( datatype == CDI_DATATYPE_UINT32 ) xtype = NC_INT;
else if ( datatype == CDI_DATATYPE_FLT64 ) xtype = NC_DOUBLE;
else xtype = NC_FLOAT;
else xtype = NC_FLOAT;
}
return xtype;
......
......@@ -1186,7 +1186,6 @@ void gridDefPrec(int gridID, int prec)
int gridInqPrec(int gridID)
{
grid_t *gridptr = grid_to_pointer(gridID);
return gridptr->prec;
}
......@@ -1209,7 +1208,6 @@ The function @func{gridInqXsize} returns the number of values of a X-axis.
int gridInqXsize(int gridID)
{
grid_t *gridptr = grid_to_pointer(gridID);
return gridptr->x.size;
}
......@@ -1274,7 +1272,6 @@ The function @func{gridInqYsize} returns the number of values of a Y-axis.
int gridInqYsize(int gridID)
{
grid_t *gridptr = grid_to_pointer(gridID);
return gridptr->y.size;
}
......@@ -1324,7 +1321,6 @@ of a Gaussian grid.
int gridInqNP(int gridID)
{
grid_t *gridptr = grid_to_pointer(gridID);
return gridptr->np;
}
......@@ -2895,7 +2891,6 @@ void gridDefNvertex(int gridID, int nvertex)
int gridInqNvertex(int gridID)
{
grid_t *gridptr = grid_to_pointer(gridID);
return gridptr->nvertex;
}
......
......@@ -35,6 +35,8 @@ void cdfDefTime(stream_t* streamptr);
void cdf_scale_add(size_t size, double *data, double addoffset, double scalefactor);
int cdfDefDatatype(int datatype, int filetype);
#endif
/*
* Local Variables:
......
......@@ -2129,7 +2129,8 @@ bool cdf_read_xcoord(struct cdfLazyGrid *restrict lazyGrid, ncdim_t *ncdims, ncv
return true;
}
if ( axisvar->xtype == NC_FLOAT ) grid->prec = CDI_DATATYPE_FLT32;
int prec = cdfInqDatatype(axisvar->xtype, axisvar->lunsigned);
if ( prec != -1 ) grid->prec = prec;
cdf_load_vals(size, ndims, xvarid, axisvar, &grid->x.vals, &lazyGrid->xValsGet, ntdims, start, count);
......@@ -2180,10 +2181,10 @@ bool cdf_read_ycoord(struct cdfLazyGrid *restrict lazyGrid, ncdim_t *ncdims, ncv
return true;
}
if ( axisvar->xtype == NC_FLOAT ) grid->prec = CDI_DATATYPE_FLT32;
int prec = cdfInqDatatype(axisvar->xtype, axisvar->lunsigned);
if ( prec != -1 ) grid->prec = prec;
cdf_load_vals(size, ndims, yvarid, axisvar, &grid->y.vals, &lazyGrid->yValsGet,
ntdims, start, count);
cdf_load_vals(size, ndims, yvarid, axisvar, &grid->y.vals, &lazyGrid->yValsGet, ntdims, start, count);
cdf_copy_axis_attr(axisvar, &grid->y);
......
......@@ -655,7 +655,8 @@ cdfDefAxisCommon(stream_t *streamptr, int gridID, int gridindex, int ndims,
int nvdimID = UNDEFID;
int fileID = streamptr->fileID;
size_t dimlen = (size_t)gridAxisInq->axisSize(gridID);
nc_type xtype = (gridInqPrec(gridID) == CDI_DATATYPE_FLT32) ? NC_FLOAT : NC_DOUBLE;
nc_type xtype = (nc_type)cdfDefDatatype(gridInqPrec(gridID), streamptr->filetype);
ncgrid_t *ncgrid = streamptr->ncgrid;
for ( int index = 0; index < gridindex; ++index )
......@@ -831,7 +832,7 @@ void cdfDefCurvilinear(stream_t *streamptr, int gridID, int gridindex)
int ydimID = UNDEFID;
int ncxvarid = UNDEFID, ncyvarid = UNDEFID;
int ncbxvarid = UNDEFID, ncbyvarid = UNDEFID, ncavarid = UNDEFID;
nc_type xtype = (gridInqPrec(gridID) == CDI_DATATYPE_FLT32) ? NC_FLOAT : NC_DOUBLE;
nc_type xtype = (nc_type)cdfDefDatatype(gridInqPrec(gridID), streamptr->filetype);
ncgrid_t *ncgrid = streamptr->ncgrid;
int fileID = streamptr->fileID;
......@@ -1172,7 +1173,7 @@ void cdfDefUnstructured(stream_t *streamptr, int gridID, int gridindex)
int ncxvarid = UNDEFID, ncyvarid = UNDEFID;
int ncbxvarid = UNDEFID, ncbyvarid = UNDEFID, ncavarid = UNDEFID;
int nvdimID = UNDEFID;
nc_type xtype = (gridInqPrec(gridID) == CDI_DATATYPE_FLT32) ? NC_FLOAT : NC_DOUBLE;
nc_type xtype = (nc_type)cdfDefDatatype(gridInqPrec(gridID), streamptr->filetype);
ncgrid_t *ncgrid = streamptr->ncgrid;
int fileID = streamptr->fileID;
......
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