Skip to content

EAMxx: MAM4xx+ZM [DRAFT] - #8671

Open
odiazib wants to merge 22 commits into
masterfrom
odiazib/eamxx/mam4xx-zm
Open

odiazib wants to merge 22 commits into
masterfrom
odiazib/eamxx/mam4xx-zm

Conversation

@odiazib

@odiazib odiazib commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

The ZM+MAM4xx coupling is based on E3SM v2 and currently includes only the MAM4xx side. Please check for any missing code integration. I will keep this PR as a draft, as there is still a lot of work and discussion to be done.

see also: E3SM-Project/mam4xx#587

This PR is BFB. However, we added two multi-process tests, one of which checks baselines. Since baselines have not been created for this test yet, it will fail:

homme_shoc_cld_spa_p3_rrtmgp_zm_mam4_wetscav_baseline_cmp
Failed: baseline_cmp, baseline_gen

@whannah1
whannah1 self-requested a review August 26, 2026 16:40
@odiazib
odiazib force-pushed the odiazib/eamxx/mam4xx-zm branch from 1d8b5a4 to 38517b8 Compare September 10, 2026 14:48
@github-actions

github-actions Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.2

QR code for preview link

🚀 View preview at
https://E3SM-Project.github.io/E3SM/pr-preview/pr-8671/

Built to branch gh-pages at 2026-10-31 05:28 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@odiazib
odiazib force-pushed the odiazib/eamxx/mam4xx-zm branch 2 times, most recently from 4f7920a to 24ce329 Compare September 17, 2026 15:02
@odiazib
odiazib force-pushed the odiazib/eamxx/mam4xx-zm branch 2 times, most recently from 39c78a4 to a57b412 Compare September 23, 2026 15:16

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.

Copilot review overview

🟡 Changes recommended

The implementation has a missing mam4xx API update, GPU-invalid host pointers, and incorrect dry-pressure units.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 3 High severity · 1 Low severity

Open (4)
What changed in this PR

Couples ZM deep-convection outputs to MAM4xx convective wet scavenging.

Changes:

  • Exposes ZM diagnostics required by MAM4xx.
  • Adds configurable aerosol and gas convective processing.
  • Adds physics-only, dynamics-physics, and CIME integration tests.
File Description
components/​eamxx/​tests/​multi-process/​physics_only/​mam/​p3_zm_mam4_wetscav/​output.yaml Defines test outputs.
components/​eamxx/​tests/​multi-process/​physics_only/​mam/​p3_zm_mam4_wetscav/​input.yaml Configures the physics-only test.
components/​eamxx/​tests/​multi-process/​physics_only/​mam/​p3_zm_mam4_wetscav/​CMakeLists.txt Registers the test.
components/​eamxx/​tests/​multi-process/​physics_only/​CMakeLists.txt Enables the test directory.
components/​eamxx/​tests/​multi-process/​dynamics_physics/​mam/​homme_shoc_cld_spa_p3_rrtmgp_zm_mam4_wetscav/​output.yaml Defines coupled test outputs.
components/​eamxx/​tests/​multi-process/​dynamics_physics/​mam/​homme_shoc_cld_spa_p3_rrtmgp_zm_mam4_wetscav/​input.yaml Configures the coupled process chain.
components/​eamxx/​tests/​multi-process/​dynamics_physics/​mam/​homme_shoc_cld_spa_p3_rrtmgp_zm_mam4_wetscav/​CMakeLists.txt Registers the coupled test.
components/​eamxx/​tests/​multi-process/​dynamics_physics/​mam/​CMakeLists.txt Enables the coupled test directory.
components/​eamxx/​src/​physics/​zm/​impl/​zm_conv_main_impl.hpp Initializes inactive-column cloud-top output.
components/​eamxx/​src/​physics/​zm/​eamxx_zm_process_interface.cpp Exports ZM coupling fields.
components/​eamxx/​src/​physics/​mam/​eamxx_mam_wetscav_process_interface.hpp Adds ConvProc state and workspace.
components/​eamxx/​src/​physics/​mam/​eamxx_mam_wetscav_process_interface.cpp Integrates ConvProc with ZM outputs.
components/​eamxx/​cime_config/​testdefs/​testmods_dirs/​eamxx/​mam4xx/​zm/​shell_commands Configures the CIME ZM/MAM4xx test.
components/​eamxx/​cime_config/​namelist_defaults_eamxx.xml Adds ConvProc defaults.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@odiazib odiazib closed this Sep 28, 2026
@odiazib odiazib reopened this Sep 28, 2026
@odiazib
odiazib force-pushed the odiazib/eamxx/mam4xx-zm branch from f309386 to a5bb2ce Compare October 1, 2026 15:11
@susburrows

Copy link
Copy Markdown
Contributor

As we discussed yesterday, it would be a good idea to consolidate the convective vertical transport in one place. But I think that can wait for a follow-up PR.

@whannah1

whannah1 commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

As we discussed yesterday, it would be a good idea to consolidate the convective vertical transport in one place. But I think that can wait for a follow-up PR.

To be clear - "consolidate" does not mean we remove the ZM tracer transport since we discussed scenarios where we might want to use that capability.

@kaizhangpnl

This comment was marked as resolved.

@kaizhangpnl

Copy link
Copy Markdown
Contributor

Remember that there is a potential bug in convproc.hpp:

https://github.com/E3SM-Project/mam4xx/blob/077a017ed3cdd2803ed64b34fc2f666688274875/src/mam4xx/convproc.hpp#L2732-L2744

@kaizhangpnl

This comment was marked as resolved.

@whannah1

This comment was marked as resolved.

@kaizhangpnl

This comment was marked as resolved.

@kaizhangpnl

This comment was marked as resolved.

@kaizhangpnl kaizhangpnl 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.

Great effort for this important PR. There are code changes in mam4xx, so I couldn't use in-line comment. Some of them are not MAM4xx+ZM coupling issues and they (and there are more "FIXME" comments) can be fixed later.

add_field<Computed>("zm_dcape", scalar2d, J/kg/s, grid_name);
add_field<Computed>("zm_activity", scalar2d, none, grid_name);
add_field<Computed>("zm_jt", scalar2d, none, grid_name);
add_field<Computed>("zm_jcbot", scalar2d, none, grid_name);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ZM scheme uses the parcel lifting level (maxi) as the cloud-base level, which is appropriate for convective transport. However, for aerosol activation, the lifting condensation level (LCL) may be more appropriate, as it represents the level at which a rising air parcel becomes saturated, allowing aerosol activation and cloud droplet formation to occur.

@odiazib odiazib Oct 13, 2026 •

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.

@DJFJJA could you please point to the variable name (Fortran) of the lifting condensation level (LCL)?

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.

@odiazib the variable jlcl in zm_conv_main() gives the index of the LCL.

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.

So, zm tracer transport uses maxi (is this jctop?). But we want the aerosol tracer to use jlcl instead of jctop?
Note: for gases, which we agree will be handled by MAM4xx, we still need to use jctop. @DJFJJA and @whannah1.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

maxi represents the parcel lifting level, corresponding to jcbot (the cloud-base level index), while jctop represents the cloud-top level index.

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.

So, zm tracer transport uses maxi (is this jctop?). But we want the aerosol tracer to use jlcl instead of jctop? Note: for gases, which we agree will be handled by MAM4xx, we still need to use jctop. @DJFJJA and @whannah1.

To clarify - maxi was the old name for the level of maximum MSE used to launch parcels, and maxg was the "gathered" version. In the fortran refactor I renamed these to be msemax_klev / msemax_klev_g.

@DJFJJA was pointing out that the LCL may be "above" jcbot and the layers between the parcel launch level and the LCL might not have any condensate, thus no aerosol activation should happen in those levels. Whereas it might still be appropriate to use the parcel launch level for transport. I think it's a good point, but I'm not sure how to address it.

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.

@whannah1 @DJFJJA, we are using zm_jt for ktop and zm_msemax_klev for kbot. Is this correct?

Comment thread externals/mam4xx

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

In mam4xx/convproc.hpp:

Image

I can confirm that this is a bug. The layer thickness (dz) should vary with vertical level rather than being a single scalar value. The same issue exists in the Fortran code as well.

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.

@kaizhangpnl and @DJFJJA, can we handle this bug in a follow-up PR? This PR and its associated MAM4xx PR are too large. Note that I created an issue for this bug here: E3SM-Project/mam4xx#612

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.

Good!

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sounds good!

@overfelt
overfelt force-pushed the odiazib/eamxx/mam4xx-zm branch from 8c82a19 to 5986c44 Compare October 28, 2026 22:01
@kaizhangpnl

kaizhangpnl commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Many thanks for all your work in finalizing this PR. I have one additional comment: we should verify that the units of all fields passed to ma_convproc_intr match the units it expects. I may have missed some necessary conversions, so I would appreciate the developers’ help checking this.

Two potential inconsistencies:

Could you help confirm that the necessary conversions are applied and check the remaining input fields for similar inconsistencies? Thanks!

@odiazib

odiazib commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor Author

@kaizhangpnl The units of kg/m²/s come from the ZM interface see here.

@whannah1 Is there a typo in the units of zm_mflx_up? Should mb/s be kg/m/s^3?

@odiazib

odiazib commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

@kaizhangpnl I corrected the units for dpdry. Note that dpdry is used only by ma_convproc_intr.

@DJFJJA

DJFJJA commented Oct 29, 2026

Copy link
Copy Markdown

@kaizhangpnl The units of kg/m²/s come from the ZM interface see here.

@whannah1 Is there a typo in the units of zm_mflx_up? Should mb/s be kg/m/s^3?

In the ZM scheme, the updraft mass flux (mflx_up) is calculated in mb/s. In the Fortran implementation, it is converted to kg/m²/s using hydrostatic balance, with the conversion factor 100/g, before being stored in the output diagnostic arrays.

For example, in zm_conv_intr.F90:
! Store upward and downward mass fluxes in un-gathered arrays + convert from mb/s to kg/m^2/s
do i = 1,lengath
do k = 1,pver
mu_out(ideep(i),k) = mu(i,k) * 100.0_r8/gravit
md_out(ideep(i),k) = md(i,k) * 100.0_r8/gravit
end do
end do

However, I couldn't find an equivalent unit conversion in the current C++ implementation. In eamxx_zm_process_interface.cpp, zm_mflx_up is registered with units of kg/m²/s, but the output appears to be copied directly from the internal mflx_up array, which is documented as mb/s. @whannah1 Could you double-check this?

@odiazib
odiazib marked this pull request as ready for review October 29, 2026 16:29
@odiazib odiazib changed the title EAMxx: MAM4xx+ZM EAMxx: MAM4xx+ZM [DRAFT] Oct 29, 2026
@odiazib

odiazib commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

I am marking this PR as ready for review so the tests can run on CI.

@odiazib odiazib added BFB PR leaves answers BFB EAMxx C++ based E3SM atmosphere model (aka SCREAM) MAM4xx MAM4xx related changes labels Oct 29, 2026
rliq(i) = 0;
dsubcld(i) = 0;
jctop(i) = pver - 1;
jctop(i) = -1;

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.

@overfelt I will revert this change.

This branch has not been deployed

No deployments
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) MAM4xx MAM4xx related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants