18 FILE *afosfile,*biasfile;
19 char ch, prevchar,pprevchar;
20 int i,
j,n,ihr,iminute,len,
len2,
k,kk;
23 char hour[3],minute[3],radar[4],chour[3];
24 unsigned char ncharrows;
25 char param[7],junk[4],t1[7],t2[7],t3[7];
26 char maxval[7],bias[7],error[7],jdate[7],jmin[7];
27 char outname[81],biasname[81],sjunk[50],lradar[4];
30 unsigned char data[300];
40 unsigned char value[131][131];
43 unsigned char cbytes1,cbytes2;
50 int imonth,iyear,ihour,iday;
57 afosfile = fopen(argv[1],
"rb");
61 printf(
"could not open %s\n",argv[1]);
67 fread(data,
sizeof(
char),300,afosfile);
71 n=memcmp(&data[
i],
"HDP",3);
79 printf(
"could not find HDP\n");
89 memcpy(radar,&data[
i+3],4);
91 printf(
"decoding of %s started\n",argv[1]);
95 n = fscanf(afosfile,
"%c",&ch);
104 if (ch ==
' ' && prevchar==
'1' && pprevchar ==
'8')
114 n = fscanf(afosfile,
"%7s%8s%6s%2s%2s%2s%2s%2s",clat,clon,
height,
year,
month,
127 n = fscanf(afosfile,
"%6s%6s%6s%6s",param,t1,t2,t3);
137 fscanf(afosfile,
"%6s",param);
139 n = fscanf(afosfile,
"%6s%6s%6s%6s%6s%6s%6s",maxval,bias,error,
140 jdate,jmin,param,param);
154 time = div(atoi(jmin),60);
158 printf(
"%s %02d:%02d max=%6s bias=%6s err=%6s\n",
159 cdate, ihr, iminute, maxval,bias,error);
163 printf(
"%s too old - aborting\n",argv[1]);
172 fread(sjunk,
sizeof(
char),11,afosfile);
176 n = fread(&ncharrows,
sizeof(
char),1,afosfile);
177 printf(
"ncharrows %d\n",ncharrows);
179 for (
i=0;
i<ncharrows;
i++)
183 n = fread(&cbytes1,
sizeof(
char),1,afosfile);
184 n = fread(&cbytes2,
sizeof(
char),1,afosfile);
187 n = fread(data,
sizeof(
unsigned char), nbytes-2,afosfile);
192 printf(
" unexpected EOF encoutered -- ");
193 printf(
" number of bytes expected = %d",nbytes-2);
194 printf(
" number of bytes found =%d \n",n);
201 nruns = (short)((
float)(nbytes-2)/2.);
204 printf(
"nruns %d\n",nruns);
206 for (
j=0;
j<nruns;
j++)
208 xchar = (
unsigned char)data[
j*2];
209 xrun = (short) xchar;
210 level = (short) data[1+
j*2];
213 printf(
"xrun %d %d %d\n",xrun,xchar,level);
215 for(
k=0;
k<xrun;
k++) {
219 if(
i > 130 || kk > 130) {
227 value[130-
i][kk]=(char)level;
231 if(
value[130-
i][kk] != 255 &&
232 value[130-
i][kk] > maxvalue)
233 maxvalue=
value[130-
i][kk] ;
250 len = strlen(
"st2_st1");
253 lradar[
i]=tolower(radar[
i]);
263 errno=access(dname,R_OK);
267 sprintf(ibuf,
"mkdir -p %s",dname);
270 sprintf(ibuf,
"chmod -R 777 /awips/hydroapps/rfc/local/apps/mapper/nexrad");
275 sprintf(outname,
"%s/%s.%02d-%02d-%02d-%02d",dname,
276 lradar,iyear,imonth,iday,ihour);
278 fpout=fopen(outname,
"wb");
281 printf(
"could not open %s\n",outname);
287 fwrite(
value,
sizeof(
char),131*131,fpout);
291 sprintf(ibuf,
"gzip -f %s",outname);
295 printf(
"file %s written and zipped\n",outname);
297 printf(
"max value is %d\n",maxvalue);
305 int days[]={31,28,31,30,31,30,31,31,30,31,30,31} ;
306 int year,
month,ndays,date,total,nyear,leap_year;
323 if (
month==1 && leap_year==
TRUE) ndays++;
324 date=ndays - (total-jdate);
char * convertJulianDate()
main(int argc, char **argv)
char database_directory[100]
char nexrad_directory[100]
sprintf(fbuf,"/usr/mapper/nexrad/ngrid.%02d-%02d-%02d-%02d", year, month, day, hour)
printf("fbuf is %s\n", fbuf)