mirror of https://github.com/ecmwf/eccodes.git
ECC-976: Add hint
This commit is contained in:
parent
56aca66573
commit
62cc82ac52
|
@ -245,6 +245,7 @@ static int unpack_double (grib_accessor* a, double*v, size_t *len)
|
||||||
char val[1024];
|
char val[1024];
|
||||||
size_t l = sizeof(val);
|
size_t l = sizeof(val);
|
||||||
char *last = NULL;
|
char *last = NULL;
|
||||||
|
|
||||||
grib_unpack_string (a , val, &l);
|
grib_unpack_string (a , val, &l);
|
||||||
|
|
||||||
*v = strtod(val,&last);
|
*v = strtod(val,&last);
|
||||||
|
@ -255,7 +256,8 @@ static int unpack_double (grib_accessor* a, double*v, size_t *len)
|
||||||
return GRIB_SUCCESS;
|
return GRIB_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
grib_context_log(a->context,GRIB_LOG_ERROR,"Cannot unpack %s as double",a->name);
|
grib_context_log(a->context,GRIB_LOG_ERROR,"Cannot unpack %s as double. Hint: Try unpacking as string",a->name);
|
||||||
|
|
||||||
return GRIB_NOT_IMPLEMENTED;
|
return GRIB_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -463,6 +463,7 @@ static long get_ECMWF_local_paramId(grib_accessor* a, grib_handle* h)
|
||||||
|
|
||||||
static int unpack_long(grib_accessor* a, long* val, size_t *len)
|
static int unpack_long(grib_accessor* a, long* val, size_t *len)
|
||||||
{
|
{
|
||||||
|
char *endptr;
|
||||||
const char *p = concept_evaluate(a);
|
const char *p = concept_evaluate(a);
|
||||||
|
|
||||||
if(!p) {
|
if(!p) {
|
||||||
|
@ -480,8 +481,16 @@ static int unpack_long(grib_accessor* a, long* val, size_t *len)
|
||||||
return GRIB_NOT_FOUND;
|
return GRIB_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
*val = atol(p);
|
|
||||||
*len = 1;
|
*len = 1;
|
||||||
|
*val = strtol(p, &endptr, 10);
|
||||||
|
if (endptr == p) {
|
||||||
|
int type = GRIB_TYPE_UNDEFINED;
|
||||||
|
grib_context_log(a->context,GRIB_LOG_ERROR,"Cannot unpack %s as long",a->name);
|
||||||
|
if (grib_get_native_type(grib_handle_of_accessor(a), a->name, &type) == GRIB_SUCCESS) {
|
||||||
|
grib_context_log(a->context,GRIB_LOG_ERROR,"Hint: Try unpacking as %s", grib_get_type_name(type));
|
||||||
|
}
|
||||||
|
return GRIB_DECODING_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
return GRIB_SUCCESS;
|
return GRIB_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -268,6 +268,7 @@ static int clear(grib_accessor* a)
|
||||||
|
|
||||||
static int unpack_long (grib_accessor* a, long* v, size_t *len)
|
static int unpack_long (grib_accessor* a, long* v, size_t *len)
|
||||||
{
|
{
|
||||||
|
int type = GRIB_TYPE_UNDEFINED;
|
||||||
if(a->cclass->unpack_double && a->cclass->unpack_double != &unpack_double)
|
if(a->cclass->unpack_double && a->cclass->unpack_double != &unpack_double)
|
||||||
{
|
{
|
||||||
double val = 0.0;
|
double val = 0.0;
|
||||||
|
@ -295,11 +296,15 @@ static int unpack_long (grib_accessor* a, long* v, size_t *len)
|
||||||
}
|
}
|
||||||
|
|
||||||
grib_context_log(a->context,GRIB_LOG_ERROR,"Cannot unpack %s as long",a->name);
|
grib_context_log(a->context,GRIB_LOG_ERROR,"Cannot unpack %s as long",a->name);
|
||||||
|
if (grib_get_native_type(grib_handle_of_accessor(a), a->name, &type) == GRIB_SUCCESS) {
|
||||||
|
grib_context_log(a->context,GRIB_LOG_ERROR,"Hint: Try unpacking as %s", grib_get_type_name(type));
|
||||||
|
}
|
||||||
return GRIB_NOT_IMPLEMENTED;
|
return GRIB_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int unpack_double (grib_accessor* a, double*v, size_t *len)
|
static int unpack_double (grib_accessor* a, double*v, size_t *len)
|
||||||
{
|
{
|
||||||
|
int type = GRIB_TYPE_UNDEFINED;
|
||||||
if(a->cclass->unpack_long && a->cclass->unpack_long != &unpack_long)
|
if(a->cclass->unpack_long && a->cclass->unpack_long != &unpack_long)
|
||||||
{
|
{
|
||||||
long val = 0;
|
long val = 0;
|
||||||
|
@ -327,12 +332,15 @@ static int unpack_double (grib_accessor* a, double*v, size_t *len)
|
||||||
}
|
}
|
||||||
|
|
||||||
grib_context_log(a->context,GRIB_LOG_ERROR,"Cannot unpack %s as double",a->name);
|
grib_context_log(a->context,GRIB_LOG_ERROR,"Cannot unpack %s as double",a->name);
|
||||||
|
if (grib_get_native_type(grib_handle_of_accessor(a), a->name, &type) == GRIB_SUCCESS) {
|
||||||
|
grib_context_log(a->context,GRIB_LOG_ERROR,"Hint: Try unpacking as %s", grib_get_type_name(type));
|
||||||
|
}
|
||||||
|
|
||||||
return GRIB_NOT_IMPLEMENTED;
|
return GRIB_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int unpack_string(grib_accessor*a , char* v, size_t *len)
|
static int unpack_string(grib_accessor*a , char* v, size_t *len)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(a->cclass->unpack_double && a->cclass->unpack_double != &unpack_double)
|
if(a->cclass->unpack_double && a->cclass->unpack_double != &unpack_double)
|
||||||
{
|
{
|
||||||
double val = 0.0;
|
double val = 0.0;
|
||||||
|
|
Loading…
Reference in New Issue