Newer
Older
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "grb2.h"
#include "wgrib2.h"
#include "fnlist.h"
/*
* FlagTable.c
*
* routines to return the value of the various flags
* policy: use this instead of .h files
*
* 12/2006: Public Domain Wesley Ebisuzaki
* 1/2007 cleanup M. Schwarb
*/
/*
* HEADER:-1:flag_table_3.3:inv:0:flag table 3.3, resolution and component flags
*/
int f_flag_table_3_3(ARG0) {
int res;
if (mode >= 0) {
res = flag_table_3_3(sec);
if (res >= 0) {
sprintf(inv_out,"flag table 3.3=%d", res);
inv_out += strlen(inv_out);
}
}
return 0;
}
int flag_table_3_3(unsigned char **sec) {
unsigned char *p;
p = flag_table_3_3_location(sec);
if (p == NULL) return -1;
return (int) *p;
}
int set_flag_table_3_3(unsigned char **sec, unsigned int flag) {
unsigned char *p;
p = flag_table_3_3_location(sec);
if (p == NULL) return -1;
*p = flag;
return 0;
}
unsigned char *flag_table_3_3_location(unsigned char **sec) {
int grid_template;
unsigned char *gds;
grid_template = code_table_3_1(sec);
gds = sec[3];
switch (grid_template) {
case 0:
case 1:
case 2:
case 3:
case 40:
case 41:
case 42:
case 43:
case 204:
case 10:
case 20:
case 30:
case 31:
case 90:
case 110:
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
* HEADER:1:vector_dir:inv:0:grid or earth relative winds
*/
int f_vector_dir(ARG0) {
int res;
if (mode >= 0) {
res = flag_table_3_3(sec);
if (res >= 0) {
sprintf(inv_out, res & 8 ? "winds(grid)" : "winds(N/S)");
inv_out += strlen(inv_out);
}
}
return 0;
}
/*
* HEADER:-1:flag_table_3.4:inv:0:flag table 3.4, scanning mode
*/
int f_flag_table_3_4(ARG0) {
int scan;
extern char *scan_order[];
if (mode >= 0) {
scan = flag_table_3_4(sec);
if (scan >= 0) {
sprintf(inv_out,"flag table 3.4=%d %s", scan, scan_order[scan >> 4]);
}
}
return 0;
}
int flag_table_3_4(unsigned char **sec) {
unsigned char *p;
p = flag_table_3_4_location(sec);
if (p == NULL) return -1;
return (int) *p;
}
int set_flag_table_3_4(unsigned char **sec, unsigned int flag) {
unsigned char *p;
p = flag_table_3_4_location(sec);
unsigned char *flag_table_3_4_location(unsigned char **sec) {
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
int grid_template;
unsigned char *gds;
gds = sec[3];
grid_template = code_table_3_1(sec);
switch (grid_template) {
case 0:
case 1:
case 2:
case 3:
case 40:
case 41:
case 42:
case 43:
return gds+71; break;
case 10: return gds+59; break;
case 20: return gds+64; break;
case 30:
case 31: return gds+64; break;
case 50:
case 51:
case 52:
case 53:
/* spectral modes don't have scan order */
return NULL; break;
case 90: return gds+63; break;
case 110: return gds+56; break;
case 190:
case 120: return gds+38; break;
case 204: return gds+71; break;
case 1000: return gds+50; break;
default: return NULL; break;
}
return NULL;
}
/*
* HEADER:-1:flag_table_3.5:inv:0:flag table 3.5 projection center
*/
int f_flag_table_3_5(ARG0) {
int p;
if (mode >= 0) {
p = flag_table_3_5(sec);
if (p >= 0) {
sprintf(inv_out,"flag table 3.5=%d", p);
inv_out += strlen(inv_out);
}
}
return 0;
}
int flag_table_3_5(unsigned char **sec) {
unsigned char *gds;
gds = sec[3];
switch (code_table_3_1(sec)) {
case 20:
case 30:
case 31: return gds[63];
case 110: return gds[55];
}
return -1;
}
/*
* HEADER:-1:flag_table_3.9:inv:0:flag table 3.9 numbering order of diamonds seen from corresponding pole
*/
int f_flag_table_3_9(ARG0) {
int p;
if (mode >= 0) {
p = flag_table_3_9(sec);
if (p >= 0) {
sprintf(inv_out,"flag table 3.9=%d", p);
inv_out += strlen(inv_out);
}
}
return 0;
}
int flag_table_3_9(unsigned char **sec) {
unsigned char *gds;
gds = sec[3];
switch (code_table_3_1(sec)) {
case 100: return gds[32];
}
return -1;
}
/*
* HEADER:-1:flag_table_3.10:inv:0:flag table 3.10 scanning mode for one diamond
*/
int f_flag_table_3_10(ARG0) {
int p;
if (mode >= 0) {
p = flag_table_3_10(sec);
if (p >= 0) {
sprintf(inv_out,"flag table 3.10=%d", p);
inv_out += strlen(inv_out);
}
}
return 0;
}
int flag_table_3_10(unsigned char **sec) {
unsigned char *gds;
gds = sec[3];
switch (code_table_3_1(sec)) {
case 100: return gds[33];
}
return -1;
}