Rename data member and fix condition

This commit is contained in:
Shahram Najm 2021-03-17 21:24:40 +00:00
parent 24d973e1bc
commit 01c0cd7586
1 changed files with 20 additions and 19 deletions

View File

@ -19,7 +19,7 @@
IMPLEMENTS = init IMPLEMENTS = init
MEMBERS=const char* productDefinitionTemplateNumber MEMBERS=const char* productDefinitionTemplateNumber
MEMBERS=const char* stepType MEMBERS=const char* stepType
MEMBERS=int distribution MEMBERS=int chemical_type
END_CLASS_DEF END_CLASS_DEF
*/ */
@ -51,7 +51,7 @@ typedef struct grib_accessor_g2_chemical
/* Members defined in g2_chemical */ /* Members defined in g2_chemical */
const char* productDefinitionTemplateNumber; const char* productDefinitionTemplateNumber;
const char* stepType; const char* stepType;
int distribution; int chemical_type;
} grib_accessor_g2_chemical; } grib_accessor_g2_chemical;
extern grib_accessor_class* grib_accessor_class_unsigned; extern grib_accessor_class* grib_accessor_class_unsigned;
@ -146,7 +146,7 @@ static void init(grib_accessor* a, const long l, grib_arguments* c)
self->productDefinitionTemplateNumber = grib_arguments_get_name(hand, c, n++); self->productDefinitionTemplateNumber = grib_arguments_get_name(hand, c, n++);
self->stepType = grib_arguments_get_name(hand, c, n++); self->stepType = grib_arguments_get_name(hand, c, n++);
self->distribution = grib_arguments_get_long(hand, c, n++); self->chemical_type = grib_arguments_get_long(hand, c, n++);
} }
static int unpack_long(grib_accessor* a, long* val, size_t* len) static int unpack_long(grib_accessor* a, long* val, size_t* len)
@ -160,10 +160,10 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
* 1 = atmospheric chemical constituents based on a distribution function * 1 = atmospheric chemical constituents based on a distribution function
* 2 = atmospheric chemical constituents with source or sink * 2 = atmospheric chemical constituents with source or sink
*/ */
Assert(self->distribution == 0 || self->distribution == 1 || self->distribution == 2); Assert(self->chemical_type == 0 || self->chemical_type == 1 || self->chemical_type == 2);
if (self->distribution == 1) if (self->chemical_type == 1)
*val = grib2_is_PDTN_ChemicalDistFunc(productDefinitionTemplateNumber); *val = grib2_is_PDTN_ChemicalDistFunc(productDefinitionTemplateNumber);
else if (self->distribution == 2) else if (self->chemical_type == 2)
*val = grib2_is_PDTN_ChemicalSourceSink(productDefinitionTemplateNumber); *val = grib2_is_PDTN_ChemicalSourceSink(productDefinitionTemplateNumber);
else else
*val = grib2_is_PDTN_Chemical(productDefinitionTemplateNumber); *val = grib2_is_PDTN_Chemical(productDefinitionTemplateNumber);
@ -207,30 +207,31 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len)
* 1 = atmospheric chemical constituents based on a distribution function * 1 = atmospheric chemical constituents based on a distribution function
* 2 = atmospheric chemical constituents with source or sink * 2 = atmospheric chemical constituents with source or sink
*/ */
Assert(self->distribution == 0 || self->distribution == 1 || self->distribution == 2); Assert(self->chemical_type == 0 || self->chemical_type == 1 || self->chemical_type == 2);
if (eps == 1) { if (eps == 1) {
if (isInstant) { if (isInstant) {
if (self->distribution == 0) productDefinitionTemplateNumberNew=41; if (self->chemical_type == 0) productDefinitionTemplateNumberNew=41;
if (self->distribution == 1) productDefinitionTemplateNumberNew=58; else if (self->chemical_type == 1) productDefinitionTemplateNumberNew=58;
if (self->distribution == 2) productDefinitionTemplateNumberNew=77; else if (self->chemical_type == 2) productDefinitionTemplateNumberNew=77;
} }
else { else {
if (self->distribution == 0) productDefinitionTemplateNumberNew=43; if (self->chemical_type == 0) productDefinitionTemplateNumberNew=43;
if (self->distribution == 1) productDefinitionTemplateNumberNew=68; else if (self->chemical_type == 1) productDefinitionTemplateNumberNew=68;
if (self->distribution == 2) productDefinitionTemplateNumberNew=79; else if (self->chemical_type == 2) productDefinitionTemplateNumberNew=79;
} }
} }
else { else {
/* deterministic */
if (isInstant) { if (isInstant) {
if (self->distribution == 0) productDefinitionTemplateNumberNew=40; if (self->chemical_type == 0) productDefinitionTemplateNumberNew=40;
if (self->distribution == 1) productDefinitionTemplateNumberNew=57; else if (self->chemical_type == 1) productDefinitionTemplateNumberNew=57;
if (self->distribution == 2) productDefinitionTemplateNumberNew=76; else if (self->chemical_type == 2) productDefinitionTemplateNumberNew=76;
} }
else { else {
if (self->distribution == 0) productDefinitionTemplateNumberNew=42; if (self->chemical_type == 0) productDefinitionTemplateNumberNew=42;
if (self->distribution == 0) productDefinitionTemplateNumberNew=67; else if (self->chemical_type == 1) productDefinitionTemplateNumberNew=67;
if (self->distribution == 0) productDefinitionTemplateNumberNew=78; else if (self->chemical_type == 2) productDefinitionTemplateNumberNew=78;
} }
} }