NGen
Loading...
Searching...
No Matches
realization::config Namespace Reference

Classes

struct  Config
 Structure representing the configuration for a general Formulation. More...
 
struct  Forcing
 Structure for holding forcing configuration information. More...
 
struct  Formulation
 
struct  Layer
 Layer configuration information. More...
 
struct  Output
 Parsed representation of a realization config's output settings. More...
 
struct  OutputDomain
 Settings for one output domain (catchment or nexus). More...
 
struct  Routing
 
struct  Time
 Simple structure for holding time bounds and output interval (seconds) More...
 

Enumerations

enum class  GlobalConfigKey { SERIALIZATION }
 Identifier for a realization-level configuration block that can be inherited down into each formulation's params. More...
 
enum class  OutputFormat {
  csv ,
  netcdf
}
 Serialization format for an output domain. More...
 
enum class  OutputGrouping {
  per_feature ,
  per_formulation
}
 How a domain's records are distributed across files (the file-*granularity* axis): per_feature - one file per feature (one CSV per catchment / per nexus) per_formulation - the features of a formulation aggregate into one file (a feature-id column distinguishes their rows). More...
 

Functions

std::shared_ptr< utils::CatchmentOutputsMgr > make_catchment_output_mgr (const Output &output_config, std::vector< utils::FeatureDescriptor > descriptors, const std::string &aggregated_filename=DEFAULT_AGGREGATED_FILENAME)
 Build the catchment output manager from the parsed output configuration.
 
const char * to_key_string (GlobalConfigKey which)
 Top-level JSON key string for a given GlobalConfigKey.
 
void apply_config (geojson::PropertyMap &child, const geojson::PropertyMap &parent, GlobalConfigKey which)
 Copy a named config block from parent into child, unless the child already declares its own entry for the same key.
 
OutputFormat parse_output_format (const std::string &s)
 
OutputGrouping parse_output_grouping (const std::string &s)
 
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 requests per-rank subdirectories, or when it aggregates per formulation (which requires per-rank separation so ranks don't write the same file).
 
void apply_serialization_path_token_resolution (boost::property_tree::ptree &block)
 Resolve {{rank}}/{{pid}}/{{host}}/{{date}} tokens in every path field the serialization block may carry.
 
void apply_serialization_restore_subset_default (geojson::PropertyMap &global_configs, const std::vector< std::string > &known_ids)
 Auto-populate serialization.restore.id_subset with the set of catchment identifiers that this realization will actually instantiate, when the user hasn't supplied one.
 

Variables

static const std::string DEFAULT_AGGREGATED_FILENAME = "cat_output.csv"
 Default file name for an aggregated (per_formulation) catchment file.
 
static const std::string OUTPUT_CONFIG_KEY = "output"
 Key for the dedicated output configuration block in a realization config.
 
static const std::string LEGACY_OUTPUT_ROOT_KEY = "output_root"
 Deprecated top-level keys this block replaces.
 
static const std::string LEGACY_DISABLE_CATCHMENT_KEY = "disable_catchment_output"
 
static const std::string LEGACY_PER_FORMULATION_KEY = "per_formulation_nexus_files"
 
static const std::string ROUTING_CONFIG_KEY = "t_route_config_file_with_path"
 

Enumeration Type Documentation

◆ GlobalConfigKey

Identifier for a realization-level configuration block that can be inherited down into each formulation's params.

The inheritance convention is: if a realization-level JSON document carries a block under the key identified by this enum, every formulation built by Formulation_Manager receives that block in its params unless the per-formulation config already declares it. Within a multi-BMI formulation, the block is further propagated into each submodule's params on the same "child wins" basis.

Adding a new realization-level inheritable block is a two-step: 1) add an enum entry here; 2) add a matching case in to_key_string() below. The rest of the plumbing (parsing, injection, submodule propagation) is already wired to iterate enum values.

Enumerator
SERIALIZATION 

The serialization block consumed by the BMI serialization protocols (Ngen{Serialization,Deserialization}Protocol).

◆ OutputFormat

Serialization format for an output domain.

Enumerator
csv 
netcdf 

◆ OutputGrouping

How a domain's records are distributed across files (the file-*granularity* axis): per_feature - one file per feature (one CSV per catchment / per nexus) per_formulation - the features of a formulation aggregate into one file (a feature-id column distinguishes their rows).

Fewer, larger files; columns are uniform within a file by construction. Orthogonal to this is OutputDomain::rank_subdir, the filesystem-*layout* axis.

Enumerator
per_feature 
per_formulation 

Function Documentation

◆ apply_config()

void realization::config::apply_config ( geojson::PropertyMap & child,
const geojson::PropertyMap & parent,
GlobalConfigKey which )
inline

Copy a named config block from parent into child, unless the child already declares its own entry for the same key.

Per-child entries always win; the parent value is a default, not an override. This is the single mechanism for realization-level config inheritance — Formulation_Manager calls it to seed every formulation from parsed top-level blocks, and Bmi_Multi_Formulation calls it during submodule setup to carry the same defaults further down the tree.

No-op if the parent has no entry under which.

References to_key_string().

Referenced by realization::Formulation_Manager::construct_formulation_from_config(), realization::Formulation_Manager::construct_missing_formulation(), and realization::Bmi_Multi_Formulation::create_multi_formulation().

◆ apply_serialization_path_token_resolution()

void realization::config::apply_serialization_path_token_resolution ( boost::property_tree::ptree & block)
inline

Resolve {{rank}}/{{pid}}/{{host}}/{{date}} tokens in every path field the serialization block may carry.

The serialization block accepts a shared top-level path plus two per-direction overrides — save.path and restore.path. Each may be absent; when present, its value goes through utilities::resolve_path_tokens so consumers see concrete strings.

Absent keys are skipped; ptree's dotted-path put() would otherwise fabricate the intermediate sub-block.

Parameters
blockThe raw serialization sub-tree (mutated in place).

References utilities::resolve_path_tokens().

Referenced by realization::Formulation_Manager::read().

◆ apply_serialization_restore_subset_default()

void realization::config::apply_serialization_restore_subset_default ( geojson::PropertyMap & global_configs,
const std::vector< std::string > & known_ids )
inline

Auto-populate serialization.restore.id_subset with the set of catchment identifiers that this realization will actually instantiate, when the user hasn't supplied one.

id_subset is a scoping knob that bounds which records are requested from the serialization backend. This function applies a default policy for creating the subset based on the realization's enumerated features when they are specified.

No-op if any of the following hold (deliberately conservative):

  • no serialization block is present in global_configs;
  • the serialization block has no restore sub-block;
  • the restore sub-block already declares id_subset — the caller's explicit value always wins, same as the rest of the inheritance system;
  • known_ids is empty (passing an empty list could be read as "restore nothing", which is the wrong default).
Parameters
global_configsThe realization-level inheritable configs map (mutated in place).
known_idsCatchment ids the caller intends to construct.

References geojson::Object, SERIALIZATION, and to_key_string().

Referenced by realization::Formulation_Manager::read().

◆ make_catchment_output_mgr()

std::shared_ptr< utils::CatchmentOutputsMgr > realization::config::make_catchment_output_mgr ( const Output & output_config,
std::vector< utils::FeatureDescriptor > descriptors,
const std::string & aggregated_filename = DEFAULT_AGGREGATED_FILENAME )
inline

Build the catchment output manager from the parsed output configuration.

Grouping and precision come from output_config; the resolved root comes from output_config.root, which the caller is expected to have already adjusted for rank layout (see rank_output_root) so any rank_<N>/ subdirectory is baked into the root.

The manager is constructed with the full set of descriptors (every catchment and its columns), so the backend lays out its files up front and is ready to receive data on return.

Side effect: constructing the manager creates the output directory tree it writes into (config parsing only normalizes the root – it does not touch the filesystem). Each output manager owns creating what it writes, so no caller need pre-create the directory.

Only the CSV format is implemented today; any other configured format is rejected here (the branch on output_config.catchment.format is where an added format would slot in). Layout follows the grouping: per_formulation aggregates each formulation's catchments into one file (leading catchment_id column) named aggregated_filename; per_feature writes one file per catchment.

Exceptions
std::runtime_errorif a catchment output format other than CSV is configured.

References realization::config::Output::catchment, csv, realization::config::OutputDomain::format, realization::config::OutputDomain::grouping, per_formulation, realization::config::Output::precision, and realization::config::Output::root.

◆ parse_output_format()

OutputFormat realization::config::parse_output_format ( const std::string & s)
inline

◆ parse_output_grouping()

OutputGrouping realization::config::parse_output_grouping ( const std::string & s)
inline

◆ rank_output_root()

std::string realization::config::rank_output_root ( const std::string & base_root,
const OutputDomain & domain,
int mpi_rank,
int mpi_num_procs )
inline

The output root for a rank's files in this domain: appends "rank_<N>/" to base_root when the domain requests per-rank subdirectories, or when it aggregates per formulation (which requires per-rank separation so ranks don't write the same file).

Only distributed (mpi_num_procs > 1) runs are affected; in serial base_root is returned unchanged. The directory is created lazily by the backend when it opens files.

References realization::config::OutputDomain::grouping, per_formulation, and realization::config::OutputDomain::rank_subdir.

◆ to_key_string()

const char * realization::config::to_key_string ( GlobalConfigKey which)
inline

Top-level JSON key string for a given GlobalConfigKey.

References SERIALIZATION.

Referenced by apply_config(), apply_serialization_restore_subset_default(), and realization::Formulation_Manager::read().

Variable Documentation

◆ DEFAULT_AGGREGATED_FILENAME

const std::string realization::config::DEFAULT_AGGREGATED_FILENAME = "cat_output.csv"
static

Default file name for an aggregated (per_formulation) catchment file.

The rank, when applicable, is carried in the resolved root (a rank_<N>/ subdirectory), not the file name.

◆ LEGACY_DISABLE_CATCHMENT_KEY

const std::string realization::config::LEGACY_DISABLE_CATCHMENT_KEY = "disable_catchment_output"
static

◆ LEGACY_OUTPUT_ROOT_KEY

const std::string realization::config::LEGACY_OUTPUT_ROOT_KEY = "output_root"
static

Deprecated top-level keys this block replaces.

Referenced by realization::config::Output::parse_legacy().

◆ LEGACY_PER_FORMULATION_KEY

const std::string realization::config::LEGACY_PER_FORMULATION_KEY = "per_formulation_nexus_files"
static

◆ OUTPUT_CONFIG_KEY

const std::string realization::config::OUTPUT_CONFIG_KEY = "output"
static

Key for the dedicated output configuration block in a realization config.

Referenced by realization::config::Output::from_realization().

◆ ROUTING_CONFIG_KEY

const std::string realization::config::ROUTING_CONFIG_KEY = "t_route_config_file_with_path"
static