Mapper
shdotc.c
Go to the documentation of this file.
1 #define _POSIX_SOURCE
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <ctype.h>
5 #include <dirent.h>
6 #include <unistd.h>
7 #include <math.h>
8 #include <string.h>
9 #include <fcntl.h>
10 #include <sys/stat.h>
11 #include "shef_structs_external.h"
12 
13 /*---------------------------------------------------------------------
14 
15  NAME
16  SUBROUTINE SHDOTB(STATUS)
17 
18  PURPOSE
19  Decode the body of the .B FORMAT.
20  The header information for each expected data value is
21  stored on the file.
22 
23  VERSION and UPDATES
24  1.0 AUG 82 GEOFFREY M BONNIN MBRFC
25  1.1 JAN 84
26  Correct -1 date relative bug
27  Improve testing for bad dates on date
28  relative adjustment
29  1.2 AUG 84
30  Change test for creation date to non-fatal
31  Change test for error 32 to non-fatal
32  Add seconds time
33  1.3 NOV 84
34  Virtual buffering of DOTBTEMP
35  1.4 MAY 85
36  Correct error in adjusting to PREV 7AM
37  1.5 JAN 94 Robert Hartman
38  Correct year error when .B header defaults to a
39  different year than the default for the .B
40  body.
41  2.0 JUN 94 David G. Brandon
42  Include NSFLAG for selected send codes
43  Also Translated to 'C' using FOR_C
44  Removed alternate returns in subroutines
45  2.1 APR 95 David G. Brandon
46  Changed shefpass to pass all parameters in argument
47  list...prepare for INFORMIX posting.
48  2.2 Add iscore to t_codes array.
49  2.3 NOV 95 DGB
50  Add check to place nyear and k1 in correct century.
51  Allow for all valid qualifier codes excepting for
52  'O' and 'I'.
53  2.4 DEC 95 DGB
54  Do not process DC when they are missing, or the month
55  k2 is set to 0
56  2.5 JAN 96 DGB
57  Update struct t_data to include lcent
58  and kcent for the century.
59  Modify code to print out correct century for
60  shefout file and shefpass.
61  2.6 FEB 11, 96 DGB
62  Changed code to accomodate the century in the positional
63  date, date of creation and date override.
64  2.7x SEP 10 97 DGB
65  Add the use of MAX_SHEF_INPUT so that the input line can
66  be longer than 80 characters.
67  Add capability to output a database comment.
68  2.8 DEC 1 97 DGB
69  Add advanced test option will will print a shefout
70  record to the error file.
71  2.9 JAN 17 98 DGB
72  The incorrect year was calculated for certain values
73  when an override was specified. For example,
74  if the system year was 98 but december was specified in
75  the positional data, the year was not calculated
76  correctly.
77  A few sample messages that were not (but now are)
78  all correctly determined is now fixed:
79 
80  .B MCI 1231 Z DH07/HG
81  KCDM6 DY940101/8.3
82  SMHM6 DM1231/1.14
83  SMHM6 DM0102/1.14
84  AGYM6 11.9
85  .END
86  .B MCI 971231 Z DH07/HG
87  KCDM6 DY940101/8.3
88  SMHM6 DM0102/1.14
89  SMHM6 DM1231/1.14
90  AGYM6 11.9
91  .END
92  .B MCI 19971231 Z DH07/HG
93  SMHM6 DM0102/1.14
94  KCDM6 DY940101/8.3
95  SMHM6 DM1231/1.14
96  AGYM6 11.9
97  .END
98  3.0 MAR 3 98 DGB
99  Try fixing what was supposed to be fixed in 2.9.
100  3.1 DEC 5 98 DGB
101  Try to adjust mon/day on overrides only if year
102  is not respecified in the data line. Check with
103  an if test for ldum1.
104  3.2 JAN 8 99 DGB
105  Fix check for year when there is an override.
106  3.3 AUG 29 02 DGB
107  Check for hour specified as '24' and change to '00'
108  *--------------------------------------------------------------------- */
109 
110 
111 
112 void shdotb(status)
113 short int *status;
114 {
115  /* dgb:02/11/96 added lcent, kcent, ncent, lcentdum1,kcentdum1,lcentfl1,mcent */
116  static short int i, i_, iadj, idcodd, idote, idur, iend_,
117  irev, item, itest, ival, k1, k2, k3, k4, k5, k6, kday,
118  kdum4, kdum5, kdum6, khour, kmin, kmon, kodu, ksec, kwal, kyear,
119  lday, ldfk4, ldfk5, ldfk6, ldfl1, ldfl4, ldfl5, ldfl6, ldum1,
120  ldum4, ldum5, ldum6, lflag, lhour, lmin, lmon, lsec, lwal,
121  lyear, mday, mend, mhour, mmin, mmon, msec, myear, nchar, nday, ndig,
122  nflag, nhour, nmin, nmon, nsec, num, nyear, flag,
123  lcentdum1, kcentdum1, kcent,ncent,lcent,lcentfl1, mcent;
124  static double factor;
125  int DEBUG1, DEBUG2;
126 
127  /* OFFSET Vectors w/subscript range: 1 to dimension */
128  short *const Ibuf = &buffer_.ibuf[0] - 1;
129  short *const Idate = &datim_.idate[0] - 1;
130  short *const Idstn = &data_.idstn[0] - 1;
131  short *const Msource = &data_.msource[0] - 1;
132 
133  DEBUG1 = 0;
134  DEBUG2 = 0;
135 
136  /* Initialise */
137 L_10:
138  if ( DEBUG1 ) printf("\nshdotb: at L_10 ");
139  data_.overcentury = -1; /* dgb:01/18/99 */
140  data_.overyear = -1; /* dgb:01/18/99 */
141  data_.overmonth = -1; /* dgb:01/18/99 */
142 
143  Msource[1] = codes_.iblnk; /* dgb:09/10/97 */
144  Msource[2] = codes_.iblnk;
145  Msource[3] = codes_.iblnk;
146  Msource[4] = codes_.iblnk;
147  Msource[5] = codes_.iblnk;
148  Msource[6] = codes_.iblnk;
149  Msource[7] = codes_.iblnk;
150  Msource[8] = codes_.iblnk;
151 
152  *status = 0;
153  item = 0;
154  bbuf1_.nmrec = 0;
155  dotbee_.nelem = 0;
156  idote = 0;
157  Idstn[1] = codes_.iblnk;
158  Idstn[2] = codes_.iblnk;
159  Idstn[3] = codes_.iblnk;
160  Idstn[4] = codes_.iblnk;
161  Idstn[5] = codes_.iblnk;
162  Idstn[6] = codes_.iblnk;
163  Idstn[7] = codes_.iblnk;
164  Idstn[8] = codes_.iblnk;
165  ldum1 = -31999;
166  lcentdum1 = -31999; /* dgb:02/11/96 add */
167  data_.lmon = -31999;
168  data_.lday = -31999;
169  ldum4 = -31999;
170  ldum5 = -31999;
171  ldum6 = -31999;
172  data_.kcent = -31999;
173  data_.kyear = -31999;
174  data_.kmon = -31999;
175  data_.kday = -31999;
176  kdum4 = -31999;
177  kdum5 = -31999;
178  kdum6 = -31999;
179  datrel_.mcent = -31999; /* dgb:02/11/96 add*/
180  datrel_.myear = -31999;
181  datrel_.mmon = -31999;
182  datrel_.mday = -31999;
183  datrel_.mhour = -31999;
184  datrel_.mmin = -31999;
185  datrel_.msec = -31999;
186  datrel_.mend = -31999;
187  data_.idcodd = -31999;
188  data_.kwal = -31999;
189  data_.kodu = -31999;
190 
191  goto L_25;
192 
193  /* Now get the station ID */
194 
195 L_20:
196  if ( DEBUG1 ) printf("\nshdotb: at L_20 getting ID");
197  nextch( &xchar_.ichar, status );
198  if( *status == 1 )
199  {
200  *status = 0;
201  goto L_9000;
202  }
203  else if( *status == 2 )
204  {
205  *status = 0;
206  goto L_9020;
207  }
208 L_25:
209  if( xchar_.ichar == codes_.iblnk )
210  goto L_20;
211 
212  /* Read up to 8 chars, checking for legit ones */
213 
214  nchar = 0;
215 
216  for( i = 1; i <= 8; i++ )
217  {
218  i_ = i - 1;
219  irang( &xchar_.ichar, &codes_.icha, &codes_.ichz, status );
220  if( *status == 1 )
221  {
222  *status = 0;
223  goto L_15;
224  }
225  goto L_40;
226 
227 L_15:
228  irang( &xchar_.ichar, &codes_.ich0, &codes_.ich9, status );
229  if( *status == 1 )
230  {
231  *status = 0;
232  goto L_16;
233  }
234  goto L_40;
235 
236 
237 L_16: if ( xchar_.ichar == codes_.iscore ) /* dgb:11/07/95 */
238  goto L_40;
239  else
240  goto L_9030;
241 
242 L_40: Idstn[i] = xchar_.ichar;
243  nchar = nchar + 1;
244  nextch( &xchar_.ichar, status );
245  if( *status == 1 )
246  {
247  *status = 0;
248  goto L_190;
249  }
250  else if( *status == 2 )
251  {
252  *status = 0;
253  goto L_9020;
254  }
255  if( xchar_.ichar == codes_.iblnk )
256  goto L_60;
257  }
258 
259  if( xchar_.ichar != codes_.iblnk )
260  goto L_9120;
261 L_60:
262  if( nchar < 3 )
263  goto L_9040;
264 
265  /* Test for too many items */
266 
267 L_65:
268  if ( DEBUG1 ) printf("\nshdotb: at L_65 reading data header");
269  item = item + 1;
270  if( item > luns_.mrec )
271  goto L_70;
272 
273 
274 
275 
276  /* Read the data header */
277 
278  /* dgb:02/11/96 add &lcent, *kcent, &mcent */
279  shbfr( data_.msource, &lcent, &lyear, &lmon, &lday, &lhour, &lmin, &lsec,
280  &kcent,&kyear, &kmon, &kday, &khour, &kmin, &ksec, &mcent, &myear, &mmon, &mday,
281  &mhour, &mmin, &msec, &mend, &data_.kodp, &data_.kode, &data_.icodd,
282  &idcodd, &data_.kodt, &data_.kods, &data_.kodex, &data_.codp,
283  &kwal, &data_.nadjtz, &kodu, &factor, &irev, &durprob_.kodd,
284  &durprob_.kodpr );
285 
286  /* Get the value */
287 L_70:
288  if ( DEBUG1 ) printf("\nshdotb: at L_70 getting value");
289  flag = 1;
290  shreal( &data_.value, &flag, &ndig, status );
291  if ( DEBUG1 ) printf("\nshdotb: status from shreal = %d",*status);
292  if( *status == 1 )
293  {
294  *status = 0;
295  goto L_74;
296  }
297  else if( *status == 2 )
298  {
299  *status = 0;
300  goto L_9010;
301  }
302  iend_ = 0;
303  goto L_77;
304 
305 L_74:
306  iend_ = 1;
307 L_77:
308  if ( DEBUG2 ) printf("\nshdotb: ndig = %d iend_ = %d luns_.mrec = %d",ndig,iend_,luns_.mrec);
309  if( (ndig == 0) && (iend_ == 0) )
310  goto L_150;
311  if( (ndig == 0) && (iend_ == 1) )
312  goto L_190;
313  if( ndig == -1 )
314  goto L_65;
315  if( item > luns_.mrec )
316  goto L_9050;
317 
318  /* Check for changes in D type elements */
319  if( lcentdum1 != -31999 ) /* dgb:02/11/96 add */
320  lcent = lcentdum1;
321  if( ldum1 != -31999 )
322  lyear = ldum1;
323  if( data_.lmon != -31999 )
324  lmon = data_.lmon;
325  if( data_.lday != -31999 )
326  lday = data_.lday;
327  if( ldum4 != -31999 )
328  lhour = ldum4;
329  if( ldum5 != -31999 )
330  lmin = ldum5;
331  if( ldum6 != -31999 )
332  lsec = ldum6;
333  if( data_.kcent != -31999 )
334  kcent = data_.kcent;
335  if( data_.kyear != -31999 )
336  kyear = data_.kyear;
337  if( data_.kmon != -31999 )
338  kmon = data_.kmon;
339  if( data_.kday != -31999 )
340  kday = data_.kday;
341  if( kdum4 != -31999 )
342  khour = kdum4;
343  if( kdum5 != -31999 )
344  kmin = kdum5;
345  if( kdum6 != -31999 )
346  ksec = kdum6;
347  if( datrel_.mcent != -31999 ) /* dgb:02/11/96 add */
348  mcent = datrel_.mcent;
349  if( datrel_.myear != -31999 )
350  myear = datrel_.myear;
351  if( datrel_.mmon != -31999 )
352  mmon = datrel_.mmon;
353  if( datrel_.mday != -31999 )
354  mday = datrel_.mday;
355  if( datrel_.mhour != -31999 )
356  mhour = datrel_.mhour;
357  if( datrel_.mmin != -31999 )
358  mmin = datrel_.mmin;
359  if( datrel_.msec != -31999 )
360  msec = datrel_.msec;
361  if( datrel_.mend != -31999 )
362  mend = datrel_.mend;
363  if( data_.idcodd != -31999 )
364  idcodd = data_.idcodd;
365  if( data_.kwal != -31999 )
366  kwal = data_.kwal;
367  if( data_.kodu != -31999 )
368  kodu = data_.kodu;
369 
370  /* Adjust for TRACE */
371 
372  if( data_.value >= -8e10 )
373  goto L_80;
374  if( data_.kodp != codes_.ichp )
375  goto L_78;
376  if( data_.kode == codes_.ichc )
377  goto L_79;
378  if( data_.kode == codes_.ichp )
379  goto L_79;
380  goto L_9060;
381 
382 L_78:
383  if( data_.kodp != codes_.ichs )
384  goto L_9060;
385  if( data_.kode == codes_.ichd )
386  goto L_79;
387  if( data_.kode == codes_.ichf )
388  goto L_79;
389  if( data_.kode == codes_.ichw )
390  goto L_79;
391  goto L_9060;
392 
393 L_79:
394  data_.value = 0.001e0;
395  goto L_90;
396 
397  /* Convert SI to english units if necessary */
398 
399 L_80:
400  if( kodu == 1 )
401  goto L_90;
402  ival = data_.value - 0.01;
403  if( ival == -9999 )
404  goto L_90;
405  if( ival == -9002 )
406  goto L_90;
407  if( factor < 0e0 )
408  data_.value = data_.value*1.8e0 + 32e0;
409  if( factor > 0e0 )
410  data_.value = data_.value*factor;
411 
412  /* Test the qualifier - it should be in ICHAR already */
413 
414 L_90:
415  if ( DEBUG1 ) printf("\nshdotb: at L_90 testing qualifier");
416  if( iend_ == 1 ) goto L_95;
417 
418  /* pass all alphabetical characters except 'O' and 'I' dgb:11/13/95 */
419  irang(&xchar_.ichar,&codes_.icha,&codes_.ichz,status);
420  if ( !*status )
421  {
422  *status = 0;
423  if ( xchar_.ichar == codes_.icho ) goto L_9090;
424  if ( xchar_.ichar == codes_.ichi ) goto L_9090;
425  goto L_100;
426  }
427 
428  *status = 0;
429  if( xchar_.ichar == codes_.iblnk ) goto L_95;
430  if( xchar_.ichar == codes_.islash ) goto L_95;
431  if( xchar_.ichar == codes_.icomma ) goto L_95;
432 
433  goto L_9090;
434 
435 L_95:
436  lwal = kwal;
437  nflag = 0;
438  goto L_110;
439 
440 L_100:
441  lwal = xchar_.ichar;
442  nflag = 1;
443 
444  /* Adjust the observation time to 7AM previous day if necessary.
445  * Can't do it if ZULU time or date rel has been specified */
446 
447 L_110:
448  ncent = lcent; /* dgb:02/11/96 add */
449  nyear = lyear;
450  nmon = lmon;
451  nday = lday;
452  nhour = lhour;
453  nmin = lmin;
454  nsec = lsec;
455  if( sendflg_.nsflag == 0 )
456  goto L_115; /*DGB: CHECK SEND FLAG */
457  if( data_.nadjtz == 0 )
458  goto L_9130;
459  if( mcent != 0 ) /* dgb:02/11/96 add */
460  goto L_9130;
461  if( myear != 0 )
462  goto L_9130;
463  if( mmon != 0 )
464  goto L_9130;
465  if( mday != 0 )
466  goto L_9130;
467  if( mhour != 0 )
468  goto L_9130;
469  if( mmin != 0 )
470  goto L_9130;
471  if( msec != 0 )
472  goto L_9130;
473  iadj = -1;
474 
475  if( nhour < 7 )
476  {
477  flag = 3;
478  shtadj( &nyear, &nmon, &nday, &nhour, &nmin, &nsec, &iadj,
479  &flag, status );
480  }
481  if( *status == 1 )
482  {
483  *status = 0;
484  goto L_9100;
485  }
486 
487  nhour = 7;
488  nmin = 0;
489  nsec = 0;
490  goto L_117;
491 
492  /* Adjust for date relative for year, month and day */
493 
494 L_115:
495  flag = 3;
496  shtadj( &nyear, &nmon, &nday, &nhour, &nmin, &nsec, &mday, &flag,
497  status );
498  if( *status == 1 )
499  {
500  *status = 0;
501  goto L_9000;
502  }
503 
504  flag = 4;
505  shtadj( &nyear, &nmon, &nday, &nhour, &nmin, &nsec, &mmon, &flag,
506  status );
507  if( *status == 1 )
508  {
509  *status = 0;
510  goto L_9000;
511  }
512 
513  flag = 5;
514  shtadj( &nyear, &nmon, &nday, &nhour, &nmin, &nsec, &myear, &flag,
515  status );
516  if( *status == 1 )
517  {
518  *status = 0;
519  goto L_9000;
520  }
521 
522  flag = 6;
523  shtadj( &nyear, &nmon, &nday, &nhour, &nmin, &nsec, &mend, &flag,
524  status );
525  if( *status == 1 )
526  {
527  *status = 0;
528  goto L_9000;
529  }
530 
531  shtdat( &nyear, &nmon, &nday, status );
532  if( *status == 1 )
533  {
534  *status = 0;
535  goto L_9100;
536  }
537 
538  /* Test for local time zone and adjust to ZULU time */
539 
540 L_117:
541  iadj = 0;
542  shlocl( &nyear, &nmon, &nday, &nhour, &nmin, &nsec, &data_.nadjtz,
543  &iadj, status );
544  if( *status == 1 )
545  {
546  *status = 0;
547  goto L_9000;
548  }
549  flag = 1;
550  shtadj( &nyear, &nmon, &nday, &nhour, &nmin, &nsec, &iadj, &flag,
551  status );
552  if( *status == 1 )
553  {
554  *status = 0;
555  goto L_9000;
556  }
557  k1 = kyear;
558  k2 = kmon;
559  k3 = kday;
560  k4 = khour;
561  k5 = kmin;
562  k6 = ksec;
563  if( kmon == 0 )
564  goto L_119;
565  iadj = 0;
566  shlocl( &k1, &k2, &k3, &k4, &k5, &k6, &data_.nadjtz, &iadj, status );
567  if( *status == 1 )
568  {
569  *status = 0;
570  goto L_9000;
571  }
572  flag = 1;
573  shtadj( &k1, &k2, &k3, &k4, &k5, &k6, &iadj, &flag, status );
574  if( *status == 1 )
575  {
576  *status = 0;
577  goto L_9000;
578  }
579 
580  /* Adjust for date relative for hour and minute */
581 
582 L_119:
583  flag = 7;
584  shtadj( &nyear, &nmon, &nday, &nhour, &nmin, &nsec, &msec, &flag,
585  status );
586  if( *status == 1 )
587  {
588  *status = 0;
589  goto L_9000;
590  }
591  flag = 1;
592  shtadj( &nyear, &nmon, &nday, &nhour, &nmin, &nsec, &mmin, &flag,
593  status );
594  if( *status == 1 )
595  {
596  *status = 0;
597  goto L_9000;
598  }
599  flag = 2;
600  shtadj( &nyear, &nmon, &nday, &nhour, &nmin, &nsec, &mhour, &flag,
601  status );
602  if( *status == 1 )
603  {
604  *status = 0;
605  goto L_9000;
606  }
607 
608  /* Test for correct duration */
609 
610  if( (data_.icodd == 5003) && (idcodd == 5000) )
611  {
612  goto L_9070;
613  }
614  idur = data_.icodd;
615  if( data_.icodd == 5003 )
616  idur = idcodd;
617 
618  /* Test if creation date specified for forecast data */
619 
620  if( (data_.kodt == codes_.ichf) && (kmon == 0) )
621  {
622  flag = 23;
623  sherr( &flag );
624  }
625 
626 
627  /* Test for correct year if a date override was specified */
628  if ( data_.overyear > -1 && data_.overcentury == -1 )
629  if ( data_.overyear > 30 ) nyear = data_.overyear + 1900;
630  else
631  if ( data_.overcentury > -1 && data_.overyear > -1 )
632  nyear = ( data_.overcentury * 100 ) + data_.overyear; /* dgb:01/18/99 */
633 
634 
635  if ( data_.overmonth > -1 && data_.overyear == -1 ) /* dgb:01/07/99 */
636  {
637  itest = nmon - bbuf2_.iarray[bbuf1_.nmrec - 1][1];
638  if ( itest > 6 ) nyear--;
639  if ( itest < -6 ) nyear++;
640  if ( (itest == -6 ) & ( lday < bbuf2_.iarray[bbuf1_.nmrec-1][2] ) )
641  nyear++;
642  if ( (itest == 6 ) && ( lday > bbuf2_.iarray[bbuf1_.nmrec-1][2] ) )
643  nyear--;
644  }
645 
646  /* bbuf2_.iarray[bbuf1_.nmrec - 1][2]; lday */
647  /* bbuf2_.iarray[bbuf1_.nmrec - 1][3]; lhour */
648  /* bbuf2_.iarray[bbuf1_.nmrec - 1][4]; lmin */
649  /* bbuf2_.iarray[bbuf1_.nmrec - 1][5]; lsec */
650  /* bbuf2_.iarray[bbuf1_.nmrec - 1][24]; lcent */
651 
652  /* Write the data to SHEF_OUT */
653 
654  if ( DEBUG1 ) printf("\nshdotb: writing shefout record");
655 
656  /* check for hour being 24 */
657  if ( nhour == 24 ) /* dgb:08/29/02 */
658  check_24( &nyear, &nmon, &nday, &nhour, &nmin, &nsec ); /* dgb:08/29/02 */
659 
660  if ( data_.value != -10000 ) /* dgb:02/04 98 */
661  {
662  if( cont_.out_flag[0] == '+' )
663  {
664 
665  fprintf(fp_.jchn,
666  "%c%c%c%c%c%c%c%c %4d %2d %2d %2d %2d %2d %4d %2d %2d %2d %2d %2d ",
667  data_.idstn[0], data_.idstn[1], data_.idstn[2], data_.idstn[3],
668  data_.idstn[4], data_.idstn[5], data_.idstn[6], data_.idstn[7],
669  nyear, nmon, nday, nhour, nmin, nsec, k1, k2, k3, k4, k5, k6);
670  fprintf(fp_.jchn,
671  "%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",
673  data_.kodex, durprob_.kodpr, idur, data_.codp, data_.value, lwal, irev,
676  idote, comment_.comment ); /* dgb:09/10/97 */
677 
678  if ( test_.atest_flag ) /* dgb:12/01/97 */
679  {
680  fprintf(fp_.icher,
681  "%c%c%c%c%c%c%c%c %4d %2d %2d %2d %2d %2d %4d %2d %2d %2d %2d %2d ",
682  data_.idstn[0], data_.idstn[1], data_.idstn[2], data_.idstn[3],
683  data_.idstn[4], data_.idstn[5], data_.idstn[6], data_.idstn[7],
684  nyear, nmon, nday, nhour, nmin, nsec, k1, k2, k3, k4, k5, k6);
685  fprintf(fp_.icher,
686  "%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",
688  data_.kodex, durprob_.kodpr, idur, data_.codp, data_.value, lwal, irev,
691  idote, comment_.comment ); /* dgb:09/10/97 */
692  }
693  }
694 
695  /* Pass data to SHEFPASS */
696 
697  if( cont_.post_flag[0] == '+' )
698  {
699  shefpass( data_.idstn[0],
700  data_.idstn[1],
701  data_.idstn[2],
702  data_.idstn[3],
703  data_.idstn[4],
704  data_.idstn[5],
705  data_.idstn[6],
706  data_.idstn[7],
707  nyear,
708  nmon,
709  nday,
710  nhour,
711  nmin,
712  nsec,
713  k1,
714  k2,
715  k3,
716  k4,
717  k5,
718  k6,
719  data_.kodp,
720  data_.kode,
721  durprob_.kodd,
722  data_.kodt,
723  data_.kods,
724  data_.kodex,
725  durprob_.kodpr,
726  idur,
727  data_.codp,
728  data_.value,
729  lwal,
730  irev,
731  data_.msource[0],
732  data_.msource[1],
733  data_.msource[2],
734  data_.msource[3],
735  data_.msource[4],
736  data_.msource[5],
737  data_.msource[6],
738  data_.msource[7],
739  idote
740 
741  );
742  }
743  } /* dgb:02/04/98 */
744  memset(comment_.comment,0,sizeof(comment_.comment)); /* dgb:/09/10/97 */
745 
746  data_.overmonth = -1; /* dgb:01/18/99 */
747  data_.overyear = -1; /* dgb:01/18/99 */
748  data_.overcentury = -1; /* dgb:01/18/99 */
749  if( iend_ == 1 )
750  goto L_190;
751  goto L_160;
752 
753  /* Check for date and data type elements */
754 
755 L_150:
756  if ( DEBUG1 ) printf("\nshdotb: at L_150 check for data and data type");
757  if( xchar_.ichar == codes_.islash )
758  goto L_65;
759 
760  ldfl1 = 0;
761  if( ldum1 != -31999 )
762  ldfl1 = 1;
763  data_.lyear = lyear;
764  if( ldfl1 == 1 )
765  data_.lyear = ldum1;
766 
767  lcentfl1 = 0; /* dgb: 02/11/96 add */
768  if ( lcentdum1 != -31999 ) /* dgb: 02/11/96 add */
769  lcentfl1 = 1; /* dgb: 02/11/96 add */
770  data_.lcent = lcent; /* dgb: 02/11/96 add */
771  if ( lcentfl1 == 1 ) /* dgb: 02/11/96 add */
772  data_.lcent = lcentdum1; /* dgb: 02/11/96 add */
773 
774 
775  /* The following five lines of code were added by
776  * Robert Hartman to correct year error when .B header
777  * defaults to a difference year than the default
778  * for the .B body */
779 
780 /*
781  itest = lmon - Idate[1];
782  if( itest > 6 )
783  data_.lyear = data_.lyear - 1;
784  if( itest < -6 )
785  data_.lyear = data_.lyear + 1;
786  if( (itest == -6) && (lday < Idate[2]) )
787  data_.lyear = data_.lyear + 1;
788  if( (itest == 6) && (lday > Idate[2]) )
789  data_.lyear = data_.lyear - 1;
790 */
791  ldfl4 = 0;
792  if( ldum4 != -31999 )
793  ldfl4 = 1;
794  data_.lhour = lhour;
795  if( ldfl4 == 1 )
796  data_.lhour = ldum4;
797 
798  ldfl5 = 0;
799  if( ldum5 != -31999 )
800  ldfl5 = 1;
801  data_.lmin = lmin;
802  if( ldfl5 == 1 )
803  data_.lmin = ldum5;
804 
805  ldfl6 = 0;
806  if( ldum6 != -31999 )
807  ldfl6 = 1;
808  data_.lsec = lmin;
809  if( ldfl6 == 1 )
810  data_.lsec = ldum6;
811 
812  ldfk4 = 0;
813  if( kdum4 != -31999 )
814  ldfk4 = 1;
815  data_.khour = khour;
816  if( ldfk4 == 1 )
817  data_.khour = kdum4;
818 
819  ldfk5 = 0;
820  if( kdum5 != -31999 )
821  ldfk5 = 1;
822  data_.kmin = kmin;
823  if( ldfk5 == 1 )
824  data_.kmin = kdum5;
825 
826  ldfk6 = 0;
827  if( kdum6 != -31999 )
828  ldfk6 = 1;
829  data_.ksec = kmin;
830  if( ldfk6 == 1 )
831  data_.ksec = kdum6;
832 
833  flag = 4;
834  shdtype( &flag, status );
835  if( *status == 1 )
836  {
837  *status = 0;
838  goto L_9010;
839  }
840  else if( *status == 2 )
841  {
842  *status = 0;
843  goto L_9020;
844  }
845  else if( *status == 3 )
846  {
847  *status = 0;
848  goto L_9000;
849  }
850 
851 
852  if( (ldfl1 == 0) && (data_.lyear != lyear) )
853  {
855  ldum1 = data_.lyear;
856  }
857  if( ldfl1 == 1 )
858  ldum1 = data_.lyear;
859 
860  /* dgb: 02/11/96 add next 4 lines */
861  if( (lcentfl1 == 0) && (data_.lcent != lcent) )
862  {
864  lcentdum1 = data_.lcent;
865  }
866 
867  if( lcentfl1 == 1 )
868  lcentdum1 = data_.lcent;
869 
870 
871  if( (ldfl4 == 0) && (data_.lhour != lhour) )
872  ldum4 = data_.lhour;
873  if( ldfl4 == 1 )
874  ldum4 = data_.lhour;
875 
876  if( (ldfl5 == 0) && (data_.lmin != lmin) )
877  ldum5 = data_.lmin;
878  if( ldfl5 == 1 )
879  ldum5 = data_.lmin;
880 
881  if( (ldfl6 == 0) && (data_.lsec != lmin) )
882  ldum6 = data_.lsec;
883  if( ldfl6 == 1 )
884  ldum6 = data_.lsec;
885 
886  if( (ldfk4 == 0) && (data_.khour != khour) )
887  kdum4 = data_.khour;
888  if( ldfk4 == 1 )
889  kdum4 = data_.khour;
890 
891  if( (ldfk5 == 0) && (data_.kmin != kmin) )
892  kdum5 = data_.kmin;
893  if( ldfk5 == 1 )
894  kdum5 = data_.kmin;
895 
896  if( (ldfk6 == 0) && (data_.ksec != kmin) )
897  kdum6 = data_.ksec;
898  if( ldfk6 == 1 )
899  kdum6 = data_.ksec;
900 
901  goto L_170;
902 
903  /* Clear past the next slash */
904 
905 L_160:
906  if ( DEBUG1 ) printf("\nshdotb: at L_160 clear past next shlash");
907  if( nflag == 0 )
908  goto L_170;
909 L_165:
910  if ( DEBUG1 ) printf("\nshdotb: at L_165");
911  nextch( &xchar_.ichar, status );
912  if( *status == 1 )
913  {
914  *status = 0;
915  goto L_190;
916  }
917  else if( *status == 2 )
918  {
919  *status = 0;
920  goto L_9020;
921  }
922 L_170:
923  if ( DEBUG1 ) printf("\nshdotb: at L_170");
924  if( xchar_.ichar == codes_.iblnk )
925  goto L_165;
926  if( xchar_.ichar == codes_.islash )
927  goto L_175;
928  if( xchar_.ichar == codes_.icomma )
929  goto L_180;
930  goto L_9090;
931 
932 L_175:
933  if ( DEBUG1 ) printf("\nshdotb: at L_175");
934  if ( DEBUG2 ) printf("\nshdotb: dotbee_.nelem = %d",dotbee_.nelem);
935  if( dotbee_.nelem == 0 )
936  goto L_65;
937  dotbee_.nelem = 0;
938  goto L_70;
939 
940  /* Check if all the items appeared */
941 
942 L_180:
943  if ( DEBUG1 ) printf("\nshdotb: at L_180 check if items appeared");
944  lflag = 1;
945  goto L_200;
946 
947 L_190:
948  if ( DEBUG1 ) printf("\nshdotb: at L_190");
949  lflag = 0;
950 L_200:
951  if ( DEBUG1 ) printf("\nshdotb: at L_200");
952  if( item < luns_.mrec )
953  {
954  flag = 32;
955  sherr( &flag );
956  }
957  if( iend_ == 1 )
958  goto L_9000;
959  if( lflag == 0 )
960  goto L_9000;
961  goto L_230;
962 
963  /* Clear to a comma or the end of the line */
964 
965 L_220:
966  if ( DEBUG1 ) printf("\nshdotb: at L_220 clear to comma or end of line");
967  nextch( &xchar_.ichar, status );
968  if( *status == 1 )
969  {
970  *status = 0;
971  goto L_9000;
972  }
973  else if( *status == 2 )
974  {
975  *status = 0;
976  goto L_9020;
977  }
978 L_230:
979  if ( DEBUG1 ) printf("\nshdotb: at L_230");
980  if( xchar_.ichar != codes_.icomma )
981  goto L_220;
982  nextch( &xchar_.ichar, status );
983  if( *status == 1 )
984  {
985  *status = 0;
986  goto L_190;
987  }
988  else if( *status == 2 )
989  {
990  *status = 0;
991  goto L_9020;
992  }
993  goto L_10;
994 
995 L_9000:
996  if ( DEBUG1 ) printf("\nshdotb: at L_9000 return ");
997  return;
998 
999 L_9010:
1000  buffer_.ip = MAX_SHEF_INPUT + 1; /* dgb:09/10/97 */
1001  *status = 1;
1002  return;
1003 
1004 L_9020:
1005  *status = 2;
1006  return;
1007 
1008 L_9030:
1009  num = 6;
1010  goto L_9200;
1011 
1012 L_9040:
1013  num = 3;
1014  goto L_9200;
1015 
1016 L_9050:
1017  flag = 30;
1018  sherr( &flag );
1019  goto L_230;
1020 
1021 L_9060:
1022  num = 28;
1023  goto L_9200;
1024 
1025 L_9070:
1026  num = 25;
1027  goto L_9200;
1028 
1029 L_9090:
1030  num = 31;
1031  goto L_9200;
1032 
1033 L_9100:
1034  num = 24;
1035  goto L_9200;
1036 
1037 L_9120:
1038  num = 2;
1039  goto L_9200;
1040 
1041 L_9130:
1042  num = 35;
1043 L_9200:
1044  sherr( &num );
1045  dotbee_.nerror = dotbee_.nerror + 1;
1046  if( dotbee_.nerror >= 3 )
1047  goto L_9010;
1048  goto L_180;
1049 
1050 }
1051 
1052 
static int i
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
int mday[]
Definition: fmap_qtrly.c:519
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 shbfr(msource, *lcent, *lyear, *lmon, *lday, *lhour, *lmin, *lsec, *kcent, *kyear, *kmon, *kday, *khour, *kmin, *ksec, *mcent, *myear, *mmon, *mday, *mhour, *mmin, *msec, *mend, *kodp, *kode, *icodd, *idcodd, *kodt, *kods, *kodex, float *codp, short int *kwal, short int *nadjtz, short int *kodu, double *factor, short int *irev, short int *kodd, short int *kodpr)
Definition: shbfr.c:41
void shdotb(short int *status)
Definition: shdotc.c:112
void shdtype(short int *iflag, short int *status)
Definition: shdtype.c:72
#define MAX_SHEF_INPUT
Definition: shef.h:38
struct t_luns luns_
struct t_datim_ datim_
struct t_bbuf2_ bbuf2_
struct t_pointers_ fp_
struct t_codes_ codes_
struct t_dotbee_ dotbee_
struct t_bbuf1_ bbuf1_
struct t_datrel_ datrel_
struct t_data_ data_
struct s_test test_
struct t_buffer_ buffer_
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 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 nmrec
Definition: shef_structs.h:118
short int iarray[38][27]
Definition: shef_structs.h:123
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 ich0
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 ichw
Definition: shef_structs.h:80
short int iscore
Definition: shef_structs.h:82
short int icomma
Definition: shef_structs.h:82
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 kcent
Definition: shef_structs.h:178
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 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 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 nerror
Definition: shef_structs.h:165
short int nelem
Definition: shef_structs.h:165
short int kodd
Definition: shef_structs.h:97
short int kodpr
Definition: shef_structs.h:97
short int mrec
Definition: shef_structs.h:215
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