Skip to content
Snippets Groups Projects
Commit b6cad026 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

cdfDefDatatype(): changed interface.

parent cb41b907
No related branches found
No related tags found
No related merge requests found
......@@ -39,29 +39,30 @@ void cdfDefVarDeflate(int ncid, int ncvarid, int deflate_level)
}
int cdfDefDatatype(int datatype, int filetype)
int cdfDefDatatype(int datatype, stream_t *streamptr)
{
int xtype = NC_FLOAT;
if ( datatype == CDI_DATATYPE_CPX32 || datatype == CDI_DATATYPE_CPX64 )
Error("CDI library does not support complex numbers with NetCDF!");
if ( filetype == CDI_FILETYPE_NC4 )
if ( streamptr->filetype == CDI_FILETYPE_NC4 )
{
if ( datatype == CDI_DATATYPE_INT8 ) xtype = NC_BYTE;
else if ( datatype == CDI_DATATYPE_INT16 ) xtype = NC_SHORT;
else if ( datatype == CDI_DATATYPE_INT32 ) xtype = NC_INT;
#if defined (HAVE_NETCDF4)
#ifdef HAVE_NETCDF4
else if ( datatype == CDI_DATATYPE_UINT8 ) xtype = NC_UBYTE;
else if ( datatype == CDI_DATATYPE_UINT16 ) xtype = NC_USHORT;
else if ( datatype == CDI_DATATYPE_UINT32 ) xtype = NC_UINT;
else if ( datatype == CDI_DATATYPE_CPX32 || datatype == CDI_DATATYPE_CPX64 )
Error("CDI library does not support complex numbers with NetCDF!");
#else
else if ( datatype == CDI_DATATYPE_UINT8 ) xtype = NC_SHORT;
else if ( datatype == CDI_DATATYPE_UINT16 ) xtype = NC_INT;
else if ( datatype == CDI_DATATYPE_UINT32 ) xtype = NC_INT;
else if ( datatype == CDI_DATATYPE_CPX32 || datatype == CDI_DATATYPE_CPX64 )
Error("CDI library does not support complex numbers with NetCDF4 classic!");
#endif
else if ( datatype == CDI_DATATYPE_FLT64 ) xtype = NC_DOUBLE;
else xtype = NC_FLOAT;
else if ( datatype == CDI_DATATYPE_FLT32 ) xtype = NC_FLOAT;
}
else
{
......@@ -72,7 +73,9 @@ 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 if ( datatype == CDI_DATATYPE_FLT32 ) xtype = NC_FLOAT;
else if ( datatype == CDI_DATATYPE_CPX32 || datatype == CDI_DATATYPE_CPX64 )
Error("CDI library does not support complex numbers with NetCDF classic!");
}
return xtype;
......@@ -90,7 +93,7 @@ void cdfDefVarMissval(stream_t *streamptr, int varID, int dtype, int lcheck)
if ( lcheck && streamptr->ncmode == 2 ) cdf_redef(fileID);
int xtype = cdfDefDatatype(dtype, streamptr->filetype);
int xtype = cdfDefDatatype(dtype, streamptr);
if ( xtype == NC_BYTE && missval > 127 && missval < 256 ) xtype = NC_INT;
......@@ -514,7 +517,7 @@ int cdfDefVar(stream_t *streamptr, int varID)
/* if ( streamptr->ncmode == 2 ) cdf_redef(fileID); */
int dtype = vlistInqVarDatatype(vlistID, varID);
int xtype = cdfDefDatatype(dtype, streamptr->filetype);
int xtype = cdfDefDatatype(dtype, streamptr);
cdf_def_var(fileID, name, (nc_type) xtype, ndims, dims, &ncvarid);
......
......@@ -35,7 +35,7 @@ void cdfDefTime(stream_t* streamptr);
void cdf_scale_add(size_t size, double *data, double addoffset, double scalefactor);
int cdfDefDatatype(int datatype, int filetype);
int cdfDefDatatype(int datatype, stream_t* streamptr);
#endif
/*
......
......@@ -452,7 +452,7 @@ cdfDefAxisCommon(stream_t *streamptr, int gridID, int gridindex, int ndims,
int nvdimID = CDI_UNDEFID;
int fileID = streamptr->fileID;
size_t dimlen = gridAxisInq->axisSize(gridID);
nc_type xtype = (nc_type)cdfDefDatatype(gridInqDatatype(gridID), streamptr->filetype);
nc_type xtype = (nc_type)cdfDefDatatype(gridInqDatatype(gridID), streamptr);
ncgrid_t *ncgrid = streamptr->ncgrid;
......@@ -663,7 +663,7 @@ cdfDefIrregularGridCommon(stream_t *streamptr, int gridID,
size_t nvertex, const char *vdimname_default,
bool setVdimname)
{
nc_type xtype = (nc_type)cdfDefDatatype(gridInqDatatype(gridID), streamptr->filetype);
nc_type xtype = (nc_type)cdfDefDatatype(gridInqDatatype(gridID), streamptr);
int xdimID = CDI_UNDEFID;
int ydimID = CDI_UNDEFID;
int ncxvarid = CDI_UNDEFID, ncyvarid = CDI_UNDEFID, ncavarid = CDI_UNDEFID;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment