source: XIOS3/trunk/src/io/onetcdf4.hpp @ 2561

Last change on this file since 2561 was 2529, checked in by jderouillat, 12 months ago

Enable parallel compression regarding NetCDF & HDF5 configurations at compile time. Implement an API to use HDF5 lossy compression plugins (SZ is available for now).

  • 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: 5.8 KB
RevLine 
[599]1#ifndef __XIOS_ONETCDF4__
2#define __XIOS_ONETCDF4__
[219]3
[591]4/// XIOS headers ///
5#include "xios_spl.hpp"
[219]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 ///
[707]28            CONetCDF4(const StdString& filename, bool append, bool useClassicFormat = false,
[878]29                          bool useCFConvention = true,
[1639]30                      const MPI_Comm* comm = NULL, bool multifile = true,
[802]31                      const StdString& timeCounterName = "time_counter");
[219]32
[707]33            CONetCDF4(const CONetCDF4& onetcdf4);       // Not implemented.
34            CONetCDF4(const CONetCDF4* const onetcdf4); // Not implemented.
[219]35
36
37            /// Initialisation ///
[878]38            void initialize(const StdString& filename, bool append, bool useClassicFormat, bool useCFConvention,
[1639]39                            const MPI_Comm* comm, bool multifile, const StdString& timeCounterName);
[707]40            void close(void);
41            void sync(void);
[219]42            void definition_start(void);
43            void definition_end(void);
44
45            /// Mutateurs ///
[707]46            void setCurrentPath(const CONetCDF4Path& path);
[219]47
[707]48            int addGroup(const StdString& name);
[219]49            int addDimension(const StdString& name, const StdSize size = UNLIMITED_DIM);
[707]50            int addVariable(const StdString& name, nc_type type,
[2481]51                            const std::vector<StdString>& dim, bool defineChunking=true);
[2479]52            int addChunk(CField* field, nc_type type,
53                         const std::vector<StdString>& dim, int compressionLevel=0);
[606]54
[219]55      //----------------------------------------------------------------
56         public :
[606]57
[219]58            template <class T>
[707]59               void setDefaultValue(const StdString& varname, const T* value = NULL);
[606]60
[2529]61            void setCompressionLevel(const StdString& varname, const StdString& compressionType, int compressionLevel, 
62                                     const CArray<double,1>& compressionParam );
[606]63
[707]64            template <class T>  void addAttribute (const StdString& name, const T& value, const StdString* varname = NULL);
[219]65
66            /// Ecriture des données ///
[369]67            template <class T, int ndim>
[707]68               void writeData(const CArray<T,ndim>& data, const StdString& name,
[219]69                              bool collective, StdSize record,
[707]70                              const std::vector<StdSize>* start = NULL,
71                              const std::vector<StdSize>* count = NULL);
[219]72
[707]73            void writeData(const CArray<int, 2>& data, const StdString& name);
74            void writeTimeAxisData(const CArray<double,1>& data, const StdString& name,
75                                   bool collective, StdSize record, bool Isroot);
[1158]76            void writeTimeAxisDataBounds(const CArray<double,1>& data, const StdString& name,
77                                   bool collective, StdSize record, bool Isroot);
[219]78            /// Accesseur ///
[707]79            const CONetCDF4Path& getCurrentPath(void) const;
[219]80
81            /// Destructeur ///
82            virtual ~CONetCDF4(void);
[606]83
[219]84      //----------------------------------------------------------------
[606]85
[219]86         protected :
87
88            /// Ecriture ///
[347]89            virtual void writeField_ (CField*  field)  = 0;
90            virtual void writeDomain_(CDomain* domain) = 0;
91            virtual void writeAxis_  (CAxis*   axis)   = 0;
[219]92
93            /// Accesseurs ///
94            int getCurrentGroup(void);
[707]95            int getGroup(const CONetCDF4Path& path);
96            int getVariable(const StdString& varname);
97            int getDimension(const StdString& dimname);
98            std::vector<StdSize>   getDimensions       (const StdString& varname);
99            std::vector<StdString> getDimensionsIdList (const StdString* varname);
[266]100            int       getUnlimitedDimension(void);
101            StdString getUnlimitedDimensionName(void);
[802]102            const StdString& getTimeCounterName(void) const { return timeCounterName; };
[219]103
[1158]104            void getTimeAxisBounds(CArray<double,2>& timeAxisBounds, const StdString& name, bool collective );
105            void getTimeAxisBounds(CArray<double,2>& timeAxisBounds, const StdString& name, bool collective, size_t record);
[219]106
[707]107            bool varExist(const StdString& varname);
[878]108            bool dimExist(const StdString& dimname);
[707]109
[517]110            bool useClassicFormat; //!< If true, NetCDF4 will use the classic NetCDF3 format
[878]111            bool useCFConvention;  //!< If true data is written in the CF convention otherwise in UGRID
[517]112
[219]113      //----------------------------------------------------------------
[606]114
[219]115         private :
116            template <class T>
[707]117            void writeData_(int grpid, int varid,
118                            const std::vector<StdSize>& sstart,
119                            const std::vector<StdSize>& scount, T* data);
[219]120
[707]121            void getWriteDataInfos(const StdString& name, StdSize record, StdSize& array_size,
122                                   std::vector<StdSize>& sstart,
123                                   std::vector<StdSize>& scount,
124                                   const std::vector<StdSize>* start,
125                                   const std::vector<StdSize>* count);
[219]126
127            /// Propriétés privées ///
128            CONetCDF4Path path;
129            int ncidp;
130            bool wmpi;
[707]131            map<int,size_t> timeAxis;
[802]132            StdString timeCounterName;
[219]133      }; // class CONetCDF4
134
135      ///---------------------------------------------------------------
136
137
[606]138
[335]139} // namespace xios
[219]140
[599]141#endif //__XIOS_ONETCDF4__
Note: See TracBrowser for help on using the repository browser.