Skip to content

Commit 110861e

Browse files
Use default value for initial chemical species mixing ratios (#405)
Tag name (required for release branches): Originator(s): Matt Dawson Description (include the issue title, and the keyword ['closes', 'fixes', 'resolves'] followed by the issue number): This PR updates to use a newer version of `atmospheric_physics` that includes setting the `default_value` of constituent instances created for chemical species based on data in the MICM species configuration files. The updates to CAM-SIMA remove the hard-coded initial species mixing ratios for Terminator and Chapman mechanisms and instead set the initial mixing ratios for chemical species based on the `default_value` of the corresponding constituent, which allows any mechanism to be run. This is needed to demonstrate the run-time configurability of the chemical system. @nusbaume - I wasn't sure if the logic for setting default values for constituents should be restricted to chemical species or not. If it makes sense to set this value for any constituent, I can modify this PR, but would need some guidance on where in the workflow to set the default value to avoid overwriting conditions explicitly set in other parts of the code. Describe any changes made to build system: updated commits for `atmospheric_physics` and `cam-sima-chemistry-data` repos. Describe any changes made to the namelist: none List any changes to the defaults for the input datasets (e.g. boundary datasets): none List all files eliminated and why: `musica_sima_namelist.F90` - no namelist parameters are needed for musica now that CAM-SIMA is not restricted to Terminator and Chapman List all files added and what they do: none List all existing files that have been modified, and describe the changes: (Helpful git command: `git diff --name-status development...<your_branch_name>`) | File | Description | |-----------------------------------------------|-------------------------------------------------------------------------| | src/physics/utils/musica_sima_namelist.F90 | Removed use of deleted musica namelist module | | src/physics/utils/musica_ccpp_dependencies.F90| Replaced hard-coded initial mixing ratios for MICM species with constituent `default_value` | | src/control/runtime_opts.F90 | Removed call to `musica_ccpp_dependencies_readnl` | | src/control/cam_comp.F90 | Updated `set_initial_musica_concentrations` call to include properties for accessing `default_value` | | cime_config/atm_musica_config.py | Updated `CHEMISTRY_DATA_TAG` | | .gitmodules | Updated `atmospheric_physics` submodule tag | </details> If there are new failures (compared to the `test/existing-test-failures.txt` file), have them OK'd by the gatekeeper, note them here, and add them to the file. If there are baseline differences, include the test and the reason for the diff. What is the nature of the change? Roundoff? will add after tests are run derecho/intel/aux_sima: derecho/gnu/aux_sima: If this changes climate describe any run(s) done to evaluate the new climate in enough detail that it(they) could be reproduced: this should only affect chemistry CAM-SIMA date used for the baseline comparison tests if different than latest: --------- Co-authored-by: Jesse Nusbaumer <nusbaume@ucar.edu>
1 parent 93c5438 commit 110861e

File tree

9 files changed

+60
-192
lines changed

9 files changed

+60
-192
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
[submodule "ncar-physics"]
2121
path = src/physics/ncar_ccpp
2222
url = https://github.com/ESCOMP/atmospheric_physics
23-
fxtag = 2b66267fe263d9268effeaa1d47e3c03e6121d74
23+
fxtag = e92f76351e7f7703fb6d91cb5e76dcbbc6dcb3f2
2424
fxrequired = AlwaysRequired
2525
fxDONOTUSEurl = https://github.com/ESCOMP/atmospheric_physics
2626
[submodule "rrtmgp-data"]

cime_config/atm_musica_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
MUSICA_REPO_URL = "https://github.com/NCAR/musica.git"
99
MUSICA_TAG = "25fff7ae42d146bf3f83ad5ac18b3caac8701ddd"
1010
CHEMISTRY_DATA_REPO_URL = "https://github.com/NCAR/cam-sima-chemistry-data.git"
11-
CHEMISTRY_DATA_TAG = "71ed143c54b0d5d6e3e70f3d05d413fddcf8d59e"
11+
CHEMISTRY_DATA_TAG = "1ea9d1b8b04980738894d30a864f9a000daf2e5c"

cime_config/buildlib

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,15 @@ def _build_cam():
193193
f'-I{os.path.join(musica_install_path, "include", "musica", "fortran")} '
194194
'"'
195195
)
196+
else:
197+
# If MUSICA scheme is not used, then copy over MUSICA
198+
# source code file into a build directory, as it is needed
199+
# by the temporary "musica_ccpp_dependencies.F90"
200+
# CAM-SIMA file:
201+
musica_species_src_path = os.path.join(atm_root, "src", "physics", "ncar_ccpp",
202+
"schemes", "musica", "util",
203+
"musica_ccpp_species.F90")
204+
_copy2_as_needed(musica_species_src_path, phys_dirs[0])
196205

197206
retcode, out, err = run_cmd(cmd)
198207
_LOGGER.info("Command %s:\n\nstdout:\n%s\n\nstderr:\n%s\n", cmd, out, err)
@@ -335,7 +344,7 @@ def _build_musica(clone_dest: str) -> str:
335344
cmake_build_type = "Debug"
336345
else:
337346
cmake_build_type = "Release"
338-
347+
339348
command = [
340349
"cmake",
341350
f"-D CMAKE_INSTALL_PREFIX={install_dir}",

cime_config/namelist_definition_cam.xml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -364,23 +364,6 @@
364364
</values>
365365
</entry>
366366

367-
<!-- Host model chemistry settings -->
368-
369-
<entry id="musica_config">
370-
<type>char*256</type>
371-
<category>chemistry</category>
372-
<group>chemistry_nl</group>
373-
<desc>
374-
Configuration option for the
375-
MUSICA chemistry package.
376-
377-
Default: none
378-
</desc>
379-
<values>
380-
<value>none</value>
381-
</values>
382-
</entry>
383-
384367
<!-- Tropopause -->
385368
<entry id="tropopause_climo_file">
386369
<type>char*256</type>

src/control/cam_comp.F90

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -290,15 +290,18 @@ subroutine cam_timestep_init()
290290
!
291291
!-----------------------------------------------------------------------
292292

293-
use phys_comp, only: phys_timestep_init
294-
use physics_grid, only: lat_rad, lon_rad
295-
use orbital_data, only: orbital_data_advance
296-
use stepon, only: stepon_timestep_init
297-
use cam_ccpp_cap, only: cam_constituents_array
298-
use ccpp_kinds, only: kind_phys
299-
use musica_ccpp_dependencies, only: set_initial_musica_concentrations
293+
use phys_comp, only: phys_timestep_init
294+
use physics_grid, only: lat_rad, lon_rad
295+
use orbital_data, only: orbital_data_advance
296+
use stepon, only: stepon_timestep_init
297+
use cam_ccpp_cap, only: cam_constituents_array
298+
use cam_ccpp_cap, only: cam_model_const_properties
299+
use ccpp_constituent_prop_mod, only: ccpp_constituent_prop_ptr_t
300+
use ccpp_kinds, only: kind_phys
301+
use musica_ccpp_dependencies, only: set_initial_musica_concentrations
300302

301303
real(kind_phys), pointer :: constituents_array(:,:,:)
304+
type(ccpp_constituent_prop_ptr_t), pointer :: constituent_properties(:)
302305

303306
! Update current fractional calendar day. Needs to be updated at every timestep.
304307
calday = get_curr_calday()
@@ -331,7 +334,9 @@ subroutine cam_timestep_init()
331334
!----------------------------------------------------------
332335
if (is_first_timestep) then
333336
constituents_array => cam_constituents_array()
334-
call set_initial_musica_concentrations(constituents_array)
337+
constituent_properties => cam_model_const_properties()
338+
call set_initial_musica_concentrations(constituents_array, &
339+
constituent_properties)
335340
end if
336341

337342
!

src/control/runtime_opts.F90

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ subroutine read_namelist(nlfilename, single_column, scmlat, scmlon)
4545
use inic_analytic_utils, only: analytic_ic_readnl
4646

4747
use tropopause_climo_read, only: tropopause_climo_readnl
48-
use musica_sima_namelist, only: musica_ccpp_dependencies_readnl
4948

5049
! use tracers, only: tracers_readnl
5150
! use nudging, only: nudging_readnl
@@ -103,7 +102,6 @@ subroutine read_namelist(nlfilename, single_column, scmlat, scmlon)
103102
! call check_energy_readnl(nlfilename)
104103
call analytic_ic_readnl(nlfilename)
105104
call tropopause_climo_readnl(nlfilename)
106-
call musica_ccpp_dependencies_readnl(nlfilename)
107105
! call scam_readnl(nlfilename, single_column, scmlat, scmlon)
108106
! call nudging_readnl(nlfilename)
109107

src/physics/ncar_ccpp

Submodule ncar_ccpp updated 36 files

src/physics/utils/musica_ccpp_dependencies.F90

Lines changed: 34 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ module musica_ccpp_dependencies
4747
!> Indicator of whether MUSICA suite is being used
4848
logical :: is_musica_suite = .false.
4949

50-
!> Set of species for the current MUSICA configuration
51-
type(species_t), allocatable :: musica_species(:)
50+
!> Set of species for TUV-x
51+
type(species_t), allocatable :: tuvx_species(:)
5252

5353
!==============================================================================
5454
contains
@@ -84,20 +84,13 @@ subroutine initialize_musica_species_constituents(constituents_properties, &
8484
use ccpp_const_utils, only: ccpp_const_get_idx
8585
use cam_logfile, only: iulog
8686
use spmd_utils, only: primary_process => masterproc
87-
use musica_sima_namelist, only: musica_config_str
8887

8988
type(ccpp_constituent_prop_ptr_t), pointer :: constituents_properties(:)
9089
character(len=512), intent(out) :: errmsg
9190
integer, intent(out) :: errcode
9291

9392
! local variables
94-
character(len=*), parameter :: chapman_config = 'chapman'
95-
character(len=*), parameter :: terminator_config = 'terminator'
96-
logical :: is_chapman = .false.
97-
logical :: is_terminator = .false.
98-
integer :: num_micm_species = 0
99-
integer :: num_tuvx_constituents = 1
100-
integer :: num_tuvx_only_gas_species = 0
93+
integer, parameter :: num_tuvx_constituents = 4
10194
integer :: position
10295
integer :: constituent_index
10396
integer :: i_species
@@ -108,67 +101,28 @@ subroutine initialize_musica_species_constituents(constituents_properties, &
108101
return
109102
end if
110103

111-
! Currently, we only support two types of MUSICA configurations: Chapman and Terminator,
112-
! until the file I/O object is implemented. If the configuration is neither of these,
113-
! an error will be thrown.
114-
if (trim(musica_config_str) == "chapman") then
115-
is_chapman = .true.
116-
if (primary_process) then
117-
write(iulog,*) "[MUSICA Info] Using the Chapman configuration with stubbed dependencies."
118-
end if
119-
else if (trim(musica_config_str) == "terminator") then
120-
is_terminator = .true.
121-
if (primary_process) then
122-
write(iulog,*) "[MUSICA Info] Using the Terminator configuration with stubbed dependencies."
123-
end if
124-
else
125-
errcode = 1
126-
errmsg = "[MUSICA Error] MUSICA configuration is not found."
127-
return
128-
end if
129-
130-
if (is_chapman) then
131-
num_micm_species = 5
132-
num_tuvx_only_gas_species = 1
133-
else if (is_terminator) then
134-
num_micm_species = 2
135-
num_tuvx_only_gas_species = 3
136-
end if
137-
138-
allocate (musica_species(num_micm_species + num_tuvx_constituents + num_tuvx_only_gas_species), &
139-
stat=errcode, errmsg=errmsg)
104+
allocate (tuvx_species(num_tuvx_constituents), stat=errcode, errmsg=errmsg)
140105
if (errcode /= 0) return
141106

142-
musica_species(1) = species_t(&
107+
tuvx_species(1) = species_t(&
143108
"cloud_liquid_water_mixing_ratio_wrt_moist_air_and_condensed_water", 0.0000060_kind_phys)
144-
145-
if (is_chapman) then
146-
musica_species(2) = species_t("O2", 0.22474_kind_phys)
147-
musica_species(3) = species_t("O", 5.3509e-10_kind_phys)
148-
musica_species(4) = species_t("O1D", 5.3509e-10_kind_phys)
149-
musica_species(5) = species_t("O3", 0.00016_kind_phys)
150-
musica_species(6) = species_t("N2", 0.74015_kind_phys)
151-
musica_species(7) = species_t("air", 1.0_kind_phys)
152-
153-
else if (is_terminator) then
154-
musica_species(2) = species_t("Cl", 1.0e-12_kind_phys)
155-
musica_species(3) = species_t("Cl2", 1.0e-12_kind_phys)
156-
musica_species(4) = species_t("air", 1.0_kind_phys)
157-
musica_species(5) = species_t("O2", 0.21_kind_phys)
158-
musica_species(6) = species_t("O3", 4.0e-6_kind_phys)
159-
end if
160-
161-
do i_species = 1, num_micm_species + num_tuvx_constituents + num_tuvx_only_gas_species
162-
call ccpp_const_get_idx(constituents_properties, trim(musica_species(i_species)%name), &
163-
musica_species(i_species)%constituent_index, errmsg, errcode)
109+
tuvx_species(2) = species_t("air", 1.0_kind_phys)
110+
tuvx_species(3) = species_t("O2", 0.21_kind_phys)
111+
tuvx_species(4) = species_t("O3", 4.0e-6_kind_phys)
112+
113+
do i_species = 1, num_tuvx_constituents
114+
call ccpp_const_get_idx(constituents_properties, trim(tuvx_species(i_species)%name), &
115+
tuvx_species(i_species)%constituent_index, errmsg, errcode)
164116
if (errcode /= 0) return
165117
end do
166118

167119
end subroutine initialize_musica_species_constituents
168120

169-
subroutine set_initial_musica_concentrations(constituents_array)
121+
subroutine set_initial_musica_concentrations(constituents_array, constituent_properties)
170122

171-
use cam_abortutils, only: endrun
123+
use cam_abortutils, only: endrun
124+
use ccpp_constituent_prop_mod, only: ccpp_constituent_prop_ptr_t
125+
use musica_ccpp_species, only: micm_species_set
172126

173127
!-----------------------------------------------------------------------
174128
!
@@ -177,22 +131,35 @@ subroutine set_initial_musica_concentrations(constituents_array)
177131
!-----------------------------------------------------------------------
178132

179133
real(kind_phys), intent(inout) :: constituents_array(:,:,:)
134+
type(ccpp_constituent_prop_ptr_t), pointer, intent(inout) :: constituent_properties(:)
180135

181136
! local variables
182-
integer :: i_species
137+
integer :: i_species, i_constituent
183138
character(len=512) :: errmsg
139+
integer :: errcode
140+
real(kind_phys) :: default_value
184141

185142
! Don't do anything if MUSICA suite is not being used
186143
if (.not. is_musica_suite) return
187144

188-
if (.not. allocated(musica_species)) then
145+
if (.not. allocated(tuvx_species)) then
189146
errmsg = "[MUSICA Error] MUSICA species are not initialized."
190147
call endrun(errmsg, file=__FILE__, line=__LINE__)
191148
end if
192149

193-
do i_species = 1, size(musica_species)
194-
constituents_array(:,:,musica_species(i_species)%constituent_index) = &
195-
musica_species(i_species)%initial_mixing_ratio
150+
do i_species = 1, size(tuvx_species)
151+
constituents_array(:,:,tuvx_species(i_species)%constituent_index) = &
152+
tuvx_species(i_species)%initial_mixing_ratio
153+
end do
154+
155+
do i_species = 1, size(micm_species_set)
156+
i_constituent = micm_species_set(i_species)%index_constituent_props
157+
call constituent_properties(i_constituent)%default_value( &
158+
default_value, errcode, errmsg)
159+
if (errcode /= 0) then
160+
call endrun(errmsg, file=__FILE__, line=__LINE__)
161+
end if
162+
constituents_array(:,:,i_constituent) = default_value
196163
end do
197164

198165
end subroutine set_initial_musica_concentrations
@@ -205,7 +172,6 @@ subroutine musica_ccpp_dependencies_init( &
205172
use cam_logfile, only: iulog
206173
use spmd_utils, only: primary_process => masterproc
207174
use ccpp_constituent_prop_mod, only: ccpp_constituent_prop_ptr_t
208-
use musica_sima_namelist, only: musica_config_str
209175

210176
!-----------------------------------------------------------------------
211177
!
@@ -228,12 +194,6 @@ subroutine musica_ccpp_dependencies_init( &
228194
if (trim(phys_suite_name) /= "musica") return
229195
is_musica_suite = .true.
230196

231-
if (trim(musica_config_str) == "none") then
232-
errmsg = "[MUSICA Error] MUSICA configuration is not found. Please set musica_config to 'chapman' or 'terminator'."
233-
errcode = 1
234-
call endrun(errmsg, file=__FILE__, line=__LINE__)
235-
end if
236-
237197
if (primary_process) then
238198
write(iulog,*) 'WARNING: Using placeholder data for MUSICA chemistry.'
239199
end if

src/physics/utils/musica_sima_namelist.F90

Lines changed: 0 additions & 87 deletions
This file was deleted.

0 commit comments

Comments
 (0)