Skip to content

Commit

Permalink
Fill in errmsg, errflg in check_energy schemes (ESCOMP#160)
Browse files Browse the repository at this point in the history
Originator(s): @jimmielin 

Summary (include the keyword ['closes', 'fixes', 'resolves'] and issue
number):

Fixes ESCOMP#159. b4b changes to include errmsg, errflg in the check_energy
schemes

Describe any changes made to the namelist: N/A

List all files eliminated and why: N/A

List all files added and what they do: N/A

List all existing files that have been modified, and describe the
changes:
(Helpful git command: `git diff --name-status
development...<your_branch_name>`)
```
Add errmsg, errflg (or set when not previously set) in check_energy schemes.

M       schemes/check_energy/check_energy_chng.F90
M       schemes/check_energy/check_energy_fix.F90
M       schemes/check_energy/check_energy_fix.meta
M       schemes/check_energy/check_energy_gmean/check_energy_gmean.F90
M       schemes/check_energy/check_energy_gmean/check_energy_gmean.meta
M       schemes/check_energy/check_energy_save_teout.F90
M       schemes/check_energy/check_energy_save_teout.meta
M       schemes/check_energy/check_energy_zero_fluxes.F90
M       schemes/check_energy/check_energy_zero_fluxes.meta
M       schemes/check_energy/dycore_energy_consistency_adjust.F90
M       schemes/check_energy/dycore_energy_consistency_adjust.meta
```

List any test failures: N/A

Is this a science-changing update? New physics package, algorithm
change, tuning changes, etc? No
  • Loading branch information
jimmielin authored Nov 25, 2024
1 parent 36e083a commit 9cec536
Show file tree
Hide file tree
Showing 11 changed files with 101 additions and 6 deletions.
6 changes: 6 additions & 0 deletions schemes/check_energy/check_energy_chng.F90
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ subroutine check_energy_chng_timestep_init( &
character(len=512), intent(out) :: errmsg ! error message
integer, intent(out) :: errflg ! error flag

errmsg = ''
errflg = 0

!------------------------------------------------
! Physics total energy.
!------------------------------------------------
Expand Down Expand Up @@ -276,6 +279,9 @@ subroutine check_energy_chng_run( &

integer :: i

errmsg = ''
errflg = 0

!------------------------------------------------
! Physics total energy.
!------------------------------------------------
Expand Down
8 changes: 7 additions & 1 deletion schemes/check_energy/check_energy_fix.F90
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module check_energy_fix
! Add heating rate required for global mean total energy conservation
!> \section arg_table_check_energy_fix_run Argument Table
!! \htmlinclude arg_table_check_energy_fix_run.html
subroutine check_energy_fix_run(ncol, pver, pint, gravit, heat_glob, ptend_s, eshflx, scheme_name)
subroutine check_energy_fix_run(ncol, pver, pint, gravit, heat_glob, ptend_s, eshflx, scheme_name, errmsg, errflg)
! Input arguments
integer, intent(in) :: ncol ! number of atmospheric columns
integer, intent(in) :: pver ! number of vertical layers
Expand All @@ -22,11 +22,17 @@ subroutine check_energy_fix_run(ncol, pver, pint, gravit, heat_glob, ptend_s, es
real(kind_phys), intent(out) :: eshflx(:) ! effective sensible heat flux [W m-2]
! for check_energy_chng

! Output arguments
character(len=64), intent(out) :: scheme_name ! scheme name
character(len=512), intent(out) :: errmsg ! error message
integer, intent(out) :: errflg ! error flag

! Local variables
integer :: i

errmsg = ''
errflg = 0

! Set scheme name for check_energy_chng
scheme_name = "check_energy_fix"

Expand Down
12 changes: 12 additions & 0 deletions schemes/check_energy/check_energy_fix.meta
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,15 @@
type = character | kind = len=64
dimensions = ()
intent = out
[ 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
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ subroutine check_energy_gmean_run( &
pint, &
te_ini_dyn, teout, &
tedif_glob, heat_glob, &
teinp_glob, teout_glob, psurf_glob, ptopb_glob)
teinp_glob, teout_glob, psurf_glob, ptopb_glob, &
errmsg, errflg)

! This scheme is non-portable due to dependency: Global mean module gmean from src/utils
use gmean_mod, only: gmean
Expand All @@ -43,10 +44,16 @@ subroutine check_energy_gmean_run( &
real(kind_phys), intent(out) :: psurf_glob ! global mean surface pressure [Pa]
real(kind_phys), intent(out) :: ptopb_glob ! global mean top boundary pressure [Pa]

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

! Local variables
real(kind_phys) :: te(ncol, 4) ! total energy of input/output states (copy)
real(kind_phys) :: te_glob(4) ! global means of total energy

errmsg = ''
errflg = 0

! Copy total energy out of input and output states.
! These four fields will have their global means calculated respectively
te(:ncol, 1) = te_ini_dyn(:ncol) ! Input energy using dycore energy formula [J m-2]
Expand Down
12 changes: 12 additions & 0 deletions schemes/check_energy/check_energy_gmean/check_energy_gmean.meta
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,15 @@
type = real | kind = kind_phys
dimensions = ()
intent = out
[ 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
7 changes: 6 additions & 1 deletion schemes/check_energy/check_energy_save_teout.F90
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,19 @@ module check_energy_save_teout

!> \section arg_table_check_energy_save_teout_run Argument Table
!! \htmlinclude arg_table_check_energy_save_teout_run.html
subroutine check_energy_save_teout_run(ncol, te_cur_dyn, teout)
subroutine check_energy_save_teout_run(ncol, te_cur_dyn, teout, errmsg, errflg)

! Input arguments
integer, intent(in) :: ncol ! number of atmospheric columns
real(kind_phys), intent(in) :: te_cur_dyn (:) ! dycore formula: current total energy [J m-2]

! Output arguments
real(kind_phys), intent(out) :: teout(:) ! total energy for global fixer in next timestep [J m-2]
character(len=512), intent(out) :: errmsg ! error message
integer, intent(out) :: errflg ! error flag

errmsg = ''
errflg = 0

! nb hplin: note that in physpkg.F90, the pbuf is updated to the previous dyn timestep
! through itim_old. Need to check if we need to replicate such pbuf functionality
Expand Down
12 changes: 12 additions & 0 deletions schemes/check_energy/check_energy_save_teout.meta
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,15 @@
type = real | kind = kind_phys
dimensions = (horizontal_loop_extent)
intent = out
[ 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
7 changes: 6 additions & 1 deletion schemes/check_energy/check_energy_zero_fluxes.F90
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module check_energy_zero_fluxes

!> \section arg_table_check_energy_zero_fluxes_run Argument Table
!! \htmlinclude arg_table_check_energy_zero_fluxes_run.html
subroutine check_energy_zero_fluxes_run(ncol, name, flx_vap, flx_cnd, flx_ice, flx_sen)
subroutine check_energy_zero_fluxes_run(ncol, name, flx_vap, flx_cnd, flx_ice, flx_sen, errmsg, errflg)
! Input arguments
integer, intent(in) :: ncol ! number of atmospheric columns

Expand All @@ -22,6 +22,11 @@ subroutine check_energy_zero_fluxes_run(ncol, name, flx_vap, flx_cnd, flx_ice, f
real(kind_phys), intent(out) :: flx_cnd(:) ! boundary flux of liquid+ice (precip?) [m s-1]
real(kind_phys), intent(out) :: flx_ice(:) ! boundary flux of ice (snow?) [m s-1]
real(kind_phys), intent(out) :: flx_sen(:) ! boundary flux of sensible heat [W m-2]
character(len=512), intent(out) :: errmsg ! error message
integer, intent(out) :: errflg ! error flag

errmsg = ''
errflg = 0

! reset values to zero
name = ''
Expand Down
12 changes: 12 additions & 0 deletions schemes/check_energy/check_energy_zero_fluxes.meta
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,15 @@
type = real | kind = kind_phys
dimensions = (horizontal_loop_extent)
intent = out
[ 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: 8 additions & 2 deletions schemes/check_energy/dycore_energy_consistency_adjust.F90
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ subroutine dycore_energy_consistency_adjust_run( &
do_consistency_adjust, &
scaling_dycore, &
tend_dTdt, &
tend_dTdt_local)
tend_dTdt_local, &
errmsg, errflg)

! Input arguments
integer, intent(in) :: ncol ! number of atmospheric columns
Expand All @@ -26,7 +27,12 @@ subroutine dycore_energy_consistency_adjust_run( &
real(kind_phys), intent(in) :: tend_dTdt(:,:) ! model physics temperature tendency [K s-1]

! Output arguments
real(kind_phys), intent(out) :: tend_dTdt_local(:,:) ! (scheme) temperature tendency [K s-1]
real(kind_phys), intent(out) :: tend_dTdt_local(:,:) ! (scheme) temperature tendency [K s-1]
character(len=512), intent(out) :: errmsg ! error message
integer, intent(out) :: errflg ! error flag

errmsg = ''
errflg = 0

if (do_consistency_adjust) then
! original formula for scaling of temperature:
Expand Down
12 changes: 12 additions & 0 deletions schemes/check_energy/dycore_energy_consistency_adjust.meta
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,15 @@
type = real | kind = kind_phys
dimensions = (horizontal_loop_extent, vertical_layer_dimension)
intent = out
[ 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

0 comments on commit 9cec536

Please sign in to comment.