34 subroutine getlocal(cgrib, lcgrib, localnum, csec2, lcsec2, ierr)
37 character(len = 1),
intent(in) :: cgrib(lcgrib)
38 integer,
intent(in) :: lcgrib, localnum
39 character(len = 1),
intent(out) :: csec2(*)
40 integer,
intent(out) :: lcsec2, ierr
42 character(len = 4),
parameter :: grib =
'GRIB', c7777 =
'7777'
43 character(len = 4) :: ctemp
44 integer :: listsec0(2)
45 integer iofst, istart, numlocal
46 integer :: lengrib, lensec, lensec0, j, ipos, isecnum
52 if (localnum .le. 0)
then
53 print *,
'getlocal: Request for local section must be positive.'
61 ctemp = cgrib(j)//cgrib(j+1)//cgrib(j+2)//cgrib(j+3)
62 if (ctemp .eq. grib)
then
67 if (istart .eq. 0)
then
68 print *,
'getlocal: Beginning characters GRIB not found.'
74 iofst = 8 * (istart + 5)
75 call g2_gbytec(cgrib, listsec0(1), iofst, 8)
77 call g2_gbytec(cgrib, listsec0(2), iofst, 8)
83 ipos = istart + lensec0
86 if (listsec0(2) .ne. 2)
then
87 print *,
'getlocal: can only decode GRIB edition 2.'
97 ctemp = cgrib(ipos) // cgrib(ipos + 1) // cgrib(ipos + 2) // cgrib(ipos + 3)
98 if (ctemp .eq. c7777)
then
102 if (ipos .ne. (istart + lengrib))
then
103 print *,
'getlocal: "7777" found, but not where expected.'
111 iofst = (ipos - 1) * 8
119 if (isecnum .eq. 2)
then
120 numlocal = numlocal + 1
121 if (numlocal.eq.localnum)
then
123 csec2(1:lcsec2) = cgrib(ipos + 5:ipos + lensec - 1)
131 if (ipos .gt. (istart + lengrib))
then
132 print *,
'getlocal: "7777" not found at end of GRIB message.'
140 print *,
'getlocal: GRIB message contained ', numlocal,
' local sections.'
141 print *,
'getlocal: The request was for the ', localnum,
' occurrence.'
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 getlocal(cgrib, lcgrib, localnum, csec2, lcsec2, ierr)
This subroutine returns the contents of Section 2 from a GRIB2 message.