Mapper
fma_qtrly.c
Go to the documentation of this file.
1 #include <sqlhdr.h>
2 #include <sqliapi.h>
3 #line 1 "fma_qtrly.ec"
4 #include "prototypes_new.h"
5 /*
6  * EXEC SQL include sqlca.h;
7  */
8 #line 2 "fma_qtrly.ec"
9 
10 #line 2 "fma_qtrly.ec"
11 #line 1 "/opt/informix/incl/esql/sqlca.h"
12 /****************************************************************************
13  *
14  * Licensed Material - Property Of IBM
15  *
16  * "Restricted Materials of IBM"
17  *
18  * IBM Informix Client SDK
19  * Copyright IBM Corporation 1997, 2008. All rights reserved.
20  *
21  * Title: sqlca.h
22  * Description: SQL Control Area
23  *
24  ***************************************************************************
25  */
26 
27 #ifndef SQLCA_INCL
28 #define SQLCA_INCL
29 
30 #include "ifxtypes.h"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 typedef struct sqlca_s
37  {
38  int4 sqlcode;
39 #ifdef DB2CLI
40  char sqlerrm[600]; /* error message parameters */
41 #else /* DB2CLI */
42  char sqlerrm[72]; /* error message parameters */
43 #endif /* DB2CLI */
44  char sqlerrp[8];
45  int4 sqlerrd[6];
46  /* 0 - estimated number of rows returned */
47  /* 1 - serial value after insert or ISAM error code */
48  /* 2 - number of rows processed */
49  /* 3 - estimated cost */
50  /* 4 - offset of the error into the SQL statement */
51  /* 5 - rowid after insert */
52 #ifdef _FGL_
53  char sqlawarn[8];
54 #else
55  struct sqlcaw_s
56  {
57  char sqlwarn0; /* = W if any of sqlwarn[1-7] = W */
58  char sqlwarn1; /* = W if any truncation occurred or
59  database has transactions or
60  no privileges revoked */
61  char sqlwarn2; /* = W if a null value returned or
62  ANSI database */
63  char sqlwarn3; /* = W if no. in select list != no. in into list or
64  turbo backend or no privileges granted */
65  char sqlwarn4; /* = W if no where clause on prepared update, delete or
66  incompatible float format */
67  char sqlwarn5; /* = W if non-ANSI statement */
68  char sqlwarn6; /* = W if server is in data replication secondary mode */
69  char sqlwarn7; /* = W if database locale is different from proc_locale
70  = W if backend XPS and if explain avoid_execute is set
71  (for select, insert, delete and update only)
72  */
73  } sqlwarn;
74 #endif
76 
77 /* NOTE: 4gl assumes that the sqlwarn structure can be defined as
78  * sqlawarn -- an 8 character string, because single-char
79  * variables are not recognized in 4gl.
80  *
81  * If this structure should change, the code generated by 4gl compiler
82  * must also change
83  */
84 
85 #define SQLNOTFOUND 100
86 
87 #ifndef IFX_THREAD
88 #ifdef DB2CLI
89 #define sqlca ifmxsqlca
90 extern struct sqlca_s sqlca;
91 #else /* DB2CLI */
92 extern struct sqlca_s sqlca;
93 #endif /* DB2CLI */
94 
95 #ifndef DRDAHELP
96 extern int4 SQLCODE;
97 #endif
98 
99 extern char SQLSTATE[];
100 #else /* IFX_THREAD */
101 extern int4 * ifx_sqlcode(void);
102 extern struct sqlca_s * ifx_sqlca(void);
103 /* ifx_sqlstate() declared in sqlhdr.h */
104 #define SQLCODE (*(ifx_sqlcode()))
105 #define SQLSTATE ((char *)(ifx_sqlstate()))
106 #define sqlca (*(ifx_sqlca()))
107 #endif /* IFX_THREAD */
108 
109 #ifdef __cplusplus
110 }
111 #endif
112 
113 #endif /* SQLCA_INCL */
114 
115 #line 103 "/opt/informix/incl/esql/sqlca.h"
116 #line 3 "fma_qtrly.ec"
117 
118 /*
119  * EXEC SQL BEGIN DECLARE SECTION;
120  */
121 #line 4 "fma_qtrly.ec"
122 #line 5 "fma_qtrly.ec"
123 int eyr, emo, edy;
124 int byr, bmo, bdy;
125 extern struct fma_qrtly_rec
126  {
127  char id[6];
128  char drain[2];
129  char pos[2];
130  char cgroup[2];
131  char pe1[2];
132  char pe2[2];
133  char dur[2];
134  char t[2];
135  char s[2];
136  char e[2];
137  char p[2];
138  int vcal_yr;
139  int vmon;
140  int vzday;
141  int ccal_yr;
142  int cmon;
143  int czday;
144  int ctime;
145  double z00;
146  double z06;
147  double z12;
148  double z18;
149  char qz00[2];
150  char qz06[2];
151  char qz12[2];
152  char qz18[2];
154 /*
155  * EXEC SQL END DECLARE SECTION;
156  */
157 #line 39 "fma_qtrly.ec"
158 
159 
160 extern struct data_rec {
161  char id[9];
162  char source[9];
163  char pe1;
164  char pe2;
165  char dur;
166  char t;
167  char s;
168  char e;
169  char p;
170  int zdate;
171  int ztime;
172  int czdate;
173  int cztime;
174  int idur;
175  double codp;
176  char lwal;
177  int idote;
178  int irev;
179  double value;
180  double values[96];
181  char lwals[96];
182  char pedtsep[8];
184 
186 
188 
189 int fma_qtrly(char *hb5,char *dparm,char *parm,struct stim begin_date,struct stim
190 end_date, struct stim q_date,struct stn_values *stn_values)
191 
192 {
193 
194 char line[512];
195 
196 int i,jtotal,k,atime,iclear;
197 int etime,btime;
198 int hour,min;
199 int zdate,hh,qlen;
200 time_t tim,tim2;
201 struct tm *gmtim;
202 int fdate;
203 
204 
205 /*
206  * EXEC SQL BEGIN DECLARE SECTION;
207  */
208 #line 86 "fma_qtrly.ec"
209 #line 87 "fma_qtrly.ec"
210 int edate, bdate;
211 int month, day, year;
212  char sparm[10];
213 int fyear, fmonth, fday, fhour, fminute, ftime;
214  char shb5[6];
215  char pe1[2];
216  char pe2[2];
217  char dur[2];
218  char t[2];
219  char s[2];
220  char e[2];
221  char p[2];
222  char drain[2], pos[2], cgroup[2];
223 /*
224  * EXEC SQL END DECLARE SECTION;
225  */
226 #line 101 "fma_qtrly.ec"
227 
228 
229 pe1[1]=0;
230 pe2[1]=0;
231 dur[1]=0;
232 t[1]=0;
233 s[1]=0;
234 e[1]=0;
235 p[1]=0;
236 
237 strcpy(shb5,hb5);
238 
239 pe1[0]=parm[0];
240 pe2[0]=parm[1];
241 dur[0]=parm[2];
242 t[0]=parm[3];
243 s[0]=parm[4];
244 e[0]=parm[5];
245 p[0]=parm[6];
246 
247 eyr=end_date.year;
248 emo=end_date.month;
249 edy=end_date.day;
250 etime=end_date.hour*10000+
251  end_date.minute*100;
252 
253 byr=begin_date.year;
254 bmo=begin_date.month;
255 bdy=begin_date.day;
256 btime=begin_date.hour*10000+
257  begin_date.minute*100;
258 
259 year=byr;
260 month=bmo;
261 day=bdy;
262 
263 fyear=q_date.year;
264 fmonth=q_date.month;
265 fday=q_date.day;
266 fhour=q_date.hour;
267 fminute=q_date.minute;
268 ftime=fhour*10000+fminute*100;
269 
270 jtotal=0;
271 
272 iclear=0;
273 
274 drain[0]=dparm[0];
275 pos[0]=dparm[1];
276 cgroup[0]=dparm[2];
277 
278 drain[1]=0;
279 pos[1]=0;
280 cgroup[1]=0;
281 
282 
283 
284 for(;;) {
285 
286 
287  /* printf("%s %s%s%s%s%s%s%s %s%s%s %d %d %d %d %d %d %d\n",
288  shb5,pe1,pe2,dur,t,s,e,p,drain,pos,cgroup,
289  year,month,day,fyear,fmonth,fday,ftime); */
290 
291 /*
292  * EXEC SQL select *
293  * into :fma_qtrly_rec
294  * from fmaqtrly
295  * where id=:shb5 and
296  * pe1=:pe1 and
297  * pe2=:pe2 and
298  * dur=:dur and
299  * t=:t and
300  * s=:s and
301  * e=:e and
302  * p=:p and
303  * drain=:drain and
304  * pos=:pos and
305  * cgroup=:cgroup and
306  * vcal_yr=:year and
307  * vmon=:month and
308  * vzday=:day and
309  * ccal_yr=:fyear and
310  * cmon=:fmonth and
311  * czday=:fday and
312  * ctime=:ftime;
313  */
314 #line 165 "fma_qtrly.ec"
315  {
316 #line 185 "fma_qtrly.ec"
317  static const char *sqlcmdtxt[] =
318 #line 185 "fma_qtrly.ec"
319  {
320 #line 185 "fma_qtrly.ec"
321  "select * from fmaqtrly where id = ? and pe1 = ? and pe2 = ? and dur = ? and t = ? and s = ? and e = ? and p = ? and drain = ? and pos = ? and cgroup = ? and vcal_yr = ? and vmon = ? and vzday = ? and ccal_yr = ? and cmon = ? and czday = ? and ctime = ?",
322  0
323  };
324 #line 185 "fma_qtrly.ec"
325 static ifx_cursor_t _SQ0 = {0};
326  static ifx_sqlvar_t _sqibind[] =
327  {
328  { 100, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
329  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
330  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
331  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
332  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
333  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
334  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
335  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
336  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
337  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
338  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
339  { 102, sizeof(year), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
340  { 102, sizeof(month), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
341  { 102, sizeof(day), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
342  { 102, sizeof(fyear), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
343  { 102, sizeof(fmonth), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
344  { 102, sizeof(fday), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
345  { 102, sizeof(ftime), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
346 #line 185 "fma_qtrly.ec"
347  };
348  static ifx_sqlvar_t _sqobind[] =
349  {
350  { 100, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
351  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
352  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
353  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
354  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
355  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
356  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
357  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
358  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
359  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
360  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
361  { 102, sizeof((fma_qtrly_rec).vcal_yr), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
362  { 102, sizeof((fma_qtrly_rec).vmon), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
363  { 102, sizeof((fma_qtrly_rec).vzday), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
364  { 102, sizeof((fma_qtrly_rec).ccal_yr), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
365  { 102, sizeof((fma_qtrly_rec).cmon), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
366  { 102, sizeof((fma_qtrly_rec).czday), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
367  { 102, sizeof((fma_qtrly_rec).ctime), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
368  { 105, sizeof((fma_qtrly_rec).z00), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
369  { 105, sizeof((fma_qtrly_rec).z06), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
370  { 105, sizeof((fma_qtrly_rec).z12), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
371  { 105, sizeof((fma_qtrly_rec).z18), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
372  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
373  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
374  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
375  { 100, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
376 #line 185 "fma_qtrly.ec"
377  };
378 #line 185 "fma_qtrly.ec"
379  _sqibind[0].sqldata = shb5;
380 #line 185 "fma_qtrly.ec"
381  _sqibind[1].sqldata = pe1;
382 #line 185 "fma_qtrly.ec"
383  _sqibind[2].sqldata = pe2;
384 #line 185 "fma_qtrly.ec"
385  _sqibind[3].sqldata = dur;
386 #line 185 "fma_qtrly.ec"
387  _sqibind[4].sqldata = t;
388 #line 185 "fma_qtrly.ec"
389  _sqibind[5].sqldata = s;
390 #line 185 "fma_qtrly.ec"
391  _sqibind[6].sqldata = e;
392 #line 185 "fma_qtrly.ec"
393  _sqibind[7].sqldata = p;
394 #line 185 "fma_qtrly.ec"
395  _sqibind[8].sqldata = drain;
396 #line 185 "fma_qtrly.ec"
397  _sqibind[9].sqldata = pos;
398 #line 185 "fma_qtrly.ec"
399  _sqibind[10].sqldata = cgroup;
400 #line 185 "fma_qtrly.ec"
401  _sqibind[11].sqldata = (char *) &year;
402 #line 185 "fma_qtrly.ec"
403  _sqibind[12].sqldata = (char *) &month;
404 #line 185 "fma_qtrly.ec"
405  _sqibind[13].sqldata = (char *) &day;
406 #line 185 "fma_qtrly.ec"
407  _sqibind[14].sqldata = (char *) &fyear;
408 #line 185 "fma_qtrly.ec"
409  _sqibind[15].sqldata = (char *) &fmonth;
410 #line 185 "fma_qtrly.ec"
411  _sqibind[16].sqldata = (char *) &fday;
412 #line 185 "fma_qtrly.ec"
413  _sqibind[17].sqldata = (char *) &ftime;
414 #line 185 "fma_qtrly.ec"
415  _sqobind[0].sqldata = (fma_qtrly_rec).id;
416 #line 185 "fma_qtrly.ec"
417  _sqobind[1].sqldata = (fma_qtrly_rec).drain;
418 #line 185 "fma_qtrly.ec"
419  _sqobind[2].sqldata = (fma_qtrly_rec).pos;
420 #line 185 "fma_qtrly.ec"
421  _sqobind[3].sqldata = (fma_qtrly_rec).cgroup;
422 #line 185 "fma_qtrly.ec"
423  _sqobind[4].sqldata = (fma_qtrly_rec).pe1;
424 #line 185 "fma_qtrly.ec"
425  _sqobind[5].sqldata = (fma_qtrly_rec).pe2;
426 #line 185 "fma_qtrly.ec"
427  _sqobind[6].sqldata = (fma_qtrly_rec).dur;
428 #line 185 "fma_qtrly.ec"
429  _sqobind[7].sqldata = (fma_qtrly_rec).t;
430 #line 185 "fma_qtrly.ec"
431  _sqobind[8].sqldata = (fma_qtrly_rec).s;
432 #line 185 "fma_qtrly.ec"
433  _sqobind[9].sqldata = (fma_qtrly_rec).e;
434 #line 185 "fma_qtrly.ec"
435  _sqobind[10].sqldata = (fma_qtrly_rec).p;
436 #line 185 "fma_qtrly.ec"
437  _sqobind[11].sqldata = (char *) &(fma_qtrly_rec).vcal_yr;
438 #line 185 "fma_qtrly.ec"
439  _sqobind[12].sqldata = (char *) &(fma_qtrly_rec).vmon;
440 #line 185 "fma_qtrly.ec"
441  _sqobind[13].sqldata = (char *) &(fma_qtrly_rec).vzday;
442 #line 185 "fma_qtrly.ec"
443  _sqobind[14].sqldata = (char *) &(fma_qtrly_rec).ccal_yr;
444 #line 185 "fma_qtrly.ec"
445  _sqobind[15].sqldata = (char *) &(fma_qtrly_rec).cmon;
446 #line 185 "fma_qtrly.ec"
447  _sqobind[16].sqldata = (char *) &(fma_qtrly_rec).czday;
448 #line 185 "fma_qtrly.ec"
449  _sqobind[17].sqldata = (char *) &(fma_qtrly_rec).ctime;
450 #line 185 "fma_qtrly.ec"
451  _sqobind[18].sqldata = (char *) &(fma_qtrly_rec).z00;
452 #line 185 "fma_qtrly.ec"
453  _sqobind[19].sqldata = (char *) &(fma_qtrly_rec).z06;
454 #line 185 "fma_qtrly.ec"
455  _sqobind[20].sqldata = (char *) &(fma_qtrly_rec).z12;
456 #line 185 "fma_qtrly.ec"
457  _sqobind[21].sqldata = (char *) &(fma_qtrly_rec).z18;
458 #line 185 "fma_qtrly.ec"
459  _sqobind[22].sqldata = (fma_qtrly_rec).qz00;
460 #line 185 "fma_qtrly.ec"
461  _sqobind[23].sqldata = (fma_qtrly_rec).qz06;
462 #line 185 "fma_qtrly.ec"
463  _sqobind[24].sqldata = (fma_qtrly_rec).qz12;
464 #line 185 "fma_qtrly.ec"
465  _sqobind[25].sqldata = (fma_qtrly_rec).qz18;
466 #line 185 "fma_qtrly.ec"
467  sqli_slct(ESQLINTVERSION, &_SQ0,sqlcmdtxt,18,_sqibind,26,_sqobind,0,(ifx_literal_t *)0,(ifx_namelist_t *)0,0);
468 #line 185 "fma_qtrly.ec"
469  }
470 
471  if(sqlca.sqlcode < 0) {
472 
473  printf("sql error %d\n",sqlca.sqlcode);
474 
475  return(sqlca.sqlcode);
476 
477  }
478 
479 
480 /* printf("ier is %d\n", sqlca.sqlcode ); */
481 
482  if(sqlca.sqlcode==100) {
483 
484 
485 
486  iclear++;
487  change_dateffmaq(&fyear,&fmonth,&fday,&ftime);
488 
489  if(iclear==17) {
490 
491  fyear=q_date.year;
492  fmonth=q_date.month;
493  fday=q_date.day;
494  fhour=q_date.hour;
495  fminute=q_date.minute;
496  ftime=fhour*10000+fminute*100;
497 
498 
499  if(year==eyr && month==emo && day==edy)
500  break;
501 
503 
504  iclear=0;
505 
506  }
507 
508  continue;
509 
510 
511  }
512 
513 
514  if(sqlca.sqlcode == 0) {
515 
516  iclear=0;
517 
518  get_fma06_array();
519 
520 /* sprintf(line,"echo %d %d %d",fma_qtrly_rec.vmon,fma_qtrly_rec.vzday,fma_qtrly_rec.vcal_yr);
521  system(line);*/
522 
523  for(k=3;k>=0;k--) {
524 
525  hour=k;
526  atime=hour*60000;
527 
530 
531  if(year==eyr && month==emo && day==edy &&
532  atime < etime)
533  break;
534 
535  if(year==byr && month==bmo && day==bdy &&
536  atime > btime)
537  continue;
538 
539  if(data_record.values[k] < -98)
540  continue;
541 
543  stn_values[jtotal].zdate=zdate;
544  stn_values[jtotal].cdate=fdate;
545  stn_values[jtotal].qual= data_record.lwals[k];
546 
547  stn_values[jtotal].ctime=ftime;
548  stn_values[jtotal++].ztime=atime;
549 
550  }
551 
552 
553  }
554 
555  if(jtotal > 9600)
556  break;
557 
558  if(year==eyr && month==emo && day==edy)
559  break;
560 
562 
563 
564  }
565 
566 return(jtotal);
567 
568 }
569 
571 {
572 
581 
582  return(0);
583 }
584 void change_datefmaq(int *year,int *month, int*day)
585 
586 {
587 
588 extern int mday[];
589 char buf[10];
590 XmString btn_text;
591 Arg args[10];
592 
593 if (!((*year)%4))
594  mday[1]=29;
595 else
596  mday[1]=28;
597 
598 /*
599 if ((*year)==1972 || (*year)==1976 || (*year)==1980 ||
600  (*year)==1984 || (*year)==1988 || (*year)==1992 ||
601  (*year)==1996 || (*year)==2000 || (*year)==2004 ||
602  (*year)==2008 || (*year)==2012 || (*year)==2016)
603  mday[1]=29;
604 else
605  mday[1]=28;
606 */
607 
608 (*day)--;
609 
610 if(*day <= 0) {
611 
612  (*month)--;
613  if(*month==0) {
614 
615  (*year)--;
616  *month=12;
617 
618  }
619 
620  *day=mday[*month-1];
621 
622  }
623 
624 else if(*day > mday[*month-1]) {
625 
626  *(month)++;
627 
628  if(*month > 12) {
629 
630  (*year)++;
631  *month=1;
632 
633  }
634 
635  *day=1;
636 
637  }
638 
639 
640 }
641 
642 void change_dateffmaq(int *year,int *month, int *day,int *ztime)
643 
644 {
645 
646 extern int mday[];
647 char buf[10];
648 
649 if (!((*year)%4))
650  mday[1]=29;
651 else
652  mday[1]=28;
653 
654 /*
655 if ((*year)==1972 || (*year)==1976 || (*year)==1980 ||
656  (*year)==1984 || (*year)==1988 || (*year)==1992 ||
657  (*year)==1996 || (*year)==2000 || (*year)==2004 ||
658  (*year)==2008 || (*year)==2012 || (*year)==2016)
659  mday[1]=29;
660 else
661  mday[1]=28;
662 */
663 
664 *ztime=*ztime-10000;
665 
666 if(*ztime < 0) {
667 
668  *ztime=230000;
669  (*day)--;
670 
671  }
672 
673 if(*day <= 0) {
674 
675  (*month)--;
676  if(*month==0) {
677 
678  (*year)--;
679  *month=12;
680 
681  }
682 
683  *day=mday[*month-1];
684 
685  }
686 
687 else if(*day > mday[*month-1]) {
688 
689  *(month)++;
690 
691  if(*month > 12) {
692 
693  (*year)++;
694  *month=1;
695 
696  }
697 
698  *day=1;
699 
700  }
701 
702 
703 return;
704 
705 }
706 
707 
708 #line 422 "fma_qtrly.ec"
static int i
int hour
Definition: display_data.c:26
int day
Definition: display_data.c:26
int year
Definition: display_data.c:26
int month
Definition: display_data.c:26
int get_fma06_array()
Definition: fma_qtrly.c:570
int emo
Definition: fma_qtrly.c:123
struct data_rec data_record
int bdy
Definition: fma_qtrly.c:124
int eyr
Definition: fma_qtrly.c:123
int edy
Definition: fma_qtrly.c:123
int bmo
Definition: fma_qtrly.c:124
struct fma_qrtly_rec fma_qtrly_rec
int fma_qtrly(char *hb5, char *dparm, char *parm, struct stim begin_date, struct stim end_date, struct stim q_date, struct stn_values *stn_values)
Definition: fma_qtrly.c:189
int4 SQLCODE
struct sqlca_s ifx_sqlca_t
char SQLSTATE[]
struct sqlca_s sqlca
int byr
Definition: fma_qtrly.c:124
void change_dateffmaq()
void change_datefmaq()
int mday[]
Definition: fmap_qtrly.c:519
struct stat buf
Definition: is_file_closed.c:8
printf("fbuf is %s\n", fbuf)
int k
Definition: mapp2h.h:48
Arg args[10]
char source[9]
Definition: calfma_qtrly.c:162
double values[96]
Definition: calfma_qtrly.c:180
char lwals[96]
Definition: calfma_qtrly.c:181
char pedtsep[8]
Definition: calfma_qtrly.c:182
double codp
Definition: calfma_qtrly.c:175
double value
Definition: calfma_qtrly.c:179
char cgroup[2]
Definition: calfma_qtrly.c:130
char sqlwarn5
Definition: db.c:65
char sqlwarn3
Definition: db.c:61
char sqlwarn4
Definition: db.c:63
char sqlwarn7
Definition: db.c:67
char sqlwarn1
Definition: db.c:57
char sqlwarn6
Definition: db.c:66
char sqlwarn2
Definition: db.c:59
char sqlwarn0
Definition: db.c:56
Definition: db.c:43
long sqlerrd[6]
Definition: db.c:47
struct sqlca_s::sqlcaw_s sqlwarn
long sqlcode
Definition: db.c:44
char sqlerrm[72]
Definition: db.c:45
char sqlerrp[8]
Definition: db.c:46
Definition: misc.h:93
int minute
Definition: misc.h:99
int day
Definition: misc.h:97
int year
Definition: misc.h:95
int hour
Definition: misc.h:98
int month
Definition: misc.h:96
char qual
Definition: hydro_data.h:36
int ctime
Definition: misc_new.h:199
int cdate
Definition: misc_new.h:198
float value
Definition: hydro_data.h:35
tim()
Definition: tim.c:4