Merge branch 'develop' into feature/mtg2

This commit is contained in:
Sebastien Villaume 2024-10-16 14:06:52 +01:00
commit 76e8e1e82b
27 changed files with 163 additions and 108 deletions

View File

@ -129,6 +129,7 @@
013234|snowDepthWaterEquivalentSdGrib|double|SNOW DEPTH (WATER EQUIVALENT SD GRIB)|m|4|0|14|NA|0|0
013240|airDensity|double|AIR DENSITY|kg m-3|3|0|10|NA|0|0
013241|cape|double|CONVECTIVE AVAILABLE POTENTIAL ENERGY|J/kg|1|0|17|NA|0|0
013242|mucape|long|MOST UNSTABLE CAPE|J/kg|0|0|14|NA|0|0
014200|surfaceSolarRadiationDownwardsSsrdGrib|long|SURFACE SOLAR RADIATION DOWNWARDS (SSRD GRIB)|W m-2 s|-2|0|24|NA|0|0
015202|integratedElectronDensity|double|INTEGRATED ELECTRON DENSITY|m-2|3|13000|12|NA|0|0
015231|atmosphericPathDelayInSatelliteSignal|double|ATMOSPHERIC PATH DELAY IN SATELLITE SIGNAL|m|4|0|15|NA|0|0

View File

@ -110,6 +110,7 @@
013231|largeScalePrecipitation|double|LARGE SCALE PRECIPITATION|kg m-2|1|-1|14|NA|0|0
013240|airDensity|double|AIR DENSITY|kg m-3|3|0|10|NA|0|0
013241|cape|double|CONVECTIVE AVAILABLE POTENTIAL ENERGY|J/kg|1|0|17|NA|0|0
013242|mucape|long|MOST UNSTABLE CAPE|J/kg|0|0|14|NA|0|0
015008|significandOfVolumetricMixingRatio|long|(VAL) SCALED VOLUMETRIC MIXING RATIO|Numeric|0|0|24|NA|0|0
015021|integratedMassDensity|long|(VAL) SCALED INTEGRATED MASS DENSITY|kg m-2|0|0|24|NA|0|0
015042|reflectance|long|(VAL) REFLECTANCE|Numeric|6|0|20|NA|0|0

View File

@ -123,6 +123,7 @@
013234|snowDepthWaterEquivalentSdGrib|double|SNOW DEPTH (WATER EQUIVALENT SD GRIB)|m|4|0|14|NA|0|0
013240|airDensity|double|AIR DENSITY|kg m-3|3|0|10|NA|0|0
013241|cape|double|CONVECTIVE AVAILABLE POTENTIAL ENERGY|J/kg|1|0|17|NA|0|0
013242|mucape|long|MOST UNSTABLE CAPE|J/kg|0|0|14|NA|0|0
014200|surfaceSolarRadiationDownwardsSsrdGrib|long|SURFACE SOLAR RADIATION DOWNWARDS (SSRD GRIB)|W m-2 s|-2|0|24|NA|0|0
015202|integratedElectronDensity|double|INTEGRATED ELECTRON DENSITY|m-2|3|13000|12|NA|0|0
015231|atmosphericPathDelayInSatelliteSignal|double|ATMOSPHERIC PATH DELAY IN SATELLITE SIGNAL|m|4|0|15|NA|0|0

View File

@ -1,11 +1,10 @@
codetable[1] marsClass "mars/class.table" = "od" : dump, string_type, lowercase;
codetable[1] marsClass "mars/class.table" = "od" : dump, string_type, lowercase;
codetable[1] marsType "mars/type.table" = "an" : dump, string_type, lowercase;
codetable[2] marsStream "mars/stream.table" = "oper" : dump, string_type, lowercase ;
codetable[2] marsStream "mars/stream.table" = "oper" : dump, string_type, lowercase;
ksec1expver[4] experimentVersionNumber = "0001" : dump;
#alias typeOfProcessedData=marsType;
alias ls.dataType = marsType;
alias mars.class = marsClass;
alias mars.type = marsType;
alias mars.stream = marsStream;

View File

@ -98,4 +98,4 @@
'road' = {typeOfFirstFixedSurface=187; typeOfSecondFixedSurface=255;}
'roadLayer' = {typeOfFirstFixedSurface=187; typeOfSecondFixedSurface=187;}
'urbanCanyon' = {typeOfFirstFixedSurface=187; typeOfSecondFixedSurface=185;}
'unknown' = {dummy=0;}
'unknown' = {dummyc=1;}

View File

@ -0,0 +1,15 @@
# aliasing MARS date and Time to the date and time defined in local section,
# corresponding to the end of the Ocean NRT data assimilation
alias mars.date = dateOfAnalysis;
alias mars.time = timeOfAnalysis;
# aliasing the new offset date and time to the date and time
# coming fron the section 1, i.e. reference date and time
alias mars.offsetdate = dataDate;
alias mars.offsettime = dataTime;
unalias mars.step;
alias mars.step = stepRange;
if (defined(perturbationNumber)) {
alias mars.number = perturbationNumber;
}

View File

@ -1,5 +1,3 @@
if (class is "ai")
{
if (class is "ai") {
alias mars.step = stepRange;
}

View File

@ -1,17 +1,19 @@
if ((stream is "eehs" or stream is "efhs" or stream is "wees" or stream is "wehs") and (type is "cd")){
if (edition == 1){
# defined in local section 19
alias mars.quantile = quantile;
} else {
meta marsQuantile sprintf("%d:%d",quantileValue,totalNumberOfQuantiles);
alias mars.quantile = marsQuantile;
}
} else {
if (edition == 1){
meta marsQuantile sprintf("%d:%d",perturbationNumber,numberOfForecastsInEnsemble);
alias mars.quantile = marsQuantile;
} else {
meta marsQuantile sprintf("%d:%d",quantileValue,totalNumberOfQuantiles);
alias mars.quantile = marsQuantile;
}
if ((stream is "eehs" or stream is "efhs" or stream is "wees" or stream is "wehs") and (type is "cd")) {
if (edition == 1) {
# defined in local section 19
alias mars.quantile = quantile;
} else {
meta marsQuantile sprintf("%d:%d",quantileValue,totalNumberOfQuantiles);
alias mars.quantile = marsQuantile;
}
}
else
{
if (edition == 1) {
meta marsQuantile sprintf("%d:%d",perturbationNumber,numberOfForecastsInEnsemble);
alias mars.quantile = marsQuantile;
} else {
meta marsQuantile sprintf("%d:%d",quantileValue,totalNumberOfQuantiles);
alias mars.quantile = marsQuantile;
}
}

View File

@ -98,9 +98,7 @@ int grib_accessor_ascii_t::pack_double(const double* v, size_t* len)
int grib_accessor_ascii_t::unpack_long(long* v, size_t* len)
{
char val[1024] = {
0,
};
char val[1024] = {0,};
size_t l = sizeof(val);
size_t i = 0;
char* last = NULL;

View File

@ -175,9 +175,7 @@ int grib_accessor_bufr_data_element_t::unpack_string(char* val, size_t* len)
grib_context* c = context_;
if (type_ != BUFR_DESCRIPTOR_TYPE_STRING) {
char sval[32] = {
0,
};
char sval[32] = {0,};
err = unpack_double(&dval, &dlen);
if (err) return err;
snprintf(sval, sizeof(sval), "%g", dval);
@ -539,9 +537,7 @@ int grib_accessor_bufr_data_element_t::is_missing()
grib_context_free(c, values);
}
else {
char value[MAX_STRING_SIZE] = {
0,
}; /* See ECC-710 */
char value[MAX_STRING_SIZE] = {0,}; /* See ECC-710 */
size = MAX_STRING_SIZE;
err = unpack_string(value, &size);
if (err) return 0; /* TODO: no way of propagating the error up */

View File

@ -85,9 +85,7 @@ static int build_long_array(grib_context* c, grib_handle* h, int compressed,
}
else {
/* uncompressed */
char keystr[32] = {
0,
};
char keystr[32] = {0,};
size_t values_len = 0;
for (i = 0; i < numberOfSubsets; ++i) {
long lVal = 0;
@ -108,21 +106,15 @@ static int build_long_array(grib_context* c, grib_handle* h, int compressed,
int grib_accessor_bufr_extract_datetime_subsets_t::select_datetime()
{
int ret = 0;
long compressed = 0;
grib_handle* h = grib_handle_of_accessor(this);
grib_context* c = h->context;
size_t n;
int ret = 0;
long compressed = 0;
grib_handle* h = grib_handle_of_accessor(this);
grib_context* c = h->context;
double julianStart = 0, julianEnd = 0, julianDT = 0;
char start_str[80] = {
0,
},
end_str[80] = {
0,
},
datetime_str[80] = {
0,
};
char start_str[80] = {0,},
end_str[80] = {0,},
datetime_str[80] = {0,};
long yearRank, monthRank, dayRank, hourRank, minuteRank, secondRank;
long yearStart, monthStart, dayStart, hourStart, minuteStart, secondStart;
long yearEnd, monthEnd, dayEnd, hourEnd, minuteEnd, secondEnd;
@ -196,7 +188,7 @@ int grib_accessor_bufr_extract_datetime_subsets_t::select_datetime()
if (ret) return ret;
/* SECOND: Double array */
n = numberOfSubsets;
size_t n = numberOfSubsets;
second = (double*)grib_context_malloc_clear(c, sizeof(double) * numberOfSubsets);
if (compressed) {
ret = grib_get_double_array(h, secondstr, second, &n);

View File

@ -23,9 +23,7 @@ void grib_accessor_cf_var_name_t::init(const long l, grib_arguments* arg)
int grib_accessor_cf_var_name_t::unpack_string(char* val, size_t* len)
{
grib_handle* h = grib_handle_of_accessor(this);
char defaultKey[256] = {
0,
};
char defaultKey[256] = {0,};
size_t size = sizeof(defaultKey) / sizeof(*defaultKey);
char* pDefaultKey = defaultKey;

View File

@ -33,9 +33,7 @@ void grib_accessor_g1end_of_interval_monthly_t::init(const long l, grib_argument
int grib_accessor_g1end_of_interval_monthly_t::unpack_double(double* val, size_t* len)
{
int ret = 0;
char verifyingMonth[7] = {
0,
};
char verifyingMonth[7] = {0,};
size_t slen = 7;
long year = 0, month = 0, date = 0;
const long mdays[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

View File

@ -1,4 +1,3 @@
/*
* (C) Copyright 2005- ECMWF.
*
@ -46,9 +45,7 @@ int grib_accessor_g2_aerosol_t::pack_long(const long* val, size_t* len)
// long type=-1;
// long stream=-1;
long eps = -1;
char stepType[15] = {
0,
};
char stepType[15] = {0,};
size_t slen = 15;
// int aerosol = *val;
int isInstant = 0;

View File

@ -1,4 +1,3 @@
/*
* (C) Copyright 2005- ECMWF.
*
@ -54,9 +53,7 @@ int grib_accessor_g2_chemical_t::pack_long(const long* val, size_t* len)
// long type=-1;
// long stream=-1;
long eps = -1;
char stepType[15] = {
0,
};
char stepType[15] = {0,};
size_t slen = 15;
// int chemical = *val;
int isInstant = 0;

View File

@ -1,4 +1,3 @@
/*
* (C) Copyright 2005- ECMWF.
*
@ -54,9 +53,7 @@ int grib_accessor_g2_eps_t::pack_long(const long* val, size_t* len)
long stream = -1;
long chemical = -1;
long aerosol = -1;
char stepType[15] = {
0,
};
char stepType[15] = {0,};
size_t slen = 15;
int eps = *val;
int isInstant = 0;

View File

@ -81,9 +81,7 @@ int grib_accessor_g2_mars_labeling_t::extra_set(long val)
{
int ret = 0;
grib_handle* hand = grib_handle_of_accessor(this);
char stepType[30] = {
0,
};
char stepType[30] = {0,};
size_t stepTypelen = 30;
long derivedForecast = -1;
long productDefinitionTemplateNumberNew = -1;

View File

@ -48,9 +48,7 @@ int grib_accessor_local_definition_t::pack_long(const long* val, size_t* len)
long eps = -1;
long chemical = -1;
long aerosol = -1;
char stepType[15] = {
0,
};
char stepType[15] = {0,};
size_t slen = 15;
int localDefinitionNumber = *val;
int isInstant = 0;

View File

@ -32,12 +32,8 @@ void grib_accessor_lookup_t::post_init()
void grib_accessor_lookup_t::dump(grib_dumper* dumper)
{
unsigned char bytes[1024] = {
0,
};
char msg[1024] = {
0,
};
unsigned char bytes[1024] = {0,};
char msg[1024] = {0,};
char buf[2048];
unsigned long v = 0;
@ -59,9 +55,7 @@ void grib_accessor_lookup_t::dump(grib_dumper* dumper)
int grib_accessor_lookup_t::unpack_string(char* v, size_t* len)
{
unsigned char bytes[1024] = {
0,
};
unsigned char bytes[1024] = {0,};
size_t llen = llength_;
unpack_bytes(bytes, &llen);

View File

@ -75,12 +75,21 @@ int grib_accessor_select_step_template_t::pack_long(const long* val, size_t* len
case 47: // ENS aerosol
productDefinitionTemplateNumberNew = 45;
break;
case 67: // DET chemical distrib func
productDefinitionTemplateNumberNew = 57;
break;
case 68: // ENS chemical distrib func
productDefinitionTemplateNumberNew = 58;
break;
case 78: // DET chemical source/sink
productDefinitionTemplateNumberNew = 76;
break;
case 79: // ENS chemical source/sink
productDefinitionTemplateNumberNew = 77;
break;
case 72: // DET post-processing
productDefinitionTemplateNumberNew = 70;
break;
@ -136,12 +145,21 @@ int grib_accessor_select_step_template_t::pack_long(const long* val, size_t* len
case 45: // ENS aerosol
productDefinitionTemplateNumberNew = 85; // 47 is deprecated
break;
case 57: // DET chemical distrib func
productDefinitionTemplateNumberNew = 67;
break;
case 58: // ENS chemical distrib func
productDefinitionTemplateNumberNew = 68;
break;
case 76: // DET chemical source/sink
productDefinitionTemplateNumberNew = 78;
break;
case 77: // ENS chemical source/sink
productDefinitionTemplateNumberNew = 79;
break;
case 70: // DET post-processing
productDefinitionTemplateNumberNew = 72;
break;

View File

@ -733,7 +733,7 @@ int grib_get_long_array_internal(grib_handle* h, const char* name, long* val, si
int grib_get_long_array(const grib_handle* h, const char* name, long* val, size_t* length);
int grib_set_values(grib_handle* h, grib_values* args, size_t count);
int grib_get_nearest_smaller_value(grib_handle* h, const char* name, double val, double* nearest);
void grib_print_values(const char* title, grib_values* values, FILE* out);
void grib_print_values(const char* title, const grib_values* values, FILE* out, int count);
int grib_values_check(grib_handle* h, grib_values* values, int count);
int codes_copy_key(grib_handle* h1, grib_handle* h2, const char* key, int type);
int codes_compare_key(grib_handle* h1, grib_handle* h2, const char* key, int compare_flags);

View File

@ -1801,7 +1801,7 @@ int grib_set_values(grib_handle* h, grib_values* args, size_t count)
if (h->context->debug) {
for (i = 0; i < count; i++) {
grib_print_values("ECCODES DEBUG about to set key/value pair", &args[i], stderr);
grib_print_values("ECCODES DEBUG about to set key/value pair", &args[i], stderr, 1);
}
}
@ -1875,22 +1875,24 @@ int grib_get_nearest_smaller_value(grib_handle* h, const char* name,
return act->nearest_smaller_value(val, nearest);
}
void grib_print_values(const char* title, grib_values* values, FILE* out)
void grib_print_values(const char* title, const grib_values* values, FILE* out, int count)
{
if (values) {
fprintf(out, "%s: %s=", title, values->name);
switch (values->type) {
Assert(values);
for (int i = 0; i < count; ++i) {
const grib_values aVal = values[i];
fprintf(out, "%s: %s=", title, aVal.name);
switch (aVal.type) {
case GRIB_TYPE_LONG:
fprintf(out, "%ld", values->long_value);
fprintf(out, "%ld", aVal.long_value);
break;
case GRIB_TYPE_DOUBLE:
fprintf(out, "%g", values->double_value);
fprintf(out, "%g", aVal.double_value);
break;
case GRIB_TYPE_STRING:
fprintf(out, "%s", values->string_value);
fprintf(out, "%s", aVal.string_value);
break;
}
fprintf(out, " (type=%s)\n", grib_get_type_name(values->type));
fprintf(out, " (type=%s)\n", grib_get_type_name(aVal.type));
}
}

View File

@ -280,6 +280,7 @@ if( HAVE_BUILD_TOOLS )
grib_ecc-1792
grib_ecc-1806
grib_ecc-1907
grib_ecc-1941
grib_modelName
grib_sub_hourly
grib_set_bytes

View File

@ -8,7 +8,6 @@
# virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
#
. ./include.ctest.sh
set -u
label="grib2_templates_test"
@ -32,6 +31,25 @@ awk '$1 !~ /#/ && $1 < 65000 {print $1}' $latest_codetable_file | while read pdt
fi
done
rm -f $tempText
pdtns=$( awk '!/^#/ && $1 < 65000 {print $1}' $latest_codetable_file )
for p in $pdtns; do
$tools_dir/grib_set -s tablesVersion=$latestOfficial,productDefinitionTemplateNumber=$p $sample2 $temp
$tools_dir/grib_dump -O -p section_4 $temp >> $tempText
# Expect the grep to fail and not find 'unknown' in the dump output
set +e
grep -q -i unknown $tempText
status=$?
set -e
if [ $status -ne 1 ]; then
echo "GRIB2 PDTN $p produced a dump with unknown!"
grep -i unknown $tempText
exit 1
fi
done
rm -f $tempText
# ECC-1746
# -------------
$tools_dir/grib_set -s tablesVersion=31,productDefinitionTemplateNumber=34 $sample2 $temp

View File

@ -37,19 +37,21 @@ check_grib_defs()
# -----------------------------------
echo "Check for duplicate encodings"
# -----------------------------------
paramIdFile=$ECCODES_DEFINITION_PATH/grib2/paramId.def
paramIdFiles="$ECCODES_DEFINITION_PATH/grib2/paramId.def $ECCODES_DEFINITION_PATH/grib2/localConcepts/ecmf/paramId.def"
# Flatten the file so we get just the encoding part.
# uniq -d outputs a single copy of each line that is repeated in the input
cat $paramIdFile | tr '\n' ' ' | tr '\t' ' ' | tr '#' '\n' | sed "s/^.* '//" | sed "s/'//" | awk '{$1="";print}' | sort |uniq -d > $tempText
if [ -s "$tempText" ]; then
# File exists and has a size greater than zero
echo "ERROR: Duplicate parameter encoding(s) found in $paramIdFile" >&2
cat $tempText | sed -e 's/ ;/;/g'
exit 1
else
echo "No duplicates in $paramIdFile"
fi
for paramIdFile in $paramIdFiles; do
cat $paramIdFile | tr '\n' ' ' | tr '\t' ' ' | tr '#' '\n' | sed "s/^.* '//" | sed "s/'//" | awk '{$1="";print}' | sort |uniq -d > $tempText
if [ -s "$tempText" ]; then
# File exists and has a size greater than zero
echo "ERROR: Duplicate parameter encoding(s) found in $paramIdFile" >&2
cat $tempText | sed -e 's/ ;/;/g'
exit 1
else
echo "No duplicates in $paramIdFile"
fi
done
# First check the GRIB2 paramId.def and shortName.def
# ----------------------------------------------------

34
tests/grib_ecc-1941.sh Executable file
View File

@ -0,0 +1,34 @@
#!/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
# ------------------------------------------------------------
# This is the test for the JIRA issue ECC-1941
# Setting paramId=131060 fails if typeOfFirstFixedSurface=255
# ------------------------------------------------------------
label="grib_ecc-1941_test"
tempGribA=temp.$label.A.grib
tempGribB=temp.$label.B.grib
sample_grib2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl
${tools_dir}/grib_set -s paramId=131060 $sample_grib2 $tempGribA
grib_check_key_equals $tempGribA paramId,shortName '131060 tpg1'
${tools_dir}/grib_set -s typeOfFirstFixedSurface=255 $sample_grib2 $tempGribA
grib_check_key_equals $tempGribA typeOfLevel unknown
${tools_dir}/grib_set -s paramId=131060 $tempGribA $tempGribB
grib_check_key_equals $tempGribB paramId,shortName '131060 tpg1'
# Clean up
rm -f $tempGribA $tempGribB

View File

@ -486,7 +486,7 @@ static void test_parse_keyval_string()
values_required, GRIB_TYPE_UNDEFINED, values1, &count);
Assert( !err );
Assert( count == 2 );
grib_print_values("print values test: values1", values1, stdout);
grib_print_values("print values test: values1", values1, stdout, count);
Assert( strcmp(values1[0].name, "key1")==0 );
Assert( strcmp(values1[0].string_value, "value1")==0 );
@ -506,7 +506,7 @@ static void test_parse_keyval_string()
values_required, GRIB_TYPE_LONG, values2, &count);
Assert( !err );
Assert( count == 1 );
grib_print_values("print values test: values2", values2, stdout);
grib_print_values("print values test: values2", values2, stdout, count);
Assert( strcmp(values2[0].name, "x")==0 );
Assert( values2[0].long_value == 14 );
Assert( values2[0].equal == 1 );
@ -517,7 +517,7 @@ static void test_parse_keyval_string()
values_required, GRIB_TYPE_DOUBLE, values3, &count);
Assert( !err );
Assert( count == 1 );
grib_print_values("print values test: values3", values3, stdout);
grib_print_values("print values test: values3", values3, stdout, count);
Assert( strcmp(values3[0].name, "mars.level")==0 );
free( (void*)values3[0].name );
}