<Example Program>
| Module vector_module Type vector Real :: x,y End Type vector Interface Assignment(=) Module Procedure v_asgn_int, v_asgn_real Module Procedure v_asgn_double End Interface Contains Subroutine v_asgn_int( this, a ) Integer, Intent(In) :: a Type(vector), Intent(Out) :: this this%x = -a ; this%y = -a End Subroutine v_asgn_int Subroutine v_asgn_real( this, a ) Real, Intent(In) :: a Type(vector), Intent(Out) :: this this%x = a*10. ; this%y = a*10. End Subroutine v_asgn_real Subroutine v_asgn_double( this, a ) Double Precision, Intent(In) :: a Type(vector), Intent(Out) :: this this%x = a*100. ; this%y = a*100. End Subroutine v_asgn_double End Module Program example_program Use vector_module Type(vector) a,b,c a = 2 b = 3. c = 4d0 Print *, a Print *, b Print *, c End Program |
|
Execution Results-2.0000000 -2.0000000 30.0000000 30.0000000 4.0000000E+02 4.0000000E+02 |
|