PISM, A Parallel Ice Sheet Model  stable v2.1.1 committed by Constantine Khrulev on 2024-12-04 13:36:58 -0900
NC_Serial.hh
Go to the documentation of this file.
1 // Copyright (C) 2012, 2013, 2014, 2015, 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 PISM_NC_SERIAL_H
20 #define PISM_NC_SERIAL_H
21 
22 #include "pism/util/io/NCFile.hh"
23 
24 namespace pism {
25 namespace io {
26 
27 class NC_Serial : public NCFile
28 {
29 public:
30  NC_Serial(MPI_Comm com);
31  virtual ~NC_Serial();
32 
33  std::string get_format() const;
34 
35 protected:
36  // implementations:
37  // open/create/close
38  void open_impl(const std::string &filename, io::Mode mode);
39 
40  virtual void create_impl(const std::string &filename);
41 
42  void sync_impl() const;
43 
44  void close_impl();
45 
46  // redef/enddef
47  void enddef_impl() const;
48 
49  void redef_impl() const;
50 
51  // dim
52  void def_dim_impl(const std::string &name, size_t length) const;
53 
54  void inq_dimid_impl(const std::string &dimension_name, bool &exists) const;
55 
56  void inq_dimlen_impl(const std::string &dimension_name, unsigned int &result) const;
57 
58  void inq_unlimdim_impl(std::string &result) const;
59 
60  // var
61  virtual void def_var_impl(const std::string &name, io::Type nctype, const std::vector<std::string> &dims) const;
62 
63  void get_vara_double_impl(const std::string &variable_name,
64  const std::vector<unsigned int> &start,
65  const std::vector<unsigned int> &count,
66  double *ip) const;
67 
68  void put_vara_double_impl(const std::string &variable_name,
69  const std::vector<unsigned int> &start,
70  const std::vector<unsigned int> &count,
71  const double *op) const;
72 
73  void get_varm_double_impl(const std::string &variable_name,
74  const std::vector<unsigned int> &start,
75  const std::vector<unsigned int> &count,
76  const std::vector<unsigned int> &imap,
77  double *ip) const;
78 
79  void inq_nvars_impl(int &result) const;
80 
81  void inq_vardimid_impl(const std::string &variable_name, std::vector<std::string> &result) const;
82 
83  void inq_varnatts_impl(const std::string &variable_name, int &result) const;
84 
85  void inq_varid_impl(const std::string &variable_name, bool &exists) const;
86 
87  void inq_varname_impl(unsigned int j, std::string &result) const;
88 
89  virtual void set_compression_level_impl(int level) const;
90 
91  // att
92  void get_att_double_impl(const std::string &variable_name, const std::string &att_name, std::vector<double> &result) const;
93 
94  void get_att_text_impl(const std::string &variable_name, const std::string &att_name, std::string &result) const;
95 
96  void put_att_double_impl(const std::string &variable_name, const std::string &att_name, io::Type xtype, const std::vector<double> &data) const;
97 
98  void put_att_text_impl(const std::string &variable_name, const std::string &att_name, const std::string &value) const;
99 
100  void inq_attname_impl(const std::string &variable_name, unsigned int n, std::string &result) const;
101 
102  void inq_atttype_impl(const std::string &variable_name, const std::string &att_name, io::Type &result) const;
103 
104  // misc
105  void set_fill_impl(int fillmode, int &old_modep) const;
106 
107  void del_att_impl(const std::string &variable_name, const std::string &att_name) const;
108 
109  int m_rank;
110 
111  int get_varid(const std::string &variable_name) const;
112 
113 private:
114 
115  void get_var_double(const std::string &variable_name,
116  const std::vector<unsigned int> &start,
117  const std::vector<unsigned int> &count,
118  const std::vector<unsigned int> &imap, double *ip,
119  bool transposed) const;
120  };
121 
122 } // end of namespace io
123 } // end of namespace pism
124 
125 #endif /* PISM_NC_SERIAL_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 get_att_text_impl(const std::string &variable_name, const std::string &att_name, std::string &result) const
Gets a text attribute.
Definition: NC_Serial.cc:699
virtual void create_impl(const std::string &filename)
Create a NetCDF file.
Definition: NC_Serial.cc:94
void def_dim_impl(const std::string &name, size_t length) const
Define a dimension.
Definition: NC_Serial.cc:171
void inq_varname_impl(unsigned int j, std::string &result) const
Definition: NC_Serial.cc:579
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: NC_Serial.cc:393
void set_fill_impl(int fillmode, int &old_modep) const
Sets the fill mode.
Definition: NC_Serial.cc:857
std::string get_format() const
Definition: NC_Serial.cc:871
void enddef_impl() const
Exit define mode.
Definition: NC_Serial.cc:140
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: NC_Serial.cc:288
void inq_vardimid_impl(const std::string &variable_name, std::vector< std::string > &result) const
Get dimensions a variable depends on.
Definition: NC_Serial.cc:488
void put_att_text_impl(const std::string &variable_name, const std::string &att_name, const std::string &value) const
Writes a text attribute.
Definition: NC_Serial.cc:773
void get_att_double_impl(const std::string &variable_name, const std::string &att_name, std::vector< double > &result) const
Gets a double attribute.
Definition: NC_Serial.cc:601
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: NC_Serial.cc:281
void put_att_double_impl(const std::string &variable_name, const std::string &att_name, io::Type xtype, const std::vector< double > &data) const
Writes a double attribute.
Definition: NC_Serial.cc:747
void open_impl(const std::string &filename, io::Mode mode)
Definition: NC_Serial.cc:77
void inq_varnatts_impl(const std::string &variable_name, int &result) const
Get the number of attributes of a variable.
Definition: NC_Serial.cc:544
void inq_varid_impl(const std::string &variable_name, bool &exists) const
Finds a variable and sets the "exists" flag.
Definition: NC_Serial.cc:565
void inq_attname_impl(const std::string &variable_name, unsigned int n, std::string &result) const
Gets the name of a numbered attribute.
Definition: NC_Serial.cc:797
virtual void def_var_impl(const std::string &name, io::Type nctype, const std::vector< std::string > &dims) const
Define a variable.
Definition: NC_Serial.cc:252
virtual void set_compression_level_impl(int level) const
Definition: NC_Serial.cc:71
void close_impl()
Close a NetCDF file.
Definition: NC_Serial.cc:109
NC_Serial(MPI_Comm com)
Definition: NC_Serial.cc:55
void del_att_impl(const std::string &variable_name, const std::string &att_name) const
Definition: NC_Serial.cc:894
void inq_nvars_impl(int &result) const
Get the number of variables.
Definition: NC_Serial.cc:473
void sync_impl() const
Definition: NC_Serial.cc:125
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
Get variable data.
Definition: NC_Serial.cc:296
void inq_dimlen_impl(const std::string &dimension_name, unsigned int &result) const
Get a dimension length.
Definition: NC_Serial.cc:201
void redef_impl() const
Enter define mode.
Definition: NC_Serial.cc:156
void inq_dimid_impl(const std::string &dimension_name, bool &exists) const
Definition: NC_Serial.cc:185
virtual ~NC_Serial()
Definition: NC_Serial.cc:60
int get_varid(const std::string &variable_name) const
Definition: NC_Serial.cc:917
void inq_unlimdim_impl(std::string &result) const
Get an unlimited dimension.
Definition: NC_Serial.cc:224
void inq_atttype_impl(const std::string &variable_name, const std::string &att_name, io::Type &result) const
Gets the type of an attribute.
Definition: NC_Serial.cc:825
#define n
Definition: exactTestM.c:37
int count
Definition: test_cube.c:16