32 parameter(version=
'ROTATE V1.1 rotate horizontal components')
34 integer maxtraces, maxsamples, maxfree
35 parameter(maxtraces=3,maxsamples=1000000,maxfree=6)
39 character*80 infile, outfile, angle
45 character*13 timestamp
46 character*80 free(maxfree)
47 character*132 wid2line(maxtraces), wid2
48 integer idata(maxsamples)
49 real fdata(maxsamples)
50 equivalence(idata,fdata)
51 integer firstsamp(maxtraces)
52 real tanf(maxtraces), dt(maxtraces)
53 integer nsamp(maxtraces), sample, trace
56 integer cnsamp, cesamp
57 real vcos, vsin, pi, radial, trans, rangle
63 print *,
'Usage: rotate infile outfile angle' 64 print *,
'or: rotate -help' 66 call getarg(1, infile)
67 if (infile(1:5).eq.
'-help')
then 69 print *,
' Data will be read from infile an written to outfile' 70 print *,
' in sff data format. The file has to consist of three' 71 print *,
' traces which will be called Z, N and E component' 72 print *,
' (in that order). The horizontal components will be' 73 print *,
' rotated by the amount of angle. Angle is counted in' 74 print *,
' degrees from north to east. Hence the input north' 75 print *,
' component will be the output east component if you' 76 print *,
' set angle to 90.' 78 print *,
'The second trace will be ''R'' on output and the' 79 print *,
'third will be ''T''.' 82 if (iargc().ne.3) stop
'ERROR: check argumemnts' 84 call getarg(1, infile)
85 call getarg(2, outfile)
90 print *,
'open input data...' 91 call sff_ropen(lu, infile, fversion, timestamp, code, ierr)
92 if (ierr.ne.0) stop
'ERROR: opening input file' 93 print *,
'read input data...' 96 nsamp(trace)=maxsamples-firstsamp(trace)
97 call sff_rtrace(lu, tanf(trace), dt(trace), wid2line(trace),
99 & fdata(firstsamp(trace)), idata(firstsamp(trace)),
103 if (ierr.ne.0) stop
'ERROR: reading trace\n' 105 firstsamp(trace+1)=firstsamp(trace)+nsamp(trace)
106 if ((firstsamp(trace+1)+nsamp(trace)).gt.maxsamples)
107 & stop
'ERROR: too many samples\n' 108 if (last) stop
'ERROR: less than 3 traces in file\n' 110 if ((nsamp(trace).ne.nsamp(1)).or.
111 & (dt(trace).ne.dt(1)).or.
112 & (tanf(trace).ne.tanf(1))) stop
'ERROR: inconsistent dataset\n' 114 if (.not.(last))
close (lu)
119 vcos=cos(pi*rangle/180.)
120 vsin=sin(pi*rangle/180.)
121 print 50,
'R', vcos, vsin
122 print 50,
'T', -vsin, vcos
123 50
format(
' ',a,
'=',f7.4,
'*N + ',f7.4,
'*E')
125 cnsamp=sample+firstsamp(2)-1
126 cesamp=sample+firstsamp(3)-1
127 radial=fdata(cnsamp)*vcos+fdata(cesamp)*vsin
128 trans=fdata(cesamp)*vcos-fdata(cnsamp)*vsin
134 print *,
'prepare comments...' 135 write(free(1),
'(a)') version
136 write(free(2),
'(aa)')
'input file: ',infile(1:index(infile,
' ')-1
137 write(free(3),
'(aa)')
'output file: ',outfile(1:index(outfile,
' ' 138 write(free(4),
'(af10.3)')
'angle of rotation (degrees): ',rangle
146 print *,
'open output data...' 147 call sff_wopenf(lu, outfile, free, maxfree, ierr)
148 if (ierr.ne.0) stop
'ERROR: opening output file' 149 print *,
'write output data...' 152 if (trace.eq.3) last=.true.
155 call sff_wtrace(lu, wid2line(trace),
157 & fdata(firstsamp(trace)), idata(firstsamp(trace)),
159 if (ierr.ne.0) stop
'ERROR: writing trace\n' 167 subroutine modchan(wid2line, chan)
168 character*132 wid2line
170 write(wid2line(36:38),
'(a3)') chan
subroutine modchan(wid2line, chan)