module time_object
  implicit none

  type :: time
    integer :: hour,minute
  end type time

  interface operator(+)
    module procedure add_time_time
  end interface

  contains
    function add_time_time( a, b )
      implicit none
      type(time) :: add_time_time
      type(time), intent(in) :: a,b
      integer :: minutes,carry

      minutes=a%minute+b%minute
      carry=minutes/60
      add_time_time%minute=mod(minutes,60)
      add_time_time%hour=a%hour+b%hour+carry

      return
    end function add_time_time

    subroutine input( a )
      implicit none
      type(time), intent(out) :: a

      write(*,*) " Input hours:"
      read (*,*) a%hour
      write(*,*) " Input minutes:"
      read (*,*) a%minute

      return
    end subroutine input

    subroutine output( a )
      implicit none
      type(time), intent(in) :: a
      write(*, "(I3,'ours',I3,'minutes')") a%hour,a%minute
      return
    end subroutine output

end module time_object

program ex1103
  use time_object
  implicit none
  type(time) :: a,b,c

  call input(a)
  call input(b)
  c=a+b
  call output(c)

  stop
end program ex1103