From b7665f481bc6868d4a63c4ef3f76b2e90a42b39b Mon Sep 17 00:00:00 2001 From: Gustavo Marques Date: Fri, 25 Mar 2022 15:17:31 -0600 Subject: [PATCH] Heat conservation when enthalpy is via coupler * If fluxes%heat_content_evap is associated, which will only happens in CESM and when ENTHALPY_FROM_COUPLER=True, the heat contribution from mass entering/leaving the ocean is accounted for using the six enthalpy terms provided by the coupler: heat_content_evap, heat_content_lprec, heat_content_fprec, heat_content_cond, heat_content_lrunoff, and heat_content_frunoff. If fluxes%heat_content_evap is not associated, these terms are accounted for via tv%TempxPmE; * TODO: check that these changes do not change answers for GFDL. --- src/diagnostics/MOM_sum_output.F90 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/diagnostics/MOM_sum_output.F90 b/src/diagnostics/MOM_sum_output.F90 index 668c297658..578d1ca88c 100644 --- a/src/diagnostics/MOM_sum_output.F90 +++ b/src/diagnostics/MOM_sum_output.F90 @@ -1008,7 +1008,14 @@ subroutine accumulate_net_input(fluxes, sfc_state, tv, dt, G, US, CS) ! enddo ; enddo ; endif ! smg: old code - if (associated(tv%TempxPmE)) then + if (associated(fluxes%heat_content_evap)) then + do j=js,je ; do i=is,ie + heat_in(i,j) = heat_in(i,j) + dt * QRZL2_to_J * G%areaT(i,j) * & + (fluxes%heat_content_evap(i,j) + fluxes%heat_content_lprec(i,j) + & + fluxes%heat_content_cond(i,j) + fluxes%heat_content_fprec(i,j) + & + fluxes%heat_content_lrunoff(i,j) + fluxes%heat_content_frunoff(i,j)) + enddo ; enddo + elseif (associated(tv%TempxPmE)) then do j=js,je ; do i=is,ie heat_in(i,j) = heat_in(i,j) + (fluxes%C_p * QRZL2_to_J*G%areaT(i,j)) * tv%TempxPmE(i,j) enddo ; enddo