From 412b4d59a0e3d762158e1e2d8bf2248b41d0bf42 Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Mon, 18 Apr 2022 13:21:11 -0500 Subject: [PATCH] Move conditionals for efficiency --- .../src/shared/mpas_ocn_wetting_drying.F | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/components/mpas-ocean/src/shared/mpas_ocn_wetting_drying.F b/components/mpas-ocean/src/shared/mpas_ocn_wetting_drying.F index 891ed49643b6..e0a2b0e6e36a 100644 --- a/components/mpas-ocean/src/shared/mpas_ocn_wetting_drying.F +++ b/components/mpas-ocean/src/shared/mpas_ocn_wetting_drying.F @@ -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 !}}} @@ -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) @@ -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