Testing: grib_util_set_spec edition conversion

This commit is contained in:
shahramn 2024-02-28 12:36:48 +00:00
parent 95da948d3c
commit d31f36f66b
1 changed files with 17 additions and 8 deletions

View File

@ -14,12 +14,13 @@
static void dump_it(grib_handle* h) static void dump_it(grib_handle* h)
{ {
int dump_flags = GRIB_DUMP_FLAG_CODED | GRIB_DUMP_FLAG_OCTET | GRIB_DUMP_FLAG_VALUES | GRIB_DUMP_FLAG_READ_ONLY; int dump_flags = GRIB_DUMP_FLAG_CODED | GRIB_DUMP_FLAG_OCTET | GRIB_DUMP_FLAG_VALUES | GRIB_DUMP_FLAG_READ_ONLY;
grib_dump_content(h, stdout, "wmo", dump_flags, NULL); grib_dump_content(h, stderr, "wmo", dump_flags, NULL);
} }
// Lambert conformal // Lambert conformal
static grib_handle* test0() static grib_handle* test0()
{ {
fprintf(stderr, "Doing test %s\n-----------------\n", __func__);
int err = 0; int err = 0;
grib_util_grid_spec spec = {0,}; grib_util_grid_spec spec = {0,};
grib_util_packing_spec packing_spec = {0,}; grib_util_packing_spec packing_spec = {0,};
@ -47,6 +48,7 @@ static grib_handle* test0()
// Lambert azimuthal // Lambert azimuthal
static grib_handle* test1() static grib_handle* test1()
{ {
fprintf(stderr, "Doing test %s\n-----------------\n", __func__);
int err = 0; int err = 0;
grib_util_grid_spec spec = {0,}; grib_util_grid_spec spec = {0,};
grib_util_packing_spec packing_spec = {0,}; grib_util_packing_spec packing_spec = {0,};
@ -68,6 +70,7 @@ static grib_handle* test1()
// HEALPix // HEALPix
static grib_handle* test2() static grib_handle* test2()
{ {
fprintf(stderr, "Doing test %s\n-----------------\n", __func__);
int err = 0; int err = 0;
grib_util_grid_spec spec = {0,}; grib_util_grid_spec spec = {0,};
grib_util_packing_spec packing_spec = {0,}; grib_util_packing_spec packing_spec = {0,};
@ -75,17 +78,13 @@ static grib_handle* test2()
int set_spec_flags = 0; int set_spec_flags = 0;
size_t outlen = 4; size_t outlen = 4;
grib_handle* handle = grib_handle_new_from_samples(0, "GRIB2"); grib_handle* handle = grib_handle_new_from_samples(0, "GRIB1");
spec.grid_type = GRIB_UTIL_GRID_SPEC_HEALPIX; spec.grid_type = GRIB_UTIL_GRID_SPEC_HEALPIX;
spec.N = 2; spec.N = 2;
packing_spec.extra_settings_count = 1;
packing_spec.extra_settings[0].type = GRIB_TYPE_LONG;
packing_spec.extra_settings[0].name = "tablesVersion";
packing_spec.extra_settings[0].long_value = 32;
packing_spec.packing_type = GRIB_UTIL_PACKING_TYPE_GRID_SECOND_ORDER; packing_spec.packing_type = GRIB_UTIL_PACKING_TYPE_GRID_SECOND_ORDER;
packing_spec.packing = GRIB_UTIL_PACKING_USE_PROVIDED; packing_spec.packing = GRIB_UTIL_PACKING_USE_PROVIDED;
packing_spec.editionNumber = 2;
grib_handle* finalh = grib_util_set_spec( grib_handle* finalh = grib_util_set_spec(
handle, &spec, &packing_spec, set_spec_flags, handle, &spec, &packing_spec, set_spec_flags,
@ -97,6 +96,7 @@ static grib_handle* test2()
// Spherical harmonics // Spherical harmonics
static grib_handle* test3() static grib_handle* test3()
{ {
fprintf(stderr, "Doing test %s\n-----------------\n", __func__);
int err = 0; int err = 0;
grib_util_grid_spec spec = {0,}; grib_util_grid_spec spec = {0,};
grib_util_packing_spec packing_spec = {0,}; grib_util_packing_spec packing_spec = {0,};
@ -124,6 +124,7 @@ static grib_handle* test3()
// Polar stereo // Polar stereo
static grib_handle* test4() static grib_handle* test4()
{ {
fprintf(stderr, "Doing test %s\n-----------------\n", __func__);
int err = 0; int err = 0;
grib_util_grid_spec spec = {0,}; grib_util_grid_spec spec = {0,};
grib_util_packing_spec packing_spec = {0,}; grib_util_packing_spec packing_spec = {0,};
@ -132,10 +133,15 @@ static grib_handle* test4()
size_t outlen = 0; size_t outlen = 0;
grib_handle* handle = grib_handle_new_from_samples(0, "GRIB2"); grib_handle* handle = grib_handle_new_from_samples(0, "GRIB2");
grib_set_long(handle, "tablesVersion", 32); //grib_set_long(handle, "tablesVersion", 32);
spec.grid_type = GRIB_UTIL_GRID_SPEC_POLAR_STEREOGRAPHIC; spec.grid_type = GRIB_UTIL_GRID_SPEC_POLAR_STEREOGRAPHIC;
outlen = 4; outlen = 4;
packing_spec.extra_settings_count = 1;
packing_spec.extra_settings[0].type = GRIB_TYPE_LONG;
packing_spec.extra_settings[0].name = "tablesVersion";
packing_spec.extra_settings[0].long_value = 32;
grib_handle* finalh = grib_util_set_spec( grib_handle* finalh = grib_util_set_spec(
handle, &spec, &packing_spec, set_spec_flags, handle, &spec, &packing_spec, set_spec_flags,
values, outlen, &err); values, outlen, &err);
@ -146,6 +152,7 @@ static grib_handle* test4()
// Regular Gaussian // Regular Gaussian
static grib_handle* test5() static grib_handle* test5()
{ {
fprintf(stderr, "Doing test %s\n-----------------\n", __func__);
int err = 0; int err = 0;
grib_util_grid_spec spec = {0,}; grib_util_grid_spec spec = {0,};
grib_util_packing_spec packing_spec = {0,}; grib_util_packing_spec packing_spec = {0,};
@ -168,6 +175,7 @@ static grib_handle* test5()
// Reduced LL // Reduced LL
static grib_handle* test6() static grib_handle* test6()
{ {
fprintf(stderr, "Doing test %s\n-----------------\n", __func__);
int err = 0; int err = 0;
grib_util_grid_spec spec = {0,}; grib_util_grid_spec spec = {0,};
grib_util_packing_spec packing_spec = {0,}; grib_util_packing_spec packing_spec = {0,};
@ -190,6 +198,7 @@ static grib_handle* test6()
// Unstructured // Unstructured
static grib_handle* test7() static grib_handle* test7()
{ {
fprintf(stderr, "Doing test %s\n-----------------\n", __func__);
int err = 0; int err = 0;
grib_util_grid_spec spec = {0,}; grib_util_grid_spec spec = {0,};
grib_util_packing_spec packing_spec = {0,}; grib_util_packing_spec packing_spec = {0,};