43 integer,
dimension(200) :: ids, gdt, pdt
44 integer :: dscpl, gdtn, pdtn
45 integer :: nbul, nrec, mbul, dayofmonth, hourofday
46 integer,
parameter :: lenhead=21, jrew=0
48 CHARACTER * 80 desc, wmohead
49 CHARACTER * 200 fileb, filei, fileo
51 CHARACTER * 1 csep(80)
52 CHARACTER * 1 wmohdr(lenhead)
53 character(len=1),
pointer,
dimension(:) :: gribm
55 logical :: extract=.false.
57 integer (kind = 8) :: itot8
60 subroutine getgb2p2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, &
61 extract, idxver, k, gribm, leng8, iret)
62 integer,
intent(in) :: lugb, lugi, j, jdisc
63 integer,
dimension(:) :: jids(*)
64 integer,
intent(in) :: jpdtn
65 integer,
dimension(:) :: jpdt(*)
66 integer,
intent(in) :: jgdtn
67 integer,
dimension(:) :: jgdt(*)
68 logical,
intent(in) :: extract
69 integer,
intent(inout) :: idxver
70 integer,
intent(out) :: k
71 character(len = 1),
pointer,
dimension(:) :: gribm
72 integer (kind = 8),
intent(out) :: leng8
73 integer,
intent(out) :: iret
76 namelist /gribids/dscpl,ids,gdtn,gdt,pdtn,pdt,desc,wmohead,extract
78 CALL w3tagb(
'tocgrib2', 2012, 0916, 0083,
'NP11')
87 write(envvar(5:6), fmt=
'(I2)') lugb
88 call getenv(envvar, fileb)
89 write(envvar(5:6), fmt=
'(I2)') lugi
90 call getenv(envvar, filei)
92 call baopenr(lugb, fileb, iret1)
93 if (iret1 .ne. 0)
then
94 write(6, fmt=
'(" Error opening GRIB file: ", A200)') fileb
95 write(6, fmt=
'(" baopenr error = ", I5)') iret1
101 call baopenr(lugi, filei, iret2)
102 if (iret2 .ne. 0)
then
108 write(envvar(5:6), fmt=
'(I2)') lugo
109 call getenv(envvar, fileo)
110 call baopenw(lugo, fileo, iret1)
111 if (iret1 .ne. 0)
then
112 write(6, fmt=
'(" Error opening output transmission file: ", &
114 write(6, fmt=
'(" baopenw error = ", I5)') iret1
122 foreachinputrecord:
do
131 wmohead=
'TTAAnn CCCC'
134 READ (*, gribids, iostat=ios,
end=999)
137 write(6, fmt=
'(" Error reading PDS from input file. iostat = " &
143 WRITE(6, fmt=
'(/, ''***********************************'', &
144 ''********************************************'')')
145 write(6,
'(A, I0)')
' Start new record no. = ', nrec
146 write(6,
'(73A)')
' DESC=', desc(1:73)
147 write(6,
'(11A)')
' WMOHEAD=', wmohead(1:11)
148 write(6,
'(A, I0)')
' GRIB2 DISCIPLINE= ', dscpl
149 write(6,
'(A, 20(1x, I0))')
' Section 1=', &
151 if (gdtn .ne. -1)
then
152 write(6,
'(A, I0, A, 100(1x, I0))')
' GDT 3. ', gdtn,
' =', &
153 (gdt(j2), j2=1, getgdtlen(gdtn))
155 if (pdtn .ne. -1)
then
156 write(6,
'(A, I0, A, 100(1x, I0))')
' PDT 4. ', pdtn,
' =', &
157 (pdt(j2), j2=1, getpdtlen(pdtn))
162 CALL getgb2p2(lugb, lugi, jrew, dscpl, ids, pdtn, pdt, &
163 gdtn, gdt, extract, idxver, krew, gribm, itot8, iret)
164 itot = int(itot8, kind(4))
166 IF (iret.EQ.96)
WRITE(6,
'(A)')
' GETGB2P: ERROR READING INDEX' &
168 IF (iret.EQ.97)
WRITE(6,
'(A)')
' GETGB2P: ERROR READING GRIB' &
170 IF (iret.EQ.99)
WRITE(6,
'(A)')
' GETGB2P: ERROR REQUEST NOT' &
174 WRITE (6,
'(A, 1x, I0)')
' RECORD NO. OF GRIB RECORD IN INPUT ' &
177 WRITE (6,
'(A, I0)')
' Size of GRIB Field = ', itot
182 call mkfldsep(csep, iopt, insize, itot+lenhead, lenout)
186 dayofmonth=mova2i(gribm(16+16))
187 hourofday=mova2i(gribm(16+17))
188 CALL makwmo (wmohead(1:6), dayofmonth, hourofday, &
189 wmohead(8:11), wmohdr)
194 call wryte(lugo, lenout, csep)
195 call wryte(lugo, lenhead, wmohdr)
196 call wryte(lugo, itot, gribm)
198 if (
associated(gribm))
then
203 enddo foreachinputrecord
206999
if (nbul .EQ. 0)
then
207 WRITE (6, fmt=
'('' SOMETHING WRONG WITH DATA CARDS...'', &
208 ''NOTHING WAS PROCESSED'')')
212 call baclose (lugb, iret)
213 call baclose (lugi, iret)
214 call baclose (lugo, iret)
215 WRITE (6, fmt=
'(//, '' ******** RECAP OF THIS EXECUTION '', &
216 ''********'', /, 5X, ''READ '', I6, '' INDIVIDUAL IDS'', &
217 /, 5X, ''WROTE '', I6, '' BULLETINS OUT FOR TRANSMISSION'', &
222 IF (mbul .ne. 0)
THEN
223 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 tocgrib2
Program reads selected GRIB2 fields from a file, adds a TOC Flag Field separator block and WMO Header...
subroutine mkfldsep(csep, iopt, lenin, lenbull, lenout)
Generates a TOC Flag Field Separator Block used to separate WMO Bulletins within a transmission file ...