Mapper
blockdata.c
Go to the documentation of this file.
1 /*Translated by FOR_C, v3.4.2 (-), on 04/06/95 at 13:53:42 */
2 /*FOR_C Options SET: c=2 com=u do=r44 ftn=ln6kk op=iv s=dvnk str=l sq=i */
3 #define _POSIX_SOURCE
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <ctype.h>
7 #include <dirent.h>
8 #include <unistd.h>
9 #include <math.h>
10 #include <string.h>
11 #include <fcntl.h>
12 #include <sys/stat.h>
13 #include "shef_structs_external.h"
14 /*---------------------------------------------------------------------
15 
16  NAME
17  BLOCKDATA
18 
19  PURPOSE
20  Initialize data arrays
21 
22  VERSION and UPDATES
23  1.0 APR 82 Geoffrey M. Bonnin
24  Original Version
25  1.1 JUN 89 David G. Brandon
26  Adapted to QNX NWS Hydromet
27  2.0 MAY 94 David G. Brandon
28  Also Translated to 'C' using FOR_C
29  Added error messages, moved daylight/standard time
30  switch over times.
31  2.1 OCT 95 dgb
32  Include the underscore '_' as a character.
33  2.2 JAN 96
34  Remove FORC initializations and replace them with
35  simple assignment statements.
36  2.3 Increase message5 array to 63. Modify error message5
37  to state, 'not enough digits or bad value'. Add warning message
38  about not checking for daylights savings time if
39  year is between {1975 and 2021}.
40  2.4 Add codes_.dquote.
41  Add error messages 39 and 40.
42  2.5 OCT 19 97 DGB
43  Change datet_.itable array numbers for switchover
44  times to daylight savings time.
45  2.6 MAR 30 2001 DGB
46  Change all strcpy to strncpy.
47  2.7 OCT 18 2012 RKH
48  Modify structure to represent March and November
49  dates from 2007 forwad.
50  *--------------------------------------------------------------------- */
51 
52 
53 void blk_data()
54 {
55  /* OFFSET Vectors w/subscript range: 1 to dimension */
56  short *const Iday = &days_.iday[0] - 1;
57 
58 
59  /* Error Messages */
60 
61  strncpy( err1_.message1, "Error No. 1 ->This line not decoded",sizeof(err1_.message1) );
62  strncpy( err1_.message2, "Error No. 2 ->No space in positional data",sizeof(err1_.message2) );
63  strncpy( err1_.message3, "Error No. 3 ->Less than 3 characters in ID of message source",sizeof(err1_.message3));
64  strncpy( err1_.message4, "Error No. 4 ->TZ code error",sizeof( err1_.message4));
65  strncpy( err1_.message5, "Error No. 5 ->Date group error-not enough digits or bad value",sizeof( err1_.message5));
66  strncpy( err2_.message6, "Error No. 6 ->Illegal character in Id or message source",sizeof(err2_.message6) );
67  strncpy( err2_.message7, "Error No. 7 ->Error in date code",sizeof( err2_.message7));
68  strncpy( err2_.message8, "Error No. 8 ->Observation time error",sizeof(err2_.message8) );
69  strncpy( err2_.message9, "Error No. 9 ->Date relative code error",sizeof(err2_.message9) );
70  strncpy( err2_.message10, "Error No. 10 ->Julian day error",sizeof( err2_.message10));
71  strncpy( err3_.message11, "Error No. 11 ->Illegal data string qualifier",sizeof(err3_.message11) );
72  strncpy( err3_.message12, "Error No. 12 ->Units code error",sizeof( err3_.message12));
73  strncpy( err3_.message13, "Error No. 13 ->Not a date or data type element",sizeof(err3_.message13) );
74  strncpy( err3_.message14, "Error No. 14 ->Not a date or data type...maybe missing slash",sizeof(err3_.message14));
75  strncpy( err3_.message15, "Error No. 15 ->Illegal character in parameter code",sizeof(err3_.message15) );
76  strncpy( err4_.message16, "Error No. 16 ->File read error on shef_parm",sizeof(err4_.message16) );
77  strncpy( err4_.message17, "Error No. 17 ->Non-existant parameter code",sizeof(err4_.message17) );
78  strncpy( err4_.message18, "Error No. 18 ->Parameters coded with a send cod",sizeof( err4_.message18));
79  strncpy( err4_.message19, "Error No. 19 ->Continuation of a format does not follow the correct format",sizeof(err4_.message19));
80  strncpy( err4_.message20, "Error No. 20 ->A format revision continuation follows an original",sizeof(err4_.message20));
81  strncpy( err5_.message21, "Error No. 21 ->The format that this is continuing had an error",sizeof(err5_.message21));
82  strncpy( err5_.message22, "Error No. 22 ->Year not in the range 1976-2020 for local time zone",sizeof(err5_.message22));
83  strncpy( err5_.message221," ...use Z for time zone for historical data",sizeof(err5_.message221));
84  strncpy( err5_.message23, "Warng No. 23 ->Forecast data without creation date",sizeof( err5_.message23));
85  strncpy( err5_.message24, "Error No. 24 ->Bad data somehow",sizeof(err5_.message24) );
86  strncpy( err5_.message25, "Error No. 25 ->DV not defined for ZZV",sizeof(err5_.message25) );
87  strncpy( err6_.message26, "Error No. 26 ->DV code error",sizeof(err6_.message26) );
88  strncpy( err6_.message27, "Error No. 27 ->DI code error",sizeof(err6_.message27) );
89  strncpy( err6_.message28, "Error No. 28 ->Trace specified for other than PP,PC,SF,SD or SW",sizeof(err6_.message28));
90  strncpy( err6_.message29, "Error No. 29 ->No time increment specified",sizeof(err6_.message29) );
91  strncpy( err6_.message30, "Error No. 30 ->To many items in .B body line",sizeof( err6_.message30));
92  strncpy( err7_.message31, "Error No. 31 ->Bad character in the line",sizeof(err7_.message31) );
93  strncpy( err7_.message32, "Warng No. 32 ->Not enough items in .B body line",sizeof(err7_.message32) );
94  strncpy( err7_.message33, "Error No. 33 ->No value specified",sizeof( err7_.message33));
95  strncpy( err7_.message34, "Error No. 34 ->No .END at end of .B",sizeof( err7_.message34));
96  strncpy( err7_.message35, "Error No. 35 ->Zulu,DR or DI coded with send code QY,PY or HY",sizeof(err7_.message35));
97  strncpy( err8_.message36, "Error No. 36 ->The explicit date referenced by DRE is not the end of the month",sizeof(err8_.message36));
98  strncpy( err8_.message37, "Error No. 37 ->Obervation or creation time is between 020001 and 025959",sizeof(err8_.message37));
99  strncpy( err8_.message371, "on the date of change from standard to daylight time",sizeof(err8_.message371) );
100  strncpy( err8_.message38, "Warning No.38 ->No check for daylight savings time-year out of bounds [1976-2020]",sizeof(err8_.message38));
101  strncpy( err8_.message39, "Error No. 39 ->Embedded database comments with internal comments not allowed",sizeof(err8_.message39));
102  strncpy( err8_.message40, "Error No. 40 ->Database comment too long",sizeof(err8_.message40));
103 
104  days_.iday[0] = 31;
105  days_.iday[1] = 28;
106  days_.iday[2] = 31;
107  days_.iday[3] = 30;
108  days_.iday[4] = 31;
109  days_.iday[5] = 30;
110  days_.iday[6] = 31;
111  days_.iday[7] = 31;
112  days_.iday[8] = 30;
113  days_.iday[9] = 31;
114  days_.iday[10] = 30;
115  days_.iday[11] = 31;
116 
117 
118  /* Daylight/Standard Switch over Dates */
119  /* The switch over dates for daylight and standard time for the
120  years 1976 through 2020 are contained in the structure
121  datet_.itable[][].
122  In 1987, the law went into effect that made the change over
123  on the first Sunday in April, and the last Sunday in October.
124  The datet_.itable[y][x] structure contains years 1976 - 2020.
125  The [y] index contains the years..the [x] index is sized to
126  2 elements. The first element is the switchover day in
127  April, the second element is the switchover day in
128  October.
129  The change occurs at 2AM.
130  */
131 
132  /* 1976 */
133  datet_.itable[0][0] = 26;
134  datet_.itable[0][1] = 31;
135 
136  /* 1977 */
137  datet_.itable[1][0] = 24;
138  datet_.itable[1][1] = 30;
139 
140  /* 1978 */
141  datet_.itable[2][0] = 30;
142  datet_.itable[2][1] = 29;
143 
144  /* 1979 */
145  datet_.itable[3][0] = 29;
146  datet_.itable[3][1] = 28;
147 
148  /* 1980 */
149  datet_.itable[4][0] = 27;
150  datet_.itable[4][1] = 26;
151 
152  /* 1981 */
153  datet_.itable[5][0] = 26;
154  datet_.itable[5][1] = 25;
155 
156  /* 1982 */
157  datet_.itable[6][0] = 25;
158  datet_.itable[6][1] = 31;
159 
160  /* 1983 */
161  datet_.itable[7][0] = 24;
162  datet_.itable[7][1] = 30;
163 
164  /* 1984 */
165  datet_.itable[8][0] = 29;
166  datet_.itable[8][1] = 28;
167 
168  /* 1985 */
169  datet_.itable[9][0] = 28;
170  datet_.itable[9][1] = 27;
171 
172  /* 1986 */
173  datet_.itable[10][0] = 27;
174  datet_.itable[10][1] = 26;
175 
176  /* 1987 */
177  datet_.itable[11][0] = 5;
178  datet_.itable[11][1] = 25;
179 
180  /* 1988 */
181  datet_.itable[12][0] = 3;
182  datet_.itable[12][1] = 30;
183 
184  /* 1989 */
185  datet_.itable[13][0] = 2;
186  datet_.itable[13][1] = 29;
187 
188  /* 1990 */
189  datet_.itable[14][0] = 1;
190  datet_.itable[14][1] = 28;
191 
192  /* 1991 */
193  datet_.itable[15][0] = 7;
194  datet_.itable[15][1] = 27;
195 
196  /* 1992 */
197  datet_.itable[16][0] = 5;
198  datet_.itable[16][1] = 25;
199 
200  /* 1993 */
201  datet_.itable[17][0] = 4;
202  datet_.itable[17][1] = 31;
203 
204  /* 1994 */
205  datet_.itable[18][0] = 3;
206  datet_.itable[18][1] = 30;
207 
208  /* 1995 */
209  datet_.itable[19][0] = 2;
210  datet_.itable[19][1] = 29;
211 
212  /* 1996 */
213  datet_.itable[20][0] = 7;
214  datet_.itable[20][1] = 27;
215 
216  /* 1997 */
217  datet_.itable[21][0] = 6;
218  datet_.itable[21][1] = 26;
219 
220  /* 1998 */
221  datet_.itable[22][0] = 5;
222  datet_.itable[22][1] = 25;
223 
224  /* 1999 */
225  datet_.itable[23][0] = 4;
226  datet_.itable[23][1] = 31;
227 
228  /* 2000 */
229  datet_.itable[24][0] = 2;
230  datet_.itable[24][1] = 29;
231 
232  /* 2001 */
233  datet_.itable[25][0] = 1;
234  datet_.itable[25][1] = 28;
235 
236  /* 2002 */
237  datet_.itable[26][0] = 7;
238  datet_.itable[26][1] = 27;
239 
240  /* 2003 */
241  datet_.itable[27][0] = 6;
242  datet_.itable[27][1] = 26;
243 
244  /* 2004 */
245  datet_.itable[28][0] = 4;
246  datet_.itable[28][1] = 31;
247 
248  /* 2005 */
249  datet_.itable[29][0] = 3;
250  datet_.itable[29][1] = 30;
251 
252  /* 2006 */
253  datet_.itable[30][0] = 2;
254  datet_.itable[30][1] = 29;
255 
256  /* 2007 These dates are now for March and November RKH 101812*/
257 
258  datet_.itable[31][0] = 11;
259  datet_.itable[31][1] = 4;
260 
261  /* 2008 */
262  datet_.itable[32][0] = 9;
263  datet_.itable[32][1] = 2;
264 
265  /* 2009 */
266  datet_.itable[33][0] = 8;
267  datet_.itable[33][1] = 1;
268 
269  /* 2010 */
270  datet_.itable[34][0] = 14;
271  datet_.itable[34][1] = 7;
272 
273  /* 2011 */
274  datet_.itable[35][0] = 13;
275  datet_.itable[35][1] = 6;
276 
277  /* 2012 */
278  datet_.itable[36][0] = 11; /* corrected index typo here RKH 101812 */
279  datet_.itable[36][1] = 4;
280 
281  /* 2013 */
282  datet_.itable[37][0] = 10;
283  datet_.itable[37][1] = 3;
284 
285  /* 2014 */
286  datet_.itable[38][0] = 9;
287  datet_.itable[38][1] = 2;
288 
289  /* 2015 */
290  datet_.itable[39][0] = 8;
291  datet_.itable[39][1] = 1;
292 
293  /* 2016 */
294  datet_.itable[40][0] = 13;
295  datet_.itable[40][1] = 6;
296 
297  /* 2017 */
298  datet_.itable[41][0] = 12;
299  datet_.itable[41][1] = 5;
300 
301  /* 2018 */
302  datet_.itable[42][0] = 11;
303  datet_.itable[42][1] = 4;
304 
305  /* 2019 */
306  datet_.itable[43][0] = 10;
307  datet_.itable[43][1] = 3;
308 
309  /* 2020 */
310  datet_.itable[44][0] = 8;
311  datet_.itable[44][1] = 1;
312 
313  /* Character Assignments */
314 
315  codes_.icha = 'A';
316  codes_.ichb = 'B';
317  codes_.ichc = 'C';
318  codes_.ichd = 'D';
319  codes_.iche = 'E';
320  codes_.ichf = 'F';
321  codes_.ichg = 'G';
322  codes_.ichh = 'H';
323  codes_.ichi = 'I';
324  codes_.ichj = 'J';
325  codes_.ichk = 'K';
326  codes_.ichl = 'L';
327  codes_.ichm = 'M';
328  codes_.ichn = 'N';
329  codes_.icho = 'O';
330  codes_.ichp = 'P';
331  codes_.ichq = 'Q';
332  codes_.ichr = 'R';
333  codes_.ichs = 'S';
334  codes_.icht = 'T';
335  codes_.ichu = 'U';
336  codes_.ichv = 'V';
337  codes_.ichw = 'W';
338  codes_.ichx = 'X';
339  codes_.ichy = 'Y';
340  codes_.ichz = 'Z';
341  codes_.ich0 = '0';
342  codes_.ich1 = '1';
343  codes_.ich2 = '2';
344  codes_.ich3 = '3';
345  codes_.ich4 = '4';
346  codes_.ich5 = '5';
347  codes_.ich6 = '6';
348  codes_.ich7 = '7';
349  codes_.ich8 = '8';
350  codes_.ich9 = '9';
351  codes_.iblnk = ' ';
352  codes_.islash = '/';
353  codes_.icolon = ':';
354  codes_.iplus = '+';
355  codes_.iminus = '-';
356  codes_.idot = '.';
357  codes_.iarrow = '>';
358  codes_.icomma = ',';
359  codes_.iscore = '_';
360  codes_.dquote = '"'; /* dgb:09/10/97 */
361 
362  /* Last Day of the Month */
363 
364 } /* end of function */
365 
366 
void blk_data()
Definition: blockdata.c:53
struct t_err3_ err3_
struct t_err1_ err1_
struct t_err8_ err8_
struct t_err7_ err7_
struct t_codes_ codes_
struct t_err5_ err5_
struct t_err4_ err4_
struct t_err6_ err6_
struct t_days_ days_
struct t_err2_ err2_
struct t_datet_ datet_
short int ich7
Definition: shef_structs.h:81
short int iblnk
Definition: shef_structs.h:81
short int iche
Definition: shef_structs.h:78
short int ich5
Definition: shef_structs.h:81
short int ichq
Definition: shef_structs.h:79
short int ichl
Definition: shef_structs.h:79
short int ichs
Definition: shef_structs.h:79
short int ichk
Definition: shef_structs.h:79
short int iarrow
Definition: shef_structs.h:82
short int ichz
Definition: shef_structs.h:80
short int ichy
Definition: shef_structs.h:80
short int ich0
Definition: shef_structs.h:80
short int ich4
Definition: shef_structs.h:80
short int ichd
Definition: shef_structs.h:78
short int icho
Definition: shef_structs.h:79
short int ichv
Definition: shef_structs.h:80
short int iplus
Definition: shef_structs.h:81
short int ichm
Definition: shef_structs.h:79
short int ichu
Definition: shef_structs.h:80
short int ichc
Definition: shef_structs.h:78
short int ich6
Definition: shef_structs.h:81
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 icolon
Definition: shef_structs.h:81
short int ichp
Definition: shef_structs.h:79
short int ichh
Definition: shef_structs.h:78
short int ich1
Definition: shef_structs.h:80
short int ichw
Definition: shef_structs.h:80
short int ichr
Definition: shef_structs.h:79
short int ichj
Definition: shef_structs.h:79
short int ich2
Definition: shef_structs.h:80
short int iminus
Definition: shef_structs.h:81
short int iscore
Definition: shef_structs.h:82
short int ich8
Definition: shef_structs.h:81
short int icomma
Definition: shef_structs.h:82
short int ich9
Definition: shef_structs.h:81
short int ichg
Definition: shef_structs.h:78
short int dquote
Definition: shef_structs.h:82
short int ich3
Definition: shef_structs.h:80
short int ichn
Definition: shef_structs.h:79
short int icht
Definition: shef_structs.h:79
short int ichb
Definition: shef_structs.h:78
short int idot
Definition: shef_structs.h:82
short int ichx
Definition: shef_structs.h:80
short int ichf
Definition: shef_structs.h:78
short int itable[45][2]
Definition: shef_structs.h:174
short int iday[12]
Definition: shef_structs.h:171
char message3[62]
Definition: shef_structs.h:135
char message2[43]
Definition: shef_structs.h:135
char message5[63]
Definition: shef_structs.h:135
char message4[29]
Definition: shef_structs.h:135
char message1[37]
Definition: shef_structs.h:135
char message7[34]
Definition: shef_structs.h:138
char message8[38]
Definition: shef_structs.h:138
char message6[57]
Definition: shef_structs.h:138
char message9[40]
Definition: shef_structs.h:138
char message10[32]
Definition: shef_structs.h:138
char message14[61]
Definition: shef_structs.h:141
char message15[51]
Definition: shef_structs.h:142
char message13[47]
Definition: shef_structs.h:141
char message11[45]
Definition: shef_structs.h:141
char message12[32]
Definition: shef_structs.h:141
char message19[75]
Definition: shef_structs.h:145
char message16[44]
Definition: shef_structs.h:145
char message17[43]
Definition: shef_structs.h:145
char message18[48]
Definition: shef_structs.h:145
char message20[66]
Definition: shef_structs.h:146
char message25[38]
Definition: shef_structs.h:150
char message221[58]
Definition: shef_structs.h:149
char message23[51]
Definition: shef_structs.h:149
char message24[32]
Definition: shef_structs.h:150
char message22[67]
Definition: shef_structs.h:149
char message21[63]
Definition: shef_structs.h:149
char message30[45]
Definition: shef_structs.h:154
char message26[29]
Definition: shef_structs.h:153
char message27[29]
Definition: shef_structs.h:153
char message28[64]
Definition: shef_structs.h:153
char message29[43]
Definition: shef_structs.h:153
char message33[34]
Definition: shef_structs.h:157
char message35[79]
Definition: shef_structs.h:158
char message32[48]
Definition: shef_structs.h:157
char message31[41]
Definition: shef_structs.h:157
char message34[36]
Definition: shef_structs.h:157
char message39[77]
Definition: shef_structs.h:162
char message37[72]
Definition: shef_structs.h:161
char message38[82]
Definition: shef_structs.h:161
char message36[80]
Definition: shef_structs.h:161
char message371[53]
Definition: shef_structs.h:161
char message40[41]
Definition: shef_structs.h:162