Skip to content
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

Build MUSICA in CAM-SIMA #198

Merged
merged 2 commits into from
Feb 4, 2025
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
24 changes: 12 additions & 12 deletions schemes/musica/musica_ccpp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -124,22 +124,22 @@ subroutine musica_ccpp_run(time_step, temperature, pressure, dry_air_density, co
extract_subset_constituents, update_constituents

real(kind_phys), intent(in) :: time_step ! s
real(kind_phys), target, intent(in) :: temperature(:,:) ! K
real(kind_phys), target, intent(in) :: pressure(:,:) ! Pa
real(kind_phys), target, intent(in) :: dry_air_density(:,:) ! kg m-3
real(kind_phys), target, intent(in) :: temperature(:,:) ! K (column, layer)
real(kind_phys), target, intent(in) :: pressure(:,:) ! Pa (column, layer)
real(kind_phys), target, intent(in) :: dry_air_density(:,:) ! kg m-3 (column, layer)
type(ccpp_constituent_prop_ptr_t), &
intent(in) :: constituent_props(:)
real(kind_phys), target, intent(inout) :: constituents(:,:,:) ! kg kg-1
intent(in) :: constituent_props(:) ! (constituent)
real(kind_phys), target, intent(inout) :: constituents(:,:,:) ! kg kg-1 (column, layer, constituent)
real(kind_phys), intent(in) :: geopotential_height_wrt_surface_at_midpoint(:,:) ! m (column, layer)
real(kind_phys), intent(in) :: geopotential_height_wrt_surface_at_interface(:,:) ! m (column, interface)
real(kind_phys), intent(in) :: surface_geopotential(:) ! m2 s-2
real(kind_phys), intent(in) :: surface_temperature(:) ! K
real(kind_phys), intent(in) :: surface_albedo ! unitless
real(kind_phys), intent(in) :: photolysis_wavelength_grid_interfaces(:) ! nm
real(kind_phys), intent(in) :: extraterrestrial_flux(:) ! photons cm-2 s-1 nm-1
real(kind_phys), intent(in) :: surface_geopotential(:) ! m2 s-2 (column)
real(kind_phys), intent(in) :: surface_temperature(:) ! K (column)
real(kind_phys), intent(in) :: surface_albedo(:) ! fraction (column)
real(kind_phys), intent(in) :: photolysis_wavelength_grid_interfaces(:) ! nm (wavelength interface)
real(kind_phys), intent(in) :: extraterrestrial_flux(:) ! photons cm-2 s-1 nm-1 (wavelength interface)
real(kind_phys), intent(in) :: standard_gravitational_acceleration ! m s-2
real(kind_phys), intent(in) :: cloud_area_fraction(:,:) ! unitless (column, level)
real(kind_phys), intent(in) :: air_pressure_thickness(:,:) ! Pa (column, level)
real(kind_phys), intent(in) :: cloud_area_fraction(:,:) ! fraction (column, layer)
real(kind_phys), intent(in) :: air_pressure_thickness(:,:) ! Pa (column, layer)
real(kind_phys), intent(in) :: solar_zenith_angle(:) ! radians (column)
real(kind_phys), intent(in) :: earth_sun_distance ! AU
character(len=512), intent(out) :: errmsg
Expand Down
9 changes: 7 additions & 2 deletions schemes/musica/musica_ccpp.meta
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
[ccpp-table-properties]
name = musica_ccpp
type = scheme
dependencies = micm/musica_ccpp_micm.F90,micm/musica_ccpp_micm_util.F90,tuvx/musica_ccpp_tuvx.F90,tuvx/musica_ccpp_tuvx_height_grid.F90,musica_ccpp_util.F90
dependencies = musica_ccpp.F90,musica_ccpp_util.F90,musica_ccpp_species.F90
dependencies = micm/musica_ccpp_micm.F90,micm/musica_ccpp_micm_util.F90
dependencies = tuvx/musica_ccpp_tuvx_aerosol_optics.F90,tuvx/musica_ccpp_tuvx_cloud_optics.F90,tuvx/musica_ccpp_tuvx_extraterrestrial_flux.F90
dependencies = tuvx/musica_ccpp_tuvx_gas_species.F90,tuvx/musica_ccpp_tuvx_height_grid.F90,tuvx/musica_ccpp_tuvx_load_species.F90
dependencies = tuvx/musica_ccpp_tuvx_surface_albedo.F90,tuvx/musica_ccpp_tuvx_temperature.F90,tuvx/musica_ccpp_tuvx_wavelength_grid.F90
dependencies = tuvx/musica_ccpp_tuvx.F90

[ccpp-arg-table]
name = musica_ccpp_register
Expand Down Expand Up @@ -139,7 +144,7 @@
standard_name = surface_albedo_due_to_UV_and_VIS_direct
type = real | kind = kind_phys
units = fraction
dimensions = ()
dimensions = (horizontal_loop_extent)
intent = in
[ photolysis_wavelength_grid_interfaces ]
standard_name = photolysis_wavelength_grid_interfaces
Expand Down
6 changes: 3 additions & 3 deletions schemes/musica/musica_ccpp_namelist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
A configuration file for the MICM chemical solver.
</desc>
<values>
<value>UNSET_PATH</value>
<value>${CASEROOT}</value>
</values>
</entry>
<entry id="filename_of_tuvx_configuration">
Expand All @@ -112,7 +112,7 @@
A configuration file for the TUV-x photolysis rate calculator
</desc>
<values>
<value>UNSET_PATH</value>
<value>${CASEROOT}</value>
</values>
</entry>
<entry id="filename_of_tuvx_micm_mapping_configuration">
Expand All @@ -125,7 +125,7 @@
A configuration file for the mapping of TUV-x photolysis rates to MICM custom rate parameters
</desc>
<values>
<value>UNSET_PATH</value>
<value>${CASEROOT}</value>
</values>
</entry>
</entry_id_pg>
23 changes: 12 additions & 11 deletions schemes/musica/tuvx/musica_ccpp_tuvx.F90
Original file line number Diff line number Diff line change
Expand Up @@ -533,15 +533,15 @@ subroutine tuvx_run(temperature, dry_air_density, &
real(kind_phys), intent(in) :: constituents(:,:,:) ! kg kg-1 (column, layer, constituent)
real(kind_phys), intent(in) :: geopotential_height_wrt_surface_at_midpoint(:,:) ! m (column, layer)
real(kind_phys), intent(in) :: geopotential_height_wrt_surface_at_interface(:,:) ! m (column, interface)
real(kind_phys), intent(in) :: surface_geopotential(:) ! m2 s-2
real(kind_phys), intent(in) :: surface_temperature(:) ! K
real(kind_phys), intent(in) :: surface_albedo ! unitless
real(kind_phys), intent(in) :: photolysis_wavelength_grid_interfaces(:) ! nm
real(kind_phys), intent(in) :: extraterrestrial_flux(:) ! photons cm-2 s-1 nm-1
real(kind_phys), intent(in) :: surface_geopotential(:) ! m2 s-2 (column)
real(kind_phys), intent(in) :: surface_temperature(:) ! K (column)
real(kind_phys), intent(in) :: surface_albedo(:) ! fraction (column)
real(kind_phys), intent(in) :: photolysis_wavelength_grid_interfaces(:) ! nm (wavelength interface)
real(kind_phys), intent(in) :: extraterrestrial_flux(:) ! photons cm-2 s-1 nm-1 (wavelength interface)
real(kind_phys), intent(in) :: standard_gravitational_acceleration ! m s-2
real(kind_phys), intent(in) :: cloud_area_fraction(:,:) ! unitless (column, layer)
real(kind_phys), intent(in) :: cloud_area_fraction(:,:) ! fraction (column, layer)
real(kind_phys), intent(in) :: air_pressure_thickness(:,:) ! Pa (column, layer)
real(kind_phys), intent(in) :: solar_zenith_angle(:) ! radians
real(kind_phys), intent(in) :: solar_zenith_angle(:) ! radians (column)
real(kind_phys), intent(in) :: earth_sun_distance ! m
real(kind_phys), intent(inout) :: rate_parameters(:,:,:) ! various units (column, layer, reaction)
character(len=512), intent(out) :: errmsg
Expand All @@ -561,10 +561,6 @@ subroutine tuvx_run(temperature, dry_air_density, &

reciprocal_of_gravitational_acceleration = 1.0_kind_phys / standard_gravitational_acceleration

! surface albedo with respect to direct UV/visible radiation
call set_surface_albedo_values( surface_albedo_profile, surface_albedo, errmsg, errcode )
if (errcode /= 0) return

call set_extraterrestrial_flux_values( extraterrestrial_flux_profile, &
photolysis_wavelength_grid_interfaces, &
extraterrestrial_flux, errmsg, errcode )
Expand All @@ -587,6 +583,11 @@ subroutine tuvx_run(temperature, dry_air_density, &
height_deltas, errmsg, errcode )
if (errcode /= 0) return

! surface albedo with respect to direct UV/visible radiation
call set_surface_albedo_values( surface_albedo_profile, surface_albedo(i_col), &
errmsg, errcode )
if (errcode /= 0) return

call set_temperature_values( temperature_profile, temperature(i_col,:), &
surface_temperature(i_col), errmsg, errcode )
if (errcode /= 0) return
Expand Down
6 changes: 3 additions & 3 deletions schemes/musica/tuvx/musica_ccpp_tuvx_surface_albedo.F90
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ end function create_surface_albedo_profile
!> Sets TUV-x surface albedo values
!!
!! CAM uses a single value for surface albedo at all wavelengths
subroutine set_surface_albedo_values( profile, host_surface_albedo, &
subroutine set_surface_albedo_values( profile, surface_albedo, &
errmsg, errcode )
use ccpp_kinds, only: kind_phys
use musica_ccpp_util, only: has_error_occurred
use musica_tuvx_profile, only: profile_t
use musica_util, only: error_t

type(profile_t), intent(inout) :: profile
real(kind_phys), intent(in) :: host_surface_albedo ! unitless
real(kind_phys), intent(in) :: surface_albedo ! fraction
character(len=*), intent(out) :: errmsg
integer, intent(out) :: errcode

Expand All @@ -65,7 +65,7 @@ subroutine set_surface_albedo_values( profile, host_surface_albedo, &
return
end if

surface_albedo_interfaces(:) = host_surface_albedo
surface_albedo_interfaces(:) = surface_albedo

call profile%set_edge_values( surface_albedo_interfaces, error )
if ( has_error_occurred( error, errmsg, errcode ) ) return
Expand Down
12 changes: 6 additions & 6 deletions test/musica/test_musica_api.F90
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,15 @@ subroutine test_chapman()
real(kind_phys), dimension(NUM_COLUMNS,NUM_LAYERS+1) :: geopotential_height_wrt_surface_at_interface ! m
real(kind_phys), dimension(NUM_COLUMNS) :: surface_geopotential ! m2 s-2
real(kind_phys), dimension(NUM_COLUMNS) :: surface_temperature ! K
real(kind_phys) :: surface_albedo ! unitless
real(kind_phys), dimension(NUM_COLUMNS) :: surface_albedo ! fraction
integer, parameter :: num_photolysis_wavelength_grid_sections = 8 ! (count)
real(kind_phys), dimension(num_photolysis_wavelength_grid_sections+1) :: flux_data_photolysis_wavelength_interfaces ! nm
real(kind_phys), dimension(num_photolysis_wavelength_grid_sections) :: extraterrestrial_flux ! photons cm-2 s-1 nm-1
real(kind_phys) :: standard_gravitational_acceleration ! s2 m-1
real(kind_phys), dimension(NUM_COLUMNS,NUM_LAYERS) :: temperature ! K
real(kind_phys), dimension(NUM_COLUMNS,NUM_LAYERS) :: pressure ! Pa
real(kind_phys), dimension(NUM_COLUMNS,NUM_LAYERS) :: dry_air_density ! kg m-3
real(kind_phys), dimension(NUM_COLUMNS,NUM_LAYERS) :: cloud_area_fraction ! unitless
real(kind_phys), dimension(NUM_COLUMNS,NUM_LAYERS) :: cloud_area_fraction ! fraction
real(kind_phys), dimension(NUM_COLUMNS,NUM_LAYERS) :: air_pressure_thickness ! Pa
real(kind_phys), dimension(NUM_COLUMNS,NUM_LAYERS, &
NUM_SPECIES+NUM_TUVX_CONSTITUENTS+NUM_TUVX_ONLY_GAS_SPECIES) :: constituents ! kg kg-1
Expand All @@ -204,7 +204,7 @@ subroutine test_chapman()
geopotential_height_wrt_surface_at_interface(2,:) = (/ 3000.0_kind_phys, 500.0_kind_phys, -1500.0_kind_phys /)
surface_temperature = (/ 300.0_kind_phys, 300.0_kind_phys /)
surface_geopotential = (/ 100.0_kind_phys, 200.0_kind_phys /)
surface_albedo = 0.10_kind_phys
surface_albedo(:) = 0.10_kind_phys
standard_gravitational_acceleration = 10.0_kind_phys
temperature(:,1) = (/ 100._kind_phys, 200._kind_phys /)
temperature(:,2) = (/ 300._kind_phys, 400._kind_phys /)
Expand Down Expand Up @@ -411,15 +411,15 @@ subroutine test_terminator()
real(kind_phys), dimension(NUM_COLUMNS,NUM_LAYERS+1) :: geopotential_height_wrt_surface_at_interface ! m
real(kind_phys), dimension(NUM_COLUMNS) :: surface_geopotential ! m2 s-2
real(kind_phys), dimension(NUM_COLUMNS) :: surface_temperature ! K
real(kind_phys) :: surface_albedo ! unitless
real(kind_phys), dimension(NUM_COLUMNS) :: surface_albedo ! fraction
integer, parameter :: num_photolysis_wavelength_grid_sections = 8 ! (count)
real(kind_phys), dimension(num_photolysis_wavelength_grid_sections+1) :: flux_data_photolysis_wavelength_interfaces ! nm
real(kind_phys), dimension(num_photolysis_wavelength_grid_sections) :: extraterrestrial_flux ! photons cm-2 s-1 nm-1
real(kind_phys) :: standard_gravitational_acceleration ! s2 m-1
real(kind_phys), dimension(NUM_COLUMNS,NUM_LAYERS) :: temperature ! K
real(kind_phys), dimension(NUM_COLUMNS,NUM_LAYERS) :: pressure ! Pa
real(kind_phys), dimension(NUM_COLUMNS,NUM_LAYERS) :: dry_air_density ! kg m-3
real(kind_phys), dimension(NUM_COLUMNS,NUM_LAYERS) :: cloud_area_fraction ! unitless
real(kind_phys), dimension(NUM_COLUMNS,NUM_LAYERS) :: cloud_area_fraction ! fraction
real(kind_phys), dimension(NUM_COLUMNS,NUM_LAYERS) :: air_pressure_thickness ! Pa
real(kind_phys), dimension(NUM_COLUMNS,NUM_LAYERS, &
NUM_SPECIES+NUM_TUVX_CONSTITUENTS+NUM_TUVX_ONLY_GAS_SPECIES) :: constituents ! kg kg-1
Expand All @@ -446,7 +446,7 @@ subroutine test_terminator()
geopotential_height_wrt_surface_at_interface(2,:) = (/ 3000.0_kind_phys, 500.0_kind_phys, -1500.0_kind_phys /)
surface_temperature = (/ 300.0_kind_phys, 300.0_kind_phys /)
surface_geopotential = (/ 100.0_kind_phys, 200.0_kind_phys /)
surface_albedo = 0.10_kind_phys
surface_albedo(:) = 0.10_kind_phys
standard_gravitational_acceleration = 10.0_kind_phys
temperature(:,1) = (/ 100._kind_phys, 200._kind_phys /)
temperature(:,2) = (/ 300._kind_phys, 400._kind_phys /)
Expand Down