NCEPLIBS-g2c  1.6.4
getpoly.c
Go to the documentation of this file.
1 
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include "grib2.h"
10 
39 g2int
40 getpoly(unsigned char *csec3, g2int *jj, g2int *kk, g2int *mm)
41 {
42 
43  g2int *igdstmpl, *list_opt;
44  g2int *igds;
45  g2int iofst, igdtlen, num_opt;
46 
47  iofst = 0; /* set offset to beginning of section */
48  if (!g2_unpack3(csec3, &iofst, &igds, &igdstmpl, &igdtlen,
49  &list_opt, &num_opt))
50  {
51  switch (igds[4]) /* Template number */
52  {
53  case 50: /* Spherical harmonic coefficients */
54  case 51:
55  case 52:
56  case 53:
57  {
58  *jj = igdstmpl[0];
59  *kk = igdstmpl[1];
60  *mm = igdstmpl[2];
61  break;
62  }
63  default:
64  {
65  *jj = 0;
66  *kk = 0;
67  *mm = 0;
68  break;
69  }
70  } /* end switch */
71  }
72  else
73  {
74  *jj = 0;
75  *kk = 0;
76  *mm = 0;
77  }
78 
79  if (igds)
80  free(igds);
81  if (igdstmpl)
82  free(igdstmpl);
83  if (list_opt)
84  free(list_opt);
85 
86  return 0;
87 }
g2int g2_unpack3(unsigned char *, g2int *, g2int **, g2int **, g2int *, g2int **, g2int *)
This routine unpacks Section 3 (Grid Definition Section) as defined in GRIB Edition 2.
Definition: g2_unpack3.c:57
g2int getpoly(unsigned char *csec3, g2int *jj, g2int *kk, g2int *mm)
This subroutine returns the J, K, and M pentagonal resolution parameters specified in a GRIB Grid Def...
Definition: getpoly.c:40
Header file for NCEPLIBS-g2c library.
int64_t g2int
Long integer type.
Definition: grib2.h:20