Commit be965313 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

gribapiDefSteptype: check stepType status.

parent 25f5a4ea
......@@ -340,6 +340,7 @@ int gribapiTimeIsFC(grib_handle *gh)
return sigofrtime != 3;
}
struct cdiGribAPI_ts_str_map_elem cdiGribAPI_ts_str_map[] = {
// clang-format off
[TSTEP_INSTANT] = { 0, "instant" },
......@@ -353,7 +354,7 @@ struct cdiGribAPI_ts_str_map_elem cdiGribAPI_ts_str_map[] = {
[TSTEP_COV] = { 8, "cov" },
[TSTEP_RATIO] = { 8, "ratio" },
[TSTEP_SUM] = { 8, "sum" },
{ 0, "" }
{ 0, "" }
// clang-format on
};
......
......@@ -1721,7 +1721,7 @@ int gribapiDefSteptype(int editionNumber, grib_handle *gh, int productDefinition
const char *stepType = "instant";
long proDefTempNum = 0;
if ( tsteptype >= TSTEP_INSTANT && tsteptype <= TSTEP_RATIO )
if ( tsteptype >= TSTEP_INSTANT && tsteptype <= TSTEP_SUM )
{
stepType = cdiGribAPI_ts_str_map[tsteptype].sname;
proDefTempNum = cdiGribAPI_ts_str_map[tsteptype].productionTemplate;
......@@ -1738,7 +1738,8 @@ int gribapiDefSteptype(int editionNumber, grib_handle *gh, int productDefinition
{
if ( editionNumber > 1 ) GRIB_CHECK(my_grib_set_long(gh, "productDefinitionTemplateNumber", proDefTempNum), 0);
size_t len = strlen(stepType);
GRIB_CHECK(my_grib_set_string(gh, "stepType", stepType, &len), 0);
int status = my_grib_set_string(gh, "stepType", stepType, &len);
if (status != 0) GRIB_CHECK(my_grib_set_long(gh, "productDefinitionTemplateNumber", 0), 0);
}
return (int)proDefTempNum;
......
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