Skip to content

Commit

Permalink
template 3.13
Browse files Browse the repository at this point in the history
  • Loading branch information
AlysonStahl-NOAA committed Jan 6, 2025
1 parent 80806b4 commit 11ee502
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/grib2.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ g2int g2_gribend(unsigned char *cgrib);
#define G2C_SECTION1_LEN 13 /**< Length of section 1 array. */

/* Constants to help with templates. */
#define G2C_MAX_GDS_TEMPLATE 31 /**< Maximum number of grid templates. */
#define G2C_MAX_GDS_TEMPLATE 32 /**< Maximum number of grid templates. */
#define G2C_MAX_GDS_TEMPLATE_MAPLEN 28 /**< Maximum grid template map length. */
#define G2C_MAX_PDS_TEMPLATE 102 /**< Maximum number of PDS templates. */
#define G2C_MAX_PDS_TEMPLATE_MAPLEN 50 /**< Maximum template map length. */
Expand Down
6 changes: 5 additions & 1 deletion src/gridtemplates.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,11 @@ static const struct gridtemplate templatesgrid[G2C_MAX_GDS_TEMPLATE] =
/* 3.1100: Hovmoller Diagram Grid */
{1100, 28, 0, {1, 1, 4, 1, 4, 1, 4, 4, 4, 4, -4, 4, 1, -4, 4, 1, 4, 1, -4, 1, 1, -4, 2, 1, 1, 1, 1, 1}},
/* 3.1200: Time Section Grid */
{1200, 16, 1, {4, 1, -4, 1, 1, -4, 2, 1, 1, 1, 1, 1, 2, 1, 1, 2}}};
{1200, 16, 1, {4, 1, -4, 1, 1, -4, 2, 1, 1, 1, 1, 1, 2, 1, 1, 2}}

/* 3.13: Mercator with modelling subdomains definition */
{13, 23, 0, {1, 1, 4, 1, 4, 1, 4, 4, 4, -4, 4, 1, -4, -4, 4, 1, 4, 4, 4, 4, 4, 4, 4}}
};

/**
* This function returns the index of specified Grid Definition
Expand Down
19 changes: 13 additions & 6 deletions tests/tst_get_grid_template.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "grib2_int.h"

/* Number of grid templates to test. */
#define NUM_TESTS 31
#define NUM_TESTS 32

/* Number of grid templates with extensions. */
#define NUM_EXT_TESTS 5
Expand All @@ -18,10 +18,16 @@ main()
printf("Testing g2c_get_grid_template()\n");
printf("Testing simple g2c_get_grid_template() calls...\n");
{
int template_number[NUM_TESTS] = {0, 1, 2, 3, 4, 5, 12, 101, 140, 10, 20, 30, 31, 40, 41, 42, 43, 50, 51, 52, 53, 90, 100, 110, 120, 204, 32768, 32769, 1000, 1100, 1200};
int expected_maplen[NUM_TESTS] = {19, 22, 22, 25, 13, 16, 22, 4, 17, 19, 18, 22, 22, 19, 22, 22, 25, 5, 8, 8, 11, 21, 11, 16, 7, 19, 19, 21, 20, 28, 16};
int expected_needsext[NUM_TESTS] = {0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1};
int expected_extlen[NUM_TESTS] = {0, 0, 0, 0, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 2, 0, 2};
int template_number[NUM_TESTS] = {
0, 1, 2, 3, 4, 5, 12, 101, 140, 10, 20, 30, 31, 40, 41, 42, 43, 50, 51, 52, 53, 90, 100, 110, 120,
204, 32768, 32769, 1000, 1100, 1200, 13};
int expected_maplen[NUM_TESTS] = {
19, 22, 22, 25, 13, 16, 22, 4, 17, 19, 18, 22, 22, 19, 22, 22, 25, 5, 8, 8, 11, 21, 11, 16, 7, 19,
19, 21, 20, 28, 16, 23};
int expected_needsext[NUM_TESTS] = {
0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 1, 0, 0, 0, 1, 0, 1, 0};
int expected_extlen[NUM_TESTS] = {
0, 0, 0, 0, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 2, 0, 2, 0};
int expected_map[NUM_TESTS][28] = {
{1, 1, 4, 1, 4, 1, 4, 4, 4, 4, 4, -4, 4, 1, -4, 4, 4, 4, 1, 0, 0, 0}, /* 0 */
{1, 1, 4, 1, 4, 1, 4, 4, 4, 4, 4, -4, 4, 1, -4, 4, 4, 4, 1, -4, 4, 4, 0, 0, 0}, /* 1 */
Expand Down Expand Up @@ -53,7 +59,8 @@ main()
{1, 1, 4, 1, 4, 1, 4, 4, 4, 4, 4, -4, 4, 1, -4, 4, 4, 4, 1, 4, 4}, /* 32769 */
{1, 1, 4, 1, 4, 1, 4, 4, 4, 4, -4, 4, 1, 4, 4, 1, 2, 1, 1, 2}, /* 1000 */
{1, 1, 4, 1, 4, 1, 4, 4, 4, 4, -4, 4, 1, -4, 4, 1, 4, 1, -4, 1, 1, -4, 2, 1, 1, 1, 1, 1}, /* 1100 */
{4, 1, -4, 1, 1, -4, 2, 1, 1, 1, 1, 1, 2, 1, 1, 2} /* 1200 */
{4, 1, -4, 1, 1, -4, 2, 1, 1, 1, 1, 1, 2, 1, 1, 2}, /* 1200 */
{1, 1, 4, 1, 4, 1, 4, 4, 4, -4, 4, 1, -4, -4, 4, 1, 4, 4, 4, 4, 4, 4, 4}, /* 13 */
};
int expected_ext[NUM_EXT_TESTS][8] = {
{4, 4, -4, -4},
Expand Down

0 comments on commit 11ee502

Please sign in to comment.