source: vendor/nemo/current/NEMOGCM/EXTERNAL/XIOS/src/output/onetcdf4.hpp @ 44

Last change on this file since 44 was 44, checked in by cholod, 12 years ago

Load NEMO_TMP into vendor/nemo/current.

File size: 4.5 KB
Line 
1#ifndef __XMLIO_INETCDF4__
2#define __XMLIO_INETCDF4__
3
4/// xios headers ///
5#include "xmlioserver_spl.hpp"
6#include "exception.hpp"
7#include "array.hpp"
8#include "data_output.hpp"
9
10#include <mpi.h>
11#define MPI_INCLUDED
12#include <netcdf.h>
13extern "C" {
14#include <netcdf_par.h>
15}
16
17
18#ifndef UNLIMITED_DIM
19   #define UNLIMITED_DIM (size_t)(-1)
20#endif  //UNLIMITED_DIM
21
22namespace xios
23{
24      /// ////////////////////// Déclarations ////////////////////// ///
25      class CONetCDF4
26         : public virtual CDataOutput
27      {
28         public :
29
30            /// Définition de type ///
31            typedef std::vector<StdString> CONetCDF4Path;
32
33            /// Constructeurs ///
34            CONetCDF4(const StdString & filename, bool exist, const MPI_Comm * comm = NULL, bool multifile=true);
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, bool multifile);
42            void close(void) ;
43            void sync(void) ;
44            void definition_start(void);
45            void definition_end(void);
46
47            /// Mutateurs ///
48            void setCurrentPath(const CONetCDF4Path & path);
49
50            int addGroup(const StdString & name);
51            int addDimension(const StdString& name, const StdSize size = UNLIMITED_DIM);
52            int addVariable(const StdString & name, nc_type type,
53                            const std::vector<StdString> & dim);
54                           
55      //----------------------------------------------------------------
56         public :
57         
58            template <class T>
59               void setDefaultValue(const StdString & varname, const T * value = NULL);
60         
61            template <class T>
62               void addAttribute
63                  (const StdString & name, const T & value, const StdString * varname = NULL);
64
65            /// Ecriture des données ///
66            template <class T, StdSize ndim>
67               void writeData(const ARRAY(T, ndim) data, const StdString & name,
68                              bool collective, StdSize record,
69                              const std::vector<StdSize> * start = NULL,
70                              const std::vector<StdSize> * count = NULL);
71
72            void writeData(const ARRAY(int, 2) data, const StdString & name);
73
74            /// Accesseur ///
75            const CONetCDF4Path & getCurrentPath(void) const;
76
77            /// Destructeur ///
78            virtual ~CONetCDF4(void);
79           
80      //----------------------------------------------------------------
81     
82         protected :
83
84            /// Ecriture ///
85            virtual void writeField_ (CField*  field)  = 0;
86            virtual void writeDomain_(CDomain* domain) = 0;
87            virtual void writeAxis_  (CAxis*   axis)   = 0;
88
89            /// Accesseurs ///
90            int getCurrentGroup(void);
91            int getGroup(const CONetCDF4Path & path);
92            int getVariable(const StdString & varname);
93            int getDimension(const StdString & dimname);
94            std::vector<StdSize>   getDimensions       (const StdString & varname);
95            std::vector<StdString> getDimensionsIdList (const StdString * varname);
96            int       getUnlimitedDimension(void);
97            StdString getUnlimitedDimensionName(void);
98
99            bool varExist(const StdString & varname);
100
101      //----------------------------------------------------------------
102     
103         private :
104         
105            template <class T>
106               void writeData_(int grpid, int varid,
107                               const std::vector<StdSize> & sstart,
108                               const std::vector<StdSize> & scount, T * data);
109
110            void getWriteDataInfos(const StdString & name, StdSize record, StdSize & array_size,
111                                   std::vector<StdSize> & sstart,
112                                   std::vector<StdSize> & scount,
113                                   const std::vector<StdSize> * start,
114                                   const std::vector<StdSize> * count);
115
116            /// Vérification des erreurs NetCDF ///
117            void CheckError(int status);
118
119            /// Propriétés privées ///
120            CONetCDF4Path path;
121            int ncidp;
122            bool wmpi;
123
124      }; // class CONetCDF4
125
126      ///---------------------------------------------------------------
127           
128
129
130} // namespace xios
131
132#endif //__XMLIO_INETCDF4__
Note: See TracBrowser for help on using the repository browser.