Commit 90e520b8 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Added support for CDI_KEY_UVRELATIVETOGRID.

parent 15ba64ee
......@@ -802,6 +802,7 @@ size_t gridInqYCvals(int gridID, char *ycvals[]);
#define CDI_KEY_GRIB2LOCALSECTIONNUMBER 818 // GRIB2 grib2LocalSectionNumber
#define CDI_KEY_SECTION2PADDINGLENGTH 819 // GRIB2 length of section2Padding
#define CDI_KEY_SECTION2PADDING 820 // GRIB2 section2Padding
#define CDI_KEY_UVRELATIVETOGRID 821 // GRIB uvRelativeToGrid
// cdiDefKeyInt: Define an integer value from a key of a CDI variable
int cdiDefKeyInt(int cdiID, int varID, int key, int value);
......
......@@ -764,8 +764,9 @@ void gribapiGetGridGeneric(grib_handle *gh, grid_t *grid, size_t numberOfPoints)
}
//TODO: Simplify by use of the convenience functions (gribGetLong(), gribGetLongDefault(), etc.).
void gribapiGetGrid(grib_handle *gh, grid_t *grid)
bool gribapiGetGrid(grib_handle *gh, grid_t *grid)
{
bool uvRelativeToGrid = false;
const long editionNumber = gribEditionNumber(gh);
int gridtype = gribapiGetGridType(gh);
int projtype = (gridtype == GRID_PROJECTION && gribapiGetIsRotated(gh)) ? CDI_PROJ_RLL : CDI_UNDEFID;
......@@ -834,6 +835,7 @@ void gribapiGetGrid(grib_handle *gh, grid_t *grid)
GRIB_CHECK(grib_get_long(gh, "uvRelativeToGrid", &temp), 0);
assert(temp == 0 || temp == 1);
grid->uvRelativeToGrid = (bool)temp;
uvRelativeToGrid = (bool)temp;
}
if ( gridtype == GRID_GAUSSIAN || gridtype == GRID_LONLAT || gridtype == GRID_PROJECTION )
......@@ -863,14 +865,16 @@ void gribapiGetGrid(grib_handle *gh, grid_t *grid)
Message("(param,ltype,level) = (%3d,%3d,%4d); Scanning mode = %02d -> bits:(%1d.%1d.%1d)*32; uvRelativeToGrid = %02d",\
(int)paramId, (int)levelTypeId, (int)levelId,
grid->scanningMode,grid->jPointsAreConsecutive,
grid->jScansPositively,grid->iScansNegatively,
grid->uvRelativeToGrid);
grid->jScansPositively, grid->iScansNegatively,
uvRelativeToGrid);
}
#endif //HIRLAM_EXTENSIONS
}
grid->type = gridtype;
grid->projtype = projtype;
return uvRelativeToGrid;
}
#endif
/*
......
......@@ -31,7 +31,7 @@ int gribapiGetTsteptype(grib_handle *gh);
int gribGetDatatype(grib_handle* gribHandle);
int gribapiGetParam(grib_handle *gh);
int gribapiGetGridType(grib_handle *gh);
void gribapiGetGrid(grib_handle *gh, grid_t *grid);
bool gribapiGetGrid(grib_handle *gh, grid_t *grid);
size_t gribapiGetGridsize(grib_handle *gh);
......
......@@ -240,8 +240,9 @@ int cgribexGetTsteptype(int timerange)
}
static
void cgribexGetGrid(stream_t *streamptr, int *isec2, int *isec4, grid_t *grid, int iret)
bool cgribexGetGrid(stream_t *streamptr, int *isec2, int *isec4, grid_t *grid, int iret)
{
bool uvRelativeToGrid = false;
bool compyinc = true;
int gridtype = cgribexGetGridType(isec2);
int projtype = (gridtype == GRID_PROJECTION && cgribexGetIsRotated(isec2)) ? CDI_PROJ_RLL : CDI_UNDEFID;
......@@ -268,8 +269,7 @@ void cgribexGetGrid(stream_t *streamptr, int *isec2, int *isec4, grid_t *grid, i
if ( gridtype == GRID_LONLAT || gridtype == GRID_GAUSSIAN || projtype == CDI_PROJ_RLL )
{
const bool ijDirectionIncrementGiven = gribbyte_get_bit(ISEC2_ResFlag, 1);
const bool uvRelativeToGrid = gribbyte_get_bit(ISEC2_ResFlag, 5);
if ( uvRelativeToGrid ) grid->uvRelativeToGrid = 1;
uvRelativeToGrid = gribbyte_get_bit(ISEC2_ResFlag, 5);
const size_t nvalues = (size_t) ISEC4_NumValues;
const size_t nlon = (size_t) ISEC2_NumLon;
......@@ -352,8 +352,7 @@ void cgribexGetGrid(stream_t *streamptr, int *isec2, int *isec4, grid_t *grid, i
else if ( gridtype == GRID_GAUSSIAN_REDUCED )
{
const bool ijDirectionIncrementGiven = gribbyte_get_bit(ISEC2_ResFlag, 1);
const bool uvRelativeToGrid = gribbyte_get_bit(ISEC2_ResFlag, 5);
if ( uvRelativeToGrid ) grid->uvRelativeToGrid = 1;
uvRelativeToGrid = gribbyte_get_bit(ISEC2_ResFlag, 5);
grid->np = ISEC2_NumPar;
grid->size = (size_t)ISEC4_NumValues;
grid->rowlon = ISEC2_RowLonPtr;
......@@ -394,8 +393,7 @@ void cgribexGetGrid(stream_t *streamptr, int *isec2, int *isec4, grid_t *grid, i
}
else if ( projtype == CDI_PROJ_LCC )
{
const bool uvRelativeToGrid = gribbyte_get_bit(ISEC2_ResFlag, 5);
if ( uvRelativeToGrid ) grid->uvRelativeToGrid = 1;
uvRelativeToGrid = gribbyte_get_bit(ISEC2_ResFlag, 5);
const size_t nvalues = (size_t) ISEC4_NumValues;
const size_t nlon = (size_t) ISEC2_NumLon;
......@@ -443,6 +441,10 @@ void cgribexGetGrid(stream_t *streamptr, int *isec2, int *isec4, grid_t *grid, i
grid->type = gridtype;
grid->projtype = projtype;
if ( uvRelativeToGrid ) grid->uvRelativeToGrid = 1;
return uvRelativeToGrid;
}
static
......@@ -466,6 +468,8 @@ void cgribexAddRecord(stream_t *streamptr, cgribexrec_t *cgribexp, int param, si
double *fsec3 = cgribexp->fsec3;
int datatype = (ISEC4_NumBits > 0 && ISEC4_NumBits <= 32) ? ISEC4_NumBits : CDI_DATATYPE_PACK;
if ( datatype > 32 ) datatype = CDI_DATATYPE_PACK32;
if ( datatype < 0 ) datatype = CDI_DATATYPE_PACK;
int varID;
int levelID = 0;
......@@ -492,7 +496,7 @@ void cgribexAddRecord(stream_t *streamptr, cgribexrec_t *cgribexp, int param, si
record->tsteptype = (short)tsteptype;
grid_t *gridptr = (grid_t*) Malloc(sizeof(*gridptr));
cgribexGetGrid(streamptr, isec2, isec4, gridptr, iret);
const bool uvRelativeToGrid = cgribexGetGrid(streamptr, isec2, isec4, gridptr, iret);
struct addIfNewRes gridAdded = cdiVlistAddGridIfNew(vlistID, gridptr, 0);
int gridID = gridAdded.Id;
......@@ -514,9 +518,9 @@ void cgribexAddRecord(stream_t *streamptr, cgribexrec_t *cgribexp, int param, si
}
else if ( gridptr->projtype == CDI_PROJ_LCC )
{
double a = 6367470., rf = 0;
bool earthIsOblate = gribbyte_get_bit(ISEC2_ResFlag, 2);
if ( earthIsOblate ) { a = 6378160.; rf = 297.0; }
const bool earthIsOblate = gribbyte_get_bit(ISEC2_ResFlag, 2);
const double a = earthIsOblate ? 6378160. : 6367470.;
const double rf = earthIsOblate ? 297.0 : 0;
const double xval_0 = ISEC2_FirstLon * 0.001;
const double yval_0 = ISEC2_FirstLat * 0.001;
const double lon_0 = ISEC2_Lambert_Lov * 0.001;
......@@ -552,9 +556,6 @@ void cgribexAddRecord(stream_t *streamptr, cgribexrec_t *cgribexp, int param, si
const bool lbounds = cgribexGetZaxisHasBounds(leveltype);
if ( datatype > 32 ) datatype = CDI_DATATYPE_PACK32;
if ( datatype < 0 ) datatype = CDI_DATATYPE_PACK;
varAddRecord(recID, param, gridID, zaxistype, lbounds, level1, level2, 0, 0,
datatype, &varID, &levelID, tsteptype, numavg, leveltype, -1,
NULL, NULL, NULL, NULL, NULL, NULL, 0);
......@@ -564,6 +565,8 @@ void cgribexAddRecord(stream_t *streamptr, cgribexrec_t *cgribexp, int param, si
varDefCompType(varID, comptype);
if ( uvRelativeToGrid ) varDefKeyInt(varID, CDI_KEY_UVRELATIVETOGRID, 1);
if ( ISEC1_LocalFLag )
{
if ( ISEC1_CenterID == 78 && isec1[36] == 253 ) // DWD local extension
......@@ -1587,7 +1590,7 @@ void cgribexDefTime(int *isec1, int vdate, int vtime, int tsteptype, int numavg,
}
static
void cgribexDefGridRegular(int *isec2, double *fsec2, int gridID, int gridtype, bool gridIsRotated, bool gridIsCurvilinear)
void cgribexDefGridRegular(int *isec2, double *fsec2, int gridID, int gridtype, bool gridIsRotated, bool gridIsCurvilinear, int uvRelativeToGrid)
{
if ( gridtype == GRID_GAUSSIAN || gridtype == GRID_GAUSSIAN_REDUCED )
ISEC2_GridType = GRIB1_GTYPE_GAUSSIAN;
......@@ -1663,7 +1666,7 @@ void cgribexDefGridRegular(int *isec2, double *fsec2, int gridID, int gridtype,
ISEC2_ResFlag = 0;
if ( ISEC2_LatIncr && ISEC2_LonIncr ) gribbyte_set_bit(&ISEC2_ResFlag, 1);
if ( gridInqUvRelativeToGrid(gridID) ) gribbyte_set_bit(&ISEC2_ResFlag, 5);
if ( uvRelativeToGrid > 0 ) gribbyte_set_bit(&ISEC2_ResFlag, 5);
if ( gridIsRotated )
{
......@@ -1682,7 +1685,7 @@ void cgribexDefGridRegular(int *isec2, double *fsec2, int gridID, int gridtype,
}
static
void cgribexDefGridLambert(int *isec2, int gridID)
void cgribexDefGridLambert(int *isec2, int gridID, int uvRelativeToGrid)
{
const int xsize = (int)gridInqXsize(gridID);
const int ysize = (int)gridInqYsize(gridID);
......@@ -1715,7 +1718,7 @@ void cgribexDefGridLambert(int *isec2, int gridID)
ISEC2_ResFlag = 0;
if ( ISEC2_Lambert_dx && ISEC2_Lambert_dy ) gribbyte_set_bit(&ISEC2_ResFlag, 1);
if ( earthIsOblate ) gribbyte_set_bit(&ISEC2_ResFlag, 2);
if ( gridInqUvRelativeToGrid(gridID) ) gribbyte_set_bit(&ISEC2_ResFlag, 5);
if ( uvRelativeToGrid > 0 ) gribbyte_set_bit(&ISEC2_ResFlag, 5);
ISEC2_ScanFlag = 0;
gribbyte_set_bit(&ISEC2_ScanFlag, 2); // South -> North
......@@ -1764,7 +1767,7 @@ void cgribexDefGridGME(int *isec2, int gridID)
}
static
void cgribexDefGrid(int *isec1, int *isec2, double *fsec2, int *isec4, int gridID)
void cgribexDefGrid(int *isec1, int *isec2, double *fsec2, int *isec4, int gridID, int uvRelativeToGrid)
{
memset(isec2, 0, 16*sizeof(int));
ISEC1_Sec2Or3Flag = 128;
......@@ -1784,12 +1787,12 @@ void cgribexDefGrid(int *isec1, int *isec2, double *fsec2, int *isec4, int gridI
case GRID_GAUSSIAN_REDUCED:
case GRID_TRAJECTORY:
{
cgribexDefGridRegular(isec2, fsec2, gridID, gridtype, gridIsRotated, gridIsCurvilinear);
cgribexDefGridRegular(isec2, fsec2, gridID, gridtype, gridIsRotated, gridIsCurvilinear, uvRelativeToGrid);
break;
}
case CDI_PROJ_LCC:
{
cgribexDefGridLambert(isec2, gridID);
cgribexDefGridLambert(isec2, gridID, uvRelativeToGrid);
break;
}
case GRID_SPECTRAL:
......@@ -2074,9 +2077,12 @@ size_t cgribexEncode(int memtype, int varID, int levelID, int vlistID, int gridI
const int datatype = vlistInqVarDatatype(vlistID, varID);
int uvRelativeToGrid = -1;
cdiInqKeyInt(vlistID, varID, CDI_KEY_UVRELATIVETOGRID, &uvRelativeToGrid);
cgribexDefParam(isec1, param);
cgribexDefTime(isec1, vdate, vtime, tsteptype, numavg, vlistInqTaxis(vlistID));
cgribexDefGrid(isec1, isec2, fsec2, isec4, gridID);
cgribexDefGrid(isec1, isec2, fsec2, isec4, gridID, uvRelativeToGrid);
cgribexDefLevel(isec1, isec2, fsec2, zaxisID, levelID);
cgribexDefEnsembleVar(isec1, vlistID, varID);
......
......@@ -595,12 +595,12 @@ void gribapiAddRecord(stream_t *streamptr, int param, grib_handle *gh,
{
char stdname[CDI_MAX_NAME], longname[CDI_MAX_NAME], units[CDI_MAX_NAME];
int vlistID = streamptr->vlistID;
int tsID = streamptr->curTsID;
int recID = recordNewEntry(streamptr, tsID);
const int vlistID = streamptr->vlistID;
const int tsID = streamptr->curTsID;
const int recID = recordNewEntry(streamptr, tsID);
record_t *record = &streamptr->tsteps[tsID].records[recID];
int tsteptype = gribapiGetTsteptype(gh);
const int tsteptype = gribapiGetTsteptype(gh);
// numavg = ISEC1_AvgNum;
int numavg = 0;
......@@ -622,16 +622,16 @@ void gribapiAddRecord(stream_t *streamptr, int param, grib_handle *gh,
record->varname[sizeof(record->varname) - 1] = 0;
grid_t *grid = (grid_t *)Malloc(sizeof(*grid));
gribapiGetGrid(gh, grid);
const bool uvRelativeToGrid = gribapiGetGrid(gh, grid);
struct addIfNewRes gridAdded = cdiVlistAddGridIfNew(vlistID, grid, 0);
int gridID = gridAdded.Id;
const int gridID = gridAdded.Id;
if ( !gridAdded.isNew ) Free(grid);
else if ( grid->projtype == CDI_PROJ_RLL ) gribapiDefProjRLL(gh, gridID);
else if ( grid->projtype == CDI_PROJ_LCC ) gribapiDefProjLCC(gh, gridID);
else if ( grid->projtype == CDI_PROJ_STERE ) gribapiDefProjSTERE(gh, gridID);
int zaxistype = gribapiGetZaxisType(gribEditionNumber(gh), leveltype1);
const int zaxistype = gribapiGetZaxisType(gribEditionNumber(gh), leveltype1);
switch (zaxistype)
{
......@@ -641,7 +641,7 @@ void gribapiAddRecord(stream_t *streamptr, int param, grib_handle *gh,
long lpar;
GRIB_CHECK(grib_get_long(gh, "NV", &lpar), 0);
/* FIXME: assert(lpar >= 0) */
size_t vctsize = (size_t)lpar;
const size_t vctsize = (size_t)lpar;
if ( vctsize > 0 )
{
double *vctptr = (double *) Malloc(vctsize*sizeof(double));
......@@ -702,6 +702,8 @@ void gribapiAddRecord(stream_t *streamptr, int param, grib_handle *gh,
varDefCompType(varID, comptype);
if ( uvRelativeToGrid ) varDefKeyInt(varID, CDI_KEY_UVRELATIVETOGRID, 1);
gribapiGetKeys(gh, varID);
if (lread_additional_keys)
......@@ -1883,7 +1885,7 @@ void gribapiDefTime(int editionNumber, int productDefinitionTemplate, int typeOf
}
static
void gribapiDefGridRegular(grib_handle *gh, int gridID, int gridtype, bool gridIsRotated, bool gridIsCurvilinear)
void gribapiDefGridRegular(grib_handle *gh, int gridID, int gridtype, bool gridIsRotated, bool gridIsCurvilinear, int uvRelativeToGrid)
{
const char *mesg;
size_t len;
......@@ -1999,12 +2001,11 @@ void gribapiDefGridRegular(grib_handle *gh, int gridID, int gridtype, bool gridI
GRIB_CHECK(my_grib_set_double(gh, "angleOfRotation", angle), 0);
}
long uvRelativeToGrid = gridInqUvRelativeToGrid(gridID);
if ( uvRelativeToGrid ) GRIB_CHECK(my_grib_set_long(gh, "uvRelativeToGrid", uvRelativeToGrid), 0);
if ( uvRelativeToGrid >= 0 ) GRIB_CHECK(my_grib_set_long(gh, "uvRelativeToGrid", uvRelativeToGrid), 0);
}
static
void gribapiDefGridLCC(grib_handle *gh, int editionNumber, int gridID)
void gribapiDefGridLCC(grib_handle *gh, int editionNumber, int gridID, int uvRelativeToGrid)
{
long xsize = (long) gridInqXsize(gridID);
long ysize = (long) gridInqYsize(gridID);
......@@ -2036,8 +2037,7 @@ void gribapiDefGridLCC(grib_handle *gh, int editionNumber, int gridID)
GRIB_CHECK(my_grib_set_double(gh, "Latin2InDegrees", lat_2), 0);
GRIB_CHECK(my_grib_set_long(gh, "projectionCentreFlag", projflag), 0);
long uvRelativeToGrid = gridInqUvRelativeToGrid(gridID);
if ( uvRelativeToGrid ) GRIB_CHECK(my_grib_set_long(gh, "uvRelativeToGrid", uvRelativeToGrid), 0);
if ( uvRelativeToGrid >= 0 ) GRIB_CHECK(my_grib_set_long(gh, "uvRelativeToGrid", uvRelativeToGrid), 0);
long earthIsOblate = (IS_EQUAL(a, 6378160.) && IS_EQUAL(rf, 297.));
if ( earthIsOblate ) GRIB_CHECK(my_grib_set_long(gh, "earthIsOblate", earthIsOblate), 0);
......@@ -2200,7 +2200,7 @@ void gribapiDefPackingType(grib_handle *gh, bool lieee, bool lspectral, bool lco
}
static
void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int comptype, int datatype)
void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int comptype, int datatype, int uvRelativeToGrid)
{
// bitsPerValue have to be defined first (complex packing)
GRIB_CHECK(my_grib_set_long(gh, "bitsPerValue", (long)grbBitsPerValue(datatype)), 0);
......@@ -2237,12 +2237,12 @@ void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int comptype
case GRID_GAUSSIAN_REDUCED:
case GRID_TRAJECTORY:
{
gribapiDefGridRegular(gh, gridID, gridtype, gridIsRotated, gridIsCurvilinear);
gribapiDefGridRegular(gh, gridID, gridtype, gridIsRotated, gridIsCurvilinear, uvRelativeToGrid);
break;
}
case CDI_PROJ_LCC:
{
gribapiDefGridLCC(gh, editionNumber, gridID);
gribapiDefGridLCC(gh, editionNumber, gridID, uvRelativeToGrid);
break;
}
case CDI_PROJ_STERE:
......@@ -2633,21 +2633,6 @@ void gribapiSetScanningMode(grib_handle *gh, int scanningMode)
}
static
void gribapiSetUvRelativeToGrid(grib_handle *gh, int mode)
{
long uvRelativeToGridMode = mode;
long uvRelativeToGridModeOld;
GRIB_CHECK(grib_get_long(gh, "uvRelativeToGrid", &uvRelativeToGridModeOld), 0);
if (cdiDebugExt>=30)
printf("gribapiSetUvRelativeToGrid(): uvRelativeToGrid: %02d (old) => %02d (new); \n",(int)uvRelativeToGridModeOld,(int)uvRelativeToGridMode);
GRIB_CHECK(my_grib_set_long(gh, "uvRelativeToGrid", uvRelativeToGridMode), 0);
}
/*
TABLE 8. SCANNING MODE FLAG
......@@ -3003,11 +2988,6 @@ void gribapiSetExtMode(grib_handle *gh, int gridID, size_t datasize, const doubl
if (cdiDebugExt>=100) Message("Set ModeUvRelativeToGrid =>%d ( note grid has: %d)", cdiGribChangeModeUvRelativeToGrid.mode, gridInqUvRelativeToGrid(gridID));
GRIB_CHECK(my_grib_set_long(gh, "uvRelativeToGrid", (long) cdiGribChangeModeUvRelativeToGrid.mode), 0);
}
else
{
if (cdiDebugExt>=100) Message("Set ModeUvRelativeToGrid =>%d based on used grid", gridInqUvRelativeToGrid(gridID));
gribapiSetUvRelativeToGrid(gh, gridInqUvRelativeToGrid(gridID));
}
}
}
......@@ -3032,6 +3012,9 @@ size_t gribapiEncode(int varID, int levelID, int vlistID, int gridID, int zaxisI
int productDefinitionTemplate = 0;
cdiInqKeyInt(vlistID, varID, CDI_KEY_PRODUCTDEFINITIONTEMPLATE, &productDefinitionTemplate);
int uvRelativeToGrid = -1;
cdiInqKeyInt(vlistID, varID, CDI_KEY_UVRELATIVETOGRID, &uvRelativeToGrid);
char name[256];
char stdname[256];
vlistInqVarName(vlistID, varID, name);
......@@ -3127,7 +3110,7 @@ size_t gribapiEncode(int varID, int levelID, int vlistID, int gridID, int zaxisI
}
}
if ( ! gc->init ) gribapiDefGrid((int)editionNumber, gh, gridID, comptype, datatype);
if ( ! gc->init ) gribapiDefGrid((int)editionNumber, gh, gridID, comptype, datatype, uvRelativeToGrid);
gribapiDefLevel((int)editionNumber, gh, zaxisID, levelID, gc->init, productDefinitionTemplate);
......
......@@ -560,7 +560,7 @@ int cdi_generate_cmp_varname(const void *s1, const void *s2)
void cdi_generate_vars(stream_t *streamptr)
{
int vlistID = streamptr->vlistID;
const int vlistID = streamptr->vlistID;
int *varids = (int *) Malloc(varTableUsed*sizeof(int));
for ( size_t varID = 0; varID < varTableUsed; varID++ ) varids[varID] = (int)varID;
......@@ -594,29 +594,29 @@ void cdi_generate_vars(stream_t *streamptr)
for ( size_t index = 0; index < varTableUsed; index++ )
{
int varid = varids[index];
const int varid = varids[index];
int gridID = vartable[varid].gridID;
int param = vartable[varid].param;
int ltype1 = vartable[varid].ltype1;
int ltype2 = vartable[varid].ltype2;
const int gridID = vartable[varid].gridID;
const int param = vartable[varid].param;
const int ltype1 = vartable[varid].ltype1;
const int ltype2 = vartable[varid].ltype2;
int zaxistype = vartable[varid].zaxistype;
if ( ltype1 == 0 && zaxistype == ZAXIS_GENERIC && cdiDefaultLeveltype != -1 )
zaxistype = cdiDefaultLeveltype;
int lbounds = vartable[varid].lbounds;
int prec = vartable[varid].prec;
const int lbounds = vartable[varid].lbounds;
const int prec = vartable[varid].prec;
int instID = vartable[varid].instID;
int modelID = vartable[varid].modelID;
int tableID = vartable[varid].tableID;
int tsteptype = vartable[varid].tsteptype;
int timave = vartable[varid].timave;
int comptype = vartable[varid].comptype;
const int tsteptype = vartable[varid].tsteptype;
const int timave = vartable[varid].timave;
const int comptype = vartable[varid].comptype;
double level_sf = 1;
if ( vartable[varid].level_sf != 0 ) level_sf = 1./vartable[varid].level_sf;
/* consistency check: test if all subtypes have the same levels: */
unsigned nlevels = vartable[varid].recordTable[0].nlevels;
const unsigned nlevels = vartable[varid].recordTable[0].nlevels;
for ( int isub = 1; isub < vartable[varid].nsubtypes; isub++ ) {
if ( vartable[varid].recordTable[isub].nlevels != nlevels )
{
......@@ -627,8 +627,8 @@ void cdi_generate_vars(stream_t *streamptr)
Error("zaxis size must not change for same parameter!");
}
leveltable_t *t1 = vartable[varid].recordTable[isub-1].levelTable;
leveltable_t *t2 = vartable[varid].recordTable[isub ].levelTable;
const leveltable_t *t1 = vartable[varid].recordTable[isub-1].levelTable;
const leveltable_t *t2 = vartable[varid].recordTable[isub ].levelTable;
for ( unsigned ilev = 0; ilev < nlevels; ilev++ )
if ((t1[ilev].level1 != t2[ilev].level1) ||
(t1[ilev].level2 != t2[ilev].level2) ||
......@@ -763,7 +763,7 @@ void cdi_generate_vars(stream_t *streamptr)
{
resize_opt_grib_entries(&vlistptr->vars[varID], vlistptr->vars[varID].opt_grib_nentries+1);
vlistptr->vars[varID].opt_grib_nentries += 1;
int idx = vlistptr->vars[varID].opt_grib_nentries-1;
const int idx = vlistptr->vars[varID].opt_grib_nentries-1;
vlistptr->vars[varID].opt_grib_kvpair[idx] = vartable[varid].opt_grib_kvpair[i];
vlistptr->vars[varID].opt_grib_kvpair[idx].keyword = NULL;
......
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