Skip to content

Commit

Permalink
Move conditionals for efficiency
Browse files Browse the repository at this point in the history
  • Loading branch information
cbegeman committed Jul 13, 2022
1 parent 6520ad1 commit 412b4d5
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions components/mpas-ocean/src/shared/mpas_ocn_wetting_drying.F
Original file line number Diff line number Diff line change
Expand Up @@ -267,20 +267,22 @@ subroutine ocn_prevent_drying_rk4(block, dt, rkSubstepWeight, config_zero_drying
normalTransportVelocity, rkSubstepWeight, wettingVelocityFactor, err)
! prevent drying from happening with selective wettingVelocityFactor
!$omp parallel
!$omp do schedule(runtime) private(k)
do iEdge = 1, nEdgesAll
do k = minLevelEdgeTop(iEdge), maxLevelEdgeBot(iEdge)
if (abs(wettingVelocityFactor(k, iEdge)) > 0.0_RKIND .and. config_zero_drying_velocity) then
normalTransportVelocity(k, iEdge) = 0.0_RKIND
normalVelocity(k, iEdge) = 0.0_RKIND
end if
if (config_zero_drying_velocity) then
!$omp parallel
!$omp do schedule(runtime) private(k)
do iEdge = 1, nEdgesAll
do k = minLevelEdgeTop(iEdge), maxLevelEdgeBot(iEdge)
if (abs(wettingVelocityFactor(k, iEdge)) > 0.0_RKIND) then
normalTransportVelocity(k, iEdge) = 0.0_RKIND
normalVelocity(k, iEdge) = 0.0_RKIND
end if
end do
end do
end do
!$omp end do
!$omp end parallel
!$omp end do
!$omp end parallel
end if
end subroutine ocn_prevent_drying_rk4 !}}}
Expand Down Expand Up @@ -352,6 +354,8 @@ subroutine ocn_wetting_drying_wettingVelocity(layerThickEdgeFlux, layerThickness
err = 0
if (.not. config_zero_drying_velocity ) return
! need predicted transport velocity to limit drying flux
!$omp parallel
!$omp do schedule(runtime) private(i, iEdge, k, divOutFlux, layerThickness)
Expand Down Expand Up @@ -380,8 +384,7 @@ subroutine ocn_wetting_drying_wettingVelocity(layerThickEdgeFlux, layerThickness
do i = 1, nEdgesOnCell(iCell)
iEdge = edgesOnCell(i, iCell)
if (k <= maxLevelEdgeBot(iEdge) .or. k >= minLevelEdgeTop(iEdge)) then
if ( normalVelocity(k, iEdge) * edgeSignOnCell(i, iCell) <= 0.0_RKIND &
.and. config_zero_drying_velocity ) then
if ( normalVelocity(k, iEdge) * edgeSignOnCell(i, iCell) <= 0.0_RKIND ) then
! just go with simple boolean approach for zero wetting velocity for debugging purposes
wettingVelocityFactor(k, iEdge) = 1.0_RKIND
end if
Expand Down

0 comments on commit 412b4d5

Please sign in to comment.