Merge pull request #22 from wirc-sjsu/develop-w21
[WRF-SFIRE.git] / external / io_grib1 / WGRIB / levels.c
blob349ae1bbd5921e16e589ab27106658ae6c5135bd
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include "pds4.h"
4 #include "grib.h"
6 /* wesley ebisuzaki v1.0
8 * levels.c
10 * prints out a simple description of kpds6, kpds7
11 * (level/layer data)
12 * kpds6 = octet 10 of the PDS
13 * kpds7 = octet 11 and 12 of the PDS
14 * (kpds values are from NMC's grib routines)
15 * center = PDS_Center(pds) .. NMC, ECMWF, etc
17 * the description of the levels is
18 * (1) incomplete
19 * (2) include some NMC-only values (>= 200?)
21 * v1.1 wgrib v1.7.3.1 updated with new levels
22 * v1.2 added new level and new parameter
23 * v1.2.1 modified level 117 pv units
24 * v1.2.2 corrected level 141
25 * v1.2.3 fixed layer 206 (was 205)
28 void levels(int kpds6, int kpds7, int center) {
30 int o11, o12;
32 /* octets 11 and 12 */
33 o11 = kpds7 / 256;
34 o12 = kpds7 % 256;
37 switch (kpds6) {
39 case 1: printf("sfc");
40 break;
41 case 2: printf("cld base");
42 break;
43 case 3: printf("cld top");
44 break;
45 case 4: printf("0C isotherm");
46 break;
47 case 5: printf("cond lev");
48 break;
49 case 6: printf("max wind lev");
50 break;
51 case 7: printf("tropopause");
52 break;
53 case 8: printf("nom. top");
54 break;
55 case 9: printf("sea bottom");
56 break;
57 case 200:
58 case 10: printf("atmos col");
59 break;
61 case 12:
62 case 212: printf("low cld bot");
63 break;
64 case 13:
65 case 213: printf("low cld top");
66 break;
67 case 14:
68 case 214: printf("low cld lay");
69 break;
70 case 22:
71 case 222: printf("mid cld bot");
72 break;
73 case 23:
74 case 223: printf("mid cld top");
75 break;
76 case 24:
77 case 224: printf("mid cld lay");
78 break;
79 case 32:
80 case 232: printf("high cld bot");
81 break;
82 case 33:
83 case 233: printf("high cld top");
84 break;
85 case 34:
86 case 234: printf("high cld lay");
87 break;
89 case 201: printf("ocean column");
90 break;
91 case 204: printf("high trop freezing lvl");
92 break;
93 case 206: printf("grid-scale cld bot");
94 break;
95 case 207: printf("grid-scale cld top");
96 break;
97 case 209: printf("bndary-layer cld bot");
98 break;
99 case 210: printf("bndary-layer cld top");
100 break;
101 case 211: printf("bndary-layer cld layer");
102 break;
103 case 242: printf("convect-cld bot");
104 break;
105 case 243: printf("convect-cld top");
106 break;
107 case 244: printf("convect-cld layer");
108 break;
109 case 246: printf("max e-pot-temp lvl");
110 break;
111 case 247: printf("equilibrium lvl");
112 break;
113 case 248: printf("shallow convect-cld bot");
114 break;
115 case 249: printf("shallow convect-cld top");
116 break;
117 case 251: printf("deep convect-cld bot");
118 break;
119 case 252: printf("deep convect-cld top");
120 break;
122 case 100: printf("%d mb",kpds7);
123 break;
124 case 101: printf("%d-%d mb",o11*10,o12*10);
125 break;
126 case 102: printf("MSL");
127 break;
128 case 103: printf("%d m above MSL",kpds7);
129 break;
130 case 104: printf("%d-%d m above msl",o11*100,o12*100);
131 break;
132 case 105: printf("%d m above gnd",kpds7);
133 break;
134 case 106: printf("%d-%d m above gnd",o11*100,o12*100);
135 break;
136 case 107: printf("sigma=%.4f",kpds7/10000.0);
137 break;
138 case 108: printf("sigma %.2f-%.2f",o11/100.0,o12/100.0);
139 break;
140 case 109: printf("hybrid lev %d",kpds7);
141 break;
142 case 110: printf("hybrid %d-%d",o11,o12);
143 break;
144 case 111: printf("%d cm down",kpds7);
145 break;
146 case 112: printf("%d-%d cm down",o11,o12);
147 break;
148 case 113: printf("%dK",kpds7);
149 break;
150 case 114: printf("%d-%dK",475-o11,475-o12);
151 break;
152 case 115: printf("%d mb above gnd",kpds7);
153 break;
154 case 116: printf("%d-%d mb above gnd",o11,o12);
155 break;
156 case 117: printf("%d pv units",INT2(o11,o12)); /* units are suspect */
157 break;
158 case 119: printf("%.5f (ETA level)",kpds7/10000.0);
159 break;
160 case 120: printf("%.2f-%.2f (ETA levels)",o11/100.0,o12/100.0);
161 break;
162 case 121: printf("%d-%d mb",1100-o11,1100-o12);
163 break;
164 case 125: printf("%d cm above gnd",kpds7);
165 break;
166 case 126:
167 if (center == NMC) printf("%.2f mb",kpds7*0.01);
168 break;
169 case 128: printf("%.3f-%.3f (sigma)",1.1-o11/1000.0, 1.1-o12/1000.0);
170 break;
171 case 141: printf("%d-%d mb",o11*10,1100-o12);
172 break;
173 case 160: printf("%d m below sea level",kpds7);
174 break;
175 default:
176 break;