38 integer maxtraces, maxsamples, maxfree
39 parameter(maxtraces=3,maxsamples=1000000,maxfree=4)
43 character*80 infile, outfile, switch
49 character*13 timestamp
50 character*80 free(maxfree)
51 character*132 wid2line(maxtraces)
52 integer idata(maxsamples)
53 real fdata(maxsamples)
54 equivalence(idata,fdata)
55 integer firstsamp(maxtraces)
56 real tanf(maxtraces), dt(maxtraces)
57 integer nsamp(maxtraces), sample, trace
66 version=
'XYZ2UVW V1.2 calculate STS-2 components' 69 print *,
'Usage: xyz2uvw -x|-u infile outfile' 70 print *,
'or: xyz2uvw -help' 71 if (iargc().lt.1) stop
'ERROR: check argumemnts\n' 73 call getarg(1, infile)
74 if (infile(1:5).eq.
'-help')
then 76 print *,
'STS-2 output components X, Y, Z are not identical to' 77 print *,
'the sensor components U, V, W. For some purposes it' 78 print *,
'is desireable to have U, V, W seismograms.' 80 print *,
'-x input file has components X,Y,Z' 81 print *,
' trace infile outfile' 86 print *,
'-u input file has components U,V,W' 87 print *,
' trace infile outfile' 94 if (iargc().ne.3) stop
'ERROR: check argumemnts\n' 96 call getarg(1, switch)
97 call getarg(2, infile)
98 call getarg(3, outfile)
99 if (switch.eq.
'-x')
then 101 elseif (switch.eq.
'-u')
then 104 stop
'ERROR: wrong option (use -x or -u)\n' 108 call sff_ropen(lu, infile, version, timestamp, code, ierr)
109 if (ierr.ne.0) stop
'ERROR: opening input file' 112 nsamp(trace)=maxsamples
113 call sff_rtrace(lu, tanf(trace), dt(trace), wid2line(trace),
115 & fdata(firstsamp(trace)), idata(firstsamp(trace)),
117 if (ierr.ne.0) stop
'ERROR: reading trace\n' 119 firstsamp(trace+1)=firstsamp(trace)+nsamp(trace)
120 if ((firstsamp(trace+1)+nsamp(trace)).gt.maxsamples)
121 & stop
'ERROR: too many samples\n' 122 if (last) stop
'ERROR: less than 3 traces in file\n' 124 if (nsamp(trace).ne.nsamp(1))
125 & stop
'ERROR: inconsistent number of samples\n' 126 if (dt(trace).ne.dt(1))
127 & stop
'ERROR: inconsistent sampling intervals\n' 128 if (tanf(trace).ne.tanf(1))
129 & stop
'ERROR: inconsistent time of first sample\n' 131 if (.not.(last))
close (lu)
169 write(6,
'(i6,3(2x,f10.6),i6)') b(i),(t(i,j), j=1,3),a(i)
178 r(i)=r(i)+(fdata(a(j)+sample)*t(i,j))
182 fdata(b(i)+sample)=r(i)
187 write(free(1),
'(a)') version
188 write(free(2),
'(aa)')
'input file: ',infile(1:index(infile,
' ')-1
189 write(free(3),
'(aa)')
'output file: ',outfile(1:index(outfile,
' ' 191 write(free(4),
'(a)')
'conversion is done from x,y,z to u,v,w' 193 write(free(4),
'(a)')
'conversion is done from u,v,w to x,y,z' 202 call modchan(wid2line(1),
'Z/Z')
203 call modchan(wid2line(2),
'N/Y')
204 call modchan(wid2line(3),
'E/X')
208 call sff_wopenf(lu, outfile, free, maxfree, ierr)
209 if (ierr.ne.0) stop
'ERROR: opening output file' 212 if (trace.eq.3) last=.true.
213 call sff_wtrace(lu, wid2line(trace),
215 & fdata(firstsamp(trace)), idata(firstsamp(trace)),
217 if (ierr.ne.0) stop
'ERROR: writing trace\n' 225 subroutine modchan(wid2line, chan)
226 character*132 wid2line
228 write(wid2line(36:38),
'(a3)') chan
subroutine modchan(wid2line, chan)