78 subroutine gribinfo(cgrib, lcgrib, listsec0, listsec1, &
79 numlocal, numfields, maxvals, ierr)
82 character(len = 1),
intent(in) :: cgrib(lcgrib)
83 integer,
intent(in) :: lcgrib
84 integer,
intent(out) :: listsec0(3), listsec1(13), maxvals(7)
85 integer,
intent(out) :: numlocal, numfields, ierr
87 integer :: i, ipos, isecnum, j, lengrib, lenposs, lensec, lensec0, lensec1
88 integer :: maxcoordlist, maxdeflist, maxdrstmpl, maxgridpts, maxpdstmpl, maxgdstmpl
89 integer :: maxsec2len, nbits, nbyte, ngdpts, numcoord
90 character(len = 4),
parameter :: grib =
'GRIB', c7777 =
'7777'
91 character(len = 4) :: ctemp
92 integer,
parameter :: zero = 0, one = 1
93 integer,
parameter :: mapsec1len = 13
94 integer,
parameter :: mapsec1(mapsec1len) = (/ 2, 2, 1, 1, 1, 2, 1, 1, &
112 ctemp = cgrib(j) // cgrib(j + 1) // cgrib(j + 2) // cgrib(j + 3)
113 if (ctemp .eq. grib)
then
118 if (istart .eq. 0)
then
119 print *,
'gribinfo: Beginning characters GRIB not found.'
125 iofst = 8 * (istart + 5)
126 call g2_gbytec(cgrib, listsec0(1), iofst, 8)
128 call g2_gbytec(cgrib, listsec0(2), iofst, 8)
131 call g2_gbytec(cgrib, lengrib, iofst, 32)
133 listsec0(3) = lengrib
135 ipos = istart + lensec0
138 if (listsec0(2) .ne. 2)
then
139 print *,
'gribinfo: can only decode GRIB edition 2.'
145 call g2_gbytec(cgrib, lensec1, iofst, 32)
149 if (isecnum .ne. 1)
then
150 print *,
'gribinfo: Could not find section 1.'
159 nbits = mapsec1(i) * 8
160 call g2_gbytec(cgrib, listsec1(i), iofst, nbits)
161 iofst = iofst + nbits
163 ipos = ipos + lensec1
169 ctemp = cgrib(ipos) // cgrib(ipos + 1) // cgrib(ipos + 2) // &
171 if (ctemp .eq. c7777)
then
173 if (ipos .ne. (istart + lengrib))
then
174 print *,
'gribinfo: "7777" found, but not where expected.'
180 iofst = (ipos - 1) * 8
186 if (ipos .gt. (istart + lengrib))
then
187 print *,
'gribinfo: "7777" not found at end of GRIB message.'
191 if (isecnum .eq. 2)
then
194 numlocal = numlocal + 1
196 if (lenposs .gt. maxsec2len) maxsec2len = lenposs
197 elseif (isecnum .eq. 3)
then
203 if (ngdpts .gt. maxgridpts) maxgridpts = ngdpts
204 lenposs = lensec - 14
205 if (lenposs .gt. maxgdstmpl) maxgdstmpl = lenposs
206 if (nbyte .ne. 0)
then
207 lenposs = lenposs / nbyte
208 if (lenposs .gt. maxdeflist) maxdeflist = lenposs
210 elseif (isecnum .eq. 4)
then
211 numfields = numfields + 1
212 call g2_gbytec(cgrib, numcoord, iofst, 16)
214 if (numcoord .ne. 0)
then
215 if (numcoord .gt. maxcoordlist) maxcoordlist = numcoord
218 if (lenposs.gt.maxpdstmpl) maxpdstmpl = lenposs
219 elseif (isecnum .eq. 5)
then
221 if (lenposs .gt. maxdrstmpl) maxdrstmpl = lenposs
225 maxvals(1) = maxsec2len
226 maxvals(2) = maxgdstmpl
227 maxvals(3) = maxdeflist
228 maxvals(4) = maxpdstmpl
229 maxvals(5) = maxcoordlist
230 maxvals(6) = maxdrstmpl
231 maxvals(7) = maxgridpts
subroutine g2_gbytec(in, iout, iskip, nbits)
Extract arbitrary size values from a packed bit string, right justifying each value in the unpacked a...
subroutine gribinfo(cgrib, lcgrib, listsec0, listsec1, numlocal, numfields, maxvals, ierr)
Find the number of Local Use Sections and gridded fields in a GRIB2 message, and the maximum sizes of...