19 #include "pism/util/io/NCFile.hh"
22 #include "pism/util/error_handling.hh"
23 #include "pism/util/Grid.hh"
28 #define MPI_INCLUDED 1
36 : m_com(c), m_file_id(-1), m_define_mode(false) {
53 std::vector<size_t> &dimensions)
const {
115 const std::vector<std::string> &dims)
const {
121 std::vector<size_t> &dimensions)
const {
127 const std::vector<unsigned int> &start,
128 const std::vector<unsigned int> &
count,
131 if (start.size() !=
count.size()) {
133 "start and count arrays have to have the same size");
142 const std::vector<unsigned int> &start,
143 const std::vector<unsigned int> &
count,
144 const double *op)
const {
146 if (start.size() !=
count.size()) {
148 "start and count arrays have to have the same size");
159 unsigned int z_count,
162 const double *input) {
164 this->
write_darray_impl(variable_name, grid, z_count, time_dependent, record, input);
172 unsigned int z_count,
175 const double *input) {
176 std::vector<unsigned int> start,
count;
178 if (time_dependent) {
179 start = { record, (unsigned)grid.
ys(), (unsigned)grid.
xs(), 0 };
180 count = { 1, (unsigned)grid.
ym(), (unsigned)grid.
xm(), z_count };
182 start = { (unsigned)grid.
ys(), (unsigned)grid.
xs(), 0 };
183 count = { (unsigned)grid.
ym(), (unsigned)grid.
xm(), z_count };
191 const std::vector<unsigned int> &start,
192 const std::vector<unsigned int> &
count,
193 const std::vector<unsigned int> &imap,
197 if (start.size() !=
count.size() or
198 start.size() != imap.size()) {
200 "start, count and imap arrays have to have the same size");
229 const std::string &att_name,
230 std::vector<double> &result)
const {
235 const std::string &att_name,
236 std::string &result)
const {
241 const std::string &att_name,
243 const std::vector<double> &data)
const {
248 const std::string &att_name,
249 const std::string &value)
const {
255 std::string &result)
const {
260 const std::string &att_name,
270 void NCFile::del_att(
const std::string &variable_name,
const std::string &att_name)
const {
int ys() const
Global starting index of this processor's subset.
int xs() const
Global starting index of this processor's subset.
int xm() const
Width of this processor's sub-domain.
int ym() const
Width of this processor's sub-domain.
Describes the PISM grid and the distribution of data across processors.
static RuntimeError formatted(const ErrorLocation &location, const char format[],...) __attribute__((format(printf
build a RuntimeError with a formatted message
void inq_varname(unsigned int j, std::string &result) const
virtual void enddef_impl() const =0
void inq_atttype(const std::string &variable_name, const std::string &att_name, io::Type &result) const
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 =0
virtual void inq_attname_impl(const std::string &variable_name, unsigned int n, std::string &result) const =0
void inq_attname(const std::string &variable_name, unsigned int n, std::string &result) const
virtual void create_impl(const std::string &filename)=0
virtual void inq_dimlen_impl(const std::string &dimension_name, unsigned int &result) const =0
void del_att(const std::string &variable_name, const std::string &att_name) const
void get_vara_double(const std::string &variable_name, const std::vector< unsigned int > &start, const std::vector< unsigned int > &count, double *ip) const
virtual void close_impl()=0
virtual void put_att_text_impl(const std::string &variable_name, const std::string &att_name, const std::string &value) const =0
void inq_unlimdim(std::string &result) const
virtual void del_att_impl(const std::string &variable_name, const std::string &att_name) const =0
virtual void inq_atttype_impl(const std::string &variable_name, const std::string &att_name, io::Type &result) const =0
void create(const std::string &filename)
void get_att_text(const std::string &variable_name, const std::string &att_name, std::string &result) const
void put_att_double(const std::string &variable_name, const std::string &att_name, io::Type xtype, const std::vector< double > &data) const
virtual void open_impl(const std::string &filename, io::Mode mode)=0
void get_att_double(const std::string &variable_name, const std::string &att_name, std::vector< double > &result) const
void inq_dimlen(const std::string &dimension_name, unsigned int &result) const
void def_dim(const std::string &name, size_t length) const
void put_vara_double(const std::string &variable_name, const std::vector< unsigned int > &start, const std::vector< unsigned int > &count, const double *op) const
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 =0
void set_compression_level(int level) const
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 =0
virtual void inq_varname_impl(unsigned int j, std::string &result) const =0
virtual void set_compression_level_impl(int level) const =0
void write_darray(const std::string &variable_name, const Grid &grid, unsigned int z_count, bool time_dependent, unsigned int record, const double *input)
virtual void def_dim_impl(const std::string &name, size_t length) const =0
void open(const std::string &filename, io::Mode mode)
virtual void inq_vardimid_impl(const std::string &variable_name, std::vector< std::string > &result) const =0
void set_fill(int fillmode, int &old_modep) const
virtual void inq_varnatts_impl(const std::string &variable_name, int &result) const =0
virtual void inq_dimid_impl(const std::string &dimension_name, bool &exists) const =0
void def_var_chunking(const std::string &name, std::vector< size_t > &dimensions) const
void get_varm_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) const
virtual void get_att_double_impl(const std::string &variable_name, const std::string &att_name, std::vector< double > &result) const =0
virtual void inq_unlimdim_impl(std::string &result) const =0
virtual void set_fill_impl(int fillmode, int &old_modep) const =0
virtual 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)
void inq_dimid(const std::string &dimension_name, bool &exists) const
virtual void sync_impl() const =0
std::string filename() const
virtual void def_var_impl(const std::string &name, io::Type nctype, const std::vector< std::string > &dims) const =0
void inq_nvars(int &result) const
virtual void redef_impl() const =0
virtual void def_var_chunking_impl(const std::string &name, std::vector< size_t > &dimensions) const
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 =0
virtual void get_att_text_impl(const std::string &variable_name, const std::string &att_name, std::string &result) const =0
virtual void inq_varid_impl(const std::string &variable_name, bool &exists) const =0
void put_att_text(const std::string &variable_name, const std::string &att_name, const std::string &value) const
void inq_vardimid(const std::string &variable_name, std::vector< std::string > &result) const
void inq_varnatts(const std::string &variable_name, int &result) const
void inq_varid(const std::string &variable_name, bool &result) const
virtual void inq_nvars_impl(int &result) const =0
void def_var(const std::string &name, io::Type nctype, const std::vector< std::string > &dims) const
#define PISM_ERROR_LOCATION