NCEPLIBS-w3emc 2.12.0
Loading...
Searching...
No Matches
getgbp.f
Go to the documentation of this file.
1C> @file
2C> @brief Finds 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> (The index buffer is saved for use by future prospective calls.)
8C> Find in the index buffer a reference to the grib message requested.
9C> The grib message request specifies the number of messages to skip
10C> and the unpacked pds and gds parameters. (A requested parameter
11C> of -1 means to allow any value of this parameter to be found.)
12C> If the requested grib message is found, then it is read from the
13C> grib file. Its message number is returned along with the unpacked
14C> pds and gds parameters and the packed grib message. If the grib
15C> message is not found, then the return code will be nonzero.
16C>
17C> Program history log:
18C> - Mark Iredell 1994-04-01
19C> - Mark Iredell 1995-10-31 Modularized portions of code into subprograms
20C> and allowed for unspecified index file.
21C>
22C> @param[in] lugb integer unit of the unblocked grib data file.
23C> @param[in] lugi integer unit of the unblocked grib index file
24C> (=0 to get index buffer from the grib file).
25C> @param[in] jg integer maximum number of bytes in the grib message.
26C> @param[in] j integer number of messages to skip
27C> (=0 to search from beginning)
28C> (<0 to read index buffer and skip -1-j messages).
29C> @param[in] jpds integer (200) pds parameters for which to search.
30C> (=-1 for wildcard).
31C> - 1): id of center.
32C> - 2): generating process id number.
33C> - 3): grid definition.
34C> - 4): gds/bms flag (right adj copy of octet 8).
35C> - 5): indicator of parameter.
36C> - 6): type of level.
37C> - 7): height/pressure , etc of level.
38C> - 8): year including (century-1).
39C> - 9): month of year.
40C> - 10: day of month.
41C> - 11: hour of day.
42C> - 12: minute of hour.
43C> - 13: indicator of forecast time unit.
44C> - 14: time range 1.
45C> - 15: time range 2.
46C> - 16: time range flag.
47C> - 17: number included in average.
48C> - 18: version nr of grib specification.
49C> - 19: version nr of parameter table.
50C> - 20: nr missing from average/accumulation.
51C> - 21: century of reference time of data.
52C> - 22: units decimal scale factor.
53C> - 23: subcenter number.
54C> - 24: pds byte 29, for nmc ensemble products.
55C> - 128 if forecast field error.
56C> - 64 if bias corrected fcst field.
57C> - 32 if smoothed field.
58C> - warning: can be combination of more than 1.
59C> - 25: pds byte 30, not used.
60C> @param[in] jgds integer (200) gds parameters for which to search
61C> (only searched if jpds(3)=255)
62C> (=-1 for wildcard).
63C> - 1): data representation type.
64C> - 19: number of vertical coordinate parameters.
65C> - 20: octet number of the list of vertical coordinate parameters or
66C> octet number of the list of numbers of points in each row or
67C> 255 if neither are present.
68C> - 21: for grids with pl, number of points in grid.
69C> - 22: number of words in each row.
70C> - Latitude/longitude grids.
71C> - 2: n(i) nr points on latitude circle.
72C> - 3: n(j) nr points on longitude meridian.
73C> - 4: la(1) latitude of origin.
74C> - 5: lo(1) longitude of origin.
75C> - 6: resolution flag (right adj copy of octet 17).
76C> - 7: la(2) latitude of extreme point.
77C> - 8: lo(2) longitude of extreme point.
78C> - 9: di longitudinal direction of increment.
79C> - 10: dj latitudinal direction increment.
80C> - 11: scanning mode flag (right adj copy of octet 28).
81C> - Gaussian grids.
82C> - 2: n(i) nr points on latitude circle.
83C> - 3: n(j) nr points on longitude meridian.
84C> - 4: la(1) latitude of origin.
85C> - 5: lo(1) longitude of origin.
86C> - 6: resolution flag (right adj copy of octet 17).
87C> - 7: la(2) latitude of extreme point.
88C> - 8: lo(2) longitude of extreme point.
89C> - 9: di longitudinal direction of increment.
90C> - 10: n - nr of circles pole to equator.
91C> - 11: scanning mode flag (right adj copy of octet 28).
92C> - 12: nv - nr of vert coord parameters.
93C> - 13: pv - octet nr of list of vert coord parameters or
94C> pl - location of the list of numbers of points in each row
95C> (if no vert coord parameters are present) or
96C> 255 if neither are present
97C> - Polar stereographic grids.
98C> - 2: n(i) nr points along lat circle.
99C> - 3: n(j) nr points along lon circle.
100C> - 4: la(1) latitude of origin.
101C> - 5: lo(1) longitude of origin.
102C> - 6: resolution flag (right adj copy of octet 17).
103C> - 7: lov grid orientation.
104C> - 8: dx - x direction increment.
105C> - 9: dy - y direction increment.
106C> - 10: projection center flag.
107C> - 11: scanning mode (right adj copy of octet 28).
108C> - Spherical harmonic coefficients.
109C> - 2: j pentagonal resolution parameter.
110C> - 3: k pentagonal resolution parameter.
111C> - 4: m pentagonal resolution parameter.
112C> - 5: representation type.
113C> - 6: coefficient storage mode.
114C> - Mercator grids.
115C> - 2: n(i) nr points on latitude circle.
116C> - 3: n(j) nr points on longitude meridian.
117C> - 4: la(1) latitude of origin.
118C> - 5: lo(1) longitude of origin.
119C> - 6: resolution flag (right adj copy of octet 17).
120C> - 7: la(2) latitude of last grid point.
121C> - 8: lo(2) longitude of last grid point.
122C> - 9: latit - latitude of projection intersection.
123C> - 10: reserved.
124C> - 11: scanning mode flag (right adj copy of octet 28).
125C> - 12: longitudinal dir grid length.
126C> - 13: latitudinal dir grid length.
127C> - Lambert conformal grids.
128C> - 2): nx nr points along x-axis.
129C> - 3): ny nr points along y-axis.
130C> - 4): la1 lat of origin (lower left).
131C> - 5): lo1 lon of origin (lower left).
132C> - 6): resolution (right adj copy of octet 17).
133C> - 7): lov - orientation of grid.
134C> - 8): dx - x-dir increment.
135C> - 9): dy - y-dir increment.
136C> - 10: projection center flag.
137C> - 11: scanning mode flag (right adj copy of octet 28).
138C> - 12: latin 1 - first lat from pole of secant cone inter.
139C> - 13: latin 2 - second lat from pole of secant cone inter.
140C> @param[out] kg integer number of bytes in the grib message.
141C> @param[out] k integer message number unpacked
142C> (can be same as j in calling program in order to facilitate multiple searches).
143C> @param[out] kpds integer (200) unpacked pds parameters.
144C> @param[out] kgds integer (200) unpacked gds parameters.
145C> @param[out] g character*1 (kg) grib message.
146C> @param[out] iret integer return code.
147C> - 0: all ok.
148C> - 96: error reading index file.
149C> - 97: error reading grib file.
150C> - 98: number of bytes greater than jg.
151C> - 99: request not found.
152C>
153C> @note In order to unpack grib from a multiprocessing environment
154C> where each processor is attempting to read from its own pair of
155C> logical units, one must directly call subprogram getgbmp as below,
156C> allocating a private copy of cbuf, nlen and nnum to each processor.
157C> Do not engage the same logical unit from more than one processor.
158C>
159C> @author Mark Iredell @date 1994-04-01
160C-----------------------------------------------------------------------
161 SUBROUTINE getgbp(LUGB,LUGI,JG,J,JPDS,JGDS,
162 & KG,K,KPDS,KGDS,G,IRET)
163 INTEGER JPDS(200),JGDS(200),KPDS(200),KGDS(200)
164 CHARACTER G(JG)
165 parameter(mbuf=256*1024)
166 CHARACTER CBUF(MBUF)
167 SAVE cbuf,nlen,nnum,mnum
168 DATA lux/0/
169C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
170C DETERMINE WHETHER INDEX BUFFER NEEDS TO BE INITIALIZED
171 IF(lugi.GT.0.AND.(j.LT.0.OR.lugi.NE.lux)) THEN
172 lux=lugi
173 jj=min(j,-1-j)
174 ELSEIF(lugi.LE.0.AND.(j.LT.0.OR.lugb.NE.lux)) THEN
175 lux=lugb
176 jj=min(j,-1-j)
177 ELSE
178 jj=j
179 ENDIF
180C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
181C FIND AND UNPACK GRIB MESSAGE
182 CALL getgbmp(lugb,lugi,jg,jj,jpds,jgds,
183 & mbuf,cbuf,nlen,nnum,mnum,
184 & kg,k,kpds,kgds,g,iret)
185 IF(iret.EQ.96) lux=0
186C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
187 RETURN
188 END
subroutine getgbmp(lugb, lugi, jg, j, jpds, jgds, mbuf, cbuf, nlen, nnum, mnum, kg, k, kpds, kgds, g, iret)
Read a grib index file (or optionally the grib file itself) to get the index buffer (i....
Definition getgbmp.f:170
subroutine getgbp(lugb, lugi, jg, j, jpds, jgds, kg, k, kpds, kgds, g, iret)
Read a grib index file (or optionally the grib file itself) to get the index buffer (i....
Definition getgbp.f:163