Skip to content

DEMO cosp diag on top of peter's parser - #8624

Draft
mahf708 wants to merge 13 commits into
masterfrom
mahf708/eamxx/dsl-cosp
Draft

DEMO cosp diag on top of peter's parser #8624
mahf708 wants to merge 13 commits into
masterfrom
mahf708/eamxx/dsl-cosp

Conversation

@mahf708

@mahf708 mahf708 commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@mahf708
mahf708 changed the base branch from mahf708/eamxx/dsl to master August 12, 2026 14:55
@mahf708 mahf708 mentioned this pull request Aug 20, 2026
@rljacob

rljacob commented Aug 26, 2026

Copy link
Copy Markdown
Member

Where does the parser get applied in this?

Comment on lines +1159 to +1170
// 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);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rljacob here's a good entry point

@mahf708

mahf708 commented Aug 26, 2026

Copy link
Copy Markdown
Contributor Author

Where does the parser get applied in this?

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.

@mahf708

mahf708 commented Aug 26, 2026

Copy link
Copy Markdown
Contributor Author

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

@mahf708

mahf708 commented Aug 26, 2026

Copy link
Copy Markdown
Contributor Author

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;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants