mirror of https://github.com/ecmwf/eccodes.git
Merge branch 'develop' into feature/ECC-1467-FloatDataValues
This commit is contained in:
commit
d300abb636
|
@ -0,0 +1,24 @@
|
|||
name: sync
|
||||
|
||||
# Controls when the workflow will run
|
||||
on:
|
||||
# Trigger the workflow on all pushes
|
||||
push:
|
||||
branches:
|
||||
- "**"
|
||||
tags:
|
||||
- "**"
|
||||
|
||||
# Trigger the workflow when a branch or tag is deleted
|
||||
delete: ~
|
||||
|
||||
jobs:
|
||||
# Calls a reusable CI workflow to sync the current with a remote repository.
|
||||
# It will correctly handle addition of any new and removal of existing Git objects.
|
||||
sync:
|
||||
name: sync
|
||||
uses: ecmwf-actions/reusable-workflows/.github/workflows/sync.yml@v2
|
||||
secrets:
|
||||
target_repository: eccodes/eccodes
|
||||
target_username: ClonedDuck
|
||||
target_token: ${{ secrets.BITBUCKET_PAT }}
|
|
@ -12,13 +12,18 @@ file(READ "bufr_ref_files.txt" bufr_refs_to_download)
|
|||
string(REGEX REPLACE "\n" ";" bufr_refs_to_download "${bufr_refs_to_download}")
|
||||
|
||||
# Exceptional case: download bufr files which have to be treated specially
|
||||
list(APPEND bufr_refs_to_download "vos308014_v3_26.bufr") # See test ecc-197
|
||||
list(APPEND bufr_files_to_download "vos308014_v3_26.bufr") # See test ecc-197
|
||||
|
||||
if( ENABLE_EXTRA_TESTS )
|
||||
ecbuild_get_test_multidata(
|
||||
TARGET eccodes_download_bufrs
|
||||
NOCHECK
|
||||
NAMES ${bufr_files_to_download} ${bufr_refs_to_download}
|
||||
TARGET eccodes_download_bufrs
|
||||
NOCHECK
|
||||
NAMES ${bufr_files_to_download}
|
||||
)
|
||||
ecbuild_get_test_multidata(
|
||||
TARGET eccodes_download_bufr_refs
|
||||
NOCHECK
|
||||
NAMES ${bufr_refs_to_download}
|
||||
)
|
||||
endif()
|
||||
|
||||
|
|
|
@ -2453,6 +2453,21 @@
|
|||
typeOfFirstFixedSurface = 1 ;
|
||||
typeOfStatisticalProcessing = 1 ;
|
||||
}
|
||||
#Potential evaporation rate
|
||||
'pevr' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 1 ;
|
||||
parameterNumber = 143 ;
|
||||
typeOfFirstFixedSurface = 1 ;
|
||||
}
|
||||
#Potential evaporation
|
||||
'peva' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 1 ;
|
||||
parameterNumber = 143 ;
|
||||
typeOfFirstFixedSurface = 1 ;
|
||||
typeOfStatisticalProcessing = 1 ;
|
||||
}
|
||||
#Mean temperature tendency due to short-wave radiation
|
||||
'mttswr' = {
|
||||
discipline = 0 ;
|
||||
|
@ -5572,12 +5587,6 @@
|
|||
parameterCategory = 1 ;
|
||||
parameterNumber = 40 ;
|
||||
}
|
||||
#Potential evaporation rate
|
||||
'pevpr' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 1 ;
|
||||
parameterNumber = 41 ;
|
||||
}
|
||||
#Snow cover
|
||||
'snowc' = {
|
||||
discipline = 0 ;
|
||||
|
|
|
@ -65,12 +65,6 @@
|
|||
parameterCategory = 1 ;
|
||||
parameterNumber = 199 ;
|
||||
}
|
||||
#Potential evaporation rate
|
||||
'Potential evaporation rate' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 1 ;
|
||||
parameterNumber = 200 ;
|
||||
}
|
||||
#Snow cover
|
||||
'Snow cover' = {
|
||||
discipline = 0 ;
|
||||
|
|
|
@ -65,12 +65,6 @@
|
|||
parameterCategory = 1 ;
|
||||
parameterNumber = 199 ;
|
||||
}
|
||||
#Potential evaporation rate
|
||||
'260037' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 1 ;
|
||||
parameterNumber = 200 ;
|
||||
}
|
||||
#Snow cover
|
||||
'260038' = {
|
||||
discipline = 0 ;
|
||||
|
|
|
@ -65,12 +65,6 @@
|
|||
parameterCategory = 1 ;
|
||||
parameterNumber = 199 ;
|
||||
}
|
||||
#Potential evaporation rate
|
||||
'pevpr' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 1 ;
|
||||
parameterNumber = 200 ;
|
||||
}
|
||||
#Snow cover
|
||||
'snowc' = {
|
||||
discipline = 0 ;
|
||||
|
|
|
@ -65,12 +65,6 @@
|
|||
parameterCategory = 1 ;
|
||||
parameterNumber = 199 ;
|
||||
}
|
||||
#Potential evaporation rate
|
||||
'W m**-2' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 1 ;
|
||||
parameterNumber = 200 ;
|
||||
}
|
||||
#Snow cover
|
||||
'%' = {
|
||||
discipline = 0 ;
|
||||
|
|
|
@ -2453,6 +2453,21 @@
|
|||
typeOfFirstFixedSurface = 1 ;
|
||||
typeOfStatisticalProcessing = 1 ;
|
||||
}
|
||||
#Potential evaporation rate
|
||||
'Potential evaporation rate' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 1 ;
|
||||
parameterNumber = 143 ;
|
||||
typeOfFirstFixedSurface = 1 ;
|
||||
}
|
||||
#Potential evaporation
|
||||
'Potential evaporation' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 1 ;
|
||||
parameterNumber = 143 ;
|
||||
typeOfFirstFixedSurface = 1 ;
|
||||
typeOfStatisticalProcessing = 1 ;
|
||||
}
|
||||
#Mean temperature tendency due to short-wave radiation
|
||||
'Mean temperature tendency due to short-wave radiation' = {
|
||||
discipline = 0 ;
|
||||
|
@ -5572,12 +5587,6 @@
|
|||
parameterCategory = 1 ;
|
||||
parameterNumber = 40 ;
|
||||
}
|
||||
#Potential evaporation rate
|
||||
'Potential evaporation rate' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 1 ;
|
||||
parameterNumber = 41 ;
|
||||
}
|
||||
#Snow cover
|
||||
'Snow cover' = {
|
||||
discipline = 0 ;
|
||||
|
|
|
@ -2453,6 +2453,21 @@
|
|||
typeOfFirstFixedSurface = 1 ;
|
||||
typeOfStatisticalProcessing = 1 ;
|
||||
}
|
||||
#Potential evaporation rate
|
||||
'231004' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 1 ;
|
||||
parameterNumber = 143 ;
|
||||
typeOfFirstFixedSurface = 1 ;
|
||||
}
|
||||
#Potential evaporation
|
||||
'231005' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 1 ;
|
||||
parameterNumber = 143 ;
|
||||
typeOfFirstFixedSurface = 1 ;
|
||||
typeOfStatisticalProcessing = 1 ;
|
||||
}
|
||||
#Mean temperature tendency due to short-wave radiation
|
||||
'235001' = {
|
||||
discipline = 0 ;
|
||||
|
@ -5572,12 +5587,6 @@
|
|||
parameterCategory = 1 ;
|
||||
parameterNumber = 40 ;
|
||||
}
|
||||
#Potential evaporation rate
|
||||
'260037' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 1 ;
|
||||
parameterNumber = 41 ;
|
||||
}
|
||||
#Snow cover
|
||||
'260038' = {
|
||||
discipline = 0 ;
|
||||
|
|
|
@ -2453,6 +2453,21 @@
|
|||
typeOfFirstFixedSurface = 1 ;
|
||||
typeOfStatisticalProcessing = 1 ;
|
||||
}
|
||||
#Potential evaporation rate
|
||||
'pevr' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 1 ;
|
||||
parameterNumber = 143 ;
|
||||
typeOfFirstFixedSurface = 1 ;
|
||||
}
|
||||
#Potential evaporation
|
||||
'peva' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 1 ;
|
||||
parameterNumber = 143 ;
|
||||
typeOfFirstFixedSurface = 1 ;
|
||||
typeOfStatisticalProcessing = 1 ;
|
||||
}
|
||||
#Mean temperature tendency due to short-wave radiation
|
||||
'mttswr' = {
|
||||
discipline = 0 ;
|
||||
|
@ -5572,12 +5587,6 @@
|
|||
parameterCategory = 1 ;
|
||||
parameterNumber = 40 ;
|
||||
}
|
||||
#Potential evaporation rate
|
||||
'pevpr' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 1 ;
|
||||
parameterNumber = 41 ;
|
||||
}
|
||||
#Snow cover
|
||||
'snowc' = {
|
||||
discipline = 0 ;
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
# (C) Copyright 2005- ECMWF.
|
||||
|
||||
# TEMPLATE 4.108, Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for generic optical properties
|
||||
|
||||
include "grib2/template.4.parameter.def"
|
||||
include "grib2/template.4.optical.def"
|
||||
include "grib2/template.4.generating_process.def"
|
||||
include "grib2/template.4.forecast_time.def"
|
||||
include "grib2/template.4.point_in_time.def"
|
||||
include "grib2/template.4.horizontal.def"
|
|
@ -0,0 +1,11 @@
|
|||
# (C) Copyright 2005- ECMWF.
|
||||
|
||||
# TEMPLATE 4.109, Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for generic optical properties
|
||||
|
||||
include "grib2/template.4.parameter.def"
|
||||
include "grib2/template.4.optical.def"
|
||||
include "grib2/template.4.generating_process.def"
|
||||
include "grib2/template.4.forecast_time.def"
|
||||
include "grib2/template.4.point_in_time.def"
|
||||
include "grib2/template.4.horizontal.def"
|
||||
include "grib2/template.4.eps.def"
|
|
@ -0,0 +1,10 @@
|
|||
# (C) Copyright 2005- ECMWF.
|
||||
|
||||
# TEMPLATE 4.110 - Average, accumulation, and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for generic optical properties
|
||||
|
||||
include "grib2/template.4.parameter.def"
|
||||
include "grib2/template.4.optical.def"
|
||||
include "grib2/template.4.generating_process.def"
|
||||
include "grib2/template.4.forecast_time.def"
|
||||
include "grib2/template.4.horizontal.def"
|
||||
include "grib2/template.4.statistical.def"
|
|
@ -0,0 +1,11 @@
|
|||
# (C) Copyright 2005- ECMWF.
|
||||
|
||||
# TEMPLATE 4.111, Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for generic optical properties
|
||||
|
||||
include "grib2/template.4.parameter.def"
|
||||
include "grib2/template.4.optical.def"
|
||||
include "grib2/template.4.generating_process.def"
|
||||
include "grib2/template.4.forecast_time.def"
|
||||
include "grib2/template.4.horizontal.def"
|
||||
include "grib2/template.4.eps.def"
|
||||
include "grib2/template.4.statistical.def"
|
|
@ -2453,6 +2453,21 @@
|
|||
typeOfFirstFixedSurface = 1 ;
|
||||
typeOfStatisticalProcessing = 1 ;
|
||||
}
|
||||
#Potential evaporation rate
|
||||
'kg m**-2 s**-1' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 1 ;
|
||||
parameterNumber = 143 ;
|
||||
typeOfFirstFixedSurface = 1 ;
|
||||
}
|
||||
#Potential evaporation
|
||||
'kg m**-2' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 1 ;
|
||||
parameterNumber = 143 ;
|
||||
typeOfFirstFixedSurface = 1 ;
|
||||
typeOfStatisticalProcessing = 1 ;
|
||||
}
|
||||
#Mean temperature tendency due to short-wave radiation
|
||||
'K s**-1' = {
|
||||
discipline = 0 ;
|
||||
|
@ -5572,12 +5587,6 @@
|
|||
parameterCategory = 1 ;
|
||||
parameterNumber = 40 ;
|
||||
}
|
||||
#Potential evaporation rate
|
||||
'W m**-2' = {
|
||||
discipline = 0 ;
|
||||
parameterCategory = 1 ;
|
||||
parameterNumber = 41 ;
|
||||
}
|
||||
#Snow cover
|
||||
'%' = {
|
||||
discipline = 0 ;
|
||||
|
|
|
@ -148,7 +148,7 @@ foreach( test ${tests_extra} )
|
|||
TYPE SCRIPT
|
||||
CONDITION ENABLE_EXTRA_TESTS
|
||||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${test}.sh
|
||||
TEST_DEPENDS eccodes_download_gribs eccodes_download_bufrs )
|
||||
TEST_DEPENDS eccodes_download_gribs eccodes_download_bufrs eccodes_download_bufr_refs )
|
||||
endforeach()
|
||||
|
||||
# Tests which are conditional
|
||||
|
|
|
@ -15,9 +15,11 @@ tempGrib="out_surface_level.grib2"
|
|||
${examples_dir}/c_grib_set_missing
|
||||
|
||||
# Check the keys have been set to MISSING
|
||||
sf=`${tools_dir}/grib_get -p scaleFactorOfFirstFixedSurface $tempGrib`
|
||||
[ "$sf" = "MISSING" ]
|
||||
sf=`${tools_dir}/grib_get -p scaledValueOfFirstFixedSurface $tempGrib`
|
||||
[ "$sf" = "MISSING" ]
|
||||
if [ -f "${tools_dir}/grib_get" ]; then
|
||||
sf=`${tools_dir}/grib_get -p scaleFactorOfFirstFixedSurface $tempGrib`
|
||||
[ "$sf" = "MISSING" ]
|
||||
sf=`${tools_dir}/grib_get -p scaledValueOfFirstFixedSurface $tempGrib`
|
||||
[ "$sf" = "MISSING" ]
|
||||
fi
|
||||
|
||||
rm -f $tempGrib
|
||||
|
|
|
@ -115,7 +115,7 @@ foreach( tool ${tests_extra} )
|
|||
CONDITION HAVE_FORTRAN AND ENABLE_EXTRA_TESTS
|
||||
RESOURCES bufr_read_scatterometer_f.ref
|
||||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${tool}.sh
|
||||
TEST_DEPENDS eccodes_download_gribs eccodes_download_bufrs )
|
||||
TEST_DEPENDS eccodes_download_gribs eccodes_download_bufrs eccodes_download_bufr_refs )
|
||||
endforeach()
|
||||
|
||||
# Test for CCSDS (AEC) packing
|
||||
|
@ -123,7 +123,7 @@ ecbuild_add_test( TARGET eccodes_f_grib_set_packing
|
|||
SOURCES grib_set_packing.f90
|
||||
LINKER_LANGUAGE Fortran
|
||||
LIBS eccodes_f90 eccodes
|
||||
CONDITION HAVE_AEC AND HAVE_FORTRAN
|
||||
CONDITION HAVE_BUILD_TOOLS AND HAVE_AEC AND HAVE_FORTRAN
|
||||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/grib_set_packing.sh )
|
||||
|
||||
# Executables without a shell script
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
SUPER = action_class_gen
|
||||
IMPLEMENTS = dump
|
||||
IMPLEMENTS = destroy
|
||||
MEMBERS = grib_concept_value* concept
|
||||
MEMBERS = grib_concept_value* concept_value
|
||||
MEMBERS = char* basename
|
||||
MEMBERS = char* masterDir
|
||||
MEMBERS = char* localDir
|
||||
|
@ -46,7 +46,7 @@ static void destroy (grib_context*,grib_action*);
|
|||
|
||||
|
||||
typedef struct grib_action_concept {
|
||||
grib_action act;
|
||||
grib_action act;
|
||||
/* Members defined in gen */
|
||||
long len;
|
||||
grib_arguments* params;
|
||||
|
|
|
@ -211,7 +211,7 @@ static int bufr_decode_rdb_keys(const void* message, long offset_section2, codes
|
|||
/* The ECMWF BUFR local use section */
|
||||
static int bufr_decode_extra_rdb_keys(const void* message, long offset_section2, codes_bufr_header* hdr)
|
||||
{
|
||||
int isSatelliteType = 0;
|
||||
bool isSatelliteType = false;
|
||||
long start = 0;
|
||||
const long offset_keyData = offset_section2 + 6;
|
||||
const long offset_keyMore = offset_section2 + 19; /* 8 bytes long */
|
||||
|
@ -223,7 +223,7 @@ static int bufr_decode_extra_rdb_keys(const void* message, long offset_section2,
|
|||
DebugAssert(hdr->ecmwfLocalSectionPresent);
|
||||
|
||||
if (hdr->rdbType == 2 || hdr->rdbType == 3 || hdr->rdbType == 8 || hdr->rdbType == 12) {
|
||||
isSatelliteType = 1;
|
||||
isSatelliteType = true;
|
||||
}
|
||||
if (isSatelliteType || hdr->numberOfSubsets > 1) {
|
||||
hdr->isSatellite = 1;
|
||||
|
@ -844,7 +844,7 @@ static char* codes_bufr_header_get_centre_name(long edition, long centre_code)
|
|||
int codes_bufr_header_get_string(codes_bufr_header* bh, const char* key, char* val, size_t* len)
|
||||
{
|
||||
static const char* NOT_FOUND = "not_found";
|
||||
int isEcmwfLocal = 0;
|
||||
bool isEcmwfLocal = false;
|
||||
Assert(bh);
|
||||
Assert(key);
|
||||
*len = strlen(NOT_FOUND); /*By default*/
|
||||
|
|
|
@ -1079,7 +1079,6 @@ void grib_multi_support_reset(grib_context* c);
|
|||
|
||||
/* grib_header_compute.cc*/
|
||||
void print_math(grib_math* m);
|
||||
grib_math* grib_math_clone(grib_context* c, grib_math* m);
|
||||
void grib_math_delete(grib_context* c, grib_math* m);
|
||||
grib_math* grib_math_new(grib_context* c, const char* formula, int* err);
|
||||
|
||||
|
|
|
@ -271,7 +271,7 @@ static int get_native_type(grib_accessor* a)
|
|||
|
||||
size_t compute_size_AO(const long* descriptors, size_t numberOfDescriptors)
|
||||
{
|
||||
int i = 0;
|
||||
size_t i = 0;
|
||||
size_t sizeAO = numberOfDescriptors;
|
||||
int extraElement = 0;
|
||||
int X, F, Y;
|
||||
|
@ -661,7 +661,7 @@ static int unpack_string_array(grib_accessor* a, char** val, size_t* len)
|
|||
{
|
||||
grib_accessor_apply_operators* self = (grib_accessor_apply_operators*)a;
|
||||
int ret = 0;
|
||||
int i = 0;
|
||||
size_t i = 0;
|
||||
grib_context* c = a->context;
|
||||
|
||||
ret = apply_operators(a);
|
||||
|
|
|
@ -175,17 +175,18 @@ static int get_native_type(grib_accessor* a)
|
|||
|
||||
static int unpack_string(grib_accessor* a, char* val, size_t* len)
|
||||
{
|
||||
int i = 0;
|
||||
size_t i = 0;
|
||||
grib_handle* hand = grib_handle_of_accessor(a);
|
||||
const size_t alen = a->length;
|
||||
|
||||
if (len[0] < (a->length + 1)) {
|
||||
grib_context_log(a->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%lu) for %s it contains %ld values",
|
||||
if (len[0] < (alen + 1)) {
|
||||
grib_context_log(a->context, GRIB_LOG_ERROR, "unpack_string: Wrong size (%zu) for %s, it contains %ld values",
|
||||
len[0], a->name, a->length + 1);
|
||||
len[0] = 0;
|
||||
return GRIB_ARRAY_TOO_SMALL;
|
||||
}
|
||||
|
||||
for (i = 0; i < a->length; i++)
|
||||
for (i = 0; i < alen; i++)
|
||||
val[i] = hand->buffer->data[a->offset + i];
|
||||
val[i] = 0;
|
||||
len[0] = i;
|
||||
|
@ -194,16 +195,17 @@ static int unpack_string(grib_accessor* a, char* val, size_t* len)
|
|||
|
||||
static int pack_string(grib_accessor* a, const char* val, size_t* len)
|
||||
{
|
||||
int i = 0;
|
||||
size_t i = 0;
|
||||
grib_handle* hand = grib_handle_of_accessor(a);
|
||||
if (len[0] > (a->length) + 1) {
|
||||
const size_t alen = a->length;
|
||||
if (len[0] > (alen + 1)) {
|
||||
grib_context_log(a->context, GRIB_LOG_ERROR,
|
||||
"pack_string: Wrong size (%lu) for %s it contains %ld values", len[0], a->name, a->length + 1);
|
||||
"pack_string: Wrong size (%zu) for %s, it contains %ld values", len[0], a->name, a->length + 1);
|
||||
len[0] = 0;
|
||||
return GRIB_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
for (i = 0; i < a->length; i++) {
|
||||
for (i = 0; i < alen; i++) {
|
||||
if (i < len[0])
|
||||
hand->buffer->data[a->offset + i] = val[i];
|
||||
else
|
||||
|
|
|
@ -151,7 +151,7 @@ static int get_native_type(grib_accessor* a)
|
|||
|
||||
static int unpack_bytes(grib_accessor* a, unsigned char* buffer, size_t* len)
|
||||
{
|
||||
if (*len < a->length) {
|
||||
if (*len < (size_t)a->length) {
|
||||
*len = a->length;
|
||||
return GRIB_ARRAY_TOO_SMALL;
|
||||
}
|
||||
|
|
|
@ -816,8 +816,8 @@ static int encode_double_array(grib_context* c, grib_buffer* buff, long* pos, bu
|
|||
double min = 0, max = 0, maxAllowed, minAllowed;
|
||||
double* v = NULL;
|
||||
double* values = NULL;
|
||||
int thereIsAMissing = 0;
|
||||
int is_constant;
|
||||
bool thereIsAMissing = false;
|
||||
bool is_constant = true;
|
||||
double val0;
|
||||
/* ECC-379, ECC-830 */
|
||||
const int dont_fail_if_out_of_range = self->set_to_missing_if_out_of_range;
|
||||
|
@ -863,7 +863,7 @@ static int encode_double_array(grib_context* c, grib_buffer* buff, long* pos, bu
|
|||
grib_set_bits_on(buff->data, pos, modifiedWidth);
|
||||
}
|
||||
else {
|
||||
grib_context_log(c, GRIB_LOG_ERROR, "encode_double_array: %s (%06d). Value (%g) out of range (minAllowed=%g, maxAllowed=%g).",
|
||||
grib_context_log(c, GRIB_LOG_ERROR, "encode_double_array: %s (%06ld). Value (%g) out of range (minAllowed=%g, maxAllowed=%g).",
|
||||
bd->shortName, bd->code, *v, minAllowed, maxAllowed);
|
||||
return GRIB_OUT_OF_RANGE; /* ECC-611 */
|
||||
}
|
||||
|
@ -882,16 +882,16 @@ static int encode_double_array(grib_context* c, grib_buffer* buff, long* pos, bu
|
|||
return GRIB_ARRAY_TOO_SMALL;
|
||||
values = (double*)grib_context_malloc_clear(c, sizeof(double) * nvals);
|
||||
val0 = dvalues->v[self->iss_list->v[0]];
|
||||
is_constant = 1;
|
||||
is_constant = true;
|
||||
for (i = 0; i < nvals; i++) {
|
||||
values[i] = dvalues->v[self->iss_list->v[i]];
|
||||
if (val0 != values[i])
|
||||
is_constant = 0;
|
||||
is_constant = false;
|
||||
}
|
||||
v = values;
|
||||
|
||||
/* encoding a range with constant values*/
|
||||
if (is_constant == 1) {
|
||||
if (is_constant) {
|
||||
localWidth = 0;
|
||||
grib_buffer_set_ulength_bits(c, buff, buff->ulength_bits + modifiedWidth);
|
||||
if (*v == GRIB_MISSING_DOUBLE) {
|
||||
|
@ -909,7 +909,7 @@ static int encode_double_array(grib_context* c, grib_buffer* buff, long* pos, bu
|
|||
|
||||
ii = 0;
|
||||
while (ii < nvals && *v == GRIB_MISSING_DOUBLE) {
|
||||
thereIsAMissing = 1;
|
||||
thereIsAMissing = true;
|
||||
v++;
|
||||
ii++;
|
||||
}
|
||||
|
@ -950,17 +950,17 @@ static int encode_double_array(grib_context* c, grib_buffer* buff, long* pos, bu
|
|||
index_of_max = ii;
|
||||
}
|
||||
if (*v == GRIB_MISSING_DOUBLE)
|
||||
thereIsAMissing = 1;
|
||||
thereIsAMissing = true;
|
||||
ii++;
|
||||
v++;
|
||||
}
|
||||
if (max > maxAllowed && max != GRIB_MISSING_DOUBLE) {
|
||||
grib_context_log(c, GRIB_LOG_ERROR, "encode_double_array: %s (%06d). Maximum value (value[%lu]=%g) out of range (maxAllowed=%g).",
|
||||
grib_context_log(c, GRIB_LOG_ERROR, "encode_double_array: %s (%06ld). Maximum value (value[%lu]=%g) out of range (maxAllowed=%g).",
|
||||
bd->shortName, bd->code, index_of_max, max, maxAllowed);
|
||||
return GRIB_OUT_OF_RANGE;
|
||||
}
|
||||
if (min < minAllowed && min != GRIB_MISSING_DOUBLE) {
|
||||
grib_context_log(c, GRIB_LOG_ERROR, "encode_double_array: %s (%06d). Minimum value (value[%lu]=%g) out of range (minAllowed=%g).",
|
||||
grib_context_log(c, GRIB_LOG_ERROR, "encode_double_array: %s (%06ld). Minimum value (value[%lu]=%g) out of range (minAllowed=%g).",
|
||||
bd->shortName, bd->code, index_of_min, min, minAllowed);
|
||||
return GRIB_OUT_OF_RANGE;
|
||||
}
|
||||
|
@ -980,7 +980,7 @@ static int encode_double_array(grib_context* c, grib_buffer* buff, long* pos, bu
|
|||
localWidth++;
|
||||
}
|
||||
else {
|
||||
if (thereIsAMissing == 1)
|
||||
if (thereIsAMissing)
|
||||
localWidth = 1;
|
||||
else
|
||||
localWidth = 0;
|
||||
|
@ -1052,7 +1052,7 @@ static int encode_double_value(grib_context* c, grib_buffer* buff, long* pos, bu
|
|||
grib_set_bits_on(buff->data, pos, modifiedWidth);
|
||||
}
|
||||
else {
|
||||
grib_context_log(c, GRIB_LOG_ERROR, "encode_double_value: %s (%06d). Value (%g) out of range (minAllowed=%g, maxAllowed=%g).",
|
||||
grib_context_log(c, GRIB_LOG_ERROR, "encode_double_value: %s (%06ld). Value (%g) out of range (minAllowed=%g, maxAllowed=%g).",
|
||||
bd->shortName, bd->code, value, minAllowed, maxAllowed);
|
||||
return GRIB_OUT_OF_RANGE;
|
||||
}
|
||||
|
|
|
@ -456,7 +456,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
|
|||
|
||||
value_count(a, &count);
|
||||
|
||||
if (*len < count)
|
||||
if (*len < (size_t)count)
|
||||
return GRIB_ARRAY_TOO_SMALL;
|
||||
|
||||
if (self->compressedData) {
|
||||
|
@ -485,7 +485,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
|
|||
|
||||
value_count(a, &count);
|
||||
|
||||
if (*len < count)
|
||||
if (*len < (size_t)count)
|
||||
return GRIB_ARRAY_TOO_SMALL;
|
||||
|
||||
if (self->compressedData) {
|
||||
|
@ -597,11 +597,11 @@ static int unpack_double_element(grib_accessor* a, size_t idx, double* val)
|
|||
{
|
||||
/* ECC-415 */
|
||||
grib_accessor_bufr_data_element* self = (grib_accessor_bufr_data_element*)a;
|
||||
int ret = GRIB_SUCCESS;
|
||||
long count = 0;
|
||||
int ret = GRIB_SUCCESS;
|
||||
long count = 0;
|
||||
|
||||
value_count(a, &count);
|
||||
if (idx >= count) {
|
||||
if (idx >= (size_t)count) {
|
||||
return GRIB_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
|
|
|
@ -167,11 +167,11 @@ static int unpack_string(grib_accessor* a, char* v, size_t* len)
|
|||
{
|
||||
unsigned char* p = NULL;
|
||||
char* s = v;
|
||||
int i;
|
||||
long i = 0;
|
||||
const long length = grib_byte_count(a);
|
||||
const long slength = 2 * length;
|
||||
|
||||
if (*len < slength) {
|
||||
if (*len < (size_t)slength) {
|
||||
*len = slength;
|
||||
return GRIB_ARRAY_TOO_SMALL;
|
||||
}
|
||||
|
|
|
@ -195,8 +195,8 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len)
|
|||
if ((err = grib_get_size(h, self->values, &size)) != GRIB_SUCCESS)
|
||||
return err;
|
||||
|
||||
if (size > Ni * Nj) {
|
||||
grib_context_log(c, GRIB_LOG_ERROR, "change_alternative_row_scanning: wrong values size!=Ni*Nj (%ld!=%ld*%ld)", size, Ni, Nj);
|
||||
if ( size > (size_t)(Ni * Nj) ) {
|
||||
grib_context_log(c, GRIB_LOG_ERROR, "change_alternative_row_scanning: wrong values size!=Ni*Nj (%zu!=%ld*%ld)", size, Ni, Nj);
|
||||
return GRIB_WRONG_ARRAY_SIZE;
|
||||
}
|
||||
|
||||
|
|
|
@ -176,7 +176,10 @@ static int grib_get_codeflag(grib_accessor* a, long code, char* codename)
|
|||
int err = 0;
|
||||
|
||||
err = grib_recompose_name(grib_handle_of_accessor(a), NULL, self->tablename, fname, 1);
|
||||
if (err) strncpy(fname, self->tablename, 1023);
|
||||
if (err) {
|
||||
strncpy(fname, self->tablename, sizeof(fname)-1);
|
||||
fname[sizeof(fname)-1] = '\0';
|
||||
}
|
||||
|
||||
if ((filename = grib_context_full_defs_path(a->context, fname)) == NULL) {
|
||||
grib_context_log(a->context, GRIB_LOG_WARNING, "Cannot open flag table %s", filename);
|
||||
|
|
|
@ -350,6 +350,31 @@ static int cmpstringp(const void* p1, const void* p2)
|
|||
return strcmp(*(char* const*)p1, *(char* const*)p2);
|
||||
}
|
||||
|
||||
static bool blacklisted(grib_handle* h, long edition, const char* concept_name, const char* concept_value)
|
||||
{
|
||||
if ( strcmp(concept_name, "packingType")==0 ) {
|
||||
char input_packing_type[100];
|
||||
size_t len = sizeof(input_packing_type);
|
||||
if (strstr(concept_value, "SPD")) {
|
||||
return true;
|
||||
}
|
||||
if (edition == 2 && strstr(concept_value, "grid_run_length")) {
|
||||
return true;
|
||||
}
|
||||
if (edition == 1 && (strstr(concept_value, "ccsds") || strstr(concept_value, "jpeg"))) {
|
||||
return true;
|
||||
}
|
||||
grib_get_string(h, "packingType", input_packing_type, &len);
|
||||
if (strstr(input_packing_type,"grid_") && !strstr(concept_value,"grid_")) {
|
||||
return true;
|
||||
}
|
||||
if (strstr(input_packing_type,"spectral_") && !strstr(concept_value,"spectral_")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static int grib_concept_apply(grib_accessor* a, const char* name)
|
||||
{
|
||||
int err = 0;
|
||||
|
@ -405,16 +430,20 @@ static int grib_concept_apply(grib_accessor* a, const char* name)
|
|||
/* Only print out all concepts if fewer than MAX_NUM_CONCEPT_VALUES.
|
||||
* Printing out all values for concepts like paramId would be silly! */
|
||||
if (concept_count < MAX_NUM_CONCEPT_VALUES) {
|
||||
fprintf(stderr, "Here are the possible values for concept %s:\n", act->name);
|
||||
fprintf(stderr, "Here are some possible values for concept %s:\n", act->name);
|
||||
qsort(&all_concept_vals, concept_count, sizeof(char*), cmpstringp);
|
||||
for (i = 0; i < concept_count; ++i) {
|
||||
if (all_concept_vals[i]) {
|
||||
int print_it = 1;
|
||||
bool print_it = true;
|
||||
if (i > 0 && all_concept_vals[i - 1] && strcmp(all_concept_vals[i], all_concept_vals[i - 1]) == 0) {
|
||||
print_it = 0; /* skip duplicate entries */
|
||||
print_it = false; /* skip duplicate entries */
|
||||
}
|
||||
if (print_it)
|
||||
if (blacklisted(h, editionNumber, act->name, all_concept_vals[i])) {
|
||||
print_it = false;
|
||||
}
|
||||
if (print_it) {
|
||||
fprintf(stderr, "\t%s\n", all_concept_vals[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -230,8 +230,9 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
|
|||
grib_accessor_data_ccsds_packing* self = (grib_accessor_data_ccsds_packing*)a;
|
||||
|
||||
grib_handle* hand = grib_handle_of_accessor(a);
|
||||
int err = GRIB_SUCCESS, i = 0, is_constant_field = 0;
|
||||
size_t buflen = 0;
|
||||
int err = GRIB_SUCCESS;
|
||||
size_t buflen = 0, i = 0;
|
||||
bool is_constant_field = false;
|
||||
|
||||
unsigned char* buf = NULL;
|
||||
unsigned char* encoded = NULL;
|
||||
|
@ -291,7 +292,7 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
|
|||
}
|
||||
|
||||
if (min == max) {
|
||||
is_constant_field = 1;
|
||||
is_constant_field = true;
|
||||
} else {
|
||||
if (bits_per_value == 0) {
|
||||
/* ECC-1202: A non-constant field with bitsPerValue==0! */
|
||||
|
|
|
@ -380,15 +380,15 @@ cleanup:
|
|||
return err;
|
||||
}
|
||||
|
||||
static int is_constant(const double* values, size_t n_vals)
|
||||
static bool is_constant(const double* values, size_t n_vals)
|
||||
{
|
||||
int isConstant = 1;
|
||||
bool isConstant = true;
|
||||
double v = 0;
|
||||
size_t i;
|
||||
for (i = 0; i < n_vals; i++) {
|
||||
if (i == 0) v = values[i];
|
||||
else if (v != values[i]) {
|
||||
isConstant = 0;
|
||||
isConstant = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -399,7 +399,8 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
|
|||
{
|
||||
grib_accessor_data_png_packing* self = (grib_accessor_data_png_packing*)a;
|
||||
|
||||
int err = GRIB_SUCCESS, is_constant_field = 0;
|
||||
int err = GRIB_SUCCESS;
|
||||
bool is_constant_field = false;
|
||||
int i, j;
|
||||
size_t buflen = 0;
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
SUPER = grib_accessor_class_values
|
||||
IMPLEMENTS = init
|
||||
IMPLEMENTS = unpack_double
|
||||
IMPLEMENTS = pack_double
|
||||
IMPLEMENTS = value_count
|
||||
MEMBERS=const char* number_of_values
|
||||
MEMBERS=const char* bits_per_value
|
||||
|
@ -39,6 +40,7 @@ or edit "accessor.class" and rerun ./make_class.pl
|
|||
|
||||
*/
|
||||
|
||||
static int pack_double(grib_accessor*, const double* val, size_t* len);
|
||||
static int unpack_double(grib_accessor*, double* val, size_t* len);
|
||||
static int value_count(grib_accessor*, long*);
|
||||
static void init(grib_accessor*, const long, grib_arguments*);
|
||||
|
@ -86,10 +88,8 @@ static grib_accessor_class _grib_accessor_class_data_run_length_packing = {
|
|||
0, /* grib_pack procedures long */
|
||||
0, /* grib_pack procedures long */
|
||||
0, /* grib_unpack procedures long */
|
||||
0, /* grib_pack procedures double */
|
||||
0, /* grib_pack procedures float */
|
||||
&pack_double, /* grib_pack procedures double */
|
||||
&unpack_double, /* grib_unpack procedures double */
|
||||
0, /* grib_unpack procedures float */
|
||||
0, /* grib_pack procedures string */
|
||||
0, /* grib_unpack procedures string */
|
||||
0, /* grib_pack array procedures string */
|
||||
|
@ -105,9 +105,7 @@ static grib_accessor_class _grib_accessor_class_data_run_length_packing = {
|
|||
0, /* next accessor */
|
||||
0, /* compare vs. another accessor */
|
||||
0, /* unpack only ith value */
|
||||
0, /* unpack only ith value */
|
||||
0, /* unpack a given set of elements */
|
||||
0, /* unpack a given set of elements */
|
||||
0, /* unpack a subarray */
|
||||
0, /* clear */
|
||||
0, /* clone accessor */
|
||||
|
@ -130,9 +128,6 @@ static void init_class(grib_accessor_class* c)
|
|||
c->is_missing = (*(c->super))->is_missing;
|
||||
c->pack_long = (*(c->super))->pack_long;
|
||||
c->unpack_long = (*(c->super))->unpack_long;
|
||||
c->pack_double = (*(c->super))->pack_double;
|
||||
c->pack_float = (*(c->super))->pack_float;
|
||||
c->unpack_float = (*(c->super))->unpack_float;
|
||||
c->pack_string = (*(c->super))->pack_string;
|
||||
c->unpack_string = (*(c->super))->unpack_string;
|
||||
c->pack_string_array = (*(c->super))->pack_string_array;
|
||||
|
@ -148,9 +143,7 @@ static void init_class(grib_accessor_class* c)
|
|||
c->next = (*(c->super))->next;
|
||||
c->compare = (*(c->super))->compare;
|
||||
c->unpack_double_element = (*(c->super))->unpack_double_element;
|
||||
c->unpack_float_element = (*(c->super))->unpack_float_element;
|
||||
c->unpack_double_element_set = (*(c->super))->unpack_double_element_set;
|
||||
c->unpack_float_element_set = (*(c->super))->unpack_float_element_set;
|
||||
c->unpack_double_subarray = (*(c->super))->unpack_double_subarray;
|
||||
c->clear = (*(c->super))->clear;
|
||||
c->make_clone = (*(c->super))->make_clone;
|
||||
|
@ -275,3 +268,9 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
|
|||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
static int pack_double(grib_accessor* a, const double* val, size_t* len)
|
||||
{
|
||||
grib_context_log(a->context, GRIB_LOG_ERROR, "Changing the packing type to 'grid_run_length' is not implemented.");
|
||||
return GRIB_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
|
@ -199,7 +199,8 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len)
|
|||
ret = grib_get_string(hand, self->stepType, stepType, &slen);
|
||||
Assert(ret == GRIB_SUCCESS);
|
||||
|
||||
eps = grib2_is_PDTN_EPS(productDefinitionTemplateNumber);
|
||||
//eps = grib2_is_PDTN_EPS(productDefinitionTemplateNumber);
|
||||
eps = grib_is_defined(hand, "perturbationNumber");
|
||||
|
||||
if (!strcmp(stepType, "instant"))
|
||||
isInstant = 1;
|
||||
|
|
|
@ -207,7 +207,8 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len)
|
|||
ret = grib_get_string(hand, self->stepType, stepType, &slen);
|
||||
Assert(ret == GRIB_SUCCESS);
|
||||
|
||||
eps = grib2_is_PDTN_EPS(productDefinitionTemplateNumber);
|
||||
eps = grib_is_defined(hand, "perturbationNumber");
|
||||
//eps = grib2_is_PDTN_EPS(productDefinitionTemplateNumber);
|
||||
|
||||
if (!strcmp(stepType, "instant"))
|
||||
isInstant = 1;
|
||||
|
|
|
@ -173,12 +173,18 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
|
|||
{
|
||||
grib_accessor_g2_eps* self = (grib_accessor_g2_eps*)a;
|
||||
long productDefinitionTemplateNumber = 0;
|
||||
int err = 0;
|
||||
grib_handle* hand = grib_handle_of_accessor(a);
|
||||
|
||||
grib_get_long(grib_handle_of_accessor(a), self->productDefinitionTemplateNumber, &productDefinitionTemplateNumber);
|
||||
err = grib_get_long(hand, self->productDefinitionTemplateNumber, &productDefinitionTemplateNumber);
|
||||
if (err) return err;
|
||||
|
||||
*val = 0;
|
||||
if (grib2_is_PDTN_EPS(productDefinitionTemplateNumber))
|
||||
if (grib_is_defined(hand, "perturbationNumber")) {
|
||||
*val = 1;
|
||||
}
|
||||
//if (grib2_is_PDTN_EPS(productDefinitionTemplateNumber))
|
||||
// *val = 1;
|
||||
|
||||
return GRIB_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -151,12 +151,13 @@ static void init_class(grib_accessor_class* c)
|
|||
static void init(grib_accessor* a, const long l, grib_arguments* c)
|
||||
{
|
||||
grib_accessor_g2level* self = (grib_accessor_g2level*)a;
|
||||
grib_handle* hand = grib_handle_of_accessor(a);
|
||||
int n = 0;
|
||||
|
||||
self->type_first = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++);
|
||||
self->scale_first = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++);
|
||||
self->value_first = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++);
|
||||
self->pressure_units = grib_arguments_get_name(grib_handle_of_accessor(a), c, n++);
|
||||
self->type_first = grib_arguments_get_name(hand, c, n++);
|
||||
self->scale_first = grib_arguments_get_name(hand, c, n++);
|
||||
self->value_first = grib_arguments_get_name(hand, c, n++);
|
||||
self->pressure_units = grib_arguments_get_name(hand, c, n++);
|
||||
}
|
||||
|
||||
static void dump(grib_accessor* a, grib_dumper* dumper)
|
||||
|
@ -168,6 +169,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
|
|||
{
|
||||
int ret = 0;
|
||||
grib_accessor_g2level* self = (grib_accessor_g2level*)a;
|
||||
grib_handle* hand = grib_handle_of_accessor(a);
|
||||
|
||||
long type_first = 0;
|
||||
long scale_first = 0;
|
||||
|
@ -177,13 +179,13 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
|
|||
|
||||
double v;
|
||||
|
||||
if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->type_first, &type_first)) != GRIB_SUCCESS)
|
||||
if ((ret = grib_get_long_internal(hand, self->type_first, &type_first)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->scale_first, &scale_first)) != GRIB_SUCCESS)
|
||||
if ((ret = grib_get_long_internal(hand, self->scale_first, &scale_first)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->value_first, &value_first)) != GRIB_SUCCESS)
|
||||
if ((ret = grib_get_long_internal(hand, self->value_first, &value_first)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
if ((ret = grib_get_string_internal(grib_handle_of_accessor(a), self->pressure_units, pressure_units, &pressure_units_len)) != GRIB_SUCCESS)
|
||||
if ((ret = grib_get_string_internal(hand, self->pressure_units, pressure_units, &pressure_units_len)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
|
||||
if (value_first == GRIB_MISSING_LONG) {
|
||||
|
@ -221,7 +223,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t* len)
|
|||
// Switch to Pa instead of hPa as the value is less than a hectoPascal
|
||||
char pa[] = "Pa";
|
||||
size_t lpa = strlen(pa);
|
||||
if ((ret = grib_set_string_internal(grib_handle_of_accessor(a), self->pressure_units, pa, &lpa)) != GRIB_SUCCESS)
|
||||
if ((ret = grib_set_string_internal(hand, self->pressure_units, pa, &lpa)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
}
|
||||
else {
|
||||
|
@ -249,6 +251,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
|
|||
static int pack_double(grib_accessor* a, const double* val, size_t* len)
|
||||
{
|
||||
grib_accessor_g2level* self = (grib_accessor_g2level*)a;
|
||||
grib_handle* hand = grib_handle_of_accessor(a);
|
||||
int ret = 0;
|
||||
double value_first = *val;
|
||||
long scale_first = 0;
|
||||
|
@ -259,10 +262,10 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
|
|||
if (*len != 1)
|
||||
return GRIB_WRONG_ARRAY_SIZE;
|
||||
|
||||
if ((ret = grib_get_long_internal(grib_handle_of_accessor(a), self->type_first, &type_first)) != GRIB_SUCCESS)
|
||||
if ((ret = grib_get_long_internal(hand, self->type_first, &type_first)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
|
||||
if ((ret = grib_get_string_internal(grib_handle_of_accessor(a), self->pressure_units, pressure_units, &pressure_units_len)) != GRIB_SUCCESS)
|
||||
if ((ret = grib_get_string_internal(hand, self->pressure_units, pressure_units, &pressure_units_len)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
|
||||
switch (type_first) {
|
||||
|
@ -285,9 +288,9 @@ static int pack_double(grib_accessor* a, const double* val, size_t* len)
|
|||
value_first = value_first + 0.5; /* round up */
|
||||
|
||||
if (type_first > 9) {
|
||||
if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->scale_first, scale_first)) != GRIB_SUCCESS)
|
||||
if ((ret = grib_set_long_internal(hand, self->scale_first, scale_first)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
if ((ret = grib_set_long_internal(grib_handle_of_accessor(a), self->value_first, (long)value_first)) != GRIB_SUCCESS)
|
||||
if ((ret = grib_set_long_internal(hand, self->value_first, (long)value_first)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -371,10 +374,11 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len)
|
|||
static int is_missing(grib_accessor* a)
|
||||
{
|
||||
grib_accessor_g2level* self = (grib_accessor_g2level*)a;
|
||||
grib_handle* hand = grib_handle_of_accessor(a);
|
||||
int err = 0;
|
||||
int ret = 0;
|
||||
|
||||
ret = grib_is_missing(grib_handle_of_accessor(a), self->scale_first, &err) +
|
||||
grib_is_missing(grib_handle_of_accessor(a), self->value_first, &err);
|
||||
ret = grib_is_missing(hand, self->scale_first, &err) +
|
||||
grib_is_missing(hand, self->value_first, &err);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -242,10 +242,10 @@ static grib_hash_array_value* find_hash_value(grib_accessor* a, int* err)
|
|||
|
||||
static int unpack_long(grib_accessor* a, long* val, size_t* len)
|
||||
{
|
||||
grib_hash_array_value* ha = 0;
|
||||
grib_hash_array_value* ha = 0;
|
||||
grib_accessor_hash_array* self = (grib_accessor_hash_array*)a;
|
||||
int err = 0;
|
||||
int i;
|
||||
int err = 0;
|
||||
size_t i = 0;
|
||||
|
||||
if (!self->ha) {
|
||||
ha = find_hash_value(a, &err);
|
||||
|
|
|
@ -238,8 +238,11 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len)
|
|||
return GRIB_ENCODING_ERROR;
|
||||
}
|
||||
|
||||
if (grib2_is_PDTN_EPS(productDefinitionTemplateNumber))
|
||||
if (grib_is_defined(hand, "perturbationNumber")) {
|
||||
eps = 1;
|
||||
}
|
||||
//if (grib2_is_PDTN_EPS(productDefinitionTemplateNumber))
|
||||
// eps = 1;
|
||||
|
||||
switch (localDefinitionNumber) {
|
||||
case 0:
|
||||
|
|
|
@ -328,13 +328,14 @@ static int unpack_long_new(grib_accessor* a, long* val, size_t* len);
|
|||
|
||||
static int unpack_long(grib_accessor* a, long* val, size_t* len)
|
||||
{
|
||||
int ret = GRIB_SUCCESS;
|
||||
int err = GRIB_SUCCESS;
|
||||
long support_legacy = 1;
|
||||
grib_accessor_number_of_points_gaussian* self = (grib_accessor_number_of_points_gaussian*)a;
|
||||
grib_handle* h = grib_handle_of_accessor(a);
|
||||
|
||||
if ((ret = grib_get_long_internal(h, self->support_legacy, &support_legacy)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
if ((err = grib_get_long_internal(h, self->support_legacy, &support_legacy)) != GRIB_SUCCESS)
|
||||
return err;
|
||||
|
||||
if (support_legacy == 1)
|
||||
return unpack_long_with_legacy_support(a, val, len);
|
||||
else
|
||||
|
@ -344,7 +345,7 @@ static int unpack_long(grib_accessor* a, long* val, size_t* len)
|
|||
/* New algorithm */
|
||||
static int unpack_long_new(grib_accessor* a, long* val, size_t* len)
|
||||
{
|
||||
int ret = GRIB_SUCCESS;
|
||||
int err = GRIB_SUCCESS;
|
||||
int is_global = 0;
|
||||
long ni = 0, nj = 0, plpresent = 0, order = 0;
|
||||
size_t plsize = 0;
|
||||
|
@ -360,14 +361,14 @@ static int unpack_long_new(grib_accessor* a, long* val, size_t* len)
|
|||
grib_accessor_number_of_points_gaussian* self = (grib_accessor_number_of_points_gaussian*)a;
|
||||
grib_context* c = a->context;
|
||||
|
||||
if ((ret = grib_get_long_internal(h, self->ni, &ni)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
if ((err = grib_get_long_internal(h, self->ni, &ni)) != GRIB_SUCCESS)
|
||||
return err;
|
||||
|
||||
if ((ret = grib_get_long_internal(h, self->nj, &nj)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
if ((err = grib_get_long_internal(h, self->nj, &nj)) != GRIB_SUCCESS)
|
||||
return err;
|
||||
|
||||
if ((ret = grib_get_long_internal(h, self->plpresent, &plpresent)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
if ((err = grib_get_long_internal(h, self->plpresent, &plpresent)) != GRIB_SUCCESS)
|
||||
return err;
|
||||
|
||||
if (nj == 0)
|
||||
return GRIB_GEOCALCULUS_PROBLEM;
|
||||
|
@ -383,19 +384,19 @@ static int unpack_long_new(grib_accessor* a, long* val, size_t* len)
|
|||
double lon_first_row = 0, lon_last_row = 0;
|
||||
|
||||
/*reduced*/
|
||||
if ((ret = grib_get_long_internal(h, self->order, &order)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
if ((ret = grib_get_double_internal(h, self->lat_first, &lat_first)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
if ((ret = grib_get_double_internal(h, self->lon_first, &lon_first)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
if ((ret = grib_get_double_internal(h, self->lat_last, &lat_last)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
if ((ret = grib_get_double_internal(h, self->lon_last, &lon_last)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
if ((err = grib_get_long_internal(h, self->order, &order)) != GRIB_SUCCESS)
|
||||
return err;
|
||||
if ((err = grib_get_double_internal(h, self->lat_first, &lat_first)) != GRIB_SUCCESS)
|
||||
return err;
|
||||
if ((err = grib_get_double_internal(h, self->lon_first, &lon_first)) != GRIB_SUCCESS)
|
||||
return err;
|
||||
if ((err = grib_get_double_internal(h, self->lat_last, &lat_last)) != GRIB_SUCCESS)
|
||||
return err;
|
||||
if ((err = grib_get_double_internal(h, self->lon_last, &lon_last)) != GRIB_SUCCESS)
|
||||
return err;
|
||||
|
||||
if ((ret = grib_get_size(h, self->pl, &plsize)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
if ((err = grib_get_size(h, self->pl, &plsize)) != GRIB_SUCCESS)
|
||||
return err;
|
||||
|
||||
pl = (long*)grib_context_malloc_clear(c, sizeof(long) * plsize);
|
||||
plsave = pl;
|
||||
|
@ -423,6 +424,10 @@ static int unpack_long_new(grib_accessor* a, long* val, size_t* len)
|
|||
*val = 0;
|
||||
for (j = 0; j < nj; j++) {
|
||||
row_count = 0;
|
||||
if (pl[j] == 0) {
|
||||
grib_context_log(h->context, GRIB_LOG_ERROR, "Invalid pl array: entry at index=%d is zero", j);
|
||||
return GRIB_GEOCALCULUS_PROBLEM;
|
||||
}
|
||||
grib_get_reduced_row_wrapper(h, pl[j], lon_first, lon_last, &row_count, &ilon_first, &ilon_last);
|
||||
lon_first_row = ((ilon_first)*360.0) / pl[j];
|
||||
lon_last_row = ((ilon_last)*360.0) / pl[j];
|
||||
|
@ -445,13 +450,13 @@ static int unpack_long_new(grib_accessor* a, long* val, size_t* len)
|
|||
if (plsave)
|
||||
grib_context_free(c, plsave);
|
||||
|
||||
return ret;
|
||||
return err;
|
||||
}
|
||||
|
||||
/* With Legacy support */
|
||||
static int unpack_long_with_legacy_support(grib_accessor* a, long* val, size_t* len)
|
||||
{
|
||||
int ret = GRIB_SUCCESS;
|
||||
int err = GRIB_SUCCESS;
|
||||
int is_global = 0;
|
||||
long ni = 0, nj = 0, plpresent = 0, order = 0;
|
||||
size_t plsize = 0;
|
||||
|
@ -468,14 +473,14 @@ static int unpack_long_with_legacy_support(grib_accessor* a, long* val, size_t*
|
|||
grib_accessor_number_of_points_gaussian* self = (grib_accessor_number_of_points_gaussian*)a;
|
||||
grib_context* c = a->context;
|
||||
|
||||
if ((ret = grib_get_long_internal(h, self->ni, &ni)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
if ((err = grib_get_long_internal(h, self->ni, &ni)) != GRIB_SUCCESS)
|
||||
return err;
|
||||
|
||||
if ((ret = grib_get_long_internal(h, self->nj, &nj)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
if ((err = grib_get_long_internal(h, self->nj, &nj)) != GRIB_SUCCESS)
|
||||
return err;
|
||||
|
||||
if ((ret = grib_get_long_internal(h, self->plpresent, &plpresent)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
if ((err = grib_get_long_internal(h, self->plpresent, &plpresent)) != GRIB_SUCCESS)
|
||||
return err;
|
||||
|
||||
if (nj == 0)
|
||||
return GRIB_GEOCALCULUS_PROBLEM;
|
||||
|
@ -491,19 +496,19 @@ static int unpack_long_with_legacy_support(grib_accessor* a, long* val, size_t*
|
|||
double lon_first_row = 0, lon_last_row = 0;
|
||||
|
||||
/*reduced*/
|
||||
if ((ret = grib_get_long_internal(h, self->order, &order)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
if ((ret = grib_get_double_internal(h, self->lat_first, &lat_first)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
if ((ret = grib_get_double_internal(h, self->lon_first, &lon_first)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
if ((ret = grib_get_double_internal(h, self->lat_last, &lat_last)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
if ((ret = grib_get_double_internal(h, self->lon_last, &lon_last)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
if ((err = grib_get_long_internal(h, self->order, &order)) != GRIB_SUCCESS)
|
||||
return err;
|
||||
if ((err = grib_get_double_internal(h, self->lat_first, &lat_first)) != GRIB_SUCCESS)
|
||||
return err;
|
||||
if ((err = grib_get_double_internal(h, self->lon_first, &lon_first)) != GRIB_SUCCESS)
|
||||
return err;
|
||||
if ((err = grib_get_double_internal(h, self->lat_last, &lat_last)) != GRIB_SUCCESS)
|
||||
return err;
|
||||
if ((err = grib_get_double_internal(h, self->lon_last, &lon_last)) != GRIB_SUCCESS)
|
||||
return err;
|
||||
|
||||
if ((ret = grib_get_size(h, self->pl, &plsize)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
if ((err = grib_get_size(h, self->pl, &plsize)) != GRIB_SUCCESS)
|
||||
return err;
|
||||
|
||||
pl = (long*)grib_context_malloc_clear(c, sizeof(long) * plsize);
|
||||
plsave = pl;
|
||||
|
@ -543,6 +548,10 @@ static int unpack_long_with_legacy_support(grib_accessor* a, long* val, size_t*
|
|||
#if EFDEBUG
|
||||
printf("-- %d ", j);
|
||||
#endif
|
||||
if (pl[j] == 0) {
|
||||
grib_context_log(h->context, GRIB_LOG_ERROR, "Invalid pl array: entry at index=%d is zero", j);
|
||||
return GRIB_GEOCALCULUS_PROBLEM;
|
||||
}
|
||||
grib_get_reduced_row_wrapper(h, pl[j], lon_first, lon_last, &row_count, &ilon_first, &ilon_last);
|
||||
#if 0
|
||||
if ( row_count != pl[j] ) {
|
||||
|
@ -593,5 +602,5 @@ static int unpack_long_with_legacy_support(grib_accessor* a, long* val, size_t*
|
|||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
return err;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#endif
|
||||
|
||||
#ifdef ENABLE_FLOATING_POINT_EXCEPTIONS
|
||||
#define _GNU_SOURCE
|
||||
#include <fenv.h>
|
||||
int feenableexcept(int excepts);
|
||||
#endif
|
||||
|
@ -643,6 +642,7 @@ static int init_definition_files_dir(grib_context* c)
|
|||
|
||||
/* Note: strtok_r modifies its first argument so we copy */
|
||||
strncpy(path, c->grib_definition_files_path, ECC_PATH_MAXLEN-1);
|
||||
path[ ECC_PATH_MAXLEN - 1 ] = '\0';
|
||||
|
||||
GRIB_MUTEX_INIT_ONCE(&once, &init);
|
||||
GRIB_MUTEX_LOCK(&mutex_c);
|
||||
|
|
|
@ -415,19 +415,19 @@ static grib_math* reador(grib_context* c, char** form, int* err)
|
|||
return p;
|
||||
}
|
||||
|
||||
grib_math* grib_math_clone(grib_context* c, grib_math* m)
|
||||
{
|
||||
grib_math* n = NULL;
|
||||
if (m) {
|
||||
n = (grib_math*)grib_context_malloc(c, sizeof(grib_math));
|
||||
n->arity = m->arity;
|
||||
n->name = strdup(m->name);
|
||||
Assert(n->name);
|
||||
n->left = grib_math_clone(c, m->left);
|
||||
n->right = grib_math_clone(c, m->right);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
// static grib_math* grib_math_clone(grib_context* c, grib_math* m)
|
||||
// {
|
||||
// grib_math* n = NULL;
|
||||
// if (m) {
|
||||
// n = (grib_math*)grib_context_malloc(c, sizeof(grib_math));
|
||||
// n->arity = m->arity;
|
||||
// n->name = strdup(m->name);
|
||||
// Assert(n->name);
|
||||
// n->left = grib_math_clone(c, m->left);
|
||||
// n->right = grib_math_clone(c, m->right);
|
||||
// }
|
||||
// return n;
|
||||
// }
|
||||
|
||||
void grib_math_delete(grib_context* c, grib_math* m)
|
||||
{
|
||||
|
|
|
@ -33,7 +33,7 @@ static const struct table_entry table[] = {
|
|||
|
||||
grib_iterator* grib_iterator_factory(grib_handle* h, grib_arguments* args, unsigned long flags, int* ret)
|
||||
{
|
||||
int i;
|
||||
size_t i = 0;
|
||||
const char* type = (char*)grib_arguments_get_name(h, args, 0);
|
||||
|
||||
for (i = 0; i < NUMBER(table); i++)
|
||||
|
|
|
@ -108,20 +108,20 @@ static int init(grib_nearest* nearest, grib_handle* h, grib_arguments* args)
|
|||
return GRIB_OUT_OF_MEMORY;
|
||||
grib_get_long(h, "global", &self->global);
|
||||
if (!self->global) {
|
||||
int ret;
|
||||
int err;
|
||||
/*TODO longitudeOfFirstGridPointInDegrees from the def file*/
|
||||
if ((ret = grib_get_double(h, "longitudeOfFirstGridPointInDegrees", &self->lon_first)) != GRIB_SUCCESS) {
|
||||
if ((err = grib_get_double(h, "longitudeOfFirstGridPointInDegrees", &self->lon_first)) != GRIB_SUCCESS) {
|
||||
grib_context_log(h->context, GRIB_LOG_ERROR,
|
||||
"grib_nearest_reduced: Unable to get longitudeOfFirstGridPointInDegrees %s\n",
|
||||
grib_get_error_message(ret));
|
||||
return ret;
|
||||
grib_get_error_message(err));
|
||||
return err;
|
||||
}
|
||||
/*TODO longitudeOfLastGridPointInDegrees from the def file*/
|
||||
if ((ret = grib_get_double(h, "longitudeOfLastGridPointInDegrees", &self->lon_last)) != GRIB_SUCCESS) {
|
||||
if ((err = grib_get_double(h, "longitudeOfLastGridPointInDegrees", &self->lon_last)) != GRIB_SUCCESS) {
|
||||
grib_context_log(h->context, GRIB_LOG_ERROR,
|
||||
"grib_nearest_reduced: Unable to get longitudeOfLastGridPointInDegrees %s\n",
|
||||
grib_get_error_message(ret));
|
||||
return ret;
|
||||
grib_get_error_message(err));
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -135,13 +135,16 @@ static int find_global(grib_nearest* nearest, grib_handle* h,
|
|||
double* outlats, double* outlons, double* values,
|
||||
double* distances, int* indexes, size_t* len);
|
||||
|
||||
static int is_legacy(grib_handle* h)
|
||||
static int is_legacy(grib_handle* h, int* legacy)
|
||||
{
|
||||
long is_legacy = 0;
|
||||
return (grib_get_long(h, "legacyGaussSubarea", &is_legacy) == GRIB_SUCCESS && is_legacy == 1);
|
||||
int err = 0;
|
||||
long lLegacy = 0;
|
||||
err = grib_get_long(h, "legacyGaussSubarea", &lLegacy);
|
||||
if (err) return err;
|
||||
*legacy = (int)lLegacy;
|
||||
return GRIB_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static int find(grib_nearest* nearest, grib_handle* h,
|
||||
double inlat, double inlon, unsigned long flags,
|
||||
double* outlats, double* outlons, double* values,
|
||||
|
@ -186,7 +189,7 @@ static int find_global(grib_nearest* nearest, grib_handle* h,
|
|||
double* distances, int* indexes, size_t* len)
|
||||
{
|
||||
grib_nearest_reduced* self = (grib_nearest_reduced*)nearest;
|
||||
int ret = 0, kk = 0, ii = 0;
|
||||
int err = 0, kk = 0, ii = 0;
|
||||
size_t jj = 0;
|
||||
long* pla = NULL;
|
||||
long* pl = NULL;
|
||||
|
@ -198,18 +201,19 @@ static int find_global(grib_nearest* nearest, grib_handle* h,
|
|||
get_reduced_row_proc get_reduced_row_func = &grib_get_reduced_row;
|
||||
|
||||
if (self->legacy == -1 || (flags & GRIB_NEAREST_SAME_GRID) == 0) {
|
||||
self->legacy = is_legacy(h);
|
||||
err = is_legacy(h, &(self->legacy));
|
||||
if (err) return err;
|
||||
}
|
||||
if (self->legacy == 1) {
|
||||
get_reduced_row_func = &grib_get_reduced_row_legacy;
|
||||
}
|
||||
|
||||
if ((ret = grib_get_size(h, self->values_key, &nvalues)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
if ((err = grib_get_size(h, self->values_key, &nvalues)) != GRIB_SUCCESS)
|
||||
return err;
|
||||
nearest->values_count = nvalues;
|
||||
|
||||
if ((ret = grib_nearest_get_radius(h, &radiusInKm)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
if ((err = grib_nearest_get_radius(h, &radiusInKm)) != GRIB_SUCCESS)
|
||||
return err;
|
||||
|
||||
/* Compute lat/lon info, create iterator etc if it's the 1st time or different grid.
|
||||
* This is for performance: if the grid has not changed, we only do this once
|
||||
|
@ -220,13 +224,13 @@ static int find_global(grib_nearest* nearest, grib_handle* h,
|
|||
|
||||
ilat = 0;
|
||||
ilon = 0;
|
||||
if (grib_is_missing(h, self->Nj, &ret)) {
|
||||
if (grib_is_missing(h, self->Nj, &err)) {
|
||||
grib_context_log(h->context, GRIB_LOG_DEBUG, "Key '%s' is missing", self->Nj);
|
||||
return ret ? ret : GRIB_GEOCALCULUS_PROBLEM;
|
||||
return err ? err : GRIB_GEOCALCULUS_PROBLEM;
|
||||
}
|
||||
|
||||
if ((ret = grib_get_long(h, self->Nj, &n)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
if ((err = grib_get_long(h, self->Nj, &n)) != GRIB_SUCCESS)
|
||||
return err;
|
||||
self->lats_count = n;
|
||||
|
||||
if (self->lats)
|
||||
|
@ -243,10 +247,10 @@ static int find_global(grib_nearest* nearest, grib_handle* h,
|
|||
if (!self->lons)
|
||||
return GRIB_OUT_OF_MEMORY;
|
||||
|
||||
iter = grib_iterator_new(h, GRIB_GEOITERATOR_NO_VALUES, &ret);
|
||||
if (ret != GRIB_SUCCESS) {
|
||||
iter = grib_iterator_new(h, GRIB_GEOITERATOR_NO_VALUES, &err);
|
||||
if (err != GRIB_SUCCESS) {
|
||||
grib_context_log(h->context, GRIB_LOG_ERROR, "grib_nearest_reduced: Unable to create lat/lon iterator");
|
||||
return ret;
|
||||
return err;
|
||||
}
|
||||
while (grib_iterator_next(iter, &lat, &lon, NULL)) {
|
||||
if (olat != lat) {
|
||||
|
@ -307,13 +311,13 @@ static int find_global(grib_nearest* nearest, grib_handle* h,
|
|||
&(self->j[0]), &(self->j[1]));
|
||||
|
||||
plsize = self->lats_count;
|
||||
if ((ret = grib_get_size(h, self->pl, &plsize)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
if ((err = grib_get_size(h, self->pl, &plsize)) != GRIB_SUCCESS)
|
||||
return err;
|
||||
pla = (long*)grib_context_malloc(h->context, plsize * sizeof(long));
|
||||
if (!pla)
|
||||
return GRIB_OUT_OF_MEMORY;
|
||||
if ((ret = grib_get_long_array(h, self->pl, pla, &plsize)) != GRIB_SUCCESS)
|
||||
return ret;
|
||||
if ((err = grib_get_long_array(h, self->pl, pla, &plsize)) != GRIB_SUCCESS)
|
||||
return err;
|
||||
|
||||
pl = pla;
|
||||
while ((*pl) == 0) {
|
||||
|
@ -471,8 +475,8 @@ static int find_global(grib_nearest* nearest, grib_handle* h,
|
|||
if (values) {
|
||||
/* See ECC-1403 and ECC-499 */
|
||||
/* Performance: Decode the field once and get all 4 values */
|
||||
ret = grib_get_double_element_set(h, self->values_key, self->k, NUM_NEIGHBOURS, values);
|
||||
if (ret != GRIB_SUCCESS) return ret;
|
||||
err = grib_get_double_element_set(h, self->values_key, self->k, NUM_NEIGHBOURS, values);
|
||||
if (err != GRIB_SUCCESS) return err;
|
||||
}
|
||||
for (jj = 0; jj < 2; jj++) {
|
||||
for (ii = 0; ii < 2; ii++) {
|
||||
|
|
|
@ -213,13 +213,13 @@ static int find(grib_nearest* nearest, grib_handle* h,
|
|||
return GRIB_SUCCESS;
|
||||
}
|
||||
#else
|
||||
static int is_rotated_grid(grib_handle* h)
|
||||
static bool is_rotated_grid(grib_handle* h)
|
||||
{
|
||||
long is_rotated = 0;
|
||||
int err = grib_get_long(h, "isRotatedGrid", &is_rotated);
|
||||
if (!err && is_rotated)
|
||||
return 1;
|
||||
return 0;
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static int find(grib_nearest* nearest, grib_handle* h,
|
||||
|
@ -234,7 +234,7 @@ static int find(grib_nearest* nearest, grib_handle* h,
|
|||
|
||||
grib_iterator* iter = NULL;
|
||||
double lat = 0, lon = 0;
|
||||
const int is_rotated = is_rotated_grid(h);
|
||||
const bool is_rotated = is_rotated_grid(h);
|
||||
double angleOfRotation = 0, southPoleLat = 0, southPoleLon = 0;
|
||||
|
||||
while (inlon < 0)
|
||||
|
|
|
@ -108,7 +108,8 @@ int grib_recompose_name(grib_handle* h, grib_accessor* observer, const char* una
|
|||
snprintf(val, sizeof(val), "undef");
|
||||
}
|
||||
else {
|
||||
grib_context_log(h->context, GRIB_LOG_WARNING, "grib_recompose_name: Problem to recompose filename with : %s ( %s no accessor found)", uname, loc);
|
||||
grib_context_log(h->context, GRIB_LOG_WARNING,
|
||||
"Recompose name: Problem recomposing filename with : %s ( %s no accessor found)", uname, loc);
|
||||
return GRIB_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
|
@ -129,14 +130,15 @@ int grib_recompose_name(grib_handle* h, grib_accessor* observer, const char* una
|
|||
snprintf(val, sizeof(val), "%d", (int)lval);
|
||||
break;
|
||||
default:
|
||||
grib_context_log(h->context, GRIB_LOG_WARNING, "grib_recompose_name: Problem to recompose filename with : %s, invalid type %d", loc, type);
|
||||
grib_context_log(h->context, GRIB_LOG_WARNING,
|
||||
"Recompose name: Problem recomposing filename with %s, invalid type %d", loc, type);
|
||||
break;
|
||||
}
|
||||
|
||||
grib_dependency_add(observer, a);
|
||||
|
||||
if ((ret != GRIB_SUCCESS)) {
|
||||
grib_context_log(h->context, GRIB_LOG_ERROR, "grib_recompose_name: Could not recompose filename : %s", uname);
|
||||
grib_context_log(h->context, GRIB_LOG_ERROR, "Recompose name: Could not recompose filename: %s", uname);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
@ -420,7 +422,7 @@ int grib_accessors_list_print(grib_handle* h, grib_accessors_list* al, const cha
|
|||
break;
|
||||
default:
|
||||
grib_context_log(h->context, GRIB_LOG_WARNING,
|
||||
"grib_accessor_print: Problem printing \"%s\", invalid type %d", a->name, grib_get_type_name(type));
|
||||
"Accessor print: Problem printing \"%s\", invalid type %d", a->name, grib_get_type_name(type));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -496,7 +498,8 @@ int grib_recompose_print(grib_handle* h, grib_accessor* observer, const char* un
|
|||
ret = GRIB_NOT_FOUND;
|
||||
}
|
||||
else {
|
||||
grib_context_log(h->context, GRIB_LOG_WARNING, "grib_recompose_print: Problem to recompose print with : %s, no accessor found", loc);
|
||||
grib_context_log(h->context, GRIB_LOG_WARNING,
|
||||
"Recompose print: Problem recomposing print with : %s, no accessor found", loc);
|
||||
return GRIB_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
|
@ -623,7 +626,7 @@ char* file_being_parsed()
|
|||
int grib_yyerror(const char* msg)
|
||||
{
|
||||
grib_context_log(grib_parser_context, GRIB_LOG_ERROR,
|
||||
"grib_parser: %s at line %d of %s", msg, grib_yylineno + 1, parse_file);
|
||||
"Parser: %s at line %d of %s", msg, grib_yylineno + 1, parse_file);
|
||||
grib_context_log(grib_parser_context, GRIB_LOG_ERROR,
|
||||
"ecCodes Version: %s", ECCODES_VERSION_STR);
|
||||
error = 1;
|
||||
|
@ -658,7 +661,7 @@ void grib_parser_include(const char* included_fname)
|
|||
grib_parser_context->grib_definition_files_path);
|
||||
|
||||
grib_context_log(grib_parser_context, GRIB_LOG_FATAL,
|
||||
"grib_parser_include: Could not resolve '%s' (included in %s)", included_fname, parse_file);
|
||||
"Parser include: Could not resolve '%s' (included in %s)", included_fname, parse_file);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -678,7 +681,7 @@ void grib_parser_include(const char* included_fname)
|
|||
|
||||
if (f == NULL) {
|
||||
char buffer[1024];
|
||||
grib_context_log(grib_parser_context, (GRIB_LOG_ERROR) | (GRIB_LOG_PERROR), "grib_parser_include: cannot open: '%s'", parse_file);
|
||||
grib_context_log(grib_parser_context, (GRIB_LOG_ERROR) | (GRIB_LOG_PERROR), "Parser include: cannot open: '%s'", parse_file);
|
||||
snprintf(buffer, sizeof(buffer), "Cannot include file: '%s'", parse_file);
|
||||
grib_yyerror(buffer);
|
||||
}
|
||||
|
|
110
src/grib_util.cc
110
src/grib_util.cc
|
@ -808,7 +808,7 @@ static const char* get_grid_type_name(const int spec_grid_type)
|
|||
|
||||
static int is_constant_field(const double missingValue, const double* data_values, size_t data_values_count)
|
||||
{
|
||||
int ii = 0;
|
||||
size_t ii = 0;
|
||||
int constant = 1;
|
||||
double value = missingValue;
|
||||
|
||||
|
@ -1716,7 +1716,7 @@ int grib_moments(grib_handle* h, double east, double north, double west, double
|
|||
}
|
||||
#endif
|
||||
|
||||
/* Helper function for 'parse_keyval_string' */
|
||||
// Helper function for 'parse_keyval_string'
|
||||
static void set_value(grib_values* value, char* str, int equal)
|
||||
{
|
||||
char *p = 0, *q = 0, *s = 0;
|
||||
|
@ -1802,14 +1802,14 @@ static void set_value(grib_values* value, char* str, int equal)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
'grib_tool' Optional tool name which is printed on error. Can be NULL
|
||||
'arg' The string to be parsed e.g. key1=value1,key2!=value2 etc (cannot be const)
|
||||
'values_required' If true then each key must have a value after it
|
||||
'default_type' The default type e.g. GRIB_TYPE_UNDEFINED or GRIB_TYPE_DOUBLE
|
||||
'values' The array we populate and return (output)
|
||||
'count' Number of elements (output). Must be initialised to the size of the values array
|
||||
*/
|
||||
//
|
||||
// 'grib_tool' Optional tool name which is printed on error. Can be NULL
|
||||
// 'arg' The string to be parsed e.g. key1=value1,key2!=value2 etc (cannot be const)
|
||||
// 'values_required' If true then each key must have a value after it
|
||||
// 'default_type' The default type e.g. GRIB_TYPE_UNDEFINED or GRIB_TYPE_DOUBLE
|
||||
// 'values' The array we populate and return (output)
|
||||
// 'count' Number of elements (output). Must be initialised to the size of the values array
|
||||
//
|
||||
int parse_keyval_string(const char* grib_tool,
|
||||
char* arg, int values_required, int default_type,
|
||||
grib_values values[], int* count)
|
||||
|
@ -1890,18 +1890,22 @@ int parse_keyval_string(const char* grib_tool,
|
|||
return GRIB_SUCCESS;
|
||||
}
|
||||
|
||||
/* Return 1 if the productDefinitionTemplateNumber (GRIB2) is related to EPS */
|
||||
// Return 1 if the productDefinitionTemplateNumber (GRIB2) is for EPS (ensemble) products
|
||||
int grib2_is_PDTN_EPS(long pdtn)
|
||||
{
|
||||
return (
|
||||
pdtn == 1 || pdtn == 11 ||
|
||||
pdtn == 33 || pdtn == 34 || /*simulated (synthetic) satellite data*/
|
||||
pdtn == 41 || pdtn == 43 || /*atmospheric chemical constituents*/
|
||||
pdtn == 45 || pdtn == 47 || pdtn == 85 /*aerosols*/
|
||||
);
|
||||
#define NUMBER(x) (sizeof(x) / sizeof(x[0]))
|
||||
|
||||
static int eps_pdtns[] = { 1, 11, 33, 34, 41, 43, 45, 47,
|
||||
49, 54, 56, 58, 59, 60, 61, 63, 68, 71, 73, 77, 79,
|
||||
81, 83, 84, 85, 92, 94, 96, 98 };
|
||||
size_t i;
|
||||
for (i = 0; i < NUMBER(eps_pdtns); ++i) {
|
||||
if (eps_pdtns[i] == pdtn) return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Return 1 if the productDefinitionTemplateNumber (GRIB2) is for atmospheric chemical constituents */
|
||||
// Return 1 if the productDefinitionTemplateNumber (GRIB2) is for atmospheric chemical constituents
|
||||
int grib2_is_PDTN_Chemical(long pdtn)
|
||||
{
|
||||
return (
|
||||
|
@ -1911,8 +1915,8 @@ int grib2_is_PDTN_Chemical(long pdtn)
|
|||
pdtn == 43);
|
||||
}
|
||||
|
||||
/* Return 1 if the productDefinitionTemplateNumber (GRIB2) is for
|
||||
* atmospheric chemical constituents with source or sink */
|
||||
// Return 1 if the productDefinitionTemplateNumber (GRIB2) is for
|
||||
// atmospheric chemical constituents with source or sink
|
||||
int grib2_is_PDTN_ChemicalSourceSink(long pdtn)
|
||||
{
|
||||
return (
|
||||
|
@ -1922,8 +1926,8 @@ int grib2_is_PDTN_ChemicalSourceSink(long pdtn)
|
|||
pdtn == 79);
|
||||
}
|
||||
|
||||
/* Return 1 if the productDefinitionTemplateNumber (GRIB2) is for
|
||||
* atmospheric chemical constituents based on a distribution function */
|
||||
// Return 1 if the productDefinitionTemplateNumber (GRIB2) is for
|
||||
// atmospheric chemical constituents based on a distribution function
|
||||
int grib2_is_PDTN_ChemicalDistFunc(long pdtn)
|
||||
{
|
||||
return (
|
||||
|
@ -1933,11 +1937,11 @@ int grib2_is_PDTN_ChemicalDistFunc(long pdtn)
|
|||
pdtn == 68);
|
||||
}
|
||||
|
||||
/* Return 1 if the productDefinitionTemplateNumber (GRIB2) is for aerosols */
|
||||
// Return 1 if the productDefinitionTemplateNumber (GRIB2) is for aerosols
|
||||
int grib2_is_PDTN_Aerosol(long pdtn)
|
||||
{
|
||||
/* Notes: PDT 44 is deprecated and replaced by 48 */
|
||||
/* PDT 47 is deprecated and replaced by 85 */
|
||||
// Notes: PDT 44 is deprecated and replaced by 48
|
||||
// PDT 47 is deprecated and replaced by 85
|
||||
return (
|
||||
pdtn == 44 ||
|
||||
pdtn == 48 ||
|
||||
|
@ -1948,23 +1952,21 @@ int grib2_is_PDTN_Aerosol(long pdtn)
|
|||
pdtn == 85);
|
||||
}
|
||||
|
||||
/* Return 1 if the productDefinitionTemplateNumber (GRIB2) is for optical properties of aerosol */
|
||||
// Return 1 if the productDefinitionTemplateNumber (GRIB2) is for optical properties of aerosol
|
||||
int grib2_is_PDTN_AerosolOptical(long pdtn)
|
||||
{
|
||||
/* Note: PDT 48 can be used for both plain aerosols as well as optical properties of aerosol.
|
||||
* For the former user must set the optical wavelength range to missing.
|
||||
*/
|
||||
// Note: PDT 48 can be used for both plain aerosols as well as optical properties of aerosol.
|
||||
// For the former user must set the optical wavelength range to missing
|
||||
return (
|
||||
pdtn == 48 ||
|
||||
pdtn == 49);
|
||||
}
|
||||
|
||||
/* Given some information about the type of grib2 parameter, return the productDefinitionTemplateNumber to use.
|
||||
* All arguments are booleans (0 or 1)
|
||||
* is_eps: ensemble or deterministic
|
||||
* is_instant: instantaneous or interval-based
|
||||
* etc
|
||||
*/
|
||||
// Given some information about the type of grib2 parameter, return the productDefinitionTemplateNumber to use.
|
||||
// All arguments are booleans (0 or 1)
|
||||
// is_eps: ensemble or deterministic
|
||||
// is_instant: instantaneous or interval-based
|
||||
// etc...
|
||||
int grib2_select_PDTN(int is_eps, int is_instant,
|
||||
int is_chemical,
|
||||
int is_chemical_srcsink,
|
||||
|
@ -1972,8 +1974,8 @@ int grib2_select_PDTN(int is_eps, int is_instant,
|
|||
int is_aerosol,
|
||||
int is_aerosol_optical)
|
||||
{
|
||||
/* At most one has to be set. All could be 0 */
|
||||
/* Unfortunately if PDTN=48 then both aerosol and aerosol_optical can be 1! */
|
||||
// At most one has to be set. All could be 0
|
||||
// Unfortunately if PDTN=48 then both aerosol and aerosol_optical can be 1!
|
||||
const int sum = is_chemical + is_chemical_srcsink + is_chemical_distfn + is_aerosol + is_aerosol_optical;
|
||||
Assert(sum == 0 || sum == 1 || sum == 2);
|
||||
|
||||
|
@ -2026,12 +2028,12 @@ int grib2_select_PDTN(int is_eps, int is_instant,
|
|||
if (is_eps) {
|
||||
if (is_instant)
|
||||
return 49;
|
||||
/* WMO does not have a non-instantaneous case here! */
|
||||
// WMO does not have a non-instantaneous case here!
|
||||
}
|
||||
else {
|
||||
if (is_instant)
|
||||
return 48;
|
||||
/* WMO does not have a non-instantaneous case here! */
|
||||
// WMO does not have a non-instantaneous case here!
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2040,17 +2042,17 @@ int grib2_select_PDTN(int is_eps, int is_instant,
|
|||
if (is_instant)
|
||||
return 45;
|
||||
else
|
||||
return 85; /* PDT 47 is deprecated*/
|
||||
return 85; // PDT 47 is deprecated
|
||||
}
|
||||
else {
|
||||
if (is_instant)
|
||||
return 48; /*44 is deprecated*/
|
||||
return 48; // 44 is deprecated
|
||||
else
|
||||
return 46;
|
||||
}
|
||||
}
|
||||
|
||||
/* Fallthru case: default */
|
||||
// Fallthru case: default
|
||||
if (is_eps) {
|
||||
if (is_instant)
|
||||
return 1;
|
||||
|
@ -2098,7 +2100,7 @@ int grib_check_data_values_range(grib_handle* h, const double min_val, const dou
|
|||
return GRIB_ENCODING_ERROR;
|
||||
}
|
||||
|
||||
/* Data Quality checks */
|
||||
// Data Quality checks
|
||||
if (ctx->grib_data_quality_checks) {
|
||||
result = grib_util_grib_data_quality_check(h, min_val, max_val);
|
||||
}
|
||||
|
@ -2106,10 +2108,10 @@ int grib_check_data_values_range(grib_handle* h, const double min_val, const dou
|
|||
return result;
|
||||
}
|
||||
|
||||
/* Return true(1) if large constant fields are to be created, otherwise false(0) */
|
||||
// Return true(1) if large constant fields are to be created, otherwise false(0)
|
||||
int grib_producing_large_constant_fields(grib_handle* h, int edition)
|
||||
{
|
||||
/* First check if the transient key is set */
|
||||
// First check if the transient key is set
|
||||
grib_context* c = h->context;
|
||||
long produceLargeConstantFields = 0;
|
||||
if (grib_get_long(h, "produceLargeConstantFields", &produceLargeConstantFields) == GRIB_SUCCESS &&
|
||||
|
@ -2121,7 +2123,7 @@ int grib_producing_large_constant_fields(grib_handle* h, int edition)
|
|||
return 1;
|
||||
}
|
||||
|
||||
/* Finally check the environment variable via the context */
|
||||
// Finally check the environment variable via the context
|
||||
return c->large_constant_fields;
|
||||
}
|
||||
|
||||
|
@ -2132,18 +2134,18 @@ int grib_util_grib_data_quality_check(grib_handle* h, double min_val, double max
|
|||
double min_field_value_allowed = 0, max_field_value_allowed = 0;
|
||||
long paramId = 0;
|
||||
grib_context* ctx = h->context;
|
||||
int is_error = 1;
|
||||
bool is_error = true;
|
||||
char description[1024] = {0,};
|
||||
char step[32] = "unknown";
|
||||
size_t len = 32;
|
||||
/*
|
||||
* If grib_data_quality_checks == 1, limits failure results in an error
|
||||
* If grib_data_quality_checks == 2, limits failure results in a warning
|
||||
*/
|
||||
|
||||
// If grib_data_quality_checks == 1, limits failure results in an error
|
||||
// If grib_data_quality_checks == 2, limits failure results in a warning
|
||||
|
||||
Assert(ctx->grib_data_quality_checks == 1 || ctx->grib_data_quality_checks == 2);
|
||||
is_error = (ctx->grib_data_quality_checks == 1);
|
||||
|
||||
/* The limit keys must exist if we are here */
|
||||
// The limit keys must exist if we are here
|
||||
err = grib_get_double(h, "param_value_min", &min_field_value_allowed);
|
||||
if (err) {
|
||||
grib_context_log(ctx, GRIB_LOG_ERROR, "grib_data_quality_check: Could not get param_value_min");
|
||||
|
@ -2177,7 +2179,7 @@ int grib_util_grib_data_quality_check(grib_handle* h, double min_val, double max
|
|||
}
|
||||
}
|
||||
if (is_error) {
|
||||
return GRIB_OUT_OF_RANGE; /* Failure */
|
||||
return GRIB_OUT_OF_RANGE; // Failure
|
||||
}
|
||||
}
|
||||
if (max_val > max_field_value_allowed) {
|
||||
|
@ -2193,7 +2195,7 @@ int grib_util_grib_data_quality_check(grib_handle* h, double min_val, double max
|
|||
}
|
||||
}
|
||||
if (is_error) {
|
||||
return GRIB_OUT_OF_RANGE; /* Failure */
|
||||
return GRIB_OUT_OF_RANGE; // Failure
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -84,6 +84,7 @@ if( HAVE_BUILD_TOOLS )
|
|||
grib_uerra
|
||||
grib_s2s
|
||||
grib_fire
|
||||
# grib_true_imagery
|
||||
grib_element
|
||||
grib_suppressed
|
||||
grib_2nd_order_numValues
|
||||
|
@ -315,7 +316,8 @@ if( HAVE_BUILD_TOOLS )
|
|||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${test}.sh
|
||||
RESOURCES asca_139.t1.ref
|
||||
TEST_DEPENDS eccodes_download_gribs eccodes_download_tigge_gribs
|
||||
eccodes_download_bufrs eccodes_download_metars eccodes_download_gts )
|
||||
eccodes_download_bufrs eccodes_download_bufr_refs
|
||||
eccodes_download_metars eccodes_download_gts )
|
||||
endforeach()
|
||||
|
||||
if( HAVE_FORTRAN AND ENABLE_EXTRA_TESTS )
|
||||
|
@ -352,7 +354,7 @@ if( HAVE_BUILD_TOOLS )
|
|||
TYPE SCRIPT
|
||||
CONDITION NOT ECCODES_ON_WINDOWS AND ENABLE_EXTRA_TESTS
|
||||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bufr_ecc-1288.sh
|
||||
TEST_DEPENDS eccodes_download_bufrs )
|
||||
TEST_DEPENDS eccodes_download_bufrs eccodes_download_bufr_refs )
|
||||
|
||||
|
||||
if( ENABLE_EXTRA_TESTS AND HAVE_ECCODES_THREADS )
|
||||
|
|
|
@ -34,10 +34,14 @@ cat <<EOF
|
|||
#
|
||||
|
||||
. ./include.ctest.sh
|
||||
set -u
|
||||
|
||||
REDIRECT=/dev/null
|
||||
|
||||
label="prod_${TEST_TITLE}_test" # Change prod to bufr or grib etc
|
||||
temp=temp.\$label
|
||||
tempGrib=temp.\$label.grib
|
||||
tempBufr=temp.\$label.bufr
|
||||
tempText=temp.\$label.txt
|
||||
|
||||
sample_grib1=\$ECCODES_SAMPLES_PATH/GRIB1.tmpl
|
||||
sample_grib2=\$ECCODES_SAMPLES_PATH/GRIB2.tmpl
|
||||
sample_bufr3=\$ECCODES_SAMPLES_PATH/BUFR3.tmpl
|
||||
|
@ -48,11 +52,12 @@ sample_bufr4=\$ECCODES_SAMPLES_PATH/BUFR4.tmpl
|
|||
#\${tools_dir}/grib_get
|
||||
#\${tools_dir}/grib_set
|
||||
#grib_check_key_equals \$temp k1,k2 "v1 v2"
|
||||
|
||||
#\${tools_dir}/bufr_get
|
||||
#\${tools_dir}/bufr_set
|
||||
#...
|
||||
|
||||
rm -f \$temp
|
||||
rm -f \$tempText \$tempGrib \$tempBufr
|
||||
EOF
|
||||
|
||||
echo >&2
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
. ./include.ctest.sh
|
||||
|
||||
label="grib_global_test"
|
||||
|
||||
# Check Gaussian grids
|
||||
files_global="
|
||||
reduced_gaussian_lsm.grib1
|
||||
|
@ -49,3 +51,39 @@ for gg in $files_subarea; do
|
|||
filepath=${data_dir}/$gg
|
||||
grib_check_key_equals $filepath "global" 0
|
||||
done
|
||||
|
||||
|
||||
# ECC-1542: Invalid pl array in a Gaussian grid
|
||||
# -----------------------------------------------
|
||||
sample1=$ECCODES_SAMPLES_PATH/reduced_gg_pl_32_grib1.tmpl
|
||||
sample2=$ECCODES_SAMPLES_PATH/reduced_gg_pl_32_grib2.tmpl
|
||||
tempGrib=temp.$label.grib
|
||||
tempText=temp.$label.txt
|
||||
tempFilt=temp.$label.filt
|
||||
|
||||
# Insert a zero into the pl array
|
||||
cat > $tempFilt <<EOF
|
||||
meta pli element(pl, 3);
|
||||
set pli = 0;
|
||||
write;
|
||||
EOF
|
||||
|
||||
${tools_dir}/grib_filter -o $tempGrib $tempFilt $sample2
|
||||
set +e
|
||||
${tools_dir}/grib_get -p numberOfDataPointsExpected $tempGrib > $tempText 2>&1
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
grep -q "Invalid pl array: entry at index=3 is zero" $tempText
|
||||
|
||||
${tools_dir}/grib_filter -o $tempGrib $tempFilt $sample1
|
||||
set +e
|
||||
${tools_dir}/grib_get -l 0,0 $tempGrib > $tempText 2>&1
|
||||
status=$?
|
||||
set -e
|
||||
[ $status -ne 0 ]
|
||||
grep -q "Invalid pl array: entry at index=3 is zero" $tempText
|
||||
|
||||
|
||||
# Clean up
|
||||
rm -f $tempGrib $tempText $tempFilt
|
||||
|
|
|
@ -198,6 +198,14 @@ grib_check_key_equals $temp 'mars.iteration' '23'
|
|||
${tools_dir}/grib_ls -jm $temp > $temp.1
|
||||
grep -q "iteration.* 23" $temp.1
|
||||
|
||||
# ECC-1540: Local Definition 36
|
||||
# --------------------------------
|
||||
${tools_dir}/grib_set -s \
|
||||
setLocalDefinition=1,localDefinitionNumber=36,paramId=210170,class=rd,type=4v,stream=elda \
|
||||
$sample_g2 $temp
|
||||
grib_check_key_exists $temp mars.number,constituentType,sourceSinkChemicalPhysicalProcess
|
||||
${tools_dir}/grib_set -s localDefinitionNumber=36 $temp $temp.1
|
||||
${tools_dir}/grib_compare $temp $temp.1
|
||||
|
||||
# Clean up
|
||||
rm -f $temp $temp.1 $temp.2 $temp.3
|
||||
|
|
|
@ -10,6 +10,11 @@
|
|||
|
||||
. ./include.ctest.sh
|
||||
|
||||
label="grib_proj_string_test"
|
||||
tempGrib=temp.$label.grib
|
||||
tempText=temp.$label.txt
|
||||
grib2_sample=$ECCODES_SAMPLES_PATH/GRIB2.tmpl
|
||||
|
||||
files="
|
||||
mercator.grib2
|
||||
satellite.grib
|
||||
|
@ -39,3 +44,19 @@ for f in `echo $files`; do
|
|||
$PROJ_TOOL $ps
|
||||
fi
|
||||
done
|
||||
|
||||
# Various grids
|
||||
${tools_dir}/grib_set -s gridType=lambert_azimuthal_equal_area $grib2_sample $tempGrib
|
||||
${tools_dir}/grib_get -p projString $tempGrib > $tempText
|
||||
grep -q "proj=laea" $tempText
|
||||
|
||||
${tools_dir}/grib_set -s gridType=lambert $grib2_sample $tempGrib
|
||||
${tools_dir}/grib_get -p projString $tempGrib > $tempText
|
||||
grep -q "proj=lcc" $tempText
|
||||
|
||||
${tools_dir}/grib_set -s gridType=polar_stereographic $grib2_sample $tempGrib
|
||||
${tools_dir}/grib_get -p projString $tempGrib > $tempText
|
||||
grep -q "proj=stere" $tempText
|
||||
|
||||
|
||||
rm -f $tempGrib $tempText
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
#!/bin/sh
|
||||
# (C) Copyright 2005- ECMWF.
|
||||
#
|
||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
||||
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
#
|
||||
# In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
|
||||
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
|
||||
#
|
||||
|
||||
. ./include.ctest.sh
|
||||
|
||||
label="grib_true_imagery_test"
|
||||
temp=temp.$label
|
||||
tempd=temp_dump.$label
|
||||
sample_grib2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl
|
||||
|
||||
latest=30 # TODO
|
||||
|
||||
## PDTN 108 - Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for generic optical products
|
||||
${tools_dir}/grib_set -s tablesVersion=$latest,productDefinitionTemplateNumber=108 $sample_grib2 $temp
|
||||
${tools_dir}/grib_dump -O $temp > $tempd
|
||||
grep -q 'Analysis or forecast at a horizontal level or in a horizontal layer at a point in time for generic optical properties' $tempd
|
||||
grib_check_key_equals $temp typeOfWavelengthInterval,scaledValueOfFirstWavelength,scaledValueOfSecondWavelength "0 0 MISSING"
|
||||
|
||||
## PDTN 109 - Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for generic optical products
|
||||
${tools_dir}/grib_set -s tablesVersion=$latest,productDefinitionTemplateNumber=109 $sample_grib2 $temp
|
||||
${tools_dir}/grib_dump -O $temp > $tempd
|
||||
grep -q 'Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer at a point in time for generic optical properties' $tempd
|
||||
grib_check_key_equals $temp typeOfWavelengthInterval,scaledValueOfFirstWavelength,scaledValueOfSecondWavelength "0 0 MISSING"
|
||||
|
||||
## PDTN 110 - Average, accumulation, extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for generic optical products
|
||||
${tools_dir}/grib_set -s tablesVersion=$latest,productDefinitionTemplateNumber=110 $sample_grib2 $temp
|
||||
${tools_dir}/grib_dump -O $temp > $tempd
|
||||
grep -q 'Average, accumulation, and/or extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for generic optical properties' $tempd
|
||||
grib_check_key_equals $temp typeOfWavelengthInterval,scaledValueOfFirstWavelength,scaledValueOfSecondWavelength "0 0 MISSING"
|
||||
|
||||
## PDTN 111 - Average, accumulation, extreme values or other statistically processed values at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for generic optical products
|
||||
${tools_dir}/grib_set -s tablesVersion=$latest,productDefinitionTemplateNumber=111 $sample_grib2 $temp
|
||||
${tools_dir}/grib_dump -O $temp > $tempd
|
||||
grep -q 'Individual ensemble forecast, control and perturbed, at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval for generic optical properties' $tempd
|
||||
grib_check_key_equals $temp typeOfWavelengthInterval,scaledValueOfFirstWavelength,scaledValueOfSecondWavelength "0 0 MISSING"
|
||||
|
||||
rm -f $temp $tempd
|
1247
tests/unit_tests.cc
1247
tests/unit_tests.cc
File diff suppressed because it is too large
Load Diff
|
@ -48,13 +48,9 @@ static double global_missing_value = 9.9692099683868690e+36; /* See GRIB-953 */
|
|||
|
||||
#define NUMBER(x) (sizeof(x) / sizeof(x[0]))
|
||||
|
||||
typedef int boolean;
|
||||
typedef int err;
|
||||
typedef off_t file_offset;
|
||||
|
||||
static int FALSE = 0;
|
||||
static int TRUE = 1;
|
||||
|
||||
static int files = 0;
|
||||
|
||||
struct value
|
||||
|
@ -85,60 +81,60 @@ struct parameter
|
|||
typedef struct parameter parameter;
|
||||
|
||||
static const char* get_value(const request*, const char* name, int n);
|
||||
static boolean parsedate(const char* name, long* julian, long* second, boolean* isjul);
|
||||
static bool parsedate(const char* name, long* julian, long* second, bool* isjul);
|
||||
|
||||
static boolean eq_string(const char* l, const char* r)
|
||||
static bool eq_string(const char* l, const char* r)
|
||||
{
|
||||
if (l && r)
|
||||
return strcmp(l, r) == 0;
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
static boolean eq_integer(const char* l, const char* r)
|
||||
static bool eq_integer(const char* l, const char* r)
|
||||
{
|
||||
if (l && r)
|
||||
return atol(l) == atol(r);
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
static boolean eq_null(const char* l, const char* r)
|
||||
static bool eq_null(const char* l, const char* r)
|
||||
{
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
static boolean eq_coord(const char* l, const char* r)
|
||||
static bool eq_coord(const char* l, const char* r)
|
||||
{
|
||||
if (l && r)
|
||||
return strcmp(l, r) == 0;
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
static boolean eq_range(const char* l, const char* r)
|
||||
static bool eq_range(const char* l, const char* r)
|
||||
{
|
||||
if (l && r)
|
||||
return strcmp(l, r) == 0;
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
static boolean eq_date(const char* l, const char* r)
|
||||
static bool eq_date(const char* l, const char* r)
|
||||
{
|
||||
if (l && r)
|
||||
return strcmp(l, r) == 0;
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
static boolean eq_param(const char* l, const char* r)
|
||||
static bool eq_param(const char* l, const char* r)
|
||||
{
|
||||
if (l && r)
|
||||
return strcmp(l, r) == 0;
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
static boolean eq_time(const char* l, const char* r)
|
||||
static bool eq_time(const char* l, const char* r)
|
||||
{
|
||||
if (l && r)
|
||||
return strcmp(l, r) == 0;
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
static value* new_value(const char* name)
|
||||
|
@ -175,11 +171,11 @@ static void ecc_reqmerge(parameter* pa, const parameter* pb, request* a)
|
|||
value* va = pa->values;
|
||||
value* last = 0;
|
||||
const char* nb = vb->name;
|
||||
boolean add = TRUE;
|
||||
bool add = true;
|
||||
|
||||
while (va) {
|
||||
if (strcmp(va->name, nb) == 0) {
|
||||
add = FALSE;
|
||||
add = false;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -201,14 +197,14 @@ static void ecc_reqmerge(parameter* pa, const parameter* pb, request* a)
|
|||
}
|
||||
|
||||
/* Fast version if a && b same */
|
||||
static boolean ecc_reqmerge1(request* a, const request* b)
|
||||
static bool ecc_reqmerge1(request* a, const request* b)
|
||||
{
|
||||
parameter* pa = a->params;
|
||||
const parameter* pb = b->params;
|
||||
|
||||
while (pa && pb) {
|
||||
if (strcmp(pa->name, pb->name) != 0)
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
ecc_reqmerge(pa, pb, a);
|
||||
|
||||
|
@ -248,13 +244,13 @@ static const char* parse1(const char* p, int* x, int* n)
|
|||
return p;
|
||||
}
|
||||
|
||||
static boolean is_number(const char* name)
|
||||
static bool is_number(const char* name)
|
||||
{
|
||||
const char* p = name;
|
||||
int x, n;
|
||||
|
||||
if (p == 0 || *p == 0)
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
if (*p == '-')
|
||||
p++;
|
||||
|
@ -263,7 +259,7 @@ static boolean is_number(const char* name)
|
|||
|
||||
p = parse1(p, &x, &n);
|
||||
if (n == 0 && *p != '.')
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
if (*p == '.') {
|
||||
p++;
|
||||
|
@ -278,10 +274,10 @@ static boolean is_number(const char* name)
|
|||
p++;
|
||||
p = parse1(p, &x, &n);
|
||||
if (n == 0)
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
return *p == 0 ? TRUE : FALSE;
|
||||
return *p == 0 ? true : false;
|
||||
}
|
||||
static parameter* new_parameter(char* name, value* v)
|
||||
{
|
||||
|
@ -292,7 +288,7 @@ static parameter* new_parameter(char* name, value* v)
|
|||
return p;
|
||||
}
|
||||
|
||||
static void put_value(request* r, const char* parname, const char* valname, boolean append, boolean unique, boolean ascending)
|
||||
static void put_value(request* r, const char* parname, const char* valname, bool append, bool unique, bool ascending)
|
||||
{
|
||||
parameter* p;
|
||||
value* v;
|
||||
|
@ -393,7 +389,7 @@ static void add_value(request* r, const char* parname, const char* fmt, ...)
|
|||
vsnprintf(buffer, sizeof(buffer), fmt, list);
|
||||
va_end(list);
|
||||
|
||||
put_value(r, parname, buffer, TRUE, FALSE, FALSE);
|
||||
put_value(r, parname, buffer, true, false, false);
|
||||
}
|
||||
|
||||
static void ecc_reqmerge2(request* a, const request* b)
|
||||
|
@ -406,7 +402,7 @@ static void ecc_reqmerge2(request* a, const request* b)
|
|||
if (pa == NULL) {
|
||||
value* v = pb->values;
|
||||
while (v) {
|
||||
put_value(a, pb->name, v->name, TRUE, TRUE, FALSE);
|
||||
put_value(a, pb->name, v->name, true, true, false);
|
||||
v = v->next;
|
||||
}
|
||||
}
|
||||
|
@ -540,7 +536,7 @@ static void set_value(request* r, const char* parname, const char* fmt, ...)
|
|||
vsnprintf(buffer, sizeof(buffer), fmt, list);
|
||||
va_end(list);
|
||||
|
||||
put_value(r, parname, buffer, FALSE, FALSE, FALSE);
|
||||
put_value(r, parname, buffer, false, false, false);
|
||||
}
|
||||
|
||||
static err handle_to_request(request* r, grib_handle* g)
|
||||
|
@ -624,7 +620,7 @@ static err handle_to_request(request* r, grib_handle* g)
|
|||
/*===============================================================================*/
|
||||
/*===============================================================================*/
|
||||
|
||||
typedef boolean (*namecmp)(const char*, const char*);
|
||||
typedef bool (*namecmp)(const char*, const char*);
|
||||
|
||||
typedef struct hypercube
|
||||
{
|
||||
|
@ -682,8 +678,8 @@ typedef struct field
|
|||
|
||||
/* missing fields/values */
|
||||
|
||||
/*boolean is_missing;*/ /* field is missing */
|
||||
boolean has_bitmap; /* field has missing values (= bitmap) */
|
||||
/*bool is_missing;*/ /* field is missing */
|
||||
bool has_bitmap; /* field has missing values (= bitmap) */
|
||||
|
||||
field_request* r;
|
||||
|
||||
|
@ -719,7 +715,7 @@ static const char* get_axis(const hypercube* h, int pos);
|
|||
static const char* get_axis(const hypercube* h, int pos);
|
||||
static int cube_order(const hypercube* h, const request* r);
|
||||
static void free_hypercube(hypercube* h);
|
||||
static int ecc_cube_position(const hypercube* h, const request* r, boolean remove_holes);
|
||||
static int ecc_cube_position(const hypercube* h, const request* r, bool remove_holes);
|
||||
|
||||
static value* clone_one_value(const value* p)
|
||||
{
|
||||
|
@ -1143,14 +1139,14 @@ static request* fieldset_to_request(fieldset* fs)
|
|||
/* hypercube from mars client */
|
||||
/*===============================================================================*/
|
||||
|
||||
static boolean eq_string(const char*, const char*);
|
||||
static boolean eq_integer(const char*, const char*);
|
||||
static boolean eq_range(const char*, const char*);
|
||||
static boolean eq_param(const char*, const char*);
|
||||
static boolean eq_coord(const char*, const char*);
|
||||
static boolean eq_date(const char*, const char*);
|
||||
static boolean eq_time(const char*, const char*);
|
||||
static boolean eq_null(const char*, const char*);
|
||||
static bool eq_string(const char*, const char*);
|
||||
static bool eq_integer(const char*, const char*);
|
||||
static bool eq_range(const char*, const char*);
|
||||
static bool eq_param(const char*, const char*);
|
||||
static bool eq_coord(const char*, const char*);
|
||||
static bool eq_date(const char*, const char*);
|
||||
static bool eq_time(const char*, const char*);
|
||||
static bool eq_null(const char*, const char*);
|
||||
|
||||
static axis_t global_axis[] = {
|
||||
|
||||
|
@ -1319,7 +1315,7 @@ static axis_t global_axis[] = {
|
|||
|
||||
static int axisindex(const char* name)
|
||||
{
|
||||
int i = 0;
|
||||
size_t i = 0;
|
||||
for (i = 0; i < NUMBER(global_axis); i++) {
|
||||
if (strcmp(name, global_axis[i].name) == 0)
|
||||
return i;
|
||||
|
@ -1330,12 +1326,12 @@ static int axisindex(const char* name)
|
|||
static namecmp comparator(const char* name)
|
||||
{
|
||||
static char* dontcompare = NULL;
|
||||
static boolean first = 1;
|
||||
static bool first = 1;
|
||||
int i = 0;
|
||||
|
||||
if (first) {
|
||||
dontcompare = getenv("MARS_DONT_CHECK");
|
||||
first = FALSE;
|
||||
first = false;
|
||||
}
|
||||
|
||||
if (dontcompare != NULL) {
|
||||
|
@ -1460,11 +1456,11 @@ static void valcpy(request* a, request* b, char* aname, char* bname)
|
|||
{
|
||||
parameter* p;
|
||||
if (a && b && (p = find_parameter(b, bname))) {
|
||||
boolean z = FALSE;
|
||||
bool z = false;
|
||||
value* v = p->values;
|
||||
while (v) {
|
||||
put_value(a, aname, v->name, z, FALSE, FALSE);
|
||||
z = TRUE;
|
||||
put_value(a, aname, v->name, z, false, false);
|
||||
z = true;
|
||||
v = v->next;
|
||||
}
|
||||
}
|
||||
|
@ -1521,7 +1517,8 @@ static int count_dimensions(const hypercube* h, const char* axis)
|
|||
|
||||
static int count_hypercube(const request* r)
|
||||
{
|
||||
int i = 0, count = 1;
|
||||
int count = 1;
|
||||
size_t i = 0;
|
||||
for (i = 0; i < NUMBER(global_axis); ++i) {
|
||||
int c = count_values(r, global_axis[i].name);
|
||||
count *= c ? c : 1;
|
||||
|
@ -1532,17 +1529,17 @@ static int count_hypercube(const request* r)
|
|||
|
||||
static int cube_order(const hypercube* h, const request* r)
|
||||
{
|
||||
return ecc_cube_position(h, r, TRUE);
|
||||
return ecc_cube_position(h, r, true);
|
||||
}
|
||||
|
||||
static int cube_position(const hypercube* h, const request* r)
|
||||
{
|
||||
return ecc_cube_position(h, r, FALSE);
|
||||
return ecc_cube_position(h, r, false);
|
||||
}
|
||||
|
||||
static void reserve_index_cache(hypercube* h, int size)
|
||||
{
|
||||
if (size == 0)
|
||||
if (size <= 0)
|
||||
return;
|
||||
|
||||
if (h->index_cache != 0)
|
||||
|
@ -1553,7 +1550,7 @@ static void reserve_index_cache(hypercube* h, int size)
|
|||
h->index_cache_size = size;
|
||||
}
|
||||
|
||||
static int ecc_cube_position(const hypercube* h, const request* r, boolean remove_holes)
|
||||
static int ecc_cube_position(const hypercube* h, const request* r, bool remove_holes)
|
||||
{
|
||||
request* cube = h->cube;
|
||||
int c = count_axis(h);
|
||||
|
@ -1627,7 +1624,7 @@ static void cube_indexes(
|
|||
int k = 0;
|
||||
int count = count_values(cube, axis);
|
||||
int last = h->index_cache[i];
|
||||
const boolean is_time_axis = (strcmp(axis, "time") == 0);
|
||||
const bool is_time_axis = (strcmp(axis, "time") == 0);
|
||||
if (is_time_axis) {
|
||||
Assert(times_array);
|
||||
Assert(times_array_size == count);
|
||||
|
@ -1669,7 +1666,7 @@ static hypercube* new_hypercube(const request* r)
|
|||
{
|
||||
hypercube* h = (hypercube*)calloc(sizeof(hypercube), 1);
|
||||
int total = 0, count = 0;
|
||||
int n = 0;
|
||||
size_t n = 0;
|
||||
const char* val = 0;
|
||||
Assert(h);
|
||||
h->r = clone_one_request(r);
|
||||
|
@ -1850,10 +1847,10 @@ typedef struct filter_type
|
|||
double scale_factor;
|
||||
double add_offset;
|
||||
double missing;
|
||||
boolean bitmap;
|
||||
bool bitmap;
|
||||
ncatt_t att;
|
||||
request* filter_request;
|
||||
boolean scale;
|
||||
bool scale;
|
||||
} dataset_t;
|
||||
|
||||
/*
|
||||
|
@ -1865,19 +1862,19 @@ typedef struct filter_type
|
|||
|
||||
typedef struct ncoptions
|
||||
{
|
||||
boolean usevalidtime; /* Whether to use valid TIME only or not */
|
||||
boolean auto_refdate; /* Automatic Reference Date */
|
||||
bool usevalidtime; /* Whether to use valid TIME only or not */
|
||||
bool auto_refdate; /* Automatic Reference Date */
|
||||
long refdate; /* Reference date */
|
||||
const char* version;
|
||||
|
||||
char* title;
|
||||
char* history;
|
||||
char* unlimited;
|
||||
boolean checkvalidtime;
|
||||
bool checkvalidtime;
|
||||
request* mars_description;
|
||||
boolean mmeans; /* Whether this dataset is Monthly Means */
|
||||
boolean climatology; /* Whether this dataset is climatology */
|
||||
boolean shuffle;
|
||||
bool mmeans; /* Whether this dataset is Monthly Means */
|
||||
bool climatology; /* Whether this dataset is climatology */
|
||||
bool shuffle;
|
||||
long deflate;
|
||||
} ncoptions_t;
|
||||
|
||||
|
@ -2020,7 +2017,7 @@ static void validation_time(request* r)
|
|||
date = atol(p);
|
||||
else {
|
||||
long second = 0;
|
||||
boolean isjul, date_ok;
|
||||
bool isjul, date_ok;
|
||||
date_ok = parsedate(p, &julian, &second, &isjul);
|
||||
if (!date_ok)
|
||||
grib_context_log(ctx, GRIB_LOG_ERROR, "Failed to parse date: '%s'", p);
|
||||
|
@ -2031,9 +2028,9 @@ static void validation_time(request* r)
|
|||
if (strlen(p) == 3) {
|
||||
if (setup.usevalidtime)
|
||||
grib_context_log(ctx, GRIB_LOG_ERROR, "Climatology data. Setting usevalidtime=OFF");
|
||||
setup.auto_refdate = FALSE;
|
||||
setup.usevalidtime = FALSE;
|
||||
setup.climatology = TRUE;
|
||||
setup.auto_refdate = false;
|
||||
setup.usevalidtime = false;
|
||||
setup.climatology = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2103,11 +2100,11 @@ static void get_nc_options(const request* user_r)
|
|||
const char* history = get_value(user_r, "history", 0);
|
||||
const char* unlimited = get_value(user_r, "unlimited", 0);
|
||||
|
||||
setup.shuffle = shuffle ? (strcmp(shuffle, "true") == 0) : FALSE;
|
||||
setup.shuffle = shuffle ? (strcmp(shuffle, "true") == 0) : false;
|
||||
setup.deflate = deflate ? ((strcmp(deflate, "none") == 0) ? -1 : atol(deflate)) : -1;
|
||||
setup.usevalidtime = validtime ? (strcmp(validtime, "true") == 0) : FALSE;
|
||||
setup.usevalidtime = validtime ? (strcmp(validtime, "true") == 0) : false;
|
||||
setup.refdate = refdate ? atol(refdate) : 19000101;
|
||||
setup.auto_refdate = refdate ? (strcmp(get_value(user_r, "referencedate", 0), "AUTOMATIC") == 0) : FALSE;
|
||||
setup.auto_refdate = refdate ? (strcmp(get_value(user_r, "referencedate", 0), "AUTOMATIC") == 0) : false;
|
||||
|
||||
setup.title = title ? grib_context_strdup(ctx, (title)) : NULL;
|
||||
setup.history = history ? grib_context_strdup(ctx, (history)) : NULL;
|
||||
|
@ -2266,7 +2263,7 @@ static int def_latlon(int ncid, fieldset* fs)
|
|||
n = nlats;
|
||||
set_dimension(ncid, "latitude", n, NC_FLOAT, "degrees_north", "latitude");
|
||||
|
||||
/* g->purge_header = TRUE; */
|
||||
/* g->purge_header = true; */
|
||||
release_field(g);
|
||||
|
||||
return e;
|
||||
|
@ -2275,7 +2272,7 @@ static int def_latlon(int ncid, fieldset* fs)
|
|||
static int put_latlon(int ncid, fieldset* fs)
|
||||
{
|
||||
int var_id = 0;
|
||||
int i = 0;
|
||||
size_t i = 0;
|
||||
size_t n = 0;
|
||||
int stat = 0;
|
||||
err e = 0;
|
||||
|
@ -2364,7 +2361,7 @@ static int put_latlon(int ncid, fieldset* fs)
|
|||
stat = nc_put_var_float(ncid, var_id, fvalues);
|
||||
check_err("nc_put_var_float", stat, __LINE__);
|
||||
|
||||
/* g->purge_header = TRUE; */
|
||||
/* g->purge_header = true; */
|
||||
release_field(g);
|
||||
grib_context_free(ctx, fvalues);
|
||||
grib_context_free(ctx, dvalues);
|
||||
|
@ -2378,7 +2375,7 @@ static int compute_scale(dataset_t* subset)
|
|||
double min = DBL_MAX;
|
||||
double median = 0;
|
||||
long i = 0;
|
||||
long j = 0;
|
||||
size_t j = 0;
|
||||
int64_t scaled_max = 0;
|
||||
int64_t scaled_min = 0;
|
||||
int64_t scaled_median = 0;
|
||||
|
@ -2417,7 +2414,7 @@ static int compute_scale(dataset_t* subset)
|
|||
}
|
||||
|
||||
if (g->has_bitmap) {
|
||||
subset->bitmap = TRUE;
|
||||
subset->bitmap = true;
|
||||
for (j = 0; j < len; ++j) {
|
||||
if (vals && vals[j] != global_missing_value) {
|
||||
if (vals[j] > max) max = vals[j];
|
||||
|
@ -2433,7 +2430,7 @@ static int compute_scale(dataset_t* subset)
|
|||
}
|
||||
}
|
||||
}
|
||||
/* g->purge_header = TRUE; */
|
||||
/* g->purge_header = true; */
|
||||
release_field(g);
|
||||
}
|
||||
|
||||
|
@ -2754,7 +2751,7 @@ static int put_data(hypercube* h, int ncid, const char* name, dataset_t* subset)
|
|||
field* f = get_field(fs, 0, expand_mem);
|
||||
|
||||
void* vscaled = NULL;
|
||||
long vscaled_length = 0;
|
||||
size_t vscaled_length = 0;
|
||||
|
||||
long ni;
|
||||
long nj;
|
||||
|
@ -2782,7 +2779,7 @@ static int put_data(hypercube* h, int ncid, const char* name, dataset_t* subset)
|
|||
count[naxis] = nj; /* latitude */
|
||||
count[naxis + 1] = ni; /* longitude */
|
||||
|
||||
/* f->purge_header = TRUE; */
|
||||
/* f->purge_header = true; */
|
||||
release_field(f);
|
||||
|
||||
stat = nc_inq_varid(ncid, name, &dataid);
|
||||
|
@ -2797,7 +2794,7 @@ static int put_data(hypercube* h, int ncid, const char* name, dataset_t* subset)
|
|||
size_t len;
|
||||
static double* vals = NULL;
|
||||
static size_t vals_len = 0;
|
||||
boolean missing = 0;
|
||||
bool missing = 0;
|
||||
|
||||
request* r;
|
||||
int j = 0;
|
||||
|
@ -2821,7 +2818,7 @@ static int put_data(hypercube* h, int ncid, const char* name, dataset_t* subset)
|
|||
}
|
||||
|
||||
#if 0
|
||||
boolean missing = (g->ksec4[0] < 0); /* If negative number of values, field is missing */
|
||||
bool missing = (g->ksec4[0] < 0); /* If negative number of values, field is missing */
|
||||
#endif
|
||||
|
||||
r = field_to_request(g);
|
||||
|
@ -2865,7 +2862,7 @@ static int put_data(hypercube* h, int ncid, const char* name, dataset_t* subset)
|
|||
check_err("nc_put_vara_type", stat, __LINE__);
|
||||
}
|
||||
|
||||
/* g->purge_header = TRUE; */
|
||||
/* g->purge_header = true; */
|
||||
release_field(g);
|
||||
}
|
||||
|
||||
|
@ -2993,7 +2990,7 @@ static int define_netcdf_dimensions(hypercube* h, fieldset* fs, int ncid, datase
|
|||
}
|
||||
|
||||
if (strcmp(axis, "time") == 0) {
|
||||
boolean onedtime = (count_values(cube, "date") == 0 && count_values(cube, "step") == 0);
|
||||
bool onedtime = (count_values(cube, "date") == 0 && count_values(cube, "step") == 0);
|
||||
snprintf(u, sizeof(u), "hours since 0000-00-00 00:00:00.0");
|
||||
longname = "reference_time";
|
||||
if (setup.usevalidtime || onedtime) {
|
||||
|
@ -3370,7 +3367,7 @@ static void print_ignored_keys(FILE* f, request* data)
|
|||
#define NO_TABLE -1
|
||||
#define NO_PARAM 0
|
||||
|
||||
static void paramtable(const char* p, long* param, long* table, boolean paramIdMode)
|
||||
static void paramtable(const char* p, long* param, long* table, bool paramIdMode)
|
||||
{
|
||||
const char* q = p;
|
||||
int len = strlen(p);
|
||||
|
@ -3406,7 +3403,7 @@ static void find_nc_attributes(const request* subset_r, const request* user_r, n
|
|||
{
|
||||
const char* split = NULL;
|
||||
int j = 0;
|
||||
boolean set_param_as_name = TRUE;
|
||||
bool set_param_as_name = true;
|
||||
long datatable = 0; /* = atol(get_value(data_r,"_CODETABLE2",0)); */
|
||||
|
||||
if (count_values(user_r, "split") == 0)
|
||||
|
@ -3415,18 +3412,18 @@ static void find_nc_attributes(const request* subset_r, const request* user_r, n
|
|||
while ((split = get_value(user_r, "split", j++)) != NULL) {
|
||||
if (strcmp(split, "param") != 0) {
|
||||
if (count_values(data_r, split) > 1)
|
||||
set_param_as_name = FALSE;
|
||||
set_param_as_name = false;
|
||||
}
|
||||
}
|
||||
|
||||
j = 0;
|
||||
while ((split = get_value(user_r, "split", j++)) != NULL) {
|
||||
boolean found = FALSE;
|
||||
bool found = false;
|
||||
request* cfg = (request*)config_r;
|
||||
boolean is_param = strcmp(split, "param") == 0;
|
||||
bool is_param = strcmp(split, "param") == 0;
|
||||
/* Only use this parameter in the name if there is more
|
||||
than one value in the original request or if param */
|
||||
boolean setname = ((count_values(data_r, split) > 1) || (is_param && set_param_as_name));
|
||||
bool setname = ((count_values(data_r, split) > 1) || (is_param && set_param_as_name));
|
||||
|
||||
while (cfg) {
|
||||
const char* cfgname = get_value(cfg, "NAME", 0);
|
||||
|
@ -3441,7 +3438,7 @@ static void find_nc_attributes(const request* subset_r, const request* user_r, n
|
|||
|
||||
long cfgparam = atol(cfgval);
|
||||
long dataparam = atol(dataval);
|
||||
paramtable(dataval, &dataparam, &datatable, FALSE);
|
||||
paramtable(dataval, &dataparam, &datatable, false);
|
||||
|
||||
/* If it is not param and they're EXACTLY equal or
|
||||
being param, they're the same parameter and table */
|
||||
|
@ -3473,7 +3470,7 @@ static void find_nc_attributes(const request* subset_r, const request* user_r, n
|
|||
strcat(att->name, "_");
|
||||
strcat(att->name, pname);
|
||||
}
|
||||
found = TRUE;
|
||||
found = true;
|
||||
|
||||
grib_context_log(ctx, GRIB_LOG_DEBUG, "grib_to_netcdf: Var. name found: '%s'", att->name);
|
||||
}
|
||||
|
@ -3516,7 +3513,7 @@ static void reqcb(const request* r, int count, axis_t* names, char* vals[], void
|
|||
w->order = (*n)++;
|
||||
for (i = 0; i < count; i++) {
|
||||
if (vals[i])
|
||||
put_value(w, names[i].name, vals[i], FALSE, FALSE, FALSE);
|
||||
put_value(w, names[i].name, vals[i], false, false, false);
|
||||
}
|
||||
|
||||
if (first == NULL)
|
||||
|
@ -3526,12 +3523,12 @@ static void reqcb(const request* r, int count, axis_t* names, char* vals[], void
|
|||
last = w;
|
||||
}
|
||||
|
||||
static boolean chk_152(int count, axis_t* names, char* vals[])
|
||||
static bool chk_152(int count, axis_t* names, char* vals[])
|
||||
{
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void loop(const request* r, boolean ml, int index, int count, axis_t* strings, char* values[], loopproc callback, void* data)
|
||||
static void loop(const request* r, bool ml, int index, int count, axis_t* strings, char* values[], loopproc callback, void* data)
|
||||
{
|
||||
if (index < count) {
|
||||
parameter* p = find_parameter(r, strings[index].name);
|
||||
|
@ -3560,14 +3557,14 @@ static void values_loop(const request* r, int count, axis_t* parnames, loopproc
|
|||
{
|
||||
char** values = (char**)grib_context_malloc(ctx, sizeof(char*) * count);
|
||||
const char* p = get_value(r, "levtype", 0);
|
||||
boolean ml = (boolean)(p && (strcmp(p, "ml") == 0));
|
||||
bool ml = (bool)(p && (strcmp(p, "ml") == 0));
|
||||
|
||||
if (ml) {
|
||||
p = get_value(r, "expect", 0);
|
||||
if (p && atol(p) != 0) {
|
||||
grib_context_log(ctx, GRIB_LOG_ERROR, "EXPECT provided, special treatment of LNSP");
|
||||
grib_context_log(ctx, GRIB_LOG_ERROR, "and other single level parameters disabled");
|
||||
ml = FALSE;
|
||||
ml = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3622,14 +3619,14 @@ static int split_fieldset(fieldset* fs, request* data_r, dataset_t** subsets, co
|
|||
filters[i].fset = new_fieldset(1);
|
||||
filters[i].count = 0;
|
||||
filters[i].filter_request = clone_one_request(s);
|
||||
filters[i].bitmap = FALSE;
|
||||
/* filters[i].mmeans = FALSE; */
|
||||
filters[i].bitmap = false;
|
||||
/* filters[i].mmeans = false; */
|
||||
|
||||
s = s->next;
|
||||
}
|
||||
|
||||
for (i = 0; i < fs->count; ++i) {
|
||||
boolean ok = FALSE;
|
||||
bool ok = false;
|
||||
field* f = get_field(fs, i, packed_mem);
|
||||
request* g = field_to_request(f);
|
||||
int j = 0;
|
||||
|
@ -3660,13 +3657,13 @@ static int split_fieldset(fieldset* fs, request* data_r, dataset_t** subsets, co
|
|||
print_hypercube(filters[0].filter);
|
||||
exit(1);
|
||||
}
|
||||
/* f->purge_header = TRUE; */
|
||||
/* f->purge_header = true; */
|
||||
release_field(f);
|
||||
}
|
||||
|
||||
for (i = 0; i < count; ++i) {
|
||||
filters[i].att.nctype = nctype;
|
||||
filters[i].scale = TRUE;
|
||||
filters[i].scale = true;
|
||||
filters[i].missing = nc_type_values[nctype].nc_type_missing;
|
||||
find_nc_attributes(filters[i].filter_request, user_r, &(filters[i].att), config_r, data_r);
|
||||
grib_context_log(ctx, GRIB_LOG_DEBUG, "grib_to_netcdf: filter[%d] found.- Var. name '%s', nctype: %d, found nctype: %d", i, filters[i].att.name, nctype, filters[i].att.nctype);
|
||||
|
@ -3680,10 +3677,10 @@ static int split_fieldset(fieldset* fs, request* data_r, dataset_t** subsets, co
|
|||
switch (filters[i].att.nctype) {
|
||||
case NC_FLOAT:
|
||||
case NC_DOUBLE:
|
||||
filters[i].scale = FALSE;
|
||||
filters[i].scale = false;
|
||||
break;
|
||||
default:
|
||||
filters[i].scale = TRUE;
|
||||
filters[i].scale = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -3740,17 +3737,17 @@ static int convert_month(const char* pMonthString)
|
|||
return -1; /*Failed*/
|
||||
}
|
||||
|
||||
static boolean parsedate(const char* name, long* julian, long* second, boolean* isjul)
|
||||
static bool parsedate(const char* name, long* julian, long* second, bool* isjul)
|
||||
{
|
||||
const char* p = name;
|
||||
int n;
|
||||
int y = 0, m = 0, d = 0, H = 0, M = 0, S = 0;
|
||||
|
||||
*julian = *second = 0;
|
||||
*isjul = FALSE;
|
||||
*isjul = false;
|
||||
|
||||
if (p == 0 || *p == 0)
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
/* Special ERA Interim grib1 date format: jul-21, sep-02 etc
|
||||
* See GRIB-416
|
||||
|
@ -3764,29 +3761,29 @@ static boolean parsedate(const char* name, long* julian, long* second, boolean*
|
|||
y = 1900; /* no year specified */
|
||||
m = convert_month(month);
|
||||
if (m == -1)
|
||||
return FALSE;
|
||||
return false;
|
||||
*julian = grib_date_to_julian(y * 10000 + m * 100 + day);
|
||||
*second = 0;
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* year */
|
||||
p = parse1(p, &y, &n);
|
||||
if (n != 2 && n != 4) /* year string must be 2 or 4 characters long: 93 or 1993 */
|
||||
return FALSE;
|
||||
return false;
|
||||
if (*p++ != '-')
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
/* month */
|
||||
p = parse1(p, &m, &n);
|
||||
if (n == 2) {
|
||||
/* day */
|
||||
if (*p++ != '-')
|
||||
return FALSE;
|
||||
return false;
|
||||
p = parse1(p, &d, &n);
|
||||
if (n != 2)
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
else if (n == 3) {
|
||||
long j = grib_date_to_julian(y * 10000 + 101) + m - 1;
|
||||
|
@ -3794,13 +3791,13 @@ static boolean parsedate(const char* name, long* julian, long* second, boolean*
|
|||
/* julian day */;
|
||||
d = j % 100;
|
||||
m = (j % 10000) / 100;
|
||||
*isjul = TRUE;
|
||||
*isjul = true;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
if (m == 0 || m > 12) {
|
||||
return FALSE; /* month out of range */
|
||||
return false; /* month out of range */
|
||||
}
|
||||
|
||||
while (*p && isspace(*p))
|
||||
|
@ -3810,53 +3807,53 @@ static boolean parsedate(const char* name, long* julian, long* second, boolean*
|
|||
p = parse1(p, &H, &n);
|
||||
if (n != 0) {
|
||||
if (n != 2)
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
/* minute */
|
||||
if (*p++ != ':')
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
p = parse1(p, &M, &n);
|
||||
if (n != 2)
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
if (*p != 0) {
|
||||
/* second */
|
||||
if (*p++ != ':')
|
||||
return FALSE;
|
||||
return false;
|
||||
p = parse1(p, &S, &n);
|
||||
if (n != 2)
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
*julian = grib_date_to_julian(y * 10000 + m * 100 + d);
|
||||
*second = H * 3600 + M * 60 + S;
|
||||
|
||||
return *p == 0 ? TRUE : FALSE;
|
||||
return *p == 0 ? true : false;
|
||||
}
|
||||
|
||||
static boolean check_dimension_name(const char* dim)
|
||||
static bool check_dimension_name(const char* dim)
|
||||
{
|
||||
/* Dimension name must begin with an alphabetic character, followed by zero
|
||||
* or more alphanumeric characters including the underscore */
|
||||
int i = 0, len = 0;
|
||||
if (!dim)
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
len = strlen(dim);
|
||||
if (len == 0)
|
||||
return FALSE;
|
||||
return false;
|
||||
if (!isalpha(dim[0]))
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
for (i = 1; i < len; ++i) {
|
||||
const char c = dim[i];
|
||||
const int ok = isalnum(c) || c == '_';
|
||||
if (!ok)
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int get_creation_mode(int option_kind)
|
||||
|
@ -4173,7 +4170,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options, const char* fil
|
|||
|
||||
if (i == 1) {
|
||||
const char* mmeans = get_value(r, "_MONTHLY_MEANS", 0);
|
||||
setup.mmeans = mmeans ? (atol(mmeans) == 1) : FALSE;
|
||||
setup.mmeans = mmeans ? (atol(mmeans) == 1) : false;
|
||||
}
|
||||
fcmonth2nbmonths(r);
|
||||
|
||||
|
@ -4186,7 +4183,7 @@ int grib_tool_new_filename_action(grib_runtime_options* options, const char* fil
|
|||
setup.refdate = atol(p);
|
||||
else {
|
||||
long julian = 0, second = 0;
|
||||
boolean isjul;
|
||||
bool isjul;
|
||||
parsedate(p, &julian, &second, &isjul);
|
||||
setup.refdate = grib_julian_to_date(julian);
|
||||
}
|
||||
|
|
|
@ -21,9 +21,8 @@
|
|||
#endif
|
||||
|
||||
#ifdef ENABLE_FLOATING_POINT_EXCEPTIONS
|
||||
#define _GNU_SOURCE
|
||||
#include <fenv.h>
|
||||
int feenableexcept(int excepts);
|
||||
#include <fenv.h>
|
||||
int feenableexcept(int excepts);
|
||||
#endif
|
||||
|
||||
GRIB_INLINE static int grib_inline_strcmp(const char* a, const char* b)
|
||||
|
@ -672,7 +671,7 @@ static void grib_print_header(grib_runtime_options* options, grib_handle* h)
|
|||
int width;
|
||||
int written_to_dump = 0; /* boolean */
|
||||
if (options->json_output && !options->latlon)
|
||||
return; /* For JSON output we do not print a single header for all msgs */
|
||||
return; // For JSON output we do not print a single header for all msgs
|
||||
if (options->handle_count != 1)
|
||||
return;
|
||||
|
||||
|
@ -713,9 +712,9 @@ static void grib_print_header(grib_runtime_options* options, grib_handle* h)
|
|||
|
||||
static int cmpstringp(const void* p1, const void* p2)
|
||||
{
|
||||
/* The actual arguments to this function are "pointers to
|
||||
pointers to char", but strcmp(3) arguments are "pointers
|
||||
to char", hence the following cast plus dereference */
|
||||
// The actual arguments to this function are "pointers to
|
||||
// pointers to char", but strcmp(3) arguments are "pointers
|
||||
// to char", hence the following cast plus dereference
|
||||
return strcmp(*(char* const*)p1, *(char* const*)p2);
|
||||
}
|
||||
|
||||
|
@ -766,9 +765,7 @@ static void grib_tools_set_print_keys(grib_runtime_options* options, grib_handle
|
|||
grib_keys_iterator_delete(kiter);
|
||||
if (options->print_keys_count == 0 && options->latlon == 0) {
|
||||
int j = 0, k = 0, ns_count = 0;
|
||||
const char* all_namespace_vals[1024] = {
|
||||
NULL,
|
||||
}; /* sorted array containing all namespaces */
|
||||
const char* all_namespace_vals[1024] = {NULL,}; // sorted array containing all namespaces
|
||||
printf("ERROR: namespace \"%s\" does not contain any key.\n", ns);
|
||||
printf("Here are the available namespaces in this message:\n");
|
||||
for (i = 0; i < ACCESSORS_ARRAY_SIZE; i++) {
|
||||
|
@ -788,7 +785,7 @@ static void grib_tools_set_print_keys(grib_runtime_options* options, grib_handle
|
|||
if (all_namespace_vals[i]) {
|
||||
int print_it = 1;
|
||||
if (i > 0 && strcmp(all_namespace_vals[i], all_namespace_vals[i - 1]) == 0) {
|
||||
print_it = 0; /* skip duplicate entries */
|
||||
print_it = 0; // skip duplicate entries
|
||||
}
|
||||
if (print_it)
|
||||
printf("\t%s\n", all_namespace_vals[i]);
|
||||
|
|
|
@ -665,7 +665,7 @@ static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_h
|
|||
save_error(c, name);
|
||||
}
|
||||
if (err1 == GRIB_SUCCESS && err2 == GRIB_SUCCESS && len1 == len2) {
|
||||
int i;
|
||||
size_t i;
|
||||
countdiff = 0;
|
||||
for (i = 0; i < len1; i++)
|
||||
if (lval1[i] != lval2[i])
|
||||
|
@ -726,7 +726,7 @@ static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_h
|
|||
|
||||
if (err1 == GRIB_SUCCESS && err2 == GRIB_SUCCESS) {
|
||||
if (memcmp(uval1, uval2, len1) != 0) {
|
||||
int i;
|
||||
size_t i;
|
||||
for (i = 0; i < len1; i++)
|
||||
if (uval1[i] != uval2[i]) {
|
||||
printInfo(h1);
|
||||
|
@ -735,7 +735,7 @@ static int compare_values(grib_runtime_options* options, grib_handle* h1, grib_h
|
|||
printf("[%s] byte values are different: [%02x] and [%02x]\n",
|
||||
name, uval1[i], uval2[i]);
|
||||
else
|
||||
printf("[%s] byte value %d of %ld are different: [%02x] and [%02x]\n",
|
||||
printf("[%s] byte value %zu of %ld are different: [%02x] and [%02x]\n",
|
||||
name, i, (long)len1, uval1[i], uval2[i]);
|
||||
|
||||
err1 = GRIB_VALUE_MISMATCH;
|
||||
|
|
Loading…
Reference in New Issue