46 subroutine addgrid(cgrib,lcgrib,igds,igdstmpl,igdstmplen,
47 & ideflist,idefnum,ierr)
51 character(len=1),
intent(inout) :: cgrib(lcgrib)
52 integer,
intent(in) :: igds(*),igdstmpl(*),ideflist(idefnum)
53 integer,
intent(in) :: lcgrib,idefnum,igdstmplen
54 integer,
intent(out) :: ierr
56 character(len=4),
parameter :: grib=
'GRIB',c7777=
'7777'
57 character(len=4):: ctemp
58 integer:: mapgrid(igdstmplen)
59 integer,
parameter :: one=1,three=3
60 integer lensec3,iofst,ibeg,lencurr,len,mapgridlen
68 if(cgrib(i)/=grib(i:i))
then
69 print *,
'addgrid: GRIB not found in given message.'
70 print *,
'addgrid: Call to routine gribcreate required',
71 &
' to initialize GRIB messge.'
72 10
format(
'"',4a1,
'" /= "GRIB"')
86 ctemp=cgrib(lencurr-3)//cgrib(lencurr-2)//cgrib(lencurr-1)
88 if ( ctemp.eq.c7777 )
then
89 print *,
'addgrid: GRIB message already complete. Cannot',
107 if ( len.eq.lencurr )
exit
110 if ( len.gt.lencurr )
then
111 print *,
'addgrid: Section byte counts don''t add to total.'
112 print *,
'addgrid: Sum of section byte counts = ',len
113 print *,
'addgrid: Total byte count in Section 0 = ',lencurr
121 if ( (isecnum.ne.1) .and. (isecnum.ne.2) .and.
122 & (isecnum.ne.7) )
then
123 print *,
'addgrid: Section 3 can only be added after Section',
125 print *,
'addgrid: Section ',isecnum,
' was the last found in',
126 &
' given GRIB message.'
147 if ( igds(1).eq.0 )
then
156 if (igds(1).eq.0)
then
181 nbits=iabs(mapgrid(i))*8
182 if ( (mapgrid(i).ge.0).or.(igdstmpl(i).ge.0) )
then
183 call g2_sbytec(cgrib,igdstmpl(i),iofst,nbits)
186 call g2_sbytec(cgrib,iabs(igdstmpl(i)),iofst+1,nbits-1)
196 if ( igds(3).ne.0 )
then
198 call g2_sbytesc(cgrib,ideflist,iofst,nbits,0,idefnum)
199 iofst=iofst+(nbits*idefnum)
205 lensec3=(iofst-ibeg)/8
211 call g2_sbytec(cgrib,lencurr+lensec3,96,32)