From 1ad3858128753c5961c1aad199e9fe894d002cad Mon Sep 17 00:00:00 2001 From: Xylar Asay-Davis Date: Sat, 2 Sep 2023 13:02:12 +0200 Subject: [PATCH] Accumulate data land-ice mass fluxes Before this merge, we were only accumulating this flux in prognostic flux mode. With this merge, we accumulate the mass flux in data mode as well, as this term is needed in the total mass budget of the model. To facilitate this and reduce issues related to initialization vs. forward time stepping, this accumulation step has been broken into its own subroutine, ocn_surface_land_ice_fluxes_accumulate_fluxes. This subroutine is called when time-stepping the model but not at initialization (since we do not want to accumulate any fluxes at that time). --- components/mpas-ocean/driver/ocn_comp_mct.F | 6 +- components/mpas-ocean/src/Registry.xml | 4 +- .../src/mode_forward/mpas_ocn_forward_mode.F | 6 +- .../src/shared/mpas_ocn_init_routines.F | 7 +- .../shared/mpas_ocn_surface_land_ice_fluxes.F | 106 +++++++++++++++--- 5 files changed, 105 insertions(+), 24 deletions(-) diff --git a/components/mpas-ocean/driver/ocn_comp_mct.F b/components/mpas-ocean/driver/ocn_comp_mct.F index b262fa01fda9..232c7a41fbfa 100644 --- a/components/mpas-ocean/driver/ocn_comp_mct.F +++ b/components/mpas-ocean/driver/ocn_comp_mct.F @@ -675,7 +675,7 @@ end subroutine xml_stream_get_attributes call ocn_forcing_build_fraction_absorbed_array(meshPool, statePool, forcingPool, ierr, 1) call mpas_timer_start("land_ice_build_arrays", .false.) call ocn_surface_land_ice_fluxes_build_arrays(meshPool, forcingPool, scratchPool, & - statePool, dt=0.0_RKIND, err=ierr) + statePool, err=ierr) call mpas_timer_stop("land_ice_build_arrays") call ocn_frazil_forcing_build_arrays(domain, meshPool, forcingPool, statePool, ierr) @@ -962,8 +962,10 @@ subroutine ocn_run_mct( EClock, cdata_o, x2o_o, o2x_o)!{{{ call mpas_timer_start("land_ice_build_arrays", .false.) call ocn_surface_land_ice_fluxes_build_arrays(meshPool, & - forcingPool, scratchPool, statePool, dt, ierr) + forcingPool, scratchPool, statePool, ierr) call mpas_timer_stop("land_ice_build_arrays") + call ocn_surface_land_ice_fluxes_accumulate_fluxes(meshPool, forcingPool, & + statePool, dt, ierr) call ocn_frazil_forcing_build_arrays(domain, meshPool, forcingPool, statePool, ierr) diff --git a/components/mpas-ocean/src/Registry.xml b/components/mpas-ocean/src/Registry.xml index 2091c51429e2..0c454fbca420 100644 --- a/components/mpas-ocean/src/Registry.xml +++ b/components/mpas-ocean/src/Registry.xml @@ -2285,11 +2285,11 @@ \brief Accumulate total land-ice mass and heat fluxes +!> \author Xylar Asay-Davis +!> \date 09/02/2023 +!> \details +!> This routine accumulates land-ice mass and heat fluxes into variables +!> used to keep track of the total mass and energy budgets. +!----------------------------------------------------------------------- + + subroutine ocn_surface_land_ice_fluxes_accumulate_fluxes(meshPool, & + forcingPool, statePool, dt, err) !{{{ + + !----------------------------------------------------------------- + ! + ! input variables + ! + !----------------------------------------------------------------- + + type (mpas_pool_type), intent(in) :: & + meshPool !< Input: mesh information + real(kind=RKIND), intent(in) :: dt ! the time step over which to accumulate fluxes + + !----------------------------------------------------------------- + ! + ! input/output variables + ! + !----------------------------------------------------------------- + type (mpas_pool_type), intent(inout) :: & + forcingPool, & !< Input: Forcing information + statePool !< Input: state field information + + !----------------------------------------------------------------- + ! + ! output variables + ! + !----------------------------------------------------------------- + + integer, intent(out) :: err !< Output: Error flag + + !----------------------------------------------------------------- + ! + ! local variables + ! + !----------------------------------------------------------------- + + integer :: iCell, nCells + integer, dimension(:), pointer :: nCellsArray + + real (kind=RKIND), dimension(:), pointer :: landIceFreshwaterFlux, & + heatFluxToLandIce + real (kind=RKIND), dimension(:), pointer :: accumulatedLandIceMassOld, & + accumulatedLandIceMassNew, & + accumulatedLandIceHeatOld, & + accumulatedLandIceHeatNew + + err = 0 + + call mpas_pool_get_dimension(meshPool, 'nCellsArray', nCellsArray) + nCells = nCellsArray( size(nCellsArray) ) + + if (landIceStandaloneOn .or. landIceDataOn) then + call mpas_pool_get_array(statePool, 'accumulatedLandIceMass', accumulatedLandIceMassNew, 2) + call mpas_pool_get_array(statePool, 'accumulatedLandIceMass', accumulatedLandIceMassOld, 1) + call mpas_pool_get_array(forcingPool, 'landIceFreshwaterFlux', landIceFreshwaterFlux) + ! accumulate land-ice mass + do iCell = 1, nCells + accumulatedLandIceMassNew(iCell) = accumulatedLandIceMassOld(iCell) - dt*landIceFreshwaterFlux(iCell) + end do + end if + + if (landIceStandaloneOn) then + call mpas_pool_get_array(forcingPool, 'heatFluxToLandIce', heatFluxToLandIce) + call mpas_pool_get_array(statePool, 'accumulatedLandIceHeat', accumulatedLandIceHeatNew, 2) + call mpas_pool_get_array(statePool, 'accumulatedLandIceHeat', accumulatedLandIceHeatOld, 1) + ! accumulate land-ice heat + do iCell = 1, nCells + accumulatedLandIceHeatNew(iCell) = accumulatedLandIceHeatOld(iCell) + dt*heatFluxToLandIce(iCell) + end do + end if + + !-------------------------------------------------------------------- + + end subroutine ocn_surface_land_ice_fluxes_accumulate_fluxes!}}} + !*********************************************************************** ! ! routine ocn_surface_land_ice_fluxes_init