1 /* version 3.4 of grib headers w. ebisuzaki */
2 /* this version is incomplete */
3 /* add center DWD Helmut P. Frank */
4 /* 10/02 add center CPTEC */
7 #define INT2(a,b) ((1-(int) ((unsigned) (a & 0x80) >> 6)) * (int) (((a & 0x7f) << 8) + b))
10 #define PDS_Len1(pds) (pds[0])
11 #define PDS_Len2(pds) (pds[1])
12 #define PDS_Len3(pds) (pds[2])
13 #define PDS_LEN(pds) ((int) ((pds[0]<<16)+(pds[1]<<8)+pds[2]))
14 #define PDS_Vsn(pds) (pds[3])
15 #define PDS_Center(pds) (pds[4])
16 #define PDS_Model(pds) (pds[5])
17 #define PDS_Grid(pds) (pds[6])
18 #define PDS_HAS_GDS(pds) ((pds[7] & 128) != 0)
19 #define PDS_HAS_BMS(pds) ((pds[7] & 64) != 0)
20 #define PDS_PARAM(pds) (pds[8])
21 #define PDS_L_TYPE(pds) (pds[9])
22 #define PDS_LEVEL1(pds) (pds[10])
23 #define PDS_LEVEL2(pds) (pds[11])
25 #define PDS_KPDS5(pds) (pds[8])
26 #define PDS_KPDS6(pds) (pds[9])
27 #define PDS_KPDS7(pds) ((int) ((pds[10]<<8) + pds[11]))
29 /* this requires a 32-bit default integer machine */
30 #define PDS_Field(pds) ((pds[8]<<24)+(pds[9]<<16)+(pds[10]<<8)+pds[11])
32 #define PDS_Year(pds) (pds[12])
33 #define PDS_Month(pds) (pds[13])
34 #define PDS_Day(pds) (pds[14])
35 #define PDS_Hour(pds) (pds[15])
36 #define PDS_Minute(pds) (pds[16])
37 #define PDS_ForecastTimeUnit(pds) (pds[17])
38 #define PDS_P1(pds) (pds[18])
39 #define PDS_P2(pds) (pds[19])
40 #define PDS_TimeRange(pds) (pds[20])
41 #define PDS_NumAve(pds) ((int) ((pds[21]<<8)+pds[22]))
42 #define PDS_NumMissing(pds) (pds[23])
43 #define PDS_Century(pds) (pds[24])
44 #define PDS_Subcenter(pds) (pds[25])
45 #define PDS_DecimalScale(pds) INT2(pds[26],pds[27])
46 /* old #define PDS_Year4(pds) (pds[12] + 100*(pds[24] - (pds[12] != 0))) */
47 #define PDS_Year4(pds) (pds[12] + 100*(pds[24] - 1))
56 /* ECMWF Extensions */
58 #define PDS_EcLocalId(pds) (PDS_LEN(pds) >= 41 ? (pds[40]) : 0)
59 #define PDS_EcClass(pds) (PDS_LEN(pds) >= 42 ? (pds[41]) : 0)
60 #define PDS_EcType(pds) (PDS_LEN(pds) >= 43 ? (pds[42]) : 0)
61 #define PDS_EcStream(pds) (PDS_LEN(pds) >= 45 ? (INT2(pds[43], pds[44])) : 0)
63 #define PDS_EcENS(pds) (PDS_LEN(pds) >= 52 && pds[40] == 1 && \
64 pds[43] * 256 + pds[44] == 1035 && pds[50] != 0)
65 #define PDS_EcFcstNo(pds) (pds[50])
66 #define PDS_EcNoFcst(pds) (pds[51])
71 #define PDS_NcepENS(pds) (PDS_LEN(pds) >= 44 && pds[25] == 2 && pds[40] == 1)
72 #define PDS_NcepFcstType(pds) (pds[41])
73 #define PDS_NcepFcstNo(pds) (pds[42])
74 #define PDS_NcepFcstProd(pds) (pds[43])