Skip to content

Conversation

@bischtob
Copy link
Collaborator

@bischtob bischtob commented Oct 1, 2025

Ideas for an RRTMGP.jl interface. WIP.

@bischtob bischtob self-assigned this Oct 1, 2025
@bischtob bischtob added the enhancement ✨ New feature or request label Oct 1, 2025
@glwagner
Copy link
Member

glwagner commented Oct 2, 2025

Another idea is to add an extension for RRTMGP, which would avoid adding those explicit dependencies?

Copy link
Member

Choose a reason for hiding this comment

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

this probably belongs in test/ directory

Copy link
Member

Choose a reason for hiding this comment

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

we can also create a validation directory for user-like scripts that are not formal tests but just for sandboxing stuff

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. This belongs into test.

grid::RectilinearGrid;
temperature::Field,
pressure::Field,
lat::Field,
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain how we have both a grid argument as well as a lat argument (eg latitude?) In the case of any curvilinear grid, we can extract the latitudes from the grid itself so would not need an independent input. But I might be misunderstanding how this should work. I could also imagine that radiation works only with column grids (eg RectilinearGrid with (Flat, Flat, Bounded) topology)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep, we'll have to extract the latitude from the grid.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Basically, you have to supply for each column where it is located in latitude. This could be derived from the grid.

grid::RectilinearGrid;
temperature::Field,
pressure::Field,
lat::Field,
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain how we have both a grid argument as well as a lat argument (eg latitude?) In the case of any curvilinear grid, we can extract the latitudes from the grid itself so would not need an independent input. But I might be misunderstanding how this should work. I could also imagine that radiation works only with column grids (eg RectilinearGrid with (Flat, Flat, Bounded) topology)

@bischtob
Copy link
Collaborator Author

bischtob commented Oct 2, 2025

Another idea is to add an extension for RRTMGP, which would avoid adding those explicit dependencies?

Can you elaborate?

@bischtob bischtob added wip 🚧 work in progress and removed enhancement ✨ New feature or request labels Oct 2, 2025
@glwagner
Copy link
Member

glwagner commented Oct 2, 2025

Another idea is to add an extension for RRTMGP, which would avoid adding those explicit dependencies?

Can you elaborate?

an "extension" is a feature of the package manager that allows conditional code loading. There is some documentation here:

https://pkgdocs.julialang.org/dev/creating-packages/#Conditional-loading-of-code-in-packages-(Extensions)

by convention, we implement extensions in a directory ext. We usually create the extension as a module (or nested modules) with a specific name; in this case it would be BreezeRRTMGPExt.

There are several examples in Oceananigans, eg:

https://github.com/CliMA/Oceananigans.jl/tree/main/ext

For example, we have extended Oceananigans architecture/device interface to support CUDA, AMDGPU, intel oneAPI, and Metal. All of the methods / functionality necessary to use these devices is contained in corresponding extensions, eg:

https://github.com/CliMA/Oceananigans.jl/blob/main/ext/OceananigansMetalExt.jl

The extension packages become weakdeps in Project.toml, and the extension is added to a list under the heading [extensions]:

https://github.com/CliMA/Oceananigans.jl/blob/49c0a09b0e5e56b27b42780c3448297c5dd4b683/Project.toml#L57

on the user side, they will invoke RRTMGP by writing

using Breeze
using RRTMGP

# etc

in other words RRTMGP is not shipped in Breeze by default, but must be loaded / part of the user environment.

This design enforces modularity --- if we wanted to discontinue support for RRTMGP in the future, all we have to do is delete the extension. Conversely, adding support for other radiation codes is relatively simple because we have defined the interface.

"""
context_from_arch(arch)

Return a `ClimaComms` execution context compatible with the provided
Copy link
Member

Choose a reason for hiding this comment

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

what's an "execution context"?

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure. It might be the ClimaComms equivalent of what we call "architecture" in Oceananigans.

I think we should move all of this into an extension so that we don't pollute the source code with ClimaComms stuff, but this will be easy.

Copy link
Member

Choose a reason for hiding this comment

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

@bischtob do you understand the distinction between "context" and "architecture"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I believe they are equivalent, but I am not 100% certain in all cases (e.g., distributed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wip 🚧 work in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants