Loading [MathJax]/extensions/tex2jax.js
PISM, A Parallel Ice Sheet Model 2.2.2-d6b3a29ca committed by Constantine Khrulev on 2025-03-28
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
NC_Serial.hh
Go to the documentation of this file.
1// Copyright (C) 2012, 2013, 2014, 2015, 2017, 2019, 2020, 2023, 2024 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
24namespace pism {
25namespace io {
26
27class NC_Serial : public NCFile
28{
29public:
30 NC_Serial(MPI_Comm com);
31 virtual ~NC_Serial();
32
33 std::string get_format() const;
34
35protected:
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 inq_nvars_impl(int &result) const;
74
75 void inq_vardimid_impl(const std::string &variable_name, std::vector<std::string> &result) const;
76
77 void inq_varnatts_impl(const std::string &variable_name, int &result) const;
78
79 void inq_varid_impl(const std::string &variable_name, bool &exists) const;
80
81 void inq_varname_impl(unsigned int j, std::string &result) const;
82
83 virtual void set_compression_level_impl(int level) const;
84
85 // att
86 void get_att_double_impl(const std::string &variable_name, const std::string &att_name, std::vector<double> &result) const;
87
88 void get_att_text_impl(const std::string &variable_name, const std::string &att_name, std::string &result) const;
89
90 void put_att_double_impl(const std::string &variable_name, const std::string &att_name, io::Type xtype, const std::vector<double> &data) const;
91
92 void put_att_text_impl(const std::string &variable_name, const std::string &att_name, const std::string &value) const;
93
94 void inq_attname_impl(const std::string &variable_name, unsigned int n, std::string &result) const;
95
96 void inq_atttype_impl(const std::string &variable_name, const std::string &att_name, io::Type &result) const;
97
98 // misc
99 void set_fill_impl(int fillmode, int &old_modep) const;
100
101 void del_att_impl(const std::string &variable_name, const std::string &att_name) const;
102
104
105 int get_varid(const std::string &variable_name) const;
106
107private:
108 void get_var_double(const std::string &variable_name, const std::vector<unsigned int> &start,
109 const std::vector<unsigned int> &count, double *ip) const;
110};
111
112} // end of namespace io
113} // end of namespace pism
114
115#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:670
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:550
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:368
void set_fill_impl(int fillmode, int &old_modep) const
Sets the fill mode.
Definition NC_Serial.cc:828
std::string get_format() const
Definition NC_Serial.cc:842
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:281
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:459
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:744
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:572
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:718
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:515
void inq_varid_impl(const std::string &variable_name, bool &exists) const
Finds a variable and sets the "exists" flag.
Definition NC_Serial.cc:536
void get_var_double(const std::string &variable_name, const std::vector< unsigned int > &start, const std::vector< unsigned int > &count, double *ip) const
Get variable data.
Definition NC_Serial.cc:288
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:768
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
void del_att_impl(const std::string &variable_name, const std::string &att_name) const
Definition NC_Serial.cc:865
void inq_nvars_impl(int &result) const
Get the number of variables.
Definition NC_Serial.cc:444
void sync_impl() const
Definition NC_Serial.cc:125
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:888
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:796
#define n
Definition exactTestM.c:37
int count
Definition test_cube.c:16