Skip to content

Skeleton ideas for radiation interfaces#31

Closed
bischtob wants to merge 3 commits intomainfrom
tb/rad_ideas
Closed

Skeleton ideas for radiation interfaces#31
bischtob wants to merge 3 commits intomainfrom
tb/rad_ideas

Conversation

@bischtob
Copy link
Copy Markdown
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 ✨ ideas and requests for new features label Oct 1, 2025
@glwagner
Copy link
Copy Markdown
Member

glwagner commented Oct 2, 2025

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

Comment thread test/test_rrtmgp_gray.jl
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

Comment thread src/Radiation/rrtmgp_interface.jl Outdated
grid::RectilinearGrid;
temperature::Field,
pressure::Field,
lat::Field,
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

Comment thread src/Radiation/rrtmgp_interface.jl Outdated
grid::RectilinearGrid;
temperature::Field,
pressure::Field,
lat::Field,
Copy link
Copy Markdown
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
Copy Markdown
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 ✨ ideas and requests for new features labels Oct 2, 2025
@glwagner
Copy link
Copy Markdown
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.

Comment thread src/Radiation/rrtmgp_interface.jl
@glwagner
Copy link
Copy Markdown
Member

superceded by #176

@glwagner glwagner closed this Dec 15, 2025
@giordano giordano deleted the tb/rad_ideas branch December 15, 2025 21:56
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.

3 participants