subroutine hv(output_file,n_win,nsamps_inwin,nfft,maxsave, # n_freq,freq, current_window, wsave, sv, sn, se, smv, smn, sme, # buf1,buf2,buf3,cbuf,ierr) c c main processing routine that uses dynamical dimension of vectors c c a.tento 05/03 v.1.0. c implicit none character*200 output_file integer n_win, nsamps_inwin, maxsave, nfft, n_freq, ierr real current_window, wsave, sv, sn, se, smv, smn, sme real buf1, buf2, buf3, freq dimension current_window(nsamps_inwin), wsave(maxsave) dimension sv(nfft), sn(nfft), se(nfft) dimension freq(n_freq),buf1(n_freq), buf2(n_freq), buf3(n_freq) dimension smv(n_freq,n_win),smn(n_freq,n_win),sme(n_freq,n_win) complex cbuf dimension cbuf(nsamps_inwin) c include 'main.h' include 'parameters.h' include 'times.h' c integer loop_index, icomp,curwin_length,nw,jmax,jmin,nf1 real df, f0, f1, f2 c character sep2*1 parameter (sep2 = ':') character*200 argout(20) c c c Start main loop over windows. do 10 loop_index = 1, n_win c c Read time history if not in memory (3 components) and c verify constant sampling rate (one call to 'readerth' must be c already done) c if ( loop_index .ne. 1 ) then call readerth(loop_index,ierr) call ckerr(ierr) endif c c loop over 3 components do 20 icomp = 1, 3 c c Identify time window call itw(loop_index,icomp,nsamps_inwin,current_window, & curwin_length,ierr) call ckerr(ierr) c c Tapering, padding call apply_taper(current_window,curwin_length, # nsamps_inwin,ierr) call ckerr(ierr) c c FFT call xfft(current_window,nsamps_inwin,sampling_rate, # icomp,wsave,df,nf1,sv,sn,se,nfft,cbuf,ierr) call ckerr(ierr) c 20 continue c write(*,*)' se(1,2,3,4)', se(1),se(2),se(3),se(4) c c c Smoothing of the spectrum call apply_smooth(sv,sn,se,nfft,df,nf1,freq, & smv,smn,sme,n_freq,n_win,loop_index,jmin,jmax,ierr) call ckerr(ierr) c 10 continue c c c Optional output for average Fourier spectra call split3(average_spectra_out,argout,sep2,nw) if ( argout(1) .eq. 'yes' )then call average_sd(0,smv,smn,sme,buf1,buf2,buf3,n_freq, # n_win,sv,sn,se,nfft,jmin,jmax,ierr) call ckerr(ierr) c call av_write(1,output_file,freq,buf1,buf2,buf3,n_freq, # sv,sn,se,nfft,f1,f0,f2,jmin,jmax,ierr) call ckerr(ierr) endif c c Merge horizontal spectra, compute h/v and optionally write single c window files call gel_hv(output_file,smv,smn,sme,freq,buf1,n_freq,n_win, # sv,sn,se,nfft,jmin,jmax,ierr) call ckerr(ierr) c c Form average and error estimate for merged and single component H/V call average_sd(1,smv,smn,sme,buf1,buf2,buf3,n_freq, # n_win,sv,sn,se,nfft,jmin,jmax,ierr) call ckerr(ierr) c c Find an estimate of Fo according to Chatelain & Guillier method c .... warning: vector 'smn', of columns dimension 'n_win', is used in c 'comp_f0 as working vector therefore its content (h/v of c ns components of each window) is destroyed after c the call. c In case 'smn' is still needed, a vector(2,n_win) c should be (dynamically) dimensioned. call comp_f0(smv,smn,buf1,freq,n_freq,n_win, # jmin,jmax,f1,f0,f2,ierr) call ckerr(ierr) c c Output of average hv call av_write(0,output_file,freq,buf1,buf2,buf3,n_freq, # sv,sn,se,nfft,f1,f0,f2,jmin,jmax,ierr) call ckerr(ierr) c c return c c c end