Fortran SFF API to data I/O streams in C++
fapid_sff_rtrace.cc
Go to the documentation of this file.
1 
35 #define TF_FAPID_SFF_RTRACE_CC_VERSION \
36  "TF_FAPID_SFF_RTRACE_CC V1.0 "
37 
38 #include <fapidxx/fapidsff.h>
39 #include <fapidxx/fileunit.h>
40 #include <fapidxx/helper.h>
41 #include <fapidxx/error.h>
42 
43 using namespace fapidxx;
44 
84 int sff_rtrace__(integer *lu, real *tanf, real *dt, char *wid2line,
85  integer *nsamp, real *fdata, integer *idata, char *code,
86  logical *last, integer *ierr,
87  ftnlen wid2line_len, ftnlen code_len)
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__
119 
120 /* ----- END OF fapid_sff_rtrace.cc ----- */
This is the interface usually expected by Fortran programs linking to libsff.a (prototypes) ...
Definition: error.cc:44
long int integer
Fortran integer type.
Definition: fapidsff.h:66
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.
void fillfstring(const std::string &s, char *fstring, ftnlen slen)
fill a Fortran string with a C++ string
Definition: helper.cc:60
exceptions and error handling macros (prototypes)
#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
long int logical
Fortran logical type.
Definition: fapidsff.h:68
long int ftnlen
Fortran string size type.
Definition: fapidsff.h:70
a file unit interface to libdatrwxx (prototypes)
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
some helper functions (prototypes)