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

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

Fixing compilation error in parallel with sequential netcdf
(This patch is also posted on trunk)

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