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

Add cryo terms to coupler budget #74

Closed
Show file tree
Hide file tree
Changes from 12 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
13 changes: 12 additions & 1 deletion components/mpas-ocean/driver/mpaso_cpl_indices.F
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ module mpaso_cpl_indices
integer :: index_o2x_Faoo_fco2_ocn
integer :: index_o2x_Faoo_fdms_ocn
integer :: index_o2x_So_ssh

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 @@ -188,6 +192,13 @@ subroutine mpaso_cpl_indices_set( )
index_o2x_Faoo_fdms_ocn = mct_avect_indexra(o2x,'Faoo_fdms_ocn',perrWith='quiet')
index_o2x_So_ssh = mct_avect_indexra(o2x,'So_ssh')

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
64 changes: 61 additions & 3 deletions components/mpas-ocean/driver/ocn_comp_mct.F
Original file line number Diff line number Diff line change
Expand Up @@ -2694,7 +2694,12 @@ subroutine ocn_export_mct(o2x_o, errorCode) !{{{
avgOceanSurfaceDOCSemiLabile, &
avgOceanSurfaceFeParticulate, &
avgOceanSurfaceFeDissolved, &
ssh
ssh, &
avgLandIceFreshwaterFlux, &
avgRemovedRiverRunoffFlux, &
avgRemovedIceRunoffFlux, &
avgLandIceHeatFlux, &
avgRemovedIceRunoffHeatFlux

real (kind=RKIND), dimension(:,:), pointer :: avgTracersSurfaceValue, avgSurfaceVelocity, &
avgSSHGradient, avgOceanSurfacePhytoC, &
Expand All @@ -2703,6 +2708,7 @@ subroutine ocn_export_mct(o2x_o, errorCode) !{{{
real (kind=RKIND) :: surfaceFreezingTemp

logical, pointer :: frazilIceActive, &
config_remove_AIS_coupler_runoff, &
config_use_ecosysTracers, &
config_use_DMSTracers, &
config_use_MacroMoleculesTracers, &
Expand All @@ -2719,6 +2725,7 @@ subroutine ocn_export_mct(o2x_o, errorCode) !{{{
call mpas_pool_get_package(domain % packages, 'frazilIceActive', frazilIceActive)
call mpas_pool_get_config(domain % configs, 'config_use_ecosysTracers', config_use_ecosysTracers)
call mpas_pool_get_config(domain % configs, 'config_land_ice_flux_mode', config_land_ice_flux_mode)
call mpas_pool_get_config(domain % configs, 'config_remove_AIS_coupler_runoff', config_remove_AIS_coupler_runoff)
call mpas_pool_get_config(domain % configs, 'config_use_DMSTracers', config_use_DMSTracers)
call mpas_pool_get_config(domain % configs, 'config_use_MacroMoleculesTracers', config_use_MacroMoleculesTracers)
call mpas_pool_get_config(domain % configs, 'config_use_ecosysTracers_sea_ice_coupling', &
Expand Down Expand Up @@ -2761,6 +2768,17 @@ subroutine ocn_export_mct(o2x_o, errorCode) !{{{
call mpas_pool_get_array(statePool, 'accumulatedFrazilIceMass', accumulatedFrazilIceMass, 1)
end if

! 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
if (config_use_ecosysTracers) then

Expand Down Expand Up @@ -2812,6 +2830,17 @@ subroutine ocn_export_mct(o2x_o, errorCode) !{{{

o2x_o % rAttr(index_o2x_Faoo_h2otemp, n) = avgTotalFreshWaterTemperatureFlux(i) * rho_sw * cp_sw

! 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
! negative when frazil ice can be melted
keepFrazil = .true.
Expand Down Expand Up @@ -3590,6 +3619,7 @@ subroutine ocn_import_moab( Eclock, errorCode)!{{{
endif

if ( landIceFreshwaterFluxField % isActive ) then
!DC is this ok with proposed implementation? think so since different coupling field
!landIceFreshwaterFlux(i) = x2o_om(n, index_x2o_Fogx_qicelo)
end if
if ( landIceHeatFluxField % isActive ) then
Expand Down Expand Up @@ -3975,7 +4005,12 @@ subroutine ocn_export_moab(EClock) !{{{
avgOceanSurfaceDOCSemiLabile, &
avgOceanSurfaceFeParticulate, &
avgOceanSurfaceFeDissolved, &
ssh
ssh, &
avgLandIceFreshwaterFlux, &
avgRemovedRiverRunoffFlux, &
avgRemovedIceRunoffFlux, &
avgLandIceHeatFlux, &
avgRemovedIceRunoffHeatFlux

real (kind=RKIND), dimension(:,:), pointer :: avgTracersSurfaceValue, avgSurfaceVelocity, &
avgSSHGradient, avgOceanSurfacePhytoC, &
Expand All @@ -3984,6 +4019,7 @@ subroutine ocn_export_moab(EClock) !{{{
real (kind=RKIND) :: surfaceFreezingTemp

logical, pointer :: frazilIceActive, &
config_remove_AIS_coupler_runoff, &
config_use_ecosysTracers, &
config_use_DMSTracers, &
config_use_MacroMoleculesTracers, &
Expand All @@ -4000,6 +4036,7 @@ subroutine ocn_export_moab(EClock) !{{{
call mpas_pool_get_package(domain % packages, 'frazilIceActive', frazilIceActive)
call mpas_pool_get_config(domain % configs, 'config_use_ecosysTracers', config_use_ecosysTracers)
call mpas_pool_get_config(domain % configs, 'config_land_ice_flux_mode', config_land_ice_flux_mode)
call mpas_pool_get_config(domain % configs, 'config_remove_AIS_coupler_runoff', config_remove_AIS_coupler_runoff)
call mpas_pool_get_config(domain % configs, 'config_use_DMSTracers', config_use_DMSTracers)
call mpas_pool_get_config(domain % configs, 'config_use_MacroMoleculesTracers', config_use_MacroMoleculesTracers)
call mpas_pool_get_config(domain % configs, 'config_use_ecosysTracers_sea_ice_coupling', &
Expand Down Expand Up @@ -4041,6 +4078,16 @@ subroutine ocn_export_moab(EClock) !{{{
call mpas_pool_get_array(forcingPool, 'frazilSurfacePressure', frazilSurfacePressure)
call mpas_pool_get_array(statePool, 'accumulatedFrazilIceMass', accumulatedFrazilIceMass, 1)
end if

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
if (config_use_ecosysTracers) then
Expand Down Expand Up @@ -4092,7 +4139,18 @@ subroutine ocn_export_moab(EClock) !{{{
o2x_om(n, index_o2x_So_dhdy) = avgSSHGradient(index_avgMeridionalSSHGradient, i)

o2x_om(n, index_o2x_Faoo_h2otemp) = avgTotalFreshWaterTemperatureFlux(i) * rho_sw * cp_sw


!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
! negative when frazil ice can be melted
keepFrazil = .true.
Expand Down
16 changes: 16 additions & 0 deletions components/mpas-ocean/src/Registry.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3608,6 +3608,7 @@
packages="activeTracersBulkRestoringPKG;thicknessBulkPKG"
/>


<!-- Misc. coupling fields -->
<var name="iceFraction" type="real" dimensions="nCells Time" units="fractional"
description="Fraction of sea ice coverage at cell centers from coupler. Positive into the ocean."
Expand Down Expand Up @@ -3689,6 +3690,21 @@
<var name="avgTotalFreshWaterTemperatureFlux" type="real" dimensions="nCells Time" units="C m s^-1"
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."
/>
<var name="avgLandIceHeatFlux" type="real" dimensions="nCells Time" units="J m^-2 s^-1"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to check units here

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 -->
<var name="landIceFraction" type="real" dimensions="nCells Time" units="1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2432,7 +2432,8 @@ subroutine ocn_restart_conservation_check(domain, err)!{{{
err = 0

if ( trim(config_land_ice_flux_mode) == 'standalone' .or. &
trim(config_land_ice_flux_mode) == 'coupled' ) then
trim(config_land_ice_flux_mode) == 'coupled' .or. &
trim(config_land_ice_flux_mode) == 'data' ) then
landIceFreshwaterFluxesOn = .true.
end if

Expand Down
88 changes: 86 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 @@ -53,7 +53,10 @@ subroutine ocn_time_average_coupled_init(forcingPool)!{{{
real (kind=RKIND), dimension(:,:), pointer :: avgTracersSurfaceValue, avgSurfaceVelocity, avgSSHGradient, &
avgLandIceBoundaryLayerTracers, avgLandIceTracerTransferVelocities

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

integer :: iCell
integer, pointer :: nAccumulatedCoupled, nCells
Expand Down Expand Up @@ -116,6 +119,37 @@ subroutine ocn_time_average_coupled_init(forcingPool)!{{{
!$omp end parallel
end if

! 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
end if

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
end if

! set up BGC coupling fields if necessary
if (config_use_ecosysTracers) then

Expand Down Expand Up @@ -201,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 @@ -215,7 +252,12 @@ subroutine ocn_time_average_coupled_accumulate(statePool, forcingPool, timeLevel
real (kind=RKIND), dimension(:,:), pointer :: &
avgLandIceBoundaryLayerTracers, avgLandIceTracerTransferVelocities
real (kind=RKIND), dimension(:), pointer :: effectiveDensityInLandIce, avgEffectiveDensityInLandIce, &
totalFreshWaterTemperatureFlux, avgTotalFreshWaterTemperatureFlux
totalFreshWaterTemperatureFlux, avgTotalFreshWaterTemperatureFlux, &
landIceFreshwaterFlux, avgLandIceFreshwaterFlux, &
landIceHeatFlux, avgLandIceHeatFlux, &
removedRiverRunoffFlux, avgRemovedRiverRunoffFlux, &
removedIceRunoffFlux, avgRemovedIceRunoffFlux, &
avgRemovedIceRunoffHeatFlux

type (mpas_pool_type), pointer :: tracersPool

Expand Down Expand Up @@ -311,6 +353,48 @@ subroutine ocn_time_average_coupled_accumulate(statePool, forcingPool, timeLevel
!$omp end parallel
end if

! Accumulate 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, '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

end if

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)

!$omp parallel
!$omp do schedule(runtime)
do iCell = 1, nCells
avgRemovedRiverRunoffFlux(iCell) = ( avgRemovedRiverRunoffFlux(iCell) * nAccumulatedCoupled &
+ 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

end if

! accumulate BGC coupling fields if necessary
if (config_use_ecosysTracers) then

Expand Down
Loading