1 | /* version 1.4.3 of grib headers w. ebisuzaki */ |
---|
2 | /* this version is incomplete */ |
---|
3 | /* 5/00 - dx/dy or di/dj controlled by bit 1 of resolution byte */ |
---|
4 | /* 8/00 - dx/dy or di/dj for polar and lambert not controlled by res. byte */ |
---|
5 | /* Added headers for the triangular grid of the gme model of DWD |
---|
6 | Helmut P. Frank, 13.09.2001 */ |
---|
7 | /* Clean up of triangular grid properties access and added spectral information |
---|
8 | Luis Kornblueh, 27.03.2002 */ |
---|
9 | |
---|
10 | #ifndef INT3 |
---|
11 | #define INT3(a,b,c) ((1-(int) ((unsigned) (a & 0x80) >> 6)) * (int) (((a & 127) << 16)+(b<<8)+c)) |
---|
12 | #endif |
---|
13 | #ifndef INT2 |
---|
14 | #define INT2(a,b) ((1-(int) ((unsigned) (a & 0x80) >> 6)) * (int) (((a & 127) << 8) + b)) |
---|
15 | #endif |
---|
16 | |
---|
17 | #ifndef UINT4 |
---|
18 | #define UINT4(a,b,c,d) ((int) ((a << 24) + (b << 16) + (c << 8) + (d))) |
---|
19 | #endif |
---|
20 | |
---|
21 | #ifndef UINT3 |
---|
22 | #define UINT3(a,b,c) ((int) ((a << 16) + (b << 8) + (c))) |
---|
23 | #endif |
---|
24 | |
---|
25 | #ifndef UINT2 |
---|
26 | #define UINT2(a,b) ((int) ((a << 8) + (b))) |
---|
27 | #endif |
---|
28 | |
---|
29 | |
---|
30 | #define GDS_Len1(gds) (gds[0]) |
---|
31 | #define GDS_Len2(gds) (gds[1]) |
---|
32 | #define GDS_Len3(gds) (gds[2]) |
---|
33 | #define GDS_LEN(gds) ((int) ((gds[0]<<16)+(gds[1]<<8)+gds[2])) |
---|
34 | |
---|
35 | #define GDS_NV(gds) (gds[3]) |
---|
36 | #define GDS_DataType(gds) (gds[5]) |
---|
37 | |
---|
38 | #define GDS_LatLon(gds) (gds[5] == 0) |
---|
39 | #define GDS_Mercator(gds) (gds[5] == 1) |
---|
40 | #define GDS_Gnomonic(gds) (gds[5] == 2) |
---|
41 | #define GDS_Lambert(gds) (gds[5] == 3) |
---|
42 | #define GDS_Gaussian(gds) (gds[5] == 4) |
---|
43 | #define GDS_Polar(gds) (gds[5] == 5) |
---|
44 | #define GDS_RotLL(gds) (gds[5] == 10) |
---|
45 | #define GDS_Harmonic(gds) (gds[5] == 50) |
---|
46 | #define GDS_Triangular(gds) (gds[5] == 192) |
---|
47 | #define GDS_ssEgrid(gds) (gds[5] == 201) /* semi-staggered E grid */ |
---|
48 | #define GDS_fEgrid(gds) (gds[5] == 202) /* filled E grid */ |
---|
49 | #define GDS_ss2dEgrid(gds) (gds[5] == 203) /* semi-staggered E grid 2 d*/ |
---|
50 | |
---|
51 | #define GDS_has_dy(mode) ((mode) & 128) |
---|
52 | #define GDS_LatLon_nx(gds) ((int) ((gds[6] << 8) + gds[7])) |
---|
53 | #define GDS_LatLon_ny(gds) ((int) ((gds[8] << 8) + gds[9])) |
---|
54 | #define GDS_LatLon_La1(gds) INT3(gds[10],gds[11],gds[12]) |
---|
55 | #define GDS_LatLon_Lo1(gds) INT3(gds[13],gds[14],gds[15]) |
---|
56 | #define GDS_LatLon_mode(gds) (gds[16]) |
---|
57 | #define GDS_LatLon_La2(gds) INT3(gds[17],gds[18],gds[19]) |
---|
58 | #define GDS_LatLon_Lo2(gds) INT3(gds[20],gds[21],gds[22]) |
---|
59 | |
---|
60 | #define GDS_LatLon_dx(gds) (gds[16] & 128 ? INT2(gds[23],gds[24]) : 0) |
---|
61 | #define GDS_LatLon_dy(gds) (gds[16] & 128 ? INT2(gds[25],gds[26]) : 0) |
---|
62 | #define GDS_Gaussian_nlat(gds) ((gds[25]<<8)+gds[26]) |
---|
63 | |
---|
64 | #define GDS_LatLon_scan(gds) (gds[27]) |
---|
65 | |
---|
66 | #define GDS_Polar_nx(gds) ((gds[6] << 8) + gds[7]) |
---|
67 | #define GDS_Polar_ny(gds) ((gds[8] << 8) + gds[9]) |
---|
68 | #define GDS_Polar_La1(gds) INT3(gds[10],gds[11],gds[12]) |
---|
69 | #define GDS_Polar_Lo1(gds) INT3(gds[13],gds[14],gds[15]) |
---|
70 | #define GDS_Polar_mode(gds) (gds[16]) |
---|
71 | #define GDS_Polar_Lov(gds) INT3(gds[17],gds[18],gds[19]) |
---|
72 | #define GDS_Polar_scan(gds) (gds[27]) |
---|
73 | #define GDS_Polar_Dx(gds) INT3(gds[20], gds[21], gds[22]) |
---|
74 | #define GDS_Polar_Dy(gds) INT3(gds[23], gds[24], gds[25]) |
---|
75 | #define GDS_Polar_pole(gds) ((gds[26] & 128) == 128) |
---|
76 | |
---|
77 | #define GDS_Lambert_nx(gds) ((gds[6] << 8) + gds[7]) |
---|
78 | #define GDS_Lambert_ny(gds) ((gds[8] << 8) + gds[9]) |
---|
79 | #define GDS_Lambert_La1(gds) INT3(gds[10],gds[11],gds[12]) |
---|
80 | #define GDS_Lambert_Lo1(gds) INT3(gds[13],gds[14],gds[15]) |
---|
81 | #define GDS_Lambert_mode(gds) (gds[16]) |
---|
82 | #define GDS_Lambert_Lov(gds) INT3(gds[17],gds[18],gds[19]) |
---|
83 | #define GDS_Lambert_dx(gds) INT3(gds[20],gds[21],gds[22]) |
---|
84 | #define GDS_Lambert_dy(gds) INT3(gds[23],gds[24],gds[25]) |
---|
85 | #define GDS_Lambert_NP(gds) ((gds[26] & 128) == 0) |
---|
86 | #define GDS_Lambert_scan(gds) (gds[27]) |
---|
87 | #define GDS_Lambert_Latin1(gds) INT3(gds[28],gds[29],gds[30]) |
---|
88 | #define GDS_Lambert_Latin2(gds) INT3(gds[31],gds[32],gds[33]) |
---|
89 | #define GDS_Lambert_LatSP(gds) INT3(gds[34],gds[35],gds[36]) |
---|
90 | #define GDS_Lambert_LonSP(gds) INT3(gds[37],gds[37],gds[37]) |
---|
91 | |
---|
92 | #define GDS_ssEgrid_n(gds) UINT2(gds[6],gds[7]) |
---|
93 | #define GDS_ssEgrid_n_dum(gds) UINT2(gds[8],gds[9]) |
---|
94 | #define GDS_ssEgrid_La1(gds) INT3(gds[10],gds[11],gds[12]) |
---|
95 | #define GDS_ssEgrid_Lo1(gds) INT3(gds[13],gds[14],gds[15]) |
---|
96 | #define GDS_ssEgrid_mode(gds) (gds[16]) |
---|
97 | #define GDS_ssEgrid_La2(gds) UINT3(gds[17],gds[18],gds[19]) |
---|
98 | #define GDS_ssEgrid_Lo2(gds) UINT3(gds[20],gds[21],gds[22]) |
---|
99 | #define GDS_ssEgrid_di(gds) (gds[16] & 128 ? INT2(gds[23],gds[24]) : 0) |
---|
100 | #define GDS_ssEgrid_dj(gds) (gds[16] & 128 ? INT2(gds[25],gds[26]) : 0) |
---|
101 | #define GDS_ssEgrid_scan(gds) (gds[27]) |
---|
102 | |
---|
103 | #define GDS_fEgrid_n(gds) UINT2(gds[6],gds[7]) |
---|
104 | #define GDS_fEgrid_n_dum(gds) UINT2(gds[8],gds[9]) |
---|
105 | #define GDS_fEgrid_La1(gds) INT3(gds[10],gds[11],gds[12]) |
---|
106 | #define GDS_fEgrid_Lo1(gds) INT3(gds[13],gds[14],gds[15]) |
---|
107 | #define GDS_fEgrid_mode(gds) (gds[16]) |
---|
108 | #define GDS_fEgrid_La2(gds) UINT3(gds[17],gds[18],gds[19]) |
---|
109 | #define GDS_fEgrid_Lo2(gds) UINT3(gds[20],gds[21],gds[22]) |
---|
110 | #define GDS_fEgrid_di(gds) (gds[16] & 128 ? INT2(gds[23],gds[24]) : 0) |
---|
111 | #define GDS_fEgrid_dj(gds) (gds[16] & 128 ? INT2(gds[25],gds[26]) : 0) |
---|
112 | #define GDS_fEgrid_scan(gds) (gds[27]) |
---|
113 | |
---|
114 | #define GDS_ss2dEgrid_nx(gds) UINT2(gds[6],gds[7]) |
---|
115 | #define GDS_ss2dEgrid_ny(gds) UINT2(gds[8],gds[9]) |
---|
116 | #define GDS_ss2dEgrid_La1(gds) INT3(gds[10],gds[11],gds[12]) |
---|
117 | #define GDS_ss2dEgrid_Lo1(gds) INT3(gds[13],gds[14],gds[15]) |
---|
118 | #define GDS_ss2dEgrid_mode(gds) (gds[16]) |
---|
119 | #define GDS_ss2dEgrid_La2(gds) INT3(gds[17],gds[18],gds[19]) |
---|
120 | #define GDS_ss2dEgrid_Lo2(gds) INT3(gds[20],gds[21],gds[22]) |
---|
121 | #define GDS_ss2dEgrid_di(gds) (gds[16] & 128 ? INT2(gds[23],gds[24]) : 0) |
---|
122 | #define GDS_ss2dEgrid_dj(gds) (gds[16] & 128 ? INT2(gds[25],gds[26]) : 0) |
---|
123 | #define GDS_ss2dEgrid_scan(gds) (gds[27]) |
---|
124 | |
---|
125 | |
---|
126 | #define GDS_Merc_nx(gds) UINT2(gds[6],gds[7]) |
---|
127 | #define GDS_Merc_ny(gds) UINT2(gds[8],gds[9]) |
---|
128 | #define GDS_Merc_La1(gds) INT3(gds[10],gds[11],gds[12]) |
---|
129 | #define GDS_Merc_Lo1(gds) INT3(gds[13],gds[14],gds[15]) |
---|
130 | #define GDS_Merc_mode(gds) (gds[16]) |
---|
131 | #define GDS_Merc_La2(gds) INT3(gds[17],gds[18],gds[19]) |
---|
132 | #define GDS_Merc_Lo2(gds) INT3(gds[20],gds[21],gds[22]) |
---|
133 | #define GDS_Merc_Latin(gds) INT3(gds[23],gds[24],gds[25]) |
---|
134 | #define GDS_Merc_scan(gds) (gds[27]) |
---|
135 | #define GDS_Merc_dx(gds) (gds[16] & 128 ? INT3(gds[28],gds[29],gds[30]) : 0) |
---|
136 | #define GDS_Merc_dy(gds) (gds[16] & 128 ? INT3(gds[31],gds[32],gds[33]) : 0) |
---|
137 | |
---|
138 | /* rotated Lat-lon grid */ |
---|
139 | |
---|
140 | #define GDS_RotLL_nx(gds) UINT2(gds[6],gds[7]) |
---|
141 | #define GDS_RotLL_ny(gds) UINT2(gds[8],gds[9]) |
---|
142 | #define GDS_RotLL_La1(gds) INT3(gds[10],gds[11],gds[12]) |
---|
143 | #define GDS_RotLL_Lo1(gds) INT3(gds[13],gds[14],gds[15]) |
---|
144 | #define GDS_RotLL_mode(gds) (gds[16]) |
---|
145 | #define GDS_RotLL_La2(gds) INT3(gds[17],gds[18],gds[19]) |
---|
146 | #define GDS_RotLL_Lo2(gds) INT3(gds[20],gds[21],gds[22]) |
---|
147 | #define GDS_RotLL_dx(gds) (gds[16] & 128 ? INT2(gds[23],gds[24]) : 0) |
---|
148 | #define GDS_RotLL_dy(gds) (gds[16] & 128 ? INT2(gds[25],gds[26]) : 0) |
---|
149 | #define GDS_RotLL_scan(gds) (gds[27]) |
---|
150 | #define GDS_RotLL_LaSP(gds) INT3(gds[32],gds[33],gds[34]) |
---|
151 | #define GDS_RotLL_LoSP(gds) INT3(gds[35],gds[36],gds[37]) |
---|
152 | #define GDS_RotLL_RotAng(gds) ibm2flt(&(gds[38])) |
---|
153 | |
---|
154 | /* Triangular grid of DWD */ |
---|
155 | #define GDS_Triangular_ni2(gds) INT2(gds[6],gds[7]) |
---|
156 | #define GDS_Triangular_ni3(gds) INT2(gds[8],gds[9]) |
---|
157 | #define GDS_Triangular_ni(gds) INT3(gds[13],gds[14],gds[15]) |
---|
158 | #define GDS_Triangular_nd(gds) INT3(gds[10],gds[11],gds[12]) |
---|
159 | |
---|
160 | /* Harmonics data */ |
---|
161 | #define GDS_Harmonic_nj(gds) ((int) ((gds[6] << 8) + gds[7])) |
---|
162 | #define GDS_Harmonic_nk(gds) ((int) ((gds[8] << 8) + gds[9])) |
---|
163 | #define GDS_Harmonic_nm(gds) ((int) ((gds[10] << 8) + gds[11])) |
---|
164 | #define GDS_Harmonic_type(gds) (gds[12]) |
---|
165 | #define GDS_Harmonic_mode(gds) (gds[13]) |
---|
166 | |
---|
167 | /* index of NV and PV */ |
---|
168 | #define GDS_PV(gds) ((gds[3] == 0) ? -1 : (int) gds[4] - 1) |
---|
169 | #define GDS_PL(gds) ((gds[4] == 255) ? -1 : (int) gds[3] * 4 + (int) gds[4] - 1) |
---|
170 | |
---|