Mapper
shdece.c
Go to the documentation of this file.
1 /*Translated by FOR_C, v3.4.2 (-), on 04/06/95 at 20:26:05 */
2 /*FOR_C Options SET: c=2 com=u do=r4 ftn=2ln6kk op=iv s=dvn str=l sq=i */
3 
4 #define _POSIX_SOURCE
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <ctype.h>
8 #include <dirent.h>
9 #include <unistd.h>
10 #include <math.h>
11 #include <string.h>
12 #include <fcntl.h>
13 #include <sys/stat.h>
14 #include "shef_structs_external.h"
15 
16 /*---------------------------------------------------------------------
17 
18  NAME
19  SUBROUTINE SHDECE(IREV,STATUS)
20 
21  PURPOSE
22  Decode .E Format
23  IREV = 1 FOR REVISED, = 0 FOR NEW DATA
24 
25  VERSION and UPDATES
26  1.0 UGR 82 Geoffrey M. Bonnin
27  Original Version
28  1.1 JAN 84
29  Improve testing for bad dates on date
30  Relative Adjustment
31  1.2 AUG 84
32  Change test for creation data to non-fatal
33  Allow negative DI increments
34  Add seconds to times
35  1.3 MAR 86
36  Fix error in subsequent revision continuation
37  2.0 JUN 94 David G. Brandon
38  Include NSFLAG for selected send codes
39  Also Translated to 'C' using FOR_C
40  Removed alternate returns in subroutines
41  2.1 Add iscore to t_codes array.
42  2.3 NOV 95 DGB
43  Add check to place n1 and k1 in correct century.
44  Allow for all valid qualifier codes excepting
45  for 'O' and 'I'.
46  2.4 DEC 95 DGB
47  Do not process DC when they are missing, or the month
48  k2 is set to 0
49  2.5 JAN 96 DGB
50  Update struct t_data to include lcent
51  and kcent for century.
52  Modify code to print out correct century in shefout
53  and shefpass.
54  2.6 SEP 10 97 DGB
55  Add the use of MAX_SHEF_INPUT so that the input line can
56  be longer than 80 characters.
57  Add capability to output a database comment.
58  2.7 OCT 30 97 DGB
59  Fix time problem for .E messages like the one
60  that follows:
61 
62  .E XXXXX 971020 DH12/HG/DI6
63  .E1 / 12.2
64  Messages that had a leading '/' were setting the
65  initial time incorrectly.
66  2.8 DEC 1 97 DGB
67  Include advanced test flag option. This will print
68  a shefout record to the error file.
69  2.5 JAN 25 98 DGB
70  Fix increments of NULL values in .E type messages.
71  These messages are flagged with *flag = 3.
72  Previously, the NULL would be read, but the time
73  would not be incremented. Also, leading slashes
74  on .E continuation lines caused some problems.
75  Add capabilities for preprocessing .E lines.
76  Preprocessing consists of detecting NULL fields,
77  i.e., a slash followed by another slash or blanks
78  then a slash. { e.g. 12.2 / / 4 }. Also,
79  leading slash marks on continuation lines are
80  replaced by a blank. See function pre_process_dote()
81  at the end of the function, shdece.
82  2.6 SEP 15 98 DGB
83  Change pre_process_dote to handle a NULL
84  at the end of a line, e.g.,
85  { before} .E1 / N / N / N /
86  { after} .E1 / N / N / N / N
87  2.7 OCT 5 98 DGB
88  Change placement of null_it inpre_process_dote.
89  2.8 JAN 18 99 DGB
90  Check/compute correct century/year if override
91  is specified.
92  2.9 FEB 15 2002 DGB
93  Make software recognize more than a single digit
94  for a continuation line...e.g., .E1 would work
95  but .E11 would not. Now it will.
96  3.0 AUG 29 02 DGB
97  Check for hour specified as '24' and change to '00'
98 
99  *--------------------------------------------------------------------- */
100 
101 void shdece(irev, status)
102 short int *irev, *status;
103 {
104 
105  int DEBUG1;
106  int itest;
107  static short int iadj, idote, idur, iend_, intval,
108  iunit, ival, k1, k2, k3, k4, k5, k6, lwal,
109  n1, n2, n3, n4, n5, n6, ndig, nflag, null_,
110  num, flag,
111  n11 ; /* dgb cent */
112 
113  static double factor;
114 
115  /* OFFSET Vectors w/subscript range: 1 to dimension */
116  short *const Idate = &datim_.idate[0] - 1; /* dgb:01/01/96 */
117  short *const Ibuf = &buffer_.ibuf[0] - 1;
118  short *const Idstn = &data_.idstn[0] - 1;
119  short *const Msource = &data_.msource[0] - 1;
120 
121  data_.overmonth = -1; /* dgb:01/18/99 */
122  data_.overyear = -1; /* dgb:01/18/99 */
123  data_.overcentury = -1; /* dgb:01/18/99 */
124 
125  DEBUG1 = 0;
126  if ( DEBUG1 ) printf("\nshdece:******************************begin");
127  /* Initialise */
128  *status = 0;
129  Msource[1] = codes_.iblnk;
130  Msource[2] = codes_.iblnk;
131  Msource[3] = codes_.iblnk;
132  Msource[4] = codes_.iblnk;
133  Msource[5] = codes_.iblnk;
134  Msource[6] = codes_.iblnk;
135  Msource[7] = codes_.iblnk;
136  Msource[8] = codes_.iblnk;
137 
138  /* Check for Continuation */
139  if ( DEBUG1 ) printf("\nshdece:format_.iform = format_.iform %d",format_.iform);
140  if( format_.iform > 0 )
141  goto L_10;
143  if( (format_.lform != 5) && (format_.lform != 6) )
144  goto L_9020;
145  if( (format_.iform == 6) && (format_.lform == 5) )
146  goto L_9030;
147  if( (format_.iform == 5) && (format_.lform == 6) )
148  *irev = 1;
149  if( (format_.iform == 5) && (format_.lform == 6) )
150  format_.iform = 6;
151  if( format_.nerr > 0 )
152  goto L_9040;
153  goto L_21;
154 
155  /* Defaults */
156 
157 L_10:
158  if ( DEBUG1 ) printf("\nshdece:at L_10");
159  /* get default century */
160  data_.lcent = 0; /* dgb:01/10/97 */
161  data_.kyear = 0;
162  data_.kmon = 0;
163  data_.kday = 0;
164  data_.khour = 0;
165  data_.kmin = 0;
166  data_.ksec = 0;
167  data_.kwal = codes_.ichz;
168  data_.kodu = 1;
169  datrel_.mcent = 0; /* dgb cent */
170  datrel_.myear = 0;
171  datrel_.mmon = 0;
172  datrel_.mday = 0;
173  datrel_.mhour = 0;
174  datrel_.mmin = 0;
175  datrel_.msec = 0;
176  datrel_.mend = 0;
177  data_.idcodd = 5000;
178  data_.itz = -9999;
179  data_.kflag = 0;
180  format_.nerr = 0;
181  dotee_.inul = 0;
182 
183  /* Get the Positional Data */
184 
185  if ( DEBUG1 ) printf("\nshdece:getting positional data");
186  shpos( status );
187  if( *status == 1 )
188  {
189  *status = 0;
190  goto L_9050;
191  }
192  else if( *status == 2 )
193  {
194  *status = 0;
195  goto L_9010;
196  }
197  goto L_30;
198 
199  /* Check for a NULL */
200 
201 L_21:
202  if ( DEBUG1 ) printf("\nshdece:at L_21 dotee_.inul = %d",dotee_.inul);
203  if( dotee_.inul == 0 )
204  goto L_30;
205  goto L_25;
206 
207 L_24:
208  if ( DEBUG1 ) printf("\nshdece:at L_24");
209  nextch( &xchar_.ichar, status );
210  if( *status == 1 )
211  {
212  *status = 0;
213  goto L_170;
214  }
215  else if( *status == 2 )
216  {
217  *status = 0;
218  goto L_9010;
219  }
220 L_25:
221  if ( DEBUG1 ) printf("\nshdece:at L_25");
222  if( xchar_.ichar == codes_.iblnk )
223  goto L_24;
224  if( xchar_.ichar != codes_.islash )
225  goto L_30;
226  null_ = 1;
227  goto L_100;
228 
229  /* Get the data and data type elements */
230 
231 L_30:
232  if ( DEBUG1 ) printf("\nshdece:at L_30 dtype_.ieee = %d",dtype_.ieee);
233  dtype_.ieee = 0;
234  flag = 3;
235  shdtype( &flag, status );
236 
237  if ( DEBUG1 ) printf("\nshdece:return status from shdtype = %d",*status);
238 
239  if( *status == 1 )
240  {
241  *status = 0;
242  goto L_9000;
243  }
244  else if( *status == 2 )
245  {
246  *status = 0;
247  goto L_9010;
248  }
249  else if( *status == 3 )
250  {
251  *status = 0;
252  goto L_165;
253  }
254  if ( DEBUG1 ) printf("\nshdece:dtype_.ieee = %d data_.kflag=%d",dtype_.ieee,data_.kflag);
255 
256  if( (dtype_.ieee == 1) && (data_.kflag > 0) )
257  data_.kflag = 1;
258  if( data_.kflag != 0 )
259  goto L_45;
260  if ( DEBUG1 ) printf("\nshdece:dtype_.ieee = %d data_.kflag=%d",dtype_.ieee,data_.kflag);
261 
262  /* Get the Parameter Code */
263  if ( DEBUG1 ) printf("\nshdece:calling shpcode");
264 
266  &data_.kods, &data_.kodex, &data_.codp, &factor, status );
267 
268  if ( DEBUG1 ) printf("\nshdece:status from shdtype = %d",*status);
269  if( *status == 1 )
270  {
271  *status = 0;
272  goto L_170;
273  }
274  else if( *status == 2 )
275  {
276  *status = 0;
277  goto L_9010;
278  }
279  else if( *status == 3 )
280  {
281  *status = 0;
282  goto L_170;
283  }
284 
285  if( buffer_.ip > MAX_SHEF_INPUT ) /* dgb:09/10/97 */
286  goto L_48;
287  data_.kflag = 1;
288  if( xchar_.ichar == codes_.iblnk )
289  goto L_30;
290  if( xchar_.ichar == codes_.islash )
291  goto L_30;
292  goto L_9130;
293 
294  /* Get the Value */
295 
296 L_45:
297  if ( DEBUG1 ) printf("\nshdece:calling shreal iend_ = %d",iend_);
298  flag = 0;
299  shreal( &data_.value, &flag, &ndig, status );
300  if( *status == 1 )
301  {
302  *status = 0;
303  goto L_47;
304  }
305  else if( *status == 2 )
306  {
307  *status = 0;
308  goto L_9010;
309  }
310  iend_ = 0;
311  goto L_48;
312 L_47:
313  if ( DEBUG1 ) printf("\nshdece:at L_47");
314  iend_ = 1;
315 L_48:
316  if ( DEBUG1 )
317  printf("\nshdece:at L_48 data_.kflag = %d ndig = %d iend_ = %d",data_.kflag,ndig,iend_);
318  null_ = 0;
319 
320  if( ndig > 0 )
321  goto L_49;
322  if( (ndig == 0) && (iend_ == 0) )
323  goto L_9110;
324  if( (ndig == 0) && (iend_ == 1) )
325  goto L_9000;
326  if( dotee_.inul == 1 )
327  null_ = 1;
328  goto L_100;
329 
330  /* Test if Creation date specified for forecast data */
331 
332 L_49:
333  if ( DEBUG1 ) printf("\nshdece:at 49");
334  if( (data_.kodt == codes_.ichf) && (data_.kmon == 0) )
335  {
336  flag = 23;
337  sherr( &flag );
338  }
339 
340  /* Test for 7AM Prev day */
341 
342  if( sendflg_.nsflag == 1 )
343  goto L_9120; /*dgb: Check selected send codes */
344 
345  /* Test for correct duration */
346 
347  if( (data_.icodd == 5003) && (data_.idcodd == 5000) )
348  goto L_9080;
349  idur = data_.icodd;
350  if( data_.icodd == 5003 )
351  idur = data_.idcodd;
352 
353  /* Adjust for trace */
354 
355  if( data_.value >= -8e10 )
356  goto L_50;
357  if( data_.kodp != codes_.ichp )
358  goto L_491;
359  if( data_.kode == codes_.ichc )
360  goto L_495;
361  if( data_.kode == codes_.ichp )
362  goto L_495;
363  goto L_9090;
364 
365 L_491:
366  if ( DEBUG1 ) printf("\nshdece:at 491");
367  if( data_.kodp != codes_.ichs )
368  goto L_9090;
369  if( data_.kode == codes_.ichd )
370  goto L_495;
371  if( data_.kode == codes_.ichf )
372  goto L_495;
373  if( data_.kode == codes_.ichw )
374  goto L_495;
375  goto L_9090;
376 
377 L_495:
378  if ( DEBUG1 ) printf("\nshdece:at 495");
379  data_.value = 0.001e0;
380  goto L_60;
381 
382  /* Convert SI to englist units if necessary */
383 
384 L_50:
385  if ( DEBUG1 ) printf("\nshdece:at 50 data_.kflag=%d",data_.kflag);
386  if( data_.kodu == 1 )
387  goto L_60;
388  ival = data_.value - 0.01;
389  if( ival == -9999 )
390  goto L_60;
391  if( ival == -9002 )
392  goto L_60;
393  if( factor < 0e0 )
394  data_.value = data_.value*1.8e0 + 32e0;
395  if( factor > 0e0 )
396  data_.value = data_.value*factor;
397 
398  /* Test the qualifier - it should be in ICHAR already */
399 
400 L_60:
401  if ( DEBUG1 ) printf("\nshdece:at 60 iend_ = %d",iend_);
402  if( iend_ == 1 )
403  goto L_65;
404 
405  /* pass all alphabetical characters except 'O' and 'I' dgb:11/13/95 */
406  irang(&xchar_.ichar,&codes_.icha,&codes_.ichz,status);
407  if ( !*status )
408  {
409  if ( xchar_.ichar == codes_.icho ) goto L_9130;
410  if ( xchar_.ichar == codes_.ichi ) goto L_9130;
411  *status = 0;
412  goto L_70;
413  }
414 
415  if( xchar_.ichar == codes_.iblnk )
416  goto L_65;
417  if( xchar_.ichar == codes_.islash )
418  goto L_65;
419  goto L_9130;
420 
421 L_65:
422  if ( DEBUG1 ) printf("\nshdece:at 65");
423  lwal = data_.kwal;
424  nflag = 0;
425  goto L_100;
426 
427 L_70:
428  if ( DEBUG1 ) printf("\nshdece:at 70");
429  lwal = xchar_.ichar;
430  nflag = 1;
431 
432  /* Do the date relative and time increment calculations
433  * Get the time increment value and units */
434 
435 L_100:
436  if ( DEBUG1 ) printf("\nshdece:at 100 ");
437  if( data_.itz == -9999 )
438  goto L_9100;
439  iunit = (data_.itz + 99)/1000 + 1;
440  intval = data_.itz - (iunit - 1)*1000;
441  if ( DEBUG1 ) printf("\nshdece: data_.kflag = %d iunit = %d intval = %d",data_.kflag,iunit,intval);
442 
443  /* Adjust KFLAG and set up the time variables
444  * 1 = NOT YET STARTED A TIME SERIES
445  * 2 = WITHIN A TIME SERIES
446  * 3 = FIRST ELEMENT OF A TIME SERIES */
447 
448 
449  if( data_.kflag == 3 )
450  data_.kflag = 2;
451  if( data_.kflag == 2 )
452  goto L_105;
453  if( data_.kflag == 1 )
454  idote = 1;
455  if( data_.kflag == 1 )
456  data_.kflag = 3;
457 
458  if ( DEBUG1 ) printf("\nshdece:data_.kflag = %d",data_.kflag);
459  dotee_.ncent = data_.lcent; /* dgb cent */
461  dotee_.nmon = data_.lmon;
462  dotee_.nday = data_.lday;
464  dotee_.nmin = data_.lmin;
465  dotee_.nsec = data_.lsec;
466 
467  /* Adjust the forecast date to ZULU */
468 
469 L_105:
470  if ( DEBUG1 ) printf("\nshdece:at 105");
471  k1 = data_.kyear;
472  k2 = data_.kmon;
473  k3 = data_.kday;
474  k4 = data_.khour;
475  k5 = data_.kmin;
476  k6 = data_.ksec;
477  if( data_.kmon == 0 )
478  goto L_110;
479  iadj = 0;
480  shlocl( &k1, &k2, &k3, &k4, &k5, &k6, &data_.nadjtz, &iadj, status );
481  if( *status == 1 )
482  {
483  *status = 0;
484  goto L_9000;
485  }
486  flag = 1;
487  shtadj( &k1, &k2, &k3, &k4, &k5, &k6, &iadj, &flag, status );
488  if( *status == 1 )
489  {
490  *status = 0;
491  goto L_9000;
492  }
493 
494  /* Do the date relative adjustment for year, month
495  * and day (LOCAL TIME) if necessary */
496 
497 
498 L_110:
499  if ( DEBUG1 ) printf("\nshdece:at 110 data_.kflag = %d",data_.kflag);
500  if( data_.kflag == 2 )
501  goto L_130;
502  if( ((datrel_.myear == 0) && (datrel_.mmon == 0)) && (datrel_.mday ==
503  0) )
504  goto L_120;
505 
506  flag = 3;
508  &dotee_.nmin, &dotee_.nsec, &datrel_.mday, &flag, status );
509  if( *status == 1 )
510  {
511  *status = 0;
512  goto L_9000;
513  }
514  flag = 4;
516  &dotee_.nmin, &dotee_.nsec, &datrel_.mmon, &flag, status );
517  if( *status == 1 )
518  {
519  *status = 0;
520  goto L_9000;
521  }
522  flag = 5;
524  &dotee_.nmin, &dotee_.nsec, &datrel_.myear, &flag, status );
525  if( *status == 1 )
526  {
527  *status = 0;
528  goto L_9000;
529  }
530  flag = 6;
532  &dotee_.nmin, &dotee_.nsec, &datrel_.mend, &flag, status );
533  if( *status == 1 )
534  {
535  *status = 0;
536  goto L_9000;
537  }
538  shtdat( &dotee_.nyear, &dotee_.nmon, &dotee_.nday, status );
539  if( *status == 1 )
540  {
541  *status = 0;
542  goto L_9070;
543  }
544 
545  /* Convert to ZULU if necessary
546  * - DIHXX, DINXX OR DISXX */
547 
548  if( (iunit >= 3 && iunit != 7) || (data_.nadjtz >= 0) )
549  goto L_130;
550  iadj = 0;
551 
553  &dotee_.nmin, &dotee_.nsec, &data_.nadjtz, &iadj, status );
554  if( *status == 1 )
555  {
556  *status = 0;
557  goto L_9000;
558  }
559  flag = 1;
561  &dotee_.nmin, &dotee_.nsec, &iadj, &flag, status );
562  if( *status == 1 )
563  {
564  *status = 0;
565  goto L_9000;
566  }
567  goto L_130;
568 
569  /* Do the date relative adjustment for hour and minute
570  * (ZULU TIME) if necessary */
571 
572 L_120:
573  if ( DEBUG1 ) printf("\nshdece:at 120");
574  if( ((datrel_.mhour == 0) && (datrel_.mmin == 0)) && (datrel_.msec ==
575  0) )
576  goto L_125;
577  iadj = 0;
578 
580  &dotee_.nmin, &dotee_.nsec, &data_.nadjtz, &iadj, status );
581  if( *status == 1 )
582  {
583  *status = 0;
584  goto L_9000;
585  }
586  flag = 1;
588  &dotee_.nmin, &dotee_.nsec, &iadj, &flag, status );
589  if( *status == 1 )
590  {
591  *status = 0;
592  goto L_9000;
593  }
594  flag = 7;
596  &dotee_.nmin, &dotee_.nsec, &datrel_.msec, &flag, status );
597  if( *status == 1 )
598  {
599  *status = 0;
600  goto L_9000;
601  }
602  flag = 1;
604  &dotee_.nmin, &dotee_.nsec, &datrel_.mmin, &flag, status );
605  if( *status == 1 )
606  {
607  *status = 0;
608  goto L_9000;
609  }
610  flag = 2;
612  &dotee_.nmin, &dotee_.nsec, &datrel_.mhour, &flag, status );
613  if( *status == 1 )
614  {
615  *status = 0;
616  goto L_9000;
617  }
618 
619  /* Convert back to local time if necessary
620  * DIYXX,DIMXX,DIDXX,DIEXX */
621 
622  if( (iunit < 3 || iunit == 7) && (data_.nadjtz <= 0) )
623  goto L_130;
624  iadj = 1;
626  &dotee_.nmin, &dotee_.nsec, &data_.nadjtz, &iadj, status );
627  if( *status == 1 )
628  {
629  *status = 0;
630  goto L_9000;
631  }
632  iadj = -iadj;
633  flag = 1;
635  &dotee_.nmin, &dotee_.nsec, &iadj, &flag, status );
636  if( *status == 1 )
637  {
638  *status = 0;
639  goto L_9000;
640  }
641  goto L_130;
642 
643  /* No date relatives, make sure the time zone is correct */
644 
645 L_125:
646  if ( DEBUG1 ) printf("\nshdece:at 125");
647  if( (iunit >= 3 && iunit != 7) || (data_.nadjtz >= 0) )
648  goto L_130;
649  iadj = 0;
651  &dotee_.nmin, &dotee_.nsec, &data_.nadjtz, &iadj, status );
652  if( *status == 1 )
653  {
654  *status = 0;
655  goto L_9000;
656  }
657  flag = 1;
659  &dotee_.nmin, &dotee_.nsec, &iadj, &flag, status );
660  if( *status == 1 )
661  {
662  *status = 0;
663  goto L_9000;
664  }
665 
666  /* Now do the time increment
667  * - we should be in the correct time zone at this stage */
668 
669 L_130:
670  if ( DEBUG1 ) printf("\nshdece:at 130 increment data_.kflag = %d",data_.kflag);
671 
672  if( data_.kflag != 2 )
673  goto L_135;
674  idote = 2;
675  if ( DEBUG1 ) printf("\nshdece:before %d %d %d %d %d %d intval=%d iunit=%d",
677  dotee_.nmin, dotee_.nsec, intval, iunit );
678 
680  &dotee_.nmin, &dotee_.nsec, &intval, &iunit, status );
681 
682  if ( DEBUG1 ) printf("\nshdece:before %d %d %d %d %d %d intval=%d iunit=%d",
684  dotee_.nmin, dotee_.nsec, intval, iunit );
685 
686  if( *status == 1 )
687  {
688  *status = 0;
689  goto L_9000;
690  }
691 
692  /* If this is a NULL bypass the rest */
693 
694 L_135:
695  if ( DEBUG1 ) printf("\nshdece:at 135 null_ = %d",null_);
696  if( null_ == 1 )
697  goto L_160;
698 
699  /* Adjust to ZULU for output if necessary */
700 
701  n11= dotee_.ncent; /* dgb cent */
702  n1 = dotee_.nyear;
703  n2 = dotee_.nmon;
704  n3 = dotee_.nday;
705  n4 = dotee_.nhour;
706  n5 = dotee_.nmin;
707  n6 = dotee_.nsec;
708  if( (iunit < 3 || iunit == 7) && (data_.nadjtz <= 0) )
709  goto L_140;
710  iadj = 0;
711 
712  shlocl( &n1, &n2, &n3, &n4, &n5, &n6, &data_.nadjtz, &iadj, status );
713  if( *status == 1 )
714  {
715  *status = 0;
716  goto L_9000;
717  }
718  flag = 1;
719  shtadj( &n1, &n2, &n3, &n4, &n5, &n6, &iadj, &flag, status );
720  if( *status == 1 )
721  {
722  *status = 0;
723  goto L_9000;
724  }
725 
726  /* Test that the date is OK */
727 
728 L_140:
729  shtdat( &n1, &n2, &n3, status );
730  if( *status == 1 )
731  {
732  *status = 0;
733  goto L_9070;
734  }
735 
736  if ( data_.overyear > -1 && data_.overcentury == -1 ) /* dgb:01/18/99 */
737  if ( data_.overyear > 30 ) n1 = data_.overyear + 1900;
738  else
739  if ( data_.overcentury > -1 && data_.overyear > -1 )
740  n1 = (data_.overcentury * 100) + data_.overyear; /* dgb:01/18/99 */
741 
742 
743  if ( data_.overmonth > -1 && data_.overyear == -1 ) /* dgb:01/18/99 */
744  {
745  itest = n2 - Idate[1];
746  if ( itest > 6 ) n1--;
747  if ( itest < -6 ) n1++;
748  if ( (itest == -6 ) & ( n3 < Idate[2] ) )
749  n1++;
750  if ( (itest == 6 ) && ( n3 > Idate[2] ) )
751  n1--;
752  }
753 
754  /* Write the data to SHEF_OUT */
755 
756  if ( DEBUG1 ) printf("\nshdece:wrting shefout");
757 
758  /* check for hour being 24 */
759  if ( n4 == 24 ) /* dgb:08/29/02 */
760  check_24( &n1, &n2, &n3, &n4, &n5, &n6 ); /* dgb:08/29/02 */
761 
762 
763  if ( data_.value != -10000 ) /* dgb:01/27/98 */
764  {
765  if( cont_.out_flag[0] == '+' )
766  {
767  fprintf(fp_.jchn,
768  "%c%c%c%c%c%c%c%c %4d %2d %2d %2d %2d %2d %4d %2d %2d %2d %2d %2d ",
769  data_.idstn[0], data_.idstn[1], data_.idstn[2], data_.idstn[3],
770  data_.idstn[4], data_.idstn[5], data_.idstn[6], data_.idstn[7],
771  n1, n2, n3, n4, n5, n6, k1, k2, k3, k4, k5, k6);
772  fprintf(fp_.jchn,
773  "%c%c%c%c%c%c%c %4d %20.6f %20.6f %c %d %c%c%c%c%c%c%c%c %d %s\n",
775  data_.kodex, durprob_.kodpr, idur, data_.codp, data_.value, lwal, *irev,
778  idote, comment_.comment ); /* dgb:09/10/97 */
779 
780  if ( test_.atest_flag ) /* dgb:12/01/97 */
781  {
782  fprintf(fp_.icher,
783  "%c%c%c%c%c%c%c%c %4d %2d %2d %2d %2d %2d %4d %2d %2d %2d %2d %2d ",
784  data_.idstn[0], data_.idstn[1], data_.idstn[2], data_.idstn[3],
785  data_.idstn[4], data_.idstn[5], data_.idstn[6], data_.idstn[7],
786  n1, n2, n3, n4, n5, n6, k1, k2, k3, k4, k5, k6);
787  fprintf(fp_.icher,
788  "%c%c%c%c%c%c%c %4d %20.6f %20.6f %c %d %c%c%c%c%c%c%c%c %d %s\n",
790  data_.kodex, durprob_.kodpr, idur, data_.codp, data_.value, lwal, *irev,
793  idote, comment_.comment ); /* dgb:09/10/97 */
794  }
795 
796  }
797 
798  /* Pass data to SHEFPASS */
799 
800  if( cont_.post_flag[0] == '+' )
801  {
802 
803  shefpass( data_.idstn[0],
804  data_.idstn[1],
805  data_.idstn[2],
806  data_.idstn[3],
807  data_.idstn[4],
808  data_.idstn[5],
809  data_.idstn[6],
810  data_.idstn[7],
811  n1,
812  n2,
813  n3,
814  n4,
815  n5,
816  n6,
817  k1,
818  k2,
819  k3,
820  k4,
821  k5,
822  k6,
823  data_.kodp,
824  data_.kode,
825  durprob_.kodd,
826  data_.kodt,
827  data_.kods,
828  data_.kodex,
829  durprob_.kodpr,
830  idur,
831  data_.codp,
832  data_.value,
833  lwal,
834  *irev,
835  data_.msource[0],
836  data_.msource[1],
837  data_.msource[2],
838  data_.msource[3],
839  data_.msource[4],
840  data_.msource[5],
841  data_.msource[6],
842  data_.msource[7],
843  idote
844  );
845  }
846  } /* dgb:01/27/98 */
847  memset(comment_.comment,0,sizeof(comment_.comment)); /* dgb:09/10/97 */
848  data_.overmonth = -1; /* dgb:01/18/99 */
849  data_.overyear = -1; /* dgb:01/18/99 */
850  data_.overcentury = -1; /* dgb:01/18/99 */
851 
852  if( iend_ == 1 )
853  goto L_9000;
854 
855  /* Clear past the next slash */
856 
857  if( nflag == 0 )
858  goto L_160;
859 L_150:
860  if ( DEBUG1 ) printf("\nshdece:at 150");
861  nextch( &xchar_.ichar, status );
862  if( *status == 1 )
863  {
864  *status = 0;
865  goto L_9000;
866  }
867  else if( *status == 2 )
868  {
869  *status = 0;
870  goto L_9010;
871  }
872 L_160:
873  if ( DEBUG1 ) printf("\nshdece:at 160");
874  if( xchar_.ichar == codes_.iblnk )
875  goto L_150;
876 
877  irang( &xchar_.ichar, &codes_.ich1, &codes_.ich9, status ); /* dgb:02/15/02 */
878  if ( *status != 1 ) /* dgb:02/15/02 */
879  goto L_150; /* dgb:02/15/02 */
880 
881  if( xchar_.ichar != codes_.islash )
882  goto L_9130;
883  nextch( &xchar_.ichar, status );
884  if( *status == 1 )
885  {
886  *status = 0;
887  goto L_170;
888  }
889  else if( *status == 2 )
890  {
891  *status = 0;
892  goto L_9010;
893  }
894  dotee_.inul = 0;
895  goto L_30;
896 
897 L_165:
898  if ( DEBUG1 ) printf("\nshdece:at 165 dtype_.ieee = %d data_.kflag=%d",dtype_.ieee, data_.kflag);
899  if( (dtype_.ieee == 1) && (data_.kflag > 0) )
900  data_.kflag = 1;
901 L_170:
902  if ( DEBUG1 ) printf("\nshdece:at 170");
903  dotee_.inul = 1;
904 
905  /* Error return - stop looking at this format */
906 
907 L_9000:
908  if ( DEBUG1 ) printf("\nshdece:at 9000");
909  *status = 1;
910 
911  return;
912  /* Error return - stop looking at this file */
913 
914 L_9010:
915  if ( DEBUG1 ) printf("\nshdece:at 9010");
916  *status = 2;
917  return;
918 
919 L_9020:
920 
921  num = 19;
922  goto L_9200;
923 
924 L_9030:
925  num = 20;
926  goto L_9200;
927 
928 L_9040:
929  num = 21;
930  goto L_9200;
931 
932 L_9050:
933  format_.nerr = 1;
934  goto L_9000;
935 
936 L_9070:
937  num = 24;
938  format_.nerr = 1;
939  goto L_9200;
940 
941 L_9080:
942  num = 25;
943  format_.nerr = 1;
944  goto L_9200;
945 
946 L_9090:
947  num = 28;
948  format_.nerr = 1;
949  goto L_9200;
950 
951 L_9100:
952  num = 29;
953  format_.nerr = 1;
954  goto L_9200;
955 
956 L_9110:
957  num = 33;
958  format_.nerr = 1;
959  goto L_9200;
960 
961 L_9120:
962  num = 35;
963  sendflg_.nsflag = 0;
964  goto L_9200;
965 
966 L_9130:
967  num = 31;
968  format_.nerr = 1;
969 
970 L_9200:
971  sherr( &num );
972  goto L_9000;
973 
974 }
975 
long check_24(short int *year, short int *month, short int *day, short int *hour, short int *minute, short int *second)
Definition: check_24.c:13
void irang(short int *i, short int *min_, short int *max_, short int *status)
Definition: irang.c:33
printf("fbuf is %s\n", fbuf)
fprintf(fp,"%d %d %d %d 1\n", iminx, iminy, maxi, maxj)
void nextch(short int *ichar, short int *status)
Definition: nextch.c:76
void shdece(short int *irev, short int *status)
Definition: shdece.c:101
void shdtype(short int *iflag, short int *status)
Definition: shdtype.c:72
#define MAX_SHEF_INPUT
Definition: shef.h:38
struct t_dtype_ dtype_
struct t_datim_ datim_
struct t_pointers_ fp_
struct t_codes_ codes_
struct t_dotee_ dotee_
struct t_datrel_ datrel_
struct t_data_ data_
struct s_test test_
struct t_buffer_ buffer_
struct t_format_ format_
struct t_xchar_ xchar_
struct t_comment comment_
struct t_sendflg_ sendflg_
struct t_cont_ cont_
struct t_durprob_ durprob_
void sherr(short int *ier)
Definition: sherr.c:44
void shlocl(short int *nyear, short int *nmon, short int *nday, short int *nhour, short int *nmin, short int *nsec, short int *nadjtz, short int *iadj, short int *status)
Definition: shlocl.c:77
void shpcode(short int *kodp, short int *kode, short int *icodd, short int *kodt, short int *kods, short int *kodex, float *codp, double *factor, short int *status)
Definition: shpcode.c:43
void shpos(short int *status)
Definition: shpos.c:62
void shreal(double *value, short int *iflag, short int *ndig, short int *status)
Definition: shreal.c:50
void shtadj(short int *lyear, short int *lmon, short int *lday, short int *lhour, short int *lmin, short int *lsec, short int *kadj, short int *iadj, short int *status)
Definition: shtadj.c:53
void shtdat(short int *lyear, short int *lmon, short int *lday, short int *status)
Definition: shtdat.c:30
int atest_flag
Definition: shef_structs.h:211
short int ip
Definition: shef_structs.h:109
short int ibuf[MAX_SHEF_INPUT]
Definition: shef_structs.h:109
short int iblnk
Definition: shef_structs.h:81
short int ichs
Definition: shef_structs.h:79
short int ichz
Definition: shef_structs.h:80
short int ichd
Definition: shef_structs.h:78
short int icho
Definition: shef_structs.h:79
short int ichc
Definition: shef_structs.h:78
short int islash
Definition: shef_structs.h:81
short int ichi
Definition: shef_structs.h:78
short int icha
Definition: shef_structs.h:78
short int ichp
Definition: shef_structs.h:79
short int ich1
Definition: shef_structs.h:80
short int ichw
Definition: shef_structs.h:80
short int ich9
Definition: shef_structs.h:81
short int ichf
Definition: shef_structs.h:78
char comment[MAX_COMMENT_LENGTH]
Definition: shef_structs.h:228
char out_flag[13]
Definition: shef_structs.h:75
char post_flag[13]
Definition: shef_structs.h:75
short int overcentury
Definition: shef_structs.h:187
short int kodu
Definition: shef_structs.h:181
short int lmon
Definition: shef_structs.h:177
short int kods
Definition: shef_structs.h:179
short int overyear
Definition: shef_structs.h:188
short int msource[8]
Definition: shef_structs.h:181
short int ksec
Definition: shef_structs.h:178
short int khour
Definition: shef_structs.h:178
short int lcent
Definition: shef_structs.h:177
short int kyear
Definition: shef_structs.h:178
short int icodd
Definition: shef_structs.h:178
short int kodex
Definition: shef_structs.h:179
short int nadjtz
Definition: shef_structs.h:181
float codp
Definition: shef_structs.h:180
short int lyear
Definition: shef_structs.h:177
short int lsec
Definition: shef_structs.h:177
short int kmin
Definition: shef_structs.h:178
short int lhour
Definition: shef_structs.h:177
short int itz
Definition: shef_structs.h:181
short int kday
Definition: shef_structs.h:178
short int lmin
Definition: shef_structs.h:177
short int idstn[8]
Definition: shef_structs.h:177
short int kodt
Definition: shef_structs.h:179
short int kmon
Definition: shef_structs.h:178
short int kodp
Definition: shef_structs.h:178
short int lday
Definition: shef_structs.h:177
short int kflag
Definition: shef_structs.h:183
short int overmonth
Definition: shef_structs.h:189
double value
Definition: shef_structs.h:182
short int idcodd
Definition: shef_structs.h:179
short int kode
Definition: shef_structs.h:178
short int kwal
Definition: shef_structs.h:181
short int idate[6]
Definition: shef_structs.h:100
short int msec
Definition: shef_structs.h:132
short int mmon
Definition: shef_structs.h:132
short int mhour
Definition: shef_structs.h:132
short int mcent
Definition: shef_structs.h:132
short int mmin
Definition: shef_structs.h:132
short int myear
Definition: shef_structs.h:132
short int mend
Definition: shef_structs.h:132
short int mday
Definition: shef_structs.h:132
short int nsec
Definition: shef_structs.h:218
short int nmin
Definition: shef_structs.h:218
short int ncent
Definition: shef_structs.h:218
short int nyear
Definition: shef_structs.h:218
short int nday
Definition: shef_structs.h:218
short int nhour
Definition: shef_structs.h:218
short int inul
Definition: shef_structs.h:218
short int nmon
Definition: shef_structs.h:218
short int ieee
Definition: shef_structs.h:168
short int kodd
Definition: shef_structs.h:97
short int kodpr
Definition: shef_structs.h:97
short int lform
Definition: shef_structs.h:129
short int nerr
Definition: shef_structs.h:129
short int iform
Definition: shef_structs.h:129
FILE * icher
Definition: shef_structs.h:72
FILE * jchn
Definition: shef_structs.h:72
short int nsflag
Definition: shef_structs.h:115
short int ichar
Definition: shef_structs.h:112