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: cleanup remappers API #6908

Merged
merged 6 commits into from
Jan 20, 2025
Merged

Conversation

bartgol
Copy link
Contributor

@bartgol bartgol commented Jan 17, 2025

Remove unused interfaces and simplify API as much as possible


This has been on my TODO list for at least 3 years. After talking to @tcclevenger and deciding that an IOPRemapper may simplify the steps toward DataInterpolation integration, I decided to clean up the remappers interface. The main goal was to get rid of the idea that fields can be registered before being allocated. This was needed YEARS ago, when we were trying to handle the remap back/fort to/from the reference grid (the physics grid) directly from the AtmosphereProcess base class. We soon abandoned that idea, but never retracted the remapper interface, making the class overly complicated for NO reason.

A more detailed list of changes:

  • Do not allow registration of fields via identifier only
  • Remove distinction between registration and binding phase
  • Moved some common implementations in the base class
  • Provide empty impl for do_XYZ methods in base class
  • Removed DoNothingRemapper (unused and pointless)
  • Remove remap(bool) method in favor of remap_fwd/remap_bwd
  • Renamed all the do_XYZ protected method as XYZ_impl. I figured since that's what we do in the atm procs classes, one naming style was less confusing.
  • Removed do_registration_begin and do_register_field: derived class specific stuff is done all in registration_ends_impl

@bartgol bartgol added BFB PR leaves answers BFB EAMxx PRs focused on capabilities for EAMxx code cleanup labels Jan 17, 2025
@bartgol bartgol self-assigned this Jan 17, 2025
@bartgol bartgol force-pushed the bartgol/eamxx/remappers-api-cleanup branch from f3b5870 to 8e87eac Compare January 17, 2025 00:32
* Do not allow registration of fields via identifier only
* Remove distinction between registration and binding phase
* Moved some common implementations in the base class
* Provide empty impl for do_XYZ methods in base class
* Removed DoNothingRemapper (unused and pointless)
* Remove remap(bool) method in favor of remap_fwd/remap_bwd
@bartgol bartgol force-pushed the bartgol/eamxx/remappers-api-cleanup branch from 8e87eac to 5fc1d5d Compare January 17, 2025 00:39
* Renamed do_XYZ into XYZ_impl (similar to other classes)
* Removed impl method for register_field and registration_begin.
  Derived class peculiar work is done when ALL fields are registered
@bartgol bartgol force-pushed the bartgol/eamxx/remappers-api-cleanup branch from fd19645 to 92df1fb Compare January 17, 2025 19:19
@bartgol
Copy link
Contributor Author

bartgol commented Jan 17, 2025

@AaronDonahue @tcclevenger tests pass. Youi can review whenever you have time.

Copy link
Contributor

@tcclevenger tcclevenger left a comment

Choose a reason for hiding this comment

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

Excellent -Red to +Green ratio.

Comment on lines +122 to +130
P3Data::Ptr Factory::create (IC ic, Int ncol, Int nlev)
{
P3Data::Ptr ret;
switch (ic) {
case mixed: ret = make_mixed(ncol, nlev); break;
default:
EKAT_REQUIRE_MSG(false, "Not an IC: " << ic);
}
return ret;
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this for? I'm guessing a random warning cleanup?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, I guess I would have a slight preference for

EKAT_ERROR_MSG("Not an IC: " << ic)

but feel free to ignore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I also prever to avoid assert-like macro that hard-code false. If it's ok, I will attach the change to the next PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What is this for? I'm guessing a random warning cleanup?

This is the "fix compiler warning" commit. The error was something like "control reaches the end of a function returninng non-void". Basically the compiler did not see that there was no way to reach the end: you either returned the value or threw an exception. I still don't know why sometimes compilers give this warning.

Alas, "fixing" it was simple, so I did it.

@bartgol bartgol merged commit 63cb5bb into master Jan 20, 2025
20 checks passed
@bartgol bartgol deleted the bartgol/eamxx/remappers-api-cleanup branch January 20, 2025 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BFB PR leaves answers BFB code cleanup EAMxx PRs focused on capabilities for EAMxx
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants