c-------------------------------------------------------------------------- c Reading one s-file at a time in a loop and extract SPEC and AMPG and c AMSG for each station. c c Some parameters are then modified and the modified event is written c to the output file. c--------------------------------------------------------------------------c c c For detail on parameters and variables names, see rea.inc c c To compile this program, use command make sample_read_write_s on sun c and nmake sample_read_write_s on pc c c implicit none ! force delcaration of all variables include 'seidim.inc' ! dimensions for rea block include 'seisan.inc' ! dimensions for rea block include 'rea.inc' ! parameter common bliock character*80 data(5000) ! s-file with data in text array character*80 err_text ! error text character*80 infile ! input file logical all ! true: read all data, false: headers integer code ! error return code integer nevent ! number of events in file integer i, j ! counter real :: ampS(100) ! amplitude of S-wave real :: ampP(100) ! amplitude of P-wave character*5 cur_sta c c open output file open(2,file='spec_amp.out',status='unknown') c c get input file name, check if exist c 9 continue write(6,*) 'Give input file' read(5,'(a)') infile open(1,file=infile,status='old',err=10) goto 11 10 continue write(6,*)' No such input file' goto 9 11 continue c all=.true. ! read all parameters nevent=0 ! initialize counter c c----------------------------------------------------------------- c Loop to read events start here c----------------------------------------------------------------- c 50 continue c c read all parameters for one event form file unit 1 c call rea_event_in(1,all,data,code) c c check if end of file (code=1), if so jump out of loop c if(code.eq.1) goto 1000 c nevent=nevent+1 ! count events c c write on screen a bit info on event, number of headers and c total number of records c write(6,*)' Number of headers and number of records', *rea_nhead,rea_nrecord write(*,*) ' nhead, nspec ',rea_nhead,rea_nspec c c write the whole first header line c write(6,'(a)') data(1)(1:79) c c some example of modifying event c c--------------------------------------------------------- c select all traces with s-wave spectral values, print c on screen station, time and log moment c---------------------------------------------------------- c do i=1,rea_nphase if(rea_phase(i)(1:5).eq.'SPECS') then cur_sta = rea_stat(i) do j=1, rea_nphase if (rea_stat(j)(1:5).eq.cur_sta .and. +rea_phase(j)(1:4).eq.'AMPG') then ampP = rea_amp(j) else if (rea_stat(j).eq.cur_sta .and. +rea_phase(j)(1:4).eq.'AMSG') then ampS = rea_amp(j) end if end do print *, rea_stat(i),' ',rea_comp(i),' ',ampP,' ', ampS c write(6,'(1x,a4,1x,a5,2i2,f6.1,f6.2)') c * rea_stat(i), rea_comp(i), rea_hour(i), c * rea_min(i),rea_sec(i),rea_moment(i) end if end do c c------------------------------------------------ c write out all magnitudes form all hypocneters c------------------------------------------------ c write(6,'(1x,6(f4.1,a1,a4,1x))') (hyp_mag_all(i), *hyp_mag_type_all(i),hyp_mag_agency_all(i),i=1,rea_nmag) c c write out modified event, the array data has also been modified c call rea_event_out(2,all,data,code) c c get next event c goto 50 c c end of file c 1000 continue c write(6,*) ! blank line close(2) ! close output file write(6,*) 'Number of events in input file', nevent write(6,*) 'Output file name is sample_read_write_s.out' stop end