<MODULE PROCEDURE Example Program>
Module data_swap
Interface swap
Procedure int_swap, real_swap
End Interface
Contains
Subroutine int_swap(a,b)
Integer,Intent(InOut) :: a,b
Integer :: tmp
tmp = a
a = b
b = tmp
End Subroutine
Subroutine real_swap(a,b)
Real,Intent(InOut) :: a,b
Real :: tmp
tmp = a
a = b
b = tmp
End Subroutine
End Module
Program module_procedure_example
Use data_swap
Integer :: i,j
Real :: x,y
i = 10 ; j = 20
x = 3. ; y = 4.
Call swap(i,j)
Call swap(x,y)
Print *, i,j
Print *, x,y
End Program
■ Execution Results
20 10
4.0000000 3.0000000