Waveform filter programs
coro.f
Go to the documentation of this file.
1 c this is <coro.f>
2 c------------------------------------------------------------------------------
3 c
4 c 27/05/98 by Thomas Forbriger (IfG Stuttgart)
5 c
6 c seismogram COmponent ROtation
7 c
8 c ----
9 c This program is free software; you can redistribute it and/or modify
10 c it under the terms of the GNU General Public License as published by
11 c the Free Software Foundation; either version 2 of the License, or
12 c (at your option) any later version.
13 c
14 c This program is distributed in the hope that it will be useful,
15 c but WITHOUT ANY WARRANTY; without even the implied warranty of
16 c MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 c GNU General Public License for more details.
18 c
19 c You should have received a copy of the GNU General Public License
20 c along with this program; if not, write to the Free Software
21 c Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 c ----
23 c
24 c REVISIONS and CHANGES
25 c 27/05/98 V1.0 Thomas Forbriger
26 c 06/12/04 V1.1 set component name
27 c
28 c==============================================================================
29 c
30  program coro
31 c
32  character*79 version
33  parameter(version='CORO V1.1 seismogram COmponent ROtation')
34 c
35 c dimensions
36  integer maxsamps, maxfree
37  parameter(maxsamps=66000, maxfree=20)
38 c parameters
39  real vx,vy,vz,amp
40  character*80 para
41 c
42  integer i
43 c input data
44  real xdata(maxsamps), ydata(maxsamps), zdata(maxsamps)
45  integer ixdata(maxsamps), iydata(maxsamps), izdata(maxsamps)
46  equivalence(xdata,ixdata)
47  equivalence(ydata,iydata)
48  equivalence(zdata,izdata)
49  character*80 inxname, inyname, inzname
50  integer lux, luy, luz
51  parameter(lux=10, luy=11, luz=12)
52 c output data
53  real data(maxsamps)
54  integer idata(maxsamps)
55  equivalence(data,idata)
56  character*80 outname
57  character*132 wid2line
58  integer luo
59  parameter(luo=13)
60 c sff extras
61  character*80 free(maxfree)
62  integer nfree
63  real libversion
64  character timestamp*13, code*10, type*20, cs*1, date*6, time*10
65  character code2*10, cs2*1
66  real c1,c2,c3,c12,c22,c32
67  integer ierr,nsamp,nsamp2,nstack,nstack2
68  logical last,last2
69  real tanf,dt
70  character*132 wid2line2
71  character*40 compname
72 c commandline
73  integer maxopt, lastarg, iargc
74  parameter(maxopt=2)
75  character*2 optid(maxopt)
76  character*40 optarg(maxopt)
77  logical optset(maxopt), opthasarg(maxopt)
78 c debugging
79  logical debug
80 c here are the keys to our commandline options
81  data optid/2h-d,2h-n/
82  data opthasarg/.false.,.true./
83  data optarg/1h-,3hnsp/
84 c
85 c------------------------------------------------------------------------------
86 c basic information
87 c
88  print *,version
89  print *,'Usage: coro x,y,z inx iny inz out [-n name]'
90  print *,' or: coro -help'
91 c
92  if (iargc().lt.1) stop 'ERROR: missing arguments'
93  call getarg(1, para)
94  if (para(1:5).eq.'-help') then
95  print *,' '
96  print *,'seismogram COmponent ROtation'
97  print *,' '
98  print *,'x,y,z components of a vactor that defines the'
99  print *,' direction of the resulting component'
100  print *,'inx filename of input seismograms for x-component'
101  print *,'iny filename of input seismograms for y-component'
102  print *,'inz filename of input seismograms for z-component'
103  print *,'out filename of output seismograms'
104  print *,' '
105  print *,'-n name set name of new component'
106  print *,' '
107  print *,'All information about source and receiver location will'
108  print *,'be taken from inx. No plausibility checks are performed!'
109  print *,' '
110  stop
111  endif
112 c
113 c------------------------------------------------------------------------------
114 c read command line arguments
115 c
116  call tf_cmdline(6, lastarg, maxopt, optid,
117  & optarg, optset, opthasarg)
118  debug=optset(1)
119  compname=optarg(2)
120 c
121  call getarg(1, para)
122  call getarg(2, inxname)
123  call getarg(3, inyname)
124  call getarg(4, inzname)
125  call getarg(5, outname)
126 c
127 c------------------------------------------------------------------------------
128 c
129 c calculate direction
130  read(para, *) vx,vy,vz
131  amp=sqrt(vx*vx+vy*vy+vz*vz)
132  vx=vx/amp
133  vy=vy/amp
134  vz=vz/amp
135 c
136  free(1)=version
137  write(free(2), '(3hvx=,f10.6,2x,3hvy=,f10.6,2x,3hvz=,f10.6)')
138  & vx,vy,vz
139  free(3)='x-data from '//inxname(1:index(inxname, ' '))
140  free(4)='y-data from '//inyname(1:index(inyname, ' '))
141  free(5)='z-data from '//inzname(1:index(inzname, ' '))
142  free(6)='all information is taken from x-data file'
143  free(7)='no plausibility checks were performed'
144  nfree=7
145 c
146  call sff_ropens(lux, inxname,
147  & libversion, timestamp, code,
148  & type, cs, c1, c2, c3, date, time, ierr)
149  if (ierr.ne.0) stop 'ERROR: opening x-component'
150  call sff_new(luo, outname, ierr)
151  call sff_wopenfs(luo, outname,
152  & free, nfree,
153  & type, cs, c1, c2, c3, date, time, ierr)
154  if (ierr.ne.0) stop 'ERROR: opening output file'
155  call sff_ropens(luy, inyname,
156  & libversion, timestamp, code,
157  & type, cs, c1, c2, c3, date, time, ierr)
158  if (ierr.ne.0) stop 'ERROR: opening y-component'
159  call sff_ropens(luz, inzname,
160  & libversion, timestamp, code,
161  & type, cs, c1, c2, c3, date, time, ierr)
162  if (ierr.ne.0) stop 'ERROR: opening z-component'
163 c
164  last=.false.
165  do while (.not.(last))
166  nsamp=maxsamps
167  call sff_rtracei(lux, tanf, dt, wid2line, nsamp, xdata, ixdata,
168  & code, last, cs, c1, c2, c3, nstack, ierr)
169  if (ierr.ne.0) stop 'ERROR: reading x-data'
170  nsamp2=maxsamps
171  call sff_rtracei(luy, tanf, dt, wid2line2, nsamp2, ydata, iydata,
172  & code2, last2, cs2, c12, c22, c32, nstack2, ierr)
173  if (ierr.ne.0) stop 'ERROR: reading y-data'
174  if (nsamp.ne.nsamp2) stop 'ERROR: wrong number of samples in y-data'
175  last=(last.or.last2)
176  nsamp2=maxsamps
177  call sff_rtracei(luz, tanf, dt, wid2line2, nsamp2, zdata, izdata,
178  & code2, last2, cs2, c12, c22, c32, nstack2, ierr)
179  if (ierr.ne.0) stop 'ERROR: reading z-data'
180  if (nsamp.ne.nsamp2) stop 'ERROR: wrong number of samples in z-data'
181  last=(last.or.last2)
182 c
183  do i=1,nsamp
184  data(i)=vx*xdata(i)+vy*ydata(i)+vz*zdata(i)
185  enddo
186  wid2line(36:38)=compname(1:3)
187 c
188  call sff_wtracei(luo, wid2line, nsamp, data, idata, last,
189  & cs, c1, c2, c3, nstack, ierr)
190  if (ierr.ne.0) stop 'ERROR: writing trace'
191  enddo
192 c
193  stop
194  end
195 c
196 c ----- END OF coro.f -----
program coro
Definition: coro.f:30