RBGen  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
RBGen_NetCDFFileIOHandler.h
1 
2 
3 #ifndef NETCDF_FILE_IO_HANDLER_H
4 #define NETCDF_FILE_IO_HANDLER_H
5 
6 
7 #include "RBGen_FileIOHandler.hpp"
8 #include "RBGen_ConfigDefs.h"
9 
10 #include <netcdf.h>
11 
12 // Forward declaration of Epetra_MultiVector class
13 class Epetra_MultiVector;
14 
15 namespace RBGen {
16 
18  class NetCDFFileIOHandler : public virtual FileIOHandler< Epetra_MultiVector >
19  {
20  public:
22 
23 
26 
28  virtual ~NetCDFFileIOHandler();
29 
31 
33 
34 
36 
37  void Reset();
38 
40 
42 
43 
45  Teuchos::RCP< Epetra_MultiVector > Read( const std::vector<std::string>& filenames );
46 
48 
50 
51 
53  void Write( const Teuchos::RCP< const Epetra_MultiVector >& MV, const std::string& filename );
54 
56 
58 
59 
61  bool isInitialized() const { return isInit; };
62 
64 
65  private:
66 
67  bool isInit;
68  int num_nodes, num_nod_var, len_string;
69  char **var_name;
70  string in_path, out_path;
72 
73  // Method for handling error from NetCDF.
74  void handle_error( int status ) {
75  if (status != NC_NOERR) {
76  fprintf(stderr,"%s\n", nc_strerror(status));
77  exit(-1);
78  }
79  }
80  };
81 
82 } // namespace RBGen
83 
84 #endif // NETCDF_FILE_IO_HANDLER_H
85 
bool isInitialized() const
Return initialized status of the handler.
FileIOHandler for reading an Epetra_MultiVector from a NetCDF file.
Teuchos::RCP< Epetra_MultiVector > Read(const std::vector< std::string > &filenames)
Method for reading multiple files and putting them into an Epetra_MultiVector.
NetCDFFileIOHandler()
Default constructor.
void Write(const Teuchos::RCP< const Epetra_MultiVector > &MV, const std::string &filename)
Method for writing one Epetra_MultiVector into a file.
Abstract base class for reading datasets from files.
virtual ~NetCDFFileIOHandler()
Destructor.
void Initialize(const Teuchos::RCP< Teuchos::ParameterList > &params)
Initialize file reader using.