Commit 4c5f31c1 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Consistent test for GRIB2 shortName.

parent 27e5524b
......@@ -4,6 +4,7 @@
2018-01-05 Uwe Schulzweida
* Consistent test for GRIB2 shortName [patch from: Florian Prill]
* Added support for GRIB2 keys shapeOfTheEarth and typeOfProcessedData
* Replaced vlistDefVarProductDefinitionTemplate() by cdiDefKeyInt().
* Replaced vlistDefVarTypeOfGeneratingProcess() by cdiDefKeyInt().
......
......@@ -3,9 +3,6 @@
#include <stdbool.h>
void str_tolower(char *str);
bool str_is_equal(const char *vstr, const char *cstr);
int get_timeunit(size_t len, const char *ptu);
bool is_time_units(const char *timeunits);
......
......@@ -18,7 +18,7 @@
#include "cdf_config.h"
/* dummy use of unused parameters to silence compiler warnings */
#ifndef UNUSED
#ifndef UNUSED
#define UNUSED(x) (void)x
#endif
......@@ -38,6 +38,9 @@ char *strdup(const char *s);
*/
#endif
void str_tolower(char *str);
bool str_is_equal(const char *vstr, const char *cstr);
#ifndef M_PI
#define M_PI 3.14159265358979323846 /* pi */
#endif
......
......@@ -3145,6 +3145,19 @@ size_t gribapiEncode(int varID, int levelID, int vlistID, int gridID, int zaxisI
*gribbuffersize = recsize;
*gribbuffer = Malloc(*gribbuffersize);
if ( ! gc->init )
{
char cdi_name[CDI_MAX_NAME]; cdi_name[0] = 0;
char grb_name[256]; grb_name[0] = 0;
vlistInqVarName(vlistID, varID, cdi_name);
gribapiGetString(gh, "shortName", grb_name, sizeof(grb_name));
str_tolower(cdi_name);
str_tolower(grb_name);
if ( (strlen(cdi_name) != strlen(grb_name)) || !str_is_equal(cdi_name, grb_name) )
Message("*** GRIB2 shortName does not correspond to chosen variable name: \"%s\" (\"%s\").",
grb_name[0]?grb_name:"unknown", cdi_name);
}
/* get a copy of the coded message */
GRIB_CHECK(grib_get_message_copy(gh, *gribbuffer, &recsize), 0);
......
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