Fortran SFF API to data I/O streams in C++

◆ sff_rtrace__()

int sff_rtrace__ ( integer lu,
real tanf,
real dt,
char *  wid2line,
integer nsamp,
real fdata,
integer idata,
char *  code,
logical last,
integer ierr,
ftnlen  wid2line_len,
ftnlen  code_len 
)

Read one trace of data.

Description from stuff.f:

c----------------------------------------------------------------------
subroutine sff_RTrace(lu, tanf, dt,
& wid2line, nsamp, fdata, idata, code, last, ierr)
c
c Read one data block starting with DAST line.
c The File will be closed after reading the last trace.
c
c input
c lu logical file unit
c nsamp array dimension of idata and fdata
c ouput:
c ierr error status (ok: ierr=0)
c code code indicating optional blocks
c wid2line valid WID2 line
c tanf time of first sample from midnight
c dt sampling interval in seconds
c nsamp number of samples
c fdata data array
c last is true if read trace is the last one in this file
c
c workspace:
c idata data will be first read to idata and then converted
c to fdata using sff_i2f (both array may be in same memory
c space - see comments on sff_f2i)
c
integer lu, nsamp, idata(nsamp)
real fdata(nsamp), dt, tanf
logical last
character wid2line*132, code*(*)
c----------------------------------------------------------------------

Definition at line 84 of file fapid_sff_rtrace.cc.

References FAPIDXX_fuassert, fapidxx::fillfstring(), fapidxx::istreammanager, and fapidxx::maketanf().

88 {
89  int retval=0;
90  *ierr=0;
91  try {
92  datrw::ianystream &is=istreammanager(static_cast<int>(*lu));
93  sff::WID2 wid2;
94  datrw::Tfseries iseries;
95  is >> iseries;
96  FAPIDXX_fuassert((static_cast<int>(iseries.size())<=(*nsamp)), *lu,
97  "sff_rtracei__: too many samples");
98  int nsamples=iseries.size();
99  aff::LinearShape shape(0, nsamples-1, 0);
100  datrw::Tfseries series(shape, aff::SharedHeap<real>(fdata, *nsamp));
101  series.copyin(iseries);
102  *last = is.last() ? 1 : 0;
103  is >> wid2;
104  std::string ocode("");
105  if (is.hasfree()) { ocode.append("F"); }
106  if (is.hasinfo()) { ocode.append("I"); }
107  if (!is.last()) { ocode.append("D"); }
108  fillfstring(ocode, code, code_len);
109  *tanf=static_cast<real>(maketanf(wid2.date));
110  *dt=static_cast<real>(wid2.dt);
111  fillfstring(wid2.line(), wid2line, wid2line_len);
112  *nsamp=series.size();
113  }
114  catch(...) {
115  *ierr=1;
116  }
117  return retval;
118 } // int sff_rtrace__
void fillfstring(const std::string &s, char *fstring, ftnlen slen)
fill a Fortran string with a C++ string
Definition: helper.cc:60
#define FAPIDXX_fuassert(C, U, M)
Check an assertion and report by throwing an exception.
Definition: error.h:205
float real
Fortran real type (single precision)
Definition: fapidsff.h:73
float maketanf(const libtime::TAbsoluteTime &time)
create the tanf value
Definition: helper.cc:118
::fapidxx::IFileUnits istreammanager
the global istream manager
Definition: fileunit.cc:48
Here is the call graph for this function: