NCEPLIBS-w3emc  2.11.0
putgbn.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Packs and writes a grib message.
3 C> @author Mark Iredell @date 1994-04-01
4 
5 C> This subprogram is nearly the inverse of getgb.
6 C>
7 C> Program history log:
8 C> - Mark Iredell 1994-04-01
9 C> - Mark Iredell 1995-10-31 Removed saves and prints.
10 C>
11 C> @param[in] lugb integer unit of the unblocked grib data file.
12 C> @param[in] kf integer number of data points.
13 C> @param[in] kpds integer (200) pds parameters.
14 C> - 1): id of center.
15 C> - 2): generating process id number.
16 C> - 3): grid definition.
17 C> - 4): gds/bms flag (right adj copy of octet 8).
18 C> - 5): indicator of parameter.
19 C> - 6): type of level.
20 C> - 7): height/pressure , etc of level.
21 C> - 8): year including (century-1).
22 C> - 9): month of year.
23 C> - 10: day of month.
24 C> - 11: hour of day.
25 C> - 12: minute of hour.
26 C> - 13: indicator of forecast time unit.
27 C> - 14: time range 1.
28 C> - 15: time range 2.
29 C> - 16: time range flag.
30 C> - 17: number included in average.
31 C> - 18: version nr of grib specification.
32 C> - 19: version nr of parameter table.
33 C> - 20: nr missing from average/accumulation.
34 C> - 21: century of reference time of data.
35 C> - 22: units decimal scale factor.
36 C> - 23: subcenter number.
37 C> - 24: pds byte 29, for nmc ensemble products.
38 C> - 128 if forecast field error.
39 C> - 64 if bias corrected fcst field.
40 C> - 32 if smoothed field.
41 C> - warning: can be combination of more than 1.
42 C> - 25: pds byte 30, not used.
43 C> @param[in] kgds integer (200) gds parameters.
44 C> - 1): data representation type.
45 C> - 19: number of vertical coordinate parameters.
46 C> - 20: octet number of the list of vertical coordinate parameters or
47 C> octet number of the list of numbers of points in each row or
48 C> 255 if neither are present.
49 C> - 21: for grids with pl, number of points in grid.
50 C> - 22: number of words in each row.
51 C> - Latitude/longitude grids.
52 C> - 2): n(i) nr points on latitude circle.
53 C> - 3): n(j) nr points on longitude meridian.
54 C> - 4): la(1) latitude of origin.
55 C> - 5): lo(1) longitude of origin.
56 C> - 6): resolution flag (right adj copy of octet 17).
57 C> - 7): la(2) latitude of extreme point.
58 C> - 8): lo(2) longitude of extreme point.
59 C> - 9): di longitudinal direction of increment.
60 C> - 10: dj latitudinal direction increment.
61 C> - 11: scanning mode flag (right adj copy of octet 28).
62 C> - Gaussian grids.
63 C> - 2): n(i) nr points on latitude circle.
64 C> - 3): n(j) nr points on longitude meridian.
65 C> - 4): la(1) latitude of origin.
66 C> - 5): lo(1) longitude of origin.
67 C> - 6): resolution flag (right adj copy of octet 17).
68 C> - 7): la(2) latitude of extreme point.
69 C> - 8): lo(2) longitude of extreme point.
70 C> - 9): di longitudinal direction of increment.
71 C> - 10: n - nr of circles pole to equator.
72 C> - 11: scanning mode flag (right adj copy of octet 28).
73 C> - 12: nv - nr of vert coord parameters.
74 C> - 13: pv - octet nr of list of vert coord parameters or
75 C> pl - location of the list of numbers of points in
76 C> each row (if no vert coord parameters are present) or
77 C> 255 if neither are present.
78 C> - Polar stereographic grids.
79 C> - 2): n(i) nr points along lat circle.
80 C> - 3): n(j) nr points along lon circle.
81 C> - 4): la(1) latitude of origin.
82 C> - 5): lo(1) longitude of origin.
83 C> - 6): resolution flag (right adj copy of octet 17).
84 C> - 7): lov grid orientation.
85 C> - 8): dx - x direction increment.
86 C> - 9): dy - y direction increment.
87 C> - 10: projection center flag.
88 C> - 11: scanning mode (right adj copy of octet 28).
89 C> - Spherical harmonic coefficients.
90 C> - 2): j pentagonal resolution parameter.
91 C> - 3): k pentagonal resolution parameter.
92 C> - 4): m pentagonal resolution parameter.
93 C> - 5): representation type.
94 C> - 6): coefficient storage mode.
95 C> - Mercator grids.
96 C> - 2): n(i) nr points on latitude circle.
97 C> - 3): n(j) nr points on longitude meridian.
98 C> - 4): la(1) latitude of origin.
99 C> - 5): lo(1) longitude of origin.
100 C> - 6): resolution flag (right adj copy of octet 17).
101 C> - 7): la(2) latitude of last grid point.
102 C> - 8): lo(2) longitude of last grid point.
103 C> - 9): latit - latitude of projection intersection.
104 C> - 10: reserved.
105 C> - 11: scanning mode flag (right adj copy of octet 28).
106 C> - 12: longitudinal dir grid length.
107 C> - 13: latitudinal dir grid length.
108 C> - Lambert conformal grids.
109 C> - 2): nx nr points along x-axis.
110 C> - 3): ny nr points along y-axis.
111 C> - 4): la1 lat of origin (lower left).
112 C> - 5): lo1 lon of origin (lower left).
113 C> - 6): resolution (right adj copy of octet 17).
114 C> - 7): lov - orientation of grid.
115 C> - 8): dx - x-dir increment.
116 C> - 9): dy - y-dir increment.
117 C> - 10: projection center flag.
118 C> - 11: scanning mode flag (right adj copy of octet 28).
119 C> - 12: latin 1 - first lat from pole of secant cone inter.
120 C> - 13: latin 2 - second lat from pole of secant cone inter.
121 C> @param[in] ibs integer binary scale factor (0 to ignore).
122 C> @param[in] nbits integer number of bits in which to pack (0 to ignore).
123 C> @param[in] lb logical*1 (kf) bitmap if present.
124 C> @param[in] f real (kf) data.
125 C> @param[out] iret integer return code.
126 C> - 0 all ok.
127 C> - other w3fi72 grib packer return code.
128 C>
129 C> @note Subprogram can be called from a multiprocessing environment.
130 C> Do not engage the same logical unit from more than one processor.
131 C>
132 C> @author Mark Iredell @date 1994-04-01
133 C-----------------------------------------------------------------------
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)
142 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
143 C GET W3FI72 PARAMETERS
144  CALL r63w72(kpds,kgds,ipds,igds)
145  ibds=0
146 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
147 C 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
161 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
162 C 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
179 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
180 C 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)
185 C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
186  RETURN
187  END
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