-
Notifications
You must be signed in to change notification settings - Fork 64
Add constituent tendency capability #584
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
Changes from all commits
1ee7a16
922a4dd
44179da
a6f8dd3
0dbc881
1387cf2
dc3f3f3
fb08863
a7eb174
1f7387d
d49fcfa
07e6a1b
17db5c0
69186d1
cd2452f
e070589
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -857,7 +857,7 @@ class VarCompatObj: | |
def __init__(self, var1_stdname, var1_type, var1_kind, var1_units, | ||
var1_dims, var1_lname, var1_top, var2_stdname, var2_type, var2_kind, | ||
var2_units, var2_dims, var2_lname, var2_top, run_env, v1_context=None, | ||
v2_context=None): | ||
v2_context=None, is_tend=False): | ||
"""Initialize this object with information on the equivalence and/or | ||
conformability of two variables. | ||
variable 1 is described by <var1_stdname>, <var1_type>, <var1_kind>, | ||
|
@@ -866,6 +866,8 @@ def __init__(self, var1_stdname, var1_type, var1_kind, var1_units, | |
<var2_units>, <var2_dims>, <var2_lname>, <var2_top>, and <v2_context>. | ||
<run_env> is the CCPPFrameworkEnv object used here to verify kind | ||
equivalence or to produce kind transformations. | ||
<is_tend> is a flag where, if true, we are validating a tendency variable (var1) | ||
against it's equivalent state variable (var2) | ||
""" | ||
self.__equiv = True # No transformation required | ||
self.__compat = True # Callable with transformation | ||
|
@@ -881,7 +883,13 @@ def __init__(self, var1_stdname, var1_type, var1_kind, var1_units, | |
self.has_vert_transforms = False | ||
incompat_reason = list() | ||
# First, check for fatal incompatibilities | ||
if var1_stdname != var2_stdname: | ||
# If it's a tendency variable, the standard name should be of the | ||
# form "tendency_of_var2_stdname" | ||
if is_tend and not var1_stdname.startswith('tendency_of'): | ||
self.__equiv = False | ||
self.__compat = False | ||
incompat_reason.append('not a tendency variable') | ||
if not is_tend and var1_stdname != var2_stdname: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we add a check that starts with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good call! as it's currently used, it's only called when a variable starts with "tendency_of" but I added the check to prevent future (by me) implementation issues! |
||
self.__equiv = False | ||
self.__compat = False | ||
incompat_reason.append("standard names") | ||
|
@@ -944,7 +952,20 @@ def __init__(self, var1_stdname, var1_type, var1_kind, var1_units, | |
var2_units = 'none' | ||
# end if | ||
# Check units argument | ||
if var1_units != var2_units: | ||
if is_tend: | ||
# A tendency variable's units should be "<var2_units> s-1" | ||
tendency_split_units = var1_units.split('s-1')[0].strip() | ||
if tendency_split_units != var2_units: | ||
# We don't currently support unit conversions for tendency variables | ||
emsg = f"\nMismatch tendency variable units '{var1_units}'" | ||
emsg += f" for variable '{var1_stdname}'." | ||
emsg += " No variable transforms supported for tendencies." | ||
emsg += f" Tendency units should be '{var2_units} s-1' to match state variable." | ||
self.__equiv = False | ||
self.__compat = False | ||
incompat_reason.append(emsg) | ||
# end if | ||
elif var1_units != var2_units: | ||
self.__equiv = False | ||
# Try to find a set of unit conversions | ||
self.__unit_transforms = self._get_unit_convstrs(var1_units, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
module apply_constituent_tendencies | ||
|
||
use ccpp_kinds, only: kind_phys | ||
|
||
implicit none | ||
private | ||
|
||
public :: apply_constituent_tendencies_run | ||
|
||
CONTAINS | ||
|
||
!> \section arg_table_apply_constituent_tendencies_run Argument Table | ||
!!! \htmlinclude apply_constituent_tendencies_run.html | ||
subroutine apply_constituent_tendencies_run(const_tend, const, errcode, errmsg) | ||
! Dummy arguments | ||
real(kind_phys), intent(inout) :: const_tend(:,:,:) ! constituent tendency array | ||
real(kind_phys), intent(inout) :: const(:,:,:) ! constituent state array | ||
integer, intent(out) :: errcode | ||
character(len=512), intent(out) :: errmsg | ||
|
||
! Local variables | ||
integer :: klev, jcnst, icol | ||
|
||
errcode = 0 | ||
errmsg = '' | ||
|
||
do icol = 1, size(const_tend, 1) | ||
do klev = 1, size(const_tend, 2) | ||
do jcnst = 1, size(const_tend, 3) | ||
const(icol, klev, jcnst) = const(icol, klev, jcnst) + const_tend(icol, klev, jcnst) | ||
end do | ||
end do | ||
end do | ||
|
||
const_tend = 0._kind_phys | ||
|
||
end subroutine apply_constituent_tendencies_run | ||
|
||
end module apply_constituent_tendencies |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
##################################################################### | ||
[ccpp-table-properties] | ||
name = apply_constituent_tendencies | ||
type = scheme | ||
[ccpp-arg-table] | ||
name = apply_constituent_tendencies_run | ||
type = scheme | ||
[ const_tend ] | ||
standard_name = ccpp_constituent_tendencies | ||
long_name = ccpp constituent tendencies | ||
units = none | ||
type = real | kind = kind_phys | ||
dimensions = (horizontal_loop_extent, vertical_layer_dimension, number_of_ccpp_constituents) | ||
intent = inout | ||
[ const ] | ||
standard_name = ccpp_constituents | ||
long_name = ccpp constituents | ||
units = none | ||
type = real | kind = kind_phys | ||
dimensions = (horizontal_loop_extent, vertical_layer_dimension, number_of_ccpp_constituents) | ||
intent = inout | ||
[ errcode ] | ||
standard_name = ccpp_error_code | ||
long_name = Error flag for error handling in CCPP | ||
units = 1 | ||
type = integer | ||
dimensions = () | ||
intent = out | ||
[ errmsg ] | ||
standard_name = ccpp_error_message | ||
long_name = Error message for error handling in CCPP | ||
units = none | ||
type = character | kind = len=512 | ||
dimensions = () | ||
intent = out | ||
######################################################### |
Uh oh!
There was an error while loading. Please reload this page.