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

Last change on this file since 413 was 413, checked in by ymipsl, 11 years ago

Performance improvment on Lustre

YM

File size: 4.7 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"
[382]9#include "mpi.hpp"
[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
[413]66            void writeData(const CArray<int, 2>& data, const StdString & name);     
67            void writeTimeAxisData(const CArray<double,1>& data, const StdString & name,
68                                   bool collective, StdSize record, bool Isroot) ;
[219]69            /// Accesseur ///
70            const CONetCDF4Path & getCurrentPath(void) const;
71
72            /// Destructeur ///
73            virtual ~CONetCDF4(void);
74           
75      //----------------------------------------------------------------
76     
77         protected :
78
79            /// Ecriture ///
[347]80            virtual void writeField_ (CField*  field)  = 0;
81            virtual void writeDomain_(CDomain* domain) = 0;
82            virtual void writeAxis_  (CAxis*   axis)   = 0;
[219]83
84            /// Accesseurs ///
85            int getCurrentGroup(void);
86            int getGroup(const CONetCDF4Path & path);
87            int getVariable(const StdString & varname);
88            int getDimension(const StdString & dimname);
[266]89            std::vector<StdSize>   getDimensions       (const StdString & varname);
90            std::vector<StdString> getDimensionsIdList (const StdString * varname);
91            int       getUnlimitedDimension(void);
92            StdString getUnlimitedDimensionName(void);
[219]93
94            bool varExist(const StdString & varname);
95
96      //----------------------------------------------------------------
97     
98         private :
99         
100            template <class T>
101               void writeData_(int grpid, int varid,
102                               const std::vector<StdSize> & sstart,
103                               const std::vector<StdSize> & scount, T * data);
104
105            void getWriteDataInfos(const StdString & name, StdSize record, StdSize & array_size,
106                                   std::vector<StdSize> & sstart,
107                                   std::vector<StdSize> & scount,
108                                   const std::vector<StdSize> * start,
109                                   const std::vector<StdSize> * count);
110
111            /// Vérification des erreurs NetCDF ///
112            void CheckError(int status);
113
114            /// Propriétés privées ///
115            CONetCDF4Path path;
116            int ncidp;
117            bool wmpi;
[413]118            map<int,size_t> timeAxis ;
[219]119      }; // class CONetCDF4
120
121      ///---------------------------------------------------------------
122           
123
124
[335]125} // namespace xios
[219]126
127#endif //__XMLIO_INETCDF4__
Note: See TracBrowser for help on using the repository browser.