Merge remote-tracking branch 'origin/release-v4.6.1'
[WRF.git] / external / io_grib1 / WGRIB / bds.h
blobb05212aa3e1ab2c3ed610b3f21019c838b766ac2
1 /*
2 * version 1.2.1 of grib headers w. ebisuzaki
3 * 1.2.2 added access to spectral reference value l. kornblueh
4 */
6 #ifndef INT2
7 #define INT2(a,b) ((1-(int) ((unsigned) (a & 0x80) >> 6)) * (int) (((a & 0x7f) << 8) + b))
8 #endif
10 #define BDS_LEN(bds) ((int) ((bds[0]<<16)+(bds[1]<<8)+bds[2]))
11 #define BDS_Flag(bds) (bds[3])
13 #define BDS_Grid(bds) ((bds[3] & 128) == 0)
14 #define BDS_Harmonic(bds) (bds[3] & 128)
16 #define BDS_Packing(bds) ((bds[3] & 64) != 0)
17 #define BDS_SimplePacking(bds) ((bds[3] & 64) == 0)
18 #define BDS_ComplexPacking(bds) ((bds[3] & 64) != 0)
20 #define BDS_OriginalType(bds) ((bds[3] & 32) != 0)
21 #define BDS_OriginalFloat(bds) ((bds[3] & 32) == 0)
22 #define BDS_OriginalInt(bds) ((bds[3] & 32) != 0)
24 #define BDS_MoreFlags(bds) ((bds[3] & 16) != 0)
25 #define BDS_UnusedBits(bds) ((int) (bds[3] & 15))
27 #define BDS_BinScale(bds) INT2(bds[4],bds[5])
29 #define BDS_RefValue(bds) (ibm2flt(bds+6))
30 #define BDS_NumBits(bds) ((int) bds[10])
32 #define BDS_Harmonic_RefValue(bds) (ibm2flt(bds+11))
34 #define BDS_DataStart(bds) ((int) (11 + BDS_MoreFlags(bds)*3))
36 /* breaks if BDS_NumBits(bds) == 0 */
37 #define BDS_NValues(bds) (((BDS_LEN(bds) - BDS_DataStart(bds))*8 - \
38 BDS_UnusedBits(bds)) / BDS_NumBits(bds))
41 #define BDS_NValues(bds) ((BDS_NumBits(bds) == 0) ? 0 : \
42 (((BDS_LEN(bds) - BDS_DataStart(bds))*8 - \
43 BDS_UnusedBits(bds)) / BDS_NumBits(bds)))
47 /* undefined value -- if bitmap */
48 #define UNDEFINED 9.999e20