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