Mapper
rsel_load.c
Go to the documentation of this file.
1 #include <sqlhdr.h>
2 #include <sqliapi.h>
3 static const char _Cn7[] = "get_val";
4 static const char _Cn6[] = "get_fval";
5 static const char _Cn5[] = "get_fval18";
6 static const char _Cn4[] = "loop_seg_ts";
7 static const char _Cn3[] = "loop_seg";
8 static const char _Cn2[] = "loop_fg";
9 static const char _Cn1[] = "qfg";
10 #line 1 "rsel_load.ec"
11 #include <stdlib.h>
12 #include <stdio.h>
13 #include <string.h>
14 #include <errno.h>
15 #include <ctype.h>
16 #include <sys/time.h>
17 #include <sys/types.h>
18 #include <sys/stat.h>
19 
20 #include <X11/Xos.h>
21 #include <Xm/Text.h>
22 #include <Xm/TextF.h>
23 
24 #include "mm2rfs.h"
25 
26 /* external variables */
27 extern Widget text_output;
28 extern int fg_toggle_item_set;
29 extern int parm_toggle_item_set;
30 extern int dur_toggle_item_set;
31 extern int src_toggle_item_set;
32 extern int ver_toggle_item_set;
33 extern debug;
34 
35 extern struct fgroup_info fg[20];
36 extern struct time_cntl tc;
37 
38 int rsel_load( struct rsel_struct *rsel )
39 {
40 
41 char src1[2];
42 char src2[2];
43 char dc[11];
44 char line[256];
45 int i,j,k;
46 int num_rsels=-1;
47 int get_fcst_err,loop_fg_err,loop_seg_err,loop_seg_ts_err;
48 
49 /* declare informix host variables */
50 /*
51  * exec sql begin declare section;
52  */
53 #line 40 "rsel_load.ec"
54 #line 41 "rsel_load.ec"
55  char fgroupid[9], segid[9], wfo_resp[4];
56  char ts_id[9], ts_dt[5], id[6];
57  char pe1[2], pe2[2], dur[2], t[2], s[2], e[2], p[2];
58  char src[2];
59  char query[256];
60 int rfs_post;
61 int ccal_yr, cmon, czday, ctime;
62 int vcal_yr, vmon, vzday, vhour, vtime;
63 int segnum;
64 float value;
65 /*
66  * exec sql end declare section;
67  */
68 #line 51 "rsel_load.ec"
69 
70 
71 /*
72  * exec sql set isolation to dirty read;
73  */
74 #line 53 "rsel_load.ec"
75  {
76 #line 53 "rsel_load.ec"
77  static const char *sqlcmdtxt[] =
78 #line 53 "rsel_load.ec"
79  {
80 #line 53 "rsel_load.ec"
81  "set isolation to dirty read",
82  0
83  };
84 #line 53 "rsel_load.ec"
85  static ifx_statement_t _SQ0 = {0};
86 #line 53 "rsel_load.ec"
87  sqli_stmt(ESQLINTVERSION, &_SQ0, sqlcmdtxt, 0, (ifx_sqlvar_t *)0, (struct value *)0, (ifx_literal_t *)0, (ifx_namelist_t *)0, (ifx_cursor_t *)0, -1, 0, 0);
88 #line 53 "rsel_load.ec"
89  }
90 
91  /* database should already be open */
92 
93  /* establish data source(s) */
94  strcpy(src1,"E"); /* default is HAS */
95  strcpy(src2,"E"); /* default is HAS */
96  if(src_toggle_item_set==2)
97  {
98  strcpy(src1,"W"); /* HPC */
99  strcpy(src2,"W"); /* HPC */
100  }
101  if(src_toggle_item_set==3)
102  {
103  strcpy(src1,"U"); /* model 1 */
104  strcpy(src2,"U"); /* model 2 */
105  }
106  if(src_toggle_item_set==4)
107  {
108  strcpy(src1,"V"); /* model 2 */
109  strcpy(src2,"V"); /* model 2 */
110  }
111  if(src_toggle_item_set==5)
112  {
113  strcpy(src1,"E"); /* WFO */
114  strcpy(src2,"U"); /* model 1 */
115  }
116  if(src_toggle_item_set==6)
117  {
118  strcpy(src1,"E"); /* HAS */
119  strcpy(src2,"V"); /* model 2 */
120  }
121  if(src_toggle_item_set==7)
122  {
123  strcpy(src1,"W"); /* HPC */
124  strcpy(src2,"U"); /* model 1 */
125  }
126  if(src_toggle_item_set==8)
127  {
128  strcpy(src1,"W"); /* HPC */
129  strcpy(src2,"V"); /* model 2 */
130  }
131 
132  /* set up loop to find selected or all (*) forecast groups */
133  /* this configuration will allow all (*) usage at some point */
134  if(fg_toggle_item_set < 0)
135  sprintf(query,"select fgroupid "
136  "from fgroup");
137  else
138  sprintf(query,"select fgroupid "
139  "from fgroup "
140  "where fgroupid matches \"%s\"",
141  fg[fg_toggle_item_set].id);
142 
143 /*
144  * $prepare qfg from $query;
145  */
146 #line 107 "rsel_load.ec"
147  {
148 #line 107 "rsel_load.ec"
149  sqli_prep(ESQLINTVERSION, _Cn1, query,(ifx_literal_t *)0, (ifx_namelist_t *)0, -1, 0, 0 );
150 #line 107 "rsel_load.ec"
151  }
152  if(sqlca.sqlcode)
153  {
154  sprintf(line,"prepare qfg failed (%d)",sqlca.sqlcode);
155  if(text_output)
156  XmTextFieldSetString (text_output, line);
157  return(-1);
158  }
159 
160 /*
161  * $declare loop_fg cursor for qfg;
162  */
163 #line 116 "rsel_load.ec"
164  {
165 #line 116 "rsel_load.ec"
166  sqli_curs_decl_dynm(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn2, 512), _Cn2, sqli_curs_locate(ESQLINTVERSION, _Cn1, 513), 0, 0);
167 #line 116 "rsel_load.ec"
168  }
169  if(sqlca.sqlcode)
170  {
171  sprintf(line,"declare loop_fg failed (%d)",sqlca.sqlcode);
172  if(text_output)
173  XmTextFieldSetString (text_output, line);
174  return(-1);
175  }
176 /*
177  * $open loop_fg;
178  */
179 #line 124 "rsel_load.ec"
180  {
181 #line 124 "rsel_load.ec"
182  sqli_curs_open(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn2, 768), (ifx_sqlda_t *)0, (char *)0, (struct value *)0, 0, 0);
183 #line 124 "rsel_load.ec"
184  }
185  if(sqlca.sqlcode)
186  {
187  sprintf(line,"open loop_fg failed (%d)",sqlca.sqlcode);
188  if(text_output)
189  XmTextFieldSetString (text_output, line);
190  return(-1);
191  }
192  loop_fg_err=sqlca.sqlcode;
193 
194 
195  /* loop here for multiple forecast groups */
196  while(!loop_fg_err)
197  {
198 /*
199  * $fetch next loop_fg into $fgroupid;
200  */
201 #line 138 "rsel_load.ec"
202  {
203 #line 138 "rsel_load.ec"
204  static ifx_sqlvar_t _sqobind[] =
205  {
206  { 100, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
207 #line 138 "rsel_load.ec"
208  };
209  static ifx_sqlda_t _SD0 = { 1, _sqobind, {0}, 1, 0 };
210  static _FetchSpec _FS1 = { 0, 1, 0 };
211 #line 138 "rsel_load.ec"
212  _sqobind[0].sqldata = fgroupid;
213  sqli_curs_fetch(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn2, 768), (ifx_sqlda_t *)0, &_SD0, (char *)0, &_FS1);
214 #line 138 "rsel_load.ec"
215  }
216  loop_fg_err=sqlca.sqlcode;
217  if(!loop_fg_err)
218  {
219 /*
220  * $declare loop_seg cursor for select segid,segnum
221  * from fgroup_seg
222  * where fgroupid=$fgroupid
223  * order by segnum;
224  */
225 #line 142 "rsel_load.ec"
226  {
227 #line 145 "rsel_load.ec"
228  static const char *sqlcmdtxt[] =
229 #line 145 "rsel_load.ec"
230  {
231 #line 145 "rsel_load.ec"
232  "select segid , segnum from fgroup_seg where fgroupid = ? order by segnum",
233  0
234  };
235 #line 145 "rsel_load.ec"
236  static ifx_sqlvar_t _sqibind[] =
237  {
238  { 100, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
239 #line 145 "rsel_load.ec"
240  };
241  static ifx_sqlda_t _SD0 = { 1, _sqibind, {0}, 1, 0 };
242 #line 145 "rsel_load.ec"
243  _sqibind[0].sqldata = fgroupid;
244 #line 145 "rsel_load.ec"
245 sqli_curs_decl_stat(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn3, 512), _Cn3, sqlcmdtxt, &_SD0, (ifx_sqlda_t *)0, 0, (ifx_literal_t *)0, (ifx_namelist_t *)0, 2, 0, 0);
246 #line 145 "rsel_load.ec"
247  }
248  if(sqlca.sqlcode)
249  {
250  sprintf(line,"declare loop_seg failed (%d)",sqlca.sqlcode);
251  if(text_output)
252  XmTextFieldSetString (text_output, line);
253  return(-1);
254  }
255 /*
256  * $open loop_seg;
257  */
258 #line 153 "rsel_load.ec"
259  {
260 #line 153 "rsel_load.ec"
261  sqli_curs_open(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn3, 768), (ifx_sqlda_t *)0, (char *)0, (struct value *)0, 0, 0);
262 #line 153 "rsel_load.ec"
263  }
264  if(sqlca.sqlcode)
265  {
266  sprintf(line,"open loop_seg failed (%d)",sqlca.sqlcode);
267  if(text_output)
268  XmTextFieldSetString (text_output, line);
269  return(-1);
270  }
271  loop_seg_err=sqlca.sqlcode;
272 
273 
274  /* loop here for multiple segments in same forecast group */
275  while(!loop_seg_err)
276  {
277 /*
278  * $fetch next loop_seg into $segid,$segnum;
279  */
280 #line 167 "rsel_load.ec"
281  {
282 #line 167 "rsel_load.ec"
283  static ifx_sqlvar_t _sqobind[] =
284  {
285  { 100, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
286  { 102, sizeof(segnum), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
287 #line 167 "rsel_load.ec"
288  };
289  static ifx_sqlda_t _SD0 = { 2, _sqobind, {0}, 2, 0 };
290  static _FetchSpec _FS1 = { 0, 1, 0 };
291 #line 167 "rsel_load.ec"
292  _sqobind[0].sqldata = segid;
293 #line 167 "rsel_load.ec"
294  _sqobind[1].sqldata = (char *) &segnum;
295  sqli_curs_fetch(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn3, 768), (ifx_sqlda_t *)0, &_SD0, (char *)0, &_FS1);
296 #line 167 "rsel_load.ec"
297  }
298  loop_seg_err=sqlca.sqlcode;
299  if(!loop_seg_err)
300  {
301 /*
302  * $declare loop_seg_ts cursor for
303  * select unique
304  * rfs_post,
305  * ts_id,ts_dt,
306  * id,pe1,pe2,dur,t,e,p,wfo_resp
307  * from seg_ts
308  * where segid=$segid and
309  * pe1="H" and
310  * pe2="Z" and
311  * dur = "I" and
312  * t = "F" and
313  * e = "Z" and
314  * p = "Z";
315  */
316 #line 171 "rsel_load.ec"
317  {
318 #line 183 "rsel_load.ec"
319  static const char *sqlcmdtxt[] =
320 #line 183 "rsel_load.ec"
321  {
322 #line 183 "rsel_load.ec"
323  "select unique rfs_post , ts_id , ts_dt , id , pe1 , pe2 , dur , t , e , p , wfo_resp from seg_ts where segid = ? and pe1 = \"H\" and pe2 = \"Z\" and dur = \"I\" and t = \"F\" and e = \"Z\" and p = \"Z\"",
324  0
325  };
326 #line 183 "rsel_load.ec"
327  static ifx_sqlvar_t _sqibind[] =
328  {
329  { 100, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
330 #line 183 "rsel_load.ec"
331  };
332  static ifx_sqlda_t _SD0 = { 1, _sqibind, {0}, 1, 0 };
333 #line 183 "rsel_load.ec"
334  _sqibind[0].sqldata = segid;
335 #line 183 "rsel_load.ec"
336 sqli_curs_decl_stat(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn4, 512), _Cn4, sqlcmdtxt, &_SD0, (ifx_sqlda_t *)0, 0, (ifx_literal_t *)0, (ifx_namelist_t *)0, 2, 0, 0);
337 #line 183 "rsel_load.ec"
338  }
339 
340  if(sqlca.sqlcode)
341  {
342  sprintf(line,"declare loop_seg_ts failed (%d)",sqlca.sqlcode);
343  if(text_output)
344  XmTextFieldSetString (text_output, line);
345  return(-1);
346  }
347 /*
348  * $open loop_seg_ts;
349  */
350 #line 192 "rsel_load.ec"
351  {
352 #line 192 "rsel_load.ec"
353  sqli_curs_open(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn4, 768), (ifx_sqlda_t *)0, (char *)0, (struct value *)0, 0, 0);
354 #line 192 "rsel_load.ec"
355  }
356  if(sqlca.sqlcode)
357  {
358  sprintf(line,"open loop_seg_ts failed (%d)",sqlca.sqlcode);
359  if(text_output)
360  XmTextFieldSetString (text_output, line);
361  return(-1);
362  }
363  loop_seg_ts_err=sqlca.sqlcode;
364 
365 
366  /* loop here for multiple time series in the same segment */
367  while(!loop_seg_ts_err)
368  {
369 /*
370  * $fetch next loop_seg_ts into $rfs_post,
371  * $ts_id,$ts_dt,
372  * $id,$pe1,$pe2,$dur,$t,$e,$p,
373  * $wfo_resp;
374  */
375 #line 206 "rsel_load.ec"
376  {
377 #line 209 "rsel_load.ec"
378  static ifx_sqlvar_t _sqobind[] =
379  {
380  { 102, sizeof(rfs_post), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
381  { 100, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
382  { 100, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
383  { 100, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
384  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
385  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
386  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
387  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
388  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
389  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
390  { 100, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
391 #line 209 "rsel_load.ec"
392  };
393  static ifx_sqlda_t _SD0 = { 11, _sqobind, {0}, 11, 0 };
394  static _FetchSpec _FS1 = { 0, 1, 0 };
395 #line 209 "rsel_load.ec"
396  _sqobind[0].sqldata = (char *) &rfs_post;
397 #line 209 "rsel_load.ec"
398  _sqobind[1].sqldata = ts_id;
399 #line 209 "rsel_load.ec"
400  _sqobind[2].sqldata = ts_dt;
401 #line 209 "rsel_load.ec"
402  _sqobind[3].sqldata = id;
403 #line 209 "rsel_load.ec"
404  _sqobind[4].sqldata = pe1;
405 #line 209 "rsel_load.ec"
406  _sqobind[5].sqldata = pe2;
407 #line 209 "rsel_load.ec"
408  _sqobind[6].sqldata = dur;
409 #line 209 "rsel_load.ec"
410  _sqobind[7].sqldata = t;
411 #line 209 "rsel_load.ec"
412  _sqobind[8].sqldata = e;
413 #line 209 "rsel_load.ec"
414  _sqobind[9].sqldata = p;
415 #line 209 "rsel_load.ec"
416  _sqobind[10].sqldata = wfo_resp;
417  sqli_curs_fetch(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn4, 768), (ifx_sqlda_t *)0, &_SD0, (char *)0, &_FS1);
418 #line 209 "rsel_load.ec"
419  }
420 
421  loop_seg_ts_err=sqlca.sqlcode;
422  if(!loop_seg_ts_err)
423  {
424 
425  /* collect forecast values and load into structure */
426  num_rsels++;
427  strcpy(src,src1);
428  strcpy(rsel[num_rsels].fgroupid,fgroupid);
429  strcpy(rsel[num_rsels].segid,segid);
430  strcpy(rsel[num_rsels].oper,"SNOW-17");
431  strcpy(rsel[num_rsels].oper_name,"n/a");
432  strcpy(rsel[num_rsels].ts_id,ts_id);
433  strcpy(rsel[num_rsels].ts_dt,ts_dt);
434  rsel[num_rsels].rfs_post=rfs_post;
435  strcpy(rsel[num_rsels].create,"\0");
436  strcpy(rsel[num_rsels].id,id);
437  sprintf(rsel[num_rsels].shefpc,
438  "%s%s%s%s%s%s%s",pe1,pe2,dur,t,src,e,p);
439  strcpy(rsel[num_rsels].wfo_resp,wfo_resp);
440 
441  for(i=0;i<28;i++)
442  {
443  rsel[num_rsels].per[i].amt=9.999;
444  strcpy(rsel[num_rsels].per[i].qual,"M");
445  if(i >= 12)
446  strcpy(rsel[num_rsels].per[i].src,src2);
447  else
448  strcpy(rsel[num_rsels].per[i].src,src1);
449  }
450 
451  k=0;
452  strcpy(src,src1);
453  for(i=0;i<=dur_toggle_item_set;i++)
454  {
455  if(!i)
456  {
457  adj_time((tc.period-1)*(-6),
458  tc.year,tc.month,tc.day,tc.hour,
459  &vcal_yr,&vmon,&vzday,&vhour);
460 
461  vtime=180000;
462 
463 /*
464  * $declare get_fval18 cursor for
465  * select value,ccal_yr,cmon,czday,ctime
466  * from fval
467  * where id=$id and pe1=$pe1 and pe2=$pe2 and
468  * dur=$dur and t=$t and s=$src and
469  * e=$e and p=$p and
470  * vcal_yr=$vcal_yr and vmon=$vmon and
471  * vzday=$vzday and vtime=$vtime and
472  * value >= 0.
473  * order by ccal_yr desc,cmon desc,czday desc,ctime desc;
474  */
475 #line 253 "rsel_load.ec"
476  {
477 #line 262 "rsel_load.ec"
478  static const char *sqlcmdtxt[] =
479 #line 262 "rsel_load.ec"
480  {
481 #line 262 "rsel_load.ec"
482  "select value , ccal_yr , cmon , czday , ctime from fval where id = ? and pe1 = ? and pe2 = ? and dur = ? and t = ? and s = ? and e = ? and p = ? and vcal_yr = ? and vmon = ? and vzday = ? and vtime = ? and value >= 0. order by ccal_yr desc , cmon desc , czday desc , ctime desc",
483  0
484  };
485 #line 262 "rsel_load.ec"
486  static ifx_sqlvar_t _sqibind[] =
487  {
488  { 100, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
489  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
490  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
491  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
492  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
493  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
494  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
495  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
496  { 102, sizeof(vcal_yr), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
497  { 102, sizeof(vmon), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
498  { 102, sizeof(vzday), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
499  { 102, sizeof(vtime), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
500 #line 262 "rsel_load.ec"
501  };
502  static ifx_sqlda_t _SD0 = { 12, _sqibind, {0}, 12, 0 };
503 #line 262 "rsel_load.ec"
504  _sqibind[0].sqldata = id;
505 #line 262 "rsel_load.ec"
506  _sqibind[1].sqldata = pe1;
507 #line 262 "rsel_load.ec"
508  _sqibind[2].sqldata = pe2;
509 #line 262 "rsel_load.ec"
510  _sqibind[3].sqldata = dur;
511 #line 262 "rsel_load.ec"
512  _sqibind[4].sqldata = t;
513 #line 262 "rsel_load.ec"
514  _sqibind[5].sqldata = src;
515 #line 262 "rsel_load.ec"
516  _sqibind[6].sqldata = e;
517 #line 262 "rsel_load.ec"
518  _sqibind[7].sqldata = p;
519 #line 262 "rsel_load.ec"
520  _sqibind[8].sqldata = (char *) &vcal_yr;
521 #line 262 "rsel_load.ec"
522  _sqibind[9].sqldata = (char *) &vmon;
523 #line 262 "rsel_load.ec"
524  _sqibind[10].sqldata = (char *) &vzday;
525 #line 262 "rsel_load.ec"
526  _sqibind[11].sqldata = (char *) &vtime;
527 #line 262 "rsel_load.ec"
528 sqli_curs_decl_stat(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn5, 512), _Cn5, sqlcmdtxt, &_SD0, (ifx_sqlda_t *)0, 0, (ifx_literal_t *)0, (ifx_namelist_t *)0, 2, 0, 0);
529 #line 262 "rsel_load.ec"
530  }
531 /*
532  * $open get_fval18;
533  */
534 #line 263 "rsel_load.ec"
535  {
536 #line 263 "rsel_load.ec"
537  sqli_curs_open(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn5, 768), (ifx_sqlda_t *)0, (char *)0, (struct value *)0, 0, 0);
538 #line 263 "rsel_load.ec"
539  }
540 /*
541  * $fetch next get_fval18
542  * into $value,$ccal_yr,$cmon,$czday,$ctime;
543  */
544 #line 264 "rsel_load.ec"
545  {
546 #line 265 "rsel_load.ec"
547  static ifx_sqlvar_t _sqobind[] =
548  {
549  { 104, sizeof(value), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
550  { 102, sizeof(ccal_yr), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
551  { 102, sizeof(cmon), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
552  { 102, sizeof(czday), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
553  { 102, sizeof(ctime), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
554 #line 265 "rsel_load.ec"
555  };
556  static ifx_sqlda_t _SD0 = { 5, _sqobind, {0}, 5, 0 };
557  static _FetchSpec _FS1 = { 0, 1, 0 };
558 #line 265 "rsel_load.ec"
559  _sqobind[0].sqldata = (char *) &value;
560 #line 265 "rsel_load.ec"
561  _sqobind[1].sqldata = (char *) &ccal_yr;
562 #line 265 "rsel_load.ec"
563  _sqobind[2].sqldata = (char *) &cmon;
564 #line 265 "rsel_load.ec"
565  _sqobind[3].sqldata = (char *) &czday;
566 #line 265 "rsel_load.ec"
567  _sqobind[4].sqldata = (char *) &ctime;
568  sqli_curs_fetch(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn5, 768), (ifx_sqlda_t *)0, &_SD0, (char *)0, &_FS1);
569 #line 265 "rsel_load.ec"
570  }
571  if(ver_toggle_item_set==2)
572 /*
573  * $fetch next get_fval18
574  * into $value,$ccal_yr,$cmon,$czday,$ctime;
575  */
576 #line 267 "rsel_load.ec"
577  {
578 #line 268 "rsel_load.ec"
579  static ifx_sqlvar_t _sqobind[] =
580  {
581  { 104, sizeof(value), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
582  { 102, sizeof(ccal_yr), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
583  { 102, sizeof(cmon), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
584  { 102, sizeof(czday), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
585  { 102, sizeof(ctime), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
586 #line 268 "rsel_load.ec"
587  };
588  static ifx_sqlda_t _SD0 = { 5, _sqobind, {0}, 5, 0 };
589  static _FetchSpec _FS1 = { 0, 1, 0 };
590 #line 268 "rsel_load.ec"
591  _sqobind[0].sqldata = (char *) &value;
592 #line 268 "rsel_load.ec"
593  _sqobind[1].sqldata = (char *) &ccal_yr;
594 #line 268 "rsel_load.ec"
595  _sqobind[2].sqldata = (char *) &cmon;
596 #line 268 "rsel_load.ec"
597  _sqobind[3].sqldata = (char *) &czday;
598 #line 268 "rsel_load.ec"
599  _sqobind[4].sqldata = (char *) &ctime;
600  sqli_curs_fetch(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn5, 768), (ifx_sqlda_t *)0, &_SD0, (char *)0, &_FS1);
601 #line 268 "rsel_load.ec"
602  }
603 
604  if(debug)
605  printf("%s %s%s%s%s%s %02d/%02d @ %04d %8.1f "
606  "DC %02d/%02d/%02d @ %04d (%d)\n",
607  id,pe1,pe2,dur,t,src,vmon,vzday,vtime/100,
608  value,cmon,czday,ccal_yr%100,ctime/100,
609  sqlca.sqlcode);
610  if(!sqlca.sqlcode)
611  {
612  /* set creation date/time */
613  if(!strlen(rsel[num_rsels].create))
614  {
615  sprintf(dc,"%02d%02d%02d%02d%02d\0",
616  ccal_yr%100,cmon,czday,
617  ctime/10000,(ctime%10000)/100);
618  strcpy(rsel[num_rsels].create,dc);
619  }
620  if(value < 0.0)
621  {
622  rsel[num_rsels].per[k].amt=9.999;
623  strcpy(rsel[num_rsels].per[k].qual,"M");
624  }
625  else
626  {
627  value=value-1.5;
628  if(value < 0.0) value=0.0;
629  rsel[num_rsels].per[k].amt=value;
630  strcpy(rsel[num_rsels].per[k].qual,"Z");
631  }
632  }
633  k++;
634 /*
635  * $close get_fval18;
636  */
637 #line 300 "rsel_load.ec"
638  {
639 #line 300 "rsel_load.ec"
640  sqli_curs_close(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn5, 768));
641 #line 300 "rsel_load.ec"
642  }
643 /*
644  * $free get_fval18;
645  */
646 #line 300 "rsel_load.ec"
647  {
648 #line 300 "rsel_load.ec"
649  sqli_curs_free(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn5, 770));
650 #line 300 "rsel_load.ec"
651  }
652  }
653  else
654  {
655  adj_time(24,vcal_yr,vmon,vzday,vhour,
656  &vcal_yr,&vmon,&vzday,&vhour);
657 
658  for(j=0;j<=3;j++)
659  {
660  /* switch src */
661  if(k>=12)
662  strcpy(src,src2);
663  vtime=60000*j;
664 /*
665  * $declare get_fval cursor for
666  * select value,ccal_yr,cmon,czday,ctime
667  * from fval
668  * where id=$id and pe1=$pe1 and pe2=$pe2 and
669  * dur=$dur and t=$t and s=$src and
670  * e=$e and p=$p and
671  * vcal_yr=$vcal_yr and vmon=$vmon and
672  * vzday=$vzday and vtime=$vtime and
673  * value >= 0.
674  * order by ccal_yr desc,cmon desc,
675  * czday desc,ctime desc;
676  */
677 #line 313 "rsel_load.ec"
678  {
679 #line 323 "rsel_load.ec"
680  static const char *sqlcmdtxt[] =
681 #line 323 "rsel_load.ec"
682  {
683 #line 323 "rsel_load.ec"
684  "select value , ccal_yr , cmon , czday , ctime from fval where id = ? and pe1 = ? and pe2 = ? and dur = ? and t = ? and s = ? and e = ? and p = ? and vcal_yr = ? and vmon = ? and vzday = ? and vtime = ? and value >= 0. order by ccal_yr desc , cmon desc , czday desc , ctime desc",
685  0
686  };
687 #line 323 "rsel_load.ec"
688  static ifx_sqlvar_t _sqibind[] =
689  {
690  { 100, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
691  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
692  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
693  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
694  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
695  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
696  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
697  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
698  { 102, sizeof(vcal_yr), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
699  { 102, sizeof(vmon), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
700  { 102, sizeof(vzday), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
701  { 102, sizeof(vtime), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
702 #line 323 "rsel_load.ec"
703  };
704  static ifx_sqlda_t _SD0 = { 12, _sqibind, {0}, 12, 0 };
705 #line 323 "rsel_load.ec"
706  _sqibind[0].sqldata = id;
707 #line 323 "rsel_load.ec"
708  _sqibind[1].sqldata = pe1;
709 #line 323 "rsel_load.ec"
710  _sqibind[2].sqldata = pe2;
711 #line 323 "rsel_load.ec"
712  _sqibind[3].sqldata = dur;
713 #line 323 "rsel_load.ec"
714  _sqibind[4].sqldata = t;
715 #line 323 "rsel_load.ec"
716  _sqibind[5].sqldata = src;
717 #line 323 "rsel_load.ec"
718  _sqibind[6].sqldata = e;
719 #line 323 "rsel_load.ec"
720  _sqibind[7].sqldata = p;
721 #line 323 "rsel_load.ec"
722  _sqibind[8].sqldata = (char *) &vcal_yr;
723 #line 323 "rsel_load.ec"
724  _sqibind[9].sqldata = (char *) &vmon;
725 #line 323 "rsel_load.ec"
726  _sqibind[10].sqldata = (char *) &vzday;
727 #line 323 "rsel_load.ec"
728  _sqibind[11].sqldata = (char *) &vtime;
729 #line 323 "rsel_load.ec"
730 sqli_curs_decl_stat(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn6, 512), _Cn6, sqlcmdtxt, &_SD0, (ifx_sqlda_t *)0, 0, (ifx_literal_t *)0, (ifx_namelist_t *)0, 2, 0, 0);
731 #line 323 "rsel_load.ec"
732  }
733 /*
734  * $open get_fval;
735  */
736 #line 324 "rsel_load.ec"
737  {
738 #line 324 "rsel_load.ec"
739  sqli_curs_open(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn6, 768), (ifx_sqlda_t *)0, (char *)0, (struct value *)0, 0, 0);
740 #line 324 "rsel_load.ec"
741  }
742 /*
743  * $fetch next get_fval
744  * into $value,$ccal_yr,$cmon,$czday,$ctime;
745  */
746 #line 325 "rsel_load.ec"
747  {
748 #line 326 "rsel_load.ec"
749  static ifx_sqlvar_t _sqobind[] =
750  {
751  { 104, sizeof(value), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
752  { 102, sizeof(ccal_yr), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
753  { 102, sizeof(cmon), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
754  { 102, sizeof(czday), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
755  { 102, sizeof(ctime), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
756 #line 326 "rsel_load.ec"
757  };
758  static ifx_sqlda_t _SD0 = { 5, _sqobind, {0}, 5, 0 };
759  static _FetchSpec _FS1 = { 0, 1, 0 };
760 #line 326 "rsel_load.ec"
761  _sqobind[0].sqldata = (char *) &value;
762 #line 326 "rsel_load.ec"
763  _sqobind[1].sqldata = (char *) &ccal_yr;
764 #line 326 "rsel_load.ec"
765  _sqobind[2].sqldata = (char *) &cmon;
766 #line 326 "rsel_load.ec"
767  _sqobind[3].sqldata = (char *) &czday;
768 #line 326 "rsel_load.ec"
769  _sqobind[4].sqldata = (char *) &ctime;
770  sqli_curs_fetch(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn6, 768), (ifx_sqlda_t *)0, &_SD0, (char *)0, &_FS1);
771 #line 326 "rsel_load.ec"
772  }
773  if(ver_toggle_item_set==2)
774 /*
775  * $fetch next get_fval
776  * into $value,$ccal_yr,$cmon,$czday,$ctime;
777  */
778 #line 328 "rsel_load.ec"
779  {
780 #line 329 "rsel_load.ec"
781  static ifx_sqlvar_t _sqobind[] =
782  {
783  { 104, sizeof(value), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
784  { 102, sizeof(ccal_yr), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
785  { 102, sizeof(cmon), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
786  { 102, sizeof(czday), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
787  { 102, sizeof(ctime), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
788 #line 329 "rsel_load.ec"
789  };
790  static ifx_sqlda_t _SD0 = { 5, _sqobind, {0}, 5, 0 };
791  static _FetchSpec _FS1 = { 0, 1, 0 };
792 #line 329 "rsel_load.ec"
793  _sqobind[0].sqldata = (char *) &value;
794 #line 329 "rsel_load.ec"
795  _sqobind[1].sqldata = (char *) &ccal_yr;
796 #line 329 "rsel_load.ec"
797  _sqobind[2].sqldata = (char *) &cmon;
798 #line 329 "rsel_load.ec"
799  _sqobind[3].sqldata = (char *) &czday;
800 #line 329 "rsel_load.ec"
801  _sqobind[4].sqldata = (char *) &ctime;
802  sqli_curs_fetch(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn6, 768), (ifx_sqlda_t *)0, &_SD0, (char *)0, &_FS1);
803 #line 329 "rsel_load.ec"
804  }
805 
806  if(debug)
807  printf("%s %s%s%s%s%s %02d/%02d @ %04d %8.1f "
808  "DC %02d/%02d/%02d @ %04d (%d)\n",
809  id,pe1,pe2,dur,t,src,vmon,vzday,vtime/100,
810  value,cmon,czday,ccal_yr%100,ctime/100,
811  sqlca.sqlcode);
812 
813  if(!sqlca.sqlcode)
814  {
815  /* set creation date/time */
816  if(!strlen(rsel[num_rsels].create))
817  {
818  sprintf(dc,"%02d%02d%02d%02d%02d\0",
819  ccal_yr%100,cmon,czday,
820  ctime/10000,(ctime%10000)/100);
821  strcpy(rsel[num_rsels].create,dc);
822  }
823  if(value < 0.0)
824  {
825  rsel[num_rsels].per[k].amt=9.999;
826  strcpy(rsel[num_rsels].per[k].qual,"M");
827  }
828  else
829  {
830  value=value-1.5;
831  if(value < 0.0) value=0.0;
832  rsel[num_rsels].per[k].amt=value;
833  strcpy(rsel[num_rsels].per[k].qual,"Z");
834  }
835  }
836  k++;
837 /*
838  * $close get_val;
839  */
840 #line 362 "rsel_load.ec"
841  {
842 #line 362 "rsel_load.ec"
843  sqli_curs_close(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn7, 768));
844 #line 362 "rsel_load.ec"
845  }
846 /*
847  * $free get_fval;
848  */
849 #line 362 "rsel_load.ec"
850  {
851 #line 362 "rsel_load.ec"
852  sqli_curs_free(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn6, 770));
853 #line 362 "rsel_load.ec"
854  }
855  }
856  }
857  }
858  }
859  };
860 /*
861  * $close loop_seg_ts;
862  */
863 #line 367 "rsel_load.ec"
864  {
865 #line 367 "rsel_load.ec"
866  sqli_curs_close(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn4, 768));
867 #line 367 "rsel_load.ec"
868  }
869 /*
870  * $free loop_seg_ts;
871  */
872 #line 367 "rsel_load.ec"
873  {
874 #line 367 "rsel_load.ec"
875  sqli_curs_free(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn4, 770));
876 #line 367 "rsel_load.ec"
877  }
878  }
879  };
880 /*
881  * $close loop_seg;
882  */
883 #line 369 "rsel_load.ec"
884  {
885 #line 369 "rsel_load.ec"
886  sqli_curs_close(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn3, 768));
887 #line 369 "rsel_load.ec"
888  }
889 /*
890  * $free loop_seg;
891  */
892 #line 369 "rsel_load.ec"
893  {
894 #line 369 "rsel_load.ec"
895  sqli_curs_free(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn3, 770));
896 #line 369 "rsel_load.ec"
897  }
898  }
899  };
900 /*
901  * $close loop_fg;
902  */
903 #line 371 "rsel_load.ec"
904  {
905 #line 371 "rsel_load.ec"
906  sqli_curs_close(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn2, 768));
907 #line 371 "rsel_load.ec"
908  }
909 /*
910  * $free loop_fg;
911  */
912 #line 371 "rsel_load.ec"
913  {
914 #line 371 "rsel_load.ec"
915  sqli_curs_free(ESQLINTVERSION, sqli_curs_locate(ESQLINTVERSION, _Cn2, 770));
916 #line 371 "rsel_load.ec"
917  }
918 
919 
920  /* change array ptr to total count */
921  num_rsels++;
922  return(num_rsels);
923 }
924 
925 #line 377 "rsel_load.ec"
int adj_time(int adj, int y, int m, int d, int h, int *adj_y, int *adj_m, int *adj_d, int *adj_h)
Definition: adj_time.c:10
static int i
struct sqlca_s sqlca
char qual[10]
Definition: subdisplay.c:33
sprintf(fbuf,"/usr/mapper/nexrad/ngrid.%02d-%02d-%02d-%02d", year, month, day, hour)
printf("fbuf is %s\n", fbuf)
int j
Definition: mapp2h.h:48
int k
Definition: mapp2h.h:48
float value
debug
Definition: hydro_data.h:53
static const char _Cn3[]
Definition: rsel_load.c:7
struct fgroup_info fg[20]
int rsel_load(struct rsel_struct *rsel)
Definition: rsel_load.c:38
static const char _Cn1[]
Definition: rsel_load.c:9
int parm_toggle_item_set
static const char _Cn4[]
Definition: rsel_load.c:6
static const char _Cn2[]
Definition: rsel_load.c:8
int ver_toggle_item_set
static const char _Cn6[]
Definition: rsel_load.c:4
static const char _Cn5[]
Definition: rsel_load.c:5
Widget text_output
int fg_toggle_item_set
static const char _Cn7[]
Definition: rsel_load.c:3
int src_toggle_item_set
int dur_toggle_item_set
struct time_cntl tc
long sqlcode
Definition: db.c:44