From def2be3d85e9a779adbee0dd5be93b785c9349bb Mon Sep 17 00:00:00 2001 From: Robert Hallberg Date: Fri, 20 May 2022 07:14:49 -0400 Subject: [PATCH] (*)Fix occasional bug with PFv_visc_rem diagnostic Corrected a bug that causes the bottom-drag filtered meridional acceleration diagnostics, like PFv_visc_rem, to erroneously be filled with all zeros unless one of the filtered u-point diagnostics is also enabled in the diag_table, and conversely could lead to segmentation fault if there are are only filtered u-point diagnostics. However, if at least one of both kinds of diagnostics are enabled, everything was already working as intended. Also changed a call to enabled_averaging into a call to enable_averages to avoid having to scale an argument. All solutions are bitwise identical, and in many cases the diagnostics are also unchanged. --- src/core/MOM_barotropic.F90 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/MOM_barotropic.F90 b/src/core/MOM_barotropic.F90 index 7f91428c94..6c13fa8af0 100644 --- a/src/core/MOM_barotropic.F90 +++ b/src/core/MOM_barotropic.F90 @@ -6,7 +6,7 @@ module MOM_barotropic use MOM_debugging, only : hchksum, uvchksum use MOM_cpu_clock, only : cpu_clock_id, cpu_clock_begin, cpu_clock_end, CLOCK_ROUTINE use MOM_diag_mediator, only : post_data, query_averaging_enabled, register_diag_field -use MOM_diag_mediator, only : diag_ctrl, enable_averaging +use MOM_diag_mediator, only : diag_ctrl, enable_averaging, enable_averages use MOM_domains, only : min_across_PEs, clone_MOM_domain, deallocate_MOM_domain use MOM_domains, only : To_All, Scalar_Pair, AGRID, CORNER, MOM_domain_type use MOM_domains, only : create_group_pass, do_group_pass, group_pass_type @@ -2351,7 +2351,7 @@ subroutine btstep(U_in, V_in, eta_in, dt, bc_accel_u, bc_accel_v, forces, pbce, if (do_hifreq_output) then time_step_end = time_bt_start + real_to_time(n*US%T_to_s*dtbt) - call enable_averaging(US%T_to_s*dtbt, time_step_end, CS%diag) + call enable_averages(dtbt, time_step_end, CS%diag) if (CS%id_ubt_hifreq > 0) call post_data(CS%id_ubt_hifreq, ubt(IsdB:IedB,jsd:jed), CS%diag) if (CS%id_vbt_hifreq > 0) call post_data(CS%id_vbt_hifreq, vbt(isd:ied,JsdB:JedB), CS%diag) if (CS%id_eta_hifreq > 0) call post_data(CS%id_eta_hifreq, eta(isd:ied,jsd:jed), CS%diag) @@ -2711,7 +2711,7 @@ subroutine btstep(U_in, V_in, eta_in, dt, bc_accel_u, bc_accel_v, forces, pbce, ADp%visc_rem_u(I,j,k) = visc_rem_u(I,j,k) enddo ; enddo ; enddo endif - if (associated(ADp%visc_rem_u)) then + if (associated(ADp%visc_rem_v)) then do k=1,nz ; do J=js-1,je ; do i=is,ie ADp%visc_rem_v(i,J,k) = visc_rem_v(i,J,k) enddo ; enddo ; enddo