33 parameter(mxsiz3=1000000)
45 INTEGER,
dimension(28) :: hexpds
51 CHARACTER * 1 grib(mxsiz3)
52 CHARACTER * 200 fileb,filei,fileo
56 CHARACTER * 1 pdsl(28)
57 CHARACTER * 1 csep(80)
59 integer,
parameter :: lenhead=21
60 CHARACTER * 1 wmohdr(lenhead)
73 CALL w3as00(nparm, cparm, ier)
75 IF (nparm .EQ. 0 .OR. cparm(1:4) .EQ.
' ')
THEN
76 print *,
'THERE IS A PARM FIELD BUT IT IS EMPTY'
77 print *,
'OR BLANK, I WILL USE THE DEFAULT KWBC'
79 kwbx(1:4) = cparm(1:4)
81 ELSE IF (ier .EQ. 2 .OR. ier .EQ. 3)
THEN
82 print *,
'W3AS00 ERROR = ', ier
83 print *,
'THERE IS NO PARM FIELD, I USED DEFAULT KWBC'
85 print *,
'W3AS00 ERROR = ', ier
87 print *,
'NPARM = ',nparm
88 print *,
'CPARM = ',cparm(1:4)
89 print *,
'KWBX = ',kwbx(1:4)
94 write(envvar(5:6),fmt=
'(I2)') lugb
95 call getenv(envvar,fileb)
96 write(envvar(5:6),fmt=
'(I2)') lugi
97 call getenv(envvar,filei)
99 call baopenr(lugb,fileb,iret1)
100 if ( iret1 .ne. 0 )
then
101 write(6,fmt=
'(" Error opening GRIB file: ", A200)') fileb
102 write(6,fmt=
'(" baopenr error = ",I5)') iret1
108 call baopenr(lugi,filei,iret2)
109 if ( iret2 .ne. 0 )
then
115 write(envvar(5:6),fmt=
'(I2)') lugo
116 call getenv(envvar,fileo)
117 call baopenw(lugo,fileo,iret1)
118 if ( iret1 .ne. 0 )
then
119 write(6,fmt=
'(" Error opening GRIB file: ",A200)') fileo
120 write(6,fmt=
'(" baopenw error = ",I5)') iret1
133 READ (*,66,iostat=ios) (hexpds(j),j=1,12), &
134 (hexpds(j),j=17,20), punum, desc
13566
FORMAT(3(2x,4z2.2),3x,4z2.2,6x,i3,1x,a20)
136 if ( ios .ne. 0 )
then
137 write(6,fmt=
'(" Error reading PDS from input file. iostat = ", i5)') ios
143 IF ( mova2i(pds(1)) .EQ. 255)
exit
146 WRITE(6,fmt=
'(/,''***********************************'', ''********************************************'')')
147 print *,
'Start new record no. = ',nrec
148 WRITE (6,fmt=
'('' INPUT PDS, PUNUM'', '' & DESC...DESIRED GRIB MAPS LISTED ON FOLLOWING '', ' // &
149 ' ''LINES...'',/,4X,3(2X,4z2.2),3X,4z2.2,6X,I3,1X, A20)') (hexpds(j),j=1,12), &
150 (hexpds(j),j=17,20), punum, desc
153 READ (*,iostat=ios,fmt=
'(4X,I3,2X,I2,2X,A6,1X,I3,24X,A3)') &
154 mapnum,nbits, bulhed, dum, eoml
155 WRITE (6,fmt=
'(4X,I3,2X,I2,2X,A6,1X,I3,24X,A3)') &
156 mapnum,nbits, bulhed, dum, eoml
157 if ( ios .ne. 0 )
then
158 write(6,fmt=
'(" Error reading PDS from input file. iostat =", i6)') ios
165 mpds(3) = mova2i(pds(7))
166 mpds(5) = mova2i(pds(9))
167 mpds(6) = mova2i(pds(10))
168 mpds(7) = mova2i(pds(11)) * 256 + mova2i(pds(12))
169 mpds(14) = mova2i(pds(19))
170 mpds(15) = mova2i(pds(20))
173 CALL getgbp(lugb,lugi,mxsiz3,jrew,mpds,jgds, &
174 itot,krew,kpds,kgds,grib,iret)
176 IF (iret.LT.96) print *,
'GETGB-W3FI63: ERROR = ',iret
177 IF (iret.EQ.96) print *,
'GETGB: ERROR READING INDEX FILE'
178 IF (iret.EQ.97) print *,
'GETGB: ERROR READING GRIB FILE'
180 print *,
'GETGB ERROR: NUM. OF DATA POINTS GREATER THAN JF'
182 IF (iret.EQ.99) print *,
'GETGB ERROR: REQUEST NOT FOUND'
183 IF (iret.GT.99) print *,
'GETGB ERROR = ',iret
186 print *,
'RECORD NO. OF GRIB RECORD IN INPUT FILE = ',krew
189 pdsl(1:28)=grib(9:36)
191 IF (.NOT.iw3pds(pdsl,pds,key))
THEN
192 print 2900, nrec,(mova2i(pdsl(j)),j=1,28), &
193 (mova2i(pds(j)),j=1,28)
1942900
FORMAT ( 1x,i4,
' (PDS) IN RECORD DOES NOT MATCH (PDS) IN ',
'CONTROL CARD ',/,7(1x,4z2.2), /,7(1x,4z2.2))
199 print 2, (mova2i(pdsl(j)),j=1,28)
2002
FORMAT (
' PDS = ',7(4z2.2,1x))
203 CALL w3fp11 (grib,pdsl,title,ier)
204 IF (ier.NE.0) print *,
'W3FP11 ERROR = ',ier
207 print *,
' Size of GRIB Field = ',itot
210 call mkfldsep(csep,iopt,insize,itot+lenhead,lenout)
214 CALL makwmo (bulhed,kpds(10),kpds(11),kwbx,wmohdr)
218 call wryte(lugo,lenout,csep)
219 call wryte(lugo,lenhead,wmohdr)
220 call wryte(lugo,itot,grib)
225 IF (nbul .EQ. 0 )
THEN
226 WRITE (6,fmt=
'('' SOMETHING WRONG WITH DATA CARDS...'', ''NOTHING WAS PROCESSED'')')
229 CALL baclose (lugb,iret)
230 CALL baclose (lugi,iret)
231 CALL baclose (lugo,iret)
232 WRITE (6,fmt=
'(//,'' ******** RECAP OF THIS EXECUTION '', ''********'',/,5X,''READ '',I6,'' INDIVIDUAL IDS'', ' // &
233 ' /,5X,''WROTE '',I6,'' BULLETINS OUT FOR TRANSMISSION'', //)') nrec, nbul
239 print *,
'BULLETINS MISSING = ',mbul
299 character*(*),
intent(out) :: csep
300 integer,
intent(in) :: iopt,lenin,lenbull
301 integer,
intent(out) :: lenout
303 character(len=4),
parameter :: cstar=
'****',clb=
'####'
306 if ( lenin .le. 18 .and. lenbull .le. 999999 )
then
310 write(csep(8:13),fmt=
'(I6.6)') lenbull
316 if ( nnn.lt.23 ) nnn=23
318 write(csep(5:7),fmt=
'(I3.3)') nnn
319 write(csep(8:18),fmt=
'(I11.11)') lenbull
321 csep(nnn-4:nnn-1)=clb
322 csep(nnn:nnn)=char(10)
325 elseif (iopt.eq.2)
then
327 write(csep(5:14),fmt=
'(I10.10)') lenbull
332 print *,
"mkfldsep: Option ",iopt,
" not recognized."
337end subroutine mkfldsep
subroutine makwmo(bulhed, iday, ihour, imin, kwbx, header)
Forms the wmo header for a given bulletin.
program tocgrib
Create new GRIB2 file from exiting GRIB2 file.
subroutine mkfldsep(csep, iopt, lenin, lenbull, lenout)
Generates a TOC Flag Field Separator Block used to separate WMO Bulletins within a transmission file ...