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

Fix layerNormalVelocity bug in Runge-Kutta loop #130

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
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 @@ -1045,6 +1045,11 @@ subroutine advection_solver(domain, err)
real (kind=RKIND), dimension(:), pointer :: thicknessNew
real (kind=RKIND), dimension(:), pointer :: thickness
real (kind=RKIND), dimension(:,:), pointer :: layerThickness
real (kind=RKIND), dimension(:,:), pointer :: normalVelocity
real (kind=RKIND), dimension(:,:), pointer :: layerNormalVelocity

integer, dimension(:), pointer :: edgeMask
real (kind=RKIND) :: allowableDtACFL

real (kind=RKIND), dimension(:,:), pointer :: temperature
real (kind=RKIND), dimension(:,:), pointer :: waterFrac
Expand Down Expand Up @@ -1094,6 +1099,18 @@ subroutine advection_solver(domain, err)
call mpas_pool_get_subpool(block % structs, 'mesh', meshPool)
call mpas_pool_get_subpool(block % structs, 'velocity', velocityPool)
call mpas_pool_get_subpool(block % structs, 'geometry', geometryPool)
call mpas_pool_get_array(velocityPool, 'normalVelocity', normalVelocity)
call mpas_pool_get_array(geometryPool, 'edgeMask', edgeMask)
call mpas_pool_get_array(velocityPool, 'layerNormalVelocity', layerNormalVelocity)

call li_layer_normal_velocity( &
meshPool, &
normalVelocity, &
edgeMask, &
layerNormalVelocity, &
allowableDtACFL, &
err_tmp)
err = ior(err,err_tmp)

call calculate_layerThicknessEdge(meshPool, geometryPool, velocityPool, err_tmp)
err = ior(err,err_tmp)
Expand Down Expand Up @@ -1458,7 +1475,7 @@ subroutine calculate_layerThicknessEdge(meshPool, geometryPool, velocityPool, er
! local variables
!-----------------------------------------------------------------
real (kind=RKIND), dimension(:), pointer :: thickness
real (kind=RKIND), dimension(:,:), pointer :: layerThickness, layerThicknessEdge, normalVelocity
real (kind=RKIND), dimension(:,:), pointer :: layerThickness, layerThicknessEdge, layerNormalVelocity
integer, dimension(:,:), pointer :: cellsOnEdge
integer, pointer :: nEdges, nVertLevels
integer :: iEdge, cell1, cell2, k
Expand All @@ -1472,7 +1489,7 @@ subroutine calculate_layerThicknessEdge(meshPool, geometryPool, velocityPool, er
call mpas_pool_get_array(geometryPool, 'thickness', thickness, timeLevel = 1)
call mpas_pool_get_array(geometryPool, 'layerThickness', layerThickness, timeLevel = 1)
call mpas_pool_get_array(geometryPool, 'layerThicknessEdge', layerThicknessEdge)
call mpas_pool_get_array(velocityPool, 'normalVelocity', normalVelocity)
call mpas_pool_get_array(velocityPool, 'layerNormalVelocity', layerNormalVelocity)

! Note: SIA velocity solver uses its own local calculation of h_edge that is always 2nd order.
! Note: ocn_diagnostic_solve in mpas_ocn_tendency.F has 2, 3, & 4th order calculations for h_edge that can be used.
Expand All @@ -1486,7 +1503,7 @@ subroutine calculate_layerThicknessEdge(meshPool, geometryPool, velocityPool, er
cell2 = cellsOnEdge(2,iEdge)
do k=1, nVertLevels
! Calculate h on edges using first order
VelSign = sign(1.0_RKIND, normalVelocity(k, iEdge))
VelSign = sign(1.0_RKIND, layerNormalVelocity(k, iEdge))
layerThicknessEdge(k,iEdge) = max(VelSign * layerThickness(k, cell1), &
VelSign * (-1.0_RKIND) * layerThickness(k, cell2))
! + velocity goes from index 1 to 2 in the cellsOnEdge array.
Expand Down