Skip to content

Commit 49dc5dd

Browse files
committed
Merge changes from hotfix 2.28.1
2 parents cf72281 + bc105ef commit 49dc5dd

12 files changed

+156
-48
lines changed

definitions/grib1/section.1.def

+4
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ if( indicatorOfTypeOfLevel == 109 ||
112112
{
113113
alias mars.levelist = level;
114114
}
115+
if (indicatorOfTypeOfLevel == 117) {
116+
# See ECC-1081
117+
constant levelFactor = 6;
118+
}
115119

116120
unsigned[1] yearOfCentury : edition_specific;
117121
unsigned[1] month;
+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
1 CRRA Copernicus regional reanalysis
2+
2 CRRA Copernicus regional reanalysis with expver

definitions/grib2/local.crra.2.def

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# CARRA/CERRA local
2+
3+
codetable[2] suiteName "grib2/crra_suiteName.table" : dump;
4+
alias crraSuiteID = suiteName;
5+
6+
ksec1expver[4] experimentVersionNumber = "0002" : dump;
7+
alias marsExpver = experimentVersionNumber ;

definitions/grib2/products_10.def

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# (C) Copyright 2005- ECMWF.
22

33
# Copernicus regional reanalysis (CARRA/CERRA)
4-
constant marsExpver = 'prod';
4+
if (!defined(marsExpver)) {
5+
constant marsExpver = 'prod';
6+
}
57
include "grib2/products_crra.def"

definitions/grib2/products_11.def

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# (C) Copyright 2005- ECMWF.
22

3-
# Copernicus regional reanalysis (CARRA/CERRA)
4-
constant marsExpver = 'test';
3+
# Copernicus regional reanalysis test (CARRA/CERRA)
4+
if (!defined(marsExpver)) {
5+
constant marsExpver = 'test';
6+
}
57
include "grib2/products_crra.def"

experimental/show_compile.sh

+1
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,4 @@ echo
4747
echo "Compilation for C ..."
4848
echo "$CCMP myprog.c $LIBS $INCL"
4949
echo
50+
echo

src/grib_accessor_class_g2level.cc

+6
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len)
292292
long value_first = *val;
293293
long scale_first = 0;
294294
long type_first = 0;
295+
long levelFactor = 1;
295296
char pressure_units[10] = {0,};
296297
size_t pressure_units_len = 10;
297298

@@ -324,6 +325,11 @@ static int pack_long(grib_accessor* a, const long* val, size_t* len)
324325
if (!strcmp(pressure_units, "hPa"))
325326
value_first *= 100;
326327
break;
328+
case 109:
329+
if ((ret = grib_get_long(hand, "levelFactor", &levelFactor)) == GRIB_SUCCESS) {
330+
/* See ECC-1081 */
331+
scale_first = levelFactor;
332+
}
327333

328334
default:
329335
break;

src/grib_util.cc

+6
Original file line numberDiff line numberDiff line change
@@ -990,6 +990,12 @@ grib_handle* grib_util_set_spec2(grib_handle* h,
990990
if (STR_EQUAL(input_packing_type, "grid_ieee")) {
991991
SET_STRING_VALUE("packingType", input_packing_type);
992992
}
993+
if (STR_EQUAL(input_packing_type, "grid_ccsds")) {
994+
setCcsdsPacking = 1;
995+
}
996+
if (STR_EQUAL(input_packing_type, "grid_second_order")) {
997+
setSecondOrder = 1;
998+
}
993999
}
9941000

9951001
/*if ( (*err=check_values(data_values, data_values_count))!=GRIB_SUCCESS ) {

tests/grib_threads_ecc-604.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ GRIB2_INPUTS="
7171
${data_dir}/test_file.grib2
7272
${data_dir}/sample.grib2"
7373

74-
if [ $HAVE_JPEG -eq 1 ]; then
74+
# There is a problem with multi-threading and Jasper versions > 2
75+
if [ $HAVE_JPEG -eq 1 -a $HAVE_LIBJASPER -eq 0 ]; then
7576
echo "Adding extra files (HAVE_JPEG=1)"
7677
GRIB2_INPUTS="${data_dir}/jpeg.grib2 ${data_dir}/reduced_gaussian_surface_jpeg.grib2 "$GRIB2_INPUTS
7778
fi

tests/grib_uerra.sh

+25
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,30 @@ status=$?
7373
set -e
7474
[ $status -ne 0 ]
7575

76+
# ECC-1532
77+
# ---------
78+
# By default crraLocalVersion=1 which does not allow expver to be set
79+
# because it is a constant (prod or test)
80+
set +e
81+
${tools_dir}/grib_set -s \
82+
productionStatusOfProcessedData=10,grib2LocalSectionPresent=1,marsExpver=coco \
83+
$grib2_sample $temp1
84+
status=$?
85+
set -e
86+
[ $status -ne 0 ]
87+
88+
# ECC-1532
89+
# crraLocalVersion=2 has a coded key for experimentVersionNumber
90+
${tools_dir}/grib_set -s \
91+
productionStatusOfProcessedData=10,grib2LocalSectionPresent=1,crraLocalVersion=2,marsExpver=coco \
92+
$grib2_sample $temp1
93+
grib_check_key_equals $temp1 'marsExpver,mars.expver' 'coco coco'
94+
95+
${tools_dir}/grib_set -s \
96+
productionStatusOfProcessedData=11,grib2LocalSectionPresent=1,crraLocalVersion=2,experimentVersionNumber=0078 \
97+
$grib2_sample $temp1
98+
grib_check_key_equals $temp1 'marsExpver,mars.expver' '0078 0078'
99+
100+
76101
# Clean up
77102
rm -f $temp1 $temp2 $tempSample

tests/grib_util_set_spec.cc

+48-35
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,20 @@ static int get_packing_type_code(const char* packingType)
1717
{
1818
int result = GRIB_UTIL_PACKING_TYPE_GRID_SIMPLE;
1919
if (packingType == NULL)
20-
return result;
20+
return GRIB_UTIL_PACKING_TYPE_SAME_AS_INPUT;
2121

2222
if (STR_EQUAL(packingType, "grid_jpeg"))
23-
result = GRIB_UTIL_PACKING_TYPE_JPEG;
24-
if (STR_EQUAL(packingType, "grid_ccsds"))
25-
result = GRIB_UTIL_PACKING_TYPE_CCSDS;
23+
return GRIB_UTIL_PACKING_TYPE_JPEG;
24+
else if (STR_EQUAL(packingType, "grid_ccsds"))
25+
return GRIB_UTIL_PACKING_TYPE_CCSDS;
2626
else if (STR_EQUAL(packingType, "grid_simple"))
27-
result = GRIB_UTIL_PACKING_TYPE_GRID_SIMPLE;
27+
return GRIB_UTIL_PACKING_TYPE_GRID_SIMPLE;
2828
else if (STR_EQUAL(packingType, "grid_second_order"))
29-
result = GRIB_UTIL_PACKING_TYPE_GRID_SECOND_ORDER;
29+
return GRIB_UTIL_PACKING_TYPE_GRID_SECOND_ORDER;
3030
else if (STR_EQUAL(packingType, "grid_ieee"))
31-
result = GRIB_UTIL_PACKING_TYPE_IEEE;
31+
return GRIB_UTIL_PACKING_TYPE_IEEE;
3232

33+
Assert(!"Invalid packingType");
3334
return result;
3435
}
3536

@@ -47,8 +48,8 @@ static void test_reduced_gg(int remove_local_def, int edition, const char* packi
4748
const void* buffer = NULL;
4849
char gridType[128] = {0,};
4950

50-
codes_handle* handle = 0;
51-
codes_handle* finalh = 0;
51+
grib_handle* handle = 0;
52+
grib_handle* finalh = 0;
5253
grib_util_grid_spec spec = {0,};
5354
grib_util_packing_spec packing_spec = {0,};
5455

@@ -70,6 +71,9 @@ static void test_reduced_gg(int remove_local_def, int edition, const char* packi
7071
CODES_CHECK(grib_get_size(handle, "values", &inlen), 0);
7172
values = (double*)malloc(sizeof(double) * inlen);
7273
CODES_CHECK(grib_get_double_array(handle, "values", values, &inlen), 0);
74+
// make sure values are not constant
75+
values[0] = 4.4;
76+
values[1] = 5.5;
7377
for (i = 0; i < inlen; ++i) {
7478
values[i] *= 1.10;
7579
}
@@ -90,7 +94,10 @@ static void test_reduced_gg(int remove_local_def, int edition, const char* packi
9094
packing_spec.packing_type = get_packing_type_code(packingType);
9195
packing_spec.bitsPerValue = 24;
9296
packing_spec.accuracy = GRIB_UTIL_ACCURACY_USE_PROVIDED_BITS_PER_VALUES;
93-
packing_spec.packing = GRIB_UTIL_PACKING_USE_PROVIDED;
97+
if (packingType)
98+
packing_spec.packing = GRIB_UTIL_PACKING_USE_PROVIDED;
99+
else
100+
packing_spec.packing = GRIB_UTIL_PACKING_SAME_AS_INPUT;
94101

95102
/*Extra settings
96103
packing_spec.extra_settings_count++;
@@ -112,7 +119,7 @@ static void test_reduced_gg(int remove_local_def, int edition, const char* packi
112119

113120
/* Try some invalid inputs and check it is handled */
114121
{
115-
codes_handle* h2 = 0;
122+
grib_handle* h2 = 0;
116123
packing_spec.accuracy = 999;
117124
h2 = grib_util_set_spec(handle, &spec, &packing_spec, set_spec_flags, values, outlen, &err);
118125
Assert(err == GRIB_INTERNAL_ERROR);
@@ -158,18 +165,18 @@ static void test_regular_ll(int remove_local_def, int edition, const char* packi
158165
char gridType[128] = {0,};
159166
long input_edition = 0;
160167

161-
codes_handle* handle = 0;
162-
codes_handle* finalh = 0;
168+
grib_handle* handle = 0;
169+
grib_handle* finalh = 0;
163170
grib_util_grid_spec spec = {0,};
164171
grib_util_packing_spec packing_spec = {0,};
165172

166173
Assert(input_filename);
167174
in = fopen(input_filename, "rb");
168175
Assert(in);
169-
handle = codes_handle_new_from_file(0, in, PRODUCT_GRIB, &err);
176+
handle = grib_handle_new_from_file(0, in, &err);
170177
Assert(handle);
171178

172-
CODES_CHECK(codes_get_long(handle, "edition", &input_edition), 0);
179+
CODES_CHECK(grib_get_long(handle, "edition", &input_edition), 0);
173180

174181
CODES_CHECK(grib_get_string(handle, "gridType", gridType, &slen), 0);
175182
if (!STR_EQUAL(gridType, "regular_ll")) {
@@ -180,9 +187,12 @@ static void test_regular_ll(int remove_local_def, int edition, const char* packi
180187
out = fopen(output_filename, "wb");
181188
Assert(out);
182189

183-
CODES_CHECK(codes_get_size(handle, "values", &inlen), 0);
190+
CODES_CHECK(grib_get_size(handle, "values", &inlen), 0);
184191
values = (double*)malloc(sizeof(double) * inlen);
185-
CODES_CHECK(codes_get_double_array(handle, "values", values, &inlen), 0);
192+
CODES_CHECK(grib_get_double_array(handle, "values", values, &inlen), 0);
193+
// make sure values are not constant
194+
values[0] = 4.4;
195+
values[1] = 5.5;
186196

187197
spec.grid_type = GRIB_UTIL_GRID_SPEC_REGULAR_LL;
188198
spec.Nj = 14;
@@ -201,7 +211,10 @@ static void test_regular_ll(int remove_local_def, int edition, const char* packi
201211
packing_spec.packing_type = get_packing_type_code(packingType);
202212
packing_spec.bitsPerValue = 24;
203213
packing_spec.accuracy = GRIB_UTIL_ACCURACY_USE_PROVIDED_BITS_PER_VALUES;
204-
packing_spec.packing = GRIB_UTIL_PACKING_USE_PROVIDED;
214+
if (packingType)
215+
packing_spec.packing = GRIB_UTIL_PACKING_USE_PROVIDED;
216+
else
217+
packing_spec.packing = GRIB_UTIL_PACKING_SAME_AS_INPUT;
205218

206219
packing_spec.extra_settings_count++;
207220
packing_spec.extra_settings[0].type = GRIB_TYPE_LONG;
@@ -215,7 +228,7 @@ static void test_regular_ll(int remove_local_def, int edition, const char* packi
215228
packing_spec.deleteLocalDefinition = 1;
216229
}
217230

218-
finalh = codes_grib_util_set_spec(
231+
finalh = grib_util_set_spec(
219232
handle,
220233
&spec,
221234
&packing_spec,
@@ -232,19 +245,19 @@ static void test_regular_ll(int remove_local_def, int edition, const char* packi
232245
if (input_edition == 1) {
233246
const double expected_lat1 = 60.001;
234247
double lat1 = 0;
235-
CODES_CHECK(codes_get_double(finalh, "latitudeOfFirstGridPointInDegrees", &lat1), 0);
248+
CODES_CHECK(grib_get_double(finalh, "latitudeOfFirstGridPointInDegrees", &lat1), 0);
236249
Assert(fabs(lat1 - expected_lat1) < 1e-10);
237250
}
238251

239252
/* Write out the message to the output file */
240-
CODES_CHECK(codes_get_message(finalh, &buffer, &size), 0);
253+
CODES_CHECK(grib_get_message(finalh, &buffer, &size), 0);
241254
CODES_CHECK(codes_check_message_header(buffer, size, PRODUCT_GRIB), 0);
242255
CODES_CHECK(codes_check_message_footer(buffer, size, PRODUCT_GRIB), 0);
243256
if (fwrite(buffer, 1, size, out) != size) {
244257
Assert(0);
245258
}
246-
codes_handle_delete(handle);
247-
codes_handle_delete(finalh);
259+
grib_handle_delete(handle);
260+
grib_handle_delete(finalh);
248261
free(values);
249262
fclose(in);
250263
fclose(out);
@@ -266,13 +279,13 @@ static void test_grid_complex_spatial_differencing(int remove_local_def, int edi
266279
char gridType[128] = {0,};
267280
double theMax,theMin,theAverage;
268281

269-
codes_handle *handle = 0;
270-
codes_handle *finalh = 0;
282+
grib_handle *handle = 0;
283+
grib_handle *finalh = 0;
271284
grib_util_grid_spec spec={0,};
272285
grib_util_packing_spec packing_spec={0,};
273286

274287
in = fopen(input_filename,"rb"); Assert(in);
275-
handle = codes_handle_new_from_file(0, in, PRODUCT_GRIB, &err); Assert(handle);
288+
handle = grib_handle_new_from_file(0, in, &err); Assert(handle);
276289

277290
CODES_CHECK(grib_get_string(handle, "packingType", gridType, &slen),0);
278291
if (!STR_EQUAL(gridType, "grid_complex_spatial_differencing")) {
@@ -281,13 +294,13 @@ static void test_grid_complex_spatial_differencing(int remove_local_def, int edi
281294
}
282295
out = fopen(output_filename,"wb"); Assert(out);
283296

284-
CODES_CHECK(codes_get_size(handle,"values",&inlen), 0);
297+
CODES_CHECK(grib_get_size(handle,"values",&inlen), 0);
285298
values = (double*)malloc(sizeof(double)*inlen);
286-
CODES_CHECK(codes_get_double_array(handle, "values", values,&inlen), 0);
299+
CODES_CHECK(grib_get_double_array(handle, "values", values,&inlen), 0);
287300

288-
CODES_CHECK(codes_get_double(handle, "max", &theMax),0);
289-
CODES_CHECK(codes_get_double(handle, "min", &theMin),0);
290-
CODES_CHECK(codes_get_double(handle, "average",&theAverage),0);
301+
CODES_CHECK(grib_get_double(handle, "max", &theMax),0);
302+
CODES_CHECK(grib_get_double(handle, "min", &theMin),0);
303+
CODES_CHECK(grib_get_double(handle, "average",&theAverage),0);
291304
printf("inlen=%lu \t max=%g \t min=%g \t avg=%g\n", inlen, theMax, theMin, theAverage);
292305

293306
spec.grid_type = GRIB_UTIL_GRID_SPEC_REGULAR_LL;
@@ -315,7 +328,7 @@ static void test_grid_complex_spatial_differencing(int remove_local_def, int edi
315328
packing_spec.deleteLocalDefinition = 1;
316329
}
317330

318-
finalh = codes_grib_util_set_spec(
331+
finalh = grib_util_set_spec(
319332
handle,
320333
&spec,
321334
&packing_spec,
@@ -327,12 +340,12 @@ static void test_grid_complex_spatial_differencing(int remove_local_def, int edi
327340
Assert(err == 0);
328341

329342
/* Write out the message to the output file */
330-
CODES_CHECK(codes_get_message(finalh, &buffer, &size),0);
343+
CODES_CHECK(grib_get_message(finalh, &buffer, &size),0);
331344
if(fwrite(buffer,1,size,out) != size) {
332345
Assert(0);
333346
}
334-
codes_handle_delete(handle);
335-
codes_handle_delete(finalh);
347+
grib_handle_delete(handle);
348+
grib_handle_delete(finalh);
336349
fclose(in);
337350
fclose(out);
338351
}

0 commit comments

Comments
 (0)