forked from E3SM-Project/E3SM
-
Notifications
You must be signed in to change notification settings - Fork 4
Do not update MPAS masks during advection #115
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
Merged
matthewhoffman
merged 3 commits into
MALI-Dev:develop
from
trhille:mali/remove_mask_updates_in_RK_loop
Aug 26, 2024
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -193,6 +193,8 @@ subroutine li_advection_thickness_tracers(& | |
|
|
||
| type (field1DInteger), pointer :: & | ||
| cellMaskTemporaryField, & ! scratch field containing old values of cellMask | ||
| edgeMaskTemporaryField, & | ||
| vertexMaskTemporaryField, & | ||
| thermalCellMaskField | ||
|
|
||
| ! Allocatable arrays need for flux-corrected transport advection | ||
|
|
@@ -201,6 +203,7 @@ subroutine li_advection_thickness_tracers(& | |
| integer, dimension(:), pointer :: & | ||
| cellMask, & ! integer bitmask for cells | ||
| edgeMask, & ! integer bitmask for edges | ||
| vertexMask, & | ||
| thermalCellMask | ||
|
|
||
| integer, dimension(:,:), pointer :: cellsOnEdge | ||
|
|
@@ -290,6 +293,7 @@ subroutine li_advection_thickness_tracers(& | |
| call mpas_pool_get_array(geometryPool, 'layerThicknessEdge', layerThicknessEdge) | ||
| call mpas_pool_get_array(geometryPool, 'cellMask', cellMask) | ||
| call mpas_pool_get_array(geometryPool, 'edgeMask', edgeMask) | ||
| call mpas_pool_get_array(geometryPool, 'vertexMask', vertexMask, timeLevel=1) | ||
| call mpas_pool_get_array(geometryPool, 'dynamicThickening', dynamicThickening) | ||
| call mpas_pool_get_array(geometryPool, 'groundedToFloatingThickness', groundedToFloatingThickness) | ||
|
|
||
|
|
@@ -356,6 +360,12 @@ subroutine li_advection_thickness_tracers(& | |
| call mpas_pool_get_field(geometryPool, 'cellMaskTemporary', cellMaskTemporaryField) | ||
| call mpas_allocate_scratch_field(cellMaskTemporaryField, .true.) | ||
|
|
||
| call mpas_pool_get_field(geometryPool, 'edgeMaskTemporary', edgeMaskTemporaryField) | ||
| call mpas_allocate_scratch_field(edgeMaskTemporaryField, .true.) | ||
|
|
||
| call mpas_pool_get_field(geometryPool, 'vertexMaskTemporary', vertexMaskTemporaryField) | ||
| call mpas_allocate_scratch_field(vertexMaskTemporaryField, .true.) | ||
|
|
||
| call mpas_pool_get_field(scratchPool, 'iceCellMask', thermalCellMaskField) | ||
| call mpas_allocate_scratch_field(thermalCellMaskField, .true.) | ||
| thermalCellMask => thermalCellMaskField % array | ||
|
|
@@ -366,12 +376,14 @@ subroutine li_advection_thickness_tracers(& | |
| ! given the old thickness, compute the thickness in each layer | ||
| call li_calculate_layerThickness(meshPool, thickness, layerThickness) | ||
|
|
||
| ! update masks | ||
| call li_calculate_mask(meshPool, velocityPool, geometryPool, err_tmp) | ||
| err = ior(err, err_tmp) | ||
|
|
||
| ! save old copycellMask for determining cells changing from grounded to floating and vice versa | ||
| ! Save copies of masks because we need to preserve mask | ||
| ! states prior to advection for accurate time integration. | ||
| ! A mask update is necessary to calculate grounding line flux, | ||
| ! after which we will reset the masks to their previous states. | ||
| cellMaskTemporaryField % array(:) = cellMask(:) | ||
| edgeMaskTemporaryField % array(:) = edgeMask(:) | ||
| vertexMaskTemporaryField % array(:) = vertexMask(:) | ||
|
|
||
| layerThicknessEdgeFlux(:,:) = 0.0_RKIND | ||
|
|
||
| !----------------------------------------------------------------- | ||
|
|
@@ -540,10 +552,10 @@ subroutine li_advection_thickness_tracers(& | |
| dynamicThickening = (sum(layerThickness, 1) - thickness) / dt * scyr ! units of m/yr | ||
|
|
||
|
|
||
| ! Update the thickness and cellMask before applying the mass balance. | ||
| ! The update is needed because the SMB and BMB depend on whether ice is present. | ||
| ! Update the thickness before applying the mass balance, but | ||
| ! do not update masks because mass balance acts on geometry | ||
| ! before advection took place. | ||
| thickness = sum(layerThickness, 1) | ||
| call li_calculate_mask(meshPool, velocityPool, geometryPool, err_tmp) | ||
|
|
||
|
|
||
|
|
||
|
|
@@ -627,6 +639,9 @@ subroutine li_advection_thickness_tracers(& | |
| enddo | ||
| endif | ||
|
|
||
| ! We need an updated set of masks to calculate fluxAcrossGroundingLine, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why the flux at the grounding line is calculated at each stage? Also, if I understand correctly at this point the thickness is not consistent with the velocity. Wouldn't be better to move the calculation of the GL flux outside of this function? |
||
| ! but we will reset this to the previous state below for accuracy of the | ||
| ! time integration scheme. | ||
| call li_calculate_mask(meshPool, velocityPool, geometryPool, err_tmp) | ||
| err = ior(err, err_tmp) | ||
|
|
||
|
|
@@ -667,12 +682,17 @@ subroutine li_advection_thickness_tracers(& | |
| endif | ||
| enddo ! edges | ||
|
|
||
| ! Reset masks to state before advection and mass balance for | ||
| ! accuracy of time integration scheme. | ||
| cellMask(:) = cellMaskTemporaryField % array(:) | ||
| edgeMask(:) = edgeMaskTemporaryField % array(:) | ||
| vertexMask(:) = vertexMaskTemporaryField % array(:) | ||
|
|
||
| ! Remap tracers to the standard vertical sigma coordinate | ||
| ! Note: If tracers are not being advected, then this subroutine simply restores the | ||
| ! layer thickness to sigma coordinate values. | ||
|
|
||
| call vertical_remap(thickness, cellMask, meshPool, layerThickness, advectedTracers, err_tmp) | ||
| call vertical_remap(thickness, meshPool, layerThickness, advectedTracers, err_tmp) | ||
| err = ior(err, err_tmp) | ||
|
|
||
| if (config_print_thickness_advection_info) then | ||
|
|
@@ -727,6 +747,8 @@ subroutine li_advection_thickness_tracers(& | |
| call mpas_deallocate_scratch_field(basalTracersField, .true.) | ||
| call mpas_deallocate_scratch_field(surfaceTracersField, .true.) | ||
| call mpas_deallocate_scratch_field(cellMaskTemporaryField, .true.) | ||
| call mpas_deallocate_scratch_field(edgeMaskTemporaryField, .true.) | ||
| call mpas_deallocate_scratch_field(vertexMaskTemporaryField, .true.) | ||
| call mpas_deallocate_scratch_field(thermalCellMaskField, .true.) | ||
|
|
||
| ! === error check | ||
|
|
@@ -1939,7 +1961,7 @@ end subroutine li_layer_normal_velocity | |
| !> OpenMP over either blocks or cells. | ||
| ! | ||
| !----------------------------------------------------------------------- | ||
| subroutine vertical_remap(thickness, cellMask, meshPool, layerThickness, tracers, err) | ||
| subroutine vertical_remap(thickness, meshPool, layerThickness, tracers, err) | ||
|
|
||
| !----------------------------------------------------------------- | ||
| ! | ||
|
|
@@ -1953,9 +1975,6 @@ subroutine vertical_remap(thickness, cellMask, meshPool, layerThickness, tracers | |
| real(kind=RKIND), dimension(:), intent(in) :: & | ||
| thickness !< Input: ice thickness | ||
|
|
||
| integer, dimension(:), intent(in) :: & | ||
| cellMask !< Input: mask for cells (needed for determining presence/absence of ice) | ||
|
|
||
| !----------------------------------------------------------------- | ||
| ! | ||
| ! input/output variables | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.