source: XIOS/trunk/src/io/onetcdf4.hpp @ 934

Last change on this file since 934 was 878, checked in by oabramkina, 8 years ago

Sequential version for UGRID norms. File attribute "convention" has been added with two possible values "CF" and "UGRID". The default value is "CF".

  • 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.2 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,
[802]30                      const MPI_Comm* comm = NULL, bool multifile = true,
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,
[802]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,
51                            const std::vector<StdString>& dim);
[606]52
[219]53      //----------------------------------------------------------------
54         public :
[606]55
[219]56            template <class T>
[707]57               void setDefaultValue(const StdString& varname, const T* value = NULL);
[606]58
59            void setCompressionLevel(const StdString& varname, int compressionLevel);
60
[707]61            template <class T>  void addAttribute (const StdString& name, const T& value, const StdString* varname = NULL);
[219]62
63            /// Ecriture des données ///
[369]64            template <class T, int ndim>
[707]65               void writeData(const CArray<T,ndim>& data, const StdString& name,
[219]66                              bool collective, StdSize record,
[707]67                              const std::vector<StdSize>* start = NULL,
68                              const std::vector<StdSize>* count = NULL);
[219]69
[707]70            void writeData(const CArray<int, 2>& data, const StdString& name);
71            void writeTimeAxisData(const CArray<double,1>& data, const StdString& name,
72                                   bool collective, StdSize record, bool Isroot);
[219]73            /// Accesseur ///
[707]74            const CONetCDF4Path& getCurrentPath(void) const;
[219]75
76            /// Destructeur ///
77            virtual ~CONetCDF4(void);
[606]78
[219]79      //----------------------------------------------------------------
[606]80
[219]81         protected :
82
83            /// Ecriture ///
[347]84            virtual void writeField_ (CField*  field)  = 0;
85            virtual void writeDomain_(CDomain* domain) = 0;
86            virtual void writeAxis_  (CAxis*   axis)   = 0;
[219]87
88            /// Accesseurs ///
89            int getCurrentGroup(void);
[707]90            int getGroup(const CONetCDF4Path& path);
91            int getVariable(const StdString& varname);
92            int getDimension(const StdString& dimname);
93            std::vector<StdSize>   getDimensions       (const StdString& varname);
94            std::vector<StdString> getDimensionsIdList (const StdString* varname);
[266]95            int       getUnlimitedDimension(void);
96            StdString getUnlimitedDimensionName(void);
[802]97            const StdString& getTimeCounterName(void) const { return timeCounterName; };
[219]98
[707]99            void getTimeAxisBounds(CArray<double,2>& timeAxisBounds, const StdString& name, bool collective);
[219]100
[707]101            bool varExist(const StdString& varname);
[878]102            bool dimExist(const StdString& dimname);
[707]103
[517]104            bool useClassicFormat; //!< If true, NetCDF4 will use the classic NetCDF3 format
[878]105            bool useCFConvention;  //!< If true data is written in the CF convention otherwise in UGRID
[517]106
[219]107      //----------------------------------------------------------------
[606]108
[219]109         private :
110            template <class T>
[707]111            void writeData_(int grpid, int varid,
112                            const std::vector<StdSize>& sstart,
113                            const std::vector<StdSize>& scount, T* data);
[219]114
[707]115            void getWriteDataInfos(const StdString& name, StdSize record, StdSize& array_size,
116                                   std::vector<StdSize>& sstart,
117                                   std::vector<StdSize>& scount,
118                                   const std::vector<StdSize>* start,
119                                   const std::vector<StdSize>* count);
[219]120
121            /// Propriétés privées ///
122            CONetCDF4Path path;
123            int ncidp;
124            bool wmpi;
[707]125            map<int,size_t> timeAxis;
[802]126            StdString timeCounterName;
[219]127      }; // class CONetCDF4
128
129      ///---------------------------------------------------------------
130
131
[606]132
[335]133} // namespace xios
[219]134
[599]135#endif //__XIOS_ONETCDF4__
Note: See TracBrowser for help on using the repository browser.