Mapper
get_forecast_station_list.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 int max_stations;
12  extern struct fstation fstation[500];
13  extern int max_fstations;
14  FILE *fp;
15  char *p,kbuf[150];
16  int i,ier;
17  int m,l,h,k,j;
18  int kk,ii;
19  char dbuf[10],tbuf[10],wfo[10];
20  extern char *txbuf[3];
21  int n;
22 
23  max_fstations=0;
24 
25  fp=fopen(fname,"r");
26 
27  if(fp==NULL) {
28 
29  printf("could not open forecast station_list %s\n",fname);
30  exit(1);
31 
32  }
33 
34  i=0;
35 
36  for(ii=0;ii<500;ii++) {
37 
38  p=fgets(kbuf,100,fp);
39  if(p==NULL)
40  break;
41 
42  p=strchr(kbuf,'\n');
43 
44  if(p!=NULL)
45  *p=0;
46 
47 
48  *(txbuf[0])=0;
49  *(txbuf[1])=0;
50  *(txbuf[2])=0;
51 
52  ier=sscanf(kbuf,"%s %s %s %s %s",
53  fstation[i].hb5,wfo,txbuf[0],txbuf[1],txbuf[2]);
54 
55  if(ier < 1)
56  continue;
57 
58  j=0;
59  while(wfo[j] != 0) {
60 
61  wfo[j]=tolower(wfo[j]);
62  j++;
63 
64  }
65 
66  for(j=0;j<max_stations;j++) {
67 
68  if(strcmp(fstation[i].hb5,station[j].hb5)==0 ) {
69 
70  fstation[i].owner=-1;
71 
72  for(m=0;m<20;m++) {
73 
74  if(strcmp(wfo,tag[m].wfo)==0) {
75 
76  fstation[i].owner=m;
77  break;
78 
79  }
80 
81  }
82 
83  fstation[i].qpf=-1;
84  fstation[i].frz=-1;
85  fstation[i].txn=-1;
86 
87  fstation[i].index=j;
88 
89  for(n=0;n<60;n++) {
90 
91  fdata[n].fstn[j].rain=calloc(5,sizeof(float));
92  fdata[n].fstn[j].frz=calloc(5,sizeof(float));
93  fdata[n].fstn[j].tx=calloc(5,sizeof(int));
94  fdata[n].fstn[j].tn=calloc(5,sizeof(int));
95 
96 
97  for(k=0;k<5;k++) {
98 
99  fdata[n].fstn[j].rain[k]=-9999;
100  fdata[n].fstn[j].frz[k]=-9999;
101  fdata[n].fstn[j].tx[k]=-9999;
102  fdata[n].fstn[j].tn[k]=-9999;
103 
104  }
105 
106 
107  }
108 
109  if(ier==5 || ier==2) {
110 
111  fstation[i].qpf=1;
112  fstation[i].frz=1;
113  fstation[i].txn=1;
114 
115  }
116 
117  else {
118 
119  for(m=0;m<3;m++) {
120 
121  if(*(txbuf[m])==0)
122  continue;
123 
124  if(strcmp(txbuf[m],"HZ")==0)
125  fstation[i].frz=1;
126 
127  else if(strcmp(txbuf[m],"PP")==0)
128  fstation[i].qpf=1;
129 
130  else if(strcmp(txbuf[m],"TA")==0)
131  fstation[i].txn=1;
132 
133 
134 
135  }
136 
137  }
138 
139  i++;
140  break;
141 
142  }
143 
144  }
145 
146  }
147 
148 max_fstations=i;
149 fclose(fp);
150 
151 return;
152 
153 }
154 
155 
156 
157 
158 
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 index
Definition: misc.h:33
int owner
Definition: misc_new.h:101
int frz
Definition: misc.h:35
char hb5[10]
Definition: misc.h:32
int qpf
Definition: misc.h:34
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:296
Definition: misc_new.h:61