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

Refactor some max_patch_per_col and maxsoil_patches loops #2056

Merged
merged 9 commits into from
Aug 25, 2023

Conversation

slevis-lmwg
Copy link
Contributor

Description of changes

Issue #2025 shows examples of such loops that can be refactored for a clearer and more efficient code.

Specific notes

Contributors other than yourself, if any:
@glemieux @ekluzek @billsacks

CTSM Issues Fixed (include github issue #):
#2025

Are answers expected to change (and if so in what way)?
No, based on most recent testing.

Any User Interface Changes (namelist or namelist defaults changes)?
No.

Testing performed, if any:
...on the changes that I have made this far:
PASS ./create_test SMS_D_Ld3.f10_f10_mg37.I1850Clm50BgcCrop.cheyenne_intel.clm-default -c /glade/p/cgd/tss/ctsm_baselines/ctsm5.1.dev130
Cheyenne test-suite is in progress and hasn't raised any failures this far

@slevis-lmwg slevis-lmwg self-assigned this Jul 12, 2023
@slevis-lmwg slevis-lmwg added the code health improving internal code structure to make easier to maintain (sustainability) label Jul 12, 2023
@slevis-lmwg slevis-lmwg linked an issue Jul 12, 2023 that may be closed by this pull request
@slevis-lmwg slevis-lmwg requested a review from rgknox July 13, 2023 17:00
@slevis-lmwg
Copy link
Contributor Author

slevis-lmwg commented Jul 13, 2023

@rgknox I added you as reviewer, since you pointed out that you performed a similar (or the same) refactor in CNCIsoFluxMod yourself.

Test-suites:
Cheyenne OK
Izumi OK

@slevis-lmwg slevis-lmwg marked this pull request as ready for review July 13, 2023 17:53
@rgknox rgknox requested review from rgknox and removed request for rgknox July 31, 2023 18:51
@slevis-lmwg
Copy link
Contributor Author

slevis-lmwg commented Jul 31, 2023

Test-suites:
Izumi ./run_sys_tests -s aux_clm -c ctsm5.1.dev131 -g ctsm5.1.dev134 PASS

Cheyenne WAIT for compute nodes to become available

@slevis-lmwg
Copy link
Contributor Author

Since this PR is bfb, I agreed with @ekluzek that it could be merged with one of his other bfb PRs if he so decides.

@ekluzek
Copy link
Collaborator

ekluzek commented Aug 7, 2023

I tried merging this with #1959 to see how ugly the merge would be. It's ugly enough that we should wait until after #1959 comes in.

The files with merge conflicts are:

both modified:   src/biogeochem/CNCIsoFluxMod.F90
both modified:   src/biogeochem/CNDriverMod.F90
both modified:   src/biogeochem/CNPhenologyMod.F90
both modified:   src/main/clm_initializeMod.F90
both modified:   src/soilbiogeochem/SoilBiogeochemVerticalProfileMod.F90

For the last two the merges are pretty trivial. The top three have merges that aren't completely horrible, but complex enough that we should wait. Then a few that are trivial. When this does come in it might be good for a few of us to examine them closely to make sure we are adopting the best solution. Probably at least @slevis-lmwg and @rgknox. And I'd be willing to part of that as well.

So I'm leaving this as a draft, to come in later.

@slevis-lmwg
Copy link
Contributor Author

Resolved conflicts and this test passed:
SMS_D_Ld3.f10_f10_mg37.I1850Clm50BgcCrop.cheyenne_intel.clm-default
I will push to the PR and run test-suites next.

Resolved conflicts:
doc/ChangeLog
doc/ChangeSum
src/biogeochem/CNCIsoFluxMod.F90
src/biogeochem/CNDriverMod.F90
src/biogeochem/CNPhenologyMod.F90
src/soilbiogeochem/SoilBiogeochemVerticalProfileMod.F90
@slevis-lmwg
Copy link
Contributor Author

Izumi test-suite PASS

@slevis-lmwg
Copy link
Contributor Author

Updated to dev137 and running test-suites. I plan to merge this tomorrow.

@ekluzek would you like to review this PR before I merge? If so, either late this afternoon or tomorrow morning. Let me know what you think. Or would you prefer that I reach out to someone else?

@ekluzek
Copy link
Collaborator

ekluzek commented Aug 24, 2023

I think it would be good for me to look it over. I'll try to get to that tonight. I'm not sure there's anyone else. @rgknox did work on this so maybe him. But, it's too late in the day to expect that.

@slevis-lmwg
Copy link
Contributor Author

Test-suites
izumi PASS
cheyenne OK

if (pi <= col%npatches(c)) then
p = col%patchi(c) + pi - 1

if (patch%active(p)) then
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ahhh, yes this is a nice improvement, just loop over the soil patches in the filter, and remove the if statements to make sure they are active and within range.

Copy link
Collaborator

@ekluzek ekluzek left a comment

Choose a reason for hiding this comment

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

OK, this is awesome, and results in a nice cleanup of the code. Not having to send both column and patch filters down is a nice simplification. And the result looks a lot cleaner (and slightly more efficient) than how this was previously done. Glad you worked on this and bringing it in.

I have one small request in the ChangeLog.

doc/ChangeLog Outdated
Bugs fixed or introduced
------------------------
CTSM issues fixed (include CTSM Issue #):
Fixes #2025
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's helpful to give the summary of the issue fixed in the ChangeLog, since the issue isn't connected to github.

Other details
-------------
Pull Requests that document the changes (include PR ids):
https://github.com/ESCOMP/ctsm/pull/2056
Copy link
Collaborator

Choose a reason for hiding this comment

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

I usually give the one line comment for PR's, but it's OK here. That's important when several PR's are merged together. But, with one PR in a tag, there's no reason to give the description. It's also easier for a single PR in a tag to just give the number, so I'll do that in the future as well.

@slevis-lmwg slevis-lmwg merged commit 311ed6d into ESCOMP:master Aug 25, 2023
@slevis-lmwg slevis-lmwg deleted the repl_max_patch_per_col branch August 25, 2023 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code health improving internal code structure to make easier to maintain (sustainability)
Projects
Status: Done (non release/external)
Development

Successfully merging this pull request may close these issues.

Refactor loops that use max_patch_per_col?
3 participants