Fortran SFF API to data I/O streams in C++
fapid_sff_wopenfs.cc
Go to the documentation of this file.
1 
35 #define TF_FAPID_SFF_WOPENFS_CC_VERSION \
36  "TF_FAPID_SFF_WOPENFS_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 #include <sffxx.h>
43 
44 using namespace fapidxx;
45 
79 int sff_wopenfs__(integer *lu, char *filename, char *lines, integer *nline,
80  char *type__, char *cs, real *c1, real *c2, real *c3,
81  char *date, char *time, integer *ierr, ftnlen filename_len,
82  ftnlen lines_len, ftnlen type_len, ftnlen cs_len,
83  ftnlen date_len, ftnlen time_len)
84 {
85  int retval=0;
86  *ierr=0;
87  try {
88  datrw::oanystream &os=
89  ostreammanager.open(static_cast<int>(*lu),
90  stringfromfstring(filename, filename_len));
91  if (os.handlessrce())
92  {
93  sff::SRCE srce;
94  srce.cs=sff::coosysID(*cs);
95  srce.cx=static_cast<double>(*c1);
96  srce.cy=static_cast<double>(*c2);
97  srce.cz=static_cast<double>(*c3);
98  srce.type=stringfromfstring(type__, type_len);
99  srce.date=SRCEdate(date, time, date_len, time_len);
100  os << srce;
101  }
102  if (os.handlesfilefree())
103  {
104  sff::FREE filefree=freeblock(nline, lines, lines_len);
105  os << filefree;
106  }
107  }
108  catch (...) {
109  *ierr=1;
110  }
111  return(retval);
112 } // int sff_wopenfs__
113 
114 /* ----- END OF fapid_sff_wopenfs.cc ----- */
int sff_wopenfs__(integer *lu, char *filename, char *lines, integer *nline, char *type__, char *cs, real *c1, real *c2, real *c3, char *date, char *time, integer *ierr, ftnlen filename_len, ftnlen lines_len, ftnlen type_len, ftnlen cs_len, ftnlen date_len, ftnlen time_len)
Open file for writing and pass FREE block and SRCE line.
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
datrw::oanystream & open(const int &unit, const std::string &filename)
open a new file
Definition: fileunit.cc:147
libtime::TAbsoluteTime SRCEdate(char *date, char *time, ftnlen date_len, ftnlen time_len)
create appropriate time string for SRCE line
Definition: helper.cc:127
exceptions and error handling macros (prototypes)
float real
Fortran real type (single precision)
Definition: fapidsff.h:73
::fapidxx::OFileUnits ostreammanager
the global ostream manager
Definition: fileunit.cc:51
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)
some helper functions (prototypes)