-
Notifications
You must be signed in to change notification settings - Fork 7
Add API to RRTMGP #575
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
Add API to RRTMGP #575
Conversation
5242056
to
88fc7c1
Compare
3fbbbee
to
7ac3cf0
Compare
7ac3cf0
to
d96735b
Compare
43aa96f
to
1d01f06
Compare
cab6563
to
fbe61d0
Compare
Warning You have reached your daily quota limit. As a reminder, free tier users are limited to 5 requests per day. Please wait up to 24 hours and I will start processing your requests again! |
fbe61d0
to
e838102
Compare
Suggestions on the following function names (and internal structure names)? I suppose the internals can be cleaned up, but it might be nice to at least solidify the user-facing part. lw_flux_up(s::RRTMGPSolver) = s.lws.flux.flux_up
lw_flux_dn(s::RRTMGPSolver) = s.lws.flux.flux_dn
lw_flux(s::RRTMGPSolver) = s.lws.flux.flux_net
clear_lw_flux_up(s::RRTMGPSolver) = s.clear_flux_lw.flux_up
clear_lw_flux_dn(s::RRTMGPSolver) = s.clear_flux_lw.flux_dn
clear_lw_flux(s::RRTMGPSolver) = s.clear_flux_lw.flux_net
sw_flux_up(s::RRTMGPSolver) = s.sws.flux.flux_up
sw_flux_dn(s::RRTMGPSolver) = s.sws.flux.flux_dn
sw_flux(s::RRTMGPSolver) = s.sws.flux.flux_net
clear_sw_flux_up(s::RRTMGPSolver) = s.clear_flux_sw.flux_up
clear_sw_flux_dn(s::RRTMGPSolver) = s.clear_flux_sw.flux_dn
clear_sw_direct_flux_dn(s::RRTMGPSolver) = s.clear_flux_sw.flux_dn_dir
clear_sw_flux(s::RRTMGPSolver) = s.clear_flux_sw.flux_net |
Maybe use lw_flux_net instead of lw_flux (and same for other net fluxes) to be more clear? |
Can @Sbozzolo also take a look at this? |
42e2c71
to
fc1b62b
Compare
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.
Could you add please add documentation?
The documentation should provide enough information/instructions so that a technically versed user can use the code without input from experts.
This is currently not possible, and there's only one (incomplete) sentence about using the code:
First, users can construct a settings object using `RRTMGPSolver`
Many docstrings are also incomplete or could be more useful. For example, where does a user learn what AllSkyRadiationWithClearSkyDiagnostics mean?
Or, it's never explained what isothermal_boundary_layer is, or this docstring has an incomplete sentence:
"""
set_cols!(data, value::Union{Number, AbstractArray})
Sets the columns in data to values in value.
If this
"""
6c65177
to
ea8b9bd
Compare
Address comments Address some comments Use correct _lookup_tables method Address comment Apply formatter Revise volume_mixing_ratio definitions Add more tests Change aero column_mass_density and radius to lookup methods Fixes GPU unit test fixes Combine doc sections Fix tests for gpu Apply suggestion
ea8b9bd
to
54f6032
Compare
I've fixed the example that you gave. |
I just wanted to point out that my comments have not been addressed and this PR was merged against my review. |
Sorry about that. I'll address the remaining pieces in a follow-up PR. I'd like to get started, in parallel, on the PR in atmos where we leverage these new pieces. |
Is there a reason |
The docs are not complete, but I'd like some early feedback before finishing documenting.
In efforts towards the RRTMGP interface refactoring, this PR adds an API to RRTMGP, which should achieve a few things:
DA, FT, nlay, ncol
-- all of which are now packed intoRRTMGPGridParams
source_func_longwave
andsource_func_shortwave
are type-unstable, and they need not be (by simply removing them and having users utilize union-splitting when constructing these source functions).One of the requirements in
RRTMGP interface refactoring
was to eliminateset_and_save!
.set_and_save!
does a few things. It:center_
orface_
set_array!
, which checks the sizes of the inputs and outputs, and assigns the view to the initial valueSome issues with this function are:
center_
,face_
)To understand the range of types of data passed to rrtmgp, I used
grep
forDA{
to find the arrays created in that are passed toset_and_save
/set_array
in RRTMGPInterface, I've found:If we generalize all of the non-
nlay
and non-ncol
values toN
, this simplifies to 8 cases:If we provide users with a mechanism to specify
nlay
and theeltype
(FT
orBool
), then this can further simplify to 6 cases:It is a bit odd that both
DA{FT}(undef,N,ncol)
andDA{FT}(undef,ncol,N)
exist, and perhaps they too should be unified--but they need not be. Also, technically,DA{FT}(undef,nlay,ncol)
andDA{FT}(undef,ncol)
are somewhat subsets ofDA{FT}(undef,N,nlay,ncol)
andDA{FT}(undef,N,ncol)
. The important point here is that we need to be able to disambiguatencol,N
and, for example,nlay,ncol
data, if we want to provide users a safe and generic way to operate on this data, and to be able to write extendable custom kernels, as proposed in CliMA/ClimaCore.jl#2233.To make this possible, this PR introduces a new array type,
RRTMGPData <: AbstractArray
, with 4 constructors:These constructors all return a
RRTMGPData
object with a subtype parameter ofAbstractIndexOrder
, of which, there are 4:NVCOrder
Index order with dimensions (N, vertical level, column).VCOrder
Index order with dimensions (vertical level, column).NCOrder
Index order with dimensions (N, column).NOrder
Index order with a single N dimension.This will allow us to eliminate
set_and_save!
like the following:Later, when ClimaAtmos needs
z_lay
, it can call:and the view can be constructed on the fly with:
This will allow us to eliminate the views that are stored in
RRTMGPModel
.Fortunately, this works out of the box, without requiring changes RRTMGP since it is mostly written with generic concrete types, like
AtmosphericState
:and these types simply assume that inputs are arrays.