50 subroutine gf_unpack3(cgrib, lcgrib, iofst, igds, igdstmpl, &
51 mapgridlen, ideflist, idefnum, ierr)
57 character(len = 1),
intent(in) :: cgrib(lcgrib)
58 integer,
intent(in) :: lcgrib
59 integer,
intent(inout) :: iofst
60 integer,
pointer,
dimension(:) :: igdstmpl, ideflist
61 integer,
intent(out) :: igds(5)
62 integer,
intent(out) :: ierr, idefnum
64 integer,
allocatable :: mapgrid(:)
65 integer,
intent(out) :: mapgridlen
68 integer :: lensec, istat, i, nbits, isign, newmapgridlen, iret
71 nullify(igdstmpl, ideflist)
88 if (igds(1) .eq. 0 .OR. igds(1) .eq. 255)
then
89 allocate(mapgrid(lensec))
95 if (
allocated(mapgrid))
deallocate(mapgrid)
107 if (mapgridlen .gt. 0)
allocate(igdstmpl(mapgridlen), stat = istat)
108 if (istat .ne. 0)
then
111 if (
allocated(mapgrid))
deallocate(mapgrid)
116 nbits = iabs(mapgrid(i)) * 8
117 if (mapgrid(i) .ge. 0)
then
118 call g2_gbytec(cgrib, igdstmpl(i), iofst, nbits)
121 call g2_gbytec(cgrib, igdstmpl(i), iofst + 1, nbits - 1)
122 if (isign .eq. 1) igdstmpl(i) = -igdstmpl(i)
124 iofst = iofst + nbits
125 ibyttem = ibyttem + iabs(mapgrid(i))
136 call realloc(igdstmpl, mapgridlen, newmapgridlen, istat)
137 do i = mapgridlen + 1, newmapgridlen
138 nbits = iabs(mapgrid(i)) * 8
139 if (mapgrid(i) .ge. 0)
then
140 call g2_gbytec(cgrib, igdstmpl(i), iofst, nbits)
143 call g2_gbytec(cgrib, igdstmpl(i), iofst + 1, nbits - 1)
144 if (isign.eq.1) igdstmpl(i) = -igdstmpl(i)
146 iofst = iofst + nbits
147 ibyttem = ibyttem + iabs(mapgrid(i))
149 mapgridlen = newmapgridlen
151 if (
allocated(mapgrid))
deallocate(mapgrid)
155 if (igds(3) .ne. 0)
then
157 idefnum = (lensec - 14 - ibyttem) / igds(3)
159 if (idefnum .gt. 0)
allocate(ideflist(idefnum), stat = istat)
160 if (istat .ne. 0)
then
165 call g2_gbytesc(cgrib, ideflist, iofst, nbits, 0, idefnum)
166 iofst = iofst + (nbits * idefnum)
subroutine g2_gbytesc(in, iout, iskip, nbits, nskip, n)
Extract arbitrary size values from a packed bit string, right justifying each value in the unpacked a...
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 gf_unpack3(cgrib, lcgrib, iofst, igds, igdstmpl, mapgridlen, ideflist, idefnum, ierr)
Unpack Section 3 (Grid Definition Section) of a GRIB2 message, starting at octet 6 of that Section.
This Fortran module contains info on all the available GRIB2 Grid Definition Templates used in [Secti...
subroutine getgridtemplate(number, nummap, map, needext, iret)
Get the grid template information for a specified Grid Definition Template.
subroutine extgridtemplate(number, list, nummap, map)
Generate the remaining octet map for a given Grid Definition Template, if required.
Reallocate memory, preserving contents.