diff --git a/src/grib2.h.in b/src/grib2.h.in index 08aae39b..e585e35b 100644 --- a/src/grib2.h.in +++ b/src/grib2.h.in @@ -291,7 +291,7 @@ g2int g2_gribend(unsigned char *cgrib); /* Constants to help with templates. */ #define G2C_MAX_GDS_TEMPLATE 31 /**< Maximum number of grid templates. */ #define G2C_MAX_GDS_TEMPLATE_MAPLEN 28 /**< Maximum grid template map length. */ -#define G2C_MAX_PDS_TEMPLATE 74 /**< Maximum number of PDS templates. */ +#define G2C_MAX_PDS_TEMPLATE 75 /**< Maximum number of PDS templates. */ #define G2C_MAX_PDS_TEMPLATE_MAPLEN 45 /**< Maximum template map length. */ #define G2C_MAX_DRS_TEMPLATE 10 /**< Maximum number of DRS templates. */ #define G2C_MAX_DRS_TEMPLATE_MAPLEN 18 /**< Maximum DRS template map length. */ diff --git a/src/pdstemplates.c b/src/pdstemplates.c index 6b1a3909..399ef850 100644 --- a/src/pdstemplates.c +++ b/src/pdstemplates.c @@ -341,6 +341,10 @@ static const struct pdstemplate templatespds[G2C_MAX_PDS_TEMPLATE] = 4.90: Post-processed quantile forecasts at a horizontal level or in a horizontal layer in a continuous or non-continuous time interval */ {90, 34, 1, {1, 1, 2, 2, 1, 1, 1, 1, 2, 1, 1, -4, 1, -1, -4, 1, -1, -4, 2, 2, 2, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 4, 1, 4}}, + /** PDT 4.92 (12/04/2024) + 4.92: Individual ensemble forecast, control and perturbed, at a horizontal + level or in a horizontal layer at a specified local time. */ + {92, 27, 1, {1, 1, 1, 1, 1, 1, -1, -4, 1, -1, -4, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, -4, 1, 1, 4}}, }; /** @@ -1182,6 +1186,23 @@ extpdstemplate(g2int number, g2int *list) } } } + /* PDT 4.92 (12/04/2024) */ + else if (number == 92) + { + if (list[15] > 1) + { + new->extlen = (list[15] - 1) * 11; + new->ext = malloc(sizeof(g2int) * new->extlen); + for (j = 2; j <= list[15]; j++) + { + l = (j - 2) * 11; + for (k = 0; k < 11; k++) + { + new->ext[l + k] = new->map[16 + k]; + } + } + } + } return new; } diff --git a/tests/tst_pdstemplates.c b/tests/tst_pdstemplates.c index 9e9d0286..88d7257a 100644 --- a/tests/tst_pdstemplates.c +++ b/tests/tst_pdstemplates.c @@ -528,25 +528,36 @@ main() return G2C_ERROR; free(tmpl->ext); free(tmpl); + + /* Check for one that's there but does need an extension. */ + tmpl = extpdstemplate(92, list); + if (!tmpl) + return G2C_ERROR; + if (tmpl->num != 92 || tmpl->maplen != 27 || !tmpl->needext) + return G2C_ERROR; + if (!tmpl->ext) + return G2C_ERROR; + free(tmpl->ext); + free(tmpl); } printf("ok!\n"); printf("Testing all getpdstemplate() calls with extensions...\n"); { -#define NUM_TEST 74 +#define NUM_TEST 75 int number[NUM_TEST] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 20, 30, 31, 40, 41, 42, 43, 254, 1000, 1001, 1002, 1100, 1101, 32, 44, 45, 46, 47, 48, 50, 52, 51, 91, 33, 34, 53, 54, 57, 60, 61, 35, 49, 55, 58, 59, 62, 63, 67, 68, 70, - 71, 72, 73, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90}; + 71, 72, 73, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 92}; int expected_maplen[NUM_TEST] = { 15, 18, 17, 31, 30, 22, 16, 15, 29, 36, 30, 32, 31, 45, 44, 18, 19, 5, 5, 16, 19, 30, 33, 3, 9, 16, 15, 15, 22, 10, 21, 24, 35, 38, 26, 21, 15, 16, 36, 18, 32, 19, 22, 7, 24, 38, 6, 29, 21, 7, 24, 35, 38, 7, 7, 19, 21, 32, - 34, 17, 20, 31, 34, 27, 30, 36, 40, 39, 38, 17, 31, 24, 20, 34}; + 34, 17, 20, 31, 34, 27, 30, 36, 40, 39, 38, 17, 31, 24, 20, 34, 27}; int expected_needext[NUM_TEST] = { 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, - 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1}; + 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1}; int expected_map[NUM_TEST][48] = { {1, 1, 1, 1, 1, 2, 1, 1, -4, 1, -1, -4, 1, -1, -4}, /* 0 */ {1, 1, 1, 1, 1, 2, 1, 1, -4, 1, -1, -4, 1, -1, -4, 1, 1, 1}, /* 1 */ @@ -622,6 +633,7 @@ main() {1, 1, 1, 1, 1, 1, -1, -4, 1, -1, -4, 1, 1, 2, 1, 1, 1, 1, 1, 1, -4, 1, 1, 4}, /* 88 */ {1, 1, 2, 2, 1, 1, 1, 1, 2, 1, 1, -4, 1, -1, -4, 1, -1, -4, 2, 2}, /* 89 */ {1, 1, 2, 2, 1, 1, 1, 1, 2, 1, 1, -4, 1, -1, -4, 1, -1, -4, 2, 2, 2, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 4, 1, 4}, /* 90 */ + {1, 1, 1, 1, 1, 1, -1, -4, 1, -1, -4, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, -4, 1, 1, 4}, /* 92 */ }; int t; int ext_t = 0; @@ -663,11 +675,11 @@ main() if (map[m] != expected_map[t][m]) return G2C_ERROR; -#define NUM_EXT_TEST 41 +#define NUM_EXT_TEST 42 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, - 10, 20, 6, 6, 31, 34, 6, 6, 6, 6, 6, 6, 6, 6, 6, 11, 6}; + 10, 20, 6, 6, 31, 34, 6, 6, 6, 6, 6, 6, 6, 6, 6, 11, 6, 11}; int expected_ext[NUM_EXT_TEST][48] = { {1, 1}, /* 3 */ {1, 1}, /* 4 */ @@ -710,6 +722,7 @@ main() {1, 1, 1, 4, 1, 4}, /* 87 */ {2, 1, 1, 1, 1, 1, 1, -4, 1, 1, 4}, /* 88 */ {1, 1, 1, 4, 1, 4}, /* 90 */ + {2, 1, 1, 1, 1, 1, 1, -4, 1, 1, 4}, /* 92 */ }; if (needext) @@ -849,6 +862,9 @@ main() case 90: template[26] = 2; break; + case 92: + template[15] = 2; + break; default: return G2C_ERROR; }