67 igdslen, ideflist, idefnum, ipdsnum, ipdstmpl, ipdslen, coordlist, numcoord, ierr)
70 character(len = 1),
intent(in) :: cgrib(lcgrib)
71 integer,
intent(in) :: lcgrib, ifldnum
72 integer,
intent(out) :: igds(*), igdstmpl(*), ideflist(*)
73 integer,
intent(out) :: ipdsnum, ipdstmpl(*)
74 integer,
intent(out) :: idefnum, numcoord
75 integer,
intent(out) :: ierr
76 real,
intent(out) :: coordlist(*)
78 character(len = 4),
parameter :: grib =
'GRIB', c7777 =
'7777'
79 character(len = 4) :: ctemp
83 integer :: igdslen, ipdslen, ipos, isecnum, j, jerr, lengrib, lensec, lensec0, numfld
91 if (ifldnum .le. 0)
then
92 print *,
'gettemplates: Request for field number must be positive.'
100 ctemp = cgrib(j) // cgrib(j + 1) // cgrib(j + 2) // cgrib(j + 3)
101 if (ctemp .eq. grib )
then
106 if (istart .eq. 0)
then
107 print *,
'gettemplates: Beginning characters GRIB not found.'
113 iofst = 8 * (istart + 5)
114 call g2_gbytec(cgrib, listsec0(1), iofst, 8)
116 call g2_gbytec(cgrib, listsec0(2), iofst, 8)
119 call g2_gbytec(cgrib, lengrib, iofst, 32)
122 ipos = istart + lensec0
125 if (listsec0(2) .ne. 2)
then
126 print *,
'gettemplates: can only decode GRIB edition 2.'
136 ctemp = cgrib(ipos) // cgrib(ipos + 1) // cgrib(ipos + 2) // cgrib(ipos + 3)
137 if (ctemp .eq. c7777 )
then
140 if (ipos .ne. (istart + lengrib))
then
141 print *,
'gettemplates: "7777" found, but not where expected.'
148 iofst = (ipos - 1) * 8
158 if (isecnum .eq. 3)
then
160 call unpack3(cgrib, lcgrib, iofst, igds, igdstmpl, igdslen, ideflist, idefnum, jerr)
161 if (jerr .eq. 0)
then
171 if (isecnum .eq. 4)
then
173 if (numfld .eq. ifldnum)
then
175 call unpack4(cgrib, lcgrib, iofst, ipdsnum, ipdstmpl, ipdslen, coordlist, numcoord, jerr)
176 if (jerr .eq. 0)
then
188 if (ipos .gt. (istart + lengrib))
then
189 print *,
'gettemplates: "7777" not found at end of GRIB message.'
194 if (have3.and.have4)
return
199 print *,
'gettemplates: GRIB message contained ', numfld,
' different fields.'
200 print *,
'gettemplates: The request was for the ', ifldnum,
' field.'
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 unpack4(cgrib, lcgrib, iofst, ipdsnum, ipdstmpl, mappdslen, coordlist, numcoord, ierr)
This subroutine unpacks Section 4 (Product Definition Section) starting at octet 6 of that Section.
subroutine unpack3(cgrib, lcgrib, iofst, igds, igdstmpl, mapgridlen, ideflist, idefnum, ierr)
This subroutine unpacks Section 3 (Grid Definition Section) starting at octet 6 of that Section.
subroutine gettemplates(cgrib, lcgrib, ifldnum, igds, igdstmpl, igdslen, ideflist, idefnum, ipdsnum, ipdstmpl, ipdslen, coordlist, numcoord, ierr)
This subroutine returns the Grid Definition, and Product Definition for a given data field.