NCEPLIBS-w3emc 2.12.0
Loading...
Searching...
No Matches
getgbemp.f
Go to the documentation of this file.
1C> @file
2C> @brief Find a grib message.
3C> @author Mark Iredell @date 1994-04-01
4
5C> Read a grib index file (or optionally the grib file itself)
6C> to get the index buffer (i.e. table of contents) for the grib file.
7C> Find in the index buffer a reference to the grib message requested.
8C> the grib message request specifies the number of messages to skip
9C> and the unpacked pds and gds parameters. (A requested parameter
10C> of -1 means to allow any value of this parameter to be found.)
11C> If the requested grib message is found, then it is read from the
12C> grib file. Its message number is returned along with the unpacked
13C> pds and gds parameters and the packed grib message. If the grib
14C> message is not found, then the return code will be nonzero.
15C>
16C> Program history log:
17C> - Mark Iredell 1994-04-01
18C> - Mark Iredell 1995-10-31 Modularized portions of code into subprograms
19C> and allowed for unspecified index file.
20C>
21C> @param[in] lugb integer unit of the unblocked grib data file.
22C> @param[in] lugi integer unit of the unblocked grib index file
23C> (=0 to get index buffer from the grib file).
24C> @param[in] jg integer maximum number of bytes in the grib message.
25C> @param[in] j integer number of messages to skip
26C> (=0 to search from beginning)
27C> (<0 to read index buffer and skip -1-j messages).
28C> @param[in] jpds integer (200) pds parameters for which to search
29C> (=-1 for wildcard).
30C> - 1: id of center.
31C> - 2: generating process id number.
32C> - 3: grid definition.
33C> - 4: gds/bms flag (right adj copy of octet 8).
34C> - 5: indicator of parameter.
35C> - 6: type of level.
36C> - 7: height/pressure , etc of level.
37C> - 8: year including (century-1).
38C> - 9: month of year.
39C> - 10: day of month.
40C> - 11: hour of day.
41C> - 12: minute of hour.
42C> - 13: indicator of forecast time unit.
43C> - 14: time range 1.
44C> - 15: time range 2.
45C> - 16: time range flag.
46C> - 17: number included in average.
47C> - 18: version nr of grib specification.
48C> - 19: version nr of parameter table.
49C> - 20: nr missing from average/accumulation.
50C> - 21: century of reference time of data.
51C> - 22: units decimal scale factor.
52C> - 23: subcenter number.
53C> - 24: pds byte 29, for nmc ensemble products.
54C> - 128 if forecast field error.
55C> - 64 if bias corrected fcst field.
56C> - 32 if smoothed field.
57C> - warning: can be combination of more than 1.
58C> - 25: pds byte 30, not used.
59C> @param[in] jgds integer (200) gds parameters for which to search
60C> (only searched if jpds(3)=255)
61C> (=-1 for wildcard).
62C> - 1: data representation type.
63C> - 19: number of vertical coordinate parameters.
64C> - 20: octet number of the list of vertical coordinate parameters or
65C> octet number of the list of numbers of points in each row or
66C> 255 if neither are present.
67C> - 21: for grids with pl, number of points in grid.
68C> - 22: number of words in each row.
69C> - Latitude/longitude grids.
70C> - 2: n(i) nr points on latitude circle.
71C> - 3: n(j) nr points on longitude meridian.
72C> - 4: la(1) latitude of origin.
73C> - 5: lo(1) longitude of origin.
74C> - 6: resolution flag (right adj copy of octet 17).
75C> - 7: la(2) latitude of extreme point.
76C> - 8: lo(2) longitude of extreme point.
77C> - 9: di longitudinal direction of increment.
78C> - 10: dj latitudinal direction increment.
79C> - 11: scanning mode flag (right adj copy of octet 28).
80C> - Gaussian grids.
81C> - 2: n(i) nr points on latitude circle.
82C> - 3: n(j) nr points on longitude meridian.
83C> - 4: la(1) latitude of origin.
84C> - 5: lo(1) longitude of origin.
85C> - 6: resolution flag (right adj copy of octet 17).
86C> - 7: la(2) latitude of extreme point.
87C> - 8: lo(2) longitude of extreme point.
88C> - 9: di longitudinal direction of increment.
89C> - 10: n - nr of circles pole to equator.
90C> - 11: scanning mode flag (right adj copy of octet 28).
91C> - 12: nv - nr of vert coord parameters.
92C> - 13: pv - octet nr of list of vert coord parameters or.
93C> - pl - location of the list of numbers of points in each row
94C> (if no vert coord parameters are present) or
95C> - 255 if neither are present.
96C> - Polar stereographic grids.
97C> - 2: n(i) nr points along lat circle.
98C> - 3: n(j) nr points along lon circle.
99C> - 4: la(1) latitude of origin.
100C> - 5: lo(1) longitude of origin.
101C> - 6: resolution flag (right adj copy of octet 17).
102C> - 7: lov grid orientation.
103C> - 8: dx - x direction increment.
104C> - 9: dy - y direction increment.
105C> - 10: projection center flag.
106C> - 11: scanning mode (right adj copy of octet 28).
107C> - Spherical harmonic coefficients.
108C> - 2: j pentagonal resolution parameter.
109C> - 3: k pentagonal resolution parameter.
110C> - 4: m pentagonal resolution parameter.
111C> - 5: representation type.
112C> - 6: coefficient storage mode.
113C> - Mercator grids.
114C> - 2: n(i) nr points on latitude circle.
115C> - 3: n(j) nr points on longitude meridian.
116C> - 4: la(1) latitude of origin.
117C> - 5: lo(1) longitude of origin.
118C> - 6: resolution flag (right adj copy of octet 17).
119C> - 7: la(2) latitude of last grid point.
120C> - 8: lo(2) longitude of last grid point.
121C> - 9: latit - latitude of projection intersection.
122C> - 10: reserved.
123C> - 11: scanning mode flag (right adj copy of octet 28).
124C> - 12: longitudinal dir grid length.
125C> - 13: latitudinal dir grid length.
126C> - Lambert conformal grids.
127C> - 2: nx nr points along x-axis.
128C> - 3: ny nr points along y-axis.
129C> - 4: la1 lat of origin (lower left).
130C> - 5: lo1 lon of origin (lower left).
131C> - 6: resolution (right adj copy of octet 17).
132C> - 7: lov - orientation of grid.
133C> - 8: dx - x-dir increment.
134C> - 9: dy - y-dir increment.
135C> - 10: projection center flag.
136C> - 11: scanning mode flag (right adj copy of octet 28).
137C> - 12: latin 1 - first lat from pole of secant cone inter.
138C> - 13: latin 2 - second lat from pole of secant cone inter.
139C> @param[in] jens integer (200) ensemble pds parms for which to search
140C> (only searched if jpds(23)=2)
141C> (=-1 for wildcard).
142C> - 1: application identifier.
143C> - 2: ensemble type.
144C> - 3: ensemble identifier.
145C> - 4: product identifier.
146C> - 5: smoothing flag.
147C> @param[in] mbuf integer length of index buffer in bytes.
148C> @param[inout] cbuf character*1 (mbuf) index buffer
149C> (initialize by setting j=-1).
150C> @param[inout] nlen integer length of each index record in bytes
151C> (initialize by setting j=-1).
152C> @param[inout] nnum integer number of index records
153C> (initialize by setting j=-1).
154C> @param[inout] mnum integer number of index records skipped
155C> (initialize by setting j=-1).
156C> @param[out] kg integer number of bytes in the grib message.
157C> @param[out] k integer message number unpacked
158C> (can be same as j in calling program
159C> in order to facilitate multiple searches).
160C> @param[out] kpds integer (200) unpacked pds parameters.
161C> @param[out] kgds integer (200) unpacked gds parameters.
162C> @param[out] kens integer (200) unpacked ensemble pds parms.
163C> @param[out] g character*1 (kg) grib message.
164C> @param[out] iret integer return code.
165C> - 0: all ok.
166C> - 96: error reading index file.
167C> - 97: error reading grib file.
168C> - 98: number of bytes greater than jg.
169C> - 99: request not found.
170C>
171C> @note Specify an index file if feasible to increase speed.
172C> Subprogram can be called from a multiprocessing environment.
173C> Do not engage the same logical unit from more than one processor.
174C>
175C> @author Mark Iredell @date 1994-04-01
176C-----------------------------------------------------------------------
177 SUBROUTINE getgbemp(LUGB,LUGI,JG,J,JPDS,JGDS,JENS,
178 & MBUF,CBUF,NLEN,NNUM,MNUM,
179 & KG,K,KPDS,KGDS,KENS,G,IRET)
180 INTEGER JPDS(200),JGDS(200),JENS(200)
181 INTEGER KPDS(200),KGDS(200),KENS(200)
182 CHARACTER CBUF(MBUF)
183 CHARACTER G(JG)
184 parameter(msk1=32000,msk2=4000)
185C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
186C SEARCH PREVIOUS INDEX BUFFER IF POSSIBLE
187 IF(j.GE.0) THEN
188 IF(mnum.GE.0) THEN
189 irgi=0
190 ELSE
191 mnum=-1-mnum
192 irgi=1
193 ENDIF
194 jr=j-mnum
195 IF(jr.GE.0.AND.(jr.LT.nnum.OR.irgi.EQ.0)) THEN
196 CALL getgb1s(cbuf,nlen,nnum,jr,jpds,jgds,jens,
197 & kr,kpds,kgds,kens,lskip,lgrib,irgs)
198 IF(irgs.EQ.0) k=kr+mnum
199 IF(irgi.EQ.1.AND.irgs.EQ.0) mnum=-1-mnum
200 IF(irgi.EQ.1.AND.irgs.GT.0) mnum=mnum+nnum
201 ELSE
202 mnum=j
203 irgi=1
204 irgs=1
205 ENDIF
206 ELSE
207 mnum=-1-j
208 irgi=1
209 irgs=1
210 ENDIF
211C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
212C READ AND SEARCH NEXT INDEX BUFFER
213 jr=0
214 dowhile(irgi.EQ.1.AND.irgs.EQ.1)
215 IF(lugi.GT.0) THEN
216 CALL getgi(lugi,mnum,mbuf,cbuf,nlen,nnum,irgi)
217 ELSE
218 CALL getgir(lugb,msk1,msk2,mnum,mbuf,cbuf,nlen,nnum,irgi)
219 ENDIF
220 IF(irgi.LE.1) THEN
221 CALL getgb1s(cbuf,nlen,nnum,jr,jpds,jgds,jens,
222 & kr,kpds,kgds,kens,lskip,lgrib,irgs)
223 IF(irgs.EQ.0) k=kr+mnum
224 IF(irgi.EQ.1.AND.irgs.EQ.0) mnum=-1-mnum
225 IF(irgi.EQ.1.AND.irgs.GT.0) mnum=mnum+nnum
226 ENDIF
227 ENDDO
228C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
229C READ GRIB RECORD
230 IF(irgi.GT.1) THEN
231 iret=96
232 ELSEIF(irgs.NE.0) THEN
233 iret=99
234 ELSEIF(lgrib.GT.jg) THEN
235 iret=98
236 ELSE
237 iret=97
238 CALL baread(lugb,lskip,lgrib,kg,g)
239 IF(kg.EQ.lgrib) iret=0
240 ENDIF
241C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
242 RETURN
243 END
subroutine getgb1s(cbuf, nlen, nnum, j, jpds, jgds, jens, k, kpds, kgds, kens, lskip, lgrib, iret)
Find a grib message.
Definition getgb1s.f:44
subroutine getgbemp(lugb, lugi, jg, j, jpds, jgds, jens, mbuf, cbuf, nlen, nnum, mnum, kg, k, kpds, kgds, kens, g, iret)
Read a grib index file (or optionally the grib file itself) to get the index buffer (i....
Definition getgbemp.f:180
subroutine getgi(lugi, mnum, mbuf, cbuf, nlen, nnum, iret)
Read a grib index file and return its contents.
Definition getgi.f:50
subroutine getgir(lugb, msk1, msk2, mnum, mbuf, cbuf, nlen, nnum, iret)
Read a grib file and return its index contents.
Definition getgir.f:45