Skip to content

Commit

Permalink
changed type of g2c_inq_prod() parameters (#499)
Browse files Browse the repository at this point in the history
* changed type of g2c_inq_prod() parameters

* fixed tests
  • Loading branch information
edwardhartnett authored Jul 9, 2024
1 parent 7b38144 commit 53444de
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 20 deletions.
10 changes: 5 additions & 5 deletions src/g2cinq.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,11 @@ g2c_inq_msg_time(int g2cid, int msg_num, unsigned char *sig_ref_time, short *yea
* @param msg_num Message number.
* @param prod_num Product number.
* @param pds_template_len PDS template length. Ignored if NULL.
* @param pds_template The PDS template. Ignored if NULL.
* @param pds_template Pointer that gets the PDS template. Ignored if NULL.
* @param gds_template_len GDS template length. Ignored if NULL.
* @param gds_template The GDS template. Ignored if NULL.
* @param gds_template Pointer that gets the GDS template. Ignored if NULL.
* @param drs_template_len The DRS template length. Ignored if NULL.
* @param drs_template The DRS template. Ignored if NULL.
* @param drs_template Pointer that gets the DRS template. Ignored if NULL.
*
* @return
* - ::G2C_NOERROR No error.
Expand All @@ -205,8 +205,8 @@ g2c_inq_msg_time(int g2cid, int msg_num, unsigned char *sig_ref_time, short *yea
*/
int
g2c_inq_prod(int g2cid, int msg_num, int prod_num, int *pds_template_len,
int *pds_template, int *gds_template_len, int *gds_template,
int *drs_template_len, int *drs_template)
long long int *pds_template, int *gds_template_len, long long int *gds_template,
int *drs_template_len, long long int *drs_template)
{
G2C_MESSAGE_INFO_T *msg;
G2C_SECTION_INFO_T *sec4, *sec3, *sec5;
Expand Down
4 changes: 2 additions & 2 deletions src/grib2.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,8 @@ int g2c_inq_msg_time(int g2cid, int msg_num, unsigned char *sig_ref_time, short
unsigned char *month, unsigned char *day, unsigned char *hour,
unsigned char *minute, unsigned char *second);
int g2c_inq_prod(int g2cid, int msg_num, int prod_num, int *pds_template_len,
int *pds_template, int *gds_template_len, int *gds_template,
int *drs_template_len, int *drs_template);
long long int *pds_template, int *gds_template_len, long long int *gds_template,
int *drs_template_len, long long int *drs_template);
int g2c_inq_dim(int g2cid, int msg_num, int prod_num, int dim_num, size_t *len,
char *name, float *val);

Expand Down
13 changes: 8 additions & 5 deletions tests/tst_g2_testfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ main()
unsigned char sig_ref_time;
short year;
unsigned char month, day, hour, minute, second;
int pds_template_len, pds_template[PDSLEN], gds_template_len, gds_template[GDSLEN];
int drs_template_len, drs_template[DRSLEN];
int expected_pds[PDSLEN] = {0, 0, 0, 0, 0, 12, 59, 0, 0, 1, 1, 1, 2, 1, 1};
int expected_gds[GDSLEN] = {0, 1, 1, 1, 1, 1, 1, 2, 2, 0, 0, 45, 91, 0, 55, 101, 5, 5, 0};
int expected_drs[DRSLEN] = {1093664768, 1, 1, 8, 0};
int pds_template_len, gds_template_len, drs_template_len;
long long int pds_template[PDSLEN], gds_template[GDSLEN], drs_template[DRSLEN];
long long int expected_pds[PDSLEN] = {0, 0, 0, 0, 0, 12, 59, 0, 0, 1, 1, 1, 2, 1, 1};
long long int expected_gds[GDSLEN] = {0, 1, 1, 1, 1, 1, 1, 2, 2, 0, 0, 45, 91, 0, 55, 101, 5, 5, 0};
long long int expected_drs[DRSLEN] = {1093664768, 1, 1, 8, 0};
int i;
int ret;

Expand Down Expand Up @@ -77,8 +77,11 @@ main()
if (gds_template[i] != expected_gds[i])
return G2C_ERROR;
for (i = 0; i < DRSLEN; i++)
{
printf("drs_template[%d] %lld\n", i, drs_template[i]);
if (drs_template[i] != expected_drs[i])
return G2C_ERROR;
}

/* Close test file. */
if ((ret = g2c_close(g2cid)))
Expand Down
21 changes: 13 additions & 8 deletions tests/tst_inq.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ main()
int num_fields, num_local;
unsigned char discipline;
int pds_template_len, gds_template_len, drs_template_len;
int pds_template[G2C_MAX_PDS_TEMPLATE_MAPLEN];
int gds_template[G2C_MAX_GDS_TEMPLATE_MAPLEN];
int drs_template[G2C_MAX_DRS_TEMPLATE_MAPLEN];
int expected_pds_template[NUM_MSG][G2C_MAX_PDS_TEMPLATE_MAPLEN] = {
long long int pds_template[G2C_MAX_PDS_TEMPLATE_MAPLEN];
long long int gds_template[G2C_MAX_GDS_TEMPLATE_MAPLEN];
long long int drs_template[G2C_MAX_DRS_TEMPLATE_MAPLEN];
long long int expected_pds_template[NUM_MSG][G2C_MAX_PDS_TEMPLATE_MAPLEN] = {
{2, 1, 2, 0, 11, 0, 0, 1, 0, 1, 0, 1, 255, 0, 0},
{2, 0, 2, 0, 11, 0, 0, 1, 0, 1, 0, 1, 255, 0, 0},
{2, 2, 2, 0, 11, 0, 0, 1, 0, 1, 0, 1, 255, 0, 0},
Expand All @@ -125,13 +125,13 @@ main()
{0, 7, 2, 0, 11, 0, 0, 1, 0, 241, 0, 2, 255, 0, 0},
{0, 7, 2, 0, 11, 0, 0, 1, 0, 241, 0, 3, 255, 0, 0}
};
int expected_gds_template[G2C_MAX_GDS_TEMPLATE_MAPLEN] =
long long int expected_gds_template[G2C_MAX_GDS_TEMPLATE_MAPLEN] =
{6, 0, 0, 0, 0, 0, 0, 241, 151, 0, 0, 50000000, 210000000, 48, 25000000, 250000000, 166667, 166667, 0};
int expected_drs_template[NUM_MSG][G2C_MAX_DRS_TEMPLATE_MAPLEN] = {
long long int expected_drs_template[NUM_MSG][G2C_MAX_DRS_TEMPLATE_MAPLEN] = {
{1092616192, 0, 2, 11, 0, 0, 255},
{1065353216, 0, 2, 16, 0, 0, 255},
{-1006403584, 0, 2, 11, 0, 0, 255},
{-996777984, 0, 2, 12, 0, 0, 255},
{3288563712, 0, 2, 11, 0, 0, 255},
{3298189312, 0, 2, 12, 0, 0, 255},
{1102053376, 0, 2, 9, 0, 0, 255},
{1144815616, 0, 2, 10, 0, 0, 255},
{1185159680, 0, 2, 14, 0, 0, 255},
Expand All @@ -154,6 +154,8 @@ main()
unsigned char master_version, local_version;
int p;

printf("\t\tinquiring about message %d...\n", m);

/* Inquire about this message. */
if ((ret = g2c_inq_msg(g2cid, m, &discipline, &num_fields, &num_local,
&center, &subcenter, &master_version, &local_version)))
Expand Down Expand Up @@ -197,8 +199,11 @@ main()
if (drs_template_len != 7)
return G2C_ERROR;
for (p = 0; p < drs_template_len; p++)
{
/* printf("drs_template[%d] %lld\n", p, drs_template[p]); */
if (drs_template[p] != expected_drs_template[m][p])
return G2C_ERROR;
}
}

/* Close the file. */
Expand Down

0 comments on commit 53444de

Please sign in to comment.