1#ifndef NGEN_REALIZATION_CONFIG_OUTPUT_H
2#define NGEN_REALIZATION_CONFIG_OUTPUT_H
7#include <boost/property_tree/ptree.hpp>
8#include <boost/optional.hpp>
36 throw std::runtime_error(
"Invalid output format '" + s +
"'; expected 'csv' or 'netcdf'.");
43 throw std::runtime_error(
"Invalid output grouping '" + s +
"'; expected 'per_feature' or 'per_formulation'.");
61 enable = tree.get<
bool>(
"enable",
true);
76 int mpi_rank,
int mpi_num_procs)
80 if (mpi_num_procs > 1 && needs_rank_subdir) {
81 return base_root +
"rank_" + std::to_string(mpi_rank) +
"/";
125 out.
root = output_tree.get<std::string>(
"root",
"");
128 if (
auto n = output_tree.get_child_optional(
"nexus")) out.
nexus =
OutputDomain(*n);
144 out.
from_legacy_keys =
static_cast<bool>(
root) ||
static_cast<bool>(disable_cat) ||
static_cast<bool>(per_form);
165 if (configured_root.empty()) {
168 return configured_root.back() ==
'/' ? configured_root : configured_root +
"/";
OutputGrouping
How a domain's records are distributed across files (the file-*granularity* axis): per_feature - one ...
Definition output.hpp:30
OutputGrouping parse_output_grouping(const std::string &s)
Definition output.hpp:39
static const std::string LEGACY_DISABLE_CATCHMENT_KEY
Definition output.hpp:18
static const std::string LEGACY_OUTPUT_ROOT_KEY
Deprecated top-level keys this block replaces.
Definition output.hpp:17
std::string rank_output_root(const std::string &base_root, const OutputDomain &domain, int mpi_rank, int mpi_num_procs)
The output root for a rank's files in this domain: appends "rank_<N>/" to base_root when the domain r...
Definition output.hpp:75
OutputFormat
Serialization format for an output domain.
Definition output.hpp:22
static const std::string LEGACY_PER_FORMULATION_KEY
Definition output.hpp:19
OutputFormat parse_output_format(const std::string &s)
Definition output.hpp:32
static const std::string OUTPUT_CONFIG_KEY
Key for the dedicated output configuration block in a realization config.
Definition output.hpp:14
Definition HY_Features.hpp:13
Settings for one output domain (catchment or nexus).
Definition output.hpp:47
OutputDomain(const boost::property_tree::ptree &tree)
Definition output.hpp:60
OutputGrouping grouping
Definition output.hpp:50
bool enable
Definition output.hpp:48
bool rank_subdir
Place each MPI rank's files under a "rank_<N>/" subdirectory (the filesystem-layout axis,...
Definition output.hpp:56
OutputFormat format
Definition output.hpp:49
Parsed representation of a realization config's output settings.
Definition output.hpp:102
static constexpr int DEFAULT_PRECISION
Significant digits applied uniformly when a text backend (CSV) renders values.
Definition output.hpp:104
static Output from_realization(const boost::property_tree::ptree &realization_tree)
Prefer the modern "output" block; otherwise fall back to legacy keys, then normalize the root (see no...
Definition output.hpp:152
static Output parse_legacy(const boost::property_tree::ptree &realization_tree)
Build from the deprecated top-level keys.
Definition output.hpp:133
static std::string normalize_root(const std::string &configured_root)
Normalize a configured directory to a trailing-slash path, falling back to "./" when unset.
Definition output.hpp:163
std::string root
Output directory.
Definition output.hpp:111
static Output parse_block(const boost::property_tree::ptree &output_tree)
Parse the modern "output" block sub-tree.
Definition output.hpp:122
OutputDomain catchment
Definition output.hpp:112
bool from_legacy_keys
True when built from the deprecated top-level keys (used to warn).
Definition output.hpp:117
OutputDomain nexus
Definition output.hpp:113
int precision
Global value precision for text output backends.
Definition output.hpp:115