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

Remove usage of Fortran copy of field data, part 1 #1128

Merged
merged 7 commits into from
Jan 22, 2025

Conversation

travissluka
Copy link
Collaborator

Description

Part 1 of 3 to address

This refactors Model2GeoVaLs and Balance so that:

  • the Atlas fieldset is used on the Fortran side for accessing field data, no longer using the Fortran-only internal field%val structure
  • The sync_to_atlas() and sync_from_atlas() calls in the interface for these classes were removed, which should make these classes go faster
  • Also, I fixed the loop order in Balance, it was wrong, and there were switch statements inside the loops, eeek. Should be faster now

2 more PRs after this before we can remove the Fortran-only internal field data and free up some memory!

Testing

There are no change in any answers.

I also tested with the 1/4 deg, 1/2 deg minimization on my computer, 24 cores, there are no changes in answers and runtime for these components is faster (not much, and would be even less with more PEs, but every little bit counts)

develop branch

OOPS_STATS Name                                                :   total (ms)   count    time/call (ms)
OOPS_STATS soca::Balance::Balance                              :      2835.24       1         2835.2442
OOPS_STATS soca::Balance::multiply                             :      5452.57      12          454.3808
OOPS_STATS soca::Balance::multiplyAD                           :      4556.61      12          379.7176
OOPS_STATS soca::Model2GeoVaLs::changeVar                      :      1482.66       3          494.2216

this branch

OOPS_STATS Name                                                :   total (ms)   count    time/call (ms)
OOPS_STATS soca::Balance::Balance                              :      2231.90       1         2231.8992
OOPS_STATS soca::Balance::multiply                             :       448.99      12           37.4157
OOPS_STATS soca::Balance::multiplyAD                           :       467.96      12           38.9964
OOPS_STATS soca::Model2GeoVaLs::changeVar                      :         3.82       3            1.2744

@travissluka travissluka self-assigned this Jan 22, 2025
Copy link
Contributor

@guillaumevernieres guillaumevernieres left a comment

Choose a reason for hiding this comment

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

nice 👍

Copy link
Contributor

@shlyaeva shlyaeva 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!
a couple of unrelated naive questions for my understanding of this code in the comments below.

idx = self%geom%atlas_ij2idx(i,j)
data_m(1, idx) = data_a(1, idx)
do k = 1, tocn_a%shape(1)
data_m(1, idx) = data_m(1, idx) + &
Copy link
Contributor

Choose a reason for hiding this comment

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

Double-checking since I don't know this code (and don't feel like thinking, I guess): both in develop and here is it intended to have data_m = data_m + ...? (I see all other variables updated as data_m = data_a + ....

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, it's different here because 3D variables are combined into a 2D variable. There is an initial data_m = data_a on line 299 (2D) then the loop is a summation over 3D data putting into the 2D data_m

Copy link
Collaborator Author

@travissluka travissluka Jan 22, 2025

Choose a reason for hiding this comment

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

... in fact, when I refactored this i did have data_m = data_a + at first and couldn't figure out why it was giving completely wrong answers !

Comment on lines +390 to +393
if (associated(data_cice)) then
data_a(1, idx) = data_a(1, idx) + &
self%kct(i,j) * data_cice(1, idx)
end if
Copy link
Contributor

Choose a reason for hiding this comment

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

similar question here: intended to have data_a = data_a + ... as opposed to data_a = data_m + ...

@travissluka travissluka merged commit 697e426 into develop Jan 22, 2025
2 checks passed
@travissluka travissluka deleted the feature/rm_fortran_field_part1 branch January 22, 2025 22:34
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.

3 participants