78 SUBROUTINE getgb2s(CBUF, NLEN, NNUM, J, JDISC, JIDS, JPDTN, JPDT, JGDTN, &
79 JGDT, K, GFLD, LPOS, IRET)
83 CHARACTER(LEN = 1),
INTENT(IN) :: CBUF(NLEN)
84 INTEGER,
INTENT(IN) :: NLEN, NNUM, J, JDISC, JPDTN, JGDTN
85 INTEGER,
DIMENSION(:) :: JIDS(*), JPDT(*), JGDT(*)
86 INTEGER,
INTENT(OUT) :: K, LPOS, IRET
90 LOGICAL :: MATCH1, MATCH3, MATCH4
91 integer :: i, icnd, inlen, iof, ipos, jpos, lsec1, lsec3, lsec4, lsec5, numgdt, numpdt
94 subroutine gf_unpack1(cgrib, lcgrib, iofst, ids, idslen, ierr)
95 character(len = 1),
intent(in) :: cgrib(lcgrib)
96 integer,
intent(in) :: lcgrib
97 integer,
intent(inout) :: iofst
98 integer,
pointer,
dimension(:) :: ids
99 integer,
intent(out) :: ierr, idslen
101 subroutine gf_unpack3(cgrib, lcgrib, iofst, igds, igdstmpl, &
102 mapgridlen, ideflist, idefnum, ierr)
103 character(len = 1),
intent(in) :: cgrib(lcgrib)
104 integer,
intent(in) :: lcgrib
105 integer,
intent(inout) :: iofst
106 integer,
pointer,
dimension(:) :: igdstmpl, ideflist
107 integer,
intent(out) :: igds(5)
108 integer,
intent(out) :: ierr, idefnum
110 subroutine gf_unpack4(cgrib, lcgrib, iofst, ipdsnum, ipdstmpl, &
111 mappdslen, coordlist, numcoord, ierr)
112 character(len = 1),
intent(in) :: cgrib(lcgrib)
113 integer,
intent(in) :: lcgrib
114 integer,
intent(inout) :: iofst
115 real,
pointer,
dimension(:) :: coordlist
116 integer,
pointer,
dimension(:) :: ipdstmpl
117 integer,
intent(out) :: ipdsnum
118 integer,
intent(out) :: ierr, numcoord
120 subroutine gf_unpack5(cgrib, lcgrib, iofst, ndpts, idrsnum, &
121 idrstmpl, mapdrslen, ierr)
122 character(len = 1),
intent(in) :: cgrib(lcgrib)
123 integer,
intent(in) :: lcgrib
124 integer,
intent(inout) :: iofst
125 integer,
intent(out) :: ndpts, idrsnum
126 integer,
pointer,
dimension(:) :: idrstmpl
127 integer,
intent(out) :: ierr
136 nullify(gfld%idsect, gfld%local)
137 nullify(gfld%list_opt, gfld%igdtmpl, gfld%ipdtmpl)
138 nullify(gfld%coord_list, gfld%idrtmpl, gfld%bmap, gfld%fld)
141 DO WHILE(iret.NE.0 .and. k.LT.nnum)
143 CALL g2_gbytec(cbuf, inlen, ipos * 8, 4 * 8)
151 CALL g2_gbytec(cbuf, gfld%DISCIPLINE, (ipos + 41)*8, 1*8)
152 IF ((jdisc.NE.-1) .and. (jdisc.NE.gfld%DISCIPLINE))
THEN
159 CALL g2_gbytec(cbuf, lsec1, (ipos + 44) * 8, 4 * 8)
161 CALL gf_unpack1(cbuf(ipos + 45), lsec1, iof, gfld%IDSECT, gfld%IDSECTLEN, icnd)
162 IF (icnd .eq. 0)
THEN
164 DO i = 1, gfld%IDSECTLEN
165 IF ((jids(i).NE.-9999) .and. (jids(i).NE.gfld%IDSECT(i)))
THEN
171 IF (.NOT. match1)
THEN
172 DEALLOCATE(gfld%IDSECT)
178 jpos = ipos + 44 + lsec1
180 CALL g2_gbytec(cbuf, lsec3, jpos * 8, 4 * 8)
181 IF (jgdtn .eq. -1)
THEN
184 CALL g2_gbytec(cbuf, numgdt, (jpos + 12) * 8, 2 * 8)
185 IF (jgdtn .eq. numgdt)
THEN
187 CALL gf_unpack3(cbuf(jpos + 1), lsec3, iof, kgds, gfld%IGDTMPL, &
188 gfld%IGDTLEN, gfld%LIST_OPT, gfld%NUM_OPT, icnd)
189 IF (icnd .eq. 0)
THEN
191 DO i = 1, gfld%IGDTLEN
192 IF ((jgdt(i).NE.-9999) .and. (jgdt(i).NE.gfld%IGDTMPL(i)))
THEN
200 IF (.NOT. match3)
THEN
201 IF (
ASSOCIATED(gfld%IDSECT))
DEALLOCATE(gfld%IDSECT)
202 IF (
ASSOCIATED(gfld%IGDTMPL))
DEALLOCATE(gfld%IGDTMPL)
203 IF (
ASSOCIATED(gfld%LIST_OPT))
DEALLOCATE(gfld%LIST_OPT)
207 gfld%GRIDDEF = kgds(1)
208 gfld%NGRDPTS = kgds(2)
209 gfld%NUMOCT_OPT = kgds(3)
210 gfld%INTERP_OPT = kgds(4)
211 gfld%IGDTNUM = kgds(5)
217 CALL g2_gbytec(cbuf, lsec4, jpos * 8, 4 * 8)
218 IF (jpdtn .eq. -1)
THEN
221 CALL g2_gbytec(cbuf, numpdt, (jpos + 7) * 8, 2 * 8)
222 IF (jpdtn .eq. numpdt)
THEN
224 CALL gf_unpack4(cbuf(jpos + 1), lsec4, iof, gfld%IPDTNUM, &
225 gfld%IPDTMPL, gfld%IPDTLEN, gfld%COORD_LIST, gfld%NUM_COORD, icnd)
226 IF (icnd .eq. 0)
THEN
228 DO i = 1, gfld%IPDTLEN
229 IF ((jpdt(i).NE.-9999) .and. (jpdt(i).NE.gfld%IPDTMPL(i)))
THEN
237 IF (.NOT. match4)
THEN
238 IF (
ASSOCIATED(gfld%IDSECT))
DEALLOCATE(gfld%IDSECT)
239 IF (
ASSOCIATED(gfld%IPDTMPL))
DEALLOCATE(gfld%IPDTMPL)
240 IF (
ASSOCIATED(gfld%COORD_LIST))
DEALLOCATE(gfld%COORD_LIST)
245 IF(match1 .and. match3 .and. match4)
THEN
247 CALL g2_gbytec(cbuf, gfld%VERSION, (ipos + 40) * 8, 1 * 8)
248 CALL g2_gbytec(cbuf, gfld%IFLDNUM, (ipos + 42) * 8, 2 * 8)
249 gfld%UNPACKED = .false.
250 jpos = ipos + 44 + lsec1
251 IF (jgdtn.EQ.-1)
THEN
253 CALL gf_unpack3(cbuf(jpos + 1), lsec3, iof, kgds, gfld%IGDTMPL, &
254 gfld%IGDTLEN, gfld%LIST_OPT, gfld%NUM_OPT, icnd)
255 gfld%GRIDDEF = kgds(1)
256 gfld%NGRDPTS = kgds(2)
257 gfld%NUMOCT_OPT = kgds(3)
258 gfld%INTERP_OPT = kgds(4)
259 gfld%IGDTNUM = kgds(5)
262 IF (jpdtn.EQ.-1 )
THEN
264 CALL gf_unpack4(cbuf(jpos + 1), lsec4, iof, gfld%IPDTNUM, &
265 gfld%IPDTMPL, gfld%IPDTLEN, gfld%COORD_LIST, gfld%NUM_COORD, icnd)
268 CALL g2_gbytec(cbuf, lsec5, jpos * 8, 4 * 8)
270 CALL gf_unpack5(cbuf(jpos + 1), lsec5, iof, gfld%NDPTS, &
271 gfld%IDRTNUM, gfld%IDRTMPL, gfld%IDRTLEN, icnd)
273 CALL g2_gbytec(cbuf, gfld%IBMAP, (jpos + 5)*8, 1 * 8)
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 getgb2s(CBUF, NLEN, NNUM, J, JDISC, JIDS, JPDTN, JPDT, JGDTN, JGDT, K, GFLD, LPOS, IRET)
Find information about a GRIB field from the index and fill a grib_mod::gribfield.
subroutine gf_unpack1(cgrib, lcgrib, iofst, ids, idslen, ierr)
Unpack Section 1 (Identification Section) of a GRIB2 message, starting at octet 6 of that Section.
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.
subroutine gf_unpack4(cgrib, lcgrib, iofst, ipdsnum, ipdstmpl, mappdslen, coordlist, numcoord, ierr)
Unpack Section 4 (Product Definition Section) of a GRIB2 message, starting at octet 6 of that Section...
subroutine gf_unpack5(cgrib, lcgrib, iofst, ndpts, idrsnum, idrstmpl, mapdrslen, ierr)
Unpack Section 5 (Data Representation Section) of a GRIB2 message, starting at octet 6 of that Sectio...
This Fortran module contains the declaration of derived type gribfield.