Skip to content

EAMxx: Output P0 scalar variable alongside lev/ilev geometry data#8405

Merged
bartgol merged 3 commits into
masterfrom
copilot/improve-cf-metadata-part-2
May 27, 2026
Merged

EAMxx: Output P0 scalar variable alongside lev/ilev geometry data#8405
bartgol merged 3 commits into
masterfrom
copilot/improve-cf-metadata-part-2

Conversation

Copilot AI commented May 19, 2026

Copy link
Copy Markdown
Contributor

CF conventions require a scalar reference pressure variable (P0) to accompany hybrid sigma-pressure coordinate variables (lev/ilev). Its absence breaks downstream tools (e.g., ncclimo, vertical interpolation workflows) that work fine with EAM output.

Changes

  • io_metadata.csv: Added P0 entry with long_name = "reference pressure".
  • homme_grids_manager.cpp and mesh_free_grids_manager.cpp: add P0 as a 0-dim geo data field whenever lev/ilev geo data fields are added. Get value from physics::Constants<Real>. This ensures IO will automatically add it whenever the lev/ilev geo data fields are added to the output stream.

Luca: I edited this, as I changed the impl to a different strategy.

Copilot AI linked an issue May 19, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Update CF metadata for EAMxx part 2 EAMxx: Output P0 scalar variable alongside lev/ilev geometry data May 19, 2026
Copilot AI requested a review from bartgol May 19, 2026 22:10
@bartgol
bartgol force-pushed the copilot/improve-cf-metadata-part-2 branch from d1c296f to 60d88cc Compare May 19, 2026 22:33
@bartgol
bartgol requested a review from Copilot May 19, 2026 22:35
@bartgol bartgol added BFB PR leaves answers BFB EAMxx C++ based E3SM atmosphere model (aka SCREAM) labels May 19, 2026
@bartgol
bartgol removed their request for review May 19, 2026 22:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds the CF-required scalar reference pressure variable (P0) alongside hybrid sigma-pressure vertical coordinate geometry (lev/ilev) so downstream tooling can correctly interpret hybrid coordinates.

Changes:

  • Added P0 to io_metadata.csv with long_name = "reference pressure".
  • Introduced FieldLayout::scalar() to represent 0-D (scalar) fields.
  • Ensured P0 geometry data is created and populated from physics::Constants<Real>::P0.value when building/adding vertical coordinate geo data.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
components/eamxx/src/share/util/io_metadata/io_metadata.csv Registers P0 metadata so IO can attach a descriptive long_name.
components/eamxx/src/share/field/field_layout.hpp Adds a scalar (0-D) layout helper used to define P0 as a scalar field.
components/eamxx/src/share/data_managers/mesh_free_grids_manager.cpp Creates and populates P0 in mesh-free grids to keep geo-data behavior consistent.
components/eamxx/src/dynamics/homme/homme_grids_manager.cpp Creates and populates P0 in Homme physics grid and uses it to compute lev/ilev.

@bartgol

bartgol commented May 19, 2026

Copy link
Copy Markdown
Contributor

@chengzhuzhang I don't know if you are familiar with the eamxx code, but I want to make sure that adding P0 is indeed enough to close the linked issue.

@AaronDonahue the PR adds P0 to the geo data of the grid, since we already have an automatic mechanism that writes geo data to file (including long name, units, etc).

@bartgol
bartgol marked this pull request as ready for review May 19, 2026 23:40
@czender
czender self-requested a review May 20, 2026 19:40

@czender czender left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@bartgol I added myself as a reviewer because I do not see where in this PR the CF formula_terms attribute has been added to lev and ilev coordinates. Same for standard_name. Perhaps those are in a different PR? If so, my concerns have been addressed. If not, then this PR is insufficient to address the original problem. Writing those attributes is also necessary to resolve the problem.

@chengzhuzhang

Copy link
Copy Markdown
Contributor

@bartgol thanks for getting to it so quickly. Sorry that I didn't make it clear that both formula_terms and standard_name attribute needs to be added, following the example from EAM. I just updated the issue description, and we may want to summon copilot for the additional work.

@czender thank you for catch this.

@bartgol

bartgol commented May 21, 2026

Copy link
Copy Markdown
Contributor

Ah, thanks. I did not get that we needed the formula attribute as well. I can easily add it.

@bartgol

bartgol commented May 21, 2026

Copy link
Copy Markdown
Contributor

Side q: none of our vars have the attribute positive = "down". I can add it to this PR if that's also needed.

@bartgol
bartgol requested a review from czender May 21, 2026 02:48
@bartgol

bartgol commented May 21, 2026

Copy link
Copy Markdown
Contributor

@czender @chengzhuzhang did I address all the concerns? Is there any other metadata you'd like me to add?

Comment thread components/eamxx/src/share/data_managers/mesh_free_grids_manager.cpp Outdated
@czender

czender commented May 21, 2026

Copy link
Copy Markdown
Contributor

@bartgol CF says "If the units attribute value is a valid pressure unit the default value of the positive attribute is down."
This means that positive = down is implicit for lev and ilev. It's your call whether to make that explicit by adding the attribute. In my opinion it would slightly improve the clarity of the EAMxx vertical coordinate. It's definitely a good idea to suggest adding this attribute to your MPAS Omega counterparts for their depth vertical coordinate.

@bartgol

bartgol commented May 21, 2026

Copy link
Copy Markdown
Contributor

@bartgol CF says "If the units attribute value is a valid pressure unit the default value of the positive attribute is down." This means that positive = down is implicit for lev and ilev. It's your call whether to make that explicit by adding the attribute. In my opinion it would slightly improve the clarity of the EAMxx vertical coordinate. It's definitely a good idea to suggest adding this attribute to your MPAS Omega counterparts for their depth vertical coordinate.

Is the CF guidance to add this attribute only to the vert coord variable? Or to all variables with vertical levels?

Edit: nvm, the AI bot answered that for me

@bartgol
bartgol force-pushed the copilot/improve-cf-metadata-part-2 branch from 283777b to 6e06de4 Compare May 21, 2026 22:43
@bartgol
bartgol requested a review from czender May 21, 2026 22:43
@bartgol

bartgol commented May 21, 2026

Copy link
Copy Markdown
Contributor

Ok, I fixed the var name, and added the positive = down att too. Let me know if there's anything else we need to add.

@czender czender left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good now. Thanks @bargol!

@chengzhuzhang chengzhuzhang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The code change looks good to me! Thanks @bartgol .

bartgol added a commit that referenced this pull request May 27, 2026
Add metadata to vertical hybrid coordinates variables (required by NCO)

[BFB]
@bartgol
bartgol merged commit 046c3bd into master May 27, 2026
12 checks passed
@bartgol
bartgol deleted the copilot/improve-cf-metadata-part-2 branch May 27, 2026 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BFB PR leaves answers BFB EAMxx C++ based E3SM atmosphere model (aka SCREAM)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EAMxx: Suggested CF Metadata Improvements Part 2

5 participants