source: XIOS/dev/branch_yushan_merged/src/io/onetcdf4.hpp @ 1138

Last change on this file since 1138 was 1138, checked in by yushan, 7 years ago

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