ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_SurfaceCouplingParams.H File Reference

The inputs every surface coupling reads: enable, engine, grid_ratio, anchor_level. More...

#include <ERF_SurfaceCouplingNames.H>
#include <AMReX_ParmParse.H>
#include <string>
#include <vector>
Include dependency graph for ERF_SurfaceCouplingParams.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

std::string surface_quoted_list (const std::vector< std::string > &v)
 "a", "b", "c" (each name in double quotes, comma separated) More...
 
void read_surface_coupling_common (amrex::ParmParse &pp, const SurfaceCouplingNames &names, const std::vector< std::string > &engines, bool &enable, int &grid_ratio, int &anchor_level, std::string &engine)
 Read erf.<coupling>.enable, grid_ratio, anchor_level and engine. More...
 

Detailed Description

The inputs every surface coupling reads: enable, engine, grid_ratio, anchor_level.

Function Documentation

◆ read_surface_coupling_common()

void read_surface_coupling_common ( amrex::ParmParse &  pp,
const SurfaceCouplingNames &  names,
const std::vector< std::string > &  engines,
bool &  enable,
int &  grid_ratio,
int &  anchor_level,
std::string &  engine 
)

Read erf.<coupling>.enable, grid_ratio, anchor_level and engine.

Parameters
[in]ppParmParse with the coupling's prefix (erf.fire, erf.flood)
[in]namesThe coupling's names
[in]enginesThe engines compiled into this executable, sorted
[in,out]enableerf.<coupling>.enable (default on entry)
[in,out]grid_ratioerf.<coupling>.grid_ratio (default on entry); aborts below 1
[in,out]anchor_levelerf.<coupling>.anchor_level (default on entry); aborts below -1
[out]engineThe engine: the only one compiled in, or the one the deck names. Aborts when the deck enables the coupling or names an engine and no engine, or no single one, fits.
20 {
21  // Every message names the key and the value
22  auto fail = [&](const std::string& msg) { amrex::Abort(names.tag() + " " + msg); };
23 
24  pp.query("enable", enable);
25  pp.query("grid_ratio", grid_ratio);
26  if (grid_ratio < 1) {
27  fail(names.key("grid_ratio") + " must be >= 1, got " + std::to_string(grid_ratio));
28  }
29  pp.query("anchor_level", anchor_level);
30  if (anchor_level < -1) {
31  fail(names.key("anchor_level") + " must be -1 (the finest level) or a level >= 0, got "
32  + std::to_string(anchor_level));
33  }
34 
35  // The engine: one compiled into this executable (ERF_REGISTER_<X>_ENGINE).
36  // With a single engine it is the default; with several the deck names one.
37  if (engines.size() == 1) { engine = engines.front(); }
38  const bool engine_given = pp.query("engine", engine);
39  if (engine_given || enable) {
40  const std::string dir = std::string("Source/") + names.title + "Coupling";
41  if (engines.empty()) {
42  fail((enable ? names.key("enable") + " = true" : names.key("engine") + " is set")
43  + ", but no " + names.lower + " engine is compiled into this executable: " + dir
44  + " holds only the coupling to the atmosphere. Build with an engine directory (GNU make "
45  + names.upper + "_HOME, CMake ERF_" + names.upper + "_ENGINE_DIRS); " + dir + "/ERF_"
46  + names.title + "EngineTemplate.H lists what an engine provides.");
47  }
48  if (!engine_given && engines.size() > 1) {
49  fail(std::string("several ") + names.lower + " engines are compiled in ("
50  + surface_quoted_list(engines) + "): set " + names.key("engine") + " to one of them");
51  }
52  bool known = false;
53  for (const auto& a : engines) { known = known || (a == engine); }
54  if (!known) {
55  fail(names.key("engine") + " = \"" + engine + "\" is not one of " + surface_quoted_list(engines));
56  }
57  }
58 }
ParmParse pp("prob")
std::string surface_quoted_list(const std::vector< std::string > &v)
"a", "b", "c" (each name in double quotes, comma separated)
Definition: ERF_SurfaceCouplingParams.cpp:5
const char * title
"Fire": Source/<title>Coupling, ERF_<title>EngineTemplate.H
Definition: ERF_SurfaceCouplingNames.H:20
std::string tag() const
"[FIRE]"
Definition: ERF_SurfaceCouplingNames.H:24
const char * upper
"FIRE": the message tag [<upper>], <upper>HOME, ERF<upper>_ENGINE_DIRS
Definition: ERF_SurfaceCouplingNames.H:21
const char * lower
"fire": input prefix erf.<lower>, "the <lower> grid", "<lower> engine"
Definition: ERF_SurfaceCouplingNames.H:19
std::string key(const std::string &k) const
"erf.fire." followed by key
Definition: ERF_SurfaceCouplingNames.H:26

Referenced by FireCouplingParams::read(), and FloodCouplingParams::read().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ surface_quoted_list()

std::string surface_quoted_list ( const std::vector< std::string > &  v)

"a", "b", "c" (each name in double quotes, comma separated)

6 {
7  std::string list;
8  for (const auto& a : v) { list += (list.empty() ? "" : ", ") + std::string("\"") + a + "\""; }
9  return list;
10 }

Referenced by read_surface_coupling_common().

Here is the caller graph for this function: