Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Diag_manager: Leap day fix #1479

Merged
merged 1 commit into from
Mar 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions diag_manager/fms_diag_time_utils.F90
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@ TYPE(time_type) FUNCTION diag_forecast_time_inc(time, output_freq, output_units,

CHARACTER(len=128) :: error_message_local !< Local variable to store the error_message

integer :: cyear !< The current year stored in the time type
integer :: cmonth !< The current month stored in the time type
integer :: cday !< The current day stored in the time type
integer :: chour !< The current hour stored in the time type
integer :: cmin !< The current minute stored in the time type
integer :: csecond !< The current second stored in the time type

IF ( PRESENT(err_msg) ) err_msg = ''
error_message_local = ''

Expand Down Expand Up @@ -180,7 +187,17 @@ TYPE(time_type) FUNCTION diag_forecast_time_inc(time, output_freq, output_units,
IF ( get_calendar_type() == NO_CALENDAR ) THEN
error_message_local = 'output units of years NOT allowed with no calendar'
ELSE
call get_date(Time, cyear, cmonth, cday, chour, cmin, csecond)
if (cmonth .eq. 2 .and. cday .eq. 29) then
!! TODO this is a hack, the leap year issue should be fixed inside increment_date instead
!! increment_date should also be updated to work in cases like when the frequency is 1 month and you
!! are starting from 1/31
Comment on lines +192 to +194
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

! This is a leap year, so increment the date from 2/28 instead
diag_forecast_time_inc = increment_date(set_date(cyear, cmonth, 28, chour, cmin, csecond), &
output_freq, 0, 0, 0, 0, 0, err_msg=error_message_local)
else
diag_forecast_time_inc = increment_date(time, output_freq, 0, 0, 0, 0, 0, err_msg=error_message_local)
endif
END IF
ELSE
error_message_local = 'illegal output units'
Expand Down
Loading