Commit f313e3ba authored by thomas.forbriger's avatar thomas.forbriger Committed by thomas.forbriger
Browse files

multi format read test works properly

This is a legacy commit from before 2015-03-01.
It may be incomplete as well as inconsistent.
See COPYING.legacy and README.history for details.

SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/branches/libdatrwxx.su
SVN Revision: 3488
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent f9e87acb
......@@ -192,7 +192,13 @@ doxyview: $(DOXYWWWPATH)/html/index.html
#======================================================================
# test code
fapidtest: fapidtest.o libfapidxx.a
$(FC) -o $@ $< -lfapidxx -ltf -L$(LOCLIBDIR) -lstdc++
fapidtestx: fapidtest.o libfapidxx.a
$(FC) -o $@ $< -lfapidxx -ldatrwxx -lsffxx -lgsexx -ltime++ \
-laff -ltf -L$(LOCLIBDIR) -lstdc++
/bin/mv -fv $@ $(LOCBINDIR)
fapidtest: fapidtest.o
$(FC) -o $@ $< -lsff -ltf -L$(LOCLIBDIR)
/bin/mv -fv $@ $(LOCBINDIR)
# ----- END OF Makefile -----
......@@ -40,11 +40,14 @@
#include <fapidxx/fapidsff.h>
#include <fapidxx/helper.h>
#include <datrwxx/formats.h>
using namespace fapidxx;
int sff_help_details__(void)
{
datrw::online_help();
return(0);
} // int sff_help_details__(void)
/* ----- END OF fapid_sff_help_details.cc ----- */
......@@ -40,11 +40,14 @@
#include <fapidxx/fapidsff.h>
#include <fapidxx/helper.h>
#include <datrwxx/formats.h>
using namespace fapidxx;
int sff_help_formats__(void)
{
datrw::supported_data_types();
return(0);
} // int sff_help_formats__(void)
/* ----- END OF fapid_sff_help_formats.cc ----- */
......@@ -40,12 +40,23 @@
#include <fapidxx/fapidsff.h>
#include <fapidxx/helper.h>
#include <fapidxx/fileunit.h>
#include <datrwxx/formats.h>
#include <datrwxx/error.h>
using namespace fapidxx;
int sff_select_format__(char *formatid, integer *ierr,
ftnlen formatid_len)
{
std::string formatstring=stringfromfstring(formatid, formatid_len);
*ierr=0;
try {
istreammanager.setformat(formatstring);
} catch (datrw::Exception) {
*ierr=1;
}
return(0);
} // int sff_select_format__
/* ----- END OF fapid_sff_select_format.cc ----- */
......@@ -15,7 +15,7 @@ c
c
character*(*) version
parameter(version=
& 'FAPIDTEST V1.0 this is a program to test several steps of fapid development')
& 'FAPIDTEST V1.0 this is a program to test libfapidxx.a')
character*(*) FAPIDTEST_CVS_ID
parameter(FAPIDTEST_CVS_ID=
& '$Id$')
......@@ -23,18 +23,44 @@ c
c commandline
integer maxopt, lastarg, iargc
character*80 argument
parameter(maxopt=2)
parameter(maxopt=4)
character*2 optid(maxopt)
character*40 optarg(maxopt)
logical optset(maxopt), opthasarg(maxopt)
c debugging
logical debug, verbose
c
real a
c here are the keys to our commandline options
data optid/2h-d, 2h-v/
data opthasarg/2*.FALSE./
data optarg/2*1h-/
data optid/2h-d, 2h-v, 2h-x, 2h-t/
data opthasarg/3*.FALSE.,.TRUE./
data optarg/3*1h-,'sff'/
c
character*80 filename
character*20 formatid
integer lu
parameter(lu=10)
c sff file header
character code*10, timestamp*13, scs*1, date*6, time*10
real sffversion, sc1, sc2, sc3
character*20 source
c
c sff trace
logical last
character rcs*1, wid2line*132
real rc1, rc2, rc3, tanf, dt
integer nstack
c
c functions
real sffu_offset, sffu_tfirst, ts_max, ts_min, ts_average
real offshift
c
c time series
integer maxsamp, nsamp
parameter(maxsamp=100000)
real fdata(maxsamp)
integer idata(maxsamp)
equivalence(fdata, idata)
c
c------------------------------------------------------------------------------
c basic information
......@@ -46,10 +72,14 @@ c
print *,version
print *,'Usage: fapidtest arguments'
print *,' or: fapidtest -help'
print *,' or: fapidtest -x'
if (argument(1:5).ne.'-help')
& stop 'ERROR: wrong number of arguments'
print *,' '
print *,'-x print online help'
print *,FAPIDTEST_CVS_ID
print *,' '
call sff_help_formats
stop
endif
c
......@@ -58,14 +88,58 @@ c read command line arguments
c
call tf_cmdline(1, lastarg, maxopt, optid,
& optarg, optset, opthasarg)
if (optset(3)) then
call sff_help_details
stop
endif
debug=optset(1)
verbose=optset(2)
formatid=optarg(4)
call getarg(lastarg+1, filename)
c
c------------------------------------------------------------------------------
c go
c
call interfacesub(a)
print *,a
print *,'select format ',formatid
call sff_select_format(formatid, ierr)
if (ierr.ne.0) then
stop 'ERROR: selecting format'
endif
print *,'open ',filename(1:index(filename,' '))
call sff_ROpenS(lu, filename, sffversion, timestamp, code,
& source, scs, sc1, sc2, sc3, date, time, ierr)
if (ierr.ne.0) then
stop 'ERROR: opening file'
endif
print *,'sffversion: ', sffversion
print *,'timestamp: ', timestamp
print *,'code: ', code
print *,'source: ', source
print *,'scs, sc1, sc2, sc3: ', scs, sc1, sc2, sc3
print *,'date time: ', date, ' ', time
last=.false.
do while (.not.last)
print *,' '
print *,'read next trace'
nsamp=maxsamp
call sff_RTraceI(lu, tanf, dt,
& wid2line, nsamp, fdata,
& idata, code, last,
& rcs, rc1, rc2, rc3, nstack, ierr)
print *,wid2line
print *,'nsamp: ',nsamp
print *,'rcs, rc1, rc2, rc3: ',rcs, rc1, rc2, rc3
print *,'nstack: ',nstack
print *,'dt: ',dt
print *,'tanf: ',tanf
print *,'code: ',code
if (ierr.ne.0) then
stop 'ERROR: reading trace'
endif
enddo
stop
end
c
......
......@@ -47,6 +47,9 @@ namespace fapidxx {
//! the global istream manager
::fapidxx::IFileUnits istreammanager;
//! file format to be used
datrw::Eformat selectedformat=datrw::Fsff;
/*----------------------------------------------------------------------*/
IFileUnits::IFileUnits()
......@@ -74,7 +77,8 @@ namespace fapidxx {
FAPIDXX_fuassert((!this->isopen(unit)), unit,
"IFileUnits::open: file is already open");
IstreamCompound &compound=Mstreammap[unit];
compound.Mistream=new std::ifstream(filename.c_str());
compound.Mistream=new std::ifstream(filename.c_str(),
datrw::ianystream::openmode(Mformat));
compound.Mianystream=new datrw::ianystream(*compound.Mistream, Mformat);
return (this->getstream(unit));
} // datrw::ianystream& IFileUnits::open
......@@ -109,6 +113,13 @@ namespace fapidxx {
return (*Mstreammap[unit].Mianystream);
} // datrw::ianystream& IFileUnits::getstream(const int& unit)
/*----------------------------------------------------------------------*/
void IFileUnits::setformat(const std::string& format)
{
Mformat=datrw::anyID(format);
} // bool IFileUnits::isopen(const int& unit) const
} // namespace fapidxx
/* ----- END OF fileunit.cc ----- */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment