From 22890746ec5eb1b57f87a44f618ed36ea6521766 Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Thu, 27 Oct 2022 10:29:03 -0500 Subject: [PATCH 1/6] Re-apply PR#5254 Modify ocean z-star ALE coordinate for inactive top cells --- .../src/shared/mpas_ocn_thick_ale.F | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/components/mpas-ocean/src/shared/mpas_ocn_thick_ale.F b/components/mpas-ocean/src/shared/mpas_ocn_thick_ale.F index a4e861f6ed67..7e225a5bf405 100644 --- a/components/mpas-ocean/src/shared/mpas_ocn_thick_ale.F +++ b/components/mpas-ocean/src/shared/mpas_ocn_thick_ale.F @@ -125,10 +125,12 @@ subroutine ocn_ALE_thickness(verticalMeshPool, SSH, ALE_thickness, & nCells ! number of cells real (kind=RKIND) :: & - weightSum, &! sum of weights in vertical - thicknessSum, &! total thickness - remainder, &! track remainder in mix/max alteration - newThickness ! temp used during min/max adjustment + weightSum, &! sum of weights in vertical + 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 real (kind=RKIND), dimension(:), allocatable :: & prelim_ALE_thickness, & ! ALE thickness at new time @@ -172,31 +174,37 @@ subroutine ocn_ALE_thickness(verticalMeshPool, SSH, ALE_thickness, & !xacc present(ALE_thickness, SSH, restingThickness, & !xacc minLevelCell, maxLevelCell, & !xacc vertCoordMovementWeights) & - !xacc private(k, kMin, kMax, thicknessSum) + !xacc private(k, kMin, kMax, restingThicknessDiff, & + !xacc restingThicknessSum, weightedThicknessSum) #else !$omp parallel !$omp do schedule(runtime) & - !$omp private(k, kMin, kMax, thicknessSum) + !$omp private(k, kMin, kMax, restingThicknessDiff, & + !$omp restingThicknessSum, weightedThicknessSum) #endif do iCell = 1, nCells kMax = maxLevelCell(iCell) kMin = minLevelCell(iCell) - thicknessSum = 1e-14_RKIND + restingThicknessSum = 0.0_RKIND + weightedThicknessSum = 0.0_RKIND do k = kMin, kMax - thicknessSum = thicknessSum & + restingThicknessSum = restingThicknessSum & + + restingThickness(k,iCell) + weightedThicknessSum = weightedThicknessSum & + vertCoordMovementWeights(k) & * restingThickness(k,iCell) end do + restingThicknessDiff = restingThicknessSum - bottomDepth(iCell) ! Note that restingThickness is nonzero, and remaining ! terms are perturbations about zero. ! This is equation 4 and 6 in Petersen et al 2015, ! but with eqn 6 do k = kMin, kMax - ALE_thickness(k,iCell) = restingThickness(k,iCell) & - + (SSH(iCell)*vertCoordMovementWeights(k)* & - restingThickness(k,iCell) )/thicknessSum + ALE_thickness(k, iCell) = restingThickness(k, iCell) & + + ( (SSH(iCell) + restingThicknessDiff) * vertCoordMovementWeights(k) * & + restingThickness(k, iCell) ) / weightedThicknessSum end do enddo #ifndef MPAS_OPENACC From 5bdb41abb69cf9949bc51f149282bf4976206b75 Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Tue, 28 May 2024 15:01:47 -0500 Subject: [PATCH 2/6] Change sign of restingThickness ALE contribution --- components/mpas-ocean/src/shared/mpas_ocn_thick_ale.F | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/mpas-ocean/src/shared/mpas_ocn_thick_ale.F b/components/mpas-ocean/src/shared/mpas_ocn_thick_ale.F index 7e225a5bf405..7f95aa12c0ce 100644 --- a/components/mpas-ocean/src/shared/mpas_ocn_thick_ale.F +++ b/components/mpas-ocean/src/shared/mpas_ocn_thick_ale.F @@ -203,7 +203,7 @@ subroutine ocn_ALE_thickness(verticalMeshPool, SSH, ALE_thickness, & ! but with eqn 6 do k = kMin, kMax ALE_thickness(k, iCell) = restingThickness(k, iCell) & - + ( (SSH(iCell) + restingThicknessDiff) * vertCoordMovementWeights(k) * & + + ( (SSH(iCell) - restingThicknessDiff) * vertCoordMovementWeights(k) * & restingThickness(k, iCell) ) / weightedThicknessSum end do enddo From 43fe745e6e1bfb0ad2cdb389a7499e7741d2e45a Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Tue, 28 May 2024 15:08:21 -0500 Subject: [PATCH 3/6] Set minimum vertCoordMovementWeight --- components/mpas-ocean/src/shared/mpas_ocn_mesh.F | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/mpas-ocean/src/shared/mpas_ocn_mesh.F b/components/mpas-ocean/src/shared/mpas_ocn_mesh.F index 5e0690704e40..de21287093f8 100644 --- a/components/mpas-ocean/src/shared/mpas_ocn_mesh.F +++ b/components/mpas-ocean/src/shared/mpas_ocn_mesh.F @@ -1568,7 +1568,7 @@ subroutine ocn_meshVertCoordInit(domain)!{{{ select case (trim(config_vert_coord_movement)) case ('fixed') - vertCoordMovementWeights = 0.0_RKIND + vertCoordMovementWeights = 1e-14_RKIND vertCoordMovementWeights(1) = 1.0_RKIND case ('uniform_stretching') @@ -1587,7 +1587,7 @@ subroutine ocn_meshVertCoordInit(domain)!{{{ (config_vert_taper_weight_depth_2 - & config_vert_taper_weight_depth_1) ! limit range to (0,1) - vertCoordMovementWeights(k) = max( 0.0_RKIND, & + vertCoordMovementWeights(k) = max( 1e-14_RKIND, & min( 1.0_RKIND, vertCoordMovementWeights(k) ) ) end do From 5fbc260fe7329029afbc8f56f3453fec13712464 Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Tue, 4 Jun 2024 11:17:43 -0500 Subject: [PATCH 4/6] fixup openacc --- components/mpas-ocean/src/shared/mpas_ocn_thick_ale.F | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/mpas-ocean/src/shared/mpas_ocn_thick_ale.F b/components/mpas-ocean/src/shared/mpas_ocn_thick_ale.F index 7f95aa12c0ce..9ebe1b3645d2 100644 --- a/components/mpas-ocean/src/shared/mpas_ocn_thick_ale.F +++ b/components/mpas-ocean/src/shared/mpas_ocn_thick_ale.F @@ -172,7 +172,7 @@ subroutine ocn_ALE_thickness(verticalMeshPool, SSH, ALE_thickness, & #ifdef MPAS_OPENACC !xacc parallel loop & !xacc present(ALE_thickness, SSH, restingThickness, & - !xacc minLevelCell, maxLevelCell, & + !xacc minLevelCell, maxLevelCell, bottomDepth, & !xacc vertCoordMovementWeights) & !xacc private(k, kMin, kMax, restingThicknessDiff, & !xacc restingThicknessSum, weightedThicknessSum) From 33fe3097f3152a4a9a15994d755e0db2f682ebf9 Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Wed, 12 Jun 2024 14:18:35 -0500 Subject: [PATCH 5/6] Use pressureAdjustedSSH with ssh_gradient pressure tendency --- components/mpas-ocean/src/shared/mpas_ocn_tendency.F | 2 +- .../mpas-ocean/src/shared/mpas_ocn_vel_pressure_grad.F | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/components/mpas-ocean/src/shared/mpas_ocn_tendency.F b/components/mpas-ocean/src/shared/mpas_ocn_tendency.F index a16e52f14499..89cfa07ad2bf 100644 --- a/components/mpas-ocean/src/shared/mpas_ocn_tendency.F +++ b/components/mpas-ocean/src/shared/mpas_ocn_tendency.F @@ -419,7 +419,7 @@ subroutine ocn_tend_vel(domain, tendPool, statePool, forcingPool, & vertAleTransportTop, tendVel, err) ! Add pressure gradient - call ocn_vel_pressure_grad_tend(ssh, pressure, surfacePressure, & + call ocn_vel_pressure_grad_tend(ssh, gradSSH, pressure, surfacePressure, & montgomeryPotential, zMid, & density, potentialDensity, & indxTemp, indxSalt, activeTracers, & diff --git a/components/mpas-ocean/src/shared/mpas_ocn_vel_pressure_grad.F b/components/mpas-ocean/src/shared/mpas_ocn_vel_pressure_grad.F index b8f83cd01dce..f7e97aa13384 100644 --- a/components/mpas-ocean/src/shared/mpas_ocn_vel_pressure_grad.F +++ b/components/mpas-ocean/src/shared/mpas_ocn_vel_pressure_grad.F @@ -94,7 +94,7 @@ module ocn_vel_pressure_grad ! !----------------------------------------------------------------------- - subroutine ocn_vel_pressure_grad_tend(ssh, pressure, surfacePressure, & + subroutine ocn_vel_pressure_grad_tend(ssh, gradSSH, pressure, surfacePressure, & montgomeryPotential, zMid, & density, potentialDensity, & indxT, indxS, tracers, & @@ -113,6 +113,7 @@ subroutine ocn_vel_pressure_grad_tend(ssh, pressure, surfacePressure, & real (kind=RKIND), dimension(:), intent(in) :: & ssh, &!< [in] sea surface height + gradSSH, &!< [in] sea surface height gradient on edges surfacePressure !< [in] surface pressure real (kind=RKIND), dimension(:,:), intent(in) :: & @@ -241,7 +242,7 @@ subroutine ocn_vel_pressure_grad_tend(ssh, pressure, surfacePressure, & do k=kMin,kMax tend(k,iEdge) = tend(k,iEdge) - & edgeMask(k,iEdge)*invdcEdge* & - ( gravity*(ssh(cell2) - ssh(cell1)) & + ( gravity*gradSSH(iEdge) & + density0Inv*( surfacePressure(cell2) & - surfacePressure(cell1)) ) end do From 81762421f3a48a3bc4214a0d541642db8ada8aa3 Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Thu, 8 Aug 2024 10:55:42 -0500 Subject: [PATCH 6/6] Make init mode vertical coord consistent with allowing differences between initial wct and restingThicknessSum --- .../src/mode_init/mpas_ocn_init_vertical_grids.F | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/components/mpas-ocean/src/mode_init/mpas_ocn_init_vertical_grids.F b/components/mpas-ocean/src/mode_init/mpas_ocn_init_vertical_grids.F index 5c0ac5a0e114..d2c0033c0d0b 100644 --- a/components/mpas-ocean/src/mode_init/mpas_ocn_init_vertical_grids.F +++ b/components/mpas-ocean/src/mode_init/mpas_ocn_init_vertical_grids.F @@ -591,7 +591,7 @@ subroutine ocn_compute_z_star_layerThickness(layerThickness, restingThickness, s integer, intent(out) :: iErr integer :: k - real (kind=RKIND) :: layerStretch + real (kind=RKIND) :: layerStretch, restingThicknessSum iErr = 0 @@ -599,7 +599,10 @@ subroutine ocn_compute_z_star_layerThickness(layerThickness, restingThickness, s if (maxLevelCell<=0) return - layerStretch = (ssh + bottomDepth)/bottomDepth + do k = minLevelCell, maxLevelCell + restingThicknessSum = restingThicknessSum + restingThickness(k) + end do + layerStretch = (ssh + bottomDepth)/restingThicknessSum do k = minLevelCell, maxLevelCell layerThickness(k) = layerStretch * restingThickness(k) end do