PISM, A Parallel Ice Sheet Model  stable v2.1-1-g6902d5502 committed by Ed Bueler on 2023-12-20 08:38:27 -0800
ParallelIO.hh
Go to the documentation of this file.
1 /* Copyright (C) 2019, 2020, 2021, 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 
20 #include "pism/util/io/NCFile.hh"
21 
22 namespace pism {
23 namespace io {
24 
25 enum Backend : int;
26 enum Type : int;
27 enum Mode : int;
28 
29 class ParallelIO : public NCFile {
30 public:
31  ParallelIO(MPI_Comm com, int iosysid, io::Backend iotype);
32  virtual ~ParallelIO() = default;
33 
34  static io::Backend best_iotype(bool netcdf3);
35 
36 protected:
37  // open/create/close
38  void open_impl(const std::string &filename, io::Mode mode);
39  void create_impl(const std::string &filename);
40  void sync_impl() const;
41  void close_impl();
42 
43  void set_compression_level_impl(int level) const;
44 
45  // redef/enddef
46  void enddef_impl() const;
47 
48  void redef_impl() const;
49 
50  // dim
51  void def_dim_impl(const std::string &name, size_t length) const;
52 
53  void inq_dimid_impl(const std::string &dimension_name, bool &exists) const;
54 
55  void inq_dimlen_impl(const std::string &dimension_name, unsigned int &result) const;
56 
57  void inq_unlimdim_impl(std::string &result) const;
58 
59  // var
60  void def_var_impl(const std::string &name, io::Type nctype,
61  const std::vector<std::string> &dims) const;
62 
63  void def_var_chunking_impl(const std::string &name, std::vector<size_t> &dimensions) 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, double *ip) const;
68 
69  void put_vara_double_impl(const std::string &variable_name,
70  const std::vector<unsigned int> &start,
71  const std::vector<unsigned int> &count, const double *op) const;
72 
73  void write_darray_impl(const std::string &variable_name, const Grid &grid, unsigned int z_count,
74  bool time_dependent, unsigned int record, const double *input);
75 
76  void get_varm_double_impl(const std::string &variable_name,
77  const std::vector<unsigned int> &start,
78  const std::vector<unsigned int> &count,
79  const std::vector<unsigned int> &imap, 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  // att
92  void get_att_double_impl(const std::string &variable_name, const std::string &att_name,
93  std::vector<double> &result) const;
94 
95  void get_att_text_impl(const std::string &variable_name, const std::string &att_name,
96  std::string &result) const;
97 
98  void put_att_double_impl(const std::string &variable_name, const std::string &att_name,
99  io::Type xtype, const std::vector<double> &data) const;
100 
101  void put_att_text_impl(const std::string &variable_name, const std::string &att_name,
102  const std::string &value) const;
103 
104  void inq_attname_impl(const std::string &variable_name, unsigned int n,
105  std::string &result) const;
106 
107  void inq_atttype_impl(const std::string &variable_name, const std::string &att_name,
108  io::Type &result) const;
109 
110  // misc
111  void set_fill_impl(int fillmode, int &old_modep) const;
112 
113  void del_att_impl(const std::string &variable_name, const std::string &att_name) const;
114 private:
116  int m_iotype;
117  int get_varid(const std::string &variable_name) const;
118 };
119 
120 } // end of namespace io
121 } // end of namespace pism
Describes the PISM grid and the distribution of data across processors.
Definition: Grid.hh:282
std::string filename() const
Definition: NCFile.cc:39
The PISM wrapper for a subset of the NetCDF C API.
Definition: NCFile.hh:59
void inq_varid_impl(const std::string &variable_name, bool &exists) const
Definition: ParallelIO.cc:354
ParallelIO(MPI_Comm com, int iosysid, io::Backend iotype)
Definition: ParallelIO.cc:60
void inq_dimlen_impl(const std::string &dimension_name, unsigned int &result) const
Definition: ParallelIO.cc:146
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: ParallelIO.cc:201
void del_att_impl(const std::string &variable_name, const std::string &att_name) const
Definition: ParallelIO.cc:475
void inq_varnatts_impl(const std::string &variable_name, int &result) const
Definition: ParallelIO.cc:342
void set_fill_impl(int fillmode, int &old_modep) const
Definition: ParallelIO.cc:469
void enddef_impl() const
Definition: ParallelIO.cc:117
void sync_impl() const
Definition: ParallelIO.cc:105
void put_att_text_impl(const std::string &variable_name, const std::string &att_name, const std::string &value) const
Definition: ParallelIO.cc:438
void redef_impl() const
Definition: ParallelIO.cc:122
void def_var_impl(const std::string &name, io::Type nctype, const std::vector< std::string > &dims) const
Definition: ParallelIO.cc:177
void inq_nvars_impl(int &result) const
Definition: ParallelIO.cc:304
void open_impl(const std::string &filename, io::Mode mode)
Definition: ParallelIO.cc:87
static io::Backend best_iotype(bool netcdf3)
Definition: ParallelIO.cc:45
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: ParallelIO.cc:431
void create_impl(const std::string &filename)
Definition: ParallelIO.cc:94
void get_att_double_impl(const std::string &variable_name, const std::string &att_name, std::vector< double > &result) const
Definition: ParallelIO.cc:374
void inq_dimid_impl(const std::string &dimension_name, bool &exists) const
Definition: ParallelIO.cc:134
void set_compression_level_impl(int level) const
Definition: ParallelIO.cc:82
void def_dim_impl(const std::string &name, size_t length) const
Definition: ParallelIO.cc:128
void get_att_text_impl(const std::string &variable_name, const std::string &att_name, std::string &result) const
Definition: ParallelIO.cc:402
int get_varid(const std::string &variable_name) const
Definition: ParallelIO.cc:480
void def_var_chunking_impl(const std::string &name, std::vector< size_t > &dimensions) const
Definition: ParallelIO.cc:194
virtual ~ParallelIO()=default
void write_darray_impl(const std::string &variable_name, const Grid &grid, unsigned int z_count, bool time_dependent, unsigned int record, const double *input)
Definition: ParallelIO.cc:249
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: ParallelIO.cc:220
void inq_attname_impl(const std::string &variable_name, unsigned int n, std::string &result) const
Definition: ParallelIO.cc:445
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: ParallelIO.cc:291
void inq_atttype_impl(const std::string &variable_name, const std::string &att_name, io::Type &result) const
Definition: ParallelIO.cc:455
void inq_vardimid_impl(const std::string &variable_name, std::vector< std::string > &result) const
Definition: ParallelIO.cc:309
void inq_varname_impl(unsigned int j, std::string &result) const
Definition: ParallelIO.cc:362
void inq_unlimdim_impl(std::string &result) const
Definition: ParallelIO.cc:159
#define n
Definition: exactTestM.c:37
int count
Definition: test_cube.c:16