ECC-1572: Fortran codes_get/grib_get fails to get array of 32-bit real numbers

This commit is contained in:
Shahram Najm 2023-04-24 16:43:59 +01:00
parent a42a8547bc
commit 1ef77a8b47
3 changed files with 7 additions and 5 deletions

View File

@ -16,7 +16,7 @@ program grib_get_pv
integer :: infile
integer :: igrib
integer :: PVPresent, nb_pv
real(kind=8), dimension(:), allocatable :: pv
real(kind=4), dimension(:), allocatable :: pv
call codes_open_file(infile, '../../data/reduced_gaussian_model_level.grib1', 'r')

View File

@ -151,7 +151,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
rlen = count;
if (*len < rlen) {
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size (%lu) for %s, it contains %lu values", *len, a->name, rlen);
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size (%zu) for %s, it contains %lu values", *len, a->name, rlen);
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}
@ -163,6 +163,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
return GRIB_SUCCESS;
}
// ECC-1572: TODO(masn) use templates
static int unpack_float(grib_accessor* a, float* val, size_t* len)
{
unsigned long rlen = 0;
@ -177,7 +178,7 @@ static int unpack_float(grib_accessor* a, float* val, size_t* len)
rlen = count;
if (*len < rlen) {
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size (%lu) for %s, it contains %lu values", *len, a->name, rlen);
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size (%zu) for %s, it contains %lu values", *len, a->name, rlen);
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}

View File

@ -195,7 +195,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
return err;
if (*len < (size_t)rlen) {
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size (%lu) for %s, it contains %ld values", *len, a->name, rlen);
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size (%zu) for %s, it contains %ld values", *len, a->name, rlen);
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}
@ -206,6 +206,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
return GRIB_SUCCESS;
}
// ECC-1572: TODO(masn) use templates
static int unpack_float(grib_accessor* a, float* val, size_t* len)
{
long rlen = 0;
@ -218,7 +219,7 @@ static int unpack_float(grib_accessor* a, float* val, size_t* len)
return err;
if (*len < (size_t)rlen) {
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size (%lu) for %s, it contains %ld values", *len, a->name, rlen);
grib_context_log(a->context, GRIB_LOG_ERROR, "Wrong size (%zu) for %s, it contains %ld values", *len, a->name, rlen);
*len = 0;
return GRIB_ARRAY_TOO_SMALL;
}