Skip to content

Commit

Permalink
Merge branch 'xylar/ocn/fix-high-freq-output-layer-index' (PR #6497)
Browse files Browse the repository at this point in the history
Fix indexing of layers in high freq. output

Previously, the layer above the one containing the desired depth was
being selected, rather than the layer containing the depth.

The default depth if no layer is found is now the deepest layer, rather
than the first layer. This is because, if no layer is found, it means
that even the deepest layer is shallower than the desired depth, and the
only sensible default is the deepest layer.

Fixes #6496

[non-BFB] only for MPAS-Ocean high-frequency output
  • Loading branch information
jonbob committed Oct 22, 2024
2 parents 812c88c + 266a8e8 commit 1f51259
Showing 1 changed file with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ subroutine ocn_compute_high_frequency_output(domain, timeLevel, err)!{{{
type (mpas_pool_type), pointer :: highFrequencyOutputAMPool
type (mpas_pool_type), pointer :: tracersPool

integer :: iLevel, iLevelTarget, iCell, iEdge, i, cell1, cell2, k, eoe
integer :: iLevel, iCell, iEdge, i, cell1, cell2, k, eoe
integer :: iLevel0100, iLevel0250, iLevel0700, iLevel2000
real (kind=RKIND) :: sumLayerThickness
integer, pointer :: nVertLevels, nCells, nEdges
Expand Down Expand Up @@ -377,37 +377,41 @@ subroutine ocn_compute_high_frequency_output(domain, timeLevel, err)!{{{
call mpas_pool_get_array(highFrequencyOutputAMPool, 'columnIntegratedSpeed', columnIntegratedSpeed)

! find vertical level that is just above the 100 m reference level
iLevel0100 = 1
do iLevel=2,nVertLevels
! if even the bottom level isn't deep enough, we still default to the bottom level
iLevel0100 = nVertLevels
do iLevel=1,nVertLevels
if(refBottomDepth(iLevel) > 100.0_RKIND) then
iLevel0100 = iLevel-1
iLevel0100 = iLevel
exit
endif
enddo
! find vertical level that is just above the 250 m reference level
iLevel0250 = 1
! if even the bottom level isn't deep enough, we still default to the bottom level
iLevel0250 = nVertLevels
do iLevel=iLevel0100,nVertLevels
if(refBottomDepth(iLevel) > 250.0_RKIND) then
iLevel0250 = iLevel-1
iLevel0250 = iLevel
exit
endif
enddo

! find vertical level that is just above the 700 m reference level
iLevel0700 = 1
! if even the bottom level isn't deep enough, we still default to the bottom level
iLevel0700 = nVertLevels
do iLevel=iLevel0250,nVertLevels
if(refBottomDepth(iLevel) > 700.0_RKIND) then
iLevel0700 = iLevel-1
iLevel0700 = iLevel
exit
endif
enddo
! find vertical level that is just above the 2000 m reference level
iLevel2000 = 1
! if even the bottom level isn't deep enough, we still default to the bottom level
iLevel2000 = nVertLevels
do iLevel=iLevel0700,nVertLevels
if(refBottomDepth(iLevel) > 2000.0_RKIND) then
iLevel2000 = iLevel-1
iLevel2000 = iLevel
exit
endif
enddo
Expand Down

0 comments on commit 1f51259

Please sign in to comment.