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

Last change on this file since 501 was 501, checked in by ymipsl, 10 years ago

Add licence copyright to all file ond directory src using the command :
svn propset -R copyright -F header_licence src

XIOS is now officialy under CeCILL licence

YM

  • Property copyright set to
    Software name : XIOS (Xml I/O Server)
    http://forge.ipsl.jussieu.fr/ioserver
    Creation date : January 2009
    Licence : CeCCIL version2
    see license file in root directory : Licence_CeCILL_V2-en.txt
    or http://www.cecill.info/licences/Licence_CeCILL_V2-en.html
    Holder : CEA/LSCE (Laboratoire des Sciences du CLimat et de l'Environnement)
    CNRS/IPSL (Institut Pierre Simon Laplace)
    Project Manager : Yann Meurdesoif
    yann.meurdesoif@cea.fr
File size: 4.6 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         
[472]55            template <class T>  void addAttribute (const StdString & name, const T & value, const StdString * varname = NULL);
[219]56
57            /// Ecriture des données ///
[369]58            template <class T, int ndim>
59               void writeData(const CArray<T,ndim>& data, const StdString & name,
[219]60                              bool collective, StdSize record,
61                              const std::vector<StdSize> * start = NULL,
62                              const std::vector<StdSize> * count = NULL);
63
[413]64            void writeData(const CArray<int, 2>& data, const StdString & name);     
65            void writeTimeAxisData(const CArray<double,1>& data, const StdString & name,
66                                   bool collective, StdSize record, bool Isroot) ;
[219]67            /// Accesseur ///
68            const CONetCDF4Path & getCurrentPath(void) const;
69
70            /// Destructeur ///
71            virtual ~CONetCDF4(void);
72           
73      //----------------------------------------------------------------
74     
75         protected :
76
77            /// Ecriture ///
[347]78            virtual void writeField_ (CField*  field)  = 0;
79            virtual void writeDomain_(CDomain* domain) = 0;
80            virtual void writeAxis_  (CAxis*   axis)   = 0;
[219]81
82            /// Accesseurs ///
83            int getCurrentGroup(void);
84            int getGroup(const CONetCDF4Path & path);
85            int getVariable(const StdString & varname);
86            int getDimension(const StdString & dimname);
[266]87            std::vector<StdSize>   getDimensions       (const StdString & varname);
88            std::vector<StdString> getDimensionsIdList (const StdString * varname);
89            int       getUnlimitedDimension(void);
90            StdString getUnlimitedDimensionName(void);
[219]91
92            bool varExist(const StdString & varname);
93
94      //----------------------------------------------------------------
95     
96         private :
97         
98            template <class T>
99               void writeData_(int grpid, int varid,
100                               const std::vector<StdSize> & sstart,
101                               const std::vector<StdSize> & scount, T * data);
102
103            void getWriteDataInfos(const StdString & name, StdSize record, StdSize & array_size,
104                                   std::vector<StdSize> & sstart,
105                                   std::vector<StdSize> & scount,
106                                   const std::vector<StdSize> * start,
107                                   const std::vector<StdSize> * count);
108
109            /// Vérification des erreurs NetCDF ///
110            void CheckError(int status);
111
112            /// Propriétés privées ///
113            CONetCDF4Path path;
114            int ncidp;
115            bool wmpi;
[413]116            map<int,size_t> timeAxis ;
[219]117      }; // class CONetCDF4
118
119      ///---------------------------------------------------------------
120           
121
122
[335]123} // namespace xios
[219]124
125#endif //__XMLIO_INETCDF4__
Note: See TracBrowser for help on using the repository browser.