Skip to content

Commit

Permalink
Fix bug in LBM diagnostics and add diags
Browse files Browse the repository at this point in the history
- uFlx_bulk was being defined on the T-grid even though it's on the U-grid
- add Vertically integrated quantities for the uFlx, vFlx
  • Loading branch information
gustavo-marques committed Sep 23, 2019
1 parent 73d0d78 commit 66a8f0a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/tracer/MOM_lateral_boundary_mixing.F90
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,11 @@ subroutine lateral_boundary_mixing(G, GV, US, h, Coef_x, Coef_y, dt, Reg, CS)
real, dimension(SZI_(G),SZJ_(G),SZK_(G),2) :: ppoly0_E !< Edge values from reconstructions
real, dimension(SZK_(G),CS%deg+1) :: ppoly_S !< Slopes from reconstruction (placeholder)
real, dimension(SZIB_(G),SZJ_(G),SZK_(G)) :: uFlx ! Zonal flux of tracer [H conc ~> m conc or conc kg m-2]
real, dimension(SZI_(G),SZJ_(G)) :: uFLx_bulk ! Total calculated bulk-layer u-flux for the tracer
real, dimension(SZIB_(G),SZJ_(G)) :: uFLx_bulk ! Total calculated bulk-layer u-flux for the tracer
real, dimension(SZI_(G),SZJB_(G),SZK_(G)) :: vFlx ! Meridional flux of tracer
real, dimension(SZI_(G),SZJB_(G)) :: vFlx_bulk ! Total calculated bulk-layer v-flux for the tracer
real, dimension(SZIB_(G),SZJ_(G)) :: uwork_2d ! Layer summed u-flux transport
real, dimension(SZI_(G),SZJB_(G)) :: vwork_2d ! Layer summed v-flux transport
type(tracer_type), pointer :: Tracer => NULL() ! Pointer to the current tracer
integer :: remap_method !< Reconstruction method
integer :: i,j,k,m
Expand Down Expand Up @@ -215,7 +217,21 @@ subroutine lateral_boundary_mixing(G, GV, US, h, Coef_x, Coef_y, dt, Reg, CS)
! Post the tracer diagnostics
if (tracer%id_lbm_dfx>0) call post_data(tracer%id_lbm_dfx, uFlx, CS%diag)
if (tracer%id_lbm_dfy>0) call post_data(tracer%id_lbm_dfy, vFlx, CS%diag)
if (tracer%id_lbm_dfx_2d>0) then
uwork_2d(:,:) = 0.
do k=1,GV%ke; do j=G%jsc,G%jec; do I=G%isc-1,G%iec
uwork_2d(I,j) = uwork_2d(I,j) + uFlx(I,j,k)
enddo; enddo; enddo
endif
call post_data(tracer%id_lbm_dfx_2d, uwork_2d, CS%diag)

if (tracer%id_lbm_dfy_2d>0) then
vwork_2d(:,:) = 0.
do k=1,GV%ke; do J=G%jsc-1,G%jec; do i=G%isc,G%iec
vwork_2d(i,J) = vwork_2d(i,J) + vFlx(i,J,k)
enddo; enddo; enddo
endif
call post_data(tracer%id_lbm_dfy_2d, vwork_2d, CS%diag)
enddo

end subroutine lateral_boundary_mixing
Expand Down
21 changes: 21 additions & 0 deletions src/tracer/MOM_tracer_registry.F90
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ module MOM_tracer_registry
!! [conc H m2 s-1 ~> conc m3 s-1 or conc kg s-1]
real, dimension(:,:,:), pointer :: lbm_df_y => NULL() !< diagnostic array for y-diffusive tracer flux
!! [conc H m2 s-1 ~> conc m3 s-1 or conc kg s-1]
real, dimension(:,:), pointer :: lbm_df_x_2d => NULL() !< diagnostic array for x-diffusive tracer flux
!! [conc H m2 s-1 ~> conc m3 s-1 or conc kg s-1]
real, dimension(:,:), pointer :: lbm_df_y_2d => NULL() !< diagnostic array for y-diffusive tracer flux
!! [conc H m2 s-1 ~> conc m3 s-1 or conc kg s-1]
real, dimension(:,:), pointer :: lbm_bulk_df_x => NULL() !< diagnostic array for x-diffusive tracer flux
!! [conc H m2 s-1 ~> conc m3 s-1 or conc kg s-1]
real, dimension(:,:), pointer :: lbm_bulk_df_y => NULL() !< diagnostic array for y-diffusive tracer flux
Expand Down Expand Up @@ -118,6 +122,7 @@ module MOM_tracer_registry
integer :: id_tr = -1
integer :: id_adx = -1, id_ady = -1, id_dfx = -1, id_dfy = -1
integer :: id_lbm_bulk_dfx = -1, id_lbm_bulk_dfy = -1, id_lbm_dfx = -1, id_lbm_dfy = -1
integer :: id_lbm_dfx_2d, id_lbm_dfy_2d
integer :: id_adx_2d = -1, id_ady_2d = -1, id_dfx_2d = -1, id_dfy_2d = -1
integer :: id_adv_xy = -1, id_adv_xy_2d = -1
integer :: id_dfxy_cont = -1, id_dfxy_cont_2d = -1, id_dfxy_conc = -1
Expand Down Expand Up @@ -415,6 +420,14 @@ subroutine register_tracer_diagnostics(Reg, h, Time, diag, G, GV, use_ALE)
Tr%id_lbm_dfy = register_diag_field("ocean_model", trim(shortnm)//"_lbm_dfy", &
diag%axesCvL, Time, trim(flux_longname)//" diffusive meridional flux from the near-boundary mixing scheme" , &
trim(flux_units), v_extensive = .true., x_cell_method = 'sum')
Tr%id_lbm_dfx_2d = register_diag_field("ocean_model", trim(shortnm)//"_lbm_dfx_2d", &
diag%axesCu1, Time, trim(flux_longname)//&
" diffusive zonal flux from the near-boundary mixing scheme vertically integrated" , &
trim(flux_units), v_extensive = .true., y_cell_method = 'sum')
Tr%id_lbm_dfy_2d = register_diag_field("ocean_model", trim(shortnm)//"_lbm_dfy_2d", &
diag%axesCv1, Time, trim(flux_longname)//&
" diffusive meridional flux from the near-boundary mixing scheme vertically integrated" , &
trim(flux_units), v_extensive = .true., x_cell_method = 'sum')
else
Tr%id_adx = register_diag_field("ocean_model", trim(shortnm)//"_adx", &
diag%axesCuL, Time, "Advective (by residual mean) Zonal Flux of "//trim(flux_longname), &
Expand All @@ -434,13 +447,21 @@ subroutine register_tracer_diagnostics(Reg, h, Time, diag, G, GV, use_ALE)
Tr%id_lbm_dfy = register_diag_field("ocean_model", trim(shortnm)//"_lbm_diffy", &
diag%axesCvL, Time, "Boundary Diffusive Meridional Flux of "//trim(flux_longname), &
flux_units, v_extensive=.true., conversion=Tr%flux_scale, x_cell_method = 'sum')
Tr%id_lbm_dfx_2d = register_diag_field("ocean_model", trim(shortnm)//"_lbm_diffx_2d", &
diag%axesCu1, Time, "Vertically integrated Boundary Diffusive Zonal Flux of "//trim(flux_longname), &
flux_units, v_extensive=.true., conversion=Tr%flux_scale, y_cell_method = 'sum')
Tr%id_lbm_dfy_2d = register_diag_field("ocean_model", trim(shortnm)//"_lbm_diffy_2d", &
diag%axesCv1, Time, "Vertically integrated Boundary Diffusive Meridional Flux of "//trim(flux_longname), &
flux_units, v_extensive=.true., conversion=Tr%flux_scale, x_cell_method = 'sum')
endif
if (Tr%id_adx > 0) call safe_alloc_ptr(Tr%ad_x,IsdB,IedB,jsd,jed,nz)
if (Tr%id_ady > 0) call safe_alloc_ptr(Tr%ad_y,isd,ied,JsdB,JedB,nz)
if (Tr%id_dfx > 0) call safe_alloc_ptr(Tr%df_x,IsdB,IedB,jsd,jed,nz)
if (Tr%id_dfy > 0) call safe_alloc_ptr(Tr%df_y,isd,ied,JsdB,JedB,nz)
if (Tr%id_lbm_dfx > 0) call safe_alloc_ptr(Tr%lbm_df_x,IsdB,IedB,jsd,jed,nz)
if (Tr%id_lbm_dfy > 0) call safe_alloc_ptr(Tr%lbm_df_y,isd,ied,JsdB,JedB,nz)
if (Tr%id_lbm_dfx_2d > 0) call safe_alloc_ptr(Tr%lbm_df_x_2d,IsdB,IedB,jsd,jed)
if (Tr%id_lbm_dfy_2d > 0) call safe_alloc_ptr(Tr%lbm_df_y_2d,isd,ied,JsdB,JedB)

Tr%id_adx_2d = register_diag_field("ocean_model", trim(shortnm)//"_adx_2d", &
diag%axesCu1, Time, &
Expand Down

0 comments on commit 66a8f0a

Please sign in to comment.