PISM, A Parallel Ice Sheet Model  stable v2.0.4 committed by Constantine Khrulev on 2022-05-25 12:02:27 -0800
Context.hh
Go to the documentation of this file.
1 /* Copyright (C) 2014, 2015, 2016, 2019, 2020, 2021 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_CONTEXT_H
21 #define PISM_CONTEXT_H
22 
23 #include <memory>
24 #include <string>
25 
26 #include <mpi.h>
27 
28 namespace pism {
29 
30 namespace units {
31 class System;
32 }
33 
34 class Config;
35 class EnthalpyConverter;
36 class Time;
37 class Profiling;
38 class Logger;
39 
40 class Context {
41 public:
42  typedef std::shared_ptr<units::System> UnitsSystemPtr;
43  typedef std::shared_ptr<Config> ConfigPtr;
44  typedef std::shared_ptr<const Config> ConstConfigPtr;
45  typedef std::shared_ptr<EnthalpyConverter> EnthalpyConverterPtr;
46  typedef std::shared_ptr<Time> TimePtr;
47  typedef std::shared_ptr<const Time> ConstTimePtr;
48  typedef std::shared_ptr<Logger> LoggerPtr;
49  typedef std::shared_ptr<const Logger> ConstLoggerPtr;
50 
51  Context(MPI_Comm c, UnitsSystemPtr sys,
53  LoggerPtr log,
54  const std::string &p);
55  ~Context();
56 
57  MPI_Comm com() const;
58  int size() const;
59  int rank() const;
61  ConstConfigPtr config() const;
63  ConstTimePtr time() const;
64  const std::string& prefix() const;
65  const Profiling& profiling() const;
66 
67  ConstLoggerPtr log() const;
68  LoggerPtr log();
69 
70  ConfigPtr config();
71  TimePtr time();
72 
73  int pio_iosys_id() const;
74 private:
75  class Impl;
77  // disable copying and assignments
78  Context(const Context& other);
80 };
81 
82 //! Create a default context using options.
83 std::shared_ptr<Context> context_from_options(MPI_Comm com,
84  const std::string &prefix,
85  bool print = false);
86 
87 } // end of namespace pism
88 
89 #endif /* PISM_CONTEXT_H */
A class for storing and accessing PISM configuration flags and parameters.
std::shared_ptr< units::System > UnitsSystemPtr
Definition: Context.hh:42
MPI_Comm com() const
Definition: Context.cc:82
EnthalpyConverterPtr enthalpy_converter() const
Definition: Context.cc:110
Context(const Context &other)
Impl * m_impl
Definition: Context.hh:75
ConstConfigPtr config() const
Definition: Context.cc:106
std::shared_ptr< const Config > ConstConfigPtr
Definition: Context.hh:44
int pio_iosys_id() const
Definition: Context.cc:141
const std::string & prefix() const
Definition: Context.cc:122
int size() const
Definition: Context.cc:86
const Profiling & profiling() const
Definition: Context.cc:126
Context & operator=(const Context &)
std::shared_ptr< const Logger > ConstLoggerPtr
Definition: Context.hh:49
Context(MPI_Comm c, UnitsSystemPtr sys, ConfigPtr conf, EnthalpyConverterPtr EC, TimePtr t, LoggerPtr log, const std::string &p)
Definition: Context.cc:62
int rank() const
Definition: Context.cc:92
UnitsSystemPtr unit_system() const
Definition: Context.cc:98
std::shared_ptr< EnthalpyConverter > EnthalpyConverterPtr
Definition: Context.hh:45
std::shared_ptr< Logger > LoggerPtr
Definition: Context.hh:48
std::shared_ptr< Config > ConfigPtr
Definition: Context.hh:43
std::shared_ptr< Time > TimePtr
Definition: Context.hh:46
std::shared_ptr< const Time > ConstTimePtr
Definition: Context.hh:47
ConstLoggerPtr log() const
Definition: Context.cc:130
ConstTimePtr time() const
Definition: Context.cc:118
Converts between specific enthalpy and temperature or liquid content.
A basic logging class.
Definition: Logger.hh:40
Time management class.
Definition: Time.hh:55
std::shared_ptr< Context > context_from_options(MPI_Comm com, const std::string &prefix, bool print)
Create a default context using options.
Definition: Context.cc:171