source: XIOS/dev/branch_openmp/src/io/inetcdf4.hpp @ 1491

Last change on this file since 1491 was 1491, checked in by yushan, 6 years ago

Branch EP merged with Dev_cmip6 @r1490

  • 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: 7.1 KB
RevLine 
[591]1#ifndef __XIOS_INETCDF4__
2#define __XIOS_INETCDF4__
[219]3
[591]4/// XIOS headers ///
5#include "xios_spl.hpp"
[219]6#include "exception.hpp"
[369]7#include "array_new.hpp"
[219]8
[1134]9#include "mpi_std.hpp"
[382]10#include "netcdf.hpp"
[219]11
12#ifndef UNLIMITED_DIM
[599]13#define UNLIMITED_DIM (size_t)(-1)
14#endif  // UNLIMITED_DIM
[219]15
[335]16namespace xios
[219]17{
[599]18  typedef std::vector<StdString> CVarPath;
[219]19
[599]20  class CINetCDF4
21  {
22    public:
23      /// Constructors ///
[1328]24      CINetCDF4(const StdString& filename, const ep_lib::MPI_Comm* comm = NULL, bool multifile = true,
[1491]25                bool readMetaDataPar = false, const StdString& timeCounterName = "time_counter");
26                //const StdString& timeCounterName = "time_counter");
[599]27      CINetCDF4(const CINetCDF4& inetcdf4);       // Not implemented.
28      CINetCDF4(const CINetCDF4* const inetcdf4); // Not implemented.
[219]29
[599]30      //-------------------------------------------------------------
[219]31
[599]32      /// Destructor ///
33      virtual ~CINetCDF4(void);
[219]34
[599]35      //-------------------------------------------------------------
[219]36
[599]37      void close(void);
[219]38
[599]39      //-------------------------------------------------------------
[219]40
[599]41      /// Getters ///
42      StdSize getNbOfTimestep(const CVarPath* const path = NULL);
[219]43
[599]44      StdString getUnlimitedDimensionName(const CVarPath* const path = NULL);
[219]45
[802]46      const StdString& getTimeCounterName(void) const { return timeCounterName; };
47
[599]48      StdString getCoordinatesId(const StdString& name, const CVarPath* const path = NULL);
[219]49
[599]50      StdString getBoundsId(const StdString& name, const CVarPath* const path = NULL);
[219]51
[599]52      StdString getLonCoordName(const StdString& varname, const CVarPath* const path = NULL);
53      StdString getLatCoordName(const StdString& varname, const CVarPath* const path = NULL);
54      StdString getVertCoordName(const StdString& varname, const CVarPath* const path = NULL);
[219]55
[599]56      std::set<StdString> getCoordVariables(const CVarPath* const path = NULL);
57      std::set<StdString> getBoundVariables(const CVarPath* const path = NULL);
[219]58
[599]59      std::list<StdString> getGroups   (const CVarPath* const path = NULL);
60      std::list<StdString> getVariables(const CVarPath* const path = NULL);
[219]61
[599]62      std::list<StdString> getDataVariables(bool _is3D       = true,
63                                            bool _isRecti    = true,
64                                            bool _isCurvi    = true,
65                                            bool _isUnstr    = true,
66                                            bool _isCellData = true,
67                                            bool _isTemporal = true,
68                                            const CVarPath* const path = NULL);
[219]69
[599]70      std::list<StdString> getAttributes(const StdString* const var  = NULL,
71                                         const CVarPath* const path = NULL);
[219]72
[599]73      std::list<StdString> getDimensionsList(const StdString* const var  = NULL,
74                                             const CVarPath* const path = NULL);
[219]75
[599]76      std::list<StdString> getCoordinatesIdList(const StdString& name,
77                                                const CVarPath* const path = NULL);
[219]78
[599]79      std::map<StdString, StdSize> getDimensions(const StdString* const var  = NULL,
80                                                 const CVarPath* const path = NULL);
[219]81
[599]82      StdSize getNbVertex(const StdString& name, const CVarPath* const path = NULL);
[219]83
[599]84      //-------------------------------------------------------------
[219]85
[599]86      template <class T>
87      T getMissingValue(const StdString& name, const CVarPath* const path = NULL);
[219]88
[599]89      template <class T>
[686]90      std::vector<T> getAttributeValue(const StdString& name,
91                                       const StdString* const var  = NULL,
92                                       const CVarPath* const path = NULL);
[219]93
[686]94      StdString getAttributeValue(const StdString& name,
95                                  const StdString* const var,
96                                  const CVarPath* const path);
97
[599]98      template <class T>
99      void getData(CArray<T, 1>& data,
100                   const StdString& var,
101                   const CVarPath* const path = NULL,
102                   StdSize record = UNLIMITED_DIM);
[219]103
[782]104      template <class T, int Ndim>
105      void getData(CArray<T, Ndim>& data, const StdString& var,
[599]106                   bool collective, StdSize record,
107                   const std::vector<StdSize>* start = NULL,
108                   const std::vector<StdSize>* count = NULL);
[219]109
[599]110      //-------------------------------------------------------------
[219]111
[599]112      /// Tests ///
113      bool hasMissingValue(const StdString& name, const CVarPath* const path = NULL);
[219]114
[599]115      bool hasAttribute(const StdString& name, const StdString* const var  = NULL, const CVarPath* const path = NULL);
[219]116
[599]117      bool hasVariable(const StdString& name, const CVarPath* const path = NULL);
[219]118
[599]119      bool hasCoordinates(const StdString& name, const CVarPath* const path = NULL);
[219]120
[599]121      bool hasTemporalDim(const CVarPath* const path = NULL);
[219]122
[599]123      bool hasBounds(const StdString& name, const CVarPath* const path = NULL);
[219]124
[599]125      //-------------------------------------------------------------
[219]126
[599]127      bool isBound(const StdString& name, const CVarPath* const path = NULL);
128      bool isCoordinate(const StdString& name, const CVarPath* const path = NULL);
129      bool isRectilinear(const StdString& name, const CVarPath* const path = NULL);
130      bool isCurvilinear(const StdString& name, const CVarPath* const path = NULL);
131      bool isUnknown(const StdString& name, const CVarPath* const path = NULL);
132      bool isUnstructured(const StdString& name, const CVarPath* const path = NULL);
[219]133
[599]134      bool isTemporal(const StdString& name, const CVarPath* const path = NULL);
135      bool is3Dim(const StdString& name, const CVarPath* const path = NULL);
136      bool isCellGrid(const StdString& name, const CVarPath* const path = NULL);
[219]137
[1460]138      bool isLonOrLat(const StdString& varname, const CVarPath* const path = NULL);
139
[599]140    protected:
141      /// Getters ///
142      int getGroup   (const CVarPath* const path = NULL);
143      int getVariable(const StdString& varname, const CVarPath* const path = NULL);
144      int getDimension(const StdString& dimname, const CVarPath* const path = NULL);
145      int getUnlimitedDimension(const CVarPath* const path = NULL);
146      int getAttributeId(const StdString& name,
147                         const StdString* const var = NULL,
148                         const CVarPath* const path = NULL);
[219]149
[599]150      std::pair<nc_type , StdSize> getAttribute(const StdString& attname,
151                                                const StdString* const var  = NULL,
152                                                const CVarPath* const path = NULL);
[219]153
[599]154      //-------------------------------------------------------------
[219]155
[599]156      void getDataInfo(const StdString& var, const CVarPath* const path, StdSize record,
157                       std::vector<StdSize>& sstart, std::vector<StdSize>& scount, StdSize& array_size,
158                       const std::vector<StdSize>* start = NULL, const std::vector<StdSize>* count = NULL);
[219]159
[599]160    private:
[686]161      int ncidp; //< Id of the NetCDF file
162      bool mpi;  //< Whether parallel file access is used
[802]163      StdString timeCounterName;
[599]164  }; // class CINetCDF4
[591]165} // namespace xios
[219]166
[591]167#endif //__XIOS_INETCDF4__
Note: See TracBrowser for help on using the repository browser.