This commit is contained in:
Shahram Najm 2019-01-28 10:49:58 +00:00
parent 483489a05a
commit afbcfd0d62
1 changed files with 30 additions and 32 deletions

View File

@ -137,53 +137,51 @@ static void init_class(grib_accessor_class* c)
static void init(grib_accessor* a,const long l, grib_arguments* c)
{
grib_accessor_g1verificationdate* self = (grib_accessor_g1verificationdate*)a;
int n = 0;
grib_accessor_g1verificationdate* self = (grib_accessor_g1verificationdate*)a;
int n = 0;
self->date = grib_arguments_get_name(grib_handle_of_accessor(a),c,n++);
self->time = grib_arguments_get_name(grib_handle_of_accessor(a),c,n++);
self->step = grib_arguments_get_name(grib_handle_of_accessor(a),c,n++);
self->date = grib_arguments_get_name(grib_handle_of_accessor(a),c,n++);
self->time = grib_arguments_get_name(grib_handle_of_accessor(a),c,n++);
self->step = grib_arguments_get_name(grib_handle_of_accessor(a),c,n++);
a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY;
a->flags |= GRIB_ACCESSOR_FLAG_READ_ONLY;
}
static void dump(grib_accessor* a, grib_dumper* dumper)
{
grib_dump_long(dumper,a,NULL);
grib_dump_long(dumper,a,NULL);
}
static int unpack_long(grib_accessor* a, long* val, size_t *len)
{
grib_accessor_g1verificationdate* self = (grib_accessor_g1verificationdate*)a;
int ret=0;
long date = 0;
long time = 0;
long cdate = 0;
long step = 0;
long vtime = 0;
long vdate = 0;
long vd = 0;
grib_accessor_g1verificationdate* self = (grib_accessor_g1verificationdate*)a;
int ret=0;
long date = 0;
long time = 0;
long cdate = 0;
long step = 0;
long vtime = 0;
long vdate = 0;
long vd = 0;
if ((ret=grib_get_long_internal(grib_handle_of_accessor(a), self->date,&date))!=GRIB_SUCCESS) return ret;
if ((ret=grib_get_long_internal(grib_handle_of_accessor(a), self->time,&time))!=GRIB_SUCCESS) return ret;
if ((ret=grib_get_long_internal(grib_handle_of_accessor(a), self->step,&step))!=GRIB_SUCCESS) return ret;
if ((ret=grib_get_long_internal(grib_handle_of_accessor(a), self->date,&date))!=GRIB_SUCCESS) return ret;
if ((ret=grib_get_long_internal(grib_handle_of_accessor(a), self->time,&time))!=GRIB_SUCCESS) return ret;
if ((ret=grib_get_long_internal(grib_handle_of_accessor(a), self->step,&step))!=GRIB_SUCCESS) return ret;
time /= 100;
time /= 100;
cdate = (long)grib_date_to_julian (date);
vtime = cdate * 24 + time + step;
vd = vtime / 24;
vdate = grib_julian_to_date (vd);
cdate = (long)grib_date_to_julian (date);
vtime = cdate * 24 + time + step;
vd = vtime / 24;
vdate = grib_julian_to_date (vd);
/* printf("\n********\n date %d, time %d, step %d, vdate: %d, cdate %d, vd %d\n********\n", date, time, step, vdate, cdate, vd); */
/* printf("\n********\n date %d, time %d, step %d, vdate: %d, cdate %d, vd %d\n********\n", date, time, step, vdate, cdate, vd); */
if(*len < 1)
return GRIB_ARRAY_TOO_SMALL;
if(*len < 1)
return GRIB_ARRAY_TOO_SMALL;
*val = vdate;
*val = vdate;
/* fprintf(stdout,"\n********\n %d cdate %d vd %d\n********\n", vdate, cdate, step); */
return GRIB_SUCCESS;
/* fprintf(stdout,"\n********\n %d cdate %d vd %d\n********\n", vdate, cdate, step); */
return GRIB_SUCCESS;
}