69 subroutine gettemplates(cgrib,lcgrib,ifldnum,igds,igdstmpl,
70 & igdslen,ideflist,idefnum,ipdsnum,ipdstmpl,
71 & ipdslen,coordlist,numcoord,ierr)
73 character(len=1),
intent(in) :: cgrib(lcgrib)
74 integer,
intent(in) :: lcgrib,ifldnum
75 integer,
intent(out) :: igds(*),igdstmpl(*),ideflist(*)
76 integer,
intent(out) :: ipdsnum,ipdstmpl(*)
77 integer,
intent(out) :: idefnum,numcoord
78 integer,
intent(out) :: ierr
79 real,
intent(out) :: coordlist(*)
81 character(len=4),
parameter :: grib=
'GRIB',c7777=
'7777'
82 character(len=4) :: ctemp
84 integer iofst,ibeg,istart
94 if (ifldnum.le.0)
then
95 print *,
'gettemplates: Request for field number must be ',
105 ctemp=cgrib(j)//cgrib(j+1)//cgrib(j+2)//cgrib(j+3)
106 if (ctemp.eq.grib )
then
111 if (istart.eq.0)
then
112 print *,
'gettemplates: Beginning characters GRIB not found.'
120 call g2_gbytec(cgrib,listsec0(1),iofst,8)
122 call g2_gbytec(cgrib,listsec0(2),iofst,8)
132 if (listsec0(2).ne.2)
then
133 print *,
'gettemplates: can only decode GRIB edition 2.'
144 ctemp=cgrib(ipos)//cgrib(ipos+1)//cgrib(ipos+2)//cgrib(ipos+3)
145 if (ctemp.eq.c7777 )
then
148 if (ipos.ne.(istart+lengrib))
then
149 print *,
'gettemplates: "7777" found, but not where ',
168 if (isecnum.eq.3)
then
170 call unpack3(cgrib,lcgrib,iofst,igds,igdstmpl,igdslen,
171 & ideflist,idefnum,jerr)
183 if (isecnum.eq.4)
then
185 if (numfld.eq.ifldnum)
then
187 call unpack4(cgrib,lcgrib,iofst,ipdsnum,ipdstmpl,ipdslen,
188 & coordlist,numcoord,jerr)
202 if (ipos.gt.(istart+lengrib))
then
203 print *,
'gettemplates: "7777" not found at end of GRIB ',
209 if (have3.and.have4)
return
217 print *,
'gettemplates: GRIB message contained ',numlocal,
218 &
' different fields.'
219 print *,
'gettemplates: The request was for the ',ifldnum,