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