Mapper
make_fzelv_file.c
Go to the documentation of this file.
1 #define _POSIX_SOURCE
2 #include "prototypes_new.h"
3 
5 
6 {
7 
8 extern char rfc[10];
9 extern int mode;
10 extern char shef_source[50];
11 extern int wfo_orig;
12 extern time_t tim;
13 extern char fmaz_file[100];
14 extern struct map map[1500];
15 FILE *fo;
16 int ib,j;
17 char fbuf[100];
18 char *spaces,xbuf[300],mbuf[100];
19 int len,k;
20 struct tm *gmtim;
21 float temp;
22 int itim;
23 int numzones;
24 int i;
25 char pchar[2];
26 time_t stim;
27 int kk;
28 time_t ctim;
29 int year,month,day,hour,min;
30 char dcbuf[100];
31 
32 printf("starting\n");
33 
34 ctim=time(NULL);
35 
36 gmtim=gmtime(&ctim);
37 
38 year=gmtim->tm_year+1900;
39 month=gmtim->tm_mon+1;
40 day=gmtim->tm_mday;
41 hour=gmtim->tm_hour;
42 min=0;
43 
44 /*
45 if(dcbuf[0]==0) */
46 
47  sprintf(dcbuf,"%04d%02d%02d%02d",year,month,day,hour);
48 
49 pchar[1]=0;
50 
51 spaces=" ";
52 
53 gmtim=gmttime(&tim);
54 
55 sprintf(fbuf,"%s%02d-%02d-%02d",fmaz_file,gmtim->tm_mon+1,gmtim->tm_mday,
56  gmtim->tm_year);
57 
58 fo=fopen(fbuf,"w");
59 
60 if(fo==NULL) {
61 
62  printf("could not open %s\n",fbuf);
63 
64  exit(1);
65 
66  }
67 
68 chmod(fbuf,S_IRUSR | S_IWUSR |
69  S_IRGRP | S_IWGRP |
70  S_IROTH | S_IWOTH);
71 
72 stim=tim-86400;
73 gmtim=gmtime(&stim);
74 
75 printf("thru\n");
76 
77 for(ib=0;map[ib].hb5[0]!=0;ib++){
78 
79  if(mode==0) {
80 
81  if(wfo_orig != map[ib].owner)
82  continue;
83 
84  }
85 
86  numzones=0;
87  for(j=0;j < 4;j++) {
88 
89  if(map[ib].zones[j] < 0)
90  continue;
91 
92  numzones++;
93 
94  }
95 
96 
97  for(j=0;j < 4;j++) {
98 
99  if(map[ib].zones[j] < 0)
100  continue;
101 
102  strcpy(xbuf,".ER ");
103  strcat(xbuf,map[ib].hb5);
104 
105  i=0;
106  while(xbuf[i] != 0)
107  xbuf[i++]=toupper(xbuf[i]);
108 
109 
110  if(strcmp(rfc,"cbrfc")==0 &&
111  strlen(map[ib].hb5)==7) {
112 
113  printf("polygon write\n");
114 
115  pchar[0]=map[ib].bchar[0];
116  strcat(xbuf,pchar);
117 
118  }
119 
120  else {
121 
122  if(j==0 && numzones != 1) {
123 
124  strcat(xbuf,"L");
125  pchar[0]=map[ib].bchar[0];
126  strcat(xbuf,pchar);
127 
128  }
129 
130 
131  else if(j==0 && numzones == 1) {
132 
133  strcat(xbuf,"O");
134  pchar[0]=map[ib].bchar[0];
135  strcat(xbuf,pchar);
136 
137  }
138 
139 
140  else if(j==1) {
141 
142  strcat(xbuf,"M");
143  pchar[0]=map[ib].bchar[1];
144  strcat(xbuf,pchar);
145 
146  }
147 
148  else if(j==2) {
149 
150  strcat(xbuf,"U");
151  pchar[0]=map[ib].bchar[2];
152  strcat(xbuf,pchar);
153 
154  }
155 
156  else if(j==3) {
157 
158  strcat(xbuf,"G");
159  pchar[0]=map[ib].bchar[3];
160  strcat(xbuf,pchar);
161 
162  }
163 
164  }
165 
166  sprintf(mbuf," %04d%02d%02d",gmtim->tm_year+1900,
167  gmtim->tm_mon+1,gmtim->tm_mday);
168  strcat(xbuf,mbuf);
169 
170  sprintf(mbuf," DH12/DC%s00/HZIF%cZZ/DIH+6",
171  dcbuf,shef_source[0]);
172  strcat(xbuf,mbuf);
173 
174  for(k=0;k<13;k++) {
175 
176  if(k==4) {
177 
178  strcat(xbuf,"\n");
179  strcat(xbuf,".E1 ");
180 
181  }
182 
183  if(map[ib].zmaps_done[k]==1) {
184 
185  if(j==0)
186  temp=map[ib].zlz[k];
187 
188  if(j==1)
189  temp=map[ib].zmz[k];
190 
191  if(j==2)
192  temp=map[ib].zuz[k];
193 
194  if(j==3)
195  temp=map[ib].zgz[k];
196 
197  }
198 
199  else
200  temp=-1.0;
201 
202  if(k != 4)
203  strcat(xbuf,"/");
204 
205  if(temp < 0)
206  sprintf(mbuf,"M ",temp);
207 
208  else
209  sprintf(mbuf,"%5.2f",temp);
210 
211  strcat(xbuf,mbuf);
212 
213  }
214 
215  strcat(xbuf,"\n");
216  fputs(xbuf,fo);
217 
218  }
219 
220  }
221 
222 
223 fclose(fo);
224 
225 return;
226 
227 }
228 
229 
230 
static int i
struct tm * gmttime(time_t *secs)
Definition: gmttime.c:5
char fbuf[100]
Definition: decode_HDP.c:2
int hour
Definition: display_data.c:26
int day
Definition: display_data.c:26
int year
Definition: display_data.c:26
int month
Definition: display_data.c:26
fclose(fp)
sprintf(fbuf,"/usr/mapper/nexrad/ngrid.%02d-%02d-%02d-%02d", year, month, day, hour)
printf("fbuf is %s\n", fbuf)
void make_fzelv_file()
int j
Definition: mapp2h.h:48
char temp[9]
Definition: mapp2h.h:66
int k
Definition: mapp2h.h:48
ib
Definition: shleap.cc:46
Definition: misc.h:236
char bchar[5]
Definition: misc.h:242
char hb5[10]
Definition: misc.h:238
float * zgz
Definition: misc_new.h:334
float * zuz
Definition: misc_new.h:335
float * zlz
Definition: misc_new.h:337
float * zmz
Definition: misc_new.h:336
Definition: misc.h:93
tim()
Definition: tim.c:4