Fortran SFF API to data I/O streams in C++
fapid_sff_ropen.cc
Go to the documentation of this file.
1 
35 #define TF_FAPID_SFF_ROPEN_CC_VERSION \
36  "TF_FAPID_SFF_ROPEN_CC V1.0 "
37 
38 #include <fapidxx/fapidsff.h>
39 #include <fapidxx/fileunit.h>
40 #include <fapidxx/helper.h>
41 #include <sffxx.h>
42 
43 using namespace fapidxx;
44 
73 int sff_ropen__(integer *lu, char *filename, real *version, char *timestamp,
74  char *code, integer *ierr, ftnlen filename_len,
75  ftnlen timestamp_len, ftnlen code_len)
76 {
77  int retval=0;
78  *ierr=0;
79  try {
80  datrw::ianystream &is=
81  istreammanager.open(static_cast<int>(*lu),
82  stringfromfstring(filename, filename_len));
83  std::string ocode("");
84  if (is.hasfree()) { ocode.append("F"); }
85  if (is.hassrce()) { ocode.append("S"); }
86  // set output
87  fillfstring(ocode, code, code_len);
88  // timestamp and version got lost
89  sff::STAT stat;
90  fillfstring(stat.timestamp, timestamp, timestamp_len);
91  *version=static_cast<real>(sff::STAT::libversion);
92  }
93  catch(...) {
94  *ierr=1;
95  }
96  return retval;
97 } // int sff_ropen__
98 
99 
100 /* ----- END OF fapid_sff_ropen.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
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
int sff_ropen__(integer *lu, char *filename, real *version, char *timestamp, char *code, integer *ierr, ftnlen filename_len, ftnlen timestamp_len, ftnlen code_len)
Open SFF file.
datrw::ianystream & open(const int &unit, const std::string &filename)
open a new file
Definition: fileunit.cc:77
long int ftnlen
Fortran string size type.
Definition: fapidsff.h:70
std::string stringfromfstring(char *fstring, ftnlen slen)
create a C++ string from a Fortran string
Definition: helper.cc:51
a file unit interface to libdatrwxx (prototypes)
::fapidxx::IFileUnits istreammanager
the global istream manager
Definition: fileunit.cc:48
some helper functions (prototypes)