Skip to content

Commit d3dcffa

Browse files
jimmielinHaipeng Linnusbaumehplin-ucar
authored
Export CO2 value to the land model via coupler (ESCOMP#427)
Tag name (The PR title should also include the tag name): Originator(s): @jimmielin assisted-by claude-fable:5 Description (include issue title and the keyword ['closes', 'fixes', 'resolves'] and issue number): - Update the `set_surface_coupling_vars` scheme to pass the `prescribed_volume_mixing_ratio_of_co2` prescribed via `prescribe_radiative_gas_concentrations` to the coupler CAM just does this in `camsrfexch.F90` ```fortran cam_out%co2diag(:ncol) = chem_surfvals_get('CO2VMR') * 1.0e+6_r8 ``` List all namelist files that were added or changed: A schemes/utilities/set_surface_coupling_vars_namelist.xml List all files eliminated and why: List all files added and what they do: N/A List all existing files that have been modified, and describe the changes: (Helpful git command: `git diff --name-status main...<your_branch_name>`) ``` M schemes/utilities/set_surface_coupling_vars.F90 M schemes/utilities/set_surface_coupling_vars.meta - update to set co2diag, co2prog ``` List all automated tests that failed, as well as an explanation for why they weren't fixed: Is this an answer-changing PR? If so, is it a new physics package, algorithm change, tuning change, etc? If yes to the above question, describe how this code was validated with the new/modified features: --------- Co-authored-by: Haipeng Lin <hplin+github@ucar.edu> Co-authored-by: Jesse Nusbaumer <nusbaume@ucar.edu> Co-authored-by: Haipeng Lin <hplin@ucar.edu>
1 parent 9865ef6 commit d3dcffa

3 files changed

Lines changed: 151 additions & 5 deletions

File tree

schemes/utilities/set_surface_coupling_vars.F90

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
!-----------------------------------------------------------------------
22
! Module to handle data that is exchanged between the atmosphere
33
! model and the surface models (land, sea-ice, ocean, etc.).
4-
4+
!
55
! Please note that currently this is a SIMA-specific module,
66
! but could be made more host model-independent in the future.
77
!-----------------------------------------------------------------------
@@ -24,17 +24,20 @@ subroutine set_surface_coupling_vars_run(ncol, pver, ncnst, gravit, rair, phis,
2424
surf_pres, air_temp, inv_ps_exner, zm, &
2525
rho, uwnd, vwnd, air_pres, cnst_array, &
2626
prec_dp, snow_dp, prec_sh, snow_sh, &
27-
prec_str, snow_str, air_temp_bot, &
27+
prec_str, snow_str, do_diagnostic_co2, &
28+
air_temp_bot, &
2829
pot_temp_bot, zm_bot, rho_bot, &
2930
uwnd_bot, vwnd_bot, air_pres_bot, &
3031
topo_height, sea_lev_pres, cnst_bot, &
3132
conv_prec, conv_snow, strat_prec, &
32-
strat_snow, errmsg, errcode)
33+
strat_snow, co2diag, co2prog, &
34+
errmsg, errcode)
3335

3436
! Set surface variables needed for atmosphere-surface coupling.
3537

3638
! Use statements
37-
use ccpp_kinds, only: kind_phys
39+
use ccpp_kinds, only: kind_phys
40+
use ccpp_scheme_utils, only: ccpp_constituent_index
3841

3942
! Input arguments
4043
integer, intent(in) :: ncol
@@ -61,6 +64,8 @@ subroutine set_surface_coupling_vars_run(ncol, pver, ncnst, gravit, rair, phis,
6164
real(kind_phys), intent(in) :: prec_str(:) ! LWE stratiform precipitation (all phases) [m s-1]
6265
real(kind_phys), intent(in) :: snow_str(:) ! LWE stratiform frozen precipitation (e.g. snow) [m s-1]
6366

67+
logical, intent(in) :: do_diagnostic_co2 ! Export CO2 in the diagnostic (T) or prognostic (F) coupler field [flag]
68+
6469
! Output arguments
6570
real(kind_phys), intent(out) :: air_temp_bot(:) ! Air temperature at bottom of atmosphere for coupling [K]
6671
real(kind_phys), intent(out) :: pot_temp_bot(:) ! Potential air temprature at bottom of atmosphere for coupling [K]
@@ -78,14 +83,22 @@ subroutine set_surface_coupling_vars_run(ncol, pver, ncnst, gravit, rair, phis,
7883
real(kind_phys), intent(out) :: strat_prec(:) ! LWE Stratiform (large-scale) precipitation (all phases) [m s-1]
7984
real(kind_phys), intent(out) :: strat_snow(:) ! LWE Frozen stratiform (large-scale)precipitation (e.g. snow) [m s-1]
8085

86+
real(kind_phys), intent(out) :: co2diag(:) ! Diagnostic CO2 volume mixing ratio for coupler [ppmv]
87+
real(kind_phys), intent(out) :: co2prog(:) ! Prognostic CO2 volume mixing ratio for coupler [ppmv]
88+
8189
character(len=512), intent(out) :: errmsg ! CCPP error message
8290
integer, intent(out) :: errcode ! CCPP error code
8391

8492
! Local variables
85-
8693
integer :: i ! column index
8794
integer :: m ! constituent index
8895

96+
integer :: co2_idx ! CO2 constituent index
97+
98+
! Ratio of dry air molar mass to CO2 molar mass.
99+
! Duplicated from radiation_utils rather than used from there to avoid a build dependency.
100+
real(kind_phys), parameter :: dry_air_to_co2_molar_mass_ratio = 0.658114_kind_phys
101+
89102
!-----------------------------------------------------------------------
90103

91104
errmsg = ''
@@ -114,6 +127,27 @@ subroutine set_surface_coupling_vars_run(ncol, pver, ncnst, gravit, rair, phis,
114127
end do
115128
end do
116129

130+
! Export the CO2 volume mixing ratio for surface models.
131+
! do_diagnostic_co2 selects whether it is sent in the diagnostic
132+
! or prognostic coupler field (for surface model).
133+
co2diag(:) = 0._kind_phys
134+
co2prog(:) = 0._kind_phys
135+
call ccpp_constituent_index('CO2', co2_idx, errcode, errmsg)
136+
if (errcode /= 0) return
137+
138+
if (co2_idx > 0) then
139+
! Convert bottom-layer dry mass mixing ratio to ppmv expected by the coupler:
140+
if (do_diagnostic_co2) then
141+
do i = 1, ncol
142+
co2diag(i) = cnst_array(i,pver,co2_idx) * dry_air_to_co2_molar_mass_ratio * 1.0e+6_kind_phys
143+
end do
144+
else
145+
do i = 1, ncol
146+
co2prog(i) = cnst_array(i,pver,co2_idx) * dry_air_to_co2_molar_mass_ratio * 1.0e+6_kind_phys
147+
end do
148+
end if
149+
end if
150+
117151
!
118152
! Precipation and snow rates from shallow convection, deep convection and stratiform processes.
119153
! Compute total convective and stratiform precipitation and snow rates

schemes/utilities/set_surface_coupling_vars.meta

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,12 @@
136136
type = real | kind = kind_phys
137137
dimensions = (horizontal_loop_extent)
138138
intent = in
139+
[ do_diagnostic_co2 ]
140+
standard_name = do_diagnostic_co2_export_to_coupler
141+
units = flag
142+
type = logical
143+
dimensions = ()
144+
intent = in
139145

140146
#----------------
141147
#Output Arguments
@@ -225,6 +231,18 @@
225231
type = real | kind = kind_phys
226232
dimensions = (horizontal_loop_extent)
227233
intent = out
234+
[ co2diag ]
235+
standard_name = diagnostic_volume_mixing_ratio_of_co2_to_coupler
236+
units = ppmv
237+
type = real | kind = kind_phys
238+
dimensions = (horizontal_loop_extent)
239+
intent = out
240+
[ co2prog ]
241+
standard_name = prognostic_volume_mixing_ratio_of_co2_to_coupler
242+
units = ppmv
243+
type = real | kind = kind_phys
244+
dimensions = (horizontal_loop_extent)
245+
intent = out
228246
[ errmsg ]
229247
standard_name = ccpp_error_message
230248
units = none
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?xml version="1.0"?>
2+
3+
<?xml-stylesheet type="text/xsl"?>
4+
5+
<entry_id_pg version="2.0">
6+
7+
<!-- Each namelist variable is defined in an <entry> element. The
8+
content of the element is the documentation of how the variable is
9+
used. Other aspects of the variable's definition are expressed as
10+
attributes of the <entry> element. Note that it is an XML requirement
11+
that the attribute values are enclosed in quotes. The attributes are:
12+
13+
id
14+
The variable's name. *** N.B. *** The name must be lower case.
15+
The module convert all namelist variable names to lower case
16+
since Fortran is case insensitive.
17+
18+
type
19+
An abbreviation of the fortran declaration for the variable.
20+
Valid declarations are:
21+
22+
char*n
23+
integer
24+
logical
25+
real
26+
27+
Any of these types may be followed by a comma separated list of
28+
integers enclosed in parenthesis to indicate an array.
29+
30+
The current namelist validation code only distinquishes between
31+
string and non-string types.
32+
33+
input_pathname
34+
Only include this attribute to indicate that the variable
35+
contains the pathname of an input dataset that resides in the
36+
CESM inputdata directory tree. Note that the variables
37+
containing the names of restart files that are used in branch
38+
runs don't reside in the inputdata tree and should not be given
39+
this attribute.
40+
41+
The recognized values are "abs" to indicate that an absolute
42+
pathname is required, or "rel:var_name" to indicate that the
43+
pathname is relative and that the namelist variable "var_name"
44+
contains the absolute root directory.
45+
46+
category
47+
A category assigned for organizing the documentation.
48+
49+
group
50+
The namelist group that the variable is declared in.
51+
52+
valid_values
53+
This is an optional attribute that is mainly useful for variables
54+
that have only a small number of allowed values. It is a
55+
comma-separated list of valid values for the variable.
56+
57+
desc
58+
This is a text description of the variable including its
59+
purpose and use.
60+
61+
values
62+
This is a grouping of all the cases where a value can be
63+
assigned with the namelist generator has been run.
64+
65+
value
66+
Each <value> tag specifies a case where a value is assigned
67+
to this variable when the namelist generator is run. If the
68+
tag has no attributes, it is a default value. In general,
69+
the namelist generator attempts to find a value with the
70+
maximium number of attribute matches (and no non-matches).
71+
72+
standard_name
73+
This is the CCPP Standard Name of the variable
74+
75+
units
76+
This is the CCPP unit specification of the variable (e.g., m s-1).
77+
-->
78+
<entry id="do_diagnostic_co2">
79+
<type>logical</type>
80+
<category>coupling</category>
81+
<group>surface_coupling_nl</group>
82+
<standard_name>do_diagnostic_co2_export_to_coupler</standard_name>
83+
<units>flag</units>
84+
<desc>
85+
Send the atmospheric CO2 volume mixing ratio to the coupler in the
86+
diagnostic CO2 field (true) or the prognostic CO2 field (false)
87+
Default: true
88+
</desc>
89+
<values>
90+
<value>.true.</value>
91+
</values>
92+
</entry>
93+
94+
</entry_id_pg>

0 commit comments

Comments
 (0)