Skip to content

Commit

Permalink
Merge pull request #74 from COSIMA/fix_filename_leap_year
Browse files Browse the repository at this point in the history
handle ERA5 leap year Feb inputs
  • Loading branch information
aekiss authored Apr 7, 2022
2 parents ffecfde + 2f67753 commit 70e2c46
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions libutil/src/util.F90
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module util_mod

use netcdf
use datetime_module, only : datetime
use datetime_module, only : datetime, isLeapYear
use error_handler, only : assert
use, intrinsic :: iso_fortran_env, only : stderr=>error_unit

Expand Down Expand Up @@ -206,7 +206,11 @@ function filename_for_date(filename_template, date)
write(month_str, "(I2.2)") month

start_day = 1
end_day = DAYS_IN_MONTH(month)
if (isLeapYear(year) .and. month == 2) then
end_day = 29
else
end_day = DAYS_IN_MONTH(month)
end if
write(start_day_str, "(I2.2)") start_day
write(end_day_str, "(I2.2)") end_day

Expand Down

0 comments on commit 70e2c46

Please sign in to comment.