📄 rdseed.c
字号:
else if (alt_headerfile != NULL) printf("WARNING - Alternate Header File Present - Processing will be SEQUENTIAL\n"); } switch (output_format) { case 0: sprintf (outputformat, "sac.binary"); break; case 1: sprintf (outputformat, "ah.binary"); break; case 2: sprintf (outputformat, "css.binary"); break; case 3 : sprintf (outputformat, "mini.seed"); break; case 4 : sprintf(outputformat, "seed"); break; case 5 : sprintf(outputformat, "sac.ascii"); break; default: sprintf (outputformat, "unknown"); break; } if (outputformat_flag) fprintf (stderr,"Output data format will be %s.\n", outputformat); /* +=======================================+ *//*=================| Open input file |=================*//* +=======================================+ *//* +=======================================+ *//*=================| Initialization |=================*//* +=======================================+ */ init_data_hdr (); start_record = 0; offset = 0; more_data = TRUE; eof_count = 0; found_lrecl_flag = at_volume = FALSE; volume_count = 0; sample_rate_accum = 0.0; sample_rate_count = 0; if (alt_headerfile != NULL) { save_file = inputfile; inputfile = alt_headerfile; reading_alt_file = TRUE; } else reading_alt_file = FALSE; /* print nice header for times data...if times data was specified. * option "t" */ if (times_flag) { fprintf(outputfile, "Time series: \n"); fprintf(outputfile, " Rec# Sta Cha Net Loc Start Time End Time Sample Rate Tot Samples\n"); }/* +=======================================+ *//*=================| Read and process file until EOF found |=================*//* +=======================================+ *//* if (snoop_flag) snoop (inputfile); *//* if (times_flag) times (inputfile); */MORE_ALT_FILES: while (more_data == TRUE) { if (offset == 0) /* read a physical record */ { /*****************************************************/ /* read a physical record and point to its beginning */ /*****************************************************/ num_bytes_read = fread(precord, 1, PRECL, inputfile); if (num_bytes_read == 0) { if (reading_alt_file) { /* No more alt files */ reading_alt_file = FALSE; inputfile = save_file; /* force a read (in skip_to_(d)) */ offset = PRECL; /* skip to 'D' */ if ((num_bytes_read = skip_to_DRQ(inputfile)) == 0) break; } else if ((eof_count > 0) || input_file_type) { if (at_volume) break; fprintf(stderr,"!!! ERROR - Volume Not Found !!!\n"); fclose(inputfile); exit(1); } else { eof_count++; fclose(inputfile); inputfile = fopen(inputfilename,"r"); if (at_volume) more_data = FALSE; continue; } } else if (num_bytes_read < 0) { fprintf(stderr,"!!! ERROR - Fatal I/O Read Error, Exiting Program !!!\n"); perror(argv[0]); fclose(inputfile); exit(1); } else eof_count = 0; precord_ptr = (char *)precord; lrecord_ptr = precord_ptr; }skip_flag: /* point to beginning of this logical record */ input_data_hdr = (struct input_data_hdr *) (lrecord_ptr + 8); input_data_ptr = (lrecord_ptr + 8); /* extract a logical record from the physical record */ read_logical_record (lrecord_ptr); if (snoop_flag) fprintf(stderr,"%06ld ", input.recordnumber); /* process logical record according to its type */ /* "read_blockette" handles spans across logical or physical records */ if (found_lrecl_flag || input.type=='V') switch (input.type) { case 'D': case 'R': case 'Q': { /* bale here if only interested in event info */ if (event_flag || ex_stn_flag || stations_flag || station_comments_flag || channel_comments_flag) { more_data = FALSE; break; } if (reading_alt_file) { reading_alt_file = FALSE; inputfile = save_file; at_volume = FALSE; break; } else if ((alt_headerfile!=NULL) && (volume_count==0)) at_volume = TRUE; if (abbrev_flag || stations_flag) { more_data = FALSE; break; } if (times_flag) { if (chk_station(input_data_hdr->station)&& chk_channel(input_data_hdr->channel) && chk_network(input_data_hdr->network)) { /* check if byteswapping will be needed * to recover data */ /* hopefully, rdseed will not be around by 2010 */ if (input_data_hdr->time.year <1950 || input_data_hdr->time.year > 2010) swap_fsdh(&input_data_hdr, &input_data_ptr); /* check for sanity */ if (input_data_hdr->time.year <1950 || input_data_hdr->time.year > 2010) { fprintf(stderr, "ERROR - rdseed(): Unknown word order for station %s, channel %s, network %s\n", input_data_hdr->station, input_data_hdr->channel, input_data_hdr->network); fprintf(stderr, "Skipping data record.\n"); continue; } LRECL = get_LRECL(input_data_hdr, lrecord_ptr); times_data(0); } break; } if (contents_flag) { if (type74_head != NULL) { more_data = FALSE; break; } } if (input_file_type == DISK_DEVICE) { /* scan in all atc data from block 74s */ atc_load(inputfile); atc_dump(); } if (read_summary_flag && (input_file_type == DISK_DEVICE)) { if (input_file_type == DISK_DEVICE) { process_summary_file(); more_data = FALSE; continue; } } if ((data_flag||mini_flag) && input_file_type && (volume_number==1) && (alt_headerfile==NULL)&& (!station_volume)) /* whew!! */ { if (i = process_time_span_index()) /* 0 = type74; 1 = type73; -1 = none */ { if (i < 0) { input_file_type = 0; if (chk_station(input_data_hdr->station) && chk_channel(input_data_hdr->channel) && chk_network(input_data_hdr->network)) { process_data (); output_flag = TRUE; } } else offset = 0; } else more_data = FALSE; } else if (data_flag) { if (chk_station(input_data_hdr->station)&& chk_channel(input_data_hdr->channel) && chk_network(input_data_hdr->network)) { /* check if byteswapping will be needed * to recover data */ /* hopefully, rdseed will not be around by 2010 */ if (input_data_hdr->time.year < 1950 || input_data_hdr->time.year > 2010) swap_fsdh(&input_data_hdr, &input_data_ptr); /* check for sanity */ if (input_data_hdr->time.year < 1950 || input_data_hdr->time.year > 2010) { fprintf(stderr, "ERROR - rdseed(): Unknown word order for station %s, channel %s, network %s\n", input_data_hdr->station, input_data_hdr->channel, input_data_hdr->network); fprintf(stderr, "Skipping data record.\n"); continue; } if (strcmp(prevStn, "") != 0) { if ((strncmp(prevStn, input_data_hdr->station, 5) != 0) || (strncmp(prevChn, input_data_hdr->channel, 3) != 0) || (strncmp(prevNet, input_data_hdr->network, 2) != 0) || (strncmp(prevLoc, input_data_hdr->location, 2) != 0)) LRECL = get_LRECL(input_data_hdr, lrecord_ptr); } else LRECL = get_LRECL(input_data_hdr, lrecord_ptr); process_data (); output_flag = TRUE; strncpy(prevStn, input_data_hdr->station, 5); prevStn[5] = 0; strncpy(prevChn, input_data_hdr->channel, 3); prevChn[3] = 0; strncpy(prevNet, input_data_hdr->network, 2); prevNet[2] = 0; strncpy(prevLoc, input_data_hdr->location, 2); prevNet[2] = 0; } } break; } case 'T': /* bale here if only interested in station*/ if (ex_stn_flag || stations_flag) { more_data = FALSE; break; } if (reading_alt_file) { reading_alt_file = FALSE; close_alt_files(); inputfile = save_file; at_volume = FALSE; /* reset offset so we load * in new stuff */ offset = 0; break; } if (!at_volume) break; process_timeh (); break; case 'S': /* if we are not reading the alt_response file && * we aren't at the right volume number, skip it */ if ((!reading_alt_file) && (!at_volume)) break; /* bale if they want only abbrev */ if (abbrev_flag) { more_data = FALSE; continue; } /* if they want contents, * skip to the block 70s */ if (contents_flag || event_flag) { if ((input_file_type != TAPE_DEVICE) && (!reading_alt_file)) { process_B70s(inputfile); more_data = FALSE; continue; } /* else alt response file ?*/ if (reading_alt_file) { /* drop out fini*/ more_data = FALSE; continue; } /* else - continue to loop */ break; } if (!at_volume || ((alt_headerfile!=NULL) && !reading_alt_file)) break; if (input_file_type != TAPE_DEVICE) { if (type11.number_stations > 0) { process_B11(inputfile); /* finished with the stations, * go on to the timepsans */ if (stations_flag || (Output_PnZs && (!data_flag)) || ex_stn_flag || station_comments_flag || channel_comments_flag) { more_data = FALSE; break; } if (reading_alt_file) { reading_alt_file = FALSE; inputfile = save_file; /* force a read */ offset = PRECL; /* skip to 'D' */ if ((num_bytes_read = skip_to_DRQ(inputfile)) == 0) break; goto skip_flag; } if (data_flag || Output_PnZs || mini_flag || Seed_flag) { process_B70s(inputfile); continue; } if (outresp_flag) { /* bale */ more_data = FALSE; continue; } break; } } if (input.continuation && !got_station) break; /* look to the blockette type for B050 */ sprintf(wrkstr, "%3.3s", input.data); if (atoi(wrkstr) == 50) { if ((got_station = scan_stn_net()) == 0) break; } if (got_station) process_stnh (); break; case 'A': if (!at_volume || ((alt_headerfile!=NULL) && !reading_alt_file)) break; process_abrvd (); /* Ver 3.1 */ break; case 'V': /* check to see if already reading seed volume, * if multi volume seed file */ if (at_volume && input.recordnumber == 1) { if (reading_alt_file) { /* No more alt files */ reading_alt_file = FALSE; inputfile = save_file; at_volume = FALSE; continue; } } if (input.recordnumber == 1) at_volume = ++volume_count == volume_number; if (!at_volume) { if (volume_count > volume_number) more_data = FALSE; break; } if (snoop_flag) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -