46 integer,
dimension(200) :: ids,gdt,pdt
47 integer :: dscpl,gdtn,pdtn
48 integer :: nbul,nrec,mbul,dayofmonth,hourofday,minofhour
49 integer,
parameter :: lenhead=21,jrew=0
53 CHARACTER * 16 superwmo
54 CHARACTER * 80 desc,wmohead
55 CHARACTER * 200 fileb,filei,fileo,filea
57 CHARACTER * 1 csep(80)
58 CHARACTER * 1 wmohdr(lenhead)
59 character(len=1),
pointer,
dimension(:) :: gribm
61 logical :: extract=.false.
63 integer (kind = 8) :: itot8
66 subroutine getgb2p2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
67 extract, idxver, k, gribm, leng8, iret)
68 integer,
intent(in) :: lugb, lugi, j, jdisc
69 integer,
dimension(:) :: jids(*)
70 integer,
intent(in) :: jpdtn
71 integer,
dimension(:) :: jpdt(*)
72 integer,
intent(in) :: jgdtn
73 integer,
dimension(:) :: jgdt(*)
74 logical,
intent(in) :: extract
75 integer,
intent(inout) :: idxver
76 integer,
intent(out) :: k
77 character(len = 1),
pointer,
dimension(:) :: gribm
78 integer (kind = 8),
intent(out) :: leng8
79 integer,
intent(out) :: iret
83 namelist /gribids/dscpl,ids,gdtn,gdt,pdtn,pdt,desc,wmohead,extract
85 CALL w3tagb(
'tocgrib2super',2010,0900,0246,
'NP11')
90 superwmo =
'SUPER WMO HEADER'
97 write(envvar(5:6),fmt=
'(I2)') lugb
98 call getenv(envvar,fileb)
99 write(envvar(5:6),fmt=
'(I2)') luga
100 call getenv(envvar,filea)
101 write(envvar(5:6),fmt=
'(I2)') lugi
102 call getenv(envvar,filei)
107 open(unit=luga,file=
'filesize',form=
'formatted',status=
'old', &
109 if (iret1 .ne. 0)
then
110 write(6,fmt=
'(" Error opening GRIB file: ",A200)') filea
111 write(6,fmt=
'(" baopenr error = ",I5)') iret1
115 READ(luga,
'(I15)') fsize
116 print *,
' filesize ', fsize
118 call baopenr(lugb,fileb,iret1)
119 if (iret1 .ne. 0)
then
120 write(6,fmt=
'(" Error opening GRIB file: ",A200)')fileb
121 write(6,fmt=
'(" baopenr error = ",I5)') iret1
128 call baopenr(lugi,filei,iret2)
129 if (iret2 .ne. 0)
then
137 write(envvar(5:6),fmt=
'(I2)') lugo
138 call getenv(envvar,fileo)
139 call baopenw(lugo,fileo,iret1)
140 if (iret1 .ne. 0)
then
141 write(6,fmt=
'(" Error opening output transmission file: ", &
143 write(6,fmt=
'(" baopenw error = ",I5)') iret1
151 if (fsize >= insize)
then
152 fsize = fsize - insize
162 foreachinputrecord:
do
173 wmohead=
'TTAAnn CCCC'
177 READ (*,gribids,iostat=ios,
end=999)
179 if (desc(1:16) .EQ. superwmo(1:16))
then
183 call mkfldsep(csep,iopt,insize,fsize,lenout)
192 CALL makwmo (wmohead(1:6),dayofmonth,hourofday,minofhour, &
193 wmohead(8:11),wmohdr)
198 call wryte(lugo,lenout,csep)
199 call wryte(lugo,lenhead,wmohdr)
201 write(6,
'(16A)')
' DESC=',desc(1:16)
202 write(6,
'(11A)')
' WMOHEAD=',wmohead(1:11)
209 write(6,fmt=
'(" Error reading PDS from input file. iostat = " &
216 WRITE(6,fmt=
'(/,''***********************************'', &
217 ''********************************************'')')
218 write(6,
'(A,I0)')
' Start new record no. = ',nrec
219 write(6,
'(73A)')
' DESC=',desc(1:73)
220 write(6,
'(11A)')
' WMOHEAD=',wmohead(1:11)
221 write(6,
'(A,I0)')
' GRIB2 DISCIPLINE= ',dscpl
222 write(6,
'(A,20(1x,I0))')
' Section 1=', &
224 if (gdtn .ne. -1)
then
225 write(6,
'(A,I0,A,100(1x,I0))')
' GDT 3. ',gdtn,
' =', &
226 (gdt(j2),j2=1,getgdtlen(gdtn))
228 if (pdtn .ne. -1)
then
229 write(6,
'(A,I0,A,100(1x,I0))')
' PDT 4. ',pdtn,
' =', &
230 (pdt(j2),j2=1,getpdtlen(pdtn))
236 CALL getgb2p2(lugb,lugi,jrew,dscpl,ids,pdtn,pdt, &
237 gdtn,gdt,extract,idxver,krew,gribm,itot8,iret)
238 itot = int(itot8, kind(4))
240 IF (iret.EQ.96)
WRITE(6,
'(A)')
' GETGB2P: ERROR READING INDEX' &
242 IF (iret.EQ.97)
WRITE(6,
'(A)')
' GETGB2P: ERROR READING GRIB' &
244 IF (iret.EQ.99)
WRITE(6,
'(A)')
' GETGB2P: ERROR REQUEST NOT' &
248 WRITE (6,
'(A,1x,I0)')
' RECORD NO. OF GRIB RECORD IN INPUT ' &
251 WRITE (6,
'(A,I0)')
' Size of GRIB Field = ',itot
255 call mkfldsep(csep,iopt,insize,itot+lenhead,lenout)
260 CALL makwmo (wmohead(1:6),dayofmonth,hourofday,minofhour, &
261 wmohead(8:11),wmohdr)
267 call wryte(lugo,lenout,csep)
268 call wryte(lugo,lenhead,wmohdr)
269 call wryte(lugo,itot,gribm)
271 if (
associated(gribm))
then
276 enddo foreachinputrecord
280999
if (nbul .EQ. 0)
then
281 WRITE (6,fmt=
'('' SOMETHING WRONG WITH DATA CARDS...'', &
282 ''NOTHING WAS PROCESSED'')')
286 call baclose (lugb,iret)
287 call baclose (lugi,iret)
288 call baclose (lugo,iret)
289 WRITE (6,fmt=
'(//,'' ******** RECAP OF THIS EXECUTION '', &
290 ''********'',/,5X,''READ '',I6,'' INDIVIDUAL IDS'', &
291 /,5X,''WROTE '',I6,'' BULLETINS OUT FOR TRANSMISSION'', &
298 IF (mbul .ne. 0)
THEN
299 WRITE(6,
'(A,1X,I0)')
' BULLETINS MISSING = ',mbul
subroutine getgb2p2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, extract, idxver, k, gribm, leng8, iret)
Find and extract a GRIB2 message from a file.
subroutine makwmo(bulhed, iday, ihour, imin, kwbx, header)
Forms the wmo header for a given bulletin.
This Fortran module contains the declaration of derived type gribfield.
This Fortran module contains info on all the available GRIB2 Grid Definition Templates used in [Secti...
Information on all GRIB2 Product Definition Templates used in Section 4 - the Product Definition Sect...
program tocgrib2super
This program reads selected GRIB2 fields from a file, adds a flag Field separator block and the size ...
subroutine mkfldsep(csep, iopt, lenin, lenbull, lenout)
Generates a TOC Flag Field Separator Block used to separate WMO Bulletins within a transmission file ...