Skip to content

Commit

Permalink
fix: diag_manager hack for when starting with 2/29 and outputting yea…
Browse files Browse the repository at this point in the history
…rly data (NOAA-GFDL#1479)
  • Loading branch information
uramirez8707 authored and rem1776 committed May 1, 2024
1 parent e94bf0f commit 7e5bded
Showing 1 changed file with 17 additions and 0 deletions.
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
! 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

0 comments on commit 7e5bded

Please sign in to comment.