-
Notifications
You must be signed in to change notification settings - Fork 2
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
Acquire ownership of data returned by compute! #88
Conversation
Prior to this version, `ClimaDiagnostics` would directly store use the output returned by `compute!` functions the first time they are called. This leads to problems when the output is a reference to an existing object since multiple diagnostics would modify the same object. Now, `ClimaDiagnostics` makes a copy of the return object so that it is no longer necessary to do so in the `compute!` function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I think that this is more along the lines of how the functional version will look, too, if/when we change over to using LazyBroadcast.jl.
Yes, I agree, and I don't know why I didn't think about this earlier |
The radiation diagnostics were returning references to objects, leading to conflicts when multiple diagnostics were added at the same time. This commit ensures that all the radiation diagnostics return a new object. CliMA/ClimaDiagnostics.jl#88 fixes the problem direclty in ClimaDiagnostics, but I think it is still worth fixing in atmos, too, so that we can be compatible with previous versions of ClimaDiagnostics and more uniform with what we are doing with all the other diagnostics
The radiation diagnostics were returning references to objects, leading to conflicts when multiple diagnostics were added at the same time. This commit ensures that all the radiation diagnostics return a new object. CliMA/ClimaDiagnostics.jl#88 fixes the problem direclty in ClimaDiagnostics, but I think it is still worth fixing in atmos, too, so that we can be compatible with previous versions of ClimaDiagnostics and more uniform with what we are doing with all the other diagnostics
This was kind of my related concern with the deepcopy (I forget which repo/PR it was from). |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #88 +/- ##
=======================================
Coverage 85.19% 85.19%
=======================================
Files 13 13
Lines 520 520
=======================================
Hits 443 443
Misses 77 77 ☔ View full report in Codecov by Sentry. |
Prior to this version,
ClimaDiagnostics
would directly store use the output returned bycompute!
functions the first time they are called. This leads to problems when the output is a reference to an existing object since multiple diagnostics would modify the same object. Now,ClimaDiagnostics
makes a copy of the return object so that it is no longer necessary to do so in thecompute!
function.Fixes problem found by @szy21 with radiation