Commit 2a8e3fe6 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

gribapiDefParam: use cfName to find parameter ids

parent 46d6fc5d
......@@ -5,6 +5,7 @@
2015-04-22 Uwe Schulzweida
* gribapiDefParam: use cfName to find parameter ids
* cgribex rotated grids: added support for parameter >angle< (bug fix)
* netcdf rotated grids: bug fix for negative angles
......
......@@ -1566,22 +1566,34 @@ void gribapiDefModel(grib_handle *gh, int vlistID, int varID)
}
static
void gribapiDefParam(int editionNumber, grib_handle *gh, int param, const char *name)
void gribapiDefParam(int editionNumber, grib_handle *gh, int param, const char *name, const char *stdname)
{
int pdis, pcat, pnum;
bool ldefined = false;
int pdis, pcat, pnum;
cdiDecodeParam(param, &pnum, &pcat, &pdis);
if ( pnum < 0 )
{
size_t len;
int status;
len = strlen(stdname);
if ( len )
{
int status = my_grib_set_string(gh, "cfName", stdname, &len);
if ( status == 0 ) ldefined = true;
else Warning("grib_api: No match for cfName=%s", stdname);
}
if ( ldefined == false )
{
len = strlen(name);
status = my_grib_set_string(gh, "shortName", name, &len);
if ( status != 0 )
Warning("grib_api: No match for shortName=%s", name);
int status = my_grib_set_string(gh, "shortName", name, &len);
if ( status == 0 ) ldefined = true;
else Warning("grib_api: No match for shortName=%s", name);
}
else
}
if ( ldefined == false )
{
if ( pnum < 0 ) pnum = -pnum;
......@@ -2549,8 +2561,6 @@ size_t gribapiEncode(int varID, int levelID, int vlistID, int gridID, int zaxisI
{
size_t recsize = 0;
void *dummy = NULL;
int datatype;
int param;
int lieee = FALSE;
/* int ensID, ensCount, forecast_type; *//* Ensemble Data */
int typeOfGeneratingProcess;
......@@ -2558,15 +2568,17 @@ size_t gribapiEncode(int varID, int levelID, int vlistID, int gridID, int zaxisI
long bitsPerValue;
long editionNumber = 2;
char name[256];
char stdname[256];
gribContainer_t *gc = (gribContainer_t *) gribContainer;
// extern unsigned char _grib_template_GRIB2[];
param = vlistInqVarParam(vlistID, varID);
datatype = vlistInqVarDatatype(vlistID, varID);
int param = vlistInqVarParam(vlistID, varID);
int datatype = vlistInqVarDatatype(vlistID, varID);
typeOfGeneratingProcess = vlistInqVarTypeOfGeneratingProcess(vlistID, varID);
productDefinitionTemplate = vlistInqVarProductDefinitionTemplate(vlistID, varID);
vlistInqVarName(vlistID, varID, name);
vlistInqVarStdname(vlistID, varID, stdname);
#if defined(GRIBAPIENCODETEST)
grib_handle *gh = (grib_handle *) gribHandleNew(editionNumber);
......@@ -2595,7 +2607,7 @@ size_t gribapiEncode(int varID, int levelID, int vlistID, int gridID, int zaxisI
if ( ! gc->init ) gribapiDefInstitut(gh, vlistID, varID);
if ( ! gc->init ) gribapiDefModel(gh, vlistID, varID);
if ( ! gc->init ) gribapiDefParam(editionNumber, gh, param, name);
if ( ! gc->init ) gribapiDefParam(editionNumber, gh, param, name, stdname);
if ( editionNumber == 2 && (datatype == DATATYPE_FLT32 || datatype == DATATYPE_FLT64) ) lieee = TRUE;
......
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