Mapper
get_forecast_station_list_new.c
Go to the documentation of this file.
1 #include "prototypes_new.h"
2 
4 
5 {
6 
7  extern struct fdata fdata[60];
8  extern int isom;
9  extern struct tag tag[20];
10  extern struct station station[3000];
11  extern struct station zstation[750];
12  extern struct station tstation[1000];
13  extern int max_stations;
14  extern int max_zstations;
15  extern int max_tstations;
16  extern struct fstation fstation[1000];
17  extern int max_fstations;
18  FILE *fp;
19  char *p,kbuf[150];
20  int i,ier;
21  int m,l,h,k,j;
22  int kk,ii;
23  char dbuf[10],tbuf[10],wfo[10];
24  extern char *txbuf[3];
25  int n;
26 
27  max_fstations=0;
28 
29  fp=fopen(fname,"r");
30 
31  if(fp==NULL) {
32 
33  printf("could not open forecast station_list %s\n",fname);
34  exit(1);
35 
36  }
37 
38  i=0;
39 
40  for(ii=0;ii<1000;ii++) {
41 
42  p=fgets(kbuf,100,fp);
43  if(p==NULL)
44  break;
45 
46  p=strchr(kbuf,'\n');
47 
48  if(p!=NULL)
49  *p=0;
50 
51  *(txbuf[0])=0;
52  *(txbuf[1])=0;
53  *(txbuf[2])=0;
54 
55 
56  ier=sscanf(kbuf,"%s %s %s %s %s",
57  fstation[i].hb5,wfo,txbuf[0],txbuf[1],txbuf[2]);
58 
59  if(ier < 1)
60  continue;
61 
62  j=0;
63  while(wfo[j] != 0) {
64 
65  wfo[j]=tolower(wfo[j]);
66  j++;
67 
68  }
69 
70 
71  fstation[i].qpf=-1;
72  fstation[i].frz=-1;
73  fstation[i].txn=-1;
74  fstation[i].pindex=-1;
75  fstation[i].zindex=-1;
76  fstation[i].tindex=-1;
77 
78 
79  if(ier==5 || ier==2) {
80 
81  fstation[i].qpf=1;
82  fstation[i].frz=1;
83  fstation[i].txn=1;
84 
85  }
86 
87  else {
88 
89  for(m=0;m<3;m++) {
90 
91  if(*(txbuf[m])==0)
92  continue;
93 
94  if(strcmp(txbuf[m],"HZ")==0)
95  fstation[i].frz=1;
96 
97  else if(strcmp(txbuf[m],"PP")==0)
98  fstation[i].qpf=1;
99 
100  else if(strcmp(txbuf[m],"TA")==0) {
101 
102 
103  fstation[i].txn=1;
104 
105  }
106 
107  }
108 
109  }
110 
111  if(fstation[i].qpf == 1) {
112 
113  for(j=0;j<max_stations;j++) {
114 
115  if(strcmp(fstation[i].hb5,station[j].hb5)==0 ) {
116 
117  fstation[i].owner=-1;
118 
119  for(m=0;m<20;m++) {
120 
121  if(strcmp(wfo,tag[m].wfo)==0) {
122 
123  fstation[i].owner=m;
124  break;
125 
126  }
127 
128  }
129 
130  fstation[i].pindex=j;
131 
132  for(n=0;n<60;n++) {
133 
134  fdata[n].fstn[j].rain=calloc(5,sizeof(float));
135 
136 
137  for(k=0;k<5;k++)
138  fdata[n].fstn[j].rain[k]=-9999;
139 
140  }
141 
142  break;
143 
144  }
145 
146 
147  }
148 
149  }
150 
151  if(fstation[i].frz == 1) {
152 
153  for(j=0;j<max_zstations;j++) {
154 
155  if(strcmp(fstation[i].hb5,zstation[j].hb5)==0 ) {
156 
157  fstation[i].owner=-1;
158 
159  for(m=0;m<20;m++) {
160 
161  if(strcmp(wfo,tag[m].wfo)==0) {
162 
163  fstation[i].owner=m;
164  break;
165 
166  }
167 
168  }
169 
170  fstation[i].zindex=j;
171 
172 
173 
174  for(n=0;n<60;n++) {
175 
176 
177 
178  fdata[n].fstn[j].frz=calloc(5,sizeof(float));
179 
180  for(k=0;k<5;k++)
181  fdata[n].fstn[j].frz[k]=-9999;
182 
183  }
184 
185  break;
186 
187  }
188 
189 
190  }
191 
192 
193  }
194 
195 
196  if(fstation[i].txn == 1) {
197 
198 
199 
200  for(j=0;j<max_tstations;j++) {
201 
202  if(strcmp(fstation[i].hb5,tstation[j].hb5)==0 ) {
203 
204 
205 
206  fstation[i].owner=-1;
207 
208  for(m=0;m<20;m++) {
209 
210  if(strcmp(wfo,tag[m].wfo)==0) {
211 
212  fstation[i].owner=m;
213  break;
214 
215  }
216 
217  }
218 
219  fstation[i].tindex=j;
220 
221  for(n=0;n<60;n++) {
222 
223  fdata[n].fstn[j].tx=calloc(5,sizeof(int));
224  fdata[n].fstn[j].tn=calloc(5,sizeof(int));
225 
226 
227  for(k=0;k<5;k++) {
228 
229  fdata[n].fstn[j].tx[k]=-9999;
230  fdata[n].fstn[j].tn[k]=-9999;
231 
232  }
233 
234 
235  }
236 
237  break;
238 
239  }
240 
241 
242  }
243 
244 
245  }
246 
247  if(fstation[i].tindex == -1)
248  fstation[i].txn=-1;
249 
250  if(fstation[i].pindex == -1)
251  fstation[i].qpf=-1;
252 
253  if(fstation[i].zindex == -1)
254  fstation[i].frz=-1;
255 
256 
257  i++;
258 
259 
260  }
261 
262 max_fstations=i;
263 fclose(fp);
264 
265 
266 return;
267 
268 }
269 
270 
271 
272 
273 
static int i
void get_forecast_station_list(char *fname)
fclose(fp)
printf("fbuf is %s\n", fbuf)
fp
Definition: make_NEXRAD.c:339
int j
Definition: mapp2h.h:48
int k
Definition: mapp2h.h:48
int max_stations
Definition: mapper.c:64
char fname[100]
Definition: send_afos.c:6
Definition: misc.h:23
struct fstn fstn[1500]
Definition: misc.h:25
Definition: misc.h:30
int txn
Definition: misc_new.h:99
int tindex
Definition: misc_new.h:95
int owner
Definition: misc_new.h:101
int zindex
Definition: misc_new.h:96
int pindex
Definition: misc_new.h:94
int frz
Definition: misc.h:35
char hb5[10]
Definition: misc.h:32
int qpf
Definition: misc.h:34
Definition: misc.h:16
float rain[5]
Definition: misc.h:18
float frz[5]
Definition: misc.h:19
int * tn
Definition: misc_new.h:80
int * tx
Definition: misc_new.h:79
Definition: misc.h:255
Definition: misc.h:296
Definition: misc_new.h:61