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

Implement diagnostics for global energy fixer #169

Open
wants to merge 3 commits into
base: development
Choose a base branch
from
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
13 changes: 4 additions & 9 deletions schemes/sima_diagnostics/check_energy_diagnostics.F90
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
! Diagnostic scheme for check_energy
! Not all quantities are needed as diagnostics; this module is designed to ease development
!
!
module check_energy_diagnostics
use ccpp_kinds, only: kind_phys

Expand Down Expand Up @@ -31,22 +33,19 @@ subroutine check_energy_diagnostics_init(errmsg, errflg)
call history_add_field('scaling_dycore', 'ratio_of_specific_heat_of_air_used_in_physics_energy_formula_to_specific_heat_of_air_used_in_dycore_energy_formula', 'lev', 'inst', '1')

call history_add_field('te_cur_phys', 'vertically_integrated_total_energy_using_physics_energy_formula', horiz_only, 'inst', 'J m-2')
call history_add_field('te_cur_dyn', 'vertically_integrated_total_energy_using_dycore_energy_formula', horiz_only, 'inst', 'J m-2')
call history_add_field('tw_cur', 'vertically_integrated_total_water', horiz_only, 'inst', 'kg m-2')

call history_add_field('tend_te_tnd', 'cumulative_total_energy_boundary_flux_using_physics_energy_formula', horiz_only, 'inst', 'J m-2 s-1')
call history_add_field('tend_tw_tnd', 'cumulative_total_water_boundary_flux', horiz_only, 'inst', 'kg m-2 s-1')

call history_add_field('teout', 'vertically_integrated_total_energy_at_end_of_physics_timestep', horiz_only, 'inst', 'J m-2')

end subroutine check_energy_diagnostics_init

!> \section arg_table_check_energy_diagnostics_run Argument Table
!! \htmlinclude check_energy_diagnostics_run.html
subroutine check_energy_diagnostics_run( &
cp_or_cv_dycore, scaling_dycore, &
te_cur_phys, te_cur_dyn, tw_cur, &
tend_te_tnd, tend_tw_tnd, teout, &
te_cur_phys, tw_cur, &
tend_te_tnd, tend_tw_tnd, &
errmsg, errflg)

use cam_history, only: history_out_field
Expand All @@ -57,11 +56,9 @@ subroutine check_energy_diagnostics_run( &
real(kind_phys), intent(in) :: cp_or_cv_dycore(:,:)
real(kind_phys), intent(in) :: scaling_dycore(:,:)
real(kind_phys), intent(in) :: te_cur_phys(:)
real(kind_phys), intent(in) :: te_cur_dyn(:)
real(kind_phys), intent(in) :: tw_cur(:)
real(kind_phys), intent(in) :: tend_te_tnd(:)
real(kind_phys), intent(in) :: tend_tw_tnd(:)
real(kind_phys), intent(in) :: teout(:)


! CCPP error handling variables
Expand All @@ -75,11 +72,9 @@ subroutine check_energy_diagnostics_run( &
call history_out_field('cp_or_cv_dycore', cp_or_cv_dycore)
call history_out_field('scaling_dycore', scaling_dycore)
call history_out_field('te_cur_phys', te_cur_phys)
call history_out_field('te_cur_dyn', te_cur_dyn)
call history_out_field('tw_cur', tw_cur)
call history_out_field('tend_te_tnd', tend_te_tnd)
call history_out_field('tend_tw_tnd', tend_tw_tnd)
call history_out_field('teout', teout)

end subroutine check_energy_diagnostics_run

Expand Down
12 changes: 0 additions & 12 deletions schemes/sima_diagnostics/check_energy_diagnostics.meta
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@
type = real | kind = kind_phys
dimensions = (horizontal_loop_extent)
intent = in
[ te_cur_dyn ]
standard_name = vertically_integrated_total_energy_using_dycore_energy_formula
units = J m-2
type = real | kind = kind_phys
dimensions = (horizontal_loop_extent)
intent = in
[ tw_cur ]
standard_name = vertically_integrated_total_water
units = kg m-2
Expand All @@ -63,12 +57,6 @@
type = real | kind = kind_phys
dimensions = (horizontal_loop_extent)
intent = in
[ teout ]
standard_name = vertically_integrated_total_energy_at_end_of_physics_timestep
units = J m-2
type = real | kind = kind_phys
dimensions = (horizontal_loop_extent)
intent = in
[ errmsg ]
standard_name = ccpp_error_message
units = none
Expand Down
73 changes: 73 additions & 0 deletions schemes/sima_diagnostics/check_energy_fix_diagnostics.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
! Diagnostic scheme for check_energy_fix
! This module includes diagnostics that have to be output
! right after the energy fixer has been ran and check_energy_chng has updated energy state
! (before the fluxes for check_energy_chng are zeroed out)
module check_energy_fix_diagnostics
use ccpp_kinds, only: kind_phys

implicit none
private
save

public :: check_energy_fix_diagnostics_init
public :: check_energy_fix_diagnostics_run

contains

!> \section arg_table_check_energy_fix_diagnostics_init Argument Table
!! \htmlinclude check_energy_fix_diagnostics_init.html
subroutine check_energy_fix_diagnostics_init(errmsg, errflg)
use cam_history, only: history_add_field
use cam_history_support, only: horiz_only

character(len=512), intent(out) :: errmsg
integer, intent(out) :: errflg

! Local variables:

errmsg = ''
errflg = 0

! History add field calls
call history_add_field('teinp', 'vertically_integrated_total_energy_using_dycore_energy_formula_at_start_of_physics_timestep', horiz_only, 'inst', 'J m-2')
call history_add_field('tefix', 'vertically_integrated_total_energy_using_dycore_energy_formula', horiz_only, 'inst', 'J m-2')
call history_add_field('teout', 'vertically_integrated_total_energy_at_end_of_physics_timestep', horiz_only, 'inst', 'J m-2')
call history_add_field('efix', 'net_sensible_heat_flux_through_top_and_bottom_of_atmosphere_column_from_global_total_energy_correction', horiz_only, 'inst', 'J m-2')

end subroutine check_energy_fix_diagnostics_init

!> \section arg_table_check_energy_fix_diagnostics_run Argument Table
!! \htmlinclude check_energy_diagnostics_run.html
subroutine check_energy_fix_diagnostics_run( &
te_ini_dyn, te_cur_dyn, &
teout, &
eshflx, &
errmsg, errflg)

use cam_history, only: history_out_field
!------------------------------------------------
! Input / output parameters
!------------------------------------------------
! State variables
real(kind_phys), intent(in) :: te_ini_dyn(:)
real(kind_phys), intent(in) :: te_cur_dyn(:)
real(kind_phys), intent(in) :: teout(:)
real(kind_phys), intent(in) :: eshflx(:)


! CCPP error handling variables
character(len=512), intent(out) :: errmsg
integer, intent(out) :: errflg

errmsg = ''
errflg = 0

! History out field calls
call history_out_field('teinp', te_ini_dyn)
call history_out_field('teout', teout)
call history_out_field('tefix', te_cur_dyn)
call history_out_field('efix', eshflx)

end subroutine check_energy_fix_diagnostics_run

end module check_energy_fix_diagnostics
59 changes: 59 additions & 0 deletions schemes/sima_diagnostics/check_energy_fix_diagnostics.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
[ccpp-table-properties]
name = check_energy_fix_diagnostics
type = scheme

[ccpp-arg-table]
name = check_energy_fix_diagnostics_init
type = scheme
[ errmsg ]
standard_name = ccpp_error_message
units = none
type = character | kind = len=512
dimensions = ()
intent = out
[ errflg ]
standard_name = ccpp_error_code
units = 1
type = integer
dimensions = ()
intent = out

[ccpp-arg-table]
name = check_energy_fix_diagnostics_run
type = scheme
[ te_ini_dyn ]
standard_name = vertically_integrated_total_energy_using_dycore_energy_formula_at_start_of_physics_timestep
units = J m-2
type = real | kind = kind_phys
dimensions = (horizontal_dimension)
intent = in
[ te_cur_dyn ]
standard_name = vertically_integrated_total_energy_using_dycore_energy_formula
units = J m-2
type = real | kind = kind_phys
dimensions = (horizontal_loop_extent)
intent = in
[ teout ]
standard_name = vertically_integrated_total_energy_at_end_of_physics_timestep
units = J m-2
type = real | kind = kind_phys
dimensions = (horizontal_loop_extent)
intent = in
[ eshflx ]
standard_name = net_sensible_heat_flux_through_top_and_bottom_of_atmosphere_column
units = W m-2
type = real | kind = kind_phys
dimensions = (horizontal_loop_extent)
intent = in
[ errmsg ]
standard_name = ccpp_error_message
units = none
type = character | kind = len=512
dimensions = ()
intent = out
[ errflg ]
standard_name = ccpp_error_code
units = 1
type = integer
dimensions = ()
intent = out
10 changes: 7 additions & 3 deletions suites/suite_adiabatic.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,19 @@
<!-- After gmean, output global mean energy diagnostics -->
<scheme>check_energy_gmean_diagnostics</scheme>

<!-- Add global mean energy difference as heating (diff between gmean and save_teout) -->
<!--
Global energy fixer (check_energy_fix)
Add global mean energy difference as heating (diff between gmean and save_teout)
-->
<scheme>check_energy_zero_fluxes</scheme>
<scheme>check_energy_fix</scheme>
<scheme>apply_heating_rate</scheme>
<scheme>geopotential_temp</scheme>

<!-- Check that energy and water change matches the boundary fluxes -->
<!-- Check that energy and water change matches the boundary fluxes, update global energy -->
<scheme>check_energy_scaling</scheme>
<scheme>check_energy_chng</scheme>
<!-- Global energy fixer diagnostics (must run after check_energy_chng which updates global energies, but before zero_fluxes zeroes out boundary fluxes from energy fixer) -->
<scheme>check_energy_fix_diagnostics</scheme>

<!-- Save current total energy from dycore for energy fixer in time step. This requires te_cur to be updated from check_energy_chng first. -->
<scheme>check_energy_save_teout</scheme>
Expand Down
Loading