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

Add calculation of solar zenith angle and Earth–Sun distance #337

Merged
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
6b6262c
and orbital data module
mattldawson Dec 10, 2024
6a78028
draft updates to call orbital data functions during simulation
mattldawson Dec 10, 2024
85507a5
update musica dependency modules
mattldawson Dec 13, 2024
64972ba
update MUSICA dependencies
mattldawson Dec 13, 2024
c5b59b2
merge development into develop-328-orbital-properties
peverwhee Dec 10, 2024
1503ca4
Sort `use` statements and adjust indentation
kuanchihwang Sep 11, 2024
0374d8d
Implement MPAS subdriver
kuanchihwang Jun 24, 2024
01af24b
Support for computing edge wind tendency in MPAS subdriver
kuanchihwang Sep 10, 2024
7a06bcb
Implement `dyn_run`
kuanchihwang Jul 30, 2024
eb3792f
Wire up `dyn_run`
kuanchihwang Jul 30, 2024
22c26d5
Sort `use` statements and add comments
kuanchihwang Sep 27, 2024
3c4faa5
Factor out variable finalization
kuanchihwang Aug 9, 2024
0e3a2d1
Implement `reverse`
kuanchihwang Aug 5, 2024
7e34e0c
Refactor assignments between CAM-SIMA and MPAS in terms of `reverse`
kuanchihwang Aug 5, 2024
eb81389
Implement `dyn_exchange_constituent_state`
kuanchihwang Aug 9, 2024
d6fc775
Switch to use `dyn_exchange_constituent_state`
kuanchihwang Aug 9, 2024
9b81368
Implement dynamics-physics coupling and vice versa
kuanchihwang Jul 22, 2024
c6d65bd
Wire up dynamics-physics coupling
kuanchihwang Jul 30, 2024
ffded6e
Add more detailed comments about an MPAS subroutine
kuanchihwang Nov 4, 2024
f58a958
Fix grammar in comments
kuanchihwang Nov 4, 2024
4f1fe50
Only call `reverse` once per cell when performing conversion
kuanchihwang Nov 4, 2024
4de2299
Pass arguments by keywords for better clarity
kuanchihwang Nov 4, 2024
cf1e015
Rename internal subroutines
kuanchihwang Nov 4, 2024
19ff182
Include error codes and messages returned by external procedures
kuanchihwang Nov 4, 2024
ac8fbe0
Just use equation of state
kuanchihwang Nov 4, 2024
0a7d866
Do not assume no water at top of model
kuanchihwang Nov 4, 2024
47c41ba
Add more detailed comments about equation derivation
kuanchihwang Nov 4, 2024
1472273
add function argument
mattldawson Dec 13, 2024
3c153f5
merge development into develop-328-optical-properties
mattldawson Dec 13, 2024
1ceba5a
update dockerfile
mattldawson Dec 13, 2024
b473122
use photons in units
mattldawson Dec 13, 2024
afee2af
address reviewer comments
mattldawson Dec 16, 2024
253a5eb
address reviewer comments
mattldawson Dec 16, 2024
da5891c
update atmopsheric physics
mattldawson Dec 17, 2024
252cdb1
Merge branch 'development' into develop-328-orbital-properties
mattldawson Dec 23, 2024
404e8e4
update atmos phys commit and change radians to rad
mattldawson Dec 23, 2024
be4ee44
ignore vscode files
mattldawson Dec 31, 2024
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
59 changes: 38 additions & 21 deletions src/control/cam_comp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -83,25 +83,27 @@ subroutine cam_init(caseid, ctitle, model_doi_url, &
!
!-----------------------------------------------------------------------

use cam_initfiles, only: cam_initfiles_open
use dyn_grid, only: model_grid_init
use phys_comp, only: phys_init
use phys_comp, only: phys_register
use dyn_comp, only: dyn_init
! use cam_restart, only: cam_read_restart
use camsrfexch, only: hub2atm_alloc, atm2hub_alloc
use cam_history, only: history_init_files
! use history_scam, only: scm_intht
use cam_pio_utils, only: init_pio_subsystem
use cam_instance, only: inst_suffix
! use history_defaults, only: initialize_iop_history
use stepon, only: stepon_init
use air_composition, only: air_composition_init
use cam_ccpp_cap, only: cam_ccpp_initialize_constituents
use physics_grid, only: columns_on_task
use vert_coord, only: pver
use phys_vars_init_check, only: mark_as_initialized
use tropopause_climo_read, only: tropopause_climo_read_file
use cam_initfiles, only: cam_initfiles_open
use dyn_grid, only: model_grid_init
use phys_comp, only: phys_init
use phys_comp, only: phys_register
use dyn_comp, only: dyn_init
! use cam_restart, only: cam_read_restart
use camsrfexch, only: hub2atm_alloc, atm2hub_alloc
use cam_history, only: history_init_files
! use history_scam, only: scm_intht
use cam_pio_utils, only: init_pio_subsystem
use cam_instance, only: inst_suffix
! use history_defaults, only: initialize_iop_history
use stepon, only: stepon_init
use air_composition, only: air_composition_init
use cam_ccpp_cap, only: cam_ccpp_initialize_constituents
use physics_grid, only: columns_on_task
use vert_coord, only: pver
use phys_vars_init_check, only: mark_as_initialized
use tropopause_climo_read, only: tropopause_climo_read_file
use musica_ccpp_dependencies, only: musica_ccpp_dependencies_init
use orbital_data, only: orbital_data_init

! Arguments
character(len=cl), intent(in) :: caseid ! case ID
Expand Down Expand Up @@ -253,6 +255,16 @@ subroutine cam_init(caseid, ctitle, model_doi_url, &
! end if
call history_init_files(model_doi_url, caseid, ctitle)

! Temporary: Prescribe realistic but inaccurate physical quantities
! necessary for MUSICA that are currently unavailable in CAM-SIMA.
!
! Remove this when MUSICA input data are available from CAM-SIMA or
! other physics schemes.
call musica_ccpp_dependencies_init(columns_on_task, pver, iulog)

! Initialize orbital data
call orbital_data_init(columns_on_task)

end subroutine cam_init

!
Expand All @@ -265,8 +277,10 @@ subroutine cam_timestep_init()
!
!-----------------------------------------------------------------------

use phys_comp, only: phys_timestep_init
use stepon, only: stepon_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

!----------------------------------------------------------
! First phase of dynamics (at least couple from dynamics to physics)
Expand All @@ -287,6 +301,9 @@ subroutine cam_timestep_init()
! Update current fractional calendar day. Needs to be updated at every timestep.
calday = get_curr_calday()

! Update the orbital data
call orbital_data_advance(calday, lat_rad, lon_rad)

nusbaume marked this conversation as resolved.
Show resolved Hide resolved
end subroutine cam_timestep_init
!
!-----------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions src/data/registry.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
<metadata_file>$SRCROOT/src/control/camsrfexch.meta</metadata_file>
<metadata_file>$SRCROOT/src/control/runtime_obj.meta</metadata_file>
<metadata_file>$SRCROOT/src/data/physconst.meta</metadata_file>
<metadata_file>$SRCROOT/src/physics/utils/orbital_data.meta</metadata_file>
<metadata_file>$SRCROOT/src/physics/utils/musica_ccpp_dependencies.meta</metadata_file>
<metadata_file>$SRCROOT/src/physics/utils/physics_grid.meta</metadata_file>
<metadata_file>$SRCROOT/src/physics/utils/cam_constituents.meta</metadata_file>
<metadata_file>$SRCROOT/src/physics/utils/tropopause_climo_read.meta</metadata_file>
Expand Down
197 changes: 197 additions & 0 deletions src/physics/utils/musica_ccpp_dependencies.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
! Copyright (C) 2024 National Science Foundation-National Center for Atmospheric Research
! SPDX-License-Identifier: Apache-2.0
module musica_ccpp_dependencies
!--------------------------------------------------------------------------
!
! This module temporarily provides data that MUSICA chemistry consumes but
! does not produce. The values are realistic but are not based on the
! actual model state. These should be removed as the producers of this data
! are added to CAM-SIMA or as CCPP-compliant physics schemes.
!
! IMPORTANT: This module must be completely removed before doing any actual
! science with MUSICA chemistry in CAM-SIMA.
!
!--------------------------------------------------------------------------

use ccpp_kinds, only: kind_phys

implicit none
private

public :: musica_ccpp_dependencies_init

!> \section arg_table_musica_ccpp_dependencies Argument Table
!! \htmlinclude arg_table_musica_ccpp_dependencies.html
!!
integer, public, protected :: photolysis_wavelength_grid_section_dimension = 102
integer, public, protected :: photolysis_wavelength_grid_interface_dimension = 103
real(kind_phys), allocatable, public, protected :: photolysis_wavelength_grid_interfaces(:)
real(kind_phys), allocatable, public, protected :: extraterrestrial_radiation_flux(:)
real(kind_phys), allocatable, public, protected :: surface_albedo(:)
real(kind_phys), allocatable, public, protected :: blackbody_temperature_at_surface(:)
real(kind_phys), allocatable, public, protected :: cloud_area_fraction(:,:)

! local parameters
character(len=*), parameter :: module_name = '(musica_ccpp_dependencies)'

!==============================================================================
CONTAINS
!==============================================================================
boulderdaze marked this conversation as resolved.
Show resolved Hide resolved

subroutine musica_ccpp_dependencies_init(horizontal_dimension, &
vertical_layer_dimension, log_file_unit)

use cam_abortutils, only: check_allocate

!-----------------------------------------------------------------------
!
! Initialize the MUSICA scheme dependencies.
!
!-----------------------------------------------------------------------

integer, intent(in) :: horizontal_dimension
integer, intent(in) :: vertical_layer_dimension
integer, intent(in) :: log_file_unit

integer :: error_code
character(len=*), parameter :: subroutine_name = &
trim(module_name)//':(musica_ccpp_dependencies_init)'

write(log_file_unit,*) 'WARNING: Using placeholder data for MUSICA chemistry.'

allocate(photolysis_wavelength_grid_interfaces(photolysis_wavelength_grid_interface_dimension), &
stat=error_code)
call check_allocate(error_code, subroutine_name, &
'photolysis_wavelength_grid_interfaces(photolysis_wavelength_grid_interface_dimension)', &
file=__FILE__, line=__LINE__)
allocate(extraterrestrial_radiation_flux(photolysis_wavelength_grid_section_dimension), &
stat=error_code)
call check_allocate(error_code, subroutine_name, &
'extraterrestrial_radiation_flux(photolysis_wavelength_grid_section_dimension)', &
file=__FILE__, line=__LINE__)
allocate(surface_albedo(horizontal_dimension), stat=error_code)
call check_allocate(error_code, subroutine_name, &
'surface_albedo(horizontal_dimension)', &
file=__FILE__, line=__LINE__)
allocate(blackbody_temperature_at_surface(horizontal_dimension), stat=error_code)
call check_allocate(error_code, subroutine_name, &
'blackbody_temperature_at_surface(horizontal_dimension)', &
file=__FILE__, line=__LINE__)
allocate(cloud_area_fraction(horizontal_dimension, vertical_layer_dimension), stat=error_code)
call check_allocate(error_code, subroutine_name, &
'cloud_area_fraction(horizontal_dimension, vertical_layer_dimension)', &
file=__FILE__, line=__LINE__)

surface_albedo(:) = 0.1_kind_phys
Copy link
Member

Choose a reason for hiding this comment

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

Just to confirm - these appear to be realistic values for a first version of MUSICA in CAM-SIMA, while the necessary physical quantities are not fully available yet. Is this correct?

Just to make sure since if "realistic" values are provided here at initialization it might be difficult to debug later when something's supposed to be provided from a physical scheme and the values are not as expected. But if this is a placeholder then it is fine!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is just a placeholder, but I tried to add more text to the comments describing this module to make clear that it should be entirely removed once the things that actually provide this information are in place, and before doing any real science. Let me know if it's more clear now, or if we should add anything else.

blackbody_temperature_at_surface(:) = 292.3_kind_phys
cloud_area_fraction(:,:) = 0.7_kind_phys
extraterrestrial_radiation_flux(:) = 1.0e14_kind_phys
photolysis_wavelength_grid_interfaces = (/ &
120.0e-9_kind_phys, &
121.4e-9_kind_phys, &
121.9e-9_kind_phys, &
123.5e-9_kind_phys, &
124.3e-9_kind_phys, &
125.5e-9_kind_phys, &
126.3e-9_kind_phys, &
127.1e-9_kind_phys, &
130.1e-9_kind_phys, &
131.1e-9_kind_phys, &
135.0e-9_kind_phys, &
140.0e-9_kind_phys, &
145.0e-9_kind_phys, &
150.0e-9_kind_phys, &
155.0e-9_kind_phys, &
160.0e-9_kind_phys, &
165.0e-9_kind_phys, &
168.0e-9_kind_phys, &
171.0e-9_kind_phys, &
173.0e-9_kind_phys, &
174.4e-9_kind_phys, &
175.4e-9_kind_phys, &
177.0e-9_kind_phys, &
178.6e-9_kind_phys, &
180.2e-9_kind_phys, &
181.8e-9_kind_phys, &
183.5e-9_kind_phys, &
185.2e-9_kind_phys, &
186.9e-9_kind_phys, &
188.7e-9_kind_phys, &
190.5e-9_kind_phys, &
192.3e-9_kind_phys, &
194.2e-9_kind_phys, &
196.1e-9_kind_phys, &
198.0e-9_kind_phys, &
200.0e-9_kind_phys, &
202.0e-9_kind_phys, &
204.1e-9_kind_phys, &
206.2e-9_kind_phys, &
208.0e-9_kind_phys, &
211.0e-9_kind_phys, &
214.0e-9_kind_phys, &
217.0e-9_kind_phys, &
220.0e-9_kind_phys, &
223.0e-9_kind_phys, &
226.0e-9_kind_phys, &
229.0e-9_kind_phys, &
232.0e-9_kind_phys, &
235.0e-9_kind_phys, &
238.0e-9_kind_phys, &
241.0e-9_kind_phys, &
244.0e-9_kind_phys, &
247.0e-9_kind_phys, &
250.0e-9_kind_phys, &
253.0e-9_kind_phys, &
256.0e-9_kind_phys, &
259.0e-9_kind_phys, &
263.0e-9_kind_phys, &
267.0e-9_kind_phys, &
271.0e-9_kind_phys, &
275.0e-9_kind_phys, &
279.0e-9_kind_phys, &
283.0e-9_kind_phys, &
287.0e-9_kind_phys, &
291.0e-9_kind_phys, &
295.0e-9_kind_phys, &
298.5e-9_kind_phys, &
302.5e-9_kind_phys, &
305.5e-9_kind_phys, &
308.5e-9_kind_phys, &
311.5e-9_kind_phys, &
314.5e-9_kind_phys, &
317.5e-9_kind_phys, &
322.5e-9_kind_phys, &
327.5e-9_kind_phys, &
332.5e-9_kind_phys, &
337.5e-9_kind_phys, &
342.5e-9_kind_phys, &
347.5e-9_kind_phys, &
350.0e-9_kind_phys, &
355.0e-9_kind_phys, &
360.0e-9_kind_phys, &
365.0e-9_kind_phys, &
370.0e-9_kind_phys, &
375.0e-9_kind_phys, &
380.0e-9_kind_phys, &
385.0e-9_kind_phys, &
390.0e-9_kind_phys, &
395.0e-9_kind_phys, &
400.0e-9_kind_phys, &
405.0e-9_kind_phys, &
410.0e-9_kind_phys, &
415.0e-9_kind_phys, &
420.0e-9_kind_phys, &
430.0e-9_kind_phys, &
440.0e-9_kind_phys, &
450.0e-9_kind_phys, &
500.0e-9_kind_phys, &
550.0e-9_kind_phys, &
600.0e-9_kind_phys, &
650.0e-9_kind_phys, &
700.0e-9_kind_phys, &
750.0e-9_kind_phys &
/)

end subroutine musica_ccpp_dependencies_init

end module musica_ccpp_dependencies
48 changes: 48 additions & 0 deletions src/physics/utils/musica_ccpp_dependencies.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
[ccpp-table-properties]
name = musica_ccpp_dependencies
type = module
[ccpp-arg-table]
name = musica_ccpp_dependencies
type = module
[ photolysis_wavelength_grid_section_dimension ]
standard_name = photolysis_wavelength_grid_section_dimension
units = count
type = integer
dimensions = ()
protected = True
[ photolysis_wavelength_grid_interface_dimension ]
standard_name = photolysis_wavelength_grid_interface_dimension
units = count
type = integer
dimensions = ()
protected = True
[ photolysis_wavelength_grid_interfaces ]
standard_name = photolysis_wavelength_grid_interfaces
units = m
type = real | kind = kind_phys
dimensions = (photolysis_wavelength_grid_interface_dimension)
protected = True
[ extraterrestrial_radiation_flux ]
standard_name = extraterrestrial_radiation_flux
units = photons cm-2 s-1 nm-1
type = real | kind = kind_phys
dimensions = (photolysis_wavelength_grid_section_dimension)
protected = True
[ surface_albedo ]
standard_name = surface_albedo_due_to_UV_and_VIS_direct
units = none
nusbaume marked this conversation as resolved.
Show resolved Hide resolved
type = real | kind = kind_phys
dimensions = (horizontal_dimension)
protected = True
[ blackbody_temperature_at_surface ]
standard_name = blackbody_temperature_at_surface
type = real | kind = kind_phys
units = K
dimensions = (horizontal_dimension)
protected = True
[ cloud_area_fraction ]
standard_name = cloud_area_fraction
type = real | kind = kind_phys
units = fraction
dimensions = (horizontal_dimension,vertical_layer_dimension)
protected = True
Loading