tPNCFile.hh - pism - [fork] customized build of PISM, the parallel ice sheet model (tillflux branch)
HTML git clone git://src.adamsgaard.dk/pism
DIR Log
DIR Files
DIR Refs
DIR LICENSE
---
tPNCFile.hh (4467B)
---
1 // Copyright (C) 2012, 2013, 2014, 2015, 2016, 2017, 2019 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 "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 // 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
115 private:
116 std::vector<std::string> m_mpi_io_hints;
117
118 void get_var_double(const std::string &variable_name,
119 const std::vector<unsigned int> &start,
120 const std::vector<unsigned int> &count,
121 const std::vector<unsigned int> &imap, double *ip,
122 bool transposed) const;
123
124 void init_hints();
125
126 int get_varid(const std::string &variable_name) const;
127
128 MPI_Info m_mpi_info; // MPI hints
129 };
130
131 } // end of namespace io
132 } // end of namespace pism
133
134 #endif /* _PISMPNCFILE_H_ */