Merge branch 'develop' into feature/mtg2

This commit is contained in:
shahramn 2024-07-12 14:38:00 +01:00
commit 46f58f42f8
15 changed files with 161 additions and 103 deletions

View File

@ -14,6 +14,11 @@ module load python3
version=$(cat $TMPDIR/eccodes/VERSION)
regression_suite_dir=$TMPDIR/eccodes-regression-tests
mkdir -p $regression_suite_dir
git clone git@github.com:ecmwf/eccodes-regression-tests.git $regression_suite_dir
# cd $regression_suite_dir
cd ~masn/REGRESSION_TESTING/ecCodes
./par-suite.sh -w $TMPDIR/install/eccodes/$version

View File

@ -11293,12 +11293,6 @@
parameterCategory = 19 ;
parameterNumber = 43 ;
}
#Soil moisture
'sm' = {
discipline = 2 ;
parameterCategory = 3 ;
parameterNumber = 19 ;
}
#10 metre u-component of neutral wind
'u10n' = {
discipline = 0 ;

View File

@ -11293,12 +11293,6 @@
parameterCategory = 19 ;
parameterNumber = 43 ;
}
#Soil moisture
'Soil moisture' = {
discipline = 2 ;
parameterCategory = 3 ;
parameterNumber = 19 ;
}
#10 metre u-component of neutral wind
'10 metre u-component of neutral wind' = {
discipline = 0 ;

View File

@ -11293,12 +11293,6 @@
parameterCategory = 19 ;
parameterNumber = 43 ;
}
#Soil moisture
'228039' = {
discipline = 2 ;
parameterCategory = 3 ;
parameterNumber = 19 ;
}
#10 metre u-component of neutral wind
'228131' = {
discipline = 0 ;

View File

@ -11293,12 +11293,6 @@
parameterCategory = 19 ;
parameterNumber = 43 ;
}
#Soil moisture
'sm' = {
discipline = 2 ;
parameterCategory = 3 ;
parameterNumber = 19 ;
}
#10 metre u-component of neutral wind
'u10n' = {
discipline = 0 ;

View File

@ -11293,12 +11293,6 @@
parameterCategory = 19 ;
parameterNumber = 43 ;
}
#Soil moisture
'kg m**-3' = {
discipline = 2 ;
parameterCategory = 3 ;
parameterNumber = 19 ;
}
#10 metre u-component of neutral wind
'm s**-1' = {
discipline = 0 ;

View File

@ -1,2 +0,0 @@

View File

@ -11,23 +11,25 @@
#include "grib_accessor_class_g2_aerosol.h"
grib_accessor_class_g2_aerosol_t _grib_accessor_class_g2_aerosol{"g2_aerosol"};
grib_accessor_class_g2_aerosol_t _grib_accessor_class_g2_aerosol{ "g2_aerosol" };
grib_accessor_class* grib_accessor_class_g2_aerosol = &_grib_accessor_class_g2_aerosol;
void grib_accessor_class_g2_aerosol_t::init(grib_accessor* a, const long l, grib_arguments* c){
void grib_accessor_class_g2_aerosol_t::init(grib_accessor* a, const long l, grib_arguments* c)
{
grib_accessor_class_unsigned_t::init(a, l, c);
grib_accessor_g2_aerosol_t* self = (grib_accessor_g2_aerosol_t*)a;
grib_handle* hand = grib_handle_of_accessor(a);
int n = 0;
grib_handle* hand = grib_handle_of_accessor(a);
int n = 0;
self->productDefinitionTemplateNumber = grib_arguments_get_name(hand, c, n++);
self->stepType = grib_arguments_get_name(hand, c, n++);
self->optical = grib_arguments_get_long(hand, c, n++);
}
int grib_accessor_class_g2_aerosol_t::unpack_long(grib_accessor* a, long* val, size_t* len){
grib_accessor_g2_aerosol_t* self = (grib_accessor_g2_aerosol_t*)a;
int grib_accessor_class_g2_aerosol_t::unpack_long(grib_accessor* a, long* val, size_t* len)
{
grib_accessor_g2_aerosol_t* self = (grib_accessor_g2_aerosol_t*)a;
long productDefinitionTemplateNumber = 0;
grib_get_long(grib_handle_of_accessor(a), self->productDefinitionTemplateNumber, &productDefinitionTemplateNumber);
@ -39,32 +41,31 @@ int grib_accessor_class_g2_aerosol_t::unpack_long(grib_accessor* a, long* val, s
return GRIB_SUCCESS;
}
int grib_accessor_class_g2_aerosol_t::pack_long(grib_accessor* a, const long* val, size_t* len){
grib_accessor_g2_aerosol_t* self = (grib_accessor_g2_aerosol_t*)a;
int grib_accessor_class_g2_aerosol_t::pack_long(grib_accessor* a, const long* val, size_t* len)
{
grib_accessor_g2_aerosol_t* self = (grib_accessor_g2_aerosol_t*)a;
grib_handle* hand = grib_handle_of_accessor(a);
long productDefinitionTemplateNumber = -1;
long productDefinitionTemplateNumberNew = -1;
/*long type=-1;
long stream=-1;*/
//long type=-1;
//long stream=-1;
long eps = -1;
char stepType[15] = {0,};
size_t slen = 15;
/*int aerosol = *val;*/
//int aerosol = *val;
int isInstant = 0;
/*long derivedForecast=-1;*/
//long derivedForecast=-1;
int ret = 0;
if (grib_get_long(hand, self->productDefinitionTemplateNumber, &productDefinitionTemplateNumber) != GRIB_SUCCESS)
return GRIB_SUCCESS;
/*
grib_get_long(hand, self->type,&type);
grib_get_long(hand, self->stream,&stream);
*/
// grib_get_long(hand, self->type,&type);
// grib_get_long(hand, self->stream,&stream);
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"))
@ -75,13 +76,13 @@ int grib_accessor_class_g2_aerosol_t::pack_long(grib_accessor* a, const long* va
productDefinitionTemplateNumberNew = 45;
}
else {
/*productDefinitionTemplateNumberNew = 47; PDT deprecated*/
// productDefinitionTemplateNumberNew = 47; // PDT deprecated
productDefinitionTemplateNumberNew = 85;
}
}
else {
if (isInstant) {
productDefinitionTemplateNumberNew = 48; /*44 is deprecated*/
productDefinitionTemplateNumberNew = 48; // 44 is deprecated
}
else {
productDefinitionTemplateNumberNew = 46;
@ -89,7 +90,7 @@ int grib_accessor_class_g2_aerosol_t::pack_long(grib_accessor* a, const long* va
}
if (self->optical) {
/* Note: There is no interval based template for optical properties of aerosol! */
// Note: There is no interval based template for optical properties of aerosol!
if (eps)
productDefinitionTemplateNumberNew = 49;
else
@ -102,13 +103,14 @@ int grib_accessor_class_g2_aerosol_t::pack_long(grib_accessor* a, const long* va
if (productDefinitionTemplateNumber != productDefinitionTemplateNumberNew) {
grib_set_long(hand, self->productDefinitionTemplateNumber, productDefinitionTemplateNumberNew);
/*if (derivedForecast>=0) grib_set_long(hand, self->derivedForecast,derivedForecast);*/
// if (derivedForecast>=0) grib_set_long(hand, self->derivedForecast,derivedForecast);
}
return 0;
}
int grib_accessor_class_g2_aerosol_t::value_count(grib_accessor* a, long* count){
int grib_accessor_class_g2_aerosol_t::value_count(grib_accessor* a, long* count)
{
*count = 1;
return 0;
}

View File

@ -11,31 +11,33 @@
#include "grib_accessor_class_g2_chemical.h"
grib_accessor_class_g2_chemical_t _grib_accessor_class_g2_chemical{"g2_chemical"};
grib_accessor_class_g2_chemical_t _grib_accessor_class_g2_chemical{ "g2_chemical" };
grib_accessor_class* grib_accessor_class_g2_chemical = &_grib_accessor_class_g2_chemical;
void grib_accessor_class_g2_chemical_t::init(grib_accessor* a, const long l, grib_arguments* c){
void grib_accessor_class_g2_chemical_t::init(grib_accessor* a, const long l, grib_arguments* c)
{
grib_accessor_class_unsigned_t::init(a, l, c);
grib_accessor_g2_chemical_t* self = (grib_accessor_g2_chemical_t*)a;
grib_handle* hand = grib_handle_of_accessor(a);
int n = 0;
grib_handle* hand = grib_handle_of_accessor(a);
int n = 0;
self->productDefinitionTemplateNumber = grib_arguments_get_name(hand, c, n++);
self->stepType = grib_arguments_get_name(hand, c, n++);
self->chemical_type = grib_arguments_get_long(hand, c, n++);
self->chemical_type = grib_arguments_get_long(hand, c, n++);
}
int grib_accessor_class_g2_chemical_t::unpack_long(grib_accessor* a, long* val, size_t* len){
grib_accessor_g2_chemical_t* self = (grib_accessor_g2_chemical_t*)a;
int grib_accessor_class_g2_chemical_t::unpack_long(grib_accessor* a, long* val, size_t* len)
{
grib_accessor_g2_chemical_t* self = (grib_accessor_g2_chemical_t*)a;
long productDefinitionTemplateNumber = 0;
grib_get_long(grib_handle_of_accessor(a), self->productDefinitionTemplateNumber, &productDefinitionTemplateNumber);
/*
* 0 = atmospheric chemical constituents
* 1 = atmospheric chemical constituents based on a distribution function
* 2 = atmospheric chemical constituents with source or sink
*/
// Meaning of self->chemical_type:
// 0 = atmospheric chemical constituents
// 1 = atmospheric chemical constituents based on a distribution function
// 2 = atmospheric chemical constituents with source or sink
//
Assert(self->chemical_type == 0 || self->chemical_type == 1 || self->chemical_type == 2);
if (self->chemical_type == 1)
*val = grib2_is_PDTN_ChemicalDistFunc(productDefinitionTemplateNumber);
@ -47,79 +49,91 @@ int grib_accessor_class_g2_chemical_t::unpack_long(grib_accessor* a, long* val,
return GRIB_SUCCESS;
}
int grib_accessor_class_g2_chemical_t::pack_long(grib_accessor* a, const long* val, size_t* len){
grib_accessor_g2_chemical_t* self = (grib_accessor_g2_chemical_t*)a;
int grib_accessor_class_g2_chemical_t::pack_long(grib_accessor* a, const long* val, size_t* len)
{
grib_accessor_g2_chemical_t* self = (grib_accessor_g2_chemical_t*)a;
grib_handle* hand = grib_handle_of_accessor(a);
long productDefinitionTemplateNumber = -1;
long productDefinitionTemplateNumberNew = -1;
/*long type=-1;
long stream=-1;*/
// long type=-1;
// long stream=-1;
long eps = -1;
char stepType[15] = {0,};
size_t slen = 15;
/*int chemical = *val;*/
// int chemical = *val;
int isInstant = 0;
/*long derivedForecast=-1;*/
// long derivedForecast=-1;
int ret = 0;
if (grib_get_long(hand, self->productDefinitionTemplateNumber, &productDefinitionTemplateNumber) != GRIB_SUCCESS)
return GRIB_SUCCESS;
/*
grib_get_long(hand, self->type,&type);
grib_get_long(hand, self->stream,&stream);
*/
// grib_get_long(hand, self->type,&type);
// grib_get_long(hand, self->stream,&stream);
ret = grib_get_string(hand, self->stepType, stepType, &slen);
Assert(ret == GRIB_SUCCESS);
eps = grib_is_defined(hand, "perturbationNumber");
//eps = grib2_is_PDTN_EPS(productDefinitionTemplateNumber);
// eps = grib2_is_PDTN_EPS(productDefinitionTemplateNumber);
if (!strcmp(stepType, "instant"))
isInstant = 1;
/*
* 0 = atmospheric chemical constituents
* 1 = atmospheric chemical constituents based on a distribution function
* 2 = atmospheric chemical constituents with source or sink
*/
// Meaning of self->chemical_type:
// 0 = atmospheric chemical constituents
// 1 = atmospheric chemical constituents based on a distribution function
// 2 = atmospheric chemical constituents with source or sink
//
Assert(self->chemical_type == 0 || self->chemical_type == 1 || self->chemical_type == 2);
if (eps == 1) {
if (isInstant) {
if (self->chemical_type == 0) productDefinitionTemplateNumberNew=41;
else if (self->chemical_type == 1) productDefinitionTemplateNumberNew=58;
else if (self->chemical_type == 2) productDefinitionTemplateNumberNew=77;
if (self->chemical_type == 0)
productDefinitionTemplateNumberNew = 41;
else if (self->chemical_type == 1)
productDefinitionTemplateNumberNew = 58;
else if (self->chemical_type == 2)
productDefinitionTemplateNumberNew = 77;
}
else {
if (self->chemical_type == 0) productDefinitionTemplateNumberNew=43;
else if (self->chemical_type == 1) productDefinitionTemplateNumberNew=68;
else if (self->chemical_type == 2) productDefinitionTemplateNumberNew=79;
if (self->chemical_type == 0)
productDefinitionTemplateNumberNew = 43;
else if (self->chemical_type == 1)
productDefinitionTemplateNumberNew = 68;
else if (self->chemical_type == 2)
productDefinitionTemplateNumberNew = 79;
}
}
else {
/* deterministic */
// deterministic
if (isInstant) {
if (self->chemical_type == 0) productDefinitionTemplateNumberNew=40;
else if (self->chemical_type == 1) productDefinitionTemplateNumberNew=57;
else if (self->chemical_type == 2) productDefinitionTemplateNumberNew=76;
if (self->chemical_type == 0)
productDefinitionTemplateNumberNew = 40;
else if (self->chemical_type == 1)
productDefinitionTemplateNumberNew = 57;
else if (self->chemical_type == 2)
productDefinitionTemplateNumberNew = 76;
}
else {
if (self->chemical_type == 0) productDefinitionTemplateNumberNew=42;
else if (self->chemical_type == 1) productDefinitionTemplateNumberNew=67;
else if (self->chemical_type == 2) productDefinitionTemplateNumberNew=78;
if (self->chemical_type == 0)
productDefinitionTemplateNumberNew = 42;
else if (self->chemical_type == 1)
productDefinitionTemplateNumberNew = 67;
else if (self->chemical_type == 2)
productDefinitionTemplateNumberNew = 78;
}
}
if (productDefinitionTemplateNumber != productDefinitionTemplateNumberNew) {
grib_set_long(hand, self->productDefinitionTemplateNumber, productDefinitionTemplateNumberNew);
/*if (derivedForecast>=0) grib_set_long(hand, self->derivedForecast,derivedForecast);*/
//if (derivedForecast>=0) grib_set_long(hand, self->derivedForecast,derivedForecast);
}
return 0;
}
int grib_accessor_class_g2_chemical_t::value_count(grib_accessor* a, long* count){
int grib_accessor_class_g2_chemical_t::value_count(grib_accessor* a, long* count)
{
*count = 1;
return 0;
}

View File

@ -101,6 +101,7 @@ static int extra_set(grib_accessor* a, long val)
long is_chemical_srcsink = 0;
long is_aerosol = 0;
long is_aerosol_optical = 0;
long is_wave = 0, is_wave_prange = 0;
grib_get_long(hand, "is_chemical", &is_chemical);
grib_get_long(hand, "is_chemical_srcsink", &is_chemical_srcsink);
@ -108,6 +109,9 @@ static int extra_set(grib_accessor* a, long val)
grib_get_long(hand, "is_aerosol", &is_aerosol);
grib_get_long(hand, "is_aerosol_optical", &is_aerosol_optical);
is_wave = grib_is_defined(hand, "waveDirectionNumber");
is_wave_prange = grib_is_defined(hand, "typeOfWavePeriodInterval");
switch (self->index) {
case 0:
/* class */
@ -287,6 +291,11 @@ static int extra_set(grib_accessor* a, long val)
return GRIB_INTERNAL_ERROR;
}
if (is_wave || is_wave_prange) {
// ECC-1867
productDefinitionTemplateNumberNew = -1; // disable PDT selection
}
if (productDefinitionTemplateNumberNew >= 0) {
grib_get_long(hand, self->productDefinitionTemplateNumber, &productDefinitionTemplateNumber);
if (productDefinitionTemplateNumber != productDefinitionTemplateNumberNew)

View File

@ -413,8 +413,8 @@ int grib_accessor_class_g2end_step_t::unpack_double(grib_accessor* a, double* va
static int pack_long_(grib_accessor* a, const long end_step_value, const long end_step_unit)
{
grib_accessor_g2end_step_t* self = (grib_accessor_g2end_step_t*)a;
grib_handle* h = grib_handle_of_accessor(a);
int err = 0;
grib_handle* h = grib_handle_of_accessor(a);
int err = 0;
long year;
long month;
@ -491,6 +491,13 @@ static int pack_long_(grib_accessor* a, const long end_step_value, const long en
return GRIB_WRONG_STEP;
}
if (!is_date_valid(year, month, day, hour, minute, second)) { // ECC-1866
grib_context_log(h->context, GRIB_LOG_ERROR, "%s:%s: Date/Time is not valid! "
"year=%ld month=%ld day=%ld hour=%ld minute=%ld second=%ld",
a->cclass->name, __func__, year, month, day, hour, minute, second);
return GRIB_DECODING_ERROR;
}
err = grib_datetime_to_julian(year, month, day, hour, minute, second, &dend);
if (err != GRIB_SUCCESS)
return err;

View File

@ -119,6 +119,25 @@ grib_check_key_equals $temp aerosolType,typeOfSizeInterval '0 0'
${tools_dir}/grib_set -s paramId=210072 $tempSample $temp
${tools_dir}/grib_ls -p firstSize,secondSize $temp
# =============================
# Ensemble interval-based
# =============================
tempSample=temp.sample.$label
${tools_dir}/grib_set -s tablesVersion=$latest,productDefinitionTemplateNumber=11,typeOfStatisticalProcessing=1 $sample2 $tempSample
grib_check_key_equals $tempSample stepType,perturbationNumber 'accum 0'
${tools_dir}/grib_set -s is_chemical=1 $tempSample $temp
grib_check_key_equals $temp productDefinitionTemplateNumber '43'
grib_check_key_equals $temp constituentType,perturbationNumber,stepType '0 0 accum'
${tools_dir}/grib_set -s is_chemical_srcsink=1 $tempSample $temp
grib_check_key_equals $temp productDefinitionTemplateNumber '79'
${tools_dir}/grib_set -s is_chemical_distfn=1 $tempSample $temp
grib_check_key_equals $temp productDefinitionTemplateNumber '68'
# ECC-1303: Setting localDefinitionNumber=1 on chemical source/sink
# ------------------------------------------------------------------
${tools_dir}/grib_set -s paramId=228104,setLocalDefinition=1,localDefinitionNumber=1 $sample2 $temp

View File

@ -12,6 +12,8 @@
label="grib2_wave_spectra_test"
temp=temp.$label
tempGribA=temp.$label.A.grib
tempGribB=temp.$label.B.grib
tempSample=temp.$label.tmpl
sample2=$ECCODES_SAMPLES_PATH/GRIB2.tmpl
@ -52,5 +54,18 @@ grib_check_key_equals $temp firstWavelengthInNanometres '12'
grib_check_key_equals $temp firstWavelengthInMetres '1.2e-08'
# ECC-1867: Unexpected PDT change for wave template for ensemble DA streams
sample_ld=$ECCODES_SAMPLES_PATH/reduced_gg_pl_32_grib2.tmpl # Sample with a mars local def
${tools_dir}/grib_set -s tablesVersion=32,productDefinitionTemplateNumber=99,waveFrequencyNumber=14 $sample_ld $tempGribA
${tools_dir}/grib_set -s stream=ewla $tempGribA $tempGribB
grib_check_key_equals $tempGribB productDefinitionTemplateNumber,waveFrequencyNumber '99 14'
${tools_dir}/grib_compare -b marsStream $tempGribA $tempGribB
${tools_dir}/grib_set -s type=em $tempGribA $tempGribB
${tools_dir}/grib_compare -b marsType,typeOfProcessedData,typeOfGeneratingProcess $tempGribA $tempGribB
${tools_dir}/grib_set -s type=es $tempGribA $tempGribB
${tools_dir}/grib_compare -b marsType,typeOfProcessedData,typeOfGeneratingProcess $tempGribA $tempGribB
# Clean up
rm -f $tempSample $temp
rm -f $tempSample $temp $tempGribA $tempGribB

View File

@ -116,8 +116,8 @@ grib_check_key_equals $temp2 level 5
# ${tools_dir}/grib_filter level.filter $sample_g2
# Related to ECC-530: make sure GRIB2 parameters with typeOfSecondFixedSurface
# have correct parameter definitions (grib_set does not cause scale factor/value loss
params="228086 228087 228095 228096 228170 228171 228039 228139"
# have correct parameter definitions (grib_set does not cause scale factor/value loss)
params="228086 228087 228095 228096 228170 228171 228139"
for pid in $params; do
${tools_dir}/grib_set -s paramId=$pid $sample_g2 $temp
grib_check_key_equals $temp paramId $pid

View File

@ -256,9 +256,28 @@ cat >$tempFilt <<EOF
print "[typeOfStatisticalProcessing]";
EOF
${tools_dir}/grib_filter $tempFilt $ECCODES_SAMPLES_PATH/GRIB2.tmpl > $tempLog
cat $tempLog
grep -q "255 8 7" $tempLog
# ECC-1866: Setting step on interval-based message with dataDate=0000
# -------------------------------------------------------------------
tempGrbA=${data_dir}/temp.$label.A.grib
tempGrbB=${data_dir}/temp.$label.B.grib
${tools_dir}/grib_set -s stepType=accum $ECCODES_SAMPLES_PATH/GRIB2.tmpl $tempGrbA
set +e
${tools_dir}/grib_set -s year=0,month=0,day=0,step=0 $tempGrbA $tempGrbB 2>$tempLog
status=$?
set -e
[ $status -ne 0 ]
grep -q "Date/Time is not valid" $tempLog
set +e
${tools_dir}/grib_set -s year=0,month=0,day=0,stepUnits=1 $tempGrbA $tempGrbB 2>$tempLog
status=$?
set -e
[ $status -ne 0 ]
grep -q "Date/Time is not valid" $tempLog
rm -f $tempGrbA $tempGrbB
# Clean up
rm -f $temp $tempLog $tempFilt
rm -f $grib2File.p8tmp ${grib2File}.tmp x.grib