source: XMLIO_V2/dev/dev_rv/src/output/onetcdf4.hpp @ 141

Last change on this file since 141 was 141, checked in by hozdoba, 13 years ago

Mise à jour depuis un autre dépôt

File size: 3.7 KB
Line 
1#ifndef __XMLIO_INETCDF4__
2#define __XMLIO_INETCDF4__
3
4/// xmlioserver headers ///
5#include "xmlioserver_spl.hpp"
6#include "exception.hpp"
7#include "array.hpp"
8#include "mask.hpp"
9#include "../data_output.hpp"
10#include "manager/mpi_manager.hpp"
11
12#include <mpi.h>
13#include <netcdf.h>
14
15#ifndef UNLIMITED_DIM
16   #define UNLIMITED_DIM (size_t)(-1)
17#endif  //UNLIMITED_DIM
18
19namespace xmlioserver
20{
21   namespace io
22   {
23      /// ////////////////////// Déclarations ////////////////////// ///
24      class CONetCDF4
25         : public virtual CDataOutput
26      {
27         public :
28
29            /// Définition de type ///
30            typedef std::vector<StdString> CONetCDF4Path;
31
32            /// Constructeurs ///
33            CONetCDF4(const StdString & filename, bool exist, const MPI_Comm * comm = NULL);
34            CONetCDF4(const StdString & filename, bool exist, const comm::MPIComm * comm);
35
36            CONetCDF4(const CONetCDF4 & onetcdf4);       // Not implemented.
37            CONetCDF4(const CONetCDF4 * const onetcdf4); // Not implemented.
38
39
40            /// Initialisation ///
41            void initialize(const StdString & filename, bool exist, const MPI_Comm * comm);
42            void definition_start(void);
43            void definition_end(void);
44
45            /// Mutateurs ///
46            void setCurrentPath(const CONetCDF4Path & path);
47
48            int addGroup(const StdString & name);
49            int addDimension(const StdString& name, const StdSize size = UNLIMITED_DIM);
50            int addVariable(const StdString & name, nc_type type,
51                                    const std::vector<StdString> & dim);
52            template <class T>
53               void addAttribute
54                  (const StdString & name, const T & value, const StdString * varname = NULL);
55
56            /// Ecriture des données ///
57            template <class T>
58               void writeData(const ARRAY(T, 1) data, const StdString & name,
59                              bool collective, StdSize record,
60                              const std::vector<StdSize> * start = NULL,
61                              const std::vector<StdSize> * count = NULL);
62
63            void writeData(const boost::shared_ptr<CMask> data, const StdString & name);
64
65            /// Accesseur ///
66            const CONetCDF4Path & getCurrentPath(void) const;
67
68            /// Destructeur ///
69            virtual ~CONetCDF4(void);
70
71         protected :
72
73            /// Ecriture ///
74            virtual void writeField_ (const boost::shared_ptr<tree::CField>  field)  = 0;
75            virtual void writeDomain_(const boost::shared_ptr<tree::CDomain> domain) = 0;
76            virtual void writeAxis_  (const boost::shared_ptr<tree::CAxis>   axis)   = 0;
77
78            /// Accesseurs ///
79            int getCurrentGroup(void);
80            int getGroup(const CONetCDF4Path & path);
81            int getVariable(const StdString & varname);
82            int getDimension(const StdString & dimname);
83            std::vector<StdSize> getDimensions(const StdString & varname);
84            int getUnlimitedDimension(void);
85
86         private :
87
88            void getWriteDataInfos(const StdString & name, StdSize record, StdSize & array_size,
89                                   std::vector<StdSize> & sstart,
90                                   std::vector<StdSize> & scount,
91                                   const std::vector<StdSize> * start,
92                                   const std::vector<StdSize> * count);
93
94            /// Vérification des erreurs NetCDF ///
95            void CheckError(int status);
96
97            /// Propriétés privées ///
98            CONetCDF4Path path;
99            int ncidp;
100            bool wmpi;
101
102      }; // class CONetCDF4
103
104   } // namespace io
105} // namespace xmlioserver
106
107#endif //__XMLIO_INETCDF4__
Note: See TracBrowser for help on using the repository browser.