Skip to content

Commit

Permalink
added missing implementation for extension of template 35
Browse files Browse the repository at this point in the history
  • Loading branch information
AlysonStahl-NOAA committed Aug 22, 2024
1 parent 9626ac5 commit d19b1ed
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
16 changes: 15 additions & 1 deletion src/pdstemplates.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
5 changes: 3 additions & 2 deletions tests/tst_pdstemplates.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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)
Expand Down

0 comments on commit d19b1ed

Please sign in to comment.