subroutine av_write(flag,output_file,fre,buf1,buf2,buf3,nf, # sv,sn,se,nfft,f1,f0,f2,jmin,jmax,ierr) c c FLAG = 0 c main output : writes file with average H/V ratios c c FLAG = 1 c writes optional output file with average Fourier spectra c output file name is "output_file"_sp c c originally written by Fortunat Kind (avhv_write.f) c modified by a.tento 05/03 v.1.0 c a.tento 02/04 v.1.0 --> more c implicit none character*200 output_file real sv, sn, se, buf1, buf2, buf3, fre, f1, f0, f2 integer ierr, jmin, jmax, nf, nfft, flag dimension sv(nfft), sn(nfft), se(nfft), fre(nf), # buf1(nf), buf2(nf), buf3(nf) c include 'main.h' include 'parameters.h' include 'window.h' c character fnout*200, row*200 integer j1, nunit ,l, jlen, nfa, iflu, iflc, i c ierr = 0 fnout = output_file if ( flag .ne. 0 ) then j1 = jlen(fnout) fnout(j1 + 1:j1 + 3) = '_sp' endif c call glun(nunit,ierr) if (ierr .eq. 1) then write (*,*) ' ERROR: AV_WRITE: can not find free unit number' ierr=1 return endif c open(unit=nunit,file=fnout,status='unknown') c if ( flag .eq. 0 ) then write(nunit,*) ' ### data used in the H/V ratio processing:' else write(nunit,*) ' ### data used in the FOURIER spectra', # 'processing:' endif c do 1 l = 1, n_windows row=data_file(l) j1 = jlen(row) write(nunit,10) row(1:j1),start_time(l), end_time(l), & idV(l), idN(l), idE(l), idsta(l) 1 continue 10 format(1x,'# ',a,' ',2f13.2,4(1x,a3)) * copy the parameter definitions write(nunit,'(1x,a)') '#' write(nunit,*) '# parameters actually used in the processing:' write(nunit,'(1x,a)') '### section processing' write(nunit,21) freq_spacing write(nunit,22) offset_rem write(nunit,23) taper write(nunit,25) smooth write(nunit,26) merge_type write(nunit,29) single_win_out write(nunit,30) average_spectra_out write(nunit,'(1x,a)') '### end processing' nfa= jmax-jmin +1 if(nfa .ne. nf) write(nunit,300) 21 format(1x,'# freq_spacing:',a) 22 format(1x,'# offset_rem:',a) 23 format(1x,'# taper:',a) 24 format(1x,'# instrument_resp:',a) 25 format(1x,'# smooth:',a) 26 format(1x,'# merge_type:',a) 27 format(1x,'# single_component:',a) 28 format(1x,'# average_type:',a) 29 format(1x,'# single_win_out:',a) 30 format(1x,'# average_spectra_out:',a) 300 format(' # WARNING : output frequency limits have been changed', # ' by the smoothing procedure') c check on units and components labels c iflu = 0 iflc = 0 do 17 i = 2, n_windows if ( kunits(i) .ne. kunits(i-1) ) iflu = 1 if ( kv(i) .ne. kv(i-1) ) iflc = 1 if ( kn(i) .ne. kn(i-1) ) iflc = 1 if ( ke(i) .ne. ke(i-1) ) iflc = 1 17 continue if ( iflu .ne. 0 ) then ierr = 2 if (flag .eq. 0) write(*,*)' WARNING :', # ' UNITS label is not the same for all files' write(nunit,301) 301 format(' # WARNING : UNITS label is not the same for all files') endif if ( iflc .ne. 0 ) then ierr = 2 if (flag .eq. 0) write(*,*)' WARNING :', # ' COMPONENT labels are not the same for all files' write(nunit,302) 302 format(' # WARNING : COMPONENT labels are not the', # ' same for all files') endif c en of the check on units and components labels c write(nunit,'(1x,''#'',30(''-''))') write(nunit,'(1x,''# n_windows: '',i6)') n_windows write(nunit,'(1x,''# window_len: '',f10.3)')rmaxwl write(nunit,127)kunits(1),kv(1),kn(1),ke(1) 127 format(1x,'# labels: ', 4(1x,a12)) if ( flag .eq. 0 ) then write(nunit,123) nfa, f0, f1,f2 123 format(1x,'# n_freq_samples: ',i6,' Fo: ',f9.4, # ' range +/- 1 s.d.: ', f9.4,' - ', f9.4,' [Hz]') write(nunit,350) 350 format(' # freq av_HV ', # 'ns_HV ew_HV av_HV_logstd ', # 'ns_HV_logstd ew_HV_logstd') else write(nunit,124) nfa 124 format(1x,'# n_freq_samples: ',i6) write(nunit,360) 360 format(' # freq vert_sp ', # 'ns_sp ew_sp vert_SD ', # 'ns_SD ew_SD') endif c do 2 l = jmin, jmax write(nunit,40) fre(l), # buf1(l), buf2(l), buf3(l), # sv(l), sn(l), se(l) 2 continue 40 format(7(1x,g15.7)) close(nunit) return end