Skip to content

Commit

Permalink
Fixed bug in AlarmIncrementMonths: increment month at end of loop
Browse files Browse the repository at this point in the history
Fixed an issue in routine AlarmIncrementMonths (in module
History/histcontainer_mod.F90).  We have to increment the month at the
end of the DO loop after updating the nDays variable.  Otherwise this
causes an incorrect count of days.

Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
  • Loading branch information
yantosca committed Feb 26, 2019
1 parent ca68f50 commit 98b0785
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions History/histcontainer_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1636,15 +1636,6 @@ SUBROUTINE AlarmIncrementMonths( IntervalYmd, Year, Month, Increment )
! Loop over the requested # of months
DO T = 0, nMonths-1

! Increment the month
MM = MM + 1

! Increment the year if we straddle New Year's Day
IF ( MM > 12 ) THEN
MM = 1
YYYY = YYYY + 1
ENDIF

! Keep a running total of the number of days in the interval
nDays = nDays + DpM(MM)

Expand All @@ -1653,6 +1644,15 @@ SUBROUTINE AlarmIncrementMonths( IntervalYmd, Year, Month, Increment )
nDays = nDays + 1
ENDIF

! Increment the month for next iteration
MM = MM + 1

! Also increment the year if we straddle New Year's Day
IF ( MM > 12 ) THEN
MM = 1
YYYY = YYYY + 1
ENDIF

ENDDO

! Convert from days to seconds
Expand Down

0 comments on commit 98b0785

Please sign in to comment.