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

◆ sff_ropens__()

int sff_ropens__ ( integer lu,
char *  filename,
real version,
char *  timestamp,
char *  code,
char *  type__,
char *  cs,
real c1,
real c2,
real c3,
char *  date,
char *  time,
integer ierr,
ftnlen  filename_len,
ftnlen  timestamp_len,
ftnlen  code_len,
ftnlen  type_len,
ftnlen  cs_len,
ftnlen  date_len,
ftnlen  time_len 
)

Open SFF file and return source line.

Description from stuff.f:

c----------------------------------------------------------------------
subroutine sff_ROpenS(lu, filename,
& version, timestamp, code,
& type, cs, c1, c2, c3, date, time, ierr)
c
c Open file for reading. Read STAT line and SRCE line.
c
c input:
c lu logical file unit
c filename name of file
c ouput:
c version version of writing library
c timestamp time and date file was written
c code indicates optional blocks
c ierr error status (ok: ierr=0)
c type type of source
c cs coordinate system
c c1, c2, c3 coordinates of source
c date, time date and time of source signal
c
integer lu, ierr
real version
character timestamp*(*), code *(*)
character filename*(*), type*(*), date*(*), time*(*), cs*1
real c1, c2, c3
c----------------------------------------------------------------------

Definition at line 79 of file fapid_sff_ropens.cc.

References fapidxx::fillfstring(), fapidxx::istreammanager, fapidxx::IFileUnits::open(), and fapidxx::stringfromfstring().

85 {
86  int retval=0;
87  *ierr=0;
88  try {
89  datrw::ianystream &is=
90  istreammanager.open(static_cast<int>(*lu),
91  stringfromfstring(filename, filename_len));
92  sff::SRCE srce;
93  std::string ocode("");
94  if (is.hasfree()) { ocode.append("F"); }
95  if (is.hassrce()) { ocode.append("S"); }
96  if (is.hassrce()) { is >> srce; }
97  // set output
98  std::string srceline=srce.line();
99  fillfstring(ocode, code, code_len);
100  fillfstring(srce.type, type__, type_len);
101  char thecs=sff::coosysID(srce.cs);
102  fillfstring(std::string(&thecs, 1), cs, cs_len);
103  *c1=static_cast<real>(srce.cx);
104  *c2=static_cast<real>(srce.cy);
105  *c3=static_cast<real>(srce.cz);
106  fillfstring(srceline.substr(74,6), date, date_len);
107  fillfstring(srceline.substr(81,10), time, time_len);
108  // timestamp and version got lost
109  sff::STAT stat;
110  fillfstring(stat.timestamp, timestamp, timestamp_len);
111  *version=static_cast<real>(sff::STAT::libversion);
112 // std::cerr << "leaving sff_ropens__" << std::endl;
113  }
114  catch(...) {
115  *ierr=1;
116  }
117  return retval;
118 } // int sff_ropens__
void fillfstring(const std::string &s, char *fstring, ftnlen slen)
fill a Fortran string with a C++ string
Definition: helper.cc:60
float real
Fortran real type (single precision)
Definition: fapidsff.h:73
datrw::ianystream & open(const int &unit, const std::string &filename)
open a new file
Definition: fileunit.cc:77
std::string stringfromfstring(char *fstring, ftnlen slen)
create a C++ string from a Fortran string
Definition: helper.cc:51
::fapidxx::IFileUnits istreammanager
the global istream manager
Definition: fileunit.cc:48
Here is the call graph for this function: