7 extern char station_climo_file[100];
8 extern char tstation_list_custom_file[100];
10 int i,ier,sflag,field,
j,xadd,yadd;
11 extern struct station tstation[1000];
12 extern int max_tstations;
14 char *p,kbuf[200],
hb5[10],
parm[10];
15 double dist1,dist2,dist,sorted[30];
63 tstation[
i].
hb5=calloc(10,
sizeof(
char));
64 tstation[
i].
name=calloc(50,
sizeof(
char));
65 tstation[
i].
parm=calloc(10,
sizeof(
char));
66 tstation[
i].
cparm=calloc(10,
sizeof(
char));
67 tstation[
i].
max=calloc(12,
sizeof(
float));
68 tstation[
i].
min=calloc(12,
sizeof(
float));
69 tstation[
i].
index=calloc(20,
sizeof(
short int));
71 ier=sscanf(kbuf,
"%s %s %f %f %f %d ",tstation[
i].
hb5,
77 if(strncasecmp(
"TAI",tstation[
i].
parm,3)!=0)
83 if(strcmp(tstation[
i].
hb5,tstation[m].
hb5)==0 &&
84 tstation[
i].
parm[4]==tstation[m].
parm[4]){
115 for(
j=0;
j<strlen(kbuf);
j++) {
117 if(kbuf[
j] !=
' ' && sflag==1) {
123 else if(kbuf[
j]==
' ')
130 strcpy(tstation[
i].
name,&kbuf[
j]);
145 for(
i=0;
i<max_tstations;
i++){
149 tstation[
i].
max[m]=-99;
150 tstation[
i].
min[m]=-99;
157 if(station_climo_file[0]!=0)
158 fp=fopen(station_climo_file,
"r");
162 for(
i=0;
i<max_tstations;
i++) {
173 if(tstation[
i].
max[
k] < 0)
174 printf(
"No max temp climatology for %s\n",tstation[
i].
hb5);
176 strcpy(tstation[
i].
cparm,
"TAIPBXM");
180 if(tstation[
i].
min[
k] < 0)
181 printf(
"No min temp climatology for %s\n",tstation[
i].
hb5);
194 p=fgets(kbuf,200,
fp);
198 ier=sscanf(kbuf,
"%s %s %f %f %f %f %f %f %f %f %f %f %f %f",
199 hb5,
parm,&f[0],&f[1],&f[2],&f[3],&f[4],&f[5],&f[6],&f[7],&f[8],
200 &f[9],&f[10],&f[11]);
205 for(
i=0;
i<max_tstations;
i++) {
207 if(strcmp(tstation[
i].
hb5,
hb5)==0 &&
213 tstation[
i].
max[m]=f[m];
217 else if(
parm[5]==
'N') {
220 tstation[
i].
min[m]=f[m];
237 p=fgets(kbuf,200,
fp);
241 ier=sscanf(kbuf,
"%s %s %f %f %f %f %f %f %f %f %f %f %f %f",
242 hb5,
parm,&f[0],&f[1],&f[2],&f[3],&f[4],&f[5],&f[6],&f[7],&f[8],
243 &f[9],&f[10],&f[11]);
248 if(strncmp(
parm,
"TAIPB",5) != 0 &&
249 strncmp(
parm,
"TAIRZ",5) != 0)
252 for(
i=0;
i<max_tstations;
i++) {
254 if(strcmp(tstation[
i].
hb5,
hb5)==0 &&
255 ((
parm[5]==
'X' && tstation[
i].
max[0] < 0) ||
256 (
parm[5]==
'N' && tstation[
i].
min[0] < 0) ||
257 strncmp(tstation[
i].
cparm,
"TAIPB",5)==0)) {
262 tstation[
i].
max[m]=f[m];
266 else if(
parm[5]==
'N') {
269 tstation[
i].
min[m]=f[m];
288 strcat(kbuf,
".tcustom");
289 strcpy(tstation_list_custom_file,kbuf);
306 for(
j=0;
j<max_tstations;
j++) {
308 if(strcmp(
hb5,tstation[
j].
hb5)==0) {
310 if(strncmp(
parm,tstation[
j].
parm,3)==0 &&
328 for(
i=0;
i<max_tstations;
i++) {
333 for(m=0;m<max_tstations;m++) {
338 dist1=tstation[
i].
lat-tstation[m].
lat;
340 dist2=(tstation[
i].
lon-tstation[m].
lon)*
341 cos((tstation[
i].
lat+tstation[m].
lat)/2*conv);
343 dist=pow(dist1,2)+pow(dist2,2);
347 if(dist < sorted[l]) {
349 for(h=19; h > l; h--) {
351 sorted[h]=sorted[h-1];
float get_lmaxmin(float lat, float lon, int mon, int type)
void get_tstation_list(char *fname, int smonth, int emonth)
int is_good(int k, int smonth, int emonth)
printf("fbuf is %s\n", fbuf)