36 parameter(version=
'SUSPECT V1.2 SUm of SPECTra')
39 integer maxsamps, maxfree
40 parameter(maxsamps=16400, maxfree=20)
49 real xdata(maxsamps), ydata(maxsamps), zdata(maxsamps)
50 integer ixdata(maxsamps), iydata(maxsamps), izdata(maxsamps)
51 equivalence(xdata,ixdata)
52 equivalence(ydata,iydata)
53 equivalence(zdata,izdata)
54 character*80 inxname, inyname
56 parameter(lux=10, luy=11, luz=12)
59 integer idata(maxsamps)
60 double complex spect(maxsamps)
61 equivalence(
data,idata)
63 character*132 wid2line
67 character*80 free(maxfree)
70 character timestamp*13, code*10, type*20, cs*1, date*6, time*10
71 character code2*10, cs2*1
72 real c1,c2,c3,c12,c22,c32
73 integer ierr,nsamp,nsamp2,nstack,nstack2
76 character*132 wid2line2
80 integer sdate1(7), sdate2(7), rdate1(7), rdate2(7), toff1(7), toff2(
81 double precision offsec1, offsec2, offseco
82 integer sdateo(7), rdateo(7), toffo(7)
84 integer maxopt, lastarg, iargc
87 character*2 optid(maxopt)
88 character*40 optarg(maxopt)
89 logical optset(maxopt), opthasarg(maxopt)
94 data opthasarg/2*.false./
101 print *,
'Usage: suspect file1 file2 outfile [-s]' 102 print *,
' or: suspect -help' 104 if (iargc().lt.1) stop
'ERROR: missing arguments' 105 call getarg(1, argument)
106 if (argument(1:5).eq.
'-help')
then 108 print *,
'SUm of SEIsmograms' 110 print *,
'file1 first input file' 111 print *,
'file2 second input file' 112 print *,
'outfile output file' 114 print *,
'-s The default coordinate system for SFF data is set' 115 print *,
' to cartesian. This will be set in the case of the' 116 print *,
' input file containing no source coordinates.' 117 print *,
' Use this option to force using spherical coordinates.' 119 print *,
'The program read all traces from the first input file' 120 print *,
'and stacks them on the corresponding traces of the' 121 print *,
'second input file. The resulting traces arw written to the' 122 print *,
'the output file. Data is expected to contain a source' 123 print *,
'origin time which might differ from the time of first' 124 print *,
'for this reason both input traces are first aligned' 125 print *,
'to origin time (by application of the time shift in' 126 print *,
'the Fourier domain).' 128 print *,
'The original purpose of this program was to calculate' 129 print *,
'appropriate waveforms for seismograms on the global' 130 print *,
'sphere for epicentral distances larger than 180 deg' 131 print *,
'by applying the focal phase shift first and then' 132 print *,
'stacking them with the waves travelling along the' 136 if (iargc().lt.3) stop
'ERROR: too few arguments' 142 call tf_cmdline(4, lastarg, maxopt, optid,
143 & optarg, optset, opthasarg)
147 call getarg(1, inxname)
148 call getarg(2, inyname)
149 call getarg(3, outname)
155 free(2)=
'first data from '//inxname(1:index(inxname,
' '))
156 free(3)=
'second data from '//inyname(1:index(inyname,
' '))
157 free(4)=
'all information is taken from first data file' 158 free(5)=
'no plausibility checks were performed' 161 call sff_ropens(luy, inyname,
162 & libversion, timestamp, code,
163 &
type, cs, c1, c2, c3, date, time, ierr)
164 if (ierr.ne.0) stop
'ERROR: opening y-component' 165 call sff_new(luo, outname, ierr)
166 if (index(code,
'S').gt.0)
then 167 call sffu_timesrce(date, time, sdate2)
170 print *,
'WARNING: SRCE line is missing!' 171 print *,
'WARNING: setting zero SRCE time!' 172 call time_clear(sdate2)
178 call sff_ropens(lux, inxname,
179 & libversion, timestamp, code,
180 &
type, cs, c1, c2, c3, date, time, ierr)
181 if (ierr.ne.0) stop
'ERROR: opening x-component' 182 call sff_new(luo, outname, ierr)
184 call time_clear(sdate1)
188 if (index(code,
'S').gt.0)
then 189 call sffu_timesrce(date, time, sdate1)
192 print *,
'WARNING: SRCE line is missing!' 193 print *,
'WARNING: setting zero SRCE time!' 194 call time_clear(sdate1)
197 call time_clear(sdate2)
204 if (time_compare(sdate1,sdate2).lt.0)
then 205 call time_copy(sdate1,sdateo)
207 call time_copy(sdate2,sdateo)
209 call sffu_srcetime(sdateo,date,time)
211 if (spherical) cs=
'S' 213 call sff_wopenfs(luo, outname,
215 &
type, cs, c1, c2, c3, date, time, ierr)
216 if (ierr.ne.0) stop
'ERROR: opening output file' 219 do while (.not.(last))
221 call sff_rtracei(lux, tanf, dt, wid2line, nsamp, xdata, ixdata,
222 & code, last, cs, c1, c2, c3, nstack, ierr)
223 if (ierr.ne.0) stop
'ERROR: reading x-data' 225 call sffu_timewid2(wid2line, rdate1)
230 call time_sub(rdate1,sdate1,toff1)
231 offsec1=sffu_seconds(toff1)
233 call sff_rtracei(luy, tanf, dt2, wid2line2, nsamp2, ydata, iydata
235 if (ierr.ne.0) stop
'ERROR: reading y-data' 236 call sffu_timewid2(wid2line2, rdate2)
241 call time_sub(rdate2,sdate2,toff2)
256 offsec2=sffu_seconds(toff2)
257 if (time_compare(rdate1,rdate2).lt.0)
then 258 call time_copy(rdate1,rdateo)
260 call time_copy(rdate2,rdateo)
262 offseco=min(offsec1,offsec2)
265 if (nsamp.ne.nsamp2) stop
'ERROR: wrong number of samples in y-data' 266 if (dt.ne.dt2) stop
'ERROR: inconsistent sampling rates' 268 call shifttrace(maxsamps, nsamp, spect, xdata, dt, offsec1)
269 call shifttrace(maxsamps, nsamp2, spect, ydata, dt, offsec2)
272 data(i)=(xdata(i)+ydata(i))
274 wid2line(36:38)=
'NSP' 276 call time_sub(rdateo,sdateo,toffo)
277 offseco=sffu_seconds(toffo)
278 call shifttrace(maxsamps, nsamp, spect,
data, dt, -offseco)
280 call sffu_setwid2time(wid2line, rdateo)
281 call sff_modwid2samps(wid2line, nsamp)
283 call sff_wtracei(luo, wid2line, nsamp,
data, idata, last,
284 & cs, c1, c2, c3, nstack, ierr)
285 if (ierr.ne.0) stop
'ERROR: writing trace' 293 subroutine shifttrace(maxsamp, nsamp, spect, data, dt, timeshift)
295 integer maxsamp, nsamp
296 double complex spect(maxsamp)
299 double precision timeshift
302 parameter(pi=3.14159265358979311599796346854418516d0)
304 integer npow, powsamp,i
306 real*8 singback, singto
307 parameter(singback=1.d0, singto=-1.d0)
312 do while (powsamp.lt.nsamp)
317 if (powsamp.gt.maxsamp)
then 318 print *,
'ERROR: dataset has ',nsamp,
' samples' 319 print *,
'ERROR: fourier number of samples should be ',powsamp
320 print *,
'ERROR: array size is ',maxsamp
325 spect(i)=dcmplx(
data(i))
330 call tf_dfork(powsamp, spect, singback)
331 factor=(0.d0,1.d0)*(1.d0/(powsamp*dt))*2.d0*pi*timeshift
333 spect(i+1)=spect(i+1)*exp(i*factor)
336 spect(powsamp-i)=conjg(spect(i+2))
338 call tf_dfork(powsamp, spect, singto)
341 data(i)=sngl(
real(spect(i)))
subroutine shifttrace(maxsamp, nsamp, spect, data, dt, timeshift)