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