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 5 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
8 changes: 7 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,9 @@ 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

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

Expand Down Expand Up @@ -187,6 +189,10 @@ 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?
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Noting I added 'P' for the ice-shelf melt term; I'm not sure if this matters with the way I did the scaling below. The removed runoff terms do not have P.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I just tested without the 'P' and get the same answers, so I'm removing this.

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

index_o2x_So_blt = mct_avect_indexra(o2x,'So_blt')
index_o2x_So_bls = mct_avect_indexra(o2x,'So_bls')
Expand Down
52 changes: 49 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,10 @@ subroutine ocn_export_mct(o2x_o, errorCode) !{{{
avgOceanSurfaceDOCSemiLabile, &
avgOceanSurfaceFeParticulate, &
avgOceanSurfaceFeDissolved, &
ssh
ssh, &
avgLandIceFreshwaterFlux, &
avgRemovedRiverRunoffFlux, &
avgRemovedIceRunoffFlux

real (kind=RKIND), dimension(:,:), pointer :: avgTracersSurfaceValue, avgSurfaceVelocity, &
avgSSHGradient, avgOceanSurfacePhytoC, &
Expand All @@ -2703,6 +2706,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 +2723,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 +2766,15 @@ subroutine ocn_export_mct(o2x_o, errorCode) !{{{
call mpas_pool_get_array(statePool, 'accumulatedFrazilIceMass', accumulatedFrazilIceMass, 1)
end if

! Cryo fields
if (config_land_ice_flux_mode == 'standalone' .or. 'data') then
xylar marked this conversation as resolved.
Show resolved Hide resolved
xylar marked this conversation as resolved.
Show resolved Hide resolved
call mpas_pool_get_array(forcingPool, 'avgLandIceFreshwaterFlux', avgLandIceFreshwaterFlux)
endif
if (config_remove_AIS_coupler_runoff) then
call mpas_pool_get_array(forcingPool, 'avgRemovedRiverRunoffFlux', avgRemovedRiverRunoffFlux)
call mpas_pool_get_array(forcingPool, 'avgRemovedIceRunoffFlux', avgRemovedIceRunoffFlux)
endif

! BGC fields
if (config_use_ecosysTracers) then

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

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

! Cryo fields
if (config_land_ice_flux_mode == 'standalone' .or. 'data') then
xylar marked this conversation as resolved.
Show resolved Hide resolved
o2x_o % rAttr(index_o2x_Foxo_ismw, n) = avgLandIceFreshwaterFlux(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)
endif

if ( frazilIceActive ) then
! negative when frazil ice can be melted
keepFrazil = .true.
Expand Down Expand Up @@ -3590,6 +3613,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 +3999,10 @@ subroutine ocn_export_moab(EClock) !{{{
avgOceanSurfaceDOCSemiLabile, &
avgOceanSurfaceFeParticulate, &
avgOceanSurfaceFeDissolved, &
ssh
ssh, &
avgLandIceFreshwaterFlux, &
avgRemovedRiverRunoffFlux, &
avgRemovedIceRunoffFlux

real (kind=RKIND), dimension(:,:), pointer :: avgTracersSurfaceValue, avgSurfaceVelocity, &
avgSSHGradient, avgOceanSurfacePhytoC, &
Expand All @@ -3984,6 +4011,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 +4028,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 +4070,14 @@ 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 (config_land_ice_flux_mode == 'standalone' .or. 'data') then
xylar marked this conversation as resolved.
Show resolved Hide resolved
call mpas_pool_get_array(forcingPool, 'avgLandIceFreshwaterFlux', avgLandIceFreshwaterFlux)
endif
if (config_remove_AIS_coupler_runoff) then
call mpas_pool_get_array(forcingPool, 'avgRemovedRiverRunoffFlux', avgRemovedRiverRunoffFlux)
call mpas_pool_get_array(forcingPool, 'avgRemovedIceRunoffFlux', avgRemovedIceRunoffFlux)
endif

! BGC fields
if (config_use_ecosysTracers) then
Expand Down Expand Up @@ -4092,7 +4129,16 @@ 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 (config_land_ice_flux_mode == 'standalone' .or. 'data') then
xylar marked this conversation as resolved.
Show resolved Hide resolved
o2x_om(n, index_o2x_Foxo_ismw) = avgLandIceFreshwaterFlux(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)
endif

if ( frazilIceActive ) then
! negative when frazil ice can be melted
keepFrazil = .true.
Expand Down
10 changes: 10 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,15 @@
<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="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."
/>

<!-- Input fields from coupler or initial condition for forcing under land ice -->
<var name="landIceFraction" type="real" dimensions="nCells Time" units="1"
Expand Down
78 changes: 76 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,9 @@ 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

integer :: iCell
integer, pointer :: nAccumulatedCoupled, nCells
Expand Down Expand Up @@ -116,6 +118,33 @@ 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. 'data') then
Copy link
Collaborator

Choose a reason for hiding this comment

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

@darincomeau, same issue here as below. This may explain why you still were having trouble with data mode.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah this is fixed locally, I just hadn't pushed it yet since I was still getting 0s.

call mpas_pool_get_array(forcingPool, 'avgLandIceFreshwaterFlux', avgLandIceFreshwaterFlux)

!$omp parallel
!$omp do schedule(runtime)
do iCell = 1, nCells
avgLandIceFreshwaterFlux(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)

!$omp parallel
!$omp do schedule(runtime)
do iCell = 1, nCells
avgRemovedRiverRunoffFlux(iCell) = 0.0_RKIND
avgRemovedIceRunoffFlux(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 @@ -215,7 +244,10 @@ 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, &
removedRiverRunoffFlux, avgRemovedRiverRunoffFlux, &
removedIceRunoffFlux, avgRemovedIceRunoffFlux

type (mpas_pool_type), pointer :: tracersPool

Expand Down Expand Up @@ -311,6 +343,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. 'data') then
xylar marked this conversation as resolved.
Show resolved Hide resolved
call mpas_pool_get_array(forcingPool, 'avgLandIceFreshwaterFlux', avgLandIceFreshwaterFlux)

if(trim(config_land_ice_flux_mode) == 'standalone') then
call mpas_pool_get_array(forcingPool, 'landIceFreshwaterFlux', landIceFreshwaterFlux)
endif

! load data melt rates if used
Copy link
Collaborator Author

@darincomeau darincomeau Feb 1, 2024

Choose a reason for hiding this comment

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

this didn't work, stays 0 when data ISMF is used.

Copy link
Collaborator

Choose a reason for hiding this comment

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

You should be able to use landIceFreshwaterFlux for both standalone and data, since one is just copied to the other:
https://github.com/E3SM-Project/E3SM/blob/104a2027d9ad34fbd9198422641ad47f19db65c0/components/mpas-ocean/src/shared/mpas_ocn_surface_land_ice_fluxes.F#L300
But that doesn't explain why you're getting zero.

if(trim(config_land_ice_flux_mode) == 'data') then
call mpas_pool_get_array(forcingPool, 'dataLandIceFreshwaterFlux', landIceFreshwaterFlux)
endif

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

end if

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

Expand Down
Loading
Loading