39 parameter(version=
'SUSEI V1.4 SUm of SEIsmograms')
42 integer maxsamps, maxfree
43 parameter(maxsamps=150000, maxfree=20)
45 integer i, nsumfiles,ifile
47 real xdata(maxsamps), ydata(maxsamps)
48 integer ixdata(maxsamps), iydata(maxsamps)
49 equivalence(xdata,ixdata)
50 equivalence(ydata,iydata)
51 character*80 inxname, inyname, inputformat
56 integer idata(maxsamps)
57 equivalence(
data,idata)
58 character*80 outname, outputformat
59 character*132 wid2line
63 character*80 free(maxfree)
66 character timestamp*13, code*10, type*20, cs*1, date*6, time*10
67 character code2*10, cs2*1
68 real c1,c2,c3,c12,c22,c32
69 integer ierr,nsamp,nsamp2,nstack,nstack2
72 character*132 wid2line2
74 integer maxopt, lastarg, iargc
77 character*3 optid(maxopt)
78 character*40 optarg(maxopt)
79 logical optset(maxopt), opthasarg(maxopt)
85 data optid/
'-d',
'-nn',
'-ty',
'-it',
'-ot'/
86 data opthasarg/2*.false.,3*.true./
87 data optarg/2*
'-',
'sff',
'sff',
'sff'/
93 print *,
'Usage: susei [-nn] [-ty f] [-it f] [-ot f]' 94 print *,
' file1 file2 ... outfile' 95 print *,
' or: susei -help' 97 if (iargc().lt.1) stop
'ERROR: missing arguments' 98 call getarg(1, argument)
99 if (argument(1:5).eq.
'-help')
then 101 print *,
'SUm of SEIsmograms' 103 print *,
'file1 first input data file' 104 print *,
'file2 second input data file to be stacked to file1' 105 print *,
'... further input data files to be stacked' 106 print *,
'outfile output data file' 108 print *,
'-nn do not normalize' 109 print *,
' The program is inteded to be used for stacking.' 110 print *,
' In that case the amplitude should be normalized' 111 print *,
' by the number of traces stacked. This option' 112 print *,
' turns off amplitude normalization.' 113 print *,
'-ty f choose file format ''f'' instead of SFF' 114 print *,
' for input and output files' 115 print *,
'-it f choose input file format ''f'' instead of SFF' 116 print *,
'-ot f choose output file format ''f'' instead of SFF' 118 print *,
'The data files are expected to have the same number of' 119 print *,
'traces each. The number of traces is determined' 120 print *,
'from the file with the least number of traces.' 121 print *,
'All traces of equal index within each file are' 122 print *,
'expected to have the same number of samples. The' 123 print *,
'programs aborts, if this is not the case. No further' 124 print *,
'consistency checks are applied.' 126 call sff_help_formats
129 if (iargc().lt.3) stop
'ERROR: too few arguments' 135 call tf_cmdline(1, lastarg, maxopt, optid,
136 & optarg, optset, opthasarg)
138 nonormalize=optset(2)
139 inputformat=optarg(3)
140 outputformat=optarg(3)
141 if (optset(4)) inputformat=optarg(4)
142 if (optset(5)) outputformat=optarg(5)
144 nsumfiles=iargc()-lastarg-2
146 call getarg(lastarg+1, inxname)
147 call getarg(lastarg+nsumfiles+2, outname)
150 call sff_select_input_format(inputformat, ierr)
151 if (ierr.ne.0) stop
'ERROR: selected input format is not supported' 152 call sff_select_output_format(outputformat, ierr)
153 if (ierr.ne.0) stop
'ERROR: selected output format is not supported' 159 free(2)=
'first data from '//inxname(1:index(inxname,
' '))
160 free(3)=
'second data from '//inyname(1:index(inyname,
' '))
161 free(4)=
'all information is taken from first data file' 162 free(5)=
'no plausibility checks were performed' 165 print *,
'open ',inxname(1:index(inxname,
' ')),
'for input' 166 call sff_ropens(lui, inxname,
167 & libversion, timestamp, code,
168 &
type, cs, c1, c2, c3, date, time, ierr)
169 if (ierr.ne.0) stop
'ERROR: opening x-component' 170 call sff_new(luo, outname, ierr)
171 print *,
'open ',outname(1:index(outname,
' ')),
'for output' 172 call sff_wopenfs(luo, outname,
174 &
type, cs, c1, c2, c3, date, time, ierr)
175 if (ierr.ne.0) stop
'ERROR: opening output file' 177 call getarg(lastarg+ifile+1, inyname)
178 print *,
'open ',inyname(1:index(inyname,
' ')),
'for input' 179 call sff_ropens(lui+ifile, inyname,
180 & libversion, timestamp, code,
181 &
type, cs, c1, c2, c3, date, time, ierr)
182 if (ierr.ne.0) stop
'ERROR: opening y-component' 190 do while (.not.(last))
192 call sff_rtracei(lui, tanf, dt, wid2line, nsamp, xdata, ixdata,
193 & code, last, cs, c1, c2, c3, nstack, ierr)
194 if (ierr.ne.0) stop
'ERROR: reading x-data' 200 call sff_rtracei(lui+ifile, tanf, dt, wid2line2,
201 & nsamp2, ydata, iydata,
202 & code2, last2, cs2, c12, c22, c32, nstack2, ierr)
204 print *,
'ERROR: reading y-data no. ',ifile
207 if (nsamp.ne.nsamp2)
then 208 print *,
'ERROR: wrong number of samples in y-data no. ',ifile
213 data(i)=(
data(i)+ydata(i))
216 if (.not.nonormalize)
then 218 data(i)=
data(i)/float(nsumfiles+1)
221 wid2line(36:38)=
'NSP' 223 call sff_wtracei(luo, wid2line, nsamp,
data, idata, last,
224 & cs, c1, c2, c3, nstack, ierr)
225 if (ierr.ne.0) stop
'ERROR: writing trace'