SUP-3892: Eccodes 2.32 onwards compile with Intel problems

This commit is contained in:
Shahram Najm 2023-12-19 14:47:35 +00:00
parent 8f7a3c0693
commit 7bcdcdf40c
3 changed files with 35 additions and 8 deletions

View File

@ -727,6 +727,12 @@ static bool is_number(const char* s)
return true;
}
static bool strings_equal(const char* s1, const char* s2, bool case_sensitive)
{
if (case_sensitive) return (strcmp(s1, s2) == 0);
return (strcmp_nocase(s1, s2) == 0);
}
static int pack_string(grib_accessor* a, const char* buffer, size_t* len)
{
long lValue = 0;
@ -742,13 +748,14 @@ static int pack_string(grib_accessor* a, const char* buffer, size_t* len)
}
grib_accessor_codetable* self = (grib_accessor_codetable*)a;
grib_codetable* table;
long i;
grib_codetable* table = NULL;
long i = 0;
size_t size = 1;
bool case_sensitive = true;
typedef int (*cmpproc)(const char*, const char*);
cmpproc cmp = (a->flags & GRIB_ACCESSOR_FLAG_LOWERCASE) ? strcmp_nocase : strcmp;
// If the key has the "lowercase" flag set, then the string comparison
// should ignore the case
if (a->flags & GRIB_ACCESSOR_FLAG_LOWERCASE) case_sensitive = false;
if (!self->table_loaded) {
self->table = load_table(a); /* may return NULL */
@ -765,10 +772,13 @@ static int pack_string(grib_accessor* a, const char* buffer, size_t* len)
return err;
}
for (i = 0; i < table->size; i++)
if (table->entries[i].abbreviation)
if (cmp(table->entries[i].abbreviation, buffer) == 0)
for (i = 0; i < table->size; i++) {
if (table->entries[i].abbreviation) {
if (strings_equal(table->entries[i].abbreviation, buffer, case_sensitive)) {
return grib_pack_long(a, &i, &size);
}
}
}
if (a->flags & GRIB_ACCESSOR_FLAG_NO_FAIL) {
grib_action* act = (grib_action*)(a->creator);

View File

@ -13,8 +13,16 @@
label="grib_mars_keys2_test"
tempGrib=temp.${label}.grib
grib1_sample=$ECCODES_SAMPLES_PATH/GRIB1.tmpl
grib2_sample=$ECCODES_SAMPLES_PATH/reduced_gg_pl_32_grib2.tmpl
# Check lowercase/uppercase
${tools_dir}/grib_set -s class=YT,type=EM,stream=DCWV $grib1_sample $tempGrib
grib_check_key_equals $tempGrib mars.class,mars.type,mars.stream 'yt em dcwv'
grib_check_key_equals $tempGrib marsClass:i,marsType:i,marsStream:i '18 17 1029'
# Check all combinations
# ------------------------
i=0
@ -31,4 +39,5 @@ for cfg in $ECCODES_DEFINITION_PATH/mars/grib.*.*.def; do
done
echo "Checked $i files"
# Clean up
rm -f $tempGrib

View File

@ -225,6 +225,14 @@ set -e
[ $status -ne 0 ]
grep -q "stepUnits: No such code table entry.*Did you mean" $temp
set +e
${tools_dir}/grib_set -s centre=ECMF $input $outfile > $temp 2>&1
status=$?
set -e
[ $status -ne 0 ]
grep -q "centre: No such code table entry.*Did you mean.*ecmf" $temp
# ------------------------
# Unreadable message
# ------------------------