PISM, A Parallel Ice Sheet Model  stable v2.1.1 committed by Constantine Khrulev on 2024-12-04 13:36:58 -0900
PNCFile.hh
Go to the documentation of this file.
1 // Copyright (C) 2012, 2013, 2014, 2015, 2016, 2017, 2019, 2020, 2023 PISM Authors
2 //
3 // This file is part of PISM.
4 //
5 // PISM is free software; you can redistribute it and/or modify it under the
6 // terms of the GNU General Public License as published by the Free Software
7 // Foundation; either version 3 of the License, or (at your option) any later
8 // version.
9 //
10 // PISM is distributed in the hope that it will be useful, but WITHOUT ANY
11 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with PISM; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 
19 #ifndef _PISMPNCFILE_H_
20 #define _PISMPNCFILE_H_
21 
22 #include "pism/util/io/NCFile.hh"
23 
24 namespace pism {
25 
26 class ErrorLocation;
27 
28 namespace io {
29 
30 //! \brief PISM's PnetCDF I/O wrapper.
31 class PNCFile : public NCFile
32 {
33 public:
34  PNCFile(MPI_Comm com);
35  virtual ~PNCFile();
36 protected:
37  // implementations:
38  // open/create/close
39  void open_impl(const std::string &filename, io::Mode mode);
40 
41  void create_impl(const std::string &filename);
42 
43  void sync_impl() const;
44 
45  void close_impl();
46 
47  // redef/enddef
48  void enddef_impl() const;
49 
50  void redef_impl() const;
51 
52  // dim
53  void def_dim_impl(const std::string &name, size_t length) const;
54 
55  void inq_dimid_impl(const std::string &dimension_name, bool &exists) const;
56 
57  void inq_dimlen_impl(const std::string &dimension_name, unsigned int &result) const;
58 
59  void inq_unlimdim_impl(std::string &result) const;
60 
61  // var
62  void def_var_impl(const std::string &name, io::Type nctype,
63  const std::vector<std::string> &dims) const;
64 
65  void get_vara_double_impl(const std::string &variable_name,
66  const std::vector<unsigned int> &start,
67  const std::vector<unsigned int> &count,
68  double *ip) const;
69 
70  void put_vara_double_impl(const std::string &variable_name,
71  const std::vector<unsigned int> &start,
72  const std::vector<unsigned int> &count,
73  const double *op) const;
74 
75  void get_varm_double_impl(const std::string &variable_name,
76  const std::vector<unsigned int> &start,
77  const std::vector<unsigned int> &count,
78  const std::vector<unsigned int> &imap,
79  double *ip) const;
80 
81  void inq_nvars_impl(int &result) const;
82 
83  void inq_vardimid_impl(const std::string &variable_name, std::vector<std::string> &result) const;
84 
85  void inq_varnatts_impl(const std::string &variable_name, int &result) const;
86 
87  void inq_varid_impl(const std::string &variable_name, bool &exists) const;
88 
89  void inq_varname_impl(unsigned int j, std::string &result) const;
90 
91  void set_compression_level_impl(int level) const;
92 
93  // att
94  void get_att_double_impl(const std::string &variable_name, const std::string &att_name,
95  std::vector<double> &result) const;
96 
97  void get_att_text_impl(const std::string &variable_name, const std::string &att_name,
98  std::string &result) const;
99 
100  void put_att_double_impl(const std::string &variable_name, const std::string &att_name,
101  io::Type xtype, const std::vector<double> &data) const;
102 
103  void put_att_text_impl(const std::string &variable_name, const std::string &att_name,
104  const std::string &value) const;
105 
106  void inq_attname_impl(const std::string &variable_name, unsigned int n,
107  std::string &result) const;
108 
109  void inq_atttype_impl(const std::string &variable_name, const std::string &att_name,
110  io::Type &result) const;
111 
112  // misc
113  void set_fill_impl(int fillmode, int &old_modep) const;
114 
115  void del_att_impl(const std::string &variable_name, const std::string &att_name) const;
116 
117 private:
118  std::vector<std::string> m_mpi_io_hints;
119 
120  void get_var_double(const std::string &variable_name,
121  const std::vector<unsigned int> &start,
122  const std::vector<unsigned int> &count,
123  const std::vector<unsigned int> &imap, double *ip,
124  bool transposed) const;
125 
126  void init_hints();
127 
128  int get_varid(const std::string &variable_name) const;
129 
130  MPI_Info m_mpi_info; // MPI hints
131 };
132 
133 } // end of namespace io
134 } // end of namespace pism
135 
136 #endif /* _PISMPNCFILE_H_ */
std::string filename() const
Definition: NCFile.cc:39
The PISM wrapper for a subset of the NetCDF C API.
Definition: NCFile.hh:59
void def_dim_impl(const std::string &name, size_t length) const
Definition: PNCFile.cc:99
PNCFile(MPI_Comm com)
Definition: PNCFile.cc:33
void inq_unlimdim_impl(std::string &result) const
Definition: PNCFile.cc:134
void get_vara_double_impl(const std::string &variable_name, const std::vector< unsigned int > &start, const std::vector< unsigned int > &count, double *ip) const
Definition: PNCFile.cc:169
void inq_varid_impl(const std::string &variable_name, bool &exists) const
Definition: PNCFile.cc:266
void get_varm_double_impl(const std::string &variable_name, const std::vector< unsigned int > &start, const std::vector< unsigned int > &count, const std::vector< unsigned int > &imap, double *ip) const
Definition: PNCFile.cc:198
void close_impl()
Definition: PNCFile.cc:77
void inq_varname_impl(unsigned int j, std::string &result) const
Definition: PNCFile.cc:275
void inq_dimid_impl(const std::string &dimension_name, bool &exists) const
Definition: PNCFile.cc:107
void inq_nvars_impl(int &result) const
Definition: PNCFile.cc:206
void del_att_impl(const std::string &variable_name, const std::string &att_name) const
Definition: PNCFile.cc:347
void enddef_impl() const
Definition: PNCFile.cc:85
void put_vara_double_impl(const std::string &variable_name, const std::vector< unsigned int > &start, const std::vector< unsigned int > &count, const double *op) const
Definition: PNCFile.cc:177
void inq_varnatts_impl(const std::string &variable_name, int &result) const
Definition: PNCFile.cc:259
void inq_dimlen_impl(const std::string &dimension_name, unsigned int &result) const
Definition: PNCFile.cc:120
std::vector< std::string > m_mpi_io_hints
Definition: PNCFile.hh:118
void sync_impl() const
Definition: PNCFile.cc:70
void put_att_double_impl(const std::string &variable_name, const std::string &att_name, io::Type xtype, const std::vector< double > &data) const
Definition: PNCFile.cc:352
void inq_attname_impl(const std::string &variable_name, unsigned int n, std::string &result) const
Definition: PNCFile.cc:369
void inq_atttype_impl(const std::string &variable_name, const std::string &att_name, io::Type &result) const
Definition: PNCFile.cc:384
virtual ~PNCFile()
Definition: PNCFile.cc:39
void inq_vardimid_impl(const std::string &variable_name, std::vector< std::string > &result) const
Definition: PNCFile.cc:214
void get_att_text_impl(const std::string &variable_name, const std::string &att_name, std::string &result) const
Definition: PNCFile.cc:322
void init_hints()
Definition: PNCFile.cc:442
MPI_Info m_mpi_info
Definition: PNCFile.hh:130
void redef_impl() const
Definition: PNCFile.cc:92
void get_var_double(const std::string &variable_name, const std::vector< unsigned int > &start, const std::vector< unsigned int > &count, const std::vector< unsigned int > &imap, double *ip, bool transposed) const
Definition: PNCFile.cc:406
void set_fill_impl(int fillmode, int &old_modep) const
Definition: PNCFile.cc:400
void set_compression_level_impl(int level) const
Definition: PNCFile.cc:465
void create_impl(const std::string &filename)
Definition: PNCFile.cc:61
void get_att_double_impl(const std::string &variable_name, const std::string &att_name, std::vector< double > &result) const
Definition: PNCFile.cc:286
int get_varid(const std::string &variable_name) const
Definition: PNCFile.cc:247
void open_impl(const std::string &filename, io::Mode mode)
Definition: PNCFile.cc:49
void put_att_text_impl(const std::string &variable_name, const std::string &att_name, const std::string &value) const
Definition: PNCFile.cc:361
void def_var_impl(const std::string &name, io::Type nctype, const std::vector< std::string > &dims) const
Definition: PNCFile.cc:151
PISM's PnetCDF I/O wrapper.
Definition: PNCFile.hh:32
#define n
Definition: exactTestM.c:37
int count
Definition: test_cube.c:16