Commit 13725a68 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Added support for GRIB_API keys: mpimType mpimClass mpimUser revStatus.

parent 0c3887fd
......@@ -811,6 +811,11 @@ size_t gridInqYCvals(int gridID, char *ycvals[]);
#define CDI_KEY_PERTURBATIONNUMBER 810 // GRIB2 perturbationNumber
#define CDI_KEY_CENTRE 811 // GRIB2 centre
#define CDI_KEY_SUBCENTRE 812 // GRIB2 subCentre
#define CDI_KEY_MPIMTYPE 813 // GRIB2 mpimType
#define CDI_KEY_MPIMCLASS 814 // GRIB2 mpimClass
#define CDI_KEY_MPIMUSER 815 // GRIB2 mpimUser
#define CDI_KEY_REVSTATUS 816 // GRIB2 revStatus
#define CDI_KEY_REVNUMBER 817 // GRIB2 revNumber
// cdiDefKeyInt: Define a CDI variable integer value from a key
int cdiDefKeyInt(int cdiID, int varID, int key, int value);
......
......@@ -153,7 +153,9 @@ int cdiDefKeyInt(int cdiID, int varID, int key, int value)
// cdiInqKeyInt: Get a CDI variable integer value from a key
int cdiInqKeyInt(int cdiID, int varID, int key, int *value)
{
int status = CDI_NOERR;
int status = -1;
if ( varID != CDI_GLOBAL ) status = cdiInqKeyInt(cdiID, CDI_GLOBAL, key, value);
cdi_keys_t *keysp = cdi_get_keysp(cdiID, varID);
xassert(keysp != NULL);
......@@ -164,6 +166,7 @@ int cdiInqKeyInt(int cdiID, int varID, int key, int *value)
// if ( keyp->indtype == indtype )
{
*value = keyp->v.i;
status = CDI_NOERR;
}
/*
else
......@@ -173,11 +176,6 @@ int cdiInqKeyInt(int cdiID, int varID, int key, int *value)
}
*/
}
else
{
//Warning("Internal problem, key %d not found!", key);
status = -1;
}
return status;
}
......
......@@ -1810,7 +1810,7 @@ int gribapiDefDateTimeRel(int editionNumber, grib_handle *gh, int rdate, int rti
// Product Definition Template Number: defined in GRIB_API file 4.0.table
// point in time products:
if ( (proDefTempNum >= 0 && proDefTempNum <= 7) ||
if ( (proDefTempNum >= 0 && proDefTempNum <= 7) ||
proDefTempNum == 55 || proDefTempNum == 40055 ) // Tile
startStep = endStep;
......@@ -3020,6 +3020,23 @@ size_t gribapiEncode(int varID, int levelID, int vlistID, int gridID, int zaxisI
int shapeOfTheEarth = 0;
cdiInqKeyInt(vlistID, varID, CDI_KEY_SHAPEOFTHEEARTH, &shapeOfTheEarth);
GRIB_CHECK(my_grib_set_long(gh, "shapeOfTheEarth", (long)shapeOfTheEarth), 0);
int mpimType, mpimClass, mpimUser;
if ( cdiInqKeyInt(vlistID, varID, CDI_KEY_MPIMTYPE, &mpimType) == CDI_NOERR &&
cdiInqKeyInt(vlistID, varID, CDI_KEY_MPIMCLASS, &mpimClass) == CDI_NOERR &&
cdiInqKeyInt(vlistID, varID, CDI_KEY_MPIMUSER, &mpimUser) == CDI_NOERR )
{
grib_set_long(gh, "grib2LocalSectionPresent", 1);
grib_set_long(gh, "grib2LocalSectionNumber", 1);
grib_set_long(gh, "mpimType", mpimType);
grib_set_long(gh, "mpimClass", mpimClass);
grib_set_long(gh, "mpimUser", mpimUser);
int revNumber;
if ( cdiInqKeyInt(vlistID, varID, CDI_KEY_REVNUMBER, &revNumber) == CDI_NOERR )
grib_set_long(gh, "revNumber", revNumber);
}
}
if ( ! gc->init ) gribapiDefGrid((int)editionNumber, gh, gridID, comptype, datatype);
......
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