From 1ecca0804c9bf92c2c2efd3f7ef2b3ef91930918 Mon Sep 17 00:00:00 2001 From: Haipeng Lin Date: Thu, 5 Sep 2024 18:19:36 -0400 Subject: [PATCH] Remove second dimension of tw_ini tw_cur as it is not different between physics and dycore --- src/control/cam_snapshot_common.F90 | 26 +++++++------------------- src/physics/cam/check_energy.F90 | 24 +++++++++++------------- src/physics/cam/physics_types.F90 | 23 ++++++++++++----------- 3 files changed, 30 insertions(+), 43 deletions(-) diff --git a/src/control/cam_snapshot_common.F90 b/src/control/cam_snapshot_common.F90 index 42b4c678c7..70216f3f18 100644 --- a/src/control/cam_snapshot_common.F90 +++ b/src/control/cam_snapshot_common.F90 @@ -81,7 +81,7 @@ module cam_snapshot_common integer :: cam_snapshot_before_num, cam_snapshot_after_num ! Note the maximum number of variables for each type -type (snapshot_type) :: state_snapshot(31) +type (snapshot_type) :: state_snapshot(29) type (snapshot_type) :: cnst_snapshot(pcnst) type (snapshot_type) :: tend_snapshot(6) type (snapshot_type) :: cam_in_snapshot(30) @@ -272,10 +272,10 @@ subroutine cam_state_snapshot_init(cam_snapshot_before_num_in, cam_snapshot_afte 'state%te_cur_phys', 'state_te_cur_phys', 'unset', horiz_only) call snapshot_addfld( nstate_var, state_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, & - 'state%tw_ini_phys', 'state_tw_ini_phys', 'unset', horiz_only) + 'state%tw_ini', 'state_tw_ini', 'unset', horiz_only) call snapshot_addfld( nstate_var, state_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, & - 'state%tw_cur_phys', 'state_tw_cur_phys', 'unset', horiz_only) + 'state%tw_cur', 'state_tw_cur', 'unset', horiz_only) call snapshot_addfld( nstate_var, state_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, & 'state%te_ini_dyn', 'state_te_ini_dyn', 'unset', horiz_only) @@ -283,12 +283,6 @@ subroutine cam_state_snapshot_init(cam_snapshot_before_num_in, cam_snapshot_afte call snapshot_addfld( nstate_var, state_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, & 'state%te_cur_dyn', 'state_te_cur_dyn', 'unset', horiz_only) - call snapshot_addfld( nstate_var, state_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, & - 'state%tw_ini_dyn', 'state_tw_ini_dyn', 'unset', horiz_only) - - call snapshot_addfld( nstate_var, state_snapshot, cam_snapshot_before_num, cam_snapshot_after_num, & - 'state%tw_cur_dyn', 'state_tw_cur_dyn', 'unset', horiz_only) - end subroutine cam_state_snapshot_init subroutine cam_cnst_snapshot_init(cam_snapshot_before_num, cam_snapshot_after_num) @@ -837,11 +831,11 @@ subroutine state_snapshot_all_outfld(lchnk, file_num, state) case ('state%te_cur_phys') call outfld(state_snapshot(i)%standard_name, state%te_cur(:, phys_te_idx), pcols, lchnk) - case ('state%tw_ini_phys') - call outfld(state_snapshot(i)%standard_name, state%tw_ini(:, phys_te_idx), pcols, lchnk) + case ('state%tw_ini') + call outfld(state_snapshot(i)%standard_name, state%tw_ini, pcols, lchnk) - case ('state%tw_cur_phys') - call outfld(state_snapshot(i)%standard_name, state%tw_cur(:, phys_te_idx), pcols, lchnk) + case ('state%tw_cur') + call outfld(state_snapshot(i)%standard_name, state%tw_cur, pcols, lchnk) case ('state%te_ini_dyn') call outfld(state_snapshot(i)%standard_name, state%te_ini(:, dyn_te_idx), pcols, lchnk) @@ -849,12 +843,6 @@ subroutine state_snapshot_all_outfld(lchnk, file_num, state) case ('state%te_cur_dyn') call outfld(state_snapshot(i)%standard_name, state%te_cur(:, dyn_te_idx), pcols, lchnk) - case ('state%tw_ini_dyn') - call outfld(state_snapshot(i)%standard_name, state%tw_ini(:, dyn_te_idx), pcols, lchnk) - - case ('state%tw_cur_dyn') - call outfld(state_snapshot(i)%standard_name, state%tw_cur(:, dyn_te_idx), pcols, lchnk) - case default call endrun('ERROR in state_snapshot_all_outfld: no match found for '//trim(state_snapshot(i)%ddt_string)) diff --git a/src/physics/cam/check_energy.F90 b/src/physics/cam/check_energy.F90 index 290d0022de..9c569387e0 100644 --- a/src/physics/cam/check_energy.F90 +++ b/src/physics/cam/check_energy.F90 @@ -262,7 +262,7 @@ subroutine check_energy_timestep_init(state, tend, pbuf, col_type) 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 = state%te_ini(1:ncol,phys_te_idx), H2O = state%tw_ini(1:ncol,phys_te_idx)) + te = state%te_ini(1:ncol,phys_te_idx), H2O = state%tw_ini(1:ncol)) ! ! Dynamical core total energy ! @@ -283,7 +283,7 @@ subroutine check_energy_timestep_init(state, tend, pbuf, col_type) state%u(1:ncol,1:pver), state%v(1:ncol,1:pver), state%T(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_ini(1:ncol,dyn_te_idx), H2O = state%tw_ini(1:ncol,dyn_te_idx)) + te = state%te_ini(1:ncol,dyn_te_idx), H2O = state%tw_ini(1:ncol)) else if (vc_dycore == vc_dry_pressure) then ! ! SE specific hydrostatic energy (enthalpy) @@ -297,16 +297,15 @@ subroutine check_energy_timestep_init(state, tend, pbuf, col_type) 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_dry_pressure, ptop=state%pintdry(1:ncol,1), phis = state%phis(1:ncol), & - te = state%te_ini(1:ncol,dyn_te_idx), H2O = state%tw_ini(1:ncol,dyn_te_idx)) + te = state%te_ini(1:ncol,dyn_te_idx), H2O = state%tw_ini(1:ncol)) else ! ! dycore energy is the same as physics ! state%te_ini(1:ncol,dyn_te_idx) = state%te_ini(1:ncol,phys_te_idx) - state%tw_ini(1:ncol,dyn_te_idx) = state%tw_ini(1:ncol,phys_te_idx) end if state%te_cur(:ncol,:) = state%te_ini(:ncol,:) - state%tw_cur(:ncol,:) = state%tw_ini(:ncol,:) + state%tw_cur(:ncol) = state%tw_ini(:ncol) ! zero cummulative boundary fluxes tend%te_tnd(:ncol) = 0._r8 @@ -404,7 +403,7 @@ subroutine check_energy_chng(state, tend, name, nstep, ztodt, & 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) + tw_dif(i) = tw(i) - state%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) @@ -416,7 +415,7 @@ subroutine check_energy_chng(state, tend, name, nstep, ztodt, & ! 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 + tw_xpd(i) = state%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) @@ -424,8 +423,8 @@ subroutine check_energy_chng(state, tend, name, nstep, ztodt, & ! 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) + where (state%tw_cur(:ncol) > 0._r8) + tw_rer(:ncol) = (tw_xpd(:ncol) - tw(:ncol)) / state%tw_cur(:ncol) end where ! error checking @@ -457,7 +456,7 @@ subroutine check_energy_chng(state, tend, name, nstep, ztodt, & do i = 1, ncol state%te_cur(i,phys_te_idx) = te(i) - state%tw_cur(i,phys_te_idx) = tw(i) + state%tw_cur(i) = tw(i) end do ! @@ -480,7 +479,7 @@ subroutine check_energy_chng(state, tend, name, nstep, ztodt, & 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)) + te = state%te_cur(1:ncol,dyn_te_idx), H2O = state%tw_cur(1:ncol)) else if (vc_dycore == vc_dry_pressure) then ! ! SE specific hydrostatic energy @@ -500,10 +499,9 @@ subroutine check_energy_chng(state, tend, name, nstep, ztodt, & 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)) + te = state%te_cur(1:ncol,dyn_te_idx), H2O = state%tw_cur(1:ncol)) 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 diff --git a/src/physics/cam/physics_types.F90 b/src/physics/cam/physics_types.F90 index 03f8022fa8..3228c27105 100644 --- a/src/physics/cam/physics_types.F90 +++ b/src/physics/cam/physics_types.F90 @@ -101,7 +101,8 @@ module physics_types ! Second dimension is (phys_te_idx) CAM physics total energy and ! (dyn_te_idx) dycore total energy computed in physics te_ini, &! vertically integrated total (kinetic + static) energy of initial state - te_cur, &! vertically integrated total (kinetic + static) energy of current state + te_cur ! vertically integrated total (kinetic + static) energy of current state + real(r8), dimension(:), allocatable :: & tw_ini, &! vertically integrated total water of initial state tw_cur ! vertically integrated total water of new state real(r8), dimension(:,:),allocatable :: & @@ -537,9 +538,9 @@ subroutine physics_state_check(state, name) varname="state%te_ini", msg=msg) call shr_assert_in_domain(state%te_cur(:ncol,:), is_nan=.false., & varname="state%te_cur", msg=msg) - call shr_assert_in_domain(state%tw_ini(:ncol,:), is_nan=.false., & + call shr_assert_in_domain(state%tw_ini(:ncol), is_nan=.false., & varname="state%tw_ini", msg=msg) - call shr_assert_in_domain(state%tw_cur(:ncol,:), is_nan=.false., & + call shr_assert_in_domain(state%tw_cur(:ncol), is_nan=.false., & varname="state%tw_cur", msg=msg) call shr_assert_in_domain(state%temp_ini(:ncol,:), is_nan=.false., & varname="state%temp_ini", msg=msg) @@ -615,9 +616,9 @@ subroutine physics_state_check(state, name) varname="state%te_ini", msg=msg) call shr_assert_in_domain(state%te_cur(:ncol,:), lt=posinf_r8, gt=neginf_r8, & varname="state%te_cur", msg=msg) - call shr_assert_in_domain(state%tw_ini(:ncol,:), lt=posinf_r8, gt=neginf_r8, & + call shr_assert_in_domain(state%tw_ini(:ncol), lt=posinf_r8, gt=neginf_r8, & varname="state%tw_ini", msg=msg) - call shr_assert_in_domain(state%tw_cur(:ncol,:), lt=posinf_r8, gt=neginf_r8, & + call shr_assert_in_domain(state%tw_cur(:ncol), lt=posinf_r8, gt=neginf_r8, & varname="state%tw_cur", msg=msg) call shr_assert_in_domain(state%temp_ini(:ncol,:), lt=posinf_r8, gt=neginf_r8, & varname="state%temp_ini", msg=msg) @@ -1351,8 +1352,8 @@ subroutine physics_state_copy(state_in, state_out) end do state_out%te_ini(:ncol,:) = state_in%te_ini(:ncol,:) state_out%te_cur(:ncol,:) = state_in%te_cur(:ncol,:) - state_out%tw_ini(:ncol,:) = state_in%tw_ini(:ncol,:) - state_out%tw_cur(:ncol,:) = state_in%tw_cur(:ncol,:) + state_out%tw_ini(:ncol) = state_in%tw_ini(:ncol) + state_out%tw_cur(:ncol) = state_in%tw_cur(:ncol) do k = 1, pver do i = 1, ncol @@ -1667,10 +1668,10 @@ subroutine physics_state_alloc(state,lchnk,psetcols) allocate(state%te_cur(psetcols,2), stat=ierr) if ( ierr /= 0 ) call endrun('physics_state_alloc error: allocation error for state%te_cur') - allocate(state%tw_ini(psetcols,2), stat=ierr) + allocate(state%tw_ini(psetcols), stat=ierr) if ( ierr /= 0 ) call endrun('physics_state_alloc error: allocation error for state%tw_ini') - allocate(state%tw_cur(psetcols,2), stat=ierr) + allocate(state%tw_cur(psetcols), stat=ierr) if ( ierr /= 0 ) call endrun('physics_state_alloc error: allocation error for state%tw_cur') allocate(state%temp_ini(psetcols,pver), stat=ierr) @@ -1720,8 +1721,8 @@ subroutine physics_state_alloc(state,lchnk,psetcols) state%te_ini(:,:) = inf state%te_cur(:,:) = inf - state%tw_ini(:,:) = inf - state%tw_cur(:,:) = inf + state%tw_ini(:) = inf + state%tw_cur(:) = inf state%temp_ini(:,:) = inf state%z_ini(:,:) = inf