mirror of https://github.com/ecmwf/eccodes.git
ECC-604: Replace global variable with data member
This commit is contained in:
parent
9006a680c3
commit
880f3b8437
|
@ -48,6 +48,7 @@ typedef struct grib_accessor_g1fcperiod {
|
||||||
const char *step_unit;
|
const char *step_unit;
|
||||||
const char *stepType;
|
const char *stepType;
|
||||||
const char *patch_fp_precip;
|
const char *patch_fp_precip;
|
||||||
|
int error_on_units;
|
||||||
/* Members defined in g1fcperiod */
|
/* Members defined in g1fcperiod */
|
||||||
} grib_accessor_g1fcperiod;
|
} grib_accessor_g1fcperiod;
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
MEMBERS = const char *step_unit
|
MEMBERS = const char *step_unit
|
||||||
MEMBERS = const char *stepType
|
MEMBERS = const char *stepType
|
||||||
MEMBERS = const char *patch_fp_precip
|
MEMBERS = const char *patch_fp_precip
|
||||||
|
MEMBERS = int error_on_units
|
||||||
END_CLASS_DEF
|
END_CLASS_DEF
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
@ -71,6 +72,7 @@ typedef struct grib_accessor_g1step_range {
|
||||||
const char *step_unit;
|
const char *step_unit;
|
||||||
const char *stepType;
|
const char *stepType;
|
||||||
const char *patch_fp_precip;
|
const char *patch_fp_precip;
|
||||||
|
int error_on_units;
|
||||||
} grib_accessor_g1step_range;
|
} grib_accessor_g1step_range;
|
||||||
|
|
||||||
extern grib_accessor_class* grib_accessor_class_abstract_long_vector;
|
extern grib_accessor_class* grib_accessor_class_abstract_long_vector;
|
||||||
|
@ -164,6 +166,7 @@ static void init(grib_accessor* a,const long l, grib_arguments* c)
|
||||||
self->step_unit = grib_arguments_get_name(h,c,n++);
|
self->step_unit = grib_arguments_get_name(h,c,n++);
|
||||||
self->stepType = grib_arguments_get_name(h,c,n++);
|
self->stepType = grib_arguments_get_name(h,c,n++);
|
||||||
self->patch_fp_precip = grib_arguments_get_name(h,c,n++);
|
self->patch_fp_precip = grib_arguments_get_name(h,c,n++);
|
||||||
|
self->error_on_units = 1;
|
||||||
|
|
||||||
self->number_of_elements=2;
|
self->number_of_elements=2;
|
||||||
self->v=(long*)grib_context_malloc_clear(h->context,
|
self->v=(long*)grib_context_malloc_clear(h->context,
|
||||||
|
@ -180,8 +183,6 @@ static void dump(grib_accessor* a, grib_dumper* dumper)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int error_on_units=1;
|
|
||||||
|
|
||||||
static int u2s1[] = {
|
static int u2s1[] = {
|
||||||
60, /* (0) minutes */
|
60, /* (0) minutes */
|
||||||
3600, /* (1) hour */
|
3600, /* (1) hour */
|
||||||
|
@ -324,7 +325,7 @@ static int unpack_string(grib_accessor* a, char* val, size_t *len)
|
||||||
else
|
else
|
||||||
sprintf(step_unit_string,"h");
|
sprintf(step_unit_string,"h");
|
||||||
|
|
||||||
if (error_on_units) {
|
if (self->error_on_units) {
|
||||||
grib_get_long_internal(hand,self->unit,&unit);
|
grib_get_long_internal(hand,self->unit,&unit);
|
||||||
if (unit==254) {
|
if (unit==254) {
|
||||||
unit=15; /* See ECC-316 */
|
unit=15; /* See ECC-316 */
|
||||||
|
@ -640,9 +641,9 @@ static int pack_long(grib_accessor* a, const long* val, size_t *len)
|
||||||
return pack_string( a,buff,&bufflen);
|
return pack_string( a,buff,&bufflen);
|
||||||
case 0 :
|
case 0 :
|
||||||
self->pack_index=-1;
|
self->pack_index=-1;
|
||||||
error_on_units=0;
|
self->error_on_units=0;
|
||||||
unpack_string(a,sval,&svallen);
|
unpack_string(a,sval,&svallen);
|
||||||
error_on_units=1;
|
self->error_on_units=1;
|
||||||
while (*p != '-' && *p != '\0' ) p++;
|
while (*p != '-' && *p != '\0' ) p++;
|
||||||
if (*p=='-') {
|
if (*p=='-') {
|
||||||
sprintf(buff,"%ld-%s",*val,++p);
|
sprintf(buff,"%ld-%s",*val,++p);
|
||||||
|
@ -656,9 +657,9 @@ static int pack_long(grib_accessor* a, const long* val, size_t *len)
|
||||||
return pack_string( a,buff,&bufflen);
|
return pack_string( a,buff,&bufflen);
|
||||||
case 1 :
|
case 1 :
|
||||||
self->pack_index=-1;
|
self->pack_index=-1;
|
||||||
error_on_units=0;
|
self->error_on_units=0;
|
||||||
unpack_string(a,sval,&svallen);
|
unpack_string(a,sval,&svallen);
|
||||||
error_on_units=1;
|
self->error_on_units=1;
|
||||||
while (*p != '-' && *p != '\0' ) p++;
|
while (*p != '-' && *p != '\0' ) p++;
|
||||||
if (*p=='-') {
|
if (*p=='-') {
|
||||||
*p='\0';
|
*p='\0';
|
||||||
|
|
Loading…
Reference in New Issue