Fortran SFF API to data I/O streams in C++
fapid_sff_rtracefi.cc
Go to the documentation of this file.
1 
35 #define TF_FAPID_SFF_RTRACEFI_CC_VERSION \
36  "TF_FAPID_SFF_RTRACEFI_CC V1.0 "
37 
38 
39 #include <fapidxx/fapidsff.h>
40 #include <fapidxx/fileunit.h>
41 #include <fapidxx/helper.h>
42 #include <fapidxx/error.h>
43 
44 using namespace fapidxx;
45 
95 int sff_rtracefi__(integer *lu, real *tanf, real *dt, char *wid2line,
96  integer *nsamp, real *fdata, integer *idata, char *code,
97  logical *last, integer *nline, char *lines,
98  integer *lindim, integer *lenmax, char *cs, real *c1,
99  real *c2, real *c3, integer *nstack, integer *ierr,
100  ftnlen wid2line_len, ftnlen code_len,
101  ftnlen lines_len, ftnlen cs_len)
102 {
103  int retval=0;
104  *ierr=0;
105  try {
106  datrw::ianystream &is=istreammanager(static_cast<int>(*lu));
107  sff::WID2 wid2;
108  sff::INFO info;
109  datrw::Tfseries iseries;
110  is >> iseries;
111  FAPIDXX_fuassert((static_cast<int>(iseries.size())<=(*nsamp)), *lu,
112  "sff_rtracefi__: too many samples");
113  int nsamples=iseries.size();
114  aff::LinearShape shape(0, nsamples-1, 0);
115  datrw::Tfseries series(shape, aff::SharedHeap<real>(fdata, *nsamp));
116  series.copyin(iseries);
117  *last = is.last() ? 1 : 0;
118  is >> wid2;
119  std::string ocode("");
120  if (is.hasfree()) { ocode.append("F"); }
121  if (is.hasinfo()) { ocode.append("I"); }
122  if (!is.last()) { ocode.append("D"); }
123  if (is.hasinfo()) { is >> info; }
124  fillfstring(ocode, code, code_len);
125  *tanf=static_cast<real>(maketanf(wid2.date));
126  *dt=static_cast<real>(wid2.dt);
127  fillfstring(wid2.line(), wid2line, wid2line_len);
128  *nsamp=series.size();
129  char thecs=sff::coosysID(info.cs);
130  fillfstring(std::string(&thecs, 1), cs, cs_len);
131  *c1=static_cast<real>(info.cx);
132  *c2=static_cast<real>(info.cy);
133  *c3=static_cast<real>(info.cz);
134  *nstack=info.nstacks;
135  sff::FREE free;
136  if (is.hasfree()) { is >> free; }
137  freeblock(free, nline, lines, lindim, lenmax, lines_len);
138  }
139  catch(...) {
140  *ierr=1;
141  }
142  return retval;
143 } // int sff_rtracefi__
144 
145 /* ----- END OF fapid_sff_rtracefi.cc ----- */
This is the interface usually expected by Fortran programs linking to libsff.a (prototypes) ...
Definition: error.cc:44
sff::FREE freeblock(integer *nline, char *lines, ftnlen lines_len)
create C++ FREE block from Fortran FREE lines
Definition: helper.cc:150
long int integer
Fortran integer type.
Definition: fapidsff.h:66
int sff_rtracefi__(integer *lu, real *tanf, real *dt, char *wid2line, integer *nsamp, real *fdata, integer *idata, char *code, logical *last, integer *nline, char *lines, integer *lindim, integer *lenmax, char *cs, real *c1, real *c2, real *c3, integer *nstack, integer *ierr, ftnlen wid2line_len, ftnlen code_len, ftnlen lines_len, ftnlen cs_len)
Read one trace of data and return FREE block and INFO line additionally.
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)