From f4aa8738f243a99ed59441d46b3ffdf12d61bee7 Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Wed, 4 Sep 2024 22:08:58 -0400 Subject: [PATCH 01/41] Initial commit --- check_energy/check_energy_chng.F90 | 197 +++++++++++++++++++++++++++++ 1 file changed, 197 insertions(+) create mode 100644 check_energy/check_energy_chng.F90 diff --git a/check_energy/check_energy_chng.F90 b/check_energy/check_energy_chng.F90 new file mode 100644 index 00000000..81f8edd6 --- /dev/null +++ b/check_energy/check_energy_chng.F90 @@ -0,0 +1,197 @@ +module check_energy_chng + + use ccpp_kinds, only: kind_phys + + implicit none + private + + public :: check_energy_chng_run + +contains + + subroutine check_energy_chng_run( & + state, tend, name, nstep, ztodt, & + flx_vap, flx_cnd, flx_ice, flx_sen) + use cam_thermo, only: get_hydrostatic_energy + use dyn_tests_utils, only: vc_physics, vc_dycore, vc_height, vc_dry_pressure + use cam_abortutils, only: endrun + use physics_types, only: phys_te_idx, dyn_te_idx +!----------------------------------------------------------------------- +! Check that the energy and water change matches the boundary fluxes +!----------------------------------------------------------------------- +!------------------------------Arguments-------------------------------- + + type(physics_state) , intent(inout) :: state + type(physics_tend ) , intent(inout) :: tend + character*(*),intent(in) :: name ! parameterization name for fluxes + integer , intent(in ) :: nstep ! current timestep number + real(r8), intent(in ) :: ztodt ! 2 delta t (model time increment) + real(r8), intent(in ) :: flx_vap(:) ! (pcols) - boundary flux of vapor (kg/m2/s) + real(r8), intent(in ) :: flx_cnd(:) ! (pcols) -boundary flux of liquid+ice (m/s) (precip?) + real(r8), intent(in ) :: flx_ice(:) ! (pcols) -boundary flux of ice (m/s) (snow?) + real(r8), intent(in ) :: flx_sen(:) ! (pcols) -boundary flux of sensible heat (w/m2) + +!******************** BAB ****************************************************** +!******* Note that the precip and ice fluxes are in precip units (m/s). ******** +!******* I would prefer to have kg/m2/s. ******** +!******* I would also prefer liquid (not total) and ice fluxes ******** +!******************************************************************************* + +!---------------------------Local storage------------------------------- + + real(r8) :: te_xpd(state%ncol) ! expected value (f0 + dt*boundary_flux) + real(r8) :: te_dif(state%ncol) ! energy of input state - original energy + real(r8) :: te_tnd(state%ncol) ! tendency from last process + real(r8) :: te_rer(state%ncol) ! relative error in energy column + + real(r8) :: tw_xpd(state%ncol) ! expected value (w0 + dt*boundary_flux) + real(r8) :: tw_dif(state%ncol) ! tw_inp - original water + real(r8) :: tw_tnd(state%ncol) ! tendency from last process + real(r8) :: tw_rer(state%ncol) ! relative error in water column + + real(r8) :: te(state%ncol) ! vertical integral of total energy + real(r8) :: tw(state%ncol) ! vertical integral of total water + real(r8) :: cp_or_cv(state%psetcols,pver) ! cp or cv depending on vcoord + real(r8) :: scaling(state%psetcols,pver) ! scaling for conversion of temperature increment + real(r8) :: temp(state%ncol,pver) ! temperature + + real(r8) :: se(state%ncol) ! enthalpy or internal energy (J/m2) + real(r8) :: po(state%ncol) ! surface potential or potential energy (J/m2) + real(r8) :: ke(state%ncol) ! kinetic energy (J/m2) + real(r8) :: wv(state%ncol) ! column integrated vapor (kg/m2) + real(r8) :: liq(state%ncol) ! column integrated liquid (kg/m2) + real(r8) :: ice(state%ncol) ! column integrated ice (kg/m2) + + integer lchnk ! chunk identifier + integer ncol ! number of atmospheric columns + integer i ! column index +!----------------------------------------------------------------------- + + lchnk = state%lchnk + ncol = state%ncol + + ! If psetcols == pcols, cpairv is the correct size and just copy into cp_or_cv + ! If psetcols > pcols and all cpairv match cpair, then assign the constant cpair + + if (state%psetcols == pcols) then + cp_or_cv(:,:) = cpairv(:,:,lchnk) + else if (state%psetcols > pcols .and. all(cpairv(:,:,:) == cpair)) then + cp_or_cv(:,:) = cpair + else + call endrun('check_energy_chng: cpairv is not allowed to vary when subcolumns are turned on') + end if + + call get_hydrostatic_energy(state%q(1:ncol,1:pver,1:pcnst),.true., & + state%pdel(1:ncol,1:pver), cp_or_cv(1:ncol,1:pver), & + state%u(1:ncol,1:pver), state%v(1:ncol,1:pver), state%T(1:ncol,1:pver), & + vc_physics, ptop=state%pintdry(1:ncol,1), phis = state%phis(1:ncol), & + te = te(1:ncol), H2O = tw(1:ncol), se=se(1:ncol),po=po(1:ncol), & + ke=ke(1:ncol),wv=wv(1:ncol),liq=liq(1:ncol),ice=ice(1:ncol)) + ! compute expected values and tendencies + do i = 1, ncol + ! change in static energy and total water + te_dif(i) = te(i) - state%te_cur(i,phys_te_idx) + tw_dif(i) = tw(i) - state%tw_cur(i,phys_te_idx) + + ! expected tendencies from boundary fluxes for last process + te_tnd(i) = flx_vap(i)*(latvap+latice) - (flx_cnd(i) - flx_ice(i))*1000._r8*latice + flx_sen(i) + tw_tnd(i) = flx_vap(i) - flx_cnd(i) *1000._r8 + + ! cummulative tendencies from boundary fluxes + tend%te_tnd(i) = tend%te_tnd(i) + te_tnd(i) + tend%tw_tnd(i) = tend%tw_tnd(i) + tw_tnd(i) + + ! expected new values from previous state plus boundary fluxes + te_xpd(i) = state%te_cur(i,phys_te_idx) + te_tnd(i)*ztodt + tw_xpd(i) = state%tw_cur(i,phys_te_idx) + tw_tnd(i)*ztodt + + ! relative error, expected value - input state / previous state + te_rer(i) = (te_xpd(i) - te(i)) / state%te_cur(i,phys_te_idx) + end do + + ! relative error for total water (allow for dry atmosphere) + tw_rer = 0._r8 + where (state%tw_cur(:ncol,phys_te_idx) > 0._r8) + tw_rer(:ncol) = (tw_xpd(:ncol) - tw(:ncol)) / state%tw_cur(:ncol,1) + end where + + ! error checking + if (print_energy_errors) then + if (any(abs(te_rer(1:ncol)) > 1.E-14_r8 .or. abs(tw_rer(1:ncol)) > 1.E-10_r8)) then + do i = 1, ncol + ! the relative error threshold for the water budget has been reduced to 1.e-10 + ! to avoid messages generated by QNEG3 calls + ! PJR- change to identify if error in energy or water + if (abs(te_rer(i)) > 1.E-14_r8 ) then + state%count = state%count + 1 + write(iulog,*) "significant energy conservation error after ", name, & + " count", state%count, " nstep", nstep, "chunk", lchnk, "col", i + write(iulog,*) te(i),te_xpd(i),te_dif(i),tend%te_tnd(i)*ztodt, & + te_tnd(i)*ztodt,te_rer(i) + endif + if ( abs(tw_rer(i)) > 1.E-10_r8) then + state%count = state%count + 1 + write(iulog,*) "significant water conservation error after ", name, & + " count", state%count, " nstep", nstep, "chunk", lchnk, "col", i + write(iulog,*) tw(i),tw_xpd(i),tw_dif(i),tend%tw_tnd(i)*ztodt, & + tw_tnd(i)*ztodt,tw_rer(i) + end if + end do + end if + end if + + ! copy new value to state + + do i = 1, ncol + state%te_cur(i,phys_te_idx) = te(i) + state%tw_cur(i,phys_te_idx) = tw(i) + end do + + ! + ! Dynamical core total energy + ! + if (vc_dycore == vc_height) then + ! + ! compute cv if vertical coordinate is height: cv = cp - R + ! + ! Note: cp_or_cv set above for pressure coordinate + if (state%psetcols == pcols) then + cp_or_cv(:ncol,:) = cp_or_cv_dycore(:ncol,:,lchnk) + else + cp_or_cv(:ncol,:) = cpair-rair + endif + scaling(:,:) = cpairv(:,:,lchnk)/cp_or_cv(:,:) !cp/cv scaling + temp(1:ncol,:) = state%temp_ini(1:ncol,:)+scaling(1:ncol,:)*(state%T(1:ncol,:)-state%temp_ini(1:ncol,:)) + call get_hydrostatic_energy(state%q(1:ncol,1:pver,1:pcnst),.true., & + state%pdel(1:ncol,1:pver), cp_or_cv(1:ncol,1:pver), & + state%u(1:ncol,1:pver), state%v(1:ncol,1:pver), temp(1:ncol,1:pver), & + vc_dycore, ptop=state%pintdry(1:ncol,1), phis = state%phis(1:ncol), & + z_mid = state%z_ini(1:ncol,:), & + te = state%te_cur(1:ncol,dyn_te_idx), H2O = state%tw_cur(1:ncol,dyn_te_idx)) + else if (vc_dycore == vc_dry_pressure) then + ! + ! SE specific hydrostatic energy + ! + if (state%psetcols == pcols) then + cp_or_cv(:ncol,:) = cp_or_cv_dycore(:ncol,:,lchnk) + scaling(:ncol,:) = cpairv(:ncol,:,lchnk)/cp_or_cv_dycore(:ncol,:,lchnk) + else + cp_or_cv(:ncol,:) = cpair + scaling(:ncol,:) = 1.0_r8 + endif + ! + ! enthalpy scaling for energy consistency + ! + temp(1:ncol,:) = state%temp_ini(1:ncol,:)+scaling(1:ncol,:)*(state%T(1:ncol,:)-state%temp_ini(1:ncol,:)) + call get_hydrostatic_energy(state%q(1:ncol,1:pver,1:pcnst),.true., & + state%pdel(1:ncol,1:pver), cp_or_cv(1:ncol,1:pver), & + state%u(1:ncol,1:pver), state%v(1:ncol,1:pver), temp(1:ncol,1:pver), & + vc_dry_pressure, ptop=state%pintdry(1:ncol,1), phis = state%phis(1:ncol), & + te = state%te_cur(1:ncol,dyn_te_idx), H2O = state%tw_cur(1:ncol,dyn_te_idx)) + else + state%te_cur(1:ncol,dyn_te_idx) = te(1:ncol) + state%tw_cur(1:ncol,dyn_te_idx) = tw(1:ncol) + end if + end subroutine check_energy_chng + +end module check_energy_chng \ No newline at end of file From 807f10da85dc68c88b9fed444fe77768d993c35b Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Fri, 6 Sep 2024 15:19:23 -0400 Subject: [PATCH 02/41] Initial CCPP-ization and cleanup of check_energy_chng with support utilities. --- check_energy/check_energy_chng.F90 | 502 ++++++++++++++++++------- check_energy/check_energy_chng.meta | 396 +++++++++++++++++++ check_energy/check_energy_scaling.F90 | 43 +++ check_energy/check_energy_scaling.meta | 49 +++ 4 files changed, 851 insertions(+), 139 deletions(-) create mode 100644 check_energy/check_energy_chng.meta create mode 100644 check_energy/check_energy_scaling.F90 create mode 100644 check_energy/check_energy_scaling.meta diff --git a/check_energy/check_energy_chng.F90 b/check_energy/check_energy_chng.F90 index 81f8edd6..87db49d9 100644 --- a/check_energy/check_energy_chng.F90 +++ b/check_energy/check_energy_chng.F90 @@ -1,196 +1,420 @@ module check_energy_chng - use ccpp_kinds, only: kind_phys + use ccpp_kinds, only: kind_phys - implicit none - private + ! FIXME hplin: for DEBUG only + use cam_logfile, only: iulog - public :: check_energy_chng_run + implicit none + private + + public :: check_energy_chng_timestep_init + public :: check_energy_chng_run + + ! Private module options. + logical :: print_energy_errors = .false. contains + ! Compute initial values of energy and water integrals, + ! and zero out cumulative boundary tendencies. +!> \section arg_table_check_energy_chng_timestep_init Argument Table +!! \htmlinclude arg_table_check_energy_chng_timestep_init.html + subroutine check_energy_chng_timestep_init( & + ncol, pver, pcnst, & + q, pdel, pdeldry, & + u, v, T, & + pint, pintdry, phis, zm, & + cp_phys, & ! cpairv generally, cpair fixed size for subcolumns code + cp_or_cv_dycore, & + te_ini_phys, te_ini_dyn, & + tw_ini, & + te_cur_phys, te_cur_dyn, & + tw_cur, & + tend_te_tnd, tend_tw_tnd, & + temp_ini, z_ini, & + count, & + vc_physics, vc_dycore, & + errmsg, errflg) + + use cam_thermo, only: get_hydrostatic_energy + use dyn_tests_utils, only: vc_height, vc_dry_pressure + use physics_types, only: phys_te_idx, dyn_te_idx + + ! Input arguments + integer, intent(in) :: ncol ! number of atmospheric columns + integer, intent(in) :: pver ! number of vertical layers + integer, intent(in) :: pcnst ! number of ccpp constituents + real(kind_phys), intent(in) :: q(:,:,:) ! constituent mass mixing ratios [kg kg-1] + real(kind_phys), intent(in) :: pdel(:,:) ! layer thickness [Pa] + real(kind_phys), intent(in) :: pdeldry(:,:) ! dry air layer thickness [Pa] + real(kind_phys), intent(in) :: u(:,:) ! zonal wind [m s-1] + real(kind_phys), intent(in) :: v(:,:) ! meridional wind [m s-1] + real(kind_phys), intent(in) :: T(:,:) ! temperature [K] + real(kind_phys), intent(in) :: pint(:,:) ! interface pressure [Pa] + real(kind_phys), intent(in) :: pintdry(:) ! interface pressure dry [Pa] + real(kind_phys), intent(in) :: phis(:) ! surface geopotential [m2 s-2] + real(kind_phys), intent(in) :: zm(:,:) ! geopotential height at layer midpoints [m] + real(kind_phys), intent(in) :: temp_ini(:,:) ! initial temperature [K] + real(kind_phys), intent(in) :: z_ini(:,:) ! initial geopotential height [m] + real(kind_phys), intent(in) :: cp_phys(:,:) ! enthalpy (cpairv generally) [J kg-1 K-1] + real(kind_phys), intent(in) :: cp_or_cv_dycore(:,:) ! enthalpy or heat capacity, dycore dependent [J K-1 kg-1] + integer, intent(in) :: vc_physics ! vertical coordinate system, physics + integer, intent(in) :: vc_dycore ! vertical coordinate system, dycore + + ! Input/Output arguments + real(kind_phys), intent(inout) :: te_ini_phys(:) ! physics formula: initial total energy [J m-2] + real(kind_phys), intent(inout) :: te_ini_dyn (:) ! dycore formula: initial total energy [J m-2] + real(kind_phys), intent(inout) :: tw_ini (:) ! initial total water [kg m-2] + real(kind_phys), intent(inout) :: te_cur_phys(:) ! physics formula: current total energy [J m-2] + real(kind_phys), intent(inout) :: te_cur_dyn (:) ! dycore formula: current total energy [J m-2] + real(kind_phys), intent(inout) :: tw_cur (:) ! current total water [kg m-2] + integer, intent(inout) :: count ! count of values with significant energy or water imbalances [1] + real(kind_phys), intent(inout) :: tend_te_tnd(:) ! total energy tendency [J m-2 s-1] + real(kind_phys), intent(inout) :: tend_tw_tnd(:) ! total water tendency [kg m-2 s-1] + + ! Output arguments + character(len=512), intent(out) :: errmsg ! error message + integer, intent(out) :: errflg ! error flag + + !------------------------------------------------ + ! Physics total energy. + !------------------------------------------------ + call get_hydrostatic_energy( & + tracer = q(1:ncol,1:pver,1:pcnst), & ! moist mixing ratios + moist_mixing_ratio = .true., & + pdel_in = pdel (1:ncol,1:pver), & + cp_or_cv = cp_phys (1:ncol,1:pver), & + U = u (1:ncol,1:pver), & + V = v (1:ncol,1:pver), & + T = T (1:ncol,1:pver), & + vcoord = vc_physics, & ! vertical coordinate for physics + ptop = pintdry (1:ncol,1), & + phis = phis (1:ncol), & + te = te_ini_phys(1:ncol), & ! vertically integrated total energy + H2O = tw_ini (1:ncol), & ! v.i. total water + ) + + ! Save initial state temperature and geopotential height for use in run phase + temp_ini(:ncol,:) = T (:ncol, :) + z_ini (:ncol,:) = zm(:ncol, :) + + !------------------------------------------------ + ! Dynamical core total energy. + !------------------------------------------------ + if (vc_dycore == vc_dry_pressure) then + ! SE dycore specific hydrostatic energy (enthalpy) + call get_hydrostatic_energy( & + tracer = q(1:ncol,1:pver,1:pcnst), & ! moist mixing ratios + moist_mixing_ratio = .true., & + pdel_in = pdel (1:ncol,1:pver), & + cp_or_cv = cp_or_cv_dycore(1:ncol,1:pver), & + U = u (1:ncol,1:pver), & + V = v (1:ncol,1:pver), & + T = T (1:ncol,1:pver), & + vcoord = vc_dycore, & ! vertical coordinate for dycore + ptop = pintdry (1:ncol,1), & + phis = phis (1:ncol), & + te = te_ini_dyn (1:ncol) & ! WRITE OPERATION - vertically integrated total energy + ) + + else if (vc_dycore == vc_height) then + ! MPAS dycore: compute cv if vertical coordinate is height: cv = cp - R (internal energy) + call get_hydrostatic_energy( & + tracer = q(1:ncol,1:pver,1:pcnst), & ! moist mixing ratios + moist_mixing_ratio = .true., & + pdel_in = pdel (1:ncol,1:pver), & + cp_or_cv = cp_or_cv_dycore(1:ncol,1:pver), & + U = u (1:ncol,1:pver), & + V = v (1:ncol,1:pver), & + T = T (1:ncol,1:pver), & ! enthalpy-scaled temperature for energy consistency + vcoord = vc_dycore, & ! vertical coordinate for dycore + ptop = pintdry (1:ncol,1), & + phis = phis (1:ncol), & + z_mid = z_ini (1:ncol), & ! unique for vc_height (MPAS) + te = te_ini_dyn (1:ncol) & ! WRITE OPERATION - vertically integrated total energy + ) + else + ! FV dycore: dycore energy is the same as physics + te_ini_dyn(:ncol) = te_ini_phys(:ncol) + endif + + ! Set current state to be the same as initial + te_cur_phys(:ncol) = te_ini_phys(:ncol) + te_cur_dyn (:ncol) = te_ini_dyn (:ncol) + tw_cur (:ncol) = tw_ini (:ncol) + + ! Zero out current energy unbalances count + count = 0 + + ! Zero out cumulative boundary fluxes + tend_te_tnd(:ncol) = 0._kind_phys + tend_tw_tnd(:ncol) = 0._kind_phys + + end subroutine check_energy_chng_timestep_init + + + ! Check that energy and water change matches the boundary fluxes. +!> \section arg_table_check_energy_chng_run Argument Table +!! \htmlinclude arg_table_check_energy_chng_run.html subroutine check_energy_chng_run( & - state, tend, name, nstep, ztodt, & - flx_vap, flx_cnd, flx_ice, flx_sen) + ncol, pver, pcnst, & + q, pdel, pdeldry, & + u, v, T, & + pint, pintdry, phis, zm, & + cp_phys, & ! cpairv generally, cpair fixed size for subcolumns code + cp_or_cv_dycore, & + scaling_dycore, & ! From check_energy_scaling to work around subcolumns code + te_cur_phys, te_cur_dyn, & + tw_cur, & + tend_te_tnd, tend_tw_tnd, & + temp_ini, z_ini, & + count, ztodt, & + vc_physics, vc_dycore, & + name, flx_vap, flx_cnd, flx_ice, flx_sen, & + errmsg, errflg) + use cam_thermo, only: get_hydrostatic_energy - use dyn_tests_utils, only: vc_physics, vc_dycore, vc_height, vc_dry_pressure - use cam_abortutils, only: endrun + use dyn_tests_utils, only: vc_height, vc_dry_pressure use physics_types, only: phys_te_idx, dyn_te_idx -!----------------------------------------------------------------------- -! Check that the energy and water change matches the boundary fluxes -!----------------------------------------------------------------------- -!------------------------------Arguments-------------------------------- - - type(physics_state) , intent(inout) :: state - type(physics_tend ) , intent(inout) :: tend - character*(*),intent(in) :: name ! parameterization name for fluxes - integer , intent(in ) :: nstep ! current timestep number - real(r8), intent(in ) :: ztodt ! 2 delta t (model time increment) - real(r8), intent(in ) :: flx_vap(:) ! (pcols) - boundary flux of vapor (kg/m2/s) - real(r8), intent(in ) :: flx_cnd(:) ! (pcols) -boundary flux of liquid+ice (m/s) (precip?) - real(r8), intent(in ) :: flx_ice(:) ! (pcols) -boundary flux of ice (m/s) (snow?) - real(r8), intent(in ) :: flx_sen(:) ! (pcols) -boundary flux of sensible heat (w/m2) - -!******************** BAB ****************************************************** -!******* Note that the precip and ice fluxes are in precip units (m/s). ******** -!******* I would prefer to have kg/m2/s. ******** -!******* I would also prefer liquid (not total) and ice fluxes ******** -!******************************************************************************* - -!---------------------------Local storage------------------------------- - - real(r8) :: te_xpd(state%ncol) ! expected value (f0 + dt*boundary_flux) - real(r8) :: te_dif(state%ncol) ! energy of input state - original energy - real(r8) :: te_tnd(state%ncol) ! tendency from last process - real(r8) :: te_rer(state%ncol) ! relative error in energy column - - real(r8) :: tw_xpd(state%ncol) ! expected value (w0 + dt*boundary_flux) - real(r8) :: tw_dif(state%ncol) ! tw_inp - original water - real(r8) :: tw_tnd(state%ncol) ! tendency from last process - real(r8) :: tw_rer(state%ncol) ! relative error in water column - - real(r8) :: te(state%ncol) ! vertical integral of total energy - real(r8) :: tw(state%ncol) ! vertical integral of total water - real(r8) :: cp_or_cv(state%psetcols,pver) ! cp or cv depending on vcoord - real(r8) :: scaling(state%psetcols,pver) ! scaling for conversion of temperature increment - real(r8) :: temp(state%ncol,pver) ! temperature - - real(r8) :: se(state%ncol) ! enthalpy or internal energy (J/m2) - real(r8) :: po(state%ncol) ! surface potential or potential energy (J/m2) - real(r8) :: ke(state%ncol) ! kinetic energy (J/m2) - real(r8) :: wv(state%ncol) ! column integrated vapor (kg/m2) - real(r8) :: liq(state%ncol) ! column integrated liquid (kg/m2) - real(r8) :: ice(state%ncol) ! column integrated ice (kg/m2) - - integer lchnk ! chunk identifier - integer ncol ! number of atmospheric columns - integer i ! column index -!----------------------------------------------------------------------- - lchnk = state%lchnk - ncol = state%ncol + ! Input arguments + integer, intent(in) :: ncol ! number of atmospheric columns + integer, intent(in) :: pver ! number of vertical layers + integer, intent(in) :: pcnst ! number of ccpp constituents + real(kind_phys), intent(in) :: q(:,:,:) ! constituent mass mixing ratios [kg kg-1] + real(kind_phys), intent(in) :: pdel(:,:) ! layer thickness [Pa] + real(kind_phys), intent(in) :: pdeldry(:,:) ! dry air layer thickness [Pa] + real(kind_phys), intent(in) :: u(:,:) ! zonal wind [m s-1] + real(kind_phys), intent(in) :: v(:,:) ! meridional wind [m s-1] + real(kind_phys), intent(in) :: T(:,:) ! temperature [K] + real(kind_phys), intent(in) :: pint(:,:) ! interface pressure [Pa] + real(kind_phys), intent(in) :: pintdry(:) ! interface pressure dry [Pa] + real(kind_phys), intent(in) :: phis(:) ! surface geopotential [m2 s-2] + real(kind_phys), intent(in) :: zm(:,:) ! geopotential height at layer midpoints [m] + real(kind_phys), intent(in) :: temp_ini(:,:) ! initial temperature [K] + real(kind_phys), intent(in) :: z_ini(:,:) ! initial geopotential height [m] + real(kind_phys), intent(in) :: cp_phys(:,:) ! enthalpy (cpairv generally) [J kg-1 K-1] + real(kind_phys), intent(in) :: cp_or_cv_dycore(:,:) ! enthalpy or heat capacity, dycore dependent [J K-1 kg-1] + real(kind_phys), intent(in) :: scaling_dycore(:,:) ! scaling for conversion of temperature increment [1] + real(kind_phys), intent(in) :: ztodt ! 2 delta t (model time increment) [s] + integer, intent(in) :: vc_physics ! vertical coordinate system, physics + integer, intent(in) :: vc_dycore ! vertical coordinate system, dycore + + ! Input from CCPP-scheme being checked: + ! parameterization name; surface fluxes of (1) vapor, (2) liquid+ice, (3) ice, (4) sensible heat + ! to pass in the values to be checked, call check_energy_zero_input_fluxes to reset these values + ! before a parameterization that is checked, then update these values as-needed + ! (can be all zero; in fact, most parameterizations calling _chng call with zero arguments) + ! + ! Original comment from BAB: + ! Note that the precip and ice fluxes are in precip units (m/s). + ! I would prefer to have kg/m2/s. + ! I would also prefer liquid (not total) and ice fluxes + character(len=*), intent(in) :: name ! parameterization name for fluxes + real(kind_phys), intent(in) :: flx_vap(:) ! boundary flux of vapor [kg m-2 s-1] + real(kind_phys), intent(in) :: flx_cnd(:) ! boundary flux of liquid+ice (precip?) [m s-1] + real(kind_phys), intent(in) :: flx_ice(:) ! boundary flux of ice (snow?) [m s-1] + real(kind_phys), intent(in) :: flx_sen(:) ! boundary flux of sensible heat [W m-2] + + ! Input/Output arguments + real(kind_phys), intent(inout) :: te_cur_phys(:) ! physics formula: current total energy [J m-2] + real(kind_phys), intent(inout) :: te_cur_dyn (:) ! dycore formula: current total energy [J m-2] + real(kind_phys), intent(inout) :: tw_cur (:) ! current total water [kg m-2] + integer, intent(inout) :: count ! count of values with significant energy or water imbalances [1] + real(kind_phys), intent(inout) :: tend_te_tnd(:) ! total energy tendency [J m-2 s-1] + real(kind_phys), intent(inout) :: tend_tw_tnd(:) ! total water tendency [kg m-2 s-1] + + ! Output arguments + character(len=512), intent(out) :: errmsg ! error message + integer, intent(out) :: errflg ! error flag + + ! Local variables + real(kind_phys) :: te_xpd(ncol) ! expected value (f0 + dt*boundary_flux) + real(kind_phys) :: te_dif(ncol) ! energy of input state - original energy + real(kind_phys) :: te_tnd(ncol) ! tendency from last process + real(kind_phys) :: te_rer(ncol) ! relative error in energy column + + real(kind_phys) :: tw_xpd(ncol) ! expected value (w0 + dt*boundary_flux) + real(kind_phys) :: tw_dif(ncol) ! tw_inp - original water + real(kind_phys) :: tw_tnd(ncol) ! tendency from last process + real(kind_phys) :: tw_rer(ncol) ! relative error in water column + + real(kind_phys) :: te(ncol) ! vertical integral of total energy + real(kind_phys) :: tw(ncol) ! vertical integral of total water + real(kind_phys) :: temp(ncol,pver) ! temperature + + real(kind_phys) :: se(ncol) ! enthalpy or internal energy (J/m2) + real(kind_phys) :: po(ncol) ! surface potential or potential energy (J/m2) + real(kind_phys) :: ke(ncol) ! kinetic energy (J/m2) + real(kind_phys) :: wv(ncol) ! column integrated vapor (kg/m2) + real(kind_phys) :: liq(ncol) ! column integrated liquid (kg/m2) + real(kind_phys) :: ice(ncol) ! column integrated ice (kg/m2) + + integer :: i +!----------------------------------------------------------------------- ! If psetcols == pcols, cpairv is the correct size and just copy into cp_or_cv ! If psetcols > pcols and all cpairv match cpair, then assign the constant cpair - if (state%psetcols == pcols) then - cp_or_cv(:,:) = cpairv(:,:,lchnk) - else if (state%psetcols > pcols .and. all(cpairv(:,:,:) == cpair)) then - cp_or_cv(:,:) = cpair - else - call endrun('check_energy_chng: cpairv is not allowed to vary when subcolumns are turned on') - end if + ! below to be passed to cp_phys: + ! if (state%psetcols == pcols) then + ! cp_or_cv(:,:) = cpairv(:,:,lchnk) + ! else if (state%psetcols > pcols .and. all(cpairv(:,:,:) == cpair)) then + ! cp_or_cv(:,:) = cpair + ! else + ! call endrun('check_energy_chng: cpairv is not allowed to vary when subcolumns are turned on') + ! end if + + !------------------------------------------------ + ! Physics total energy. + !------------------------------------------------ + call get_hydrostatic_energy( & + tracer = q(1:ncol,1:pver,1:pcnst), & ! moist mixing ratios + moist_mixing_ratio = .true., & + pdel_in = pdel (1:ncol,1:pver), & + cp_or_cv = cp_phys(1:ncol,1:pver), & + U = u (1:ncol,1:pver), & + V = v (1:ncol,1:pver), & + T = T (1:ncol,1:pver), & + vcoord = vc_physics, & ! vertical coordinate for physics + ptop = pintdry(1:ncol,1), & + phis = phis (1:ncol), & + te = te (1:ncol), & ! vertically integrated total energy + H2O = tw (1:ncol), & ! v.i. total water + se = se (1:ncol), & ! v.i. enthalpy + po = po (1:ncol), & ! v.i. PHIS term + ke = ke (1:ncol), & ! v.i. kinetic energy + wv = wv (1:ncol), & ! v.i. water vapor + liq = liq (1:ncol), & ! v.i. liquid + ice = ice (1:ncol) & ! v.i. ice + ) - call get_hydrostatic_energy(state%q(1:ncol,1:pver,1:pcnst),.true., & - state%pdel(1:ncol,1:pver), cp_or_cv(1:ncol,1:pver), & - state%u(1:ncol,1:pver), state%v(1:ncol,1:pver), state%T(1:ncol,1:pver), & - vc_physics, ptop=state%pintdry(1:ncol,1), phis = state%phis(1:ncol), & - te = te(1:ncol), H2O = tw(1:ncol), se=se(1:ncol),po=po(1:ncol), & - ke=ke(1:ncol),wv=wv(1:ncol),liq=liq(1:ncol),ice=ice(1:ncol)) ! compute expected values and tendencies do i = 1, ncol ! change in static energy and total water - te_dif(i) = te(i) - state%te_cur(i,phys_te_idx) - tw_dif(i) = tw(i) - state%tw_cur(i,phys_te_idx) + te_dif(i) = te(i) - te_cur_phys(i) + tw_dif(i) = tw(i) - tw_cur (i) ! expected tendencies from boundary fluxes for last process - te_tnd(i) = flx_vap(i)*(latvap+latice) - (flx_cnd(i) - flx_ice(i))*1000._r8*latice + flx_sen(i) - tw_tnd(i) = flx_vap(i) - flx_cnd(i) *1000._r8 + te_tnd(i) = flx_vap(i)*(latvap+latice) - (flx_cnd(i) - flx_ice(i))*1000._kind_phys*latice + flx_sen(i) + tw_tnd(i) = flx_vap(i) - flx_cnd(i) *1000._kind_phys ! cummulative tendencies from boundary fluxes - tend%te_tnd(i) = tend%te_tnd(i) + te_tnd(i) - tend%tw_tnd(i) = tend%tw_tnd(i) + tw_tnd(i) + tend_te_tnd(i) = tend_te_tnd(i) + te_tnd(i) + tend_tw_tnd(i) = tend_tw_tnd(i) + tw_tnd(i) ! expected new values from previous state plus boundary fluxes - te_xpd(i) = state%te_cur(i,phys_te_idx) + te_tnd(i)*ztodt - tw_xpd(i) = state%tw_cur(i,phys_te_idx) + tw_tnd(i)*ztodt + te_xpd(i) = te_cur_phys(i) + te_tnd(i)*ztodt + tw_xpd(i) = tw_cur (i) + tw_tnd(i)*ztodt ! relative error, expected value - input state / previous state - te_rer(i) = (te_xpd(i) - te(i)) / state%te_cur(i,phys_te_idx) + te_rer(i) = (te_xpd(i) - te(i)) / te_cur_phys(i) end do ! relative error for total water (allow for dry atmosphere) - tw_rer = 0._r8 - where (state%tw_cur(:ncol,phys_te_idx) > 0._r8) + tw_rer = 0._kind_phys + where (tw_cur(:ncol) > 0._kind_phys) tw_rer(:ncol) = (tw_xpd(:ncol) - tw(:ncol)) / state%tw_cur(:ncol,1) end where ! error checking if (print_energy_errors) then - if (any(abs(te_rer(1:ncol)) > 1.E-14_r8 .or. abs(tw_rer(1:ncol)) > 1.E-10_r8)) then + if (any(abs(te_rer(1:ncol)) > 1.E-14_kind_phys .or. abs(tw_rer(1:ncol)) > 1.E-10_kind_phys)) then do i = 1, ncol ! the relative error threshold for the water budget has been reduced to 1.e-10 ! to avoid messages generated by QNEG3 calls ! PJR- change to identify if error in energy or water - if (abs(te_rer(i)) > 1.E-14_r8 ) then - state%count = state%count + 1 + if (abs(te_rer(i)) > 1.E-14_kind_phys ) then + count = count + 1 write(iulog,*) "significant energy conservation error after ", name, & - " count", state%count, " nstep", nstep, "chunk", lchnk, "col", i - write(iulog,*) te(i),te_xpd(i),te_dif(i),tend%te_tnd(i)*ztodt, & + " count", count, "col", i + write(iulog,*) te(i),te_xpd(i),te_dif(i),tend_te_tnd(i)*ztodt, & te_tnd(i)*ztodt,te_rer(i) endif - if ( abs(tw_rer(i)) > 1.E-10_r8) then - state%count = state%count + 1 + if ( abs(tw_rer(i)) > 1.E-10_kind_phys) then + count = count + 1 write(iulog,*) "significant water conservation error after ", name, & - " count", state%count, " nstep", nstep, "chunk", lchnk, "col", i - write(iulog,*) tw(i),tw_xpd(i),tw_dif(i),tend%tw_tnd(i)*ztodt, & + " count", count, "col", i + write(iulog,*) tw(i),tw_xpd(i),tw_dif(i),tend_tw_tnd(i)*ztodt, & tw_tnd(i)*ztodt,tw_rer(i) end if end do end if end if - ! copy new value to state - + ! WRITE OPERATION - copy new value to state, including total water. + ! the total water operations are consistent regardless of vcoord, so it only has to be written once. do i = 1, ncol - state%te_cur(i,phys_te_idx) = te(i) - state%tw_cur(i,phys_te_idx) = tw(i) + te_cur_phys(i) = te(i) + tw_cur(i) = tw(i) end do - ! - ! Dynamical core total energy - ! - if (vc_dycore == vc_height) then - ! - ! compute cv if vertical coordinate is height: cv = cp - R - ! - ! Note: cp_or_cv set above for pressure coordinate - if (state%psetcols == pcols) then - cp_or_cv(:ncol,:) = cp_or_cv_dycore(:ncol,:,lchnk) - else - cp_or_cv(:ncol,:) = cpair-rair - endif - scaling(:,:) = cpairv(:,:,lchnk)/cp_or_cv(:,:) !cp/cv scaling - temp(1:ncol,:) = state%temp_ini(1:ncol,:)+scaling(1:ncol,:)*(state%T(1:ncol,:)-state%temp_ini(1:ncol,:)) - call get_hydrostatic_energy(state%q(1:ncol,1:pver,1:pcnst),.true., & - state%pdel(1:ncol,1:pver), cp_or_cv(1:ncol,1:pver), & - state%u(1:ncol,1:pver), state%v(1:ncol,1:pver), temp(1:ncol,1:pver), & - vc_dycore, ptop=state%pintdry(1:ncol,1), phis = state%phis(1:ncol), & - z_mid = state%z_ini(1:ncol,:), & - te = state%te_cur(1:ncol,dyn_te_idx), H2O = state%tw_cur(1:ncol,dyn_te_idx)) - else if (vc_dycore == vc_dry_pressure) then - ! - ! SE specific hydrostatic energy - ! - if (state%psetcols == pcols) then - cp_or_cv(:ncol,:) = cp_or_cv_dycore(:ncol,:,lchnk) - scaling(:ncol,:) = cpairv(:ncol,:,lchnk)/cp_or_cv_dycore(:ncol,:,lchnk) - else - cp_or_cv(:ncol,:) = cpair - scaling(:ncol,:) = 1.0_r8 - endif - ! + !------------------------------------------------ + ! Dynamical core total energy. + !------------------------------------------------ + if (vc_dycore == vc_dry_pressure) then + ! SE dycore specific hydrostatic energy + + ! logic for cp_or_cv_dycore and scaling_dycore -- to extract into CAM shim + ! if (state%psetcols == pcols) then + ! cp_or_cv(:ncol,:) = cp_or_cv_dycore(:ncol,:,lchnk) + ! scaling_dycore(:ncol,:) = cpairv(:ncol,:,lchnk)/cp_or_cv_dycore(:ncol,:,lchnk) + ! else + ! cp_or_cv(:ncol,:) = cpair + ! scaling_dycore(:ncol,:) = 1.0_kind_phys + ! endif + ! enthalpy scaling for energy consistency - ! - temp(1:ncol,:) = state%temp_ini(1:ncol,:)+scaling(1:ncol,:)*(state%T(1:ncol,:)-state%temp_ini(1:ncol,:)) - call get_hydrostatic_energy(state%q(1:ncol,1:pver,1:pcnst),.true., & - state%pdel(1:ncol,1:pver), cp_or_cv(1:ncol,1:pver), & - state%u(1:ncol,1:pver), state%v(1:ncol,1:pver), temp(1:ncol,1:pver), & - vc_dry_pressure, ptop=state%pintdry(1:ncol,1), phis = state%phis(1:ncol), & - te = state%te_cur(1:ncol,dyn_te_idx), H2O = state%tw_cur(1:ncol,dyn_te_idx)) + temp(1:ncol,:) = temp_ini(1:ncol,:)+scaling_dycore(1:ncol,:)*(T(1:ncol,:)-temp_ini(1:ncol,:)) + + call get_hydrostatic_energy( & + tracer = q(1:ncol,1:pver,1:pcnst), & ! moist mixing ratios + moist_mixing_ratio = .true., & + pdel_in = pdel (1:ncol,1:pver), & + cp_or_cv = cp_or_cv_dycore(1:ncol,1:pver), & + U = u (1:ncol,1:pver), & + V = v (1:ncol,1:pver), & + T = temp (1:ncol,1:pver), & ! enthalpy-scaled temperature for energy consistency + vcoord = vc_dycore, & ! vertical coordinate for dycore + ptop = pintdry (1:ncol,1), & + phis = phis (1:ncol), & + te = te_cur_dyn (1:ncol) & ! WRITE OPERATION - vertically integrated total energy + ) + + else if (vc_dycore == vc_height) then + ! MPAS dycore: compute cv if vertical coordinate is height: cv = cp - R + + ! logic for cp_or_cv_dycore and scaling_dycore -- to extract into CAM shim + ! Note: cp_or_cv set above for pressure coordinate + ! if (state%psetcols == pcols) then + ! cp_or_cv(:ncol,:) = cp_or_cv_dycore(:ncol,:,lchnk) + ! else + ! cp_or_cv(:ncol,:) = cpair-rair + ! endif + ! scaling(:,:) = cpairv(:,:,lchnk)/cp_or_cv(:,:) !cp/cv scaling + + ! REMOVECAM: note this scaling is different with subcols off/on which is why it was put into separate scheme (hplin, 9/5/24) + temp(1:ncol,:) = temp_ini(1:ncol,:)+scaling_dycore(1:ncol,:)*(T(1:ncol,:)-temp_ini(1:ncol,:)) + + call get_hydrostatic_energy( & + tracer = q(1:ncol,1:pver,1:pcnst), & ! moist mixing ratios + moist_mixing_ratio = .true., & + pdel_in = pdel (1:ncol,1:pver), & + cp_or_cv = cp_or_cv_dycore(1:ncol,1:pver), & + U = u (1:ncol,1:pver), & + V = v (1:ncol,1:pver), & + T = temp (1:ncol,1:pver), & ! enthalpy-scaled temperature for energy consistency + vcoord = vc_dycore, & ! vertical coordinate for dycore + ptop = pintdry (1:ncol,1), & + phis = phis (1:ncol), & + z_mid = z_ini (1:ncol), & ! unique for vc_height (MPAS) + te = te_cur_dyn (1:ncol) & ! WRITE OPERATION - vertically integrated total energy + ) + else - state%te_cur(1:ncol,dyn_te_idx) = te(1:ncol) - state%tw_cur(1:ncol,dyn_te_idx) = tw(1:ncol) + ! FV dycore + te_cur_dyn(1:ncol) = te(1:ncol) end if end subroutine check_energy_chng diff --git a/check_energy/check_energy_chng.meta b/check_energy/check_energy_chng.meta new file mode 100644 index 00000000..2e27ca51 --- /dev/null +++ b/check_energy/check_energy_chng.meta @@ -0,0 +1,396 @@ +[ccpp-table-properties] + name = check_energy_chng + type = scheme + dependencies = ../../data/cam_thermo.F90,../../ + +[ccpp-arg-table] + name = check_energy_chng_timestep_init + type = scheme +[ ncol ] + standard_name = horizontal_loop_extent + units = count + type = integer + dimensions = () + intent = in +[ pver ] + standard_name = vertical_layer_dimension + units = count + type = integer + dimensions = () + intent = in +[ pcnst ] + standard_name = number_of_ccpp_constituents + units = count + type = integer + dimensions = () + intent = in +[ q ] + standard_name = ccpp_constituents + units = none + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent, vertical_layer_dimension, number_of_ccpp_constituents) + intent = in +[ pdel ] + standard_name = air_pressure_thickness + units = Pa + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent, vertical_layer_dimension) + intent = in +[ pdeldry ] + standard_name = air_pressure_thickness_of_dry_air + units = Pa + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent, vertical_layer_dimension) + intent = in +[ u ] + standard_name = eastward_wind + units = m s-1 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent, vertical_layer_dimension) + intent = in +[ v ] + standard_name = northward_wind + units = m s-1 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent, vertical_layer_dimension) + intent = in +[ T ] + standard_name = air_temperature + units = K + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent, vertical_layer_dimension) + intent = in +[ pint ] + standard_name = air_pressure_at_interface + units = Pa + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent, vertical_interface_dimension) + intent = in +[ pintdry ] + standard_name = air_pressure_of_dry_air_at_interface + units = Pa + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent, vertical_interface_dimension) + intent = in +[ phis ] + standard_name = surface_geopotential + units = m2 s-2 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent) + intent = in +[ zm ] + standard_name = geopotential_height_wrt_surface + units = m + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent, vertical_layer_dimension) + intent = in +[ cp_phys ] + standard_name = composition_dependent_specific_heat_of_dry_air_at_constant_pressure + units = J kg-1 K-1 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent, vertical_layer_dimension) + intent = in +[ cp_or_cv_dycore ] + standard_name = enthalpy_or_internal_energy_scaling_factor_for_energy_consistency? + units = J kg-1 K-1 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent, vertical_layer_dimension) + intent = in +[ te_ini_phys ] + standard_name = vertically_integrated_total_energy_of_initial_state_using_physics_energy_formula + units = J m-2 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent) + intent = inout +[ te_ini_dyn ] + standard_name = vertically_integrated_total_energy_of_initial_state_using_dycore_energy_formula + units = J m-2 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent) + intent = inout +[ tw_ini ] + standard_name = vertically_integrated_moist_air_and_condensed_water_of_initial_state + units = kg m-2 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent) + intent = inout +[ te_cur_phys ] + standard_name = vertically_integrated_total_energy_of_current_state_using_physics_energy_formula + units = J m-2 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent) + intent = inout +[ te_cur_dyn ] + standard_name = vertically_integrated_total_energy_of_current_state_using_dycore_energy_formula + units = J m-2 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent) + intent = inout +[ tw_cur ] + standard_name = vertically_integrated_moist_air_and_condensed_water_of_current_state + units = kg m-2 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent) + intent = inout +[ tend_te_tnd ] + standard_name = tendency_of_total_energy? + units = J m-2 s-1 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent) + intent = inout +[ tend_tw_tnd ] + standard_name = tendency_of_total_water? + units = kg m-2 s-1 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent) + intent = inout +[ temp_ini ] + standard_name = temperature_on_current_timestep_for_check_energy? + units = K + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent, vertical_layer_dimension) + intent = in +[ z_ini ] + standard_name = geopotential_height_on_current_timestep_for_check_energy? + units = m + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent, vertical_layer_dimension) + intent = in +[ count ] + standard_name = number_of_values_with_significant_energy_or_water_imbalances? + units = count + type = integer + dimensions = () + intent = inout +[ vc_physics ] + standard_name = vertical_coordinate_for_physics? + units = 1 + type = integer + dimensions = () + intent = in +[ vc_dycore ] + standard_name = vertical_coordinate_for_dynamical_core? + units = 1 + type = integer + dimensions = () + 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 + +[ccpp-arg-table] + name = check_energy_chng_run + type = scheme +[ ncol ] + standard_name = horizontal_loop_extent + units = count + type = integer + dimensions = () + intent = in +[ pver ] + standard_name = vertical_layer_dimension + units = count + type = integer + dimensions = () + intent = in +[ pcnst ] + standard_name = number_of_ccpp_constituents + units = count + type = integer + dimensions = () + intent = in +[ q ] + standard_name = ccpp_constituents + units = none + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent, vertical_layer_dimension, number_of_ccpp_constituents) + intent = in +[ pdel ] + standard_name = air_pressure_thickness + units = Pa + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent, vertical_layer_dimension) + intent = in +[ pdeldry ] + standard_name = air_pressure_thickness_of_dry_air + units = Pa + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent, vertical_layer_dimension) + intent = in +[ u ] + standard_name = eastward_wind + units = m s-1 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent, vertical_layer_dimension) + intent = in +[ v ] + standard_name = northward_wind + units = m s-1 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent, vertical_layer_dimension) + intent = in +[ T ] + standard_name = air_temperature + units = K + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent, vertical_layer_dimension) + intent = in +[ pint ] + standard_name = air_pressure_at_interface + units = Pa + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent, vertical_interface_dimension) + intent = in +[ pintdry ] + standard_name = air_pressure_of_dry_air_at_interface + units = Pa + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent, vertical_interface_dimension) + intent = in +[ phis ] + standard_name = surface_geopotential + units = m2 s-2 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent) + intent = in +[ zm ] + standard_name = geopotential_height_wrt_surface + units = m + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent, vertical_layer_dimension) + intent = in +[ cp_phys ] + standard_name = composition_dependent_specific_heat_of_dry_air_at_constant_pressure + units = J kg-1 K-1 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent, vertical_layer_dimension) + intent = in +[ cp_or_cv_dycore ] + standard_name = enthalpy_or_internal_energy_scaling_factor_for_energy_consistency? + units = J kg-1 K-1 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent, vertical_layer_dimension) + intent = in +[ scaling_dycore ] + standard_name = composition_dependent_ratio_of_specific_heat_of_dry_air_at_constant_pressure_to_enthalpy_or_internal_energy_scaling_factor_for_energy_consistency? + units = 1 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent, vertical_layer_dimension) + intent = in +[ te_cur_phys ] + standard_name = vertically_integrated_total_energy_of_current_state_using_physics_energy_formula + units = J m-2 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent) + intent = inout +[ te_cur_dyn ] + standard_name = vertically_integrated_total_energy_of_current_state_using_dycore_energy_formula + units = J m-2 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent) + intent = inout +[ tw_cur ] + standard_name = vertically_integrated_moist_air_and_condensed_water_of_current_state + units = kg m-2 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent) + intent = inout +[ tend_te_tnd ] + standard_name = tendency_of_total_energy? + units = J m-2 s-1 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent) + intent = inout +[ tend_tw_tnd ] + standard_name = tendency_of_total_water? + units = kg m-2 s-1 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent) + intent = inout +[ temp_ini ] + standard_name = temperature_on_current_timestep_for_check_energy? + units = K + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent, vertical_layer_dimension) + intent = in +[ z_ini ] + standard_name = geopotential_height_on_current_timestep_for_check_energy? + units = m + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent, vertical_layer_dimension) + intent = in +[ count ] + standard_name = number_of_values_with_significant_energy_or_water_imbalances? + units = count + type = integer + dimensions = () + intent = inout +[ ztodt ] + standard_name = timestep_for_physics + units = s + type = real | kind = kind_phys + dimensions = () + intent = in +[ vc_physics ] + standard_name = vertical_coordinate_for_physics? + units = 1 + type = integer + dimensions = () + intent = in +[ vc_dycore ] + standard_name = vertical_coordinate_for_dynamical_core? + units = 1 + type = integer + dimensions = () + intent = in +[ name ] + standard_name = scheme_name + units = none + type = character | kind = len=* + dimensions = () + intent = in +[ flx_vap ] + standard_name = flux_of_vapor_at_surface_due_to_scheme? + units = kg m-2 s-1 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent) + intent = in +[ flx_cnd ] + standard_name = flux_of_liquid_and_ice_at_surface_due_to_scheme? + units = m s-1 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent) + intent = in +[ flx_ice ] + standard_name = flux_of_ice_at_surface_due_to_scheme? + units = m s-1 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent) + intent = in +[ flx_sen ] + standard_name = flux_of_sensible_heat_at_surface_due_to_scheme? + 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 diff --git a/check_energy/check_energy_scaling.F90 b/check_energy/check_energy_scaling.F90 new file mode 100644 index 00000000..a5d9a948 --- /dev/null +++ b/check_energy/check_energy_scaling.F90 @@ -0,0 +1,43 @@ +module check_energy_scaling + use ccpp_kinds, only: kind_phys + + implicit none + private + + public :: check_energy_scaling_run + +contains + + ! CCPP routine to get scaling factor for conversion of temperature increment. + ! This is extracted to a separate subroutine so that scaling_dycore can be passed + ! directly to the CCPP-ized check_energy_chng_run subroutine from CAM with subcolumns. + ! + ! When subcolumns are removed from CAM, this dummy scheme can be removed, and + ! scaling_dycore can just be calculated in check_energy_chng. (hplin, 9/5/24) +!> \section arg_table_check_energy_scaling_run Argument Table +!! \htmlinclude arg_table_check_energy_scaling_run.html + subroutine check_energy_scaling_run( & + ncol, pver, & + cp_or_cv_dycore, cpairv, & + scaling_dycore, & + errmsg, errflg) + + ! Input arguments + integer, intent(in) :: ncol ! number of atmospheric columns + integer, intent(in) :: pver ! number of vertical layers + real(kind_phys), intent(in) :: cp_or_cv_dycore(:,:) ! cp or cv from dycore [J kg-1 K-1] + real(kind_phys), intent(in) :: cpairv(:,:) ! specific heat of dry air at constant pressure [J kg-1 K-1] + + ! Output arguments + real(kind_phys), intent(out) :: scaling_dycore(:,:) ! scaling for conversion of temperature increment [1] + character(len=512), intent(out) :: errmsg + integer, intent(out) :: errflg + + errmsg = '' + errflg = 0 + + scaling_dycore(:ncol,:) = cpairv(:ncol,:) / cp_or_cv_dycore(:ncol,:) + + end subroutine check_energy_scaling_run + +end module check_energy_scaling diff --git a/check_energy/check_energy_scaling.meta b/check_energy/check_energy_scaling.meta new file mode 100644 index 00000000..53e5907c --- /dev/null +++ b/check_energy/check_energy_scaling.meta @@ -0,0 +1,49 @@ +[ccpp-table-properties] + name = check_energy_scaling + type = scheme + +[ccpp-arg-table] + name = check_energy_scaling_run + type = scheme +[ ncol ] + standard_name = horizontal_loop_extent + units = count + type = integer + dimensions = () + intent = in +[ pver ] + standard_name = vertical_layer_dimension + units = count + type = integer + dimensions = () + intent = in +[ cp_or_cv_dycore ] + standard_name = enthalpy_or_internal_energy_scaling_factor_for_energy_consistency? + units = J kg-1 K-1 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent, vertical_layer_dimension) + intent = in +[ cpairv ] + standard_name = composition_dependent_specific_heat_of_dry_air_at_constant_pressure + units = J kg-1 K-1 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent, vertical_layer_dimension) + intent = in +[ scaling_dycore ] + standard_name = composition_dependent_ratio_of_specific_heat_of_dry_air_at_constant_pressure_to_enthalpy_or_internal_energy_scaling_factor_for_energy_consistency? + units = 1 + 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 From cb77ae84d44bca0e89c10abedd169a495ec71f80 Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Mon, 9 Sep 2024 23:12:43 -0400 Subject: [PATCH 03/41] Cleanup arguments; fix compile issues; remove commented out CAM shim code --- check_energy/check_energy_chng.F90 | 80 ++++++++++------------------- check_energy/check_energy_chng.meta | 46 ++++++----------- 2 files changed, 44 insertions(+), 82 deletions(-) diff --git a/check_energy/check_energy_chng.F90 b/check_energy/check_energy_chng.F90 index 87db49d9..590b4410 100644 --- a/check_energy/check_energy_chng.F90 +++ b/check_energy/check_energy_chng.F90 @@ -22,9 +22,9 @@ module check_energy_chng !! \htmlinclude arg_table_check_energy_chng_timestep_init.html subroutine check_energy_chng_timestep_init( & ncol, pver, pcnst, & - q, pdel, pdeldry, & + q, pdel, & u, v, T, & - pint, pintdry, phis, zm, & + pintdry, phis, zm, & cp_phys, & ! cpairv generally, cpair fixed size for subcolumns code cp_or_cv_dycore, & te_ini_phys, te_ini_dyn, & @@ -37,9 +37,11 @@ subroutine check_energy_chng_timestep_init( & vc_physics, vc_dycore, & errmsg, errflg) + ! Dependency for hydrostatic energy calculation (physics and dycore formulas) use cam_thermo, only: get_hydrostatic_energy + + ! FIXME: Flags for vertical coordinate used in physics/dycore use dyn_tests_utils, only: vc_height, vc_dry_pressure - use physics_types, only: phys_te_idx, dyn_te_idx ! Input arguments integer, intent(in) :: ncol ! number of atmospheric columns @@ -47,21 +49,24 @@ subroutine check_energy_chng_timestep_init( & integer, intent(in) :: pcnst ! number of ccpp constituents real(kind_phys), intent(in) :: q(:,:,:) ! constituent mass mixing ratios [kg kg-1] real(kind_phys), intent(in) :: pdel(:,:) ! layer thickness [Pa] - real(kind_phys), intent(in) :: pdeldry(:,:) ! dry air layer thickness [Pa] real(kind_phys), intent(in) :: u(:,:) ! zonal wind [m s-1] real(kind_phys), intent(in) :: v(:,:) ! meridional wind [m s-1] real(kind_phys), intent(in) :: T(:,:) ! temperature [K] - real(kind_phys), intent(in) :: pint(:,:) ! interface pressure [Pa] - real(kind_phys), intent(in) :: pintdry(:) ! interface pressure dry [Pa] + real(kind_phys), intent(in) :: pintdry(:,:) ! interface pressure dry [Pa] real(kind_phys), intent(in) :: phis(:) ! surface geopotential [m2 s-2] real(kind_phys), intent(in) :: zm(:,:) ! geopotential height at layer midpoints [m] - real(kind_phys), intent(in) :: temp_ini(:,:) ! initial temperature [K] - real(kind_phys), intent(in) :: z_ini(:,:) ! initial geopotential height [m] real(kind_phys), intent(in) :: cp_phys(:,:) ! enthalpy (cpairv generally) [J kg-1 K-1] real(kind_phys), intent(in) :: cp_or_cv_dycore(:,:) ! enthalpy or heat capacity, dycore dependent [J K-1 kg-1] integer, intent(in) :: vc_physics ! vertical coordinate system, physics integer, intent(in) :: vc_dycore ! vertical coordinate system, dycore + ! Output arguments + real(kind_phys), intent(out) :: temp_ini(:,:) ! initial temperature [K] + real(kind_phys), intent(out) :: z_ini(:,:) ! initial geopotential height [m] + integer, intent(out) :: count ! count of values with significant energy or water imbalances [1] + real(kind_phys), intent(out) :: tend_te_tnd(:) ! total energy tendency [J m-2 s-1] + real(kind_phys), intent(out) :: tend_tw_tnd(:) ! total water tendency [kg m-2 s-1] + ! Input/Output arguments real(kind_phys), intent(inout) :: te_ini_phys(:) ! physics formula: initial total energy [J m-2] real(kind_phys), intent(inout) :: te_ini_dyn (:) ! dycore formula: initial total energy [J m-2] @@ -69,9 +74,6 @@ subroutine check_energy_chng_timestep_init( & real(kind_phys), intent(inout) :: te_cur_phys(:) ! physics formula: current total energy [J m-2] real(kind_phys), intent(inout) :: te_cur_dyn (:) ! dycore formula: current total energy [J m-2] real(kind_phys), intent(inout) :: tw_cur (:) ! current total water [kg m-2] - integer, intent(inout) :: count ! count of values with significant energy or water imbalances [1] - real(kind_phys), intent(inout) :: tend_te_tnd(:) ! total energy tendency [J m-2 s-1] - real(kind_phys), intent(inout) :: tend_tw_tnd(:) ! total water tendency [kg m-2 s-1] ! Output arguments character(len=512), intent(out) :: errmsg ! error message @@ -92,7 +94,7 @@ subroutine check_energy_chng_timestep_init( & ptop = pintdry (1:ncol,1), & phis = phis (1:ncol), & te = te_ini_phys(1:ncol), & ! vertically integrated total energy - H2O = tw_ini (1:ncol), & ! v.i. total water + H2O = tw_ini (1:ncol) & ! v.i. total water ) ! Save initial state temperature and geopotential height for use in run phase @@ -131,7 +133,7 @@ subroutine check_energy_chng_timestep_init( & vcoord = vc_dycore, & ! vertical coordinate for dycore ptop = pintdry (1:ncol,1), & phis = phis (1:ncol), & - z_mid = z_ini (1:ncol), & ! unique for vc_height (MPAS) + z_mid = z_ini (1:ncol,:), & ! unique for vc_height (MPAS) te = te_ini_dyn (1:ncol) & ! WRITE OPERATION - vertically integrated total energy ) else @@ -159,9 +161,9 @@ end subroutine check_energy_chng_timestep_init !! \htmlinclude arg_table_check_energy_chng_run.html subroutine check_energy_chng_run( & ncol, pver, pcnst, & - q, pdel, pdeldry, & + q, pdel, & u, v, T, & - pint, pintdry, phis, zm, & + pintdry, phis, zm, & cp_phys, & ! cpairv generally, cpair fixed size for subcolumns code cp_or_cv_dycore, & scaling_dycore, & ! From check_energy_scaling to work around subcolumns code @@ -170,13 +172,16 @@ subroutine check_energy_chng_run( & tend_te_tnd, tend_tw_tnd, & temp_ini, z_ini, & count, ztodt, & + latice, latvap, & vc_physics, vc_dycore, & name, flx_vap, flx_cnd, flx_ice, flx_sen, & errmsg, errflg) + ! Dependency for hydrostatic energy calculation (physics and dycore formulas) use cam_thermo, only: get_hydrostatic_energy + + ! FIXME: Flags for vertical coordinate used in physics/dycore use dyn_tests_utils, only: vc_height, vc_dry_pressure - use physics_types, only: phys_te_idx, dyn_te_idx ! Input arguments integer, intent(in) :: ncol ! number of atmospheric columns @@ -184,12 +189,10 @@ subroutine check_energy_chng_run( & integer, intent(in) :: pcnst ! number of ccpp constituents real(kind_phys), intent(in) :: q(:,:,:) ! constituent mass mixing ratios [kg kg-1] real(kind_phys), intent(in) :: pdel(:,:) ! layer thickness [Pa] - real(kind_phys), intent(in) :: pdeldry(:,:) ! dry air layer thickness [Pa] real(kind_phys), intent(in) :: u(:,:) ! zonal wind [m s-1] real(kind_phys), intent(in) :: v(:,:) ! meridional wind [m s-1] real(kind_phys), intent(in) :: T(:,:) ! temperature [K] - real(kind_phys), intent(in) :: pint(:,:) ! interface pressure [Pa] - real(kind_phys), intent(in) :: pintdry(:) ! interface pressure dry [Pa] + real(kind_phys), intent(in) :: pintdry(:,:) ! interface pressure dry [Pa] real(kind_phys), intent(in) :: phis(:) ! surface geopotential [m2 s-2] real(kind_phys), intent(in) :: zm(:,:) ! geopotential height at layer midpoints [m] real(kind_phys), intent(in) :: temp_ini(:,:) ! initial temperature [K] @@ -198,6 +201,8 @@ subroutine check_energy_chng_run( & real(kind_phys), intent(in) :: cp_or_cv_dycore(:,:) ! enthalpy or heat capacity, dycore dependent [J K-1 kg-1] real(kind_phys), intent(in) :: scaling_dycore(:,:) ! scaling for conversion of temperature increment [1] real(kind_phys), intent(in) :: ztodt ! 2 delta t (model time increment) [s] + real(kind_phys), intent(in) :: latice ! constant, latent heat of fusion of water at 0 C [J kg-1] + real(kind_phys), intent(in) :: latvap ! constant, latent heat of vaporization of water at 0 C [J kg-1] integer, intent(in) :: vc_physics ! vertical coordinate system, physics integer, intent(in) :: vc_dycore ! vertical coordinate system, dycore @@ -252,19 +257,6 @@ subroutine check_energy_chng_run( & real(kind_phys) :: ice(ncol) ! column integrated ice (kg/m2) integer :: i -!----------------------------------------------------------------------- - - ! If psetcols == pcols, cpairv is the correct size and just copy into cp_or_cv - ! If psetcols > pcols and all cpairv match cpair, then assign the constant cpair - - ! below to be passed to cp_phys: - ! if (state%psetcols == pcols) then - ! cp_or_cv(:,:) = cpairv(:,:,lchnk) - ! else if (state%psetcols > pcols .and. all(cpairv(:,:,:) == cpair)) then - ! cp_or_cv(:,:) = cpair - ! else - ! call endrun('check_energy_chng: cpairv is not allowed to vary when subcolumns are turned on') - ! end if !------------------------------------------------ ! Physics total energy. @@ -315,7 +307,7 @@ subroutine check_energy_chng_run( & ! relative error for total water (allow for dry atmosphere) tw_rer = 0._kind_phys where (tw_cur(:ncol) > 0._kind_phys) - tw_rer(:ncol) = (tw_xpd(:ncol) - tw(:ncol)) / state%tw_cur(:ncol,1) + tw_rer(:ncol) = (tw_xpd(:ncol) - tw(:ncol)) / tw_cur(:ncol) end where ! error checking @@ -356,15 +348,6 @@ subroutine check_energy_chng_run( & if (vc_dycore == vc_dry_pressure) then ! SE dycore specific hydrostatic energy - ! logic for cp_or_cv_dycore and scaling_dycore -- to extract into CAM shim - ! if (state%psetcols == pcols) then - ! cp_or_cv(:ncol,:) = cp_or_cv_dycore(:ncol,:,lchnk) - ! scaling_dycore(:ncol,:) = cpairv(:ncol,:,lchnk)/cp_or_cv_dycore(:ncol,:,lchnk) - ! else - ! cp_or_cv(:ncol,:) = cpair - ! scaling_dycore(:ncol,:) = 1.0_kind_phys - ! endif - ! enthalpy scaling for energy consistency temp(1:ncol,:) = temp_ini(1:ncol,:)+scaling_dycore(1:ncol,:)*(T(1:ncol,:)-temp_ini(1:ncol,:)) @@ -385,15 +368,6 @@ subroutine check_energy_chng_run( & else if (vc_dycore == vc_height) then ! MPAS dycore: compute cv if vertical coordinate is height: cv = cp - R - ! logic for cp_or_cv_dycore and scaling_dycore -- to extract into CAM shim - ! Note: cp_or_cv set above for pressure coordinate - ! if (state%psetcols == pcols) then - ! cp_or_cv(:ncol,:) = cp_or_cv_dycore(:ncol,:,lchnk) - ! else - ! cp_or_cv(:ncol,:) = cpair-rair - ! endif - ! scaling(:,:) = cpairv(:,:,lchnk)/cp_or_cv(:,:) !cp/cv scaling - ! REMOVECAM: note this scaling is different with subcols off/on which is why it was put into separate scheme (hplin, 9/5/24) temp(1:ncol,:) = temp_ini(1:ncol,:)+scaling_dycore(1:ncol,:)*(T(1:ncol,:)-temp_ini(1:ncol,:)) @@ -408,7 +382,7 @@ subroutine check_energy_chng_run( & vcoord = vc_dycore, & ! vertical coordinate for dycore ptop = pintdry (1:ncol,1), & phis = phis (1:ncol), & - z_mid = z_ini (1:ncol), & ! unique for vc_height (MPAS) + z_mid = z_ini (1:ncol,:), & ! unique for vc_height (MPAS) te = te_cur_dyn (1:ncol) & ! WRITE OPERATION - vertically integrated total energy ) @@ -416,6 +390,6 @@ subroutine check_energy_chng_run( & ! FV dycore te_cur_dyn(1:ncol) = te(1:ncol) end if - end subroutine check_energy_chng + end subroutine check_energy_chng_run end module check_energy_chng \ No newline at end of file diff --git a/check_energy/check_energy_chng.meta b/check_energy/check_energy_chng.meta index 2e27ca51..c8d3e2e1 100644 --- a/check_energy/check_energy_chng.meta +++ b/check_energy/check_energy_chng.meta @@ -36,12 +36,6 @@ type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = in -[ pdeldry ] - standard_name = air_pressure_thickness_of_dry_air - units = Pa - type = real | kind = kind_phys - dimensions = (horizontal_loop_extent, vertical_layer_dimension) - intent = in [ u ] standard_name = eastward_wind units = m s-1 @@ -60,12 +54,6 @@ type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = in -[ pint ] - standard_name = air_pressure_at_interface - units = Pa - type = real | kind = kind_phys - dimensions = (horizontal_loop_extent, vertical_interface_dimension) - intent = in [ pintdry ] standard_name = air_pressure_of_dry_air_at_interface units = Pa @@ -137,31 +125,31 @@ units = J m-2 s-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) - intent = inout + intent = out [ tend_tw_tnd ] standard_name = tendency_of_total_water? units = kg m-2 s-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) - intent = inout + intent = out [ temp_ini ] standard_name = temperature_on_current_timestep_for_check_energy? units = K type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) - intent = in + intent = out [ z_ini ] standard_name = geopotential_height_on_current_timestep_for_check_energy? units = m type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) - intent = in + intent = out [ count ] standard_name = number_of_values_with_significant_energy_or_water_imbalances? units = count type = integer dimensions = () - intent = inout + intent = out [ vc_physics ] standard_name = vertical_coordinate_for_physics? units = 1 @@ -220,12 +208,6 @@ type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = in -[ pdeldry ] - standard_name = air_pressure_thickness_of_dry_air - units = Pa - type = real | kind = kind_phys - dimensions = (horizontal_loop_extent, vertical_layer_dimension) - intent = in [ u ] standard_name = eastward_wind units = m s-1 @@ -244,12 +226,6 @@ type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = in -[ pint ] - standard_name = air_pressure_at_interface - units = Pa - type = real | kind = kind_phys - dimensions = (horizontal_loop_extent, vertical_interface_dimension) - intent = in [ pintdry ] standard_name = air_pressure_of_dry_air_at_interface units = Pa @@ -340,6 +316,18 @@ type = real | kind = kind_phys dimensions = () intent = in +[ latice ] + standard_name = latent_heat_of_fusion_of_water_at_0c + units = J kg-1 + type = real | kind = kind_phys + dimensions = () + intent = in +[ latvap ] + standard_name = latent_heat_of_vaporization_of_water_at_0c + units = J kg-1 + type = real | kind = kind_phys + dimensions = () + intent = in [ vc_physics ] standard_name = vertical_coordinate_for_physics? units = 1 From 5c67d4bf7d51167c354fc23ebbb85d14706a6413 Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Wed, 11 Sep 2024 22:25:27 -0400 Subject: [PATCH 04/41] Stub for zero fluxes before going into check_energy_chng --- check_energy/check_energy_zero_fluxes.F90 | 31 +++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 check_energy/check_energy_zero_fluxes.F90 diff --git a/check_energy/check_energy_zero_fluxes.F90 b/check_energy/check_energy_zero_fluxes.F90 new file mode 100644 index 00000000..bfb1f853 --- /dev/null +++ b/check_energy/check_energy_zero_fluxes.F90 @@ -0,0 +1,31 @@ +! zeros input fluxes to check_energy +! before running other schemes +module check_energy_zero_fluxes + + use ccpp_kinds, only: kind_phys + + implicit none + private + + public :: check_energy_zero_fluxes_run + +contains + +!> \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(name, flx_vap, flx_cnd, flx_ice, flx_sen) + character(len=*), intent(out) :: name ! parameterization name for fluxes + real(kind_phys), intent(out) :: flx_vap(:) ! boundary flux of vapor [kg m-2 s-1] + 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] + + ! reset values to zero + name = '' + flx_vap(:) = 0._kind_phys + flx_cnd(:) = 0._kind_phys + flx_ice(:) = 0._kind_phys + flx_sen(:) = 0._kind_phys + end subroutine check_energy_zero_fluxes_run + +end module check_energy_zero_fluxes \ No newline at end of file From dd1a8133f5ce318160d069ec8ddb6db8754ddea6 Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Thu, 12 Sep 2024 14:39:07 -0400 Subject: [PATCH 05/41] Add stub to zero fluxes; test SDF --- check_energy/check_energy_zero_fluxes.meta | 37 ++++++++++++++++++++ test/test_suites/suite_check_energy_chng.xml | 10 ++++++ 2 files changed, 47 insertions(+) create mode 100644 check_energy/check_energy_zero_fluxes.meta create mode 100644 test/test_suites/suite_check_energy_chng.xml diff --git a/check_energy/check_energy_zero_fluxes.meta b/check_energy/check_energy_zero_fluxes.meta new file mode 100644 index 00000000..32132354 --- /dev/null +++ b/check_energy/check_energy_zero_fluxes.meta @@ -0,0 +1,37 @@ +[ccpp-table-properties] + name = check_energy_zero_fluxes + type = scheme + +[ccpp-arg-table] + name = check_energy_zero_fluxes_run + type = scheme +[ name ] + standard_name = scheme_name + units = none + type = character | kind = len=* + dimensions = () + intent = out +[ flx_vap ] + standard_name = flux_of_vapor_at_surface_due_to_scheme? + units = kg m-2 s-1 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent) + intent = out +[ flx_cnd ] + standard_name = flux_of_liquid_and_ice_at_surface_due_to_scheme? + units = m s-1 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent) + intent = out +[ flx_ice ] + standard_name = flux_of_ice_at_surface_due_to_scheme? + units = m s-1 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent) + intent = out +[ flx_sen ] + standard_name = flux_of_sensible_heat_at_surface_due_to_scheme? + units = W m-2 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent) + intent = out \ No newline at end of file diff --git a/test/test_suites/suite_check_energy_chng.xml b/test/test_suites/suite_check_energy_chng.xml new file mode 100644 index 00000000..d3a3c512 --- /dev/null +++ b/test/test_suites/suite_check_energy_chng.xml @@ -0,0 +1,10 @@ + + + + + + check_energy_zero_fluxes + check_energy_scaling + check_energy_chng + + From b54964cba3339305bf8e0cbe75ff1265f2b7b52a Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Thu, 12 Sep 2024 14:55:00 -0400 Subject: [PATCH 06/41] Update placeholders for undecided standard names --- check_energy/check_energy_chng.meta | 42 +++++++++++----------- check_energy/check_energy_scaling.meta | 4 +-- check_energy/check_energy_zero_fluxes.meta | 8 ++--- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/check_energy/check_energy_chng.meta b/check_energy/check_energy_chng.meta index c8d3e2e1..de4f5449 100644 --- a/check_energy/check_energy_chng.meta +++ b/check_energy/check_energy_chng.meta @@ -79,7 +79,7 @@ dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = in [ cp_or_cv_dycore ] - standard_name = enthalpy_or_internal_energy_scaling_factor_for_energy_consistency? + standard_name = enthalpy_or_internal_energy_scaling_factor_for_energy_consistency_TBD units = J kg-1 K-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) @@ -121,43 +121,43 @@ dimensions = (horizontal_loop_extent) intent = inout [ tend_te_tnd ] - standard_name = tendency_of_total_energy? + standard_name = tendency_of_total_energy_TBD units = J m-2 s-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) intent = out [ tend_tw_tnd ] - standard_name = tendency_of_total_water? + standard_name = tendency_of_total_water_TBD units = kg m-2 s-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) intent = out [ temp_ini ] - standard_name = temperature_on_current_timestep_for_check_energy? + standard_name = temperature_on_current_timestep_for_check_energy_TBD units = K type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = out [ z_ini ] - standard_name = geopotential_height_on_current_timestep_for_check_energy? + standard_name = geopotential_height_on_current_timestep_for_check_energy_TBD units = m type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = out [ count ] - standard_name = number_of_values_with_significant_energy_or_water_imbalances? + standard_name = number_of_values_with_significant_energy_or_water_imbalances_TBD units = count type = integer dimensions = () intent = out [ vc_physics ] - standard_name = vertical_coordinate_for_physics? + standard_name = vertical_coordinate_for_physics_TBD units = 1 type = integer dimensions = () intent = in [ vc_dycore ] - standard_name = vertical_coordinate_for_dynamical_core? + standard_name = vertical_coordinate_for_dynamical_core_TBD units = 1 type = integer dimensions = () @@ -251,13 +251,13 @@ dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = in [ cp_or_cv_dycore ] - standard_name = enthalpy_or_internal_energy_scaling_factor_for_energy_consistency? + standard_name = enthalpy_or_internal_energy_scaling_factor_for_energy_consistency_TBD units = J kg-1 K-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = in [ scaling_dycore ] - standard_name = composition_dependent_ratio_of_specific_heat_of_dry_air_at_constant_pressure_to_enthalpy_or_internal_energy_scaling_factor_for_energy_consistency? + standard_name = composition_dependent_ratio_of_specific_heat_of_dry_air_at_constant_pressure_to_enthalpy_or_internal_energy_scaling_factor_for_energy_consistency_TBD units = 1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) @@ -281,31 +281,31 @@ dimensions = (horizontal_loop_extent) intent = inout [ tend_te_tnd ] - standard_name = tendency_of_total_energy? + standard_name = tendency_of_total_energy_TBD units = J m-2 s-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) intent = inout [ tend_tw_tnd ] - standard_name = tendency_of_total_water? + standard_name = tendency_of_total_water_TBD units = kg m-2 s-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) intent = inout [ temp_ini ] - standard_name = temperature_on_current_timestep_for_check_energy? + standard_name = temperature_on_current_timestep_for_check_energy_TBD units = K type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = in [ z_ini ] - standard_name = geopotential_height_on_current_timestep_for_check_energy? + standard_name = geopotential_height_on_current_timestep_for_check_energy_TBD units = m type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = in [ count ] - standard_name = number_of_values_with_significant_energy_or_water_imbalances? + standard_name = number_of_values_with_significant_energy_or_water_imbalances_TBD units = count type = integer dimensions = () @@ -329,13 +329,13 @@ dimensions = () intent = in [ vc_physics ] - standard_name = vertical_coordinate_for_physics? + standard_name = vertical_coordinate_for_physics_TBD units = 1 type = integer dimensions = () intent = in [ vc_dycore ] - standard_name = vertical_coordinate_for_dynamical_core? + standard_name = vertical_coordinate_for_dynamical_core_TBD units = 1 type = integer dimensions = () @@ -347,25 +347,25 @@ dimensions = () intent = in [ flx_vap ] - standard_name = flux_of_vapor_at_surface_due_to_scheme? + standard_name = flux_of_vapor_at_surface_due_to_scheme_TBD units = kg m-2 s-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) intent = in [ flx_cnd ] - standard_name = flux_of_liquid_and_ice_at_surface_due_to_scheme? + standard_name = flux_of_liquid_and_ice_at_surface_due_to_scheme_TBD units = m s-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) intent = in [ flx_ice ] - standard_name = flux_of_ice_at_surface_due_to_scheme? + standard_name = flux_of_ice_at_surface_due_to_scheme_TBD units = m s-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) intent = in [ flx_sen ] - standard_name = flux_of_sensible_heat_at_surface_due_to_scheme? + standard_name = flux_of_sensible_heat_at_surface_due_to_scheme_TBD units = W m-2 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) diff --git a/check_energy/check_energy_scaling.meta b/check_energy/check_energy_scaling.meta index 53e5907c..f0b701cf 100644 --- a/check_energy/check_energy_scaling.meta +++ b/check_energy/check_energy_scaling.meta @@ -18,7 +18,7 @@ dimensions = () intent = in [ cp_or_cv_dycore ] - standard_name = enthalpy_or_internal_energy_scaling_factor_for_energy_consistency? + standard_name = enthalpy_or_internal_energy_scaling_factor_for_energy_consistency_TBD units = J kg-1 K-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) @@ -30,7 +30,7 @@ dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = in [ scaling_dycore ] - standard_name = composition_dependent_ratio_of_specific_heat_of_dry_air_at_constant_pressure_to_enthalpy_or_internal_energy_scaling_factor_for_energy_consistency? + standard_name = composition_dependent_ratio_of_specific_heat_of_dry_air_at_constant_pressure_to_enthalpy_or_internal_energy_scaling_factor_for_energy_consistency_TBD units = 1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) diff --git a/check_energy/check_energy_zero_fluxes.meta b/check_energy/check_energy_zero_fluxes.meta index 32132354..cd0ed4c2 100644 --- a/check_energy/check_energy_zero_fluxes.meta +++ b/check_energy/check_energy_zero_fluxes.meta @@ -12,25 +12,25 @@ dimensions = () intent = out [ flx_vap ] - standard_name = flux_of_vapor_at_surface_due_to_scheme? + standard_name = flux_of_vapor_at_surface_due_to_scheme_TBD units = kg m-2 s-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) intent = out [ flx_cnd ] - standard_name = flux_of_liquid_and_ice_at_surface_due_to_scheme? + standard_name = flux_of_liquid_and_ice_at_surface_due_to_scheme_TBD units = m s-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) intent = out [ flx_ice ] - standard_name = flux_of_ice_at_surface_due_to_scheme? + standard_name = flux_of_ice_at_surface_due_to_scheme_TBD units = m s-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) intent = out [ flx_sen ] - standard_name = flux_of_sensible_heat_at_surface_due_to_scheme? + standard_name = flux_of_sensible_heat_at_surface_due_to_scheme_TBD units = W m-2 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) From e30c70c59b71b13dc50abb7edd3e1299f2bf85e6 Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Thu, 12 Sep 2024 15:49:50 -0400 Subject: [PATCH 07/41] Remove horizontal_loop_extent from timestep_init phase as disallowed --- check_energy/check_energy_chng.meta | 42 ++++++++++++++--------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/check_energy/check_energy_chng.meta b/check_energy/check_energy_chng.meta index de4f5449..8d96d1f9 100644 --- a/check_energy/check_energy_chng.meta +++ b/check_energy/check_energy_chng.meta @@ -7,7 +7,7 @@ name = check_energy_chng_timestep_init type = scheme [ ncol ] - standard_name = horizontal_loop_extent + standard_name = horizontal_dimension units = count type = integer dimensions = () @@ -28,121 +28,121 @@ standard_name = ccpp_constituents units = none type = real | kind = kind_phys - dimensions = (horizontal_loop_extent, vertical_layer_dimension, number_of_ccpp_constituents) + dimensions = (horizontal_dimension, vertical_layer_dimension, number_of_ccpp_constituents) intent = in [ pdel ] standard_name = air_pressure_thickness units = Pa type = real | kind = kind_phys - dimensions = (horizontal_loop_extent, vertical_layer_dimension) + dimensions = (horizontal_dimension, vertical_layer_dimension) intent = in [ u ] standard_name = eastward_wind units = m s-1 type = real | kind = kind_phys - dimensions = (horizontal_loop_extent, vertical_layer_dimension) + dimensions = (horizontal_dimension, vertical_layer_dimension) intent = in [ v ] standard_name = northward_wind units = m s-1 type = real | kind = kind_phys - dimensions = (horizontal_loop_extent, vertical_layer_dimension) + dimensions = (horizontal_dimension, vertical_layer_dimension) intent = in [ T ] standard_name = air_temperature units = K type = real | kind = kind_phys - dimensions = (horizontal_loop_extent, vertical_layer_dimension) + dimensions = (horizontal_dimension, vertical_layer_dimension) intent = in [ pintdry ] standard_name = air_pressure_of_dry_air_at_interface units = Pa type = real | kind = kind_phys - dimensions = (horizontal_loop_extent, vertical_interface_dimension) + dimensions = (horizontal_dimension, vertical_interface_dimension) intent = in [ phis ] standard_name = surface_geopotential units = m2 s-2 type = real | kind = kind_phys - dimensions = (horizontal_loop_extent) + dimensions = (horizontal_dimension) intent = in [ zm ] standard_name = geopotential_height_wrt_surface units = m type = real | kind = kind_phys - dimensions = (horizontal_loop_extent, vertical_layer_dimension) + dimensions = (horizontal_dimension, vertical_layer_dimension) intent = in [ cp_phys ] standard_name = composition_dependent_specific_heat_of_dry_air_at_constant_pressure units = J kg-1 K-1 type = real | kind = kind_phys - dimensions = (horizontal_loop_extent, vertical_layer_dimension) + dimensions = (horizontal_dimension, vertical_layer_dimension) intent = in [ cp_or_cv_dycore ] standard_name = enthalpy_or_internal_energy_scaling_factor_for_energy_consistency_TBD units = J kg-1 K-1 type = real | kind = kind_phys - dimensions = (horizontal_loop_extent, vertical_layer_dimension) + dimensions = (horizontal_dimension, vertical_layer_dimension) intent = in [ te_ini_phys ] standard_name = vertically_integrated_total_energy_of_initial_state_using_physics_energy_formula units = J m-2 type = real | kind = kind_phys - dimensions = (horizontal_loop_extent) + dimensions = (horizontal_dimension) intent = inout [ te_ini_dyn ] standard_name = vertically_integrated_total_energy_of_initial_state_using_dycore_energy_formula units = J m-2 type = real | kind = kind_phys - dimensions = (horizontal_loop_extent) + dimensions = (horizontal_dimension) intent = inout [ tw_ini ] standard_name = vertically_integrated_moist_air_and_condensed_water_of_initial_state units = kg m-2 type = real | kind = kind_phys - dimensions = (horizontal_loop_extent) + dimensions = (horizontal_dimension) intent = inout [ te_cur_phys ] standard_name = vertically_integrated_total_energy_of_current_state_using_physics_energy_formula units = J m-2 type = real | kind = kind_phys - dimensions = (horizontal_loop_extent) + dimensions = (horizontal_dimension) intent = inout [ te_cur_dyn ] standard_name = vertically_integrated_total_energy_of_current_state_using_dycore_energy_formula units = J m-2 type = real | kind = kind_phys - dimensions = (horizontal_loop_extent) + dimensions = (horizontal_dimension) intent = inout [ tw_cur ] standard_name = vertically_integrated_moist_air_and_condensed_water_of_current_state units = kg m-2 type = real | kind = kind_phys - dimensions = (horizontal_loop_extent) + dimensions = (horizontal_dimension) intent = inout [ tend_te_tnd ] standard_name = tendency_of_total_energy_TBD units = J m-2 s-1 type = real | kind = kind_phys - dimensions = (horizontal_loop_extent) + dimensions = (horizontal_dimension) intent = out [ tend_tw_tnd ] standard_name = tendency_of_total_water_TBD units = kg m-2 s-1 type = real | kind = kind_phys - dimensions = (horizontal_loop_extent) + dimensions = (horizontal_dimension) intent = out [ temp_ini ] standard_name = temperature_on_current_timestep_for_check_energy_TBD units = K type = real | kind = kind_phys - dimensions = (horizontal_loop_extent, vertical_layer_dimension) + dimensions = (horizontal_dimension, vertical_layer_dimension) intent = out [ z_ini ] standard_name = geopotential_height_on_current_timestep_for_check_energy_TBD units = m type = real | kind = kind_phys - dimensions = (horizontal_loop_extent, vertical_layer_dimension) + dimensions = (horizontal_dimension, vertical_layer_dimension) intent = out [ count ] standard_name = number_of_values_with_significant_energy_or_water_imbalances_TBD From 29cbd5953c2db4d382b21a000eb7b30df30970da Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Mon, 16 Sep 2024 13:48:22 -0400 Subject: [PATCH 08/41] Update check_energy in preparation for gmean/fix --- check_energy/check_energy_chng.F90 | 27 +++++++---- check_energy/check_energy_chng.meta | 56 +++++++++++++--------- check_energy/check_energy_fix.F90 | 36 ++++++++++++++ check_energy/check_energy_fix.meta | 49 +++++++++++++++++++ check_energy/check_energy_gmean.F90 | 56 ++++++++++++++++++++++ check_energy/check_energy_gmean.meta | 43 +++++++++++++++++ check_energy/check_energy_save_teout.F90 | 32 +++++++++++++ check_energy/check_energy_save_teout.meta | 25 ++++++++++ check_energy/check_energy_scaling.meta | 4 +- check_energy/check_energy_zero_fluxes.F90 | 40 +++++++++------- check_energy/check_energy_zero_fluxes.meta | 14 ++++-- 11 files changed, 327 insertions(+), 55 deletions(-) create mode 100644 check_energy/check_energy_fix.F90 create mode 100644 check_energy/check_energy_fix.meta create mode 100644 check_energy/check_energy_gmean.F90 create mode 100644 check_energy/check_energy_gmean.meta create mode 100644 check_energy/check_energy_save_teout.F90 create mode 100644 check_energy/check_energy_save_teout.meta diff --git a/check_energy/check_energy_chng.F90 b/check_energy/check_energy_chng.F90 index 590b4410..a0f27bf3 100644 --- a/check_energy/check_energy_chng.F90 +++ b/check_energy/check_energy_chng.F90 @@ -1,18 +1,18 @@ module check_energy_chng - use ccpp_kinds, only: kind_phys + use ccpp_kinds, only: kind_phys - ! FIXME hplin: for DEBUG only - use cam_logfile, only: iulog + ! FIXME hplin: for DEBUG only + use cam_logfile, only: iulog - implicit none - private + implicit none + private - public :: check_energy_chng_timestep_init - public :: check_energy_chng_run + public :: check_energy_chng_timestep_init + public :: check_energy_chng_run - ! Private module options. - logical :: print_energy_errors = .false. + ! Private module options. + logical :: print_energy_errors = .false. contains @@ -22,6 +22,7 @@ module check_energy_chng !! \htmlinclude arg_table_check_energy_chng_timestep_init.html subroutine check_energy_chng_timestep_init( & ncol, pver, pcnst, & + is_first_timestep, & q, pdel, & u, v, T, & pintdry, phis, zm, & @@ -34,6 +35,7 @@ subroutine check_energy_chng_timestep_init( & tend_te_tnd, tend_tw_tnd, & temp_ini, z_ini, & count, & + teout, & vc_physics, vc_dycore, & errmsg, errflg) @@ -47,6 +49,7 @@ subroutine check_energy_chng_timestep_init( & integer, intent(in) :: ncol ! number of atmospheric columns integer, intent(in) :: pver ! number of vertical layers integer, intent(in) :: pcnst ! number of ccpp constituents + logical, intent(in) :: is_first_timestep ! is first step of initial run? real(kind_phys), intent(in) :: q(:,:,:) ! constituent mass mixing ratios [kg kg-1] real(kind_phys), intent(in) :: pdel(:,:) ! layer thickness [Pa] real(kind_phys), intent(in) :: u(:,:) ! zonal wind [m s-1] @@ -64,6 +67,7 @@ subroutine check_energy_chng_timestep_init( & real(kind_phys), intent(out) :: temp_ini(:,:) ! initial temperature [K] real(kind_phys), intent(out) :: z_ini(:,:) ! initial geopotential height [m] integer, intent(out) :: count ! count of values with significant energy or water imbalances [1] + real(kind_phys), intent(out) :: teout(:) ! total energy for global fixer in next timestep [J m-2] real(kind_phys), intent(out) :: tend_te_tnd(:) ! total energy tendency [J m-2 s-1] real(kind_phys), intent(out) :: tend_tw_tnd(:) ! total water tendency [kg m-2 s-1] @@ -153,6 +157,11 @@ subroutine check_energy_chng_timestep_init( & tend_te_tnd(:ncol) = 0._kind_phys tend_tw_tnd(:ncol) = 0._kind_phys + ! If first timestep, initialize value of teout + if(is_first_timestep) then + teout(:ncol) = te_ini_dyn(:ncol) + endif + end subroutine check_energy_chng_timestep_init diff --git a/check_energy/check_energy_chng.meta b/check_energy/check_energy_chng.meta index 8d96d1f9..a77b8bf9 100644 --- a/check_energy/check_energy_chng.meta +++ b/check_energy/check_energy_chng.meta @@ -1,7 +1,7 @@ [ccpp-table-properties] name = check_energy_chng type = scheme - dependencies = ../../data/cam_thermo.F90,../../ + dependencies = ../../../data/cam_thermo.F90,../../../dynamics/tests/dyn_tests_utils.F90 [ccpp-arg-table] name = check_energy_chng_timestep_init @@ -24,6 +24,12 @@ type = integer dimensions = () intent = in +[ is_first_timestep ] + standard_name = is_first_timestep + units = flag + type = logical + dimensions = () + intent = in [ q ] standard_name = ccpp_constituents units = none @@ -79,7 +85,7 @@ dimensions = (horizontal_dimension, vertical_layer_dimension) intent = in [ cp_or_cv_dycore ] - standard_name = enthalpy_or_internal_energy_scaling_factor_for_energy_consistency_TBD + standard_name = enthalpy_or_internal_energy_scaling_factor_for_energy_consistency_tbd units = J kg-1 K-1 type = real | kind = kind_phys dimensions = (horizontal_dimension, vertical_layer_dimension) @@ -121,43 +127,49 @@ dimensions = (horizontal_dimension) intent = inout [ tend_te_tnd ] - standard_name = tendency_of_total_energy_TBD + standard_name = tendency_of_total_energy_tbd units = J m-2 s-1 type = real | kind = kind_phys dimensions = (horizontal_dimension) intent = out [ tend_tw_tnd ] - standard_name = tendency_of_total_water_TBD + standard_name = tendency_of_total_water_tbd units = kg m-2 s-1 type = real | kind = kind_phys dimensions = (horizontal_dimension) intent = out [ temp_ini ] - standard_name = temperature_on_current_timestep_for_check_energy_TBD + standard_name = temperature_on_current_timestep_for_check_energy_tbd units = K type = real | kind = kind_phys dimensions = (horizontal_dimension, vertical_layer_dimension) intent = out [ z_ini ] - standard_name = geopotential_height_on_current_timestep_for_check_energy_TBD + standard_name = geopotential_height_on_current_timestep_for_check_energy_tbd units = m type = real | kind = kind_phys dimensions = (horizontal_dimension, vertical_layer_dimension) intent = out [ count ] - standard_name = number_of_values_with_significant_energy_or_water_imbalances_TBD + standard_name = number_of_values_with_significant_energy_or_water_imbalances_tbd units = count type = integer dimensions = () intent = out +[ teout ] + standard_name = vertically_integrated_total_energy_at_end_of_physics + units = J m-2 + type = real | kind = kind_phys + dimensions = (horizontal_dimension) + intent = out [ vc_physics ] - standard_name = vertical_coordinate_for_physics_TBD + standard_name = vertical_coordinate_for_physics_tbd units = 1 type = integer dimensions = () intent = in [ vc_dycore ] - standard_name = vertical_coordinate_for_dynamical_core_TBD + standard_name = vertical_coordinate_for_dynamical_core_tbd units = 1 type = integer dimensions = () @@ -251,13 +263,13 @@ dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = in [ cp_or_cv_dycore ] - standard_name = enthalpy_or_internal_energy_scaling_factor_for_energy_consistency_TBD + standard_name = enthalpy_or_internal_energy_scaling_factor_for_energy_consistency_tbd units = J kg-1 K-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = in [ scaling_dycore ] - standard_name = composition_dependent_ratio_of_specific_heat_of_dry_air_at_constant_pressure_to_enthalpy_or_internal_energy_scaling_factor_for_energy_consistency_TBD + standard_name = composition_dependent_ratio_of_specific_heat_of_dry_air_at_constant_pressure_to_enthalpy_or_internal_energy_scaling_factor_for_energy_consistency_tbd units = 1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) @@ -281,31 +293,31 @@ dimensions = (horizontal_loop_extent) intent = inout [ tend_te_tnd ] - standard_name = tendency_of_total_energy_TBD + standard_name = tendency_of_total_energy_tbd units = J m-2 s-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) intent = inout [ tend_tw_tnd ] - standard_name = tendency_of_total_water_TBD + standard_name = tendency_of_total_water_tbd units = kg m-2 s-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) intent = inout [ temp_ini ] - standard_name = temperature_on_current_timestep_for_check_energy_TBD + standard_name = temperature_on_current_timestep_for_check_energy_tbd units = K type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = in [ z_ini ] - standard_name = geopotential_height_on_current_timestep_for_check_energy_TBD + standard_name = geopotential_height_on_current_timestep_for_check_energy_tbd units = m type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = in [ count ] - standard_name = number_of_values_with_significant_energy_or_water_imbalances_TBD + standard_name = number_of_values_with_significant_energy_or_water_imbalances_tbd units = count type = integer dimensions = () @@ -329,13 +341,13 @@ dimensions = () intent = in [ vc_physics ] - standard_name = vertical_coordinate_for_physics_TBD + standard_name = vertical_coordinate_for_physics_tbd units = 1 type = integer dimensions = () intent = in [ vc_dycore ] - standard_name = vertical_coordinate_for_dynamical_core_TBD + standard_name = vertical_coordinate_for_dynamical_core_tbd units = 1 type = integer dimensions = () @@ -347,25 +359,25 @@ dimensions = () intent = in [ flx_vap ] - standard_name = flux_of_vapor_at_surface_due_to_scheme_TBD + standard_name = flux_of_vapor_at_surface_due_to_scheme_tbd units = kg m-2 s-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) intent = in [ flx_cnd ] - standard_name = flux_of_liquid_and_ice_at_surface_due_to_scheme_TBD + standard_name = flux_of_liquid_and_ice_at_surface_due_to_scheme_tbd units = m s-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) intent = in [ flx_ice ] - standard_name = flux_of_ice_at_surface_due_to_scheme_TBD + standard_name = flux_of_ice_at_surface_due_to_scheme_tbd units = m s-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) intent = in [ flx_sen ] - standard_name = flux_of_sensible_heat_at_surface_due_to_scheme_TBD + standard_name = flux_of_sensible_heat_at_surface_due_to_scheme_tbd units = W m-2 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) diff --git a/check_energy/check_energy_fix.F90 b/check_energy/check_energy_fix.F90 new file mode 100644 index 00000000..727169c8 --- /dev/null +++ b/check_energy/check_energy_fix.F90 @@ -0,0 +1,36 @@ +module check_energy_fix + use ccpp_kinds, only: kind_phys + + implicit none + private + + public :: check_energy_fix + +contains + + ! 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, rga, heat_glob, ptend_s, eshflx) + ! Input arguments + integer, intent(in) :: ncol ! number of atmospheric columns + integer, intent(in) :: pver ! number of vertical layers + real(kind_phys), intent(in) :: pint(:,:) ! interface pressure [Pa] + real(kind_phys), intent(in) :: rga ! 1/gravit [m-1 s2] + real(kind_phys), intent(in) :: heat_glob ! global mean heating rate [J kg-1 s-1] + real(kind_phys), intent(out) :: ptend_s(:,:) ! physics tendency heating rate [J kg-1 s-1] + real(kind_phys), intent(out) :: eshflx(:) ! effective sensible heat flux [W m-2] + + ! Local variables + integer :: i + + ! add (-) global mean total energy difference as heating + ptend_s(:ncol, :pver) = heat_glob + + ! compute effective sensible heat flux + do i = 1, ncol + eshflx(i) = heat_glob * (pint(i,pver+1) - pint(i,1)) * rga + end do + end subroutine check_energy_fix_run + +end module check_energy_fix diff --git a/check_energy/check_energy_fix.meta b/check_energy/check_energy_fix.meta new file mode 100644 index 00000000..651f7cc4 --- /dev/null +++ b/check_energy/check_energy_fix.meta @@ -0,0 +1,49 @@ +[ccpp-table-properties] + name = check_energy_fix + type = scheme + +[ccpp-arg-table] + name = check_energy_fix_run + type = scheme +[ ncol ] + standard_name = horizontal_loop_extent + units = count + type = integer + dimensions = () + intent = in +[ pver ] + standard_name = vertical_layer_dimension + units = count + type = integer + dimensions = () + intent = in +[ pint ] + standard_name = air_pressure_at_interface + units = Pa + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent, vertical_layer_dimension) + intent = in +[ rga ] + standard_name = reciprocal_of_gravitational_acceleration + units = s2 m-1 + type = real | kind = kind_phys + dimensions = () + intent = in +[ heat_glob ] + standard_name = global_mean_heating_rate_for_energy_conservation_tbd + units = J kg-1 s-1 + type = real | kind = kind_phys + dimensions = () + intent = in +[ ptend_s ] + standard_name = tendency_of_dry_air_enthalpy_at_constant_pressure + units = J kg-1 s-1 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent, vertical_layer_dimension) + intent = out +[ eshflx ] + standard_name = effective_surface_upward_sensible_heat_flux_due_to_energy_conservation_tbd + units = W m-2 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent) + intent = out diff --git a/check_energy/check_energy_gmean.F90 b/check_energy/check_energy_gmean.F90 new file mode 100644 index 00000000..ebeb7d43 --- /dev/null +++ b/check_energy/check_energy_gmean.F90 @@ -0,0 +1,56 @@ +module check_energy_gmean + use ccpp_kinds, only: kind_phys + + implicit none + private + + public :: check_energy_gmean + +contains + + ! Compute global mean total energy of physics input and output states + ! computed consistently with dynamical core vertical coordinate + ! (under hydrostatic assumption) +!> \section arg_table_check_energy_gmean_run Argument Table +!! \htmlinclude arg_table_check_energy_gmean_run.html + subroutine check_energy_gmean_run( & + ncol, pver, & + pint, & + te_ini_dyn, teout, & + heat_glob) + + ! To-be-CCPP-ized + use gmean_mod, only: gmean + + ! Input arguments + integer, intent(in) :: ncol ! number of atmospheric columns + integer, intent(in) :: pver ! number of vertical layers + real(kind_phys), intent(in) :: pint(:,:) ! interface pressure [Pa] + real(kind_phys), intent(in) :: te_ini_dyn(:) ! dycore formula: initial total energy [J m-2] + real(kind_phys), intent(in) :: teout(:) ! total energy for global fixer in next timestep [J m-2] + real(kind_phys), intent(out) :: heat_glob ! global mean heating rate [J kg-1 s-1] + + ! 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 + + ! These used to be module variables in check_energy and could be made into intent(out) if needed. + real(kind_phys) :: teout_glob ! global mean energy of output state + real(kind_phys) :: teinp_glob ! global mean energy of input state + real(kind_phys) :: tedif_glob ! global mean energy difference + real(kind_phys) :: psurf_glob ! global mean surface pressure + real(kind_phys) :: ptopb_glob ! global mean top boundary pressure + + ! nb hplin: in CAM te(i, lchnk, 2) gets teout from pbuf and this is chunkized. + ! so check_energy_gmean_run ccppized will not be used in CAM because of this chunk handling, + ! and so will gmean be different between CAM and CAM-SIMA. + + ! Copy total energy out of input and output states. + + ! Compute global means of input and output energies and of surface pressure for heating rate. + ! (assuming uniform ptop) + + ! Compute global mean total energy difference for check_energy_fix + end subroutine check_energy_gmean_run + +end module check_energy_gmean diff --git a/check_energy/check_energy_gmean.meta b/check_energy/check_energy_gmean.meta new file mode 100644 index 00000000..4b61a7a5 --- /dev/null +++ b/check_energy/check_energy_gmean.meta @@ -0,0 +1,43 @@ +[ccpp-table-properties] + name = check_energy_gmean + type = scheme + +[ccpp-arg-table] + name = check_energy_gmean_run + type = scheme +[ ncol ] + standard_name = horizontal_loop_extent + units = count + type = integer + dimensions = () + intent = in +[ pver ] + standard_name = vertical_layer_dimension + units = count + type = integer + dimensions = () + intent = in +[ pint ] + standard_name = air_pressure_at_interface + units = Pa + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent, vertical_layer_dimension) + intent = in +[ te_ini_dyn ] + standard_name = vertically_integrated_total_energy_of_initial_state_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 + units = J m-2 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent) + intent = in +[ heat_glob ] + standard_name = global_mean_heating_rate_for_energy_conservation_tbd + units = J kg-1 s-1 + type = real | kind = kind_phys + dimensions = () + intent = out diff --git a/check_energy/check_energy_save_teout.F90 b/check_energy/check_energy_save_teout.F90 new file mode 100644 index 00000000..40cfd40e --- /dev/null +++ b/check_energy/check_energy_save_teout.F90 @@ -0,0 +1,32 @@ +! save total energy for global fixer in next timestep +! this must be called after the last parameterization and physics_update, +! and after a final check_energy_chng to compute te_cur. +module check_energy_save_teout + use ccpp_kinds, only: kind_phys + + implicit none + private + + public :: check_energy_save_teout_run + +contains + +!> \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) + + ! 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] + + ! 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 + ! in the CAM-SIMA/CCPP infrastructure. + teout(:ncol) = te_cur_dyn(:ncol) + + end subroutine check_energy_save_teout_run + +end module check_energy_save_teout \ No newline at end of file diff --git a/check_energy/check_energy_save_teout.meta b/check_energy/check_energy_save_teout.meta new file mode 100644 index 00000000..7972ef4d --- /dev/null +++ b/check_energy/check_energy_save_teout.meta @@ -0,0 +1,25 @@ +[ccpp-table-properties] + name = check_energy_save_teout + type = scheme + +[ccpp-arg-table] + name = check_energy_save_teout_run + type = scheme +[ ncol ] + standard_name = horizontal_loop_extent + units = count + type = integer + dimensions = () + intent = in +[ te_cur_dyn ] + standard_name = vertically_integrated_total_energy_of_current_state_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 + units = J m-2 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent) + intent = out diff --git a/check_energy/check_energy_scaling.meta b/check_energy/check_energy_scaling.meta index f0b701cf..de61a4a4 100644 --- a/check_energy/check_energy_scaling.meta +++ b/check_energy/check_energy_scaling.meta @@ -18,7 +18,7 @@ dimensions = () intent = in [ cp_or_cv_dycore ] - standard_name = enthalpy_or_internal_energy_scaling_factor_for_energy_consistency_TBD + standard_name = enthalpy_or_internal_energy_scaling_factor_for_energy_consistency_tbd units = J kg-1 K-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) @@ -30,7 +30,7 @@ dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = in [ scaling_dycore ] - standard_name = composition_dependent_ratio_of_specific_heat_of_dry_air_at_constant_pressure_to_enthalpy_or_internal_energy_scaling_factor_for_energy_consistency_TBD + standard_name = composition_dependent_ratio_of_specific_heat_of_dry_air_at_constant_pressure_to_enthalpy_or_internal_energy_scaling_factor_for_energy_consistency_tbd units = 1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) diff --git a/check_energy/check_energy_zero_fluxes.F90 b/check_energy/check_energy_zero_fluxes.F90 index bfb1f853..4e93bb9d 100644 --- a/check_energy/check_energy_zero_fluxes.F90 +++ b/check_energy/check_energy_zero_fluxes.F90 @@ -2,30 +2,34 @@ ! before running other schemes module check_energy_zero_fluxes - use ccpp_kinds, only: kind_phys + use ccpp_kinds, only: kind_phys - implicit none - private + implicit none + private - public :: check_energy_zero_fluxes_run + public :: check_energy_zero_fluxes_run contains !> \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(name, flx_vap, flx_cnd, flx_ice, flx_sen) - character(len=*), intent(out) :: name ! parameterization name for fluxes - real(kind_phys), intent(out) :: flx_vap(:) ! boundary flux of vapor [kg m-2 s-1] - 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] - - ! reset values to zero - name = '' - flx_vap(:) = 0._kind_phys - flx_cnd(:) = 0._kind_phys - flx_ice(:) = 0._kind_phys - flx_sen(:) = 0._kind_phys - end subroutine check_energy_zero_fluxes_run + subroutine check_energy_zero_fluxes_run(ncol, name, flx_vap, flx_cnd, flx_ice, flx_sen) + ! Input arguments + integer, intent(in) :: ncol ! number of atmospheric columns + + ! Output arguments + character(len=*), intent(out) :: name ! parameterization name for fluxes + real(kind_phys), intent(out) :: flx_vap(:) ! boundary flux of vapor [kg m-2 s-1] + 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] + + ! reset values to zero + name = '' + flx_vap(:) = 0._kind_phys + flx_cnd(:) = 0._kind_phys + flx_ice(:) = 0._kind_phys + flx_sen(:) = 0._kind_phys + end subroutine check_energy_zero_fluxes_run end module check_energy_zero_fluxes \ No newline at end of file diff --git a/check_energy/check_energy_zero_fluxes.meta b/check_energy/check_energy_zero_fluxes.meta index cd0ed4c2..62a6b500 100644 --- a/check_energy/check_energy_zero_fluxes.meta +++ b/check_energy/check_energy_zero_fluxes.meta @@ -5,6 +5,12 @@ [ccpp-arg-table] name = check_energy_zero_fluxes_run type = scheme +[ ncol ] + standard_name = horizontal_loop_extent + units = count + type = integer + dimensions = () + intent = in [ name ] standard_name = scheme_name units = none @@ -12,25 +18,25 @@ dimensions = () intent = out [ flx_vap ] - standard_name = flux_of_vapor_at_surface_due_to_scheme_TBD + standard_name = flux_of_vapor_at_surface_due_to_scheme_tbd units = kg m-2 s-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) intent = out [ flx_cnd ] - standard_name = flux_of_liquid_and_ice_at_surface_due_to_scheme_TBD + standard_name = flux_of_liquid_and_ice_at_surface_due_to_scheme_tbd units = m s-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) intent = out [ flx_ice ] - standard_name = flux_of_ice_at_surface_due_to_scheme_TBD + standard_name = flux_of_ice_at_surface_due_to_scheme_tbd units = m s-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) intent = out [ flx_sen ] - standard_name = flux_of_sensible_heat_at_surface_due_to_scheme_TBD + standard_name = flux_of_sensible_heat_at_surface_due_to_scheme_tbd units = W m-2 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) From 35449ccc4719fce280bc597a158111d90b68dbdf Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Wed, 25 Sep 2024 17:55:49 -0400 Subject: [PATCH 09/41] SDF for check_energy; implement gmean (& replacement for get_integrals); namelist variable control for print_energy_errors --- check_energy/check_energy_chng.F90 | 13 +++++++- check_energy/check_energy_chng.meta | 11 ++++++ check_energy/check_energy_chng_namelist.xml | 20 +++++++++++ check_energy/check_energy_gmean.F90 | 37 +++++++++++++++------ check_energy/check_energy_gmean.meta | 19 +++++++++++ test/test_suites/suite_check_energy.xml | 20 +++++++++++ 6 files changed, 109 insertions(+), 11 deletions(-) create mode 100644 check_energy/check_energy_chng_namelist.xml create mode 100644 test/test_suites/suite_check_energy.xml diff --git a/check_energy/check_energy_chng.F90 b/check_energy/check_energy_chng.F90 index a0f27bf3..c1d469f7 100644 --- a/check_energy/check_energy_chng.F90 +++ b/check_energy/check_energy_chng.F90 @@ -8,14 +8,25 @@ module check_energy_chng implicit none private + public :: check_energy_chng_init public :: check_energy_chng_timestep_init public :: check_energy_chng_run ! Private module options. - logical :: print_energy_errors = .false. + logical :: print_energy_errors = .false. ! Turn on verbose output identifying columns that fail + ! energy/water checks? contains +!> \section arg_table_check_energy_chng_init Argument Table +!! \htmlinclude arg_table_check_energy_chng_init.html + subroutine check_energy_chng_init(print_energy_errors_in) + ! Input arguments + logical, intent(in) :: print_energy_errors_in + + print_energy_errors = print_energy_errors_in + end subroutine check_energy_chng_init + ! Compute initial values of energy and water integrals, ! and zero out cumulative boundary tendencies. !> \section arg_table_check_energy_chng_timestep_init Argument Table diff --git a/check_energy/check_energy_chng.meta b/check_energy/check_energy_chng.meta index a77b8bf9..b1ecf625 100644 --- a/check_energy/check_energy_chng.meta +++ b/check_energy/check_energy_chng.meta @@ -3,6 +3,17 @@ type = scheme dependencies = ../../../data/cam_thermo.F90,../../../dynamics/tests/dyn_tests_utils.F90 + +[ccpp-arg-table] + name = check_energy_chng_init + type = scheme +[ print_energy_errors_in ] + standard_name = control_for_energy_conservation_warning_tbd + units = none + type = logical + dimensions = () + intent = in + [ccpp-arg-table] name = check_energy_chng_timestep_init type = scheme diff --git a/check_energy/check_energy_chng_namelist.xml b/check_energy/check_energy_chng_namelist.xml new file mode 100644 index 00000000..68e0ef24 --- /dev/null +++ b/check_energy/check_energy_chng_namelist.xml @@ -0,0 +1,20 @@ + + + + + + + logical + diagnostics + check_energy_nl + control_for_energy_conservation_warning_tbd + none + + + Turn on verbose output identifying columns that fail energy/water conservation checks. Default: FALSE + + + .false. + + + diff --git a/check_energy/check_energy_gmean.F90 b/check_energy/check_energy_gmean.F90 index ebeb7d43..c75659aa 100644 --- a/check_energy/check_energy_gmean.F90 +++ b/check_energy/check_energy_gmean.F90 @@ -14,43 +14,60 @@ module check_energy_gmean !> \section arg_table_check_energy_gmean_run Argument Table !! \htmlinclude arg_table_check_energy_gmean_run.html subroutine check_energy_gmean_run( & - ncol, pver, & + ncol, pver, dtime, & + gravit, & pint, & te_ini_dyn, teout, & - heat_glob) + tedif_glob, heat_glob) - ! To-be-CCPP-ized + ! Dependency: Uses gmean from src/utils use gmean_mod, only: gmean ! Input arguments integer, intent(in) :: ncol ! number of atmospheric columns integer, intent(in) :: pver ! number of vertical layers + real(kind_phys), intent(in) :: dtime ! physics time step [s] + real(kind_phys), intent(in) :: gravit ! gravitational acceleration [m s-2] real(kind_phys), intent(in) :: pint(:,:) ! interface pressure [Pa] real(kind_phys), intent(in) :: te_ini_dyn(:) ! dycore formula: initial total energy [J m-2] real(kind_phys), intent(in) :: teout(:) ! total energy for global fixer in next timestep [J m-2] + + ! Output arguments + real(kind_phys), intent(out) :: tedif_glob ! global mean energy difference [J m-2] real(kind_phys), intent(out) :: heat_glob ! global mean heating rate [J kg-1 s-1] ! 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 - ! These used to be module variables in check_energy and could be made into intent(out) if needed. - real(kind_phys) :: teout_glob ! global mean energy of output state - real(kind_phys) :: teinp_glob ! global mean energy of input state - real(kind_phys) :: tedif_glob ! global mean energy difference - real(kind_phys) :: psurf_glob ! global mean surface pressure - real(kind_phys) :: ptopb_glob ! global mean top boundary pressure + real(kind_phys) :: teinp_glob ! global mean energy of input state [J m-2] + real(kind_phys) :: teout_glob ! global mean energy of output state [J m-2] + real(kind_phys) :: psurf_glob ! global mean surface pressure [Pa] + real(kind_phys) :: ptopb_glob ! global mean top boundary pressure [Pa] - ! nb hplin: in CAM te(i, lchnk, 2) gets teout from pbuf and this is chunkized. + ! DEVNOTE hplin: in CAM te(i, lchnk, 2) gets teout from pbuf and this is chunkized. ! so check_energy_gmean_run ccppized will not be used in CAM because of this chunk handling, ! and so will gmean be different between CAM and CAM-SIMA. ! 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] + te(:ncol, 2) = teout(:ncol) ! Total energy from end of physics timestep [J m-2] + te(:ncol, 3) = pint(:ncol, pver+1) ! Surface pressure for heating rate [Pa] + te(:ncol, 4) = pint(:ncol, 1) ! Model top pressure for heating rate [Pa] + ! not constant for z-based vertical coordinate ! Compute global means of input and output energies and of surface pressure for heating rate. ! (assuming uniform ptop) + call gmean(te, te_glob, 4) + teinp_glob = te_glob(1) + teout_glob = te_glob(2) + psurf_glob = te_glob(3) + ptopb_glob = te_glob(4) ! Compute global mean total energy difference for check_energy_fix + tedif_glob = teinp_glob - teout_glob + heat_glob = -tedif_glob/dtime * gravit / (psurf_glob - ptopb_glob) ! [J kg-1 s-1] end subroutine check_energy_gmean_run end module check_energy_gmean diff --git a/check_energy/check_energy_gmean.meta b/check_energy/check_energy_gmean.meta index 4b61a7a5..5f1ed59c 100644 --- a/check_energy/check_energy_gmean.meta +++ b/check_energy/check_energy_gmean.meta @@ -1,6 +1,7 @@ [ccpp-table-properties] name = check_energy_gmean type = scheme + dependencies = ../../../utils/gmean_mod.F90 [ccpp-arg-table] name = check_energy_gmean_run @@ -17,6 +18,18 @@ type = integer dimensions = () intent = in +[ dtime ] + standard_name = timestep_for_physics + units = s + type = real | kind = kind_phys + dimensions = () + intent = in +[ gravit ] + standard_name = standard_gravitational_acceleration + units = m s-2 + type = real | kind = kind_phys + dimensions = () + intent = in [ pint ] standard_name = air_pressure_at_interface units = Pa @@ -35,6 +48,12 @@ type = real | kind = kind_phys dimensions = (horizontal_loop_extent) intent = in +[ tedif_glob ] + standard_name = global_mean_total_energy_difference_for_energy_conservation_tbd + units = J m-2 + type = real | kind = kind_phys + dimensions = () + intent = out [ heat_glob ] standard_name = global_mean_heating_rate_for_energy_conservation_tbd units = J kg-1 s-1 diff --git a/test/test_suites/suite_check_energy.xml b/test/test_suites/suite_check_energy.xml new file mode 100644 index 00000000..8cfa9d84 --- /dev/null +++ b/test/test_suites/suite_check_energy.xml @@ -0,0 +1,20 @@ + + + + + + check_energy_zero_fluxes + check_energy_scaling + check_energy_chng + + + check_energy_gmean + + check_energy_fix + apply_heating_rate + + + + check_energy_save_teout + + From 65a750c0bcfcba90b7b260228d5b11134f4f2910 Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Thu, 3 Oct 2024 17:30:15 -0400 Subject: [PATCH 10/41] Update standard names to accepted variants; debug printout handling --- check_energy/check_energy_chng.F90 | 6 +++--- check_energy/check_energy_chng.meta | 16 ++++++++-------- check_energy/check_energy_gmean.F90 | 11 +++++++++++ 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/check_energy/check_energy_chng.F90 b/check_energy/check_energy_chng.F90 index c1d469f7..b3e2b6eb 100644 --- a/check_energy/check_energy_chng.F90 +++ b/check_energy/check_energy_chng.F90 @@ -2,9 +2,6 @@ module check_energy_chng use ccpp_kinds, only: kind_phys - ! FIXME hplin: for DEBUG only - use cam_logfile, only: iulog - implicit none private @@ -203,6 +200,9 @@ subroutine check_energy_chng_run( & ! FIXME: Flags for vertical coordinate used in physics/dycore use dyn_tests_utils, only: vc_height, vc_dry_pressure + ! FIXME hplin: for DEBUG only + use cam_logfile, only: iulog + ! Input arguments integer, intent(in) :: ncol ! number of atmospheric columns integer, intent(in) :: pver ! number of vertical layers diff --git a/check_energy/check_energy_chng.meta b/check_energy/check_energy_chng.meta index b1ecf625..f83b15c5 100644 --- a/check_energy/check_energy_chng.meta +++ b/check_energy/check_energy_chng.meta @@ -138,25 +138,25 @@ dimensions = (horizontal_dimension) intent = inout [ tend_te_tnd ] - standard_name = tendency_of_total_energy_tbd + standard_name = cumulative_total_energy_boundary_flux_using_physics_energy_formula units = J m-2 s-1 type = real | kind = kind_phys dimensions = (horizontal_dimension) intent = out [ tend_tw_tnd ] - standard_name = tendency_of_total_water_tbd + standard_name = cumulative_total_water_boundary_flux units = kg m-2 s-1 type = real | kind = kind_phys dimensions = (horizontal_dimension) intent = out [ temp_ini ] - standard_name = temperature_on_current_timestep_for_check_energy_tbd + standard_name = temperature_of_initial_state units = K type = real | kind = kind_phys dimensions = (horizontal_dimension, vertical_layer_dimension) intent = out [ z_ini ] - standard_name = geopotential_height_on_current_timestep_for_check_energy_tbd + standard_name = height_wrt_surface_of_initial_state units = m type = real | kind = kind_phys dimensions = (horizontal_dimension, vertical_layer_dimension) @@ -304,25 +304,25 @@ dimensions = (horizontal_loop_extent) intent = inout [ tend_te_tnd ] - standard_name = tendency_of_total_energy_tbd + standard_name = cumulative_total_energy_boundary_flux_using_physics_energy_formula units = J m-2 s-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) intent = inout [ tend_tw_tnd ] - standard_name = tendency_of_total_water_tbd + standard_name = cumulative_total_water_boundary_flux units = kg m-2 s-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) intent = inout [ temp_ini ] - standard_name = temperature_on_current_timestep_for_check_energy_tbd + standard_name = temperature_of_initial_state units = K type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = in [ z_ini ] - standard_name = geopotential_height_on_current_timestep_for_check_energy_tbd + standard_name = height_wrt_surface_of_initial_state units = m type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) diff --git a/check_energy/check_energy_gmean.F90 b/check_energy/check_energy_gmean.F90 index c75659aa..531cca96 100644 --- a/check_energy/check_energy_gmean.F90 +++ b/check_energy/check_energy_gmean.F90 @@ -23,6 +23,11 @@ subroutine check_energy_gmean_run( & ! Dependency: Uses gmean from src/utils use gmean_mod, only: gmean + ! Dev-only Dependency: Debug output to mimic CAM behavior + use spmd_utils, only: masterproc + use cam_logfile, only: iulog + use time_manager, only: get_nstep + ! Input arguments integer, intent(in) :: ncol ! number of atmospheric columns integer, intent(in) :: pver ! number of vertical layers @@ -68,6 +73,12 @@ subroutine check_energy_gmean_run( & ! Compute global mean total energy difference for check_energy_fix tedif_glob = teinp_glob - teout_glob heat_glob = -tedif_glob/dtime * gravit / (psurf_glob - ptopb_glob) ! [J kg-1 s-1] + + ! Dev-only: Debug output for CAM only + if (masterproc) then + write(iulog,'(1x,a9,1x,i8,5(1x,e25.17))') "nstep, te", get_nstep(), teinp_glob, teout_glob, & + heat_glob, psurf_glob, ptopb_glob + endif end subroutine check_energy_gmean_run end module check_energy_gmean From bc5306264c855fdd91e26d1514a7e4747d368a14 Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Thu, 3 Oct 2024 17:33:43 -0400 Subject: [PATCH 11/41] Rebase to new directory structure --- {check_energy => schemes/check_energy}/check_energy_chng.F90 | 0 {check_energy => schemes/check_energy}/check_energy_chng.meta | 0 .../check_energy}/check_energy_chng_namelist.xml | 0 {check_energy => schemes/check_energy}/check_energy_fix.F90 | 0 {check_energy => schemes/check_energy}/check_energy_fix.meta | 0 {check_energy => schemes/check_energy}/check_energy_gmean.F90 | 0 {check_energy => schemes/check_energy}/check_energy_gmean.meta | 0 .../check_energy}/check_energy_save_teout.F90 | 0 .../check_energy}/check_energy_save_teout.meta | 0 {check_energy => schemes/check_energy}/check_energy_scaling.F90 | 0 {check_energy => schemes/check_energy}/check_energy_scaling.meta | 0 .../check_energy}/check_energy_zero_fluxes.F90 | 0 .../check_energy}/check_energy_zero_fluxes.meta | 0 13 files changed, 0 insertions(+), 0 deletions(-) rename {check_energy => schemes/check_energy}/check_energy_chng.F90 (100%) rename {check_energy => schemes/check_energy}/check_energy_chng.meta (100%) rename {check_energy => schemes/check_energy}/check_energy_chng_namelist.xml (100%) rename {check_energy => schemes/check_energy}/check_energy_fix.F90 (100%) rename {check_energy => schemes/check_energy}/check_energy_fix.meta (100%) rename {check_energy => schemes/check_energy}/check_energy_gmean.F90 (100%) rename {check_energy => schemes/check_energy}/check_energy_gmean.meta (100%) rename {check_energy => schemes/check_energy}/check_energy_save_teout.F90 (100%) rename {check_energy => schemes/check_energy}/check_energy_save_teout.meta (100%) rename {check_energy => schemes/check_energy}/check_energy_scaling.F90 (100%) rename {check_energy => schemes/check_energy}/check_energy_scaling.meta (100%) rename {check_energy => schemes/check_energy}/check_energy_zero_fluxes.F90 (100%) rename {check_energy => schemes/check_energy}/check_energy_zero_fluxes.meta (100%) diff --git a/check_energy/check_energy_chng.F90 b/schemes/check_energy/check_energy_chng.F90 similarity index 100% rename from check_energy/check_energy_chng.F90 rename to schemes/check_energy/check_energy_chng.F90 diff --git a/check_energy/check_energy_chng.meta b/schemes/check_energy/check_energy_chng.meta similarity index 100% rename from check_energy/check_energy_chng.meta rename to schemes/check_energy/check_energy_chng.meta diff --git a/check_energy/check_energy_chng_namelist.xml b/schemes/check_energy/check_energy_chng_namelist.xml similarity index 100% rename from check_energy/check_energy_chng_namelist.xml rename to schemes/check_energy/check_energy_chng_namelist.xml diff --git a/check_energy/check_energy_fix.F90 b/schemes/check_energy/check_energy_fix.F90 similarity index 100% rename from check_energy/check_energy_fix.F90 rename to schemes/check_energy/check_energy_fix.F90 diff --git a/check_energy/check_energy_fix.meta b/schemes/check_energy/check_energy_fix.meta similarity index 100% rename from check_energy/check_energy_fix.meta rename to schemes/check_energy/check_energy_fix.meta diff --git a/check_energy/check_energy_gmean.F90 b/schemes/check_energy/check_energy_gmean.F90 similarity index 100% rename from check_energy/check_energy_gmean.F90 rename to schemes/check_energy/check_energy_gmean.F90 diff --git a/check_energy/check_energy_gmean.meta b/schemes/check_energy/check_energy_gmean.meta similarity index 100% rename from check_energy/check_energy_gmean.meta rename to schemes/check_energy/check_energy_gmean.meta diff --git a/check_energy/check_energy_save_teout.F90 b/schemes/check_energy/check_energy_save_teout.F90 similarity index 100% rename from check_energy/check_energy_save_teout.F90 rename to schemes/check_energy/check_energy_save_teout.F90 diff --git a/check_energy/check_energy_save_teout.meta b/schemes/check_energy/check_energy_save_teout.meta similarity index 100% rename from check_energy/check_energy_save_teout.meta rename to schemes/check_energy/check_energy_save_teout.meta diff --git a/check_energy/check_energy_scaling.F90 b/schemes/check_energy/check_energy_scaling.F90 similarity index 100% rename from check_energy/check_energy_scaling.F90 rename to schemes/check_energy/check_energy_scaling.F90 diff --git a/check_energy/check_energy_scaling.meta b/schemes/check_energy/check_energy_scaling.meta similarity index 100% rename from check_energy/check_energy_scaling.meta rename to schemes/check_energy/check_energy_scaling.meta diff --git a/check_energy/check_energy_zero_fluxes.F90 b/schemes/check_energy/check_energy_zero_fluxes.F90 similarity index 100% rename from check_energy/check_energy_zero_fluxes.F90 rename to schemes/check_energy/check_energy_zero_fluxes.F90 diff --git a/check_energy/check_energy_zero_fluxes.meta b/schemes/check_energy/check_energy_zero_fluxes.meta similarity index 100% rename from check_energy/check_energy_zero_fluxes.meta rename to schemes/check_energy/check_energy_zero_fluxes.meta From faacfb7a5f8b88dbf4d20ba0338b779bfe1b8433 Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Fri, 4 Oct 2024 18:08:40 -0400 Subject: [PATCH 12/41] Add debug diagnostics for check_energy --- schemes/check_energy/check_energy_chng.F90 | 2 +- .../check_energy/check_energy_save_teout.F90 | 2 +- .../check_energy/check_energy_zero_fluxes.F90 | 2 +- .../check_energy_zero_fluxes.meta | 2 +- .../check_energy_diagnostics.F90 | 86 +++++++++++++++++++ .../check_energy_diagnostics.meta | 83 ++++++++++++++++++ 6 files changed, 173 insertions(+), 4 deletions(-) create mode 100644 schemes/sima_diagnostics/check_energy_diagnostics.F90 create mode 100644 schemes/sima_diagnostics/check_energy_diagnostics.meta diff --git a/schemes/check_energy/check_energy_chng.F90 b/schemes/check_energy/check_energy_chng.F90 index b3e2b6eb..208e802a 100644 --- a/schemes/check_energy/check_energy_chng.F90 +++ b/schemes/check_energy/check_energy_chng.F90 @@ -412,4 +412,4 @@ subroutine check_energy_chng_run( & end if end subroutine check_energy_chng_run -end module check_energy_chng \ No newline at end of file +end module check_energy_chng diff --git a/schemes/check_energy/check_energy_save_teout.F90 b/schemes/check_energy/check_energy_save_teout.F90 index 40cfd40e..6ccdc15c 100644 --- a/schemes/check_energy/check_energy_save_teout.F90 +++ b/schemes/check_energy/check_energy_save_teout.F90 @@ -29,4 +29,4 @@ subroutine check_energy_save_teout_run(ncol, te_cur_dyn, teout) end subroutine check_energy_save_teout_run -end module check_energy_save_teout \ No newline at end of file +end module check_energy_save_teout diff --git a/schemes/check_energy/check_energy_zero_fluxes.F90 b/schemes/check_energy/check_energy_zero_fluxes.F90 index 4e93bb9d..9d73b436 100644 --- a/schemes/check_energy/check_energy_zero_fluxes.F90 +++ b/schemes/check_energy/check_energy_zero_fluxes.F90 @@ -32,4 +32,4 @@ subroutine check_energy_zero_fluxes_run(ncol, name, flx_vap, flx_cnd, flx_ice, f flx_sen(:) = 0._kind_phys end subroutine check_energy_zero_fluxes_run -end module check_energy_zero_fluxes \ No newline at end of file +end module check_energy_zero_fluxes diff --git a/schemes/check_energy/check_energy_zero_fluxes.meta b/schemes/check_energy/check_energy_zero_fluxes.meta index 62a6b500..3ca34c03 100644 --- a/schemes/check_energy/check_energy_zero_fluxes.meta +++ b/schemes/check_energy/check_energy_zero_fluxes.meta @@ -40,4 +40,4 @@ units = W m-2 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) - intent = out \ No newline at end of file + intent = out diff --git a/schemes/sima_diagnostics/check_energy_diagnostics.F90 b/schemes/sima_diagnostics/check_energy_diagnostics.F90 new file mode 100644 index 00000000..aee841af --- /dev/null +++ b/schemes/sima_diagnostics/check_energy_diagnostics.F90 @@ -0,0 +1,86 @@ +! 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 + + implicit none + private + save + + public :: check_energy_diagnostics_init ! init routine + public :: check_energy_diagnostics_run ! main routine + +CONTAINS + + !> \section arg_table_check_energy_diagnostics_init Argument Table + !! \htmlinclude check_energy_diagnostics_init.html + subroutine check_energy_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('cp_or_cv_dycore', 'enthalpy_or_internal_energy_scaling_factor_for_energy_consistency_tbd', 'lev', 'inst', 'J kg-1 K-1') + call history_add_field('scaling_dycore', 'composition_dependent_ratio_of_specific_heat_of_dry_air_at_constant_pressure_to_enthalpy_or_internal_energy_scaling_factor_for_energy_consistency_tbd', 'lev', 'inst', '1') + + call history_add_field('te_cur_phys', 'vertically_integrated_total_energy_of_current_state_using_physics_energy_formula', horiz_only, 'inst', 'J m-2') + call history_add_field('te_cur_dyn', 'vertically_integrated_total_energy_of_current_state_using_dycore_energy_formula', horiz_only, 'inst', 'J m-2') + call history_add_field('tw_cur', 'vertically_integrated_moist_air_and_condensed_water_of_current_state', 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', 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, & + errmsg, errflg) + + use cam_history, only: history_out_field + !------------------------------------------------ + ! Input / output parameters + !------------------------------------------------ + ! State variables + 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 + character(len=512), intent(out) :: errmsg + integer, intent(out) :: errflg + + errmsg = '' + errflg = 0 + + ! History out field calls + 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 + +end module check_energy_diagnostics diff --git a/schemes/sima_diagnostics/check_energy_diagnostics.meta b/schemes/sima_diagnostics/check_energy_diagnostics.meta new file mode 100644 index 00000000..73d6b467 --- /dev/null +++ b/schemes/sima_diagnostics/check_energy_diagnostics.meta @@ -0,0 +1,83 @@ +[ccpp-table-properties] + name = check_energy_diagnostics + type = scheme + +[ccpp-arg-table] + name = check_energy_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_diagnostics_run + type = scheme +[ cp_or_cv_dycore ] + standard_name = enthalpy_or_internal_energy_scaling_factor_for_energy_consistency_tbd + units = J kg-1 K-1 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent, vertical_layer_dimension) + intent = in +[ scaling_dycore ] + standard_name = composition_dependent_ratio_of_specific_heat_of_dry_air_at_constant_pressure_to_enthalpy_or_internal_energy_scaling_factor_for_energy_consistency_tbd + units = 1 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent, vertical_layer_dimension) + intent = in +[ te_cur_phys ] + standard_name = vertically_integrated_total_energy_of_current_state_using_physics_energy_formula + units = J m-2 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent) + intent = in +[ te_cur_dyn ] + standard_name = vertically_integrated_total_energy_of_current_state_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_moist_air_and_condensed_water_of_current_state + units = kg m-2 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent) + intent = in +[ tend_te_tnd ] + standard_name = cumulative_total_energy_boundary_flux_using_physics_energy_formula + units = J m-2 s-1 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent) + intent = in +[ tend_tw_tnd ] + standard_name = cumulative_total_water_boundary_flux + units = kg m-2 s-1 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent) + intent = in +[ teout ] + standard_name = vertically_integrated_total_energy_at_end_of_physics + units = J 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 From cb922ee7de45ddc6b823e60caf97a098cf86bef2 Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Mon, 7 Oct 2024 10:54:10 -0600 Subject: [PATCH 13/41] Fix compile issues --- schemes/check_energy/check_energy_fix.F90 | 2 +- schemes/check_energy/check_energy_gmean.F90 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/schemes/check_energy/check_energy_fix.F90 b/schemes/check_energy/check_energy_fix.F90 index 727169c8..3452e150 100644 --- a/schemes/check_energy/check_energy_fix.F90 +++ b/schemes/check_energy/check_energy_fix.F90 @@ -4,7 +4,7 @@ module check_energy_fix implicit none private - public :: check_energy_fix + public :: check_energy_fix_run contains diff --git a/schemes/check_energy/check_energy_gmean.F90 b/schemes/check_energy/check_energy_gmean.F90 index 531cca96..f8cd88ff 100644 --- a/schemes/check_energy/check_energy_gmean.F90 +++ b/schemes/check_energy/check_energy_gmean.F90 @@ -4,7 +4,7 @@ module check_energy_gmean implicit none private - public :: check_energy_gmean + public :: check_energy_gmean_run contains From cdb5b5ed3543c2429c92fd6e81c7e72a17161825 Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Thu, 10 Oct 2024 15:41:46 -0600 Subject: [PATCH 14/41] Move check_energy_gmean to subdir to avoid CAM from building it --- .../check_energy/{ => check_energy_gmean}/check_energy_gmean.F90 | 0 .../check_energy/{ => check_energy_gmean}/check_energy_gmean.meta | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename schemes/check_energy/{ => check_energy_gmean}/check_energy_gmean.F90 (100%) rename schemes/check_energy/{ => check_energy_gmean}/check_energy_gmean.meta (100%) diff --git a/schemes/check_energy/check_energy_gmean.F90 b/schemes/check_energy/check_energy_gmean/check_energy_gmean.F90 similarity index 100% rename from schemes/check_energy/check_energy_gmean.F90 rename to schemes/check_energy/check_energy_gmean/check_energy_gmean.F90 diff --git a/schemes/check_energy/check_energy_gmean.meta b/schemes/check_energy/check_energy_gmean/check_energy_gmean.meta similarity index 100% rename from schemes/check_energy/check_energy_gmean.meta rename to schemes/check_energy/check_energy_gmean/check_energy_gmean.meta From 53307381bf0e2047f6bfbb3ab104d41ced782673 Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Tue, 15 Oct 2024 15:11:29 -0400 Subject: [PATCH 15/41] Add test SDF with teout assignment so it can run standalone; remove old check_energy_chng SDF --- test/test_suites/suite_check_energy.xml | 9 ++++++--- test/test_suites/suite_check_energy_chng.xml | 10 ---------- 2 files changed, 6 insertions(+), 13 deletions(-) delete mode 100644 test/test_suites/suite_check_energy_chng.xml diff --git a/test/test_suites/suite_check_energy.xml b/test/test_suites/suite_check_energy.xml index 8cfa9d84..a3ac981d 100644 --- a/test/test_suites/suite_check_energy.xml +++ b/test/test_suites/suite_check_energy.xml @@ -2,13 +2,16 @@ + + check_energy_save_teout + + + check_energy_gmean + check_energy_zero_fluxes check_energy_scaling check_energy_chng - - - check_energy_gmean check_energy_fix apply_heating_rate diff --git a/test/test_suites/suite_check_energy_chng.xml b/test/test_suites/suite_check_energy_chng.xml deleted file mode 100644 index d3a3c512..00000000 --- a/test/test_suites/suite_check_energy_chng.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - check_energy_zero_fluxes - check_energy_scaling - check_energy_chng - - From 2b6c48138f843cd9e722d9d8e70a335c0ded4269 Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Tue, 15 Oct 2024 15:23:27 -0400 Subject: [PATCH 16/41] Update tw_ini, tw_cur standard names --- schemes/check_energy/check_energy_chng.meta | 6 +++--- schemes/sima_diagnostics/check_energy_diagnostics.F90 | 2 +- schemes/sima_diagnostics/check_energy_diagnostics.meta | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/schemes/check_energy/check_energy_chng.meta b/schemes/check_energy/check_energy_chng.meta index f83b15c5..544fa18e 100644 --- a/schemes/check_energy/check_energy_chng.meta +++ b/schemes/check_energy/check_energy_chng.meta @@ -114,7 +114,7 @@ dimensions = (horizontal_dimension) intent = inout [ tw_ini ] - standard_name = vertically_integrated_moist_air_and_condensed_water_of_initial_state + standard_name = vertically_integrated_water_vapor_and_condensed_water_of_initial_state units = kg m-2 type = real | kind = kind_phys dimensions = (horizontal_dimension) @@ -132,7 +132,7 @@ dimensions = (horizontal_dimension) intent = inout [ tw_cur ] - standard_name = vertically_integrated_moist_air_and_condensed_water_of_current_state + standard_name = vertically_integrated_water_vapor_and_condensed_water_of_current_state units = kg m-2 type = real | kind = kind_phys dimensions = (horizontal_dimension) @@ -298,7 +298,7 @@ dimensions = (horizontal_loop_extent) intent = inout [ tw_cur ] - standard_name = vertically_integrated_moist_air_and_condensed_water_of_current_state + standard_name = vertically_integrated_water_vapor_and_condensed_water_of_current_state units = kg m-2 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) diff --git a/schemes/sima_diagnostics/check_energy_diagnostics.F90 b/schemes/sima_diagnostics/check_energy_diagnostics.F90 index aee841af..4648831a 100644 --- a/schemes/sima_diagnostics/check_energy_diagnostics.F90 +++ b/schemes/sima_diagnostics/check_energy_diagnostics.F90 @@ -32,7 +32,7 @@ subroutine check_energy_diagnostics_init(errmsg, errflg) call history_add_field('te_cur_phys', 'vertically_integrated_total_energy_of_current_state_using_physics_energy_formula', horiz_only, 'inst', 'J m-2') call history_add_field('te_cur_dyn', 'vertically_integrated_total_energy_of_current_state_using_dycore_energy_formula', horiz_only, 'inst', 'J m-2') - call history_add_field('tw_cur', 'vertically_integrated_moist_air_and_condensed_water_of_current_state', horiz_only, 'inst', 'kg m-2') + call history_add_field('tw_cur', 'vertically_integrated_water_vapor_and_condensed_water_of_current_state', 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') diff --git a/schemes/sima_diagnostics/check_energy_diagnostics.meta b/schemes/sima_diagnostics/check_energy_diagnostics.meta index 73d6b467..d6a7f611 100644 --- a/schemes/sima_diagnostics/check_energy_diagnostics.meta +++ b/schemes/sima_diagnostics/check_energy_diagnostics.meta @@ -46,7 +46,7 @@ dimensions = (horizontal_loop_extent) intent = in [ tw_cur ] - standard_name = vertically_integrated_moist_air_and_condensed_water_of_current_state + standard_name = vertically_integrated_water_vapor_and_condensed_water_of_current_state units = kg m-2 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) From f54840234cb1b65312614697e59632d9f06d1a05 Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Tue, 15 Oct 2024 15:27:21 -0400 Subject: [PATCH 17/41] Fix vertical_interface_dimension for pint --- schemes/check_energy/check_energy_fix.meta | 2 +- schemes/check_energy/check_energy_gmean/check_energy_gmean.meta | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/schemes/check_energy/check_energy_fix.meta b/schemes/check_energy/check_energy_fix.meta index 651f7cc4..9cf1254c 100644 --- a/schemes/check_energy/check_energy_fix.meta +++ b/schemes/check_energy/check_energy_fix.meta @@ -21,7 +21,7 @@ standard_name = air_pressure_at_interface units = Pa type = real | kind = kind_phys - dimensions = (horizontal_loop_extent, vertical_layer_dimension) + dimensions = (horizontal_loop_extent, vertical_interface_dimension) intent = in [ rga ] standard_name = reciprocal_of_gravitational_acceleration diff --git a/schemes/check_energy/check_energy_gmean/check_energy_gmean.meta b/schemes/check_energy/check_energy_gmean/check_energy_gmean.meta index 5f1ed59c..551eb52c 100644 --- a/schemes/check_energy/check_energy_gmean/check_energy_gmean.meta +++ b/schemes/check_energy/check_energy_gmean/check_energy_gmean.meta @@ -34,7 +34,7 @@ standard_name = air_pressure_at_interface units = Pa type = real | kind = kind_phys - dimensions = (horizontal_loop_extent, vertical_layer_dimension) + dimensions = (horizontal_loop_extent, vertical_interface_dimension) intent = in [ te_ini_dyn ] standard_name = vertically_integrated_total_energy_of_initial_state_using_dycore_energy_formula From b30f55f3b53bb98fd9258fb2a55868153932a66a Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Tue, 15 Oct 2024 17:36:19 -0400 Subject: [PATCH 18/41] Fix build issues --- schemes/check_energy/check_energy_chng.F90 | 2 +- schemes/check_energy/check_energy_chng.meta | 4 ++-- .../check_energy/check_energy_gmean/check_energy_gmean.meta | 2 +- schemes/check_energy/check_energy_zero_fluxes.F90 | 2 +- schemes/check_energy/check_energy_zero_fluxes.meta | 2 +- test/test_suites/suite_check_energy.xml | 4 +++- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/schemes/check_energy/check_energy_chng.F90 b/schemes/check_energy/check_energy_chng.F90 index 208e802a..bf0d32f7 100644 --- a/schemes/check_energy/check_energy_chng.F90 +++ b/schemes/check_energy/check_energy_chng.F90 @@ -236,7 +236,7 @@ subroutine check_energy_chng_run( & ! Note that the precip and ice fluxes are in precip units (m/s). ! I would prefer to have kg/m2/s. ! I would also prefer liquid (not total) and ice fluxes - character(len=*), intent(in) :: name ! parameterization name for fluxes + character(len=64), intent(in) :: name ! parameterization name for fluxes real(kind_phys), intent(in) :: flx_vap(:) ! boundary flux of vapor [kg m-2 s-1] real(kind_phys), intent(in) :: flx_cnd(:) ! boundary flux of liquid+ice (precip?) [m s-1] real(kind_phys), intent(in) :: flx_ice(:) ! boundary flux of ice (snow?) [m s-1] diff --git a/schemes/check_energy/check_energy_chng.meta b/schemes/check_energy/check_energy_chng.meta index 544fa18e..689cef7b 100644 --- a/schemes/check_energy/check_energy_chng.meta +++ b/schemes/check_energy/check_energy_chng.meta @@ -1,7 +1,7 @@ [ccpp-table-properties] name = check_energy_chng type = scheme - dependencies = ../../../data/cam_thermo.F90,../../../dynamics/tests/dyn_tests_utils.F90 + dependencies = ../../../../data/cam_thermo.F90,../../../../dynamics/tests/dyn_tests_utils.F90 [ccpp-arg-table] @@ -366,7 +366,7 @@ [ name ] standard_name = scheme_name units = none - type = character | kind = len=* + type = character | kind = len=64 dimensions = () intent = in [ flx_vap ] diff --git a/schemes/check_energy/check_energy_gmean/check_energy_gmean.meta b/schemes/check_energy/check_energy_gmean/check_energy_gmean.meta index 551eb52c..6d76615d 100644 --- a/schemes/check_energy/check_energy_gmean/check_energy_gmean.meta +++ b/schemes/check_energy/check_energy_gmean/check_energy_gmean.meta @@ -1,7 +1,7 @@ [ccpp-table-properties] name = check_energy_gmean type = scheme - dependencies = ../../../utils/gmean_mod.F90 + dependencies = ../../../../../utils/gmean_mod.F90 [ccpp-arg-table] name = check_energy_gmean_run diff --git a/schemes/check_energy/check_energy_zero_fluxes.F90 b/schemes/check_energy/check_energy_zero_fluxes.F90 index 9d73b436..c4ffece3 100644 --- a/schemes/check_energy/check_energy_zero_fluxes.F90 +++ b/schemes/check_energy/check_energy_zero_fluxes.F90 @@ -18,7 +18,7 @@ subroutine check_energy_zero_fluxes_run(ncol, name, flx_vap, flx_cnd, flx_ice, f integer, intent(in) :: ncol ! number of atmospheric columns ! Output arguments - character(len=*), intent(out) :: name ! parameterization name for fluxes + character(len=64), intent(out) :: name ! parameterization name for fluxes real(kind_phys), intent(out) :: flx_vap(:) ! boundary flux of vapor [kg m-2 s-1] 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] diff --git a/schemes/check_energy/check_energy_zero_fluxes.meta b/schemes/check_energy/check_energy_zero_fluxes.meta index 3ca34c03..34efe087 100644 --- a/schemes/check_energy/check_energy_zero_fluxes.meta +++ b/schemes/check_energy/check_energy_zero_fluxes.meta @@ -14,7 +14,7 @@ [ name ] standard_name = scheme_name units = none - type = character | kind = len=* + type = character | kind = len=64 dimensions = () intent = out [ flx_vap ] diff --git a/test/test_suites/suite_check_energy.xml b/test/test_suites/suite_check_energy.xml index a3ac981d..4b7e73a2 100644 --- a/test/test_suites/suite_check_energy.xml +++ b/test/test_suites/suite_check_energy.xml @@ -17,7 +17,9 @@ apply_heating_rate - + qneg + + check_energy_chng check_energy_save_teout From 32929bfe634002f3333f144242806906f5e6260b Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Tue, 15 Oct 2024 17:43:34 -0400 Subject: [PATCH 19/41] Update assigned standard names --- schemes/check_energy/check_energy_chng.meta | 28 +++++++++---------- .../check_energy_chng_namelist.xml | 2 +- schemes/check_energy/check_energy_fix.meta | 4 +-- .../check_energy_gmean.meta | 4 +-- .../check_energy/check_energy_scaling.meta | 4 +-- .../check_energy_zero_fluxes.meta | 8 +++--- .../check_energy_diagnostics.F90 | 4 +-- .../check_energy_diagnostics.meta | 4 +-- 8 files changed, 29 insertions(+), 29 deletions(-) diff --git a/schemes/check_energy/check_energy_chng.meta b/schemes/check_energy/check_energy_chng.meta index 689cef7b..d473155c 100644 --- a/schemes/check_energy/check_energy_chng.meta +++ b/schemes/check_energy/check_energy_chng.meta @@ -8,7 +8,7 @@ name = check_energy_chng_init type = scheme [ print_energy_errors_in ] - standard_name = control_for_energy_conservation_warning_tbd + standard_name = control_for_energy_conservation_warning units = none type = logical dimensions = () @@ -96,7 +96,7 @@ dimensions = (horizontal_dimension, vertical_layer_dimension) intent = in [ cp_or_cv_dycore ] - standard_name = enthalpy_or_internal_energy_scaling_factor_for_energy_consistency_tbd + standard_name = specific_heat_for_air_used_in_dycore units = J kg-1 K-1 type = real | kind = kind_phys dimensions = (horizontal_dimension, vertical_layer_dimension) @@ -162,7 +162,7 @@ dimensions = (horizontal_dimension, vertical_layer_dimension) intent = out [ count ] - standard_name = number_of_values_with_significant_energy_or_water_imbalances_tbd + standard_name = number_of_values_with_significant_energy_or_water_imbalances units = count type = integer dimensions = () @@ -174,13 +174,13 @@ dimensions = (horizontal_dimension) intent = out [ vc_physics ] - standard_name = vertical_coordinate_for_physics_tbd + standard_name = total_energy_formula_for_physics units = 1 type = integer dimensions = () intent = in [ vc_dycore ] - standard_name = vertical_coordinate_for_dynamical_core_tbd + standard_name = total_energy_formula_for_dycore units = 1 type = integer dimensions = () @@ -274,13 +274,13 @@ dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = in [ cp_or_cv_dycore ] - standard_name = enthalpy_or_internal_energy_scaling_factor_for_energy_consistency_tbd + standard_name = specific_heat_for_air_used_in_dycore units = J kg-1 K-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = in [ scaling_dycore ] - standard_name = composition_dependent_ratio_of_specific_heat_of_dry_air_at_constant_pressure_to_enthalpy_or_internal_energy_scaling_factor_for_energy_consistency_tbd + standard_name = ratio_of_specific_heat_for_air_used_in_physics_energy_formula_and_specific_heat_for_air_used_in_dycore_energy_formula units = 1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) @@ -328,7 +328,7 @@ dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = in [ count ] - standard_name = number_of_values_with_significant_energy_or_water_imbalances_tbd + standard_name = number_of_values_with_significant_energy_or_water_imbalances units = count type = integer dimensions = () @@ -352,13 +352,13 @@ dimensions = () intent = in [ vc_physics ] - standard_name = vertical_coordinate_for_physics_tbd + standard_name = total_energy_formula_for_physics units = 1 type = integer dimensions = () intent = in [ vc_dycore ] - standard_name = vertical_coordinate_for_dynamical_core_tbd + standard_name = total_energy_formula_for_dycore units = 1 type = integer dimensions = () @@ -370,25 +370,25 @@ dimensions = () intent = in [ flx_vap ] - standard_name = flux_of_vapor_at_surface_due_to_scheme_tbd + standard_name = net_water_vapor_fluxes_through_top_and_bottom_of_atmosphere_column units = kg m-2 s-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) intent = in [ flx_cnd ] - standard_name = flux_of_liquid_and_ice_at_surface_due_to_scheme_tbd + standard_name = net_liquid_and_ice_fluxes_through_top_and_bottom_of_atmosphere_column units = m s-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) intent = in [ flx_ice ] - standard_name = flux_of_ice_at_surface_due_to_scheme_tbd + standard_name = net_ice_fluxes_through_top_and_bottom_of_atmosphere_column units = m s-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) intent = in [ flx_sen ] - standard_name = flux_of_sensible_heat_at_surface_due_to_scheme_tbd + 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) diff --git a/schemes/check_energy/check_energy_chng_namelist.xml b/schemes/check_energy/check_energy_chng_namelist.xml index 68e0ef24..c06e9839 100644 --- a/schemes/check_energy/check_energy_chng_namelist.xml +++ b/schemes/check_energy/check_energy_chng_namelist.xml @@ -7,7 +7,7 @@ logical diagnostics check_energy_nl - control_for_energy_conservation_warning_tbd + control_for_energy_conservation_warning none diff --git a/schemes/check_energy/check_energy_fix.meta b/schemes/check_energy/check_energy_fix.meta index 9cf1254c..ae0a014d 100644 --- a/schemes/check_energy/check_energy_fix.meta +++ b/schemes/check_energy/check_energy_fix.meta @@ -30,7 +30,7 @@ dimensions = () intent = in [ heat_glob ] - standard_name = global_mean_heating_rate_for_energy_conservation_tbd + standard_name = global_mean_heating_rate_correction_for_energy_conservation units = J kg-1 s-1 type = real | kind = kind_phys dimensions = () @@ -42,7 +42,7 @@ dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = out [ eshflx ] - standard_name = effective_surface_upward_sensible_heat_flux_due_to_energy_conservation_tbd + standard_name = net_sensible_heat_flux_through_top_and_bottom_of_atmosphere_column_from_global_total_energy_correction units = W m-2 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) diff --git a/schemes/check_energy/check_energy_gmean/check_energy_gmean.meta b/schemes/check_energy/check_energy_gmean/check_energy_gmean.meta index 6d76615d..09385652 100644 --- a/schemes/check_energy/check_energy_gmean/check_energy_gmean.meta +++ b/schemes/check_energy/check_energy_gmean/check_energy_gmean.meta @@ -49,13 +49,13 @@ dimensions = (horizontal_loop_extent) intent = in [ tedif_glob ] - standard_name = global_mean_total_energy_difference_for_energy_conservation_tbd + standard_name = global_mean_total_energy_correction_for_energy_conservation units = J m-2 type = real | kind = kind_phys dimensions = () intent = out [ heat_glob ] - standard_name = global_mean_heating_rate_for_energy_conservation_tbd + standard_name = global_mean_heating_rate_correction_for_energy_conservation units = J kg-1 s-1 type = real | kind = kind_phys dimensions = () diff --git a/schemes/check_energy/check_energy_scaling.meta b/schemes/check_energy/check_energy_scaling.meta index de61a4a4..066dcf6a 100644 --- a/schemes/check_energy/check_energy_scaling.meta +++ b/schemes/check_energy/check_energy_scaling.meta @@ -18,7 +18,7 @@ dimensions = () intent = in [ cp_or_cv_dycore ] - standard_name = enthalpy_or_internal_energy_scaling_factor_for_energy_consistency_tbd + standard_name = specific_heat_for_air_used_in_dycore units = J kg-1 K-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) @@ -30,7 +30,7 @@ dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = in [ scaling_dycore ] - standard_name = composition_dependent_ratio_of_specific_heat_of_dry_air_at_constant_pressure_to_enthalpy_or_internal_energy_scaling_factor_for_energy_consistency_tbd + standard_name = ratio_of_specific_heat_for_air_used_in_physics_energy_formula_and_specific_heat_for_air_used_in_dycore_energy_formula units = 1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) diff --git a/schemes/check_energy/check_energy_zero_fluxes.meta b/schemes/check_energy/check_energy_zero_fluxes.meta index 34efe087..6b850672 100644 --- a/schemes/check_energy/check_energy_zero_fluxes.meta +++ b/schemes/check_energy/check_energy_zero_fluxes.meta @@ -18,25 +18,25 @@ dimensions = () intent = out [ flx_vap ] - standard_name = flux_of_vapor_at_surface_due_to_scheme_tbd + standard_name = net_water_vapor_fluxes_through_top_and_bottom_of_atmosphere_column units = kg m-2 s-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) intent = out [ flx_cnd ] - standard_name = flux_of_liquid_and_ice_at_surface_due_to_scheme_tbd + standard_name = net_liquid_and_ice_fluxes_through_top_and_bottom_of_atmosphere_column units = m s-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) intent = out [ flx_ice ] - standard_name = flux_of_ice_at_surface_due_to_scheme_tbd + standard_name = net_ice_fluxes_through_top_and_bottom_of_atmosphere_column units = m s-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) intent = out [ flx_sen ] - standard_name = flux_of_sensible_heat_at_surface_due_to_scheme_tbd + 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) diff --git a/schemes/sima_diagnostics/check_energy_diagnostics.F90 b/schemes/sima_diagnostics/check_energy_diagnostics.F90 index 4648831a..dac21bf1 100644 --- a/schemes/sima_diagnostics/check_energy_diagnostics.F90 +++ b/schemes/sima_diagnostics/check_energy_diagnostics.F90 @@ -27,8 +27,8 @@ subroutine check_energy_diagnostics_init(errmsg, errflg) errflg = 0 ! History add field calls - call history_add_field('cp_or_cv_dycore', 'enthalpy_or_internal_energy_scaling_factor_for_energy_consistency_tbd', 'lev', 'inst', 'J kg-1 K-1') - call history_add_field('scaling_dycore', 'composition_dependent_ratio_of_specific_heat_of_dry_air_at_constant_pressure_to_enthalpy_or_internal_energy_scaling_factor_for_energy_consistency_tbd', 'lev', 'inst', '1') + call history_add_field('cp_or_cv_dycore', 'specific_heat_for_air_used_in_dycore', 'lev', 'inst', 'J kg-1 K-1') + call history_add_field('scaling_dycore', 'ratio_of_specific_heat_for_air_used_in_physics_energy_formula_and_specific_heat_for_air_used_in_dycore_energy_formula', 'lev', 'inst', '1') call history_add_field('te_cur_phys', 'vertically_integrated_total_energy_of_current_state_using_physics_energy_formula', horiz_only, 'inst', 'J m-2') call history_add_field('te_cur_dyn', 'vertically_integrated_total_energy_of_current_state_using_dycore_energy_formula', horiz_only, 'inst', 'J m-2') diff --git a/schemes/sima_diagnostics/check_energy_diagnostics.meta b/schemes/sima_diagnostics/check_energy_diagnostics.meta index d6a7f611..bce2cd47 100644 --- a/schemes/sima_diagnostics/check_energy_diagnostics.meta +++ b/schemes/sima_diagnostics/check_energy_diagnostics.meta @@ -22,13 +22,13 @@ name = check_energy_diagnostics_run type = scheme [ cp_or_cv_dycore ] - standard_name = enthalpy_or_internal_energy_scaling_factor_for_energy_consistency_tbd + standard_name = specific_heat_for_air_used_in_dycore units = J kg-1 K-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = in [ scaling_dycore ] - standard_name = composition_dependent_ratio_of_specific_heat_of_dry_air_at_constant_pressure_to_enthalpy_or_internal_energy_scaling_factor_for_energy_consistency_tbd + standard_name = ratio_of_specific_heat_for_air_used_in_physics_energy_formula_and_specific_heat_for_air_used_in_dycore_energy_formula units = 1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) From 8aafb77b3b184459c52a52425140e69ee5f3a80c Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Tue, 15 Oct 2024 17:46:40 -0400 Subject: [PATCH 20/41] Update check_energy namelist --- schemes/check_energy/check_energy_chng_namelist.xml | 3 +-- test/test_suites/suite_check_energy.xml | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/schemes/check_energy/check_energy_chng_namelist.xml b/schemes/check_energy/check_energy_chng_namelist.xml index c06e9839..4368b7b6 100644 --- a/schemes/check_energy/check_energy_chng_namelist.xml +++ b/schemes/check_energy/check_energy_chng_namelist.xml @@ -9,12 +9,11 @@ check_energy_nl control_for_energy_conservation_warning none - Turn on verbose output identifying columns that fail energy/water conservation checks. Default: FALSE - .false. + false diff --git a/test/test_suites/suite_check_energy.xml b/test/test_suites/suite_check_energy.xml index 4b7e73a2..f84e9afd 100644 --- a/test/test_suites/suite_check_energy.xml +++ b/test/test_suites/suite_check_energy.xml @@ -1,6 +1,6 @@ - + check_energy_save_teout From 3eacca25e6c3e62386ab9d56954af5867c2589eb Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Mon, 21 Oct 2024 13:12:53 -0400 Subject: [PATCH 21/41] Add note about eventual removal of dyn_tests_utils --- schemes/check_energy/check_energy_chng.F90 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/schemes/check_energy/check_energy_chng.F90 b/schemes/check_energy/check_energy_chng.F90 index bf0d32f7..6d391f86 100644 --- a/schemes/check_energy/check_energy_chng.F90 +++ b/schemes/check_energy/check_energy_chng.F90 @@ -50,7 +50,8 @@ subroutine check_energy_chng_timestep_init( & ! Dependency for hydrostatic energy calculation (physics and dycore formulas) use cam_thermo, only: get_hydrostatic_energy - ! FIXME: Flags for vertical coordinate used in physics/dycore + !REMOVECAM: when CAM is retired the energy formulation flag values which are + ! stored in dyn_tests_utils can be moved elsewhere. use dyn_tests_utils, only: vc_height, vc_dry_pressure ! Input arguments From 11be7fd8d10a85cdf31c278e361e2cb0b003635e Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Tue, 22 Oct 2024 17:55:37 -0400 Subject: [PATCH 22/41] Update check_energy from vcoord to energy_formula --- schemes/check_energy/check_energy_chng.F90 | 37 +++++++++++---------- schemes/check_energy/check_energy_chng.meta | 8 ++--- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/schemes/check_energy/check_energy_chng.F90 b/schemes/check_energy/check_energy_chng.F90 index 6d391f86..a5b2226f 100644 --- a/schemes/check_energy/check_energy_chng.F90 +++ b/schemes/check_energy/check_energy_chng.F90 @@ -44,14 +44,14 @@ subroutine check_energy_chng_timestep_init( & temp_ini, z_ini, & count, & teout, & - vc_physics, vc_dycore, & + energy_formula_physics, energy_formula_dycore, & errmsg, errflg) ! Dependency for hydrostatic energy calculation (physics and dycore formulas) use cam_thermo, only: get_hydrostatic_energy !REMOVECAM: when CAM is retired the energy formulation flag values which are - ! stored in dyn_tests_utils can be moved elsewhere. + ! stored in dyn_tests_utils can be changed to use cam_thermo_formula use dyn_tests_utils, only: vc_height, vc_dry_pressure ! Input arguments @@ -69,8 +69,8 @@ subroutine check_energy_chng_timestep_init( & real(kind_phys), intent(in) :: zm(:,:) ! geopotential height at layer midpoints [m] real(kind_phys), intent(in) :: cp_phys(:,:) ! enthalpy (cpairv generally) [J kg-1 K-1] real(kind_phys), intent(in) :: cp_or_cv_dycore(:,:) ! enthalpy or heat capacity, dycore dependent [J K-1 kg-1] - integer, intent(in) :: vc_physics ! vertical coordinate system, physics - integer, intent(in) :: vc_dycore ! vertical coordinate system, dycore + integer, intent(in) :: energy_formula_physics! total energy formulation physics + integer, intent(in) :: energy_formula_dycore ! total energy formulation dycore ! Output arguments real(kind_phys), intent(out) :: temp_ini(:,:) ! initial temperature [K] @@ -103,7 +103,7 @@ subroutine check_energy_chng_timestep_init( & U = u (1:ncol,1:pver), & V = v (1:ncol,1:pver), & T = T (1:ncol,1:pver), & - vcoord = vc_physics, & ! vertical coordinate for physics + vcoord = energy_formula_physics, & ! energy formula for physics ptop = pintdry (1:ncol,1), & phis = phis (1:ncol), & te = te_ini_phys(1:ncol), & ! vertically integrated total energy @@ -117,7 +117,7 @@ subroutine check_energy_chng_timestep_init( & !------------------------------------------------ ! Dynamical core total energy. !------------------------------------------------ - if (vc_dycore == vc_dry_pressure) then + if (energy_formula_dycore == vc_dry_pressure) then ! SE dycore specific hydrostatic energy (enthalpy) call get_hydrostatic_energy( & tracer = q(1:ncol,1:pver,1:pcnst), & ! moist mixing ratios @@ -127,13 +127,13 @@ subroutine check_energy_chng_timestep_init( & U = u (1:ncol,1:pver), & V = v (1:ncol,1:pver), & T = T (1:ncol,1:pver), & - vcoord = vc_dycore, & ! vertical coordinate for dycore + vcoord = energy_formula_dycore, & ! energy formula for dycore ptop = pintdry (1:ncol,1), & phis = phis (1:ncol), & te = te_ini_dyn (1:ncol) & ! WRITE OPERATION - vertically integrated total energy ) - else if (vc_dycore == vc_height) then + else if (energy_formula_dycore == vc_height) then ! MPAS dycore: compute cv if vertical coordinate is height: cv = cp - R (internal energy) call get_hydrostatic_energy( & tracer = q(1:ncol,1:pver,1:pcnst), & ! moist mixing ratios @@ -143,7 +143,7 @@ subroutine check_energy_chng_timestep_init( & U = u (1:ncol,1:pver), & V = v (1:ncol,1:pver), & T = T (1:ncol,1:pver), & ! enthalpy-scaled temperature for energy consistency - vcoord = vc_dycore, & ! vertical coordinate for dycore + vcoord = energy_formula_dycore, & ! energy formula for dycore ptop = pintdry (1:ncol,1), & phis = phis (1:ncol), & z_mid = z_ini (1:ncol,:), & ! unique for vc_height (MPAS) @@ -191,14 +191,15 @@ subroutine check_energy_chng_run( & temp_ini, z_ini, & count, ztodt, & latice, latvap, & - vc_physics, vc_dycore, & + energy_formula_physics, energy_formula_dycore, & name, flx_vap, flx_cnd, flx_ice, flx_sen, & errmsg, errflg) ! Dependency for hydrostatic energy calculation (physics and dycore formulas) use cam_thermo, only: get_hydrostatic_energy - ! FIXME: Flags for vertical coordinate used in physics/dycore + !REMOVECAM: when CAM is retired the energy formulation flag values which are + ! stored in dyn_tests_utils can be changed to use cam_thermo_formula use dyn_tests_utils, only: vc_height, vc_dry_pressure ! FIXME hplin: for DEBUG only @@ -224,8 +225,8 @@ subroutine check_energy_chng_run( & real(kind_phys), intent(in) :: ztodt ! 2 delta t (model time increment) [s] real(kind_phys), intent(in) :: latice ! constant, latent heat of fusion of water at 0 C [J kg-1] real(kind_phys), intent(in) :: latvap ! constant, latent heat of vaporization of water at 0 C [J kg-1] - integer, intent(in) :: vc_physics ! vertical coordinate system, physics - integer, intent(in) :: vc_dycore ! vertical coordinate system, dycore + integer, intent(in) :: energy_formula_physics! total energy formulation physics + integer, intent(in) :: energy_formula_dycore ! total energy formulation dycore ! Input from CCPP-scheme being checked: ! parameterization name; surface fluxes of (1) vapor, (2) liquid+ice, (3) ice, (4) sensible heat @@ -290,7 +291,7 @@ subroutine check_energy_chng_run( & U = u (1:ncol,1:pver), & V = v (1:ncol,1:pver), & T = T (1:ncol,1:pver), & - vcoord = vc_physics, & ! vertical coordinate for physics + vcoord = energy_formula_physics, & ! energy formula for physics ptop = pintdry(1:ncol,1), & phis = phis (1:ncol), & te = te (1:ncol), & ! vertically integrated total energy @@ -366,7 +367,7 @@ subroutine check_energy_chng_run( & !------------------------------------------------ ! Dynamical core total energy. !------------------------------------------------ - if (vc_dycore == vc_dry_pressure) then + if (energy_formula_dycore == vc_dry_pressure) then ! SE dycore specific hydrostatic energy ! enthalpy scaling for energy consistency @@ -380,13 +381,13 @@ subroutine check_energy_chng_run( & U = u (1:ncol,1:pver), & V = v (1:ncol,1:pver), & T = temp (1:ncol,1:pver), & ! enthalpy-scaled temperature for energy consistency - vcoord = vc_dycore, & ! vertical coordinate for dycore + vcoord = energy_formula_dycore, & ! energy formula for dycore ptop = pintdry (1:ncol,1), & phis = phis (1:ncol), & te = te_cur_dyn (1:ncol) & ! WRITE OPERATION - vertically integrated total energy ) - else if (vc_dycore == vc_height) then + else if (energy_formula_dycore == vc_height) then ! MPAS dycore: compute cv if vertical coordinate is height: cv = cp - R ! REMOVECAM: note this scaling is different with subcols off/on which is why it was put into separate scheme (hplin, 9/5/24) @@ -400,7 +401,7 @@ subroutine check_energy_chng_run( & U = u (1:ncol,1:pver), & V = v (1:ncol,1:pver), & T = temp (1:ncol,1:pver), & ! enthalpy-scaled temperature for energy consistency - vcoord = vc_dycore, & ! vertical coordinate for dycore + vcoord = energy_formula_dycore, & ! energy formula for dycore ptop = pintdry (1:ncol,1), & phis = phis (1:ncol), & z_mid = z_ini (1:ncol,:), & ! unique for vc_height (MPAS) diff --git a/schemes/check_energy/check_energy_chng.meta b/schemes/check_energy/check_energy_chng.meta index d473155c..152f6e0f 100644 --- a/schemes/check_energy/check_energy_chng.meta +++ b/schemes/check_energy/check_energy_chng.meta @@ -173,13 +173,13 @@ type = real | kind = kind_phys dimensions = (horizontal_dimension) intent = out -[ vc_physics ] +[ energy_formula_physics ] standard_name = total_energy_formula_for_physics units = 1 type = integer dimensions = () intent = in -[ vc_dycore ] +[ energy_formula_dycore ] standard_name = total_energy_formula_for_dycore units = 1 type = integer @@ -351,13 +351,13 @@ type = real | kind = kind_phys dimensions = () intent = in -[ vc_physics ] +[ energy_formula_physics ] standard_name = total_energy_formula_for_physics units = 1 type = integer dimensions = () intent = in -[ vc_dycore ] +[ energy_formula_dycore ] standard_name = total_energy_formula_for_dycore units = 1 type = integer From c925c0b2da157dca9284f422dad6d7d08b7e35f3 Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Wed, 23 Oct 2024 13:18:00 -0400 Subject: [PATCH 23/41] Move energy formula definitions to cam_thermo_formula --- schemes/check_energy/check_energy_chng.F90 | 28 ++++++++++------------ 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/schemes/check_energy/check_energy_chng.F90 b/schemes/check_energy/check_energy_chng.F90 index a5b2226f..e5827c00 100644 --- a/schemes/check_energy/check_energy_chng.F90 +++ b/schemes/check_energy/check_energy_chng.F90 @@ -48,11 +48,8 @@ subroutine check_energy_chng_timestep_init( & errmsg, errflg) ! Dependency for hydrostatic energy calculation (physics and dycore formulas) - use cam_thermo, only: get_hydrostatic_energy - - !REMOVECAM: when CAM is retired the energy formulation flag values which are - ! stored in dyn_tests_utils can be changed to use cam_thermo_formula - use dyn_tests_utils, only: vc_height, vc_dry_pressure + use cam_thermo, only: get_hydrostatic_energy + use cam_thermo_formula, only: ENERGY_FORMULA_DYCORE_SE, ENERGY_FORMULA_DYCORE_MPAS ! Input arguments integer, intent(in) :: ncol ! number of atmospheric columns @@ -117,7 +114,7 @@ subroutine check_energy_chng_timestep_init( & !------------------------------------------------ ! Dynamical core total energy. !------------------------------------------------ - if (energy_formula_dycore == vc_dry_pressure) then + if (energy_formula_dycore == ENERGY_FORMULA_DYCORE_SE) then ! SE dycore specific hydrostatic energy (enthalpy) call get_hydrostatic_energy( & tracer = q(1:ncol,1:pver,1:pcnst), & ! moist mixing ratios @@ -133,7 +130,7 @@ subroutine check_energy_chng_timestep_init( & te = te_ini_dyn (1:ncol) & ! WRITE OPERATION - vertically integrated total energy ) - else if (energy_formula_dycore == vc_height) then + else if (energy_formula_dycore == ENERGY_FORMULA_DYCORE_MPAS) then ! MPAS dycore: compute cv if vertical coordinate is height: cv = cp - R (internal energy) call get_hydrostatic_energy( & tracer = q(1:ncol,1:pver,1:pcnst), & ! moist mixing ratios @@ -146,7 +143,7 @@ subroutine check_energy_chng_timestep_init( & vcoord = energy_formula_dycore, & ! energy formula for dycore ptop = pintdry (1:ncol,1), & phis = phis (1:ncol), & - z_mid = z_ini (1:ncol,:), & ! unique for vc_height (MPAS) + z_mid = z_ini (1:ncol,:), & ! unique for MPAS te = te_ini_dyn (1:ncol) & ! WRITE OPERATION - vertically integrated total energy ) else @@ -196,14 +193,13 @@ subroutine check_energy_chng_run( & errmsg, errflg) ! Dependency for hydrostatic energy calculation (physics and dycore formulas) - use cam_thermo, only: get_hydrostatic_energy + use cam_thermo, only: get_hydrostatic_energy - !REMOVECAM: when CAM is retired the energy formulation flag values which are - ! stored in dyn_tests_utils can be changed to use cam_thermo_formula - use dyn_tests_utils, only: vc_height, vc_dry_pressure + ! Dependency for energy formula used by physics and dynamical cores + use cam_thermo_formula, only: ENERGY_FORMULA_DYCORE_FV, ENERGY_FORMULA_DYCORE_SE, ENERGY_FORMULA_DYCORE_MPAS ! FIXME hplin: for DEBUG only - use cam_logfile, only: iulog + use cam_logfile, only: iulog ! Input arguments integer, intent(in) :: ncol ! number of atmospheric columns @@ -367,7 +363,7 @@ subroutine check_energy_chng_run( & !------------------------------------------------ ! Dynamical core total energy. !------------------------------------------------ - if (energy_formula_dycore == vc_dry_pressure) then + if (energy_formula_dycore == ENERGY_FORMULA_DYCORE_SE) then ! SE dycore specific hydrostatic energy ! enthalpy scaling for energy consistency @@ -387,7 +383,7 @@ subroutine check_energy_chng_run( & te = te_cur_dyn (1:ncol) & ! WRITE OPERATION - vertically integrated total energy ) - else if (energy_formula_dycore == vc_height) then + else if (energy_formula_dycore == ENERGY_FORMULA_DYCORE_MPAS) then ! MPAS dycore: compute cv if vertical coordinate is height: cv = cp - R ! REMOVECAM: note this scaling is different with subcols off/on which is why it was put into separate scheme (hplin, 9/5/24) @@ -404,7 +400,7 @@ subroutine check_energy_chng_run( & vcoord = energy_formula_dycore, & ! energy formula for dycore ptop = pintdry (1:ncol,1), & phis = phis (1:ncol), & - z_mid = z_ini (1:ncol,:), & ! unique for vc_height (MPAS) + z_mid = z_ini (1:ncol,:), & ! unique for MPAS te = te_cur_dyn (1:ncol) & ! WRITE OPERATION - vertically integrated total energy ) From 952ebddfa22dd796578fba8d73db6128c8db88c1 Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Fri, 25 Oct 2024 11:42:30 -0400 Subject: [PATCH 24/41] Split out gmean_diagnostics; cleanup --- doc/ChangeLog | 61 +++++++++++++++++++ schemes/check_energy/check_energy_chng.F90 | 3 +- schemes/check_energy/check_energy_chng.meta | 2 +- .../check_energy_gmean/check_energy_gmean.F90 | 29 +++------ .../check_energy_gmean.meta | 24 ++++++++ .../check_energy_gmean_diagnostics.F90 | 60 ++++++++++++++++++ .../check_energy_gmean_diagnostics.meta | 49 +++++++++++++++ test/test_suites/suite_check_energy.xml | 2 + 8 files changed, 207 insertions(+), 23 deletions(-) create mode 100644 schemes/sima_diagnostics/check_energy_gmean_diagnostics.F90 create mode 100644 schemes/sima_diagnostics/check_energy_gmean_diagnostics.meta diff --git a/doc/ChangeLog b/doc/ChangeLog index 721b9f0d..8949b433 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,5 +1,66 @@ =============================================================== +Tag name: +Originator(s): jimmielin +Date: October 25, 2024 +One-line Summary: Implement CCPPized check_energy_chng and check_energy_fix +Github PR URL: + +This PR fixes the following NCAR/atmospheric_physics Github issues: #114 + +- Implements check_energy_chng. The routine computes total energies using physics and dycore formula and takes in boundary fluxes of vapor, liquid+ice, ice, sensible heat, and writes to log significant energy conservation errors. +In order to take in the scheme name and fluxes from the last calling physics scheme (usually zero) a check_energy_zero_fluxes has to be ran before the scheme, then the physics scheme to be checked, then check_energy_chng. + +- Implements check_energy_fix. The routine computes the heating rate required for global mean total energy conservation which is later applied by apply_heating_rate. +Supporting routines include the global mean calculator for total energy (check_energy_gmean) - stored in separate folder to prevent CAM from building it. +The global means are very useful for diagnosing model state (as the computed energy numbers include all model state incl. constituents) through a simple one-line printout. check_energy_gmean_diagnostics implements this. +At the end of the timestep check_energy_save_teout has to be ran in order to save total energies at the end of the timestep for use in the next timestep. + +- Diagnostics of intermediate quantities used in check_energy_diagnostics. + +Code reviewed by: + +List all existing files that have been added (A), modified (M), or deleted (D), +and describe the changes: + +- Docs: +M doc/ChangeLog + +- check_energy_chng and supporting routines: +A schemes/check_energy/check_energy_chng.F90 +A schemes/check_energy/check_energy_chng.meta +A schemes/check_energy/check_energy_chng_namelist.xml +A schemes/check_energy/check_energy_scaling.F90 +A schemes/check_energy/check_energy_scaling.meta +A schemes/check_energy/check_energy_zero_fluxes.F90 +A schemes/check_energy/check_energy_zero_fluxes.meta + +- check_energy_fix and supporting routines: +A schemes/check_energy/check_energy_fix.F90 +A schemes/check_energy/check_energy_fix.meta +A schemes/check_energy/check_energy_gmean/check_energy_gmean.F90 +A schemes/check_energy/check_energy_gmean/check_energy_gmean.meta +A schemes/check_energy/check_energy_save_teout.F90 +A schemes/check_energy/check_energy_save_teout.meta + +- check_energy related diagnostics: +A schemes/sima_diagnostics/check_energy_diagnostics.F90 +A schemes/sima_diagnostics/check_energy_diagnostics.meta + +- check_energy_gmean "nstep, te" atm.log output: +A schemes/sima_diagnostics/check_energy_gmean_diagnostics.F90 +A schemes/sima_diagnostics/check_energy_gmean_diagnostics.meta + +- test SDF including all functionality: +A test/test_suites/suite_check_energy.xml + + +List and Describe any test failures: N/A + +Summarize any changes to answers: none + +=============================================================== + Tag name: Originator(s): jimmielin Date: October 17, 2024 diff --git a/schemes/check_energy/check_energy_chng.F90 b/schemes/check_energy/check_energy_chng.F90 index e5827c00..812d90df 100644 --- a/schemes/check_energy/check_energy_chng.F90 +++ b/schemes/check_energy/check_energy_chng.F90 @@ -354,7 +354,8 @@ subroutine check_energy_chng_run( & end if ! WRITE OPERATION - copy new value to state, including total water. - ! the total water operations are consistent regardless of vcoord, so it only has to be written once. + ! the total water operations are consistent regardless of energy formula, + ! so it only has to be written once. do i = 1, ncol te_cur_phys(i) = te(i) tw_cur(i) = tw(i) diff --git a/schemes/check_energy/check_energy_chng.meta b/schemes/check_energy/check_energy_chng.meta index 152f6e0f..b5fc90d3 100644 --- a/schemes/check_energy/check_energy_chng.meta +++ b/schemes/check_energy/check_energy_chng.meta @@ -1,7 +1,7 @@ [ccpp-table-properties] name = check_energy_chng type = scheme - dependencies = ../../../../data/cam_thermo.F90,../../../../dynamics/tests/dyn_tests_utils.F90 + dependencies = ../../../../data/cam_thermo.F90,../../../../data/cam_thermo_formula.F90 [ccpp-arg-table] diff --git a/schemes/check_energy/check_energy_gmean/check_energy_gmean.F90 b/schemes/check_energy/check_energy_gmean/check_energy_gmean.F90 index f8cd88ff..5aa784b8 100644 --- a/schemes/check_energy/check_energy_gmean/check_energy_gmean.F90 +++ b/schemes/check_energy/check_energy_gmean/check_energy_gmean.F90 @@ -18,16 +18,12 @@ subroutine check_energy_gmean_run( & gravit, & pint, & te_ini_dyn, teout, & - tedif_glob, heat_glob) + tedif_glob, heat_glob, & + teinp_glob, teout_glob, psurf_glob, ptopb_glob) ! Dependency: Uses gmean from src/utils use gmean_mod, only: gmean - ! Dev-only Dependency: Debug output to mimic CAM behavior - use spmd_utils, only: masterproc - use cam_logfile, only: iulog - use time_manager, only: get_nstep - ! Input arguments integer, intent(in) :: ncol ! number of atmospheric columns integer, intent(in) :: pver ! number of vertical layers @@ -41,19 +37,16 @@ subroutine check_energy_gmean_run( & real(kind_phys), intent(out) :: tedif_glob ! global mean energy difference [J m-2] real(kind_phys), intent(out) :: heat_glob ! global mean heating rate [J kg-1 s-1] + ! Output for check_energy_gmean_diagnostics + real(kind_phys), intent(out) :: teinp_glob ! global mean energy of input state [J m-2] + real(kind_phys), intent(out) :: teout_glob ! global mean energy of output state [J m-2] + 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] + ! 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 - real(kind_phys) :: teinp_glob ! global mean energy of input state [J m-2] - real(kind_phys) :: teout_glob ! global mean energy of output state [J m-2] - real(kind_phys) :: psurf_glob ! global mean surface pressure [Pa] - real(kind_phys) :: ptopb_glob ! global mean top boundary pressure [Pa] - - ! DEVNOTE hplin: in CAM te(i, lchnk, 2) gets teout from pbuf and this is chunkized. - ! so check_energy_gmean_run ccppized will not be used in CAM because of this chunk handling, - ! and so will gmean be different between CAM and CAM-SIMA. - ! 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] @@ -73,12 +66,6 @@ subroutine check_energy_gmean_run( & ! Compute global mean total energy difference for check_energy_fix tedif_glob = teinp_glob - teout_glob heat_glob = -tedif_glob/dtime * gravit / (psurf_glob - ptopb_glob) ! [J kg-1 s-1] - - ! Dev-only: Debug output for CAM only - if (masterproc) then - write(iulog,'(1x,a9,1x,i8,5(1x,e25.17))') "nstep, te", get_nstep(), teinp_glob, teout_glob, & - heat_glob, psurf_glob, ptopb_glob - endif end subroutine check_energy_gmean_run end module check_energy_gmean diff --git a/schemes/check_energy/check_energy_gmean/check_energy_gmean.meta b/schemes/check_energy/check_energy_gmean/check_energy_gmean.meta index 09385652..14d8409d 100644 --- a/schemes/check_energy/check_energy_gmean/check_energy_gmean.meta +++ b/schemes/check_energy/check_energy_gmean/check_energy_gmean.meta @@ -60,3 +60,27 @@ type = real | kind = kind_phys dimensions = () intent = out +[ teinp_glob ] + standard_name = global_mean_vertically_integrated_total_energy_of_initial_state_using_dycore_energy_formula + units = J m-2 + type = real | kind = kind_phys + dimensions = () + intent = out +[ teout_glob ] + standard_name = global_mean_vertically_integrated_total_energy_at_end_of_physics + units = J m-2 + type = real | kind = kind_phys + dimensions = () + intent = out +[ psurf_glob ] + standard_name = global_mean_surface_air_pressure + units = Pa + type = real | kind = kind_phys + dimensions = () + intent = out +[ ptopb_glob ] + standard_name = global_mean_air_pressure_at_top_of_atmosphere_model + units = Pa + type = real | kind = kind_phys + dimensions = () + intent = out diff --git a/schemes/sima_diagnostics/check_energy_gmean_diagnostics.F90 b/schemes/sima_diagnostics/check_energy_gmean_diagnostics.F90 new file mode 100644 index 00000000..3880949f --- /dev/null +++ b/schemes/sima_diagnostics/check_energy_gmean_diagnostics.F90 @@ -0,0 +1,60 @@ +! Diagnostic scheme for check_energy_gmean +! This replicates the "debug printout" with the global mean total energy in CAM: +! nstep, te 0 0.25872620595082335E+10 0.25872620595082335E+10 -0.00000000000000000E+00 0.10126767279027148E+06 0.21940670000000080E+03 +! where the numbers correspond to: +! - timestep number +! - global mean input energy using dycore energy formula +! - global mean output energy at end of physics timestep using dycore energy formula +! - global mean heating rate for energy conservation +! - global mean surface pressure +! - global mean model top pressure +! These numbers are very useful for matching models bit-for-bit because they include "everything" in the model. +module check_energy_gmean_diagnostics + use ccpp_kinds, only: kind_phys + + implicit none + private + save + + public :: check_energy_gmean_diagnostics_run ! main routine + +CONTAINS + + !> \section arg_table_check_energy_gmean_diagnostics_run Argument Table + !! \htmlinclude check_energy_gmean_diagnostics_run.html + subroutine check_energy_gmean_diagnostics_run( & + teinp_glob, & + teout_glob, & + heat_glob, & + psurf_glob, & + ptopb_glob, & + errmsg, errflg) + + use spmd_utils, only: masterproc + use cam_logfile, only: iulog + use time_manager, only: get_nstep + + !------------------------------------------------ + ! Input / output parameters + !------------------------------------------------ + real(kind_phys), intent(in) :: teinp_glob ! global mean energy of input state [J m-2] + real(kind_phys), intent(in) :: teout_glob ! global mean energy of output state [J m-2] + real(kind_phys), intent(in) :: psurf_glob ! global mean surface pressure [Pa] + real(kind_phys), intent(in) :: ptopb_glob ! global mean top boundary pressure [Pa] + real(kind_phys), intent(in) :: heat_glob ! global mean heating rate [J kg-1 s-1] + + ! CCPP error handling variables + character(len=512), intent(out) :: errmsg + integer, intent(out) :: errflg + + errmsg = '' + errflg = 0 + + if (masterproc) then + write(iulog,'(1x,a9,1x,i8,5(1x,e25.17))') "nstep, te", get_nstep(), teinp_glob, teout_glob, & + heat_glob, psurf_glob, ptopb_glob + endif + + end subroutine check_energy_gmean_diagnostics_run + +end module check_energy_gmean_diagnostics diff --git a/schemes/sima_diagnostics/check_energy_gmean_diagnostics.meta b/schemes/sima_diagnostics/check_energy_gmean_diagnostics.meta new file mode 100644 index 00000000..952b2558 --- /dev/null +++ b/schemes/sima_diagnostics/check_energy_gmean_diagnostics.meta @@ -0,0 +1,49 @@ +[ccpp-table-properties] + name = check_energy_gmean_diagnostics + type = scheme + +[ccpp-arg-table] + name = check_energy_gmean_diagnostics_run + type = scheme +[ teinp_glob ] + standard_name = global_mean_vertically_integrated_total_energy_of_initial_state_using_dycore_energy_formula + units = J m-2 + type = real | kind = kind_phys + dimensions = () + intent = in +[ teout_glob ] + standard_name = global_mean_vertically_integrated_total_energy_at_end_of_physics + units = J m-2 + type = real | kind = kind_phys + dimensions = () + intent = in +[ heat_glob ] + standard_name = global_mean_heating_rate_correction_for_energy_conservation + units = J kg-1 s-1 + type = real | kind = kind_phys + dimensions = () + intent = in +[ psurf_glob ] + standard_name = global_mean_surface_air_pressure + units = Pa + type = real | kind = kind_phys + dimensions = () + intent = in +[ ptopb_glob ] + standard_name = global_mean_air_pressure_at_top_of_atmosphere_model + units = Pa + type = real | kind = kind_phys + dimensions = () + 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 diff --git a/test/test_suites/suite_check_energy.xml b/test/test_suites/suite_check_energy.xml index f84e9afd..36cfea8b 100644 --- a/test/test_suites/suite_check_energy.xml +++ b/test/test_suites/suite_check_energy.xml @@ -7,6 +7,8 @@ check_energy_gmean + + check_energy_gmean_diagnostics check_energy_zero_fluxes From 84371bd1c5c350d3a671024069d313c474e80b02 Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Fri, 25 Oct 2024 13:00:37 -0400 Subject: [PATCH 25/41] Update doc/NamesNotInDictionary.txt --- doc/NamesNotInDictionary.txt | 273 ++++++++++++++++++++++++----------- 1 file changed, 186 insertions(+), 87 deletions(-) diff --git a/doc/NamesNotInDictionary.txt b/doc/NamesNotInDictionary.txt index c934e247..192baf0c 100644 --- a/doc/NamesNotInDictionary.txt +++ b/doc/NamesNotInDictionary.txt @@ -1,19 +1,43 @@ ####################### Date/time of when script was run: -2024-10-10 14:17:36.423628 +2024-10-25 12:47:27.849590 ####################### Non-dictionary standard names found in the following metadata files: -------------------------- +atmospheric_physics/schemes/sima_diagnostics/check_energy_gmean_diagnostics.meta + + - global_mean_air_pressure_at_top_of_atmosphere_model + - global_mean_heating_rate_correction_for_energy_conservation + - global_mean_surface_air_pressure + - global_mean_vertically_integrated_total_energy_at_end_of_physics + - global_mean_vertically_integrated_total_energy_of_initial_state_using_dycore_energy_formula + +-------------------------- + +atmospheric_physics/schemes/sima_diagnostics/check_energy_diagnostics.meta + + - cumulative_total_energy_boundary_flux_using_physics_energy_formula + - cumulative_total_water_boundary_flux + - ratio_of_specific_heat_for_air_used_in_physics_energy_formula_and_specific_heat_for_air_used_in_dycore_energy_formula + - specific_heat_for_air_used_in_dycore + - vertically_integrated_total_energy_at_end_of_physics + - vertically_integrated_total_energy_of_current_state_using_dycore_energy_formula + - vertically_integrated_total_energy_of_current_state_using_physics_energy_formula + - vertically_integrated_water_vapor_and_condensed_water_of_current_state + +-------------------------- + atmospheric_physics/schemes/sima_diagnostics/sima_state_diagnostics.meta - air_pressure_at_interface - air_pressure_of_dry_air_at_interface - ln_air_pressure_at_interface - ln_air_pressure_of_dry_air_at_interface + - surface_air_pressure -------------------------- @@ -45,65 +69,49 @@ atmospheric_physics/schemes/sima_diagnostics/tropopause_diagnostics.meta -------------------------- -atmospheric_physics/schemes/dry_adiabatic_adjust/dadadj.meta +atmospheric_physics/schemes/tj2016/tj2016_precip.meta - - air_pressure_at_interface - - binary_indicator_for_dry_adiabatic_adjusted_grid_cell - - number_of_iterations_for_dry_adiabatic_adjustment_algorithm_convergence - - number_of_vertical_levels_from_model_top_where_dry_adiabatic_adjustment_occurs - - tendency_of_water_vapor_mixing_ratio_wrt_moist_air_and_condensed_water + - gas_constant_of_water_vapor + - lwe_large_scale_precipitation_rate_at_surface + - ratio_of_water_vapor_to_dry_air_molecular_weights + - sum_of_sigma_pressure_hybrid_coordinate_a_coefficient_and_sigma_pressure_hybrid_coordinate_b_coefficient -------------------------- -atmospheric_physics/schemes/dry_adiabatic_adjust/dadadj_apply_qv_tendency.meta +atmospheric_physics/schemes/tj2016/tj2016_sfc_pbl_hs.meta - - tendency_of_water_vapor_mixing_ratio_wrt_moist_air_and_condensed_water + - air_pressure_at_interface + - eddy_heat_diffusivity + - eddy_momentum_diffusivity + - gas_constant_of_water_vapor + - ln_air_pressure_at_interface + - pi_constant + - ratio_of_water_vapor_to_dry_air_molecular_weights + - sum_of_sigma_pressure_hybrid_coordinate_a_coefficient_and_sigma_pressure_hybrid_coordinate_b_coefficient + - surface_air_pressure + - surface_eastward_wind_stress + - surface_evaporation_rate + - surface_northward_wind_stress + - surface_upward_sensible_heat_flux + - tendency_of_air_temperature_due_to_diabatic_heating + - tendency_of_air_temperature_due_to_vertical_diffusion + - tendency_of_water_vapor_mixing_ratio_wrt_moist_air_and_condensed_water_due_to_vertical_diffusion -------------------------- -atmospheric_physics/schemes/utilities/geopotential_temp.meta +atmospheric_physics/schemes/dry_adiabatic_adjust/dadadj.meta - air_pressure_at_interface - - ln_air_pressure_at_interface + - binary_indicator_for_dry_adiabatic_adjusted_grid_cell + - number_of_iterations_for_dry_adiabatic_adjustment_algorithm_convergence + - number_of_vertical_levels_from_model_top_where_dry_adiabatic_adjustment_occurs + - tendency_of_water_vapor_mixing_ratio_wrt_moist_air_and_condensed_water -------------------------- -atmospheric_physics/schemes/tropopause_find/tropopause_find.meta +atmospheric_physics/schemes/dry_adiabatic_adjust/dadadj_apply_qv_tendency.meta - - air_pressure_at_interface - - fill_value_for_diagnostic_output - - fractional_calendar_days_on_end_of_current_timestep - - pi_constant - - ratio_of_dry_air_gas_constant_to_specific_heat_of_dry_air_at_constant_pressure - - tropopause_air_pressure - - tropopause_air_pressure_from_chemical_method - - tropopause_air_pressure_from_climatological_method - - tropopause_air_pressure_from_climatology_dataset - - tropopause_air_pressure_from_cold_point_method - - tropopause_air_pressure_from_hybrid_stobie_linoz_with_climatological_backup_method - - tropopause_air_pressure_from_lapse_rate_method - - tropopause_air_temperature - - tropopause_air_temperature_from_chemical_method - - tropopause_air_temperature_from_climatological_method - - tropopause_air_temperature_from_cold_point_method - - tropopause_air_temperature_from_hybrid_stobie_linoz_with_climatological_backup_method - - tropopause_air_temperature_from_lapse_rate_method - - tropopause_calendar_days_from_climatology - - tropopause_geopotential_height_wrt_surface - - tropopause_geopotential_height_wrt_surface_from_chemical_method - - tropopause_geopotential_height_wrt_surface_from_climatological_method - - tropopause_geopotential_height_wrt_surface_from_cold_point_method - - tropopause_geopotential_height_wrt_surface_from_hybrid_stobie_linoz_with_climatological_backup_method - - tropopause_geopotential_height_wrt_surface_from_lapse_rate_method - - tropopause_vertical_layer_index - - tropopause_vertical_layer_index_from_chemical_method - - tropopause_vertical_layer_index_from_climatological_method - - tropopause_vertical_layer_index_from_cold_point_method - - tropopause_vertical_layer_index_from_hybrid_stobie_linoz_with_climatological_backup_method - - tropopause_vertical_layer_index_from_hybrid_stobie_linoz_with_climatological_backup_method_for_chemistry - - tropopause_vertical_layer_index_from_lapse_rate_method - - vertical_layer_index_lower_bound_from_hybrid_stobie_linoz_with_climatological_backup_method_for_linearized_ozone_chemistry - - vertical_layer_index_lower_bound_from_hybrid_stobie_linoz_with_climatological_backup_method_for_stratospheric_chemistry + - tendency_of_water_vapor_mixing_ratio_wrt_moist_air_and_condensed_water -------------------------- @@ -134,6 +142,32 @@ atmospheric_physics/schemes/zhang_mcfarlane/zm_conv_momtran.meta -------------------------- +atmospheric_physics/schemes/zhang_mcfarlane/zm_conv_evap.meta + + - + - cloud_area_fraction + - flag_for_zhang_mcfarlane_convective_organization_parameterization? + - freezing_point_of_water? + - frozen_precipitation_mass_flux_at_interface_due_to_deep_convection? + - heating_rate + - latent_heat_of_fusion_of_water_at_0c? + - latent_heat_of_vaporization_of_water_at_0c? + - lwe_frozen_precipitation_rate_at_surface_due_to_deep_convection + - lwe_precipitation_rate_at_surface_due_to_deep_convection + - precipitation_mass_flux_at_interface_due_to_deep_convection? + - pressure_thickness + - specific_heat_of_dry_air_at_constant_pressure? + - tendency_of_dry_air_enthalpy_at_constant_pressure_due_to_frozen_precipitation_melt? + - tendency_of_dry_air_enthalpy_at_constant_pressure_due_to_frozen_precipitation_production_in_deep_convection? + - tendency_of_frozen_precipitation_wrt_moist_air_and_condensed_water_due_to_deep_convection? + - tendency_of_precipitation_wrt_moist_air_and_condensed_water_due_to_deep_convection? + - tendency_of_precipitation_wrt_moist_air_and_condensed_water_due_to_deep_convection_excluding_subcloud_evaporation + - tendency_of_water_vapor_mixing_ratio_wrt_moist_air and_condensed_water? + - tunable_evaporation_efficiency_for_land_in_zhang_mcfarlane_deep_convection_scheme? + - tunable_evaporation_efficiency_in_zhang_mcfarlane_deep_convection_scheme? + +-------------------------- + atmospheric_physics/schemes/zhang_mcfarlane/zm_convr.meta - air_pressure_at_interface @@ -212,57 +246,122 @@ atmospheric_physics/schemes/zhang_mcfarlane/zm_conv_convtran.meta -------------------------- -atmospheric_physics/schemes/zhang_mcfarlane/zm_conv_evap.meta +atmospheric_physics/schemes/utilities/geopotential_temp.meta - - - - cloud_area_fraction - - flag_for_zhang_mcfarlane_convective_organization_parameterization? - - freezing_point_of_water? - - frozen_precipitation_mass_flux_at_interface_due_to_deep_convection? - - heating_rate - - latent_heat_of_fusion_of_water_at_0c? - - latent_heat_of_vaporization_of_water_at_0c? - - lwe_frozen_precipitation_rate_at_surface_due_to_deep_convection - - lwe_precipitation_rate_at_surface_due_to_deep_convection - - precipitation_mass_flux_at_interface_due_to_deep_convection? - - pressure_thickness - - specific_heat_of_dry_air_at_constant_pressure? - - tendency_of_dry_air_enthalpy_at_constant_pressure_due_to_frozen_precipitation_melt? - - tendency_of_dry_air_enthalpy_at_constant_pressure_due_to_frozen_precipitation_production_in_deep_convection? - - tendency_of_frozen_precipitation_wrt_moist_air_and_condensed_water_due_to_deep_convection? - - tendency_of_precipitation_wrt_moist_air_and_condensed_water_due_to_deep_convection? - - tendency_of_precipitation_wrt_moist_air_and_condensed_water_due_to_deep_convection_excluding_subcloud_evaporation - - tendency_of_water_vapor_mixing_ratio_wrt_moist_air and_condensed_water? - - tunable_evaporation_efficiency_for_land_in_zhang_mcfarlane_deep_convection_scheme? - - tunable_evaporation_efficiency_in_zhang_mcfarlane_deep_convection_scheme? + - air_pressure_at_interface + - ln_air_pressure_at_interface -------------------------- -atmospheric_physics/schemes/tj2016/tj2016_precip.meta +atmospheric_physics/schemes/check_energy/check_energy_save_teout.meta - - gas_constant_of_water_vapor - - lwe_large_scale_precipitation_rate_at_surface - - ratio_of_water_vapor_to_dry_air_molecular_weights - - sum_of_sigma_pressure_hybrid_coordinate_a_coefficient_and_sigma_pressure_hybrid_coordinate_b_coefficient + - vertically_integrated_total_energy_at_end_of_physics + - vertically_integrated_total_energy_of_current_state_using_dycore_energy_formula -------------------------- -atmospheric_physics/schemes/tj2016/tj2016_sfc_pbl_hs.meta +atmospheric_physics/schemes/check_energy/check_energy_chng.meta + + - air_pressure_of_dry_air_at_interface + - control_for_energy_conservation_warning + - cumulative_total_energy_boundary_flux_using_physics_energy_formula + - cumulative_total_water_boundary_flux + - height_wrt_surface_of_initial_state + - latent_heat_of_fusion_of_water_at_0c + - net_ice_fluxes_through_top_and_bottom_of_atmosphere_column + - net_liquid_and_ice_fluxes_through_top_and_bottom_of_atmosphere_column + - net_sensible_heat_flux_through_top_and_bottom_of_atmosphere_column + - net_water_vapor_fluxes_through_top_and_bottom_of_atmosphere_column + - number_of_values_with_significant_energy_or_water_imbalances + - ratio_of_specific_heat_for_air_used_in_physics_energy_formula_and_specific_heat_for_air_used_in_dycore_energy_formula + - specific_heat_for_air_used_in_dycore + - temperature_of_initial_state + - total_energy_formula_for_dycore + - total_energy_formula_for_physics + - vertically_integrated_total_energy_at_end_of_physics + - vertically_integrated_total_energy_of_current_state_using_dycore_energy_formula + - vertically_integrated_total_energy_of_current_state_using_physics_energy_formula + - vertically_integrated_total_energy_of_initial_state_using_dycore_energy_formula + - vertically_integrated_total_energy_of_initial_state_using_physics_energy_formula + - vertically_integrated_water_vapor_and_condensed_water_of_current_state + - vertically_integrated_water_vapor_and_condensed_water_of_initial_state + +-------------------------- + +atmospheric_physics/schemes/check_energy/check_energy_zero_fluxes.meta + + - net_ice_fluxes_through_top_and_bottom_of_atmosphere_column + - net_liquid_and_ice_fluxes_through_top_and_bottom_of_atmosphere_column + - net_sensible_heat_flux_through_top_and_bottom_of_atmosphere_column + - net_water_vapor_fluxes_through_top_and_bottom_of_atmosphere_column + +-------------------------- + +atmospheric_physics/schemes/check_energy/check_energy_scaling.meta + + - ratio_of_specific_heat_for_air_used_in_physics_energy_formula_and_specific_heat_for_air_used_in_dycore_energy_formula + - specific_heat_for_air_used_in_dycore + +-------------------------- + +atmospheric_physics/schemes/check_energy/check_energy_fix.meta - air_pressure_at_interface - - eddy_heat_diffusivity - - eddy_momentum_diffusivity - - gas_constant_of_water_vapor - - ln_air_pressure_at_interface + - global_mean_heating_rate_correction_for_energy_conservation + - net_sensible_heat_flux_through_top_and_bottom_of_atmosphere_column_from_global_total_energy_correction + - reciprocal_of_gravitational_acceleration + +-------------------------- + +atmospheric_physics/schemes/check_energy/check_energy_gmean/check_energy_gmean.meta + + - air_pressure_at_interface + - global_mean_air_pressure_at_top_of_atmosphere_model + - global_mean_heating_rate_correction_for_energy_conservation + - global_mean_surface_air_pressure + - global_mean_total_energy_correction_for_energy_conservation + - global_mean_vertically_integrated_total_energy_at_end_of_physics + - global_mean_vertically_integrated_total_energy_of_initial_state_using_dycore_energy_formula + - vertically_integrated_total_energy_at_end_of_physics + - vertically_integrated_total_energy_of_initial_state_using_dycore_energy_formula + +-------------------------- + +atmospheric_physics/schemes/tropopause_find/tropopause_find.meta + + - air_pressure_at_interface + - fill_value_for_diagnostic_output + - fractional_calendar_days_on_end_of_current_timestep - pi_constant - - ratio_of_water_vapor_to_dry_air_molecular_weights - - sum_of_sigma_pressure_hybrid_coordinate_a_coefficient_and_sigma_pressure_hybrid_coordinate_b_coefficient - - surface_eastward_wind_stress - - surface_evaporation_rate - - surface_northward_wind_stress - - surface_upward_sensible_heat_flux - - tendency_of_air_temperature_due_to_diabatic_heating - - tendency_of_air_temperature_due_to_vertical_diffusion - - tendency_of_water_vapor_mixing_ratio_wrt_moist_air_and_condensed_water_due_to_vertical_diffusion + - ratio_of_dry_air_gas_constant_to_specific_heat_of_dry_air_at_constant_pressure + - tropopause_air_pressure + - tropopause_air_pressure_from_chemical_method + - tropopause_air_pressure_from_climatological_method + - tropopause_air_pressure_from_climatology_dataset + - tropopause_air_pressure_from_cold_point_method + - tropopause_air_pressure_from_hybrid_stobie_linoz_with_climatological_backup_method + - tropopause_air_pressure_from_lapse_rate_method + - tropopause_air_temperature + - tropopause_air_temperature_from_chemical_method + - tropopause_air_temperature_from_climatological_method + - tropopause_air_temperature_from_cold_point_method + - tropopause_air_temperature_from_hybrid_stobie_linoz_with_climatological_backup_method + - tropopause_air_temperature_from_lapse_rate_method + - tropopause_calendar_days_from_climatology + - tropopause_geopotential_height_wrt_surface + - tropopause_geopotential_height_wrt_surface_from_chemical_method + - tropopause_geopotential_height_wrt_surface_from_climatological_method + - tropopause_geopotential_height_wrt_surface_from_cold_point_method + - tropopause_geopotential_height_wrt_surface_from_hybrid_stobie_linoz_with_climatological_backup_method + - tropopause_geopotential_height_wrt_surface_from_lapse_rate_method + - tropopause_vertical_layer_index + - tropopause_vertical_layer_index_from_chemical_method + - tropopause_vertical_layer_index_from_climatological_method + - tropopause_vertical_layer_index_from_cold_point_method + - tropopause_vertical_layer_index_from_hybrid_stobie_linoz_with_climatological_backup_method + - tropopause_vertical_layer_index_from_hybrid_stobie_linoz_with_climatological_backup_method_for_chemistry + - tropopause_vertical_layer_index_from_lapse_rate_method + - vertical_layer_index_lower_bound_from_hybrid_stobie_linoz_with_climatological_backup_method_for_linearized_ozone_chemistry + - vertical_layer_index_lower_bound_from_hybrid_stobie_linoz_with_climatological_backup_method_for_stratospheric_chemistry ####################### From 44d724d8e88ab0b910543a9fdecd24fea9ca62f7 Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Mon, 28 Oct 2024 11:07:22 -0400 Subject: [PATCH 26/41] Fix len=* for dummy argument in check_energy_chng_run --- schemes/check_energy/check_energy_chng.F90 | 2 +- schemes/check_energy/check_energy_chng.meta | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/schemes/check_energy/check_energy_chng.F90 b/schemes/check_energy/check_energy_chng.F90 index 812d90df..c91a1afa 100644 --- a/schemes/check_energy/check_energy_chng.F90 +++ b/schemes/check_energy/check_energy_chng.F90 @@ -234,7 +234,7 @@ subroutine check_energy_chng_run( & ! Note that the precip and ice fluxes are in precip units (m/s). ! I would prefer to have kg/m2/s. ! I would also prefer liquid (not total) and ice fluxes - character(len=64), intent(in) :: name ! parameterization name for fluxes + character(len=*), intent(in) :: name ! parameterization name for fluxes real(kind_phys), intent(in) :: flx_vap(:) ! boundary flux of vapor [kg m-2 s-1] real(kind_phys), intent(in) :: flx_cnd(:) ! boundary flux of liquid+ice (precip?) [m s-1] real(kind_phys), intent(in) :: flx_ice(:) ! boundary flux of ice (snow?) [m s-1] diff --git a/schemes/check_energy/check_energy_chng.meta b/schemes/check_energy/check_energy_chng.meta index b5fc90d3..ede40d13 100644 --- a/schemes/check_energy/check_energy_chng.meta +++ b/schemes/check_energy/check_energy_chng.meta @@ -366,7 +366,7 @@ [ name ] standard_name = scheme_name units = none - type = character | kind = len=64 + type = character | kind = len=* dimensions = () intent = in [ flx_vap ] From 87a45418a647a08fc9626b1f04c8d6c0e460bfc0 Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Mon, 4 Nov 2024 14:33:34 -0500 Subject: [PATCH 27/41] Add adiabatic scheme; check_energy calls to CAM7; check_energy_fix compatibility with check_energy_chng --- schemes/check_energy/check_energy_fix.F90 | 8 +++++- schemes/check_energy/check_energy_fix.meta | 8 +++++- suites/suite_adiabatic.xml | 31 ++++++++++++++++++++++ suites/suite_cam7.xml | 14 ++++++++++ 4 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 suites/suite_adiabatic.xml diff --git a/schemes/check_energy/check_energy_fix.F90 b/schemes/check_energy/check_energy_fix.F90 index 3452e150..cbedccac 100644 --- a/schemes/check_energy/check_energy_fix.F90 +++ b/schemes/check_energy/check_energy_fix.F90 @@ -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, rga, heat_glob, ptend_s, eshflx) + subroutine check_energy_fix_run(ncol, pver, pint, rga, heat_glob, ptend_s, eshflx, scheme_name) ! Input arguments integer, intent(in) :: ncol ! number of atmospheric columns integer, intent(in) :: pver ! number of vertical layers @@ -20,10 +20,16 @@ subroutine check_energy_fix_run(ncol, pver, pint, rga, heat_glob, ptend_s, eshfl real(kind_phys), intent(in) :: heat_glob ! global mean heating rate [J kg-1 s-1] real(kind_phys), intent(out) :: ptend_s(:,:) ! physics tendency heating rate [J kg-1 s-1] real(kind_phys), intent(out) :: eshflx(:) ! effective sensible heat flux [W m-2] + ! for check_energy_chng + + character(len=64), intent(out) :: scheme_name ! scheme name ! Local variables integer :: i + ! Set scheme name for check_energy_chng + scheme_name = "check_energy_fix" + ! add (-) global mean total energy difference as heating ptend_s(:ncol, :pver) = heat_glob diff --git a/schemes/check_energy/check_energy_fix.meta b/schemes/check_energy/check_energy_fix.meta index ae0a014d..055bf5d3 100644 --- a/schemes/check_energy/check_energy_fix.meta +++ b/schemes/check_energy/check_energy_fix.meta @@ -42,8 +42,14 @@ dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = out [ eshflx ] - standard_name = net_sensible_heat_flux_through_top_and_bottom_of_atmosphere_column_from_global_total_energy_correction + 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 = out +[ scheme_name ] + standard_name = scheme_name + units = none + type = character | kind = len=64 + dimensions = () + intent = out diff --git a/suites/suite_adiabatic.xml b/suites/suite_adiabatic.xml new file mode 100644 index 00000000..f7df5701 --- /dev/null +++ b/suites/suite_adiabatic.xml @@ -0,0 +1,31 @@ + + + + + + check_energy_gmean + + check_energy_gmean_diagnostics + + + check_energy_zero_fluxes + check_energy_fix + apply_heating_rate + + + check_energy_scaling + check_energy_chng + + + check_energy_save_teout + + + + + + check_energy_scaling + + + diff --git a/suites/suite_cam7.xml b/suites/suite_cam7.xml index 1bacbe94..ae7d0c02 100644 --- a/suites/suite_cam7.xml +++ b/suites/suite_cam7.xml @@ -2,6 +2,20 @@ + + check_energy_gmean + + check_energy_gmean_diagnostics + + + check_energy_zero_fluxes + check_energy_fix + apply_heating_rate + + + check_energy_scaling + check_energy_chng + dadadj dadadj_apply_qv_tendency From 003ece7f3a88cef889fb72392600e6b0702cfcaf Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Tue, 5 Nov 2024 18:06:10 -0500 Subject: [PATCH 28/41] Add dycore_energy_consistency_adjust scheme --- .../dycore_energy_consistency_adjust.F90 | 50 +++++++++++++++++++ .../dycore_energy_consistency_adjust.meta | 49 ++++++++++++++++++ suites/suite_adiabatic.xml | 4 +- suites/suite_cam7.xml | 7 +++ 4 files changed, 108 insertions(+), 2 deletions(-) create mode 100644 schemes/check_energy/dycore_energy_consistency_adjust.F90 create mode 100644 schemes/check_energy/dycore_energy_consistency_adjust.meta diff --git a/schemes/check_energy/dycore_energy_consistency_adjust.F90 b/schemes/check_energy/dycore_energy_consistency_adjust.F90 new file mode 100644 index 00000000..9c40fd27 --- /dev/null +++ b/schemes/check_energy/dycore_energy_consistency_adjust.F90 @@ -0,0 +1,50 @@ +! MPAS and SE dynamical core specific +! 1) scaling of temperature for enforcing energy consistency +! 2) and to ensure correct computation of temperature dependent diagnostic tendencies, e.g., dtcore +module dycore_energy_consistency_adjust + use ccpp_kinds, only: kind_phys + implicit none + private + + public :: dycore_energy_consistency_adjust_run + +contains +!> \section arg_table_dycore_energy_consistency_adjust_run Argument Table +!! \htmlinclude arg_table_dycore_energy_consistency_adjust_run.html + subroutine dycore_energy_consistency_adjust_run( & + ncol, pver, & + energy_formula_dycore, & + scaling_dycore, & + temp_ini, & + t, & + tend_dtdt) + + ! Dependency for energy formula definitions in SIMA + use cam_thermo_formula, only: ENERGY_FORMULA_DYCORE_SE, ENERGY_FORMULA_DYCORE_MPAS + + ! Input arguments + integer, intent(in) :: ncol ! number of atmospheric columns + integer, intent(in) :: pver ! number of vertical layers + integer, intent(in) :: energy_formula_dycore ! total energy formulation dycore + real(kind_phys), intent(in) :: scaling_dycore(:,:) ! scaling for conversion of temperature increment [1] + real(kind_phys), intent(in) :: temp_ini(:,:) ! initial temperature [K] + + ! Input/output arguments + real(kind_phys), intent(inout) :: T(:,:) ! temperature [K] + real(kind_phys), intent(inout) :: tend_dtdt(:,:) ! model phys temperature tendency [K s-1] + + errmsg = '' + errflg = 0 + + if(energy_formula_dycore == ENERGY_FORMULA_DYCORE_MPAS .or. & + energy_formula_dycore == ENERGY_FORMULA_DYCORE_SE) then + T(:ncol,:) = temp_ini(:ncol,:) + & + scaling_dycore(:ncol,:) * (T(:ncol,:) - temp_ini(:ncol,:)) + + tend_dtdt(:ncol,:) = scaling_dycore(:ncol,:) * tend_dtdt(:ncol,:) + endif + ! do nothing for dynamical cores with energy consistent with CAM physics + + end subroutine dycore_energy_consistency_adjust_run + +end module dycore_energy_consistency_adjust diff --git a/schemes/check_energy/dycore_energy_consistency_adjust.meta b/schemes/check_energy/dycore_energy_consistency_adjust.meta new file mode 100644 index 00000000..be12dea1 --- /dev/null +++ b/schemes/check_energy/dycore_energy_consistency_adjust.meta @@ -0,0 +1,49 @@ +[ccpp-table-properties] + name = dycore_energy_consistency_adjust + type = scheme + +[ccpp-arg-table] + name = dycore_energy_consistency_adjust_run + type = scheme +[ ncol ] + standard_name = horizontal_dimension + units = count + type = integer + dimensions = () + intent = in +[ pver ] + standard_name = vertical_layer_dimension + units = count + type = integer + dimensions = () + intent = in +[ energy_formula_dycore ] + standard_name = total_energy_formula_for_dycore + units = 1 + type = integer + dimensions = () + intent = in +[ scaling_dycore ] + standard_name = ratio_of_specific_heat_for_air_used_in_physics_energy_formula_and_specific_heat_for_air_used_in_dycore_energy_formula + units = 1 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent, vertical_layer_dimension) + intent = in +[ temp_ini ] + standard_name = temperature_of_initial_state + units = K + type = real | kind = kind_phys + dimensions = (horizontal_dimension, vertical_layer_dimension) + intent = in +[ T ] + standard_name = air_temperature + units = K + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent, vertical_layer_dimension) + intent = inout +[ tend_dtdt ] + standard_name = tendency_of_air_temperature_due_to_model_physics + units = K s-1 + type = real | kind = kind_phys + dimensions = (horizontal_loop_extent, vertical_layer_dimension) + intent = inout diff --git a/suites/suite_adiabatic.xml b/suites/suite_adiabatic.xml index f7df5701..bc951316 100644 --- a/suites/suite_adiabatic.xml +++ b/suites/suite_adiabatic.xml @@ -24,8 +24,8 @@ + Then, perform the temperature and temperature tendency scaling --> check_energy_scaling - + dycore_energy_consistency_adjust diff --git a/suites/suite_cam7.xml b/suites/suite_cam7.xml index ae7d0c02..2a655286 100644 --- a/suites/suite_cam7.xml +++ b/suites/suite_cam7.xml @@ -31,6 +31,13 @@ tropopause_find tropopause_diagnostics + + + check_energy_scaling + dycore_energy_consistency_adjust + sima_tend_diagnostics From 56808e19c8bf0412d07f02404acf54d7d3e40fec Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Fri, 8 Nov 2024 10:49:33 -0500 Subject: [PATCH 29/41] Fix build error --- schemes/check_energy/dycore_energy_consistency_adjust.F90 | 3 --- 1 file changed, 3 deletions(-) diff --git a/schemes/check_energy/dycore_energy_consistency_adjust.F90 b/schemes/check_energy/dycore_energy_consistency_adjust.F90 index 9c40fd27..396fc86f 100644 --- a/schemes/check_energy/dycore_energy_consistency_adjust.F90 +++ b/schemes/check_energy/dycore_energy_consistency_adjust.F90 @@ -33,9 +33,6 @@ subroutine dycore_energy_consistency_adjust_run( & real(kind_phys), intent(inout) :: T(:,:) ! temperature [K] real(kind_phys), intent(inout) :: tend_dtdt(:,:) ! model phys temperature tendency [K s-1] - errmsg = '' - errflg = 0 - if(energy_formula_dycore == ENERGY_FORMULA_DYCORE_MPAS .or. & energy_formula_dycore == ENERGY_FORMULA_DYCORE_SE) then T(:ncol,:) = temp_ini(:ncol,:) + & From e87c44d14ceb7c2fdda788af60f5eb53ff047f83 Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Fri, 8 Nov 2024 11:17:52 -0500 Subject: [PATCH 30/41] Fix dycore_energy_consistency_adjust.meta ncol dimensions --- schemes/check_energy/dycore_energy_consistency_adjust.meta | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/schemes/check_energy/dycore_energy_consistency_adjust.meta b/schemes/check_energy/dycore_energy_consistency_adjust.meta index be12dea1..60708262 100644 --- a/schemes/check_energy/dycore_energy_consistency_adjust.meta +++ b/schemes/check_energy/dycore_energy_consistency_adjust.meta @@ -6,7 +6,7 @@ name = dycore_energy_consistency_adjust_run type = scheme [ ncol ] - standard_name = horizontal_dimension + standard_name = horizontal_loop_extent units = count type = integer dimensions = () @@ -33,7 +33,7 @@ standard_name = temperature_of_initial_state units = K type = real | kind = kind_phys - dimensions = (horizontal_dimension, vertical_layer_dimension) + dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = in [ T ] standard_name = air_temperature From 27238bcc86dbfaeb3599a8250174b4c2d452d640 Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Tue, 12 Nov 2024 20:26:59 -0500 Subject: [PATCH 31/41] Address code review comments --- doc/ChangeLog | 15 +++++++++-- schemes/check_energy/check_energy_chng.F90 | 13 +++++---- schemes/check_energy/check_energy_chng.meta | 10 +++++-- .../check_energy_chng_namelist.xml | 4 +-- .../check_energy_gmean/check_energy_gmean.F90 | 5 ++-- schemes/check_energy/check_energy_scaling.F90 | 5 ++-- .../check_energy/check_energy_scaling.meta | 6 ----- .../check_energy/check_energy_zero_fluxes.F90 | 1 - .../dycore_energy_consistency_adjust.F90 | 4 +-- .../check_energy_gmean_diagnostics.F90 | 17 ++++++------ .../check_energy_gmean_diagnostics.meta | 18 +++++++++++++ suites/suite_adiabatic.xml | 11 +++----- suites/suite_cam7.xml | 9 +++++-- suites/suite_held_suarez_1994.xml | 8 ++++++ suites/suite_kessler.xml | 8 ++++++ test/test_suites/suite_check_energy.xml | 27 ------------------- 16 files changed, 88 insertions(+), 73 deletions(-) delete mode 100644 test/test_suites/suite_check_energy.xml diff --git a/doc/ChangeLog b/doc/ChangeLog index 8949b433..ea566733 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -18,6 +18,8 @@ At the end of the timestep check_energy_save_teout has to be ran in order to sav - Diagnostics of intermediate quantities used in check_energy_diagnostics. +- Implements dycore_energy_consistency_adjust which adjusts temperature and temperature tendencies for the MPAS and SE dynamical cores. + Code reviewed by: List all existing files that have been added (A), modified (M), or deleted (D), @@ -51,8 +53,17 @@ A schemes/sima_diagnostics/check_energy_diagnostics.meta A schemes/sima_diagnostics/check_energy_gmean_diagnostics.F90 A schemes/sima_diagnostics/check_energy_gmean_diagnostics.meta -- test SDF including all functionality: -A test/test_suites/suite_check_energy.xml +- dycore_energy_consistency_adjust and applications in simple physics: +A schemes/check_energy/dycore_energy_consistency_adjust.F90 +A schemes/check_energy/dycore_energy_consistency_adjust.meta +M suites/suite_held_suarez_1994.xml +M suites/suite_kessler.xml + +- add check_energy to SDFs: +M suites/suite_cam7.xml + +- adiabatic SDF: +A suites/suite_adiabatic.xml List and Describe any test failures: N/A diff --git a/schemes/check_energy/check_energy_chng.F90 b/schemes/check_energy/check_energy_chng.F90 index c91a1afa..0b5a5608 100644 --- a/schemes/check_energy/check_energy_chng.F90 +++ b/schemes/check_energy/check_energy_chng.F90 @@ -1,5 +1,4 @@ module check_energy_chng - use ccpp_kinds, only: kind_phys implicit none @@ -47,7 +46,8 @@ subroutine check_energy_chng_timestep_init( & energy_formula_physics, energy_formula_dycore, & errmsg, errflg) - ! Dependency for hydrostatic energy calculation (physics and dycore formulas) + ! This scheme is non-portable due to dependencies on cam_thermo + ! for hydrostatic energy calculation (physics and dycore formulas) use cam_thermo, only: get_hydrostatic_energy use cam_thermo_formula, only: ENERGY_FORMULA_DYCORE_SE, ENERGY_FORMULA_DYCORE_MPAS @@ -176,6 +176,7 @@ end subroutine check_energy_chng_timestep_init !! \htmlinclude arg_table_check_energy_chng_run.html subroutine check_energy_chng_run( & ncol, pver, pcnst, & + iulog, & q, pdel, & u, v, T, & pintdry, phis, zm, & @@ -192,15 +193,13 @@ subroutine check_energy_chng_run( & name, flx_vap, flx_cnd, flx_ice, flx_sen, & errmsg, errflg) - ! Dependency for hydrostatic energy calculation (physics and dycore formulas) + ! This scheme is non-portable due to dependencies on cam_thermo + ! for hydrostatic energy calculation (physics and dycore formulas) use cam_thermo, only: get_hydrostatic_energy ! Dependency for energy formula used by physics and dynamical cores use cam_thermo_formula, only: ENERGY_FORMULA_DYCORE_FV, ENERGY_FORMULA_DYCORE_SE, ENERGY_FORMULA_DYCORE_MPAS - ! FIXME hplin: for DEBUG only - use cam_logfile, only: iulog - ! Input arguments integer, intent(in) :: ncol ! number of atmospheric columns integer, intent(in) :: pver ! number of vertical layers @@ -218,7 +217,7 @@ subroutine check_energy_chng_run( & real(kind_phys), intent(in) :: cp_phys(:,:) ! enthalpy (cpairv generally) [J kg-1 K-1] real(kind_phys), intent(in) :: cp_or_cv_dycore(:,:) ! enthalpy or heat capacity, dycore dependent [J K-1 kg-1] real(kind_phys), intent(in) :: scaling_dycore(:,:) ! scaling for conversion of temperature increment [1] - real(kind_phys), intent(in) :: ztodt ! 2 delta t (model time increment) [s] + real(kind_phys), intent(in) :: ztodt ! physics timestep [s] real(kind_phys), intent(in) :: latice ! constant, latent heat of fusion of water at 0 C [J kg-1] real(kind_phys), intent(in) :: latvap ! constant, latent heat of vaporization of water at 0 C [J kg-1] integer, intent(in) :: energy_formula_physics! total energy formulation physics diff --git a/schemes/check_energy/check_energy_chng.meta b/schemes/check_energy/check_energy_chng.meta index ede40d13..a37ca5b8 100644 --- a/schemes/check_energy/check_energy_chng.meta +++ b/schemes/check_energy/check_energy_chng.meta @@ -8,8 +8,8 @@ name = check_energy_chng_init type = scheme [ print_energy_errors_in ] - standard_name = control_for_energy_conservation_warning - units = none + standard_name = flag_for_energy_conservation_warning + units = flag type = logical dimensions = () intent = in @@ -219,6 +219,12 @@ type = integer dimensions = () intent = in +[ iulog ] + standard_name = log_output_unit + units = 1 + type = integer + dimensions = () + intent = in [ q ] standard_name = ccpp_constituents units = none diff --git a/schemes/check_energy/check_energy_chng_namelist.xml b/schemes/check_energy/check_energy_chng_namelist.xml index 4368b7b6..e6ff1bbc 100644 --- a/schemes/check_energy/check_energy_chng_namelist.xml +++ b/schemes/check_energy/check_energy_chng_namelist.xml @@ -7,8 +7,8 @@ logical diagnostics check_energy_nl - control_for_energy_conservation_warning - none + flag_for_energy_conservation_warning + flag Turn on verbose output identifying columns that fail energy/water conservation checks. Default: FALSE diff --git a/schemes/check_energy/check_energy_gmean/check_energy_gmean.F90 b/schemes/check_energy/check_energy_gmean/check_energy_gmean.F90 index 5aa784b8..4d50c428 100644 --- a/schemes/check_energy/check_energy_gmean/check_energy_gmean.F90 +++ b/schemes/check_energy/check_energy_gmean/check_energy_gmean.F90 @@ -21,7 +21,7 @@ subroutine check_energy_gmean_run( & tedif_glob, heat_glob, & teinp_glob, teout_glob, psurf_glob, ptopb_glob) - ! Dependency: Uses gmean from src/utils + ! This scheme is non-portable due to dependency: Global mean module gmean from src/utils use gmean_mod, only: gmean ! Input arguments @@ -30,7 +30,7 @@ subroutine check_energy_gmean_run( & real(kind_phys), intent(in) :: dtime ! physics time step [s] real(kind_phys), intent(in) :: gravit ! gravitational acceleration [m s-2] real(kind_phys), intent(in) :: pint(:,:) ! interface pressure [Pa] - real(kind_phys), intent(in) :: te_ini_dyn(:) ! dycore formula: initial total energy [J m-2] + real(kind_phys), intent(in) :: te_ini_dyn(:) ! dycore formula: initial total energy [J m-2] real(kind_phys), intent(in) :: teout(:) ! total energy for global fixer in next timestep [J m-2] ! Output arguments @@ -56,7 +56,6 @@ subroutine check_energy_gmean_run( & ! not constant for z-based vertical coordinate ! Compute global means of input and output energies and of surface pressure for heating rate. - ! (assuming uniform ptop) call gmean(te, te_glob, 4) teinp_glob = te_glob(1) teout_glob = te_glob(2) diff --git a/schemes/check_energy/check_energy_scaling.F90 b/schemes/check_energy/check_energy_scaling.F90 index a5d9a948..c10818c1 100644 --- a/schemes/check_energy/check_energy_scaling.F90 +++ b/schemes/check_energy/check_energy_scaling.F90 @@ -1,5 +1,5 @@ module check_energy_scaling - use ccpp_kinds, only: kind_phys + use ccpp_kinds, only: kind_phys implicit none private @@ -17,14 +17,13 @@ module check_energy_scaling !> \section arg_table_check_energy_scaling_run Argument Table !! \htmlinclude arg_table_check_energy_scaling_run.html subroutine check_energy_scaling_run( & - ncol, pver, & + ncol, & cp_or_cv_dycore, cpairv, & scaling_dycore, & errmsg, errflg) ! Input arguments integer, intent(in) :: ncol ! number of atmospheric columns - integer, intent(in) :: pver ! number of vertical layers real(kind_phys), intent(in) :: cp_or_cv_dycore(:,:) ! cp or cv from dycore [J kg-1 K-1] real(kind_phys), intent(in) :: cpairv(:,:) ! specific heat of dry air at constant pressure [J kg-1 K-1] diff --git a/schemes/check_energy/check_energy_scaling.meta b/schemes/check_energy/check_energy_scaling.meta index 066dcf6a..da74ea23 100644 --- a/schemes/check_energy/check_energy_scaling.meta +++ b/schemes/check_energy/check_energy_scaling.meta @@ -11,12 +11,6 @@ type = integer dimensions = () intent = in -[ pver ] - standard_name = vertical_layer_dimension - units = count - type = integer - dimensions = () - intent = in [ cp_or_cv_dycore ] standard_name = specific_heat_for_air_used_in_dycore units = J kg-1 K-1 diff --git a/schemes/check_energy/check_energy_zero_fluxes.F90 b/schemes/check_energy/check_energy_zero_fluxes.F90 index c4ffece3..bda0d74c 100644 --- a/schemes/check_energy/check_energy_zero_fluxes.F90 +++ b/schemes/check_energy/check_energy_zero_fluxes.F90 @@ -1,7 +1,6 @@ ! zeros input fluxes to check_energy ! before running other schemes module check_energy_zero_fluxes - use ccpp_kinds, only: kind_phys implicit none diff --git a/schemes/check_energy/dycore_energy_consistency_adjust.F90 b/schemes/check_energy/dycore_energy_consistency_adjust.F90 index 396fc86f..06925060 100644 --- a/schemes/check_energy/dycore_energy_consistency_adjust.F90 +++ b/schemes/check_energy/dycore_energy_consistency_adjust.F90 @@ -25,8 +25,8 @@ subroutine dycore_energy_consistency_adjust_run( & ! Input arguments integer, intent(in) :: ncol ! number of atmospheric columns integer, intent(in) :: pver ! number of vertical layers - integer, intent(in) :: energy_formula_dycore ! total energy formulation dycore - real(kind_phys), intent(in) :: scaling_dycore(:,:) ! scaling for conversion of temperature increment [1] + integer, intent(in) :: energy_formula_dycore ! total energy formulation used by dycore + real(kind_phys), intent(in) :: scaling_dycore(:,:) ! scaling for conversion of temperature increment [1] real(kind_phys), intent(in) :: temp_ini(:,:) ! initial temperature [K] ! Input/output arguments diff --git a/schemes/sima_diagnostics/check_energy_gmean_diagnostics.F90 b/schemes/sima_diagnostics/check_energy_gmean_diagnostics.F90 index 3880949f..9ee260ad 100644 --- a/schemes/sima_diagnostics/check_energy_gmean_diagnostics.F90 +++ b/schemes/sima_diagnostics/check_energy_gmean_diagnostics.F90 @@ -23,6 +23,9 @@ module check_energy_gmean_diagnostics !> \section arg_table_check_energy_gmean_diagnostics_run Argument Table !! \htmlinclude check_energy_gmean_diagnostics_run.html subroutine check_energy_gmean_diagnostics_run( & + amIRoot, & + iulog, & + nstep, & teinp_glob, & teout_glob, & heat_glob, & @@ -30,28 +33,24 @@ subroutine check_energy_gmean_diagnostics_run( & ptopb_glob, & errmsg, errflg) - use spmd_utils, only: masterproc - use cam_logfile, only: iulog - use time_manager, only: get_nstep + logical, intent(in) :: amIRoot + integer, intent(in) :: iulog ! log output unit + integer, intent(in) :: nstep ! current timestep number - !------------------------------------------------ - ! Input / output parameters - !------------------------------------------------ real(kind_phys), intent(in) :: teinp_glob ! global mean energy of input state [J m-2] real(kind_phys), intent(in) :: teout_glob ! global mean energy of output state [J m-2] real(kind_phys), intent(in) :: psurf_glob ! global mean surface pressure [Pa] real(kind_phys), intent(in) :: ptopb_glob ! global mean top boundary pressure [Pa] real(kind_phys), intent(in) :: heat_glob ! global mean heating rate [J kg-1 s-1] - ! CCPP error handling variables character(len=512), intent(out) :: errmsg integer, intent(out) :: errflg errmsg = '' errflg = 0 - if (masterproc) then - write(iulog,'(1x,a9,1x,i8,5(1x,e25.17))') "nstep, te", get_nstep(), teinp_glob, teout_glob, & + if (amIRoot) then + write(iulog,'(1x,a9,1x,i8,5(1x,e25.17))') "nstep, te", nstep, teinp_glob, teout_glob, & heat_glob, psurf_glob, ptopb_glob endif diff --git a/schemes/sima_diagnostics/check_energy_gmean_diagnostics.meta b/schemes/sima_diagnostics/check_energy_gmean_diagnostics.meta index 952b2558..583356c2 100644 --- a/schemes/sima_diagnostics/check_energy_gmean_diagnostics.meta +++ b/schemes/sima_diagnostics/check_energy_gmean_diagnostics.meta @@ -5,6 +5,24 @@ [ccpp-arg-table] name = check_energy_gmean_diagnostics_run type = scheme +[ amIRoot ] + standard_name = flag_for_mpi_root + units = flag + type = logical + dimensions = () + intent = in +[ iulog ] + standard_name = log_output_unit + units = 1 + type = integer + dimensions = () + intent = in +[ nstep ] + standard_name = current_timestep_number + units = count + type = integer + dimensions = () + intent = in [ teinp_glob ] standard_name = global_mean_vertically_integrated_total_energy_of_initial_state_using_dycore_energy_formula units = J m-2 diff --git a/suites/suite_adiabatic.xml b/suites/suite_adiabatic.xml index bc951316..20fc4557 100644 --- a/suites/suite_adiabatic.xml +++ b/suites/suite_adiabatic.xml @@ -11,6 +11,7 @@ check_energy_zero_fluxes check_energy_fix apply_heating_rate + geopotential_temp check_energy_scaling @@ -18,14 +19,10 @@ check_energy_save_teout + + sima_state_diagnostics - - - - check_energy_scaling - dycore_energy_consistency_adjust + sima_tend_diagnostics diff --git a/suites/suite_cam7.xml b/suites/suite_cam7.xml index 2a655286..bce3c2df 100644 --- a/suites/suite_cam7.xml +++ b/suites/suite_cam7.xml @@ -11,6 +11,7 @@ check_energy_zero_fluxes check_energy_fix apply_heating_rate + geopotential_temp check_energy_scaling @@ -22,16 +23,20 @@ apply_heating_rate qneg geopotential_temp - - sima_state_diagnostics + + sima_state_diagnostics + tropopause_find tropopause_diagnostics + + check_energy_save_teout + diff --git a/suites/suite_held_suarez_1994.xml b/suites/suite_held_suarez_1994.xml index 83d3d63a..cb62dff3 100644 --- a/suites/suite_held_suarez_1994.xml +++ b/suites/suite_held_suarez_1994.xml @@ -10,6 +10,14 @@ sima_state_diagnostics + + + + check_energy_scaling + dycore_energy_consistency_adjust + sima_tend_diagnostics diff --git a/suites/suite_kessler.xml b/suites/suite_kessler.xml index d8d58adb..c6b38dd0 100644 --- a/suites/suite_kessler.xml +++ b/suites/suite_kessler.xml @@ -20,6 +20,14 @@ kessler_diagnostics + + + + check_energy_scaling + dycore_energy_consistency_adjust + sima_tend_diagnostics diff --git a/test/test_suites/suite_check_energy.xml b/test/test_suites/suite_check_energy.xml deleted file mode 100644 index 36cfea8b..00000000 --- a/test/test_suites/suite_check_energy.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - check_energy_save_teout - - - check_energy_gmean - - check_energy_gmean_diagnostics - - - check_energy_zero_fluxes - check_energy_scaling - check_energy_chng - - check_energy_fix - apply_heating_rate - - - qneg - - check_energy_chng - check_energy_save_teout - - From 7b46000093aa3e4d2ab90b9bfadf8a06a1d87957 Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Wed, 13 Nov 2024 12:41:27 -0500 Subject: [PATCH 32/41] Update standard names --- doc/NamesNotInDictionary.txt | 49 +++++++++++-------- schemes/check_energy/check_energy_chng.F90 | 2 +- schemes/check_energy/check_energy_chng.meta | 16 +++--- .../check_energy_gmean.meta | 4 +- .../check_energy/check_energy_save_teout.meta | 2 +- .../check_energy/check_energy_scaling.meta | 4 +- .../check_energy_zero_fluxes.meta | 4 +- .../dycore_energy_consistency_adjust.meta | 2 +- .../check_energy_diagnostics.F90 | 6 +-- .../check_energy_diagnostics.meta | 6 +-- .../check_energy_gmean_diagnostics.meta | 2 +- 11 files changed, 53 insertions(+), 44 deletions(-) diff --git a/doc/NamesNotInDictionary.txt b/doc/NamesNotInDictionary.txt index 192baf0c..49fb304b 100644 --- a/doc/NamesNotInDictionary.txt +++ b/doc/NamesNotInDictionary.txt @@ -1,7 +1,7 @@ ####################### Date/time of when script was run: -2024-10-25 12:47:27.849590 +2024-11-13 12:40:59.115207 ####################### Non-dictionary standard names found in the following metadata files: @@ -10,10 +10,11 @@ Non-dictionary standard names found in the following metadata files: atmospheric_physics/schemes/sima_diagnostics/check_energy_gmean_diagnostics.meta + - current_timestep_number - global_mean_air_pressure_at_top_of_atmosphere_model - global_mean_heating_rate_correction_for_energy_conservation - global_mean_surface_air_pressure - - global_mean_vertically_integrated_total_energy_at_end_of_physics + - global_mean_vertically_integrated_total_energy_at_end_of_physics_timestep - global_mean_vertically_integrated_total_energy_of_initial_state_using_dycore_energy_formula -------------------------- @@ -22,9 +23,9 @@ atmospheric_physics/schemes/sima_diagnostics/check_energy_diagnostics.meta - cumulative_total_energy_boundary_flux_using_physics_energy_formula - cumulative_total_water_boundary_flux - - ratio_of_specific_heat_for_air_used_in_physics_energy_formula_and_specific_heat_for_air_used_in_dycore_energy_formula - - specific_heat_for_air_used_in_dycore - - vertically_integrated_total_energy_at_end_of_physics + - ratio_of_specific_heat_of_dry_air_used_in_physics_energy_formula_to_specific_heat_of_dry_air_used_in_dycore_energy_formula + - specific_heat_of_dry_air_used_in_dycore + - vertically_integrated_total_energy_at_end_of_physics_timestep - vertically_integrated_total_energy_of_current_state_using_dycore_energy_formula - vertically_integrated_total_energy_of_current_state_using_physics_energy_formula - vertically_integrated_water_vapor_and_condensed_water_of_current_state @@ -255,7 +256,7 @@ atmospheric_physics/schemes/utilities/geopotential_temp.meta atmospheric_physics/schemes/check_energy/check_energy_save_teout.meta - - vertically_integrated_total_energy_at_end_of_physics + - vertically_integrated_total_energy_at_end_of_physics_timestep - vertically_integrated_total_energy_of_current_state_using_dycore_energy_formula -------------------------- @@ -263,22 +264,22 @@ atmospheric_physics/schemes/check_energy/check_energy_save_teout.meta atmospheric_physics/schemes/check_energy/check_energy_chng.meta - air_pressure_of_dry_air_at_interface - - control_for_energy_conservation_warning - cumulative_total_energy_boundary_flux_using_physics_energy_formula - cumulative_total_water_boundary_flux + - flag_for_energy_conservation_warning - height_wrt_surface_of_initial_state - latent_heat_of_fusion_of_water_at_0c - - net_ice_fluxes_through_top_and_bottom_of_atmosphere_column - - net_liquid_and_ice_fluxes_through_top_and_bottom_of_atmosphere_column + - net_liquid_and_lwe_ice_fluxes_through_top_and_bottom_of_atmosphere_column + - net_lwe_ice_fluxes_through_top_and_bottom_of_atmosphere_column - net_sensible_heat_flux_through_top_and_bottom_of_atmosphere_column - net_water_vapor_fluxes_through_top_and_bottom_of_atmosphere_column - - number_of_values_with_significant_energy_or_water_imbalances - - ratio_of_specific_heat_for_air_used_in_physics_energy_formula_and_specific_heat_for_air_used_in_dycore_energy_formula - - specific_heat_for_air_used_in_dycore + - number_of_atmosphere_columns_with_significant_energy_or_water_imbalances + - ratio_of_specific_heat_of_dry_air_used_in_physics_energy_formula_to_specific_heat_of_dry_air_used_in_dycore_energy_formula + - specific_heat_of_dry_air_used_in_dycore - temperature_of_initial_state - total_energy_formula_for_dycore - total_energy_formula_for_physics - - vertically_integrated_total_energy_at_end_of_physics + - vertically_integrated_total_energy_at_end_of_physics_timestep - vertically_integrated_total_energy_of_current_state_using_dycore_energy_formula - vertically_integrated_total_energy_of_current_state_using_physics_energy_formula - vertically_integrated_total_energy_of_initial_state_using_dycore_energy_formula @@ -290,17 +291,25 @@ atmospheric_physics/schemes/check_energy/check_energy_chng.meta atmospheric_physics/schemes/check_energy/check_energy_zero_fluxes.meta - - net_ice_fluxes_through_top_and_bottom_of_atmosphere_column - - net_liquid_and_ice_fluxes_through_top_and_bottom_of_atmosphere_column + - net_liquid_and_lwe_ice_fluxes_through_top_and_bottom_of_atmosphere_column + - net_lwe_ice_fluxes_through_top_and_bottom_of_atmosphere_column - net_sensible_heat_flux_through_top_and_bottom_of_atmosphere_column - net_water_vapor_fluxes_through_top_and_bottom_of_atmosphere_column -------------------------- +atmospheric_physics/schemes/check_energy/dycore_energy_consistency_adjust.meta + + - ratio_of_specific_heat_of_dry_air_used_in_physics_energy_formula_to_specific_heat_of_dry_air_used_in_dycore_energy_formula + - temperature_of_initial_state + - total_energy_formula_for_dycore + +-------------------------- + atmospheric_physics/schemes/check_energy/check_energy_scaling.meta - - ratio_of_specific_heat_for_air_used_in_physics_energy_formula_and_specific_heat_for_air_used_in_dycore_energy_formula - - specific_heat_for_air_used_in_dycore + - ratio_of_specific_heat_of_dry_air_used_in_physics_energy_formula_to_specific_heat_of_dry_air_used_in_dycore_energy_formula + - specific_heat_of_dry_air_used_in_dycore -------------------------- @@ -308,7 +317,7 @@ atmospheric_physics/schemes/check_energy/check_energy_fix.meta - air_pressure_at_interface - global_mean_heating_rate_correction_for_energy_conservation - - net_sensible_heat_flux_through_top_and_bottom_of_atmosphere_column_from_global_total_energy_correction + - net_sensible_heat_flux_through_top_and_bottom_of_atmosphere_column - reciprocal_of_gravitational_acceleration -------------------------- @@ -320,9 +329,9 @@ atmospheric_physics/schemes/check_energy/check_energy_gmean/check_energy_gmean.m - global_mean_heating_rate_correction_for_energy_conservation - global_mean_surface_air_pressure - global_mean_total_energy_correction_for_energy_conservation - - global_mean_vertically_integrated_total_energy_at_end_of_physics + - global_mean_vertically_integrated_total_energy_at_end_of_physics_timestep - global_mean_vertically_integrated_total_energy_of_initial_state_using_dycore_energy_formula - - vertically_integrated_total_energy_at_end_of_physics + - vertically_integrated_total_energy_at_end_of_physics_timestep - vertically_integrated_total_energy_of_initial_state_using_dycore_energy_formula -------------------------- diff --git a/schemes/check_energy/check_energy_chng.F90 b/schemes/check_energy/check_energy_chng.F90 index 0b5a5608..3e2477e4 100644 --- a/schemes/check_energy/check_energy_chng.F90 +++ b/schemes/check_energy/check_energy_chng.F90 @@ -243,7 +243,7 @@ subroutine check_energy_chng_run( & real(kind_phys), intent(inout) :: te_cur_phys(:) ! physics formula: current total energy [J m-2] real(kind_phys), intent(inout) :: te_cur_dyn (:) ! dycore formula: current total energy [J m-2] real(kind_phys), intent(inout) :: tw_cur (:) ! current total water [kg m-2] - integer, intent(inout) :: count ! count of values with significant energy or water imbalances [1] + integer, intent(inout) :: count ! count of columns with significant energy or water imbalances [1] real(kind_phys), intent(inout) :: tend_te_tnd(:) ! total energy tendency [J m-2 s-1] real(kind_phys), intent(inout) :: tend_tw_tnd(:) ! total water tendency [kg m-2 s-1] diff --git a/schemes/check_energy/check_energy_chng.meta b/schemes/check_energy/check_energy_chng.meta index a37ca5b8..6e4f9826 100644 --- a/schemes/check_energy/check_energy_chng.meta +++ b/schemes/check_energy/check_energy_chng.meta @@ -96,7 +96,7 @@ dimensions = (horizontal_dimension, vertical_layer_dimension) intent = in [ cp_or_cv_dycore ] - standard_name = specific_heat_for_air_used_in_dycore + standard_name = specific_heat_of_dry_air_used_in_dycore units = J kg-1 K-1 type = real | kind = kind_phys dimensions = (horizontal_dimension, vertical_layer_dimension) @@ -162,13 +162,13 @@ dimensions = (horizontal_dimension, vertical_layer_dimension) intent = out [ count ] - standard_name = number_of_values_with_significant_energy_or_water_imbalances + standard_name = number_of_atmosphere_columns_with_significant_energy_or_water_imbalances units = count type = integer dimensions = () intent = out [ teout ] - standard_name = vertically_integrated_total_energy_at_end_of_physics + standard_name = vertically_integrated_total_energy_at_end_of_physics_timestep units = J m-2 type = real | kind = kind_phys dimensions = (horizontal_dimension) @@ -280,13 +280,13 @@ dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = in [ cp_or_cv_dycore ] - standard_name = specific_heat_for_air_used_in_dycore + standard_name = specific_heat_of_dry_air_used_in_dycore units = J kg-1 K-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = in [ scaling_dycore ] - standard_name = ratio_of_specific_heat_for_air_used_in_physics_energy_formula_and_specific_heat_for_air_used_in_dycore_energy_formula + standard_name = ratio_of_specific_heat_of_dry_air_used_in_physics_energy_formula_to_specific_heat_of_dry_air_used_in_dycore_energy_formula units = 1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) @@ -334,7 +334,7 @@ dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = in [ count ] - standard_name = number_of_values_with_significant_energy_or_water_imbalances + standard_name = number_of_atmosphere_columns_with_significant_energy_or_water_imbalances units = count type = integer dimensions = () @@ -382,13 +382,13 @@ dimensions = (horizontal_loop_extent) intent = in [ flx_cnd ] - standard_name = net_liquid_and_ice_fluxes_through_top_and_bottom_of_atmosphere_column + standard_name = net_liquid_and_lwe_ice_fluxes_through_top_and_bottom_of_atmosphere_column units = m s-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) intent = in [ flx_ice ] - standard_name = net_ice_fluxes_through_top_and_bottom_of_atmosphere_column + standard_name = net_lwe_ice_fluxes_through_top_and_bottom_of_atmosphere_column units = m s-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) diff --git a/schemes/check_energy/check_energy_gmean/check_energy_gmean.meta b/schemes/check_energy/check_energy_gmean/check_energy_gmean.meta index 14d8409d..36c0d77d 100644 --- a/schemes/check_energy/check_energy_gmean/check_energy_gmean.meta +++ b/schemes/check_energy/check_energy_gmean/check_energy_gmean.meta @@ -43,7 +43,7 @@ dimensions = (horizontal_loop_extent) intent = in [ teout ] - standard_name = vertically_integrated_total_energy_at_end_of_physics + standard_name = vertically_integrated_total_energy_at_end_of_physics_timestep units = J m-2 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) @@ -67,7 +67,7 @@ dimensions = () intent = out [ teout_glob ] - standard_name = global_mean_vertically_integrated_total_energy_at_end_of_physics + standard_name = global_mean_vertically_integrated_total_energy_at_end_of_physics_timestep units = J m-2 type = real | kind = kind_phys dimensions = () diff --git a/schemes/check_energy/check_energy_save_teout.meta b/schemes/check_energy/check_energy_save_teout.meta index 7972ef4d..86fcd818 100644 --- a/schemes/check_energy/check_energy_save_teout.meta +++ b/schemes/check_energy/check_energy_save_teout.meta @@ -18,7 +18,7 @@ dimensions = (horizontal_loop_extent) intent = in [ teout ] - standard_name = vertically_integrated_total_energy_at_end_of_physics + standard_name = vertically_integrated_total_energy_at_end_of_physics_timestep units = J m-2 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) diff --git a/schemes/check_energy/check_energy_scaling.meta b/schemes/check_energy/check_energy_scaling.meta index da74ea23..abd51c7d 100644 --- a/schemes/check_energy/check_energy_scaling.meta +++ b/schemes/check_energy/check_energy_scaling.meta @@ -12,7 +12,7 @@ dimensions = () intent = in [ cp_or_cv_dycore ] - standard_name = specific_heat_for_air_used_in_dycore + standard_name = specific_heat_of_dry_air_used_in_dycore units = J kg-1 K-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) @@ -24,7 +24,7 @@ dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = in [ scaling_dycore ] - standard_name = ratio_of_specific_heat_for_air_used_in_physics_energy_formula_and_specific_heat_for_air_used_in_dycore_energy_formula + standard_name = ratio_of_specific_heat_of_dry_air_used_in_physics_energy_formula_to_specific_heat_of_dry_air_used_in_dycore_energy_formula units = 1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) diff --git a/schemes/check_energy/check_energy_zero_fluxes.meta b/schemes/check_energy/check_energy_zero_fluxes.meta index 6b850672..65782599 100644 --- a/schemes/check_energy/check_energy_zero_fluxes.meta +++ b/schemes/check_energy/check_energy_zero_fluxes.meta @@ -24,13 +24,13 @@ dimensions = (horizontal_loop_extent) intent = out [ flx_cnd ] - standard_name = net_liquid_and_ice_fluxes_through_top_and_bottom_of_atmosphere_column + standard_name = net_liquid_and_lwe_ice_fluxes_through_top_and_bottom_of_atmosphere_column units = m s-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) intent = out [ flx_ice ] - standard_name = net_ice_fluxes_through_top_and_bottom_of_atmosphere_column + standard_name = net_lwe_ice_fluxes_through_top_and_bottom_of_atmosphere_column units = m s-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) diff --git a/schemes/check_energy/dycore_energy_consistency_adjust.meta b/schemes/check_energy/dycore_energy_consistency_adjust.meta index 60708262..4277f765 100644 --- a/schemes/check_energy/dycore_energy_consistency_adjust.meta +++ b/schemes/check_energy/dycore_energy_consistency_adjust.meta @@ -24,7 +24,7 @@ dimensions = () intent = in [ scaling_dycore ] - standard_name = ratio_of_specific_heat_for_air_used_in_physics_energy_formula_and_specific_heat_for_air_used_in_dycore_energy_formula + standard_name = ratio_of_specific_heat_of_dry_air_used_in_physics_energy_formula_to_specific_heat_of_dry_air_used_in_dycore_energy_formula units = 1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) diff --git a/schemes/sima_diagnostics/check_energy_diagnostics.F90 b/schemes/sima_diagnostics/check_energy_diagnostics.F90 index dac21bf1..b7c51f92 100644 --- a/schemes/sima_diagnostics/check_energy_diagnostics.F90 +++ b/schemes/sima_diagnostics/check_energy_diagnostics.F90 @@ -27,8 +27,8 @@ subroutine check_energy_diagnostics_init(errmsg, errflg) errflg = 0 ! History add field calls - call history_add_field('cp_or_cv_dycore', 'specific_heat_for_air_used_in_dycore', 'lev', 'inst', 'J kg-1 K-1') - call history_add_field('scaling_dycore', 'ratio_of_specific_heat_for_air_used_in_physics_energy_formula_and_specific_heat_for_air_used_in_dycore_energy_formula', 'lev', 'inst', '1') + call history_add_field('cp_or_cv_dycore', 'specific_heat_of_dry_air_used_in_dycore', 'lev', 'inst', 'J kg-1 K-1') + call history_add_field('scaling_dycore', 'ratio_of_specific_heat_of_dry_air_used_in_physics_energy_formula_to_specific_heat_of_dry_air_used_in_dycore_energy_formula', 'lev', 'inst', '1') call history_add_field('te_cur_phys', 'vertically_integrated_total_energy_of_current_state_using_physics_energy_formula', horiz_only, 'inst', 'J m-2') call history_add_field('te_cur_dyn', 'vertically_integrated_total_energy_of_current_state_using_dycore_energy_formula', horiz_only, 'inst', 'J m-2') @@ -37,7 +37,7 @@ subroutine check_energy_diagnostics_init(errmsg, errflg) 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', 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') end subroutine check_energy_diagnostics_init diff --git a/schemes/sima_diagnostics/check_energy_diagnostics.meta b/schemes/sima_diagnostics/check_energy_diagnostics.meta index bce2cd47..d0e1bdb4 100644 --- a/schemes/sima_diagnostics/check_energy_diagnostics.meta +++ b/schemes/sima_diagnostics/check_energy_diagnostics.meta @@ -22,13 +22,13 @@ name = check_energy_diagnostics_run type = scheme [ cp_or_cv_dycore ] - standard_name = specific_heat_for_air_used_in_dycore + standard_name = specific_heat_of_dry_air_used_in_dycore units = J kg-1 K-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = in [ scaling_dycore ] - standard_name = ratio_of_specific_heat_for_air_used_in_physics_energy_formula_and_specific_heat_for_air_used_in_dycore_energy_formula + standard_name = ratio_of_specific_heat_of_dry_air_used_in_physics_energy_formula_to_specific_heat_of_dry_air_used_in_dycore_energy_formula units = 1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) @@ -64,7 +64,7 @@ dimensions = (horizontal_loop_extent) intent = in [ teout ] - standard_name = vertically_integrated_total_energy_at_end_of_physics + standard_name = vertically_integrated_total_energy_at_end_of_physics_timestep units = J m-2 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) diff --git a/schemes/sima_diagnostics/check_energy_gmean_diagnostics.meta b/schemes/sima_diagnostics/check_energy_gmean_diagnostics.meta index 583356c2..4341a801 100644 --- a/schemes/sima_diagnostics/check_energy_gmean_diagnostics.meta +++ b/schemes/sima_diagnostics/check_energy_gmean_diagnostics.meta @@ -30,7 +30,7 @@ dimensions = () intent = in [ teout_glob ] - standard_name = global_mean_vertically_integrated_total_energy_at_end_of_physics + standard_name = global_mean_vertically_integrated_total_energy_at_end_of_physics_timestep units = J m-2 type = real | kind = kind_phys dimensions = () From 1003f81c12f722ba3c68bcc89f9dbf9bf0beca4c Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Wed, 13 Nov 2024 13:27:02 -0500 Subject: [PATCH 33/41] Fix build error --- schemes/check_energy/check_energy_chng.F90 | 1 + 1 file changed, 1 insertion(+) diff --git a/schemes/check_energy/check_energy_chng.F90 b/schemes/check_energy/check_energy_chng.F90 index 3e2477e4..7fa4a28f 100644 --- a/schemes/check_energy/check_energy_chng.F90 +++ b/schemes/check_energy/check_energy_chng.F90 @@ -204,6 +204,7 @@ subroutine check_energy_chng_run( & integer, intent(in) :: ncol ! number of atmospheric columns integer, intent(in) :: pver ! number of vertical layers integer, intent(in) :: pcnst ! number of ccpp constituents + integer, intent(in) :: iulog ! log output unit real(kind_phys), intent(in) :: q(:,:,:) ! constituent mass mixing ratios [kg kg-1] real(kind_phys), intent(in) :: pdel(:,:) ! layer thickness [Pa] real(kind_phys), intent(in) :: u(:,:) ! zonal wind [m s-1] From a53ff9bd853c7519488219972e14ac4ee469297a Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Wed, 13 Nov 2024 21:28:57 -0500 Subject: [PATCH 34/41] Update standard names from review comments --- doc/NamesNotInDictionary.txt | 50 +++++++++---------- schemes/check_energy/check_energy_chng.F90 | 2 +- schemes/check_energy/check_energy_chng.meta | 32 ++++++------ .../check_energy_gmean.meta | 4 +- .../check_energy/check_energy_save_teout.meta | 2 +- .../check_energy/check_energy_scaling.meta | 4 +- .../dycore_energy_consistency_adjust.F90 | 10 ++-- .../dycore_energy_consistency_adjust.meta | 12 ++--- .../check_energy_diagnostics.F90 | 10 ++-- .../check_energy_diagnostics.meta | 10 ++-- .../check_energy_gmean_diagnostics.meta | 2 +- 11 files changed, 67 insertions(+), 71 deletions(-) diff --git a/doc/NamesNotInDictionary.txt b/doc/NamesNotInDictionary.txt index 49fb304b..9d1de30e 100644 --- a/doc/NamesNotInDictionary.txt +++ b/doc/NamesNotInDictionary.txt @@ -1,7 +1,7 @@ ####################### Date/time of when script was run: -2024-11-13 12:40:59.115207 +2024-11-13 21:26:20.526396 ####################### Non-dictionary standard names found in the following metadata files: @@ -15,7 +15,7 @@ atmospheric_physics/schemes/sima_diagnostics/check_energy_gmean_diagnostics.meta - global_mean_heating_rate_correction_for_energy_conservation - global_mean_surface_air_pressure - global_mean_vertically_integrated_total_energy_at_end_of_physics_timestep - - global_mean_vertically_integrated_total_energy_of_initial_state_using_dycore_energy_formula + - global_mean_vertically_integrated_total_energy_using_dycore_energy_formula_at_start_of_physics_timestep -------------------------- @@ -23,12 +23,12 @@ atmospheric_physics/schemes/sima_diagnostics/check_energy_diagnostics.meta - cumulative_total_energy_boundary_flux_using_physics_energy_formula - cumulative_total_water_boundary_flux - - ratio_of_specific_heat_of_dry_air_used_in_physics_energy_formula_to_specific_heat_of_dry_air_used_in_dycore_energy_formula - - specific_heat_of_dry_air_used_in_dycore + - ratio_of_specific_heat_of_air_used_in_physics_energy_formula_to_specific_heat_of_air_used_in_dycore_energy_formula + - specific_heat_of_air_used_in_dycore - vertically_integrated_total_energy_at_end_of_physics_timestep - - vertically_integrated_total_energy_of_current_state_using_dycore_energy_formula - - vertically_integrated_total_energy_of_current_state_using_physics_energy_formula - - vertically_integrated_water_vapor_and_condensed_water_of_current_state + - vertically_integrated_total_energy_using_dycore_energy_formula + - vertically_integrated_total_energy_using_physics_energy_formula + - vertically_integrated_total_water -------------------------- @@ -257,35 +257,35 @@ atmospheric_physics/schemes/utilities/geopotential_temp.meta atmospheric_physics/schemes/check_energy/check_energy_save_teout.meta - vertically_integrated_total_energy_at_end_of_physics_timestep - - vertically_integrated_total_energy_of_current_state_using_dycore_energy_formula + - vertically_integrated_total_energy_using_dycore_energy_formula -------------------------- atmospheric_physics/schemes/check_energy/check_energy_chng.meta - air_pressure_of_dry_air_at_interface + - air_temperature_at_start_of_physics_timestep - cumulative_total_energy_boundary_flux_using_physics_energy_formula - cumulative_total_water_boundary_flux - flag_for_energy_conservation_warning - - height_wrt_surface_of_initial_state + - geopotential_height_wrt_surface_at_start_of_physics_timestep - latent_heat_of_fusion_of_water_at_0c - net_liquid_and_lwe_ice_fluxes_through_top_and_bottom_of_atmosphere_column - net_lwe_ice_fluxes_through_top_and_bottom_of_atmosphere_column - net_sensible_heat_flux_through_top_and_bottom_of_atmosphere_column - net_water_vapor_fluxes_through_top_and_bottom_of_atmosphere_column - number_of_atmosphere_columns_with_significant_energy_or_water_imbalances - - ratio_of_specific_heat_of_dry_air_used_in_physics_energy_formula_to_specific_heat_of_dry_air_used_in_dycore_energy_formula - - specific_heat_of_dry_air_used_in_dycore - - temperature_of_initial_state + - ratio_of_specific_heat_of_air_used_in_physics_energy_formula_to_specific_heat_of_air_used_in_dycore_energy_formula + - specific_heat_of_air_used_in_dycore - total_energy_formula_for_dycore - total_energy_formula_for_physics - vertically_integrated_total_energy_at_end_of_physics_timestep - - vertically_integrated_total_energy_of_current_state_using_dycore_energy_formula - - vertically_integrated_total_energy_of_current_state_using_physics_energy_formula - - vertically_integrated_total_energy_of_initial_state_using_dycore_energy_formula - - vertically_integrated_total_energy_of_initial_state_using_physics_energy_formula - - vertically_integrated_water_vapor_and_condensed_water_of_current_state - - vertically_integrated_water_vapor_and_condensed_water_of_initial_state + - vertically_integrated_total_energy_using_dycore_energy_formula + - vertically_integrated_total_energy_using_dycore_energy_formula_at_start_of_physics_timestep + - vertically_integrated_total_energy_using_physics_energy_formula + - vertically_integrated_total_energy_using_physics_energy_formula_at_start_of_physics_timestep + - vertically_integrated_total_water + - vertically_integrated_total_water_at_start_of_physics_timestep -------------------------- @@ -300,16 +300,16 @@ atmospheric_physics/schemes/check_energy/check_energy_zero_fluxes.meta atmospheric_physics/schemes/check_energy/dycore_energy_consistency_adjust.meta - - ratio_of_specific_heat_of_dry_air_used_in_physics_energy_formula_to_specific_heat_of_dry_air_used_in_dycore_energy_formula - - temperature_of_initial_state - - total_energy_formula_for_dycore + - air_temperature_at_start_of_physics_timestep + - flag_for_dycore_energy_consistency_adjustment + - ratio_of_specific_heat_of_air_used_in_physics_energy_formula_to_specific_heat_of_air_used_in_dycore_energy_formula -------------------------- atmospheric_physics/schemes/check_energy/check_energy_scaling.meta - - ratio_of_specific_heat_of_dry_air_used_in_physics_energy_formula_to_specific_heat_of_dry_air_used_in_dycore_energy_formula - - specific_heat_of_dry_air_used_in_dycore + - ratio_of_specific_heat_of_air_used_in_physics_energy_formula_to_specific_heat_of_air_used_in_dycore_energy_formula + - specific_heat_of_air_used_in_dycore -------------------------- @@ -330,9 +330,9 @@ atmospheric_physics/schemes/check_energy/check_energy_gmean/check_energy_gmean.m - global_mean_surface_air_pressure - global_mean_total_energy_correction_for_energy_conservation - global_mean_vertically_integrated_total_energy_at_end_of_physics_timestep - - global_mean_vertically_integrated_total_energy_of_initial_state_using_dycore_energy_formula + - global_mean_vertically_integrated_total_energy_using_dycore_energy_formula_at_start_of_physics_timestep - vertically_integrated_total_energy_at_end_of_physics_timestep - - vertically_integrated_total_energy_of_initial_state_using_dycore_energy_formula + - vertically_integrated_total_energy_using_dycore_energy_formula_at_start_of_physics_timestep -------------------------- diff --git a/schemes/check_energy/check_energy_chng.F90 b/schemes/check_energy/check_energy_chng.F90 index 7fa4a28f..91af5151 100644 --- a/schemes/check_energy/check_energy_chng.F90 +++ b/schemes/check_energy/check_energy_chng.F90 @@ -237,7 +237,7 @@ subroutine check_energy_chng_run( & character(len=*), intent(in) :: name ! parameterization name for fluxes real(kind_phys), intent(in) :: flx_vap(:) ! boundary flux of vapor [kg m-2 s-1] real(kind_phys), intent(in) :: flx_cnd(:) ! boundary flux of liquid+ice (precip?) [m s-1] - real(kind_phys), intent(in) :: flx_ice(:) ! boundary flux of ice (snow?) [m s-1] + real(kind_phys), intent(in) :: flx_ice(:) ! boundary flux of ice [m s-1] real(kind_phys), intent(in) :: flx_sen(:) ! boundary flux of sensible heat [W m-2] ! Input/Output arguments diff --git a/schemes/check_energy/check_energy_chng.meta b/schemes/check_energy/check_energy_chng.meta index 6e4f9826..f69792df 100644 --- a/schemes/check_energy/check_energy_chng.meta +++ b/schemes/check_energy/check_energy_chng.meta @@ -96,43 +96,43 @@ dimensions = (horizontal_dimension, vertical_layer_dimension) intent = in [ cp_or_cv_dycore ] - standard_name = specific_heat_of_dry_air_used_in_dycore + standard_name = specific_heat_of_air_used_in_dycore units = J kg-1 K-1 type = real | kind = kind_phys dimensions = (horizontal_dimension, vertical_layer_dimension) intent = in [ te_ini_phys ] - standard_name = vertically_integrated_total_energy_of_initial_state_using_physics_energy_formula + standard_name = vertically_integrated_total_energy_using_physics_energy_formula_at_start_of_physics_timestep units = J m-2 type = real | kind = kind_phys dimensions = (horizontal_dimension) intent = inout [ te_ini_dyn ] - standard_name = vertically_integrated_total_energy_of_initial_state_using_dycore_energy_formula + 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 = inout [ tw_ini ] - standard_name = vertically_integrated_water_vapor_and_condensed_water_of_initial_state + standard_name = vertically_integrated_total_water_at_start_of_physics_timestep units = kg m-2 type = real | kind = kind_phys dimensions = (horizontal_dimension) intent = inout [ te_cur_phys ] - standard_name = vertically_integrated_total_energy_of_current_state_using_physics_energy_formula + standard_name = vertically_integrated_total_energy_using_physics_energy_formula units = J m-2 type = real | kind = kind_phys dimensions = (horizontal_dimension) intent = inout [ te_cur_dyn ] - standard_name = vertically_integrated_total_energy_of_current_state_using_dycore_energy_formula + standard_name = vertically_integrated_total_energy_using_dycore_energy_formula units = J m-2 type = real | kind = kind_phys dimensions = (horizontal_dimension) intent = inout [ tw_cur ] - standard_name = vertically_integrated_water_vapor_and_condensed_water_of_current_state + standard_name = vertically_integrated_total_water units = kg m-2 type = real | kind = kind_phys dimensions = (horizontal_dimension) @@ -150,13 +150,13 @@ dimensions = (horizontal_dimension) intent = out [ temp_ini ] - standard_name = temperature_of_initial_state + standard_name = air_temperature_at_start_of_physics_timestep units = K type = real | kind = kind_phys dimensions = (horizontal_dimension, vertical_layer_dimension) intent = out [ z_ini ] - standard_name = height_wrt_surface_of_initial_state + standard_name = geopotential_height_wrt_surface_at_start_of_physics_timestep units = m type = real | kind = kind_phys dimensions = (horizontal_dimension, vertical_layer_dimension) @@ -280,31 +280,31 @@ dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = in [ cp_or_cv_dycore ] - standard_name = specific_heat_of_dry_air_used_in_dycore + standard_name = specific_heat_of_air_used_in_dycore units = J kg-1 K-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = in [ scaling_dycore ] - standard_name = ratio_of_specific_heat_of_dry_air_used_in_physics_energy_formula_to_specific_heat_of_dry_air_used_in_dycore_energy_formula + standard_name = ratio_of_specific_heat_of_air_used_in_physics_energy_formula_to_specific_heat_of_air_used_in_dycore_energy_formula units = 1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = in [ te_cur_phys ] - standard_name = vertically_integrated_total_energy_of_current_state_using_physics_energy_formula + standard_name = vertically_integrated_total_energy_using_physics_energy_formula units = J m-2 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) intent = inout [ te_cur_dyn ] - standard_name = vertically_integrated_total_energy_of_current_state_using_dycore_energy_formula + standard_name = vertically_integrated_total_energy_using_dycore_energy_formula units = J m-2 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) intent = inout [ tw_cur ] - standard_name = vertically_integrated_water_vapor_and_condensed_water_of_current_state + standard_name = vertically_integrated_total_water units = kg m-2 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) @@ -322,13 +322,13 @@ dimensions = (horizontal_loop_extent) intent = inout [ temp_ini ] - standard_name = temperature_of_initial_state + standard_name = air_temperature_at_start_of_physics_timestep units = K type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = in [ z_ini ] - standard_name = height_wrt_surface_of_initial_state + standard_name = geopotential_height_wrt_surface_at_start_of_physics_timestep units = m type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) diff --git a/schemes/check_energy/check_energy_gmean/check_energy_gmean.meta b/schemes/check_energy/check_energy_gmean/check_energy_gmean.meta index 36c0d77d..8ebf6f83 100644 --- a/schemes/check_energy/check_energy_gmean/check_energy_gmean.meta +++ b/schemes/check_energy/check_energy_gmean/check_energy_gmean.meta @@ -37,7 +37,7 @@ dimensions = (horizontal_loop_extent, vertical_interface_dimension) intent = in [ te_ini_dyn ] - standard_name = vertically_integrated_total_energy_of_initial_state_using_dycore_energy_formula + 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_loop_extent) @@ -61,7 +61,7 @@ dimensions = () intent = out [ teinp_glob ] - standard_name = global_mean_vertically_integrated_total_energy_of_initial_state_using_dycore_energy_formula + standard_name = global_mean_vertically_integrated_total_energy_using_dycore_energy_formula_at_start_of_physics_timestep units = J m-2 type = real | kind = kind_phys dimensions = () diff --git a/schemes/check_energy/check_energy_save_teout.meta b/schemes/check_energy/check_energy_save_teout.meta index 86fcd818..57a712a0 100644 --- a/schemes/check_energy/check_energy_save_teout.meta +++ b/schemes/check_energy/check_energy_save_teout.meta @@ -12,7 +12,7 @@ dimensions = () intent = in [ te_cur_dyn ] - standard_name = vertically_integrated_total_energy_of_current_state_using_dycore_energy_formula + standard_name = vertically_integrated_total_energy_using_dycore_energy_formula units = J m-2 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) diff --git a/schemes/check_energy/check_energy_scaling.meta b/schemes/check_energy/check_energy_scaling.meta index abd51c7d..400e97e5 100644 --- a/schemes/check_energy/check_energy_scaling.meta +++ b/schemes/check_energy/check_energy_scaling.meta @@ -12,7 +12,7 @@ dimensions = () intent = in [ cp_or_cv_dycore ] - standard_name = specific_heat_of_dry_air_used_in_dycore + standard_name = specific_heat_of_air_used_in_dycore units = J kg-1 K-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) @@ -24,7 +24,7 @@ dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = in [ scaling_dycore ] - standard_name = ratio_of_specific_heat_of_dry_air_used_in_physics_energy_formula_to_specific_heat_of_dry_air_used_in_dycore_energy_formula + standard_name = ratio_of_specific_heat_of_air_used_in_physics_energy_formula_to_specific_heat_of_air_used_in_dycore_energy_formula units = 1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) diff --git a/schemes/check_energy/dycore_energy_consistency_adjust.F90 b/schemes/check_energy/dycore_energy_consistency_adjust.F90 index 06925060..13015f20 100644 --- a/schemes/check_energy/dycore_energy_consistency_adjust.F90 +++ b/schemes/check_energy/dycore_energy_consistency_adjust.F90 @@ -13,19 +13,16 @@ module dycore_energy_consistency_adjust !! \htmlinclude arg_table_dycore_energy_consistency_adjust_run.html subroutine dycore_energy_consistency_adjust_run( & ncol, pver, & - energy_formula_dycore, & + do_consistency_adjust, & scaling_dycore, & temp_ini, & t, & tend_dtdt) - ! Dependency for energy formula definitions in SIMA - use cam_thermo_formula, only: ENERGY_FORMULA_DYCORE_SE, ENERGY_FORMULA_DYCORE_MPAS - ! Input arguments integer, intent(in) :: ncol ! number of atmospheric columns integer, intent(in) :: pver ! number of vertical layers - integer, intent(in) :: energy_formula_dycore ! total energy formulation used by dycore + logical, intent(in) :: do_consistency_adjust ! do energy consistency adjustment? real(kind_phys), intent(in) :: scaling_dycore(:,:) ! scaling for conversion of temperature increment [1] real(kind_phys), intent(in) :: temp_ini(:,:) ! initial temperature [K] @@ -33,8 +30,7 @@ subroutine dycore_energy_consistency_adjust_run( & real(kind_phys), intent(inout) :: T(:,:) ! temperature [K] real(kind_phys), intent(inout) :: tend_dtdt(:,:) ! model phys temperature tendency [K s-1] - if(energy_formula_dycore == ENERGY_FORMULA_DYCORE_MPAS .or. & - energy_formula_dycore == ENERGY_FORMULA_DYCORE_SE) then + if(do_consistency_adjust) then T(:ncol,:) = temp_ini(:ncol,:) + & scaling_dycore(:ncol,:) * (T(:ncol,:) - temp_ini(:ncol,:)) diff --git a/schemes/check_energy/dycore_energy_consistency_adjust.meta b/schemes/check_energy/dycore_energy_consistency_adjust.meta index 4277f765..6a44354a 100644 --- a/schemes/check_energy/dycore_energy_consistency_adjust.meta +++ b/schemes/check_energy/dycore_energy_consistency_adjust.meta @@ -17,20 +17,20 @@ type = integer dimensions = () intent = in -[ energy_formula_dycore ] - standard_name = total_energy_formula_for_dycore - units = 1 - type = integer +[ do_consistency_adjust ] + standard_name = flag_for_dycore_energy_consistency_adjustment + units = flag + type = logical dimensions = () intent = in [ scaling_dycore ] - standard_name = ratio_of_specific_heat_of_dry_air_used_in_physics_energy_formula_to_specific_heat_of_dry_air_used_in_dycore_energy_formula + standard_name = ratio_of_specific_heat_of_air_used_in_physics_energy_formula_to_specific_heat_of_air_used_in_dycore_energy_formula units = 1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = in [ temp_ini ] - standard_name = temperature_of_initial_state + standard_name = air_temperature_at_start_of_physics_timestep units = K type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) diff --git a/schemes/sima_diagnostics/check_energy_diagnostics.F90 b/schemes/sima_diagnostics/check_energy_diagnostics.F90 index b7c51f92..be52eb8d 100644 --- a/schemes/sima_diagnostics/check_energy_diagnostics.F90 +++ b/schemes/sima_diagnostics/check_energy_diagnostics.F90 @@ -27,12 +27,12 @@ subroutine check_energy_diagnostics_init(errmsg, errflg) errflg = 0 ! History add field calls - call history_add_field('cp_or_cv_dycore', 'specific_heat_of_dry_air_used_in_dycore', 'lev', 'inst', 'J kg-1 K-1') - call history_add_field('scaling_dycore', 'ratio_of_specific_heat_of_dry_air_used_in_physics_energy_formula_to_specific_heat_of_dry_air_used_in_dycore_energy_formula', 'lev', 'inst', '1') + call history_add_field('cp_or_cv_dycore', 'specific_heat_of_air_used_in_dycore', 'lev', 'inst', 'J kg-1 K-1') + 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_of_current_state_using_physics_energy_formula', horiz_only, 'inst', 'J m-2') - call history_add_field('te_cur_dyn', 'vertically_integrated_total_energy_of_current_state_using_dycore_energy_formula', horiz_only, 'inst', 'J m-2') - call history_add_field('tw_cur', 'vertically_integrated_water_vapor_and_condensed_water_of_current_state', horiz_only, 'inst', 'kg m-2') + 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') diff --git a/schemes/sima_diagnostics/check_energy_diagnostics.meta b/schemes/sima_diagnostics/check_energy_diagnostics.meta index d0e1bdb4..cd5e1532 100644 --- a/schemes/sima_diagnostics/check_energy_diagnostics.meta +++ b/schemes/sima_diagnostics/check_energy_diagnostics.meta @@ -22,31 +22,31 @@ name = check_energy_diagnostics_run type = scheme [ cp_or_cv_dycore ] - standard_name = specific_heat_of_dry_air_used_in_dycore + standard_name = specific_heat_of_air_used_in_dycore units = J kg-1 K-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = in [ scaling_dycore ] - standard_name = ratio_of_specific_heat_of_dry_air_used_in_physics_energy_formula_to_specific_heat_of_dry_air_used_in_dycore_energy_formula + standard_name = ratio_of_specific_heat_of_air_used_in_physics_energy_formula_to_specific_heat_of_air_used_in_dycore_energy_formula units = 1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = in [ te_cur_phys ] - standard_name = vertically_integrated_total_energy_of_current_state_using_physics_energy_formula + standard_name = vertically_integrated_total_energy_using_physics_energy_formula units = J m-2 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) intent = in [ te_cur_dyn ] - standard_name = vertically_integrated_total_energy_of_current_state_using_dycore_energy_formula + 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_water_vapor_and_condensed_water_of_current_state + standard_name = vertically_integrated_total_water units = kg m-2 type = real | kind = kind_phys dimensions = (horizontal_loop_extent) diff --git a/schemes/sima_diagnostics/check_energy_gmean_diagnostics.meta b/schemes/sima_diagnostics/check_energy_gmean_diagnostics.meta index 4341a801..b58cf996 100644 --- a/schemes/sima_diagnostics/check_energy_gmean_diagnostics.meta +++ b/schemes/sima_diagnostics/check_energy_gmean_diagnostics.meta @@ -24,7 +24,7 @@ dimensions = () intent = in [ teinp_glob ] - standard_name = global_mean_vertically_integrated_total_energy_of_initial_state_using_dycore_energy_formula + standard_name = global_mean_vertically_integrated_total_energy_using_dycore_energy_formula_at_start_of_physics_timestep units = J m-2 type = real | kind = kind_phys dimensions = () From 5e52537390e9fc65b898e76d28ae8148f171dba3 Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Wed, 13 Nov 2024 21:43:10 -0500 Subject: [PATCH 35/41] Change rga to gravit --- schemes/check_energy/check_energy_fix.F90 | 6 +++--- schemes/check_energy/check_energy_fix.meta | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/schemes/check_energy/check_energy_fix.F90 b/schemes/check_energy/check_energy_fix.F90 index cbedccac..1bdc7ae8 100644 --- a/schemes/check_energy/check_energy_fix.F90 +++ b/schemes/check_energy/check_energy_fix.F90 @@ -11,12 +11,12 @@ 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, rga, heat_glob, ptend_s, eshflx, scheme_name) + subroutine check_energy_fix_run(ncol, pver, pint, gravit, heat_glob, ptend_s, eshflx, scheme_name) ! Input arguments integer, intent(in) :: ncol ! number of atmospheric columns integer, intent(in) :: pver ! number of vertical layers real(kind_phys), intent(in) :: pint(:,:) ! interface pressure [Pa] - real(kind_phys), intent(in) :: rga ! 1/gravit [m-1 s2] + real(kind_phys), intent(in) :: gravit ! gravitational acceleration [m s-2] real(kind_phys), intent(in) :: heat_glob ! global mean heating rate [J kg-1 s-1] real(kind_phys), intent(out) :: ptend_s(:,:) ! physics tendency heating rate [J kg-1 s-1] real(kind_phys), intent(out) :: eshflx(:) ! effective sensible heat flux [W m-2] @@ -35,7 +35,7 @@ subroutine check_energy_fix_run(ncol, pver, pint, rga, heat_glob, ptend_s, eshfl ! compute effective sensible heat flux do i = 1, ncol - eshflx(i) = heat_glob * (pint(i,pver+1) - pint(i,1)) * rga + eshflx(i) = heat_glob * (pint(i,pver+1) - pint(i,1)) / gravit end do end subroutine check_energy_fix_run diff --git a/schemes/check_energy/check_energy_fix.meta b/schemes/check_energy/check_energy_fix.meta index 055bf5d3..b5f935fb 100644 --- a/schemes/check_energy/check_energy_fix.meta +++ b/schemes/check_energy/check_energy_fix.meta @@ -23,9 +23,9 @@ type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_interface_dimension) intent = in -[ rga ] - standard_name = reciprocal_of_gravitational_acceleration - units = s2 m-1 +[ gravit ] + standard_name = standard_gravitational_acceleration + units = m s-2 type = real | kind = kind_phys dimensions = () intent = in From cef429feb6e15569270576edbcbf088111f4bb16 Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Wed, 13 Nov 2024 22:26:28 -0500 Subject: [PATCH 36/41] Add namelist option to control gmean diagnostic; reformat gmean diagnostic --- .../check_energy_gmean_diagnostics.F90 | 23 ++++++++++++++----- .../check_energy_gmean_diagnostics.meta | 16 ++++++++----- ...heck_energy_gmean_diagnostics_namelist.xml | 19 +++++++++++++++ 3 files changed, 46 insertions(+), 12 deletions(-) create mode 100644 schemes/sima_diagnostics/check_energy_gmean_diagnostics_namelist.xml diff --git a/schemes/sima_diagnostics/check_energy_gmean_diagnostics.F90 b/schemes/sima_diagnostics/check_energy_gmean_diagnostics.F90 index 9ee260ad..a2e51dc7 100644 --- a/schemes/sima_diagnostics/check_energy_gmean_diagnostics.F90 +++ b/schemes/sima_diagnostics/check_energy_gmean_diagnostics.F90 @@ -16,16 +16,28 @@ module check_energy_gmean_diagnostics private save + public :: check_energy_gmean_diagnostics_init public :: check_energy_gmean_diagnostics_run ! main routine -CONTAINS + ! Private module options. + logical :: print_global_means = .false. + +contains + +!> \section arg_table_check_energy_gmean_diagnostics_init Argument Table +!! \htmlinclude arg_table_check_energy_gmean_diagnostics_init.html + subroutine check_energy_gmean_diagnostics_init(print_global_means_in) + ! Input arguments + logical, intent(in) :: print_global_means_in + + print_global_means = print_global_means_in + end subroutine check_energy_gmean_diagnostics_init !> \section arg_table_check_energy_gmean_diagnostics_run Argument Table !! \htmlinclude check_energy_gmean_diagnostics_run.html subroutine check_energy_gmean_diagnostics_run( & amIRoot, & iulog, & - nstep, & teinp_glob, & teout_glob, & heat_glob, & @@ -35,7 +47,6 @@ subroutine check_energy_gmean_diagnostics_run( & logical, intent(in) :: amIRoot integer, intent(in) :: iulog ! log output unit - integer, intent(in) :: nstep ! current timestep number real(kind_phys), intent(in) :: teinp_glob ! global mean energy of input state [J m-2] real(kind_phys), intent(in) :: teout_glob ! global mean energy of output state [J m-2] @@ -49,9 +60,9 @@ subroutine check_energy_gmean_diagnostics_run( & errmsg = '' errflg = 0 - if (amIRoot) then - write(iulog,'(1x,a9,1x,i8,5(1x,e25.17))') "nstep, te", nstep, teinp_glob, teout_glob, & - heat_glob, psurf_glob, ptopb_glob + if (print_global_means .and. amIRoot) then + write(iulog,'(1x,a26,1x,e25.17,1x,a15,1x,e25.17)') 'global mean input energy =', teinp_glob, 'output energy =', teout_glob + write(iulog,'(1x,a38,1x,e25.17)') 'heating rate for energy conservation =', heat_glob endif end subroutine check_energy_gmean_diagnostics_run diff --git a/schemes/sima_diagnostics/check_energy_gmean_diagnostics.meta b/schemes/sima_diagnostics/check_energy_gmean_diagnostics.meta index b58cf996..5fedbcd8 100644 --- a/schemes/sima_diagnostics/check_energy_gmean_diagnostics.meta +++ b/schemes/sima_diagnostics/check_energy_gmean_diagnostics.meta @@ -2,6 +2,16 @@ name = check_energy_gmean_diagnostics type = scheme +[ccpp-arg-table] + name = check_energy_gmean_diagnostics_init + type = scheme +[ print_global_means_in ] + standard_name = flag_for_energy_global_means_output + units = flag + type = logical + dimensions = () + intent = in + [ccpp-arg-table] name = check_energy_gmean_diagnostics_run type = scheme @@ -17,12 +27,6 @@ type = integer dimensions = () intent = in -[ nstep ] - standard_name = current_timestep_number - units = count - type = integer - dimensions = () - intent = in [ teinp_glob ] standard_name = global_mean_vertically_integrated_total_energy_using_dycore_energy_formula_at_start_of_physics_timestep units = J m-2 diff --git a/schemes/sima_diagnostics/check_energy_gmean_diagnostics_namelist.xml b/schemes/sima_diagnostics/check_energy_gmean_diagnostics_namelist.xml new file mode 100644 index 00000000..cd5896f6 --- /dev/null +++ b/schemes/sima_diagnostics/check_energy_gmean_diagnostics_namelist.xml @@ -0,0 +1,19 @@ + + + + + + + logical + diagnostics + check_energy_gmean_nl + flag_for_energy_global_means_output + flag + + Turn on output of global means of total energy and heating rate for energy conservation. Default: TRUE + + + true + + + From 7b188e35fe26247289d3bdbbbdd902cde382765a Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Fri, 15 Nov 2024 12:46:25 -0500 Subject: [PATCH 37/41] Address review comments --- .../check_energy_gmean_diagnostics.F90 | 13 ++----------- .../check_energy_gmean_diagnostics.meta | 12 ------------ suites/suite_adiabatic.xml | 6 ++++-- suites/suite_cam7.xml | 4 ++-- suites/suite_held_suarez_1994.xml | 8 -------- suites/suite_kessler.xml | 3 +++ suites/suite_tj2016.xml | 12 ++++++++++++ 7 files changed, 23 insertions(+), 35 deletions(-) diff --git a/schemes/sima_diagnostics/check_energy_gmean_diagnostics.F90 b/schemes/sima_diagnostics/check_energy_gmean_diagnostics.F90 index a2e51dc7..cd582b2e 100644 --- a/schemes/sima_diagnostics/check_energy_gmean_diagnostics.F90 +++ b/schemes/sima_diagnostics/check_energy_gmean_diagnostics.F90 @@ -1,13 +1,8 @@ ! Diagnostic scheme for check_energy_gmean -! This replicates the "debug printout" with the global mean total energy in CAM: -! nstep, te 0 0.25872620595082335E+10 0.25872620595082335E+10 -0.00000000000000000E+00 0.10126767279027148E+06 0.21940670000000080E+03 -! where the numbers correspond to: -! - timestep number +! This creates a debug printout with: ! - global mean input energy using dycore energy formula ! - global mean output energy at end of physics timestep using dycore energy formula ! - global mean heating rate for energy conservation -! - global mean surface pressure -! - global mean model top pressure ! These numbers are very useful for matching models bit-for-bit because they include "everything" in the model. module check_energy_gmean_diagnostics use ccpp_kinds, only: kind_phys @@ -41,17 +36,13 @@ subroutine check_energy_gmean_diagnostics_run( & teinp_glob, & teout_glob, & heat_glob, & - psurf_glob, & - ptopb_glob, & errmsg, errflg) - logical, intent(in) :: amIRoot + logical, intent(in) :: amIRoot ! are we on the MPI root task? integer, intent(in) :: iulog ! log output unit real(kind_phys), intent(in) :: teinp_glob ! global mean energy of input state [J m-2] real(kind_phys), intent(in) :: teout_glob ! global mean energy of output state [J m-2] - real(kind_phys), intent(in) :: psurf_glob ! global mean surface pressure [Pa] - real(kind_phys), intent(in) :: ptopb_glob ! global mean top boundary pressure [Pa] real(kind_phys), intent(in) :: heat_glob ! global mean heating rate [J kg-1 s-1] character(len=512), intent(out) :: errmsg diff --git a/schemes/sima_diagnostics/check_energy_gmean_diagnostics.meta b/schemes/sima_diagnostics/check_energy_gmean_diagnostics.meta index 5fedbcd8..7eff0709 100644 --- a/schemes/sima_diagnostics/check_energy_gmean_diagnostics.meta +++ b/schemes/sima_diagnostics/check_energy_gmean_diagnostics.meta @@ -45,18 +45,6 @@ type = real | kind = kind_phys dimensions = () intent = in -[ psurf_glob ] - standard_name = global_mean_surface_air_pressure - units = Pa - type = real | kind = kind_phys - dimensions = () - intent = in -[ ptopb_glob ] - standard_name = global_mean_air_pressure_at_top_of_atmosphere_model - units = Pa - type = real | kind = kind_phys - dimensions = () - intent = in [ errmsg ] standard_name = ccpp_error_message units = none diff --git a/suites/suite_adiabatic.xml b/suites/suite_adiabatic.xml index 20fc4557..eda9d892 100644 --- a/suites/suite_adiabatic.xml +++ b/suites/suite_adiabatic.xml @@ -4,7 +4,7 @@ check_energy_gmean - + check_energy_gmean_diagnostics @@ -17,12 +17,14 @@ check_energy_scaling check_energy_chng - + check_energy_save_teout + sima_state_diagnostics + sima_tend_diagnostics diff --git a/suites/suite_cam7.xml b/suites/suite_cam7.xml index bce3c2df..092e1846 100644 --- a/suites/suite_cam7.xml +++ b/suites/suite_cam7.xml @@ -4,7 +4,7 @@ check_energy_gmean - + check_energy_gmean_diagnostics @@ -34,7 +34,7 @@ tropopause_find tropopause_diagnostics - + check_energy_save_teout - - - check_energy_scaling - dycore_energy_consistency_adjust - sima_tend_diagnostics diff --git a/suites/suite_kessler.xml b/suites/suite_kessler.xml index c6b38dd0..02d78c68 100644 --- a/suites/suite_kessler.xml +++ b/suites/suite_kessler.xml @@ -16,6 +16,8 @@ kessler_update qneg geopotential_temp + + sima_state_diagnostics kessler_diagnostics @@ -28,6 +30,7 @@ check_energy_scaling dycore_energy_consistency_adjust + sima_tend_diagnostics diff --git a/suites/suite_tj2016.xml b/suites/suite_tj2016.xml index 8aa50be6..f3ca019b 100644 --- a/suites/suite_tj2016.xml +++ b/suites/suite_tj2016.xml @@ -5,6 +5,8 @@ tj2016_precip apply_heating_rate qneg + + sima_state_diagnostics @@ -13,6 +15,16 @@ apply_tendency_of_eastward_wind apply_tendency_of_northward_wind qneg + + + + + check_energy_scaling + dycore_energy_consistency_adjust + + sima_tend_diagnostics From 419bc0ee46db57918e240db22b8ea70911132bf9 Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Fri, 15 Nov 2024 16:35:40 -0500 Subject: [PATCH 38/41] As suggested use tendencies for dycore_energy_consistency_adjust --- .../dycore_energy_consistency_adjust.F90 | 31 ++++++++++++------- .../dycore_energy_consistency_adjust.meta | 12 +++---- suites/suite_kessler.xml | 12 ++++++- suites/suite_tj2016.xml | 12 ++++++- 4 files changed, 47 insertions(+), 20 deletions(-) diff --git a/schemes/check_energy/dycore_energy_consistency_adjust.F90 b/schemes/check_energy/dycore_energy_consistency_adjust.F90 index 13015f20..96706ef3 100644 --- a/schemes/check_energy/dycore_energy_consistency_adjust.F90 +++ b/schemes/check_energy/dycore_energy_consistency_adjust.F90 @@ -15,26 +15,33 @@ subroutine dycore_energy_consistency_adjust_run( & ncol, pver, & do_consistency_adjust, & scaling_dycore, & - temp_ini, & - t, & - tend_dtdt) + tend_dTdt, & + T, & + tend_dTdt_local) ! Input arguments integer, intent(in) :: ncol ! number of atmospheric columns integer, intent(in) :: pver ! number of vertical layers logical, intent(in) :: do_consistency_adjust ! do energy consistency adjustment? real(kind_phys), intent(in) :: scaling_dycore(:,:) ! scaling for conversion of temperature increment [1] - real(kind_phys), intent(in) :: temp_ini(:,:) ! initial temperature [K] + real(kind_phys), intent(in) :: tend_dTdt(:,:) ! model physics temperature tendency [K s-1] ! Input/output arguments - real(kind_phys), intent(inout) :: T(:,:) ! temperature [K] - real(kind_phys), intent(inout) :: tend_dtdt(:,:) ! model phys temperature tendency [K s-1] - - if(do_consistency_adjust) then - T(:ncol,:) = temp_ini(:ncol,:) + & - scaling_dycore(:ncol,:) * (T(:ncol,:) - temp_ini(:ncol,:)) - - tend_dtdt(:ncol,:) = scaling_dycore(:ncol,:) * tend_dtdt(:ncol,:) + real(kind_phys), intent(inout) :: T(:,:) ! air temperature [K] + + ! Output arguments + real(kind_phys), intent(out) :: tend_dTdt_local(:,:) ! (scheme) temperature tendency [K s-1] + + if (do_consistency_adjust) then + ! original formula for scaling of temperature: + ! T(:ncol,:) = temp_ini(:ncol,:) + & + ! scaling_dycore(:ncol,:) * (T(:ncol,:) - temp_ini(:ncol,:)) + ! and temperature tendency due to model physics: + ! tend_dTdt(:ncol,:) = scaling_dycore(:ncol,:) * tend_dTdt(:ncol,:) + ! + ! the terms can be arranged for this scaling to be applied through scheme tendencies + ! at the cost of a round-off level difference + tend_dTdt_local(:ncol,:) = (scaling_dycore(:ncol,:) - 1._kind_phys) * tend_dTdt(:ncol,:) endif ! do nothing for dynamical cores with energy consistent with CAM physics diff --git a/schemes/check_energy/dycore_energy_consistency_adjust.meta b/schemes/check_energy/dycore_energy_consistency_adjust.meta index 6a44354a..067a8996 100644 --- a/schemes/check_energy/dycore_energy_consistency_adjust.meta +++ b/schemes/check_energy/dycore_energy_consistency_adjust.meta @@ -29,9 +29,9 @@ type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = in -[ temp_ini ] - standard_name = air_temperature_at_start_of_physics_timestep - units = K +[ tend_dTdt ] + standard_name = tendency_of_air_temperature_due_to_model_physics + units = K s-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = in @@ -41,9 +41,9 @@ type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = inout -[ tend_dtdt ] - standard_name = tendency_of_air_temperature_due_to_model_physics +[ tend_dTdt_local ] + standard_name = tendency_of_air_temperature units = K s-1 type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) - intent = inout + intent = out diff --git a/suites/suite_kessler.xml b/suites/suite_kessler.xml index 02d78c68..792c6ee3 100644 --- a/suites/suite_kessler.xml +++ b/suites/suite_kessler.xml @@ -17,6 +17,14 @@ qneg geopotential_temp + + check_energy_zero_fluxes + check_energy_scaling + check_energy_chng + sima_state_diagnostics kessler_diagnostics @@ -26,9 +34,11 @@ + Then, perform the temperature and temperature tendency scaling, + and apply tendencies resulting from such adjustment --> check_energy_scaling dycore_energy_consistency_adjust + apply_tendency_of_air_temperature sima_tend_diagnostics diff --git a/suites/suite_tj2016.xml b/suites/suite_tj2016.xml index f3ca019b..a99bca79 100644 --- a/suites/suite_tj2016.xml +++ b/suites/suite_tj2016.xml @@ -6,6 +6,14 @@ apply_heating_rate qneg + + check_energy_zero_fluxes + check_energy_scaling + check_energy_chng + sima_state_diagnostics @@ -20,9 +28,11 @@ + Then, perform the temperature and temperature tendency scaling, + and apply tendencies resulting from such adjustment --> check_energy_scaling dycore_energy_consistency_adjust + apply_tendency_of_air_temperature sima_tend_diagnostics From b1e2c2a9d188172f888b0b5c903c5a12a741f30e Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Fri, 15 Nov 2024 17:21:19 -0500 Subject: [PATCH 39/41] Remove unused arguments; update cam7 suite --- schemes/check_energy/dycore_energy_consistency_adjust.F90 | 4 ---- schemes/check_energy/dycore_energy_consistency_adjust.meta | 6 ------ suites/suite_cam7.xml | 1 + 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/schemes/check_energy/dycore_energy_consistency_adjust.F90 b/schemes/check_energy/dycore_energy_consistency_adjust.F90 index 96706ef3..14fce382 100644 --- a/schemes/check_energy/dycore_energy_consistency_adjust.F90 +++ b/schemes/check_energy/dycore_energy_consistency_adjust.F90 @@ -16,7 +16,6 @@ subroutine dycore_energy_consistency_adjust_run( & do_consistency_adjust, & scaling_dycore, & tend_dTdt, & - T, & tend_dTdt_local) ! Input arguments @@ -26,9 +25,6 @@ subroutine dycore_energy_consistency_adjust_run( & real(kind_phys), intent(in) :: scaling_dycore(:,:) ! scaling for conversion of temperature increment [1] real(kind_phys), intent(in) :: tend_dTdt(:,:) ! model physics temperature tendency [K s-1] - ! Input/output arguments - real(kind_phys), intent(inout) :: T(:,:) ! air temperature [K] - ! Output arguments real(kind_phys), intent(out) :: tend_dTdt_local(:,:) ! (scheme) temperature tendency [K s-1] diff --git a/schemes/check_energy/dycore_energy_consistency_adjust.meta b/schemes/check_energy/dycore_energy_consistency_adjust.meta index 067a8996..e1afb294 100644 --- a/schemes/check_energy/dycore_energy_consistency_adjust.meta +++ b/schemes/check_energy/dycore_energy_consistency_adjust.meta @@ -35,12 +35,6 @@ type = real | kind = kind_phys dimensions = (horizontal_loop_extent, vertical_layer_dimension) intent = in -[ T ] - standard_name = air_temperature - units = K - type = real | kind = kind_phys - dimensions = (horizontal_loop_extent, vertical_layer_dimension) - intent = inout [ tend_dTdt_local ] standard_name = tendency_of_air_temperature units = K s-1 diff --git a/suites/suite_cam7.xml b/suites/suite_cam7.xml index 092e1846..7351223d 100644 --- a/suites/suite_cam7.xml +++ b/suites/suite_cam7.xml @@ -42,6 +42,7 @@ Then, perform the temperature and temperature tendency scaling --> check_energy_scaling dycore_energy_consistency_adjust + apply_tendency_of_air_temperature sima_tend_diagnostics From 3ae094e1707988200eb91bb6dd857999bfd7e9a1 Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Mon, 18 Nov 2024 15:43:08 -0500 Subject: [PATCH 40/41] Update ChangeLog with tag atmos_phys0_07_000 --- doc/ChangeLog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/ChangeLog b/doc/ChangeLog index ea566733..b08a0987 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,8 +1,8 @@ =============================================================== -Tag name: +Tag name: atmos_phys0_07_000 Originator(s): jimmielin -Date: October 25, 2024 +Date: November 18, 2024 One-line Summary: Implement CCPPized check_energy_chng and check_energy_fix Github PR URL: From 7506b057384a4841df09a5a791ab3cc0f0a9a4d9 Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Mon, 18 Nov 2024 15:45:18 -0500 Subject: [PATCH 41/41] Update NamesNotInDictionary before merge --- doc/NamesNotInDictionary.txt | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/doc/NamesNotInDictionary.txt b/doc/NamesNotInDictionary.txt index 9d1de30e..57566b4d 100644 --- a/doc/NamesNotInDictionary.txt +++ b/doc/NamesNotInDictionary.txt @@ -1,7 +1,7 @@ ####################### Date/time of when script was run: -2024-11-13 21:26:20.526396 +2024-11-18 15:44:54.993446 ####################### Non-dictionary standard names found in the following metadata files: @@ -10,10 +10,8 @@ Non-dictionary standard names found in the following metadata files: atmospheric_physics/schemes/sima_diagnostics/check_energy_gmean_diagnostics.meta - - current_timestep_number - - global_mean_air_pressure_at_top_of_atmosphere_model + - flag_for_energy_global_means_output - global_mean_heating_rate_correction_for_energy_conservation - - global_mean_surface_air_pressure - global_mean_vertically_integrated_total_energy_at_end_of_physics_timestep - global_mean_vertically_integrated_total_energy_using_dycore_energy_formula_at_start_of_physics_timestep @@ -300,7 +298,6 @@ atmospheric_physics/schemes/check_energy/check_energy_zero_fluxes.meta atmospheric_physics/schemes/check_energy/dycore_energy_consistency_adjust.meta - - air_temperature_at_start_of_physics_timestep - flag_for_dycore_energy_consistency_adjustment - ratio_of_specific_heat_of_air_used_in_physics_energy_formula_to_specific_heat_of_air_used_in_dycore_energy_formula @@ -318,7 +315,6 @@ atmospheric_physics/schemes/check_energy/check_energy_fix.meta - air_pressure_at_interface - global_mean_heating_rate_correction_for_energy_conservation - net_sensible_heat_flux_through_top_and_bottom_of_atmosphere_column - - reciprocal_of_gravitational_acceleration -------------------------- @@ -373,4 +369,15 @@ atmospheric_physics/schemes/tropopause_find/tropopause_find.meta - vertical_layer_index_lower_bound_from_hybrid_stobie_linoz_with_climatological_backup_method_for_linearized_ozone_chemistry - vertical_layer_index_lower_bound_from_hybrid_stobie_linoz_with_climatological_backup_method_for_stratospheric_chemistry +-------------------------- + +atmospheric_physics/schemes/musica/musica_ccpp.meta + + - blackbody_temperature_at_surface + - dynamic_constituents_for_musica_ccpp + - micm_solver_type + - number_of_grid_cells + - photolysis_wavelength_grid_interfaces + - surface_albedo_due_to_UV_and_VIS_direct + #######################