NCEPLIBS-w3emc 2.12.0
Loading...
Searching...
No Matches
putgbex.f
Go to the documentation of this file.
1C> @file
2C> @brief Packs and writes a grib message.
3C> @author Mark Iredell @date 1994-04-01
4
5C> This subprogram is nearly the inverse of getgbe.
6C>
7C> Program history log:
8C> - Mark Iredell 1994-04-01
9C> - Mark Iredell 1995-10-31 Removed saves and prints.
10C> - Y. Zhu 1997-02-11 Included probability and cluster arguments.
11C>
12C> @param[in] lugb integer unit of the unblocked grib data file.
13C> @param[in] kf integer number of data points.
14C> @param[in] kpds integer (200) pds parameters.
15C> - 1): id of center.
16C> - 2): generating process id number.
17C> - 3): grid definition.
18C> - 4): gds/bms flag (right adj copy of octet 8).
19C> - 5): indicator of parameter.
20C> - 6): type of level.
21C> - 7): height/pressure , etc of level.
22C> - 8): year including (century-1).
23C> - 9): month of year.
24C> - 10: day of month.
25C> - 11: hour of day.
26C> - 12: minute of hour.
27C> - 13: indicator of forecast time unit.
28C> - 14: time range 1.
29C> - 15: time range 2.
30C> - 16: time range flag.
31C> - 17: number included in average.
32C> - 18: version nr of grib specification.
33C> - 19: version nr of parameter table.
34C> - 20: nr missing from average/accumulation.
35C> - 21: century of reference time of data.
36C> - 22: units decimal scale factor.
37C> - 23: subcenter number.
38C> - 24: pds byte 29, for nmc ensemble products.
39C> - 128 if forecast field error.
40C> - 64 if bias corrected fcst field.
41C> - 32 if smoothed field.
42C> - warning: can be combination of more than 1.
43C> - 25: pds byte 30, not used.
44C> @param[in] kgds Integer (200) gds parameters.
45C> - 1): data representation type.
46C> - 19: number of vertical coordinate parameters.
47C> - 20: octet number of the list of vertical coordinate parameters or
48C> octet number of the list of numbers of points in each row or
49C> 255 if neither are present.
50C> - 21: for grids with pl, number of points in grid.
51C> - 22: number of words in each row.
52C> - Latitude/longitude grids.
53C> - 2): n(i) nr points on latitude circle.
54C> - 3): n(j) nr points on longitude meridian.
55C> - 4): la(1) latitude of origin.
56C> - 5): lo(1) longitude of origin.
57C> - 6): resolution flag (right adj copy of octet 17).
58C> - 7): la(2) latitude of extreme point.
59C> - 8): lo(2) longitude of extreme point.
60C> - 9): di longitudinal direction of increment.
61C> - 10: dj latitudinal direction increment.
62C> - 11: scanning mode flag (right adj copy of octet 28).
63C> - Gaussian grids.
64C> - 2): n(i) nr points on latitude circle.
65C> - 3): n(j) nr points on longitude meridian.
66C> - 4): la(1) latitude of origin.
67C> - 5): lo(1) longitude of origin.
68C> - 6): resolution flag (right adj copy of octet 17).
69C> - 7): la(2) latitude of extreme point.
70C> - 8): lo(2) longitude of extreme point.
71C> - 9): di longitudinal direction of increment.
72C> - 10: n - nr of circles pole to equator.
73C> - 11: scanning mode flag (right adj copy of octet 28).
74C> - 12: nv - nr of vert coord parameters.
75C> - 13: pv - octet nr of list of vert coord parameters or
76C> pl - location of the list of numbers of points in
77C> each row (if no vert coord parameters are present or
78C> 255 if neither are present
79C> - Polar stereographic grids.
80C> - 2): n(i) nr points along lat circle.
81C> - 3): n(j) nr points along lon circle.
82C> - 4): la(1) latitude of origin.
83C> - 5): lo(1) longitude of origin.
84C> - 6): resolution flag (right adj copy of octet 17).
85C> - 7): lov grid orientation.
86C> - 8): dx - x direction increment.
87C> - 9): dy - y direction increment.
88C> - 10: projection center flag.
89C> - 11: scanning mode (right adj copy of octet 28).
90C> - Spherical harmonic coefficients.
91C> - 2): j pentagonal resolution parameter.
92C> - 3): k pentagonal resolution parameter.
93C> - 4): m pentagonal resolution parameter.
94C> - 5): representation type.
95C> - 6): coefficient storage mode.
96C> - Mercator grids.
97C> - 2): n(i) nr points on latitude circle.
98C> - 3): n(j) nr points on longitude meridian.
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): la(2) latitude of last grid point.
103C> - 8): lo(2) longitude of last grid point.
104C> - 9): latit - latitude of projection intersection.
105C> - 10: reserved.
106C> - 11: scanning mode flag (right adj copy of octet 28).
107C> - 12: longitudinal dir grid length.
108C> - 13: latitudinal dir grid length.
109C> - Lambert conformal grids.
110C> - 2): nx nr points along x-axis.
111C> - 3): ny nr points along y-axis.
112C> - 4): la1 lat of origin (lower left).
113C> - 5): lo1 lon of origin (lower left).
114C> - 6): resolution (right adj copy of octet 17).
115C> - 7): lov - orientation of grid.
116C> - 8): dx - x-dir increment.
117C> - 9): dy - y-dir increment.
118C> - 10: projection center flag.
119C> - 11: scanning mode flag (right adj copy of octet 28).
120C> - 12: latin 1 - first lat from pole of secant cone inter.
121C> - 13: latin 2 - second lat from pole of secant cone inter.
122C> @param[in] kens integer (200) ensemble pds parms.
123C> - 1): application identifier.
124C> - 2): ensemble type.
125C> - 3): ensemble identifier.
126C> - 4): product identifier.
127C> - 5): smoothing flag.
128C> @param[in] kprob integer (2) probability ensemble parms.
129C> @param[in] xprob real (2) probability ensemble parms.
130C> @param[in] kclust integer (16) cluster ensemble parms.
131C> @param[in] kmembr integer (8) cluster ensemble parms.
132C> @param[in] lb logical*1 (kf) bitmap if present.
133C> @param[in] f real (kf) data.
134C> @param[out] iret integer return code.
135C> - 0 all ok.
136C> - other w3fi72 grib packer return code.
137C>
138C> @note Subprogram can be called from a multiprocessing environment.
139C> Do not engage the same logical unit from more than one processor.
140C>
141C> @author Mark Iredell @date 1994-04-01
142C-----------------------------------------------------------------------
143 SUBROUTINE putgbex(LUGB,KF,KPDS,KGDS,KENS,
144 & KPROB,XPROB,KCLUST,KMEMBR,LB,F,IRET)
145 INTEGER KPDS(200),KGDS(200),KENS(200)
146 INTEGER KPROB(2),KCLUST(16),KMEMBR(80)
147 REAL XPROB(2)
148 LOGICAL*1 LB(KF)
149 REAL F(KF)
150 parameter(maxbit=16)
151 INTEGER IBM(KF),IPDS(200),IGDS(200),IBDS(200)
152 REAL FR(KF)
153 CHARACTER PDS(400),GRIB(1000+KF*(MAXBIT+1)/8)
154C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
155C GET W3FI72 PARAMETERS
156 CALL r63w72(kpds,kgds,ipds,igds)
157 ibds=0
158C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
159C COUNT VALID DATA
160 kbm=kf
161 IF(ipds(7).NE.0) THEN
162 kbm=0
163 DO i=1,kf
164 IF(lb(i)) THEN
165 ibm(i)=1
166 kbm=kbm+1
167 ELSE
168 ibm(i)=0
169 ENDIF
170 ENDDO
171 IF(kbm.EQ.kf) ipds(7)=0
172 ENDIF
173C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
174C GET NUMBER OF BITS AND ROUND DATA
175 IF(kbm.EQ.0) THEN
176 DO i=1,kf
177 fr(i)=0.
178 ENDDO
179 nbit=0
180 ELSE
181 CALL getbit(ipds(7),0,ipds(25),kf,ibm,f,fr,fmin,fmax,nbit)
182 nbit=min(nbit,maxbit)
183 ENDIF
184C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
185C CREATE PRODUCT DEFINITION SECTION
186 CALL w3fi68(ipds,pds)
187 IF(ipds(24).EQ.2) THEN
188 ilast=86
189 CALL pdsens(kens,kprob,xprob,kclust,kmembr,ilast,pds)
190 ENDIF
191C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
192C PACK AND WRITE GRIB DATA
193 CALL w3fi72(0,fr,0,nbit,1,ipds,pds,
194 & 1,255,igds,0,0,ibm,kf,ibds,
195 & kfo,grib,lgrib,iret)
196 IF(iret.EQ.0) CALL wryte(lugb,lgrib,grib)
197C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
198 RETURN
199 END
subroutine getbit(ibm, ibs, ids, len, mg, g, ground, gmin, gmax, nbit)
The number of bits required to pack a given field.
Definition getbit.f:33
subroutine pdsens(kens, kprob, xprob, kclust, kmembr, ilast, msga)
Packs brib pds extension starting on byte 41 for ensemble forecast products.
Definition pdsens.f:28
subroutine putgbex(lugb, kf, kpds, kgds, kens, kprob, xprob, kclust, kmembr, lb, f, iret)
This subprogram is nearly the inverse of getgbe.
Definition putgbex.f:145
subroutine r63w72(kpds, kgds, ipds, igds)
Determines the integer PDS and GDS parameters for the GRIB1 packing routine w3fi72() given the parame...
Definition r63w72.f:27
subroutine w3fi68(id, pds)
Converts an array of 25, or 27 integer words into a grib product definition section (pds) of 28 bytes...
Definition w3fi68.f:85
subroutine w3fi72(itype, fld, ifld, ibitl, ipflag, id, pds, igflag, igrid, igds, icomp, ibflag, ibmap, iblen, ibdsfl, npts, kbuf, itot, jerr)
Makes a complete GRIB message from a user supplied array of floating point or integer data.
Definition w3fi72.f:121