Mapper
new_read_qpf_grids.c
Go to the documentation of this file.
1 
2 #include "prototypes_new.h"
3 
4 int read_qpf_grids(int k,char *fname)
5 
6 {
7 extern int pcp_in_use[500];
8 FILE *fp;
9 extern struct hrap_grid *hrap_grid;
10 int i,j,h;
11 char kbuf[10000];
12 extern struct pcp *pcp;
13 int minhrapi,minhrapj,maxhrapi,maxhrapj;
14 int ghrapi,ghrapj;
15 int ii,jj;
16 int ier;
17 char *p;
18 int gmini,gminj,gmaxi,gmaxj;
19 int iflag;
20 int ibig;
21 
22 fp=fopen(fname,"r");
23 
24 
25 if(fp==NULL) {
26 
27  printf("could not open %s\n",fname);
28 
29  return(-1);
30 
31  }
32 
33 for(i=0;i<hrap_grid->maxi;i++) {
34 
35 for(j=0;j<hrap_grid->maxj;j++) {
36 
37  pcp->value[i][j]=0;
38 
39  }
40 
41 }
42 
43 minhrapi=hrap_grid->hrap_minx;
44 minhrapj=hrap_grid->hrap_miny;
45 maxhrapi=hrap_grid->hrap_minx + hrap_grid->maxi;
46 maxhrapj=hrap_grid->hrap_miny + hrap_grid->maxj;
47 
48 p=fgets(kbuf,100,fp);
49 
50 ier=sscanf(kbuf,"%d %d %d %d %d\n",&gmini,&gminj,&gmaxi,&gmaxj,&iflag);
51 
52 if(ier==4)
53  iflag=0;
54 
55 for(i=0;i<gmaxi;i++) {
56 
57  if(iflag==0) {
58 
59  fread(kbuf,sizeof(char),gmaxj*4,fp);
60  kbuf[gmaxj*4]=0;
61 
62  }
63 
64  else {
65 
66  fread(kbuf,sizeof(char),gmaxj*6,fp);
67  kbuf[gmaxj*6]=0;
68 
69  }
70 
71  /* get hrap coord of gridded data */
72 
73  ghrapi=gmini+i;
74 
75  ii=ghrapi-minhrapi;
76 
77  if(ghrapi >= minhrapi && ghrapi < maxhrapi) {
78 
79  h=0;
80 
81  for(j=0;j<gmaxj;j++) {
82 
83  ghrapj=gminj+j;
84 
85  jj=ghrapj-minhrapj;
86 
87  if(ghrapj >= minhrapj && ghrapj < maxhrapj) {
88 
89  pcp->value[ii][jj]=atoi(&kbuf[h]);
90 
91  }
92 
93  if(iflag==0)
94  h=h+4;
95 
96  else
97  h=h+6;
98 
99  }
100 
101  }
102 
103  }
104 
105 fclose(fp);
106 
107 /*copy to internal file */
108 
109 write_file("pcp",k,pcp);
110 
111 pcp_in_use[k]=1;
112 
113 return(1);
114 
115 }
116 
static int i
void write_file(char *, int, struct pcp *)
Definition: write_file.c:5
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 read_qpf_grids(int k, char *fname)
struct pcp * pcp
Definition: mapper.c:140
int pcp_in_use[50]
Definition: mapper.c:78
struct hrap_grid * hrap_grid
Definition: mapper.c:142
char fname[100]
Definition: send_afos.c:6
short int hrap_miny
Definition: misc.h:583
short int hrap_minx
Definition: misc.h:582
short int maxi
Definition: misc.h:580
short int maxj
Definition: misc.h:581
Definition: misc.h:596
short int ** value
Definition: misc.h:599