PISM, A Parallel Ice Sheet Model  stable v2.1-1-g6902d5502 committed by Ed Bueler on 2023-12-20 08:38:27 -0800
NC4File.hh
Go to the documentation of this file.
1 // Copyright (C) 2012, 2013, 2014, 2015, 2017, 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 #ifndef _PISMNC4FILE_H_
20 #define _PISMNC4FILE_H_
21 
22 #include "pism/util/io/NCFile.hh"
23 
24 namespace pism {
25 namespace io {
26 
27 class NC4File : public NCFile
28 {
29 public:
30  NC4File(MPI_Comm com, unsigned int compression_level);
31  virtual ~NC4File() = default;
32 
33 protected:
34  // implementations:
35  // open/create/close
36 
37  virtual void sync_impl() const;
38 
39  virtual void close_impl();
40 
41  // redef/enddef
42  virtual void enddef_impl() const;
43 
44  virtual void redef_impl() const;
45 
46  // dim
47  virtual void def_dim_impl(const std::string &name, size_t length) const;
48 
49  virtual void inq_dimid_impl(const std::string &dimension_name, bool &exists) const;
50 
51  virtual void inq_dimlen_impl(const std::string &dimension_name, unsigned int &result) const;
52 
53  virtual void inq_unlimdim_impl(std::string &result) const;
54 
55  // var
56  virtual void def_var_chunking_impl(const std::string &name,
57  std::vector<size_t> &dimensions) const;
58 
59  virtual void def_var_impl(const std::string &name,
60  io::Type nctype, const std::vector<std::string> &dims) const;
61 
62  virtual void get_vara_double_impl(const std::string &variable_name,
63  const std::vector<unsigned int> &start,
64  const std::vector<unsigned int> &count,
65  double *ip) const;
66 
67  virtual void put_vara_double_impl(const std::string &variable_name,
68  const std::vector<unsigned int> &start,
69  const std::vector<unsigned int> &count,
70  const double *op) const;
71 
72  virtual void get_varm_double_impl(const std::string &variable_name,
73  const std::vector<unsigned int> &start,
74  const std::vector<unsigned int> &count,
75  const std::vector<unsigned int> &imap, double *ip) const;
76 
77  virtual void inq_nvars_impl(int &result) const;
78 
79  virtual void inq_vardimid_impl(const std::string &variable_name, std::vector<std::string> &result) const;
80 
81  virtual void inq_varnatts_impl(const std::string &variable_name, int &result) const;
82 
83  virtual void inq_varid_impl(const std::string &variable_name, bool &exists) const;
84 
85  virtual void inq_varname_impl(unsigned int j, std::string &result) const;
86 
87  // att
88  virtual void get_att_double_impl(const std::string &variable_name, const std::string &att_name, std::vector<double> &result) const;
89 
90  virtual void get_att_text_impl(const std::string &variable_name, const std::string &att_name, std::string &result) const;
91 
92  virtual void put_att_double_impl(const std::string &variable_name, const std::string &att_name, io::Type xtype, const std::vector<double> &data) const;
93 
94  virtual void put_att_text_impl(const std::string &variable_name, const std::string &att_name, const std::string &value) const;
95 
96  virtual void inq_attname_impl(const std::string &variable_name, unsigned int n, std::string &result) const;
97 
98  virtual void inq_atttype_impl(const std::string &variable_name, const std::string &att_name, io::Type &result) const;
99 
100  // misc
101  virtual void set_fill_impl(int fillmode, int &old_modep) const;
102 
103  virtual void del_att_impl(const std::string &variable_name, const std::string &att_name) const;
104 protected:
105  virtual void set_access_mode(int varid, bool mapped) const;
106  virtual void get_put_var_double(const std::string &variable_name,
107  const std::vector<unsigned int> &start,
108  const std::vector<unsigned int> &count,
109  const std::vector<unsigned int> &imap, double *ip,
110  bool get,
111  bool mapped) const;
112 
113  mutable unsigned int m_compression_level;
114 
115  int get_varid(const std::string &variable_name) const;
116 };
117 
118 } // end of namespace io
119 } // end of namespace pism
120 
121 #endif /* _PISMNC4FILE_H_ */
virtual void get_att_double_impl(const std::string &variable_name, const std::string &att_name, std::vector< double > &result) const
Definition: NC4File.cc:258
virtual void inq_attname_impl(const std::string &variable_name, unsigned int n, std::string &result) const
Definition: NC4File.cc:375
virtual void inq_nvars_impl(int &result) const
Definition: NC4File.cc:191
virtual 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: NC4File.cc:358
virtual void get_att_text_impl(const std::string &variable_name, const std::string &att_name, std::string &result) const
Definition: NC4File.cc:331
virtual void close_impl()
Definition: NC4File.cc:54
virtual void inq_varid_impl(const std::string &variable_name, bool &exists) const
Definition: NC4File.cc:239
virtual void sync_impl() const
Definition: NC4File.cc:49
virtual void inq_dimid_impl(const std::string &dimension_name, bool &exists) const
Definition: NC4File.cc:77
virtual void enddef_impl() const
Definition: NC4File.cc:61
virtual void inq_unlimdim_impl(std::string &result) const
Definition: NC4File.cc:101
unsigned int m_compression_level
Definition: NC4File.hh:113
virtual void def_var_chunking_impl(const std::string &name, std::vector< size_t > &dimensions) const
Definition: NC4File.cc:147
virtual void set_access_mode(int varid, bool mapped) const
Definition: NC4File.cc:406
virtual void redef_impl() const
Definition: NC4File.cc:65
virtual void inq_dimlen_impl(const std::string &dimension_name, unsigned int &result) const
Definition: NC4File.cc:89
virtual void del_att_impl(const std::string &variable_name, const std::string &att_name) const
Definition: NC4File.cc:353
virtual void get_put_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 get, bool mapped) const
Definition: NC4File.cc:410
virtual void put_att_text_impl(const std::string &variable_name, const std::string &att_name, const std::string &value) const
Definition: NC4File.cc:367
NC4File(MPI_Comm com, unsigned int compression_level)
Definition: NC4File.cc:42
virtual ~NC4File()=default
virtual void def_dim_impl(const std::string &name, size_t length) const
Definition: NC4File.cc:70
virtual void inq_vardimid_impl(const std::string &variable_name, std::vector< std::string > &result) const
Definition: NC4File.cc:195
virtual void set_fill_impl(int fillmode, int &old_modep) const
Definition: NC4File.cc:402
virtual void def_var_impl(const std::string &name, io::Type nctype, const std::vector< std::string > &dims) const
Definition: NC4File.cc:117
virtual 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: NC4File.cc:158
virtual 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: NC4File.cc:179
int get_varid(const std::string &variable_name) const
Definition: NC4File.cc:222
virtual void inq_varname_impl(unsigned int j, std::string &result) const
Definition: NC4File.cc:247
virtual 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: NC4File.cc:168
virtual void inq_atttype_impl(const std::string &variable_name, const std::string &att_name, io::Type &result) const
Definition: NC4File.cc:385
virtual void inq_varnatts_impl(const std::string &variable_name, int &result) const
Definition: NC4File.cc:234
The PISM wrapper for a subset of the NetCDF C API.
Definition: NCFile.hh:59
#define n
Definition: exactTestM.c:37
int count
Definition: test_cube.c:16