Skip to content

Commit

Permalink
Add unweighted sum
Browse files Browse the repository at this point in the history
  • Loading branch information
cbegeman committed Nov 10, 2022
1 parent eeb6090 commit 41fcf7c
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions components/mpas-ocean/src/shared/mpas_ocn_thick_ale.F
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,9 @@ subroutine ocn_ALE_thickness(verticalMeshPool, SSH, ALE_thickness, &

real (kind=RKIND) :: &
weightSum, &! sum of weights in vertical
restingThicknessSum, &! total resting thickness
restingThicknessDiff, &! total resting thickness
restingThicknessSum, &! total resting thickness
restingThicknessDiff, &! difference from total resting thickness
weightedThicknessSum, &! total resting thickness, weighted
remainder, &! track remainder in mix/max alteration
newThickness ! temp used during min/max adjustment

Expand Down Expand Up @@ -173,19 +174,24 @@ subroutine ocn_ALE_thickness(verticalMeshPool, SSH, ALE_thickness, &
!xacc present(ALE_thickness, SSH, restingThickness, &
!xacc minLevelCell, maxLevelCell, &
!xacc vertCoordMovementWeights) &
!xacc private(k, kMin, kMax, restingThicknessDiff, restingThicknessSum)
!xacc private(k, kMin, kMax, restingThicknessDiff, &
!xacc restingThicknessSum, weightedThicknessSum)
#else
!$omp parallel
!$omp do schedule(runtime) &
!$omp private(k, kMin, kMax, restingThicknessDiff, restingThicknessSum)
!$omp private(k, kMin, kMax, restingThicknessDiff, &
!$omp restingThicknessSum, weightedThicknessSum)
#endif
do iCell = 1, nCells
kMax = maxLevelCell(iCell)
kMin = minLevelCell(iCell)

restingThicknessSum = 0.0_RKIND
weightedThicknessSum = 0.0_RKIND
do k = kMin, kMax
restingThicknessSum = restingThicknessSum &
+ restingThickness(k,iCell)
weightedThicknessSum = weightedThicknessSum &
+ vertCoordMovementWeights(k) &
* restingThickness(k,iCell)
end do
Expand All @@ -198,7 +204,7 @@ subroutine ocn_ALE_thickness(verticalMeshPool, SSH, ALE_thickness, &
do k = kMin, kMax
ALE_thickness(k, iCell) = restingThickness(k, iCell) &
+ ( (SSH(iCell) + restingThicknessDiff) * vertCoordMovementWeights(k) * &
restingThickness(k, iCell) ) / max(1e-14_RKIND, restingThicknessSum)
restingThickness(k, iCell) ) / max(1e-14_RKIND, weightedThicknessSum)
end do
enddo
#ifndef MPAS_OPENACC
Expand Down

0 comments on commit 41fcf7c

Please sign in to comment.