PISM, A Parallel Ice Sheet Model 2.3.0-79cae578d committed by Constantine Khrulev on 2026-03-22
Loading...
Searching...
No Matches
SynchronousOutputWriter.hh
Go to the documentation of this file.
1/* Copyright (C) 2025 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
20#ifndef PISM_SYNCHRONOUSOUTPUTWRITER_H
21#define PISM_SYNCHRONOUSOUTPUTWRITER_H
22
23#include "pism/util/io/OutputWriter.hh"
24
25#include <memory>
26#include <string>
27
28namespace pism {
29
30class File;
31
32namespace io {
33enum Backend : int;
34}
35
36/*!
37 * Synchronous implementation of OutputWriter.
38 */
40public:
41 SynchronousOutputWriter(MPI_Comm comm, const Config &config);
42 virtual ~SynchronousOutputWriter() = default;
43
44private:
45 std::map<std::string, std::shared_ptr<File> > m_files;
48
49 const File &file(const std::string &file_name);
50
51 void initialize_impl(const std::set<VariableMetadata> &array_variables);
52
53 void define_dimension_impl(const std::string &file_name, const std::string &name,
54 unsigned int length);
55
56 void define_variable_impl(const std::string &file_name, const std::string &variable_name,
57 const std::vector<std::string> &dims, io::Type type,
58 const VariableAttributes &attributes);
59
60 void set_global_attributes_impl(const std::string &file_name,
61 const std::map<std::string, std::string> &strings,
62 const std::map<std::string, std::vector<double> > &numbers);
63
64 void write_attributes(const std::string &file_name, const std::string &var_name,
65 const std::map<std::string, std::string> &strings,
66 const std::map<std::string, std::vector<double> > &numbers,
67 io::Type output_type);
68
69 void append_time_impl(const std::string &file_name, double time_seconds);
70
71 void append_history_impl(const std::string &file_name, const std::string &text);
72
73 unsigned int time_dimension_length_impl(const std::string &file_name);
74
75 double last_time_value_impl(const std::string &file_name);
76
77 void write_array_impl(const std::string &file_name, const std::string &variable_name,
78 const std::vector<unsigned int> &start,
79 const std::vector<unsigned int> &count, const double *data);
80
81 void write_text_impl(const std::string &file_name, const std::string &variable_name,
82 const std::vector<unsigned int> &start,
83 const std::vector<unsigned int> &count, const std::string &input);
84
85 void write_distributed_array_impl(const std::string &file_name,
86 const std::string &variable_name, const double *data);
87
88 void append_impl(const std::string &file_name);
89 void sync_impl(const std::string &file_name);
90 void close_impl(const std::string &file_name);
91};
92
93} // namespace pism
94
95#endif /* PISM_SYNCHRONOUSOUTPUTWRITER_H */
A class for storing and accessing PISM configuration flags and parameters.
Definition Config.hh:56
High-level PISM I/O class.
Definition File.hh:57
MPI_Comm comm() const
void append_history_impl(const std::string &file_name, const std::string &text)
const File & file(const std::string &file_name)
void define_dimension_impl(const std::string &file_name, const std::string &name, unsigned int length)
void write_text_impl(const std::string &file_name, const std::string &variable_name, const std::vector< unsigned int > &start, const std::vector< unsigned int > &count, const std::string &input)
void write_distributed_array_impl(const std::string &file_name, const std::string &variable_name, const double *data)
void append_impl(const std::string &file_name)
void write_attributes(const std::string &file_name, const std::string &var_name, const std::map< std::string, std::string > &strings, const std::map< std::string, std::vector< double > > &numbers, io::Type output_type)
std::map< std::string, std::shared_ptr< File > > m_files
void define_variable_impl(const std::string &file_name, const std::string &variable_name, const std::vector< std::string > &dims, io::Type type, const VariableAttributes &attributes)
unsigned int time_dimension_length_impl(const std::string &file_name)
void append_time_impl(const std::string &file_name, double time_seconds)
void set_global_attributes_impl(const std::string &file_name, const std::map< std::string, std::string > &strings, const std::map< std::string, std::vector< double > > &numbers)
void write_array_impl(const std::string &file_name, const std::string &variable_name, const std::vector< unsigned int > &start, const std::vector< unsigned int > &count, const double *data)
virtual ~SynchronousOutputWriter()=default
void close_impl(const std::string &file_name)
void sync_impl(const std::string &file_name)
void initialize_impl(const std::set< VariableMetadata > &array_variables)
double last_time_value_impl(const std::string &file_name)
int count
Definition test_cube.c:16