source: XIOS/branchs/xios-1.0/src/output/netCdfInterface.hpp @ 514

Last change on this file since 514 was 514, checked in by mhnguyen, 8 years ago

Removing a line causing compilation error on Ada

  • 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.0 KB
Line 
1/*!
2   \file netCdfInterface.hpp
3   \author Ha NGUYEN
4   \date 08 Oct 2014
5   \since 03 Oct 2014
6
7   \brief Wrapper of netcdf functions.
8 */
9#ifndef __NETCDF_INTERFACE_HPP_
10#define __NETCDF_INTERFACE_HPP_
11
12#include "xmlioserver_spl.hpp"
13#include "mpi.hpp"
14#include "netcdf.hpp"
15
16namespace xios
17{
18  /*!
19  \class CNetCdfInterface
20   This class is  wrapper of some common used functions of netCdf in Xios
21  */
22  class CNetCdfInterface
23  {
24  public:
25    //! Create a netcdf file
26    static int create(const StdString& path, int cmode, int& ncId);
27
28    //! Create a netcdf file on a parallel file system
29    static int createPar(const StdString& path, int cmode, MPI_Comm comm, MPI_Info info, int& ncId);
30
31    //! Open a netcdf file
32    static int open(const StdString& path, int oMode, int& ncId);
33
34    //! Open a netcdf file
35    static int openPar(const StdString& path, int cmode, MPI_Comm comm, MPI_Info info, int& ncId);
36
37    //! Close a netcdf file
38    static int close(int ncId);
39
40    //! Put netcdf file into define mode
41    static int reDef(int ncId);
42
43    //! End define mode of a netcdf file
44    static int endDef(int ncId);
45
46    //! Query identity of a named group
47    static int inqNcId(int ncid, const StdString& grpName, int& grpId);
48
49    //! Query identity of a named variable
50    static int inqVarId(int ncid, const StdString& varName, int& varId);
51
52    //! Query identity of a named dimension
53    static int inqDimId(int ncid,const StdString& dimName, int& dimId);
54
55    //! Query identity of unlimited dimension
56    static int inqUnLimDim(int ncid, int& dimId);
57
58    //! Query name of a dimension with its id
59    static int inqDimName(int ncid, int dimId, StdString& dimName);
60
61    //! Query length of dimension with its id
62    static int inqDimLen(int ncid, int dimId, StdSize& dimLen);
63
64    //! Query number of dimension of a variable with its id
65    static int inqVarNDims(int ncid, int varId, int& nDims);
66
67    //! Query list of dimension of a variable with its id
68    static int inqVarDimId(int, int, int*);
69
70    //! Query dimensions of a group
71    static int inqDimIds(int ncid, int& nDims, int* dimIds, int includeParents);
72
73
74    //! Define a group
75    static int defGrp(int parentNcid,const StdString& grpName, int& grpId);
76
77    //! Define a dimension
78    static int defDim(int ncid,const StdString& dimName, StdSize dimLen, int& dimId);
79
80    //! Define a variable
81    static int defVar(int ncid,const StdString& varName, nc_type xtype,
82                      int nDims, const int dimIds[], int& varId);
83
84    //! Define variable chunking size
85    static int defVarChunking(int ncid, int varId, int storage, StdSize chunkSize[]);
86
87    //! Define variable fill parameters
88    static int defVarFill(int ncid, int varId, int noFill, void* fillValue);
89
90
91    //! Change access type of a variable
92    static int varParAccess(int ncid, int varid, int access);
93
94    //! Syn
95    static int sync(int ncId);
96
97    //! Put attribute into variable
98    static int putAtt(int ncid, int varid, const StdString& attrName, nc_type xtype,
99                      StdSize numVal, const void* op);
100
101
102    //! Put attribute into variable with specific type
103    template<typename T>
104    static int putAttType(int ncid, int varid, const StdString& attrName, StdSize numVal, const T* op);
105
106    //! Put value into a variable with a specific type
107    template<typename T>
108    static int putVaraType(int ncid, int varid, const StdSize* start, const StdSize* count, const T* op);
109
110  private:
111    template<typename T>
112    static int ncPutAttType(int ncid, int varid, const char* attrName, StdSize numVal, const T* op);
113
114    template<typename T>
115    static int ncPutVaraType(int ncid, int varid, const StdSize* start, const StdSize* count, const T* op);
116
117  private:
118    static StdString openMode2String(int oMode);
119
120    static StdString creationMode2String(int cMode);
121
122
123  public:
124    // Some functions dedude from several special cases
125    //! Query the existence of a variable
126    static bool isVarExisted(int ncId, const StdString& varName);
127
128  };
129}
130
131
132#endif // NETCDFINTERFACE_HPP_
Note: See TracBrowser for help on using the repository browser.