Skip to content

Commit

Permalink
Bringing on the heat
Browse files Browse the repository at this point in the history
  • Loading branch information
darincomeau committed Feb 9, 2024
1 parent d46f9b2 commit 4951935
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 48 deletions.
7 changes: 6 additions & 1 deletion components/mpas-ocean/driver/mpaso_cpl_indices.F
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ module mpaso_cpl_indices
integer :: index_o2x_Foxo_ismw
integer :: index_o2x_Foxo_rrofl
integer :: index_o2x_Foxo_rrofi
integer :: index_o2x_Foxo_ismh
integer :: index_o2x_Foxo_rrofih

! ocn -> drv for calculation of ocean-ice sheet interactions

Expand Down Expand Up @@ -189,11 +191,14 @@ subroutine mpaso_cpl_indices_set( )
index_o2x_Faoo_fco2_ocn = mct_avect_indexra(o2x,'Faoo_fco2_ocn',perrWith='quiet')
index_o2x_Faoo_fdms_ocn = mct_avect_indexra(o2x,'Faoo_fdms_ocn',perrWith='quiet')
index_o2x_So_ssh = mct_avect_indexra(o2x,'So_ssh')
!DC P needed since in ice-shelf ocean domain?

index_o2x_Foxo_ismw = mct_avect_indexra(o2x,'Foxo_ismw')
index_o2x_Foxo_rrofl = mct_avect_indexra(o2x,'Foxo_rrofl')
index_o2x_Foxo_rrofi = mct_avect_indexra(o2x,'Foxo_rrofi')

index_o2x_Foxo_ismh = mct_avect_indexra(o2x,'Foxo_ismh')
index_o2x_Foxo_rrofih = mct_avect_indexra(o2x,'Foxo_rrofih')

index_o2x_So_blt = mct_avect_indexra(o2x,'So_blt')
index_o2x_So_bls = mct_avect_indexra(o2x,'So_bls')
index_o2x_So_htv = mct_avect_indexra(o2x,'So_htv')
Expand Down
16 changes: 14 additions & 2 deletions components/mpas-ocean/driver/ocn_comp_mct.F
Original file line number Diff line number Diff line change
Expand Up @@ -2697,7 +2697,9 @@ subroutine ocn_export_mct(o2x_o, errorCode) !{{{
ssh, &
avgLandIceFreshwaterFlux, &
avgRemovedRiverRunoffFlux, &
avgRemovedIceRunoffFlux
avgRemovedIceRunoffFlux, &
avgLandIceHeatFlux, &
avgRemovedIceRunoffHeatFlux

real (kind=RKIND), dimension(:,:), pointer :: avgTracersSurfaceValue, avgSurfaceVelocity, &
avgSSHGradient, avgOceanSurfacePhytoC, &
Expand Down Expand Up @@ -2769,10 +2771,12 @@ subroutine ocn_export_mct(o2x_o, errorCode) !{{{
! Cryo fields
if (trim(config_land_ice_flux_mode) == 'standalone' .or. trim(config_land_ice_flux_mode) == 'data') then
call mpas_pool_get_array(forcingPool, 'avgLandIceFreshwaterFlux', avgLandIceFreshwaterFlux)
call mpas_pool_get_array(forcingPool, 'avgLandIceHeatFlux', avgLandIceHeatFlux)
endif
if (config_remove_AIS_coupler_runoff) then
call mpas_pool_get_array(forcingPool, 'avgRemovedRiverRunoffFlux', avgRemovedRiverRunoffFlux)
call mpas_pool_get_array(forcingPool, 'avgRemovedIceRunoffFlux', avgRemovedIceRunoffFlux)
call mpas_pool_get_array(forcingPool, 'avgRemovedIceRunoffHeatFlux', avgRemovedIceRunoffHeatFlux)
endif

! BGC fields
Expand Down Expand Up @@ -2829,10 +2833,12 @@ subroutine ocn_export_mct(o2x_o, errorCode) !{{{
! Cryo fields
if (trim(config_land_ice_flux_mode) == 'standalone' .or. trim(config_land_ice_flux_mode) == 'data') then
o2x_o % rAttr(index_o2x_Foxo_ismw, n) = avgLandIceFreshwaterFlux(i)
o2x_o % rAttr(index_o2x_Foxo_ismh, n) = avgLandIceHeatFlux(i)
endif
if (config_remove_AIS_coupler_runoff) then
o2x_o % rAttr(index_o2x_Foxo_rrofl, n) = avgRemovedRiverRunoffFlux(i)
o2x_o % rAttr(index_o2x_Foxo_rrofi, n) = avgRemovedIceRunoffFlux(i)
o2x_o % rAttr(index_o2x_Foxo_rrofih, n) = avgRemovedIceRunoffHeatFlux(i)
endif

if ( frazilIceActive ) then
Expand Down Expand Up @@ -4002,7 +4008,9 @@ subroutine ocn_export_moab(EClock) !{{{
ssh, &
avgLandIceFreshwaterFlux, &
avgRemovedRiverRunoffFlux, &
avgRemovedIceRunoffFlux
avgRemovedIceRunoffFlux, &
avgLandIceHeatFlux, &
avgRemovedIceRunoffHeatFlux

real (kind=RKIND), dimension(:,:), pointer :: avgTracersSurfaceValue, avgSurfaceVelocity, &
avgSSHGradient, avgOceanSurfacePhytoC, &
Expand Down Expand Up @@ -4073,10 +4081,12 @@ subroutine ocn_export_moab(EClock) !{{{

if (trim(config_land_ice_flux_mode == 'standalone') .or. trim(config_land_ice_flux_mode) == 'data') then
call mpas_pool_get_array(forcingPool, 'avgLandIceFreshwaterFlux', avgLandIceFreshwaterFlux)
call mpas_pool_get_array(forcingPool, 'avgLandIceHeatFlux', avgLandIceHeatFlux)
endif
if (config_remove_AIS_coupler_runoff) then
call mpas_pool_get_array(forcingPool, 'avgRemovedRiverRunoffFlux', avgRemovedRiverRunoffFlux)
call mpas_pool_get_array(forcingPool, 'avgRemovedIceRunoffFlux', avgRemovedIceRunoffFlux)
call mpas_pool_get_array(forcingPool, 'avgRemovedIceRunoffHeatFlux', avgRemovedIceRunoffHeatFlux)
endif

! BGC fields
Expand Down Expand Up @@ -4133,10 +4143,12 @@ subroutine ocn_export_moab(EClock) !{{{
!DC, blindly following pattern
if (trim(config_land_ice_flux_mode == 'standalone') .or. trim(config_land_ice_flux_mode) == 'data') then
o2x_om(n, index_o2x_Foxo_ismw) = avgLandIceFreshwaterFlux(i)
o2x_om(n, index_o2x_Foxo_ismh) = avgLandIceHeatFlux(i)
endif
if (config_remove_AIS_coupler_runoff) then
o2x_om(n, index_o2x_Foxo_rrofl) = avgRemovedRiverRunoffFlux(i)
o2x_om(n, index_o2x_Foxo_rrofi) = avgRemovedIceRunoffFlux(i)
o2x_om(n, index_o2x_Foxo_rrofih) = avgRemovedIceRunoffHeatFlux(i)
endif

if ( frazilIceActive ) then
Expand Down
8 changes: 7 additions & 1 deletion components/mpas-ocean/src/Registry.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3691,13 +3691,19 @@
description="Sum of heat fluxes associated with water fluxes cell centers sent to coupler. Positive into the ocean."
/>
<var name="avgLandIceFreshwaterFlux" type="real" dimensions="nCells Time" units="kg m^-2 s^-1"
description="Time-averaged sum of freshwater fluxes associated with ice shelf basal melt fluxes cell centers sent to coupler. Positive into the ocean."
description="Time-averaged sum of freshwater fluxes associated with ice shelf basal melt fluxes cell centers sent to coupler. Positive into the ocean."
/>
<var name="avgLandIceHeatFlux" type="real" dimensions="nCells Time" units="J m^-2 s^-1"
description="Time-averaged sum of heat fluxes associated with ice shelf basal melt fluxes cell centers sent to coupler. Positive into the ocean."
/>
<var name="avgRemovedRiverRunoffFlux" type="real" dimensions="nCells Time" units="kg m^-2 s^-1"
description="Time-averaged sum of freshwater fluxes associated with removed liquid runoff fluxes cell centers sent to coupler. Positive into the ocean."
/>
<var name="avgRemovedIceRunoffFlux" type="real" dimensions="nCells Time" units="kg m^-2 s^-1"
description="Time-averaged sum of freshwater fluxes associated with removed ice runoff fluxes cell centers sent to coupler. Positive into the ocean."
/>
<var name="avgRemovedIceRunoffHeatFlux" type="real" dimensions="nCells Time" units="J m^-2 s^-1"
description="Time-averaged sum of heat fluxes associated with removed ice runoff fluxes cell centers sent to coupler. Positive into the ocean."
/>

<!-- Input fields from coupler or initial condition for forcing under land ice -->
Expand Down
21 changes: 19 additions & 2 deletions components/mpas-ocean/src/shared/mpas_ocn_time_average_coupled.F
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ subroutine ocn_time_average_coupled_init(forcingPool)!{{{

real (kind=RKIND), dimension(:), pointer :: avgEffectiveDensityInLandIce, avgTotalFreshWaterTemperatureFlux, &
avgLandIceFreshwaterFlux, &
avgRemovedRiverRunoffFlux, avgRemovedIceRunoffFlux
avgRemovedRiverRunoffFlux, avgRemovedIceRunoffFlux, &
avgLandIceHeatFlux, avgRemovedIceRunoffHeatFlux

integer :: iCell
integer, pointer :: nAccumulatedCoupled, nCells
Expand Down Expand Up @@ -121,11 +122,13 @@ subroutine ocn_time_average_coupled_init(forcingPool)!{{{
! Set up polar fields if necessary
if(trim(config_land_ice_flux_mode)=='standalone' .or. trim(config_land_ice_flux_mode) == 'data') then
call mpas_pool_get_array(forcingPool, 'avgLandIceFreshwaterFlux', avgLandIceFreshwaterFlux)
call mpas_pool_get_array(forcingPool, 'avgLandIceHeatFlux', avgLandIceHeatFlux)

!$omp parallel
!$omp do schedule(runtime)
do iCell = 1, nCells
avgLandIceFreshwaterFlux(iCell) = 0.0_RKIND
avgLandIceHeatFlux(iCell) = 0.0_RKIND
end do
!$omp end do
!$omp end parallel
Expand All @@ -134,12 +137,14 @@ subroutine ocn_time_average_coupled_init(forcingPool)!{{{
if(config_remove_AIS_coupler_runoff) then
call mpas_pool_get_array(forcingPool, 'avgRemovedRiverRunoffFlux', avgRemovedRiverRunoffFlux)
call mpas_pool_get_array(forcingPool, 'avgRemovedIceRunoffFlux', avgRemovedIceRunoffFlux)
call mpas_pool_get_array(forcingPool, 'avgRemovedIceRunoffHeatFlux', avgRemovedIceRunoffHeatFlux)

!$omp parallel
!$omp do schedule(runtime)
do iCell = 1, nCells
avgRemovedRiverRunoffFlux(iCell) = 0.0_RKIND
avgRemovedIceRunoffFlux(iCell) = 0.0_RKIND
avgRemovedIceRunoffHeatFlux(iCell) = 0.0_RKIND
end do
!$omp end do
!$omp end parallel
Expand Down Expand Up @@ -230,6 +235,9 @@ end subroutine ocn_time_average_coupled_init!}}}
!
!-----------------------------------------------------------------------
subroutine ocn_time_average_coupled_accumulate(statePool, forcingPool, timeLevel)!{{{
use ocn_constants, only: &
latent_heat_fusion_mks

type (mpas_pool_type), intent(in) :: statePool
type (mpas_pool_type), intent(inout) :: forcingPool
integer, intent(in) :: timeLevel
Expand All @@ -246,8 +254,10 @@ subroutine ocn_time_average_coupled_accumulate(statePool, forcingPool, timeLevel
real (kind=RKIND), dimension(:), pointer :: effectiveDensityInLandIce, avgEffectiveDensityInLandIce, &
totalFreshWaterTemperatureFlux, avgTotalFreshWaterTemperatureFlux, &
landIceFreshwaterFlux, avgLandIceFreshwaterFlux, &
landIceHeatFlux, avgLandIceHeatFlux, &
removedRiverRunoffFlux, avgRemovedRiverRunoffFlux, &
removedIceRunoffFlux, avgRemovedIceRunoffFlux
removedIceRunoffFlux, avgRemovedIceRunoffFlux, &
avgRemovedIceRunoffHeatFlux

type (mpas_pool_type), pointer :: tracersPool

Expand Down Expand Up @@ -347,12 +357,16 @@ subroutine ocn_time_average_coupled_accumulate(statePool, forcingPool, timeLevel
if(trim(config_land_ice_flux_mode) == 'standalone' .or. trim(config_land_ice_flux_mode) == 'data') then
call mpas_pool_get_array(forcingPool, 'avgLandIceFreshwaterFlux', avgLandIceFreshwaterFlux)
call mpas_pool_get_array(forcingPool, 'landIceFreshwaterFlux', landIceFreshwaterFlux)
call mpas_pool_get_array(forcingPool, 'avgLandIceHeatFlux', avgLandIceHeatFlux)
call mpas_pool_get_array(forcingPool, 'landIceHeatFlux', landIceHeatFlux)

!$omp parallel
!$omp do schedule(runtime)
do iCell = 1, nCells
avgLandIceFreshwaterFlux(iCell) = ( avgLandIceFreshwaterFlux(iCell) * nAccumulatedCoupled &
+ landIceFreshwaterFlux(iCell) ) / ( nAccumulatedCoupled + 1)
avgLandIceHeatFlux(iCell) = ( avgLandIceHeatFlux(iCell) * nAccumulatedCoupled &
+ landIceHeatFlux(iCell) ) / ( nAccumulatedCoupled + 1)
end do
!$omp end do
!$omp end parallel
Expand All @@ -362,6 +376,7 @@ subroutine ocn_time_average_coupled_accumulate(statePool, forcingPool, timeLevel
if (config_remove_AIS_coupler_runoff) then
call mpas_pool_get_array(forcingPool, 'avgRemovedRiverRunoffFlux', avgRemovedRiverRunoffFlux)
call mpas_pool_get_array(forcingPool, 'avgRemovedIceRunoffFlux', avgRemovedIceRunoffFlux)
call mpas_pool_get_array(forcingPool, 'avgRemovedIceRunoffHeatFlux', avgRemovedIceRunoffHeatFlux)
call mpas_pool_get_array(forcingPool, 'removedRiverRunoffFlux', removedRiverRunoffFlux)
call mpas_pool_get_array(forcingPool, 'removedIceRunoffFlux', removedIceRunoffFlux)

Expand All @@ -372,6 +387,8 @@ subroutine ocn_time_average_coupled_accumulate(statePool, forcingPool, timeLevel
+ removedRiverRunoffFlux(iCell) ) / ( nAccumulatedCoupled + 1)
avgRemovedIceRunoffFlux(iCell) = ( avgRemovedIceRunoffFlux(iCell) * nAccumulatedCoupled &
+ removedIceRunoffFlux(iCell) ) / ( nAccumulatedCoupled + 1)
avgRemovedIceRunoffHeatFlux(iCell) = ( avgRemovedIceRunoffHeatFlux(iCell) * nAccumulatedCoupled &
+ removedIceRunoffFlux(iCell)*latent_heat_fusion_mks ) / ( nAccumulatedCoupled + 1)
end do
!$omp end do
!$omp end parallel
Expand Down
Loading

0 comments on commit 4951935

Please sign in to comment.