Skip to content

Commit

Permalink
Set target diagnostic grid based on boolean
Browse files Browse the repository at this point in the history
The target grid for the diagnostic grid update is now based on a
assigning a differrent pointer based on the boolean input argument
'intensive'. This is done so that this update is done in a more
'object-oriented' way
  • Loading branch information
Andrew Shao committed Mar 11, 2020
1 parent 988f8f2 commit 9abcb10
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/framework/MOM_diag_mediator.F90
Original file line number Diff line number Diff line change
Expand Up @@ -3250,13 +3250,13 @@ subroutine diag_update_remap_grids(diag_cs, alt_h, alt_T, alt_S, update_intensiv
if (update_intensive_local) then
do i=1, diag_cs%num_diag_coords
call diag_remap_update(diag_cs%diag_remap_cs(i), diag_cs%G, diag_cs%GV, diag_cs%US, h_diag, T_diag, S_diag, &
diag_cs%eqn_of_state, diag_cs%diag_remap_cs(i)%h)
diag_cs%eqn_of_state, intensive=.true.)
enddo
endif
if (update_extensive_local) then
do i=1, diag_cs%num_diag_coords
call diag_remap_update(diag_cs%diag_remap_cs(i), diag_cs%G, diag_cs%GV, diag_cs%US, h_diag, T_diag, S_diag, &
diag_cs%eqn_of_state, diag_cs%diag_remap_cs(i)%h_extensive)
diag_cs%eqn_of_state, intensive=.false.)
enddo
endif

Expand Down
12 changes: 10 additions & 2 deletions src/framework/MOM_diag_remap.F90
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ function diag_remap_axes_configured(remap_cs)
!! height or layer thicknesses changes. In the case of density-based
!! coordinates then technically we should also regenerate the
!! target grid whenever T/S change.
subroutine diag_remap_update(remap_cs, G, GV, US, h, T, S, eqn_of_state, h_target)
subroutine diag_remap_update(remap_cs, G, GV, US, h, T, S, eqn_of_state, intensive)
type(diag_remap_ctrl), intent(inout) :: remap_cs !< Diagnostic coordinate control structure
type(ocean_grid_type), pointer :: G !< The ocean's grid type
type(verticalGrid_type), intent(in ) :: GV !< ocean vertical grid structure
Expand All @@ -281,7 +281,9 @@ subroutine diag_remap_update(remap_cs, G, GV, US, h, T, S, eqn_of_state, h_targe
real, dimension(:, :, :), intent(in ) :: T !< Temperatures used to construct new diagnostic grid
real, dimension(:, :, :), intent(in ) :: S !< Salinity used to construct new diagnostic grid
type(EOS_type), pointer :: eqn_of_state !< A pointer to the equation of state
real, dimension(:, :, :), intent(inout) :: h_target !< Where to store the new diagnostic array
logical, intent(in ) :: intensive !< If true, update the intensive diagnostic array

real, dimension(:,:,:), pointer :: h_target !< Where to store the new diagnostic array

! Local variables
real, dimension(remap_cs%nz + 1) :: zInterfaces
Expand Down Expand Up @@ -312,6 +314,12 @@ subroutine diag_remap_update(remap_cs, G, GV, US, h, T, S, eqn_of_state, h_targe
remap_cs%initialized = .true.
endif

if (intensive) then
h_target => remap_cs%h
else
h_target => reamp_cs%h_extensive
endif

! Calculate remapping thicknesses for different target grids based on
! nominal/target interface locations. This happens for every call on the
! assumption that h, T, S has changed.
Expand Down

0 comments on commit 9abcb10

Please sign in to comment.