#include #include #include #include #include #include #include #include #include #include static int read_evt_file(); int main() { read_evt_file(); } static int read_evt_file() { FILE *inp; FILE *out; FILE *evt; FILE *map; FILE *win; char temp[25]; char dato[25]; char fdato[25]; char ftime[25]; char fecha[25]; char time[25]; char lat[25]; char lon[25]; char dep[25]; char mag[25]; char path[100]; char kopi[500]; char syscmd[100]; char wind[200]; char dum[10]; int no_channels; char filename[100]; char lines[5000][100]; char skjelv[5000][500]; char location[100]; char noloc[100]; int teller; int telleverk=0; int sw; int ne; int l; int i; int j; int ret; float lati; float longi; float latmax,latmin,lonmax,lonmin; for(i=0;i<80;i++) noloc[i]=' '; noloc[0]='N'; noloc[1]='o'; noloc[i]='\n'; // sprintf(noloc,"No description\0"); // // Run collect with parameterd from collect.par to get a collect.out list for rest of program // This file will be searched for S-files marked for WEB // /// sprintf(syscmd,"rm -f select.out"); /// ret=system(syscmd); /// sprintf(syscmd,"collect -start_time %s -end_time %s -base_name %s",start_time,end_time,dbase); /// ret=system(syscmd); /// sleep(2); /// sprintf(filename,"%s/par/geowin.txt",topdir_map); /// if((win = fopen(filename,"r")) == NULL) /// { /// printf("Can't open %s\n",filename); /// exit(0); /// } /// if(fgets(wind,sizeof wind,win)!=NULL) /// if(fgets(wind,sizeof wind,win)!=NULL) /// fclose(win); /// sscanf(wind,"%f %f %f %f",&latmax,&latmin,&lonmax,&lonmin); if ((inp = fopen ("select.out", "rb")) == NULL) { printf("Can't open select.out\n"); } if ((evt = fopen ("ALL_EPI.txt", "w")) == NULL) { printf("Can't open ALL_EPI.txt\n"); } for(i=0;i<25;i++) { dato[i] = '\0'; time[i] = '\0'; lat[i] = '\0'; lon[i] = '\0'; dep[i] = '\0'; mag[i] = '\0'; temp[i] = '\0'; } teller = 0; i = 0; while(fgets(path,100,inp) != NULL) { sw = 0; for(j=0;j<80;j++) // check line to see if any char != 0 { if(path[j] != ' ') sw = 1; // end of s-record } if(sw == 1) // end of s-record { // no sprintf(lines[i],"%s",path); i++; }else{ // yes, end of s-record, all ==" " sw=0; teller = 0; // check record for WEB indicator sprintf(location,"%s",noloc); if(lines[0][22] == 'P' || lines[0][22] == 'E') { // printf("Explosion\n"); }else{ teller = 1; if(lines[0][18] == '.' && lines[0][26] == '.') // do we have a location ? { for(l=0;l<25;l++) // extract latitude temp[l] = '\0'; for(l=0;l<7;l++) lat[l] = lines[0][l+23]; if(lat[3] == ' ') lat[3] = '0'; if(lat[4] == ' ') lat[4] = '0'; if(lat[5] == ' ') lat[5] = '0'; sscanf(lat,"%f",&lati); for(l=0;l<25;l++) // extract longitude temp[l] = '\0'; for(l=0;l<8;l++) lon[l] = lines[0][l+30]; if(lon[3] == ' ') lon[3] = '0'; if(lon[4] == ' ') lon[4] = '0'; if(lon[5] == ' ') lon[5] = '0'; sscanf(lon,"%f",&longi); // printf("LAT1: %f LON1: %f\n",lati,longi); /// if(lati < latmax && lati > latmin && longi > lonmax && longi < lonmin) /// { telleverk++; // printf("%s\n",location); for(l=0;l<25;l++) { dato[l] = '\0'; time[l] = '\0'; temp[l] = '\0'; } printf("%s",lines[0]); strncpy(temp,lines[0],10); // extract date dato[0] = temp[1]; dato[1] = temp[2]; dato[2] = temp[3]; dato[3] = temp[4]; dato[4] = '/'; dato[5] = temp[6]; dato[6] = temp[7]; dato[7] = '/'; dato[8] = temp[8]; dato[9] = temp[9]; if(dato[5] == ' ') dato[5] = '0'; if(dato[8] == ' ') dato[8] = '0'; for(l=0;l<25;l++) // extract time temp[l] = '\0'; for(l=0;l<9;l++) temp[l] = lines[0][l+11]; time[0] = temp[0]; time[1] = temp[1]; time[2] = ':'; time[3] = temp[2]; time[4] = temp[3]; time[5] = ':'; time[6] = temp[5]; time[7] = temp[6]; time[8] = temp[7]; time[9] = temp[8]; if(time[0] == ' ') time[0] = '0'; if(time[3] == ' ') time[3] = '0'; if(time[6] == ' ') time[6] = '0'; for(l=0;l<5;l++) // extract depth dep[l] = lines[0][l+38]; if(lines[0][57] == '.') { for(l=0;l<4;l++) // extract mag mag[l] = lines[0][l+55]; }else{ mag[0]=' '; mag[1]='0'; mag[2]='.'; mag[3]='0'; } //printf("here01\n"); for(i=0;i<20;i++) { fdato[i]=dato[i]; ftime[i]=time[i]; } fdato[4]='_'; fdato[7]='_'; ftime[2]='_'; ftime[5]='_'; fprintf(evt,"%s %s %s %s %s %s\n",dato,time,lat,lon,dep,mag); teller = 0; /// } }else{ printf(" number of lines in record: %d\n",i); } // if location } // if explosion i=0; } // if(sw.........else........... } // while( fclose(inp); fclose(evt); printf("TELLEVERK: %d\n",telleverk); // sprintf(syscmd,"rm -f /inetpub/www/html/seismo/nnsn2/GMAPS/ALL_30/temp.txt"); /// sprintf(syscmd,"rm -f temp.txt"); /// ret=system(syscmd); sprintf(syscmd,"cp ALL_EPI.txt ALL_EPI_OMV.txt"); ret=system(syscmd); /// sprintf(syscmd,"sort -r --k=1,20 ALL_EPI.txt > temp.txt"); /// ret=system(syscmd); /// sprintf(syscmd,"rm -f ALL_EPI.txt"); /// ret=system(syscmd); /// sprintf(syscmd,"cp temp.txt ALL_EPI.txt"); /// ret=system(syscmd); /// printf("Number of events in region between %s - %s: %d\n",start_time,end_time,telleverk); }