Skip to content
Open
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
57 changes: 48 additions & 9 deletions schemes/vertical_diffusion/diffusion_stubs.F90
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ module diffusion_stubs
! CCPP-compliant subroutines
public :: zero_upper_boundary_condition_init

public :: tms_beljaars_zero_stub_run
public :: beljaars_zero_stub_run
public :: tms_beljaars_zero_stub_run ! Stub out both TMS and Beljaars (do_beljaars set to false)
public :: beljaars_zero_stub_run ! Stub out Beljaars only and allows TMS to be read from snapshot (do_beljaars set to false)
public :: tms_zero_stub_run ! Stub out TMS only and allow Beljaars to be read from snapshot (do_beljaars set to true)
public :: turbulent_mountain_stress_add_drag_coefficient_run
public :: turbulent_mountain_stress_add_updated_surface_stress_run

Expand Down Expand Up @@ -49,7 +50,7 @@ subroutine zero_upper_boundary_condition_init( &
! Output arguments
real(kind_phys), intent(out) :: ubc_mmr(:,:) ! Upper boundary condition mass mixing ratios [none]
logical, intent(out) :: cnst_fixed_ubc(:) ! Flag for fixed upper boundary condition of constituents [flag]
character(len=512), intent(out) :: errmsg ! Error message
character(len=*) , intent(out) :: errmsg ! Error message
integer, intent(out) :: errflg ! Error flag

errmsg = ''
Expand Down Expand Up @@ -87,7 +88,7 @@ subroutine tms_beljaars_zero_stub_run( &
real(kind_phys), intent(out) :: dragblj(:,:)! Drag profile from Beljaars SGO form drag > 0. [s-1]
real(kind_phys), intent(out) :: taubljx(:) ! Eastward Beljaars surface stress [N m-2]
real(kind_phys), intent(out) :: taubljy(:) ! Northward Beljaars surface stress [N m-2]
character(len=512), intent(out) :: errmsg ! Error message
character(len=*) , intent(out) :: errmsg ! Error message
integer, intent(out) :: errflg ! Error flag

errmsg = ''
Expand Down Expand Up @@ -133,7 +134,7 @@ subroutine beljaars_zero_stub_run( &
real(kind_phys), intent(out) :: dragblj(:,:)! Drag profile from Beljaars SGO form drag > 0. [s-1]
real(kind_phys), intent(out) :: taubljx(:) ! Eastward Beljaars surface stress [N m-2]
real(kind_phys), intent(out) :: taubljy(:) ! Northward Beljaars surface stress [N m-2]
character(len=512), intent(out) :: errmsg ! Error message
character(len=*) , intent(out) :: errmsg ! Error message
integer, intent(out) :: errflg ! Error flag

errmsg = ''
Expand All @@ -155,6 +156,44 @@ subroutine beljaars_zero_stub_run( &

end subroutine beljaars_zero_stub_run

! Stub for TMS to be set to zero while not implemented
! but allow CAM7 Beljaars to be tested from snapshot.
!> \section arg_table_tms_zero_stub_run Argument Table
!! \htmlinclude tms_zero_stub_run.html
subroutine tms_zero_stub_run( &
ncol, pver, &
ksrftms, &
tautmsx, tautmsy, &
do_beljaars, &
errmsg, errflg)

! Input arguments
integer, intent(in) :: ncol
integer, intent(in) :: pver

! Output arguments
real(kind_phys), intent(out) :: ksrftms(:) ! Surface drag coefficient for turbulent mountain stress. > 0. [kg m-2 s-1]
real(kind_phys), intent(out) :: tautmsx(:) ! Eastward turbulent mountain surface stress [N m-2]
real(kind_phys), intent(out) :: tautmsy(:) ! Northward turbulent mountain surface stress [N m-2]
logical, intent(out) :: do_beljaars
character(len=*) , intent(out) :: errmsg ! Error message
integer, intent(out) :: errflg ! Error flag

errmsg = ''
errflg = 0

! Set TMS drag coefficient to zero (stub implementation)
ksrftms(:ncol) = 0._kind_phys

! Set all TMS and Beljaars stresses to zero (stub implementation)
tautmsx(:ncol) = 0._kind_phys
tautmsy(:ncol) = 0._kind_phys

! Set do_beljaars flag to true as it is being read from snapshot.
do_beljaars = .true.

end subroutine tms_zero_stub_run

! Add turbulent mountain stress to the total surface drag coefficient
!> \section arg_table_turbulent_mountain_stress_add_drag_coefficient_run Argument Table
!! \htmlinclude arg_table_turbulent_mountain_stress_add_drag_coefficient_run.html
Expand All @@ -173,7 +212,7 @@ subroutine turbulent_mountain_stress_add_drag_coefficient_run( &
real(kind_phys), intent(inout) :: ksrf(:) ! total surface drag coefficient [kg m-2 s-1]

! Output arguments
character(len=512), intent(out) :: errmsg ! error message
character(len=*) , intent(out) :: errmsg ! error message
integer, intent(out) :: errflg ! error flag

errmsg = ''
Expand Down Expand Up @@ -217,7 +256,7 @@ subroutine turbulent_mountain_stress_add_updated_surface_stress_run( &
! Output arguments
real(kind_phys), intent(out) :: tautmsx(:) ! Implicit zonal turbulent mountain surface stress [N m-2]
real(kind_phys), intent(out) :: tautmsy(:) ! Implicit meridional turbulent mountain surface stress [N m-2]
character(len=512), intent(out) :: errmsg ! error message
character(len=*) , intent(out) :: errmsg ! error message
integer, intent(out) :: errflg ! error flag

errmsg = ''
Expand Down Expand Up @@ -258,7 +297,7 @@ subroutine vertical_diffusion_not_use_rairv_init( &

! Output arguments
logical, intent(out) :: use_rairv ! Flag for constituent-dependent gas constant [flag]
character(len=512), intent(out) :: errmsg
character(len=*) , intent(out) :: errmsg
integer, intent(out) :: errflg

errmsg = ''
Expand Down Expand Up @@ -303,7 +342,7 @@ subroutine dropmixnuc_apply_surface_fluxes_run( &
real(kind_phys), intent(inout) :: q1(:, :, :) ! Constituent array after "vertical diffusion" [kg kg-1]

! Output arguments
character(len=512), intent(out) :: errmsg
character(len=*) , intent(out) :: errmsg
integer, intent(out) :: errflg

! Local variables
Expand Down
14 changes: 7 additions & 7 deletions schemes/vertical_diffusion/diffusion_stubs.meta
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
standard_name = ccpp_error_message
units = none
dimensions = ()
type = character | kind = len=512
type = character | kind = len=*
intent = out
[ errflg ]
standard_name = ccpp_error_code
Expand Down Expand Up @@ -107,7 +107,7 @@
standard_name = ccpp_error_message
units = none
dimensions = ()
type = character | kind = len=512
type = character | kind = len=*
intent = out
[ errflg ]
standard_name = ccpp_error_code
Expand Down Expand Up @@ -164,7 +164,7 @@
standard_name = ccpp_error_message
units = none
dimensions = ()
type = character | kind = len=512
type = character | kind = len=*
intent = out
[ errflg ]
standard_name = ccpp_error_code
Expand Down Expand Up @@ -208,7 +208,7 @@
standard_name = ccpp_error_message
units = none
dimensions = ()
type = character | kind = len=512
type = character | kind = len=*
intent = out
[ errflg ]
standard_name = ccpp_error_code
Expand Down Expand Up @@ -305,7 +305,7 @@
[ errmsg ]
standard_name = ccpp_error_message
units = none
type = character | kind = len=512
type = character | kind = len=*
dimensions = ()
intent = out
[ errflg ]
Expand All @@ -331,7 +331,7 @@
[ errmsg ]
standard_name = ccpp_error_message
units = none
type = character | kind = len=512
type = character | kind = len=*
dimensions = ()
intent = out
[ errflg ]
Expand Down Expand Up @@ -407,7 +407,7 @@
[ errmsg ]
standard_name = ccpp_error_message
units = none
type = character | kind = len=512
type = character | kind = len=*
dimensions = ()
intent = out
[ errflg ]
Expand Down
113 changes: 113 additions & 0 deletions test/test_suites/suite_vdiff_holtslag_boville_free_atm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
CAM7 variant of the
Holtslag and Boville (HB) boundary layer scheme and vertical diffusion.

For CAM7 with CLUBB_SGS, the HB PBL scheme is only used in levels above
where CLUBB is active (the "free atmosphere"), via
hb_diff_free_atm_exchange_coefficients. The PBL-dependent coefficients
(hb_pbl_dependent_coefficients) are not computed; CLUBB handles the PBL.

The "prepare" interstitial zeros surface stresses and sensible heat flux
(CLUBB handles these), and optionally passes non-water-vapor constituent
fluxes (CAM6) or no fluxes at all (CAM7) to the diffusion solver via the
flag_for_vertical_diffusion_apply_ccpp_constituent_fluxes_excluding_water_vapor
flag.

The first part of this file is for HB to compute exchange coefficients
in the free atmosphere. The second part is the vertical diffusion solver.
TMS and Beljaars are stubbed as zeroes for now; when CCPPized they would
be separate schemes providing tautmsx/y, taubljx/y, and dragblj.
-->
<suite name="vdiff_holtslag_boville_free_atm" version="1.0">
<group name="physics_before_coupler">
<scheme>initialize_constituents</scheme>
<scheme>to_be_ccppized_temporary</scheme>

<!-- read namelist options -->
<scheme>holtslag_boville_diff_options</scheme>
<scheme>vertical_diffusion_options</scheme>

<!-- stub: zero UBC -->
<scheme>zero_upper_boundary_condition</scheme>

<!-- init phase only: for setting vertical diffusion top -->
<scheme>hb_diff_set_vertical_diffusion_top</scheme>

<!-- hb pre-interstitial: tautotx/y from coupler + TMS + Beljaars stresses -->
<scheme>tms_beljaars_zero_stub</scheme>

<!-- vdiff pre-interstitial 0: create p coords1d and potential temp. -->
<scheme>vertical_diffusion_prepare_inputs</scheme>

<!-- vdiff pre-interstitial 1: copy surfaces from coupler (cam_in)
For CAM7 with CLUBB: taux/tauy/shflux are zeroed (CLUBB handles surface).
Constituent fluxes depend on flag_for_cflux (CAM6: non-wv, CAM7: none). -->
<scheme>hb_free_atm_diff_prepare_vertical_diffusion_inputs</scheme>

<!-- vdiff pre-interstitial 2: interpolate t, rho, p to interfaces -->
<!-- not in WACCM-X mode so do not use rairv in vdiff. -->
<scheme>vertical_diffusion_not_use_rairv</scheme>
<scheme>vertical_diffusion_set_temperature_at_toa_default</scheme>
<scheme>vertical_diffusion_interpolate_to_interfaces</scheme>

<!-- vdiff pre-interstitial 3: calculate total surface stresses
used for surface momentum flux diagnostic.
here, also used for HB. -->
<scheme>vertical_diffusion_set_total_surface_stress</scheme>

<!-- Initialize Holtslag-Boville boundary layer scheme (no run phase) -->
<scheme>holtslag_boville_diff</scheme>

<!-- Holtslag-Boville boundary layer scheme: free atmosphere variant.
Only independent coefficients are computed (s2, ri).
PBL-dependent coefficients are NOT computed since CLUBB handles PBL. -->
<scheme>hb_pbl_independent_coefficients</scheme>
<scheme>compute_kinematic_fluxes_and_obklen</scheme>
<scheme>hb_diff_free_atm_exchange_coefficients</scheme>

<!-- sponge layer vertical diffusion (mutate kvm) -->
<scheme>vertical_diffusion_sponge_layer</scheme>

<!-- HB scheme diagnostics are not enabled for the free atmosphere variant,
as they are mostly zero when CLUBB is active.
TODO: ustar and obklen are still output by HB in CAM7; if needed,
a slimmed-down free_atm diagnostics scheme could be added here. -->

<!-- vdiff pre-interstitial 4: calculate drag coefficient -->
<scheme>implicit_surface_stress_add_drag_coefficient</scheme>

<!-- vdiff pre-interstitial 5: calculate damping rate from drag coef. -->
<scheme>vertical_diffusion_wind_damping_rate</scheme>
<scheme>beljaars_add_wind_damping_rate</scheme>

<!-- vdiff compute 1: horizontal momentum diffusion; dissipate KE -->
<scheme>vertical_diffusion_diffuse_horizontal_momentum</scheme>

<!-- set dry static energy top boundary condition to zero.
zero is used for: no molecular diffusion, or molecular diffusion + WACCM-X is active.
otherwise, use vertical_diffusion_set_dry_static_energy_at_toa_molecdiff -->
<scheme>vertical_diffusion_set_dry_static_energy_at_toa_zero</scheme>

<!-- vdiff compute 2: dry static energy diffusion -->
<scheme>vertical_diffusion_diffuse_dry_static_energy</scheme>

<!-- vdiff compute 3: tracer diffusion -->
<scheme>vertical_diffusion_diffuse_tracers</scheme>

<!-- vdiff post-interstitial 1: convert provisional updates to tendencies -->
<scheme>vertical_diffusion_tendencies</scheme>

<!-- diagnostics need to be outputted before tendencies are applied. -->
<scheme>vertical_diffusion_tendencies_diagnostics</scheme>

<!-- apply tendencies from vdiff -->
<scheme>apply_tendency_of_northward_wind</scheme>
<scheme>apply_tendency_of_eastward_wind</scheme>
<scheme>apply_constituent_tendencies</scheme>
<scheme>apply_heating_rate</scheme>
<scheme>qneg</scheme>
<scheme>geopotential_temp</scheme>
<scheme>update_dry_static_energy</scheme>
</group>
</suite>
Loading