Skip to content

Commit 3fac1c5

Browse files
committed
Allow incorrect PPM:H3 tracer advection stencil
Due to answer changes in multiple production experiments, this patch introduces a new parameter, USE_HUYNH_STENCIL_BUG, which sets the tracer advection stencil width to its previous incorrect value. This parameter replicates the previous method, which keeps `stencil` at 2 when PPM:H3 is used. ---- The logical parameters are * P = CS%usePPM * H = CS%useHuynh * E = USE_HUYNH_STENCIL_BUG * R = CS%useHuynhStencilBug The three expressions of interest: 1. P & ~H 2. P 3. P & ~R (1) is the original incorrect expression, (2) is the fixed expression, and (3) is the proposed update. What we want: If E is false, then (3) should reduce to (2). If E is true, then (3) should reduce to (1). R is computed as follows: * R = False (from derived type initialization) * if (H) R = E (from get_param call) This is equivalent to R = H & E, and (3) is P & ~(H & E). * If E is False, then P & ~(H & False) = P. * If E is True, then P & ~(H & True) = P & ~H So this flag should replicate both the previous and current behavior.
1 parent ac2b642 commit 3fac1c5

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/tracer/MOM_tracer_advect.F90

+16-3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ module MOM_tracer_advect
3434
logical :: debug !< If true, write verbose checksums for debugging purposes.
3535
logical :: usePPM !< If true, use PPM instead of PLM
3636
logical :: useHuynh !< If true, use the Huynh scheme for PPM interface values
37+
logical :: useHuynhStencilBug = .false. !< If true, use the incorrect stencil width.
38+
!! This is provided for compatibility with legacy simuations.
3739
type(group_pass_type) :: pass_uhr_vhr_t_hprev !< A structure used for group passes
3840
end type tracer_advect_CS
3941

@@ -94,6 +96,7 @@ subroutine advect_tracer(h_end, uhtr, vhtr, OBC, dt, G, GV, US, CS, Reg, x_first
9496
! can be simply discarded [H L2 ~> m3 or kg].
9597

9698
real :: landvolfill ! An arbitrary? nonzero cell volume [H L2 ~> m3 or kg].
99+
logical :: use_PPM_stencil ! If true, use the correct PPM stencil width.
97100
real :: Idt ! 1/dt [T-1 ~> s-1].
98101
logical :: domore_u(SZJ_(G),SZK_(GV)) ! domore_u and domore_v indicate whether there is more
99102
logical :: domore_v(SZJB_(G),SZK_(GV)) ! advection to be done in the corresponding row or column.
@@ -112,7 +115,7 @@ subroutine advect_tracer(h_end, uhtr, vhtr, OBC, dt, G, GV, US, CS, Reg, x_first
112115
isd = G%isd ; ied = G%ied ; jsd = G%jsd ; jed = G%jed
113116
IsdB = G%IsdB ; IedB = G%IedB ; JsdB = G%JsdB ; JedB = G%JedB
114117
landvolfill = 1.0e-20 ! This is arbitrary, but must be positive.
115-
stencil = 2 ! The scheme's stencil; 2 for PLM and PPM:H3
118+
stencil = 2 ! The scheme's stencil; 2 for PLM
116119

117120
if (.not. associated(CS)) call MOM_error(FATAL, "MOM_tracer_advect: "// &
118121
"tracer_advect_init must be called before advect_tracer.")
@@ -123,8 +126,8 @@ subroutine advect_tracer(h_end, uhtr, vhtr, OBC, dt, G, GV, US, CS, Reg, x_first
123126
x_first = (MOD(G%first_direction,2) == 0)
124127

125128
! increase stencil size for Colella & Woodward PPM
126-
! if (CS%usePPM .and. .not. CS%useHuynh) stencil = 3
127-
if (CS%usePPM) stencil = 3
129+
use_PPM_stencil = CS%usePPM .and. .not. CS%useHuynhStencilBug
130+
if (use_PPM_stencil) stencil = 3
128131

129132
ntr = Reg%ntr
130133
Idt = 1.0 / dt
@@ -1130,6 +1133,16 @@ subroutine tracer_advect_init(Time, G, US, param_file, diag, CS)
11301133
"Unknown TRACER_ADVECTION_SCHEME = "//trim(mesg))
11311134
end select
11321135

1136+
if (CS%useHuynh) then
1137+
call get_param(param_file, mdl, "USE_HUYNH_STENCIL_BUG", &
1138+
CS%useHuynhStencilBug, &
1139+
desc="If true, use a stencil width of 2 in PPM:H3 tracer advection. " &
1140+
// "This is incorrect and will produce regressions in certain " &
1141+
// "configurations, but may be required to reproduce results in " &
1142+
// "legacy simulations.", &
1143+
default=.false.)
1144+
endif
1145+
11331146
id_clock_advect = cpu_clock_id('(Ocean advect tracer)', grain=CLOCK_MODULE)
11341147
id_clock_pass = cpu_clock_id('(Ocean tracer halo updates)', grain=CLOCK_ROUTINE)
11351148
id_clock_sync = cpu_clock_id('(Ocean tracer global synch)', grain=CLOCK_ROUTINE)

0 commit comments

Comments
 (0)