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
96411e6e
Commit
96411e6e
authored
8 years ago
by
Florian Prill
Browse files
Options
Downloads
Patches
Plain Diff
added error handling to two HL procedures.
parent
d5b9afd6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
examples/example_hl.f90
+1
-1
1 addition, 1 deletion
examples/example_hl.f90
src/error_handling.f90
+2
-0
2 additions, 0 deletions
src/error_handling.f90
src/libmtime_hl.f90
+43
-15
43 additions, 15 deletions
src/libmtime_hl.f90
with
46 additions
and
16 deletions
examples/example_hl.f90
+
1
−
1
View file @
96411e6e
...
...
@@ -66,7 +66,7 @@ PROGRAM example
! CALL timedeltaToString(td, dstring2)
! WRITE (0,*) "compute ", dstring1, " + ", dstring2
WRITE
(
0
,
*
)
"compute "
,
dt
%
to_string
(),
" + "
,
td
%
to_string
()
WRITE
(
0
,
*
)
"compute "
,
dt
%
to_string
(),
" + "
,
td
%
to_string
()
! Adding time intervals is unchanged:
...
...
This diff is collapsed.
Click to expand it.
src/error_handling.f90
+
2
−
0
View file @
96411e6e
...
...
@@ -20,6 +20,8 @@ MODULE error_handling
PUBLIC
::
create_error
PUBLIC
::
transfer_error
PUBLIC
::
MAX_ERROR_STR_LEN
INTEGER
,
PARAMETER
::
MAX_ERROR_STR_LEN
=
256
...
...
This diff is collapsed.
Click to expand it.
src/libmtime_hl.f90
+
43
−
15
View file @
96411e6e
...
...
@@ -11,6 +11,7 @@
module
mtime_hl
use
mtime
USE
error_handling
implicit
none
...
...
@@ -76,16 +77,32 @@ module mtime_hl
end
type
t_timedelta
!> Error info type: mtime error
TYPE
,
EXTENDS
(
t_error_info
)
::
t_mtime_error
END
TYPE
t_mtime_error
contains
! Convert t_datetime object to string.
!
function
t_datetime_to_string
(
this
)
character
(
len
=
max_datetime_str_len
)
::
t_datetime_to_string
class
(
t_datetime
)
::
this
type
(
datetime
),
pointer
::
dt_tmp
FUNCTION
t_datetime_to_string
(
this
,
opt_error
)
character
(
len
=
max_datetime_str_len
)
::
t_datetime_to_string
TYPE
(
t_error
),
INTENT
(
OUT
),
OPTIONAL
::
opt_error
class
(
t_datetime
)
::
this
type
(
datetime
),
pointer
::
dt_tmp
INTEGER
::
errno
CHARACTER
(
len
=
MAX_ERROR_STR_LEN
)
::
error_str
dt_tmp
=>
newDatetime
(
this
%
dt
)
call
datetimeToString
(
dt_tmp
,
t_datetime_to_string
)
IF
(
PRESENT
(
opt_error
))
THEN
CALL
datetimeToString
(
dt_tmp
,
t_datetime_to_string
,
errno
)
IF
(
errno
/
=
0
)
THEN
CALL
mtime_strerror
(
errno
,
error_str
)
CALL
create_error
(
opt_error
,
t_mtime_error
(
error_str
))
END
IF
ELSE
CALL
datetimeToString
(
dt_tmp
,
t_datetime_to_string
)
END
IF
call
deallocateDatetime
(
dt_tmp
)
end
function
t_datetime_to_string
...
...
@@ -165,21 +182,32 @@ contains
! Convert t_timedelta object to string.
!
function
t_timedelta_to_string
(
this
)
FUNCTION
t_timedelta_to_string
(
this
,
opt_error
)
character
(
len
=
max_timedelta_str_len
)
::
t_timedelta_to_string
class
(
t_timedelta
)
::
this
type
(
timedelta
),
pointer
::
td_tmp
class
(
t_timedelta
)
::
this
TYPE
(
t_error
),
INTENT
(
OUT
),
OPTIONAL
::
opt_error
type
(
timedelta
),
pointer
::
td_tmp
INTEGER
::
errno
CHARACTER
(
len
=
MAX_ERROR_STR_LEN
)
::
error_str
td_tmp
=>
newTimedelta
(
this
%
td
)
call
timedeltaToString
(
td_tmp
,
t_timedelta_to_string
)
call
deallocateTimedelta
(
td_tmp
)
end
function
t_timedelta_to_string
IF
(
PRESENT
(
opt_error
))
THEN
CALL
timedeltaToString
(
td_tmp
,
t_timedelta_to_string
,
errno
)
IF
(
errno
/
=
0
)
THEN
CALL
mtime_strerror
(
errno
,
error_str
)
CALL
create_error
(
opt_error
,
t_mtime_error
(
error_str
))
END
IF
ELSE
CALL
timedeltaToString
(
td_tmp
,
t_timedelta_to_string
)
END
IF
CALL
deallocateTimedelta
(
td_tmp
)
END
FUNCTION
t_timedelta_to_string
! Assignment operator: this = "time interval string".
!
subroutine
t_timedelta_assign_string
(
this
,
td_string
)
class
(
t_timedelta
),
intent
(
out
)
::
this
character
(
len
=*
),
intent
(
in
)
::
td_string
type
(
timedelta
),
pointer
::
td_tmp
SUBROUTINE
t_timedelta_assign_string
(
this
,
td_string
)
CLASS
(
t_timedelta
),
INTENT
(
out
)
::
this
CHARACTER
(
len
=*
),
INTENT
(
in
)
::
td_string
TYPE
(
timedelta
),
POINTER
::
td_tmp
td_tmp
=>
newTimedelta
(
td_string
)
this
%
td
=
td_tmp
this
%
td
%
sign
=
td_tmp
%
sign
...
...
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