Testing: GRIB2 local definitions

This commit is contained in:
Shahram Najm 2024-01-18 15:52:10 +00:00
parent d35419ec21
commit 92d3ec50eb
2 changed files with 27 additions and 7 deletions

View File

@ -8,10 +8,6 @@
* virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction.
*/
/**************************************
* Enrico Fucile
**************************************/
#include "grib_api_internal.h"
/*
This is used by make_class.pl
@ -121,7 +117,6 @@ static int compare(grib_accessor* a, grib_accessor* b)
static void update_size(grib_accessor* a, size_t new_size)
{
/* printf("update_size: grib_accessor_class_padding.c %ld %ld %s %s\n", (long)new_size,(long)a->length,a->cclass->name,a->name); */
a->length = new_size;
}
@ -129,9 +124,13 @@ static void resize(grib_accessor* a, size_t new_size)
{
void* zero = grib_context_malloc_clear(a->context, new_size);
grib_buffer_replace(a, (const unsigned char*)zero, new_size, 1, 0);
grib_buffer_replace(a, (const unsigned char*)zero, new_size,
/*update_lengths=*/1, /*update_paddings=*/0);
grib_context_free(a->context, zero);
grib_context_log(a->context, GRIB_LOG_DEBUG, "resize: grib_accessor_class_padding.c %ld %ld %s %s\n", (long)new_size, (long)a->length, a->cclass->name, a->name);
grib_context_log(a->context, GRIB_LOG_DEBUG,
"grib_accessor_class_padding::resize new_size=%zu a->length=%ld %s %s",
new_size, a->length, a->cclass->name, a->name);
Assert(new_size == a->length);
}
@ -140,10 +139,12 @@ static int value_count(grib_accessor* a, long* c)
*c = a->length;
return 0;
}
static long byte_count(grib_accessor* a)
{
return a->length;
}
static size_t string_length(grib_accessor* a)
{
return (size_t)a->length;

View File

@ -125,6 +125,12 @@ ${tools_dir}/grib_set -s \
grib_check_key_equals $temp "mars.levelist,roundedMarsLevelist:d,roundedMarsLevelist:s" "1 1.234 1.234"
# Local Definition 192
# ---------------------------------------
${tools_dir}/grib_set -s setLocalDefinition=1,localDefinitionNumber=192 $sample_g2 $temp
${tools_dir}/grib_set -s stepType=accum,setLocalDefinition=1,localDefinitionNumber=192 $sample_g2 $temp
# Local Definition 5: Forecast probability data
# ---------------------------------------------
sample_g1=$ECCODES_SAMPLES_PATH/GRIB1.tmpl
@ -207,5 +213,18 @@ grib_check_key_exists $temp mars.number,constituentType,sourceSinkChemicalPhysic
${tools_dir}/grib_set -s localDefinitionNumber=36 $temp $temp.1
${tools_dir}/grib_compare $temp $temp.1
# Chemicals, aerosols etc (check GRIB2 templates are selected)
${tools_dir}/grib_set -s paramId=211123,setLocalDefinition=1,localDefinitionNumber=36 $sample_g2 $temp
grib_check_key_equals $temp productDefinitionTemplateNumber 40
${tools_dir}/grib_set -s paramId=456000,setLocalDefinition=1,localDefinitionNumber=36 $sample_g2 $temp
grib_check_key_equals $temp productDefinitionTemplateNumber 76
${tools_dir}/grib_set -s paramId=215225,setLocalDefinition=1,localDefinitionNumber=36 $sample_g2 $temp
grib_check_key_equals $temp productDefinitionTemplateNumber 48
${tools_dir}/grib_set -s paramId=210251,setLocalDefinition=1,localDefinitionNumber=36 $sample_g2 $temp
# Clean up
rm -f $temp $temp.1 $temp.2 $temp.3