mirror of https://github.com/ecmwf/eccodes.git
Refactoring and preparation for GRIB-70: take into account chemical and aerosol PDTNs
This commit is contained in:
parent
7e34d69386
commit
966ea699a8
|
@ -150,7 +150,6 @@ static void init(grib_accessor* a,const long l, grib_arguments* c)
|
|||
self->stream = grib_arguments_get_name(a->parent->h,c,n++);
|
||||
self->stepType = grib_arguments_get_name(a->parent->h,c,n++);
|
||||
self->derivedForecast = grib_arguments_get_name(a->parent->h,c,n++);
|
||||
|
||||
}
|
||||
|
||||
static int unpack_long(grib_accessor* a, long* val, size_t *len)
|
||||
|
@ -161,13 +160,12 @@ static int unpack_long (grib_accessor* a, long* val, size_t *len)
|
|||
grib_get_long(a->parent->h, self->productDefinitionTemplateNumber,&productDefinitionTemplateNumber);
|
||||
|
||||
*val=0;
|
||||
if (productDefinitionTemplateNumber==1 || productDefinitionTemplateNumber==11)
|
||||
if (is_productDefinitionTemplateNumber_EPS(productDefinitionTemplateNumber))
|
||||
*val=1;
|
||||
|
||||
return GRIB_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static int pack_long(grib_accessor* a, const long* val, size_t *len)
|
||||
{
|
||||
grib_accessor_g2_eps* self = (grib_accessor_g2_eps*)a;
|
||||
|
@ -189,7 +187,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t *len)
|
|||
grib_get_string(a->parent->h, self->stepType,stepType,&slen);
|
||||
if (!strcmp(stepType,"instant")) isInstant=1;
|
||||
|
||||
/* eps or enda or elda or ewla */
|
||||
/* eps or stream=(enda or elda or ewla) */
|
||||
if ( eps || stream==1030 || stream==1249 || stream==1250 ) {
|
||||
if (isInstant) {
|
||||
/* type=em || type=es */
|
||||
|
@ -235,4 +233,3 @@ static long value_count(grib_accessor* a)
|
|||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -216,7 +216,8 @@ static int unpack_string (grib_accessor* a, char* val, size_t *len)
|
|||
|
||||
}
|
||||
|
||||
static int extra_set(grib_accessor* a,long val) {
|
||||
static int extra_set(grib_accessor* a,long val)
|
||||
{
|
||||
int ret=0;
|
||||
grib_accessor_g2_mars_labeling* self = (grib_accessor_g2_mars_labeling*)a;
|
||||
char stepType[30]={0,};
|
||||
|
@ -441,15 +442,14 @@ static int pack_string(grib_accessor* a, const char* val, size_t *len)
|
|||
}
|
||||
|
||||
ret=grib_set_string(a->parent->h, key,val,len);
|
||||
if (ret) return ret;
|
||||
if (ret) return ret; /* failed */
|
||||
|
||||
ret=grib_get_long(a->parent->h, key,&lval);
|
||||
if (ret) return ret;
|
||||
if (ret) return ret; /* failed */
|
||||
|
||||
return extra_set(a,lval);
|
||||
}
|
||||
|
||||
|
||||
static int pack_long(grib_accessor* a, const long* val, size_t *len)
|
||||
{
|
||||
grib_accessor_g2_mars_labeling* self = (grib_accessor_g2_mars_labeling*)a;
|
||||
|
@ -474,7 +474,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t *len)
|
|||
}
|
||||
|
||||
ret=grib_set_long(a->parent->h, key,*val);
|
||||
if (ret) return ret;
|
||||
if (ret) return ret; /* failed */
|
||||
|
||||
return extra_set(a,*val);
|
||||
}
|
||||
|
|
|
@ -204,7 +204,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t *len)
|
|||
if (!strcmp(stepType,"instant")) isInstant=1;
|
||||
grib_get_long(a->parent->h, self->grib2LocalSectionNumber,&grib2LocalSectionNumber);
|
||||
|
||||
if (productDefinitionTemplateNumber==1 || productDefinitionTemplateNumber==11)
|
||||
if (is_productDefinitionTemplateNumber_EPS(productDefinitionTemplateNumber))
|
||||
eps=1;
|
||||
|
||||
switch (localDefinitionNumber) {
|
||||
|
@ -306,4 +306,3 @@ static long value_count(grib_accessor* a)
|
|||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -141,7 +141,6 @@ static void init(grib_accessor* a,const long l, grib_arguments* c)
|
|||
|
||||
self->productDefinitionTemplateNumber = grib_arguments_get_name(a->parent->h,c,n++);
|
||||
self->instant = grib_arguments_get_long(a->parent->h,c,n++);
|
||||
|
||||
}
|
||||
|
||||
static int unpack_long(grib_accessor* a, long* val, size_t *len)
|
||||
|
@ -150,7 +149,6 @@ static int unpack_long (grib_accessor* a, long* val, size_t *len)
|
|||
return GRIB_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static int pack_long(grib_accessor* a, const long* val, size_t* len)
|
||||
{
|
||||
grib_accessor_select_step_template* self = (grib_accessor_select_step_template*)a;
|
||||
|
@ -160,6 +158,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t *len)
|
|||
grib_get_long(a->parent->h, self->productDefinitionTemplateNumber,&productDefinitionTemplateNumber);
|
||||
|
||||
if (self->instant) {
|
||||
/* Going from continuous or non-continuous interval to a point-in-time (instantaneous) */
|
||||
switch (productDefinitionTemplateNumber) {
|
||||
case 8:
|
||||
productDefinitionTemplateNumberNew=0;
|
||||
|
@ -182,6 +181,18 @@ static int pack_long(grib_accessor* a, const long* val, size_t *len)
|
|||
case 14:
|
||||
productDefinitionTemplateNumberNew=4;
|
||||
break;
|
||||
case 42: /* non-EPS chemical */
|
||||
productDefinitionTemplateNumberNew=40;
|
||||
break;
|
||||
case 43: /* EPS chemical */
|
||||
productDefinitionTemplateNumberNew=41;
|
||||
break;
|
||||
case 46: /* non-EPS aerosol */
|
||||
productDefinitionTemplateNumberNew=44;
|
||||
break;
|
||||
case 47: /* EPS aerosol */
|
||||
productDefinitionTemplateNumberNew=45;
|
||||
break;
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
|
@ -198,6 +209,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t *len)
|
|||
break;
|
||||
}
|
||||
} else {
|
||||
/* Going from point-in-time (instantaneous) to continuous or non-continuous interval */
|
||||
switch (productDefinitionTemplateNumber) {
|
||||
case 0:
|
||||
productDefinitionTemplateNumberNew=8;
|
||||
|
@ -220,6 +232,18 @@ static int pack_long(grib_accessor* a, const long* val, size_t *len)
|
|||
case 6:
|
||||
productDefinitionTemplateNumberNew=10;
|
||||
break;
|
||||
case 40: /* non-EPS chemical */
|
||||
productDefinitionTemplateNumberNew=42;
|
||||
break;
|
||||
case 41: /* EPS chemical */
|
||||
productDefinitionTemplateNumberNew=43;
|
||||
break;
|
||||
case 44: /* non-EPS aerosol */
|
||||
productDefinitionTemplateNumberNew=46;
|
||||
break;
|
||||
case 45: /* EPS aerosol */
|
||||
productDefinitionTemplateNumberNew=47;
|
||||
break;
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
|
@ -234,7 +258,6 @@ static int pack_long(grib_accessor* a, const long* val, size_t *len)
|
|||
productDefinitionTemplateNumberNew=productDefinitionTemplateNumber;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (productDefinitionTemplateNumber != productDefinitionTemplateNumberNew)
|
||||
|
@ -247,4 +270,3 @@ static long value_count(grib_accessor* a)
|
|||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue