Loading [MathJax]/extensions/tex2jax.js
PISM, A Parallel Ice Sheet Model 2.2.2-d6b3a29ca committed by Constantine Khrulev on 2025-03-28
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
options.cc
Go to the documentation of this file.
1/* Copyright (C) 2018, 2019, 2021, 2023 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#include "pism/coupler/util/options.hh"
21
22#include "pism/util/Context.hh"
23#include "pism/util/ConfigInterface.hh"
24#include "pism/util/Logger.hh"
25#include "pism/util/Component.hh"
26
27namespace pism {
28
30 const std::string &prefix) {
31
32 const Logger &log = *ctx.log();
33 const Config &config = *ctx.config();
34
35 {
36 auto file = config.get_string(prefix + ".file");
37
38 if (not file.empty()) {
39 this->filename = file;
40 log.message(2,
41 " - Reading boundary conditions from '%s'...\n",
42 file.c_str());
43 } else {
44 this->filename = process_input_options(ctx.com(), ctx.config()).filename;
45
46 log.message(2,
47 " - Option %s.file is not set. Trying the input file '%s'...\n",
48 prefix.c_str(), this->filename.c_str());
49 }
50
51 if (this->filename.empty()) {
53 "PISM ERROR: %s.file is empty and no input ('-i') file found.",
54 prefix.c_str());
55 }
56 }
57
58 this->periodic = config.get_flag(prefix + ".periodic");
59}
60
61} // end of namespace pism
std::string get_string(const std::string &name, UseFlag flag=REMEMBER_THIS_USE) const
bool get_flag(const std::string &name, UseFlag flag=REMEMBER_THIS_USE) const
A class for storing and accessing PISM configuration flags and parameters.
MPI_Comm com() const
Definition Context.cc:65
std::shared_ptr< const Config > config() const
Definition Context.cc:89
std::shared_ptr< const Logger > log() const
Definition Context.cc:113
void message(int threshold, const char format[],...) const __attribute__((format(printf
Print a message to the log.
Definition Logger.cc:49
A basic logging class.
Definition Logger.hh:40
static RuntimeError formatted(const ErrorLocation &location, const char format[],...) __attribute__((format(printf
build a RuntimeError with a formatted message
#define PISM_ERROR_LOCATION
InputOptions process_input_options(MPI_Comm com, Config::ConstPtr config)
Definition Component.cc:43
std::string filename
Definition options.hh:33
ForcingOptions(const Context &ctx, const std::string &option_prefix)
Definition options.cc:29
std::string filename
name of the input file (if applicable)
Definition Component.hh:63