DEMO cosp diag on top of peter's parser - #8624
Conversation
|
Where does the parser get applied in this? |
| // Every requested name -- a plain model field, a rename, or a diagnostic | ||
| // expression -- goes into the bank, which works out what has to be built, | ||
| // in what order, and what can be shared. See eamxx_diag_bank.hpp. | ||
| // NOTE: the bank is given the static diag repo, so that two output streams | ||
| // asking for the same thing share one diagnostic, as they always have. | ||
| DiagBank bank (fm_grid,*fm_model,m_diag_repo); | ||
| bank.set_diag_params(m_diag_params); | ||
|
|
||
| // The 'aliases' yaml section declares intermediates: they must exist, so that | ||
| // other requests can refer to them, but they are not written to file. | ||
| for (const auto& request : m_intermediate_aliases) { | ||
| bank.add(request,/*write=*/false); |
In this specific demo, we have a few things handling the organization on eamxx side (I called them diag spec, diag tree, diag bank). Basically, the idea is that these collectively build the "bank" of diagnostics in EAMxx. This bank then queries the parser to figure out the order of dependencies, etc., and to also translate the expressions into something actionable in the code. |
|
spec is base, tree is on top of spec, and the bank is on top of the tree. bank is the one that ultimately interfaces with the parser (because it assembles the bank of diags) I plan to write this up on confluence soon |
|
The cosp part of this PR is noise, we need cosp for the manuscript for other reasons... This is the ultimate piece for the parser, everything else is just niceties and cute stuff. This is from the spec cpp file: DiagSpec lower_to_diag_spec (const std::string& expr,
const std::string& registered,
const bool write)
{
edp::parser::Parser parser {edp::Lexer{expr}};
const auto ast = parser.parse();
EKAT_REQUIRE_MSG (ast!=nullptr,
"Error! Could not parse diagnostic expression.\n"
" - expression: " + expr + "\n");
auto spec = lower(*ast);
spec.names.registered = registered.empty() ? expr : registered;
spec.names.write = write;
return spec;
} |
No description provided.