Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
[submodule "ncar-physics"]
path = src/physics/ncar_ccpp
url = https://github.com/ESCOMP/atmospheric_physics
fxtag = 2b66267fe263d9268effeaa1d47e3c03e6121d74
fxtag = e92f76351e7f7703fb6d91cb5e76dcbbc6dcb3f2
fxrequired = AlwaysRequired
fxDONOTUSEurl = https://github.com/ESCOMP/atmospheric_physics
[submodule "rrtmgp-data"]
Expand Down
2 changes: 1 addition & 1 deletion cime_config/atm_musica_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
MUSICA_REPO_URL = "https://github.com/NCAR/musica.git"
MUSICA_TAG = "25fff7ae42d146bf3f83ad5ac18b3caac8701ddd"
CHEMISTRY_DATA_REPO_URL = "https://github.com/NCAR/cam-sima-chemistry-data.git"
CHEMISTRY_DATA_TAG = "71ed143c54b0d5d6e3e70f3d05d413fddcf8d59e"
CHEMISTRY_DATA_TAG = "1ea9d1b8b04980738894d30a864f9a000daf2e5c"
11 changes: 10 additions & 1 deletion cime_config/buildlib
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,15 @@ def _build_cam():
f'-I{os.path.join(musica_install_path, "include", "musica", "fortran")} '
'"'
)
else:
# If MUSICA scheme is not used, then copy over MUSICA
# source code file into a build directory, as it is needed
# by the temporary "musica_ccpp_dependencies.F90"
# CAM-SIMA file:
musica_species_src_path = os.path.join(atm_root, "src", "physics", "ncar_ccpp",
"schemes", "musica", "util",
"musica_ccpp_species.F90")
_copy2_as_needed(musica_species_src_path, phys_dirs[0])

retcode, out, err = run_cmd(cmd)
_LOGGER.info("Command %s:\n\nstdout:\n%s\n\nstderr:\n%s\n", cmd, out, err)
Expand Down Expand Up @@ -335,7 +344,7 @@ def _build_musica(clone_dest: str) -> str:
cmake_build_type = "Debug"
else:
cmake_build_type = "Release"

command = [
"cmake",
f"-D CMAKE_INSTALL_PREFIX={install_dir}",
Expand Down
17 changes: 0 additions & 17 deletions cime_config/namelist_definition_cam.xml
Original file line number Diff line number Diff line change
Expand Up @@ -364,23 +364,6 @@
</values>
</entry>

<!-- Host model chemistry settings -->

<entry id="musica_config">
<type>char*256</type>
<category>chemistry</category>
<group>chemistry_nl</group>
<desc>
Configuration option for the
MUSICA chemistry package.

Default: none
</desc>
<values>
<value>none</value>
</values>
</entry>

<!-- Tropopause -->
<entry id="tropopause_climo_file">
<type>char*256</type>
Expand Down
21 changes: 13 additions & 8 deletions src/control/cam_comp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -290,15 +290,18 @@ subroutine cam_timestep_init()
!
!-----------------------------------------------------------------------

use phys_comp, only: phys_timestep_init
use physics_grid, only: lat_rad, lon_rad
use orbital_data, only: orbital_data_advance
use stepon, only: stepon_timestep_init
use cam_ccpp_cap, only: cam_constituents_array
use ccpp_kinds, only: kind_phys
use musica_ccpp_dependencies, only: set_initial_musica_concentrations
use phys_comp, only: phys_timestep_init
use physics_grid, only: lat_rad, lon_rad
use orbital_data, only: orbital_data_advance
use stepon, only: stepon_timestep_init
use cam_ccpp_cap, only: cam_constituents_array
use cam_ccpp_cap, only: cam_model_const_properties
Comment on lines +297 to +298
Copy link
Preview

Copilot AI Jul 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] These two use cam_ccpp_cap statements import symbols from the same module. Consider merging them into a single use cam_ccpp_cap listing both cam_constituents_array and cam_model_const_properties to improve clarity.

Suggested change
use cam_ccpp_cap, only: cam_constituents_array
use cam_ccpp_cap, only: cam_model_const_properties
use cam_ccpp_cap, only: cam_constituents_array, cam_model_const_properties

Copilot uses AI. Check for mistakes.

use ccpp_constituent_prop_mod, only: ccpp_constituent_prop_ptr_t
use ccpp_kinds, only: kind_phys
use musica_ccpp_dependencies, only: set_initial_musica_concentrations

real(kind_phys), pointer :: constituents_array(:,:,:)
type(ccpp_constituent_prop_ptr_t), pointer :: constituent_properties(:)

! Update current fractional calendar day. Needs to be updated at every timestep.
calday = get_curr_calday()
Expand Down Expand Up @@ -331,7 +334,9 @@ subroutine cam_timestep_init()
!----------------------------------------------------------
if (is_first_timestep) then
constituents_array => cam_constituents_array()
call set_initial_musica_concentrations(constituents_array)
constituent_properties => cam_model_const_properties()
call set_initial_musica_concentrations(constituents_array, &
constituent_properties)
end if

!
Expand Down
2 changes: 0 additions & 2 deletions src/control/runtime_opts.F90
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ subroutine read_namelist(nlfilename, single_column, scmlat, scmlon)
use inic_analytic_utils, only: analytic_ic_readnl

use tropopause_climo_read, only: tropopause_climo_readnl
use musica_sima_namelist, only: musica_ccpp_dependencies_readnl

! use tracers, only: tracers_readnl
! use nudging, only: nudging_readnl
Expand Down Expand Up @@ -103,7 +102,6 @@ subroutine read_namelist(nlfilename, single_column, scmlat, scmlon)
! call check_energy_readnl(nlfilename)
call analytic_ic_readnl(nlfilename)
call tropopause_climo_readnl(nlfilename)
call musica_ccpp_dependencies_readnl(nlfilename)
! call scam_readnl(nlfilename, single_column, scmlat, scmlon)
! call nudging_readnl(nlfilename)

Expand Down
2 changes: 1 addition & 1 deletion src/physics/ncar_ccpp
Submodule ncar_ccpp updated 36 files
+33 −0 phys_utils/atmos_phys_rad_utils.F90
+60 −0 phys_utils/atmos_phys_string_utils.F90
+17 −1 schemes/musica/micm/musica_ccpp_micm.F90
+11 −0 schemes/rrtmgp/objects/ccpp_fluxes.F90
+8 −0 schemes/rrtmgp/objects/ccpp_fluxes.meta
+11 −0 schemes/rrtmgp/objects/ccpp_fluxes_byband.F90
+8 −0 schemes/rrtmgp/objects/ccpp_fluxes_byband.meta
+11 −0 schemes/rrtmgp/objects/ccpp_gas_concentrations.F90
+8 −0 schemes/rrtmgp/objects/ccpp_gas_concentrations.meta
+11 −0 schemes/rrtmgp/objects/ccpp_gas_optics_rrtmgp.F90
+8 −0 schemes/rrtmgp/objects/ccpp_gas_optics_rrtmgp.meta
+18 −0 schemes/rrtmgp/objects/ccpp_optical_props.F90
+16 −0 schemes/rrtmgp/objects/ccpp_optical_props.meta
+11 −0 schemes/rrtmgp/objects/ccpp_source_functions.F90
+8 −0 schemes/rrtmgp/objects/ccpp_source_functions.meta
+627 −0 schemes/rrtmgp/rrtmgp_inputs.F90
+395 −0 schemes/rrtmgp/rrtmgp_lw_cloud_optics.F90
+91 −0 schemes/rrtmgp/rrtmgp_lw_gas_optics.F90
+102 −0 schemes/rrtmgp/rrtmgp_lw_gas_optics_data.F90
+182 −0 schemes/rrtmgp/rrtmgp_lw_gas_optics_pre.F90
+251 −0 schemes/rrtmgp/rrtmgp_lw_main.F90
+194 −0 schemes/rrtmgp/rrtmgp_lw_mcica_subcol_gen.F90
+159 −0 schemes/rrtmgp/rrtmgp_post.F90
+402 −0 schemes/rrtmgp/rrtmgp_pre.F90
+66 −0 schemes/rrtmgp/utils/calculate_net_heating.F90
+98 −0 schemes/rrtmgp/utils/radiation_tools.F90
+205 −0 schemes/rrtmgp/utils/radiation_utils.F90
+62 −0 schemes/rrtmgp/utils/rrtmgp_dry_static_energy_tendency.F90
+1 −1 test/docker/Dockerfile.musica
+1 −1 test/docker/Dockerfile.musica.no_install
+9 −7 test/musica/test_musica_api.F90
+2 −0 test/unit-test/CMakeLists.txt
+2 −0 test/unit-test/tests/phys_utils/CMakeLists.txt
+41 −0 test/unit-test/tests/phys_utils/test_atmos_rad_utils.pf
+103 −0 test/unit-test/tests/phys_utils/test_atmos_string_utils.pf
+18 −18 to_be_ccppized/coords_1d.F90
108 changes: 34 additions & 74 deletions src/physics/utils/musica_ccpp_dependencies.F90
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ module musica_ccpp_dependencies
!> Indicator of whether MUSICA suite is being used
logical :: is_musica_suite = .false.

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

!==============================================================================
contains
Expand Down Expand Up @@ -84,20 +84,13 @@ subroutine initialize_musica_species_constituents(constituents_properties, &
use ccpp_const_utils, only: ccpp_const_get_idx
use cam_logfile, only: iulog
use spmd_utils, only: primary_process => masterproc
use musica_sima_namelist, only: musica_config_str

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

! local variables
character(len=*), parameter :: chapman_config = 'chapman'
character(len=*), parameter :: terminator_config = 'terminator'
logical :: is_chapman = .false.
logical :: is_terminator = .false.
integer :: num_micm_species = 0
integer :: num_tuvx_constituents = 1
integer :: num_tuvx_only_gas_species = 0
integer, parameter :: num_tuvx_constituents = 4
integer :: position
integer :: constituent_index
integer :: i_species
Expand All @@ -108,67 +101,28 @@ subroutine initialize_musica_species_constituents(constituents_properties, &
return
end if

! Currently, we only support two types of MUSICA configurations: Chapman and Terminator,
! until the file I/O object is implemented. If the configuration is neither of these,
! an error will be thrown.
if (trim(musica_config_str) == "chapman") then
is_chapman = .true.
if (primary_process) then
write(iulog,*) "[MUSICA Info] Using the Chapman configuration with stubbed dependencies."
end if
else if (trim(musica_config_str) == "terminator") then
is_terminator = .true.
if (primary_process) then
write(iulog,*) "[MUSICA Info] Using the Terminator configuration with stubbed dependencies."
end if
else
errcode = 1
errmsg = "[MUSICA Error] MUSICA configuration is not found."
return
end if

if (is_chapman) then
num_micm_species = 5
num_tuvx_only_gas_species = 1
else if (is_terminator) then
num_micm_species = 2
num_tuvx_only_gas_species = 3
end if

allocate (musica_species(num_micm_species + num_tuvx_constituents + num_tuvx_only_gas_species), &
stat=errcode, errmsg=errmsg)
allocate (tuvx_species(num_tuvx_constituents), stat=errcode, errmsg=errmsg)
if (errcode /= 0) return

musica_species(1) = species_t(&
tuvx_species(1) = species_t(&
"cloud_liquid_water_mixing_ratio_wrt_moist_air_and_condensed_water", 0.0000060_kind_phys)

if (is_chapman) then
musica_species(2) = species_t("O2", 0.22474_kind_phys)
musica_species(3) = species_t("O", 5.3509e-10_kind_phys)
musica_species(4) = species_t("O1D", 5.3509e-10_kind_phys)
musica_species(5) = species_t("O3", 0.00016_kind_phys)
musica_species(6) = species_t("N2", 0.74015_kind_phys)
musica_species(7) = species_t("air", 1.0_kind_phys)

else if (is_terminator) then
musica_species(2) = species_t("Cl", 1.0e-12_kind_phys)
musica_species(3) = species_t("Cl2", 1.0e-12_kind_phys)
musica_species(4) = species_t("air", 1.0_kind_phys)
musica_species(5) = species_t("O2", 0.21_kind_phys)
musica_species(6) = species_t("O3", 4.0e-6_kind_phys)
end if

do i_species = 1, num_micm_species + num_tuvx_constituents + num_tuvx_only_gas_species
call ccpp_const_get_idx(constituents_properties, trim(musica_species(i_species)%name), &
musica_species(i_species)%constituent_index, errmsg, errcode)
tuvx_species(2) = species_t("air", 1.0_kind_phys)
tuvx_species(3) = species_t("O2", 0.21_kind_phys)
tuvx_species(4) = species_t("O3", 4.0e-6_kind_phys)

do i_species = 1, num_tuvx_constituents
call ccpp_const_get_idx(constituents_properties, trim(tuvx_species(i_species)%name), &
tuvx_species(i_species)%constituent_index, errmsg, errcode)
if (errcode /= 0) return
end do

end subroutine initialize_musica_species_constituents

subroutine set_initial_musica_concentrations(constituents_array)
subroutine set_initial_musica_concentrations(constituents_array, constituent_properties)

use cam_abortutils, only: endrun
use cam_abortutils, only: endrun
use ccpp_constituent_prop_mod, only: ccpp_constituent_prop_ptr_t
use musica_ccpp_species, only: micm_species_set

!-----------------------------------------------------------------------
!
Expand All @@ -177,22 +131,35 @@ subroutine set_initial_musica_concentrations(constituents_array)
!-----------------------------------------------------------------------

real(kind_phys), intent(inout) :: constituents_array(:,:,:)
type(ccpp_constituent_prop_ptr_t), pointer, intent(inout) :: constituent_properties(:)

! local variables
integer :: i_species
integer :: i_species, i_constituent
character(len=512) :: errmsg
integer :: errcode
real(kind_phys) :: default_value

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

if (.not. allocated(musica_species)) then
if (.not. allocated(tuvx_species)) then
errmsg = "[MUSICA Error] MUSICA species are not initialized."
call endrun(errmsg, file=__FILE__, line=__LINE__)
end if

do i_species = 1, size(musica_species)
constituents_array(:,:,musica_species(i_species)%constituent_index) = &
musica_species(i_species)%initial_mixing_ratio
do i_species = 1, size(tuvx_species)
constituents_array(:,:,tuvx_species(i_species)%constituent_index) = &
tuvx_species(i_species)%initial_mixing_ratio
end do

do i_species = 1, size(micm_species_set)
i_constituent = micm_species_set(i_species)%index_constituent_props
call constituent_properties(i_constituent)%default_value( &
default_value, errcode, errmsg)
if (errcode /= 0) then
call endrun(errmsg, file=__FILE__, line=__LINE__)
end if
constituents_array(:,:,i_constituent) = default_value
end do

end subroutine set_initial_musica_concentrations
Expand All @@ -205,7 +172,6 @@ subroutine musica_ccpp_dependencies_init( &
use cam_logfile, only: iulog
use spmd_utils, only: primary_process => masterproc
use ccpp_constituent_prop_mod, only: ccpp_constituent_prop_ptr_t
use musica_sima_namelist, only: musica_config_str

!-----------------------------------------------------------------------
!
Expand All @@ -228,12 +194,6 @@ subroutine musica_ccpp_dependencies_init( &
if (trim(phys_suite_name) /= "musica") return
is_musica_suite = .true.

if (trim(musica_config_str) == "none") then
errmsg = "[MUSICA Error] MUSICA configuration is not found. Please set musica_config to 'chapman' or 'terminator'."
errcode = 1
call endrun(errmsg, file=__FILE__, line=__LINE__)
end if

if (primary_process) then
write(iulog,*) 'WARNING: Using placeholder data for MUSICA chemistry.'
end if
Expand Down
87 changes: 0 additions & 87 deletions src/physics/utils/musica_sima_namelist.F90

This file was deleted.