Skip to content
Snippets Groups Projects
Commit 6e737461 authored by Florian Prill's avatar Florian Prill
Browse files

hl interface: add element-wise addition of timedeltas.

parent c9c973db
No related branches found
No related tags found
No related merge requests found
......@@ -53,7 +53,7 @@ MODULE mtime_hl
PUBLIC :: OPERATOR(*)
! Re-export stuff
public :: register_finish_mtime_procedure, finish_mtime
public :: register_finish_mtime_procedure, finish_mtime
!
! TODO: simply repeat the implementation of "divisionquotienttimespan" in order to disentangle the mtime_hl and the mtime Fortran modules.
......@@ -157,7 +157,7 @@ MODULE mtime_hl
MODULE PROCEDURE t_datetime_assign_raw
END INTERFACE t_datetime
!> Wrapper class for "mtime" data type "timedelta".
!
......@@ -211,6 +211,7 @@ MODULE mtime_hl
PROCEDURE :: scalar_multiply_long => t_timedelta_scalar_multiply_long
PROCEDURE :: scalar_multiply_int => t_timedelta_scalar_multiply_int
PROCEDURE :: scalar_multiply_real => t_timedelta_scalar_multiply_real
PROCEDURE :: addElementWise => t_timedelta_addElementWise
PROCEDURE :: get_c_pointer => t_timedelta_get_c_pointer
......@@ -222,6 +223,7 @@ MODULE mtime_hl
GENERIC :: OPERATOR(>=) => greater_or_equal_datetime
GENERIC :: OPERATOR(*) => scalar_multiply_long, scalar_multiply_int, &
& scalar_multiply_real
GENERIC :: OPERATOR(+) => addElementWise
END TYPE t_timedelta
......
......@@ -123,7 +123,7 @@
FUNCTION t_datetime_sub_timedelta(this, td) RESULT(dt_td_sum)
TYPE (t_datetime) :: dt_td_sum
CLASS (t_datetime), INTENT(in) :: this
type (t_timedelta), INTENT(in) :: td
TYPE (t_timedelta), INTENT(in) :: td
TYPE(t_timedelta) :: td_tmp
TYPE(datetime), pointer :: dt_tmp
type(c_ptr) :: c_pointer1, c_pointer2, dummy_ptr
......
......@@ -335,3 +335,21 @@
& this%td%hour, this%td%minute, this%td%second, this%td%ms)
call handle_errno((.not. c_associated(c_pointer)), 5 * 100 + 2, __FILE__, __LINE__)
END FUNCTION t_timedelta_get_c_pointer
FUNCTION t_timedelta_addElementWise(this, td) RESULT(added_td)
TYPE (t_timedelta) :: added_td
CLASS(t_timedelta), INTENT(IN) :: this
TYPE (t_timedelta), INTENT(in) :: td
TYPE (c_ptr) :: c_pointer1, c_pointer2, dummy_ptr
TYPE(timedelta), POINTER :: td_tmp
c_pointer1 = this%get_c_pointer()
c_pointer2 = td%get_c_pointer()
dummy_ptr = my_elementwiseaddtimedeltatotimedelta(c_pointer1, c_pointer2, c_pointer1)
CALL handle_errno(.NOT. C_ASSOCIATED(dummy_ptr), 0 * 100 + 2, __FILE__, __LINE__)
CALL C_F_POINTER(c_pointer1, td_tmp)
CALL my_deallocatedatetime(c_pointer1)
CALL my_deallocatedatetime(c_pointer2)
added_td%td = td_tmp
END FUNCTION t_timedelta_addElementWise
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