Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing undefined value in specpack and simpack functions #529

Draft
wants to merge 6 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/g2_addfield.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ g2_addfield(unsigned char *cgrib, g2int ipdsnum, g2int *ipdstmpl,
g2int ilen, isecnum, i, nbits, temp, left;
g2int ibmprev, j, lcpack, ioctet, newlen, ndpts;
g2int lensec4, lensec5, lensec6, lensec7;
g2int issec3 = 0, isprevbmap = 0, lpos3 = 0, JJ, KK, MM;
g2int issec3 = 0, isprevbmap = 0, lpos3 = 0, JJ, KK;
g2intu MM;
g2int *coordieee;
float *pfld;
gtemplate *mappds, *mapdrs;
Expand Down
2 changes: 1 addition & 1 deletion src/grib2_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ void misspack(float *fld, g2int ndpts, g2int idrsnum, g2int *idrstmpl,
void cmplxpack(float *fld, g2int ndpts, g2int idrsnum, g2int *idrstmpl,
unsigned char *cpack, g2int *lcpack);
g2int getpoly(unsigned char *csec3, g2int *jj, g2int *kk, g2int *mm);
void specpack(float *fld, g2int ndpts, g2int JJ, g2int KK, g2int MM,
void specpack(float *fld, g2int ndpts, g2int JJ, g2int KK, g2intu MM,
g2int *idrstmpl, unsigned char *cpack, g2int *lcpack);
g2int specunpack(unsigned char *cpack, g2int *idrstmpl, g2int ndpts, g2int JJ,
g2int KK, g2int MM, float *fld);
Expand Down
2 changes: 1 addition & 1 deletion src/specpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* @author Stephen Gilbert @date 2002-12-19
*/
void
specpack(float *fld, g2int ndpts, g2int JJ, g2int KK, g2int MM,
specpack(float *fld, g2int ndpts, g2int JJ, g2int KK, g2intu MM,
g2int *idrstmpl, unsigned char *cpack, g2int *lcpack)
{

Expand Down
29 changes: 27 additions & 2 deletions tests/tst_spec.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <stdio.h>
#include <stdlib.h>

#define DATA_LEN 4
#define DATA_LEN 6
#define PACKED_LEN 200

/* Prototypes we are testing. */
Expand All @@ -17,6 +17,31 @@ int
main()
{
printf("Testing spec functions.\n");
{
g2int ndpts = DATA_LEN;
float fld[DATA_LEN] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0};
float fld_in[DATA_LEN];
unsigned char cpack[PACKED_LEN];
g2int lcpack;
g2int idrstmpl[10] = {0, 1, 1, 16, 0, 0, 0, 0, 2, 1};
g2int JJ = 1, KK = 1;
g2intu MM = 1;
int i;

printf("Packing the data...");
specpack(fld, ndpts, JJ, KK, MM, idrstmpl, cpack, &lcpack);

printf("Unpacking the data...");
if (specunpack(cpack, idrstmpl, ndpts, JJ, KK, MM, fld_in))
return G2C_ERROR;

for (i = 0; i < DATA_LEN; i++)
{
printf("%g %g\n", fld[i], fld_in[i]);
if (fld[i] != fld_in[i])
return G2C_ERROR;
}
}
/* printf("Testing specpack()/specunpack() calls..."); */
/* { */
/* g2int height = 2, width = 2; */
Expand Down Expand Up @@ -76,4 +101,4 @@ main()
/* printf("ok!\n"); */
printf("SUCCESS!\n");
return 0;
}
}
Loading