Mapper
write_archived_data.c
Go to the documentation of this file.
1 #define _POSIX_SOURCE
2 #include "prototypes_new.h"
3 
4 void write_archived_obs_data(char *sfile,char *abuf,char *wfo,time_t tim,
5  char *archive_file)
6 
7 {
8 
9 extern char *timefile[];
10 extern char *ztimefile[];
11 extern char *ttimefile[];
12 char sbuf[4000];
13 char tbuf[100];
14 char dbuf[100];
15 struct tm *gmtim;
16 int ier,k;
17 time_t stime;
18 
19 chdir(sfile);
20 
21 gmtim=gmttime(&tim);
22 
23 sprintf(tbuf,"%s/%s.%s.tar.%02d-%02d-%02d",archive_file,abuf,wfo,
24  gmtim->tm_mon+1,gmtim->tm_mday,gmtim->tm_year);
25 
26 chmod(tbuf,S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH | S_IRUSR | S_IWUSR);
27 
28 sprintf(sbuf,"tar -cvf %s ",tbuf);
29 
30 sprintf(dbuf,"opoint.%s.%02d-%02d-%02d",wfo,
31  gmtim->tm_mon+1,gmtim->tm_mday,gmtim->tm_year);
32 
33 chmod(dbuf,S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH | S_IRUSR | S_IWUSR);
34 
35 strcat(sbuf,dbuf);
36 strcat(sbuf," ");
37 
38 sprintf(dbuf,"opoint2.%s.%02d-%02d-%02d",wfo,
39  gmtim->tm_mon+1,gmtim->tm_mday,gmtim->tm_year);
40 
41 chmod(dbuf,S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH | S_IRUSR | S_IWUSR);
42 
43 strcat(sbuf,dbuf);
44 strcat(sbuf," ");
45 
46 sprintf(dbuf,"opoint2.%s.bad.%02d-%02d-%02d",wfo,
47  gmtim->tm_mon+1,gmtim->tm_mday,gmtim->tm_year);
48 
49 chmod(dbuf,S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH | S_IRUSR | S_IWUSR);
50 
51 strcat(sbuf,dbuf);
52 strcat(sbuf," ");
53 
54 sprintf(dbuf,"opoint2.%s.dev.%02d-%02d-%02d",wfo,
55  gmtim->tm_mon+1,gmtim->tm_mday,gmtim->tm_year);
56 
57 chmod(dbuf,S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH | S_IRUSR | S_IWUSR);
58 
59 strcat(sbuf,dbuf);
60 strcat(sbuf," ");
61 
62 sprintf(dbuf,"omap.%s.%02d-%02d-%02d",wfo,
63  gmtim->tm_mon+1,gmtim->tm_mday,gmtim->tm_year);
64 
65 chmod(dbuf,S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH | S_IRUSR | S_IWUSR);
66 
67 strcat(sbuf,dbuf);
68 strcat(sbuf," ");
69 
70 for(k=0;k<5;k++) {
71 
72  if(k<2)
73  stime=tim-84600;
74 
75  else
76  stime=tim;
77 
78  gmtim=gmttime(&stime);
79 
80  sprintf(dbuf,"ogrid.%s.%02d-%02d-%02d.%s",wfo,
81  gmtim->tm_mon+1,gmtim->tm_mday,gmtim->tm_year,
82  timefile[k]);
83 
84  chmod(dbuf,S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH | S_IRUSR | S_IWUSR);
85 
86  strcat(sbuf,dbuf);
87  strcat(sbuf," ");
88 
89  }
90 
91 sprintf(dbuf,"ozpoint.%s.%02d-%02d-%02d",wfo,
92  gmtim->tm_mon+1,gmtim->tm_mday,gmtim->tm_year);
93 
94 chmod(dbuf,S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH | S_IRUSR | S_IWUSR);
95 
96 strcat(sbuf,dbuf);
97 strcat(sbuf," ");
98 
99 sprintf(dbuf,"ozpoint2.%s.%02d-%02d-%02d",wfo,
100  gmtim->tm_mon+1,gmtim->tm_mday,gmtim->tm_year);
101 
102 chmod(dbuf,S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH | S_IRUSR | S_IWUSR);
103 
104 strcat(sbuf,dbuf);
105 strcat(sbuf," ");
106 
107 sprintf(dbuf,"omaz.%s.%02d-%02d-%02d",wfo,
108  gmtim->tm_mon+1,gmtim->tm_mday,gmtim->tm_year);
109 
110 chmod(dbuf,S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH | S_IRUSR | S_IWUSR);
111 
112 strcat(sbuf,dbuf);
113 strcat(sbuf," ");
114 
115 for(k=0;k<4;k++) {
116 
117  if(k<2)
118  stime=tim-84600;
119 
120  else
121  stime=tim;
122 
123  gmtim=gmttime(&stime);
124 
125  sprintf(dbuf,"ozgrid.%s.%02d-%02d-%02d.%s",wfo,
126  gmtim->tm_mon+1,gmtim->tm_mday,gmtim->tm_year,
127  ztimefile[k]);
128 
129  chmod(dbuf,S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH | S_IRUSR |
130  S_IWUSR);
131 
132  strcat(sbuf,dbuf);
133  strcat(sbuf," ");
134 
135  }
136 
137 sprintf(dbuf,"otpoint.%s.%02d-%02d-%02d",wfo,
138  gmtim->tm_mon+1,gmtim->tm_mday,gmtim->tm_year);
139 
140 chmod(dbuf,S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH | S_IRUSR | S_IWUSR);
141 
142 strcat(sbuf,dbuf);
143 strcat(sbuf," ");
144 
145 sprintf(dbuf,"otpoint2.%s.%02d-%02d-%02d",wfo,
146  gmtim->tm_mon+1,gmtim->tm_mday,gmtim->tm_year);
147 
148 chmod(dbuf,S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH | S_IRUSR | S_IWUSR);
149 
150 strcat(sbuf,dbuf);
151 strcat(sbuf," ");
152 
153 sprintf(dbuf,"otpoint2.%s.bad.%02d-%02d-%02d",wfo,
154  gmtim->tm_mon+1,gmtim->tm_mday,gmtim->tm_year);
155 
156 chmod(dbuf,S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH | S_IRUSR | S_IWUSR);
157 
158 strcat(sbuf,dbuf);
159 strcat(sbuf," ");
160 
161 sprintf(dbuf,"otpoint2.%s.dev.%02d-%02d-%02d",wfo,
162  gmtim->tm_mon+1,gmtim->tm_mday,gmtim->tm_year);
163 
164 chmod(dbuf,S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH | S_IRUSR | S_IWUSR);
165 
166 strcat(sbuf,dbuf);
167 strcat(sbuf," ");
168 
169 sprintf(dbuf,"omat.%s.%02d-%02d-%02d",wfo,
170  gmtim->tm_mon+1,gmtim->tm_mday,gmtim->tm_year);
171 
172 chmod(dbuf,S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH | S_IRUSR | S_IWUSR);
173 
174 strcat(sbuf,dbuf);
175 strcat(sbuf," ");
176 
177 for(k=0;k<6;k++) {
178 
179  if(k<2)
180  stime=tim-84600;
181 
182  else
183  stime=tim;
184 
185  gmtim=gmttime(&stime);
186 
187  sprintf(dbuf,"otgrid.%s.%02d-%02d-%02d.%s",wfo,
188  gmtim->tm_mon+1,gmtim->tm_mday,gmtim->tm_year,
189  ttimefile[k]);
190 
191  chmod(dbuf,S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH | S_IRUSR |
192  S_IWUSR);
193 
194  strcat(sbuf,dbuf);
195  strcat(sbuf," ");
196 
197  }
198 
199 system(sbuf);
200 
201 sprintf(sbuf,"gzip -1 -f %s",tbuf);
202 
203 system(sbuf);
204 
205 
206 }
207 
208 
209 
210 
211 
212 
213 
214 
215 
216 
struct tm * gmttime(time_t *secs)
Definition: gmttime.c:5
sprintf(fbuf,"/usr/mapper/nexrad/ngrid.%02d-%02d-%02d-%02d", year, month, day, hour)
system(tarbuf)
int k
Definition: mapp2h.h:48
struct sensor_file * sfile
Definition: mapper.c:126
tim()
Definition: tim.c:4
void write_archived_obs_data(char *sfile, char *abuf, char *wfo, time_t tim, char *archive_file)