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
3e17f701
Commit
3e17f701
authored
6 years ago
by
Florian Prill
Browse files
Options
Downloads
Patches
Plain Diff
removed assign operator and the need for UNINITIALIZED.
parent
9c535070
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/libmtime_hl.f90
+8
-61
8 additions, 61 deletions
src/libmtime_hl.f90
with
8 additions
and
61 deletions
src/libmtime_hl.f90
+
8
−
61
View file @
3e17f701
...
...
@@ -53,7 +53,8 @@ MODULE mtime_hl
!> NOTE / TODO:
!
! This "UNINITIALIZED" constant hints at a problem:
! Why does this wrapper module *not* implement the assignment
! operator? - Lenghty answer:
!
! The fundamental question is: Why do our "t_datetime",
! "t_timedelta", "t_xxx" types need assignment operators which
...
...
@@ -81,27 +82,16 @@ MODULE mtime_hl
! of "t_datetime" attempts to create an mtime "datetime" pointer
! based on the uninitializd "tmp_b%dt".
!
! It would be better to drop the "copy assign" implementations in
! libmtime_hl altogether. At least for the basic "datetime",
! "timedelta", "julianday" this is possible, since the data types
! do not contain data members on the heap.
!
! But what can we do for the more complex events? - We can work
! around this problem by defining "uninitialized states" which
! are recognized by the assign operator. Sigh!
!
INTEGER
(
c_int
),
PARAMETER
::
UNINITIALIZED
=
-1_c_int
!> Wrapper class for "mtime" data type "datetime".
!
TYPE
t_datetime
!private
!> wrapped datatype of the standard mtime interface
TYPE
(
datetime
)
::
dt
=
datetime
(
date
(
year
=
0_c_int64_t
,
month
=
UNINITIALIZED
,
day
=
0_c_int
),&
&
time
(
hour
=
0_c_int
,
minute
=
0_c_int
,
second
=
0_c_int
,
ms
=
0_c_int
))
!private
!> wrapped datatype of the standard mtime interface
TYPE
(
datetime
)
::
dt
CONTAINS
! --- conversions
...
...
@@ -126,7 +116,6 @@ MODULE mtime_hl
! --- overloaded operators
PROCEDURE
::
assign_t_datetime
PROCEDURE
::
add_timedelta
=>
t_datetime_add_timedelta
PROCEDURE
::
sub_timedelta
=>
t_datetime_sub_timedelta
PROCEDURE
::
sub_datetime
=>
t_datetime_sub_datetime
...
...
@@ -139,7 +128,6 @@ MODULE mtime_hl
PROCEDURE
::
get_c_pointer
=>
t_datetime_get_c_pointer
GENERIC
::
ASSIGNMENT
(
=
)
=>
assign_t_datetime
GENERIC
::
OPERATOR
(
+
)
=>
add_timedelta
GENERIC
::
OPERATOR
(
-
)
=>
sub_timedelta
GENERIC
::
OPERATOR
(
-
)
=>
sub_datetime
...
...
@@ -165,10 +153,8 @@ MODULE mtime_hl
!private
!> wrapped datatype of the standard mtime interface
TYPE
(
timedelta
)
::
td
=
timedelta
(
flag_std_form
=
0_c_int
,
sign
=
'+'
,
year
=
0_c_int64_t
,
&
&
month
=
UNINITIALIZED
,
day
=
0_c_int
,
hour
=
0_c_int
,
&
&
minute
=
0_c_int
,
second
=
0_c_int
,
ms
=
0_c_int
)
TYPE
(
timedelta
)
::
td
CONTAINS
! --- conversions
...
...
@@ -200,7 +186,6 @@ MODULE mtime_hl
! note: the "+", "-" operators are not well-defined for timedelta
! objects!
PROCEDURE
::
assign_t_timedelta
PROCEDURE
::
equal_datetime
=>
t_timedelta_equal
PROCEDURE
::
not_equal_datetime
=>
t_timedelta_not_equal
PROCEDURE
::
less_than_datetime
=>
t_timedelta_less_than
...
...
@@ -213,7 +198,6 @@ MODULE mtime_hl
PROCEDURE
::
get_c_pointer
=>
t_timedelta_get_c_pointer
GENERIC
::
ASSIGNMENT
(
=
)
=>
assign_t_timedelta
GENERIC
::
OPERATOR
(
==
)
=>
equal_datetime
GENERIC
::
OPERATOR
(/
=
)
=>
not_equal_datetime
GENERIC
::
OPERATOR
(
<
)
=>
less_than_datetime
...
...
@@ -421,24 +405,6 @@ CONTAINS
! datetime section:
! ================================================================================
! generic assignment for constructors
!
SUBROUTINE
assign_t_datetime
(
to
,
from
)
CLASS
(
t_datetime
),
INTENT
(
out
)
::
to
CLASS
(
t_datetime
),
INTENT
(
in
)
::
from
TYPE
(
datetime
),
POINTER
::
dt_tmp
INTEGER
::
errno
! first, check if "from" is an initialized t_datetime object:
IF
(
from
%
dt
%
date
%
month
/
=
UNINITIALIZED
)
THEN
dt_tmp
=>
newdatetime
(
from
%
dt
,
errno
)
CALL
handle_errno
(
errno
,
__
FILE__
,
__
LINE__
)
to
%
dt
=
dt_tmp
CALL
deallocatedatetime
(
dt_tmp
)
ELSE
to
%
dt
=
from
%
dt
END
IF
END
SUBROUTINE
assign_t_datetime
! constructor for a datetime string
!
...
...
@@ -652,25 +618,6 @@ CONTAINS
! timedelta section:
! ================================================================================
! generic assignment for constructors
!
SUBROUTINE
assign_t_timedelta
(
to
,
from
)
CLASS
(
t_timedelta
),
INTENT
(
out
)
::
to
CLASS
(
t_timedelta
),
INTENT
(
in
)
::
from
TYPE
(
timedelta
),
POINTER
::
td_tmp
INTEGER
::
errno
! first, check if "from" is an initialized t_datetime object:
IF
(
from
%
td
%
month
/
=
UNINITIALIZED
)
THEN
td_tmp
=>
newTimedelta
(
from
%
td
,
errno
)
CALL
handle_errno
(
errno
,
__
FILE__
,
__
LINE__
)
to
%
td
=
td_tmp
to
%
td
%
sign
=
td_tmp
%
sign
CALL
deallocateTimedelta
(
td_tmp
)
ELSE
to
%
td
=
from
%
td
END
IF
END
SUBROUTINE
assign_t_timedelta
! constructor for timedelta string
!
...
...
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