From 44fb28c7449a068ed4c70b55b59eb1f86f185b98 Mon Sep 17 00:00:00 2001 From: Andrew Ross <5852283+andrew-c-ross@users.noreply.github.com> Date: Wed, 17 Jul 2024 16:21:22 -0400 Subject: [PATCH 01/11] Apply changes for BGC budgets # Conflicts: # src/tracer/MOM_generic_tracer.F90 # src/tracer/MOM_tracer_registry.F90 --- src/tracer/MOM_generic_tracer.F90 | 14 ++++++ src/tracer/MOM_tracer_advect.F90 | 69 ++++++++++++++++++++++++++++++ src/tracer/MOM_tracer_hor_diff.F90 | 12 ++++++ src/tracer/MOM_tracer_registry.F90 | 48 ++++++++++++++++++++- src/tracer/MOM_tracer_types.F90 | 7 +++ 5 files changed, 148 insertions(+), 2 deletions(-) diff --git a/src/tracer/MOM_generic_tracer.F90 b/src/tracer/MOM_generic_tracer.F90 index 77d6777b61..8428f1457e 100644 --- a/src/tracer/MOM_generic_tracer.F90 +++ b/src/tracer/MOM_generic_tracer.F90 @@ -601,9 +601,23 @@ subroutine MOM_generic_tracer_column_physics(h_old, h_new, ea, eb, fluxes, Hml, if (g_tracer_is_prog(g_tracer)) then do k=1,nk ;do j=jsc,jec ; do i=isc,iec h_work(i,j,k) = h_old(i,j,k) + !liao + g_tracer%boundary_forcing_tend(i,j,k) = 0 + if (g_tracer%diag_id_boundary_forcing_tend .gt. 0) then + g_tracer%boundary_forcing_tend(i,j,k) = g_tracer%field(i,j,k,1) + endif + !liao enddo ; enddo ; enddo call applyTracerBoundaryFluxesInOut(G, GV, g_tracer%field(:,:,:,1), dt, & fluxes, h_work, evap_CFL_limit, minimum_forcing_depth) + !liao + if (g_tracer%diag_id_boundary_forcing_tend .gt. 0) then + do k=1,nk ;do j=jsc,jec ; do i=isc,iec + g_tracer%boundary_forcing_tend(i,j,k)=G%mask2dT(i,j)*(g_tracer%field(i,j,k,1) & + - g_tracer%boundary_forcing_tend(i,j,k))/dt + enddo ; enddo ; enddo + endif + !liao endif !traverse the linked list till hit NULL diff --git a/src/tracer/MOM_tracer_advect.F90 b/src/tracer/MOM_tracer_advect.F90 index b77949342d..8d7effa00e 100644 --- a/src/tracer/MOM_tracer_advect.F90 +++ b/src/tracer/MOM_tracer_advect.F90 @@ -187,9 +187,50 @@ subroutine advect_tracer(h_end, uhtr, vhtr, OBC, dt, G, GV, US, CS, Reg, x_first ! initialize diagnostic fluxes and tendencies !$OMP do do m=1,ntr +! if (associated(Tr(m)%ad_x)) then +! do k=1,nz ; do j=jsd,jed ; do i=isd,ied +! Tr(m)%ad_x(I,j,k) = 0.0 +! enddo ; enddo ; enddo +! endif +! if (associated(Tr(m)%ad_y)) then +! do k=1,nz ; do J=jsd,jed ; do i=isd,ied +! Tr(m)%ad_y(i,J,k) = 0.0 +! enddo ; enddo ; enddo +! endif +! if (associated(Tr(m)%advection_xy)) then +! do k=1,nz ; do j=jsd,jed ; do i=isd,ied +! Tr(m)%advection_xy(i,j,k) = 0.0 +! enddo ; enddo ; enddo +! endif +! !liao +! if (associated(Tr(m)%advectionc_xy)) then +! do k=1,nz ; do j=jsd,jed ; do i=isd,ied +! Tr(m)%advectionc_xy(i,j,k) = 0.0 +! enddo ; enddo ; enddo +! endif +! if (associated(Tr(m)%advectionc_x)) then +! do k=1,nz ; do j=jsd,jed ; do i=isd,ied +! Tr(m)%advectionc_x(i,j,k) = 0.0 +! enddo ; enddo ; enddo +! endif +! if (associated(Tr(m)%advectionc_y)) then +! do k=1,nz ; do j=jsd,jed ; do i=isd,ied +! Tr(m)%advectionc_y(i,j,k) = 0.0 +! enddo ; enddo ; enddo +! endif +! !liao +! if (associated(Tr(m)%ad2d_x)) then +! do j=jsd,jed ; do i=isd,ied ; Tr(m)%ad2d_x(I,j) = 0.0 ; enddo ; enddo +! endif +! if (associated(Tr(m)%ad2d_y)) then +! do J=jsd,jed ; do i=isd,ied ; Tr(m)%ad2d_y(i,J) = 0.0 ; enddo ; enddo +! endif if (associated(Reg%Tr(m)%ad_x)) Reg%Tr(m)%ad_x(:,:,:) = 0.0 if (associated(Reg%Tr(m)%ad_y)) Reg%Tr(m)%ad_y(:,:,:) = 0.0 if (associated(Reg%Tr(m)%advection_xy)) Reg%Tr(m)%advection_xy(:,:,:) = 0.0 + if (associated(Reg%Tr(m)%advectionc_xy)) Reg%Tr(m)%advectionc_xy(:,:,:) = 0.0 + if (associated(Reg%Tr(m)%advectionc_x)) Reg%Tr(m)%advectionc_x(:,:,:) = 0.0 + if (associated(Reg%Tr(m)%advectionc_y)) Reg%Tr(m)%advectionc_y(:,:,:) = 0.0 if (associated(Reg%Tr(m)%ad2d_x)) Reg%Tr(m)%ad2d_x(:,:) = 0.0 if (associated(Reg%Tr(m)%ad2d_y)) Reg%Tr(m)%ad2d_y(:,:) = 0.0 enddo @@ -362,6 +403,7 @@ subroutine advect_x(Tr, hprev, uhr, uh_neglect, OBC, domore_u, ntr, Idt, & ! the grid box, both in [H L2 ~> m3 or kg]. real :: uhh(SZIB_(G)) ! The zonal flux that occurs during the ! current iteration [H L2 ~> m3 or kg]. + real, dimension(SZIB_(G)) :: tprev !< tracer conc at the end of !liao real, dimension(SZIB_(G)) :: & hlst, & ! Work variable [H L2 ~> m3 or kg]. Ihnew, & ! Work variable [H-1 L-2 ~> m-3 or kg-1]. @@ -652,6 +694,7 @@ subroutine advect_x(Tr, hprev, uhr, uh_neglect, OBC, domore_u, ntr, Idt, & do i=is,ie if (do_i(i,j)) then if (Ihnew(i) > 0.0) then + tprev(i)=Tr(m)%t(i,j,k) !liao Tr(m)%t(i,j,k) = (Tr(m)%t(i,j,k) * hlst(i) - & (flux_x(I,j,m) - flux_x(I-1,j,m))) * Ihnew(i) endif @@ -671,6 +714,18 @@ subroutine advect_x(Tr, hprev, uhr, uh_neglect, OBC, domore_u, ntr, Idt, & Idt * G%IareaT(i,j) endif ; enddo endif + !liao + if (associated(Tr(m)%advectionc_xy)) then + do i=is,ie ; if (do_i(i,j)) then + Tr(m)%advectionc_xy(i,j,k) = Tr(m)%advectionc_xy(i,j,k)+(Tr(m)%t(i,j,k) - tprev(i))*Idt*G%mask2dT(i,j) + endif ; enddo + endif + if (associated(Tr(m)%advectionc_x)) then + do i=is,ie ; if (do_i(i,j)) then + Tr(m)%advectionc_x(i,j,k) =(Tr(m)%t(i,j,k) - tprev(i))*Idt*G%mask2dT(i,j) + endif ; enddo + endif + !liao enddo @@ -733,6 +788,7 @@ subroutine advect_y(Tr, hprev, vhr, vh_neglect, OBC, domore_v, ntr, Idt, & T_tmp ! The copy of the tracer concentration at constant i,k [conc]. real :: vhh(SZI_(G),SZJB_(G)) ! The meridional flux that occurs during the ! current iteration [H L2 ~> m3 or kg]. + real, dimension(SZIB_(G)) :: tprev !< tracer conc at the end of !liao real :: hup, hlos ! hup is the upwind volume, hlos is the ! part of that volume that might be lost ! due to advection out the other side of @@ -1039,6 +1095,7 @@ subroutine advect_y(Tr, hprev, vhr, vh_neglect, OBC, domore_v, ntr, Idt, & ! update tracer and save some diagnostics do m=1,ntr do i=is,ie ; if (do_i(i,j)) then + tprev(i)=Tr(m)%t(i,j,k) !liao Tr(m)%t(i,j,k) = (Tr(m)%t(i,j,k) * hlst(i) - & (flux_y(i,m,J) - flux_y(i,m,J-1))) * Ihnew(i) endif ; enddo @@ -1051,6 +1108,18 @@ subroutine advect_y(Tr, hprev, vhr, vh_neglect, OBC, domore_v, ntr, Idt, & G%IareaT(i,j) endif ; enddo endif + !liao + if (associated(Tr(m)%advectionc_xy)) then + do i=is,ie ; if (do_i(i,j)) then + Tr(m)%advectionc_xy(i,j,k) = Tr(m)%advectionc_xy(i,j,k)+(Tr(m)%t(i,j,k) - tprev(i))*Idt*G%mask2dT(i,j) + endif ; enddo + endif + if (associated(Tr(m)%advectionc_y)) then + do i=is,ie ; if (do_i(i,j)) then + Tr(m)%advectionc_y(i,j,k) = (Tr(m)%t(i,j,k) - tprev(i))*Idt*G%mask2dT(i,j) + endif ; enddo + endif + !liao enddo endif ; enddo ! End of j-loop. diff --git a/src/tracer/MOM_tracer_hor_diff.F90 b/src/tracer/MOM_tracer_hor_diff.F90 index 5538e210da..2bcbcd3ebf 100644 --- a/src/tracer/MOM_tracer_hor_diff.F90 +++ b/src/tracer/MOM_tracer_hor_diff.F90 @@ -400,6 +400,13 @@ subroutine tracer_hordiff(h, dt, MEKE, VarMix, visc, G, GV, US, CS, Reg, tv, do_ if (associated(Reg%Tr(m)%df2d_y)) then do J=js-1,je ; do i=is,ie ; Reg%Tr(m)%df2d_y(i,J) = 0.0 ; enddo ; enddo endif + ! mpoupon + if (associated(Reg%Tr(m)%diffusionc_xy)) then + do k=1,nz ; do j=js,je ; do i=is,ie + Reg%Tr(m)%diffusionc_xy(i,j,k) = 0.0 + enddo ; enddo ; enddo + endif + ! mpoupon enddo if (CS%use_hor_bnd_diffusion) then @@ -569,6 +576,11 @@ subroutine tracer_hordiff(h, dt, MEKE, VarMix, visc, G, GV, US, CS, Reg, tv, do_ enddo ; enddo ; endif do j=js,je ; do i=is,ie Reg%Tr(m)%t(i,j,k) = Reg%Tr(m)%t(i,j,k) + dTr(i,j) + ! mpoupon + if (associated(Reg%Tr(m)%diffusionc_xy)) then + Reg%Tr(m)%diffusionc_xy(i,j,k) = dTr(i,j) * Idt + endif + ! mpoupon enddo ; enddo enddo diff --git a/src/tracer/MOM_tracer_registry.F90 b/src/tracer/MOM_tracer_registry.F90 index 835b93bb82..56b86bfbcc 100644 --- a/src/tracer/MOM_tracer_registry.F90 +++ b/src/tracer/MOM_tracer_registry.F90 @@ -53,6 +53,8 @@ subroutine register_tracer(tr_ptr, Reg, param_file, HI, GV, name, longname, unit cmor_name, cmor_units, cmor_longname, net_surfflux_name, NLT_budget_name, & net_surfflux_longname, tr_desc, OBC_inflow, OBC_in_u, OBC_in_v, ad_x, ad_y, & df_x, df_y, ad_2d_x, ad_2d_y, df_2d_x, df_2d_y, advection_xy, registry_diags, & + advectionc_xy, advectionc_x, advectionc_y, & !liao + diffusionc_xy, & ! mpoupon conc_scale, flux_nameroot, flux_longname, flux_units, flux_scale, & convergence_units, convergence_scale, cmor_tendprefix, diag_form, & restart_CS, mandatory, underflow_conc, Tr_out) @@ -100,6 +102,11 @@ subroutine register_tracer(tr_ptr, Reg, param_file, HI, GV, name, longname, unit real, dimension(:,:,:), optional, pointer :: advection_xy !< convergence of lateral advective tracer fluxes !! [CU H T-1 ~> conc m s-1 or conc kg m-2 s-1] + real, dimension(:,:,:), optional, pointer :: advectionc_xy !< convergence of lateral advection !liao + real, dimension(:,:,:), optional, pointer :: diffusionc_xy !< convergence of lateral diffusion !mpoupon + real, dimension(:,:,:), optional, pointer :: advectionc_x !< lateral advection concentration !liao + real, dimension(:,:,:), optional, pointer :: advectionc_y !< lateral advection concentration !liao + logical, optional, intent(in) :: registry_diags !< If present and true, use the registry for !! the diagnostics of this tracer. real, optional, intent(in) :: conc_scale !< A scaling factor used to convert the concentration @@ -245,6 +252,10 @@ subroutine register_tracer(tr_ptr, Reg, param_file, HI, GV, name, longname, unit if (present(df_2d_x)) then ; if (associated(df_2d_x)) Tr%df2d_x => df_2d_x ; endif if (present(advection_xy)) then ; if (associated(advection_xy)) Tr%advection_xy => advection_xy ; endif + if (present(advectionc_xy)) then; if (associated(advectionc_xy)) Tr%advectionc_xy => advectionc_xy ; endif !liao + if (present(diffusionc_xy)) then; if (associated(diffusionc_xy)) Tr%diffusionc_xy => diffusionc_xy ; endif !mpoupon + if (present(advectionc_x)) then; if (associated(advectionc_x)) Tr%advectionc_x => advectionc_x ; endif !liao + if (present(advectionc_y)) then; if (associated(advectionc_y)) Tr%advectionc_y => advectionc_y ; endif !liao if (present(restart_CS)) then ! Register this tracer to be read from and written to restart files. @@ -436,14 +447,43 @@ subroutine register_tracer_diagnostics(Reg, h, Time, diag, G, GV, US, use_ALE, u Tr%id_adv_xy = register_diag_field('ocean_model', trim(shortnm)//"_advection_xy", & diag%axesTL, Time, & - 'Horizontal convergence of residual mean advective fluxes of '//trim(lowercase(flux_longname)), & - conv_units, v_extensive=.true., conversion=Tr%conv_scale*US%s_to_T) + 'Horizontal convergence of residual mean advective fluxes of '//& + trim(lowercase(flux_longname)), conv_units, v_extensive=.true., & + conversion=Tr%conv_scale*US%s_to_T) + ! mpoupon + Tr%id_difc_xy = register_diag_field('ocean_model',trim(shortnm)//"_diffusionc_xy", & + diag%axesTL, Time, "Horizontal convergence of residual mean diffusive fluxes of "//trim(shortnm), & + trim(units)//' s-1') + ! mpoupon + !liao + Tr%id_advc_xy = register_diag_field('ocean_model',trim(shortnm)//"_advectionc_xy", & + diag%axesTL, Time, "Horizontal convergence of residual mean advective fluxes of "//trim(shortnm), & + trim(units)//' s-1') + Tr%id_advc_x = register_diag_field("ocean_model",trim(shortnm)//'_advectionc_x', & + diag%axesTL, Time, "Horizontal x mean advective fluxes of "//trim(shortnm), & + trim(units)//' s-1') + Tr%id_advc_y = register_diag_field("ocean_model",trim(shortnm)//'_advectionc_y', & + diag%axesTL, Time, "Horizontal y mean advective fluxes of "//trim(shortnm), & + trim(units)//' s-1') + !liao Tr%id_adv_xy_2d = register_diag_field('ocean_model', trim(shortnm)//"_advection_xy_2d", & diag%axesT1, Time, & 'Vertical sum of horizontal convergence of residual mean advective fluxes of '//& trim(lowercase(flux_longname)), conv_units, conversion=Tr%conv_scale*US%s_to_T) if ((Tr%id_adv_xy > 0) .or. (Tr%id_adv_xy_2d > 0)) & call safe_alloc_ptr(Tr%advection_xy,isd,ied,jsd,jed,nz) + !mpoupon + if (Tr%id_difc_xy > 0) & + call safe_alloc_ptr(Tr%diffusionc_xy,isd,ied,jsd,jed,nz) + !mpoupon + !liao + if (Tr%id_advc_xy > 0) & + call safe_alloc_ptr(Tr%advectionc_xy,isd,ied,jsd,jed,nz) + if (Tr%id_advc_x > 0) & + call safe_alloc_ptr(Tr%advectionc_x,isd,ied,jsd,jed,nz) + if (Tr%id_advc_y > 0) & + call safe_alloc_ptr(Tr%advectionc_y,isd,ied,jsd,jed,nz) + !liao Tr%id_tendency = register_diag_field('ocean_model', trim(shortnm)//'_tendency', & diag%axesTL, Time, & @@ -739,6 +779,10 @@ subroutine post_tracer_transport_diagnostics(G, GV, Reg, h_diag, diag) if (Tr%id_dfx_2d > 0) call post_data(Tr%id_dfx_2d, Tr%df2d_x, diag) if (Tr%id_dfy_2d > 0) call post_data(Tr%id_dfy_2d, Tr%df2d_y, diag) if (Tr%id_adv_xy > 0) call post_data(Tr%id_adv_xy, Tr%advection_xy, diag, alt_h=h_diag) + if (Tr%id_advc_xy > 0) call post_data(Tr%id_advc_xy, Tr%advectionc_xy, diag, alt_h=h_diag) !liao + if (Tr%id_difc_xy > 0) call post_data(Tr%id_difc_xy, Tr%diffusionc_xy, diag, alt_h=h_diag) !mpoupon + if (Tr%id_advc_x > 0) call post_data(Tr%id_advc_x, Tr%advectionc_x, diag, alt_h=h_diag) !liao + if (Tr%id_advc_y > 0) call post_data(Tr%id_advc_y, Tr%advectionc_y, diag, alt_h=h_diag) !liao if (Tr%id_adv_xy_2d > 0) then work2d(:,:) = 0.0 do k=1,nz ; do j=js,je ; do i=is,ie diff --git a/src/tracer/MOM_tracer_types.F90 b/src/tracer/MOM_tracer_types.F90 index 861acedb75..2dcd3d98fc 100644 --- a/src/tracer/MOM_tracer_types.F90 +++ b/src/tracer/MOM_tracer_types.F90 @@ -48,6 +48,11 @@ module MOM_tracer_types real, dimension(:,:,:), pointer :: advection_xy => NULL() !< convergence of lateral advective tracer fluxes !! [CU H T-1 ~> conc m s-1 or conc kg m-2 s-1] + real, dimension(:,:,:), pointer :: advectionc_xy => NULL() !< convergence of lateral advection concentration liao + real, dimension(:,:,:), pointer :: diffusionc_xy => NULL() !< convergence of lateral diffusion concentration mpoupon + real, dimension(:,:,:), pointer :: advectionc_x => NULL() !< lateral advection concentration liao + real, dimension(:,:,:), pointer :: advectionc_y => NULL() !< lateral advection concentration liao + ! real, dimension(:,:,:), pointer :: diff_cont_xy => NULL() !< convergence of lateral diffusive tracer fluxes ! !! [CU H T-1 ~> conc m s-1 or conc kg m-2 s-1] ! real, dimension(:,:,:), pointer :: diff_conc_xy => NULL() !< convergence of lateral diffusive tracer fluxes @@ -108,6 +113,8 @@ module MOM_tracer_types integer :: id_hbd_dfx_2d = -1, id_hbd_dfy_2d = -1 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_advc_xy = -1, id_advc_x = -1, id_advc_y = -1 !liao + integer :: id_difc_xy = -1 ! mpoupon integer :: id_dfxy_cont = -1, id_dfxy_cont_2d = -1, id_dfxy_conc = -1 integer :: id_hbdxy_cont = -1, id_hbdxy_cont_2d = -1, id_hbdxy_conc = -1 integer :: id_remap_conc = -1, id_remap_cont = -1, id_remap_cont_2d = -1 From 0576a77574acb42659d87968c9f79dec6713aaa7 Mon Sep 17 00:00:00 2001 From: Andrew Ross <5852283+andrew-c-ross@users.noreply.github.com> Date: Wed, 17 Jul 2024 16:41:16 -0400 Subject: [PATCH 02/11] Updated budget code from Fan --- src/tracer/MOM_tracer_hor_diff.F90 | 9 +++++++++ src/tracer/MOM_tracer_registry.F90 | 10 +++++++++- src/tracer/MOM_tracer_types.F90 | 7 ++++--- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/tracer/MOM_tracer_hor_diff.F90 b/src/tracer/MOM_tracer_hor_diff.F90 index 2bcbcd3ebf..3fbc5746be 100644 --- a/src/tracer/MOM_tracer_hor_diff.F90 +++ b/src/tracer/MOM_tracer_hor_diff.F90 @@ -406,6 +406,12 @@ subroutine tracer_hordiff(h, dt, MEKE, VarMix, visc, G, GV, US, CS, Reg, tv, do_ Reg%Tr(m)%diffusionc_xy(i,j,k) = 0.0 enddo ; enddo ; enddo endif + + if (associated(Reg%Tr(m)%diffusion_xy)) then + do k=1,nz ; do j=js,je ; do i=is,ie + Reg%Tr(m)%diffusion_xy(i,j,k) = 0.0 + enddo ; enddo ; enddo + endif ! mpoupon enddo @@ -580,6 +586,9 @@ subroutine tracer_hordiff(h, dt, MEKE, VarMix, visc, G, GV, US, CS, Reg, tv, do_ if (associated(Reg%Tr(m)%diffusionc_xy)) then Reg%Tr(m)%diffusionc_xy(i,j,k) = dTr(i,j) * Idt endif + if (associated(Reg%Tr(m)%diffusion_xy)) then + Reg%Tr(m)%diffusion_xy(i,j,k) = dTr(i,j) * Idt * (h(i,j,k)+h_neglect) + endif ! mpoupon enddo ; enddo enddo diff --git a/src/tracer/MOM_tracer_registry.F90 b/src/tracer/MOM_tracer_registry.F90 index 56b86bfbcc..bffd163529 100644 --- a/src/tracer/MOM_tracer_registry.F90 +++ b/src/tracer/MOM_tracer_registry.F90 @@ -54,7 +54,7 @@ subroutine register_tracer(tr_ptr, Reg, param_file, HI, GV, name, longname, unit net_surfflux_longname, tr_desc, OBC_inflow, OBC_in_u, OBC_in_v, ad_x, ad_y, & df_x, df_y, ad_2d_x, ad_2d_y, df_2d_x, df_2d_y, advection_xy, registry_diags, & advectionc_xy, advectionc_x, advectionc_y, & !liao - diffusionc_xy, & ! mpoupon + diffusionc_xy, diffusion_xy, & ! mpoupon conc_scale, flux_nameroot, flux_longname, flux_units, flux_scale, & convergence_units, convergence_scale, cmor_tendprefix, diag_form, & restart_CS, mandatory, underflow_conc, Tr_out) @@ -104,6 +104,7 @@ subroutine register_tracer(tr_ptr, Reg, param_file, HI, GV, name, longname, unit !! [CU H T-1 ~> conc m s-1 or conc kg m-2 s-1] real, dimension(:,:,:), optional, pointer :: advectionc_xy !< convergence of lateral advection !liao real, dimension(:,:,:), optional, pointer :: diffusionc_xy !< convergence of lateral diffusion !mpoupon + real, dimension(:,:,:), optional, pointer :: diffusion_xy !< convergence of lateral diffusive tracer fluxes !mpoupon real, dimension(:,:,:), optional, pointer :: advectionc_x !< lateral advection concentration !liao real, dimension(:,:,:), optional, pointer :: advectionc_y !< lateral advection concentration !liao @@ -254,6 +255,7 @@ subroutine register_tracer(tr_ptr, Reg, param_file, HI, GV, name, longname, unit if (present(advection_xy)) then ; if (associated(advection_xy)) Tr%advection_xy => advection_xy ; endif if (present(advectionc_xy)) then; if (associated(advectionc_xy)) Tr%advectionc_xy => advectionc_xy ; endif !liao if (present(diffusionc_xy)) then; if (associated(diffusionc_xy)) Tr%diffusionc_xy => diffusionc_xy ; endif !mpoupon + if (present(diffusion_xy)) then; if (associated(diffusion_xy)) Tr%diffusion_xy => diffusion_xy ; endif !mpoupon if (present(advectionc_x)) then; if (associated(advectionc_x)) Tr%advectionc_x => advectionc_x ; endif !liao if (present(advectionc_y)) then; if (associated(advectionc_y)) Tr%advectionc_y => advectionc_y ; endif !liao @@ -454,6 +456,9 @@ subroutine register_tracer_diagnostics(Reg, h, Time, diag, G, GV, US, use_ALE, u Tr%id_difc_xy = register_diag_field('ocean_model',trim(shortnm)//"_diffusionc_xy", & diag%axesTL, Time, "Horizontal convergence of residual mean diffusive fluxes of "//trim(shortnm), & trim(units)//' s-1') + Tr%id_dif_xy = register_diag_field('ocean_model',trim(shortnm)//"_diffusion_xy", & + diag%axesTL, Time, "Horizontal convergence of residual mean diffusive fluxes of "//trim(shortnm), & + trim(units)//' s-1') ! mpoupon !liao Tr%id_advc_xy = register_diag_field('ocean_model',trim(shortnm)//"_advectionc_xy", & @@ -475,6 +480,8 @@ subroutine register_tracer_diagnostics(Reg, h, Time, diag, G, GV, US, use_ALE, u !mpoupon if (Tr%id_difc_xy > 0) & call safe_alloc_ptr(Tr%diffusionc_xy,isd,ied,jsd,jed,nz) + if (Tr%id_dif_xy > 0) & + call safe_alloc_ptr(Tr%diffusion_xy,isd,ied,jsd,jed,nz) !mpoupon !liao if (Tr%id_advc_xy > 0) & @@ -781,6 +788,7 @@ subroutine post_tracer_transport_diagnostics(G, GV, Reg, h_diag, diag) if (Tr%id_adv_xy > 0) call post_data(Tr%id_adv_xy, Tr%advection_xy, diag, alt_h=h_diag) if (Tr%id_advc_xy > 0) call post_data(Tr%id_advc_xy, Tr%advectionc_xy, diag, alt_h=h_diag) !liao if (Tr%id_difc_xy > 0) call post_data(Tr%id_difc_xy, Tr%diffusionc_xy, diag, alt_h=h_diag) !mpoupon + if (Tr%id_dif_xy > 0) call post_data(Tr%id_dif_xy, Tr%diffusion_xy, diag, alt_h=h_diag) !mpoupon if (Tr%id_advc_x > 0) call post_data(Tr%id_advc_x, Tr%advectionc_x, diag, alt_h=h_diag) !liao if (Tr%id_advc_y > 0) call post_data(Tr%id_advc_y, Tr%advectionc_y, diag, alt_h=h_diag) !liao if (Tr%id_adv_xy_2d > 0) then diff --git a/src/tracer/MOM_tracer_types.F90 b/src/tracer/MOM_tracer_types.F90 index 2dcd3d98fc..011b34b157 100644 --- a/src/tracer/MOM_tracer_types.F90 +++ b/src/tracer/MOM_tracer_types.F90 @@ -50,8 +50,9 @@ module MOM_tracer_types !! [CU H T-1 ~> conc m s-1 or conc kg m-2 s-1] real, dimension(:,:,:), pointer :: advectionc_xy => NULL() !< convergence of lateral advection concentration liao real, dimension(:,:,:), pointer :: diffusionc_xy => NULL() !< convergence of lateral diffusion concentration mpoupon - real, dimension(:,:,:), pointer :: advectionc_x => NULL() !< lateral advection concentration liao - real, dimension(:,:,:), pointer :: advectionc_y => NULL() !< lateral advection concentration liao + real, dimension(:,:,:), pointer :: diffusion_xy => NULL() !< convergence of lateral diffusion content mpoupon + real, dimension(:,:,:), pointer :: advectionc_x => NULL() !< lateral advection concentration liao + real, dimension(:,:,:), pointer :: advectionc_y => NULL() !< lateral advection concentration liao ! real, dimension(:,:,:), pointer :: diff_cont_xy => NULL() !< convergence of lateral diffusive tracer fluxes ! !! [CU H T-1 ~> conc m s-1 or conc kg m-2 s-1] @@ -114,7 +115,7 @@ module MOM_tracer_types 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_advc_xy = -1, id_advc_x = -1, id_advc_y = -1 !liao - integer :: id_difc_xy = -1 ! mpoupon + integer :: id_difc_xy = -1, id_dif_xy = -1 ! mpoupon integer :: id_dfxy_cont = -1, id_dfxy_cont_2d = -1, id_dfxy_conc = -1 integer :: id_hbdxy_cont = -1, id_hbdxy_cont_2d = -1, id_hbdxy_conc = -1 integer :: id_remap_conc = -1, id_remap_cont = -1, id_remap_cont_2d = -1 From fee66a72baa2fefa5c86a09e3da3abaff784a95f Mon Sep 17 00:00:00 2001 From: Andrew Ross <5852283+andrew-c-ross@users.noreply.github.com> Date: Wed, 17 Jul 2024 16:43:09 -0400 Subject: [PATCH 03/11] Enable built in diagnostics --- src/tracer/MOM_generic_tracer.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tracer/MOM_generic_tracer.F90 b/src/tracer/MOM_generic_tracer.F90 index 8428f1457e..15ed477f90 100644 --- a/src/tracer/MOM_generic_tracer.F90 +++ b/src/tracer/MOM_generic_tracer.F90 @@ -210,7 +210,7 @@ function register_MOM_generic_tracer(HI, GV, param_file, CS, tr_Reg, restart_CS) if (g_tracer_is_prog(g_tracer)) then call register_tracer(tr_ptr, tr_Reg, param_file, HI, GV, & name=g_tracer_name, longname=longname, units=units, & - registry_diags=.false., & !### CHANGE TO TRUE? + registry_diags=.true., & !### CHANGE TO TRUE? restart_CS=restart_CS, mandatory=.not.CS%tracers_may_reinit) else call register_restart_field(tr_ptr, g_tracer_name, .not.CS%tracers_may_reinit, & From 7f70ac405ec3e5b7ef77949b51ec6b4069b0fedf Mon Sep 17 00:00:00 2001 From: Andrew Ross <5852283+andrew-c-ross@users.noreply.github.com> Date: Wed, 17 Jul 2024 16:43:17 -0400 Subject: [PATCH 04/11] Cleanup --- src/tracer/MOM_tracer_advect.F90 | 38 -------------------------------- 1 file changed, 38 deletions(-) diff --git a/src/tracer/MOM_tracer_advect.F90 b/src/tracer/MOM_tracer_advect.F90 index 8d7effa00e..1ad3b061d0 100644 --- a/src/tracer/MOM_tracer_advect.F90 +++ b/src/tracer/MOM_tracer_advect.F90 @@ -187,44 +187,6 @@ subroutine advect_tracer(h_end, uhtr, vhtr, OBC, dt, G, GV, US, CS, Reg, x_first ! initialize diagnostic fluxes and tendencies !$OMP do do m=1,ntr -! if (associated(Tr(m)%ad_x)) then -! do k=1,nz ; do j=jsd,jed ; do i=isd,ied -! Tr(m)%ad_x(I,j,k) = 0.0 -! enddo ; enddo ; enddo -! endif -! if (associated(Tr(m)%ad_y)) then -! do k=1,nz ; do J=jsd,jed ; do i=isd,ied -! Tr(m)%ad_y(i,J,k) = 0.0 -! enddo ; enddo ; enddo -! endif -! if (associated(Tr(m)%advection_xy)) then -! do k=1,nz ; do j=jsd,jed ; do i=isd,ied -! Tr(m)%advection_xy(i,j,k) = 0.0 -! enddo ; enddo ; enddo -! endif -! !liao -! if (associated(Tr(m)%advectionc_xy)) then -! do k=1,nz ; do j=jsd,jed ; do i=isd,ied -! Tr(m)%advectionc_xy(i,j,k) = 0.0 -! enddo ; enddo ; enddo -! endif -! if (associated(Tr(m)%advectionc_x)) then -! do k=1,nz ; do j=jsd,jed ; do i=isd,ied -! Tr(m)%advectionc_x(i,j,k) = 0.0 -! enddo ; enddo ; enddo -! endif -! if (associated(Tr(m)%advectionc_y)) then -! do k=1,nz ; do j=jsd,jed ; do i=isd,ied -! Tr(m)%advectionc_y(i,j,k) = 0.0 -! enddo ; enddo ; enddo -! endif -! !liao -! if (associated(Tr(m)%ad2d_x)) then -! do j=jsd,jed ; do i=isd,ied ; Tr(m)%ad2d_x(I,j) = 0.0 ; enddo ; enddo -! endif -! if (associated(Tr(m)%ad2d_y)) then -! do J=jsd,jed ; do i=isd,ied ; Tr(m)%ad2d_y(i,J) = 0.0 ; enddo ; enddo -! endif if (associated(Reg%Tr(m)%ad_x)) Reg%Tr(m)%ad_x(:,:,:) = 0.0 if (associated(Reg%Tr(m)%ad_y)) Reg%Tr(m)%ad_y(:,:,:) = 0.0 if (associated(Reg%Tr(m)%advection_xy)) Reg%Tr(m)%advection_xy(:,:,:) = 0.0 From 0fb2043dc0f14b9be3e8f77f5626858e5759553a Mon Sep 17 00:00:00 2001 From: Andrew Ross <5852283+andrew-c-ross@users.noreply.github.com> Date: Tue, 6 Aug 2024 14:51:29 -0400 Subject: [PATCH 05/11] Cleanup --- src/tracer/MOM_generic_tracer.F90 | 20 ++++++-------- src/tracer/MOM_tracer_advect.F90 | 15 +++-------- src/tracer/MOM_tracer_hor_diff.F90 | 5 ---- src/tracer/MOM_tracer_registry.F90 | 42 ++++++++++++------------------ src/tracer/MOM_tracer_types.F90 | 14 +++++----- 5 files changed, 36 insertions(+), 60 deletions(-) diff --git a/src/tracer/MOM_generic_tracer.F90 b/src/tracer/MOM_generic_tracer.F90 index cbb977336e..ccf9abb713 100644 --- a/src/tracer/MOM_generic_tracer.F90 +++ b/src/tracer/MOM_generic_tracer.F90 @@ -612,27 +612,23 @@ subroutine MOM_generic_tracer_column_physics(h_old, h_new, ea, eb, fluxes, Hml, if (g_tracer_is_prog(g_tracer)) then do k=1,nk ;do j=jsc,jec ; do i=isc,iec h_work(i,j,k) = h_old(i,j,k) - !liao g_tracer%boundary_forcing_tend(i,j,k) = 0 if (g_tracer%diag_id_boundary_forcing_tend .gt. 0) then g_tracer%boundary_forcing_tend(i,j,k) = g_tracer%field(i,j,k,1) endif - !liao enddo ; enddo ; enddo call applyTracerBoundaryFluxesInOut(G, GV, g_tracer%field(:,:,:,1), dt, & fluxes, h_work, evap_CFL_limit, minimum_forcing_depth) - !liao - if (g_tracer%diag_id_boundary_forcing_tend .gt. 0) then - do k=1,nk ;do j=jsc,jec ; do i=isc,iec - g_tracer%boundary_forcing_tend(i,j,k)=G%mask2dT(i,j)*(g_tracer%field(i,j,k,1) & - - g_tracer%boundary_forcing_tend(i,j,k))/dt - enddo ; enddo ; enddo - endif - !liao + if (g_tracer%diag_id_boundary_forcing_tend .gt. 0) then + do k=1,nk ;do j=jsc,jec ; do i=isc,iec + g_tracer%boundary_forcing_tend(i,j,k)=G%mask2dT(i,j)*(g_tracer%field(i,j,k,1) & + - g_tracer%boundary_forcing_tend(i,j,k))/dt + enddo ; enddo ; enddo + endif endif - !traverse the linked list till hit NULL - call g_tracer_get_next(g_tracer, g_tracer_next) + !traverse the linked list till hit NULL + call g_tracer_get_next(g_tracer, g_tracer_next) if (.NOT. associated(g_tracer_next)) exit g_tracer=>g_tracer_next enddo diff --git a/src/tracer/MOM_tracer_advect.F90 b/src/tracer/MOM_tracer_advect.F90 index 464ad411f6..7d65651c54 100644 --- a/src/tracer/MOM_tracer_advect.F90 +++ b/src/tracer/MOM_tracer_advect.F90 @@ -368,7 +368,7 @@ subroutine advect_x(Tr, hprev, uhr, uh_neglect, OBC, domore_u, ntr, Idt, & ! the grid box, both in [H L2 ~> m3 or kg]. real :: uhh(SZIB_(G)) ! The zonal flux that occurs during the ! current iteration [H L2 ~> m3 or kg]. - real, dimension(SZIB_(G)) :: tprev !< tracer conc at the end of !liao + real, dimension(SZIB_(G)) :: tprev !< tracer conc at the end of previous step. real, dimension(SZIB_(G)) :: & hlst, & ! Work variable [H L2 ~> m3 or kg]. Ihnew, & ! Work variable [H-1 L-2 ~> m-3 or kg-1]. @@ -659,7 +659,7 @@ subroutine advect_x(Tr, hprev, uhr, uh_neglect, OBC, domore_u, ntr, Idt, & do i=is,ie if (do_i(i,j)) then if (Ihnew(i) > 0.0) then - tprev(i)=Tr(m)%t(i,j,k) !liao + tprev(i)=Tr(m)%t(i,j,k) Tr(m)%t(i,j,k) = (Tr(m)%t(i,j,k) * hlst(i) - & (flux_x(I,j,m) - flux_x(I-1,j,m))) * Ihnew(i) endif @@ -679,7 +679,6 @@ subroutine advect_x(Tr, hprev, uhr, uh_neglect, OBC, domore_u, ntr, Idt, & Idt * G%IareaT(i,j) endif ; enddo endif - !liao if (associated(Tr(m)%advectionc_xy)) then do i=is,ie ; if (do_i(i,j)) then Tr(m)%advectionc_xy(i,j,k) = Tr(m)%advectionc_xy(i,j,k)+(Tr(m)%t(i,j,k) - tprev(i))*Idt*G%mask2dT(i,j) @@ -690,8 +689,6 @@ subroutine advect_x(Tr, hprev, uhr, uh_neglect, OBC, domore_u, ntr, Idt, & Tr(m)%advectionc_x(i,j,k) =(Tr(m)%t(i,j,k) - tprev(i))*Idt*G%mask2dT(i,j) endif ; enddo endif - !liao - enddo endif ; enddo ! End of j-loop. @@ -753,7 +750,7 @@ subroutine advect_y(Tr, hprev, vhr, vh_neglect, OBC, domore_v, ntr, Idt, & T_tmp ! The copy of the tracer concentration at constant i,k [conc]. real :: vhh(SZI_(G),SZJB_(G)) ! The meridional flux that occurs during the ! current iteration [H L2 ~> m3 or kg]. - real, dimension(SZIB_(G)) :: tprev !< tracer conc at the end of !liao + real, dimension(SZIB_(G)) :: tprev !< tracer conc at the end of previous step. real :: hup, hlos ! hup is the upwind volume, hlos is the ! part of that volume that might be lost ! due to advection out the other side of @@ -1060,11 +1057,10 @@ subroutine advect_y(Tr, hprev, vhr, vh_neglect, OBC, domore_v, ntr, Idt, & ! update tracer and save some diagnostics do m=1,ntr do i=is,ie ; if (do_i(i,j)) then - tprev(i)=Tr(m)%t(i,j,k) !liao + tprev(i)=Tr(m)%t(i,j,k) Tr(m)%t(i,j,k) = (Tr(m)%t(i,j,k) * hlst(i) - & (flux_y(i,m,J) - flux_y(i,m,J-1))) * Ihnew(i) endif ; enddo - ! diagnose convergence of flux_y and add to convergence of flux_x. ! division by areaT to get into W/m2 for heat and kg/(s*m2) for salt. if (associated(Tr(m)%advection_xy)) then @@ -1073,7 +1069,6 @@ subroutine advect_y(Tr, hprev, vhr, vh_neglect, OBC, domore_v, ntr, Idt, & G%IareaT(i,j) endif ; enddo endif - !liao if (associated(Tr(m)%advectionc_xy)) then do i=is,ie ; if (do_i(i,j)) then Tr(m)%advectionc_xy(i,j,k) = Tr(m)%advectionc_xy(i,j,k)+(Tr(m)%t(i,j,k) - tprev(i))*Idt*G%mask2dT(i,j) @@ -1084,8 +1079,6 @@ subroutine advect_y(Tr, hprev, vhr, vh_neglect, OBC, domore_v, ntr, Idt, & Tr(m)%advectionc_y(i,j,k) = (Tr(m)%t(i,j,k) - tprev(i))*Idt*G%mask2dT(i,j) endif ; enddo endif - !liao - enddo endif ; enddo ! End of j-loop. diff --git a/src/tracer/MOM_tracer_hor_diff.F90 b/src/tracer/MOM_tracer_hor_diff.F90 index 3fbc5746be..bf9e9fcb1d 100644 --- a/src/tracer/MOM_tracer_hor_diff.F90 +++ b/src/tracer/MOM_tracer_hor_diff.F90 @@ -400,19 +400,16 @@ subroutine tracer_hordiff(h, dt, MEKE, VarMix, visc, G, GV, US, CS, Reg, tv, do_ if (associated(Reg%Tr(m)%df2d_y)) then do J=js-1,je ; do i=is,ie ; Reg%Tr(m)%df2d_y(i,J) = 0.0 ; enddo ; enddo endif - ! mpoupon if (associated(Reg%Tr(m)%diffusionc_xy)) then do k=1,nz ; do j=js,je ; do i=is,ie Reg%Tr(m)%diffusionc_xy(i,j,k) = 0.0 enddo ; enddo ; enddo endif - if (associated(Reg%Tr(m)%diffusion_xy)) then do k=1,nz ; do j=js,je ; do i=is,ie Reg%Tr(m)%diffusion_xy(i,j,k) = 0.0 enddo ; enddo ; enddo endif - ! mpoupon enddo if (CS%use_hor_bnd_diffusion) then @@ -582,14 +579,12 @@ subroutine tracer_hordiff(h, dt, MEKE, VarMix, visc, G, GV, US, CS, Reg, tv, do_ enddo ; enddo ; endif do j=js,je ; do i=is,ie Reg%Tr(m)%t(i,j,k) = Reg%Tr(m)%t(i,j,k) + dTr(i,j) - ! mpoupon if (associated(Reg%Tr(m)%diffusionc_xy)) then Reg%Tr(m)%diffusionc_xy(i,j,k) = dTr(i,j) * Idt endif if (associated(Reg%Tr(m)%diffusion_xy)) then Reg%Tr(m)%diffusion_xy(i,j,k) = dTr(i,j) * Idt * (h(i,j,k)+h_neglect) endif - ! mpoupon enddo ; enddo enddo diff --git a/src/tracer/MOM_tracer_registry.F90 b/src/tracer/MOM_tracer_registry.F90 index bffd163529..e443542d1a 100644 --- a/src/tracer/MOM_tracer_registry.F90 +++ b/src/tracer/MOM_tracer_registry.F90 @@ -53,8 +53,8 @@ subroutine register_tracer(tr_ptr, Reg, param_file, HI, GV, name, longname, unit cmor_name, cmor_units, cmor_longname, net_surfflux_name, NLT_budget_name, & net_surfflux_longname, tr_desc, OBC_inflow, OBC_in_u, OBC_in_v, ad_x, ad_y, & df_x, df_y, ad_2d_x, ad_2d_y, df_2d_x, df_2d_y, advection_xy, registry_diags, & - advectionc_xy, advectionc_x, advectionc_y, & !liao - diffusionc_xy, diffusion_xy, & ! mpoupon + advectionc_xy, advectionc_x, advectionc_y, & + diffusionc_xy, diffusion_xy, & conc_scale, flux_nameroot, flux_longname, flux_units, flux_scale, & convergence_units, convergence_scale, cmor_tendprefix, diag_form, & restart_CS, mandatory, underflow_conc, Tr_out) @@ -102,11 +102,11 @@ subroutine register_tracer(tr_ptr, Reg, param_file, HI, GV, name, longname, unit real, dimension(:,:,:), optional, pointer :: advection_xy !< convergence of lateral advective tracer fluxes !! [CU H T-1 ~> conc m s-1 or conc kg m-2 s-1] - real, dimension(:,:,:), optional, pointer :: advectionc_xy !< convergence of lateral advection !liao - real, dimension(:,:,:), optional, pointer :: diffusionc_xy !< convergence of lateral diffusion !mpoupon - real, dimension(:,:,:), optional, pointer :: diffusion_xy !< convergence of lateral diffusive tracer fluxes !mpoupon - real, dimension(:,:,:), optional, pointer :: advectionc_x !< lateral advection concentration !liao - real, dimension(:,:,:), optional, pointer :: advectionc_y !< lateral advection concentration !liao + real, dimension(:,:,:), optional, pointer :: advectionc_xy !< convergence of lateral advection + real, dimension(:,:,:), optional, pointer :: diffusionc_xy !< convergence of lateral diffusion + real, dimension(:,:,:), optional, pointer :: diffusion_xy !< convergence of lateral diffusive tracer fluxes + real, dimension(:,:,:), optional, pointer :: advectionc_x !< lateral advection concentration + real, dimension(:,:,:), optional, pointer :: advectionc_y !< lateral advection concentration logical, optional, intent(in) :: registry_diags !< If present and true, use the registry for !! the diagnostics of this tracer. @@ -253,11 +253,11 @@ subroutine register_tracer(tr_ptr, Reg, param_file, HI, GV, name, longname, unit if (present(df_2d_x)) then ; if (associated(df_2d_x)) Tr%df2d_x => df_2d_x ; endif if (present(advection_xy)) then ; if (associated(advection_xy)) Tr%advection_xy => advection_xy ; endif - if (present(advectionc_xy)) then; if (associated(advectionc_xy)) Tr%advectionc_xy => advectionc_xy ; endif !liao - if (present(diffusionc_xy)) then; if (associated(diffusionc_xy)) Tr%diffusionc_xy => diffusionc_xy ; endif !mpoupon - if (present(diffusion_xy)) then; if (associated(diffusion_xy)) Tr%diffusion_xy => diffusion_xy ; endif !mpoupon - if (present(advectionc_x)) then; if (associated(advectionc_x)) Tr%advectionc_x => advectionc_x ; endif !liao - if (present(advectionc_y)) then; if (associated(advectionc_y)) Tr%advectionc_y => advectionc_y ; endif !liao + if (present(advectionc_xy)) then; if (associated(advectionc_xy)) Tr%advectionc_xy => advectionc_xy ; endif + if (present(diffusionc_xy)) then; if (associated(diffusionc_xy)) Tr%diffusionc_xy => diffusionc_xy ; endif + if (present(diffusion_xy)) then; if (associated(diffusion_xy)) Tr%diffusion_xy => diffusion_xy ; endif + if (present(advectionc_x)) then; if (associated(advectionc_x)) Tr%advectionc_x => advectionc_x ; endif + if (present(advectionc_y)) then; if (associated(advectionc_y)) Tr%advectionc_y => advectionc_y ; endif if (present(restart_CS)) then ! Register this tracer to be read from and written to restart files. @@ -452,15 +452,12 @@ subroutine register_tracer_diagnostics(Reg, h, Time, diag, G, GV, US, use_ALE, u 'Horizontal convergence of residual mean advective fluxes of '//& trim(lowercase(flux_longname)), conv_units, v_extensive=.true., & conversion=Tr%conv_scale*US%s_to_T) - ! mpoupon Tr%id_difc_xy = register_diag_field('ocean_model',trim(shortnm)//"_diffusionc_xy", & diag%axesTL, Time, "Horizontal convergence of residual mean diffusive fluxes of "//trim(shortnm), & trim(units)//' s-1') Tr%id_dif_xy = register_diag_field('ocean_model',trim(shortnm)//"_diffusion_xy", & diag%axesTL, Time, "Horizontal convergence of residual mean diffusive fluxes of "//trim(shortnm), & trim(units)//' s-1') - ! mpoupon - !liao Tr%id_advc_xy = register_diag_field('ocean_model',trim(shortnm)//"_advectionc_xy", & diag%axesTL, Time, "Horizontal convergence of residual mean advective fluxes of "//trim(shortnm), & trim(units)//' s-1') @@ -470,27 +467,22 @@ subroutine register_tracer_diagnostics(Reg, h, Time, diag, G, GV, US, use_ALE, u Tr%id_advc_y = register_diag_field("ocean_model",trim(shortnm)//'_advectionc_y', & diag%axesTL, Time, "Horizontal y mean advective fluxes of "//trim(shortnm), & trim(units)//' s-1') - !liao Tr%id_adv_xy_2d = register_diag_field('ocean_model', trim(shortnm)//"_advection_xy_2d", & diag%axesT1, Time, & 'Vertical sum of horizontal convergence of residual mean advective fluxes of '//& trim(lowercase(flux_longname)), conv_units, conversion=Tr%conv_scale*US%s_to_T) if ((Tr%id_adv_xy > 0) .or. (Tr%id_adv_xy_2d > 0)) & call safe_alloc_ptr(Tr%advection_xy,isd,ied,jsd,jed,nz) - !mpoupon if (Tr%id_difc_xy > 0) & call safe_alloc_ptr(Tr%diffusionc_xy,isd,ied,jsd,jed,nz) if (Tr%id_dif_xy > 0) & call safe_alloc_ptr(Tr%diffusion_xy,isd,ied,jsd,jed,nz) - !mpoupon - !liao if (Tr%id_advc_xy > 0) & call safe_alloc_ptr(Tr%advectionc_xy,isd,ied,jsd,jed,nz) if (Tr%id_advc_x > 0) & call safe_alloc_ptr(Tr%advectionc_x,isd,ied,jsd,jed,nz) if (Tr%id_advc_y > 0) & call safe_alloc_ptr(Tr%advectionc_y,isd,ied,jsd,jed,nz) - !liao Tr%id_tendency = register_diag_field('ocean_model', trim(shortnm)//'_tendency', & diag%axesTL, Time, & @@ -786,11 +778,11 @@ subroutine post_tracer_transport_diagnostics(G, GV, Reg, h_diag, diag) if (Tr%id_dfx_2d > 0) call post_data(Tr%id_dfx_2d, Tr%df2d_x, diag) if (Tr%id_dfy_2d > 0) call post_data(Tr%id_dfy_2d, Tr%df2d_y, diag) if (Tr%id_adv_xy > 0) call post_data(Tr%id_adv_xy, Tr%advection_xy, diag, alt_h=h_diag) - if (Tr%id_advc_xy > 0) call post_data(Tr%id_advc_xy, Tr%advectionc_xy, diag, alt_h=h_diag) !liao - if (Tr%id_difc_xy > 0) call post_data(Tr%id_difc_xy, Tr%diffusionc_xy, diag, alt_h=h_diag) !mpoupon - if (Tr%id_dif_xy > 0) call post_data(Tr%id_dif_xy, Tr%diffusion_xy, diag, alt_h=h_diag) !mpoupon - if (Tr%id_advc_x > 0) call post_data(Tr%id_advc_x, Tr%advectionc_x, diag, alt_h=h_diag) !liao - if (Tr%id_advc_y > 0) call post_data(Tr%id_advc_y, Tr%advectionc_y, diag, alt_h=h_diag) !liao + if (Tr%id_advc_xy > 0) call post_data(Tr%id_advc_xy, Tr%advectionc_xy, diag, alt_h=h_diag) + if (Tr%id_difc_xy > 0) call post_data(Tr%id_difc_xy, Tr%diffusionc_xy, diag, alt_h=h_diag) + if (Tr%id_dif_xy > 0) call post_data(Tr%id_dif_xy, Tr%diffusion_xy, diag, alt_h=h_diag) + if (Tr%id_advc_x > 0) call post_data(Tr%id_advc_x, Tr%advectionc_x, diag, alt_h=h_diag) + if (Tr%id_advc_y > 0) call post_data(Tr%id_advc_y, Tr%advectionc_y, diag, alt_h=h_diag) if (Tr%id_adv_xy_2d > 0) then work2d(:,:) = 0.0 do k=1,nz ; do j=js,je ; do i=is,ie diff --git a/src/tracer/MOM_tracer_types.F90 b/src/tracer/MOM_tracer_types.F90 index 011b34b157..d6ea3d024f 100644 --- a/src/tracer/MOM_tracer_types.F90 +++ b/src/tracer/MOM_tracer_types.F90 @@ -48,11 +48,11 @@ module MOM_tracer_types real, dimension(:,:,:), pointer :: advection_xy => NULL() !< convergence of lateral advective tracer fluxes !! [CU H T-1 ~> conc m s-1 or conc kg m-2 s-1] - real, dimension(:,:,:), pointer :: advectionc_xy => NULL() !< convergence of lateral advection concentration liao - real, dimension(:,:,:), pointer :: diffusionc_xy => NULL() !< convergence of lateral diffusion concentration mpoupon - real, dimension(:,:,:), pointer :: diffusion_xy => NULL() !< convergence of lateral diffusion content mpoupon - real, dimension(:,:,:), pointer :: advectionc_x => NULL() !< lateral advection concentration liao - real, dimension(:,:,:), pointer :: advectionc_y => NULL() !< lateral advection concentration liao + real, dimension(:,:,:), pointer :: advectionc_xy => NULL() !< convergence of lateral advection concentration + real, dimension(:,:,:), pointer :: diffusionc_xy => NULL() !< convergence of lateral diffusion concentration + real, dimension(:,:,:), pointer :: diffusion_xy => NULL() !< convergence of lateral diffusion content + real, dimension(:,:,:), pointer :: advectionc_x => NULL() !< lateral advection concentration + real, dimension(:,:,:), pointer :: advectionc_y => NULL() !< lateral advection concentration ! real, dimension(:,:,:), pointer :: diff_cont_xy => NULL() !< convergence of lateral diffusive tracer fluxes ! !! [CU H T-1 ~> conc m s-1 or conc kg m-2 s-1] @@ -114,8 +114,8 @@ module MOM_tracer_types integer :: id_hbd_dfx_2d = -1, id_hbd_dfy_2d = -1 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_advc_xy = -1, id_advc_x = -1, id_advc_y = -1 !liao - integer :: id_difc_xy = -1, id_dif_xy = -1 ! mpoupon + integer :: id_advc_xy = -1, id_advc_x = -1, id_advc_y = -1 + integer :: id_difc_xy = -1, id_dif_xy = -1 integer :: id_dfxy_cont = -1, id_dfxy_cont_2d = -1, id_dfxy_conc = -1 integer :: id_hbdxy_cont = -1, id_hbdxy_cont_2d = -1, id_hbdxy_conc = -1 integer :: id_remap_conc = -1, id_remap_cont = -1, id_remap_cont_2d = -1 From ef29b125930fdd4802b14074e19c58c094ce6b47 Mon Sep 17 00:00:00 2001 From: Andrew Ross <5852283+andrew-c-ross@users.noreply.github.com> Date: Tue, 6 Aug 2024 16:40:55 -0400 Subject: [PATCH 06/11] Add boundary_forcing_tend to stub g_tracer_type --- config_src/external/GFDL_ocean_BGC/generic_tracer_utils.F90 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config_src/external/GFDL_ocean_BGC/generic_tracer_utils.F90 b/config_src/external/GFDL_ocean_BGC/generic_tracer_utils.F90 index 5c87c37e70..1acb2299cc 100644 --- a/config_src/external/GFDL_ocean_BGC/generic_tracer_utils.F90 +++ b/config_src/external/GFDL_ocean_BGC/generic_tracer_utils.F90 @@ -20,6 +20,7 @@ module g_tracer_utils real, pointer, dimension(:,:,:,:) :: field => NULL() !> Tracer concentration in river runoff real, allocatable, dimension(:,:) :: trunoff + real, allocatable, dimension(:,:,:) :: boundary_forcing_tend !< Tendency for budget diagnostics logical :: requires_restart = .true. !< Unknown character(len=fm_string_len) :: src_file !< Tracer source filename character(len=fm_string_len) :: src_var_name !< Tracer source variable name @@ -27,6 +28,7 @@ module g_tracer_utils character(len=fm_string_len) :: src_var_gridspec !< Tracer source grid file name character(len=fm_string_len) :: obc_src_file_name !< Boundary condition tracer source filename character(len=fm_string_len) :: obc_src_field_name !< Boundary condition tracer source fieldname + integer :: diag_id_boundary_forcing_tend = -1 !< Budget diagnostic id integer :: src_var_record !< Unknown logical :: runoff_added_to_stf = .false. !< Has flux in from runoff been added to stf? logical :: requires_src_info = .false. !< Unknown From 109d6a96fe8f80dfda64dd85a3fa9006189b1d4f Mon Sep 17 00:00:00 2001 From: Andrew Ross <5852283+andrew-c-ross@users.noreply.github.com> Date: Tue, 6 Aug 2024 17:14:32 -0400 Subject: [PATCH 07/11] Clean trailing whitespace --- src/tracer/MOM_tracer_registry.F90 | 2 +- src/tracer/MOM_tracer_types.F90 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tracer/MOM_tracer_registry.F90 b/src/tracer/MOM_tracer_registry.F90 index e443542d1a..ef0adf9479 100644 --- a/src/tracer/MOM_tracer_registry.F90 +++ b/src/tracer/MOM_tracer_registry.F90 @@ -253,7 +253,7 @@ subroutine register_tracer(tr_ptr, Reg, param_file, HI, GV, name, longname, unit if (present(df_2d_x)) then ; if (associated(df_2d_x)) Tr%df2d_x => df_2d_x ; endif if (present(advection_xy)) then ; if (associated(advection_xy)) Tr%advection_xy => advection_xy ; endif - if (present(advectionc_xy)) then; if (associated(advectionc_xy)) Tr%advectionc_xy => advectionc_xy ; endif + if (present(advectionc_xy)) then; if (associated(advectionc_xy)) Tr%advectionc_xy => advectionc_xy ; endif if (present(diffusionc_xy)) then; if (associated(diffusionc_xy)) Tr%diffusionc_xy => diffusionc_xy ; endif if (present(diffusion_xy)) then; if (associated(diffusion_xy)) Tr%diffusion_xy => diffusion_xy ; endif if (present(advectionc_x)) then; if (associated(advectionc_x)) Tr%advectionc_x => advectionc_x ; endif diff --git a/src/tracer/MOM_tracer_types.F90 b/src/tracer/MOM_tracer_types.F90 index d6ea3d024f..2b8ceeca09 100644 --- a/src/tracer/MOM_tracer_types.F90 +++ b/src/tracer/MOM_tracer_types.F90 @@ -50,7 +50,7 @@ module MOM_tracer_types !! [CU H T-1 ~> conc m s-1 or conc kg m-2 s-1] real, dimension(:,:,:), pointer :: advectionc_xy => NULL() !< convergence of lateral advection concentration real, dimension(:,:,:), pointer :: diffusionc_xy => NULL() !< convergence of lateral diffusion concentration - real, dimension(:,:,:), pointer :: diffusion_xy => NULL() !< convergence of lateral diffusion content + real, dimension(:,:,:), pointer :: diffusion_xy => NULL() !< convergence of lateral diffusion content real, dimension(:,:,:), pointer :: advectionc_x => NULL() !< lateral advection concentration real, dimension(:,:,:), pointer :: advectionc_y => NULL() !< lateral advection concentration @@ -115,7 +115,7 @@ module MOM_tracer_types 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_advc_xy = -1, id_advc_x = -1, id_advc_y = -1 - integer :: id_difc_xy = -1, id_dif_xy = -1 + integer :: id_difc_xy = -1, id_dif_xy = -1 integer :: id_dfxy_cont = -1, id_dfxy_cont_2d = -1, id_dfxy_conc = -1 integer :: id_hbdxy_cont = -1, id_hbdxy_cont_2d = -1, id_hbdxy_conc = -1 integer :: id_remap_conc = -1, id_remap_cont = -1, id_remap_cont_2d = -1 From f954adc53859e91b0c44c3f1285dc16249142b98 Mon Sep 17 00:00:00 2001 From: Andrew Ross <5852283+andrew-c-ross@users.noreply.github.com> Date: Fri, 9 Aug 2024 16:13:30 -0400 Subject: [PATCH 08/11] Remove redundant zeroing of boundary_forcing_tend --- src/tracer/MOM_generic_tracer.F90 | 1 - 1 file changed, 1 deletion(-) diff --git a/src/tracer/MOM_generic_tracer.F90 b/src/tracer/MOM_generic_tracer.F90 index ccf9abb713..0448d8cd2e 100644 --- a/src/tracer/MOM_generic_tracer.F90 +++ b/src/tracer/MOM_generic_tracer.F90 @@ -612,7 +612,6 @@ subroutine MOM_generic_tracer_column_physics(h_old, h_new, ea, eb, fluxes, Hml, if (g_tracer_is_prog(g_tracer)) then do k=1,nk ;do j=jsc,jec ; do i=isc,iec h_work(i,j,k) = h_old(i,j,k) - g_tracer%boundary_forcing_tend(i,j,k) = 0 if (g_tracer%diag_id_boundary_forcing_tend .gt. 0) then g_tracer%boundary_forcing_tend(i,j,k) = g_tracer%field(i,j,k,1) endif From e64a381271e5f43da6a57562cedbe27798812e95 Mon Sep 17 00:00:00 2001 From: Andrew Ross <5852283+andrew-c-ross@users.noreply.github.com> Date: Wed, 21 Aug 2024 14:16:54 -0400 Subject: [PATCH 09/11] Add an attribution --- src/tracer/MOM_tracer_registry.F90 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/tracer/MOM_tracer_registry.F90 b/src/tracer/MOM_tracer_registry.F90 index ef0adf9479..b56e10afc9 100644 --- a/src/tracer/MOM_tracer_registry.F90 +++ b/src/tracer/MOM_tracer_registry.F90 @@ -447,6 +447,9 @@ subroutine register_tracer_diagnostics(Reg, h, Time, diag, G, GV, US, use_ALE, u if (Tr%id_hbd_dfx_2d > 0) call safe_alloc_ptr(Tr%hbd_dfx_2d,IsdB,IedB,jsd,jed) if (Tr%id_hbd_dfy_2d > 0) call safe_alloc_ptr(Tr%hbd_dfy_2d,isd,ied,JsdB,JedB) + ! The following diagnostics for generic tracer budgets were + ! originally developed by Enhui Lao, Fan Yang, and Mathieu Poupon. + Tr%id_adv_xy = register_diag_field('ocean_model', trim(shortnm)//"_advection_xy", & diag%axesTL, Time, & 'Horizontal convergence of residual mean advective fluxes of '//& From 75112a6b2f1f3d8aae09ff2b9e87bbdd842010c8 Mon Sep 17 00:00:00 2001 From: Andrew Ross <5852283+andrew-c-ross@users.noreply.github.com> Date: Thu, 22 Aug 2024 15:03:08 -0400 Subject: [PATCH 10/11] Clarify which diagnostics are for concentration --- src/tracer/MOM_tracer_registry.F90 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/tracer/MOM_tracer_registry.F90 b/src/tracer/MOM_tracer_registry.F90 index b56e10afc9..006f49aded 100644 --- a/src/tracer/MOM_tracer_registry.F90 +++ b/src/tracer/MOM_tracer_registry.F90 @@ -456,19 +456,19 @@ subroutine register_tracer_diagnostics(Reg, h, Time, diag, G, GV, US, use_ALE, u trim(lowercase(flux_longname)), conv_units, v_extensive=.true., & conversion=Tr%conv_scale*US%s_to_T) Tr%id_difc_xy = register_diag_field('ocean_model',trim(shortnm)//"_diffusionc_xy", & - diag%axesTL, Time, "Horizontal convergence of residual mean diffusive fluxes of "//trim(shortnm), & - trim(units)//' s-1') + diag%axesTL, Time, "Horizontal convergence of residual mean diffusive fluxes of "//& + trim(shortnm)//' concentration', trim(units)//' s-1') Tr%id_dif_xy = register_diag_field('ocean_model',trim(shortnm)//"_diffusion_xy", & diag%axesTL, Time, "Horizontal convergence of residual mean diffusive fluxes of "//trim(shortnm), & trim(units)//' s-1') Tr%id_advc_xy = register_diag_field('ocean_model',trim(shortnm)//"_advectionc_xy", & - diag%axesTL, Time, "Horizontal convergence of residual mean advective fluxes of "//trim(shortnm), & - trim(units)//' s-1') + diag%axesTL, Time, "Horizontal convergence of residual mean advective fluxes of "//& + trim(shortnm)//' concentration', trim(units)//' s-1') Tr%id_advc_x = register_diag_field("ocean_model",trim(shortnm)//'_advectionc_x', & - diag%axesTL, Time, "Horizontal x mean advective fluxes of "//trim(shortnm), & + diag%axesTL, Time, "Horizontal x mean advective fluxes of "//trim(shortnm)//' concentration', & trim(units)//' s-1') Tr%id_advc_y = register_diag_field("ocean_model",trim(shortnm)//'_advectionc_y', & - diag%axesTL, Time, "Horizontal y mean advective fluxes of "//trim(shortnm), & + diag%axesTL, Time, "Horizontal y mean advective fluxes of "//trim(shortnm)//' concentration', & trim(units)//' s-1') Tr%id_adv_xy_2d = register_diag_field('ocean_model', trim(shortnm)//"_advection_xy_2d", & diag%axesT1, Time, & From 8f53e557ee8be0ad0aa77e90b4aa39539a21c7df Mon Sep 17 00:00:00 2001 From: Andrew Ross <5852283+andrew-c-ross@users.noreply.github.com> Date: Thu, 22 Aug 2024 15:21:30 -0400 Subject: [PATCH 11/11] Fix units for _diffusion_xy --- src/tracer/MOM_tracer_registry.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tracer/MOM_tracer_registry.F90 b/src/tracer/MOM_tracer_registry.F90 index 006f49aded..39ffac5e0b 100644 --- a/src/tracer/MOM_tracer_registry.F90 +++ b/src/tracer/MOM_tracer_registry.F90 @@ -460,7 +460,7 @@ subroutine register_tracer_diagnostics(Reg, h, Time, diag, G, GV, US, use_ALE, u trim(shortnm)//' concentration', trim(units)//' s-1') Tr%id_dif_xy = register_diag_field('ocean_model',trim(shortnm)//"_diffusion_xy", & diag%axesTL, Time, "Horizontal convergence of residual mean diffusive fluxes of "//trim(shortnm), & - trim(units)//' s-1') + conv_units, conversion=Tr%conv_scale*US%s_to_T) Tr%id_advc_xy = register_diag_field('ocean_model',trim(shortnm)//"_advectionc_xy", & diag%axesTL, Time, "Horizontal convergence of residual mean advective fluxes of "//& trim(shortnm)//' concentration', trim(units)//' s-1')