Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EAMxx: Adds aerosols heterogeneous freezing calculations in P3 microphysics #6947

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

singhbalwinder
Copy link
Contributor

@singhbalwinder singhbalwinder commented Jan 25, 2025

The heterogeneous freezing calculations from prognostics aerosols are
added to P3 microphysics. Setting use_hetfrz_classnuc to true
will turn on these calculations. Otherwise, P3 will use the default
prescribed aerosol calculations.

[BFB] for EAM and EAMxx

Copy link

github-actions bot commented Jan 25, 2025

PR Preview Action v1.6.0

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

Built to branch gh-pages at 2025-02-05 06:10 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@singhbalwinder
Copy link
Contributor Author

TODO:

  1. Turn off this feature for default EAMxx
  2. Revive commented-out P3 tests after adding missing arguments in various function signatures.

@singhbalwinder singhbalwinder changed the title Adds aerosols heterogeneous freezing calculations in P3 microphysics EAMxx: Adds aerosols heterogeneous freezing calculations in P3 microphysics Jan 28, 2025
@mahf708
Copy link
Contributor

mahf708 commented Jan 29, 2025

Qucik comments:

  1. Please turn off the feature by default
  2. Please follow for the do_ice_production procedure (as an example) for passing the flag inside
  3. Please hide most (if not all) additions inside if-else guards (with the new flag), for example, the add_required calls and such
  4. Please keep tests intact if you intend to integrate this
  5. Also, ensure you don't break PAM/MMF2 (I am 100% almost certain you're currently breaking it)

Copy link
Contributor

@bartgol bartgol left a comment

Choose a reason for hiding this comment

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

I have a few comments. Mostly: why are lots of unit tests now commented?

components/eamxx/cime_config/namelist_defaults_scream.xml Outdated Show resolved Hide resolved
const auto mask = qc_incld > qsmall;
switch (Iflag) {
case 1: // cloud droplet immersion freezing
ncheti_cnt.set(mask, frzimm*1.0e6/rho /* frzimm input is in [#/cm3] */ , Zero);
Copy link
Contributor

Choose a reason for hiding this comment

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

In all these "set" calls, how often do you expect the mask to be true/false? If the mask could often be ALL false (not sometimes, often), then you may consider using if statements, to avoid computing the packs for the true case for nothing (e.g., in the 1st line we have to compute frzimm*1e6/rho regardless of whether we need it or not).

Note: this nano-opt makes sense only if you expect mask to be often false. I assume that's not the case, since qsmall is very small. But I don't know how qc_incld is computed, so maybe it's often 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is a good question. I am not sure about that. @kaizhangpnl or @AaronDonahue might know if mask can often be false or not.

Copy link
Contributor

@bartgol bartgol left a comment

Choose a reason for hiding this comment

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

I have a few comments. Mostly: why are lots of unit tests now commented?

@mahf708 mahf708 requested a review from brhillman February 2, 2025 18:16
@mahf708
Copy link
Contributor

mahf708 commented Feb 2, 2025

Requesting reviews from @hassanbeydoun and @brhillman because I know they're very curious about and interested in this part of the p3 code

@singhbalwinder singhbalwinder force-pushed the jroverf/singhbalwinder/eamxx/add-het-frz-p3_rebase1_1 branch from 487f9b6 to 9be599e Compare February 3, 2025 19:25
Comment on lines +100 to +109
add_field<Required>("hetfrz_immersion_nucleation_tend", scalar3d_layout_mid,
frz_unit, grid_name, ps);

// heterogeneous freezing by contact nucleation [cm^-3 s^-1]
add_field<Required>("hetfrz_contact_nucleation_tend", scalar3d_layout_mid, frz_unit,
grid_name, ps);

// heterogeneous freezing by deposition nucleation [cm^-3 s^-1]
add_field<Required>("hetfrz_deposition_nucleation_tend", scalar3d_layout_mid,
frz_unit, grid_name, ps);
Copy link
Contributor

Choose a reason for hiding this comment

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

@singhbalwinder this is the last potential important comment, otherwise, I think the PR is mergeable:

What happens if MAM is inactive? What happens to these variables? Maybe we should make these hidden behind if-else? IF so, make sure to do the same below (around 333):

  // Inputs for the heteogeneous freezing
  diag_inputs.hetfrz_immersion_nucleation_tend  = get_field_in("hetfrz_immersion_nucleation_tend").get_view<const Pack**>();
  diag_inputs.hetfrz_contact_nucleation_tend    = get_field_in("hetfrz_contact_nucleation_tend").get_view<const Pack**>();
  diag_inputs.hetfrz_deposition_nucleation_tend = get_field_in("hetfrz_deposition_nucleation_tend").get_view<const Pack**>();

where in the unused/uneeded case, you can use the buffer.unused or something like that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When MAM is inactive, values for these variables will be picked up from the namelist and will stay the same for the entire simulation. The simulation will run as usual with no impact from these variables.

I can hide it behind an if/else if it is not the desired behavior. Is there a way for P3 to know if MAM4 is active or not? Previously, when I discussed this, the design principle did not allow this, as each parameterization should be able to run independently without the knowledge of other parameterizations/processes. Otherwise, it makes the logic complex (e.g., to decide if different combinations of processes are valid or not). If it has changed, please let me know, and I will add if/else blocks.

Copy link
Contributor

@mahf708 mahf708 Feb 3, 2025

Choose a reason for hiding this comment

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

If they are defined, then there's no need to worry (I wasn't aware they would be defined; this is a little surprising to me tbh)

For hiding them, I would use the boolean you're adding here (hetfrz). It doesn't matter though, whether these statements are hidden or not, won't make a difference as far as I could tell. I was worried a CIME case would error out if these variables are here, but MAM is inactive. I guess we will pick this up in testing soon enough :)

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I would hide these behind the boolean you introduced in this PR. For the other branch of the if, set the buffer.unused or any other dummy values

@singhbalwinder singhbalwinder marked this pull request as ready for review February 5, 2025 20:57
@singhbalwinder
Copy link
Contributor Author

@mahf708 and @bartgol : I have now addressed all the review comments. Please let me know if there is anything still missing. The P3 tests passed on Compy. I will try running the tests on PM-GPUs.

Copy link
Contributor

@mahf708 mahf708 left a comment

Choose a reason for hiding this comment

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

Looks good to me. If the tests pass, I support merging.

For the record, I will note that Balwinder, Luca, and I all agree we likely need to restructure the P3 code at some point in the future. This is outside the scope of the current PR, and we will think about finding the time to do it at a later point.

@mahf708
Copy link
Contributor

mahf708 commented Feb 5, 2025

One of the public CI tests failed with (which I think is related to my comment here #6947 (comment))

 FAIL:
!m_add_time_dim
/__w/E3SM/E3SM/components/eamxx/src/share/io/scorpio_output.cpp:477
Error! Time-dependent output field 'hetfrz_contact_nucleation_tend' has not been initialized yet
.

 FAIL:
!m_add_time_dim
/__w/E3SM/E3SM/components/eamxx/src/share/io/scorpio_output.cpp:477
Error! Time-dependent output field 'hetfrz_contact_nucleation_tend' has not been initialized yet
.

 FAIL:
!m_add_time_dim
/__w/E3SM/E3SM/components/eamxx/src/share/io/scorpio_output.cpp:477
Error! Time-dependent output field 'hetfrz_contact_nucleation_tend' has not been initialized yet
.

 FAIL:
!m_add_time_dim
/__w/E3SM/E3SM/components/eamxx/src/share/io/scorpio_output.cpp:477
Error! Time-dependent output field 'hetfrz_contact_nucleation_tend' has not been initialized yet
.

to reproduce locally, this is the test:

ERS_Ld5_P4.ne4pg2_oQU480.F2010-SCREAMv1-MPASSI.<MACHINE>_<COMPILER>.eamxx-prod

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.

4 participants