Skip to content

Commit 5fdc370

Browse files
committed
Merge remote-tracking branch 'origin/develop' into feature/mtg2_tablesVersion_switch
2 parents 522bac7 + 9bba27d commit 5fdc370

10 files changed

+7373
-7159
lines changed

Diff for: definitions/grib2/section.4.def

+7-9
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@ alias numberOfCoordinatesValues=NV;
1515
# For table 4.5, code 150 Generalized vertical height coordinate
1616
alias numberOfVerticalGridDescriptors=NV ;
1717

18-
# Product Definition Template Number
19-
2018
transient neitherPresent = 0;
2119

22-
if (centre==7 || centre==46) {
23-
alias disableGrib1LocalSection=true;
24-
}
20+
# if (centre==7 || centre==46) {
21+
# alias disableGrib1LocalSection=true;
22+
# }
2523

2624
concept datasetForLocal(unknown) {
2725
"tigge" = {productionStatusOfProcessedData=4;}
@@ -94,9 +92,9 @@ if (section2Used == 1) {
9492
transient genVertHeightCoords = 0;
9593

9694
if (productDefinitionTemplateNumber >= 32768) {
97-
template productDefinition "grib2/local/[centreForLocal]/template.4.[productDefinitionTemplateNumber:l].def";
95+
template productDefinition "grib2/local/[centreForLocal]/template.4.[productDefinitionTemplateNumber:l].def";
9896
} else {
99-
template productDefinition "grib2/templates/template.4.[productDefinitionTemplateNumber:l].def";
97+
template productDefinition "grib2/templates/template.4.[productDefinitionTemplateNumber:l].def";
10098
}
10199

102100
if (defined(marsStream) && defined(marsType)) {
@@ -130,9 +128,9 @@ if (genVertHeightCoords) {
130128
}
131129
else {
132130
if (NV == 0){
133-
transient PVPresent = 0;
131+
transient PVPresent = 0;
134132
} else {
135-
transient PVPresent = 1;
133+
transient PVPresent = 1;
136134
}
137135
# See GRIB-547
138136
if (PVPresent || NV>0){

Diff for: src/accessor/grib_accessor_class_g2_param_concept_filename.cc

+6-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ void grib_accessor_g2_param_concept_filename_t::init(const long len, grib_argume
1818
grib_accessor_gen_t::init(len, arg);
1919
grib_handle* h = grib_handle_of_accessor(this);
2020

21-
const int numArgs = arg->get_count();
22-
if (numArgs != 3) {
23-
grib_context_log(context_, GRIB_LOG_FATAL, "Accessor %s (key %s): %d arguments provided but expected 3",
24-
class_name_, name_, numArgs);
21+
if (context_->debug) {
22+
const int numArgs = arg->get_count();
23+
if (numArgs != 3) {
24+
grib_context_log(context_, GRIB_LOG_FATAL, "Accessor %s (key %s): %d arguments provided but expected 3",
25+
class_name_, name_, numArgs);
26+
}
2527
}
2628

2729
basename_ = arg->get_string(h, 0);

Diff for: src/accessor/grib_accessor_class_mtg2_switch_default.cc

+7-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@ void grib_accessor_mtg2_switch_default_t::init(const long len, grib_arguments* a
1818
grib_accessor_long_t::init(len, arg);
1919

2020
grib_handle* h = grib_handle_of_accessor(this);
21-
const int numArgs = arg->get_count();
22-
if (numArgs != 4) {
23-
grib_context_log(context_, GRIB_LOG_FATAL, "Accessor %s (key %s): %d arguments provided but expected 4",
24-
class_name_, name_, numArgs);
21+
22+
if (context_->debug) {
23+
const int numArgs = arg->get_count();
24+
if (numArgs != 4) {
25+
grib_context_log(context_, GRIB_LOG_FATAL, "Accessor %s (key %s): %d arguments provided but expected 4",
26+
class_name_, name_, numArgs);
27+
}
2528
}
2629

2730
tablesVersion_ = arg->get_name(h, 0);

Diff for: src/grib_hash_keys.cc

+4,948-4,839
Large diffs are not rendered by default.

Diff for: tests/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ list(APPEND test_c_bins
4646
grib_ecc-1431
4747
grib_ecc-1433
4848
grib_ecc-1764
49+
grib_ecc-2019
4950
bufr_ecc-517
5051
bufr_ecc-1288
5152
bufr_ecc-2011

Diff for: tests/grib_ecc-136.sh

+4
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ set -e
3939
${tools_dir}/grib_set -s typeOfFirstFixedSurface=1 $sample2 $temp1
4040
${tools_dir}/grib_set -s typeOfFirstFixedSurface=103 $sample2 $temp2
4141

42+
# Native type of typeOfFirstFixedSurface is string
43+
grib_check_key_equals $temp1 'typeOfFirstFixedSurface,typeOfFirstFixedSurface:s' 'sfc sfc'
44+
grib_check_key_equals $temp2 'typeOfFirstFixedSurface,typeOfFirstFixedSurface:s' 'sfc sfc'
45+
4246
# This should fail
4347
set +e
4448
${tools_dir}/grib_compare $temp1 $temp2

Diff for: tests/grib_ecc-2019.cc

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* (C) Copyright 2005- ECMWF.
3+
*
4+
* This software is licensed under the terms of the Apache Licence Version 2.0
5+
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6+
*
7+
* In applying this licence, ECMWF does not waive the privileges and immunities granted to it by
8+
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
9+
*/
10+
11+
#undef NDEBUG
12+
#include <assert.h>
13+
#include "eccodes.h"
14+
15+
#define MAX_VAL_LEN 1024
16+
17+
static void check_for_levelist(codes_handle* h, bool should_exist)
18+
{
19+
codes_keys_iterator* kiter = codes_keys_iterator_new(h, 0, "mars");
20+
bool mars_levelist_found = false;
21+
char value[MAX_VAL_LEN];
22+
23+
while (codes_keys_iterator_next(kiter)) {
24+
const char* name = codes_keys_iterator_get_name(kiter);
25+
size_t vlen = MAX_VAL_LEN;
26+
memset(value, 0, vlen);
27+
CODES_CHECK(codes_get_string(h, name, value, &vlen), name);
28+
// printf(" name=%s val=%s\n", name, value);
29+
if (strcmp(name, "levelist")) {
30+
mars_levelist_found = true;
31+
assert( strcmp(value, "42") );
32+
}
33+
}
34+
assert( mars_levelist_found == should_exist );
35+
codes_keys_iterator_delete(kiter);
36+
}
37+
38+
int main(int argc, char* argv[])
39+
{
40+
codes_handle* h = grib_handle_new_from_samples(0, "GRIB2");
41+
size_t alen = 1000;
42+
CODES_CHECK(codes_set_string(h, "typeOfLevel", "isobaricInhPa", &alen), 0);
43+
CODES_CHECK(codes_set_long(h, "level", 42), 0);
44+
//codes_dump_content(h, stdout, "wmo", GRIB_DUMP_FLAG_CODED | GRIB_DUMP_FLAG_OCTET | GRIB_DUMP_FLAG_VALUES | GRIB_DUMP_FLAG_READ_ONLY, 0);
45+
check_for_levelist(h, true);
46+
47+
// TODO(maee): This is related to
48+
// ECC-1898: GRIB: Key 'levelist' persists despite being taken out of the mars namespace
49+
// Once the bug is fixed we should remove the comments
50+
// alen = 1000;
51+
// CODES_CHECK(codes_set_string(h, "typeOfLevel", "surface", &alen), 0);
52+
// CODES_CHECK(codes_set_missing(h, "scaleFactorOfFirstFixedSurface"), 0);
53+
// CODES_CHECK(codes_set_missing(h, "scaledValueOfFirstFixedSurface"), 0);
54+
// check_for_levelist(h, false);
55+
56+
codes_handle_delete(h);
57+
58+
return 0;
59+
}

Diff for: tests/grib_ecc-2019.sh

+2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ grib_check_key_equals $tempGrib mars.levelist "42"
5050
${tools_dir}/grib_set -s typeOfLevel=isobaricInhPa,levelist=900 $sample_grib2 $tempGrib
5151
grib_check_key_equals $tempGrib mars.levelist "900"
5252

53+
# Check keys iterator too
54+
$EXEC $test_dir/grib_ecc-2019
5355

5456
# Clean up
5557
rm -f $tempGrib $tempFilt $tempLog $tempOut $tempRef $tempGribA $tempGribB

Diff for: tests/grib_levtype.sh

+11
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,19 @@ fi
1919

2020
sample2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl
2121
tempGrib=temp.${label}.grib
22+
tempText=temp.${label}.txt
2223
latestAvailable=`${tools_dir}/grib_get -p tablesVersionLatest $sample2`
2324
latestOfficial=`${tools_dir}/grib_get -p tablesVersionLatestOfficial $sample2`
2425

26+
# ECC-1333: levtype should be read-only in GRIB2
27+
set +e
28+
${tools_dir}/grib_set -s mars.levtype=o2d $sample2 $tempGrib 2>$tempText
29+
status=$?
30+
set -e
31+
[ $status -ne 0 ]
32+
grep -q "Value is read only" $tempText
33+
34+
2535
# These level types are S2S ocean parameters and are dealt with differently (See products_s2s.def)
2636
exclude="20 160 169"
2737

@@ -60,3 +70,4 @@ done
6070

6171

6272
rm -f $tempGrib
73+
rm -f $tempText

0 commit comments

Comments
 (0)