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

Last change on this file since 508 was 508, checked in by mhnguyen, 10 years ago

Fixing bug with netcdf_seq

+) Adding include file for exception
+) Correcting call inside a namespace

Test
+) On local
+) Passed

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