Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accumulate data land-ice mass fluxes #5910

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions components/mpas-ocean/driver/ocn_comp_mct.F
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions components/mpas-ocean/src/Registry.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2285,11 +2285,11 @@
<!-- FIELDS FOR LAND ICE STORAGE -->
<var name="accumulatedLandIceMass" type="real" dimensions="nCells Time" units="kg m^-2"
description="Mass per unit area of land ice produced at land ice-ocean interface. Only computed in 'standalone' mode where land-ice fluxes are computed in MPAS-O."
packages="landIceFluxesPKG"
packages="landIceFluxesPKG;dataLandIceFluxesPKG"
/>
<var name="accumulatedLandIceHeat" type="real" dimensions="nCells Time" units="J m^-2"
description="Heat per unit area stored in land ice produced at land ice-ocean interface. Only computed in 'standalone' mode where land-ice fluxes are computed in MPAS-O."
packages="landIceFluxesPKG"
packages="landIceFluxesPKG;dataLandIceFluxesPKG"
/>
<var name="accumulatedLandIceFrazilMass" type="real" dimensions="nCells Time" units="kg m^-2"
description="Mass per unit area of frazil ice produced under land ice. Only computed when not coupled to a dynamic land-ice model."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ module ocn_forward_mode
use ocn_tracer_surface_restoring
use ocn_gm
use ocn_submesoscale_eddies
use ocn_stokes_drift
use ocn_stokes_drift
use ocn_manufactured_solution

use ocn_high_freq_thickness_hmix_del2
Expand Down Expand Up @@ -701,8 +701,10 @@ function ocn_forward_mode_run(domain) result(ierr)!{{{
call ocn_forcing_build_fraction_absorbed_array(meshPool, statePool, forcingPool, ierr, 1)
call mpas_timer_start("land_ice_build_arrays")
call ocn_surface_land_ice_fluxes_build_arrays(meshPool, &
forcingPool, scratchPool, statePool, dt, err)
forcingPool, scratchPool, statePool, err)
call mpas_timer_stop("land_ice_build_arrays")
call ocn_surface_land_ice_fluxes_accumulate_fluxes(meshPool, forcingPool, &
statePool, dt, err)

call ocn_frazil_forcing_build_arrays(domain, meshPool, forcingPool, statePool, err)
call ocn_tidal_forcing_build_array(domain, meshPool, forcingPool, statePool, err)
Expand Down
7 changes: 5 additions & 2 deletions components/mpas-ocean/src/shared/mpas_ocn_init_routines.F
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ subroutine ocn_init_routines_block(block, dt, err)!{{{
normalVelocity(maxLevelEdgeTop(iEdge)+1:maxLevelEdgeBot(iEdge), iEdge) = 0.0_RKIND

normalVelocity(maxLevelEdgeBot(iEdge)+1:nVertLevels,iEdge) = -1.0e34_RKIND

normalVelocity(1:minLevelEdgeTop(iEdge)-1,iEdge) = -1.0e34_RKIND
end do

Expand Down Expand Up @@ -265,7 +265,10 @@ subroutine ocn_init_routines_block(block, dt, err)!{{{
call ocn_forcing_build_fraction_absorbed_array(meshPool, statePool, forcingPool, err1, 1)
err = ior(err, err1)
call ocn_surface_land_ice_fluxes_build_arrays(meshPool, &
forcingPool, scratchPool, statePool, dt, err1)
forcingPool, scratchPool, statePool, err1)
err = ior(err, err1)
call ocn_surface_land_ice_fluxes_accumulate_fluxes(meshPool, forcingPool, &
statePool, dt, err1)
err = ior(err, err1)


Expand Down
106 changes: 90 additions & 16 deletions components/mpas-ocean/src/shared/mpas_ocn_surface_land_ice_fluxes.F
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ module ocn_surface_land_ice_fluxes
ocn_surface_land_ice_fluxes_vel, &
ocn_surface_land_ice_fluxes_thick, &
ocn_surface_land_ice_fluxes_build_arrays, &
ocn_surface_land_ice_fluxes_accumulate_fluxes, &
ocn_surface_land_ice_fluxes_init

!--------------------------------------------------------------------
Expand Down Expand Up @@ -422,7 +423,7 @@ end subroutine ocn_surface_land_ice_fluxes_active_tracers!}}}
!-----------------------------------------------------------------------

subroutine ocn_surface_land_ice_fluxes_build_arrays(meshPool, &
forcingPool, scratchPool, statePool, dt, err) !{{{
forcingPool, scratchPool, statePool, err) !{{{

!-----------------------------------------------------------------
!
Expand All @@ -432,7 +433,6 @@ subroutine ocn_surface_land_ice_fluxes_build_arrays(meshPool, &

type (mpas_pool_type), intent(in) :: &
meshPool !< Input: mesh information
real(kind=RKIND), intent(in) :: dt ! the time step over which to accumulate fluxes

!-----------------------------------------------------------------
!
Expand Down Expand Up @@ -467,10 +467,6 @@ subroutine ocn_surface_land_ice_fluxes_build_arrays(meshPool, &
landIceSurfaceTemperature, &
landIceFreshwaterFlux, &
landIceHeatFlux, heatFluxToLandIce
real (kind=RKIND), dimension(:), pointer :: accumulatedLandIceMassOld, &
accumulatedLandIceMassNew, &
accumulatedLandIceHeatOld, &
accumulatedLandIceHeatNew

integer, dimension(:), pointer :: landIceFloatingMask

Expand Down Expand Up @@ -518,10 +514,6 @@ subroutine ocn_surface_land_ice_fluxes_build_arrays(meshPool, &
indexISPtr)
indexIT = indexITPtr
indexIS = indexISPtr
call mpas_pool_get_array(statePool, 'accumulatedLandIceMass', accumulatedLandIceMassNew, 2)
call mpas_pool_get_array(statePool, 'accumulatedLandIceMass', accumulatedLandIceMassOld, 1)
call mpas_pool_get_array(statePool, 'accumulatedLandIceHeat', accumulatedLandIceHeatNew, 2)
call mpas_pool_get_array(statePool, 'accumulatedLandIceHeat', accumulatedLandIceHeatOld, 1)

if (useHollandJenkinsAdvDiff) then
call mpas_pool_get_array(forcingPool, 'landIceSurfaceTemperature', landIceSurfaceTemperature)
Expand Down Expand Up @@ -666,18 +658,100 @@ subroutine ocn_surface_land_ice_fluxes_build_arrays(meshPool, &
freezeIceHeatFlux)
end if

! accumulate land-ice mass and heat
do iCell = 1, nCells
accumulatedLandIceMassNew(iCell) = accumulatedLandIceMassOld(iCell) - dt*landIceFreshwaterFlux(iCell)
accumulatedLandIceHeatNew(iCell) = accumulatedLandIceHeatOld(iCell) + dt*heatFluxToLandIce(iCell)
end do

call mpas_timer_stop("land_ice_build_arrays")

!--------------------------------------------------------------------

end subroutine ocn_surface_land_ice_fluxes_build_arrays!}}}


!***********************************************************************
!
! routine ocn_surface_land_ice_fluxes_accumulate_fluxes
!
!> \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
Expand Down