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