-
Notifications
You must be signed in to change notification settings - Fork 23
Make ᶜspecific lazy and remove matching_subfields #3857
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
Conversation
cf2a81a
to
8edcb24
Compare
1704408
to
ceed2c9
Compare
@tapios, I tried lumping everything into the one function, but I'm getting an error: ERROR: LoadError: The function body AST defined by this @generated function is not pure. This likely means it contains a closure, a comprehension or a generator.
| Stacktrace:
| [1] macro expansion
| @ /central/scratch/esm/slurm-buildkite/climaatmos-ci/24693/climaatmos-ci/src/prognostic_equations/hyperdiffusion.jl:245 [inlined]
| Is it alright if I break this back down into smaller function calls (which worked) and only do the generated function where it's needed? Or maybe @dennisYatunin has a better idea? |
I'd like to understand what fails here. The problem is in hyperdiffusion, l. 245. Nothing here needs to change if what we use is the old I'm fine with breaking this down into smaller functions, but I'm afraid the problem is something else. @dennisYatunin can weigh in. |
Isn't the right thing to do here is using the same logic of looping over scalar names that you used several times in #3858? |
|
As I mentioned, you'd want to use a (corrected form) of |
It's not clear to me how to use for χ_name in propertynames(ᶜ∇²specific_tracers)
@. ᶜ∇²specific_tracers.:($$χ_name) = wdivₕ(gradₕ(ᶜspecific.:($$χ_name)))
end ? |
7b8c68d
to
df89531
Compare
@tapios, I've modified this PR to include the change you requested above, replacing the last use of In the process of updating the hyperdiffusion tendency, I found a bug on lines 283--298 in the current version of
This loop modifies the value of I also changed the docstring on lines 301--302 to more accurately describe what the hyperdiffusion tendency is doing. @tapios, please take a look and let me know if the new version of this comment on lines 300--302 is incorrect. |
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. Good catch on the hyperdiffusivity bug; that's important.
We should isolate the hyperviscosity/-diffusivity calculation to a function, and determine scalar diffusivity from hyperdiffusivity = hyperviscosity/Prandtl_number_hyperdiff, with the Prandtl number in the parameter file. You may consider introducing a function now, to avoid possible errors from the code duplication and inconsistent edits. We can also do it later.
df89531
to
3eb7436
Compare
3eb7436
to
0d80a61
Compare
Ok, I've moved the computation of |
Sounds good. Thanks. |
This PR extends
foreach_gs_tracer
to handle specific tracer variables (like the ones inᶜ∇²specific_tracers
), and uses it to replace the for-loop overmatching_subfields
in the hyperdiffusion tendency. It also replacesspecific_gs.(Y.c)
with the lazy functionᶜspecific_gs_tracers(Y)
, which we can use to removeᶜspecific
from the cache in a future PR. Sincematching_subfields
,specific_gs
, and some related functions are no longer needed, their definitions are removed.This PR also fixes a minor bug and updates an inaccurate code comment in the hyperdiffusion tendency for precipitating species. Details can be found in the comment below.