Skip to content
Snippets Groups Projects
Commit a59faf8a authored by Luis Kornblueh's avatar Luis Kornblueh
Browse files

Correct comp_weights for the bug found by Helmut Frank

parent 72d220f4
No related branches found
No related tags found
No related merge requests found
......@@ -39,6 +39,13 @@ program comp_weights
call calculate_time_interpolation_weights(test_date, m1, m2, pw1, pw2)
write(0,*) 'mtime 1: ', m1, m2, pw1, pw2
call deallocateDatetime(test_date)
!-> new tests
test_date => newDatetime('2017-08-31T00:00:00')
call calculate_time_interpolation_weights(test_date, m1, m2, pw1, pw2)
write(0,*) 'mtime 2: ', m1, m2, pw1, pw2
call deallocateDatetime(test_date)
contains
......@@ -184,15 +191,19 @@ contains
integer :: errno
days_in_month = getNoOfDaysInMonthDateTime(current_date)
print *, 'days in month: ', days_in_month
seconds_in_middle_of_month = 43200 * days_in_month ! 86400 * my_month_len / 2
print *, 'seconds in middle of month: ', seconds_in_middle_of_month
seconds_in_month = getNoOfSecondsElapsedInMonthDateTime(current_date)
print *, 'seconds in month: ', seconds_in_month
if (seconds_in_month <= seconds_in_middle_of_month) then
! first half of month
print *, "first half of month"
one_month => newTimedelta('-P1M')
previous_month => newDatetime(current_date)
previous_month = current_date + one_month
previous_month => newDatetime(current_date%date%year, current_date%date%month, 15, 0, 0, 0, 0)
! use patched current_date stored in previous_month to get a proper previous month
previous_month = previous_month + one_month
days_in_previous_month = getNoOfDaysInMonthDateTime(previous_month)
seconds_in_middle_of_previous_month = 43200 * days_in_previous_month ! 86400 * my_month_len / 2
! simple linear interpolation
......@@ -203,10 +214,11 @@ contains
month2 = current_date%date%month
else
! second half of month
print *, "second half of month"
one_month => newTimedelta('P1M')
next_month => newDatetime(current_date)
next_month = current_date + one_month
next_month => newDatetime(current_date%date%year, current_date%date%month, 15, 0, 0, 0, 0)
! use patched current_date stored in next_month to get a proper next month
next_month = next_month + one_month
days_in_next_month = getNoOfDaysInMonthDateTime(next_month)
seconds_in_middle_of_next_month = 43200 * days_in_next_month ! 86400 * my_month_len / 2
! simple linear interpolation
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment