SWE
/import/home/rettenbs/src/SWE/src/writer/NetCdfWriter.hh
Go to the documentation of this file.
00001 
00029 #ifndef NETCDFWRITER_HH_
00030 #define NETCDFWRITER_HH_
00031 
00032 #include <cstring>
00033 #include <string>
00034 #include <vector>
00035 #include <netcdf.h>
00036 
00037 #include "writer/Writer.hh"
00038 
00039 namespace io {
00040   class NetCdfWriter;
00041 }
00042 
00043 class io::NetCdfWriter : public io::Writer {
00044 private:
00046     int dataFile;
00047 
00049     int timeVar, hVar, huVar, hvVar, bVar;
00050 
00052     unsigned int flush;
00053 
00054     // writer time dependent variables.
00055     void writeVarTimeDependent( const Float2D &i_matrix,
00056                                 int i_ncVariable);
00057 
00058     // writes time independent variables.
00059     void writeVarTimeIndependent( const Float2D &i_matrix,
00060                                   int i_ncVariable);
00061 
00062 
00063   public:
00064     NetCdfWriter(const std::string &i_fileName,
00065                          const Float2D &i_b,
00066                  const BoundarySize &i_boundarySize,
00067                  int i_nX, int i_nY,
00068                  float i_dX, float i_dY,
00069                  float i_originX = 0., float i_originY = 0.,
00070                  unsigned int i_flush = 0);
00071     virtual ~NetCdfWriter();
00072 
00073     // writes the unknowns at a given time step to the netCDF-file.
00074     void writeTimeStep( const Float2D &i_h,
00075                         const Float2D &i_hu,
00076                         const Float2D &i_hv,
00077                         float i_time);
00078 
00079   private:
00083     void ncPutAttText(int varid, const char* name, const char *value)
00084     {
00085         nc_put_att_text(dataFile, varid, name, strlen(value), value);
00086     }
00087 
00088 };
00089 
00090 #endif /* NETCDFWRITER_HH_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends