35 &
'FAPIDTEST V1.1 this is a program to test libfapidxx.a')
38 integer maxopt, lastarg, iargc
41 character*2 optid(maxopt)
42 character*40 optarg(maxopt)
43 logical optset(maxopt), opthasarg(maxopt)
45 logical debug, verbose
49 data optid/
'-D',
'-v',
'-x',
'-t',
'-w',
'-r',
'-d'/
50 data opthasarg/3*.false.,4*.true./
51 data optarg/3*
'-',
'sff',
'testfile.sff',
'junk.sff',
'1.e-3'/
54 character*40 infile, outfile
55 logical doread, dowrite
62 if (iargc().eq.1)
call getarg(1, argument)
63 if ((argument(1:5).eq.
'-help').or.(iargc().lt.1))
then 65 print *,
'Usage: fapidtest [-r file] [-w file] [-t type]' 67 print *,
' or: fapidtest -help' 68 print *,
' or: fapidtest -x' 69 if (argument(1:5).ne.
'-help')
70 & stop
'ERROR: wrong number of arguments' 72 print *,
'-x print online help' 73 print *,
'-r file test reading from file' 74 print *,
'-w file test writing to file' 75 print *,
'-t type select file type for input/output' 76 print *,
'-d t set sampling interval to ''t'' seconds' 85 call tf_cmdline(1, lastarg, maxopt, optid,
86 & optarg, optset, opthasarg)
100 read(optarg(7), *, err=99) dt
105 print *,
'select format ',formatid
106 call sff_select_format(formatid, ierr)
108 stop
'ERROR: selecting format' 112 print *,
'write data with sampling interval ',dt,
' s' 123 99 stop
'ERROR: reading command line arument' 132 character*(*) filename
133 double precision indt
145 character date*7, time*12,stype*22, wid2line*132, nil*10
150 print *,
'open ',filename(1:index(filename,
' '))
159 call sff_prepwid2(m, rate,
'sta ',
160 & 2011, 04, 01, 12, 32,
'chan ',
'aux ',
'ins ',
161 & 10.023456, -1., -1., -1., -1., wid2line, ierr)
162 if (ierr.ne.0) stop
'ERROR: preparing wid2line' 163 call sff_wopens(lu, filename, stype,
'C', 0., 0., 0., date, time, ierr
164 if (ierr.ne.0) stop
'ERROR: opening file' 168 print *,
'write trace #',i
172 if (k.le.m) d(k)=1./sqrt(i*dx)
175 call sff_wtracei(lu, wid2line, m, d, id, .true.,
'C',
176 & i*dx, 0., 0., 1, ierr)
178 call sff_wtracei(lu, wid2line, m, d, id, .false.,
'C',
179 & i*dx, 0., 0., 1, ierr)
181 if (ierr.ne.0) stop
'ERROR: writing trace' 191 character*(*) filename
195 integer maxsamp, nsamp
196 parameter(maxsamp=100000)
198 integer idata(maxsamp)
199 equivalence(fdata, idata)
202 character code*10, timestamp*13, scs*1, date*6, time*10
203 real sffversion, sc1, sc2, sc3
208 character rcs*1, wid2line*132
209 real rc1, rc2, rc3, tanf, dt
214 print *,
'open ',filename(1:index(filename,
' '))
215 call sff_ropens(lu, filename, sffversion, timestamp, code,
216 & source, scs, sc1, sc2, sc3, date, time, ierr)
218 stop
'ERROR: opening file' 220 print *,
'sffversion: ', sffversion
221 print *,
'timestamp: ', timestamp
222 print *,
'code: ', code
223 print *,
'source: ', source
224 print *,
'scs, sc1, sc2, sc3: ', scs, sc1, sc2, sc3
225 print *,
'date time: ', date,
' ', time
229 print *,
'read next trace' 231 call sff_rtracei(lu, tanf, dt,
232 & wid2line, nsamp, fdata,
234 & rcs, rc1, rc2, rc3, nstack, ierr)
236 print *,
'nsamp: ',nsamp
237 print *,
'rcs, rc1, rc2, rc3: ',rcs, rc1, rc2, rc3
238 print *,
'nstack: ',nstack
240 print *,
'tanf: ',tanf
241 print *,
'code: ',code
243 stop
'ERROR: reading trace' subroutine readtest(filename)
subroutine writetest(filename, indt)