Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libmtime
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
icon-libraries
libmtime
Commits
a59faf8a
Commit
a59faf8a
authored
5 years ago
by
Luis Kornblueh
Browse files
Options
Downloads
Patches
Plain Diff
Correct comp_weights for the bug found by Helmut Frank
parent
72d220f4
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/comp_weights.f90
+19
-7
19 additions, 7 deletions
examples/comp_weights.f90
with
19 additions
and
7 deletions
examples/comp_weights.f90
+
19
−
7
View file @
a59faf8a
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment