module module1 ! compile with: f90 -c module1.f90 ! results in files: module1.o and module1.mod implicit none type mine private integer :: a real :: b end type mine interface assignment (=) module procedure let end interface public assignment (=) interface operator (+) module procedure plus end interface public operator (+) interface huge module procedure very_huge end interface public huge contains subroutine let(output, input) type (mine), intent(out) :: output type (mine), intent(in) :: input output%a = input%a output%b = input%b end subroutine let function plus(x, y) result(output) type (mine) :: output type (mine), intent(in) :: x type (mine), intent(in) :: y output=mine(x%a+y%a, x%b+y%b) end function plus function very_huge(x) result(output) type (mine) :: output type (mine), intent(in) :: x output=mine(huge(x%a), huge(x%b)) end function very_huge subroutine subr1(x) type (mine), intent(inout) :: x x%a = x%a + int(x%b) x%b = x%b + real(x%a) end subroutine subr1 function funct1() result(x) type (mine) :: x x = mine(1, 2.0) end function funct1 subroutine print1(x) type (mine), intent(in) :: x print *, x%a, x%b end subroutine print1 end module module1