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

Bugfixes for ocean inactive top cells feature #5246

Merged
merged 5 commits into from
Nov 8, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,7 @@ subroutine ocn_compute_Haney_number(domain, iErr)
dzVert2 = zMid(k-1,c2)-zMid(k,c2)
dzEdgeK = zMid(k-1,c2)-zMid(k-1,c1)
end if
if ( dzVert1+dzVert2 == 0.0_RKIND ) cycle
dzEdgeKp1 = zMid(k,c2)-zMid(k,c1)

rx1 = abs(dzEdgeK+dzEdgeKp1)/(dzVert1+dzVert2)
Expand Down
2 changes: 1 addition & 1 deletion components/mpas-ocean/src/shared/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ mpas_ocn_transport_tests.o: mpas_ocn_config.o

mpas_ocn_effective_density_in_land_ice.o: mpas_ocn_constants.o mpas_ocn_config.o mpas_ocn_mesh.o

mpas_ocn_forcing_restoring.o: mpas_ocn_constants.o mpas_ocn_config.o
mpas_ocn_forcing_restoring.o: mpas_ocn_constants.o mpas_ocn_config.o mpas_ocn_mesh.o

mpas_ocn_tracer_surface_restoring.o: mpas_ocn_constants.o mpas_ocn_config.o mpas_ocn_framework_forcing.o mpas_ocn_diagnostics_variables.o

Expand Down
2 changes: 1 addition & 1 deletion components/mpas-ocean/src/shared/mpas_ocn_diagnostics.F
Original file line number Diff line number Diff line change
Expand Up @@ -2587,7 +2587,7 @@ subroutine ocn_diagnostic_solve_ssh(forcingPool, ssh, seaIcePressure, &
cell1 = cellsOnEdge(1, iEdge)
cell2 = cellsOnEdge(2, iEdge)

gradSSH(iEdge) = edgeMask(1, iEdge) * ( pressureAdjustedSSH(cell2) - pressureAdjustedSSH(cell1) ) / dcEdge(iEdge)
gradSSH(iEdge) = edgeMask(minLevelEdgeBot(iEdge), iEdge) * ( pressureAdjustedSSH(cell2) - pressureAdjustedSSH(cell1) ) / dcEdge(iEdge)
end do
#ifndef MPAS_OPENACC
!$omp end do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,8 @@ subroutine ocn_surface_bulk_forcing_active_tracers(meshPool, forcingPool, tracer

! Negative seaIceSalinityFlux is an extraction of salt from the ocean
! So, we negate seaIceSalinityFlux when determining how much salt this flux needs.
requiredSalt = - seaIceSalinityFlux(iCell) * sflux_factor * dt / layerThickness(1, iCell)
allowedSalt = min( 4.0_RKIND, tracerGroup(index_salinity_flux, 1, iCell) )
requiredSalt = - seaIceSalinityFlux(iCell) * sflux_factor * dt / layerThickness(minLevelCell(iCell), iCell)
allowedSalt = min( 4.0_RKIND, tracerGroup(index_salinity_flux, minLevelCell(iCell), iCell) )

if ( allowedSalt < requiredSalt ) then
tracersSurfaceFluxRemoved(index_salinity_flux, iCell) = tracersSurfaceFluxRemoved(index_salinity_flux, iCell) &
Expand Down
12 changes: 5 additions & 7 deletions components/mpas-ocean/src/shared/mpas_ocn_tracer_hmix_redi.F
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,8 @@ subroutine ocn_tracer_hmix_Redi_tend(meshPool, layerThickness, layerThickEdgeMea
r_tmp = dvEdge(iEdge)/dcEdge(iEdge)
coef = dvEdge(iEdge)

k = minLevelEdgeBot(iEdge)
kappaRediEdgeVal = 0.25_RKIND*(RediKappaScaling(k, cell1) + RediKappaScaling(k, cell2) + &
RediKappaScaling(k + 1, cell1) + RediKappaScaling(k + 1, cell2))
k = 1
if (minLevelEdgeBot(iEdge) .ne. 1) k = minLevelEdgeBot(iEdge)
kappaRediEdgeVal = 0.25_RKIND*(RediKappaScaling(k, cell1) + RediKappaScaling(k, cell2) + &
RediKappaScaling(k + 1, cell1) + RediKappaScaling(k + 1, cell2))

Expand All @@ -259,13 +257,13 @@ subroutine ocn_tracer_hmix_Redi_tend(meshPool, layerThickness, layerThickEdgeMea
/(zMid(k, cell2) - zMid(k + 1, cell2)))
if (minLevelCell(cell1) < minLevelEdgeBot(iEdge)) then
flux_term2 = flux_term2 + coef*RediKappa(iEdge)* &
layerThickEdgeMean(minLevelEdgeBot(iEdge), iEdge)*0.25_RKIND*kappaRediEdgeVal*slopeTriadUp(minLevelEdgeBot(iEdge), 1, iEdge)* &
(tracers(iTr, minLevelEdgeBot(iEdge) - 1, cell1) - tracers(iTr, minLevelEdgeBot(iEdge), cell1))/(zMid(minLevelEdgeBot(iEdge) - 1, cell1) - zMid(minLevelEdgeBot(iEdge), cell1))
layerThickEdgeMean(k, iEdge)*0.25_RKIND*kappaRediEdgeVal*slopeTriadUp(k, 1, iEdge)* &
(tracers(iTr, k - 1, cell1) - tracers(iTr, k, cell1))/(zMid(k - 1, cell1) - zMid(k, cell1))
cbegeman marked this conversation as resolved.
Show resolved Hide resolved
endif
if (minLevelCell(cell2) < minLevelEdgeBot(iEdge)) then
flux_term2 = flux_term2 + coef*RediKappa(iEdge)* &
layerThickEdgeMean(minLevelEdgeBot(iEdge), iEdge)*0.25_RKIND*kappaRediEdgeVal*slopeTriadUp(minLevelEdgeBot(iEdge), 2, iEdge)* &
(tracers(iTr, minLevelEdgeBot(iEdge) - 1, cell2) - tracers(iTr, minLevelEdgeBot(iEdge), cell2))/(zMid(minLevelEdgeBot(iEdge) - 1, cell2) - zMid(minLevelEdgeBot(iEdge), cell2))
layerThickEdgeMean(k, iEdge)*0.25_RKIND*kappaRediEdgeVal*slopeTriadUp(k, 2, iEdge)* &
(tracers(iTr, k - 1, cell2) - tracers(iTr, k, cell2))/(zMid(k - 1, cell2) - zMid(k, cell2))
endif

redi_term2(iTr, k, iCell) = redi_term2(iTr, k, iCell) - edgeSignOnCell(i, iCell)*flux_term2*invAreaCell
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ module ocn_tracer_surface_restoring
use ocn_config
use ocn_framework_forcing
use ocn_diagnostics_variables
use ocn_mesh

implicit none

Expand Down Expand Up @@ -135,11 +136,11 @@ subroutine ocn_tracer_surface_restoring_compute(groupName, nTracers, nCells, tra

err = 0

iLevel = 1 ! base surface flux restoring on tracer fields in the top layer

!$omp parallel
!$omp do schedule(runtime) private(iTracer)
!$omp do schedule(runtime) private(iTracer, iLevel)
do iCell=1,nCells
iLevel = minLevelCell(iCell) ! base surface flux restoring on tracer fields in the top layer

do iTracer=1,nTracers

! For monthly salinity restoring, tracersSurfaceRestoringValue contains the zero-mean deltaS
Expand Down