source: XIOS/trunk/src/output/onetcdf4.hpp @ 379

Last change on this file since 379 was 379, checked in by ymipsl, 12 years ago
  • zoom can be output in single file without need to patch the netcdf library
  • sequential version of netcdf4 are now managed. Can be used to output in multiple_file mode

YM

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