PISM, A Parallel Ice Sheet Model
stable v2.1-1-g6902d5502 committed by Ed Bueler on 2023-12-20 08:38:27 -0800
src
coupler
util
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
27
namespace
pism
{
28
29
ForcingOptions::ForcingOptions
(
const
Context
&ctx,
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()) {
52
throw
RuntimeError::formatted
(
PISM_ERROR_LOCATION
,
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
pism::Config::get_string
std::string get_string(const std::string &name, UseFlag flag=REMEMBER_THIS_USE) const
Definition:
ConfigInterface.cc:257
pism::Config::get_flag
bool get_flag(const std::string &name, UseFlag flag=REMEMBER_THIS_USE) const
Definition:
ConfigInterface.cc:286
pism::Config
A class for storing and accessing PISM configuration flags and parameters.
Definition:
ConfigInterface.hh:53
pism::Context::com
MPI_Comm com() const
Definition:
Context.cc:81
pism::Context::config
std::shared_ptr< const Config > config() const
Definition:
Context.cc:105
pism::Context::log
std::shared_ptr< const Logger > log() const
Definition:
Context.cc:129
pism::Context
Definition:
Context.hh:40
pism::Logger::message
void message(int threshold, const char format[],...) const __attribute__((format(printf
Print a message to the log.
Definition:
Logger.cc:49
pism::Logger
A basic logging class.
Definition:
Logger.hh:40
pism::RuntimeError::formatted
static RuntimeError formatted(const ErrorLocation &location, const char format[],...) __attribute__((format(printf
build a RuntimeError with a formatted message
Definition:
error_handling.cc:47
PISM_ERROR_LOCATION
#define PISM_ERROR_LOCATION
Definition:
error_handling.hh:43
pism::process_input_options
InputOptions process_input_options(MPI_Comm com, Config::ConstPtr config)
Definition:
Component.cc:43
pism
Definition:
AgeColumnSystem.cc:23
pism::ForcingOptions::filename
std::string filename
Definition:
options.hh:33
pism::ForcingOptions::ForcingOptions
ForcingOptions(const Context &ctx, const std::string &option_prefix)
Definition:
options.cc:29
pism::ForcingOptions::periodic
bool periodic
Definition:
options.hh:34
pism::InputOptions::filename
std::string filename
name of the input file (if applicable)
Definition:
Component.hh:63
Generated by
1.9.1