Mapper
shpcode.c
Go to the documentation of this file.
1 /*Translated by FOR_C, v3.4.2 (-), on 04/06/95 at 13:56:16 */
2 /*FOR_C Options SET: c=2 com=u do=r44 ftn=ln6kk op=iv s=dvnk 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 SHPCODE(KODP,KODE,ICODD,KODT,KODS,KODEX,CODP,FACTOR,STATUS)
20 
21  PURPOSE
22  This routine gets the parameter code, validates it
23  and interprets it.
24 
25  VERSION and UPDATES
26  1.0 JUL 82 Geoffrey M. Bonnin
27  Original Version
28  1.1 MAY 85
29  Allow for numeric source code
30  2.0 JUN 94 David G. Brandon
31  Also Translated to 'C' using FOR_C
32  PEDSTEP validation is now done in memory. There is
33  no longer disk IO with the shefparm file.
34  Removed alternate returns to subroutines.
35  2.1 OCT 95 DGB
36  Allow for the 'T' in the PEDTSEP to be numeric.
37  Change from fixed array sizes to values read out of the
38  header file. Add iscore to t_codes array.
39 
40  *--------------------------------------------------------------------- */
41 
42 
43 void shpcode(kodp, kode, icodd, kodt, kods, kodex, codp, factor, status)
44 short int *kodp, *kode, *icodd, *kodt, *kods, *kodex;
45 float *codp;
46 double *factor;
47 short int *status;
48 {
49 
50  static short int iend_, inum, irec, ival, jchar, koddd, kodtt;
51  static double value;
52 
53  /* OFFSET Vectors w/subscript range: 1 to dimension */
54  short *const Durvalue = &parms2_.durvalue[0] - 1;
55  short *const Exvalue = &parms2_.exvalue[0] - 1;
56  short *const Numval = &parms2_.numval[0] - 1;
57  double *const Pevalue = &parms3_.pevalue[0] - 1;
58  double *const Provalue = &parms3_.provalue[0] - 1;
59  short *const Sendflag = &parms2_.sendflag[0] - 1;
60  short *const Tsvalue = &parms2_.tsvalue[0] - 1;
61 
62  /* Set defaults */
63  *status = 0;
64  *kodp = codes_.iblnk;
65  *kode = codes_.iblnk;
67  koddd = codes_.iblnk;
68  *kodt = codes_.iblnk;
69  *kods = codes_.iblnk;
70  *kodex = codes_.iblnk;
72  kodtt = codes_.iblnk;
73  *icodd = 0;
74  *codp = -1.0;
75  iend_ = 0;
76  sendflg_.nsflag = 0;
77 
78 
79  /* Search for a non blank character */
80 
81 L_10:
82  if( xchar_.ichar != codes_.iblnk )
83  goto L_20;
84  nextch( &xchar_.ichar, status );
85  if( *status == 1 )
86  {
87  *status = 0;
88  goto L_9500;
89  }
90  else if( *status == 2 )
91  {
92  *status = 0;
93  goto L_9010;
94  }
95  goto L_10;
96 
97  /* Is it a letter ? */
98 
99 L_20:
100 
101  irang( &xchar_.ichar, &codes_.icha, &codes_.ichz, status );
102  if( *status == 1 )
103  {
104  *status = 0;
105  goto L_9020;
106  }
107  jchar = xchar_.ichar;
108 
109  /* Get the second character of 'PE' */
110 
111  nextch( &xchar_.ichar, status );
112  if( *status == 1 )
113  {
114  *status = 0;
115  goto L_9500;
116  }
117  else if( *status == 2 )
118  {
119  *status = 0;
120  goto L_9010;
121  }
122 
123  irang( &xchar_.ichar, &codes_.icha, &codes_.ichz, status );
124  if( *status == 1 )
125  {
126  *status = 0;
127  goto L_9020;
128  }
129  *kodp = jchar;
130  *kode = xchar_.ichar;
131 
132  /* Get the 'D' character */
133 
134  nextch( &xchar_.ichar, status );
135  if( *status == 1 )
136  {
137  *status = 0;
138  goto L_65;
139  }
140  else if( *status == 2 )
141  {
142  *status = 0;
143  goto L_9010;
144  }
145  if( xchar_.ichar == codes_.iblnk )
146  goto L_70;
147  if( xchar_.ichar == codes_.islash )
148  goto L_70;
149  irang( &xchar_.ichar, &codes_.icha, &codes_.ichz, status );
150  if( *status == 1 )
151  {
152  *status = 0;
153  goto L_9020;
154  }
156 
157  /* Get the 'T' of the 'TS' code */
158 
159  nextch( &xchar_.ichar, status );
160  if( *status == 1 )
161  {
162  *status = 0;
163  goto L_65;
164  }
165  else if( *status == 2 )
166  {
167  *status = 0;
168  goto L_9010;
169  }
170 
171  if( xchar_.ichar == codes_.iblnk )
172  goto L_70;
173  if( xchar_.ichar == codes_.islash )
174  goto L_70;
175  irang( &xchar_.ichar, &codes_.icha, &codes_.ichz, status );
176 
177  /* dgb:10/16/95 allow for 'T' to be numeric */
178  if( *status == 1 )
179  {
180  *status = 0;
181  irang( &xchar_.ichar, &codes_.ich1, &codes_.ich9, status );
182  if( *status == 1 )
183  {
184  *status = 0;
185  goto L_9020;
186  }
187  }
188 
189 
190  *kodt = xchar_.ichar;
191 
192  /* Get the 'S' of the 'TS' code */
193 
194  nextch( &xchar_.ichar, status );
195  if( *status == 1 )
196  {
197  *status = 0;
198  goto L_65;
199  }
200  else if( *status == 2 )
201  {
202  *status = 0;
203  goto L_9010;
204  }
205 
206  if( xchar_.ichar == codes_.iblnk )
207  goto L_70;
208  if( xchar_.ichar == codes_.islash )
209  goto L_70;
210  irang( &xchar_.ichar, &codes_.icha, &codes_.ichz, status );
211  if( *status == 1 )
212  {
213  *status = 0;
214  goto L_30;
215  }
216  goto L_40;
217 
218 L_30:
219  irang( &xchar_.ichar, &codes_.ich1, &codes_.ich9, status );
220  if( *status == 1 )
221  {
222  *status = 0;
223  goto L_9020;
224  }
225 L_40:
226  *kods = xchar_.ichar;
227 
228  /* Get the 'E' of the extremum code */
229 
230  nextch( &xchar_.ichar, status );
231  if( *status == 1 )
232  {
233  *status = 0;
234  goto L_65;
235  }
236  else if( *status == 2 )
237  {
238  *status = 0;
239  goto L_9010;
240  }
241 
242  if( xchar_.ichar == codes_.iblnk )
243  goto L_70;
244  if( xchar_.ichar == codes_.islash )
245  goto L_70;
246  irang( &xchar_.ichar, &codes_.icha, &codes_.ichz, status );
247  if( *status == 1 )
248  {
249  *status = 0;
250  goto L_9020;
251  }
252  *kodex = xchar_.ichar;
253 
254  /* Get the 'P' of the probability code */
255 
256  nextch( &xchar_.ichar, status );
257  if( *status == 1 )
258  {
259  *status = 0;
260  goto L_65;
261  }
262  else if( *status == 2 )
263  {
264  *status = 0;
265  goto L_9010;
266  }
267 
268  if( xchar_.ichar == codes_.iblnk )
269  goto L_70;
270  if( xchar_.ichar == codes_.islash )
271  goto L_70;
272  irang( &xchar_.ichar, &codes_.icha, &codes_.ichz, status );
273  if( *status == 1 )
274  {
275  *status = 0;
276  goto L_50;
277  }
278  goto L_60;
279 
280 L_50:
281  irang( &xchar_.ichar, &codes_.ich1, &codes_.ich9, status );
282  if( *status == 1 )
283  {
284  *status = 0;
285  goto L_9020;
286  }
287 L_60:
289  nextch( &xchar_.ichar, status );
290  if( *status == 1 )
291  {
292  *status = 0;
293  goto L_65;
294  }
295  else if( *status == 2 )
296  {
297  *status = 0;
298  goto L_9010;
299  }
300 
301  goto L_70;
302 
303  /* Validate the 'PE' code */
304 
305 L_65:
306  iend_ = 1;
307 L_70:
308  inum = 1;
309  checkparm( kodp, kode, &durprob_.kodd, kodt, kods, kodex, &durprob_.kodpr,
310  factor, &ival, &inum );
311  if( *factor < -1.5e0 )
312  goto L_9040;
313 
314  /* Check for send codes */
315 
316  inum = 6;
317  checkparm( kodp, kode, &durprob_.kodd, kodt, kods, kodex, &durprob_.kodpr,
318  &value, &irec, &inum );
319  if( irec <= 0 )
320  goto L_90;
321 
322  *kodp = parms2_.sendcodes[irec - 1][0];
323  *kode = parms2_.sendcodes[irec - 1][1];
324  koddd = parms2_.sendcodes[irec - 1][2];
325  kodtt = parms2_.sendcodes[irec - 1][3];
326  if( (durprob_.kodd != codes_.iblnk) && (kodtt != codes_.iblnk) )
327  goto L_9050;
328  if( durprob_.kodd != codes_.iblnk )
329  goto L_90;
330 
331  durprob_.kodd = koddd;
332  *kodt = kodtt;
333  sendflg_.nsflag = 0;
334 
335  *kods = parms2_.sendcodes[irec - 1][4];
336  *kodex = parms2_.sendcodes[irec - 1][5];
337  durprob_.kodpr = parms2_.sendcodes[irec - 1][6];
338 
339  sendflg_.nsflag = Sendflag[irec];
340 
341  /* Validate and Interprept the Duration Code */
342 
343 L_90:
344  if( durprob_.kodd == codes_.iblnk )
345  goto L_140;
346  if( durprob_.kodd != codes_.ichz )
347  goto L_92;
348  if( koddd == codes_.iblnk )
349  goto L_95;
350  durprob_.kodd = koddd;
351 
352 L_92:
353  inum = 2;
354  checkparm( kodp, kode, &durprob_.kodd, kodt, kods, kodex, &durprob_.kodpr,
355  &value, &ival, &inum );
356  if( ival == -9 )
357  goto L_9040;
358  *icodd = ival;
359 
360  /* Validate the 'TS' code */
361 
362 L_95:
363  if( *kodt == codes_.iblnk )
364  goto L_140;
365  if( *kods == codes_.iblnk )
366  *kods = codes_.ichz;
367  if( *kodt != codes_.ichz )
368  goto L_98;
369  if( *kods != codes_.ichz )
370  goto L_9040;
371  goto L_105;
372 
373 L_98:
374  irang( kods, &codes_.ich1, &codes_.ich9, status );
375  if( *status == 1 )
376  {
377  *status = 0;
378  goto L_99;
379  }
380  goto L_100;
381 
382 L_99:
383  inum = 3;
384  checkparm( kodp, kode, &durprob_.kodd, kodt, kods, kodex, &durprob_.kodpr,
385  &value, &ival, &inum );
386 
387 L_100:
388  if( ival < 0 )
389  goto L_9040;
390 
391  /* Validate the extremum code */
392 
393 L_105:
394  if( *kodex == codes_.iblnk )
395  goto L_160;
396  inum = 4;
397  checkparm( kodp, kode, &durprob_.kodd, kodt, kods, kodex, &durprob_.kodpr,
398  &value, &ival, &inum );
399  if( ival < 0 )
400  goto L_9040;
401 
402  /* Validate and interpret the probability code */
403 
404  if( durprob_.kodpr == codes_.iblnk )
405  goto L_9000;
406  irang( &durprob_.kodpr, &codes_.icha, &codes_.ichz, status );
407  if( *status == 1 )
408  {
409  *status = 0;
410  goto L_110;
411  }
412 
413 L_110:
414  inum = 5;
415  checkparm( kodp, kode, &durprob_.kodd, kodt, kods, kodex, &durprob_.kodpr,
416  &value, &ival, &inum );
417  if( value < -8.0e0 )
418  goto L_9040;
419  *codp = value;
420  goto L_9000;
421 
422  /* Real defaults */
423 
424 L_140:
425  *kodt = codes_.ichr;
426  *kods = codes_.ichz;
427 L_160:
428  *kodex = codes_.ichz;
429 
430  /* Got it - return */
431 
432 L_9000:
433  if( durprob_.kodd == codes_.iblnk )
435  if( durprob_.kodpr == codes_.iblnk )
437  if( iend_ == 1 )
438  goto L_9600;
439  return;
440 
441  /* Error returns */
442 
443 L_9010:
444  *status = 2;
445  return;
446 
447 L_9020:
448  inum = 15;
449  goto L_9400;
450 
451 L_9040:
452  inum = 17;
453  goto L_9400;
454 
455 L_9050:
456  inum = 18;
457 
458 L_9400:
459  sherr( &inum );
460  format_.nerr = 1;
461 
462 L_9500:
463  *status = 1;
464  return;
465 
466 L_9600:
467  *status = 3;
468  return;
469 
470 }
471 
void checkparm(short int *kodp, short int *kode, short int *kodd, short int *kodt, short int *kods, short int *kodex, short int *kodpr, double *value, short int *ival, short int *inum)
Definition: checkparm.c:35
void irang(short int *i, short int *min_, short int *max_, short int *status)
Definition: irang.c:33
void nextch(short int *ichar, short int *status)
Definition: nextch.c:76
float value
struct t_codes_ codes_
struct t_parms2_ parms2_
struct t_format_ format_
struct t_parms3_ parms3_
struct t_xchar_ xchar_
struct t_sendflg_ sendflg_
struct t_durprob_ durprob_
void sherr(short int *ier)
Definition: sherr.c:44
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
short int iblnk
Definition: shef_structs.h:81
short int ichz
Definition: shef_structs.h:80
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 ich1
Definition: shef_structs.h:80
short int ichr
Definition: shef_structs.h:79
short int ich9
Definition: shef_structs.h:81
short int kodd
Definition: shef_structs.h:97
short int kodpr
Definition: shef_structs.h:97
short int nerr
Definition: shef_structs.h:129
short int numval[7]
Definition: shef_structs.h:90
char sendcodes[NUM_SENVAL][7]
Definition: shef_structs.h:91
short int exvalue[NUM_EXVAL]
Definition: shef_structs.h:89
short int durvalue[NUM_DURVAL]
Definition: shef_structs.h:89
short int tsvalue[NUM_TSVAL]
Definition: shef_structs.h:89
short int sendflag[NUM_SENVAL]
Definition: shef_structs.h:90
double provalue[NUM_PROVAL]
Definition: shef_structs.h:94
double pevalue[NUM_PEVAL]
Definition: shef_structs.h:94
short int nsflag
Definition: shef_structs.h:115
short int ichar
Definition: shef_structs.h:112