Skip to content

Commit

Permalink
Bug fix for write_energy with short dt
Browse files Browse the repository at this point in the history
Fix a bug with subroutine write_energy when using a DT<2. Otherwise,
the energy outputs are written at wrong time steps.

The reason was that time type divide is essentially a floor.
So DT/2 = 0 if DT<2.
  • Loading branch information
herrwang0 authored and Hallberg-NOAA committed Nov 30, 2024
1 parent 2b72682 commit 98f0a69
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/diagnostics/MOM_sum_output.F90
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ module MOM_sum_output
use MOM_io, only : attribute_info, set_attribute_info, delete_attribute_info
use MOM_io, only : APPEND_FILE, SINGLE_FILE, WRITEONLY_FILE
use MOM_spatial_means, only : array_global_min_max
use MOM_time_manager, only : time_type, get_time, get_date, set_time, operator(>)
use MOM_time_manager, only : time_type, get_time, get_date, set_time
use MOM_time_manager, only : operator(+), operator(-), operator(*), operator(/)
use MOM_time_manager, only : operator(/=), operator(<=), operator(>=), operator(<)
use MOM_time_manager, only : operator(/=), operator(<=), operator(>=), operator(<), operator(>)
use MOM_time_manager, only : get_calendar_type, time_type_to_real, NO_CALENDAR
use MOM_tracer_flow_control, only : tracer_flow_control_CS, call_tracer_stocks
use MOM_unit_scaling, only : unit_scale_type
Expand Down Expand Up @@ -489,7 +489,7 @@ subroutine write_energy(u, v, h, tv, day, n, G, GV, US, CS, tracer_CSp, dt_forci
CS%write_energy_time = CS%Start_time + CS%energysavedays * &
(1 + (day - CS%Start_time) / CS%energysavedays)
endif
elseif (day + (dt_force/2) <= CS%write_energy_time) then
elseif (day + (dt_force/2) < CS%write_energy_time) then
return ! Do not write this step
else ! Determine the next write time before proceeding
if (CS%energysave_geometric) then
Expand Down

0 comments on commit 98f0a69

Please sign in to comment.