PISM, A Parallel Ice Sheet Model 2.3.0-79cae578d committed by Constantine Khrulev on 2026-03-22
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
pism::OutputWriter Class Referenceabstract

#include <OutputWriter.hh>

+ Inheritance diagram for pism::OutputWriter:

Classes

struct  Impl
 

Public Member Functions

 OutputWriter (MPI_Comm comm, const Config &config)
 
virtual ~OutputWriter ()
 
void initialize (const std::set< VariableMetadata > &array_variables, bool relaxed_mode=false)
 
void define_variable (const std::string &file_name, const VariableMetadata &variable)
 
void set_global_attributes (const std::string &file_name, const std::map< std::string, std::string > &strings, const std::map< std::string, std::vector< double > > &numbers)
 
void append_history (const std::string &file_name, const std::string &text)
 
void append_time (const std::string &file_name, double time_seconds)
 
void write_array (const std::string &file_name, const std::string &variable_name, const std::vector< unsigned int > &start, const std::vector< unsigned int > &count, const std::vector< double > &input)
 
void write_text (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 (const std::string &file_name, const std::string &variable_name, const double *input)
 
void write_timeseries (const std::string &file_name, const std::string &variable_name, const std::vector< unsigned int > &start, const std::vector< unsigned int > &count, const std::vector< double > &input)
 
void append (const std::string &file_name)
 
void sync (const std::string &file_name)
 
void close (const std::string &file_name)
 
unsigned int time_dimension_length (const std::string &file_name)
 
double last_time_value (const std::string &file_name)
 
MPI_Comm comm () const
 
bool is_async () const
 

Protected Member Functions

void define_dimension (const std::string &file_name, const std::string &dimension_name, unsigned int length)
 
void define_variable (const std::string &file_name, const std::string &variable_name, const std::vector< std::string > &dims, io::Type type, const VariableAttributes &attributes)
 
void add_variable (const VariableMetadata &metadata)
 
const VariableMetadatavariable_info (const std::string &variable_name) const
 
bool variable_info_is_available (const std::string &variable_name) const
 
boolalready_written (const std::string &file_name, const std::string &variable_name, bool time_dependent)
 
const std::string & time_name () const
 
std::vector< std::string > define_dimensions (const std::string &file_name, const VariableMetadata &variable)
 
void write_dimensions (const std::string &file_name, const VariableMetadata &variable)
 
virtual void initialize_impl (const std::set< VariableMetadata > &array_variables)=0
 
virtual 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)=0
 
virtual void define_dimension_impl (const std::string &file_name, const std::string &name, unsigned int length)=0
 
virtual 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)=0
 
virtual void append_time_impl (const std::string &file_name, double time_seconds)=0
 
virtual void append_history_impl (const std::string &file_name, const std::string &text)=0
 
virtual unsigned int time_dimension_length_impl (const std::string &file_name)=0
 
virtual double last_time_value_impl (const std::string &file_name)=0
 
virtual 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)=0
 
virtual 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)=0
 
virtual void write_distributed_array_impl (const std::string &file_name, const std::string &variable_name, const double *data)=0
 
virtual void append_impl (const std::string &file_name)=0
 
virtual void sync_impl (const std::string &file_name)=0
 
virtual void close_impl (const std::string &file_name)=0
 
const std::string & experiment_id () const
 
void set_is_async (bool flag)
 

Private Member Functions

void write_experiment_id (const std::string &file_name)
 

Private Attributes

Implm_impl
 

Detailed Description

File output API

PISM writes the following kinds of output:

1) output at the end of a run (used to re-start the model),

2) 2D and 3D diagnostic output saved at specified model times during a run (affects model time stepping),

3) Same as 2), but each time record is saved to a separate file,

4) Same as 2), but appending to a file created by an earlier run,

5) Snapshots of the model state at times close to specified model times during a run (does not affect model time stepping; can be used to re-start a failed run)

6) Same as 5, but each snapshot is saved to separate file,

7) Scalar time-dependent diagnostics (value are stored redundantly on all MPI ranks),

8) Same as 7), but appending to a file created by an earlier run,

9) Snapshots of the model state saved after a specified wall clock time interval passed (used to re-start a failed run).

All files contain one unlimited dimension (time).

File contents are determined at run time.

A file may contain a mix of 1D, 2D, and 3D time-dependent and time-independent variables.

A file may contain more than one x,y grid and more than one set of vertical (z) levels.

Appending to a file requires being able to get the current length of the time dimension in a file and the last value of the corresponding coordinate variable.

In this API, the first call using file_name opens the file file_name. If the file already exists it is moved to file_name + "~" (a "backup" file).

If the first call using file_name is append(file_name), the file is opened for appending.

An opened file remains open until close() is called or until an instance of OutputWriter is de-allocated (i.e. until the end of a model run).

PISM defines all variables before writing any of the associated data. Attributes are set once and not modified afterwards. (This should make it possible to aggregate all metadata and write all of it at once.)

All variables associated with a grid (2D and 3D arrays, etc) have to be "declared" using a call to initialize(array_variables). This allows a class derived from OutputWriter to set up infrastructure needed to write these variables. For example: an implementation of asynchronous I/O can set up communication for all files at once.

PISM buffers scalar time-dependent diagnostics to reduce the number of I/O operations. 2D and 3D arrays are written one time record at a time (increase the length of time dimension by one, write a bunch of variables, increase the length of time dimension by one, write more, etc).

Definition at line 102 of file OutputWriter.hh.


The documentation for this class was generated from the following files: