PageRenderTime 50ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/wrfv2_fire/external/io_grib1/WGRIB/gds.h

http://github.com/jbeezley/wrf-fire
C++ Header | 170 lines | 134 code | 24 blank | 12 comment | 16 complexity | 3f8cec6396a93cf4a25550eea14a1e9f MD5 | raw file
Possible License(s): AGPL-1.0
  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. #ifndef INT3
  10. #define INT3(a,b,c) ((1-(int) ((unsigned) (a & 0x80) >> 6)) * (int) (((a & 127) << 16)+(b<<8)+c))
  11. #endif
  12. #ifndef INT2
  13. #define INT2(a,b) ((1-(int) ((unsigned) (a & 0x80) >> 6)) * (int) (((a & 127) << 8) + b))
  14. #endif
  15. #ifndef UINT4
  16. #define UINT4(a,b,c,d) ((int) ((a << 24) + (b << 16) + (c << 8) + (d)))
  17. #endif
  18. #ifndef UINT3
  19. #define UINT3(a,b,c) ((int) ((a << 16) + (b << 8) + (c)))
  20. #endif
  21. #ifndef UINT2
  22. #define UINT2(a,b) ((int) ((a << 8) + (b)))
  23. #endif
  24. #define GDS_Len1(gds) (gds[0])
  25. #define GDS_Len2(gds) (gds[1])
  26. #define GDS_Len3(gds) (gds[2])
  27. #define GDS_LEN(gds) ((int) ((gds[0]<<16)+(gds[1]<<8)+gds[2]))
  28. #define GDS_NV(gds) (gds[3])
  29. #define GDS_DataType(gds) (gds[5])
  30. #define GDS_LatLon(gds) (gds[5] == 0)
  31. #define GDS_Mercator(gds) (gds[5] == 1)
  32. #define GDS_Gnomonic(gds) (gds[5] == 2)
  33. #define GDS_Lambert(gds) (gds[5] == 3)
  34. #define GDS_Gaussian(gds) (gds[5] == 4)
  35. #define GDS_Polar(gds) (gds[5] == 5)
  36. #define GDS_RotLL(gds) (gds[5] == 10)
  37. #define GDS_Harmonic(gds) (gds[5] == 50)
  38. #define GDS_Triangular(gds) (gds[5] == 192)
  39. #define GDS_ssEgrid(gds) (gds[5] == 201) /* semi-staggered E grid */
  40. #define GDS_fEgrid(gds) (gds[5] == 202) /* filled E grid */
  41. #define GDS_ss2dEgrid(gds) (gds[5] == 203) /* semi-staggered E grid 2 d*/
  42. #define GDS_has_dy(mode) ((mode) & 128)
  43. #define GDS_LatLon_nx(gds) ((int) ((gds[6] << 8) + gds[7]))
  44. #define GDS_LatLon_ny(gds) ((int) ((gds[8] << 8) + gds[9]))
  45. #define GDS_LatLon_La1(gds) INT3(gds[10],gds[11],gds[12])
  46. #define GDS_LatLon_Lo1(gds) INT3(gds[13],gds[14],gds[15])
  47. #define GDS_LatLon_mode(gds) (gds[16])
  48. #define GDS_LatLon_La2(gds) INT3(gds[17],gds[18],gds[19])
  49. #define GDS_LatLon_Lo2(gds) INT3(gds[20],gds[21],gds[22])
  50. #define GDS_LatLon_dx(gds) (gds[16] & 128 ? INT2(gds[23],gds[24]) : 0)
  51. #define GDS_LatLon_dy(gds) (gds[16] & 128 ? INT2(gds[25],gds[26]) : 0)
  52. #define GDS_Gaussian_nlat(gds) ((gds[25]<<8)+gds[26])
  53. #define GDS_LatLon_scan(gds) (gds[27])
  54. #define GDS_Polar_nx(gds) ((gds[6] << 8) + gds[7])
  55. #define GDS_Polar_ny(gds) ((gds[8] << 8) + gds[9])
  56. #define GDS_Polar_La1(gds) INT3(gds[10],gds[11],gds[12])
  57. #define GDS_Polar_Lo1(gds) INT3(gds[13],gds[14],gds[15])
  58. #define GDS_Polar_mode(gds) (gds[16])
  59. #define GDS_Polar_Lov(gds) INT3(gds[17],gds[18],gds[19])
  60. #define GDS_Polar_scan(gds) (gds[27])
  61. #define GDS_Polar_Dx(gds) INT3(gds[20], gds[21], gds[22])
  62. #define GDS_Polar_Dy(gds) INT3(gds[23], gds[24], gds[25])
  63. #define GDS_Polar_pole(gds) ((gds[26] & 128) == 128)
  64. #define GDS_Lambert_nx(gds) ((gds[6] << 8) + gds[7])
  65. #define GDS_Lambert_ny(gds) ((gds[8] << 8) + gds[9])
  66. #define GDS_Lambert_La1(gds) INT3(gds[10],gds[11],gds[12])
  67. #define GDS_Lambert_Lo1(gds) INT3(gds[13],gds[14],gds[15])
  68. #define GDS_Lambert_mode(gds) (gds[16])
  69. #define GDS_Lambert_Lov(gds) INT3(gds[17],gds[18],gds[19])
  70. #define GDS_Lambert_dx(gds) INT3(gds[20],gds[21],gds[22])
  71. #define GDS_Lambert_dy(gds) INT3(gds[23],gds[24],gds[25])
  72. #define GDS_Lambert_NP(gds) ((gds[26] & 128) == 0)
  73. #define GDS_Lambert_scan(gds) (gds[27])
  74. #define GDS_Lambert_Latin1(gds) INT3(gds[28],gds[29],gds[30])
  75. #define GDS_Lambert_Latin2(gds) INT3(gds[31],gds[32],gds[33])
  76. #define GDS_Lambert_LatSP(gds) INT3(gds[34],gds[35],gds[36])
  77. #define GDS_Lambert_LonSP(gds) INT3(gds[37],gds[37],gds[37])
  78. #define GDS_ssEgrid_n(gds) UINT2(gds[6],gds[7])
  79. #define GDS_ssEgrid_n_dum(gds) UINT2(gds[8],gds[9])
  80. #define GDS_ssEgrid_La1(gds) INT3(gds[10],gds[11],gds[12])
  81. #define GDS_ssEgrid_Lo1(gds) INT3(gds[13],gds[14],gds[15])
  82. #define GDS_ssEgrid_mode(gds) (gds[16])
  83. #define GDS_ssEgrid_La2(gds) UINT3(gds[17],gds[18],gds[19])
  84. #define GDS_ssEgrid_Lo2(gds) UINT3(gds[20],gds[21],gds[22])
  85. #define GDS_ssEgrid_di(gds) (gds[16] & 128 ? INT2(gds[23],gds[24]) : 0)
  86. #define GDS_ssEgrid_dj(gds) (gds[16] & 128 ? INT2(gds[25],gds[26]) : 0)
  87. #define GDS_ssEgrid_scan(gds) (gds[27])
  88. #define GDS_fEgrid_n(gds) UINT2(gds[6],gds[7])
  89. #define GDS_fEgrid_n_dum(gds) UINT2(gds[8],gds[9])
  90. #define GDS_fEgrid_La1(gds) INT3(gds[10],gds[11],gds[12])
  91. #define GDS_fEgrid_Lo1(gds) INT3(gds[13],gds[14],gds[15])
  92. #define GDS_fEgrid_mode(gds) (gds[16])
  93. #define GDS_fEgrid_La2(gds) UINT3(gds[17],gds[18],gds[19])
  94. #define GDS_fEgrid_Lo2(gds) UINT3(gds[20],gds[21],gds[22])
  95. #define GDS_fEgrid_di(gds) (gds[16] & 128 ? INT2(gds[23],gds[24]) : 0)
  96. #define GDS_fEgrid_dj(gds) (gds[16] & 128 ? INT2(gds[25],gds[26]) : 0)
  97. #define GDS_fEgrid_scan(gds) (gds[27])
  98. #define GDS_ss2dEgrid_nx(gds) UINT2(gds[6],gds[7])
  99. #define GDS_ss2dEgrid_ny(gds) UINT2(gds[8],gds[9])
  100. #define GDS_ss2dEgrid_La1(gds) INT3(gds[10],gds[11],gds[12])
  101. #define GDS_ss2dEgrid_Lo1(gds) INT3(gds[13],gds[14],gds[15])
  102. #define GDS_ss2dEgrid_mode(gds) (gds[16])
  103. #define GDS_ss2dEgrid_La2(gds) INT3(gds[17],gds[18],gds[19])
  104. #define GDS_ss2dEgrid_Lo2(gds) INT3(gds[20],gds[21],gds[22])
  105. #define GDS_ss2dEgrid_di(gds) (gds[16] & 128 ? INT2(gds[23],gds[24]) : 0)
  106. #define GDS_ss2dEgrid_dj(gds) (gds[16] & 128 ? INT2(gds[25],gds[26]) : 0)
  107. #define GDS_ss2dEgrid_scan(gds) (gds[27])
  108. #define GDS_Merc_nx(gds) UINT2(gds[6],gds[7])
  109. #define GDS_Merc_ny(gds) UINT2(gds[8],gds[9])
  110. #define GDS_Merc_La1(gds) INT3(gds[10],gds[11],gds[12])
  111. #define GDS_Merc_Lo1(gds) INT3(gds[13],gds[14],gds[15])
  112. #define GDS_Merc_mode(gds) (gds[16])
  113. #define GDS_Merc_La2(gds) INT3(gds[17],gds[18],gds[19])
  114. #define GDS_Merc_Lo2(gds) INT3(gds[20],gds[21],gds[22])
  115. #define GDS_Merc_Latin(gds) INT3(gds[23],gds[24],gds[25])
  116. #define GDS_Merc_scan(gds) (gds[27])
  117. #define GDS_Merc_dx(gds) (gds[16] & 128 ? INT3(gds[28],gds[29],gds[30]) : 0)
  118. #define GDS_Merc_dy(gds) (gds[16] & 128 ? INT3(gds[31],gds[32],gds[33]) : 0)
  119. /* rotated Lat-lon grid */
  120. #define GDS_RotLL_nx(gds) UINT2(gds[6],gds[7])
  121. #define GDS_RotLL_ny(gds) UINT2(gds[8],gds[9])
  122. #define GDS_RotLL_La1(gds) INT3(gds[10],gds[11],gds[12])
  123. #define GDS_RotLL_Lo1(gds) INT3(gds[13],gds[14],gds[15])
  124. #define GDS_RotLL_mode(gds) (gds[16])
  125. #define GDS_RotLL_La2(gds) INT3(gds[17],gds[18],gds[19])
  126. #define GDS_RotLL_Lo2(gds) INT3(gds[20],gds[21],gds[22])
  127. #define GDS_RotLL_dx(gds) (gds[16] & 128 ? INT2(gds[23],gds[24]) : 0)
  128. #define GDS_RotLL_dy(gds) (gds[16] & 128 ? INT2(gds[25],gds[26]) : 0)
  129. #define GDS_RotLL_scan(gds) (gds[27])
  130. #define GDS_RotLL_LaSP(gds) INT3(gds[32],gds[33],gds[34])
  131. #define GDS_RotLL_LoSP(gds) INT3(gds[35],gds[36],gds[37])
  132. #define GDS_RotLL_RotAng(gds) ibm2flt(&(gds[38]))
  133. /* Triangular grid of DWD */
  134. #define GDS_Triangular_ni2(gds) INT2(gds[6],gds[7])
  135. #define GDS_Triangular_ni3(gds) INT2(gds[8],gds[9])
  136. #define GDS_Triangular_ni(gds) INT3(gds[13],gds[14],gds[15])
  137. #define GDS_Triangular_nd(gds) INT3(gds[10],gds[11],gds[12])
  138. /* Harmonics data */
  139. #define GDS_Harmonic_nj(gds) ((int) ((gds[6] << 8) + gds[7]))
  140. #define GDS_Harmonic_nk(gds) ((int) ((gds[8] << 8) + gds[9]))
  141. #define GDS_Harmonic_nm(gds) ((int) ((gds[10] << 8) + gds[11]))
  142. #define GDS_Harmonic_type(gds) (gds[12])
  143. #define GDS_Harmonic_mode(gds) (gds[13])
  144. /* index of NV and PV */
  145. #define GDS_PV(gds) ((gds[3] == 0) ? -1 : (int) gds[4] - 1)
  146. #define GDS_PL(gds) ((gds[4] == 255) ? -1 : (int) gds[3] * 4 + (int) gds[4] - 1)