Skip to content

Commit c478543

Browse files
herrwang0Hallberg-NOAA
authored andcommitted
Simplify do_advection and do_diabatic
Flags `do_advection` and `do_diabatic` in subroutine step_MOM are simplified for slightly better readability and efficiency.
1 parent 89067a3 commit c478543

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

src/core/MOM.F90

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,7 @@ subroutine step_MOM(forces_in, fluxes_in, sfc_state, Time_start, time_int_in, CS
675675
if (do_dyn) then
676676
n_max = 1
677677
if (time_interval > CS%dt) n_max = ceiling(time_interval/CS%dt - 0.001)
678+
ntstep = 1 ! initialization
678679
dt = time_interval / real(n_max)
679680
thermo_does_span_coupling = (CS%thermo_spans_coupling .and. &
680681
(CS%dt_therm > 1.5*cycle_time))
@@ -966,10 +967,9 @@ subroutine step_MOM(forces_in, fluxes_in, sfc_state, Time_start, time_int_in, CS
966967

967968
!===========================================================================
968969
! This is the start of the tracer advection part of the algorithm.
969-
do_advection = .false.
970970
if (tradv_does_span_coupling .or. .not.do_thermo) then
971-
do_advection = (CS%t_dyn_rel_adv + 0.5*dt > dt_tr_adv)
972-
if (CS%t_dyn_rel_thermo + 0.5*dt > dt_therm) do_advection = .true.
971+
do_advection = ((CS%t_dyn_rel_adv + 0.5*dt > dt_tr_adv) .or. &
972+
(CS%t_dyn_rel_thermo + 0.5*dt > dt_therm))
973973
else
974974
do_advection = ((MOD(n,ntastep) == 0) .or. (n==n_max))
975975
endif
@@ -984,15 +984,12 @@ subroutine step_MOM(forces_in, fluxes_in, sfc_state, Time_start, time_int_in, CS
984984

985985
!===========================================================================
986986
! This is the second place where the diabatic processes and remapping could occur.
987-
if (do_thermo) then
988-
do_diabatic = .false.
989-
if (thermo_does_span_coupling .or. .not.do_dyn) then
990-
do_diabatic = (CS%t_dyn_rel_thermo + 0.5*dt > dt_therm)
991-
else
992-
do_diabatic = ((MOD(n,ntstep) == 0) .or. (n==n_max))
993-
endif
987+
if (thermo_does_span_coupling .or. .not.do_dyn) then
988+
do_diabatic = (do_thermo .and. (CS%t_dyn_rel_thermo + 0.5*dt > dt_therm))
989+
else
990+
do_diabatic = (do_thermo .and. ((MOD(n,ntstep) == 0) .or. (n==n_max)))
994991
endif
995-
if ((CS%t_dyn_rel_adv==0.0) .and. do_thermo .and. (.not.CS%diabatic_first) .and. do_diabatic) then
992+
if ((CS%t_dyn_rel_adv==0.0) .and. (.not.CS%diabatic_first) .and. do_diabatic) then
996993

997994
dtdia = CS%t_dyn_rel_thermo
998995
! If the MOM6 dynamic and thermodynamic time stepping is being orchestrated

0 commit comments

Comments
 (0)