From d19b1ed6cf4b28eb156b9926fe0d651ae9b389f1 Mon Sep 17 00:00:00 2001 From: AlysonStahl-NOAA <166434581+AlysonStahl-NOAA@users.noreply.github.com> Date: Thu, 22 Aug 2024 14:17:09 -0700 Subject: [PATCH] added missing implementation for extension of template 35 --- src/pdstemplates.c | 16 +++++++++++++++- tests/tst_pdstemplates.c | 5 +++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/pdstemplates.c b/src/pdstemplates.c index 59e79d2c..7ca7d1b7 100644 --- a/src/pdstemplates.c +++ b/src/pdstemplates.c @@ -716,7 +716,21 @@ extpdstemplate(g2int number, g2int *list) } } } - + /* PDT 4.35 (10/07/2015) */ + else if (number == 35) + { + new->extlen = list[5] * 5; + new->ext = malloc(sizeof(g2int) * new->extlen); + for (i=0; i < list[5]; i++) + { + l = i * 6; + new->ext[l] = 2; + new->ext[l+1] = 2; + new->ext[l+2] = 2; + new->ext[l+3] = 1; + new->ext[l+4] = 4; + } + } return new; } diff --git a/tests/tst_pdstemplates.c b/tests/tst_pdstemplates.c index 26332e10..3923e382 100644 --- a/tests/tst_pdstemplates.c +++ b/tests/tst_pdstemplates.c @@ -465,9 +465,9 @@ main() /* There's a bug with 35 see https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp4-35.shtml. */ if (number[t] != 35) { -#define NUM_EXT_TEST 24 +#define NUM_EXT_TEST 25 int template[G2C_MAX_PDS_TEMPLATE_MAPLEN]; - int expected_extlen[NUM_EXT_TEST] = {2, 2, 6, 6, 6, 6, 6, 8, 8, 10, 10, 6, 6, 10, 6, 6, 12, 8, 2, 8, 2, 2, 30, 6}; + int expected_extlen[NUM_EXT_TEST] = {2, 2, 6, 6, 6, 6, 6, 8, 8, 10, 10, 6, 6, 10, 6, 6, 12, 8, 2, 8, 2, 2, 30, 6, 5}; int expected_ext[NUM_EXT_TEST][48] = { {1, 1}, /* 3 */ {1, 1}, /* 4 */ @@ -493,6 +493,7 @@ main() {1, 1}, /* 54 */ {1, -4, 1, 1, 1, 2, 1, 1, -4, 1, -1, -4, 1, -1, -4, 1, -4, 1, 1, 1, 2, 1, 1, -4, 1, -1, -4, 1, -1, -4}, /* 57 */ {1, 1, 1, 4, 1, 4}, /* 61 */ + {2, 2, 2, 1, 4}, /* 35 */ }; if (needext)